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 <maraeo@gmail.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
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,
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);