From c7a2a7be35b2c035a9dce9fcfdb88ffd547fe59f Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Sun, 6 Oct 2024 19:53:50 +0200 Subject: [PATCH] Receive dynamic offsets --- .../Sources/kope/direct3d12/commandlist.cpp | 14 +++++++++++++- .../kope/direct3d12/commandlist_functions.h | 2 +- .../kope/direct3d12/descriptorset_structs.h | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp index a4ce518f9..76a8c3e11 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp @@ -226,7 +226,7 @@ void kope_d3d12_command_list_draw_indexed(kope_g5_command_list *list, uint32_t i list->d3d12.list->DrawIndexedInstanced(index_count, instance_count, first_index, base_vertex, first_instance); } -void kope_d3d12_command_list_set_descriptor_table(kope_g5_command_list *list, uint32_t table_index, kope_d3d12_descriptor_set *set) { +void kope_d3d12_command_list_set_descriptor_table(kope_g5_command_list *list, uint32_t table_index, kope_d3d12_descriptor_set *set, uint32_t *dynamic_offsets) { if (set->descriptor_count > 0) { D3D12_GPU_DESCRIPTOR_HANDLE gpu_descriptor = list->d3d12.device->descriptor_heap->GetGPUDescriptorHandleForHeapStart(); gpu_descriptor.ptr += set->descriptor_allocation.offset * list->d3d12.device->cbv_srv_uav_increment; @@ -239,6 +239,18 @@ void kope_d3d12_command_list_set_descriptor_table(kope_g5_command_list *list, ui table_index += 1; } + if (set->dynamic_descriptor_count > 0) { + D3D12_GPU_DESCRIPTOR_HANDLE gpu_descriptor = list->d3d12.device->descriptor_heap->GetGPUDescriptorHandleForHeapStart(); + /*gpu_descriptor.ptr += set->descriptor_allocation.offset * list->d3d12.device->cbv_srv_uav_increment; + if (list->d3d12.compute_pipe != NULL || list->d3d12.ray_pipe != NULL) { + list->d3d12.list->SetComputeRootDescriptorTable(table_index, gpu_descriptor); + } + else { + list->d3d12.list->SetGraphicsRootDescriptorTable(table_index, gpu_descriptor); + }*/ + table_index += 1; + } + if (set->sampler_count > 0) { D3D12_GPU_DESCRIPTOR_HANDLE gpu_descriptor = list->d3d12.device->sampler_heap->GetGPUDescriptorHandleForHeapStart(); gpu_descriptor.ptr += set->sampler_allocation.offset * list->d3d12.device->sampler_increment; diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_functions.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_functions.h index 0ec59e393..d9ceb4a66 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_functions.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_functions.h @@ -56,7 +56,7 @@ void kope_d3d12_command_list_draw(kope_g5_command_list *list, uint32_t vertex_co void kope_d3d12_command_list_draw_indexed(kope_g5_command_list *list, uint32_t index_count, uint32_t instance_count, uint32_t first_index, int32_t base_vertex, uint32_t first_instance); -void kope_d3d12_command_list_set_descriptor_table(kope_g5_command_list *list, uint32_t table_index, kope_d3d12_descriptor_set *set); +void kope_d3d12_command_list_set_descriptor_table(kope_g5_command_list *list, uint32_t table_index, kope_d3d12_descriptor_set *set, uint32_t *dynamic_offsets); void kope_d3d12_command_list_set_root_constants(kope_g5_command_list *list, uint32_t table_index, const void *data, size_t data_size); diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_structs.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_structs.h index 6df0a08a1..4b3eb95ff 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_structs.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_structs.h @@ -15,6 +15,8 @@ typedef struct kope_d3d12_descriptor_set { oa_allocation_t descriptor_allocation; size_t descriptor_count; + size_t dynamic_descriptor_count; + oa_allocation_t sampler_allocation; size_t sampler_count; } kope_d3d12_descriptor_set;