From 9fe1b9d03ff89faeb210a577baad4aee0e49fedb Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Fri, 7 Aug 2020 09:52:25 +0100 Subject: [PATCH] [d3d9] Replace macropixel size with plane count --- src/d3d9/d3d9_common_texture.cpp | 11 ++++------- src/d3d9/d3d9_common_texture.h | 4 +--- src/d3d9/d3d9_format.cpp | 12 ++++++------ src/d3d9/d3d9_format.h | 2 +- src/d3d9/d3d9_format_helpers.cpp | 17 +++++++++-------- src/d3d9/d3d9_format_helpers.h | 3 ++- 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/d3d9/d3d9_common_texture.cpp b/src/d3d9/d3d9_common_texture.cpp index 679bd69e..49cf03ff 100644 --- a/src/d3d9/d3d9_common_texture.cpp +++ b/src/d3d9/d3d9_common_texture.cpp @@ -19,9 +19,6 @@ namespace dxvk { m_mapping = pDevice->LookupFormat(m_desc.Format); - auto pxSize = m_mapping.ConversionFormatInfo.MacroPixelSize; - m_adjustedExtent = VkExtent3D{ m_desc.Width / pxSize.width, m_desc.Height / pxSize.height, m_desc.Depth }; - m_mapMode = DetermineMapMode(); m_shadow = DetermineShadowState(); @@ -185,15 +182,15 @@ namespace dxvk { : m_device->UnsupportedFormatInfo(m_desc.Format); const VkExtent3D mipExtent = util::computeMipLevelExtent( - m_adjustedExtent, MipLevel); + GetExtent(), MipLevel); const VkExtent3D blockCount = util::computeBlockCount( mipExtent, formatInfo.blockSize); - const uint32_t planeCount = m_mapping.ConversionFormatInfo.MacroPixelSize.depth; + const uint32_t planeCount = m_mapping.ConversionFormatInfo.PlaneCount; - return formatInfo.elementSize - * planeCount + return planeCount + * formatInfo.elementSize * blockCount.width * blockCount.height * blockCount.depth; diff --git a/src/d3d9/d3d9_common_texture.h b/src/d3d9/d3d9_common_texture.h index 8157b7a8..ea60b113 100644 --- a/src/d3d9/d3d9_common_texture.h +++ b/src/d3d9/d3d9_common_texture.h @@ -280,7 +280,7 @@ namespace dxvk { * \returns The extent of the top-level mip */ VkExtent3D GetExtent() const { - return m_adjustedExtent; + return VkExtent3D{ m_desc.Width, m_desc.Height, m_desc.Depth }; } /** @@ -382,8 +382,6 @@ namespace dxvk { D3D9_VK_FORMAT_MAPPING m_mapping; - VkExtent3D m_adjustedExtent; - bool m_shadow; //< Depth Compare-ness int64_t m_size = 0; diff --git a/src/d3d9/d3d9_format.cpp b/src/d3d9/d3d9_format.cpp index 9a52b414..34ab9079 100644 --- a/src/d3d9/d3d9_format.cpp +++ b/src/d3d9/d3d9_format.cpp @@ -136,7 +136,7 @@ namespace dxvk { VK_IMAGE_ASPECT_COLOR_BIT, { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }, - { D3D9ConversionFormat_L6V5U5, { 1u, 1u }, + { D3D9ConversionFormat_L6V5U5, 1u, // Convert -> float (this is a mixed snorm and unorm type) VK_FORMAT_R16G16B16A16_SFLOAT } }; @@ -146,7 +146,7 @@ namespace dxvk { VK_IMAGE_ASPECT_COLOR_BIT, { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ONE }, - { D3D9ConversionFormat_X8L8V8U8, { 1u, 1u }, + { D3D9ConversionFormat_X8L8V8U8, 1u, // Convert -> float (this is a mixed snorm and unorm type) VK_FORMAT_R16G16B16A16_SFLOAT } }; @@ -168,7 +168,7 @@ namespace dxvk { VK_IMAGE_ASPECT_COLOR_BIT, { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }, - { D3D9ConversionFormat_A2W10V10U10, { 1u, 1u }, + { D3D9ConversionFormat_A2W10V10U10, 1u, // Convert -> float (this is a mixed snorm and unorm type) VK_FORMAT_R16G16B16A16_SFLOAT } }; @@ -178,7 +178,7 @@ namespace dxvk { VK_IMAGE_ASPECT_COLOR_BIT, { VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY }, - { D3D9ConversionFormat_UYVY, { 2u, 1u } } + { D3D9ConversionFormat_UYVY, 1u } }; case D3D9Format::R8G8_B8G8: return { @@ -192,7 +192,7 @@ namespace dxvk { VK_IMAGE_ASPECT_COLOR_BIT, { VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY }, - { D3D9ConversionFormat_YUY2, { 2u, 1u } } + { D3D9ConversionFormat_YUY2, 1u } }; case D3D9Format::G8R8_G8B8: return { @@ -412,7 +412,7 @@ namespace dxvk { VK_IMAGE_ASPECT_COLOR_BIT, { VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY }, - { D3D9ConversionFormat_NV12, { 1u, 1u, 2u }, VK_FORMAT_B8G8R8A8_UNORM } + { D3D9ConversionFormat_NV12, 2u, VK_FORMAT_B8G8R8A8_UNORM } }; case D3D9Format::RAWZ: return {}; // Unsupported diff --git a/src/d3d9/d3d9_format.h b/src/d3d9/d3d9_format.h index ab722134..9cc4c350 100644 --- a/src/d3d9/d3d9_format.h +++ b/src/d3d9/d3d9_format.h @@ -140,7 +140,7 @@ namespace dxvk { struct D3D9_CONVERSION_FORMAT_INFO { D3D9ConversionFormat FormatType = D3D9ConversionFormat_None; - VkExtent3D MacroPixelSize = { 1u, 1u, 1u }; + uint32_t PlaneCount = 1; VkFormat FormatColor = VK_FORMAT_UNDEFINED; VkFormat FormatSrgb = VK_FORMAT_UNDEFINED; }; diff --git a/src/d3d9/d3d9_format_helpers.cpp b/src/d3d9/d3d9_format_helpers.cpp index 564f30eb..047e058f 100644 --- a/src/d3d9/d3d9_format_helpers.cpp +++ b/src/d3d9/d3d9_format_helpers.cpp @@ -32,24 +32,24 @@ namespace dxvk { case D3D9ConversionFormat_YUY2: case D3D9ConversionFormat_UYVY: { uint32_t specConstant = conversionFormat.FormatType == D3D9ConversionFormat_UYVY ? 1 : 0; - ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, specConstant); + ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, specConstant, { 2u, 1u }); break; } case D3D9ConversionFormat_NV12: - ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R8_UINT, 0); + ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R8_UINT, 0, { 1u, 1u }); break; case D3D9ConversionFormat_L6V5U5: - ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R16_UINT, 0); + ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R16_UINT, 0, { 1u, 1u }); break; case D3D9ConversionFormat_X8L8V8U8: - ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, 0); + ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, 0, { 1u, 1u }); break; case D3D9ConversionFormat_A2W10V10U10: - ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, 0); + ConvertGenericFormat(conversionFormat, dstImage, dstSubresource, srcBuffer, VK_FORMAT_R32_UINT, 0, { 1u, 1u }); break; default: @@ -64,7 +64,8 @@ namespace dxvk { VkImageSubresourceLayers dstSubresource, const Rc& srcBuffer, VkFormat bufferFormat, - uint32_t specConstantValue) { + uint32_t specConstantValue, + VkExtent2D macroPixelRun) { DxvkImageViewCreateInfo imageViewInfo; imageViewInfo.type = VK_IMAGE_VIEW_TYPE_2D; imageViewInfo.format = dstImage->info().format; @@ -77,8 +78,8 @@ namespace dxvk { auto tmpImageView = m_device->createImageView(dstImage, imageViewInfo); VkExtent3D imageExtent = dstImage->mipLevelExtent(dstSubresource.mipLevel); - imageExtent = VkExtent3D{ imageExtent.width / videoFormat.MacroPixelSize.width, - imageExtent.height / videoFormat.MacroPixelSize.height, + imageExtent = VkExtent3D{ imageExtent.width / macroPixelRun.width, + imageExtent.height / macroPixelRun.height, 1 }; DxvkBufferViewCreateInfo bufferViewInfo; diff --git a/src/d3d9/d3d9_format_helpers.h b/src/d3d9/d3d9_format_helpers.h index b7f10c5c..08019842 100644 --- a/src/d3d9/d3d9_format_helpers.h +++ b/src/d3d9/d3d9_format_helpers.h @@ -29,7 +29,8 @@ namespace dxvk { VkImageSubresourceLayers dstSubresource, const Rc& srcBuffer, VkFormat bufferFormat, - uint32_t specConstantValue); + uint32_t specConstantValue, + VkExtent2D macroPixelRun); enum BindingIds : uint32_t { Image = 0,