shader: translate for Metal without descriptor aliasing, graphics subgroups, or 64-bit atomics #2270

Open
github-bot wants to merge 4 commits from github-bot/gh-2270 into main AGit
Owner

@⁠bengidev on GitHub · 2026-11-14 07:08 UTC · original
bengidev:macos-metal-shaders → main · +295 −55 · 17 files · 4 commits · open

Stacked on #2269 — that device-enablement PR is the first commit here; only the three
shader commits below are new. (If #2269 lands first, this diff shrinks to them
automatically.)

With #2269 a Metal-backed device is accepted and agc boots, but the first pipelines
still fail. Three translation gaps, each blocking the next, all on MoltenVK 1.4.2 and
KosmicKrisp:

1. Descriptor aliasing → one binding per buffer element width

[mvk-error] SPIR-V to MSL conversion error: Attempting to alias same binding with a
descriptor array which is not implemented through argument buffers. This is unsupported.

DefineDescriptors declared up to four variables for one buffer array (buffers,
buffers_u8, buffers_u16, buffers_u64, plus lds_dwords/lds_qwords for shared
memory) and aliased them onto one binding with OpDecorate ... Aliased. Vulkan permits
it, MSL does not.

Each width variant now has its own DescriptorBindingKind, appended after
SharedMemory so Samplers (51) and the group stride keep their values; a variant is
only counted when the program uses that width; the host write loop binds every variant to
the same buffer. The storage-buffer pool grows to 32k because one set can now hold four
buffer arrays.

2. Subgroup builtins in graphics stages → single-lane model

error: invalid 'thread_index_in_simdgroup' attribute for input declaration in a
vertex function
uint gl_SubGroupInvocation [[thread_index_in_simdgroup]]

Kyty emits OpGroupNonUniformBallot for the launch/exec masks and loads
gl_SubgroupInvocationID whenever a stage asks for a lane id; Metal forbids both in
vertex and pixel functions (same root cause as #1427).

GraphicContext reports whether the device carries subgroup builtins in graphics stages
(false on macOS) and Profile::graphics_subgroups carries it into the emitter. Where it
is false, graphics stages use a single-lane model: EmitLiveMask, EmitSourceLaneActive,
EmitSubgroupLaneActiveBool and the lane-id load all go through one
EmitSingleLaneBallot that emits {predicate, 0, 0, 0}, and the existing lane-mask
projection folds the membership tests to the scalar predicate. A vertex or pixel
invocation has no defined wave anyway, so this does not change what those stages compute.

3. 64-bit buffer atomics → 32-bit word atomics

[mvk-error] SPIR-V to MSL conversion error: MSL currently does not support 64-bit atomics.

The coherent 64-bit pair load now lowers to a plain load when the device reports
shaderBufferInt64Atomics = false (initialised 64-bit values do not need atomicity), and
EmitBufferAtomic64 — the single choke point for every BufferAtomic*64 opcode — falls
back to word atomics on the u32 alias: add/sub carry and borrow into the high word,
and/or/xor act per word, and min/max/swap/compare-exchange read both words, merge them and
write both halves back through one OpAtomicExchange. Results are packed back into the
64-bit type, so the IR still sees a single value and only shaders that use 64-bit atomics
are affected.

Result

Apple M1 Max / macOS 26.7 / x86_64 under Rosetta, bundled MoltenVK 1.4.2. Madden NFL 26
(PPSA26127, 01.016.000) now compiles its shader set (VS 17 | PS 26 | CS 100), creates its
pipelines and reaches the main menu — the rendered stadium background, Quick Play /
Franchise / Ultimate Team / Superstar tiles, the PSN sign-in prompt, the Accessibility
first-run screen. The only emulation warning left is the same tolerated one reported on
Linux (TEMPORARY COMPUTE DISPATCH SKIP ... unsupported GPU-selected callable target).

Not fast yet: 11–15 fps on the menu (M1 Max), with the perf overlay attributing
904 ms/s to CPU waits on the GPU and 616 ms/s to DCC/CMASK emulation, and with Kyty +
MoltenVK both running as x86_64 under Rosetta. No perf work in this PR.

Caveats

  • ShaderIR::DescriptorBindingKind grew from 58 to 62 entries, which changes the shader
    store layout; BuildStamp() already keys cached records to the executable.
  • The swap/min-max/compare-exchange emulation is not itself atomic against other
    emulated accesses — it is a read-modify-write with a barrier, correct for single-writer
    patterns and documented in the code.
  • Verified on this one title only; the single-lane model is gated on a device capability,
    so nothing changes on RADV/Turnip where subgroup ops in graphics stages work.
**@⁠bengidev** on GitHub · 2026-11-14 07:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270) `bengidev:macos-metal-shaders` → `main` · +295 −55 · 17 files · 4 commits · open Stacked on #2269 — that device-enablement PR is the first commit here; only the three shader commits below are new. (If #2269 lands first, this diff shrinks to them automatically.) With #2269 a Metal-backed device is accepted and `agc` boots, but the first pipelines still fail. Three translation gaps, each blocking the next, all on MoltenVK 1.4.2 *and* KosmicKrisp: ### 1. Descriptor aliasing → one binding per buffer element width ``` [mvk-error] SPIR-V to MSL conversion error: Attempting to alias same binding with a descriptor array which is not implemented through argument buffers. This is unsupported. ``` `DefineDescriptors` declared up to four variables for one buffer array (`buffers`, `buffers_u8`, `buffers_u16`, `buffers_u64`, plus `lds_dwords`/`lds_qwords` for shared memory) and aliased them onto one binding with `OpDecorate ... Aliased`. Vulkan permits it, MSL does not. Each width variant now has its own `DescriptorBindingKind`, appended *after* `SharedMemory` so `Samplers` (51) and the group stride keep their values; a variant is only counted when the program uses that width; the host write loop binds every variant to the same buffer. The storage-buffer pool grows to 32k because one set can now hold four buffer arrays. ### 2. Subgroup builtins in graphics stages → single-lane model ``` error: invalid 'thread_index_in_simdgroup' attribute for input declaration in a vertex function uint gl_SubGroupInvocation [[thread_index_in_simdgroup]] ``` Kyty emits `OpGroupNonUniformBallot` for the launch/exec masks and loads `gl_SubgroupInvocationID` whenever a stage asks for a lane id; Metal forbids both in vertex and pixel functions (same root cause as #1427). `GraphicContext` reports whether the device carries subgroup builtins in graphics stages (false on macOS) and `Profile::graphics_subgroups` carries it into the emitter. Where it is false, graphics stages use a single-lane model: `EmitLiveMask`, `EmitSourceLaneActive`, `EmitSubgroupLaneActiveBool` and the lane-id load all go through one `EmitSingleLaneBallot` that emits `{predicate, 0, 0, 0}`, and the existing lane-mask projection folds the membership tests to the scalar predicate. A vertex or pixel invocation has no defined wave anyway, so this does not change what those stages compute. ### 3. 64-bit buffer atomics → 32-bit word atomics ``` [mvk-error] SPIR-V to MSL conversion error: MSL currently does not support 64-bit atomics. ``` The coherent 64-bit pair *load* now lowers to a plain load when the device reports `shaderBufferInt64Atomics = false` (initialised 64-bit values do not need atomicity), and `EmitBufferAtomic64` — the single choke point for every `BufferAtomic*64` opcode — falls back to word atomics on the u32 alias: add/sub carry and borrow into the high word, and/or/xor act per word, and min/max/swap/compare-exchange read both words, merge them and write both halves back through one `OpAtomicExchange`. Results are packed back into the 64-bit type, so the IR still sees a single value and only shaders that use 64-bit atomics are affected. ## Result Apple M1 Max / macOS 26.7 / x86_64 under Rosetta, bundled MoltenVK 1.4.2. Madden NFL 26 (PPSA26127, 01.016.000) now compiles its shader set (VS 17 | PS 26 | CS 100), creates its pipelines and reaches the main menu — the rendered stadium background, Quick Play / Franchise / Ultimate Team / Superstar tiles, the PSN sign-in prompt, the Accessibility first-run screen. The only emulation warning left is the same tolerated one reported on Linux (`TEMPORARY COMPUTE DISPATCH SKIP ... unsupported GPU-selected callable target`). Not fast yet: 11–15 fps on the menu (M1 Max), with the perf overlay attributing 904 ms/s to CPU waits on the GPU and 616 ms/s to DCC/CMASK emulation, and with Kyty + MoltenVK both running as x86_64 under Rosetta. No perf work in this PR. ## Caveats - `ShaderIR::DescriptorBindingKind` grew from 58 to 62 entries, which changes the shader store layout; `BuildStamp()` already keys cached records to the executable. - The swap/min-max/compare-exchange emulation is not itself atomic against other emulated accesses — it is a read-modify-write with a barrier, correct for single-writer patterns and documented in the code. - Verified on this one title only; the single-lane model is gated on a device capability, so nothing changes on RADV/Turnip where subgroup ops in graphics stages work.
Metal drivers (MoltenVK, KosmicKrisp) implement none of VK_EXT_image_view_min_lod,
64-bit buffer atomics, null descriptors, cull distance or non-solid fill, so device
selection rejected every Apple Silicon device with "Could not find suitable device"
(issue #1068). Those five are optional again on macOS: selection warns about them and
the renderer falls back where it relies on them.

- VK_EXT_image_view_min_lod moved from the required extension list to the optional
  set; image views only carry minLod when the device advertises it, otherwise the
  view starts at its base level.
- vkCreateDevice takes shaderBufferInt64Atomics, shaderCullDistance and
  fillModeNonSolid from the device instead of forcing VK_TRUE, and drops the
  corresponding features from the pNext chain when they are unavailable.
  GraphicContext now records the three capabilities for the shader emitter.
- Pipelines fall back to filled triangles when fillModeNonSolid is missing; Metal
  cannot rasterize point or line fill.
- VK_KHR_portability_subset is only requested from drivers that advertise it
  (KosmicKrisp does not), and Metal rejects subgroup builtins in vertex and pixel
  functions, so GraphicContext records that too.

The AGC driver memory no longer has to land on its fixed base: the x86_64 build runs
under Rosetta, which reserves 0x0fe0000000, so the mapping is retried without the
fixed address and everything derived from it follows the returned base.

Together with the shader changes in the follow-up PR this brings Madden NFL 26
(PPSA26127) to its main menu on an M1 Max.
Metal rejects subgroup builtins and intrinsics in vertex and pixel functions:
MoltenVK and KosmicKrisp both fail pipeline creation with
"Subgroup builtins are not available in this type of function" as soon as a
vertex shader touches gl_SubgroupInvocationID, and the ballot that builds the
launch/exec masks is such a touch.

A vertex or pixel invocation has no defined wave anyway, and the ballots Kyty
emits for those stages only ask "is this lane in the launched set". GraphicContext
now reports whether the device carries subgroup builtins in graphics stages
(false on macOS) and Profile carries it into the emitter; where it is false the
graphics stages emit a single-lane model: the lane id reads as 0 and
ballot(predicate) becomes {predicate, 0, 0, 0}, so the existing lane-mask
projection folds to the scalar predicate instead of loading a builtin.

Profile grows two fields (int64_atomics, graphics_subgroups) which changes the
shader store records, but BuildStamp() keys those to the executable.
The emitter declared up to four variables for one buffer array (buffers,
buffers_u8, buffers_u16, buffers_u64) and two for shared memory, all aliased onto
the same descriptor binding. MoltenVK refuses that layout:

  Attempting to alias same binding with a descriptor array which is not
  implemented through argument buffers. This is unsupported.

Vulkan allows the aliasing, so the layout stays as it is on drivers that can
express it; instead each width variant becomes its own DescriptorBindingKind.
The variants are appended after SharedMemory so the existing binding numbers of
Samplers and everything above it are unchanged, a variant is only counted when
the program actually uses that width (so programs that do not pay nothing), and
every variant is bound to the same resource in the host write loop. Metal sees
distinct bindings with the same underlying buffer.

The storage-buffer descriptor pool grows to 32k entries because a set can now
carry four buffer arrays.
Metal has no 64-bit atomics, so a compute shader that atomically ORs a 64-bit
counter fails translation with "MSL currently does not support 64-bit atomics".
The same code path already lowers a coherent 64-bit pair load to a plain load
when the device reports shaderBufferInt64Atomics = false; this adds the read-
modify-write half.

EmitBufferAtomic64 now dispatches on Profile::int64_atomics. Without the feature
the emulation works on the u32 alias of the buffer: add/sub carry and borrow into
the high word, and/or/xor act per word, while min/max/swap/compare-exchange read
both words, merge them and write both back through an exchange. Results are
packed back into the 64-bit type so the IR sees one value. Only shaders that use
64-bit atomics are affected.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:17:44 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:17 UTC · original

Explain Change →

Walkthrough

The changes add optional Vulkan feature handling and pass feature availability into renderer and SPIR-V configuration. SPIR-V emission adds single-lane graphics behavior and a two-word fallback for buffer 64-bit atomics. Descriptor handling adds buffer-width and shared-memory descriptor kinds. Gen5 driver initialization retries DMEM mapping without a fixed address and uses the returned address for the binding-table base.

Suggested reviewers: nmzik, senaxx

Change: Bug fix

Merge Risk: Moderate · up to 17246

This adds Metal support, but several new paths can produce wrong 64-bit atomic results, invalid shaders, or invalid descriptor writes on affected Apple devices. Other platforms are largely unaffected. These issues should be fixed before merge, or explicitly accepted given the reported single-title verification.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: translating shaders for Metal by removing descriptor aliasing, adding a single-lane model for graphics subgroups, and emulating 64-bit buffer atomics. The changeset ma…
Description check Passed The description is directly related to the changeset. It explains the three shader translation gaps and the fixes for each: descriptor aliasing, subgroup builtins in graphics stages, and 64-bit buffer…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: translating shaders for Metal by removing descriptor aliasing, adding a single-lane model for graphics subgroups, and emulating 64-bit buffer atomics. The changeset matches each of these three parts, including per-width descriptor bindings, the single-lane ballot path, and the 32-bit word atomic fallback. The title is long (94 characters), but it stays specific and relevant.

Full details: Description check

Explanation

The description is directly related to the changeset. It explains the three shader translation gaps and the fixes for each: descriptor aliasing, subgroup builtins in graphics stages, and 64-bit buffer atomics. It also covers the affected files, the storage-buffer pool increase, the DescriptorBindingKind change, and the test result on Madden NFL 26.

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#issuecomment-6873687936) <!-- 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/2270?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-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> The changes add optional Vulkan feature handling and pass feature availability into renderer and SPIR-V configuration. SPIR-V emission adds single-lane graphics behavior and a two-word fallback for buffer 64-bit atomics. Descriptor handling adds buffer-width and shared-memory descriptor kinds. Gen5 driver initialization retries DMEM mapping without a fixed address and uses the returned address for the binding-table base. **Suggested reviewers:** `nmzik`, `senaxx` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"17246cda5cf116954a7365984f9a26cab7451394" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix <!-- 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>17246</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `17246` --> <!-- final_review_risk_coverage:{"sourceCommitId":"17246cda5cf116954a7365984f9a26cab7451394","coveredCommitId":"17246cda5cf116954a7365984f9a26cab7451394","kind":"reviewed"} --> This adds Metal support, but several new paths can produce wrong 64-bit atomic results, invalid shaders, or invalid descriptor writes on affected Apple devices. Other platforms are largely unaffected. These issues should be fixed before merge, or explicitly accepted given the reported single-title verification. <!-- 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</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title names the main change: translating shaders for Metal by removing descriptor aliasing, adding a single-lane model for graphics subgroups, and emulating 64-bit buffer atomics. The changeset ma… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description is directly related to the changeset. It explains the three shader translation gaps and the fixes for each: descriptor aliasing, subgroup builtins in graphics stages, and 64-bit buffer… | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title names the main change: translating shaders for Metal by removing descriptor aliasing, adding a single-lane model for graphics subgroups, and emulating 64-bit buffer atomics. The changeset matches each of these three parts, including per-width descriptor bindings, the single-lane ballot path, and the 32-bit word atomic fallback. The title is long (94 characters), but it stays specific and relevant. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description is directly related to the changeset. It explains the three shader translation gaps and the fixes for each: descriptor aliasing, subgroup builtins in graphics stages, and 64-bit buffer atomics. It also covers the affected files, the storage-buffer pool increase, the DescriptorBindingKind change, and the test result on Madden NFL 26. </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=2270)! 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> <br> - [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> <!-- tips_end -->
@ -251,3 +265,3 @@
"descriptorBindingPartiallyBound");
check_feature(features13.robustImageAccess, "robustImageAccess");
check_feature(robustness2.nullDescriptor, "nullDescriptor");
check_optional_feature(robustness2.nullDescriptor, "nullDescriptor");
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:17 UTC · original

