shader: load coherent words with device-scope atomic loads #1613

Closed
github-bot wants to merge 4 commits from gh-pr/1613/head into gh-pr/1613/base
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 17:28 UTC · original
Nawid3333:shader/atomic-coherent-loads → main · +20 −8 · 2 files · 4 commits · closed without merging

Fixes #1600.

BufferWorkgroupPublicationWave32 / Wave64 hang on the Ryzen 7600X iGPU (RDNA2, AMD's non-LLPC compiler): the poll of the predecessor's published word is an OpLoad ... Volatile inside the loop, and that compiler moves it in front of the loop, so every workgroup from ticket 1 on spins on a stale value. In the Vulkan memory model a non-atomic load of a word that another invocation stores at the same time is a data race ("If there does not exist a location-ordered relation between X and Y ... then there is a data race", for X and Y that are "not mutually-ordered atomic operations"), so a compiler may treat the value as loop-invariant. Volatile doesn't change that, and neither do MakePointerVisible|NonPrivatePointer (measured in #1600).

Change: coherent (GLC or DLC) word loads from storage buffers and from global memory are emitted as OpAtomicLoad at device scope with relaxed semantics: read at the device level, no ordering. Loads through the 8- and 16-bit buffer views stay volatile loads. Stores are unchanged, so the publishing store is still a plain store; the pair is not race-free in the spec's terms, but the poll can no longer be treated as a plain load and stays in the loop.

What the compilers make of it (ISA checked): LLPC on the RX 9070 XT emits the same buffer_load_b32 ... scope:SCOPE_DEV as for the volatile load; the iGPU's compiler emits buffer_atomic_add of 0 inside the loop, so on that GPU a coherent load becomes a read-modify-write that adds nothing. Cost in a load-heavy benchmark where every load is coherent (64M strided loads from a 16 MiB host-visible buffer per dispatch, median of 20): RX 9070 XT 5.39 ms before, 5.37 ms after; iGPU 5.42 ms before, 8.80 ms after. The other option from #1600 (volatile load followed by an acquire barrier) took 11.81 ms on the iGPU in the same benchmark.

Tests

  • On both GPUs, in both subgroup modes (native and the harness forced to 32-wide, a local switch), compared with 763d3be3: BufferWorkgroupPublicationWave32 / Wave64 go from fail to pass on the iGPU (they pass on the RX 9070 XT before and after); every other compute entry and the 30 graphics cases keep their status. The named cases give no validation-layer messages. With the volatile load restored (a local mutant), they fail again in every configuration.
  • BufferWorkgroupPublication (including its StoreCompletionPublication cases), BufferLoadsGpuSelectedDescriptors, the non-formatted cases of BufferLoadGpuSelectedDescriptors and FlatLoadDlcCaptured required Volatile in the SPIR-V; they now require OpAtomicLoad.
  • shader_cfg_tests (not run by CI) passes.
  • d8b08a0f merges main 4919fdb6 (the only conflict was the required_spirv line of BufferLoadsGpuSelectedDescriptors, now if (!formatted) ... OpAtomicLoad) and drops the code comment above EmitCoherentLoad. On it, shader_cfg_tests passes, and shader_recompiler_compute_tests on the RX 9070 XT gives the same results as on main: GuardedWaterfallBufferRecords and SharedIndirectBufferLoads pass; GpuSelectedFormattedRgba16Store and BufferStoreFormatXAddTidUsesLaneIndex fail on both (to reach SharedIndirectBufferLoads, --indirect-buffer-only ran with the first of these skipped locally).
  • CI (build and tests on Windows, Linux and macOS) passes on d8b08a0f.

If you'd like this done differently, tell me and I'll change it.

Written with Claude Code (AI): it measured this on my PC (driver 26.8.1, Windows 11), wrote the change and ran the tests.

🤖 Generated with Claude Code

**@⁠Nawid3333** on GitHub · 2026-10-17 17:28 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613) `Nawid3333:shader/atomic-coherent-loads` → `main` · +20 −8 · 2 files · 4 commits · closed without merging Fixes #1600. `BufferWorkgroupPublicationWave32` / `Wave64` hang on the Ryzen 7600X iGPU (RDNA2, AMD's non-LLPC compiler): the poll of the predecessor's published word is an `OpLoad ... Volatile` inside the loop, and that compiler moves it in front of the loop, so every workgroup from ticket 1 on spins on a stale value. In the Vulkan memory model a non-atomic load of a word that another invocation stores at the same time is a data race ("If there does not exist a location-ordered relation between X and Y ... then there is a data race", for X and Y that are "not mutually-ordered atomic operations"), so a compiler may treat the value as loop-invariant. `Volatile` doesn't change that, and neither do `MakePointerVisible|NonPrivatePointer` (measured in #1600). **Change:** coherent (GLC or DLC) word loads from storage buffers and from global memory are emitted as `OpAtomicLoad` at device scope with relaxed semantics: read at the device level, no ordering. Loads through the 8- and 16-bit buffer views stay volatile loads. Stores are unchanged, so the publishing store is still a plain store; the pair is not race-free in the spec's terms, but the poll can no longer be treated as a plain load and stays in the loop. What the compilers make of it (ISA checked): LLPC on the RX 9070 XT emits the same `buffer_load_b32 ... scope:SCOPE_DEV` as for the volatile load; the iGPU's compiler emits `buffer_atomic_add` of 0 inside the loop, so on that GPU a coherent load becomes a read-modify-write that adds nothing. Cost in a load-heavy benchmark where every load is coherent (64M strided loads from a 16 MiB host-visible buffer per dispatch, median of 20): RX 9070 XT 5.39 ms before, 5.37 ms after; iGPU 5.42 ms before, 8.80 ms after. The other option from #1600 (volatile load followed by an acquire barrier) took 11.81 ms on the iGPU in the same benchmark. **Tests** - On both GPUs, in both subgroup modes (native and the harness forced to 32-wide, a local switch), compared with 763d3be3: `BufferWorkgroupPublicationWave32` / `Wave64` go from fail to pass on the iGPU (they pass on the RX 9070 XT before and after); every other compute entry and the 30 graphics cases keep their status. The named cases give no validation-layer messages. With the volatile load restored (a local mutant), they fail again in every configuration. - `BufferWorkgroupPublication` (including its `StoreCompletionPublication` cases), `BufferLoadsGpuSelectedDescriptors`, the non-formatted cases of `BufferLoadGpuSelectedDescriptors` and `FlatLoadDlcCaptured` required `Volatile` in the SPIR-V; they now require `OpAtomicLoad`. - `shader_cfg_tests` (not run by CI) passes. - d8b08a0f merges main 4919fdb6 (the only conflict was the `required_spirv` line of `BufferLoadsGpuSelectedDescriptors`, now `if (!formatted) ... OpAtomicLoad`) and drops the code comment above `EmitCoherentLoad`. On it, `shader_cfg_tests` passes, and `shader_recompiler_compute_tests` on the RX 9070 XT gives the same results as on main: `GuardedWaterfallBufferRecords` and `SharedIndirectBufferLoads` pass; `GpuSelectedFormattedRgba16Store` and `BufferStoreFormatXAddTidUsesLaneIndex` fail on both (to reach `SharedIndirectBufferLoads`, `--indirect-buffer-only` ran with the first of these skipped locally). - CI (build and tests on Windows, Linux and macOS) passes on d8b08a0f. If you'd like this done differently, tell me and I'll change it. Written with Claude Code (AI): it measured this on my PC (driver 26.8.1, Windows 11), wrote the change and ran the tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A coherent (GLC) load may read a value another invocation stores at the
same time, for example a word another workgroup publishes while this one
polls it. As a non-atomic load that is a data race, and AMD's non-LLPC
compiler moves the Volatile poll load out of the loop, so the loop spins on
a stale value. Coherent word loads from storage buffers and global memory
become relaxed OpAtomicLoad at device scope.

