From 9c32beccdc6a8ea9c7f9d6f4255cb54600ab5b49 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 8 Feb 2022 23:44:23 +0100 Subject: [PATCH] [d3d11] Store buffer map mode in D3D11Buffer Matches what we do for textures, and makes it so that we don't have to dereference the resource pointer to figure this out. --- src/d3d11/d3d11_buffer.cpp | 9 +++++++++ src/d3d11/d3d11_buffer.h | 19 ++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/d3d11/d3d11_buffer.cpp b/src/d3d11/d3d11_buffer.cpp index 687be0a5..9b1ee35a 100644 --- a/src/d3d11/d3d11_buffer.cpp +++ b/src/d3d11/d3d11_buffer.cpp @@ -74,6 +74,8 @@ namespace dxvk { m_buffer = m_parent->GetDXVKDevice()->createBuffer(info, GetMemoryFlags()); m_mapped = m_buffer->getSliceHandle(); + m_mapMode = DetermineMapMode(); + // For Stream Output buffers we need a counter if (pDesc->BindFlags & D3D11_BIND_STREAM_OUTPUT) m_soCounter = CreateSoCounterBuffer(); @@ -273,6 +275,13 @@ namespace dxvk { | VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT; return device->createBuffer(info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); } + + + D3D11_COMMON_BUFFER_MAP_MODE D3D11Buffer::DetermineMapMode() { + return (m_buffer->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) + ? D3D11_COMMON_BUFFER_MAP_MODE_DIRECT + : D3D11_COMMON_BUFFER_MAP_MODE_NONE; + } D3D11Buffer* GetCommonBuffer(ID3D11Resource* pResource) { diff --git a/src/d3d11/d3d11_buffer.h b/src/d3d11/d3d11_buffer.h index 3ddd61a0..8bb30aef 100644 --- a/src/d3d11/d3d11_buffer.h +++ b/src/d3d11/d3d11_buffer.h @@ -67,9 +67,7 @@ namespace dxvk { } D3D11_COMMON_BUFFER_MAP_MODE GetMapMode() const { - return (m_buffer->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) - ? D3D11_COMMON_BUFFER_MAP_MODE_DIRECT - : D3D11_COMMON_BUFFER_MAP_MODE_NONE; + return m_mapMode; } Rc GetBuffer() const { @@ -130,14 +128,15 @@ namespace dxvk { private: - const D3D11_BUFFER_DESC m_desc; + D3D11_BUFFER_DESC m_desc; + D3D11_COMMON_BUFFER_MAP_MODE m_mapMode; - Rc m_buffer; - Rc m_soCounter; - DxvkBufferSliceHandle m_mapped; + Rc m_buffer; + Rc m_soCounter; + DxvkBufferSliceHandle m_mapped; - D3D11DXGIResource m_resource; - D3D10Buffer m_d3d10; + D3D11DXGIResource m_resource; + D3D10Buffer m_d3d10; BOOL CheckFormatFeatureSupport( VkFormat Format, @@ -147,6 +146,8 @@ namespace dxvk { Rc CreateSoCounterBuffer(); + D3D11_COMMON_BUFFER_MAP_MODE DetermineMapMode(); + };