tessellation: run Gran Turismo 7's patches #1919

Open
github-bot wants to merge 5 commits from github-bot/gh-1919 into main AGit
Owner

@⁠ew-sudo on GitHub · 2026-10-26 19:26 UTC · original
ew-sudo:pr-gt7-tessellation → main · +134 −37 · 3 files · 5 commits · open

Gran Turismo 7 (PPSA01317) stopped in the tessellation analysis as soon as its cars or tracks were drawn. This series adds what its LS/HS/TES need on top of the current tessellation code. It keeps the recent work (strides across branches, patch constants, control-point read-back, looped HS reflection) and does not replace it.

  1. Quad domains, counter-clockwise output and every partitioning mode: VGT_TF_PARAM.TYPE 2 (quads, 4 outer + 2 inner factors), TOPOLOGY 3 (CCW), fractional-even spacing, and power-of-two approximated by equal spacing.
  2. Bit operations on control-point addresses: the packed HS ID is read as control point * 256, and masks, BFEs, right shifts, ORs and SDWA selects are evaluated exactly on a power-of-two scaled index. This fixes "HS tessellation address is not affine" on (ID & 0x1f00) + (ordinal << 10).
  3. Shifts and masks through EXEC-masked addresses (ActiveAddress): patch-constant addresses computed under a narrower EXEC were taken for control-point writes, and the cars rendered as shards.
  4. The immediate offset counts when classifying patch accesses: a TES read at base 0 + offset 144 was taken for a fifth control point, which caused a GPU fault.
  5. The static key of a stage only holds the tessellation fields its translation reads: a shared LS or TES was compiled again for every HS pairing.
  • #1032 covers part of the same ground (quad domains, partitioning, winding) on an older base. With it, GT7 still stops when a race loads: unsupported tessellation memory shape (LS 0xdaf84971c11582b7).
  • On current main, GT7 also needs #1918 to stop its tessellation vertex shaders from hanging the GPU.

Testing

Gran Turismo 7 (PPSA01317), RTX 4070 Laptop: menus, garage and race start, together with #1918

**@⁠ew-sudo** on GitHub · 2026-10-26 19:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1919) `ew-sudo:pr-gt7-tessellation` → `main` · +134 −37 · 3 files · 5 commits · open Gran Turismo 7 (PPSA01317) stopped in the tessellation analysis as soon as its cars or tracks were drawn. This series adds what its LS/HS/TES need on top of the current tessellation code. It keeps the recent work (strides across branches, patch constants, control-point read-back, looped HS reflection) and does not replace it. 1. **Quad domains, counter-clockwise output and every partitioning mode**: `VGT_TF_PARAM.TYPE 2` (quads, 4 outer + 2 inner factors), `TOPOLOGY 3` (CCW), fractional-even spacing, and power-of-two approximated by equal spacing. 2. **Bit operations on control-point addresses**: the packed HS ID is read as control point * 256, and masks, BFEs, right shifts, ORs and SDWA selects are evaluated exactly on a power-of-two scaled index. This fixes "HS tessellation address is not affine" on `(ID & 0x1f00) + (ordinal << 10)`. 3. **Shifts and masks through EXEC-masked addresses** (`ActiveAddress`): patch-constant addresses computed under a narrower EXEC were taken for control-point writes, and the cars rendered as shards. 4. **The immediate offset counts when classifying patch accesses**: a TES read at base 0 + offset 144 was taken for a fifth control point, which caused a GPU fault. 5. **The static key of a stage only holds the tessellation fields its translation reads**: a shared LS or TES was compiled again for every HS pairing. ### Related - #1032 covers part of the same ground (quad domains, partitioning, winding) on an older base. With it, GT7 still stops when a race loads: `unsupported tessellation memory shape` (LS `0xdaf84971c11582b7`). - On current main, GT7 also needs #1918 to stop its tessellation vertex shaders from hanging the GPU. ### Testing Gran Turismo 7 (PPSA01317), RTX 4070 Laptop: menus, garage and race start, together with https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/1918
GT7's cars use VGT_TF_PARAM.TYPE 2 (quads), some of its track geometry
TOPOLOGY 3 (counter-clockwise triangles), and its patches use integer,
fractional-odd and fractional-even partitioning. The evaluation shader
refused anything but clockwise triangles with integer or fractional-odd
spacing.

