From: Nicolai Hähnle Date: Thu, 28 Apr 2016 20:29:23 +0000 (-0500) Subject: tgsi/dump: shared dump_ctx initialization X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e08eaa5b723a22301f117ac6120c3d9cd399855e;p=mesa.git tgsi/dump: shared dump_ctx initialization Reviewed-by: Dave Airlie --- 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;