From 099c70c2bdd13a22278692497101b2c3b5763083 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 17 Aug 2022 14:09:50 +0200 Subject: [PATCH] [d3d11] Use new format support queries in resource creation --- src/d3d11/d3d11_buffer.cpp | 8 ++--- src/d3d11/d3d11_buffer.h | 2 +- src/d3d11/d3d11_texture.cpp | 58 +++++++++++++++++-------------------- src/d3d11/d3d11_texture.h | 2 +- src/d3d11/d3d11_util.cpp | 20 ++++++------- src/d3d11/d3d11_util.h | 4 +-- 6 files changed, 45 insertions(+), 49 deletions(-) diff --git a/src/d3d11/d3d11_buffer.cpp b/src/d3d11/d3d11_buffer.cpp index c53003a0..3069d71e 100644 --- a/src/d3d11/d3d11_buffer.cpp +++ b/src/d3d11/d3d11_buffer.cpp @@ -156,7 +156,7 @@ namespace dxvk { // Check whether the given combination of buffer view // type and view format is supported by the device DXGI_VK_FORMAT_INFO viewFormat = m_parent->LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY); - VkFormatFeatureFlags features = GetBufferFormatFeatures(BindFlags); + VkFormatFeatureFlags2 features = GetBufferFormatFeatures(BindFlags); return CheckFormatFeatureSupport(viewFormat.Format, features); } @@ -201,9 +201,9 @@ namespace dxvk { BOOL D3D11Buffer::CheckFormatFeatureSupport( VkFormat Format, - VkFormatFeatureFlags Features) const { - VkFormatProperties properties = m_parent->GetDXVKDevice()->adapter()->formatProperties(Format); - return (properties.bufferFeatures & Features) == Features; + VkFormatFeatureFlags2 Features) const { + DxvkFormatFeatures support = m_parent->GetDXVKDevice()->getFormatFeatures(Format); + return (support.buffer & Features) == Features; } diff --git a/src/d3d11/d3d11_buffer.h b/src/d3d11/d3d11_buffer.h index a2012145..b13b18aa 100644 --- a/src/d3d11/d3d11_buffer.h +++ b/src/d3d11/d3d11_buffer.h @@ -158,7 +158,7 @@ namespace dxvk { BOOL CheckFormatFeatureSupport( VkFormat Format, - VkFormatFeatureFlags Features) const; + VkFormatFeatureFlags2 Features) const; VkMemoryPropertyFlags GetMemoryFlags() const; diff --git a/src/d3d11/d3d11_texture.cpp b/src/d3d11/d3d11_texture.cpp index 1c88c655..5f814902 100644 --- a/src/d3d11/d3d11_texture.cpp +++ b/src/d3d11/d3d11_texture.cpp @@ -359,7 +359,7 @@ namespace dxvk { if (imageInfo.flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) { // Check whether the given combination of image // view type and view format is actually supported - VkFormatFeatureFlags features = GetImageFormatFeatures(BindFlags); + VkFormatFeatureFlags2 features = GetImageFormatFeatures(BindFlags); if (!CheckFormatFeatureSupport(viewFormat.Format, features)) return false; @@ -444,77 +444,73 @@ namespace dxvk { BOOL D3D11CommonTexture::CheckImageSupport( const DxvkImageCreateInfo* pImageInfo, VkImageTiling Tiling) const { - const Rc adapter = m_device->GetDXVKDevice()->adapter(); - VkImageUsageFlags usage = pImageInfo->usage; if (pImageInfo->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT) usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; - VkImageFormatProperties formatProps = { }; - VkResult status = adapter->imageFormatProperties( - pImageInfo->format, pImageInfo->type, Tiling, - usage, pImageInfo->flags, formatProps); + auto properties = m_device->GetDXVKDevice()->getFormatLimits( + pImageInfo->format, pImageInfo->type, Tiling, usage, pImageInfo->flags); - if (status != VK_SUCCESS) + if (!properties) return FALSE; - return (pImageInfo->extent.width <= formatProps.maxExtent.width) - && (pImageInfo->extent.height <= formatProps.maxExtent.height) - && (pImageInfo->extent.depth <= formatProps.maxExtent.depth) - && (pImageInfo->numLayers <= formatProps.maxArrayLayers) - && (pImageInfo->mipLevels <= formatProps.maxMipLevels) - && (pImageInfo->sampleCount & formatProps.sampleCounts); + return (pImageInfo->extent.width <= properties->maxExtent.width) + && (pImageInfo->extent.height <= properties->maxExtent.height) + && (pImageInfo->extent.depth <= properties->maxExtent.depth) + && (pImageInfo->numLayers <= properties->maxArrayLayers) + && (pImageInfo->mipLevels <= properties->maxMipLevels) + && (pImageInfo->sampleCount & properties->sampleCounts); } BOOL D3D11CommonTexture::CheckFormatFeatureSupport( VkFormat Format, - VkFormatFeatureFlags Features) const { - VkFormatProperties properties = m_device->GetDXVKDevice()->adapter()->formatProperties(Format); + VkFormatFeatureFlags2 Features) const { + DxvkFormatFeatures support = m_device->GetDXVKDevice()->getFormatFeatures(Format); - return (properties.linearTilingFeatures & Features) == Features - || (properties.optimalTilingFeatures & Features) == Features; + return (support.linear & Features) == Features + || (support.optimal & Features) == Features; } VkImageUsageFlags D3D11CommonTexture::EnableMetaCopyUsage( VkFormat Format, VkImageTiling Tiling) const { - VkFormatFeatureFlags requestedFeatures = 0; + VkFormatFeatureFlags2 requestedFeatures = 0; if (Format == VK_FORMAT_D16_UNORM || Format == VK_FORMAT_D32_SFLOAT) { - requestedFeatures |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT - | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; + requestedFeatures |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT + | VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT; } if (Format == VK_FORMAT_R16_UNORM || Format == VK_FORMAT_R32_SFLOAT) { - requestedFeatures |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT - | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; + requestedFeatures |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT + | VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT; } if (Format == VK_FORMAT_D32_SFLOAT_S8_UINT || Format == VK_FORMAT_D24_UNORM_S8_UINT) - requestedFeatures |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; + requestedFeatures |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT; - if (requestedFeatures == 0) + if (!requestedFeatures) return 0; // Enable usage flags for all supported and requested features - VkFormatProperties properties = m_device->GetDXVKDevice()->adapter()->formatProperties(Format); + DxvkFormatFeatures support = m_device->GetDXVKDevice()->getFormatFeatures(Format); requestedFeatures &= Tiling == VK_IMAGE_TILING_OPTIMAL - ? properties.optimalTilingFeatures - : properties.linearTilingFeatures; + ? support.optimal + : support.linear; VkImageUsageFlags requestedUsage = 0; - if (requestedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) + if (requestedFeatures & VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT) requestedUsage |= VK_IMAGE_USAGE_SAMPLED_BIT; - 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; - if (requestedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) + if (requestedFeatures & VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT) requestedUsage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; return requestedUsage; diff --git a/src/d3d11/d3d11_texture.h b/src/d3d11/d3d11_texture.h index 2db2bc0c..3ca91da2 100644 --- a/src/d3d11/d3d11_texture.h +++ b/src/d3d11/d3d11_texture.h @@ -405,7 +405,7 @@ namespace dxvk { BOOL CheckFormatFeatureSupport( VkFormat Format, - VkFormatFeatureFlags Features) const; + VkFormatFeatureFlags2 Features) const; VkImageUsageFlags EnableMetaCopyUsage( VkFormat Format, diff --git a/src/d3d11/d3d11_util.cpp b/src/d3d11/d3d11_util.cpp index 92f5f6d4..6c31ce3f 100644 --- a/src/d3d11/d3d11_util.cpp +++ b/src/d3d11/d3d11_util.cpp @@ -78,29 +78,29 @@ namespace dxvk { } - VkFormatFeatureFlags GetBufferFormatFeatures(UINT BindFlags) { - VkFormatFeatureFlags features = 0; + VkFormatFeatureFlags2 GetBufferFormatFeatures(UINT BindFlags) { + VkFormatFeatureFlags2 features = 0; if (BindFlags & D3D11_BIND_SHADER_RESOURCE) - features |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT; + features |= VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT; if (BindFlags & D3D11_BIND_UNORDERED_ACCESS) - features |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT; + features |= VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT; return features; } - VkFormatFeatureFlags GetImageFormatFeatures(UINT BindFlags) { - VkFormatFeatureFlags features = 0; + VkFormatFeatureFlags2 GetImageFormatFeatures(UINT BindFlags) { + VkFormatFeatureFlags2 features = 0; if (BindFlags & D3D11_BIND_DEPTH_STENCIL) - features |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; + features |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT; if (BindFlags & D3D11_BIND_RENDER_TARGET) - features |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; + features |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT; if (BindFlags & D3D11_BIND_SHADER_RESOURCE) - features |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; + features |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT; if (BindFlags & D3D11_BIND_UNORDERED_ACCESS) - features |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; + features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT; return features; } diff --git a/src/d3d11/d3d11_util.h b/src/d3d11/d3d11_util.h index 8913d2c3..beb3e13b 100644 --- a/src/d3d11/d3d11_util.h +++ b/src/d3d11/d3d11_util.h @@ -31,10 +31,10 @@ namespace dxvk { VkConservativeRasterizationModeEXT DecodeConservativeRasterizationMode( D3D11_CONSERVATIVE_RASTERIZATION_MODE Mode); - VkFormatFeatureFlags GetBufferFormatFeatures( + VkFormatFeatureFlags2 GetBufferFormatFeatures( UINT BindFlags); - VkFormatFeatureFlags GetImageFormatFeatures( + VkFormatFeatureFlags2 GetImageFormatFeatures( UINT BindFlags); VkFormat GetPackedDepthStencilFormat(