diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp index 06d8549ee..a1c15833c 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp @@ -148,9 +148,23 @@ void kope_d3d12_command_list_begin_render_pass(kope_g5_command_list *list, const } list->d3d12.occlusion_query_set = parameters->occlusion_query_set; + + list->d3d12.timestamp_query_set = parameters->timestamp_writes.query_set; + list->d3d12.timestamp_beginning_of_pass_write_index = parameters->timestamp_writes.beginning_of_pass_write_index; + list->d3d12.timestamp_end_of_pass_write_index = parameters->timestamp_writes.end_of_pass_write_index; + + if (list->d3d12.timestamp_query_set != NULL) { + list->d3d12.list->EndQuery(list->d3d12.timestamp_query_set->d3d12.query_heap, D3D12_QUERY_TYPE_TIMESTAMP, + list->d3d12.timestamp_beginning_of_pass_write_index); + } } -void kope_d3d12_command_list_end_render_pass(kope_g5_command_list *list) {} +void kope_d3d12_command_list_end_render_pass(kope_g5_command_list *list) { + if (list->d3d12.timestamp_query_set != NULL) { + list->d3d12.list->EndQuery(list->d3d12.timestamp_query_set->d3d12.query_heap, D3D12_QUERY_TYPE_TIMESTAMP, + list->d3d12.timestamp_end_of_pass_write_index); + } +} void kope_d3d12_command_list_present(kope_g5_command_list *list) { list->d3d12.presenting = true; diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_structs.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_structs.h index 457403e05..d86631a94 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_structs.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist_structs.h @@ -43,6 +43,10 @@ typedef struct kope_d3d12_command_list { struct kope_g5_query_set *occlusion_query_set; uint32_t current_occlusion_query_index; + struct kope_g5_query_set *timestamp_query_set; + uint32_t timestamp_beginning_of_pass_write_index; + uint32_t timestamp_end_of_pass_write_index; + bool presenting; } kope_d3d12_command_list; diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp index 8be721eb4..b8bb5adc2 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp @@ -315,6 +315,10 @@ void kope_d3d12_device_create_command_list(kope_g5_device *device, kope_g5_comma list->d3d12.occlusion_query_set = NULL; list->d3d12.current_occlusion_query_index = 0; + list->d3d12.timestamp_query_set = NULL; + list->d3d12.timestamp_beginning_of_pass_write_index = 0; + list->d3d12.timestamp_end_of_pass_write_index = 0; + list->d3d12.blocking_frame_index = 0; list->d3d12.presenting = false; diff --git a/Sources/kope/graphics5/commandlist.h b/Sources/kope/graphics5/commandlist.h index 1873760dd..5415d255d 100644 --- a/Sources/kope/graphics5/commandlist.h +++ b/Sources/kope/graphics5/commandlist.h @@ -73,12 +73,18 @@ typedef struct kope_g5_render_pass_depth_stencil_attachment { bool stencil_read_only; } kope_g5_render_pass_depth_stencil_attachment; +typedef struct kope_g5_render_pass_timestamp_writes { + struct kope_g5_query_set *query_set; + uint32_t beginning_of_pass_write_index; + uint32_t end_of_pass_write_index; +} kope_g5_render_pass_timestamp_writes; + typedef struct kope_g5_render_pass_parameters { kope_g5_render_pass_color_attachment color_attachments[8]; size_t color_attachments_count; kope_g5_render_pass_depth_stencil_attachment depth_stencil_attachment; struct kope_g5_query_set *occlusion_query_set; - // GPURenderPassTimestampWrites timestampWrites; + kope_g5_render_pass_timestamp_writes timestamp_writes; } kope_g5_render_pass_parameters; KOPE_FUNC void kope_g5_command_list_begin_render_pass(kope_g5_command_list *list, const kope_g5_render_pass_parameters *parameters);