Home | History | Annotate | Download | only in glshared
      1 #ifndef _GLSATTRIBUTELOCATIONTESTS_HPP
      2 #define _GLSATTRIBUTELOCATIONTESTS_HPP
      3 /*-------------------------------------------------------------------------
      4  * drawElements Quality Program OpenGL (ES) Module
      5  * -----------------------------------------------
      6  *
      7  * Copyright 2014 The Android Open Source Project
      8  *
      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
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     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.
     20  *
     21  *//*!
     22  * \file
     23  * \brief Attribute location tests
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "tcuDefs.hpp"
     27 #include "tcuTestCase.hpp"
     28 
     29 #include <string>
     30 #include <vector>
     31 
     32 namespace glu
     33 {
     34 class ShaderProgram;
     35 class RenderContext;
     36 } // glu
     37 
     38 namespace deqp
     39 {
     40 namespace gls
     41 {
     42 namespace AttributeLocationTestUtil
     43 {
     44 
     45 class AttribType
     46 {
     47 public:
     48 						AttribType		(const std::string& name, deUint32 locationSize, deUint32 typeEnum);
     49 
     50 	const std::string&	getName			(void) const { return m_name;			}
     51 	deUint32			getLocationSize	(void) const { return m_locationSize;	}
     52 	deUint32			getGLTypeEnum	(void) const { return m_glTypeEnum;		}
     53 
     54 private:
     55 	std::string			m_name;
     56 	deUint32			m_locationSize;
     57 	deUint32			m_glTypeEnum;
     58 };
     59 
     60 class Cond
     61 {
     62 public:
     63 	enum ConstCond
     64 	{
     65 		COND_ALWAYS,
     66 		COND_NEVER
     67 	};
     68 
     69 						Cond		(ConstCond cond);
     70 	explicit			Cond		(const std::string& name, bool negate = true);
     71 	bool				operator==	(const Cond& other)	const	{ return m_negate == other.m_negate && m_name == other.m_name;	}
     72 	bool				operator!=	(const Cond& other)	const	{ return !(*this == other);										}
     73 	const std::string	getName		(void) const				{ return m_name;												}
     74 	bool				getNegate	(void) const				{ return m_negate;												}
     75 
     76 private:
     77 	bool				m_negate;
     78 	std::string			m_name;
     79 };
     80 
     81 class Attribute
     82 {
     83 public:
     84 	enum
     85 	{
     86 		// Location is not defined
     87 		LOC_UNDEF = -1
     88 	};
     89 
     90 	enum
     91 	{
     92 		// Not an array
     93 		NOT_ARRAY = -1
     94 	};
     95 
     96 						Attribute			(const AttribType&	type,
     97 											 const std::string&	name,
     98 											 deInt32			layoutLocation	= LOC_UNDEF,
     99 											 const Cond&		cond			= Cond::COND_ALWAYS,
    100 											 int				arraySize		= NOT_ARRAY);
    101 
    102 	const AttribType	getType				(void) const { return m_type;			}
    103 	const std::string&	getName				(void) const { return m_name;			}
    104 	deInt32				getLayoutLocation	(void) const { return m_layoutLocation;	}
    105 	const Cond&			getCondition		(void) const { return m_cond;			}
    106 	int					getArraySize		(void) const { return m_arraySize;		}
    107 
    108 private:
    109 	AttribType			m_type;
    110 	std::string			m_name;
    111 	deInt32				m_layoutLocation;
    112 	Cond				m_cond;
    113 	int					m_arraySize;
    114 };
    115 
    116 class Bind
    117 {
    118 public:
    119 						Bind				(const std::string& attribute, deUint32 location);
    120 
    121 	const std::string&	getAttributeName	(void) const { return m_attribute;	}
    122 	deUint32			getLocation			(void) const { return m_location;	}
    123 
    124 private:
    125 	std::string			m_attribute;
    126 	deUint32			m_location;
    127 };
    128 
    129 } // AttributeLocationTestUtil
    130 
    131 // Simple bind attribute test
    132 class BindAttributeTest : public tcu::TestCase
    133 {
    134 public:
    135 	typedef AttributeLocationTestUtil::AttribType AttribType;
    136 
    137 							BindAttributeTest	(tcu::TestContext&		testCtx,
    138 												 glu::RenderContext&	renderCtx,
    139 												 const AttribType&		type,
    140 												 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    141 
    142 	virtual IterateResult	iterate				(void);
    143 
    144 private:
    145 	glu::RenderContext&		m_renderCtx;
    146 	const AttribType		m_type;
    147 	const int				m_arraySize;
    148 };
    149 
    150 // Bind maximum number of attributes
    151 class BindMaxAttributesTest : public tcu::TestCase
    152 {
    153 public:
    154 	typedef AttributeLocationTestUtil::AttribType AttribType;
    155 
    156 							BindMaxAttributesTest	(tcu::TestContext&		testCtx,
    157 													 glu::RenderContext&	renderCtx,
    158 													 const AttribType&		type,
    159 													 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    160 
    161 	virtual IterateResult	iterate					(void);
    162 
    163 private:
    164 	glu::RenderContext&		m_renderCtx;
    165 	const AttribType		m_type;
    166 	const int				m_arraySize;
    167 };
    168 
    169 class BindAliasingAttributeTest : public tcu::TestCase
    170 {
    171 public:
    172 	typedef AttributeLocationTestUtil::AttribType AttribType;
    173 
    174 							BindAliasingAttributeTest	(tcu::TestContext&		testCtx,
    175 														 glu::RenderContext&	renderCtx,
    176 														 const AttribType&		type,
    177 														 int					offset = 0,
    178 														 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    179 
    180 	virtual IterateResult	iterate						(void);
    181 
    182 private:
    183 	glu::RenderContext&		m_renderCtx;
    184 	const AttribType		m_type;
    185 	const int				m_offset;
    186 	const int				m_arraySize;
    187 };
    188 
    189 class BindMaxAliasingAttributeTest : public tcu::TestCase
    190 {
    191 public:
    192 	typedef AttributeLocationTestUtil::AttribType AttribType;
    193 
    194 							BindMaxAliasingAttributeTest	(tcu::TestContext&	testCtx,
    195 															glu::RenderContext&	renderCtx,
    196 															const AttribType&	type,
    197 															int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    198 
    199 	virtual IterateResult	iterate							(void);
    200 
    201 private:
    202 	glu::RenderContext&		m_renderCtx;
    203 	const AttribType		m_type;
    204 	const int				m_arraySize;
    205 };
    206 
    207 class BindInactiveAliasingAttributeTest : public tcu::TestCase
    208 {
    209 public:
    210 	typedef AttributeLocationTestUtil::AttribType AttribType;
    211 
    212 							BindInactiveAliasingAttributeTest	(tcu::TestContext&		testCtx,
    213 																 glu::RenderContext&	renderCtx,
    214 																 const AttribType&		type,
    215 																 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    216 
    217 	virtual IterateResult	iterate								(void);
    218 
    219 private:
    220 	glu::RenderContext&		m_renderCtx;
    221 	const AttribType		m_type;
    222 	const int				m_arraySize;
    223 };
    224 
    225 class BindHoleAttributeTest : public tcu::TestCase
    226 {
    227 public:
    228 	typedef AttributeLocationTestUtil::AttribType AttribType;
    229 
    230 							BindHoleAttributeTest		(tcu::TestContext&		testCtx,
    231 														 glu::RenderContext&	renderCtx,
    232 														 const AttribType&		type,
    233 														 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    234 
    235 	virtual IterateResult	iterate						(void);
    236 
    237 private:
    238 	glu::RenderContext&		m_renderCtx;
    239 	const AttribType		m_type;
    240 	const int				m_arraySize;
    241 };
    242 
    243 class PreAttachBindAttributeTest : public tcu::TestCase
    244 {
    245 public:
    246 							PreAttachBindAttributeTest	(tcu::TestContext&		testCtx,
    247 														 glu::RenderContext&	renderCtx);
    248 
    249 	virtual IterateResult	iterate						(void);
    250 
    251 private:
    252 	glu::RenderContext&		m_renderCtx;
    253 };
    254 
    255 class PreLinkBindAttributeTest : public tcu::TestCase
    256 {
    257 public:
    258 	typedef AttributeLocationTestUtil::AttribType AttribType;
    259 
    260 							PreLinkBindAttributeTest	(tcu::TestContext&		testCtx,
    261 														 glu::RenderContext&	renderCtx);
    262 
    263 	virtual IterateResult	iterate						(void);
    264 
    265 private:
    266 	glu::RenderContext&		m_renderCtx;
    267 };
    268 
    269 class PostLinkBindAttributeTest : public tcu::TestCase
    270 {
    271 public:
    272 	typedef AttributeLocationTestUtil::AttribType AttribType;
    273 
    274 							PostLinkBindAttributeTest	(tcu::TestContext&		testCtx,
    275 														 glu::RenderContext&	renderCtx);
    276 
    277 	virtual IterateResult	iterate						(void);
    278 
    279 private:
    280 	glu::RenderContext&		m_renderCtx;
    281 };
    282 
    283 class BindReattachAttributeTest : public tcu::TestCase
    284 {
    285 public:
    286 	typedef AttributeLocationTestUtil::AttribType AttribType;
    287 
    288 							BindReattachAttributeTest	(tcu::TestContext&		testCtx,
    289 														 glu::RenderContext&	renderCtx);
    290 
    291 	virtual IterateResult	iterate						(void);
    292 
    293 private:
    294 	glu::RenderContext&		m_renderCtx;
    295 };
    296 
    297 class LocationAttributeTest : public tcu::TestCase
    298 {
    299 public:
    300 	typedef AttributeLocationTestUtil::AttribType AttribType;
    301 
    302 							LocationAttributeTest	(tcu::TestContext&		testCtx,
    303 													 glu::RenderContext&	renderCtx,
    304 													 const AttribType&		type,
    305 													 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    306 
    307 	virtual IterateResult	iterate					(void);
    308 
    309 private:
    310 	glu::RenderContext&		m_renderCtx;
    311 	const AttribType		m_type;
    312 	const int				m_arraySize;
    313 };
    314 
    315 class LocationMaxAttributesTest : public tcu::TestCase
    316 {
    317 public:
    318 	typedef AttributeLocationTestUtil::AttribType AttribType;
    319 
    320 							LocationMaxAttributesTest	(tcu::TestContext&		testCtx,
    321 														 glu::RenderContext&	renderCtx,
    322 														 const AttribType&		type,
    323 														 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    324 
    325 	virtual IterateResult	iterate						(void);
    326 
    327 private:
    328 	glu::RenderContext&		m_renderCtx;
    329 	const AttribType		m_type;
    330 	const int				m_arraySize;
    331 };
    332 
    333 class LocationHoleAttributeTest : public tcu::TestCase
    334 {
    335 public:
    336 	typedef AttributeLocationTestUtil::AttribType AttribType;
    337 
    338 							LocationHoleAttributeTest	(tcu::TestContext&		testCtx,
    339 														 glu::RenderContext&	renderCtx,
    340 														 const AttribType&		type,
    341 														 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    342 
    343 	virtual IterateResult	iterate						(void);
    344 
    345 private:
    346 	glu::RenderContext&		m_renderCtx;
    347 	const AttribType		m_type;
    348 	const int				m_arraySize;
    349 };
    350 
    351 class MixedAttributeTest : public tcu::TestCase
    352 {
    353 public:
    354 	typedef AttributeLocationTestUtil::AttribType AttribType;
    355 
    356 							MixedAttributeTest	(tcu::TestContext&		testCtx,
    357 												 glu::RenderContext&	renderCtx,
    358 												 const AttribType&		type,
    359 												 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    360 
    361 	virtual IterateResult	iterate				(void);
    362 
    363 private:
    364 	glu::RenderContext&		m_renderCtx;
    365 	const AttribType		m_type;
    366 	const int				m_arraySize;
    367 };
    368 
    369 class MixedMaxAttributesTest : public tcu::TestCase
    370 {
    371 public:
    372 	typedef AttributeLocationTestUtil::AttribType AttribType;
    373 
    374 							MixedMaxAttributesTest	(tcu::TestContext&		testCtx,
    375 													 glu::RenderContext&	renderCtx,
    376 													 const AttribType&		type,
    377 													 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    378 
    379 	virtual IterateResult	iterate					(void);
    380 
    381 private:
    382 	glu::RenderContext&		m_renderCtx;
    383 	const AttribType		m_type;
    384 	const int				m_arraySize;
    385 };
    386 
    387 class MixedHoleAttributeTest : public tcu::TestCase
    388 {
    389 public:
    390 	typedef AttributeLocationTestUtil::AttribType AttribType;
    391 
    392 							MixedHoleAttributeTest	(tcu::TestContext&		testCtx,
    393 													 glu::RenderContext&	renderCtx,
    394 													 const AttribType&		type,
    395 													 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    396 
    397 	virtual IterateResult	iterate					(void);
    398 
    399 private:
    400 	glu::RenderContext&		m_renderCtx;
    401 	const AttribType		m_type;
    402 	const int				m_arraySize;
    403 };
    404 
    405 class BindRelinkAttributeTest : public tcu::TestCase
    406 {
    407 public:
    408 	typedef AttributeLocationTestUtil::AttribType AttribType;
    409 
    410 							BindRelinkAttributeTest	(tcu::TestContext&		testCtx,
    411 													 glu::RenderContext&	renderCtx);
    412 
    413 	virtual IterateResult	iterate					(void);
    414 
    415 private:
    416 	glu::RenderContext&		m_renderCtx;
    417 };
    418 
    419 class BindRelinkHoleAttributeTest : public tcu::TestCase
    420 {
    421 public:
    422 	typedef AttributeLocationTestUtil::AttribType AttribType;
    423 
    424 							BindRelinkHoleAttributeTest	(tcu::TestContext&		testCtx,
    425 														 glu::RenderContext&	renderCtx,
    426 														 const AttribType&		type,
    427 														 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    428 
    429 	virtual IterateResult	iterate						(void);
    430 
    431 private:
    432 	glu::RenderContext&		m_renderCtx;
    433 	const AttribType		m_type;
    434 	const int				m_arraySize;
    435 };
    436 
    437 class MixedRelinkHoleAttributeTest : public tcu::TestCase
    438 {
    439 public:
    440 	typedef AttributeLocationTestUtil::AttribType AttribType;
    441 
    442 							MixedRelinkHoleAttributeTest	(tcu::TestContext&		testCtx,
    443 															 glu::RenderContext&	renderCtx,
    444 															 const AttribType&		type,
    445 															 int					arraySize = AttributeLocationTestUtil::Attribute::NOT_ARRAY);
    446 
    447 	virtual IterateResult	iterate							(void);
    448 
    449 private:
    450 	glu::RenderContext&		m_renderCtx;
    451 	const AttribType		m_type;
    452 	const int				m_arraySize;
    453 };
    454 
    455 class PreAttachMixedAttributeTest : public tcu::TestCase
    456 {
    457 public:
    458 	typedef AttributeLocationTestUtil::AttribType AttribType;
    459 
    460 							PreAttachMixedAttributeTest	(tcu::TestContext&		testCtx,
    461 														 glu::RenderContext&	renderCtx);
    462 
    463 	virtual IterateResult	iterate						(void);
    464 
    465 private:
    466 	glu::RenderContext&		m_renderCtx;
    467 };
    468 
    469 class PreLinkMixedAttributeTest : public tcu::TestCase
    470 {
    471 public:
    472 	typedef AttributeLocationTestUtil::AttribType AttribType;
    473 
    474 							PreLinkMixedAttributeTest	(tcu::TestContext&		testCtx,
    475 														 glu::RenderContext&	renderCtx);
    476 
    477 	virtual IterateResult	iterate						(void);
    478 
    479 private:
    480 	glu::RenderContext&		m_renderCtx;
    481 };
    482 
    483 class PostLinkMixedAttributeTest : public tcu::TestCase
    484 {
    485 public:
    486 	typedef AttributeLocationTestUtil::AttribType AttribType;
    487 
    488 							PostLinkMixedAttributeTest	(tcu::TestContext&		testCtx,
    489 														 glu::RenderContext&	renderCtx);
    490 
    491 	virtual IterateResult	iterate						(void);
    492 
    493 private:
    494 	glu::RenderContext&		m_renderCtx;
    495 };
    496 
    497 class MixedReattachAttributeTest : public tcu::TestCase
    498 {
    499 public:
    500 	typedef AttributeLocationTestUtil::AttribType AttribType;
    501 
    502 							MixedReattachAttributeTest		(tcu::TestContext&		testCtx,
    503 															 glu::RenderContext&	renderCtx);
    504 
    505 	virtual IterateResult	iterate							(void);
    506 
    507 private:
    508 	glu::RenderContext&		m_renderCtx;
    509 };
    510 
    511 class MixedRelinkAttributeTest : public tcu::TestCase
    512 {
    513 public:
    514 	typedef AttributeLocationTestUtil::AttribType AttribType;
    515 
    516 							MixedRelinkAttributeTest(tcu::TestContext&		testCtx,
    517 													 glu::RenderContext&	renderCtx);
    518 
    519 	virtual IterateResult	iterate					(void);
    520 
    521 private:
    522 	glu::RenderContext&								m_renderCtx;
    523 };
    524 
    525 } // gls
    526 } // deqp
    527 
    528 #endif // _GLSATTRIBUTELOCATIONTESTS_HPP
    529