1 #ifndef _GLUSHADERLIBRARY_HPP
2 #define _GLUSHADERLIBRARY_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL ES Utilities
5 * ------------------------------------------------
7 * Copyright 2015 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Shader .test file utilities.
24 *//*--------------------------------------------------------------------*/
26 #include "gluDefs.hpp"
27 #include "gluVarType.hpp"
28 #include "gluShaderProgram.hpp"
29 #include "tcuTestCase.hpp"
41 CASETYPE_COMPLETE = 0, //!< Has all shaders specified separately.
42 CASETYPE_VERTEX_ONLY, //!< "Both" case, vertex shader sub case.
43 CASETYPE_FRAGMENT_ONLY, //!< "Both" case, fragment shader sub case.
53 EXPECT_COMPILE_LINK_FAIL,
54 EXPECT_VALIDATION_FAIL,
55 EXPECT_BUILD_SUCCESSFUL,
71 std::vector<Element> elements; // Scalar values (variable.varType.getScalarSize() * #values).
76 std::vector<Value> inputs;
77 std::vector<Value> outputs;
78 std::vector<Value> uniforms;
81 struct RequiredCapability
86 RequiredCapability (void)
92 RequiredCapability (deUint32 enumName_, int referenceValue_)
93 : enumName (enumName_)
94 , referenceValue (referenceValue_)
99 struct RequiredExtension
101 std::vector<std::string> alternatives; // One or more extensions, at least one (but not all) must be supported
102 deUint32 effectiveStages; // Bitfield of shader stages requiring this extension
104 RequiredExtension (const std::vector<std::string>& alternatives_,
105 deUint32 effectiveStages_)
106 : alternatives (alternatives_)
107 , effectiveStages (effectiveStages_)
111 RequiredExtension (const std::string& extension,
112 deUint32 effectiveStages_)
113 : effectiveStages (effectiveStages_)
115 alternatives.push_back(extension);
118 RequiredExtension (void)
119 : effectiveStages (0u)
124 struct ProgramSpecification
126 glu::ProgramSources sources;
127 std::vector<RequiredExtension> requiredExtensions;
128 deUint32 activeStages; // Has an effect only if sources.separable == true, must be 0 otherwise
130 ProgramSpecification (void)
136 struct ShaderCaseSpecification
139 ExpectResult expectResult;
140 glu::GLSLVersion targetVersion;
142 // \todo [pyry] Clean this up
143 std::vector<RequiredCapability> requiredCaps;
144 bool fullGLSLES100Required;
147 std::vector<ProgramSpecification> programs;
149 ShaderCaseSpecification (void)
150 : caseType (CASETYPE_LAST)
151 , expectResult (EXPECT_LAST)
152 , targetVersion (glu::GLSL_VERSION_LAST)
153 , fullGLSLES100Required (false)
158 bool isValid (const ValueBlock& block);
159 bool isValid (const ShaderCaseSpecification& spec);
161 class ShaderCaseFactory
164 virtual tcu::TestCaseGroup* createGroup (const std::string& name, const std::string& description, const std::vector<tcu::TestNode*>& children) = 0;
165 virtual tcu::TestCase* createCase (const std::string& name, const std::string& description, const ShaderCaseSpecification& spec) = 0;
168 std::vector<tcu::TestNode*> parseFile (const tcu::Archive& archive, const std::string& filename, ShaderCaseFactory* caseFactory);
170 // Specialization utilties
172 struct ProgramSpecializationParams
174 const ShaderCaseSpecification& caseSpec;
175 const std::vector<RequiredExtension> requiredExtensions; // Extensions, must be resolved to single ext per entry
176 const int maxPatchVertices; // Used by tess shaders only
178 ProgramSpecializationParams (const ShaderCaseSpecification& caseSpec_,
179 const std::vector<RequiredExtension>& requiredExtensions_,
180 int maxPatchVertices_)
181 : caseSpec (caseSpec_)
182 , requiredExtensions (requiredExtensions_)
183 , maxPatchVertices (maxPatchVertices_)
188 void genCompareFunctions (std::ostringstream& stream, const ValueBlock& valueBlock, bool useFloatTypes);
189 std::string injectExtensionRequirements (const std::string& baseCode, const std::vector<RequiredExtension>& extensions, ShaderType shaderType);
193 void dumpValues (tcu::TestLog& log, const ValueBlock& values, int arrayNdx);
198 #endif // _GLUSHADERLIBRARY_HPP