graphics: ignore depth load clears when detecting attachment feedback loops #943
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!943
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/943/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?
@joaodiaslobo on GitHub · 2026-09-30 12:04 UTC · original
joaodiaslobo:graphics/depth-feedback-load-clear→main· +7 −5 · 3 files · 1 commits · closed without mergingFixes the crash reported in #904. Demon's Souls does not boot on hosts without the attachment feedback loop extension.
The draw that fails samples the depth buffer while the depth attachment has a load clear pending. Feedback detection counts that clear as a write, so it looks like the shader is reading depth that the same draw is writing, and the emulator aborts. The game never writes depth in that draw. The clear comes from HTile metadata holding a fast clear that the emulator applies on load, and depth writes are disabled.
A load clear happens when rendering begins, before any fragment runs, so it cannot alias a sampled read the way a per-fragment write can. This change only counts per-fragment writes when deciding whether the extension is needed. Draws that genuinely write and sample the same aspect still abort as before.
Testing
Demon's Souls (PPSA01342) boots and plays normally. I do not have a GPU without the extension, so I tested by forcing the capability off, and confirmed a normal run with it enabled is unchanged. A check on the AMD card from the report would be useful.
@coderabbitai[bot] on GitHub · 2026-09-30 12:22 UTC · original · edited 2026-09-30 12:28 UTC
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
📝 Walkthrough
Walkthrough
AttachmentWriteAspectsnow accepts an option to exclude clear writes.AcquireRenderTargetschecks feedback aspects against depth and stencil aspects written per fragment before rejecting feedback when attachment-feedback-loop support is unavailable.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🔵 Low · up to
f67ccThe change avoids the reported unsupported-extension abort, but sampling outside covered samples can still race with attachment stores. Address this bounded rendering risk or explicitly accept it before merging.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
f67ccThe change preserves rejection of genuine per-fragment feedback writes. However, the safety of the newly allowed clear-only case has not been fully established when the required graphics extension is unavailable. The remaining risk is bounded to graphics execution; no privilege escalation or isolation breach was demonstrated.
Retained concerns
Security review details
Security Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
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.@ -535,1 +535,3 @@if (feedback_aspects && !m_context.GetGraphics().attachment_feedback_loop_enabled) {const auto per_fragment_writes = depth.AttachmentWriteAspects(false);if ((feedback_aspects & per_fragment_writes) &&!m_context.GetGraphics().attachment_feedback_loop_enabled) {@coderabbitai[bot] on GitHub · 2026-09-30 12:23 UTC · original · edited 2026-09-30 13:18 UTC
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8328
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 22916
🌐 Web query:
official Vulkan specification attachment feedback loop sampled depth stencil attachment load store covered samples non-covered samples💡 Result:
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 32025
🌐 Web query:
site:docs.vulkan.org/spec/latest/chapters/renderpass.html "Sampling From a Read-Only Attachment" "covered"💡 Result:
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7218
Account for load and store accesses in the feedback-loop guard.
AttachmentWriteAspects(false)excludes clear loads, whileBeginRenderinguseseClearwhen requested and always useseStore. Vulkan permits covered-sample reads from a read-only attachment witheStore, but non-covered sample reads can race with the store. The sampled-depth binding contract does not enforce covered-sample access.When feedback-loop support is disabled, include the effective load/store accesses in this guard, or prove that the shader reads only covered samples. Do not gate the decision only on per-fragment writes.
@coderabbitai[bot] on GitHub · 2026-09-30 12:23 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:
1324ff71-16e1-48ec-ba7b-e5884ac874b9📥 Commits
Reviewing files that changed from the base of the PR and between
05057c9441andf67cc8441f.📒 Files selected for processing (3)
src/graphics/host_gpu/renderer/depthRenderTarget.cppsrc/graphics/host_gpu/renderer/depthRenderTarget.hsrc/graphics/host_gpu/renderer/renderDraw.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@ -535,1 +535,3 @@if (feedback_aspects && !m_context.GetGraphics().attachment_feedback_loop_enabled) {const auto per_fragment_writes = depth.AttachmentWriteAspects(false);if ((feedback_aspects & per_fragment_writes) &&!m_context.GetGraphics().attachment_feedback_loop_enabled) {@joaodiaslobo on GitHub · 2026-09-30 13:18 UTC · original
The store op is always
eStorefor depth, so including it in the guard would make it fire on every draw that samples its own depth attachment and would bring the crash back.In this case nothing modifies the depth values,
depth_write_enableis 0 and the only load write is the HTile clear, so the store writes back what is read.@ -535,1 +535,3 @@if (feedback_aspects && !m_context.GetGraphics().attachment_feedback_loop_enabled) {const auto per_fragment_writes = depth.AttachmentWriteAspects(false);if ((feedback_aspects & per_fragment_writes) &&!m_context.GetGraphics().attachment_feedback_loop_enabled) {@coderabbitai[bot] on GitHub · 2026-09-30 13:19 UTC · original
🧩 Analysis chain
🤖 web_search executed:
In the official Vulkan specification section "Sampling From a Read-Only Attachment", do depth attachment STORE operations potentially race with shader sampling of non-covered samples even if depthWriteEnable is false and the stored depth values are unchanged? Quote the relevant normative text and load CLEAR ordering requirements. Is STORE_OP_NONE with LOAD_OP_CLEAR sufficient or must a clear be performed separately before rendering?Length of output: 2585
@joaodiaslobo, you are right that counting everyeStorein the abort guard would bring the crash back. My recommendation was too broad.However, unchanged depth values do not remove the Vulkan data-race concern. The specification states that
STOREmay write even when no recorded command writes the attachment. It guarantees safe fragment-shader reads for covered samples, but not for other samples or other shader stages.The concern therefore remains, but the remedy should not be a blanket abort. For sampled aspects with no per-fragment writes, a safe path is to materialize the HTile clear before rendering, synchronize that clear with shader reads, and use a non-writing load operation with
STORE_OP_NONEduring rendering.Thanks for clarifying the depth store behavior.
✏️ Learnings added
You are interacting with an AI system.
@Nmzik on GitHub · 2026-10-21 19:41 UTC · original
Superseded by
b89971790.Pull request closed