fix(shader): initialize LDS lock from one invocation #6670

Merged
MarcZX10 merged 1 commit from upstream-pr/6670 into main 2026-10-19 08:45:40 +00:00
MarcZX10 commented 2026-10-16 03:37:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T03:37:45Z.


What

LockedLdsUpdate uses a workgroup-memory word as a spinlock. Its entry code currently emits an unguarded OpStore 0 to that word, so every invocation in the workgroup writes the same location before the barrier. Those unsynchronized non-atomic writes are a data race. The AMD Windows compiler hang reported in #6666 is consistent with this invalid initialization pattern, though I have not reproduced that hardware-specific hang with this change.

Only local invocation 0 now initializes the lock. A workgroup barrier still makes the initialized value visible before any invocation attempts to acquire it. The SPIR-V regression test checks that the lock's zero store is guarded by LocalInvocationIndex == 0 and has a negative control for the prior unguarded form.

Related: #6666.

Tested

  • Linux x86-64, GCC 12.2: compiled the changed emitter files and test, linked agc_spirv_lds_atomic_lock_tests against the configured Linux build artifacts, and ran it successfully.
  • Negative control: the test fails when the old unguarded initialization is substituted.
  • python3 tools/check_conventions.py --base upstream/main --head HEAD and git diff --check pass.
  • A clean CMake configure could not complete because this worktree has no populated SDL2 submodule and the host lacks XRandR development files.
  • Not tested: the reported AMD Windows GPU runtime case.

Checklist

  • Based on current main; no other open PR implements this lock initialization
  • 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 documented
  • No notes, investigation files or images added to the repository
  • No new third-party code
  • Generic behavior, not title-specific
  • Depends on: none
  • Unblocks: none
  • GPUs tested: none; GPU execution was not available
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4883119222 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6670). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T03:37:45Z. --- ### What `LockedLdsUpdate` uses a workgroup-memory word as a spinlock. Its entry code currently emits an unguarded `OpStore 0` to that word, so every invocation in the workgroup writes the same location before the barrier. Those unsynchronized non-atomic writes are a data race. The AMD Windows compiler hang reported in #6666 is consistent with this invalid initialization pattern, though I have not reproduced that hardware-specific hang with this change. Only local invocation 0 now initializes the lock. A workgroup barrier still makes the initialized value visible before any invocation attempts to acquire it. The SPIR-V regression test checks that the lock's zero store is guarded by `LocalInvocationIndex == 0` and has a negative control for the prior unguarded form. Related: #6666. ### Tested - Linux x86-64, GCC 12.2: compiled the changed emitter files and test, linked `agc_spirv_lds_atomic_lock_tests` against the configured Linux build artifacts, and ran it successfully. - Negative control: the test fails when the old unguarded initialization is substituted. - `python3 tools/check_conventions.py --base upstream/main --head HEAD` and `git diff --check` pass. - A clean CMake configure could not complete because this worktree has no populated SDL2 submodule and the host lacks XRandR development files. - Not tested: the reported AMD Windows GPU runtime case. ### Checklist - [x] Based on current `main`; no other open PR implements this lock initialization - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are documented - [x] No notes, investigation files or images added to the repository - [x] No new third-party code - [x] Generic behavior, not title-specific - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: none; GPU execution was not available - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-16 04:34:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T04:34:53Z.


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
PR 6976 core/libs/prx/libSceAgcDriver/tests/SpirvLdsAtomicLock.cpp L30, L65, L69, L97

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 5500 core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6235 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6612 core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6683 core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6762 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6941 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6947 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 7201 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 7332 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 7642 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6208161875 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6670#issuecomment-6208161875). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-16T04:34:53Z. --- <!-- 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 | |---|---|---|---| | [PR 6976](https://www.github.com/boykopovar/AnyPS5/pull/6976) | `core/libs/prx/libSceAgcDriver/tests/SpirvLdsAtomicLock.cpp` [L30](https://github.com/boykopovar/AnyPS5/blob/fb0dc118f3380db5c8b583b0c8f7577dfcbca059/core/libs/prx/libSceAgcDriver/tests/SpirvLdsAtomicLock.cpp#L30), [L65](https://github.com/boykopovar/AnyPS5/blob/fb0dc118f3380db5c8b583b0c8f7577dfcbca059/core/libs/prx/libSceAgcDriver/tests/SpirvLdsAtomicLock.cpp#L65), [L69](https://github.com/boykopovar/AnyPS5/blob/fb0dc118f3380db5c8b583b0c8f7577dfcbca059/core/libs/prx/libSceAgcDriver/tests/SpirvLdsAtomicLock.cpp#L69), [L97](https://github.com/boykopovar/AnyPS5/blob/fb0dc118f3380db5c8b583b0c8f7577dfcbca059/core/libs/prx/libSceAgcDriver/tests/SpirvLdsAtomicLock.cpp#L97) | | | 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 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6612](https://www.github.com/boykopovar/AnyPS5/pull/6612) | `core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6683](https://www.github.com/boykopovar/AnyPS5/pull/6683) | `core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6762](https://www.github.com/boykopovar/AnyPS5/pull/6762) | `core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6941](https://www.github.com/boykopovar/AnyPS5/pull/6941) | `core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` |
veosett commented 2026-10-16 06:13:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by veosett on 2026-10-16T06:13:54Z.


