diff --git a/src/Cafe/HW/Latte/Renderer/Metal/LatteToMtl.cpp b/src/Cafe/HW/Latte/Renderer/Metal/LatteToMtl.cpp index 581c0e19..daa283e4 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/LatteToMtl.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/LatteToMtl.cpp @@ -1,4 +1,5 @@ #include "Cafe/HW/Latte/Renderer/Metal/LatteToMtl.h" +#include "Cemu/Logging/CemuLogging.h" #include "Common/precompiled.h" #include "Metal/MTLDepthStencil.hpp" #include "Metal/MTLPixelFormat.hpp" @@ -95,42 +96,40 @@ const MetalPixelFormatInfo GetMtlPixelFormatInfo(Latte::E_GX2SURFFMT format, boo else formatInfo = MTL_COLOR_FORMAT_TABLE[format]; - if (formatInfo.pixelFormat == MTL::PixelFormatInvalid) - { - printf("invalid pixel format: %u\n", (uint32)format); - } - return formatInfo; } MTL::PixelFormat GetMtlPixelFormat(Latte::E_GX2SURFFMT format, bool isDepth, const MetalPixelFormatSupport& pixelFormatSupport) { 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) - pixelFormat = MTL::PixelFormatRGBA8Unorm_sRGB; - - if (!pixelFormatSupport.m_supportsRG8Unorm_sRGB && pixelFormat == MTL::PixelFormatRG8Unorm_sRGB) - pixelFormat = MTL::PixelFormatRGBA8Unorm_sRGB; - - if (!pixelFormatSupport.m_supportsPacked16BitFormats) + switch (pixelFormat) { - switch (pixelFormat) - { - case MTL::PixelFormatB5G6R5Unorm: - case MTL::PixelFormatA1BGR5Unorm: - case MTL::PixelFormatABGR4Unorm: - case MTL::PixelFormatBGR5A1Unorm: - pixelFormat = MTL::PixelFormatRGBA8Unorm; - break; - default: - break; - } + case MTL::PixelFormatR8Unorm_sRGB: + if (!pixelFormatSupport.m_supportsR8Unorm_sRGB) + return MTL::PixelFormatRGBA8Unorm_sRGB; + break; + case MTL::PixelFormatRG8Unorm_sRGB: + if (!pixelFormatSupport.m_supportsRG8Unorm_sRGB) + return MTL::PixelFormatRGBA8Unorm_sRGB; + break; + case MTL::PixelFormatB5G6R5Unorm: + 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; } diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalCommon.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalCommon.h index ede0bed6..8a6daa92 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalCommon.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalCommon.h @@ -18,7 +18,7 @@ struct MetalPixelFormatSupport m_supportsR8Unorm_sRGB = device->supportsFamily(MTL::GPUFamilyApple1); m_supportsRG8Unorm_sRGB = device->supportsFamily(MTL::GPUFamilyApple1); m_supportsPacked16BitFormats = device->supportsFamily(MTL::GPUFamilyApple1); - m_supportsDepth24Unorm_Stencil8 = device->supportsFamily(MTL::GPUFamilyMac2); + m_supportsDepth24Unorm_Stencil8 = device->depth24Stencil8PixelFormatSupported(); } };