[Mesa-dev] [PATCH 5/6] radeonsi: remove nr_vertex_buffers
Marek Olšák
maraeo at gmail.com
Sat Jul 12 09:35:36 PDT 2014
From: Marek Olšák <marek.olsak at amd.com>
Unused.
Also inline util_set_vertex_buffers_count and simplify it.
---
src/gallium/drivers/radeonsi/si_descriptors.c | 4 ++--
src/gallium/drivers/radeonsi/si_pipe.h | 3 +--
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 18cc947..fedb4e2 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -551,7 +551,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;
@@ -600,7 +600,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 85bef5d..635ac0d 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -148,8 +148,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 dd79cf2..71ece91 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -2842,12 +2842,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,
--
1.9.1
More information about the mesa-dev
mailing list