mirror of https://github.com/cemu-project/Cemu.git
MoltenVK: Workaround for unsupported formats (#315)
This commit is contained in:
parent
3767257220
commit
ecfbbd4e26
|
@ -1929,6 +1929,20 @@ void VulkanRenderer::QueryAvailableFormats()
|
||||||
{
|
{
|
||||||
m_supportedFormatInfo.fmt_r4g4_unorm_pack = true;
|
m_supportedFormatInfo.fmt_r4g4_unorm_pack = true;
|
||||||
}
|
}
|
||||||
|
// R4G4B4A4
|
||||||
|
fmtProp = {};
|
||||||
|
vkGetPhysicalDeviceFormatProperties(m_physical_device, VK_FORMAT_R4G4B4A4_UNORM_PACK16, &fmtProp);
|
||||||
|
if (fmtProp.optimalTilingFeatures != 0)
|
||||||
|
{
|
||||||
|
m_supportedFormatInfo.fmt_r4g4b4a4_unorm_pack = true;
|
||||||
|
}
|
||||||
|
// A1R5G5B5
|
||||||
|
fmtProp = {};
|
||||||
|
vkGetPhysicalDeviceFormatProperties(m_physical_device, VK_FORMAT_A1R5G5B5_UNORM_PACK16, &fmtProp);
|
||||||
|
if (fmtProp.optimalTilingFeatures != 0)
|
||||||
|
{
|
||||||
|
m_supportedFormatInfo.fmt_a1r5g5b5_unorm_pack = true;
|
||||||
|
}
|
||||||
// print info about unsupported formats to log
|
// print info about unsupported formats to log
|
||||||
for (auto& it : requestedFormatList)
|
for (auto& it : requestedFormatList)
|
||||||
{
|
{
|
||||||
|
@ -2565,9 +2579,15 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
|
||||||
case Latte::E_GX2SURFFMT::R4_G4_UNORM:
|
case Latte::E_GX2SURFFMT::R4_G4_UNORM:
|
||||||
if (m_supportedFormatInfo.fmt_r4g4_unorm_pack == false)
|
if (m_supportedFormatInfo.fmt_r4g4_unorm_pack == false)
|
||||||
{
|
{
|
||||||
|
if (m_supportedFormatInfo.fmt_r4g4b4a4_unorm_pack == false) {
|
||||||
|
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
formatInfoOut->decoder = nullptr;
|
||||||
|
}
|
||||||
|
else {
|
||||||
formatInfoOut->vkImageFormat = VK_FORMAT_R4G4B4A4_UNORM_PACK16;
|
formatInfoOut->vkImageFormat = VK_FORMAT_R4G4B4A4_UNORM_PACK16;
|
||||||
formatInfoOut->decoder = TextureDecoder_R4_G4_UNORM_toRGBA4444_vk::getInstance();
|
formatInfoOut->decoder = TextureDecoder_R4_G4_UNORM_toRGBA4444_vk::getInstance();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
formatInfoOut->vkImageFormat = VK_FORMAT_R4G4_UNORM_PACK8;
|
formatInfoOut->vkImageFormat = VK_FORMAT_R4G4_UNORM_PACK8;
|
||||||
|
@ -2618,23 +2638,41 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
|
||||||
formatInfoOut->decoder = TextureDecoder_R5_G6_B5_swappedRB::getInstance();
|
formatInfoOut->decoder = TextureDecoder_R5_G6_B5_swappedRB::getInstance();
|
||||||
break;
|
break;
|
||||||
case Latte::E_GX2SURFFMT::R5_G5_B5_A1_UNORM:
|
case Latte::E_GX2SURFFMT::R5_G5_B5_A1_UNORM:
|
||||||
|
if (m_supportedFormatInfo.fmt_a1r5g5b5_unorm_pack == false) {
|
||||||
|
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
formatInfoOut->decoder = nullptr;
|
||||||
|
}
|
||||||
|
else {
|
||||||
// used in Super Mario 3D World for the hidden Luigi sprites
|
// used in Super Mario 3D World for the hidden Luigi sprites
|
||||||
// since order of channels is reversed in Vulkan compared to GX2 the format we need is A1B5G5R5
|
// since order of channels is reversed in Vulkan compared to GX2 the format we need is A1B5G5R5
|
||||||
formatInfoOut->vkImageFormat = VK_FORMAT_A1R5G5B5_UNORM_PACK16;
|
formatInfoOut->vkImageFormat = VK_FORMAT_A1R5G5B5_UNORM_PACK16;
|
||||||
formatInfoOut->decoder = TextureDecoder_R5_G5_B5_A1_UNORM_swappedRB::getInstance();
|
formatInfoOut->decoder = TextureDecoder_R5_G5_B5_A1_UNORM_swappedRB::getInstance();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Latte::E_GX2SURFFMT::A1_B5_G5_R5_UNORM:
|
case Latte::E_GX2SURFFMT::A1_B5_G5_R5_UNORM:
|
||||||
|
if (m_supportedFormatInfo.fmt_a1r5g5b5_unorm_pack == false) {
|
||||||
|
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
formatInfoOut->decoder = nullptr;
|
||||||
|
}
|
||||||
|
else {
|
||||||
// used by VC64 (e.g. Ocarina of Time)
|
// used by VC64 (e.g. Ocarina of Time)
|
||||||
formatInfoOut->vkImageFormat = VK_FORMAT_A1R5G5B5_UNORM_PACK16; // A 15 R 10..14, G 5..9 B 0..4
|
formatInfoOut->vkImageFormat = VK_FORMAT_A1R5G5B5_UNORM_PACK16; // A 15 R 10..14, G 5..9 B 0..4
|
||||||
formatInfoOut->decoder = TextureDecoder_A1_B5_G5_R5_UNORM_vulkan::getInstance();
|
formatInfoOut->decoder = TextureDecoder_A1_B5_G5_R5_UNORM_vulkan::getInstance();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Latte::E_GX2SURFFMT::R11_G11_B10_FLOAT:
|
case Latte::E_GX2SURFFMT::R11_G11_B10_FLOAT:
|
||||||
formatInfoOut->vkImageFormat = VK_FORMAT_B10G11R11_UFLOAT_PACK32; // verify if order of channels is still the same as GX2
|
formatInfoOut->vkImageFormat = VK_FORMAT_B10G11R11_UFLOAT_PACK32; // verify if order of channels is still the same as GX2
|
||||||
formatInfoOut->decoder = TextureDecoder_R11_G11_B10_FLOAT::getInstance();
|
formatInfoOut->decoder = TextureDecoder_R11_G11_B10_FLOAT::getInstance();
|
||||||
break;
|
break;
|
||||||
case Latte::E_GX2SURFFMT::R4_G4_B4_A4_UNORM:
|
case Latte::E_GX2SURFFMT::R4_G4_B4_A4_UNORM:
|
||||||
formatInfoOut->vkImageFormat = VK_FORMAT_R4G4B4A4_UNORM_PACK16; // verify order of channels
|
if (m_supportedFormatInfo.fmt_r4g4b4a4_unorm_pack == false) {
|
||||||
|
formatInfoOut->vkImageFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
formatInfoOut->decoder = nullptr;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
formatInfoOut->vkImageFormat = VK_FORMAT_R4G4B4A4_UNORM_PACK16;
|
||||||
formatInfoOut->decoder = TextureDecoder_R4_G4_B4_A4_UNORM::getInstance();
|
formatInfoOut->decoder = TextureDecoder_R4_G4_B4_A4_UNORM::getInstance();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
// special formats - R10G10B10_A2
|
// special formats - R10G10B10_A2
|
||||||
case Latte::E_GX2SURFFMT::R10_G10_B10_A2_UNORM:
|
case Latte::E_GX2SURFFMT::R10_G10_B10_A2_UNORM:
|
||||||
|
|
|
@ -15,6 +15,8 @@ struct VkSupportedFormatInfo_t
|
||||||
{
|
{
|
||||||
bool fmt_d24_unorm_s8_uint{};
|
bool fmt_d24_unorm_s8_uint{};
|
||||||
bool fmt_r4g4_unorm_pack{};
|
bool fmt_r4g4_unorm_pack{};
|
||||||
|
bool fmt_r4g4b4a4_unorm_pack{};
|
||||||
|
bool fmt_a1r5g5b5_unorm_pack{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VkDescriptorSetInfo
|
struct VkDescriptorSetInfo
|
||||||
|
|
Loading…
Reference in New Issue