From de99760bf3511d05185799c4fb4347f9e5f420f4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 12 Nov 2005 17:53:14 +0000 Subject: 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(). --- src/mesa/tnl/t_vb_arbprogram.c | 16 ++++++++-------- src/mesa/tnl/t_vb_program.c | 6 +++--- src/mesa/tnl/t_vp_build.c | 25 +++++++++++++------------ 3 files changed, 24 insertions(+), 23 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 27ff50932c..bf784446cd 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -1109,7 +1109,7 @@ static void compile_vertex_program( struct vertex_program *program, /* Compile instructions: */ for (i = 0; i < program->Base.NumInstructions; i++) { - cvp_emit_inst(&cp, &program->Instructions[i]); + cvp_emit_inst(&cp, &program->Base.Instructions[i]); } /* Finish up: @@ -1269,8 +1269,8 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) if (!program || program->IsNVProgram) return GL_TRUE; - if (program->Parameters) { - _mesa_load_state_parameters(ctx, program->Parameters); + if (program->Base.Parameters) { + _mesa_load_state_parameters(ctx, program->Base.Parameters); } p = (struct tnl_compiled_program *)program->TnlData; @@ -1280,7 +1280,7 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) m->nr_inputs = m->nr_outputs = 0; for (i = 0; i < _TNL_ATTRIB_MAX; i++) { - if (program->InputsRead & (1<Base.InputsRead & (1<nr_inputs++; m->input[j].idx = i; m->input[j].data = (GLfloat *)m->VB->AttribPtr[i]->data; @@ -1291,7 +1291,7 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) } for (i = 0; i < VERT_RESULT_MAX; i++) { - if (program->OutputsWritten & (1<Base.OutputsWritten & (1 << i)) { GLuint j = m->nr_outputs++; m->output[j].idx = i; m->output[j].data = (GLfloat *)m->attribs[i].data; @@ -1347,7 +1347,7 @@ run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage) VB->ClipPtr = &m->attribs[VERT_RESULT_HPOS]; VB->ClipPtr->count = VB->Count; - outputs = program->OutputsWritten; + outputs = program->Base.OutputsWritten; if (outputs & (1<ColorPtr[0] = &m->attribs[VERT_RESULT_COL0]; @@ -1424,8 +1424,8 @@ validate_vertex_program( GLcontext *ctx, struct tnl_pipeline_stage *stage ) m->File[FILE_LOCAL_PARAM] = program->Base.LocalParams; m->File[FILE_ENV_PARAM] = ctx->VertexProgram.Parameters; /* GL_NV_vertex_programs can't reference GL state */ - if (program->Parameters) - m->File[FILE_STATE_PARAM] = program->Parameters->ParameterValues; + if (program->Base.Parameters) + m->File[FILE_STATE_PARAM] = program->Base.Parameters->ParameterValues; else m->File[FILE_STATE_PARAM] = NULL; } diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 0f53657183..297b731b1d 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -112,7 +112,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) /* the vertex array case */ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { - if (program->InputsRead & (1 << attr)) { + if (program->Base.InputsRead & (1 << attr)) { const GLubyte *ptr = (const GLubyte*) VB->AttribPtr[attr]->data; const GLuint size = VB->AttribPtr[attr]->size; const GLuint stride = VB->AttribPtr[attr]->stride; @@ -127,12 +127,12 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) /* Fixup fog an point size results if needed */ if (ctx->Fog.Enabled && - (program->OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) { + (program->Base.OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) { ctx->VertexProgram.Outputs[VERT_RESULT_FOGC][0] = 1.0; } if (ctx->VertexProgram.PointSizeEnabled && - (program->OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) { + (program->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) { ctx->VertexProgram.Outputs[VERT_RESULT_PSIZ][0] = ctx->Point.Size; } diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 4ff70cd6ed..0f1f303be2 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.3.1 + * Version: 6.5 * * Copyright (C) 2005 Tungsten Graphics All Rights Reserved. * @@ -124,7 +124,7 @@ static struct state_key *make_state_key( GLcontext *ctx ) */ assert(fp); - key->fragprog_inputs_read = fp->InputsRead; + key->fragprog_inputs_read = fp->Base.InputsRead; key->separate_specular = (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR); @@ -365,13 +365,13 @@ static void release_temps( struct tnl_program *p ) static struct ureg register_input( struct tnl_program *p, GLuint input ) { - p->program->InputsRead |= (1<program->Base.InputsRead |= (1<program->OutputsWritten |= (1<program->Base.OutputsWritten |= (1<program->Parameters, values ); + idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values ); return make_ureg(PROGRAM_STATE_VAR, idx); } @@ -425,7 +425,7 @@ static struct ureg register_param6( struct tnl_program *p, tokens[3] = s3; tokens[4] = s4; tokens[5] = s5; - idx = _mesa_add_state_reference( p->program->Parameters, tokens ); + idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens ); return make_ureg(PROGRAM_STATE_VAR, idx); } @@ -492,7 +492,7 @@ static void debug_insn( struct prog_instruction *inst, const char *fn, } _mesa_printf("%d:\t", line); - _mesa_print_program(1, inst); + _mesa_print_instruction(inst); } } @@ -508,7 +508,7 @@ static void emit_op3fn(struct tnl_program *p, GLuint line) { GLuint nr = p->program->Base.NumInstructions++; - struct prog_instruction *inst = &p->program->Instructions[nr]; + struct prog_instruction *inst = &p->program->Base.Instructions[nr]; if (p->program->Base.NumInstructions > MAX_INSN) { _mesa_problem(0, "Out of instructions in emit_op3fn\n"); @@ -1406,15 +1406,16 @@ create_new_program( const struct state_key *key, else p.temp_reserved = ~((1<Instructions = MALLOC(sizeof(struct prog_instruction) * MAX_INSN); + p.program->Base.Instructions + = MALLOC(sizeof(struct prog_instruction) * MAX_INSN); p.program->Base.String = 0; p.program->Base.NumInstructions = p.program->Base.NumTemporaries = p.program->Base.NumParameters = p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0; - p.program->Parameters = _mesa_new_parameter_list(); - p.program->InputsRead = 0; - p.program->OutputsWritten = 0; + p.program->Base.Parameters = _mesa_new_parameter_list(); + p.program->Base.InputsRead = 0; + p.program->Base.OutputsWritten = 0; build_tnl_program( &p ); } -- cgit v1.2.3