- Quads declare the Quads execution mode, and the factor buffer maps 4 outer
  and 2 inner factors (3 + 1 for triangles) to TessLevelOuter/Inner.
- Topology 3 maps to VertexOrderCcw.
- Fractional-even maps to SpacingFractionalEven. Power-of-two spacing, which
  Vulkan lacks, is approximated with equal spacing.
- An unsupported combination reports its values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CM9KLt5uNWomVHfHUhCLFz
The stride reflection knew the packed HS ID only through V_BFE_U32 8, 5 and
V_AND_B32 0xff. GT7's race hull shaders build their output address as
(ID & 0x1f00) + (ordinal << 10), which stopped the emulator with "HS
tessellation address is not affine".

The packed ID (patch ordinal in bits 0-7, control point in bits 8-12) is now
read as control point * 256, the ordinal being 0 in the logical interface as
before. Masks, bit-field extracts, right shifts, ORs and SDWA byte/word
selects are evaluated exactly on a control-point index scaled by a power of
two, and are refused when they would cut through it. V_MOV_B32, V_ADD3_U32,
V_LSHL_OR_B32 and V_SUBREV_NC_U32 are followed as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CM9KLt5uNWomVHfHUhCLFz
ActiveAddress removes the EXEC selects of a store's address through integer
adds, subtractions, multiplies and bit-field extracts. GT7 computes its patch
constant addresses with shifts and masks of the patch ordinal under a
narrower EXEC: the select stayed, the address was not constant, and the
writes were taken for control-point writes (the cars rendered as shards).
Logical shifts, ANDs and ORs are now followed too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CM9KLt5uNWomVHfHUhCLFz
An evaluation shader read past its patch's control points was classified by
its base address alone. GT7's track evaluation shaders read their patch
constants at base 0 + offset 144 of a 4 x 32-byte patch: the read was taken
for a fifth control point, outside the input array, and fed a garbage index
to a later buffer load (a GPU fault, then a lost device). The immediate
offset is now added before comparing with the control-point area.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CM9KLt5uNWomVHfHUhCLFz
Every tessellation field was part of the static key of the LS, HS and TES.
GT7 pairs the same LS and TES with hull shaders of different patch sizes,
so each pairing translated and compiled them again, and each of those
compiles is a stutter in a race. The LS is now keyed on ls_stride only, the
TES on the HS output layout and the domain modes; the HS keeps every field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CM9KLt5uNWomVHfHUhCLFz
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:08:55 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 19:33 UTC · original

Review in Change Stack →

Walkthrough

The changes select tessellation fields for shader-stage keys, expand control-point address analysis, and account for memory offsets when classifying patch accesses. SPIR-V tessellation handling now uses domain-specific factor counts and supports triangle and quad execution modes with validated partitioning and topology values.

Suggested reviewers: nmzik

Priority: Normal

Change: Bug fix

Merge Risk: Moderate · up to 68bef

Different tessellation patch sizes can reuse a shader with the wrong interface, and some valid bit-field instructions can produce incorrect address analysis. Fix both before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. 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 support needed to run Gran Turismo 7 patches.
Description check Passed The description directly explains the tessellation changes, their purpose for Gran Turismo 7, related pull requests, and testing performed.
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.
  • Autofix · 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-26 19:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1919#issuecomment-6425453970) <!-- coderabbit-ai-generated:v1 --> <!-- 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/1919?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 --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> The changes select tessellation fields for shader-stage keys, expand control-point address analysis, and account for memory offsets when classifying patch accesses. SPIR-V tessellation handling now uses domain-specific factor counts and supports triangle and quad execution modes with validated partitioning and topology values. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <strong>Priority: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/priority-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Normal</strong> <!-- change_assessment_commit:"68befc66da4f424af51adff774a4b36d8afeda0e" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Moderate</strong> · up to <code>68bef</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `68bef` --> <!-- final_review_risk_coverage:{"sourceCommitId":"68befc66da4f424af51adff774a4b36d8afeda0e","coveredCommitId":"68befc66da4f424af51adff774a4b36d8afeda0e","kind":"reviewed"} --> Different tessellation patch sizes can reuse a shader with the wrong interface, and some valid bit-field instructions can produce incorrect address analysis. Fix both before merging. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></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 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. | 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 support needed to run Gran Turismo 7 patches. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the tessellation changes, their purpose for Gran Turismo 7, related pull requests, and testing performed. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </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">Autofix</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=1919)! 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 -->
