graphics: support deferred DCC clears beyond 32 slices #543

Closed
github-bot wants to merge 1 commit from gh-pr/543/head into gh-pr/543/base
Owner

@⁠MehmetCambaz on GitHub · 2026-09-09 12:32 UTC · original
MehmetCambaz:fix/dcc-clear-beyond-32-slices → main · +344 −37 · 4 files · 1 commits · closed without merging

Problem

MetaDataInfo::clear_mask tracked pending DCC clear slices in a uint32_t, so only
slices 0-31 could be represented. PrepareDccClear bailed out on any view whose slice
range fell outside that window, and IsMetaCleared/TouchMeta reported slice 32 and
above as not pending. A recognised guest DCC clear on a layered target with more than
32 slices was armed and then never materialised, leaving the image with its previous
contents.

Change

Track pending slices with the existing RangeSet across the slice range the guest can
address. Widening the integer would only move the limit — CB_COLOR_VIEW encodes 13-bit
slice indices.

PrepareDccClear now materialises the intersection of the bound view with the slices
still pending, one contiguous run at a time. Partial consumption is unchanged: slices
already cleared are not cleared again, since they may have been rendered into since, and
a repeated metadata fill re-arms the whole range. The metadata entry is re-found after
each ClearImage, because retiring an image can erase it.

HTile still arms the same 32 slices as before; widening that belongs with a separate
multi-layer depth change.

Validation

New texture_cache_dcc_slice_range covers a 64-slice target, a view starting above slice
31, overlapping partial consumption, and a target past 64 slices so widening the mask
alone does not pass. The cases run through ResolveRenderColorTarget/FindRenderTarget
and check host texels and pending state before and after.

Focused DCC, HTile, depth and cache groups pass. Full CTest 37/38; kernel_file_system
fails identically on pristine upstream.

Kena: Bridge of Spirits exposed this with a 64-slice RGBA16F volumetric lighting target
that is fast-cleared each frame before additive light injection. Before, the clear never
landed and radiance accumulated across frames into progressively over-bright blue/white
lighting. After, lighting stays stable.

AI assistance

AI assistance was used during investigation, implementation and testing. I reviewed the
resulting change and validation before submitting it.

**@⁠MehmetCambaz** on GitHub · 2026-09-09 12:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/543) `MehmetCambaz:fix/dcc-clear-beyond-32-slices` → `main` · +344 −37 · 4 files · 1 commits · closed without merging ## Problem `MetaDataInfo::clear_mask` tracked pending DCC clear slices in a `uint32_t`, so only slices 0-31 could be represented. `PrepareDccClear` bailed out on any view whose slice range fell outside that window, and `IsMetaCleared`/`TouchMeta` reported slice 32 and above as not pending. A recognised guest DCC clear on a layered target with more than 32 slices was armed and then never materialised, leaving the image with its previous contents. ## Change Track pending slices with the existing `RangeSet` across the slice range the guest can address. Widening the integer would only move the limit — `CB_COLOR_VIEW` encodes 13-bit slice indices. `PrepareDccClear` now materialises the intersection of the bound view with the slices still pending, one contiguous run at a time. Partial consumption is unchanged: slices already cleared are not cleared again, since they may have been rendered into since, and a repeated metadata fill re-arms the whole range. The metadata entry is re-found after each `ClearImage`, because retiring an image can erase it. HTile still arms the same 32 slices as before; widening that belongs with a separate multi-layer depth change. ## Validation New `texture_cache_dcc_slice_range` covers a 64-slice target, a view starting above slice 31, overlapping partial consumption, and a target past 64 slices so widening the mask alone does not pass. The cases run through `ResolveRenderColorTarget`/`FindRenderTarget` and check host texels and pending state before and after. Focused DCC, HTile, depth and cache groups pass. Full CTest 37/38; `kernel_file_system` fails identically on pristine upstream. Kena: Bridge of Spirits exposed this with a 64-slice RGBA16F volumetric lighting target that is fast-cleared each frame before additive light injection. Before, the clear never landed and radiance accumulated across frames into progressively over-bright blue/white lighting. After, lighting stays stable. ## AI assistance AI assistance was used during investigation, implementation and testing. I reviewed the resulting change and validation before submitting it.
Deferred colour DCC clear state tracked pending slices in a uint32_t mask, so
only slices 0..31 could be represented. PrepareDccClear refused any view whose
range fell outside that window, and IsMetaCleared/TouchMeta reported slices at
or above 32 as not pending. A guest fast clear of a layered colour target with
more than 32 slices was therefore armed but never materialized, and the image
kept its previous contents. Additively blended targets accumulated across
frames as a result.