Fixes #1600.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:01:41 +00:00
github-bot closed this pull request 2026-11-26 10:01:41 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 17:35 UTC · original · edited 2026-10-30 20:10 UTC

Review in Change Stack →

Walkthrough

Coherent reads in LoadBdaDword and volatile-only reads in LoadWordInBounds now use device-scope OpAtomicLoad instructions with no memory semantics. Non-coherent LoadBdaDword reads continue to use aligned ordinary loads. Five compute test expectations now check for OpAtomicLoad instead of volatile load text.

Suggested reviewers: shadowbeat070

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Moderate · up to d8b08

Polling and publication still use mismatched atomicity, so cross-workgroup publication may remain unsynchronized; resolve this before merging.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: emitting device-scope atomic loads for coherent word loads.
Description check Passed The description directly explains the iGPU polling issue, the OpAtomicLoad change, scope, preserved behavior, test updates, and reported validation results.
Linked Issues check Passed Issue #1600 requires a coding fix so that the polling load of BufferWorkgroupPublicationWave32/Wave64 stays inside the loop on the iGPU. The reviewed head implements option 1 of the issue. In spirvEmi…
Out of Scope Changes check Passed Whole-PR diff against the merge base contains two files. spirvEmitterMemory.cpp adds EmitCoherentLoad and routes coherent word loads through it. These changes implement the issue. ShaderRecompilerComp…
Full details: Linked Issues check

Explanation

Issue #1600 requires a coding fix so that the polling load of BufferWorkgroupPublicationWave32/Wave64 stays inside the loop on the iGPU. The reviewed head implements option 1 of the issue. In spirvEmitterMemory.cpp, the new EmitCoherentLoad emits OpAtomicLoad at ScopeDevice with MemorySemanticsMaskNone (relaxed). LoadBdaDword calls it for coherent global-memory words. LoadWordInBounds calls it when memory_access equals MemoryAccessVolatileMask. Noncoherent BDA loads keep the aligned OpLoad. Stores are unchanged. Subword (8/16-bit) paths are not modified and remain volatile. The updated tests in ShaderRecompilerComputeTests.cpp (BufferWorkgroupPublication, BufferLoadsGpuSelectedDescriptors, BufferLoadGpuSelectedDescriptors, FlatLoadDlcCaptured, CheckGuardedWaterfallBufferRecords) require OpAtomicLoad. The Wave32/Wave64 runtime results on the iGPU are reported by the author. I did not run the tests. The code evidence supports the change, so the requirement is met.

Full details: Out of Scope Changes check

Explanation

