shader: eliminate uniform read-first-lane operations #735

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

@⁠carbonimax on GitHub · 2026-09-20 15:25 UTC · original
carbonimax:codex/read-first-lane-uniform → main · +364 −27 · 6 files · 2 commits · closed without merging

Summary

  • Rebuild proven lane-invariant ReadFirstLane sources before SPIR-V emission.
  • Strip nested EXEC-masked update chains and clone only a validated allowlist of operations.
  • Accept runtime constant-buffer roots only when integer evaluation is proven.
  • Cover successful reconstruction, varying rejection, and refusal without residual IR mutation.

Validation

  • cmake --build /private/tmp/kyty-vertex-subgroup-build --target scalar_provenance_tests shader_cfg_tests
  • ctest --test-dir /private/tmp/kyty-vertex-subgroup-build -R "scalar_provenance|shader_cfg" --output-on-failure: 2/2 passed.
  • A targeted MoltenVK integration check passed the affected pipeline creation and reached the next independent renderer limitation.

Scope

This commit is based on current main (c3cc845). The integration check also included #637 and the existing PerVertex/NGG stack; #637 is required to fold the constant lane-mask portion before this pass. This does not establish correct rendering or playability in the game.

**@⁠carbonimax** on GitHub · 2026-09-20 15:25 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/735) `carbonimax:codex/read-first-lane-uniform` → `main` · +364 −27 · 6 files · 2 commits · closed without merging ## Summary - Rebuild proven lane-invariant `ReadFirstLane` sources before SPIR-V emission. - Strip nested EXEC-masked update chains and clone only a validated allowlist of operations. - Accept runtime constant-buffer roots only when integer evaluation is proven. - Cover successful reconstruction, varying rejection, and refusal without residual IR mutation. ## Validation - `cmake --build /private/tmp/kyty-vertex-subgroup-build --target scalar_provenance_tests shader_cfg_tests` - `ctest --test-dir /private/tmp/kyty-vertex-subgroup-build -R "scalar_provenance|shader_cfg" --output-on-failure`: 2/2 passed. - A targeted MoltenVK integration check passed the affected pipeline creation and reached the next independent renderer limitation. ## Scope This commit is based on current `main` (`c3cc845`). The integration check also included #637 and the existing PerVertex/NGG stack; #637 is required to fold the constant lane-mask portion before this pass. This does not establish correct rendering or playability in the game.
Read-lane elimination runs before resource tracking and removes the
first-lane read of a uniform value while keeping the one of a lane-varying
value. Counted-row selectors and indexed pointer tables required both
sides to stay first-lane reads and lost their proof.

Accept a wave-uniform row in place of its removed first-lane read, and
cover both matchers and the translated pipeline for wave32 and wave64.

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

@⁠coderabbitai[bot] on GitHub · 2026-09-20 15:28 UTC · original · edited 2026-10-16 06:50 UTC

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

The pass now validates and rebuilds eligible lane-invariant ReadFirstLane sources, replaces their uses, and records rewritten reads. Unsupported or lane-varying sources remain unchanged. Resource tracking now accepts qualifying wave-uniform rows and descriptor keys after read-lane elimination. Tests cover reconstruction, rejected proofs, resource plans, and compiled shader inputs.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: 🟡 Moderate · up to 3bc9a

The new ReadFirstLane elimination can change shader results when no lanes are active at the read and the masked selection's fallback value varies by lane. Prove that EXEC is non-empty at the read, or preserve the fallback value, before merging.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 4 files. (2 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: eliminating uniform ReadFirstLane operations.
Description check Passed The description directly explains the reconstruction logic, validation rules, test coverage, and reported validation results.
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 5.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 4 files. (2 skipped: 1 unsupported, 1 too large.)

Resolution

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

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

❤️ Share

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

