diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_descriptors.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state.c | 22 |
3 files changed, 23 insertions, 6 deletions
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index c3236375e4b..bd7695c8cd0 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -549,7 +549,7 @@ static void si_vertex_buffers_begin_new_cs(struct si_context *sctx) for (i = 0; i < count; i++) { int vb = sctx->vertex_elements->elements[i].vertex_buffer_index; - if (vb >= sctx->nr_vertex_buffers) + if (vb >= Elements(sctx->vertex_buffer)) continue; if (!sctx->vertex_buffer[vb].buffer) continue; @@ -598,7 +598,7 @@ void si_update_vertex_buffers(struct si_context *sctx) unsigned offset; uint32_t *desc = &ptr[i*4]; - if (ve->vertex_buffer_index >= sctx->nr_vertex_buffers) { + if (ve->vertex_buffer_index >= Elements(sctx->vertex_buffer)) { memset(desc, 0, 16); continue; } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 227b8fad3d8..7b6c8600718 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -144,8 +144,7 @@ struct si_context { /* Vertex and index buffers. */ bool vertex_buffers_dirty; struct pipe_index_buffer index_buffer; - struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; - unsigned nr_vertex_buffers; + struct pipe_vertex_buffer vertex_buffer[SI_NUM_VERTEX_BUFFERS]; /* With rasterizer discard, there doesn't have to be a pixel shader. * In that case, we bind this one: */ diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 31d387e974e..c6918721f61 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2824,12 +2824,30 @@ static void si_delete_vertex_element(struct pipe_context *ctx, void *state) FREE(state); } -static void si_set_vertex_buffers(struct pipe_context *ctx, unsigned start_slot, unsigned count, +static void si_set_vertex_buffers(struct pipe_context *ctx, + unsigned start_slot, unsigned count, const struct pipe_vertex_buffer *buffers) { struct si_context *sctx = (struct si_context *)ctx; + struct pipe_vertex_buffer *dst = sctx->vertex_buffer + start_slot; + int i; + + assert(start_slot + count <= Elements(sctx->vertex_buffer)); - util_set_vertex_buffers_count(sctx->vertex_buffer, &sctx->nr_vertex_buffers, buffers, start_slot, count); + if (buffers) { + for (i = 0; i < count; i++) { + const struct pipe_vertex_buffer *src = buffers + i; + struct pipe_vertex_buffer *dsti = dst + i; + + pipe_resource_reference(&dsti->buffer, src->buffer); + dsti->buffer_offset = src->buffer_offset; + dsti->stride = src->stride; + } + } else { + for (i = 0; i < count; i++) { + pipe_resource_reference(&dst[i].buffer, NULL); + } + } } static void si_set_index_buffer(struct pipe_context *ctx, |