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.
This commit is contained in:
Moţ
2026-08-29 19:06:54 +03:00
committed by GitHub
parent 7d81d2874b
commit 4b4c138fb0

View File

@@ -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