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

Open
github-sync wants to merge 1 commit from github/pr/2718 into main
Owner

@juliotec opened this pull request on GitHub · 2026-11-12 09:08 UTC · original

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
the Vulkan spec does not allow vkCmdClearColorImage on a compressed format; the
region path only converts the rectangle to BC blocks. 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). The texture is not marked
GPU-written, on purpose: nothing was written to it. Decoded ASTC textures (RGBA8)
and every other format are cleared as before.

Only devices that expose textureCompressionASTC_LDR (Intel iGPUs and similar)
reach this code; AMD and NVIDIA desktop drivers don't.

How tested: release build; Zelda OoT on Radeon RX 9070 XT (Windows,
Adrenalin), which checks that the change does not affect a GPU without native
ASTC. The ASTC path itself was not run.

Assisted-by: GitHub Copilot

> [@juliotec](https://github.com/juliotec) opened this pull request on GitHub · 2026-11-12 09:08 UTC · [original](https://github.com/NotRexed/Hookshot/pull/2718) 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 the Vulkan spec does not allow vkCmdClearColorImage on a compressed format; the region path only converts the rectangle to BC blocks. 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). The texture is not marked GPU-written, on purpose: nothing was written to it. Decoded ASTC textures (RGBA8) and every other format are cleared as before. Only devices that expose textureCompressionASTC_LDR (Intel iGPUs and similar) reach this code; AMD and NVIDIA desktop drivers don't. How tested: release build; Zelda OoT on Radeon RX 9070 XT (Windows, Adrenalin), which checks that the change does not affect a GPU without native ASTC. The ASTC path itself was not run. Assisted-by: GitHub Copilot <!-- github-sync:item:2718 -->
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
Vulkan allows neither vkCmdClearColorImage on a compressed format nor a colour
attachment view of one for the region path, so the clear was invalid and some
drivers hang on it.

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
Author
Owner

@Joey-Magnus reviewed on GitHub · 2026-11-12 14:34 UTC · original

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.
> [@Joey-Magnus](https://github.com/Joey-Magnus) reviewed on GitHub · 2026-11-12 14:34 UTC · [original](https://github.com/NotRexed/Hookshot/pull/2718#pullrequestreview-5876238818) 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. <!-- github-sync:r:5876238818 -->
Author
Owner

@juliotec commented on GitHub · 2026-11-12 18:54 UTC · original

Thanks. You're right on both. The description no longer claims drivers hang: it says the spec does not allow it, that only devices with textureCompressionASTC_LDR reach this code, and that the RX 9070 XT test only checks a GPU without native ASTC is unaffected. Skipping texture_written is intended, since nothing is written; that is in the commit and description now.

> [@juliotec](https://github.com/juliotec) commented on GitHub · 2026-11-12 18:54 UTC · [original](https://github.com/NotRexed/Hookshot/pull/2718#issuecomment-6832955062) Thanks. You're right on both. The description no longer claims drivers hang: it says the spec does not allow it, that only devices with textureCompressionASTC_LDR reach this code, and that the RX 9070 XT test only checks a GPU without native ASTC is unaffected. Skipping texture_written is intended, since nothing is written; that is in the commit and description now. <!-- github-sync:c:6832955062 -->
Commenting is not possible because the repository is archived.
No description provided.