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,
79 std::vector<Element> elements; // Scalar values (variable.varType.getScalarSize() * #values).
84 std::vector<Value> inputs;
85 std::vector<Value> outputs;
86 std::vector<Value> uniforms;
89 struct RequiredCapability
94 RequiredCapability (void)
100 RequiredCapability (deUint32 enumName_, int referenceValue_)
101 : enumName (enumName_)
102 , referenceValue (referenceValue_)
107 struct RequiredExtension
109 std::vector<std::string> alternatives; // One or more extensions, at least one (but not all) must be supported
110 deUint32 effectiveStages; // Bitfield of shader stages requiring this extension
112 RequiredExtension (const std::vector<std::string>& alternatives_,
113 deUint32 effectiveStages_)
114 : alternatives (alternatives_)
115 , effectiveStages (effectiveStages_)
119 RequiredExtension (const std::string& extension,
120 deUint32 effectiveStages_)
121 : effectiveStages (effectiveStages_)
123 alternatives.push_back(extension);
126 RequiredExtension (void)
127 : effectiveStages (0u)
132 struct ProgramSpecification
134 glu::ProgramSources sources;
135 std::vector<RequiredExtension> requiredExtensions;
136 deUint32 activeStages; // Has an effect only if sources.separable == true, must be 0 otherwise
138 ProgramSpecification (void)
144 struct ShaderCaseSpecification
147 ExpectResult expectResult;
148 OutputType outputType;
149 DataType outputFormat;
150 glu::GLSLVersion targetVersion;
152 // \todo [pyry] Clean this up
153 std::vector<RequiredCapability> requiredCaps;
154 bool fullGLSLES100Required;
157 std::vector<ProgramSpecification> programs;
159 ShaderCaseSpecification (void)
160 : caseType (CASETYPE_LAST)
161 , expectResult (EXPECT_LAST)
162 , outputType (OUTPUT_RESULT)
163 , outputFormat (TYPE_LAST)
164 , targetVersion (glu::GLSL_VERSION_LAST)
165 , fullGLSLES100Required (false)
170 bool isValid (const ValueBlock& block);
171 bool isValid (const ShaderCaseSpecification& spec);
173 class ShaderCaseFactory
176 virtual tcu::TestCaseGroup* createGroup (const std::string& name, const std::string& description, const std::vector<tcu::TestNode*>& children) = 0;
177 virtual tcu::TestCase* createCase (const std::string& name, const std::string& description, const ShaderCaseSpecification& spec) = 0;
180 std::vector<tcu::TestNode*> parseFile (const tcu::Archive& archive, const std::string& filename, ShaderCaseFactory* caseFactory);
182 // Specialization utilties
184 struct ProgramSpecializationParams
186 const ShaderCaseSpecification& caseSpec;
187 const std::vector<RequiredExtension> requiredExtensions; // Extensions, must be resolved to single ext per entry
188 const int maxPatchVertices; // Used by tess shaders only
190 ProgramSpecializationParams (const ShaderCaseSpecification& caseSpec_,
191 const std::vector<RequiredExtension>& requiredExtensions_,
192 int maxPatchVertices_)
193 : caseSpec (caseSpec_)
194 , requiredExtensions (requiredExtensions_)
195 , maxPatchVertices (maxPatchVertices_)
200 void genCompareFunctions (std::ostringstream& stream, const ValueBlock& valueBlock, bool useFloatTypes);
201 std::string injectExtensionRequirements (const std::string& baseCode, const std::vector<RequiredExtension>& extensions, ShaderType shaderType);
205 void dumpValues (tcu::TestLog& log, const ValueBlock& values, int arrayNdx);
210 #endif // _GLUSHADERLIBRARY_HPP