diff --git a/src/d3d9/d3d9_adapter.h b/src/d3d9/d3d9_adapter.h index 854463a7..0cf74981 100644 --- a/src/d3d9/d3d9_adapter.h +++ b/src/d3d9/d3d9_adapter.h @@ -83,7 +83,7 @@ namespace dxvk { return m_d3d9Formats.GetFormatMapping(Format); } - DxvkFormatInfo GetUnsupportedFormatInfo(D3D9Format Format) const { + const DxvkFormatInfo* GetUnsupportedFormatInfo(D3D9Format Format) const { return m_d3d9Formats.GetUnsupportedFormatInfo(Format); } diff --git a/src/d3d9/d3d9_common_texture.cpp b/src/d3d9/d3d9_common_texture.cpp index fbc353ce..a44bb459 100644 --- a/src/d3d9/d3d9_common_texture.cpp +++ b/src/d3d9/d3d9_common_texture.cpp @@ -112,7 +112,7 @@ namespace dxvk { if (!mapping.IsValid() && pDesc->Format != D3D9Format::NULL_FORMAT) { auto info = pDevice->UnsupportedFormatInfo(pDesc->Format); - if (pDesc->Pool != D3DPOOL_SCRATCH || info.elementSize == 0) + if (pDesc->Pool != D3DPOOL_SCRATCH || info->elementSize == 0) return D3DERR_INVALIDCALL; } @@ -186,20 +186,20 @@ namespace dxvk { VkDeviceSize D3D9CommonTexture::GetMipSize(UINT Subresource) const { const UINT MipLevel = Subresource % m_desc.MipLevels; - const DxvkFormatInfo formatInfo = m_mapping.FormatColor != VK_FORMAT_UNDEFINED - ? *imageFormatInfo(m_mapping.FormatColor) + const DxvkFormatInfo* formatInfo = m_mapping.FormatColor != VK_FORMAT_UNDEFINED + ? imageFormatInfo(m_mapping.FormatColor) : m_device->UnsupportedFormatInfo(m_desc.Format); const VkExtent3D mipExtent = util::computeMipLevelExtent( GetExtent(), MipLevel); const VkExtent3D blockCount = util::computeBlockCount( - mipExtent, formatInfo.blockSize); + mipExtent, formatInfo->blockSize); const uint32_t planeCount = m_mapping.ConversionFormatInfo.PlaneCount; return std::min(planeCount, 2u) - * align(formatInfo.elementSize * blockCount.width, 4) + * align(formatInfo->elementSize * blockCount.width, 4) * blockCount.height * blockCount.depth; } diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index fea0e4d5..49627755 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4004,7 +4004,7 @@ namespace dxvk { return m_adapter->GetFormatMapping(Format); } - DxvkFormatInfo D3D9DeviceEx::UnsupportedFormatInfo( + const DxvkFormatInfo* D3D9DeviceEx::UnsupportedFormatInfo( D3D9Format Format) const { return m_adapter->GetUnsupportedFormatInfo(Format); } diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index 4f37ab85..be18542d 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -657,7 +657,7 @@ namespace dxvk { D3D9_VK_FORMAT_MAPPING LookupFormat( D3D9Format Format) const; - DxvkFormatInfo UnsupportedFormatInfo( + const DxvkFormatInfo* UnsupportedFormatInfo( D3D9Format Format) const; bool WaitForResource( diff --git a/src/d3d9/d3d9_format.cpp b/src/d3d9/d3d9_format.cpp index 5fe65f1a..424d0413 100644 --- a/src/d3d9/d3d9_format.cpp +++ b/src/d3d9/d3d9_format.cpp @@ -502,44 +502,55 @@ namespace dxvk { } - DxvkFormatInfo D3D9VkFormatTable::GetUnsupportedFormatInfo( + const DxvkFormatInfo* D3D9VkFormatTable::GetUnsupportedFormatInfo( D3D9Format Format) const { + static const DxvkFormatInfo r8b8g8 = { 3, VK_IMAGE_ASPECT_COLOR_BIT }; + static const DxvkFormatInfo r3g3b2 = { 1, VK_IMAGE_ASPECT_COLOR_BIT }; + static const DxvkFormatInfo a8r3g3b2 = { 2, VK_IMAGE_ASPECT_COLOR_BIT }; + static const DxvkFormatInfo a8p8 = { 2, VK_IMAGE_ASPECT_COLOR_BIT }; + static const DxvkFormatInfo p8 = { 1, VK_IMAGE_ASPECT_COLOR_BIT }; + static const DxvkFormatInfo l6v5u5 = { 2, VK_IMAGE_ASPECT_COLOR_BIT }; + static const DxvkFormatInfo x8l8v8u8 = { 4, VK_IMAGE_ASPECT_COLOR_BIT }; + static const DxvkFormatInfo a2w10v10u10 = { 4, VK_IMAGE_ASPECT_COLOR_BIT }; + static const DxvkFormatInfo cxv8u8 = { 2, VK_IMAGE_ASPECT_COLOR_BIT }; + static const DxvkFormatInfo unknown = {}; + switch (Format) { case D3D9Format::R8G8B8: - return { 3, VK_IMAGE_ASPECT_COLOR_BIT }; + return &r8b8g8; case D3D9Format::R3G3B2: - return { 1, VK_IMAGE_ASPECT_COLOR_BIT }; + return &r3g3b2; case D3D9Format::A8R3G3B2: - return { 2, VK_IMAGE_ASPECT_COLOR_BIT }; + return &a8r3g3b2; case D3D9Format::A8P8: - return { 2, VK_IMAGE_ASPECT_COLOR_BIT }; + return &a8p8; case D3D9Format::P8: - return { 1, VK_IMAGE_ASPECT_COLOR_BIT }; + return &p8; case D3D9Format::L6V5U5: - return { 2, VK_IMAGE_ASPECT_COLOR_BIT }; + return &l6v5u5; case D3D9Format::X8L8V8U8: - return { 4, VK_IMAGE_ASPECT_COLOR_BIT }; + return &x8l8v8u8; case D3D9Format::A2W10V10U10: - return { 4, VK_IMAGE_ASPECT_COLOR_BIT }; + return &a2w10v10u10; // MULTI2_ARGB8 -> Don't have a clue what this is. case D3D9Format::CxV8U8: - return { 2, VK_IMAGE_ASPECT_COLOR_BIT }; + return &cxv8u8; // A1 -> Doesn't map nicely here cause it's not byte aligned. // Gonna just pretend that doesn't exist until something // depends on that. default: - return {}; + return &unknown; } } diff --git a/src/d3d9/d3d9_format.h b/src/d3d9/d3d9_format.h index 5fecc5e5..732eb6e6 100644 --- a/src/d3d9/d3d9_format.h +++ b/src/d3d9/d3d9_format.h @@ -201,7 +201,7 @@ namespace dxvk { * * \param [in] Format The D3D9 format to look up */ - DxvkFormatInfo GetUnsupportedFormatInfo( + const DxvkFormatInfo* GetUnsupportedFormatInfo( D3D9Format Format) const; private: