shader: fold branch-proven vertex selects #1071

Open
github-bot wants to merge 1 commit from github-bot/gh-1071 into main AGit
Owner

@⁠Abhi011999 on GitHub · 2026-10-05 15:37 UTC · original
Abhi011999:fix/vertex-branch-selects → main · +150 −0 · 4 files · 1 commits · open

I have tested out Stray (the game) with these additional changes besides what mentioned in below PRs, and its going in-game successfully.

Stray's native vertex shader 0x79ef5bf7d0ca9452 retained inactive WriteLane chains after uniform lane-read elimination. Those chains introduced vertex subgroup builtins that MoltenVK could not translate.

Fold SelectU32 and SelectF32 when a vertex block has one predecessor and that predecessor's conditional edge proves the select predicate. Normalize ConditionRef and logical negation, then run identity removal and dead-code elimination. Preserve observable lane writes. Refuse workgroup stages, dispatcher fallback, reconverged blocks, wave exchanges, lane queries, and shared-memory operations.

This patch contains only the new branch-select pass, its pipeline call, and regression tests. It does not duplicate #637 or #735. The Stray integration test used those PRs to remove independent constant-mask and uniform-read dependencies before this pass could apply. #985 changes wave-wide zero-branch emission, and #1012 changes identical-target SPIR-V branch emission; neither supplies this pass.

Validation:

  • Based on upstream 77d772217310dc734ce53289110c9be0885a0577.
  • Built and ran the focused scalar-provenance test executable on macOS 15.7.4, Apple M4 Pro, x86_64 through Rosetta 2. All cases passed.
  • With this pass replaced by a no-op, the same tests failed on the first required branch fold, exit 1. Existing tests and the new tests were otherwise unchanged.
  • The seven new cases cover both conditional edges, nested condition wrappers, reconvergence, compute-stage refusal, dispatcher refusal, multiple predecessors, observable writes, lane reads, and lane IDs.
  • Earlier integration of the same pass in the custom Stray build produced valid Vulkan 1.3 SPIR-V without subgroup declarations for the affected vertex shader. MoltenVK pipeline creation succeeded, and the human tester confirmed cat control.
  • Changed source lines formatted with clang-format 22.1.3; git diff --check passed.

Limits: the isolated patch was not used to rebuild and replay the full game on current upstream main. Full-game integration used a custom PR stack and an experimental MoltenVK mesh-shader fork. Windows and Linux were not tested. This change does not establish correct rendering, stable gameplay, or a completed playthrough.

AI involvement: Codex prepared the implementation, tests, comparison, and this draft, and ran the automated checks. The human tester confirmed gameplay in the earlier integration build.


I have tested the changes & they look fine.


Stray macOS compatibility report

Status: In game, custom experimental build. PPSA02100, game version 01.005.000. Tested on macOS 15.7.4, Apple M4 Pro, 24 GB unified memory, with an x86_64 Release emulator through Rosetta 2.

The rainy opening scene plays and cat control is confirmed. Typical presentation rates were about 5–8 FPS. A later blue-gray rendering fault remains unresolved, and a capture-enabled run exited under memory pressure. A complete playthrough was not tested. Gameplay after the later #977 cache patch is still unverified.

This result requires the documented PR stack and experimental MoltenVK mesh-shader fork; this PR alone does not establish stock-release compatibility.

Website publication is deferred. The maintainer closed website PR #629 and requires a clean/official-build result submitted through the main repository's game-status issue form. The website bot processes those reports; direct website PRs are not accepted. Issue #1073 records only the earlier custom-build evidence and does not establish official-build compatibility. The tester has removed the game dump, so a clean-build retest is currently unavailable. Complete log upload remains pending separate approval.

