r300g: support user buffers as constant buffers
authorMarek Olšák <maraeo@gmail.com>
Wed, 29 Dec 2010 03:04:32 +0000 (04:04 +0100)
committerMarek Olšák <maraeo@gmail.com>
Wed, 29 Dec 2010 17:32:41 +0000 (18:32 +0100)
src/gallium/drivers/r300/r300_state.c

index 3eed0c26d64b540816c3c8fe885432a0a16cf817..f748fe599797370278d2a4edd947fe94e00a4c28 100644 (file)
@@ -1827,6 +1827,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
     struct r300_constant_buffer *cbuf;
+    struct r300_buffer *rbuf = r300_buffer(buf);
     uint32_t *mapped;
 
     switch (shader) {
@@ -1840,10 +1841,15 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
             return;
     }
 
-    if (buf == NULL || buf->width0 == 0 ||
-        (mapped = (uint32_t*)r300_buffer(buf)->constant_buffer) == NULL) {
+    if (buf == NULL || buf->width0 == 0)
+        return;
+
+    if (rbuf->user_buffer)
+        mapped = (uint32_t*)rbuf->user_buffer;
+    else if (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)) {