From a644eebfd783fbbb3c0e31ae0219ae2e58c9aa61 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 19 Jan 2018 18:11:20 +0100 Subject: [PATCH] [d3d11] Fixed initialization of compressed images --- src/d3d11/d3d11_device.cpp | 38 +++++++++++++++++++++++--------------- src/dxvk/dxvk_context.cpp | 7 ------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 9db6588ca..2cba39a7b 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1486,9 +1486,10 @@ namespace dxvk { } else { LockResourceInitContext(); - // 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. + // 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. VkImageSubresourceRange subresources; subresources.aspectMask = formatInfo->aspectMask; subresources.baseMipLevel = 0; @@ -1496,19 +1497,26 @@ namespace dxvk { subresources.baseArrayLayer = 0; subresources.layerCount = image->info().numLayers; - if (subresources.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) { - VkClearColorValue value; - std::memset(&value, 0, sizeof(value)); - - m_resourceInitContext->clearColorImage( - image, value, subresources); + const DxvkFormatInfo* formatInfo = imageFormatInfo(image->info().format); + + if (formatInfo->flags.test(DxvkFormatFlag::BlockCompressed)) { + m_resourceInitContext->initImage( + image, subresources); } else { - VkClearDepthStencilValue value; - value.depth = 1.0f; - value.stencil = 0; - - m_resourceInitContext->clearDepthStencilImage( - image, value, subresources); + if (subresources.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) { + VkClearColorValue value; + std::memset(&value, 0, sizeof(value)); + + m_resourceInitContext->clearColorImage( + image, value, subresources); + } else { + VkClearDepthStencilValue value; + value.depth = 1.0f; + value.stencil = 0; + + m_resourceInitContext->clearDepthStencilImage( + image, value, subresources); + } } UnlockResourceInitContext(1); diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 496936ff8..141ba11d5 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -182,13 +182,6 @@ namespace dxvk { const VkImageSubresourceRange& subresources) { this->renderPassEnd(); - const DxvkFormatInfo* formatInfo = imageFormatInfo(image->info().format); - - if (formatInfo->flags.test(DxvkFormatFlag::BlockCompressed)) { - Logger::err("DxvkContext: Compressed clears not supported"); - return; - } - if (image->info().layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) { m_barriers.accessImage(image, subresources, VK_IMAGE_LAYOUT_UNDEFINED, 0, 0,