From ab3ba776e092a68ea4bfa98561df6e924d8148cf Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 8 Nov 2018 18:15:24 +0100 Subject: [PATCH] [d3d11] Do not re-upload mapped image if it was mapped for reading --- src/d3d11/d3d11_context_imm.cpp | 5 ++++- src/d3d11/d3d11_texture.h | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 8f63440e..5315203d 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -394,7 +394,7 @@ namespace dxvk { auto subresource = pResource->GetSubresourceFromIndex( formatInfo->aspectMask, Subresource); - pResource->SetMappedSubresource(subresource); + pResource->SetMappedSubresource(subresource, MapType); if (pResource->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT) { const VkImageType imageType = mappedImage->info().type; @@ -503,6 +503,9 @@ namespace dxvk { void D3D11ImmediateContext::UnmapImage( D3D11CommonTexture* pResource, UINT Subresource) { + if (pResource->GetMapType() == D3D11_MAP_READ) + return; + if (pResource->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER) { // Now that data has been written into the buffer, // we need to copy its contents into the image diff --git a/src/d3d11/d3d11_texture.h b/src/d3d11/d3d11_texture.h index b400dbee..5e291da7 100644 --- a/src/d3d11/d3d11_texture.h +++ b/src/d3d11/d3d11_texture.h @@ -105,13 +105,21 @@ namespace dxvk { VkImageSubresource GetMappedSubresource() const { return m_mappedSubresource; } + + /** + * \brief Current map type + */ + D3D11_MAP GetMapType() const { + return m_mapType; + } /** * \brief Sets mapped subresource * \param [in] subresource THe subresource */ - void SetMappedSubresource(VkImageSubresource subresource) { - m_mappedSubresource = subresource; + void SetMappedSubresource(VkImageSubresource Subresource, D3D11_MAP MapType) { + m_mappedSubresource = Subresource; + m_mapType = MapType; } /** @@ -188,6 +196,7 @@ namespace dxvk { VkImageSubresource m_mappedSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 }; + D3D11_MAP m_mapType = D3D11_MAP_READ; Rc CreateMappedBuffer() const;