[Vulkan] Basic Vulkan backend
[platform/core/uifw/dali-core.git] / dali / graphics / vulkan / vulkan-descriptor-set.h
1 #ifndef DALI_GRAPHICS_VULKAN_DESCRIPTOR_SET
2 #define DALI_GRAPHICS_VULKAN_DESCRIPTOR_SET
3
4 /*
5  * Copyright (c) 2018 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 #include <dali/graphics/vulkan/vulkan-types.h>
22
23 namespace Dali
24 {
25 namespace Graphics
26 {
27 namespace Vulkan
28 {
29 class Graphics;
30 class Buffer;
31 class Image;
32 class DescriptorPool;
33
34 class DescriptorSet : public VkManaged
35 {
36   friend class DescriptorPool;
37
38 public:
39
40   ~DescriptorSet() override;
41
42   /**
43    *
44    * @param buffer
45    * @param offset
46    * @param size
47    */
48   void WriteUniformBuffer( uint32_t binding, Handle<Buffer> buffer, uint32_t offset, uint32_t size );
49
50   /**
51    *
52    * @param buffer
53    * @param offset
54    * @param size
55    */
56   void WriteStorageBuffer( Handle<Buffer> buffer, uint32_t offset, uint32_t size );
57
58   /**
59    *
60    */
61   void WriteImage( Handle<Image> );
62
63   /**
64    *
65    * @param writeDescriptorSet
66    */
67   void Write( vk::WriteDescriptorSet writeDescriptorSet );
68
69   /**
70    * Returns VkDescriptorSet associated with this object
71    * @return Descriptor set
72    */
73   vk::DescriptorSet GetVkDescriptorSet() const;
74
75 private:
76
77   DescriptorSet( Graphics& graphics, DescriptorPool& pool, vk::DescriptorSet descriptorSet, vk::DescriptorSetAllocateInfo allocateInfo );
78
79   class Impl;
80   std::unique_ptr<Impl> mImpl;
81 };
82
83 using DescriptorSetHandle = Handle<DescriptorSet>;
84
85 class DescriptorPool : public VkManaged
86 {
87 public:
88
89   static Handle<DescriptorPool> New( Graphics& graphics, const vk::DescriptorPoolCreateInfo& createInfo );
90
91   ~DescriptorPool() override;
92
93   vk::DescriptorPool GetVkDescriptorPool() const;
94
95   std::vector<DescriptorSetHandle> AllocateDescriptorSets( vk::DescriptorSetAllocateInfo allocateInfo );
96
97 private:
98
99   DescriptorPool( Graphics& graphics, const vk::DescriptorPoolCreateInfo& createInfo );
100
101   class Impl;
102   std::unique_ptr<Impl> mImpl;
103 };
104
105
106 class DescriptorSetLayout
107 {
108 public:
109
110   static std::unique_ptr<DescriptorSetLayout> New( Graphics& graphics, const vk::DescriptorSetLayoutCreateInfo& createInfo );
111
112 private:
113
114   DescriptorSetLayout( Graphics& graphics, const vk::DescriptorSetLayoutCreateInfo& createInfo );
115
116 private:
117
118   class Impl;
119   std::unique_ptr<Impl> mImpl;
120 };
121
122 } // Namespace Vulkan
123
124 } // Namespace Graphics
125
126 } // Namespace Dali
127
128 #endif // DALI_GRAPHICS_VULKAN_DESCRIPTOR_SET