r300g/swtcl: move vertex buffer updates into set_vertex_buffers
authorMarek Olšák <maraeo@gmail.com>
Fri, 11 May 2012 21:33:50 +0000 (23:33 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 11 May 2012 22:50:53 +0000 (00:50 +0200)
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_state.c

index ea82e49d450080e91fa5967a4edffc331a184a47..ceda1269707b601eebabd763154a46bab4c3867e 100644 (file)
@@ -855,7 +855,6 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
                                 const struct pipe_draw_info *info)
 {
     struct r300_context* r300 = r300_context(pipe);
-    int i;
     boolean indexed = info->indexed;
 
     if (r300->skip_rendering) {
@@ -869,16 +868,6 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
             (indexed ? PREP_INDEXED : 0),
             indexed ? 256 : 6);
 
-    for (i = 0; i < r300->nr_vertex_buffers; i++) {
-        if (r300->vertex_buffer[i].user_buffer) {
-            draw_set_mapped_vertex_buffer(r300->draw, i,
-                                          r300->vertex_buffer[i].user_buffer);
-        } else if (r300->vertex_buffer[i].buffer) {
-            draw_set_mapped_vertex_buffer(r300->draw, i,
-                r300_resource(r300->vertex_buffer[i].buffer)->malloced_buffer);
-        }
-    }
-
     r300->draw_vbo_locked = TRUE;
     r300->draw_first_emitted = FALSE;
     draw_vbo(r300->draw, info);
index cecbfd213f340e9fb16977983578163b0791eb04..812fe39155a9a31fe0e05ce279d815133b3eb471 100644 (file)
@@ -1588,29 +1588,45 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
     }
 }
 
-static void r300_set_vertex_buffers(struct pipe_context* pipe,
+static void r300_set_vertex_buffers_hwtcl(struct pipe_context* pipe,
                                     unsigned count,
                                     const struct pipe_vertex_buffer* buffers)
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    if (r300->screen->caps.has_tcl) {
-        /* There must be at least one vertex buffer set, otherwise it locks up. */
-        if (!count) {
-            buffers = &r300->dummy_vb;
-            count = 1;
-        }
+    /* There must be at least one vertex buffer set, otherwise it locks up. */
+    if (!count) {
+        buffers = &r300->dummy_vb;
+        count = 1;
+    }
 
-        util_copy_vertex_buffers(r300->vertex_buffer,
-                                 &r300->nr_vertex_buffers,
-                                 buffers, count);
+    util_copy_vertex_buffers(r300->vertex_buffer,
+                             &r300->nr_vertex_buffers,
+                             buffers, count);
 
-        r300->vertex_arrays_dirty = TRUE;
-    } else {
-        util_copy_vertex_buffers(r300->vertex_buffer,
-                                 &r300->nr_vertex_buffers,
-                                 buffers, count);
-        draw_set_vertex_buffers(r300->draw, count, buffers);
+    r300->vertex_arrays_dirty = TRUE;
+}
+
+static void r300_set_vertex_buffers_swtcl(struct pipe_context* pipe,
+                                    unsigned count,
+                                    const struct pipe_vertex_buffer* buffers)
+{
+    struct r300_context* r300 = r300_context(pipe);
+    unsigned i;
+
+    util_copy_vertex_buffers(r300->vertex_buffer,
+                             &r300->nr_vertex_buffers,
+                             buffers, count);
+    draw_set_vertex_buffers(r300->draw, count, buffers);
+
+    for (i = 0; i < count; i++) {
+        if (buffers[i].user_buffer) {
+            draw_set_mapped_vertex_buffer(r300->draw, i,
+                                          buffers[i].user_buffer);
+        } else if (buffers[i].buffer) {
+            draw_set_mapped_vertex_buffer(r300->draw, i,
+                r300_resource(buffers[i].buffer)->malloced_buffer);
+        }
     }
 }
 
@@ -1952,11 +1968,11 @@ void r300_init_state_functions(struct r300_context* r300)
 
     r300->context.set_viewport_state = r300_set_viewport_state;
 
-    r300->context.set_vertex_buffers = r300_set_vertex_buffers;
-
     if (r300->screen->caps.has_tcl) {
+        r300->context.set_vertex_buffers = r300_set_vertex_buffers_hwtcl;
         r300->context.set_index_buffer = r300_set_index_buffer_hwtcl;
     } else {
+        r300->context.set_vertex_buffers = r300_set_vertex_buffers_swtcl;
         r300->context.set_index_buffer = r300_set_index_buffer_swtcl;
     }