351a9fbfba04b61629b689380e66e8ec902a2270
[platform/core/uifw/dali-core.git] / dali / graphics / vulkan / vulkan-queue.h
1 #ifndef DALI_GRAPHICS_VULKAN_QUEUE_H
2 #define DALI_GRAPHICS_VULKAN_QUEUE_H
3
4 /*
5  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/graphics/vulkan/vulkan-types.h>
23
24 namespace Dali
25 {
26 namespace Graphics
27 {
28 namespace Vulkan
29 {
30
31 class Fence;
32 class Submission
33 {
34 public:
35   Submission(Fence& fence);
36
37   bool WaitForFence(uint32_t timeout = 0u);
38
39 private:
40   // todo: possibly resources locks stored here?
41   FenceRef mFences;
42 };
43
44 class Queue
45 {
46 public:
47   Queue() = delete;
48   Queue(Graphics& graphics, vk::Queue queue, uint32_t queueFamilyIndex, uint32_t queueIndex,
49         vk::QueueFlags queueFlags);
50   ~Queue(); // queues are non-destructible
51
52   /** Submits command buffers */
53   std::unique_ptr< Submission > Submit(const std::vector< CommandBufferRef >& commandBuffers,
54                                        Fence&                                 fence);
55
56   /** Helper function to submit single command buffer */
57   std::unique_ptr< Submission > Submit(CommandBuffer& commandBuffer, Fence& fence);
58
59   void WaitIdle() const;
60
61   /**
62    *
63    * @param presentInfo
64    * @return
65    */
66   vk::Result Present( const vk::PresentInfoKHR& presentInfo );
67
68   /**
69    *
70    * @param swapchain
71    * @return
72    */
73   vk::Result Present( vk::SwapchainKHR swapchain, uint32_t imageIndex );
74
75 private:
76   /** Prepares command buffers for submission */
77   std::vector< vk::CommandBuffer > PrepareBuffers(
78       const std::vector< CommandBufferRef >& commandBuffers) const;
79
80
81
82 private:
83   Graphics&                mGraphics;
84   vk::Queue                mQueue;
85   vk::QueueFlags           mFlags;
86   std::vector< vk::Fence > mFences;
87   uint32_t                 mQueueFamilyIndex;
88   uint32_t                 mQueueIndex;
89 };
90
91 } // namespace Vulkan
92 } // namespace Graphics
93 } // namespace Dali
94
95 #endif // DALI_GRAPHICS_VULKAN_QUEUE_H