@ -156,2 +208,2 @@
if (rhs.constant == 0u && third.constant == 8u) value = constant(0u);
}
if (is_constant(rhs) && is_constant(third))
value = extract(lhs, rhs.constant, third.constant);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 19:33 UTC · original

Minor · Functional Correctness · Quick win

Mask V_BFE_U32 operands before address analysis.

V_BFE_U32 uses only the low five bits of its offset and width operands. A width of 32 therefore produces zero, but extract(lhs, 0, 32) can retain the control-point index. An offset of 40 means offset 8, but extract returns zero. Either case can produce an incorrect stride or patch-access classification. Pass rhs.constant & 31u and third.constant & 31u to extract. (gpuopen.com)

Proposed correction
-						value = extract(lhs, rhs.constant, third.constant);
+						value = extract(lhs, rhs.constant & 31u, third.constant & 31u);
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.

					if (is_constant(rhs) && is_constant(third))
						value = extract(lhs, rhs.constant & 31u, third.constant & 31u);
**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 19:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1919#discussion_r4381603017) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** **Mask `V_BFE_U32` operands before address analysis.** `V_BFE_U32` uses only the low five bits of its offset and width operands. A width of `32` therefore produces zero, but `extract(lhs, 0, 32)` can retain the control-point index. An offset of `40` means offset `8`, but `extract` returns zero. Either case can produce an incorrect stride or patch-access classification. Pass `rhs.constant & 31u` and `third.constant & 31u` to `extract`. ([gpuopen.com](https://gpuopen.com/download/AMD_GCN3_Instruction_Set_Architecture_rev1.1.pdf)) <details> <summary>Proposed correction</summary> <dl> <dd> ```diff - value = extract(lhs, rhs.constant, third.constant); + value = extract(lhs, rhs.constant & 31u, third.constant & 31u); ``` </dd> </dl> </details> <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> > ‼️ **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 if (is_constant(rhs) && is_constant(third)) value = extract(lhs, rhs.constant & 31u, third.constant & 31u); ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:f883cf070c5c263171ebc731 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -453,0 +464,4 @@
tess.patch_size, tess.domain, tess.partitioning,
tess.output_topology});
break;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 19:33 UTC · original

Major · Functional Correctness · Quick win

🔎 Supported by static analysis

Script executed:

sed -n '415,490p' src/graphics/shader/shader.cpp
rg -n 'ls_stride|hs_stride|output_control_points|partitioning|output_topology|patch_base|patch_size|tessellation_domain' src/graphics/shader/recompiler src/graphics/shader/shader.cpp

Repository: KytyPS5/KytyPS5

Length of output: 8592


Script executed:

set -o pipefail
printf '%s\n' '--- BuildStageStaticKey callers and shader cache key flow ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'BuildStageStaticKey' -e 'BuildStageDynamicKey' -e 'StaticKey' -e 'logical_stage' src/graphics/shader | head -240
printf '%s\n' '--- Tessellation emitter complete relevant blocks ---'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | sed -n '1,185p'
printf '%s\n' '--- Tessellation analysis and translation call sites ---'
nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '1,180p'
nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '230,290p'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'EmitTessellation' -e 'tessellation' -e 'ShaderType::Local' -e 'ShaderType::TessellationEvaluation' src/graphics/shader/recompiler src/graphics/shader | head -300

Repository: KytyPS5/KytyPS5

Length of output: 36594


Script executed:

set -o pipefail
printf '%s\n' '--- key callers ---'
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' -e 'BuildStageStaticKey' -e 'logical_stage' src/graphics/shader | head -240
printf '%s\n' '--- emitter ---'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | sed -n '1,180p'
printf '%s\n' '--- analysis ---'
nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '1,180p'
nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '230,290p'

Repository: KytyPS5/KytyPS5

Length of output: 24507


Script executed:

