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.
30 namespace ShaderDetails
33 constexpr uint32_t ERROR_VERTEX_INPUT_ATTRIBUTE_NOT_FOUND( -1u );
35 enum class ShaderSourceType
44 * Creates shader source object from source string
47 explicit ShaderSource( const std::string& sourceString )
49 source = sourceString;
50 type = ShaderSourceType::STRING;
54 * Creates shader source object from vector
58 explicit ShaderSource( const std::vector<T>& sourceBinary )
60 code.resize( sourceBinary.size() * sizeof(T) );
61 auto begin = reinterpret_cast<const char*>(&*sourceBinary.begin());
62 auto end = reinterpret_cast<const char*>(&*sourceBinary.end());
63 std::copy( begin, end, code.begin() );
64 type = ShaderSourceType::BINARY;
68 explicit ShaderSource( const std::vector<char>& sourceBinary )
71 type = ShaderSourceType::BINARY;
75 * Creates shader source object from C-Style binary data
79 explicit ShaderSource( const void* pBinary, uint32_t size )
82 auto begin = reinterpret_cast<const char*>(pBinary);
83 auto end = begin + size;
84 std::copy( begin, end, code.begin() );
85 type = ShaderSourceType::BINARY;
88 ShaderSource( const ShaderSource& shaderSource ) = default;
91 * Tests whether the shader module has been set
96 if( (type == ShaderSourceType::BINARY && code.empty()) ||
97 (type == ShaderSourceType::STRING && source.empty()) )
104 bool operator==(const ShaderSource& rhs ) const
106 if( type == ShaderSourceType::BINARY )
108 return code == rhs.code;
112 return source == rhs.source;
118 std::vector<char> code;
119 ShaderSourceType type;
122 enum class Language {
130 enum class PipelineStage {
136 TESSELATION_EVALUATION,
139 enum class VertexInputAttributeFormat
149 enum class UniformClass
153 COMBINED_IMAGE_SAMPLER,
160 std::string name{""};
161 UniformClass uniformClass{ UniformClass::UNDEFINED };
162 uint32_t binding { 0u };
163 uint32_t bufferIndex { 0u };
164 uint32_t offset { 0u };
165 uint32_t location { 0u };
168 struct UniformBlockInfo
170 std::string name {""};
171 uint32_t descriptorSet {0u};
172 uint32_t binding {0u};
174 std::vector<UniformInfo> members {};
177 } // namespace TextureDetails
179 } // namespace Graphics
182 #endif // DALI_GRAPHICS_API_SHADER_DETAILS_H