Whole-PR diff against the merge base contains two files. spirvEmitterMemory.cpp adds EmitCoherentLoad and routes coherent word loads through it. These changes implement the issue. ShaderRecompilerComputeTests.cpp changes only the required_spirv expectations from Volatile to OpAtomicLoad in the five cases tied to coherent word loads. These are supporting test updates required by the new code. No unrelated change is shown. The non-coherent BDA path, the subword paths, and store emission are unchanged, which matches the stated scope.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files. (1 skipped: 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 17:35 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613#issuecomment-6237765090) · edited 2026-10-30 20:10 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1613?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> Coherent reads in `LoadBdaDword` and volatile-only reads in `LoadWordInBounds` now use device-scope `OpAtomicLoad` instructions with no memory semantics. Non-coherent `LoadBdaDword` reads continue to use aligned ordinary loads. Five compute test expectations now check for `OpAtomicLoad` instead of volatile load text. **Suggested reviewers:** `shadowbeat070` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"d8b08a0ff175a581babf9eb1b3ce73f086b843e8" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix · **Severity of issue fixed:** Medium <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Moderate</strong> · up to <code>d8b08</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `d8b08` --> <!-- final_review_risk_coverage:{"sourceCommitId":"d8b08a0ff175a581babf9eb1b3ce73f086b843e8","coveredCommitId":"d8b08a0ff175a581babf9eb1b3ce73f086b843e8","kind":"reviewed"} --> Polling and publication still use mismatched atomicity, so cross-workgroup publication may remain unsynchronized; resolve this before merging. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely identifies the main change: emitting device-scope atomic loads for coherent word loads. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the iGPU polling issue, the OpAtomicLoad change, scope, preserved behavior, test updates, and reported validation results. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Issue `#1600` requires a coding fix so that the polling load of BufferWorkgroupPublicationWave32/Wave64 stays inside the loop on the iGPU. The reviewed head implements option 1 of the issue. In spirvEmi… | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Whole-PR diff against the merge base contains two files. spirvEmitterMemory.cpp adds EmitCoherentLoad and routes coherent word loads through it. These changes implement the issue. ShaderRecompilerComp… | <details> <summary><strong>Full details: Linked Issues check</strong></summary> <dl> <dd> **Explanation** Issue `#1600` requires a coding fix so that the polling load of BufferWorkgroupPublicationWave32/Wave64 stays inside the loop on the iGPU. The reviewed head implements option 1 of the issue. In spirvEmitterMemory.cpp, the new EmitCoherentLoad emits OpAtomicLoad at ScopeDevice with MemorySemanticsMaskNone (relaxed). LoadBdaDword calls it for coherent global-memory words. LoadWordInBounds calls it when memory_access equals MemoryAccessVolatileMask. Noncoherent BDA loads keep the aligned OpLoad. Stores are unchanged. Subword (8/16-bit) paths are not modified and remain volatile. The updated tests in ShaderRecompilerComputeTests.cpp (BufferWorkgroupPublication, BufferLoadsGpuSelectedDescriptors, BufferLoadGpuSelectedDescriptors, FlatLoadDlcCaptured, CheckGuardedWaterfallBufferRecords) require OpAtomicLoad. The Wave32/Wave64 runtime results on the iGPU are reported by the author. I did not run the tests. The code evidence supports the change, so the requirement is met. </dd> </dl> </details> <details> <summary><strong>Full details: Out of Scope Changes check</strong></summary> <dl> <dd> **Explanation** Whole-PR diff against the merge base contains two files. spirvEmitterMemory.cpp adds EmitCoherentLoad and routes coherent word loads through it. These changes implement the issue. ShaderRecompilerComputeTests.cpp changes only the required_spirv expectations from Volatile to OpAtomicLoad in the five cases tied to coherent word loads. These are supporting test updates required by the new code. No unrelated change is shown. The non-coherent BDA path, the subword paths, and store emission are unchanged, which matches the stated scope. </dd> </dl> </details> </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files. (1 skipped: 1 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1613)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -170,0 +170,4 @@
void EmitCoherentLoad(EmitterState& state, uint32_t value, uint32_t pointer) {
state.builder.AddFunction(spv::OpAtomicLoad, TypeU32(state), value, pointer,
ConstantU32(state, spv::ScopeDevice),
ConstantU32(state, spv::MemorySemanticsMaskNone));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 17:35 UTC · original · edited 2026-10-17 17:38 UTC

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect the declared memory model and publication-store emission.
rg -n -C 4 'OpMemoryModel|MemoryModelVulkan|MemoryModelGLSL450' src/graphics/shader/recompiler/backend/spirv
rg -n -C 5 'BufferWorkgroupPublicationWave(32|64)|StoreWordInBounds|OpAtomicStore' src/graphics/shader/recompiler/backend/spirv tests

Repository: KytyPS5/KytyPS5

Length of output: 10227


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- publication test ---'
sed -n '35870,36120p' tests/ShaderRecompilerComputeTests.cpp
printf '%s\n' '--- load/store and access definitions ---'
rg -n -C 5 -F -- 'MemoryResourceAccess' src/graphics/shader/recompiler/backend/spirv src/graphics/shader/recompiler
rg -n -C 8 -F -- 'LoadWordInBounds' src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
rg -n -C 8 -F -- 'StoreWordInBounds' src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp

Repository: KytyPS5/KytyPS5

Length of output: 41987


🌐 Web query:

official SPIR-V Vulkan memory model atomic load non-atomic store data race MemoryModelGLSL450

💡 Result:

**Yes—under the Vulkan memory model, an atomic load racing with a non-atomic store to the same memory location is a data race** if they can run concurrently and there is no location-ordered synchronization between them. The store is a write, and the pair is not two mutually ordered atomic operations. An atomic load alone does not make the non-atomic store safe. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/appendices/memorymodel.html))

