Skip to content

Commit

Permalink
Implement timestamp queries
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 30, 2024
1 parent 930f218 commit 9a28393
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion Sources/kope/graphics5/commandlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9a28393

Please sign in to comment.