fix(agc): scale a depth bias constant to the target depth format #21345
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21345"
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 relativespace2K on 2026-11-16T05:25:47Z.
What
The AGC depth-bias format register (
0x2de) selects 16-bit (0xf0) or float (0x1e9) bias units.decodeDepthBiasrejected a draw when the selected units differed from the target depth format. It now scales the front and back constant factors by 256 (16-bit units on a float target) or 1/256 (float units on a 16-bit target) instead of throwing; the slope factor is already divided by 16. The new case intests/Graphics.cppcovers the four format pairs, including 16-bit units on a D16 target.The fixed factor is an approximation for the float-unit case:
0x1e9is the float encoding, so on a D16 target the exact factor depends on the primitive's largest-depth exponent (2^(e-7)); 1/256 is exact only for a largest depth in [0.5, 1).0xf0on a D32F target can be exact withVK_EXT_depth_bias_control's force-unorm representation, which is not used. The gap is recorded indocs/dev/debt/changes/fix-agc-depth-bias-format.md.Tested
Windows 11 22621, AMD RX 6800 XT (RDNA2, driver 26.10.1), Ryzen 5 5600, MinGW-w64 GCC 15.2.0.
agc_driver_graphicswithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1: 1/1 passed, 0VUID-lines. This test validates decoded state on the CPU and creates no Vulkan instance, so the validation layer has nothing to insert.mainaborts at about 90 s withdepth bias in units other than the depth format (register 0x2de = 0x000001e9). With this change the village scene runs; 300 s stable with no crash.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)0x2de = 0x1e9/D16 stop)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T05:37:43Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
094fc0db345895ae470edefefa5e5a8994e91618using the prepared diff andrepo_read.pyfor targeted source reads. No tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The changed implementation file was read in full around the modified function. The added test lines were read; the rest of the changed test file was not read. No tests, build, physical console run, or hardware behavior were verified. The author reports Windows 11 and AMD RX 6800 XT testing in the PR description; those runs were not independently verified. Excluded files: none (
files.jsonwas unavailable, and the manifest lists both changed files, with the test file's full text excluded from the review folder).To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T06:48:18Z.
Review: APPROVED
Reviewed — looks good
The depth bias unit conversion and its CPU decode coverage are consistent with the stated goal at head
a4288d774c7a06d27f14b3c0c8655c73ddeeeb82; no checks were run in this review.What I ran
Read the prepared description, commits, manifest, diff, changed State.cpp context, the changed test context, and Pipeline.cpp depth bias call sites through
repo_read.py. No test commands were run. The author reports a Windows test run in the PR description; it was not run by this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full test file was not read; only lines 3388–3475, including the changed test, were inspected.
files.jsonwas not available in the prepared review folder, so exclusions beyond the manifest were not verified. No build, test, GPU, or console run was performed. The PR description reports Windows 11 testing and a 300-second game run; those results were not independently confirmed.Files read:
description.md,commits.md,manifest.json,diff.patch,State.cpp,Graphics.cpplines 3388–3475, andPipeline.cpplines 940–985 and 996–1025. Excluded by the manifest: the remainder ofGraphics.cpp, which was too large for the review folder.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by GRG-DA on 2026-11-16T16:04:54Z.
Review: COMMENTED
Checked the fixed direction against the four format pairs:
0x1e9)0x1e9)0xf0)0xf0)The first three are covered by the new cases. The fourth — a D16 target with
0x2de = 0xf0, the both-16 combination — is not, and it is the case that would catch a regression where thebias16 == d16shortcut is lost. Could you add it next tod16Bias? It should leave the constant at4.0f, with the same slope and clamp assertions.The direction now matches the units: a 16-bit-unit constant on D24 is
c * 2^-16 = (c * 256) * 2^-24, and a 24-bit-unit constant on D16 isc * 2^-24 = (c / 256) * 2^-16. Nothing else in the diff looked wrong.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T16:33:35Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the tests were not run in this review, and the documented fixed scaling approximation remains a known limitation.
What I ran
Reviewed head
1309320bc454e750f7805dbb3a53766fb383a3a5using the prepared diff andrepo_read.pysource reads. No tests or build commands were run.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:587uses a fixed1/256conversion for float-unit bias on D16. The PR documents that the exact conversion depends on the primitive’s largest-depth exponent; console equivalence remains unmeasured. Consider follow-up work for an exact representation where supported.Not verified
No build, automated test, or game run was performed. The description’s Windows and Witcher 3 results are author-reported.
core/libs/prx/libSceAgcDriver/tests/Graphics.cppwas excluded from the review folder, but its changed lines were read throughrepo_read.py. No files listed in the changed-file manifest were left unread; no additional files were excluded by rule.To get this to a good state
Nothing is required. Optional: address the documented depth-dependent conversion approximation in follow-up work.