From: Jason Ekstrand Date: Thu, 15 Oct 2015 20:45:53 +0000 (-0700) Subject: anv: Add support for BufferInfo in descriptor sets X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bed7d1e03cfb03148e65566d299430063e90a47a;p=mesa.git anv: Add support for BufferInfo in descriptor sets --- diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index df076d0cac6..2801f730478 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -614,11 +614,25 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, bo = desc->buffer_view->bo; bo_offset = desc->buffer_view->offset; break; + case ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET: { + struct anv_state state = + anv_cmd_buffer_alloc_surface_state(cmd_buffer); + anv_fill_buffer_surface_state(cmd_buffer->device, state.map, + anv_format_for_vk_format(VK_FORMAT_R32G32B32A32_SFLOAT), + desc->offset, desc->range); + surface_state = &state; + bo = desc->buffer_view->bo; + bo_offset = desc->buffer_view->offset; + break; + } case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW: surface_state = &desc->image_view->nonrt_surface_state; bo = desc->image_view->bo; bo_offset = desc->image_view->offset; break; + case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER: + /* Nothing for us to do here */ + break; } bt_map[bias + s] = surface_state->offset + state_offset; @@ -657,7 +671,8 @@ 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) + if (desc->type != ANV_DESCRIPTOR_TYPE_SAMPLER && + desc->type != ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER) continue; struct anv_sampler *sampler = desc->sampler; diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 98c1b2334e6..cc9ead86e73 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -1698,13 +1698,28 @@ void anv_UpdateDescriptorSets( case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: for (uint32_t j = 0; j < write->count; j++) { - ANV_FROM_HANDLE(anv_buffer_view, bview, - write->pDescriptors[j].bufferView); - - set->descriptors[write->destBinding + j] = (struct anv_descriptor) { - .type = ANV_DESCRIPTOR_TYPE_BUFFER_VIEW, - .buffer_view = bview, - }; + if (write->pDescriptors[j].bufferView.handle) { + ANV_FROM_HANDLE(anv_buffer_view, bview, + write->pDescriptors[j].bufferView); + + set->descriptors[write->destBinding + j] = + (struct anv_descriptor) { + .type = ANV_DESCRIPTOR_TYPE_BUFFER_VIEW, + .buffer_view = bview, + }; + } else { + ANV_FROM_HANDLE(anv_buffer, buffer, + write->pDescriptors[j].bufferInfo.buffer); + assert(buffer); + + set->descriptors[write->destBinding + j] = + (struct anv_descriptor) { + .type = ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET, + .buffer = buffer, + .offset = write->pDescriptors[j].bufferInfo.offset, + .range = write->pDescriptors[j].bufferInfo.range, + }; + } } default: diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index bcfb6fada50..6bbf7c0291b 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -696,18 +696,30 @@ struct anv_descriptor_set_layout { enum anv_descriptor_type { ANV_DESCRIPTOR_TYPE_EMPTY = 0, ANV_DESCRIPTOR_TYPE_BUFFER_VIEW, + 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; + union { - struct anv_buffer_view *buffer_view; - struct anv_image_view *image_view; - struct anv_sampler *sampler; - }; + struct { + union { + struct anv_buffer_view *buffer_view; + struct anv_image_view *image_view; + }; + struct anv_sampler *sampler; + }; - enum anv_descriptor_type type; + struct { + struct anv_buffer *buffer; + uint64_t offset; + uint64_t range; + }; + }; }; struct anv_descriptor_set {