**@⁠coderabbitai[bot]** on GitHub · 2026-09-20 15:28 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/735#issuecomment-5750741964) · edited 2026-10-16 06:50 UTC <!-- 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/735?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 --> <!-- This is an auto-generated comment: review paused by coderabbit.ai --> > [!NOTE] > ## Reviews paused > > It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the `reviews.auto_review.auto_pause_after_reviewed_commits` setting. > > - Last reviewed commit: 3bc9aac0b9dc72ccefa6219985ec79a47109da77 > > Use the following commands to manage reviews: > - `@coderabbitai resume` to resume automatic reviews. > - `@coderabbitai review` to trigger a single review. > > Use the checkboxes below for quick actions: > - [ ] <!-- {"checkboxId":"7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> ▶️ Resume reviews > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review <!-- end of auto-generated comment: review paused by coderabbit.ai --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The pass now validates and rebuilds eligible lane-invariant ReadFirstLane sources, replaces their uses, and records rewritten reads. Unsupported or lane-varying sources remain unchanged. Resource tracking now accepts qualifying wave-uniform rows and descriptor keys after read-lane elimination. Tests cover reconstruction, rejected proofs, resource plans, and compiled shader inputs. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"3bc9aac0b9dc72ccefa6219985ec79a47109da77" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🟡 Moderate</strong> · up to <code>3bc9a</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `3bc9a` --> <!-- final_review_risk_coverage:{"sourceCommitId":"3bc9aac0b9dc72ccefa6219985ec79a47109da77","coveredCommitId":"3bc9aac0b9dc72ccefa6219985ec79a47109da77","kind":"reviewed"} --> The new ReadFirstLane elimination can change shader results when no lanes are active at the read and the masked selection's fallback value varies by lane. Prove that EXEC is non-empty at the read, or preserve the fallback value, before merging. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 4 files. (2 skipped: 1… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: eliminating uniform ReadFirstLane operations. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the reconstruction logic, validation rules, test coverage, and reported validation results. | | 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 5.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 4 files. (2 skipped: 1 unsupported, 1 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=735)! 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

@⁠coderabbitai[bot] on GitHub · 2026-10-16 06:50 UTC · original · reviewed

Caution

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

⚠️ Outside diff range comments (1)

🟠 Major · Preserve the empty-EXEC result before stripping SelectU32. · ReadLaneElimination.cpp:62-64

src/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cpp:62-64
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve the empty-EXEC result before stripping SelectU32.

If exec is empty, ReadFirstLane selects lane zero. The original SelectU32 then supplies its false arm, but this branch rebuilds its true arm. A varying false arm can therefore change the value observed after EXEC is restored. Require proof that EXEC is nonempty at the read, or preserve the false-arm result for empty EXEC. src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp Line 1523-1525 documents the empty-EXEC behavior.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 12255001-e960-4245-9882-6804863709b0
📥 Commits

Reviewing files that changed from the base of the PR and between 5d1c509209e0f9bface958a1941fb1563e0a993c and 3bc9aac0b9.

📒 Files selected for processing: 6
  • CMakeLists.txt
  • src/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • tests/ResourceTrackingTests.cpp
  • tests/ScalarProvenanceTests.cpp
  • tests/shaderCfgTests.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.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-16 06:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/735#pullrequestreview-5544023689) · **reviewed** > [!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>🟠 Major</strong> · Preserve the empty-EXEC result before stripping <code>SelectU32</code>. · <code>ReadLaneElimination.cpp:62-64</code></summary><blockquote> > > `src/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cpp:62-64` > **🎯 Functional Correctness** | **🟠 Major** | **⚡ Quick win** > > **Preserve the empty-EXEC result before stripping `SelectU32`.** > > If `exec` is empty, `ReadFirstLane` selects lane zero. The original `SelectU32` then supplies its false arm, but this branch rebuilds its true arm. A varying false arm can therefore change the value observed after EXEC is restored. Require proof that EXEC is nonempty at the read, or preserve the false-arm result for empty EXEC. `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` Line 1523-1525 documents the empty-EXEC behavior. > > <!-- cr-comment:v1:37b78956d0994befb1f8e9fa --> > > </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `12255001-e960-4245-9882-6804863709b0` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 5d1c509209e0f9bface958a1941fb1563e0a993c and 3bc9aac0b9dc72ccefa6219985ec79a47109da77. </details> <details> <summary>📒 Files selected for processing: 6</summary> * `CMakeLists.txt` * `src/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `tests/ResourceTrackingTests.cpp` * `tests/ScalarProvenanceTests.cpp` * `tests/shaderCfgTests.cpp` </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. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=42a89f37-cf9c-41d8-a9a2-1b7f4e76ae62 attempt=bb3290f8-46a2-431f-8678-6af71bb44822 batch=1/1 -->

Pull request closed

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