graphics: resolve multisampled color targets into another format #2371

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

@⁠Nawid3333 on GitHub · 2026-11-18 05:50 UTC · original
Nawid3333:fix/resolve-format-conversion → main · +112 −3 · 3 files · 1 commits · closed without merging

Problem

A CB resolve (color mode 3) writes the averaged samples of render target 0 in the format of render target 1. Image::Resolve used vkCmdResolveImage, which needs both images in the same format (VUID-vkCmdResolveImage-srcImage-01386), so a resolve between two formats stopped at its format check (image.cpp:421 at 2638b1b07):

Error: condition (layers == 0 || (copy ? !ImageViewOps::FormatsCompatible(source.backing.format, backing.format) : source.backing.format != backing.format)) is true in ...\image.cpp:421

Beat Saber (PPSA15035, #2337) stops there once its first frames are presented (main stops earlier, in the presenter's layer-count check; a separate PR fixes that). A diagnostic build printed the two images (@⁠Crispy81):

resolve mismatch: source format=R8G8B8A8Srgb samples=8 layers=2 levels=1 extent=1632x1836 range=0/0 | destination format=A2B10G10R10UnormPack32 samples=1 layers=2 levels=1 extent=1632x1836 range=0/0 | layers=1

Change

  • A multisampled resolve between two formats resolves into a single-sample scratch image of the source format, then blits that image into the destination with vkCmdBlitImage (nearest filter, same extent), which converts the format: an sRGB source is decoded to linear and written in the destination's encoding.
  • The blit is used only when both formats support it: eBlitSrc on the source and eBlitDst on the destination (optimal tiling), and both are integer formats of the same signedness or both are not integer (VUID-vkCmdBlitImage-srcImage-00229/00230). Other pairs still reach the EXIT_IF.
  • Each destination image keeps one scratch image and replaces it when the source format, extent or layer count changes. The old scratch is freed through DeferOperation, after the GPU work that uses it.
  • Unchanged: resolves between equal formats and single-sample copies take the same path as before.

Tests

shader_recompiler_compute_tests, check "MSAA resolve into another color format" (next to the existing Image::Resolve checks): a 2-sample 4x4 R8G8B8A8Srgb image cleared to (0.5, 0, 1, 1) is resolved into an A2B10G10R10UnormPack32 image and read back. Every texel must have red 500..525 (linear 0.5; a resolve that skips the sRGB decode gives about 754), green 0, blue 1023 and alpha 3.

RX 9070 XT (Windows 11, clang-cl, with the harness change of #2038), Vulkan validation layer on: with the change the check passes with 0 validation errors. On main's sources the same test stops at the game's exact image.cpp:421 condition. With the change, the test function then stops after this check at its 2-sample D24UnormS8Uint image (format=129 ... samples=2, image.cpp:771), which this GPU does not support; main's own tests stop at the same image.

Fork build of this head (run 44242028720): Windows, Linux and macOS build.

In a game

With this commit and that presenter change (fork build 23237f3, run 44195030260), @⁠Crispy81's Beat Saber reaches its language selection menu at 30 fps (screenshot in #2337). Going further needs the PS VR2 Sense controllers.

Written with Claude Code (AI): Claude Code wrote the change and the test from the diagnostic build's output and ran them; Claude Opus reviewed the change and asked for the mid-value sRGB check; GLM fact-checked this text.

**@⁠Nawid3333** on GitHub · 2026-11-18 05:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2371) `Nawid3333:fix/resolve-format-conversion` → `main` · +112 −3 · 3 files · 1 commits · closed without merging ## Problem A CB resolve (color mode 3) writes the averaged samples of render target 0 in the format of render target 1. `Image::Resolve` used `vkCmdResolveImage`, which needs both images in the same format (VUID-vkCmdResolveImage-srcImage-01386), so a resolve between two formats stopped at its format check (image.cpp:421 at 2638b1b07): ``` Error: condition (layers == 0 || (copy ? !ImageViewOps::FormatsCompatible(source.backing.format, backing.format) : source.backing.format != backing.format)) is true in ...\image.cpp:421 ``` Beat Saber (PPSA15035, #2337) stops there once its first frames are presented (main stops earlier, in the presenter's layer-count check; a separate PR fixes that). A diagnostic build printed the two images (@⁠Crispy81): ``` resolve mismatch: source format=R8G8B8A8Srgb samples=8 layers=2 levels=1 extent=1632x1836 range=0/0 | destination format=A2B10G10R10UnormPack32 samples=1 layers=2 levels=1 extent=1632x1836 range=0/0 | layers=1 ``` ## Change - A multisampled resolve between two formats resolves into a single-sample scratch image of the source format, then blits that image into the destination with `vkCmdBlitImage` (nearest filter, same extent), which converts the format: an sRGB source is decoded to linear and written in the destination's encoding. - The blit is used only when both formats support it: `eBlitSrc` on the source and `eBlitDst` on the destination (optimal tiling), and both are integer formats of the same signedness or both are not integer (VUID-vkCmdBlitImage-srcImage-00229/00230). Other pairs still reach the `EXIT_IF`. - Each destination image keeps one scratch image and replaces it when the source format, extent or layer count changes. The old scratch is freed through `DeferOperation`, after the GPU work that uses it. - Unchanged: resolves between equal formats and single-sample copies take the same path as before. ## Tests `shader_recompiler_compute_tests`, check "MSAA resolve into another color format" (next to the existing `Image::Resolve` checks): a 2-sample 4x4 `R8G8B8A8Srgb` image cleared to (0.5, 0, 1, 1) is resolved into an `A2B10G10R10UnormPack32` image and read back. Every texel must have red 500..525 (linear 0.5; a resolve that skips the sRGB decode gives about 754), green 0, blue 1023 and alpha 3. RX 9070 XT (Windows 11, clang-cl, with the harness change of #2038), Vulkan validation layer on: with the change the check passes with 0 validation errors. On main's sources the same test stops at the game's exact `image.cpp:421` condition. With the change, the test function then stops after this check at its 2-sample `D24UnormS8Uint` image (`format=129 ... samples=2`, image.cpp:771), which this GPU does not support; main's own tests stop at the same image. Fork build of this head ([run 44242028720](https://github.com/Nawid3333/KytyPS5/actions/runs/44242028720)): Windows, Linux and macOS build. ## In a game With this commit and that presenter change (fork build 23237f3, [run 44195030260](https://github.com/Nawid3333/KytyPS5/actions/runs/44195030260)), @⁠Crispy81's Beat Saber reaches its language selection menu at 30 fps ([screenshot in #2337](https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/2337)). Going further needs the PS VR2 Sense controllers. Written with Claude Code (AI): Claude Code wrote the change and the test from the diagnostic build's output and ran them; Claude Opus reviewed the change and asked for the mid-value sRGB check; GLM fact-checked this text.
A CB resolve (color mode 3) writes the averaged samples of render target 0 in the
format of render target 1. vkCmdResolveImage needs equal formats, so a resolve
between formats now resolves into a single-sample image of the source format and
blits it into the destination, which converts the format.

Beat Saber (#2337) resolves an 8x R8G8B8A8 sRGB target into an A2B10G10R10 one
and stopped at the resolve's format check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:19:00 +00:00
github-bot closed this pull request 2026-11-26 10:19:00 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-18 05:58 UTC · original

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Multisample resolves can now convert between formats when their numeric classes match and the required blit features are supported. The resolve uses a source-format scratch image, then nearest-blits to the destination. Same-format multisample resolves retain the direct path, and single-sample copies retain the format-compatibility check. A compute test checks the resolved texel values.

Suggested reviewers: nmzik, senaxx

Change: Bug fix

Merge Risk: Minimal · up to 3b8ac

This change lets multisample color resolves convert between formats when the GPU supports the required blits. Previously these resolves failed at the format check. No merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: multisampled color resolves between two different formats. The changeset adds a scratch-image resolve followed by a blit for differing formats, which matches the title…
Description check Passed The description explains the problem (a CB resolve between render target formats hits the format check in Image::Resolve), the change (scratch image resolve, then vkCmdBlitImage with format conversion…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: multisampled color resolves between two different formats. The changeset adds a scratch-image resolve followed by a blit for differing formats, which matches the title's subject and intent.

Full details: Description check

Explanation

The description explains the problem (a CB resolve between render target formats hits the format check in Image::Resolve), the change (scratch image resolve, then vkCmdBlitImage with format conversion, and scratch lifetime handling), and the added test. It is closely related to the changeset.

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2638b1b076 and 3b8ac623dc.

Files selected for processing: 3

  • src/graphics/host_gpu/renderer/image/image.cpp
  • src/graphics/host_gpu/renderer/image/image.h
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 05:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2371#issuecomment-6970486386) <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/2371?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_status_start --> No actionable comments were generated in the recent review. <!-- recent_review_status_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> Multisample resolves can now convert between formats when their numeric classes match and the required blit features are supported. The resolve uses a source-format scratch image, then nearest-blits to the destination. Same-format multisample resolves retain the direct path, and single-sample copies retain the format-compatibility check. A compute test checks the resolved texel values. **Suggested reviewers:** `nmzik`, `senaxx` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"3b8ac623dcb247917fd7b079ab7fcacda83e541e" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>3b8ac</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `3b8ac` --> <!-- final_review_risk_coverage:{"sourceCommitId":"3b8ac623dcb247917fd7b079ab7fcacda83e541e","coveredCommitId":"3b8ac623dcb247917fd7b079ab7fcacda83e541e","kind":"reviewed"} --> This change lets multisample color resolves convert between formats when the GPU supports the required blits. Previously these resolves failed at the format check. No merge-blocking risk is identified. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title names the main change: multisampled color resolves between two different formats. The changeset adds a scratch-image resolve followed by a blit for differing formats, which matches the title… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description explains the problem (a CB resolve between render target formats hits the format check in Image::Resolve), the change (scratch image resolve, then vkCmdBlitImage with format conversion… | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title names the main change: multisampled color resolves between two different formats. The changeset adds a scratch-image resolve followed by a blit for differing formats, which matches the title's subject and intent. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description explains the problem (a CB resolve between render target formats hits the format check in Image::Resolve), the change (scratch image resolve, then vkCmdBlitImage with format conversion, and scratch lifetime handling), and the added test. It is closely related to the changeset. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2371)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> <br> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end --> <!-- recent_review_start --> <h6> <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <br> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/2638b1b07613dc32a4708d2cd61a75711b84b6cf/.coderabbit.yaml>) - **Commit**: [2638b1b](<https://github.com/KytyPS5/KytyPS5/commit/2638b1b07613dc32a4708d2cd61a75711b84b6cf>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `f8c597c5-ed21-4a02-a6f0-ff85fcf33a62` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 2638b1b07613dc32a4708d2cd61a75711b84b6cf and 3b8ac623dcb247917fd7b079ab7fcacda83e541e. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 3</strong></summary> <dl> <dd> <br> * `src/graphics/host_gpu/renderer/image/image.cpp` * `src/graphics/host_gpu/renderer/image/image.h` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->

Pull request closed

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