r5xx: Dump shader constants when dumping program assembly.
[mesa.git] / src / mesa / drivers / dri / r300 / r300_swtcl.c
index c949f33bf33eb348432555c2aa15971258073408..8aebd9be3ea0b9f434576702c7d2609c23b280f6 100644 (file)
@@ -40,6 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "enums.h"
 #include "image.h"
 #include "imports.h"
+#include "light.h"
 #include "macros.h"
 
 #include "swrast/s_context.h"
@@ -77,31 +78,6 @@ do {                                                                 \
    rmesa->swtcl.vertex_attr_count++;                                   \
 } while (0)
 
-/* this differs from the VIR0 in emit.c - TODO merge them using another option */
-static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
-                                int *inputs, GLint * tab, GLuint nr)
-{
-       GLuint i, dw;
-
-       /* type, inputs, stop bit, size */
-       for (i = 0; i + 1 < nr; i += 2) {
-               dw = (inputs[tab[i]] << 8) | 0x3;
-               dw |= ((inputs[tab[i + 1]] << 8) | 0x3) << 16;
-               if (i + 2 == nr) {
-                       dw |= (R300_VAP_INPUT_ROUTE_END << 16);
-               }
-               dst[i >> 1] = dw;
-       }
-
-       if (nr & 1) {
-               dw = (inputs[tab[nr - 1]] << 8) | 0x3;
-               dw |= R300_VAP_INPUT_ROUTE_END;
-               dst[nr >> 1] = dw;
-       }
-
-       return (nr + 1) >> 1;
-}
-
 static void r300SetVertexFormat( GLcontext *ctx )
 {
        r300ContextPtr rmesa = R300_CONTEXT( ctx );
@@ -117,19 +93,24 @@ static void r300SetVertexFormat( GLcontext *ctx )
        GLint tab[VERT_ATTRIB_MAX];
        int swizzle[VERT_ATTRIB_MAX][4];
        GLuint i, nr;
+       GLuint sz, vap_fmt_1 = 0;
 
        DECLARE_RENDERINPUTS(render_inputs_bitset);
        RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset);
        RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
        RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset);
 
+       vte = rmesa->hw.vte.cmd[1];
+       vte &= ~(R300_VTX_XY_FMT | R300_VTX_Z_FMT | R300_VTX_W0_FMT);
        /* Important:
         */
        if ( VB->NdcPtr != NULL ) {
                VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+               vte |= R300_VTX_XY_FMT | R300_VTX_Z_FMT;
        }
        else {
                VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr;
+               vte |= R300_VTX_W0_FMT;
        }
 
        assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL );
@@ -139,14 +120,15 @@ static void r300SetVertexFormat( GLcontext *ctx )
         * build up a hardware vertex.
         */
        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POS)) {
-               vap_vte_cntl |= R300_VTX_W0_FMT;
+               sz = VB->AttribPtr[VERT_ATTRIB_POS]->size;
                InputsRead |= 1 << VERT_ATTRIB_POS;
                OutputsWritten |= 1 << VERT_RESULT_HPOS;
-               EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F );
-       } else
+               EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_1F + sz - 1 );
+               offset = sz;
+       } else {
+               offset = 4;
                EMIT_PAD(4 * sizeof(float));
-
-       offset = 4;
+       }
 
        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) {
                EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F );
@@ -155,18 +137,19 @@ static void r300SetVertexFormat( GLcontext *ctx )
        }
 
        if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR0)) {
+               sz = VB->AttribPtr[VERT_ATTRIB_COLOR0]->size;
                rmesa->swtcl.coloroffset = offset;
                InputsRead |= 1 << VERT_ATTRIB_COLOR0;
                OutputsWritten |= 1 << VERT_RESULT_COL0;
-               EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F );
+               EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_1F + sz - 1 );
+               offset += sz;
        }
 
-       offset += 4;
-
        rmesa->swtcl.specoffset = 0;
        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
+               sz = VB->AttribPtr[VERT_ATTRIB_COLOR1]->size;
                rmesa->swtcl.specoffset = offset;
-               EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F );
+               EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_1F + sz - 1 );
                InputsRead |= 1 << VERT_ATTRIB_COLOR1;
                OutputsWritten |= 1 << VERT_RESULT_COL1;
        }
@@ -176,9 +159,11 @@ static void r300SetVertexFormat( GLcontext *ctx )
 
                for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
                        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
+                               sz = VB->TexCoordPtr[i]->size;
                                InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i);
                                OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
-                               EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F );
+                               EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1 );
+                               vap_fmt_1 |= sz << (3 * i);
                        }
                }
        }
@@ -237,7 +222,7 @@ static void r300SetVertexFormat( GLcontext *ctx )
    
        R300_STATECHANGE(rmesa, vof);
        rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten);
-       rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten);
+       rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = vap_fmt_1;
    
        rmesa->swtcl.vertex_size =
                _tnl_install_attrs( ctx,
@@ -249,7 +234,7 @@ static void r300SetVertexFormat( GLcontext *ctx )
 
        RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset );
 
-       vte = rmesa->hw.vte.cmd[1];
+
        R300_STATECHANGE(rmesa, vte);
        rmesa->hw.vte.cmd[1] = vte;
        rmesa->hw.vte.cmd[2] = rmesa->swtcl.vertex_size;
@@ -590,6 +575,7 @@ static void r300RenderStart(GLcontext *ctx)
        r300ChooseRenderState(ctx);     
        r300SetVertexFormat(ctx);
 
+       r300UpdateShaders(rmesa);
        r300UpdateShaderStates(rmesa);
 
        r300EmitCacheFlush(rmesa);