UFC 5 in-game #883

Manually merged
github merged 18 commits from gh-pr/883/head into gh-pr/883/base 2026-11-26 09:35:59 +00:00
Owner

@⁠Nmzik on GitHub · 2026-09-28 02:41 UTC · original
KytyPS5:ufc-5-in-game → main · +3226 −2265 · 34 files · 18 commits · merged 2026-09-28 12:03 UTC

  1. Rework the CFG structurizer using goto elimination + bug fixes (no more hardcoded cfg)
  2. Fix players face rendering (sampler border colors)
  3. Fix LDS append/consume counters RDNA2 (atomics)
  4. Respect native FP32 mode in shader comparisons with float_mode
  5. Skip inactive pixel shaders.
  6. Clean up descriptor resource planning
  7. Small optimizations via existing refresh/evaluation work
    image

Huge change, requires extensive testing against main branch

The generated shaders seem to be smaller than before

**@⁠Nmzik** on GitHub · 2026-09-28 02:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883) `KytyPS5:ufc-5-in-game` → `main` · +3226 −2265 · 34 files · 18 commits · merged 2026-09-28 12:03 UTC 1. Rework the CFG structurizer using goto elimination + bug fixes (no more hardcoded cfg) 2. Fix players face rendering (sampler border colors) 5. Fix LDS append/consume counters RDNA2 (atomics) 6. Respect native FP32 mode in shader comparisons with float_mode 7. Skip inactive pixel shaders. 8. Clean up descriptor resource planning 9. Small optimizations via existing refresh/evaluation work <img width="1597" height="894" alt="image" src="https://github.com/user-attachments/assets/7d47526c-ec55-4fb9-af07-9ea48b609336" /> Huge change, requires extensive testing against main branch The generated shaders seem to be smaller than before
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:35:57 +00:00
github manually merged commit 86246ef7cc into gh-pr/883/base 2026-11-26 09:35:59 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-28 02:49 UTC · original · edited 2026-09-28 03:01 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The changes update sampler type specialization and border-color caching, color-output selection for draws, shader CFG structurization, descriptor and scalar-read tracking, FP32 denormal handling, and scalar-address and append/consume memory operations. The test suites add coverage for these paths and rename PM4-related test references.

Priority: ⬇️ Low

Change: Feature

Merge Risk: 🟡 Moderate · up to 4dd35

Several shader-compilation changes can cause incorrect rendering or compute results. Branches can go the wrong way in partially filled waves. Some loops can exit at the wrong point. Shaders with many samplers can be rejected. Pixel-shader buffer writes can be dropped. Address these issues before merging.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 4dd35

Resource binding and memory-access behavior change across the shader compiler and renderer. No security regression was confirmed, but the changed access paths warrant design-level validation.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Guest-provided shader instructions and descriptors can affect GPU resource selection and translated memory reads within the renderer. The evidence does not establish exposure beyond that graphics execution context.

Trust Boundaries and Controls

  • observed — The scalar-address load now calls the aligned dword loader directly rather than passing an active predicate to the generic loader. The examined scalar-load producer supplies a true predicate; page presence still gates the dword read.

Resilience and Maintainability Implications

  • inferred — Sampler-plan rejection before descriptor append and conditional append/consume updates limit partially applied resource state in the examined paths; this does not establish equivalent protection for every changed memory operation.

Hardening Proposals

  • proposed — Validate the maximum guest page index against the allocated DMA page table and exercise the new indirect-buffer vector path with boundary-crossing descriptors. This is a validation proposal, not a verified out-of-bounds access.
🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 4.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 165 functions across 29 files. (3 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title identifies the main goal of the changes: making UFC 5 playable in-game. It is concise and related to the changeset, although it does not describe the technical fixes.
Description check ✅ Passed The description lists the major changes, including CFG structurization, sampler border colors, LDS append/consume handling, FP32 comparisons, inactive pixel shaders, and descriptor planning.
Full details: Docstring Coverage

Explanation

Docstring coverage is 4.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 165 functions across 29 files. (3 skipped: 1 unsupported, 2 too large.)


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

❤️ Share

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

**@⁠coderabbitai[bot]** on GitHub · 2026-09-28 02:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883#issuecomment-5862386186) · edited 2026-09-28 03:01 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/883"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The changes update sampler type specialization and border-color caching, color-output selection for draws, shader CFG structurization, descriptor and scalar-read tracking, FP32 denormal handling, and scalar-address and append/consume memory operations. The test suites add coverage for these paths and rename PM4-related test references. </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"4dd35a42b3f34c64ea3745467a05f18f6d93731c" --> **Change:** Feature <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _🟡 Moderate_ · up to `4dd35` <!-- final_review_risk_coverage:{"sourceCommitId":"4dd35a42b3f34c64ea3745467a05f18f6d93731c","coveredCommitId":"4dd35a42b3f34c64ea3745467a05f18f6d93731c","kind":"reviewed"} --> Several shader-compilation changes can cause incorrect rendering or compute results. Branches can go the wrong way in partially filled waves. Some loops can exit at the wrong point. Shaders with many samplers can be rejected. Pixel-shader buffer writes can be dropped. Address these issues before merging. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🟡 Moderate_ · up to `4dd35` Resource binding and memory-access behavior change across the shader compiler and renderer. No security regression was confirmed, but the changed access paths warrant design-level validation. **Retained concerns** No architecture-level concerns identified. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — Guest-provided shader instructions and descriptors can affect GPU resource selection and translated memory reads within the renderer. The evidence does not establish exposure beyond that graphics execution context. **Trust Boundaries and Controls** - _observed_ — The scalar-address load now calls the aligned dword loader directly rather than passing an active predicate to the generic loader. The examined scalar-load producer supplies a true predicate; page presence still gates the dword read. **Resilience and Maintainability Implications** - _inferred_ — Sampler-plan rejection before descriptor append and conditional append/consume updates limit partially applied resource state in the examined paths; this does not establish equivalent protection for every changed memory operation. **Hardening Proposals** - _proposed_ — Validate the maximum guest page index against the allocated DMA page table and exercise the new indirect-buffer vector path with boundary-crossing descriptors. This is a validation proposal, not a verified out-of-bounds access. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❓ 1</summary> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :----------------: | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ❓ Inconclusive | Docstring coverage is 4.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 165 functions across 29 files. (3 skipped:… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Title check | ✅ Passed | The title identifies the main goal of the changes: making UFC 5 playable in-game. It is concise and related to the changeset, although it does not describe the technical fixes. | | Description check | ✅ Passed | The description lists the major changes, including CFG structurization, sampler border colors, LDS append/consume handling, FP32 comparisons, inactive pixel shaders, and descriptor planning. | </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 4.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 165 functions across 29 files. (3 skipped: 1 unsupported, 2 too large.) </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=883)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -885,0 +889,4 @@
const auto color_output_mask = DrawColorOutputMask(buffer.GetRegisters());
state.ps_active = buffer.GetShaders().GetPs().ps_regs.data_addr != 0 &&
(color_output_mask != 0 ||
PixelShaderHasDepthOrCoverageSideEffects(shader_regs));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-28 02:49 UTC · original

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Keep pixel shaders with buffer writes active.

If a pixel shader writes to a buffer but has no active color output or depth/coverage flag, this condition sets state.ps_active to false. ExecutePreparedDraw then omits the pixel-shader bindings and its buffer-write path, so the draw loses those writes. Include pixel-shader buffer writes in the activity decision.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-28 02:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883#discussion_r4118147975) _🎯 Functional Correctness_ | _🟠 Major_ | _🏗️ Heavy lift_ **Keep pixel shaders with buffer writes active.** If a pixel shader writes to a buffer but has no active color output or depth/coverage flag, this condition sets `state.ps_active` to false. `ExecutePreparedDraw` then omits the pixel-shader bindings and its buffer-write path, so the draw loses those writes. Include pixel-shader buffer writes in the activity decision. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:cd387296fcd84cf8bc3d83db --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -639,0 +655,4 @@
TypeU32(ctx.state), combined, low, high);
ctx.state.builder.AddFunction(zero ? spv::OpIEqual : spv::OpINotEqual,
TypeBool(ctx.state), result, combined,
ConstantU32(ctx.state, zero ? ~0u : 0u));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-28 02:49 UTC · original

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -nP '\blane_count\s*=' src/graphics/shader/recompiler -C4
rg -nP 'host_subgroup_size' src/graphics -C3

