texture_cache: give a storage binding its own image when the cached BC image lacks storage usage #2174

Closed
github-bot wants to merge 4 commits from gh-pr/2174/head into gh-pr/2174/base
Owner

@⁠Nawid3333 on GitHub · 2026-11-08 04:41 UTC · original
Nawid3333:fix/bc-storage-view-usage → main · +90 −4 · 3 files · 4 commits · closed without merging

Some drivers refuse VK_IMAGE_USAGE_STORAGE_BIT for BC5 and BC6H images: AMD's Windows driver 26.10.1 refuses it in vkGetPhysicalDeviceImageFormatProperties2 for BC5_UNORM and BC6H_UFLOAT on an RX 9070 XT and on the Radeon iGPU of a Ryzen 5 7600X (also with MUTABLE | EXTENDED_USAGE | BLOCK_TEXEL_VIEW_COMPATIBLE, with and without a format list), while BC1/3/4/7 are accepted. ImageUsageFlags then creates those images without STORAGE and logs Warning: format Bc5UnormBlock does not support storage access. Of the logs attached to issues here, 24 of 152 AMD logs (20 titles) contain that warning, and none of 106 NVIDIA logs.

When the guest later binds the same range as an uncompressed 128-bit storage image at block resolution (e.g. R32G32B32A32_UINT), ResolveOverlap reaches the final equal-pitch handover and returns the cached BC image, because FormatsCompatible puts BC5/BC6H in the 128-bit class. Image::FindView then creates a storage view of an image without STORAGE usage (VUID-VkImageViewCreateInfo-pNext-02662).

Changes.

  • ResolveOverlap: a storage request whose cached image has no STORAGE usage (and no image merged yet) goes through ExpandImage, like the other layout changes in that branch. The new image of the requested format is filled from the cached one and replaces it; a later BC request at the range is rebuilt from it the same way. Devices that give BC images STORAGE keep the current reuse; the decision reads the image's usage, not the vendor. (#1980 makes FindView exit on such a view; with this change the BC case no longer reaches that check.)
  • Image::CopyImage clamped each level's extent to the smaller image in texels. vkCmdCopyImage counts the extent in source texels, so a copy from a BC image (4x4 blocks) into a 128-bit image at block resolution covered a sixteenth of the blocks, and a larger 128-bit source could write past a BC destination. When the block extents differ, the extent is now clamped to the destination's block count; copies between equal block extents are unchanged. This is the block-ratio rule of CopyExtent in #1176 by @⁠overlordxrz-source, which also covers partial blocks and the buffer path but conflicts with main since 440245f6; if #1176 lands first, this commit can be dropped.

Test. A case in CheckUnifiedTextureCacheFlow (--buffer-cache-range-only) uploads a 256x256 BC5 image, removes STORAGE from its backing (so the case runs on every device), binds a 64x64 R32G32B32A32_UINT storage image at the same range and requires: a separate image with STORAGE, the uploaded blocks in it, a stored value in a later BC sample, and the stored value again after binding the storage image once more (the BC image then holds the only copy).

  • RX 9070 XT: main with the test fails at storage alias of a BC image without storage usage; with only the texture cache change it fails at storage rebind after a BC sample; with both changes the case passes. All 145 selectors of shader_recompiler_compute_tests give the same exit code and the same failures on main and on this branch, and the full run fails the same two existing cases on both (GpuSelectedFormattedRgba16Store, IndirectImageQueryDimensions); both stop later at the same D24S8 depth image this GPU cannot create. A lab-only patch replaced the MSAA D24S8 depth format with D32S8 on every arm so the runs reach this case; it is not part of the PR.
  • CI on this head (16d4469ac, main f399d4818 merged in): Windows, Linux and macOS build and pass the tests: https://github.com/KytyPS5/KytyPS5/actions/runs/42641619709

Written with Claude Code, OpenAI Codex and GLM (AI): the fix, the test and the measurements, run on my PC; reviewed by me.

