fix(shader): call load_bda_span outside read_bda_span's per-lane selection #22774
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22774"
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 zarmstrong on 2026-11-18T08:27:38Z.
What
read_bda_spanchooses per lane between the span's in-place loads, a call to theDontInlineload_bda_span, and the dword fallback, which callsread_bda_dword_bytesin a loop. On NVIDIA's Blackwell driver (RTX 5090, 621.01) the lanes that take the fallback then get other lanes' results, soagc_driver_bda_devicefails on every run (#22773). The diagnosis is in the issue.read_bda_spannow callsload_bda_spanonce before the selection, passing the used-dword mask for lanes whose span is mapped and aligned and 0 for the others, soload_bda_spanloads nothing for them. The selection keeps that result for the in-place lanes and runs the fallback for the rest.load_bda_spanitself is unchanged:DontInline, the four loads, no call, as8c04efcfbcrequires for the drivers that hung with the loads in the selection (#3291, #4975). Probe, loads, lookups, faults, stops and theAPS5_BDA_BYTE_READSpath are unchanged for every lane.BdaContracts.cppchecks thatread_bda_spanandread_bda_span_coherentcall their load function outside every selection and loop. CI runs on lavapipe, which does not show the fault, so without the check a later change could restore the shape unnoticed. Withmain'sSpirvBdaRead.cppthe check fails (run on the Intel GPU; it reads only the generated SPIR-V).Tested
Windows 11 Pro 10.0.26200, i9-13900K, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON, every execution test built.main72cf170a25and this branch on it.ctest --test-dir build -R "agc|shader|video_out" -V -j 8withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_GPU=RTX 5090,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer(validation layer 1.4.363, Vulkan SDK 1.4.363.0), on the RTX 5090. The OBS, Overwolf and Twitch implicit layers are disabled withVK_LOADER_LAYERS_DISABLEon both sides (see #20011).mainagc_driver_bda_device,agc_driver_msaa_dcc_unwatch,agc_driver_stencil_plane_memory,agc_driver_store_over_untrackedagc_driver_msaa_dcc_unwatch,agc_driver_stencil_plane_memoryInsert instance layer "VK_LAYER_KHRONOS_validation"was not found but was requestedVUID-,SYNC-HAZARD-,UNASSIGNED-agc_driver_bda_deviceon the RTX 5090:mainfails 10 of 10 (an anchored BDA read differs from the same read through the lookups at anchor 0x7fff12340101 + 0 + (0), 32 bits, 4 dwords); this branch passes 10 of 10, with the validation layer and noVUID-lines.main.agc_shader_memoryandagc_shader_memory_coherent_atomic_loads, which check thatload_bda_spanstaysDontInlinewith its four loads and is called once from the span read function: pass.agc_driver_store_over_untrackedfails intermittently on both sides on this machine (4 of 10 runs without the layer on9b60c84343), so its pass here is not from this change.agc_driver_stencil_plane_memoryis #22427.agc_driver_msaa_dcc_unwatchfails on both sides.agc_driver_upload_cache_read_only_flushdoes not build on Windows (setenv, #19899).Not tested: the NVIDIA drivers that hung in #3291 and #4975 (591.86, 590.48.01, 595.97, 596.36, 610.x). The loads stay in their own
DontInlinefunction, but its call now runs for every lane, so a run ofagc_driver_bda_span_reads,agc_driver_scalar_wide_loadsandagc_driver_flat_apertures_*on one of those drivers would confirm they still pass.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)agc_driver_bda_deviceonly)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-18T14:26:16Z.
Review: COMMENTED
Reviewed head
1f9ddd3783by reading, and ranagc_driver_bda_deviceon an older NVIDIA generation.Run: Windows 11 VM, GeForce GT 1030 (Pascal), NVIDIA 582.78, WinLibs GCC 16.2.0 POSIX UCRT, Ninja, Release,
ANYPS5_REQUIRE_VULKAN=1.main8ba52d0287and this PR merged onto it both passagc_driver_bda_device3 of 3 runs, so the uniform-call shape doesn't regress on Pascal.Reading
SpirvBdaRead.cpp:load_bda_spancall passesSelect(wide, used, 0). With a used mask of 0, each of the four loads is inside its ownEmitValueOrZeroIfCondition, so those lanes never form or dereference a pointer.physicalandfirstBytesreaching the call for those lanes is harmless, since they're only used under the per-dword condition.widelanes takeloadedand the others run the unchanged dword fallback. The coherent variant goes through the sameDefineBdaSpanReadFunction, so it gets the same shape.BdaContracts.cpppins that shape (the call outside every selection and loop) on lavapipe CI, where the fault can't be observed.No changes needed from my side.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T22:16:24Z.
Review: COMMENTED
Reviewed — no blocking findings
The source change moves the span loader call outside the lane selection and guards its loads with the selected mask; I found no verified blocking defect.
What I ran
Reviewed head
1f9ddd378332b86aaace2a12056025d515b6a4d1using the prepared review bundle andrepo_read.py. I did not run build or test commands; no merged-preview check was performed.Results
Findings
Blocking
None.
Non-blocking
MakeBdaDwordReadTestShader.Not verified
I did not independently verify the described GPU results, the unsupported NVIDIA driver behavior, or the author's CI and local test results. No changed files were excluded:
core/libs/prx/libSceAgcDriver/tests/BdaContracts.cppandcore/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cppwere read;files.jsonwas not present in the prepared bundle.To get this to a good state
Nothing is required. Optional: extend the SPIR-V contract coverage to the stop-invocation variant.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T17:35:34Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected changes blocks merging; approval is justified by the code and author-reported GPU results, although those results were not run by me.
What I ran
Head:
27456456f4fe00394a2db86ecda85e3d70f52d10. No commands or tests were run. I read the prepared diff and both changed files at the pinned head throughrepo_read.py.Results
files.jsonwas unavailableFindings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently run tests or validate the reported NVIDIA/Intel GPU results. I did not inspect repository files outside the two changed files. The review folder’s
files.jsoninventory was unavailable;manifest.jsonlists both changed files as included, and I read both.To get this to a good state
Nothing is required.