Skip to content

fix(vk): skip clears of textures kept in ASTC blocks - #2718

Open
juliotec wants to merge 1 commit into
NotRexed:mainfrom
juliotec:fix/vk-astc-clear
Open

juliotec wants to merge 1 commit into
NotRexed:mainfrom
juliotec:fix/vk-astc-clear

Conversation

@juliotec

@juliotec juliotec commented Nov 12, 2026 •

Copy link
Copy Markdown

clear_tex already leaves BC images out of vkCmdClearColorImage, but not ASTC
ones. On a GPU that samples ASTC natively the image stays in ASTC blocks, and
vkCmdClearColorImage does not take a compressed format, and the region path only
converts the rectangle to BC blocks, so the clear was invalid and some drivers
hang on it. A colour written over ASTC blocks would be garbage anyway.

What changed (gpu/vk/vk_xfer.cpp, clear_tex): a clear of an image whose format
is ASTC is skipped with a one-time warning (warn 14). Decoded ASTC textures
(RGBA8) and every other format are cleared as before.

How tested: release build; Zelda OoT on Radeon RX 9070 XT (Windows,
Adrenalin).

Assisted-by: GitHub Copilot

clear_tex already leaves BC images out of vkCmdClearColorImage, but not ASTC
ones. On a GPU that samples ASTC natively the image stays in ASTC blocks, and
vkCmdClearColorImage does not take a compressed format, and the region path only
converts the rectangle to BC blocks, so the clear was invalid and some drivers
hang on it. A colour written over ASTC blocks would be garbage anyway.

What changed (gpu/vk/vk_xfer.cpp, clear_tex): a clear of an image whose format
is ASTC is skipped with a one-time warning (warn 14). Decoded ASTC textures
(RGBA8) and every other format are cleared as before.

How tested: release build; Zelda OoT on Radeon RX 9070 XT (Windows,
Adrenalin).

Assisted-by: GitHub Copilot

@Joey-Magnus Joey-Magnus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI never ran here. I merged this with #2719, #2741, #2742 and #2743 onto current main. I compiled vk_xfer.cpp with clang++ using the back end's flags and ran tests/run_all.py with the Vulkan headers. None of the failures come from this PR, and test_bc_raw_targets.py and test_vulkan_clear_mip.py pass.

The guard is right. vkCmdClearColorImage must not be given a compressed format, and with astc_native() the image keeps the ASTC VkFormat, so the whole-image branch at gpu/vk/vk_xfer.cpp:340 would do exactly that. BC3-kept ASTC still goes down the raw path as before.

Two notes:

  • AMD and NVIDIA desktop drivers don't expose textureCompressionASTC_LDR, so on the RX 9070 XT you tested, this code never runs. Only Intel iGPUs and similar would reach it. The "some drivers hang" claim would be good to back with a log or a validation-layer message from such a device, or the description should say it is from the spec.
  • The early return also skips texture_written(s.tex) at :404, so the texture is not marked GPU-written. Since nothing was written, that seems right, but please confirm it was intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants