From 6c17fa075bc0ea3dff8bfaf222aae5d466b0fbd9 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 4 Feb 2019 10:25:49 +0100 Subject: [PATCH] [d3d11] Minor map optimization on deferred contexts --- src/d3d11/d3d11_buffer.h | 4 ++++ src/d3d11/d3d11_context_def.cpp | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/d3d11/d3d11_buffer.h b/src/d3d11/d3d11_buffer.h index 1883aa51..45b1a9a7 100644 --- a/src/d3d11/d3d11_buffer.h +++ b/src/d3d11/d3d11_buffer.h @@ -94,6 +94,10 @@ namespace dxvk { return m_soCounter; } + DxvkBufferSliceHandle AllocSlice() { + return m_buffer->allocSlice(); + } + DxvkBufferSliceHandle DiscardSlice() { m_mapped = m_buffer->allocSlice(); return m_mapped; diff --git a/src/d3d11/d3d11_context_def.cpp b/src/d3d11/d3d11_context_def.cpp index 97999233..0220a4dc 100644 --- a/src/d3d11/d3d11_context_def.cpp +++ b/src/d3d11/d3d11_context_def.cpp @@ -165,9 +165,8 @@ namespace dxvk { UINT MapFlags, D3D11DeferredContextMapEntry* pMapEntry) { D3D11Buffer* pBuffer = static_cast(pResource); - const Rc buffer = pBuffer->GetBuffer(); - if (!(buffer->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { + if (unlikely(pBuffer->GetMapMode() == D3D11_COMMON_BUFFER_MAP_MODE_NONE)) { Logger::err("D3D11: Cannot map a device-local buffer"); return E_INVALIDARG; } @@ -182,7 +181,7 @@ namespace dxvk { // For resources that cannot be written by the GPU, // we may write to the buffer resource directly and // just swap in the buffer slice as needed. - pMapEntry->BufferSlice = buffer->allocSlice(); + pMapEntry->BufferSlice = pBuffer->AllocSlice(); pMapEntry->MapPointer = pMapEntry->BufferSlice.mapPtr; } else { // For GPU-writable resources, we need a data slice