diff options
author | Marek Olšák <[email protected]> | 2013-04-26 01:54:41 +0200 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2013-06-25 14:24:56 -0700 |
commit | 65b251f4b0dfd80c303b73ff954f30b0d004d2dc (patch) | |
tree | a34c877abaff7125392751b54f019e4e5ecceccd /src | |
parent | 03c3e082dc70dd2526caabdd23db40da23572ca2 (diff) |
st/mesa: fix a couple of issues in st_bind_ubos
- don't reference a buffer for a local variable
(that's never useful unless it can be the only reference to the buffer)
- check if the buffer is not NULL
- set buffer_size as specified with BindBufferRange
NOTE: This is a candidate for the 9.1 branch.
Reviewed-by: Fredrik Höglund <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
(cherry picked from commit a17e87d4ebd84c1a01c3821c04ed9d8d7c763983)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_atom_constbuf.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index b92a24877ae..c7eb0790d29 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -192,13 +192,25 @@ static void st_bind_ubos(struct st_context *st, binding = &st->ctx->UniformBufferBindings[shader->UniformBlocks[i].Binding]; st_obj = st_buffer_object(binding->BufferObject); - pipe_resource_reference(&cb.buffer, st_obj->buffer); - cb.buffer_size = st_obj->buffer->width0 - binding->Offset; - cb.buffer_offset = binding->Offset; + cb.buffer = st_obj->buffer; + + if (cb.buffer) { + cb.buffer_offset = binding->Offset; + cb.buffer_size = cb.buffer->width0 - binding->Offset; + + /* AutomaticSize is FALSE if the buffer was set with BindBufferRange. + * Take the minimum just to be sure. + */ + if (!binding->AutomaticSize) + cb.buffer_size = MIN2(cb.buffer_size, binding->Size); + } + else { + cb.buffer_offset = 0; + cb.buffer_size = 0; + } st->pipe->set_constant_buffer(st->pipe, shader_type, 1 + i, &cb); - pipe_resource_reference(&cb.buffer, NULL); } } |