summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2016-04-28 15:29:23 -0500
committerNicolai Hähnle <[email protected]>2016-04-29 11:39:21 -0500
commite08eaa5b723a22301f117ac6120c3d9cd399855e (patch)
tree6a73e344548a9f500d85a8745460ff65aaff9a94 /src/gallium/auxiliary/tgsi
parent4b1ea6910ee54afb30fd005eb1f8cf6f88338eda (diff)
tgsi/dump: shared dump_ctx initialization
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index f57f2bbcc18..94826446525 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -705,30 +705,31 @@ prolog(
return TRUE;
}
+static void
+init_dump_ctx(struct dump_ctx *ctx, uint flags)
+{
+ memset(ctx, 0, sizeof(*ctx));
+
+ ctx->iter.prolog = prolog;
+ ctx->iter.iterate_instruction = iter_instruction;
+ ctx->iter.iterate_declaration = iter_declaration;
+ ctx->iter.iterate_immediate = iter_immediate;
+ ctx->iter.iterate_property = iter_property;
+
+ if (flags & TGSI_DUMP_FLOAT_AS_HEX)
+ ctx->dump_float_as_hex = TRUE;
+}
+
void
tgsi_dump_to_file(const struct tgsi_token *tokens, uint flags, FILE *file)
{
struct dump_ctx ctx;
- ctx.iter.prolog = prolog;
- ctx.iter.iterate_instruction = iter_instruction;
- ctx.iter.iterate_declaration = iter_declaration;
- ctx.iter.iterate_immediate = iter_immediate;
- ctx.iter.iterate_property = iter_property;
- ctx.iter.epilog = NULL;
+ init_dump_ctx(&ctx, flags);
- ctx.instno = 0;
- ctx.immno = 0;
- ctx.indent = 0;
ctx.dump_printf = dump_ctx_printf;
- ctx.indentation = 0;
ctx.file = file;
- if (flags & TGSI_DUMP_FLOAT_AS_HEX)
- ctx.dump_float_as_hex = TRUE;
- else
- ctx.dump_float_as_hex = FALSE;
-
tgsi_iterate_shader( tokens, &ctx.iter );
}
@@ -780,19 +781,9 @@ tgsi_dump_str(
{
struct str_dump_ctx ctx;
- ctx.base.iter.prolog = prolog;
- ctx.base.iter.iterate_instruction = iter_instruction;
- ctx.base.iter.iterate_declaration = iter_declaration;
- ctx.base.iter.iterate_immediate = iter_immediate;
- ctx.base.iter.iterate_property = iter_property;
- ctx.base.iter.epilog = NULL;
+ init_dump_ctx(&ctx.base, flags);
- ctx.base.instno = 0;
- ctx.base.immno = 0;
- ctx.base.indent = 0;
ctx.base.dump_printf = &str_dump_ctx_printf;
- ctx.base.indentation = 0;
- ctx.base.file = NULL;
ctx.str = str;
ctx.str[0] = 0;
@@ -800,11 +791,6 @@ tgsi_dump_str(
ctx.left = (int)size;
ctx.nospace = false;
- if (flags & TGSI_DUMP_FLOAT_AS_HEX)
- ctx.base.dump_float_as_hex = TRUE;
- else
- ctx.base.dump_float_as_hex = FALSE;
-
tgsi_iterate_shader( tokens, &ctx.base.iter );
return !ctx.nospace;