fix(agc): an all-zero sampled descriptor binds a 1x1 zero texture #293
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/293"
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 MichonGoddijn231849 on 2026-10-01T21:58:12Z.
What
Split out of #167. An all-zero sampled descriptor was rejected by
DecodeTextureResource, which skipped the draw or dispatch and cost an exception per binding. It now binds a 1×1 zero texture of the shader's image shape, one per device and image shape.Only an all-zero T# counts as null. That matches RADV's null image view (
radv_descriptors.h,memset(dst, 0, size)): its DST_SEL 0 selects 0, so it reads zeros. A descriptor with base 0 and any other field set keeps throwing, because the hardware would fetch from address 0. The stage-A records and the fast revalidation recognise the null texture, so a reused binding stays one.Tested
Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.
ctest: the newIsNullTextureDescriptorcases (all-zero, short, and base 0 with each other word set) pass, as does everything else that passes onmainhere.mainwith the first version.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T07:10:02Z.
@boykopovar this one needs your call: should a sampled T# whose base address is 0 bind a 1x1 zero texture instead of throwing? The PR body says the hardware behaviour is inferred, not documented, so it comes down to how you apply exact-or-throw here.
What backs part of it: RADV writes an all-zero descriptor for a null image view (
src/amd/vulkan/radv_descriptors.h:133at Mesa e5f06878,memset(dst, 0, size)), and an all-zero T# reads zeros because DST_SEL 0 selects 0. ButIsNullTextureDescriptoronly looks at the 40-bit base, so a descriptor with base 0 and a real type, size and DST_SEL also gets the zero texture, where the hardware would fetch from address 0. My read: I'd accept the all-zero descriptor and keep throwing when any other field is set.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-04T08:13:36Z.
Agreed, that is the stricter reading of exact-or-throw, and it's the part RADV backs. I'll narrow it: only an all-zero T# binds the 1x1 zero texture, and a descriptor with base 0 and any other field set keeps throwing. I'll add a test for both cases and push it today.
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-04T08:53:46Z.
Narrowed as discussed in
d50ed1ad: only an all-zero T# binds the zero texture. Base 0 with any other field set keeps throwing, and the null texture no longer takes a swizzle.IsNullTextureDescriptormoved next toDecodeTextureResourcewith a test (all-zero, short, and base 0 with each other word set). I updated the title and description, including that GTA V and Demon's Souls haven't been re-run with the stricter rule.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T09:51:40Z.
Thanks, that's the narrowing I meant. Only an all-zero T# takes the null texture now, base 0 with any other word set still throws, and the test covers each word. An all-zero T# has DST_SEL 0 in every channel, which selects 0, so the zero texture with a ZERO swizzle reads the same. Merged with current main it builds and passes the full ctest here, and it's ready to merge from my side after a PPSA21564 run on my integration branch.
@boykopovar, this is now only the all-zero descriptor, as I suggested above. Let me know if you'd rather it kept throwing there too.
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-05T15:41:11Z.
Rebased onto current
main. The only conflict was the null texture next tomain's new extended-surface helpers (#490) inShaderResources.cpp. Both are kept, unchanged. Build and ctest are clean apart from the failuresmainhas locally.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T13:40:13Z.
Review: CHANGES_REQUESTED
Measured an all-zero T# on real RDNA2 (gfx1035) with the HW oracle (
tools/hw-oracle), dims 1D/2D/3D/Cube/2DArray:image_sample_lz,image_gather4_lz,image_loadandimage_get_resinfoall return 0 in every channel. Sample/gather/load match this PR (zero texture + ZERO swizzle). One thing doesn't:image_get_resinfoon a null binding: the PR binds a real 1x1 view with one mip, so the recompiler'sOpImageQuerySize[Lod]/OpImageQueryLevels(SpirvImageEmitter.cpp:397-413) give width 1, height 1, levels 1, while the hardware gives 0 for all of them. This matters: Astro's Playroom usesimage_get_resinfoin 88 shaders. One direction: a real null descriptor (VK_EXT_robustness2nullDescriptor, where Vulkan requires reads and size queries to return 0), with the 1x1 texture kept only as a fallback when the feature is missing. In that fallback, resinfo on that binding should either be modelled as 0 or throw.binding.imageDepthCompare) binds the RGBA8 null texture, which lacksSAMPLED_IMAGE_DEPTH_COMPARISON, so that's a Vulkan validation error. Either give the depth-compare case its own depth-format null texture or keep throwing there.IsNullTextureDescriptor, and they're inagc_driver_graphics_tests, which isn't registered in ctest, so CI never runs them (that's already true on main). An execution test that binds an all-zero T# and checks sample = 0 and resinfo = 0 would pin the behaviour above and run on CI.Build and the full ctest pass merged with current main here.
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-07T17:31:12Z.
Rebased onto current
main(now 5d828e33), no conflicts. #1184 (bindless tables up to the device's limit) builds on this one. Working on the review points next.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-07T18:22:22Z.
@adriadam10 thanks for measuring it. Changes in d00dabf8:
VK_EXT_robustness2nullDescriptor(enabled when present), an all-zero T# now bindsVK_NULL_HANDLE, soimage_get_resinforeturns 0 like the hardware. Without the feature it keeps the 1x1 zero texture. There is no per-binding record of size queries to refuse it on, so that fallback's size difference is listed in TechnicalDebt.agc_driver_null_texture(tests/execution/NullTexture.cpp, so it runs in ctest). It runsimage_sample_lzandimage_get_resinfothrough an all-zero T#, and expects 0 from both wherenullDescriptoris available; otherwise it checks only the sample. With the null handle not written it fails with resinfo 1. It passes on an RTX 5080.Build and ctest pass. #1184 is rebased on this.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T19:59:54Z.
Review: CHANGES_REQUESTED
Thanks for the quick turnaround. Checked d00dabf8 merged onto current main: build and full ctest pass, and
agc_driver_null_texturepasses on RADV and on CI's lavapipe (both exposenullDescriptor, so the size check runs).image_get_resinfo= 0 on a null descriptor is also what the Vulkan CTS requires (vktRobustnessExtsTests.cpp, textureSize/textureQueryLevels on a null descriptor), so it holds on any conformant driver.Also measured
image_sample_c_lzwith an all-zero T# on RDNA2 (gfx1035,tools/hw-oracle): 0 in every channel for compare funcs ALWAYS/GREATER/LESS, dims 1D/2D/Cube/2DArray. One thing doesn't match:nullDescriptor, depth-comparison binding (ShaderResources.cppnullTexture(..., depthCompare=true)): I ran your test withimage_sample_lzreplaced byimage_sample_c_lz(ref 1.0, sampler compare func ALWAYS) and forcednullDescriptoroff. RADV returns 1.0, the hardware returns 0. The ZERO swizzle doesn't reach the comparison result, so the D32 zero texture gives whatever the compare func says. WithnullDescriptoron, the same test gives 0 (RADV and lavapipe), so only the fallback is wrong. Since there's no texture content that makes every compare func return 0, I'd suggest the fallback keep throwing for comparison bindings (as onmain), and the TechnicalDebt line say so.image_sample_c_lzcase inNullTexture.cpp(expecting 0 with the device'snullDescriptor) would pin the comparison path. Encoding I used, for reference:v_mov_b32 v1, 1.0thenimage_sample_c_lz v[8:11], v[1:3], s[4:11], s[12:15] dmask:0xf dim:SQ_RSRC_IMG_2D(0x7e0202f2, ..., 0xf0bc0f08, 0x00610801), and| (7u << 12u)inuserData[12].Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-08T15:56:37Z.
Thanks for measuring the comparison case. Rebased onto main and updated:
nullDescriptor, an all-zero T# bound by a depth-comparison sampler now throws again (as onmain), with the descriptor dwords in the message. The D32 stand-in is gone. Sample, gather and load in the fallback still bind the 1x1 zero texture; withnullDescriptor, comparisons bind the null descriptor as before.NullTexture.cppadds animage_sample_c_lzcase (ref 1.0, compare ALWAYS) that expects 0 withnullDescriptor, and a new ctestagc_driver_null_texture_fallbackruns the same test withAPS5_NO_NULL_DESCRIPTOR=1and expects the throw for the comparison and 0 for the plain sample. Against the previous version the fallback test fails with the 1.0 read you saw.image_get_resinfodeviation.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-09T08:31:59Z.
Closing: superseded by #639. The runtime ABI requires robustness2 null descriptors, so an all-zero sampled descriptor now binds as a null descriptor and reads zeros, which is what this PR did with a 1x1 zero texture.
Pull request closed