Skip to content

fix(shader): call load_bda_span outside read_bda_span's per-lane selection - #22774

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
zarmstrong:fix/bda-span-load-inline
Nov 26, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
zarmstrong:fix/bda-span-load-inline

Conversation

@zarmstrong

Copy link
Copy Markdown
Contributor

What

read_bda_span chooses per lane between the span's in-place loads, a call to the DontInline load_bda_span, and the dword fallback, which calls read_bda_dword_bytes in a loop. On NVIDIA's Blackwell driver (RTX 5090, 621.01) the lanes that take the fallback then get other lanes' results, so agc_driver_bda_device fails on every run (#22773). The diagnosis is in the issue.

read_bda_span now calls load_bda_span once before the selection, passing the used-dword mask for lanes whose span is mapped and aligned and 0 for the others, so load_bda_span loads nothing for them. The selection keeps that result for the in-place lanes and runs the fallback for the rest. load_bda_span itself is unchanged: DontInline, the four loads, no call, as 8c04efc requires for the drivers that hung with the loads in the selection (#3291, #4975). Probe, loads, lookups, faults, stops and the APS5_BDA_BYTE_READS path are unchanged for every lane.

BdaContracts.cpp checks that read_bda_span and read_bda_span_coherent call 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. With main's SpirvBdaRead.cpp the 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. main 72cf170a25 and this branch on it.

ctest --test-dir build -R "agc|shader|video_out" -V -j 8 with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_GPU=RTX 5090, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_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 with VK_LOADER_LAYERS_DISABLE on both sides (see #20011).

main this branch
tests 2076 2076
passed 2052 2054
failed agc_driver_bda_device, agc_driver_msaa_dcc_unwatch, agc_driver_stencil_plane_memory, agc_driver_store_over_untracked agc_driver_msaa_dcc_unwatch, agc_driver_stencil_plane_memory
skipped / not run 19 / 1 19 / 1
Insert instance layer "VK_LAYER_KHRONOS_validation" in all 1465 tests that create an instance same
was not found but was requested 0 0
VUID-, SYNC-HAZARD-, UNASSIGNED- 0 0
  • agc_driver_bda_device on the RTX 5090: main fails 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 no VUID- lines.
  • The same test on the Intel UHD Graphics 770 in the same machine (101.6129): passes 3 of 3 on this branch, as on main.
  • agc_shader_memory and agc_shader_memory_coherent_atomic_loads, which check that load_bda_span stays DontInline with its four loads and is called once from the span read function: pass.
  • agc_driver_store_over_untracked fails intermittently on both sides on this machine (4 of 10 runs without the layer on 9b60c84343), so its pass here is not from this change. agc_driver_stencil_plane_memory is agc_driver_stencil_plane_memory fails on Windows hardware GPUs: "a consumed stencil clear was lost on a read-only rebind" #22427. agc_driver_msaa_dcc_unwatch fails on both sides. agc_driver_upload_cache_read_only_flush does not build on Windows (setenv, fix(tests): set the upload cache test's environment with _putenv_s on Windows #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 DontInline function, but its call now runs for every lane, so a run of agc_driver_bda_span_reads, agc_driver_scalar_wide_loads and agc_driver_flat_apertures_* on one of those drivers would confirm they still pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: Fixes agc_driver_bda_device fails on NVIDIA Blackwell (RTX 5090, 621.01): read_bda_span gives the lanes on its dword path other lanes' results #22773
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5090, driver 621.01, Windows 11 Pro 26200 (AGC, shader recompiler and VideoOut tests); Intel UHD Graphics 770, driver 101.6129, Windows 11 Pro 26200 (agc_driver_bda_device only)
  • AI-assisted: yes

🤖 Generated with Claude Code

…ction

read_bda_span calls the DontInline load_bda_span from one arm of a per-lane selection and runs the dword fallback, which calls read_bda_dword_bytes in a loop, in the other. On NVIDIA's Blackwell driver (RTX 5090, 621.01) the lanes that take the fallback then get the results of other lanes: agc_driver_bda_device fails on every run with values read at another lane's address, and the lanes that differ change from run to run.

read_bda_span now calls load_bda_span once before the selection, with the mask of used dwords for lanes that take the in-place loads and 0 for the others, so load_bda_span loads nothing for them; the selection keeps its result or runs the fallback. load_bda_span stays DontInline, holds the four loads and calls nothing, as 8c04efc requires for the drivers that hang when the loads are inlined into the selection. Probe, loads, lookups, faults and stops are unchanged for every lane.

The contract test checks that read_bda_span calls load_bda_span outside every selection and loop, since CI runs on lavapipe, which does not show the fault.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added shader core/shader agc libSceAgc* fix error Closes an issue (Fixes #N) labels Nov 18, 2026
@domx4q

domx4q commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Ran the BDA suites on NVIDIA's proprietary Linux driver with the Khronos validation layer, since the description's layer run is on Windows.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 1f9ddd3783 merged onto main 1ccc399b17 with --no-ff, clean merge. Main baseline is a Release build of 1ccc399b17 on the same machine.

WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0 ANYPS5_REQUIRE_DISPLAY=1 \
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^(agc_driver_bda_device|agc_driver_host_import_failure_handles|agc_driver_bda_span_reads|agc_driver_bda_anchor_reads)$' -V
main 1ccc399b17 this PR
Result 4/4 passed 4/4 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 4 4
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

agc_driver_bda_device (which carries the new BdaContracts.cpp check) passes on both sides here; unlike the description's RTX 5090 run on Windows, main does not fail it on this machine. agc_driver_bda_device and agc_driver_host_import_failure_handles use "NVIDIA GeForce RTX 4090", and the two Selected GPU lines from agc_driver_bda_anchor_reads and agc_driver_bda_span_reads name the RTX 4090.

No new VUID- errors; all focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 7392 core/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp
PR 9508 core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp
PR 10193 core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp
PR 13928 core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp
PR 13929 core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp
PR 15555 core/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cpp
PR 16571 core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp
core/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cpp
PR 18106 core/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cpp
PR 18107 core/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cpp
PR 20519 core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp
PR 22424 core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp

@oneandonlydean

Copy link
Copy Markdown
Collaborator

I am reviewing 1f9ddd3. The change reads right to me: load_bda_span now runs for every lane, and lanes that are unmapped or unaligned pass mask 0, so they load nothing.

The open question is the driver. Main passes agc_driver_bda_device on a 5080 with 610.88 but fails it on a 5090 with 621.01, so the fault may follow the 621.x driver rather than Blackwell.

@zarmstrong, or anyone from #22773 with a Blackwell card: could you run this at exactly 1f9ddd3 and post the driver version? Ideally on a 621.x driver:
ctest --test-dir build -R "^(agc_driver_bda_device|agc_driver_bda_span_reads|agc_driver_pixel_interlock)$" --repeat until-fail:5 -V

On our side I am running the same tests and the flat and global load suites on an RTX 4090, plus a Windows run on an RTX 4050 laptop.

@milescoviello milescoviello left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 1f9ddd3783 by reading, and ran agc_driver_bda_device on 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.

  • main 8ba52d0287 and this PR merged onto it both pass agc_driver_bda_device 3 of 3 runs, so the uniform-call shape doesn't regress on Pascal.
  • Pascal doesn't show the Blackwell fault, so this only covers the no-regression side.

Reading SpirvBdaRead.cpp:

  • Lanes that fall back load nothing. The single load_bda_span call passes Select(wide, used, 0). With a used mask of 0, each of the four loads is inside its own EmitValueOrZeroIfCondition, so those lanes never form or dereference a pointer.
  • Inputs are unchanged. physical and firstBytes reaching the call for those lanes is harmless, since they're only used under the per-dword condition.
  • The result is the same as before. The wide lanes take loaded and the others run the unchanged dword fallback. The coherent variant goes through the same DefineBdaSpanReadFunction, so it gets the same shape.
  • The new contract in BdaContracts.cpp pins 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

@lazy-dev-77

Copy link
Copy Markdown
Contributor

Older-driver regression check on an RTX 4090, NVIDIA Linux driver 595.99.02. I compared the PR parent 8ba52d0287 with head 1f9ddd3783 in the same Ubuntu 26.04 container (GCC 15.2, Release).

On each revision, agc_driver_bda_device, agc_driver_bda_span_reads, and agc_driver_pixel_interlock each passed 5/5. agc_driver_scalar_wide_loads and all 14 agc_driver_flat_apertures_* partitions also passed, covering 126 flat-aperture rows per revision.

All 30 executions per revision used the 4090 with Khronos validation 1.4.341 loaded and the AnyPS5 shader cache disabled. No skips, device losses, or VUID- messages appeared. Both builds used the guest-memory comparison fallback because the container denied userfaultfd.

AI-assisted testing and reporting.

@zarmstrong

Copy link
Copy Markdown
Contributor Author

Ran at exactly 1f9ddd3783 on an NVIDIA GeForce RTX 5090, Windows 11 Pro 26200, driver 621.01, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363) and VK_LOADER_DEBUG=layer:

ctest --test-dir build -R "^(agc_driver_bda_device|agc_driver_bda_span_reads|agc_driver_pixel_interlock)$" --repeat until-fail:5 -V

parent 8ba52d0287 1f9ddd3783
agc_driver_bda_device fails on run 1 (an anchored BDA read differs from the same read through the lookups at anchor 0x7fff12340101 + 0 + (0), 32 bits, 4 dwords) 5/5
agc_driver_bda_span_reads 5/5 5/5
agc_driver_pixel_interlock 5/5 5/5

The layer was inserted in every run, there were no was not found but was requested lines, and neither side logged VUID- or SYNC-HAZARD-. All runs selected the RTX 5090.

On driver versus architecture, the reports so far:

GPU driver main
RTX 5090 (Blackwell) 621.01 fails
RTX 5080 (Blackwell) 621.14 fails (#21961, #22441)
RTX 5080 (Blackwell) 610.88 passes (your note)
RTX 4080 (Ada) 621.01 passes (#20870)
RTX 4090 (Ada) 620.70.06, 595.99.02 passes (above)

So it appears to need both Blackwell and a 621.x driver: 610.88 on Blackwell passes, and 621.01 on Ada passes.

AI-assisted: yes (Claude Code)

@thalesdot1dot1

Copy link
Copy Markdown
Contributor

Paired Windows/Blackwell validation on an NVIDIA GeForce RTX 5060 with driver 616.64. Windows 11 Home 25H2 (26200.9711), WinLibs GCC 15.2.0 r7, Release. I compared main at 67d3465feb9 with PR head 1f9ddd37833 merged onto the same base (29a77be4c81).

Test group main main + this PR
agc_driver_bda_device, additional repeated runs 10/10 10/10
Focused CTest suite 19/19 19/19

The suite covered agc_driver_bda_device, the three agc_driver_bda_span_reads variants, agc_driver_scalar_wide_loads, and all 14 agc_driver_flat_apertures parts. I used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer. The loader inserted validation layer 1.4.368 for every run, with zero VUID- or SYNC-HAZARD- messages.

The baseline already passes on this setup, so these results give regression coverage for driver 616.64. The original reproduction in #22773 used an RTX 5090 with 621.01. The two additional agc_shader_memory cases were excluded after objcopy failed while preparing their Windows executable.

AI-assisted: yes

@ThiagoShade

Copy link
Copy Markdown

A data point from another Blackwell card on a newer driver: on an RTX 5060 Ti with 621.24, agc_driver_bda_device fails 10 of 10 runs without this PR and passes 10 of 10 with it.

Build Result
8ba52d0287 (this PR's base) fails 10 of 10, ~0.16 s each: AGC graphics: an anchored BDA read differs from the same read through the lookups at anchor 0x7fff12340101 + 0 + (0), 32 bits, 4 dwords
1f9ddd3783 (this PR's head; its parent is 8ba52d0287) passes 10 of 10, ~0.7 s each

The failure message and anchor are the same as in #22773, so 621.24 still has the problem, at least on this card. It adds a row to the driver table above: RTX 5060 Ti (Blackwell), 621.24, main fails.

System: Windows 11 Pro for Workstations 10.0.26300, Intel Core i9-14900K, NVIDIA GeForce RTX 5060 Ti (10de:2d04), driver 621.24, WinLibs GCC 15.2.0 r7, Release. Using "NVIDIA GeForce RTX 5060 Ti" in every run. No validation layer (the Vulkan SDK is not installed here).

Steps, for each of the two commits, built in a separate checkout with -DBUILD_TESTING=ON, target agc_driver_bda_device_tests:

set ANYPS5_REQUIRE_VULKAN=1
set ANYPS5_NO_SHADER_CACHE=1
set ANYPS5_GPU=RTX 5060 Ti
ctest --test-dir build -R "^agc_driver_bda_device$" -V

Run 10 times in a row per build, on 2026-11-18.

AI-assisted: yes (Claude Code)

@Colewiz7

Copy link
Copy Markdown
Contributor

Head 1f9ddd3783 merged onto main 973026d9b0 as 607ba3ca3a, no conflict. Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, RX 7900 XT (gfx1100) and 7800X3D iGPU (gfx1036).

No new failures and no new validation messages on either GPU.

RX 7900 XT iGPU
full suite (6163 tests), new failures vs main none none
-R '^agc' (1936 tests) with the layer, new failures vs main none none
VUID- / SYNC-HAZARD lines 0 / 0 0 / 0

Layer runs used VK_LAYER_KHRONOS_validation 1.4.363.1 with VK_LOADER_DEBUG=layer and ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; the loader inserted the layer in every run, and the validation message set matches main.

AI-assisted: yes

@gugdun

gugdun commented Nov 19, 2026

Copy link
Copy Markdown

Verified on a third Blackwell card, under Linux, with a driver older than the one in the issue.

NVIDIA GeForce RTX 5060 Ti (10de:2d04), driver 620.70.06, Arch Linux, kernel 7.3.4-arch1-2, GCC 16.2.1, CMake 4.5.0, Release, BUILD_TESTING=ON, validation layer 1.4.363 (the loader log shows Insert instance layer "VK_LAYER_KHRONOS_validation" and no VUID- lines). This PR cherry-picked onto main 168921678f; no other changes.

agc_driver_bda_device, with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1:

build result
main 168921678f fails 5 of 5, AGC graphics: an anchored BDA read differs from the same read through the lookups at anchor 0x7fff12340101 + 0 + (0), 32 bits, 4 dwords
main + APS5_BDA_BYTE_READS=1 passes 5 of 5
this PR passes 10 of 10, the new contract checks included

This also puts the driver boundary below 621: 610.88 passes on an RTX 5080 (#22773), 620.70.06 fails on Linux on this card, 621.01 fails on the RTX 5090. The fault is not specific to the 621 series, and not to Windows.

ctest --test-dir build -R "agc|shader" -j8, 1,959 tests, same environment:

main this PR
tests 1959 1959
passed 1930 1932
failed agc_driver_bda_device, agc_driver_image_table_packed_guards agc_driver_image_table_packed_guards
skipped 27 27

agc_driver_image_table_packed_guards is not caused by this change: it fails 10 of 10 on main and 5 of 5 on this PR when it runs alone (it passed once inside a parallel run of this PR, so it is order-dependent on this GPU). It is the same failure as #22512; I added this card there.

Not tested: Windows, an AMD GPU, and driver 621.01.

AI-assisted: yes.

@eaglescoutmaster

Copy link
Copy Markdown
Contributor

RTX 5080 on driver 617.14, head 1f9ddd3783. agc_driver_bda_device, agc_driver_bda_span_reads and agc_driver_pixel_interlock: 3 of 3 on main and 3 of 3 with this PR. main does not fail on this driver (#22773), so this shows no regression on a driver below the failing range, not the fix itself. 22 neighbouring tests (bda device, span and anchor, scalar wide loads, 14 flat apertures) pass on both sides. Not run: the recorder-based bda tests.

Setup: base main afe88d44ad, the PR diff applied with git apply (clean), only the affected targets rebuilt. Windows 11 Pro build 26300, Intel Core i9-14900K, NVIDIA GeForce RTX 5080 (10de:2c02), driver 617.14, Vulkan API 1.4.351, WinLibs GCC 15.2.0 r7, Release. ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_GPU=RTX 5080. No validation layer installed, so no VUID- check. Another application was using the GPU during the runs.

AI-assisted: yes (Claude Code)

@XFlawless1

Copy link
Copy Markdown
Contributor

Confirmed on a second Blackwell card.

Windows 11 Pro (build 26300), WinLibs GCC 15.2.0 r7, Release, -DBUILD_TESTING=ON. NVIDIA GeForce RTX 5080 (Blackwell), driver 621.14, Vulkan 1.4.357; AMD Radeon integrated graphics (Ryzen 7 9800X3D, gfx1036), AMD driver 32.0.21042.62, Vulkan driver 2.0.353. ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (SDK 1.4.363; the loader's Insert instance layer "VK_LAYER_KHRONOS_validation" was confirmed with VK_LOADER_DEBUG=layer on the same build). The PR head was merged onto main ff63c72 with git merge --no-ff, as the CI build does; each test ran three times (--repeat until-fail:3) per GPU.

main ff63c72 this PR (1f9ddd3) merged
RTX 5080 agc_driver_bda_device fails: an anchored BDA read differs from the same read through the lookups at anchor 0x7fff12340101 + 0 + (0), 32 bits, 4 dwords passes 3/3
AMD gfx1036 passes passes 3/3

No VUID- messages in either run. So the fix holds on driver 621.14 as well as the 621.01 in #22773.

@PERRETJonatan

PERRETJonatan commented Nov 19, 2026 •

Copy link
Copy Markdown

Ran on an Ada Lovelace card, a generation the results above don't cover yet. main does not fail here, so like the Pascal and pre-621 Blackwell runs this shows no regression rather than the fix itself.

Setup: NVIDIA GeForce RTX 4070 Ti (AD104, 10de:2782), driver 620.70.06, Vulkan 1.4.357, CachyOS (Arch), kernel 7.3.4-1-cachyos, GCC 16.2.1, CMake 4.5.0, Ninja, Release, BUILD_TESTING=ON. Validation layer 1.4.363 with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1. Every log shows Insert instance layer "VK_LAYER_KHRONOS_validation" and none contains was not found but was requested by env var VK_INSTANCE_LAYERS.

Code: main 14f2b97bc4, and head 1f9ddd3783 merged alone onto it (git merge --no-ff, clean merge, same diff as the PR).

Tests main 14f2b97bc4 with 1f9ddd3783
bda|pixel_interlock (14 tests: agc_driver_bda_device, agc_driver_bda_span_reads and its _draw_pipeline/_plan_verify modes, agc_driver_bda_anchor_reads, agc_driver_pixel_interlock, agc_bda_atomics, agc_bda_staging, agc_bda_staging_bound, ...), 3 runs 3 of 3 pass, 0 VUID- 3 of 3 pass, 0 VUID-
^(agc|video_out|shader|guest_video) (2057 tests), 1 run 2057 pass, 0 VUID- 2057 pass, 0 VUID-

The only validation output in either full run is the same 65 Undefined-Value-ShaderOutputNotConsumed/OutputNotWritten warnings in the same 16 AGC tests, plus the VALIDATION-SETTINGS notice. The new read_bda_span/read_bda_span_coherent nesting check in agc_driver_bda_device passes with the PR.

I also read the diff before building: it changes only the SPIR-V emission in SpirvBdaRead.cpp and adds the SPIR-V walk in BdaContracts.cpp.

AI-assisted: yes (Claude Code). The builds and tests ran on my machine.

@u-instinct11

Copy link
Copy Markdown
Contributor

I checked whether the anchored read failure also occurs with validation off on an RTX 5090 Laptop (0x2c58, 621.01), using Intel Graphics (0x7d67, 101.8860) as a control on the same Windows 11 build 26200 machine. Base 34bd032 and the merge-base diff for head 1f9ddd3 were compiled and relinked using the same procedure. Vulkan was required, shader cache disabled, and the ICD pinned per adapter.

On NVIDIA, base failed the anchored 32-bit, four-dword read at 0x7fff12340101 in 3/3 ordinary runs and 3/3 validation runs. The PR passed all six. On Intel both revisions passed all six runs each. With only the new contract test on the unfixed backend, the call-nesting assertion failed before device creation, as expected. This isolates the regression check from driver execution.

The attachment contains the build recipe, hashes and 36 logs, including the contract controls. These comparisons establish that enabling validation is unnecessary to reproduce this failure on this laptop driver. AI-assisted (Claude and Codex).

AnyPS5-BDA-22774-verified.zip

@M4gnif1cus

Copy link
Copy Markdown

Tested on an NVIDIA Blackwell laptop GPU. This PR fixes agc_driver_bda_device here, adds no new failure and no new validation error.

The failing test, 3 runs each

Build Run 1 Run 2 Run 3
main 335fdd7 Failed Failed Failed
main 335fdd7 + this PR (1f9ddd3, git merge --no-ff, no conflicts) Passed Passed Passed

On main every run ends with:

AGC graphics: an anchored BDA read differs from the same read through the lookups at anchor 0x7fff12340101 + 0 + (0), 32 bits, 4 dwords

Graphics tests, one run each (ctest -j 8 --timeout 180 -R "agc|shader|bda|video_?out|recompiler|spirv", 2122 tests)

Build Failed Which
main 4 agc_driver_bda_device, agc_driver_msaa_dcc_unwatch, agc_driver_stencil_plane_memory, agc_storage_write_back_host_retile
main + this PR 3 the same without agc_driver_bda_device

The three remaining failures are the ones tracked in #22930, #22427 and #23708.

Validation (ctest -V -R "^agc_driver_bda_", 8 tests, with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer, layer 1.4.363 from the LunarG SDK)

Build Passed VUID- / SYNC-HAZARD- / UNASSIGNED- IDs
main 7 of 8 (agc_driver_bda_device fails) none
main + this PR 8 of 8 none

Both logs show Insert instance layer "VK_LAYER_KHRONOS_validation" for the seven tests that create a device (agc_driver_bda_device_selection_cpu creates none), and neither contains was not found but was requested by env var VK_INSTANCE_LAYERS.

  • GPU: NVIDIA GeForce RTX 5070 Ti Laptop GPU (vendor 0x10de, device 0x2f58), driver 621.14
  • CPU: Intel Core Ultra 9 275HX
  • OS: Windows 11 Pro, build 26300
  • Toolchain: WinLibs GCC 15.2.0 r7, Release
  • Environment for all runs: ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1

The builds and runs were driven with an AI assistant; the tables are measured output.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 1f9ddd378332b86aaace2a12056025d515b6a4d1 using the prepared review bundle and repo_read.py. I did not run build or test commands; no merged-preview check was performed.

Results

Check Result Note
Changed-line review passed Both changed files reviewed
Build and tests not run Author-reported results only
Negative control not run Not run in this review

Findings

Blocking

None.

Non-blocking

  • The new SPIR-V contract check covers coherent and non-coherent span reads without the stop-invocation variant. Consider adding that variant if it can be generated by 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.cpp and core/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cpp were read; files.json was 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.

@Mr-Fawx

Mr-Fawx commented Nov 21, 2026

Copy link
Copy Markdown

Tested on another machine: main at bb628f7722, with and without this PR. Both builds also carry a change that adds ANYPS5_GPU_INDEX (device selection by enumeration index, PR to follow), which is needed here to select the second of two RTX 5090s; it touches only device selection.

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7 (Release, BUILD_TESTING=ON). GPUs: NVIDIA GeForce RTX 5090 (Blackwell, driver 621.24, PCI 03:00.0) and AMD Radeon(TM) Graphics (gfx1036 iGPU of a Ryzen 9 9950X3D2, AMD Windows driver). Validation layer VK_LAYER_KHRONOS_validation 1.4.363 (Vulkan SDK).

main main + #22774
RTX 5090 agc_driver_bda_device fails 3 of 3 (an anchored BDA read differs from the same read through the lookups at anchor 0x7fff12340101 + 0 + (0), 32 bits, 4 dwords) passes 3 of 3
Radeon iGPU (gfx1036) passes 3 of 3 passes 3 of 3

With ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer, ctest -R '^agc_driver_bda_device$' -V passes on both GPUs; both logs show Insert instance layer "VK_LAYER_KHRONOS_validation", neither has was not found but was requested, and neither has a VUID- message.

All four of #22774, #22508, #22950 and #23751 applied together: every agc|shader|bda|spirv|videoout|recompiler test (2055) on the RTX 5090 passes except agc_driver_store_over_untracked (a pending storage result was stored over bytes the CPU wrote to untracked memory), which is intermittent: main alone 13 of 13 on the RTX 5090 and 2 of 5 on the Radeon; main with any one of the four PRs 7 or 8 of 8 on the RTX 5090; all four 7 of 8 on each GPU (1 of 5 right after a parallel ctest -j 20 run). The same test is listed as intermittent on an RTX 5090 in #24663. A first -j 20 pass of that set also timed out 31 tests and failed 5 others besides that one, with no device-lost error; all 36 passed when rerun with -j 4.

AI-assisted: yes (Claude Code ran the builds and tests and wrote this comment).

@andyohyeah

Copy link
Copy Markdown
Contributor

An Ampere row on an NVIDIA driver older than every one in "Not tested": RTX 3060 on Windows 572.16. This is the card #3291 hung on (with 591.86). No regression and no validation messages.

Setup: Windows 11 Pro 10.0.26200, Ryzen 9 5900X, NVIDIA GeForce RTX 3060 (10de:2504), driver 572.16, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. main ea07e039a9, and head 1f9ddd3783 merged onto it with git merge --no-ff (clean). Each log shows Selected GPU name=NVIDIA GeForce RTX 3060.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="RTX 3060" \
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest -R '^(agc_driver_bda_.*|agc_driver_scalar_wide_loads.*|agc_driver_flat_apertures_.*|agc_driver_flat_loads.*|agc_driver_global_loads.*|agc_driver_pixel_interlock.*)$' -V -j1

That selects 30 tests:

  • agc_driver_bda_device, _selection_cpu, agc_driver_bda_span_reads, _draw_pipeline and _plan_verify, and agc_driver_bda_anchor_reads.
  • agc_driver_scalar_wide_loads.
  • agc_driver_flat_apertures_0 to _13.
  • agc_driver_flat_loads, _x2_x3 and _x4, agc_driver_global_loads, _x2_x3 and _x4, and agc_driver_pixel_interlock.

All ten tests that hung in #3291 are in this set.

Each side ran 5 times. The validation layer is VK_LAYER_KHRONOS_validation 1.4.363.

main main + this PR
tests passed 150 of 150 (30 × 5) 150 of 150
Insert instance layer "VK_LAYER_KHRONOS_validation" 29 of 30 tests in every run* same
was not found but was requested 0 0
VUID- / SYNC-HAZARD- 0 0
device lost / Vulkan result -4 0 0

* The 30th, agc_driver_bda_device_selection_cpu, creates no Vulkan instance.

agc_driver_bda_device includes the new BdaContracts.cpp check, and it passes in all 5 runs. I did not run agc_shader_memory. Windows Defender quarantines agc_shader_memory_tests.exe on this machine as a false positive.

What this does not show: I did not build the shape from before 8c04efc, so I don't know whether 572.16 hangs the way 591.86 did. This shows no regression on an older driver; it does not show that the PR avoids a hang this driver has.

AI-assisted: yes (Claude Code)

@methmoussa

Copy link
Copy Markdown
Contributor

Tested on a second Blackwell card. This fixes agc_driver_bda_device there.

Setup: NVIDIA GeForce RTX 5060 Ti, driver 621.01 (32.0.16.2101), Windows 11 build 26300, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh r7), Release. Base main is 7bf7d80. This PR's head 1f9ddd3783 is merged on top with --no-ff.

main main + this PR
agc_driver_bda_device 0 / 6 pass 11 / 11 pass

Each column has 1 run with validation and the rest without.

On main every run fails with the message from #22773: AGC graphics: an anchored BDA read differs from the same read through the lookups at anchor 0x7fff12340101 + 0 + (0), 32 bits, 4 dwords.

Validation run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer with Vulkan SDK 1.4.363. Both logs show Insert instance layer "VK_LAYER_KHRONOS_validation" and neither has the "was not found but was requested" message. Neither log has a VUID- line.

Rest of the suite: I ran the full suite (ctest -j 12, 6,741 tests) on both trees. The only test that differs is agc_driver_bda_device, apart from one timeout. All 15 tests matching bda pass with the PR, except one whose executable Defender quarantined on both trees, as BUILD.md describes.

The timeout was guest_pthread_mutex_contention in the PR run. It passes 3 / 3 when run alone (about 10 s each), so I put it down to load.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 23, 2026
@methmoussa

Copy link
Copy Markdown
Contributor

This PR now conflicts with main, but only in the test file. SpirvBdaRead.cpp still merges cleanly. 1e26d58ca1 (perf(shader): loop the dword-by-dword fallback of a multi-dword BDA write over one dword store) added its own check at the end of RunBdaContractTests, in the same place as this PR's new CallNesting check. The resolution keeps both loops one after the other:

         AgcDriver::Graphics::Require(lookups == 2u && loops == 1u, "the dword-by-dword fallback of a " + std::to_string(dwords) + "-dword write has " + std::to_string(lookups) + " write lookups and " + std::to_string(loops) + " byte-loop calls, not one dword store looped over its dwords");
+    }
     for (const bool coherent : {false, true}) {

With that resolution, the fix still holds on current main:

Setup: NVIDIA GeForce RTX 5060 Ti, driver 621.01, Windows 11 build 26300, Ryzen 5 9600X, WinLibs GCC 15.2.0 r7, Release. main 38d22efc06, with head 1f9ddd3783 merged on top with --no-ff and the conflict resolved as above. Khronos validation layer 1.4.363.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="RTX 5060 Ti" \
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R 'agc_.*bda' -V

That pattern selects 13 tests. I ran it 3 times per build, and then ran agc_driver_bda_device alone 7 more times without the layer.

main main + this PR
agc_driver_bda_device 0 / 10 10 / 10
other 12 BDA tests 12 / 12 in each run 12 / 12 in each run
VUID- lines (validated runs) 0 0

Every validated log shows Using "NVIDIA GeForce RTX 5060 Ti" and Insert instance layer "VK_LAYER_KHRONOS_validation", and none shows was not found but was requested by env var VK_INSTANCE_LAYERS. On main, every failure is the #22773 message: an anchored BDA read differs from the same read through the lookups at anchor 0x7fff12340101 + 0 + (0), 32 bits, 4 dwords. Both contract checks pass with the PR: the new CallNesting check and the write-fallback check from main.

AI-assisted: yes (Claude Code)

# Conflicts:
#	core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 through repo_read.py.

Results

Check Result Note
Diff and changed files passed Both changed files read
Tests in this review not run GPU runs reported by author
Prepared-file inventory not run files.json was unavailable

Findings

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.json inventory was unavailable; manifest.json lists both changed files as included, and I read both.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 25, 2026
@zarmstrong

Copy link
Copy Markdown
Contributor Author

Thanks @oneandonlydean for merging main and resolving the test conflict.

Retested the merged head 27456456f4 on the RTX 5090 (driver 621.01, Windows 11, WinLibs GCC 15.2.0, validation layer 1.4.363, overlay layers disabled). The 18 tests matching agc_.*bda.*|agc_shader_memory.*|shader_memory_decoder_tolerance|agc_driver_pixel_interlock|agc_driver_scalar_wide_loads pass 3/3, with the layer inserted in all 12 Vulkan tests and no VUID- lines.

I'll send the stop-variant contract check @MarcZX10 suggested as a separate follow-up once this merges.

AI-assisted: yes (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* fix error Closes an issue (Fixes #N) shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agc_driver_bda_device fails on NVIDIA Blackwell (RTX 5090, 621.01): read_bda_span gives the lanes on its dword path other lanes' results