From d9009efd22dd5d141dee1baf84d06e61e96ec042 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 18 Sep 2018 16:22:47 +0200 Subject: [PATCH] [d3d11] Implement and advertize support for CopyWithOverlap feature --- src/d3d11/d3d11_context.cpp | 40 +++++++++++++++++++++++++++---------- src/d3d11/d3d11_device.cpp | 2 +- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 7d7e496d..1965c12d 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -342,12 +342,22 @@ namespace dxvk { cDstSlice = dstBuffer.subSlice(dstOffset, regLength), cSrcSlice = srcBuffer.subSlice(srcOffset, regLength) ] (DxvkContext* ctx) { - ctx->copyBuffer( - cDstSlice.buffer(), - cDstSlice.offset(), - cSrcSlice.buffer(), - cSrcSlice.offset(), - cSrcSlice.length()); + bool sameResource = cDstSlice.buffer() == cSrcSlice.buffer(); + + if (!sameResource) { + ctx->copyBuffer( + cDstSlice.buffer(), + cDstSlice.offset(), + cSrcSlice.buffer(), + cSrcSlice.offset(), + cSrcSlice.length()); + } else { + ctx->copyBufferRegion( + cDstSlice.buffer(), + cDstSlice.offset(), + cSrcSlice.offset(), + cSrcSlice.length()); + } }); } else { const D3D11CommonTexture* dstTextureInfo = GetCommonTexture(pDstResource); @@ -476,10 +486,20 @@ namespace dxvk { cSrcOffset = srcOffset, cExtent = regExtent ] (DxvkContext* ctx) { - ctx->copyImage( - cDstImage, cDstLayers, cDstOffset, - cSrcImage, cSrcLayers, cSrcOffset, - cExtent); + bool sameSubresource = cDstImage == cSrcImage + && cDstLayers == cSrcLayers; + + if (!sameSubresource) { + ctx->copyImage( + cDstImage, cDstLayers, cDstOffset, + cSrcImage, cSrcLayers, cSrcOffset, + cExtent); + } else { + ctx->copyImageRegion( + cDstImage, cDstLayers, + cDstOffset, cSrcOffset, + cExtent); + } }); } } diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index d8d46555..77d555f8 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1153,7 +1153,7 @@ namespace dxvk { info->DiscardAPIsSeenByDriver = TRUE; info->FlagsForUpdateAndCopySeenByDriver = TRUE; info->ClearView = TRUE; - info->CopyWithOverlap = FALSE; + info->CopyWithOverlap = TRUE; info->ConstantBufferPartialUpdate = TRUE; info->ConstantBufferOffsetting = TRUE; info->MapNoOverwriteOnDynamicConstantBuffer = TRUE;