summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsTools
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-04-16 05:47:22 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-04-16 05:47:22 +0000
commitffb0104f60cd4152f84fe0cd5e1d9f51b82683c3 (patch)
tree2469485f2aac6dad816a20872fe1419936fcc690 /Graphics/GraphicsTools
parentFixed Linux/Mac build error (diff)
downloadDiligentCore-ffb0104f60cd4152f84fe0cd5e1d9f51b82683c3.tar.gz
DiligentCore-ffb0104f60cd4152f84fe0cd5e1d9f51b82683c3.zip
Added ITextureUploader::GetStats method
Diffstat (limited to 'Graphics/GraphicsTools')
-rw-r--r--Graphics/GraphicsTools/include/TextureUploader.h23
-rw-r--r--Graphics/GraphicsTools/include/TextureUploaderD3D11.h2
-rw-r--r--Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h2
-rw-r--r--Graphics/GraphicsTools/include/TextureUploaderGL.h2
-rw-r--r--Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp8
-rw-r--r--Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp32
-rw-r--r--Graphics/GraphicsTools/src/TextureUploaderGL.cpp8
7 files changed, 65 insertions, 12 deletions
diff --git a/Graphics/GraphicsTools/include/TextureUploader.h b/Graphics/GraphicsTools/include/TextureUploader.h
index 8066e0ca..dbc4383f 100644
--- a/Graphics/GraphicsTools/include/TextureUploader.h
+++ b/Graphics/GraphicsTools/include/TextureUploader.h
@@ -59,14 +59,27 @@ namespace Diligent
};
+ struct TextureUploaderStats
+ {
+ Uint32 NumPendingOperations = 0;
+ };
+
class ITextureUploader : public IObject
{
public:
- virtual void RenderThreadUpdate(IDeviceContext *pContext) = 0;
- virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc, bool IsRenderThread, IUploadBuffer **ppBuffer) = 0;
- virtual void ScheduleGPUCopy(ITexture *pDstTexture, Uint32 ArraySlice, Uint32 MipLevel, IUploadBuffer *pUploadBuffer) = 0;
- virtual void RecycleBuffer(IUploadBuffer *pUploadBuffer) = 0;
+ virtual void RenderThreadUpdate(IDeviceContext* pContext) = 0;
+
+ virtual void AllocateUploadBuffer(const UploadBufferDesc& Desc,
+ bool IsRenderThread,
+ IUploadBuffer** ppBuffer) = 0;
+ virtual void ScheduleGPUCopy(ITexture* pDstTexture,
+ Uint32 ArraySlice,
+ Uint32 MipLevel,
+ IUploadBuffer* pUploadBuffer) = 0;
+ virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer) = 0;
+
+ virtual TextureUploaderStats GetStats() = 0;
};
- void CreateTextureUploader(IRenderDevice *pDevice, const TextureUploaderDesc& Desc, ITextureUploader **ppUploader);
+ void CreateTextureUploader(IRenderDevice* pDevice, const TextureUploaderDesc& Desc, ITextureUploader** ppUploader);
}
diff --git a/Graphics/GraphicsTools/include/TextureUploaderD3D11.h b/Graphics/GraphicsTools/include/TextureUploaderD3D11.h
index f6cec59d..a1274df5 100644
--- a/Graphics/GraphicsTools/include/TextureUploaderD3D11.h
+++ b/Graphics/GraphicsTools/include/TextureUploaderD3D11.h
@@ -45,6 +45,8 @@ namespace Diligent
IUploadBuffer* pUploadBuffer)override final;
virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer)override final;
+ virtual TextureUploaderStats GetStats()override final;
+
private:
struct InternalData;
std::unique_ptr<InternalData> m_pInternalData;
diff --git a/Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h b/Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h
index 585d0f37..6b8bc7e3 100644
--- a/Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h
+++ b/Graphics/GraphicsTools/include/TextureUploaderD3D12_Vk.h
@@ -45,6 +45,8 @@ namespace Diligent
IUploadBuffer* pUploadBuffer)override final;
virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer)override final;
+ virtual TextureUploaderStats GetStats()override final;
+
private:
struct InternalData;
std::unique_ptr<InternalData> m_pInternalData;
diff --git a/Graphics/GraphicsTools/include/TextureUploaderGL.h b/Graphics/GraphicsTools/include/TextureUploaderGL.h
index fd9d77e4..d8182d22 100644
--- a/Graphics/GraphicsTools/include/TextureUploaderGL.h
+++ b/Graphics/GraphicsTools/include/TextureUploaderGL.h
@@ -45,6 +45,8 @@ namespace Diligent
IUploadBuffer* pUploadBuffer)override final;
virtual void RecycleBuffer(IUploadBuffer* pUploadBuffer)override final;
+ virtual TextureUploaderStats GetStats()override final;
+
private:
struct InternalData;
std::unique_ptr<InternalData> m_pInternalData;
diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp
index 17fffc39..162823d7 100644
--- a/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp
+++ b/Graphics/GraphicsTools/src/TextureUploaderD3D11.cpp
@@ -334,4 +334,12 @@ void TextureUploaderD3D11::RecycleBuffer(IUploadBuffer *pUploadBuffer)
m_pInternalData->EnqueMap(pUploadBufferD3D11, InternalData::PendingBufferOperation::MapAndCache);
}
+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());
+ return Stats;
+}
+
} // namespace Diligent
diff --git a/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp b/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp
index b2c6e5e1..2888a65d 100644
--- a/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp
+++ b/Graphics/GraphicsTools/src/TextureUploaderD3D12_Vk.cpp
@@ -239,6 +239,12 @@ struct TextureUploaderD3D12_Vk::InternalData
Deque.emplace_back(pUploadTexture);
}
+ Uint32 GetNumPendingOperations()
+ {
+ std::lock_guard<std::mutex> QueueLock(m_PendingOperationsMtx);
+ return static_cast<Uint32>(m_PendingOperations.size());
+ }
+
private:
std::mutex m_PendingOperationsMtx;
std::vector<PendingBufferOperation> m_PendingOperations;
@@ -267,6 +273,7 @@ void TextureUploaderD3D12_Vk::RenderThreadUpdate(IDeviceContext* pContext)
auto& InWorkOperations = m_pInternalData->SwapMapQueues();
if (!InWorkOperations.empty())
{
+ Uint32 NumCopyOperations = 0;
for (auto& OperationInfo : InWorkOperations)
{
auto& pUploadTex = OperationInfo.pUploadTexture;
@@ -295,19 +302,23 @@ void TextureUploaderD3D12_Vk::RenderThreadUpdate(IDeviceContext* pContext)
CopyInfo.DstSlice = OperationInfo.DstSlice;
CopyInfo.DstMipLevel = OperationInfo.DstMip;
pContext->CopyTexture(CopyInfo);
+ ++NumCopyOperations;
}
break;
}
}
- // The buffer may be recycled immediately after the copy scheduled is signaled,
- // so we must signal the fence first.
- auto SignaledFenceValue = m_pInternalData->SignalFence(pContext);
-
- for (auto& OperationInfo : InWorkOperations)
+ if (NumCopyOperations > 0)
{
- if (OperationInfo.operation == InternalData::PendingBufferOperation::Copy)
- OperationInfo.pUploadTexture->SignalCopyScheduled(SignaledFenceValue);
+ // The buffer may be recycled immediately after the copy scheduled is signaled,
+ // so we must signal the fence first.
+ auto SignaledFenceValue = m_pInternalData->SignalFence(pContext);
+
+ for (auto& OperationInfo : InWorkOperations)
+ {
+ if (OperationInfo.operation == InternalData::PendingBufferOperation::Copy)
+ OperationInfo.pUploadTexture->SignalCopyScheduled(SignaledFenceValue);
+ }
}
InWorkOperations.clear();
@@ -362,4 +373,11 @@ void TextureUploaderD3D12_Vk::RecycleBuffer(IUploadBuffer* pUploadBuffer)
m_pInternalData->RecycleUploadTexture(pUploadTexture);
}
+TextureUploaderStats TextureUploaderD3D12_Vk::GetStats()
+{
+ TextureUploaderStats Stats;
+ Stats.NumPendingOperations = static_cast<Uint32>(m_pInternalData->GetNumPendingOperations());
+ return Stats;
+}
+
} // namespace Diligent
diff --git a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp
index ff568f94..4171a822 100644
--- a/Graphics/GraphicsTools/src/TextureUploaderGL.cpp
+++ b/Graphics/GraphicsTools/src/TextureUploaderGL.cpp
@@ -278,4 +278,12 @@ void TextureUploaderGL::RecycleBuffer(IUploadBuffer *pUploadBuffer)
Deque.emplace_back( pUploadBufferGL );
}
+TextureUploaderStats TextureUploaderGL::GetStats()
+{
+ TextureUploaderStats Stats;
+ std::lock_guard<std::mutex> QueueLock(m_pInternalData->m_PendingOperationsMtx);
+ Stats.NumPendingOperations = static_cast<Uint32>(m_pInternalData->m_PendingOperations.size());
+ return Stats;
+}
+
} // namespace Diligent