From 6d0e5dfd21045ec6e417bcc7f69c32ca5539535e Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 17 Feb 2022 15:19:05 +0100 Subject: [PATCH] [d3d11] Use initImage to clear uninitialized image resources --- src/d3d11/d3d11_initializer.cpp | 21 ++------------------- src/d3d11/d3d11_swapchain.cpp | 10 ++-------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/d3d11/d3d11_initializer.cpp b/src/d3d11/d3d11_initializer.cpp index d1d66f19..723938c2 100644 --- a/src/d3d11/d3d11_initializer.cpp +++ b/src/d3d11/d3d11_initializer.cpp @@ -181,8 +181,7 @@ namespace dxvk { // While the Microsoft docs state that resource contents are // undefined if no initial data is provided, some applications - // expect a resource to be pre-cleared. We can only do that - // for non-compressed images, but that should be fine. + // expect a resource to be pre-cleared. VkImageSubresourceRange subresources; subresources.aspectMask = formatInfo->aspectMask; subresources.baseMipLevel = 0; @@ -190,23 +189,7 @@ namespace dxvk { subresources.baseArrayLayer = 0; subresources.layerCount = desc->ArraySize; - if (formatInfo->flags.any(DxvkFormatFlag::BlockCompressed, DxvkFormatFlag::MultiPlane)) { - m_context->clearCompressedColorImage(image, subresources); - } else { - if (subresources.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) { - VkClearColorValue value = { }; - - m_context->clearColorImage( - image, value, subresources); - } else { - VkClearDepthStencilValue value; - value.depth = 0.0f; - value.stencil = 0; - - m_context->clearDepthStencilImage( - image, value, subresources); - } - } + m_context->initImage(image, subresources, VK_IMAGE_LAYOUT_UNDEFINED); } if (mapMode != D3D11_COMMON_TEXTURE_MAP_MODE_NONE) { diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index b803d37c..647faa46 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -523,17 +523,11 @@ namespace dxvk { subresources.baseArrayLayer = 0; subresources.layerCount = 1; - VkClearColorValue clearColor; - clearColor.float32[0] = 0.0f; - clearColor.float32[1] = 0.0f; - clearColor.float32[2] = 0.0f; - clearColor.float32[3] = 0.0f; - m_context->beginRecording( m_device->createCommandList()); - m_context->clearColorImage( - m_swapImage, clearColor, subresources); + m_context->initImage(m_swapImage, + subresources, VK_IMAGE_LAYOUT_UNDEFINED); m_device->submitCommandList( m_context->endRecording(),