consolidate vertex/fragment program printing into _mesa_print_program()
This commit is contained in:
@@ -39,93 +39,6 @@
|
|||||||
#include "arbprogparse.h"
|
#include "arbprogparse.h"
|
||||||
#include "arbfragparse.h"
|
#include "arbfragparse.h"
|
||||||
|
|
||||||
void
|
|
||||||
_mesa_debug_fp_inst(GLint num, struct prog_instruction *fp)
|
|
||||||
{
|
|
||||||
GLint a;
|
|
||||||
static const char swz[] = "xyzw01??";
|
|
||||||
|
|
||||||
for (a=0; a<num; a++) {
|
|
||||||
_mesa_printf("%s", _mesa_opcode_string(fp[a].Opcode));
|
|
||||||
|
|
||||||
if (fp[a].Saturate)
|
|
||||||
_mesa_printf("_SAT");
|
|
||||||
|
|
||||||
if (fp[a].DstReg.File != 0xf) {
|
|
||||||
if (fp[a].DstReg.WriteMask != 0xf)
|
|
||||||
_mesa_printf(" %s[%d].%s%s%s%s ",
|
|
||||||
_mesa_program_file_string(fp[a].DstReg.File),
|
|
||||||
fp[a].DstReg.Index,
|
|
||||||
GET_BIT(fp[a].DstReg.WriteMask, 0) ? "x" : "",
|
|
||||||
GET_BIT(fp[a].DstReg.WriteMask, 1) ? "y" : "",
|
|
||||||
GET_BIT(fp[a].DstReg.WriteMask, 2) ? "z" : "",
|
|
||||||
GET_BIT(fp[a].DstReg.WriteMask, 3) ? "w" : "");
|
|
||||||
else
|
|
||||||
_mesa_printf(" %s[%d] ",
|
|
||||||
_mesa_program_file_string(fp[a].DstReg.File),
|
|
||||||
fp[a].DstReg.Index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Examine each bit of negatebase here as this may be a SWZ instruction
|
|
||||||
*/
|
|
||||||
if (fp[a].SrcReg[0].File != 0xf) {
|
|
||||||
if (fp[a].SrcReg[0].Swizzle != SWIZZLE_NOOP ||
|
|
||||||
fp[a].SrcReg[0].NegateBase)
|
|
||||||
_mesa_printf("%s[%d].%s%c%s%c%s%c%s%c ",
|
|
||||||
_mesa_program_file_string(fp[a].SrcReg[0].File),
|
|
||||||
fp[a].SrcReg[0].Index,
|
|
||||||
GET_BIT(fp[a].SrcReg[0].NegateBase, 0) ? "-" : "",
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 0)],
|
|
||||||
GET_BIT(fp[a].SrcReg[0].NegateBase, 0) ? "-" : "",
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 1)],
|
|
||||||
GET_BIT(fp[a].SrcReg[0].NegateBase, 0) ? "-" : "",
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 2)],
|
|
||||||
GET_BIT(fp[a].SrcReg[0].NegateBase, 0) ? "-" : "",
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 3)]);
|
|
||||||
else
|
|
||||||
_mesa_printf("%s[%d] ",
|
|
||||||
_mesa_program_file_string(fp[a].SrcReg[0].File),
|
|
||||||
fp[a].SrcReg[0].Index);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fp[a].SrcReg[1].File != 0xf) {
|
|
||||||
if (fp[a].SrcReg[1].Swizzle != SWIZZLE_NOOP ||
|
|
||||||
fp[a].SrcReg[1].NegateBase)
|
|
||||||
_mesa_printf("%s[%d].%s%c%c%c%c ",
|
|
||||||
_mesa_program_file_string(fp[a].SrcReg[1].File),
|
|
||||||
fp[a].SrcReg[1].Index,
|
|
||||||
fp[a].SrcReg[1].NegateBase ? "-" : "",
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[1].Swizzle, 0)],
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[1].Swizzle, 1)],
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[1].Swizzle, 2)],
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[1].Swizzle, 3)]);
|
|
||||||
else
|
|
||||||
_mesa_printf("%s[%d] ",
|
|
||||||
_mesa_program_file_string(fp[a].SrcReg[1].File),
|
|
||||||
fp[a].SrcReg[1].Index);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fp[a].SrcReg[2].File != 0xf) {
|
|
||||||
if (fp[a].SrcReg[2].Swizzle != SWIZZLE_NOOP ||
|
|
||||||
fp[a].SrcReg[2].NegateBase)
|
|
||||||
_mesa_printf("%s[%d].%s%c%c%c%c ",
|
|
||||||
_mesa_program_file_string(fp[a].SrcReg[2].File),
|
|
||||||
fp[a].SrcReg[2].Index,
|
|
||||||
fp[a].SrcReg[1].NegateBase ? "-" : "",
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[2].Swizzle, 0)],
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[2].Swizzle, 1)],
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[2].Swizzle, 2)],
|
|
||||||
swz[GET_SWZ(fp[a].SrcReg[2].Swizzle, 3)]);
|
|
||||||
else
|
|
||||||
_mesa_printf("%s[%d] ",
|
|
||||||
_mesa_program_file_string(fp[a].SrcReg[2].File),
|
|
||||||
fp[a].SrcReg[2].Index);
|
|
||||||
}
|
|
||||||
|
|
||||||
_mesa_printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
|
_mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
|
||||||
@@ -182,6 +95,6 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
|
|||||||
program->FogOption = ap.FogOption;
|
program->FogOption = ap.FogOption;
|
||||||
|
|
||||||
#if DEBUG_FP
|
#if DEBUG_FP
|
||||||
_mesa_debug_fp_inst(ap.Base.NumInstructions, ap.FPInstructions);
|
_mesa_print_program(ap.Base.NumInstructions, ap.FPInstructions);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -45,89 +45,6 @@
|
|||||||
#include "arbprogparse.h"
|
#include "arbprogparse.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XXX this is probably redundant. We've already got code like this
|
|
||||||
* in the nvvertparse.c file. Combine/clean-up someday.
|
|
||||||
*/
|
|
||||||
void _mesa_debug_vp_inst(GLint num, struct prog_instruction *vp)
|
|
||||||
{
|
|
||||||
GLint a;
|
|
||||||
static const char swz[] = "xyzw01??";
|
|
||||||
|
|
||||||
for (a=0; a<num; a++) {
|
|
||||||
_mesa_printf("%s", _mesa_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 ",
|
|
||||||
_mesa_program_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] ",
|
|
||||||
_mesa_program_file_string(vp[a].DstReg.File),
|
|
||||||
vp[a].DstReg.Index);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vp[a].SrcReg[0].File != 0xf) {
|
|
||||||
if (vp[a].SrcReg[0].Swizzle != SWIZZLE_NOOP ||
|
|
||||||
vp[a].SrcReg[0].NegateBase)
|
|
||||||
_mesa_printf("%s[%d].%s%c%c%c%c ",
|
|
||||||
_mesa_program_file_string(vp[a].SrcReg[0].File),
|
|
||||||
vp[a].SrcReg[0].Index,
|
|
||||||
vp[a].SrcReg[0].NegateBase ? "-" : "",
|
|
||||||
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] ",
|
|
||||||
_mesa_program_file_string(vp[a].SrcReg[0].File),
|
|
||||||
vp[a].SrcReg[0].Index);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vp[a].SrcReg[1].File != 0xf) {
|
|
||||||
if (vp[a].SrcReg[1].Swizzle != SWIZZLE_NOOP ||
|
|
||||||
vp[a].SrcReg[1].NegateBase)
|
|
||||||
_mesa_printf("%s[%d].%s%c%c%c%c ",
|
|
||||||
_mesa_program_file_string(vp[a].SrcReg[1].File),
|
|
||||||
vp[a].SrcReg[1].Index,
|
|
||||||
vp[a].SrcReg[1].NegateBase ? "-" : "",
|
|
||||||
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] ",
|
|
||||||
_mesa_program_file_string(vp[a].SrcReg[1].File),
|
|
||||||
vp[a].SrcReg[1].Index);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vp[a].SrcReg[2].File != 0xf) {
|
|
||||||
if (vp[a].SrcReg[2].Swizzle != SWIZZLE_NOOP ||
|
|
||||||
vp[a].SrcReg[2].NegateBase)
|
|
||||||
_mesa_printf("%s[%d].%s%c%c%c%c ",
|
|
||||||
_mesa_program_file_string(vp[a].SrcReg[2].File),
|
|
||||||
vp[a].SrcReg[2].Index,
|
|
||||||
vp[a].SrcReg[2].NegateBase ? "-" : "",
|
|
||||||
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] ",
|
|
||||||
_mesa_program_file_string(vp[a].SrcReg[2].File),
|
|
||||||
vp[a].SrcReg[2].Index);
|
|
||||||
}
|
|
||||||
|
|
||||||
_mesa_printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the vertex program string. If success, update the given
|
* Parse the vertex program string. If success, update the given
|
||||||
* vertex_program object with the new program. Else, leave the vertex_program
|
* vertex_program object with the new program. Else, leave the vertex_program
|
||||||
@@ -181,7 +98,7 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
|
|||||||
}
|
}
|
||||||
program->Parameters = ap.Parameters;
|
program->Parameters = ap.Parameters;
|
||||||
|
|
||||||
#if DEBUG_VP
|
#if 1/*DEBUG_VP*/
|
||||||
_mesa_debug_vp_inst(ap.Base.NumInstructions, ap.VPInstructions);
|
_mesa_print_program(ap.Base.NumInstructions, ap.VPInstructions);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
* Version: 5.1
|
* Version: 6.5
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
|
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -30,7 +30,4 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
|
|||||||
const GLubyte * str, GLsizei len,
|
const GLubyte * str, GLsizei len,
|
||||||
struct vertex_program *program);
|
struct vertex_program *program);
|
||||||
|
|
||||||
extern void
|
|
||||||
_mesa_debug_vp_inst(GLint num, struct prog_instruction *vp);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1074,8 +1074,8 @@ _mesa_opcode_string(enum prog_opcode opcode)
|
|||||||
/**
|
/**
|
||||||
* Return string name for given program/register file.
|
* Return string name for given program/register file.
|
||||||
*/
|
*/
|
||||||
const char *
|
static const char *
|
||||||
_mesa_program_file_string(enum register_file f)
|
program_file_string(enum register_file f)
|
||||||
{
|
{
|
||||||
switch (f) {
|
switch (f) {
|
||||||
case PROGRAM_TEMPORARY:
|
case PROGRAM_TEMPORARY:
|
||||||
@@ -1104,6 +1104,125 @@ _mesa_program_file_string(enum register_file f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a string representation of the given swizzle word.
|
||||||
|
*/
|
||||||
|
static const char *
|
||||||
|
swizzle_string(GLuint swizzle, GLuint negateBase)
|
||||||
|
{
|
||||||
|
static const char swz[] = "xyzw01";
|
||||||
|
static char s[20];
|
||||||
|
GLuint i = 0;
|
||||||
|
|
||||||
|
if (swizzle == SWIZZLE_NOOP && negateBase == 0)
|
||||||
|
return ""; /* no swizzle/negation */
|
||||||
|
|
||||||
|
s[i++] = '.';
|
||||||
|
|
||||||
|
if (negateBase & 0x1)
|
||||||
|
s[i++] = '-';
|
||||||
|
s[i++] = swz[GET_SWZ(swizzle, 0)];
|
||||||
|
|
||||||
|
if (negateBase & 0x2)
|
||||||
|
s[i++] = '-';
|
||||||
|
s[i++] = swz[GET_SWZ(swizzle, 1)];
|
||||||
|
|
||||||
|
if (negateBase & 0x4)
|
||||||
|
s[i++] = '-';
|
||||||
|
s[i++] = swz[GET_SWZ(swizzle, 2)];
|
||||||
|
|
||||||
|
if (negateBase & 0x8)
|
||||||
|
s[i++] = '-';
|
||||||
|
s[i++] = swz[GET_SWZ(swizzle, 3)];
|
||||||
|
|
||||||
|
s[i] = 0;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
writemask_string(GLuint writeMask)
|
||||||
|
{
|
||||||
|
static char s[10];
|
||||||
|
GLuint i = 0;
|
||||||
|
|
||||||
|
if (writeMask == WRITEMASK_XYZW)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
s[i++] = '.';
|
||||||
|
if (writeMask & WRITEMASK_X)
|
||||||
|
s[i++] = 'x';
|
||||||
|
if (writeMask & WRITEMASK_Y)
|
||||||
|
s[i++] = 'y';
|
||||||
|
if (writeMask & WRITEMASK_Z)
|
||||||
|
s[i++] = 'z';
|
||||||
|
if (writeMask & WRITEMASK_W)
|
||||||
|
s[i++] = 'w';
|
||||||
|
|
||||||
|
s[i] = 0;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a vertx/fragment program to stdout.
|
||||||
|
* XXX this function could be greatly improved.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_mesa_print_program(GLuint count, const struct prog_instruction *inst)
|
||||||
|
{
|
||||||
|
GLuint i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
/* inst number */
|
||||||
|
_mesa_printf("%3d: ", i);
|
||||||
|
|
||||||
|
switch (inst[i].Opcode) {
|
||||||
|
case OPCODE_PRINT:
|
||||||
|
_mesa_printf("PRINT %s\n", inst->Data);
|
||||||
|
break;
|
||||||
|
/* XXX check for a bunch of other special-case instructions */
|
||||||
|
default:
|
||||||
|
/* typical alu instruction */
|
||||||
|
{
|
||||||
|
const GLuint numRegs = _mesa_num_inst_src_regs(inst[i].Opcode);
|
||||||
|
GLuint j;
|
||||||
|
|
||||||
|
_mesa_printf("%s", _mesa_opcode_string(inst[i].Opcode));
|
||||||
|
|
||||||
|
/* frag prog only */
|
||||||
|
if (inst[i].Saturate)
|
||||||
|
_mesa_printf("_SAT");
|
||||||
|
|
||||||
|
if (inst[i].DstReg.File != PROGRAM_UNDEFINED) {
|
||||||
|
_mesa_printf(" %s[%d]%s",
|
||||||
|
program_file_string(inst[i].DstReg.File),
|
||||||
|
inst[i].DstReg.Index,
|
||||||
|
writemask_string(inst[i].DstReg.WriteMask));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numRegs > 0)
|
||||||
|
_mesa_printf(", ");
|
||||||
|
|
||||||
|
for (j = 0; j < numRegs; j++) {
|
||||||
|
_mesa_printf("%s[%d]%s",
|
||||||
|
program_file_string(inst[i].SrcReg[j].File),
|
||||||
|
inst[i].SrcReg[j].Index,
|
||||||
|
swizzle_string(inst[i].SrcReg[j].Swizzle,
|
||||||
|
inst[i].SrcReg[j].NegateBase));
|
||||||
|
if (j + 1 < numRegs)
|
||||||
|
_mesa_printf(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
_mesa_printf(";\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* API functions */
|
/* API functions */
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
@@ -254,6 +254,11 @@ _mesa_load_state_parameters(GLcontext *ctx,
|
|||||||
struct program_parameter_list *paramList);
|
struct program_parameter_list *paramList);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
_mesa_print_program(GLuint count, const struct prog_instruction *inst);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* API functions common to ARB/NV_vertex/fragment_program
|
* API functions common to ARB/NV_vertex/fragment_program
|
||||||
*/
|
*/
|
||||||
|
@@ -346,7 +346,5 @@ _mesa_num_inst_src_regs(enum prog_opcode opcode);
|
|||||||
extern const char *
|
extern const char *
|
||||||
_mesa_opcode_string(enum prog_opcode opcode);
|
_mesa_opcode_string(enum prog_opcode opcode);
|
||||||
|
|
||||||
extern const char *
|
|
||||||
_mesa_program_file_string(enum register_file f);
|
|
||||||
|
|
||||||
#endif /* PROG_INSTRUCTION_H */
|
#endif /* PROG_INSTRUCTION_H */
|
||||||
|
Reference in New Issue
Block a user