Repository navigation
Frame pacer: keep the 30 fps grid half a vsync before the latch (VK_GOOGLE_display_timing), no more 50 / 16.7 ms judder - #183
Conversation
…OOGLE_display_timing) With a frame limit the present grid had no tie to the display: its phase stayed wherever the last long frame left it, and near the compositor's latch frames went out as 50 / 16.7 ms (60 Hz) or 41.7 / 25 ms (120 Hz) for minutes. On Android the vsync period and past present times come from VK_GOOGLE_display_timing; the pacer now keeps each frame queued half a vsync before one. No timings, no whole-vsync grid, or LARECOMP_PACE_VSYNC=0: pacing as before. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Follow-up: the remaining 41.7 / 25 ms intervals at 120 Hz come from the display HAL, not from the pacing The PR's limitations list a ~0.17 share of 41.7 / 25 ms intervals at 120 Hz that does not depend on the grid's phase. I traced it on the same device (Samsung SM-X730, Dimensity 9400+ / Mali-G925, Android 16, 120 Hz, Native, 30 fps cap). Capture: one 180 s window with Perfetto FrameTimeline + atrace
So this background is outside the app and needs no change in this PR. Only one device and HWC vendor was checked, with refresh forced to 120 Hz and USB power. Other panels and adaptive refresh were not tested. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged, thank you! I measured it on my POCO F7 Ultra (Adreno 830, Turnip, 30 fps, in the world) by SurfaceFlinger's actual present times (
So at 60 Hz it does exactly what you described, a clear win. At 120 Hz it made things worse here, as you suspected. I added a follow-up (cdb85c6) that keeps the steering to refresh periods of 12 ms and up (60 Hz) for now; with it, 120 Hz measured 3.5%, like main. If you find what goes wrong at 120 Hz (maybe the 4 ms half-vsync lead is too tight for the jitter there), I'd be glad to lift it. You're in the README's contributors now, for this and #210. |
…he judder on a POCO F7 Ultra (#183) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… tamanhos inteiros Junção da v0.3.1-beta de mamcjr (0.3.0 e 0.3.1): quedas com Magnésis, Stasis e câmera do Slate, botão de flechas, álbum, mapa com dois toques, giroscópio como a tela do Switch, 40/45 FPS, folga de ADPF, correções da tela larga, variáveis do driver, memória por arquivo compartilhado (Mali/Xclipse) e som depois do segundo plano (SDL refeita). Conflitos resolvidos: - Ritmo: os quadros regulares do S23 (present_lock) continuam o padrão; o ajuste de fase do original (mamcjr#183) vale quando eles estão desligados (LARECOMP_VSYNC_STEER=1/0 força). Os dois liam os mesmos tempos do painel, que o driver entrega uma vez só. - A extensão de tempo de apresentação é ligada uma vez só (o original a punha depois das duas de mapa, que saem juntas pela contagem n_ext -= 2). - O pedido de 40/45 FPS à janela não apaga mais o pedido de 60 Hz dos quadros regulares. - Configurações: linha de 2048 com o fim de linha CRLF do original. Novidades S23: - Mira pelo dedo (experimental, desligada): com os ícones, o arco na mão e o sensor de movimento ligado, o arrasto gira a mira como o celular girando, sem o limite de velocidade do direcional. - Dica na sensibilidade do arrasto: acima de uns 400% só os arrastos lentos mudam (limite do jogo). - Escala da cena em múltiplos de 0,08 (do TOTK S23): metades das imagens sempre inteiras (LARECOMP_SCALE_SNAP=0). - versionCode 49 (0.3.1-s23-b12) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
With a frame limit (30 fps) the
framepace_on()grid innvnQueuePresentTexturehas no tie to the display. Its phaseis wherever the last long frame (load, menu, map, hitch) left it, and then it stays there for minutes. When that puts
queueBufferwithin about 1.5 ms before SurfaceFlinger's latch, sub-millisecond jitter makes frames alternately makeand miss the latch: they reach the screen as 50.0 / 16.7 ms (60 Hz) or 41.7 / 25.0 ms (120 Hz) instead of 33.3 ms. The
mean stays 30 fps, so FPS counters look fine, but it is visible judder.
On a Samsung SM-X730 (Immortalis-G925 MC12, r49p1) at 60 Hz, 7 of 24 baseline windows had bursts (up to 1,398
consecutive alternating intervals in one segment). The cause was checked with a phase-sweep experiment (temporary
instrumentation moving the grid 0.5 ms every 150 presents): at 60 Hz, 150-frame blocks with a queue lead of 0.4-1.4 ms
before the vsync had burst share 0.11-0.47, any other lead 0.00-0.01. Content, Native vs Recompiled, shader compiles
and GPU load are not needed to explain it.
Change
vulkan/device.c: on Android, enableVK_GOOGLE_display_timingwhen the device advertises it (it is Android's ownswapchain layer, not a vendor feature). Presents chain
VkPresentTimesInfoGOOGLEwithdesiredPresentTime = 0, soscheduling is as before. After each present, keep the newest
actualPresentTime, the refresh period (re-queried aboutonce a second) and the median of the last 9 hand-over -> queueBuffer delays.
backend_vsync_offset()returns theshift that would put the next queueBuffer half a vsync before a vsync. It returns false (pacing exactly as today)
without valid, recent (2 s) timings, when the timings do not fit the vsync grid, or when the frame grid is not a
whole number of vsyncs (no limit, 40 fps on 60 Hz).
objects.c(grid branch offramepace_on()only): at a grid restart (after a long frame, a hitch anyway) the grid ismoved by the full shift; otherwise by 0.25 ms per frame once it is more than 0.5 ms off. Steering is capped at one
vsync per correction and then left alone until the next restart.
vulkan/async.c,nvn.h: the PRESENT request carries the hand-over time; one declaration.LARECOMP_PACE_VSYNC=0leaves the extension off and the pacer as before. No RT_ON_RESET hook is needed: a reboot ofthe game is a long frame, which restarts the grid, and the timing state ages out after 2 s.
Not touched:
desiredPresentTimescheduling, Choreographer,setFrameRate, present mode, swapchain image count, ADPF,the
g_vsync_countpath, other platforms (stub returns false).Testing
Device: Samsung SM-X730, Dimensity 9400+, Immortalis-G925 MC12 (Vulkan driver r49p1), Android with the game at 1.9.0
Great Plateau start, Native and Recompiled, 30 fps cap, scratch save. Compared against unchanged v0.2.10-beta APK.
actualPresentTimevs SurfaceFlinger actual present (60 and 120 Hz)LARECOMP_PACE_VSYNC=0Everything above was seen in game on the device; captures were reviewed, no visual change.
Limitations (please read)
41.7 / 25 ms intervals stays: mean 150-frame block share 0.175 (max 0.253; baseline pacing 0.228 / 0.480 in the same
sweep). I attribute it to the compositor side (late-shown frames were queued and GPU-ready on time), not proven on
other devices. My own bar for 120 Hz (no block above 0.16) was therefore not met; I did not relax it.
timings) is the existing pacing.
cell per mode and cache state, so the >50 ms reductions are supportive, not statistically established.
a host test seemed out of proportion. Happy to do it if you prefer.
Notes for review
(Test summary only; raw logs stay with me and can be attached on request.)
🤖 Generated with Claude Code