From 596f65f75f91d3f97e3a8f9132f58d93f5154fc9 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 22 Jun 2021 08:02:59 +0200 Subject: [PATCH] [d3d11] Handle MAP_MODE_STAGING when mapping images on the immediate context --- src/d3d11/d3d11_context_imm.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index b25cd4530..8a0b33a19 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -443,17 +443,24 @@ namespace dxvk { mapPtr = physSlice.mapPtr; } else { - // When using any map mode which requires the image contents - // to be preserved, and if the GPU has write access to the - // image, copy the current image contents into the buffer. - if (pResource->Desc()->Usage == D3D11_USAGE_STAGING - && !pResource->CanUpdateMappedBufferEarly()) { - UpdateMappedBuffer(pResource, subresource); - MapFlags &= ~D3D11_MAP_FLAG_DO_NOT_WAIT; + bool wait = MapType != D3D11_MAP_WRITE_NO_OVERWRITE; + + if (mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER) { + // When using any map mode which requires the image contents + // to be preserved, and if the GPU has write access to the + // image, copy the current image contents into the buffer. + if (pResource->Desc()->Usage == D3D11_USAGE_STAGING + && !pResource->CanUpdateMappedBufferEarly()) { + UpdateMappedBuffer(pResource, subresource); + MapFlags &= ~D3D11_MAP_FLAG_DO_NOT_WAIT; + } + + // Need to wait for any previous upload to finish anyway + wait = true; } // Wait for mapped buffer to become available - if (!WaitForResource(mappedBuffer, MapType, MapFlags)) + if (wait && !WaitForResource(mappedBuffer, MapType, MapFlags)) return DXGI_ERROR_WAS_STILL_DRAWING; mapPtr = pResource->GetMappedSlice(Subresource).mapPtr;