metal: remove unused legacy code for old OS support

This commit is contained in:
Sasha Szpakowski
2026-07-01 14:35:41 -03:00
parent cad88c0098
commit 0f95aea730
5 changed files with 57 additions and 88 deletions
+39 -53
View File
@@ -286,31 +286,24 @@ Graphics::Graphics()
, families()
, isVMDevice(false)
{ @autoreleasepool {
if (@available(macOS 10.15, iOS 13.0, *))
{
graphicsInstance = this;
graphicsInstance = this;
#ifdef LOVE_MACOS
if (isLowPowerPreferred())
if (isLowPowerPreferred())
{
for (id<MTLDevice> dev in MTLCopyAllDevices())
{
for (id<MTLDevice> dev in MTLCopyAllDevices())
if (dev.isLowPower)
{
if (dev.isLowPower)
{
device = dev;
break;
}
device = dev;
break;
}
}
}
#endif
if (device == nil)
device = MTLCreateSystemDefaultDevice();
if (device == nil)
throw love::Exception("Metal is not supported on this system.");
}
else
{
throw love::Exception("LOVE's Metal graphics backend requires macOS 10.15+ or iOS 13+.");
}
if (device == nil)
device = MTLCreateSystemDefaultDevice();
if (device == nil)
throw love::Exception("Metal is not supported on this system.");
isVMDevice = [device.name containsString:@("Apple Paravirtual device")];
@@ -1942,16 +1935,12 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage)
flags |= all;
break;
case PIXELFORMAT_LA8_UNORM:
// Requires texture swizzle support.
if (@available(macOS 10.15, iOS 13, *))
// As of early 2024, the VM device doesn't properly support texture swizzles
// (observed on GitHub's runners) which is required for LA8 support.
if (!isVMDevice)
{
// As of early 2024, the VM device doesn't properly support texture swizzles
// (observed on GitHub's runners) which is required for LA8 support.
if (!isVMDevice)
{
if (families.apple[1] || families.mac[2] || families.macCatalyst[2])
flags |= commonsample;
}
if (families.apple[1] || families.mac[2] || families.macCatalyst[2])
flags |= commonsample;
}
break;
case PIXELFORMAT_RG16_UNORM:
@@ -2207,35 +2196,32 @@ int Graphics::getClosestMSAASamples(int requestedsamples)
void Graphics::initCapabilities()
{
if (@available(macOS 10.15, iOS 13.0, *))
for (NSInteger i = 0; i < 7; i++)
{
for (NSInteger i = 0; i < 7; i++)
{
MTLGPUFamily family = (MTLGPUFamily) (MTLGPUFamilyApple1 + i);
if ([device supportsFamily:family])
families.apple[1 + i] = true;
}
MTLGPUFamily family = (MTLGPUFamily) (MTLGPUFamilyApple1 + i);
if ([device supportsFamily:family])
families.apple[1 + i] = true;
}
for (NSInteger i = 0; i < 2; i++)
{
MTLGPUFamily family = (MTLGPUFamily) (MTLGPUFamilyMac1 + i);
if ([device supportsFamily:family])
families.mac[1 + i] = true;
}
for (NSInteger i = 0; i < 2; i++)
{
MTLGPUFamily family = (MTLGPUFamily) (MTLGPUFamilyMac1 + i);
if ([device supportsFamily:family])
families.mac[1 + i] = true;
}
for (NSInteger i = 0; i < 3; i++)
{
MTLGPUFamily family = (MTLGPUFamily) (MTLGPUFamilyCommon1 + i);
if ([device supportsFamily:family])
families.common[1 + i] = true;
}
for (NSInteger i = 0; i < 3; i++)
{
MTLGPUFamily family = (MTLGPUFamily) (MTLGPUFamilyCommon1 + i);
if ([device supportsFamily:family])
families.common[1 + i] = true;
}
for (NSInteger i = 0; i < 2; i++)
{
MTLGPUFamily family = (MTLGPUFamily) (MTLGPUFamilyMacCatalyst1 + i);
if ([device supportsFamily:family])
families.macCatalyst[1 + i] = true;
}
for (NSInteger i = 0; i < 2; i++)
{
MTLGPUFamily family = (MTLGPUFamily) (MTLGPUFamilyMacCatalyst1 + i);
if ([device supportsFamily:family])
families.macCatalyst[1 + i] = true;
}
capabilities.features[FEATURE_MULTI_RENDER_TARGET_FORMATS] = true;
+1 -1
View File
@@ -40,7 +40,7 @@ public:
{
MTLPixelFormat format;
bool swizzled = false;
API_AVAILABLE(macos(10.15), ios(13.0)) MTLTextureSwizzleChannels swizzle;
MTLTextureSwizzleChannels swizzle;
};
static PixelFormatDesc convertPixelFormat(id<MTLDevice> device, PixelFormat format);
+6 -10
View File
@@ -137,16 +137,12 @@ Metal::PixelFormatDesc Metal::convertPixelFormat(id<MTLDevice> device, PixelForm
break;
case PIXELFORMAT_LA8_UNORM:
// 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;
}
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:
+5 -10
View File
@@ -859,16 +859,11 @@ id<MTLRenderPipelineState> Shader::getCachedRenderPipeline(graphics::Graphics *g
auto dsformat = (PixelFormat) key.depthStencilFormat;
if (isPixelFormatDepthStencil(dsformat))
{
if (@available(macOS 10.15, iOS 13, *))
{
// We already don't really support metal on older systems, this just
// silences a compiler warning about it.
auto formatdesc = Metal::convertPixelFormat(device, dsformat);
if (isPixelFormatDepth(dsformat))
desc.depthAttachmentPixelFormat = formatdesc.format;
if (isPixelFormatStencil(dsformat))
desc.stencilAttachmentPixelFormat = formatdesc.format;
}
auto formatdesc = Metal::convertPixelFormat(device, dsformat);
if (isPixelFormatDepth(dsformat))
desc.depthAttachmentPixelFormat = formatdesc.format;
if (isPixelFormatStencil(dsformat))
desc.stencilAttachmentPixelFormat = formatdesc.format;
}
VertexAttributes attributes;
+6 -14
View File
@@ -61,12 +61,7 @@ Texture::Texture(love::graphics::Graphics *gfxbase, id<MTLDevice> device, const
auto formatdesc = Metal::convertPixelFormat(device, format);
desc.pixelFormat = formatdesc.format;
if (formatdesc.swizzled)
{
// Swizzled formats are already only used on supported systems, this
// just silences a compiler warning about it.
if (@available(macOS 10.15, iOS 13, *))
desc.swizzle = formatdesc.swizzle;
}
desc.swizzle = formatdesc.swizzle;
desc.storageMode = MTLStorageModePrivate;
@@ -228,14 +223,11 @@ Texture::Texture(love::graphics::Graphics *gfx, id<MTLDevice> device, love::grap
if (formatdesc.swizzled)
{
if (@available(macOS 10.15, iOS 13, *))
{
texture = [basetex newTextureViewWithPixelFormat:formatdesc.format
textureType:getMTLTextureType(texType, 1)
levels:NSMakeRange(parentView.startMipmap, mipmapCount)
slices:NSMakeRange(parentView.startLayer, slices)
swizzle:formatdesc.swizzle];
}
texture = [basetex newTextureViewWithPixelFormat:formatdesc.format
textureType:getMTLTextureType(texType, 1)
levels:NSMakeRange(parentView.startMipmap, mipmapCount)
slices:NSMakeRange(parentView.startLayer, slices)
swizzle:formatdesc.swizzle];
}
else
{