Major · Stability & Availability · Heavy lift

Null image writes need a valid fallback when nullDescriptor is disabled.

Apple devices that lack nullDescriptor now pass the optional check at vulkanWindow.cpp:267, and device creation leaves the feature disabled. The image heap still writes element 0 with a null image view at imageHeap.cpp:119-122 and imageHeap.cpp:531-539. Unbound textures also write null image views through MakeImageInfo at descriptors.cpp:74-78 and descriptors.cpp:1088. Without nullDescriptor, these descriptor writes are invalid and can lead to undefined behavior when a shader reads them.

Before accepting these devices, bind a valid placeholder image view for element 0 and for unbound textures when nullDescriptor is disabled. Resolve the conflicting selection comment at vulkanWindow.cpp:670-672 as part of the same change.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#discussion_r4572171485) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Stability & Availability** · **Heavy lift** **Null image writes need a valid fallback when `nullDescriptor` is disabled.** Apple devices that lack `nullDescriptor` now pass the optional check at `vulkanWindow.cpp:267`, and device creation leaves the feature disabled. The image heap still writes element 0 with a null image view at `imageHeap.cpp:119-122` and `imageHeap.cpp:531-539`. Unbound textures also write null image views through `MakeImageInfo` at `descriptors.cpp:74-78` and `descriptors.cpp:1088`. Without `nullDescriptor`, these descriptor writes are invalid and can lead to undefined behavior when a shader reads them. Before accepting these devices, bind a valid placeholder image view for element 0 and for unbound textures when `nullDescriptor` is disabled. Resolve the conflicting selection comment at `vulkanWindow.cpp:670-672` as part of the same change. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:8d48e6249728db68d9011bb9 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -257,3 +271,3 @@
check_feature(device_features2.features.depthBiasClamp, "depthBiasClamp");
check_feature(device_features2.features.shaderClipDistance, "shaderClipDistance");
check_feature(device_features2.features.shaderCullDistance, "shaderCullDistance");
check_optional_feature(device_features2.features.shaderCullDistance, "shaderCullDistance");
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:17 UTC · original

