renderer: materialize DCC clears before sampled access #440
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!440
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/440/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-09-01 16:14 UTC · original
brandostrong:fix/dcc-clear-before-sampling→main· +139 −63 · 5 files · 1 commits · closed without mergingThis is the whiteout/hdr fix that was affecting multiple games
Problem
A DCC fast clear is materialized only as a render-pass load-op, at the next time the surface is
bound as a colour render target. If the guest samples that surface as a texture before that
bind, the read returns the pre-clear contents.
I hit this in GTA V. An ordered, per-draw trace of one frame shows a full-screen blit sampling a
1280x720
B10G11R11transient at draw 101, while the surface's first render-target bind — and soits clear — is draw 103:
The surface is reused several times per frame, and at draw 101 it still held the previous frame's
bloom. The blit adds it into the HDR scene with
ONE/ONE, the next frame's bloom threshold readsthat scene, and the loop gains roughly 1.7-2x per frame until the image saturates. Auto-exposure
compensates until it hits its lower clamp and then cannot keep up.
Why
A fast clear is a metadata write that takes effect when it is issued. Any later read of the
surface — as a texture or as a render target — must observe cleared data. Deferring to the next
render-target bind is only valid if nothing reads the surface in between.
The same requirement is visible in AMD's open-source PAL driver: a colour surface that will be
texture-fetched needs a fast-clear-eliminate pass before it can be sampled, and only a small set
of hardware-defined clear colours avoid it
(
src/core/hw/gfxip/gfx9/gfx9MaskRam.cpp,Gfx9Dcc::GetFastClearCodeandpNeedFastClearElim).Change
TextureCache, so both therender-target path and the sampled path resolve it the same way.
FindTexturenow materializes a pending DCC clear withclearColorImagebefore the image isused, then consumes it. The render-target path keeps the cheaper load-op.
ImageDescso the cache can resolve a clearwithout the draw-time register state.
No title, address or shader-hash special cases.
Testing
kernel_file_system_tests,resource_tracking_tests,scalar_provenance_tests,shader_cfg_tests,virtual_memory_allocation_testspass.shader_recompiler_compute_testsfails atRenderExecutorStencilBindingDiscovery("depth texture compatibility identity"). This reproduces unchanged on
mainatdd062cewith no patch applied, so it is pre-existing and unrelated; the existing
UnifiedTextureCacheFlowcase was extended to assert that a pending clear is materialized onthe sampled path.
non-finite values, against a saturated 48099 before.
Known gap
GFX10's comp-to-single clear code (
0x10) is still unhandled — its colour lives in the firstpixel of each DCC block rather than in a register, so it needs a different value source. It does
not occur in the title I tested; the new report makes it visible rather than silent if it does.
AI involvement
Investigation, patch and testing were done with AI assistance
@brandostrong on GitHub · 2026-09-01 16:34 UTC · original · edited 2026-09-01 17:02 UTC
0x10 is yet to be supported, I'll add it in a further pr. I do not have any games that use it though, so is it better to leave it off as a crash/error to fix with a game as backing, or just to try to implement?
correction: gta 5 does fire some 0x10 clears
DCC fast-clear codes
A DCC fast clear writes only the metadata byte for each block — no pixels are touched. The code
records how a reader recovers the colour.
0x00(0, 0, 0, 0)0x40(0, 0, 0, 1)0x80(1, 1, 1, 0)0xC0(1, 1, 1, 1)0x20CB_COLOR*_CLEAR_WORD0/10x10Pull request closed