**@⁠Nawid3333** on GitHub · 2026-11-08 04:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2174) `Nawid3333:fix/bc-storage-view-usage` → `main` · +90 −4 · 3 files · 4 commits · closed without merging Some drivers refuse `VK_IMAGE_USAGE_STORAGE_BIT` for BC5 and BC6H images: AMD's Windows driver 26.10.1 refuses it in `vkGetPhysicalDeviceImageFormatProperties2` for BC5_UNORM and BC6H_UFLOAT on an RX 9070 XT and on the Radeon iGPU of a Ryzen 5 7600X (also with MUTABLE | EXTENDED_USAGE | BLOCK_TEXEL_VIEW_COMPATIBLE, with and without a format list), while BC1/3/4/7 are accepted. `ImageUsageFlags` then creates those images without STORAGE and logs `Warning: format Bc5UnormBlock does not support storage access`. Of the logs attached to issues here, 24 of 152 AMD logs (20 titles) contain that warning, and none of 106 NVIDIA logs. When the guest later binds the same range as an uncompressed 128-bit storage image at block resolution (e.g. R32G32B32A32_UINT), `ResolveOverlap` reaches the final equal-pitch handover and returns the cached BC image, because `FormatsCompatible` puts BC5/BC6H in the 128-bit class. `Image::FindView` then creates a storage view of an image without STORAGE usage (VUID-VkImageViewCreateInfo-pNext-02662). **Changes.** - `ResolveOverlap`: a storage request whose cached image has no STORAGE usage (and no image merged yet) goes through `ExpandImage`, like the other layout changes in that branch. The new image of the requested format is filled from the cached one and replaces it; a later BC request at the range is rebuilt from it the same way. Devices that give BC images STORAGE keep the current reuse; the decision reads the image's usage, not the vendor. (#1980 makes `FindView` exit on such a view; with this change the BC case no longer reaches that check.) - `Image::CopyImage` clamped each level's extent to the smaller image in texels. `vkCmdCopyImage` counts the extent in source texels, so a copy from a BC image (4x4 blocks) into a 128-bit image at block resolution covered a sixteenth of the blocks, and a larger 128-bit source could write past a BC destination. When the block extents differ, the extent is now clamped to the destination's block count; copies between equal block extents are unchanged. This is the block-ratio rule of `CopyExtent` in #1176 by @⁠overlordxrz-source, which also covers partial blocks and the buffer path but conflicts with main since 440245f6; if #1176 lands first, this commit can be dropped. **Test.** A case in `CheckUnifiedTextureCacheFlow` (`--buffer-cache-range-only`) uploads a 256x256 BC5 image, removes STORAGE from its backing (so the case runs on every device), binds a 64x64 R32G32B32A32_UINT storage image at the same range and requires: a separate image with STORAGE, the uploaded blocks in it, a stored value in a later BC sample, and the stored value again after binding the storage image once more (the BC image then holds the only copy). - RX 9070 XT: main with the test fails at `storage alias of a BC image without storage usage`; with only the texture cache change it fails at `storage rebind after a BC sample`; with both changes the case passes. All 145 selectors of `shader_recompiler_compute_tests` give the same exit code and the same failures on main and on this branch, and the full run fails the same two existing cases on both (`GpuSelectedFormattedRgba16Store`, `IndirectImageQueryDimensions`); both stop later at the same D24S8 depth image this GPU cannot create. A lab-only patch replaced the MSAA D24S8 depth format with D32S8 on every arm so the runs reach this case; it is not part of the PR. - CI on this head (16d4469ac, main f399d4818 merged in): Windows, Linux and macOS build and pass the tests: https://github.com/KytyPS5/KytyPS5/actions/runs/42641619709 Written with Claude Code, OpenAI Codex and GLM (AI): the fix, the test and the measurements, run on my PC; reviewed by me.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A storage request that aliases a cached image of a compatible format reused that
image even when its backing was created without VK_IMAGE_USAGE_STORAGE_BIT, which
happens for BC5/BC6H on drivers that refuse storage for those formats. The storage
view created on it is then invalid. Expand into a new image instead, so the guest's
writes land in an image that can hold them and the next BC sample is rebuilt from it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Image::CopyImage clamped each level's extent to the smaller of the two images in
texels. vkCmdCopyImage measures the extent in source texels, so a copy from a BC
image (4x4 texel blocks) into a 128-bit image at block resolution covered only a
sixteenth of the blocks. Clamp to the destination's block count instead when the
block extents differ; copies between equal block extents are unchanged.

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

@⁠coderabbitai[bot] on GitHub · 2026-11-08 04:48 UTC · original · edited 2026-11-09 15:12 UTC

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Image copies now calculate mip extents using source and destination block sizes. When a storage request overlaps a compatible cached image without storage usage, ResolveOverlap calls ExpandImage. A new BC5 compute test checks storage alias separation, retained data, and visibility of storage clears.

Suggested reviewers: nmzik, claxten10

Change: Bug fix

Merge Risk: Minimal · up to 16d44

The change makes storage bindings of cached BC images use a storage-capable image and clamps image copies at block boundaries. No actionable merge-blocking risk was identified in the supplied context.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title names the main change: a storage binding gets its own image when the cached BC image lacks storage usage. The raw summary's ResolveOverlap change and the test case match this. The CopyImage …
Description check Passed The description covers the driver issue that causes the bug, the ResolveOverlap and Image::CopyImage changes, the new test case, and the test results. It is detailed and directly related to the change…
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: a storage binding gets its own image when the cached BC image lacks storage usage. The raw summary's ResolveOverlap change and the test case match this. The CopyImage clamp is a secondary change that the title does not mention, which is acceptable.

Full details: Description check

Explanation

The description covers the driver issue that causes the bug, the ResolveOverlap and Image::CopyImage changes, the new test case, and the test results. It is detailed and directly related to the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files. (1 skipped: 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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 d1c2f7abad and 16d4469ac4.

Files selected for processing: 1

  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-08 04:48 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2174#issuecomment-6717403315) · edited 2026-11-09 15:12 UTC <!-- 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/2174?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> Image copies now calculate mip extents using source and destination block sizes. When a storage request overlaps a compatible cached image without storage usage, `ResolveOverlap` calls `ExpandImage`. A new BC5 compute test checks storage alias separation, retained data, and visibility of storage clears. **Suggested reviewers:** `nmzik`, `claxten10` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"16d4469ac443d9f15c454da9d38a8be1b0e19fcc" --> <!-- 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>16d44</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `16d44` --> <!-- final_review_risk_coverage:{"sourceCommitId":"16d4469ac443d9f15c454da9d38a8be1b0e19fcc","coveredCommitId":"16d4469ac443d9f15c454da9d38a8be1b0e19fcc","kind":"reviewed"} --> The change makes storage bindings of cached BC images use a storage-capable image and clamps image copies at block boundaries. No actionable merge-blocking risk was identified in the supplied context. <!-- 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 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <br> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><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> Passed checks: 4 passed</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: a storage binding gets its own image when the cached BC image lacks storage usage. The raw summary's ResolveOverlap change and the test case match this. The CopyImage … | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description covers the driver issue that causes the bug, the ResolveOverlap and Image::CopyImage changes, the new test case, and the test results. It is detailed and directly related to the change… | | 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: a storage binding gets its own image when the cached BC image lacks storage usage. The raw summary's ResolveOverlap change and the test case match this. The CopyImage clamp is a secondary change that the title does not mention, which is acceptable. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description covers the driver issue that causes the bug, the ResolveOverlap and Image::CopyImage changes, the new test case, and the test results. It is detailed and directly related to the changeset. </dd> </dl> </details> </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> <br> **Explanation** Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files. (1 skipped: 1 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </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=2174)! 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/f399d481839722e6153d2ca190b7f669a7a40a6e/.coderabbit.yaml>) - **Commit**: [f399d48](<https://github.com/KytyPS5/KytyPS5/commit/f399d481839722e6153d2ca190b7f669a7a40a6e>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `240c72b8-81c1-47fa-8572-63d3184d10e4` </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 d1c2f7abad7fd837116d3fa040c358ecf7bc973b and 16d4469ac443d9f15c454da9d38a8be1b0e19fcc. </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: 1</strong></summary> <dl> <dd> <br> * `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; 8 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.