summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-11-24 21:04:17 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-11-24 21:04:17 +0000
commit3a2dbbcbe5c7a9057184b1e11fd875f2f371ab10 (patch)
tree6d13cb56fd32e7bea05670f9ac5fb731a9166f29 /Graphics/GraphicsEngineVulkan
parentclang-formatted GraphicsEngineMetal project (diff)
downloadDiligentCore-3a2dbbcbe5c7a9057184b1e11fd875f2f371ab10.tar.gz
DiligentCore-3a2dbbcbe5c7a9057184b1e11fd875f2f371ab10.zip
clang-formatted headers of GraphicsEngineVulkan project
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h15
-rw-r--r--Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h48
-rw-r--r--Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h22
-rw-r--r--Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/CommandQueueVkImpl.h36
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h59
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h190
-rw-r--r--Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h13
-rw-r--r--Graphics/GraphicsEngineVulkan/include/FramebufferCache.h24
-rw-r--r--Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.h62
-rw-r--r--Graphics/GraphicsEngineVulkan/include/PipelineLayout.h106
-rw-r--r--Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h66
-rw-r--r--Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h80
-rw-r--r--Graphics/GraphicsEngineVulkan/include/RenderPassCache.h44
-rw-r--r--Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h8
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.h19
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h96
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h159
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h66
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h17
-rw-r--r--Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.h38
-rw-r--r--Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h28
-rw-r--r--Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h42
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h64
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanErrors.h26
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.h25
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h43
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h752
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h57
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h218
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanFencePool.h44
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h82
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h286
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h72
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h123
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h72
-rw-r--r--Graphics/GraphicsEngineVulkan/include/pch.h41
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/BufferViewVk.h7
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/BufferVk.h7
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h14
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h11
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h101
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/FenceVk.h6
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/PipelineStateVk.h9
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h23
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/SamplerVk.h7
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/ShaderResourceBindingVk.h6
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/ShaderVk.h7
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h5
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/TextureViewVk.h7
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/TextureVk.h11
51 files changed, 1751 insertions, 1615 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h
index 1d031bde..5a8795de 100644
--- a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h
@@ -45,24 +45,23 @@ public:
using TBufferViewBase = BufferViewBase<IBufferViewVk, RenderDeviceVkImpl>;
BufferViewVkImpl(IReferenceCounters* pRefCounters,
- RenderDeviceVkImpl* pDevice,
- const BufferViewDesc& ViewDesc,
+ RenderDeviceVkImpl* pDevice,
+ const BufferViewDesc& ViewDesc,
class IBuffer* pBuffer,
VulkanUtilities::BufferViewWrapper&& BuffView,
bool bIsDefaultView);
~BufferViewVkImpl();
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
/// Implementation of IBufferViewVk::GetVkBufferView().
- virtual VkBufferView GetVkBufferView()const override final{return m_BuffView;}
+ virtual VkBufferView GetVkBufferView() const override final { return m_BuffView; }
- const BufferVkImpl* GetBufferVk()const;
- BufferVkImpl* GetBufferVk();
+ const BufferVkImpl* GetBufferVk() const;
+ BufferVkImpl* GetBufferVk();
protected:
-
VulkanUtilities::BufferViewWrapper m_BuffView;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h
index 0f785181..9462b423 100644
--- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h
@@ -49,29 +49,29 @@ class BufferVkImpl final : public BufferBase<IBufferVk, RenderDeviceVkImpl, Buff
public:
using TBufferBase = BufferBase<IBufferVk, RenderDeviceVkImpl, BufferViewVkImpl, FixedBlockMemoryAllocator>;
- BufferVkImpl(IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
- RenderDeviceVkImpl* pDeviceVk,
- const BufferDesc& BuffDesc,
+ BufferVkImpl(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
+ RenderDeviceVkImpl* pDeviceVk,
+ const BufferDesc& BuffDesc,
const BufferData* pBuffData = nullptr);
- BufferVkImpl(IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
- class RenderDeviceVkImpl* pDeviceVk,
- const BufferDesc& BuffDesc,
+ BufferVkImpl(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& BuffViewObjMemAllocator,
+ class RenderDeviceVkImpl* pDeviceVk,
+ const BufferDesc& BuffDesc,
RESOURCE_STATE InitialState,
VkBuffer vkBuffer);
~BufferVkImpl();
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override;
#ifdef DEVELOPMENT
- void DvpVerifyDynamicAllocation(DeviceContextVkImpl* pCtx)const;
+ void DvpVerifyDynamicAllocation(DeviceContextVkImpl* pCtx) const;
#endif
- Uint32 GetDynamicOffset(Uint32 CtxId, DeviceContextVkImpl* pCtx)const
+ Uint32 GetDynamicOffset(Uint32 CtxId, DeviceContextVkImpl* pCtx) const
{
- if(m_VulkanBuffer != VK_NULL_HANDLE)
+ if (m_VulkanBuffer != VK_NULL_HANDLE)
{
return 0;
}
@@ -88,22 +88,22 @@ public:
}
/// Implementation of IBufferVk::GetVkBuffer().
- VkBuffer GetVkBuffer()const override final;
+ VkBuffer GetVkBuffer() const override final;
/// Implementation of IBuffer::GetNativeHandle() in Vulkan backend.
- virtual void* GetNativeHandle()override final
- {
- auto vkBuffer = GetVkBuffer();
+ virtual void* GetNativeHandle() override final
+ {
+ auto vkBuffer = GetVkBuffer();
return vkBuffer;
}
/// Implementation of IBufferVk::SetAccessFlags().
- virtual void SetAccessFlags(VkAccessFlags AccessFlags)override final;
+ virtual void SetAccessFlags(VkAccessFlags AccessFlags) override final;
/// Implementation of IBufferVk::GetAccessFlags().
- virtual VkAccessFlags GetAccessFlags()const override final;
+ virtual VkAccessFlags GetAccessFlags() const override final;
- bool CheckAccessFlags(VkAccessFlags AccessFlags)const
+ bool CheckAccessFlags(VkAccessFlags AccessFlags) const
{
return (GetAccessFlags() & AccessFlags) == AccessFlags;
}
@@ -111,15 +111,15 @@ public:
private:
friend class DeviceContextVkImpl;
- virtual void CreateViewInternal(const struct BufferViewDesc& ViewDesc, IBufferView** ppView, bool bIsDefaultView)override;
+ virtual void CreateViewInternal(const struct BufferViewDesc& ViewDesc, IBufferView** ppView, bool bIsDefaultView) override;
- VulkanUtilities::BufferViewWrapper CreateView(struct BufferViewDesc &ViewDesc);
- Uint32 m_DynamicOffsetAlignment = 0;
+ VulkanUtilities::BufferViewWrapper CreateView(struct BufferViewDesc& ViewDesc);
+ Uint32 m_DynamicOffsetAlignment = 0;
- std::vector<VulkanDynamicAllocation, STDAllocatorRawMem<VulkanDynamicAllocation> > m_DynamicAllocations;
+ std::vector<VulkanDynamicAllocation, STDAllocatorRawMem<VulkanDynamicAllocation>> m_DynamicAllocations;
VulkanUtilities::BufferWrapper m_VulkanBuffer;
VulkanUtilities::VulkanMemoryAllocation m_MemoryAllocation;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h b/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h
index e0aaa628..86badad8 100644
--- a/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h
@@ -39,16 +39,18 @@ class CommandListVkImpl final : public CommandListBase<ICommandList, RenderDevic
public:
using TCommandListBase = CommandListBase<ICommandList, RenderDeviceVkImpl>;
- CommandListVkImpl(IReferenceCounters* pRefCounters,
- RenderDeviceVkImpl* pDevice,
- IDeviceContext* pDeferredCtx,
- VkCommandBuffer vkCmdBuff) :
+ CommandListVkImpl(IReferenceCounters* pRefCounters,
+ RenderDeviceVkImpl* pDevice,
+ IDeviceContext* pDeferredCtx,
+ VkCommandBuffer vkCmdBuff) :
+ // clang-format off
TCommandListBase {pRefCounters, pDevice},
m_pDeferredCtx {pDeferredCtx},
m_vkCmdBuff {vkCmdBuff }
+ // clang-format on
{
}
-
+
~CommandListVkImpl()
{
VERIFY(m_vkCmdBuff == VK_NULL_HANDLE && !m_pDeferredCtx, "Destroying command list that was never executed");
@@ -57,14 +59,14 @@ public:
void Close(VkCommandBuffer& CmdBuff,
RefCntAutoPtr<IDeviceContext>& pDeferredCtx)
{
- CmdBuff = m_vkCmdBuff;
- m_vkCmdBuff = VK_NULL_HANDLE;
- pDeferredCtx = std::move(m_pDeferredCtx);
+ CmdBuff = m_vkCmdBuff;
+ m_vkCmdBuff = VK_NULL_HANDLE;
+ pDeferredCtx = std::move(m_pDeferredCtx);
}
private:
RefCntAutoPtr<IDeviceContext> m_pDeferredCtx;
- VkCommandBuffer m_vkCmdBuff;
+ VkCommandBuffer m_vkCmdBuff;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h b/Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h
index f57f8b22..c28d1838 100644
--- a/Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h
+++ b/Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h
@@ -42,10 +42,12 @@ public:
uint32_t queueFamilyIndex,
VkCommandPoolCreateFlags flags)noexcept;
+ // clang-format off
CommandPoolManager (const CommandPoolManager&) = delete;
CommandPoolManager ( CommandPoolManager&&) = delete;
CommandPoolManager& operator = (const CommandPoolManager&) = delete;
CommandPoolManager& operator = ( CommandPoolManager&&) = delete;
+ // clang-format on
~CommandPoolManager();
diff --git a/Graphics/GraphicsEngineVulkan/include/CommandQueueVkImpl.h b/Graphics/GraphicsEngineVulkan/include/CommandQueueVkImpl.h
index 2744a013..4172ef2c 100644
--- a/Graphics/GraphicsEngineVulkan/include/CommandQueueVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/CommandQueueVkImpl.h
@@ -43,48 +43,48 @@ class CommandQueueVkImpl final : public ObjectBase<ICommandQueueVk>
public:
using TBase = ObjectBase<ICommandQueueVk>;
- CommandQueueVkImpl(IReferenceCounters* pRefCounters,
- std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> LogicalDevice,
+ CommandQueueVkImpl(IReferenceCounters* pRefCounters,
+ std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> LogicalDevice,
uint32_t QueueFamilyIndex);
~CommandQueueVkImpl();
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
- /// Implementation of ICommandQueueVk::GetNextFenceValue().
- virtual Uint64 GetNextFenceValue()override final { return m_NextFenceValue; }
+ /// Implementation of ICommandQueueVk::GetNextFenceValue().
+ virtual Uint64 GetNextFenceValue() override final { return m_NextFenceValue; }
- /// Implementation of ICommandQueueVk::Submit().
- virtual Uint64 Submit(VkCommandBuffer cmdBuffer)override final;
+ /// Implementation of ICommandQueueVk::Submit().
+ virtual Uint64 Submit(VkCommandBuffer cmdBuffer) override final;
/// Implementation of ICommandQueueVk::Submit().
- virtual Uint64 Submit(const VkSubmitInfo& SubmitInfo)override final;
+ virtual Uint64 Submit(const VkSubmitInfo& SubmitInfo) override final;
/// Implementation of ICommandQueueVk::Present().
- virtual VkResult Present(const VkPresentInfoKHR& PresentInfo)override final;
+ virtual VkResult Present(const VkPresentInfoKHR& PresentInfo) override final;
/// Implementation of ICommandQueueVk::GetVkQueue().
- virtual VkQueue GetVkQueue()override final{return m_VkQueue;}
+ virtual VkQueue GetVkQueue() override final { return m_VkQueue; }
/// Implementation of ICommandQueueVk::GetQueueFamilyIndex().
- virtual uint32_t GetQueueFamilyIndex()const override final { return m_QueueFamilyIndex; }
+ virtual uint32_t GetQueueFamilyIndex() const override final { return m_QueueFamilyIndex; }
/// Implementation of ICommandQueueVk::GetQueueFamilyIndex().
- virtual Uint64 WaitForIdle()override final;
+ virtual Uint64 WaitForIdle() override final;
/// Implementation of ICommandQueueVk::GetCompletedFenceValue().
- virtual Uint64 GetCompletedFenceValue()override final;
+ virtual Uint64 GetCompletedFenceValue() override final;
/// Implementation of ICommandQueueVk::SignalFence().
- virtual void SignalFence(VkFence vkFence)override final;
+ virtual void SignalFence(VkFence vkFence) override final;
- void SetFence(RefCntAutoPtr<FenceVkImpl> pFence){m_pFence = std::move(pFence);}
+ void SetFence(RefCntAutoPtr<FenceVkImpl> pFence) { m_pFence = std::move(pFence); }
private:
std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> m_LogicalDevice;
- const VkQueue m_VkQueue;
+ const VkQueue m_VkQueue;
const uint32_t m_QueueFamilyIndex;
- // Fence is signaled right after a command buffer has been
+ // Fence is signaled right after a command buffer has been
// submitted to the command queue for execution.
// All command buffers with fence value less than or equal to the signaled value
// are guaranteed to be finished by the GPU
@@ -96,4 +96,4 @@ private:
std::mutex m_QueueMutex;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h b/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h
index d80f30b9..00b4e62c 100644
--- a/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h
+++ b/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h
@@ -21,7 +21,7 @@
* of the possibility of such damages.
*/
-// Descriptor heap management utilities.
+// Descriptor heap management utilities.
// See http://diligentgraphics.com/diligent-engine/architecture/d3d12/managing-descriptor-heaps/ for details
#pragma once
@@ -38,13 +38,14 @@ namespace Diligent
class DescriptorSetAllocator;
class RenderDeviceVkImpl;
-// This class manages descriptor set allocation.
+// This class manages descriptor set allocation.
// The class destructor calls DescriptorSetAllocator::FreeDescriptorSet() that moves
// the set into the release queue.
// sizeof(DescriptorSetAllocation) == 32 (x64)
class DescriptorSetAllocation
{
public:
+ // clang-format off
DescriptorSetAllocation(VkDescriptorSet _Set,
VkDescriptorPool _Pool,
Uint64 _CmdQueueMask,
@@ -67,8 +68,9 @@ public:
{
rhs.Reset();
}
+ // clang-format on
- DescriptorSetAllocation& operator = (DescriptorSetAllocation&& rhs)noexcept
+ DescriptorSetAllocation& operator=(DescriptorSetAllocation&& rhs) noexcept
{
Release();
@@ -82,7 +84,7 @@ public:
return *this;
}
- operator bool()const
+ operator bool() const
{
return Set != VK_NULL_HANDLE;
}
@@ -102,7 +104,7 @@ public:
Release();
}
- VkDescriptorSet GetVkDescriptorSet()const {return Set;}
+ VkDescriptorSet GetVkDescriptorSet() const { return Set; }
private:
VkDescriptorSet Set = VK_NULL_HANDLE;
@@ -113,19 +115,20 @@ private:
// The class manages pool of descriptor set pools
-// ______________________________
+// ______________________________
// | |
// | DescriptorPoolManager |
// | |
// | | Pool[0] | Pool[1] | ... |
// |______________________________|
-// | A
+// | A
// GetPool() | | FreePool()
// V |
//
class DescriptorPoolManager
{
public:
+ // clang-format off
DescriptorPoolManager(RenderDeviceVkImpl& DeviceVkImpl,
std::string PoolName,
std::vector<VkDescriptorPoolSize> PoolSizes,
@@ -147,18 +150,23 @@ public:
DescriptorPoolManager& operator = (const DescriptorPoolManager&) = delete;
DescriptorPoolManager (DescriptorPoolManager&&) = delete;
DescriptorPoolManager& operator = (DescriptorPoolManager&&) = delete;
-
+ // clang-format on
+
VulkanUtilities::DescriptorPoolWrapper GetPool(const char* DebugName);
+
void DisposePool(VulkanUtilities::DescriptorPoolWrapper&& Pool, Uint64 QueueMask);
- RenderDeviceVkImpl& GetDeviceVkImpl() {return m_DeviceVkImpl;}
+ RenderDeviceVkImpl& GetDeviceVkImpl() { return m_DeviceVkImpl; }
#ifdef DEVELOPMENT
- int32_t GetAllocatedPoolCounter()const{return m_AllocatedPoolCounter;}
+ int32_t GetAllocatedPoolCounter() const
+ {
+ return m_AllocatedPoolCounter;
+ }
#endif
protected:
- VulkanUtilities::DescriptorPoolWrapper CreateDescriptorPool(const char* DebugName)const;
+ VulkanUtilities::DescriptorPoolWrapper CreateDescriptorPool(const char* DebugName) const;
RenderDeviceVkImpl& m_DeviceVkImpl;
const std::string m_PoolName;
@@ -166,15 +174,15 @@ protected:
const std::vector<VkDescriptorPoolSize> m_PoolSizes;
const uint32_t m_MaxSets;
const bool m_AllowFreeing;
-
- std::mutex m_Mutex;
- std::deque< VulkanUtilities::DescriptorPoolWrapper > m_Pools;
+
+ std::mutex m_Mutex;
+ std::deque<VulkanUtilities::DescriptorPoolWrapper> m_Pools;
private:
void FreePool(VulkanUtilities::DescriptorPoolWrapper&& Pool);
#ifdef DEVELOPMENT
- std::atomic_int32_t m_AllocatedPoolCounter;
+ std::atomic_int32_t m_AllocatedPoolCounter;
#endif
};
@@ -189,7 +197,8 @@ public:
std::string PoolName,
std::vector<VkDescriptorPoolSize> PoolSizes,
uint32_t MaxSets,
- bool AllowFreeing) noexcept:
+ bool AllowFreeing) noexcept :
+ // clang-format off
DescriptorPoolManager
{
DeviceVkImpl,
@@ -198,6 +207,7 @@ public:
MaxSets,
AllowFreeing
}
+ // clang-format on
{
#ifdef DEVELOPMENT
m_AllocatedSetCounter = 0;
@@ -209,10 +219,13 @@ public:
DescriptorSetAllocation Allocate(Uint64 CommandQueueMask, VkDescriptorSetLayout SetLayout, const char* DebugName = "");
#ifdef DEVELOPMENT
- int32_t GetAllocatedDescriptorSetCounter()const{return m_AllocatedSetCounter;}
+ int32_t GetAllocatedDescriptorSetCounter() const
+ {
+ return m_AllocatedSetCounter;
+ }
#endif
-private:
+private:
void FreeDescriptorSet(VkDescriptorSet Set, VkDescriptorPool Pool, Uint64 QueueMask);
#ifdef DEVELOPMENT
@@ -235,7 +248,7 @@ private:
// | A |
// | | |
// |Allocate() GetPool()| |FreePool()
-// | _____|___________________V____
+// | _____|___________________V____
// V | |
// VkDescriptorSet | DescriptorPoolManager |
// | |
@@ -245,9 +258,11 @@ private:
class DynamicDescriptorSetAllocator
{
public:
- DynamicDescriptorSetAllocator(DescriptorPoolManager& PoolMgr, std::string Name) :
+ DynamicDescriptorSetAllocator(DescriptorPoolManager& PoolMgr, std::string Name) :
+ // clang-format off
m_GlobalPoolMgr{PoolMgr },
m_Name {std::move(Name)}
+ // clang-format on
{}
~DynamicDescriptorSetAllocator();
@@ -258,7 +273,7 @@ public:
// be destroyed before the pools are actually returned to the global pool manager.
void ReleasePools(Uint64 QueueMask);
- size_t GetAllocatedPoolCount()const{return m_AllocatedPools.size();}
+ size_t GetAllocatedPoolCount() const { return m_AllocatedPools.size(); }
private:
DescriptorPoolManager& m_GlobalPoolMgr;
@@ -267,4 +282,4 @@ private:
size_t m_PeakPoolCount = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
index 3dbe25f2..aa4085f1 100644
--- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
@@ -70,80 +70,82 @@ public:
Uint32 CommandQueueId,
std::shared_ptr<GenerateMipsVkHelper> GenerateMipsHelper);
~DeviceContextVkImpl();
-
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final;
+
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
/// Implementation of IDeviceContext::SetPipelineState() in Vulkan backend.
- virtual void SetPipelineState(IPipelineState* pPipelineState)override final;
+ virtual void SetPipelineState(IPipelineState* pPipelineState) override final;
/// Implementation of IDeviceContext::TransitionShaderResources() in Vulkan backend.
- virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding)override final;
+ virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) override final;
/// Implementation of IDeviceContext::CommitShaderResources() in Vulkan backend.
- virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
+ virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final;
/// Implementation of IDeviceContext::SetStencilRef() in Vulkan backend.
- virtual void SetStencilRef(Uint32 StencilRef)override final;
+ virtual void SetStencilRef(Uint32 StencilRef) override final;
/// Implementation of IDeviceContext::SetBlendFactors() in Vulkan backend.
- virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final;
+ virtual void SetBlendFactors(const float* pBlendFactors = nullptr) override final;
/// Implementation of IDeviceContext::SetVertexBuffers() in Vulkan backend.
- virtual void SetVertexBuffers( Uint32 StartSlot,
- Uint32 NumBuffersSet,
- IBuffer** ppBuffers,
- Uint32* pOffsets,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
- SET_VERTEX_BUFFERS_FLAGS Flags )override final;
-
+ virtual void SetVertexBuffers(Uint32 StartSlot,
+ Uint32 NumBuffersSet,
+ IBuffer** ppBuffers,
+ Uint32* pOffsets,
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
+ SET_VERTEX_BUFFERS_FLAGS Flags) override final;
+
/// Implementation of IDeviceContext::InvalidateState() in Vulkan backend.
- virtual void InvalidateState()override final;
+ virtual void InvalidateState() override final;
/// Implementation of IDeviceContext::SetIndexBuffer() in Vulkan backend.
- virtual void SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )override final;
+ virtual void SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final;
/// Implementation of IDeviceContext::SetViewports() in Vulkan backend.
- virtual void SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight )override final;
+ virtual void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight) override final;
/// Implementation of IDeviceContext::SetScissorRects() in Vulkan backend.
- virtual void SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight )override final;
+ virtual void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight) override final;
/// Implementation of IDeviceContext::SetRenderTargets() in Vulkan backend.
- virtual void SetRenderTargets( Uint32 NumRenderTargets,
- ITextureView* ppRenderTargets[],
- ITextureView* pDepthStencil,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )override final;
+ virtual void SetRenderTargets(Uint32 NumRenderTargets,
+ ITextureView* ppRenderTargets[],
+ ITextureView* pDepthStencil,
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final;
+ // clang-format off
/// Implementation of IDeviceContext::Draw() in Vulkan backend.
- virtual void Draw (const DrawAttribs& Attribs)override final;
+ virtual void Draw (const DrawAttribs& Attribs) override final;
/// Implementation of IDeviceContext::DrawIndexed() in Vulkan backend.
- virtual void DrawIndexed (const DrawIndexedAttribs& Attribs)override final;
+ virtual void DrawIndexed (const DrawIndexedAttribs& Attribs) override final;
/// Implementation of IDeviceContext::DrawIndirect() in Vulkan backend.
- virtual void DrawIndirect (const DrawIndirectAttribs& Attribs, IBuffer* pAttribsBuffer)override final;
+ virtual void DrawIndirect (const DrawIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) override final;
/// Implementation of IDeviceContext::DrawIndexedIndirect() in Vulkan backend.
- virtual void DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs, IBuffer* pAttribsBuffer)override final;
+ virtual void DrawIndexedIndirect(const DrawIndexedIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) override final;
/// Implementation of IDeviceContext::DispatchCompute() in Vulkan backend.
- virtual void DispatchCompute(const DispatchComputeAttribs& Attribs)override final;
+ virtual void DispatchCompute (const DispatchComputeAttribs& Attribs) override final;
/// Implementation of IDeviceContext::DispatchComputeIndirect() in Vulkan backend.
- virtual void DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs, IBuffer* pAttribsBuffer)override final;
+ virtual void DispatchComputeIndirect(const DispatchComputeIndirectAttribs& Attribs, IBuffer* pAttribsBuffer) override final;
+ // clang-format on
/// Implementation of IDeviceContext::ClearDepthStencil() in Vulkan backend.
virtual void ClearDepthStencil(ITextureView* pView,
CLEAR_DEPTH_STENCIL_FLAGS ClearFlags,
float fDepth,
Uint8 Stencil,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final;
/// Implementation of IDeviceContext::ClearRenderTarget() in Vulkan backend.
- virtual void ClearRenderTarget( ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )override final;
+ virtual void ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final;
/// Implementation of IDeviceContext::UpdateBuffer() in Vulkan backend.
virtual void UpdateBuffer(IBuffer* pBuffer,
Uint32 Offset,
Uint32 Size,
const PVoid pData,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final;
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final;
/// Implementation of IDeviceContext::CopyBuffer() in Vulkan backend.
virtual void CopyBuffer(IBuffer* pSrcBuffer,
@@ -152,13 +154,13 @@ public:
IBuffer* pDstBuffer,
Uint32 DstOffset,
Uint32 Size,
- RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode)override final;
+ RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) override final;
/// Implementation of IDeviceContext::MapBuffer() in Vulkan backend.
- virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData)override final;
+ virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData) override final;
/// Implementation of IDeviceContext::UnmapBuffer() in Vulkan backend.
- virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType)override final;
+ virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) override final;
/// Implementation of IDeviceContext::UpdateTexture() in Vulkan backend.
virtual void UpdateTexture(ITexture* pTexture,
@@ -167,40 +169,40 @@ public:
const Box& DstBox,
const TextureSubResData& SubresData,
RESOURCE_STATE_TRANSITION_MODE SrcBufferStateTransitionMode,
- RESOURCE_STATE_TRANSITION_MODE TextureStateTransitionModee)override final;
+ RESOURCE_STATE_TRANSITION_MODE TextureStateTransitionModee) override final;
/// Implementation of IDeviceContext::CopyTexture() in Vulkan backend.
- virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs)override final;
+ virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs) override final;
/// Implementation of IDeviceContext::MapTextureSubresource() in Vulkan backend.
- virtual void MapTextureSubresource( ITexture* pTexture,
- Uint32 MipLevel,
- Uint32 ArraySlice,
- MAP_TYPE MapType,
- MAP_FLAGS MapFlags,
- const Box* pMapRegion,
- MappedTextureSubresource& MappedData )override final;
+ virtual void MapTextureSubresource(ITexture* pTexture,
+ Uint32 MipLevel,
+ Uint32 ArraySlice,
+ MAP_TYPE MapType,
+ MAP_FLAGS MapFlags,
+ const Box* pMapRegion,
+ MappedTextureSubresource& MappedData) override final;
/// Implementation of IDeviceContext::UnmapTextureSubresource() in Vulkan backend.
- virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)override final;
+ virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) override final;
/// Implementation of IDeviceContext::FinishCommandList() in Vulkan backend.
- virtual void FinishCommandList(class ICommandList** ppCommandList)override final;
+ virtual void FinishCommandList(class ICommandList** ppCommandList) override final;
/// Implementation of IDeviceContext::ExecuteCommandList() in Vulkan backend.
- virtual void ExecuteCommandList(class ICommandList* pCommandList)override final;
+ virtual void ExecuteCommandList(class ICommandList* pCommandList) override final;
/// Implementation of IDeviceContext::SignalFence() in Vulkan backend.
- virtual void SignalFence(IFence* pFence, Uint64 Value)override final;
+ virtual void SignalFence(IFence* pFence, Uint64 Value) override final;
/// Implementation of IDeviceContext::WaitForFence() in Vulkan backend.
- virtual void WaitForFence(IFence* pFence, Uint64 Value, bool FlushContext)override final;
+ virtual void WaitForFence(IFence* pFence, Uint64 Value, bool FlushContext) override final;
/// Implementation of IDeviceContext::WaitForIdle() in Vulkan backend.
- virtual void WaitForIdle()override final;
+ virtual void WaitForIdle() override final;
/// Implementation of IDeviceContext::Flush() in Vulkan backend.
- virtual void Flush()override final;
+ virtual void Flush() override final;
// Transitions texture subresources from OldState to NewState, and optionally updates
// internal texture state.
@@ -210,26 +212,26 @@ public:
RESOURCE_STATE NewState,
bool UpdateTextureState,
VkImageSubresourceRange* pSubresRange = nullptr);
-
+
void TransitionImageLayout(TextureVkImpl& TextureVk,
VkImageLayout OldLayout,
VkImageLayout NewLayout,
const VkImageSubresourceRange& SubresRange);
/// Implementation of IDeviceContextVk::TransitionImageLayout().
- virtual void TransitionImageLayout(ITexture* pTexture, VkImageLayout NewLayout)override final;
+ virtual void TransitionImageLayout(ITexture* pTexture, VkImageLayout NewLayout) override final;
// Transitions buffer state from OldState to NewState, and optionally updates
// internal buffer state.
// If OldState == RESOURCE_STATE_UNKNOWN, internal buffer state is used as old state.
- void TransitionBufferState(BufferVkImpl& BufferVk,
+ void TransitionBufferState(BufferVkImpl& BufferVk,
RESOURCE_STATE OldState,
RESOURCE_STATE NewState,
bool UpdateBufferState);
/// Implementation of IDeviceContextVk::BufferMemoryBarrier().
- virtual void BufferMemoryBarrier(IBuffer* pBuffer, VkAccessFlags NewAccessFlags)override final;
+ virtual void BufferMemoryBarrier(IBuffer* pBuffer, VkAccessFlags NewAccessFlags) override final;
void AddWaitSemaphore(VkSemaphore Semaphore, VkPipelineStageFlags WaitDstStageMask)
@@ -264,11 +266,11 @@ public:
const Box& DstBox,
RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode);
- virtual void GenerateMips(ITextureView* pTexView)override final;
+ virtual void GenerateMips(ITextureView* pTexView) override final;
- Uint32 GetContextId()const{return m_ContextId;}
+ Uint32 GetContextId() const { return m_ContextId; }
- size_t GetNumCommandsInCtx()const { return m_State.NumCommands; }
+ size_t GetNumCommandsInCtx() const { return m_State.NumCommands; }
__forceinline VulkanUtilities::VulkanCommandBuffer& GetCommandBuffer()
{
@@ -276,35 +278,35 @@ public:
return m_CommandBuffer;
}
- virtual void FinishFrame()override final;
+ virtual void FinishFrame() override final;
- virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)override final;
+ virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) override final;
virtual void ResolveTextureSubresource(ITexture* pSrcTexture,
ITexture* pDstTexture,
- const ResolveTextureSubresourceAttribs& ResolveAttribs)override final;
+ const ResolveTextureSubresourceAttribs& ResolveAttribs) override final;
VkDescriptorSet AllocateDynamicDescriptorSet(VkDescriptorSetLayout SetLayout, const char* DebugName = "")
{
- // Descriptor pools are externally synchronized, meaning that the application must not allocate
+ // Descriptor pools are externally synchronized, meaning that the application must not allocate
// and/or free descriptor sets from the same pool in multiple threads simultaneously (13.2.3)
return m_DynamicDescrSetAllocator.Allocate(SetLayout, DebugName);
}
VulkanDynamicAllocation AllocateDynamicSpace(Uint32 SizeInBytes, Uint32 Alignment);
- void ResetRenderTargets();
- Int64 GetContextFrameNumber()const{return m_ContextFrameNumber;}
+ void ResetRenderTargets();
+ Int64 GetContextFrameNumber() const { return m_ContextFrameNumber; }
- GenerateMipsVkHelper& GetGenerateMipsHelper(){return *m_GenerateMipsHelper;}
+ GenerateMipsVkHelper& GetGenerateMipsHelper() { return *m_GenerateMipsHelper; }
private:
- void TransitionRenderTargets(RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
+ void TransitionRenderTargets(RESOURCE_STATE_TRANSITION_MODE StateTransitionMode);
__forceinline void CommitRenderPassAndFramebuffer(bool VerifyStates);
- void CommitVkVertexBuffers();
- void CommitViewports();
- void CommitScissorRects();
-
+ void CommitVkVertexBuffers();
+ void CommitViewports();
+ void CommitScissorRects();
+
__forceinline void TransitionOrVerifyBufferState(BufferVkImpl& Buffer,
RESOURCE_STATE_TRANSITION_MODE TransitionMode,
RESOURCE_STATE RequiredState,
@@ -329,23 +331,23 @@ private:
m_CommandBuffer.SetVkCmdBuffer(vkCmdBuff);
}
}
-
+
inline void DisposeVkCmdBuffer(Uint32 CmdQueue, VkCommandBuffer vkCmdBuff, Uint64 FenceValue);
inline void DisposeCurrentCmdBuffer(Uint32 CmdQueue, Uint64 FenceValue);
struct BufferToTextureCopyInfo
{
- Uint32 RowSize = 0;
- Uint32 Stride = 0;
- Uint32 StrideInTexels = 0;
- Uint32 DepthStride = 0;
- Uint32 MemorySize = 0;
- Uint32 RowCount = 0;
- Box Region;
+ Uint32 RowSize = 0;
+ Uint32 Stride = 0;
+ Uint32 StrideInTexels = 0;
+ Uint32 DepthStride = 0;
+ Uint32 MemorySize = 0;
+ Uint32 RowCount = 0;
+ Box Region;
};
BufferToTextureCopyInfo GetBufferToTextureCopyInfo(const TextureDesc& TexDesc,
Uint32 MipLevel,
- const Box& Region)const;
+ const Box& Region) const;
void CopyBufferToTexture(VkBuffer vkSrcBuffer,
Uint32 SrcBufferOffset,
@@ -365,10 +367,10 @@ private:
Uint32 DstBufferOffset,
Uint32 DstBufferRowStrideInTexels);
- __forceinline void PrepareForDraw(DRAW_FLAGS Flags);
- __forceinline void PrepareForIndexedDraw(DRAW_FLAGS Flags, VALUE_TYPE IndexType);
+ __forceinline void PrepareForDraw(DRAW_FLAGS Flags);
+ __forceinline void PrepareForIndexedDraw(DRAW_FLAGS Flags, VALUE_TYPE IndexType);
__forceinline BufferVkImpl* PrepareIndirectDrawAttribsBuffer(IBuffer* pAttribsBuffer, RESOURCE_STATE_TRANSITION_MODE TransitonMode);
- __forceinline void PrepareForDispatchCompute();
+ __forceinline void PrepareForDispatchCompute();
void DvpLogRenderPass_PSOMismatch();
@@ -384,7 +386,7 @@ private:
bool CommittedIBUpToDate = false;
Uint32 NumCommands = 0;
- }m_State;
+ } m_State;
/// Render pass that matches currently bound render targets.
@@ -398,30 +400,30 @@ private:
FixedBlockMemoryAllocator m_CmdListAllocator;
// Semaphores are not owned by the command context
- std::vector<VkSemaphore> m_WaitSemaphores;
- std::vector<VkPipelineStageFlags> m_WaitDstStageMasks;
- std::vector<VkSemaphore> m_SignalSemaphores;
+ std::vector<VkSemaphore> m_WaitSemaphores;
+ std::vector<VkPipelineStageFlags> m_WaitDstStageMasks;
+ std::vector<VkSemaphore> m_SignalSemaphores;
// List of fences to signal next time the command context is flushed
- std::vector<std::pair<Uint64, RefCntAutoPtr<IFence> > > m_PendingFences;
+ std::vector<std::pair<Uint64, RefCntAutoPtr<IFence>>> m_PendingFences;
std::unordered_map<BufferVkImpl*, VulkanUploadAllocation> m_UploadAllocations;
struct MappedTextureKey
{
TextureVkImpl* const Texture;
- Uint32 const MipLevel;
- Uint32 const ArraySlice;
+ Uint32 const MipLevel;
+ Uint32 const ArraySlice;
- bool operator == (const MappedTextureKey& rhs)const
+ bool operator==(const MappedTextureKey& rhs) const
{
- return Texture == rhs.Texture &&
- MipLevel == rhs.MipLevel &&
- ArraySlice == rhs.ArraySlice;
+ return Texture == rhs.Texture &&
+ MipLevel == rhs.MipLevel &&
+ ArraySlice == rhs.ArraySlice;
}
struct Hasher
{
- size_t operator()(const MappedTextureKey& Key)const
+ size_t operator()(const MappedTextureKey& Key) const
{
return ComputeHash(Key.Texture, Key.MipLevel, Key.ArraySlice);
}
@@ -447,4 +449,4 @@ private:
RefCntAutoPtr<BufferVkImpl> m_DummyVB;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h
index db6748f3..15067106 100644
--- a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h
@@ -55,12 +55,13 @@ public:
/// are signaled 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;
+ virtual Uint64 GetCompletedValue() override final;
/// Implementation of IFence::Reset() in Vulkan backend.
- virtual void Reset(Uint64 Value)override final;
-
+ virtual void Reset(Uint64 Value) override final;
+
VulkanUtilities::FenceWrapper GetVkFence() { return m_FencePool.GetFence(); }
+
void AddPendingFence(VulkanUtilities::FenceWrapper&& vkFence, Uint64 FenceValue)
{
m_PendingFences.emplace_back(FenceValue, std::move(vkFence));
@@ -69,9 +70,9 @@ public:
void Wait(Uint64 Value);
private:
- VulkanUtilities::VulkanFencePool m_FencePool;
+ VulkanUtilities::VulkanFencePool m_FencePool;
std::deque<std::pair<Uint64, VulkanUtilities::FenceWrapper>> m_PendingFences;
- volatile Uint64 m_LastCompletedFenceValue = 0;
+ volatile Uint64 m_LastCompletedFenceValue = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/FramebufferCache.h b/Graphics/GraphicsEngineVulkan/include/FramebufferCache.h
index ad2e48d8..acdf3037 100644
--- a/Graphics/GraphicsEngineVulkan/include/FramebufferCache.h
+++ b/Graphics/GraphicsEngineVulkan/include/FramebufferCache.h
@@ -38,13 +38,15 @@ class FramebufferCache
{
public:
FramebufferCache(RenderDeviceVkImpl& DeviceVKImpl) :
- m_DeviceVk(DeviceVKImpl)
+ m_DeviceVk{DeviceVKImpl}
{}
+ // clang-format off
FramebufferCache (const FramebufferCache&) = delete;
FramebufferCache (FramebufferCache&&) = delete;
FramebufferCache& operator = (const FramebufferCache&) = delete;
FramebufferCache& operator = (FramebufferCache&&) = delete;
+ // clang-format on
~FramebufferCache();
@@ -58,33 +60,33 @@ public:
VkImageView RTVs[MaxRenderTargets];
Uint64 CommandQueueMask;
- bool operator == (const FramebufferCacheKey &rhs)const;
- size_t GetHash()const;
+ bool operator==(const FramebufferCacheKey& rhs) const;
+ size_t GetHash() const;
private:
mutable size_t Hash = 0;
};
VkFramebuffer GetFramebuffer(const FramebufferCacheKey& Key, uint32_t width, uint32_t height, uint32_t layers);
- void OnDestroyImageView(VkImageView ImgView);
- void OnDestroyRenderPass(VkRenderPass Pass);
+ void OnDestroyImageView(VkImageView ImgView);
+ void OnDestroyRenderPass(VkRenderPass Pass);
private:
-
RenderDeviceVkImpl& m_DeviceVk;
struct FramebufferCacheKeyHash
{
- std::size_t operator() (const FramebufferCacheKey& Key)const
+ std::size_t operator()(const FramebufferCacheKey& Key) const
{
return Key.GetHash();
}
};
-
- std::mutex m_Mutex;
+
+ std::mutex m_Mutex;
std::unordered_map<FramebufferCacheKey, VulkanUtilities::FramebufferWrapper, FramebufferCacheKeyHash> m_Cache;
- std::unordered_multimap<VkImageView, FramebufferCacheKey> m_ViewToKeyMap;
+
+ std::unordered_multimap<VkImageView, FramebufferCacheKey> m_ViewToKeyMap;
std::unordered_multimap<VkRenderPass, FramebufferCacheKey> m_RenderPassToKeyMap;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.h b/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.h
index 43bd32de..7bead823 100644
--- a/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.h
+++ b/Graphics/GraphicsEngineVulkan/include/GenerateMipsVkHelper.h
@@ -23,7 +23,7 @@
#pragma once
- /// \file
+/// \file
/// Implementation of mipmap generation routines
#include <array>
@@ -33,36 +33,42 @@
namespace Diligent
{
- class RenderDeviceVkImpl;
- class TextureViewVkImpl;
- class DeviceContextVkImpl;
- class GenerateMipsVkHelper
- {
- public:
- GenerateMipsVkHelper(RenderDeviceVkImpl& DeviceVkImpl);
-
- GenerateMipsVkHelper (const GenerateMipsVkHelper&) = delete;
- GenerateMipsVkHelper ( GenerateMipsVkHelper&&) = delete;
- GenerateMipsVkHelper& operator = (const GenerateMipsVkHelper&) = delete;
- GenerateMipsVkHelper& operator = ( GenerateMipsVkHelper&&) = delete;
+class RenderDeviceVkImpl;
+class TextureViewVkImpl;
+class DeviceContextVkImpl;
- void GenerateMips(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB);
- void CreateSRB(IShaderResourceBinding** ppSRB);
- void WarmUpCache(TEXTURE_FORMAT Fmt);
+class GenerateMipsVkHelper
+{
+public:
+ GenerateMipsVkHelper(RenderDeviceVkImpl& DeviceVkImpl);
+
+ // clang-format off
+ GenerateMipsVkHelper (const GenerateMipsVkHelper&) = delete;
+ GenerateMipsVkHelper ( GenerateMipsVkHelper&&) = delete;
+ GenerateMipsVkHelper& operator = (const GenerateMipsVkHelper&) = delete;
+ GenerateMipsVkHelper& operator = ( GenerateMipsVkHelper&&) = delete;
+ // clang-format on
+
+ void GenerateMips(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB);
+ void CreateSRB(IShaderResourceBinding** ppSRB);
+ void WarmUpCache(TEXTURE_FORMAT Fmt);
+
+private:
+ std::array<RefCntAutoPtr<IPipelineState>, 4> CreatePSOs(TEXTURE_FORMAT Fmt);
+ std::array<RefCntAutoPtr<IPipelineState>, 4>& FindPSOs(TEXTURE_FORMAT Fmt);
+
+ VkImageLayout GenerateMipsCS(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange);
+ VkImageLayout GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange) const;
+
+ RenderDeviceVkImpl& m_DeviceVkImpl;
- private:
- std::array<RefCntAutoPtr<IPipelineState>, 4> CreatePSOs(TEXTURE_FORMAT Fmt);
- std::array<RefCntAutoPtr<IPipelineState>, 4>& FindPSOs (TEXTURE_FORMAT Fmt);
+ std::mutex m_PSOMutex;
+ std::unordered_map<TEXTURE_FORMAT, std::array<RefCntAutoPtr<IPipelineState>, 4>> m_PSOHash;
- VkImageLayout GenerateMipsCS (TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange);
- VkImageLayout GenerateMipsBlit(TextureViewVkImpl& TexView, DeviceContextVkImpl& Ctx, IShaderResourceBinding& SRB, VkImageSubresourceRange& SubresRange)const;
+ static void GetGlImageFormat(const TextureFormatAttribs& FmtAttribs, std::array<char, 16>& GlFmt);
- RenderDeviceVkImpl& m_DeviceVkImpl;
+ RefCntAutoPtr<IBuffer> m_ConstantsCB;
+};
- std::mutex m_PSOMutex;
- std::unordered_map< TEXTURE_FORMAT, std::array<RefCntAutoPtr<IPipelineState>, 4> > m_PSOHash;
- static void GetGlImageFormat(const TextureFormatAttribs& FmtAttribs, std::array<char, 16>& GlFmt);
- RefCntAutoPtr<IBuffer> m_ConstantsCB;
- };
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineLayout.h b/Graphics/GraphicsEngineVulkan/include/PipelineLayout.h
index bbaa1960..93210f5b 100644
--- a/Graphics/GraphicsEngineVulkan/include/PipelineLayout.h
+++ b/Graphics/GraphicsEngineVulkan/include/PipelineLayout.h
@@ -50,38 +50,40 @@ public:
void Release(RenderDeviceVkImpl* pDeviceVkImpl, Uint64 CommandQueueMask);
void Finalize(const VulkanUtilities::VulkanLogicalDevice& LogicalDevice);
- VkPipelineLayout GetVkPipelineLayout()const{return m_LayoutMgr.GetVkPipelineLayout();}
- std::array<Uint32, 2> GetDescriptorSetSizes(Uint32& NumSets)const;
+ VkPipelineLayout GetVkPipelineLayout() const { return m_LayoutMgr.GetVkPipelineLayout(); }
+
+ std::array<Uint32, 2> GetDescriptorSetSizes(Uint32& NumSets) const;
+
void InitResourceCache(RenderDeviceVkImpl* pDeviceVkImpl,
ShaderResourceCacheVk& ResourceCache,
IMemoryAllocator& CacheMemAllocator,
- const char* DbgPipelineName)const;
+ const char* DbgPipelineName) const;
- void AllocateResourceSlot(const SPIRVShaderResourceAttribs& ResAttribs,
+ void AllocateResourceSlot(const SPIRVShaderResourceAttribs& ResAttribs,
SHADER_RESOURCE_VARIABLE_TYPE VariableType,
VkSampler vkImmutableSampler,
- SHADER_TYPE ShaderType,
- Uint32& DescriptorSet,
+ SHADER_TYPE ShaderType,
+ Uint32& DescriptorSet,
Uint32& Binding,
Uint32& OffsetInCache,
std::vector<uint32_t>& SPIRV);
- Uint32 GetTotalDescriptors(SHADER_RESOURCE_VARIABLE_TYPE VarType)const
+ Uint32 GetTotalDescriptors(SHADER_RESOURCE_VARIABLE_TYPE VarType) const
{
VERIFY_EXPR(VarType >= 0 && VarType < SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES);
return m_LayoutMgr.GetDescriptorSet(VarType).TotalDescriptors;
}
- bool IsSameAs(const PipelineLayout& RS)const
+ bool IsSameAs(const PipelineLayout& RS) const
{
return m_LayoutMgr == RS.m_LayoutMgr;
}
- size_t GetHash()const
+ size_t GetHash() const
{
return m_LayoutMgr.GetHash();
}
- VkDescriptorSetLayout GetDynamicDescriptorSetVkLayout()const
+ VkDescriptorSetLayout GetDynamicDescriptorSetVkLayout() const
{
return m_LayoutMgr.GetDescriptorSet(SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC).VkLayout;
}
@@ -97,11 +99,13 @@ public:
bool DynamicBuffersPresent = false;
bool DynamicDescriptorsBound = false;
#ifdef _DEBUG
- const PipelineLayout* pDbgPipelineLayout = nullptr;
+ const PipelineLayout* pDbgPipelineLayout = nullptr;
#endif
- DescriptorSetBindInfo() :
+ DescriptorSetBindInfo() :
+ // clang-format off
vkSets {2},
DynamicOffsets{64}
+ // clang-format on
{
}
@@ -124,89 +128,92 @@ public:
}
};
- // Prepares Vulkan descriptor sets for binding. Actual binding
- // may not be possible until draw command time because dynamic offsets are
+ // Prepares Vulkan descriptor sets for binding. Actual binding
+ // may not be possible until draw command time because dynamic offsets are
// set by the same Vulkan command. If there are no dynamic descriptors, this
// function also binds descriptor sets rightaway.
- void PrepareDescriptorSets(DeviceContextVkImpl* pCtxVkImpl,
- bool IsCompute,
- const ShaderResourceCacheVk& ResourceCache,
- DescriptorSetBindInfo& BindInfo,
- VkDescriptorSet VkDynamicDescrSet)const;
+ void PrepareDescriptorSets(DeviceContextVkImpl* pCtxVkImpl,
+ bool IsCompute,
+ const ShaderResourceCacheVk& ResourceCache,
+ DescriptorSetBindInfo& BindInfo,
+ VkDescriptorSet VkDynamicDescrSet) const;
// Computes dynamic offsets and binds descriptor sets
__forceinline void BindDescriptorSetsWithDynamicOffsets(VulkanUtilities::VulkanCommandBuffer& CmdBuffer,
Uint32 CtxId,
DeviceContextVkImpl* pCtxVkImpl,
- DescriptorSetBindInfo& BindInfo)const;
+ DescriptorSetBindInfo& BindInfo) const;
private:
-
class DescriptorSetLayoutManager
{
public:
struct DescriptorSetLayout
{
DescriptorSetLayout() noexcept {}
+ // clang-format off
DescriptorSetLayout (DescriptorSetLayout&&) = default;
DescriptorSetLayout (const DescriptorSetLayout&) = delete;
DescriptorSetLayout& operator = (const DescriptorSetLayout&) = delete;
DescriptorSetLayout& operator = (DescriptorSetLayout&&) = delete;
-
+ // clang-format on
+
uint32_t TotalDescriptors = 0;
int8_t SetIndex = -1;
uint8_t NumDynamicDescriptors = 0; // Total number of uniform and storage buffers, counting all array elements
uint16_t NumLayoutBindings = 0;
VkDescriptorSetLayoutBinding* pBindings = nullptr;
VulkanUtilities::DescriptorSetLayoutWrapper VkLayout;
-
+
~DescriptorSetLayout();
void AddBinding(const VkDescriptorSetLayoutBinding& Binding, IMemoryAllocator& MemAllocator);
void Finalize(const VulkanUtilities::VulkanLogicalDevice& LogicalDevice, IMemoryAllocator& MemAllocator, VkDescriptorSetLayoutBinding* pNewBindings);
void Release(RenderDeviceVkImpl* pRenderDeviceVk, IMemoryAllocator& MemAllocator, Uint64 CommandQueueMask);
- bool operator == (const DescriptorSetLayout& rhs)const;
- bool operator != (const DescriptorSetLayout& rhs)const{return !(*this == rhs);}
- size_t GetHash()const;
+ bool operator==(const DescriptorSetLayout& rhs) const;
+ bool operator!=(const DescriptorSetLayout& rhs) const { return !(*this == rhs); }
+ size_t GetHash() const;
private:
- void ReserveMemory(Uint32 NumBindings, IMemoryAllocator &MemAllocator);
+ void ReserveMemory(Uint32 NumBindings, IMemoryAllocator& MemAllocator);
static size_t GetMemorySize(Uint32 NumBindings);
};
- DescriptorSetLayoutManager(IMemoryAllocator &MemAllocator);
+ DescriptorSetLayoutManager(IMemoryAllocator& MemAllocator);
~DescriptorSetLayoutManager();
+ // clang-format off
DescriptorSetLayoutManager (const DescriptorSetLayoutManager&) = delete;
DescriptorSetLayoutManager& operator= (const DescriptorSetLayoutManager&) = delete;
DescriptorSetLayoutManager (DescriptorSetLayoutManager&&) = delete;
DescriptorSetLayoutManager& operator= (DescriptorSetLayoutManager&&) = delete;
-
- void Finalize(const VulkanUtilities::VulkanLogicalDevice &LogicalDevice);
+ // clang-format on
+
+ void Finalize(const VulkanUtilities::VulkanLogicalDevice& LogicalDevice);
void Release(RenderDeviceVkImpl* pRenderDeviceVk, Uint64 CommandQueueMask);
- DescriptorSetLayout& GetDescriptorSet(SHADER_RESOURCE_VARIABLE_TYPE VarType) { return m_DescriptorSetLayouts[VarType == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC ? 1 : 0]; }
- const DescriptorSetLayout& GetDescriptorSet(SHADER_RESOURCE_VARIABLE_TYPE VarType)const { return m_DescriptorSetLayouts[VarType == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC ? 1 : 0]; }
+ DescriptorSetLayout& GetDescriptorSet(SHADER_RESOURCE_VARIABLE_TYPE VarType) { return m_DescriptorSetLayouts[VarType == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC ? 1 : 0]; }
+ const DescriptorSetLayout& GetDescriptorSet(SHADER_RESOURCE_VARIABLE_TYPE VarType) const { return m_DescriptorSetLayouts[VarType == SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC ? 1 : 0]; }
- bool operator == (const DescriptorSetLayoutManager& rhs)const;
- bool operator != (const DescriptorSetLayoutManager& rhs)const {return !(*this == rhs);}
- size_t GetHash()const;
- VkPipelineLayout GetVkPipelineLayout()const{return m_VkPipelineLayout;}
+ bool operator==(const DescriptorSetLayoutManager& rhs) const;
+ bool operator!=(const DescriptorSetLayoutManager& rhs) const { return !(*this == rhs); }
+ size_t GetHash() const;
+ VkPipelineLayout GetVkPipelineLayout() const { return m_VkPipelineLayout; }
void AllocateResourceSlot(const SPIRVShaderResourceAttribs& ResAttribs,
SHADER_RESOURCE_VARIABLE_TYPE VariableType,
VkSampler vkImmutableSampler,
SHADER_TYPE ShaderType,
Uint32& DescriptorSet,
- Uint32& Binding,
+ Uint32& Binding,
Uint32& OffsetInCache);
private:
- IMemoryAllocator &m_MemAllocator;
- VulkanUtilities::PipelineLayoutWrapper m_VkPipelineLayout;
- std::array<DescriptorSetLayout, 2> m_DescriptorSetLayouts;
+ IMemoryAllocator& m_MemAllocator;
+ VulkanUtilities::PipelineLayoutWrapper m_VkPipelineLayout;
+ std::array<DescriptorSetLayout, 2> m_DescriptorSetLayouts;
std::vector<VkDescriptorSetLayoutBinding, STDAllocatorRawMem<VkDescriptorSetLayoutBinding>> m_LayoutBindings;
- uint8_t m_ActiveSets = 0;
+ uint8_t m_ActiveSets = 0;
};
IMemoryAllocator& m_MemAllocator;
@@ -217,7 +224,7 @@ private:
__forceinline void PipelineLayout::BindDescriptorSetsWithDynamicOffsets(VulkanUtilities::VulkanCommandBuffer& CmdBuffer,
Uint32 CtxId,
DeviceContextVkImpl* pCtxVkImpl,
- DescriptorSetBindInfo& BindInfo)const
+ DescriptorSetBindInfo& BindInfo) const
{
VERIFY(BindInfo.pDbgPipelineLayout != nullptr, "Pipeline layout is not initialized, which most likely means that CommitShaderResources() has never been called");
VERIFY(BindInfo.pDbgPipelineLayout->IsSameAs(*this), "Inconsistent pipeline layout");
@@ -228,7 +235,7 @@ __forceinline void PipelineLayout::BindDescriptorSetsWithDynamicOffsets(VulkanUt
Uint32 TotalDynamicDescriptors = 0;
for (SHADER_RESOURCE_VARIABLE_TYPE VarType = SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE; VarType <= SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC; VarType = static_cast<SHADER_RESOURCE_VARIABLE_TYPE>(VarType + 1))
{
- const auto &Set = m_LayoutMgr.GetDescriptorSet(VarType);
+ const auto& Set = m_LayoutMgr.GetDescriptorSet(VarType);
TotalDynamicDescriptors += Set.NumDynamicDescriptors;
}
VERIFY(BindInfo.DynamicOffsetCount == TotalDynamicDescriptors, "Incosistent dynamic buffer size");
@@ -236,17 +243,18 @@ __forceinline void PipelineLayout::BindDescriptorSetsWithDynamicOffsets(VulkanUt
#endif
auto NumOffsetsWritten = BindInfo.pResourceCache->GetDynamicBufferOffsets(CtxId, pCtxVkImpl, BindInfo.DynamicOffsets);
- VERIFY_EXPR(NumOffsetsWritten == BindInfo.DynamicOffsetCount); (void)NumOffsetsWritten;
+ VERIFY_EXPR(NumOffsetsWritten == BindInfo.DynamicOffsetCount);
+ (void)NumOffsetsWritten;
// Note that there is one global dynamic buffer from which all dynamic resources are suballocated in Vulkan back-end,
// and this buffer is not resizable, so the buffer handle can never change.
- // vkCmdBindDescriptorSets causes the sets numbered [firstSet .. firstSet+descriptorSetCount-1] to use the
- // bindings stored in pDescriptorSets[0 .. descriptorSetCount-1] for subsequent rendering commands
- // (either compute or graphics, according to the pipelineBindPoint). Any bindings that were previously
+ // vkCmdBindDescriptorSets causes the sets numbered [firstSet .. firstSet+descriptorSetCount-1] to use the
+ // bindings stored in pDescriptorSets[0 .. descriptorSetCount-1] for subsequent rendering commands
+ // (either compute or graphics, according to the pipelineBindPoint). Any bindings that were previously
// applied via these sets are no longer valid (13.2.5)
CmdBuffer.BindDescriptorSets(BindInfo.BindPoint,
- m_LayoutMgr.GetVkPipelineLayout(),
+ m_LayoutMgr.GetVkPipelineLayout(),
0, // First set
BindInfo.SetCout,
BindInfo.vkSets.data(), // BindInfo.vkSets is never empty
@@ -257,4 +265,4 @@ __forceinline void PipelineLayout::BindDescriptorSetsWithDynamicOffsets(VulkanUt
BindInfo.DynamicDescriptorsBound = true;
}
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h
index c1c2116b..30936afd 100644
--- a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h
@@ -56,22 +56,22 @@ public:
PipelineStateVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDeviceVk, const PipelineStateDesc& PipelineDesc);
~PipelineStateVkImpl();
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final;
-
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
+
/// Implementation of IPipelineState::CreateShaderResourceBinding() in Vulkan backend.
- virtual void CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources)override final;
+ virtual void CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources) override final;
/// Implementation of IPipelineState::IsCompatibleWith() in Vulkan backend.
- virtual bool IsCompatibleWith(const IPipelineState* pPSO)const override final;
+ virtual bool IsCompatibleWith(const IPipelineState* pPSO) const override final;
/// Implementation of IPipelineStateVk::GetVkRenderPass().
- virtual VkRenderPass GetVkRenderPass()const override final { return m_RenderPass; }
+ virtual VkRenderPass GetVkRenderPass() const override final { return m_RenderPass; }
/// Implementation of IPipelineStateVk::GetVkPipeline().
- virtual VkPipeline GetVkPipeline() const override final { return m_Pipeline; }
+ virtual VkPipeline GetVkPipeline() const override final { return m_Pipeline; }
/// Implementation of IPipelineState::BindStaticResources() in Vulkan backend.
- virtual void BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResourceMapping, Uint32 Flags)override final;
+ virtual void BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResourceMapping, Uint32 Flags) override final;
/// Implementation of IPipelineState::GetStaticVariableCount() in Vulkan backend.
virtual Uint32 GetStaticVariableCount(SHADER_TYPE ShaderType) const override final;
@@ -82,11 +82,11 @@ public:
/// Implementation of IPipelineState::GetStaticVariableByIndex() in Vulkan backend.
virtual IShaderResourceVariable* GetStaticVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) override final;
- void CommitAndTransitionShaderResources(IShaderResourceBinding* pShaderResourceBinding,
- DeviceContextVkImpl* pCtxVkImpl,
- bool CommitResources,
- RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
- PipelineLayout::DescriptorSetBindInfo* pDescrSetBindInfo)const;
+ void CommitAndTransitionShaderResources(IShaderResourceBinding* pShaderResourceBinding,
+ DeviceContextVkImpl* pCtxVkImpl,
+ bool CommitResources,
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
+ PipelineLayout::DescriptorSetBindInfo* pDescrSetBindInfo) const;
__forceinline void BindDescriptorSetsWithDynamicOffsets(VulkanUtilities::VulkanCommandBuffer& CmdBuffer,
Uint32 CtxId,
@@ -96,9 +96,9 @@ public:
m_PipelineLayout.BindDescriptorSetsWithDynamicOffsets(CmdBuffer, CtxId, pCtxVkImpl, BindInfo);
}
- const PipelineLayout& GetPipelineLayout()const{return m_PipelineLayout;}
-
- const ShaderResourceLayoutVk& GetShaderResLayout(Uint32 ShaderInd)const
+ const PipelineLayout& GetPipelineLayout() const { return m_PipelineLayout; }
+
+ const ShaderResourceLayoutVk& GetShaderResLayout(Uint32 ShaderInd) const
{
VERIFY_EXPR(ShaderInd < m_NumShaders);
return m_ShaderResourceLayouts[ShaderInd];
@@ -108,47 +108,47 @@ public:
{
return m_SRBMemAllocator;
}
-
- static VkRenderPassCreateInfo GetRenderPassCreateInfo(Uint32 NumRenderTargets,
- const TEXTURE_FORMAT RTVFormats[],
- TEXTURE_FORMAT DSVFormat,
- Uint32 SampleCount,
- std::array<VkAttachmentDescription, MaxRenderTargets+1>& Attachments,
- std::array<VkAttachmentReference, MaxRenderTargets+1>& AttachmentReferences,
- VkSubpassDescription& SubpassDesc);
+ static VkRenderPassCreateInfo GetRenderPassCreateInfo(Uint32 NumRenderTargets,
+ const TEXTURE_FORMAT RTVFormats[],
+ TEXTURE_FORMAT DSVFormat,
+ Uint32 SampleCount,
+ std::array<VkAttachmentDescription, MaxRenderTargets + 1>& Attachments,
+ std::array<VkAttachmentReference, MaxRenderTargets + 1>& AttachmentReferences,
+ VkSubpassDescription& SubpassDesc);
- void InitializeStaticSRBResources(ShaderResourceCacheVk& ResourceCache)const;
+
+ void InitializeStaticSRBResources(ShaderResourceCacheVk& ResourceCache) const;
private:
- const ShaderResourceLayoutVk& GetStaticShaderResLayout(Uint32 ShaderInd)const
+ const ShaderResourceLayoutVk& GetStaticShaderResLayout(Uint32 ShaderInd) const
{
VERIFY_EXPR(ShaderInd < m_NumShaders);
return m_ShaderResourceLayouts[m_NumShaders + ShaderInd];
}
- const ShaderResourceCacheVk& GetStaticResCache(Uint32 ShaderInd)const
+ const ShaderResourceCacheVk& GetStaticResCache(Uint32 ShaderInd) const
{
VERIFY_EXPR(ShaderInd < m_NumShaders);
return m_StaticResCaches[ShaderInd];
}
- ShaderVariableManagerVk& GetStaticVarMgr(Uint32 ShaderInd)const
+ ShaderVariableManagerVk& GetStaticVarMgr(Uint32 ShaderInd) const
{
VERIFY_EXPR(ShaderInd < m_NumShaders);
return m_StaticVarsMgrs[ShaderInd];
}
- ShaderResourceLayoutVk* m_ShaderResourceLayouts = nullptr;
- ShaderResourceCacheVk* m_StaticResCaches = nullptr;
- ShaderVariableManagerVk* m_StaticVarsMgrs = nullptr;
+ ShaderResourceLayoutVk* m_ShaderResourceLayouts = nullptr;
+ ShaderResourceCacheVk* m_StaticResCaches = nullptr;
+ ShaderVariableManagerVk* m_StaticVarsMgrs = nullptr;
// SRB memory allocator must be declared before m_pDefaultShaderResBinding
SRBMemoryAllocator m_SRBMemAllocator;
-
+
std::array<VulkanUtilities::ShaderModuleWrapper, MaxShadersInPipeline> m_ShaderModules;
- VkRenderPass m_RenderPass = VK_NULL_HANDLE; // Render passes are managed by the render device
+ VkRenderPass m_RenderPass = VK_NULL_HANDLE; // Render passes are managed by the render device
VulkanUtilities::PipelineWrapper m_Pipeline;
PipelineLayout m_PipelineLayout;
@@ -157,4 +157,4 @@ private:
bool m_HasNonStaticResources = false;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h
index 858d3180..52051652 100644
--- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h
@@ -55,72 +55,72 @@ class RenderDeviceVkImpl final : public RenderDeviceNextGenBase<RenderDeviceBase
public:
using TRenderDeviceBase = RenderDeviceNextGenBase<RenderDeviceBase<IRenderDeviceVk>, ICommandQueueVk>;
- RenderDeviceVkImpl(IReferenceCounters* pRefCounters,
- IMemoryAllocator& RawMemAllocator,
- IEngineFactory* pEngineFactory,
- const EngineVkCreateInfo& EngineCI,
- size_t CommandQueueCount,
- ICommandQueueVk** pCmdQueues,
- std::shared_ptr<VulkanUtilities::VulkanInstance> Instance,
- std::unique_ptr<VulkanUtilities::VulkanPhysicalDevice> PhysicalDevice,
- std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> LogicalDevice);
+ RenderDeviceVkImpl(IReferenceCounters* pRefCounters,
+ IMemoryAllocator& RawMemAllocator,
+ IEngineFactory* pEngineFactory,
+ const EngineVkCreateInfo& EngineCI,
+ size_t CommandQueueCount,
+ ICommandQueueVk** pCmdQueues,
+ std::shared_ptr<VulkanUtilities::VulkanInstance> Instance,
+ std::unique_ptr<VulkanUtilities::VulkanPhysicalDevice> PhysicalDevice,
+ std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> LogicalDevice);
~RenderDeviceVkImpl();
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface )override final;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
/// Implementation of IRenderDevice::CreatePipelineState() in Vulkan backend.
- virtual void CreatePipelineState(const PipelineStateDesc& PipelineDesc, IPipelineState** ppPipelineState)override final;
+ virtual void CreatePipelineState(const PipelineStateDesc& PipelineDesc, IPipelineState** ppPipelineState) override final;
/// Implementation of IRenderDevice::CreateBuffer() in Vulkan backend.
- virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer** ppBuffer)override final;
+ virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer** ppBuffer) override final;
/// Implementation of IRenderDevice::CreateShader() in Vulkan backend.
- virtual void CreateShader(const ShaderCreateInfo& ShaderCreateInfo, IShader** ppShader)override final;
+ virtual void CreateShader(const ShaderCreateInfo& ShaderCreateInfo, IShader** ppShader) override final;
/// Implementation of IRenderDevice::CreateTexture() in Vulkan backend.
- virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture** ppTexture)override final;
-
+ virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture** ppTexture) override final;
+
void CreateTexture(const TextureDesc& TexDesc, VkImage vkImgHandle, RESOURCE_STATE InitialState, class TextureVkImpl** ppTexture);
-
+
/// Implementation of IRenderDevice::CreateSampler() in Vulkan backend.
- virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler** ppSampler)override final;
+ virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler** ppSampler) override final;
/// Implementation of IRenderDevice::CreateFence() in Vulkan backend.
- virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence)override final;
+ virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence) override final;
/// Implementation of IRenderDeviceVk::GetVkDevice().
- virtual VkDevice GetVkDevice()override final{ return m_LogicalVkDevice->GetVkDevice();}
-
+ virtual VkDevice GetVkDevice() override final { return m_LogicalVkDevice->GetVkDevice(); }
+
/// Implementation of IRenderDeviceVk::CreateTextureFromVulkanImage().
- virtual void CreateTextureFromVulkanImage(VkImage vkImage, const TextureDesc& TexDesc, RESOURCE_STATE InitialState, ITexture** ppTexture)override final;
+ virtual void CreateTextureFromVulkanImage(VkImage vkImage, const TextureDesc& TexDesc, RESOURCE_STATE InitialState, ITexture** ppTexture) override final;
/// Implementation of IRenderDeviceVk::CreateBufferFromVulkanResource().
- virtual void CreateBufferFromVulkanResource(VkBuffer vkBuffer, const BufferDesc& BuffDesc, RESOURCE_STATE InitialState, IBuffer** ppBuffer)override final;
+ virtual void CreateBufferFromVulkanResource(VkBuffer vkBuffer, const BufferDesc& BuffDesc, RESOURCE_STATE InitialState, IBuffer** ppBuffer) override final;
/// Implementation of IRenderDevice::IdleGPU() in Vulkan backend.
- virtual void IdleGPU()override final;
+ virtual void IdleGPU() override final;
// pImmediateCtx parameter is only used to make sure the command buffer is submitted from the immediate context
// The method returns fence value associated with the submitted command buffer
- Uint64 ExecuteCommandBuffer(Uint32 QueueIndex, const VkSubmitInfo &SubmitInfo, class DeviceContextVkImpl* pImmediateCtx, std::vector<std::pair<Uint64, RefCntAutoPtr<IFence> > >* pSignalFences);
+ Uint64 ExecuteCommandBuffer(Uint32 QueueIndex, const VkSubmitInfo& SubmitInfo, class DeviceContextVkImpl* pImmediateCtx, std::vector<std::pair<Uint64, RefCntAutoPtr<IFence>>>* pSignalFences);
void AllocateTransientCmdPool(VulkanUtilities::CommandPoolWrapper& CmdPool, VkCommandBuffer& vkCmdBuff, const Char* DebugPoolName = nullptr);
void ExecuteAndDisposeTransientCmdBuff(Uint32 QueueIndex, VkCommandBuffer vkCmdBuff, VulkanUtilities::CommandPoolWrapper&& CmdPool);
/// Implementation of IRenderDevice::ReleaseStaleResources() in Vulkan backend.
- virtual void ReleaseStaleResources(bool ForceRelease = false)override final;
+ virtual void ReleaseStaleResources(bool ForceRelease = false) override final;
DescriptorSetAllocation AllocateDescriptorSet(Uint64 CommandQueueMask, VkDescriptorSetLayout SetLayout, const char* DebugName = "")
{
return m_DescriptorSetAllocator.Allocate(CommandQueueMask, SetLayout, DebugName);
}
- DescriptorPoolManager& GetDynamicDescriptorPool(){return m_DynamicDescriptorPool;}
+ DescriptorPoolManager& GetDynamicDescriptorPool() { return m_DynamicDescriptorPool; }
- std::shared_ptr<const VulkanUtilities::VulkanInstance> GetVulkanInstance()const { return m_VulkanInstance;}
- const VulkanUtilities::VulkanPhysicalDevice& GetPhysicalDevice()const { return *m_PhysicalDevice;}
- const VulkanUtilities::VulkanLogicalDevice& GetLogicalDevice () { return *m_LogicalVkDevice;}
- FramebufferCache& GetFramebufferCache() { return m_FramebufferCache;}
- RenderPassCache& GetRenderPassCache() { return m_RenderPassCache;}
+ std::shared_ptr<const VulkanUtilities::VulkanInstance> GetVulkanInstance() const { return m_VulkanInstance; }
+ const VulkanUtilities::VulkanPhysicalDevice& GetPhysicalDevice() const { return *m_PhysicalDevice; }
+ const VulkanUtilities::VulkanLogicalDevice& GetLogicalDevice() { return *m_LogicalVkDevice; }
+ FramebufferCache& GetFramebufferCache() { return m_FramebufferCache; }
+ RenderPassCache& GetRenderPassCache() { return m_RenderPassCache; }
VulkanUtilities::VulkanMemoryAllocation AllocateMemory(const VkMemoryRequirements& MemReqs, VkMemoryPropertyFlags MemoryProperties)
{
@@ -129,21 +129,21 @@ public:
VulkanUtilities::VulkanMemoryManager& GetGlobalMemoryManager() { return m_MemoryMgr; }
VulkanDynamicMemoryManager& GetDynamicMemoryManager() { return m_DynamicMemoryManager; }
- void FlushStaleResources(Uint32 CmdQueueIndex);
+ void FlushStaleResources(Uint32 CmdQueueIndex);
private:
- virtual void TestTextureFormat( TEXTURE_FORMAT TexFormat )override final;
+ virtual void TestTextureFormat(TEXTURE_FORMAT TexFormat) override final;
// Submits command buffer for execution to the command queue
// Returns the submitted command buffer number and the fence value
// Parameters:
// * SubmittedCmdBuffNumber - submitted command buffer number
// * SubmittedFenceValue - fence value associated with the submitted command buffer
- void SubmitCommandBuffer(Uint32 QueueIndex, const VkSubmitInfo& SubmitInfo, Uint64& SubmittedCmdBuffNumber, Uint64& SubmittedFenceValue, std::vector<std::pair<Uint64, RefCntAutoPtr<IFence> > >* pFences);
+ void SubmitCommandBuffer(Uint32 QueueIndex, const VkSubmitInfo& SubmitInfo, Uint64& SubmittedCmdBuffNumber, Uint64& SubmittedFenceValue, std::vector<std::pair<Uint64, RefCntAutoPtr<IFence>>>* pFences);
- std::shared_ptr<VulkanUtilities::VulkanInstance> m_VulkanInstance;
- std::unique_ptr<VulkanUtilities::VulkanPhysicalDevice> m_PhysicalDevice;
- std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> m_LogicalVkDevice;
+ std::shared_ptr<VulkanUtilities::VulkanInstance> m_VulkanInstance;
+ std::unique_ptr<VulkanUtilities::VulkanPhysicalDevice> m_PhysicalDevice;
+ std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> m_LogicalVkDevice;
EngineVkCreateInfo m_EngineAttribs;
@@ -153,13 +153,13 @@ private:
DescriptorPoolManager m_DynamicDescriptorPool;
// These one-time command pools are used by buffer and texture constructors to
- // issue copy commands. Vulkan requires that every command pool is used by one thread
+ // issue copy commands. Vulkan requires that every command pool is used by one thread
// at a time, so every constructor must allocate command buffer from its own pool.
- CommandPoolManager m_TransientCmdPoolMgr;
+ CommandPoolManager m_TransientCmdPoolMgr;
VulkanUtilities::VulkanMemoryManager m_MemoryMgr;
VulkanDynamicMemoryManager m_DynamicMemoryManager;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/RenderPassCache.h b/Graphics/GraphicsEngineVulkan/include/RenderPassCache.h
index 1d94e538..d5a3737e 100644
--- a/Graphics/GraphicsEngineVulkan/include/RenderPassCache.h
+++ b/Graphics/GraphicsEngineVulkan/include/RenderPassCache.h
@@ -40,47 +40,54 @@ class RenderDeviceVkImpl;
class RenderPassCache
{
public:
- RenderPassCache(RenderDeviceVkImpl& DeviceVk)noexcept :
- m_DeviceVkImpl(DeviceVk)
+ RenderPassCache(RenderDeviceVkImpl& DeviceVk) noexcept :
+ m_DeviceVkImpl{DeviceVk}
{}
+ // clang-format off
RenderPassCache (const RenderPassCache&) = delete;
RenderPassCache (RenderPassCache&&) = delete;
RenderPassCache& operator = (const RenderPassCache&) = delete;
RenderPassCache& operator = (RenderPassCache&&) = delete;
+ // clang-format on
~RenderPassCache();
// This structure is used as the key to find framebuffer
struct RenderPassCacheKey
{
+ // clang-format off
RenderPassCacheKey() :
NumRenderTargets{0},
SampleCount {0},
DSVFormat {TEX_FORMAT_UNKNOWN}
{}
+ // clang-format on
- RenderPassCacheKey(Uint32 _NumRenderTargets,
+ RenderPassCacheKey(Uint32 _NumRenderTargets,
Uint32 _SampleCount,
const TEXTURE_FORMAT _RTVFormats[],
- TEXTURE_FORMAT _DSVFormat) :
+ TEXTURE_FORMAT _DSVFormat) :
+ // clang-format off
NumRenderTargets{static_cast<decltype(NumRenderTargets)>(_NumRenderTargets)},
SampleCount {static_cast<decltype(SampleCount)> (_SampleCount) },
DSVFormat {_DSVFormat }
+ // clang-format on
{
VERIFY_EXPR(_NumRenderTargets <= std::numeric_limits<decltype(NumRenderTargets)>::max());
VERIFY_EXPR(_SampleCount <= std::numeric_limits<decltype(SampleCount)>::max());
- for(Uint32 rt=0; rt < NumRenderTargets; ++rt)
+ for (Uint32 rt = 0; rt < NumRenderTargets; ++rt)
RTVFormats[rt] = _RTVFormats[rt];
}
// Default memeber initialization is intentionally omitted
- Uint8 NumRenderTargets;
- Uint8 SampleCount;
- TEXTURE_FORMAT DSVFormat;
- TEXTURE_FORMAT RTVFormats[MaxRenderTargets];
+ Uint8 NumRenderTargets;
+ Uint8 SampleCount;
+ TEXTURE_FORMAT DSVFormat;
+ TEXTURE_FORMAT RTVFormats[MaxRenderTargets];
- bool operator == (const RenderPassCacheKey &rhs)const
+ bool operator==(const RenderPassCacheKey& rhs) const
{
+ // clang-format off
if (GetHash() != rhs.GetHash() ||
NumRenderTargets != rhs.NumRenderTargets ||
SampleCount != rhs.SampleCount ||
@@ -88,6 +95,7 @@ public:
{
return false;
}
+ // clang-format on
for (Uint32 rt = 0; rt < NumRenderTargets; ++rt)
if (RTVFormats[rt] != rhs.RTVFormats[rt])
@@ -96,12 +104,12 @@ public:
return true;
}
- size_t GetHash()const
+ size_t GetHash() const
{
- if(Hash == 0)
+ if (Hash == 0)
{
Hash = ComputeHash(NumRenderTargets, SampleCount, DSVFormat);
- for(Uint32 rt = 0; rt < NumRenderTargets; ++rt)
+ for (Uint32 rt = 0; rt < NumRenderTargets; ++rt)
HashCombine(Hash, RTVFormats[rt]);
}
return Hash;
@@ -114,18 +122,18 @@ public:
VkRenderPass GetRenderPass(const RenderPassCacheKey& Key);
private:
-
struct RenderPassCacheKeyHash
{
- std::size_t operator() (const RenderPassCacheKey& Key)const
+ std::size_t operator()(const RenderPassCacheKey& Key) const
{
return Key.GetHash();
}
};
-
+
RenderDeviceVkImpl& m_DeviceVkImpl;
- std::mutex m_Mutex;
+
+ std::mutex m_Mutex;
std::unordered_map<RenderPassCacheKey, VulkanUtilities::RenderPassWrapper, RenderPassCacheKeyHash> m_Cache;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h b/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h
index d59a9491..324e3562 100644
--- a/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h
@@ -46,16 +46,16 @@ public:
SamplerVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, const SamplerDesc& SamplerDesc);
~SamplerVkImpl();
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override;
/// Implementation of ISamplerVk::GetVkSampler().
- virtual VkSampler GetVkSampler()const override final{return m_VkSampler;}
+ virtual VkSampler GetVkSampler() const override final { return m_VkSampler; }
private:
friend class ShaderVkImpl;
/// Vk sampler handle
VulkanUtilities::SamplerWrapper m_VkSampler;
- static constexpr Uint64 m_CommandQueueMask = ~Uint64{0};
+ static constexpr Uint64 m_CommandQueueMask = ~Uint64{0};
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.h b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.h
index 94ee2ba4..d4b72e4e 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.h
@@ -48,36 +48,35 @@ public:
ShaderResourceBindingVkImpl(IReferenceCounters* pRefCounters, class PipelineStateVkImpl* pPSO, bool IsPSOInternal);
~ShaderResourceBindingVkImpl();
- virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override final;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
/// Implementation of IShaderResourceBinding::BindResources() in Vulkan backend.
- virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags)override final;
+ virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags) override final;
/// Implementation of IShaderResourceBinding::GetVariableByName() in Vulkan backend.
- virtual IShaderResourceVariable* GetVariableByName(SHADER_TYPE ShaderType, const char* Name)override final;
+ virtual IShaderResourceVariable* GetVariableByName(SHADER_TYPE ShaderType, const char* Name) override final;
/// Implementation of IShaderResourceBinding::GetVariableCount() in Vulkan backend.
virtual Uint32 GetVariableCount(SHADER_TYPE ShaderType) const override final;
/// Implementation of IShaderResourceBinding::GetVariableByIndex() in Vulkan backend.
- virtual IShaderResourceVariable* GetVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index)override final;
+ virtual IShaderResourceVariable* GetVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) override final;
/// Implementation of IShaderResourceBinding::InitializeStaticResources() in Vulkan backend.
- virtual void InitializeStaticResources(const IPipelineState* pPipelineState)override final;
+ virtual void InitializeStaticResources(const IPipelineState* pPipelineState) override final;
ShaderResourceCacheVk& GetResourceCache() { return m_ShaderResourceCache; }
bool StaticResourcesInitialized() const { return m_bStaticResourcesInitialized; }
private:
-
ShaderResourceCacheVk m_ShaderResourceCache;
ShaderVariableManagerVk* m_pShaderVarMgrs = nullptr;
// Shader variable manager index in m_pShaderVarMgrs[] array for every shader stage
- Int8 m_ResourceLayoutIndex[6] = {-1, -1, -1, -1, -1, -1};
- bool m_bStaticResourcesInitialized = false;
- Uint8 m_NumShaders = 0;
+ Int8 m_ResourceLayoutIndex[6] = {-1, -1, -1, -1, -1, -1};
+ bool m_bStaticResourcesInitialized = false;
+ Uint8 m_NumShaders = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h
index 2ec63afe..fae9cd2d 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceCacheVk.h
@@ -27,7 +27,7 @@
/// Declaration of Diligent::ShaderResourceCacheVk class
// Shader resource cache stores Vk resources in a continuous chunk of memory:
-//
+//
// |Vulkan Descriptor Set|
// A ___________________________________________________________
// m_pMemory | | m_pResources, m_NumResources == m |
@@ -37,12 +37,12 @@
// | | A \
// | | | \
// | |________________________________________________| \RefCntAutoPtr
-// | m_pResources, m_NumResources == n \_________
+// | m_pResources, m_NumResources == n \_________
// | | Object |
-// | m_DescriptorSetAllocation ---------
+// | m_DescriptorSetAllocation ---------
// V
// |Vulkan Descriptor Set|
-//
+//
// Ns = m_NumSets
//
//
@@ -70,6 +70,7 @@ public:
SRBResources
};
+ // clang-format off
ShaderResourceCacheVk(DbgCacheContentType dbgContentType)
#ifdef _DEBUG
: m_DbgContentType{dbgContentType}
@@ -81,18 +82,21 @@ public:
ShaderResourceCacheVk (ShaderResourceCacheVk&&) = delete;
ShaderResourceCacheVk& operator = (const ShaderResourceCacheVk&) = delete;
ShaderResourceCacheVk& operator = (ShaderResourceCacheVk&&) = delete;
+ // clang-format on
~ShaderResourceCacheVk();
static size_t GetRequiredMemorySize(Uint32 NumSets, Uint32 SetSizes[]);
+
void InitializeSets(IMemoryAllocator& MemAllocator, Uint32 NumSets, Uint32 SetSizes[]);
void InitializeResources(Uint32 Set, Uint32 Offset, Uint32 ArraySize, SPIRVShaderResourceAttribs::ResourceType Type);
// sizeof(Resource) == 16 (x64, msvc, Release)
struct Resource
{
+ // clang-format off
Resource(SPIRVShaderResourceAttribs::ResourceType _Type) :
- Type(_Type)
+ Type{_Type}
{}
Resource (const Resource&) = delete;
@@ -109,12 +113,14 @@ public:
VkDescriptorImageInfo GetImageDescriptorWriteInfo (bool IsImmutableSampler)const;
VkBufferView GetBufferViewWriteInfo () const;
VkDescriptorImageInfo GetSamplerDescriptorWriteInfo() const;
+ // clang-format on
};
// sizeof(DescriptorSet) == 48 (x64, msvc, Release)
class DescriptorSet
{
public:
+ // clang-format off
DescriptorSet(Uint32 NumResources, Resource *pResources) :
m_NumResources {NumResources},
m_pResources {pResources }
@@ -124,21 +130,22 @@ public:
DescriptorSet (DescriptorSet&&) = delete;
DescriptorSet& operator = (const DescriptorSet&) = delete;
DescriptorSet& operator = (DescriptorSet&&) = delete;
+ // clang-format on
inline Resource& GetResource(Uint32 CacheOffset)
{
- VERIFY(CacheOffset < m_NumResources, "Offset ", CacheOffset, " is out of range" );
+ VERIFY(CacheOffset < m_NumResources, "Offset ", CacheOffset, " is out of range");
return m_pResources[CacheOffset];
}
- inline const Resource& GetResource(Uint32 CacheOffset)const
+ inline const Resource& GetResource(Uint32 CacheOffset) const
{
- VERIFY(CacheOffset < m_NumResources, "Offset ", CacheOffset, " is out of range" );
+ VERIFY(CacheOffset < m_NumResources, "Offset ", CacheOffset, " is out of range");
return m_pResources[CacheOffset];
}
- inline Uint32 GetSize()const{return m_NumResources; }
+ inline Uint32 GetSize() const { return m_NumResources; }
- VkDescriptorSet GetVkDescriptorSet()const
+ VkDescriptorSet GetVkDescriptorSet() const
{
return m_DescriptorSetAllocation.GetVkDescriptorSet();
}
@@ -149,12 +156,14 @@ public:
m_DescriptorSetAllocation = std::move(Allocation);
}
+ // clang-format off
/* 0 */ const Uint32 m_NumResources = 0;
private:
/* 8 */ Resource* const m_pResources = nullptr;
/*16 */ DescriptorSetAllocation m_DescriptorSetAllocation;
/*48 */ // End of structure
+ // clang-format on
};
inline DescriptorSet& GetDescriptorSet(Uint32 Index)
@@ -162,50 +171,49 @@ public:
VERIFY_EXPR(Index < m_NumSets);
return reinterpret_cast<DescriptorSet*>(m_pMemory)[Index];
}
- inline const DescriptorSet& GetDescriptorSet(Uint32 Index)const
+ inline const DescriptorSet& GetDescriptorSet(Uint32 Index) const
{
VERIFY_EXPR(Index < m_NumSets);
return reinterpret_cast<const DescriptorSet*>(m_pMemory)[Index];
}
- inline Uint32 GetNumDescriptorSets()const{return m_NumSets; }
- inline Uint32 GetNumDynamicBuffers()const{return m_NumDynamicBuffers;}
+ inline Uint32 GetNumDescriptorSets() const { return m_NumSets; }
+ inline Uint32 GetNumDynamicBuffers() const { return m_NumDynamicBuffers; }
- Uint16& GetDynamicBuffersCounter(){return m_NumDynamicBuffers;}
+ Uint16& GetDynamicBuffersCounter() { return m_NumDynamicBuffers; }
#ifdef _DEBUG
// Only for debug purposes: indicates what types of resources are stored in the cache
- DbgCacheContentType DbgGetContentType()const{return m_DbgContentType;}
- void DbgVerifyResourceInitialization()const;
- void DbgVerifyDynamicBuffersCounter()const;
+ DbgCacheContentType DbgGetContentType() const { return m_DbgContentType; }
+ void DbgVerifyResourceInitialization() const;
+ void DbgVerifyDynamicBuffersCounter() const;
#endif
- template<bool VerifyOnly>
- void TransitionResources(DeviceContextVkImpl *pCtxVkImpl);
+ template <bool VerifyOnly>
+ void TransitionResources(DeviceContextVkImpl* pCtxVkImpl);
- __forceinline Uint32 GetDynamicBufferOffsets(Uint32 CtxId, DeviceContextVkImpl* pCtxVkImpl, std::vector<uint32_t>& Offsets)const;
+ __forceinline Uint32 GetDynamicBufferOffsets(Uint32 CtxId, DeviceContextVkImpl* pCtxVkImpl, std::vector<uint32_t>& Offsets) const;
private:
-
Resource* GetFirstResourcePtr()
{
return reinterpret_cast<Resource*>(reinterpret_cast<DescriptorSet*>(m_pMemory) + m_NumSets);
}
- const Resource* GetFirstResourcePtr()const
+ const Resource* GetFirstResourcePtr() const
{
return reinterpret_cast<const Resource*>(reinterpret_cast<const DescriptorSet*>(m_pMemory) + m_NumSets);
}
- IMemoryAllocator* m_pAllocator = nullptr;
- void* m_pMemory = nullptr;
- Uint16 m_NumSets = 0;
+ IMemoryAllocator* m_pAllocator = nullptr;
+ void* m_pMemory = nullptr;
+ Uint16 m_NumSets = 0;
// Total number of dynamic buffers bound in the resource cache regardless of the variable type
- Uint16 m_NumDynamicBuffers = 0;
- Uint32 m_TotalResources = 0;
+ Uint16 m_NumDynamicBuffers = 0;
+ Uint32 m_TotalResources = 0;
#ifdef _DEBUG
// Only for debug purposes: indicates what types of resources are stored in the cache
- const DbgCacheContentType m_DbgContentType;
+ const DbgCacheContentType m_DbgContentType;
// Debug array that stores flags indicating if resources in the cache have been initialized
std::vector<std::vector<bool>> m_DbgInitializedResources;
#endif
@@ -213,22 +221,22 @@ private:
__forceinline Uint32 ShaderResourceCacheVk::GetDynamicBufferOffsets(Uint32 CtxId,
DeviceContextVkImpl* pCtxVkImpl,
- std::vector<uint32_t>& Offsets)const
+ std::vector<uint32_t>& Offsets) const
{
- // If any of the sets being bound include dynamic uniform or storage buffers, then
- // pDynamicOffsets includes one element for each array element in each dynamic descriptor
- // type binding in each set. Values are taken from pDynamicOffsets in an order such that
- // all entries for set N come before set N+1; within a set, entries are ordered by the binding
- // numbers (unclear if this is SPIRV binding or VkDescriptorSetLayoutBinding number) in the
+ // If any of the sets being bound include dynamic uniform or storage buffers, then
+ // pDynamicOffsets includes one element for each array element in each dynamic descriptor
+ // type binding in each set. Values are taken from pDynamicOffsets in an order such that
+ // all entries for set N come before set N+1; within a set, entries are ordered by the binding
+ // numbers (unclear if this is SPIRV binding or VkDescriptorSetLayoutBinding number) in the
// descriptor set layouts; and within a binding array, elements are in order. (13.2.5)
// In each descriptor set, all uniform buffers for every shader stage come first,
// followed by all storage buffers for every shader stage, followed by all other resources
Uint32 OffsetInd = 0;
- for (Uint32 set=0; set < m_NumSets; ++set)
+ for (Uint32 set = 0; set < m_NumSets; ++set)
{
const auto& DescrSet = GetDescriptorSet(set);
- Uint32 res = 0;
+ Uint32 res = 0;
while (res < DescrSet.GetSize())
{
const auto& Res = DescrSet.GetResource(res);
@@ -236,8 +244,8 @@ __forceinline Uint32 ShaderResourceCacheVk::GetDynamicBufferOffsets(Uint32
break;
const auto* pBufferVk = Res.pObject.RawPtr<const BufferVkImpl>();
- auto Offset = pBufferVk != nullptr ? pBufferVk->GetDynamicOffset(CtxId, pCtxVkImpl) : 0;
- Offsets[OffsetInd++] = Offset;
+ auto Offset = pBufferVk != nullptr ? pBufferVk->GetDynamicOffset(CtxId, pCtxVkImpl) : 0;
+ Offsets[OffsetInd++] = Offset;
++res;
}
@@ -245,14 +253,14 @@ __forceinline Uint32 ShaderResourceCacheVk::GetDynamicBufferOffsets(Uint32
while (res < DescrSet.GetSize())
{
const auto& Res = DescrSet.GetResource(res);
- if (Res.Type != SPIRVShaderResourceAttribs::ResourceType::ROStorageBuffer &&
+ if (Res.Type != SPIRVShaderResourceAttribs::ResourceType::ROStorageBuffer &&
Res.Type != SPIRVShaderResourceAttribs::ResourceType::RWStorageBuffer)
break;
const auto* pBufferVkView = Res.pObject.RawPtr<const BufferViewVkImpl>();
- const auto* pBufferVk = pBufferVkView != nullptr ? pBufferVkView->GetBufferVk() : 0;
- auto Offset = pBufferVk != nullptr ? pBufferVk->GetDynamicOffset(CtxId, pCtxVkImpl) : 0;
- Offsets[OffsetInd++] = Offset;
+ const auto* pBufferVk = pBufferVkView != nullptr ? pBufferVkView->GetBufferVk() : 0;
+ auto Offset = pBufferVk != nullptr ? pBufferVk->GetDynamicOffset(CtxId, pCtxVkImpl) : 0;
+ Offsets[OffsetInd++] = Offset;
++res;
}
@@ -261,14 +269,16 @@ __forceinline Uint32 ShaderResourceCacheVk::GetDynamicBufferOffsets(Uint32
for (; res < DescrSet.GetSize(); ++res)
{
const auto& Res = DescrSet.GetResource(res);
+ // clang-format off
VERIFY(Res.Type != SPIRVShaderResourceAttribs::ResourceType::UniformBuffer &&
Res.Type != SPIRVShaderResourceAttribs::ResourceType::ROStorageBuffer &&
Res.Type != SPIRVShaderResourceAttribs::ResourceType::RWStorageBuffer,
"All uniform and storage buffers are expected to go first in the beginning of each descriptor set");
+ // clang-format on
}
#endif
}
return OffsetInd;
}
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
index 951e6bfa..0d4d123f 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
@@ -28,8 +28,8 @@
// All resources are stored in a single continuous chunk of memory using the following layout:
//
-// m_ResourceBuffer
-// |
+// m_ResourceBuffer
+// |
// || VkResource[0] ... VkResource[s-1] | VkResource[s] ... VkResource[s+m-1] | VkResource[s+m] ... VkResource[s+m+d-1] || ||
// || | | || ||
// || VARIABLE_TYPE_STATIC | VARIABLE_TYPE_MUTABLE | VARIABLE_TYPE_DYNAMIC || Immutable Samplers ||
@@ -88,7 +88,7 @@
//
// Every pipeline state object (PipelineStateVkImpl) keeps the following layouts:
// * One layout object per shader stage to facilitate management of static shader resources
-// - Uses artificial layout where resource binding matches the resource type (SPIRVShaderResourceAttribs::ResourceType)
+// - Uses artificial layout where resource binding matches the resource type (SPIRVShaderResourceAttribs::ResourceType)
// * One layout object per shader stage used by SRBs to manage all resource types:
// - All variable types are preserved
// - Bindings, descriptor sets and offsets are assigned during the initialization
@@ -111,40 +111,42 @@ namespace Diligent
class ShaderResourceLayoutVk
{
public:
- ShaderResourceLayoutVk(const VulkanUtilities::VulkanLogicalDevice& LogicalDevice) :
+ ShaderResourceLayoutVk(const VulkanUtilities::VulkanLogicalDevice& LogicalDevice) :
m_LogicalDevice{LogicalDevice}
{
}
-
+ // clang-format off
ShaderResourceLayoutVk (const ShaderResourceLayoutVk&) = delete;
ShaderResourceLayoutVk (ShaderResourceLayoutVk&&) = delete;
ShaderResourceLayoutVk& operator = (const ShaderResourceLayoutVk&) = delete;
ShaderResourceLayoutVk& operator = (ShaderResourceLayoutVk&&) = delete;
-
+ // clang-format on
+
~ShaderResourceLayoutVk();
- // This method is called by PipelineStateVkImpl class instance to initialize static
+ // This method is called by PipelineStateVkImpl class instance to initialize static
// shader resource layout and the cache
- void InitializeStaticResourceLayout(std::shared_ptr<const SPIRVShaderResources> pSrcResources,
+ void InitializeStaticResourceLayout(std::shared_ptr<const SPIRVShaderResources> pSrcResources,
IMemoryAllocator& LayoutDataAllocator,
const PipelineResourceLayoutDesc& ResourceLayoutDesc,
ShaderResourceCacheVk& StaticResourceCache);
// This method is called by PipelineStateVkImpl class instance to initialize resource
// layouts for all shader stages in the pipeline.
- static void Initialize(IRenderDevice* pRenderDevice,
- Uint32 NumShaders,
- ShaderResourceLayoutVk Layouts[],
- std::shared_ptr<const SPIRVShaderResources> pShaderResources[],
- IMemoryAllocator& LayoutDataAllocator,
- const PipelineResourceLayoutDesc& ResourceLayoutDesc,
- std::vector<uint32_t> SPIRVs[],
- class PipelineLayout& PipelineLayout);
+ static void Initialize(IRenderDevice* pRenderDevice,
+ Uint32 NumShaders,
+ ShaderResourceLayoutVk Layouts[],
+ std::shared_ptr<const SPIRVShaderResources> pShaderResources[],
+ IMemoryAllocator& LayoutDataAllocator,
+ const PipelineResourceLayoutDesc& ResourceLayoutDesc,
+ std::vector<uint32_t> SPIRVs[],
+ class PipelineLayout& PipelineLayout);
// sizeof(VkResource) == 24 (x64)
struct VkResource
{
+ // clang-format off
VkResource (const VkResource&) = delete;
VkResource ( VkResource&&) = delete;
VkResource& operator = (const VkResource&) = delete;
@@ -192,25 +194,26 @@ public:
VERIFY(_Binding <= std::numeric_limits<decltype(Binding)>::max(), "Binding (", _Binding, ") exceeds max representable value ", std::numeric_limits<decltype(Binding)>::max() );
VERIFY(_DescriptorSet <= std::numeric_limits<decltype(DescriptorSet)>::max(), "Descriptor set (", _DescriptorSet, ") exceeds max representable value ", std::numeric_limits<decltype(DescriptorSet)>::max());
}
+ // clang-format on
// Checks if a resource is bound in ResourceCache at the given ArrayIndex
- bool IsBound(Uint32 ArrayIndex, const ShaderResourceCacheVk& ResourceCache)const;
-
+ bool IsBound(Uint32 ArrayIndex, const ShaderResourceCacheVk& ResourceCache) const;
+
// Binds a resource pObject in the ResourceCache
- void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex, ShaderResourceCacheVk& ResourceCache)const;
+ void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex, ShaderResourceCacheVk& ResourceCache) const;
// Updates resource descriptor in the descriptor set
- inline void UpdateDescriptorHandle(VkDescriptorSet vkDescrSet,
- uint32_t ArrayElement,
- const VkDescriptorImageInfo* pImageInfo,
- const VkDescriptorBufferInfo* pBufferInfo,
- const VkBufferView* pTexelBufferView)const;
+ inline void UpdateDescriptorHandle(VkDescriptorSet vkDescrSet,
+ uint32_t ArrayElement,
+ const VkDescriptorImageInfo* pImageInfo,
+ const VkDescriptorBufferInfo* pBufferInfo,
+ const VkBufferView* pTexelBufferView) const;
bool IsImmutableSamplerAssigned() const
{
VERIFY(ImmutableSamplerAssigned == 0 ||
- SpirvAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SampledImage ||
- SpirvAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SeparateSampler,
+ SpirvAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SampledImage ||
+ SpirvAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SeparateSampler,
"Immutable sampler can only be assigned to a sampled image or separate sampler");
return ImmutableSamplerAssigned != 0;
}
@@ -221,90 +224,90 @@ public:
}
private:
- void CacheUniformBuffer(IDeviceObject* pBuffer,
- ShaderResourceCacheVk::Resource& DstRes,
- VkDescriptorSet vkDescrSet,
- Uint32 ArrayInd,
- Uint16& DynamicBuffersCounter)const;
-
- void CacheStorageBuffer(IDeviceObject* pBufferView,
- ShaderResourceCacheVk::Resource& DstRes,
- VkDescriptorSet vkDescrSet,
- Uint32 ArrayInd,
- Uint16& DynamicBuffersCounter)const;
-
- void CacheTexelBuffer(IDeviceObject* pBufferView,
- ShaderResourceCacheVk::Resource& DstRes,
- VkDescriptorSet vkDescrSet,
- Uint32 ArrayInd,
- Uint16& DynamicBuffersCounter)const;
-
- template<typename TCacheSampler>
+ void CacheUniformBuffer(IDeviceObject* pBuffer,
+ ShaderResourceCacheVk::Resource& DstRes,
+ VkDescriptorSet vkDescrSet,
+ Uint32 ArrayInd,
+ Uint16& DynamicBuffersCounter) const;
+
+ void CacheStorageBuffer(IDeviceObject* pBufferView,
+ ShaderResourceCacheVk::Resource& DstRes,
+ VkDescriptorSet vkDescrSet,
+ Uint32 ArrayInd,
+ Uint16& DynamicBuffersCounter) const;
+
+ void CacheTexelBuffer(IDeviceObject* pBufferView,
+ ShaderResourceCacheVk::Resource& DstRes,
+ VkDescriptorSet vkDescrSet,
+ Uint32 ArrayInd,
+ Uint16& DynamicBuffersCounter) const;
+
+ template <typename TCacheSampler>
void CacheImage(IDeviceObject* pTexView,
ShaderResourceCacheVk::Resource& DstRes,
VkDescriptorSet vkDescrSet,
Uint32 ArrayInd,
- TCacheSampler CacheSampler)const;
+ TCacheSampler CacheSampler) const;
void CacheSeparateSampler(IDeviceObject* pSampler,
ShaderResourceCacheVk::Resource& DstRes,
VkDescriptorSet vkDescrSet,
- Uint32 ArrayInd)const;
+ Uint32 ArrayInd) const;
- template<typename ObjectType, typename TPreUpdateObject>
- bool UpdateCachedResource(ShaderResourceCacheVk::Resource& DstRes,
- RefCntAutoPtr<ObjectType>&& pObject,
- TPreUpdateObject PreUpdateObject)const;
+ template <typename ObjectType, typename TPreUpdateObject>
+ bool UpdateCachedResource(ShaderResourceCacheVk::Resource& DstRes,
+ RefCntAutoPtr<ObjectType>&& pObject,
+ TPreUpdateObject PreUpdateObject) const;
};
// Copies static resources from SrcResourceCache defined by SrcLayout
// to DstResourceCache defined by this layout
- void InitializeStaticResources(const ShaderResourceLayoutVk& SrcLayout,
+ void InitializeStaticResources(const ShaderResourceLayoutVk& SrcLayout,
const ShaderResourceCacheVk& SrcResourceCache,
- ShaderResourceCacheVk& DstResourceCache)const;
+ ShaderResourceCacheVk& DstResourceCache) const;
#ifdef DEVELOPMENT
- bool dvpVerifyBindings(const ShaderResourceCacheVk& ResourceCache)const;
- static void dvpVerifyResourceLayoutDesc(Uint32 NumShaders,
- const std::shared_ptr<const SPIRVShaderResources> pShaderResources[],
- const PipelineResourceLayoutDesc& ResourceLayoutDesc);
+ bool dvpVerifyBindings(const ShaderResourceCacheVk& ResourceCache) const;
+ static void dvpVerifyResourceLayoutDesc(Uint32 NumShaders,
+ const std::shared_ptr<const SPIRVShaderResources> pShaderResources[],
+ const PipelineResourceLayoutDesc& ResourceLayoutDesc);
#endif
- Uint32 GetResourceCount(SHADER_RESOURCE_VARIABLE_TYPE VarType)const
+ Uint32 GetResourceCount(SHADER_RESOURCE_VARIABLE_TYPE VarType) const
{
return m_NumResources[VarType];
}
// Initializes resource slots in the ResourceCache
- void InitializeResourceMemoryInCache(ShaderResourceCacheVk& ResourceCache)const;
-
+ void InitializeResourceMemoryInCache(ShaderResourceCacheVk& ResourceCache) const;
+
// Writes dynamic resource descriptors from ResourceCache to vkDynamicDescriptorSet
void CommitDynamicResources(const ShaderResourceCacheVk& ResourceCache,
- VkDescriptorSet vkDynamicDescriptorSet)const;
+ VkDescriptorSet vkDynamicDescriptorSet) const;
- const Char* GetShaderName()const
+ const Char* GetShaderName() const
{
return m_pResources->GetShaderName();
}
- SHADER_TYPE GetShaderType()const
+ SHADER_TYPE GetShaderType() const
{
return m_pResources->GetShaderType();
}
- const VkResource& GetResource(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 r)const
+ const VkResource& GetResource(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 r) const
{
- VERIFY_EXPR( r < m_NumResources[VarType] );
+ VERIFY_EXPR(r < m_NumResources[VarType]);
auto* Resources = reinterpret_cast<const VkResource*>(m_ResourceBuffer.get());
- return Resources[GetResourceOffset(VarType,r)];
+ return Resources[GetResourceOffset(VarType, r)];
}
- bool IsUsingSeparateSamplers()const {return !m_pResources->IsUsingCombinedSamplers();}
+ bool IsUsingSeparateSamplers() const { return !m_pResources->IsUsingCombinedSamplers(); }
private:
- Uint32 GetResourceOffset(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 r)const
+ Uint32 GetResourceOffset(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 r) const
{
- VERIFY_EXPR( r < m_NumResources[VarType] );
+ VERIFY_EXPR(r < m_NumResources[VarType]);
static_assert(SHADER_RESOURCE_VARIABLE_TYPE_STATIC == 0, "SHADER_RESOURCE_VARIABLE_TYPE_STATIC == 0 expected");
r += (VarType > SHADER_RESOURCE_VARIABLE_TYPE_STATIC) ? m_NumResources[SHADER_RESOURCE_VARIABLE_TYPE_STATIC] : 0;
static_assert(SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE == 1, "SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE == 1 expected");
@@ -313,24 +316,24 @@ private:
}
VkResource& GetResource(SHADER_RESOURCE_VARIABLE_TYPE VarType, Uint32 r)
{
- VERIFY_EXPR( r < m_NumResources[VarType] );
+ VERIFY_EXPR(r < m_NumResources[VarType]);
auto* Resources = reinterpret_cast<VkResource*>(m_ResourceBuffer.get());
- return Resources[GetResourceOffset(VarType,r)];
+ return Resources[GetResourceOffset(VarType, r)];
}
- const VkResource& GetResource(Uint32 r)const
+ const VkResource& GetResource(Uint32 r) const
{
VERIFY_EXPR(r < GetTotalResourceCount());
auto* Resources = reinterpret_cast<const VkResource*>(m_ResourceBuffer.get());
return Resources[r];
}
- Uint32 GetTotalResourceCount()const
+ Uint32 GetTotalResourceCount() const
{
return m_NumResources[SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES];
}
- void AllocateMemory(std::shared_ptr<const SPIRVShaderResources> pSrcResources,
+ void AllocateMemory(std::shared_ptr<const SPIRVShaderResources> pSrcResources,
IMemoryAllocator& Allocator,
const PipelineResourceLayoutDesc& ResourceLayoutDesc,
const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes,
@@ -339,16 +342,17 @@ private:
Uint32 FindAssignedSampler(const SPIRVShaderResourceAttribs& SepImg,
Uint32 CurrResourceCount,
- SHADER_RESOURCE_VARIABLE_TYPE ImgVarType)const;
+ SHADER_RESOURCE_VARIABLE_TYPE ImgVarType) const;
using ImmutableSamplerPtrType = RefCntAutoPtr<ISampler>;
- ImmutableSamplerPtrType& GetImmutableSampler(Uint32 n)noexcept
+ ImmutableSamplerPtrType& GetImmutableSampler(Uint32 n) noexcept
{
VERIFY(n < m_NumImmutableSamplers, "Immutable sampler index (", n, ") is out of range. Total immutable sampler count: ", m_NumImmutableSamplers);
auto* ResourceMemoryEnd = reinterpret_cast<VkResource*>(m_ResourceBuffer.get()) + GetTotalResourceCount();
return reinterpret_cast<ImmutableSamplerPtrType*>(ResourceMemoryEnd)[n];
}
+ // clang-format off
/* 0 */ const VulkanUtilities::VulkanLogicalDevice& m_LogicalDevice;
/* 8 */ std::unique_ptr<void, STDDeleterRawMem<void> > m_ResourceBuffer;
@@ -359,6 +363,7 @@ private:
/*40 */ std::array<Uint16, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES+1> m_NumResources = {};
/*48 */ Uint32 m_NumImmutableSamplers = 0;
/*56*/ // End of class
+ // clang-format on
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h
index cfaa41a8..a2c04faa 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h
@@ -26,7 +26,7 @@
/// \file
/// Declaration of Diligent::ShaderVariableManagerVk and Diligent::ShaderVariableVkImpl classes
-//
+//
// * ShaderVariableManagerVk keeps list of variables of specific types
// * Every ShaderVariableVkImpl references VkResource from ShaderResourceLayoutVk
// * ShaderVariableManagerVk keeps reference to ShaderResourceCacheVk
@@ -69,12 +69,12 @@ class ShaderVariableVkImpl;
class ShaderVariableManagerVk
{
public:
- ShaderVariableManagerVk(IObject& Owner,
- const ShaderResourceLayoutVk& SrcLayout,
- IMemoryAllocator& Allocator,
- const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes,
- Uint32 NumAllowedTypes,
- ShaderResourceCacheVk& ResourceCache);
+ ShaderVariableManagerVk(IObject& Owner,
+ const ShaderResourceLayoutVk& SrcLayout,
+ IMemoryAllocator& Allocator,
+ const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes,
+ Uint32 NumAllowedTypes,
+ ShaderResourceCacheVk& ResourceCache);
~ShaderVariableManagerVk();
@@ -85,33 +85,33 @@ public:
void BindResources(IResourceMapping* pResourceMapping, Uint32 Flags);
- static size_t GetRequiredMemorySize(const ShaderResourceLayoutVk& Layout,
- const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes,
- Uint32 NumAllowedTypes,
- Uint32& NumVariables);
+ static size_t GetRequiredMemorySize(const ShaderResourceLayoutVk& Layout,
+ const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes,
+ Uint32 NumAllowedTypes,
+ Uint32& NumVariables);
- Uint32 GetVariableCount()const { return m_NumVariables; }
+ Uint32 GetVariableCount() const { return m_NumVariables; }
private:
friend ShaderVariableVkImpl;
Uint32 GetVariableIndex(const ShaderVariableVkImpl& Variable);
- IObject& m_Owner;
+ IObject& m_Owner;
// Variable mgr is owned by either Pipeline state object (in which case m_ResourceCache references
- // static resource cache owned by the same PSO object), or by SRB object (in which case
+ // static resource cache owned by the same PSO object), or by SRB object (in which case
// m_ResourceCache references the cache in the SRB). Thus the cache and the resource layout
// (which the variables reference) are guaranteed to be alive while the manager is alive.
- ShaderResourceCacheVk& m_ResourceCache;
+ ShaderResourceCacheVk& m_ResourceCache;
// Memory is allocated through the allocator provided by the pipeline state. If allocation granularity > 1, fixed block
// memory allocator is used. This ensures that all resources from different shader resource bindings reside in
// continuous memory. If allocation granularity == 1, raw allocator is used.
- ShaderVariableVkImpl* m_pVariables = nullptr;
- Uint32 m_NumVariables = 0;
+ ShaderVariableVkImpl* m_pVariables = nullptr;
+ Uint32 m_NumVariables = 0;
#ifdef _DEBUG
- IMemoryAllocator& m_DbgAllocator;
+ IMemoryAllocator& m_DbgAllocator;
#endif
};
@@ -121,32 +121,34 @@ class ShaderVariableVkImpl final : public IShaderResourceVariable
public:
ShaderVariableVkImpl(ShaderVariableManagerVk& ParentManager,
const ShaderResourceLayoutVk::VkResource& Resource) :
- m_ParentManager(ParentManager),
- m_Resource(Resource)
+ m_ParentManager{ParentManager},
+ m_Resource{Resource}
{}
+ // clang-format off
ShaderVariableVkImpl (const ShaderVariableVkImpl&) = delete;
ShaderVariableVkImpl (ShaderVariableVkImpl&&) = delete;
ShaderVariableVkImpl& operator= (const ShaderVariableVkImpl&) = delete;
ShaderVariableVkImpl& operator= (ShaderVariableVkImpl&&) = delete;
+ // clang-format on
- virtual IReferenceCounters* GetReferenceCounters()const override final
+ virtual IReferenceCounters* GetReferenceCounters() const override final
{
return m_ParentManager.m_Owner.GetReferenceCounters();
}
- virtual Atomics::Long AddRef()override final
+ virtual Atomics::Long AddRef() override final
{
return m_ParentManager.m_Owner.AddRef();
}
- virtual Atomics::Long Release()override final
+ virtual Atomics::Long Release() override final
{
return m_ParentManager.m_Owner.Release();
}
- void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final
+ void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final
{
if (ppInterface == nullptr)
return;
@@ -159,29 +161,29 @@ public:
}
}
- virtual SHADER_RESOURCE_VARIABLE_TYPE GetType()const override final
+ virtual SHADER_RESOURCE_VARIABLE_TYPE GetType() const override final
{
return m_Resource.GetVariableType();
}
- virtual void Set(IDeviceObject* pObject)override final
+ virtual void Set(IDeviceObject* pObject) override final
{
- m_Resource.BindResource(pObject, 0, m_ParentManager.m_ResourceCache);
+ m_Resource.BindResource(pObject, 0, m_ParentManager.m_ResourceCache);
}
- virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements)override final
+ virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) override final
{
VerifyAndCorrectSetArrayArguments(m_Resource.SpirvAttribs.Name, m_Resource.SpirvAttribs.ArraySize, FirstElement, NumElements);
for (Uint32 Elem = 0; Elem < NumElements; ++Elem)
m_Resource.BindResource(ppObjects[Elem], FirstElement + Elem, m_ParentManager.m_ResourceCache);
}
- virtual ShaderResourceDesc GetResourceDesc()const override final
+ virtual ShaderResourceDesc GetResourceDesc() const override final
{
return m_Resource.SpirvAttribs.GetResourceDesc();
}
- virtual Uint32 GetIndex()const override final
+ virtual Uint32 GetIndex() const override final
{
return m_ParentManager.GetVariableIndex(*this);
}
@@ -191,7 +193,7 @@ public:
return m_Resource.IsBound(ArrayIndex, m_ParentManager.m_ResourceCache);
}
- const ShaderResourceLayoutVk::VkResource& GetResource()const
+ const ShaderResourceLayoutVk::VkResource& GetResource() const
{
return m_Resource;
}
@@ -203,4 +205,4 @@ private:
const ShaderResourceLayoutVk::VkResource& m_Resource;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h
index 9dd0dcac..e605b5bf 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h
@@ -46,31 +46,32 @@ public:
ShaderVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, const ShaderCreateInfo& CreationAttribs);
~ShaderVkImpl();
-
+
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_ShaderVk, TShaderBase);
/// Implementation of IShader::GetResourceCount() in Vulkan backend.
- virtual Uint32 GetResourceCount()const override final
+ virtual Uint32 GetResourceCount() const override final
{
return m_pShaderResources->GetTotalResources();
}
/// Implementation of IShader::GetResource() in Vulkan backend.
- virtual ShaderResourceDesc GetResource(Uint32 Index)const override final;
+ virtual ShaderResourceDesc GetResource(Uint32 Index) const override final;
/// Implementation of IShaderVk::GetSPIRV().
- virtual const std::vector<uint32_t>& GetSPIRV()const override final
+ virtual const std::vector<uint32_t>& GetSPIRV() const override final
{
return m_SPIRV;
}
-
- const std::shared_ptr<const SPIRVShaderResources>& GetShaderResources()const{return m_pShaderResources;}
+
+ const std::shared_ptr<const SPIRVShaderResources>& GetShaderResources() const { return m_pShaderResources; }
+
const char* GetEntryPoint() const { return m_EntryPoint.c_str(); }
private:
void MapHLSLVertexShaderInputs();
- // SPIRVShaderResources class instance must be referenced through the shared pointer, because
+ // SPIRVShaderResources class instance must be referenced through the shared pointer, because
// it is referenced by ShaderResourceLayoutVk class instances
std::shared_ptr<const SPIRVShaderResources> m_pShaderResources;
@@ -78,4 +79,4 @@ private:
std::vector<uint32_t> m_SPIRV;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.h b/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.h
index 72475a31..88c3e392 100644
--- a/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.h
@@ -44,47 +44,48 @@ public:
using TSwapChainBase = SwapChainBase<ISwapChainVk>;
SwapChainVkImpl(IReferenceCounters* pRefCounters,
- const SwapChainDesc& SwapChainDesc,
+ const SwapChainDesc& SwapChainDesc,
class RenderDeviceVkImpl* pRenderDeviceVk,
class DeviceContextVkImpl* pDeviceContextVk,
void* pNativeWndHandle);
~SwapChainVkImpl();
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
/// Implementation of ISwapChain::Present() in Vulkan backend.
- virtual void Present(Uint32 SyncInterval)override final;
+ virtual void Present(Uint32 SyncInterval) override final;
/// Implementation of ISwapChain::Resize() in Vulkan backend.
- virtual void Resize( Uint32 NewWidth, Uint32 NewHeight )override final;
+ virtual void Resize(Uint32 NewWidth, Uint32 NewHeight) override final;
/// Implementation of ISwapChain::SetFullscreenMode() in Vulkan backend.
- virtual void SetFullscreenMode(const DisplayModeAttribs &DisplayMode)override final;
+ virtual void SetFullscreenMode(const DisplayModeAttribs& DisplayMode) override final;
/// Implementation of ISwapChain::SetWindowedMode() in Vulkan backend.
- virtual void SetWindowedMode()override final;
+ virtual void SetWindowedMode() override final;
/// Implementation of ISwapChainVk::GetVkSwapChain().
- virtual VkSwapchainKHR GetVkSwapChain()override final{ return m_VkSwapChain; }
+ virtual VkSwapchainKHR GetVkSwapChain() override final { return m_VkSwapChain; }
/// Implementation of ISwapChain::GetCurrentBackBufferRTV() in Vulkan backend.
- virtual ITextureViewVk* GetCurrentBackBufferRTV()override final
+ virtual ITextureViewVk* GetCurrentBackBufferRTV() override final
{
VERIFY_EXPR(m_BackBufferIndex >= 0 && m_BackBufferIndex < m_SwapChainDesc.BufferCount);
return m_pBackBufferRTV[m_BackBufferIndex];
}
/// Implementation of ISwapChain::GetDepthBufferDSV() in Vulkan backend.
- virtual ITextureViewVk* GetDepthBufferDSV()override final{return m_pDepthBufferDSV;}
+ virtual ITextureViewVk* GetDepthBufferDSV() override final { return m_pDepthBufferDSV; }
private:
- void CreateVulkanSwapChain();
- void InitBuffersAndViews();
+ void CreateVulkanSwapChain();
+ void InitBuffersAndViews();
VkResult AcquireNextImage(DeviceContextVkImpl* pDeviceCtxVk);
- void RecreateVulkanSwapchain(DeviceContextVkImpl* pImmediateCtxVk);
- void WaitForImageAcquiredFences();
+ void RecreateVulkanSwapchain(DeviceContextVkImpl* pImmediateCtxVk);
+ void WaitForImageAcquiredFences();
std::shared_ptr<const VulkanUtilities::VulkanInstance> m_VulkanInstance;
+
VkSurfaceKHR m_VkSurface = VK_NULL_HANDLE;
VkSwapchainKHR m_VkSwapChain = VK_NULL_HANDLE;
VkFormat m_VkColorFormat = VK_FORMAT_UNDEFINED;
@@ -92,14 +93,17 @@ private:
std::vector<VulkanUtilities::SemaphoreWrapper> m_ImageAcquiredSemaphores;
std::vector<VulkanUtilities::SemaphoreWrapper> m_DrawCompleteSemaphores;
std::vector<VulkanUtilities::FenceWrapper> m_ImageAcquiredFences;
- std::vector< RefCntAutoPtr<ITextureViewVk>, STDAllocatorRawMem<RefCntAutoPtr<ITextureViewVk>> > m_pBackBufferRTV;
- std::vector<bool, STDAllocatorRawMem<bool> > m_SwapChainImagesInitialized;
- std::vector<bool, STDAllocatorRawMem<bool> > m_ImageAcquiredFenceSubmitted;
+
+ std::vector<RefCntAutoPtr<ITextureViewVk>, STDAllocatorRawMem<RefCntAutoPtr<ITextureViewVk>>> m_pBackBufferRTV;
+
+ std::vector<bool, STDAllocatorRawMem<bool>> m_SwapChainImagesInitialized;
+ std::vector<bool, STDAllocatorRawMem<bool>> m_ImageAcquiredFenceSubmitted;
RefCntAutoPtr<ITextureViewVk> m_pDepthBufferDSV;
+
Uint32 m_SemaphoreIndex = 0;
uint32_t m_BackBufferIndex = 0;
bool m_IsMinimized = false;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h
index e6482d5c..e9f38b95 100644
--- a/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h
@@ -43,18 +43,18 @@ class TextureViewVkImpl final : public TextureViewBase<ITextureViewVk, RenderDev
public:
using TTextureViewBase = TextureViewBase<ITextureViewVk, RenderDeviceVkImpl>;
- TextureViewVkImpl( IReferenceCounters* pRefCounters,
- RenderDeviceVkImpl* pDevice,
- const TextureViewDesc& ViewDesc,
- class ITexture* pTexture,
- VulkanUtilities::ImageViewWrapper&& ImgView,
- bool bIsDefaultView);
+ TextureViewVkImpl(IReferenceCounters* pRefCounters,
+ RenderDeviceVkImpl* pDevice,
+ const TextureViewDesc& ViewDesc,
+ class ITexture* pTexture,
+ VulkanUtilities::ImageViewWrapper&& ImgView,
+ bool bIsDefaultView);
~TextureViewVkImpl();
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
/// Implementation of ITextureViewVk::GetVulkanImageView().
- VkImageView GetVulkanImageView()const override final{return m_ImageView;}
+ VkImageView GetVulkanImageView() const override final { return m_ImageView; }
bool HasMipLevelViews() const
{
@@ -64,16 +64,16 @@ public:
TextureViewVkImpl* GetMipLevelSRV(Uint32 MipLevel)
{
VERIFY_EXPR(m_MipLevelViews != nullptr && MipLevel < m_Desc.NumMipLevels);
- return m_MipLevelViews[MipLevel*2].get();
+ return m_MipLevelViews[MipLevel * 2].get();
}
TextureViewVkImpl* GetMipLevelUAV(Uint32 MipLevel)
{
VERIFY_EXPR(m_MipLevelViews != nullptr && MipLevel < m_Desc.NumMipLevels);
- return m_MipLevelViews[MipLevel*2 + 1].get();
+ return m_MipLevelViews[MipLevel * 2 + 1].get();
}
- using MipLevelViewAutoPtrType = std::unique_ptr<TextureViewVkImpl, STDDeleter<TextureViewVkImpl, FixedBlockMemoryAllocator> >;
+ using MipLevelViewAutoPtrType = std::unique_ptr<TextureViewVkImpl, STDDeleter<TextureViewVkImpl, FixedBlockMemoryAllocator>>;
void AssignMipLevelViews(MipLevelViewAutoPtrType* MipLevelViews)
{
@@ -82,10 +82,10 @@ public:
protected:
/// Vulkan image view descriptor handle
- VulkanUtilities::ImageViewWrapper m_ImageView;
+ VulkanUtilities::ImageViewWrapper m_ImageView;
/// Individual mip level views used for mipmap generation
- MipLevelViewAutoPtrType* m_MipLevelViews = nullptr;
+ MipLevelViewAutoPtrType* m_MipLevelViews = nullptr;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h
index e6515204..4a75bdc1 100644
--- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h
@@ -50,44 +50,44 @@ public:
// Creates a new Vk resource
TextureVkImpl(IReferenceCounters* pRefCounters,
FixedBlockMemoryAllocator& TexViewObjAllocator,
- RenderDeviceVkImpl* pDeviceVk,
- const TextureDesc& TexDesc,
+ RenderDeviceVkImpl* pDeviceVk,
+ const TextureDesc& TexDesc,
const TextureData* pInitData = nullptr);
-
+
// Attaches to an existing Vk resource
- TextureVkImpl(IReferenceCounters* pRefCounters,
- FixedBlockMemoryAllocator& TexViewObjAllocator,
- class RenderDeviceVkImpl* pDeviceVk,
- const TextureDesc& TexDesc,
- RESOURCE_STATE InitialState,
- VkImage VkImageHandle);
+ TextureVkImpl(IReferenceCounters* pRefCounters,
+ FixedBlockMemoryAllocator& TexViewObjAllocator,
+ class RenderDeviceVkImpl* pDeviceVk,
+ const TextureDesc& TexDesc,
+ RESOURCE_STATE InitialState,
+ VkImage VkImageHandle);
~TextureVkImpl();
- virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface)override final;
+ virtual void QueryInterface(const INTERFACE_ID& IID, IObject** ppInterface) override final;
/// Implementation of ITextureVk::GetVkImage().
- virtual VkImage GetVkImage()const override final{ return m_VulkanImage; }
+ virtual VkImage GetVkImage() const override final { return m_VulkanImage; }
/// Implementation of ITexture::GetNativeHandle() in Vulkan backend.
- virtual void* GetNativeHandle()override final
+ virtual void* GetNativeHandle() override final
{
auto vkImage = GetVkImage();
return vkImage;
}
/// Implementation of ITextureVk::SetLayout().
- void SetLayout(VkImageLayout Layout)override final;
+ void SetLayout(VkImageLayout Layout) override final;
/// Implementation of ITextureVk::GetLayout().
- VkImageLayout GetLayout()const override final;
+ VkImageLayout GetLayout() const override final;
- VkBuffer GetVkStagingBuffer()const
+ VkBuffer GetVkStagingBuffer() const
{
return m_StagingBuffer;
}
- uint8_t* GetStagingDataCPUAddress()const
+ uint8_t* GetStagingDataCPUAddress() const
{
auto* StagingDataCPUAddress = reinterpret_cast<uint8_t*>(m_MemoryAllocation.Page->GetCPUMemory());
VERIFY_EXPR(StagingDataCPUAddress != nullptr);
@@ -98,12 +98,12 @@ public:
void InvalidateStagingRange(VkDeviceSize Offset, VkDeviceSize Size);
protected:
- void CreateViewInternal( const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView )override;
+ void CreateViewInternal(const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView) override;
//void PrepareVkInitData(const TextureData &InitData, Uint32 NumSubresources, std::vector<Vk_SUBRESOURCE_DATA> &VkInitData);
-
- bool CheckCSBasedMipGenerationSupport(VkFormat vkFmt)const;
- VulkanUtilities::ImageViewWrapper CreateImageView(TextureViewDesc &ViewDesc);
+ bool CheckCSBasedMipGenerationSupport(VkFormat vkFmt) const;
+
+ VulkanUtilities::ImageViewWrapper CreateImageView(TextureViewDesc& ViewDesc);
VulkanUtilities::ImageWrapper m_VulkanImage;
VulkanUtilities::BufferWrapper m_StagingBuffer;
@@ -112,4 +112,4 @@ protected:
bool m_bCSBasedMipGenerationSupported = false;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h b/Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h
index d7140786..4008da54 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h
@@ -45,8 +45,9 @@ class VulkanDynamicMemoryManager;
// sizeof(VulkanDynamicAllocation) must be at least 16 to avoid false cache line sharing problems
struct VulkanDynamicAllocation
{
- VulkanDynamicAllocation()noexcept{}
+ VulkanDynamicAllocation() noexcept {}
+ // clang-format off
VulkanDynamicAllocation(VulkanDynamicMemoryManager& _DynamicMemMgr, size_t _AlignedOffset, size_t _Size)noexcept :
pDynamicMemMgr{&_DynamicMemMgr},
AlignedOffset {_AlignedOffset },
@@ -71,12 +72,13 @@ struct VulkanDynamicAllocation
rhs.dvpFrameNumber = 0;
#endif
}
+ // clang-format on
- VulkanDynamicAllocation& operator = (VulkanDynamicAllocation&& rhs)noexcept // Must be noexcept on MSVC, so can't use = default
+ VulkanDynamicAllocation& operator=(VulkanDynamicAllocation&& rhs) noexcept // Must be noexcept on MSVC, so can't use = default
{
- pDynamicMemMgr = rhs.pDynamicMemMgr;
- AlignedOffset = rhs.AlignedOffset;
- Size = rhs.Size;
+ pDynamicMemMgr = rhs.pDynamicMemMgr;
+ AlignedOffset = rhs.AlignedOffset;
+ Size = rhs.Size;
rhs.pDynamicMemMgr = nullptr;
rhs.AlignedOffset = 0;
rhs.Size = 0;
@@ -88,10 +90,10 @@ struct VulkanDynamicAllocation
}
VulkanDynamicMemoryManager* pDynamicMemMgr = nullptr;
- size_t AlignedOffset = 0; // Offset from the start of the buffer
- size_t Size = 0; // Reserved size of this allocation
+ size_t AlignedOffset = 0; // Offset from the start of the buffer
+ size_t Size = 0; // Reserved size of this allocation
#ifdef DEVELOPMENT
- Int64 dvpFrameNumber = 0;
+ Int64 dvpFrameNumber = 0;
#endif
};
@@ -111,16 +113,17 @@ struct VulkanDynamicAllocation
class VulkanDynamicMemoryManager : public DynamicHeap::MasterBlockListBasedManager
{
public:
- using TBase = DynamicHeap::MasterBlockListBasedManager;
+ using TBase = DynamicHeap::MasterBlockListBasedManager;
using OffsetType = TBase::OffsetType;
using MasterBlock = TBase::MasterBlock;
- VulkanDynamicMemoryManager(IMemoryAllocator& Allocator,
- class RenderDeviceVkImpl& DeviceVk,
+ VulkanDynamicMemoryManager(IMemoryAllocator& Allocator,
+ class RenderDeviceVkImpl& DeviceVk,
Uint32 Size,
Uint64 CommandQueueMask);
~VulkanDynamicMemoryManager();
+ // clang-format off
VulkanDynamicMemoryManager (const VulkanDynamicMemoryManager&) = delete;
VulkanDynamicMemoryManager ( VulkanDynamicMemoryManager&&) = delete;
VulkanDynamicMemoryManager& operator= (const VulkanDynamicMemoryManager&) = delete;
@@ -128,33 +131,33 @@ public:
VkBuffer GetVkBuffer() const{return m_VkBuffer;}
Uint8* GetCPUAddress()const{return m_CPUAddress;}
+ // clang-format on
void Destroy();
static constexpr const Uint32 MasterBlockAlignment = 1024;
- MasterBlock AllocateMasterBlock(OffsetType SizeInBytes, OffsetType Alignment);
+ MasterBlock AllocateMasterBlock(OffsetType SizeInBytes, OffsetType Alignment);
private:
-
RenderDeviceVkImpl& m_DeviceVk;
VulkanUtilities::BufferWrapper m_VkBuffer;
VulkanUtilities::DeviceMemoryWrapper m_BufferMemory;
Uint8* m_CPUAddress;
const VkDeviceSize m_DefaultAlignment;
const Uint64 m_CommandQueueMask;
- OffsetType m_TotalPeakSize = 0;
+ OffsetType m_TotalPeakSize = 0;
};
-// Dynamic heap is used by a device context to allocate dynamic space when
+// Dynamic heap is used by a device context to allocate dynamic space when
// mapping a buffer or a texture. This is very similar to upload heap,
// however dynamic heap uses special persistently mapped buffer while
// upload heap uses global memory manager.
-//
+//
// The heap allocates master blocks from the global dynamic memory manager.
// The pages are released and returned to the manager at the end of every frame.
-//
+//
// _______________________________________________________________________________________________________________________________
// | |
// | VulkanDynamicHeap |
@@ -165,7 +168,7 @@ private:
// | A |
// | | |
// |Allocate() AllocateMasterBlock()| |FinishFrame()
-// | ______|___________________V____
+// | ______|___________________V____
// V | |
// | VulkanDynamicMemoryManager |
// | |
@@ -175,21 +178,23 @@ private:
class VulkanDynamicHeap
{
public:
+ // clang-format off
VulkanDynamicHeap(VulkanDynamicMemoryManager& DynamicMemMgr, std::string HeapName, Uint32 PageSize) :
- m_GlobalDynamicMemMgr(DynamicMemMgr),
- m_HeapName(std::move(HeapName)),
- m_MasterBlockSize(PageSize)
+ m_GlobalDynamicMemMgr{DynamicMemMgr},
+ m_HeapName {std::move(HeapName)},
+ m_MasterBlockSize {PageSize}
{}
VulkanDynamicHeap (const VulkanDynamicHeap&) = delete;
VulkanDynamicHeap (VulkanDynamicHeap&&) = delete;
VulkanDynamicHeap& operator= (const VulkanDynamicHeap&) = delete;
VulkanDynamicHeap& operator= (VulkanDynamicHeap&&) = delete;
-
+ // clang-format on
+
~VulkanDynamicHeap();
VulkanDynamicAllocation Allocate(Uint32 SizeInBytes, Uint32 Alignment);
-
+
// Releases all master blocks that are later returned to the global dynamic memory manager.
// CmdQueueMask indicates which command queues the allocations from this heap were used
// with during the last frame.
@@ -199,19 +204,20 @@ public:
using OffsetType = VulkanDynamicMemoryManager::OffsetType;
using MasterBlock = VulkanDynamicMemoryManager::MasterBlock;
+
static constexpr OffsetType InvalidOffset = static_cast<OffsetType>(-1);
-
- size_t GetAllocatedMasterBlockCount()const {return m_MasterBlocks.size();}
+
+ size_t GetAllocatedMasterBlockCount() const { return m_MasterBlocks.size(); }
private:
VulkanDynamicMemoryManager& m_GlobalDynamicMemMgr;
- const std::string m_HeapName;
+ const std::string m_HeapName;
std::vector<MasterBlock> m_MasterBlocks;
- OffsetType m_CurrOffset = InvalidOffset;
+ OffsetType m_CurrOffset = InvalidOffset;
const Uint32 m_MasterBlockSize;
- Uint32 m_AvailableSize = 0;
+ Uint32 m_AvailableSize = 0;
Uint32 m_CurrAlignedSize = 0;
Uint32 m_CurrUsedSize = 0;
@@ -221,4 +227,4 @@ private:
Uint32 m_PeakAllocatedSize = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanErrors.h b/Graphics/GraphicsEngineVulkan/include/VulkanErrors.h
index b086a08c..fd018430 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanErrors.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanErrors.h
@@ -27,17 +27,17 @@
#include "DebugUtilities.h"
#include "VulkanUtilities/VulkanDebug.h"
-#define CHECK_VK_ERROR(err, ...)\
-{ \
- if( err < 0 ) \
- { \
- Diligent::LogError<false>(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__, "\nVK Error: ", VulkanUtilities::VkResultToString(err)); \
- UNEXPECTED("Error"); \
- } \
-}
+#define CHECK_VK_ERROR(err, ...) \
+ { \
+ if (err < 0) \
+ { \
+ Diligent::LogError<false>(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__, "\nVK Error: ", VulkanUtilities::VkResultToString(err)); \
+ UNEXPECTED("Error"); \
+ } \
+ }
-#define CHECK_VK_ERROR_AND_THROW(err, ...)\
-{ \
- if( err < 0 ) \
- Diligent::LogError<true>(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__, "\nVK Error Code: ", VulkanUtilities::VkResultToString(err)); \
-}
+#define CHECK_VK_ERROR_AND_THROW(err, ...) \
+ { \
+ if (err < 0) \
+ Diligent::LogError<true>(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__, "\nVK Error Code: ", VulkanUtilities::VkResultToString(err)); \
+ }
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.h b/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.h
index 0f6c966a..d44b6333 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.h
@@ -32,31 +32,32 @@
namespace Diligent
{
-VkFormat TexFormatToVkFormat(TEXTURE_FORMAT TexFmt);
+VkFormat TexFormatToVkFormat(TEXTURE_FORMAT TexFmt);
TEXTURE_FORMAT VkFormatToTexFormat(VkFormat VkFmt);
VkFormat TypeToVkFormat(VALUE_TYPE ValType, Uint32 NumComponents, Bool bIsNormalized);
-VkPipelineRasterizationStateCreateInfo RasterizerStateDesc_To_VkRasterizationStateCI(const RasterizerStateDesc &RasterizerDesc);
-VkPipelineDepthStencilStateCreateInfo DepthStencilStateDesc_To_VkDepthStencilStateCI(const DepthStencilStateDesc &DepthStencilDesc);
-void BlendStateDesc_To_VkBlendStateCI(const BlendStateDesc& BSDesc,
+VkPipelineRasterizationStateCreateInfo RasterizerStateDesc_To_VkRasterizationStateCI(const RasterizerStateDesc& RasterizerDesc);
+VkPipelineDepthStencilStateCreateInfo DepthStencilStateDesc_To_VkDepthStencilStateCI(const DepthStencilStateDesc& DepthStencilDesc);
+
+void BlendStateDesc_To_VkBlendStateCI(const BlendStateDesc& BSDesc,
VkPipelineColorBlendStateCreateInfo& ColorBlendStateCI,
std::vector<VkPipelineColorBlendAttachmentState>& ColorBlendAttachments);
-void InputLayoutDesc_To_VkVertexInputStateCI(const InputLayoutDesc& LayoutDesc,
+void InputLayoutDesc_To_VkVertexInputStateCI(const InputLayoutDesc& LayoutDesc,
VkPipelineVertexInputStateCreateInfo& VertexInputStateCI,
std::array<VkVertexInputBindingDescription, iMaxLayoutElements>& BindingDescriptions,
std::array<VkVertexInputAttributeDescription, iMaxLayoutElements>& AttributeDescription);
-void PrimitiveTopology_To_VkPrimitiveTopologyAndPatchCPCount(PRIMITIVE_TOPOLOGY PrimTopology,
- VkPrimitiveTopology& VkPrimTopology,
+void PrimitiveTopology_To_VkPrimitiveTopologyAndPatchCPCount(PRIMITIVE_TOPOLOGY PrimTopology,
+ VkPrimitiveTopology& VkPrimTopology,
uint32_t& PatchControlPoints);
-VkCompareOp ComparisonFuncToVkCompareOp(COMPARISON_FUNCTION CmpFunc);
-VkFilter FilterTypeToVkFilter(FILTER_TYPE FilterType);
-VkSamplerMipmapMode FilterTypeToVkMipmapMode(FILTER_TYPE FilterType);
+VkCompareOp ComparisonFuncToVkCompareOp(COMPARISON_FUNCTION CmpFunc);
+VkFilter FilterTypeToVkFilter(FILTER_TYPE FilterType);
+VkSamplerMipmapMode FilterTypeToVkMipmapMode(FILTER_TYPE FilterType);
VkSamplerAddressMode AddressModeToVkAddressMode(TEXTURE_ADDRESS_MODE AddressMode);
-VkBorderColor BorderColorToVkBorderColor(const Float32 BorderColor[]);
+VkBorderColor BorderColorToVkBorderColor(const Float32 BorderColor[]);
VkAccessFlags ResourceStateFlagsToVkAccessFlags(RESOURCE_STATE StateFlags);
VkImageLayout ResourceStateToVkImageLayout(RESOURCE_STATE StateFlag);
@@ -64,4 +65,4 @@ VkImageLayout ResourceStateToVkImageLayout(RESOURCE_STATE StateFlag);
RESOURCE_STATE VkAccessFlagsToResourceStates(VkAccessFlags AccessFlags);
RESOURCE_STATE VkImageLayoutToResourceState(VkImageLayout Layout);
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h b/Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h
index 303ec70d..f544dd1f 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUploadHeap.h
@@ -30,12 +30,12 @@
namespace Diligent
{
-// Upload heap is used by a device context to update texture and buffer regions through
+// Upload heap is used by a device context to update texture and buffer regions through
// UpdateBufferRegion() and UpdateTextureRegion().
-//
+//
// The heap allocates pages from the global memory manager.
// The pages are released and returned to the manager at the end of every frame.
-//
+//
// _______________________________________________________________________________________________________________________________
// | |
// | VulkanUploadHeap |
@@ -46,7 +46,7 @@ namespace Diligent
// | A |
// | | |
// |Allocate() CreateNewPage()| |ReleaseAllocatedPages()
-// | ______|___________________V____
+// | ______|___________________V____
// V | |
// VulkanUploadAllocation | Global Memory Manager |
// | (VulkanMemoryManager) |
@@ -58,6 +58,7 @@ class RenderDeviceVkImpl;
struct VulkanUploadAllocation
{
VulkanUploadAllocation() noexcept {}
+ // clang-format off
VulkanUploadAllocation(void* _CPUAddress,
VkDeviceSize _Size,
VkDeviceSize _AlignedOffset,
@@ -71,6 +72,7 @@ struct VulkanUploadAllocation
VulkanUploadAllocation& operator = (const VulkanUploadAllocation&) = delete;
VulkanUploadAllocation ( VulkanUploadAllocation&&) = default;
VulkanUploadAllocation& operator = ( VulkanUploadAllocation&&) = default;
+ // clang-format on
VkBuffer vkBuffer = VK_NULL_HANDLE; // Vulkan buffer associated with this memory.
void* CPUAddress = nullptr;
@@ -84,22 +86,24 @@ public:
VulkanUploadHeap(RenderDeviceVkImpl& RenderDevice,
std::string HeapName,
VkDeviceSize PageSize);
-
+
+ // clang-format off
VulkanUploadHeap (const VulkanUploadHeap&) = delete;
VulkanUploadHeap ( VulkanUploadHeap&&) = delete;
VulkanUploadHeap& operator= (const VulkanUploadHeap&) = delete;
VulkanUploadHeap& operator= ( VulkanUploadHeap&&) = delete;
+ // clang-format on
~VulkanUploadHeap();
VulkanUploadAllocation Allocate(size_t SizeInBytes, size_t Alignment);
-
+
// Releases all allocated pages that are later returned to the global memory manager by the release queues.
- // As global memory manager is hosted by the render device, the upload heap can be destroyed before the
+ // As global memory manager is hosted by the render device, the upload heap can be destroyed before the
// pages are actually returned to the manager.
void ReleaseAllocatedPages(Uint64 CmdQueueMask);
- size_t GetStalePagesCount()const
+ size_t GetStalePagesCount() const
{
return m_Pages.size();
}
@@ -111,6 +115,7 @@ private:
struct UploadPageInfo
{
+ // clang-format off
UploadPageInfo(VulkanUtilities::VulkanMemoryAllocation&& _MemAllocation,
VulkanUtilities::BufferWrapper&& _Buffer,
Uint8* _CPUAddress) :
@@ -119,6 +124,8 @@ private:
CPUAddress {_CPUAddress }
{
}
+ // clang-format on
+
VulkanUtilities::VulkanMemoryAllocation MemAllocation;
VulkanUtilities::BufferWrapper Buffer;
Uint8* const CPUAddress = nullptr;
@@ -131,6 +138,7 @@ private:
Uint8* CurrCPUAddress = nullptr;
size_t CurrOffset = 0;
size_t AvailableSize = 0;
+
void Reset(UploadPageInfo& NewPage, size_t PageSize)
{
vkBuffer = NewPage.Buffer;
@@ -138,20 +146,21 @@ private:
CurrOffset = 0;
AvailableSize = PageSize;
}
+
void Advance(size_t SizeInBytes)
{
- CurrCPUAddress+= SizeInBytes;
- CurrOffset += SizeInBytes;
+ CurrCPUAddress += SizeInBytes;
+ CurrOffset += SizeInBytes;
AvailableSize -= SizeInBytes;
}
- }m_CurrPage;
+ } m_CurrPage;
- size_t m_CurrFrameSize = 0;
- size_t m_PeakFrameSize = 0;
- size_t m_CurrAllocatedSize = 0;
- size_t m_PeakAllocatedSize = 0;
+ size_t m_CurrFrameSize = 0;
+ size_t m_PeakFrameSize = 0;
+ size_t m_CurrAllocatedSize = 0;
+ size_t m_PeakAllocatedSize = 0;
- UploadPageInfo CreateNewPage(VkDeviceSize SizeInBytes)const;
+ UploadPageInfo CreateNewPage(VkDeviceSize SizeInBytes) const;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h
index 517b7e50..9a59e91a 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h
@@ -28,432 +28,442 @@
namespace VulkanUtilities
{
- class VulkanCommandBuffer
- {
- public:
- VulkanCommandBuffer(VkPipelineStageFlags EnabledGraphicsShaderStages)noexcept :
- m_EnabledGraphicsShaderStages{EnabledGraphicsShaderStages}
- {}
-
- VulkanCommandBuffer (const VulkanCommandBuffer&) = delete;
- VulkanCommandBuffer ( VulkanCommandBuffer&&) = delete;
- VulkanCommandBuffer& operator = (const VulkanCommandBuffer&) = delete;
- VulkanCommandBuffer& operator = ( VulkanCommandBuffer&&) = delete;
- __forceinline void ClearColorImage(VkImage Image, const VkClearColorValue& Color, const VkImageSubresourceRange& Subresource)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdClearColorImage() must be called outside of render pass (17.1)");
- VERIFY(Subresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT, "The aspectMask of all image subresource ranges must only include VK_IMAGE_ASPECT_COLOR_BIT (17.1)");
-
- vkCmdClearColorImage(
- m_VkCmdBuffer,
- Image,
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
- &Color,
- 1,
- &Subresource
- );
- }
+class VulkanCommandBuffer
+{
+public:
+ VulkanCommandBuffer(VkPipelineStageFlags EnabledGraphicsShaderStages) noexcept :
+ m_EnabledGraphicsShaderStages{EnabledGraphicsShaderStages}
+ {}
+
+ // clang-format off
+ VulkanCommandBuffer (const VulkanCommandBuffer&) = delete;
+ VulkanCommandBuffer ( VulkanCommandBuffer&&) = delete;
+ VulkanCommandBuffer& operator = (const VulkanCommandBuffer&) = delete;
+ VulkanCommandBuffer& operator = ( VulkanCommandBuffer&&) = delete;
+ // clang-format on
+
+ __forceinline void ClearColorImage(VkImage Image,
+ const VkClearColorValue& Color,
+ const VkImageSubresourceRange& Subresource)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdClearColorImage() must be called outside of render pass (17.1)");
+ VERIFY(Subresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT, "The aspectMask of all image subresource ranges must only include VK_IMAGE_ASPECT_COLOR_BIT (17.1)");
+
+ vkCmdClearColorImage(
+ m_VkCmdBuffer,
+ Image,
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
+ &Color,
+ 1,
+ &Subresource);
+ }
+
+ __forceinline void ClearDepthStencilImage(VkImage Image,
+ const VkClearDepthStencilValue& DepthStencil,
+ const VkImageSubresourceRange& Subresource)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdClearDepthStencilImage() must be called outside of render pass (17.1)");
+ // clang-format off
+ VERIFY((Subresource.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != 0 &&
+ (Subresource.aspectMask & ~(VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) == 0,
+ "The aspectMask of all image subresource ranges must only include VK_IMAGE_ASPECT_DEPTH_BIT or VK_IMAGE_ASPECT_STENCIL_BIT(17.1)");
+ // clang-format on
+
+ vkCmdClearDepthStencilImage(
+ m_VkCmdBuffer,
+ Image,
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
+ &DepthStencil,
+ 1,
+ &Subresource);
+ }
+
+ __forceinline void ClearAttachment(const VkClearAttachment& Attachment, const VkClearRect& ClearRect)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdClearAttachments() must be called inside render pass (17.2)");
+
+ vkCmdClearAttachments(
+ m_VkCmdBuffer,
+ 1,
+ &Attachment,
+ 1,
+ &ClearRect // The rectangular region specified by each element of pRects must be
+ // contained within the render area of the current render pass instance
+ );
+ }
+
+ __forceinline void Draw(uint32_t VertexCount, uint32_t InstanceCount, uint32_t FirstVertex, uint32_t FirstInstance)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDraw() must be called inside render pass (19.3)");
+ VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
- __forceinline void ClearDepthStencilImage(VkImage Image, const VkClearDepthStencilValue& DepthStencil, const VkImageSubresourceRange& Subresource)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdClearDepthStencilImage() must be called outside of render pass (17.1)");
- VERIFY( (Subresource.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT|VK_IMAGE_ASPECT_STENCIL_BIT)) != 0 &&
- (Subresource.aspectMask & ~(VK_IMAGE_ASPECT_DEPTH_BIT|VK_IMAGE_ASPECT_STENCIL_BIT)) == 0,
- "The aspectMask of all image subresource ranges must only include VK_IMAGE_ASPECT_DEPTH_BIT or VK_IMAGE_ASPECT_STENCIL_BIT(17.1)");
-
- vkCmdClearDepthStencilImage(
- m_VkCmdBuffer,
- Image,
- VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
- &DepthStencil,
- 1,
- &Subresource
- );
- }
+ vkCmdDraw(m_VkCmdBuffer, VertexCount, InstanceCount, FirstVertex, FirstInstance);
+ }
- __forceinline void ClearAttachment(const VkClearAttachment& Attachment, const VkClearRect& ClearRect)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdClearAttachments() must be called inside render pass (17.2)");
-
- vkCmdClearAttachments(
- m_VkCmdBuffer,
- 1,
- &Attachment,
- 1,
- &ClearRect // The rectangular region specified by each element of pRects must be
- // contained within the render area of the current render pass instance
- );
- }
+ __forceinline void DrawIndexed(uint32_t IndexCount, uint32_t InstanceCount, uint32_t FirstIndex, int32_t VertexOffset, uint32_t FirstInstance)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawIndexed() must be called inside render pass (19.3)");
+ VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
+ VERIFY(m_State.IndexBuffer != VK_NULL_HANDLE, "No index buffer bound");
- __forceinline void Draw(uint32_t VertexCount, uint32_t InstanceCount, uint32_t FirstVertex, uint32_t FirstInstance)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDraw() must be called inside render pass (19.3)");
- VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
+ vkCmdDrawIndexed(m_VkCmdBuffer, IndexCount, InstanceCount, FirstIndex, VertexOffset, FirstInstance);
+ }
- vkCmdDraw(m_VkCmdBuffer, VertexCount, InstanceCount, FirstVertex, FirstInstance);
- }
+ __forceinline void DrawIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawIndirect() must be called inside render pass (19.3)");
+ VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
- __forceinline void DrawIndexed(uint32_t IndexCount,uint32_t InstanceCount, uint32_t FirstIndex, int32_t VertexOffset, uint32_t FirstInstance)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawIndexed() must be called inside render pass (19.3)");
- VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
- VERIFY(m_State.IndexBuffer != VK_NULL_HANDLE, "No index buffer bound");
+ vkCmdDrawIndirect(m_VkCmdBuffer, Buffer, Offset, DrawCount, Stride);
+ }
- vkCmdDrawIndexed(m_VkCmdBuffer, IndexCount, InstanceCount, FirstIndex, VertexOffset, FirstInstance);
- }
+ __forceinline void DrawIndexedIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawIndirect() must be called inside render pass (19.3)");
+ VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
+ VERIFY(m_State.IndexBuffer != VK_NULL_HANDLE, "No index buffer bound");
- __forceinline void DrawIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawIndirect() must be called inside render pass (19.3)");
- VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
+ vkCmdDrawIndexedIndirect(m_VkCmdBuffer, Buffer, Offset, DrawCount, Stride);
+ }
- vkCmdDrawIndirect(m_VkCmdBuffer, Buffer, Offset, DrawCount, Stride);
- }
+ __forceinline void Dispatch(uint32_t GroupCountX, uint32_t GroupCountY, uint32_t GroupCountZ)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdDispatch() must be called outside of render pass (27)");
+ VERIFY(m_State.ComputePipeline != VK_NULL_HANDLE, "No compute pipeline bound");
- __forceinline void DrawIndexedIndirect(VkBuffer Buffer, VkDeviceSize Offset, uint32_t DrawCount, uint32_t Stride)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "vkCmdDrawIndirect() must be called inside render pass (19.3)");
- VERIFY(m_State.GraphicsPipeline != VK_NULL_HANDLE, "No graphics pipeline bound");
- VERIFY(m_State.IndexBuffer != VK_NULL_HANDLE, "No index buffer bound");
+ vkCmdDispatch(m_VkCmdBuffer, GroupCountX, GroupCountY, GroupCountZ);
+ }
- vkCmdDrawIndexedIndirect(m_VkCmdBuffer, Buffer, Offset, DrawCount, Stride);
- }
+ __forceinline void DispatchIndirect(VkBuffer Buffer, VkDeviceSize Offset)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdDispatchIndirect() must be called outside of render pass (27)");
+ VERIFY(m_State.ComputePipeline != VK_NULL_HANDLE, "No compute pipeline bound");
- __forceinline void Dispatch(uint32_t GroupCountX, uint32_t GroupCountY, uint32_t GroupCountZ)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdDispatch() must be called outside of render pass (27)");
- VERIFY(m_State.ComputePipeline != VK_NULL_HANDLE, "No compute pipeline bound");
+ vkCmdDispatchIndirect(m_VkCmdBuffer, Buffer, Offset);
+ }
- vkCmdDispatch(m_VkCmdBuffer, GroupCountX, GroupCountY, GroupCountZ);
+ __forceinline void BeginRenderPass(VkRenderPass RenderPass, VkFramebuffer Framebuffer, uint32_t FramebufferWidth, uint32_t FramebufferHeight)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "Current pass has not been ended");
+
+ if (m_State.RenderPass != RenderPass || m_State.Framebuffer != Framebuffer)
+ {
+ VkRenderPassBeginInfo BeginInfo;
+ BeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ BeginInfo.pNext = nullptr;
+ BeginInfo.renderPass = RenderPass;
+ BeginInfo.framebuffer = Framebuffer;
+ // The render area MUST be contained within the framebuffer dimensions (7.4)
+ BeginInfo.renderArea = {{0, 0}, {FramebufferWidth, FramebufferHeight}};
+ BeginInfo.clearValueCount = 0;
+ BeginInfo.pClearValues = nullptr; // an array of VkClearValue structures that contains clear values for
+ // each attachment, if the attachment uses a loadOp value of VK_ATTACHMENT_LOAD_OP_CLEAR
+ // or if the attachment has a depth/stencil format and uses a stencilLoadOp value of
+ // VK_ATTACHMENT_LOAD_OP_CLEAR. The array is indexed by attachment number. Only elements
+ // corresponding to cleared attachments are used. Other elements of pClearValues are
+ // ignored (7.4)
+
+ vkCmdBeginRenderPass(m_VkCmdBuffer, &BeginInfo,
+ VK_SUBPASS_CONTENTS_INLINE // the contents of the subpass will be recorded inline in the
+ // primary command buffer, and secondary command buffers must not
+ // be executed within the subpass
+ );
+ m_State.RenderPass = RenderPass;
+ m_State.Framebuffer = Framebuffer;
+ m_State.FramebufferWidth = FramebufferWidth;
+ m_State.FramebufferHeight = FramebufferHeight;
}
+ }
- __forceinline void DispatchIndirect(VkBuffer Buffer, VkDeviceSize Offset)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "vkCmdDispatchIndirect() must be called outside of render pass (27)");
- VERIFY(m_State.ComputePipeline != VK_NULL_HANDLE, "No compute pipeline bound");
+ __forceinline void EndRenderPass()
+ {
+ VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "Render pass has not been started");
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ vkCmdEndRenderPass(m_VkCmdBuffer);
+ m_State.RenderPass = VK_NULL_HANDLE;
+ m_State.Framebuffer = VK_NULL_HANDLE;
+ m_State.FramebufferWidth = 0;
+ m_State.FramebufferHeight = 0;
+ }
+
+ __forceinline void EndCommandBuffer()
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ vkEndCommandBuffer(m_VkCmdBuffer);
+ }
- vkCmdDispatchIndirect(m_VkCmdBuffer, Buffer, Offset);
- }
+ __forceinline void Reset()
+ {
+ m_VkCmdBuffer = VK_NULL_HANDLE;
+ m_State = StateCache{};
+ }
- __forceinline void BeginRenderPass(VkRenderPass RenderPass, VkFramebuffer Framebuffer, uint32_t FramebufferWidth, uint32_t FramebufferHeight)
+ __forceinline void BindComputePipeline(VkPipeline ComputePipeline)
+ {
+ // 9.8
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.ComputePipeline != ComputePipeline)
{
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- VERIFY(m_State.RenderPass == VK_NULL_HANDLE, "Current pass has not been ended");
-
- if (m_State.RenderPass != RenderPass || m_State.Framebuffer != Framebuffer)
- {
- VkRenderPassBeginInfo BeginInfo;
- BeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- BeginInfo.pNext = nullptr;
- BeginInfo.renderPass = RenderPass;
- BeginInfo.framebuffer = Framebuffer;
- // The render area MUST be contained within the framebuffer dimensions (7.4)
- BeginInfo.renderArea = {{0,0}, { FramebufferWidth, FramebufferHeight }};
- BeginInfo.clearValueCount = 0;
- BeginInfo.pClearValues = nullptr; // an array of VkClearValue structures that contains clear values for
- // each attachment, if the attachment uses a loadOp value of VK_ATTACHMENT_LOAD_OP_CLEAR
- // or if the attachment has a depth/stencil format and uses a stencilLoadOp value of
- // VK_ATTACHMENT_LOAD_OP_CLEAR. The array is indexed by attachment number. Only elements
- // corresponding to cleared attachments are used. Other elements of pClearValues are
- // ignored (7.4)
-
- vkCmdBeginRenderPass(m_VkCmdBuffer, &BeginInfo,
- VK_SUBPASS_CONTENTS_INLINE // the contents of the subpass will be recorded inline in the
- // primary command buffer, and secondary command buffers must not
- // be executed within the subpass
- );
- m_State.RenderPass = RenderPass;
- m_State.Framebuffer = Framebuffer;
- m_State.FramebufferWidth = FramebufferWidth;
- m_State.FramebufferHeight = FramebufferHeight;
- }
+ vkCmdBindPipeline(m_VkCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, ComputePipeline);
+ m_State.ComputePipeline = ComputePipeline;
}
+ }
- __forceinline void EndRenderPass()
+ __forceinline void BindGraphicsPipeline(VkPipeline GraphicsPipeline)
+ {
+ // 9.8
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.GraphicsPipeline != GraphicsPipeline)
{
- VERIFY(m_State.RenderPass != VK_NULL_HANDLE, "Render pass has not been started");
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- vkCmdEndRenderPass(m_VkCmdBuffer);
- m_State.RenderPass = VK_NULL_HANDLE;
- m_State.Framebuffer = VK_NULL_HANDLE;
- m_State.FramebufferWidth = 0;
- m_State.FramebufferHeight = 0;
+ vkCmdBindPipeline(m_VkCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, GraphicsPipeline);
+ m_State.GraphicsPipeline = GraphicsPipeline;
}
+ }
- __forceinline void EndCommandBuffer()
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- vkEndCommandBuffer(m_VkCmdBuffer);
- }
+ __forceinline void SetViewports(uint32_t FirstViewport, uint32_t ViewportCount, const VkViewport* pViewports)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ vkCmdSetViewport(m_VkCmdBuffer, FirstViewport, ViewportCount, pViewports);
+ }
- __forceinline void Reset()
- {
- m_VkCmdBuffer = VK_NULL_HANDLE;
- m_State = StateCache{};
- }
+ __forceinline void SetScissorRects(uint32_t FirstScissor, uint32_t ScissorCount, const VkRect2D* pScissors)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ vkCmdSetScissor(m_VkCmdBuffer, FirstScissor, ScissorCount, pScissors);
+ }
- __forceinline void BindComputePipeline(VkPipeline ComputePipeline)
- {
- // 9.8
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.ComputePipeline != ComputePipeline)
- {
- vkCmdBindPipeline(m_VkCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, ComputePipeline);
- m_State.ComputePipeline = ComputePipeline;
- }
- }
+ __forceinline void SetStencilReference(uint32_t Reference)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ vkCmdSetStencilReference(m_VkCmdBuffer, VK_STENCIL_FRONT_AND_BACK, Reference);
+ }
- __forceinline void BindGraphicsPipeline(VkPipeline GraphicsPipeline)
- {
- // 9.8
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.GraphicsPipeline != GraphicsPipeline)
- {
- vkCmdBindPipeline(m_VkCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, GraphicsPipeline);
- m_State.GraphicsPipeline = GraphicsPipeline;
- }
- }
+ __forceinline void SetBlendConstants(const float BlendConstants[4])
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ vkCmdSetBlendConstants(m_VkCmdBuffer, BlendConstants);
+ }
- __forceinline void SetViewports(uint32_t FirstViewport, uint32_t ViewportCount, const VkViewport* pViewports)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- vkCmdSetViewport(m_VkCmdBuffer, FirstViewport, ViewportCount, pViewports);
+ __forceinline void BindIndexBuffer(VkBuffer Buffer, VkDeviceSize Offset, VkIndexType IndexType)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ // clang-format off
+ if (m_State.IndexBuffer != Buffer ||
+ m_State.IndexBufferOffset != Offset ||
+ m_State.IndexType != IndexType)
+ {
+ // clang-format on
+ vkCmdBindIndexBuffer(m_VkCmdBuffer, Buffer, Offset, IndexType);
+ m_State.IndexBuffer = Buffer;
+ m_State.IndexBufferOffset = Offset;
+ m_State.IndexType = IndexType;
}
+ }
- __forceinline void SetScissorRects(uint32_t FirstScissor, uint32_t ScissorCount, const VkRect2D* pScissors)
+ __forceinline void BindVertexBuffers(uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ vkCmdBindVertexBuffers(m_VkCmdBuffer, firstBinding, bindingCount, pBuffers, pOffsets);
+ }
+
+ static void TransitionImageLayout(VkCommandBuffer CmdBuffer,
+ VkImage Image,
+ VkImageLayout OldLayout,
+ VkImageLayout NewLayout,
+ const VkImageSubresourceRange& SubresRange,
+ VkPipelineStageFlags EnabledGraphicsShaderStages,
+ VkPipelineStageFlags SrcStages = 0,
+ VkPipelineStageFlags DestStages = 0);
+
+ __forceinline void TransitionImageLayout(VkImage Image,
+ VkImageLayout OldLayout,
+ VkImageLayout NewLayout,
+ const VkImageSubresourceRange& SubresRange,
+ VkPipelineStageFlags SrcStages = 0,
+ VkPipelineStageFlags DestStages = 0)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- vkCmdSetScissor(m_VkCmdBuffer, FirstScissor, ScissorCount, pScissors);
+ // Image layout transitions within a render pass execute
+ // dependencies between attachments
+ EndRenderPass();
}
-
- __forceinline void SetStencilReference(uint32_t Reference)
+ TransitionImageLayout(m_VkCmdBuffer, Image, OldLayout, NewLayout, SubresRange, m_EnabledGraphicsShaderStages, SrcStages, DestStages);
+ }
+
+
+ static void BufferMemoryBarrier(VkCommandBuffer CmdBuffer,
+ VkBuffer Buffer,
+ VkAccessFlags srcAccessMask,
+ VkAccessFlags dstAccessMask,
+ VkPipelineStageFlags EnabledGraphicsShaderStages,
+ VkPipelineStageFlags SrcStages = 0,
+ VkPipelineStageFlags DestStages = 0);
+
+ __forceinline void BufferMemoryBarrier(VkBuffer Buffer,
+ VkAccessFlags srcAccessMask,
+ VkAccessFlags dstAccessMask,
+ VkPipelineStageFlags SrcStages = 0,
+ VkPipelineStageFlags DestStages = 0)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- vkCmdSetStencilReference(m_VkCmdBuffer, VK_STENCIL_FRONT_AND_BACK, Reference);
+ // Image layout transitions within a render pass execute
+ // dependencies between attachments
+ EndRenderPass();
}
-
- __forceinline void SetBlendConstants(const float BlendConstants[4])
+ BufferMemoryBarrier(m_VkCmdBuffer, Buffer, srcAccessMask, dstAccessMask, m_EnabledGraphicsShaderStages, SrcStages, DestStages);
+ }
+
+ __forceinline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint,
+ VkPipelineLayout layout,
+ uint32_t firstSet,
+ uint32_t descriptorSetCount,
+ const VkDescriptorSet* pDescriptorSets,
+ uint32_t dynamicOffsetCount = 0,
+ const uint32_t* pDynamicOffsets = nullptr)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ vkCmdBindDescriptorSets(m_VkCmdBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
+ }
+
+ __forceinline void CopyBuffer(VkBuffer srcBuffer,
+ VkBuffer dstBuffer,
+ uint32_t regionCount,
+ const VkBufferCopy* pRegions)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- vkCmdSetBlendConstants(m_VkCmdBuffer, BlendConstants);
+ // Copy buffer operation must be performed outside of render pass.
+ EndRenderPass();
}
-
- __forceinline void BindIndexBuffer(VkBuffer Buffer, VkDeviceSize Offset, VkIndexType IndexType)
+ vkCmdCopyBuffer(m_VkCmdBuffer, srcBuffer, dstBuffer, regionCount, pRegions);
+ }
+
+ __forceinline void CopyImage(VkImage srcImage,
+ VkImageLayout srcImageLayout,
+ VkImage dstImage,
+ VkImageLayout dstImageLayout,
+ uint32_t regionCount,
+ const VkImageCopy* pRegions)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.IndexBuffer != Buffer ||
- m_State.IndexBufferOffset != Offset ||
- m_State.IndexType != IndexType)
- {
- vkCmdBindIndexBuffer(m_VkCmdBuffer, Buffer, Offset, IndexType);
- m_State.IndexBuffer = Buffer;
- m_State.IndexBufferOffset = Offset;
- m_State.IndexType = IndexType;
- }
+ // Copy operations must be performed outside of render pass.
+ EndRenderPass();
}
- __forceinline void BindVertexBuffers(uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- vkCmdBindVertexBuffers(m_VkCmdBuffer, firstBinding, bindingCount, pBuffers, pOffsets);
- }
+ vkCmdCopyImage(m_VkCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
+ }
- static void TransitionImageLayout(VkCommandBuffer CmdBuffer,
- VkImage Image,
- VkImageLayout OldLayout,
- VkImageLayout NewLayout,
- const VkImageSubresourceRange& SubresRange,
- VkPipelineStageFlags EnabledGraphicsShaderStages,
- VkPipelineStageFlags SrcStages = 0,
- VkPipelineStageFlags DestStages = 0);
-
- __forceinline void TransitionImageLayout(VkImage Image,
- VkImageLayout OldLayout,
- VkImageLayout NewLayout,
- const VkImageSubresourceRange& SubresRange,
- VkPipelineStageFlags SrcStages = 0,
- VkPipelineStageFlags DestStages = 0)
+ __forceinline void CopyBufferToImage(VkBuffer srcBuffer,
+ VkImage dstImage,
+ VkImageLayout dstImageLayout,
+ uint32_t regionCount,
+ const VkBufferImageCopy* pRegions)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.RenderPass != VK_NULL_HANDLE)
- {
- // Image layout transitions within a render pass execute
- // dependencies between attachments
- EndRenderPass();
- }
- TransitionImageLayout(m_VkCmdBuffer, Image, OldLayout, NewLayout, SubresRange, m_EnabledGraphicsShaderStages, SrcStages, DestStages);
+ // Copy operations must be performed outside of render pass.
+ EndRenderPass();
}
+ vkCmdCopyBufferToImage(m_VkCmdBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions);
+ }
- static void BufferMemoryBarrier(VkCommandBuffer CmdBuffer,
- VkBuffer Buffer,
- VkAccessFlags srcAccessMask,
- VkAccessFlags dstAccessMask,
- VkPipelineStageFlags EnabledGraphicsShaderStages,
- VkPipelineStageFlags SrcStages = 0,
- VkPipelineStageFlags DestStages = 0);
-
- __forceinline void BufferMemoryBarrier(VkBuffer Buffer,
- VkAccessFlags srcAccessMask,
- VkAccessFlags dstAccessMask,
- VkPipelineStageFlags SrcStages = 0,
- VkPipelineStageFlags DestStages = 0)
+ __forceinline void CopyImageToBuffer(VkImage srcImage,
+ VkImageLayout srcImageLayout,
+ VkBuffer dstBuffer,
+ uint32_t regionCount,
+ const VkBufferImageCopy* pRegions)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.RenderPass != VK_NULL_HANDLE)
- {
- // Image layout transitions within a render pass execute
- // dependencies between attachments
- EndRenderPass();
- }
- BufferMemoryBarrier(m_VkCmdBuffer, Buffer, srcAccessMask, dstAccessMask, m_EnabledGraphicsShaderStages, SrcStages, DestStages);
+ // Copy operations must be performed outside of render pass.
+ EndRenderPass();
}
- __forceinline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint,
- VkPipelineLayout layout,
- uint32_t firstSet,
- uint32_t descriptorSetCount,
- const VkDescriptorSet* pDescriptorSets,
- uint32_t dynamicOffsetCount = 0,
- const uint32_t* pDynamicOffsets = nullptr)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- vkCmdBindDescriptorSets(m_VkCmdBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
- }
+ vkCmdCopyImageToBuffer(m_VkCmdBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
+ }
- __forceinline void CopyBuffer(VkBuffer srcBuffer,
- VkBuffer dstBuffer,
- uint32_t regionCount,
- const VkBufferCopy* pRegions)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.RenderPass != VK_NULL_HANDLE)
- {
- // Copy buffer operation must be performed outside of render pass.
- EndRenderPass();
- }
- vkCmdCopyBuffer(m_VkCmdBuffer, srcBuffer, dstBuffer, regionCount, pRegions);
- }
-
- __forceinline void CopyImage(VkImage srcImage,
- VkImageLayout srcImageLayout,
- VkImage dstImage,
- VkImageLayout dstImageLayout,
- uint32_t regionCount,
- const VkImageCopy* pRegions)
+ __forceinline void BlitImage(VkImage srcImage,
+ VkImageLayout srcImageLayout,
+ VkImage dstImage,
+ VkImageLayout dstImageLayout,
+ uint32_t regionCount,
+ const VkImageBlit* pRegions,
+ VkFilter filter)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.RenderPass != VK_NULL_HANDLE)
- {
- // Copy operations must be performed outside of render pass.
- EndRenderPass();
- }
-
- vkCmdCopyImage(m_VkCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
+ // Blit must be performed outside of render pass.
+ EndRenderPass();
}
- __forceinline void CopyBufferToImage(VkBuffer srcBuffer,
- VkImage dstImage,
- VkImageLayout dstImageLayout,
- uint32_t regionCount,
- const VkBufferImageCopy* pRegions)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.RenderPass != VK_NULL_HANDLE)
- {
- // Copy operations must be performed outside of render pass.
- EndRenderPass();
- }
-
- vkCmdCopyBufferToImage(m_VkCmdBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions);
- }
+ vkCmdBlitImage(m_VkCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
+ }
- __forceinline void CopyImageToBuffer(VkImage srcImage,
- VkImageLayout srcImageLayout,
- VkBuffer dstBuffer,
- uint32_t regionCount,
- const VkBufferImageCopy* pRegions)
+ __forceinline void ResolveImage(VkImage srcImage,
+ VkImageLayout srcImageLayout,
+ VkImage dstImage,
+ VkImageLayout dstImageLayout,
+ uint32_t regionCount,
+ const VkImageResolve* pRegions)
+ {
+ VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.RenderPass != VK_NULL_HANDLE)
- {
- // Copy operations must be performed outside of render pass.
- EndRenderPass();
- }
-
- vkCmdCopyImageToBuffer(m_VkCmdBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
+ // Resolve must be performed outside of render pass.
+ EndRenderPass();
}
+ vkCmdResolveImage(m_VkCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
+ }
- __forceinline void BlitImage(VkImage srcImage,
- VkImageLayout srcImageLayout,
- VkImage dstImage,
- VkImageLayout dstImageLayout,
- uint32_t regionCount,
- const VkImageBlit* pRegions,
- VkFilter filter)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.RenderPass != VK_NULL_HANDLE)
- {
- // Blit must be performed outside of render pass.
- EndRenderPass();
- }
-
- vkCmdBlitImage(m_VkCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
- }
+ void FlushBarriers();
- __forceinline void ResolveImage(VkImage srcImage,
- VkImageLayout srcImageLayout,
- VkImage dstImage,
- VkImageLayout dstImageLayout,
- uint32_t regionCount,
- const VkImageResolve* pRegions)
- {
- VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if (m_State.RenderPass != VK_NULL_HANDLE)
- {
- // Resolve must be performed outside of render pass.
- EndRenderPass();
- }
- vkCmdResolveImage(m_VkCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
- }
+ __forceinline void SetVkCmdBuffer(VkCommandBuffer VkCmdBuffer)
+ {
+ m_VkCmdBuffer = VkCmdBuffer;
+ }
+ VkCommandBuffer GetVkCmdBuffer() const { return m_VkCmdBuffer; }
+
+ struct StateCache
+ {
+ VkRenderPass RenderPass = VK_NULL_HANDLE;
+ VkFramebuffer Framebuffer = VK_NULL_HANDLE;
+ VkPipeline GraphicsPipeline = VK_NULL_HANDLE;
+ VkPipeline ComputePipeline = VK_NULL_HANDLE;
+ VkBuffer IndexBuffer = VK_NULL_HANDLE;
+ VkDeviceSize IndexBufferOffset = 0;
+ VkIndexType IndexType = VK_INDEX_TYPE_MAX_ENUM;
+ uint32_t FramebufferWidth = 0;
+ uint32_t FramebufferHeight = 0;
+ };
- void FlushBarriers();
+ const StateCache& GetState() const { return m_State; }
- __forceinline void SetVkCmdBuffer(VkCommandBuffer VkCmdBuffer)
- {
- m_VkCmdBuffer = VkCmdBuffer;
- }
- VkCommandBuffer GetVkCmdBuffer()const{return m_VkCmdBuffer;}
+private:
+ StateCache m_State;
+ VkCommandBuffer m_VkCmdBuffer = VK_NULL_HANDLE;
+ const VkPipelineStageFlags m_EnabledGraphicsShaderStages;
+};
- struct StateCache
- {
- VkRenderPass RenderPass = VK_NULL_HANDLE;
- VkFramebuffer Framebuffer = VK_NULL_HANDLE;
- VkPipeline GraphicsPipeline = VK_NULL_HANDLE;
- VkPipeline ComputePipeline = VK_NULL_HANDLE;
- VkBuffer IndexBuffer = VK_NULL_HANDLE;
- VkDeviceSize IndexBufferOffset = 0;
- VkIndexType IndexType = VK_INDEX_TYPE_MAX_ENUM;
- uint32_t FramebufferWidth = 0;
- uint32_t FramebufferHeight = 0;
- };
-
- const StateCache& GetState()const{return m_State;}
-
- private:
- StateCache m_State;
- VkCommandBuffer m_VkCmdBuffer = VK_NULL_HANDLE;
- const VkPipelineStageFlags m_EnabledGraphicsShaderStages;
- };
-}
+} // namespace VulkanUtilities
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h
index 52fdca31..e59a7b33 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h
@@ -33,39 +33,46 @@
namespace VulkanUtilities
{
- class VulkanCommandBufferPool
- {
- public:
- VulkanCommandBufferPool(std::shared_ptr<const VulkanLogicalDevice> LogicalDevice,
- uint32_t queueFamilyIndex,
- VkCommandPoolCreateFlags flags);
- VulkanCommandBufferPool (const VulkanCommandBufferPool&) = delete;
- VulkanCommandBufferPool ( VulkanCommandBufferPool&&) = delete;
- VulkanCommandBufferPool& operator = (const VulkanCommandBufferPool&) = delete;
- VulkanCommandBufferPool& operator = ( VulkanCommandBufferPool&&) = delete;
+class VulkanCommandBufferPool
+{
+public:
+ VulkanCommandBufferPool(std::shared_ptr<const VulkanLogicalDevice> LogicalDevice,
+ uint32_t queueFamilyIndex,
+ VkCommandPoolCreateFlags flags);
+
+ // clang-format off
+ VulkanCommandBufferPool (const VulkanCommandBufferPool&) = delete;
+ VulkanCommandBufferPool ( VulkanCommandBufferPool&&) = delete;
+ VulkanCommandBufferPool& operator = (const VulkanCommandBufferPool&) = delete;
+ VulkanCommandBufferPool& operator = ( VulkanCommandBufferPool&&) = delete;
+ // clang-format on
- ~VulkanCommandBufferPool();
+ ~VulkanCommandBufferPool();
- VkCommandBuffer GetCommandBuffer(const char* DebugName = "");
- // The GPU must have finished with the command buffer being returned to the pool
- void FreeCommandBuffer(VkCommandBuffer&& CmdBuffer);
+ VkCommandBuffer GetCommandBuffer(const char* DebugName = "");
+ // The GPU must have finished with the command buffer being returned to the pool
+ void FreeCommandBuffer(VkCommandBuffer&& CmdBuffer);
- CommandPoolWrapper&& Release();
+ CommandPoolWrapper&& Release();
#ifdef DEVELOPMENT
- int32_t DvpGetBufferCounter()const{return m_BuffCounter;}
+ int32_t DvpGetBufferCounter() const
+ {
+ return m_BuffCounter;
+ }
#endif
- private:
- // Shared point to logical device must be defined before the command pool
- std::shared_ptr<const VulkanLogicalDevice> m_LogicalDevice;
- CommandPoolWrapper m_CmdPool;
+private:
+ // Shared point to logical device must be defined before the command pool
+ std::shared_ptr<const VulkanLogicalDevice> m_LogicalDevice;
+ CommandPoolWrapper m_CmdPool;
- std::mutex m_Mutex;
- std::deque< VkCommandBuffer > m_CmdBuffers;
+ std::mutex m_Mutex;
+ std::deque<VkCommandBuffer> m_CmdBuffers;
#ifdef DEVELOPMENT
- std::atomic_int32_t m_BuffCounter;
+ std::atomic_int32_t m_BuffCounter;
#endif
- };
-}
+};
+
+} // namespace VulkanUtilities
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h
index 2a165f58..60ba5410 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDebug.h
@@ -5,113 +5,119 @@
namespace VulkanUtilities
{
- // Default validation layers
+
+// clang-format off
+// Default validation layers
#if !PLATFORM_ANDROID
- // On desktop the LunarG loaders exposes a meta layer that contains all layers
- static constexpr const char* ValidationLayerNames[] =
- {
- "VK_LAYER_LUNARG_standard_validation"
- };
+// On desktop the LunarG loaders exposes a meta layer that contains all layers
+static constexpr const char* ValidationLayerNames[] =
+{
+ "VK_LAYER_LUNARG_standard_validation"
+};
#else
- // On Android we need to explicitly select all layers
- static constexpr const char *ValidationLayerNames[] =
- {
- "VK_LAYER_GOOGLE_threading",
- "VK_LAYER_LUNARG_parameter_validation",
- "VK_LAYER_LUNARG_object_tracker",
- "VK_LAYER_LUNARG_core_validation",
- "VK_LAYER_LUNARG_swapchain",
- "VK_LAYER_GOOGLE_unique_objects"
- };
+// On Android we need to explicitly select all layers
+static constexpr const char *ValidationLayerNames[] =
+{
+ "VK_LAYER_GOOGLE_threading",
+ "VK_LAYER_LUNARG_parameter_validation",
+ "VK_LAYER_LUNARG_object_tracker",
+ "VK_LAYER_LUNARG_core_validation",
+ "VK_LAYER_LUNARG_swapchain",
+ "VK_LAYER_GOOGLE_unique_objects"
+};
#endif
+// clang-format on
+
+// Load debug function pointers and set debug callback
+// if callBack is NULL, default message callback will be used
+void SetupDebugging(VkInstance instance,
+ VkDebugUtilsMessageSeverityFlagsEXT messageSeverity,
+ VkDebugUtilsMessageTypeFlagsEXT messageType,
+ void* pUserData = nullptr);
+// Clear debug callback
+void FreeDebugging(VkInstance instance);
+
+// Setup and functions for the VK_EXT_debug_marker_extension
+// Extension spec can be found at https://github.com/KhronosGroup/Vulkan-Docs/blob/1.0-VK_EXT_debug_marker/doc/specs/vulkan/appendices/VK_EXT_debug_marker.txt
+// Note that the extension will only be present if run from an offline debugging application
+// The actual check for extension presence and enabling it on the device is done in the example base class
+// See VulkanExampleBase::createInstance and VulkanExampleBase::createDevice (base/vulkanexamplebase.cpp)
+
+// Sets the debug name of an object
+// All Objects in Vulkan are represented by their 64-bit handles which are passed into this function
+// along with the object type
+void SetObjectName(VkDevice device, uint64_t object, VkObjectType objectType, const char* name);
+
+// Set the tag for an object
+void SetObjectTag(VkDevice device, uint64_t objectHandle, VkObjectType objectType, uint64_t name, size_t tagSize, const void* tag);
+
+// Start a new label region
+void BeginCmdQueueLabelRegion(VkQueue cmdQueue, const char* pLabelName, const float* color);
+
+// End the label region
+void EndCmdQueueLabelRegion(VkQueue cmdQueue);
+
+// Insert a single label
+void InsertCmdQueueLabel(VkQueue cmdQueue, const char* pLabelName, const float* color);
+
+// Start a new label region
+void BeginCmdBufferLabelRegion(VkCommandBuffer cmdBuffer, const char* pLabelName, const float* color);
+
+// End the label region
+void EndCmdBufferLabelRegion(VkCommandBuffer cmdBuffer);
+
+// Insert a single label
+void InsertCmdBufferLabel(VkCommandBuffer cmdBuffer, const char* pLabelName, const float* color);
+
+// clang-format off
+// Object specific naming functions
+void SetCommandPoolName (VkDevice device, VkCommandPool cmdPool, const char * name);
+void SetCommandBufferName (VkDevice device, VkCommandBuffer cmdBuffer, const char * name);
+void SetQueueName (VkDevice device, VkQueue queue, const char * name);
+void SetImageName (VkDevice device, VkImage image, const char * name);
+void SetImageViewName (VkDevice device, VkImageView imageView, const char * name);
+void SetSamplerName (VkDevice device, VkSampler sampler, const char * name);
+void SetBufferName (VkDevice device, VkBuffer buffer, const char * name);
+void SetBufferViewName (VkDevice device, VkBufferView bufferView, const char * name);
+void SetDeviceMemoryName (VkDevice device, VkDeviceMemory memory, const char * name);
+void SetShaderModuleName (VkDevice device, VkShaderModule shaderModule, const char * name);
+void SetPipelineName (VkDevice device, VkPipeline pipeline, const char * name);
+void SetPipelineLayoutName (VkDevice device, VkPipelineLayout pipelineLayout, const char * name);
+void SetRenderPassName (VkDevice device, VkRenderPass renderPass, const char * name);
+void SetFramebufferName (VkDevice device, VkFramebuffer framebuffer, const char * name);
+void SetDescriptorSetLayoutName (VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name);
+void SetDescriptorSetName (VkDevice device, VkDescriptorSet descriptorSet, const char * name);
+void SetDescriptorPoolName (VkDevice device, VkDescriptorPool descriptorPool, const char * name);
+void SetSemaphoreName (VkDevice device, VkSemaphore semaphore, const char * name);
+void SetFenceName (VkDevice device, VkFence fence, const char * name);
+void SetEventName (VkDevice device, VkEvent _event, const char * name);
+
+void SetVulkanObjectName(VkDevice device, VkCommandPool cmdPool, const char * name);
+void SetVulkanObjectName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name);
+void SetVulkanObjectName(VkDevice device, VkQueue queue, const char * name);
+void SetVulkanObjectName(VkDevice device, VkImage image, const char * name);
+void SetVulkanObjectName(VkDevice device, VkImageView imageView, const char * name);
+void SetVulkanObjectName(VkDevice device, VkSampler sampler, const char * name);
+void SetVulkanObjectName(VkDevice device, VkBuffer buffer, const char * name);
+void SetVulkanObjectName(VkDevice device, VkBufferView bufferView, const char * name);
+void SetVulkanObjectName(VkDevice device, VkDeviceMemory memory, const char * name);
+void SetVulkanObjectName(VkDevice device, VkShaderModule shaderModule, const char * name);
+void SetVulkanObjectName(VkDevice device, VkPipeline pipeline, const char * name);
+void SetVulkanObjectName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name);
+void SetVulkanObjectName(VkDevice device, VkRenderPass renderPass, const char * name);
+void SetVulkanObjectName(VkDevice device, VkFramebuffer framebuffer, const char * name);
+void SetVulkanObjectName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name);
+void SetVulkanObjectName(VkDevice device, VkDescriptorSet descriptorSet, const char * name);
+void SetVulkanObjectName(VkDevice device, VkDescriptorPool descriptorPool, const char * name);
+void SetVulkanObjectName(VkDevice device, VkSemaphore semaphore, const char * name);
+void SetVulkanObjectName(VkDevice device, VkFence fence, const char * name);
+void SetVulkanObjectName(VkDevice device, VkEvent _event, const char * name);
+
+const char* VkResultToString (VkResult errorCode);
+const char* VkAccessFlagBitToString(VkAccessFlagBits Bit);
+const char* VkImageLayoutToString (VkImageLayout Layout);
+std::string VkAccessFlagsToString (VkAccessFlags Flags);
+const char* VkObjectTypeToString (VkObjectType ObjectType);
+// clang-format on
- // Load debug function pointers and set debug callback
- // if callBack is NULL, default message callback will be used
- void SetupDebugging(VkInstance instance,
- VkDebugUtilsMessageSeverityFlagsEXT messageSeverity,
- VkDebugUtilsMessageTypeFlagsEXT messageType,
- void* pUserData = nullptr);
- // Clear debug callback
- void FreeDebugging(VkInstance instance);
-
- // Setup and functions for the VK_EXT_debug_marker_extension
- // Extension spec can be found at https://github.com/KhronosGroup/Vulkan-Docs/blob/1.0-VK_EXT_debug_marker/doc/specs/vulkan/appendices/VK_EXT_debug_marker.txt
- // Note that the extension will only be present if run from an offline debugging application
- // The actual check for extension presence and enabling it on the device is done in the example base class
- // See VulkanExampleBase::createInstance and VulkanExampleBase::createDevice (base/vulkanexamplebase.cpp)
-
- // Sets the debug name of an object
- // All Objects in Vulkan are represented by their 64-bit handles which are passed into this function
- // along with the object type
- void SetObjectName(VkDevice device, uint64_t object, VkObjectType objectType, const char *name);
-
- // Set the tag for an object
- void SetObjectTag(VkDevice device, uint64_t objectHandle, VkObjectType objectType, uint64_t name, size_t tagSize, const void* tag);
-
- // Start a new label region
- void BeginCmdQueueLabelRegion(VkQueue cmdQueue, const char* pLabelName, const float* color);
-
- // End the label region
- void EndCmdQueueLabelRegion(VkQueue cmdQueue);
-
- // Insert a single label
- void InsertCmdQueueLabel(VkQueue cmdQueue, const char* pLabelName, const float* color);
-
- // Start a new label region
- void BeginCmdBufferLabelRegion(VkCommandBuffer cmdBuffer, const char* pLabelName, const float* color);
-
- // End the label region
- void EndCmdBufferLabelRegion(VkCommandBuffer cmdBuffer);
-
- // Insert a single label
- void InsertCmdBufferLabel(VkCommandBuffer cmdBuffer, const char* pLabelName, const float* color);
-
- // Object specific naming functions
- void SetCommandPoolName (VkDevice device, VkCommandPool cmdPool, const char * name);
- void SetCommandBufferName (VkDevice device, VkCommandBuffer cmdBuffer, const char * name);
- void SetQueueName (VkDevice device, VkQueue queue, const char * name);
- void SetImageName (VkDevice device, VkImage image, const char * name);
- void SetImageViewName (VkDevice device, VkImageView imageView, const char * name);
- void SetSamplerName (VkDevice device, VkSampler sampler, const char * name);
- void SetBufferName (VkDevice device, VkBuffer buffer, const char * name);
- void SetBufferViewName (VkDevice device, VkBufferView bufferView, const char * name);
- void SetDeviceMemoryName (VkDevice device, VkDeviceMemory memory, const char * name);
- void SetShaderModuleName (VkDevice device, VkShaderModule shaderModule, const char * name);
- void SetPipelineName (VkDevice device, VkPipeline pipeline, const char * name);
- void SetPipelineLayoutName (VkDevice device, VkPipelineLayout pipelineLayout, const char * name);
- void SetRenderPassName (VkDevice device, VkRenderPass renderPass, const char * name);
- void SetFramebufferName (VkDevice device, VkFramebuffer framebuffer, const char * name);
- void SetDescriptorSetLayoutName (VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name);
- void SetDescriptorSetName (VkDevice device, VkDescriptorSet descriptorSet, const char * name);
- void SetDescriptorPoolName (VkDevice device, VkDescriptorPool descriptorPool, const char * name);
- void SetSemaphoreName (VkDevice device, VkSemaphore semaphore, const char * name);
- void SetFenceName (VkDevice device, VkFence fence, const char * name);
- void SetEventName (VkDevice device, VkEvent _event, const char * name);
-
- void SetVulkanObjectName(VkDevice device, VkCommandPool cmdPool, const char * name);
- void SetVulkanObjectName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name);
- void SetVulkanObjectName(VkDevice device, VkQueue queue, const char * name);
- void SetVulkanObjectName(VkDevice device, VkImage image, const char * name);
- void SetVulkanObjectName(VkDevice device, VkImageView imageView, const char * name);
- void SetVulkanObjectName(VkDevice device, VkSampler sampler, const char * name);
- void SetVulkanObjectName(VkDevice device, VkBuffer buffer, const char * name);
- void SetVulkanObjectName(VkDevice device, VkBufferView bufferView, const char * name);
- void SetVulkanObjectName(VkDevice device, VkDeviceMemory memory, const char * name);
- void SetVulkanObjectName(VkDevice device, VkShaderModule shaderModule, const char * name);
- void SetVulkanObjectName(VkDevice device, VkPipeline pipeline, const char * name);
- void SetVulkanObjectName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name);
- void SetVulkanObjectName(VkDevice device, VkRenderPass renderPass, const char * name);
- void SetVulkanObjectName(VkDevice device, VkFramebuffer framebuffer, const char * name);
- void SetVulkanObjectName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name);
- void SetVulkanObjectName(VkDevice device, VkDescriptorSet descriptorSet, const char * name);
- void SetVulkanObjectName(VkDevice device, VkDescriptorPool descriptorPool, const char * name);
- void SetVulkanObjectName(VkDevice device, VkSemaphore semaphore, const char * name);
- void SetVulkanObjectName(VkDevice device, VkFence fence, const char * name);
- void SetVulkanObjectName(VkDevice device, VkEvent _event, const char * name);
-
- const char* VkResultToString (VkResult errorCode);
- const char* VkAccessFlagBitToString(VkAccessFlagBits Bit);
- const char* VkImageLayoutToString (VkImageLayout Layout);
- std::string VkAccessFlagsToString (VkAccessFlags Flags);
- const char* VkObjectTypeToString (VkObjectType ObjectType);
-}
+} // namespace VulkanUtilities
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanFencePool.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanFencePool.h
index 45367291..7385f86e 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanFencePool.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanFencePool.h
@@ -31,24 +31,28 @@
namespace VulkanUtilities
{
- class VulkanFencePool
- {
- public:
- VulkanFencePool(std::shared_ptr<const VulkanLogicalDevice> LogicalDevice)noexcept;
-
- VulkanFencePool (const VulkanFencePool&) = delete;
- VulkanFencePool (VulkanFencePool&&) = delete;
- VulkanFencePool& operator = (const VulkanFencePool&) = delete;
- VulkanFencePool& operator = (VulkanFencePool&&) = delete;
-
- ~VulkanFencePool();
-
- FenceWrapper GetFence();
- void DisposeFence(FenceWrapper&& Fence);
-
- private:
- // Shared pointer to logical device must be declared before fences
- std::shared_ptr<const VulkanLogicalDevice> m_LogicalDevice;
- std::vector<FenceWrapper> m_Fences;
- };
+
+class VulkanFencePool
+{
+public:
+ VulkanFencePool(std::shared_ptr<const VulkanLogicalDevice> LogicalDevice) noexcept;
+
+ // clang-format off
+ VulkanFencePool (const VulkanFencePool&) = delete;
+ VulkanFencePool (VulkanFencePool&&) = delete;
+ VulkanFencePool& operator = (const VulkanFencePool&) = delete;
+ VulkanFencePool& operator = (VulkanFencePool&&) = delete;
+ // clang-format off
+
+ ~VulkanFencePool();
+
+ FenceWrapper GetFence();
+ void DisposeFence(FenceWrapper&& Fence);
+
+private:
+ // Shared pointer to logical device must be declared before fences
+ std::shared_ptr<const VulkanLogicalDevice> m_LogicalDevice;
+ std::vector<FenceWrapper> m_Fences;
+};
+
}
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h
index 583bc517..b6488960 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h
@@ -29,48 +29,56 @@
namespace VulkanUtilities
{
- class VulkanInstance : public std::enable_shared_from_this<VulkanInstance>
+
+class VulkanInstance : public std::enable_shared_from_this<VulkanInstance>
+{
+public:
+ // clang-format off
+ VulkanInstance (const VulkanInstance&) = delete;
+ VulkanInstance ( VulkanInstance&&) = delete;
+ VulkanInstance& operator = (const VulkanInstance&) = delete;
+ VulkanInstance& operator = ( VulkanInstance&&) = delete;
+ // clang-format on
+
+ static std::shared_ptr<VulkanInstance> Create(bool EnableValidation,
+ uint32_t GlobalExtensionCount,
+ const char* const* ppGlobalExtensionNames,
+ VkAllocationCallbacks* pVkAllocator);
+ ~VulkanInstance();
+
+ std::shared_ptr<VulkanInstance> GetSharedPtr()
+ {
+ return shared_from_this();
+ }
+
+ std::shared_ptr<const VulkanInstance> GetSharedPtr() const
{
- public:
- VulkanInstance (const VulkanInstance&) = delete;
- VulkanInstance ( VulkanInstance&&) = delete;
- VulkanInstance& operator = (const VulkanInstance&) = delete;
- VulkanInstance& operator = ( VulkanInstance&&) = delete;
+ return shared_from_this();
+ }
- static std::shared_ptr<VulkanInstance> Create(bool EnableValidation,
- uint32_t GlobalExtensionCount,
- const char* const* ppGlobalExtensionNames,
- VkAllocationCallbacks* pVkAllocator);
- ~VulkanInstance();
+ // clang-format off
+ bool IsLayerAvailable (const char* LayerName) const;
+ bool IsExtensionAvailable(const char* ExtensionName)const;
- std::shared_ptr<VulkanInstance> GetSharedPtr()
- {
- return shared_from_this();
- }
+ VkPhysicalDevice SelectPhysicalDevice()const;
- std::shared_ptr<const VulkanInstance> GetSharedPtr()const
- {
- return shared_from_this();
- }
+ VkAllocationCallbacks* GetVkAllocator()const{return m_pVkAllocator;}
+ VkInstance GetVkInstance() const{return m_VkInstance; }
+ // clang-format on
- bool IsLayerAvailable (const char* LayerName) const;
- bool IsExtensionAvailable(const char* ExtensionName)const;
- VkPhysicalDevice SelectPhysicalDevice()const;
- VkAllocationCallbacks* GetVkAllocator()const{return m_pVkAllocator;}
- VkInstance GetVkInstance() const{return m_VkInstance;}
+private:
+ VulkanInstance(bool EnableValidation,
+ uint32_t GlobalExtensionCount,
+ const char* const* ppGlobalExtensionNames,
+ VkAllocationCallbacks* pVkAllocator);
- private:
- VulkanInstance(bool EnableValidation,
- uint32_t GlobalExtensionCount,
- const char* const* ppGlobalExtensionNames,
- VkAllocationCallbacks* pVkAllocator);
+ bool m_DebugUtilsEnabled = false;
+ VkAllocationCallbacks* const m_pVkAllocator;
+ VkInstance m_VkInstance = VK_NULL_HANDLE;
- bool m_DebugUtilsEnabled = false;
- VkAllocationCallbacks* const m_pVkAllocator;
- VkInstance m_VkInstance = VK_NULL_HANDLE;
+ std::vector<VkLayerProperties> m_Layers;
+ std::vector<VkExtensionProperties> m_Extensions;
+ std::vector<VkPhysicalDevice> m_PhysicalDevices;
+};
- std::vector<VkLayerProperties> m_Layers;
- std::vector<VkExtensionProperties> m_Extensions;
- std::vector<VkPhysicalDevice> m_PhysicalDevices;
- };
-}
+} // namespace VulkanUtilities
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
index 16f61ce8..9336e25b 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
@@ -28,144 +28,150 @@
namespace VulkanUtilities
{
- template<typename VulkanObjectType>
- class VulkanObjectWrapper;
-
- using CommandPoolWrapper = VulkanObjectWrapper<VkCommandPool>;
- using BufferWrapper = VulkanObjectWrapper<VkBuffer>;
- using BufferViewWrapper = VulkanObjectWrapper<VkBufferView>;
- using ImageWrapper = VulkanObjectWrapper<VkImage>;
- using ImageViewWrapper = VulkanObjectWrapper<VkImageView>;
- using DeviceMemoryWrapper = VulkanObjectWrapper<VkDeviceMemory>;
- using FenceWrapper = VulkanObjectWrapper<VkFence>;
- using RenderPassWrapper = VulkanObjectWrapper<VkRenderPass>;
- using PipelineWrapper = VulkanObjectWrapper<VkPipeline>;
- using ShaderModuleWrapper = VulkanObjectWrapper<VkShaderModule>;
- using PipelineLayoutWrapper = VulkanObjectWrapper<VkPipelineLayout>;
- using SamplerWrapper = VulkanObjectWrapper<VkSampler>;
- using FramebufferWrapper = VulkanObjectWrapper<VkFramebuffer>;
- using DescriptorPoolWrapper = VulkanObjectWrapper<VkDescriptorPool>;
- using DescriptorSetLayoutWrapper = VulkanObjectWrapper<VkDescriptorSetLayout>;
- using SemaphoreWrapper = VulkanObjectWrapper<VkSemaphore>;
-
- class VulkanLogicalDevice : public std::enable_shared_from_this<VulkanLogicalDevice>
+
+template <typename VulkanObjectType>
+class VulkanObjectWrapper;
+
+using CommandPoolWrapper = VulkanObjectWrapper<VkCommandPool>;
+using BufferWrapper = VulkanObjectWrapper<VkBuffer>;
+using BufferViewWrapper = VulkanObjectWrapper<VkBufferView>;
+using ImageWrapper = VulkanObjectWrapper<VkImage>;
+using ImageViewWrapper = VulkanObjectWrapper<VkImageView>;
+using DeviceMemoryWrapper = VulkanObjectWrapper<VkDeviceMemory>;
+using FenceWrapper = VulkanObjectWrapper<VkFence>;
+using RenderPassWrapper = VulkanObjectWrapper<VkRenderPass>;
+using PipelineWrapper = VulkanObjectWrapper<VkPipeline>;
+using ShaderModuleWrapper = VulkanObjectWrapper<VkShaderModule>;
+using PipelineLayoutWrapper = VulkanObjectWrapper<VkPipelineLayout>;
+using SamplerWrapper = VulkanObjectWrapper<VkSampler>;
+using FramebufferWrapper = VulkanObjectWrapper<VkFramebuffer>;
+using DescriptorPoolWrapper = VulkanObjectWrapper<VkDescriptorPool>;
+using DescriptorSetLayoutWrapper = VulkanObjectWrapper<VkDescriptorSetLayout>;
+using SemaphoreWrapper = VulkanObjectWrapper<VkSemaphore>;
+
+class VulkanLogicalDevice : public std::enable_shared_from_this<VulkanLogicalDevice>
+{
+public:
+ static std::shared_ptr<VulkanLogicalDevice> Create(VkPhysicalDevice vkPhysicalDevice,
+ const VkDeviceCreateInfo& DeviceCI,
+ const VkAllocationCallbacks* vkAllocator);
+
+ // clang-format off
+ VulkanLogicalDevice (const VulkanLogicalDevice&) = delete;
+ VulkanLogicalDevice (VulkanLogicalDevice&&) = delete;
+ VulkanLogicalDevice& operator = (const VulkanLogicalDevice&) = delete;
+ VulkanLogicalDevice& operator = (VulkanLogicalDevice&&) = delete;
+ // clang-format on
+
+ ~VulkanLogicalDevice();
+
+ std::shared_ptr<VulkanLogicalDevice> GetSharedPtr()
+ {
+ return shared_from_this();
+ }
+
+ std::shared_ptr<const VulkanLogicalDevice> GetSharedPtr() const
+ {
+ return shared_from_this();
+ }
+
+ VkQueue GetQueue(uint32_t queueFamilyIndex, uint32_t queueIndex);
+
+ VkDevice GetVkDevice() const
{
- public:
- static std::shared_ptr<VulkanLogicalDevice> Create(VkPhysicalDevice vkPhysicalDevice,
- const VkDeviceCreateInfo& DeviceCI,
- const VkAllocationCallbacks* vkAllocator);
-
- VulkanLogicalDevice (const VulkanLogicalDevice&) = delete;
- VulkanLogicalDevice (VulkanLogicalDevice&&) = delete;
- VulkanLogicalDevice& operator = (const VulkanLogicalDevice&) = delete;
- VulkanLogicalDevice& operator = (VulkanLogicalDevice&&) = delete;
-
- ~VulkanLogicalDevice();
-
- std::shared_ptr<VulkanLogicalDevice> GetSharedPtr()
- {
- return shared_from_this();
- }
-
- std::shared_ptr<const VulkanLogicalDevice> GetSharedPtr()const
- {
- return shared_from_this();
- }
-
- VkQueue GetQueue(uint32_t queueFamilyIndex, uint32_t queueIndex);
-
- VkDevice GetVkDevice()const
- {
- return m_VkDevice;
- }
-
- void WaitIdle()const;
-
- CommandPoolWrapper CreateCommandPool (const VkCommandPoolCreateInfo &CmdPoolCI, const char* DebugName = "")const;
- BufferWrapper CreateBuffer (const VkBufferCreateInfo &BufferCI, const char* DebugName = "")const;
- BufferViewWrapper CreateBufferView (const VkBufferViewCreateInfo &BuffViewCI, const char* DebugName = "")const;
- ImageWrapper CreateImage (const VkImageCreateInfo &ImageCI, const char* DebugName = "")const;
- ImageViewWrapper CreateImageView (const VkImageViewCreateInfo &ImageViewCI, const char* DebugName = "")const;
- SamplerWrapper CreateSampler (const VkSamplerCreateInfo &SamplerCI, const char* DebugName = "")const;
- FenceWrapper CreateFence (const VkFenceCreateInfo &FenceCI, const char* DebugName = "")const;
- RenderPassWrapper CreateRenderPass (const VkRenderPassCreateInfo &RenderPassCI,const char* DebugName = "")const;
- DeviceMemoryWrapper AllocateDeviceMemory(const VkMemoryAllocateInfo &AllocInfo, const char* DebugName = "")const;
- PipelineWrapper CreateComputePipeline (const VkComputePipelineCreateInfo &PipelineCI, VkPipelineCache cache, const char* DebugName = "")const;
- PipelineWrapper CreateGraphicsPipeline(const VkGraphicsPipelineCreateInfo &PipelineCI, VkPipelineCache cache, const char* DebugName = "")const;
- ShaderModuleWrapper CreateShaderModule (const VkShaderModuleCreateInfo &ShaderModuleCI, const char* DebugName = "")const;
- PipelineLayoutWrapper CreatePipelineLayout(const VkPipelineLayoutCreateInfo &LayoutCI, const char* DebugName = "")const;
- FramebufferWrapper CreateFramebuffer (const VkFramebufferCreateInfo &FramebufferCI, const char* DebugName = "")const;
- DescriptorPoolWrapper CreateDescriptorPool(const VkDescriptorPoolCreateInfo &DescrPoolCI, const char* DebugName = "")const;
- DescriptorSetLayoutWrapper CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo &LayoutCI, const char* DebugName = "")const;
- SemaphoreWrapper CreateSemaphore(const VkSemaphoreCreateInfo &SemaphoreCI, const char* DebugName = "")const;
-
- VkCommandBuffer AllocateVkCommandBuffer(const VkCommandBufferAllocateInfo &AllocInfo, const char* DebugName = "")const;
- VkDescriptorSet AllocateVkDescriptorSet(const VkDescriptorSetAllocateInfo &AllocInfo, const char* DebugName = "")const;
-
- void ReleaseVulkanObject(CommandPoolWrapper&& CmdPool)const;
- void ReleaseVulkanObject(BufferWrapper&& Buffer)const;
- void ReleaseVulkanObject(BufferViewWrapper&& BufferView)const;
- void ReleaseVulkanObject(ImageWrapper&& Image)const;
- void ReleaseVulkanObject(ImageViewWrapper&& ImageView)const;
- void ReleaseVulkanObject(SamplerWrapper&& Sampler)const;
- void ReleaseVulkanObject(FenceWrapper&& Fence)const;
- void ReleaseVulkanObject(RenderPassWrapper&& RenderPass)const;
- void ReleaseVulkanObject(DeviceMemoryWrapper&& Memory)const;
- void ReleaseVulkanObject(PipelineWrapper&& Pipeline)const;
- void ReleaseVulkanObject(ShaderModuleWrapper&& ShaderModule)const;
- void ReleaseVulkanObject(PipelineLayoutWrapper&& PipelineLayout)const;
- void ReleaseVulkanObject(FramebufferWrapper&& Framebuffer)const;
- void ReleaseVulkanObject(DescriptorPoolWrapper&& DescriptorPool)const;
- void ReleaseVulkanObject(DescriptorSetLayoutWrapper&& DescriptorSetLayout)const;
- void ReleaseVulkanObject(SemaphoreWrapper&& Semaphore)const;
-
- void FreeDescriptorSet(VkDescriptorPool Pool, VkDescriptorSet Set)const;
-
- VkMemoryRequirements GetBufferMemoryRequirements(VkBuffer vkBuffer)const;
- VkMemoryRequirements GetImageMemoryRequirements (VkImage vkImage )const;
-
- VkResult BindBufferMemory(VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)const;
- VkResult BindImageMemory (VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)const;
-
- VkResult MapMemory(VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData)const;
- void UnmapMemory(VkDeviceMemory memory)const;
-
- VkResult InvalidateMappedMemoryRanges(uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)const;
- VkResult FlushMappedMemoryRanges(uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)const;
-
- VkResult GetFenceStatus(VkFence fence)const;
- VkResult ResetFence(VkFence fence)const;
- VkResult WaitForFences(uint32_t fenceCount,
- const VkFence* pFences,
- VkBool32 waitAll,
- uint64_t timeout)const;
-
- void UpdateDescriptorSets(uint32_t descriptorWriteCount,
- const VkWriteDescriptorSet* pDescriptorWrites,
- uint32_t descriptorCopyCount,
- const VkCopyDescriptorSet* pDescriptorCopies)const;
-
- VkResult ResetCommandPool(VkCommandPool vkCmdPool,
- VkCommandPoolResetFlags flags = 0)const;
-
- VkResult ResetDescriptorPool(VkDescriptorPool descriptorPool,
- VkDescriptorPoolResetFlags flags = 0)const;
-
- VkPipelineStageFlags GetEnabledGraphicsShaderStages()const { return m_EnabledGraphicsShaderStages; }
-
- private:
- VulkanLogicalDevice(VkPhysicalDevice vkPhysicalDevice,
- const VkDeviceCreateInfo &DeviceCI,
- const VkAllocationCallbacks* vkAllocator);
-
- template<typename VkObjectType, typename VkCreateObjectFuncType, typename VkObjectCreateInfoType>
- VulkanObjectWrapper<VkObjectType> CreateVulkanObject(VkCreateObjectFuncType VkCreateObject,
- const VkObjectCreateInfoType& CreateInfo,
- const char* DebugName,
- const char* ObjectType)const;
-
- VkDevice m_VkDevice = VK_NULL_HANDLE;
- const VkAllocationCallbacks* const m_VkAllocator;
- VkPipelineStageFlags m_EnabledGraphicsShaderStages = 0;
- };
-}
+ return m_VkDevice;
+ }
+
+ void WaitIdle() const;
+
+ // clang-format off
+ CommandPoolWrapper CreateCommandPool (const VkCommandPoolCreateInfo &CmdPoolCI, const char* DebugName = "")const;
+ BufferWrapper CreateBuffer (const VkBufferCreateInfo &BufferCI, const char* DebugName = "")const;
+ BufferViewWrapper CreateBufferView (const VkBufferViewCreateInfo &BuffViewCI, const char* DebugName = "")const;
+ ImageWrapper CreateImage (const VkImageCreateInfo &ImageCI, const char* DebugName = "")const;
+ ImageViewWrapper CreateImageView (const VkImageViewCreateInfo &ImageViewCI, const char* DebugName = "")const;
+ SamplerWrapper CreateSampler (const VkSamplerCreateInfo &SamplerCI, const char* DebugName = "")const;
+ FenceWrapper CreateFence (const VkFenceCreateInfo &FenceCI, const char* DebugName = "")const;
+ RenderPassWrapper CreateRenderPass (const VkRenderPassCreateInfo &RenderPassCI,const char* DebugName = "")const;
+ DeviceMemoryWrapper AllocateDeviceMemory(const VkMemoryAllocateInfo &AllocInfo, const char* DebugName = "")const;
+ PipelineWrapper CreateComputePipeline (const VkComputePipelineCreateInfo &PipelineCI, VkPipelineCache cache, const char* DebugName = "")const;
+ PipelineWrapper CreateGraphicsPipeline(const VkGraphicsPipelineCreateInfo &PipelineCI, VkPipelineCache cache, const char* DebugName = "")const;
+ ShaderModuleWrapper CreateShaderModule (const VkShaderModuleCreateInfo &ShaderModuleCI, const char* DebugName = "")const;
+ PipelineLayoutWrapper CreatePipelineLayout(const VkPipelineLayoutCreateInfo &LayoutCI, const char* DebugName = "")const;
+ FramebufferWrapper CreateFramebuffer (const VkFramebufferCreateInfo &FramebufferCI, const char* DebugName = "")const;
+ DescriptorPoolWrapper CreateDescriptorPool(const VkDescriptorPoolCreateInfo &DescrPoolCI, const char* DebugName = "")const;
+ DescriptorSetLayoutWrapper CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo &LayoutCI, const char* DebugName = "")const;
+ SemaphoreWrapper CreateSemaphore(const VkSemaphoreCreateInfo &SemaphoreCI, const char* DebugName = "")const;
+
+ VkCommandBuffer AllocateVkCommandBuffer(const VkCommandBufferAllocateInfo &AllocInfo, const char* DebugName = "")const;
+ VkDescriptorSet AllocateVkDescriptorSet(const VkDescriptorSetAllocateInfo &AllocInfo, const char* DebugName = "")const;
+
+ void ReleaseVulkanObject(CommandPoolWrapper&& CmdPool)const;
+ void ReleaseVulkanObject(BufferWrapper&& Buffer)const;
+ void ReleaseVulkanObject(BufferViewWrapper&& BufferView)const;
+ void ReleaseVulkanObject(ImageWrapper&& Image)const;
+ void ReleaseVulkanObject(ImageViewWrapper&& ImageView)const;
+ void ReleaseVulkanObject(SamplerWrapper&& Sampler)const;
+ void ReleaseVulkanObject(FenceWrapper&& Fence)const;
+ void ReleaseVulkanObject(RenderPassWrapper&& RenderPass)const;
+ void ReleaseVulkanObject(DeviceMemoryWrapper&& Memory)const;
+ void ReleaseVulkanObject(PipelineWrapper&& Pipeline)const;
+ void ReleaseVulkanObject(ShaderModuleWrapper&& ShaderModule)const;
+ void ReleaseVulkanObject(PipelineLayoutWrapper&& PipelineLayout)const;
+ void ReleaseVulkanObject(FramebufferWrapper&& Framebuffer)const;
+ void ReleaseVulkanObject(DescriptorPoolWrapper&& DescriptorPool)const;
+ void ReleaseVulkanObject(DescriptorSetLayoutWrapper&& DescriptorSetLayout)const;
+ void ReleaseVulkanObject(SemaphoreWrapper&& Semaphore)const;
+
+ void FreeDescriptorSet(VkDescriptorPool Pool, VkDescriptorSet Set)const;
+
+ VkMemoryRequirements GetBufferMemoryRequirements(VkBuffer vkBuffer)const;
+ VkMemoryRequirements GetImageMemoryRequirements (VkImage vkImage )const;
+
+ VkResult BindBufferMemory(VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)const;
+ VkResult BindImageMemory (VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)const;
+ // clang-format on
+
+ VkResult MapMemory(VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData) const;
+ void UnmapMemory(VkDeviceMemory memory) const;
+
+ VkResult InvalidateMappedMemoryRanges(uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges) const;
+ VkResult FlushMappedMemoryRanges(uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges) const;
+
+ VkResult GetFenceStatus(VkFence fence) const;
+ VkResult ResetFence(VkFence fence) const;
+ VkResult WaitForFences(uint32_t fenceCount,
+ const VkFence* pFences,
+ VkBool32 waitAll,
+ uint64_t timeout) const;
+
+ void UpdateDescriptorSets(uint32_t descriptorWriteCount,
+ const VkWriteDescriptorSet* pDescriptorWrites,
+ uint32_t descriptorCopyCount,
+ const VkCopyDescriptorSet* pDescriptorCopies) const;
+
+ VkResult ResetCommandPool(VkCommandPool vkCmdPool,
+ VkCommandPoolResetFlags flags = 0) const;
+
+ VkResult ResetDescriptorPool(VkDescriptorPool descriptorPool,
+ VkDescriptorPoolResetFlags flags = 0) const;
+
+ VkPipelineStageFlags GetEnabledGraphicsShaderStages() const { return m_EnabledGraphicsShaderStages; }
+
+private:
+ VulkanLogicalDevice(VkPhysicalDevice vkPhysicalDevice,
+ const VkDeviceCreateInfo& DeviceCI,
+ const VkAllocationCallbacks* vkAllocator);
+
+ template <typename VkObjectType, typename VkCreateObjectFuncType, typename VkObjectCreateInfoType>
+ VulkanObjectWrapper<VkObjectType> CreateVulkanObject(VkCreateObjectFuncType VkCreateObject,
+ const VkObjectCreateInfoType& CreateInfo,
+ const char* DebugName,
+ const char* ObjectType) const;
+
+ VkDevice m_VkDevice = VK_NULL_HANDLE;
+ const VkAllocationCallbacks* const m_VkAllocator;
+ VkPipelineStageFlags m_EnabledGraphicsShaderStages = 0;
+};
+
+} // namespace VulkanUtilities
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h
index 10fbffb7..b736c5ad 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanMemoryManager.h
@@ -43,8 +43,9 @@ class VulkanMemoryManager;
struct VulkanMemoryAllocation
{
- VulkanMemoryAllocation()noexcept{}
+ VulkanMemoryAllocation() noexcept {}
+ // clang-format off
VulkanMemoryAllocation (const VulkanMemoryAllocation&) = delete;
VulkanMemoryAllocation& operator= (const VulkanMemoryAllocation&) = delete;
@@ -76,25 +77,27 @@ struct VulkanMemoryAllocation
return *this;
}
+ // clang-format on
// Destructor immediately returns the allocation to the parent page.
// The allocation must not be in use by the GPU.
~VulkanMemoryAllocation();
-
- VulkanMemoryPage* Page = nullptr; // Memory page that contains this allocation
- VkDeviceSize UnalignedOffset = 0; // Unaligned offset from the start of the memory
- VkDeviceSize Size = 0; // Reserved size of this allocation
+
+ VulkanMemoryPage* Page = nullptr; // Memory page that contains this allocation
+ VkDeviceSize UnalignedOffset = 0; // Unaligned offset from the start of the memory
+ VkDeviceSize Size = 0; // Reserved size of this allocation
};
class VulkanMemoryPage
{
public:
VulkanMemoryPage(VulkanMemoryManager& ParentMemoryMgr,
- VkDeviceSize PageSize,
+ VkDeviceSize PageSize,
uint32_t MemoryTypeIndex,
- bool IsHostVisible)noexcept;
+ bool IsHostVisible) noexcept;
~VulkanMemoryPage();
+ // clang-format off
VulkanMemoryPage(VulkanMemoryPage&& rhs)noexcept :
m_ParentMemoryMgr {rhs.m_ParentMemoryMgr },
m_AllocationMgr {std::move(rhs.m_AllocationMgr)},
@@ -107,21 +110,23 @@ public:
VulkanMemoryPage (const VulkanMemoryPage&) = delete;
VulkanMemoryPage& operator= (VulkanMemoryPage&) = delete;
VulkanMemoryPage& operator= (VulkanMemoryPage&& rhs) = delete;
+
+ bool IsEmpty() const { return m_AllocationMgr.IsEmpty(); }
+ bool IsFull() const { return m_AllocationMgr.IsFull(); }
+ VkDeviceSize GetPageSize() const { return m_AllocationMgr.GetMaxSize(); }
+ VkDeviceSize GetUsedSize() const { return m_AllocationMgr.GetUsedSize(); }
- bool IsEmpty()const{return m_AllocationMgr.IsEmpty();}
- bool IsFull() const{return m_AllocationMgr.IsFull();}
- VkDeviceSize GetPageSize()const{return m_AllocationMgr.GetMaxSize();}
- VkDeviceSize GetUsedSize()const{return m_AllocationMgr.GetUsedSize();}
+ // clang-format on
VulkanMemoryAllocation Allocate(VkDeviceSize size, VkDeviceSize alignment);
- VkDeviceMemory GetVkMemory()const{return m_VkMemory;}
- void* GetCPUMemory()const{return m_CPUMemory;}
-
+ VkDeviceMemory GetVkMemory() const { return m_VkMemory; }
+ void* GetCPUMemory() const { return m_CPUMemory; }
+
private:
friend struct VulkanMemoryAllocation;
-
- // Memory is reclaimed immediately. The application is responsible to ensure it is not in use by the GPU
+
+ // Memory is reclaimed immediately. The application is responsible to ensure it is not in use by the GPU
void Free(VulkanMemoryAllocation&& Allocation);
VulkanMemoryManager& m_ParentMemoryMgr;
@@ -134,6 +139,7 @@ private:
class VulkanMemoryManager
{
public:
+ // clang-format off
VulkanMemoryManager(std::string MgrName,
const VulkanLogicalDevice& LogicalDevice,
const VulkanPhysicalDevice& PhysicalDevice,
@@ -152,6 +158,7 @@ public:
m_HostVisibleReserveSize{HostVisibleReserveSize}
{}
+
// We have to write this constructor because on msvc default
// constructor is not labeled with noexcept, which makes all
// std containers use copy instead of move
@@ -172,25 +179,28 @@ public:
m_CurrAllocatedSize {rhs.m_CurrAllocatedSize},
m_PeakAllocatedSize {rhs.m_PeakAllocatedSize}
{
- for(size_t i=0; i < m_CurrUsedSize.size(); ++i)
+ // clang-format on
+ for (size_t i = 0; i < m_CurrUsedSize.size(); ++i)
m_CurrUsedSize[i].store(rhs.m_CurrUsedSize[i].load());
}
~VulkanMemoryManager();
+ // clang-format off
VulkanMemoryManager (const VulkanMemoryManager&) = delete;
VulkanMemoryManager& operator= (const VulkanMemoryManager&) = delete;
VulkanMemoryManager& operator= (VulkanMemoryManager&&) = delete;
-
+ // clang-format on
+
VulkanMemoryAllocation Allocate(VkDeviceSize Size, VkDeviceSize Alignment, uint32_t MemoryTypeIndex, bool HostVisible);
- VulkanMemoryAllocation Allocate(const VkMemoryRequirements& MemReqs, VkMemoryPropertyFlags MemoryProps);
- void ShrinkMemory();
+ VulkanMemoryAllocation Allocate(const VkMemoryRequirements& MemReqs, VkMemoryPropertyFlags MemoryProps);
+ void ShrinkMemory();
protected:
friend class VulkanMemoryPage;
- virtual void OnNewPageCreated(VulkanMemoryPage& NewPage){}
- virtual void OnPageDestroy(VulkanMemoryPage& Page){}
+ virtual void OnNewPageCreated(VulkanMemoryPage& NewPage) {}
+ virtual void OnPageDestroy(VulkanMemoryPage& Page) {}
std::string m_MgrName;
@@ -205,6 +215,7 @@ protected:
const uint32_t MemoryTypeIndex;
const bool IsHostVisible;
+ // clang-format off
MemoryPageIndex(uint32_t _MemoryTypeIndex,
bool _IsHostVisible) :
MemoryTypeIndex(_MemoryTypeIndex),
@@ -216,31 +227,32 @@ protected:
return MemoryTypeIndex == rhs.MemoryTypeIndex &&
IsHostVisible == rhs.IsHostVisible;
}
+ // clang-format on
struct Hasher
{
- size_t operator()(const MemoryPageIndex& PageIndex)const
+ size_t operator()(const MemoryPageIndex& PageIndex) const
{
return Diligent::ComputeHash(PageIndex.MemoryTypeIndex, PageIndex.IsHostVisible);
}
};
};
std::unordered_multimap<MemoryPageIndex, VulkanMemoryPage, MemoryPageIndex::Hasher> m_Pages;
-
+
const VkDeviceSize m_DeviceLocalPageSize;
const VkDeviceSize m_HostVisiblePageSize;
const VkDeviceSize m_DeviceLocalReserveSize;
const VkDeviceSize m_HostVisibleReserveSize;
-
+
void OnFreeAllocation(VkDeviceSize Size, bool IsHostVisble);
// 0 == Device local, 1 == Host-visible
- std::array<std::atomic_int64_t, 2> m_CurrUsedSize = {};
- std::array<VkDeviceSize, 2> m_PeakUsedSize = {};
- std::array<VkDeviceSize, 2> m_CurrAllocatedSize = {};
- std::array<VkDeviceSize, 2> m_PeakAllocatedSize = {};
+ std::array<std::atomic_int64_t, 2> m_CurrUsedSize = {};
+ std::array<VkDeviceSize, 2> m_PeakUsedSize = {};
+ std::array<VkDeviceSize, 2> m_CurrAllocatedSize = {};
+ std::array<VkDeviceSize, 2> m_PeakAllocatedSize = {};
// If adding new member, do not forget to update move ctor
};
-}
+} // namespace VulkanUtilities
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
index b0442634..aac72c03 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
@@ -28,71 +28,78 @@
namespace VulkanUtilities
{
- template<typename VulkanObjectType>
- class VulkanObjectWrapper
+
+template <typename VulkanObjectType>
+class VulkanObjectWrapper
+{
+public:
+ using VkObjectType = VulkanObjectType;
+
+ // clang-format off
+ VulkanObjectWrapper() :
+ m_pLogicalDevice{nullptr },
+ m_VkObject {VK_NULL_HANDLE}
+ {}
+
+ VulkanObjectWrapper(std::shared_ptr<const VulkanLogicalDevice> pLogicalDevice, VulkanObjectType&& vkObject) :
+ m_pLogicalDevice{pLogicalDevice},
+ m_VkObject {vkObject }
{
- public:
- using VkObjectType = VulkanObjectType;
-
- VulkanObjectWrapper() :
- m_pLogicalDevice{nullptr },
- m_VkObject {VK_NULL_HANDLE}
- {}
- VulkanObjectWrapper(std::shared_ptr<const VulkanLogicalDevice> pLogicalDevice, VulkanObjectType&& vkObject) :
- m_pLogicalDevice{pLogicalDevice},
- m_VkObject {vkObject }
- {
- vkObject = VK_NULL_HANDLE;
- }
- // This constructor does not take ownership of the vulkan object
- explicit VulkanObjectWrapper(VulkanObjectType vkObject) :
- m_VkObject {vkObject}
- {
- }
+ vkObject = VK_NULL_HANDLE;
+ }
+ // This constructor does not take ownership of the vulkan object
+ explicit VulkanObjectWrapper(VulkanObjectType vkObject) :
+ m_VkObject {vkObject}
+ {
+ }
- VulkanObjectWrapper (const VulkanObjectWrapper&) = delete;
- VulkanObjectWrapper& operator = (const VulkanObjectWrapper&) = delete;
+ VulkanObjectWrapper (const VulkanObjectWrapper&) = delete;
+ VulkanObjectWrapper& operator = (const VulkanObjectWrapper&) = delete;
- VulkanObjectWrapper(VulkanObjectWrapper&& rhs)noexcept :
- m_pLogicalDevice{std::move(rhs.m_pLogicalDevice)},
- m_VkObject {rhs.m_VkObject }
- {
- rhs.m_VkObject = VK_NULL_HANDLE;
- }
- VulkanObjectWrapper& operator = (VulkanObjectWrapper&& rhs)noexcept
- {
- Release();
- m_pLogicalDevice = std::move(rhs.m_pLogicalDevice);
- m_VkObject = rhs.m_VkObject;
- rhs.m_VkObject = VK_NULL_HANDLE;
- return *this;
- }
+ VulkanObjectWrapper(VulkanObjectWrapper&& rhs)noexcept :
+ m_pLogicalDevice{std::move(rhs.m_pLogicalDevice)},
+ m_VkObject {rhs.m_VkObject }
+ {
+ rhs.m_VkObject = VK_NULL_HANDLE;
+ }
- operator VulkanObjectType()const
- {
- return m_VkObject;
- }
+ // clang-format on
- void Release()
- {
- // For externally managed objects, m_pLogicalDevice is null
- if(m_pLogicalDevice && m_VkObject != VK_NULL_HANDLE)
- {
- m_pLogicalDevice->ReleaseVulkanObject(std::move(*this));
- }
- m_VkObject = VK_NULL_HANDLE;
- m_pLogicalDevice.reset();
- }
+ VulkanObjectWrapper& operator=(VulkanObjectWrapper&& rhs) noexcept
+ {
+ Release();
+ m_pLogicalDevice = std::move(rhs.m_pLogicalDevice);
+ m_VkObject = rhs.m_VkObject;
+ rhs.m_VkObject = VK_NULL_HANDLE;
+ return *this;
+ }
- ~VulkanObjectWrapper()
+ operator VulkanObjectType() const
+ {
+ return m_VkObject;
+ }
+
+ void Release()
+ {
+ // For externally managed objects, m_pLogicalDevice is null
+ if (m_pLogicalDevice && m_VkObject != VK_NULL_HANDLE)
{
- Release();
+ m_pLogicalDevice->ReleaseVulkanObject(std::move(*this));
}
+ m_VkObject = VK_NULL_HANDLE;
+ m_pLogicalDevice.reset();
+ }
+
+ ~VulkanObjectWrapper()
+ {
+ Release();
+ }
+
+private:
+ friend class VulkanLogicalDevice;
- private:
- friend class VulkanLogicalDevice;
+ std::shared_ptr<const VulkanLogicalDevice> m_pLogicalDevice;
+ VulkanObjectType m_VkObject;
+};
- std::shared_ptr<const VulkanLogicalDevice> m_pLogicalDevice;
- VulkanObjectType m_VkObject;
- };
-}
+} // namespace VulkanUtilities
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h
index d9decd22..8c5efe4c 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h
@@ -29,35 +29,43 @@
namespace VulkanUtilities
{
- class VulkanPhysicalDevice
- {
- public:
- VulkanPhysicalDevice (const VulkanPhysicalDevice&) = delete;
- VulkanPhysicalDevice (VulkanPhysicalDevice&&) = delete;
- VulkanPhysicalDevice& operator = (const VulkanPhysicalDevice&) = delete;
- VulkanPhysicalDevice& operator = (VulkanPhysicalDevice&&) = delete;
-
- static std::unique_ptr<VulkanPhysicalDevice> Create(VkPhysicalDevice vkDevice);
-
- uint32_t FindQueueFamily (VkQueueFlags QueueFlags) const;
- VkPhysicalDevice GetVkDeviceHandle () const { return m_VkDevice; }
- bool IsExtensionSupported(const char* ExtensionName) const;
- bool CheckPresentSupport (uint32_t queueFamilyIndex, VkSurfaceKHR VkSurface) const;
-
- static constexpr uint32_t InvalidMemoryTypeIndex = static_cast<uint32_t>(-1);
- uint32_t GetMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties)const;
- const VkPhysicalDeviceProperties& GetProperties() const {return m_Properties;}
- const VkPhysicalDeviceFeatures& GetFeatures() const {return m_Features; }
- VkFormatProperties GetPhysicalDeviceFormatProperties(VkFormat imageFormat)const;
-
- private:
- VulkanPhysicalDevice(VkPhysicalDevice vkDevice);
-
- const VkPhysicalDevice m_VkDevice;
- VkPhysicalDeviceProperties m_Properties = {};
- VkPhysicalDeviceFeatures m_Features = {};
- VkPhysicalDeviceMemoryProperties m_MemoryProperties = {};
- std::vector<VkQueueFamilyProperties> m_QueueFamilyProperties;
- std::vector<VkExtensionProperties> m_SupportedExtensions;
- };
-}
+
+class VulkanPhysicalDevice
+{
+public:
+ // clang-format off
+ VulkanPhysicalDevice (const VulkanPhysicalDevice&) = delete;
+ VulkanPhysicalDevice (VulkanPhysicalDevice&&) = delete;
+ VulkanPhysicalDevice& operator = (const VulkanPhysicalDevice&) = delete;
+ VulkanPhysicalDevice& operator = (VulkanPhysicalDevice&&) = delete;
+ // clang-format on
+
+ static std::unique_ptr<VulkanPhysicalDevice> Create(VkPhysicalDevice vkDevice);
+
+ // clang-format off
+ uint32_t FindQueueFamily (VkQueueFlags QueueFlags) const;
+ VkPhysicalDevice GetVkDeviceHandle () const { return m_VkDevice; }
+ bool IsExtensionSupported(const char* ExtensionName) const;
+ bool CheckPresentSupport (uint32_t queueFamilyIndex, VkSurfaceKHR VkSurface) const;
+ // clang-format on
+
+ static constexpr uint32_t InvalidMemoryTypeIndex = static_cast<uint32_t>(-1);
+
+ uint32_t GetMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties) const;
+
+ const VkPhysicalDeviceProperties& GetProperties() const { return m_Properties; }
+ const VkPhysicalDeviceFeatures& GetFeatures() const { return m_Features; }
+ VkFormatProperties GetPhysicalDeviceFormatProperties(VkFormat imageFormat) const;
+
+private:
+ VulkanPhysicalDevice(VkPhysicalDevice vkDevice);
+
+ const VkPhysicalDevice m_VkDevice;
+ VkPhysicalDeviceProperties m_Properties = {};
+ VkPhysicalDeviceFeatures m_Features = {};
+ VkPhysicalDeviceMemoryProperties m_MemoryProperties = {};
+ std::vector<VkQueueFamilyProperties> m_QueueFamilyProperties;
+ std::vector<VkExtensionProperties> m_SupportedExtensions;
+};
+
+} // namespace VulkanUtilities
diff --git a/Graphics/GraphicsEngineVulkan/include/pch.h b/Graphics/GraphicsEngineVulkan/include/pch.h
index bb2629f6..c49785f6 100644
--- a/Graphics/GraphicsEngineVulkan/include/pch.h
+++ b/Graphics/GraphicsEngineVulkan/include/pch.h
@@ -29,13 +29,13 @@
#pragma once
#ifdef PLATFORM_WIN32
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-# endif
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+# endif
-# ifndef NOMINMAX
-# define NOMINMAX
-# endif
+# ifndef NOMINMAX
+# define NOMINMAX
+# endif
#endif
#include <vector>
@@ -48,21 +48,23 @@
namespace std
{
- template<>struct hash<Diligent::TEXTURE_FORMAT>
+
+template <> struct hash<Diligent::TEXTURE_FORMAT>
+{
+ size_t operator()(const Diligent::TEXTURE_FORMAT& fmt) const
{
- size_t operator()( const Diligent::TEXTURE_FORMAT &fmt ) const
- {
- return hash<size_t>()(size_t{fmt});
- }
- };
- template<>struct hash<VkFormat>
+ return hash<size_t>()(size_t{fmt});
+ }
+};
+template <> struct hash<VkFormat>
+{
+ size_t operator()(const VkFormat& fmt) const
{
- size_t operator()( const VkFormat &fmt ) const
- {
- return hash<int>()(int{fmt});
- }
- };
-}
+ return hash<int>()(int{fmt});
+ }
+};
+
+} // namespace std
#include "PlatformDefinitions.h"
#include "Errors.h"
@@ -70,4 +72,3 @@ namespace std
#include "VulkanErrors.h"
#include "RenderDeviceBase.h"
#include "ValidatedCast.h"
-
diff --git a/Graphics/GraphicsEngineVulkan/interface/BufferViewVk.h b/Graphics/GraphicsEngineVulkan/interface/BufferViewVk.h
index 5a896321..68da2e72 100644
--- a/Graphics/GraphicsEngineVulkan/interface/BufferViewVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/BufferViewVk.h
@@ -33,15 +33,14 @@ namespace Diligent
// {CB67024A-1E23-4202-A49A-07B6BCEABC06}
static constexpr INTERFACE_ID IID_BufferViewVk =
-{ 0xcb67024a, 0x1e23, 0x4202,{ 0xa4, 0x9a, 0x7, 0xb6, 0xbc, 0xea, 0xbc, 0x6 } };
+ {0xcb67024a, 0x1e23, 0x4202, {0xa4, 0x9a, 0x7, 0xb6, 0xbc, 0xea, 0xbc, 0x6}};
/// Exposes Vulkan-specific functionality of a buffer view object.
class IBufferViewVk : public IBufferView
{
public:
-
/// Returns Vulkan buffer view object.
- virtual VkBufferView GetVkBufferView()const = 0;
+ virtual VkBufferView GetVkBufferView() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/BufferVk.h b/Graphics/GraphicsEngineVulkan/interface/BufferVk.h
index f17ced0f..63796abf 100644
--- a/Graphics/GraphicsEngineVulkan/interface/BufferVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/BufferVk.h
@@ -33,15 +33,14 @@ namespace Diligent
// {12D8EC02-96F4-431E-9695-C5F572CC7587}
static constexpr INTERFACE_ID IID_BufferVk =
-{ 0x12d8ec02, 0x96f4, 0x431e,{ 0x96, 0x95, 0xc5, 0xf5, 0x72, 0xcc, 0x75, 0x87 } };
+ {0x12d8ec02, 0x96f4, 0x431e, {0x96, 0x95, 0xc5, 0xf5, 0x72, 0xcc, 0x75, 0x87}};
/// Exposes Vulkan-specific functionality of a buffer object.
class IBufferVk : public IBuffer
{
public:
-
/// Returns a vulkan buffer handle
- virtual VkBuffer GetVkBuffer()const = 0;
+ virtual VkBuffer GetVkBuffer() const = 0;
/// Sets vulkan access flags
@@ -53,4 +52,4 @@ public:
virtual VkAccessFlags GetAccessFlags() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h b/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h
index 49524f88..62ae08c6 100644
--- a/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/CommandQueueVk.h
@@ -33,19 +33,19 @@ namespace Diligent
// {9FBF582F-3069-41B9-AC05-344D5AF5CE8C}
static constexpr INTERFACE_ID IID_CommandQueueVk =
-{ 0x9fbf582f, 0x3069, 0x41b9,{ 0xac, 0x5, 0x34, 0x4d, 0x5a, 0xf5, 0xce, 0x8c } };
+ {0x9fbf582f, 0x3069, 0x41b9, {0xac, 0x5, 0x34, 0x4d, 0x5a, 0xf5, 0xce, 0x8c}};
/// Command queue interface
class ICommandQueueVk : public Diligent::IObject
{
public:
- /// Returns the fence value that will be signaled next time
- virtual Uint64 GetNextFenceValue() = 0;
+ /// Returns the fence value that will be signaled next time
+ virtual Uint64 GetNextFenceValue() = 0;
- /// Submits a given command buffer to the command queue
+ /// Submits a given command buffer to the command queue
/// \return Fence value associated with the submitted command buffer
- virtual Uint64 Submit(VkCommandBuffer cmdBuffer) = 0;
+ virtual Uint64 Submit(VkCommandBuffer cmdBuffer) = 0;
/// Submits a given chunk of work to the command queue
@@ -59,7 +59,7 @@ public:
virtual VkQueue GetVkQueue() = 0;
/// Returns vulkan command queue family index
- virtual uint32_t GetQueueFamilyIndex()const = 0;
+ virtual uint32_t GetQueueFamilyIndex() const = 0;
/// Returns value of the last completed fence
virtual Uint64 GetCompletedFenceValue() = 0;
@@ -73,4 +73,4 @@ public:
virtual void SignalFence(VkFence vkFence) = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h b/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h
index 0218c143..d7776daa 100644
--- a/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/DeviceContextVk.h
@@ -34,26 +34,25 @@ namespace Diligent
// {72AEB1BA-C6AD-42EC-8811-7ED9C72176BB}
static constexpr INTERFACE_ID IID_DeviceContextVk =
-{ 0x72aeb1ba, 0xc6ad, 0x42ec,{ 0x88, 0x11, 0x7e, 0xd9, 0xc7, 0x21, 0x76, 0xbb } };
+ {0x72aeb1ba, 0xc6ad, 0x42ec, {0x88, 0x11, 0x7e, 0xd9, 0xc7, 0x21, 0x76, 0xbb}};
/// Exposes Vulkan-specific functionality of a device context.
class IDeviceContextVk : public IDeviceContext
{
public:
-
/// Transitions internal vulkan image to a specified layout
/// \param [in] pTexture - texture to transition
/// \param [in] NewLayout - Vulkan image layout this texture to transition to
/// \remarks The texture state must be known to the engine.
- virtual void TransitionImageLayout(ITexture *pTexture, VkImageLayout NewLayout) = 0;
+ virtual void TransitionImageLayout(ITexture* pTexture, VkImageLayout NewLayout) = 0;
/// Transitions internal vulkan buffer object to a specified state
/// \param [in] pBuffer - Buffer to transition
/// \param [in] NewAccessFlags - Access flags to set for the buffer
/// \remarks The buffer state must be known to the engine.
- virtual void BufferMemoryBarrier(IBuffer *pBuffer, VkAccessFlags NewAccessFlags) = 0;
+ virtual void BufferMemoryBarrier(IBuffer* pBuffer, VkAccessFlags NewAccessFlags) = 0;
/// Locks the internal mutex and returns a pointer to the command queue that is associated with this device context.
@@ -63,7 +62,7 @@ public:
///
/// The engine locks the internal mutex to prevent simultaneous access to the command queue.
/// An application must release the lock by calling IDeviceContextVk::UnlockCommandQueue()
- /// when it is done working with the queue or the engine will not be able to submit any command
+ /// when it is done working with the queue or the engine will not be able to submit any command
/// list to the queue. Nested calls to LockCommandQueue() are not allowed.
/// The queue pointer never changes while the context is alive, so an application may cache and
/// use the pointer if it does not need to prevent potential simultaneous access to the queue from
@@ -77,4 +76,4 @@ public:
virtual void UnlockCommandQueue() = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h b/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h
index 092b0912..2b3381ba 100644
--- a/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h
@@ -35,12 +35,12 @@
#if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || (PLATFORM_WIN32 && !defined(_MSC_VER))
- // https://gcc.gnu.org/wiki/Visibility
-# define API_QUALIFIER __attribute__((visibility("default")))
+// https://gcc.gnu.org/wiki/Visibility
+# define API_QUALIFIER __attribute__((visibility("default")))
#elif PLATFORM_WIN32
-# define API_QUALIFIER
+# define API_QUALIFIER
#else
# error Unsupported platform
@@ -50,8 +50,8 @@ namespace Diligent
{
// {F554EEE4-57C2-4637-A508-85BE80DC657C}
-static const INTERFACE_ID IID_EngineFactoryVk =
-{ 0xf554eee4, 0x57c2, 0x4637, { 0xa5, 0x8, 0x85, 0xbe, 0x80, 0xdc, 0x65, 0x7c } };
+static const INTERFACE_ID IID_EngineFactoryVk =
+ {0xf554eee4, 0x57c2, 0x4637, {0xa5, 0x8, 0x85, 0xbe, 0x80, 0xdc, 0x65, 0x7c}};
class IEngineFactoryVk : public IEngineFactory
{
@@ -60,10 +60,10 @@ public:
IRenderDevice** ppDevice,
IDeviceContext** ppContexts) = 0;
- //virtual void AttachToVulkanDevice(void *pVkNativeDevice,
+ //virtual void AttachToVulkanDevice(void *pVkNativeDevice,
// class ICommandQueueVk *pCommandQueue,
- // const EngineVkCreateInfo& EngineCI,
- // IRenderDevice **ppDevice,
+ // const EngineVkCreateInfo& EngineCI,
+ // IRenderDevice **ppDevice,
// IDeviceContext **ppContexts) = 0;
virtual void CreateSwapChainVk(IRenderDevice* pDevice,
@@ -71,61 +71,60 @@ public:
const SwapChainDesc& SwapChainDesc,
void* pNativeWndHandle,
ISwapChain** ppSwapChain) = 0;
-
};
#if ENGINE_DLL && PLATFORM_WIN32 && defined(_MSC_VER)
-# define EXPLICITLY_LOAD_ENGINE_VK_DLL 1
+# define EXPLICITLY_LOAD_ENGINE_VK_DLL 1
+
+typedef IEngineFactoryVk* (*GetEngineFactoryVkType)();
- typedef IEngineFactoryVk* (*GetEngineFactoryVkType)();
+static bool LoadGraphicsEngineVk(GetEngineFactoryVkType& GetFactoryFunc)
+{
+ GetFactoryFunc = nullptr;
+ std::string LibName = "GraphicsEngineVk_";
+
+# if _WIN64
+ LibName += "64";
+# else
+ LibName += "32";
+# endif
+
+# ifdef _DEBUG
+ LibName += "d";
+# else
+ LibName += "r";
+# endif
+
+ LibName += ".dll";
+ auto hModule = LoadLibraryA(LibName.c_str());
+ if (hModule == NULL)
+ {
+ std::stringstream ss;
+ ss << "Failed to load " << LibName << " library.\n";
+ OutputDebugStringA(ss.str().c_str());
+ return false;
+ }
- static bool LoadGraphicsEngineVk(GetEngineFactoryVkType& GetFactoryFunc)
+ GetFactoryFunc = reinterpret_cast<GetEngineFactoryVkType>(GetProcAddress(hModule, "GetEngineFactoryVk"));
+ if (GetFactoryFunc == NULL)
{
- GetFactoryFunc = nullptr;
- std::string LibName = "GraphicsEngineVk_";
-
-# if _WIN64
- LibName += "64";
-# else
- LibName += "32";
-# endif
-
-# ifdef _DEBUG
- LibName += "d";
-# else
- LibName += "r";
-# endif
-
- LibName += ".dll";
- auto hModule = LoadLibraryA(LibName.c_str());
- if (hModule == NULL)
- {
- std::stringstream ss;
- ss << "Failed to load " << LibName << " library.\n";
- OutputDebugStringA(ss.str().c_str());
- return false;
- }
-
- GetFactoryFunc = reinterpret_cast<GetEngineFactoryVkType>(GetProcAddress(hModule, "GetEngineFactoryVk"));
- if (GetFactoryFunc == NULL)
- {
- std::stringstream ss;
- ss << "Failed to load GetEngineFactoryVk() from " << LibName << " library.\n";
- OutputDebugStringA(ss.str().c_str());
- FreeLibrary(hModule);
- return false;
- }
-
- return true;
+ std::stringstream ss;
+ ss << "Failed to load GetEngineFactoryVk() from " << LibName << " library.\n";
+ OutputDebugStringA(ss.str().c_str());
+ FreeLibrary(hModule);
+ return false;
}
+ return true;
+}
+
#else
- API_QUALIFIER
- IEngineFactoryVk* GetEngineFactoryVk();
+API_QUALIFIER
+IEngineFactoryVk* GetEngineFactoryVk();
#endif
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/FenceVk.h b/Graphics/GraphicsEngineVulkan/interface/FenceVk.h
index 3ee4b944..bd8d1690 100644
--- a/Graphics/GraphicsEngineVulkan/interface/FenceVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/FenceVk.h
@@ -33,14 +33,12 @@ namespace Diligent
// {7610B4CD-EDEA-4951-82CF-52F97FAFED2D}
static constexpr INTERFACE_ID IID_FenceVk =
-{ 0x7610b4cd, 0xedea, 0x4951, { 0x82, 0xcf, 0x52, 0xf9, 0x7f, 0xaf, 0xed, 0x2d } };
+ {0x7610b4cd, 0xedea, 0x4951, {0x82, 0xcf, 0x52, 0xf9, 0x7f, 0xaf, 0xed, 0x2d}};
/// Exposes Vulkan-specific functionality of a fence object.
class IFenceVk : public IFence
{
-public:
-
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/PipelineStateVk.h b/Graphics/GraphicsEngineVulkan/interface/PipelineStateVk.h
index 492022c9..0948445c 100644
--- a/Graphics/GraphicsEngineVulkan/interface/PipelineStateVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/PipelineStateVk.h
@@ -33,19 +33,18 @@ namespace Diligent
// {2FEA0868-0932-412A-9F0A-7CEA7E61B5E0}
static constexpr INTERFACE_ID IID_PipelineStateVk =
-{ 0x2fea0868, 0x932, 0x412a,{ 0x9f, 0xa, 0x7c, 0xea, 0x7e, 0x61, 0xb5, 0xe0 } };
+ {0x2fea0868, 0x932, 0x412a, {0x9f, 0xa, 0x7c, 0xea, 0x7e, 0x61, 0xb5, 0xe0}};
/// Exposes Vulkan-specific functionality of a pipeline state object.
class IPipelineStateVk : public IPipelineState
{
public:
-
/// Returns handle to a vulkan render pass object.
- virtual VkRenderPass GetVkRenderPass()const = 0;
+ virtual VkRenderPass GetVkRenderPass() const = 0;
/// Returns handle to a vulkan pipeline pass object.
- virtual VkPipeline GetVkPipeline()const = 0;
+ virtual VkPipeline GetVkPipeline() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h b/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h
index 4e24d246..785950a3 100644
--- a/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/RenderDeviceVk.h
@@ -33,13 +33,12 @@ namespace Diligent
// {AB8CF3A6-D959-41C1-AE00-A58AE9820E6A}
static constexpr INTERFACE_ID IID_RenderDeviceVk =
-{ 0xab8cf3a6, 0xd959, 0x41c1,{ 0xae, 0x0, 0xa5, 0x8a, 0xe9, 0x82, 0xe, 0x6a } };
+ {0xab8cf3a6, 0xd959, 0x41c1, {0xae, 0x0, 0xa5, 0x8a, 0xe9, 0x82, 0xe, 0x6a}};
/// Exposes Vulkan-specific functionality of a render device.
class IRenderDeviceVk : public IRenderDevice
{
public:
-
/// Returns logical Vulkan device handle
virtual VkDevice GetVkDevice() = 0;
@@ -56,35 +55,35 @@ public:
/// Creates a texture object from native Vulkan image
/// \param [in] vkImage - Vulkan image handle
- /// \param [in] TexDesc - Texture description. Vulkan provides no means to retrieve any
+ /// \param [in] TexDesc - Texture description. Vulkan provides no means to retrieve any
/// image properties from the image handle, so complete texture
/// description must be provided
/// \param [in] InitialState - Initial texture state. See Diligent::RESOURCE_STATE.
/// \param [out] ppTexture - Address of the memory location where the pointer to the
- /// texture interface will be stored.
- /// The function calls AddRef(), so that the new object will contain
+ /// texture interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
/// one reference.
/// \note Created texture object does not take ownership of the Vulkan image and will not
- /// destroy it once released. The application must not destroy the image while it is
+ /// destroy it once released. The application must not destroy the image while it is
/// in use by the engine.
virtual void CreateTextureFromVulkanImage(VkImage vkImage,
const TextureDesc& TexDesc,
RESOURCE_STATE InitialState,
- ITexture** ppTexture) = 0;
+ ITexture** ppTexture) = 0;
/// Creates a buffer object from native Vulkan resource
/// \param [in] vkBuffer - Vulkan buffer handle
- /// \param [in] BuffDesc - Buffer description. Vulkan provides no means to retrieve any
+ /// \param [in] BuffDesc - Buffer description. Vulkan provides no means to retrieve any
/// buffer properties from the buffer handle, so complete buffer
/// description must be provided
/// \param [in] InitialState - Initial buffer state. See Diligent::RESOURCE_STATE.
/// \param [out] ppBuffer - Address of the memory location where the pointer to the
- /// buffer interface will be stored.
- /// The function calls AddRef(), so that the new object will contain
+ /// buffer interface will be stored.
+ /// The function calls AddRef(), so that the new object will contain
/// one reference.
/// \note Created buffer object does not take ownership of the Vulkan buffer and will not
- /// destroy it once released. The application must not destroy Vulkan buffer while it is
+ /// destroy it once released. The application must not destroy Vulkan buffer while it is
/// in use by the engine.
virtual void CreateBufferFromVulkanResource(VkBuffer vkBuffer,
const BufferDesc& BuffDesc,
@@ -92,4 +91,4 @@ public:
IBuffer** ppBuffer) = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/SamplerVk.h b/Graphics/GraphicsEngineVulkan/interface/SamplerVk.h
index 9ca14a5b..d2819440 100644
--- a/Graphics/GraphicsEngineVulkan/interface/SamplerVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/SamplerVk.h
@@ -33,15 +33,14 @@ namespace Diligent
// {87C21E88-8A9F-4AD2-9A1E-D5EC140415EA}
static constexpr INTERFACE_ID IID_SamplerVk =
-{ 0x87c21e88, 0x8a9f, 0x4ad2,{ 0x9a, 0x1e, 0xd5, 0xec, 0x14, 0x4, 0x15, 0xea } };
+ {0x87c21e88, 0x8a9f, 0x4ad2, {0x9a, 0x1e, 0xd5, 0xec, 0x14, 0x4, 0x15, 0xea}};
/// Exposes Vulkan-specific functionality of a sampler object.
class ISamplerVk : public ISampler
{
public:
-
/// Returns a vulkan sampler object handle
- virtual VkSampler GetVkSampler()const = 0;
+ virtual VkSampler GetVkSampler() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/ShaderResourceBindingVk.h b/Graphics/GraphicsEngineVulkan/interface/ShaderResourceBindingVk.h
index 370869e1..8f2de085 100644
--- a/Graphics/GraphicsEngineVulkan/interface/ShaderResourceBindingVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/ShaderResourceBindingVk.h
@@ -33,13 +33,11 @@ namespace Diligent
// {1E8C82DC-5B3A-47D5-8AE9-197CAE8DB71F}
static constexpr INTERFACE_ID IID_ShaderResourceBindingVk =
-{ 0x1e8c82dc, 0x5b3a, 0x47d5,{ 0x8a, 0xe9, 0x19, 0x7c, 0xae, 0x8d, 0xb7, 0x1f } };
+ {0x1e8c82dc, 0x5b3a, 0x47d5, {0x8a, 0xe9, 0x19, 0x7c, 0xae, 0x8d, 0xb7, 0x1f}};
/// Exposes Vulkan-specific functionality of a shader resource binding object.
class IShaderResourceBindingVk : public IShaderResourceBinding
{
-public:
-
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/ShaderVk.h b/Graphics/GraphicsEngineVulkan/interface/ShaderVk.h
index 232e00b0..6daf22f5 100644
--- a/Graphics/GraphicsEngineVulkan/interface/ShaderVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/ShaderVk.h
@@ -34,15 +34,14 @@ namespace Diligent
// {8B0C91B4-B1D8-4E03-9250-A70E131A59FA}
static constexpr INTERFACE_ID IID_ShaderVk =
-{ 0x8b0c91b4, 0xb1d8, 0x4e03,{ 0x92, 0x50, 0xa7, 0xe, 0x13, 0x1a, 0x59, 0xfa } };
+ {0x8b0c91b4, 0xb1d8, 0x4e03, {0x92, 0x50, 0xa7, 0xe, 0x13, 0x1a, 0x59, 0xfa}};
/// Exposes Vulkan-specific functionality of a shader object.
class IShaderVk : public IShader
{
public:
-
/// Returns SPIRV bytecode
- virtual const std::vector<uint32_t>& GetSPIRV()const = 0;
+ virtual const std::vector<uint32_t>& GetSPIRV() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h b/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h
index 470c5144..64e6e212 100644
--- a/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/SwapChainVk.h
@@ -36,15 +36,14 @@ namespace Diligent
// {22A39881-5EC5-4A9C-8395-90215F04A5CC}
static constexpr INTERFACE_ID IID_SwapChainVk =
-{ 0x22a39881, 0x5ec5, 0x4a9c,{ 0x83, 0x95, 0x90, 0x21, 0x5f, 0x4, 0xa5, 0xcc } };
+ {0x22a39881, 0x5ec5, 0x4a9c, {0x83, 0x95, 0x90, 0x21, 0x5f, 0x4, 0xa5, 0xcc}};
/// Exposes Vulkan-specific functionality of a swap chain.
class ISwapChainVk : public ISwapChain
{
public:
-
/// Returns a handle to the Vulkan swap chain object.
virtual VkSwapchainKHR GetVkSwapChain() = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/TextureViewVk.h b/Graphics/GraphicsEngineVulkan/interface/TextureViewVk.h
index 0092b02d..9846c330 100644
--- a/Graphics/GraphicsEngineVulkan/interface/TextureViewVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/TextureViewVk.h
@@ -33,15 +33,14 @@ namespace Diligent
// {B02AA468-3328-46F3-9777-55E97BF6C86E}
static constexpr INTERFACE_ID IID_TextureViewVk =
-{ 0xb02aa468, 0x3328, 0x46f3,{ 0x97, 0x77, 0x55, 0xe9, 0x7b, 0xf6, 0xc8, 0x6e } };
+ {0xb02aa468, 0x3328, 0x46f3, {0x97, 0x77, 0x55, 0xe9, 0x7b, 0xf6, 0xc8, 0x6e}};
/// Exposes Vulkan-specific functionality of a texture view object.
class ITextureViewVk : public ITextureView
{
public:
-
/// Returns Vulkan image view handle
- virtual VkImageView GetVulkanImageView()const = 0;
+ virtual VkImageView GetVulkanImageView() const = 0;
};
-}
+} // namespace Diligent
diff --git a/Graphics/GraphicsEngineVulkan/interface/TextureVk.h b/Graphics/GraphicsEngineVulkan/interface/TextureVk.h
index 3900032f..619fefb5 100644
--- a/Graphics/GraphicsEngineVulkan/interface/TextureVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/TextureVk.h
@@ -33,18 +33,17 @@ namespace Diligent
// {3BB9155F-22C5-4365-927E-8C4049F9B949}
static constexpr INTERFACE_ID IID_TextureVk =
-{ 0x3bb9155f, 0x22c5, 0x4365,{ 0x92, 0x7e, 0x8c, 0x40, 0x49, 0xf9, 0xb9, 0x49 } };
+ {0x3bb9155f, 0x22c5, 0x4365, {0x92, 0x7e, 0x8c, 0x40, 0x49, 0xf9, 0xb9, 0x49}};
/// Exposes Vulkan-specific functionality of a texture object.
class ITextureVk : public ITexture
{
public:
-
/// Returns Vulkan image handle.
-
+
/// The application must not release the returned image
- virtual VkImage GetVkImage()const = 0;
+ virtual VkImage GetVkImage() const = 0;
/// Sets Vulkan image layout
@@ -54,7 +53,7 @@ public:
virtual void SetLayout(VkImageLayout Layout) = 0;
/// Returns current Vulkan image layout. If the state is unknown to the engine, returns VK_IMAGE_LAYOUT_UNDEFINED
- virtual VkImageLayout GetLayout()const = 0;
+ virtual VkImageLayout GetLayout() const = 0;
};
-}
+} // namespace Diligent