Home | History | Annotate | Download | only in functional
      1 /*-------------------------------------------------------------------------
      2  * drawElements Quality Program OpenGL ES 2.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 "es2fRandomShaderTests.hpp"
     25 #include "glsRandomShaderCase.hpp"
     26 #include "deStringUtil.hpp"
     27 
     28 namespace deqp
     29 {
     30 namespace gles2
     31 {
     32 namespace Functional
     33 {
     34 
     35 namespace
     36 {
     37 
     38 gls::RandomShaderCase* createRandomShaderCase (Context& context, const char* description, const rsg::ProgramParameters& baseParams, deUint32 seed, bool vertex, bool fragment)
     39 {
     40 	rsg::ProgramParameters params = baseParams;
     41 
     42 	params.seed							= seed;
     43 	params.vertexParameters.randomize	= vertex;
     44 	params.fragmentParameters.randomize	= fragment;
     45 
     46 	return new gls::RandomShaderCase(context.getTestContext(), context.getRenderContext(), de::toString(seed).c_str(), description, params);
     47 }
     48 
     49 class BasicExpressionGroup : public TestCaseGroup
     50 {
     51 public:
     52 	BasicExpressionGroup (Context& context)
     53 		: TestCaseGroup(context, "basic_expression", "Basic arithmetic expressions")
     54 	{
     55 	}
     56 
     57 	void init (void)
     58 	{
     59 		rsg::ProgramParameters params;
     60 
     61 		tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
     62 		addChild(vertexGroup);
     63 
     64 		tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
     65 		addChild(fragmentGroup);
     66 
     67 		tcu::TestCaseGroup* combinedGroup = new tcu::TestCaseGroup(m_testCtx, "combined", "Combined tests");
     68 		addChild(combinedGroup);
     69 
     70 		for (int seed = 0; seed < 100; seed++)
     71 		{
     72 			vertexGroup->addChild(createRandomShaderCase(m_context,		"Random expressions in vertex shader",					params, seed, true, false));
     73 			fragmentGroup->addChild(createRandomShaderCase(m_context,	"Random expressions in fragment shader",				params, seed, false, true));
     74 			combinedGroup->addChild(createRandomShaderCase(m_context,	"Random expressions in vertex and fragment shaders",	params, seed, true, true));
     75 		}
     76 	}
     77 };
     78 
     79 class ScalarConversionGroup : public TestCaseGroup
     80 {
     81 public:
     82 	ScalarConversionGroup (Context& context)
     83 		: TestCaseGroup(context, "scalar_conversion", "Scalar conversions")
     84 	{
     85 	}
     86 
     87 	void init (void)
     88 	{
     89 		rsg::ProgramParameters params;
     90 		params.useScalarConversions = true;
     91 
     92 		tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
     93 		addChild(vertexGroup);
     94 
     95 		tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
     96 		addChild(fragmentGroup);
     97 
     98 		tcu::TestCaseGroup* combinedGroup = new tcu::TestCaseGroup(m_testCtx, "combined", "Combined tests");
     99 		addChild(combinedGroup);
    100 
    101 		for (int seed = 0; seed < 100; seed++)
    102 		{
    103 			vertexGroup->addChild(createRandomShaderCase(m_context,		"Scalar conversions in vertex shader",					params, seed, true, false));
    104 			fragmentGroup->addChild(createRandomShaderCase(m_context,	"Scalar conversions in fragment shader",				params, seed, false, true));
    105 			combinedGroup->addChild(createRandomShaderCase(m_context,	"Scalar conversions in vertex and fragment shaders",	params, seed, true, true));
    106 		}
    107 	}
    108 };
    109 
    110 class SwizzleGroup : public TestCaseGroup
    111 {
    112 public:
    113 	SwizzleGroup (Context& context)
    114 		: TestCaseGroup(context, "swizzle", "Vector swizzles")
    115 	{
    116 	}
    117 
    118 	void init (void)
    119 	{
    120 		rsg::ProgramParameters params;
    121 		params.useScalarConversions = true;
    122 		params.useSwizzle			= true;
    123 
    124 		tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
    125 		addChild(vertexGroup);
    126 
    127 		tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
    128 		addChild(fragmentGroup);
    129 
    130 		for (int seed = 0; seed < 50; seed++)
    131 		{
    132 			vertexGroup->addChild(createRandomShaderCase(m_context,		"Vector swizzles in vertex shader",		params, seed, true, false));
    133 			fragmentGroup->addChild(createRandomShaderCase(m_context,	"Vector swizzles in fragment shader",	params, seed, false, true));
    134 		}
    135 	}
    136 };
    137 
    138 class ComparisonOpsGroup : public TestCaseGroup
    139 {
    140 public:
    141 	ComparisonOpsGroup (Context& context)
    142 		: TestCaseGroup(context, "comparison_ops", "Comparison operators")
    143 	{
    144 	}
    145 
    146 	void init (void)
    147 	{
    148 		rsg::ProgramParameters params;
    149 		params.useScalarConversions = true;
    150 		params.useComparisonOps		= true;
    151 
    152 		tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
    153 		addChild(vertexGroup);
    154 
    155 		tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
    156 		addChild(fragmentGroup);
    157 
    158 		for (int seed = 0; seed < 50; seed++)
    159 		{
    160 			vertexGroup->addChild(createRandomShaderCase(m_context,		"Comparison operators in vertex shader",		params, seed, true, false));
    161 			fragmentGroup->addChild(createRandomShaderCase(m_context,	"Comparison operators in fragment shader",		params, seed, false, true));
    162 		}
    163 	}
    164 };
    165 
    166 class ConditionalsGroup : public TestCaseGroup
    167 {
    168 public:
    169 	ConditionalsGroup (Context& context)
    170 		: TestCaseGroup(context, "conditionals", "Conditional control flow (if-else)")
    171 	{
    172 	}
    173 
    174 	void init (void)
    175 	{
    176 		rsg::ProgramParameters params;
    177 		params.useScalarConversions = true;
    178 		params.useSwizzle			= true;
    179 		params.useComparisonOps		= true;
    180 		params.useConditionals		= true;
    181 		params.vertexParameters.maxStatementDepth		= 4;
    182 		params.vertexParameters.maxStatementsPerBlock	= 5;
    183 		params.fragmentParameters.maxStatementDepth		= 4;
    184 		params.fragmentParameters.maxStatementsPerBlock	= 5;
    185 
    186 		tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
    187 		addChild(vertexGroup);
    188 
    189 		tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
    190 		addChild(fragmentGroup);
    191 
    192 		tcu::TestCaseGroup* combinedGroup = new tcu::TestCaseGroup(m_testCtx, "combined", "Combined tests");
    193 		addChild(combinedGroup);
    194 
    195 		for (int seed = 0; seed < 100; seed++)
    196 		{
    197 			vertexGroup->addChild(createRandomShaderCase(m_context,		"Conditional control flow in vertex shader",				params, seed, true, false));
    198 			fragmentGroup->addChild(createRandomShaderCase(m_context,	"Conditional control flow in fragment shader",				params, seed, false, true));
    199 			combinedGroup->addChild(createRandomShaderCase(m_context,	"Conditional control flow in vertex and fragment shaders",	params, seed, true, true));
    200 		}
    201 	}
    202 };
    203 
    204 class TrigonometricGroup : public TestCaseGroup
    205 {
    206 public:
    207 	TrigonometricGroup (Context& context)
    208 		: TestCaseGroup(context, "trigonometric", "Trigonometric built-in functions")
    209 	{
    210 	}
    211 
    212 	void init (void)
    213 	{
    214 		rsg::ProgramParameters params;
    215 		params.useScalarConversions		= true;
    216 		params.useSwizzle				= true;
    217 		params.trigonometricBaseWeight	= 4.0f;
    218 
    219 		tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
    220 		addChild(vertexGroup);
    221 
    222 		tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
    223 		addChild(fragmentGroup);
    224 
    225 		for (int seed = 0; seed < 100; seed++)
    226 		{
    227 			vertexGroup->addChild(createRandomShaderCase(m_context,		"Trigonometric ops in vertex shader",	params, seed, true, false));
    228 			fragmentGroup->addChild(createRandomShaderCase(m_context,	"Trigonometric ops in fragment shader",	params, seed, false, true));
    229 		}
    230 	}
    231 };
    232 
    233 class ExponentialGroup : public TestCaseGroup
    234 {
    235 public:
    236 	ExponentialGroup (Context& context)
    237 		: TestCaseGroup(context, "exponential", "Exponential built-in functions")
    238 	{
    239 	}
    240 
    241 	void init (void)
    242 	{
    243 		rsg::ProgramParameters params;
    244 		params.useScalarConversions		= true;
    245 		params.useSwizzle				= true;
    246 		params.exponentialBaseWeight	= 4.0f;
    247 
    248 		tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
    249 		addChild(vertexGroup);
    250 
    251 		tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
    252 		addChild(fragmentGroup);
    253 
    254 		for (int seed = 0; seed < 100; seed++)
    255 		{
    256 			vertexGroup->addChild(createRandomShaderCase(m_context,		"Exponential ops in vertex shader",		params, seed, true, false));
    257 			fragmentGroup->addChild(createRandomShaderCase(m_context,	"Exponential ops in fragment shader",	params, seed, false, true));
    258 		}
    259 	}
    260 };
    261 
    262 class TextureGroup : public TestCaseGroup
    263 {
    264 public:
    265 	TextureGroup (Context& context)
    266 		: TestCaseGroup(context, "texture", "Texture lookups")
    267 	{
    268 	}
    269 
    270 	void init (void)
    271 	{
    272 		rsg::ProgramParameters params;
    273 		params.useScalarConversions						= true;
    274 		params.useSwizzle								= true;
    275 		params.vertexParameters.texLookupBaseWeight		= 10.0f;
    276 		params.vertexParameters.useTexture2D			= true;
    277 		params.vertexParameters.useTextureCube			= true;
    278 		params.fragmentParameters.texLookupBaseWeight	= 10.0f;
    279 		params.fragmentParameters.useTexture2D			= true;
    280 		params.fragmentParameters.useTextureCube		= true;
    281 
    282 		tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
    283 		addChild(vertexGroup);
    284 
    285 		tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
    286 		addChild(fragmentGroup);
    287 
    288 		// Do only 50 vertex cases and 150 fragment cases.
    289 		for (int seed = 0; seed < 50; seed++)
    290 			vertexGroup->addChild(createRandomShaderCase(m_context,		"Texture lookups in vertex shader",		params, seed, true, false));
    291 
    292 		for (int seed = 0; seed < 150; seed++)
    293 			fragmentGroup->addChild(createRandomShaderCase(m_context,	"Texture lookups in fragment shader",	params, seed, false, true));
    294 	}
    295 };
    296 
    297 class AllFeaturesGroup : public TestCaseGroup
    298 {
    299 public:
    300 	AllFeaturesGroup (Context& context)
    301 		: TestCaseGroup(context, "all_features", "All features enabled")
    302 	{
    303 	}
    304 
    305 	void init (void)
    306 	{
    307 		rsg::ProgramParameters params;
    308 		params.useScalarConversions		= true;
    309 		params.useSwizzle				= true;
    310 		params.useComparisonOps			= true;
    311 		params.useConditionals			= true;
    312 		params.trigonometricBaseWeight	= 1.0f;
    313 		params.exponentialBaseWeight	= 1.0f;
    314 
    315 		params.vertexParameters.maxStatementDepth				= 4;
    316 		params.vertexParameters.maxStatementsPerBlock			= 7;
    317 		params.vertexParameters.maxExpressionDepth				= 7;
    318 		params.vertexParameters.maxCombinedVariableScalars		= 64;
    319 		params.fragmentParameters.maxStatementDepth				= 4;
    320 		params.fragmentParameters.maxStatementsPerBlock			= 7;
    321 		params.fragmentParameters.maxExpressionDepth			= 7;
    322 		params.fragmentParameters.maxCombinedVariableScalars	= 64;
    323 
    324 		params.fragmentParameters.texLookupBaseWeight		= 4.0f; // \note Texture lookups are enabled for fragment shaders only.
    325 		params.fragmentParameters.useTexture2D				= true;
    326 		params.fragmentParameters.useTextureCube			= true;
    327 
    328 		tcu::TestCaseGroup* vertexGroup = new tcu::TestCaseGroup(m_testCtx, "vertex", "Vertex-only tests");
    329 		addChild(vertexGroup);
    330 
    331 		tcu::TestCaseGroup* fragmentGroup = new tcu::TestCaseGroup(m_testCtx, "fragment", "Fragment-only tests");
    332 		addChild(fragmentGroup);
    333 
    334 		for (int seed = 0; seed < 100; seed++)
    335 		{
    336 			vertexGroup->addChild(createRandomShaderCase(m_context,		"Texture lookups in vertex shader",		params, seed, true, false));
    337 			fragmentGroup->addChild(createRandomShaderCase(m_context,	"Texture lookups in fragment shader",	params, seed, false, true));
    338 		}
    339 	}
    340 };
    341 
    342 } // anonymous
    343 
    344 RandomShaderTests::RandomShaderTests (Context& context)
    345 	: TestCaseGroup(context, "random", "Random shaders")
    346 {
    347 }
    348 
    349 RandomShaderTests::~RandomShaderTests (void)
    350 {
    351 }
    352 
    353 namespace
    354 {
    355 
    356 } // anonymous
    357 
    358 void RandomShaderTests::init (void)
    359 {
    360 	addChild(new BasicExpressionGroup	(m_context));
    361 	addChild(new ScalarConversionGroup	(m_context));
    362 	addChild(new SwizzleGroup			(m_context));
    363 	addChild(new ComparisonOpsGroup		(m_context));
    364 	addChild(new ConditionalsGroup		(m_context));
    365 	addChild(new TrigonometricGroup		(m_context));
    366 	addChild(new ExponentialGroup		(m_context));
    367 	addChild(new TextureGroup			(m_context));
    368 	addChild(new AllFeaturesGroup		(m_context));
    369 }
    370 
    371 } // Functional
    372 } // gles2
    373 } // deqp
    374