From 3f6abd0161c4f0c5f4716d1b97a2378219469b7a Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 1 Dec 2015 12:05:21 -0800 Subject: [PATCH] vk/0.210.0: Rework descriptor sets --- include/vulkan/vulkan.h | 105 ++++++++++++--------------- src/vulkan/anv_descriptor_set.c | 122 +++++++++++++++++--------------- src/vulkan/anv_meta.c | 29 ++++---- 3 files changed, 127 insertions(+), 129 deletions(-) diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index 92eaaaa0b9e..0a28ade4a25 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -178,6 +178,7 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO = 44, VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 45, VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 46, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO = 47, VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO, VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, VK_STRUCTURE_TYPE_NUM = (VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1), @@ -709,24 +710,6 @@ typedef enum VkDescriptorType { VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF } VkDescriptorType; -typedef enum { - VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT = 0, - VK_DESCRIPTOR_POOL_USAGE_DYNAMIC = 1, - VK_DESCRIPTOR_POOL_USAGE_BEGIN_RANGE = VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT, - VK_DESCRIPTOR_POOL_USAGE_END_RANGE = VK_DESCRIPTOR_POOL_USAGE_DYNAMIC, - VK_DESCRIPTOR_POOL_USAGE_NUM = (VK_DESCRIPTOR_POOL_USAGE_DYNAMIC - VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT + 1), - VK_DESCRIPTOR_POOL_USAGE_MAX_ENUM = 0x7FFFFFFF -} VkDescriptorPoolUsage; - -typedef enum { - VK_DESCRIPTOR_SET_USAGE_ONE_SHOT = 0, - VK_DESCRIPTOR_SET_USAGE_STATIC = 1, - VK_DESCRIPTOR_SET_USAGE_BEGIN_RANGE = VK_DESCRIPTOR_SET_USAGE_ONE_SHOT, - VK_DESCRIPTOR_SET_USAGE_END_RANGE = VK_DESCRIPTOR_SET_USAGE_STATIC, - VK_DESCRIPTOR_SET_USAGE_NUM = (VK_DESCRIPTOR_SET_USAGE_STATIC - VK_DESCRIPTOR_SET_USAGE_ONE_SHOT + 1), - VK_DESCRIPTOR_SET_USAGE_MAX_ENUM = 0x7FFFFFFF -} VkDescriptorSetUsage; - typedef enum VkAttachmentLoadOp { VK_ATTACHMENT_LOAD_OP_LOAD = 0, VK_ATTACHMENT_LOAD_OP_CLEAR = 1, @@ -1822,7 +1805,7 @@ typedef struct VkPipelineLayoutCreateInfo { VkStructureType sType; const void* pNext; VkPipelineLayoutCreateFlags flags; - uint32_t descriptorSetCount; + uint32_t setLayoutCount; const VkDescriptorSetLayout* pSetLayouts; uint32_t pushConstantRangeCount; const VkPushConstantRange* pPushConstantRanges; @@ -1849,8 +1832,9 @@ typedef struct VkSamplerCreateInfo { } VkSamplerCreateInfo; typedef struct VkDescriptorSetLayoutBinding { + uint32_t binding; VkDescriptorType descriptorType; - uint32_t arraySize; + uint32_t descriptorCount; VkShaderStageFlags stageFlags; const VkSampler* pImmutableSamplers; } VkDescriptorSetLayoutBinding; @@ -1859,48 +1843,55 @@ typedef struct VkDescriptorSetLayoutCreateInfo { VkStructureType sType; const void* pNext; VkDescriptorSetLayoutCreateFlags flags; - uint32_t count; + uint32_t bindingCount; const VkDescriptorSetLayoutBinding* pBinding; } VkDescriptorSetLayoutCreateInfo; -typedef struct { +typedef struct VkDescriptorPoolSize { VkDescriptorType type; - uint32_t count; -} VkDescriptorTypeCount; + uint32_t descriptorCount; +} VkDescriptorPoolSize; typedef struct VkDescriptorPoolCreateInfo { VkStructureType sType; const void* pNext; VkDescriptorPoolCreateFlags flags; - VkDescriptorPoolUsage poolUsage; uint32_t maxSets; - uint32_t count; - const VkDescriptorTypeCount* pTypeCount; + uint32_t poolSizeCount; + const VkDescriptorPoolSize* pPoolSizes; } VkDescriptorPoolCreateInfo; -typedef struct { - VkBuffer buffer; - VkDeviceSize offset; - VkDeviceSize range; -} VkDescriptorBufferInfo; +typedef struct VkDescriptorSetAllocateInfo { + VkStructureType sType; + const void* pNext; + VkDescriptorPool descriptorPool; + uint32_t setLayoutCount; + const VkDescriptorSetLayout* pSetLayouts; +} VkDescriptorSetAllocateInfo; -typedef struct { - VkBufferView bufferView; +typedef struct VkDescriptorImageInfo { VkSampler sampler; VkImageView imageView; VkImageLayout imageLayout; - VkDescriptorBufferInfo bufferInfo; -} VkDescriptorInfo; +} VkDescriptorImageInfo; + +typedef struct VkDescriptorBufferInfo { + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize range; +} VkDescriptorBufferInfo; typedef struct VkWriteDescriptorSet { VkStructureType sType; const void* pNext; - VkDescriptorSet destSet; - uint32_t destBinding; - uint32_t destArrayElement; - uint32_t count; + VkDescriptorSet dstSet; + uint32_t dstBinding; + uint32_t dstArrayElement; + uint32_t descriptorCount; VkDescriptorType descriptorType; - const VkDescriptorInfo* pDescriptors; + const VkDescriptorImageInfo* pImageInfo; + const VkDescriptorBufferInfo* pBufferInfo; + const VkBufferView* pTexelBufferView; } VkWriteDescriptorSet; typedef struct VkCopyDescriptorSet { @@ -1909,10 +1900,10 @@ typedef struct VkCopyDescriptorSet { VkDescriptorSet srcSet; uint32_t srcBinding; uint32_t srcArrayElement; - VkDescriptorSet destSet; - uint32_t destBinding; - uint32_t destArrayElement; - uint32_t count; + VkDescriptorSet dstSet; + uint32_t dstBinding; + uint32_t dstArrayElement; + uint32_t descriptorCount; } VkCopyDescriptorSet; typedef struct VkFramebufferCreateInfo { @@ -2223,10 +2214,10 @@ typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, c typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout); typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool); typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool); -typedef VkResult (VKAPI_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool); -typedef VkResult (VKAPI_PTR *PFN_vkAllocDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets); -typedef VkResult (VKAPI_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets); -typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies); +typedef VkResult (VKAPI_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags); +typedef VkResult (VKAPI_PTR *PFN_vkAllocateDescriptorSets)(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets); +typedef VkResult (VKAPI_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets); +typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies); typedef VkResult (VKAPI_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer); typedef void (VKAPI_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer); typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass); @@ -2684,27 +2675,25 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool( VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool( VkDevice device, - VkDescriptorPool descriptorPool); + VkDescriptorPool descriptorPool, + VkDescriptorPoolResetFlags flags); -VKAPI_ATTR VkResult VKAPI_CALL vkAllocDescriptorSets( +VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets( VkDevice device, - VkDescriptorPool descriptorPool, - VkDescriptorSetUsage setUsage, - uint32_t count, - const VkDescriptorSetLayout* pSetLayouts, + const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets); VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets( VkDevice device, VkDescriptorPool descriptorPool, - uint32_t count, + uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets); VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets( VkDevice device, - uint32_t writeCount, + uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, - uint32_t copyCount, + uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies); VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer( diff --git a/src/vulkan/anv_descriptor_set.c b/src/vulkan/anv_descriptor_set.c index 22041b540d6..186e9f92a5a 100644 --- a/src/vulkan/anv_descriptor_set.c +++ b/src/vulkan/anv_descriptor_set.c @@ -44,14 +44,16 @@ VkResult anv_CreateDescriptorSetLayout( assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO); + uint32_t max_binding = 0; uint32_t immutable_sampler_count = 0; - for (uint32_t b = 0; b < pCreateInfo->count; b++) { - if (pCreateInfo->pBinding[b].pImmutableSamplers) - immutable_sampler_count += pCreateInfo->pBinding[b].arraySize; + for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) { + max_binding = MAX2(max_binding, pCreateInfo->pBinding[j].binding); + if (pCreateInfo->pBinding[j].pImmutableSamplers) + immutable_sampler_count += pCreateInfo->pBinding[j].descriptorCount; } size_t size = sizeof(struct anv_descriptor_set_layout) + - pCreateInfo->count * sizeof(set_layout->binding[0]) + + (max_binding + 1) * sizeof(set_layout->binding[0]) + immutable_sampler_count * sizeof(struct anv_sampler *); set_layout = anv_device_alloc(device, size, 8, @@ -61,15 +63,15 @@ VkResult anv_CreateDescriptorSetLayout( /* We just allocate all the samplers at the end of the struct */ struct anv_sampler **samplers = - (struct anv_sampler **)&set_layout->binding[pCreateInfo->count]; + (struct anv_sampler **)&set_layout->binding[max_binding + 1]; - set_layout->binding_count = pCreateInfo->count; + set_layout->binding_count = max_binding + 1; set_layout->shader_stages = 0; set_layout->size = 0; /* Initialize all binding_layout entries to -1 */ memset(set_layout->binding, -1, - pCreateInfo->count * sizeof(set_layout->binding[0])); + (max_binding + 1) * sizeof(set_layout->binding[0])); /* Initialize all samplers to 0 */ memset(samplers, 0, immutable_sampler_count * sizeof(*samplers)); @@ -78,25 +80,28 @@ VkResult anv_CreateDescriptorSetLayout( uint32_t surface_count[VK_SHADER_STAGE_NUM] = { 0, }; uint32_t dynamic_offset_count = 0; - for (uint32_t b = 0; b < pCreateInfo->count; b++) { - uint32_t array_size = MAX2(1, pCreateInfo->pBinding[b].arraySize); - set_layout->binding[b].array_size = array_size; + for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) { + const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBinding[j]; + uint32_t b = binding->binding; + + assert(binding->descriptorCount > 0); + set_layout->binding[b].array_size = binding->descriptorCount; set_layout->binding[b].descriptor_index = set_layout->size; - set_layout->size += array_size; + set_layout->size += binding->descriptorCount; - switch (pCreateInfo->pBinding[b].descriptorType) { + switch (binding->descriptorType) { case VK_DESCRIPTOR_TYPE_SAMPLER: case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: - for_each_bit(s, pCreateInfo->pBinding[b].stageFlags) { + for_each_bit(s, binding->stageFlags) { set_layout->binding[b].stage[s].sampler_index = sampler_count[s]; - sampler_count[s] += array_size; + sampler_count[s] += binding->descriptorCount; } break; default: break; } - switch (pCreateInfo->pBinding[b].descriptorType) { + switch (binding->descriptorType) { case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: @@ -107,37 +112,37 @@ VkResult anv_CreateDescriptorSetLayout( case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: - for_each_bit(s, pCreateInfo->pBinding[b].stageFlags) { + for_each_bit(s, binding->stageFlags) { set_layout->binding[b].stage[s].surface_index = surface_count[s]; - surface_count[s] += array_size; + surface_count[s] += binding->descriptorCount; } break; default: break; } - switch (pCreateInfo->pBinding[b].descriptorType) { + switch (binding->descriptorType) { case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: set_layout->binding[b].dynamic_offset_index = dynamic_offset_count; - dynamic_offset_count += array_size; + dynamic_offset_count += binding->descriptorCount; break; default: break; } - if (pCreateInfo->pBinding[b].pImmutableSamplers) { + if (binding->pImmutableSamplers) { set_layout->binding[b].immutable_samplers = samplers; - samplers += array_size; + samplers += binding->descriptorCount; - for (uint32_t i = 0; i < array_size; i++) + for (uint32_t i = 0; i < binding->descriptorCount; i++) set_layout->binding[b].immutable_samplers[i] = - anv_sampler_from_handle(pCreateInfo->pBinding[b].pImmutableSamplers[i]); + anv_sampler_from_handle(binding->pImmutableSamplers[i]); } else { set_layout->binding[b].immutable_samplers = NULL; } - set_layout->shader_stages |= pCreateInfo->pBinding[b].stageFlags; + set_layout->shader_stages |= binding->stageFlags; } set_layout->dynamic_offset_count = dynamic_offset_count; @@ -172,12 +177,12 @@ VkResult anv_CreatePipelineLayout( assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO); - l.num_sets = pCreateInfo->descriptorSetCount; + l.num_sets = pCreateInfo->setLayoutCount; unsigned dynamic_offset_count = 0; memset(l.stage, 0, sizeof(l.stage)); - for (uint32_t set = 0; set < pCreateInfo->descriptorSetCount; set++) { + for (uint32_t set = 0; set < pCreateInfo->setLayoutCount; set++) { ANV_FROM_HANDLE(anv_descriptor_set_layout, set_layout, pCreateInfo->pSetLayouts[set]); l.set[set].layout = set_layout; @@ -228,7 +233,7 @@ VkResult anv_CreatePipelineLayout( int surface = 0; int sampler = 0; - for (uint32_t set = 0; set < pCreateInfo->descriptorSetCount; set++) { + for (uint32_t set = 0; set < pCreateInfo->setLayoutCount; set++) { struct anv_descriptor_set_layout *set_layout = l.set[set].layout; for (uint32_t b = 0; b < set_layout->binding_count; b++) { @@ -299,7 +304,8 @@ void anv_DestroyDescriptorPool( VkResult anv_ResetDescriptorPool( VkDevice device, - VkDescriptorPool descriptorPool) + VkDescriptorPool descriptorPool, + VkDescriptorPoolResetFlags flags) { anv_finishme("VkDescriptorPool is a stub: free the pool's descriptor sets"); return VK_SUCCESS; @@ -346,12 +352,9 @@ anv_descriptor_set_destroy(struct anv_device *device, anv_device_free(device, set); } -VkResult anv_AllocDescriptorSets( +VkResult anv_AllocateDescriptorSets( VkDevice _device, - VkDescriptorPool descriptorPool, - VkDescriptorSetUsage setUsage, - uint32_t count, - const VkDescriptorSetLayout* pSetLayouts, + const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets) { ANV_FROM_HANDLE(anv_device, device, _device); @@ -360,8 +363,9 @@ VkResult anv_AllocDescriptorSets( struct anv_descriptor_set *set; uint32_t i; - for (i = 0; i < count; i++) { - ANV_FROM_HANDLE(anv_descriptor_set_layout, layout, pSetLayouts[i]); + for (i = 0; i < pAllocateInfo->setLayoutCount; i++) { + ANV_FROM_HANDLE(anv_descriptor_set_layout, layout, + pAllocateInfo->pSetLayouts[i]); result = anv_descriptor_set_create(device, layout, &set); if (result != VK_SUCCESS) @@ -371,7 +375,8 @@ VkResult anv_AllocDescriptorSets( } if (result != VK_SUCCESS) - anv_FreeDescriptorSets(_device, descriptorPool, i, pDescriptorSets); + anv_FreeDescriptorSets(_device, pAllocateInfo->descriptorPool, + i, pDescriptorSets); return result; } @@ -395,24 +400,24 @@ VkResult anv_FreeDescriptorSets( void anv_UpdateDescriptorSets( VkDevice device, - uint32_t writeCount, + uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, - uint32_t copyCount, + uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies) { - for (uint32_t i = 0; i < writeCount; i++) { + for (uint32_t i = 0; i < descriptorWriteCount; i++) { const VkWriteDescriptorSet *write = &pDescriptorWrites[i]; - ANV_FROM_HANDLE(anv_descriptor_set, set, write->destSet); + ANV_FROM_HANDLE(anv_descriptor_set, set, write->dstSet); const struct anv_descriptor_set_binding_layout *bind_layout = - &set->layout->binding[write->destBinding]; + &set->layout->binding[write->dstBinding]; struct anv_descriptor *desc = &set->descriptors[bind_layout->descriptor_index]; switch (write->descriptorType) { case VK_DESCRIPTOR_TYPE_SAMPLER: - for (uint32_t j = 0; j < write->count; j++) { + for (uint32_t j = 0; j < write->descriptorCount; j++) { ANV_FROM_HANDLE(anv_sampler, sampler, - write->pDescriptors[j].sampler); + write->pImageInfo[j].sampler); desc[j] = (struct anv_descriptor) { .type = VK_DESCRIPTOR_TYPE_SAMPLER, @@ -422,11 +427,11 @@ void anv_UpdateDescriptorSets( break; case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: - for (uint32_t j = 0; j < write->count; j++) { + for (uint32_t j = 0; j < write->descriptorCount; j++) { ANV_FROM_HANDLE(anv_image_view, iview, - write->pDescriptors[j].imageView); + write->pImageInfo[j].imageView); ANV_FROM_HANDLE(anv_sampler, sampler, - write->pDescriptors[j].sampler); + write->pImageInfo[j].sampler); desc[j].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; desc[j].image_view = iview; @@ -441,9 +446,9 @@ void anv_UpdateDescriptorSets( case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: - for (uint32_t j = 0; j < write->count; j++) { + for (uint32_t j = 0; j < write->descriptorCount; j++) { ANV_FROM_HANDLE(anv_image_view, iview, - write->pDescriptors[j].imageView); + write->pImageInfo[j].imageView); desc[j] = (struct anv_descriptor) { .type = write->descriptorType, @@ -465,17 +470,16 @@ void anv_UpdateDescriptorSets( case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: - for (uint32_t j = 0; j < write->count; j++) { - assert(write->pDescriptors[j].bufferInfo.buffer); - ANV_FROM_HANDLE(anv_buffer, buffer, - write->pDescriptors[j].bufferInfo.buffer); + for (uint32_t j = 0; j < write->descriptorCount; j++) { + assert(write->pBufferInfo[j].buffer); + ANV_FROM_HANDLE(anv_buffer, buffer, write->pBufferInfo[j].buffer); assert(buffer); desc[j] = (struct anv_descriptor) { .type = write->descriptorType, .buffer = buffer, - .offset = write->pDescriptors[j].bufferInfo.offset, - .range = write->pDescriptors[j].bufferInfo.range, + .offset = write->pBufferInfo[j].offset, + .range = write->pBufferInfo[j].range, }; /* For buffers with dynamic offsets, we use the full possible @@ -491,12 +495,12 @@ void anv_UpdateDescriptorSets( } } - for (uint32_t i = 0; i < copyCount; i++) { + for (uint32_t i = 0; i < descriptorCopyCount; i++) { const VkCopyDescriptorSet *copy = &pDescriptorCopies[i]; - ANV_FROM_HANDLE(anv_descriptor_set, src, copy->destSet); - ANV_FROM_HANDLE(anv_descriptor_set, dest, copy->destSet); - for (uint32_t j = 0; j < copy->count; j++) { - dest->descriptors[copy->destBinding + j] = + ANV_FROM_HANDLE(anv_descriptor_set, src, copy->dstSet); + ANV_FROM_HANDLE(anv_descriptor_set, dest, copy->dstSet); + for (uint32_t j = 0; j < copy->descriptorCount; j++) { + dest->descriptors[copy->dstBinding + j] = src->descriptors[copy->srcBinding + j]; } } diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c index a3f5733e122..a2626a0f63e 100644 --- a/src/vulkan/anv_meta.c +++ b/src/vulkan/anv_meta.c @@ -303,11 +303,12 @@ anv_device_init_meta_blit_state(struct anv_device *device) VkDescriptorSetLayoutCreateInfo ds_layout_info = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, - .count = 1, + .bindingCount = 1, .pBinding = (VkDescriptorSetLayoutBinding[]) { { + .binding = 0, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, - .arraySize = 1, + .descriptorCount = 1, .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT, .pImmutableSamplers = NULL }, @@ -319,7 +320,7 @@ anv_device_init_meta_blit_state(struct anv_device *device) anv_CreatePipelineLayout(anv_device_to_handle(device), &(VkPipelineLayoutCreateInfo) { .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, - .descriptorSetCount = 1, + .setLayoutCount = 1, .pSetLayouts = &device->meta_state.blit.ds_layout, }, &device->meta_state.blit.pipeline_layout); @@ -529,24 +530,28 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, }, &sampler); VkDescriptorSet set; - anv_AllocDescriptorSets(anv_device_to_handle(device), dummy_desc_pool, - VK_DESCRIPTOR_SET_USAGE_ONE_SHOT, - 1, &device->meta_state.blit.ds_layout, &set); + anv_AllocateDescriptorSets(anv_device_to_handle(device), + &(VkDescriptorSetAllocateInfo) { + .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, + .descriptorPool = dummy_desc_pool, + .setLayoutCount = 1, + .pSetLayouts = &device->meta_state.blit.ds_layout + }, &set); anv_UpdateDescriptorSets(anv_device_to_handle(device), 1, /* writeCount */ (VkWriteDescriptorSet[]) { { .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, - .destSet = set, - .destBinding = 0, - .destArrayElement = 0, - .count = 1, + .dstSet = set, + .dstBinding = 0, + .dstArrayElement = 0, + .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, - .pDescriptors = (VkDescriptorInfo[]) { + .pImageInfo = (VkDescriptorImageInfo[]) { { + .sampler = sampler, .imageView = anv_image_view_to_handle(src_iview), .imageLayout = VK_IMAGE_LAYOUT_GENERAL, - .sampler = sampler, }, } } -- 2.30.2