tessellation: LS/HS/TES lowering fixes for My First Gran Turismo (quad patches, barriers, patch constants) #1032

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

@⁠defektu on GitHub · 2026-10-04 01:02 UTC · original
defektu:pr/mfgt-tess → main · +383 −68 · 7 files · 4 commits · closed without merging

Part of getting My First Gran Turismo (PPSA24156) running. Earlier parts landed in main (font, HLE stubs, host and shader fixes: #1030, #1031, #1033, #1034). This PR is the tessellation lowering behind --tessellation (off by default). Rebased on current main (9e41d832).

Dependency: the title does not start on main plus this PR alone. It stops with

unsupported render-target sample configuration: samples=2 fragments=1   (colorRenderTarget.cpp)

because main still lacks the EQAA colour/depth target fix (accept EQAA colour targets without FMASK, ignore the depth PARTIALLY_RESIDENT hint), and then #1035 (mixed sample counts). Those are not part of this PR; they are what the game needs next to it.

What it fixes

  • stride reflection of the LS/HS pairs: 64/96/128-bit and two-offset LDS accesses, internal branches, the packed HS id masked to its patch ordinal or to its control point field (& 0x1f00 = control point index x 256), v_add_nc_u32 / v_add3_u32, HS control point reads at a data-dependent address;
  • quad domains, partitioning modes (integer, fractional odd/even), output winding, and factor stores whose index is only known at run time (TF[i] in a loop);
  • the HS patch-constant phase: reads of the control point outputs with control barriers, TES patch inputs, per-patch output range (patch_base / patch_size, part of the program key), control point stores past the output array are dropped;
  • tessellation control barriers use invocation scope and no explicit memory semantics (GLSL450 already publishes the outputs; OutputMemory needs the Vulkan memory model, which this module does not use);
  • (x << s) & m folds to 0 when the mask lies below the shift;
  • an unsupported LS/HS interface is logged with its reason instead of asserting.

Commits

shader: fold (x << s) & m to zero when the mask lies below the shift
tessellation: log why an LS/HS interface or ring access is unsupported
tessellation: reflect wide LDS records, internal branches and the HS control point field
tessellation: quad domains, partitioning modes, winding and runtime factor indices
tessellation: HS patch-constant phase (control point read-back, barriers, TES patch inputs)

Known gaps (not in this PR): tessellation level is sometimes too low (tires can look boxy), an empty LUT and a slight shading flicker remain. The first launch compiles dozens of large HS pipelines in the driver (HS up to ~42k SPIR-V words), so it takes minutes with a cold pipeline cache.

Testing: builds on Windows (Release, clang-cl) and shader_cfg_tests passes. Run in the game on top of this PR plus the EQAA fix and #1035 (RTX 5060 Ti, Windows 11): the title runs with --tessellation. This PR alone was not run in the game for the reason above.

🤖 Generated with Claude Code

**@⁠defektu** on GitHub · 2026-10-04 01:02 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032) `defektu:pr/mfgt-tess` → `main` · +383 −68 · 7 files · 4 commits · closed without merging Part of getting My First Gran Turismo (PPSA24156) running. Earlier parts landed in `main` (font, HLE stubs, host and shader fixes: #1030, #1031, #1033, #1034). This PR is the tessellation lowering behind `--tessellation` (off by default). Rebased on current `main` (9e41d832). **Dependency:** the title does not start on `main` plus this PR alone. It stops with ``` unsupported render-target sample configuration: samples=2 fragments=1 (colorRenderTarget.cpp) ``` because `main` still lacks the EQAA colour/depth target fix (accept EQAA colour targets without FMASK, ignore the depth `PARTIALLY_RESIDENT` hint), and then #1035 (mixed sample counts). Those are not part of this PR; they are what the game needs next to it. **What it fixes** - stride reflection of the LS/HS pairs: 64/96/128-bit and two-offset LDS accesses, internal branches, the packed HS id masked to its patch ordinal or to its control point field (`& 0x1f00` = control point index x 256), `v_add_nc_u32` / `v_add3_u32`, HS control point reads at a data-dependent address; - quad domains, partitioning modes (integer, fractional odd/even), output winding, and factor stores whose index is only known at run time (`TF[i]` in a loop); - the HS patch-constant phase: reads of the control point outputs with control barriers, TES patch inputs, per-patch output range (`patch_base` / `patch_size`, part of the program key), control point stores past the output array are dropped; - tessellation control barriers use invocation scope and no explicit memory semantics (GLSL450 already publishes the outputs; `OutputMemory` needs the Vulkan memory model, which this module does not use); - `(x << s) & m` folds to 0 when the mask lies below the shift; - an unsupported LS/HS interface is logged with its reason instead of asserting. **Commits** ``` shader: fold (x << s) & m to zero when the mask lies below the shift tessellation: log why an LS/HS interface or ring access is unsupported tessellation: reflect wide LDS records, internal branches and the HS control point field tessellation: quad domains, partitioning modes, winding and runtime factor indices tessellation: HS patch-constant phase (control point read-back, barriers, TES patch inputs) ``` **Known gaps (not in this PR):** tessellation level is sometimes too low (tires can look boxy), an empty LUT and a slight shading flicker remain. The first launch compiles dozens of large HS pipelines in the driver (HS up to ~42k SPIR-V words), so it takes minutes with a cold pipeline cache. **Testing:** builds on Windows (Release, clang-cl) and `shader_cfg_tests` passes. Run in the game on top of this PR plus the EQAA fix and #1035 (RTX 5060 Ti, Windows 11): the title runs with `--tessellation`. This PR alone was not run in the game for the reason above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The stride reflection and the memory lowering asserted on every shape they do
not handle, so a log only showed the failing line. Reflection now returns no
stride (logging the instruction that produced a non-affine address), and
AnalyzeTessellationPrograms / LowerTessellationMemory return false after
logging what they could not model. A program whose lowering fails still stops
in TranslateProgram, now with its hash and the reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
My First Gran Turismo's LS/HS pairs failed the stride reflection, which knew
only 32-bit LDS accesses, straight-line programs and a few address operations:

- LDS reads and writes of 64, 96 and 128 bits and the two-offset forms;
- internal branches: a register written between a branch and its target is
  unknown from the target on;
- the packed HS id masked to its patch ordinal (& 0xff, zero for the single
  logical patch) or to its control point field (& 0x1f00, the control point
  index times 256), and v_add_nc_u32 / v_add3_u32;
- HS control point reads at a data-dependent address (gather tables): they do
  not constrain the stride. The lowering wraps their vertex index into the
  patch's input array.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The emitter handled only triangle domains with fractional-odd spacing and
clockwise winding. Translate the VGT_TF_PARAM domain (triangles or quads),
partitioning (integer, fractional odd/even; pow2 maps to equal spacing) and
output topology (cw/ccw), and lay the factors out as outer[4] + inner[2] for
quads. A factor store whose index is only known at run time (a loop writing
TF[i]) branches on which of the two builtin arrays it falls in. Isolines and
point/line output are rejected in the lowering.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
My First Gran Turismo's hull shaders read their own control point outputs back
in the patch-constant phase, and the TES reads the patch constants:

- an HS ring read is a read of the control point outputs, indexed by the
  address the guest computed, with a control barrier at the end of the last
  block that writes control points before the first read (and one in front of
  writes that follow the reads);
- the instruction's constant offset is part of a ring address, so a TES read
  at voffset 0 + offset past the control points is a patch input;
- the HS's constant-address stores past the control point records give the
  per-patch output range (ShaderTessellationInputInfo::patch_base/patch_size,
  part of the program key). Both stages lay the patch block out from it, so the
  TES locations match what the HS wrote even when the TES reads only part of
  it;
- control point stores past the output array (patch constants whose ordinal is
  not a compile-time constant) are dropped instead of overwriting the first
  control point.

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

@⁠coderabbitai[bot] on GitHub · 2026-10-04 01:14 UTC · original · edited 2026-10-16 17:35 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

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: ef976081-68f6-468f-85fc-f1e013985553
📥 Commits

Reviewing files that changed from the base of the PR and between 6c9cd1a95eeb5079ace6bcb64f5d0f154b312229 and bddfee9388.

📒 Files selected for processing: 2
  • src/graphics/shader/shader.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

📝 Walkthrough

Tessellation analysis now reports failures and records reflected strides and patch-output ranges. Memory lowering returns a status and reports unsupported tessellation-memory cases to the translation caller. The SPIR-V backend handles additional tessellation domains, topologies, factor indices, and patch and control-point accesses. Shader preparation and static keys use the reflected metadata, and the test checks analysis success and the patch-output range.

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🟡 Moderate · up to bddfe

With tessellation enabled, affected hull shaders can stall or lose per-vertex and patch outputs, causing hangs or incorrect rendering. These current lowering and emission risks warrant resolution before merging; the analysis-failure exit behavior predates this change.

Security architecture risk: 🟡 Moderate · up to ab928

The change improves compatibility and adds write protections, but newly supported reads and synchronization paths leave bounds and convergence guarantees unresolved. The optional feature is reported as disabled by default, and effects beyond the running application have not been demonstrated.

Retained concerns

  • Medium · security · inferred: The newly accepted hull-shader control-output self-read path passes a guest-derived address to an output-array access without checking that address / hs_stride is below output_control_points. Non-immediate addresses avoid the immediate patch-region rejection, and ActiveAddress does not establish a range bound. Stores have a new bound, but loads retain only the guest predicate. This permits an out-of-range generated shader read; rendering corruption or GPU/application availability effects are plausible, while disclosure beyond the patch or a driver exploit remains unverified.
  • Medium · reliability · inferred: Synchronization for newly supported self-reads selects barrier locations using the last write block, first read, and subsequent block identity. Those choices do not themselves establish that every patch invocation reaches the barrier in the same dynamic order or that it separates every cross-invocation read/write phase across branches and loops. Correct workgroup memory semantics strengthen visibility, but do not resolve convergence. Undefined synchronization or stalled GPU execution is a plausible failure-containment risk; an upstream convergence guarantee was not established.
Security review details

Security Blast Radius

  • inferred — The concrete exposure is guest-supplied shader programs and addresses influencing generated GPU code and process-wide compilation failure. The supported risk assessment reaches patch data integrity and application/GPU availability; access to other processes, tenants, persistent data, or additional privileges was not established.

Security Findings and Attack Paths

  • inferred — A guest hull shader can supply a non-immediate ring self-read address. Lowering classifies it as ControlOutput, and emission divides that address by hs_stride and performs a load without the store-side control-point check. This is a concrete control gap in the new path, not a verified exploit against the host driver.

Trust Boundaries and Controls

  • observed — Unsupported domains, topologies, missing strides, ring formats, atomics, and stage mismatches are rejected before normal emission. Dynamic patch-output references are rejected during interface discovery. These controls narrow accepted inputs but do not constrain every dynamic self-read index.
  • observed — The added EmitSetTessellationFactor helper was not found on the reachable store path. Live factor stores still call TessellationPointer, which rejects non-immediate indices and checks immediate indices against domain-specific limits. The helper's dynamic branch is therefore not evidence of a live out-of-bounds store introduced by this PR.

Resilience and Maintainability Implications

  • inferred — Broader branch and self-read support makes patch-wide barrier convergence a failure-containment invariant. Linear selection of insertion blocks does not establish that invariant across divergent branches, repeated loop phases, or later writes; correct memory semantics alone are insufficient.

Hardening Proposals

  • proposed — Apply an explicit patch-bound policy to dynamic control-output loads, and establish barrier placement through control-flow and patch-uniformity analysis or reject shapes whose synchronization cannot be proven. These are proposed controls, not existing guarantees.
Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 8 files. (1 skipped: … 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 identifies the main change: tessellation lowering fixes for My First Gran Turismo, including quad patches, barriers, and patch constants.
Description check Passed The description is directly related to the changeset. It explains the tessellation lowering fixes, supported features, testing results, dependencies, and known gaps.
Linked Issues check Passed No active directly linked issue targets remain. Issue #1030 is closed and provides historical context only. This pull request has no linked-issue coding requirements.
Out of Scope Changes check Passed The changes remain within the stated tessellation-lowering scope. They update tessellation reflection, memory lowering, SPIR-V emission, static-key data, diagnostics, and related tests. No unrelated c…
Full details: Out of Scope Changes check

Explanation

The changes remain within the stated tessellation-lowering scope. They update tessellation reflection, memory lowering, SPIR-V emission, static-key data, diagnostics, and related tests. No unrelated change is demonstrated.

Full details: Docstring Coverage

Explanation

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

Resolution

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

  • 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-04 01:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#issuecomment-5975302555) · edited 2026-10-16 17:35 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/1032?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: bddfee9388f5816523d9a6be829d857184bdda07 > > 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 --> <!-- 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**: `ef976081-68f6-468f-85fc-f1e013985553` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 6c9cd1a95eeb5079ace6bcb64f5d0f154b312229 and bddfee9388f5816523d9a6be829d857184bdda07. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 2</strong></summary> <dl> <dd> * `src/graphics/shader/shader.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> Tessellation analysis now reports failures and records reflected strides and patch-output ranges. Memory lowering returns a status and reports unsupported tessellation-memory cases to the translation caller. The SPIR-V backend handles additional tessellation domains, topologies, factor indices, and patch and control-point accesses. Shader preparation and static keys use the reflected metadata, and the test checks analysis success and the patch-output range. </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"bddfee9388f5816523d9a6be829d857184bdda07" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🟡 Moderate</strong> · up to <code>bddfe</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `bddfe` --> <!-- final_review_risk_coverage:{"sourceCommitId":"bddfee9388f5816523d9a6be829d857184bdda07","coveredCommitId":"bddfee9388f5816523d9a6be829d857184bdda07","kind":"reviewed"} --> With tessellation enabled, affected hull shaders can stall or lose per-vertex and patch outputs, causing hangs or incorrect rendering. These current lowering and emission risks warrant resolution before merging; the analysis-failure exit behavior predates this change. <!-- final_review_risk_end --> </dd> </dl> </details> <details> <summary><strong>Security architecture risk:</strong> <strong>🟡 Moderate</strong> · up to <code>ab928</code></summary> <dl> <dd> <!-- architecture_review_start --> <!-- architecture_review_label ### Security Architecture Review **Security architecture risk:** _🟡 Moderate_ · up to `ab928` --> The change improves compatibility and adds write protections, but newly supported reads and synchronization paths leave bounds and convergence guarantees unresolved. The optional feature is reported as disabled by default, and effects beyond the running application have not been demonstrated. **Retained concerns** - **Medium · security · inferred:** The newly accepted hull-shader control-output self-read path passes a guest-derived address to an output-array access without checking that address / hs_stride is below output_control_points. Non-immediate addresses avoid the immediate patch-region rejection, and ActiveAddress does not establish a range bound. Stores have a new bound, but loads retain only the guest predicate. This permits an out-of-range generated shader read; rendering corruption or GPU/application availability effects are plausible, while disclosure beyond the patch or a driver exploit remains unverified. - **Medium · reliability · inferred:** Synchronization for newly supported self-reads selects barrier locations using the last write block, first read, and subsequent block identity. Those choices do not themselves establish that every patch invocation reaches the barrier in the same dynamic order or that it separates every cross-invocation read/write phase across branches and loops. Correct workgroup memory semantics strengthen visibility, but do not resolve convergence. Undefined synchronization or stalled GPU execution is a plausible failure-containment risk; an upstream convergence guarantee was not established. <details> <summary><strong>Security review details</strong></summary> <dl> <dd> **Security Blast Radius** - _inferred_ — The concrete exposure is guest-supplied shader programs and addresses influencing generated GPU code and process-wide compilation failure. The supported risk assessment reaches patch data integrity and application/GPU availability; access to other processes, tenants, persistent data, or additional privileges was not established. **Security Findings and Attack Paths** - _inferred_ — A guest hull shader can supply a non-immediate ring self-read address. Lowering classifies it as ControlOutput, and emission divides that address by hs_stride and performs a load without the store-side control-point check. This is a concrete control gap in the new path, not a verified exploit against the host driver. **Trust Boundaries and Controls** - _observed_ — Unsupported domains, topologies, missing strides, ring formats, atomics, and stage mismatches are rejected before normal emission. Dynamic patch-output references are rejected during interface discovery. These controls narrow accepted inputs but do not constrain every dynamic self-read index. - _observed_ — The added EmitSetTessellationFactor helper was not found on the reachable store path. Live factor stores still call TessellationPointer, which rejects non-immediate indices and checks immediate indices against domain-specific limits. The helper's dynamic branch is therefore not evidence of a live out-of-bounds store introduced by this PR. **Resilience and Maintainability Implications** - _inferred_ — Broader branch and self-read support makes patch-wide barrier convergence a failure-containment invariant. Linear selection of insertion blocks does not establish that invariant across divergent branches, repeated loop phases, or later writes; correct memory semantics alone are insufficient. **Hardening Proposals** - _proposed_ — Apply an explicit patch-bound policy to dynamic control-output loads, and establish barrier placement through control-flow and patch-uniformity analysis or reject shapes whose synchronization cannot be proven. These are proposed controls, not existing guarantees. </dd> </dl> </details> <!-- architecture_review_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 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 8 files. (1 skipped: … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly identifies the main change: tessellation lowering fixes for My First Gran Turismo, including quad patches, barriers, and patch constants. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description is directly related to the changeset. It explains the tessellation lowering fixes, supported features, testing results, dependencies, and known gaps. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | No active directly linked issue targets remain. Issue `#1030` is closed and provides historical context only. This pull request has no linked-issue coding requirements. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The changes remain within the stated tessellation-lowering scope. They update tessellation reflection, memory lowering, SPIR-V emission, static-key data, diagnostics, and related tests. No unrelated c… | <details> <summary><strong>Full details: Out of Scope Changes check</strong></summary> <dl> <dd> **Explanation** The changes remain within the stated tessellation-lowering scope. They update tessellation reflection, memory lowering, SPIR-V emission, static-key data, diagnostics, and related tests. No unrelated change is demonstrated. </dd> </dl> </details> </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 8 files. (1 skipped: 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 --> <!-- 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=1032)! 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-04 01:14 UTC · original
On src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp line 118 (outdated):

@@ -46,10 +97,25 @@ uint32_t TessellationPointer(ValueEmitContext& ctx, const IR::Inst& inst) {
 		state.builder.AddFunction(spv::OpAccessChain, type, pointer, variable, attribute,
 		                          component);
 	} else {
-		const auto vertex =
-		    kind == Attribute::ControlOutput
-		        ? EmitLaneId(state)
-		        : EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride));
+		// A ControlOutput write always targets the writing invocation's own control point
+		// (its lane ID); a ControlOutput read is either a DS/TessellationEvaluation-side
+		// EvaluationInput read or a hull shader reading back another invocation's
+		// already-written control point (see LowerTessellationMemory's self_read case) --
+		// both index by the byte address the guest computed, same as PatchOutput/LocalOutput.
+		const bool is_write = inst.GetOpcode() == IR::ValueOpcode::SetTessellationAttribute;
+		// The control point comes from the address the guest computed (its invocation index is
+		// folded into v1, so the address already carries control_point * stride). The subgroup
+		// lane is not the control point: one subgroup holds several patches, and the lane of
+		// the second patch's first invocation is 3, past the end of a 3-element output array,
+		// so every patch but the first lost its writes and its attributes read back as zero.
+		(void)is_write;
+		auto vertex = EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride));
+		if (kind == Attribute::ControlInput) {
+			// The guest addresses the LS ring of the whole thread group, and a gather table can name
+			// a vertex of the draw rather than of this patch; Vulkan's input array holds one patch.
+			vertex = EmitBinaryU32(state, spv::OpUMod, vertex,
+			                       ConstantU32(state, std::max(tess.input_control_points, 1u)));
+		}

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🌐 Web query:

Vulkan tessellation control shader write per-vertex output only gl_InvocationID SPIR-V rule

💡 Result:

**Yes—for GLSL tessellation-control shaders, per-vertex output writes must use `gl_InvocationID` as the array index.** Any other index expression is a compile-time or link-time error. `gl_InvocationID` identifies the output patch vertex assigned to that invocation. ([docs.vulkan.org](https://docs.vulkan.org/glsl/latest/chapters/variables.html?utm_source=openai))

```glsl
out vec3 data[];

void main() {
    data[gl_InvocationID] = /* value */;
}
```

That’s a **GLSL source-language rule**, not a general SPIR-V rule requiring a particular `OpAccessChain` index expression. In SPIR-V, the corresponding `InvocationId` built-in identifies the invocation/output-vertex index; the Vulkan spec says each TCS invocation outputs one control point. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/interfaces.html?utm_source=openai))

Citations:

- 1: https://docs.vulkan.org/glsl/latest/chapters/variables.html?utm_source=openai
- 2: https://docs.vulkan.org/spec/latest/chapters/interfaces.html?utm_source=openai

🏁 Script executed:

git diff --unified=35 db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp; git show ab928bc73c449f9ed441e9ceac1e07cc724f3ec1:src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | nl -ba | sed -n '70,145p']

