diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-04-16 15:19:27 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-04-16 15:19:27 +0000 |
| commit | 8fe180b3b2a179eb71d937ac65d12beb70b78a50 (patch) | |
| tree | 416a2448f32100846bacc9c2e31e5897500a920f /Graphics/GraphicsTools | |
| parent | Added convenience constructors for TextureData and MappedTextureSubresource s... (diff) | |
| download | DiligentCore-8fe180b3b2a179eb71d937ac65d12beb70b78a50.tar.gz DiligentCore-8fe180b3b2a179eb71d937ac65d12beb70b78a50.zip | |
Added validation to texture uploader dtors; updated pending operations counting in TextureUploaderD3D11
Diffstat (limited to 'Graphics/GraphicsTools')
| -rw-r--r-- | Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp | 18 | ||||
| -rw-r--r-- | Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp | 9 | ||||
| -rw-r--r-- | Graphics/GraphicsTools/src/TextureUploaderGL.cpp | 9 |
3 files changed, 35 insertions, 1 deletions
diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp index 162823d7..3d21df48 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp @@ -183,6 +183,15 @@ TextureUploaderD3D11::TextureUploaderD3D11(IReferenceCounters *pRefCounters, IRe TextureUploaderD3D11::~TextureUploaderD3D11() { + auto Stats = TextureUploaderD3D11::GetStats(); + if (Stats.NumPendingOperations != 0) + { + LOG_WARNING_MESSAGE("TextureUploaderD3D11::~TextureUploaderD3D11(): there ", (Stats.NumPendingOperations > 1 ? "are " : "is "), + Stats.NumPendingOperations, (Stats.NumPendingOperations > 1 ? " pending operations" : " pending operation"), + " in the queue. If other threads wait for ", (Stats.NumPendingOperations > 1 ? "these operations" : "this operation"), + ", they may deadlock."); + } + for (auto BuffQueueIt : m_pInternalData->m_UploadBufferCache) { if (BuffQueueIt.second.size()) @@ -338,7 +347,14 @@ TextureUploaderStats TextureUploaderD3D11::GetStats() { TextureUploaderStats Stats; std::lock_guard<std::mutex> QueueLock(m_pInternalData->m_PendingOperationsMtx); - Stats.NumPendingOperations = static_cast<Uint32>(m_pInternalData->m_PendingOperations.size()); + for (auto &OperationInfo : m_pInternalData->m_PendingOperations) + { + // Do not count MapAndCache operations as they are performed as part of the + // buffer recycling. + if (OperationInfo.operation == InternalData::PendingBufferOperation::Map || + OperationInfo.operation == InternalData::PendingBufferOperation::Copy) + ++Stats.NumPendingOperations; + } return Stats; } diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp index 2888a65d..775c9523 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp @@ -266,6 +266,15 @@ TextureUploaderD3D12_Vk::TextureUploaderD3D12_Vk(IReferenceCounters* pRefCounter TextureUploaderD3D12_Vk::~TextureUploaderD3D12_Vk() { + auto NumPendingOperations = m_pInternalData->GetNumPendingOperations(); + if (NumPendingOperations != 0) + { + LOG_WARNING_MESSAGE("TextureUploaderD3D12_Vk::~TextureUploaderD3D12_Vk(): there ", (NumPendingOperations > 1 ? "are " : "is "), + NumPendingOperations, (NumPendingOperations > 1 ? " pending operations" : " pending operation"), + " in the queue. If other threads wait for ", (NumPendingOperations > 1 ? "these operations" : "this operation"), + ", they may deadlock."); + + } } void TextureUploaderD3D12_Vk::RenderThreadUpdate(IDeviceContext* pContext) diff --git a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp index 4171a822..2ba1301c 100644 --- a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp +++ b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp @@ -152,6 +152,15 @@ TextureUploaderGL::TextureUploaderGL(IReferenceCounters *pRefCounters, IRenderDe TextureUploaderGL::~TextureUploaderGL() { + auto Stats = TextureUploaderGL::GetStats(); + if (Stats.NumPendingOperations != 0) + { + LOG_WARNING_MESSAGE("TextureUploaderGL::~TextureUploaderGL(): there ", (Stats.NumPendingOperations > 1 ? "are " : "is "), + Stats.NumPendingOperations, (Stats.NumPendingOperations > 1 ? " pending operations" : " pending operation"), + " in the queue. If other threads wait for ", (Stats.NumPendingOperations > 1 ? "these operations" : "this operation"), + ", they may deadlock."); + } + for (auto BuffQueueIt : m_pInternalData->m_UploadBufferCache) { if (BuffQueueIt.second.size()) |
