vsg  1.1.0
VulkanSceneGraph library
Queue.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2018 Robert Osfield
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 
13 </editor-fold> */
14 
15 #include <vsg/core/Object.h>
16 #include <vsg/vk/vulkan.h>
17 
18 #include <mutex>
19 #include <vector>
20 
21 namespace vsg
22 {
23  // forward declare
24  class Fence;
25 
27  class VSG_DECLSPEC Queue : public Inherit<Object, Queue>
28  {
29  public:
30  operator VkQueue() const { return _vkQueue; }
31  VkQueue vk() const { return _vkQueue; }
32 
33  VkQueueFlags queueFlags() const { return _queueFlags; }
34  uint32_t queueFamilyIndex() const { return _queueFamilyIndex; }
35  uint32_t queueIndex() const { return _queueIndex; }
36 
37  VkResult submit(const std::vector<VkSubmitInfo>& submitInfos, Fence* fence = nullptr);
38 
39  VkResult submit(const VkSubmitInfo& submitInfo, Fence* fence = nullptr);
40 
41  VkResult present(const VkPresentInfoKHR& info);
42 
43  VkResult waitIdle();
44 
45  protected:
46  Queue(VkQueue queue, VkQueueFlags queueFlags, uint32_t queueFamilyIndex, uint32_t queueIndex);
47  virtual ~Queue();
48 
49  Queue() = delete;
50  Queue(const Queue&) = delete;
51  Queue& operator=(const Queue&) = delete;
52 
53  // allow only Device to create Queue to ensure that queues are shared
54  friend class Device;
55 
56  VkQueue _vkQueue;
57  VkQueueFlags _queueFlags;
58  uint32_t _queueFamilyIndex;
59  uint32_t _queueIndex;
60  std::mutex _mutex;
61  };
62  VSG_type_name(vsg::Queue);
63 
64  using Queues = std::vector<ref_ptr<Queue>>;
65 
66 } // namespace vsg
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition: Device.h:37
Definition: Fence.h:23
Definition: Inherit.h:28
Queue encapsulates a single vkQueue, used to submit vulkan commands for processing.
Definition: Queue.h:28