summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2013-07-25 09:13:47 -0600
committerBrian Paul <[email protected]>2013-07-31 06:53:48 -0600
commit99c42d11a245d6709b33353c2d88e2640f6d101e (patch)
tree48ede654f94cc8b1ed9f6acf6bad701cb988c183 /src/gallium
parent089ef37eab8270adcb3e4ad96ee9e26e116461a3 (diff)
softpipe: don't ignore pipe_constant_buffer::buffer_offset
This was never a problem since the Mesa state tracker always gives us a user-space constant buffer with buffer_offset=0. But if another state tracker ever gave us a "HW" constant buffer with non-zero buffer_offset we'd mis-render. Also, use the correct buffer size. And move an assertion to the top of the function. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/softpipe/sp_state_shader.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c
index 79bd597ebcb..d80955e696c 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -347,6 +347,8 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
unsigned size;
const void *data;
+ assert(shader < PIPE_SHADER_TYPES);
+
if (cb && cb->user_buffer) {
constants = softpipe_user_buffer_create(pipe->screen,
(void *) cb->user_buffer,
@@ -354,10 +356,10 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
PIPE_BIND_CONSTANT_BUFFER);
}
- size = constants ? constants->width0 : 0;
+ size = cb ? cb->buffer_size : 0;
data = constants ? softpipe_resource(constants)->data : NULL;
-
- assert(shader < PIPE_SHADER_TYPES);
+ if (data)
+ data = (const char *) data + cb->buffer_offset;
draw_flush(softpipe->draw);