One important distinction: **`MemoryModel GLSL450` is not `MemoryModel Vulkan`**. SPIR-V lists them as separate models; the Vulkan model is selected with the `VulkanMemoryModel` capability. So the Vulkan memory-model data-race rule above applies when the module uses `MemoryModel Vulkan`, not merely because the shader runs on Vulkan. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html))

If you mean a specific `MemoryModel GLSL450` case, the outcome depends on the applicable Vulkan specification rules for that case; the Vulkan-memory-model rule should not automatically be transferred to it. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html))

Citations:

- 1: https://docs.vulkan.org/spec/latest/appendices/memorymodel.html
- 2: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html
- 3: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html

🌐 Web query:

official SPIR-V GLSL450 memory model atomic load non-atomic store volatile coherent synchronization

💡 Result:

Assuming you mean **SPIR-V using `OpMemoryModel Logical GLSL450`**:

- **Atomic load and ordinary store are not interchangeable.** `OpAtomicLoad` reads atomically relative to other atomic accesses to that location; `OpStore` is non-atomic. So an atomic load does not make a concurrent ordinary store safe or atomic. For correctness, use atomic operations consistently on a location shared concurrently, or provide synchronization that orders the accesses. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html?utm_source=openai))
- **`coherent` is not a substitute for synchronization.** It describes coherent backing memory in SPIR-V, but does not itself order accesses or create a happens-before relation. SPIR-V provides memory barriers for ordering; `OpControlBarrier` also coordinates participating invocations, subject to its scope and execution requirements. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html))
- **`volatile` is not a synchronization primitive.** In the GLSL450 model it prevents accesses from being eliminated, duplicated, or combined, but its guarantee is limited to a single invocation; it does not ensure other invocations observe an access. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html))
- **GLSL 4.50 note:** Its atomic memory functions are read-modify-write operations. The spec says they honor the `coherent`/`volatile` qualification of the argument, but still does not say those qualifiers replace fences or barriers. ([registry.khronos.org](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.50.pdf))

**Bottom line:** `coherent volatile` plus `OpAtomicLoad` does not make a concurrent non-atomic `OpStore` safe. Use a consistent atomic protocol and the appropriate barrier/synchronization for the participating invocations. The exact required scope/order depends on your shader stages and whether synchronization is within one workgroup or across commands; GLSL450 alone doesn’t establish those details. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html))

Citations:

- 1: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html?utm_source=openai
- 2: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html
- 3: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html
- 4: https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.50.pdf
- 5: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html

🌐 Web query:

site:registry.khronos.org OpenGL Shading Language 4.60 coherent volatile memory barrier inter shader invocation buffer synchronization

💡 Result:

In GLSL 4.60, **`coherent` plus a memory barrier can make buffer writes visible between shader invocations—but a memory barrier alone does not synchronize their execution.**

- Declare the shared buffer variable or block `coherent`. The spec says coherent accesses can reflect completed writes from other invocations; without `coherent`, implementations may cache reads or writes in ways that prevent communication. `volatile` instead tells the compiler the value may change externally during execution; it does **not** replace the ordering barrier. ([registry.khronos.org](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html))
- The writing invocation calls `memoryBarrierBuffer()` to order its buffer accesses, or `memoryBarrier()` for all supported memory types. The barrier ensures prior writes by the caller become visible to future coherent accesses, provided a *happens-before* relation exists. ([registry.khronos.org](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html))
- **Neither function makes other invocations wait.** In compute shaders, `barrier()` synchronizes execution only within the same workgroup; it cannot provide a dispatch-wide rendezvous. For separate invocations, the required happens-before relationship must come from the execution context—for example, dependent shader invocations in later pipeline stages. ([registry.khronos.org](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html))

So, for producer–consumer communication: use `coherent` and the appropriate memory barrier for visibility, and ensure the consumer is ordered after the producer. `volatile` alone is not sufficient.

Citations:

- 1: https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html
- 2: https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html
- 3: https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html

🏁 Script executed:

set -o pipefail
printf '%s\n' '--- atomic operation emitters ---'
rg -n -C 8 -F -- 'OpAtomicIAdd' src/graphics/shader/recompiler/backend/spirv
rg -n -C 8 -F -- 'MemorySemanticsMaskNone' src/graphics/shader/recompiler/backend/spirv
rg -n -C 8 -F -- 'MemorySemantics' src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp
printf '%s\n' '--- publication opcode helpers ---'
rg -n -C 8 -F -- 'AppendBufferStoreDword' tests/ShaderRecompilerComputeTests.cpp
rg -n -C 8 -F -- 'BUFFER_ATOMIC_ADD' src tests

Repository: KytyPS5/KytyPS5

Length of output: 42272


Use a matching atomic publication store.

BufferWorkgroupPublicationWave32 and BufferWorkgroupPublicationWave64 poll a coherent buffer word with OpAtomicLoad, but the publisher writes it with a non-atomic OpStore. MemoryModelGLSL450 does not make these accesses interchangeable. Coherent and Volatile do not provide ordering.

