summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/arbvertparse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader/arbvertparse.c')
-rw-r--r--src/mesa/shader/arbvertparse.c208
1 files changed, 91 insertions, 117 deletions
diff --git a/src/mesa/shader/arbvertparse.c b/src/mesa/shader/arbvertparse.c
index fd0666b3260..5545aff8b70 100644
--- a/src/mesa/shader/arbvertparse.c
+++ b/src/mesa/shader/arbvertparse.c
@@ -37,6 +37,7 @@
#include "imports.h"
#include "macros.h"
#include "mtypes.h"
+#include "program.h"
#include "nvprogram.h"
#include "nvvertparse.h"
#include "nvvertprog.h"
@@ -48,129 +49,104 @@
* XXX this is probably redundant. We've already got code like this
* in the nvvertparse.c file. Combine/clean-up someday.
*/
-static GLvoid
-debug_vp_inst(GLint num, struct vp_instruction *vp)
+void _mesa_debug_vp_inst(GLint num, struct vp_instruction *vp)
{
GLint a;
+ static const char *opcode_string[] = {
+ "ABS",
+ "ADD",
+ "ARL",
+ "DP3",
+ "DP4",
+ "DPH",
+ "DST",
+ "END", /* Placeholder */
+ "EX2", /* ARB only */
+ "EXP",
+ "FLR", /* ARB */
+ "FRC", /* ARB */
+ "LG2", /* ARB only */
+ "LIT",
+ "LOG",
+ "MAD",
+ "MAX",
+ "MIN",
+ "MOV",
+ "MUL",
+ "POW", /* ARB only */
+ "PRINT", /* Mesa only */
+ "RCC",
+ "RCP",
+ "RSQ",
+ "SGE",
+ "SLT",
+ "SUB",
+ "SWZ", /* ARB only */
+ "XPD" /* ARB only */
+ };
+
+ static const char *file_string[] = {
+ "TEMP",
+ "INPUT",
+ "OUTPUT",
+ "LOCAL",
+ "ENV",
+ "NAMED",
+ "STATE",
+ "WRITE_ONLY",
+ "ADDR"
+ };
+
+ static const char swz[] = "xyzw01??";
for (a=0; a<num; a++) {
- switch (vp[a].Opcode) {
- case VP_OPCODE_MOV:
- fprintf(stderr, "VP_OPCODE_MOV"); break;
-
- case VP_OPCODE_LIT:
- fprintf(stderr, "VP_OPCODE_LIT"); break;
-
- case VP_OPCODE_RCP:
- fprintf(stderr, "VP_OPCODE_RCP"); break;
-
- case VP_OPCODE_RSQ:
- fprintf(stderr, "VP_OPCODE_RSQ"); break;
-
- case VP_OPCODE_EXP:
- fprintf(stderr, "VP_OPCODE_EXP"); break;
-
- case VP_OPCODE_LOG:
- fprintf(stderr, "VP_OPCODE_LOG"); break;
-
- case VP_OPCODE_MUL:
- fprintf(stderr, "VP_OPCODE_MUL"); break;
-
- case VP_OPCODE_ADD:
- fprintf(stderr, "VP_OPCODE_ADD"); break;
-
- case VP_OPCODE_DP3:
- fprintf(stderr, "VP_OPCODE_DP3"); break;
-
- case VP_OPCODE_DP4:
- fprintf(stderr, "VP_OPCODE_DP4"); break;
-
- case VP_OPCODE_DST:
- fprintf(stderr, "VP_OPCODE_DST"); break;
-
- case VP_OPCODE_MIN:
- fprintf(stderr, "VP_OPCODE_MIN"); break;
-
- case VP_OPCODE_MAX:
- fprintf(stderr, "VP_OPCODE_MAX"); break;
-
- case VP_OPCODE_SLT:
- fprintf(stderr, "VP_OPCODE_SLT"); break;
-
- case VP_OPCODE_SGE:
- fprintf(stderr, "VP_OPCODE_SGE"); break;
-
- case VP_OPCODE_MAD:
- fprintf(stderr, "VP_OPCODE_MAD"); break;
-
- case VP_OPCODE_ARL:
- fprintf(stderr, "VP_OPCODE_ARL"); break;
-
- case VP_OPCODE_DPH:
- fprintf(stderr, "VP_OPCODE_DPH"); break;
-
- case VP_OPCODE_RCC:
- fprintf(stderr, "VP_OPCODE_RCC"); break;
-
- case VP_OPCODE_SUB:
- fprintf(stderr, "VP_OPCODE_SUB"); break;
-
- case VP_OPCODE_ABS:
- fprintf(stderr, "VP_OPCODE_ABS"); break;
-
- case VP_OPCODE_FLR:
- fprintf(stderr, "VP_OPCODE_FLR"); break;
-
- case VP_OPCODE_FRC:
- fprintf(stderr, "VP_OPCODE_FRC"); break;
-
- case VP_OPCODE_EX2:
- fprintf(stderr, "VP_OPCODE_EX2"); break;
-
- case VP_OPCODE_LG2:
- fprintf(stderr, "VP_OPCODE_LG2"); break;
-
- case VP_OPCODE_POW:
- fprintf(stderr, "VP_OPCODE_POW"); break;
+ _mesa_printf("%s", opcode_string[vp[a].Opcode]);
+
+ if (vp[a].DstReg.File != 0xf) {
+ if (vp[a].DstReg.WriteMask != 0xf)
+ _mesa_printf(" %s[%d].%s%s%s%s ", file_string[vp[a].DstReg.File], vp[a].DstReg.Index,
+ GET_BIT(vp[a].DstReg.WriteMask, 0) ? "x" : "",
+ GET_BIT(vp[a].DstReg.WriteMask, 1) ? "y" : "",
+ GET_BIT(vp[a].DstReg.WriteMask, 2) ? "z" : "",
+ GET_BIT(vp[a].DstReg.WriteMask, 3) ? "w" : "");
+ else
+ _mesa_printf(" %s[%d] ", file_string[vp[a].DstReg.File], vp[a].DstReg.Index);
+ }
- case VP_OPCODE_XPD:
- fprintf(stderr, "VP_OPCODE_XPD"); break;
+ if (vp[a].SrcReg[0].File != 0xf) {
+ if (vp[a].SrcReg[0].Swizzle != SWIZZLE_NOOP)
+ _mesa_printf("%s[%d].%c%c%c%c ", file_string[vp[a].SrcReg[0].File], vp[a].SrcReg[0].Index,
+ swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 0)],
+ swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 1)],
+ swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 2)],
+ swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 3)]);
+ else
+ _mesa_printf("%s[%d] ", file_string[vp[a].SrcReg[0].File], vp[a].SrcReg[0].Index);
+ }
- case VP_OPCODE_SWZ:
- fprintf(stderr, "VP_OPCODE_SWZ"); break;
-
- case VP_OPCODE_PRINT:
- fprintf(stderr, "VP_OPCODE_PRINT"); break;
+ if (vp[a].SrcReg[1].File != 0xf) {
+ if (vp[a].SrcReg[1].Swizzle != SWIZZLE_NOOP)
+ _mesa_printf("%s[%d].%c%c%c%c ", file_string[vp[a].SrcReg[1].File], vp[a].SrcReg[1].Index,
+ swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 0)],
+ swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 1)],
+ swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 2)],
+ swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 3)]);
+ else
+ _mesa_printf("%s[%d] ", file_string[vp[a].SrcReg[1].File], vp[a].SrcReg[1].Index);
+ }
- case VP_OPCODE_END:
- fprintf(stderr, "VP_OPCODE_END"); break;
+ if (vp[a].SrcReg[2].File != 0xf) {
+ if (vp[a].SrcReg[2].Swizzle != SWIZZLE_NOOP)
+ _mesa_printf("%s[%d].%c%c%c%c ", file_string[vp[a].SrcReg[2].File], vp[a].SrcReg[2].Index,
+ swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 0)],
+ swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 1)],
+ swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 2)],
+ swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 3)]);
+ else
+ _mesa_printf("%s[%d] ", file_string[vp[a].SrcReg[2].File], vp[a].SrcReg[2].Index);
}
- fprintf(stderr, " D(0x%x:%d:%d%d%d%d) ", vp[a].DstReg.File, vp[a].DstReg.Index,
- vp[a].DstReg.WriteMask[0],
- vp[a].DstReg.WriteMask[1],
- vp[a].DstReg.WriteMask[2],
- vp[a].DstReg.WriteMask[3]);
-
- fprintf(stderr, "S1(0x%x:%d:%d%d%d%d) ", vp[a].SrcReg[0].File, vp[a].SrcReg[0].Index,
- vp[a].SrcReg[0].Swizzle[0],
- vp[a].SrcReg[0].Swizzle[1],
- vp[a].SrcReg[0].Swizzle[2],
- vp[a].SrcReg[0].Swizzle[3]);
-
- fprintf(stderr, "S2(0x%x:%d:%d%d%d%d) ", vp[a].SrcReg[1].File, vp[a].SrcReg[1].Index,
- vp[a].SrcReg[1].Swizzle[0],
- vp[a].SrcReg[1].Swizzle[1],
- vp[a].SrcReg[1].Swizzle[2],
- vp[a].SrcReg[1].Swizzle[3]);
-
- fprintf(stderr, "S3(0x%x:%d:%d%d%d%d)", vp[a].SrcReg[2].File, vp[a].SrcReg[2].Index,
- vp[a].SrcReg[2].Swizzle[0],
- vp[a].SrcReg[2].Swizzle[1],
- vp[a].SrcReg[2].Swizzle[2],
- vp[a].SrcReg[2].Swizzle[3]);
-
- fprintf(stderr, "\n");
+ _mesa_printf("\n");
}
}
@@ -216,9 +192,7 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
program->Instructions = ap.VPInstructions;
#if DEBUG_VP
- debug_vp_inst(ap.Base.NumInstructions, ap.VPInstructions);
-#else
- (void) debug_vp_inst;
+ _mesa_debug_vp_inst(ap.Base.NumInstructions, ap.VPInstructions);
#endif
}