diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-09-08 21:56:26 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-09-08 21:56:26 +0000 |
| commit | 52d1b5ab7fee4f2c4e63eaf5774d48111becba12 (patch) | |
| tree | 9eac4952a2eb4765352270cc7993fbefec83c6ce /Graphics/GraphicsEngineVulkan | |
| parent | Updated constructor of RefCountedObject to forward arguments to its base class (diff) | |
| download | DiligentCore-52d1b5ab7fee4f2c4e63eaf5774d48111becba12.tar.gz DiligentCore-52d1b5ab7fee4f2c4e63eaf5774d48111becba12.zip | |
Added IDeviceContext::Wait() method (updated API version to 240026)
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
5 files changed, 24 insertions, 7 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index 417f2f5b..bce9f300 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -159,6 +159,8 @@ public: virtual void SignalFence(IFence* pFence, Uint64 Value)override final; + virtual void Wait(IFence* pFence, Uint64 Value)override final; + // Transitions texture subresources from OldState to NewState, and optionally updates // internal texture state. // If OldState == RESOURCE_STATE_UNKNOWN, internal texture state is used as old state. diff --git a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h index 9816bfb1..a6c80c83 100644 --- a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h @@ -65,7 +65,7 @@ public: m_PendingFences.emplace_back(FenceValue, std::move(vkFence)); } - void Wait(); + void Wait(Uint64 Value); private: VulkanUtilities::VulkanFencePool m_FencePool; diff --git a/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp index 8ee3e7b6..2af4e27f 100644 --- a/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/CommandQueueVkImpl.cpp @@ -101,7 +101,7 @@ Uint64 CommandQueueVkImpl::WaitForIdle() Atomics::AtomicIncrement(m_NextFenceValue); vkQueueWaitIdle(m_VkQueue); // For some reason after idling the queue not all fences are signaled - m_pFence->Wait(); + m_pFence->Wait(UINT64_MAX); m_pFence->Reset(LastCompletedFenceValue); return LastCompletedFenceValue; } diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 3a3c301a..d2252b4a 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -31,6 +31,7 @@ #include "BufferVkImpl.h" #include "VulkanTypeConversions.h" #include "CommandListVkImpl.h" +#include "FenceVkImpl.h" #include "GraphicsAccessories.h" namespace Diligent @@ -1913,7 +1914,16 @@ namespace Diligent { VERIFY(!m_bIsDeferred, "Fence can only be signaled from immediate context"); m_PendingFences.emplace_back( std::make_pair(Value, pFence) ); - }; + } + + void DeviceContextVkImpl::Wait(IFence* pFence, Uint64 Value) + { + VERIFY(!m_bIsDeferred, "Fence can only be waited from immediate context"); + Flush(); + auto* pFenceVk = ValidatedCast<FenceVkImpl>(pFence); + pFenceVk->Wait(Value); + } + void DeviceContextVkImpl::TransitionImageLayout(ITexture* pTexture, VkImageLayout NewLayout) { diff --git a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp index 3314598a..07f8ba23 100644 --- a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp @@ -48,7 +48,7 @@ FenceVkImpl :: ~FenceVkImpl() // Vulkan spec states that all queue submission commands that refer to // a fence must have completed execution before the fence is destroyed. // (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyFence-fence-01120) - Wait(); + Wait(UINT64_MAX); } } @@ -83,11 +83,15 @@ void FenceVkImpl :: Reset(Uint64 Value) } -void FenceVkImpl :: Wait() +void FenceVkImpl :: Wait(Uint64 Value) { const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); - for (auto& val_fence : m_PendingFences) + while (!m_PendingFences.empty()) { + auto& val_fence = m_PendingFences.front(); + if (val_fence.first > Value) + break; + auto status = LogicalDevice.GetFenceStatus(val_fence.second); if (status == VK_NOT_READY) { @@ -99,8 +103,9 @@ void FenceVkImpl :: Wait() if (val_fence.first > m_LastCompletedFenceValue) m_LastCompletedFenceValue = val_fence.first; m_FencePool.DisposeFence(std::move(val_fence.second)); + + m_PendingFences.pop_front(); } - m_PendingFences.clear(); } } |
