fix(shader): ignore a runtime V#'s type for scalar buffer loads as RDNA2 does #11254
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11254"
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 Michael-KD on 2026-10-25T22:47:40Z.
What
A scalar buffer load through a V# that is read at run time (
gpuDescriptor) recorded anInvalidDescriptorBDA fault when the V#'sTYPEfield (word 3, bits 30-31) was nonzero, and the dispatch produced no output. RDNA2 hardware ignores the whole fourth word for scalar loads, so the scalar path no longer treatsTYPEas invalid. Vector buffer accesses keep the check.The snapshot path already zeroed the fourth word for buffers that only scalar loads read (
scalarOnly, fromaa2abf801b); its debt entry said this followed the ISA guide and had not been measured. The measurement below settles it for RDNA2, and the entry now keeps only what is still open: gfx1013, and a V# with a null base (not run, to avoid a GPU fault on the measuring machine).SpirvRuntimeBuffer.cpp:descriptor()takesinvalidas false forResourceKind::ScalarBuffer.ScalarBufferRuntimeWord3(new execution test): word 3 comes from a VGPR throughv_readfirstlane_b32, which forces the runtime-descriptor path, and nine word 3 values (the usual 0x31016fac,OOB_SELECT0,FORMAT0,ADD_TID_ENABLE,TYPE1, 2 and 3, zero, all ones) must read the in-range dwords and 0 pastNUM_RECORDS. It is a new file so that it does not overlap #10337, which editsBufferDescriptorRuntime.cpp.docs/dev/debt/shader.md: the scalar buffer descriptor entry.Measurement, with the hardware oracle:
s[8:11]over a buffer whose dword i is0xA0000000 | i, then 16s_buffer_load_dwordat offsets 0, 4, 8, 12, 16, 20, 24, 28, 1, 2, 3, 17, 18, 19, 21, 64, or 4s_buffer_load_dwordx4at 0, 8, 16, 24.SWIZZLE_ENABLE) × 18 fourth words (0x31016fac,OOB_SELECT0, 1, 2,TYPE1, 2, 3,FORMAT0 withOOB_SELECT3 and 0,ADD_TID_ENABLEwithOOB_SELECT3 and 0,INDEX_STRIDE1, 2, 3,RESOURCE_LEVEL0,DST_SEL0, zero, all ones) × dword and dwordx4.NUM_RECORDSbytes with stride 0 andSTRIDE × NUM_RECORDSotherwise, a dword reads 0 unless it lies wholly in the range (18 records: offset 16 reads 0), and the offset is rounded down to a dword. For example, with 20 records, 0x31016fac, 0x01016fac, 0xb1016fac and 0xffffffff all reada0000000-a0000004at offsets 0-16 and 0 from 20 on.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release.
ctest --test-dir build -R '^agc_driver_(buffer_descriptor_runtime|scalar_buffer_runtime_word3|scalar_wide_loads)$' -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK 1.4.363.0, insertion confirmed withVK_LOADER_DEBUG=layer) andANYPS5_GPUset to each device. Themainarm is this branch with theSpirvRuntimeBuffer.cppchange reverted, so that it runs the new test too:main, RTX 5070 Timain, Radeon iGPUagc_driver_buffer_descriptor_runtimeagc_driver_scalar_wide_loadsagc_driver_scalar_buffer_runtime_word3On
mainthe new test fails at the first nonzeroTYPE:[gpu] deferred write-back failed: BDA access failed: ... reason=8(InvalidDescriptor), thenscalar buffer runtime word 3 0x71016fac: lane 0 offset 0x4 is 0xdeadbeef, expected 0xa0000001. The four word 3 values before it pass. No log containswas not found but was requested by env var VK_INSTANCE_LAYERS, no log has aVUID-line, and each log names the selected GPU.Full
ctest -j8with this change: 2393 of 2395 pass. The two failures,agc_host_import_cut_lifetime(#10746) andagc_driver_depth_plane_partial_store(#10664), also fail with the change reverted.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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T22:57:02Z.
Review: APPROVED
Reviewed the exact runtime change and regression test. The change suppresses only the invalid-descriptor fault for scalar-buffer resources; other resource kinds retain the TYPE check. The new test exercises runtime descriptors with zero, nonzero TYPE and all-ones word 3 values, checks in-range and out-of-range reads across lanes, and the report says it fails on main and passes with this change on both listed GPUs. Diff-check and current-base conventions pass. Product CI was skipped; my local full configure could not proceed because the SDL2 submodule is uninitialized in this worktree, so I rely on the reported GPU runs and did not claim a local execution.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T00:09:23Z.
Review: DISMISSED
I am updating my earlier approval after checking the current overlap and base. The overlap bot lists open PRs #7922 and #10846. Pairwise
git merge-treeof the exact heads is clean with #7922 but conflicts indocs/dev/debt/shader.mdwith #10846.CONTRIBUTING.mdrequires the authors to agree how listed overlaps are ordered and to record any prerequisite on the checklist. Please coordinate with both authors and updateDepends onif #10846 (or another PR) must land first.The PR branch is also 42 commits behind current
main; please update it to the current base and resolve the documentation overlap before approval. The measured RDNA2 behavior and regression evidence remain useful; this request concerns merge-order coordination and the current-base rule.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T03:54:48Z.
Review: COMMENTED
Linux run on NVIDIA and lavapipe of head
5abefb16a. The description's runs are Windows (RTX 5070 Ti, Radeon iGPU) and the RADV oracle measurement. Here the new test shows a genuine red/green on both devices.Tested
Ubuntu 26.04, GCC 15.2.0, Release,
ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1, device chosen withVK_ICD_FILENAMES,-j1. This PR merged ontomaincb45ae2dd(no conflicts).agc_driver_scalar_buffer_runtime_word3,--repeat until-fail:3:main'sSpirvRuntimeBuffer.cppThe control fails with the same message on both devices, on the first
TYPE1 word:agc_driver_buffer_descriptor_runtimeandagc_driver_scalar_wide_loads(vector path and wide scalar loads) also pass 3/3 on both.ctest -R "^agc"without display/flip/lds_atomics64,--timeout 30:maincb45ae2ddNo new failures. On
main, NVIDIA's one failure isagc_driver_sgpr_pattern_fill_keys, which passed on later runs. lavapipe failsagc_driver_multisample_retirementonmainand with this PR.GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.