renderer: consume a compute dispatch as an HTile clear only when it writes exactly the live HTile range (Resident Evil Requiem device lost) #2502
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!2502
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2502"
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?
@taklaciwiz-maker on GitHub · 2026-11-21 21:06 UTC · original
taklaciwiz-maker:re-htile-meta-clear→main· +23 −1 · 3 files · 1 commits · openRefs #1929. Related to #1803.
Problem
Resident Evil Requiem (PPSA31246) loses the device a few seconds after "New Game"
(
masterSemaphore.cpp:54/vkQueueSubmit failed: ErrorDeviceLost). It does so on39936ff(current main)and also on
a21fd80.VK_NV_device_diagnostic_checkpointsnames the last dispatch every time: compute shader0x9f2abc22a7d31401.VK_EXT_device_faultreports onlyINSTRUCTION_POINTER_UNKNOWNaddresses.That points to a GPU timeout (TDR), not an invalid access.
Diagnosis
0x9f2abc22a7d31401and the same-family shaders0x845c937f706651aeand0xf6a62fe6cb77cd95arepersistent-thread, lock-free work queues:
count == 0,ticket >= Landparticipants == 0.GPU snapshots. I copied the first 4 KiB of every bound buffer into host-visible memory before each
dispatch of these shaders (temporary diagnostic, not in this PR). The queue buffer at
0x20009a0000looked like this:
In the bad frames the counters hold pixel-like data, with
participants ≈ 2·10⁹, so the exit conditionnever holds and the whole dispatch spins. The same garbage comes back for about 11 consecutive dispatches,
then the queue is fine again. The shader translation is correct; the input is not.
Address trace of
0x20009a0000(temporary diagnostic):0xe14ee3c14d5d49f5);0xdb8fe7867eaef1bc).0x2000800000: the game reuses this transient memory.Cause.
RenderExecutor::TryConsumeComputeMetaCleartreats any dispatch whose written buffer baseequals a registered HTile address as a metadata clear, and drops it.
0x20009a0000was the HTile base of a depth image that was still in the texture cache. The game hadalready reused that memory for the queue, and both the reset fill and the copy were dropped. About
11 frames later the garbage collector evicted the old depth image, the
m_surface_metasentry went away,and the queue worked again. That matches the snapshots.
Change (3 files, +23/-1)
TextureCache::MetaRangeSize(address)returns the HTile size registered ataddress. It returns itonly while the owning depth image is still registered and its HTile is still at that address;
otherwise it returns 0.
TryConsumeComputeMetaClearconsumes a written buffer as a metadata clear only when the descriptorsize equals that HTile size. Any other dispatch runs normally.
Results
The game now reaches gameplay and plays without the hang:
Metadata-clear decisions in one session (temporary log; 14,666 matches against a live HTile base):
0xdb8fe7867eaef1bc(fill)0xdb8fe7867eaef1bc(fill)0xdb8fe7867eaef1bc(fill)0x378063fc4a8d7b1b,0xf02daf961fa8a6880x5003cb4fd7ed3c220xe14ee3c14d5d49f5(copy)Relation to #1803
#1803 tightens the same classification: only metadata is written, writes stay within the metadata size,
reads are small, there is no storage image and no raw-address access. Its "Known limitations" section
lists the remaining gap: an entry survives memory reuse, so a constant fill that fits inside the surface
is still consumed as a clear.
The Requiem hang is exactly that case: a 0x810-byte constant fill into memory that still has a live
0x8000-byte HTile entry. As I read #1803's rules, it would still drop this reset, but I have not run
#1803 itself.
#1803 also measured that real clears in Octopath Traveler II and Astro Bot "bind a bounded descriptor
exactly the size of the HTILE surface". All the clears I see in Requiem match that too. If #1803 lands
first, the same fix there would be to require
size == metadata sizeinstead of<=inAddMetaClearTarget, and to ignore entries whose owning image is gone or whose HTile has moved.Caveats
(0x10000–0x48000). They may be clears of a smaller depth image that shares the HTile base, a case #1803
also mentions.
base.
did not see any in Requiem, and I can't test Octopath Traveler II or Astro Bot.
an address watch trace and a meta-clear log. I can share them if they are useful.
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-11-21 21:11 UTC · original
Walkthrough
TextureCache adds
MetaRangeSize(uint64_t address), which returns the size of a live metadata range at the requested address or zero when no valid owner matches.TryConsumeComputeMetaClearnow callsClearMetaonly when the returned range size is nonzero and exactly matches the descriptor size.Suggested reviewers:
nmzik,thecruzChange: Bug fix
Merge Risk:
Moderate · up to
38eefThe change stops a reset write that reuses HTile memory from being treated as a depth clear, which was causing the reported device loss in Resident Evil Requiem. Two edge cases remain. A reset write whose size exactly matches a live HTile could still be skipped. A genuine smaller depth clear could now be skipped, leaving stale depth contents. Both are narrow and unconfirmed, but they should be accepted or addressed before merge.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the main change: compute dispatches are consumed as HTile clears only when they write exactly the live HTile range. It also names the Resident Evil Requiem device-lost symptom. The raw summary confirms the change to TryConsumeComputeMetaClear, the new TextureCache::MetaRangeSize query, and the exact-size check. The title is specific and matches the changeset.
Full details: Description check
Explanation
The description is closely related to the changeset. It explains the Requiem device-lost problem, the diagnosis that TryConsumeComputeMetaClear drops a queue reset dispatch, and the fix that adds a live-HTile-size check in the three changed files. It also covers test results, caveats, and related PR
#1803.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
@ -79,0 +81,4 @@// queue that is then never reset hangs the GPU, a larger buffer is never filled).const auto base = descriptor.Base48();const auto meta_size = cache.MetaRangeSize(base);if (meta_size != 0 && descriptor.GetSize() == meta_size && cache.ClearMeta(base)) {@coderabbitai[bot] on GitHub · 2026-11-21 21:11 UTC · original
Keep the depth clear state when a smaller write is a genuine HTile clear.
When a write at a live HTile base does not match
meta_size,TryConsumeComputeMetaClearreturns without callingClearMeta.ClearMetais the only compute-path call that sets the HTile clear mask. A genuine clear of a smaller range therefore leaves the mask unset. The depth draw then skips the clear load and keeps the prior depth contents.Require that a genuine HTile clear of a smaller range still sets the owning depth image's clear state. Choose the mechanism that preserves this state, for example a narrower clear-detection rule that does not drop real clears. Confirm that the chosen mechanism does not reintroduce the reuse hazard the size check prevents.
Size equality does not establish that a write is an HTile clear.
When a game frees a depth image's HTile memory while the depth image stays registered, a later write-only buffer of exactly the HTile size at the same base can pass this guard. The guard then calls
ClearMeta, and the dispatch is consumed without running. A reset fill of this kind is then dropped, and the queue keeps its stale counters. That is the failure this change targets, and it still occurs for a same-size reuse.The check must establish that the write is a genuine HTile clear. Size alone is insufficient. Choose the proof, such as tracking the reuse or checking the clear provenance, before consuming the dispatch.
@coderabbitai[bot] on GitHub · 2026-11-21 21:11 UTC · original · reviewed
Actionable comments posted: 2
4d3f14f7-5bbc-4957-8c1c-d3f4cf4a9a18Reviewing files that changed from the base of the PR and between
39936ffa39and38eef9ff24.src/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/renderCompute.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.