Follow-up investigation of #6666 on the same RX 6900 XT, starting from PR head 4864a748022df4fb673202a0c1f430dac339ed10 (main 5d9dcc42d2ec5401aebd089028b8d4d7410a77b4). This narrows the failure; it is not a proposed fix.

A reduced copy of the existing uniform kernel gives these Windows results:

Workgroup / guest wave Operations per thread Result
64 / 32 and 64 / 64 16 mixed 32/64-bit exact
128 / 32 and 128 / 64 16 mixed 32/64-bit no output written
128 / 32 16 64-bit only no output written
128 / 32 16 32-bit only exact
128 / 32 one mixed 32/64-bit pair no output written

Requiring a physical 32-lane compute subgroup does not remove the failure. Replacing the initial zero stores with atomic stores does not remove it either. The reduced fixture checks every dispatched lane and unchanged sentinels outside the workgroup's output.

Linux/lavapipe controls at the same PR head pass for 64, 128 and 256 threads with one mixed pair and for 128 threads / guest wave64 with one 64-bit operation.

Driver ISA observation. With a temporary local capture hook using VK_KHR_pipeline_executable_properties, the 128-thread module contains s_barrier while the workgroup lock is still held:

ds_cmpst_rtn_b32 ... offset:16
s_waitcnt lgkmcnt(0)
... branch on successful acquisition ...
ds_read_b64 ...
... 64-bit addition ...
ds_write_b64 ...
s_waitcnt lgkmcnt(0)
s_barrier
ds_write_b32 ... offset:16

The corresponding SPIR-V critical section ends in OpAtomicStore with Workgroup scope and Release | WorkgroupMemory semantics; it has no OpControlBarrier there. The 64-thread native module omits that internal s_barrier. Waiting at a collective barrier while holding a lock is a plausible explanation of this multi-wave stall; this observation is not a Vulkan conformance verdict or proof of one hardware scheduling mechanism.

As a diagnostic only, clearing the acquire/release operands of the lock makes the reduced 128-thread 64-bit-only case produce the exact result. The mixed case still stalls: its 32-bit update also emits OpMemoryBarrier inside the lock. This relaxed experiment is not a safe correction. SPIR-V memory semantics and the Vulkan memory model require preserving the relevant ordering and visibility guarantees.

Explicit memory barriers, broader atomic scope and the existing buffer-backed LDS path completed some probes with incorrect per-lane results, so none is being proposed as a fix. The saved diagnostic modules were checked with the project's bundled SPIRV-Tools validator. The ISA-capture and optional device-feature hooks were local diagnostics, not part of the clean PR head; they have been removed from the source after capture.

Environment: Windows 11, RX 6900 XT (RDNA 2, 1002:73bf), AMD proprietary driver 25.10.30.02 / Vulkan 1.4.315, WinLibs GCC 15.2.0 r7, Release, bundled dependencies, SPIRV-Tools ON. Linux: Ubuntu 24.04 WSL2, GCC 13.3, lavapipe/Mesa 25.2.8, LLVM 20.1.2. AnyPS5 shader cache disabled, Vulkan required, selected GPU verified. User driver cache was left intact; an additional changed-generator-word control still stalled.

