1 #ifndef DALI_GRAPHICS_PIPELINE_CREATE_INFO_H
2 #define DALI_GRAPHICS_PIPELINE_CREATE_INFO_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include "graphics-pipeline.h"
26 #include "graphics-types.h"
33 * @brief Interface class for generating Pipeline types in the graphics API.
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.
39 * The dynamic states are listed in Dali::Graphics::PipelineDynamicStateBits.
41 struct PipelineCreateInfo
44 * @brief Sets pointer to the extension
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
51 * @param[in] value pointer to the valid extension structure
52 * @return reference to this structure
54 auto& SetNextExtension(ExtensionCreateInfo* value)
56 nextExtension = value;
61 * @brief Sets the color blend state
62 * param[in] pointer to valid color blend state structure
63 * @return reference to this structure
65 auto& SetColorBlendState(ColorBlendState* value)
67 colorBlendState = value;
72 * @brief Sets the shader state for the pipeline
74 * The function takes an array of shader states in order to compile
75 * the pipeline. Each ShaderState structure determines the pipeline stage
76 * the shader should be executed on. The Shader object may be already created
77 * with a specific stage. Then the ShaderState::inheritPipelineStage must be
81 * SetShaderState( { ShaderState().SetShader( vertexShader)
82 * .SetPipelineStage( PipelineStage::VERTEX_SHADER ),
83 * ShaderState().SetShader( fragmentShader )
84 * .SetPipelineStage( PipelineStage::FRAGMENT_SHADER )
87 * In modern graphics API it is possible to attach more than one Shader to a single
88 * stage. For example, one Shader may be just a library of functions:
89 * SetShaderState( { ShaderState().SetShader( vertexShader)
90 * .SetPipelineStage( PipelineStage::VERTEX_SHADER ),
91 * ShaderState().SetShader( shaderCommons )
92 * .SetPipelineStage( PipelineStage::VERTEX_SHADER ),
93 * ShaderState().SetShader( fragmentShader )
94 * .SetPipelineStage( PipelineStage::FRAGMENT_SHADER )
97 * The Pipeline will compile and link all given shaders.
99 * param[in] value Valid array of shder states
100 * @return reference to this structure
102 auto& SetShaderState(const std::vector<ShaderState>& value)
104 shaderState = &value;
109 * @brief Sets the viewport state
110 * param[in] pointer to valid viewport state structure
111 * @return reference to this structure
113 auto& SetViewportState(ViewportState* value)
115 viewportState = value;
120 * @brief Sets the framebuffer state
121 * param[in] pointer to valid framebuffer state structure
122 * @return reference to this structure
124 auto& SetFramebufferState(FramebufferState* value)
126 framebufferState = value;
131 * @brief Sets the base pipeline
133 * Setting base pipeline allows inheriting that pipeline state
134 * and build the new pipeline from it. The base pipeline
135 * must stay valid until derived pipeline needs it.
137 * param[in] pointer to valid pipeline object
138 * @return reference to this structure
140 auto& SetBasePipeline(Pipeline* value)
142 basePipeline = value;
147 * @brief Sets the depth/stencil state
148 * param[in] pointer to valid depth/stencil state structure
149 * @return reference to this structure
151 auto& SetDepthStencilState(DepthStencilState* value)
153 depthStencilState = value;
158 * @brief Sets the rasterization state
159 * param[in] pointer to valid rasterization state structure
160 * @return reference to this structure
162 auto& SetRasterizationState(RasterizationState* value)
164 rasterizationState = value;
169 * @brief Sets the vertex input state
171 * Vertex input state describes format of vertices and must
172 * be compatible with attached shaders.
174 * param[in] pointer to vertex input state structure
175 * @return reference to this structure
177 auto& SetVertexInputState(VertexInputState* value)
179 vertexInputState = value;
184 * @brief Sets the input assembly state
186 * This state describes the topology of the pipeline.
188 * param[in] pointer to valid input assembly state structure
189 * @return reference to this structure
191 auto& SetInputAssemblyState(InputAssemblyState* value)
193 inputAssemblyState = value;
198 * @brief Sets the dynamic state mask
200 * Certain states can be modified on fly without a need of
201 * creating new pipeline. The commands which modify particular
202 * states may be issued later by executing command buffers.
204 * param[in] pointer to valid color blend state structure
205 * @return reference to this structure
207 auto& SetDynamicStateMask(PipelineDynamicStateMask value)
209 dynamicStateMask = value;
214 * @brief Sets allocation callbacks which will be used when object is created
217 * @param[in] value Valid reference to AllocationCallbacksStructure
218 * @return reference to this structure
220 auto& SetAllocationCallbacks(const AllocationCallbacks& value)
222 allocationCallbacks = &value;
226 GraphicsStructureType type{GraphicsStructureType::PIPELINE_CREATE_INFO_STRUCT};
227 ExtensionCreateInfo* nextExtension{nullptr};
229 ColorBlendState* colorBlendState{nullptr};
230 const std::vector<ShaderState>* shaderState{nullptr};
231 ViewportState* viewportState{nullptr};
232 FramebufferState* framebufferState{nullptr};
233 Pipeline* basePipeline{nullptr};
234 DepthStencilState* depthStencilState{nullptr};
235 RasterizationState* rasterizationState{nullptr};
236 VertexInputState* vertexInputState{nullptr};
237 InputAssemblyState* inputAssemblyState{nullptr};
238 PipelineDynamicStateMask dynamicStateMask{0u};
240 const AllocationCallbacks* allocationCallbacks{nullptr};
243 } // namespace Graphics
246 #endif // DALI_GRAPHICS_PIPELINE_CREATE_INFO_H