Mesa (master): tgsi/dump: shared dump_ctx initialization

Nicolai Hähnle nh at kemper.freedesktop.org
Fri Apr 29 16:41:39 UTC 2016


Module: Mesa
Branch: master
Commit: e08eaa5b723a22301f117ac6120c3d9cd399855e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e08eaa5b723a22301f117ac6120c3d9cd399855e

Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
Date:   Thu Apr 28 15:29:23 2016 -0500

tgsi/dump: shared dump_ctx initialization

Reviewed-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/auxiliary/tgsi/tgsi_dump.c | 48 ++++++++++++----------------------
 1 file changed, 17 insertions(+), 31 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index f57f2bb..9482644 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;




More information about the mesa-commit mailing list