summaryrefslogtreecommitdiffstats
path: root/src/vulkan/anv_cmd_buffer.c
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2015-10-05 14:43:23 -0700
committerChad Versace <[email protected]>2015-10-05 17:46:04 -0700
commitffd051830d837705f4da6d16e59953b02066c91e (patch)
tree32d5af74dce2d9d4ecd0cd459aeddab3497ea322 /src/vulkan/anv_cmd_buffer.c
parent63439953d7f51700e1834e3003e209b387772b5e (diff)
vk: Unionize anv_desciptor
For a given struct anv_descriptor, all members are NULL (in which case the descriptor is empty) or exactly one member is non-NULL. To make struct anv_descriptor better reflect its set of valid states, convert the struct into a tagged union.
Diffstat (limited to 'src/vulkan/anv_cmd_buffer.c')
-rw-r--r--src/vulkan/anv_cmd_buffer.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c
index 419405204d5..5a00ce24bd2 100644
--- a/src/vulkan/anv_cmd_buffer.c
+++ b/src/vulkan/anv_cmd_buffer.c
@@ -456,12 +456,14 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
uint32_t start = bias + layout->set[set].stage[stage].surface_start;
for (uint32_t b = 0; b < set_layout->stage[stage].surface_count; b++) {
- struct anv_surface_view *view =
- d->set->descriptors[surface_slots[b].index].view;
+ struct anv_descriptor *desc =
+ &d->set->descriptors[surface_slots[b].index];
- if (!view)
+ if (desc->type != ANV_DESCRIPTOR_TYPE_SURFACE_VIEW)
continue;
+ struct anv_surface_view *view = desc->surface_view;
+
bt_map[start + b] = view->surface_state.offset + state_offset;
add_surface_state_reloc(cmd_buffer, view->surface_state,
view->bo, view->offset);
@@ -502,12 +504,14 @@ anv_cmd_buffer_emit_samplers(struct anv_cmd_buffer *cmd_buffer,
uint32_t start = layout->set[set].stage[stage].sampler_start;
for (uint32_t b = 0; b < set_layout->stage[stage].sampler_count; b++) {
- struct anv_sampler *sampler =
- d->set->descriptors[sampler_slots[b].index].sampler;
+ struct anv_descriptor *desc =
+ &d->set->descriptors[sampler_slots[b].index];
- if (!sampler)
+ if (desc->type != ANV_DESCRIPTOR_TYPE_SAMPLER)
continue;
+ struct anv_sampler *sampler = desc->sampler;
+
memcpy(state->map + (start + b) * 16,
sampler->state, sizeof(sampler->state));
}