From e988895e5123d42850ddad1214353e3869ce3059 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 14 May 2021 12:33:10 +0200 Subject: [PATCH] [d3d11] Set mutable and extended usage bits for multi-plane images --- src/d3d11/d3d11_texture.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/d3d11/d3d11_texture.cpp b/src/d3d11/d3d11_texture.cpp index 59e9e7bba..15221f843 100644 --- a/src/d3d11/d3d11_texture.cpp +++ b/src/d3d11/d3d11_texture.cpp @@ -58,9 +58,10 @@ namespace dxvk { bool isTypeless = formatInfo.Aspect == 0; bool isMutable = formatFamily.FormatCount > 1; + bool isMultiPlane = (formatProperties->aspectMask & VK_IMAGE_ASPECT_PLANE_0_BIT) != 0; bool isColorFormat = (formatProperties->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) != 0; - if (isMutable && isColorFormat) { + if (isMutable && (isColorFormat || isMultiPlane)) { imageInfo.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; // Typeless UAV images have relaxed reinterpretation rules @@ -104,6 +105,15 @@ namespace dxvk { imageInfo.access |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; } + + // Multi-plane formats need views to be created with color formats, and + // may not report all relevant usage flags as supported on their own. + // Also, enable sampled bit to enable use with video processor APIs. + if (isMultiPlane) { + imageInfo.usage |= VK_IMAGE_USAGE_SAMPLED_BIT; + imageInfo.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT + | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT; + } // Access pattern for meta-resolve operations if (imageInfo.sampleCount != VK_SAMPLE_COUNT_1_BIT && isColorFormat) { @@ -146,7 +156,7 @@ namespace dxvk { // We must keep LINEAR images in GENERAL layout, but we // can choose a better layout for the image based on how // it is going to be used by the game. - if (imageInfo.tiling == VK_IMAGE_TILING_OPTIMAL) + if (imageInfo.tiling == VK_IMAGE_TILING_OPTIMAL && !isMultiPlane) imageInfo.layout = OptimizeLayout(imageInfo.usage); // For some formats, we need to enable sampled and/or @@ -324,11 +334,15 @@ namespace dxvk { 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, - pImageInfo->usage, pImageInfo->flags, formatProps); + usage, pImageInfo->flags, formatProps); if (status != VK_SUCCESS) return FALSE;