mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
metal: fix a couple compiler warnings
This commit is contained in:
@@ -36,13 +36,14 @@ class Metal
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct PixelFormatDesc
|
struct API_AVAILABLE(macos(10.15), ios(13.0)) PixelFormatDesc
|
||||||
{
|
{
|
||||||
MTLPixelFormat format;
|
MTLPixelFormat format;
|
||||||
bool swizzled = false;
|
bool swizzled = false;
|
||||||
MTLTextureSwizzleChannels swizzle;
|
MTLTextureSwizzleChannels swizzle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
API_AVAILABLE(macos(10.15), ios(13.0))
|
||||||
static PixelFormatDesc convertPixelFormat(PixelFormat format, bool &isSRGB);
|
static PixelFormatDesc convertPixelFormat(PixelFormat format, bool &isSRGB);
|
||||||
|
|
||||||
}; // Metal
|
}; // Metal
|
||||||
|
|||||||
@@ -926,9 +926,14 @@ id<MTLRenderPipelineState> Shader::getCachedRenderPipeline(const RenderPipelineK
|
|||||||
|
|
||||||
MTLRenderPipelineColorAttachmentDescriptor *attachment = desc.colorAttachments[i];
|
MTLRenderPipelineColorAttachmentDescriptor *attachment = desc.colorAttachments[i];
|
||||||
|
|
||||||
bool isSRGB = false;
|
if (@available(macOS 10.15, iOS 13, *))
|
||||||
auto formatdesc = Metal::convertPixelFormat(format, isSRGB);
|
{
|
||||||
attachment.pixelFormat = formatdesc.format;
|
// We already don't really support metal on older systems, this just
|
||||||
|
// silences a compiler warning about it.
|
||||||
|
bool isSRGB = false;
|
||||||
|
auto formatdesc = Metal::convertPixelFormat(format, isSRGB);
|
||||||
|
attachment.pixelFormat = formatdesc.format;
|
||||||
|
}
|
||||||
|
|
||||||
if (key.blend.enable)
|
if (key.blend.enable)
|
||||||
{
|
{
|
||||||
@@ -959,12 +964,17 @@ id<MTLRenderPipelineState> Shader::getCachedRenderPipeline(const RenderPipelineK
|
|||||||
auto dsformat = (PixelFormat) key.depthStencilFormat;
|
auto dsformat = (PixelFormat) key.depthStencilFormat;
|
||||||
if (isPixelFormatDepthStencil(dsformat))
|
if (isPixelFormatDepthStencil(dsformat))
|
||||||
{
|
{
|
||||||
bool isSRGB = false;
|
if (@available(macOS 10.15, iOS 13, *))
|
||||||
auto formatdesc = Metal::convertPixelFormat(dsformat, isSRGB);
|
{
|
||||||
if (isPixelFormatDepth(dsformat))
|
// We already don't really support metal on older systems, this just
|
||||||
desc.depthAttachmentPixelFormat = formatdesc.format;
|
// silences a compiler warning about it.
|
||||||
if (isPixelFormatStencil(dsformat))
|
bool isSRGB = false;
|
||||||
desc.stencilAttachmentPixelFormat = formatdesc.format;
|
auto formatdesc = Metal::convertPixelFormat(dsformat, isSRGB);
|
||||||
|
if (isPixelFormatDepth(dsformat))
|
||||||
|
desc.depthAttachmentPixelFormat = formatdesc.format;
|
||||||
|
if (isPixelFormatStencil(dsformat))
|
||||||
|
desc.stencilAttachmentPixelFormat = formatdesc.format;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,17 +52,23 @@ Texture::Texture(love::graphics::Graphics *gfx, id<MTLDevice> device, const Sett
|
|||||||
int w = pixelWidth;
|
int w = pixelWidth;
|
||||||
int h = pixelHeight;
|
int h = pixelHeight;
|
||||||
|
|
||||||
auto formatdesc = Metal::convertPixelFormat(format, sRGB);
|
|
||||||
|
|
||||||
desc.width = w;
|
desc.width = w;
|
||||||
desc.height = h;
|
desc.height = h;
|
||||||
desc.depth = depth;
|
desc.depth = depth;
|
||||||
desc.arrayLength = layers;
|
desc.arrayLength = layers;
|
||||||
desc.mipmapLevelCount = mipmapCount;
|
desc.mipmapLevelCount = mipmapCount;
|
||||||
desc.textureType = getMTLTextureType(texType, 1);
|
desc.textureType = getMTLTextureType(texType, 1);
|
||||||
desc.pixelFormat = formatdesc.format;
|
if (@available(macOS 10.15, iOS 13, *))
|
||||||
if (formatdesc.swizzled)
|
{
|
||||||
desc.swizzle = formatdesc.swizzle;
|
// We already don't really support metal on older systems, this just
|
||||||
|
// silences a compiler warning about it.
|
||||||
|
auto formatdesc = Metal::convertPixelFormat(format, sRGB);
|
||||||
|
desc.pixelFormat = formatdesc.format;
|
||||||
|
if (formatdesc.swizzled)
|
||||||
|
desc.swizzle = formatdesc.swizzle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw love::Exception("Metal backend is only supported on macOS 10.15+ and iOS 13+.");
|
||||||
desc.storageMode = MTLStorageModePrivate;
|
desc.storageMode = MTLStorageModePrivate;
|
||||||
|
|
||||||
if (readable)
|
if (readable)
|
||||||
|
|||||||
Reference in New Issue
Block a user