r300: recombine the vap input route 0 code and clean
authorDave Airlie <airlied@linux.ie>
Sat, 3 May 2008 11:31:47 +0000 (21:31 +1000)
committerDave Airlie <airlied@linux.ie>
Sat, 3 May 2008 11:31:47 +0000 (21:31 +1000)
This gets non-tcl cards working again on this branch..

at least texrect and glxgears

src/mesa/drivers/dri/r300/r300_emit.c
src/mesa/drivers/dri/r300/r300_emit.h
src/mesa/drivers/dri/r300/r300_swtcl.c

index 0eeb8bf98a37c53a44a41ef2da1327eb67016116..dc08b642c52828f5bc7fa75e32cea119e51c6634 100644 (file)
@@ -207,7 +207,10 @@ static void r300EmitVec(GLcontext * ctx, struct r300_dma_region *rvb,
        }
 }
 
-static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
+#define DW_SIZE(x) ((inputs[tab[(x)]] << R300_DST_VEC_LOC_SHIFT) |     \
+                   (attribptr[tab[(x)]]->size - 1) << R300_DATA_TYPE_0_SHIFT)
+
+GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
                                 int *inputs, GLint * tab, GLuint nr)
 {
        GLuint i, dw;
@@ -216,16 +219,13 @@ static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
        for (i = 0; i < nr; i += 2) {
                /* make sure input is valid, would lockup the gpu */
                assert(inputs[tab[i]] != -1);
-               dw = (R300_SIGNED |
-                     (inputs[tab[i]] << R300_DST_VEC_LOC_SHIFT) |
-                     (attribptr[tab[i]]->size - 1)) << R300_DATA_TYPE_0_SHIFT;
+               dw = (R300_SIGNED | DW_SIZE(i));
                if (i + 1 == nr) {
                        dw |= R300_LAST_VEC << R300_DATA_TYPE_0_SHIFT;
                } else {
                        assert(inputs[tab[i + 1]] != -1);
                        dw |= (R300_SIGNED |
-                              (inputs[tab[i + 1]] << R300_DST_VEC_LOC_SHIFT) |
-                              (attribptr[tab[i + 1]]->size - 1)) << R300_DATA_TYPE_1_SHIFT;
+                              DW_SIZE(i + 1)) << R300_DATA_TYPE_1_SHIFT;
                        if (i + 2 == nr) {
                                dw |= R300_LAST_VEC << R300_DATA_TYPE_1_SHIFT;
                        }
index 51302301f7bb9cb1d13dffd36a9120e19841b7f9..e6a6df8c4c2f7ffd73779a54f41879a54a077ad9 100644 (file)
@@ -257,6 +257,8 @@ extern int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim);
 
 extern void r300EmitCacheFlush(r300ContextPtr rmesa);
 
+extern GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
+                                int *inputs, GLint * tab, GLuint nr);
 extern GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr);
 extern GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead);
 extern GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead);
index 699499d7ccfcee8a9f9e68e110c887efa538beb0..15e66317a9e23e66647954dd7cd69b095054d4eb 100644 (file)
@@ -78,36 +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 < nr; i += 2) {
-               /* make sure input is valid, would lockup the gpu */
-               assert(inputs[tab[i]] != -1);
-               dw = (R300_SIGNED |
-                     (inputs[tab[i]] << R300_DST_VEC_LOC_SHIFT) |
-                     (attribptr[tab[i]]->size - 1)) << R300_DATA_TYPE_0_SHIFT;
-               if (i + 1 == nr) {
-                       dw |= R300_LAST_VEC << R300_DATA_TYPE_0_SHIFT;
-               } else {
-                       assert(inputs[tab[i + 1]] != -1);
-                       dw |= (R300_SIGNED |
-                              (inputs[tab[i + 1]] << R300_DST_VEC_LOC_SHIFT) |
-                              (attribptr[tab[i + 1]]->size - 1)) << R300_DATA_TYPE_1_SHIFT;
-                       if (i + 2 == nr) {
-                               dw |= R300_LAST_VEC << R300_DATA_TYPE_1_SHIFT;
-                       }
-               }
-               dst[i >> 1] = dw;
-       }
-
-       return (nr + 1) >> 1;
-}
-
 static void r300SetVertexFormat( GLcontext *ctx )
 {
        r300ContextPtr rmesa = R300_CONTEXT( ctx );
@@ -123,6 +93,7 @@ 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);
@@ -145,14 +116,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 );
@@ -161,18 +133,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;
        }
@@ -182,9 +155,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);
                        }
                }
        }
@@ -243,7 +218,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,