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
// 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;
}

View File

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

View File

@ -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<DxvkAdapter> 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;

View File

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

View File

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

View File

@ -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(