Skip to content

Commit

Permalink
vkd3d: Add overhead tid to queue profile.
Browse files Browse the repository at this point in the history
Allows us to study specific parts of submission overhead.

Signed-off-by: Hans-Kristian Arntzen <[email protected]>
  • Loading branch information
HansKristian-Work committed Jan 3, 2025
1 parent b121e6d commit baa6c7f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions libs/vkd3d/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -18929,6 +18929,7 @@ static void d3d12_command_queue_execute(struct d3d12_command_queue *command_queu

if (is_first)
{
vkd3d_queue_timeline_trace_begin_execute_overhead(&command_queue->device->queue_timeline_trace, timeline_cookie);
d3d12_command_queue_gather_wait_semaphores_locked(command_queue, &submit_desc[0],
VKD3D_WAIT_SEMAPHORES_EXTERNAL | VKD3D_WAIT_SEMAPHORES_SERIALIZING);
}
Expand Down Expand Up @@ -18982,6 +18983,8 @@ static void d3d12_command_queue_execute(struct d3d12_command_queue *command_queu
command_queue->last_submission_timeline_value = signal_semaphore_infos[0].value;
}

vkd3d_queue_timeline_trace_end_execute_overhead(&command_queue->device->queue_timeline_trace, timeline_cookie);

#ifdef VKD3D_ENABLE_RENDERDOC
if (debug_capture)
vkd3d_renderdoc_command_queue_end_capture(command_queue);
Expand Down
29 changes: 28 additions & 1 deletion libs/vkd3d/queue_timeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,8 @@ void vkd3d_queue_timeline_trace_complete_execute(struct vkd3d_queue_timeline_tra
struct vkd3d_fence_worker *worker,
struct vkd3d_queue_timeline_trace_cookie cookie)
{
double end_ts, start_submit_ts, start_ts, overhead_start_ts, overhead_end_ts;
const struct vkd3d_queue_timeline_trace_state *state;
double end_ts, start_submit_ts, start_ts;
unsigned int pid;
const char *tid;
double *ts_lock;
Expand All @@ -556,6 +556,8 @@ void vkd3d_queue_timeline_trace_complete_execute(struct vkd3d_queue_timeline_tra
start_ts = (double)(state->start_ts - trace->base_ts) * 1e-3;
start_submit_ts = (double)(state->start_submit_ts - trace->base_ts) * 1e-3;
end_ts = (double)(vkd3d_get_current_time_ns() - trace->base_ts) * 1e-3;
overhead_start_ts = start_ts + 1e-3 * state->overhead_start_offset;
overhead_end_ts = start_ts + 1e-3 * state->overhead_end_offset;

if (worker)
{
Expand Down Expand Up @@ -593,6 +595,9 @@ void vkd3d_queue_timeline_trace_complete_execute(struct vkd3d_queue_timeline_tra
fprintf(trace->file,
"{ \"name\": \"%s\", \"ph\": \"X\", \"tid\": \"submit\", \"pid\": \"0x%04x\", \"ts\": %f, \"dur\": %f },\n",
state->desc, pid, start_ts, start_submit_ts - start_ts);
fprintf(trace->file,
"{ \"name\": \"%s\", \"ph\": \"X\", \"tid\": \"overhead\", \"pid\": \"0x%04x\", \"ts\": %f, \"dur\": %f },\n",
state->desc, pid, overhead_start_ts, overhead_end_ts - overhead_start_ts);
}
}

Expand All @@ -609,3 +614,25 @@ void vkd3d_queue_timeline_trace_begin_execute(struct vkd3d_queue_timeline_trace
state = &trace->state[cookie.index];
state->start_submit_ts = vkd3d_get_current_time_ns();
}

void vkd3d_queue_timeline_trace_begin_execute_overhead(struct vkd3d_queue_timeline_trace *trace,
struct vkd3d_queue_timeline_trace_cookie cookie)
{
struct vkd3d_queue_timeline_trace_state *state;
if (!trace->active || cookie.index == 0)
return;

state = &trace->state[cookie.index];
state->overhead_start_offset = vkd3d_get_current_time_ns() - state->start_ts;
}

void vkd3d_queue_timeline_trace_end_execute_overhead(struct vkd3d_queue_timeline_trace *trace,
struct vkd3d_queue_timeline_trace_cookie cookie)
{
struct vkd3d_queue_timeline_trace_state *state;
if (!trace->active || cookie.index == 0)
return;

state = &trace->state[cookie.index];
state->overhead_end_offset = vkd3d_get_current_time_ns() - state->start_ts;
}
8 changes: 7 additions & 1 deletion libs/vkd3d/vkd3d_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -4732,7 +4732,9 @@ struct vkd3d_queue_timeline_trace_state
uint64_t start_submit_ts;
uint64_t record_end_ts;
uint64_t record_cookie;
char desc[128 - 5 * sizeof(uint64_t)];
uint32_t overhead_start_offset;
uint32_t overhead_end_offset;
char desc[128 - 6 * sizeof(uint64_t)];
};

struct vkd3d_queue_timeline_trace
Expand Down Expand Up @@ -4811,6 +4813,10 @@ void vkd3d_queue_timeline_trace_close_command_list(struct vkd3d_queue_timeline_t
struct vkd3d_queue_timeline_trace_cookie cookie);
void vkd3d_queue_timeline_trace_begin_execute(struct vkd3d_queue_timeline_trace *trace,
struct vkd3d_queue_timeline_trace_cookie cookie);
void vkd3d_queue_timeline_trace_begin_execute_overhead(struct vkd3d_queue_timeline_trace *trace,
struct vkd3d_queue_timeline_trace_cookie cookie);
void vkd3d_queue_timeline_trace_end_execute_overhead(struct vkd3d_queue_timeline_trace *trace,
struct vkd3d_queue_timeline_trace_cookie cookie);

struct vkd3d_address_binding_report_buffer_info
{
Expand Down

0 comments on commit baa6c7f

Please sign in to comment.