metal: use a fallback for fonts when luminance-alpha isn't supported.

This commit is contained in:
Alex Szpakowski
2022-01-22 14:41:42 -04:00
parent 62de8f62c7
commit 1cf0073cf4
6 changed files with 79 additions and 36 deletions
+10 -5
View File
@@ -143,11 +143,16 @@ Metal::PixelFormatDesc Metal::convertPixelFormat(id<MTLDevice> device, PixelForm
break;
case PIXELFORMAT_LA8_UNORM:
// TODO: fall back to RGBA8 when swizzle isn't available. Pixel format
// size calculation will need to be adjusted as well
mtlformat = MTLPixelFormatRG8Unorm;
desc.swizzled = true;
desc.swizzle = MTLTextureSwizzleChannelsMake(MTLTextureSwizzleRed, MTLTextureSwizzleRed, MTLTextureSwizzleRed, MTLTextureSwizzleGreen);
// Only supported on some systems.
if (@available(macOS 10.15, iOS 13, *))
{
mtlformat = MTLPixelFormatRG8Unorm;
desc.swizzled = true;
desc.swizzle.red = MTLTextureSwizzleRed;
desc.swizzle.green = MTLTextureSwizzleRed;
desc.swizzle.blue = MTLTextureSwizzleRed;
desc.swizzle.alpha = MTLTextureSwizzleGreen;
}
break;
case PIXELFORMAT_RGBA4_UNORM: