mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-01 21:44:17 +01:00
refactor pixel format support
This commit is contained in:
parent
4251f3fe55
commit
6a3bdd49e9
@ -1,4 +1,5 @@
|
|||||||
#include "Cafe/HW/Latte/Renderer/Metal/LatteToMtl.h"
|
#include "Cafe/HW/Latte/Renderer/Metal/LatteToMtl.h"
|
||||||
|
#include "Cemu/Logging/CemuLogging.h"
|
||||||
#include "Common/precompiled.h"
|
#include "Common/precompiled.h"
|
||||||
#include "Metal/MTLDepthStencil.hpp"
|
#include "Metal/MTLDepthStencil.hpp"
|
||||||
#include "Metal/MTLPixelFormat.hpp"
|
#include "Metal/MTLPixelFormat.hpp"
|
||||||
@ -95,42 +96,40 @@ const MetalPixelFormatInfo GetMtlPixelFormatInfo(Latte::E_GX2SURFFMT format, boo
|
|||||||
else
|
else
|
||||||
formatInfo = MTL_COLOR_FORMAT_TABLE[format];
|
formatInfo = MTL_COLOR_FORMAT_TABLE[format];
|
||||||
|
|
||||||
if (formatInfo.pixelFormat == MTL::PixelFormatInvalid)
|
|
||||||
{
|
|
||||||
printf("invalid pixel format: %u\n", (uint32)format);
|
|
||||||
}
|
|
||||||
|
|
||||||
return formatInfo;
|
return formatInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTL::PixelFormat GetMtlPixelFormat(Latte::E_GX2SURFFMT format, bool isDepth, const MetalPixelFormatSupport& pixelFormatSupport)
|
MTL::PixelFormat GetMtlPixelFormat(Latte::E_GX2SURFFMT format, bool isDepth, const MetalPixelFormatSupport& pixelFormatSupport)
|
||||||
{
|
{
|
||||||
auto pixelFormat = GetMtlPixelFormatInfo(format, isDepth).pixelFormat;
|
auto pixelFormat = GetMtlPixelFormatInfo(format, isDepth).pixelFormat;
|
||||||
|
if (pixelFormat == MTL::PixelFormatInvalid)
|
||||||
|
cemuLog_logDebug(LogType::Force, "invalid pixel format {}\n", pixelFormat);
|
||||||
|
|
||||||
if (!pixelFormatSupport.m_supportsR8Unorm_sRGB && pixelFormat == MTL::PixelFormatR8Unorm_sRGB)
|
switch (pixelFormat)
|
||||||
pixelFormat = MTL::PixelFormatRGBA8Unorm_sRGB;
|
|
||||||
|
|
||||||
if (!pixelFormatSupport.m_supportsRG8Unorm_sRGB && pixelFormat == MTL::PixelFormatRG8Unorm_sRGB)
|
|
||||||
pixelFormat = MTL::PixelFormatRGBA8Unorm_sRGB;
|
|
||||||
|
|
||||||
if (!pixelFormatSupport.m_supportsPacked16BitFormats)
|
|
||||||
{
|
{
|
||||||
switch (pixelFormat)
|
case MTL::PixelFormatR8Unorm_sRGB:
|
||||||
{
|
if (!pixelFormatSupport.m_supportsR8Unorm_sRGB)
|
||||||
case MTL::PixelFormatB5G6R5Unorm:
|
return MTL::PixelFormatRGBA8Unorm_sRGB;
|
||||||
case MTL::PixelFormatA1BGR5Unorm:
|
break;
|
||||||
case MTL::PixelFormatABGR4Unorm:
|
case MTL::PixelFormatRG8Unorm_sRGB:
|
||||||
case MTL::PixelFormatBGR5A1Unorm:
|
if (!pixelFormatSupport.m_supportsRG8Unorm_sRGB)
|
||||||
pixelFormat = MTL::PixelFormatRGBA8Unorm;
|
return MTL::PixelFormatRGBA8Unorm_sRGB;
|
||||||
break;
|
break;
|
||||||
default:
|
case MTL::PixelFormatB5G6R5Unorm:
|
||||||
break;
|
case MTL::PixelFormatA1BGR5Unorm:
|
||||||
}
|
case MTL::PixelFormatABGR4Unorm:
|
||||||
|
case MTL::PixelFormatBGR5A1Unorm:
|
||||||
|
if (!pixelFormatSupport.m_supportsPacked16BitFormats)
|
||||||
|
return MTL::PixelFormatRGBA8Unorm;
|
||||||
|
break;
|
||||||
|
case MTL::PixelFormatDepth24Unorm_Stencil8:
|
||||||
|
if (!pixelFormatSupport.m_supportsDepth24Unorm_Stencil8)
|
||||||
|
return MTL::PixelFormatDepth32Float_Stencil8;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pixelFormatSupport.m_supportsDepth24Unorm_Stencil8 && pixelFormat == MTL::PixelFormatDepth24Unorm_Stencil8)
|
|
||||||
pixelFormat = MTL::PixelFormatDepth32Float_Stencil8;
|
|
||||||
|
|
||||||
return pixelFormat;
|
return pixelFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ struct MetalPixelFormatSupport
|
|||||||
m_supportsR8Unorm_sRGB = device->supportsFamily(MTL::GPUFamilyApple1);
|
m_supportsR8Unorm_sRGB = device->supportsFamily(MTL::GPUFamilyApple1);
|
||||||
m_supportsRG8Unorm_sRGB = device->supportsFamily(MTL::GPUFamilyApple1);
|
m_supportsRG8Unorm_sRGB = device->supportsFamily(MTL::GPUFamilyApple1);
|
||||||
m_supportsPacked16BitFormats = device->supportsFamily(MTL::GPUFamilyApple1);
|
m_supportsPacked16BitFormats = device->supportsFamily(MTL::GPUFamilyApple1);
|
||||||
m_supportsDepth24Unorm_Stencil8 = device->supportsFamily(MTL::GPUFamilyMac2);
|
m_supportsDepth24Unorm_Stencil8 = device->depth24Stencil8PixelFormatSupported();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user