1 #ifndef DALI_GRAPHICS_REFLECTION_H
2 #define DALI_GRAPHICS_REFLECTION_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.
22 #include "graphics-types.h"
29 * @brief The Reflection class represents a single shader that can be bound
30 * to the specific stage of pipeline (vertex, fragment, compute etc.).
32 * Reflections are linked together when pipeline is created.
38 Reflection() = default;
39 virtual ~Reflection() = default;
42 Reflection(const Reflection&) = delete;
43 Reflection& operator=(const Reflection&) = delete;
48 * @brief Gets the location of a vertex attribute.
50 * @param [in] name The name of vertex attribute
51 * @return The index of the vertex attribute in the shader
53 virtual uint32_t GetVertexAttributeLocation(const std::string& name) const = 0;
56 * @brief Gets the format of a vertex attribute.
58 * @param [in] location The location of vertex attribute
59 * @return The format of a vertex attribute
61 virtual Dali::Graphics::VertexInputAttributeFormat GetVertexAttributeFormat(uint32_t location) const = 0;
64 * @brief Gets the name of a vertex attribute.
66 * @param [in] location The location of vertex attribute
67 * @return The name of the vertex attribute
69 virtual std::string GetVertexAttributeName(uint32_t location) const = 0;
72 * @brief Gets the locations of all the vertex attribute in the shader.
74 * @return A vector of the locations of all the vertex attributes in the shader
76 virtual std::vector<uint32_t> GetVertexAttributeLocations() const = 0;
81 * @brief Gets the number of uniform blocks in the shader
83 * @return The number of uniform blocks
85 virtual uint32_t GetUniformBlockCount() const = 0;
88 * @brief Gets the binding point to which the uniform block with the given index is binded.
90 * @param [in] index The index of the uniform block
91 * @return The binding point
93 virtual uint32_t GetUniformBlockBinding(uint32_t index) const = 0;
96 * @brief Gets the size of the uniform block with the given index.
98 * @param [in] index The index of the uniform block
99 * @return The size of the uniform block
101 virtual uint32_t GetUniformBlockSize(uint32_t index) const = 0;
104 * @brief Retrieves the information of the uniform block with the given index.
106 * The information includes the name, binding point, size, uniforms inside the uniform block, etc.
108 * @param [in] index The index of the uniform block
109 * @param [out] out A structure that contains the information of the uniform block
110 * @return Whether the uniform block exists or not
112 virtual bool GetUniformBlock(uint32_t index, Dali::Graphics::UniformBlockInfo& out) const = 0;
115 * @brief Gets the binding points of all the uniform blocks in the shader.
117 * @return A vector of binding points
119 virtual std::vector<uint32_t> GetUniformBlockLocations() const = 0;
122 * @brief Gets the name of uniform block with the given index.
124 * @param [in] blockIndex The index of the uniform block
125 * @return The name of the uniform block
127 virtual std::string GetUniformBlockName(uint32_t blockIndex) const = 0;
130 * @brief Gets the number of uniforms in the uniform block with the given index.
132 * @param [in] blockIndex The index of the uniform block
133 * @return The number of uniforms in the uniform block
135 virtual uint32_t GetUniformBlockMemberCount(uint32_t blockIndex) const = 0;
138 * @brief Gets the name of the uniform in the given location within the uniform block.
140 * @param [in] blockIndex The index of the uniform block
141 * @param [in] memberLocation The location of the uniform within the uniform block
142 * @return The name of the uniform
144 virtual std::string GetUniformBlockMemberName(uint32_t blockIndex, uint32_t memberLocation) const = 0;
147 * @brief Gets the byte offset of the uniform in the given location within the uniform block.
149 * @param [in] blockIndex The index of the uniform block
150 * @param [in] memberLocation The location of the uniform within the uniform block
151 * @return The byte offset of the uniform
153 virtual uint32_t GetUniformBlockMemberOffset(uint32_t blockIndex, uint32_t memberLocation) const = 0;
158 * @brief Gets the information of the uniform by its name.
160 * @param [in] name The name of the uniform
161 * @param [out] out The information of the uniform
162 * @return Whether the uniform exists or not
164 virtual bool GetNamedUniform(const std::string& name, Dali::Graphics::UniformInfo& out) const = 0;
169 * @brief Gets all the sampler uniforms
171 * @return A vector of the sampler uniforms
173 virtual std::vector<Dali::Graphics::UniformInfo> GetSamplers() const = 0;
178 * @brief Retrieves the language of the shader
180 * @return The language of the shader
182 virtual Graphics::ShaderLanguage GetLanguage() const = 0;
185 Reflection(Reflection&&) = default;
186 Reflection& operator=(Reflection&&) = default;
189 } // Namespace Graphics
192 #endif // DALI_GRAPHICS_REFLECTION_H