fix(shader): update per-invocation LDS without atomics #5160

Merged
nikowolf123 merged 5 commits from upstream-pr/5160 into main 2026-10-14 10:30:38 +00:00
nikowolf123 commented 2026-10-13 13:12:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-13T13:12:38Z.


What

Pixel, vertex-path and fetch programs keep LDS in an array in Function storage that belongs to one invocation (functionLds in SpirvAnalysis.cpp; only compute and mesh programs get Workgroup memory). Several LDS operations still used atomics on that array:

  • ds_write_b8, ds_write_b16, ds_write_b8_d16_hi and ds_write_b16_d16_hi (StoreSubwordInBounds) merged the byte or half into its dword with AtomicUpdate: an OpAtomicLoad, an OpAtomicCompareExchange loop with Workgroup scope and an OpMemoryBarrier with Workgroup scope. Only scratch took a plain load and store.
  • The 32-bit LDS atomics: Atomic32 (ds_add_u32, ds_sub_u32, the integer min/max, ds_and/or/xor_b32, ds_wrxchg_rtn_b32) emitted the native OpAtomic* and a Workgroup barrier. EmitAtomicUpdate (ds_inc_u32, ds_dec_u32) and SharedAtomicUpdate (ds_rsub_u32, ds_cmpst_b32, ds_cmpst_f32, ds_mskor_b32, ds_min/max_f32, ds_add_f32, ds_wrap_rtn_b32) emitted the AtomicUpdate loop.
  • ds_append and ds_consume on LDS (AppendConsume) emitted OpAtomicIAdd or OpAtomicISub.

Vulkan forbids both parts:

  • VUID-StandaloneSpirv-None-04686 (Vulkan-Docs v1.4.335): the pointer of every atomic instruction must be in Uniform, Workgroup, Image, StorageBuffer, PhysicalStorageBuffer or TaskPayloadWorkgroupEXT storage. Function is not in the list.
  • VUID-StandaloneSpirv-None-07321: Workgroup memory scope is only for the task, mesh, tessellation control and compute execution models.

SPIRV-Tools v2025.4, the submodule this repository builds, checks them in validate_atomics.cpp#L241-L262 and validate_scopes.cpp#L275-L295. With ANYPS5_ENABLE_SPIRV_TOOLS=ON, as in Linux CI, ValidateAndOptimizeSpirv rejected every such shader: SPIR-V validation before optimization failed: [VUID-StandaloneSpirv-None-04686] AtomicLoad: Vulkan spec only allows storage classes for atomic to be: Uniform, Workgroup, Image, StorageBuffer, PhysicalStorageBuffer or TaskPayloadWorkgroupEXT. With the option off, which is the default, the invalid module went to the driver.

The instructions do not need atomics in this model. In the RDNA 2 ISA guide (30 November 2020), section 12.13, DS_WRITE_B8 and DS_WRITE_B16 (opcodes 30 and 31, p. 193) store DATA[7:0] and DATA[15:0], and DS_WRITE_B8_D16_HI and DS_WRITE_B16_D16_HI (160 and 161, p. 204) store DATA[23:16] and DATA[31:16]. The atomics read one dword, write the new value and return the old one. Here the array belongs to one invocation, so nothing else can touch the dword between the load and the store.

  • InFunctionStorage(state, kind) (SpirvBufferAccess.cpp) is true for scratch, and for LDS that is neither in device memory nor in a compute or mesh program. EmitMemoryElementPointer now picks the storage class with it, so the two cannot disagree.
  • For such pointers, StoreSubwordInBounds, Atomic32, EmitAtomicUpdate, SharedAtomicUpdate and AppendConsume load the dword, compute the new value and store it, with no atomic and no barrier, as StoreSubwordInBounds and ApertureAtomic32 already do for scratch. They return the same old value as before. Atomic32 takes the new value from AtomicNext32, keyed on the SPIR-V atomic opcode. FlatAtomicNext32 now calls it for its eleven plain integer operations instead of repeating them.
  • Compute and mesh LDS, LDS in device memory, GDS and buffers take the same paths as before.
  • docs/dev/debt/shader.md gets an entry for the per-invocation model, which had none and which this change keeps. On the console one LDS region serves the whole wave (RDNA 2 ISA section 3.6.6, p. 18, and section 10.4, p. 96), so here a lane does not see another lane's LDS writes, and ds_append/ds_consume only update the first active lane's copy. The entry also says that none of this is measured on hardware.

