diff --git a/src/d3d9/d3d9_format.cpp b/src/d3d9/d3d9_format.cpp index 34ab9079..eead1a73 100644 --- a/src/d3d9/d3d9_format.cpp +++ b/src/d3d9/d3d9_format.cpp @@ -39,11 +39,9 @@ namespace dxvk { VK_IMAGE_ASPECT_COLOR_BIT }; case D3D9Format::A4R4G4B4: return { - VK_FORMAT_B4G4R4A4_UNORM_PACK16, + VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT, VK_FORMAT_UNDEFINED, - VK_IMAGE_ASPECT_COLOR_BIT, - { VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_A, VK_COMPONENT_SWIZZLE_B }}; + VK_IMAGE_ASPECT_COLOR_BIT }; case D3D9Format::R3G3B2: return {}; // Unsupported @@ -57,11 +55,9 @@ namespace dxvk { case D3D9Format::A8R3G3B2: return {}; // Unsupported case D3D9Format::X4R4G4B4: return { - VK_FORMAT_B4G4R4A4_UNORM_PACK16, + VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT, VK_FORMAT_UNDEFINED, - VK_IMAGE_ASPECT_COLOR_BIT, - { VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_A, VK_COMPONENT_SWIZZLE_ONE }}; + VK_IMAGE_ASPECT_COLOR_BIT }; case D3D9Format::A2B10G10R10: return { VK_FORMAT_A2B10G10R10_UNORM_PACK32, // The A2 is out of place here. This should be investigated. @@ -442,6 +438,10 @@ namespace dxvk { VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); + // VK_EXT_4444_formats + m_a4r4g4b4Support = CheckImageFormatSupport(adapter, VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); + if (!m_d24s8Support) Logger::warn("D3D9: VK_FORMAT_D24_UNORM_S8_UINT -> VK_FORMAT_D32_SFLOAT_S8_UINT"); @@ -451,6 +451,9 @@ namespace dxvk { else Logger::warn("D3D9: VK_FORMAT_D16_UNORM_S8_UINT -> VK_FORMAT_D32_SFLOAT_S8_UINT"); } + + if (!m_a4r4g4b4Support) + Logger::warn("D3D9: VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT -> VK_FORMAT_B4G4R4A4_UNORM_PACK16"); } D3D9_VK_FORMAT_MAPPING D3D9VkFormatTable::GetFormatMapping( @@ -475,6 +478,17 @@ namespace dxvk { if (!m_d16s8Support && mapping.FormatColor == VK_FORMAT_D16_UNORM_S8_UINT) mapping.FormatColor = m_d24s8Support ? VK_FORMAT_D24_UNORM_S8_UINT : VK_FORMAT_D32_SFLOAT_S8_UINT; + if (!m_a4r4g4b4Support && mapping.FormatColor == VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT) { + VkComponentSwizzle alphaSwizzle = Format == D3D9Format::A4R4G4B4 + ? VK_COMPONENT_SWIZZLE_B + : VK_COMPONENT_SWIZZLE_ONE; + + mapping.FormatColor = VK_FORMAT_B4G4R4A4_UNORM_PACK16; + mapping.Swizzle = { + VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_A, alphaSwizzle }; + } + return mapping; } diff --git a/src/d3d9/d3d9_format.h b/src/d3d9/d3d9_format.h index 9cc4c350..ea4d9420 100644 --- a/src/d3d9/d3d9_format.h +++ b/src/d3d9/d3d9_format.h @@ -210,6 +210,7 @@ namespace dxvk { VkFormat Format, VkFormatFeatureFlags Features) const; + bool m_a4r4g4b4Support; bool m_d24s8Support; bool m_d16s8Support;