nv40: use vb/ve counts rather than shader inputs for related loops
authorBen Skeggs <skeggsb@gmail.com>
Wed, 9 Apr 2008 03:58:51 +0000 (13:58 +1000)
committerBen Skeggs <skeggsb@gmail.com>
Wed, 9 Apr 2008 04:02:55 +0000 (14:02 +1000)
src/gallium/drivers/nv40/nv40_draw.c
src/gallium/drivers/nv40/nv40_vbo.c

index 7f008aca3a806aafd324456f214dfc85e70a21fd..dd5cc8fc998393686d24056ffe763a14e6855595 100644 (file)
@@ -239,9 +239,7 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
        nv40->state.dirty &= ~(1ULL << NV40_STATE_VTXBUF);
        nv40_state_emit(nv40);
 
-       for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
-               if (!nv40->vtxbuf[i].buffer)
-                       continue;
+       for (i = 0; i < nv40->vtxbuf_nr; i++) {
                map = ws->buffer_map(ws, nv40->vtxbuf[i].buffer,
                                     PIPE_BUFFER_USAGE_CPU_READ);
                draw_set_mapped_vertex_buffer(nv40->draw, i, map);
@@ -262,11 +260,8 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
 
        draw_arrays(nv40->draw, mode, start, count);
 
-       for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
-               if (!nv40->vtxbuf[i].buffer)
-                       continue;
+       for (i = 0; i < nv40->vtxbuf_nr; i++)
                ws->buffer_unmap(ws, nv40->vtxbuf[i].buffer);
-       }
 
        if (idxbuf)
                ws->buffer_unmap(ws, idxbuf);
index ec88470b317daa364ce16e0be56dc113ccf7212d..06374184b124481945d98e493a7c3c83ab6ff487 100644 (file)
@@ -481,40 +481,23 @@ nv40_draw_elements(struct pipe_context *pipe,
 static boolean
 nv40_vbo_validate(struct nv40_context *nv40)
 {
-       struct nv40_vertex_program *vp = nv40->vertprog;
        struct nouveau_stateobj *vtxbuf, *vtxfmt, *sattr = NULL;
        struct nouveau_grobj *curie = nv40->screen->curie;
        struct pipe_buffer *ib = nv40->idxbuf;
        unsigned ib_format = nv40->idxbuf_format;
-       unsigned inputs, hw, num_hw;
        unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
-
-       inputs = vp->ir;
-       for (hw = 0; hw < 16 && inputs; hw++) {
-               if (inputs & (1 << hw)) {
-                       num_hw = hw;
-                       inputs &= ~(1 << hw);
-               }
-       }
-       num_hw++;
+       int hw;
 
        vtxbuf = so_new(20, 18);
-       so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), num_hw);
+       so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt_nr);
        vtxfmt = so_new(17, 0);
-       so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), num_hw);
+       so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt_nr);
 
-       inputs = vp->ir;
-       for (hw = 0; hw < num_hw; hw++) {
+       for (hw = 0; hw < nv40->vtxelt_nr; hw++) {
                struct pipe_vertex_element *ve;
                struct pipe_vertex_buffer *vb;
                unsigned type, ncomp;
 
-               if (!(inputs & (1 << hw))) {
-                       so_data(vtxbuf, 0);
-                       so_data(vtxfmt, NV40TCL_VTXFMT_TYPE_FLOAT);
-                       continue;
-               }
-
                ve = &nv40->vtxelt[hw];
                vb = &nv40->vtxbuf[ve->vertex_buffer_index];