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;
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;
}
/* 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: */
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,