From a1feaa674887c721b158f35dc969a764ea389938 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 9 May 2019 09:08:29 +0200 Subject: [PATCH] [dxvk] Add aspect mask parameter to clearImageView --- src/d3d11/d3d11_context.cpp | 18 +++++++++++++++--- src/dxvk/dxvk_context.cpp | 6 ++++-- src/dxvk/dxvk_context.h | 3 +++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 3894da89a..468024c6f 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -812,6 +812,7 @@ namespace dxvk { ctx->clearImageView(cDstView, VkOffset3D { 0, 0, 0 }, cDstView->mipLevelExtent(0), + VK_IMAGE_ASPECT_COLOR_BIT, cClearValue); }); } @@ -852,6 +853,7 @@ namespace dxvk { ctx->clearImageView(cDstView, VkOffset3D { 0, 0, 0 }, cDstView->mipLevelExtent(0), + VK_IMAGE_ASPECT_COLOR_BIT, cClearValue); }); } @@ -954,9 +956,12 @@ namespace dxvk { // Convert the clear color format. ClearView takes // the clear value for integer formats as a set of // integral floats, so we'll have to convert. - VkClearValue clearValue; + VkClearValue clearValue; + VkImageAspectFlags clearAspect; if (imgView == nullptr || imgView->info().aspect & VK_IMAGE_ASPECT_COLOR_BIT) { + clearAspect = VK_IMAGE_ASPECT_COLOR_BIT; + for (uint32_t i = 0; i < 4; i++) { if (formatInfo->flags.test(DxvkFormatFlag::SampledUInt)) clearValue.color.uint32[i] = uint32_t(Color[i]); @@ -966,6 +971,7 @@ namespace dxvk { clearValue.color.float32[i] = Color[i]; } } else { + clearAspect = VK_IMAGE_ASPECT_DEPTH_BIT; clearValue.depthStencil.depth = Color[0]; clearValue.depthStencil.stencil = 0; } @@ -1004,12 +1010,14 @@ namespace dxvk { cImageView = imgView, cAreaOffset = offset, cAreaExtent = extent, + cClearAspect = clearAspect, cClearValue = clearValue ] (DxvkContext* ctx) { ctx->clearImageView( cImageView, cAreaOffset, cAreaExtent, + cClearAspect, cClearValue); }); } @@ -1034,13 +1042,17 @@ namespace dxvk { if (imgView != nullptr) { EmitCs([ cImageView = imgView, + cClearAspect = clearAspect, cClearValue = clearValue ] (DxvkContext* ctx) { VkOffset3D offset = { 0, 0, 0 }; VkExtent3D extent = cImageView->mipLevelExtent(0); - ctx->clearImageView(cImageView, - offset, extent, cClearValue); + ctx->clearImageView( + cImageView, + offset, extent, + cClearAspect, + cClearValue); }); } } diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 328bf5609..02d13dd85 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -734,11 +734,12 @@ namespace dxvk { const Rc& imageView, VkOffset3D offset, VkExtent3D extent, + VkImageAspectFlags aspect, VkClearValue value) { const VkImageUsageFlags viewUsage = imageView->info().usage; if (viewUsage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) - this->clearImageViewFb(imageView, offset, extent, value); + this->clearImageViewFb(imageView, offset, extent, aspect, value); else if (viewUsage & VK_IMAGE_USAGE_STORAGE_BIT) this->clearImageViewCs(imageView, offset, extent, value); } @@ -2236,6 +2237,7 @@ namespace dxvk { const Rc& imageView, VkOffset3D offset, VkExtent3D extent, + VkImageAspectFlags aspect, VkClearValue value) { this->updateFramebuffer(); @@ -2311,7 +2313,7 @@ namespace dxvk { // Perform the actual clear operation VkClearAttachment clearInfo; - clearInfo.aspectMask = imageView->info().aspect; + clearInfo.aspectMask = aspect; clearInfo.colorAttachment = attachmentIndex; clearInfo.clearValue = value; diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 68aa55420..286c02a31 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -300,12 +300,14 @@ namespace dxvk { * \param [in] imageView The image view * \param [in] offset Offset of the rect to clear * \param [in] extent Extent of the rect to clear + * \param [in] aspect Aspect mask to clear * \param [in] value The clear value */ void clearImageView( const Rc& imageView, VkOffset3D offset, VkExtent3D extent, + VkImageAspectFlags aspect, VkClearValue value); /** @@ -983,6 +985,7 @@ namespace dxvk { const Rc& imageView, VkOffset3D offset, VkExtent3D extent, + VkImageAspectFlags aspect, VkClearValue value); void clearImageViewCs(