[Vulkan] Basic Vulkan backend
[platform/core/uifw/dali-core.git] / dali / graphics / vulkan / vulkan-pipeline.h
1 #ifndef DALI_GRAPHICS_VULKAN_PIPELINE
2 #define DALI_GRAPHICS_VULKAN_PIPELINE
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 // INTERNAL INCLUDES
22 #include <dali/graphics/vulkan/vulkan-types.h>
23 #include <dali/graphics/vulkan/vulkan-shader.h>
24
25 namespace Dali
26 {
27 namespace Graphics
28 {
29 namespace Vulkan
30 {
31 class Graphics;
32 class Pipeline : public VkManaged
33 {
34 public:
35
36   /**
37    * Creates immutable Pipeline object ( verified resources for tracking )
38    * @param graphics
39    * @param info
40    * @return
41    */
42   static Handle<Pipeline> New( Graphics& graphics, const vk::GraphicsPipelineCreateInfo& info );
43
44   /**
45    * Destructor
46    */
47   ~Pipeline() override;
48
49   /**
50    * Sets the viewport
51    * @param x
52    * @param y
53    * @param width
54    * @param height
55    */
56   void SetViewport( float x, float y, float width, float height );
57
58   /**
59    * Attaches A shader module to the particular stage of pipeline
60    * @param shader
61    * @param stage
62    * @return
63    */
64   bool SetShader( ShaderRef shader, Shader::Type stage );
65
66   /**
67    *
68    * @param attrDesc
69    * @param bindingDesc
70    */
71   void SetVertexInputState(std::vector<vk::VertexInputAttributeDescription> attrDesc,
72                            std::vector<vk::VertexInputBindingDescription> bindingDesc);
73
74   /**
75    *
76    * @param topology
77    * @param restartEnable
78    */
79   void SetInputAssemblyState( vk::PrimitiveTopology topology, bool restartEnable );
80   /**
81    *
82    * @return
83    */
84   bool Compile();
85
86 private:
87
88   Pipeline( Graphics& graphics, const vk::GraphicsPipelineCreateInfo& info );
89
90 public:
91
92   /**
93    * Returns Vulkan VkPipeline object associated with Pipeline
94    * @return
95    */
96   vk::Pipeline GetVkPipeline() const;
97
98   /**
99    * Returns Vulkan VkPipelineLayout object associated with Pipeline
100    * @return
101    */
102   vk::PipelineLayout GetVkPipelineLayout() const;
103
104   bool OnDestroy() override;
105
106 private:
107   class Impl;
108   std::unique_ptr<Impl> mImpl;
109 };
110
111 using PipelineRef = Handle<Pipeline>;
112
113 } // Namespace Vulkan
114
115 } // Namespace Graphics
116
117 } // Namespace Dali
118
119 #endif // DALI_GRAPHICS_VULKAN_PIPELINE