Repository: KytyPS5/KytyPS5

Length of output: 16604


🌐 Web query:

Vulkan specification tessellation control shader per-vertex output index InvocationId restriction SPIR-V OpAccessChain

💡 Result:

In a tessellation-control shader, `InvocationId` identifies the output-patch vertex assigned to the current invocation. Each invocation produces one control point, so it may write only that corresponding per-vertex output. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/shaders.html?utm_source=openai))

**For SPIR-V, the key distinction is that Vulkan’s spec does not state a general rule that an `OpAccessChain` indexing an output array must use `InvocationId`.** The GLSL language rules do impose that restriction on per-vertex output l-values: the index must be exactly `gl_InvocationID`. ([docs.vulkan.org](https://docs.vulkan.org/glsl/latest/chapters/variables.html?utm_source=openai))

So, if you’re checking raw SPIR-V, the GLSL restriction alone doesn’t establish that a different `OpAccessChain` index is invalid Vulkan SPIR-V. The sources above establish the invocation-to-output-vertex mapping and the GLSL rule, but don’t resolve whether some separate SPIR-V/Vulkan validation rule constrains such stores. The closest relevant spec sections are Vulkan’s [tessellation-control execution rules](https://docs.vulkan.org/spec/latest/chapters/shaders.html) and the SPIR-V [InvocationId definition](https://registry.khronos.org/Vulkan/specs/latest/man/html/InvocationId.html).

Citations:

- 1: https://docs.vulkan.org/spec/latest/chapters/shaders.html?utm_source=openai
- 2: https://docs.vulkan.org/glsl/latest/chapters/variables.html?utm_source=openai

🏁 Script executed:

rg -n "LowerTessellationMemory|SetTessellationAttribute|ControlOutput" src/graphics/shader/recompiler

Repository: KytyPS5/KytyPS5

Length of output: 2946


🏁 Script executed:

rg -n "LowerTessellationMemory|SetTessellationAttribute|ControlOutput" src/graphics/shader/recompiler]]

Repository: KytyPS5/KytyPS5

Length of output: 290


🏁 Script executed:

rg -n "EmitLaneId|LowerTessellationMemory|SetTessellationAttribute" src/graphics/shader/recompiler

Repository: KytyPS5/KytyPS5

Length of output: 2262


🏁 Script executed:

printf '%s\n' '--- LowerTessellationMemory ---'; nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '297,470p'; printf '%s\n' '--- EmitLaneId ---'; nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp | sed -n '590,610p'; printf '%s\n' '--- Tessellation emitter ---'; nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | sed -n '95,115p;230,260p']]

