summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-12-02 18:22:22 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-12-02 18:22:22 +0000
commit111636445d2e19420468cdf78ffd2b87b7ad6489 (patch)
treeadb5457b4f0cd56a323c99f1cedc5a2fce0667ee /Graphics/GraphicsEngineD3D12
parentAdded explicit state transition control to UpdateBuffer and UpdateTexture com... (diff)
downloadDiligentCore-111636445d2e19420468cdf78ffd2b87b7ad6489.tar.gz
DiligentCore-111636445d2e19420468cdf78ffd2b87b7ad6489.zip
Brought back MapType paramter to UnmapBuffer() function. The performance hit of keeping track of mapped buffers turned out to be unacceptable
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h8
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp27
2 files changed, 5 insertions, 30 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
index a9750a22..ff006981 100644
--- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
+++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h
@@ -105,7 +105,7 @@ public:
virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData)override final;
- virtual void UnmapBuffer(IBuffer* pBuffer)override final;
+ virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType)override final;
virtual void UpdateTexture(ITexture* pTexture,
Uint32 MipLevel,
@@ -284,12 +284,6 @@ private:
};
};
std::unordered_map<MappedTextureKey, TextureUploadSpace, MappedTextureKey::Hasher> m_MappedTextures;
-
- struct MappedBufferInfo
- {
- MAP_TYPE MapType;
- };
- std::unordered_map<BufferD3D12Impl*, MappedBufferInfo> m_MappedBuffers;
};
}
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 605cda1f..af7c2beb 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -663,8 +663,8 @@ namespace Diligent
void DeviceContextD3D12Impl::FinishFrame()
{
-#ifdef DEVELOPMENT
- for(const auto& MappedBuffIt : m_MappedBuffers)
+#ifdef _DEBUG
+ for(const auto& MappedBuffIt : m_DbgMappedBuffers)
{
const auto& BuffDesc = MappedBuffIt.first->GetDesc();
if (BuffDesc.Usage == USAGE_DYNAMIC)
@@ -941,13 +941,6 @@ namespace Diligent
const auto& BuffDesc = pBufferD3D12->GetDesc();
auto* pd3d12Resource = pBufferD3D12->m_pd3d12Resource.p;
-#ifdef DEVELOPMENT
- if (m_MappedBuffers.find(pBufferD3D12) != m_MappedBuffers.end())
- {
- LOG_ERROR_MESSAGE("Buffer '", BuffDesc.Name, "' has already been mapped");
- }
-#endif
-
if (MapType == MAP_READ)
{
LOG_WARNING_MESSAGE_ONCE("Mapping CPU buffer for reading on D3D12 currently requires flushing context and idling GPU");
@@ -999,24 +992,14 @@ namespace Diligent
{
LOG_ERROR("Only MAP_WRITE_DISCARD and MAP_READ are currently implemented in D3D12");
}
- m_MappedBuffers[pBufferD3D12] = MappedBufferInfo{MapType};
}
- void DeviceContextD3D12Impl::UnmapBuffer(IBuffer* pBuffer)
+ void DeviceContextD3D12Impl::UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType)
{
- TDeviceContextBase::UnmapBuffer(pBuffer);
+ TDeviceContextBase::UnmapBuffer(pBuffer, MapType);
auto* pBufferD3D12 = ValidatedCast<BufferD3D12Impl>(pBuffer);
- auto MappedBufferIt = m_MappedBuffers.find(pBufferD3D12);
- if (MappedBufferIt == m_MappedBuffers.end())
- {
- LOG_ERROR_MESSAGE("Buffer '", pBufferD3D12->GetDesc().Name, "' has not been mapped.");
- return;
- }
- const auto& MapInfo = MappedBufferIt->second;
const auto& BuffDesc = pBufferD3D12->GetDesc();
auto* pd3d12Resource = pBufferD3D12->m_pd3d12Resource.p;
-
- auto MapType = MapInfo.MapType;
if (MapType == MAP_READ )
{
D3D12_RANGE MapRange;
@@ -1041,8 +1024,6 @@ namespace Diligent
}
}
}
-
- m_MappedBuffers.erase(MappedBufferIt);
}
void DeviceContextD3D12Impl::UpdateTexture(ITexture* pTexture,