Skip to content

fix(shader): broadcast Wave32 readfirstlane on narrow subgroups - #25660

Merged
oneandonlydean merged 6 commits into
boykopovar:mainfrom
malekaifa:prime-c/readfirstlane-narrow-wave32-20261122
Dec 5, 2026
Merged

oneandonlydean merged 6 commits into
boykopovar:mainfrom
malekaifa:prime-c/readfirstlane-narrow-wave32-20261122

Conversation

@malekaifa

@malekaifa malekaifa commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Broadcast v_readfirstlane_b32 over the complete guest Wave32 when a compute shader runs on host subgroups narrower than 32 lanes. Each invocation publishes its source in workgroup memory, active guest lanes atomically elect the lowest lane within their own 32-lane guest wave, and all invocations read that guest-wave slot after a workgroup barrier. Separate slots keep multiple guest waves in the same workgroup independent, including a partial final wave.

The workgroup exchange is only emitted for Wave32 compute on a host subgroup below 32 lanes. The emitted module is checked with the existing barrier-uniformity analysis; if a ReadFirstLane exchange sits in per-invocation divergent control flow, compilation retries with the existing subgroup-local shuffle instead of risking an incomplete workgroup barrier. That divergent case therefore keeps the previous narrow-subgroup limitation rather than hanging. Fault-capable shaders (usesDma or usesFaultBuffer) also keep the existing subgroup-local path, so this PR does not introduce workgroup barriers into the separate barrier-safe BDA fault problem tracked by #7392.

This addresses the unequal-input V_READFIRSTLANE_B32 reproduction discussed in #25298, including the ISA lane-0 fallback when EXEC is empty. #25419 covers the separate complete-VCC-word problem; the execution fixture here intentionally stops before scalar-word-to-VCC selection so the two fixes remain independently testable. #25609 changes ReadFirstLane when a guest wave already fits inside one host subgroup and explicitly falls back to the shuffle when the guest wave is wider than the host subgroup, so the narrow-host path here is separate.

Tested

Windows 11 Education build 26200, WinLibs GCC 15.2.0, CMake/Ninja Release; rebased onto current main 0f107f9. Rebased head: 6c99e1b.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5080 (subgroup 32); AMD Radeon(TM) Graphics 0x13c0 (subgroup 64); synthetic subgroup-8 target path covered by deterministic SPIR-V/code-generation and LDS-budget tests; subgroup-8 runtime ICD unavailable
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility for 32-lane compute shaders on devices with smaller subgroup sizes, including shaders that use first-lane reads.
    • Improved handling of shared-memory limits when these shaders require additional temporary storage, helping preserve shader execution when memory is constrained.
  • Tests
    • Expanded coverage for first-lane behavior across subgroup sizes, uneven workgroups, and shared-memory boundaries.

Copilot AI balanced review requested due to automatic review settings November 22, 2026 13:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@malekaifa

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Could you review current head 6bfa63a2c3f53dd595754363a6d5785945d57f3b when convenient? The focused gate is 6/6 green, the synthetic subgroup-8 lowering check passes, and the 2,384-PR overlap audit was manually cleared for the reported shared-file branches. The narrow path is limited to convergent Wave32 compute on host subgroups below 32; divergent barrier placement is detected and re-emitted through the existing subgroup-local fallback.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — comments

The narrow-subgroup exchange is guarded by the barrier uniformity check and the added code generation and execution tests cover a full and partial guest wave; subgroup-8 execution itself was not verified on hardware.

What I ran

  • Reviewed head 6bfa63a2c3f53dd595754363a6d5785945d57f3b and the prepared diff; no commands or tests were run in this review.
  • Read the changed implementation and execution test, plus the added ShaderMemory.cpp test range through repo_read.py.

Results

Check Result Note
Diff and targeted source review passed Reviewed the exchange and its fallback
Tests run in this review not run Author reports six passing tests
Subgroup-8 Vulkan execution not run No such ICD was available to the author

Findings

Blocking

None.

Non-blocking

  • The execution test uses the detected Vulkan subgroup size, and the reported RTX 5080 run used subgroup 32. Add or run an execution test on a subgroup-8 device when available to validate runtime behavior of the new path.

Not verified

  • Did not run the reported tests or independently verify the author-reported results.
  • No subgroup-8 Vulkan runtime execution was available in the reported environment.
  • core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp was read only at the changed test range; its remaining contents were not reviewed. No changed files were excluded by rule, but that file's full text was omitted from the review folder because it was too large.

To get this to a good state

Nothing is required. The optional subgroup-8 runtime validation above would strengthen coverage.

@malekaifa
malekaifa force-pushed the prime-c/readfirstlane-narrow-wave32-20261122 branch from 6bfa63a to c7a6249 Compare November 22, 2026 13:55
@malekaifa

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Updated current head to c7a6249c0005aecb6ead94bfd830e2bc2339f094 after a BDA interaction audit. The narrow workgroup exchange now fails closed for shaders using DMA/fault-buffer handling, so it does not change #7392's barrier-fault semantics. Rebasing onto current main had no changed-file overlap; the 6-test focused gate, compile-only BDA contracts, conventions, and diff check all pass on this head. Could you review this exact head when convenient?

@mihiii1337

mihiii1337 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Following up on the subgroup-8 Vulkan request. I ran an A/B on Windows against e57e2b9930b03a53d492c3caa41c8053526946a4 and GitHub's test merge 78b213a8fe667c4caf28b7ab7f5698e2163b25b5 for head c7a6249c0005aecb6ead94bfd830e2bc2339f094. The PR's 45-invocation fixture was byte-identical in both builds. Shader caching was disabled and the Khronos validation layer was loaded.

On Mesa lavapipe 26.2.6 / LLVM 23.1.4 (Vulkan subgroup 8, software), all three repetitions gave the same results:

Check Base PR
Raw V_READFIRSTLANE_B32 mismatches, 32 active / 13 active 24 / 5 0 / 0
Downstream VCC bit mismatches, 32 active / 13 active 24 / 5 15 / 3
First active guest lane 4, wrong scalar lanes out of 32 24 0
Empty EXEC, wrong scalar lanes out of 32 24 32

Details for the two failures:

  • The checked-in agc_driver_wave32_unequal_buffer_read_first_lane is still 0/3 on subgroup 8. The base stops at the scalar assertion. The PR reaches the VCC assertion. In the separate readback diagnostic, the resulting VCC selections are 0xa9a9a9a9 and 0x1393, with 0x7b36c4a9 and 0x1e93 expected.
  • For the masked check I used the existing ReadFirstLane shader words with the subgroup-size skip removed and both values printed. Empty EXEC returned 0x00000000 on every lane on the PR. The expected result is lane 0's 0x00000100 (AMD RDNA2 ISA §12.8, VOP1 opcode 2). The last Select in the narrow emitter is consistent with this result: it discards the already loaded lane-0 value and returns a literal zero.

All six focused cases passed on both the Intel UHD and RTX 4070 Laptop GPU, each at native subgroup 32, in three repeats per build. There were no VUID or synchronization diagnostics in the runs on any adapter.

Local lane-0 follow-up on the same test merge. Dropping the final result select and returning the already loaded value after the existing barrier makes the masked subgroup-8 test pass in all three runs. Both empty EXEC and first-active-lane 4 had zero scalar mismatches across 32 lanes per run. The downstream VCC assertion still failed with the same 15/3 bit mismatches. On Intel UHD and RTX 4070 Laptop at subgroup 32 all six cases still passed in three runs per GPU. No VUID or synchronization diagnostics appeared.

AI-assisted: yes

@malekaifa
malekaifa force-pushed the prime-c/readfirstlane-narrow-wave32-20261122 branch from c7a6249 to 6425a75 Compare November 22, 2026 14:09
@malekaifa

Copy link
Copy Markdown
Contributor Author

@mihiii1337 @MarcZX10 Updated current head to 6425a75b0f430d2eaf51c9f35121dc9927e08b1d from the subgroup-8 A/B findings. Empty EXEC now returns guest lane 0 instead of zero; agc_driver_read_first_lane runs its Wave32 empty/first-active checks on narrow subgroups; and the 45-thread unequal-input fixture now isolates scalar ReadFirstLane instead of also asserting the separate VCC-word path owned by #25419. Rebasing onto current main had no changed-file overlap. Exact-head 6/6 focused tests, compile-only BDA contracts, conventions, and diff check pass locally. A lavapipe subgroup-8 rerun of the two ReadFirstLane tests would directly validate the corrected path.

@mihiii1337

Copy link
Copy Markdown
Contributor

I ran the two requested tests on Windows with GitHub's test merge 1084b0fc718b7a5d27805c25e8bee8ce0d2a3ad2 for head 6425a75b0f430d2eaf51c9f35121dc9927e08b1d.

Vulkan device Subgroup agc_driver_read_first_lane agc_driver_wave32_unequal_buffer_read_first_lane
Mesa lavapipe 26.2.6 / LLVM 23.1.4 (software) 8 3/3 3/3
Intel UHD / Raptor Lake-S Mobile, 31.0.101.5081 32 3/3 3/3
RTX 4070 Laptop GPU, 621.01 32 3/3 3/3

The subgroup-8 logs contain both success markers and show no subgroup-local fallback message. The first fixture checks empty EXEC and first-active lane 4. The second checks the scalar across all 45 active lanes, along with the guard slots. Shader caching was disabled, Vulkan was required, and the Khronos validation layer was loaded for every test. No VUID or synchronization errors appeared.

For tracking the earlier VCC observation, the buffer-fed word falls through #25419's literal/user-data proof to the existing lane predicate. #25404 changes the lane index used by that predicate. The results above cover the revised scalar fixtures.

AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change based on the code reviewed; the reported runtime and compile checks were not run in this review.

What I ran

  • Reviewed head 6425a75b0f430d2eaf51c9f35121dc9927e08b1d using the prepared diff and pinned repository reader.
  • No build or test commands were run.

Results

Check Result Note
Changed-code review passed Read 10 of 11 changed files
Tests and build not run Author-reported checks only

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp was excluded from the review folder because it was too large; only the changed region was read through the repository reader. All other changed files listed in review/manifest.json were read.
  • I did not run builds, tests, the reported GPU scenarios, or verify behavior on physical console hardware. The checks in the description are author-reported.

To get this to a good state

Nothing is required.

@malekaifa

Copy link
Copy Markdown
Contributor Author

Integration note from a local detached stack of #25660 head 6425a75b0f430d2eaf51c9f35121dc9927e08b1d plus #25419 head 321c627b0686cc494a741ea404a0b35cc60d9905 (the PRs have no changed-file overlap): the original 45-thread v_readfirstlane_b32 -> s_mov_b32 VCC_LO -> v_cndmask_b32 chain still takes #25419's fallback on a synthetic subgroup-8 target. Instrumenting resolveWave32VccUse reports word=ReadFirstLane, all_lanes=1, complete=0.

A local-only prototype that adds IrOpcode::ReadFirstLane to isCompleteWave32Mask flips that exact use to complete=1; agc_shader_memory_tests still passes. I am not adding that to this PR: doing so in #25419 alone would be unsafe while narrow-host ReadFirstLane is still subgroup-local. Once #25660's guest-wave broadcast semantics are present, this looks like a very small integration follow-up (or needs an equivalent capability/provenance gate).

So this PR remains intentionally scoped to the scalar ReadFirstLane broadcast. The downstream VCC path in the reporter's diagnostic is not yet proven fixed merely by stacking the current #25419 and #25660 heads.

@malekaifa

Copy link
Copy Markdown
Contributor Author

Safety refinement to my integration note: a global isCompleteWave32Mask(ReadFirstLane) = true is not safe, even after #25660 lands. #25660 intentionally disables the narrow exchange for DMA/fault-buffer shaders, and it can also discover a divergent workgroup barrier only after first SPIR-V emission and then re-emit with narrowReadFirstLaneExchange=false.

