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),
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,
VkStructureType sType;
const void* pNext;
VkPipelineLayoutCreateFlags flags;
- uint32_t descriptorSetCount;
+ uint32_t setLayoutCount;
const VkDescriptorSetLayout* pSetLayouts;
uint32_t pushConstantRangeCount;
const VkPushConstantRange* pPushConstantRanges;
} VkSamplerCreateInfo;
typedef struct VkDescriptorSetLayoutBinding {
+ uint32_t binding;
VkDescriptorType descriptorType;
- uint32_t arraySize;
+ uint32_t descriptorCount;
VkShaderStageFlags stageFlags;
const VkSampler* pImmutableSamplers;
} VkDescriptorSetLayoutBinding;
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 {
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 {
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);
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(
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,
/* 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));
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:
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;
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;
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++) {
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;
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);
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)
}
if (result != VK_SUCCESS)
- anv_FreeDescriptorSets(_device, descriptorPool, i, pDescriptorSets);
+ anv_FreeDescriptorSets(_device, pAllocateInfo->descriptorPool,
+ i, pDescriptorSets);
return result;
}
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,
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;
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,
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
}
}
- 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];
}
}