1 #ifndef DALI_GRAPHICS_API_SHADER_DETAILS_H
2 #define DALI_GRAPHICS_API_SHADER_DETAILS_H
5 * Copyright (c) 2017 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.
31 namespace ShaderDetails
34 constexpr uint32_t ERROR_VERTEX_INPUT_ATTRIBUTE_NOT_FOUND( -1u );
36 enum class ShaderSourceType
45 * Creates shader source object from source string
48 explicit ShaderSource( const std::string& sourceString )
50 source = sourceString;
51 type = ShaderSourceType::STRING;
55 * Creates shader source object from vector
59 explicit ShaderSource( const std::vector<T>& sourceBinary )
61 if(!sourceBinary.empty())
63 code.resize(sourceBinary.size() * sizeof(T));
64 auto begin = reinterpret_cast<const char *>(&*sourceBinary.begin());
65 auto end = reinterpret_cast<const char *>(&*sourceBinary.end());
66 std::copy(begin, end, code.begin());
68 type = ShaderSourceType::BINARY;
72 explicit ShaderSource( const std::vector<char>& sourceBinary )
74 if( !sourceBinary.empty() )
78 type = ShaderSourceType::BINARY;
82 * Creates shader source object from C-Style binary data
86 explicit ShaderSource( const void* pBinary, uint32_t size )
89 auto begin = reinterpret_cast<const char*>(pBinary);
90 auto end = begin + size;
91 std::copy( begin, end, code.begin() );
92 type = ShaderSourceType::BINARY;
95 ShaderSource( const ShaderSource& shaderSource ) = default;
98 * Tests whether the shader module has been set
103 if( type == ShaderSourceType::BINARY )
105 return !code.empty();
108 return !source.empty();
111 bool operator==(const ShaderSource& rhs ) const
113 if( type == ShaderSourceType::BINARY )
115 return code == rhs.code;
119 return source == rhs.source;
124 std::vector<char> code;
125 ShaderSourceType type;
128 enum class Language {
136 enum class PipelineStage {
142 TESSELATION_EVALUATION,
145 enum class VertexInputAttributeFormat
155 enum class UniformClass
159 COMBINED_IMAGE_SAMPLER,
166 std::string name{""};
167 UniformClass uniformClass{ UniformClass::UNDEFINED };
168 uint32_t binding { 0u };
169 uint32_t bufferIndex { 0u };
170 uint32_t offset { 0u };
171 uint32_t location { 0u };
174 struct UniformBlockInfo
176 std::string name {""};
177 uint32_t descriptorSet {0u};
178 uint32_t binding {0u};
180 std::vector<UniformInfo> members {};
183 } // namespace TextureDetails
185 } // namespace Graphics
188 #endif // DALI_GRAPHICS_API_SHADER_DETAILS_H