The ConstantFolder VCC proof runs earlier, before either of those final backend decisions. So a correct follow-up should keep the existing early proof for inherently complete words, but defer any ReadFirstLane-dependent ResolveWave32VccLane/ResolveWave32VccZero decision until SPIR-V emission (or carry an equivalent explicit semantic marker). Then the first emission may use the complete guest-wave word when state.narrowReadFirstLaneExchange is true, while BDA/divergence fallback re-emission can safely use the existing subgroup-local predicate.

I am keeping both current PRs unchanged; this is follow-up integration work, not a reason to broaden either approved patch.

@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Nov 22, 2026
@malekaifa
malekaifa force-pushed the prime-c/readfirstlane-narrow-wave32-20261122 branch 2 times, most recently from d69d2e3 to 0b4aa2f Compare November 22, 2026 19:15
@malekaifa

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (07336cc2004f) with no overlap in the 11 changed files. Exact head: 0b4aa2f6fc39939646ee0e90016b2e83e7cc9014. Rebuilt and reran agc_driver_read_first_lane, agc_driver_wave32_unequal_buffer_read_first_lane, and wave32_wide_subgroup: 3/3 passed; conventions and diff checks pass. The requested subgroup-8 Vulkan runtime A/B was also reported as 3/3 on lavapipe by @mihiii1337 earlier in this discussion. Could you confirm the rebased head? The separate VCC proof integration with #25419 remains intentionally outside this scalar-readfirstlane PR.

@malekaifa
malekaifa force-pushed the prime-c/readfirstlane-narrow-wave32-20261122 branch 2 times, most recently from 5dfbda0 to 81cee6a Compare November 22, 2026 22:59
@malekaifa

malekaifa commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased again onto latest main (7dad98050511); all 11 changed-file blobs remain identical. Local conventions and diff checks pass; fresh CI is running. The subgroup-8 evidence from @mihiii1337's follow-up remains applicable: Mesa lavapipe 26.2.6 / LLVM 23.1.4 (subgroup 8), 3/3 for both checked-in tests, plus Intel UHD and RTX 4070 Laptop (subgroup 32), also 3/3, with no VUID or synchronization diagnostics. The separate VCC-proof integration remains a follow-up after #25404 and #25419; this PR stays scoped to scalar ReadFirstLane. Could you re-confirm approval on the current head once CI is green?

@mihiii1337

Copy link
Copy Markdown
Contributor

I independently tested commit 0b4aa2f6fc39939646ee0e90016b2e83e7cc9014 on Windows 11 with Mesa lavapipe 26.2.6 / LLVM 23.1.4 (software Vulkan, subgroupSize = 8). agc_driver_read_first_lane and agc_driver_wave32_unequal_buffer_read_first_lane each passed 3/3. wave32_wide_subgroup and the conventions check also passed. Shader caching was disabled, Khronos Validation 1.4.369 was active in all six Vulkan runs, and the logs showed no VUIDs or subgroup-local fallback messages.

My verification of the current head 81cee6a76677f4424c5cb5659ea587adaf2ab2b5 was limited to a byte comparison. All 11 changed file blobs match the tested commit. The runtime results above apply to 0b4aa2f6.

AI-assisted: yes.

@malekaifa
malekaifa force-pushed the prime-c/readfirstlane-narrow-wave32-20261122 branch 4 times, most recently from d4859b9 to c9eda9c Compare November 22, 2026 23:46
@malekaifa

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Rebased onto current main 5dcb83a5528b. The upstream changes are outside the 11-file Wave32 readfirstlane diff; no topic code changed. Current head: c9eda9c28ee35609a73c46b534c4888b1eb4b18c. Please re-confirm approval on this head after CI. The optional subgroup-8 hardware run remains unavailable; the existing compile-time and subgroup-32 execution coverage is unchanged.

AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the points below are optional.

