spirv: guard pixel shader cross-lane reads from lanes the host subgroup lacks #1515

Closed
github-bot wants to merge 1 commit from gh-pr/1515/head into gh-pr/1515/base
Owner

@⁠overlordxrz-source on GitHub · 2026-10-14 19:35 UTC · original
overlordxrz-source:nhl-ps-cross-lane-missing-lanes → main · +128 −5 · 4 files · 1 commits · closed without merging

Fixes the NHL 27 (PPSA34063, #1101) GPU hang in PS 0x1da1fd2871174330. On fozter's RTX 3060 Ti it ends as a device loss about 15 s into the loading screen after START GAME:

Not implemented (result != vk::Result::eSuccess) in ...\src\graphics\host_gpu\renderer\masterSemaphore.cpp:53

That line is waitSemaphores(..., UINT64_MAX) in MasterSemaphore::Wait. With an infinite timeout, its only non-success results are out-of-memory or VK_ERROR_DEVICE_LOST. The game's own SubmissionManagerPs5::waitForFrame timeouts (0x8002003C) come right before it in the log. fozter's builds with VK_NV_device_diagnostic_checkpoints and VK_EXT_device_fault stop at the same draw every time: RectList DrawIndexAuto, 3 vertices × 3108 instances, VS 0x126d611593f8bf08 + PS 0x1da1fd2871174330. The fault has instruction pointers only, so it's a shader hang.

Cause. The PS is wave64. It walks a per-tile light list with the WaveActiveMin idiom (s_orn2_saveexec, v_cndmask -1, DPP row_shr v_min_u32 with bound_ctrl=0, v_permlanex16, v_readlane 31 and 63). It loops until every lane has consumed its list. The host subgroup is a fixed 32 wide (size_control=false), so the PS runs without split halves, and two things go wrong:

  • v_readlane 63 names a lane the subgroup doesn't have, so the shuffle is undefined.
  • A fragment subgroup can lack lanes the guest wave has (helper invocations that skip subgroup operations, partially filled subgroups). DPP/permlane reads from those lanes are undefined too.

The min then picks a value no lane holds, no lane advances, and the loop never ends.

Change (spirvEmitterFlow.cpp, spirvEmitterHelpers.cpp):

  • V_READLANE_B32 in a wave64 program without split halves wraps the lane by gl_SubgroupSize. This is a no-op on 64-wide subgroups. EmitSubgroupSize declares the builtin on first use (Flat in pixel shaders).
  • Pixel shaders only: each cross-lane read checks its source lane against ballot(true).
    • DPP16 leaves the destination unwritten.
    • v_permlane16/v_permlanex16 return the lane's own value, and read the source EXEC bit from a ballot instead of shuffling it.
    • v_readlane reads the highest lane present.
  • Other stages are unchanged.

The fallbacks are identities for min/max scans: an unwritten DPP destination keeps the running min/max, and min(x, x) = x. They aren't a general answer. The own-value fallback in permlane would double-count an add reduction. The presence check reuses main's EmitBallotLaneActiveBool on ctx.Ballot(true). EmitSubgroupLaneActiveBool isn't used, because it ballots only the host subgroup, so with split wave64 halves it would report lanes 32-63 as missing.

Which part fixes the hang. fozter bisected his original patch in the game. Each variant was a full rebuild, run to the first gameplay frame with the device-fault diagnostics on:

Variant Result at that draw
DPP inactive-source gate only (FI=0, BOUND_CTRL=0) still hangs
readlane changes only still hangs
DPP gate + readlane still hangs
DPP gate + PS missing-lane DPP/permlane handling still hangs
readlane + PS missing-lane handling (no DPP gate) passes
full patch passes

This PR is the "readlane + PS missing-lane handling" row. The DPP gate (no write from an EXEC-inactive source with FI=0/BOUND_CTRL=0) matches the ISA, but it doesn't stop this hang, so I left it out. I'm keeping it for a separate PR with its own test.

Test. CheckPixelCrossLaneMissingLanes in ShaderRecompilerComputeTests.cpp compiles a wave64 pixel shader with v_mov_b32_dpp row_shr:1, v_permlanex16_b32 and v_readlane_b32 s4, v1, 63. It checks:

  • the SPIR-V validates (CompileFragmentCase)
  • it declares BuiltIn SubgroupSize
  • it has one OpGroupNonUniformBallotFindMSB and at least five OpGroupNonUniformBallot
  • the compute readlane case (VectorReadlaneSelectsTwoKeysWithinWave) gets no FindMSB

It doesn't need a device.

Related open PRs:

  • #937 (Wolverine) has a commit with the same goal: e1580f9bb "spirv: DPP16 leaves the destination alone for missing or inactive sources", plus a V_READLANE fallback (highest active lane at or below the target in its 16-lane row, else 0) and native reductions for DPP scans. It applies to all stages. This PR is narrower: pixel shaders only, plus the wave64 wrap, and it's the version tested on NHL. They conflict textually in spirvEmitterFlow.cpp.
  • #1503 rewrites wave64 DPP OR scans into native reductions. It's a different idiom and merges cleanly with this.
  • #761 makes ctx.Ballot exclude helper invocations in pixel shaders. With both merged, helpers would count as missing lanes here, which is consistent with #761's model, but that combination is untested. #761 also realigns the EmitterState fields, so the field this PR adds conflicts textually in spirvEmitterInternal.h.

Testing

  • Human testing: fozter tested this change in NHL 27 on an RTX 3060 Ti (Windows). With it, the draw no longer hangs and the run continues into gameplay. Without it, the draw hangs every time (table above). He tested it on an earlier main (df5b9b92 + #1446), as part of his larger patch.
  • On current main I compiled the test's pixel shader through TranslateProgram/CompileProgram in a native harness and ran spirv-val (SPIRV-Tools at the pinned submodule, Vulkan 1.2 env):
    • This PR: valid, SubgroupSize declared, 1 FindMSB, 5 ballots.
    • main: valid, no SubgroupSize, 0 FindMSB, 1 ballot, so the new test fails on main.
    • With the readlane ballot unshared, the output is byte-identical to fozter's tested variant (his full patch with the DPP gate turned off). This PR shares one ballot(true) between the presence check and FindMSB, which gives the same values.
  • x86_64-linux compile (-Wall -Wextra) of spirvEmitterFlow.cpp and spirvEmitterHelpers.cpp: no new warnings. The test file builds with -fsyntax-only.
  • Not run: the full shader_recompiler_compute_tests binary (it needs a Vulkan device), and nothing on MoltenVK. threads_per_simdgroup should be allowed in Metal fragment functions (vertex functions reject it, see #983), but I haven't tried it.

fozter found the hang, wrote the patch and did the bisect (#1101). He's said others may use his findings (#1101), so he's the commit author. I split out the part his bisect shows is needed, rebased it onto current main, reused the existing ballot helper, ran clang-format and added the test.

AI-assisted: yes. fozter's investigation, patch and bisect were done with Claude. I used AI to split and rebase the patch, write the test and the harness, and draft this text. I reviewed the change and ran the checks above.

**@⁠overlordxrz-source** on GitHub · 2026-10-14 19:35 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1515) `overlordxrz-source:nhl-ps-cross-lane-missing-lanes` → `main` · +128 −5 · 4 files · 1 commits · closed without merging Fixes the NHL 27 (PPSA34063, #1101) GPU hang in PS `0x1da1fd2871174330`. On fozter's RTX 3060 Ti it ends as a device loss about 15 s into the loading screen after START GAME: ``` Not implemented (result != vk::Result::eSuccess) in ...\src\graphics\host_gpu\renderer\masterSemaphore.cpp:53 ``` That line is `waitSemaphores(..., UINT64_MAX)` in `MasterSemaphore::Wait`. With an infinite timeout, its only non-success results are out-of-memory or `VK_ERROR_DEVICE_LOST`. The game's own `SubmissionManagerPs5::waitForFrame` timeouts (`0x8002003C`) come right before it in the log. fozter's builds with VK_NV_device_diagnostic_checkpoints and VK_EXT_device_fault stop at the same draw every time: RectList `DrawIndexAuto`, 3 vertices × 3108 instances, VS `0x126d611593f8bf08` + PS `0x1da1fd2871174330`. The fault has instruction pointers only, so it's a shader hang. **Cause.** The PS is wave64. It walks a per-tile light list with the WaveActiveMin idiom (`s_orn2_saveexec`, `v_cndmask` -1, DPP `row_shr` `v_min_u32` with bound_ctrl=0, `v_permlanex16`, `v_readlane` 31 and 63). It loops until every lane has consumed its list. The host subgroup is a fixed 32 wide (`size_control=false`), so the PS runs without split halves, and two things go wrong: - `v_readlane` 63 names a lane the subgroup doesn't have, so the shuffle is undefined. - A fragment subgroup can lack lanes the guest wave has (helper invocations that skip subgroup operations, partially filled subgroups). DPP/permlane reads from those lanes are undefined too. The min then picks a value no lane holds, no lane advances, and the loop never ends. **Change** (spirvEmitterFlow.cpp, spirvEmitterHelpers.cpp): - `V_READLANE_B32` in a wave64 program without split halves wraps the lane by `gl_SubgroupSize`. This is a no-op on 64-wide subgroups. `EmitSubgroupSize` declares the builtin on first use (Flat in pixel shaders). - Pixel shaders only: each cross-lane read checks its source lane against `ballot(true)`. - DPP16 leaves the destination unwritten. - `v_permlane16`/`v_permlanex16` return the lane's own value, and read the source EXEC bit from a ballot instead of shuffling it. - `v_readlane` reads the highest lane present. - Other stages are unchanged. The fallbacks are identities for min/max scans: an unwritten DPP destination keeps the running min/max, and `min(x, x) = x`. They aren't a general answer. The own-value fallback in permlane would double-count an add reduction. The presence check reuses main's `EmitBallotLaneActiveBool` on `ctx.Ballot(true)`. `EmitSubgroupLaneActiveBool` isn't used, because it ballots only the host subgroup, so with split wave64 halves it would report lanes 32-63 as missing. **Which part fixes the hang.** fozter bisected his original patch in the game. Each variant was a full rebuild, run to the first gameplay frame with the device-fault diagnostics on: | Variant | Result at that draw | |---|---| | DPP inactive-source gate only (FI=0, BOUND_CTRL=0) | still hangs | | readlane changes only | still hangs | | DPP gate + readlane | still hangs | | DPP gate + PS missing-lane DPP/permlane handling | still hangs | | readlane + PS missing-lane handling (no DPP gate) | **passes** | | full patch | **passes** | This PR is the "readlane + PS missing-lane handling" row. The DPP gate (no write from an EXEC-inactive source with FI=0/BOUND_CTRL=0) matches the ISA, but it doesn't stop this hang, so I left it out. I'm keeping it for a separate PR with its own test. **Test.** `CheckPixelCrossLaneMissingLanes` in ShaderRecompilerComputeTests.cpp compiles a wave64 pixel shader with `v_mov_b32_dpp row_shr:1`, `v_permlanex16_b32` and `v_readlane_b32 s4, v1, 63`. It checks: - the SPIR-V validates (`CompileFragmentCase`) - it declares `BuiltIn SubgroupSize` - it has one `OpGroupNonUniformBallotFindMSB` and at least five `OpGroupNonUniformBallot` - the compute readlane case (`VectorReadlaneSelectsTwoKeysWithinWave`) gets no FindMSB It doesn't need a device. **Related open PRs:** - #937 (Wolverine) has a commit with the same goal: e1580f9bb "spirv: DPP16 leaves the destination alone for missing or inactive sources", plus a V_READLANE fallback (highest active lane at or below the target in its 16-lane row, else 0) and native reductions for DPP scans. It applies to all stages. This PR is narrower: pixel shaders only, plus the wave64 wrap, and it's the version tested on NHL. They conflict textually in spirvEmitterFlow.cpp. - #1503 rewrites wave64 DPP OR scans into native reductions. It's a different idiom and merges cleanly with this. - #761 makes `ctx.Ballot` exclude helper invocations in pixel shaders. With both merged, helpers would count as missing lanes here, which is consistent with #761's model, but that combination is untested. #761 also realigns the `EmitterState` fields, so the field this PR adds conflicts textually in spirvEmitterInternal.h. **Testing** - Human testing: fozter tested this change in NHL 27 on an RTX 3060 Ti (Windows). With it, the draw no longer hangs and the run continues into gameplay. Without it, the draw hangs every time (table above). He tested it on an earlier main (df5b9b92 + #1446), as part of his larger patch. - On current main I compiled the test's pixel shader through `TranslateProgram`/`CompileProgram` in a native harness and ran spirv-val (SPIRV-Tools at the pinned submodule, Vulkan 1.2 env): - This PR: valid, `SubgroupSize` declared, 1 FindMSB, 5 ballots. - main: valid, no `SubgroupSize`, 0 FindMSB, 1 ballot, so the new test fails on main. - With the readlane ballot unshared, the output is byte-identical to fozter's tested variant (his full patch with the DPP gate turned off). This PR shares one `ballot(true)` between the presence check and FindMSB, which gives the same values. - x86_64-linux compile (`-Wall -Wextra`) of spirvEmitterFlow.cpp and spirvEmitterHelpers.cpp: no new warnings. The test file builds with `-fsyntax-only`. - Not run: the full `shader_recompiler_compute_tests` binary (it needs a Vulkan device), and nothing on MoltenVK. `threads_per_simdgroup` should be allowed in Metal fragment functions (vertex functions reject it, see #983), but I haven't tried it. fozter found the hang, wrote the patch and did the bisect (https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/1101). He's said others may use his findings (https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/1101), so he's the commit author. I split out the part his bisect shows is needed, rebased it onto current main, reused the existing ballot helper, ran clang-format and added the test. AI-assisted: yes. fozter's investigation, patch and bisect were done with Claude. I used AI to split and rebase the patch, write the test and the harness, and draft this text. I reviewed the change and ran the checks above.
NHL 27 (PPSA34063, #1101) loses the GPU about 15 seconds into the loading
screen after START GAME. In fozter's builds with device-fault diagnostics,
the last checkpoint that completes is a RectList DrawIndexAuto (3 vertices
x 3108 instances, VS 0x126d611593f8bf08, PS 0x1da1fd2871174330), and the
fault reports only instruction pointers: a shader hang. In a normal build
the game first reports SubmissionManagerPs5::waitForFrame timeouts
(0x8002003C), then MasterSemaphore::Wait's waitSemaphores(UINT64_MAX)
fails and Kyty exits with "Not implemented (result != vk::Result::eSuccess)"
at masterSemaphore.cpp:53. The host is an RTX 3060 Ti with a fixed 32-wide
subgroup and no subgroup size control, so the wave64 pixel shader runs
without split halves.

fozter traced the PS: it walks a per-tile light list with the
WaveActiveMin idiom (s_orn2_saveexec, v_cndmask -1, DPP row_shr v_min_u32
with bound_ctrl=0, v_permlanex16, v_readlane 31 and 63) and loops until
every lane has consumed its list. If the reduction returns a value no lane
holds, no lane advances and the loop never ends. Two things make that
reduction read undefined values on this host:

- V_READLANE_B32 can name lanes 32-63, which a 32-wide subgroup does not
  have. For a wave64 program without split halves, wrap the lane by
  gl_SubgroupSize. This is a no-op on 64-wide subgroups.
- In a pixel shader, a source lane can be missing from the host subgroup
  (helper invocations that skip subgroup operations, partially filled
  subgroups). SPIR-V leaves a value read from such a lane undefined. Pixel
  shaders now check the source lane against ballot(true):
  - DPP16 leaves the destination unwritten.
  - permlane16/permlanex16 return the lane's own value, and read the
    source EXEC bit from a ballot instead of shuffling it.
  - V_READLANE reads the highest lane present, which holds the widest
    prefix of a row or half reduction.

These fallbacks are identities for the min/max scan idiom the shader
uses: an unwritten DPP destination keeps the running min/max, and
min(x, x) = x. They are not general. The own-value fallback in
permlane16/permlanex16 would double-count an add reduction.

The guard reuses main's EmitBallotLaneActiveBool on ctx.Ballot(true).
EmitSubgroupLaneActiveBool isn't used because it ballots only the host
subgroup, so with split wave64 halves it would report lanes 32-63 as
missing.

fozter bisected the original patch on the game, each variant a full rebuild
run to the first gameplay frame with device-fault diagnostics on:

  DPP inactive-source gate only (FI=0, BOUND_CTRL=0)     still hangs
  readlane changes only                                  still hangs
  DPP gate + readlane                                    still hangs
  DPP gate + PS missing-lane DPP/permlane handling       still hangs
  readlane + PS missing-lane handling (no DPP gate)      passes
  full patch                                             passes

This commit is the passing "readlane + PS missing-lane handling" variant.
The DPP gate is an ISA fix that doesn't fix this hang, so it isn't included.
The test compiles a wave64 pixel shader that uses DPP, permlanex16 and
V_READLANE_B32 lane 63. It checks that the SPIR-V validates, declares
SubgroupSize, guards the reads with ballots and has the readlane fallback,
and that a compute shader doesn't get the fallback.

Co-authored-by: overlordxrz-source <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:27 +00:00
github-bot closed this pull request 2026-11-26 09:58:27 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-14 19:43 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c12ad26a-05d9-46dc-b63a-1a1d598ad1d3
📥 Commits

Reviewing files that changed from the base of the PR and between 9e41d8320a and 6ab5269936.

📒 Files selected for processing: 4
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • tests/ShaderRecompilerComputeTests.cpp

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

📝 Walkthrough

The SPIR-V emitter now handles missing host-subgroup lanes in pixel-shader DPP updates, lane reads, and permutes. It adds a cached subgroup-size input. Non-pixel shader paths retain their existing behavior. A regression test checks emitted SPIR-V patterns for pixel shaders and verifies that the missing-lane fallback is absent for a compute shader.

Suggested reviewers: nmzik

Priority: ⬆️ High

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 6ab52

No confirmed issue currently prevents merging, subject to normal validation.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the pixel-shader cross-lane fix, the NHL 27 GPU hang, implementation scope, testing, and known limitations. It is directly related to the changeset.
Title check Passed The title is concise and accurately identifies the main change: guarding pixel-shader cross-lane reads against unavailable host-subgroup lanes.
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: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. (1 skipped: 1 too large.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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-14 19:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1515#issuecomment-6176843213) <!-- 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/1515?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 --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `c12ad26a-05d9-46dc-b63a-1a1d598ad1d3` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 9e41d8320a2774b303fbad344c2347e8d0292e83 and 6ab52699364b059d39e714e36148d9e33ea0467f. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 4</strong></summary> <dl> <dd> * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The SPIR-V emitter now handles missing host-subgroup lanes in pixel-shader DPP updates, lane reads, and permutes. It adds a cached subgroup-size input. Non-pixel shader paths retain their existing behavior. A regression test checks emitted SPIR-V patterns for pixel shaders and verifies that the missing-lane fallback is absent for a compute shader. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬆️ High <!-- change_assessment_commit:"6ab52699364b059d39e714e36148d9e33ea0467f" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>6ab52</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `6ab52` --> <!-- final_review_risk_coverage:{"sourceCommitId":"6ab52699364b059d39e714e36148d9e33ea0467f","coveredCommitId":"6ab52699364b059d39e714e36148d9e33ea0467f","kind":"reviewed"} --> No confirmed issue currently prevents merging, subject to normal validation. <!-- 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 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. (1 skipped: … | 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 | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains the pixel-shader cross-lane fix, the NHL 27 GPU hang, implementation scope, testing, and known limitations. It is directly related to the changeset. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title is concise and accurately identifies the main change: guarding pixel-shader cross-lane reads against unavailable host-subgroup lanes. | | 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. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. (1 skipped: 1 too large.) </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1515)! 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 -->
Author
Owner

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

I ran the idiom from this PR's description as a GPU test on an AMD RX 9070 XT (Windows 11, AMD driver 26.8.1, LLPC, subgroup size 64), on 9e41d832 (plus #1504's test-build fix) and on the same tree with this PR's commit 6ab52699 cherry-picked (it applied cleanly):

s_orn2_saveexec_b64 s[10:11], exec
v_mov_b32 v1, X
v_cndmask_b32 v1, -1, v1, s[10:11]
v_min_u32_dpp v1, v1, v1 row_shr:1, then :2, :4, :8    (BOUND_CTRL bit 0)
v_permlanex16_b32 v2, v1, -1, -1
v_min_u32 v1, v1, v2
v_readlane_b32 s4, v1, 31
v_readlane_b32 s5, v1, 63
s_min_u32 s4, s4, s5
s_mov_b64 exec, s[10:11]
v_mov_b32 v3, s4      ; exported to all four channels

The test draws into a 1x1 RGBA32F target, so the host fragment subgroup has a single invocation. On a console all 64 lanes of the wave exist:

  • s_orn2_saveexec turns them all on, and the v_cndmask gives the lanes that weren't launched -1.
  • The row_shr scan leaves each 16-lane row's minimum in its lane 15.
  • v_permlanex16 with -1/-1 passes that value to the other row of the same half.

So lanes 31 and 63 hold the minimum of their halves, and the result is X.

X 9e41d832, 5 runs with #1515, 5 runs
0x3f000000 0x34c43434, 0x00000003, 0x0000305c, 0x0000002f, 0x00000017 0x3f000000 in all 5
0x40400000 0x0000003b, 0xad92a729, 0x00000007, 0x00000017, 0x31893279 0x40400000 in all 5

So on main, reads of lanes the host subgroup doesn't have return undefined values on AMD too, not only on 32-lane NVIDIA, when a wave64 pixel shader runs with fewer invocations than the guest wave has lanes (here a single pixel). With this PR the result here is correct and stable. The SPIR-V on main has no SubgroupSize and no OpGroupNonUniformBallotFindMSB; with the PR it has SubgroupSize and two OpGroupNonUniformBallotFindMSB.

The PR's own test checks only the disassembly, and CI doesn't run shader_recompiler_compute_tests, so I thought a GPU run on a non-NVIDIA card would help. A few notes from reading the change (not measured):

  • A lane missing in the middle of a row, rather than at its end, still cuts off the row_shr scan below it.
  • Two fallbacks give the right result for min/max but not for add or xor reductions: a missing permlane source returns the lane's own value, and readlane of a missing lane returns the highest present lane. The description already says the fallback isn't general.
  • The missing-lane fallbacks are pixel-only (MayLackLanes), so vertex, hull and domain shaders and partial compute waves still read missing lanes as undefined; only the readlane wrap applies to every wave64 stage. #1503 handles the same idiom family for OR with a proof of which lanes were launched; extended to min/max/add, that approach would also cover these cases.

Written with Claude Code (AI); the runs above were made on my PC with Claude Code, and I checked the raw outputs.

**@⁠Nawid3333** on GitHub · 2026-10-15 22:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1515#issuecomment-6203417951) I ran the idiom from this PR's description as a GPU test on an AMD RX 9070 XT (Windows 11, AMD driver 26.8.1, LLPC, subgroup size 64), on 9e41d832 (plus #1504's test-build fix) and on the same tree with this PR's commit 6ab52699 cherry-picked (it applied cleanly): ``` s_orn2_saveexec_b64 s[10:11], exec v_mov_b32 v1, X v_cndmask_b32 v1, -1, v1, s[10:11] v_min_u32_dpp v1, v1, v1 row_shr:1, then :2, :4, :8 (BOUND_CTRL bit 0) v_permlanex16_b32 v2, v1, -1, -1 v_min_u32 v1, v1, v2 v_readlane_b32 s4, v1, 31 v_readlane_b32 s5, v1, 63 s_min_u32 s4, s4, s5 s_mov_b64 exec, s[10:11] v_mov_b32 v3, s4 ; exported to all four channels ``` The test draws into a 1x1 RGBA32F target, so the host fragment subgroup has a single invocation. On a console all 64 lanes of the wave exist: - `s_orn2_saveexec` turns them all on, and the `v_cndmask` gives the lanes that weren't launched -1. - The `row_shr` scan leaves each 16-lane row's minimum in its lane 15. - `v_permlanex16` with -1/-1 passes that value to the other row of the same half. So lanes 31 and 63 hold the minimum of their halves, and the result is X. | X | 9e41d832, 5 runs | with #1515, 5 runs | |---|---|---| | 0x3f000000 | 0x34c43434, 0x00000003, 0x0000305c, 0x0000002f, 0x00000017 | 0x3f000000 in all 5 | | 0x40400000 | 0x0000003b, 0xad92a729, 0x00000007, 0x00000017, 0x31893279 | 0x40400000 in all 5 | So on main, reads of lanes the host subgroup doesn't have return undefined values on AMD too, not only on 32-lane NVIDIA, when a wave64 pixel shader runs with fewer invocations than the guest wave has lanes (here a single pixel). With this PR the result here is correct and stable. The SPIR-V on main has no `SubgroupSize` and no `OpGroupNonUniformBallotFindMSB`; with the PR it has `SubgroupSize` and two `OpGroupNonUniformBallotFindMSB`. The PR's own test checks only the disassembly, and CI doesn't run `shader_recompiler_compute_tests`, so I thought a GPU run on a non-NVIDIA card would help. A few notes from reading the change (not measured): - A lane missing in the middle of a row, rather than at its end, still cuts off the row_shr scan below it. - Two fallbacks give the right result for min/max but not for add or xor reductions: a missing permlane source returns the lane's own value, and readlane of a missing lane returns the highest present lane. The description already says the fallback isn't general. - The missing-lane fallbacks are pixel-only (`MayLackLanes`), so vertex, hull and domain shaders and partial compute waves still read missing lanes as undefined; only the readlane wrap applies to every wave64 stage. #1503 handles the same idiom family for OR with a proof of which lanes were launched; extended to min/max/add, that approach would also cover these cases. Written with Claude Code (AI); the runs above were made on my PC with Claude Code, and I checked the raw outputs.
Author
Owner

@⁠overlordxrz-source on GitHub · 2026-10-16 18:52 UTC · original

@⁠Nawid3333 thanks for running this on a 9070 XT. That shows the problem isn't NVIDIA-only. You're right on the limits: a lane missing mid-row still cuts the row_shr scan, and the fallbacks are only right for min/max. #1503's launched-lane proof, extended to min/max/add, would be the general fix. I'd rather keep this one narrow and fold it into that if Nmzik prefers.

AI-assisted: yes

**@⁠overlordxrz-source** on GitHub · 2026-10-16 18:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1515#issuecomment-6222508108) @⁠Nawid3333 thanks for running this on a 9070 XT. That shows the problem isn't NVIDIA-only. You're right on the limits: a lane missing mid-row still cuts the row_shr scan, and the fallbacks are only right for min/max. #1503's launched-lane proof, extended to min/max/add, would be the general fix. I'd rather keep this one narrow and fold it into that if Nmzik prefers. AI-assisted: yes
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-16 19:15 UTC · original

Agreed, keeping this one narrow makes sense. For the general fix: I measured the add form of the same idiom at 5dec5231, which includes nmzik's 302240da (it lowers only the UMin form), on an RX 9070 XT (driver 26.8.1, LLPC). A pixel shader counts its wave with v_readlane 31 + 63 (and a row_xmask variant with lanes 0 + 32); the expected count is s_bcnt1 of the entry EXEC.

count / expected 8x8, 64 lanes 8x8, 32 lanes 8x4 (half wave), 64 lanes
row_shr 64 / 64 64 / 32 95 or 33 / 32
row_xmask 64 / 64 64 / 32 7.5e8 to 2.9e9 (u32) / 32

With 32 lanes (requiredSubgroupSize 32), LLPC returns lane 31 or 0 for a read of lane 63 or 32, so each half is counted twice. With a half-filled wave at 64 lanes those reads return stale values. DPP, v_permlanex16 and constant-lane v_writelane/v_readlane (folded at compile time) were correct. Extending the matching of 302240da and #1503 to add, the other min/max and and/or/xor, and to the row_xmask + lanes 0/32 shape should cover these (not tried). The tests are below; on main they fail on this GPU in the two half-wave cases, and with 32 lanes in all four.

Tests: tests/ShaderRecompilerComputeTests.cpp, applies to 5dec5231
diff --git a/tests/ShaderRecompilerComputeTests.cpp b/tests/ShaderRecompilerComputeTests.cpp
index 627a8112..13420707 100644
--- a/tests/ShaderRecompilerComputeTests.cpp
+++ b/tests/ShaderRecompilerComputeTests.cpp
@@ -1393,6 +1393,7 @@ struct GraphicsCase {
   u32 pixel_perspective_centroid_vgpr = UINT32_MAX;
   u32 pixel_custom_interpolation_mask = 0;
   u32 width = 1;
+  u32 height = 1;
   std::vector<u32> object_ids;
 };
 
@@ -18373,7 +18374,7 @@ public:
     ValidateSpirv(test.name, vertex_spirv);
 
     Image target =
-        CreateImageMips(test.name, test.width, 1, vk::Format::eR32G32B32A32Sfloat,
+        CreateImageMips(test.name, test.width, test.height, vk::Format::eR32G32B32A32Sfloat,
                       vk::ImageUsageFlagBits::eColorAttachment, {}, 4,
                       vk::ImageLayout::eGeneral, vk::ImageType::e2D,
                       test.layers > 1 ? vk::ImageViewType::e2DArray : vk::ImageViewType::e2D,
@@ -18381,7 +18382,7 @@ public:
     Image resolved;
     if (test.samples != vk::SampleCountFlagBits::e1) {
       resolved = CreateImageMips(
-          test.name, test.width, 1, target.format, vk::ImageUsageFlagBits::eColorAttachment,
+          test.name, test.width, test.height, target.format, vk::ImageUsageFlagBits::eColorAttachment,
           {}, 4, vk::ImageLayout::eGeneral, vk::ImageType::e2D,
           test.layers > 1 ? vk::ImageViewType::e2DArray : vk::ImageViewType::e2D,
           test.layers);
@@ -18389,7 +18390,7 @@ public:
     Image primitive_target;
     if (object_id) {
       primitive_target = CreateImageMips(
-          test.name, test.width, 1, vk::Format::eR32Uint,
+          test.name, test.width, test.height, vk::Format::eR32Uint,
           vk::ImageUsageFlagBits::eColorAttachment, {}, 1,
           vk::ImageLayout::eGeneral, vk::ImageType::e2D,
           test.layers > 1 ? vk::ImageViewType::e2DArray : vk::ImageViewType::e2D,
@@ -18476,12 +18477,12 @@ public:
     viewport.x = 0.0f;
     viewport.y = 0.0f;
     viewport.width = static_cast<float>(test.width);
-    viewport.height = 1.0f;
+    viewport.height = static_cast<float>(test.height);
     viewport.minDepth = 0.0f;
     viewport.maxDepth = 1.0f;
     vk::Rect2D scissor{};
     scissor.extent.width = test.width;
-    scissor.extent.height = 1;
+    scissor.extent.height = test.height;
     vk::PipelineViewportStateCreateInfo viewport_state{};
     viewport_state.sType = vk::StructureType::ePipelineViewportStateCreateInfo;
     viewport_state.viewportCount = 1;
@@ -18561,7 +18562,7 @@ public:
     }
     vk::RenderingInfo rendering{};
     rendering.sType = vk::StructureType::eRenderingInfo;
-    rendering.renderArea.extent = {test.width, 1};
+    rendering.renderArea.extent = {test.width, test.height};
     rendering.layerCount = test.layers;
     rendering.colorAttachmentCount = color_blend.attachmentCount;
     rendering.pColorAttachments = colors.data();
@@ -41423,6 +41424,47 @@ GraphicsCase GraphicsFrontFaceBits(bool reversed, bool all_bits) {
   return test;
 }
 
+GraphicsCase GraphicsWave64WholeWaveCount(u32 height, bool lanes_0_32) {
+  static const char *const names[2][2] = {
+      {"GraphicsWave64WholeWaveCount8x4Lanes31And63", "GraphicsWave64WholeWaveCount8x4Lanes0And32"},
+      {"GraphicsWave64WholeWaveCount8x8Lanes31And63", "GraphicsWave64WholeWaveCount8x8Lanes0And32"}};
+  GraphicsCase test;
+  test.name = names[height == 8u][lanes_0_32];
+  test.width = 8;
+  test.height = height;
+  auto &code = test.fragment_code;
+  code = {EncodeVop1(0x01, 13, InlineU32(1)),
+          EncodeSop1(0x10, 9, 126),
+          EncodeSop1(0x04, 24, 126),
+          EncodeSop1(0x28, 106, 126)};
+  AppendVop3(&code, 0x101, 13, InlineU32(0), Vgpr(13), 24);
+  for (u32 shift : {1u, 2u, 4u, 8u}) {
+    code.push_back(EncodeVop2(0x25, 13, 250, 13));
+    code.push_back(EncodeVop2Dpp(13, (lanes_0_32 ? 0x160u : 0x110u) + shift));
+  }
+  code.insert(code.end(), {0xd778100cu, 0x0305830du,
+                          EncodeVop2(0x25, 13, Vgpr(13), 12),
+                          EncodeSop1(0x04, 126, 106)});
+  AppendVop3(&code, 0x360, 6, Vgpr(13), InlineU32(lanes_0_32 ? 0u : 31u));
+  AppendVop3(&code, 0x360, 7, Vgpr(13), InlineU32(lanes_0_32 ? 32u : 63u));
+  code.insert(code.end(), {EncodeSop2(0x00, 8, 6, 7),
+                          EncodeSopc(0x06, 8, 9),
+                          EncodeSop2(0x0a, 10, 242, 128),
+                          EncodeSop2(0x03, 11, 8, 9),
+                          EncodeVop1(0x01, 0, 10), EncodeVop1(0x05, 1, 11),
+                          EncodeVop1(0x01, 2, InlineU32(0)), EncodeVop1(0x01, 3, 242),
+                          EncodeExp0(0x00, 0xf), EncodeExp1(0, 1, 2, 3)});
+  AppendEnd(&code);
+  for (u32 i = 0; i < 8u * height; i++) {
+    test.expected_pixel.insert(test.expected_pixel.end(),
+                               {0x3f800000u, 0u, 0u, 0x3f800000u});
+  }
+  test.opcodes = {ShaderOpcode::S_BCNT1_I32_B64, ShaderOpcode::V_ADD_NC_U32,
+                  ShaderOpcode::V_PERMLANEX16_B32, ShaderOpcode::V_READLANE_B32,
+                  ShaderOpcode::S_ADD_U32};
+  return test;
+}
+
 void CheckPixelFrontFaceModes() {
   constexpr const char *name = "PixelFrontFaceModes";
   static const std::array<u32, 1> code = {EncodeSopp(0x01)};
@@ -42351,6 +42393,10 @@ std::vector<GraphicsCase> MakeGraphicsCases() {
       GraphicsBranchPathFinalVmExportDiscardsInactiveExec(),
       GraphicsObjectPrimitiveId(false),
       GraphicsObjectPrimitiveId(true),
+      GraphicsWave64WholeWaveCount(8, false),
+      GraphicsWave64WholeWaveCount(8, true),
+      GraphicsWave64WholeWaveCount(4, false),
+      GraphicsWave64WholeWaveCount(4, true),
   };
 }
 

Written with Claude Code (AI): it wrote the tests and ran them on my PC. I read this comment before posting it.

**@⁠Nawid3333** on GitHub · 2026-10-16 19:15 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1515#issuecomment-6222897035) Agreed, keeping this one narrow makes sense. For the general fix: I measured the add form of the same idiom at 5dec5231, which includes nmzik's 302240da (it lowers only the UMin form), on an RX 9070 XT (driver 26.8.1, LLPC). A pixel shader counts its wave with `v_readlane` 31 + 63 (and a row_xmask variant with lanes 0 + 32); the expected count is `s_bcnt1` of the entry EXEC. | count / expected | 8x8, 64 lanes | 8x8, 32 lanes | 8x4 (half wave), 64 lanes | |---|---|---|---| | row_shr | 64 / 64 | 64 / 32 | 95 or 33 / 32 | | row_xmask | 64 / 64 | 64 / 32 | 7.5e8 to 2.9e9 (u32) / 32 | With 32 lanes (`requiredSubgroupSize` 32), LLPC returns lane 31 or 0 for a read of lane 63 or 32, so each half is counted twice. With a half-filled wave at 64 lanes those reads return stale values. DPP, `v_permlanex16` and constant-lane `v_writelane`/`v_readlane` (folded at compile time) were correct. Extending the matching of 302240da and #1503 to add, the other min/max and and/or/xor, and to the row_xmask + lanes 0/32 shape should cover these (not tried). The tests are below; on main they fail on this GPU in the two half-wave cases, and with 32 lanes in all four. <details><summary>Tests: tests/ShaderRecompilerComputeTests.cpp, applies to 5dec5231</summary> ```diff diff --git a/tests/ShaderRecompilerComputeTests.cpp b/tests/ShaderRecompilerComputeTests.cpp index 627a8112..13420707 100644 --- a/tests/ShaderRecompilerComputeTests.cpp +++ b/tests/ShaderRecompilerComputeTests.cpp @@ -1393,6 +1393,7 @@ struct GraphicsCase { u32 pixel_perspective_centroid_vgpr = UINT32_MAX; u32 pixel_custom_interpolation_mask = 0; u32 width = 1; + u32 height = 1; std::vector<u32> object_ids; }; @@ -18373,7 +18374,7 @@ public: ValidateSpirv(test.name, vertex_spirv); Image target = - CreateImageMips(test.name, test.width, 1, vk::Format::eR32G32B32A32Sfloat, + CreateImageMips(test.name, test.width, test.height, vk::Format::eR32G32B32A32Sfloat, vk::ImageUsageFlagBits::eColorAttachment, {}, 4, vk::ImageLayout::eGeneral, vk::ImageType::e2D, test.layers > 1 ? vk::ImageViewType::e2DArray : vk::ImageViewType::e2D, @@ -18381,7 +18382,7 @@ public: Image resolved; if (test.samples != vk::SampleCountFlagBits::e1) { resolved = CreateImageMips( - test.name, test.width, 1, target.format, vk::ImageUsageFlagBits::eColorAttachment, + test.name, test.width, test.height, target.format, vk::ImageUsageFlagBits::eColorAttachment, {}, 4, vk::ImageLayout::eGeneral, vk::ImageType::e2D, test.layers > 1 ? vk::ImageViewType::e2DArray : vk::ImageViewType::e2D, test.layers); @@ -18389,7 +18390,7 @@ public: Image primitive_target; if (object_id) { primitive_target = CreateImageMips( - test.name, test.width, 1, vk::Format::eR32Uint, + test.name, test.width, test.height, vk::Format::eR32Uint, vk::ImageUsageFlagBits::eColorAttachment, {}, 1, vk::ImageLayout::eGeneral, vk::ImageType::e2D, test.layers > 1 ? vk::ImageViewType::e2DArray : vk::ImageViewType::e2D, @@ -18476,12 +18477,12 @@ public: viewport.x = 0.0f; viewport.y = 0.0f; viewport.width = static_cast<float>(test.width); - viewport.height = 1.0f; + viewport.height = static_cast<float>(test.height); viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; vk::Rect2D scissor{}; scissor.extent.width = test.width; - scissor.extent.height = 1; + scissor.extent.height = test.height; vk::PipelineViewportStateCreateInfo viewport_state{}; viewport_state.sType = vk::StructureType::ePipelineViewportStateCreateInfo; viewport_state.viewportCount = 1; @@ -18561,7 +18562,7 @@ public: } vk::RenderingInfo rendering{}; rendering.sType = vk::StructureType::eRenderingInfo; - rendering.renderArea.extent = {test.width, 1}; + rendering.renderArea.extent = {test.width, test.height}; rendering.layerCount = test.layers; rendering.colorAttachmentCount = color_blend.attachmentCount; rendering.pColorAttachments = colors.data(); @@ -41423,6 +41424,47 @@ GraphicsCase GraphicsFrontFaceBits(bool reversed, bool all_bits) { return test; } +GraphicsCase GraphicsWave64WholeWaveCount(u32 height, bool lanes_0_32) { + static const char *const names[2][2] = { + {"GraphicsWave64WholeWaveCount8x4Lanes31And63", "GraphicsWave64WholeWaveCount8x4Lanes0And32"}, + {"GraphicsWave64WholeWaveCount8x8Lanes31And63", "GraphicsWave64WholeWaveCount8x8Lanes0And32"}}; + GraphicsCase test; + test.name = names[height == 8u][lanes_0_32]; + test.width = 8; + test.height = height; + auto &code = test.fragment_code; + code = {EncodeVop1(0x01, 13, InlineU32(1)), + EncodeSop1(0x10, 9, 126), + EncodeSop1(0x04, 24, 126), + EncodeSop1(0x28, 106, 126)}; + AppendVop3(&code, 0x101, 13, InlineU32(0), Vgpr(13), 24); + for (u32 shift : {1u, 2u, 4u, 8u}) { + code.push_back(EncodeVop2(0x25, 13, 250, 13)); + code.push_back(EncodeVop2Dpp(13, (lanes_0_32 ? 0x160u : 0x110u) + shift)); + } + code.insert(code.end(), {0xd778100cu, 0x0305830du, + EncodeVop2(0x25, 13, Vgpr(13), 12), + EncodeSop1(0x04, 126, 106)}); + AppendVop3(&code, 0x360, 6, Vgpr(13), InlineU32(lanes_0_32 ? 0u : 31u)); + AppendVop3(&code, 0x360, 7, Vgpr(13), InlineU32(lanes_0_32 ? 32u : 63u)); + code.insert(code.end(), {EncodeSop2(0x00, 8, 6, 7), + EncodeSopc(0x06, 8, 9), + EncodeSop2(0x0a, 10, 242, 128), + EncodeSop2(0x03, 11, 8, 9), + EncodeVop1(0x01, 0, 10), EncodeVop1(0x05, 1, 11), + EncodeVop1(0x01, 2, InlineU32(0)), EncodeVop1(0x01, 3, 242), + EncodeExp0(0x00, 0xf), EncodeExp1(0, 1, 2, 3)}); + AppendEnd(&code); + for (u32 i = 0; i < 8u * height; i++) { + test.expected_pixel.insert(test.expected_pixel.end(), + {0x3f800000u, 0u, 0u, 0x3f800000u}); + } + test.opcodes = {ShaderOpcode::S_BCNT1_I32_B64, ShaderOpcode::V_ADD_NC_U32, + ShaderOpcode::V_PERMLANEX16_B32, ShaderOpcode::V_READLANE_B32, + ShaderOpcode::S_ADD_U32}; + return test; +} + void CheckPixelFrontFaceModes() { constexpr const char *name = "PixelFrontFaceModes"; static const std::array<u32, 1> code = {EncodeSopp(0x01)}; @@ -42351,6 +42393,10 @@ std::vector<GraphicsCase> MakeGraphicsCases() { GraphicsBranchPathFinalVmExportDiscardsInactiveExec(), GraphicsObjectPrimitiveId(false), GraphicsObjectPrimitiveId(true), + GraphicsWave64WholeWaveCount(8, false), + GraphicsWave64WholeWaveCount(8, true), + GraphicsWave64WholeWaveCount(4, false), + GraphicsWave64WholeWaveCount(4, true), }; } ``` </details> Written with Claude Code (AI): it wrote the tests and ran them on my PC. I read this comment before posting it.

Pull request closed

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