Repository: KytyPS5/KytyPS5

Length of output: 11096


Use InvocationId for ControlOutput stores.

LowerTessellationMemory passes the guest ring-buffer address to SetTessellationAttribute. The emitter derives the vertex index from that address and only checks that the index is in range. If the address selects another control point, the store targets that point instead of the current invocation’s output, violating the Vulkan tessellation-control output contract. EmitLaneId resolves to InvocationId in the tessellation-control stage. Keep address-derived indexing for reads.

🛠 Suggested fix
-		const bool is_write = inst.GetOpcode() == IR::ValueOpcode::SetTessellationAttribute;
-		// The control point comes from the address the guest computed (its invocation index is
-		// folded into v1, so the address already carries control_point * stride). The subgroup
-		// lane is not the control point: one subgroup holds several patches, and the lane of
-		// the second patch's first invocation is 3, past the end of a 3-element output array,
-		// so every patch but the first lost its writes and its attributes read back as zero.
-		(void)is_write;
-		auto vertex = EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride));
+		const bool is_write = kind == Attribute::ControlOutput &&
+		                      inst.GetOpcode() == IR::ValueOpcode::SetTessellationAttribute;
+		auto vertex = is_write ? EmitLaneId(state)
+		                       : EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

		const bool is_write = kind == Attribute::ControlOutput &&
		                      inst.GetOpcode() == IR::ValueOpcode::SetTessellationAttribute;
		auto vertex = is_write ? EmitLaneId(state)
		                       : EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride));
		if (kind == Attribute::ControlInput) {
			// The guest addresses the LS ring of the whole thread group, and a gather table can name
			// a vertex of the draw rather than of this patch; Vulkan's input array holds one patch.
			vertex = EmitBinaryU32(state, spv::OpUMod, vertex,
			                       ConstantU32(state, std::max(tess.input_control_points, 1u)));
		}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-04 01:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#discussion_r4175647224) On `src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp` line 118 (outdated): ```diff @@ -46,10 +97,25 @@ uint32_t TessellationPointer(ValueEmitContext& ctx, const IR::Inst& inst) { state.builder.AddFunction(spv::OpAccessChain, type, pointer, variable, attribute, component); } else { - const auto vertex = - kind == Attribute::ControlOutput - ? EmitLaneId(state) - : EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride)); + // A ControlOutput write always targets the writing invocation's own control point + // (its lane ID); a ControlOutput read is either a DS/TessellationEvaluation-side + // EvaluationInput read or a hull shader reading back another invocation's + // already-written control point (see LowerTessellationMemory's self_read case) -- + // both index by the byte address the guest computed, same as PatchOutput/LocalOutput. + const bool is_write = inst.GetOpcode() == IR::ValueOpcode::SetTessellationAttribute; + // The control point comes from the address the guest computed (its invocation index is + // folded into v1, so the address already carries control_point * stride). The subgroup + // lane is not the control point: one subgroup holds several patches, and the lane of + // the second patch's first invocation is 3, past the end of a 3-element output array, + // so every patch but the first lost its writes and its attributes read back as zero. + (void)is_write; + auto vertex = EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride)); + if (kind == Attribute::ControlInput) { + // The guest addresses the LS ring of the whole thread group, and a gather table can name + // a vertex of the draw rather than of this patch; Vulkan's input array holds one patch. + vertex = EmitBinaryU32(state, spv::OpUMod, vertex, + ConstantU32(state, std::max(tess.input_control_points, 1u))); + } ``` _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_ <details> <summary>🔎 Supported by static analysis</summary> 🌐 Web query: `Vulkan tessellation control shader write per-vertex output only gl_InvocationID SPIR-V rule` 💡 Result: ```` **Yes—for GLSL tessellation-control shaders, per-vertex output writes must use `gl_InvocationID` as the array index.** Any other index expression is a compile-time or link-time error. `gl_InvocationID` identifies the output patch vertex assigned to that invocation. ([docs.vulkan.org](https://docs.vulkan.org/glsl/latest/chapters/variables.html?utm_source=openai)) ```glsl out vec3 data[]; void main() { data[gl_InvocationID] = /* value */; } ``` That’s a **GLSL source-language rule**, not a general SPIR-V rule requiring a particular `OpAccessChain` index expression. In SPIR-V, the corresponding `InvocationId` built-in identifies the invocation/output-vertex index; the Vulkan spec says each TCS invocation outputs one control point. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/interfaces.html?utm_source=openai)) Citations: - 1: https://docs.vulkan.org/glsl/latest/chapters/variables.html?utm_source=openai - 2: https://docs.vulkan.org/spec/latest/chapters/interfaces.html?utm_source=openai ```` --- 🏁 Script executed: ```bash git diff --unified=35 db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp; git show ab928bc73c449f9ed441e9ceac1e07cc724f3ec1:src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | nl -ba | sed -n '70,145p'] ``` Repository: KytyPS5/KytyPS5 Length of output: 16604 --- 🌐 Web query: `Vulkan specification tessellation control shader per-vertex output index InvocationId restriction SPIR-V OpAccessChain` 💡 Result: ``` In a tessellation-control shader, `InvocationId` identifies the output-patch vertex assigned to the current invocation. Each invocation produces one control point, so it may write only that corresponding per-vertex output. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/shaders.html?utm_source=openai)) **For SPIR-V, the key distinction is that Vulkan’s spec does not state a general rule that an `OpAccessChain` indexing an output array must use `InvocationId`.** The GLSL language rules do impose that restriction on per-vertex output l-values: the index must be exactly `gl_InvocationID`. ([docs.vulkan.org](https://docs.vulkan.org/glsl/latest/chapters/variables.html?utm_source=openai)) So, if you’re checking raw SPIR-V, the GLSL restriction alone doesn’t establish that a different `OpAccessChain` index is invalid Vulkan SPIR-V. The sources above establish the invocation-to-output-vertex mapping and the GLSL rule, but don’t resolve whether some separate SPIR-V/Vulkan validation rule constrains such stores. The closest relevant spec sections are Vulkan’s [tessellation-control execution rules](https://docs.vulkan.org/spec/latest/chapters/shaders.html) and the SPIR-V [InvocationId definition](https://registry.khronos.org/Vulkan/specs/latest/man/html/InvocationId.html). Citations: - 1: https://docs.vulkan.org/spec/latest/chapters/shaders.html?utm_source=openai - 2: https://docs.vulkan.org/glsl/latest/chapters/variables.html?utm_source=openai ``` --- 🏁 Script executed: ```bash rg -n "LowerTessellationMemory|SetTessellationAttribute|ControlOutput" src/graphics/shader/recompiler ``` Repository: KytyPS5/KytyPS5 Length of output: 2946 --- 🏁 Script executed: ```bash rg -n "LowerTessellationMemory|SetTessellationAttribute|ControlOutput" src/graphics/shader/recompiler]] ``` Repository: KytyPS5/KytyPS5 Length of output: 290 --- 🏁 Script executed: ```bash rg -n "EmitLaneId|LowerTessellationMemory|SetTessellationAttribute" src/graphics/shader/recompiler ``` Repository: KytyPS5/KytyPS5 Length of output: 2262 --- 🏁 Script executed: ```bash printf '%s\n' '--- LowerTessellationMemory ---'; nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '297,470p'; printf '%s\n' '--- EmitLaneId ---'; nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp | sed -n '590,610p'; printf '%s\n' '--- Tessellation emitter ---'; nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | sed -n '95,115p;230,260p']] ``` Repository: KytyPS5/KytyPS5 Length of output: 11096 --- </details> **Use `InvocationId` for `ControlOutput` stores.** `LowerTessellationMemory` passes the guest ring-buffer address to `SetTessellationAttribute`. The emitter derives the vertex index from that address and only checks that the index is in range. If the address selects another control point, the store targets that point instead of the current invocation’s output, violating the Vulkan tessellation-control output contract. `EmitLaneId` resolves to `InvocationId` in the tessellation-control stage. Keep address-derived indexing for reads. <details> <summary>🛠 Suggested fix</summary> ```diff - const bool is_write = inst.GetOpcode() == IR::ValueOpcode::SetTessellationAttribute; - // The control point comes from the address the guest computed (its invocation index is - // folded into v1, so the address already carries control_point * stride). The subgroup - // lane is not the control point: one subgroup holds several patches, and the lane of - // the second patch's first invocation is 3, past the end of a 3-element output array, - // so every patch but the first lost its writes and its attributes read back as zero. - (void)is_write; - auto vertex = EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride)); + const bool is_write = kind == Attribute::ControlOutput && + inst.GetOpcode() == IR::ValueOpcode::SetTessellationAttribute; + auto vertex = is_write ? EmitLaneId(state) + : EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride)); ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion const bool is_write = kind == Attribute::ControlOutput && inst.GetOpcode() == IR::ValueOpcode::SetTessellationAttribute; auto vertex = is_write ? EmitLaneId(state) : EmitBinaryU32(state, spv::OpUDiv, address, ConstantU32(state, stride)); if (kind == Attribute::ControlInput) { // The guest addresses the LS ring of the whole thread group, and a gather table can name // a vertex of the draw rather than of this patch; Vulkan's input array holds one patch. vertex = EmitBinaryU32(state, spv::OpUMod, vertex, ConstantU32(state, std::max(tess.input_control_points, 1u))); } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a3bd8a0eddd299c0cb2af0d8 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -156,1 +258,4 @@