Major · Stability & Availability · Heavy lift

Gate cull-distance outputs on shaderCullDistance.

On Apple, shaderCullDistance is now optional and stays disabled when the device does not report it. A guest shader that exports cull distance still produces a CullDistance output. DefineOutputs then creates cull_distance_variable, and DefineModule requires CapabilityCullDistance for it. No check in the emitter or output path suppresses this. The Vulkan specification requires shaderCullDistance for the CullDistance capability, so pipeline creation can fail for such a shader on these devices.

Pass the device feature state into output lowering. When the feature is unavailable, the emitter must not declare CullDistance or create gl_CullDistance. Handle the cull-distance stores in spirvEmitterFlow.cpp the same way. Choose the fallback for the cull-distance data before implementing this change.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#discussion_r4572171491) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Stability & Availability** · **Heavy lift** **Gate cull-distance outputs on `shaderCullDistance`.** On Apple, `shaderCullDistance` is now optional and stays disabled when the device does not report it. A guest shader that exports cull distance still produces a `CullDistance` output. `DefineOutputs` then creates `cull_distance_variable`, and `DefineModule` requires `CapabilityCullDistance` for it. No check in the emitter or output path suppresses this. The Vulkan specification requires `shaderCullDistance` for the `CullDistance` capability, so pipeline creation can fail for such a shader on these devices. Pass the device feature state into output lowering. When the feature is unavailable, the emitter must not declare `CullDistance` or create `gl_CullDistance`. Handle the cull-distance stores in `spirvEmitterFlow.cpp` the same way. Choose the fallback for the cull-distance data before implementing this change. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:094a26280f76ab8526a45e67 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -1421,0 +1449,4 @@
const auto dword = Binary(state, spv::OpShiftRightLogical, TypeU32(state), byte_address,
ConstantU32(state, 2u));
return EmitValueOrDefaultIfCondition(
state, EmitMemoryElementInBounds(state, resource, dword), TypeU64(state),
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:17 UTC · original

Major · Data Integrity & Integration · Quick win

Bounds-check the high word of the emulated 64-bit atomic.

The guard at line 1452 checks only dword. The emulated path also writes dword + 1. When dword is the last dword of the descriptor range, the check passes and the high-word atomic writes past the range. Both words are written in the same guarded block, so the write is not prevented.

Check both indices before either word changes:

Suggested fix

--- "a/src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp"
+++ "b/src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp"
@@ -1449,7 +1449,11 @@
 		    const auto dword = Binary(state, spv::OpShiftRightLogical, TypeU32(state), byte_address,
 		                              ConstantU32(state, 2u));
 		    return EmitValueOrDefaultIfCondition(
-		        state, EmitMemoryElementInBounds(state, resource, dword), TypeU64(state),
+		        state,
+		        AndCondition(state, EmitMemoryElementInBounds(state, resource, dword),
+		                     EmitMemoryElementInBounds(state, resource,
+		                         EmitAddU32(state, dword, ConstantU32(state, 1u)))),
+		        TypeU64(state),
 		        ConstantU64(state, 0), [&]() {
 			        const auto word         = TypeStorageBufferElementPointer(state, 32u);
 			        const auto low_pointer  = EmitStorageBufferElementPointer(state, resource, dword, word);
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

		        state,
		        AndCondition(state, EmitMemoryElementInBounds(state, resource, dword),
		                     EmitMemoryElementInBounds(state, resource,
		                         EmitAddU32(state, dword, ConstantU32(state, 1u)))),
		        TypeU64(state),
**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#discussion_r4572171495) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Quick win** **Bounds-check the high word of the emulated 64-bit atomic.** The guard at line 1452 checks only `dword`. The emulated path also writes `dword + 1`. When `dword` is the last dword of the descriptor range, the check passes and the high-word atomic writes past the range. Both words are written in the same guarded block, so the write is not prevented. Check both indices before either word changes: <details> <summary>Suggested fix</summary> <dl> <dd> <br> ```diff --- "a/src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp" +++ "b/src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp" @@ -1449,7 +1449,11 @@ const auto dword = Binary(state, spv::OpShiftRightLogical, TypeU32(state), byte_address, ConstantU32(state, 2u)); return EmitValueOrDefaultIfCondition( - state, EmitMemoryElementInBounds(state, resource, dword), TypeU64(state), + state, + AndCondition(state, EmitMemoryElementInBounds(state, resource, dword), + EmitMemoryElementInBounds(state, resource, + EmitAddU32(state, dword, ConstantU32(state, 1u)))), + TypeU64(state), ConstantU64(state, 0), [&]() { const auto word = TypeStorageBufferElementPointer(state, 32u); const auto low_pointer = EmitStorageBufferElementPointer(state, resource, dword, word); ``` </dd> </dl> </details> <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> <br> > <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg" width="20" height="20" align="absmiddle" alt=""></picture> **IMPORTANT** > Review the replacement and indentation, then test before committing. ```suggestion state, AndCondition(state, EmitMemoryElementInBounds(state, resource, dword), EmitMemoryElementInBounds(state, resource, EmitAddU32(state, dword, ConstantU32(state, 1u)))), TypeU64(state), ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:fa8103f39e30385578cb3eef --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -1421,0 +1474,4 @@
const auto carry = Select(
state, TypeU32(state),
Binary(state, spv::OpULessThan, TypeBool(state), low_old, low_new),
ConstantU32(state, 1u), ConstantU32(state, 0u));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:17 UTC · original

Major · Functional Correctness · Quick win

Calculate addition carry from the low-word sum.

For BufferAtomicIAdd64, low_old < low_new does not detect overflow. Starting from zero and adding one sets carry to one, so the stored value becomes 0x0000000100000001. Starting from 0xffffffff and adding one misses the required carry.

For addition, compare the wrapped low-word sum with low_old. Keep low_old < low_new only for subtraction borrow.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#discussion_r4572171518) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Calculate addition carry from the low-word sum.** For `BufferAtomicIAdd64`, `low_old < low_new` does not detect overflow. Starting from zero and adding one sets `carry` to one, so the stored value becomes `0x0000000100000001`. Starting from `0xffffffff` and adding one misses the required carry. For addition, compare the wrapped low-word sum with `low_old`. Keep `low_old < low_new` only for subtraction borrow. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d104569f4fcf787591eb6f11 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -1421,0 +1504,4 @@
low_new = EmitCompositeExtractU64(state, merged, IR::Value(0u));
high_new = EmitCompositeExtractU64(state, merged, IR::Value(1u));
low_old = EmitAtomicWord(state, spv::OpAtomicExchange, low_pointer, low_new);
high_old = EmitAtomicWord(state, spv::OpAtomicExchange, high_pointer, high_new);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:17 UTC · original

Major · Data Integrity & Integration · Heavy lift

Serialize the complete emulated 64-bit exchange.

Two concurrent BufferAtomicSwap64 operations can leave a value that neither operation supplied. Starting from zero, let A swap in 0x0000000000000001 and B swap in 0x0000000100000000. The order A-low, B-low, B-high, A-high leaves zero.

Atomic exchanges on each word do not make the pair atomic. Use synchronized whole-operation emulation, or reject unsupported operations rather than silently permit mixed-word results. The same serialization must cover other emulated accesses to the element.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#discussion_r4572171527) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** **Serialize the complete emulated 64-bit exchange.** Two concurrent `BufferAtomicSwap64` operations can leave a value that neither operation supplied. Starting from zero, let A swap in `0x0000000000000001` and B swap in `0x0000000100000000`. The order A-low, B-low, B-high, A-high leaves zero. Atomic exchanges on each word do not make the pair atomic. Use synchronized whole-operation emulation, or reject unsupported operations rather than silently permit mixed-word results. The same serialization must cover other emulated accesses to the element. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:cc093f03bfd4b287f32c7f3a --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -775,1 +782,3 @@
state.builder.RequireCapability(spv::CapabilityInt64Atomics);
if (state.profile.int64_atomics) {
state.builder.RequireCapability(spv::CapabilityInt64Atomics);
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:17 UTC · original

Major · Functional Correctness · Quick win

Do not remove Int64Atomics while shared atomics remain native.

When profile.int64_atomics is false and info.shared_int64_atomics is true, this branch omits Int64Atomics. However, EmitSharedAtomic64 in spirvEmitterMemory.cpp, Lines 1542-1587, still emits native 64-bit atomic instructions. Those instructions require Int64Atomics, so this path produces invalid SPIR-V. (registry.khronos.org)

Handle shared atomic support separately. Emulate or reject unsupported shared operations before emission; retain the capability when native shared operations remain.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#discussion_r4572171532) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** **Do not remove `Int64Atomics` while shared atomics remain native.** When `profile.int64_atomics` is false and `info.shared_int64_atomics` is true, this branch omits `Int64Atomics`. However, `EmitSharedAtomic64` in `spirvEmitterMemory.cpp`, Lines 1542-1587, still emits native 64-bit atomic instructions. Those instructions require `Int64Atomics`, so this path produces invalid SPIR-V. ([registry.khronos.org](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html)) Handle shared atomic support separately. Emulate or reject unsupported shared operations before emission; retain the capability when native shared operations remain. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:86a77287bcb5a1f3c6f631f7 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -4095,3 +4108,3 @@
0xbefc03ff, 0x8a6ca000, 0xbf920009, 0xbefd210e,
};
const auto base = DriverDmemBase + AgcDmemOffset;
const auto base = driver_dmem_base + AgcDmemOffset;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:17 UTC · original

Minor · Data Integrity & Integration · Quick win

Derive the DMEM test addresses from the actual driver mapping.

CheckAgcSystemTable hard-codes 0x0fe0000000 as the driver base. When the fixed mapping is refused, Gen5Driver::Initialize() maps the driver DMEM at a different address. The test can then fail its mapping check at lines 54333-54340. Its reads and writes at table_address (lines 54345 and 54354-54357) also target the old address.

Expose the mapped base from the driver, or query it, and derive driver_base and table_address from that value. The current g_driver_dmem state does not retain the base address. Keep the descriptor layout assertions relative to the returned base.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#discussion_r4572171541) <!-- coderabbit-ai-generated:v1 --> **<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** · **Data Integrity & Integration** · **Quick win** **Derive the DMEM test addresses from the actual driver mapping.** `CheckAgcSystemTable` hard-codes `0x0fe0000000` as the driver base. When the fixed mapping is refused, `Gen5Driver::Initialize()` maps the driver DMEM at a different address. The test can then fail its mapping check at lines 54333-54340. Its reads and writes at `table_address` (lines 54345 and 54354-54357) also target the old address. Expose the mapped base from the driver, or query it, and derive `driver_base` and `table_address` from that value. The current `g_driver_dmem` state does not retain the base address. Keep the descriptor layout assertions relative to the returned base. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:3348f315ca0b722de2fcca6c --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:17 UTC · original · reviewed

Actionable comments posted: 7

Caution

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

⚠️ Outside diff range comments (1)

Major · Apply the single-lane fallback to the swizzle, bpermute, and… · spirvEmitterMemory.cpp:23-27

src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp:23-27
Major · Functional Correctness · Quick win

Apply the single-lane fallback to the swizzle, bpermute, and permute emitters.

Graphics vertex and pixel stages can reach EmitSwizzleU32, EmitBpermuteU32, and EmitPermuteU32 from DS_SWIZZLE_B32, DS_PERMUTE, and their backward variant. These emitters do not check EmitSingleLaneGraphics. EmitDsMaskedLaneRead emits OpGroupNonUniformShuffle for the value and exec mask. EmitPermuteU32 also emits OpGroupNonUniformBallot and a shuffle. When graphics_subgroups is false, the shader can still contain the subgroup intrinsics that Metal rejects in vertex and pixel functions. The pipeline can then fail to create for those shaders.

Add a single-lane path to EmitDsMaskedLaneRead and EmitPermuteU32. Use the same single-lane model as the existing helpers. Do not emit OpGroupNonUniformShuffle or OpGroupNonUniformBallot in that path. Define the result for a nonzero target lane before implementing the path, because the current EmitSubgroupLaneActiveBool behavior differs from the header's stated model.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 11d834dd82 and 17246cda5c.

Files selected for processing: 17

  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/renderer/image/imageView.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/shaders.cpp
  • src/graphics/presentation/window/vulkanWindow.cpp
  • src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp
  • src/graphics/shader/recompiler/ir/Serialize.h
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/libs/agc.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-11-14 07:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#pullrequestreview-5902583606) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 7** > [!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/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major</strong> · Apply the single-lane fallback to the swizzle, bpermute, and… · <code>spirvEmitterMemory.cpp:23-27</code></summary><blockquote> > <dl> > <dd> > <br> > > `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp:23-27` > **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** > > **Apply the single-lane fallback to the swizzle, bpermute, and permute emitters.** > > Graphics vertex and pixel stages can reach `EmitSwizzleU32`, `EmitBpermuteU32`, and `EmitPermuteU32` from `DS_SWIZZLE_B32`, `DS_PERMUTE`, and their backward variant. These emitters do not check `EmitSingleLaneGraphics`. `EmitDsMaskedLaneRead` emits `OpGroupNonUniformShuffle` for the value and exec mask. `EmitPermuteU32` also emits `OpGroupNonUniformBallot` and a shuffle. When `graphics_subgroups` is false, the shader can still contain the subgroup intrinsics that Metal rejects in vertex and pixel functions. The pipeline can then fail to create for those shaders. > > Add a single-lane path to `EmitDsMaskedLaneRead` and `EmitPermuteU32`. Use the same single-lane model as the existing helpers. Do not emit `OpGroupNonUniformShuffle` or `OpGroupNonUniformBallot` in that path. Define the result for a nonzero target lane before implementing the path, because the current `EmitSubgroupLaneActiveBool` behavior differs from the header's stated model. > > <!-- cr-comment:v1:47a32960a12a0c8125cf904e --> > > </dd> > </dl> > </blockquote></details> <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <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> <br> - **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/11d834dd820c093118d37177c6162f8092134cf2/.coderabbit.yaml>) - **Commit**: [11d834d](<https://github.com/KytyPS5/KytyPS5/commit/11d834dd820c093118d37177c6162f8092134cf2>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `b8fb2dd4-40ed-4868-aa02-add0107b28fc` </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> <br> Reviewing files that changed from the base of the PR and between 11d834dd820c093118d37177c6162f8092134cf2 and 17246cda5cf116954a7365984f9a26cab7451394. </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: 17</summary> <dl> <dd> <br> * `src/graphics/host_gpu/graphicContext.h` * `src/graphics/host_gpu/renderer/image/imageView.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptorHeap.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/pipeline/shaders.cpp` * `src/graphics/presentation/window/vulkanWindow.cpp` * `src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp` * `src/graphics/shader/recompiler/ir/Serialize.h` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/libs/agc.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> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=c3a05aac-9eed-466e-aab8-0cb1c7512a82 attempt=6531e3c6-79fa-40d4-a5e1-33f320302077 batch=1/1 -->
Author
Owner

@⁠chaseb64 on GitHub · 2026-11-25 07:00 UTC · original

Hey @⁠bengidev,

While testing the shader translation changes in this PR, I identified two narrow-integer rewrites that produce incorrect 8-bit and 16-bit zero-extension results.

I have a small six-line production patch with separate regression tests that apply cleanly against 17246cda5cf1.

I personally reviewed the explanation and ran the focused regression tests on my M5 Pro MacBook. The baseline reproduced the defect, and the patched version passed.

Additional testing on a physical NVIDIA L4 across 1,041 input pairs produced the following results:

  • 8-bit zero-extension: 786 errors before the fix, 0 afterward.
  • 16-bit zero-extension: 778 errors before the fix, 0 afterward.
  • Signed extension and 32-bit/64-bit arithmetic controls: 0 errors on both versions.

Both full CFG suites still encounter the same existing descriptor assertion. Game-specific behavior and independent verification of the raw GPU evidence archive remain outstanding.

Would you be interested in incorporating the correction into this PR? I can provide the isolated patch, regression tests and supporting validation evidence.

AI disclosure: AI-assisted using OpenAI Codex (GPT-6.2 Sol for physical GPU validation; [insert other contributing models from the review package]). I personally reviewed the explanation and reproduced the focused regression on macOS.

**@⁠chaseb64** on GitHub · 2026-11-25 07:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2270#issuecomment-7155392655) Hey @⁠bengidev, While testing the shader translation changes in this PR, I identified two narrow-integer rewrites that produce incorrect 8-bit and 16-bit zero-extension results. I have a small six-line production patch with separate regression tests that apply cleanly against `17246cda5cf1`. I personally reviewed the explanation and ran the focused regression tests on my M5 Pro MacBook. The baseline reproduced the defect, and the patched version passed. Additional testing on a physical NVIDIA L4 across 1,041 input pairs produced the following results: - 8-bit zero-extension: 786 errors before the fix, 0 afterward. - 16-bit zero-extension: 778 errors before the fix, 0 afterward. - Signed extension and 32-bit/64-bit arithmetic controls: 0 errors on both versions. Both full CFG suites still encounter the same existing descriptor assertion. Game-specific behavior and independent verification of the raw GPU evidence archive remain outstanding. Would you be interested in incorporating the correction into this PR? I can provide the isolated patch, regression tests and supporting validation evidence. **AI disclosure:** AI-assisted using OpenAI Codex (GPT-6.2 Sol for physical GPU validation; [insert other contributing models from the review package]). I personally reviewed the explanation and reproduced the focused regression on macOS.
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.h
  • src/graphics/shader/recompiler/ir/Serialize.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2270/head:github-bot/gh-2270'
git switch 'github-bot/gh-2270'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2270'
git switch 'github-bot/gh-2270'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2270'
git switch 'github-bot/gh-2270'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2270'
git switch 'main'
git merge --squash 'github-bot/gh-2270'
git switch 'main'
git merge --ff-only 'github-bot/gh-2270'
git switch 'main'
git merge 'github-bot/gh-2270'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.