No title is known to use these instructions in pixel, vertex or fetch programs.

Tested

Ubuntu 26.04 under WSL2, GCC 15.2.0, CMake 4.2.3, Ninja 1.13.2, configured like CI (Release, -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON, ccache), lavapipe from Mesa 26.0.8 (8-lane subgroups) with VK_ICD_FILENAMES=<lvp_icd json> ANYPS5_REQUIRE_VULKAN=1 GALLIUM_OVERRIDE_CPU_CAPS=avx, on main ff8fe4dbc:

  • agc_shader_memory, new verifyFunctionLdsUpdates: recompiles pixel and vertex programs, as wave64 and wave32, each with one of ds_write_b8, ds_write_b16, ds_write_b8_d16_hi, ds_write_b16_d16_hi, ds_add_u32, ds_inc_rtn_u32, ds_mskor_b32 and ds_append. It fails if an atomic takes a Function pointer, or if an atomic or OpMemoryBarrier uses Workgroup memory scope. With main's recompiler sources (git checkout ff8fe4dbc -- on the four changed recompiler files) all 32 recompiles throw the VUID 04686 error above (AtomicLoad, or AtomicIAdd for ds_add_u32 and ds_append). In a local probe with SPIR-V validation switched off, the scan finds 2 to 6 such instructions in each of the 32 modules, so the test also fails on main in builds without SPIR-V tools. With the fix all 32 compile and the scan finds none.
  • agc_driver_pixel_lds_read_modify_write (new, tests/execution/PixelLdsReadModifyWrite.cpp): draws a 64x8 target as wave64 and wave32, two passes each. Each pixel uses its own 16-byte LDS slot at (pixel index & 511) * 16 and fills it with ~pixel. It writes bytes and halves into it with all four sub-dword stores, leaving the other bytes of each dword in place. It then chains ds_add_rtn_u32, ds_inc_rtn_u32 and ds_mskor_rtn_b32 on one dword, and reads ds_append from a counter that every lane set to 0x1234. The four dwords and the four returned values are stored and compared, 4096 per draw, with values computed from the ISA descriptions. With main's recompiler sources the pixel shader fails to recompile (VUID 04686). With the fix all values match, in 0.2 s. The test needs no subgroup wider than the host's, so it runs on lavapipe, where agc_driver_pixel_lds and agc_driver_pixel_lds_lane_slots skip for lack of a 32-lane subgroup. Storing the unmerged value in the new Function branch of StoreSubwordInBounds makes it fail at pixel 0.
  • A local probe, not part of the PR, ran the same unit check over 53 DS opcodes: every 32-bit LDS atomic with and without return, the src2 forms, ds_condxchg32_rtn_b64, ds_append, ds_consume, the four sub-dword stores and five 64-bit LDS atomics, in pixel and vertex programs, wave64 and wave32. On main 48 of them fail validation with VUID 04686; the 64-bit atomics already used plain loads and stores. With the fix all 53 compile and the scan finds nothing.
  • The raw dwords of both test programs match llvm-mc 21.1.8 for gfx1013 and gfx1030. The one difference is the 64 in v_mad_u32_u24: a literal in the test, an inline constant in llvm-mc's output.
  • ctest -R 'agc_shader|agc_driver|shader|recompiler': 384 tests, 348 pass and 36 skip. main has 383 of them, with the same results, and lacks only the new test.
  • Full ctest: 1050 tests, 1007 pass and 43 skip. Per test this is the same as main (1049 tests, 1006 pass, the same 43 skips) plus the new test.
  • main's tools/check_conventions.py --base origin/main with this title and body passes.