// Factor stores go through the helper: it also handles an index only known at runtime.
EmitSetTessellationFactor(ctx, inst, floating);
return;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-04 01:14 UTC · original · edited 2026-10-04 02:05 UTC

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '225,265p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp
sed -n '370,465p' src/graphics/shader/recompiler/Tessellation.cpp
git diff db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp

Repository: KytyPS5/KytyPS5

Length of output: 19630


🏁 Script executed:

git diff --unified=12 db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/Tessellation.cpp
printf '\n--- current lowering ---\n'
sed -n '330,470p' src/graphics/shader/recompiler/Tessellation.cpp
printf '\n--- emitter definitions and uses ---\n'
rg -n -C 3 'EmitSetTessellationFactor|TessellationPointer|EmitSetTessellationAttribute' src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp
printf '\n--- failure macro binding ---\n'
rg -n -m 8 '#define EXIT_NOT_IMPLEMENTED|EXIT_NOT_IMPLEMENTED\\(' src/graphics/shader/recompiler

Repository: KytyPS5/KytyPS5

Length of output: 32237


Dispatch dynamic factor stores before pointer construction.

LowerTessellationMemory passes the resolved factor-buffer address as the SetTessellationAttribute index. When that index is non-immediate, EmitSetTessellationAttribute still calls TessellationPointer, which rejects it. The new EmitSetTessellationFactor helper is not called, so the dynamic-index support added by this PR cannot emit the store. Route Factor stores at this live store path through a dynamic-index implementation with domain bounds.

✅ Addressed in commit 81c7910

