summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-06-09 19:29:27 +0200
committerMarek Olšák <[email protected]>2017-06-12 18:24:37 +0200
commite80a056ff93e9a2714a4a7e8a6ccc0a0d49b41a1 (patch)
tree4dae54b5cd9caf4ea107f50c3fa31b70787fc404
parentc8b6f42e25369d149a28dfab1eeb48ff893894ad (diff)
radeonsi: replace si_vertex_elements::elements with separate fields
It makes si_vertex_elements a little smaller. Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r--src/gallium/drivers/radeonsi/si_descriptors.c9
-rw-r--r--src/gallium/drivers/radeonsi/si_state.c8
-rw-r--r--src/gallium/drivers/radeonsi/si_state.h4
-rw-r--r--src/gallium/drivers/radeonsi/si_state_shaders.c7
4 files changed, 14 insertions, 14 deletions
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index af68ac91468..22888a68dd7 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1006,7 +1006,7 @@ static void si_vertex_buffers_begin_new_cs(struct si_context *sctx)
int i;
for (i = 0; i < count; i++) {
- int vb = sctx->vertex_elements->elements[i].vertex_buffer_index;
+ int vb = sctx->vertex_elements->vertex_buffer_index[i];
if (vb >= ARRAY_SIZE(sctx->vertex_buffer))
continue;
@@ -1065,11 +1065,10 @@ bool si_upload_vertex_buffer_descriptors(struct si_context *sctx)
assert(count <= SI_MAX_ATTRIBS);
for (i = 0; i < count; i++) {
- struct pipe_vertex_element *ve = &velems->elements[i];
struct pipe_vertex_buffer *vb;
struct r600_resource *rbuffer;
unsigned offset;
- unsigned vbo_index = ve->vertex_buffer_index;
+ unsigned vbo_index = velems->vertex_buffer_index[i];
uint32_t *desc = &ptr[i*4];
vb = &sctx->vertex_buffer[vbo_index];
@@ -1079,7 +1078,7 @@ bool si_upload_vertex_buffer_descriptors(struct si_context *sctx)
continue;
}
- offset = vb->buffer_offset + ve->src_offset;
+ offset = vb->buffer_offset + velems->src_offset[i];
va = rbuffer->gpu_address + offset;
/* Fill in T# buffer resource description */
@@ -1637,7 +1636,7 @@ static void si_rebind_buffer(struct pipe_context *ctx, struct pipe_resource *buf
/* Vertex buffers. */
if (rbuffer->bind_history & PIPE_BIND_VERTEX_BUFFER) {
for (i = 0; i < num_elems; i++) {
- int vb = sctx->vertex_elements->elements[i].vertex_buffer_index;
+ int vb = sctx->vertex_elements->vertex_buffer_index[i];
if (vb >= ARRAY_SIZE(sctx->vertex_buffer))
continue;
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 3b15545fc48..1cd1f9190e0 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -3740,8 +3740,10 @@ static void *si_create_vertex_elements(struct pipe_context *ctx,
return NULL;
}
- if (elements[i].instance_divisor)
+ if (elements[i].instance_divisor) {
v->uses_instance_divisors = true;
+ v->instance_divisors[i] = elements[i].instance_divisor;
+ }
if (!used[vbo_index]) {
v->first_vb_use_mask |= 1 << i;
@@ -3756,6 +3758,8 @@ static void *si_create_vertex_elements(struct pipe_context *ctx,
memcpy(swizzle, desc->swizzle, sizeof(swizzle));
v->format_size[i] = desc->block.bits / 8;
+ v->src_offset[i] = elements[i].src_offset;
+ v->vertex_buffer_index[i] = vbo_index;
/* The hardware always treats the 2-bit alpha channel as
* unsigned, so a shader workaround is needed. The affected
@@ -3848,8 +3852,6 @@ static void *si_create_vertex_elements(struct pipe_context *ctx,
S_008F0C_NUM_FORMAT(num_format) |
S_008F0C_DATA_FORMAT(data_format);
}
- memcpy(v->elements, elements, sizeof(struct pipe_vertex_element) * count);
-
return v;
}
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index 63a1713aac0..99c8ee65b9f 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -108,7 +108,9 @@ struct si_vertex_elements
uint8_t fix_fetch[SI_MAX_ATTRIBS];
uint32_t rsrc_word3[SI_MAX_ATTRIBS];
uint32_t format_size[SI_MAX_ATTRIBS];
- struct pipe_vertex_element elements[SI_MAX_ATTRIBS];
+ uint8_t vertex_buffer_index[SI_MAX_ATTRIBS];
+ uint16_t src_offset[SI_MAX_ATTRIBS];
+ unsigned instance_divisors[SI_MAX_ATTRIBS];
bool uses_instance_divisors;
};
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 6247b9c006e..848c5a75ee9 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1189,11 +1189,8 @@ static void si_shader_selector_key_vs(struct si_context *sctx,
unsigned count = MIN2(vs->info.num_inputs,
sctx->vertex_elements->count);
- for (unsigned i = 0; i < count; ++i) {
- prolog_key->instance_divisors[i] =
- sctx->vertex_elements->elements[i].instance_divisor;
- }
-
+ memcpy(prolog_key->instance_divisors,
+ sctx->vertex_elements->instance_divisors, count * 4);
memcpy(key->mono.vs_fix_fetch, sctx->vertex_elements->fix_fetch, count);
}