Merge branch 'devel/master' into devel/graphics
[platform/core/uifw/dali-core.git] / dali / graphics-api / graphics-shader-create-info.h
1 #ifndef DALI_GRAPHICS_SHADER_CREATE_INFO_H
2 #define DALI_GRAPHICS_SHADER_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-shader.h"
26 #include "graphics-types.h"
27
28 namespace Dali
29 {
30 namespace Graphics
31 {
32 /**
33  * @brief ShaderCreateInfo contains details of a single shader (not a GL program!)
34  * attached to a specified pipeline stage (ie. vertex shader, fragment shader etc.)
35  */
36 struct ShaderCreateInfo
37 {
38   /**
39    * @brief Sets pointer to the extension
40    *
41    * The pointer to the extension must be set either to nullptr
42    * or to the valid structure. The structures may create
43    * a chain. The last structure in a chain must point at
44    * nullptr.
45    *
46    * @param[in] value pointer to the valid extension structure
47    * @return reference to this structure
48    */
49   auto& SetNextExtension(ExtensionCreateInfo* value)
50   {
51     nextExtension = value;
52     return *this;
53   }
54
55   /**
56    * @brief Sets pipeline stage the shader will be executed in
57    *
58    * @param[in] value valid pipeline stage
59    * @return reference to this structure
60    */
61   auto& SetPipelineStage(PipelineStage value)
62   {
63     pipelineStage = value;
64     return *this;
65   }
66
67   /**
68    * @brief Sets shader source language
69    *
70    * @param[in] value valid source language
71    * @return reference to this structure
72    */
73   auto& SetShaderlanguage(ShaderLanguage value)
74   {
75     shaderlanguage = value;
76     return *this;
77   }
78
79   /**
80    * @brief Sets pointer to the source data
81    *
82    * @param[in] value pointer to the source data
83    * @return reference to this structure
84    */
85   auto& SetSourceData(const void* value)
86   {
87     sourceData = value;
88     return *this;
89   }
90
91   /**
92    * @brief Sets size of the source data (in bytes)
93    *
94    * If the shader mode is TEXT, the size must include
95    * null-terminator.
96    *
97    * @param[in] value size in bytes
98    * @return reference to this structure
99    */
100   auto& SetSourceSize(uint32_t value)
101   {
102     sourceSize = value;
103     return *this;
104   }
105
106   /**
107    * @brief Sets shader source mode
108    *
109    * @param[in] value shader mode
110    * @return reference to this structure
111    */
112   auto& SetSourceMode(ShaderSourceMode value)
113   {
114     sourceMode = value;
115     return *this;
116   }
117
118   /**
119    * @brief Sets allocation callbacks which will be used when object is created
120    * and destroyed.
121    *
122    * @param[in] value Valid reference to AllocationCallbacksStructure
123    * @return reference to this structure
124    */
125   auto& SetAllocationCallbacks(const AllocationCallbacks& value)
126   {
127     allocationCallbacks = &value;
128     return *this;
129   }
130
131   GraphicsStructureType type{GraphicsStructureType::SHADER_CREATE_INFO_STRUCT};
132   ExtensionCreateInfo*  nextExtension{nullptr};
133
134   PipelineStage    pipelineStage{};
135   ShaderLanguage   shaderlanguage{};
136   const void*      sourceData{nullptr};
137   uint32_t         sourceSize{0u};
138   ShaderSourceMode sourceMode{};
139
140   const AllocationCallbacks* allocationCallbacks{nullptr};
141 };
142
143 } // namespace Graphics
144 } // namespace Dali
145
146 #endif // DALI_GRAPHICS_SHADER_CREATE_INFO_H