fix(agc): sample a depth surface over an HTILE fill as its clear depth #28566
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28566"
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 zeezey on 2026-12-01T20:26:54Z.
What
A single-sample depth surface sampled as a texture carries its TC-compatible HTILE address in the T# metadata field (
dccAddress).textureClearKeysread those HTILE words as DCC keys. A cleared HTILE word (0xfffc0000, or0xfffffff0with a depth-only HTILE) is not byte-uniform, so the scan answered "Mixed", logged "has Mixed DCC keys ... its texels are read as stored" and read the depth plane as stored. When the depth was cleared through HTILE alone and no depth target was bound over it afterwards, the plane was never written, so the sampler read stale memory instead of the clear depth.SampledHtileClear(DepthSurface.cpp) now answers for a texture of format R32 float or R16 unorm whose metadata address is covered by an HTILE fill that no depth target has taken yet (clearedHtiles). Once the fill covers it, a texture of more than one layer (a 2D or 1D array with several layers, a cube, a volume), one of more than one mip level, a view of any dimension that starts after layer 0 (baseArray != 0, including ak2Dview of a later layer, whichrefreshForViewmakes withRefreshLayers(baseArray, 1), and ak1Done), or a multisampled texture (samples != 1) is not answered (unknown), because only the HTILE of layer 0 at level 0 is read, so it takes the DCC key path as before this change; an uncovered one keeps that path too. With the GPU lock held it publishes overlapping unit shadows first (asreadDccKeysdoes; without the lock a shadowed range proves nothing) and syncs a pending write over the words; it then reads them withhtileProvesClear(the multisample path's rule), one HTILE layout held across the whole range:Clear0000/Clear1111keys);0xfffc000f, mixed words or mixed layouts, unreadable memory): the texels are read as stored, with no "mixed DCC keys" line.A clear (zero or one) is proved only when the caller holds the GPU lock: a pending recorder write cannot be checked without it, and the lock is checked before the HTILE words are read, so an unlocked lookup reads no HTILE words. An unlocked first lookup of a covered, proved-clear texture reads as stored, without the mixed-keys line, until the locked lookup proves the clear. After the words are read, the covering fill is looked up again under the surface lock, and a fill consumed in between gives no proof (the key path answers). A count of registered fills lets a lookup with none registered return before taking that lock.
Any other texture, and any metadata address not covered by an unconsumed HTILE fill, takes the DCC key path as before.
ProvedClearKeysdoes not cache a proof for such a texture, because the fill registry changes without a guest write. It converts the first sample to keys directly, so every lookup of a covered texture reads its HTILE words again. When the answer is unknown, it passes that answer down to the key scan instead of askingSampledHtileCleara second time, so a fill registered between two asks cannot leave HTILE keys cached in the proof that nothing invalidates.Reported by lgqdaxia on discussion #27523: two mixed-DCC reports (1280x720 and 1024x4096) repeated the bytes
0f 00 fc ff, and a 1024x1024 one repeatedf0 ff ff ff. This change readsf0 ff ff ff(a depth-only clear word) as the clear depth when the fill was not bound as a depth target.0f 00 fc ffis the expanded word below: it is read as stored, as before, without the mixed-keys line.The word
0xfffc000fis an expanded word (expandedHtileWordwrites it for a depth-only HTILE): the low nibble 0xf marks the plane as holding its texels, so reading as stored is right for it. The fix keeps that.Debt fragment:
docs/dev/debt/changes/sampled-depth-htile-clear.md(partially cleared HTILE reads as stored; the console's texture unit result for cleared tiles is inferred, not measured).Tested
Windows: MinGW, Release, Vulkan validation layer on; main
1891347284. At the final head086b1c62db(it sends a view of a later layer of any dimension and a multisampled texture to the DCC key path, and passes the firstSampledHtileClearanswer down inProvedClearKeys; earlier commits check the GPU lock before the HTILE span is read, treat a 1D array like a 2D array, send layered and multi-level textures to the DCC key path, run the proof tests under the lock and drop the code comments):agc_driver_graphics(holdshtileDepthSampleKeysTests, with an unlocked caller, a mixed-layout range, a single-layer array, a four-layer array, a single-layer, a four-layer and a later-layer 1D array, a 2D and a 1D view of a later layer (baseArray = 2), a multisampled texture (samples = 4), a cube, an uncovered cube and array, a multi-level texture, a single-layer view of a later layer and a proved lookup): 1 of 1 run passed. A layered, later-layer, multisampled or multi-level texture over a covered fill reads what the DCC key path gives: stored for the cleared HTILE words (not byte-uniform), and the clear keys only when the DCC bytes are themselves uniform (all-zero words in the cube, multi-level and multisampled cases). Deliberate breaks ofSampledHtileCleareach make it fail: removingresource.samples != 1u(the multisampled case), and putting back the old guard that checksbaseArrayonly for the two array types (thek2Dandk1Dlater-layer cases). Earlier breaks, at26f0e56377: accepting a range when any one word proves the clear instead of all, removing the unlocked early return, removingk1DArrayfrom the layer guard, and removing the layer guard or the multi-level guard. The original check fails in 5 of 5 runs on main with the test commit alone. There is no deliberate break for the double call inProvedClearKeys: no host test can register a fill between the two asks.- Validation gate at086b1c62db(gate.sh, NVIDIA, repeat 5, the same 6 tests ashtile-nv8; baseline main1891347284):GATE htile-nv9: exit 0 (complete), 10 of 10 iterations clean (baseline 5/5, candidate 5/5; repeat 5), 6 tests, 60 test runs, failed/skipped 0, new diagnostics 0, layer missing 0(the one diagnostic,Undefined-Value-ShaderOutputNotConsumed-DynamicRenderingx40, is the same on both sides).At
6784c450fe(an unlocked caller of a covered, proved clear gets stored instead of unknown)agc_driver_graphicspassed 1 of 1 and the gate passed ashtile-nv6: 10 of 10 clean, same diagnostic x40 on both sides.At the previous head
9cf4bec221:agc_driver_graphics: 5 of 5 runs passed, VUID 0, SYNC-HAZARD 0.--parallel 4): 221 passed, VUID 0, SYNC-HAZARD 0; 4 skipped (3agc_driver_msaa_dcc_compared_import_*,agc_driver_native_depth_driver_queued_fill).agc_driver_depth_fewer_samplesfails, and it also fails in the Linux complete run of main1b8f79a5b5, so it is pre-existing.26f0e56377(gate.sh, NVIDIA, repeat 5, 6 tests:agc_driver_d16_depth_sampling,agc_driver_dcc_keys_first_write,agc_driver_depth_plane_sampling,agc_driver_sampled_cache_budget,agc_driver_sampled_clear_keys,agc_driver_staged_clear_sampled_read):GATE htile-nv8: exit 0 (complete), 10 of 10 iterations clean (baseline 5/5, candidate 5/5; repeat 5), 6 tests, 60 test runs, failed/skipped 0, new diagnostics 0, layer missing 0(the one diagnostic,Undefined-Value-ShaderOutputNotConsumed-DynamicRenderingx40 inagc_driver_depth_plane_sampling, is the same on both sides).agc_driver_graphicsandagc_graphics_profile_draware left out of the gate: the first does not create a Vulkan device, the second exceeds the gate's 30 s timeout.guest_video_out_hdr,windows_guest_main_stack_entry), both also failing on main; 0 new.Not run: the complete suites at the final head, the Linux complete suite, and at
086b1c62dband26f0e56377the 221-test area and the Linux run (they ran at9cf4bec221). There is no test for the secondSampledHtileClearask removed fromProvedClearKeys(a fill cannot be registered between the two asks from a host test). There is no test for an R16 unorm depth texture, for the fill entry being consumed between the first lookup and the result (nothing splits the two lookups, so a host test cannot interleave them), for the unit-shadow publish (a host test cannot create a shadow), or for the speed of the early return (not measured).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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T20:39:19Z.
Review: COMMENTED
🏛️ Architecture findings (2)
Advisory architecture findings (2)
💬 Code review
Actionable comments posted (2)
ce954159-8df8-4be2-a2c3-93a35ed4c176Reviewing files that changed from the base of the PR and between
6a1b7a1920andc72da098f8.core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DccMetadata.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/TextureFormat.cppdocs/dev/debt/changes/sampled-depth-htile-clear.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 coderabbitai[bot] on 2026-12-01T23:13:36Z.
Review: COMMENTED
🏛️ Architecture findings (1)
Advisory architecture findings (1)
💬 Code review
Actionable comments posted (3)
0af17bc7-18a0-41fe-996e-2a64df6bed62Reviewing files that changed from the base of the PR and between
c72da098f8and71af64c972.core/libs/prx/libSceAgcDriver/Graphics/src/DccMetadata.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/TextureFormat.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T00:49:20Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
71af64c9721a1dadf02cdc602436a953955f3f94using the prepared diff and manifest, andrepo_read.pyfor targeted source context. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The complete suites were not run at the final head. Console texture-unit behavior is inferred, as documented by the author. All files listed under
reviewedinfiles.jsonwere reviewed;files.jsonlists no excluded files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T02:31:50Z.
Review: COMMENTED
Actionable comments
d6789471-c611-4575-be3c-0edcbe0ad473Reviewing files that changed from the base of the PR and between
71af64c972and8feb23b6a2.core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/TextureFormat.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 MarcZX10 on 2026-12-02T03:14:40Z.
Review: COMMENTED
Reviewed — no blocking findings
No blocking defect is established in the inspected changes; optional test coverage would make the new behavior easier to verify.
What I ran
Reviewed head
8feb23b6a2374ca3c4355209527cf4ee9af692edusingrepo_read.pyand the prepared diff. No tests or builds were run.The diff for all five changed files was read. Targeted source ranges were read in
DepthSurface.cppandDccMetadata.cpp; related definitions were read inGuestTextureResource.hpp. No files were excluded by the manifest.Results
Negative control
A negative control could not be run because no tests were run.
Findings
Blocking
None established in the inspected changes.
Non-blocking
Sources
Not verified
The reported Windows, Linux, and validation-gate test results were supplied in the PR description and were not independently run. Full file contents were not read; review focused on the prepared diff and targeted source ranges. Console texture-unit behavior is described by the author as inferred, not measured.
To get this to a good state
Nothing is required. Optional: add targeted coverage for the R16 UNORM path, shadow publication, and fill consumption.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T06:56:47Z.
Review: COMMENTED
Actionable comments
f12194f4-83d1-4b28-97e0-53da627c91a6Reviewing files that changed from the base of the PR and between
8feb23b6a2and6784c450fe.core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/TextureFormat.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T07:00:22Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: exclude layered
k1DArraytextures from HTILE clear proofs.What I ran
Reviewed head
6784c450fe858ef301d8901aca68b3125b8d6fb6. I usedrepo_read.pyto inspect the prepared diff and targeted source ranges; no tests or builds were run.Results
Negative control
Not run; no test was run or modified during this review.
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:5190— The layer guard excludesk2DArray, cubes, and volumes, but notk1DArray. The sampled depth path supportsk1DArrayresources (including depth-comparison views), and those resources can expose multiple layers. For a covered HTILE fill, this can therefore prove a clear from the inspected HTILE range and apply that clear key to the whole layered texture, causing layers beyond the proved range to sample as the clear value instead of their stored texels. Treatk1DArrayas layered here and add coverage for a multi-layer depth array. Changed-line permalink Depth-array sampling pathNon-blocking
None.
Sources
The review covered all five files listed as reviewed in
files.json:DepthSurface.hpp,DccMetadata.cpp,DepthSurface.cpp,TextureFormat.cpp, andsampled-depth-htile-clear.md.files.jsonlists no excluded files.Not verified
No tests, builds, complete suites, or console behavior were run or independently confirmed. The PR description reports test results, but they were not run during this review.
To get this to a good state
Exclude
k1DArrayresources from this HTILE clear proof and add a multi-layer depth-array regression test. Review the new head for the same issue.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T09:16:17Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes at head
086b1c62dba5cead26226bc24ddd46344b4029dcrestrict HTILE clear proofs to covered, single-sample, single-layer, single-level depth textures and preserve the DCC key path otherwise.What I ran
Read the prepared diff and manifest, then inspected the changed hunks and relevant source context with
repo_read.pyat the pinned head. I did not run tests or builds. The description reports Windows and NVIDIA validation runs; those are author-reported, not runs I performed.Results
Negative control
Not run. The reported deliberate-break checks were supplied by the author; I did not run them.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The five files listed under
reviewedinmanifest.jsonwere inspected:DepthSurface.hpp,DccMetadata.cpp,DepthSurface.cpp,TextureFormat.cpp, andsampled-depth-htile-clear.md.files.jsonlists no excluded files. Unchanged portions outside the relevant hunks and callers were not inspected. I did not verify the author-reported runs, run the complete suites at this head, test on a physical PS5, or test R16 unorm behavior. The debt note says the console texture-unit behavior is inferred rather than measured.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T09:20:46Z.
Review: COMMENTED
Actionable comments
86ecb31e-9d1c-4f2a-bb57-d0d51c83f42dReviewing files that changed from the base of the PR and between
6784c450feand086b1c62db.core/libs/prx/libSceAgcDriver/Graphics/src/DccMetadata.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/TextureFormat.cppdocs/dev/debt/changes/sampled-depth-htile-clear.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:23:58Z.
Review: COMMENTED
I ran
agc_driver_graphics,agc_driver_native_depth_clears, andagc_driver_gcn_scalar_buffer_baseon the main baseline (96401c8077) and the patch. All three passed on both. The patch’s graphics cases distinguish a proved depth clear from the DCC path for layered, cube, multisampled, and multi-level views.Both runs used Linux Mesa lavapipe with Vulkan required, the shader cache disabled, and Khronos validation 1.4.369. Both logs show the loader inserting the layer and contain no VUIDs.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T10:40:23Z.
Review: APPROVED
I read the diff at
086b1c62db. Windows 11, GCC 15.2, merged intomainatb97867d3ce6together with other open PRs (so not an isolated build), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validationon an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).agc_driver_graphics_tests: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has aVUID-orSYNC-HAZARDline.agc_driver_graphicsfails: "an HTILE fill to the clear depth 1.0 (stencil in HTILE) must sample as 1.0".Not checked: a title.
AI-assisted: yes (Claude Code)
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.