MoltenVk: Workaround for unsupported format R5_G6_B5_UNORM (#318)

This commit is contained in:
emiyl 2022-09-30 17:07:00 +01:00 committed by GitHub
parent cceb4f6d0e
commit 9541c8ae85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -1929,6 +1929,13 @@ void VulkanRenderer::QueryAvailableFormats()
{ {
m_supportedFormatInfo.fmt_r4g4_unorm_pack = true; m_supportedFormatInfo.fmt_r4g4_unorm_pack = true;
} }
// R5G6B5
fmtProp = {};
vkGetPhysicalDeviceFormatProperties(m_physical_device, VK_FORMAT_R5G6B5_UNORM_PACK16, &fmtProp);
if (fmtProp.optimalTilingFeatures != 0)
{
m_supportedFormatInfo.fmt_r5g6b5_unorm_pack = true;
}
// R4G4B4A4 // R4G4B4A4
fmtProp = {}; fmtProp = {};
vkGetPhysicalDeviceFormatProperties(m_physical_device, VK_FORMAT_R4G4B4A4_UNORM_PACK16, &fmtProp); vkGetPhysicalDeviceFormatProperties(m_physical_device, VK_FORMAT_R4G4B4A4_UNORM_PACK16, &fmtProp);
@ -2633,9 +2640,15 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD
break; break;
// special formats // special formats
case Latte::E_GX2SURFFMT::R5_G6_B5_UNORM: case Latte::E_GX2SURFFMT::R5_G6_B5_UNORM:
// Vulkan has R in MSB, GPU7 has it in LSB if (m_supportedFormatInfo.fmt_r5g6b5_unorm_pack == false) {
formatInfoOut->vkImageFormat = VK_FORMAT_R5G6B5_UNORM_PACK16; formatInfoOut->vkImageFormat = VK_FORMAT_R8G8B8A8_UNORM;
formatInfoOut->decoder = TextureDecoder_R5_G6_B5_swappedRB::getInstance(); formatInfoOut->decoder = nullptr;
}
else {
// Vulkan has R in MSB, GPU7 has it in LSB
formatInfoOut->vkImageFormat = VK_FORMAT_R5G6B5_UNORM_PACK16;
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) { if (m_supportedFormatInfo.fmt_a1r5g5b5_unorm_pack == false) {

View File

@ -15,6 +15,7 @@ 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_r5g6b5_unorm_pack{};
bool fmt_r4g4b4a4_unorm_pack{}; bool fmt_r4g4b4a4_unorm_pack{};
bool fmt_a1r5g5b5_unorm_pack{}; bool fmt_a1r5g5b5_unorm_pack{};
}; };