Windows: not built. Not measured on AMD hardware, neither gfx1013 nor any PC RDNA 2 GPU. tools/hw-oracle runs compute kernels only, so it cannot run the pixel stage (HW_ORACLE.md). The values the GPU test expects do not depend on the stage, though. A reviewer with a gfx103x GPU can check them with the same instructions on one 16-byte slot per lane. Save this as body.s in the repository root:

  s_mov_b32 m0, 0xffff
  v_lshlrev_b32 v26, 4, v0
  v_not_b32 v27, v4
  v_mul_u32_u24 v28, 0xa5c3e1, v4
  v_mov_b32 v29, -1
  v_mov_b32 v30, 0xffff0000
  v_mov_b32 v31, 0
  v_mov_b32 v32, 0x1234
  ds_write_b32 v26, v27
  ds_write_b32 v26, v27 offset:4
  ds_write_b32 v26, v27 offset:8
  ds_write_b32 v26, v27 offset:12
  ds_write_b8 v26, v28
  ds_write_b8 v26, v4 offset:2
  ds_write_b16_d16_hi v26, v28 offset:6
  ds_write_b16 v26, v4 offset:8
  ds_write_b8_d16_hi v26, v28 offset:11
  ds_add_rtn_u32 v14, v26, v28 offset:12
  ds_inc_rtn_u32 v15, v26, v29 offset:12
  ds_mskor_rtn_b32 v16, v26, v30, v4 offset:12
  ds_write_b32 v31, v32 offset:8192
  ds_append v17 offset:8192
  s_waitcnt lgkmcnt(0)
  ds_read_b32 v10, v26
  ds_read_b32 v11, v26 offset:4
  ds_read_b32 v12, v26 offset:8
  ds_read_b32 v13, v26 offset:12
  s_waitcnt lgkmcnt(0)

Then run this from the same directory. It runs one wave64 of 64 rows and compares every row with the values PixelLdsReadModifyWrite.cpp expects:

import sys
sys.path.insert(0, "tools/hw-oracle")
from hw_oracle import run

body = open("body.s").read()
pixels = range(0, 512, 8)
rows = [(p, 0, 0, 0) for p in pixels]
results = run(body, rows, wave64=True, lds=16384, ieee=0, dx10_clamp=1, denorm32=0, denorm16=3, round32=0, round16=0, fp16_overflow=0)
for p, out in zip(pixels, results):
    i = ~p & 0xffffffff
    h = (0xa5c3e1 * p) & 0xffffffff
    a = (i + h) & 0xffffffff
    b = 0 if a == 0xffffffff else a + 1
    want = [(i & 0xff00ff00) | (h & 0xff) | ((p & 0xff) << 16), (i & 0xffff) | (h & 0xffff0000), (i & 0xff0000) | (p & 0xffff) | (((h >> 16) & 0xff) << 24), (b & 0xffff) | p, i, a, b, 0x1234]
    assert list(out[:8]) == want, (p, [hex(v) for v in out[:8]], [hex(v) for v in want])
print(f"{len(results)} rows match")

body.s assembles with the oracle's template for gfx1030 wave64. The script printed 64 rows match against a stand-in for run that models the LDS byte by byte, not against hardware.

Native Windows 11, WinLibs GCC 15.2.0, NVIDIA GeForce RTX 5080 (driver 616.92), on this branch rebased onto main 0f2683cb7 (16f63d8ed): agc_driver_pixel_lds_read_modify_write and agc_shader_memory pass 3 of 3 runs, and ctest -R 'agc_shader|agc_driver|shader|recompiler' passes 383 of 383.

