1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-21 13:54:18 +01:00

[d3d9] Replace macropixel size with plane count

This commit is contained in:
Joshua Ashton 2020-08-07 09:52:25 +01:00 committed by Joshie
parent 2bf9f298af
commit 9fe1b9d03f
6 changed files with 23 additions and 26 deletions

View File

@ -19,9 +19,6 @@ namespace dxvk {
m_mapping = pDevice->LookupFormat(m_desc.Format); 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_mapMode = DetermineMapMode();
m_shadow = DetermineShadowState(); m_shadow = DetermineShadowState();
@ -185,15 +182,15 @@ namespace dxvk {
: m_device->UnsupportedFormatInfo(m_desc.Format); : m_device->UnsupportedFormatInfo(m_desc.Format);
const VkExtent3D mipExtent = util::computeMipLevelExtent( const VkExtent3D mipExtent = util::computeMipLevelExtent(
m_adjustedExtent, 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.MacroPixelSize.depth; const uint32_t planeCount = m_mapping.ConversionFormatInfo.PlaneCount;
return formatInfo.elementSize return planeCount
* planeCount * formatInfo.elementSize
* blockCount.width * blockCount.width
* blockCount.height * blockCount.height
* blockCount.depth; * blockCount.depth;

View File

@ -280,7 +280,7 @@ namespace dxvk {
* \returns The extent of the top-level mip * \returns The extent of the top-level mip
*/ */
VkExtent3D GetExtent() const { 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; D3D9_VK_FORMAT_MAPPING m_mapping;
VkExtent3D m_adjustedExtent;
bool m_shadow; //< Depth Compare-ness bool m_shadow; //< Depth Compare-ness
int64_t m_size = 0; int64_t m_size = 0;

View File

@ -136,7 +136,7 @@ namespace dxvk {
VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_ASPECT_COLOR_BIT,
{ VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G,
VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }, 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) // Convert -> float (this is a mixed snorm and unorm type)
VK_FORMAT_R16G16B16A16_SFLOAT } }; VK_FORMAT_R16G16B16A16_SFLOAT } };
@ -146,7 +146,7 @@ namespace dxvk {
VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_ASPECT_COLOR_BIT,
{ VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G,
VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ONE }, 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) // Convert -> float (this is a mixed snorm and unorm type)
VK_FORMAT_R16G16B16A16_SFLOAT } }; VK_FORMAT_R16G16B16A16_SFLOAT } };
@ -168,7 +168,7 @@ namespace dxvk {
VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_ASPECT_COLOR_BIT,
{ VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G,
VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }, 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) // Convert -> float (this is a mixed snorm and unorm type)
VK_FORMAT_R16G16B16A16_SFLOAT } }; VK_FORMAT_R16G16B16A16_SFLOAT } };
@ -178,7 +178,7 @@ namespace dxvk {
VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_ASPECT_COLOR_BIT,
{ VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, { VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
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 { case D3D9Format::R8G8_B8G8: return {
@ -192,7 +192,7 @@ namespace dxvk {
VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_ASPECT_COLOR_BIT,
{ VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, { VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
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 { case D3D9Format::G8R8_G8B8: return {
@ -412,7 +412,7 @@ namespace dxvk {
VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_ASPECT_COLOR_BIT,
{ VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, { VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
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 case D3D9Format::RAWZ: return {}; // Unsupported

View File

@ -140,7 +140,7 @@ namespace dxvk {
struct D3D9_CONVERSION_FORMAT_INFO { struct D3D9_CONVERSION_FORMAT_INFO {
D3D9ConversionFormat FormatType = D3D9ConversionFormat_None; D3D9ConversionFormat FormatType = D3D9ConversionFormat_None;
VkExtent3D MacroPixelSize = { 1u, 1u, 1u }; uint32_t PlaneCount = 1;
VkFormat FormatColor = VK_FORMAT_UNDEFINED; VkFormat FormatColor = VK_FORMAT_UNDEFINED;
VkFormat FormatSrgb = VK_FORMAT_UNDEFINED; VkFormat FormatSrgb = VK_FORMAT_UNDEFINED;
}; };

View File

@ -32,24 +32,24 @@ namespace dxvk {
case D3D9ConversionFormat_YUY2: case D3D9ConversionFormat_YUY2:
case D3D9ConversionFormat_UYVY: { case D3D9ConversionFormat_UYVY: {
uint32_t specConstant = conversionFormat.FormatType == D3D9ConversionFormat_UYVY ? 1 : 0; 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; break;
} }
case D3D9ConversionFormat_NV12: 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; break;
case D3D9ConversionFormat_L6V5U5: 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; break;
case D3D9ConversionFormat_X8L8V8U8: 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; break;
case D3D9ConversionFormat_A2W10V10U10: 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; break;
default: default:
@ -64,7 +64,8 @@ namespace dxvk {
VkImageSubresourceLayers dstSubresource, VkImageSubresourceLayers dstSubresource,
const Rc<DxvkBuffer>& srcBuffer, const Rc<DxvkBuffer>& srcBuffer,
VkFormat bufferFormat, VkFormat bufferFormat,
uint32_t specConstantValue) { uint32_t specConstantValue,
VkExtent2D macroPixelRun) {
DxvkImageViewCreateInfo imageViewInfo; DxvkImageViewCreateInfo imageViewInfo;
imageViewInfo.type = VK_IMAGE_VIEW_TYPE_2D; imageViewInfo.type = VK_IMAGE_VIEW_TYPE_2D;
imageViewInfo.format = dstImage->info().format; imageViewInfo.format = dstImage->info().format;
@ -77,8 +78,8 @@ namespace dxvk {
auto tmpImageView = m_device->createImageView(dstImage, imageViewInfo); auto tmpImageView = m_device->createImageView(dstImage, imageViewInfo);
VkExtent3D imageExtent = dstImage->mipLevelExtent(dstSubresource.mipLevel); VkExtent3D imageExtent = dstImage->mipLevelExtent(dstSubresource.mipLevel);
imageExtent = VkExtent3D{ imageExtent.width / videoFormat.MacroPixelSize.width, imageExtent = VkExtent3D{ imageExtent.width / macroPixelRun.width,
imageExtent.height / videoFormat.MacroPixelSize.height, imageExtent.height / macroPixelRun.height,
1 }; 1 };
DxvkBufferViewCreateInfo bufferViewInfo; DxvkBufferViewCreateInfo bufferViewInfo;

View File

@ -29,7 +29,8 @@ namespace dxvk {
VkImageSubresourceLayers dstSubresource, VkImageSubresourceLayers dstSubresource,
const Rc<DxvkBuffer>& srcBuffer, const Rc<DxvkBuffer>& srcBuffer,
VkFormat bufferFormat, VkFormat bufferFormat,
uint32_t specConstantValue); uint32_t specConstantValue,
VkExtent2D macroPixelRun);
enum BindingIds : uint32_t { enum BindingIds : uint32_t {
Image = 0, Image = 0,