mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 23:19:57 -04:00
Add replay diagnostics that found this session's frame-time dips, all off by default.
lock_time (NX2NAVI_LOCK_TIME) makes the replay threads time each lock they have to wait for, kept per asking site (platform.h plat_lock_timing, plat_mutex_lock_at and plat_rmutex_lock_at carry the site), and the frame-time summary lists the sites with the most wait, the recorder's full-ring and drain waits, and the texture lock's holds over 1 ms with the code that took it. replay_time now also keeps each frame's replay ops: a frame over 25 ms charged to the replay says how many draws, binds and transfers it replayed, their time, its slowest op, and how much of the replay's wall time the thread was on the CPU. NX2NAVI_PROFILE_REPLAY=1 samples only the replay thread without call chains, and the profiler now follows the thread that replays instead of the one that started the back end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@ static volatile uint64_t part_fence; // the value of the part being recorded (
|
||||
|
||||
// Producer statistics, logged by rec_stats_log.
|
||||
static struct { uint64_t packets, words, drains, fallbacks, drain_ns, full_waits, parts, parts_on; } RS_;
|
||||
static volatile uint64_t full_ns_all, drain_ns_all; // since the start, for rec_wait_totals (never reset)
|
||||
|
||||
enum {
|
||||
R_PAD, R_BeginQuery, R_BeginRendering, R_BindDescriptorSets, R_BindIndexBuffer, R_BindPipeline, R_BindVertexBuffers2,
|
||||
@@ -92,9 +93,11 @@ static void wake(void) {
|
||||
static void wait_space(uint64_t need) {
|
||||
if (put_h + need - __atomic_load_n(&tail, __ATOMIC_ACQUIRE) <= RING_WORDS) return;
|
||||
RS_.full_waits++;
|
||||
uint64_t t0 = now_ns();
|
||||
__atomic_store_n(&head, put_h, __ATOMIC_RELEASE);
|
||||
wake();
|
||||
while (put_h + need - __atomic_load_n(&tail, __ATOMIC_ACQUIRE) > RING_WORDS) _mm_pause();
|
||||
full_ns_all += now_ns() - t0;
|
||||
}
|
||||
|
||||
// Room for a packet of bytes of arguments; the caller fills it and calls pub().
|
||||
@@ -130,9 +133,12 @@ void rec_drain(void) {
|
||||
for (int i = 0; __atomic_load_n(&tail, __ATOMIC_ACQUIRE) != put_h; i++)
|
||||
if (i < 20000) _mm_pause();
|
||||
else plat_yield();
|
||||
RS_.drains++, RS_.drain_ns += now_ns() - t0;
|
||||
uint64_t d = now_ns() - t0;
|
||||
RS_.drains++, RS_.drain_ns += d, drain_ns_all += d;
|
||||
}
|
||||
|
||||
void rec_wait_totals(uint64_t *full_ns, uint64_t *drain_ns) { *full_ns = full_ns_all, *drain_ns = drain_ns_all; }
|
||||
|
||||
void rec_begin(VkCommandBuffer cb, uint64_t fence) {
|
||||
static int mode = -1;
|
||||
if (mode < 0) {
|
||||
|
||||
Reference in New Issue
Block a user