fix(agc): store D16 depth with stencil as D24 or D32 where the device lacks it #3846
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3846"
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 tv7 on 2026-10-11T17:53:33Z.
What
A 16-bit depth target with stencil decodes to
VK_FORMAT_D16_UNORM_S8_UINT(State.cpp,zFormat == 1with stencil). NVIDIA devices do not offer that format as a depth/stencil attachment, soDepthSurfacethrewdepth/stencil format 128 cannot be an attachment on this device.The depth surface lives only on the host: it is cleared at creation and sampled through views, never copied from or to guest memory. So the host image can use a wider format:
HostDepthFormat(context, format): forD16_UNORM_S8_UINTit returns the first ofD16_UNORM_S8_UINT,D24_UNORM_S8_UINT,D32_SFLOAT_S8_UINTthat the device can attach and sample (cached per physical device). Every other format is returned unchanged.DepthSurfacecreates its image, view and sampled textures with it, and the pipeline uses it for the render pass attachment, the dynamic rendering formats and theBegindepth format.R16_UNORMor 16 depth bits) of the plane, the depth-bias units check indecodeDepthBias, and the pipeline keys.HostDepthBiasConstantscales it by 256 for D24 storage. For D32 float storage the unit depends on the depth value, so a non-zero constant there throws (not implemented). The slope factor needs no change.Tested
Windows 11, RTX 3070 (no
D16_UNORM_S8_UINTattachment support), GCC 15.2.0 UCRT, Release, on maina11c8f7f7.agc_driver_graphics(DepthSurfaceReuse.cpp,TestD16StencilFallback, mocked format properties): a device with D16S8 keeps it and its bias; a device without it creates the surface as D24S8, its R16 depth view and R8 stencil view still sample, and a bias of 2 becomes 512; a device with only D32S8 uses it, and a constant bias there throws.guest_kernel_sys,windows_exceptions,guest_filesystem,agc_driver_emulated_color_compare) fail the same way on main on this machine.agc_driver_prepared_shaders_debugfailed once under-j8and once in 3 runs alone. It then passed 6/6 here and 6/6 on main. It also failed once under-j8today on a branch that only changesApr.cpp, so it looks like an existing intermittent failure.tools/check_conventions.pypasses.buffer attributes are in use by a pending flip).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T22:09:28Z.
Checked: every use of the depth format (image, view, sampled textures, render pass, dynamic rendering,
Begin, depth bias in all three paths); guest-side decisions (16-bit views, bias units check, pipeline keys) correctly keep the guest format. The bias scale (2^-16 → 2^-24 = x256) is right, and the D32 constant bias throws instead of guessing.agc_driver_graphicspasses with the new case, and the case does not build without the change.Added one commit: a TechnicalDebt line under Functional for the D24/D32 precision difference and the D32 bias throw (checklist: unverified choices get a line). Merging once CI is green.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T08:24:20Z.
Conflicts with main in
DepthSurface.cppsince #2169: it addedSampleLocationsCompatibleDepth(context, target.format, target.samples)just aboveinfo.formatin theDepthSurfaceconstructor. Please rebase; that call checks the image being created, so it should takehostFormattoo.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T13:09:55Z.
Rebase handoff — rebased onto current
main, authorship unchanged (both commits).Two conflicts, both resolved: (1)
DepthSurface.cpp— main addedSampleLocationsCompatibleDepthwhere this PR addsHostDepthFormat/HostDepthBiasConstant; kept both, independent functions. (2)TechnicalDebt.md— union, both entries kept.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV — a device that has native D16_UNORM_S8_UINT, so this PR's fallback path is not exercised here, only that nothing regresses):tools/check_conventions.py --base origin/mainpassesTo pick it up:
Head is
042ff1dff.Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-12T17:20:35Z.
Took @blawesom's rebase (thanks!) and rebased it on main
2a5eca11c. Per @oneandonlydean:SampleLocationsCompatibleDepthnow gets the host format, both in theDepthSurfaceconstructor (hostFormat) and inValidateSampleLocations(HostDepthFormat(context, state.depth->format)), so the pipeline and the image ask about the same format (c2160f0e8). Windows/MinGW: 973/973.Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-12T19:14:54Z.
Rebased on main
d53960612(574d7ec44). The only conflict wasdocs/dev/TechnicalDebt.mdafter342a8c459: the D16 stencil entry now sits indocs/dev/debt/libSceAgcDriver.mdunder Functional (link depth adjusted). This also undoes a join from the earlier union, where the entry had run into the next line. Windows/MinGW: 995/995.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T19:26:32Z.
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/DepthSurface.hppL28core/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cppL8-9, L33-35Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T20:16:02Z.
Checked the new head:
SampleLocationsCompatibleDepthnow gets the host depth format in theDepthSurfaceconstructor and inValidateSampleLocations, as @oneandonlydean asked, so the pipeline and the image query the same format. The debt entry indocs/dev/debt/libSceAgcDriver.mdis correct after the move.agc_driver_graphicspasses with the D16/D24/D32 cases; libSceAgcDriver ctest 452/452.Added one commit: dropped the duplicated
DepthSurface.hppinclude inPipeline.cpp. Merging once CI is green.