summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-07-19 04:00:21 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-07-19 04:00:21 +0000
commit6c0571d498d3516e27aa1fb4bf2488e2fc6b5244 (patch)
tree5da8521f3960bf921b355c2b072b6d3bab1e6288 /Graphics/GraphicsEngineVulkan
parentAdded NarrowString(const wchar_t* WideStr) overload (diff)
downloadDiligentCore-6c0571d498d3516e27aa1fb4bf2488e2fc6b5244.tar.gz
DiligentCore-6c0571d498d3516e27aa1fb4bf2488e2fc6b5244.zip
Added Development configuration tests in Vulkan backend; fixed code formatting
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h3
-rw-r--r--Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h12
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h10
-rw-r--r--Graphics/GraphicsEngineVulkan/include/PipelineLayout.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h4
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h8
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h8
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h64
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h6
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDescriptorPool.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h19
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h38
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h10
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanUploadHeap.h4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp56
-rw-r--r--Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp22
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp216
-rw-r--r--Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp18
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp62
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp14
-rw-r--r--Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp20
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp20
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp12
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp10
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp10
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBuffer.cpp28
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp5
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDescriptorPool.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanFencePool.cpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp28
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp44
31 files changed, 415 insertions, 346 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h
index 8f7e74b4..6c88c16e 100644
--- a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h
@@ -54,8 +54,9 @@ public:
virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject** ppInterface );
virtual VkBufferView GetVkBufferView()const override final{return m_BuffView;}
+
const BufferVkImpl* GetBufferVk()const;
- BufferVkImpl* GetBufferVk();
+ BufferVkImpl* GetBufferVk();
protected:
diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h
index 9bcd789d..e4a0edf4 100644
--- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h
@@ -66,8 +66,8 @@ public:
virtual void Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData )override;
virtual void Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags )override;
-#ifdef _DEBUG
- void DbgVerifyDynamicAllocation(Uint32 ContextId)const;
+#ifdef DEVELOPMENT
+ void DvpVerifyDynamicAllocation(Uint32 ContextId)const;
#endif
Uint32 GetDynamicOffset(Uint32 CtxId)const
@@ -80,8 +80,8 @@ public:
{
VERIFY(m_Desc.Usage == USAGE_DYNAMIC, "Dynamic buffer is expected");
VERIFY_EXPR(!m_DynamicAllocations.empty());
-#ifdef _DEBUG
- DbgVerifyDynamicAllocation(CtxId);
+#ifdef DEVELOPMENT
+ DvpVerifyDynamicAllocation(CtxId);
#endif
auto& DynAlloc = m_DynamicAllocations[CtxId];
return static_cast<Uint32>(DynAlloc.Offset);
@@ -116,8 +116,8 @@ private:
VulkanUtilities::BufferViewWrapper CreateView(struct BufferViewDesc &ViewDesc);
VkAccessFlags m_AccessFlags = 0;
-#ifdef _DEBUG
- std::vector< std::pair<MAP_TYPE, Uint32> > m_DbgMapType;
+#ifdef DEVELOPMENT
+ std::vector< std::pair<MAP_TYPE, Uint32> > m_DvpMapType;
#endif
std::vector<VulkanDynamicAllocation, STDAllocatorRawMem<VulkanDynamicAllocation> > m_DynamicAllocations;
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
index 79cbc04a..0e40553c 100644
--- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
@@ -38,10 +38,6 @@
#include "PipelineLayout.h"
#include "GenerateMipsVkHelper.h"
-#ifdef _DEBUG
-# define VERIFY_CONTEXT_BINDINGS
-#endif
-
namespace Diligent
{
@@ -171,7 +167,7 @@ private:
inline void DisposeCurrentCmdBuffer(Uint64 FenceValue);
void ReleaseStaleContextResources(Uint64 SubmittedCmdBufferNumber, Uint64 SubmittedFenceValue, Uint64 CompletedFenceValue);
- void DbgLogRenderPass_PSOMismatch();
+ void DvpLogRenderPass_PSOMismatch();
VulkanUtilities::VulkanCommandBuffer m_CommandBuffer;
@@ -203,9 +199,9 @@ private:
VulkanUtilities::VulkanCommandBufferPool m_CmdPool;
// Semaphores are not owned by the command context
- std::vector<VkSemaphore> m_WaitSemaphores;
+ std::vector<VkSemaphore> m_WaitSemaphores;
std::vector<VkPipelineStageFlags> m_WaitDstStageMasks;
- std::vector<VkSemaphore> m_SignalSemaphores;
+ std::vector<VkSemaphore> m_SignalSemaphores;
std::unordered_map<BufferVkImpl*, VulkanUtilities::VulkanUploadAllocation> m_UploadAllocations;
ResourceReleaseQueue<DynamicStaleResourceWrapper> m_ReleaseQueue;
diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineLayout.h b/Graphics/GraphicsEngineVulkan/include/PipelineLayout.h
index d179b959..9d2ef248 100644
--- a/Graphics/GraphicsEngineVulkan/include/PipelineLayout.h
+++ b/Graphics/GraphicsEngineVulkan/include/PipelineLayout.h
@@ -91,7 +91,7 @@ public:
Uint32 SetCout = 0;
Uint32 DynamicOffsetCount = 0;
#ifdef _DEBUG
- const PipelineLayout* pDbgPipelineLayout = nullptr;
+ const PipelineLayout* pDbgPipelineLayout = nullptr;
#endif
DescriptorSetBindInfo() :
vkSets(2),
diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h
index fa50a025..e06d853d 100644
--- a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h
@@ -115,8 +115,8 @@ private:
std::unique_ptr<class ShaderResourceBindingVkImpl, STDDeleter<ShaderResourceBindingVkImpl, FixedBlockMemoryAllocator> > m_pDefaultShaderResBinding;
VkRenderPass m_RenderPass = VK_NULL_HANDLE; // Render passes are managed by the render device
- VulkanUtilities::PipelineWrapper m_Pipeline;
- PipelineLayout m_PipelineLayout;
+ VulkanUtilities::PipelineWrapper m_Pipeline;
+ PipelineLayout m_PipelineLayout;
bool m_HasStaticResources = false;
bool m_HasNonStaticResources = false;
};
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
index 17b21d16..019501eb 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
@@ -103,10 +103,6 @@
#include "SPIRVShaderResources.h"
#include "VulkanUtilities/VulkanLogicalDevice.h"
-#ifdef _DEBUG
-# define VERIFY_SHADER_BINDINGS
-#endif
-
namespace Diligent
{
@@ -222,8 +218,8 @@ public:
ShaderResourceCacheVk& SrcResourceCache,
ShaderResourceCacheVk& DstResourceCache)const;
-#ifdef VERIFY_SHADER_BINDINGS
- void dbgVerifyBindings(const ShaderResourceCacheVk& ResourceCache)const;
+#ifdef DEVELOPMENT
+ void dvpVerifyBindings(const ShaderResourceCacheVk& ResourceCache)const;
#endif
Uint32 GetResourceCount(SHADER_VARIABLE_TYPE VarType)const
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h
index 6764f301..2c6d7272 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h
@@ -33,10 +33,6 @@
#include "SPIRVShaderResources.h"
#include "ShaderVariableVk.h"
-#ifdef DEVELOPMENT
-# define VERIFY_SHADER_BINDINGS
-#endif
-
namespace Diligent
{
@@ -67,8 +63,8 @@ public:
const ShaderResourceLayoutVk& GetStaticResLayout()const{return m_StaticResLayout;}
ShaderResourceCacheVk& GetStaticResCache(){return m_StaticResCache;}
-#ifdef VERIFY_SHADER_BINDINGS
- void DbgVerifyStaticResourceBindings();
+#ifdef DEVELOPMENT
+ void DvpVerifyStaticResourceBindings();
#endif
private:
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h
index 63c44e80..9859af10 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBuffer.h
@@ -57,7 +57,9 @@ namespace VulkanUtilities
{
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, "The aspectMask of all image subresource ranges must only include VK_IMAGE_ASPECT_DEPTH_BIT or VK_IMAGE_ASPECT_STENCIL_BIT(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,
@@ -145,7 +147,7 @@ namespace VulkanUtilities
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)
+ if (m_State.RenderPass != RenderPass || m_State.Framebuffer != Framebuffer)
{
VkRenderPassBeginInfo BeginInfo;
BeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
@@ -201,7 +203,7 @@ namespace VulkanUtilities
{
// 9.8
VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if(m_State.ComputePipeline != ComputePipeline)
+ if (m_State.ComputePipeline != ComputePipeline)
{
vkCmdBindPipeline(m_VkCmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, ComputePipeline);
m_State.ComputePipeline = ComputePipeline;
@@ -212,7 +214,7 @@ namespace VulkanUtilities
{
// 9.8
VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if(m_State.GraphicsPipeline != GraphicsPipeline)
+ if (m_State.GraphicsPipeline != GraphicsPipeline)
{
vkCmdBindPipeline(m_VkCmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, GraphicsPipeline);
m_State.GraphicsPipeline = GraphicsPipeline;
@@ -246,9 +248,9 @@ namespace VulkanUtilities
void BindIndexBuffer(VkBuffer Buffer, VkDeviceSize Offset, VkIndexType IndexType)
{
VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if(m_State.IndexBuffer != Buffer ||
- m_State.IndexBufferOffset != Offset ||
- m_State.IndexType != IndexType)
+ if (m_State.IndexBuffer != Buffer ||
+ m_State.IndexBufferOffset != Offset ||
+ m_State.IndexType != IndexType)
{
vkCmdBindIndexBuffer(m_VkCmdBuffer, Buffer, Offset, IndexType);
m_State.IndexBuffer = Buffer;
@@ -263,23 +265,23 @@ namespace VulkanUtilities
vkCmdBindVertexBuffers(m_VkCmdBuffer, firstBinding, bindingCount, pBuffers, pOffsets);
}
- static void TransitionImageLayout(VkCommandBuffer CmdBuffer,
- VkImage Image,
- VkImageLayout OldLayout,
- VkImageLayout NewLayout,
+ static void TransitionImageLayout(VkCommandBuffer CmdBuffer,
+ VkImage Image,
+ VkImageLayout OldLayout,
+ VkImageLayout NewLayout,
const VkImageSubresourceRange& SubresRange,
- VkPipelineStageFlags SrcStages = 0,
- VkPipelineStageFlags DestStages = 0);
+ VkPipelineStageFlags SrcStages = 0,
+ VkPipelineStageFlags DestStages = 0);
- void TransitionImageLayout(VkImage Image,
- VkImageLayout OldLayout,
- VkImageLayout NewLayout,
+ void TransitionImageLayout(VkImage Image,
+ VkImageLayout OldLayout,
+ VkImageLayout NewLayout,
const VkImageSubresourceRange& SubresRange,
- VkPipelineStageFlags SrcStages = 0,
- VkPipelineStageFlags DestStages = 0)
+ VkPipelineStageFlags SrcStages = 0,
+ VkPipelineStageFlags DestStages = 0)
{
VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if(m_State.RenderPass != VK_NULL_HANDLE)
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
// Image layout transitions within a render pass execute
// dependencies between attachments
@@ -303,7 +305,7 @@ namespace VulkanUtilities
VkPipelineStageFlags DestStages = 0)
{
VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if(m_State.RenderPass != VK_NULL_HANDLE)
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
// Image layout transitions within a render pass execute
// dependencies between attachments
@@ -330,7 +332,7 @@ namespace VulkanUtilities
const VkBufferCopy* pRegions)
{
VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if(m_State.RenderPass != VK_NULL_HANDLE)
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
// Copy buffer operation must be performed outside of render pass.
EndRenderPass();
@@ -346,7 +348,7 @@ namespace VulkanUtilities
const VkImageCopy* pRegions)
{
VERIFY_EXPR(m_VkCmdBuffer != VK_NULL_HANDLE);
- if(m_State.RenderPass != VK_NULL_HANDLE)
+ if (m_State.RenderPass != VK_NULL_HANDLE)
{
// Copy operations must be performed outside of render pass.
EndRenderPass();
@@ -365,15 +367,15 @@ namespace VulkanUtilities
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;
+ 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;}
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h
index f37727d5..98edc3d8 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h
@@ -36,9 +36,9 @@ namespace VulkanUtilities
{
public:
VulkanCommandBufferPool(std::shared_ptr<const VulkanUtilities::VulkanLogicalDevice> LogicalDevice,
- uint32_t queueFamilyIndex,
- VkCommandPoolCreateFlags flags,
- bool IsThreadSafe);
+ uint32_t queueFamilyIndex,
+ VkCommandPoolCreateFlags flags,
+ bool IsThreadSafe);
VulkanCommandBufferPool (const VulkanCommandBufferPool&) = delete;
VulkanCommandBufferPool (VulkanCommandBufferPool&&) = delete;
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDescriptorPool.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDescriptorPool.h
index 97cd7f94..34bbb99d 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDescriptorPool.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanDescriptorPool.h
@@ -35,7 +35,7 @@ namespace VulkanUtilities
{
public:
VulkanDescriptorPool(std::shared_ptr<const VulkanUtilities::VulkanLogicalDevice> LogicalDevice,
- const VkDescriptorPoolCreateInfo &DescriptorPoolCI)noexcept;
+ const VkDescriptorPoolCreateInfo& DescriptorPoolCI);
VulkanDescriptorPool (const VulkanDescriptorPool&) = delete;
VulkanDescriptorPool& operator = (const VulkanDescriptorPool&) = delete;
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h
index 4738c7e7..9a60a7fd 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanInstance.h
@@ -53,23 +53,24 @@ namespace VulkanUtilities
return shared_from_this();
}
- bool IsLayerAvailable(const char *LayerName)const;
- bool IsExtensionAvailable(const char *ExtensionName)const;
- VkPhysicalDevice SelectPhysicalDevice();
+ 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;}
+ VkInstance GetVkInstance() const{return m_VkInstance;}
private:
- VulkanInstance(bool EnableValidation,
- uint32_t GlobalExtensionCount,
- const char* const* ppGlobalExtensionNames,
+ VulkanInstance(bool EnableValidation,
+ uint32_t GlobalExtensionCount,
+ const char* const* ppGlobalExtensionNames,
VkAllocationCallbacks* pVkAllocator);
bool m_ValidationEnabled = false;
VkAllocationCallbacks* const m_pVkAllocator;
VkInstance m_VkInstance = VK_NULL_HANDLE;
- std::vector<VkLayerProperties> m_Layers;
+
+ std::vector<VkLayerProperties> m_Layers;
std::vector<VkExtensionProperties> m_Extensions;
- std::vector<VkPhysicalDevice> m_PhysicalDevices;
+ std::vector<VkPhysicalDevice> m_PhysicalDevices;
};
}
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
index e40b357c..6fd7e33c 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
@@ -63,26 +63,26 @@ namespace VulkanUtilities
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;
+ 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;
+ 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;
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h
index 829ccd45..5e67138e 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanPhysicalDevice.h
@@ -51,11 +51,11 @@ namespace VulkanUtilities
private:
VulkanPhysicalDevice(VkPhysicalDevice vkDevice);
- const VkPhysicalDevice m_VkDevice;
- VkPhysicalDeviceProperties m_Properties = {};
- VkPhysicalDeviceFeatures m_Features = {};
- VkPhysicalDeviceMemoryProperties m_MemoryProperties = {};
+ const VkPhysicalDevice m_VkDevice;
+ VkPhysicalDeviceProperties m_Properties = {};
+ VkPhysicalDeviceFeatures m_Features = {};
+ VkPhysicalDeviceMemoryProperties m_MemoryProperties = {};
std::vector<VkQueueFamilyProperties> m_QueueFamilyProperties;
- std::vector<VkExtensionProperties> m_SupportedExtensions;
+ std::vector<VkExtensionProperties> m_SupportedExtensions;
};
}
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanUploadHeap.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanUploadHeap.h
index 19282886..1302f795 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanUploadHeap.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanUploadHeap.h
@@ -56,9 +56,9 @@ public:
VkDeviceSize HostVisibleReserveSize);
VulkanUploadHeap(VulkanUploadHeap&& rhs)noexcept :
- VulkanMemoryManager(std::move(rhs)),
+ VulkanMemoryManager (std::move(rhs)),
m_StagingBufferMemoryTypeIndex(rhs.m_StagingBufferMemoryTypeIndex),
- m_Buffers(std::move(rhs.m_Buffers))
+ m_Buffers (std::move(rhs.m_Buffers))
{
}
VulkanUploadHeap (const VulkanUploadHeap&) = delete;
diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp
index eedcac82..90cc149f 100644
--- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp
@@ -43,8 +43,8 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters,
const BufferData& BuffData /*= BufferData()*/) :
TBufferBase(pRefCounters, BuffViewObjMemAllocator, pRenderDeviceVk, BuffDesc, false),
m_AccessFlags(0),
-#ifdef _DEBUG
- m_DbgMapType(1 + pRenderDeviceVk->GetNumDeferredContexts()),
+#ifdef DEVELOPMENT
+ m_DvpMapType(1 + pRenderDeviceVk->GetNumDeferredContexts()),
#endif
m_DynamicAllocations(STD_ALLOCATOR_RAW_MEM(VulkanDynamicAllocation, GetRawAllocator(), "Allocator for vector<VulkanDynamicAllocation>"))
{
@@ -177,7 +177,8 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters,
auto AlignedStagingMemOffset = (StagingMemoryAllocation.UnalignedOffset + (StagingBufferMemReqs.alignment-1)) & ~(StagingBufferMemReqs.alignment-1);
auto *StagingData = reinterpret_cast<uint8_t*>(StagingMemoryAllocation.Page->GetCPUMemory());
- VERIFY_EXPR(StagingData != nullptr);
+ if (StagingData == nullptr)
+ LOG_BUFFER_ERROR_AND_THROW("Failed to allocate staging data");
memcpy(StagingData + AlignedStagingMemOffset, BuffData.pData, BuffData.DataSize);
err = LogicalDevice.BindBufferMemory(StagingBuffer, StagingBufferMemory, AlignedStagingMemOffset);
@@ -244,8 +245,8 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters,
VkBuffer vkBuffer) :
TBufferBase(pRefCounters, BuffViewObjMemAllocator, pRenderDeviceVk, BuffDesc, false),
m_AccessFlags(0),
-#ifdef _DEBUG
- m_DbgMapType(1 + pRenderDeviceVk->GetNumDeferredContexts()),
+#ifdef DEVELOPMENT
+ m_DvpMapType(1 + pRenderDeviceVk->GetNumDeferredContexts()),
#endif
m_DynamicAllocations(STD_ALLOCATOR_RAW_MEM(VulkanDynamicAllocation, GetRawAllocator(), "Allocator for vector<VulkanDynamicAllocation>")),
m_VulkanBuffer(vkBuffer)
@@ -287,12 +288,13 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF
auto* pDeviceContextVk = ValidatedCast<DeviceContextVkImpl>(pContext);
auto* pDeviceVk = GetDevice<RenderDeviceVkImpl>();
-#ifdef _DEBUG
+#ifdef DEVELOPMENT
if(pDeviceContextVk != nullptr)
- m_DbgMapType[pDeviceContextVk->GetContextId()] = std::make_pair(MapType, MapFlags);
+ m_DvpMapType[pDeviceContextVk->GetContextId()] = std::make_pair(MapType, MapFlags);
#endif
if (MapType == MAP_READ )
{
+ LOG_ERROR("Mapping buffer for reading is not yet imlemented");
UNSUPPORTED("Mapping buffer for reading is not yet imlemented");
#if 0
LOG_WARNING_MESSAGE_ONCE("Mapping CPU buffer for reading on Vk currently requires flushing context and idling GPU");
@@ -310,6 +312,7 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF
{
if (m_Desc.Usage == USAGE_CPU_ACCESSIBLE)
{
+ LOG_ERROR("Not implemented");
UNSUPPORTED("Not implemented");
#if 0
VERIFY(m_pVkResource != nullptr, "USAGE_CPU_ACCESSIBLE buffer mapped for writing must intialize Vk resource");
@@ -322,7 +325,14 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF
}
else if (m_Desc.Usage == USAGE_DYNAMIC)
{
- VERIFY(MapFlags & MAP_FLAG_DISCARD, "Vk buffer must be mapped for writing with MAP_FLAG_DISCARD flag");
+#ifdef DEVELOPMENT
+ if( (MapFlags & MAP_FLAG_DISCARD) == 0 )
+ {
+ LOG_ERROR_MESSAGE("Failed to map buffer '", m_Desc.Name, "': Vk buffer must be mapped for writing with MAP_FLAG_DISCARD flag. Context Id: ", pDeviceContextVk->GetContextId());
+ return;
+ }
+#endif
+
auto DynAlloc = pDeviceContextVk->AllocateDynamicSpace(m_Desc.uiSizeInBytes);
if(DynAlloc.pParentDynamicHeap != nullptr)
{
@@ -357,16 +367,25 @@ void BufferVkImpl::Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 Map
auto *pDeviceContextVk = ValidatedCast<DeviceContextVkImpl>(pContext);
Uint32 CtxId = pDeviceContextVk != nullptr ? pDeviceContextVk->GetContextId() : static_cast<Uint32>(-1);
-#ifdef _DEBUG
+#ifdef DEVELOPMENT
if (pDeviceContextVk != nullptr)
{
- VERIFY(m_DbgMapType[CtxId].first == MapType, "Map type does not match the type provided to Map()");
- VERIFY(m_DbgMapType[CtxId].second == MapFlags, "Map flags do not match the flags provided to Map()");
+ if (m_DvpMapType[CtxId].first != MapType)
+ {
+ LOG_ERROR_MESSAGE("Failed to unmap buffer '", m_Desc.Name, "': Map type (", GetMapTypeString(MapType), ") does not match the type provided to Map() (", GetMapTypeString(m_DvpMapType[CtxId].first), "). Context Id: ", CtxId);
+ return;
+ }
+ if (m_DvpMapType[CtxId].second != MapFlags)
+ {
+ LOG_ERROR_MESSAGE("Failed to unmap buffer '", m_Desc.Name, "': Map flags (", MapFlags, ") do not match the flags provided to Map() (", m_DvpMapType[CtxId].second, "). Context Id: ", CtxId);
+ return;
+ }
}
#endif
if (MapType == MAP_READ )
{
+ LOG_ERROR("This map type is not yet supported");
UNSUPPORTED("This map type is not yet supported");
#if 0
Vk_RANGE MapRange;
@@ -380,6 +399,7 @@ void BufferVkImpl::Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 Map
{
if (m_Desc.Usage == USAGE_CPU_ACCESSIBLE)
{
+ LOG_ERROR("This map type is not yet supported");
UNSUPPORTED("This map type is not yet supported");
#if 0
VERIFY(m_pVkResource != nullptr, "USAGE_CPU_ACCESSIBLE buffer mapped for writing must intialize Vk resource");
@@ -398,9 +418,9 @@ void BufferVkImpl::Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 Map
}
}
-#ifdef _DEBUG
+#ifdef DEVELOPMENT
if(pDeviceContextVk != nullptr)
- m_DbgMapType[CtxId] = std::make_pair(static_cast<MAP_TYPE>(-1), static_cast<Uint32>(-1));
+ m_DvpMapType[CtxId] = std::make_pair(static_cast<MAP_TYPE>(-1), static_cast<Uint32>(-1));
#endif
}
@@ -471,13 +491,15 @@ VkBuffer BufferVkImpl::GetVkBuffer()const
}
}
-#ifdef _DEBUG
-void BufferVkImpl::DbgVerifyDynamicAllocation(Uint32 ContextId)const
+#ifdef DEVELOPMENT
+void BufferVkImpl::DvpVerifyDynamicAllocation(Uint32 ContextId)const
{
const auto& DynAlloc = m_DynamicAllocations[ContextId];
- VERIFY(DynAlloc.pParentDynamicHeap != nullptr, "Dynamic buffer must be mapped before the first use");
+ if (DynAlloc.pParentDynamicHeap == nullptr)
+ LOG_ERROR_MESSAGE("Dynamic buffer '", m_Desc.Name, "' was not mapped before its first use. Context Id: ", ContextId);
auto CurrentFrame = GetDevice<RenderDeviceVkImpl>()->GetCurrentFrameNumber();
- VERIFY(DynAlloc.dbgFrameNumber == CurrentFrame, "Dynamic allocation is out-of-date. Dynamic buffer \"", m_Desc.Name, "\" must be mapped in the same frame it is used.");
+ if (DynAlloc.dbgFrameNumber != CurrentFrame)
+ LOG_ERROR_MESSAGE("Dynamic allocation is out-of-date. Dynamic buffer '", m_Desc.Name, "' must be mapped in the same frame it is used.");
}
#endif
diff --git a/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp
index 3ca86233..92fd5f85 100644
--- a/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp
@@ -32,11 +32,11 @@ CommandQueueVkImpl::CommandQueueVkImpl(IReferenceCounters*
std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> LogicalDevice,
uint32_t QueueFamilyIndex) :
TBase(pRefCounters),
- m_LogicalDevice(LogicalDevice),
- m_VkQueue(LogicalDevice->GetQueue(QueueFamilyIndex, 0)),
- m_QueueFamilyIndex(QueueFamilyIndex),
- m_NextFenceValue(1),
- m_FencePool(LogicalDevice)
+ m_LogicalDevice (LogicalDevice),
+ m_VkQueue (LogicalDevice->GetQueue(QueueFamilyIndex, 0)),
+ m_QueueFamilyIndex (QueueFamilyIndex),
+ m_NextFenceValue (1),
+ m_FencePool (LogicalDevice)
{
}
@@ -46,7 +46,7 @@ CommandQueueVkImpl::~CommandQueueVkImpl()
// All queues associated with a logical device are destroyed when vkDestroyDevice
// is called on that device.
- while(!m_PendingFences.empty())
+ while (!m_PendingFences.empty())
{
m_FencePool.DisposeFence(std::move(m_PendingFences.front().second));
m_PendingFences.pop_front();
@@ -105,12 +105,12 @@ void CommandQueueVkImpl::IdleGPU()
// Increment fence before idling the queue
Atomics::AtomicIncrement(m_NextFenceValue);
vkQueueWaitIdle(m_VkQueue);
- if(LastCompletedFenceValue > m_LastCompletedFenceValue)
+ if (LastCompletedFenceValue > m_LastCompletedFenceValue)
m_LastCompletedFenceValue = LastCompletedFenceValue;
- for(auto& val_fence : m_PendingFences)
+ for (auto& val_fence : m_PendingFences)
{
// For some reason after idling the queue not all fences are signaled
- while(m_LogicalDevice->GetFenceStatus(val_fence.second) != VK_SUCCESS)
+ while (m_LogicalDevice->GetFenceStatus(val_fence.second) != VK_SUCCESS)
{
VkFence FenceToWait = val_fence.second;
auto res = vkWaitForFences(m_LogicalDevice->GetVkDevice(), 1, &FenceToWait, VK_TRUE, UINT64_MAX);
@@ -128,13 +128,13 @@ Uint64 CommandQueueVkImpl::GetCompletedFenceValue()
{
std::lock_guard<std::mutex> Lock(m_QueueMutex);
- while(!m_PendingFences.empty())
+ while (!m_PendingFences.empty())
{
auto &Value_Fence = m_PendingFences.front();
auto status = m_LogicalDevice->GetFenceStatus(Value_Fence.second);
if(status == VK_SUCCESS)
{
- if(Value_Fence.first > m_LastCompletedFenceValue)
+ if (Value_Fence.first > m_LastCompletedFenceValue)
m_LastCompletedFenceValue = Value_Fence.first;
m_FencePool.DisposeFence(std::move(Value_Fence.second));
m_PendingFences.pop_front();
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index c4bc0753..febcc1d7 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -36,7 +36,7 @@ namespace Diligent
{
static std::string GetUploadHeapName(bool bIsDeferred, Uint32 ContextId)
{
- if(bIsDeferred)
+ if (bIsDeferred)
{
std::stringstream ss;
ss << "Upload heap of deferred context #" << ContextId;
@@ -121,7 +121,7 @@ namespace Diligent
DeviceContextVkImpl::~DeviceContextVkImpl()
{
auto *pDeviceVkImpl = m_pDevice.RawPtr<RenderDeviceVkImpl>();
- if(m_bIsDeferred)
+ if (m_bIsDeferred)
{
DisposeCurrentCmdBuffer(pDeviceVkImpl->GetNextFenceValue());
// There must be no resources in the stale resource list. All outstanding resources (if any) must be in the
@@ -165,7 +165,7 @@ namespace Diligent
{
VERIFY(m_CommandBuffer.GetState().RenderPass == VK_NULL_HANDLE, "Disposing command buffer with unifinished render pass");
auto vkCmdBuff = m_CommandBuffer.GetVkCmdBuffer();
- if(vkCmdBuff != VK_NULL_HANDLE)
+ if (vkCmdBuff != VK_NULL_HANDLE)
{
DisposeVkCmdBuffer(vkCmdBuff, FenceValue);
m_CommandBuffer.Reset();
@@ -191,7 +191,7 @@ namespace Diligent
bool CommitStates = false;
bool CommitScissor = false;
- if(!m_pPipelineState)
+ if (!m_pPipelineState)
{
// If no pipeline state is bound, we are working with the fresh command
// list. We have to commit the states set in the context that are not
@@ -223,7 +223,7 @@ namespace Diligent
auto vkPipeline = pPipelineStateVk->GetVkPipeline();
m_CommandBuffer.BindGraphicsPipeline(vkPipeline);
- if(CommitStates)
+ if (CommitStates)
{
m_CommandBuffer.SetStencilReference(m_StencilRef);
m_CommandBuffer.SetBlendConstants(m_BlendFactors);
@@ -231,7 +231,7 @@ namespace Diligent
CommitViewports();
}
- if(PSODesc.GraphicsPipeline.RasterizerDesc.ScissorEnable && (CommitStates || CommitScissor))
+ if (PSODesc.GraphicsPipeline.RasterizerDesc.ScissorEnable && (CommitStates || CommitScissor))
{
CommitScissorRects();
}
@@ -277,28 +277,29 @@ namespace Diligent
void DeviceContextVkImpl::TransitionVkVertexBuffers()
{
- for( UINT Buff = 0; Buff < m_NumVertexStreams; ++Buff )
+ for ( UINT Buff = 0; Buff < m_NumVertexStreams; ++Buff )
{
auto &CurrStream = m_VertexStreams[Buff];
VERIFY( CurrStream.pBuffer, "Attempting to bind a null buffer for rendering" );
auto *pBufferVk = CurrStream.pBuffer.RawPtr<BufferVkImpl>();
- if(!pBufferVk->CheckAccessFlags(VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT))
+ if (!pBufferVk->CheckAccessFlags(VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT))
BufferMemoryBarrier(*pBufferVk, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT);
}
}
void DeviceContextVkImpl::CommitVkVertexBuffers()
{
-#ifdef _DEBUG
+#ifdef DEVELOPMENT
auto *pPipelineStateVk = m_pPipelineState.RawPtr<PipelineStateVkImpl>();
- VERIFY( m_NumVertexStreams >= pPipelineStateVk->GetNumBufferSlotsUsed(), "Currently bound pipeline state \"", pPipelineStateVk->GetDesc().Name, "\" expects ", pPipelineStateVk->GetNumBufferSlotsUsed(), " input buffer slots, but only ", m_NumVertexStreams, " is bound");
+ if (m_NumVertexStreams < pPipelineStateVk->GetNumBufferSlotsUsed())
+ LOG_ERROR("Currently bound pipeline state \"", pPipelineStateVk->GetDesc().Name, "\" expects ", pPipelineStateVk->GetNumBufferSlotsUsed(), " input buffer slots, but only ", m_NumVertexStreams, " is bound");
#endif
// Do not initialize array with zeroes for performance reasons
VkBuffer vkVertexBuffers[MaxBufferSlots];// = {}
VkDeviceSize Offsets[MaxBufferSlots];
VERIFY( m_NumVertexStreams <= MaxBufferSlots, "Too many buffers are being set" );
bool DynamicBufferPresent = false;
- for( UINT slot = 0; slot < m_NumVertexStreams; ++slot )
+ for ( UINT slot = 0; slot < m_NumVertexStreams; ++slot )
{
auto &CurrStream = m_VertexStreams[slot];
VERIFY( CurrStream.pBuffer, "Attempting to bind a null buffer for rendering" );
@@ -307,11 +308,11 @@ namespace Diligent
if (pBufferVk->GetDesc().Usage == USAGE_DYNAMIC)
{
DynamicBufferPresent = true;
-#ifdef _DEBUG
- pBufferVk->DbgVerifyDynamicAllocation(m_ContextId);
+#ifdef DEVELOPMENT
+ pBufferVk->DvpVerifyDynamicAllocation(m_ContextId);
#endif
}
- if(!pBufferVk->CheckAccessFlags(VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT))
+ if (!pBufferVk->CheckAccessFlags(VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT))
BufferMemoryBarrier(*pBufferVk, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT);
// Device context keeps strong references to all vertex buffers.
@@ -321,14 +322,14 @@ namespace Diligent
}
//GraphCtx.FlushResourceBarriers();
- if(m_NumVertexStreams > 0)
+ if (m_NumVertexStreams > 0)
m_CommandBuffer.BindVertexBuffers( 0, m_NumVertexStreams, vkVertexBuffers, Offsets );
// GPU offset for a dynamic vertex buffer can change every time a draw command is invoked
m_State.CommittedVBsUpToDate = !DynamicBufferPresent;
}
- void DeviceContextVkImpl::DbgLogRenderPass_PSOMismatch()
+ void DeviceContextVkImpl::DvpLogRenderPass_PSOMismatch()
{
std::stringstream ss;
ss << "Active render pass is incomaptible with PSO '" << m_pPipelineState->GetDesc().Name << "'. "
@@ -336,10 +337,10 @@ namespace Diligent
"and the PSO. Vulkand requires exact match.\n"
" Bound render targets (" << m_NumBoundRenderTargets << "):";
Uint32 SampleCount = 0;
- for(Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
+ for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
{
ss << ' ';
- if(auto* pRTV = m_pBoundRenderTargets[rt].RawPtr())
+ if (auto* pRTV = m_pBoundRenderTargets[rt].RawPtr())
{
VERIFY_EXPR(SampleCount == 0 || SampleCount == pRTV->GetTexture()->GetDesc().SampleCount);
SampleCount = pRTV->GetTexture()->GetDesc().SampleCount;
@@ -349,7 +350,7 @@ namespace Diligent
ss << "<Not set>";
}
ss << "; DSV: ";
- if(m_pBoundDepthStencil)
+ if (m_pBoundDepthStencil)
{
VERIFY_EXPR(SampleCount == 0 || SampleCount == m_pBoundDepthStencil->GetTexture()->GetDesc().SampleCount);
SampleCount = m_pBoundDepthStencil->GetTexture()->GetDesc().SampleCount;
@@ -361,7 +362,7 @@ namespace Diligent
const auto& GrPipeline = m_pPipelineState->GetDesc().GraphicsPipeline;
ss << "\n PSO: render targets (" << Uint32{GrPipeline.NumRenderTargets} << "): ";
- for(Uint32 rt = 0; rt < GrPipeline.NumRenderTargets; ++rt)
+ for (Uint32 rt = 0; rt < GrPipeline.NumRenderTargets; ++rt)
ss << ' ' << GetTextureFormatAttribs(GrPipeline.RTVFormats[rt]).Name;
ss << "; DSV: " << GetTextureFormatAttribs(GrPipeline.DSVFormat).Name;
ss << "; Sample count: " << Uint32{GrPipeline.SmplDesc.Count};
@@ -371,7 +372,7 @@ namespace Diligent
void DeviceContextVkImpl::Draw( DrawAttribs &DrawAttribs )
{
-#ifdef _DEBUG
+#ifdef DEVELOPMENT
if (!m_pPipelineState)
{
LOG_ERROR("No pipeline state is bound");
@@ -388,12 +389,18 @@ namespace Diligent
EnsureVkCmdBuffer();
- if( DrawAttribs.IsIndexed )
+ if ( DrawAttribs.IsIndexed )
{
- VERIFY( m_pIndexBuffer != nullptr, "Index buffer is not set up for indexed draw command" );
+#ifdef DEVELOPMENT
+ if (m_pIndexBuffer == nullptr)
+ {
+ LOG_ERROR("Index buffer is not set up for indexed draw command");
+ return;
+ }
+#endif
BufferVkImpl *pBuffVk = m_pIndexBuffer.RawPtr<BufferVkImpl>();
- if(!pBuffVk->CheckAccessFlags(VK_ACCESS_INDEX_READ_BIT))
+ if (!pBuffVk->CheckAccessFlags(VK_ACCESS_INDEX_READ_BIT))
BufferMemoryBarrier(*pBuffVk, VK_ACCESS_INDEX_READ_BIT);
VERIFY(DrawAttribs.IndexType == VT_UINT16 || DrawAttribs.IndexType == VT_UINT32, "Unsupported index format. Only R16_UINT and R32_UINT are allowed.");
@@ -401,54 +408,60 @@ namespace Diligent
m_CommandBuffer.BindIndexBuffer(pBuffVk->GetVkBuffer(), m_IndexDataStartOffset + pBuffVk->GetDynamicOffset(m_ContextId), vkIndexType);
}
- if(m_State.CommittedVBsUpToDate)
+ if (m_State.CommittedVBsUpToDate)
TransitionVkVertexBuffers();
else
CommitVkVertexBuffers();
- if(m_DesrSetBindInfo.DynamicOffsetCount != 0)
+ if (m_DesrSetBindInfo.DynamicOffsetCount != 0)
pPipelineStateVk->BindDescriptorSetsWithDynamicOffsets(this, m_DesrSetBindInfo);
#if 0
#ifdef _DEBUG
else
{
- if( pPipelineStateVk->dbgContainsShaderResources() )
+ if ( pPipelineStateVk->dbgContainsShaderResources() )
LOG_ERROR_MESSAGE("Pipeline state \"", pPipelineStateVk->GetDesc().Name, "\" contains shader resources, but IDeviceContext::CommitShaderResources() was not called" );
}
#endif
#endif
- if( DrawAttribs.IsIndirect )
+ if ( DrawAttribs.IsIndirect )
{
- VERIFY(DrawAttribs.pIndirectDrawAttribs != nullptr, "Valid pIndirectDrawAttribs must be provided for indirect draw command");
+#ifdef DEVELOPMENT
+ if (DrawAttribs.pIndirectDrawAttribs == nullptr)
+ {
+ LOG_ERROR("Valid pIndirectDrawAttribs must be provided for indirect draw command");
+ return;
+ }
+#endif
auto *pBufferVk = ValidatedCast<BufferVkImpl>(DrawAttribs.pIndirectDrawAttribs);
// Buffer memory barries must be executed outside of render pass
- if(!pBufferVk->CheckAccessFlags(VK_ACCESS_INDIRECT_COMMAND_READ_BIT))
+ if (!pBufferVk->CheckAccessFlags(VK_ACCESS_INDIRECT_COMMAND_READ_BIT))
BufferMemoryBarrier(*pBufferVk, VK_ACCESS_INDIRECT_COMMAND_READ_BIT);
}
-#ifdef _DEBUG
- if(pPipelineStateVk->GetVkRenderPass() != m_RenderPass)
+#ifdef DEVELOPMENT
+ if (pPipelineStateVk->GetVkRenderPass() != m_RenderPass)
{
- DbgLogRenderPass_PSOMismatch();
+ DvpLogRenderPass_PSOMismatch();
}
#endif
CommitRenderPassAndFramebuffer();
- if( DrawAttribs.IsIndirect )
+ if ( DrawAttribs.IsIndirect )
{
- if( auto *pBufferVk = ValidatedCast<BufferVkImpl>(DrawAttribs.pIndirectDrawAttribs) )
+ if ( auto *pBufferVk = ValidatedCast<BufferVkImpl>(DrawAttribs.pIndirectDrawAttribs) )
{
-#ifdef _DEBUG
- if(pBufferVk->GetDesc().Usage == USAGE_DYNAMIC)
- pBufferVk->DbgVerifyDynamicAllocation(m_ContextId);
+#ifdef DEVELOPMENT
+ if (pBufferVk->GetDesc().Usage == USAGE_DYNAMIC)
+ pBufferVk->DvpVerifyDynamicAllocation(m_ContextId);
#endif
- if(!pBufferVk->CheckAccessFlags(VK_ACCESS_INDIRECT_COMMAND_READ_BIT))
+ if (!pBufferVk->CheckAccessFlags(VK_ACCESS_INDIRECT_COMMAND_READ_BIT))
BufferMemoryBarrier(*pBufferVk, VK_ACCESS_INDIRECT_COMMAND_READ_BIT);
- if( DrawAttribs.IsIndexed )
+ if ( DrawAttribs.IsIndexed )
m_CommandBuffer.DrawIndexedIndirect(pBufferVk->GetVkBuffer(), pBufferVk->GetDynamicOffset(m_ContextId) + DrawAttribs.IndirectDrawArgsOffset, 1, 0);
else
m_CommandBuffer.DrawIndirect(pBufferVk->GetVkBuffer(), pBufferVk->GetDynamicOffset(m_ContextId) + DrawAttribs.IndirectDrawArgsOffset, 1, 0);
@@ -456,7 +469,7 @@ namespace Diligent
}
else
{
- if( DrawAttribs.IsIndexed )
+ if ( DrawAttribs.IsIndexed )
m_CommandBuffer.DrawIndexed(DrawAttribs.NumIndices, DrawAttribs.NumInstances, DrawAttribs.FirstIndexLocation, DrawAttribs.BaseVertex, DrawAttribs.FirstInstanceLocation);
else
m_CommandBuffer.Draw(DrawAttribs.NumVertices, DrawAttribs.NumInstances, DrawAttribs.StartVertexLocation, DrawAttribs.FirstInstanceLocation );
@@ -467,7 +480,7 @@ namespace Diligent
void DeviceContextVkImpl::DispatchCompute( const DispatchComputeAttribs &DispatchAttrs )
{
-#ifdef _DEBUG
+#ifdef DEVELOPMENT
if (!m_pPipelineState)
{
LOG_ERROR("No pipeline state is bound");
@@ -494,19 +507,19 @@ namespace Diligent
#ifdef _DEBUG
else
{
- if( pPipelineStateVk->dbgContainsShaderResources() )
+ if ( pPipelineStateVk->dbgContainsShaderResources() )
LOG_ERROR_MESSAGE("Pipeline state \"", pPipelineStateVk->GetDesc().Name, "\" contains shader resources, but IDeviceContext::CommitShaderResources() was not called" );
}
#endif
#endif
- if( DispatchAttrs.pIndirectDispatchAttribs )
+ if ( DispatchAttrs.pIndirectDispatchAttribs )
{
- if( auto *pBufferVk = ValidatedCast<BufferVkImpl>(DispatchAttrs.pIndirectDispatchAttribs) )
+ if ( auto *pBufferVk = ValidatedCast<BufferVkImpl>(DispatchAttrs.pIndirectDispatchAttribs) )
{
-#ifdef _DEBUG
- if(pBufferVk->GetDesc().Usage == USAGE_DYNAMIC)
- pBufferVk->DbgVerifyDynamicAllocation(m_ContextId);
+#ifdef DEVELOPMENT
+ if (pBufferVk->GetDesc().Usage == USAGE_DYNAMIC)
+ pBufferVk->DvpVerifyDynamicAllocation(m_ContextId);
#endif
// Buffer memory barries must be executed outside of render pass
@@ -529,12 +542,16 @@ namespace Diligent
void DeviceContextVkImpl::ClearDepthStencil( ITextureView* pView, Uint32 ClearFlags, float fDepth, Uint8 Stencil )
{
ITextureViewVk* pVkDSV = nullptr;
- if( pView != nullptr )
+ if ( pView != nullptr )
{
pVkDSV = ValidatedCast<ITextureViewVk>(pView);
-#ifdef _DEBUG
+#ifdef DEVELOPMENT
const auto& ViewDesc = pVkDSV->GetDesc();
- VERIFY( ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL, "Incorrect view type: depth stencil is expected" );
+ if ( ViewDesc.ViewType != TEXTURE_VIEW_DEPTH_STENCIL)
+ {
+ LOG_ERROR("The type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), ") of texture view '", pView->GetDesc().Name, "' is incorrect for ClearDepthStencil operation. Depth-stencil view (TEXTURE_VIEW_DEPTH_STENCIL) must be provided." );
+ return;
+ }
#endif
}
else
@@ -555,7 +572,7 @@ namespace Diligent
const auto& ViewDesc = pVkDSV->GetDesc();
VERIFY(ViewDesc.TextureDim != RESOURCE_DIM_TEX_3D, "Depth-stencil view of a 3D texture should've been created as 2D texture array view");
- if(pVkDSV == m_pBoundDepthStencil)
+ if (pVkDSV == m_pBoundDepthStencil)
{
// Render pass may not be currently committed
VERIFY_EXPR(m_RenderPass != VK_NULL_HANDLE && m_Framebuffer != VK_NULL_HANDLE);
@@ -583,7 +600,7 @@ namespace Diligent
else
{
// End render pass to clear the buffer with vkCmdClearDepthStencilImage
- if(m_CommandBuffer.GetState().RenderPass != VK_NULL_HANDLE)
+ if (m_CommandBuffer.GetState().RenderPass != VK_NULL_HANDLE)
m_CommandBuffer.EndRenderPass();
auto* pTexture = pVkDSV->GetTexture();
@@ -614,9 +631,9 @@ namespace Diligent
{
VkClearColorValue ClearValue;
const auto& FmtAttribs = GetTextureFormatAttribs(TexFmt);
- if(FmtAttribs.ComponentType == COMPONENT_TYPE_SINT)
+ if (FmtAttribs.ComponentType == COMPONENT_TYPE_SINT)
{
- for(int i=0; i < 4; ++i)
+ for (int i=0; i < 4; ++i)
ClearValue.int32[i] = static_cast<int32_t>(RGBA[i]);
}
else if (FmtAttribs.ComponentType == COMPONENT_TYPE_UINT)
@@ -636,11 +653,15 @@ namespace Diligent
void DeviceContextVkImpl::ClearRenderTarget( ITextureView *pView, const float *RGBA )
{
ITextureViewVk* pVkRTV = nullptr;
- if( pView != nullptr )
+ if ( pView != nullptr )
{
-#ifdef _DEBUG
+#ifdef DEVELOPMENT
const auto& ViewDesc = pView->GetDesc();
- VERIFY( ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET, "Incorrect view type: render target is expected" );
+ if ( ViewDesc.ViewType != TEXTURE_VIEW_RENDER_TARGET)
+ {
+ LOG_ERROR("The type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), ") of texture view '", pView->GetDesc().Name, "' is incorrect for ClearRenderTarget operation. Render target view (TEXTURE_VIEW_RENDER_TARGET) must be provided." );
+ return;
+ }
#endif
pVkRTV = ValidatedCast<ITextureViewVk>(pView);
}
@@ -658,7 +679,7 @@ namespace Diligent
}
static constexpr float Zero[4] = { 0.f, 0.f, 0.f, 0.f };
- if( RGBA == nullptr )
+ if ( RGBA == nullptr )
RGBA = Zero;
EnsureVkCmdBuffer();
@@ -669,16 +690,16 @@ namespace Diligent
// Check if the texture is one of the currently bound render targets
static constexpr const Uint32 InvalidAttachmentIndex = static_cast<Uint32>(-1);
Uint32 attachmentIndex = InvalidAttachmentIndex;
- for(Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
+ for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
{
- if(m_pBoundRenderTargets[rt] == pVkRTV)
+ if (m_pBoundRenderTargets[rt] == pVkRTV)
{
attachmentIndex = rt;
break;
}
}
- if(attachmentIndex != InvalidAttachmentIndex)
+ if (attachmentIndex != InvalidAttachmentIndex)
{
// Render pass may not be currently committed
VERIFY_EXPR(m_RenderPass != VK_NULL_HANDLE && m_Framebuffer != VK_NULL_HANDLE);
@@ -706,7 +727,7 @@ namespace Diligent
else
{
// End current render pass and clear the image with vkCmdClearColorImage
- if(m_CommandBuffer.GetState().RenderPass != VK_NULL_HANDLE)
+ if (m_CommandBuffer.GetState().RenderPass != VK_NULL_HANDLE)
m_CommandBuffer.EndRenderPass();
auto* pTexture = pVkRTV->GetTexture();
@@ -749,7 +770,13 @@ namespace Diligent
void DeviceContextVkImpl::Flush()
{
- VERIFY(!m_bIsDeferred, "Flush() should only be called for immediate contexts");
+#ifdef DEVELOPMENT
+ if (m_bIsDeferred)
+ {
+ LOG_ERROR("Flush() should only be called for immediate contexts");
+ return;
+ }
+#endif
VkSubmitInfo SubmitInfo = {};
SubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
@@ -757,7 +784,7 @@ namespace Diligent
auto pDeviceVkImpl = m_pDevice.RawPtr<RenderDeviceVkImpl>();
auto vkCmdBuff = m_CommandBuffer.GetVkCmdBuffer();
- if(vkCmdBuff != VK_NULL_HANDLE )
+ if (vkCmdBuff != VK_NULL_HANDLE )
{
VERIFY(!m_bIsDeferred, "Deferred contexts cannot execute command lists directly");
if (m_State.NumCommands != 0)
@@ -783,7 +810,7 @@ namespace Diligent
SubmitInfo.pSignalSemaphores = SubmitInfo.signalSemaphoreCount != 0 ? m_SignalSemaphores.data() : nullptr;
// Submit command buffer even if there are no commands to release stale resources.
- //if(SubmitInfo.commandBufferCount != 0 || SubmitInfo.waitSemaphoreCount !=0 || SubmitInfo.signalSemaphoreCount != 0)
+ //if (SubmitInfo.commandBufferCount != 0 || SubmitInfo.waitSemaphoreCount !=0 || SubmitInfo.signalSemaphoreCount != 0)
auto SubmittedFenceValue = pDeviceVkImpl->ExecuteCommandBuffer(SubmitInfo, this);
m_WaitSemaphores.clear();
@@ -837,7 +864,7 @@ namespace Diligent
void DeviceContextVkImpl::CommitViewports()
{
VkViewport VkViewports[MaxViewports]; // Do not waste time initializing array to zero
- for( Uint32 vp = 0; vp < m_NumViewports; ++vp )
+ for ( Uint32 vp = 0; vp < m_NumViewports; ++vp )
{
VkViewports[vp].x = m_Viewports[vp].TopLeftX;
VkViewports[vp].y = m_Viewports[vp].TopLeftY;
@@ -911,10 +938,10 @@ namespace Diligent
// Only commit scissor rects if scissor test is enabled in the rasterizer state.
// If scissor is currently disabled, or no PSO is bound, scissor rects will be committed by
// the SetPipelineState() when a PSO with enabled scissor test is set.
- if( m_pPipelineState )
+ if ( m_pPipelineState )
{
const auto &PSODesc = m_pPipelineState->GetDesc();
- if(!PSODesc.IsComputePipeline && PSODesc.GraphicsPipeline.RasterizerDesc.ScissorEnable)
+ if (!PSODesc.IsComputePipeline && PSODesc.GraphicsPipeline.RasterizerDesc.ScissorEnable)
{
VERIFY(NumRects == m_NumScissorRects, "Unexpected number of scissor rects");
CommitScissorRects();
@@ -941,9 +968,9 @@ namespace Diligent
TransitionImageLayout(pDepthBuffer, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
}
- for(Uint32 rt=0; rt < m_NumBoundRenderTargets; ++rt)
+ for (Uint32 rt=0; rt < m_NumBoundRenderTargets; ++rt)
{
- if(ITextureView* pRTV = m_pBoundRenderTargets[rt])
+ if (ITextureView* pRTV = m_pBoundRenderTargets[rt])
{
auto* pRTVVk = ValidatedCast<TextureViewVkImpl>(pRTV);
auto* pRenderTarget = pRTVVk->GetTexture();
@@ -957,11 +984,11 @@ namespace Diligent
void DeviceContextVkImpl::SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil )
{
- if( TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil ) )
+ if ( TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil ) )
{
FramebufferCache::FramebufferCacheKey FBKey;
RenderPassCache::RenderPassCacheKey RenderPassKey;
- if(m_pBoundDepthStencil)
+ if (m_pBoundDepthStencil)
{
auto* pDSVVk = m_pBoundDepthStencil.RawPtr<TextureViewVkImpl>();
auto* pDepthBuffer = pDSVVk->GetTexture();
@@ -978,15 +1005,15 @@ namespace Diligent
FBKey.NumRenderTargets = m_NumBoundRenderTargets;
RenderPassKey.NumRenderTargets = static_cast<Uint8>(m_NumBoundRenderTargets);
- for(Uint32 rt=0; rt < m_NumBoundRenderTargets; ++rt)
+ for (Uint32 rt=0; rt < m_NumBoundRenderTargets; ++rt)
{
- if(ITextureView* pRTV = m_pBoundRenderTargets[rt])
+ if (ITextureView* pRTV = m_pBoundRenderTargets[rt])
{
auto* pRTVVk = ValidatedCast<TextureViewVkImpl>(pRTV);
auto* pRenderTarget = pRTVVk->GetTexture();
FBKey.RTVs[rt] = pRTVVk->GetVulkanImageView();
RenderPassKey.RTVFormats[rt] = pRenderTarget->GetDesc().Format;
- if(RenderPassKey.SampleCount == 0)
+ if (RenderPassKey.SampleCount == 0)
RenderPassKey.SampleCount = static_cast<Uint8>(pRenderTarget->GetDesc().SampleCount);
else
VERIFY(RenderPassKey.SampleCount == pRenderTarget->GetDesc().SampleCount, "Inconsistent sample count");
@@ -1017,13 +1044,19 @@ namespace Diligent
void DeviceContextVkImpl::ResetRenderTargets()
{
TDeviceContextBase::ResetRenderTargets();
- m_RenderPass = VK_NULL_HANDLE;
+ m_RenderPass = VK_NULL_HANDLE;
m_Framebuffer = VK_NULL_HANDLE;
}
void DeviceContextVkImpl::UpdateBufferRegion(BufferVkImpl* pBuffVk, Uint64 DstOffset, Uint64 NumBytes, VkBuffer vkSrcBuffer, Uint64 SrcOffset)
{
- VERIFY(DstOffset + NumBytes <= pBuffVk->GetDesc().uiSizeInBytes, "Update region is out of buffer");
+#ifdef DEVELOPMENT
+ if (DstOffset + NumBytes > pBuffVk->GetDesc().uiSizeInBytes)
+ {
+ LOG_ERROR("Update region is out of buffer bounds which will result in an undefined behavior");
+ }
+#endif
+
EnsureVkCmdBuffer();
if (!pBuffVk->CheckAccessFlags(VK_ACCESS_TRANSFER_WRITE_BIT))
{
@@ -1040,7 +1073,14 @@ namespace Diligent
void DeviceContextVkImpl::UpdateBufferRegion(BufferVkImpl *pBuffVk, const void *pData, Uint64 DstOffset, Uint64 NumBytes)
{
- VERIFY(pBuffVk->GetDesc().Usage != USAGE_DYNAMIC, "Dynamic buffers must be updated via Map()");
+#ifdef DEVELOPMENT
+ if (pBuffVk->GetDesc().Usage == USAGE_DYNAMIC)
+ {
+ LOG_ERROR("Dynamic buffers must be updated via Map()");
+ return;
+ }
+#endif
+
VERIFY_EXPR( static_cast<size_t>(NumBytes) == NumBytes );
auto TmpSpace = m_UploadHeap.Allocate(static_cast<size_t>(NumBytes));
auto CPUAddress = TmpSpace.MemAllocation.Page->GetCPUMemory();
@@ -1054,12 +1094,18 @@ namespace Diligent
void DeviceContextVkImpl::CopyBufferRegion(BufferVkImpl *pSrcBuffVk, BufferVkImpl *pDstBuffVk, Uint64 SrcOffset, Uint64 DstOffset, Uint64 NumBytes)
{
- VERIFY(pDstBuffVk->GetDesc().Usage != USAGE_DYNAMIC, "Dynamic buffers cannot be copy destinations");
+#ifdef DEVELOPMENT
+ if (pDstBuffVk->GetDesc().Usage == USAGE_DYNAMIC)
+ {
+ LOG_ERROR("Dynamic buffers cannot be copy destinations");
+ return;
+ }
+#endif
EnsureVkCmdBuffer();
- if(!pSrcBuffVk->CheckAccessFlags(VK_ACCESS_TRANSFER_READ_BIT))
+ if (!pSrcBuffVk->CheckAccessFlags(VK_ACCESS_TRANSFER_READ_BIT))
BufferMemoryBarrier(*pSrcBuffVk, VK_ACCESS_TRANSFER_READ_BIT);
- if(!pDstBuffVk->CheckAccessFlags(VK_ACCESS_TRANSFER_WRITE_BIT))
+ if (!pDstBuffVk->CheckAccessFlags(VK_ACCESS_TRANSFER_WRITE_BIT))
BufferMemoryBarrier(*pDstBuffVk, VK_ACCESS_TRANSFER_WRITE_BIT);
VkBufferCopy CopyRegion;
CopyRegion.srcOffset = SrcOffset + pSrcBuffVk->GetDynamicOffset(m_ContextId);
@@ -1074,11 +1120,11 @@ namespace Diligent
void DeviceContextVkImpl::CopyTextureRegion(TextureVkImpl *pSrcTexture, TextureVkImpl *pDstTexture, const VkImageCopy &CopyRegion)
{
EnsureVkCmdBuffer();
- if(pSrcTexture->GetLayout() != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
+ if (pSrcTexture->GetLayout() != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
{
TransitionImageLayout(*pSrcTexture, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
}
- if(pDstTexture->GetLayout() != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
+ if (pDstTexture->GetLayout() != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
{
TransitionImageLayout(*pDstTexture, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
}
@@ -1316,7 +1362,7 @@ namespace Diligent
void DeviceContextVkImpl::CopyAndFreeDynamicUploadData(BufferVkImpl* pBuffer)
{
auto it = m_UploadAllocations.find(pBuffer);
- if(it != m_UploadAllocations.end())
+ if (it != m_UploadAllocations.end())
{
VERIFY_EXPR(pBuffer->GetDesc().uiSizeInBytes <= it->second.MemAllocation.Size);
UpdateBufferRegion(pBuffer, 0, pBuffer->GetDesc().uiSizeInBytes, it->second.vkBuffer, it->second.MemAllocation.UnalignedOffset);
diff --git a/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp b/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp
index d3fbd6c5..a8a4a045 100644
--- a/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp
@@ -49,7 +49,7 @@ bool FramebufferCache::FramebufferCacheKey::operator == (const FramebufferCacheK
size_t FramebufferCache::FramebufferCacheKey::GetHash()const
{
- if(Hash == 0)
+ if (Hash == 0)
{
Hash = ComputeHash(Pass, NumRenderTargets, DSV);
for(Uint32 rt = 0; rt < NumRenderTargets; ++rt)
@@ -62,7 +62,7 @@ VkFramebuffer FramebufferCache::GetFramebuffer(const FramebufferCacheKey& Key, u
{
std::lock_guard<std::mutex> Lock(m_Mutex);
auto it = m_Cache.find(Key);
- if(it != m_Cache.end())
+ if (it != m_Cache.end())
{
return it->second;
}
@@ -76,9 +76,9 @@ VkFramebuffer FramebufferCache::GetFramebuffer(const FramebufferCacheKey& Key, u
FramebufferCI.attachmentCount = (Key.DSV != VK_NULL_HANDLE ? 1 : 0) + Key.NumRenderTargets;
VkImageView Attachments[1 + MaxRenderTargets];
uint32_t attachment = 0;
- if(Key.DSV != VK_NULL_HANDLE)
+ if (Key.DSV != VK_NULL_HANDLE)
Attachments[attachment++] = Key.DSV;
- for(Uint32 rt=0; rt < Key.NumRenderTargets; ++rt)
+ for (Uint32 rt=0; rt < Key.NumRenderTargets; ++rt)
Attachments[attachment++] = Key.RTVs[rt];
VERIFY_EXPR(attachment == FramebufferCI.attachmentCount);
FramebufferCI.pAttachments = Attachments;
@@ -92,10 +92,10 @@ VkFramebuffer FramebufferCache::GetFramebuffer(const FramebufferCacheKey& Key, u
VERIFY(new_it.second, "New framebuffer must be inserted into the map");
m_RenderPassToKeyMap.emplace(Key.Pass, Key);
- if(Key.DSV != VK_NULL_HANDLE)
+ if (Key.DSV != VK_NULL_HANDLE)
m_ViewToKeyMap.emplace(Key.DSV, Key);
- for(Uint32 rt=0; rt < Key.NumRenderTargets; ++rt)
- if(Key.RTVs[rt] != VK_NULL_HANDLE)
+ for (Uint32 rt=0; rt < Key.NumRenderTargets; ++rt)
+ if (Key.RTVs[rt] != VK_NULL_HANDLE)
m_ViewToKeyMap.emplace(Key.RTVs[rt], Key);
return fb;
@@ -117,12 +117,12 @@ void FramebufferCache::OnDestroyImageView(VkImageView ImgView)
std::lock_guard<std::mutex> Lock(m_Mutex);
auto equal_range = m_ViewToKeyMap.equal_range(ImgView);
- for(auto it = equal_range.first; it != equal_range.second; ++it)
+ for (auto it = equal_range.first; it != equal_range.second; ++it)
{
auto fb_it = m_Cache.find(it->second);
// Multiple image views may be associated with the same key.
// The framebuffer is deleted whenever any of the image views is deleted
- if(fb_it != m_Cache.end())
+ if (fb_it != m_Cache.end())
{
m_DeviceVk.SafeReleaseVkObject(std::move(fb_it->second));
m_Cache.erase(fb_it);
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp
index 3a415d04..6ee46d16 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp
@@ -98,7 +98,7 @@ void PipelineLayout::DescriptorSetLayoutManager::DescriptorSetLayout::AddBinding
ReserveMemory(NumLayoutBindings + 1, MemAllocator);
pBindings[NumLayoutBindings++] = Binding;
TotalDescriptors += Binding.descriptorCount;
- if(Binding.descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
+ if (Binding.descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
Binding.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)
{
VERIFY(NumDynamicDescriptors + Binding.descriptorCount <= std::numeric_limits<decltype(NumDynamicDescriptors)>::max(), "Number of dynamic descriptors exceeds max representable value");
@@ -108,14 +108,14 @@ void PipelineLayout::DescriptorSetLayoutManager::DescriptorSetLayout::AddBinding
size_t PipelineLayout::DescriptorSetLayoutManager::DescriptorSetLayout::GetMemorySize(Uint32 NumBindings)
{
- if(NumBindings == 0)
+ if (NumBindings == 0)
return 0;
// Align up to the nearest power of two
size_t MemSize = 0;
- if(NumBindings == 1)
+ if (NumBindings == 1)
MemSize = 1;
- else if(NumBindings > 1)
+ else if (NumBindings > 1)
{
// NumBindings = 2^n
// n n-1 2 1 0
@@ -153,10 +153,10 @@ void PipelineLayout::DescriptorSetLayoutManager::DescriptorSetLayout::ReserveMem
{
size_t ReservedMemory = GetMemorySize(NumLayoutBindings);
size_t RequiredMemory = GetMemorySize(NumBindings);
- if(RequiredMemory > ReservedMemory)
+ if (RequiredMemory > ReservedMemory)
{
void *pNewBindings = ALLOCATE(MemAllocator, "Memory buffer for descriptor set layout bindings", RequiredMemory);
- if(pBindings != nullptr)
+ if (pBindings != nullptr)
{
memcpy(pNewBindings, pBindings, sizeof(VkDescriptorSetLayoutBinding) * NumLayoutBindings);
MemAllocator.Free(pBindings);
@@ -186,9 +186,9 @@ void PipelineLayout::DescriptorSetLayoutManager::DescriptorSetLayout::Finalize(c
void PipelineLayout::DescriptorSetLayoutManager::DescriptorSetLayout::Release(RenderDeviceVkImpl *pRenderDeviceVk, IMemoryAllocator &MemAllocator)
{
pRenderDeviceVk->SafeReleaseVkObject(std::move(VkLayout));
- for(uint32_t b=0; b < NumLayoutBindings; ++b)
+ for (uint32_t b=0; b < NumLayoutBindings; ++b)
{
- if(pBindings[b].pImmutableSamplers != nullptr)
+ if (pBindings[b].pImmutableSamplers != nullptr)
MemAllocator.Free(const_cast<VkSampler*>(pBindings[b].pImmutableSamplers));
}
pBindings = nullptr;
@@ -202,24 +202,24 @@ PipelineLayout::DescriptorSetLayoutManager::DescriptorSetLayout::~DescriptorSetL
bool PipelineLayout::DescriptorSetLayoutManager::DescriptorSetLayout::operator == (const DescriptorSetLayout& rhs)const
{
- if(TotalDescriptors != rhs.TotalDescriptors ||
- SetIndex != rhs.SetIndex ||
- NumDynamicDescriptors != rhs.NumDynamicDescriptors ||
- NumLayoutBindings != rhs.NumLayoutBindings)
+ if (TotalDescriptors != rhs.TotalDescriptors ||
+ SetIndex != rhs.SetIndex ||
+ NumDynamicDescriptors != rhs.NumDynamicDescriptors ||
+ NumLayoutBindings != rhs.NumLayoutBindings)
return false;
for(uint32_t b=0; b < NumLayoutBindings; ++b)
{
const auto &B0 = pBindings[b];
const auto &B1 = rhs.pBindings[b];
- if(B0.binding != B1.binding ||
- B0.descriptorType != B1.descriptorType ||
- B0.descriptorCount != B1.descriptorCount ||
- B0.stageFlags != B1.stageFlags)
+ if (B0.binding != B1.binding ||
+ B0.descriptorType != B1.descriptorType ||
+ B0.descriptorCount != B1.descriptorCount ||
+ B0.stageFlags != B1.stageFlags)
return false;
- if( B0.pImmutableSamplers != nullptr && B1.pImmutableSamplers == nullptr ||
- B0.pImmutableSamplers == nullptr && B1.pImmutableSamplers != nullptr)
+ if ( B0.pImmutableSamplers != nullptr && B1.pImmutableSamplers == nullptr ||
+ B0.pImmutableSamplers == nullptr && B1.pImmutableSamplers != nullptr)
return false;
// Static samplers themselves should not affect compatibility
}
@@ -248,9 +248,9 @@ void PipelineLayout::DescriptorSetLayoutManager::Finalize(const VulkanUtilities:
m_LayoutBindings.resize(TotalBindings);
size_t BindingOffset = 0;
std::array<VkDescriptorSetLayout, 2> ActiveDescrSetLayouts = {};
- for(auto &Layout : m_DescriptorSetLayouts)
+ for (auto &Layout : m_DescriptorSetLayouts)
{
- if(Layout.SetIndex >= 0)
+ if (Layout.SetIndex >= 0)
{
std::copy(Layout.pBindings, Layout.pBindings + Layout.NumLayoutBindings, m_LayoutBindings.begin() + BindingOffset);
Layout.Finalize(LogicalDevice, m_MemAllocator, &m_LayoutBindings[BindingOffset]);
@@ -295,11 +295,11 @@ bool PipelineLayout::DescriptorSetLayoutManager::operator == (const DescriptorSe
// defined descriptor set layouts for sets zero through N, and if they were created with identical push
// constant ranges (13.2.2)
- if(m_ActiveSets != rhs.m_ActiveSets)
+ if (m_ActiveSets != rhs.m_ActiveSets)
return false;
- for(size_t i=0; i < m_DescriptorSetLayouts.size(); ++i)
- if(m_DescriptorSetLayouts[i] != rhs.m_DescriptorSetLayouts[i])
+ for (size_t i=0; i < m_DescriptorSetLayouts.size(); ++i)
+ if (m_DescriptorSetLayouts[i] != rhs.m_DescriptorSetLayouts[i])
return false;
return true;
@@ -308,7 +308,7 @@ bool PipelineLayout::DescriptorSetLayoutManager::operator == (const DescriptorSe
size_t PipelineLayout::DescriptorSetLayoutManager::GetHash()const
{
size_t Hash = 0;
- for(const auto &SetLayout : m_DescriptorSetLayouts)
+ for (const auto &SetLayout : m_DescriptorSetLayouts)
HashCombine(Hash, SetLayout.GetHash());
return Hash;
@@ -388,14 +388,14 @@ std::array<Uint32, 2> PipelineLayout::GetDescriptorSetSizes(Uint32& NumSets)cons
std::array<Uint32, 2> SetSizes = {};
const auto &StaticAndMutSet = m_LayoutMgr.GetDescriptorSet(SHADER_VARIABLE_TYPE_STATIC);
- if(StaticAndMutSet.SetIndex >= 0)
+ if (StaticAndMutSet.SetIndex >= 0)
{
NumSets = std::max(NumSets, static_cast<Uint32>(StaticAndMutSet.SetIndex + 1));
SetSizes[StaticAndMutSet.SetIndex] = StaticAndMutSet.TotalDescriptors;
}
const auto &DynamicSet = m_LayoutMgr.GetDescriptorSet(SHADER_VARIABLE_TYPE_DYNAMIC);
- if(DynamicSet.SetIndex >= 0)
+ if (DynamicSet.SetIndex >= 0)
{
NumSets = std::max(NumSets, static_cast<Uint32>(DynamicSet.SetIndex + 1));
SetSizes[DynamicSet.SetIndex] = DynamicSet.TotalDescriptors;
@@ -441,13 +441,13 @@ void PipelineLayout::PrepareDescriptorSets(DeviceContextVkImpl* pCtxVkImpl,
for(SHADER_VARIABLE_TYPE VarType = SHADER_VARIABLE_TYPE_MUTABLE; VarType <= SHADER_VARIABLE_TYPE_DYNAMIC; VarType = static_cast<SHADER_VARIABLE_TYPE>(VarType+1))
{
const auto &Set = m_LayoutMgr.GetDescriptorSet(VarType);
- if(Set.SetIndex >= 0)
+ if (Set.SetIndex >= 0)
{
BindInfo.SetCout = std::max(BindInfo.SetCout, static_cast<Uint32>(Set.SetIndex + 1));
- if(BindInfo.SetCout > BindInfo.vkSets.size())
+ if (BindInfo.SetCout > BindInfo.vkSets.size())
BindInfo.vkSets.resize(BindInfo.SetCout);
VERIFY_EXPR(BindInfo.vkSets[Set.SetIndex] == VK_NULL_HANDLE);
- if(VarType == SHADER_VARIABLE_TYPE_MUTABLE)
+ if (VarType == SHADER_VARIABLE_TYPE_MUTABLE)
BindInfo.vkSets[Set.SetIndex] = ResourceCache.GetDescriptorSet(Set.SetIndex).GetVkDescriptorSet();
else
{
@@ -465,7 +465,7 @@ void PipelineLayout::PrepareDescriptorSets(DeviceContextVkImpl* pCtxVkImpl,
#endif
BindInfo.DynamicOffsetCount = TotalDynamicDescriptors;
- if(TotalDynamicDescriptors > BindInfo.DynamicOffsets.size())
+ if (TotalDynamicDescriptors > BindInfo.DynamicOffsets.size())
BindInfo.DynamicOffsets.resize(TotalDynamicDescriptors);
BindInfo.BindPoint = IsCompute ? VK_PIPELINE_BIND_POINT_COMPUTE : VK_PIPELINE_BIND_POINT_GRAPHICS;
BindInfo.pResourceCache = &ResourceCache;
@@ -473,7 +473,7 @@ void PipelineLayout::PrepareDescriptorSets(DeviceContextVkImpl* pCtxVkImpl,
BindInfo.pDbgPipelineLayout = this;
#endif
- if(TotalDynamicDescriptors == 0)
+ if (TotalDynamicDescriptors == 0)
{
// There are no dynamic descriptors, so we can bind descriptor sets right now
auto& CmdBuffer = pCtxVkImpl->GetCommandBuffer();
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
index 16506cf8..985ce5ab 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
@@ -496,7 +496,7 @@ void PipelineStateVkImpl::CommitAndTransitionShaderResources(IShaderResourceBind
if (!m_HasStaticResources && !m_HasNonStaticResources)
return;
-#ifdef VERIFY_SHADER_BINDINGS
+#ifdef DEVELOPMENT
if (pShaderResourceBinding == nullptr && m_HasNonStaticResources)
{
LOG_ERROR_MESSAGE("Pipeline state \"", m_Desc.Name, "\" contains mutable/dynamic shader variables and requires shader resource binding to commit all resources, but none is provided.");
@@ -507,7 +507,7 @@ void PipelineStateVkImpl::CommitAndTransitionShaderResources(IShaderResourceBind
// In this case use special internal SRB object
auto* pResBindingVkImpl = pShaderResourceBinding ? ValidatedCast<ShaderResourceBindingVkImpl>(pShaderResourceBinding) : m_pDefaultShaderResBinding.get();
-#ifdef VERIFY_SHADER_BINDINGS
+#ifdef DEVELOPMENT
{
auto* pRefPSO = pResBindingVkImpl->GetPipelineState();
if ( IsIncompatibleWith(pRefPSO) )
@@ -526,8 +526,8 @@ void PipelineStateVkImpl::CommitAndTransitionShaderResources(IShaderResourceBind
for (Uint32 s = 0; s < m_NumShaders; ++s)
{
auto* pShaderVk = GetShader<ShaderVkImpl>(s);
-#ifdef VERIFY_SHADER_BINDINGS
- pShaderVk->DbgVerifyStaticResourceBindings();
+#ifdef DEVELOPMENT
+ pShaderVk->DvpVerifyStaticResourceBindings();
#endif
auto& StaticResLayout = pShaderVk->GetStaticResLayout();
auto& StaticResCache = pShaderVk->GetStaticResCache();
@@ -536,10 +536,10 @@ void PipelineStateVkImpl::CommitAndTransitionShaderResources(IShaderResourceBind
pResBindingVkImpl->SetStaticResourcesInitialized();
}
-#ifdef VERIFY_SHADER_BINDINGS
+#ifdef DEVELOPMENT
for (Uint32 s = 0; s < m_NumShaders; ++s)
{
- m_ShaderResourceLayouts[s].dbgVerifyBindings(ResourceCache);
+ m_ShaderResourceLayouts[s].dvpVerifyBindings(ResourceCache);
}
#endif
@@ -549,7 +549,7 @@ void PipelineStateVkImpl::CommitAndTransitionShaderResources(IShaderResourceBind
ResourceCache.TransitionResources<false>(pCtxVkImpl);
else if (Flags & COMMIT_SHADER_RESOURCES_FLAG_VERIFY_STATES)
{
-#ifdef VERIFY_SHADER_BINDINGS
+#ifdef DEVELOPMENT
ResourceCache.TransitionResources<true>(pCtxVkImpl);
#endif
}
diff --git a/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp
index 91a82c0c..ff248c3a 100644
--- a/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp
@@ -46,15 +46,23 @@ SamplerVkImpl::SamplerVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImp
SamplerCI.addressModeW = AddressModeToVkAddressMode(m_Desc.AddressW);
SamplerCI.mipLodBias = m_Desc.MipLODBias;
SamplerCI.anisotropyEnable = IsAnisotropicFilter(m_Desc.MinFilter);
- VERIFY(SamplerCI.anisotropyEnable && IsAnisotropicFilter(m_Desc.MagFilter) ||
- !SamplerCI.anisotropyEnable && !IsAnisotropicFilter(m_Desc.MagFilter),
- "Min and mag fiters must both be either anisotropic filters or non-anisotropic ones");
+#ifdef DEVELOPMENT
+ if( !( SamplerCI.anisotropyEnable && IsAnisotropicFilter(m_Desc.MagFilter) ||
+ !SamplerCI.anisotropyEnable && !IsAnisotropicFilter(m_Desc.MagFilter)) )
+ {
+ LOG_ERROR("Min and mag fiters must both be either anisotropic filters or non-anisotropic ones");
+ }
+#endif
SamplerCI.maxAnisotropy = static_cast<float>(m_Desc.MaxAnisotropy);
SamplerCI.compareEnable = IsComparisonFilter(m_Desc.MinFilter);
- VERIFY( SamplerCI.compareEnable && IsComparisonFilter(m_Desc.MagFilter) ||
- !SamplerCI.compareEnable && !IsComparisonFilter(m_Desc.MagFilter),
- "Min and mag fiters must both be either comparison filters or non-comparison ones");
+#ifdef DEVELOPMENT
+ if( !( SamplerCI.compareEnable && IsComparisonFilter(m_Desc.MagFilter) ||
+ !SamplerCI.compareEnable && !IsComparisonFilter(m_Desc.MagFilter)) )
+ {
+ LOG_ERROR("Min and mag fiters must both be either comparison filters or non-comparison ones");
+ }
+#endif
SamplerCI.compareOp = ComparisonFuncToVkCompareOp(m_Desc.ComparisonFunc);
SamplerCI.minLod = m_Desc.MinLOD;
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp
index e1091a88..c4d57b54 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp
@@ -63,7 +63,7 @@ void ShaderResourceCacheVk::InitializeSets(IMemoryAllocator& MemAllocator, Uint3
m_TotalResources += SetSizes[t];
auto MemorySize = NumSets * sizeof(DescriptorSet) + m_TotalResources * sizeof(Resource);
VERIFY_EXPR(MemorySize == GetRequiredMemorySize(NumSets, SetSizes));
- if(MemorySize > 0)
+ if (MemorySize > 0)
{
m_pMemory = ALLOCATE( *m_pAllocator, "Memory for shader resource cache data", MemorySize);
auto *pSets = reinterpret_cast<DescriptorSet*>(m_pMemory);
@@ -111,9 +111,9 @@ void ShaderResourceCacheVk::TransitionResources(DeviceContextVkImpl *pCtxVkImpl)
{
auto *pBufferVk = Res.pObject.RawPtr<BufferVkImpl>();
VkAccessFlags RequiredAccessFlags = VK_ACCESS_UNIFORM_READ_BIT;
- if(!pBufferVk->CheckAccessFlags(RequiredAccessFlags))
+ if (!pBufferVk->CheckAccessFlags(RequiredAccessFlags))
{
- if(VerifyOnly)
+ if (VerifyOnly)
{
LOG_ERROR_MESSAGE("State of buffer \"", pBufferVk->GetDesc().Name, "\" is incorrect. Required access flags: ",
VulkanUtilities::VkAccessFlagsToString(RequiredAccessFlags), ". Actual access flags: ",
@@ -164,11 +164,11 @@ void ShaderResourceCacheVk::TransitionResources(DeviceContextVkImpl *pCtxVkImpl)
// VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
// or VK_IMAGE_LAYOUT_GENERAL layout in order to access its data in a shader (13.1.3, 13.1.4).
VkImageLayout RequiredLayout;
- if(Res.Type == SPIRVShaderResourceAttribs::ResourceType::StorageImage)
+ if (Res.Type == SPIRVShaderResourceAttribs::ResourceType::StorageImage)
RequiredLayout = VK_IMAGE_LAYOUT_GENERAL;
else
{
- if(pTextureVk->GetDesc().BindFlags & BIND_DEPTH_STENCIL)
+ if (pTextureVk->GetDesc().BindFlags & BIND_DEPTH_STENCIL)
{
// VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL must only be used as a read - only depth / stencil attachment
// in a VkFramebuffer and/or as a read - only image in a shader (which can be read as a sampled image, combined
@@ -179,7 +179,7 @@ void ShaderResourceCacheVk::TransitionResources(DeviceContextVkImpl *pCtxVkImpl)
else
RequiredLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
- if(pTextureVk->GetLayout() != RequiredLayout)
+ if (pTextureVk->GetLayout() != RequiredLayout)
{
if (VerifyOnly)
{
@@ -291,11 +291,11 @@ VkDescriptorImageInfo ShaderResourceCacheVk::Resource::GetImageDescriptorWriteIn
// If descriptorType is VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, for each descriptor that will be accessed
// via load or store operations the imageLayout member for corresponding elements of pImageInfo
// MUST be VK_IMAGE_LAYOUT_GENERAL (13.2.4)
- if(IsStorageImage)
+ if (IsStorageImage)
DescrImgInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
else
{
- if(ValidatedCast<const TextureVkImpl>(pTexViewVk->GetTexture())->GetDesc().BindFlags & BIND_DEPTH_STENCIL)
+ if (ValidatedCast<const TextureVkImpl>(pTexViewVk->GetTexture())->GetDesc().BindFlags & BIND_DEPTH_STENCIL)
DescrImgInfo.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
else
DescrImgInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
@@ -349,7 +349,7 @@ Uint32 ShaderResourceCacheVk::GetDynamicBufferOffsets(Uint32 CtxId, std::vector<
while(res < DescrSet.GetSize())
{
const auto& Res = DescrSet.GetResource(res);
- if(Res.Type != SPIRVShaderResourceAttribs::ResourceType::UniformBuffer)
+ if (Res.Type != SPIRVShaderResourceAttribs::ResourceType::UniformBuffer)
break;
const auto* pBufferVk = Res.pObject.RawPtr<const BufferVkImpl>();
@@ -374,7 +374,7 @@ Uint32 ShaderResourceCacheVk::GetDynamicBufferOffsets(Uint32 CtxId, std::vector<
}
#ifdef _DEBUG
- for(; res < DescrSet.GetSize(); ++res)
+ for (; res < DescrSet.GetSize(); ++res)
{
const auto& Res = DescrSet.GetResource(res);
VERIFY(Res.Type != SPIRVShaderResourceAttribs::ResourceType::UniformBuffer &&
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
index 1696e4a7..3c468729 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp
@@ -349,7 +349,7 @@ void ShaderResourceLayoutVk::VkResource::CacheUniformBuffer(IDeviceObject*
if( UpdateCachedResource(DstRes, ArrayInd, pBuffer, IID_BufferVk, "buffer") )
{
-#ifdef VERIFY_SHADER_BINDINGS
+#ifdef DEVELOPMENT
// VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER or VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC descriptor type require
// buffer to be created with VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
auto* pBuffVk = DstRes.pObject.RawPtr<BufferVkImpl>(); // Use final type
@@ -380,7 +380,7 @@ void ShaderResourceLayoutVk::VkResource::CacheStorageBuffer(IDeviceObject*
if( UpdateCachedResource(DstRes, ArrayInd, pBuffer, IID_BufferViewVk, "buffer view") )
{
-#ifdef VERIFY_SHADER_BINDINGS
+#ifdef DEVELOPMENT
// VK_DESCRIPTOR_TYPE_STORAGE_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC descriptor type
// require buffer to be created with VK_BUFFER_USAGE_STORAGE_BUFFER_BIT (13.2.4)
auto* pBuffViewVk = DstRes.pObject.RawPtr<BufferViewVkImpl>();
@@ -416,7 +416,7 @@ void ShaderResourceLayoutVk::VkResource::CacheTexelBuffer(IDeviceObject*
{
auto* pBuffViewVk = DstRes.pObject.RawPtr<BufferViewVkImpl>();
-#ifdef VERIFY_SHADER_BINDINGS
+#ifdef DEVELOPMENT
// The following bits must have been set at buffer creation time:
// * VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER -> VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT
// * VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER -> VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT
@@ -456,7 +456,7 @@ void ShaderResourceLayoutVk::VkResource::CacheImage(IDeviceObject*
if (UpdateCachedResource(DstRes, ArrayInd, pTexView, IID_TextureViewVk, "texture view") )
{
-#ifdef VERIFY_SHADER_BINDINGS
+#ifdef DEVELOPMENT
auto* pTexViewVk = DstRes.pObject.RawPtr<TextureViewVkImpl>();
const auto ViewType = pTexViewVk->GetDesc().ViewType;
const bool IsStorageImage = SpirvAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::StorageImage;
@@ -645,8 +645,8 @@ void ShaderResourceLayoutVk::InitializeStaticResources(const ShaderResourceLayou
}
-#ifdef VERIFY_SHADER_BINDINGS
-void ShaderResourceLayoutVk::dbgVerifyBindings(const ShaderResourceCacheVk& ResourceCache)const
+#ifdef DEVELOPMENT
+void ShaderResourceLayoutVk::dvpVerifyBindings(const ShaderResourceCacheVk& ResourceCache)const
{
for(SHADER_VARIABLE_TYPE VarType = SHADER_VARIABLE_TYPE_STATIC; VarType < SHADER_VARIABLE_TYPE_NUM_TYPES; VarType = static_cast<SHADER_VARIABLE_TYPE>(VarType+1))
{
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
index 83d1f7d2..1d6bd8e9 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
@@ -45,7 +45,7 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl*
{
auto GLSLSource = BuildGLSLSourceString(CreationAttribs, TargetGLSLCompiler::glslang, "#define TARGET_API_VULKAN 1\n");
m_SPIRV = GLSLtoSPIRV(m_Desc.ShaderType, GLSLSource.c_str(), CreationAttribs.ppCompilerOutput);
- if(m_SPIRV.empty())
+ if (m_SPIRV.empty())
{
LOG_ERROR_AND_THROW("Failed to compile shader");
}
@@ -77,7 +77,7 @@ void ShaderVkImpl::BindResources(IResourceMapping* pResourceMapping, Uint32 Flag
IShaderVariable* ShaderVkImpl::GetShaderVariable(const Char* Name)
{
IShaderVariable *pVar = m_StaticVarsMgr.GetVariable(Name);
- if(pVar == nullptr)
+ if (pVar == nullptr)
{
LOG_ERROR_MESSAGE("Shader variable \"", Name, "\" is not found in shader \"", m_Desc.Name, "\". Note that only static variables can be accessed through shader object.");
return &m_DummyShaderVar;
@@ -86,10 +86,10 @@ IShaderVariable* ShaderVkImpl::GetShaderVariable(const Char* Name)
return pVar;
}
-#ifdef VERIFY_SHADER_BINDINGS
-void ShaderVkImpl::DbgVerifyStaticResourceBindings()
+#ifdef DEVELOPMENT
+void ShaderVkImpl::DvpVerifyStaticResourceBindings()
{
- m_StaticResLayout.dbgVerifyBindings(m_StaticResCache);
+ m_StaticResLayout.dvpVerifyBindings(m_StaticResCache);
}
#endif
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp
index bb107d91..4dc335d3 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanDynamicHeap.cpp
@@ -97,7 +97,7 @@ VulkanRingBuffer::VulkanRingBuffer(IMemoryAllocator& Allocator,
err = LogicalDevice.BindBufferMemory(m_VkBuffer, m_BufferMemory, 0 /*offset*/);
CHECK_VK_ERROR_AND_THROW(err, "Failed to bind bufer memory");
- LOG_INFO_MESSAGE("GPU dynamic heap created. Total buffer size: ", SizeFormatter{Size,2} );
+ LOG_INFO_MESSAGE("GPU dynamic heap created. Total buffer size: ", FormatMemorySize(Size, 2) );
}
void VulkanRingBuffer::Destroy()
@@ -115,9 +115,9 @@ VulkanRingBuffer::~VulkanRingBuffer()
{
VERIFY(m_BufferMemory == VK_NULL_HANDLE && m_VkBuffer == VK_NULL_HANDLE, "Vulkan resources must be explcitly released with Destroy()");
LOG_INFO_MESSAGE("Dynamic heap ring buffer usage stats:\n"
- " Total size: ", SizeFormatter{ m_RingBuffer.GetMaxSize(), 2 },
- ". Peak allocated size: ", SizeFormatter{ m_TotalPeakSize, 2, m_RingBuffer.GetMaxSize() },
- ". Peak frame size: ", SizeFormatter{ m_FramePeakSize, 2, m_RingBuffer.GetMaxSize() },
+ " Total size: ", FormatMemorySize(m_RingBuffer.GetMaxSize(), 2),
+ ". Peak allocated size: ", FormatMemorySize(m_TotalPeakSize, 2, m_RingBuffer.GetMaxSize()),
+ ". Peak frame size: ", FormatMemorySize(m_FramePeakSize, 2, m_RingBuffer.GetMaxSize()),
". Peak utilization: ", std::fixed, std::setprecision(1), static_cast<double>(m_TotalPeakSize) / static_cast<double>(std::max(m_RingBuffer.GetMaxSize(), size_t{1})) * 100.0, '%' );
}
@@ -249,7 +249,7 @@ VulkanDynamicAllocation VulkanDynamicHeap::Allocate(Uint32 SizeInBytes, Uint32 A
VulkanDynamicHeap::~VulkanDynamicHeap()
{
LOG_INFO_MESSAGE(m_HeapName, " usage stats:\n"
- " Peak used/peak allocated size: ", SizeFormatter{ m_PeakUsedSize, 2, m_PeakAllocatedSize }, '/', SizeFormatter{ m_PeakAllocatedSize, 2, m_PeakAllocatedSize },
+ " Peak used/peak allocated size: ", FormatMemorySize(m_PeakUsedSize, 2, m_PeakAllocatedSize), '/', FormatMemorySize(m_PeakAllocatedSize, 2, m_PeakAllocatedSize),
". Peak utilization: ", std::fixed, std::setprecision(1), static_cast<double>(m_PeakUsedSize) / static_cast<double>(std::max(m_PeakAllocatedSize, 1U)) * 100.0, '%');
}
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBuffer.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBuffer.cpp
index 9969a009..831e4a19 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBuffer.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBuffer.cpp
@@ -32,7 +32,7 @@ static VkPipelineStageFlags PipelineStageFromAccessFlags(VkAccessFlags AccessFla
// 6.1.3
VkPipelineStageFlags Stages = 0;
- while(AccessFlags != 0)
+ while (AccessFlags != 0)
{
VkAccessFlagBits AccessFlag = static_cast<VkAccessFlagBits>( AccessFlags & (~(AccessFlags-1)));
VERIFY_EXPR( AccessFlag != 0 && (AccessFlag & (AccessFlag-1)) == 0 );
@@ -48,7 +48,7 @@ static VkPipelineStageFlags PipelineStageFromAccessFlags(VkAccessFlags AccessFla
// An application MUST NOT specify an access flag in a synchronization command if it does not include a
// pipeline stage in the corresponding stage mask that is able to perform accesses of that type.
// A table that lists, for each access flag, which pipeline stages can perform that type of access is given in 6.1.3.
- switch(AccessFlag)
+ switch (AccessFlag)
{
// Read access to an indirect command structure read as part of an indirect drawing or dispatch command
case VK_ACCESS_INDIRECT_COMMAND_READ_BIT:
@@ -143,13 +143,13 @@ static VkPipelineStageFlags PipelineStageFromAccessFlags(VkAccessFlags AccessFla
return Stages;
}
-void VulkanCommandBuffer::TransitionImageLayout(VkCommandBuffer CmdBuffer,
- VkImage Image,
- VkImageLayout OldLayout,
- VkImageLayout NewLayout,
+void VulkanCommandBuffer::TransitionImageLayout(VkCommandBuffer CmdBuffer,
+ VkImage Image,
+ VkImageLayout OldLayout,
+ VkImageLayout NewLayout,
const VkImageSubresourceRange& SubresRange,
- VkPipelineStageFlags SrcStages,
- VkPipelineStageFlags DestStages)
+ VkPipelineStageFlags SrcStages,
+ VkPipelineStageFlags DestStages)
{
VERIFY_EXPR(CmdBuffer != VK_NULL_HANDLE);
@@ -295,13 +295,13 @@ void VulkanCommandBuffer::TransitionImageLayout(VkCommandBuffer CmdBuffer,
break;
}
- if(SrcStages == 0)
+ if (SrcStages == 0)
{
- if(OldLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)
+ if (OldLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)
{
SrcStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
}
- else if(ImgBarrier.srcAccessMask != 0)
+ else if (ImgBarrier.srcAccessMask != 0)
{
SrcStages = PipelineStageFromAccessFlags(ImgBarrier.srcAccessMask);
}
@@ -315,11 +315,11 @@ void VulkanCommandBuffer::TransitionImageLayout(VkCommandBuffer CmdBuffer,
if (DestStages == 0)
{
- if(NewLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)
+ if (NewLayout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR)
{
DestStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
}
- else if(ImgBarrier.dstAccessMask != 0)
+ else if (ImgBarrier.dstAccessMask != 0)
{
DestStages = PipelineStageFromAccessFlags(ImgBarrier.dstAccessMask);
}
@@ -377,7 +377,7 @@ void VulkanCommandBuffer::BufferMemoryBarrier(VkCommandBuffer CmdBuffer,
BuffBarrier.size = VK_WHOLE_SIZE;
if (SrcStages == 0)
{
- if(BuffBarrier.srcAccessMask != 0)
+ if (BuffBarrier.srcAccessMask != 0)
SrcStages = PipelineStageFromAccessFlags(BuffBarrier.srcAccessMask);
else
{
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp
index 16180a54..6929fc14 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp
@@ -80,7 +80,8 @@ namespace VulkanUtilities
{
CmdBuffer = OldestBuff.second;
auto err = vkResetCommandBuffer(CmdBuffer,
- 0 // VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT - specifies that most or all memory resources currently owned by the command buffer should be returned to the parent command pool.
+ 0 // VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT - specifies that most or all memory resources currently
+ // owned by the command buffer should be returned to the parent command pool.
);
VERIFY(err == VK_SUCCESS, "Failed to reset command buffer");
m_DiscardedCmdBuffers.pop_front();
@@ -88,7 +89,7 @@ namespace VulkanUtilities
}
}
- // If no allocators were ready to be reused, create a new one
+ // If no cmd buffers were ready to be reused, create a new one
if (CmdBuffer == VK_NULL_HANDLE)
{
VkCommandBufferAllocateInfo BuffAllocInfo = {};
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDescriptorPool.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDescriptorPool.cpp
index b8c2dc1d..9113023e 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDescriptorPool.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanDescriptorPool.cpp
@@ -31,7 +31,7 @@
namespace VulkanUtilities
{
VulkanDescriptorPool::VulkanDescriptorPool(std::shared_ptr<const VulkanUtilities::VulkanLogicalDevice> LogicalDevice,
- const VkDescriptorPoolCreateInfo& DescriptorPoolCI)noexcept :
+ const VkDescriptorPoolCreateInfo& DescriptorPoolCI) :
m_LogicalDevice(LogicalDevice)
{
VERIFY_EXPR(DescriptorPoolCI.sType == VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO);
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanFencePool.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanFencePool.cpp
index eaf6bd7c..5293aa21 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanFencePool.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanFencePool.cpp
@@ -29,12 +29,12 @@
namespace VulkanUtilities
{
VulkanFencePool::VulkanFencePool(std::shared_ptr<const VulkanLogicalDevice> LogicalDevice) :
- m_LogicalDevice(LogicalDevice)
+ m_LogicalDevice(std::move(LogicalDevice))
{}
VulkanFencePool::~VulkanFencePool()
{
- for(const auto &fence : m_Fences)
+ for (const auto& fence : m_Fences)
{
VERIFY(m_LogicalDevice->GetFenceStatus(fence) == VK_SUCCESS, "Destroying a fence that has not been signaled");
}
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp
index e2365f7d..f084577f 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp
@@ -32,8 +32,8 @@ namespace VulkanUtilities
{
bool VulkanInstance::IsLayerAvailable(const char* LayerName)const
{
- for(const auto& Layer : m_Layers)
- if(strcmp(Layer.layerName, LayerName) == 0)
+ for (const auto& Layer : m_Layers)
+ if (strcmp(Layer.layerName, LayerName) == 0)
return true;
return false;
@@ -66,7 +66,7 @@ namespace VulkanUtilities
{
// Enumerate available layers
uint32_t LayerCount = 0;
- auto res = vkEnumerateInstanceLayerProperties(&LayerCount, NULL);
+ auto res = vkEnumerateInstanceLayerProperties(&LayerCount, nullptr);
CHECK_VK_ERROR_AND_THROW(res, "Failed to query layer count");
m_Layers.resize(LayerCount);
vkEnumerateInstanceLayerProperties(&LayerCount, m_Layers.data());
@@ -77,10 +77,10 @@ namespace VulkanUtilities
{
// Enumerate available extensions
uint32_t ExtensionCount = 0;
- auto res = vkEnumerateInstanceExtensionProperties(NULL, &ExtensionCount, NULL);
+ auto res = vkEnumerateInstanceExtensionProperties(nullptr, &ExtensionCount, nullptr);
CHECK_VK_ERROR_AND_THROW(res, "Failed to query extension count");
m_Extensions.resize(ExtensionCount);
- vkEnumerateInstanceExtensionProperties(NULL, &ExtensionCount, m_Extensions.data());
+ vkEnumerateInstanceExtensionProperties(nullptr, &ExtensionCount, m_Extensions.data());
CHECK_VK_ERROR_AND_THROW(res, "Failed to enumerate extensions");
VERIFY_EXPR(ExtensionCount == m_Extensions.size());
}
@@ -115,7 +115,7 @@ namespace VulkanUtilities
for(const auto* ExtName : GlobalExtensions)
{
- if(!IsExtensionAvailable(ExtName))
+ if (!IsExtensionAvailable(ExtName))
LOG_ERROR_AND_THROW("Requested extension ", ExtName, " is not available");
}
@@ -141,7 +141,7 @@ namespace VulkanUtilities
bool ValidationLayersPresent = true;
for (size_t l = 0; l < _countof(VulkanUtilities::ValidationLayerNames); ++l)
{
- auto *pLayerName = VulkanUtilities::ValidationLayerNames[l];
+ auto* pLayerName = VulkanUtilities::ValidationLayerNames[l];
if (!IsLayerAvailable(pLayerName))
{
ValidationLayersPresent = false;
@@ -193,7 +193,7 @@ namespace VulkanUtilities
VulkanInstance::~VulkanInstance()
{
- if(m_ValidationEnabled)
+ if (m_ValidationEnabled)
{
VulkanUtilities::FreeDebugCallback(m_VkInstance);
}
@@ -202,7 +202,7 @@ namespace VulkanUtilities
Diligent::FinalizeGlslang();
}
- VkPhysicalDevice VulkanInstance::SelectPhysicalDevice()
+ VkPhysicalDevice VulkanInstance::SelectPhysicalDevice()const
{
VkPhysicalDevice SelectedPhysicalDevice = VK_NULL_HANDLE;
@@ -215,7 +215,7 @@ namespace VulkanUtilities
uint32_t QueueFamilyCount = 0;
vkGetPhysicalDeviceQueueFamilyProperties(Device, &QueueFamilyCount, nullptr);
- VERIFY_EXPR(QueueFamilyCount> 0);
+ VERIFY_EXPR(QueueFamilyCount > 0);
std::vector<VkQueueFamilyProperties> QueueFamilyProperties(QueueFamilyCount);
vkGetPhysicalDeviceQueueFamilyProperties(Device, &QueueFamilyCount, QueueFamilyProperties.data());
VERIFY_EXPR(QueueFamilyCount == QueueFamilyProperties.size());
@@ -226,14 +226,14 @@ namespace VulkanUtilities
bool GraphicsAndComputeQueueSupported = false;
for(const auto &QueueFamilyProps : QueueFamilyProperties)
{
- if( (QueueFamilyProps.queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0 &&
- (QueueFamilyProps.queueFlags & VK_QUEUE_COMPUTE_BIT) != 0)
+ if ((QueueFamilyProps.queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0 &&
+ (QueueFamilyProps.queueFlags & VK_QUEUE_COMPUTE_BIT) != 0)
{
GraphicsAndComputeQueueSupported = true;
break;
}
}
- if(GraphicsAndComputeQueueSupported)
+ if (GraphicsAndComputeQueueSupported)
{
SelectedPhysicalDevice = Device;
if (DeviceProps.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
@@ -241,7 +241,7 @@ namespace VulkanUtilities
}
}
- if(SelectedPhysicalDevice != VK_NULL_HANDLE)
+ if (SelectedPhysicalDevice != VK_NULL_HANDLE)
{
VkPhysicalDeviceProperties SelectedDeviceProps;
vkGetPhysicalDeviceProperties(SelectedPhysicalDevice, &SelectedDeviceProps);
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp
index 54d39605..38fd781f 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanMemoryManager.cpp
@@ -30,7 +30,7 @@ namespace VulkanUtilities
VulkanMemoryAllocation::~VulkanMemoryAllocation()
{
- if(Page != nullptr)
+ if (Page != nullptr)
{
Page->Free(*this);
}
@@ -50,10 +50,10 @@ VulkanMemoryPage::VulkanMemoryPage(VulkanMemoryManager& ParentMemoryMgr,
MemAlloc.memoryTypeIndex = MemoryTypeIndex;
std::stringstream ss;
- ss << "Device memory page. Size: " << (PageSize >> 10) << " Kb, type: " << MemoryTypeIndex;
+ Diligent::FormatMsg(ss, "Device memory page. Size: ", Diligent::FormatMemorySize(PageSize, 2), ", type: ", MemoryTypeIndex);
m_VkMemory = ParentMemoryMgr.m_LogicalDevice.AllocateDeviceMemory(MemAlloc, ss.str().c_str());
- if(IsHostVisible)
+ if (IsHostVisible)
{
auto err = ParentMemoryMgr.m_LogicalDevice.MapMemory(m_VkMemory,
0, // offset
@@ -66,7 +66,7 @@ VulkanMemoryPage::VulkanMemoryPage(VulkanMemoryManager& ParentMemoryMgr,
VulkanMemoryPage::~VulkanMemoryPage()
{
- if(m_CPUMemory != nullptr)
+ if (m_CPUMemory != nullptr)
{
// Unmapping memory is not necessary, byt anyway
m_ParentMemoryMgr.m_LogicalDevice.UnmapMemory(m_VkMemory);
@@ -79,7 +79,7 @@ VulkanMemoryAllocation VulkanMemoryPage::Allocate(VkDeviceSize size)
{
std::lock_guard<std::mutex> Lock(m_Mutex);
auto Offset = m_AllocationMgr.Allocate(size);
- if(Offset != Diligent::VariableSizeAllocationsManager::InvalidOffset)
+ if (Offset != Diligent::VariableSizeAllocationsManager::InvalidOffset)
{
return VulkanMemoryAllocation{this, Offset, size};
}
@@ -102,7 +102,7 @@ VulkanMemoryAllocation VulkanMemoryManager::Allocate(const VkMemoryRequirements&
// Bit i is set if and only if the memory type i in the VkPhysicalDeviceMemoryProperties structure for the
// physical device is supported for the resource.
auto MemoryTypeIndex = m_PhysicalDevice.GetMemoryTypeIndex(MemReqs.memoryTypeBits, MemoryProps);
- if(MemoryProps == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
+ if (MemoryProps == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
{
// There must be at least one memory type with the DEVICE_LOCAL_BIT bit set
VERIFY(MemoryTypeIndex != VulkanUtilities::VulkanPhysicalDevice::InvalidMemoryTypeIndex,
@@ -110,7 +110,7 @@ VulkanMemoryAllocation VulkanMemoryManager::Allocate(const VkMemoryRequirements&
"at least one bit set corresponding to a VkMemoryType with a propertyFlags that has the "
"VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT bit set (11.6)");
}
- else if( (MemoryProps & (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) == (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT))
+ else if ( (MemoryProps & (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) == (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT))
{
VERIFY(MemoryTypeIndex != VulkanUtilities::VulkanPhysicalDevice::InvalidMemoryTypeIndex,
"Vulkan spec requires that for a VkBuffer not created with the VK_BUFFER_CREATE_SPARSE_BINDING_BIT "
@@ -119,7 +119,7 @@ VulkanMemoryAllocation VulkanMemoryManager::Allocate(const VkMemoryRequirements&
"at least one bit set corresponding to a VkMemoryType with a propertyFlags that has both the "
"VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT bit AND the VK_MEMORY_PROPERTY_HOST_COHERENT_BIT bit set. (11.6)");
}
- else if(MemoryTypeIndex == VulkanUtilities::VulkanPhysicalDevice::InvalidMemoryTypeIndex)
+ else if (MemoryTypeIndex == VulkanUtilities::VulkanPhysicalDevice::InvalidMemoryTypeIndex)
{
LOG_ERROR_AND_THROW("Failed to find suitable device memory type for a buffer");
}
@@ -138,15 +138,15 @@ VulkanMemoryAllocation VulkanMemoryManager::Allocate(VkDeviceSize Size, VkDevice
for(auto page_it = range.first; page_it != range.second; ++page_it)
{
Allocation = page_it->second.Allocate(Size);
- if(Allocation.Page != nullptr)
+ if (Allocation.Page != nullptr)
break;
}
size_t stat_ind = HostVisible ? 1 : 0;
- if(Allocation.Page == nullptr)
+ if (Allocation.Page == nullptr)
{
auto PageSize = HostVisible ? m_HostVisiblePageSize : m_DeviceLocalPageSize;
- while(PageSize < Size)
+ while (PageSize < Size)
PageSize *= 2;
m_CurrAllocatedSize[stat_ind] += PageSize;
@@ -154,8 +154,8 @@ VulkanMemoryAllocation VulkanMemoryManager::Allocate(VkDeviceSize Size, VkDevice
auto it = m_Pages.emplace(MemoryTypeIndex, VulkanMemoryPage{*this, PageSize, MemoryTypeIndex, HostVisible});
LOG_INFO_MESSAGE("VulkanMemoryManager '", m_MgrName, "': created new ", (HostVisible ? "host-visible" : "device-local"),
- " page. (", Diligent::SizeFormatter{ PageSize, 2}, ", type idx: ", MemoryTypeIndex,
- "). Current allocated size: ", Diligent::SizeFormatter{ m_CurrAllocatedSize[stat_ind], 2});
+ " page. (", Diligent::FormatMemorySize(PageSize, 2), ", type idx: ", MemoryTypeIndex,
+ "). Current allocated size: ", Diligent::FormatMemorySize(m_CurrAllocatedSize[stat_ind], 2));
OnNewPageCreated(it->second);
Allocation = it->second.Allocate(Size);
VERIFY(Allocation.Page != nullptr, "Failed to allocate new memory page");
@@ -170,24 +170,24 @@ VulkanMemoryAllocation VulkanMemoryManager::Allocate(VkDeviceSize Size, VkDevice
void VulkanMemoryManager::ShrinkMemory()
{
std::lock_guard<std::mutex> Lock(m_PagesMtx);
- if(m_CurrAllocatedSize[0] <= m_DeviceLocalReserveSize && m_CurrAllocatedSize[1] <= m_HostVisibleReserveSize)
+ if (m_CurrAllocatedSize[0] <= m_DeviceLocalReserveSize && m_CurrAllocatedSize[1] <= m_HostVisibleReserveSize)
return;
auto it = m_Pages.begin();
- while(it != m_Pages.end())
+ while (it != m_Pages.end())
{
auto curr_it = it;
++it;
auto& Page = curr_it->second;
bool IsHostVisible = Page.GetCPUMemory() != nullptr;
auto ReserveSize = IsHostVisible ? m_HostVisibleReserveSize : m_DeviceLocalReserveSize;
- if(Page.IsEmpty() && m_CurrAllocatedSize[IsHostVisible ? 1 : 0] > ReserveSize)
+ if (Page.IsEmpty() && m_CurrAllocatedSize[IsHostVisible ? 1 : 0] > ReserveSize)
{
auto PageSize = Page.GetPageSize();
m_CurrAllocatedSize[IsHostVisible ? 1 : 0] -= PageSize;
LOG_INFO_MESSAGE("VulkanMemoryManager '", m_MgrName, "': destroying ", (IsHostVisible ? "host-visible" : "device-local"),
- " page (", Diligent::SizeFormatter{ PageSize, 2 }, ")."
- " Current allocated size: ", Diligent::SizeFormatter{ m_CurrAllocatedSize[IsHostVisible ? 1 : 0], 2 });
+ " page (", Diligent::FormatMemorySize(PageSize, 2), ")."
+ " Current allocated size: ", Diligent::FormatMemorySize(m_CurrAllocatedSize[IsHostVisible ? 1 : 0], 2));
OnPageDestroy(Page);
m_Pages.erase(curr_it);
}
@@ -203,11 +203,11 @@ VulkanMemoryManager::~VulkanMemoryManager()
{
LOG_INFO_MESSAGE("VulkanMemoryManager '", m_MgrName, "' stats:\n"
" Peak used/peak allocated device-local memory size: ",
- Diligent::SizeFormatter{ m_PeakUsedSize[0], 2, m_PeakAllocatedSize[0] }, "/",
- Diligent::SizeFormatter{ m_PeakAllocatedSize[0], 2, m_PeakAllocatedSize[0] },
+ Diligent::FormatMemorySize(m_PeakUsedSize[0], 2, m_PeakAllocatedSize[0]), "/",
+ Diligent::FormatMemorySize( m_PeakAllocatedSize[0], 2, m_PeakAllocatedSize[0]),
"\n Peak used/peak allocated host-visible memory size: ",
- Diligent::SizeFormatter{ m_PeakUsedSize[1], 2, m_PeakAllocatedSize[1]}, "/",
- Diligent::SizeFormatter{ m_PeakAllocatedSize[1], 2, m_PeakAllocatedSize[1]});
+ Diligent::FormatMemorySize(m_PeakUsedSize[1], 2, m_PeakAllocatedSize[1]), "/",
+ Diligent::FormatMemorySize(m_PeakAllocatedSize[1], 2, m_PeakAllocatedSize[1]));
for(auto it=m_Pages.begin(); it != m_Pages.end(); ++it )
VERIFY(it->second.IsEmpty(), "The page contains outstanding allocations");