graphics: do not arm a fast clear from a read-modify-write dispatch #428
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!428
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/428/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?
@brandostrong on GitHub · 2026-08-31 19:35 UTC · original
brandostrong:fix/htile-rmw-not-a-clear→main· +109 −1 · 3 files · 2 commits · merged 2026-09-01 01:48 UTCProblem
TryConsumeComputeMetaCleardecides a compute dispatch is a metadata fast clear from coverage alone — it writes the whole metadata surface and contains noBitwiseXor32. It never checks that the dispatch is actually a fill.GTA V runs a dispatch over the whole HTILE surface that reads each dword and writes back
(d & 0xF) == 0 ? clear_word : d.d & 0xFis ZMASK, so it re-stamps only tiles that are already clear and preserves every tile that holds real depth. Treating it as a fast clear discards the dispatch and arms a full-surface depth clear, wiping g-buffer depth mid-frame — a pixel measured0.02722705before that pass and0.0after, so the distant sky plane (depth6e-8, reverse-ZGEQUAL) then passed in front of the world. Every depth test after that point is affected, not only the sky.A second dispatch on the same path is a genuine fill — four SGPRs stored with one
BUFFER_STORE_FORMAT_XYZW— and must keep arming.Change
Reject a dispatch that also reads the metadata surface it writes. A read-modify-write preserves existing contents by definition, so it cannot be a clear.
BufferResource::readis already tracked, so this is one condition.The DCC path already requires a validated fill value before treating a compute write as a clear; HTILE had no equivalent check.
Note the rejected dispatch now executes rather than being discarded.
AI assistance
Claude. It found the cause by disassembling the guest shader's recompiled SPIR-V and comparing it to emulator code, after we traced it by bisecting(enabling/disabling) the shaders to find the offending pass.