diff --git a/dm/games/040074A01BF12000/README.md b/dm/games/040074A01BF12000/README.md index 4305928f18..ad73ce4a47 100644 --- a/dm/games/040074A01BF12000/README.md +++ b/dm/games/040074A01BF12000/README.md @@ -160,3 +160,7 @@ Each step below stopped the boot before its fix: - [A deferred write under a false guard](../../../docs/reference/shaders.md#a-deferred-write-under-a-false-guard): DK and Pauline bright white between Hilltop's rocks, from terrain captured into the environment cube with a placeholder material (issue #1100; fixed by the translator change found on Yoshi and the Mysterious Book, spot not revisited, reporter's test asked). - [MUFU.SIN and MUFU.COS of a large number of turns](../../../docs/reference/shaders.md#mufusin-and-mufucos-of-a-large-number-of-turns): the SSAO's kernel rotation, (0, 0) past 2^20 turns, no ambient occlusion in the lower right: a corner wedge at the top of dynamic resolution (1152x648), a fifth of the picture with the effects at full size. - [Unused border corrections retain sample registers](../../../docs/reference/rendering.md#unused-border-corrections-retain-sample-registers): a SilverStar material spilled 336 bytes a thread for a correction that never ran here, 160 without it; the heavy area's scene pass 5.1 → 3.2 ms on an M1 in handheld with the corrections taken out at build time (PR #1203). Open: not measured again with the function constant that landed. + +### Acquire-wait diagnostic correction + +A 350-second gameplay trace on iPhone 17 Pro Max, using a combined experimental renderer, exposed [incorrect acquire-wait telemetry](../../../docs/reference/frame-rate.md#acquire-wait-telemetry-measures-elapsed-pacing-time). `@wait_ms` now measures elapsed pacing wait. This diagnostic correction changes no rendering or pacing behavior; that phone trace is not verification of this exact source head. diff --git a/dm/gfx/nvn/hle_nvn.c b/dm/gfx/nvn/hle_nvn.c index 467fe80932..e2046ae60e 100644 --- a/dm/gfx/nvn/hle_nvn.c +++ b/dm/gfx/nvn/hle_nvn.c @@ -2393,7 +2393,7 @@ static int acq_pace_do(win_t *o, uint64_t at, uint64_t timeout_ns, uint64_t dead if (sa) *waited = 1; pace_ns += sa; } - atomic_fetch_add(&g_acq_wait_ns, wait); + atomic_fetch_add(&g_acq_wait_ns, pace_ns); uint64_t woke = wait ? now_ns() : at; trow(g_frame, "@late_ms", woke > at ? (woke - at) / 1e6 : 0); // a display-link tick can wake the acquire before the slot pthread_mutex_lock(&acq_mu); diff --git a/dm/gfx/tests/t_link_ticks.m b/dm/gfx/tests/t_link_ticks.m index 7babec65ad..7c983bf360 100644 --- a/dm/gfx/tests/t_link_ticks.m +++ b/dm/gfx/tests/t_link_ticks.m @@ -173,6 +173,13 @@ int main(int argc, char **argv) { @autoreleasepool { CHECK(a == 2, "a 60 Hz vsync is two ticks of a 120 Hz link"); CHECK(b == 1, "one own tick per frame: 120 frames a second"); CHECK(c == 2, "two own ticks"); + { // A display-link wait can block even when the fallback deadline is zero. + nvn_present_config(120, 1); win_t win = {.interval = 2}; int idx; + uint64_t start = test_now, wait0 = g_acq_wait_ns; + h_nvnWindowAcquireTexture((NVNwindow *)&win, NULL, &idx); + CHECK(test_now > start && g_acq_wait_ns - wait0 == test_now - start, + "acquire telemetry records elapsed display-link waiting without a fallback deadline"); + } acquire_ticks(120, 1, 2, 1, "display 120 Hz ignores the game's interval"); acquire_ticks(90, 1, 1, 4. / 3, "display 90 Hz preserves fractional ticks"); acquire_ticks(75, 1, 1, 1.6, "display 75 Hz preserves fractional ticks"); diff --git a/docs/agents/symptoms.md b/docs/agents/symptoms.md index 69ed32bdbe..a4b993e0ce 100644 --- a/docs/agents/symptoms.md +++ b/docs/agents/symptoms.md @@ -861,6 +861,7 @@ One line per symptom in the [subsystem references](../reference/): what you see - replay thread CPU on draw-heavy NVN scenes spends measurable time sending `textureType` and `pixelFormat` Objective-C messages on every texture slot during full argument encodes, pool walks, handle-table builds, image bindings and depth-plane checks (about 6,700–9,900 hot-path metadata lookups a frame on Mario Kart World 1.8.0's title scene, about 1,960 draws / 1,515 full encodes a frame). → [Full argument encodes messaged each texture's type and pixel format](../reference/frame-rate.md#full-argument-encodes-messaged-each-textures-type-and-pixel-format) - on a warm start, Ocarina of Time stepped the frame hold 1 → 2 → 3 at presents 9 and 12 (cost 1.92 and 5.57 vsyncs, GPU 0.02 and 0.01 vsyncs) on a progress screen while the pipeline archive was written, then stayed at hold 3 (~18 fps) for ~1,470 presents even though the scene's GPU work was 12.5 ms. → [Late frames with an idle GPU stepped the hold up and unpaced holds did not probe](../reference/frame-rate.md#late-frames-with-an-idle-gpu-stepped-the-hold-up-and-unpaced-holds-did-not-probe) - at a 30 fps cap on iOS (where `DM_PRESENT_DRAIN=0` keeps the automatic 30 Hz display link), frames just over 33.3 ms (~36 ms in Kokiri Forest on an iPhone 17 and at the Deku Tree on an M1 iPad Pro) missed their 30 Hz tick and stayed on screen for 66.7 ms (~23–33 per 300 frames, on-screen p99 66.7 ms). → [Late frames at a 30 fps cap on the 30 Hz display link](../reference/frame-rate.md#late-frames-at-a-30-fps-cap-on-the-30-hz-display-link) +- `DM_NVN_TSV` reports zero `@wait_ms` when acquire blocks on a display-link tick, or reports the planned fallback delay instead of the elapsed wait. → [Acquire-wait telemetry measures elapsed pacing time](../reference/frame-rate.md#acquire-wait-telemetry-measures-elapsed-pacing-time) ## NVN objects diff --git a/docs/reference/frame-rate.md b/docs/reference/frame-rate.md index 91634d0722..99e90e1e3f 100644 --- a/docs/reference/frame-rate.md +++ b/docs/reference/frame-rate.md @@ -1152,3 +1152,9 @@ Frame pacing: the host's frame step, engine frame limiters, present intervals an - **Measured:** M1 iPad Pro (Ocarina of Time, Deku Tree, 30 fps cap, Dynamic resolution on, 9,000 frames of camera turns): 66.7 ms gaps cut from 22.8 → 0.2 per 300 frames, on-screen p99 66.7 → 50.0 ms (27.9 → 27.7 fps, game time 1.000). iPhone 17 (Kokiri Forest, thermal state 1): ~30/300 → 1/2,096 gaps over 50 ms, p99 45.8–50.0 ms ([PR #1971](https://github.com/seedds/nxnative/pull/1971)). Open: the power cost of 60 callbacks a second while `fine` is active is not measured. - **Found on:** [The Legend of Zelda: Ocarina of Time](../../dm/games/0400486024DEC000/README.md#found-on-this-game). +### Acquire-wait telemetry measures elapsed pacing time + +- **Symptom:** `DM_NVN_TSV` reports zero `@wait_ms` when acquire blocks on a display-link tick, or reports the planned fallback delay instead of the elapsed wait. +- **Cause:** `nvnWindowAcquireTexture` accumulated `wait`, computed from the texture's fallback availability deadline, even when display-link pacing took a different path. +- **Fix:** accumulate the already measured `pace_ns`, including snapshot-capacity waiting. Present-queue waiting remains separate in `@pq_wait_ms`. This changes diagnostics only; it does not change the wait, frame rate or presentation policy. The controlled-clock `t_link_ticks` case has a zero fallback deadline and a nonzero display-link wait. +- **Found on:** [Donkey Kong Bananza](../../dm/games/040074A01BF12000/README.md), while analyzing a 350-second physical iPhone 17 Pro Max trace from a combined experimental build. Older `@wait_ms` values must not be treated as measured blocked time. This correction does not establish the cause of its pacing dips or improve performance.