**@⁠coderabbitai[bot]** on GitHub · 2026-10-04 01:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#discussion_r4175647241) · edited 2026-10-04 02:05 UTC _🎯 Functional Correctness_ | _🟡 Minor_ | _⚡ Quick win_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '225,265p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp sed -n '370,465p' src/graphics/shader/recompiler/Tessellation.cpp git diff db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 19630 --- 🏁 Script executed: ```bash git diff --unified=12 db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/Tessellation.cpp printf '\n--- current lowering ---\n' sed -n '330,470p' src/graphics/shader/recompiler/Tessellation.cpp printf '\n--- emitter definitions and uses ---\n' rg -n -C 3 'EmitSetTessellationFactor|TessellationPointer|EmitSetTessellationAttribute' src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp printf '\n--- failure macro binding ---\n' rg -n -m 8 '#define EXIT_NOT_IMPLEMENTED|EXIT_NOT_IMPLEMENTED\\(' src/graphics/shader/recompiler ``` Repository: KytyPS5/KytyPS5 Length of output: 32237 --- </details> **Dispatch dynamic factor stores before pointer construction.** `LowerTessellationMemory` passes the resolved factor-buffer address as the `SetTessellationAttribute` index. When that index is non-immediate, `EmitSetTessellationAttribute` still calls `TessellationPointer`, which rejects it. The new `EmitSetTessellationFactor` helper is not called, so the dynamic-index support added by this PR cannot emit the store. Route Factor stores at this live store path through a dynamic-index implementation with domain bounds. <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:c7ba822d04cdcdf52778ed39 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 81c7910
@ -278,0 +462,4 @@
} else if (!post_read_barrier && block != read_block) {
block->PrependNewInst(it, ValueOpcode::Barrier, {});
post_read_barrier = true;
}
Author
Owner

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

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

printf '%s\n' '--- PR diff ---'
git diff --unified=35 db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/Tessellation.cpp | sed -n '1,280p'
printf '%s\n' '--- target source ---'
sed -n '300,470p' src/graphics/shader/recompiler/Tessellation.cpp | cat -n
printf '%s\n' '--- directly relevant symbols ---'
rg -n 'PrependNewInst|post.?dom|PostDomin|ControlBarrier|seen_self_read|last_write_block' src/graphics/shader/recompiler src/graphics/shader -g '*.{cpp,h,hpp}' | head -220

Repository: KytyPS5/KytyPS5

Length of output: 32435


🏁 Script executed:

printf '%s\n' '--- final target lines ---'
nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '305,455p'
printf '%s\n' '--- barrier emitter ---'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp | sed -n '575,605p'
printf '%s\n' '--- barrier mapping and IR control-flow declarations ---'
rg -n -C 3 'ValueOpcode::Barrier|enum class ValueOpcode|OpBranchConditional|BranchConditional|CondBranch|ConditionalBranch|Block::|struct Block|class Block' src/graphics/shader/recompiler/ir src/graphics/shader/recompiler/backend/spirv -g '*.{cpp,h,hpp}'
printf '%s\n' '--- relevant program block construction/control flow ---'
rg -n -C 3 'program\.blocks|blocks\.push_back|AddBlock|branch_target|PrependNewInst' src/graphics/shader/recompiler/frontend src/graphics/shader/recompiler/ir -g '*.{cpp,h,hpp}' | head -240
printf '%s\n' '--- source comments around per-lane branch ---'
nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '315,335p'

Repository: KytyPS5/KytyPS5

Length of output: 41996


Place tessellation barriers in uniform control flow.

A hull-shader ControlOutput self-read can occur in the per-lane patch-constant phase. When last_write_block is null or is the read’s block, this code inserts ValueOpcode::Barrier immediately before the read, inside that branch. The SPIR-V emitter turns it into OpControlBarrier, but every patch invocation must reach the barrier.

Place the pre-read barrier at a point reached by every patch invocation, after the relevant writes and before the self-reads. Apply the same rule to any post-read barrier. Reject programs when no such placement exists.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-04 01:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#discussion_r4175647248) _🩺 Stability & Availability_ | _🟠 Major_ | _🏗️ Heavy lift_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash printf '%s\n' '--- PR diff ---' git diff --unified=35 db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/Tessellation.cpp | sed -n '1,280p' printf '%s\n' '--- target source ---' sed -n '300,470p' src/graphics/shader/recompiler/Tessellation.cpp | cat -n printf '%s\n' '--- directly relevant symbols ---' rg -n 'PrependNewInst|post.?dom|PostDomin|ControlBarrier|seen_self_read|last_write_block' src/graphics/shader/recompiler src/graphics/shader -g '*.{cpp,h,hpp}' | head -220 ``` Repository: KytyPS5/KytyPS5 Length of output: 32435 --- 🏁 Script executed: ```bash printf '%s\n' '--- final target lines ---' nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '305,455p' printf '%s\n' '--- barrier emitter ---' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp | sed -n '575,605p' printf '%s\n' '--- barrier mapping and IR control-flow declarations ---' rg -n -C 3 'ValueOpcode::Barrier|enum class ValueOpcode|OpBranchConditional|BranchConditional|CondBranch|ConditionalBranch|Block::|struct Block|class Block' src/graphics/shader/recompiler/ir src/graphics/shader/recompiler/backend/spirv -g '*.{cpp,h,hpp}' printf '%s\n' '--- relevant program block construction/control flow ---' rg -n -C 3 'program\.blocks|blocks\.push_back|AddBlock|branch_target|PrependNewInst' src/graphics/shader/recompiler/frontend src/graphics/shader/recompiler/ir -g '*.{cpp,h,hpp}' | head -240 printf '%s\n' '--- source comments around per-lane branch ---' nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '315,335p' ``` Repository: KytyPS5/KytyPS5 Length of output: 41996 --- </details> **Place tessellation barriers in uniform control flow.** A hull-shader `ControlOutput` self-read can occur in the per-lane patch-constant phase. When `last_write_block` is null or is the read’s block, this code inserts `ValueOpcode::Barrier` immediately before the read, inside that branch. The SPIR-V emitter turns it into `OpControlBarrier`, but every patch invocation must reach the barrier. Place the pre-read barrier at a point reached by every patch invocation, after the relevant writes and before the self-reads. Apply the same rule to any post-read barrier. Reject programs when no such placement exists. <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:f7455117b8bb19c303a39de8 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-04 01:14 UTC · original
On src/graphics/shader/recompiler/Tessellation.h line 21 (outdated):

@@ -14,8 +14,12 @@ namespace IR {
 struct Program;
 }
 
-void AnalyzeTessellationPrograms(std::span<const uint32_t> local, std::span<const uint32_t> control,
-                                 ShaderTessellationInputInfo& info);
-void LowerTessellationMemory(IR::Program& program, const CompileOptions& options);
+// False when the interface cannot be reflected; the strides are then left at zero and the
+// tessellated draw is skipped.
+[[nodiscard]] bool AnalyzeTessellationPrograms(std::span<const uint32_t> local,
+                                               std::span<const uint32_t> control,
+                                               ShaderTessellationInputInfo& info);

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -nP -C3 '\bAnalyzeTessellationPrograms\s*\(' 
rg -n 'Werror|WX' CMakeLists.txt