Run by @kr4y4 on Windows 11 with the Windows CI configuration (SPIR-V tools off), on an RTX 4070 Laptop GPU (NVIDIA 595.97) and an Intel Raptor Lake-S iGPU (32.0.101.6790), head 16f63d8ed merged into main 3b94f923a (comment):

  • With the fix, agc_driver_pixel_lds_read_modify_write and agc_shader_memory pass 3 of 3 runs on both GPUs, and the full suite passes 1087 of 1087 on both.
  • With the recompiler files put back to main, the pixel test crashes inside NVIDIA's driver (0xc0000005 in nvoglv64.dll) and stores wrong values on Intel. Without SPIR-V tools nothing reports VUID 04686 first, so on Windows the invalid module reaches the driver.

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
  • 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
  • Unblocks: none
  • GPUs tested: lavapipe (Mesa 26.0.8, llvmpipe) on WSL2 Ubuntu 26.04; NVIDIA GeForce RTX 5080, driver 616.92, Windows 11
  • AI-assisted: yes. Written with Claude Code; I reviewed every line and ran the tests above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4843767615 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5160). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-13T13:12:38Z. --- ### What Pixel, vertex-path and fetch programs keep LDS in an array in `Function` storage that belongs to one invocation (`functionLds` in `SpirvAnalysis.cpp`; only compute and mesh programs get `Workgroup` memory). Several LDS operations still used atomics on that array: - `ds_write_b8`, `ds_write_b16`, `ds_write_b8_d16_hi` and `ds_write_b16_d16_hi` (`StoreSubwordInBounds`) merged the byte or half into its dword with `AtomicUpdate`: an `OpAtomicLoad`, an `OpAtomicCompareExchange` loop with `Workgroup` scope and an `OpMemoryBarrier` with `Workgroup` scope. Only scratch took a plain load and store. - The 32-bit LDS atomics: `Atomic32` (`ds_add_u32`, `ds_sub_u32`, the integer min/max, `ds_and/or/xor_b32`, `ds_wrxchg_rtn_b32`) emitted the native `OpAtomic*` and a `Workgroup` barrier. `EmitAtomicUpdate` (`ds_inc_u32`, `ds_dec_u32`) and `SharedAtomicUpdate` (`ds_rsub_u32`, `ds_cmpst_b32`, `ds_cmpst_f32`, `ds_mskor_b32`, `ds_min/max_f32`, `ds_add_f32`, `ds_wrap_rtn_b32`) emitted the `AtomicUpdate` loop. - `ds_append` and `ds_consume` on LDS (`AppendConsume`) emitted `OpAtomicIAdd` or `OpAtomicISub`. Vulkan forbids both parts: - [VUID-StandaloneSpirv-None-04686](https://github.com/KhronosGroup/Vulkan-Docs/blob/60a4ad187cf3be4ede658f0fae7dd392192a314b/appendices/spirvenv.adoc#L596-L600) (Vulkan-Docs v1.4.335): the pointer of every atomic instruction must be in `Uniform`, `Workgroup`, `Image`, `StorageBuffer`, `PhysicalStorageBuffer` or `TaskPayloadWorkgroupEXT` storage. `Function` is not in the list. - [VUID-StandaloneSpirv-None-07321](https://github.com/KhronosGroup/Vulkan-Docs/blob/60a4ad187cf3be4ede658f0fae7dd392192a314b/appendices/spirvenv.adoc#L205-L208): `Workgroup` memory scope is only for the task, mesh, tessellation control and compute execution models. SPIRV-Tools v2025.4, the submodule this repository builds, checks them in [validate_atomics.cpp#L241-L262](https://github.com/KhronosGroup/SPIRV-Tools/blob/7f2d9ee926f98fc77a3ed1e1e0f113b8c9c49458/source/val/validate_atomics.cpp#L241-L262) and [validate_scopes.cpp#L275-L295](https://github.com/KhronosGroup/SPIRV-Tools/blob/7f2d9ee926f98fc77a3ed1e1e0f113b8c9c49458/source/val/validate_scopes.cpp#L275-L295). With `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, as in Linux CI, `ValidateAndOptimizeSpirv` rejected every such shader: `SPIR-V validation before optimization failed: [VUID-StandaloneSpirv-None-04686] AtomicLoad: Vulkan spec only allows storage classes for atomic to be: Uniform, Workgroup, Image, StorageBuffer, PhysicalStorageBuffer or TaskPayloadWorkgroupEXT.` With the option off, which is the default, the invalid module went to the driver. The instructions do not need atomics in this model. In the [RDNA 2 ISA guide](https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf) (30 November 2020), section 12.13, `DS_WRITE_B8` and `DS_WRITE_B16` (opcodes 30 and 31, p. 193) store `DATA[7:0]` and `DATA[15:0]`, and `DS_WRITE_B8_D16_HI` and `DS_WRITE_B16_D16_HI` (160 and 161, p. 204) store `DATA[23:16]` and `DATA[31:16]`. The atomics read one dword, write the new value and return the old one. Here the array belongs to one invocation, so nothing else can touch the dword between the load and the store. - `InFunctionStorage(state, kind)` (`SpirvBufferAccess.cpp`) is true for scratch, and for LDS that is neither in device memory nor in a compute or mesh program. `EmitMemoryElementPointer` now picks the storage class with it, so the two cannot disagree. - For such pointers, `StoreSubwordInBounds`, `Atomic32`, `EmitAtomicUpdate`, `SharedAtomicUpdate` and `AppendConsume` load the dword, compute the new value and store it, with no atomic and no barrier, as `StoreSubwordInBounds` and `ApertureAtomic32` already do for scratch. They return the same old value as before. `Atomic32` takes the new value from `AtomicNext32`, keyed on the SPIR-V atomic opcode. `FlatAtomicNext32` now calls it for its eleven plain integer operations instead of repeating them. - Compute and mesh LDS, LDS in device memory, GDS and buffers take the same paths as before. - `docs/dev/debt/shader.md` gets an entry for the per-invocation model, which had none and which this change keeps. On the console one LDS region serves the whole wave (RDNA 2 ISA section 3.6.6, p. 18, and section 10.4, p. 96), so here a lane does not see another lane's LDS writes, and `ds_append`/`ds_consume` only update the first active lane's copy. The entry also says that none of this is measured on hardware. No title is known to use these instructions in pixel, vertex or fetch programs. ### Tested Ubuntu 26.04 under WSL2, GCC 15.2.0, CMake 4.2.3, Ninja 1.13.2, configured like CI (Release, `-DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON`, ccache), lavapipe from Mesa 26.0.8 (8-lane subgroups) with `VK_ICD_FILENAMES=<lvp_icd json> ANYPS5_REQUIRE_VULKAN=1 GALLIUM_OVERRIDE_CPU_CAPS=avx`, on `main` ff8fe4dbc: - `agc_shader_memory`, new `verifyFunctionLdsUpdates`: recompiles pixel and vertex programs, as wave64 and wave32, each with one of `ds_write_b8`, `ds_write_b16`, `ds_write_b8_d16_hi`, `ds_write_b16_d16_hi`, `ds_add_u32`, `ds_inc_rtn_u32`, `ds_mskor_b32` and `ds_append`. It fails if an atomic takes a `Function` pointer, or if an atomic or `OpMemoryBarrier` uses `Workgroup` memory scope. With `main`'s recompiler sources (`git checkout ff8fe4dbc --` on the four changed recompiler files) all 32 recompiles throw the VUID 04686 error above (`AtomicLoad`, or `AtomicIAdd` for `ds_add_u32` and `ds_append`). In a local probe with SPIR-V validation switched off, the scan finds 2 to 6 such instructions in each of the 32 modules, so the test also fails on `main` in builds without SPIR-V tools. With the fix all 32 compile and the scan finds none. - `agc_driver_pixel_lds_read_modify_write` (new, `tests/execution/PixelLdsReadModifyWrite.cpp`): draws a 64x8 target as wave64 and wave32, two passes each. Each pixel uses its own 16-byte LDS slot at `(pixel index & 511) * 16` and fills it with `~pixel`. It writes bytes and halves into it with all four sub-dword stores, leaving the other bytes of each dword in place. It then chains `ds_add_rtn_u32`, `ds_inc_rtn_u32` and `ds_mskor_rtn_b32` on one dword, and reads `ds_append` from a counter that every lane set to 0x1234. The four dwords and the four returned values are stored and compared, 4096 per draw, with values computed from the ISA descriptions. With `main`'s recompiler sources the pixel shader fails to recompile (VUID 04686). With the fix all values match, in 0.2 s. The test needs no subgroup wider than the host's, so it runs on lavapipe, where `agc_driver_pixel_lds` and `agc_driver_pixel_lds_lane_slots` skip for lack of a 32-lane subgroup. Storing the unmerged value in the new `Function` branch of `StoreSubwordInBounds` makes it fail at pixel 0. - A local probe, not part of the PR, ran the same unit check over 53 DS opcodes: every 32-bit LDS atomic with and without return, the `src2` forms, `ds_condxchg32_rtn_b64`, `ds_append`, `ds_consume`, the four sub-dword stores and five 64-bit LDS atomics, in pixel and vertex programs, wave64 and wave32. On `main` 48 of them fail validation with VUID 04686; the 64-bit atomics already used plain loads and stores. With the fix all 53 compile and the scan finds nothing. - The raw dwords of both test programs match `llvm-mc` 21.1.8 for gfx1013 and gfx1030. The one difference is the 64 in `v_mad_u32_u24`: a literal in the test, an inline constant in `llvm-mc`'s output. - `ctest -R 'agc_shader|agc_driver|shader|recompiler'`: 384 tests, 348 pass and 36 skip. `main` has 383 of them, with the same results, and lacks only the new test. - Full `ctest`: 1050 tests, 1007 pass and 43 skip. Per test this is the same as `main` (1049 tests, 1006 pass, the same 43 skips) plus the new test. - `main`'s `tools/check_conventions.py --base origin/main` with this title and body passes. Windows: not built. Not measured on AMD hardware, neither gfx1013 nor any PC RDNA 2 GPU. `tools/hw-oracle` runs compute kernels only, so it cannot run the pixel stage ([HW_ORACLE.md](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/HW_ORACLE.md)). The values the GPU test expects do not depend on the stage, though. A reviewer with a gfx103x GPU can check them with the same instructions on one 16-byte slot per lane. Save this as `body.s` in the repository root: ``` s_mov_b32 m0, 0xffff v_lshlrev_b32 v26, 4, v0 v_not_b32 v27, v4 v_mul_u32_u24 v28, 0xa5c3e1, v4 v_mov_b32 v29, -1 v_mov_b32 v30, 0xffff0000 v_mov_b32 v31, 0 v_mov_b32 v32, 0x1234 ds_write_b32 v26, v27 ds_write_b32 v26, v27 offset:4 ds_write_b32 v26, v27 offset:8 ds_write_b32 v26, v27 offset:12 ds_write_b8 v26, v28 ds_write_b8 v26, v4 offset:2 ds_write_b16_d16_hi v26, v28 offset:6 ds_write_b16 v26, v4 offset:8 ds_write_b8_d16_hi v26, v28 offset:11 ds_add_rtn_u32 v14, v26, v28 offset:12 ds_inc_rtn_u32 v15, v26, v29 offset:12 ds_mskor_rtn_b32 v16, v26, v30, v4 offset:12 ds_write_b32 v31, v32 offset:8192 ds_append v17 offset:8192 s_waitcnt lgkmcnt(0) ds_read_b32 v10, v26 ds_read_b32 v11, v26 offset:4 ds_read_b32 v12, v26 offset:8 ds_read_b32 v13, v26 offset:12 s_waitcnt lgkmcnt(0) ``` Then run this from the same directory. It runs one wave64 of 64 rows and compares every row with the values `PixelLdsReadModifyWrite.cpp` expects: ```python import sys sys.path.insert(0, "tools/hw-oracle") from hw_oracle import run body = open("body.s").read() pixels = range(0, 512, 8) rows = [(p, 0, 0, 0) for p in pixels] results = run(body, rows, wave64=True, lds=16384, ieee=0, dx10_clamp=1, denorm32=0, denorm16=3, round32=0, round16=0, fp16_overflow=0) for p, out in zip(pixels, results): i = ~p & 0xffffffff h = (0xa5c3e1 * p) & 0xffffffff a = (i + h) & 0xffffffff b = 0 if a == 0xffffffff else a + 1 want = [(i & 0xff00ff00) | (h & 0xff) | ((p & 0xff) << 16), (i & 0xffff) | (h & 0xffff0000), (i & 0xff0000) | (p & 0xffff) | (((h >> 16) & 0xff) << 24), (b & 0xffff) | p, i, a, b, 0x1234] assert list(out[:8]) == want, (p, [hex(v) for v in out[:8]], [hex(v) for v in want]) print(f"{len(results)} rows match") ``` `body.s` assembles with the oracle's template for gfx1030 wave64. The script printed `64 rows match` against a stand-in for `run` that models the LDS byte by byte, not against hardware. Native Windows 11, WinLibs GCC 15.2.0, NVIDIA GeForce RTX 5080 (driver 616.92), on this branch rebased onto `main` 0f2683cb7 (16f63d8ed): `agc_driver_pixel_lds_read_modify_write` and `agc_shader_memory` pass 3 of 3 runs, and `ctest -R 'agc_shader|agc_driver|shader|recompiler'` passes 383 of 383. Run by @kr4y4 on Windows 11 with the Windows CI configuration (SPIR-V tools off), on an RTX 4070 Laptop GPU (NVIDIA 595.97) and an Intel Raptor Lake-S iGPU (32.0.101.6790), head 16f63d8ed merged into `main` 3b94f923a ([comment](https://github.com/boykopovar/AnyPS5/pull/5160#issuecomment-6150235081)): - With the fix, `agc_driver_pixel_lds_read_modify_write` and `agc_shader_memory` pass 3 of 3 runs on both GPUs, and the full suite passes 1087 of 1087 on both. - With the recompiler files put back to `main`, the pixel test crashes inside NVIDIA's driver (`0xc0000005` in `nvoglv64.dll`) and stores wrong values on Intel. Without SPIR-V tools nothing reports VUID 04686 first, so on Windows the invalid module reaches the driver. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: lavapipe (Mesa 26.0.8, llvmpipe) on WSL2 Ubuntu 26.04; NVIDIA GeForce RTX 5080, driver 616.92, Windows 11 - [x] AI-assisted: yes. Written with Claude Code; I reviewed every line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-13 14:08:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T14:08:44Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#5492 docs/dev/debt/shader.md L102
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147450117 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5160#issuecomment-6147450117). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T14:08:44Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5492 | `docs/dev/debt/shader.md` [L102](https://github.com/boykopovar/AnyPS5/blob/6ade14f52de652028a621e8fc38c20c0cb3f71a7/docs/dev/debt/shader.md#L102) | | |
kr4y4 commented 2026-10-13 16:28:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-13T16:28:51Z.


