1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-05 19:46:15 +01:00

[d3d9] Use new format support queries

This commit is contained in:
Philip Rebohle 2022-08-17 15:16:23 +02:00
parent 13152088d4
commit 80fc1d8b25
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
7 changed files with 43 additions and 48 deletions

View File

@ -717,32 +717,32 @@ namespace dxvk {
VkFormat Format, VkFormat Format,
DWORD Usage, DWORD Usage,
D3DRESOURCETYPE RType) { D3DRESOURCETYPE RType) {
VkFormatFeatureFlags checkFlags = 0; VkFormatFeatureFlags2 checkFlags = 0;
if (RType != D3DRTYPE_SURFACE) if (RType != D3DRTYPE_SURFACE)
checkFlags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; checkFlags |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT;
if (Usage & D3DUSAGE_RENDERTARGET) { if (Usage & D3DUSAGE_RENDERTARGET) {
checkFlags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; checkFlags |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;
if (Usage & D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING) if (Usage & D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
checkFlags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT; checkFlags |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT;
} }
if (Usage & D3DUSAGE_DEPTHSTENCIL) if (Usage & D3DUSAGE_DEPTHSTENCIL)
checkFlags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; checkFlags |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT;
else else
checkFlags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; checkFlags |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT;
VkFormatFeatureFlags checkFlagsMipGen = checkFlags; VkFormatFeatureFlags2 checkFlagsMipGen = checkFlags;
if (Usage & D3DUSAGE_AUTOGENMIPMAP) { if (Usage & D3DUSAGE_AUTOGENMIPMAP) {
checkFlagsMipGen |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; checkFlagsMipGen |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT;
checkFlagsMipGen |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; checkFlagsMipGen |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;
} }
VkFormatProperties fmtSupport = m_adapter->formatProperties(Format); DxvkFormatFeatures fmtSupport = m_adapter->getFormatFeatures(Format);
VkFormatFeatureFlags imgFeatures = fmtSupport.optimalTilingFeatures | fmtSupport.linearTilingFeatures; VkFormatFeatureFlags2 imgFeatures = fmtSupport.optimal | fmtSupport.linear;
if ((imgFeatures & checkFlags) != checkFlags) if ((imgFeatures & checkFlags) != checkFlags)
return D3DERR_NOTAVAILABLE; return D3DERR_NOTAVAILABLE;

View File

@ -379,53 +379,49 @@ namespace dxvk {
BOOL D3D9CommonTexture::CheckImageSupport( BOOL D3D9CommonTexture::CheckImageSupport(
const DxvkImageCreateInfo* pImageInfo, const DxvkImageCreateInfo* pImageInfo,
VkImageTiling Tiling) const { VkImageTiling Tiling) const {
const Rc<DxvkAdapter> adapter = m_device->GetDXVKDevice()->adapter(); auto properties = m_device->GetDXVKDevice()->getFormatLimits(
VkImageFormatProperties formatProps = { };
VkResult status = adapter->imageFormatProperties(
pImageInfo->format, pImageInfo->type, Tiling, pImageInfo->format, pImageInfo->type, Tiling,
pImageInfo->usage, pImageInfo->flags, formatProps); pImageInfo->usage, pImageInfo->flags);
if (status != VK_SUCCESS) if (!properties)
return FALSE; return FALSE;
return (pImageInfo->extent.width <= formatProps.maxExtent.width) return (pImageInfo->extent.width <= properties->maxExtent.width)
&& (pImageInfo->extent.height <= formatProps.maxExtent.height) && (pImageInfo->extent.height <= properties->maxExtent.height)
&& (pImageInfo->extent.depth <= formatProps.maxExtent.depth) && (pImageInfo->extent.depth <= properties->maxExtent.depth)
&& (pImageInfo->numLayers <= formatProps.maxArrayLayers) && (pImageInfo->numLayers <= properties->maxArrayLayers)
&& (pImageInfo->mipLevels <= formatProps.maxMipLevels) && (pImageInfo->mipLevels <= properties->maxMipLevels)
&& (pImageInfo->sampleCount & formatProps.sampleCounts); && (pImageInfo->sampleCount & properties->sampleCounts);
} }
VkImageUsageFlags D3D9CommonTexture::EnableMetaCopyUsage( VkImageUsageFlags D3D9CommonTexture::EnableMetaCopyUsage(
VkFormat Format, VkFormat Format,
VkImageTiling Tiling) const { VkImageTiling Tiling) const {
VkFormatFeatureFlags requestedFeatures = 0; VkFormatFeatureFlags2 requestedFeatures = 0;
if (Format == VK_FORMAT_D16_UNORM || Format == VK_FORMAT_D32_SFLOAT) if (Format == VK_FORMAT_D16_UNORM || Format == VK_FORMAT_D32_SFLOAT)
requestedFeatures |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; requestedFeatures |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT;
if (Format == VK_FORMAT_R16_UNORM || Format == VK_FORMAT_R32_SFLOAT) if (Format == VK_FORMAT_R16_UNORM || Format == VK_FORMAT_R32_SFLOAT)
requestedFeatures |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; requestedFeatures |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;
if (requestedFeatures == 0) if (!requestedFeatures)
return 0; return 0;
// Enable usage flags for all supported and requested features // Enable usage flags for all supported and requested features
VkFormatProperties properties = m_device->GetDXVKDevice()->adapter()->formatProperties(Format); DxvkFormatFeatures properties = m_device->GetDXVKDevice()->getFormatFeatures(Format);
requestedFeatures &= Tiling == VK_IMAGE_TILING_OPTIMAL requestedFeatures &= Tiling == VK_IMAGE_TILING_OPTIMAL
? properties.optimalTilingFeatures ? properties.optimal
: properties.linearTilingFeatures; : properties.linear;
VkImageUsageFlags requestedUsage = 0; VkImageUsageFlags requestedUsage = 0;
if (requestedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) if (requestedFeatures & VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT)
requestedUsage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; requestedUsage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
if (requestedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) if (requestedFeatures & VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT)
requestedUsage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; requestedUsage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
return requestedUsage; return requestedUsage;

View File

@ -3903,7 +3903,6 @@ namespace dxvk {
enabled.core.features.vertexPipelineStoresAndAtomics = supported.core.features.vertexPipelineStoresAndAtomics; enabled.core.features.vertexPipelineStoresAndAtomics = supported.core.features.vertexPipelineStoresAndAtomics;
// DXVK Meta // DXVK Meta
enabled.core.features.shaderStorageImageWriteWithoutFormat = VK_TRUE;
enabled.core.features.imageCubeArray = VK_TRUE; enabled.core.features.imageCubeArray = VK_TRUE;
// SM1 level hardware // SM1 level hardware

View File

@ -435,14 +435,14 @@ namespace dxvk {
// AMD do not support 24-bit depth buffers on Vulkan, // AMD do not support 24-bit depth buffers on Vulkan,
// so we have to fall back to a 32-bit depth format. // so we have to fall back to a 32-bit depth format.
m_d24s8Support = CheckImageFormatSupport(adapter, VK_FORMAT_D24_UNORM_S8_UINT, m_d24s8Support = CheckImageFormatSupport(adapter, VK_FORMAT_D24_UNORM_S8_UINT,
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT |
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT);
// NVIDIA do not support 16-bit depth buffers with stencil on Vulkan, // NVIDIA do not support 16-bit depth buffers with stencil on Vulkan,
// so we have to fall back to a 32-bit depth format. // so we have to fall back to a 32-bit depth format.
m_d16s8Support = CheckImageFormatSupport(adapter, VK_FORMAT_D16_UNORM_S8_UINT, m_d16s8Support = CheckImageFormatSupport(adapter, VK_FORMAT_D16_UNORM_S8_UINT,
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT |
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT);
// VK_EXT_4444_formats // VK_EXT_4444_formats
if (!m_d24s8Support) if (!m_d24s8Support)
@ -538,11 +538,11 @@ namespace dxvk {
bool D3D9VkFormatTable::CheckImageFormatSupport( bool D3D9VkFormatTable::CheckImageFormatSupport(
const Rc<DxvkAdapter>& Adapter, const Rc<DxvkAdapter>& Adapter,
VkFormat Format, VkFormat Format,
VkFormatFeatureFlags Features) const { VkFormatFeatureFlags2 Features) const {
VkFormatProperties supported = Adapter->formatProperties(Format); DxvkFormatFeatures supported = Adapter->getFormatFeatures(Format);
return (supported.linearTilingFeatures & Features) == Features return (supported.linear & Features) == Features
|| (supported.optimalTilingFeatures & Features) == Features; || (supported.optimal & Features) == Features;
} }
} }

View File

@ -209,7 +209,7 @@ namespace dxvk {
bool CheckImageFormatSupport( bool CheckImageFormatSupport(
const Rc<DxvkAdapter>& Adapter, const Rc<DxvkAdapter>& Adapter,
VkFormat Format, VkFormat Format,
VkFormatFeatureFlags Features) const; VkFormatFeatureFlags2 Features) const;
bool m_d24s8Support; bool m_d24s8Support;
bool m_d16s8Support; bool m_d16s8Support;

View File

@ -97,14 +97,14 @@ namespace dxvk {
} }
VkFormatFeatureFlags GetImageFormatFeatures(DWORD Usage) { VkFormatFeatureFlags2 GetImageFormatFeatures(DWORD Usage) {
VkFormatFeatureFlags features = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; VkFormatFeatureFlags2 features = VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT;
if (Usage & D3DUSAGE_DEPTHSTENCIL) if (Usage & D3DUSAGE_DEPTHSTENCIL)
features |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; features |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT;
if (Usage & D3DUSAGE_RENDERTARGET) if (Usage & D3DUSAGE_RENDERTARGET)
features |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; features |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;
return features; return features;
} }

View File

@ -102,7 +102,7 @@ namespace dxvk {
VkFormat GetPackedDepthStencilFormat(D3D9Format Format); VkFormat GetPackedDepthStencilFormat(D3D9Format Format);
VkFormatFeatureFlags GetImageFormatFeatures(DWORD Usage); VkFormatFeatureFlags2 GetImageFormatFeatures(DWORD Usage);
VkImageUsageFlags GetImageUsageFlags(DWORD Usage); VkImageUsageFlags GetImageUsageFlags(DWORD Usage);