shader: translate GTA V's tessellated tree trunks #1245

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

@⁠TheCruZ on GitHub · 2026-10-08 19:50 UTC · original
pr/tess-tree-trunks → main · +319 −39 · 8 files · 1 commits · closed without merging

Summary

Makes the tessellated tree trunks of Grand Theft Auto V (PPSA04263) translate. GTA V draws the trunk and lower branches of trees near the camera as tessellated patches. Without --tessellation those draws are skipped, so next to a tree only its separately drawn upper branches and leaves remained (floating) while its whole shadow was on the ground; with --tessellation, the interface analysis aborted with stride == 0.

Shaders: LS 565d492d8752ae5f / HS 063b41d4cf2d6719 with TES fb962980bce03500, ad7ac562a9597df6 and d50eb887bc4d8a50; LS 0be40d22aeec2cdd / HS ef022c6b5d96334c / TES 2854c49749ef2363.

Problem

  • The LS and HS write and read 40-byte records in LDS with 64-, 96- and 128-bit DS instructions, index them with the masked patch ordinal (v_and_b32 0xff of the packed HS ID) and v_add_nc_u32, and contain internal forward branches. Stride reflection did not accept any of these, so the strides came out as 0.
  • The HS stores its per-patch outputs at the top of the offchip ring (0x8000 - 0x150 * (patch + 1)) under CP0's EXEC. Active-address resolution did not look through the multiplies, shifts and bit-field extracts of that address, so it was not a constant.
  • The TES reads that per-patch block, which had no input mapping.
hidden_tree_bug

Change

  • Stride reflection accepts the 64/96/128-bit LDS accesses, the masked patch ordinal, v_add_nc_u32, and internal forward branches (a register keeps its address at a join only if every path agrees on it; code after an unconditional branch starts from the state of its joins).
  • Active-address resolution also looks through multiplies, shifts and bit-field extracts, and constant propagation folds (x << s) & m to zero when m < 2^s, so the HS per-patch addresses become constants.
  • A new PatchInput attribute maps the per-patch block to a Patch-decorated TES input at the locations of the HS's patch outputs. Both stages use the patch range found in the HS (patch_base / patch_size of ShaderTessellationInputInfo, which are part of the program key). Accesses are classified by their byte address, instruction offset included.

Tessellation stays behind --tessellation as today.

Relation to #1032

#1032 (My First Gran Turismo) also changes the tessellation stride analysis and patch-constant handling, and adds the same (x << s) & m == 0 fold. The two touch the same files and will likely conflict; whichever lands second needs a rebase. The cases differ: #1032 handles the & 0x1f00 control-point field and quad patches, this PR the LDS record accesses, the masked patch ordinal, branches and the offchip per-patch block of GTA V's trees.

Testing

  • Grand Theft Auto V (PPSA04263): with tessellation on, the trunks of nearby trees are drawn; played in my fork with this change.
  • shader_recompiler_compute_tests: new TessellationPatchConstants host case (in --tessellation-only and the default run) analyzes an LS/HS pair with this record layout and the per-patch block, and checks the strides, the patch range and the TES patch inputs. --tessellation-only, the default run and shader_cfg_tests pass.
  • Tested on Windows 11 with AMD Ryzen 5900x and RTX 3090.

AI usage

AI (Claude Opus 5.5) was used to investigate the issue and to implement the change. I reviewed the code, understand it, tested it as described above, and wrote this description myself, in general fully tested the game while doing few missions and playing in-game with my GTA V fork, i will be bringing PRs here after test them enough.