First Windows build and hardware run. With the fix both GPUs pass. Without it, main's pixel shader crashes NVIDIA's driver and gives wrong values on Intel. This build has no SPIR-V tools, so nothing reports VUID 04686 first.

Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, Windows CI configure flags (ANYPS5_ENABLE_SPIRV_TOOLS off), an RTX 4070 Laptop GPU (NVIDIA 595.97) and an Intel Raptor Lake-S iGPU (32.0.101.6790). The head 16f63d8ed merged into main 3b94f923a.

  • With the fix: agc_driver_pixel_lds_read_modify_write, agc_shader_memory and the shader tests next to it pass 3 of 3 runs on both GPUs. The full suite passes 1087 of 1087 on both (7 skipped on NVIDIA, 34 on Intel).
  • With the four recompiler files put back to main:
    • agc_shader_memory fails on both with function LDS: ds_write_b8 in a pixel wave64 program uses an atomic on a Function pointer or a Workgroup memory scope.
    • NVIDIA: agc_driver_pixel_lds_read_modify_write crashes after printing pixel LDS read-modify-write wave64, with 0xc0000005 at nvoglv64.dll+0x17f5ad (a read of 0x8).
    • Intel: it runs and fails with pixel 0 ds_write_b8 dword expected 4278255360 got 4294967295. The dword still holds the ~pixel fill (0xffffffff, expected 0xff00ff00).

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150235081 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5160#issuecomment-6150235081). Originally posted by [kr4y4](https://github.com/kr4y4) on 2026-10-13T16:28:51Z. --- First Windows build and hardware run. With the fix both GPUs pass. Without it, `main`'s pixel shader crashes NVIDIA's driver and gives wrong values on Intel. This build has no SPIR-V tools, so nothing reports VUID 04686 first. Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, Windows CI configure flags (`ANYPS5_ENABLE_SPIRV_TOOLS` off), an RTX 4070 Laptop GPU (NVIDIA 595.97) and an Intel Raptor Lake-S iGPU (32.0.101.6790). The head 16f63d8ed merged into `main` 3b94f923a. - With the fix: `agc_driver_pixel_lds_read_modify_write`, `agc_shader_memory` and the shader tests next to it pass 3 of 3 runs on both GPUs. The full suite passes 1087 of 1087 on both (7 skipped on NVIDIA, 34 on Intel). - With the four recompiler files put back to `main`: - `agc_shader_memory` fails on both with `function LDS: ds_write_b8 in a pixel wave64 program uses an atomic on a Function pointer or a Workgroup memory scope`. - NVIDIA: `agc_driver_pixel_lds_read_modify_write` crashes after printing `pixel LDS read-modify-write wave64`, with `0xc0000005` at `nvoglv64.dll+0x17f5ad` (a read of 0x8). - Intel: it runs and fails with `pixel 0 ds_write_b8 dword expected 4278255360 got 4294967295`. The dword still holds the `~pixel` fill (0xffffffff, expected 0xff00ff00). Written with AI assistance.
nikowolf123 commented 2026-10-13 16:35:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-13T16:35:01Z.


