feat(vk): add owned asynchronous presentation and queue selection #2172
Open
mikaba-eu wants to merge 33 commits from
mikaba-eu/pr/native-present-slots into main
pull from: mikaba-eu/pr/native-present-slots
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2756
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2172
Loading…
Reference in a new issue
No description provided.
Delete branch "mikaba-eu/pr/native-present-slots"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A slow external Present can stall native frame production even when another queue could submit useful work. This adds opt-in bounded native presentation with three owned source images, explicit timeline ownership and real Vulkan Present results. Implemented with GPT-6 Astra medium & xhigh.
This PR is stacked on #1541 (renderer diagnostics/capture/present-result groundwork). Until that lands, the base diff also includes its changes. The native-only scope is vk_framegen.cpp/.h, vk_replay.cpp, vk_main.cpp and their presentation/capture tests; no material tables, packet encoding or visibility changes are required.
RX_VK_ASYNC_PRESENT=1enables three owned source-image slots, bounded backpressure, ready/read-complete timeline values, resize draining and direct/interpolated mode transitions.RX_VK_PRESENT_QUEUE=2optionally uses a second queue in the graphics family; existing surface/queue fallback remains.Prior integrated Linux/NVIDIA gameplay covered normal output, helper recovery and real swapchain resize/restore. Matched same-artifact A/B/A with the corresponding external DLSS5VKLayer transport and unchanged 576x324 model workspace measured 52.37 / 62.21 / 52.63 FPS (+18.50% versus the bracketing mean). This supports the complete opt-in combination, not a standalone native gain or 120 FPS. New rebase gameplay acceptance is separate. Added buffering may increase latency.
Validation: all 380 eligible Linux source checks passed, with 14 documented platform/tool skips, across the initial full suite and corrected-environment resumed/follow-up checks. Refreshed to upstream
ddafc1f9; the native-only diff can be reviewed against the renderer prerequisite. All runtime options remain off by default. External layer changes belong to bmitch87/DLSS5VKLayer and are not vendored here.The final isolated Linux renderer also compiled and linked successfully (60 seconds, zero compilation failures).
The final source includes upstream
2e62a977; its release-only changes passed both affected release/update checks.The external transport counterpart is DLSS5VKLayer #39.
Heads-up: this conflicts with main now. Could you rebase onto main and resolve the conflicts? Thanks!
The native-present part is careful work. I read it in isolation: #1541's head
131b0a34against this PR's head is 20 files, +761. Each slot has its own timeline, and the values are ordered so no submit ever waits on a value that hasn't been submitted yet. That matters, becausepresent_image's own comment warns that this has hung the queue before. Here it holds:submit_recordingskips batching and flushes before the handoff, the worker only gets the job after that submit, and the replay only reuses a slot once the worker has submitted its read orpresent_async_release. A resize drains and idles before images are replaced. The changed tests are updated rather than loosened, andtest_present_device_lossis actually stricter now. At the PR's head,async_present,present_queue_selection,present_device_loss,present_clock_epoch,present_aspectandpresent_semaphorespass locally. In its current shape, though, this can't be merged:blocking: the PR is #1541 plus this feature. #1541 is still open, so this diff is 79 files and +3,365 lines covering renderer CPU work, stage traces, thread affinity, guest-import changes in
vk_memory.cppand the analysis scripts. Merging this would merge #1541 without its own review. CONTRIBUTING asks for one topic per PR. Please let #1541 land (or be dropped) first, then rebase so this PR's diff is the native-present part alone. I reviewed only that part here.blocking: as hckrman101 said, it conflicts with main in
gpu/vk/vk_draw.cpp,vk_main.cpp,vk_memory.cpp,vk_replay.cpp,vk_shader.cpp,vk_texture.cpp,tests/present_geometry_trace_test.cpp,tests/test_antilag.pyandtests/test_present_aspect.py. Most of that comes from the #1541 part, so the rebase above should shrink it.should fix,
gpu/vk/vk_replay.cpp:3824:if (res != VK_SUCCESS) device_lost();is inpresent_imagefor every present, not only the async ones. Today, for every player, an out-of-memory or other non-device-lost submit failure becomes the device-lost report and exit. The reasoning may be right (the frame fence was already reset), but it contradicts "all runtime options remain off by default". It's a behaviour change for all hardware tiers, so it deserves its own small PR, or at least a line in the description and indocs/design.md's present notes. The== VK_ERROR_DEVICE_LOSTline just above it becomes redundant.should fix (docs):
RX_VK_ASYNC_PRESENT,RX_VK_ASYNC_PRESENT_LOGand the newRX_VK_PRESENT_QUEUE=2aren't in the switch table indocs/development.md, which is where CONTRIBUTING asks new switches to be documented. Neither isRX_VK_PRESENT_QUEUEitself.NATIVE_PRESENT_IMPLEMENTATION.mdat the repository root reads like design notes; it belongs ingpu/vk/VULKAN.mdor underdocs/.question (testing): the only measured gain is with the external DLSS5VKLayer, and the description says itself that this "supports the complete opt-in combination, not a standalone native gain". Gameplay after the rebase is still pending, and only Linux/NVIDIA was run. Since the switch is off by default it can't regress anyone who doesn't set it. Still, before merge it would help to have one run of
RX_VK_ASYNC_PRESENT=1without the layer, on NVIDIA and on an AMD card and ideally on Windows, showing frame pacing and latency against the direct path. That lets players who try the switch know what to expect.About 2,600 of the ~3,365 lines are #1541's, which is still open and conflicting, so this can't be reviewed or merged on its own until it's rebased onto that. The native-present part (20 files, +761) has sound synchronization: odd/even timeline values per slot, captures flushed before handoff, early returns releasing the slot, and a resize draining the present thread and idling before teardown.
Two things for everyone even with the switches off:
vk_replay.cpp:3824addsif (res != VK_SUCCESS) device_lost();to every present's submit, so out-of-memory and other errors exit through the device-lost path.RX_VK_PRESENT_QUEUE=2silently does nothing with a single-queue graphics family (vk_main.cpp:301), which is likely RADV and much of Intel. Please log it.Also: the switches aren't in
docs/development.md, and the design notes file sits at the repo root.