Repository: KytyPS5/KytyPS5

Length of output: 2882


🏁 Script executed:

printf '%s\n' '--- shader.cpp ---'
sed -n '760,850p' src/graphics/shader/shader.cpp
printf '%s\n' '--- translation and lowering call sites ---'
rg -n -C 5 'LowerTessellationMemory|TranslateProgram|PrepareTessellationPrograms' src/graphics/shader
printf '%s\n' '--- lowering implementation ---'
rg -n -C 18 'bool LowerTessellationMemory|LowerTessellationMemory\(' src/graphics/shader/recompiler/Tessellation.cpp src/graphics/shader
printf '%s\n' '--- tessellation analysis failure returns ---'
sed -n '265,365p' src/graphics/shader/recompiler/Tessellation.cpp

Repository: KytyPS5/KytyPS5

Length of output: 36748


🏁 Script executed:

printf '%s\n' '--- PR diff ---'
git diff --unified=5 db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/Tessellation.h src/graphics/shader/recompiler/Tessellation.cpp src/graphics/shader/shader.cpp src/graphics/shader/recompiler/ShaderRecompiler.cpp
printf '%s\n' '--- PrepareTessellationPrograms callers ---'
rg -n -C 8 'PrepareTessellationPrograms\s*\('
printf '%s\n' '--- EXIT macro definitions ---'
rg -n -C 3 '#\s*define\s+EXIT(_IF|_NOT_IMPLEMENTED)?\b|#\s*define\s+EXIT\b' --glob '*.{h,hpp,cpp,cxx}'

Repository: KytyPS5/KytyPS5

Length of output: 29923


🏁 Script executed:

printf '%s\n' '--- DbgExit declarations and implementation ---'
rg -n -C 5 '\bDbgExit(Handler)?\s*\(' src
printf '%s\n' '--- tessellation info declaration ---'
rg -n -C 8 'struct ShaderTessellationInputInfo'
printf '%s\n' '--- graphics programs API and call sites ---'
rg -n -C 10 'GetGraphicsPrograms\s*\(' src/graphics/host_gpu
printf '%s\n' '--- pipeline cache result type ---'
rg -n -C 8 'struct GraphicsPrograms|class PipelineCache|GraphicsPrograms' src/graphics/host_gpu/renderer/pipeline/pipelineCache.h src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 26973


🏁 Script executed:

printf '%s\n' '--- program-cache translation binding ---'
rg -n -C 12 'struct PipelineCache::ProgramCache|ProgramCache::Get|TranslateProgram\s*\(' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp src/graphics/shader
printf '%s\n' '--- immediate draw flow ---'
sed -n '830,955p' src/graphics/host_gpu/renderer/renderDraw.cpp

Repository: KytyPS5/KytyPS5

Length of output: 21949


Propagate failed tessellation analysis so the draw can be skipped.

When interface reflection fails for a supported domain and topology, AnalyzeTessellationPrograms returns false and leaves the strides at zero. PrepareTessellationPrograms ignores the result and copies those zero strides to every stage. ProgramCache::Get then calls TranslateProgram; LowerTessellationMemory rejects the zero strides, and the new EXIT path calls std::_Exit(321). The emulator terminates instead of skipping the draw. Propagate the failure to the draw path and skip the draw before compiling its tessellation stages.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-04 01:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#discussion_r4175647252) On `src/graphics/shader/recompiler/Tessellation.h` line 21 (outdated): ```diff @@ -14,8 +14,12 @@ namespace IR { struct Program; } -void AnalyzeTessellationPrograms(std::span<const uint32_t> local, std::span<const uint32_t> control, - ShaderTessellationInputInfo& info); -void LowerTessellationMemory(IR::Program& program, const CompileOptions& options); +// False when the interface cannot be reflected; the strides are then left at zero and the +// tessellated draw is skipped. +[[nodiscard]] bool AnalyzeTessellationPrograms(std::span<const uint32_t> local, + std::span<const uint32_t> control, + ShaderTessellationInputInfo& info); ``` _🎯 Functional Correctness_ | _🟠 Major_ | _🏗️ Heavy lift_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash rg -nP -C3 '\bAnalyzeTessellationPrograms\s*\(' rg -n 'Werror|WX' CMakeLists.txt ``` Repository: KytyPS5/KytyPS5 Length of output: 2882 --- 🏁 Script executed: ```bash printf '%s\n' '--- shader.cpp ---' sed -n '760,850p' src/graphics/shader/shader.cpp printf '%s\n' '--- translation and lowering call sites ---' rg -n -C 5 'LowerTessellationMemory|TranslateProgram|PrepareTessellationPrograms' src/graphics/shader printf '%s\n' '--- lowering implementation ---' rg -n -C 18 'bool LowerTessellationMemory|LowerTessellationMemory\(' src/graphics/shader/recompiler/Tessellation.cpp src/graphics/shader printf '%s\n' '--- tessellation analysis failure returns ---' sed -n '265,365p' src/graphics/shader/recompiler/Tessellation.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 36748 --- 🏁 Script executed: ```bash printf '%s\n' '--- PR diff ---' git diff --unified=5 db1758527751125592f57bf02f29616fa0643159 ab928bc73c449f9ed441e9ceac1e07cc724f3ec1 -- src/graphics/shader/recompiler/Tessellation.h src/graphics/shader/recompiler/Tessellation.cpp src/graphics/shader/shader.cpp src/graphics/shader/recompiler/ShaderRecompiler.cpp printf '%s\n' '--- PrepareTessellationPrograms callers ---' rg -n -C 8 'PrepareTessellationPrograms\s*\(' printf '%s\n' '--- EXIT macro definitions ---' rg -n -C 3 '#\s*define\s+EXIT(_IF|_NOT_IMPLEMENTED)?\b|#\s*define\s+EXIT\b' --glob '*.{h,hpp,cpp,cxx}' ``` Repository: KytyPS5/KytyPS5 Length of output: 29923 --- 🏁 Script executed: ```bash printf '%s\n' '--- DbgExit declarations and implementation ---' rg -n -C 5 '\bDbgExit(Handler)?\s*\(' src printf '%s\n' '--- tessellation info declaration ---' rg -n -C 8 'struct ShaderTessellationInputInfo' printf '%s\n' '--- graphics programs API and call sites ---' rg -n -C 10 'GetGraphicsPrograms\s*\(' src/graphics/host_gpu printf '%s\n' '--- pipeline cache result type ---' rg -n -C 8 'struct GraphicsPrograms|class PipelineCache|GraphicsPrograms' src/graphics/host_gpu/renderer/pipeline/pipelineCache.h src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 26973 --- 🏁 Script executed: ```bash printf '%s\n' '--- program-cache translation binding ---' rg -n -C 12 'struct PipelineCache::ProgramCache|ProgramCache::Get|TranslateProgram\s*\(' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp src/graphics/shader printf '%s\n' '--- immediate draw flow ---' sed -n '830,955p' src/graphics/host_gpu/renderer/renderDraw.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 21949 --- </details> **Propagate failed tessellation analysis so the draw can be skipped.** When interface reflection fails for a supported domain and topology, `AnalyzeTessellationPrograms` returns false and leaves the strides at zero. `PrepareTessellationPrograms` ignores the result and copies those zero strides to every stage. `ProgramCache::Get` then calls `TranslateProgram`; `LowerTessellationMemory` rejects the zero strides, and the new `EXIT` path calls `std::_Exit(321)`. The emulator terminates instead of skipping the draw. Propagate the failure to the draw path and skip the draw before compiling its tessellation stages. <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:5a90db6ba368fee1d3dbc86c --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-04 01:14 UTC · original · reviewed

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4cfb511c-d846-440b-b83a-8a8ca0d48dcc
📥 Commits

