fix(agc): give a multisampled depth-stencil sample shadow attachment usage #15750
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15750"
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 EagleBearerYS on 2026-11-04T12:13:02Z.
What
On RADV for GFX6-8 GPUs, a multisampled D32S8 surface sampled through its sample shadow returned wrong depths. After
vkCmdCopyImageinto the shadow, most samples were never written and a few held wrong bytes.On those GPUs RADV treats a depth-stencil image without depth-stencil attachment usage as not renderable, so its copy into the shadow runs on RADV's compute path. The sample shadow of a format with a stencil aspect now gets depth-stencil attachment usage. RADV then copies on its graphics path, as it already does on GFX9 and later, and the shadow's format query asks for the same usage. There's no driver or device check. Depth-only shadows are unchanged.
This was never a regression. On GFX8 RADV, seven tests have failed since #9533 and #9717 added them. @XatiX pointed out that the bisect's "passing" side ran no tests at all. On today's
main, four tests added since then fail there too, so 11 of the 17agc_driver_native_depth_*tests fail on that GPU. With this PR, all 17 pass.Sources:
RADV in Mesa 26.2.5:
radv_image.cL652-L674: ongfx_level <= GFX8, a depth+stencil image without depth-stencil attachment usage getsRADEON_SURF_NO_RENDER_TARGET;radv_image.cL1756-L1765: such an image isn't renderable;radv_meta_copy.cL832: a copy into a non-renderable image uses compute;radv_meta_bufimage.cL666-L762 andradv_meta_nir.cL602-L651: that path fetches and stores each sample.These lines show which path the copy takes. Why RADV's compute copy leaves samples unwritten on GFX8 isn't traced, so that part is inferred from the runs below. They show the copy fails on the compute path and succeeds on the graphics path.
@ryanc2112's runs on an RX 570 (RADV POLARIS10, Mesa 26.2.5), with diagnostic branches that printed every fetch (first run, switches):
main05050505The same Mesa on a Steam Deck (RADV VANGOGH) passed every mode.
RADV_DEBUG=nohizandnofastclearschanged nothing, and noVUID-errors were reported in any mode.Why the attachment usage and not direct sampling: both pass. The usage keeps the shadow, so the sampling path is unchanged on every driver, and only the shadow's usage flags change.
One trade-off, from @Superseabas's review: the shadow's format query now includes the attachment usage. A driver that supports a sampled multisample D32S8 shadow at some sample count only without that usage would skip the shadow at that count. It would then sample the attachment directly if that's supported, or have no sampled path. Vulkan reports sample counts per usage, so this can differ in principle. Superseabas's probe shows the same counts with and without the usage on both of their GPUs.
Overlap: #15301 (@Prophet069) changes how
createSampleShadowallocates the shadow's memory, and this PR changes its usage flags. The two merge cleanly in either order and compose. None of the other open PRs that touchDepthSurface.cppchanges the shadow's usage. No other D+S image in the AGC driver is created multisampled without depth-stencil attachment usage.Tested
The second commit adds a 64x32 D32S8 case to
agc_driver_native_depth_driver_pathat each supported sample count. The 5x3 surfaces the tests used before get no HTILE. At 64x32, drivers can compress the attachment and, with this PR's usage, the shadow.On today's
main, RX 570 (RADV POLARIS10, Mesa 26.2.5), from @ryanc2112 (results), 3 of 3 runs each.agc_driver_native_depth_*mainb11c7bf84fb11c7bf84fwith0605086887and5537967776cherry-picked, the same tree as this PR's headVUID-errorsThe 11 are the original seven plus four tests added since
9090972b7e:aliased_depth_depth_onlyandaliased_depth_stencil, from #9742;uniform_planes, from #14005;publication, from #13021.So the change also covers those tests on that GPU. Setup: a clean build, GCC 16.2.1, Release,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1,VK_LAYER_KHRONOS_validation,ctest --no-tests=error.The first confirmation, on both machines. Earlier, @ryanc2112 ran the seven failing tests on both machines, 3 times at each commit, with
ctest --no-tests=errorand no diagnostic switches (results).9090972b7e:0605086887is the new case without the fix, and5537967776adds the fix.main, with the fix first so the new case never lands failing.driver_pathrun at each commit loadedVK_LAYER_KHRONOS_validationand reported noVUID-errors.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1.0605086887(the new case, no fix), ormainwhere marked5537967776, or this branch where markeddriver_pathstops ata sampled depth on the driver's device is not 0.000000main: 11 / 12*, 0 VUIDsmain: 11 / 12*, 0 VUIDsb11c7bf84f(run)main's code with the new case: 17 / 18 pass, 1 skipsmain's tree: 17 / 18 pass, 1 skips* Of the 12
agc_driver_native_depth_*tests:bda_clearwasn't built in that tree;driver_queued_fillskips on Windows, as it does onmain.The local runs compared
mainwith the two commits, both on8b7d6c183b, where neither file differs from9090972b7e. Both sides used the same machine and GPU, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1andctest -V.was not found but was requested by env var VK_INSTANCE_LAYERS. AVK_LOADER_DEBUG=layerrun showed the layer inserted.mainand 9 with the 64x32 cases. The 64x32 cases passed at 2, 4 and 8 samples.On GitHub's runners:
agc_driver_native_depth_bda_clear, which skips itself there.VK_LAYER_KHRONOS_validationloaded on both sides. The only VUID,VUID-VkDeviceCreateInfo-pNext-pNext, is inmain's log too.@Superseabas's review at this head (approval):
7fe8857559merged ontomainb11c7bf84f, run on two Windows GPUs without the GFX8 copy problem, so a no-regression check, not a red check of the fix. Windows 11, WinLibs GCC 16.2.0, Release,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -R '^agc_driver_native_depth.*$'.maindriver_queued_fillon both sides. NoVUID-lines in any of the four runs.driver_pathon the merge, 3 runs per GPU:cases checked=9 unavailable=0every time, the 64x32 cases at 2, 4 and 8 samples included.DepthSurface.cppreports sample counts0xffor D32S8 and D32 on both GPUs, withmain's shadow usage, with this PR's, and for the attachment's. So the runs take the shadow path, with the new usage.TechLevelZero's NVIDIA GPU test at this head (report):
7fe8857559merged ontomainb11c7bf, NVIDIA RTX 2000 Ada Generation, driver 595.99.02, 2,822 of 3,894 tests selected. 2,768 passed, 5 failed (none new: 3 also fail onmain, 2 unstable onmain), 49 skipped, and no new validation IDs over 974 GPU tests. Of theagc_driver_native_*tests, onlyagc_driver_native_multisample_depthandagc_driver_native_depth_bda_clearwere selected, and both passed.agc_driver_native_depth_driver_path, which holds the new case, wasn't selected.Checks:
tools/check_conventions.py: all passed.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)Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-04T16:32:14Z.
Review: APPROVED
Head
7fe8857559merged onto currentmainb11c7bf84f(clean merge, local only): code read and a run on two Windows GPUs. The usage change applies to every driver, and this checks it at the current head on NVIDIA Blackwell and on AMD's Windows driver for an RDNA 2 iGPU. Neither GPU has the GFX8 compute-copy problem, so this is a no-regression check, not a red check of the fix itself.Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Release,BUILD_TESTING=ON.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -R '^agc_driver_native_depth.*$',ANYPS5_GPUselecting the device (confirmed bySelected GPU):main10de:2c05)1002:164e)The skip is
agc_driver_native_depth_driver_queued_fillon both sides, as in the description. There are noVUID-lines and no missing-layer line in any of the four runs.agc_driver_native_depth_driver_pathon the merge, 3 runs per GPU:cases checked=9 unavailable=0every time, including the three new 64x32 cases at 2, 4 and 8 samples.The sample shadow path is the one exercised here. A standalone
vkGetPhysicalDeviceImageFormatPropertiesprobe with the exact usages fromDepthSurface.cpp(2D, optimal tiling, flags 0) reportssampleCounts0xffor D32S8 and D32 on both GPUs:main's shadow usage,SAMPLED | TRANSFER_DST;DEPTH_STENCIL_ATTACHMENT;So
useSampleShadowstays true on these drivers and the shadow now gets the attachment usage.check_conventions.py --base mainpasses on the merge.Read through the change:
sampleShadowUsage()addsDEPTH_STENCIL_ATTACHMENTonly whenHasStencil(hostFormat), so depth-only shadows keepmain's usage. The same function feeds the format query that decidesuseSampleShadowand thevkCreateImageincreateSampleShadow, so the query and the image agree. One consequence: a driver that supports sampled multisample D32S8 but not with depth-stencil attachment usage at some sample count would leave the shadow and take the direct attachment path if it is sampleable, or have no sampled path. Neither GPU here hits that. The test change only makes the extent a parameter and adds a 64x32 case per sample count on the whole-fill path, withunavailablecounting the extra case. I found nothing to change.AI-assisted: yes (Claude Code)