1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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.
21 * \brief Random shader tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es3fRandomShaderTests.hpp"
25 #include "glsRandomShaderCase.hpp"
27 #include "deStringUtil.hpp"
39 gls::RandomShaderCase* createRandomShaderCase (Context& context, const char* description, const rsg::ProgramParameters& baseParams, deUint32 seed, bool vertex, bool fragment)
41 rsg::ProgramParameters params = baseParams;
43 params.version = rsg::VERSION_300;
45 params.vertexParameters.randomize = vertex;
46 params.fragmentParameters.randomize = fragment;
48 return new gls::RandomShaderCase(context.getTestContext(), context.getRenderContext(), de::toString(seed).c_str(), description, params);
51 class BasicExpressionGroup : public TestCaseGroup
54 BasicExpressionGroup (Context& context)
55 : TestCaseGroup(context, "basic_expression", "Basic arithmetic expressions")
61 rsg::ProgramParameters params;
63 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
64 addChild(vertexGroup);
66 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
67 addChild(fragmentGroup);
69 tcu::TestCaseGroup* combinedGroup = new tcu::TestCaseGroup(m_testCtx, "combined", "Combined tests");
70 addChild(combinedGroup);
72 for (int seed = 0; seed < 100; seed++)
74 vertexGroup->addChild(createRandomShaderCase(m_context, "Random expressions in vertex shader", params, seed, true, false));
75 fragmentGroup->addChild(createRandomShaderCase(m_context, "Random expressions in fragment shader", params, seed, false, true));
76 combinedGroup->addChild(createRandomShaderCase(m_context, "Random expressions in vertex and fragment shaders", params, seed, true, true));
81 class ScalarConversionGroup : public TestCaseGroup
84 ScalarConversionGroup (Context& context)
85 : TestCaseGroup(context, "scalar_conversion", "Scalar conversions")
91 rsg::ProgramParameters params;
92 params.useScalarConversions = true;
94 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
95 addChild(vertexGroup);
97 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
98 addChild(fragmentGroup);
100 tcu::TestCaseGroup* combinedGroup = new tcu::TestCaseGroup(m_testCtx, "combined", "Combined tests");
101 addChild(combinedGroup);
103 for (int seed = 0; seed < 100; seed++)
105 vertexGroup->addChild(createRandomShaderCase(m_context, "Scalar conversions in vertex shader", params, seed, true, false));
106 fragmentGroup->addChild(createRandomShaderCase(m_context, "Scalar conversions in fragment shader", params, seed, false, true));
107 combinedGroup->addChild(createRandomShaderCase(m_context, "Scalar conversions in vertex and fragment shaders", params, seed, true, true));
112 class SwizzleGroup : public TestCaseGroup
115 SwizzleGroup (Context& context)
116 : TestCaseGroup(context, "swizzle", "Vector swizzles")
122 rsg::ProgramParameters params;
123 params.useScalarConversions = true;
124 params.useSwizzle = true;
126 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
127 addChild(vertexGroup);
129 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
130 addChild(fragmentGroup);
132 for (int seed = 0; seed < 50; seed++)
134 vertexGroup->addChild(createRandomShaderCase(m_context, "Vector swizzles in vertex shader", params, seed, true, false));
135 fragmentGroup->addChild(createRandomShaderCase(m_context, "Vector swizzles in fragment shader", params, seed, false, true));
140 class ComparisonOpsGroup : public TestCaseGroup
143 ComparisonOpsGroup (Context& context)
144 : TestCaseGroup(context, "comparison_ops", "Comparison operators")
150 rsg::ProgramParameters params;
151 params.useScalarConversions = true;
152 params.useComparisonOps = true;
154 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
155 addChild(vertexGroup);
157 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
158 addChild(fragmentGroup);
160 for (int seed = 0; seed < 50; seed++)
162 vertexGroup->addChild(createRandomShaderCase(m_context, "Comparison operators in vertex shader", params, seed, true, false));
163 fragmentGroup->addChild(createRandomShaderCase(m_context, "Comparison operators in fragment shader", params, seed, false, true));
168 class ConditionalsGroup : public TestCaseGroup
171 ConditionalsGroup (Context& context)
172 : TestCaseGroup(context, "conditionals", "Conditional control flow (if-else)")
178 rsg::ProgramParameters params;
179 params.useScalarConversions = true;
180 params.useSwizzle = true;
181 params.useComparisonOps = true;
182 params.useConditionals = true;
183 params.vertexParameters.maxStatementDepth = 4;
184 params.vertexParameters.maxStatementsPerBlock = 5;
185 params.fragmentParameters.maxStatementDepth = 4;
186 params.fragmentParameters.maxStatementsPerBlock = 5;
188 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
189 addChild(vertexGroup);
191 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
192 addChild(fragmentGroup);
194 tcu::TestCaseGroup* combinedGroup = new tcu::TestCaseGroup(m_testCtx, "combined", "Combined tests");
195 addChild(combinedGroup);
197 for (int seed = 0; seed < 100; seed++)
199 vertexGroup->addChild(createRandomShaderCase(m_context, "Conditional control flow in vertex shader", params, seed, true, false));
200 fragmentGroup->addChild(createRandomShaderCase(m_context, "Conditional control flow in fragment shader", params, seed, false, true));
201 combinedGroup->addChild(createRandomShaderCase(m_context, "Conditional control flow in vertex and fragment shaders", params, seed, true, true));
206 class TrigonometricGroup : public TestCaseGroup
209 TrigonometricGroup (Context& context)
210 : TestCaseGroup(context, "trigonometric", "Trigonometric built-in functions")
216 rsg::ProgramParameters params;
217 params.useScalarConversions = true;
218 params.useSwizzle = true;
219 params.trigonometricBaseWeight = 4.0f;
221 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
222 addChild(vertexGroup);
224 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
225 addChild(fragmentGroup);
227 for (int seed = 0; seed < 100; seed++)
229 vertexGroup->addChild(createRandomShaderCase(m_context, "Trigonometric ops in vertex shader", params, seed, true, false));
230 fragmentGroup->addChild(createRandomShaderCase(m_context, "Trigonometric ops in fragment shader", params, seed, false, true));
235 class ExponentialGroup : public TestCaseGroup
238 ExponentialGroup (Context& context)
239 : TestCaseGroup(context, "exponential", "Exponential built-in functions")
245 rsg::ProgramParameters params;
246 params.useScalarConversions = true;
247 params.useSwizzle = true;
248 params.exponentialBaseWeight = 4.0f;
250 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
251 addChild(vertexGroup);
253 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
254 addChild(fragmentGroup);
256 for (int seed = 0; seed < 100; seed++)
258 vertexGroup->addChild(createRandomShaderCase(m_context, "Exponential ops in vertex shader", params, seed, true, false));
259 fragmentGroup->addChild(createRandomShaderCase(m_context, "Exponential ops in fragment shader", params, seed, false, true));
264 class TextureGroup : public TestCaseGroup
267 TextureGroup (Context& context)
268 : TestCaseGroup(context, "texture", "Texture lookups")
274 rsg::ProgramParameters params;
275 params.useScalarConversions = true;
276 params.useSwizzle = true;
277 params.vertexParameters.texLookupBaseWeight = 10.0f;
278 params.vertexParameters.useTexture2D = true;
279 params.vertexParameters.useTextureCube = true;
280 params.fragmentParameters.texLookupBaseWeight = 10.0f;
281 params.fragmentParameters.useTexture2D = true;
282 params.fragmentParameters.useTextureCube = true;
284 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
285 addChild(vertexGroup);
287 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
288 addChild(fragmentGroup);
290 // Do only 50 vertex cases and 150 fragment cases.
291 for (int seed = 0; seed < 50; seed++)
292 vertexGroup->addChild(createRandomShaderCase(m_context, "Texture lookups in vertex shader", params, seed, true, false));
294 for (int seed = 0; seed < 150; seed++)
295 fragmentGroup->addChild(createRandomShaderCase(m_context, "Texture lookups in fragment shader", params, seed, false, true));
299 class AllFeaturesGroup : public TestCaseGroup
302 AllFeaturesGroup (Context& context)
303 : TestCaseGroup(context, "all_features", "All features enabled")
309 rsg::ProgramParameters params;
310 params.useScalarConversions = true;
311 params.useSwizzle = true;
312 params.useComparisonOps = true;
313 params.useConditionals = true;
314 params.trigonometricBaseWeight = 1.0f;
315 params.exponentialBaseWeight = 1.0f;
317 params.vertexParameters.maxStatementDepth = 4;
318 params.vertexParameters.maxStatementsPerBlock = 7;
319 params.vertexParameters.maxExpressionDepth = 7;
320 params.vertexParameters.maxCombinedVariableScalars = 64;
321 params.fragmentParameters.maxStatementDepth = 4;
322 params.fragmentParameters.maxStatementsPerBlock = 7;
323 params.fragmentParameters.maxExpressionDepth = 7;
324 params.fragmentParameters.maxCombinedVariableScalars = 64;
326 params.fragmentParameters.texLookupBaseWeight = 4.0f; // \note Texture lookups are enabled for fragment shaders only.
327 params.fragmentParameters.useTexture2D = true;
328 params.fragmentParameters.useTextureCube = true;
330 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
331 addChild(vertexGroup);
333 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
334 addChild(fragmentGroup);
336 for (int seed = 0; seed < 100; seed++)
338 vertexGroup->addChild(createRandomShaderCase(m_context, "Texture lookups in vertex shader", params, seed, true, false));
339 fragmentGroup->addChild(createRandomShaderCase(m_context, "Texture lookups in fragment shader", params, seed, false, true));
346 RandomShaderTests::RandomShaderTests (Context& context)
347 : TestCaseGroup(context, "random", "Random shaders")
351 RandomShaderTests::~RandomShaderTests (void)
360 void RandomShaderTests::init (void)
362 addChild(new BasicExpressionGroup (m_context));
363 addChild(new ScalarConversionGroup (m_context));
364 addChild(new SwizzleGroup (m_context));
365 addChild(new ComparisonOpsGroup (m_context));
366 addChild(new ConditionalsGroup (m_context));
367 addChild(new TrigonometricGroup (m_context));
368 addChild(new ExponentialGroup (m_context));
369 addChild(new TextureGroup (m_context));
370 addChild(new AllFeaturesGroup (m_context));