renderer: decode R32_SFLOAT packed colour clears #436

Manually merged
github merged 2 commits from gh-pr/436/head into gh-pr/436/base 2026-11-26 09:20:48 +00:00
Owner

@⁠CheesyPoofs346 on GitHub · 2026-08-31 22:45 UTC · original
CheesyPoofs346:fix/r32-sfloat-packed-clear → main · +4 −0 · 1 files · 2 commits · merged 2026-08-31 23:37 UTC

Summary

  • Decode R32_SFLOAT packed colour clears instead of rejecting them.
  • R32Uint and R32Sint were handled; the float case fell through to default: return false, so the clear was discarded.

Problem

DecodePackedColorClear covers R32Uint, R32Sint and the 8/10-bit UNORM/SRGB formats, but has no case for eR32Sfloat:

switch (format) {
    case vk::Format::eR32Uint: next.uint32[0] = packed; break;
    case vk::Format::eR32Sint: next.int32[0] = static_cast<int32_t>(packed); break;
    ...
    default: return false;
}

Returning false makes ResolveDccClearInfo clear metadata_clear_supported and discard the clear value:

info.metadata_clear_supported =
    has_dcc && DecodePackedColorClear(format, packed_clear, info.color_clear_value);
...
if (!info.metadata_clear_supported) {
    info.color_clear_value = {};
}

So a single-channel float target that the guest asked to clear keeps whatever was in that memory.

Observed in Grand Theft Auto V (PPSA04264) as red static covering window surfaces. With the clear decoded the same surfaces render their intended contents.

The encoding is the same one DecodePackedDepthClear already uses immediately below — the packed word is the float's bit pattern. Non-finite patterns are rejected rather than materialized, matching the guard the depth decoder applies.

Scope

Only the decoding is added. R32_SFLOAT is deliberately not added to metadata_fixed_clear_supported in colorRenderTarget.cpp: that path applies a fixed opaque-black clear, and enabling it for this format turned character surfaces white in testing.

Validation

  • Built on Windows with clang-cl/Ninja and verified in game from the same change in my working tree; the PR branch itself was not built in isolation because that checkout lacks the vendored submodules.
  • GTA5: red static on window surfaces before, correct contents after, with no other visible change.

AI assistance

AI assistance was used for this change.

**@⁠CheesyPoofs346** on GitHub · 2026-08-31 22:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/436) `CheesyPoofs346:fix/r32-sfloat-packed-clear` → `main` · +4 −0 · 1 files · 2 commits · merged 2026-08-31 23:37 UTC ## Summary - Decode `R32_SFLOAT` packed colour clears instead of rejecting them. - `R32Uint` and `R32Sint` were handled; the float case fell through to `default: return false`, so the clear was discarded. ## Problem `DecodePackedColorClear` covers `R32Uint`, `R32Sint` and the 8/10-bit UNORM/SRGB formats, but has no case for `eR32Sfloat`: ```cpp switch (format) { case vk::Format::eR32Uint: next.uint32[0] = packed; break; case vk::Format::eR32Sint: next.int32[0] = static_cast<int32_t>(packed); break; ... default: return false; } ``` Returning false makes `ResolveDccClearInfo` clear `metadata_clear_supported` and discard the clear value: ```cpp info.metadata_clear_supported = has_dcc && DecodePackedColorClear(format, packed_clear, info.color_clear_value); ... if (!info.metadata_clear_supported) { info.color_clear_value = {}; } ``` So a single-channel float target that the guest asked to clear keeps whatever was in that memory. Observed in Grand Theft Auto V (PPSA04264) as red static covering window surfaces. With the clear decoded the same surfaces render their intended contents. The encoding is the same one `DecodePackedDepthClear` already uses immediately below — the packed word is the float's bit pattern. Non-finite patterns are rejected rather than materialized, matching the guard the depth decoder applies. ## Scope Only the decoding is added. `R32_SFLOAT` is deliberately **not** added to `metadata_fixed_clear_supported` in `colorRenderTarget.cpp`: that path applies a fixed opaque-black clear, and enabling it for this format turned character surfaces white in testing. ## Validation - Built on Windows with clang-cl/Ninja and verified in game from the same change in my working tree; the PR branch itself was not built in isolation because that checkout lacks the vendored submodules. - GTA5: red static on window surfaces before, correct contents after, with no other visible change. ## AI assistance AI assistance was used for this change.
DecodePackedColorClear handled R32Uint, R32Sint and the 8/10-bit formats but fell through to the default false case for R32Sfloat. metadata_clear_supported then went false, the clear value was discarded, and the target kept its previous contents. Decode the packed word as float bits, matching DecodePackedDepthClear directly below, and reject non-finite patterns rather than materializing them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:20:47 +00:00
github manually merged commit 36c48ceb3e into gh-pr/436/base 2026-11-26 09:20:48 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-08-31 22:45 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-08-31 22:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/436#pullrequestreview-5072105238) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
This discussion has been locked. Commenting is limited to contributors.
No description provided.