diff options
author | Dave Airlie <airlied@redhat.com> | 2015-01-22 15:18:05 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2015-10-13 14:30:52 +1000 |
commit | cd97fe9d0a217755ba78649f795f60c3f02741de (patch) | |
tree | 7c6486da2199cee406a765ea35fed4e93feb13d4 | |
parent | bbe150067c46ad7e14d764b1a31fd42977925c2f (diff) |
tgsi: try and handle overflowing shaders.
This is used to detect error in virgl if we overflow the shader
dumping buffers.
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_dump.c | 10 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_dump.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 33f6a56d945..f3417832bd8 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -708,6 +708,7 @@ struct str_dump_ctx char *str; char *ptr; int left; + bool nospace; }; static void @@ -730,10 +731,11 @@ str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...) sctx->ptr += written; sctx->left -= written; } - } + } else + sctx->nospace = true; } -void +int tgsi_dump_str( const struct tgsi_token *tokens, uint flags, @@ -760,6 +762,7 @@ tgsi_dump_str( ctx.str[0] = 0; ctx.ptr = str; ctx.left = (int)size; + ctx.nospace = false; if (flags & TGSI_DUMP_FLOAT_AS_HEX) ctx.base.dump_float_as_hex = TRUE; @@ -767,6 +770,8 @@ tgsi_dump_str( ctx.base.dump_float_as_hex = FALSE; tgsi_iterate_shader( tokens, &ctx.base.iter ); + + return (ctx.nospace == true) ? -1 : 0; } void @@ -789,6 +794,7 @@ tgsi_dump_instruction_str( ctx.str[0] = 0; ctx.ptr = str; ctx.left = (int)size; + ctx.nospace = false; iter_instruction( &ctx.base.iter, (struct tgsi_full_instruction *)inst ); } diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.h b/src/gallium/auxiliary/tgsi/tgsi_dump.h index 6666b983e9c..f800be57eec 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.h +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.h @@ -40,7 +40,7 @@ extern "C" { #define TGSI_DUMP_FLOAT_AS_HEX (1 << 0) -void +int tgsi_dump_str( const struct tgsi_token *tokens, uint flags, |