fix(agc): take 16-bit depth bias units exactly on float depth targets #24327
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24327"
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 GiannisG1 on 2026-11-20T14:13:04Z.
What
#21345 converts a constant depth bias whose
PA_SU_POLY_OFFSET_DB_FMT_CNTLunits differ from the target's by a fixed factor, and its debt entry notes that0xf0(16-bit units, 2^-16 each) on a D32F target "can be exact withVK_EXT_depth_bias_control's force-unorm representation, which is not used". This PR uses it.On a float depth attachment Vulkan's default unit is 2^(e-23) for the primitive's largest-depth exponent e, so
constant × 256equalsconstant × 2^-16only for a largest depth in [0.5, 1); at depth 0.125 the bias is a quarter of the guest's.VK_EXT_depth_bias_controlgives a constant unit instead (Vulkan-Docschapters/primsrast.adoc, "Depth Bias"):depthBiasExact: r = 2^-n, n = mantissa bits + 1 = 24 for D32F, so the constant is× 256at every depth;× 2^-16.With
VK_DYNAMIC_STATE_DEPTH_BIASthe representation is dynamic state too (chapters/pipelines.adoc), soCommandState::SetDepthBiassets it throughvkCmdSetDepthBias2EXTwith aVkDepthBiasRepresentationInfoEXT, and the tracked state includes it.vkCmdSetDepthBiasis the same asvkCmdSetDepthBias2EXTwith the format representation anddepthBiasExactfalse, so a device without the extension records what it did before. Where the extension is on and the device hasdepthBiasExact, it is requested on every depth-bias draw: the guest's units are exact, and without it a fixed-point unit may be up to twice 2^-n.The units now stay in
State(depthBiasUnits, from0x2de), and one host-side function,HostDepthBiasConstant, converts the constant for the format the device stores. That also covers a case that throws today: a 16-bit target with stencil that a device withoutD16_UNORM_S8_UINTandD24_UNORM_S8_UINT(RADV) stores asD32_SFLOAT_S8_UINTrefused any constant depth bias; with either representation it is exact, and without one it still throws. Float units on such a target need no conversion. The conversions that were exact stay as they were. On a device without the extension the only change is that float units on such a D32F_S8 target no longer throw.0xf0)× 256(exact for depth in [0.5, 1))× 256or float× 2^-16, exact; else unchanged0x1e9)× 1/× 256depthBiasExact)× 1/× 1/256/× 1Support here: the GTX 1050 Ti has force-unorm and not float, the HD 630 (ANV) float and not force-unorm, llvmpipe both.
APS5_NO_DEPTH_BIAS_FORCE_UNORMandAPS5_NO_DEPTH_BIAS_CONTROL(rows indocs/dev/ENVIRONMENT.md) select the other paths, so CI's llvmpipe runs all three.Debt: #21345's entry is still a pending fragment, and a fragment can only
changean entry of the debt file itself, so itsaddtext is updated in place (asa1aad4c914did); this PR's own fragment updates "16-bit depth with stencil".New and changed tests:
agc_driver_depth_bias_units(new,tests/execution/DepthBiasUnits.cpp): draws on a D32F target at a fixed depth with 64 units of 2^-16 and probes the stored depth with anEQUALdraw. Depth 0.75 must give 0.75 + 2^-10 on every path; 0.125 and 2^-7 must give depth + 2^-10 where a representation exists. On a failure it reports the power-of-two unit it found instead._float(APS5_NO_DEPTH_BIAS_FORCE_UNORM) and_without_control(APS5_NO_DEPTH_BIAS_CONTROL, depth 0.75 only) run the other paths; a device without the representation skips with "skipped, the device has no …".agc_graphics_profile_draw(DepthSurfaceReuse.cpp):HostDepthBiasConstantfor every units/format pair with fake device contexts, including the D32F_S8 fallback with each representation and without.agc_command_state: the representation anddepthBiasExactreachvkCmdSetDepthBias2EXT, a change of representation alone is recorded, and a non-format representation without the extension throws.agc_driver_depth_bounds_state: #21345's decode cases now check the units and the unconverted constant.Tested
Linux Mint 22.3, kernel 7.0.0-38, GCC 13.3.0, Release, under Xvfb, head on
main42f6354612(merges cleanly with0a025bd3c6). lavapipe from Mesa 26.0.8 was built from the release tarball and selected withVK_DRIVER_FILES.main's scaling, 3 runs_floatskips)_float_floatmain's scaling is this PR with the two representation lines ofHostDepthBiasConstantremoved:agc_driver_depth_bias_units(and_floatwhere float exists) fails 3/3 with64 units of 2^-16 on a D32 target at depth 0.125000 stored depth + 64 * 2^-18, expected depth + 64 * 2^-16, a quarter of the guest's bias. The depth 0.75 case and_without_controlpass.agc_graphics_profile_drawfails on the force-unorm case.agc_driver_depth_bias*,agc_command_state,agc_driver_depth_bounds_state,agc_graphics_profile_draw,agc_driver_library_keys_narrow*,agc_driver_depth_export_clamp) pass 3/3 on all four devices, andcheck_skips.pyaccepts every skip.VK_LOADER_DEBUG=layer, on the focused tests,mainand this PR, all four devices: the loader inserts the layer in every Vulkan test (7 onmain, 10 here), and there is noVUID-,SYNC-HAZARD-orUNASSIGNED-message on either side.tools/suite.py: every test once, GPU tests on the GTX 1050 Ti, the HD 630 and llvmpipe) on this PR and onmain42f6354612: the same failures. GTX none (main's run hadtitle_run, which passes 3/3 alone). HD 630 the same 9 (main's run also hadagc_driver_frame_replay_rewind_copy, intermittent, #22028). llvmpipeagc_driver_image_gather_lod(#24100),agc_driver_image_table_packed_guards(#21255) andagc_driver_scattered_runs(#21649). New skips:agc_driver_depth_bias_units_floaton the GTX;guest_video_out_hdrskipped once on llvmpipe because Xvfb had no X11 display at that moment, and passes 3/3 when rerun.check_conventions.py,check_test_registration.py,check_main_sync.py,check_compile.py,debt_fold.py --checkandgit diff --checkare clean.pr_overlap.py --branch: #18185 changes the same lines ofDepthSurfaceReuse.cpp. Its new test also callsHostDepthBiasConstantwith the old signature and expects the D32F_S8 refusal, which now applies only without a representation. #23739 adds anENVIRONMENT.mdrow next to the new ones.main), #22697 changes the same line ofCommandState::SetDepthBias, and #17899, #19697, #20315 and #23982 insert next to lines this PR changes.vkCmdSetDepthBiasfor its deferred encoding; with this PR the call isvkCmdSetDepthBias2EXTwhere the extension is enabled.Update 2026-11-25 (head
bb3d3da843): rebased ontomaind237f5d065. Two files conflicted:Pipeline.cpp: this PR's bias lines now sit next tomain's newHostDepthBoundsblock.DepthSurfaceReuse.cpp:main's stencil-plane checks are kept, and this PR'sHostBiasIschecks replace the old-signature ones.#17899 changed the same '16-bit depth with stencil' debt entry, so this PR now edits #17899's fragment (
fix-agc-d16s8-depth-quantization.md) instead of adding a second one, asdebt_fold.py --checkrequires.On this head:
agc_driver_d16_stencil_precision, passes 3/3 on the four devices.maind237f5d065run, exceptagc_driver_pm4_order_signalon the GTX: that timing check failed once under the suite's load and passes 3/3 alone (#24170 is about this check).Merge order with #18185 (
6a0957ab33): whichever of the two lands second has three things to adapt.DepthSurfaceReuse.cpp: the two PRs edit adjacent lines, this PR'sHostBiasIschecks and #18185's new "must be converted" lookups. The resolution keeps both.fix-agc-d16s8-depth-quantization.mdand moves its '16-bit depth with stencil' entry intofix-agc-d16s8-depth-copy-sampling.md, so this PR'sVK_EXT_depth_bias_controlsentence then belongs in that entry.D16DepthSampling.cppcalls the old three-argumentHostDepthBiasConstant. Git reports no conflict here; the build fails instead.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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T14:59:51Z.
Review: COMMENTED
Reviewed — comments
The change addresses the stated depth bias unit conversion; I could not complete a full review or run checks, so a formal merge decision is not justified.
What I ran
Reviewed PR head
aad98b9909be3b395e0b444326db99cd10a5bea4using the prepared diff and the pinned repository reader. No tests or other commands were run.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
I read the description, commit summary, manifest, review README, and complete diff. I inspected relevant head ranges in
VulkanDevice.cpp,State.hpp,DepthSurface.cpp,State.cpp,Recorder.cpp, andPipeline.cpp. The changed-file additions in the diff for other files were not independently read from their head versions.VulkanDevice.cppandGraphics.cppwere excluded from the review bundle because they were too large; relevant ranges fromVulkanDevice.cppwere read through the reader, but the changed ranges inGraphics.cppwere not. No tests, builds, or prechecks were run; reported test results in the PR description were not independently verified. The review bundle lists 19 changed files; this review did not independently read every changed file’s added lines.To get this to a good state
Nothing is required. Optional: complete the remaining changed-line review and run the focused checks on this head before making a formal merge decision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T22:55:17Z.
Review: COMMENTED
Reviewed — comments
The core depth bias conversion and state changes are coherent; I could not verify the full review because two changed files were excluded from the bundle.
What I ran
Reviewed prepared diff for head
bb3d3da8438f2fa7932c10d0b9d7abb4d7f1d9edand targeted source ranges viarepo_read.py. No tests were run.Results
Findings
Blocking
None verified.
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 bundle. Their relevant changed hunks were available in the diff, and targeted ranges were read for the Vulkan device setup and command-state tests. Remaining full-file contents and the other included changed files were not read. The author-reported test runs were not performed in this review.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T05:07:16Z.
Review: COMMENTED
Actionable comments posted: 1
74fef8bb-4afc-4aee-a1b5-ed1376945280Reviewing files that changed from the base of the PR and between
5ab4337794and3955111304.core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/include/State.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Resources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/State.cppcore/libs/prx/libSceAgcDriver/tests/CommandStateLog.hppcore/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_depth_bias_units_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/DepthBiasUnits.cppcore/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearHarness.hppdocs/dev/ENVIRONMENT.mddocs/dev/debt/changes/fix-agc-d16s8-depth-quantization.mddocs/dev/debt/changes/fix-agc-depth-bias-format.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-30T05:16:29Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected code blocks merging; the reported test runs support the change, but I did not run them in this review.
What I ran
Reviewed head
39551113043f66b48c4d6b729bf4fdd95cb9120a; no commands or tests were run. I inspected the prepared diff and targeted source ranges throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
VulkanDevice.cppandGraphics.cppwas excluded from the review bundle; I read their changed hunks and relevant context through the reader. I did not read every added line in those files, so approval is not justified. Other changed files read:Context.hpp,DepthSurface.hpp,Recorder.hpp,State.hpp,DepthSurface.cpp,Pipeline.cpp,Recorder.cpp,Resources.cpp,State.cpp,CommandStateLog.hpp,DepthSurfaceReuse.cpp,agc_driver_depth_bias_units_tests.cmake,DepthBiasUnits.cpp,DepthFastClearHarness.hpp,ENVIRONMENT.md, and both listed debt fragments. The PR description, commits, manifest, and complete diff were also read. No separatefiles.jsonwas available; the review inventory was checked inreview/README.mdandmanifest.json.Hardware behavior and the reported test runs were not independently confirmed.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T05:18:10Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The changed
HostDepthBiasConstantsignature leaves an existing execution test calling the removed three-argument overload, which prevents that test target from compiling.What I ran
Reviewed head
15e08bdb3cfe42e715c133ee075e20a7f8add32dthroughrepo_read.pyin the read-only review environment. I inspected the changed hunks and relevant callers; I did not run a build or tests.Results
Negative control
Not run; this review did not execute tests.
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp:143changesHostDepthBiasConstantto require aDepthBiasUnitsargument. The existing call atcore/libs/prx/libSceAgcDriver/tests/execution/D16DepthSampling.cpp:724still supplies only the format and constant, so theagc_driver_d16_depth_sampling_teststarget cannot compile. Update that caller to pass the intended units.Non-blocking
None.
Sources
Not verified
Read the changed sections of all 19 files listed under
reviewedinfiles.json. The full text ofVulkanDevice.cppandGraphics.cppwas not in the review folder; their relevant changed ranges were inspected throughrepo_read.py.files.jsonlists no excluded paths; the preparation rules omit lockfiles, minified files,dist/,build/, and.svgfiles.To get this to a good state
Pass the intended
DepthBiasUnitsvalue at theD16DepthSampling.cppcall site, then build and run theagc_driver_d16_depth_sampling_teststarget on the updated head.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T05:22:11Z.
Review: COMMENTED
Actionable comments
fe741e28-b66e-49c3-a70f-1b97015d6590Reviewing files that changed from the base of the PR and between
3955111304and15e08bdb3c.core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Resources.cppcore/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/changes/fix-agc-d16s8-depth-copy-sampling.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-12-02T06:02:07Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The default
Targetunits are converted incorrectly for D24 targets, so map them to the target’s actual depth units before merging.What I ran
Reviewed head
a4be747dead692457789fcf619dd9f93815296d8. Read the prepared diff for all 20 changed files and usedrepo_read.pyto inspect targeted head contexts inVulkanDevice.cpp,DepthSurface.cpp,State.cpp,Pipeline.cpp,Recorder.cpp, andResources.cpp.No tests or build checks were run. The author’s test results in the PR description were not independently verified.
Results
Negative control
Not run; no non-compiling negative control was available for this review.
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:4499treatsDepthBiasUnits::Targetas float units only for D32 formats. The decoder uses float units by default for every non-D16 depth format, including D24 (State.cpp:656-661). As a result, a D24 target passed withTargetis treated as 16-bit units, and the conversion at line 4502 scales its constant by 256 instead of leaving it unchanged. Preserve the target’s actual default units for D24, and cover this case in the format conversion tests.Non-blocking
None.
Sources
Not verified
The full head text of
VulkanDevice.cppandGraphics.cppwas not read; their changed hunks were inspected in the prepared diff. The other changed files were also reviewed through their diff hunks, not as complete files. Tests and the author-reported device behavior were not independently verified.To get this to a good state
Correct the
Targetunit mapping for D24 depth formats and add a regression check for the D24 conversion. Then rerun the relevant depth-bias tests on the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T03:42:52Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes at head
17695b3d29fee66c500dae74f5366c68ef9a92d8have no verified blocking defects in the depth-bias conversion and extension-gated command path.What I ran
Read-only review of the prepared diff and all 20 changed files’ relevant hunks. The two oversized files were inspected through
repo_read.pyat the pinned head. No build or tests were run; the test results in the PR description are author-reported.Results
Negative control
Not run; no source mutation or test execution was performed.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Buildability, runtime behavior, hardware behavior, and the test results reported in the PR description were not independently verified. The full bodies of
VulkanDevice.cppandGraphics.cppwere not read; their relevant changed hunks were inspected through the pinned reader. The other 18 changed files were available in the prepared review folder and their relevant changes were inspected.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T03:45:42Z.
Review: COMMENTED
Actionable comments
3d69524d-3411-4eb3-b049-995f4ad513a8Reviewing files that changed from the base of the PR and between
a4be747deaand17695b3d29.core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cppIncluded 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 ligmaSec on 2026-12-03T21:46:12Z.
Review: COMMENTED
The command-state cache now keys the bias representation as well as its three factors, so equal numbers in different representations still update Vulkan. The conversion factors agree with the specified units for exact forced UNORM and FLOAT. Please report which branches ran alongside the focused CTest count, since the float-only case can skip if that representation is unavailable. The paired depth-bias cases and capability controls are queued. Vulkan depth bias specification
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.