The ticket OpAtomicIAdd does not establish a publication edge. Buffer atomics use MemorySemanticsMaskNone and ScopeWorkgroup, while the publication spans workgroups.

Emit a matching device-scope OpAtomicStore for coherent word stores. Use release semantics for the store and acquire semantics for the load when the word publishes other memory.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 17:35 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613#discussion_r4303755449) · edited 2026-10-17 17:38 UTC **🩺 Stability & Availability** | **🟠 Major** | **🏗️ Heavy lift** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash # Inspect the declared memory model and publication-store emission. rg -n -C 4 'OpMemoryModel|MemoryModelVulkan|MemoryModelGLSL450' src/graphics/shader/recompiler/backend/spirv rg -n -C 5 'BufferWorkgroupPublicationWave(32|64)|StoreWordInBounds|OpAtomicStore' src/graphics/shader/recompiler/backend/spirv tests ``` Repository: KytyPS5/KytyPS5 Length of output: 10227 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- publication test ---' sed -n '35870,36120p' tests/ShaderRecompilerComputeTests.cpp printf '%s\n' '--- load/store and access definitions ---' rg -n -C 5 -F -- 'MemoryResourceAccess' src/graphics/shader/recompiler/backend/spirv src/graphics/shader/recompiler rg -n -C 8 -F -- 'LoadWordInBounds' src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp rg -n -C 8 -F -- 'StoreWordInBounds' src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 41987 --- 🌐 Web query: `official SPIR-V Vulkan memory model atomic load non-atomic store data race MemoryModelGLSL450` 💡 Result: ``` **Yes—under the Vulkan memory model, an atomic load racing with a non-atomic store to the same memory location is a data race** if they can run concurrently and there is no location-ordered synchronization between them. The store is a write, and the pair is not two mutually ordered atomic operations. An atomic load alone does not make the non-atomic store safe. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/appendices/memorymodel.html)) One important distinction: **`MemoryModel GLSL450` is not `MemoryModel Vulkan`**. SPIR-V lists them as separate models; the Vulkan model is selected with the `VulkanMemoryModel` capability. So the Vulkan memory-model data-race rule above applies when the module uses `MemoryModel Vulkan`, not merely because the shader runs on Vulkan. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html)) If you mean a specific `MemoryModel GLSL450` case, the outcome depends on the applicable Vulkan specification rules for that case; the Vulkan-memory-model rule should not automatically be transferred to it. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html)) Citations: - 1: https://docs.vulkan.org/spec/latest/appendices/memorymodel.html - 2: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html - 3: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html ``` --- 🌐 Web query: `official SPIR-V GLSL450 memory model atomic load non-atomic store volatile coherent synchronization` 💡 Result: ``` Assuming you mean **SPIR-V using `OpMemoryModel Logical GLSL450`**: - **Atomic load and ordinary store are not interchangeable.** `OpAtomicLoad` reads atomically relative to other atomic accesses to that location; `OpStore` is non-atomic. So an atomic load does not make a concurrent ordinary store safe or atomic. For correctness, use atomic operations consistently on a location shared concurrently, or provide synchronization that orders the accesses. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html?utm_source=openai)) - **`coherent` is not a substitute for synchronization.** It describes coherent backing memory in SPIR-V, but does not itself order accesses or create a happens-before relation. SPIR-V provides memory barriers for ordering; `OpControlBarrier` also coordinates participating invocations, subject to its scope and execution requirements. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html)) - **`volatile` is not a synchronization primitive.** In the GLSL450 model it prevents accesses from being eliminated, duplicated, or combined, but its guarantee is limited to a single invocation; it does not ensure other invocations observe an access. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html)) - **GLSL 4.50 note:** Its atomic memory functions are read-modify-write operations. The spec says they honor the `coherent`/`volatile` qualification of the argument, but still does not say those qualifiers replace fences or barriers. ([registry.khronos.org](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.50.pdf)) **Bottom line:** `coherent volatile` plus `OpAtomicLoad` does not make a concurrent non-atomic `OpStore` safe. Use a consistent atomic protocol and the appropriate barrier/synchronization for the participating invocations. The exact required scope/order depends on your shader stages and whether synchronization is within one workgroup or across commands; GLSL450 alone doesn’t establish those details. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html)) Citations: - 1: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html?utm_source=openai - 2: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html - 3: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html - 4: https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.50.pdf - 5: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html ``` --- 🌐 Web query: `site:registry.khronos.org OpenGL Shading Language 4.60 coherent volatile memory barrier inter shader invocation buffer synchronization` 💡 Result: ``` In GLSL 4.60, **`coherent` plus a memory barrier can make buffer writes visible between shader invocations—but a memory barrier alone does not synchronize their execution.** - Declare the shared buffer variable or block `coherent`. The spec says coherent accesses can reflect completed writes from other invocations; without `coherent`, implementations may cache reads or writes in ways that prevent communication. `volatile` instead tells the compiler the value may change externally during execution; it does **not** replace the ordering barrier. ([registry.khronos.org](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html)) - The writing invocation calls `memoryBarrierBuffer()` to order its buffer accesses, or `memoryBarrier()` for all supported memory types. The barrier ensures prior writes by the caller become visible to future coherent accesses, provided a *happens-before* relation exists. ([registry.khronos.org](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html)) - **Neither function makes other invocations wait.** In compute shaders, `barrier()` synchronizes execution only within the same workgroup; it cannot provide a dispatch-wide rendezvous. For separate invocations, the required happens-before relationship must come from the execution context—for example, dependent shader invocations in later pipeline stages. ([registry.khronos.org](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html)) So, for producer–consumer communication: use `coherent` and the appropriate memory barrier for visibility, and ensure the consumer is ordered after the producer. `volatile` alone is not sufficient. Citations: - 1: https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html - 2: https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html - 3: https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html ``` --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- atomic operation emitters ---' rg -n -C 8 -F -- 'OpAtomicIAdd' src/graphics/shader/recompiler/backend/spirv rg -n -C 8 -F -- 'MemorySemanticsMaskNone' src/graphics/shader/recompiler/backend/spirv rg -n -C 8 -F -- 'MemorySemantics' src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cpp printf '%s\n' '--- publication opcode helpers ---' rg -n -C 8 -F -- 'AppendBufferStoreDword' tests/ShaderRecompilerComputeTests.cpp rg -n -C 8 -F -- 'BUFFER_ATOMIC_ADD' src tests ``` Repository: KytyPS5/KytyPS5 Length of output: 42272 --- </details> **Use a matching atomic publication store.** `BufferWorkgroupPublicationWave32` and `BufferWorkgroupPublicationWave64` poll a coherent buffer word with `OpAtomicLoad`, but the publisher writes it with a non-atomic `OpStore`. `MemoryModelGLSL450` does not make these accesses interchangeable. `Coherent` and `Volatile` do not provide ordering. The ticket `OpAtomicIAdd` does not establish a publication edge. Buffer atomics use `MemorySemanticsMaskNone` and `ScopeWorkgroup`, while the publication spans workgroups. Emit a matching device-scope `OpAtomicStore` for coherent word stores. Use release semantics for the store and acquire semantics for the load when the word publishes other memory. <!-- coderabbit-global-learning v1 gid=eb77e69742caf35b scope=lang --> <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:413fc6ebdce66e9434d8fa7e --> <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 17:35 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b2cf18e-9165-4cca-b525-128dfc5c2498
📥 Commits

