fix(agc): normalize unused viewport depth ranges #6535
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6535"
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?
Imported from boykopovar/AnyPS5. Originally posted by gguerra26 on 2026-10-15T19:19:40Z.
What
Balatro (PPSA21402) uses a viewport depth range of [-1, 1] for color-only draws. On Apple M1 with MoltenVK these stop at
viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted, even when there is no depth attachment and the pixel shader does not read PositionZ.Normalize the viewport endpoints only for those draws. Preserve XY coordinates, clip-space mode and depth clamping. Depth attachments, PositionZ inputs and non-finite ranges keep their existing behavior and validation. The adjustment is part of the decoded draw state, so cached draws receive the same state.
This is independent of #4650, which emulates observable depth transforms, and does not include the broader Mac changes in #6222.
Tested
agc_driver_unused_viewport_depthpasses. It also runs the existing depth-clip checks and covers PositionZ reads, attached depth, reversed ranges, in-range values, non-finite rejection and preserved XY/clipping state.git diff --checkandpython3 tools/check_conventions.py --base origin/main --head fix/agc-unused-viewport-depthpass.The reasoning follows Vulkan's viewport transform and fragment operations: the changed depth value has no consumer when neither the fragment shader nor a depth attachment observes it.
Checklist
main; no other open PR implements the same function (related #4650 and #6222 reviewed)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T19:31:14Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Graphics/include/State.hppL165core/libs/prx/libSceAgcDriver/CMakeLists.txtL1783-1785, L1803Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-15T19:33:02Z.
A Linux data point from a device without
VK_EXT_depth_range_unrestricted: an Intel Arrow Lake iGPU on Mesa 26.1 ANV (Ubuntu VM), release build, 40 s runs. Onmain44df21632, 22 catalog homebrew apps stop 0–1 s in withviewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted. With this PR merged (head 378212176):I didn't check why the last 12 still stop. I'd expect their draws to have a depth target or read PositionZ, which this PR leaves alone. One run per app and build.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T07:33:46Z.
A second title this clears on macOS: ProsperoLichess (PPSA99009, homebrew catalog), on Apple M2.
macOS 26.7.1, Apple M2, x86-64 under Rosetta, MoltenVK from the LunarG Vulkan SDK 1.4.363, Release. A local tree of
maince991f1ecwith #4627, #4630, #6124, the four macOS relinker PRs and mugurc's macOS port branches merged; this PR's head378212176applied on top, nothing else changed between the runs.agc_driver_unused_viewport_depthpasses in this tree.I didn't test #4650.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T04:58:21Z.
A check on a device without
VK_EXT_depth_range_unrestricted: Intel Arrow Lake iGPU (ANV, Mesa 26.1.6), Debian 13, kernel 6.12. I ran this PR's head (3782121769) as-is against its base (44df216321), same relinker, 60 s, no pad input. Two catalog titles that stop on the depth range there:44df216321viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestrictedSo ProsperoEden's out-of-range viewports are all the unused kind this PR normalizes. Signal Companion gets 8 s further and then reaches a draw whose depth range is in use, which this PR leaves alone (that one needs #4650). On NVIDIA, which has the extension, neither stops on the depth range.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-17T12:08:07Z.
Rebase handoff — rebased onto current
main(authorship unchanged). One conflict in the test registration: youragc_driver_unused_viewport_depthentry sits alongsidemain's neweragc_driver_msaa_dcc_state, both kept.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesmainregression (agc_driver_tessellationsegfault, #4727), not this PRTo pick it up:
Head is
be25cb2eb.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:15:13Z.
Thanks.
mainmoved again, so I rebased onto it and added one commit on your branch:CMakeLists.txt:agc_driver_unused_viewport_depthwas missing the WindowsPATHprepend forlibc, so the Windows job failed with0xc0000135(DLL not found). It is now in the sameWIN32block as the otheragc_driver_graphics_testscases.Merging once the full Build is green.