From 220261a0c9d4f08e060f02d9cc61219360c2d3f9 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 6 Nov 2015 14:09:52 -0800 Subject: [PATCH] anv: Use VkDescriptorType instead of anv_descriptor_type --- src/vulkan/anv_cmd_buffer.c | 29 +++++++++++++++++++++-------- src/vulkan/anv_device.c | 8 ++++---- src/vulkan/anv_private.h | 10 +--------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index c0e28bdf047..77471941071 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -610,11 +610,14 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, uint32_t bo_offset; switch (desc->type) { - case ANV_DESCRIPTOR_TYPE_EMPTY: - case ANV_DESCRIPTOR_TYPE_SAMPLER: + case VK_DESCRIPTOR_TYPE_SAMPLER: /* Nothing for us to do here */ continue; - case ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET: { + + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: { bo = desc->buffer->bo; bo_offset = desc->buffer->offset + desc->offset; @@ -625,12 +628,20 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, bo_offset, desc->range); break; } - case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW: - case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER: + + case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: + case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: + case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: surface_state = desc->image_view->nonrt_surface_state; bo = desc->image_view->bo; bo_offset = desc->image_view->offset; break; + + case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: + case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: + case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: + assert(!"Unsupported descriptor type"); + break; } bt_map[bias + s] = surface_state.offset + state_offset; @@ -669,13 +680,15 @@ anv_cmd_buffer_emit_samplers(struct anv_cmd_buffer *cmd_buffer, cmd_buffer->state.descriptors[binding->set]; struct anv_descriptor *desc = &set->descriptors[binding->offset]; - if (desc->type != ANV_DESCRIPTOR_TYPE_SAMPLER && - desc->type != ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER) + if (desc->type != VK_DESCRIPTOR_TYPE_SAMPLER && + desc->type != VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) continue; struct anv_sampler *sampler = desc->sampler; - /* FIXME: We shouldn't have to do this */ + /* This can happen if we have an unfilled slot since TYPE_SAMPLER + * happens to be zero. + */ if (sampler == NULL) continue; diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 9483816b53f..dcb3ef20115 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -1715,7 +1715,7 @@ void anv_UpdateDescriptorSets( write->pDescriptors[j].sampler); desc[j] = (struct anv_descriptor) { - .type = ANV_DESCRIPTOR_TYPE_SAMPLER, + .type = VK_DESCRIPTOR_TYPE_SAMPLER, .sampler = sampler, }; } @@ -1728,7 +1728,7 @@ void anv_UpdateDescriptorSets( ANV_FROM_HANDLE(anv_sampler, sampler, write->pDescriptors[j].sampler); - desc[j].type = ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER; + desc[j].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; desc[j].image_view = iview; /* If this descriptor has an immutable sampler, we don't want @@ -1746,7 +1746,7 @@ void anv_UpdateDescriptorSets( write->pDescriptors[j].imageView); desc[j] = (struct anv_descriptor) { - .type = ANV_DESCRIPTOR_TYPE_IMAGE_VIEW, + .type = write->descriptorType, .image_view = iview, }; } @@ -1772,7 +1772,7 @@ void anv_UpdateDescriptorSets( assert(buffer); desc[j] = (struct anv_descriptor) { - .type = ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET, + .type = write->descriptorType, .buffer = buffer, .offset = write->pDescriptors[j].bufferInfo.offset, .range = write->pDescriptors[j].bufferInfo.range, diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 821e16164eb..6ba2e460a8d 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -724,16 +724,8 @@ struct anv_descriptor_set_layout { struct anv_descriptor_set_binding_layout binding[0]; }; -enum anv_descriptor_type { - ANV_DESCRIPTOR_TYPE_EMPTY = 0, - ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET, - ANV_DESCRIPTOR_TYPE_IMAGE_VIEW, - ANV_DESCRIPTOR_TYPE_SAMPLER, - ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER, -}; - struct anv_descriptor { - enum anv_descriptor_type type; + VkDescriptorType type; union { struct { -- 2.30.2