Browse Source

metal: improve detection of rgba32f format filter and MSAA support.

Alex Szpakowski 3 years ago
parent
commit
a5351e5046
2 changed files with 26 additions and 9 deletions
  1. 26 8
      src/modules/graphics/metal/Graphics.mm
  2. 0 1
      src/modules/graphics/metal/Texture.mm

+ 26 - 8
src/modules/graphics/metal/Graphics.mm

@@ -1785,6 +1785,7 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, PixelFormatUsageFlags
 		format = getSRGBPixelFormat(format);
 
 	const uint32 sample = PIXELFORMATUSAGEFLAGS_SAMPLE;
+	const uint32 filter = PIXELFORMATUSAGEFLAGS_LINEAR;
 	const uint32 rt = PIXELFORMATUSAGEFLAGS_RENDERTARGET;
 	const uint32 blend = PIXELFORMATUSAGEFLAGS_BLEND;
 	const uint32 msaa = PIXELFORMATUSAGEFLAGS_MSAA;
@@ -1820,9 +1821,16 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, PixelFormatUsageFlags
 			break;
 		case PIXELFORMAT_R32_FLOAT:
 			if (families.apple[1])
-				flags |= sample | rt | blend | msaa | computewrite;
+				flags |= sample | rt | blend | computewrite;
 			if (families.mac[1] || families.macCatalyst[1])
-				flags |= all;
+				flags |= (all & ~(msaa | filter));
+			if (@available(macOS 11.0, iOS 14.0, *))
+			{
+				if (device.supports32BitFloatFiltering)
+					flags |= filter;
+				if (device.supports32BitMSAA)
+					flags |= msaa;
+			}
 			break;
 
 		case PIXELFORMAT_RG8_UNORM:
@@ -1848,10 +1856,15 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, PixelFormatUsageFlags
 		case PIXELFORMAT_RG32_FLOAT:
 			if (families.apple[1])
 				flags |= sample | rt | blend | computewrite;
-			if (families.apple[7])
-				flags |= sample | rt | msaa | blend | computewrite;
 			if (families.mac[1] || families.macCatalyst[1])
-				flags |= all;
+				flags |= (all & ~(msaa | filter));
+			if (@available(macOS 11.0, iOS 14.0, *))
+			{
+				if (device.supports32BitFloatFiltering)
+					flags |= filter;
+				if (device.supports32BitMSAA)
+					flags |= msaa;
+			}
 			break;
 
 		case PIXELFORMAT_RGBA8_UNORM:
@@ -1878,10 +1891,15 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, PixelFormatUsageFlags
 		case PIXELFORMAT_RGBA32_FLOAT:
 			if (families.apple[1])
 				flags |= sample | rt | computewrite;
-			if (families.apple[7])
-				flags |= sample | rt | msaa | computewrite;
 			if (families.mac[1] || families.macCatalyst[1])
-				flags |= all;
+				flags |= (all & ~(msaa | filter));
+			if (@available(macOS 11.0, iOS 14.0, *))
+			{
+				if (device.supports32BitFloatFiltering)
+					flags |= filter;
+				if (device.supports32BitMSAA)
+					flags |= msaa;
+			}
 			break;
 
 		case PIXELFORMAT_R8_INT:

+ 0 - 1
src/modules/graphics/metal/Texture.mm

@@ -94,7 +94,6 @@ Texture::Texture(love::graphics::Graphics *gfxbase, id<MTLDevice> device, const
 		desc.textureType = getMTLTextureType(texType, actualMSAASamples);
 		desc.usage &= ~MTLTextureUsageShaderRead;
 
-		// TODO: This needs to be cleared, etc.
 		msaaTexture = [device newTextureWithDescriptor:desc];
 		if (msaaTexture == nil)
 		{