Merge pull request #1467 from billhollings/restore-bc1-rgb-support

Restore support for BC1_RGB compressed formats.
This commit is contained in:
Bill Hollings 2021-11-10 14:43:49 -05:00 committed by GitHub
commit f99384da96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 4 deletions

View File

@ -24,8 +24,6 @@ Released TBD
is not supported on platform, but app doesn't actually attempt to render to multiple layers. 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 - Fix dynamic pipeline state such as `vkCmdSetDepthBias()` sometimes ignoring pipeline dyamic
state flags when called before `vkCmdBindPipeline()`. 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: - Update to latest SPIRV-Cross version:
- MSL: Add support for `OpSpecConstantOp` ops `OpQuantizeToF16` and `OpSRem`. - MSL: Add support for `OpSpecConstantOp` ops `OpQuantizeToF16` and `OpSRem`.
- MSL: Return fragment function value even when last SPIR-V Op is discard (`OpKill`). - MSL: Return fragment function value even when last SPIR-V Op is discard (`OpKill`).

View File

@ -1489,6 +1489,25 @@ VkResult MVKImageViewPlane::initSwizzledMTLPixelFormat(const VkImageViewCreateIn
_componentSwizzle = pCreateInfo->components; _componentSwizzle = pCreateInfo->components;
VkImageAspectFlags aspectMask = pCreateInfo->subresourceRange.aspectMask; VkImageAspectFlags aspectMask = pCreateInfo->subresourceRange.aspectMask;
#define adjustComponentSwizzleValue(comp, currVal, newVal) if (_componentSwizzle.comp == VK_COMPONENT_SWIZZLE_ ##currVal) { _componentSwizzle.comp = VK_COMPONENT_SWIZZLE_ ##newVal; }
// 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 references to substituted BC1_RGBA alpha to 1.0.
adjustComponentSwizzleValue(r, A, ONE);
adjustComponentSwizzleValue(g, A, ONE);
adjustComponentSwizzleValue(b, A, ONE);
adjustComponentSwizzleValue(a, A, ONE);
adjustComponentSwizzleValue(a, IDENTITY, 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 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 #define VK_COMPONENT_SWIZZLE_ANY VK_COMPONENT_SWIZZLE_MAX_ENUM

View File

@ -935,8 +935,8 @@ void MVKPixelFormats::initVkFormatCapabilities() {
addVkFormatDesc( X8_D24_UNORM_PACK32, Invalid, Depth24Unorm_Stencil8, Invalid, Invalid, 1, 1, 4, DepthStencil ); 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_UNORM_BLOCK, BC1_RGBA, Invalid, Invalid, Invalid, 4, 4, 8, Compressed );
addVkFormatDesc( BC1_RGB_SRGB_BLOCK, Invalid, BC1_RGBA_sRGB, 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_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 ); addVkFormatDesc( BC1_RGBA_SRGB_BLOCK, BC1_RGBA_sRGB, Invalid, Invalid, Invalid, 4, 4, 8, Compressed );