diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp index b6eca4579..9457ba29d 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp @@ -786,3 +786,8 @@ void kope_d3d12_command_list_queue_buffer_access(kope_g5_command_list *list, kop list->d3d12.queued_buffer_accesses[list->d3d12.queued_buffer_accesses_count] = access; list->d3d12.queued_buffer_accesses_count += 1; } + +void kope_d3d12_command_list_queue_descriptor_set_access(kope_g5_command_list *list, kope_d3d12_descriptor_set *descriptor_set) { + list->d3d12.queued_descriptor_set_accesses[list->d3d12.queued_descriptor_set_accesses_count] = descriptor_set; + list->d3d12.queued_descriptor_set_accesses_count += 1; +} diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_functions.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_functions.h index e7888ffd0..05685c9f1 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_functions.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_functions.h @@ -101,6 +101,8 @@ void kope_d3d12_command_list_compute_indirect(kope_g5_command_list *list, kope_g void kope_d3d12_command_list_queue_buffer_access(kope_g5_command_list *list, kope_g5_buffer *buffer, uint32_t offset, uint32_t size); +void kope_d3d12_command_list_queue_descriptor_set_access(kope_g5_command_list *list, kope_d3d12_descriptor_set *descriptor_set); + #ifdef __cplusplus } #endif diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_structs.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_structs.h index e1cc39bfe..7e4ad909f 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_structs.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_structs.h @@ -14,6 +14,7 @@ struct kope_d3d12_texture; struct kope_d3d12_compute_pipeline; struct kope_d3d12_ray_pipeline; struct kope_d3d12_rendery_pipeline; +struct kope_d3d12_descriptor_set; struct kope_g5_query_set; struct ID3D12Fence; @@ -26,6 +27,8 @@ struct ID3D12Fence; #define KOPE_D3D12_COMMAND_LIST_MAX_QUEUED_BUFFER_ACCESSES 256 +#define KOPE_D3D12_COMMAND_LIST_MAX_QUEUED_DESCRIPTOR_SET_ACCESSES 256 + typedef struct kope_d3d12_buffer_access { kope_g5_buffer *buffer; uint64_t offset; @@ -68,6 +71,9 @@ typedef struct kope_d3d12_command_list { kope_d3d12_buffer_access queued_buffer_accesses[KOPE_D3D12_COMMAND_LIST_MAX_QUEUED_BUFFER_ACCESSES]; uint32_t queued_buffer_accesses_count; + struct kope_d3d12_descriptor_set *queued_descriptor_set_accesses[KOPE_D3D12_COMMAND_LIST_MAX_QUEUED_DESCRIPTOR_SET_ACCESSES]; + uint32_t queued_descriptor_set_accesses_count; + bool presenting; } kope_d3d12_command_list; diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_structs.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_structs.h index c4cb645da..d97eee4a8 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_structs.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_structs.h @@ -22,6 +22,8 @@ typedef struct kope_d3d12_descriptor_set { oa_allocation_t sampler_allocation; size_t sampler_count; + + uint64_t execution_index; } kope_d3d12_descriptor_set; #ifdef __cplusplus diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp index 3891d5f6e..7a3b5ae32 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp @@ -334,6 +334,8 @@ void kope_d3d12_device_create_command_list(kope_g5_device *device, kope_g5_comma list->d3d12.queued_buffer_accesses_count = 0; + list->d3d12.queued_descriptor_set_accesses_count = 0; + list->d3d12.presenting = false; ID3D12DescriptorHeap *heaps[] = {list->d3d12.device->descriptor_heap, list->d3d12.device->sampler_heap}; @@ -595,6 +597,13 @@ void kope_d3d12_device_execute_command_list(kope_g5_device *device, kope_g5_comm } list->d3d12.queued_buffer_accesses_count = 0; + for (uint32_t set_access_index = 0; set_access_index < list->d3d12.queued_descriptor_set_accesses_count; ++set_access_index) { + kope_d3d12_descriptor_set *set = list->d3d12.queued_descriptor_set_accesses[set_access_index]; + + set->execution_index = device->d3d12.execution_index; + } + list->d3d12.queued_descriptor_set_accesses_count = 0; + list->d3d12.allocator_execution_index[list->d3d12.current_allocator_index] = device->d3d12.execution_index; ID3D12CommandList *lists[] = {list->d3d12.list}; @@ -654,6 +663,8 @@ void kope_d3d12_device_create_descriptor_set(kope_g5_device *device, uint32_t de oa_allocate(&device->d3d12.sampler_heap_allocator, sampler_count, &set->sampler_allocation); } set->sampler_count = sampler_count; + + set->execution_index = 0; } static D3D12_TEXTURE_ADDRESS_MODE convert_address_mode(kope_g5_address_mode mode) {