Repository navigation
shim: answer the panel's latch grid to gamescope's frame-rate limit - #33
Closed
utkarshdalal wants to merge 4 commits into
Closed
utkarshdalal wants to merge 4 commits into
utkarshdalal wants to merge 4 commits into
Conversation
Contributor
Author
|
Superseded by the standalone PR on master: the gate fix is independent of the scan-out-size branch, and the gamescope-side grid export in this branch is dead code (the daemon serves one scan-out connection at a time, and gamescope's ICD is not it). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
With the FPS limiter at 60 under gamescope on a 60 Hz panel, gamescope commits ~59.4 frames/s but SurfaceFlinger shows ~56.7: about 105 double-period gaps per 30 s on the Odin 3 with Dave the Diver. At 120 Hz the same session shows every commit (59.46 shown, 59.46 committed), so the frames are lost at the latch: the limiter's release grid is free-running against the panel (the daemon stamps flip events on its own 1200 Hz timeline,
VblankTimeline), two commits land on one latch point and one is replaced.The daemon already measures the panel's latch grid from the latch stats (
vsync.rs) and pushes it to shims subscribed withCAP_VSYNC_NOTE, which the Vulkan ICD in the gamescope process is. This PR makes that grid reachable from gamescope so its limiter (GameNative/gamescope#21, patch A52) can place releases on it:libadrenotools_gamescope.so): exportsgamenative_drm_icd_latch_grid(anchor_ns, period_ns, lead_ns), which answers the latestVsyncNotethe ICD holds (the same valueslsfg::latch_grid()reads), 0 before the first note.libgndrm_shim.so): exportsgamenative_drm_latch_grid(...), the symbol gamescope binds weakly, like A51'sgamenative_drm_scanout_pitch. It resolves the ICD's getter from the already-loaded ICD (found by its mapped path, since the ICD carries noDT_SONAME;RTLD_NOLOADonly, never a load), logs once where it answered from, and returns 0 until the ICD is loaded.libgndrm_shim.so15 exports, the ICD 4.check-exports.shpasses on both.No daemon change: gamescope steers its own lead from where each commit lands on the grid, so the daemon's LSFG-only lead loop is left alone.
Verification
check-exports.shPASS for both.lsfg: panel grid period=8333us lead=5166usand the C shim found the symbol. That run also showed the grid's period is the panel's maximum rate (120 Hz) while the panel runs at 60 Hz, because the app reportsdetectMaxRefreshRateHz; snapping to that lattice puts commits on the edge of the real latch window, so the fix only works with the active rate reported. App side: utkarshdalal/GameNative PR (stacked on #2283) reports the active rate and re-reports on display changes. Device verification of the three together is pending an app build.Stacked on #32 (base branch
fix/gamescope-resolution-scanout) so the three ship in one payload.