shader: handle address-backed indirect image descriptors #811
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!811
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/811/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tototomate123 on GitHub · 2026-09-24 19:24 UTC · original
tototomate123:fix/hfw-image-descriptor-specialization→main· +794 −324 · 4 files · 2 commits · closed without mergingAn indirect image descriptor pattern in an Horizon Forbidden West shader previously stopped shader compilation. A manual game run with this branch got past that first failure and compiled additional shaders. The run later stopped while refreshing resources for a cached shader. This PR does not fix that later failure.
The diff includes spacing, alignment, and line-wrap changes outside the new shader logic. The repositorys pre commit hook runs clang-format v22.1.3 on whole touched source files, and some existing lines on
maindiffer from its current output.Summary
Validation
cmake --build _Build/linux --target resource_tracking_tests resource_materialization_tests kyty_emulator -j 4passed.ctest --test-dir _Build/linux --output-on-failure -R '^(resource_tracking|resource_materialization)$'passed (2 tests).clang-formatpre-commit hook passedAI assistance
AI assistance was used to investigate and partially implement this shader change.
@coderabbitai[bot] on GitHub · 2026-09-24 19:39 UTC · original · edited 2026-09-27 16:32 UTC
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
📝 Walkthrough
Walkthrough
Indirect-image tracking recognizes uniform loop-index selectors and keys read from buffer records. Materialization supports scalar material descriptors and buffer descriptors, enumerates wrapped offsets, and validates descriptor reads and protected buffers. Tests cover address-backed selectors, buffer-record keys, flattened mappings, rejected formatted loads, and buffer alias rejection.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Feature
Merge Risk: ⚪ Minimal · up to
5a0f6The previously identified shader-compilation stall paths are addressed. The remaining suggestion does not block merging.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
5a0f6The new descriptor path has bounds, validation, and failure checks, and no security bypass was established. Risk remains because the path reads mutable guest memory while refreshing cached shader resources, and its behavior has not been validated on Windows.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-09-24 19:39 UTC · original
On
src/graphics/shader/recompiler/ir/passes/ResourceTracking.cppline 448 (outdated):🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Add a depth limit to
IsUniformLoopIndex, and skip operands that were already checked.IsUniformLoopIndexvisits each operand again for every path that reaches it. Theactivelist stops endless cycles through a Phi. It does not stop repeated visits to shared operands. For a chain such asx1 = x0 + x0,x2 = x1 + x1, the number of visits doubles at each step (2^n). The function also has no depth limit, so a long scalar chain can use up the stack during resource tracking.MatchAffineOffsetstops at depth 16, but this function has no such limit.MatchMaterialOffsetcalls this function on the fallback path for every indirect image, so one bad shader can stall or crash shader compilation.Record operands that already passed, and add a depth limit.
♻️ Proposed fix
A skipped operand has already set
saw_looporsaw_leafin an earlier visit. For this reason, the finalsaw_loop && saw_leafcheck does not change.📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-09-24 19:39 UTC · original · reviewed
Actionable comments posted: 1
🧹 Nitpick comments (1)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
f26b3803-a3db-4a57-bb28-51dcb788f869📥 Commits
Reviewing files that changed from the base of the PR and between
83628a436eand 50698e2e808230feeb76c3477ee532b1f1442df5.📒 Files selected for processing (4)
src/graphics/shader/recompiler/ir/ShaderIR.hsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cppsrc/graphics/shader/recompiler/ir/passes/ResourceTracking.cpptests/ResourceTrackingTests.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@tototomate123 on GitHub · 2026-09-24 20:32 UTC · original · edited 2026-09-24 20:36 UTC
The Linux build completed successfully, but CI failed during
virtual_memory_allocation: SmallFiberStacksAndMigration reported a write outside its supplied stack. This PR changes shader resource tracking and tests, not the fiber code.Recent runs on main also fail
virtual_memory_allocationin SmallFiberStacksAndMigration with the same stack error.The fiber failure was reproduced with Ubuntu 24.04 and Clang 18 locally, and i added a focused fix on the separate fix/linux-small-fiber-stack branch. I'd appreciate review of the shader change while the fiber failure is handled separately.
@coderabbitai[bot] on GitHub · 2026-09-24 20:37 UTC · original
On
src/graphics/shader/recompiler/ir/passes/ResourceTracking.cppline 453 (outdated):🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Stop checking operands after the first failure in
IsUniformLoopIndex.The earlier fix added
accepted, so operands that pass are checked only once. Operands that fail are still checked again on every path that reaches them.Line 452 writes the check as
IsUniformLoopIndex(...) && valid. Because the call comes first, it always runs, even aftervalidis already false. The function also never records instructions that failed.Example: take a chain like
x1 = x0 + x0,x2 = x1 + x1, wherex0fails the check (for example, aReadFirstLaneoperand or an unsupported opcode). Each level visits both operands, so the number of visits doubles per level. Theactive.size() > 32ulimit allows about 2^33 visits.MatchMaterialOffsetcalls this function on the fallback path for every indirect image selector that is not a directReadFirstLane. One such shader can therefore stall shader compilation.Return as soon as one operand fails.
saw_loopandsaw_leafonly matter when the whole check returns true, so stopping early does not change any accepted result.🐛 Proposed fix
@coderabbitai[bot] on GitHub · 2026-09-24 20:37 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:
f6877721-f075-4bd3-ad31-b3e4c2b8a932📥 Commits
Reviewing files that changed from the base of the PR and between 50698e2e808230feeb76c3477ee532b1f1442df5 and 9a88cec8b6d819c2b72a14758317b7ff56e86528.
📒 Files selected for processing (2)
src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpptests/ResourceTrackingTests.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@coderabbitai[bot] on GitHub · 2026-09-27 16:29 UTC · original · reviewed
🧹 Nitpick comments (1)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
8d5b6bdd-4871-429c-a295-2f26f74166d9📥 Commits
Reviewing files that changed from the base of the PR and between
2135a90bdband5a0f65f326.📒 Files selected for processing (2)
src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cppsrc/graphics/shader/recompiler/ir/passes/ResourceTracking.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Pull request closed