Proper VAP output configuration as R300_RS_ROUTE_0_COLOR became optional and broke...
authorAapo Tahkola <aet@rasterburn.org>
Wed, 16 Mar 2005 22:32:48 +0000 (22:32 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Wed, 16 Mar 2005 22:32:48 +0000 (22:32 +0000)
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_maos.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_vertexprog.c

index 66eaa0f2b22c0cac20a3af75c7ab8deaa5471207..9075f6321fe9c72580d0b801a9bfb8b3417fc24c 100644 (file)
@@ -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 */
index 547ab359b9bd83d3a2c901a4d0309a09f7d68173..39d446034aec6e6fabdf41da144fae70b2dd37e6 100644 (file)
@@ -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;i<ctx->Const.MaxTextureUnits;i++) 
+                       if(ctx->Texture.Unit[i].Enabled == 0)
+                               inputs &= ~ (_TNL_BIT_TEX0<<i);*/
        }
        rmesa->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<<i))
+               if(outputs & (_TNL_BIT_TEX0<<i))
                        r300->hw.vof.cmd[R300_VOF_CNTL_1]|=(4<<(3*i));
 
        rmesa->state.aos_count = nr;
index 73005eb82de8e2c94e15c1fae351ba219947a685..716f62346a41306b71ad413ddb8b462e26694579 100644 (file)
@@ -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<<i))!=0) != ((ctx->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<<i))!=0), ((ctx->Texture.Unit[i].Enabled)!=0));
                }
                
                if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)) {
@@ -1422,6 +1423,7 @@ void r300_setup_rs_unit(GLcontext *ctx)
                0x00,
                0x00
        };
+       GLuint vap_outputs;
        
        /* This needs to be rewritten - it is a hack at best */
 
@@ -1433,6 +1435,11 @@ void r300_setup_rs_unit(GLcontext *ctx)
        cur_reg = 0;
        r300->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;i<ctx->Const.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);
index 811f9ccb55fd7a936450950066ef53d117be1d67..428fe41258a4bee0e7cccf0a0fb20eef906026c8 100644 (file)
@@ -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++){