Thank you. The NVIDIA crash and the wrong Intel values without the fix are the hardware consequence this PR was missing: with SPIR-V tools off, as in the Windows CI configuration, the invalid module goes straight to the driver. I added your run to the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150348565 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5160#issuecomment-6150348565). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-13T16:35:01Z. --- Thank you. The NVIDIA crash and the wrong Intel values without the fix are the hardware consequence this PR was missing: with SPIR-V tools off, as in the Windows CI configuration, the invalid module goes straight to the driver. I added your run to the description.
nikowolf123 commented 2026-10-14 07:13:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-14T07:13:47Z.


Closing this following the request on #4926 to hold off on pull requests that do not name a title needing the change while the queue is this long. The branch stays; if a title stops on this on current main, I will reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162996763 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5160#issuecomment-6162996763). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-14T07:13:47Z. --- Closing this following the request on #4926 to hold off on pull requests that do not name a title needing the change while the queue is this long. The branch stays; if a title stops on this on current `main`, I will reopen with the title ID and the log line.
oneandonlydean commented 2026-10-14 09:15:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T09:15:50Z.


Reopened, like #4926 and #5028: atomics on per-invocation Function LDS in pixel and vertex programs aren't valid Vulkan, so this is worth having without a title. It still merges cleanly on current main and its tests pass here; running the full build now. @adriadam10 heads-up since it's in core/shader/.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6165010586 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5160#issuecomment-6165010586). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T09:15:50Z. --- Reopened, like #4926 and #5028: atomics on per-invocation `Function` LDS in pixel and vertex programs aren't valid Vulkan, so this is worth having without a title. It still merges cleanly on current `main` and its tests pass here; running the full build now. @adriadam10 heads-up since it's in `core/shader/`.
oneandonlydean commented 2026-10-14 09:43:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T09:43:14Z.


The Linux timeout came from ds_append/ds_consume: FunctionLdsDwords gave up on their M0 operand, so the per-pixel LDS array was declared at the full 32 KiB, and llvmpipe on CI needs over 5 s to compile that during the draw. Pushed a fix that sizes it by the counter's offset (with a unit test) and a smaller test footprint; the results were right before too.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6165487823 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5160#issuecomment-6165487823). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T09:43:14Z. --- The Linux timeout came from `ds_append`/`ds_consume`: `FunctionLdsDwords` gave up on their M0 operand, so the per-pixel LDS array was declared at the full 32 KiB, and llvmpipe on CI needs over 5 s to compile that during the draw. Pushed a fix that sizes it by the counter's offset (with a unit test) and a smaller test footprint; the results were right before too.
oneandonlydean commented 2026-10-14 10:09:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T10:09:33Z.


One more: since #4806 retained SPIR-V is a span on main, so the new test's word check now takes a span; it builds against main with SPIRV-Tools on and the shader tests pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6165955656 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5160#issuecomment-6165955656). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T10:09:33Z. --- One more: since #4806 retained SPIR-V is a span on `main`, so the new test's word check now takes a span; it builds against `main` with SPIRV-Tools on and the shader tests pass.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5160
No description provided.