From ec6ad7ba3ce4fa71620642ddde06cf843d1c8d54 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Jun 2009 07:42:49 -0600 Subject: mesa: added _mesa_postprocess_program() to aid shader debugging --- src/mesa/shader/program.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src/mesa/shader/program.c') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index d270bf9e1c..b56308b029 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -820,3 +820,61 @@ _mesa_find_free_register(const struct gl_program *prog, GLuint regFile) return -1; } + + + +/** + * "Post-process" a GPU program. This is intended to be used for debugging. + * Example actions include no-op'ing instructions or changing instruction + * behaviour. + */ +void +_mesa_postprocess_program(GLcontext *ctx, struct gl_program *prog) +{ + static const GLfloat white[4] = { 0.5, 0.5, 0.5, 0.5 }; + GLuint i; + GLuint whiteSwizzle; + GLint whiteIndex = _mesa_add_unnamed_constant(prog->Parameters, + white, 4, &whiteSwizzle); + + for (i = 0; i < prog->NumInstructions; i++) { + struct prog_instruction *inst = prog->Instructions + i; + const GLuint n = _mesa_num_inst_src_regs(inst->Opcode); + + (void) n; + + if (_mesa_is_tex_instruction(inst->Opcode)) { +#if 0 + /* replace TEX/TXP/TXB with MOV */ + inst->Opcode = OPCODE_MOV; + inst->DstReg.WriteMask = WRITEMASK_XYZW; + inst->SrcReg[0].Swizzle = SWIZZLE_XYZW; + inst->SrcReg[0].Negate = NEGATE_NONE; +#endif + +#if 0 + /* disable shadow texture mode */ + inst->TexShadow = 0; +#endif + } + + if (inst->Opcode == OPCODE_TXP) { +#if 0 + inst->Opcode = OPCODE_MOV; + inst->DstReg.WriteMask = WRITEMASK_XYZW; + inst->SrcReg[0].File = PROGRAM_CONSTANT; + inst->SrcReg[0].Index = whiteIndex; + inst->SrcReg[0].Swizzle = SWIZZLE_XYZW; + inst->SrcReg[0].Negate = NEGATE_NONE; +#endif +#if 0 + inst->TexShadow = 0; +#endif +#if 0 + inst->Opcode = OPCODE_TEX; + inst->TexShadow = 0; +#endif + } + + } +} -- cgit v1.2.3 From 516d20fd2688fce833b764ca21f1f1772bed0a03 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Jun 2009 07:43:44 -0600 Subject: mesa: silence warning --- src/mesa/shader/program.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa/shader/program.c') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index b56308b029..4623ff60de 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -837,6 +837,8 @@ _mesa_postprocess_program(GLcontext *ctx, struct gl_program *prog) GLint whiteIndex = _mesa_add_unnamed_constant(prog->Parameters, white, 4, &whiteSwizzle); + (void) whiteIndex; + for (i = 0; i < prog->NumInstructions; i++) { struct prog_instruction *inst = prog->Instructions + i; const GLuint n = _mesa_num_inst_src_regs(inst->Opcode); -- cgit v1.2.3