From a29e40a42382630c2d9d95d3a1e03a7b3db87add Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 14 Nov 2013 14:02:24 +0000 Subject: gallivm: Compile flag to debug TGSI execution through printfs. It is similar to tgsi_exec.c's DEBUG_EXECUTION compile flag. I had prototyped this for a while while debugging an issue, but finally cleaned this up and added a few more bells and whistles. v2: Use '$' as marker; better output. Thanks to Brian, Zack and Roland reviews. Here is a sample output. CONST[0].x = 0.00625000009 0.00625000009 0.00625000009 0.00625000009 CONST[0].y = -0.00714285718 -0.00714285718 -0.00714285718 -0.00714285718 CONST[0].z = -1 -1 -1 -1 CONST[0].w = 1 1 1 1 IN[0].x = 143.5 175.5 175.5 143.5 IN[0].y = 123.5 123.5 155.5 155.5 IN[0].z = 0 0 0 0 IN[0].w = 1 1 1 1 $ 1: RCP TEMP[0].w, IN[0].wwww TEMP[0].w = 1 1 1 1 $ 2: MAD TEMP[0].xy, IN[0], CONST[0], CONST[0].zwzw TEMP[0].x = -0.103124976 0.0968750715 0.0968750715 -0.103124976 TEMP[0].y = 0.117857158 0.117857158 -0.110714316 -0.110714316 $ 3: MUL OUT[0].xy, TEMP[0], TEMP[0].wwww OUT[0].x = -0.103124976 0.0968750715 0.0968750715 -0.103124976 OUT[0].y = 0.117857158 0.117857158 -0.110714316 -0.110714316 $ 4: MUL OUT[0].z, IN[0].zzzz, TEMP[0].wwww OUT[0].z = 0 0 0 0 $ 5: MOV OUT[0].w, TEMP[0] OUT[0].w = 1 1 1 1 $ 6: END OUT[0].x = -0.103124976 0.0968750715 0.0968750715 -0.103124976 OUT[0].y = 0.117857158 0.117857158 -0.110714316 -0.110714316 OUT[0].z = 0 0 0 0 OUT[0].w = 1 1 1 1 --- src/gallium/auxiliary/tgsi/tgsi_dump.c | 23 +++++++++++++++++++++++ src/gallium/auxiliary/tgsi/tgsi_dump.h | 7 +++++++ 2 files changed, 30 insertions(+) (limited to 'src/gallium/auxiliary/tgsi') diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 7f6a3d8ad8f..77bca623082 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -721,3 +721,26 @@ tgsi_dump_str( tgsi_iterate_shader( tokens, &ctx.base.iter ); } + +void +tgsi_dump_instruction_str( + const struct tgsi_full_instruction *inst, + uint instno, + char *str, + size_t size) +{ + struct str_dump_ctx ctx; + + ctx.base.instno = instno; + ctx.base.immno = instno; + ctx.base.indent = 0; + ctx.base.dump_printf = &str_dump_ctx_printf; + ctx.base.indentation = 0; + + ctx.str = str; + ctx.str[0] = 0; + ctx.ptr = str; + ctx.left = (int)size; + + 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 adaef9d89fe..9820bb1cacf 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.h +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.h @@ -57,6 +57,13 @@ void tgsi_dump_immediate( const struct tgsi_full_immediate *imm ); +void +tgsi_dump_instruction_str( + const struct tgsi_full_instruction *inst, + uint instno, + char *str, + size_t size); + void tgsi_dump_instruction( const struct tgsi_full_instruction *inst, -- cgit v1.2.3