From 8c68236f701028f93ba152ea40175a1dd76255e5 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 18 Apr 2020 17:04:16 +0200 Subject: [PATCH] [d3d11] Check return value of Map in UpdateSubresource1 And fall back to a GPU-side copy if necessary. --- src/d3d11/d3d11_context.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 0cb8dcecd..69c9d9807 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1173,10 +1173,13 @@ namespace dxvk { : D3D11_MAP_WRITE_DISCARD; D3D11_MAPPED_SUBRESOURCE mappedSr; - Map(pDstResource, 0, mapType, 0, &mappedSr); - std::memcpy(reinterpret_cast(mappedSr.pData) + offset, pSrcData, size); - Unmap(pDstResource, 0); - } else { + if (likely(useMap = SUCCEEDED(Map(pDstResource, 0, mapType, 0, &mappedSr)))) { + std::memcpy(reinterpret_cast(mappedSr.pData) + offset, pSrcData, size); + Unmap(pDstResource, 0); + } + } + + if (!useMap) { DxvkDataSlice dataSlice = AllocUpdateBufferSlice(size); std::memcpy(dataSlice.ptr(), pSrcData, size);