From b3c19ba5e86a540b3293599b30846db0612f060e Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 22 Apr 2020 21:01:19 +0200 Subject: [PATCH] [d3d11] Optimize ClearView for render target and depth-only views We should use clearRenderTarget whenever we clear the entire view. The Talos Principle uses ClearView to clear its render targets for some reason, and we were hitting a slow path there. --- src/d3d11/d3d11_context.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 69c9d9807..57fdb1575 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1082,14 +1082,25 @@ namespace dxvk { cClearAspect = clearAspect, cClearValue = clearValue ] (DxvkContext* ctx) { + const VkImageUsageFlags rtUsage = + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; + VkOffset3D offset = { 0, 0, 0 }; VkExtent3D extent = cImageView->mipLevelExtent(0); - ctx->clearImageView( - cImageView, - offset, extent, - cClearAspect, - cClearValue); + if (cImageView->info().usage & rtUsage) { + ctx->clearRenderTarget( + cImageView, + cClearAspect, + cClearValue); + } else { + ctx->clearImageView( + cImageView, + offset, extent, + cClearAspect, + cClearValue); + } }); } }