From 6b2f4f93cc51c7c75dbf4cc067c0b924052d6d35 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 3 Aug 2019 19:11:19 +0200 Subject: [PATCH] [d3d11] Fix incorrect tracking of mapped image subresources When returnig DXGI_ERROR_WAS_STILL_DRAWING, we should not mark the subresource as mapped, and instead ignore subsequent calls to Unmap. --- src/d3d11/d3d11_context_imm.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index a7d186d98..118da122e 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -340,8 +340,6 @@ namespace dxvk { if (unlikely(Subresource >= pResource->CountSubresources())) return E_INVALIDARG; - pResource->SetMapType(Subresource, MapType); - VkFormat packedFormat = m_parent->LookupPackedFormat( pResource->Desc()->Format, pResource->GetFormatMode()).Format; @@ -356,6 +354,9 @@ namespace dxvk { if (!WaitForResource(mappedImage, MapFlags)) return DXGI_ERROR_WAS_STILL_DRAWING; + // Mark the given subresource as mapped + pResource->SetMapType(Subresource, MapType); + // Query the subresource's memory layout and hope that // the application respects the returned pitch values. VkSubresourceLayout layout = mappedImage->querySubresourceLayout(subresource); @@ -397,6 +398,9 @@ namespace dxvk { physSlice = mappedBuffer->getSliceHandle(); } + // Mark the given subresource as mapped + pResource->SetMapType(Subresource, MapType); + // Set up map pointer. Data is tightly packed within the mapped buffer. pMappedResource->pData = physSlice.mapPtr; pMappedResource->RowPitch = formatInfo->elementSize * blockCount.width;