No game, console or other GPU/driver run. The full CTest suite was not run. No production fix is claimed. Logs, diagnostic source, SPIR-V and ISA captures retained locally.

AI-assisted: yes (Codex). Builds and runs were executed on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6209338072 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6670#issuecomment-6209338072). Originally posted by [veosett](https://github.com/veosett) on 2026-10-16T06:13:54Z. --- Follow-up investigation of #6666 on the same RX 6900 XT, starting from PR head `4864a748022df4fb673202a0c1f430dac339ed10` (main `5d9dcc42d2ec5401aebd089028b8d4d7410a77b4`). This narrows the failure; it is not a proposed fix. A reduced copy of the existing uniform kernel gives these Windows results: | Workgroup / guest wave | Operations per thread | Result | | --- | --- | --- | | 64 / 32 and 64 / 64 | 16 mixed 32/64-bit | exact | | 128 / 32 and 128 / 64 | 16 mixed 32/64-bit | no output written | | 128 / 32 | 16 64-bit only | no output written | | 128 / 32 | 16 32-bit only | exact | | 128 / 32 | one mixed 32/64-bit pair | no output written | Requiring a physical 32-lane compute subgroup does not remove the failure. Replacing the initial zero stores with atomic stores does not remove it either. The reduced fixture checks every dispatched lane and unchanged sentinels outside the workgroup's output. Linux/lavapipe controls at the same PR head pass for 64, 128 and 256 threads with one mixed pair and for 128 threads / guest wave64 with one 64-bit operation. **Driver ISA observation.** With a temporary local capture hook using `VK_KHR_pipeline_executable_properties`, the 128-thread module contains `s_barrier` while the workgroup lock is still held: ```text ds_cmpst_rtn_b32 ... offset:16 s_waitcnt lgkmcnt(0) ... branch on successful acquisition ... ds_read_b64 ... ... 64-bit addition ... ds_write_b64 ... s_waitcnt lgkmcnt(0) s_barrier ds_write_b32 ... offset:16 ``` The corresponding SPIR-V critical section ends in `OpAtomicStore` with Workgroup scope and `Release | WorkgroupMemory` semantics; it has no `OpControlBarrier` there. The 64-thread native module omits that internal `s_barrier`. Waiting at a collective barrier while holding a lock is a plausible explanation of this multi-wave stall; this observation is not a Vulkan conformance verdict or proof of one hardware scheduling mechanism. As a diagnostic only, clearing the acquire/release operands of the lock makes the reduced 128-thread 64-bit-only case produce the exact result. The mixed case still stalls: its 32-bit update also emits `OpMemoryBarrier` inside the lock. This relaxed experiment is not a safe correction. [SPIR-V memory semantics](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html) and the [Vulkan memory model](https://docs.vulkan.org/spec/latest/appendices/memorymodel.html) require preserving the relevant ordering and visibility guarantees. Explicit memory barriers, broader atomic scope and the existing buffer-backed LDS path completed some probes with incorrect per-lane results, so none is being proposed as a fix. The saved diagnostic modules were checked with the project's bundled SPIRV-Tools validator. The ISA-capture and optional device-feature hooks were local diagnostics, not part of the clean PR head; they have been removed from the source after capture. Environment: Windows 11, RX 6900 XT (RDNA 2, 1002:73bf), AMD proprietary driver 25.10.30.02 / Vulkan 1.4.315, WinLibs GCC 15.2.0 r7, Release, bundled dependencies, SPIRV-Tools ON. Linux: Ubuntu 24.04 WSL2, GCC 13.3, lavapipe/Mesa 25.2.8, LLVM 20.1.2. AnyPS5 shader cache disabled, Vulkan required, selected GPU verified. User driver cache was left intact; an additional changed-generator-word control still stalled. No game, console or other GPU/driver run. The full CTest suite was not run. No production fix is claimed. Logs, diagnostic source, SPIR-V and ISA captures retained locally. AI-assisted: yes (Codex). Builds and runs were executed on this machine.
tezzgod74 commented 2026-10-16 10:02:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tezzgod74 on 2026-10-16T10:02:10Z.