What I ran

  • Reviewed head c0065b712b90ca51a5e2c4564ba86e81a3745fe5 using the pinned repo_read.py tools. No build or tests were run in this environment.
  • Read description.md, commits.md, manifest.json, and diff.patch. Inspected the changed shader emission, LDS budgeting and fallback paths, the relevant tests, and confirmed execution tests are globbed from tests/execution/*.cpp.

Results

Check Result Note
Changed-code review passed No concrete defect found
Tests in this environment not run No shell or test runner available
Author-reported checks not run Six listed checks passed on the candidate

Findings

Blocking

None.

Non-blocking

  • The author reports no subgroup-8 Vulkan ICD was available, so the added narrow-host runtime fixture still needs a run on such a device.

Not verified

  • No tests or build were run here; reported test results are from the author’s description.
  • Physical-console behavior and the subgroup-8 runtime path were not verified.
  • Read changed lines and relevant context in all changed files, including ShaderMemory.cpp via repo_read.py; did not read unrelated portions of large files. files.json was not available as a review document; list_files showed all changed files and identified ShaderMemory.cpp as too large to include in the bundle.

To get this to a good state

Nothing is required. Optional: run agc_driver_wave32_unequal_buffer_read_first_lane on a subgroup-8 Vulkan device.

@malekaifa
malekaifa force-pushed the prime-c/readfirstlane-narrow-wave32-20261122 branch from c0065b7 to 6c99e1b Compare November 30, 2026 09:09
@malekaifa

Copy link
Copy Markdown
Contributor Author

Conflict triage and rebase complete. Rebased all six commits onto latest main 0f107f9; GitHub now reports MERGEABLE. The emitter retains main's spanned-unreachable verification and the PR's narrow ReadFirstLane exchange validation as separate branches.

Local Windows 11 / GCC 15.2 validation: build succeeded; 9/9 focused tests passed on NVIDIA RTX 5080 (subgroup 32) and 9/9 on AMD Radeon(TM) Graphics 0x13c0 (subgroup 64). Khronos validation was loaded on both; zero VUID, synchronization-hazard, or unassigned diagnostics. The deterministic code-generation/LDS-budget tests cover synthetic subgroup 8. No subgroup-8 Vulkan ICD is available here, so a current-head subgroup-8 runtime A/B remains outstanding. The BDA device target compiled and its CPU-selection test passed; the separate full BDA runtime test was not run because of the known RTX 5080 anchored-read issue in #25167.

No review decisions were modified. Marc's and Mihiii's APPROVED reviews remain in the review history. Hosted checks are running on the new head.

@malekaifa

Copy link
Copy Markdown
Contributor Author

Cross-PR integration check: a three-way git merge-tree of rebased heads #23553 (436dd13) and #25660 (6c99e1b) completed with no conflicts (tree b86c49163969). The only shared paths are ShaderMemory.cpp and SpirvEmitterHelpers.cpp; their changes are in separate hunks (depth-export serialization/runtime tests vs narrow-ReadFirstLane codegen tests, and viewport-index input vs workgroup-local-size/input additions). No dependency or merge-order constraint was found.

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Changes: Wave32 ReadFirstLane exchange

Layer / File(s) Summary
ReadFirstLane requirements and exchange eligibility
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvAnalysis.hpp, SpirvAnalysis.cpp, SpirvEmitter.hpp, SpirvEmitterHelpers.hpp, SpirvEmitterState.hpp, core/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cpp, SpirvEmitter.cpp, SpirvMemory/SpirvEmitterHelpers.cpp
The SPIR-V requirements track ReadFirstLane. The emitter enables narrow exchange for eligible compute workgroups, and the workgroup-size helpers expose the sizing inputs used by that decision.
Workgroup-memory ReadFirstLane exchange
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
The narrow-subgroup path selects the first active lane through workgroup memory, barriers, and atomic minima. The existing ballot-and-shuffle path remains when narrow exchange is disabled.
LDS budgeting and emission fallback
core/shader/recompiler/Recompiler.cpp
LDS capacity checks include reserved exchange bytes. When the exchange exceeds the limit, the recompiler retranslates with guest LDS placement. If emission rejects the exchange due to divergent barriers, it retries with the exchange disabled.
SPIR-V and LDS budget validation
core/libs/prx/libSceAgcDriver/tests/LdsLockBudget.cpp, ShaderMemory.cpp
Tests check exchange allocation and LDS placement at memory boundaries. SPIR-V checks compare narrow and matching host subgroup sizes.
Vulkan ReadFirstLane validation
core/libs/prx/libSceAgcDriver/tests/execution/ReadFirstLane.cpp, Wave32UnequalBufferReadFirstLane.cpp
Execution tests check Wave32 results for unequal inputs. The existing test now runs Wave32 on smaller subgroups and runs Wave64 only when the subgroup size is at least 32.

Possibly related PRs

  • boykopovar/AnyPS5#25609: It changes the same ReadFirstLane lowering for guest waves that fit within a host subgroup; this PR covers the complementary narrow-subgroup case.

Suggested reviewers: celegans12, elliot1377, oneandonlydean

Change: Bug fix

Merge Risk: Minimal · up to 6c99e

This change makes the Wave32 first-lane read return the correct value on hosts with narrow subgroups. It reserves workgroup memory for the exchange and falls back to the existing path when the exchange is unsupported. The reviewed code shows no remaining merge-blocking issue; the narrow-subgroup path has not been run on hardware at the exact head.

Security architecture risk: Low · up to 6c99e

The new broadcast is limited to eligible compute shaders, and the compiler keeps the old behavior when it detects unsafe synchronization. The remaining risk is that some dispatches may still need extra device memory even when the broadcast is not used.

Retained concerns

  • Trivial · reliability · inferred: Exchange budgeting can move guest LDS into device memory before the compiler knows whether the exchange will be emitted. Fault exclusion or a uniformity rejection can leave the shader using the old shuffle with the new device-backed LDS requirement. That preserves the synchronization fallback but not its prior resource requirements; the existing split-table dispatch guard can reject device-backed LDS if an affected shader reaches that mode.

View findings in the submitted review

Security review details

Security Blast Radius

  • inferred — Guest shader code and workgroup configuration influence entry into the new path. The affected scope shown by the source is eligible GPU dispatches: scratch is per workgroup, and spilled LDS uses an existing descriptor-backed buffer with separate offsets for each workgroup. No broader authority grant was established.

Trust Boundaries and Controls

  • observed — Guest lane activity controls election, not scratch addressing. The compiler derives the slot partition from the local invocation index and rejects a generated module when its analysis detects a barrier in divergent flow, including cases where divergent exits affect later barriers.

Hardening Proposals

  • proposed — When the exchange is excluded or rejected, reconsider any LDS spill caused only by exchange budgeting before publishing the final module and resource layout. Verify that the resulting fallback retains the prior dispatch compatibility.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)

Cppcheck (2.22.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp

Cppcheck interrupted; analysis of this file is incomplete

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing blocks this change based on the code inspected; the narrow-subgroup runtime behavior remains unverified.

What I ran

Reviewed PR head 6c99e1b164747b3c3937f5a828d987d54e3b4d7b using the prepared diff and pinned repo_read.py reader. No commands or tests were run. The description reports Windows 11, GCC 15.2, and focused test runs on NVIDIA subgroup 32 and AMD subgroup 64; those are author-reported results.

Results

Check Result Note
Diff and changed implementation passed Core exchange and LDS budgeting inspected
Tests in this review not run No tests executed
Narrow-subgroup runtime not run No subgroup-8 runtime device reported

Findings

Blocking

None.

Non-blocking

  • Consider reporting or otherwise surfacing when divergent control flow makes the exchange unsupported. The catch at core/shader/recompiler/Recompiler.cpp:955 retries with the existing subgroup-local shuffle, which preserves the known narrow-subgroup limitation for those shaders.

Not verified

The full text of core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp was excluded by the review-folder size rule; its changed hunk was inspected in diff.patch. No tests were run, and narrow-host runtime behavior was not verified. Other repository files outside the targeted implementation and test context were not inspected.

To get this to a good state

Nothing is required. Optional: make the divergent-flow fallback visible to callers or diagnostics.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Architecture findings (1)

Advisory architecture findings (1)

  • Trivial — Exchange budgeting can move guest LDS into device memory before the compiler knows whether the exchange will be emitted. Fault exclusion or a uniformity rejection can leave the shader using the old shuffle with the new device-backed LDS requirement. That preserves the synchronization fallback but not its prior resource requirements; the existing split-table dispatch guard can reject device-backed LDS if an affected shader reaches that mode.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 951e0444-d8bf-46f6-8c30-b6ba9b924033
Commits

Reviewing files that changed from the base of the PR and between 0f107f9 and 6c99e1b.

Files selected for processing: 13

  • core/libs/prx/libSceAgcDriver/tests/LdsLockBudget.cpp
  • core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
  • core/libs/prx/libSceAgcDriver/tests/execution/ReadFirstLane.cpp
  • core/libs/prx/libSceAgcDriver/tests/execution/Wave32UnequalBufferReadFirstLane.cpp
  • core/shader/recompiler/Recompiler.cpp
  • core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvAnalysis.hpp
  • core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitter.hpp
  • core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterHelpers.hpp
  • core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
  • core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
  • core/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cpp
  • core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp
  • core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp

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

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 30, 2026
@malekaifa

Copy link
Copy Markdown
Contributor Author

Exact-head CI recheck (6c99e1b16474): all checks are complete; 11 succeeded and the only failure is relinker (macos-latest, clang++). The failure is the same frame_capture_minimize_replay / PermissionError from os.killpg(process.pid, 0) also seen on #28166 (and #26686's older run); this PR does not modify tools/frame_capture_minimize.py. The head is merge-tree clean against current main dd5412d54ef5, and its shared edits with #23553 are in separate hunks. I attempted a failed-job rerun, but GitHub requires repository admin rights for that action; this needs an admin rerun or a separate shared-harness fix before the check can be cleared.

@ycbuzi

ycbuzi commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Tested 6c99e1b164 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 3 tests failed out of 7493; 99% tests passed, 2 tests failed out of 7493. 2 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 7493; 99% tests passed, 1 tests failed out of 7493. 1 of the failing tests fail on main too. run

Not covered: GPU. This pull request changes GPU code, and the GitHub-hosted runners above have no GPU, so the Vulkan and GPU tests fail there on main and on this pull request alike. This result says nothing about the changed GPU paths; they still need a run on a real GPU.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unequal-input fixture checks both guest waves in a 45-thread workgroup, including the partial final wave. Please run it on a Vulkan device that actually selects a subgroup below 32, and include the chosen subgroup width with the result. The synthetic SPIR-V and LDS-budget checks confirm emission and accounting. The listed hardware runs have subgroup sizes 32 and 64, so the narrow exchange's workgroup barriers and observed results still need runtime evidence. I queued the common tests and unequal-input fixture on lavapipe.

AI-assisted: yes.

@oneandonlydean
oneandonlydean merged commit 689180c into boykopovar:main Dec 5, 2026
16 of 21 checks passed
superSniper4576154 pushed a commit to superSniper4576154/AnyPS5 that referenced this pull request Dec 6, 2026
…32-lane hosts

A wave64 pixel program on a 32-lane host refused v_readlane_b32 of lane 63
of a half-wave scan whose keys are selected by an s_wqm_b64 mask, because the
entry-lane proof requires keys of non-helper lanes only. Such a mask still
holds no lane the wave does not launch, so lane 63 is the identity; lane 31
combines each quad's keys with quad broadcasts before the subgroup reduction,
since Vulkan may leave helper invocations out of subgroup arithmetic. Adds
are excluded (a quad combine counts keys more than once) and masks that may
hold unlaunched lanes still throw.

The open PRs boykopovar#25404, boykopovar#25660, boykopovar#25419 and boykopovar#25609 were evaluated for this
refusal; all four change Wave32 compute masks or readfirstlane on narrow
hosts and do not reach a wave64 pixel lane-63 read, so none is ported.

Seen in PPSA38500 pixel shaders 0x106ccc7000, 0x106ccdcc00, 0x106ced0c00
and 0x106cee6800 (an OR scan in a waterfall loop under WQM).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants