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;
99 CAPABILITY_FULL_GLSL_ES_100_SUPPORT,
100 CAPABILITY_ONLY_GLSL_ES_100_SUPPORT, // only ES2, no ES3 capability
101 CAPABILITY_EXACTLY_ONE_DRAW_BUFFER // gl_MaxDrawBuffers is exactly 1
104 struct RequiredCapability
110 CapabilityFlag flagName;
116 RequiredCapability (CapabilityFlag flagName_)
117 : type (CAPABILITY_FLAG)
118 , flagName (flagName_)
119 , referenceValue (0) // not used
123 RequiredCapability (deUint32 enumName_, int referenceValue_)
124 : type (CAPABILITY_LIMIT)
125 , enumName (enumName_)
126 , referenceValue (referenceValue_)
131 struct RequiredExtension
133 std::vector<std::string> alternatives; // One or more extensions, at least one (but not all) must be supported
134 deUint32 effectiveStages; // Bitfield of shader stages requiring this extension
136 RequiredExtension (const std::vector<std::string>& alternatives_,
137 deUint32 effectiveStages_)
138 : alternatives (alternatives_)
139 , effectiveStages (effectiveStages_)
143 RequiredExtension (const std::string& extension,
144 deUint32 effectiveStages_)
145 : effectiveStages (effectiveStages_)
147 alternatives.push_back(extension);
150 RequiredExtension (void)
151 : effectiveStages (0u)
156 struct ProgramSpecification
158 glu::ProgramSources sources;
159 std::vector<RequiredExtension> requiredExtensions;
160 deUint32 activeStages; // Has an effect only if sources.separable == true, must be 0 otherwise
162 ProgramSpecification (void)
168 struct ShaderCaseSpecification
171 ExpectResult expectResult;
172 OutputType outputType;
173 DataType outputFormat;
174 glu::GLSLVersion targetVersion;
176 std::vector<RequiredCapability> requiredCaps;
179 std::vector<ProgramSpecification> programs;
181 ShaderCaseSpecification (void)
182 : caseType (CASETYPE_LAST)
183 , expectResult (EXPECT_LAST)
184 , outputType (OUTPUT_RESULT)
185 , outputFormat (TYPE_LAST)
186 , targetVersion (glu::GLSL_VERSION_LAST)
191 bool isValid (const ValueBlock& block);
192 bool isValid (const ShaderCaseSpecification& spec);
194 bool isCapabilityRequired(CapabilityFlag capabilityFlag, const ShaderCaseSpecification& spec);
196 class ShaderCaseFactory
199 virtual tcu::TestCaseGroup* createGroup (const std::string& name, const std::string& description, const std::vector<tcu::TestNode*>& children) = 0;
200 virtual tcu::TestCase* createCase (const std::string& name, const std::string& description, const ShaderCaseSpecification& spec) = 0;
203 std::vector<tcu::TestNode*> parseFile (const tcu::Archive& archive, const std::string& filename, ShaderCaseFactory* caseFactory);
205 // Specialization utilties
207 struct ProgramSpecializationParams
209 const ShaderCaseSpecification& caseSpec;
210 const std::vector<RequiredExtension> requiredExtensions; // Extensions, must be resolved to single ext per entry
211 const int maxPatchVertices; // Used by tess shaders only
213 ProgramSpecializationParams (const ShaderCaseSpecification& caseSpec_,
214 const std::vector<RequiredExtension>& requiredExtensions_,
215 int maxPatchVertices_)
216 : caseSpec (caseSpec_)
217 , requiredExtensions (requiredExtensions_)
218 , maxPatchVertices (maxPatchVertices_)
223 void genCompareFunctions (std::ostringstream& stream, const ValueBlock& valueBlock, bool useFloatTypes);
224 std::string injectExtensionRequirements (const std::string& baseCode, const std::vector<RequiredExtension>& extensions, ShaderType shaderType);
228 void dumpValues (tcu::TestLog& log, const ValueBlock& values, int arrayNdx);
233 #endif // _GLUSHADERLIBRARY_HPP