Ran it on the RDNA 2 iGPU from #6666. This PR at 4864a7480 (on main 5d9dcc42d), Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release:

Test Ryzen 9 7950X iGPU (RDNA 2, 0x164e, 32.0.21045.5002) RX 9060 XT (RDNA 4, 32.0.31041.1004)
agc_spirv_lds_atomic_lock pass pass
agc_driver_lds_mixed_width_atomics, 3 runs fails 3/3, 4.4-4.6 s each, lane 0 read 0xdeadbeefdeadbeef passes 3/3

Same as main, so the per-invocation lock store isn't what makes the dispatch run past ~4 s here. Every invocation stores the same zero before the workgroup barrier, so no lane can take the lock until those stores are done. The change still removes a data race, though.

This matches @veosett's RX 6900 XT runs above on a second RDNA 2 device, here an APU on the same 21045 driver branch. Their ISA capture (an s_barrier emitted between the critical section's ds_write_b64 and the lock release, only in the 128-thread module) fits the threshold in #6666 exactly.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6213042621 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6670#issuecomment-6213042621). Originally posted by [tezzgod74](https://github.com/tezzgod74) on 2026-10-16T10:02:10Z. --- Ran it on the RDNA 2 iGPU from #6666. This PR at 4864a7480 (on `main` 5d9dcc42d), Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release: | Test | Ryzen 9 7950X iGPU (RDNA 2, 0x164e, 32.0.21045.5002) | RX 9060 XT (RDNA 4, 32.0.31041.1004) | |---|---|---| | `agc_spirv_lds_atomic_lock` | pass | pass | | `agc_driver_lds_mixed_width_atomics`, 3 runs | fails 3/3, 4.4-4.6 s each, `lane 0 read 0xdeadbeefdeadbeef` | passes 3/3 | Same as `main`, so the per-invocation lock store isn't what makes the dispatch run past ~4 s here. Every invocation stores the same zero before the workgroup barrier, so no lane can take the lock until those stores are done. The change still removes a data race, though. This matches @veosett's RX 6900 XT runs above on a second RDNA 2 device, here an APU on the same 21045 driver branch. Their ISA capture (an `s_barrier` emitted between the critical section's `ds_write_b64` and the lock release, only in the 128-thread module) fits the threshold in #6666 exactly. AI-assisted: yes
MarcZX10 commented 2026-10-16 13:06:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T13:06:50Z.


Thanks for testing this head on the reported RDNA 2 iGPU and the RDNA 4 control. The 3/3 result confirms this initialization change does not resolve the #6666 stall. I suggest keeping #6670 scoped to the separate SPIR-V lock-initialization correctness issue. The captured s_barrier while the lock is held is the concrete lead for a separate follow-up; a change there needs to preserve the memory-ordering guarantees and be validated on RDNA 2.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6216159947 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6670#issuecomment-6216159947). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T13:06:50Z. --- Thanks for testing this head on the reported RDNA 2 iGPU and the RDNA 4 control. The 3/3 result confirms this initialization change does not resolve the #6666 stall. I suggest keeping #6670 scoped to the separate SPIR-V lock-initialization correctness issue. The captured `s_barrier` while the lock is held is the concrete lead for a separate follow-up; a change there needs to preserve the memory-ordering guarantees and be validated on RDNA 2.
jotitadev commented 2026-10-16 15:30:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T15:30:07Z.

Review: COMMENTED


NVIDIA control for the #6666 discussion, plus the new test on a device.

