feat(agc): emulate a one-sided depth bounds test without the depthBounds feature #9737
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9737"
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 imellag on 2026-10-22T11:02:21Z.
What
On a device without the
depthBoundsfeature (MoltenVK has none), every draw with the depth bounds test stops withdevice does not support the depth bounds test. Stray (PPSA02100) stops there on macOS, at two full-screen draws with bounds[0, 0.000125]and[0.000125, 1], no depth test and no depth write.The depth bounds test passes a pixel when its stored depth
Zsis within[min, max]. When the draw itself neither tests nor writes depth and one bound is at the end of the range, a depth test does the same thing:minDepth = maxDepth = bound), every fragment's depth is that bound, whatever the vertices say.DB_RENDER_CONTROL.DEPTH_CLEAR_ENABLEdraws already pin the range this way.GREATER_OR_EQUALagainst the upper bound passes exactly whenmax >= Zs;LESS_OR_EQUALagainst the lower bound exactly whenmin <= Zs.ApplyDepthBoundsEmulation(Graphics/src/State.cpp) runs afterApplyDepthRemapindecodeDraw, only when the device lacksdepthBounds, and turns such a draw into a read-only depth test against one bound:<= 0:GREATER_OR_EQUALagainst the upper bound (bounds covering[0, 1]take this case too);>= 1:LESS_OR_EQUALagainst the lower bound;It throws, with its own message, for every case where this would not be exact:
(0, 1);FragCoord.zor exports depth, since its fragment depth would change;failOp) or on a failed depth test (depthFailOp), since fragments outside the bounds now reach the stencil test;VK_EXT_depth_range_unrestricted, where stored depth can be outside[0, 1]and a bound at 0 or 1 does not cover every value;[0, 1], asValidateDepthBoundsalready refuses.Devices with
depthBoundsare unchanged. The limits are a new entry indocs/dev/debt/libSceAgcDriver.md.Tested
macOS (Apple M4 Pro, macOS 27.0.1, MoltenVK 1.4.2 from Vulkan SDK 1.4.363.0, x86-64 Release under Rosetta 2).
maindoes not build on macOS, so this ran onmain+ #8658 + #9193 + #9263 + #8612 + #8477 + #9356 + #9387 (with the three fixes from #9387's review: the reviewed names,meshBarycentricPixeloff undermeshAsCompute, the test text) with this commit.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:agc_driver_graphicspasses. Its newDepthBoundsEmulationTestscheck the state each case becomes, that a device withdepthBoundsand a draw without a depth target are left alone, and each refusal.agc_driver_depth_bounds_emulation_drawpasses. It stores a known depth with one draw, then draws with depth bounds and counts the pixels that pass, in 12 cases: each bound equal to the stored depth, and one float step past it, Stray's two bounds, and[0, 1]around stored 0 and 1. On a device withdepthBoundsit runs each case through the native test as well and requires the same result.agc_driver_depth_bounds_statepasses.VUID-VkDeviceCreateInfo-pProperties-04451at device creation, which every test on this stack prints.agc_driver_depth_bounds_emulation_drawfails (stored 0.25, upper bound one step below it (emulated): 2048 of 2048 pixels passed, expected none).device does not support the depth bounds test. With it, it passes those draws and the mesh check, and stops about 70 s in at a Metal GPU hang (kIOGPUCommandBufferCallbackErrorHang) after the first mesh compute fallback work. That stop is outside this change. No frame is presented yet.Linux (Ubuntu 24.04 x86-64 container, GCC 14.2, Release, lavapipe from Mesa 25.2.8, llvmpipe LLVM 20.1.2), paired:
main8a85a5c848and this PR rebased onto it (dbda360df4), same container, same environment variables:agc_driver_graphicsandagc_driver_depth_bounds_statepass on both;agc_driver_depth_bounds_emulation_draw(12 cases) passes on the PR.depthBoundseither, so neither of these runs could compare the emulation with the native test; the NVIDIA run below does.VUID-VkDeviceCreateInfo-pNext-pNextat device creation, on both sides: Ubuntu's layer (1.3.275) does not know a structure type the device chain carries.mainprints it through the existingagc_driver_pixel_barycentric_emulation; the PR prints it once more for its new draw test.NVIDIA (run by @Lindamea1): RTX 5090, which reports
depthBounds, driver 595.99.02, Gentoo, GCC 16.2.1, Release, layer 1.4.350, head077bb434e5merged ontomain8499ea52e, same environment variables:agc_driver_depth_bounds_emulation_drawpasses with12 cases, 12 compared with the native test: every case also ran through the native depth bounds test, with the expected pixel count on both paths.agc_driver_graphicsandagc_driver_depth_bounds_statepass onmainand with the change, with no validation errors.^(agc|shader|request_serializer)under the layer (874 tests onmain, 875 with the change) and the fullctestwithout it: the same results asmainapart from the new test passing, and the same validation errors, all present onmain.tools/check_conventions.py --base upstream/mainpasses. No other open pull request implements the depth bounds test. Merging each PR thattools/pr_overlap.pylists into currentmainand this PR on top: #6146, #6612, #6639, #6804, #9412, #9533, #9717 and #9742 merge cleanly; #7893, #8395, #8538, #9020, #9335, #9387 and #9748 conflict withmainon their own and were not checked.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T15:06:29Z.
Review: DISMISSED
The emulation is carefully bounded: it only substitutes a one-sided check for draws without a depth test/write, rejects normalized depth and depth-reading/exporting pixel programs, and guards stencil failure side effects. The state tests cover these refusal boundaries, while the GPU test covers equality and adjacent-float boundary cases. I did not find a substantiated implementation defect.
Please refresh from current
mainand rerun the focused test/validation comparison on that base. This PR is based on4777caca, 54 commits behind the currentmainb7d1d47a.CONTRIBUTING.mdrequires shader/AGC changes to run the same focused tests onmainand the change usingVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1, andANYPS5_REQUIRE_VULKAN=1withctest -V, comparing VUID output. The description records detailed validation-layer runs on the change and negative controls, but not a paired run on the current main revision.Please also refresh the overlap check and record the agreed order/dependency for any confirmed shared edits. The current overlap bot comment lists #6612 (
Graphics/src/State.cpp) and #6639/#9412 (the AGC debt entry); the description instead lists #6146/#6804/#9335. Since #6612 is still open, please reconcile the current overlap list and follow the repository rule to coordinate order and updateDepends onwhen applicable.Local
git diff --checkandpython tools/check_conventions.py --base upstream/main --head upstream/pr/9737pass. I could not run Vulkan tests locally because there is no configured build and only about 649 MB free. The PR reports macOS/MoltenVK and Linux/lavapipe runs; neither device has the nativedepthBoundsfeature, so an NVIDIA/AMD comparison would add valuable coverage if available.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T03:28:33Z.
Review: CHANGES_REQUESTED
Main moved under this PR (the one-sample colour and DB_EQAA changes in
State.cpp,Graphics.cppand the CMake file); the depth bounds emulation itself is unaffected, and the head is unchanged, so the code review stands.The request still open is the one from @MarcZX10: a paired run of the focused tests with
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationon this head against currentmain. The last paired run (56c0df9795) predates main's multisample and coverage changes. Please post it forda2f6513crebased onto the currentmain:ctest -V -R 'agc_driver_(graphics|depth_bounds_state|depth_bounds_emulation_draw)'onmainand on the PR, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation;VUID-messages (the existing device-creation ones are fine; any new one must be explained).