From 752f98cf00f5329f8aa5ba89ef027574e27d3d54 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 17 Feb 2022 15:20:09 +0100 Subject: [PATCH] [d3d9] Use initImage to clear uninitialized image resources --- src/d3d9/d3d9_initializer.cpp | 21 ++------------------- src/d3d9/d3d9_swapchain.cpp | 10 ++-------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/d3d9/d3d9_initializer.cpp b/src/d3d9/d3d9_initializer.cpp index d3076954..64ac3497 100644 --- a/src/d3d9/d3d9_initializer.cpp +++ b/src/d3d9/d3d9_initializer.cpp @@ -91,8 +91,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; @@ -100,23 +99,7 @@ namespace dxvk { subresources.baseArrayLayer = 0; subresources.layerCount = image->info().numLayers; - if (formatInfo->flags.test(DxvkFormatFlag::BlockCompressed)) { - 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); }; InitImage(pTexture->GetImage()); diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 1c2c23b1..ad413d28 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -1050,19 +1050,13 @@ 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()); for (uint32_t i = 0; i < m_backBuffers.size(); i++) { - m_context->clearColorImage( + m_context->initImage( m_backBuffers[i]->GetCommonTexture()->GetImage(), - clearColor, subresources); + subresources, VK_IMAGE_LAYOUT_UNDEFINED); } m_device->submitCommandList(