Machine: NVIDIA GeForce RTX 3070 (Ampere), driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8). Ubuntu 26.04 (kernel 7.0.0-38), i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. Head 4864a7480 merged onto main 0615cd2b8, clean merge (main did not build at the time, #6784).

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04

Set: agc_spirv_lds_atomic_lock, every agc_driver_lds_* test and the three agc_driver_pixel_lds* tests (15), -j1 --timeout 60.

  • Test only (the new test on main's emitter): agc_spirv_lds_atomic_lock fails with the workgroup lock is not initialized by only local invocation zero; the other 14 pass.
  • With the change, RTX 3070: 15/15 pass in 3 runs. agc_driver_lds_mixed_width_atomics takes 0.27 s without the change and 0.26-0.53 s with it; no stall either way, unlike the RDNA 2 runs above.
  • With the change, lavapipe: 12 pass, 3 skip (lds_addtid, pixel_lds, pixel_lds_lane_slots).

So on NVIDIA the stall does not show with or without this change, which fits it being specific to the RDNA 2 s_barrier placement rather than to the lock initialization. I did not capture ISA here.

Not checked: Windows, AMD, the reduced 128-thread kernel from the comment above.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5549986042 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6670#pullrequestreview-5549986042). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T15:30:07Z. **Review:** COMMENTED --- NVIDIA control for the #6666 discussion, plus the new test on a device. **Machine:** NVIDIA GeForce RTX 3070 (Ampere), driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8). Ubuntu 26.04 (kernel 7.0.0-38), i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. Head `4864a7480` merged onto `main` `0615cd2b8`, clean merge (`main` did not build at the time, #6784). GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 Set: `agc_spirv_lds_atomic_lock`, every `agc_driver_lds_*` test and the three `agc_driver_pixel_lds*` tests (15), `-j1 --timeout 60`. - Test only (the new test on `main`'s emitter): `agc_spirv_lds_atomic_lock` fails with `the workgroup lock is not initialized by only local invocation zero`; the other 14 pass. - With the change, RTX 3070: 15/15 pass in 3 runs. `agc_driver_lds_mixed_width_atomics` takes 0.27 s without the change and 0.26-0.53 s with it; no stall either way, unlike the RDNA 2 runs above. - With the change, lavapipe: 12 pass, 3 skip (`lds_addtid`, `pixel_lds`, `pixel_lds_lane_slots`). So on NVIDIA the stall does not show with or without this change, which fits it being specific to the RDNA 2 `s_barrier` placement rather than to the lock initialization. I did not capture ISA here. Not checked: Windows, AMD, the reduced 128-thread kernel from the comment above. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-16 15:34:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:34:50Z.


Thanks for the RTX 3070 and lavapipe control runs. The output comparison and test mutation result add useful hardware evidence for the LDS-lock initialization fix.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6218956951 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6670#issuecomment-6218956951). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T15:34:50Z. --- Thanks for the RTX 3070 and lavapipe control runs. The output comparison and test mutation result add useful hardware evidence for the LDS-lock initialization fix.
MarcZX10 commented 2026-10-18 12:53:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T12:53:09Z.


I checked #7368 against this change after it merged to main as 385ed71f2. They cover separate cases: #7368 uses native 64-bit buffer atomics for device-backed LDS when the feature is available, while workgroup-memory LDS still uses LockedLdsUpdate. This PR's single-invocation initialization remains an independent SPIR-V correctness fix for the lock path. #7368 also confirms the reported #6666 hardware hang is addressed by the separate #6976 lock-release change; I am not claiming this initialization change fixes that RDNA 2 runtime failure.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6250147780 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6670#issuecomment-6250147780). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T12:53:09Z. --- I checked #7368 against this change after it merged to `main` as `385ed71f2`. They cover separate cases: #7368 uses native 64-bit buffer atomics for device-backed LDS when the feature is available, while workgroup-memory LDS still uses `LockedLdsUpdate`. This PR's single-invocation initialization remains an independent SPIR-V correctness fix for the lock path. #7368 also confirms the reported #6666 hardware hang is addressed by the separate #6976 lock-release change; I am not claiming this initialization change fixes that RDNA 2 runtime failure.
adriadam10 commented 2026-10-19 08:46:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:46:49Z.


Checked: the lock zero-store is now done by local invocation 0 only, ahead of the existing workgroup barrier; LocalInvocationIndex is added as an input when missing; the regression test requires the store inside the LocalInvocationIndex == 0 branch and the old unguarded form fails it. Third-party runs (RDNA 2/3/4, RTX 3070, lavapipe) show no regression. Merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6263326174 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6670#issuecomment-6263326174). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T08:46:49Z. --- Checked: the lock zero-store is now done by local invocation 0 only, ahead of the existing workgroup barrier; `LocalInvocationIndex` is added as an input when missing; the regression test requires the store inside the `LocalInvocationIndex == 0` branch and the old unguarded form fails it. Third-party runs (RDNA 2/3/4, RTX 3070, lavapipe) show no regression. Merged.
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!6670
No description provided.