Reviewing files that changed from the base of the PR and between 763d3be3a9 and 72881d74ee.

📒 Files selected for processing: 2
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 17:35 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613#pullrequestreview-5559116649) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `5b2cf18e-9165-4cca-b525-128dfc5c2498` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 763d3be3a9bc4e5a068d7cf52015030d6c03308f and 72881d74ee0e75203c010cf63a3136b1a1fc194f. </details> <details> <summary>📒 Files selected for processing: 2</summary> * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=c4bf43a0-9465-4ca2-9a95-dc40af063188 attempt=791993da-2f2a-4d49-9ad6-7859bf034638 batch=1/1 -->
@ -170,0 +170,4 @@
void EmitCoherentLoad(EmitterState& state, uint32_t value, uint32_t pointer) {
state.builder.AddFunction(spv::OpAtomicLoad, TypeU32(state), value, pointer,
ConstantU32(state, spv::ScopeDevice),
ConstantU32(state, spv::MemorySemanticsMaskNone));
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 17:38 UTC · original

Thanks. The publishing store in these tests is a plain buffer_store_dword without GLC or DLC (RDNA2 stores write through to L2 anyway, which the test relies on), so turning coherent stores into OpAtomicStore wouldn't make the publisher atomic; that would take every buffer store. This PR leaves stores as they are and only stops the poll from being treated as a plain load, as the description says. The ticket's OpAtomicIAdd uses device scope (%uint_1); Kyty uses workgroup scope only for LDS atomics.

**@⁠Nawid3333** on GitHub · 2026-10-17 17:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613#discussion_r4303764236) Thanks. The publishing store in these tests is a plain `buffer_store_dword` without GLC or DLC (RDNA2 stores write through to L2 anyway, which the test relies on), so turning coherent stores into `OpAtomicStore` wouldn't make the publisher atomic; that would take every buffer store. This PR leaves stores as they are and only stops the poll from being treated as a plain load, as the description says. The ticket's `OpAtomicIAdd` uses device scope (`%uint_1`); Kyty uses workgroup scope only for LDS atomics.
@ -170,0 +170,4 @@
void EmitCoherentLoad(EmitterState& state, uint32_t value, uint32_t pointer) {
state.builder.AddFunction(spv::OpAtomicLoad, TypeU32(state), value, pointer,
ConstantU32(state, spv::ScopeDevice),
ConstantU32(state, spv::MemorySemanticsMaskNone));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 17:39 UTC · original

@⁠Nawid3333 Thanks for the clarification. My scope claim was wrong: EmitAtomic32 uses device scope for buffer atomics and workgroup scope for LDS atomics.

My proposed fix also missed the publisher. Because that buffer_store_dword has neither GLC nor DLC, converting only coherent stores to OpAtomicStore would leave it unchanged.

I withdraw this finding. This PR prevents the coherent poll from being treated as a plain load; it does not claim to establish a fully atomic publication protocol.


✏️ Learnings added
Learnt from: Nawid3333
Repo: KytyPS5/KytyPS5 PR: 1613
File: src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp:174-176
Timestamp: 2026-10-17T17:39:00.745Z
Learning: In KytyPS5/KytyPS5, src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp implements EmitAtomic32 with ScopeWorkgroup for IR::ResourceKind::Lds and ScopeDevice otherwise. Buffer atomics therefore use device scope, not workgroup scope. Do not infer an atomic operation's scope from its MemorySemanticsMaskNone operand.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-17 17:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613#discussion_r4303765653) @⁠Nawid3333 Thanks for the clarification. My scope claim was wrong: `EmitAtomic32` uses device scope for buffer atomics and workgroup scope for LDS atomics. My proposed fix also missed the publisher. Because that `buffer_store_dword` has neither GLC nor DLC, converting only coherent stores to `OpAtomicStore` would leave it unchanged. I withdraw this finding. This PR prevents the coherent poll from being treated as a plain load; it does not claim to establish a fully atomic publication protocol. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: Nawid3333 Repo: KytyPS5/KytyPS5 PR: 1613 File: src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp:174-176 Timestamp: 2026-10-17T17:39:00.745Z Learning: In KytyPS5/KytyPS5, src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp implements EmitAtomic32 with ScopeWorkgroup for IR::ResourceKind::Lds and ScopeDevice otherwise. Buffer atomics therefore use device scope, not workgroup scope. Do not infer an atomic operation's scope from its MemorySemanticsMaskNone operand. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> <!-- <review_comment_withdrawn> --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠NeySlim on GitHub · 2026-10-17 23:09 UTC · original

RADV data point: Radeon 8060S (RDNA 3.5), Mesa 26.2.4, against 763d3be3. BufferWorkgroupPublicationWave32/Wave64 already pass on main here: ACO keeps the poll in the loop (buffer_load_b32 ... offen glc), and with this PR it emits exactly the same ISA, no atomic. One difference in the suite: CheckGuardedWaterfallBufferRecords passes on main and fails with the PR at the SPIR-V check ("missing required text: Volatile"); its required_spirv still lists Volatile.

**@⁠NeySlim** on GitHub · 2026-10-17 23:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613#issuecomment-6242862690) RADV data point: Radeon 8060S (RDNA 3.5), Mesa 26.2.4, against 763d3be3. `BufferWorkgroupPublicationWave32`/`Wave64` already pass on main here: ACO keeps the poll in the loop (`buffer_load_b32 ... offen glc`), and with this PR it emits exactly the same ISA, no atomic. One difference in the suite: `CheckGuardedWaterfallBufferRecords` passes on main and fails with the PR at the SPIR-V check ("missing required text: Volatile"); its `required_spirv` still lists `Volatile`.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-18 04:15 UTC · original

Thanks, you're right: this PR turns that check's GLC load into an OpAtomicLoad, so its required_spirv had to change. I pushed a commit that expects OpAtomicLoad there, and the check passes with the PR on my RX 9070 XT and Ryzen 7600X iGPU. I missed it because my per-case test runner covered only 32 of the 115 standalone checks that the full run executes. It now covers all of them, and none of the other 84 changes with the PR on the RX 9070 XT or the 7600X iGPU. Good to know that ACO emits the same ISA with the PR, so it costs nothing on RADV.

Written with Claude Code (AI): it fixed the check and reran the tests on my PC; I read this comment before posting it.

**@⁠Nawid3333** on GitHub · 2026-10-18 04:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613#issuecomment-6245555641) Thanks, you're right: this PR turns that check's GLC load into an `OpAtomicLoad`, so its `required_spirv` had to change. I pushed a commit that expects `OpAtomicLoad` there, and the check passes with the PR on my RX 9070 XT and Ryzen 7600X iGPU. I missed it because my per-case test runner covered only 32 of the 115 standalone checks that the full run executes. It now covers all of them, and none of the other 84 changes with the PR on the RX 9070 XT or the 7600X iGPU. Good to know that ACO emits the same ISA with the PR, so it costs nothing on RADV. Written with Claude Code (AI): it fixed the check and reran the tests on my PC; I read this comment before posting it.
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-30 20:10 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Preserve memory.coherent for formatted indirect buffers. · spirvEmitterMemory.cpp:1288-1289

src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp:1288-1289
Minor · Functional Correctness · Quick win

Preserve memory.coherent for formatted indirect buffers.

MemoryInfo::SupportsIndirectBufferLoad allows formatted 32-bit indirect loads without excluding memory.coherent. The formatted variant therefore can be generated, but LoadIndirectFormattedX drops the flag and emits an ordinary OpLoad instead of EmitCoherentLoad.

Suggested fix
-uint32_t LoadIndirectFormattedX(ValueEmitContext& ctx, const IndirectBufferAccess& buffer) {
+uint32_t LoadIndirectFormattedX(ValueEmitContext& ctx, const IndirectBufferAccess& buffer,
+                                bool coherent) {
...
-		                    ConstantU64(state, ~uint64_t {3})));
+		                    ConstantU64(state, ~uint64_t {3})),
+		        coherent);
...
-			const auto result = memory.formatted ? LoadIndirectFormattedX(ctx, buffer)
+			const auto result = memory.formatted
+			    ? LoadIndirectFormattedX(ctx, buffer, memory.coherent)
Nitpick comments: 1
tests/ShaderRecompilerComputeTests.cpp: 1

