summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor <egor.yusov@gmail.com>2018-11-03 07:40:12 +0000
committerEgor <egor.yusov@gmail.com>2018-11-03 07:40:12 +0000
commit0cb37acdadbe609f3e0d31c990f47c4ef9c8dd31 (patch)
tree7665de2338d6b295c5c7e41c67f76e530afe24d9 /Graphics/GraphicsEngineVulkan
parentFixed few linux build issues (diff)
downloadDiligentCore-0cb37acdadbe609f3e0d31c990f47c4ef9c8dd31.tar.gz
DiligentCore-0cb37acdadbe609f3e0d31c990f47c4ef9c8dd31.zip
Fixed multiple linux build issues in Vk backend
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h10
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h19
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h6
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h25
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h21
-rw-r--r--Graphics/GraphicsEngineVulkan/src/CommandPoolManager.cpp3
-rw-r--r--Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp14
-rw-r--r--Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp3
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp1
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp1
15 files changed, 66 insertions, 53 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h b/Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h
index d7bf771e..e7807dba 100644
--- a/Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h
+++ b/Graphics/GraphicsEngineVulkan/include/CommandPoolManager.h
@@ -73,7 +73,7 @@ private:
std::deque< VulkanUtilities::CommandPoolWrapper, STDAllocatorRawMem<VulkanUtilities::CommandPoolWrapper> > m_CmdPools;
#ifdef DEVELOPMENT
- std::atomic_int32_t m_AllocatedPoolCounter = 0;
+ std::atomic_int32_t m_AllocatedPoolCounter;
#endif
};
diff --git a/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h b/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h
index a0200ee6..6749b697 100644
--- a/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h
+++ b/Graphics/GraphicsEngineVulkan/include/DescriptorPoolManager.h
@@ -136,6 +136,9 @@ public:
m_MaxSets (MaxSets),
m_AllowFreeing(AllowFreeing)
{
+#ifdef DEVELOPMENT
+ m_AllocatedPoolCounter = 0;
+#endif
}
~DescriptorPoolManager();
@@ -170,7 +173,7 @@ private:
void FreePool(VulkanUtilities::DescriptorPoolWrapper&& Pool);
#ifdef DEVELOPMENT
- std::atomic_int32_t m_AllocatedPoolCounter = 0;
+ std::atomic_int32_t m_AllocatedPoolCounter;
#endif
};
@@ -188,6 +191,9 @@ public:
bool AllowFreeing) noexcept:
DescriptorPoolManager(DeviceVkImpl, std::move(PoolName), std::move(PoolSizes), MaxSets, AllowFreeing)
{
+#ifdef DEVELOPMENT
+ m_AllocatedSetCounter = 0;
+#endif
}
~DescriptorSetAllocator();
@@ -202,7 +208,7 @@ private:
void FreeDescriptorSet(VkDescriptorSet Set, VkDescriptorPool Pool, Uint64 QueueMask);
#ifdef DEVELOPMENT
- std::atomic_int32_t m_AllocatedSetCounter = 0;
+ std::atomic_int32_t m_AllocatedSetCounter;
#endif
};
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
index 71f7a28c..eff4aff2 100644
--- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
@@ -38,9 +38,9 @@
#include "DescriptorPoolManager.h"
#include "PipelineLayout.h"
#include "GenerateMipsVkHelper.h"
-#include "BufferVKImpl.h"
-#include "TextureViewVKImpl.h"
-#include "PipelineStateVKImpl.h"
+#include "BufferVkImpl.h"
+#include "TextureViewVkImpl.h"
+#include "PipelineStateVkImpl.h"
#include "HashUtils.h"
namespace Diligent
@@ -180,7 +180,18 @@ private:
void CommitViewports();
void CommitScissorRects();
- inline void EnsureVkCmdBuffer();
+ inline void EnsureVkCmdBuffer()
+ {
+ // Make sure that the number of commands in the context is at least one,
+ // so that the context cannot be disposed by Flush()
+ m_State.NumCommands = m_State.NumCommands != 0 ? m_State.NumCommands : 1;
+ if (m_CommandBuffer.GetVkCmdBuffer() == VK_NULL_HANDLE)
+ {
+ auto vkCmdBuff = m_CmdPool.GetCommandBuffer();
+ m_CommandBuffer.SetVkCmdBuffer(vkCmdBuff);
+ }
+ }
+
inline void DisposeVkCmdBuffer(Uint32 CmdQueue, VkCommandBuffer vkCmdBuff, Uint64 FenceValue);
inline void DisposeCurrentCmdBuffer(Uint32 CmdQueue, Uint64 FenceValue);
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h b/Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h
index b76d0d6c..fe902029 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanDynamicHeap.h
@@ -24,7 +24,7 @@
#pragma once
#include <mutex>
-#include "Vulkan.h"
+#include "vulkan.h"
#include "VulkanUtilities/VulkanMemoryManager.h"
#include "VulkanUtilities/VulkanLogicalDevice.h"
#include "VulkanUtilities/VulkanObjectWrappers.h"
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h
index 41e3cdf3..dad99285 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h
@@ -50,7 +50,7 @@ namespace VulkanUtilities
VkCommandBuffer GetCommandBuffer(const char* DebugName = "");
// The GPU must have finished with the command buffer being returned to the pool
void FreeCommandBuffer(VkCommandBuffer&& CmdBuffer);
-
+
CommandPoolWrapper&& Release();
#ifdef DEVELOPMENT
@@ -61,11 +61,11 @@ namespace VulkanUtilities
// Shared point to logical device must be defined before the command pool
std::shared_ptr<const VulkanLogicalDevice> m_LogicalDevice;
CommandPoolWrapper m_CmdPool;
-
+
std::mutex m_Mutex;
std::deque< VkCommandBuffer > m_CmdBuffers;
#ifdef DEVELOPMENT
- std::atomic_int32_t m_BuffCounter = 0;
+ std::atomic_int32_t m_BuffCounter;
#endif
};
}
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
index a9cf747d..6d2f8e77 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
@@ -25,10 +25,29 @@
#include <memory>
#include "vulkan.h"
-#include "VulkanObjectWrappers.h"
namespace VulkanUtilities
{
+ template<typename VulkanObjectType>
+ class VulkanObjectWrapper;
+
+ using CommandPoolWrapper = VulkanObjectWrapper<VkCommandPool>;
+ using BufferWrapper = VulkanObjectWrapper<VkBuffer>;
+ using BufferViewWrapper = VulkanObjectWrapper<VkBufferView>;
+ using ImageWrapper = VulkanObjectWrapper<VkImage>;
+ using ImageViewWrapper = VulkanObjectWrapper<VkImageView>;
+ using DeviceMemoryWrapper = VulkanObjectWrapper<VkDeviceMemory>;
+ using FenceWrapper = VulkanObjectWrapper<VkFence>;
+ using RenderPassWrapper = VulkanObjectWrapper<VkRenderPass>;
+ using PipelineWrapper = VulkanObjectWrapper<VkPipeline>;
+ using ShaderModuleWrapper = VulkanObjectWrapper<VkShaderModule>;
+ using PipelineLayoutWrapper = VulkanObjectWrapper<VkPipelineLayout>;
+ using SamplerWrapper = VulkanObjectWrapper<VkSampler>;
+ using FramebufferWrapper = VulkanObjectWrapper<VkFramebuffer>;
+ using DescriptorPoolWrapper = VulkanObjectWrapper<VkDescriptorPool>;
+ using DescriptorSetLayoutWrapper = VulkanObjectWrapper<VkDescriptorSetLayout>;
+ using SemaphoreWrapper = VulkanObjectWrapper<VkSemaphore>;
+
class VulkanLogicalDevice : public std::enable_shared_from_this<VulkanLogicalDevice>
{
public:
@@ -80,7 +99,7 @@ namespace VulkanUtilities
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;
@@ -119,7 +138,7 @@ namespace VulkanUtilities
const VkWriteDescriptorSet* pDescriptorWrites,
uint32_t descriptorCopyCount,
const VkCopyDescriptorSet* pDescriptorCopies)const;
-
+
VkResult ResetCommandPool(VkCommandPool vkCmdPool,
VkCommandPoolResetFlags flags = 0)const;
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
index 6029f489..c7f94f64 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanObjectWrappers.h
@@ -24,12 +24,10 @@
#pragma once
#include <memory>
-#include "vulkan.h"
+#include "VulkanLogicalDevice.h"
namespace VulkanUtilities
{
- class VulkanLogicalDevice;
-
template<typename VulkanObjectType>
class VulkanObjectWrapper
{
@@ -97,21 +95,4 @@ namespace VulkanUtilities
std::shared_ptr<const VulkanLogicalDevice> m_pLogicalDevice;
VulkanObjectType m_VkObject;
};
-
- using CommandPoolWrapper = VulkanObjectWrapper<VkCommandPool>;
- using BufferWrapper = VulkanObjectWrapper<VkBuffer>;
- using BufferViewWrapper = VulkanObjectWrapper<VkBufferView>;
- using ImageWrapper = VulkanObjectWrapper<VkImage>;
- using ImageViewWrapper = VulkanObjectWrapper<VkImageView>;
- using DeviceMemoryWrapper = VulkanObjectWrapper<VkDeviceMemory>;
- using FenceWrapper = VulkanObjectWrapper<VkFence>;
- using RenderPassWrapper = VulkanObjectWrapper<VkRenderPass>;
- using PipelineWrapper = VulkanObjectWrapper<VkPipeline>;
- using ShaderModuleWrapper = VulkanObjectWrapper<VkShaderModule>;
- using PipelineLayoutWrapper = VulkanObjectWrapper<VkPipelineLayout>;
- using SamplerWrapper = VulkanObjectWrapper<VkSampler>;
- using FramebufferWrapper = VulkanObjectWrapper<VkFramebuffer>;
- using DescriptorPoolWrapper = VulkanObjectWrapper<VkDescriptorPool>;
- using DescriptorSetLayoutWrapper = VulkanObjectWrapper<VkDescriptorSetLayout>;
- using SemaphoreWrapper = VulkanObjectWrapper<VkSemaphore>;
}
diff --git a/Graphics/GraphicsEngineVulkan/src/CommandPoolManager.cpp b/Graphics/GraphicsEngineVulkan/src/CommandPoolManager.cpp
index 2702172d..f8f1c7be 100644
--- a/Graphics/GraphicsEngineVulkan/src/CommandPoolManager.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/CommandPoolManager.cpp
@@ -38,6 +38,9 @@ CommandPoolManager::CommandPoolManager(RenderDeviceVkImpl& DeviceVkImpl,
m_CmdPoolFlags (flags),
m_CmdPools (STD_ALLOCATOR_RAW_MEM(VulkanUtilities::CommandPoolWrapper, GetRawAllocator(), "Allocator for deque<VulkanUtilities::CommandPoolWrapper>"))
{
+#ifdef DEVELOPMENT
+ m_AllocatedPoolCounter = 0;
+#endif
}
VulkanUtilities::CommandPoolWrapper CommandPoolManager::AllocateCommandPool(const char* DebugName)
diff --git a/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp
index 6e3361d3..53a1d193 100644
--- a/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp
@@ -52,8 +52,8 @@ IMPLEMENT_QUERY_INTERFACE( CommandQueueVkImpl, IID_CommandQueueVk, TBase )
Uint64 CommandQueueVkImpl::Submit(const VkSubmitInfo& SubmitInfo)
{
std::lock_guard<std::mutex> Lock(m_QueueMutex);
-
- auto FenceValue = m_NextFenceValue;
+
+ Atomics::Int64 FenceValue = m_NextFenceValue;
// Increment the value before submitting the buffer to be overly safe
Atomics::AtomicIncrement(m_NextFenceValue);
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index cffc5591..767ecb02 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -137,18 +137,6 @@ namespace Diligent
}
IMPLEMENT_QUERY_INTERFACE( DeviceContextVkImpl, IID_DeviceContextVk, TDeviceContextBase )
-
- inline void DeviceContextVkImpl::EnsureVkCmdBuffer()
- {
- // Make sure that the number of commands in the context is at least one,
- // so that the context cannot be disposed by Flush()
- m_State.NumCommands = m_State.NumCommands != 0 ? m_State.NumCommands : 1;
- if (m_CommandBuffer.GetVkCmdBuffer() == VK_NULL_HANDLE)
- {
- auto vkCmdBuff = m_CmdPool.GetCommandBuffer();
- m_CommandBuffer.SetVkCmdBuffer(vkCmdBuff);
- }
- }
void DeviceContextVkImpl::DisposeVkCmdBuffer(Uint32 CmdQueue, VkCommandBuffer vkCmdBuff, Uint64 FenceValue)
{
@@ -188,7 +176,7 @@ namespace Diligent
VkCommandBuffer vkCmdBuff;
VulkanUtilities::VulkanCommandBufferPool* Pool;
};
-
+
auto& ReleaseQueue = m_pDevice.RawPtr<RenderDeviceVkImpl>()->GetReleaseQueue(CmdQueue);
ReleaseQueue.DiscardResource(CmdBufferDeleter{vkCmdBuff, m_CmdPool}, FenceValue);
}
diff --git a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp
index d894d432..9a60af88 100644
--- a/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/GenerateMipsVkHelper.cpp
@@ -29,6 +29,7 @@
#include "TextureViewVkImpl.h"
#include "TextureVkImpl.h"
#include "MapHelper.h"
+#include "PlatformMisc.h"
#include "../../GraphicsTools/include/ShaderMacroHelper.h"
#include "../../GraphicsTools/include/CommonlyUsedStates.h"
@@ -248,8 +249,7 @@ namespace Diligent
// expensive. Maybe we can update the code later to compute sample weights for
// each successive downsample. We use _BitScanForward to count number of zeros
// in the low bits. Zeros indicate we can divide by two without truncating.
- uint32_t AdditionalMips;
- _BitScanForward((unsigned long*)&AdditionalMips, DstWidth | DstHeight);
+ uint32_t AdditionalMips = PlatformMisc::GetLSB(DstWidth | DstHeight);
uint32_t NumMips = 1 + (AdditionalMips > 3 ? 3 : AdditionalMips);
if (TopMip + NumMips > TexDesc.MipLevels - 1)
NumMips = TexDesc.MipLevels - 1 - TopMip;
diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
index 58e99eb5..97381efd 100644
--- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp
@@ -201,7 +201,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters,
std::vector<VkBufferImageCopy> Regions(InitData.NumSubresources);
- UINT64 uploadBufferSize = 0;
+ Uint64 uploadBufferSize = 0;
Uint32 subres = 0;
for(Uint32 layer = 0; layer < ImageCI.arrayLayers; ++layer)
{
@@ -247,7 +247,7 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters,
VERIFY(SubResData.DepthStride == 0 || SubResData.DepthStride >= RowSize * MipHeight, "Depth stride is too small");
// bufferOffset must be a multiple of 4 (18.4)
- // If the calling command’s VkImage parameter is a compressed image, bufferOffset
+ // If the calling command�s VkImage parameter is a compressed image, bufferOffset
// must be a multiple of the compressed texel block size in bytes (18.4). This
// is automatically guaranteed as MipWidth and MipHeight are rounded to block size
uploadBufferSize += (MipSize + 3) & (~3);
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp
index 9b476773..692fbcfd 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp
@@ -42,6 +42,9 @@ namespace VulkanUtilities
CmdPoolCI.flags = flags;
m_CmdPool = m_LogicalDevice->CreateCommandPool(CmdPoolCI);
DEV_CHECK_ERR(m_CmdPool != VK_NULL_HANDLE, "Failed to create vulkan command pool");
+#ifdef DEVELOPMENT
+ m_BuffCounter = 0;
+#endif
}
VulkanCommandBufferPool::~VulkanCommandBufferPool()
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp
index b7f992f4..5902d6cb 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanInstance.cpp
@@ -27,6 +27,7 @@
#include "VulkanUtilities/VulkanInstance.h"
#include "VulkanUtilities/VulkanDebug.h"
#include "SPIRVUtils.h"
+#include "PlatformDefinitions.h"
namespace VulkanUtilities
{
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
index 490151c5..b7b431f7 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
@@ -25,6 +25,7 @@
#include "VulkanErrors.h"
#include "VulkanUtilities/VulkanLogicalDevice.h"
#include "VulkanUtilities/VulkanDebug.h"
+#include "VulkanUtilities/VulkanObjectWrappers.h"
namespace VulkanUtilities
{