On Thu, 31 Mar 2022 at 12:58, Jan Sikorski jsikorski@codeweavers.com wrote:
+VkDescriptorSet wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk,
VkDescriptorSetLayout vk_set_layout)
+{
- struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
- const struct wined3d_vk_info *vk_info = context_vk->vk_info;
- struct VkDescriptorSetAllocateInfo set_desc;
- VkDescriptorPool vk_descriptor_pool;
- VkDescriptorSet vk_descriptor_set;
- VkResult vr;
- if (!(vk_descriptor_pool = wined3d_context_vk_get_vk_descriptor_pool(context_vk)))
return VK_NULL_HANDLE;
- set_desc.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; set_desc.pNext = NULL;
- set_desc.descriptorPool = context_vk->vk_descriptor_pool;
- set_desc.descriptorPool = vk_descriptor_pool; set_desc.descriptorSetCount = 1; set_desc.pSetLayouts = &vk_set_layout;
- if ((vr = VK_CALL(vkAllocateDescriptorSets(device_vk->vk_device, &set_desc, vk_descriptor_set))) >= 0)
return vr;
if ((vr = VK_CALL(vkAllocateDescriptorSets(device_vk->vk_device, &set_desc, &vk_descriptor_set))) >= 0)
return vk_descriptor_set;
if (vr == VK_ERROR_FRAGMENTED_POOL || vr == VK_ERROR_OUT_OF_POOL_MEMORY) {
wined3d_context_vk_destroy_vk_descriptor_pool(context_vk,
context_vk->vk_descriptor_pool, context_vk->current_command_buffer.id);
context_vk->vk_descriptor_pool = VK_NULL_HANDLE;
if ((vr = wined3d_context_vk_create_vk_descriptor_pool(device_vk, vk_info, &context_vk->vk_descriptor_pool)))
wined3d_context_vk_reset_vk_descriptor_pool(context_vk,
vk_descriptor_pool, context_vk->current_command_buffer.id);
context_vk->vk_descriptor_pools[0] = context_vk->vk_descriptor_pools[--context_vk->vk_descriptor_pool_count];
It think the way we remove the pool from the array above is a little awkward. It depends on knowledge about the internals of wined3d_context_vk_get_vk_descriptor_pool() to know that "vk_descriptor_pool" is the first entry in the array, which is never quite ideal for users of such functions. Conceptually, this seems like something wined3d_context_vk_reset_vk_descriptor_pool() should take care of.