fix(agc): accept a non-finite DB_DEPTH_CLEAR until a clear uses it #11998
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11998"
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 josealissonbr on 2026-10-27T16:15:05Z.
What
decodeDepthreadDB_DEPTH_CLEARwithreadFloat, which requires a finite value, on every draw with a depth target, whether or not anything clears. PPSA99903 leaves a non-finite value in the register after its character select, so its next depth draw threw "non-finite register" although nothing used the value.DB_DEPTH_CLEARis now decoded as its raw bits. A finite value is required only where it is used: a depth clear draw (DB_RENDER_CONTROL.DEPTH_CLEAR_ENABLE,DecodeState) and a depth fast clear (RecordClear).takePlanes, which now reports whether it took the depth plane), else from the storage image over the plane (TakeStorage, which now reports whether it took the plane, including the direct copy), else from its plane in guest memory (SyncFromMemoryof the whole plane). The console's plane is that memory, so this keeps what the title wrote there.Tests:
DepthBoundsBiasTestsdecodes infinities, a NaN and0xffffffffin a draw that clears nothing, throws for each in a depth clear draw and takes a finite one.agc_driver_depth_plane_partial_storedraws on a new surface with a NaN clear value over a guest plane of 0.75 and checks that depth tests see 0.75. The gap is indocs/dev/debt/libSceAgcDriver.md.Tested
Windows 11 Pro 26200, NVIDIA GeForce RTX 5070 (driver 616.64), MinGW GCC 15.2 Release build.
main: after the character select and skipping the intro video it threw "non-finite register" at DWORD 11 (DB_DEPTH_CLEAR), then, with only the decode change, "non-finite DB_DEPTH_CLEAR for the initial contents of a depth surface". With this change the stage loads and plays. Not retested in game after the merge with currentmain.mainmerged: the full CTest suite withANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1, 2668 of 2669 passed.agc_driver_mesh_barycentric_emulationfails ("the pixel shader did not emulate barycentrics"); it fails the same way onmaine0cd1259a, so it is not from this change.tools/vulkan_validation_gate.pyrefuses to run on Windows, so I followed the manual comparison of AGENTS.md. Every^agc_test ran onmaine0cd1259aand on this branch withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos nightly layer, commit b2b44c0, API 1.4.366, throughVK_LAYER_PATH), withctest --test-dir build -R "^agc_" -j 6 -V. Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS. Both ran 1096 tests with the sameagc_driver_mesh_barycentric_emulationfailure; the same 19 tests logged validation messages on both, with the same IDs and counts (9VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605, the rest warnings), so this change adds no new ID.mainthen gainedc547deaac(one line inSampledCacheBudget.cpp), merged here; after itagc_driver_graphics,agc_driver_depth_plane_partial_storeandagc_driver_sampled_cache_budgetpass.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 XairRrR on 2026-10-29T13:25:50Z.
Review: APPROVED
Reviewed — approved
The change turns a non-finite
DB_DEPTH_CLEARfrom a decode-time throw into a value that is only rejected where it is used. It merges cleanly onto currentmainand builds. The focused depth tests pass with no validation messages, and both new tests fail without the production change.What I ran
9b580fd8756b3367efaa27e36cd3a27903673e1amain:ec08a01d0b4219ee183eff03c533d1afffa0fb28--no-ff):e3df277ede34c0b21e186fc228f107c9e7886dc8Results
maingit diff --checkcheck_conventions.pyAll conventions checks passed.libstargetagc_driver_graphics*,agc_driver_depth*,agc_driver_htile*), merged treemainInsert instance layer "VK_LAYER_KHRONOS_validation"in all 31 tests); nowas not found but was requested by env var VK_INSTANCE_LAYERSVUID-linesmain, 0 on the merged treeagc_driver_graphics_maps_fallback7.1 s,agc_driver_graphics6.5 s; all under 30 sNew test path ran (merged tree)
Negative control
I restored
Graphics/src/DepthSurface.cppandGraphics/src/State.cppfrommain, kept the PR's test changes, and rebuilt the two test targets. Both tests fail:Then I restored the merged files and rebuilt.
Findings
Blocking
None.
I traced the paths for finite values and found no behaviour change there:
decodeDepthstill yields the same float.!created || tookcondition intakePlaneis equivalent to the old one.RecordClearguard never fires fordepthFill, becauseDepthFillValueonly returns values in [0, 1].clearDepthis not part of any equality or hash onDepthTarget(sameSurfaceignores it), so a NaN does not defeat any cache lookup. The extraGpuMutexlock inhtileDepthExpandedhappens whileDepthSurfaceViewalready holds that lock.GpuMutexTypeis re-entrant (HeldByThisThread), so this does not deadlock.htileDepthExpandedreads the low ZMASK nibble the same wayHtileFillClearsandexpandedHtileWorddo.Non-blocking
The starting contents of a new surface now depend on whether
DB_DEPTH_CLEARis finite. The new branch at DepthSurface.cpp L2168-L2174 loads the whole guest plane only when the value is not finite. The description justifies this with "the console's plane is that memory". That reasoning applies equally to a finite clear value. With a finite value, though, a new surface still starts from the clear value:WrittenUnitsreports no unit as changed whileunitGenerationis 0 (L933).I checked this on the merged tree with a temporary probe in
DepthPlanePartialStore.cpp(not kept). It used the same 0.75 guest plane andclearDepth = 1.0f. A draw at 0.8 then passedLESSon 76800 of 76800 texels, so the surface started at 1.0. With NaN, the PR's test shows it starts at 0.75. One plane, two different starting contents, chosen by the register.This does not regress anything, since the non-finite case used to throw. The debt entry only implies the finite behaviour ("a new depth surface that would start from such a value"). Please say it explicitly: with a finite
DB_DEPTH_CLEAR, a new surface without an owner or storage image still starts from the clear value rather than from guest memory. Otherwise the next reader may take the memory path for the general rule. Making the finite path load memory too would be a larger, separate change.The HTILE branch is not covered by a test. The new test (DepthPlanePartialStore.cpp L186-L190) uses a surface with no HTILE, so
htileExpandedstays at its defaulttrue. Nothing exerciseshtileDepthExpanded(L1879-L1892). That covers both outcomes: an all-0xfHTILE that should load memory, and a compressed or partly cleared HTILE that should throw. The owner path (takePlanesreturningtrue) and the storage path (TakeStoragereturningtrue) with a NaN clear are also untested.DepthFastClearHarness.hppnow has aclearDepthfield, so one or two cases there should be cheap: an expanded HTILE with NaN loads the plane, and a ZMASK 0 HTILE with NaN throws.Not verified
DB_DEPTH_CLEARon the console. The PR already records this as unmeasured.Pull request closed