diff options
Diffstat (limited to 'src/mesa/shader/nvvertparse.c')
-rw-r--r-- | src/mesa/shader/nvvertparse.c | 168 |
1 files changed, 7 insertions, 161 deletions
diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c index 268b577aec9..f5e2df26708 100644 --- a/src/mesa/shader/nvvertparse.c +++ b/src/mesa/shader/nvvertparse.c @@ -44,6 +44,7 @@ #include "nvprogram.h" #include "nvvertparse.h" #include "prog_instruction.h" +#include "prog_print.h" #include "program.h" @@ -640,12 +641,12 @@ Parse_SwizzleSrcReg(struct parse_state *parseState, struct prog_src_register *sr RETURN_ERROR; if (token[0] == '-') { (void) Parse_String(parseState, "-"); - srcReg->NegateBase = NEGATE_XYZW; + srcReg->Negate = NEGATE_XYZW; if (!Peek_Token(parseState, token)) RETURN_ERROR; } else { - srcReg->NegateBase = NEGATE_NONE; + srcReg->Negate = NEGATE_NONE; } /* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */ @@ -733,13 +734,13 @@ Parse_ScalarSrcReg(struct parse_state *parseState, struct prog_src_register *src if (!Peek_Token(parseState, token)) RETURN_ERROR; if (token[0] == '-') { - srcReg->NegateBase = NEGATE_XYZW; + srcReg->Negate = NEGATE_XYZW; (void) Parse_String(parseState, "-"); /* consume '-' */ if (!Peek_Token(parseState, token)) RETURN_ERROR; } else { - srcReg->NegateBase = NEGATE_NONE; + srcReg->Negate = NEGATE_NONE; } /* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */ @@ -1061,7 +1062,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction * RETURN_ERROR; srcReg->RelAddr = GL_FALSE; - srcReg->NegateBase = NEGATE_NONE; + srcReg->Negate = NEGATE_NONE; srcReg->Swizzle = SWIZZLE_NOOP; /* Register can be R<n>, c[n], c[n +/- offset], a named vertex attrib, @@ -1394,7 +1395,7 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget, #ifdef DEBUG_foo _mesa_printf("--- glLoadProgramNV result ---\n"); - _mesa_print_nv_vertex_program(program); + _mesa_fprint_program_opt(stdout, &program->Base, PROG_PRINT_NV, 0); _mesa_printf("------------------------------\n"); #endif } @@ -1410,161 +1411,6 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget, } -static void -PrintSrcReg(const struct prog_src_register *src) -{ - static const char comps[5] = "xyzw"; - if (src->NegateBase) - _mesa_printf("-"); - if (src->RelAddr) { - if (src->Index > 0) - _mesa_printf("c[A0.x + %d]", src->Index); - else if (src->Index < 0) - _mesa_printf("c[A0.x - %d]", -src->Index); - else - _mesa_printf("c[A0.x]"); - } - else if (src->File == PROGRAM_OUTPUT) { - _mesa_printf("o[%s]", OutputRegisters[src->Index]); - } - else if (src->File == PROGRAM_INPUT) { - _mesa_printf("v[%s]", InputRegisters[src->Index]); - } - else if (src->File == PROGRAM_ENV_PARAM) { - _mesa_printf("c[%d]", src->Index); - } - else { - ASSERT(src->File == PROGRAM_TEMPORARY); - _mesa_printf("R%d", src->Index); - } - - if (GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 1) && - GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 2) && - GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 3)) { - _mesa_printf(".%c", comps[GET_SWZ(src->Swizzle, 0)]); - } - else if (src->Swizzle != SWIZZLE_NOOP) { - _mesa_printf(".%c%c%c%c", - comps[GET_SWZ(src->Swizzle, 0)], - comps[GET_SWZ(src->Swizzle, 1)], - comps[GET_SWZ(src->Swizzle, 2)], - comps[GET_SWZ(src->Swizzle, 3)]); - } -} - - -static void -PrintDstReg(const struct prog_dst_register *dst) -{ - if (dst->File == PROGRAM_OUTPUT) { - _mesa_printf("o[%s]", OutputRegisters[dst->Index]); - } - else if (dst->File == PROGRAM_INPUT) { - _mesa_printf("v[%s]", InputRegisters[dst->Index]); - } - else if (dst->File == PROGRAM_ENV_PARAM) { - _mesa_printf("c[%d]", dst->Index); - } - else { - ASSERT(dst->File == PROGRAM_TEMPORARY); - _mesa_printf("R%d", dst->Index); - } - - if (dst->WriteMask != 0 && dst->WriteMask != WRITEMASK_XYZW) { - _mesa_printf("."); - if (dst->WriteMask & WRITEMASK_X) - _mesa_printf("x"); - if (dst->WriteMask & WRITEMASK_Y) - _mesa_printf("y"); - if (dst->WriteMask & WRITEMASK_Z) - _mesa_printf("z"); - if (dst->WriteMask & WRITEMASK_W) - _mesa_printf("w"); - } -} - - -/** - * Print a single NVIDIA vertex program instruction. - */ -void -_mesa_print_nv_vertex_instruction(const struct prog_instruction *inst) -{ - GLuint i, n; - - switch (inst->Opcode) { - case OPCODE_MOV: - case OPCODE_LIT: - case OPCODE_RCP: - case OPCODE_RSQ: - case OPCODE_EXP: - case OPCODE_LOG: - case OPCODE_RCC: - case OPCODE_ABS: - case OPCODE_MUL: - case OPCODE_ADD: - case OPCODE_DP3: - case OPCODE_DP4: - case OPCODE_DST: - case OPCODE_MIN: - case OPCODE_MAX: - case OPCODE_SLT: - case OPCODE_SGE: - case OPCODE_DPH: - case OPCODE_SUB: - case OPCODE_MAD: - _mesa_printf("%s ", _mesa_opcode_string(inst->Opcode)); - PrintDstReg(&inst->DstReg); - _mesa_printf(", "); - n = _mesa_num_inst_src_regs(inst->Opcode); - for (i = 0; i < n; i++) { - PrintSrcReg(&inst->SrcReg[i]); - if (i + 1 < n) - _mesa_printf(", "); - } - _mesa_printf(";\n"); - break; - case OPCODE_ARL: - _mesa_printf("ARL A0.x, "); - PrintSrcReg(&inst->SrcReg[0]); - _mesa_printf(";\n"); - break; - case OPCODE_PRINT: - _mesa_printf("PRINT '%s'", inst->Data); - if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - _mesa_printf(", "); - PrintSrcReg(&inst->SrcReg[0]); - _mesa_printf(";\n"); - } - else { - _mesa_printf("\n"); - } - break; - case OPCODE_END: - _mesa_printf("END\n"); - break; - default: - _mesa_printf("BAD INSTRUCTION\n"); - } -} - - -/** - * Print (unparse) the given vertex program. Just for debugging. - */ -void -_mesa_print_nv_vertex_program(const struct gl_vertex_program *program) -{ - const struct prog_instruction *inst; - - for (inst = program->Base.Instructions; ; inst++) { - _mesa_print_nv_vertex_instruction(inst); - if (inst->Opcode == OPCODE_END) - return; - } -} - - const char * _mesa_nv_vertex_input_register_name(GLuint i) { |