r300g: fix breakage after gallium-userbuf merge
authorMarek Olšák <maraeo@gmail.com>
Fri, 11 May 2012 20:25:03 +0000 (22:25 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 11 May 2012 22:50:52 +0000 (00:50 +0200)
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_state.c

index f84f3e5c58e06bb22df6a19e6d9caf6025b5ba16..1e7f9276b73dfd35ff6bf016b987375e5ebcf17e 100644 (file)
@@ -103,9 +103,6 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS:
         case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
         case PIPE_CAP_VERTEX_COLOR_CLAMPED:
-        case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
-        case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
-        case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
         case PIPE_CAP_USER_INDEX_BUFFERS:
         case PIPE_CAP_USER_CONSTANT_BUFFERS:
             return 1;
@@ -149,13 +146,19 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
         case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
         case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
-        case PIPE_CAP_USER_VERTEX_BUFFERS:
             return 0;
 
         /* SWTCL-only features. */
         case PIPE_CAP_PRIMITIVE_RESTART:
+        case PIPE_CAP_USER_VERTEX_BUFFERS:
             return !r300screen->caps.has_tcl;
 
+        /* HWTCL-only features / limitations. */
+        case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
+        case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
+        case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
+            return r300screen->caps.has_tcl;
+
         /* Texturing. */
         case PIPE_CAP_MAX_COMBINED_SAMPLERS:
             return r300screen->caps.num_tex_units;
@@ -426,11 +429,19 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
     }
 
     /* Check vertex buffer format support. */
-    if (usage & PIPE_BIND_VERTEX_BUFFER &&
-        /* Half float is supported on >= R400. */
-        (is_r400 || is_r500 || !is_half_float) &&
-        r300_translate_vertex_data_type(format) != R300_INVALID_FORMAT) {
-        retval |= PIPE_BIND_VERTEX_BUFFER;
+    if (usage & PIPE_BIND_VERTEX_BUFFER) {
+        if (r300_screen(screen)->caps.has_tcl) {
+            /* Half float is supported on >= R400. */
+            if ((is_r400 || is_r500 || !is_half_float) &&
+                r300_translate_vertex_data_type(format) != R300_INVALID_FORMAT) {
+                retval |= PIPE_BIND_VERTEX_BUFFER;
+            }
+        } else {
+            /* SW TCL */
+            if (!util_format_is_pure_integer(format)) {
+                retval |= PIPE_BIND_VERTEX_BUFFER;
+            }
+        }
     }
 
     /* Transfers are always supported. */
index 566bc443807a3b8534156a85292ac4eece1abd1f..a9a76c5fed81357a24e68b751b370f08d2e47f04 100644 (file)
@@ -1822,11 +1822,12 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
                                      struct pipe_constant_buffer *cb)
 {
     struct r300_context* r300 = r300_context(pipe);
-    struct pipe_resource *buf = cb ? cb->buffer : NULL;
     struct r300_constant_buffer *cbuf;
-    struct r300_resource *rbuf = r300_resource(buf);
     uint32_t *mapped;
 
+    if (!cb)
+        return;
+
     switch (shader) {
         case PIPE_SHADER_VERTEX:
             cbuf = (struct r300_constant_buffer*)r300->vs_constants.state;
@@ -1838,15 +1839,17 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
             return;
     }
 
-    if (buf == NULL || buf->width0 == 0)
-        return;
 
     if (cb->user_buffer)
         mapped = (uint32_t*)cb->user_buffer;
-    else if (rbuf->constant_buffer)
-        mapped = (uint32_t*)rbuf->constant_buffer;
-    else
-        return;
+    else {
+        struct r300_resource *rbuf = r300_resource(cb->buffer);
+
+        if (rbuf && rbuf->constant_buffer)
+            mapped = (uint32_t*)rbuf->constant_buffer;
+        else
+            return;
+    }
 
     if (shader == PIPE_SHADER_FRAGMENT ||
         (shader == PIPE_SHADER_VERTEX && r300->screen->caps.has_tcl)) {
@@ -1873,7 +1876,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
             r300_mark_atom_dirty(r300, &r300->vs_constants);
         } else if (r300->draw) {
             draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX,
-                0, mapped, buf->width0);
+                0, mapped, cb->buffer_size);
         }
     } else if (shader == PIPE_SHADER_FRAGMENT) {
         r300_mark_atom_dirty(r300, &r300->fs_constants);