st/nine: Rework update_vertex_buffers
authorAxel Davy <axel.davy@ens.fr>
Fri, 20 Feb 2015 17:25:44 +0000 (18:25 +0100)
committerAxel Davy <axel.davy@ens.fr>
Wed, 29 Apr 2015 06:28:11 +0000 (08:28 +0200)
Previous code was trying to optimise to call set_vertex_buffers on
big packets, and thus avoids as many calls as possible.

However in practice doing so won't be faster (drivers implement
set_vertex_buffers by a loop over the buffers we want to bind)

When we want to unbind a buffer, we were calling set_vertex_buffers
on a buffer with vtxbuf->buffer = NULL. It works on some drivers,
but not on all of them, because it isn't in Gallium spec.
This patch fixes that.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/nine_state.c

index 27800c61c2a763e07be809d86131fc657f0154f7..6e019558c151e440b4a53f756d3723b79c6d9845 100644 (file)
@@ -631,7 +631,6 @@ update_vertex_buffers(struct NineDevice9 *device)
     uint32_t mask = state->changed.vtxbuf;
     unsigned i;
     unsigned start;
-    unsigned count = 0;
 
     DBG("mask=%x\n", mask);
 
@@ -650,18 +649,12 @@ update_vertex_buffers(struct NineDevice9 *device)
 
     for (i = 0; mask; mask >>= 1, ++i) {
         if (mask & 1) {
-            if (!count)
-                start = i;
-            ++count;
-        } else {
-            if (count)
-                pipe->set_vertex_buffers(pipe, start, count,
-                                         &state->vtxbuf[start]);
-            count = 0;
+            if (state->vtxbuf[i].buffer)
+                pipe->set_vertex_buffers(pipe, i, 1, &state->vtxbuf[i]);
+            else
+                pipe->set_vertex_buffers(pipe, i, 1, NULL);
         }
     }
-    if (count)
-        pipe->set_vertex_buffers(pipe, start, count, &state->vtxbuf[start]);
 
     state->changed.vtxbuf = 0;
 }