mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 04:19:57 -04:00
GPU timeline (NX2NAVI_TRACE=perf): every 60 frames, what the GPU's idle time was spent waiting for.
The perf line's "idle with it queued" was the gap before each replay part handed over before the previous one ended: 13-17 ms a frame on an RX 580 in Kokiri Forest on 0.7.1, unexplained. Uploads and presents were not timed, a held submission (submit batching) counted as handed over while it still waited in vk_sync, and with cuts and pre-pass command buffers a submission closed more than the four timestamp pairs ts_unsent had room for: the rest went to the completion queue without a submit time and out of the GPU's order. Now every timed piece of GPU work (replay parts, mirror prologues, pre-pass command buffers, upload batches, presents) is noted with when it was handed to vk_sync, when it really went to the queue and its GPU start and end, and every 60 frames two lines split the idle time: starved (nothing in the queue, and how much of that a held submission waited in the batching) or with work in the queue, by the kind of piece that started after the gap, with the average delay from hand-over to start on an idle GPU per kind. ts_unsent has room for every command buffer of a submission, and the pairs are read in queue order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -671,7 +671,7 @@ void vk_mem_census(uint64_t frame) {
|
||||
mirror_frame = frame;
|
||||
static uint64_t window_start;
|
||||
if ((rt_trace & RT_TRACE_PERF) && frame % 600 == 0) vram_log(frame), mirror_pool_log(frame);
|
||||
if ((rt_trace & RT_TRACE_PERF) && frame % 60 == 0) outside_watch(frame);
|
||||
if ((rt_trace & RT_TRACE_PERF) && frame % 60 == 0) outside_watch(frame), up_ts_log(frame), vk_gtl_log(frame, 60);
|
||||
if ((rt_trace & RT_TRACE_PERF) && !vk_mirror_on) dirty_frame(frame);
|
||||
if ((rt_trace & RT_TRACE_PERF) ? frame % 60 == 0 : frame == 600 || frame == 1800)
|
||||
mirror_log(frame), shadow_log(frame); // mirror_log also logs the write-watch line
|
||||
@@ -4228,6 +4228,7 @@ typedef struct {
|
||||
VkDeviceSize chunk_used; // bytes of the last chunk handed out
|
||||
uint64_t bytes; // staging bytes of its buffers (upload_cap)
|
||||
int ts; // its pair of upload timestamps (up_ts_*), -1: not timed
|
||||
uint64_t sub_ns; // when it was handed to the queue (plat_now_ns), for the GPU timeline (vk_gtl_note)
|
||||
} Batch;
|
||||
|
||||
enum { DEAD_IMAGE = 1, DEAD_IMAGE_VMA, DEAD_VIEW, DEAD_BUFFER_VMA, DEAD_HOST };
|
||||
@@ -4241,6 +4242,7 @@ static int open_active;
|
||||
static Batch *inflight;
|
||||
static int ninflight, cap_inflight;
|
||||
static Batch *spare; // completed batches whose command buffer and fence are reused
|
||||
|
||||
// ---- upload GPU time (NX2NAVI_TRACE=perf): a timestamp at the start and the end of each upload batch, read when it
|
||||
// retires. The replay's GPU time (vk_sync.c) times only its own parts; upload batches go to the queue as submissions of
|
||||
// their own, with the ASTC decoder's dispatches in them, so their time showed only as GPU idle "with it queued".
|
||||
@@ -4276,6 +4278,7 @@ static void up_ts_read(VkCtx *c, Batch *b) { // b retired: its fence signalled
|
||||
VK_QUERY_RESULT_64_BIT) == VK_SUCCESS && t[1] >= t[0]) {
|
||||
uint64_t ns = (uint64_t)((double)(t[1] - t[0]) * c->props.limits.timestampPeriod);
|
||||
up_ts_ns += ns, up_ts_n++;
|
||||
vk_gtl_note(GTL_UPLOAD, b->sub_ns, t[0], t[1]);
|
||||
if (ns > up_ts_max_ns) up_ts_max_ns = ns;
|
||||
}
|
||||
up_ts_busy[b->ts] = 0;
|
||||
@@ -4755,6 +4758,7 @@ uint64_t vk_upload_flush(int wait) {
|
||||
vkEndCommandBuffer(open_b.cb);
|
||||
VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .commandBufferCount = 1, .pCommandBuffers = &open_b.cb};
|
||||
vk_queue_lock();
|
||||
open_b.sub_ns = plat_now_ns();
|
||||
VkResult r = vkQueueSubmit(c->gfx_queue, 1, &si, open_b.fence);
|
||||
vk_queue_unlock();
|
||||
if (r != VK_SUCCESS) {
|
||||
|
||||
Reference in New Issue
Block a user