fix(agc): import uneven planes of a native multisample D32S8 target without HTILE #27437
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27437"
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 DerKarussellbremser on 2026-11-26T10:11:48Z.
What
A multisampled D32S8 depth target without HTILE is imported only when its depth plane repeats one float in [0, 1] and its separate stencil plane repeats one byte. Any other plane records
native multisample depth plane without HTILE does not hold one depth value in [0, 1]ornative multisample stencil plane without HTILE does not hold one stencil value, and the next sampling or publication of the target throws it. #16363 added one way out: when the first draw overwrites every sample with the stencil reference of its registers, a stencil readback proves it and the refusal is dropped.Assassin's Creed Black Flag Resynced (PPSA28183, 01.006.038) stops there when its first 3D scene starts. It binds a 4-sample D32S8 target without HTILE at a dynamic resolution (900x508 down to 640x360 on this machine). The stencil plane of each new extent lies over bytes the previous, larger depth plane left there: 0x00, 0x3f and 0x80, the bytes of depth 1.0. Its first draw is the full-screen overwrite #16363 looks for, but the stencil value comes from the pixel shader (it exports the stencil operation value). Every sample then holds 1, the registers say 0, the proof fails, and the compute shader that samples the target throws the stencil message.
This change imports such planes, whatever the first draw does:
prepareUniformPlaneSamplinghands a depth plane that does not repeat one value toreadDepthPlane, the import a D32 target without stencil already has: the samples are detiled, then drawn through FragDepth when every word is stored exactly, else copied throughVK_KHR_maintenance8.importSamplesaccepts a D32S8 host image, andcopiesDepthSamplesasksDirectDepthCopyabout the target's own format.readStencilPlanedetiles the plane.importStenciluploads the samples into a multisampled R8_UINT image (DispatchMultisampleImagewith 1-byte elements) andRecordStencilSampleImportwrites them: the host stencil starts at zero, and the eightSampleOrderStencilBitspasses each set one bit where the source sample has it. This is the stencil half of theDepthStencilBitssample reorder without its depth pass (drawDepthskips the depth draw and the depth source binding when it gets no depth source), so it needs sample-rate shading and no extension.readDepthPlane,readStencilPlane) and starts the host image at that value; it is not imported sample by sample and needs none of the import features. Before, the padding refused it. Publication writes samples and keeps padding, so it can leave such a plane.framebufferStencilSampleCountsrefuses a stencil plane whose samples differ with the same messages as before, and the overwrite proof of #16363 still applies to it.The upload loop of
importSamplesmoved intouploadSamples, which both planes use. It rounds the last dispatch range up to four bytes, which only a stencil plane with a sample count not divisible by four needs.Cost: each created owner over an uneven plane reads and detiles that plane on the CPU, uploads it, and for the stencil plane draws eight full-screen passes. Black Flag creates the owner about once per frame. I did not measure the import in isolation; the scene numbers are under Tested.
Tested
Windows 11 Home 10.0.26200, i7-10750H, 16 GB, NVIDIA GeForce RTX 2060 6 GB, driver 610.91, WinLibs GCC 15.2.0 r7 UCRT, Release. Rebased onto
main611e7805f4on 30 Nov: one conflict inNativeMultisampleDepth.cpp, wheremainextendedUniformPublicationright behind the new test function, and both are kept. Thectest, validation and conventions lines below are from the head47e8348508(the rebased commit4e2c6c10a0and three review commits on it), the overlap line from4e2c6c10a0; the red-on-base check and the title runs are from before the rebase (main0af6efad52and11952ab7d1) and were not repeated. This device hasVK_KHR_maintenance8andVK_EXT_depth_range_unrestrictedand noVK_EXT_shader_stencil_export.agc_driver_native_depth_uneven_planes(--uneven-planes), at 2, 4 and 8 samples, on a 129x67 D32S8 target without HTILE (XOR 0 at 2 samples, 0x8c00 else). Each case tiles the planes over 0xa5 padding, binds the target, and reads every sample of both planes back through a compute fetch:guest writes;DepthSurface.cppandSampleOrder.cppas onmainit fails in the first case withnative multisample depth plane without HTILE does not hold one depth value in [0, 1].importsStencilSamplesanddetilesDepthSamplesdo; where the stencil import is available and the depth import is not, it expects the depth refusal for the uneven depth planes.DepthSurface.cppas at4e2c6c10a0that second run fails withnative multisample stencil plane without HTILE does not hold one stencil value.framebufferStencilSampleCountsin the test's context and expects the same as the second. Red without the second review commit: withDepthSurface.cppas at5b1b334dd2it fails withmultisample target refusal did not match does not hold one stencil value, because the plane is imported. At the head the test passes three times in a row.agc_driver_native_depth_uniform_planes: its two "does not hold one value" cases changed the last byte of a plane, which is padding. They now change a sample inside the extent. The test passes on the base and here.ctest -R "agc_driver_native_depth|agc_driver_native_multisample|sample_order": 47 tests, 45 pass and 2 skip on this device (agc_driver_native_depth_driver_queued_fill,agc_driver_sample_order_grid_reference); onmainit is 46 tests, 44 pass and the same 2 skip.agc_driver_graphicspasses too.agc_driver_graphicswithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest -V(Vulkan SDK 1.4.363.1), onmain611e7805f4and on this branch: no test fails in either run (47 and 48 tests, with the two skips above in both), the loader logsInsert instance layer "VK_LAYER_KHRONOS_validation"91 and 94 times, and neither log has aVUID-line orwas not found but was requested by env var VK_INSTANCE_LAYERS.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branch feat/agc-import-uneven-d32s8-planes(2,146 open pull requests, 46 share a file with the branch): three conflict in lines, #27698, #28229 and #28292. Each adds code next to lines this PR adds inSampleOrder.hpp,SampleOrder.cpporDepthSurface.cpp; none of them imports uneven planes of a multisample target (#28292 seeds a single-sample D32 surface from its guest plane). 25 more conflict withmainthemselves and could not be compared (#1368, #1395, #6808, #7256, #7642, #9508, #9895, #10193, #10469, #10492, #10497, #11444, #11551, #13863, #13920, #13928, #13929, #15621, #16880, #22062, #22531, #22647, #25561, #25574, #25716). I searched their diffs (for #7642 and #9508, whose diffs GitHub does not serve, the fetched heads against their merge bases, before the rebase; the seven that are new in this list, #10469, #10492, #10497, #16880, #25561, #25574 and #25716, today) forprepareUniformPlaneSampling,uniformPlaneValue,readDepthPlane,importSamples,importedSamples,importedPerSample,copiesDepthSamples,unevenPlanes,RecordDepthSampleImportanddrawDepth(. One touches them: #9508 adds aHeapSlotOwnerparameter todrawDepthand its two callers. It does not implement this import, butImportStencilhere is a third caller, so whichever of the two lands second has to pass that argument and mergedrawDepth.main11952ab7d1+ #27371: the run ends when the first 3D scene starts, withcompute shader 0x4005431400: AGC graphics: native multisample stencil plane without HTILE does not hold one stencil value.guest memory is not readable at … (range …)fromGuestBufferMemory::copyRegion(after 1 present, about 100 s and about 30 s). That abort is a separate defect, not caused by this change: a local variant that kept the import off and extended the #16363 proof instead hit it too.0ee50b24d4, testsffec15736c): a refused uneven plane now carries the reason its reader gives (importing an uneven native multisample depth plane requires ...,... stencil plane requires ...,... holds a sample other than +0 or a normal depth in (0, 1] ...) instead of the uniform-only message, which stays for a plane that is not read.agc_driver_native_depth_uniform_planes,_uneven_planesand_overwritten_planesexpect those reasons. With the validation layer loaded: 41 of the 42agc_driver_native_depth*tests pass andagc_driver_native_depth_driver_queued_fillskips as before, noVUID-line. On this GPU the two expectations behind!importsDepthand!copiesin the uneven-plane test did not run.78128bb015, teste2d55a77d1): a publication that keeps guest bytes beside an undecided one checks that the next import can read the planes it leaves. For a D32S8 target without HTILE that check asked for even planes; it now asks what the import asks. New modeUndecidedinagc_driver_native_depth_publication_without_htile(one changed stencil byte in a drawn page, then a CPU read): published and imported again at the next bind with the import features. Without them it was refused; since #28796 onmain(merged in atf0efdc2af4, test49b028e6ea) the page is left to the guest and the owner ends, which the test now expects. Red with the publication check as before78128bb015:a written D32S8 owner without HTILE did not publish its stencil samples and padding, in the context with the import features. With the validation layer loaded: 41 of the 42agc_driver_native_depth*tests pass,agc_driver_native_depth_driver_queued_fillskips, noVUID-line.pr_overlapat49b028e6ea: no confirmed line conflict; 28 conflict withmainthemselves, among them now #27698, #28229 and #28292, and none of the 28 touches this check. The title was not run again.VK_EXT_shader_stencil_export(it takes the same bit passes); a device withoutVK_KHR_maintenance8beyond the refusal the test expects there; D16 and HTILE targets, which this does not touch.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
https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T10:28:56Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code supports the described uneven-plane import, and the author reports passing targeted checks on the stated NVIDIA/Windows setup.
What I ran
4a64e0edc3acd9e183d783333eb56dc0d5ff5cd1against the prepared diff; no tests or build commands were run.description.md,commits.md,manifest.json,diff.patch, andREADME.mdusing the review reader. Read all changed lines inSampleOrder.hpp,DepthSurface.cpp,SampleOrder.cpp, the CMake test registration, and the debt note. Read the new test’s changed lines throughrepo_read.pybecause its full text was excluded from the review folder.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T08:14:20Z.
Review: COMMENTED
Actionable comments posted: 2
Architecture findings (1)
Advisory architecture findings (1)
49486c4e-02d5-462e-9e83-0fd244e26e46Reviewing files that changed from the base of the PR and between
1b8f79a5b5and4e2c6c10a0.core/libs/prx/libSceAgcDriver/Graphics/include/SampleOrder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/SampleOrder.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_native_multisample_depth_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cppdocs/dev/debt/changes/feat-agc-import-uneven-d32s8-planes.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-30T08:17:38Z.
Review: COMMENTED
Reviewed — comments
This review covers the core import paths and tests at head
4e2c6c10a0b3016fadf7c3e1550cbd6354b9bc32; the large test source was read through the pinned reader, but no checks were run here.What I ran
No commands or tests were run. I read the prepared description, commit summary, manifest, diff, and changed source ranges through
repo_read.py.Results
Findings
Blocking
None verified.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:503-506.Not verified
No build or test commands were run, so author-reported Windows, Vulkan validation, and game results were not independently verified. Linux, macOS/MoltenVK, and non-NVIDIA hardware behavior were not verified. Files read:
core/libs/prx/libSceAgcDriver/Graphics/include/SampleOrder.hpp,core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp,core/libs/prx/libSceAgcDriver/Graphics/src/SampleOrder.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_native_multisample_depth_tests.cmake,core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp, anddocs/dev/debt/changes/feat-agc-import-uneven-d32s8-planes.md. The manifest marks all changed files as reviewed; all added lines in those files were inspected. No changed files were excluded from the review.To get this to a good state
Nothing is required. Optional: check stencil attachment sample-count support before taking the new stencil import path.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T08:34:56Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: validate the R32 sampled multisample image usage before accepting an uneven depth plane.
What I ran
Reviewed head
5b1b334dd27c5d72c5d2d70173c360f40201ef56usingrepo_read.py. No build or tests were run by this review; reported test results below are author supplied.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:496checks that an R32 multisampled image supportssampleUsage, but the caller for drawn imports passesimportedSampleUsageonly atDepthSurface.cpp:500; that usage does not includeVK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT. The imported image is later sampled bydrawSamplesand is created with that attachment usage atDepthSurface.cpp:2314-2326(through the earliersampleShadowUsageimplementation). On a device where the R32 format supports storage and sampling but not depth attachment usage, the gate accepts the path and image creation can fail instead of refusing the uneven plane. Include the attachment usage in the capability check, or otherwise ensure the created image's full usage is checked before accepting the import.Non-blocking
None.
Not verified
No execution tests or builds were run. The full text of
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cppwas excluded from the review folder; relevant added test ranges were read throughrepo_read.py. All other changed files were read, with changed hunks inspected indiff.patch.To get this to a good state
Update the R32 multisample image feature check to cover the usage flags used by the created image, then rerun the relevant native multisample depth tests and validation checks on the new head.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T08:40:46Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
8e8a4940-2e23-422d-9b52-d7a6e67f5d87Reviewing files that changed from the base of the PR and between
4e2c6c10a0and5b1b334dd2.core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.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 coderabbitai[bot] on 2026-11-30T09:15:55Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (1)
Advisory architecture findings (1)
b9703ea5-eabd-4ff7-8bcc-f64a80f4b2d8Reviewing files that changed from the base of the PR and between
5b1b334dd2and4b6e60cbf7.core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.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-11-30T09:20:28Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
4b6e60cbf77b68279eb63cdfc45f8d1f95a89f45using the prepared diff andrepo_read.pyfor targeted source context. I did not run tests or a build.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
NativeMultisampleDepth.cppwas excluded from the review folder because it was too large. I read the changed test function and dispatch block at the pinned head throughrepo_read.py, but did not inspect the rest of that file. I also did not run the reported tests, build, validation layer, or game scenario, and did not independently verify the author’s hardware results. Other changed files in the manifest were read:SampleOrder.hpp,DepthSurface.cpp,SampleOrder.cpp,agc_driver_native_multisample_depth_tests.cmake, andfeat-agc-import-uneven-d32s8-planes.md.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T09:38:16Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
844ac592-eb27-4b07-b355-5ae8ac02951eReviewing files that changed from the base of the PR and between
4b6e60cbf7and47e8348508.core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.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-11-30T09:39:46Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at head
47e834850877f905faf608c265b095527a9b23ebhas no verified blocking findings; the author-reported checks were not rerun in this session.What I ran
No commands or tests were run. I read the prepared description, commit list, manifest and diff, then inspected changed code and relevant callers through
repo_read.pyat the pinned head.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run builds, tests, validation layers, or console and GPU checks. The PR description reports these checks, but I did not independently confirm them. The four changed files included in the review folder were read; the oversized
NativeMultisampleDepth.cppwas inspected through the pinned reader at its changed test sections. The prepared manifest lists no other excluded changed files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T12:38:31Z.
Review: APPROVED
I read the diff at
47e8348508. Windows 11, GCC 15.2, merged intomainatdaa61711afetogether 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_native_depth_*tests (41;_driver_queued_fillskips itself): 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_native_depth_uneven_planesfails with "native multisample depth plane without HTILE does not hold one depth value in [0, 1]".Not checked: a title.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:18:16Z.
Review: COMMENTED
The plane preparation returns the former uniform-only refusal when the new reader fails.
readStencilPlanehas a more specific explanation for missing storage image writes, sample-rate shading or R8 support, and that reason is dropped by the booleanimportshelper. Could the failure report preserve the returned reason so an unavailable device can be distinguished from an unsupported plane layout?Source review at
47e8348508. The head trial-merges onto192c4e45a0. Paired Linux checks are queued.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T02:21:07Z.
Review: COMMENTED
Actionable comments
92c2b503-4901-45ff-a60b-12ddec6fab61Reviewing files that changed from the base of the PR and between
47e8348508andffec15736c.core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.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-04T03:32:11Z.
Review: APPROVED
Reviewed — looks good
The change at
ffec15736c2a014f9dc20e6751d53d3869dd3acdcorrectly imports uneven D32S8 planes and gates those imports on the required device capabilities.What I ran
Read-only review of the prepared diff and changed code paths using
repo_read.pyat the exact head above. No tests or builds were run; the base was not merged for this review.Read the changed ranges in all six files listed under
reviewedinfiles.json; no files were excluded. The fullNativeMultisampleDepth.cppwas not read, but its changed test ranges were.Results
Negative control
Not run independently. The description reports red-on-base checks; those results were not verified in this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The reported tests, validation-layer runs, and Black Flag behavior were not independently reproduced. Other operating systems and GPU configurations described as not covered in the PR description remain unverified.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T08:50:41Z.
Review: APPROVED
Reviewed — looks good
The changed code and added test cases are consistent with the stated D32S8 import and publication behavior.
What I ran
Reviewed head
e2d55a77d1d5f4de4fa11cf22f8af44e7d433168withrepo_read.pyand the prepared diff. I did not run tests or a build.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
The stencil import gates and detiles the samples before upload in DepthSurface.cpp at the reviewed commit. The import then uses the stencil-only sample-order draw path in SampleOrder.cpp at the reviewed commit.
Not verified
Runtime behavior was not independently tested. The author's reported Windows/NVIDIA results were not rerun; Linux, macOS, AMD and Intel behavior and the device capability branches described as untested remain unverified. All changed files in
files.jsonwere reviewed; the large test source was read at its changed ranges throughrepo_read.py. No files were excluded by the prepared bundle.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T12:54:54Z.
Review: APPROVED
Reviewed — looks good
The changed import and publication paths are consistent with their capability checks, and all six reviewed files were inspected at the pinned head.
What I ran
Reviewed head
49b028e6ea8ee984e270218d7a1f7d870e664f2b, based onmain; no merged-preview check was run. I used the pinned reader for targeted source excerpts. No build, test, or runtime check was run here.Results
Negative control
Not run; no source mutation or test execution was performed.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
No runtime behavior or test results were independently verified. The Windows NVIDIA results in the PR description are author-reported. Linux, macOS, other GPU vendors, and the listed unsupported-feature configurations were not checked.
files.jsonlists six reviewed files and no excluded files; the changed hunks and relevant source context for all six were inspected.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T16:37:02Z.
Review: APPROVED
Re-verified head
49b028e6eaon Windows 11 with GCC 15.2, applied alone to main484b0368d3. That covers the five commits since my last review: the reader's refusal reason, uneven D32S8 planes beside an undecided guest byte, and the ended-owner expectation. Run withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer(layer 1.4.363).agc_driver_native_depth_*_driver_queued_fillskips itself in every run. In the negative,uniform_planes,publication_without_htile,overwritten_planesanduneven_planesfail. Each log shows the loader inserting the layer, and none has aVUID-.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.