fix(shader): load a BDA span in place from its own function #5022
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5022"
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 oneandonlydean on 2026-10-13T08:42:17Z.
What
read_bda_spanchooses between a span's in-place dword loads and its per-dword byte fallback, which callsread_bda_dword_bytes. Both shapes of that choice so far hang a group of NVIDIA drivers (a dispatch never finishes and the device is lost), and #4975 shows that reverting #4759 only moves the hang:The loads now live in
load_bda_span, aDontInlinefunction that calls nothing, andread_bda_spanis one selection again: one arm callsload_bda_span, the other is the fallback as before. Neither earlier shape is emitted: the selection is single, and no function holds both the in-place loads and the nested calls. The probe, the loads, the lookups, the fault records and the invocation stops are unchanged for every lane. A read site inmainis unchanged, so its size is too.This is the shape described in a comment on #3291 as passing on 591.86 (RTX 4060 Laptop) with no pipeline creation cost over
main(1.95 s and 7.2 s for 256 and 512 read sites). That was another implementation of it, not this commit.docs/dev/debt/shader.md: the BDA span reads entry now lists both hanging shapes with their drivers and says where the current one is measured.Tested
Linux (CachyOS, kernel 7.2, GCC 16.2), RTX 4090, NVIDIA 610.57.04, Release,
BUILD_TESTING=ON, built with-DANYPS5_ENABLE_SPIRV_TOOLS=ONandOFF.mainwas measured atc2565f0149and the branch is oncac4e9688f; nothing undercore/shaderorlibSceAgcDriverdiffers between the two.The 23 tests of #4759 plus
agc_driver_scalar_wide_loads, run one at a time withANYPS5_NO_SHADER_CACHE=1:main(1 run)agc_driver_scalar_wide_loadsandagc_driver_flat_apertures_0to_13hangagc_driver_bda_span_readsandagc_driver_pixel_interlockhangmainwithSpirvBdaRead.cppfrom e51428bf2^1 (4 of the tests)agc_driver_bda_device)[gpu] recorded batch still running on the GPU after 5 s, logs one NVIDIA Xid 109 in the kernel log and ends inguest allocation ... is still pinned by GPU work or an import. No Xid with the branch.vkQueueSubmit recorder: Vulkan result -4, Xid 109), in a build without SPIRV-Tools. Bisected toe51428bf2: its parent doesn't, andmainwith only #4759 reverted ran 5 times without it. This branch was not run in that title.agc_driver_scalar_wide_loadspassesspirv-val --target-env vulkan1.3in all three shapes; nothing invalid was found in the hanging one.agc_shader_memory, "BDA read functions": a span read function must hold no load and call its load function once, and the load function must hold the four loads and no call. Onmainit fails withthe span load function does not hold the four in-place loads and nothing else. It needs no GPU, so it runs on lavapipe CI.ctest -R "agc|shader"with SPIRV-Tools on: 476 of 476 pass, no Xid. Onmainthe 15 hangs above are the failures.python3 tools/check_conventions.py --base origin/mainandgit diff --checkpass.Not tested: drivers 591.86, 590.48.01, 595.97, 596.36, 610.62 and 610.74, any Windows build, AMD, Intel, and any title. A run on one driver of each group would settle it; the #4759 comment above offers one on 595.97 and a #4975 comment one on 610.74.
#4976 and #3655 change the same function, so whichever merges later needs a rebase.
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 kr4y4 on 2026-10-13T14:58:47Z.
Driver 595.97, which the commit message lists as not tested, passes with this change, in a default build and in one with SPIRV-Tools.
Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU (NVIDIA 595.97) and an Intel Raptor Lake-S iGPU (32.0.101.6790),
main0f2683cb7. This is the machine from my report on #4759, whereagc_driver_bda_span_readsandagc_driver_pixel_interlocklost the device onmainea2bbefb2.ANYPS5_NO_SHADER_CACHE=1,--repeat until-fail:3and--parallel 4:agc_shader_memory,agc_driver_scalar_wide_loads,agc_driver_bda_device,agc_driver_bda_span_reads,agc_driver_pixel_interlock,agc_driver_flat_apertures_0to13, and the sixflat_loadsandglobal_loadstests.-DANYPS5_ENABLE_SPIRV_TOOLS=ON: 25 of 25 on both GPUs. The slowest took 7.3 s on NVIDIA and 27.0 s on Intel.ctest --timeout 120 --parallel 4), default build: 1069 of 1069 on both GPUs.nvlddmkmevents during these runs.Written with AI assistance.