Reviewing files that changed from the base of the PR and between db17585277 and ab928bc73c449f9ed441e9ceac1e07cc724f3ec1.

📒 Files selected for processing (6)
  • src/graphics/shader/recompiler/ShaderRecompiler.cpp
  • src/graphics/shader/recompiler/Tessellation.cpp
  • src/graphics/shader/recompiler/Tessellation.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp
  • src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-04 01:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#pullrequestreview-5403718604) · **reviewed** **Actionable comments posted: 4** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `4cfb511c-d846-440b-b83a-8a8ca0d48dcc` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between db1758527751125592f57bf02f29616fa0643159 and ab928bc73c449f9ed441e9ceac1e07cc724f3ec1. </details> <details> <summary>📒 Files selected for processing (6)</summary> * `src/graphics/shader/recompiler/ShaderRecompiler.cpp` * `src/graphics/shader/recompiler/Tessellation.cpp` * `src/graphics/shader/recompiler/Tessellation.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp` * `src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 23:22 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3c73bdaf-7024-4427-a303-bec7da108ff4
📥 Commits

Reviewing files that changed from the base of the PR and between 81c791099dfa64a0b7583fa14b47b352b7c7d0cb and f1217f9113132cda5db1157131dfa81168bcc3e8.

📒 Files selected for processing: 8
  • src/graphics/shader/recompiler/ShaderRecompiler.cpp
  • src/graphics/shader/recompiler/Tessellation.cpp
  • src/graphics/shader/recompiler/Tessellation.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp
  • 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; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 23:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#pullrequestreview-5541104057) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `3c73bdaf-7024-4427-a303-bec7da108ff4` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 81c791099dfa64a0b7583fa14b47b352b7c7d0cb and f1217f9113132cda5db1157131dfa81168bcc3e8. </details> <details> <summary>📒 Files selected for processing: 8</summary> * `src/graphics/shader/recompiler/ShaderRecompiler.cpp` * `src/graphics/shader/recompiler/Tessellation.cpp` * `src/graphics/shader/recompiler/Tessellation.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp` * `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; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=7db328a5-02dd-4d61-a8fb-4a702625c1ba attempt=ba4d4990-196a-4723-898d-fc57c5a7df12 batch=1/1 -->
@ -151,0 +248,4 @@
ConstantU32(ctx.state, tess.output_control_points));
ctx.state.builder.AddFunction(spv::OpLogicalAnd, TypeBool(ctx.state), both, condition,
inside);
condition = both;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 23:22 UTC · original

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail
ast-grep outline src/graphics/shader/recompiler/Tessellation.cpp \
  --match 'LowerTessellationMemory' --view expanded
rg -n -C 8 'PatchOutput|ControlOutput|patch_base|patch_size|self_read|return false' \
  src/graphics/shader/recompiler/Tessellation.cpp
rg -n -C 5 'PatchOutput|patch_base|patch_size' tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 8072


🏁 Script executed:

set -euo pipefail
printf '%s\n' '--- LowerTessellationMemory ---'
sed -n '324,540p' src/graphics/shader/recompiler/Tessellation.cpp
printf '%s\n' '--- analysis helpers ---'
sed -n '1,324p' src/graphics/shader/recompiler/Tessellation.cpp
printf '%s\n' '--- tests around tessellation analysis and lowering ---'
sed -n '39740,39940p' tests/ShaderRecompilerComputeTests.cpp
printf '%s\n' '--- callers of LowerTessellationMemory ---'
rg -n -C 8 -F -- 'LowerTessellationMemory' src tests

Repository: KytyPS5/KytyPS5

Length of output: 43630


Do not silently discard dynamically addressed patch-constant stores.

LowerTessellationMemory keeps non-immediate patch-range stores classified as ControlOutput. The emitter then suppresses them when their derived vertex is outside output_control_points. A matching TES patch read can therefore observe an unwritten patch output.

Classify proven patch-range stores as PatchOutput. Otherwise, report unsupported lowering instead of dropping the write.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 23:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#discussion_r4289267237) **🗄️ Data Integrity & Integration** | **🟠 Major** | **🏗️ Heavy lift** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash set -euo pipefail ast-grep outline src/graphics/shader/recompiler/Tessellation.cpp \ --match 'LowerTessellationMemory' --view expanded rg -n -C 8 'PatchOutput|ControlOutput|patch_base|patch_size|self_read|return false' \ src/graphics/shader/recompiler/Tessellation.cpp rg -n -C 5 'PatchOutput|patch_base|patch_size' tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 8072 --- 🏁 Script executed: ```bash set -euo pipefail printf '%s\n' '--- LowerTessellationMemory ---' sed -n '324,540p' src/graphics/shader/recompiler/Tessellation.cpp printf '%s\n' '--- analysis helpers ---' sed -n '1,324p' src/graphics/shader/recompiler/Tessellation.cpp printf '%s\n' '--- tests around tessellation analysis and lowering ---' sed -n '39740,39940p' tests/ShaderRecompilerComputeTests.cpp printf '%s\n' '--- callers of LowerTessellationMemory ---' rg -n -C 8 -F -- 'LowerTessellationMemory' src tests ``` Repository: KytyPS5/KytyPS5 Length of output: 43630 --- </details> **Do not silently discard dynamically addressed patch-constant stores.** `LowerTessellationMemory` keeps non-immediate patch-range stores classified as `ControlOutput`. The emitter then suppresses them when their derived vertex is outside `output_control_points`. A matching TES patch read can therefore observe an unwritten patch output. Classify proven patch-range stores as `PatchOutput`. Otherwise, report unsupported lowering instead of dropping the write. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:38cbac1a91419ba2ab1efa1a --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠defektu on GitHub · 2026-10-16 14:44 UTC · original

@⁠Nmzik this is resolved for main with #1035

**@⁠defektu** on GitHub · 2026-10-16 14:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#issuecomment-6217988204) @⁠Nmzik this is resolved for main with #1035
Author
Owner

@⁠Nmzik on GitHub · 2026-10-29 04:56 UTC · original

@⁠defektu in main. credited

**@⁠Nmzik** on GitHub · 2026-10-29 04:56 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1032#issuecomment-6488329219) @⁠defektu in main. credited

Pull request closed

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