r300g/swtcl: do not use u_upload_mgr and do not compute max_index
authorMarek Olšák <maraeo@gmail.com>
Wed, 26 May 2010 16:21:59 +0000 (18:21 +0200)
committerMarek Olšák <maraeo@gmail.com>
Wed, 26 May 2010 20:22:52 +0000 (22:22 +0200)
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c

index 7f7f2929cc3ae8a008de86f9564b86ef5b4d106c..8fceb539981952fe5bda731c8a6f15b4036c9a5a 100644 (file)
@@ -1057,7 +1057,7 @@ void r300_emit_buffer_validate(struct r300_context *r300,
     boolean invalid = FALSE;
 
     /* upload buffers first */
-    if (r300->any_user_vbs) {
+    if (r300->screen->caps.has_tcl && r300->any_user_vbs) {
         r300_upload_user_buffers(r300);
         r300->any_user_vbs = false;
     }
index 67e09362d8e38fbef6ef8ce270c42f8d40d289b6..46f1653b5bd75dea2cec10fde2711b79ffcf9559 100644 (file)
@@ -1183,48 +1183,61 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
         return;
     }
 
-    /* Check if the stride is aligned to the size of DWORD. */
-    for (i = 0; i < count; i++) {
-        if (buffers[i].buffer) {
-            if (buffers[i].stride % 4 != 0) {
-                // XXX Shouldn't we align the buffer?
-                fprintf(stderr, "r300: set_vertex_buffers: "
-                        "Unaligned buffer stride %i isn't supported.\n",
-                        buffers[i].stride);
-                abort();
+    if (r300->screen->caps.has_tcl) {
+        /* HW TCL. */
+        /* Check if the stride is aligned to the size of DWORD. */
+        for (i = 0; i < count; i++) {
+            if (buffers[i].buffer) {
+                if (buffers[i].stride % 4 != 0) {
+                    // XXX Shouldn't we align the buffer?
+                    fprintf(stderr, "r300: set_vertex_buffers: "
+                            "Unaligned buffer stride %i isn't supported.\n",
+                            buffers[i].stride);
+                    abort();
+                }
             }
         }
-    }
 
-    for (i = 0; i < count; i++) {
-        /* Why, yes, I AM casting away constness. How did you know? */
-        vbo = (struct pipe_vertex_buffer*)&buffers[i];
+        for (i = 0; i < count; i++) {
+            /* Why, yes, I AM casting away constness. How did you know? */
+            vbo = (struct pipe_vertex_buffer*)&buffers[i];
 
-        /* Reference our buffer. */
-        pipe_resource_reference(&r300->vertex_buffer[i].buffer, vbo->buffer);
+            /* Skip NULL buffers */
+            if (!buffers[i].buffer) {
+                continue;
+            }
 
-        /* Skip NULL buffers */
-        if (!buffers[i].buffer) {
-            continue;
-        }
+            if (r300_buffer_is_user_buffer(vbo->buffer)) {
+                any_user_buffer = TRUE;
+            }
 
-        if (r300_buffer_is_user_buffer(vbo->buffer)) {
-            any_user_buffer = TRUE;
-        }
+            if (vbo->max_index == ~0) {
+                /* if no VBO stride then only one vertex value so max index is 1 */
+                /* should think about converting to VS constants like svga does */
+                if (!vbo->stride)
+                    vbo->max_index = 1;
+                else
+                    vbo->max_index =
+                             (vbo->buffer->width0 - vbo->buffer_offset) / vbo->stride;
+            }
 
-        if (vbo->max_index == ~0) {
-           /* if no VBO stride then only one vertex value so max index is 1 */
-           /* should think about converting to VS constants like svga does */
-           if (!vbo->stride)
-               vbo->max_index = 1;
-           else
-               vbo->max_index =
-                                (vbo->buffer->width0 - vbo->buffer_offset) / vbo->stride;
+            max_index = MIN2(vbo->max_index, max_index);
         }
 
-        max_index = MIN2(vbo->max_index, max_index);
+        r300->any_user_vbs = any_user_buffer;
+        r300->vertex_buffer_max_index = max_index;
+
+    } else {
+        /* SW TCL. */
+        draw_flush(r300->draw);
+        draw_set_vertex_buffers(r300->draw, count, buffers);
     }
 
+    /* Common code. */
+    for (i = 0; i < count; i++) {
+        /* Reference our buffer. */
+        pipe_resource_reference(&r300->vertex_buffer[i].buffer, buffers[i].buffer);
+    }
     for (; i < r300->vertex_buffer_count; i++) {
         /* Dereference any old buffers. */
         pipe_resource_reference(&r300->vertex_buffer[i].buffer, NULL);
@@ -1232,15 +1245,7 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
 
     memcpy(r300->vertex_buffer, buffers,
         sizeof(struct pipe_vertex_buffer) * count);
-
     r300->vertex_buffer_count = count;
-    r300->vertex_buffer_max_index = max_index;
-    r300->any_user_vbs = any_user_buffer;
-
-    if (r300->draw) {
-        draw_flush(r300->draw);
-        draw_set_vertex_buffers(r300->draw, count, buffers);
-    }
 }
 
 /* Initialize the PSC tables. */