Diligent Engine  v.2.4.g
CommandQueueVkImpl.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include <mutex>
34 #include <deque>
35 #include <atomic>
36 
37 #include "EngineVkImplTraits.hpp"
38 #include "ObjectBase.hpp"
39 #include "FenceVkImpl.hpp"
40 
43 
44 
45 namespace Diligent
46 {
47 
49 class CommandQueueVkImpl final : public ObjectBase<ICommandQueueVk>
50 {
51 public:
53 
55  std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> LogicalDevice,
56  uint32_t QueueFamilyIndex);
58 
59  IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_CommandQueueVk, TBase)
60 
61 
62  virtual Uint64 DILIGENT_CALL_TYPE GetNextFenceValue() const override final { return m_NextFenceValue.load(); }
63 
65  virtual Uint64 DILIGENT_CALL_TYPE SubmitCmdBuffer(VkCommandBuffer cmdBuffer) override final;
66 
68  virtual Uint64 DILIGENT_CALL_TYPE Submit(const VkSubmitInfo& SubmitInfo) override final;
69 
71  virtual VkResult DILIGENT_CALL_TYPE Present(const VkPresentInfoKHR& PresentInfo) override final;
72 
74  virtual VkQueue DILIGENT_CALL_TYPE GetVkQueue() override final { return m_VkQueue; }
75 
77  virtual uint32_t DILIGENT_CALL_TYPE GetQueueFamilyIndex() const override final { return m_QueueFamilyIndex; }
78 
80  virtual Uint64 DILIGENT_CALL_TYPE WaitForIdle() override final;
81 
83  virtual Uint64 DILIGENT_CALL_TYPE GetCompletedFenceValue() override final;
84 
86  virtual void DILIGENT_CALL_TYPE SignalFence(VkFence vkFence) override final;
87 
88  void SetFence(RefCntAutoPtr<FenceVkImpl> pFence) { m_pFence = std::move(pFence); }
89 
90 private:
91  std::shared_ptr<VulkanUtilities::VulkanLogicalDevice> m_LogicalDevice;
92 
93  const VkQueue m_VkQueue;
94  const uint32_t m_QueueFamilyIndex;
95  // Fence is signaled right after a command buffer has been
96  // submitted to the command queue for execution.
97  // All command buffers with fence value less than or equal to the signaled value
98  // are guaranteed to be finished by the GPU
100 
101  // A value that will be signaled by the command queue next
102  std::atomic_uint64_t m_NextFenceValue{1};
103 
104  std::mutex m_QueueMutex;
105 };
106 
107 } // namespace Diligent
VulkanHeaders.h
ObjectBase.hpp
VulkanLogicalDevice.hpp
Diligent::CommandQueueVkImpl::SignalFence
virtual void SignalFence(VkFence vkFence) override final
Implementation of ICommandQueueVk::SignalFence().
Definition: CommandQueueVkImpl.cpp:125
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
Diligent::CommandQueueVkImpl::GetQueueFamilyIndex
virtual uint32_t GetQueueFamilyIndex() const override final
Implementation of ICommandQueueVk::GetQueueFamilyIndex().
Definition: CommandQueueVkImpl.hpp:77
Diligent::CommandQueueVkImpl::SubmitCmdBuffer
virtual Uint64 SubmitCmdBuffer(VkCommandBuffer cmdBuffer) override final
Implementation of ICommandQueueVk::Submit().
Definition: CommandQueueVkImpl.cpp:84
Diligent::CommandQueueVkImpl::SetFence
void SetFence(RefCntAutoPtr< FenceVkImpl > pFence)
Definition: CommandQueueVkImpl.hpp:88
Diligent::CommandQueueVkImpl::WaitForIdle
virtual Uint64 WaitForIdle() override final
Implementation of ICommandQueueVk::GetQueueFamilyIndex().
Definition: CommandQueueVkImpl.cpp:104
Diligent::Uint64
uint64_t Uint64
64-bit unsigned integer
Definition: BasicTypes.h:50
Diligent::ObjectBase
Template class implementing base functionality for an object.
Definition: ObjectBase.hpp:66
Diligent::CommandQueueVkImpl::~CommandQueueVkImpl
~CommandQueueVkImpl()
Definition: CommandQueueVkImpl.cpp:52
Diligent::CommandQueueVkImpl::CommandQueueVkImpl
CommandQueueVkImpl(IReferenceCounters *pRefCounters, std::shared_ptr< VulkanUtilities::VulkanLogicalDevice > LogicalDevice, uint32_t QueueFamilyIndex)
Definition: CommandQueueVkImpl.cpp:39
Diligent::CommandQueueVkImpl
Implementation of the Diligent::ICommandQueueVk interface.
Definition: CommandQueueVkImpl.hpp:49
Diligent::CommandQueueVkImpl::GetNextFenceValue
virtual Uint64 GetNextFenceValue() const override final
Implementation of ICommandQueueVk::GetNextFenceValue().
Definition: CommandQueueVkImpl.hpp:62
IMPLEMENT_QUERY_INTERFACE_IN_PLACE
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
Diligent::RefCntAutoPtr
Template class that implements reference counting.
Definition: RefCntAutoPtr.hpp:73
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::CommandQueueVkImpl::Present
virtual VkResult Present(const VkPresentInfoKHR &PresentInfo) override final
Implementation of ICommandQueueVk::Present().
Definition: CommandQueueVkImpl.cpp:134
Diligent::CommandQueueVkImpl::GetCompletedFenceValue
virtual Uint64 GetCompletedFenceValue() override final
Implementation of ICommandQueueVk::GetCompletedFenceValue().
Definition: CommandQueueVkImpl.cpp:119
Diligent::FenceVkImpl
Fence implementation in Vulkan backend.
Definition: FenceVkImpl.hpp:44
EngineVkImplTraits.hpp
FenceVkImpl.hpp
Diligent::CommandQueueVkImpl::GetVkQueue
virtual VkQueue GetVkQueue() override final
Implementation of ICommandQueueVk::GetVkQueue().
Definition: CommandQueueVkImpl.hpp:74
Diligent::CommandQueueVkImpl::Submit
virtual Uint64 Submit(const VkSubmitInfo &SubmitInfo) override final
Implementation of ICommandQueueVk::Submit().
Definition: CommandQueueVkImpl.cpp:59
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37