From 53e45f6540066115332a1471b98182b3baa82feb Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 14 Apr 2019 08:57:17 -0700 Subject: Added comments about Fence thread safety; minor code improvements --- Graphics/GraphicsEngine/interface/Fence.h | 4 ++++ Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h | 5 +++++ Graphics/GraphicsTools/include/TextureUploader.h | 6 +++--- Graphics/GraphicsTools/include/TextureUploaderBase.h | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/interface/Fence.h b/Graphics/GraphicsEngine/interface/Fence.h index 7a7ee8c5..d2a27473 100644 --- a/Graphics/GraphicsEngine/interface/Fence.h +++ b/Graphics/GraphicsEngine/interface/Fence.h @@ -54,6 +54,10 @@ public: virtual const FenceDesc& GetDesc()const override = 0; /// Returns the last completed value signaled by the GPU + + /// \remarks This method is not thread safe (even if the fence object is protected by mutex) + /// and must only be called by the same thread that signals the fence via + /// IDeviceContext::SignalFence(). virtual Uint64 GetCompletedValue() = 0; /// Resets the fence to the specified value. diff --git a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h index 7004d92e..894451e6 100644 --- a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h @@ -49,6 +49,11 @@ public: bool IsDeviceInternal = false); ~FenceVkImpl(); + // Note that this method is not thread-safe. The reason is that VulkanFencePool is not thread + // safe, and DeviceContextVkImpl::SignalFence() adds the fence to the pending fences list that + // are signalled later by the command context when it submits the command list. So there is no + // guarantee that the fence pool is not accessed simultaneously by multiple threads even if the + // fence object itself is protected by mutex. virtual Uint64 GetCompletedValue()override final; /// Resets the fence to the specified value. diff --git a/Graphics/GraphicsTools/include/TextureUploader.h b/Graphics/GraphicsTools/include/TextureUploader.h index dbbf65d0..8066e0ca 100644 --- a/Graphics/GraphicsTools/include/TextureUploader.h +++ b/Graphics/GraphicsTools/include/TextureUploader.h @@ -30,9 +30,9 @@ namespace Diligent { struct UploadBufferDesc { - Uint32 Width = 0; - Uint32 Height = 0; - Uint32 Depth = 1; + Uint32 Width = 0; + Uint32 Height = 0; + Uint32 Depth = 1; TEXTURE_FORMAT Format = TEX_FORMAT_UNKNOWN; bool operator == (const UploadBufferDesc &rhs) const diff --git a/Graphics/GraphicsTools/include/TextureUploaderBase.h b/Graphics/GraphicsTools/include/TextureUploaderBase.h index cd26c86d..d1c460a1 100644 --- a/Graphics/GraphicsTools/include/TextureUploaderBase.h +++ b/Graphics/GraphicsTools/include/TextureUploaderBase.h @@ -66,7 +66,7 @@ namespace Diligent class TextureUploaderBase : public ObjectBase { public: - TextureUploaderBase(IReferenceCounters *pRefCounters, IRenderDevice *pDevice, const TextureUploaderDesc Desc) : + TextureUploaderBase(IReferenceCounters* pRefCounters, IRenderDevice* pDevice, const TextureUploaderDesc Desc) : ObjectBase(pRefCounters), m_pDevice(pDevice) {} -- cgit v1.2.3