Merge branch 'devel/master' into devel/graphics
[platform/core/uifw/dali-core.git] / dali / graphics-api / graphics-pipeline-create-info.h
1 #ifndef DALI_GRAPHICS_PIPELINE_CREATE_INFO_H
2 #define DALI_GRAPHICS_PIPELINE_CREATE_INFO_H
3
4 /*
5  * Copyright (c) 2021 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 // EXTERNAL INCLUDES
22 #include <memory>
23
24 // INTERNAL INCLUDES
25 #include "graphics-pipeline.h"
26 #include "graphics-types.h"
27
28 namespace Dali
29 {
30 namespace Graphics
31 {
32 /**
33  * @brief Interface class for generating Pipeline types in the graphics API.
34  *
35  * Pipeline after creation stays immutable unless the dynamic states flag is set.
36  * Dynamic states are set as a bitmask indicating which pipeline states will
37  * be changed dynamically by issuing a command in from the command buffer.
38  *
39  * The dynamic states are listed in Dali::Graphics::PipelineDynamicStateBits.
40  */
41 struct PipelineCreateInfo
42 {
43   /**
44    * @brief Sets pointer to the extension
45    *
46    * The pointer to the extension must be set either to nullptr
47    * or to the valid structure. The structures may create
48    * a chain. The last structure in a chain must point at
49    * nullptr.
50    *
51    * @param[in] value pointer to the valid extension structure
52    * @return reference to this structure
53    */
54   auto& SetNextExtension(ExtensionCreateInfo* value)
55   {
56     nextExtension = value;
57     return *this;
58   }
59
60   /**
61    * @brief Set the program
62    *
63    * @param[in] value
64    * @return a reference to this structure
65    */
66   auto& SetProgramState(ProgramState* value)
67   {
68     programState = value;
69     return *this;
70   }
71
72   /**
73    * @brief Sets the color blend state
74    * @param[in] value pointer to valid color blend state structure
75    * @return reference to this structure
76    */
77   auto& SetColorBlendState(ColorBlendState* value)
78   {
79     colorBlendState = value;
80     return *this;
81   }
82
83   /**
84    * @brief Sets the viewport state.
85    *
86    * @param[in] value pointer to valid viewport state structure
87    * @return reference to this structure
88    */
89   auto& SetViewportState(ViewportState* value)
90   {
91     viewportState = value;
92     return *this;
93   }
94
95   /**
96    * @brief Sets the framebuffer state.
97    *
98    * @param[in] value pointer to valid framebuffer state structure
99    * @return reference to this structure
100    */
101   auto& SetFramebufferState(FramebufferState* value)
102   {
103     framebufferState = value;
104     return *this;
105   }
106
107   /**
108    * @brief Sets the base pipeline.
109    *
110    * Setting base pipeline allows inheriting that pipeline state
111    * and build the new pipeline from it. The base pipeline
112    * must stay valid until derived pipeline needs it.
113    *
114    * @param[in] value pointer to valid pipeline object
115    * @return reference to this structure
116    */
117   auto& SetBasePipeline(Pipeline* value)
118   {
119     basePipeline = value;
120     return *this;
121   }
122
123   /**
124    * @brief Sets the depth/stencil state.
125    *
126    * @param[in] pointer to valid depth/stencil state structure
127    * @return reference to this structure
128    */
129   auto& SetDepthStencilState(DepthStencilState* value)
130   {
131     depthStencilState = value;
132     return *this;
133   }
134
135   /**
136    * @brief Sets the rasterization state.
137    *
138    * @param[in] pointer to valid rasterization state structure
139    * @return reference to this structure
140    */
141   auto& SetRasterizationState(RasterizationState* value)
142   {
143     rasterizationState = value;
144     return *this;
145   }
146
147   /**
148    * @brief Sets the vertex input state.
149    *
150    * Vertex input state describes format of vertices and must
151    * be compatible with attached shaders.
152    *
153    * @param[in] pointer to vertex input state structure
154    * @return reference to this structure
155    */
156   auto& SetVertexInputState(VertexInputState* value)
157   {
158     vertexInputState = value;
159     return *this;
160   }
161
162   /**
163    * @brief Sets the input assembly state.
164    *
165    * This state describes the topology of the pipeline.
166    *
167    * @param[in] pointer to valid input assembly state structure
168    * @return reference to this structure
169    */
170   auto& SetInputAssemblyState(InputAssemblyState* value)
171   {
172     inputAssemblyState = value;
173     return *this;
174   }
175
176   /**
177    * @brief Sets the dynamic state mask.
178    *
179    * Certain states can be modified on fly without a need of
180    * creating new pipeline. The commands which modify particular
181    * states may be issued later by executing command buffers.
182    *
183    * @param[in] pointer to valid color blend state structure
184    * @return reference to this structure
185    */
186   auto& SetDynamicStateMask(PipelineDynamicStateMask value)
187   {
188     dynamicStateMask = value;
189     return *this;
190   }
191
192   /**
193    * @brief Sets allocation callbacks which will be used when object is created
194    * and destroyed.
195    *
196    * @param[in] value Valid reference to AllocationCallbacksStructure
197    * @return reference to this structure
198    */
199   auto& SetAllocationCallbacks(const AllocationCallbacks& value)
200   {
201     allocationCallbacks = &value;
202     return *this;
203   }
204
205   GraphicsStructureType type{GraphicsStructureType::PIPELINE_CREATE_INFO_STRUCT};
206   ExtensionCreateInfo*  nextExtension{nullptr};
207
208   ProgramState*            programState{nullptr};
209   ColorBlendState*         colorBlendState{nullptr};
210   ViewportState*           viewportState{nullptr};
211   FramebufferState*        framebufferState{nullptr};
212   Pipeline*                basePipeline{nullptr};
213   DepthStencilState*       depthStencilState{nullptr};
214   RasterizationState*      rasterizationState{nullptr};
215   VertexInputState*        vertexInputState{nullptr};
216   InputAssemblyState*      inputAssemblyState{nullptr};
217   PipelineDynamicStateMask dynamicStateMask{0u};
218
219   const AllocationCallbacks* allocationCallbacks{nullptr};
220 };
221
222 } // namespace Graphics
223 } // namespace Dali
224
225 #endif // DALI_GRAPHICS_PIPELINE_CREATE_INFO_H