Repository: KytyPS5/KytyPS5

Length of output: 21343


Ignore inactive lanes in zero-condition reduction.

For zero conditions, ballot the positive predicate (x), reduce the ballot words with OpBitwiseOr, and compare the result with 0u. OpGroupNonUniformBallot leaves inactive invocation bits clear, so the current OpBitwiseAnd/~0u reduction can reject ExecZero, VccZero, or SccZero when a partial wave is present. This can select the nonzero branch incorrectly.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-28 02:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883#discussion_r4118147976) _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash rg -nP '\blane_count\s*=' src/graphics/shader/recompiler -C4 rg -nP 'host_subgroup_size' src/graphics -C3 ``` Repository: KytyPS5/KytyPS5 Length of output: 21343 --- </details> **Ignore inactive lanes in zero-condition reduction.** For zero conditions, ballot the positive predicate (`x`), reduce the ballot words with `OpBitwiseOr`, and compare the result with `0u`. `OpGroupNonUniformBallot` leaves inactive invocation bits clear, so the current `OpBitwiseAnd`/`~0u` reduction can reject `ExecZero`, `VccZero`, or `SccZero` when a partial wave is present. This can select the nonzero branch incorrectly. <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a6d20dd9f0c5511b5a01310e --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -1882,0 +1216,4 @@
if (std::ranges::any_of(loop->children, [](auto* child) { return child->kind == Kind::Break; })) {
Fail("goto lifting would capture an enclosing loop exit");
return node;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-28 02:49 UTC · original

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Check for Break nodes at every depth before lifting a goto into a new Loop.

The guard at Line 1300 checks only the direct children of the new Loop. Break nodes can also sit inside nested If nodes:

  • The final splice in Eliminate (Lines 1331-1335) moves siblings, including Break nodes, into a selection If.
  • The splice in Inward (Lines 1273-1277) moves siblings into a rest If.

Visit passes break_block through If nodes (Line 1454). If a spliced range contains an If with a nested Break, that Break now targets the merge of the new lifted Loop, not the merge of the enclosing loop. The shader then keeps running the enclosing loop where the guest code exits it. The final RecomputeAnalyses/irreducibility check does not catch this, because the result is still a reducible CFG.

Search the spliced subtree recursively. Stop at nested Loop nodes, because their Break nodes target their own merge.

🐛 Proposed fix
+	static bool ContainsOuterBreak(const Node* node) {
+		for (const auto* child: node->children) {
+			if (child->kind == Kind::Break) return true;
+			if (child->kind != Kind::Loop && ContainsOuterBreak(child)) return true;
+		}
+		return false;
+	}
 	Node* Lift(Node* node) {
@@
-		if (std::ranges::any_of(loop->children, [](auto* child) { return child->kind == Kind::Break; })) {
+		if (ContainsOuterBreak(loop)) {
 			Fail("goto lifting would capture an enclosing loop exit");
 			return node;
 		}
**@⁠coderabbitai[bot]** on GitHub · 2026-09-28 02:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883#discussion_r4118147983) _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_ **Check for `Break` nodes at every depth before lifting a goto into a new `Loop`.** The guard at Line 1300 checks only the direct children of the new `Loop`. `Break` nodes can also sit inside nested `If` nodes: - The final splice in `Eliminate` (Lines 1331-1335) moves siblings, including `Break` nodes, into a selection `If`. - The splice in `Inward` (Lines 1273-1277) moves siblings into a rest `If`. `Visit` passes `break_block` through `If` nodes (Line 1454). If a spliced range contains an `If` with a nested `Break`, that `Break` now targets the merge of the new lifted `Loop`, not the merge of the enclosing loop. The shader then keeps running the enclosing loop where the guest code exits it. The final `RecomputeAnalyses`/irreducibility check does not catch this, because the result is still a reducible CFG. Search the spliced subtree recursively. Stop at nested `Loop` nodes, because their `Break` nodes target their own merge. <details> <summary>🐛 Proposed fix</summary> ```diff + static bool ContainsOuterBreak(const Node* node) { + for (const auto* child: node->children) { + if (child->kind == Kind::Break) return true; + if (child->kind != Kind::Loop && ContainsOuterBreak(child)) return true; + } + return false; + } Node* Lift(Node* node) { @@ - if (std::ranges::any_of(loop->children, [](auto* child) { return child->kind == Kind::Break; })) { + if (ContainsOuterBreak(loop)) { Fail("goto lifting would capture an enclosing loop exit"); return node; } ``` </details> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:b26948dcf65f616085fb2054 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -633,0 +629,4 @@
for (uint32_t type = 0; type < mapping.size(); type++) {
if ((classes & (1u << type)) == 0u) continue;
const auto target = first ? index : plan.sampler_count++;
if (target >= ShaderInfo::MaxSamplers) return false;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-28 02:49 UTC · original

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Avoid rejecting valid shaders when sampler classes exceed the binding limit.

If a shader uses 32 distinct samplers and one sampler serves both a float and an unsigned image, this split requests 33 bindings. BuildSamplerPlan then fails, so resource materialization rejects the shader. Resource tracking permits 32 distinct samplers and records these image–sampler pairs. Avoid allocating a separate typed-border binding when the sampler does not use border clamping, or provide another layout that preserves this valid case. (raw.githubusercontent.com)

**@⁠coderabbitai[bot]** on GitHub · 2026-09-28 02:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883#discussion_r4118147993) _🎯 Functional Correctness_ | _🟠 Major_ | _🏗️ Heavy lift_ **Avoid rejecting valid shaders when sampler classes exceed the binding limit.** If a shader uses 32 distinct samplers and one sampler serves both a float and an unsigned image, this split requests 33 bindings. `BuildSamplerPlan` then fails, so resource materialization rejects the shader. Resource tracking permits 32 distinct samplers and records these image–sampler pairs. Avoid allocating a separate typed-border binding when the sampler does not use border clamping, or provide another layout that preserves this valid case. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/ufc-5-in-game/src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp)) <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a3d101116179284974462156 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -637,0 +677,4 @@
}
}
}
ir.value_storage.clear();
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-28 02:49 UTC · original

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Find consumers of srt_reads and places that use a compiled Program after CompileProgram.
rg -nP -C3 '\bsrt_reads\b' --type=cpp src
rg -nP -C4 '\bCompileProgram\s*\(' --type=cpp src
rg -nP -C3 'ExtractResourcePlan\s*\(|SrtWalker\s*\(' --type=cpp src

Repository: KytyPS5/KytyPS5

Length of output: 18257


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- ShaderIR Value and Program declarations ---'
rg -n -C6 'class Value|struct Value|class Inst|struct Inst|struct Program|struct CompileResult|struct TranslateResult|value_storage|srt_reads' src/graphics/shader/recompiler/ir/ShaderIR.h src/graphics/shader/recompiler/ShaderRecompiler.h
printf '%s\n' '--- ResourceTracking PlanScalarReads ---'
sed -n '420,525p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
printf '%s\n' '--- CompileProgram cleanup and result construction ---'
sed -n '620,735p' src/graphics/shader/recompiler/ShaderRecompiler.cpp
printf '%s\n' '--- Resource plan extraction ---'
sed -n '850,935p' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
printf '%s\n' '--- pipeline cache compile/extraction order ---'
sed -n '210,270p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
sed -n '330,375p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 21802


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- ResourceTracking storage transfer ---'
sed -n '520,590p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
printf '%s\n' '--- Compiled program conversion ---'
rg -n -C8 'TakeCompiledInfo' src/graphics/shader/recompiler

Repository: KytyPS5/KytyPS5

Length of output: 5840


Clear srt_reads when clearing value_storage.

PlanScalarReads moves each retained read into value_storage and stores Value(read) in srt_reads. CompileProgram then destroys value_storage but leaves those references in the returned CompileResult.program. A caller that passes this program to ExtractResourcePlan can dereference destroyed instructions.

The current pipeline extracts the resource plan before compilation and later calls TakeCompiledInfo, but the returned Program still contains dangling references.

Suggested fix
 	ir.value_storage.clear();
+	ir.srt_reads.clear();
📝 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.

	// The resource plan owns host descriptor evaluation now. Keep only dependencies consumed
	// by GPU memory operations; bound descriptor dwords must not retain shader instructions.
	for (auto& inst: ir.value_storage) {
		inst.Invalidate();
	}
	for (auto* block: ir.blocks) {
		for (auto& inst: *block) {
			const auto op = inst.GetOpcode();
			uint32_t first = 0;
			if (op == IR::ValueOpcode::GetBufferResource) {
				if (std::ranges::any_of(inst.Uses(), [&](const IR::Use& use) {
					return ir.memory_info[use.user->Flags<IR::MemoryFlags>().index].kind ==
					       IR::ResourceKind::IndirectBuffer;
				})) {
					continue;
				}
			} else if (op == IR::ValueOpcode::GetImageResource) {
				const auto resource = inst.Flags<uint32_t>();
				first = resource < ir.info.images.size() &&
				                ir.info.images[resource].indirect_root == resource ? 1u : 0u;
			} else if (op != IR::ValueOpcode::GetSamplerResource) {
				continue;
			}
			for (size_t index = first; index < inst.NumArgs(); index++) {
				inst.SetArg(index, IR::Value(0u));
			}
		}
	}
	ir.value_storage.clear();
	ir.srt_reads.clear();
**@⁠coderabbitai[bot]** on GitHub · 2026-09-28 02:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883#discussion_r4118147995) _🩺 Stability & Availability_ | _🟡 Minor_ | _⚡ Quick win_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash # Find consumers of srt_reads and places that use a compiled Program after CompileProgram. rg -nP -C3 '\bsrt_reads\b' --type=cpp src rg -nP -C4 '\bCompileProgram\s*\(' --type=cpp src rg -nP -C3 'ExtractResourcePlan\s*\(|SrtWalker\s*\(' --type=cpp src ``` Repository: KytyPS5/KytyPS5 Length of output: 18257 --- 🏁 Script executed: ```bash #!/bin/bash set -e printf '%s\n' '--- ShaderIR Value and Program declarations ---' rg -n -C6 'class Value|struct Value|class Inst|struct Inst|struct Program|struct CompileResult|struct TranslateResult|value_storage|srt_reads' src/graphics/shader/recompiler/ir/ShaderIR.h src/graphics/shader/recompiler/ShaderRecompiler.h printf '%s\n' '--- ResourceTracking PlanScalarReads ---' sed -n '420,525p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp printf '%s\n' '--- CompileProgram cleanup and result construction ---' sed -n '620,735p' src/graphics/shader/recompiler/ShaderRecompiler.cpp printf '%s\n' '--- Resource plan extraction ---' sed -n '850,935p' src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp printf '%s\n' '--- pipeline cache compile/extraction order ---' sed -n '210,270p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp sed -n '330,375p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 21802 --- 🏁 Script executed: ```bash #!/bin/bash set -e printf '%s\n' '--- ResourceTracking storage transfer ---' sed -n '520,590p' src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp printf '%s\n' '--- Compiled program conversion ---' rg -n -C8 'TakeCompiledInfo' src/graphics/shader/recompiler ``` Repository: KytyPS5/KytyPS5 Length of output: 5840 --- </details> **Clear `srt_reads` when clearing `value_storage`.** `PlanScalarReads` moves each retained read into `value_storage` and stores `Value(read)` in `srt_reads`. `CompileProgram` then destroys `value_storage` but leaves those references in the returned `CompileResult.program`. A caller that passes this program to `ExtractResourcePlan` can dereference destroyed instructions. The current pipeline extracts the resource plan before compilation and later calls `TakeCompiledInfo`, but the returned `Program` still contains dangling references. <details> <summary>Suggested fix</summary> ```diff ir.value_storage.clear(); + ir.srt_reads.clear(); ``` </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 // The resource plan owns host descriptor evaluation now. Keep only dependencies consumed // by GPU memory operations; bound descriptor dwords must not retain shader instructions. for (auto& inst: ir.value_storage) { inst.Invalidate(); } for (auto* block: ir.blocks) { for (auto& inst: *block) { const auto op = inst.GetOpcode(); uint32_t first = 0; if (op == IR::ValueOpcode::GetBufferResource) { if (std::ranges::any_of(inst.Uses(), [&](const IR::Use& use) { return ir.memory_info[use.user->Flags<IR::MemoryFlags>().index].kind == IR::ResourceKind::IndirectBuffer; })) { continue; } } else if (op == IR::ValueOpcode::GetImageResource) { const auto resource = inst.Flags<uint32_t>(); first = resource < ir.info.images.size() && ir.info.images[resource].indirect_root == resource ? 1u : 0u; } else if (op != IR::ValueOpcode::GetSamplerResource) { continue; } for (size_t index = first; index < inst.NumArgs(); index++) { inst.SetArg(index, IR::Value(0u)); } } } ir.value_storage.clear(); ir.srt_reads.clear(); ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:f9265dd7a8620a3270e3b7a8 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-28 02:49 UTC · original · reviewed

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 4d6868db-fe38-4b48-9318-fac7298cb2d4

📥 Commits

Reviewing files that changed from the base of the PR and between 421684e75f and 4dd35a42b3.

📒 Files selected for processing (33)
  • src/graphics/host_gpu/renderer/cache/samplerCache.cpp
  • src/graphics/host_gpu/renderer/cache/samplerCache.h
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • src/graphics/shader/recompiler/ShaderRecompiler.cpp
  • src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterAluHelpers.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp
  • src/graphics/shader/recompiler/frontend/cfg/ShaderCFG.cpp
  • src/graphics/shader/recompiler/frontend/cfg/ShaderCFG.h
  • src/graphics/shader/recompiler/frontend/translate/Compare.cpp
  • src/graphics/shader/recompiler/frontend/translate/Memory.cpp
  • src/graphics/shader/recompiler/frontend/translate/Translate.cpp
  • src/graphics/shader/recompiler/frontend/translate/Translator.h
  • src/graphics/shader/recompiler/ir/Program.cpp
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.h
  • src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.inc
  • src/graphics/shader/recompiler/ir/passes/BindingLayout.cpp
  • src/graphics/shader/recompiler/ir/passes/BindingLayout.h
  • src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.h
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.h
  • tests/ResourceTrackingTests.cpp
  • tests/ScalarProvenanceTests.cpp
  • tests/ShaderRecompilerComputeTests.cpp
  • tests/shaderCfgTests.cpp
💤 Files with no reviewable changes (1)
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.h

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-09-28 02:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883#pullrequestreview-5333494835) · **reviewed** **Actionable comments posted: 5** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `4d6868db-fe38-4b48-9318-fac7298cb2d4` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 421684e75f75e6d1a2c4b0817ca573a2e800f748 and 4dd35a42b3f34c64ea3745467a05f18f6d93731c. </details> <details> <summary>📒 Files selected for processing (33)</summary> * `src/graphics/host_gpu/renderer/cache/samplerCache.cpp` * `src/graphics/host_gpu/renderer/cache/samplerCache.h` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `src/graphics/shader/recompiler/ShaderRecompiler.cpp` * `src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterAluHelpers.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp` * `src/graphics/shader/recompiler/frontend/cfg/ShaderCFG.cpp` * `src/graphics/shader/recompiler/frontend/cfg/ShaderCFG.h` * `src/graphics/shader/recompiler/frontend/translate/Compare.cpp` * `src/graphics/shader/recompiler/frontend/translate/Memory.cpp` * `src/graphics/shader/recompiler/frontend/translate/Translate.cpp` * `src/graphics/shader/recompiler/frontend/translate/Translator.h` * `src/graphics/shader/recompiler/ir/Program.cpp` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.h` * `src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.inc` * `src/graphics/shader/recompiler/ir/passes/BindingLayout.cpp` * `src/graphics/shader/recompiler/ir/passes/BindingLayout.h` * `src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.h` * `src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp` * `src/graphics/shader/recompiler/ir/passes/SrtWalker.h` * `tests/ResourceTrackingTests.cpp` * `tests/ScalarProvenanceTests.cpp` * `tests/ShaderRecompilerComputeTests.cpp` * `tests/shaderCfgTests.cpp` </details> <details> <summary>💤 Files with no reviewable changes (1)</summary> * src/graphics/shader/recompiler/ir/passes/SrtWalker.h </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 -->
Author
Owner

@⁠cergo666 on GitHub · 2026-10-08 15:22 UTC · original

Снимок экрана 2026-10-08 174048 It turns out there is still room for improvement.

It’s a shame I’m not a programmer, as this is purely the work of AI.
I hope more experienced specialists show up here and do a proper job of it.

**@⁠cergo666** on GitHub · 2026-10-08 15:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883#issuecomment-6063159965) <img width="2555" height="1383" alt="Снимок экрана 2026-10-08 174048" src="https://github.com/user-attachments/assets/dbef2a2b-0bdd-4a36-87b3-7d025f29fb32" /> It turns out there is still room for improvement. It’s a shame I’m not a programmer, as this is purely the work of AI. I hope more experienced specialists show up here and do a proper job of it.
Author
Owner

@⁠hugosmoreira on GitHub · 2026-10-11 20:04 UTC · original

Hi @⁠Nmzik — could you confirm the setup behind the successful UFC 5 (PPSA03541) gameplay test shown in this PR? I'm checking compatibility before purchasing a console and game.

  • Which UFC 5 game/update version (contentVersion) did you use?
  • Which PS5 system firmware was used to create the dump, and what requiredSystemSoftwareVersion does that game's sce_sys/param.json report, if available?
  • Was it an unmodified decrypted dump, or did it include a backport or other changes to the executable/modules?

Thanks — this would help distinguish the successful setup from the other reports testing version 01.031.000.

**@⁠hugosmoreira** on GitHub · 2026-10-11 20:04 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/883#issuecomment-6113165100) Hi @⁠Nmzik — could you confirm the setup behind the successful UFC 5 (PPSA03541) gameplay test shown in this PR? I'm checking compatibility before purchasing a console and game. - Which UFC 5 game/update version (`contentVersion`) did you use? - Which PS5 system firmware was used to create the dump, and what `requiredSystemSoftwareVersion` does that game's `sce_sys/param.json` report, if available? - Was it an unmodified decrypted dump, or did it include a backport or other changes to the executable/modules? Thanks — this would help distinguish the successful setup from the other reports testing version 01.031.000.
This discussion has been locked. Commenting is limited to contributors.
No description provided.