Browse Source

Minor cleanup of some metal helper code

Alex Szpakowski 5 years ago
parent
commit
7c1a344c23

+ 0 - 1
src/modules/graphics/metal/Metal.h

@@ -36,7 +36,6 @@ class Metal
 {
 {
 public:
 public:
 
 
-	static MTLTextureType getTextureType(TextureType type, int msaa);
 	static MTLPixelFormat convertPixelFormat(PixelFormat format, bool &isSRGB);
 	static MTLPixelFormat convertPixelFormat(PixelFormat format, bool &isSRGB);
 
 
 }; // Metal
 }; // Metal

+ 0 - 13
src/modules/graphics/metal/Metal.mm

@@ -28,19 +28,6 @@ namespace graphics
 namespace metal
 namespace metal
 {
 {
 
 
-MTLTextureType Metal::getTextureType(TextureType type, int msaa)
-{
-	switch (type)
-	{
-		case TEXTURE_2D: return msaa > 1 ? MTLTextureType2DMultisample : MTLTextureType2D;
-		case TEXTURE_VOLUME: return MTLTextureType3D;
-		case TEXTURE_2D_ARRAY: return MTLTextureType2DArray;
-		case TEXTURE_CUBE: return MTLTextureTypeCube;
-		case TEXTURE_MAX_ENUM: return MTLTextureType2D;
-	}
-	return MTLTextureType2D;
-}
-
 MTLPixelFormat Metal::convertPixelFormat(PixelFormat format, bool &isSRGB)
 MTLPixelFormat Metal::convertPixelFormat(PixelFormat format, bool &isSRGB)
 {
 {
 	MTLPixelFormat mtlformat = MTLPixelFormatRGBA8Unorm;
 	MTLPixelFormat mtlformat = MTLPixelFormatRGBA8Unorm;

+ 15 - 2
src/modules/graphics/metal/Texture.mm

@@ -28,6 +28,19 @@ namespace graphics
 namespace metal
 namespace metal
 {
 {
 
 
+static MTLTextureType getMTLTextureType(TextureType type, int msaa)
+{
+	switch (type)
+	{
+		case TEXTURE_2D: return msaa > 1 ? MTLTextureType2DMultisample : MTLTextureType2D;
+		case TEXTURE_VOLUME: return MTLTextureType3D;
+		case TEXTURE_2D_ARRAY: return MTLTextureType2DArray;
+		case TEXTURE_CUBE: return MTLTextureTypeCube;
+		case TEXTURE_MAX_ENUM: return MTLTextureType2D;
+	}
+	return MTLTextureType2D;
+}
+
 Texture::Texture(id<MTLDevice> device, const Settings &settings, const Slices *data)
 Texture::Texture(id<MTLDevice> device, const Settings &settings, const Slices *data)
 	: love::graphics::Texture(settings, data)
 	: love::graphics::Texture(settings, data)
 	, texture(nil)
 	, texture(nil)
@@ -44,7 +57,7 @@ Texture::Texture(id<MTLDevice> device, const Settings &settings, const Slices *d
 	desc.depth = depth;
 	desc.depth = depth;
 	desc.arrayLength = layers;
 	desc.arrayLength = layers;
 	desc.mipmapLevelCount = mipmapCount;
 	desc.mipmapLevelCount = mipmapCount;
-	desc.textureType = Metal::getTextureType(texType, 1);
+	desc.textureType = getMTLTextureType(texType, 1);
 	desc.pixelFormat = Metal::convertPixelFormat(format, sRGB);
 	desc.pixelFormat = Metal::convertPixelFormat(format, sRGB);
 	desc.storageMode = MTLStorageModePrivate;
 	desc.storageMode = MTLStorageModePrivate;
 
 
@@ -62,7 +75,7 @@ Texture::Texture(id<MTLDevice> device, const Settings &settings, const Slices *d
 	{
 	{
 		// TODO: sampleCount validation
 		// TODO: sampleCount validation
 		desc.sampleCount = getRequestedMSAA();
 		desc.sampleCount = getRequestedMSAA();
-		desc.textureType = Metal::getTextureType(texType, (int)desc.sampleCount);
+		desc.textureType = getMTLTextureType(texType, (int)desc.sampleCount);
 		desc.usage &= ~MTLTextureUsageShaderRead;
 		desc.usage &= ~MTLTextureUsageShaderRead;
 
 
 		// TODO: This needs to be cleared, etc.
 		// TODO: This needs to be cleared, etc.