Represent the pending slices as ranges covering the slice space the guest can
actually address. CB_COLOR_VIEW and DB_DEPTH_VIEW encode 13-bit slice indices,
so the capacity comes from the register field rather than from a host integer
width, and a wider mask would only move the limit. PrepareDccClear now walks
the intersection of the bound view with the pending ranges and materializes
each contiguous run, so partial consumption still works: slices that were
already cleared and may have been rendered into since are not cleared again,
and a repeated metadata fill re-arms the whole range.

ClearImage can retire images, and retiring an image that shares a metadata
allocation erases its entry, so the pending state is re-found after each clear
instead of holding a reference across the call.

HTile keeps arming the same 32 slices it armed before. Its pending state is
still consumed one slice at a time at the depth binding, and widening that
belongs with the separate multi-layer depth clear fix.

Tests cover a 64-slice view, a view based at slice 40, partial consumption
followed by a wider overlapping view, and a view spanning more than 64 slices,
each checking host texels and the pending state before and after
materialization.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:24:59 +00:00
github-bot closed this pull request 2026-11-26 09:24:59 +00:00
Author
Owner

@⁠Nmzik on GitHub · 2026-09-15 08:58 UTC · original

@⁠MehmetCambaz Could you please retest with main branch if the issue still persists?

**@⁠Nmzik** on GitHub · 2026-09-15 08:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/543#issuecomment-5677510836) @⁠MehmetCambaz Could you please retest with main branch if the issue still persists?
Author
Owner

@⁠MehmetCambaz on GitHub · 2026-09-16 00:13 UTC · original

@⁠Nmzik Retested on current main (e6156bef). I couldn’t reproduce the original DCC/lighting issue in the run, although the low FPS and unrelated late-loading issues made the visual check a bit difficult.

I also checked the current DCC path and this PR appears to have been superseded by 437e69ef (Remove extra DCC tracking). TrackDccFill, PrepareDccClear, and the pending DCC tracking this PR changes are gone, and MaterializeDccClear now works per slice against the actual layer count rather than the old 32-bit pending mask.

So this PR is obsolete against current main and I’ll close it. Thanks for pointing me back to the latest code.

Also, while testing Kena I’ve been working on a couple of separate performance improvements: #562 reduces the PrepareBda overhead substantially in Kena, and #628 reduces SRT/resource-materialization CPU cost. If you get a chance, I’d appreciate a look at those as well.

**@⁠MehmetCambaz** on GitHub · 2026-09-16 00:13 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/543#issuecomment-5689964976) @⁠Nmzik Retested on current main (e6156bef). I couldn’t reproduce the original DCC/lighting issue in the run, although the low FPS and unrelated late-loading issues made the visual check a bit difficult. I also checked the current DCC path and this PR appears to have been superseded by 437e69ef (Remove extra DCC tracking). TrackDccFill, PrepareDccClear, and the pending DCC tracking this PR changes are gone, and MaterializeDccClear now works per slice against the actual layer count rather than the old 32-bit pending mask. So this PR is obsolete against current main and I’ll close it. Thanks for pointing me back to the latest code. Also, while testing Kena I’ve been working on a couple of separate performance improvements: #562 reduces the PrepareBda overhead substantially in Kena, and #628 reduces SRT/resource-materialization CPU cost. If you get a chance, I’d appreciate a look at those as well.
Author
Owner

@⁠MehmetCambaz on GitHub · 2026-09-16 00:14 UTC · original

closing the pr

**@⁠MehmetCambaz** on GitHub · 2026-09-16 00:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/543#issuecomment-5689970741) closing the pr

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.