**@⁠TheCruZ** on GitHub · 2026-10-08 19:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1245) `pr/tess-tree-trunks` → `main` · +319 −39 · 8 files · 1 commits · closed without merging ## Summary Makes the tessellated tree trunks of Grand Theft Auto V (PPSA04263) translate. GTA V draws the trunk and lower branches of trees near the camera as tessellated patches. Without `--tessellation` those draws are skipped, so next to a tree only its separately drawn upper branches and leaves remained (floating) while its whole shadow was on the ground; with `--tessellation`, the interface analysis aborted with `stride == 0`. Shaders: LS `565d492d8752ae5f` / HS `063b41d4cf2d6719` with TES `fb962980bce03500`, `ad7ac562a9597df6` and `d50eb887bc4d8a50`; LS `0be40d22aeec2cdd` / HS `ef022c6b5d96334c` / TES `2854c49749ef2363`. ## Problem - The LS and HS write and read 40-byte records in LDS with 64-, 96- and 128-bit DS instructions, index them with the masked patch ordinal (`v_and_b32 0xff` of the packed HS ID) and `v_add_nc_u32`, and contain internal forward branches. Stride reflection did not accept any of these, so the strides came out as 0. - The HS stores its per-patch outputs at the top of the offchip ring (`0x8000 - 0x150 * (patch + 1)`) under CP0's EXEC. Active-address resolution did not look through the multiplies, shifts and bit-field extracts of that address, so it was not a constant. - The TES reads that per-patch block, which had no input mapping. <img width="1085" height="1153" alt="hidden_tree_bug" src="https://github.com/user-attachments/assets/b13caecc-ee6b-419a-b37b-4ed4de829f2d" /> ## Change - Stride reflection accepts the 64/96/128-bit LDS accesses, the masked patch ordinal, `v_add_nc_u32`, and internal forward branches (a register keeps its address at a join only if every path agrees on it; code after an unconditional branch starts from the state of its joins). - Active-address resolution also looks through multiplies, shifts and bit-field extracts, and constant propagation folds `(x << s) & m` to zero when `m < 2^s`, so the HS per-patch addresses become constants. - A new `PatchInput` attribute maps the per-patch block to a `Patch`-decorated TES input at the locations of the HS's patch outputs. Both stages use the patch range found in the HS (`patch_base` / `patch_size` of `ShaderTessellationInputInfo`, which are part of the program key). Accesses are classified by their byte address, instruction offset included. Tessellation stays behind `--tessellation` as today. ## Relation to #1032 #1032 (My First Gran Turismo) also changes the tessellation stride analysis and patch-constant handling, and adds the same `(x << s) & m == 0` fold. The two touch the same files and will likely conflict; whichever lands second needs a rebase. The cases differ: #1032 handles the `& 0x1f00` control-point field and quad patches, this PR the LDS record accesses, the masked patch ordinal, branches and the offchip per-patch block of GTA V's trees. ## Testing - Grand Theft Auto V (PPSA04263): with tessellation on, the trunks of nearby trees are drawn; played in my fork with this change. - `shader_recompiler_compute_tests`: new `TessellationPatchConstants` host case (in `--tessellation-only` and the default run) analyzes an LS/HS pair with this record layout and the per-patch block, and checks the strides, the patch range and the TES patch inputs. `--tessellation-only`, the default run and `shader_cfg_tests` pass. - Tested on Windows 11 with AMD Ryzen 5900x and RTX 3090. ## AI usage AI (Claude Opus 5.5) was used to investigate the issue and to implement the change. I reviewed the code, understand it, tested it as described above, and wrote this description myself, in general fully tested the game while doing few missions and playing in-game with my [GTA V fork](https://github.com/TheCruZ/KytyPS5-GTA), i will be bringing PRs here after test them enough.
GTA V (PPSA04263) draws the trunk and lower branches of trees near the
camera as tessellated patches (LS 565d492d8752ae5f / HS 063b41d4cf2d6719
with TES fb962980bce03500, ad7ac562a9597df6 and d50eb887bc4d8a50; LS
0be40d22aeec2cdd / HS ef022c6b5d96334c / TES 2854c49749ef2363). Without
--tessellation the draws are skipped, so next to a tree only its separately
drawn upper branches and leaves remained while its whole shadow was on the
ground; with it, the interface analysis aborted with "stride == 0".

