fix(agc): sample a depth surface's stencil plane through an R8_UNORM view #5781
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5781"
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 moong15 on 2026-10-14T10:26:35Z.
What
A title can sample the stencil plane of a depth surface through an 8-bit UNORM texture (guest format 1,
R8_UNORM). Vulkan cannot view a stencil aspect as UNORM, soDepthSurface::Sampledthrew for it; onlyR8_UINTviews of the stencil plane were supported.This adds that case for a full-size, single-level, single-slice view (the same shape the existing
R8_UINTpath accepts):vkCmdCopyImageToBuffer), then from the buffer into anR8_UNORMimage of the surface's extent (vkCmdCopyBufferToImage). Stencil bytes stay unchanged, so the shader readss / 255, as on the console.writtenchanged), or when the surface is the depth target currently bound for drawing. A copy taken while the surface is bound is not reused after it is unbound, as for the existing depth plane copies (slice == drawnDepth ? 0 : written). A second sample with no write in between reuses it.Removed error, from Stellar Blade (PPSA13197 v01.141), during the first gameplay area:
Overlap check
No open or merged PR samples the stencil plane as UNORM. Searched open PRs and PRs merged since 2026-10-01 for stencil,
R8_UNORM,DepthSurface,Sampled:Sampledbut still expectR8_UINTfor the stencil plane. #1368 changes the same function, so whichever lands second needs a small rebase.planeSurfacereturns, and a surface rebound after taking another pairing's planes bumpswritten, so the copy is refreshed.R8_UNORMfor stencil storage, not sampling.Tested
TestStencilUnormViewintests/DepthSurfaceReuse.cpp(part ofagc_driver_graphics_tests). It checks that:R8_UINTview still samples without a copy;R8_UNORMview samples anR8_UNORMimage filled from the stencil aspect of the depth image;sampling the stencil plane of depth surface 0x74000000 (320x180, vk format 130) as a 320x180 texture of guest format 1 (vk 9) ... is not implemented). With it,agc_driver_graphicspasses.ctest(Release, all tests): 1140 of 1145 passed, 11 skipped. The 5 failures also fail onmainon this machine without this change:agc_driver_division_output_modifiers,agc_driver_division_result_modifiers,agc_driver_f64_conversionsandagc_driver_f64_transcendentalcrash inside the AMD Vulkan driver, andagc_driver_layered_volume_vertex_no_gplfails (checked 3 times with and 3 times without this change).tools/check_conventions.py --base origin/main: all checks passedR8_UNORMview of the stencil plane was created 3 times with no driver failure, and the run reached the first combat tutorial prompt (about 60k log lines, against about 57k before).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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-15T07:06:22Z.
RIDE 4 (PPSA01599, UE4) stops at this on current
main(d92a8dad3), about 57 s in:On
mainfrom 2026-10-11 the same draws were skipped ([gpu] skipped draw: ... sampling the stencil plane ...) and the title went on; now the throw ends the process.With this PR's commit on
maind92a8dad3, the stop is gone in three runs, with no stencil-plane refusal at all. In the run without host imports (see the next paragraph), the title reaches a race about 230 to 275 s in (Tsukuba with the YZF-R6, AI agents and the replay buffer) and runs to the 360 s limit. Only main's version oftests/DepthSurfaceReuse.cppwas used for this build, because that file conflicts withmain. The rest of the commit applies cleanly.The other two runs stopped at 117 and 140 s with
amdgpu: Not enough memory for command submission!andVK_ERROR_DEVICE_LOST. The same error hit a Kena run today on a build without this PR, and the run withAPS5_NO_HOST_IMPORT=1has none, so I don't attribute it to this change. This PR adds one surface-sizedR8_UNORMimage and staging buffer per depth surface.Linux (Arch, kernel 7.2.9), RX 9070 XT (RADV, Mesa 26.2.4), GCC Release; a local pad-script commit replays timed presses (input only).
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-15T08:52:41Z.
007 First Light (PPSA11386) stops at frame 186 with this PR's error, on
maind92a8dad3plus #5799 and local commits (input scripting, diagnostics, a workaround for an earlier #5461 throw; none touch the depth surface code):sampling the stencil plane of depth surface (1472x828, vk format 130) as a 1472x828 texture of guest format 1 (vk 9), tile mode 7, dimension 1, levels 0-0, slice 0 is not implementedWith 2901df261 cherry-picked onto that stack (by then also carrying local shader-table and clip-distance commits), 007 gets past frame 186 with no stencil-plane error, through the menu and Resume, and into the level load, where it stops at frame 1188 with an unrelated error:
registered program refers to an incompatible shader binary type.tests/DepthSurfaceReuse.cppconflicts, againstd92a8dad3and against721db55dc: main's and this PR's test globals were added at the same place, and keeping both builds.DepthSurface.cppmerges cleanly.Linux (CachyOS, kernel 7.2.10), RTX 3080 (NVIDIA 615.78.08), GCC 16.2.1, Release.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:09:36Z.
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/tests/DepthSurfaceReuse.cppL45Some 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/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T12:56:28Z.
Checked the R8_UNORM stencil-plane copy against current
main. It conflicted inDepthSurface.cppandDepthSurfaceReuse.cpp(SampledAccepts, native multisample sampling), so I rebased it and added what the new structure needs:UnormStencilView(), accepted inSampledAccepts, so the retire check inDepthSurfaceTexturedoesn't treat the R8_UNORM view as unaccepted and retire the surface throughOverwrittenInMemory.drawndefaults tofalseinSampled; the native multisample path never reaches the stencil copy (stencil is rejected there).agc_driver_graphicspasses, and fails without theDepthSurface.cppchange. The libSceAgcDriver ctest scope is green exceptagc_driver_tessellation(SEGFAULT, also reported on main in #4683). The reports from @alfalfa-star (RIDE 4) and @SleglJan (007 First Light, gets past frame 186) match the fix. Merging once CI is green.