Skip to content

Commit

Permalink
[d3d9] Replace macropixel size with plane count
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Aug 7, 2020
1 parent 2bf9f29 commit 9fe1b9d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 26 deletions.
11 changes: 4 additions & 7 deletions src/d3d9/d3d9_common_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/d3d9/d3d9_common_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

/**
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/d3d9/d3d9_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 } };

Expand All @@ -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 } };

Expand All @@ -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 } };

Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/d3d9/d3d9_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
17 changes: 9 additions & 8 deletions src/d3d9/d3d9_format_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -64,7 +64,8 @@ namespace dxvk {
VkImageSubresourceLayers dstSubresource,
const Rc<DxvkBuffer>& 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;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/d3d9/d3d9_format_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace dxvk {
VkImageSubresourceLayers dstSubresource,
const Rc<DxvkBuffer>& srcBuffer,
VkFormat bufferFormat,
uint32_t specConstantValue);
uint32_t specConstantValue,
VkExtent2D macroPixelRun);

enum BindingIds : uint32_t {
Image = 0,
Expand Down

0 comments on commit 9fe1b9d

Please sign in to comment.