vkd3d: Synchronise concurrent descriptor heap binding by multiple command lists.

It is possible for multiple command lists to use the same heap, and
submit it simultaneously to multiple d3d12 queues.
This commit is contained in:
Conor McCarthy 2023-04-27 15:05:58 +10:00 committed by Alexandre Julliard
parent fa63da6030
commit 5366ca7001
3 changed files with 14 additions and 3 deletions

View File

@ -3176,7 +3176,11 @@ static void command_list_flush_vk_heap_updates(struct d3d12_command_list *list)
unsigned int i;
for (i = 0; i < list->descriptor_heap_count; ++i)
d3d12_desc_flush_vk_heap_updates(list->descriptor_heaps[i], device);
{
vkd3d_mutex_lock(&list->descriptor_heaps[i]->vk_sets_mutex);
d3d12_desc_flush_vk_heap_updates_locked(list->descriptor_heaps[i], device);
vkd3d_mutex_unlock(&list->descriptor_heaps[i]->vk_sets_mutex);
}
list->descriptor_heap_count = 0;
}
@ -3215,6 +3219,8 @@ static void d3d12_command_list_bind_descriptor_heap(struct d3d12_command_list *l
list->descriptor_heaps[list->descriptor_heap_count++] = heap;
}
vkd3d_mutex_lock(&heap->vk_sets_mutex);
for (set = 0; set < ARRAY_SIZE(heap->vk_descriptor_sets); ++set)
{
VkDescriptorSet vk_descriptor_set = heap->vk_descriptor_sets[set].vk_set;
@ -3225,6 +3231,8 @@ static void d3d12_command_list_bind_descriptor_heap(struct d3d12_command_list *l
VK_CALL(vkCmdBindDescriptorSets(list->vk_command_buffer, bindings->vk_bind_point, rs->vk_pipeline_layout,
rs->vk_set_count + set, 1, &vk_descriptor_set, 0, NULL));
}
vkd3d_mutex_unlock(&heap->vk_sets_mutex);
}
static void d3d12_command_list_update_heap_descriptors(struct d3d12_command_list *list,

View File

@ -2323,7 +2323,7 @@ static void d3d12_desc_write_vk_heap(struct d3d12_descriptor_heap *descriptor_he
writes->count = i;
}
void d3d12_desc_flush_vk_heap_updates(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device)
void d3d12_desc_flush_vk_heap_updates_locked(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
struct d3d12_desc *descriptors, *src;
@ -3724,6 +3724,7 @@ static ULONG STDMETHODCALLTYPE d3d12_descriptor_heap_Release(ID3D12DescriptorHea
}
VK_CALL(vkDestroyDescriptorPool(device->vk_device, heap->vk_descriptor_pool, NULL));
vkd3d_mutex_destroy(&heap->vk_sets_mutex);
vkd3d_free(heap);
@ -3946,6 +3947,7 @@ static HRESULT d3d12_descriptor_heap_init(struct d3d12_descriptor_heap *descript
return hr;
d3d12_descriptor_heap_vk_descriptor_sets_init(descriptor_heap, device, desc);
vkd3d_mutex_init(&descriptor_heap->vk_sets_mutex);
d3d12_device_add_ref(descriptor_heap->device = device);

View File

@ -988,13 +988,14 @@ struct d3d12_descriptor_heap
VkDescriptorPool vk_descriptor_pool;
struct d3d12_descriptor_heap_vk_set vk_descriptor_sets[VKD3D_SET_INDEX_COUNT];
struct vkd3d_mutex vk_sets_mutex;
unsigned int volatile dirty_list_head;
uint8_t DECLSPEC_ALIGN(sizeof(void *)) descriptors[];
};
void d3d12_desc_flush_vk_heap_updates(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device);
void d3d12_desc_flush_vk_heap_updates_locked(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device);
static inline struct d3d12_descriptor_heap *d3d12_desc_get_descriptor_heap(const struct d3d12_desc *descriptor)
{