34267-34267: Trivial · Functional Correctness · Quick win

Check the scope and semantics operands of the new OpAtomicLoad expectations.

CheckSpirvEmission passes a required string when text.find(required) finds it anywhere in the disassembly. The five updated expectations require only the bare text OpAtomicLoad, so they do not check the scope or memory-semantics operands of the load. A load emitted with a non-device scope or non-None semantics can still pass. An unrelated OpAtomicLoad from another emitter path can also satisfy the check, such as the 64-bit acquire-semantics load in the same emitter. The emitter currently produces device scope with MemorySemanticsMaskNone for this path, so the gap affects regression detection, not current behavior. The tests should verify the operands of the affected load, not only its opcode.


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 41c6a15584 and d8b08a0ff1.

Files selected for processing: 2
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-30 20:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613#pullrequestreview-5718087962) · **reviewed** <!-- coderabbit-ai-generated:v1 --> > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor</strong> · Preserve <code>memory.coherent</code> for formatted indirect buffers. · <code>spirvEmitterMemory.cpp:1288-1289</code></summary><blockquote> > <dl> > <dd> > > `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp:1288-1289` > **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** > > **Preserve `memory.coherent` for formatted indirect buffers.** > > `MemoryInfo::SupportsIndirectBufferLoad` allows formatted 32-bit indirect loads without excluding `memory.coherent`. The formatted variant therefore can be generated, but `LoadIndirectFormattedX` drops the flag and emits an ordinary `OpLoad` instead of `EmitCoherentLoad`. > > <details> > <summary>Suggested fix</summary> > <dl> > <dd> > > ```diff > -uint32_t LoadIndirectFormattedX(ValueEmitContext& ctx, const IndirectBufferAccess& buffer) { > +uint32_t LoadIndirectFormattedX(ValueEmitContext& ctx, const IndirectBufferAccess& buffer, > + bool coherent) { > ... > - ConstantU64(state, ~uint64_t {3}))); > + ConstantU64(state, ~uint64_t {3})), > + coherent); > ... > - const auto result = memory.formatted ? LoadIndirectFormattedX(ctx, buffer) > + const auto result = memory.formatted > + ? LoadIndirectFormattedX(ctx, buffer, memory.coherent) > ``` > > </dd> > </dl> > </details> > > <!-- cr-comment:v1:5ca9c1fd87b9ea71c03f7da3 --> > > </dd> > </dl> > </blockquote></details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning.svg" width="16" height="16" align="absmiddle" alt=""></picture> Nitpick comments: 1</summary><blockquote> <dl> <dd> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 1</summary><blockquote> <dl> <dd> `34267-34267`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/neutral-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Trivial** · **Functional Correctness** · **Quick win** **Check the scope and semantics operands of the new `OpAtomicLoad` expectations.** `CheckSpirvEmission` passes a required string when `text.find(required)` finds it anywhere in the disassembly. The five updated expectations require only the bare text `OpAtomicLoad`, so they do not check the scope or memory-semantics operands of the load. A load emitted with a non-device scope or non-`None` semantics can still pass. An unrelated `OpAtomicLoad` from another emitter path can also satisfy the check, such as the 64-bit acquire-semantics load in the same emitter. The emitter currently produces device scope with `MemorySemanticsMaskNone` for this path, so the gap affects regression detection, not current behavior. The tests should verify the operands of the affected load, not only its opcode. <!-- cr-comment:v1:88167b7e7562d76e09fe252d --> </dd> </dl> </blockquote></details> </dd> </dl> </blockquote></details> --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/4919fdb6e6e28f46f1f5df8cf931a7a0823cb93f/.coderabbit.yaml>) - **Commit**: [4919fdb](<https://github.com/KytyPS5/KytyPS5/commit/4919fdb6e6e28f46f1f5df8cf931a7a0823cb93f>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `986e74db-7975-4975-99ee-1d55c50416d8` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 41c6a155842519a6d3150e8e549b5f7082edb033 and d8b08a0ff175a581babf9eb1b3ce73f086b843e8. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 2</summary> <dl> <dd> * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=85efe66b-a506-4b5b-bc8c-fb86b86364b2 attempt=d6669fbe-9d2c-4067-afc6-fc483eefc4ff batch=1/1 -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-30 20:18 UTC · original

About CodeRabbit's outside-diff comment on LoadIndirectFormattedX: that gap is on main too. Main's LoadIndirectFormattedX calls LoadBdaDword without coherent, so a coherent formatted X load through a GPU-selected descriptor gets neither Volatile nor an atomic load there, and this PR doesn't change that path. The formatted GPU-selected test cases use non-GLC loads, so covering it would also need a new formatted GLC case. I'd rather keep this PR to the loads it changes; I can do the formatted path separately if you want it.

**@⁠Nawid3333** on GitHub · 2026-10-30 20:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1613#issuecomment-6532630342) About CodeRabbit's outside-diff comment on `LoadIndirectFormattedX`: that gap is on main too. Main's `LoadIndirectFormattedX` calls `LoadBdaDword` without `coherent`, so a coherent formatted X load through a GPU-selected descriptor gets neither `Volatile` nor an atomic load there, and this PR doesn't change that path. The formatted GPU-selected test cases use non-GLC loads, so covering it would also need a new formatted GLC case. I'd rather keep this PR to the loads it changes; I can do the formatted path separately if you want it.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.