diff options
Diffstat (limited to 'src/mesa/shader/prog_print.c')
-rw-r--r-- | src/mesa/shader/prog_print.c | 82 |
1 files changed, 51 insertions, 31 deletions
diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index ce48767a87..b832ddb477 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -43,7 +43,7 @@ * Return string name for given program/register file. */ static const char * -file_string(enum register_file f, gl_prog_print_mode mode) +file_string(gl_register_file f, gl_prog_print_mode mode) { switch (f) { case PROGRAM_TEMPORARY: @@ -86,6 +86,9 @@ file_string(enum register_file f, gl_prog_print_mode mode) static const char * arb_input_attrib_string(GLint index, GLenum progType) { + /* + * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens. + */ const char *vertAttribs[] = { "vertex.position", "vertex.weight", @@ -160,6 +163,9 @@ arb_input_attrib_string(GLint index, GLenum progType) static const char * arb_output_attrib_string(GLint index, GLenum progType) { + /* + * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens. + */ const char *vertResults[] = { "result.position", "result.color.primary", @@ -184,7 +190,12 @@ arb_output_attrib_string(GLint index, GLenum progType) }; const char *fragResults[] = { "result.color", - "result.depth" + "result.color(half)", + "result.depth", + "result.color[0]", + "result.color[1]", + "result.color[2]", + "result.color[3]" }; if (progType == GL_VERTEX_PROGRAM_ARB) { @@ -202,25 +213,23 @@ arb_output_attrib_string(GLint index, GLenum progType) * Return string representation of the given register. * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined * by the ARB/NV program languages so we've taken some liberties here. - * \param file the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc) + * \param f the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc) * \param index number of the register in the register file * \param mode the output format/mode/style * \param prog pointer to containing program */ static const char * -reg_string(enum register_file f, GLint index, gl_prog_print_mode mode, +reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, GLboolean relAddr, const struct gl_program *prog) { static char str[100]; + const char *addr = relAddr ? "ADDR+" : ""; str[0] = 0; switch (mode) { case PROG_PRINT_DEBUG: - if (relAddr) - _mesa_sprintf(str, "%s[ADDR+%d]", file_string(f, mode), index); - else - _mesa_sprintf(str, "%s[%d]", file_string(f, mode), index); + _mesa_sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index); break; case PROG_PRINT_ARB: @@ -235,19 +244,19 @@ reg_string(enum register_file f, GLint index, gl_prog_print_mode mode, _mesa_sprintf(str, "temp%d", index); break; case PROGRAM_ENV_PARAM: - _mesa_sprintf(str, "program.env[%d]", index); + _mesa_sprintf(str, "program.env[%s%d]", addr, index); break; case PROGRAM_LOCAL_PARAM: - _mesa_sprintf(str, "program.local[%d]", index); + _mesa_sprintf(str, "program.local[%s%d]", addr, index); break; case PROGRAM_VARYING: /* extension */ - _mesa_sprintf(str, "varying[%d]", index); + _mesa_sprintf(str, "varying[%s%d]", addr, index); break; case PROGRAM_CONSTANT: /* extension */ - _mesa_sprintf(str, "constant[%d]", index); + _mesa_sprintf(str, "constant[%s%d]", addr, index); break; case PROGRAM_UNIFORM: /* extension */ - _mesa_sprintf(str, "uniform[%d]", index); + _mesa_sprintf(str, "uniform[%s%d]", addr, index); break; case PROGRAM_STATE_VAR: { @@ -284,16 +293,16 @@ reg_string(enum register_file f, GLint index, gl_prog_print_mode mode, _mesa_sprintf(str, "c[%d]", index); break; case PROGRAM_VARYING: /* extension */ - _mesa_sprintf(str, "varying[%d]", index); + _mesa_sprintf(str, "varying[%s%d]", addr, index); break; case PROGRAM_UNIFORM: /* extension */ - _mesa_sprintf(str, "uniform[%d]", index); + _mesa_sprintf(str, "uniform[%s%d]", addr, index); break; case PROGRAM_CONSTANT: /* extension */ - _mesa_sprintf(str, "constant[%d]", index); + _mesa_sprintf(str, "constant[%s%d]", addr, index); break; case PROGRAM_STATE_VAR: /* extension */ - _mesa_sprintf(str, "state[%d]", index); + _mesa_sprintf(str, "state[%s%d]", addr, index); break; default: _mesa_problem(NULL, "bad file in reg_string()"); @@ -423,7 +432,7 @@ fprint_dst_reg(FILE * f, const struct gl_program *prog) { _mesa_fprintf(f, "%s%s", - reg_string((enum register_file) dstReg->File, + reg_string((gl_register_file) dstReg->File, dstReg->Index, mode, dstReg->RelAddr, prog), _mesa_writemask_string(dstReg->WriteMask)); @@ -436,7 +445,7 @@ fprint_dst_reg(FILE * f, #if 0 _mesa_fprintf(f, "%s[%d]%s", - file_string((enum register_file) dstReg->File, mode), + file_string((gl_register_file) dstReg->File, mode), dstReg->Index, _mesa_writemask_string(dstReg->WriteMask)); #endif @@ -449,14 +458,18 @@ fprint_src_reg(FILE *f, gl_prog_print_mode mode, const struct gl_program *prog) { - _mesa_fprintf(f, "%s%s", - reg_string((enum register_file) srcReg->File, + const char *abs = srcReg->Abs ? "|" : ""; + + _mesa_fprintf(f, "%s%s%s%s", + abs, + reg_string((gl_register_file) srcReg->File, srcReg->Index, mode, srcReg->RelAddr, prog), _mesa_swizzle_string(srcReg->Swizzle, - srcReg->NegateBase, GL_FALSE)); + srcReg->NegateBase, GL_FALSE), + abs); #if 0 _mesa_fprintf(f, "%s[%d]%s", - file_string((enum register_file) srcReg->File, mode), + file_string((gl_register_file) srcReg->File, mode), srcReg->Index, _mesa_swizzle_string(srcReg->Swizzle, srcReg->NegateBase, GL_FALSE)); @@ -549,7 +562,7 @@ _mesa_fprint_instruction_opt(FILE *f, if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { _mesa_fprintf(f, ", "); _mesa_fprintf(f, "%s[%d]%s", - file_string((enum register_file) inst->SrcReg[0].File, + file_string((gl_register_file) inst->SrcReg[0].File, mode), inst->SrcReg[0].Index, _mesa_swizzle_string(inst->SrcReg[0].Swizzle, @@ -566,7 +579,7 @@ _mesa_fprint_instruction_opt(FILE *f, _mesa_fprintf(f, " "); fprint_dst_reg(f, &inst->DstReg, mode, prog); _mesa_fprintf(f, ", %s[%d], %s", - file_string((enum register_file) inst->SrcReg[0].File, + file_string((gl_register_file) inst->SrcReg[0].File, mode), inst->SrcReg[0].Index, _mesa_swizzle_string(inst->SrcReg[0].Swizzle, @@ -594,6 +607,8 @@ _mesa_fprint_instruction_opt(FILE *f, default: ; } + if (inst->TexShadow) + _mesa_fprintf(f, " SHADOW"); fprint_comment(f, inst); break; @@ -713,11 +728,16 @@ _mesa_fprint_instruction_opt(FILE *f, break; /* XXX may need other special-case instructions */ default: - /* typical alu instruction */ - fprint_alu_instruction(f, inst, - _mesa_opcode_string(inst->Opcode), - _mesa_num_inst_src_regs(inst->Opcode), - mode, prog); + if (inst->Opcode < MAX_OPCODE) { + /* typical alu instruction */ + fprint_alu_instruction(f, inst, + _mesa_opcode_string(inst->Opcode), + _mesa_num_inst_src_regs(inst->Opcode), + mode, prog); + } + else { + _mesa_fprintf(f, "Other opcode %d\n", inst->Opcode); + } break; } return indent; @@ -898,7 +918,7 @@ _mesa_write_shader_to_file(const struct gl_shader *shader) else type = "vert"; - _mesa_snprintf(filename, strlen(filename), "shader_%u.%s", shader->Name, type); + _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); f = fopen(filename, "w"); if (!f) { fprintf(stderr, "Unable to open %s for writing\n", filename); |