summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2019-12-23 20:33:55 +0000
committerassiduous <assiduous@diligentgraphics.com>2019-12-23 20:33:55 +0000
commitd4b8e0c30214065e63d428be3219f6db18e02a2d (patch)
treeb55a8a43c6cc342a098463e3b3529f566d61b203 /Graphics/GraphicsEngineD3D12
parentFixed issue with const PVoid not being the intended const void* (diff)
downloadDiligentCore-d4b8e0c30214065e63d428be3219f6db18e02a2d.tar.gz
DiligentCore-d4b8e0c30214065e63d428be3219f6db18e02a2d.zip
Fixed staging buffers in Vulkan and D3D12 backends (https://github.com/DiligentGraphics/DiligentEngine/issues/69). Added buffer access test.
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
index 12de666b..5d35eb82 100644
--- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp
@@ -1083,10 +1083,16 @@ void DeviceContextD3D12Impl::MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_F
if (MapType == MAP_READ)
{
- LOG_WARNING_MESSAGE_ONCE("Mapping CPU buffer for reading on D3D12 currently requires flushing context and idling GPU");
- Flush();
- m_pDevice->IdleGPU();
- VERIFY(BuffDesc.Usage == USAGE_STAGING, "Buffer must be created as USAGE_STAGING to be mapped for reading");
+ DEV_CHECK_ERR(BuffDesc.Usage == USAGE_STAGING, "Buffer must be created as USAGE_STAGING to be mapped for reading");
+ DEV_CHECK_ERR(pd3d12Resource != nullptr, "USAGE_STAGING buffer must intialize D3D12 resource");
+
+ if ((MapFlags & MAP_FLAG_DO_NOT_WAIT) == 0)
+ {
+ LOG_WARNING_MESSAGE("D3D12 backend never waits for GPU when mapping staging buffers for reading. "
+ "Applications must use fences or other synchronization methods to explicitly synchronize "
+ "access and use MAP_FLAG_DO_NOT_WAIT flag.");
+ }
+
D3D12_RANGE MapRange;
MapRange.Begin = 0;
MapRange.End = BuffDesc.uiSizeInBytes;
@@ -1096,7 +1102,7 @@ void DeviceContextD3D12Impl::MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_F
{
if (BuffDesc.Usage == USAGE_STAGING)
{
- VERIFY(pd3d12Resource != nullptr, "USAGE_STAGING buffer mapped for writing must intialize D3D12 resource");
+ DEV_CHECK_ERR(pd3d12Resource != nullptr, "USAGE_STAGING buffer mapped for writing must intialize D3D12 resource");
if (MapFlags & MAP_FLAG_DISCARD)
{
}
@@ -1104,7 +1110,7 @@ void DeviceContextD3D12Impl::MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_F
}
else if (BuffDesc.Usage == USAGE_DYNAMIC)
{
- VERIFY((MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_NO_OVERWRITE)) != 0, "D3D12 buffer must be mapped for writing with MAP_FLAG_DISCARD or MAP_FLAG_NO_OVERWRITE flag");
+ DEV_CHECK_ERR((MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_NO_OVERWRITE)) != 0, "D3D12 buffer must be mapped for writing with MAP_FLAG_DISCARD or MAP_FLAG_NO_OVERWRITE flag");
auto& DynamicData = pBufferD3D12->m_DynamicData[m_ContextId];
if ((MapFlags & MAP_FLAG_DISCARD) != 0 || DynamicData.CPUAddress == nullptr)
{
@@ -1564,9 +1570,9 @@ void DeviceContextD3D12Impl::MapTextureSubresource(ITexture* pTe
{
if ((MapFlags & MAP_FLAG_DO_NOT_WAIT) == 0)
{
- LOG_WARNING_MESSAGE("Mapping staging textures for reading never blocks or waits for GPU in D3D12 backend. "
+ LOG_WARNING_MESSAGE("D3D12 backend never waits for GPU when mapping staging textures for reading. "
"Applications must use fences or other synchronization methods to explicitly synchronize "
- "access and map texture with MAP_FLAG_DO_NOT_WAIT flag.");
+ "access and use MAP_FLAG_DO_NOT_WAIT flag.");
}
DEV_CHECK_ERR((TexDesc.CPUAccessFlags & CPU_ACCESS_READ), "Texture '", TexDesc.Name, "' was not created with CPU_ACCESS_READ flag and can't be mapped for reading");