1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[d3d9] Return a pointer in GetUnsupportedFormatInfo

This commit is contained in:
Georg Lehmann 2021-08-23 17:08:35 +02:00 committed by Joshie
parent fa4f40a0e6
commit 82d40f5bba
6 changed files with 31 additions and 20 deletions

View File

@ -83,7 +83,7 @@ namespace dxvk {
return m_d3d9Formats.GetFormatMapping(Format); return m_d3d9Formats.GetFormatMapping(Format);
} }
DxvkFormatInfo GetUnsupportedFormatInfo(D3D9Format Format) const { const DxvkFormatInfo* GetUnsupportedFormatInfo(D3D9Format Format) const {
return m_d3d9Formats.GetUnsupportedFormatInfo(Format); return m_d3d9Formats.GetUnsupportedFormatInfo(Format);
} }

View File

@ -112,7 +112,7 @@ namespace dxvk {
if (!mapping.IsValid() && pDesc->Format != D3D9Format::NULL_FORMAT) { if (!mapping.IsValid() && pDesc->Format != D3D9Format::NULL_FORMAT) {
auto info = pDevice->UnsupportedFormatInfo(pDesc->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; return D3DERR_INVALIDCALL;
} }
@ -186,20 +186,20 @@ namespace dxvk {
VkDeviceSize D3D9CommonTexture::GetMipSize(UINT Subresource) const { VkDeviceSize D3D9CommonTexture::GetMipSize(UINT Subresource) const {
const UINT MipLevel = Subresource % m_desc.MipLevels; const UINT MipLevel = Subresource % m_desc.MipLevels;
const DxvkFormatInfo formatInfo = m_mapping.FormatColor != VK_FORMAT_UNDEFINED const DxvkFormatInfo* formatInfo = m_mapping.FormatColor != VK_FORMAT_UNDEFINED
? *imageFormatInfo(m_mapping.FormatColor) ? imageFormatInfo(m_mapping.FormatColor)
: m_device->UnsupportedFormatInfo(m_desc.Format); : m_device->UnsupportedFormatInfo(m_desc.Format);
const VkExtent3D mipExtent = util::computeMipLevelExtent( const VkExtent3D mipExtent = util::computeMipLevelExtent(
GetExtent(), MipLevel); GetExtent(), MipLevel);
const VkExtent3D blockCount = util::computeBlockCount( const VkExtent3D blockCount = util::computeBlockCount(
mipExtent, formatInfo.blockSize); mipExtent, formatInfo->blockSize);
const uint32_t planeCount = m_mapping.ConversionFormatInfo.PlaneCount; const uint32_t planeCount = m_mapping.ConversionFormatInfo.PlaneCount;
return std::min(planeCount, 2u) return std::min(planeCount, 2u)
* align(formatInfo.elementSize * blockCount.width, 4) * align(formatInfo->elementSize * blockCount.width, 4)
* blockCount.height * blockCount.height
* blockCount.depth; * blockCount.depth;
} }

View File

@ -4004,7 +4004,7 @@ namespace dxvk {
return m_adapter->GetFormatMapping(Format); return m_adapter->GetFormatMapping(Format);
} }
DxvkFormatInfo D3D9DeviceEx::UnsupportedFormatInfo( const DxvkFormatInfo* D3D9DeviceEx::UnsupportedFormatInfo(
D3D9Format Format) const { D3D9Format Format) const {
return m_adapter->GetUnsupportedFormatInfo(Format); return m_adapter->GetUnsupportedFormatInfo(Format);
} }

View File

@ -657,7 +657,7 @@ namespace dxvk {
D3D9_VK_FORMAT_MAPPING LookupFormat( D3D9_VK_FORMAT_MAPPING LookupFormat(
D3D9Format Format) const; D3D9Format Format) const;
DxvkFormatInfo UnsupportedFormatInfo( const DxvkFormatInfo* UnsupportedFormatInfo(
D3D9Format Format) const; D3D9Format Format) const;
bool WaitForResource( bool WaitForResource(

View File

@ -502,44 +502,55 @@ namespace dxvk {
} }
DxvkFormatInfo D3D9VkFormatTable::GetUnsupportedFormatInfo( const DxvkFormatInfo* D3D9VkFormatTable::GetUnsupportedFormatInfo(
D3D9Format Format) const { 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) { switch (Format) {
case D3D9Format::R8G8B8: case D3D9Format::R8G8B8:
return { 3, VK_IMAGE_ASPECT_COLOR_BIT }; return &r8b8g8;
case D3D9Format::R3G3B2: case D3D9Format::R3G3B2:
return { 1, VK_IMAGE_ASPECT_COLOR_BIT }; return &r3g3b2;
case D3D9Format::A8R3G3B2: case D3D9Format::A8R3G3B2:
return { 2, VK_IMAGE_ASPECT_COLOR_BIT }; return &a8r3g3b2;
case D3D9Format::A8P8: case D3D9Format::A8P8:
return { 2, VK_IMAGE_ASPECT_COLOR_BIT }; return &a8p8;
case D3D9Format::P8: case D3D9Format::P8:
return { 1, VK_IMAGE_ASPECT_COLOR_BIT }; return &p8;
case D3D9Format::L6V5U5: case D3D9Format::L6V5U5:
return { 2, VK_IMAGE_ASPECT_COLOR_BIT }; return &l6v5u5;
case D3D9Format::X8L8V8U8: case D3D9Format::X8L8V8U8:
return { 4, VK_IMAGE_ASPECT_COLOR_BIT }; return &x8l8v8u8;
case D3D9Format::A2W10V10U10: case D3D9Format::A2W10V10U10:
return { 4, VK_IMAGE_ASPECT_COLOR_BIT }; return &a2w10v10u10;
// MULTI2_ARGB8 -> Don't have a clue what this is. // MULTI2_ARGB8 -> Don't have a clue what this is.
case D3D9Format::CxV8U8: case D3D9Format::CxV8U8:
return { 2, VK_IMAGE_ASPECT_COLOR_BIT }; return &cxv8u8;
// A1 -> Doesn't map nicely here cause it's not byte aligned. // A1 -> Doesn't map nicely here cause it's not byte aligned.
// Gonna just pretend that doesn't exist until something // Gonna just pretend that doesn't exist until something
// depends on that. // depends on that.
default: default:
return {}; return &unknown;
} }
} }

View File

@ -201,7 +201,7 @@ namespace dxvk {
* *
* \param [in] Format The D3D9 format to look up * \param [in] Format The D3D9 format to look up
*/ */
DxvkFormatInfo GetUnsupportedFormatInfo( const DxvkFormatInfo* GetUnsupportedFormatInfo(
D3D9Format Format) const; D3D9Format Format) const;
private: private: