radeonsi: remove nr_vertex_buffers
authorMarek Olšák <marek.olsak@amd.com>
Wed, 9 Jul 2014 12:57:18 +0000 (14:57 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 17 Jul 2014 23:58:59 +0000 (01:58 +0200)
Unused.

Also inline util_set_vertex_buffers_count and simplify it.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state.c

index c3236375e4b8fd25973d09d5ff6019a64fd1548c..bd7695c8cd0294564f063135e4f24e3a8f7ef9a4 100644 (file)
@@ -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;
                }
index 227b8fad3d860eaba5f777354beb0d80dbfc3709..7b6c8600718ece67ec014996d76d018e5ab895e2 100644 (file)
@@ -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: */
index 31d387e974e19915810797281b5284d65886d889..c6918721f617c7646c92e0e6638f0b43b9692971 100644 (file)
@@ -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,