diff options
author | Brian Paul <[email protected]> | 2005-11-12 17:53:14 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2005-11-12 17:53:14 +0000 |
commit | de99760bf3511d05185799c4fb4347f9e5f420f4 (patch) | |
tree | a0bda8570a2943b4c7dabc51b7a61e5c5344eded /src/mesa/drivers | |
parent | 77ee31930a1b0cc7766939415f4f04ed6a1fa4ac (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/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i915/i915_fragprog.c | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_tris.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_fragprog.c | 18 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_maos.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_program.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_state.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_vertexprog.c | 99 |
8 files changed, 48 insertions, 98 deletions
diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c index 20424b1da43..a96b373a217 100644 --- a/src/mesa/drivers/dri/i915/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915/i915_fragprog.c @@ -130,7 +130,7 @@ static GLuint src_vector( struct i915_fragment_program *p, case PROGRAM_STATE_VAR: case PROGRAM_NAMED_PARAM: src = i915_emit_param4fv( - p, program->Parameters->ParameterValues[source->Index] ); + p, program->Base.Parameters->ParameterValues[source->Index] ); break; default: @@ -250,7 +250,7 @@ do { \ static void upload_program( struct i915_fragment_program *p ) { const struct fragment_program *program = p->ctx->FragmentProgram._Current; - const struct prog_instruction *inst = program->Instructions; + const struct prog_instruction *inst = program->Base.Instructions; /* _mesa_debug_fp_inst(program->Base.NumInstructions, inst); */ @@ -789,7 +789,7 @@ static void fixup_depth_write( struct i915_fragment_program *p ) static void check_wpos( struct i915_fragment_program *p ) { - GLuint inputs = p->FragProg.InputsRead; + GLuint inputs = p->FragProg.Base.InputsRead; GLint i; p->wpos_tex = -1; @@ -828,7 +828,7 @@ static void track_params( struct i915_fragment_program *p ) GLint i; if (p->nr_params) - _mesa_load_state_parameters(p->ctx, p->FragProg.Parameters); + _mesa_load_state_parameters(p->ctx, p->FragProg.Base.Parameters); for (i = 0; i < p->nr_params; i++) { GLint reg = p->param[i].reg; @@ -955,7 +955,7 @@ void i915ValidateFragmentProgram( i915ContextPtr i915 ) struct i915_fragment_program *p = (struct i915_fragment_program *)ctx->FragmentProgram._Current; - GLuint inputsRead = p->FragProg.InputsRead; + const GLuint inputsRead = p->FragProg.Base.InputsRead; GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK; GLuint s2 = S2_TEXCOORD_NONE; int i, offset = 0; diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index bb0a7713e60..cef6db7a195 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -642,8 +642,8 @@ void intelChooseRenderState(GLcontext *ctx) TNLcontext *tnl = TNL_CONTEXT(ctx); intelContextPtr intel = INTEL_CONTEXT(ctx); GLuint flags = ctx->_TriangleCaps; - struct fragment_program *program = ctx->FragmentProgram._Current; - GLboolean have_wpos = (program && (program->InputsRead & FRAG_BIT_WPOS)); + struct fragment_program *fprog = ctx->FragmentProgram._Current; + GLboolean have_wpos = (fprog && (fprog->Base.InputsRead & FRAG_BIT_WPOS)); GLuint index = 0; if (INTEL_DEBUG & DEBUG_STATE) diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index c35fd1e634b..5d6ebe27aad 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -598,7 +598,7 @@ struct r300_vertex_program { struct r300_vertex_shader_fragment params; int pos_end; - unsigned long num_temporaries; /* Number of temp vars used by program */ + int num_temporaries; /* Number of temp vars used by program */ int inputs[VERT_ATTRIB_MAX]; int outputs[VERT_RESULT_MAX]; }; diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c index e86904c622b..547a099fed8 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog.c @@ -421,7 +421,7 @@ static pfs_reg_t t_src(struct r300_fragment_program *rp, break; case PROGRAM_STATE_VAR: case PROGRAM_NAMED_PARAM: - r = emit_param4fv(rp, rp->mesa_program.Parameters->ParameterValues[fpsrc.Index]); + r = emit_param4fv(rp, rp->mesa_program.Base.Parameters->ParameterValues[fpsrc.Index]); break; default: ERROR("unknown SrcReg->File %x\n", fpsrc.File); @@ -747,7 +747,7 @@ static void emit_arith(struct r300_fragment_program *rp, int op, static GLboolean parse_program(struct r300_fragment_program *rp) { struct fragment_program *mp = &rp->mesa_program; - const struct prog_instruction *inst = mp->Instructions; + const struct prog_instruction *inst = mp->Base.Instructions; struct prog_instruction *fpi; pfs_reg_t src0, src1, src2, dest, temp; int flags = 0; @@ -757,7 +757,7 @@ static GLboolean parse_program(struct r300_fragment_program *rp) return GL_FALSE; } - for (fpi=mp->Instructions; fpi->Opcode != OPCODE_END; fpi++) { + for (fpi=mp->Base.Instructions; fpi->Opcode != OPCODE_END; fpi++) { if (fpi->Saturate) { flags = PFS_FLAG_SAT; } @@ -910,7 +910,7 @@ static void init_program(struct r300_fragment_program *rp) { struct fragment_program *mp = &rp->mesa_program; struct prog_instruction *fpi; - GLuint InputsRead = mp->InputsRead; + GLuint InputsRead = mp->Base.InputsRead; GLuint temps_used = 0; /* for rp->temps[] */ int i; @@ -979,11 +979,11 @@ static void init_program(struct r300_fragment_program *rp) * Possibly not too bad actually, as we could add to this later and * find out when inputs are last used so we can reuse them as temps. */ - if (!mp->Instructions) { + if (!mp->Base.Instructions) { ERROR("No instructions found in program\n"); return; } - for (fpi=mp->Instructions;fpi->Opcode != OPCODE_END; fpi++) { + for (fpi=mp->Base.Instructions;fpi->Opcode != OPCODE_END; fpi++) { for (i=0;i<3;i++) { if (fpi->SrcReg[i].File == PROGRAM_TEMPORARY) { if (!(temps_used & (1 << fpi->SrcReg[i].Index))) { @@ -1009,7 +1009,7 @@ static void update_params(struct r300_fragment_program *rp) { /* Ask Mesa nicely to fill in ParameterValues for us */ if (rp->param_nr) - _mesa_load_state_parameters(rp->ctx, mp->Parameters); + _mesa_load_state_parameters(rp->ctx, mp->Base.Parameters); for (i=0;i<rp->param_nr;i++) COPY_4V(rp->constant[rp->param[i].idx], rp->param[i].values); @@ -1054,9 +1054,7 @@ static void dump_program(struct r300_fragment_program *rp) fprintf(stderr, "Mesa program:\n"); fprintf(stderr, "-------------\n"); - _mesa_print_program(rp->mesa_program.NumTexInstructions + - rp->mesa_program.NumAluInstructions, - rp->mesa_program.Instructions); + _mesa_print_program(&rp->mesa_program.Base); fflush(stdout); fprintf(stderr, "Hardware program\n"); diff --git a/src/mesa/drivers/dri/r300/r300_maos.c b/src/mesa/drivers/dri/r300/r300_maos.c index 52827c2d5dc..6de0fb14f0f 100644 --- a/src/mesa/drivers/dri/r300/r300_maos.c +++ b/src/mesa/drivers/dri/r300/r300_maos.c @@ -296,7 +296,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) } if (hw_tcl_on) { - GLuint InputsRead = CURRENT_VERTEX_SHADER(ctx)->InputsRead; + GLuint InputsRead = CURRENT_VERTEX_SHADER(ctx)->Base.InputsRead; struct r300_vertex_program *prog=(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx); if (InputsRead & (1<<VERT_ATTRIB_POS)) { inputs |= _TNL_BIT_POS; @@ -517,7 +517,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) r300->hw.vof.cmd[R300_VOF_CNTL_0]=0; r300->hw.vof.cmd[R300_VOF_CNTL_1]=0; if (hw_tcl_on){ - GLuint OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten; + GLuint OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten; if(OutputsWritten & (1<<VERT_RESULT_HPOS)) r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; diff --git a/src/mesa/drivers/dri/r300/r300_program.h b/src/mesa/drivers/dri/r300/r300_program.h index d1754c06653..3defe106c2d 100644 --- a/src/mesa/drivers/dri/r300/r300_program.h +++ b/src/mesa/drivers/dri/r300/r300_program.h @@ -146,6 +146,5 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ((arg2) << R300_FPI2_ARG2A_SHIFT)) extern void debug_vp(GLcontext *ctx, struct vertex_program *vp); -extern void dump_program_params(GLcontext *ctx, struct vertex_program *vp); #endif /* __R300_PROGRAM_H__ */ diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 4422a233367..cc60785aac1 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1012,7 +1012,7 @@ void r300_setup_textures(GLcontext *ctx) GLuint OutputsWritten; if(hw_tcl_on) - OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten; + OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten; R300_STATECHANGE(r300, txe); R300_STATECHANGE(r300, tex.filter); @@ -1110,12 +1110,12 @@ void r300_setup_rs_unit(GLcontext *ctx) int i; if(hw_tcl_on) - OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten; + OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten; else OutputsWritten = r300->state.render_inputs; if (ctx->FragmentProgram._Current) - InputsRead = ctx->FragmentProgram._Current->InputsRead; + InputsRead = ctx->FragmentProgram._Current->Base.InputsRead; else { fprintf(stderr, "No ctx->FragmentProgram._Current!!\n"); return; /* This should only ever happen once.. */ @@ -1213,7 +1213,7 @@ void r300_setup_rs_unit(GLcontext *ctx) GLuint OutputsWritten; if(hw_tcl_on) - OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten; + OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->Base.OutputsWritten; /* This needs to be rewritten - it is a hack at best */ diff --git a/src/mesa/drivers/dri/r300/r300_vertexprog.c b/src/mesa/drivers/dri/r300/r300_vertexprog.c index 2462ac8d7cb..f6c9db9fdc1 100644 --- a/src/mesa/drivers/dri/r300/r300_vertexprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertexprog.c @@ -132,67 +132,18 @@ static char *dst_mask_names[4]={ "X", "Y", "Z", "W" }; XPD v,v v cross product */ -void dump_program_params(GLcontext *ctx, struct vertex_program *vp) -{ - int i; - int pi; - - fprintf(stderr, "NumInstructions=%d\n", vp->Base.NumInstructions); - fprintf(stderr, "NumTemporaries=%d\n", vp->Base.NumTemporaries); - fprintf(stderr, "NumParameters=%d\n", vp->Base.NumParameters); - fprintf(stderr, "NumAttributes=%d\n", vp->Base.NumAttributes); - fprintf(stderr, "NumAddressRegs=%d\n", vp->Base.NumAddressRegs); - - _mesa_load_state_parameters(ctx, vp->Parameters); - -#if 0 - for(pi=0; pi < vp->Base.NumParameters; pi++){ - fprintf(stderr, "{ "); - for(i=0; i < 4; i++) - fprintf(stderr, "%f ", vp->Base.LocalParams[pi][i]); - fprintf(stderr, "}\n"); - } -#endif - for(pi=0; pi < vp->Parameters->NumParameters; pi++){ - fprintf(stderr, "param %02d:", pi); - - switch(vp->Parameters->Parameters[pi].Type){ - - case PROGRAM_NAMED_PARAM: - fprintf(stderr, "%s", vp->Parameters->Parameters[pi].Name); - fprintf(stderr, "(NAMED_PARAMETER)"); - break; - - case PROGRAM_CONSTANT: - fprintf(stderr, "(CONSTANT)"); - break; - - case PROGRAM_STATE_VAR: - fprintf(stderr, "(STATE)\n"); - break; - - default: - fprintf(stderr, "(UNK)\n"); - break; - } - - fprintf(stderr, "{ "); - for(i=0; i < 4; i++) - fprintf(stderr, "%f ", vp->Parameters->ParameterValues[pi][i]); - fprintf(stderr, "}\n"); - - } -} - +/* + * XXX get rid of this function. Use _mesa_print_program() instead. + */ void debug_vp(GLcontext *ctx, struct vertex_program *vp) { struct prog_instruction *vpi; int i, operand_index; int operator_index; - dump_program_params(ctx, vp); + _mesa_print_program_parameters(ctx, &vp->Base); - vpi=vp->Instructions; + vpi=vp->Base.Instructions; for(;; vpi++){ if(vpi->Opcode == OPCODE_END) @@ -250,26 +201,28 @@ int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program *vp, f int pi; struct vertex_program *mesa_vp=(void *)vp; float *dst_o=dst; + struct program_parameter_list *paramList; - _mesa_load_state_parameters(ctx, mesa_vp->Parameters); + _mesa_load_state_parameters(ctx, mesa_vp->Base.Parameters); //debug_vp(ctx, mesa_vp); - if(mesa_vp->Parameters->NumParameters * 4 > VSF_MAX_FRAGMENT_LENGTH){ + if(mesa_vp->Base.Parameters->NumParameters * 4 > VSF_MAX_FRAGMENT_LENGTH){ fprintf(stderr, "%s:Params exhausted\n", __FUNCTION__); exit(-1); } - for(pi=0; pi < mesa_vp->Parameters->NumParameters; pi++){ - switch(mesa_vp->Parameters->Parameters[pi].Type){ + paramList = mesa_vp->Base.Parameters; + for(pi=0; pi < paramList->NumParameters; pi++){ + switch(paramList->Parameters[pi].Type){ case PROGRAM_STATE_VAR: case PROGRAM_NAMED_PARAM: //fprintf(stderr, "%s", vp->Parameters->Parameters[pi].Name); case PROGRAM_CONSTANT: - *dst++=mesa_vp->Parameters->ParameterValues[pi][0]; - *dst++=mesa_vp->Parameters->ParameterValues[pi][1]; - *dst++=mesa_vp->Parameters->ParameterValues[pi][2]; - *dst++=mesa_vp->Parameters->ParameterValues[pi][3]; + *dst++=paramList->ParameterValues[pi][0]; + *dst++=paramList->ParameterValues[pi][1]; + *dst++=paramList->ParameterValues[pi][2]; + *dst++=paramList->ParameterValues[pi][3]; break; default: _mesa_problem(NULL, "Bad param type in %s", __FUNCTION__); @@ -509,39 +462,39 @@ void translate_vertex_shader(struct r300_vertex_program *vp) for(i=0; i < VERT_RESULT_MAX; i++) vp->outputs[i] = -1; - assert(mesa_vp->OutputsWritten & (1 << VERT_RESULT_HPOS)); - assert(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL0)); + assert(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_HPOS)); + assert(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_COL0)); /* Assign outputs */ - if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_HPOS)) + if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_HPOS)) vp->outputs[VERT_RESULT_HPOS] = cur_reg++; - if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_PSIZ)) + if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) vp->outputs[VERT_RESULT_PSIZ] = cur_reg++; - if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL0)) + if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_COL0)) vp->outputs[VERT_RESULT_COL0] = cur_reg++; #if 0 /* Not supported yet */ - if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_BFC0)) + if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_BFC0)) vp->outputs[VERT_RESULT_BFC0] = cur_reg++; - if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL1)) + if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_COL1)) vp->outputs[VERT_RESULT_COL1] = cur_reg++; - if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_BFC1)) + if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_BFC1)) vp->outputs[VERT_RESULT_BFC1] = cur_reg++; - if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_FOGC)) + if(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_FOGC)) vp->outputs[VERT_RESULT_FOGC] = cur_reg++; #endif for(i=VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) - if(mesa_vp->OutputsWritten & (1 << i)) + if(mesa_vp->Base.OutputsWritten & (1 << i)) vp->outputs[i] = cur_reg++; o_inst=vp->program.body.i; - for(vpi=mesa_vp->Instructions; vpi->Opcode != OPCODE_END; vpi++, o_inst++){ + for(vpi=mesa_vp->Base.Instructions; vpi->Opcode != OPCODE_END; vpi++, o_inst++){ operands=op_operands(vpi->Opcode); are_srcs_scalar=operands & SCALAR_FLAG; |