summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-11-12 17:53:14 +0000
committerBrian Paul <[email protected]>2005-11-12 17:53:14 +0000
commitde99760bf3511d05185799c4fb4347f9e5f420f4 (patch)
treea0bda8570a2943b4c7dabc51b7a61e5c5344eded /src/mesa/shader
parent77ee31930a1b0cc7766939415f4f04ed6a1fa4ac (diff)
Move stuff common to vertex/fragment_program into the base class, including:
Instructions, InputsRead, OutputsWritten, and Parameters. Also, added debug functions: _mesa_print_instruction(), _mesa_print_program_parameters() and revamp _mesa_print_program().
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/arbfragparse.c24
-rw-r--r--src/mesa/shader/arbprogparse.c32
-rw-r--r--src/mesa/shader/arbprogparse.h2
-rw-r--r--src/mesa/shader/arbvertparse.c18
-rw-r--r--src/mesa/shader/nvfragparse.c27
-rw-r--r--src/mesa/shader/nvprogram.c6
-rw-r--r--src/mesa/shader/nvvertexec.c13
-rw-r--r--src/mesa/shader/nvvertparse.c24
-rw-r--r--src/mesa/shader/program.c194
-rw-r--r--src/mesa/shader/program.h8
10 files changed, 198 insertions, 150 deletions
diff --git a/src/mesa/shader/arbfragparse.c b/src/mesa/shader/arbfragparse.c
index 31223cc4737..e6470be9fe7 100644
--- a/src/mesa/shader/arbfragparse.c
+++ b/src/mesa/shader/arbfragparse.c
@@ -67,31 +67,31 @@ _mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
}
_mesa_memcpy(newInstructions, ap.FPInstructions,
ap.Base.NumInstructions * sizeof(struct prog_instruction));
- if (program->Instructions)
- _mesa_free(program->Instructions);
- program->Instructions = newInstructions;
+ if (program->Base.Instructions)
+ _mesa_free(program->Base.Instructions);
+ program->Base.Instructions = newInstructions;
program->Base.String = ap.Base.String;
program->Base.NumInstructions = ap.Base.NumInstructions;
program->Base.NumTemporaries = ap.Base.NumTemporaries;
program->Base.NumParameters = ap.Base.NumParameters;
program->Base.NumAttributes = ap.Base.NumAttributes;
program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
- program->NumAluInstructions = ap.NumAluInstructions;
- program->NumTexInstructions = ap.NumTexInstructions;
- program->NumTexIndirections = ap.NumTexIndirections;
- program->InputsRead = ap.InputsRead;
- program->OutputsWritten = ap.OutputsWritten;
+ program->NumAluInstructions = ap.NumAluInstructions;
+ program->NumTexInstructions = ap.NumTexInstructions;
+ program->NumTexIndirections = ap.NumTexIndirections;
+ program->Base.InputsRead = ap.Base.InputsRead;
+ program->Base.OutputsWritten = ap.Base.OutputsWritten;
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
program->TexturesUsed[i] = ap.TexturesUsed[i];
- if (program->Parameters) {
+ if (program->Base.Parameters) {
/* free previous program's parameters */
- _mesa_free_parameter_list(program->Parameters);
+ _mesa_free_parameter_list(program->Base.Parameters);
}
- program->Parameters = ap.Parameters;
+ program->Base.Parameters = ap.Base.Parameters;
program->FogOption = ap.FogOption;
#if DEBUG_FP
- _mesa_print_program(ap.Base.NumInstructions, ap.FPInstructions);
+ _mesa_print_program(&program.Base);
#endif
}
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 5f039170c3b..e1a42e2dd9d 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -1518,7 +1518,7 @@ parse_attrib_binding(GLcontext * ctx, GLubyte ** inst,
_mesa_error(ctx, GL_INVALID_OPERATION, msg);
}
- Program->InputsRead |= (1 << *inputReg);
+ Program->Base.InputsRead |= (1 << *inputReg);
return err;
}
@@ -1609,7 +1609,7 @@ parse_result_binding(GLcontext *ctx, GLubyte **inst,
break;
}
- Program->OutputsWritten |= (1 << *outputReg);
+ Program->Base.OutputsWritten |= (1 << *outputReg);
return 0;
}
@@ -1698,9 +1698,8 @@ parse_param_elements (GLcontext * ctx, GLubyte ** inst,
for (row = first_row; row <= last_row; row++) {
state_tokens[3] = state_tokens[4] = row;
- idx =
- _mesa_add_state_reference (Program->Parameters,
- state_tokens);
+ idx = _mesa_add_state_reference(Program->Base.Parameters,
+ state_tokens);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
param_var->param_binding_length++;
@@ -1708,8 +1707,8 @@ parse_param_elements (GLcontext * ctx, GLubyte ** inst,
}
}
else {
- idx =
- _mesa_add_state_reference (Program->Parameters, state_tokens);
+ idx = _mesa_add_state_reference(Program->Base.Parameters,
+ state_tokens);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
param_var->param_binding_length++;
@@ -1720,7 +1719,7 @@ parse_param_elements (GLcontext * ctx, GLubyte ** inst,
case PARAM_PROGRAM_ELEMENT:
if (parse_program_single_item (ctx, inst, Program, state_tokens))
return 1;
- idx = _mesa_add_state_reference (Program->Parameters, state_tokens);
+ idx = _mesa_add_state_reference (Program->Base.Parameters, state_tokens);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
param_var->param_binding_length++;
@@ -1759,9 +1758,8 @@ parse_param_elements (GLcontext * ctx, GLubyte ** inst,
for (new_idx = start_idx; new_idx <= end_idx; new_idx++) {
state_tokens[2] = new_idx;
- idx =
- _mesa_add_state_reference (Program->Parameters,
- state_tokens);
+ idx = _mesa_add_state_reference(Program->Base.Parameters,
+ state_tokens);
param_var->param_binding_length++;
Program->Base.NumParameters++;
}
@@ -1773,9 +1771,9 @@ parse_param_elements (GLcontext * ctx, GLubyte ** inst,
case PARAM_CONSTANT:
parse_constant (inst, const_values, Program, use);
- idx =
- _mesa_add_named_constant (Program->Parameters,
- (char *) param_var->name, const_values);
+ idx = _mesa_add_named_constant(Program->Base.Parameters,
+ (char *) param_var->name,
+ const_values);
if (param_var->param_binding_begin == ~0U)
param_var->param_binding_begin = idx;
param_var->param_binding_length++;
@@ -3949,9 +3947,9 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
program->Base.NumTemporaries =
program->Base.NumParameters =
program->Base.NumAttributes = program->Base.NumAddressRegs = 0;
- program->Parameters = _mesa_new_parameter_list ();
- program->InputsRead = 0x0;
- program->OutputsWritten = 0x0;
+ program->Base.Parameters = _mesa_new_parameter_list ();
+ program->Base.InputsRead = 0x0;
+ program->Base.OutputsWritten = 0x0;
program->Position = 0;
program->MajorVersion = program->MinorVersion = 0;
program->PrecisionOption = GL_DONT_CARE;
diff --git a/src/mesa/shader/arbprogparse.h b/src/mesa/shader/arbprogparse.h
index 5dbf31a2b15..b8498ff281d 100644
--- a/src/mesa/shader/arbprogparse.h
+++ b/src/mesa/shader/arbprogparse.h
@@ -43,9 +43,11 @@
struct arb_program
{
struct program Base;
+#if 0
struct program_parameter_list *Parameters;
GLbitfield InputsRead;
GLbitfield OutputsWritten;
+#endif
GLuint Position; /* Just used for error reporting while parsing */
GLuint MajorVersion;
diff --git a/src/mesa/shader/arbvertparse.c b/src/mesa/shader/arbvertparse.c
index bb18a2ea473..253f2937edf 100644
--- a/src/mesa/shader/arbvertparse.c
+++ b/src/mesa/shader/arbvertparse.c
@@ -71,9 +71,9 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
}
_mesa_memcpy(newInstructions, ap.VPInstructions,
ap.Base.NumInstructions * sizeof(struct prog_instruction));
- if (program->Instructions)
- _mesa_free(program->Instructions);
- program->Instructions = newInstructions;
+ if (program->Base.Instructions)
+ _mesa_free(program->Base.Instructions);
+ program->Base.Instructions = newInstructions;
program->Base.String = ap.Base.String;
program->Base.NumInstructions = ap.Base.NumInstructions;
program->Base.NumTemporaries = ap.Base.NumTemporaries;
@@ -81,16 +81,16 @@ _mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
program->Base.NumAttributes = ap.Base.NumAttributes;
program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
program->IsPositionInvariant = ap.HintPositionInvariant;
- program->InputsRead = ap.InputsRead;
- program->OutputsWritten = ap.OutputsWritten;
+ program->Base.InputsRead = ap.Base.InputsRead;
+ program->Base.OutputsWritten = ap.Base.OutputsWritten;
- if (program->Parameters) {
+ if (program->Base.Parameters) {
/* free previous program's parameters */
- _mesa_free_parameter_list(program->Parameters);
+ _mesa_free_parameter_list(program->Base.Parameters);
}
- program->Parameters = ap.Parameters;
+ program->Base.Parameters = ap.Base.Parameters;
#if DEBUG_VP
- _mesa_print_program(ap.Base.NumInstructions, ap.VPInstructions);
+ _mesa_print_program(&program->Base);
#endif
}
diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c
index 3a480058440..6a8d250d7eb 100644
--- a/src/mesa/shader/nvfragparse.c
+++ b/src/mesa/shader/nvfragparse.c
@@ -1535,17 +1535,17 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget,
}
program->Base.String = programString;
program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
- if (program->Instructions) {
- FREE(program->Instructions);
+ if (program->Base.Instructions) {
+ _mesa_free(program->Base.Instructions);
}
- program->Instructions = newInst;
- program->InputsRead = parseState.inputsRead;
- program->OutputsWritten = parseState.outputsWritten;
+ program->Base.Instructions = newInst;
+ program->Base.InputsRead = parseState.inputsRead;
+ program->Base.OutputsWritten = parseState.outputsWritten;
for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++)
program->TexturesUsed[u] = parseState.texturesUsed[u];
/* save program parameters */
- program->Parameters = parseState.parameters;
+ program->Base.Parameters = parseState.parameters;
/* allocate registers for declared program parameters */
#if 00
@@ -1582,17 +1582,16 @@ PrintSrcReg(const struct fragment_program *program,
_mesa_printf("-");
}
if (src->File == PROGRAM_NAMED_PARAM) {
- if (program->Parameters->Parameters[src->Index].Type == PROGRAM_CONSTANT) {
- _mesa_printf("{%g, %g, %g, %g}",
- program->Parameters->ParameterValues[src->Index][0],
- program->Parameters->ParameterValues[src->Index][1],
- program->Parameters->ParameterValues[src->Index][2],
- program->Parameters->ParameterValues[src->Index][3]);
+ if (program->Base.Parameters->Parameters[src->Index].Type
+ == PROGRAM_CONSTANT) {
+ const GLfloat *v;
+ v = program->Base.Parameters->ParameterValues[src->Index];
+ _mesa_printf("{%g, %g, %g, %g}", v[0], v[1], v[2], v[3]);
}
else {
ASSERT(program->Parameters->Parameters[src->Index].Type
== PROGRAM_NAMED_PARAM);
- _mesa_printf("%s", program->Parameters->Parameters[src->Index].Name);
+ _mesa_printf("%s", program->Base.Parameters->Parameters[src->Index].Name);
}
}
else if (src->File == PROGRAM_OUTPUT) {
@@ -1734,7 +1733,7 @@ _mesa_print_nv_fragment_program(const struct fragment_program *program)
{
const struct prog_instruction *inst;
- for (inst = program->Instructions; inst->Opcode != OPCODE_END; inst++) {
+ for (inst = program->Base.Instructions; inst->Opcode != OPCODE_END; inst++) {
int i;
for (i = 0; Instructions[i].name; i++) {
if (inst->Opcode == Instructions[i].opcode) {
diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c
index c85e7c00bd0..fadb5be2ade 100644
--- a/src/mesa/shader/nvprogram.c
+++ b/src/mesa/shader/nvprogram.c
@@ -780,7 +780,8 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
}
fragProg = (struct fragment_program *) prog;
- v = _mesa_lookup_parameter_value(fragProg->Parameters, len, (char *) name);
+ v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, len,
+ (char *) name);
if (v) {
v[0] = x;
v[1] = y;
@@ -845,7 +846,8 @@ _mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name,
}
fragProg = (struct fragment_program *) prog;
- v = _mesa_lookup_parameter_value(fragProg->Parameters, len, (char *) name);
+ v = _mesa_lookup_parameter_value(fragProg->Base.Parameters,
+ len, (char *) name);
if (v) {
params[0] = v[0];
params[1] = v[1];
diff --git a/src/mesa/shader/nvvertexec.c b/src/mesa/shader/nvvertexec.c
index 5bb40d881e0..a413dcbc291 100644
--- a/src/mesa/shader/nvvertexec.c
+++ b/src/mesa/shader/nvvertexec.c
@@ -162,10 +162,10 @@ _mesa_init_vp_per_primitive_registers(GLcontext *ctx)
}
else {
/* Using and ARB vertex program */
- if (ctx->VertexProgram.Current->Parameters) {
+ if (ctx->VertexProgram.Current->Base.Parameters) {
/* Grab the state GL state and put into registers */
_mesa_load_state_parameters(ctx,
- ctx->VertexProgram.Current->Parameters);
+ ctx->VertexProgram.Current->Base.Parameters);
}
}
}
@@ -239,7 +239,7 @@ get_register_pointer( const struct prog_src_register *source,
else if (source->File == PROGRAM_ENV_PARAM)
return state->Parameters[reg];
else
- return state->Current->Parameters->ParameterValues[reg];
+ return state->Current->Base.Parameters->ParameterValues[reg];
}
else {
switch (source->File) {
@@ -261,7 +261,7 @@ get_register_pointer( const struct prog_src_register *source,
return state->Parameters[source->Index];
case PROGRAM_STATE_VAR:
ASSERT(source->Index < state->Current->Parameters->NumParameters);
- return state->Current->Parameters->ParameterValues[source->Index];
+ return state->Current->Base.Parameters->ParameterValues[source->Index];
default:
_mesa_problem(NULL,
"Bad source register file in get_register_pointer");
@@ -395,9 +395,10 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
ctx->VertexProgram.Inputs[VERT_ATTRIB_POS]);
/* XXX: This could go elsewhere */
- ctx->VertexProgram.Current->OutputsWritten |= VERT_BIT_POS;
+ ctx->VertexProgram.Current->Base.OutputsWritten |= VERT_BIT_POS;
}
- for (inst = program->Instructions; ; inst++) {
+
+ for (inst = program->Base.Instructions; ; inst++) {
if (ctx->VertexProgram.CallbackEnabled &&
ctx->VertexProgram.Callback) {
diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c
index fd880dc007d..e2c14b99185 100644
--- a/src/mesa/shader/nvvertparse.c
+++ b/src/mesa/shader/nvvertparse.c
@@ -1367,28 +1367,28 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
/* copy the compiled instructions */
assert(parseState.numInst <= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS);
newInst = (struct prog_instruction *)
- MALLOC(parseState.numInst * sizeof(struct prog_instruction));
+ _mesa_malloc(parseState.numInst * sizeof(struct prog_instruction));
if (!newInst) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
- FREE(programString);
+ _mesa_free(programString);
return; /* out of memory */
}
- MEMCPY(newInst, instBuffer,
- parseState.numInst * sizeof(struct prog_instruction));
+ _mesa_memcpy(newInst, instBuffer,
+ parseState.numInst * sizeof(struct prog_instruction));
/* install the program */
program->Base.Target = target;
if (program->Base.String) {
- FREE(program->Base.String);
+ _mesa_free(program->Base.String);
}
program->Base.String = programString;
program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
- if (program->Instructions) {
- FREE(program->Instructions);
+ if (program->Base.Instructions) {
+ _mesa_free(program->Base.Instructions);
}
- program->Instructions = newInst;
- program->InputsRead = parseState.inputsRead;
- program->OutputsWritten = parseState.outputsWritten;
+ program->Base.Instructions = newInst;
+ program->Base.InputsRead = parseState.inputsRead;
+ program->Base.OutputsWritten = parseState.outputsWritten;
program->IsPositionInvariant = parseState.isPositionInvariant;
program->IsNVProgram = GL_TRUE;
@@ -1531,7 +1531,7 @@ _mesa_print_nv_vertex_instruction(const struct prog_instruction *inst)
break;
case OPCODE_PRINT:
_mesa_printf("PRINT '%s'", inst->Data);
- if (inst->SrcReg[0].File) {
+ if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) {
_mesa_printf(", ");
PrintSrcReg(&inst->SrcReg[0]);
_mesa_printf(";\n");
@@ -1557,7 +1557,7 @@ _mesa_print_nv_vertex_program(const struct vertex_program *program)
{
const struct prog_instruction *inst;
- for (inst = program->Instructions; ; inst++) {
+ for (inst = program->Base.Instructions; ; inst++) {
_mesa_print_nv_vertex_instruction(inst);
if (inst->Opcode == OPCODE_END)
return;
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index d46fadefcab..a9b84fc754e 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -294,35 +294,20 @@ _mesa_delete_program(GLcontext *ctx, struct program *prog)
if (prog->String)
_mesa_free(prog->String);
- if (prog->Target == GL_VERTEX_PROGRAM_NV ||
- prog->Target == GL_VERTEX_STATE_PROGRAM_NV) {
- struct vertex_program *vprog = (struct vertex_program *) prog;
- if (vprog->Instructions) {
- GLuint i;
- for (i = 0; i < vprog->Base.NumInstructions; i++) {
- if (vprog->Instructions[i].Data)
- _mesa_free(vprog->Instructions[i].Data);
- }
- _mesa_free(vprog->Instructions);
- }
- if (vprog->Parameters)
- _mesa_free_parameter_list(vprog->Parameters);
- }
- else if (prog->Target == GL_FRAGMENT_PROGRAM_NV ||
- prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
- struct fragment_program *fprog = (struct fragment_program *) prog;
- if (fprog->Instructions) {
- GLuint i;
- for (i = 0; i < fprog->Base.NumInstructions; i++) {
- if (fprog->Instructions[i].Data)
- _mesa_free(fprog->Instructions[i].Data);
- }
- _mesa_free(fprog->Instructions);
+
+ if (prog->Instructions) {
+ GLuint i;
+ for (i = 0; i < prog->NumInstructions; i++) {
+ if (prog->Instructions[i].Data)
+ _mesa_free(prog->Instructions[i].Data);
}
- if (fprog->Parameters)
- _mesa_free_parameter_list(fprog->Parameters);
+ _mesa_free(prog->Instructions);
}
- else if (prog->Target == GL_FRAGMENT_SHADER_ATI) {
+
+ if (prog->Parameters)
+ _mesa_free_parameter_list(prog->Parameters);
+
+ if (prog->Target == GL_FRAGMENT_SHADER_ATI) {
struct ati_fragment_shader *atifs = (struct ati_fragment_shader *)prog;
GLuint i;
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
@@ -1175,73 +1160,128 @@ writemask_string(GLuint writeMask)
/**
- * Print a vertx/fragment program to stdout.
- * XXX this function could be greatly improved.
+ * Print a single vertex/fragment program instruction.
*/
void
-_mesa_print_program(GLuint count, const struct prog_instruction *inst)
+_mesa_print_instruction(const struct prog_instruction *inst)
{
- GLuint i;
+ switch (inst->Opcode) {
+ case OPCODE_PRINT:
+ _mesa_printf("PRINT '%s'", inst->Data);
+ if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) {
+ _mesa_printf(", ");
+ _mesa_printf("%s[%d]%s",
+ program_file_string(inst->SrcReg[0].File),
+ inst->SrcReg[0].Index,
+ swizzle_string(inst->SrcReg[0].Swizzle,
+ inst->SrcReg[0].NegateBase));
+ }
+ _mesa_printf(";\n");
+ break;
+ /* XXX check for a bunch of other special-case instructions */
+ default:
+ /* typical alu instruction */
+ {
+ const GLuint numRegs = _mesa_num_inst_src_regs(inst->Opcode);
+ GLuint j;
- for (i = 0; i < count; i++) {
- /* inst number */
- _mesa_printf("%3d: ", i);
+ _mesa_printf("%s", _mesa_opcode_string(inst->Opcode));
+
+ /* frag prog only */
+ if (inst->Saturate)
+ _mesa_printf("_SAT");
+
+ if (inst->DstReg.File != PROGRAM_UNDEFINED) {
+ _mesa_printf(" %s[%d]%s",
+ program_file_string(inst->DstReg.File),
+ inst->DstReg.Index,
+ writemask_string(inst->DstReg.WriteMask));
+ }
- switch (inst[i].Opcode) {
- case OPCODE_PRINT:
- _mesa_printf("PRINT '%s'", inst[i].Data);
- if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) {
+ if (numRegs > 0)
_mesa_printf(", ");
+
+ for (j = 0; j < numRegs; j++) {
_mesa_printf("%s[%d]%s",
- program_file_string(inst[i].SrcReg[0].File),
- inst[i].SrcReg[0].Index,
- swizzle_string(inst[i].SrcReg[0].Swizzle,
- inst[i].SrcReg[0].NegateBase));
+ program_file_string(inst->SrcReg[j].File),
+ inst->SrcReg[j].Index,
+ swizzle_string(inst->SrcReg[j].Swizzle,
+ inst->SrcReg[j].NegateBase));
+ if (j + 1 < numRegs)
+ _mesa_printf(", ");
}
+
_mesa_printf(";\n");
- 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(", ");
- }
+/**
+ * Print a vertx/fragment program to stdout.
+ * XXX this function could be greatly improved.
+ */
+void
+_mesa_print_program(const struct program *prog)
+{
+ GLuint i;
+ for (i = 0; i < prog->NumInstructions; i++) {
+ _mesa_printf("%3d: ", i);
+ _mesa_print_instruction(prog->Instructions + i);
+ }
+}
- _mesa_printf(";\n");
- }
+
+/**
+ * Print all of a program's parameters.
+ */
+void
+_mesa_print_program_parameters(GLcontext *ctx, const struct program *prog)
+{
+ GLint i;
+
+ _mesa_printf("NumInstructions=%d\n", prog->NumInstructions);
+ _mesa_printf("NumTemporaries=%d\n", prog->NumTemporaries);
+ _mesa_printf("NumParameters=%d\n", prog->NumParameters);
+ _mesa_printf("NumAttributes=%d\n", prog->NumAttributes);
+ _mesa_printf("NumAddressRegs=%d\n", prog->NumAddressRegs);
+
+ _mesa_load_state_parameters(ctx, prog->Parameters);
+
+#if 0
+ _mesa_printf("Local Params:\n");
+ for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){
+ const GLfloat *p = prog->LocalParams[i];
+ _mesa_printf("%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]);
+ }
+#endif
+
+ for (i = 0; i < prog->Parameters->NumParameters; i++){
+ const GLfloat *p = prog->Parameters->ParameterValues[i];
+ _mesa_printf("param %02d:", i);
+
+ switch (prog->Parameters->Parameters[i].Type) {
+ case PROGRAM_NAMED_PARAM:
+ _mesa_printf("%s", prog->Parameters->Parameters[i].Name);
+ _mesa_printf("(NAMED_PARAMETER)");
+ break;
+ case PROGRAM_CONSTANT:
+ _mesa_printf("(CONSTANT)");
+ break;
+ case PROGRAM_STATE_VAR:
+ _mesa_printf("(STATE)\n");
+ break;
+ default:
+ _mesa_printf("(UNK)\n");
+ break;
}
+
+ _mesa_printf("{ %f, %f, %f, %f }\n", p[0], p[1], p[2], p[3]);
}
}
-
/**********************************************************************/
/* API functions */
/**********************************************************************/
@@ -1674,7 +1714,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
else {
/* try user-defined identifiers */
const GLfloat *value = _mesa_lookup_parameter_value(
- ctx->FragmentProgram.Current->Parameters, -1, reg);
+ ctx->FragmentProgram.Current->Base.Parameters, -1, reg);
if (value) {
COPY_4V(v, value);
}
diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h
index 373a046da78..ab72f457eeb 100644
--- a/src/mesa/shader/program.h
+++ b/src/mesa/shader/program.h
@@ -256,7 +256,13 @@ _mesa_load_state_parameters(GLcontext *ctx,
extern void
-_mesa_print_program(GLuint count, const struct prog_instruction *inst);
+_mesa_print_instruction(const struct prog_instruction *inst);
+
+extern void
+_mesa_print_program(const struct program *prog);
+
+extern void
+_mesa_print_program_parameters(GLcontext *ctx, const struct program *prog);
/*