From 4b4c138fb0ee0dca098e88966d9b4e2ccfae44a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mo=C5=A3?= Date: Sat, 29 Aug 2026 19:06:54 +0300 Subject: [PATCH] vulkan: use BC1_RGBA formats so TextureFormat::BC1 keeps its 1-bit alpha (#3937) VK_FORMAT_BC1_RGB_UNORM_BLOCK has no alpha component, so sampling a BC1 texture on Vulkan always returns a = 1.0 and the 1-bit punch-through alpha of the source data is silently discarded. This contradicts bgfx's own definition of the format - bgfx.h documents TextureFormat::BC1 as "5-bit R, 6-bit G, 5-bit B, 1-bit A" - and it disagrees with every other backend: D3D11/D3D12 DXGI_FORMAT_BC1_UNORM OpenGL GL_COMPRESSED_RGBA_S3TC_DXT1_EXT all of which decode the punch-through alpha. There is no separate BC1A format in bgfx, so the RGB variant is not an intentional distinction. Switching to the RGBA variants costs nothing in terms of support: if textureCompressionBC is available, the specification requires all of BC1-BC7 with the same feature set, so VK_FORMAT_BC1_RGBA_UNORM_BLOCK is available wherever VK_FORMAT_BC1_RGB_UNORM_BLOCK is. Fully opaque BC1 blocks decode identically under both. --- src/renderer_vk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 46ed823f5..edaa354b5 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -185,7 +185,7 @@ VK_IMPORT_DEVICE #define $G VK_COMPONENT_SWIZZLE_G #define $B VK_COMPONENT_SWIZZLE_B #define $A VK_COMPONENT_SWIZZLE_A - { VK_FORMAT_BC1_RGB_UNORM_BLOCK, VK_FORMAT_BC1_RGB_UNORM_BLOCK, VK_FORMAT_UNDEFINED, VK_FORMAT_BC1_RGB_SRGB_BLOCK, { $_, $_, $_, $_ } }, // BC1 + { VK_FORMAT_BC1_RGBA_UNORM_BLOCK, VK_FORMAT_BC1_RGBA_UNORM_BLOCK, VK_FORMAT_UNDEFINED, VK_FORMAT_BC1_RGBA_SRGB_BLOCK, { $_, $_, $_, $_ } }, // BC1 { VK_FORMAT_BC2_UNORM_BLOCK, VK_FORMAT_BC2_UNORM_BLOCK, VK_FORMAT_UNDEFINED, VK_FORMAT_BC2_SRGB_BLOCK, { $_, $_, $_, $_ } }, // BC2 { VK_FORMAT_BC3_UNORM_BLOCK, VK_FORMAT_BC3_UNORM_BLOCK, VK_FORMAT_UNDEFINED, VK_FORMAT_BC3_SRGB_BLOCK, { $_, $_, $_, $_ } }, // BC3 { VK_FORMAT_BC4_UNORM_BLOCK, VK_FORMAT_BC4_UNORM_BLOCK, VK_FORMAT_UNDEFINED, VK_FORMAT_UNDEFINED, { $_, $_, $_, $_ } }, // BC4