From: Aapo Tahkola Date: Wed, 16 Mar 2005 22:32:48 +0000 (+0000) Subject: Proper VAP output configuration as R300_RS_ROUTE_0_COLOR became optional and broke... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c1aa3d1e6f6fd3971df93b11d4db139bec824c91;p=mesa.git Proper VAP output configuration as R300_RS_ROUTE_0_COLOR became optional and broke arbvptorus(takes no input color but produces output color). Also removing some useless code. --- diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 66eaa0f2b22..9075f6321fe 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -579,6 +579,7 @@ struct r300_vertex_program { int t2rs; unsigned long num_temporaries; /* Number of temp vars used by program */ int inputs[VERT_ATTRIB_MAX]; + GLuint outputs; }; /* 64 appears to be the maximum */ diff --git a/src/mesa/drivers/dri/r300/r300_maos.c b/src/mesa/drivers/dri/r300/r300_maos.c index 547ab359b9b..39d446034ae 100644 --- a/src/mesa/drivers/dri/r300/r300_maos.c +++ b/src/mesa/drivers/dri/r300/r300_maos.c @@ -243,7 +243,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) GLuint vic_1 = 0; /* R300_VAP_INPUT_CNTL_1 */ GLuint aa_vap_reg = 0; /* VAP register assignment */ GLuint i; - GLuint inputs = 0; + GLuint inputs = 0, outputs = 0; #define CONFIGURE_AOS(r, f, v, sz, cn) { \ @@ -306,6 +306,14 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd) nr = 0; } else { inputs = TNL_CONTEXT(ctx)->render_inputs; + /* Hack to see what would happen if we would enable tex units according to their enabled values. + Why arent we doing this? + As for vertex programs tex coords should be passed if program wants them as some programs might deliver + some other values to the program with them. Futher more some programs might generate output tex coords + without taking them as inputs. */ + /*for (i=0;iConst.MaxTextureUnits;i++) + if(ctx->Texture.Unit[i].Enabled == 0) + inputs &= ~ (_TNL_BIT_TEX0<state.render_inputs = inputs; @@ -489,13 +497,22 @@ drm_radeon_cmd_header_t *cmd = NULL; #endif /* Stage 3: VAP output */ + if (rmesa->current_vp != NULL) + outputs = rmesa->current_vp->outputs; + else + outputs = inputs; + R300_STATECHANGE(r300, vof); - r300->hw.vof.cmd[R300_VOF_CNTL_0]=R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT - | R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; + + r300->hw.vof.cmd[R300_VOF_CNTL_0]=0; + if(outputs & _TNL_BIT_POS) + r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; + if(outputs & _TNL_BIT_COLOR0) + r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; r300->hw.vof.cmd[R300_VOF_CNTL_1]=0; for(i=0;i < ctx->Const.MaxTextureUnits;i++) - if(r300->state.render_inputs & (_TNL_BIT_TEX0<hw.vof.cmd[R300_VOF_CNTL_1]|=(4<<(3*i)); rmesa->state.aos_count = nr; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 73005eb82de..716f62346a4 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1356,7 +1356,8 @@ void r300_setup_textures(GLcontext *ctx) /*if(ctx->Texture.Unit[i].Enabled == 0) continue;*/ if( ((r300->state.render_inputs & (_TNL_BIT_TEX0<Texture.Unit[i].Enabled)!=0) ) { - WARN_ONCE("Mismatch between render_inputs and ctx->Texture.Unit[i].Enabled value.\n"); + WARN_ONCE("Mismatch between render_inputs and ctx->Texture.Unit[i].Enabled value(%d vs %d).\n", + ((r300->state.render_inputs & (_TNL_BIT_TEX0<Texture.Unit[i].Enabled)!=0)); } if(r300->state.render_inputs & (_TNL_BIT_TEX0<hw.rr.cmd[R300_RR_ROUTE_0] = 0; + if (r300->current_vp != NULL) + vap_outputs = r300->current_vp->outputs; + else + vap_outputs = r300->state.render_inputs; + for (i=0;iConst.MaxTextureUnits;i++) { r300->hw.ri.cmd[R300_RI_INTERP_0+i] = 0 | R300_RS_INTERP_USED @@ -1450,7 +1457,7 @@ void r300_setup_rs_unit(GLcontext *ctx) cur_reg++; } } - if (r300->state.render_inputs & _TNL_BIT_COLOR0) + if (vap_outputs & _TNL_BIT_COLOR0) r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0 | R300_RS_ROUTE_0_COLOR | (cur_reg << R300_RS_ROUTE_0_COLOR_DEST_SHIFT); diff --git a/src/mesa/drivers/dri/r300/r300_vertexprog.c b/src/mesa/drivers/dri/r300/r300_vertexprog.c index 811f9ccb55f..428fe41258a 100644 --- a/src/mesa/drivers/dri/r300/r300_vertexprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertexprog.c @@ -373,16 +373,6 @@ static unsigned long t_src_index(struct r300_vertex_program *vp, struct vp_src_r int max_reg=-1; if(src->File == PROGRAM_INPUT){ - /* - switch(src->Index){ - case 0: return 0; - case 3: return 1; - - case 2: return 2; - case 8: return 8; - - default: printf("unknown input index %d\n", src->Index); exit(0); break; - }*/ if(vp->inputs[src->Index] != -1) return vp->inputs[src->Index]; @@ -487,6 +477,23 @@ static void translate_program(struct r300_vertex_program *vp) for(i=0; i < VERT_ATTRIB_MAX; i++) vp->inputs[i]=-1; + vp->outputs = 0; + /* FIXME: hardcoded values in arbprogparse.c:parse_result_binding () + We might want to use these constants for VAP output in general as well once they have been added to + mesa headers. + */ + if(mesa_vp->OutputsWritten & (1<<0)) + vp->outputs |= _TNL_BIT_POS; + if(mesa_vp->OutputsWritten & (1<<1)) + vp->outputs |= _TNL_BIT_COLOR0; + if(mesa_vp->OutputsWritten & (1<<2)) + vp->outputs |= _TNL_BIT_COLOR1; + for(i=0; i < 8/*ctx->Const.MaxTextureUnits*/; i++) + if(mesa_vp->OutputsWritten & (1<<(7+i))) + vp->outputs |= _TNL_BIT_TEX(i); + if(mesa_vp->OutputsWritten & ~(0x7 | 0x3f80)) + fprintf(stderr, "%s:Odd bits(0x%08x)\n", __FUNCTION__, mesa_vp->OutputsWritten); + o_inst=vp->program.body.i; for(vpi=mesa_vp->Instructions; vpi->Opcode != VP_OPCODE_END; vpi++, o_inst++){