- Stride reflection accepts the 64-, 96- and 128-bit LDS writes and reads
  the LS and HS use for their 40-byte records, the masked patch ordinal
  (v_and_b32 0xff of the packed HS ID), v_add_nc_u32, and internal forward
  branches, keeping a register's address at the join only if every path
  agrees on it (code after an unconditional branch starts from its joins).
- The HS stores its per-patch outputs at the top of the offchip ring
  (0x8000 - 0x150 * (patch + 1)) under CP0's EXEC. Active-address
  resolution now also looks through multiplies, shifts and bit-field
  extracts, and (x << s) & m folds to zero when m < 2^s, so these
  addresses become constants.
- The TES reads that block. A new PatchInput attribute maps it to a
  Patch-decorated input at the locations of the HS's patch outputs; both
  stages use the patch range found in the HS (patch_base/patch_size of
  ShaderTessellationInputInfo, part of the program key). Accesses are
  classified by their byte address, instruction offset included.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:49:45 +00:00
github-bot closed this pull request 2026-11-26 09:49:45 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 19:55 UTC · original · edited 2026-10-08 21:08 UTC

Review in Change Stack →

📝 Walkthrough

Walkthrough

Tessellation analysis now reflects patch-range bounds and classifies patch-area reads and writes as patch inputs and outputs. SPIR-V emission uses patch-array interfaces for both kinds and checks their bounds against the reflected range. The shader stage static key includes the patch bounds. New regression coverage checks translation and SPIR-V output across local, hull, and evaluation stages.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🟡 Moderate · up to bd351

The new tessellation support for GTA V can still reject some valid shaders. It can also read per-patch data from the wrong place when a buffer access uses an immediate offset, which can render geometry incorrectly. The feature stays behind a flag, but both issues should be fixed before merging.

🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. (1 skipped: 1… 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 GTA V tessellation issue, the shader-analysis changes, the patch-input mapping, and the reported testing. It is directly related to the changeset.
Title check ✅ Passed The title clearly identifies the primary outcome of the changes: translating GTA V's tessellated tree trunks.
Full details: Docstring Coverage

Explanation

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

  • 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-08 19:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1245#issuecomment-6067917607) · edited 2026-10-08 21:08 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/1245?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 --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough Tessellation analysis now reflects patch-range bounds and classifies patch-area reads and writes as patch inputs and outputs. SPIR-V emission uses patch-array interfaces for both kinds and checks their bounds against the reflected range. The shader stage static key includes the patch bounds. New regression coverage checks translation and SPIR-V output across local, hull, and evaluation stages. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"bd3515834c7429e5ac3dfb50046c9d7daf8d5496" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **🟡 Moderate** · up to `bd351` <!-- final_review_risk_coverage:{"sourceCommitId":"bd3515834c7429e5ac3dfb50046c9d7daf8d5496","coveredCommitId":"bd3515834c7429e5ac3dfb50046c9d7daf8d5496","kind":"reviewed"} --> The new tessellation support for GTA V can still reject some valid shaders. It can also read per-patch data from the wrong place when a buffer access uses an immediate offset, which can render geometry incorrectly. The feature stays behind a flag, but both issues should be fixed before merging. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❓ 1</summary> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :---------------- | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ❓ Inconclusive | Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. (1 skipped: 1… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | 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 GTA V tessellation issue, the shader-analysis changes, the patch-input mapping, and the reported testing. It is directly related to the changeset. | | Title check | ✅ Passed | The title clearly identifies the primary outcome of the changes: translating GTA V's tessellated tree trunks. | </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. (1 skipped: 1 too large.) </details> </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=1245)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [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) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -88,0 +120,4 @@
if (IsDirectBranch(inst.opcode) && inst.branch_target != program.instructions.back().pc) {
EXIT_NOT_IMPLEMENTED(inst.branch_target <= inst.pc);
joins.emplace_back(inst.branch_target, registers);
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 19:55 UTC · original · edited 2026-10-08 21:08 UTC

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect which branch opcodes reach the forward-join logic.
rg -n -C 5 '\bIsDirectBranch\s*\(|\bS_BRANCH\b' src/graphics/shader/recompiler

Repository: KytyPS5/KytyPS5

Length of output: 14112


Exclude unreachable fallthrough instructions from branch joins.

IsDirectBranch includes unconditional S_BRANCH. The linear scan continues through instructions after such a branch, so skipped register writes can alter the state before the branch target is processed. Track only reachable paths when applying branch joins. This prevents an unreachable write from invalidating the address state used by a later tessellation access.

✅ Confirmed as addressed by @⁠TheCruZ

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 19:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1245#discussion_r4223517280) · edited 2026-10-08 21:08 UTC **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash # Inspect which branch opcodes reach the forward-join logic. rg -n -C 5 '\bIsDirectBranch\s*\(|\bS_BRANCH\b' src/graphics/shader/recompiler ``` Repository: KytyPS5/KytyPS5 Length of output: 14112 --- </details> **Exclude unreachable fallthrough instructions from branch joins.** `IsDirectBranch` includes unconditional `S_BRANCH`. The linear scan continues through instructions after such a branch, so skipped register writes can alter the state before the branch target is processed. Track only reachable paths when applying branch joins. This prevents an unreachable write from invalidating the address state used by a later tessellation access. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:9577b7c252bce5b9adf59dbf --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠TheCruZ <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 19:55 UTC · original · reviewed

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bec514fd-e400-494a-8714-7ce3dbf46510
📥 Commits

Reviewing files that changed from the base of the PR and between 2f4b8a335d and bd3515834c7429e5ac3dfb50046c9d7daf8d5496.

📒 Files selected for processing (8)
  • src/graphics/shader/recompiler/Tessellation.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp
  • src/graphics/shader/shader.cpp
  • src/graphics/shader/shader.h
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 19:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1245#pullrequestreview-5462129381) · **reviewed** **Actionable comments posted: 2** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `bec514fd-e400-494a-8714-7ce3dbf46510` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 2f4b8a335d5e27a5153bdea670bd877a061e37b1 and bd3515834c7429e5ac3dfb50046c9d7daf8d5496. </details> <details> <summary>📒 Files selected for processing (8)</summary> * `src/graphics/shader/recompiler/Tessellation.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp` * `src/graphics/shader/shader.cpp` * `src/graphics/shader/shader.h` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=5e4fd62a-a76c-4cb0-8c5b-3eaac81430dd attempt=3b236614-f64b-4479-b8c0-40f95a1526b4 batch=1/1 -->
@ -273,0 +356,4 @@
if (address.IsImmediate() && address.U32() + memory.offset >=
tess.hs_stride * tess.output_control_points) {
kind = write ? TessellationAttribute::PatchOutput
: TessellationAttribute::PatchInput;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 19:55 UTC · original · edited 2026-10-08 21:08 UTC

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Classify patch accesses using the effective byte address.

If address is below hs_stride * output_control_points but memory.offset moves the access into the patch block, this test selects EvaluationInput instead of PatchInput. Line 359 adds the offset only after that decision. The emitter then indexes a per-vertex input with a patch address, which can read the wrong value or exceed the vertex array. Include memory.offset in the classification before selecting kind; handle components separately if an access crosses the boundary.

✅ Confirmed as addressed by @⁠TheCruZ

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 19:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1245#discussion_r4223517292) · edited 2026-10-08 21:08 UTC **🎯 Functional Correctness** | **🟠 Major** | **⚡ Quick win** **Classify patch accesses using the effective byte address.** If `address` is below `hs_stride * output_control_points` but `memory.offset` moves the access into the patch block, this test selects `EvaluationInput` instead of `PatchInput`. Line 359 adds the offset only after that decision. The emitter then indexes a per-vertex input with a patch address, which can read the wrong value or exceed the vertex array. Include `memory.offset` in the classification before selecting `kind`; handle components separately if an access crosses the boundary. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:11510032752e61fcf51ec8d8 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠TheCruZ <!-- This is an auto-generated comment by CodeRabbit -->
@ -88,0 +120,4 @@
if (IsDirectBranch(inst.opcode) && inst.branch_target != program.instructions.back().pc) {
EXIT_NOT_IMPLEMENTED(inst.branch_target <= inst.pc);
joins.emplace_back(inst.branch_target, registers);
}
Author
Owner

@⁠TheCruZ on GitHub · 2026-10-08 21:08 UTC · original

Fixed in aaf116a: after an unconditional S_BRANCH (or S_ENDPGM) the scan marks the state unreachable; the next join takes the branch's saved registers instead of merging them with the skipped fallthrough, and instructions no path reaches are not analyzed.

**@⁠TheCruZ** on GitHub · 2026-10-08 21:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1245#discussion_r4224148424) Fixed in aaf116a: after an unconditional `S_BRANCH` (or `S_ENDPGM`) the scan marks the state unreachable; the next join takes the branch's saved registers instead of merging them with the skipped fallthrough, and instructions no path reaches are not analyzed.
@ -273,0 +356,4 @@
if (address.IsImmediate() && address.U32() + memory.offset >=
tess.hs_stride * tess.output_control_points) {
kind = write ? TessellationAttribute::PatchOutput
: TessellationAttribute::PatchInput;
Author
Owner

@⁠TheCruZ on GitHub · 2026-10-08 21:08 UTC · original

Fixed in aaf116a: the PatchOutput/PatchInput classification compares address + memory.offset, the same byte address the reflection used to find the patch range.

**@⁠TheCruZ** on GitHub · 2026-10-08 21:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1245#discussion_r4224148645) Fixed in aaf116a: the PatchOutput/PatchInput classification compares `address + memory.offset`, the same byte address the reflection used to find the patch range.
@ -88,0 +120,4 @@
if (IsDirectBranch(inst.opcode) && inst.branch_target != program.instructions.back().pc) {
EXIT_NOT_IMPLEMENTED(inst.branch_target <= inst.pc);
joins.emplace_back(inst.branch_target, registers);
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 21:08 UTC · original

@TheCruZ, the supplied code addresses this finding. Unreachable instructions no longer change register state. The next reachable join restores the saved registers before merging any other incoming paths.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 21:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1245#discussion_r4224151474) `@TheCruZ`, the supplied code addresses this finding. Unreachable instructions no longer change register state. The next reachable join restores the saved registers before merging any other incoming paths. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Track%20reachability%20after%20%60S_BRANCH%60%2F%60S_ENDPGM%60%20so%20skipped%20writes%20can%E2%80%99t%20corrupt%20branch%20joins%20or%20tessellation%20address%20state.%20Try%20%40coderabbitai%20for%20actionable%20code%20reviews!%20%F0%9F%A9%BA%E2%9A%A1&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1245%23discussion_r4223517280)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
@ -273,0 +356,4 @@
if (address.IsImmediate() && address.U32() + memory.offset >=
tess.hs_stride * tess.output_control_points) {
kind = write ? TessellationAttribute::PatchOutput
: TessellationAttribute::PatchInput;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 21:08 UTC · original

@TheCruZ, thanks for the fix. The supplied code now includes memory.offset when selecting PatchOutput or PatchInput, consistent with patch-range reflection.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 21:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1245#discussion_r4224151623) `@TheCruZ`, thanks for the fix. The supplied code now includes `memory.offset` when selecting `PatchOutput` or `PatchInput`, consistent with patch-range reflection. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Classify%20patch%20accesses%20by%20effective%20byte%20address%20(%60address%20%2B%20memory.offset%60)%2C%20handling%20boundary-crossing%20components%20to%20prevent%20wrong%20reads.%20Try%20%40coderabbitai%20%F0%9F%90%87&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1245%23discussion_r4223517292)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->

Pull request closed

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