**@⁠Abhi011999** on GitHub · 2026-10-05 15:37 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1071) `Abhi011999:fix/vertex-branch-selects` → `main` · +150 −0 · 4 files · 1 commits · open I have tested out Stray (the game) with these additional changes besides what mentioned in below PRs, and its going in-game successfully. Stray's native vertex shader `0x79ef5bf7d0ca9452` retained inactive `WriteLane` chains after uniform lane-read elimination. Those chains introduced vertex subgroup builtins that MoltenVK could not translate. Fold `SelectU32` and `SelectF32` when a vertex block has one predecessor and that predecessor's conditional edge proves the select predicate. Normalize `ConditionRef` and logical negation, then run identity removal and dead-code elimination. Preserve observable lane writes. Refuse workgroup stages, dispatcher fallback, reconverged blocks, wave exchanges, lane queries, and shared-memory operations. This patch contains only the new branch-select pass, its pipeline call, and regression tests. It does not duplicate #637 or #735. The Stray integration test used those PRs to remove independent constant-mask and uniform-read dependencies before this pass could apply. #985 changes wave-wide zero-branch emission, and #1012 changes identical-target SPIR-V branch emission; neither supplies this pass. Validation: - Based on upstream `77d772217310dc734ce53289110c9be0885a0577`. - Built and ran the focused scalar-provenance test executable on macOS 15.7.4, Apple M4 Pro, x86_64 through Rosetta 2. All cases passed. - With this pass replaced by a no-op, the same tests failed on the first required branch fold, exit 1. Existing tests and the new tests were otherwise unchanged. - The seven new cases cover both conditional edges, nested condition wrappers, reconvergence, compute-stage refusal, dispatcher refusal, multiple predecessors, observable writes, lane reads, and lane IDs. - Earlier integration of the same pass in the custom Stray build produced valid Vulkan 1.3 SPIR-V without subgroup declarations for the affected vertex shader. MoltenVK pipeline creation succeeded, and the human tester confirmed cat control. - Changed source lines formatted with clang-format 22.1.3; `git diff --check` passed. Limits: the isolated patch was not used to rebuild and replay the full game on current upstream main. Full-game integration used a custom PR stack and an experimental MoltenVK mesh-shader fork. Windows and Linux were not tested. This change does not establish correct rendering, stable gameplay, or a completed playthrough. AI involvement: Codex prepared the implementation, tests, comparison, and this draft, and ran the automated checks. The human tester confirmed gameplay in the earlier integration build. --- I have tested the changes & they look fine. --- <!-- stray-macos-compatibility:start --> ### Stray macOS compatibility report Status: **In game, custom experimental build**. PPSA02100, game version 01.005.000. Tested on macOS 15.7.4, Apple M4 Pro, 24 GB unified memory, with an x86_64 Release emulator through Rosetta 2. The rainy opening scene plays and cat control is confirmed. Typical presentation rates were about 5–8 FPS. A later blue-gray rendering fault remains unresolved, and a capture-enabled run exited under memory pressure. A complete playthrough was not tested. Gameplay after the later #977 cache patch is still unverified. This result requires the documented PR stack and experimental MoltenVK mesh-shader fork; this PR alone does not establish stock-release compatibility. - Full game-status report: https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/1073 - Closed website submission: https://github.com/KytyPS5/kytyps5.github.io/pull/629 Website publication is deferred. The maintainer closed website PR #629 and requires a clean/official-build result submitted through the main repository's game-status issue form. The website bot processes those reports; direct website PRs are not accepted. Issue #1073 records only the earlier custom-build evidence and does not establish official-build compatibility. The tester has removed the game dump, so a clean-build retest is currently unavailable. Complete log upload remains pending separate approval. <!-- stray-macos-compatibility:end -->
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:42:03 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-05 15:48 UTC · original · edited 2026-10-12 17:10 UTC

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: e8969af0-794b-4b54-87e0-2d0350277bf8

📥 Commits

Reviewing files that changed from the base of the PR and between 77d7722173 and 2555146281.


📒 Files selected for processing (4)
  • src/graphics/shader/recompiler/ShaderRecompiler.cpp
  • src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp
  • src/graphics/shader/recompiler/ir/passes/ConstantPropagation.h
  • tests/ScalarProvenanceTests.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

Walkthrough

Adds a pass that folds vertex branch selects when a block has a uniquely targeted conditional-branch predecessor and the program meets the pass guards. TranslateProgram invokes the pass after read-lane elimination, then reruns control-flow identity resolution and cleanup. Tests cover folding, preserved select values, and WriteLane behavior.

Suggested reviewers: nmzik


Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 25551

The proposed self-loop guard is unnecessary; no actionable issue remains before merging after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description check Passed The description clearly explains the branch-select folding pass, its safeguards, test coverage, validation results, and integration limits. It is directly related to the changeset.
Title check Passed The title, "shader: fold branch-proven vertex selects," is concise, specific, and accurately summarizes the primary change.

  • Autopilot · 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-05 15:48 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1071#issuecomment-5997967652) · edited 2026-10-12 17:10 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/1071?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></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**: `e8969af0-794b-4b54-87e0-2d0350277bf8` <hr> </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 77d772217310dc734ce53289110c9be0885a0577 and 2555146281b7d016b199dd12ce88ad9a1d27544f. <hr> </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (4)</strong></summary> <dl> <dd> * `src/graphics/shader/recompiler/ShaderRecompiler.cpp` * `src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp` * `src/graphics/shader/recompiler/ir/passes/ConstantPropagation.h` * `tests/ScalarProvenanceTests.cpp` <hr> </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. <hr> </dd> </dl> </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> ## Walkthrough Adds a pass that folds vertex branch selects when a block has a uniquely targeted conditional-branch predecessor and the program meets the pass guards. `TranslateProgram` invokes the pass after read-lane elimination, then reruns control-flow identity resolution and cleanup. Tests cover folding, preserved select values, and `WriteLane` behavior. **Suggested reviewers:** `nmzik` <hr> </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"2555146281b7d016b199dd12ce88ad9a1d27544f" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `25551` <!-- final_review_risk_coverage:{"sourceCommitId":"2555146281b7d016b199dd12ce88ad9a1d27544f","coveredCommitId":"2555146281b7d016b199dd12ce88ad9a1d27544f","kind":"reviewed"} --> The proposed self-loop guard is unnecessary; no actionable issue remains before merging after normal checks. <!-- final_review_risk_end --> <!-- 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-v1.svg" width="14" height="17" align="middle" alt="Passed" title="Passed"></picture></sup> 4 | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v1.svg" width="14" height="17" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 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. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains the branch-select folding pass, its safeguards, test coverage, validation results, and integration limits. It is directly related to the changeset. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title, "shader: fold branch-proven vertex selects," is concise, specific, and accurately summarizes the primary change. | </dd> </dl> </details> <hr> </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">Autopilot</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=1071)! 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) <hr> </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
This pull request has changes conflicting with the target branch.
  • tests/ScalarProvenanceTests.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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