Home | History | Annotate | Download | only in gl
      1 #ifndef _GL4CSHADINGLANGUAGE420PACKTESTS_HPP
      2 #define _GL4CSHADINGLANGUAGE420PACKTESTS_HPP
      3 /*-------------------------------------------------------------------------
      4  * OpenGL Conformance Test Suite
      5  * -----------------------------
      6  *
      7  * Copyright (c) 2014-2016 The Khronos Group Inc.
      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
     24  */ /*-------------------------------------------------------------------*/
     25 
     26 /**
     27  * \file  gl4cShadingLanguage420PackTests.hpp
     28  * \brief Declares test classes for "Shading Language 420Pack" functionality.
     29  */ /*-------------------------------------------------------------------*/
     30 
     31 #include "glcTestCase.hpp"
     32 #include "glwDefs.hpp"
     33 
     34 namespace tcu
     35 {
     36 class MessageBuilder;
     37 } /* namespace tcu */
     38 
     39 namespace gl4cts
     40 {
     41 
     42 namespace GLSL420Pack
     43 {
     44 class Utils
     45 {
     46 public:
     47 	/* Public enums */
     48 	enum TEXTURE_TYPES
     49 	{
     50 		TEX_BUFFER,
     51 		TEX_2D,
     52 		TEX_2D_RECT,
     53 		TEX_2D_ARRAY,
     54 		TEX_3D,
     55 		TEX_CUBE,
     56 		TEX_1D,
     57 		TEX_1D_ARRAY,
     58 
     59 		/* */
     60 		TEXTURE_TYPES_MAX
     61 	};
     62 
     63 	enum SHADER_STAGES
     64 	{
     65 		COMPUTE_SHADER = 0,
     66 		VERTEX_SHADER,
     67 		TESS_CTRL_SHADER,
     68 		TESS_EVAL_SHADER,
     69 		GEOMETRY_SHADER,
     70 		FRAGMENT_SHADER,
     71 
     72 		/* */
     73 		SHADER_STAGES_MAX
     74 	};
     75 
     76 	enum UTF8_CHARACTERS
     77 	{
     78 		TWO_BYTES,
     79 		THREE_BYTES,
     80 		FOUR_BYTES,
     81 		FIVE_BYTES,
     82 		SIX_BYTES,
     83 		REDUNDANT_ASCII,
     84 
     85 		/* */
     86 		EMPTY
     87 	};
     88 
     89 	enum TYPES
     90 	{
     91 		FLOAT,
     92 		DOUBLE,
     93 		INT,
     94 		UINT,
     95 
     96 		/* */
     97 		TYPES_MAX
     98 	};
     99 
    100 	enum QUALIFIER_CLASSES
    101 	{
    102 		QUAL_CLS_INVARIANCE = 0,
    103 		QUAL_CLS_INTERPOLATION,
    104 		QUAL_CLS_LAYOUT,
    105 		QUAL_CLS_AUXILARY_STORAGE,
    106 		QUAL_CLS_STORAGE,
    107 		QUAL_CLS_PRECISION,
    108 
    109 		/* */
    110 		QUAL_CLS_MAX
    111 	};
    112 
    113 	enum QUALIFIERS
    114 	{
    115 		QUAL_NONE,
    116 
    117 		/* CONSTNESS */
    118 		QUAL_CONST,
    119 
    120 		/* STORAGE */
    121 		QUAL_IN,
    122 		QUAL_OUT,
    123 		QUAL_INOUT,
    124 		QUAL_UNIFORM,
    125 
    126 		/* AUXILARY */
    127 		QUAL_PATCH,
    128 		QUAL_CENTROID,
    129 		QUAL_SAMPLE,
    130 
    131 		/* INTERPOLATION */
    132 		QUAL_FLAT,
    133 		QUAL_NOPERSPECTIVE,
    134 		QUAL_SMOOTH,
    135 
    136 		/* LAYOUT */
    137 		QUAL_LOCATION,
    138 
    139 		/* PRECISION */
    140 		QUAL_LOWP,
    141 		QUAL_MEDIUMP,
    142 		QUAL_HIGHP,
    143 		QUAL_PRECISE,
    144 
    145 		/* INVARIANCE */
    146 		QUAL_INVARIANT,
    147 
    148 		/* */
    149 		QUAL_MAX
    150 	};
    151 
    152 	enum VARIABLE_STORAGE
    153 	{
    154 		INPUT,
    155 		OUTPUT,
    156 		UNIFORM,
    157 
    158 		/* */
    159 		STORAGE_MAX
    160 	};
    161 
    162 	enum VARIABLE_FLAVOUR
    163 	{
    164 		BASIC,
    165 		ARRAY,
    166 		INDEXED_BY_INVOCATION_ID
    167 	};
    168 
    169 	/* Public types */
    170 	struct buffer
    171 	{
    172 		buffer(deqp::Context& context);
    173 		~buffer();
    174 
    175 		void bind() const;
    176 
    177 		void bindRange(glw::GLuint index, glw::GLintptr offset, glw::GLsizeiptr size);
    178 
    179 		void generate(glw::GLenum target);
    180 		void* map(glw::GLenum access) const;
    181 		void unmap() const;
    182 
    183 		void update(glw::GLsizeiptr size, glw::GLvoid* data, glw::GLenum usage);
    184 
    185 		void		release();
    186 		glw::GLuint m_id;
    187 
    188 	private:
    189 		deqp::Context& m_context;
    190 		glw::GLenum	m_target;
    191 	};
    192 
    193 	struct framebuffer
    194 	{
    195 		framebuffer(deqp::Context& context);
    196 		~framebuffer();
    197 
    198 		void attachTexture(glw::GLenum attachment, glw::GLuint texture_id, glw::GLuint width, glw::GLuint height);
    199 
    200 		void bind();
    201 		void clear(glw::GLenum mask);
    202 
    203 		void clearColor(glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue, glw::GLfloat alpha);
    204 
    205 		void generate();
    206 
    207 		glw::GLuint m_id;
    208 
    209 	private:
    210 		deqp::Context& m_context;
    211 	};
    212 
    213 	struct shaderSource
    214 	{
    215 		shaderSource();
    216 		shaderSource(const shaderSource& source);
    217 		shaderSource(const glw::GLchar* source_code);
    218 
    219 		struct shaderPart
    220 		{
    221 			std::string m_code;
    222 			glw::GLint  m_length;
    223 		};
    224 
    225 		std::vector<shaderPart> m_parts;
    226 		bool					m_use_lengths;
    227 	};
    228 
    229 	class shaderCompilationException : public std::exception
    230 	{
    231 	public:
    232 		shaderCompilationException(const shaderSource& source, const glw::GLchar* message);
    233 
    234 		virtual ~shaderCompilationException() throw()
    235 		{
    236 		}
    237 
    238 		virtual const char* what() const throw();
    239 
    240 		shaderSource m_shader_source;
    241 		std::string  m_error_message;
    242 	};
    243 
    244 	class programLinkageException : public std::exception
    245 	{
    246 	public:
    247 		programLinkageException(const glw::GLchar* error_message);
    248 
    249 		virtual ~programLinkageException() throw()
    250 		{
    251 		}
    252 
    253 		virtual const char* what() const throw();
    254 
    255 		std::string m_error_message;
    256 	};
    257 
    258 	/** Store information about program object
    259 	 *
    260 	 **/
    261 	struct program
    262 	{
    263 		program(deqp::Context& context);
    264 		~program();
    265 
    266 		void build(const glw::GLchar* compute_shader_code, const glw::GLchar* fragment_shader_code,
    267 				   const glw::GLchar* geometry_shader_code, const glw::GLchar* tesselation_control_shader_code,
    268 				   const glw::GLchar* tesselation_evaluation_shader_code, const glw::GLchar* vertex_shader_code,
    269 				   const glw::GLchar* const* varying_names, glw::GLuint n_varying_names, bool is_separable = false);
    270 
    271 		void build(const shaderSource& compute_shader, const shaderSource& fragment_shader,
    272 				   const shaderSource& geometry_shader, const shaderSource& tesselation_control_shader,
    273 				   const shaderSource& tesselation_evaluation_shader, const shaderSource& vertex_shader,
    274 				   const glw::GLchar* const* varying_names, glw::GLuint n_varying_names, bool is_separable = false);
    275 
    276 		void compile(glw::GLuint shader_id, const shaderSource& source) const;
    277 
    278 		void createFromBinary(const std::vector<glw::GLubyte>& binary, glw::GLenum binary_format);
    279 
    280 		glw::GLint getAttribLocation(const glw::GLchar* name) const;
    281 
    282 		void getBinary(std::vector<glw::GLubyte>& binary, glw::GLenum& binary_format) const;
    283 
    284 		glw::GLuint getSubroutineIndex(const glw::GLchar* subroutine_name, glw::GLenum shader_stage) const;
    285 
    286 		glw::GLint getSubroutineUniformLocation(const glw::GLchar* uniform_name, glw::GLenum shader_stage) const;
    287 
    288 		glw::GLint getUniform1i(glw::GLuint location) const;
    289 		glw::GLint getUniformLocation(const glw::GLchar* uniform_name) const;
    290 
    291 		void link() const;
    292 		void remove();
    293 
    294 		void uniform(const glw::GLchar* uniform_name, TYPES type, glw::GLuint n_columns, glw::GLuint n_rows,
    295 					 const void* data) const;
    296 
    297 		void use() const;
    298 
    299 		/* */
    300 		static void printShaderSource(const shaderSource& source, tcu::MessageBuilder& log);
    301 
    302 		static const glw::GLenum ARB_COMPUTE_SHADER;
    303 
    304 		glw::GLuint m_compute_shader_id;
    305 		glw::GLuint m_fragment_shader_id;
    306 		glw::GLuint m_geometry_shader_id;
    307 		glw::GLuint m_program_object_id;
    308 		glw::GLuint m_tesselation_control_shader_id;
    309 		glw::GLuint m_tesselation_evaluation_shader_id;
    310 		glw::GLuint m_vertex_shader_id;
    311 
    312 	private:
    313 		deqp::Context& m_context;
    314 	};
    315 
    316 	struct texture
    317 	{
    318 		texture(deqp::Context& context);
    319 		~texture();
    320 
    321 		void bind() const;
    322 
    323 		void create(glw::GLuint width, glw::GLuint height, glw::GLenum internal_format);
    324 
    325 		void create(glw::GLuint width, glw::GLuint height, glw::GLuint depth, glw::GLenum internal_format,
    326 					TEXTURE_TYPES texture_type);
    327 
    328 		void createBuffer(glw::GLenum internal_format, glw::GLuint buffer_id);
    329 
    330 		void get(glw::GLenum format, glw::GLenum type, glw::GLvoid* out_data) const;
    331 
    332 		void release();
    333 
    334 		void update(glw::GLuint width, glw::GLuint height, glw::GLuint depth, glw::GLenum format, glw::GLenum type,
    335 					glw::GLvoid* data);
    336 
    337 		glw::GLuint m_id;
    338 
    339 	private:
    340 		glw::GLuint	m_buffer_id;
    341 		deqp::Context& m_context;
    342 		TEXTURE_TYPES  m_texture_type;
    343 	};
    344 
    345 	struct vertexArray
    346 	{
    347 		vertexArray(deqp::Context& Context);
    348 		~vertexArray();
    349 
    350 		void generate();
    351 		void bind();
    352 
    353 		glw::GLuint m_id;
    354 
    355 	private:
    356 		deqp::Context& m_context;
    357 	};
    358 
    359 	/* Public typedefs */
    360 	typedef std::vector<Utils::QUALIFIERS> qualifierSet;
    361 
    362 	/* UniformN*v prototypes */
    363 	typedef GLW_APICALL void(GLW_APIENTRY* uniformNdv)(glw::GLint, glw::GLsizei, const glw::GLdouble*);
    364 	typedef GLW_APICALL void(GLW_APIENTRY* uniformNfv)(glw::GLint, glw::GLsizei, const glw::GLfloat*);
    365 	typedef GLW_APICALL void(GLW_APIENTRY* uniformNiv)(glw::GLint, glw::GLsizei, const glw::GLint*);
    366 	typedef GLW_APICALL void(GLW_APIENTRY* uniformNuiv)(glw::GLint, glw::GLsizei, const glw::GLuint*);
    367 	typedef GLW_APICALL void(GLW_APIENTRY* uniformMatrixNdv)(glw::GLint, glw::GLsizei, glw::GLboolean,
    368 															 const glw::GLdouble*);
    369 	typedef GLW_APICALL void(GLW_APIENTRY* uniformMatrixNfv)(glw::GLint, glw::GLsizei, glw::GLboolean,
    370 															 const glw::GLfloat*);
    371 
    372 	/* Public static methods */
    373 	/* UniformN*v routine getters */
    374 	static uniformNdv getUniformNdv(const glw::Functions& gl, glw::GLuint n_rows);
    375 
    376 	static uniformNfv getUniformNfv(const glw::Functions& gl, glw::GLuint n_rows);
    377 
    378 	static uniformNiv getUniformNiv(const glw::Functions& gl, glw::GLuint n_rows);
    379 
    380 	static uniformNuiv getUniformNuiv(const glw::Functions& gl, glw::GLuint n_rows);
    381 
    382 	static uniformMatrixNdv getUniformMatrixNdv(const glw::Functions& gl, glw::GLuint n_columns, glw::GLuint n_rows);
    383 
    384 	static uniformMatrixNfv getUniformMatrixNfv(const glw::Functions& gl, glw::GLuint n_columns, glw::GLuint n_rows);
    385 
    386 	/* GLSL qualifiers */
    387 	static bool doesContainQualifier(QUALIFIERS qualifier, const qualifierSet& qualifiers);
    388 
    389 	static bool doesStageSupportQualifier(SHADER_STAGES stage, VARIABLE_STORAGE storage, QUALIFIERS qualifier);
    390 
    391 	static const glw::GLchar* getQualifierString(QUALIFIERS qualifier);
    392 	static std::string getQualifiersListString(const qualifierSet& qualifiers);
    393 
    394 	static qualifierSet prepareQualifiersSet(const qualifierSet& in_qualifiers, SHADER_STAGES stage,
    395 											 VARIABLE_STORAGE storage);
    396 
    397 	/* Variable name */
    398 	static std::string getBlockVariableDefinition(const Utils::qualifierSet& qualifiers, const glw::GLchar* type_name,
    399 												  const glw::GLchar* variable_name);
    400 
    401 	static std::string getBlockVariableReference(VARIABLE_FLAVOUR flavour, const glw::GLchar* variable_name,
    402 												 const glw::GLchar* block_name);
    403 
    404 	static std::string getVariableDefinition(VARIABLE_FLAVOUR flavour, const Utils::qualifierSet& qualifiers,
    405 											 const glw::GLchar* type_name, const glw::GLchar* variable_name);
    406 
    407 	static VARIABLE_FLAVOUR getVariableFlavour(Utils::SHADER_STAGES stage, Utils::VARIABLE_STORAGE storage,
    408 											   const Utils::qualifierSet& qualifiers);
    409 
    410 	static std::string getVariableName(Utils::SHADER_STAGES stage, Utils::VARIABLE_STORAGE storage,
    411 									   const glw::GLchar* variable_name);
    412 
    413 	static std::string getVariableReference(VARIABLE_FLAVOUR flavour, const glw::GLchar* variable_name);
    414 
    415 	static void prepareBlockVariableStrings(Utils::SHADER_STAGES in_stage, Utils::VARIABLE_STORAGE in_storage,
    416 											const Utils::qualifierSet& in_qualifiers, const glw::GLchar* in_type_name,
    417 											const glw::GLchar* in_variable_name, const glw::GLchar* in_block_name,
    418 											std::string& out_definition, std::string& out_reference);
    419 
    420 	static void prepareVariableStrings(Utils::SHADER_STAGES in_stage, Utils::VARIABLE_STORAGE in_storage,
    421 									   const Utils::qualifierSet& in_qualifiers, const glw::GLchar* in_type_name,
    422 									   const glw::GLchar* in_variable_name, std::string& out_definition,
    423 									   std::string& out_reference);
    424 
    425 	/* Textures */
    426 	static const glw::GLchar* getImageType(TEXTURE_TYPES type);
    427 	static glw::GLuint getNumberOfCoordinates(TEXTURE_TYPES type);
    428 	static const glw::GLchar* getSamplerType(TEXTURE_TYPES type);
    429 	static glw::GLenum getTextureTartet(TEXTURE_TYPES type);
    430 	static const glw::GLchar* getTextureTypeName(TEXTURE_TYPES type);
    431 
    432 	/* Stuff */
    433 	static bool checkUniformBinding(Utils::program& program, const glw::GLchar* name, glw::GLint expected_binding);
    434 	static bool checkUniformArrayBinding(Utils::program& program, const glw::GLchar* name, glw::GLuint index,
    435 										 glw::GLint expected_binding);
    436 	static bool doesTypeSupportMatrix(TYPES type);
    437 	static const glw::GLchar* getShaderStageName(SHADER_STAGES stage);
    438 	static const glw::GLchar* getTypeName(TYPES type, glw::GLuint n_columns, glw::GLuint n_rows);
    439 	static const glw::GLchar* getUtf8Character(UTF8_CHARACTERS character);
    440 	static bool isExtensionSupported(deqp::Context& context, const glw::GLchar* extension_name);
    441 	static bool isGLVersionAtLeast(const glw::Functions& gl, glw::GLint required_major, glw::GLint required_minor);
    442 	static void replaceToken(const glw::GLchar* token, size_t& search_position, const glw::GLchar* text,
    443 							 std::string& string);
    444 	static void replaceAllTokens(const glw::GLchar* token, const glw::GLchar* text, std::string& string);
    445 };
    446 
    447 /** Base class for tests **/
    448 class TestBase : public deqp::TestCase
    449 {
    450 public:
    451 	/* Public methods */
    452 	TestBase(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
    453 	virtual ~TestBase()
    454 	{
    455 	}
    456 
    457 	/* Public methods inherited from TestCase */
    458 	virtual tcu::TestNode::IterateResult iterate(void);
    459 
    460 protected:
    461 	/* Methods to be implemented by child class */
    462 	virtual void getShaderSourceConfig(glw::GLuint& out_n_parts, bool& out_use_lengths);
    463 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
    464 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
    465 									 Utils::shaderSource& out_source) = 0;
    466 	virtual void prepareUniforms(Utils::program& program);
    467 	virtual bool testInit();
    468 	virtual bool testCompute()						 = 0;
    469 	virtual bool testDrawArray(bool use_version_400) = 0;
    470 
    471 	/* Methods available to child classes */
    472 	const glw::GLchar* getStageSpecificLayout(Utils::SHADER_STAGES stage) const;
    473 	const glw::GLchar* getVersionString(Utils::SHADER_STAGES stage, bool use_version_400) const;
    474 	void initShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, Utils::shaderSource& out_source);
    475 
    476 	/* Protected variables */
    477 	bool m_is_compute_shader_supported;
    478 	bool m_is_explicit_uniform_location;
    479 	bool m_is_shader_language_420pack;
    480 
    481 private:
    482 	/* Private methods */
    483 	bool test();
    484 };
    485 
    486 /** Base class for API tests */
    487 class APITestBase : public TestBase
    488 {
    489 public:
    490 	/* Public methods */
    491 	APITestBase(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
    492 
    493 	virtual ~APITestBase()
    494 	{
    495 	}
    496 
    497 protected:
    498 	/* Protected methods inherited from TestBase */
    499 	virtual bool testCompute();
    500 	virtual bool testDrawArray(bool use_version_400);
    501 
    502 	/* Protected methods to be implemented by child class */
    503 	virtual bool checkResults(Utils::program& program) = 0;
    504 
    505 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
    506 									 Utils::shaderSource& out_source) = 0;
    507 };
    508 
    509 /** Base class for GLSL tests **/
    510 class GLSLTestBase : public TestBase
    511 {
    512 public:
    513 	/* Public methods */
    514 	GLSLTestBase(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
    515 
    516 	virtual ~GLSLTestBase()
    517 	{
    518 	}
    519 
    520 protected:
    521 	/* Protected methods inherited from TestBase */
    522 	virtual bool testCompute();
    523 	virtual bool testDrawArray(bool use_version_400);
    524 
    525 	/* Protected methods to be implemented by child class */
    526 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
    527 									 Utils::shaderSource& out_source) = 0;
    528 
    529 	virtual const glw::GLchar* prepareSourceTexture(Utils::texture& texture);
    530 
    531 	virtual void prepareVertexBuffer(const Utils::program& program, Utils::buffer& buffer, Utils::vertexArray& vao);
    532 
    533 	virtual bool verifyAdditionalResults() const;
    534 	virtual void releaseResource();
    535 
    536 private:
    537 	/* Private methods */
    538 	void bindTextureToimage(Utils::program& program, Utils::texture& texture, const glw::GLchar* uniform_name) const;
    539 
    540 	void bindTextureToSampler(Utils::program& program, Utils::texture& texture, const glw::GLchar* uniform_name) const;
    541 
    542 	bool checkResults(Utils::texture& color_texture) const;
    543 
    544 	void prepareFramebuffer(Utils::framebuffer& framebuffer, Utils::texture& color_texture) const;
    545 
    546 	void prepareImage(Utils::program& program, Utils::texture& color_texture) const;
    547 
    548 	/* Private constants */
    549 	static const glw::GLenum m_color_texture_internal_format;
    550 	static const glw::GLenum m_color_texture_format;
    551 	static const glw::GLenum m_color_texture_type;
    552 	static const glw::GLuint m_color_texture_width;
    553 	static const glw::GLuint m_color_texture_height;
    554 };
    555 
    556 /** Base class for negative tests **/
    557 class NegativeTestBase : public TestBase
    558 {
    559 public:
    560 	/* Public methods */
    561 	NegativeTestBase(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
    562 
    563 	virtual ~NegativeTestBase()
    564 	{
    565 	}
    566 
    567 protected:
    568 	/* Protected methods inherited from TestBase */
    569 	virtual bool testCompute();
    570 	virtual bool testDrawArray(bool use_version_400);
    571 
    572 	/* Protected methods to be implemented by child class */
    573 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
    574 									 Utils::shaderSource& out_source) = 0;
    575 };
    576 
    577 /** Base class for "binding image" tests **/
    578 class BindingImageTest : public GLSLTestBase
    579 {
    580 public:
    581 	/* Public methods */
    582 	BindingImageTest(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
    583 
    584 	virtual ~BindingImageTest()
    585 	{
    586 	}
    587 
    588 protected:
    589 	/* Protected methods */
    590 	void prepareBuffer(Utils::buffer& buffer, glw::GLuint color);
    591 
    592 	void prepareTexture(Utils::texture& texture, const Utils::buffer& buffer, Utils::TEXTURE_TYPES texture_type,
    593 						glw::GLuint color, glw::GLuint unit);
    594 
    595 	bool verifyBuffer(const Utils::buffer& buffer) const;
    596 	bool verifyTexture(const Utils::texture& texture) const;
    597 
    598 	/* Protected constants */
    599 	static const glw::GLuint m_width;
    600 	static const glw::GLuint m_green_color;
    601 	static const glw::GLuint m_height;
    602 	static const glw::GLuint m_depth;
    603 };
    604 
    605 /** Test implementation, description follows:
    606  *
    607  * GLSL Tests:
    608  *
    609  *   * Unix-style new line continuation:
    610  *
    611  *    Run test with shader that contains line continuation and Unix-style (LF)
    612  *    new line characters inside:
    613  *
    614  *     - assignment expression (after and before '=' operator)
    615  *
    616  *     - vector variable initializer (after ',' in contructor)
    617  *
    618  *     - tokens (inside function name, inside type name, inside variable name).
    619  *       These tokens are later used to generate some color value, that
    620  *       is later verifed.
    621  *
    622  *     - preprocessor (#define) syntax  - inside and in between preprocessor
    623  *       tokens. These tokens are later used to generate some color value,
    624  *       that is later verifed.
    625  *
    626  *     - comments
    627  *
    628  *    For example test for line continuation inside preprocessor tokens may use
    629  *    following GLSL code:
    630  *
    631  *        #define ADD_ONE(XX) (X\\
    632          *        X + 1.0)
    633  *        vec4 getColor(float f) {
    634  *            return vec4(0.0, ADD_ONE(0.0), 0.0, 1.0);
    635  *        }
    636  *
    637  *     Where returned color is verified agains some reference value.
    638  *
    639  *
    640  *   * DOS-style line continuation:
    641  *
    642  *    Run same test with line continuation sign before DOS-style (CR+LF) new
    643  *    line character.
    644  *
    645  *
    646  *   * Multiple line continuations in same GLSL token:
    647  *
    648  *    Run test with shader that contains multiple (3 or more) line
    649  *    continuation and newlines inside same GLSL tokens (function or variable
    650  *    names).
    651  *
    652  *
    653  *   * Line continuation near GLSL shader source null-termination:
    654  *
    655  *    Run test with shader that contains line continuation character as the
    656  *    last character in null terminated shader string.
    657  *
    658  *
    659  *   * Line continuation near GLSL shader source end:
    660  *
    661  *    Run test with shader that contains line continuation character as the
    662  *    last character in not null terminated shader string (shader source length
    663  *    parameter is specified in glShaderSource call).
    664  *
    665  *
    666  *   * Line continuation near end of GLSL shader source string:
    667  *
    668  *    Run test with shader constructed by multple strings passed to
    669  *    glShaderSource. New line continuation characters placed as:
    670  *
    671  *     - last character of passed null terminated string
    672  *     - next-to-last character of passed null terminated string,
    673  *       followed by newline
    674  *     - last character of passed not null terminated string
    675  *     - next-to-last character of passed not null terminated string,
    676  *       followed by newline
    677  *
    678  *     Each string with line continuation should be followed by a next,
    679  *     non-empty string.
    680  **/
    681 class LineContinuationTest : public GLSLTestBase
    682 {
    683 public:
    684 	/* Public methods */
    685 	LineContinuationTest(deqp::Context&);
    686 
    687 	virtual ~LineContinuationTest()
    688 	{
    689 	}
    690 
    691 protected:
    692 	/* Protected methods inherited from GLSLTestBase */
    693 	virtual void getShaderSourceConfig(glw::GLuint& out_n_parts, bool& out_use_lengths);
    694 
    695 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
    696 
    697 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
    698 									 Utils::shaderSource& out_source);
    699 
    700 	virtual const glw::GLchar* prepareSourceTexture(Utils::texture& texture);
    701 
    702 	virtual void prepareVertexBuffer(const Utils::program& program, Utils::buffer& buffer, Utils::vertexArray& vao);
    703 
    704 private:
    705 	/* Private enums */
    706 	enum CASES
    707 	{
    708 		ASSIGNMENT_BEFORE_OPERATOR = 0,
    709 		ASSIGNMENT_AFTER_OPERATOR,
    710 		VECTOR_VARIABLE_INITIALIZER,
    711 		TOKEN_INSIDE_FUNCTION_NAME,
    712 		TOKEN_INSIDE_TYPE_NAME,
    713 		TOKEN_INSIDE_VARIABLE_NAME,
    714 		PREPROCESSOR_TOKEN_INSIDE,
    715 		PREPROCESSOR_TOKEN_BETWEEN,
    716 		COMMENT,
    717 		SOURCE_TERMINATION_NULL,
    718 		SOURCE_TERMINATION_NON_NULL,
    719 		PART_TERMINATION_NULL,
    720 		PART_NEXT_TO_TERMINATION_NULL,
    721 		PART_TERMINATION_NON_NULL,
    722 		PART_NEXT_TO_TERMINATION_NON_NULL,
    723 
    724 		/* DEBUG: there will be no line continuations at all */
    725 		DEBUG_CASE
    726 	};
    727 
    728 	enum REPETITIONS
    729 	{
    730 		ONCE = 0,
    731 		MULTIPLE_TIMES,
    732 	};
    733 
    734 	enum LINE_ENDINGS
    735 	{
    736 		UNIX = 0,
    737 		DOS,
    738 	};
    739 
    740 	/* Private types */
    741 	/** Declare test case
    742 	 *
    743 	 **/
    744 	struct testCase
    745 	{
    746 		glw::GLuint m_case;
    747 		glw::GLuint m_repetitions;
    748 		glw::GLuint m_line_endings;
    749 	};
    750 
    751 	/* Private methods */
    752 	const glw::GLchar* casesToStr(CASES cases) const;
    753 	const glw::GLchar* getExpectedValueString() const;
    754 	std::string		   getLineContinuationString() const;
    755 	bool			   isShaderMultipart() const;
    756 	const glw::GLchar* lineEndingsToStr(LINE_ENDINGS line_ending) const;
    757 	void prepareComputShaderSource(Utils::shaderSource& shaderSource);
    758 
    759 	void prepareShaderSourceForDraw(Utils::SHADER_STAGES stage, bool use_version_400, Utils::shaderSource& source);
    760 
    761 	const glw::GLchar* repetitionsToStr(REPETITIONS repetitions) const;
    762 	void replaceAllCaseTokens(std::string& source) const;
    763 	bool useSourceLengths() const;
    764 
    765 	/* Private constants */
    766 	static const glw::GLuint  m_n_repetitions;
    767 	static const glw::GLchar* m_texture_coordinates_name;
    768 
    769 	/* Private variables */
    770 	testCase m_test_case;
    771 };
    772 
    773 /** Test implementation, description follows:
    774  *
    775  * Correct numbering of lines with line continuations:
    776  *
    777  * Try to compile shader with line continuation schemes, followed
    778  * by __LINE__ macro capturing the current line number.
    779  * The value of __LINE__ is than validated against expected
    780  * constant. Expected value must account for continued lines,
    781  * for example in code below, they are two line continuations,
    782  * so the expected value is N - 2 (where N is the "raw" line number).
    783  *
    784  *     ivec4 glsl\\
    785          *     Test\\
    786          *     Func(float f) {
    787  *         obvious = error;
    788  *         return vec4(__LINE__, 0, 0, 1);
    789  *     }
    790  **/
    791 class LineNumberingTest : public GLSLTestBase
    792 {
    793 public:
    794 	/* Public methods */
    795 	LineNumberingTest(deqp::Context&);
    796 
    797 	virtual ~LineNumberingTest()
    798 	{
    799 	}
    800 
    801 protected:
    802 	/* Protected methods inherited from GLSLTestBase */
    803 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
    804 									 Utils::shaderSource& out_source);
    805 };
    806 
    807 /** Test implementation, description follows:
    808  *
    809  * * UTF-8 characters in comments:
    810  *
    811  *   Run test with shader that contains non-ASCII UTF-8 characters in comments.
    812  *   Use 2-byte UTF-8 characters (Latin-1 supplements, Greek, Hebrew, Cyril),
    813  *   3-byte (Chinese/Japanese/Korean), 4-byte (less common CJK).
    814  *   Also test 5 and 6 byte codes.
    815  *   Also test base plane ASCII characters encoded with redundant bytes,
    816  *   such as 'a' or <whitespace> encoded by 4 bytes.
    817  *
    818  *   Encode UTF-8 strings manually in test, either by c-array or '\0xNN' escape
    819  *   sequences.
    820  *
    821  *
    822  *  * UTF-8 characters in preprocessor:
    823  *
    824  *   Run test with shader that contains non-ASCII UTF-8 characters (arbitrary
    825  *   from above) in preprocessor tokens. Use preprocessor to strip these UTF-8
    826  *   characters, so they does not occur in preprocessed GLSL shader source.
    827  *
    828  *
    829  *  * Incomplete UTF-8 near GLSL shader source null-termination:
    830  *
    831  *   Run test with shader that contains comment with incomplete UTF-8
    832  *   character as the last character in null terminated shader string.
    833  *
    834  *
    835  *  * Incomplete UTF-8 near GLSL shader source end:
    836  *
    837  *   Run test with shader that contains comment with incomplete UTF-8
    838  *   character as the last character in not-null terminated shader string.
    839  *   Shader source length parameter is specified in glShaderSource call.
    840  **/
    841 class UTF8CharactersTest : public GLSLTestBase
    842 {
    843 public:
    844 	/* Public methods */
    845 	UTF8CharactersTest(deqp::Context&);
    846 
    847 	virtual ~UTF8CharactersTest()
    848 	{
    849 	}
    850 
    851 	/* Protected methods inherited from GLSLTestBase */
    852 	virtual void getShaderSourceConfig(glw::GLuint& out_n_parts, bool& out_use_lengths);
    853 
    854 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
    855 
    856 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
    857 									 Utils::shaderSource& out_source);
    858 
    859 	virtual const glw::GLchar* prepareSourceTexture(Utils::texture& texture);
    860 
    861 private:
    862 	/* Private enums */
    863 	enum CASES
    864 	{
    865 		IN_COMMENT = 0,
    866 		IN_PREPROCESSOR,
    867 		AS_LAST_CHARACTER_NULL_TERMINATED,
    868 		AS_LAST_CHARACTER_NON_NULL_TERMINATED,
    869 
    870 		DEBUG_CASE
    871 	};
    872 
    873 	/* Private types */
    874 	struct testCase
    875 	{
    876 		CASES				   m_case;
    877 		Utils::UTF8_CHARACTERS m_character;
    878 	};
    879 
    880 	/* Private methods */
    881 	const glw::GLchar* casesToStr() const;
    882 
    883 	/* Private variables */
    884 	testCase m_test_case;
    885 };
    886 
    887 /** Test implementation, description follows:
    888  *
    889  * * UTF-8 in after preprocessor, in GLSL syntax:
    890  *
    891  *   Try to compile shader that contains non-ASCII UTF-8 character after
    892  *   preprocessing. Expect compilation error.
    893  **/
    894 class UTF8InSourceTest : public NegativeTestBase
    895 {
    896 public:
    897 	/* Public methods */
    898 	UTF8InSourceTest(deqp::Context&);
    899 
    900 	virtual ~UTF8InSourceTest()
    901 	{
    902 	}
    903 
    904 	/* Protected methods inherited from GLSLTestBase */
    905 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
    906 
    907 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
    908 									 Utils::shaderSource& out_source);
    909 
    910 private:
    911 	/* Private variables */
    912 	Utils::UTF8_CHARACTERS m_character;
    913 };
    914 
    915 /** Test implementation, description follows:
    916  *
    917  * * Check all implicit conversions on function return:
    918  *
    919  *    Run test with shader that verifies value being return by following
    920  *    function:
    921  *
    922  *        T1 f(T2 x, T2 y) { return x + y; }'
    923  *
    924  *   By substituting T1 and T2 typenames check following conversions:
    925  *    - int to uint
    926  *    - int to float
    927  *    - uint to float
    928  *    - int to double
    929  *    - uint to double
    930  *    - float to double
    931  *   Use scalars and vector types (all vector sizes). For conversions not
    932  *   involving ints or uints test also matrix types (all matrix sizes)
    933  *
    934  *   Call this function on literals, constant expressions and variables
    935  *   (variables should contain values that cannot be constant folded during
    936  *   compilation).
    937  **/
    938 class ImplicitConversionsValidTest : public GLSLTestBase
    939 {
    940 public:
    941 	/* Public methods */
    942 	ImplicitConversionsValidTest(deqp::Context&);
    943 
    944 	virtual ~ImplicitConversionsValidTest()
    945 	{
    946 	}
    947 
    948 protected:
    949 	/* Methods to be implemented by child class */
    950 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
    951 
    952 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
    953 									 Utils::shaderSource& out_source);
    954 
    955 	virtual void prepareUniforms(Utils::program& program);
    956 	virtual bool testInit();
    957 
    958 private:
    959 	/* Private types */
    960 	struct typesPair
    961 	{
    962 		Utils::TYPES m_t1;
    963 		Utils::TYPES m_t2;
    964 	};
    965 
    966 	struct testCase
    967 	{
    968 		typesPair   m_types;
    969 		glw::GLuint m_n_cols;
    970 		glw::GLuint m_n_rows;
    971 	};
    972 
    973 	/* Private methods */
    974 	const testCase& getCurrentTestCase();
    975 
    976 	std::string getValueList(glw::GLuint n_columns, glw::GLuint n_rows);
    977 
    978 	/* Private variables */
    979 	testCase			  m_debug_test_case;
    980 	std::vector<testCase> m_test_cases;
    981 	glw::GLuint			  m_current_test_case_index;
    982 };
    983 
    984 /** Test implementation, description follows:
    985  *
    986  * * Check if uint to int conversion is forbidden:
    987  *
    988  *   Try to compile shader that returns uint value from function returning int.
    989  *   Expect shader compilation error. Use scalars and vector types.
    990  **/
    991 class ImplicitConversionsInvalidTest : public NegativeTestBase
    992 {
    993 public:
    994 	/* Public methods */
    995 	ImplicitConversionsInvalidTest(deqp::Context&);
    996 
    997 	virtual ~ImplicitConversionsInvalidTest()
    998 	{
    999 	}
   1000 
   1001 protected:
   1002 	/* Methods to be implemented by child class */
   1003 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1004 
   1005 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1006 									 Utils::shaderSource& out_source);
   1007 
   1008 private:
   1009 	/* Private methods */
   1010 	std::string getValueList(glw::GLuint n_rows);
   1011 
   1012 	/* Private variables */
   1013 	glw::GLuint m_current_test_case_index;
   1014 };
   1015 
   1016 /** Test implementation, description follows:
   1017  *
   1018  * * Read-only variables:
   1019  *
   1020  *   Run shader which contains and uses following read-only variables:
   1021  *    const float c1 = X1;
   1022  *    const vec4 c2 = X2;
   1023  *    const mat2 c3 = X3;
   1024  *    const S c4 = X4;
   1025  *    const vec4 c5[15] = X5;
   1026  *
   1027  *   Where X1..X5 are non-constant initializer expressions (expressions which
   1028  *   cannot be constant folded).  S is a struct of scalar, vector and matrix
   1029  *   transparent types. Verify value of each read-only variable.
   1030  **/
   1031 class ConstDynamicValueTest : public GLSLTestBase
   1032 {
   1033 public:
   1034 	/* Public methods */
   1035 	ConstDynamicValueTest(deqp::Context&);
   1036 
   1037 	virtual ~ConstDynamicValueTest()
   1038 	{
   1039 	}
   1040 
   1041 protected:
   1042 	/* Methods to be implemented by child class */
   1043 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1044 									 Utils::shaderSource& out_source);
   1045 
   1046 	virtual void prepareUniforms(Utils::program& program);
   1047 };
   1048 
   1049 /** Test implementation, description follows:
   1050  *
   1051  * * Override value of read-only variable:
   1052  *
   1053  *   Try to compile shaders, that override value of constant variable.
   1054  *   Use constant variable defined as:
   1055  *     const float c1 = X1;
   1056  *
   1057  *   Where X1 is once a literal initializer and in another shader is a
   1058  *   non-const-foldable non-constant variable.
   1059  *
   1060  *   Variable is non-const-foldable when it's value cannot be deduced during
   1061  *   shader compilation. (As an example uniforms and varyings are non const
   1062  *   foldable).
   1063  *
   1064  *   Expect compilation errors on any assignment to such variable.
   1065  **/
   1066 class ConstAssignmentTest : public NegativeTestBase
   1067 {
   1068 public:
   1069 	/* Public methods */
   1070 	ConstAssignmentTest(deqp::Context&);
   1071 
   1072 	virtual ~ConstAssignmentTest()
   1073 	{
   1074 	}
   1075 
   1076 protected:
   1077 	/* Methods to be implemented by child class */
   1078 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1079 
   1080 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1081 									 Utils::shaderSource& out_source);
   1082 
   1083 private:
   1084 	/* Private variables */
   1085 	glw::GLuint m_current_test_case_index;
   1086 };
   1087 
   1088 /** Test implementation, description follows:
   1089  *
   1090  * * Read-only variable use in place of constant expression:
   1091  *
   1092  *   Try to compile shader, that tries to force constant folding on const
   1093  *   variable, when constant variable was initialized with non-constant,
   1094  *   non const foldable expression. For example:
   1095  *
   1096  *   vec4 glslTestFunc(float f) {
   1097  *        const float fConst1 = f;
   1098  *        float a[f]; //force constant folding of f.
   1099  *        return vec4(a[0]);
   1100  *    }
   1101  *    ...
   1102  *    glslTestFunc(gl_FragCoord.x);
   1103  **/
   1104 class ConstDynamicValueAsConstExprTest : public NegativeTestBase
   1105 {
   1106 public:
   1107 	/* Public methods */
   1108 	ConstDynamicValueAsConstExprTest(deqp::Context&);
   1109 
   1110 	virtual ~ConstDynamicValueAsConstExprTest()
   1111 	{
   1112 	}
   1113 
   1114 protected:
   1115 	/* Methods to be implemented by child class */
   1116 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1117 									 Utils::shaderSource& out_source);
   1118 };
   1119 
   1120 /** Test implementation, description follows:
   1121  *
   1122  * * Input variable qualifier order:
   1123  *
   1124  *   Run shader which uses input variable, that is declared with all
   1125  *   permutations of following qualifiers:
   1126  *
   1127  *    storage qualifiers: in
   1128  *    interpolation qualifiers: (none), flat, noperespective, smooth
   1129  *    auxaliary qualifiers: (none), patch, sample, centroid
   1130  *    precision qualifiers: (none), precise
   1131  *    invariance qualifiers: (none), invariant
   1132  *    layout qualifiers: (none), layout(location = 0)
   1133  *
   1134  *   Test fragment, tessellation evaluation, tessellation control and geometry
   1135  *   shader inputs.  Skip illegal permutations: flat interpolation qualifier
   1136  *   used with non empty auxaliary qualifier, patch qualifier outside
   1137  *   tessellation shaders. Also skip non-flat interpolation qualifiers for
   1138  *   vertex, tessellation and geometry shaders.
   1139  *
   1140  * * Input variable qualifers used multiple times:
   1141  *
   1142  *   Same as above, but use some qualifiers multiple times.
   1143  *
   1144  * * Output variable qualifier order:
   1145  *   Run shader which uses output variable, that is declared with all
   1146  *    permutations of following qualifiers:
   1147  *
   1148  *     storage qualifiers: out
   1149  *     interpolation qualifiers: (none), flat, noperespective, smooth
   1150  *     auxaliary qualifiers: (none), patch, sample, centroid
   1151  *     precision qualifiers: (none), precise
   1152  *     invariance qualifiers: (none), invariant
   1153  *     layout qualifiers: (none), layout(location = 0)
   1154  *
   1155  *    All permutations above following sets should be used (so all combinations
   1156  *    of qualifiers are tested and all orderings of such combinations are tested).
   1157  *    Used shader input must match output from earlier shader stage.
   1158  *
   1159  *    Test tessellation evaluation, tessellation control, geometry and vertex
   1160  *    shader inputs. Skip illegal permutations: flat interpolation qualifier used
   1161  *    with non empty auxaliary qualifier, patch qualifier outside tessellation
   1162  *    shaders.
   1163  *
   1164  *
   1165  * * Output variable qualifers used multiple times:
   1166  *
   1167  *   Same as above, but use some qualifiers multiple times.
   1168  **/
   1169 class QualifierOrderTest : public GLSLTestBase
   1170 {
   1171 public:
   1172 	/* Public methods */
   1173 	QualifierOrderTest(deqp::Context&);
   1174 
   1175 	virtual ~QualifierOrderTest()
   1176 	{
   1177 	}
   1178 
   1179 protected:
   1180 	/* Methods to be implemented by child class */
   1181 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1182 
   1183 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1184 									 Utils::shaderSource& out_source);
   1185 
   1186 	virtual void prepareVertexBuffer(const Utils::program& program, Utils::buffer& buffer, Utils::vertexArray& vao);
   1187 
   1188 	virtual bool testInit();
   1189 
   1190 private:
   1191 	/* Private methods */
   1192 	const Utils::qualifierSet& getCurrentTestCase();
   1193 
   1194 	/* Private varaibles */
   1195 	std::vector<Utils::qualifierSet> m_test_cases;
   1196 	glw::GLuint						 m_current_test_case_index;
   1197 };
   1198 
   1199 /** Test implementation, description follows:
   1200  *
   1201  * * Input block interface qualifier order:
   1202  *
   1203  *   Run shaders with same variable qualifications as above used for input
   1204  *   interface block member.
   1205  *
   1206  *    Use following block declaration:
   1207  *      in BLOCK {
   1208  *          vec4 color;
   1209  *      };
   1210  *
   1211  *   Test fragment shader, tessellation evaluation, tessellation control and
   1212  *   geometry shader inputs. Skip illegal permutations, same as in previous
   1213  *   test cases.
   1214  *
   1215  *
   1216  * * Input block interface qualifers used multiple times:
   1217  *
   1218  *   Same as above, but use some qualifiers multiple times.
   1219  *
   1220  * * Output block interface qualifier order:
   1221  *   Run shaders with same variable qualifications as above used for output
   1222  *   interface block member.
   1223  *
   1224  *   Use following block declaration:
   1225  *     out BLOCK {
   1226  *         vec4 color;
   1227  *     };
   1228  *
   1229  *   Test tessellation evaluation, tessellation control, geometry and vertex
   1230  *   shader outputs. Skip illegal permutations, same as in previous test case.
   1231  *
   1232  *
   1233  * * Output block interface qualifers used multiple times:
   1234  *
   1235  *   Same as above, but use some qualifiers multiple times.
   1236  **/
   1237 class QualifierOrderBlockTest : public GLSLTestBase
   1238 {
   1239 public:
   1240 	/* Public methods */
   1241 	QualifierOrderBlockTest(deqp::Context&);
   1242 
   1243 	virtual ~QualifierOrderBlockTest()
   1244 	{
   1245 	}
   1246 
   1247 protected:
   1248 	/* Methods to be implemented by child class */
   1249 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1250 
   1251 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1252 									 Utils::shaderSource& out_source);
   1253 
   1254 	virtual void prepareVertexBuffer(const Utils::program& program, Utils::buffer& buffer, Utils::vertexArray& vao);
   1255 
   1256 	virtual bool testInit();
   1257 
   1258 private:
   1259 	/* Private methods */
   1260 	const Utils::qualifierSet& getCurrentTestCase();
   1261 
   1262 	/* Private varaibles */
   1263 	std::vector<Utils::qualifierSet> m_test_cases;
   1264 	glw::GLuint						 m_current_test_case_index;
   1265 };
   1266 
   1267 /** Test implementation, description follows:
   1268  *
   1269  * * Uniform variable qualifier order:
   1270  *
   1271  *   Run shaders which use uniform, that is declared with all permutations of
   1272  *   'precise', 'uniform', and 'layout(...)' qualifiers.
   1273  *
   1274  *
   1275  * * Uniform qualifers used multiple times:
   1276  *
   1277  *   Same as above, but use some qualifiers multiple times.
   1278  **/
   1279 class QualifierOrderUniformTest : public GLSLTestBase
   1280 {
   1281 public:
   1282 	/* Public methods */
   1283 	QualifierOrderUniformTest(deqp::Context&);
   1284 
   1285 	virtual ~QualifierOrderUniformTest()
   1286 	{
   1287 	}
   1288 
   1289 protected:
   1290 	/* Methods to be implemented by child class */
   1291 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1292 
   1293 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1294 									 Utils::shaderSource& out_source);
   1295 
   1296 	virtual void prepareUniforms(Utils::program& program);
   1297 
   1298 	virtual bool testInit();
   1299 
   1300 private:
   1301 	/* Private methods */
   1302 	const Utils::qualifierSet& getCurrentTestCase();
   1303 
   1304 	/* Private varaibles */
   1305 	std::vector<Utils::qualifierSet> m_test_cases;
   1306 	glw::GLuint						 m_current_test_case_index;
   1307 };
   1308 
   1309 /** Test implementation, description follows:
   1310  *
   1311  * * Function inout parameter qualifier order:
   1312  *
   1313  *   Run shaders which use function, that has inout parameter declared with all
   1314  *   permutations of 'lowp' or 'mediump' or 'highp', 'precise' qualifiers.
   1315  *
   1316  *   Also run with some qualifiers used multiple times.
   1317  **/
   1318 class QualifierOrderFunctionInoutTest : public GLSLTestBase
   1319 {
   1320 public:
   1321 	/* Public methods */
   1322 	QualifierOrderFunctionInoutTest(deqp::Context&);
   1323 
   1324 	virtual ~QualifierOrderFunctionInoutTest()
   1325 	{
   1326 	}
   1327 
   1328 protected:
   1329 	/* Methods to be implemented by child class */
   1330 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1331 
   1332 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1333 									 Utils::shaderSource& out_source);
   1334 
   1335 	virtual void prepareUniforms(Utils::program& program);
   1336 	virtual bool testInit();
   1337 
   1338 private:
   1339 	/* Private methods */
   1340 	const Utils::qualifierSet& getCurrentTestCase();
   1341 
   1342 	/* Private varaibles */
   1343 	std::vector<Utils::qualifierSet> m_test_cases;
   1344 	glw::GLuint						 m_current_test_case_index;
   1345 };
   1346 
   1347 /** Test implementation, description follows:
   1348  *
   1349  * * Function input parameter qualifier order:
   1350  *
   1351  *   Run shaders which use function, that has 'in' parameter declared with all
   1352  *   permutations of 'in', 'lowp' or 'mediump' or 'highp', 'precise', 'const'
   1353  *   qualifiers.
   1354  *
   1355  *   Also run with some qualifiers used multiple times.
   1356  **/
   1357 class QualifierOrderFunctionInputTest : public GLSLTestBase
   1358 {
   1359 public:
   1360 	/* Public methods */
   1361 	QualifierOrderFunctionInputTest(deqp::Context&);
   1362 
   1363 	virtual ~QualifierOrderFunctionInputTest()
   1364 	{
   1365 	}
   1366 
   1367 protected:
   1368 	/* Methods to be implemented by child class */
   1369 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1370 
   1371 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1372 									 Utils::shaderSource& out_source);
   1373 
   1374 	virtual void prepareUniforms(Utils::program& program);
   1375 	virtual bool testInit();
   1376 
   1377 private:
   1378 	/* Private methods */
   1379 	const Utils::qualifierSet& getCurrentTestCase();
   1380 
   1381 	/* Private varaibles */
   1382 	std::vector<Utils::qualifierSet> m_test_cases;
   1383 	glw::GLuint						 m_current_test_case_index;
   1384 };
   1385 
   1386 /** Test implementation, description follows:
   1387  *
   1388  * * Function output parameter qualifier order:
   1389  *
   1390  *   Run shaders which use function, that has out parameter declared with all
   1391  *   permutations of  'lowp' or 'mediump' or 'highp', 'precise' qualifiers.
   1392  *
   1393  *   Also run with some qualifiers used multiple times.
   1394  **/
   1395 class QualifierOrderFunctionOutputTest : public GLSLTestBase
   1396 {
   1397 public:
   1398 	/* Public methods */
   1399 	QualifierOrderFunctionOutputTest(deqp::Context&);
   1400 
   1401 	virtual ~QualifierOrderFunctionOutputTest()
   1402 	{
   1403 	}
   1404 
   1405 protected:
   1406 	/* Methods to be implemented by child class */
   1407 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1408 
   1409 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1410 									 Utils::shaderSource& out_source);
   1411 
   1412 	virtual void prepareUniforms(Utils::program& program);
   1413 	virtual bool testInit();
   1414 
   1415 private:
   1416 	/* Private methods */
   1417 	const Utils::qualifierSet& getCurrentTestCase();
   1418 
   1419 	/* Private varaibles */
   1420 	std::vector<Utils::qualifierSet> m_test_cases;
   1421 	glw::GLuint						 m_current_test_case_index;
   1422 };
   1423 
   1424 /** Test implementation, description follows:
   1425  *
   1426  * * Input variable layout qualifiers override:
   1427  *
   1428  *   Run shaders which use input variable, qualified with multiple layout
   1429  *   qualifiers. For example:
   1430  *
   1431  *       layout(location = 3) layout(location = 2) out vec4 gColor
   1432  *
   1433  *
   1434  * * Geometry shader layout qualifiers override:
   1435  *
   1436  *   Run shader which use multiple global geometry shader qualifiers.
   1437  *   For example:
   1438  *
   1439  *       layout( triangle_strip, max_vertices = 2 ) layout( max_vertices = 3) out;'
   1440  *
   1441  *
   1442  * * Tesselation shader layout qualifiers override:
   1443  *
   1444  *   Run shader which use multiple tesselation shader qualifiers, for example:
   1445  *
   1446  *       layout(vertices = 2) layout(vertices = 4) out;
   1447  **/
   1448 class QualifierOverrideLayoutTest : public GLSLTestBase
   1449 {
   1450 public:
   1451 	/* Public methods */
   1452 	QualifierOverrideLayoutTest(deqp::Context&);
   1453 
   1454 	virtual ~QualifierOverrideLayoutTest()
   1455 	{
   1456 	}
   1457 
   1458 protected:
   1459 	/* Methods to be implemented by child class */
   1460 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1461 									 Utils::shaderSource& out_source);
   1462 
   1463 	virtual void prepareVertexBuffer(const Utils::program& program, Utils::buffer& buffer, Utils::vertexArray& vao);
   1464 };
   1465 
   1466 /** Test implementation, description follows:
   1467  *
   1468  * * 'binding' qualified used for uniform block:
   1469  *
   1470  *   Create shader program which uses uniform block declaration
   1471  *   with 'binding' layout qualifier specified. For example:
   1472  *
   1473  *        layout(std140, binding = 2) uniform BLOCK {
   1474  *           vec4 color;
   1475  *        } block;
   1476  *
   1477  *   Bind filled uniform buffer object to binding point 2.
   1478  *
   1479  *   Run shader program, validate uniform buffer contents in shader.
   1480  *
   1481  *
   1482  * * 'binding' layout qualifier used for multiple uniform blocks in same shader:
   1483  *
   1484  *   Same as above, but use multiple uniform block declarations, each with
   1485  *   different 'layout(binding = X)' qualifier. Validate contents of all
   1486  *   uniform buffers in shader.
   1487  *
   1488  *
   1489  * * 'binding' layout qualifier used for uniform block in different shader
   1490  *    stages:
   1491  *
   1492  *   Link multiple shaders of different stage that use same uniform block.
   1493  *   All uniform block declarations use same 'binding' layout qualifier.
   1494  *
   1495  *   Validate contents of uniform buffer in all shader stages.
   1496  **/
   1497 class BindingUniformBlocksTest : public GLSLTestBase
   1498 {
   1499 public:
   1500 	/* Public methods */
   1501 	BindingUniformBlocksTest(deqp::Context&);
   1502 
   1503 	virtual ~BindingUniformBlocksTest()
   1504 	{
   1505 	}
   1506 
   1507 protected:
   1508 	/* Methods to be implemented by child class */
   1509 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1510 									 Utils::shaderSource& out_source);
   1511 
   1512 	virtual void prepareUniforms(Utils::program& program);
   1513 	virtual void releaseResource();
   1514 
   1515 private:
   1516 	/* Private variables */
   1517 	Utils::buffer m_goku_buffer;
   1518 	Utils::buffer m_vegeta_buffer;
   1519 	Utils::buffer m_children_buffer;
   1520 };
   1521 
   1522 /** Test implementation, description follows:
   1523  *
   1524  * * 'binding' layout qualifier used only once for same uniform block in
   1525  *   different shader stages:
   1526 
   1527  *   Link multiple shaders of different stage that use same uniform block.
   1528  *   'binding' layout qualifier is used only in one shader stage, other shader
   1529  *   stages does not specify layout qualifier.
   1530  *
   1531  *   Validate contents of uniform buffer in all shader stages.
   1532  **/
   1533 class BindingUniformSingleBlockTest : public GLSLTestBase
   1534 {
   1535 public:
   1536 	/* Public methods */
   1537 	BindingUniformSingleBlockTest(deqp::Context&);
   1538 
   1539 	virtual ~BindingUniformSingleBlockTest()
   1540 	{
   1541 	}
   1542 
   1543 protected:
   1544 	/* Methods to be implemented by child class */
   1545 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1546 
   1547 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1548 									 Utils::shaderSource& out_source);
   1549 
   1550 	virtual void prepareUniforms(Utils::program& program);
   1551 	virtual void releaseResource();
   1552 
   1553 private:
   1554 	/* Private variables */
   1555 	Utils::buffer		 m_goku_buffer;
   1556 	Utils::SHADER_STAGES m_test_stage;
   1557 };
   1558 
   1559 /** Test implementation, description follows:
   1560  *
   1561  * * 'binding' layout qualifier used with uniform block array.
   1562  *
   1563  *   Create shader program which uses uniform block array, with 'binding'
   1564  *   layout qualifier specified, example:
   1565  *
   1566  *       layout(std140, binding = 2) uniform BLOCK {
   1567  *          vec4 color;
   1568  *       } block[14];
   1569  *
   1570  *   Bind filled uniform buffer objects to binding points 2..16. Validate
   1571  *   contents of all uniform buffers in shader.
   1572  *
   1573  * * bindings of array of uniform blocks:
   1574  *
   1575  *   Check if uniform buffer array elements automatically get subsequent
   1576  *   binding values, when their interface is specified using 'binding'
   1577  *   layout qualifier. Use glGetActiveUniformBlockiv.
   1578  **/
   1579 class BindingUniformBlockArrayTest : public GLSLTestBase
   1580 {
   1581 public:
   1582 	/* Public methods */
   1583 	BindingUniformBlockArrayTest(deqp::Context&);
   1584 
   1585 	virtual ~BindingUniformBlockArrayTest()
   1586 	{
   1587 	}
   1588 
   1589 protected:
   1590 	/* Methods to be implemented by child class */
   1591 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1592 									 Utils::shaderSource& out_source);
   1593 
   1594 	virtual void prepareUniforms(Utils::program& program);
   1595 	virtual void releaseResource();
   1596 
   1597 private:
   1598 	/* Private methods */
   1599 	void checkBinding(Utils::program& program, glw::GLuint index, glw::GLint expected_binding);
   1600 
   1601 	/* Private variables */
   1602 	Utils::buffer m_goku_00_buffer;
   1603 	Utils::buffer m_goku_01_buffer;
   1604 	Utils::buffer m_goku_02_buffer;
   1605 	Utils::buffer m_goku_03_buffer;
   1606 	Utils::buffer m_goku_04_buffer;
   1607 	Utils::buffer m_goku_05_buffer;
   1608 	Utils::buffer m_goku_06_buffer;
   1609 	Utils::buffer m_goku_07_buffer;
   1610 	Utils::buffer m_goku_08_buffer;
   1611 	Utils::buffer m_goku_09_buffer;
   1612 	Utils::buffer m_goku_10_buffer;
   1613 	Utils::buffer m_goku_11_buffer;
   1614 	Utils::buffer m_goku_12_buffer;
   1615 	Utils::buffer m_goku_13_buffer;
   1616 };
   1617 
   1618 /** Test implementation, description follows:
   1619  *
   1620  * * Default binding value:
   1621  *
   1622  *   Create shader program, with uniform buffer interface declared without
   1623  *   'binding' layout qualifier. Use glGetActiveUniformBlockiv to test if
   1624  *   default 'binding' value is 0.
   1625  **/
   1626 class BindingUniformDefaultTest : public APITestBase
   1627 {
   1628 public:
   1629 	/* Public methods */
   1630 	BindingUniformDefaultTest(deqp::Context&);
   1631 
   1632 	virtual ~BindingUniformDefaultTest()
   1633 	{
   1634 	}
   1635 
   1636 protected:
   1637 	/* Methods to be implemented by child class */
   1638 	virtual bool checkResults(Utils::program& program);
   1639 
   1640 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1641 									 Utils::shaderSource& out_source);
   1642 };
   1643 
   1644 /** Test implementation, description follows:
   1645  *
   1646  * * Override binding value from API:
   1647  *
   1648  *   Create a shader program with uniform buffer interface declared with
   1649  *   'layout(..., binding = 3)'. Use glUniformBlockBinding to change binding
   1650  *   value to 11. Test if binding point 11 is now used during rendering.
   1651  *   Test if binding point 11 is returned when enumerating interface with
   1652  *   glGetActiveUniformBlockiv.
   1653  **/
   1654 class BindingUniformAPIOverirdeTest : public GLSLTestBase
   1655 {
   1656 public:
   1657 	/* Public methods */
   1658 	BindingUniformAPIOverirdeTest(deqp::Context&);
   1659 
   1660 	virtual ~BindingUniformAPIOverirdeTest()
   1661 	{
   1662 	}
   1663 
   1664 protected:
   1665 	/* Methods to be implemented by child class */
   1666 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1667 									 Utils::shaderSource& out_source);
   1668 
   1669 	virtual void prepareUniforms(Utils::program& program);
   1670 	virtual void releaseResource();
   1671 
   1672 private:
   1673 	/* Private variables */
   1674 	Utils::buffer m_goku_buffer;
   1675 };
   1676 
   1677 /** Test implementation, description follows:
   1678  *
   1679  * * 'binding' layout qualifier used with global uniform
   1680  *
   1681  *   Use 'binding' layout qualifier on global (default block) uniform.
   1682  *   Expect shader compilation error.
   1683  **/
   1684 class BindingUniformGlobalBlockTest : public NegativeTestBase
   1685 {
   1686 public:
   1687 	/* Public methods */
   1688 	BindingUniformGlobalBlockTest(deqp::Context&);
   1689 
   1690 	virtual ~BindingUniformGlobalBlockTest()
   1691 	{
   1692 	}
   1693 
   1694 protected:
   1695 	/* Methods to be implemented by child class */
   1696 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1697 									 Utils::shaderSource& out_source);
   1698 };
   1699 
   1700 /** Test implementation, description follows:
   1701  *
   1702  * * Wrong value for 'binding' layout qualifier.
   1703  *
   1704  *   Use -1, variable name, 'std140' as binding value.
   1705  *   Expect shader compilation error in each case.
   1706  *
   1707  * * Missing value for 'binding' layout qualifier.
   1708  *
   1709  *   Expect shader compilation error in following declaration:
   1710  *
   1711  *       layout(std140, binding) uniform BLOCK {
   1712  *          vec4 color;
   1713  *       } block[14];
   1714  **/
   1715 class BindingUniformInvalidTest : public NegativeTestBase
   1716 {
   1717 public:
   1718 	/* Public methods */
   1719 	BindingUniformInvalidTest(deqp::Context&);
   1720 
   1721 	virtual ~BindingUniformInvalidTest()
   1722 	{
   1723 	}
   1724 
   1725 protected:
   1726 	/* Methods to be implemented by child class */
   1727 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1728 
   1729 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1730 									 Utils::shaderSource& out_source);
   1731 
   1732 private:
   1733 	/* Private enums */
   1734 	enum TESTCASES
   1735 	{
   1736 		NEGATIVE_VALUE,
   1737 		VARIABLE_NAME,
   1738 		STD140,
   1739 		MISSING,
   1740 
   1741 		/* */
   1742 		TEST_CASES_MAX
   1743 	};
   1744 
   1745 	/* Private methods */
   1746 	const glw::GLchar* getCaseString(TESTCASES test_case);
   1747 
   1748 	/* Provate variables */
   1749 	TESTCASES m_case;
   1750 };
   1751 
   1752 /** Test implementation, description follows:
   1753  *
   1754  * * 'binding' qualified used for sampler uniform:
   1755  *
   1756  *   Create shader program which uses sampler uniform declaration with
   1757  *   'binding' layout qualifier specified. For example:
   1758  *
   1759  *        layout(binding = 2) uniform sampler2D s;
   1760  *
   1761  *   Bind 2D texture to texture unit GL_TEXTURE2.
   1762  *
   1763  *   Run shader program, validate binding by sampling from texture in shader.
   1764  *
   1765  *
   1766  * * 'binding' layout qualifier used for multiple sampler uniforms in same
   1767  *   shader:
   1768  *
   1769  *   Same as above, but use multiple sampler uniform declarations, each with
   1770  *   different 'layout(binding = X)' qualifier. Validate bindings of all
   1771  *   samplers by sampling textures in shader.
   1772  *
   1773  *
   1774  * * 'binding' layout qualifier used for sampler uniform in different shader
   1775  *   stages:
   1776  *
   1777  *
   1778  *   Link multiple shaders of different stages that use same sampler uniform.
   1779  *   All sampler uniform declarations use same 'binding' layout qualifier.
   1780  *
   1781  *   Validate binding of sampler by sampling texture in shader.
   1782  *
   1783  * * 'binding layout qualifier used with sampler uniforms of various types.
   1784  *
   1785  *   Create shader program which uses samplers of type: samplerBuffer,
   1786  *   sampler2D, sampler2DRect, sampler2DArray, sampler3D, samplerCubeMap,
   1787  *   sampler1D, sampler1DArray.
   1788  *
   1789  *   Each sampler declaration uses 'binding' qualifier with different value.
   1790  *
   1791  *   Validate bindings of all samplers by sampling bound textures in shader.
   1792  **/
   1793 class BindingSamplersTest : public GLSLTestBase
   1794 {
   1795 public:
   1796 	/* Public methods */
   1797 	BindingSamplersTest(deqp::Context&);
   1798 
   1799 	virtual ~BindingSamplersTest()
   1800 	{
   1801 	}
   1802 
   1803 protected:
   1804 	/* Methods to be implemented by child class */
   1805 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1806 
   1807 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1808 									 Utils::shaderSource& out_source);
   1809 
   1810 	virtual void prepareUniforms(Utils::program& program);
   1811 	virtual void releaseResource();
   1812 
   1813 private:
   1814 	/* Private methods */
   1815 	void prepareTexture(Utils::texture& texture, Utils::TEXTURE_TYPES texture_type, glw::GLuint color);
   1816 
   1817 	/* Private variables */
   1818 	Utils::texture		 m_goku_texture;
   1819 	Utils::texture		 m_vegeta_texture;
   1820 	Utils::texture		 m_trunks_texture;
   1821 	Utils::buffer		 m_buffer;
   1822 	Utils::TEXTURE_TYPES m_test_case;
   1823 };
   1824 
   1825 /** Test implementation, description follows:
   1826  *
   1827  * * 'binding' layout qualifier used only once for same sampler uniform in
   1828  *   different shader stages:
   1829  *
   1830  *   Link multiple shaders of different stages that use same sampler uniform.
   1831  *   'binding' layout qualifier is used only in one shader stage, other shader
   1832  *   stages does not specify layout qualifier.
   1833  *
   1834  *   Validate binding of sampler by sampling texture in all shader stages.
   1835  **/
   1836 class BindingSamplerSingleTest : public GLSLTestBase
   1837 {
   1838 public:
   1839 	/* Public methods */
   1840 	BindingSamplerSingleTest(deqp::Context&);
   1841 
   1842 	virtual ~BindingSamplerSingleTest()
   1843 	{
   1844 	}
   1845 
   1846 protected:
   1847 	/* Methods to be implemented by child class */
   1848 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1849 
   1850 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1851 									 Utils::shaderSource& out_source);
   1852 
   1853 	virtual void prepareUniforms(Utils::program& program);
   1854 	virtual void releaseResource();
   1855 
   1856 private:
   1857 	/* Private variables */
   1858 	Utils::texture		 m_goku_texture;
   1859 	Utils::SHADER_STAGES m_test_stage;
   1860 };
   1861 
   1862 /** Test implementation, description follows:
   1863  *
   1864  * * 'binding' layout qualifier used with sampler uniform array.
   1865  *
   1866  *   Create shader program which uses sampler uniform array, with 'binding'
   1867  *   layout qualifier specified, example:
   1868  *
   1869  *       layout(binding = 2) uniform sampler2D s[7];
   1870  *
   1871  *   Bind textures to texture units 2..9. Validate bindings of all samplers
   1872  *   by sampling bound textures in shader.
   1873  *
   1874  * * bindings of array of sampler uniforms
   1875  *
   1876  *   Check if sampler uniform array elements automatically get subsequent
   1877  *   binding values, when their interface is specified using 'binding'
   1878  *   layout qualifier. Use glGetUniformiv.
   1879  **/
   1880 class BindingSamplerArrayTest : public GLSLTestBase
   1881 {
   1882 public:
   1883 	/* Public methods */
   1884 	BindingSamplerArrayTest(deqp::Context&);
   1885 
   1886 	virtual ~BindingSamplerArrayTest()
   1887 	{
   1888 	}
   1889 
   1890 protected:
   1891 	/* Methods to be implemented by child class */
   1892 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1893 									 Utils::shaderSource& out_source);
   1894 
   1895 	virtual void prepareUniforms(Utils::program& program);
   1896 	virtual void releaseResource();
   1897 
   1898 private:
   1899 	/* Private methods */
   1900 	void checkBinding(Utils::program& program, glw::GLuint index, glw::GLint expected_binding);
   1901 
   1902 	/* Private variables */
   1903 	Utils::texture m_goku_00_texture;
   1904 	Utils::texture m_goku_01_texture;
   1905 	Utils::texture m_goku_02_texture;
   1906 	Utils::texture m_goku_03_texture;
   1907 	Utils::texture m_goku_04_texture;
   1908 	Utils::texture m_goku_05_texture;
   1909 	Utils::texture m_goku_06_texture;
   1910 };
   1911 
   1912 /** Test implementation, description follows:
   1913  *
   1914  * * Default binding value:
   1915  *
   1916  *   Create shader program, with sampler uniform declared without 'binding'
   1917  *   layout qualifier. Use glGetUniformiv to test, if default 'binding' value
   1918  *   is 0.
   1919  **/
   1920 class BindingSamplerDefaultTest : public APITestBase
   1921 {
   1922 public:
   1923 	/* Public methods */
   1924 	BindingSamplerDefaultTest(deqp::Context&);
   1925 
   1926 	virtual ~BindingSamplerDefaultTest()
   1927 	{
   1928 	}
   1929 
   1930 protected:
   1931 	/* Methods to be implemented by child class */
   1932 	virtual bool checkResults(Utils::program& program);
   1933 
   1934 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1935 									 Utils::shaderSource& out_source);
   1936 };
   1937 
   1938 /** Test implementation, description follows:
   1939  *
   1940  * * Override binding value from API:
   1941  *
   1942  *   Create a shader program with sampler uniform buffer declared with
   1943  *   'layout(binding = 3)'. Use glUniform1i to change binding value to 11.
   1944  *   Test if binding point 11 is now used during rendering.
   1945  *   Test if binding point 11 is returned querying interface with
   1946  *   glGetUniformiv.
   1947  **/
   1948 class BindingSamplerAPIOverrideTest : public GLSLTestBase
   1949 {
   1950 public:
   1951 	/* Public methods */
   1952 	BindingSamplerAPIOverrideTest(deqp::Context&);
   1953 
   1954 	virtual ~BindingSamplerAPIOverrideTest()
   1955 	{
   1956 	}
   1957 
   1958 protected:
   1959 	/* Methods to be implemented by child class */
   1960 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1961 									 Utils::shaderSource& out_source);
   1962 
   1963 	virtual void prepareUniforms(Utils::program& program);
   1964 	virtual void releaseResource();
   1965 
   1966 private:
   1967 	/* Private variables */
   1968 	Utils::texture m_goku_texture;
   1969 };
   1970 
   1971 /** Test implementation, description follows:
   1972  *
   1973  * * Wrong value for 'binding' layout qualifier.
   1974  *
   1975  *   Use -1 or variable name as binding value. Expect shader compilation
   1976  *   error in each case.
   1977  *
   1978  *
   1979  * * Missing value for 'binding' layout qualifier.
   1980  *
   1981  *   Expect shader compilation error in following declaration:
   1982  *
   1983  *       layout(binding) uniform sampler2D s;
   1984  **/
   1985 class BindingSamplerInvalidTest : public NegativeTestBase
   1986 {
   1987 public:
   1988 	/* Public methods */
   1989 	BindingSamplerInvalidTest(deqp::Context&);
   1990 	virtual ~BindingSamplerInvalidTest()
   1991 	{
   1992 	}
   1993 
   1994 protected:
   1995 	/* Methods to be implemented by child class */
   1996 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   1997 
   1998 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   1999 									 Utils::shaderSource& out_source);
   2000 
   2001 private:
   2002 	/* Private enums */
   2003 	enum TESTCASES
   2004 	{
   2005 		NEGATIVE_VALUE,
   2006 		VARIABLE_NAME,
   2007 		STD140,
   2008 		MISSING,
   2009 
   2010 		/* */
   2011 		TEST_CASES_MAX
   2012 	};
   2013 
   2014 	/* Private methods */
   2015 	const glw::GLchar* getCaseString(TESTCASES test_case);
   2016 
   2017 	/* Provate variables */
   2018 	TESTCASES m_case;
   2019 };
   2020 
   2021 /** Test implementation, description follows:
   2022  *
   2023  * * 'binding' qualified used for image uniform:
   2024  *
   2025  *   Create shader program which uses image uniform declaration with
   2026  *   'binding' layout qualifier specified. For example:
   2027  *
   2028  *       layout(rgba32f, binding = 2) image2D i;
   2029  *
   2030  *   Bind 2D texture to image unit 2.
   2031  *
   2032  *   Run shader program, validate binding by storing values to image in shader.
   2033  *
   2034  *
   2035  * * 'binding' layout qualifier used for multiple image uniforms in same
   2036  *   shader:
   2037  *
   2038  *   Same as above, but use multiple image uniform declarations, each with
   2039  *   different 'layout(binding = X)' qualifier. Validate bindings of all
   2040  *   samplers by storing values to textures in shader.
   2041  *
   2042  *
   2043  * * 'binding' layout qualifier used for image uniform in different shader
   2044  *   stages:
   2045  *
   2046  *   Link multiple shaders of different stages that use same image uniform.
   2047  *   All uniform uniform declarations use same 'binding' layout qualifier.
   2048  *
   2049  *   Validate binding of image uniform by storing values to image in shader.
   2050  *
   2051  *
   2052  * * 'binding' layout qualifier used with image uniforms of various types.
   2053  *
   2054  *   Create shader program which uses samplers of type: imageBuffer,
   2055  *   image2D, image2DRect, image2DArray, image3D, imageCubeMap,
   2056  *   image1D, image1DArray.
   2057  *
   2058  *   Each image declaration uses 'binding' qualifier with different value.
   2059  *
   2060  *   Validate bindings of all image uniforms by storing values to textures
   2061  *   in shader.
   2062  **/
   2063 class BindingImagesTest : public BindingImageTest
   2064 {
   2065 public:
   2066 	/* Public methods */
   2067 	BindingImagesTest(deqp::Context&);
   2068 
   2069 	virtual ~BindingImagesTest()
   2070 	{
   2071 	}
   2072 
   2073 protected:
   2074 	/* Methods to be implemented by child class */
   2075 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   2076 
   2077 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2078 									 Utils::shaderSource& out_source);
   2079 
   2080 	virtual void prepareUniforms(Utils::program& program);
   2081 	virtual bool verifyAdditionalResults() const;
   2082 	virtual void releaseResource();
   2083 
   2084 private:
   2085 	/* Private variables */
   2086 	Utils::texture		 m_goku_texture;
   2087 	Utils::texture		 m_vegeta_texture;
   2088 	Utils::texture		 m_trunks_texture;
   2089 	Utils::buffer		 m_goku_buffer;
   2090 	Utils::buffer		 m_vegeta_buffer;
   2091 	Utils::buffer		 m_trunks_buffer;
   2092 	Utils::TEXTURE_TYPES m_test_case;
   2093 
   2094 	/* Private constant */
   2095 	static const glw::GLuint m_goku_data;
   2096 	static const glw::GLuint m_vegeta_data;
   2097 	static const glw::GLuint m_trunks_data;
   2098 };
   2099 
   2100 /** Test implementation, description follows:
   2101  *
   2102  * * 'binding' layout qualifier used only once for same image uniform in
   2103  different shader stages:
   2104  *
   2105  *   Link multiple shaders of different stages that use same image uniform.
   2106  *   'binding' layout qualifier is used only in one shader stage, other shader
   2107  *   stages does not specify layout qualifier.
   2108  *
   2109  *   Validate binding of image uniform by storing values to image in shader.
   2110  **/
   2111 class BindingImageSingleTest : public BindingImageTest
   2112 {
   2113 public:
   2114 	/* Public methods */
   2115 	BindingImageSingleTest(deqp::Context&);
   2116 
   2117 	virtual ~BindingImageSingleTest()
   2118 	{
   2119 	}
   2120 
   2121 protected:
   2122 	/* Methods to be implemented by child class */
   2123 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   2124 
   2125 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2126 									 Utils::shaderSource& out_source);
   2127 
   2128 	virtual void prepareUniforms(Utils::program& program);
   2129 	virtual bool verifyAdditionalResults() const;
   2130 	virtual void releaseResource();
   2131 
   2132 private:
   2133 	/* Private variables */
   2134 	Utils::texture		 m_goku_texture;
   2135 	Utils::SHADER_STAGES m_test_stage;
   2136 };
   2137 
   2138 /** Test implementation, description follows:
   2139  *
   2140  * * 'binding' layout qualifier used with image uniform array.
   2141  *
   2142  *   Create shader program which uses image uniform array, with 'binding'
   2143  *   layout qualifier specified, example:
   2144  *
   2145  *       layout(rgba32f, binding = 2) uniform image2D i[7];
   2146  *
   2147  *   Bind textures to image units 2..9. Validate bindings of all
   2148  *   image uniforms by storing values to textures in shader.
   2149  *
   2150  *
   2151  * * Bindings of array of image uniforms
   2152  *
   2153  *   Check if image uniform array elements automatically get subsequent
   2154  *   binding values, when their interface is specified using 'binding'
   2155  *   layout qualifier. Use glGetUniformiv.
   2156  **/
   2157 class BindingImageArrayTest : public BindingImageTest
   2158 {
   2159 public:
   2160 	/* Public methods */
   2161 	BindingImageArrayTest(deqp::Context&);
   2162 
   2163 	virtual ~BindingImageArrayTest()
   2164 	{
   2165 	}
   2166 
   2167 protected:
   2168 	/* Methods to be implemented by child class */
   2169 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2170 									 Utils::shaderSource& out_source);
   2171 
   2172 	virtual void prepareUniforms(Utils::program& program);
   2173 	virtual void releaseResource();
   2174 
   2175 private:
   2176 	/* Private methods */
   2177 	void checkBinding(Utils::program& program, glw::GLuint index, glw::GLint expected_binding);
   2178 
   2179 	/* Private variables */
   2180 	Utils::texture m_goku_00_texture;
   2181 	Utils::texture m_goku_01_texture;
   2182 	Utils::texture m_goku_02_texture;
   2183 	Utils::texture m_goku_03_texture;
   2184 	Utils::texture m_goku_04_texture;
   2185 	Utils::texture m_goku_05_texture;
   2186 	Utils::texture m_goku_06_texture;
   2187 };
   2188 
   2189 /** Test implementation, description follows:
   2190  *
   2191  * * Default binding value:
   2192  *
   2193  *   Create shader program, with image uniform declared without 'binding'
   2194  *   layout qualifier. Use glGetUniformiv to test if default 'binding' value
   2195  *   is 0.
   2196  **/
   2197 class BindingImageDefaultTest : public APITestBase
   2198 {
   2199 public:
   2200 	/* Public methods */
   2201 	BindingImageDefaultTest(deqp::Context&);
   2202 
   2203 	virtual ~BindingImageDefaultTest()
   2204 	{
   2205 	}
   2206 
   2207 protected:
   2208 	/* Methods to be implemented by child class */
   2209 	virtual bool checkResults(Utils::program& program);
   2210 
   2211 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2212 									 Utils::shaderSource& out_source);
   2213 };
   2214 
   2215 /** Test implementation, description follows:
   2216  *
   2217  * * Override binding value from API:
   2218  *
   2219  *   Create a shader program with image uniform buffer declared with
   2220  *   'layout(binding = 3)'. Use glUniform1i to change binding value to 11.
   2221  *   Test if binding point 11 is now used during rendering.
   2222  *   Test if binding point 11 is returned querying interface with
   2223  *   glGetUniformiv.
   2224  **/
   2225 class BindingImageAPIOverrideTest : public BindingImageTest
   2226 {
   2227 public:
   2228 	/* Public methods */
   2229 	BindingImageAPIOverrideTest(deqp::Context&);
   2230 
   2231 	virtual ~BindingImageAPIOverrideTest()
   2232 	{
   2233 	}
   2234 
   2235 protected:
   2236 	/* Methods to be implemented by child class */
   2237 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2238 									 Utils::shaderSource& out_source);
   2239 
   2240 	virtual void prepareUniforms(Utils::program& program);
   2241 	virtual void releaseResource();
   2242 
   2243 private:
   2244 	/* Private variables */
   2245 	Utils::texture m_goku_texture;
   2246 };
   2247 
   2248 /** Test implementation, description follows:
   2249  *
   2250  * * Wrong value for 'binding' layout qualifier.
   2251  *
   2252  *   Use -1, 'rgba32f' or variable name as binding value. Expect shader
   2253  *   compilation error in each case.
   2254  *
   2255  *
   2256  * * Missing value for 'binding' layout qualifier.
   2257  *
   2258  *   Expect shader compilation error in following declaration:
   2259  *
   2260  *      layout(rgba32f, binding) uniform image2D s;
   2261  **/
   2262 class BindingImageInvalidTest : public NegativeTestBase
   2263 {
   2264 public:
   2265 	/* Public methods */
   2266 	BindingImageInvalidTest(deqp::Context&);
   2267 
   2268 	virtual ~BindingImageInvalidTest()
   2269 	{
   2270 	}
   2271 
   2272 protected:
   2273 	/* Methods to be implemented by child class */
   2274 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   2275 
   2276 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2277 									 Utils::shaderSource& out_source);
   2278 
   2279 private:
   2280 	/* Private enums */
   2281 	enum TESTCASES
   2282 	{
   2283 		NEGATIVE_VALUE,
   2284 		VARIABLE_NAME,
   2285 		STD140,
   2286 		MISSING,
   2287 
   2288 		/* */
   2289 		TEST_CASES_MAX
   2290 	};
   2291 
   2292 	/* Private methods */
   2293 	const glw::GLchar* getCaseString(TESTCASES test_case);
   2294 
   2295 	/* Provate variables */
   2296 	TESTCASES m_case;
   2297 };
   2298 
   2299 /** Test implementation, description follows:
   2300  *
   2301  * * Vectors initialized using curly brace initializer lists:
   2302  *
   2303  *   Test expressions like:
   2304  *       vec4 a = { 0.0, 1.0, 2.0, 3.0 };
   2305  *
   2306  *   Test all vector sizes.
   2307  *   Verify if all components were set correctly.
   2308  *
   2309  *
   2310  * * Matrices initialized using curly brace initializer lists:
   2311  *
   2312  *   Test expressions like:
   2313  *       mat2   a = {{ 0.0, 1.0 }, { 2.0, 3.0 }};
   2314  *       mat2x3 b = {{ 0.0, 1.0,  2.0 }, { 3.0, 4.0, 5.0 }};
   2315  *
   2316  *       Test all square matrix sizes. Check all non-square matrix sizes.
   2317  *
   2318  *       Verify if all components were set correctly.
   2319  *
   2320  *
   2321  * * Matrix rows initialized using curly brace initializer lists:
   2322  *
   2323  *   Test expressions like:
   2324  *       mat2   a = { vec2( 0.0, 1.0 ), vec2( 2.0, 3.0 ) };
   2325  *       mat2x3 b = {vec3( 0.0, 1.0, 2.0), vec3( 3.0, 4.0, 5.0 )};
   2326  *
   2327  *       Test all square matrix sizes. Check all non-square matrix sizes.
   2328  *
   2329  *       Verify if all components were set correctly.
   2330  *
   2331  *
   2332  * * Arrays initialized using curly brace initializer lists:
   2333  *
   2334  *   - Check arrays of scalars.
   2335  *
   2336  *   - Check arrays of vectors. Vectors initialized using *vec*(...) constructor.
   2337  *
   2338  *   - Check arrays of vectors. Vectors initialized initializer lists.
   2339  *
   2340  *   - Check arrays of matrices. Matrices initialized using *mat*(...) contructor.
   2341  *
   2342  *   - Check arrays of matrices. Matrices initialized initializer lists.
   2343  *
   2344  *   Verify if all components were set correctly.
   2345  *
   2346  *
   2347  * * Structures of transparent types initialized using initializer lists:
   2348  *
   2349  *   Check arrays of structures also.
   2350  *
   2351  *   Test expressions like:
   2352  *      struct S { float f; int i; uint u; }
   2353  *      S a = {1.0, 2, -3};
   2354  *      S b[3] = { S(1.0, 2, -3 ), { 3.0, 5, -6 }, { 7.0, 8, -9 } };
   2355  *      S c[3] = { { 1.0, 2, -3 }, { 3.0, 5, -6 }, { 7.0, 8, -9 } };
   2356  *
   2357  *   Verify if all components were set correctly.
   2358  *
   2359  *
   2360  * * Nested structures and arrays initialized using initializer lists:
   2361  *
   2362  *   - Check nested structures. Members initialized using <struct-type>(...)
   2363  *     constructor.
   2364  *
   2365  *   - Check nested structures. Members initialized using initializer lists.\
   2366          *
   2367  *   - Check nested structures with multiple nesting levels.
   2368  *
   2369  *   - Check structures of arrays of structures. Initialize all members using
   2370  *     initializer lists.
   2371  *
   2372  *   - Check structures of arrays of structures. Use mix of constructors and
   2373  *     initializer lists to initialize members.
   2374  *
   2375  *   - Check arrays of structures, containing structures. Initialize all
   2376  *     members using initializer lists.
   2377  *
   2378  *   - Check arrays of structures containing structures. Use mix of
   2379  *     constructors and initializer lists to initialize members.
   2380  *
   2381  *   - Check structures containing structures, that contain arrays.
   2382  *     Initialize all members using initializer lists.
   2383  *
   2384  *   - Check structures containing structures, that contain arrays. Use mix of
   2385  *     constructors and initializer lists to initialize members.
   2386  *
   2387  *   Verify if all components were set correctly.
   2388  *
   2389  *
   2390  * * Unsized arrays initialized with initialer lists:
   2391  *
   2392  *   Test expressions like:
   2393  *       int i[] = { 1, 2, 3 };
   2394  *       S b[] = { S(1.0, 2, -3 ), { 3.0, 5, -6 }, { 7.0, 8, -9 } };
   2395  *       S c[] = { { 1.0, 2, -3 }, { 3.0, 5, -6 }, { 7.0, 8, -9 } };
   2396  *
   2397  *   Verify if all components were set correctly.
   2398  **/
   2399 class InitializerListTest : public GLSLTestBase
   2400 {
   2401 public:
   2402 	/* Public methods */
   2403 	InitializerListTest(deqp::Context&);
   2404 
   2405 	virtual ~InitializerListTest()
   2406 	{
   2407 	}
   2408 
   2409 protected:
   2410 	/* Methods to be implemented by child class */
   2411 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   2412 
   2413 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2414 									 Utils::shaderSource& out_source);
   2415 
   2416 	virtual void prepareUniforms(Utils::program& program);
   2417 	virtual bool testInit();
   2418 
   2419 private:
   2420 	/* Private enums */
   2421 	enum TESTED_INITIALIZERS
   2422 	{
   2423 		VECTOR,
   2424 		MATRIX,
   2425 		MATRIX_ROWS,
   2426 		STRUCT,
   2427 		ARRAY_SCALAR,
   2428 		ARRAY_VECTOR_CTR,
   2429 		ARRAY_VECTOR_LIST,
   2430 		ARRAY_MATRIX_CTR,
   2431 		ARRAY_MATRIX_LIST,
   2432 		ARRAY_STRUCT,
   2433 		NESTED_STRUCT_CTR,
   2434 		NESTED_STRUCT_LIST,
   2435 		NESTED_STURCT_ARRAYS_STRUCT_LIST,
   2436 		NESTED_STURCT_ARRAYS_STRUCT_MIX,
   2437 		NESTED_ARRAY_STRUCT_STRUCT_LIST,
   2438 		NESTED_ARRAY_STRUCT_STRUCT_MIX,
   2439 		NESTED_STRUCT_STRUCT_ARRAY_LIST,
   2440 		NESTED_STRUCT_STRUCT_ARRAY_MIX,
   2441 		UNSIZED_ARRAY_SCALAR,
   2442 		UNSIZED_ARRAY_VECTOR,
   2443 		UNSIZED_ARRAY_MATRIX,
   2444 		UNSIZED_ARRAY_STRUCT,
   2445 
   2446 		/* */
   2447 		TESTED_INITIALIZERS_MAX
   2448 	};
   2449 
   2450 	/* Private types */
   2451 	struct testCase
   2452 	{
   2453 		TESTED_INITIALIZERS m_initializer;
   2454 
   2455 		glw::GLuint m_n_cols;
   2456 		glw::GLuint m_n_rows;
   2457 	};
   2458 
   2459 	/* Private methods */
   2460 	std::string getArrayDefinition();
   2461 	std::string getExpectedValue();
   2462 	std::string getInitialization();
   2463 	void		logTestCaseName();
   2464 	std::string getSum();
   2465 	std::string getTypeDefinition();
   2466 	std::string getTypeName();
   2467 
   2468 	std::string getVectorArrayCtr(glw::GLuint columns, glw::GLuint size);
   2469 
   2470 	std::string getVectorArrayList(glw::GLuint columns, glw::GLuint size);
   2471 
   2472 	std::string getVectorConstructor(glw::GLuint column, glw::GLuint size);
   2473 
   2474 	std::string getVectorInitializer(glw::GLuint column, glw::GLuint size);
   2475 
   2476 	std::string getVectorArraySum(const glw::GLchar* array_name, glw::GLuint columns, glw::GLuint size);
   2477 
   2478 	std::string getVectorSum(const glw::GLchar* vector_name, glw::GLuint size);
   2479 
   2480 	std::string getVectorValues(glw::GLuint column, glw::GLuint size);
   2481 
   2482 	/* Private variables */
   2483 	std::vector<testCase> m_test_cases;
   2484 	glw::GLint			  m_current_test_case_index;
   2485 
   2486 	/* Private constants */
   2487 	static const glw::GLfloat m_value;
   2488 };
   2489 
   2490 /** Test implementation, description follows:
   2491  *
   2492  * * Wrong type of component in initializer list.
   2493  *
   2494  *   Try to use wrong type of component. Expect compilation error. For example:
   2495  *
   2496  *       int a = { true };
   2497  *
   2498  *
   2499  * * Wrong number of components in initializer list.
   2500  *
   2501  *   Try to wrong number of components. Expect compilation error. For example:
   2502  *
   2503  *       vec4 a = { 0.0, 0.0, 0.0 };
   2504  *       vec3 a = { 0.0, 0.0, 0.0, 0.0 };
   2505  *
   2506  *
   2507  * * Wrong matrix sizes in initializer lists:
   2508  *
   2509  *   Try to use wrong matrix row size or column count. Expect compilation error.
   2510  *   For example:
   2511  *
   2512  *       mat2x3 b = {{ 0.0, 1.0,  2.0 }, { 3.0, 4.0}};
   2513  *       mat2x3 b = {{ 0.0, 1.0}, { 2.0, 3.0}, { 4.0, 5.0 }};
   2514  *       mat2x3 b = {{ 0.0, 1.0,  2.0 }, { 3.0, 4.0, 5.0 }};
   2515  *       mat2x3 b = {{ 0.0, 1.0,  2.0 }, { 3.0, 4.0, 5.0 }};
   2516  *
   2517  *
   2518  * * Initializer list inside constructor:
   2519  *   Try to use initializer list inside constructor. Expect compilation error.
   2520  *   For example:
   2521  *
   2522  *       struct S { vec2 v; };
   2523  *       S s = S( {1.0, 2.0 } );
   2524  *
   2525  *
   2526  * * Wrong struct layout in initializer list:
   2527  *   Try to initialize struct with bad initializer list layout.
   2528  *   Expect compilation error.
   2529  *
   2530  *   Check wrong member type, wrong member count and wrong member ordering.
   2531  **/
   2532 class InitializerListNegativeTest : public NegativeTestBase
   2533 {
   2534 public:
   2535 	/* Public methods */
   2536 	InitializerListNegativeTest(deqp::Context&);
   2537 
   2538 	virtual ~InitializerListNegativeTest()
   2539 	{
   2540 	}
   2541 
   2542 protected:
   2543 	/* Methods to be implemented by child class */
   2544 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   2545 
   2546 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2547 									 Utils::shaderSource& out_source);
   2548 
   2549 	virtual bool testInit();
   2550 
   2551 private:
   2552 	/* Private enums */
   2553 	enum TESTED_ERRORS
   2554 	{
   2555 		TYPE_UIVEC_BOOL,
   2556 		TYPE_IVEC_BOOL,
   2557 		TYPE_VEC_BOOL,
   2558 		TYPE_MAT_BOOL,
   2559 		COMPONENTS_VEC_LESS,
   2560 		COMPONENTS_VEC_MORE,
   2561 		COMPONENTS_MAT_LESS_ROWS,
   2562 		COMPONENTS_MAT_LESS_COLUMNS,
   2563 		COMPONENTS_MAT_MORE_ROWS,
   2564 		COMPONENTS_MAT_MORE_COLUMNS,
   2565 		LIST_IN_CONSTRUCTOR,
   2566 		STRUCT_LAYOUT_MEMBER_TYPE,
   2567 		STRUCT_LAYOUT_MEMBER_COUNT_MORE,
   2568 		STRUCT_LAYOUT_MEMBER_COUNT_LESS,
   2569 		STRUCT_LAYOUT_MEMBER_ORDER,
   2570 
   2571 		/* */
   2572 		TESTED_ERRORS_MAX
   2573 	};
   2574 
   2575 	/* Private methods */
   2576 	std::string getInitialization();
   2577 	void		logTestCaseName();
   2578 	std::string getSum();
   2579 	std::string getTypeDefinition();
   2580 	std::string getTypeName();
   2581 
   2582 	/* Private variables */
   2583 	std::vector<TESTED_ERRORS> m_test_cases;
   2584 	glw::GLint				   m_current_test_case_index;
   2585 };
   2586 
   2587 /** Test implementation, description follows:
   2588  *
   2589  * * Apply .length() to various types:
   2590  *
   2591  *   Check value returned by .length(), when applied to vectors of all types.
   2592  *   Check value returned by .length(), when applied to matrices of all types.
   2593  *
   2594  *   Check float, int and uint base types of vectors and matrices.
   2595  *   Check all vector sizes, check all matrix dimensions.
   2596  *
   2597  *   Also check value returned by .length() when applied to vector or matrix
   2598  *   members of a structures or interface blocks.
   2599  *
   2600  *
   2601  * * Constant folding of .length() expressions:
   2602  *
   2603  *   Use value of .length() to set array size. For example:
   2604  *
   2605  *       vec4 a;
   2606  *       float b[a.length()];
   2607  **/
   2608 class LengthOfVectorAndMatrixTest : public GLSLTestBase
   2609 {
   2610 public:
   2611 	/* Public methods */
   2612 	LengthOfVectorAndMatrixTest(deqp::Context&);
   2613 
   2614 	virtual ~LengthOfVectorAndMatrixTest()
   2615 	{
   2616 	}
   2617 
   2618 protected:
   2619 	/* Methods to be implemented by child class */
   2620 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   2621 
   2622 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2623 									 Utils::shaderSource& out_source);
   2624 
   2625 	virtual void prepareUniforms(Utils::program& program);
   2626 
   2627 	virtual void prepareVertexBuffer(const Utils::program& program, Utils::buffer& buffer, Utils::vertexArray& vao);
   2628 
   2629 	virtual bool testInit();
   2630 
   2631 private:
   2632 	/* Private types */
   2633 	struct testCase
   2634 	{
   2635 		Utils::TYPES m_type;
   2636 		glw::GLuint  m_n_cols;
   2637 		glw::GLuint  m_n_rows;
   2638 	};
   2639 
   2640 	/* Private methods */
   2641 	std::string getExpectedValue(Utils::SHADER_STAGES in_stage);
   2642 	std::string getInitialization();
   2643 
   2644 	std::string getMatrixInitializer(glw::GLuint n_cols, glw::GLuint n_rows);
   2645 
   2646 	std::string getVectorInitializer(Utils::TYPES type, glw::GLuint n_rows);
   2647 
   2648 	void prepareComputeShaderSource(Utils::shaderSource& out_source);
   2649 
   2650 	void prepareDrawShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2651 								 Utils::shaderSource& out_source);
   2652 
   2653 	glw::GLuint			  m_current_test_case_index;
   2654 	bool				  m_is_compute_program;
   2655 	std::vector<testCase> m_test_cases;
   2656 };
   2657 
   2658 /** Test implementation, description follows:
   2659  *
   2660  * * .length() called on compute type:
   2661  *
   2662  *   Check value returned by .length(), when applied to computed types:
   2663  *
   2664  *   - rows of matrices
   2665  *        mat4x3 a;
   2666  *        a[<variable>].length()
   2667  *
   2668  *   - computed types: matrix multiplication
   2669  *       mat4x2 a;
   2670  *       mat3x4 b;
   2671  *       (a * b).length()
   2672  *       (a * b)[<variable>].length()
   2673  *
   2674  *   - computed types: vector multiplication
   2675  *       vec3 a;
   2676  *       vec3 b;
   2677  *       (a * b).length()
   2678  *
   2679  *
   2680  * * Constant folding of .length() expressions using computed type.
   2681  *
   2682  *   Use value of .length() to set array size, when called on computed type.
   2683  *   For example:
   2684  *      mat4x2 a;
   2685  *      mat3x4 b;
   2686  *      float c[a(a * b).length()];
   2687  *      float d[(a * b)[<variable>].length()];
   2688  *
   2689  *
   2690  * * .length() called on build-in values.
   2691  *
   2692  *   Check value returned by .length when called on gl_Position,
   2693  *   gl_PointCoord, gl_SamplePosition
   2694  *
   2695  *
   2696  * * .length() called on build-in functions
   2697  *
   2698  *   Check value returned by .length() when called on values returned from
   2699  *   build in functions. For example:
   2700  *      outerProduct(vec4(0.0), vec3(0.0)).length()
   2701  **/
   2702 class LengthOfComputeResultTest : public GLSLTestBase
   2703 {
   2704 public:
   2705 	/* Public methods */
   2706 	LengthOfComputeResultTest(deqp::Context&);
   2707 
   2708 	virtual ~LengthOfComputeResultTest()
   2709 	{
   2710 	}
   2711 
   2712 protected:
   2713 	/* Methods to be implemented by child class */
   2714 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2715 									 Utils::shaderSource& out_source);
   2716 
   2717 	virtual void prepareUniforms(Utils::program& program);
   2718 };
   2719 
   2720 /** Test implementation, description follows:
   2721  *
   2722  * * All sizes of scalar swizzle
   2723  *
   2724  *   Test value returned by all sizes of scalar swizzlers: .x, .xx, .xxx and
   2725  *   .xxx, when called on a float variable.
   2726  *
   2727  * * Scalar swizzling of literals
   2728  *
   2729  *   Call scalar swizzler .xxx on literal, for example (0.0).xxx.
   2730  *
   2731  * * Scalar swizzling of constant expressions
   2732  *
   2733  *   Call scalar swizzler .xxx on constant, for example:
   2734  *
   2735  *       const float x = 0.0;
   2736  *       x.xxx
   2737  *
   2738  * * Mixed scalar swizzling
   2739  *
   2740  *   Check combinations of 'x', 'r', 's' swizzlers: .xx, .rr, .ss, .xrs
   2741  *
   2742  * * Nested swizzlers
   2743  *
   2744  *   Check nested swizzlers. For example:
   2745  *       const float x = 0.0;
   2746  *       x.r.s.x.ss
   2747  **/
   2748 class ScalarSwizzlersTest : public GLSLTestBase
   2749 {
   2750 public:
   2751 	/* Public methods */
   2752 	ScalarSwizzlersTest(deqp::Context&);
   2753 
   2754 	virtual ~ScalarSwizzlersTest()
   2755 	{
   2756 	}
   2757 
   2758 protected:
   2759 	/* Methods to be implemented by child class */
   2760 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2761 									 Utils::shaderSource& out_source);
   2762 
   2763 	virtual void prepareUniforms(Utils::program& program);
   2764 };
   2765 
   2766 /** Test implementation, description follows:
   2767  *
   2768  * * Wrong swizzlers for scalars:
   2769  *
   2770  *   Swizzlers not applicable for scalars like .z, .xz, .q should fail
   2771  *   shader compilation.
   2772  *
   2773  * * Wrong swizzlers:
   2774  *
   2775  *   Wrong swizzlers, like .u  should fail shader compilation.
   2776  *
   2777  * * Wrong syntax:
   2778  *
   2779  *   Literal swizzlers without parenthesis, like 1.x, should fail shader
   2780  *   compilation.
   2781  **/
   2782 class ScalarSwizzlersInvalidTest : public NegativeTestBase
   2783 {
   2784 public:
   2785 	/* Public methods */
   2786 	ScalarSwizzlersInvalidTest(deqp::Context&);
   2787 
   2788 	virtual ~ScalarSwizzlersInvalidTest()
   2789 	{
   2790 	}
   2791 
   2792 protected:
   2793 	/* Methods to be implemented by child class */
   2794 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   2795 
   2796 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2797 									 Utils::shaderSource& out_source);
   2798 
   2799 private:
   2800 	/* Private enums */
   2801 	enum TESTED_CASES
   2802 	{
   2803 		INVALID_Y,
   2804 		INVALID_B,
   2805 		INVALID_Q,
   2806 		INVALID_XY,
   2807 		INVALID_XRS,
   2808 		WRONG,
   2809 		MISSING_PARENTHESIS,
   2810 	};
   2811 
   2812 	TESTED_CASES m_case;
   2813 };
   2814 
   2815 /** Test implementation, description follows:
   2816  *
   2817  * * Value of gl_MinProgramTexelOffset:
   2818  *
   2819  *   Check that gl_MinProgramTexelOffset matches the value of
   2820  *   GL_MIN_PROGRAM_TEXEL_OFFSET from API.
   2821  *
   2822  *   Check that both values satisfy minimal requirement from OpenGL
   2823  *   specification.
   2824  *
   2825  * * Value of gl_MinProgramTexelOffset:
   2826  *
   2827  *   Check that gl_MinProgramTexelOffset matches the value of
   2828  *   GL_MAX_PROGRAM_TEXEL_OFFSET from API.
   2829  *
   2830  *   Check that both values satisfy minimal requirement from OpenGL
   2831  *   specification.
   2832  **/
   2833 class BuiltInValuesTest : public GLSLTestBase
   2834 {
   2835 public:
   2836 	/* Public methods */
   2837 	BuiltInValuesTest(deqp::Context&);
   2838 
   2839 	virtual ~BuiltInValuesTest()
   2840 	{
   2841 	}
   2842 
   2843 protected:
   2844 	/* Methods to be implemented by child class */
   2845 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2846 									 Utils::shaderSource& out_source);
   2847 
   2848 	virtual void prepareUniforms(Utils::program& program);
   2849 	virtual bool testInit();
   2850 
   2851 private:
   2852 	/* Private constants */
   2853 	static const glw::GLint m_min_program_texel_offset_limit;
   2854 	static const glw::GLint m_max_program_texel_offset_limit;
   2855 
   2856 	/* Private variables */
   2857 	glw::GLint m_min_program_texel_offset;
   2858 	glw::GLint m_max_program_texel_offset;
   2859 };
   2860 
   2861 /** Test implementation, description follows:
   2862  *
   2863  **/
   2864 class BuiltInAssignmentTest : public NegativeTestBase
   2865 {
   2866 public:
   2867 	/* Public methods */
   2868 	BuiltInAssignmentTest(deqp::Context&);
   2869 
   2870 	virtual ~BuiltInAssignmentTest()
   2871 	{
   2872 	}
   2873 
   2874 protected:
   2875 	/* Methods to be implemented by child class */
   2876 	virtual bool prepareNextTestCase(glw::GLuint test_case_index);
   2877 
   2878 	virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400,
   2879 									 Utils::shaderSource& out_source);
   2880 
   2881 private:
   2882 	/* Private variables */
   2883 	glw::GLuint m_case;
   2884 };
   2885 } /* GLSL420Pack namespace */
   2886 
   2887 /** Group class for Shader Language 420Pack conformance tests */
   2888 class ShadingLanguage420PackTests : public deqp::TestCaseGroup
   2889 {
   2890 public:
   2891 	/* Public methods */
   2892 	ShadingLanguage420PackTests(deqp::Context& context);
   2893 
   2894 	virtual ~ShadingLanguage420PackTests(void)
   2895 	{
   2896 	}
   2897 
   2898 	virtual void init(void);
   2899 
   2900 private:
   2901 	/* Private methods */
   2902 	ShadingLanguage420PackTests(const ShadingLanguage420PackTests& other);
   2903 	ShadingLanguage420PackTests& operator=(const ShadingLanguage420PackTests& other);
   2904 };
   2905 
   2906 } // gl4cts
   2907 
   2908 #endif // _GL4CSHADINGLANGUAGE420PACKTESTS_HPP
   2909