fix(agc): clamp biased raster depth to matching viewport bounds #28209
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28209"
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 kteal on 2026-11-29T06:29:51Z.
What
Clamp biased raster depth to the selected viewport while keeping near and far primitive clipping enabled. The native path applies when the guest enables viewport clamping, the host supports Vulkan depth clamping and independent depth clipping, and each nonempty viewport has the same clamp interval as its guest registers. A reversed viewport and different ranges across viewports are supported. Guest fragment depth exports keep their existing handling. When a wider host attachment emulates D16 with stencil, the driver also preserves the depth value rounded by its own fragment shader.
Minecraft's Vibrant Visuals writes biased depth at the far plane before generating its reflection cubemap. On main the writer stores depth outside the viewport. The subsequent sky shading consequently puts magenta into the reflection texture. The fixed-function change corrects that input and preserves the draws and the shader subgroup operations.
The pipeline and pre-raster library keys distinguish the third depth-clamp mode. The journal uses the existing one-byte slot. Existing mode values and key bytes remain valid. Hosts and draws that need a different clamp interval keep their prior path, as recorded in the debt fragment.
Tested
Windows 11, Minecraft PPSA17221, Vibrant Visuals, reflections enabled, 10 chunks. Replayed the same captured depth writer and eight startup submissions on the RTX. All 8,192 sampled values were 20.4375 on main and 1.0 with the change. The resulting 1,179,648-byte sky texture matched the independent forced-depth-1 control byte for byte. The private Creative save also rendered with reflections enabled.
In the captured world the four screen-space reflection pixel shaders are followed by deferred indirect specular. A separate diagnostic replaced only that specular shader’s neighbor-lane reads with self-lane reads. It changed 1,902,373 of 2,073,600 displayed pixels. An unmodified repeat matched exactly. The diagnostic is outside this patch.
Ran
ctest --test-dir build -R "^(agc_driver_depth_bias_per_face|agc_pipeline_journal$)" -Von main and the change on both GPUs withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer. All four tests passed on each build and adapter. The loader inserted the 1.4.363.1 validation layer, with zero VUID errors. Cases exercise positive bias, separate clipping at both planes, reversed and indexed viewport eligibility, guest clamp disable, fragment depth exports, missing host support and journal encoding.The live save and its shoreline rendered normally with a fresh shader cache. A second launch reusing that cache also rendered normally with reflections on. Two sessions with an older experimental cache showed patchy magenta geometry. Turning reflections off cleared it in the old-cache control. The original broad sky tint and the later patchy artifact have different coverage. Replaying the sky producer with the old cache, fresh cache, or disk cache disabled gave the same corrected bytes. The cause of the remaining live artifact is unconfirmed.
The additional RTX graphics-state and depth-bounds targets passed with zero VUID errors. The final overlap scan reported no direct line conflicts. I compared the PRs flagged for manual inspection, including #23553, which handles fragment shader depth exports.
JJenkx tested
faf3ae496c9eon Arch Linux with an RX 6650 XT and RADV Mesa 26.3.1. All 10 depth-bias and graphics tests passed with Vulkan validation enabled, with no skips or validation messages.Review regression
viewport_max_half_quantized_EQUALinagc_driver_d16_stencil_precision: at viewport maximum 0.5, a stored D16 depth of 32768/65535 must compare equal to the rounded fragment depth. On both the RTX 4070 Laptop GPU and Intel Iris Xe, the original PR passed 0 of 2,048 pixels with D24S8 and D32S8 backing. The fix passed all 2,048 in each configuration. The D16 suite, the three depth-bias tests and the pipeline journal passed on both GPUs with zero validation errors. Replaying the Minecraft depth and sky captures on this revision produced the same readbacks as the pictured PR revision.Minecraft reflections before and after
Both captures use the same saved camera on the RTX 4070 Laptop GPU at 1920 × 1080, with Vibrant Visuals, reflections enabled, and a 10-chunk render distance. The magenta cast across the grass, trees and clouds clears with native depth clamping. These are separate launches, so the time of night and mobs differ.
2acab7d89bba)faf3ae496c9e)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)faf3ae496c9e: AMD Radeon RX 6650 XT, RADV Mesa 26.3.1, Arch LinuxSummary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T06:40:24Z.
Review: COMMENTED
Actionable comments posted: 1
2b0b158f-5168-4e52-9d05-0fb39a371ffeReviewing files that changed from the base of the PR and between
859a238b8candfaf3ae496c.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/execution/DepthBiasPerFace.cppdocs/dev/debt/changes/agc-native-raster-viewport-clamp.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T06:49:20Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code and reported checks support merging.
What I ran
Reviewed head
faf3ae496c9ef4a7a52fa2a4deb631ef013faf4fusing the prepared diff and the pinnedrepo_read.pyreader. No commands or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Full text of
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppandcore/libs/prx/libSceAgcDriver/tests/Graphics.cppwas excluded from the review folder; relevant Vulkan feature initialization was read throughrepo_read.py, but the large graphics test file was not read. The other changed files listed as included inreview/manifest.jsonwere inspected via the diff and targeted source reads. The reported Windows and Linux test runs were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T07:13:27Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reported GPU and CTest results are author-supplied, and this review environment did not run them.
What I ran
Reviewed head
8f7c200af1398e3406653914d1255e1974416042usingrepo_read.pysearch and targeted reads. No commands or tests were run by me.Results
Findings
Blocking
None identified in the code read.
Non-blocking
None.
Not verified
The full text of
VulkanDevice.cppandtests/Graphics.cppwas excluded for size; I read only their relevant changed hunks viarepo_read.py. I also did not read the full text of the included test filesD16StencilPrecision.cppandDepthBiasPerFace.cpp. Consequently, the reported test coverage and results were not independently verified. Other than the files listed here, the reviewed changed files wereDrawDecode.cpp,Context.hpp,State.hpp,Pipeline.cpp,PipelineJournal.cpp,State.cpp, anddocs/dev/debt/changes/agc-native-raster-viewport-clamp.md.files.jsonwas unavailable in the prepared review folder.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T06:04:28Z.
Review: APPROVED
I read the diff at
8f7c200af1. Windows 11, GCC 15.2, merged intomainatcf556db18c3together with other open PRs (so not an isolated build), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validationon an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).agc_driver_d16_stencil_precision,agc_driver_depth_bias_per_faceand the 60 tests ofagc_driver_graphics_tests: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has aVUID-orSYNC-HAZARDline.main's): these don't compile withoutRasterDepthClamp, so the control only shows that.Not checked: a title.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T18:47:54Z.
Review: COMMENTED
I followed the new clamp mode from draw decoding into both pipeline keys and the journal. Both caches distinguish clipping with clamp from clamp alone, and the draw key now includes the indexed viewport bounds that decide eligibility. The focused cases cover reversed ranges and an indexed viewport that fails the matching-bounds check.
The local merge of
8f7c200af1was clean. On Linux lavapipe, the scalar-buffer, pipeline-journal, and all three per-face depth-bias cases passed on botha9cbd48cb0and the merge. Both verbose logs show Khronos validation 1.4.369 inserted with zero missing-layer orVUID-messages. The RTX replay and saved-world results come from the author's runs.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.