set -o pipefail
printf '%s\n' '--- all static-key references and cache assembly ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'BuildStageStaticKey' -e 'BuildShaderKey' -e 'ShaderCache' -e 'static_key' -e 'static_key' src | head -400
printf '%s\n' '--- tessellation input/output initialization ---'
nl -ba src/graphics/shader/shader.cpp | sed -n '620,700p'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'input_control_points =' -e 'input_control_points' src/graphics/shader | head -300
printf '%s\n' '--- compiler interfaces around cache/key generation ---'
nl -ba src/graphics/shader/shaderCompiler.h | sed -n '1,180p'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'ShaderVertexInputInfo' -e 'ShaderPixelInputInfo' src | head -300

Repository: KytyPS5/KytyPS5

Length of output: 18779


Script executed:

set -o pipefail
nl -ba src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp | sed -n '330,430p'
nl -ba src/graphics/host_gpu/renderer/pipeline/pipelineCache.h | sed -n '1,190p'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'lookup_key' -e 'static_state' -e 'shader_hash' -e 'hash' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp src/graphics/host_gpu/renderer/pipeline/pipelineCache.h | head -300

Repository: KytyPS5/KytyPS5

Length of output: 19095


Include input_control_points in the Local program key.

PipelineCache::GetProgram keys the stage program by stage, params.hash, user_data_count, and static_state. For a Local shader, static_state stores only the nonzero flag and ls_stride. The translated ControlInput interface uses the actual tess.input_control_points value. Different patch counts can therefore reuse the same cached Local program.

