1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 13:08:50 +01:00

[d3d11] Use new format support queries in resource creation

This commit is contained in:
Philip Rebohle 2022-08-17 14:09:50 +02:00
parent 3717922381
commit 099c70c2bd
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 45 additions and 49 deletions

View File

@ -156,7 +156,7 @@ namespace dxvk {
// Check whether the given combination of buffer view // Check whether the given combination of buffer view
// type and view format is supported by the device // type and view format is supported by the device
DXGI_VK_FORMAT_INFO viewFormat = m_parent->LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY); 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); return CheckFormatFeatureSupport(viewFormat.Format, features);
} }
@ -201,9 +201,9 @@ namespace dxvk {
BOOL D3D11Buffer::CheckFormatFeatureSupport( BOOL D3D11Buffer::CheckFormatFeatureSupport(
VkFormat Format, VkFormat Format,
VkFormatFeatureFlags Features) const { VkFormatFeatureFlags2 Features) const {
VkFormatProperties properties = m_parent->GetDXVKDevice()->adapter()->formatProperties(Format); DxvkFormatFeatures support = m_parent->GetDXVKDevice()->getFormatFeatures(Format);
return (properties.bufferFeatures & Features) == Features; return (support.buffer & Features) == Features;
} }

View File

@ -158,7 +158,7 @@ namespace dxvk {
BOOL CheckFormatFeatureSupport( BOOL CheckFormatFeatureSupport(
VkFormat Format, VkFormat Format,
VkFormatFeatureFlags Features) const; VkFormatFeatureFlags2 Features) const;
VkMemoryPropertyFlags GetMemoryFlags() const; VkMemoryPropertyFlags GetMemoryFlags() const;

View File

@ -359,7 +359,7 @@ namespace dxvk {
if (imageInfo.flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) { if (imageInfo.flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) {
// Check whether the given combination of image // Check whether the given combination of image
// view type and view format is actually supported // view type and view format is actually supported
VkFormatFeatureFlags features = GetImageFormatFeatures(BindFlags); VkFormatFeatureFlags2 features = GetImageFormatFeatures(BindFlags);
if (!CheckFormatFeatureSupport(viewFormat.Format, features)) if (!CheckFormatFeatureSupport(viewFormat.Format, features))
return false; return false;
@ -444,77 +444,73 @@ namespace dxvk {
BOOL D3D11CommonTexture::CheckImageSupport( BOOL D3D11CommonTexture::CheckImageSupport(
const DxvkImageCreateInfo* pImageInfo, const DxvkImageCreateInfo* pImageInfo,
VkImageTiling Tiling) const { VkImageTiling Tiling) const {
const Rc<DxvkAdapter> adapter = m_device->GetDXVKDevice()->adapter();
VkImageUsageFlags usage = pImageInfo->usage; VkImageUsageFlags usage = pImageInfo->usage;
if (pImageInfo->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT) if (pImageInfo->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT)
usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
VkImageFormatProperties formatProps = { }; auto properties = m_device->GetDXVKDevice()->getFormatLimits(
VkResult status = adapter->imageFormatProperties( pImageInfo->format, pImageInfo->type, Tiling, usage, pImageInfo->flags);
pImageInfo->format, pImageInfo->type, Tiling,
usage, pImageInfo->flags, formatProps);
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);
} }
BOOL D3D11CommonTexture::CheckFormatFeatureSupport( BOOL D3D11CommonTexture::CheckFormatFeatureSupport(
VkFormat Format, VkFormat Format,
VkFormatFeatureFlags Features) const { VkFormatFeatureFlags2 Features) const {
VkFormatProperties properties = m_device->GetDXVKDevice()->adapter()->formatProperties(Format); DxvkFormatFeatures support = m_device->GetDXVKDevice()->getFormatFeatures(Format);
return (properties.linearTilingFeatures & Features) == Features return (support.linear & Features) == Features
|| (properties.optimalTilingFeatures & Features) == Features; || (support.optimal & Features) == Features;
} }
VkImageUsageFlags D3D11CommonTexture::EnableMetaCopyUsage( VkImageUsageFlags D3D11CommonTexture::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_SAMPLED_IMAGE_BIT requestedFeatures |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT
| VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; | 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_SAMPLED_IMAGE_BIT requestedFeatures |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT
| VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; | VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;
} }
if (Format == VK_FORMAT_D32_SFLOAT_S8_UINT || Format == VK_FORMAT_D24_UNORM_S8_UINT) 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; 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 support = m_device->GetDXVKDevice()->getFormatFeatures(Format);
requestedFeatures &= Tiling == VK_IMAGE_TILING_OPTIMAL requestedFeatures &= Tiling == VK_IMAGE_TILING_OPTIMAL
? properties.optimalTilingFeatures ? support.optimal
: properties.linearTilingFeatures; : support.linear;
VkImageUsageFlags requestedUsage = 0; 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; 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; 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

@ -405,7 +405,7 @@ namespace dxvk {
BOOL CheckFormatFeatureSupport( BOOL CheckFormatFeatureSupport(
VkFormat Format, VkFormat Format,
VkFormatFeatureFlags Features) const; VkFormatFeatureFlags2 Features) const;
VkImageUsageFlags EnableMetaCopyUsage( VkImageUsageFlags EnableMetaCopyUsage(
VkFormat Format, VkFormat Format,

View File

@ -78,29 +78,29 @@ namespace dxvk {
} }
VkFormatFeatureFlags GetBufferFormatFeatures(UINT BindFlags) { VkFormatFeatureFlags2 GetBufferFormatFeatures(UINT BindFlags) {
VkFormatFeatureFlags features = 0; VkFormatFeatureFlags2 features = 0;
if (BindFlags & D3D11_BIND_SHADER_RESOURCE) 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) 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; return features;
} }
VkFormatFeatureFlags GetImageFormatFeatures(UINT BindFlags) { VkFormatFeatureFlags2 GetImageFormatFeatures(UINT BindFlags) {
VkFormatFeatureFlags features = 0; VkFormatFeatureFlags2 features = 0;
if (BindFlags & D3D11_BIND_DEPTH_STENCIL) 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) 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) 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) if (BindFlags & D3D11_BIND_UNORDERED_ACCESS)
features |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT;
return features; return features;
} }

View File

@ -31,10 +31,10 @@ namespace dxvk {
VkConservativeRasterizationModeEXT DecodeConservativeRasterizationMode( VkConservativeRasterizationModeEXT DecodeConservativeRasterizationMode(
D3D11_CONSERVATIVE_RASTERIZATION_MODE Mode); D3D11_CONSERVATIVE_RASTERIZATION_MODE Mode);
VkFormatFeatureFlags GetBufferFormatFeatures( VkFormatFeatureFlags2 GetBufferFormatFeatures(
UINT BindFlags); UINT BindFlags);
VkFormatFeatureFlags GetImageFormatFeatures( VkFormatFeatureFlags2 GetImageFormatFeatures(
UINT BindFlags); UINT BindFlags);
VkFormat GetPackedDepthStencilFormat( VkFormat GetPackedDepthStencilFormat(