summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi/tgsi_dump.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2015-01-22 15:18:05 +1000
committerDave Airlie <airlied@redhat.com>2015-10-23 11:57:56 +1000
commit531f5d1270782927911c5c720201e86c6f40182d (patch)
tree98d0298dfe7b42bfc4dac91cc7b815ed28ac2e69 /src/gallium/auxiliary/tgsi/tgsi_dump.c
parent041081dc219dcf7f61748284033c6fd7627acc69 (diff)
downloadexternal_mesa3d-531f5d1270782927911c5c720201e86c6f40182d.zip
external_mesa3d-531f5d1270782927911c5c720201e86c6f40182d.tar.gz
external_mesa3d-531f5d1270782927911c5c720201e86c6f40182d.tar.bz2
tgsi: try and handle overflowing shaders. (v2)
This is used to detect error in virgl if we overflow the shader dumping buffers. v2: return a bool. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_dump.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index 3470739..e29ffb3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -709,6 +709,7 @@ struct str_dump_ctx
char *str;
char *ptr;
int left;
+ bool nospace;
};
static void
@@ -731,10 +732,11 @@ str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
sctx->ptr += written;
sctx->left -= written;
}
- }
+ } else
+ sctx->nospace = true;
}
-void
+bool
tgsi_dump_str(
const struct tgsi_token *tokens,
uint flags,
@@ -761,6 +763,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;
@@ -768,6 +771,8 @@ tgsi_dump_str(
ctx.base.dump_float_as_hex = FALSE;
tgsi_iterate_shader( tokens, &ctx.base.iter );
+
+ return !ctx.nospace;
}
void
@@ -790,6 +795,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 );
}