From daccde7643a2b3ce0e67c2d460d29145c788d6bb Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Thu, 8 Aug 2024 17:48:01 +0200 Subject: [PATCH] [d3d9] Don't set IMAGE_USAGE_SAMPLED_BIT for non-msaa depth stencil surfaces --- src/d3d9/d3d9_common_texture.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/d3d9/d3d9_common_texture.cpp b/src/d3d9/d3d9_common_texture.cpp index 065871965..08981b80f 100644 --- a/src/d3d9/d3d9_common_texture.cpp +++ b/src/d3d9/d3d9_common_texture.cpp @@ -295,8 +295,7 @@ namespace dxvk { imageInfo.numLayers = m_desc.ArraySize; imageInfo.mipLevels = m_desc.MipLevels; imageInfo.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT - | VK_IMAGE_USAGE_TRANSFER_DST_BIT - | VK_IMAGE_USAGE_SAMPLED_BIT; + | VK_IMAGE_USAGE_TRANSFER_DST_BIT; imageInfo.stages = VK_PIPELINE_STAGE_TRANSFER_BIT | m_device->GetEnabledShaderStages(); imageInfo.access = VK_ACCESS_TRANSFER_READ_BIT @@ -324,6 +323,12 @@ namespace dxvk { DecodeMultiSampleType(m_device->GetDXVKDevice(), m_desc.MultiSample, m_desc.MultisampleQuality, &imageInfo.sampleCount); + // We need SAMPLED_BIT for StretchRect. + // However, StretchRect does not allow stretching for DS formats, + // so unless we need to resolve, it should always hit code paths that only need TRANSFER_BIT. + if (!m_desc.IsAttachmentOnly || !IsDepthStencilFormat(m_desc.Format) || imageInfo.sampleCount != VK_SAMPLE_COUNT_1_BIT) + imageInfo.usage |= VK_IMAGE_USAGE_SAMPLED_BIT; + // The image must be marked as mutable if it can be reinterpreted // by a view with a different format. Depth-stencil formats cannot // be reinterpreted in Vulkan, so we'll ignore those. @@ -524,11 +529,6 @@ namespace dxvk { Usage &= ~(VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT); - - // Ignore sampled bit in case the image was created with - // an image flag that only allows attachment usage - if (m_desc.IsAttachmentOnly) - Usage &= ~VK_IMAGE_USAGE_SAMPLED_BIT; // If the image is used only as an attachment, we never // have to transform the image back to a different layout