1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
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
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 *
19 *//*!
20 * \file
21 * \brief Random shader tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "es3fRandomShaderTests.hpp"
25 #include "glsRandomShaderCase.hpp"
26 #include "deString.h"
27 #include "deStringUtil.hpp"
28
29 namespace deqp
30 {
31 namespace gles3
32 {
33 namespace Functional
34 {
35
36 namespace
37 {
38
createRandomShaderCase(Context & context,const char * description,const rsg::ProgramParameters & baseParams,deUint32 seed,bool vertex,bool fragment)39 gls::RandomShaderCase* createRandomShaderCase (Context& context, const char* description, const rsg::ProgramParameters& baseParams, deUint32 seed, bool vertex, bool fragment)
40 {
41 rsg::ProgramParameters params = baseParams;
42
43 params.version = rsg::VERSION_300;
44 params.seed = seed;
45 params.vertexParameters.randomize = vertex;
46 params.fragmentParameters.randomize = fragment;
47
48 return new gls::RandomShaderCase(context.getTestContext(), context.getRenderContext(), de::toString(seed).c_str(), description, params);
49 }
50
51 class BasicExpressionGroup : public TestCaseGroup
52 {
53 public:
BasicExpressionGroup(Context & context)54 BasicExpressionGroup (Context& context)
55 : TestCaseGroup(context, "basic_expression", "Basic arithmetic expressions")
56 {
57 }
58
init(void)59 void init (void)
60 {
61 rsg::ProgramParameters params;
62
63 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
64 addChild(vertexGroup);
65
66 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
67 addChild(fragmentGroup);
68
69 tcu::TestCaseGroup* combinedGroup = new tcu::TestCaseGroup(m_testCtx, "combined", "Combined tests");
70 addChild(combinedGroup);
71
72 for (int seed = 0; seed < 100; seed++)
73 {
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));
77 }
78 }
79 };
80
81 class ScalarConversionGroup : public TestCaseGroup
82 {
83 public:
ScalarConversionGroup(Context & context)84 ScalarConversionGroup (Context& context)
85 : TestCaseGroup(context, "scalar_conversion", "Scalar conversions")
86 {
87 }
88
init(void)89 void init (void)
90 {
91 rsg::ProgramParameters params;
92 params.useScalarConversions = true;
93
94 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
95 addChild(vertexGroup);
96
97 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
98 addChild(fragmentGroup);
99
100 tcu::TestCaseGroup* combinedGroup = new tcu::TestCaseGroup(m_testCtx, "combined", "Combined tests");
101 addChild(combinedGroup);
102
103 for (int seed = 0; seed < 100; seed++)
104 {
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));
108 }
109 }
110 };
111
112 class SwizzleGroup : public TestCaseGroup
113 {
114 public:
SwizzleGroup(Context & context)115 SwizzleGroup (Context& context)
116 : TestCaseGroup(context, "swizzle", "Vector swizzles")
117 {
118 }
119
init(void)120 void init (void)
121 {
122 rsg::ProgramParameters params;
123 params.useScalarConversions = true;
124 params.useSwizzle = true;
125
126 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
127 addChild(vertexGroup);
128
129 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
130 addChild(fragmentGroup);
131
132 for (int seed = 0; seed < 50; seed++)
133 {
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));
136 }
137 }
138 };
139
140 class ComparisonOpsGroup : public TestCaseGroup
141 {
142 public:
ComparisonOpsGroup(Context & context)143 ComparisonOpsGroup (Context& context)
144 : TestCaseGroup(context, "comparison_ops", "Comparison operators")
145 {
146 }
147
init(void)148 void init (void)
149 {
150 rsg::ProgramParameters params;
151 params.useScalarConversions = true;
152 params.useComparisonOps = true;
153
154 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
155 addChild(vertexGroup);
156
157 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
158 addChild(fragmentGroup);
159
160 for (int seed = 0; seed < 50; seed++)
161 {
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));
164 }
165 }
166 };
167
168 class ConditionalsGroup : public TestCaseGroup
169 {
170 public:
ConditionalsGroup(Context & context)171 ConditionalsGroup (Context& context)
172 : TestCaseGroup(context, "conditionals", "Conditional control flow (if-else)")
173 {
174 }
175
init(void)176 void init (void)
177 {
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;
187
188 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
189 addChild(vertexGroup);
190
191 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
192 addChild(fragmentGroup);
193
194 tcu::TestCaseGroup* combinedGroup = new tcu::TestCaseGroup(m_testCtx, "combined", "Combined tests");
195 addChild(combinedGroup);
196
197 for (int seed = 0; seed < 100; seed++)
198 {
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));
202 }
203 }
204 };
205
206 class TrigonometricGroup : public TestCaseGroup
207 {
208 public:
TrigonometricGroup(Context & context)209 TrigonometricGroup (Context& context)
210 : TestCaseGroup(context, "trigonometric", "Trigonometric built-in functions")
211 {
212 }
213
init(void)214 void init (void)
215 {
216 rsg::ProgramParameters params;
217 params.useScalarConversions = true;
218 params.useSwizzle = true;
219 params.trigonometricBaseWeight = 4.0f;
220
221 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
222 addChild(vertexGroup);
223
224 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
225 addChild(fragmentGroup);
226
227 for (int seed = 0; seed < 100; seed++)
228 {
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));
231 }
232 }
233 };
234
235 class ExponentialGroup : public TestCaseGroup
236 {
237 public:
ExponentialGroup(Context & context)238 ExponentialGroup (Context& context)
239 : TestCaseGroup(context, "exponential", "Exponential built-in functions")
240 {
241 }
242
init(void)243 void init (void)
244 {
245 rsg::ProgramParameters params;
246 params.useScalarConversions = true;
247 params.useSwizzle = true;
248 params.exponentialBaseWeight = 4.0f;
249
250 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
251 addChild(vertexGroup);
252
253 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
254 addChild(fragmentGroup);
255
256 for (int seed = 0; seed < 100; seed++)
257 {
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));
260 }
261 }
262 };
263
264 class TextureGroup : public TestCaseGroup
265 {
266 public:
TextureGroup(Context & context)267 TextureGroup (Context& context)
268 : TestCaseGroup(context, "texture", "Texture lookups")
269 {
270 }
271
init(void)272 void init (void)
273 {
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;
283
284 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
285 addChild(vertexGroup);
286
287 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
288 addChild(fragmentGroup);
289
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));
293
294 for (int seed = 0; seed < 150; seed++)
295 fragmentGroup->addChild(createRandomShaderCase(m_context, "Texture lookups in fragment shader", params, seed, false, true));
296 }
297 };
298
299 class AllFeaturesGroup : public TestCaseGroup
300 {
301 public:
AllFeaturesGroup(Context & context)302 AllFeaturesGroup (Context& context)
303 : TestCaseGroup(context, "all_features", "All features enabled")
304 {
305 }
306
init(void)307 void init (void)
308 {
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;
316
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;
325
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;
329
330 tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
331 addChild(vertexGroup);
332
333 tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
334 addChild(fragmentGroup);
335
336 for (int seed = 0; seed < 100; seed++)
337 {
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));
340 }
341 }
342 };
343
344 } // anonymous
345
RandomShaderTests(Context & context)346 RandomShaderTests::RandomShaderTests (Context& context)
347 : TestCaseGroup(context, "random", "Random shaders")
348 {
349 }
350
~RandomShaderTests(void)351 RandomShaderTests::~RandomShaderTests (void)
352 {
353 }
354
355 namespace
356 {
357
358 } // anonymous
359
init(void)360 void RandomShaderTests::init (void)
361 {
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));
371 }
372
373 } // Functional
374 } // gles2
375 } // deqp
376