Suggested fix
-			case ShaderType::Local: key.push_back(tess.ls_stride); break;
+			case ShaderType::Local:
+				key.insert(key.end(), {tess.input_control_points, tess.ls_stride});
+				break;
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.

	key.push_back(info.tess.input_control_points != 0 ? 1u : 0u);
	if (info.tess.input_control_points != 0) {
		// Only the tessellation fields a stage's translation reads: the LS writes its outputs at
		// ls_stride; the TES reads the HS outputs and sets the domain modes; the HS uses all.
		// A shared LS or TES paired with differently sized patches is then one program instead
		// of one per pairing, each translated and compiled again.
		const auto& tess = info.tess;
		switch (info.logical_stage) {
			case ShaderType::Local:
				key.insert(key.end(), {tess.input_control_points, tess.ls_stride});
				break;
			case ShaderType::TessellationEvaluation:
				key.insert(key.end(), {tess.output_control_points, tess.hs_stride, tess.patch_base,
				                       tess.patch_size, tess.domain, tess.partitioning,
				                       tess.output_topology});
				break;
			default:
				key.insert(key.end(), {tess.input_control_points, tess.output_control_points,
				                       tess.ls_stride, tess.hs_stride, tess.patch_base,
				                       tess.patch_size, tess.domain, tess.partitioning,
				                       tess.output_topology});
				break;
		}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 19:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1919#discussion_r4381603058) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Quick win** <details> <summary>🔎 Supported by static analysis</summary> <dl> <dd> Script executed: ```bash sed -n '415,490p' src/graphics/shader/shader.cpp rg -n 'ls_stride|hs_stride|output_control_points|partitioning|output_topology|patch_base|patch_size|tessellation_domain' src/graphics/shader/recompiler src/graphics/shader/shader.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 8592 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- BuildStageStaticKey callers and shader cache key flow ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'BuildStageStaticKey' -e 'BuildStageDynamicKey' -e 'StaticKey' -e 'logical_stage' src/graphics/shader | head -240 printf '%s\n' '--- Tessellation emitter complete relevant blocks ---' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | sed -n '1,185p' printf '%s\n' '--- Tessellation analysis and translation call sites ---' nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '1,180p' nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '230,290p' rg -n -F --glob '*.{cpp,h,hpp}' -e 'EmitTessellation' -e 'tessellation' -e 'ShaderType::Local' -e 'ShaderType::TessellationEvaluation' src/graphics/shader/recompiler src/graphics/shader | head -300 ``` Repository: KytyPS5/KytyPS5 Length of output: 36594 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- key callers ---' rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' -e 'BuildStageStaticKey' -e 'logical_stage' src/graphics/shader | head -240 printf '%s\n' '--- emitter ---' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | sed -n '1,180p' printf '%s\n' '--- analysis ---' nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '1,180p' nl -ba src/graphics/shader/recompiler/Tessellation.cpp | sed -n '230,290p' ``` Repository: KytyPS5/KytyPS5 Length of output: 24507 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- all static-key references and cache assembly ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'BuildStageStaticKey' -e 'BuildShaderKey' -e 'ShaderCache' -e 'static_key' -e 'static_key' src | head -400 printf '%s\n' '--- tessellation input/output initialization ---' nl -ba src/graphics/shader/shader.cpp | sed -n '620,700p' rg -n -F --glob '*.{cpp,h,hpp}' -e 'input_control_points =' -e 'input_control_points' src/graphics/shader | head -300 printf '%s\n' '--- compiler interfaces around cache/key generation ---' nl -ba src/graphics/shader/shaderCompiler.h | sed -n '1,180p' rg -n -F --glob '*.{cpp,h,hpp}' -e 'ShaderVertexInputInfo' -e 'ShaderPixelInputInfo' src | head -300 ``` Repository: KytyPS5/KytyPS5 Length of output: 18779 --- Script executed: ```bash set -o pipefail nl -ba src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp | sed -n '330,430p' nl -ba src/graphics/host_gpu/renderer/pipeline/pipelineCache.h | sed -n '1,190p' rg -n -F --glob '*.{cpp,h,hpp}' -e 'lookup_key' -e 'static_state' -e 'shader_hash' -e 'hash' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp src/graphics/host_gpu/renderer/pipeline/pipelineCache.h | head -300 ``` Repository: KytyPS5/KytyPS5 Length of output: 19095 --- </dd> </dl> </details> **Include `input_control_points` in the Local program key.** `PipelineCache::GetProgram` keys the stage program by `stage`, `params.hash`, `user_data_count`, and `static_state`. For a Local shader, `static_state` stores only the nonzero flag and `ls_stride`. The translated `ControlInput` interface uses the actual `tess.input_control_points` value. Different patch counts can therefore reuse the same cached Local program. <details><summary>Suggested fix</summary> ```diff - case ShaderType::Local: key.push_back(tess.ls_stride); break; + case ShaderType::Local: + key.insert(key.end(), {tess.input_control_points, tess.ls_stride}); + break; ``` </details> <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> > ‼️ **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 key.push_back(info.tess.input_control_points != 0 ? 1u : 0u); if (info.tess.input_control_points != 0) { // Only the tessellation fields a stage's translation reads: the LS writes its outputs at // ls_stride; the TES reads the HS outputs and sets the domain modes; the HS uses all. // A shared LS or TES paired with differently sized patches is then one program instead // of one per pairing, each translated and compiled again. const auto& tess = info.tess; switch (info.logical_stage) { case ShaderType::Local: key.insert(key.end(), {tess.input_control_points, tess.ls_stride}); break; case ShaderType::TessellationEvaluation: key.insert(key.end(), {tess.output_control_points, tess.hs_stride, tess.patch_base, tess.patch_size, tess.domain, tess.partitioning, tess.output_topology}); break; default: key.insert(key.end(), {tess.input_control_points, tess.output_control_points, tess.ls_stride, tess.hs_stride, tess.patch_base, tess.patch_size, tess.domain, tess.partitioning, tess.output_topology}); break; } ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:f2d09056c0cfd9da4d070375 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

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

Actionable comments posted: 2


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f90a8b1589 and 68befc66da.

Files selected for processing: 3
  • src/graphics/shader/recompiler/Tessellation.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp
  • src/graphics/shader/shader.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 19:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1919#pullrequestreview-5657876650) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 2** --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/f90a8b1589d08ef48d933bd472d4ba864addaefb/.coderabbit.yaml>) - **Commit**: [f90a8b1](<https://github.com/KytyPS5/KytyPS5/commit/f90a8b1589d08ef48d933bd472d4ba864addaefb>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `1b09c3f6-b0e5-4fd6-9ea9-08e9d6b4a255` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between f90a8b1589d08ef48d933bd472d4ba864addaefb and 68befc66da4f424af51adff774a4b36d8afeda0e. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 3</summary> <dl> <dd> * `src/graphics/shader/recompiler/Tessellation.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp` * `src/graphics/shader/shader.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=0ee69ffb-bbd0-400c-9bf1-e83521c92aaf attempt=83cd96b6-e5b5-4f51-ae3c-c5aefb0291b1 batch=1/1 -->
This pull request has changes conflicting with the target branch.
  • src/graphics/shader/recompiler/Tessellation.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp
  • src/graphics/shader/shader.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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