Restore support for BC1_RGB compressed format.
For Vulkan BC1_RGB formats, swizzle alpha of substituted
Metal BC1_RGBA to 1.0, to return value expected by Vulkan.
diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md
index 4460dfa..992da4c 100644
--- a/Docs/Whats_New.md
+++ b/Docs/Whats_New.md
@@ -24,8 +24,6 @@
is not supported on platform, but app doesn't actually attempt to render to multiple layers.
- Fix dynamic pipeline state such as `vkCmdSetDepthBias()` sometimes ignoring pipeline dyamic
state flags when called before `vkCmdBindPipeline()`.
-- Remove advertising support for pixel formats `VK_FORMAT_BC1_RGB_UNORM_BLOCK` and `VK_FORMAT_BC1_RGB_SRGB_BLOCK`,
- as these can cause rare compatibility problems with transparency encoding.
- Update to latest SPIRV-Cross version:
- MSL: Add support for `OpSpecConstantOp` ops `OpQuantizeToF16` and `OpSRem`.
- MSL: Return fragment function value even when last SPIR-V Op is discard (`OpKill`).
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
index 854ea5a..34b9d49 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
@@ -1489,6 +1489,19 @@
_componentSwizzle = pCreateInfo->components;
VkImageAspectFlags aspectMask = pCreateInfo->subresourceRange.aspectMask;
+ // Use swizzle adjustment to bridge some differences between Vulkan and Metal pixel formats.
+ // Do this ahead of other tests and adjustments so that swizzling will be enabled by tests below.
+ switch (pCreateInfo->format) {
+ case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
+ case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
+ // Metal doesn't support BC1_RGB, so force substituted BC1_RGBA alpha to 1.0.
+ _componentSwizzle.a = VK_COMPONENT_SWIZZLE_ONE;
+ break;
+
+ default:
+ break;
+ }
+
#define SWIZZLE_MATCHES(R, G, B, A) mvkVkComponentMappingsMatch(_componentSwizzle, {VK_COMPONENT_SWIZZLE_ ##R, VK_COMPONENT_SWIZZLE_ ##G, VK_COMPONENT_SWIZZLE_ ##B, VK_COMPONENT_SWIZZLE_ ##A} )
#define VK_COMPONENT_SWIZZLE_ANY VK_COMPONENT_SWIZZLE_MAX_ENUM
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm
index 6c7106a..3192c8c 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm
@@ -935,8 +935,8 @@
addVkFormatDesc( X8_D24_UNORM_PACK32, Invalid, Depth24Unorm_Stencil8, Invalid, Invalid, 1, 1, 4, DepthStencil );
- addVkFormatDesc( BC1_RGB_UNORM_BLOCK, Invalid, BC1_RGBA, Invalid, Invalid, 4, 4, 8, Compressed );
- addVkFormatDesc( BC1_RGB_SRGB_BLOCK, Invalid, BC1_RGBA_sRGB, Invalid, Invalid, 4, 4, 8, Compressed );
+ addVkFormatDesc( BC1_RGB_UNORM_BLOCK, BC1_RGBA, Invalid, Invalid, Invalid, 4, 4, 8, Compressed );
+ addVkFormatDesc( BC1_RGB_SRGB_BLOCK, BC1_RGBA_sRGB, Invalid, Invalid, Invalid, 4, 4, 8, Compressed );
addVkFormatDesc( BC1_RGBA_UNORM_BLOCK, BC1_RGBA, Invalid, Invalid, Invalid, 4, 4, 8, Compressed );
addVkFormatDesc( BC1_RGBA_SRGB_BLOCK, BC1_RGBA_sRGB, Invalid, Invalid, Invalid, 4, 4, 8, Compressed );