summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor <egor.yusov@gmail.com>2018-11-08 16:53:48 +0000
committerEgor <egor.yusov@gmail.com>2018-11-08 16:53:48 +0000
commit905262c95953dceea7f2982d3cba63fd01b1c905 (patch)
tree3d412f9f00f52116f4f8758631c526edaecbe8ff /Graphics/GraphicsEngineVulkan
parentFixed unexplainable ValidatedCast problem on Linux/gcc (diff)
downloadDiligentCore-905262c95953dceea7f2982d3cba63fd01b1c905.tar.gz
DiligentCore-905262c95953dceea7f2982d3cba63fd01b1c905.zip
Fixed issue with ~FenceVkImpl(): not disposing pending fences as they may not be signalled
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h4
-rw-r--r--Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp11
-rw-r--r--Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp10
3 files changed, 18 insertions, 7 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
index 6d2f8e77..91a14323 100644
--- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
+++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanLogicalDevice.h
@@ -133,6 +133,10 @@ namespace VulkanUtilities
VkResult GetFenceStatus(VkFence fence)const;
VkResult ResetFence(VkFence fence)const;
+ VkResult WaitForFences(uint32_t fenceCount,
+ const VkFence* pFences,
+ VkBool32 waitAll,
+ uint64_t timeout)const;
void UpdateDescriptorSets(uint32_t descriptorWriteCount,
const VkWriteDescriptorSet* pDescriptorWrites,
diff --git a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp
index caafb42b..424bfb4e 100644
--- a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp
@@ -41,11 +41,10 @@ FenceVkImpl :: FenceVkImpl(IReferenceCounters* pRefCounters,
FenceVkImpl :: ~FenceVkImpl()
{
- while (!m_PendingFences.empty())
- {
- m_FencePool.DisposeFence(std::move(m_PendingFences.front().second));
- m_PendingFences.pop_front();
- }
+ // Do not dispose pending fences as the pool checks that the fence
+ // is signalled, while pending fences may not be.
+ // The pool will be destroyed next anyway, so it makes no difference.
+ m_PendingFences.clear();
}
Uint64 FenceVkImpl :: GetCompletedValue()
@@ -87,7 +86,7 @@ void FenceVkImpl :: Wait()
while (LogicalDevice.GetFenceStatus(val_fence.second) != VK_SUCCESS)
{
VkFence FenceToWait = val_fence.second;
- auto res = vkWaitForFences(LogicalDevice.GetVkDevice(), 1, &FenceToWait, VK_TRUE, UINT64_MAX);
+ auto res = LogicalDevice.WaitForFences(1, &FenceToWait, VK_TRUE, UINT64_MAX);
VERIFY_EXPR(res == VK_SUCCESS);
}
diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
index b7b431f7..5108d43f 100644
--- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanLogicalDevice.cpp
@@ -424,10 +424,18 @@ namespace VulkanUtilities
VkResult VulkanLogicalDevice::ResetFence(VkFence fence)const
{
auto err = vkResetFences(m_VkDevice, 1, &fence);
- DEV_CHECK_ERR(err == VK_SUCCESS, "Failed to reset fence");
+ DEV_CHECK_ERR(err == VK_SUCCESS, "vkResetFences() failed");
return err;
}
+ VkResult VulkanLogicalDevice::WaitForFences(uint32_t fenceCount,
+ const VkFence* pFences,
+ VkBool32 waitAll,
+ uint64_t timeout) const
+ {
+ return vkWaitForFences(m_VkDevice, fenceCount, pFences, waitAll, timeout);
+ }
+
void VulkanLogicalDevice::UpdateDescriptorSets(uint32_t descriptorWriteCount,
const VkWriteDescriptorSet* pDescriptorWrites,
uint32_t descriptorCopyCount,