Home | History | Annotate | Download | only in gl
      1 #ifndef _GL4CENHANCEDLAYOUTSTESTS_HPP
      2 #define _GL4CENHANCEDLAYOUTSTESTS_HPP
      3 /*-------------------------------------------------------------------------
      4  * OpenGL Conformance Test Suite
      5  * -----------------------------
      6  *
      7  * Copyright (c) 2015-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  gl4cEnhancedLayoutsTests.hpp
     28  * \brief Declares test classes for "Enhanced Layouts" 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 EnhancedLayouts
     43 {
     44 namespace Utils
     45 {
     46 /** Represents data type
     47  *
     48  **/
     49 struct Type
     50 {
     51 public:
     52 	enum TYPES
     53 	{
     54 		Float,
     55 		Double,
     56 		Int,
     57 		Uint,
     58 	};
     59 
     60 	/* Public methods */
     61 	/* Functionality */
     62 	std::vector<glw::GLubyte> GenerateData() const;
     63 	std::vector<glw::GLubyte> GenerateDataPacked() const;
     64 	glw::GLuint GetActualAlignment(glw::GLuint align, bool is_array) const;
     65 	glw::GLuint GetBaseAlignment(bool is_array) const;
     66 	std::string GetGLSLConstructor(const glw::GLvoid* data) const;
     67 	const glw::GLchar* GetGLSLTypeName() const;
     68 	glw::GLuint GetLocations(bool is_vs_input = false) const;
     69 	glw::GLuint GetSize(const bool is_std140 = false) const;
     70 	glw::GLenum GetTypeGLenum() const;
     71 	glw::GLuint GetNumComponents() const;
     72 
     73 	/* Public static routines */
     74 	/* Functionality */
     75 	static glw::GLuint CalculateStd140Stride(glw::GLuint alignment, glw::GLuint n_columns,
     76 											 glw::GLuint n_array_elements);
     77 
     78 	static bool DoesTypeSupportMatrix(TYPES type);
     79 
     80 	static glw::GLuint GetActualOffset(glw::GLuint start_offset, glw::GLuint actual_alignment);
     81 
     82 	static Type GetType(TYPES basic_type, glw::GLuint n_columns, glw::GLuint n_rows);
     83 
     84 	static glw::GLuint GetTypeSize(TYPES type);
     85 
     86 	/* GL gets */
     87 	static glw::GLenum GetTypeGLenum(TYPES type);
     88 
     89 	/* Public fields */
     90 	TYPES		m_basic_type;
     91 	glw::GLuint m_n_columns;
     92 	glw::GLuint m_n_rows;
     93 
     94 	/* Public constants */
     95 	static const Type _double;
     96 	static const Type dmat2;
     97 	static const Type dmat2x3;
     98 	static const Type dmat2x4;
     99 	static const Type dmat3x2;
    100 	static const Type dmat3;
    101 	static const Type dmat3x4;
    102 	static const Type dmat4x2;
    103 	static const Type dmat4x3;
    104 	static const Type dmat4;
    105 	static const Type dvec2;
    106 	static const Type dvec3;
    107 	static const Type dvec4;
    108 	static const Type _float;
    109 	static const Type _int;
    110 	static const Type ivec2;
    111 	static const Type ivec3;
    112 	static const Type ivec4;
    113 	static const Type mat2;
    114 	static const Type mat2x3;
    115 	static const Type mat2x4;
    116 	static const Type mat3x2;
    117 	static const Type mat3;
    118 	static const Type mat3x4;
    119 	static const Type mat4x2;
    120 	static const Type mat4x3;
    121 	static const Type mat4;
    122 	static const Type vec2;
    123 	static const Type vec3;
    124 	static const Type vec4;
    125 	static const Type uint;
    126 	static const Type uvec2;
    127 	static const Type uvec3;
    128 	static const Type uvec4;
    129 };
    130 
    131 /** Represents buffer instance
    132  * Provides basic buffer functionality
    133  **/
    134 class Buffer
    135 {
    136 public:
    137 	/* Public enums */
    138 	enum BUFFERS
    139 	{
    140 		Array,
    141 		Element,
    142 		Shader_Storage,
    143 		Texture,
    144 		Transform_feedback,
    145 		Uniform,
    146 	};
    147 
    148 	enum USAGE
    149 	{
    150 		DynamicCopy,
    151 		DynamicDraw,
    152 		DynamicRead,
    153 		StaticCopy,
    154 		StaticDraw,
    155 		StaticRead,
    156 		StreamCopy,
    157 		StreamDraw,
    158 		StreamRead,
    159 	};
    160 
    161 	enum ACCESS
    162 	{
    163 		ReadOnly,
    164 		WriteOnly,
    165 		ReadWrite,
    166 	};
    167 
    168 	/* Public methods */
    169 	/* Ctr & Dtr */
    170 	Buffer(deqp::Context& context);
    171 	~Buffer();
    172 
    173 	/* Init & Release */
    174 	void Init(BUFFERS buffer, USAGE usage, glw::GLsizeiptr size, glw::GLvoid* data);
    175 	void Release();
    176 
    177 	/* Functionality */
    178 	void Bind() const;
    179 	void BindBase(glw::GLuint index) const;
    180 
    181 	void BindRange(glw::GLuint index, glw::GLintptr offset, glw::GLsizeiptr size) const;
    182 
    183 	void Data(USAGE usage, glw::GLsizeiptr size, glw::GLvoid* data);
    184 
    185 	glw::GLvoid* Map(ACCESS access);
    186 
    187 	void SubData(glw::GLintptr offset, glw::GLsizeiptr size, glw::GLvoid* data);
    188 
    189 	void UnMap();
    190 
    191 	/* Public static routines */
    192 	/* Functionality */
    193 	static void Bind(const glw::Functions& gl, glw::GLuint id, BUFFERS buffer);
    194 
    195 	static void BindBase(const glw::Functions& gl, glw::GLuint id, BUFFERS buffer, glw::GLuint index);
    196 
    197 	static void BindRange(const glw::Functions& gl, glw::GLuint id, BUFFERS buffer, glw::GLuint index,
    198 						  glw::GLintptr offset, glw::GLsizeiptr size);
    199 
    200 	static void Data(const glw::Functions& gl, BUFFERS buffer, USAGE usage, glw::GLsizeiptr size, glw::GLvoid* data);
    201 
    202 	static void Generate(const glw::Functions& gl, glw::GLuint& out_id);
    203 
    204 	static void* Map(const glw::Functions& gl, BUFFERS buffer, ACCESS access);
    205 
    206 	static void SubData(const glw::Functions& gl, BUFFERS buffer, glw::GLintptr offset, glw::GLsizeiptr size,
    207 						glw::GLvoid* data);
    208 
    209 	static void UnMap(const glw::Functions& gl, BUFFERS buffer);
    210 
    211 	/* GL gets */
    212 	static glw::GLenum GetAccessGLenum(ACCESS access);
    213 	static glw::GLenum GetBufferGLenum(BUFFERS buffer);
    214 	static glw::GLenum GetUsageGLenum(USAGE usage);
    215 
    216 	/* Gets */
    217 	static const glw::GLchar* GetBufferName(BUFFERS buffer);
    218 
    219 	/* Public fields */
    220 	glw::GLuint m_id;
    221 
    222 	/* Public constants */
    223 	static const glw::GLuint m_invalid_id;
    224 
    225 	/* Buffer type maybe changed for different cases*/
    226 	BUFFERS m_buffer;
    227 
    228 private:
    229 	/* Private fields */
    230 	deqp::Context& m_context;
    231 };
    232 
    233 /** Represents framebuffer
    234  * Provides basic functionality
    235  **/
    236 class Framebuffer
    237 {
    238 public:
    239 	/* Public methods */
    240 	/* Ctr & Dtr */
    241 	Framebuffer(deqp::Context& context);
    242 	~Framebuffer();
    243 
    244 	/* Init & Release */
    245 	void Init();
    246 	void Release();
    247 
    248 	/* Functionality */
    249 	void AttachTexture(glw::GLenum attachment, glw::GLuint texture_id, glw::GLuint width, glw::GLuint height);
    250 
    251 	void Bind();
    252 	void Clear(glw::GLenum mask);
    253 
    254 	void ClearColor(glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue, glw::GLfloat alpha);
    255 
    256 	/* Public static routines */
    257 	static void AttachTexture(const glw::Functions& gl, glw::GLenum attachment, glw::GLuint texture_id,
    258 							  glw::GLuint width, glw::GLuint height);
    259 
    260 	static void Bind(const glw::Functions& gl, glw::GLuint id);
    261 
    262 	static void Clear(const glw::Functions& gl, glw::GLenum mask);
    263 
    264 	static void ClearColor(const glw::Functions& gl, glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue,
    265 						   glw::GLfloat alpha);
    266 
    267 	static void Generate(const glw::Functions& gl, glw::GLuint& out_id);
    268 
    269 	/* Public fields */
    270 	glw::GLuint m_id;
    271 
    272 	/* Public constants */
    273 	static const glw::GLuint m_invalid_id;
    274 
    275 private:
    276 	/* Private fields */
    277 	deqp::Context& m_context;
    278 };
    279 
    280 /** Represents shader instance.
    281  * Provides basic functionality for shaders.
    282  **/
    283 class Shader
    284 {
    285 public:
    286 	/* Public enums */
    287 	enum STAGES
    288 	{
    289 		COMPUTE = 0,
    290 		VERTEX,
    291 		TESS_CTRL,
    292 		TESS_EVAL,
    293 		GEOMETRY,
    294 		FRAGMENT,
    295 
    296 		/* */
    297 		STAGE_MAX
    298 	};
    299 
    300 	/* Public types */
    301 
    302 	class InvalidSourceException : public std::exception
    303 	{
    304 	public:
    305 		InvalidSourceException(const glw::GLchar* error_message, const std::string& source, STAGES stage);
    306 
    307 		virtual ~InvalidSourceException() throw()
    308 		{
    309 		}
    310 
    311 		virtual const char* what() const throw();
    312 
    313 		void log(deqp::Context& context) const;
    314 
    315 		std::string m_message;
    316 		std::string m_source;
    317 		STAGES		m_stage;
    318 	};
    319 
    320 	/* Public methods */
    321 	/* Ctr & Dtr */
    322 	Shader(deqp::Context& context);
    323 	~Shader();
    324 
    325 	/* Init & Realese */
    326 	void Init(STAGES stage, const std::string& source);
    327 	void Release();
    328 
    329 	/* Public static routines */
    330 	/* Functionality */
    331 	static void Compile(const glw::Functions& gl, glw::GLuint id);
    332 
    333 	static void Create(const glw::Functions& gl, STAGES stage, glw::GLuint& out_id);
    334 
    335 	static void Source(const glw::Functions& gl, glw::GLuint id, const std::string& source);
    336 
    337 	/* GL gets */
    338 	static glw::GLenum GetShaderStageGLenum(STAGES stage);
    339 
    340 	/* Get stage name */
    341 	static const glw::GLchar* GetStageName(STAGES stage);
    342 
    343 	/* Logs sources */
    344 	static void LogSource(deqp::Context& context, const std::string& source, STAGES stage);
    345 
    346 	/* Public fields */
    347 	glw::GLuint m_id;
    348 
    349 	/* Public constants */
    350 	static const glw::GLuint m_invalid_id;
    351 
    352 private:
    353 	/* Private types */
    354 	class CompilationException : public std::exception
    355 	{
    356 	public:
    357 		CompilationException(const glw::GLchar* message);
    358 
    359 		virtual ~CompilationException() throw()
    360 		{
    361 		}
    362 
    363 		virtual const char* what() const throw();
    364 
    365 		std::string m_message;
    366 	};
    367 
    368 	/* Private fields */
    369 	deqp::Context& m_context;
    370 };
    371 
    372 /* Forward declaration */
    373 struct Interface;
    374 
    375 /** Represents GLSL variable
    376  *
    377  **/
    378 struct Variable
    379 {
    380 public:
    381 	/* Typedefs */
    382 	typedef std::vector<Variable>  Vector;
    383 	typedef std::vector<Variable*> PtrVector;
    384 
    385 	/* Enums */
    386 	enum STORAGE
    387 	{
    388 		VARYING_INPUT,
    389 		VARYING_OUTPUT,
    390 		UNIFORM,
    391 		SSB,
    392 		MEMBER,
    393 
    394 		/* */
    395 		STORAGE_MAX
    396 	};
    397 
    398 	enum VARYING_DIRECTION
    399 	{
    400 		INPUT,
    401 		OUTPUT,
    402 	};
    403 
    404 	enum FLAVOUR
    405 	{
    406 		BASIC,
    407 		ARRAY,
    408 		INDEXED_BY_INVOCATION_ID,
    409 	};
    410 
    411 	/**/
    412 	enum TYPE
    413 	{
    414 		BUILTIN,
    415 		INTERFACE,
    416 	};
    417 
    418 	/* Types */
    419 	struct Descriptor
    420 	{
    421 		/* */
    422 		typedef std::vector<Descriptor> Vector;
    423 
    424 		/* */
    425 		Descriptor(const glw::GLchar* name, const glw::GLchar* qualifiers, glw::GLint expected_component,
    426 				   glw::GLint expected_location, const Type& type, glw::GLboolean normalized,
    427 				   glw::GLuint n_array_elements, glw::GLint expected_stride_of_element, glw::GLuint offset);
    428 
    429 		Descriptor(const glw::GLchar* name, const glw::GLchar* qualifiers, glw::GLint expected_componenet,
    430 				   glw::GLint expected_location, Interface* interface, glw::GLuint n_array_elements,
    431 				   glw::GLint expected_stride_of_element, glw::GLuint offset);
    432 
    433 		/* */
    434 		std::string GetDefinition(FLAVOUR flavour, STORAGE storage) const;
    435 
    436 		/* */
    437 		glw::GLint	 m_expected_component;
    438 		glw::GLint	 m_expected_location;
    439 		glw::GLint	 m_expected_stride_of_element;
    440 		glw::GLuint	m_n_array_elements;
    441 		std::string	m_name;
    442 		glw::GLboolean m_normalized;
    443 		glw::GLuint	m_offset;
    444 		std::string	m_qualifiers;
    445 
    446 		TYPE m_type;
    447 		union {
    448 			Type	   m_builtin;
    449 			Interface* m_interface;
    450 		};
    451 	};
    452 
    453 	/* Constructors */
    454 	template <typename T>
    455 	Variable(const glw::GLchar* name, const glw::GLchar* qualifiers, glw::GLint expected_component,
    456 			 glw::GLint expected_location, const Type& type, glw::GLboolean normalized, glw::GLuint n_array_elements,
    457 			 glw::GLint expected_stride_of_element, glw::GLuint offset, const T* data, size_t data_size,
    458 			 STORAGE storage)
    459 		: m_data((glw::GLvoid*)data)
    460 		, m_data_size(data_size)
    461 		, m_descriptor(name, qualifiers, expected_component, expected_location, type, normalized, n_array_elements,
    462 					   expected_stride_of_element, offset)
    463 		, m_storage(storage)
    464 	{
    465 	}
    466 
    467 	template <typename T>
    468 	Variable(const glw::GLchar* name, const glw::GLchar* qualifiers, glw::GLint expected_component,
    469 			 glw::GLint expected_location, Interface* interface, glw::GLuint n_array_elements,
    470 			 glw::GLint expected_stride_of_element, glw::GLuint offset, const T* data, size_t data_size,
    471 			 STORAGE storage)
    472 		: m_data((glw::GLvoid*)data)
    473 		, m_data_size(data_size)
    474 		, m_descriptor(name, qualifiers, expected_component, expected_location, interface, n_array_elements,
    475 					   expected_stride_of_element, offset)
    476 		, m_storage(storage)
    477 	{
    478 	}
    479 
    480 	Variable(const Variable& var);
    481 
    482 	/* Functionality */
    483 	std::string GetDefinition(FLAVOUR flavour) const;
    484 	glw::GLuint GetSize() const;
    485 	glw::GLuint GetStride() const;
    486 	bool		IsBlock() const;
    487 	bool		IsStruct() const;
    488 	/* Static routines */
    489 	static FLAVOUR GetFlavour(Shader::STAGES stage, VARYING_DIRECTION direction);
    490 	static std::string GetReference(const std::string& parent_name, const Descriptor& variable, FLAVOUR flavour,
    491 									glw::GLuint array_index);
    492 
    493 	/* Fields */
    494 	glw::GLvoid* m_data;
    495 	size_t		 m_data_size;
    496 	Descriptor   m_descriptor;
    497 	STORAGE		 m_storage;
    498 
    499 	/* Constants */
    500 	static const glw::GLint m_automatic_location;
    501 };
    502 
    503 /* Define the methods NAME, that will add new variable to VECTOR with STORAGE set		*/
    504 #define DEFINE_VARIABLE_CLASS(NAME, STORAGE, VECTOR)                                                                  \
    505 	template <typename T>                                                                                             \
    506 	Variable* NAME(const glw::GLchar* name, const glw::GLchar* qualifiers, glw::GLint expected_component,             \
    507 				   glw::GLint expected_location, const Type& type, glw::GLboolean normalized,                         \
    508 				   glw::GLuint n_array_elements, glw::GLint expected_stride_of_element, glw::GLuint offset,           \
    509 				   const T* data, size_t data_size)                                                                   \
    510 	{                                                                                                                 \
    511 		Variable* var = new Variable(name, qualifiers, expected_component, expected_location, type, normalized,       \
    512 									 n_array_elements, expected_stride_of_element, offset, data, data_size, STORAGE); \
    513 		if (0 == var)                                                                                                 \
    514 		{                                                                                                             \
    515 			TCU_FAIL("Memory allocation");                                                                            \
    516 		}                                                                                                             \
    517 		VECTOR.push_back(var);                                                                                        \
    518 		return VECTOR.back();                                                                                         \
    519 	}                                                                                                                 \
    520                                                                                                                       \
    521 	template <typename T>                                                                                             \
    522 	Variable* NAME(const glw::GLchar* name, const glw::GLchar* qualifiers, glw::GLint expected_component,             \
    523 				   glw::GLint expected_location, Interface* interface, glw::GLuint n_array_elements,                  \
    524 				   glw::GLint expected_stride_of_element, glw::GLuint offset, const T* data, size_t data_size)        \
    525 	{                                                                                                                 \
    526 		Variable* var = new Variable(name, qualifiers, expected_component, expected_location, interface,              \
    527 									 n_array_elements, expected_stride_of_element, offset, data, data_size, STORAGE); \
    528 		if (0 == var)                                                                                                 \
    529 		{                                                                                                             \
    530 			TCU_FAIL("Memory allocation");                                                                            \
    531 		}                                                                                                             \
    532 		VECTOR.push_back(var);                                                                                        \
    533 		return VECTOR.back();                                                                                         \
    534 	}
    535 
    536 /** Represents structures and block
    537  *
    538  **/
    539 struct Interface
    540 {
    541 public:
    542 	/* Typedefs */
    543 	typedef std::vector<Interface>  Vector;
    544 	typedef std::vector<Interface*> PtrVector;
    545 
    546 	/**/
    547 	enum TYPE
    548 	{
    549 		STRUCT,
    550 		BLOCK
    551 	};
    552 
    553 	/* Constructor */
    554 	Interface(const glw::GLchar* name, TYPE type);
    555 
    556 	/*  */
    557 	Variable::Descriptor* Member(const glw::GLchar* name, const glw::GLchar* qualifiers, glw::GLint expected_component,
    558 								 glw::GLint expected_location, const Type& type, glw::GLboolean normalized,
    559 								 glw::GLuint n_array_elements, glw::GLint expected_stride_of_element,
    560 								 glw::GLuint offset);
    561 	Variable::Descriptor* Member(const glw::GLchar* name, const glw::GLchar* qualifiers, glw::GLint expected_component,
    562 								 glw::GLint expected_location, Interface* interface, glw::GLuint n_array_elements,
    563 								 glw::GLint expected_stride_of_element, glw::GLuint offset);
    564 
    565 	/**/
    566 	Variable::Descriptor* AddMember(const Variable::Descriptor& member);
    567 
    568 	std::string GetDefinition() const;
    569 
    570 	/**/
    571 	Variable::Descriptor::Vector m_members;
    572 	std::string					 m_name;
    573 	TYPE						 m_type;
    574 };
    575 
    576 struct ShaderInterface
    577 {
    578 	ShaderInterface(Shader::STAGES stage);
    579 
    580 	DEFINE_VARIABLE_CLASS(Input, Variable::VARYING_INPUT, m_inputs);
    581 	DEFINE_VARIABLE_CLASS(Output, Variable::VARYING_OUTPUT, m_outputs);
    582 	DEFINE_VARIABLE_CLASS(Uniform, Variable::UNIFORM, m_uniforms);
    583 	DEFINE_VARIABLE_CLASS(SSB, Variable::SSB, m_ssb_blocks);
    584 
    585 	/**/
    586 	std::string GetDefinitionsGlobals() const;
    587 	std::string GetDefinitionsInputs() const;
    588 	std::string GetDefinitionsOutputs() const;
    589 	std::string GetDefinitionsSSBs() const;
    590 	std::string GetDefinitionsUniforms() const;
    591 
    592 	std::string			m_globals;
    593 	Variable::PtrVector m_inputs;
    594 	Variable::PtrVector m_outputs;
    595 	Variable::PtrVector m_uniforms;
    596 	Variable::PtrVector m_ssb_blocks;
    597 
    598 	Shader::STAGES m_stage;
    599 };
    600 
    601 struct VaryingConnection
    602 {
    603 	/* */
    604 	typedef std::vector<VaryingConnection> Vector;
    605 
    606 	/* */
    607 	VaryingConnection(Variable* in, Variable* out);
    608 
    609 	/* */
    610 	Variable* m_in;
    611 	Variable* m_out;
    612 };
    613 
    614 struct VaryingPassthrough
    615 {
    616 	/* */
    617 	void Add(Shader::STAGES stage, Variable* in, Variable* out);
    618 
    619 	VaryingConnection::Vector& Get(Shader::STAGES stage);
    620 
    621 	/**/
    622 	VaryingConnection::Vector m_fragment;
    623 	VaryingConnection::Vector m_geometry;
    624 	VaryingConnection::Vector m_tess_ctrl;
    625 	VaryingConnection::Vector m_tess_eval;
    626 	VaryingConnection::Vector m_vertex;
    627 };
    628 
    629 struct ProgramInterface
    630 {
    631 
    632 	/* */
    633 	ProgramInterface();
    634 	~ProgramInterface();
    635 
    636 	/* */
    637 	Interface* AddInterface(const glw::GLchar* name, Interface::TYPE type);
    638 	Interface* Block(const glw::GLchar* name);
    639 	Interface* GetBlock(const glw::GLchar* name);
    640 	ShaderInterface& GetShaderInterface(Shader::STAGES stage);
    641 	const ShaderInterface& GetShaderInterface(Shader::STAGES stage) const;
    642 	Interface* GetStructure(const glw::GLchar* name);
    643 	Interface* Structure(const glw::GLchar* name);
    644 
    645 	/**/
    646 	std::string GetDefinitionsStructures() const;
    647 	std::string GetInterfaceForStage(Shader::STAGES stage) const;
    648 
    649 	/* */
    650 	Interface* CloneBlockForStage(const Interface& block, Shader::STAGES stage, Variable::STORAGE storage,
    651 								  const glw::GLchar* prefix);
    652 	void CloneVertexInterface(VaryingPassthrough& variable_pass);
    653 
    654 	/* */
    655 	static const glw::GLchar* GetStagePrefix(Shader::STAGES stage, Variable::STORAGE storage);
    656 
    657 	/* */
    658 	Interface::PtrVector m_structures;
    659 	Interface::PtrVector m_blocks;
    660 
    661 	ShaderInterface m_compute;
    662 	ShaderInterface m_vertex;
    663 	ShaderInterface m_tess_ctrl;
    664 	ShaderInterface m_tess_eval;
    665 	ShaderInterface m_geometry;
    666 	ShaderInterface m_fragment;
    667 
    668 	//Variable::Vector     m_fragment_outputs;
    669 	//Variable::PtrVector  m_captured_varyings;
    670 
    671 private:
    672 	/* */
    673 	void cloneVariableForStage(const Variable& variable, Shader::STAGES stage, const glw::GLchar* prefix,
    674 							   VaryingPassthrough& varying_passthrough);
    675 	Variable* cloneVariableForStage(const Variable& variable, Shader::STAGES stage, Variable::STORAGE storage,
    676 									const glw::GLchar* prefix);
    677 	void replaceBinding(Variable& variable, Shader::STAGES stage);
    678 };
    679 
    680 /** Represents program pipeline
    681  *
    682  **/
    683 class Pipeline
    684 {
    685 public:
    686 	/* Public methods */
    687 	/* Ctr & Dtr */
    688 	Pipeline(deqp::Context& context);
    689 	~Pipeline();
    690 
    691 	/* Init & Release */
    692 	void Init();
    693 	void Release();
    694 
    695 	/* Functionality */
    696 	void Bind();
    697 	void UseProgramStages(glw::GLuint program_id, glw::GLenum stages);
    698 
    699 	/* Public static routines */
    700 	/* Functionality */
    701 	void Bind(const glw::Functions& gl, glw::GLuint id);
    702 	void UseProgramStages(const glw::Functions& gl, glw::GLuint id, glw::GLuint program_id, glw::GLenum stages);
    703 
    704 	/* Public fields */
    705 	glw::GLuint m_id;
    706 
    707 	/* Public constants */
    708 	static const glw::GLuint m_invalid_id;
    709 
    710 private:
    711 	/* Private fields */
    712 	deqp::Context& m_context;
    713 };
    714 
    715 /** Represents program instance.
    716  * Provides basic functionality
    717  **/
    718 class Program
    719 {
    720 public:
    721 	/* Public types */
    722 	class BuildException : public std::exception
    723 	{
    724 	public:
    725 		BuildException(const glw::GLchar* error_message, const std::string compute_shader,
    726 					   const std::string fragment_shader, const std::string geometry_shader,
    727 					   const std::string tess_ctrl_shader, const std::string tess_eval_shader,
    728 					   const std::string vertex_shader);
    729 		virtual ~BuildException() throw()
    730 		{
    731 		}
    732 
    733 		virtual const char* what() const throw();
    734 
    735 		void log(deqp::Context& context) const;
    736 
    737 		std::string m_error_message;
    738 		std::string m_compute_shader;
    739 		std::string m_fragment_shader;
    740 		std::string m_geometry_shader;
    741 		std::string m_tess_ctrl_shader;
    742 		std::string m_tess_eval_shader;
    743 		std::string m_vertex_shader;
    744 	};
    745 
    746 	typedef std::vector<std::string> NameVector;
    747 
    748 	/* Public methods */
    749 	/* Ctr & Dtr */
    750 	Program(deqp::Context& context);
    751 	~Program();
    752 
    753 	/* Init & Release */
    754 	void Init(const std::string& compute_shader, const std::string& fragment_shader, const std::string& geometry_shader,
    755 			  const std::string& tessellation_control_shader, const std::string& tessellation_evaluation_shader,
    756 			  const std::string& vertex_shader, const NameVector& captured_varyings, bool capture_interleaved,
    757 			  bool is_separable);
    758 
    759 	void Init(const std::string& compute_shader, const std::string& fragment_shader, const std::string& geometry_shader,
    760 			  const std::string& tessellation_control_shader, const std::string& tessellation_evaluation_shader,
    761 			  const std::string& vertex_shader, bool is_separable);
    762 
    763 	void Release();
    764 
    765 	/* Functionality */
    766 	void GetActiveUniformsiv(glw::GLsizei count, const glw::GLuint* indices, glw::GLenum pname,
    767 							 glw::GLint* params) const;
    768 
    769 	glw::GLint GetAttribLocation(const std::string& name) const;
    770 
    771 	void GetResource(glw::GLenum interface, glw::GLuint index, glw::GLenum property, glw::GLsizei buf_size,
    772 					 glw::GLint* params) const;
    773 
    774 	glw::GLuint GetResourceIndex(const std::string& name, glw::GLenum interface) const;
    775 
    776 	void GetUniformIndices(glw::GLsizei count, const glw::GLchar** names, glw::GLuint* indices) const;
    777 
    778 	glw::GLint GetUniformLocation(const std::string& name) const;
    779 	void Use() const;
    780 
    781 	/* Public static routines */
    782 	/* Functionality */
    783 	static void Attach(const glw::Functions& gl, glw::GLuint program_id, glw::GLuint shader_id);
    784 
    785 	static void Capture(const glw::Functions& gl, glw::GLuint id, const NameVector& captured_varyings,
    786 						bool capture_interleaved);
    787 
    788 	static void Create(const glw::Functions& gl, glw::GLuint& out_id);
    789 
    790 	static void GetActiveUniformsiv(const glw::Functions& gl, glw::GLuint program_id, glw::GLsizei count,
    791 									const glw::GLuint* indices, glw::GLenum pname, glw::GLint* params);
    792 
    793 	static void GetUniformIndices(const glw::Functions& gl, glw::GLuint program_id, glw::GLsizei count,
    794 								  const glw::GLchar** names, glw::GLuint* indices);
    795 
    796 	static void Link(const glw::Functions& gl, glw::GLuint id);
    797 
    798 	static void Uniform(const glw::Functions& gl, const Type& type, glw::GLsizei count, glw::GLint location,
    799 						const glw::GLvoid* data);
    800 
    801 	static void Use(const glw::Functions& gl, glw::GLuint id);
    802 
    803 	/* Get locations */
    804 	static glw::GLint GetAttribLocation(const glw::Functions& gl, glw::GLuint id, const std::string& name);
    805 
    806 	static void GetResource(const glw::Functions& gl, glw::GLuint id, glw::GLenum interface, glw::GLuint index,
    807 							glw::GLenum property, glw::GLsizei buf_size, glw::GLint* params);
    808 
    809 	static glw::GLuint GetResourceIndex(const glw::Functions& gl, glw::GLuint id, const std::string& name,
    810 										glw::GLenum interface);
    811 
    812 	static glw::GLint GetUniformLocation(const glw::Functions& gl, glw::GLuint id, const std::string& name);
    813 
    814 	/* Public fields */
    815 	glw::GLuint m_id;
    816 
    817 	Shader m_compute;
    818 	Shader m_fragment;
    819 	Shader m_geometry;
    820 	Shader m_tess_ctrl;
    821 	Shader m_tess_eval;
    822 	Shader m_vertex;
    823 
    824 	/* Public constants */
    825 	static const glw::GLuint m_invalid_id;
    826 
    827 private:
    828 	/* Private types */
    829 	class LinkageException : public std::exception
    830 	{
    831 	public:
    832 		LinkageException(const glw::GLchar* error_message);
    833 
    834 		virtual ~LinkageException() throw()
    835 		{
    836 		}
    837 
    838 		virtual const char* what() const throw();
    839 
    840 		std::string m_error_message;
    841 	};
    842 
    843 	/* Private fields */
    844 	deqp::Context& m_context;
    845 };
    846 
    847 class Texture
    848 {
    849 public:
    850 	/* Public enums */
    851 	enum TYPES
    852 	{
    853 		TEX_BUFFER,
    854 		TEX_2D,
    855 		TEX_2D_RECT,
    856 		TEX_2D_ARRAY,
    857 		TEX_3D,
    858 		TEX_CUBE,
    859 		TEX_1D,
    860 		TEX_1D_ARRAY,
    861 	};
    862 
    863 	/* Public methods */
    864 	/* Ctr & Dtr */
    865 	Texture(deqp::Context& context);
    866 	~Texture();
    867 
    868 	/* Init & Release */
    869 	void Init(TYPES tex_type, glw::GLuint width, glw::GLuint height, glw::GLuint depth, glw::GLenum internal_format,
    870 			  glw::GLenum format, glw::GLenum type, glw::GLvoid* data);
    871 
    872 	void Init(glw::GLenum internal_format, glw::GLuint buffer_id);
    873 
    874 	void Release();
    875 
    876 	/* Functionality */
    877 	void Bind() const;
    878 	void Get(glw::GLenum format, glw::GLenum type, glw::GLvoid* out_data) const;
    879 
    880 	/* Public static routines */
    881 	/* Functionality */
    882 	static void Bind(const glw::Functions& gl, glw::GLuint id, TYPES tex_type);
    883 
    884 	static void Generate(const glw::Functions& gl, glw::GLuint& out_id);
    885 
    886 	static void Get(const glw::Functions& gl, TYPES tex_type, glw::GLenum format, glw::GLenum type,
    887 					glw::GLvoid* out_data);
    888 
    889 	static void Storage(const glw::Functions& gl, TYPES tex_type, glw::GLuint width, glw::GLuint height,
    890 						glw::GLuint depth, glw::GLenum internal_format);
    891 
    892 	static void TexBuffer(const glw::Functions& gl, glw::GLenum internal_format, glw::GLuint& buffer_id);
    893 
    894 	static void Update(const glw::Functions& gl, TYPES tex_type, glw::GLuint width, glw::GLuint height,
    895 					   glw::GLuint depth, glw::GLenum format, glw::GLenum type, glw::GLvoid* data);
    896 
    897 	/* GL gets */
    898 	static glw::GLenum GetTargetGLenum(TYPES tex_type);
    899 
    900 	/* Public fields */
    901 	glw::GLuint m_id;
    902 
    903 	/* Public constants */
    904 	static const glw::GLuint m_invalid_id;
    905 
    906 private:
    907 	deqp::Context& m_context;
    908 	TYPES		   m_type;
    909 };
    910 
    911 /** Represents Vertex array object
    912  * Provides basic functionality
    913  **/
    914 class VertexArray
    915 {
    916 public:
    917 	/* Public methods */
    918 	/* Ctr & Dtr */
    919 	VertexArray(deqp::Context& Context);
    920 	~VertexArray();
    921 
    922 	/* Init & Release */
    923 	void Init();
    924 	//void Init(const ProgramInterface& program_interface,
    925 	//                glw::GLuint       vertex_buffer,
    926 	//                glw::GLuint       index_buffer);
    927 	void Release();
    928 
    929 	void Attribute(glw::GLuint index, const Type& type, glw::GLuint n_array_elements, glw::GLboolean normalized,
    930 				   glw::GLsizei stride, const glw::GLvoid* pointer);
    931 
    932 	void Bind();
    933 
    934 	/* Public static methods */
    935 	static void AttribPointer(const glw::Functions& gl, glw::GLuint index, const Type& type,
    936 							  glw::GLuint n_array_elements, glw::GLboolean normalized, glw::GLsizei stride,
    937 							  const glw::GLvoid* pointer);
    938 
    939 	static void Bind(const glw::Functions& gl, glw::GLuint id);
    940 
    941 	static void Disable(const glw::Functions& gl, glw::GLuint index, const Type& type, glw::GLuint n_array_elements);
    942 
    943 	static void Divisor(const glw::Functions& gl, glw::GLuint index, glw::GLuint divisor);
    944 
    945 	static void Enable(const glw::Functions& gl, glw::GLuint index, const Type& type, glw::GLuint n_array_elements);
    946 
    947 	static void Generate(const glw::Functions& gl, glw::GLuint& out_id);
    948 
    949 	/* Public fields */
    950 	glw::GLuint m_id;
    951 
    952 	/* Public constants */
    953 	static const glw::GLuint m_invalid_id;
    954 
    955 private:
    956 	deqp::Context& m_context;
    957 };
    958 
    959 /* UniformN*v prototypes */
    960 typedef GLW_APICALL void(GLW_APIENTRY* uniformNdv)(glw::GLint, glw::GLsizei, const glw::GLdouble*);
    961 typedef GLW_APICALL void(GLW_APIENTRY* uniformNfv)(glw::GLint, glw::GLsizei, const glw::GLfloat*);
    962 typedef GLW_APICALL void(GLW_APIENTRY* uniformNiv)(glw::GLint, glw::GLsizei, const glw::GLint*);
    963 typedef GLW_APICALL void(GLW_APIENTRY* uniformNuiv)(glw::GLint, glw::GLsizei, const glw::GLuint*);
    964 typedef GLW_APICALL void(GLW_APIENTRY* uniformMatrixNdv)(glw::GLint, glw::GLsizei, glw::GLboolean,
    965 														 const glw::GLdouble*);
    966 typedef GLW_APICALL void(GLW_APIENTRY* uniformMatrixNfv)(glw::GLint, glw::GLsizei, glw::GLboolean, const glw::GLfloat*);
    967 
    968 /* Public static methods */
    969 /* UniformN*v routine getters */
    970 uniformNdv getUniformNdv(const glw::Functions& gl, glw::GLuint n_rows);
    971 uniformNfv getUniformNfv(const glw::Functions& gl, glw::GLuint n_rows);
    972 uniformNiv getUniformNiv(const glw::Functions& gl, glw::GLuint n_rows);
    973 uniformNuiv getUniformNuiv(const glw::Functions& gl, glw::GLuint n_rows);
    974 uniformMatrixNdv getUniformMatrixNdv(const glw::Functions& gl, glw::GLuint n_columns, glw::GLuint n_rows);
    975 uniformMatrixNfv getUniformMatrixNfv(const glw::Functions& gl, glw::GLuint n_columns, glw::GLuint n_rows);
    976 
    977 /* Stuff */
    978 bool checkProgramInterface(const ProgramInterface& program_interface, Program& program, std::stringstream& stream);
    979 
    980 bool isExtensionSupported(deqp::Context& context, const glw::GLchar* extension_name);
    981 
    982 bool isGLVersionAtLeast(const glw::Functions& gl, glw::GLint required_major, glw::GLint required_minor);
    983 
    984 void replaceToken(const glw::GLchar* token, size_t& search_position, const glw::GLchar* text, std::string& string);
    985 
    986 void replaceAllTokens(const glw::GLchar* token, const glw::GLchar* text, std::string& string);
    987 
    988 glw::GLuint roundUpToPowerOf2(glw::GLuint value);
    989 
    990 void insertElementOfList(const glw::GLchar* element, const glw::GLchar* separator, size_t& search_position,
    991 						 std::string& string);
    992 
    993 void endList(const glw::GLchar* separator, size_t& search_position, std::string& string);
    994 } /* Utils namespace */
    995 
    996 /** Base class for tests **/
    997 class TestBase : public deqp::TestCase
    998 {
    999 public:
   1000 	/* Public methods */
   1001 	TestBase(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
   1002 
   1003 	virtual ~TestBase()
   1004 	{
   1005 	}
   1006 
   1007 	/* Public methods inherited from TestCase */
   1008 	virtual tcu::TestNode::IterateResult iterate(void);
   1009 
   1010 protected:
   1011 	/* Methods to be implemented by child class */
   1012 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   1013 	virtual glw::GLuint getTestCaseNumber();
   1014 	virtual bool testCase(glw::GLuint test_case_index) = 0;
   1015 	virtual void testInit();
   1016 
   1017 	/* Routines avaiable for children */
   1018 	glw::GLuint calculateStride(const Utils::Interface& interface) const;
   1019 	void generateData(const Utils::Interface& interface, glw::GLuint offset, std::vector<glw::GLubyte>& out_data) const;
   1020 
   1021 	glw::GLint getLastInputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, glw::GLuint array_lenth);
   1022 
   1023 	glw::GLint getLastOutputLocation(Utils::Shader::STAGES stage, const Utils::Type& type, glw::GLuint array_lenth);
   1024 
   1025 	Utils::Type getType(glw::GLuint index) const;
   1026 	std::string getTypeName(glw::GLuint index) const;
   1027 	glw::GLuint getTypesNumber() const;
   1028 
   1029 	bool isFlatRequired(Utils::Shader::STAGES stage, const Utils::Type& type, Utils::Variable::STORAGE storage) const;
   1030 
   1031 private:
   1032 	/* Private methods */
   1033 	bool test();
   1034 };
   1035 
   1036 /** Base class for test doing Buffer alghorithm **/
   1037 class BufferTestBase : public TestBase
   1038 {
   1039 public:
   1040 	/* Public methods */
   1041 	BufferTestBase(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
   1042 
   1043 	virtual ~BufferTestBase()
   1044 	{
   1045 	}
   1046 
   1047 protected:
   1048 	/* */
   1049 	struct bufferDescriptor
   1050 	{
   1051 		/* Typedefs */
   1052 		typedef std::vector<bufferDescriptor> Vector;
   1053 
   1054 		/* Fileds */
   1055 		std::vector<glw::GLubyte> m_expected_data;
   1056 		std::vector<glw::GLubyte> m_initial_data;
   1057 		glw::GLuint				  m_index;
   1058 		Utils::Buffer::BUFFERS	m_target;
   1059 
   1060 		/* Constants */
   1061 		static const glw::GLuint m_non_indexed;
   1062 	};
   1063 
   1064 	class bufferCollection
   1065 	{
   1066 	public:
   1067 		struct pair
   1068 		{
   1069 			Utils::Buffer*	m_buffer;
   1070 			bufferDescriptor* m_descriptor;
   1071 		};
   1072 
   1073 		~bufferCollection();
   1074 
   1075 		typedef std::vector<pair> Vector;
   1076 
   1077 		Vector m_vector;
   1078 	};
   1079 
   1080 	virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index);
   1081 
   1082 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   1083 
   1084 	virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector& captured_varyings);
   1085 
   1086 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   1087 							   std::string& out_calculations);
   1088 
   1089 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   1090 									std::string& out_interface);
   1091 
   1092 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1093 
   1094 	virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program& program, std::stringstream& out_stream);
   1095 
   1096 	virtual bool testCase(glw::GLuint test_case_index);
   1097 	virtual bool verifyBuffers(bufferCollection& buffers);
   1098 
   1099 private:
   1100 	void		cleanBuffers();
   1101 	std::string getShaderTemplate(Utils::Shader::STAGES stage);
   1102 	void prepareBuffer(Utils::Buffer& buffer, bufferDescriptor& descriptor);
   1103 	void prepareBuffers(bufferDescriptor::Vector& descriptors, bufferCollection& out_buffers);
   1104 
   1105 	/* */
   1106 };
   1107 
   1108 class NegativeTestBase : public TestBase
   1109 {
   1110 public:
   1111 	/* Public methods */
   1112 	NegativeTestBase(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
   1113 
   1114 	virtual ~NegativeTestBase()
   1115 	{
   1116 	}
   1117 
   1118 protected:
   1119 	/* Methods to be implemented by child class */
   1120 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage) = 0;
   1121 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   1122 	virtual bool isFailureExpected(glw::GLuint test_case_index);
   1123 	virtual bool testCase(glw::GLuint test_case_index);
   1124 };
   1125 
   1126 /** Base class for test doing Texture alghorithm **/
   1127 class TextureTestBase : public TestBase
   1128 {
   1129 public:
   1130 	/* Public methods */
   1131 	TextureTestBase(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
   1132 
   1133 	virtual ~TextureTestBase()
   1134 	{
   1135 	}
   1136 
   1137 protected:
   1138 	/* Methods to be implemented by child class */
   1139 	virtual bool checkResults(glw::GLuint test_case_index, Utils::Texture& color_0);
   1140 
   1141 	virtual void executeDispatchCall(glw::GLuint test_case_index);
   1142 	virtual void executeDrawCall(glw::GLuint test_case_index);
   1143 
   1144 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1145 									 Utils::VaryingPassthrough& varying_passthrough);
   1146 
   1147 	virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough& varying_passthrough,
   1148 									   Utils::Shader::STAGES stage);
   1149 
   1150 	virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1151 											   Utils::Shader::STAGES stage);
   1152 
   1153 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   1154 	virtual bool isDrawRelevant(glw::GLuint test_case_index);
   1155 
   1156 	virtual void prepareAttributes(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1157 								   Utils::Buffer& buffer, Utils::VertexArray& vao);
   1158 
   1159 	virtual void prepareAttribLocation(Utils::Program& program, Utils::ProgramInterface& program_interface);
   1160 
   1161 	virtual void prepareFragmentDataLoc(Utils::Program& program, Utils::ProgramInterface& program_interface);
   1162 
   1163 	virtual void prepareFramebuffer(Utils::Framebuffer& framebuffer, Utils::Texture& color_0_texture);
   1164 
   1165 	virtual void prepareImage(glw::GLint location, Utils::Texture& image_texture) const;
   1166 
   1167 	virtual void prepareSSBs(glw::GLuint test_case_index, Utils::ShaderInterface& si, Utils::Program& program,
   1168 							 Utils::Buffer& buffer);
   1169 
   1170 	virtual void prepareSSBs(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1171 							 Utils::Program& program, Utils::Buffer& cs_buffer);
   1172 
   1173 	virtual void prepareSSBs(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1174 							 Utils::Program& program, Utils::Buffer& fs_buffer, Utils::Buffer& gs_buffer,
   1175 							 Utils::Buffer& tcs_buffer, Utils::Buffer& tes_buffer, Utils::Buffer& vs_buffer);
   1176 
   1177 	virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ShaderInterface& si, Utils::Program& program,
   1178 								 Utils::Buffer& buffer);
   1179 
   1180 	virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1181 								 Utils::Program& program, Utils::Buffer& cs_buffer);
   1182 
   1183 	virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1184 								 Utils::Program& program, Utils::Buffer& fs_buffer, Utils::Buffer& gs_buffer,
   1185 								 Utils::Buffer& tcs_buffer, Utils::Buffer& tes_buffer, Utils::Buffer& vs_buffer);
   1186 
   1187 	virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1188 								 Utils::Program& fs_program, Utils::Program& gs_program, Utils::Program& tcs_program,
   1189 								 Utils::Program& tes_program, Utils::Program& vs_program, Utils::Buffer& fs_buffer,
   1190 								 Utils::Buffer& gs_buffer, Utils::Buffer& tcs_buffer, Utils::Buffer& tes_buffer,
   1191 								 Utils::Buffer& vs_buffer);
   1192 	//virtual void        prepareDrawPrograms   (glw::GLuint                 test_case_index,
   1193 	//                                           Utils::Program&             fragment,
   1194 	//                                           Utils::Program&             geometry,
   1195 	//                                           Utils::Program&             tess_ctrl,
   1196 	//                                           Utils::Program&             tess_eval,
   1197 	//                                           Utils::Program&             vertex);
   1198 	virtual bool testCase(glw::GLuint test_case_index);
   1199 	virtual bool testMonolithic(glw::GLuint test_case_index);
   1200 	virtual bool testSeparable(glw::GLuint test_case_index);
   1201 	virtual bool useComponentQualifier(glw::GLuint test_case_index);
   1202 	virtual bool useMonolithicProgram(glw::GLuint test_case_index);
   1203 
   1204 	/* Protected constants */
   1205 	static const glw::GLuint m_width;
   1206 	static const glw::GLuint m_height;
   1207 
   1208 private:
   1209 	std::string getShaderSource(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1210 								Utils::VaryingPassthrough& varying_passthrough, Utils::Shader::STAGES stage);
   1211 
   1212 	const glw::GLchar* getShaderTemplate(Utils::Shader::STAGES stage);
   1213 
   1214 	std::string getVariablePassthrough(const std::string&				  in_parent_name,
   1215 									   const Utils::Variable::Descriptor& in_variable,
   1216 									   Utils::Variable::FLAVOUR in_flavour, const std::string& out_parent_name,
   1217 									   const Utils::Variable::Descriptor& out_variable,
   1218 									   Utils::Variable::FLAVOUR			  out_flavour);
   1219 
   1220 	std::string getVariableVerification(const std::string& parent_name, const glw::GLvoid* data,
   1221 										const Utils::Variable::Descriptor& variable, Utils::Variable::FLAVOUR flavour);
   1222 
   1223 	void prepareSSB(Utils::Program& program, Utils::Variable& variable, Utils::Buffer& buffer);
   1224 
   1225 	void prepareUniform(Utils::Program& program, Utils::Variable& variable, Utils::Buffer& buffer);
   1226 };
   1227 
   1228 /** Implementation of test APIConstantValues. Description follows:
   1229  *
   1230  *  Test verifies values of the following constants are at least as specified:
   1231  * - MAX_TRANSFORM_FEEDBACK_BUFFERS                - 4,
   1232  * - MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS - 64.
   1233  **/
   1234 class APIConstantValuesTest : public deqp::TestCase
   1235 {
   1236 public:
   1237 	/* Public methods */
   1238 	APIConstantValuesTest(deqp::Context& context);
   1239 	virtual ~APIConstantValuesTest()
   1240 	{
   1241 	}
   1242 
   1243 	/* Public methods inherited from TestCase */
   1244 	virtual tcu::TestNode::IterateResult iterate(void);
   1245 };
   1246 
   1247 /** Implementation of test APIErrors. Description follows:
   1248  *
   1249  * Test verifies that errors are generated as specified:
   1250  * - GetProgramInterfaceiv should generate INVALID_OPERATION when
   1251  * <programInterface> is TRANSFORM_FEEDBACK_BUFFER and <pname> is
   1252  * MAX_NAME_LENGTH;
   1253  * - GetProgramResourceIndex should generate INVALID_ENUM when
   1254  * <programInterface> is TRANSFORM_FEEDBACK_BUFFER;
   1255  * - GetProgramResourceName should generate INVALID_ENUM when
   1256  * <programInterface> is TRANSFORM_FEEDBACK_BUFFER;
   1257  **/
   1258 class APIErrorsTest : public deqp::TestCase
   1259 {
   1260 public:
   1261 	/* Public methods */
   1262 	APIErrorsTest(deqp::Context& context);
   1263 	virtual ~APIErrorsTest()
   1264 	{
   1265 	}
   1266 
   1267 	/* Public methods inherited from TestCase */
   1268 	virtual tcu::TestNode::IterateResult iterate(void);
   1269 
   1270 private:
   1271 	void checkError(glw::GLenum expected_error, const glw::GLchar* message, bool& test_result);
   1272 };
   1273 
   1274 /** Implementation of test GLSLContantValues. Description follows:
   1275  *
   1276  * Test verifies values of the following symbols:
   1277  *
   1278  *     GL_ARB_enhanced_layouts,
   1279  *     gl_MaxTransformFeedbackBuffers,
   1280  *     gl_MaxTransformFeedbackInterleavedComponents.
   1281  *
   1282  * This test implements Texture algorithm. Test following code snippet:
   1283  *
   1284  *     if (1 != GL_ARB_enhanced_layouts)
   1285  *     {
   1286  *         result = 0;
   1287  *     }
   1288  *     else if (MAX_TRANSFORM_FEEDBACK_BUFFERS
   1289  *         != gl_MaxTransformFeedbackBuffers)
   1290  *     {
   1291  *         result = 0;
   1292  *     }
   1293  *     else if (MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS
   1294  *         != gl_MaxTransformFeedbackInterleavedComponents)
   1295  *     {
   1296  *         result = 0;
   1297  *     }
   1298  **/
   1299 class GLSLContantValuesTest : public TextureTestBase
   1300 {
   1301 public:
   1302 	GLSLContantValuesTest(deqp::Context& context);
   1303 	~GLSLContantValuesTest()
   1304 	{
   1305 	}
   1306 
   1307 protected:
   1308 	virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1309 											   Utils::Shader::STAGES stage);
   1310 
   1311 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   1312 };
   1313 
   1314 /** Implementation of test GLSLContantImmutablity. Description follows:
   1315  *
   1316  * Test verifies that values of the following symbols cannot be changed in
   1317  * shader:
   1318  *
   1319  *     GL_ARB_enhanced_layouts,
   1320  *     gl_MaxTransformFeedbackBuffers,
   1321  *     gl_MaxTransformFeedbackInterleavedComponents.
   1322  *
   1323  * Compile following code snippet:
   1324  *
   1325  *     CONSTANT = 3;
   1326  *
   1327  * It is expected that compilation will fail. Test each shader stage
   1328  * separately. Test each constant separately.
   1329  **/
   1330 class GLSLContantImmutablityTest : public NegativeTestBase
   1331 {
   1332 public:
   1333 	/* Public methods */
   1334 	GLSLContantImmutablityTest(deqp::Context& context);
   1335 
   1336 	virtual ~GLSLContantImmutablityTest()
   1337 	{
   1338 	}
   1339 
   1340 protected:
   1341 	/* Methods to be implemented by child class */
   1342 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1343 
   1344 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   1345 	virtual glw::GLuint getTestCaseNumber();
   1346 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   1347 	virtual void testInit();
   1348 
   1349 private:
   1350 	/* Private enums */
   1351 	enum CONSTANTS
   1352 	{
   1353 		GL_ARB_ENHANCED_LAYOUTS,
   1354 		GL_MAX_XFB,
   1355 		GL_MAX_XFB_INT_COMP,
   1356 
   1357 		/* */
   1358 		CONSTANTS_MAX,
   1359 	};
   1360 
   1361 	/* Private types */
   1362 	struct testCase
   1363 	{
   1364 		CONSTANTS			  m_constant;
   1365 		Utils::Shader::STAGES m_stage;
   1366 	};
   1367 
   1368 	/* Private methods */
   1369 	const glw::GLchar* getConstantName(CONSTANTS constant);
   1370 
   1371 	/* Private fields */
   1372 	std::vector<testCase> m_test_cases;
   1373 };
   1374 
   1375 /** Implementation of test GLSLConstantIntegralExpression. Description follows:
   1376  *
   1377  * Check that following symbols can be used as integral constant expressions:
   1378  *
   1379  *     GL_ARB_enhanced_layouts,
   1380  *     gl_MaxTransformFeedbackBuffers,
   1381  *     gl_MaxTransformFeedbackInterleavedComponents.
   1382  *
   1383  * Test implement Texture algorithm. Test following code snippet:
   1384  *
   1385  *     uniform uint goku [GL_ARB_enhanced_layouts / GOKU_DIV];
   1386  *     uniform uint gohan[gl_MaxTransformFeedbackBuffers / GOHAN_DIV];
   1387  *     uniform uint goten[gl_MaxTransformFeedbackInterleavedComponents /
   1388  *                         GOTEN_DIV];
   1389  *
   1390  *     for (i = 0; i < goku.length; ++i)
   1391  *         goku_sum += goku[i];
   1392  *
   1393  *     for (i = 0; i < gohan.length; ++i)
   1394  *         gohan_sum += gohan[i];
   1395  *
   1396  *     for (i = 0; i < goten.length; ++i)
   1397  *         goten_sum += goten[i];
   1398  *
   1399  *     if ( (expected_goku_sum  == goku_sum)  &&
   1400  *          (expected_gohan_sum == gohan_sum) &&
   1401  *          (expected_goten_sum == goten_sum) )
   1402  *         result = 1;
   1403  *     else
   1404  *         result = 0;
   1405  *
   1406  * Select DIV values so as array lengths are below 16.
   1407  **/
   1408 class GLSLConstantIntegralExpressionTest : public TextureTestBase
   1409 {
   1410 public:
   1411 	/* Public methods */
   1412 	GLSLConstantIntegralExpressionTest(deqp::Context& context);
   1413 
   1414 	virtual ~GLSLConstantIntegralExpressionTest()
   1415 	{
   1416 	}
   1417 
   1418 protected:
   1419 	/* Protected methods */
   1420 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1421 									 Utils::VaryingPassthrough& varying_passthrough);
   1422 
   1423 	virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1424 											   Utils::Shader::STAGES stage);
   1425 
   1426 	virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1427 								 Utils::Program& program, Utils::Buffer& cs_buffer);
   1428 
   1429 	virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1430 								 Utils::Program& program, Utils::Buffer& fs_buffer, Utils::Buffer& gs_buffer,
   1431 								 Utils::Buffer& tcs_buffer, Utils::Buffer& tes_buffer, Utils::Buffer& vs_buffer);
   1432 
   1433 private:
   1434 	glw::GLint m_gohan_length;
   1435 	glw::GLint m_goten_length;
   1436 };
   1437 
   1438 /** Implementation of test UniformBlockMemberOffsetAndAlign. Description follows:
   1439  *
   1440  * Test verifies that:
   1441  *     - offset and align qualifiers are respected for uniform block members,
   1442  *     - align qualifier is ignored if value is too small,
   1443  *     - align qualifier accepts values bigger than size of base type,
   1444  *     - manual and automatic offsets and alignments can be mixed.
   1445  *
   1446  * This test implement Texture algorithm. Test following code snippet:
   1447  *
   1448  *     const int basic_size = sizeof(basic_type_of(type));
   1449  *     const int type_size  = sizeof(type);
   1450  *     const int type_align = roundUpToPowerOf2(type_size);
   1451  *
   1452  *     layout (std140, offset = 0) uniform Block {
   1453  *         layout(align = 8 * basic_size)  type at_first_offset;
   1454  *         layout(offset = type_size, align = basic_size / 2)
   1455  *                                         type at_second_offset;
   1456  *         layout(align = 2 * type_align)  type at_third_offset;
   1457  *         layout(offset = 3 * type_align + type_size)
   1458  *                                         type at_fourth_offset;
   1459  *                                         type at_fifth_offset;
   1460  *                                         type at_sixth_offset[2];
   1461  *         layout(align = 8 * basic_size)  type at_eight_offset;
   1462  *     };
   1463  *
   1464  *     if ( (at_first_offset  == at_eight_offset   ) &&
   1465  *          (at_second_offset == at_sixth_offset[1]) &&
   1466  *          (at_third_offset  == at_sixth_offset[0]) &&
   1467  *          (at_fourth_offset == at_fifth_offset   ) )
   1468  *         result = 1;
   1469  *     else
   1470  *         result = 0;
   1471  *
   1472  * Additionally inspect program to verify that all block members:
   1473  * - are reported,
   1474  * - have correct offsets.
   1475  *
   1476  * Test should be executed for all types.
   1477  **/
   1478 class UniformBlockMemberOffsetAndAlignTest : public TextureTestBase
   1479 {
   1480 public:
   1481 	/* Public methods */
   1482 	UniformBlockMemberOffsetAndAlignTest(deqp::Context& context);
   1483 
   1484 	virtual ~UniformBlockMemberOffsetAndAlignTest()
   1485 	{
   1486 	}
   1487 
   1488 protected:
   1489 	/* Protected methods */
   1490 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1491 									 Utils::VaryingPassthrough& varying_passthrough);
   1492 
   1493 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   1494 	virtual glw::GLuint getTestCaseNumber();
   1495 
   1496 	virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1497 											   Utils::Shader::STAGES stage);
   1498 
   1499 private:
   1500 	std::vector<glw::GLubyte> m_data;
   1501 };
   1502 
   1503 /** Implementation of test UniformBlockLayoutQualifierConflict. Description follows:
   1504  *
   1505  * Test verifies that offset and align can only be used on members of blocks
   1506  * declared as std140.
   1507  *
   1508  * Test following code snippet with all shader stages:
   1509  *
   1510  *     layout(QUALIFIER) uniform Block {
   1511  *         layout(offset = 16) vec4 boy;
   1512  *         layout(align  = 48) vec4 man;
   1513  *     };
   1514  *
   1515  * Test following block qualifiers and all types:
   1516  *
   1517  *     default - meaning not declared by shader
   1518  *     std140,
   1519  *     shared,
   1520  *     packed.
   1521  *
   1522  * Qualifier std430 is not allowed for uniform blocks.
   1523  *
   1524  * Test expect that only case using std140 will compile and link successfully,
   1525  * while the rest will fail to compile or link.
   1526  **/
   1527 class UniformBlockLayoutQualifierConflictTest : public NegativeTestBase
   1528 {
   1529 public:
   1530 	/* Public methods */
   1531 	UniformBlockLayoutQualifierConflictTest(deqp::Context& context);
   1532 
   1533 	virtual ~UniformBlockLayoutQualifierConflictTest()
   1534 	{
   1535 	}
   1536 
   1537 protected:
   1538 	/* Methods to be implemented by child class */
   1539 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1540 
   1541 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   1542 	virtual glw::GLuint getTestCaseNumber();
   1543 
   1544 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   1545 	virtual bool isFailureExpected(glw::GLuint test_case_index);
   1546 	virtual void testInit();
   1547 
   1548 private:
   1549 	/* Private enums */
   1550 	enum QUALIFIERS
   1551 	{
   1552 		DEFAULT,
   1553 		STD140,
   1554 		SHARED,
   1555 		PACKED,
   1556 
   1557 		/* */
   1558 		QUALIFIERS_MAX,
   1559 	};
   1560 
   1561 	/* Private types */
   1562 	struct testCase
   1563 	{
   1564 		QUALIFIERS			  m_qualifier;
   1565 		Utils::Shader::STAGES m_stage;
   1566 	};
   1567 
   1568 	/* Private methods */
   1569 	const glw::GLchar* getQualifierName(QUALIFIERS qualifier);
   1570 
   1571 	/* Private fields */
   1572 	std::vector<testCase> m_test_cases;
   1573 };
   1574 
   1575 /** Implementation of test UniformBlockMemberInvalidOffsetAlignment. Description follows:
   1576  *
   1577  * Test verifies that offset alignment rules are enforced.
   1578  *
   1579  * Declare uniform block, which contains following member declaration:
   1580  *
   1581  *     layout(offset = X) type block_member
   1582  *
   1583  * Shader compilation is expected to fail for any X that is not a multiple of
   1584  * the base alignment of type.
   1585  * Test all offsets covering locations first and one before last:
   1586  *
   1587  *     <0, sizeof(type)>
   1588  *     <MAX_UNIFORM_BLOCK_SIZE - 2 * sizeof(type),
   1589  *         MAX_UNIFORM_BLOCK_SIZE - sizeof(type)>
   1590  *
   1591  * Test all shader stages. Test all types. Each case should be tested
   1592  * separately.
   1593  **/
   1594 class UniformBlockMemberInvalidOffsetAlignmentTest : public NegativeTestBase
   1595 {
   1596 public:
   1597 	/* Public methods */
   1598 	UniformBlockMemberInvalidOffsetAlignmentTest(deqp::Context& context);
   1599 
   1600 	UniformBlockMemberInvalidOffsetAlignmentTest(deqp::Context& context, const glw::GLchar* name,
   1601 												 const glw::GLchar* description);
   1602 
   1603 	virtual ~UniformBlockMemberInvalidOffsetAlignmentTest()
   1604 	{
   1605 	}
   1606 
   1607 protected:
   1608 	/* Methods to be implemented by child class */
   1609 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1610 
   1611 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   1612 	virtual glw::GLuint getTestCaseNumber();
   1613 	virtual glw::GLint  getMaxBlockSize();
   1614 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   1615 	virtual bool isFailureExpected(glw::GLuint test_case_index);
   1616 	virtual bool isStageSupported(Utils::Shader::STAGES stage);
   1617 	virtual void testInit();
   1618 
   1619 protected:
   1620 	/* Protected types */
   1621 	struct testCase
   1622 	{
   1623 		glw::GLuint			  m_offset;
   1624 		bool				  m_should_fail;
   1625 		Utils::Shader::STAGES m_stage;
   1626 		Utils::Type			  m_type;
   1627 	};
   1628 
   1629 	/* Protected fields */
   1630 	std::vector<testCase> m_test_cases;
   1631 };
   1632 
   1633 /** Implementation of test UniformBlockMemberOverlappingOffsets. Description follows:
   1634  *
   1635  * Test verifies that block members cannot overlap.
   1636  *
   1637  * Use following code snippet:
   1638  *
   1639  *     layout (std140) uniform Block {
   1640  *         layout (offset = boy_offset) boy_type boy;
   1641  *         layout (offset = man_offset) man_type man;
   1642  *     };
   1643  *
   1644  * It is expected that overlapping members will cause compilation failure.
   1645  *
   1646  * There are three cases to test:
   1647  *
   1648  *     - when member is declared with the same offset as already declared
   1649  *     member,
   1650  *     - when member is declared with offset that lay in the middle of already
   1651  *     declared member,
   1652  *     - when member is declared with offset just before already declared
   1653  *     member and there is not enough space.
   1654  *
   1655  * Test all shader stages. Test all types. Test cases separately.
   1656  *
   1657  * Note that not all type combinations let to test all three cases, e.g.
   1658  * vec4 and float.
   1659  **/
   1660 class UniformBlockMemberOverlappingOffsetsTest : public NegativeTestBase
   1661 {
   1662 public:
   1663 	/* Public methods */
   1664 	UniformBlockMemberOverlappingOffsetsTest(deqp::Context& context);
   1665 
   1666 	UniformBlockMemberOverlappingOffsetsTest(deqp::Context& context, const glw::GLchar* name,
   1667 											 const glw::GLchar* description);
   1668 
   1669 	virtual ~UniformBlockMemberOverlappingOffsetsTest()
   1670 	{
   1671 	}
   1672 
   1673 protected:
   1674 	/* Methods to be implemented by child class */
   1675 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1676 
   1677 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   1678 	virtual glw::GLuint getTestCaseNumber();
   1679 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   1680 	virtual bool isStageSupported(Utils::Shader::STAGES stage);
   1681 	virtual void testInit();
   1682 
   1683 protected:
   1684 	/* Protected types */
   1685 	struct testCase
   1686 	{
   1687 		glw::GLuint			  m_boy_offset;
   1688 		Utils::Type			  m_boy_type;
   1689 		glw::GLuint			  m_man_offset;
   1690 		Utils::Type			  m_man_type;
   1691 		Utils::Shader::STAGES m_stage;
   1692 	};
   1693 
   1694 	/* Protected methods */
   1695 	glw::GLuint gcd(glw::GLuint a, glw::GLuint b);
   1696 	glw::GLuint lcm(glw::GLuint a, glw::GLuint b);
   1697 
   1698 	/* Protected fields */
   1699 	std::vector<testCase> m_test_cases;
   1700 };
   1701 
   1702 /** Implementation of test UniformBlockMemberAlignNonPowerOf2. Description follows:
   1703  *
   1704  * Test verifies that align qualifier must use power of 2.
   1705  *
   1706  * Test following code snippet:
   1707  *
   1708  *     layout (std140, offset = 8) uniform Block {
   1709  *         vec4 boy;
   1710  *         layout (align = man_alignment) type man;
   1711  *     };
   1712  *
   1713  * It is expected that compilation will fail whenever man_alignment is not
   1714  * a power of 2.
   1715  *
   1716  * Test all alignment in range <0, sizeof(dmat4)>. Test all shader stages.
   1717  * Test all types.
   1718  **/
   1719 class UniformBlockMemberAlignNonPowerOf2Test : public NegativeTestBase
   1720 {
   1721 public:
   1722 	/* Public methods */
   1723 	UniformBlockMemberAlignNonPowerOf2Test(deqp::Context& context);
   1724 
   1725 	UniformBlockMemberAlignNonPowerOf2Test(deqp::Context& context, const glw::GLchar* name,
   1726 										   const glw::GLchar* description);
   1727 
   1728 	virtual ~UniformBlockMemberAlignNonPowerOf2Test()
   1729 	{
   1730 	}
   1731 
   1732 protected:
   1733 	/* Methods to be implemented by child class */
   1734 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1735 
   1736 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   1737 	virtual glw::GLuint getTestCaseNumber();
   1738 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   1739 	virtual bool isFailureExpected(glw::GLuint test_case_index);
   1740 	virtual bool isStageSupported(Utils::Shader::STAGES stage);
   1741 	virtual void testInit();
   1742 
   1743 protected:
   1744 	/* Protected types */
   1745 	struct testCase
   1746 	{
   1747 		glw::GLuint			  m_alignment;
   1748 		Utils::Type			  m_type;
   1749 		bool				  m_should_fail;
   1750 		Utils::Shader::STAGES m_stage;
   1751 	};
   1752 
   1753 	/* Protected methods */
   1754 	bool isPowerOf2(glw::GLuint val);
   1755 
   1756 	/* Protected fields */
   1757 	std::vector<testCase> m_test_cases;
   1758 };
   1759 
   1760 /** Implementation of test UniformBlockAlignment. Description follows:
   1761  *
   1762  * UniformBlockAlignment
   1763  *
   1764  *   Test verifies that align qualifier is applied to block members as specified.
   1765  *
   1766  *   This test implements Texture algorithm. Test following code snippet:
   1767  *
   1768  *       struct Data {
   1769  *           vec4  vector;
   1770  *           float scalar;
   1771  *       };
   1772  *
   1773  *       layout (std140, offset = 8, align = 64) uniform Block {
   1774  *                               vec4 first;
   1775  *                               Data second;
   1776  *                               Data third[2];
   1777  *                               vec4 fourth[3];
   1778  *           layout (align = 16) vec4 fifth[2];
   1779  *                               Data sixth;
   1780  *       };
   1781  *
   1782  *   Verify that all uniforms have correct values. Additionally inspect program
   1783  *   to check that all offsets are as expected.
   1784  **/
   1785 class UniformBlockAlignmentTest : public TextureTestBase
   1786 {
   1787 public:
   1788 	/* Public methods */
   1789 	UniformBlockAlignmentTest(deqp::Context& context);
   1790 
   1791 	virtual ~UniformBlockAlignmentTest()
   1792 	{
   1793 	}
   1794 
   1795 protected:
   1796 	/* Protected methods */
   1797 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1798 									 Utils::VaryingPassthrough& varying_passthrough);
   1799 
   1800 private:
   1801 	std::vector<glw::GLubyte> m_data;
   1802 };
   1803 
   1804 /** Implementation of test SSBMemberOffsetAndAlign. Description follows:
   1805  *
   1806  * Test verifies that:
   1807  *     - offset and align qualifiers are respected for shader storage block
   1808  *     members,
   1809  *     - align qualifier is ignored if value is too small,
   1810  *     - align qualifier accepts values bigger than size of base type,
   1811  *     - manual and automatic offsets and alignments can be mixed.
   1812  *
   1813  * Modify UniformBlockMemberOffsetAndAlign to test shader storage block instead
   1814  * of uniform block.
   1815  **/
   1816 class SSBMemberOffsetAndAlignTest : public TextureTestBase
   1817 {
   1818 public:
   1819 	/* Public methods */
   1820 	SSBMemberOffsetAndAlignTest(deqp::Context& context);
   1821 	virtual ~SSBMemberOffsetAndAlignTest()
   1822 	{
   1823 	}
   1824 
   1825 protected:
   1826 	/* Protected methods */
   1827 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1828 									 Utils::VaryingPassthrough& varying_passthrough);
   1829 
   1830 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   1831 	virtual glw::GLuint getTestCaseNumber();
   1832 
   1833 	virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1834 											   Utils::Shader::STAGES stage);
   1835 
   1836 	virtual bool isDrawRelevant(glw::GLuint test_case_index);
   1837 
   1838 private:
   1839 	std::vector<glw::GLubyte> m_data;
   1840 };
   1841 
   1842 /** Implementation of test SSBLayoutQualifierConflict. Description follows:
   1843  *
   1844  * Test verifies that offset and align can only be used on members of blocks
   1845  * declared as std140 or std430.
   1846  *
   1847  * Modify UniformBlockMemberOffsetAndAlign to test shader storage block instead
   1848  * of uniform block.
   1849  *
   1850  * Qualifier std430 is allowed for shader storage blocks, it should be included
   1851  * in test. It is expected that std430 case will build successfully.
   1852  **/
   1853 class SSBLayoutQualifierConflictTest : public NegativeTestBase
   1854 {
   1855 public:
   1856 	/* Public methods */
   1857 	SSBLayoutQualifierConflictTest(deqp::Context& context);
   1858 
   1859 	virtual ~SSBLayoutQualifierConflictTest()
   1860 	{
   1861 	}
   1862 
   1863 protected:
   1864 	/* Methods to be implemented by child class */
   1865 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1866 
   1867 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   1868 	virtual glw::GLuint getTestCaseNumber();
   1869 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   1870 	virtual bool isFailureExpected(glw::GLuint test_case_index);
   1871 	virtual void testInit();
   1872 
   1873 private:
   1874 	/* Private enums */
   1875 	enum QUALIFIERS
   1876 	{
   1877 		DEFAULT,
   1878 		STD140,
   1879 		STD430,
   1880 		SHARED,
   1881 		PACKED,
   1882 
   1883 		/* */
   1884 		QUALIFIERS_MAX,
   1885 	};
   1886 
   1887 	/* Private types */
   1888 	struct testCase
   1889 	{
   1890 		QUALIFIERS			  m_qualifier;
   1891 		Utils::Shader::STAGES m_stage;
   1892 	};
   1893 
   1894 	/* Private methods */
   1895 	const glw::GLchar* getQualifierName(QUALIFIERS qualifier);
   1896 	bool isStageSupported(Utils::Shader::STAGES stage);
   1897 
   1898 	/* Private fields */
   1899 	std::vector<testCase> m_test_cases;
   1900 };
   1901 
   1902 /** Implementation of test SSBMemberInvalidOffsetAlignment. Description follows:
   1903  *
   1904  * Test verifies that offset alignment rules are enforced.
   1905  *
   1906  * Modify UniformBlockMemberInvalidOffsetAlignment to test shader
   1907  * storage block against MAX_SHADER_STORAGE_BLOCK_SIZE instead of
   1908  * uniform block
   1909  **/
   1910 class SSBMemberInvalidOffsetAlignmentTest : public UniformBlockMemberInvalidOffsetAlignmentTest
   1911 {
   1912 public:
   1913 	/* Public methods */
   1914 	SSBMemberInvalidOffsetAlignmentTest(deqp::Context& context);
   1915 
   1916 	virtual ~SSBMemberInvalidOffsetAlignmentTest()
   1917 	{
   1918 	}
   1919 
   1920 protected:
   1921 	/* Methods to be implemented by child class */
   1922 	virtual glw::GLint  getMaxBlockSize();
   1923 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1924 
   1925 	virtual bool isStageSupported(Utils::Shader::STAGES stage);
   1926 };
   1927 
   1928 /** Implementation of test SSBMemberOverlappingOffsets. Description follows:
   1929  *
   1930  * Test verifies that block members cannot overlap.
   1931  *
   1932  * Modify UniformBlockMemberOverlappingOffsets to test shader storage block
   1933  * instead of uniform block.
   1934  **/
   1935 class SSBMemberOverlappingOffsetsTest : public UniformBlockMemberOverlappingOffsetsTest
   1936 {
   1937 public:
   1938 	/* Public methods */
   1939 	SSBMemberOverlappingOffsetsTest(deqp::Context& context);
   1940 	virtual ~SSBMemberOverlappingOffsetsTest()
   1941 	{
   1942 	}
   1943 
   1944 protected:
   1945 	/* Methods to be implemented by child class */
   1946 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1947 
   1948 	virtual bool isStageSupported(Utils::Shader::STAGES stage);
   1949 };
   1950 
   1951 /** Implementation of test SSBMemberAlignNonPowerOf2. Description follows:
   1952  *
   1953  * Test verifies that align qualifier must use power of 2.
   1954  *
   1955  * Modify UniformBlockMemberAlignNonPowerOf2 to test shader storage block
   1956  * instead of uniform block.
   1957  **/
   1958 class SSBMemberAlignNonPowerOf2Test : public UniformBlockMemberAlignNonPowerOf2Test
   1959 {
   1960 public:
   1961 	/* Public methods */
   1962 	SSBMemberAlignNonPowerOf2Test(deqp::Context& context);
   1963 
   1964 	virtual ~SSBMemberAlignNonPowerOf2Test()
   1965 	{
   1966 	}
   1967 
   1968 protected:
   1969 	/* Methods to be implemented by child class */
   1970 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   1971 
   1972 	virtual bool isStageSupported(Utils::Shader::STAGES stage);
   1973 };
   1974 
   1975 /** Implementation of test SSBAlignment. Description follows:
   1976  *
   1977  * Test verifies that align qualifier is applied to block members as specified.
   1978  *
   1979  * Modify UniformBlockAlignment to test shader storage block instead
   1980  * of uniform block.
   1981  **/
   1982 class SSBAlignmentTest : public TextureTestBase
   1983 {
   1984 public:
   1985 	/* Public methods */
   1986 	SSBAlignmentTest(deqp::Context& context);
   1987 
   1988 	virtual ~SSBAlignmentTest()
   1989 	{
   1990 	}
   1991 
   1992 protected:
   1993 	/* Protected methods */
   1994 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   1995 									 Utils::VaryingPassthrough& varying_passthrough);
   1996 
   1997 	virtual bool isDrawRelevant(glw::GLuint test_case_index);
   1998 
   1999 private:
   2000 	std::vector<glw::GLubyte> m_data;
   2001 };
   2002 
   2003 /** Implementation of test VaryingLocations. Description follows:
   2004  *
   2005  * Test verifies that "varying" locations are assigned as declared in shader.
   2006  *
   2007  * This test implements Texture algorithm. Use separate shader objects instead
   2008  * of monolithic program. Test following code snippet:
   2009  *
   2010  *     layout(location = 0)           in  type input_at_first_location;
   2011  *     layout(location = last_input)  in  type input_at_last_location;
   2012  *     layout(location = 1)           out type output_at_first_location;
   2013  *     layout(location = last_output) out type output_at_last_location;
   2014  *
   2015  *     output_at_first_location = input_at_first_location;
   2016  *     output_at_last_location  = input_at_last_location;
   2017  *
   2018  *     if ( (EXPECTED_VALUE == input_at_first_location) &&
   2019  *          (EXPECTED_VALUE == input_at_last_location)  )
   2020  *     {
   2021  *         result = 1;
   2022  *     }
   2023  *
   2024  * Additionally inspect program to check that all locations are as expected.
   2025  *
   2026  * Test all types. Test all shader stages.
   2027  **/
   2028 class VaryingLocationsTest : public TextureTestBase
   2029 {
   2030 public:
   2031 	VaryingLocationsTest(deqp::Context& context);
   2032 
   2033 	VaryingLocationsTest(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
   2034 
   2035 	~VaryingLocationsTest()
   2036 	{
   2037 	}
   2038 
   2039 protected:
   2040 	/* Protected methods */
   2041 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   2042 									 Utils::VaryingPassthrough& varying_passthrough);
   2043 
   2044 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2045 	virtual glw::GLuint getTestCaseNumber();
   2046 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2047 	virtual bool useMonolithicProgram(glw::GLuint test_case_index);
   2048 
   2049 	/* To be implemented by children */
   2050 	virtual void prepareShaderStage(Utils::Shader::STAGES stage, const Utils::Type& type,
   2051 									Utils::ProgramInterface&   program_interface,
   2052 									Utils::VaryingPassthrough& varying_passthrough);
   2053 
   2054 	/* Protected methods */
   2055 	std::string prepareGlobals(glw::GLint last_in_loc, glw::GLint last_out_loc);
   2056 
   2057 	/* Protected fields */
   2058 	std::vector<glw::GLubyte> m_first_data;
   2059 	std::vector<glw::GLubyte> m_last_data;
   2060 };
   2061 
   2062 /** Implementation of test VertexAttribLocations. Description follows:
   2063  *
   2064  * Test verifies that drawing operations provide vertex attributes at expected
   2065  * locations.
   2066  *
   2067  * This test implements Texture algorithm. Use separate shader objects instead
   2068  * of monolithic program. Tessellation stages are not necessary and can be
   2069  * omitted. Test following code snippet:
   2070  *
   2071  *     layout (location = 2) in uint vertex_index;
   2072  *     layout (location = 5) in uint instance_index;
   2073  *
   2074  *     if ( (gl_VertexID   == vertex_index)   &&
   2075  *          (gl_InstanceID == instance_index) )
   2076  *     {
   2077  *         result = 1;
   2078  *     }
   2079  *
   2080  * Test following Draw* operations:
   2081  *     - DrawArrays,
   2082  *     - DrawArraysInstanced,
   2083  *     - DrawElements,
   2084  *     - DrawElementsBaseVertex,
   2085  *     - DrawElementsInstanced,
   2086  *     - DrawElementsInstancedBaseInstance,
   2087  *     - DrawElementsInstancedBaseVertex,
   2088  *     - DrawElementsInstancedBaseVertexBaseInstance.
   2089  *
   2090  * Number of drawn instances should be equal 4. base_vertex parameter should be
   2091  * set to 4. base_instance should be set to 2.
   2092  *
   2093  * Values provided for "vertex_index" should match index of vertex. Values
   2094  * provided for "instance_index" should match index of instance
   2095  * (use VertexAttribDivisor).
   2096  **/
   2097 class VertexAttribLocationsTest : public TextureTestBase
   2098 {
   2099 public:
   2100 	VertexAttribLocationsTest(deqp::Context& context);
   2101 
   2102 	~VertexAttribLocationsTest()
   2103 	{
   2104 	}
   2105 
   2106 protected:
   2107 	/* Protected methods */
   2108 	virtual void executeDrawCall(glw::GLuint test_case_index);
   2109 
   2110 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   2111 									 Utils::VaryingPassthrough& varying_passthrough);
   2112 
   2113 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2114 	virtual glw::GLuint getTestCaseNumber();
   2115 
   2116 	virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   2117 											   Utils::Shader::STAGES stage);
   2118 
   2119 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2120 
   2121 	virtual void prepareAttributes(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   2122 								   Utils::Buffer& buffer, Utils::VertexArray& vao);
   2123 
   2124 	virtual bool useMonolithicProgram(glw::GLuint test_case_index);
   2125 
   2126 private:
   2127 	/* Private enums */
   2128 	enum TESTCASES
   2129 	{
   2130 		DRAWARRAYS,
   2131 		DRAWARRAYSINSTANCED,
   2132 		DRAWELEMENTS,
   2133 		DRAWELEMENTSBASEVERTEX,
   2134 		DRAWELEMENTSINSTANCED,
   2135 		DRAWELEMENTSINSTANCEDBASEINSTANCE,
   2136 		DRAWELEMENTSINSTANCEDBASEVERTEX,
   2137 		DRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCE,
   2138 
   2139 		/* */
   2140 		TESTCASES_MAX
   2141 	};
   2142 
   2143 	/* Private constants */
   2144 	static const glw::GLuint m_base_vertex;
   2145 	static const glw::GLuint m_base_instance;
   2146 	static const glw::GLuint m_loc_vertex;
   2147 	static const glw::GLuint m_loc_instance;
   2148 	static const glw::GLuint m_n_instances;
   2149 };
   2150 
   2151 /** Implementation of test VaryingArrayLocations. Description follows:
   2152  *
   2153  * VaryingArrayLocations
   2154  *
   2155  *   Test verifies that locations of arrays of "varying" are assigned as declared
   2156  *   in shader.
   2157  *
   2158  *   This test implements Texture algorithm. Use separate shader objects instead
   2159  *   of monolithic program. Test following code snippet:
   2160  *
   2161  *       layout(location = 0)           in  type in_at_first_loc[FIRST_LENGTH];
   2162  *       layout(location = last_input)  in  type in_at_last_loc[LAST_LENGTH];
   2163  *       layout(location = 1)           out type out_at_first_loc[FIRST_LENGTH];
   2164  *       layout(location = last_output) out type out_at_last_loc[LAST_LENGTH];
   2165  *
   2166  *       for (uint i = 0u; i < in_at_first_loc.length(); ++i)
   2167  *       {
   2168  *           out_at_first_loc[i] = in_at_first_loc[i];
   2169  *
   2170  *           if (EXPECTED_VALUE[i] != in_at_first_loc[i])
   2171  *           {
   2172  *               result = 0;
   2173  *           }
   2174  *       }
   2175  *
   2176  *       for (uint i = 0u; i < in_at_last_loc.length(); ++i)
   2177  *       {
   2178  *           out_at_last_loc[i] = in_at_last_loc[i];
   2179  *
   2180  *           if (EXPECTED_VALUE[i] != in_at_last_loc[i])
   2181  *           {
   2182  *               result = 0;
   2183  *           }
   2184  *       }
   2185  *
   2186  *   FIRST_LENGTH and LAST_LENGTH values should be selected so as not to exceed
   2187  *   limits.
   2188  *
   2189  *   Additionally inspect program to check that all locations are as expected.
   2190  *
   2191  *   Test all types. Test all shader stages.
   2192  **/
   2193 class VaryingArrayLocationsTest : public VaryingLocationsTest
   2194 {
   2195 public:
   2196 	VaryingArrayLocationsTest(deqp::Context& context);
   2197 
   2198 	~VaryingArrayLocationsTest()
   2199 	{
   2200 	}
   2201 
   2202 protected:
   2203 	/* Protected methods */
   2204 	virtual void prepareShaderStage(Utils::Shader::STAGES stage, const Utils::Type& type,
   2205 									Utils::ProgramInterface&   program_interface,
   2206 									Utils::VaryingPassthrough& varying_passthrough);
   2207 };
   2208 
   2209 /** Implementation of test VaryingStructureLocations. Description follows:
   2210  *
   2211  * Test verifies that structures locations are as expected.
   2212  *
   2213  * This test implements Texture algorithm. Use separate shader objects instead
   2214  * of monolithic program. Test following code snippet:
   2215  *
   2216  *     struct Data
   2217  *     {
   2218  *         type single;
   2219  *         type array[ARRAY_LENGTH];
   2220  *     };
   2221  *
   2222  *     layout (location = INPUT_LOCATION)  in  Data input[VARYING_LENGTH];
   2223  *     layout (location = OUTPUT_LOCATION) out Data output[VARYING_LENGTH];
   2224  *
   2225  *     if ( (EXPECTED_VALUE == input[0].single)         &&
   2226  *          (EXPECTED_VALUE == input[0].array[0])       &&
   2227  *          (EXPECTED_VALUE == input[0].array[last])    &&
   2228  *          (EXPECTED_VALUE == input[last].single)      &&
   2229  *          (EXPECTED_VALUE == input[last].array[0])    &&
   2230  *          (EXPECTED_VALUE == input[last].array[last]) )
   2231  *     {
   2232  *         result = 1;
   2233  *     }
   2234  *
   2235  *     output[0].single         = input[0].single;
   2236  *     output[0].array[0]       = input[0].array[0];
   2237  *     output[0].array[last]    = input[0].array[last];
   2238  *     output[last].single      = input[last].single;
   2239  *     output[last].array[0]    = input[last].array[0];
   2240  *     output[last].array[last] = input[last].array[last];
   2241  *
   2242  * Select array lengths and locations so as no limits are exceeded.
   2243  **/
   2244 
   2245 class VaryingStructureLocationsTest : public TextureTestBase
   2246 {
   2247 public:
   2248 	VaryingStructureLocationsTest(deqp::Context& context);
   2249 
   2250 	~VaryingStructureLocationsTest()
   2251 	{
   2252 	}
   2253 
   2254 protected:
   2255 	/* Protected methods */
   2256 	virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough& varying_passthrough,
   2257 									   Utils::Shader::STAGES stage);
   2258 
   2259 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   2260 									 Utils::VaryingPassthrough& varying_passthrough);
   2261 
   2262 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2263 	virtual glw::GLuint getTestCaseNumber();
   2264 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2265 	virtual bool useMonolithicProgram(glw::GLuint test_case_index);
   2266 
   2267 	/* Protected fields */
   2268 	std::vector<glw::GLubyte> m_single_data;
   2269 	std::vector<glw::GLubyte> m_array_data;
   2270 	std::vector<glw::GLubyte> m_data;
   2271 };
   2272 
   2273 /** Implementation of test VaryingStructureMemberLocation. Description follows:
   2274  *
   2275  * Test verifies that it is not allowed to declare structure member at specific
   2276  * location.
   2277  *
   2278  * Test following code snippet:
   2279  *
   2280  *     struct Data
   2281  *     {
   2282  *         vec4 gohan;
   2283  *         layout (location = LOCATION) vec4 goten;
   2284  *     }
   2285  *
   2286  *     in Data goku;
   2287  *
   2288  * Select LOCATION so as not to exceed limits. Test all shader stages. Test
   2289  * both in and out varyings.
   2290  *
   2291  * It is expected that compilation will fail.
   2292  **/
   2293 class VaryingStructureMemberLocationTest : public NegativeTestBase
   2294 {
   2295 public:
   2296 	VaryingStructureMemberLocationTest(deqp::Context& context);
   2297 
   2298 	~VaryingStructureMemberLocationTest()
   2299 	{
   2300 	}
   2301 
   2302 protected:
   2303 	/* Methods to be implemented by child class */
   2304 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   2305 
   2306 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2307 	virtual glw::GLuint getTestCaseNumber();
   2308 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2309 	virtual void testInit();
   2310 
   2311 private:
   2312 	/* Private types */
   2313 	struct testCase
   2314 	{
   2315 		bool				  m_is_input;
   2316 		Utils::Shader::STAGES m_stage;
   2317 	};
   2318 
   2319 	/* Private fields */
   2320 	std::vector<testCase> m_test_cases;
   2321 };
   2322 
   2323 /** Implementation of test VaryingBlockLocations. Description follows:
   2324  *
   2325  * Test verifies that "block varyings" locations are as expected.
   2326  *
   2327  * This test implements Texture algorithm. Use separate shader objects instead
   2328  * of monolithic program. Test following code snippet:
   2329  *
   2330  *     layout (location = GOKU_LOCATION) in Goku
   2331  *     {
   2332  *                                            vec4 gohan;
   2333  *         layout (location = GOTEN_LOCATION) vec4 goten;
   2334  *                                            vec4 chichi;
   2335  *     };
   2336  *
   2337  *     layout (location = VEGETA_LOCATION) out Vegeta
   2338  *     {
   2339  *                                          vec4 trunks;
   2340  *         layout (location = BRA_LOCATION) vec4 bra;
   2341  *                                          vec4 bulma;
   2342  *     };
   2343  *
   2344  *     if ( (EXPECTED_VALUE == gohan) &&
   2345  *          (EXPECTED_VALUE == goten) &&
   2346  *          (EXPECTED_VALUE == chichi) )
   2347  *     {
   2348  *         result = 1;
   2349  *     }
   2350  *
   2351  *     trunks = gohan;
   2352  *     bra    = goten;
   2353  *     bulma  = chichi;
   2354  *
   2355  * Select all locations so as not to cause any conflicts or exceed limits.
   2356  **/
   2357 class VaryingBlockLocationsTest : public TextureTestBase
   2358 {
   2359 public:
   2360 	VaryingBlockLocationsTest(deqp::Context& context);
   2361 	~VaryingBlockLocationsTest()
   2362 	{
   2363 	}
   2364 
   2365 protected:
   2366 	/* Protected methods */
   2367 	virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough& varying_passthrough,
   2368 									   Utils::Shader::STAGES stage);
   2369 
   2370 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   2371 									 Utils::VaryingPassthrough& varying_passthrough);
   2372 
   2373 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2374 	virtual bool useMonolithicProgram(glw::GLuint test_case_index);
   2375 
   2376 	/* Protected fields */
   2377 	std::vector<glw::GLubyte> m_third_data;
   2378 	std::vector<glw::GLubyte> m_fourth_data;
   2379 	std::vector<glw::GLubyte> m_fifth_data;
   2380 	std::vector<glw::GLubyte> m_data;
   2381 };
   2382 
   2383 /** Implementation of test VaryingBlockMemberLocations. Description follows:
   2384  *
   2385  * Test verifies that it is a compilation error to declare some of block
   2386  * members with location qualifier, but not all, when there is no "block level"
   2387  * location qualifier.
   2388  *
   2389  * Test following code snippets:
   2390  *
   2391  *     in Goku
   2392  *     {
   2393  *         vec4 gohan;
   2394  *         layout (location = GOTEN_LOCATION) vec4 goten;
   2395  *         vec4 chichi;
   2396  *     };
   2397  *
   2398  * ,
   2399  *
   2400  *     in Goku
   2401  *     {
   2402  *         layout (location = GOHAN_LOCATION)  vec4 gohan;
   2403  *         layout (location = GOTEN_LOCATION)  vec4 goten;
   2404  *         layout (location = CHICHI_LOCATION) vec4 chichi;
   2405  *     };
   2406  *
   2407  * Select all locations so as not to exceed any limits.
   2408  *
   2409  * It is expected that compilation of first snippet will fail. Compilation of
   2410  * second snippet should be successful.
   2411  *
   2412  * Test all shader stages. Test both in and out blocks.
   2413  **/
   2414 class VaryingBlockMemberLocationsTest : public NegativeTestBase
   2415 {
   2416 public:
   2417 	/* Public methods */
   2418 	VaryingBlockMemberLocationsTest(deqp::Context& context);
   2419 
   2420 	virtual ~VaryingBlockMemberLocationsTest()
   2421 	{
   2422 	}
   2423 
   2424 protected:
   2425 	/* Methods to be implemented by child class */
   2426 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   2427 
   2428 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2429 	virtual glw::GLuint getTestCaseNumber();
   2430 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2431 	virtual bool isFailureExpected(glw::GLuint test_case_index);
   2432 	virtual void testInit();
   2433 
   2434 private:
   2435 	/* Private types */
   2436 	struct testCase
   2437 	{
   2438 		bool				  m_is_input;
   2439 		bool				  m_qualify_all;
   2440 		Utils::Shader::STAGES m_stage;
   2441 	};
   2442 
   2443 	/* Private fields */
   2444 	std::vector<testCase> m_test_cases;
   2445 };
   2446 
   2447 /** Implementation of test VaryingBlockAutomaticMemberLocations. Description follows:
   2448  *
   2449  * Test verifies that compiler will assign subsequent locations to block
   2450  * members.
   2451  *
   2452  * Test following code snippet:
   2453  *
   2454  *     layout (location = 2) in DBZ
   2455  *     {
   2456  *         vec4 goku;                         // 2
   2457  *         vec4 gohan[GOHAN_LENGTH];          // 3
   2458  *         vec4 goten;                        // 3 + GOHAN_LENGTH
   2459  *         layout (location = 1) vec4 chichi; // 1
   2460  *         vec4 pan;                          // 2; ERROR location 2 used twice
   2461  *     };
   2462  *
   2463  * Test all shader stages. Test both in and out blocks.
   2464  *
   2465  * It is expected that build process will fail.
   2466  **/
   2467 class VaryingBlockAutomaticMemberLocationsTest : public NegativeTestBase
   2468 {
   2469 public:
   2470 	/* Public methods */
   2471 	VaryingBlockAutomaticMemberLocationsTest(deqp::Context& context);
   2472 
   2473 	virtual ~VaryingBlockAutomaticMemberLocationsTest()
   2474 	{
   2475 	}
   2476 
   2477 protected:
   2478 	/* Methods to be implemented by child class */
   2479 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   2480 
   2481 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2482 	virtual glw::GLuint getTestCaseNumber();
   2483 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2484 	virtual void testInit();
   2485 
   2486 private:
   2487 	/* Private types */
   2488 	struct testCase
   2489 	{
   2490 		bool				  m_is_input;
   2491 		Utils::Shader::STAGES m_stage;
   2492 	};
   2493 
   2494 	/* Private fields */
   2495 	std::vector<testCase> m_test_cases;
   2496 };
   2497 
   2498 /** Implementation of test VaryingLocationLimit. Description follows:
   2499  *
   2500  * Test verifies that "location" qualifier cannot exceed limits.
   2501  *
   2502  * Test following code snippet:
   2503  *
   2504  *     layout (location = LAST + 1) in type goku;
   2505  *
   2506  * LAST should be set to index of last available location.
   2507  *
   2508  * Test all types. Test all shader stages. Test both in and out varyings.
   2509  *
   2510  * It is expected that shader compilation will fail.
   2511  **/
   2512 class VaryingLocationLimitTest : public NegativeTestBase
   2513 {
   2514 public:
   2515 	/* Public methods */
   2516 	VaryingLocationLimitTest(deqp::Context& context);
   2517 
   2518 	virtual ~VaryingLocationLimitTest()
   2519 	{
   2520 	}
   2521 
   2522 protected:
   2523 	/* Methods to be implemented by child class */
   2524 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   2525 
   2526 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2527 	virtual glw::GLuint getTestCaseNumber();
   2528 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2529 	virtual void testInit();
   2530 
   2531 private:
   2532 	/* Private types */
   2533 	struct testCase
   2534 	{
   2535 		bool				  m_is_input;
   2536 		Utils::Type			  m_type;
   2537 		Utils::Shader::STAGES m_stage;
   2538 	};
   2539 
   2540 	/* Private fields */
   2541 	std::vector<testCase> m_test_cases;
   2542 };
   2543 
   2544 /** Implementation of test VaryingComponents. Description follows:
   2545  *
   2546  * VaryingComponents
   2547  *
   2548  *   Test verifies that "varying" can be assigned to specific components.
   2549  *
   2550  *   Modify VaryingLocations to test all possible combinations of components
   2551  *   layout:
   2552  *       - gvec4
   2553  *       - scalar, gvec3
   2554  *       - gvec3, scalar
   2555  *       - gvec2, gvec2
   2556  *       - gvec2, scalar, scalar
   2557  *       - scalar, gvec2, scalar
   2558  *       - scalar, scalar, gvec2
   2559  *       - scalar, scalar, scalar, scalar.
   2560  *
   2561  *   Additionally inspect program to check that all locations and components are
   2562  *   as expected.
   2563  **/
   2564 class VaryingComponentsTest : public VaryingLocationsTest
   2565 {
   2566 public:
   2567 	VaryingComponentsTest(deqp::Context& context);
   2568 
   2569 	VaryingComponentsTest(deqp::Context& context, const glw::GLchar* test_name, const glw::GLchar* test_description);
   2570 
   2571 	~VaryingComponentsTest()
   2572 	{
   2573 	}
   2574 
   2575 protected:
   2576 	/* Protected methods */
   2577 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   2578 									 Utils::VaryingPassthrough& varying_passthrough);
   2579 
   2580 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2581 	virtual glw::GLuint getTestCaseNumber();
   2582 	virtual void		testInit();
   2583 	virtual bool useComponentQualifier(glw::GLuint test_case_index);
   2584 
   2585 	/* To be implemented by children */
   2586 	virtual glw::GLuint getArrayLength();
   2587 
   2588 private:
   2589 	/* Private enums */
   2590 	enum COMPONENTS_LAYOUT
   2591 	{
   2592 		GVEC4,
   2593 		SCALAR_GVEC3,
   2594 		GVEC3_SCALAR,
   2595 		GVEC2_GVEC2,
   2596 		GVEC2_SCALAR_SCALAR,
   2597 		SCALAR_GVEC2_SCALAR,
   2598 		SCALAR_SCALAR_GVEC2,
   2599 		SCALAR_SCALAR_SCALAR_SCALAR,
   2600 	};
   2601 
   2602 	/* Private struct */
   2603 	struct descriptor
   2604 	{
   2605 		void assign(glw::GLint component, const glw::GLchar* component_str, glw::GLint location,
   2606 					const glw::GLchar* location_str, glw::GLuint n_rows, const glw::GLchar* name);
   2607 
   2608 		glw::GLint		   m_component;
   2609 		const glw::GLchar* m_component_str;
   2610 		glw::GLint		   m_location;
   2611 		const glw::GLchar* m_location_str;
   2612 		glw::GLuint		   m_n_rows;
   2613 		const glw::GLchar* m_name;
   2614 	};
   2615 
   2616 	struct testCase
   2617 	{
   2618 		testCase(COMPONENTS_LAYOUT layout, Utils::Type::TYPES type);
   2619 
   2620 		COMPONENTS_LAYOUT  m_layout;
   2621 		Utils::Type::TYPES m_type;
   2622 	};
   2623 
   2624 	/* Private routines */
   2625 	std::string prepareGlobals(glw::GLuint last_in_location, glw::GLuint last_out_location);
   2626 
   2627 	std::string prepareName(const glw::GLchar* name, glw::GLint location, glw::GLint component,
   2628 							Utils::Shader::STAGES stage, Utils::Variable::STORAGE storage);
   2629 
   2630 	std::string prepareQualifiers(const glw::GLchar* location, const glw::GLchar* component,
   2631 								  const glw::GLchar* interpolation);
   2632 
   2633 	using VaryingLocationsTest::prepareShaderStage;
   2634 
   2635 	void prepareShaderStage(Utils::Shader::STAGES stage, const Utils::Type& vector_type,
   2636 							Utils::ProgramInterface& program_interface, const testCase& test_case,
   2637 							Utils::VaryingPassthrough& varying_passthrough);
   2638 
   2639 	Utils::Variable* prepareVarying(const Utils::Type& basic_type, const descriptor& desc,
   2640 									const glw::GLchar* interpolation, Utils::ShaderInterface& si,
   2641 									Utils::Shader::STAGES stage, Utils::Variable::STORAGE storage);
   2642 
   2643 	/* Private fields */
   2644 	std::vector<testCase>	 m_test_cases;
   2645 	std::vector<glw::GLubyte> m_data;
   2646 };
   2647 
   2648 /** Implementation of test VaryingArrayComponents. Description follows:
   2649  *
   2650  * Test verifies that arrays of "varyings" can be assigned to specific
   2651  * components.
   2652  *
   2653  * Modify VaryingComponents similarly to VaryingArrayLocations.
   2654  **/
   2655 class VaryingArrayComponentsTest : public VaryingComponentsTest
   2656 {
   2657 public:
   2658 	VaryingArrayComponentsTest(deqp::Context& context);
   2659 
   2660 	~VaryingArrayComponentsTest()
   2661 	{
   2662 	}
   2663 
   2664 protected:
   2665 	/* Protected methods */
   2666 	virtual glw::GLuint getArrayLength();
   2667 };
   2668 
   2669 /** Implementation of test VaryingExceedingComponents. Description follows:
   2670  *
   2671  * Test verifies that it is not allowed to exceed components.
   2672  *
   2673  * Test following code snippets:
   2674  *
   2675  *     layout (location = 1, component = COMPONENT) in type gohan;
   2676  *
   2677  * and
   2678  *
   2679  *     layout (location = 1, component = COMPONENT) in type gohan[LENGTH];
   2680  *
   2681  * Select COMPONENT so as to exceed space available at location, eg. 2 for
   2682  * vec4. Select array length so as to not exceed limits of available locations.
   2683  *
   2684  * Test all types. Test all shader stages. Test both in and out varyings.
   2685  *
   2686  * It is expected that build process will fail.
   2687  **/
   2688 class VaryingExceedingComponentsTest : public NegativeTestBase
   2689 {
   2690 public:
   2691 	/* Public methods */
   2692 	VaryingExceedingComponentsTest(deqp::Context& context);
   2693 
   2694 	virtual ~VaryingExceedingComponentsTest()
   2695 	{
   2696 	}
   2697 
   2698 protected:
   2699 	/* Methods to be implemented by child class */
   2700 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   2701 
   2702 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2703 	virtual glw::GLuint getTestCaseNumber();
   2704 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2705 	virtual void testInit();
   2706 
   2707 private:
   2708 	/* Private types */
   2709 	struct testCase
   2710 	{
   2711 		glw::GLuint			  m_component;
   2712 		bool				  m_is_input;
   2713 		bool				  m_is_array;
   2714 		Utils::Shader::STAGES m_stage;
   2715 		Utils::Type			  m_type;
   2716 	};
   2717 
   2718 	/* Private fields */
   2719 	std::vector<testCase> m_test_cases;
   2720 };
   2721 
   2722 /** Implementation of test VaryingComponentWithoutLocation. Description follows:
   2723  *
   2724  * Test verifies that "component" qualifier cannot be used without "location"
   2725  * qualifier.
   2726  *
   2727  * Test following code snippet:
   2728  *
   2729  *     layout (component = COMPONENT) in type goku;
   2730  *
   2731  * Test all types. Test all valid COMPONENT values. Test all shader stages.
   2732  * Test both in and out varyings.
   2733  *
   2734  * It is expected that shader compilation will fail.
   2735  **/
   2736 class VaryingComponentWithoutLocationTest : public NegativeTestBase
   2737 {
   2738 public:
   2739 	/* Public methods */
   2740 	VaryingComponentWithoutLocationTest(deqp::Context& context);
   2741 
   2742 	virtual ~VaryingComponentWithoutLocationTest()
   2743 	{
   2744 	}
   2745 
   2746 protected:
   2747 	/* Methods to be implemented by child class */
   2748 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   2749 
   2750 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2751 	virtual glw::GLuint getTestCaseNumber();
   2752 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2753 	virtual void testInit();
   2754 
   2755 private:
   2756 	/* Private types */
   2757 	struct testCase
   2758 	{
   2759 		glw::GLuint			  m_component;
   2760 		bool				  m_is_input;
   2761 		Utils::Shader::STAGES m_stage;
   2762 		Utils::Type			  m_type;
   2763 	};
   2764 
   2765 	/* Private fields */
   2766 	std::vector<testCase> m_test_cases;
   2767 };
   2768 
   2769 /** Implementation of test VaryingComponentOfInvalidType. Description follows:
   2770  *
   2771  * Test verifies that it is not allowed to declare matrix, struct, block and
   2772  * array of those at specific component.
   2773  *
   2774  * Test following code snippets:
   2775  *
   2776  *     layout (location = 0, component = COMPONENT) in matrix_type varying;
   2777  *
   2778  * ,
   2779  *
   2780  *     layout (location = 0, component = COMPONENT)
   2781  *         in matrix_type varying[LENGTH];
   2782  *
   2783  * ,
   2784  *
   2785  *     layout (location = 0, component = COMPONENT) in Block
   2786  *     {
   2787  *         type member;
   2788  *     };
   2789  *
   2790  * ,
   2791  *
   2792  *     layout (location = 0, component = COMPONENT) in Block
   2793  *     {
   2794  *         type member;
   2795  *     } block[LENGTH];
   2796  *
   2797  * ,
   2798  *
   2799  *     struct Data
   2800  *     {
   2801  *         type member;
   2802  *     };
   2803  *
   2804  *     layout (location = 0, component = COMPONENT) in Data varying;
   2805  *
   2806  * and
   2807  *
   2808  *     struct Data
   2809  *     {
   2810  *         type member;
   2811  *     };
   2812  *
   2813  *     layout (location = 0, component = COMPONENT) in Data varying[LENGTH];
   2814  *
   2815  * Test all types. Test all shader stages. Test both in and out varyings.
   2816  *
   2817  * It is expected that build process will fail.
   2818  **/
   2819 class VaryingComponentOfInvalidTypeTest : public NegativeTestBase
   2820 {
   2821 public:
   2822 	/* Public methods */
   2823 	VaryingComponentOfInvalidTypeTest(deqp::Context& context);
   2824 
   2825 	virtual ~VaryingComponentOfInvalidTypeTest()
   2826 	{
   2827 	}
   2828 
   2829 protected:
   2830 	/* Methods to be implemented by child class */
   2831 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   2832 
   2833 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2834 	virtual glw::GLuint getTestCaseNumber();
   2835 
   2836 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2837 	virtual void testInit();
   2838 
   2839 private:
   2840 	/* Private enums */
   2841 	enum CASES
   2842 	{
   2843 		MATRIX = 0,
   2844 		BLOCK,
   2845 		STRUCT,
   2846 
   2847 		/* */
   2848 		MAX_CASES
   2849 	};
   2850 
   2851 	/* Private types */
   2852 	struct testCase
   2853 	{
   2854 		CASES				  m_case;
   2855 		glw::GLuint			  m_component;
   2856 		bool				  m_is_array;
   2857 		bool				  m_is_input;
   2858 		Utils::Shader::STAGES m_stage;
   2859 		Utils::Type			  m_type;
   2860 	};
   2861 
   2862 	/* Private fields */
   2863 	std::vector<testCase> m_test_cases;
   2864 };
   2865 
   2866 /** Implementation of test InputComponentAliasing. Description follows:
   2867  *
   2868  * Test verifies that component aliasing cause compilation or linking error.
   2869  *
   2870  * Test following code snippet:
   2871  *
   2872  *     layout (location = 1, component = GOHAN_COMPONENT) in type gohan;
   2873  *     layout (location = 1, component = GOTEN_COMPONENT) in type goten;
   2874  *
   2875  *     if (EXPECTED_VALUE == gohan)
   2876  *     {
   2877  *         result = 1;
   2878  *     }
   2879  *
   2880  * Test all components combinations that cause aliasing. Test all types. Test
   2881  * all shader stages. It is expected that build process will fail.
   2882  *
   2883  * Vertex shader allows component aliasing on input as long as only one of the
   2884  * attributes is used in each execution path. Test vertex shader stage with two
   2885  * variants:
   2886  *     - first as presented above,
   2887  *     - second, where "result = 1;" is replaced with "result = goten;".
   2888  * In first case build process should succeed, in the second case build process
   2889  * should fail.
   2890  **/
   2891 class InputComponentAliasingTest : public NegativeTestBase
   2892 {
   2893 public:
   2894 	/* Public methods */
   2895 	InputComponentAliasingTest(deqp::Context& context);
   2896 
   2897 	virtual ~InputComponentAliasingTest()
   2898 	{
   2899 	}
   2900 
   2901 protected:
   2902 	/* Methods to be implemented by child class */
   2903 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   2904 
   2905 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2906 	virtual glw::GLuint getTestCaseNumber();
   2907 
   2908 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2909 	virtual bool isFailureExpected(glw::GLuint test_case_index);
   2910 	virtual void testInit();
   2911 
   2912 private:
   2913 	/* Private types */
   2914 	struct testCase
   2915 	{
   2916 		glw::GLuint			  m_component_gohan;
   2917 		glw::GLuint			  m_component_goten;
   2918 		Utils::Shader::STAGES m_stage;
   2919 		Utils::Type			  m_type;
   2920 	};
   2921 
   2922 	/* Private fields */
   2923 	std::vector<testCase> m_test_cases;
   2924 };
   2925 
   2926 /** Implementation of test OutputComponentAliasing. Description follows:
   2927  *
   2928  * Test verifies that component aliasing cause compilation or linking error.
   2929  *
   2930  * Test following code snippet:
   2931  *
   2932  *     layout (location = 1, component = GOHAN_COMPONENT) out type gohan;
   2933  *     layout (location = 1, component = GOTEN_COMPONENT) out type goten;
   2934  *
   2935  *     gohan = GOHAN_VALUE;
   2936  *     goten = GOTEN_VALUE;
   2937  *
   2938  * Test all components combinations that cause aliasing. Test all types. Test
   2939  * all shader stages. It is expected that build process will fail.
   2940  **/
   2941 class OutputComponentAliasingTest : public NegativeTestBase
   2942 {
   2943 public:
   2944 	/* Public methods */
   2945 	OutputComponentAliasingTest(deqp::Context& context);
   2946 
   2947 	virtual ~OutputComponentAliasingTest()
   2948 	{
   2949 	}
   2950 
   2951 protected:
   2952 	/* Methods to be implemented by child class */
   2953 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   2954 
   2955 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   2956 	virtual glw::GLuint getTestCaseNumber();
   2957 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   2958 	virtual void testInit();
   2959 
   2960 private:
   2961 	/* Private types */
   2962 	struct testCase
   2963 	{
   2964 		glw::GLuint			  m_component_gohan;
   2965 		glw::GLuint			  m_component_goten;
   2966 		Utils::Shader::STAGES m_stage;
   2967 		Utils::Type			  m_type;
   2968 	};
   2969 
   2970 	/* Private fields */
   2971 	std::vector<testCase> m_test_cases;
   2972 };
   2973 
   2974 /** Implementation of test VaryingLocationAliasingWithMixedTypes. Description follows:
   2975  *
   2976  * Test verifies that it is not allowed to mix integer and float base types at
   2977  * aliased location.
   2978  *
   2979  * Test following code snippet:
   2980  *
   2981  *     layout (location = 1, component = GOHAN_COMPONENT) in gohan_type gohan;
   2982  *     layout (location = 1, component = GOTEN_COMPONENT) in goten_type goten;
   2983  *
   2984  * Test all components combinations that do not cause component aliasing. Test
   2985  * all types combinations that cause float/integer conflict. Test all shader
   2986  * stages. Test both in and out varyings.
   2987  *
   2988  * It is expected that build process will fail.
   2989  **/
   2990 class VaryingLocationAliasingWithMixedTypesTest : public NegativeTestBase
   2991 {
   2992 public:
   2993 	/* Public methods */
   2994 	VaryingLocationAliasingWithMixedTypesTest(deqp::Context& context);
   2995 
   2996 	virtual ~VaryingLocationAliasingWithMixedTypesTest()
   2997 	{
   2998 	}
   2999 
   3000 protected:
   3001 	/* Methods to be implemented by child class */
   3002 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   3003 
   3004 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3005 	virtual glw::GLuint getTestCaseNumber();
   3006 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   3007 	virtual void testInit();
   3008 
   3009 private:
   3010 	/* Private types */
   3011 	struct testCase
   3012 	{
   3013 		glw::GLuint			  m_component_gohan;
   3014 		glw::GLuint			  m_component_goten;
   3015 		bool				  m_is_input;
   3016 		Utils::Shader::STAGES m_stage;
   3017 		Utils::Type			  m_type_gohan;
   3018 		Utils::Type			  m_type_goten;
   3019 	};
   3020 
   3021 	/* Private routines */
   3022 	bool isFloatType(const Utils::Type& type);
   3023 
   3024 	/* Private fields */
   3025 	std::vector<testCase> m_test_cases;
   3026 };
   3027 
   3028 /** Implementation of test VaryingLocationAliasingWithMixedInterpolation. Description follows:
   3029  *
   3030  * Test verifies that it is not allowed to mix interpolation methods at aliased
   3031  * location.
   3032  *
   3033  * Test following code snippet:
   3034  *
   3035  *     layout (location = 1, component = GOHAN_COMPONENT)
   3036  *         GOHAN_INTERPOLATION in type gohan;
   3037  *     layout (location = 1, component = GOTEN_COMPONENT)
   3038  *         GOTEN_INTERPOLATION in type goten;
   3039  *
   3040  * Test all interpolation combinations that cause conflict. Select components
   3041  * so as not to cause component aliasing. Test all types. Test all shader
   3042  * stages. Test both in and out varyings.
   3043  *
   3044  * Note, that vertex shader's input and fragment shader's output cannot be
   3045  * qualified with interpolation method.
   3046  *
   3047  * It is expected that build process will fail.
   3048  **/
   3049 class VaryingLocationAliasingWithMixedInterpolationTest : public NegativeTestBase
   3050 {
   3051 public:
   3052 	/* Public methods */
   3053 	VaryingLocationAliasingWithMixedInterpolationTest(deqp::Context& context);
   3054 
   3055 	virtual ~VaryingLocationAliasingWithMixedInterpolationTest()
   3056 	{
   3057 	}
   3058 
   3059 protected:
   3060 	/* Methods to be implemented by child class */
   3061 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   3062 
   3063 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3064 	virtual glw::GLuint getTestCaseNumber();
   3065 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   3066 	virtual void testInit();
   3067 
   3068 private:
   3069 	enum INTERPOLATIONS
   3070 	{
   3071 		SMOOTH = 0,
   3072 		FLAT,
   3073 		NO_PERSPECTIVE,
   3074 
   3075 		/* */
   3076 		INTERPOLATION_MAX
   3077 	};
   3078 
   3079 	/* Private types */
   3080 	struct testCase
   3081 	{
   3082 		glw::GLuint			  m_component_gohan;
   3083 		glw::GLuint			  m_component_goten;
   3084 		INTERPOLATIONS		  m_interpolation_gohan;
   3085 		INTERPOLATIONS		  m_interpolation_goten;
   3086 		bool				  m_is_input;
   3087 		Utils::Shader::STAGES m_stage;
   3088 		Utils::Type			  m_type_gohan;
   3089 		Utils::Type			  m_type_goten;
   3090 	};
   3091 
   3092 	/* Private routines */
   3093 	const glw::GLchar* getInterpolationQualifier(INTERPOLATIONS interpolation);
   3094 	bool isFloatType(const Utils::Type& type);
   3095 
   3096 	/* Private fields */
   3097 	std::vector<testCase> m_test_cases;
   3098 };
   3099 
   3100 /** Implementation of test VaryingLocationAliasingWithMixedAuxiliaryStorage. Description follows:
   3101  *
   3102  * Test verifies that it is not allowed to mix auxiliary storage at aliased
   3103  * location.
   3104  *
   3105  * Test following code snippet:
   3106  *
   3107  * layout (location = 1, component = GOHAN_COMPONENT)
   3108  *     GOHAN_AUXILIARY in type gohan;
   3109  * layout (location = 1, component = GOTEN_COMPONENT)
   3110  *     GOTEN_AUXILIARY in type goten;
   3111  *
   3112  * Test all auxiliary storage combinations that cause conflict. Select
   3113  * components so as not to cause component aliasing. Test all types. Test all
   3114  * shader stages. Test both in and out varyings.
   3115  *
   3116  * It is expected that build process will fail.
   3117  **/
   3118 class VaryingLocationAliasingWithMixedAuxiliaryStorageTest : public NegativeTestBase
   3119 {
   3120 public:
   3121 	/* Public methods */
   3122 	VaryingLocationAliasingWithMixedAuxiliaryStorageTest(deqp::Context& context);
   3123 
   3124 	virtual ~VaryingLocationAliasingWithMixedAuxiliaryStorageTest()
   3125 	{
   3126 	}
   3127 
   3128 protected:
   3129 	/* Methods to be implemented by child class */
   3130 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   3131 
   3132 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3133 	virtual glw::GLuint getTestCaseNumber();
   3134 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   3135 	virtual void testInit();
   3136 
   3137 private:
   3138 	enum AUXILIARIES
   3139 	{
   3140 		NONE = 0,
   3141 		PATCH,
   3142 		CENTROID,
   3143 		SAMPLE,
   3144 
   3145 		/* */
   3146 		AUXILIARY_MAX
   3147 	};
   3148 
   3149 	/* Private types */
   3150 	struct testCase
   3151 	{
   3152 		glw::GLuint			  m_component_gohan;
   3153 		glw::GLuint			  m_component_goten;
   3154 		AUXILIARIES			  m_aux_gohan;
   3155 		AUXILIARIES			  m_aux_goten;
   3156 		const glw::GLchar*	m_int_gohan;
   3157 		const glw::GLchar*	m_int_goten;
   3158 		bool				  m_is_input;
   3159 		Utils::Shader::STAGES m_stage;
   3160 		Utils::Type			  m_type_gohan;
   3161 		Utils::Type			  m_type_goten;
   3162 	};
   3163 
   3164 	/* Private routines */
   3165 	const glw::GLchar* getAuxiliaryQualifier(AUXILIARIES aux);
   3166 	bool isFloatType(const Utils::Type& type);
   3167 
   3168 	/* Private fields */
   3169 	std::vector<testCase> m_test_cases;
   3170 };
   3171 
   3172 /** Implementation of test VertexAttribLocationAPI. Description follows:
   3173  *
   3174  * Test verifies that vertex attribute location API works as expected.
   3175  *
   3176  * This test implements Texture algorithm. Tessellation shaders are not
   3177  * necessary and can be omitted. Test following code snippet in vertex shader:
   3178  *
   3179  *     layout (location = GOKU_LOCATION) in vec4 goku;
   3180  *                                       in vec4 gohan;
   3181  *                                       in vec4 goten;
   3182  *                                       in vec4 chichi;
   3183  *
   3184  *     if ( (EXPECTED_VALUE == goku)   &&
   3185  *          (EXPECTED_VALUE == gohan)  &&
   3186  *          (EXPECTED_VALUE == gotan)  &&
   3187  *          (EXPECTED_VALUE == chichi) )
   3188  *     {
   3189  *         result = 1;
   3190  *     }
   3191  *
   3192  * After compilation, before program is linked, specify locations for goku,
   3193  * and goten with glBindAttribLocation. Specify different location than the one
   3194  * used in shader.
   3195  *
   3196  * Select all locations so as not to exceed any limits.
   3197  *
   3198  * Additionally inspect program to verify that:
   3199  *     - goku location is as specified in shader text,
   3200  *     - goten location is as specified with API.
   3201  **/
   3202 class VertexAttribLocationAPITest : public TextureTestBase
   3203 {
   3204 public:
   3205 	VertexAttribLocationAPITest(deqp::Context& context);
   3206 
   3207 	~VertexAttribLocationAPITest()
   3208 	{
   3209 	}
   3210 
   3211 protected:
   3212 	/* Protected methods */
   3213 	virtual void prepareAttribLocation(Utils::Program& program, Utils::ProgramInterface& program_interface);
   3214 
   3215 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   3216 									 Utils::VaryingPassthrough& varying_passthrough);
   3217 
   3218 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   3219 
   3220 private:
   3221 	/* Private fields */
   3222 	std::vector<glw::GLubyte> m_goku_data;
   3223 	std::vector<glw::GLubyte> m_gohan_data;
   3224 	std::vector<glw::GLubyte> m_goten_data;
   3225 	std::vector<glw::GLubyte> m_chichi_data;
   3226 
   3227 	/* Private constants */
   3228 	static const glw::GLuint m_goten_location;
   3229 };
   3230 /** Implementation of test FragmentDataLocationAPI. Description follows:
   3231  *
   3232  * Test verifies that fragment data location API works as expected.
   3233  *
   3234  * This test implements Texture algorithm. Tessellation shaders are not
   3235  * necessary and can be omitted. "result" is not necessary and can be omitted.
   3236  * Test following code snippet in fragment shader:
   3237  *
   3238  *     layout (location = GOKU_LOCATION)  out vec4 goku;
   3239  *                                        out vec4 gohan;
   3240  *                                        out vec4 goten;
   3241  *                                        out vec4 chichi;
   3242  *
   3243  *     goku   = EXPECTED_VALUE;
   3244  *     gohan  = EXPECTED_VALUE;
   3245  *     goten  = EXPECTED_VALUE;
   3246  *     chichi = EXPECTED_VALUE;
   3247  *
   3248  * After compilation, before program is linked, specify locations for goku,
   3249  * and goten with glBindFragDataLocation. Specify different location than the
   3250  * one used in shader.
   3251  *
   3252  * Select all locations so as not to exceed any limits.
   3253  *
   3254  * Additionally inspect program to verify that:
   3255  *     - goku location is as specified in shader text,
   3256  *     - goten location is as specified with API.
   3257  **/
   3258 class FragmentDataLocationAPITest : public TextureTestBase
   3259 {
   3260 public:
   3261 	FragmentDataLocationAPITest(deqp::Context& context);
   3262 
   3263 	~FragmentDataLocationAPITest()
   3264 	{
   3265 	}
   3266 
   3267 protected:
   3268 	/* Protected methods */
   3269 	virtual bool checkResults(glw::GLuint test_case_index, Utils::Texture& color_0);
   3270 
   3271 	virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough& varying_passthrough,
   3272 									   Utils::Shader::STAGES stage);
   3273 
   3274 	virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface& program_interface,
   3275 									 Utils::VaryingPassthrough& varying_passthrough);
   3276 
   3277 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   3278 
   3279 	virtual void prepareFragmentDataLoc(Utils::Program& program, Utils::ProgramInterface& program_interface);
   3280 
   3281 	virtual void prepareFramebuffer(Utils::Framebuffer& framebuffer, Utils::Texture& color_0_texture);
   3282 
   3283 private:
   3284 	/* Private fields */
   3285 	Utils::Texture m_goku;
   3286 	Utils::Texture m_gohan;
   3287 	Utils::Texture m_goten;
   3288 	Utils::Texture m_chichi;
   3289 
   3290 	glw::GLint m_goku_location;
   3291 	glw::GLint m_gohan_location;
   3292 	glw::GLint m_chichi_location;
   3293 
   3294 	/* Private constants */
   3295 	static const glw::GLuint m_goten_location;
   3296 };
   3297 
   3298 /** Implementation of test XFBInput. Description follows:
   3299  *
   3300  * Test verifies that using xfb_buffer, xfb_stride or xfb_offset qualifiers on
   3301  * input variables will cause failure of build process.
   3302  *
   3303  * Test all shader stages.
   3304  **/
   3305 class XFBInputTest : public NegativeTestBase
   3306 {
   3307 public:
   3308 	/* Public methods */
   3309 	XFBInputTest(deqp::Context& context);
   3310 	virtual ~XFBInputTest()
   3311 	{
   3312 	}
   3313 
   3314 protected:
   3315 	/* Methods to be implemented by child class */
   3316 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   3317 
   3318 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3319 	virtual glw::GLuint getTestCaseNumber();
   3320 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   3321 	virtual void testInit();
   3322 
   3323 private:
   3324 	enum QUALIFIERS
   3325 	{
   3326 		BUFFER = 0,
   3327 		STRIDE,
   3328 		OFFSET,
   3329 
   3330 		/* */
   3331 		QUALIFIERS_MAX
   3332 	};
   3333 
   3334 	/* Private types */
   3335 	struct testCase
   3336 	{
   3337 		QUALIFIERS			  m_qualifier;
   3338 		Utils::Shader::STAGES m_stage;
   3339 	};
   3340 
   3341 	/* Private fields */
   3342 	std::vector<testCase> m_test_cases;
   3343 };
   3344 
   3345 /** Implementation of test XFBAllStages. Description follows:
   3346  *
   3347  * Test verifies that only outputs from last stage processing primitives can be
   3348  * captured with XFB.
   3349  *
   3350  * This test implements Buffer algorithm. Rasterization can be discarded.
   3351  *
   3352  * At each stage declare a single active output variable qualified with
   3353  * xfb_buffer and xfb_offset = 0. Use separate buffers for each stage.
   3354  *
   3355  * Test pass if outputs from geometry shader are captured, while outputs from:
   3356  * vertex and tessellation stages are ignored.
   3357  **/
   3358 class XFBAllStagesTest : public BufferTestBase
   3359 {
   3360 public:
   3361 	XFBAllStagesTest(deqp::Context& context);
   3362 
   3363 	~XFBAllStagesTest()
   3364 	{
   3365 	}
   3366 
   3367 protected:
   3368 	/* Protected methods */
   3369 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   3370 
   3371 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   3372 							   std::string& out_calculations);
   3373 
   3374 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   3375 									std::string& out_interface);
   3376 
   3377 private:
   3378 	/* Constants */
   3379 	static const glw::GLuint m_gs_index;
   3380 };
   3381 
   3382 /** Implementation of test XFBStrideOfEmptyList. Description follows:
   3383  *
   3384  * Test verifies that xfb_stride directive is respected even if there are no
   3385  * variables qualified with xfb_offset.
   3386  *
   3387  * Test implements Buffer algorithm. Rasterization can be discarded.
   3388  *
   3389  * Test following code snippet:
   3390  *
   3391  *     layout (xfb_buffer = 1, xfb_stride = 64) out;
   3392  *
   3393  * Moreover program should output something to xfb at index 0
   3394  *
   3395  * Test following cases:
   3396  *     1 Provide buffers to XFB at index 0 and 1
   3397  *     2 Provide buffer to XFB at index 1, index 0 should be missing
   3398  *     3 Provide buffer to XFB at index 0, index 1 should be missing
   3399  *
   3400  * It is expected that:
   3401  *     - BeginTransformFeedback operation will report GL_INVALID_OPERATION in cases
   3402  *     2 and 3,
   3403  *     - XFB at index 1 will not be modified in case 1.
   3404  **/
   3405 class XFBStrideOfEmptyListTest : public BufferTestBase
   3406 {
   3407 public:
   3408 	XFBStrideOfEmptyListTest(deqp::Context& context);
   3409 
   3410 	~XFBStrideOfEmptyListTest()
   3411 	{
   3412 	}
   3413 
   3414 protected:
   3415 	/* Protected methods */
   3416 	using BufferTestBase::executeDrawCall;
   3417 	virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index);
   3418 
   3419 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   3420 
   3421 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   3422 							   std::string& out_calculations);
   3423 
   3424 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   3425 									std::string& out_interface);
   3426 
   3427 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3428 	virtual glw::GLuint getTestCaseNumber();
   3429 
   3430 private:
   3431 	enum CASES
   3432 	{
   3433 		VALID = 0,
   3434 		FIRST_MISSING,
   3435 		SECOND_MISSING,
   3436 	};
   3437 
   3438 	/* Private constants */
   3439 	static const glw::GLuint m_stride;
   3440 };
   3441 
   3442 /** Implementation of test XFBStrideOfEmptyListAndAPI. Description follows:
   3443  *
   3444  * Test verifies that xfb_stride qualifier is not overridden by API.
   3445  *
   3446  * Test implements Buffer algorithm. Rasterization can be discarded.
   3447  *
   3448  * Test following code snippet:
   3449  *
   3450  *     layout (xfb_buffer = 0, xfb_stride = 64) out;
   3451  *
   3452  * Moreover program should output something to xfb at index 1
   3453 
   3454  * Use TransformFeedbackVaryings to declare a single vec4 output variable to be
   3455  * captured.
   3456  *
   3457  * Test following cases:
   3458  *     1 Provide buffers to XFB at index 0 and 1
   3459  *     2 Provide buffer to XFB at index 1, index 0 should be missing
   3460  *     3 Provide buffer to XFB at index 0, index 1 should be missing
   3461  *
   3462  * It is expected that:
   3463  *     - BeginTransformFeedback operation will report GL_INVALID_OPERATION in cases
   3464  *     2 and 3,
   3465  *     - XFB at index 0 will not be modified in case 1.
   3466  **/
   3467 class XFBStrideOfEmptyListAndAPITest : public BufferTestBase
   3468 {
   3469 public:
   3470 	XFBStrideOfEmptyListAndAPITest(deqp::Context& context);
   3471 
   3472 	~XFBStrideOfEmptyListAndAPITest()
   3473 	{
   3474 	}
   3475 
   3476 protected:
   3477 	/* Protected methods */
   3478 	using BufferTestBase::executeDrawCall;
   3479 	virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index);
   3480 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   3481 
   3482 	virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector& captured_varyings);
   3483 
   3484 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   3485 							   std::string& out_calculations);
   3486 
   3487 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   3488 									std::string& out_interface);
   3489 
   3490 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3491 	virtual glw::GLuint getTestCaseNumber();
   3492 
   3493 private:
   3494 	enum CASES
   3495 	{
   3496 		VALID = 0,
   3497 		FIRST_MISSING,
   3498 		SECOND_MISSING,
   3499 	};
   3500 
   3501 	/* Private constants */
   3502 	static const glw::GLuint m_stride;
   3503 };
   3504 
   3505 /** Implementation of test XFBTooSmallStride. Description follows:
   3506  *
   3507  * Test verifies that build process fails when xfb_stride qualifier sets not
   3508  * enough space for all variables.
   3509  *
   3510  * Test following code snippets:
   3511  *
   3512  *     layout (xfb_buffer = 0, xfb_stride = 40) out;
   3513  *
   3514  *     layout (xfb_offset = 32) out vec4 goku;
   3515  *
   3516  *     goku = EXPECTED_VALUE.
   3517  *
   3518  * ,
   3519  *
   3520  *     layout (xfb_buffer = 0, xfb_stride = 32) out;
   3521  *
   3522  *     layout (xfb_offset = 16, xfb_stride = 32) out vec4 goku;
   3523  *
   3524  *     goku = EXPECTED_VALUE.
   3525  *
   3526  * ,
   3527  *
   3528  *     layout (xfb_buffer = 0, xfb_stride = 32) out;
   3529  *
   3530  *     layout (xfb_offset = 0) out Goku {
   3531  *         vec4 gohan;
   3532  *         vec4 goten;
   3533  *         vec4 chichi;
   3534  *     };
   3535  *
   3536  *     gohan  = EXPECTED_VALUE;
   3537  *     goten  = EXPECTED_VALUE;
   3538  *     chichi = EXPECTED_VALUE;
   3539  *
   3540  * ,
   3541  *
   3542  *     layout (xfb_buffer = 0, xfb_stride = 32) out;
   3543  *
   3544  *     layout (xfb_offset = 16) out vec4 goku[4];
   3545  *
   3546  *     goku[0] = EXPECTED_VALUE.
   3547  *     goku[1] = EXPECTED_VALUE.
   3548  *     goku[2] = EXPECTED_VALUE.
   3549  *     goku[3] = EXPECTED_VALUE.
   3550  *
   3551  * It is expected that build process will fail.
   3552  *
   3553  * Test all shader stages.
   3554  **/
   3555 class XFBTooSmallStrideTest : public NegativeTestBase
   3556 {
   3557 public:
   3558 	/* Public methods */
   3559 	XFBTooSmallStrideTest(deqp::Context& context);
   3560 
   3561 	virtual ~XFBTooSmallStrideTest()
   3562 	{
   3563 	}
   3564 
   3565 protected:
   3566 	/* Methods to be implemented by child class */
   3567 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   3568 
   3569 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3570 	virtual glw::GLuint getTestCaseNumber();
   3571 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   3572 	virtual void testInit();
   3573 
   3574 private:
   3575 	enum CASES
   3576 	{
   3577 		OFFSET = 0,
   3578 		STRIDE,
   3579 		BLOCK,
   3580 		ARRAY,
   3581 
   3582 		/* */
   3583 		CASE_MAX
   3584 	};
   3585 
   3586 	/* Private types */
   3587 	struct testCase
   3588 	{
   3589 		CASES				  m_case;
   3590 		Utils::Shader::STAGES m_stage;
   3591 	};
   3592 
   3593 	/* Private fields */
   3594 	std::vector<testCase> m_test_cases;
   3595 };
   3596 
   3597 /** Implementation of test XFBVariableStride. Description follows:
   3598  *
   3599  * Test verifies that xfb_stride qualifier change stride of output variable.
   3600  *
   3601  * Test following code snippets:
   3602  *
   3603  *     layout (xfb_offset = 0, xfb_stride = 2 * sizeof(type)) out type goku;
   3604  *
   3605  * and
   3606  *
   3607  *     layout (xfb_offset = 0, xfb_stride = 2 * sizeof(type)) out type goku;
   3608  *     layout (xfb_offset = sizeof(type))                     out type vegeta;
   3609  *
   3610  * It is expected that:
   3611  *     - first snippet will build successfully,
   3612  *     - second snippet will fail to build.
   3613  *
   3614  * Test all types. Test all shader stages.
   3615  **/
   3616 class XFBVariableStrideTest : public NegativeTestBase
   3617 {
   3618 public:
   3619 	/* Public methods */
   3620 	XFBVariableStrideTest(deqp::Context& context);
   3621 	virtual ~XFBVariableStrideTest()
   3622 	{
   3623 	}
   3624 
   3625 protected:
   3626 	/* Methods to be implemented by child class */
   3627 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   3628 
   3629 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3630 	virtual glw::GLuint getTestCaseNumber();
   3631 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   3632 	virtual bool isFailureExpected(glw::GLuint test_case_index);
   3633 	virtual void testInit();
   3634 
   3635 private:
   3636 	enum CASES
   3637 	{
   3638 		VALID = 0,
   3639 		INVALID,
   3640 
   3641 		/* */
   3642 		CASE_MAX
   3643 	};
   3644 
   3645 	/* Private types */
   3646 	struct testCase
   3647 	{
   3648 		CASES				  m_case;
   3649 		Utils::Shader::STAGES m_stage;
   3650 		Utils::Type			  m_type;
   3651 	};
   3652 
   3653 	/* Private fields */
   3654 	std::vector<testCase> m_test_cases;
   3655 };
   3656 
   3657 /** Implementation of test XFBBlockStride. Description follows:
   3658  *
   3659  * Test verifies that xfb_stride qualifier change stride of output block.
   3660  *
   3661  * Test following code snippet:
   3662  *
   3663  *     layout (xfb_offset = 0, xfb_stride = 128) out Goku {
   3664  *         vec4 gohan;
   3665  *         vec4 goten;
   3666  *         vec4 chichi;
   3667  *     };
   3668  *
   3669  * Inspect program to check if Goku stride is 128 units.
   3670  *
   3671  * Test all shader stages.
   3672  **/
   3673 class XFBBlockStrideTest : public TestBase
   3674 {
   3675 public:
   3676 	/* Public methods */
   3677 	XFBBlockStrideTest(deqp::Context& context);
   3678 
   3679 	virtual ~XFBBlockStrideTest()
   3680 	{
   3681 	}
   3682 
   3683 protected:
   3684 	/* Methods to be implemented by child class */
   3685 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3686 	virtual glw::GLuint getTestCaseNumber();
   3687 	virtual bool testCase(glw::GLuint test_case_index);
   3688 	virtual void testInit();
   3689 
   3690 private:
   3691 	/* Private methods */
   3692 	std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   3693 
   3694 	bool inspectProgram(Utils::Program& program);
   3695 
   3696 	/* Private fields */
   3697 	std::vector<Utils::Shader::STAGES> m_test_cases;
   3698 };
   3699 
   3700 /** Implementation of test XFBBlockMemberStride. Description follows:
   3701  *
   3702  * Test verifies that xfb_stride qualifier change stride of output block
   3703  * member.
   3704  *
   3705  * This test implements Buffer algorithm. Rasterization can be discarded. Test
   3706  * following code snippet:
   3707  *
   3708  *     layout (xfb_offset = 0) out Goku {
   3709  *                                  vec4 gohan;
   3710  *         layout (xfb_stride = 32) vec4 goten;
   3711  *                                  vec4 chichi;
   3712  *     };
   3713  *
   3714  *     gohan  = EXPECTED_VALUE;
   3715  *     goten  = EXPECTED_VALUE;
   3716  *     chichi = EXPECTED_VALUE;
   3717  *
   3718  * Test pass if:
   3719  *     - goten stride is reported as 32,
   3720  *     - chichi offset is reported as 48,
   3721  *     - values captured for all members match expected values,
   3722  *     - part of memory reserved for goten, that is not used, is not modified.
   3723  **/
   3724 class XFBBlockMemberStrideTest : public BufferTestBase
   3725 {
   3726 public:
   3727 	XFBBlockMemberStrideTest(deqp::Context& context);
   3728 	~XFBBlockMemberStrideTest()
   3729 	{
   3730 	}
   3731 
   3732 protected:
   3733 	/* Protected methods */
   3734 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   3735 
   3736 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   3737 							   std::string& out_calculations);
   3738 
   3739 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   3740 									std::string& out_interface);
   3741 
   3742 	virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program& program, std::stringstream& out_stream);
   3743 };
   3744 
   3745 /** Implementation of test XFBDuplicatedStride. Description follows:
   3746  *
   3747  * Test verifies that conflicting xfb_stride qualifiers cause build process
   3748  * failure.
   3749  *
   3750  * Test following code snippets:
   3751  *
   3752  *     layout (xfb_buffer = 0, xfb_stride = 64) out;
   3753  *     layout (xfb_buffer = 0, xfb_stride = 64) out;
   3754  *
   3755  * and
   3756  *
   3757  *     layout (xfb_buffer = 0, xfb_stride = 64)  out;
   3758  *     layout (xfb_buffer = 0, xfb_stride = 128) out;
   3759  *
   3760  * It is expected that:
   3761  *     - first snippet will build successfully,
   3762  *     - second snippet will fail to build.
   3763  **/
   3764 class XFBDuplicatedStrideTest : public NegativeTestBase
   3765 {
   3766 public:
   3767 	/* Public methods */
   3768 	XFBDuplicatedStrideTest(deqp::Context& context);
   3769 
   3770 	virtual ~XFBDuplicatedStrideTest()
   3771 	{
   3772 	}
   3773 
   3774 protected:
   3775 	/* Methods to be implemented by child class */
   3776 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   3777 
   3778 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3779 	virtual glw::GLuint getTestCaseNumber();
   3780 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   3781 	virtual bool isFailureExpected(glw::GLuint test_case_index);
   3782 	virtual void testInit();
   3783 
   3784 private:
   3785 	enum CASES
   3786 	{
   3787 		VALID = 0,
   3788 		INVALID,
   3789 
   3790 		/* */
   3791 		CASE_MAX
   3792 	};
   3793 
   3794 	/* Private types */
   3795 	struct testCase
   3796 	{
   3797 		CASES				  m_case;
   3798 		Utils::Shader::STAGES m_stage;
   3799 	};
   3800 
   3801 	/* Private fields */
   3802 	std::vector<testCase> m_test_cases;
   3803 };
   3804 
   3805 /** Implementation of test XFBGetProgramResourceAPI. Description follows:
   3806  *
   3807  * Test verifies that GetProgramResource* API work as expected for transform
   3808  * feedback.
   3809  *
   3810  * Test results of following queries:
   3811  *     - OFFSET,
   3812  *     - TRANSFORM_FEEDBACK_BUFFER_INDEX,
   3813  *     - TRANSFORM_FEEDBACK_BUFFER_STRIDE,
   3814  *     - TYPE.
   3815  *
   3816  * Test following cases:
   3817  *     - captured varyings are declared with API, TransformFeedbackVaryings
   3818  *     with INTERLEAVED_ATTRIBS,
   3819  *     - captured varyings are declared with API, TransformFeedbackVaryings
   3820  *     with SEPARATE_ATTRIBS,
   3821  *     - captured varyings are declared with "xfb" qualifiers.
   3822  *
   3823  * Following layout should be used in cases of INTERLEAVED_ATTRIBS and "xfb"
   3824  * qualifiers:
   3825  *              | var 0 | var 1 | var 2 | var 3
   3826  *     buffer 0 | used  | used  | empty | used
   3827  *     buffer 1 | empty | used  | empty | empty
   3828  *
   3829  * In "xfb" qualifiers case, use following snippet:
   3830  *
   3831  *     layout (xfb_buffer = 1, xfb_stride = 4 * sizeof(type)) out;
   3832  *
   3833  * Declaration in shader should use following order:
   3834  *     buffer_0_var_1
   3835  *     buffer_1_var_1
   3836  *     buffer_0_var_3
   3837  *     buffer_0_var_0
   3838  *
   3839  * To make sure that captured varyings are active, they should be assigned.
   3840  *
   3841  * Test all types. Test all shader stages.
   3842  **/
   3843 class XFBGetProgramResourceAPITest : public TestBase
   3844 {
   3845 public:
   3846 	/* Public methods */
   3847 	XFBGetProgramResourceAPITest(deqp::Context& context);
   3848 
   3849 	virtual ~XFBGetProgramResourceAPITest()
   3850 	{
   3851 	}
   3852 
   3853 protected:
   3854 	/* Methods to be implemented by child class */
   3855 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3856 	virtual glw::GLuint getTestCaseNumber();
   3857 	virtual bool testCase(glw::GLuint test_case_index);
   3858 	virtual void testInit();
   3859 	virtual void insertSkipComponents(int num_components, Utils::Program::NameVector& varyings);
   3860 
   3861 private:
   3862 	/* Private enums */
   3863 	enum CASES
   3864 	{
   3865 		INTERLEAVED,
   3866 		SEPARATED,
   3867 		XFB,
   3868 	};
   3869 
   3870 	/* Private types */
   3871 	struct test_Case
   3872 	{
   3873 		CASES				  m_case;
   3874 		Utils::Shader::STAGES m_stage;
   3875 		Utils::Type			  m_type;
   3876 	};
   3877 
   3878 	/* Private methods */
   3879 	std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   3880 
   3881 	bool inspectProgram(glw::GLuint test_case_index, Utils::Program& program);
   3882 
   3883 	/* Private fields */
   3884 	std::vector<test_Case> m_test_cases;
   3885 };
   3886 
   3887 /** Implementation of test XFBOverrideQualifiersWithAPI. Description follows:
   3888  *
   3889  * Test verifies that API is ignored, when qualifiers are in use.
   3890  *
   3891  * This test follows Buffer algorithm. Rasterization can disabled. Test
   3892  * following code snippet:
   3893  *
   3894  *     layout (xfb_offset = 2 * sizeof(type)) out type vegeta;
   3895  *                                            out type trunks;
   3896  *     layout (xfb_offset = 0)                out type goku;
   3897  *                                            out type gohan;
   3898  *
   3899  *     vegeta = EXPECTED_VALUE;
   3900  *     trunks = EXPECTED_VALUE;
   3901  *     goku   = EXPECTED_VALUE;
   3902  *     gohan  = EXPECTED_VALUE;
   3903  *
   3904  * Use API, TransformFeedbackVaryings, to specify trunks and gohan as outputs
   3905  * to be captured.
   3906  *
   3907  * Test pass if:
   3908  *     - correct values are captured for vegeta and goku,
   3909  *     - trunks and gohan are not captured,
   3910  *     - correct stride is reported.
   3911  *
   3912  * Test all types. Test all shader stages.
   3913  **/
   3914 class XFBOverrideQualifiersWithAPITest : public BufferTestBase
   3915 {
   3916 public:
   3917 	XFBOverrideQualifiersWithAPITest(deqp::Context& context);
   3918 
   3919 	~XFBOverrideQualifiersWithAPITest()
   3920 	{
   3921 	}
   3922 
   3923 protected:
   3924 	/* Protected methods */
   3925 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   3926 
   3927 	virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector& captured_varyings);
   3928 
   3929 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   3930 							   std::string& out_calculations);
   3931 
   3932 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   3933 									std::string& out_interface);
   3934 
   3935 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   3936 	virtual glw::GLuint getTestCaseNumber();
   3937 
   3938 	virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program& program, std::stringstream& out_stream);
   3939 };
   3940 
   3941 /** Implementation of test XFBVertexStreams. Description follows:
   3942  *
   3943  * Test verifies that "xfb" qualifiers work as expected with multiple output
   3944  * streams.
   3945  *
   3946  * Test implements Buffer algorithm. Rasterization can be discarded.
   3947  *
   3948  * Test following code snippet:
   3949  *
   3950  *     layout (xfb_buffer = 1, xfb_stride = 64) out;
   3951  *     layout (xfb_buffer = 2, xfb_stride = 64) out;
   3952  *     layout (xfb_buffer = 3, xfb_stride = 64) out;
   3953  *
   3954  *     layout (stream = 0, xfb_buffer = 1, xfb_offset = 48) out vec4 goku;
   3955  *     layout (stream = 0, xfb_buffer = 1, xfb_offset = 32) out vec4 gohan;
   3956  *     layout (stream = 0, xfb_buffer = 1, xfb_offset = 16) out vec4 goten;
   3957  *     layout (stream = 1, xfb_buffer = 3, xfb_offset = 48) out vec4 picolo;
   3958  *     layout (stream = 1, xfb_buffer = 3, xfb_offset = 32) out vec4 vegeta;
   3959  *     layout (stream = 2, xfb_buffer = 2, xfb_offset = 32) out vec4 bulma;
   3960  *
   3961  *     goku   = EXPECTED_VALUE;
   3962  *     gohan  = EXPECTED_VALUE;
   3963  *     goten  = EXPECTED_VALUE;
   3964  *     picolo = EXPECTED_VALUE;
   3965  *     vegeta = EXPECTED_VALUE;
   3966  *     bulma  = EXPECTED_VALUE;
   3967  *
   3968  * Test pass if all captured outputs have expected values.
   3969  **/
   3970 class XFBVertexStreamsTest : public BufferTestBase
   3971 {
   3972 public:
   3973 	XFBVertexStreamsTest(deqp::Context& context);
   3974 
   3975 	~XFBVertexStreamsTest()
   3976 	{
   3977 	}
   3978 
   3979 protected:
   3980 	/* Protected methods */
   3981 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   3982 
   3983 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   3984 							   std::string& out_calculations);
   3985 
   3986 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   3987 									std::string& out_interface);
   3988 };
   3989 
   3990 /** Implementation of test XFBMultipleVertexStreams. Description follows:
   3991  *
   3992  * Test verifies that outputs from single stream must be captured with single
   3993  * xfb binding.
   3994  *
   3995  * Test following code snippet:
   3996  *
   3997  *     layout (xfb_buffer = 1, xfb_stride = 64) out;
   3998  *     layout (xfb_buffer = 3, xfb_stride = 64) out;
   3999  *
   4000  *     layout (stream = 0, xfb_buffer = 1, xfb_offset = 48) out vec4 goku;
   4001  *     layout (stream = 1, xfb_buffer = 1, xfb_offset = 32) out vec4 gohan;
   4002  *     layout (stream = 2, xfb_buffer = 1, xfb_offset = 16) out vec4 goten;
   4003  *
   4004  * It is expected that linking of program will fail.
   4005  **/
   4006 class XFBMultipleVertexStreamsTest : public NegativeTestBase
   4007 {
   4008 public:
   4009 	/* Public methods */
   4010 	XFBMultipleVertexStreamsTest(deqp::Context& context);
   4011 
   4012 	virtual ~XFBMultipleVertexStreamsTest()
   4013 	{
   4014 	}
   4015 
   4016 protected:
   4017 	/* Methods to be implemented by child class */
   4018 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4019 
   4020 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   4021 };
   4022 
   4023 /** Implementation of test XFBExceedBufferLimit. Description follows:
   4024  *
   4025  * Test verifies that MAX_TRANSFORM_FEEDBACK_BUFFERS limit is respected.
   4026  *
   4027  * Test following code snippets:
   4028  *
   4029  *     layout (xfb_buffer = MAX_TRANSFORM_FEEDBACK_BUFFERS) out;
   4030  *
   4031  * ,
   4032  *
   4033  *     layout (xfb_buffer = MAX_TRANSFORM_FEEDBACK_BUFFERS) out vec4 output;
   4034  *
   4035  * and
   4036  *
   4037  *     layout (xfb_buffer = MAX_TRANSFORM_FEEDBACK_BUFFERS) out Block {
   4038  *         vec4 member;
   4039  *     };
   4040  *
   4041  * It is expected that build process will fail.
   4042  *
   4043  * Test all shader stages.
   4044  **/
   4045 class XFBExceedBufferLimitTest : public NegativeTestBase
   4046 {
   4047 public:
   4048 	/* Public methods */
   4049 	XFBExceedBufferLimitTest(deqp::Context& context);
   4050 	virtual ~XFBExceedBufferLimitTest()
   4051 	{
   4052 	}
   4053 
   4054 protected:
   4055 	/* Methods to be implemented by child class */
   4056 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4057 
   4058 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4059 	virtual glw::GLuint getTestCaseNumber();
   4060 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   4061 	virtual void testInit();
   4062 
   4063 private:
   4064 	enum CASES
   4065 	{
   4066 		BLOCK = 0,
   4067 		GLOBAL,
   4068 		VECTOR,
   4069 
   4070 		/* */
   4071 		CASE_MAX
   4072 	};
   4073 
   4074 	/* Private types */
   4075 	struct testCase
   4076 	{
   4077 		CASES				  m_case;
   4078 		Utils::Shader::STAGES m_stage;
   4079 	};
   4080 
   4081 	/* Private fields */
   4082 	std::vector<testCase> m_test_cases;
   4083 };
   4084 
   4085 /** Implementation of test XFBExceedOffsetLimit. Description follows:
   4086  *
   4087  * Test verifies that MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS limit is
   4088  * respected.
   4089  *
   4090  * Test following code snippets:
   4091  *
   4092  *     layout (xfb_buffer = 0, xfb_stride = MAX_SIZE + 16) out;
   4093  *
   4094  * ,
   4095  *
   4096  *     layout (xfb_buffer = 0, xfb_offset = MAX_SIZE) out vec4 output;
   4097  *
   4098  * and
   4099  *
   4100  *     layout (xfb_buffer = 0, xfb_offset = MAX_SIZE) out Block
   4101  *     {
   4102  *         vec4 member;
   4103  *     };
   4104  *
   4105  * where MAX_SIZE is the maximum supported size of transform feedback buffer,
   4106  * which should be equal to:
   4107  *
   4108  *     MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS * sizeof(float)
   4109  *
   4110  * It is expected that build process will fail.
   4111  *
   4112  * Test all shader stages.
   4113  **/
   4114 class XFBExceedOffsetLimitTest : public NegativeTestBase
   4115 {
   4116 public:
   4117 	/* Public methods */
   4118 	XFBExceedOffsetLimitTest(deqp::Context& context);
   4119 	virtual ~XFBExceedOffsetLimitTest()
   4120 	{
   4121 	}
   4122 
   4123 protected:
   4124 	/* Methods to be implemented by child class */
   4125 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4126 
   4127 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4128 	virtual glw::GLuint getTestCaseNumber();
   4129 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   4130 	virtual void testInit();
   4131 
   4132 private:
   4133 	enum CASES
   4134 	{
   4135 		BLOCK = 0,
   4136 		GLOBAL,
   4137 		VECTOR,
   4138 
   4139 		/* */
   4140 		CASE_MAX
   4141 	};
   4142 
   4143 	/* Private types */
   4144 	struct testCase
   4145 	{
   4146 		CASES				  m_case;
   4147 		Utils::Shader::STAGES m_stage;
   4148 	};
   4149 
   4150 	/* Private fields */
   4151 	std::vector<testCase> m_test_cases;
   4152 };
   4153 
   4154 /** Implementation of test XFBGlobalBuffer. Description follows:
   4155  *
   4156  * Test verifies that global setting of xfb_buffer qualifier work as expected.
   4157  *
   4158  * This test implements Buffer algorithm. Rasterization can be discarded. Test
   4159  * following code snippet:
   4160  *
   4161  *     layout (xfb_buffer = 3) out;
   4162  *
   4163  *     layout (                xfb_offset = 2 * sizeof(type)) out type chichi;
   4164  *     layout (xfb_buffer = 1, xfb_offset = 0)                out type bulma;
   4165  *     layout (xfb_buffer = 1, xfb_offset = sizeof(type))     out Vegeta {
   4166  *         type trunks;
   4167  *         type bra;
   4168  *     };
   4169  *     layout (                xfb_offset = 0)                out Goku {
   4170  *         type gohan;
   4171  *         type goten;
   4172  *     };
   4173  *
   4174  *     chichi = EXPECTED_VALUE;
   4175  *     bulma  = EXPECTED_VALUE;
   4176  *     trunks = EXPECTED_VALUE;
   4177  *     bra    = EXPECTED_VALUE;
   4178  *     gohan  = EXPECTED_VALUE;
   4179  *     goten  = EXPECTED_VALUE;
   4180  *
   4181  * Test pass if all captured outputs have expected values.
   4182  *
   4183  * Test all shader stages. Test all types.
   4184  **/
   4185 class XFBGlobalBufferTest : public BufferTestBase
   4186 {
   4187 public:
   4188 	XFBGlobalBufferTest(deqp::Context& context);
   4189 
   4190 	~XFBGlobalBufferTest()
   4191 	{
   4192 	}
   4193 
   4194 protected:
   4195 	/* Protected methods */
   4196 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   4197 
   4198 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4199 
   4200 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4201 	virtual glw::GLuint getTestCaseNumber();
   4202 	virtual void		testInit();
   4203 
   4204 private:
   4205 	/* Private types */
   4206 	struct _testCase
   4207 	{
   4208 		Utils::Shader::STAGES m_stage;
   4209 		Utils::Type			  m_type;
   4210 	};
   4211 
   4212 	/* Private fields */
   4213 	std::vector<_testCase> m_test_cases;
   4214 };
   4215 
   4216 /** Implementation of test XFBStride. Description follows:
   4217  *
   4218  * Test verifies that expected stride values are used.
   4219  *
   4220  * Test following code snippet:
   4221  *
   4222  *     layout (xfb_offset = 0) out type output;
   4223  *
   4224  *     output = EXPECTED_VALUE;
   4225  *
   4226  * Test all types. Test all shader stages.
   4227  **/
   4228 class XFBStrideTest : public BufferTestBase
   4229 {
   4230 public:
   4231 	XFBStrideTest(deqp::Context& context);
   4232 	~XFBStrideTest()
   4233 	{
   4234 	}
   4235 
   4236 protected:
   4237 	/* Protected methods */
   4238 	using BufferTestBase::executeDrawCall;
   4239 
   4240 	virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index);
   4241 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   4242 
   4243 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   4244 							   std::string& out_calculations);
   4245 
   4246 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   4247 									std::string& out_interface);
   4248 
   4249 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4250 
   4251 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4252 	virtual glw::GLuint getTestCaseNumber();
   4253 	virtual void		testInit();
   4254 
   4255 private:
   4256 	/* Private types */
   4257 	struct testCase
   4258 	{
   4259 		Utils::Shader::STAGES m_stage;
   4260 		Utils::Type			  m_type;
   4261 	};
   4262 
   4263 	/* Private fields */
   4264 	std::vector<testCase> m_test_cases;
   4265 };
   4266 
   4267 /** Implementation of test XFBBlockMemberBuffer. Description follows:
   4268  *
   4269  * Test verifies that member of block have to use same buffer as block.
   4270  *
   4271  * Test following code snippet:
   4272  *
   4273  *     layout (xfb_offset = 0) out Goku
   4274  *     {
   4275  *                                 vec4 gohan;
   4276  *         layout (xfb_buffer = 1) vec4 goten;
   4277  *     };
   4278  *
   4279  * It is expected that compilation will fail.
   4280  *
   4281  * Test all shader stages.
   4282  **/
   4283 class XFBBlockMemberBufferTest : public NegativeTestBase
   4284 {
   4285 public:
   4286 	/* Public methods */
   4287 	XFBBlockMemberBufferTest(deqp::Context& context);
   4288 
   4289 	virtual ~XFBBlockMemberBufferTest()
   4290 	{
   4291 	}
   4292 
   4293 protected:
   4294 	/* Methods to be implemented by child class */
   4295 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4296 
   4297 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4298 	virtual glw::GLuint getTestCaseNumber();
   4299 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   4300 	virtual void testInit();
   4301 
   4302 private:
   4303 	/* Private types */
   4304 	struct testCase
   4305 	{
   4306 		Utils::Shader::STAGES m_stage;
   4307 	};
   4308 
   4309 	/* Private fields */
   4310 	std::vector<testCase> m_test_cases;
   4311 };
   4312 
   4313 /** Implementation of test XFBOutputOverlapping. Description follows:
   4314  *
   4315  * Test verifies that overlapped outputs are reported as errors by compiler.
   4316  *
   4317  * Test following code snippet:
   4318  *
   4319  *     layout (xfb_offset = sizeof(type))       out type gohan;
   4320  *     layout (xfb_offset = 1.5 * sizeof(type)) out type goten;
   4321  *
   4322  *     gohan = EXPECTED_VALUE;
   4323  *     goten = EXPECTED_VALUE;
   4324  *
   4325  * It is expected that compilation will fail.
   4326  *
   4327  * Test all shader stages. Test all types.
   4328  **/
   4329 class XFBOutputOverlappingTest : public NegativeTestBase
   4330 {
   4331 public:
   4332 	/* Public methods */
   4333 	XFBOutputOverlappingTest(deqp::Context& context);
   4334 
   4335 	virtual ~XFBOutputOverlappingTest()
   4336 	{
   4337 	}
   4338 
   4339 protected:
   4340 	/* Methods to be implemented by child class */
   4341 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4342 
   4343 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4344 	virtual glw::GLuint getTestCaseNumber();
   4345 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   4346 	virtual void testInit();
   4347 
   4348 private:
   4349 	/* Private types */
   4350 	struct testCase
   4351 	{
   4352 		glw::GLuint			  m_offset_gohan;
   4353 		glw::GLuint			  m_offset_goten;
   4354 		Utils::Shader::STAGES m_stage;
   4355 		Utils::Type			  m_type;
   4356 	};
   4357 
   4358 	/* Private fields */
   4359 	std::vector<testCase> m_test_cases;
   4360 };
   4361 
   4362 /** Implementation of test XFBInvalidOffsetAlignment. Description follows:
   4363  *
   4364  * Test verifies that invalidly aligned outputs cause a failure to build
   4365  * process.
   4366  *
   4367  * Test following code snippet:
   4368  *
   4369  *     layout (xfb_offset = OFFSET) out type goku;
   4370  *
   4371  *     goku = EXPECTED_VALUE;
   4372  *
   4373  * Select OFFSET values so as to cause invalid alignment. Inspect program to
   4374  * verify offset of goku.
   4375  *
   4376  * Test all shader stages. Test all types. Test all offsets in range:
   4377  * (sizeof(type), 2 * sizeof(type)).
   4378  **/
   4379 class XFBInvalidOffsetAlignmentTest : public NegativeTestBase
   4380 {
   4381 public:
   4382 	/* Public methods */
   4383 	XFBInvalidOffsetAlignmentTest(deqp::Context& context);
   4384 
   4385 	virtual ~XFBInvalidOffsetAlignmentTest()
   4386 	{
   4387 	}
   4388 
   4389 protected:
   4390 	/* Methods to be implemented by child class */
   4391 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4392 
   4393 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4394 	virtual glw::GLuint getTestCaseNumber();
   4395 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   4396 	virtual void testInit();
   4397 
   4398 private:
   4399 	/* Private types */
   4400 	struct testCase
   4401 	{
   4402 		glw::GLuint			  m_offset;
   4403 		Utils::Shader::STAGES m_stage;
   4404 		Utils::Type			  m_type;
   4405 	};
   4406 
   4407 	/* Private fields */
   4408 	std::vector<testCase> m_test_cases;
   4409 };
   4410 
   4411 /** Implementation of test XFBCaptureInactiveOutputVariable. Description follows:
   4412  *
   4413  * Test verifies behaviour of inactive outputs.
   4414  *
   4415  * This test implements Buffer algorithm. Rasterization can be disabled. Draw
   4416  * two vertices instead of one. Test following code snippet:
   4417  *
   4418  *     layout (xfb_offset = 16) out vec4 goku;
   4419  *     layout (xfb_offset = 32) out vec4 gohan;
   4420  *     layout (xfb_offset = 0)  out vec4 goten;
   4421  *
   4422  *     gohan = EXPECTED_VALUE;
   4423  *     goten = EXPECTED_VALUE;
   4424  *
   4425  * Test pass if:
   4426  *     - values captured for goten and gohan are as expected,
   4427  *     - goku value is undefined
   4428  *     - stride is 3 * sizeof(vec4) - 48
   4429  *
   4430  * Test all shader stages.
   4431  **/
   4432 class XFBCaptureInactiveOutputVariableTest : public BufferTestBase
   4433 {
   4434 public:
   4435 	XFBCaptureInactiveOutputVariableTest(deqp::Context& context);
   4436 	~XFBCaptureInactiveOutputVariableTest()
   4437 	{
   4438 	}
   4439 
   4440 protected:
   4441 	/* Protected methods */
   4442 	using BufferTestBase::executeDrawCall;
   4443 	virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index);
   4444 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   4445 
   4446 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   4447 							   std::string& out_calculations);
   4448 
   4449 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   4450 									std::string& out_interface);
   4451 
   4452 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4453 
   4454 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4455 	virtual glw::GLuint getTestCaseNumber();
   4456 
   4457 	virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program& program, std::stringstream& out_stream);
   4458 
   4459 	virtual bool verifyBuffers(bufferCollection& buffers);
   4460 
   4461 private:
   4462 	enum test_cases
   4463 	{
   4464 		TEST_VS = 0,
   4465 		TEST_TES,
   4466 		TEST_GS,
   4467 
   4468 		/* */
   4469 		TEST_MAX
   4470 	};
   4471 };
   4472 
   4473 /** Implementation of test XFBCaptureInactiveOutputComponent. Description follows:
   4474  *
   4475  * Test verifies behaviour of inactive component.
   4476  *
   4477  * This test implements Buffer algorithm. Rasterization can be disabled. Draw
   4478  * two vertices instead of one. Test following code snippet:
   4479  *
   4480  *     layout (xfb_offset = 32)  out vec4 goku;
   4481  *     layout (xfb_offset = 0)   out vec4 gohan;
   4482  *     layout (xfb_offset = 16)  out vec4 goten;
   4483  *     layout (xfb_offset = 48)  out vec4 chichi;
   4484  *     layout (xfb_offset = 112) out vec4 vegeta;
   4485  *     layout (xfb_offset = 96)  out vec4 trunks;
   4486  *     layout (xfb_offset = 80)  out vec4 bra;
   4487  *     layout (xfb_offset = 64)  out vec4 bulma;
   4488  *
   4489  *     goku.x   = EXPECTED_VALUE;
   4490  *     goku.z   = EXPECTED_VALUE;
   4491  *     gohan.y  = EXPECTED_VALUE;
   4492  *     gohan.w  = EXPECTED_VALUE;
   4493  *     goten.x  = EXPECTED_VALUE;
   4494  *     goten.y  = EXPECTED_VALUE;
   4495  *     chichi.z = EXPECTED_VALUE;
   4496  *     chichi.w = EXPECTED_VALUE;
   4497  *     vegeta.x = EXPECTED_VALUE;
   4498  *     trunks.y = EXPECTED_VALUE;
   4499  *     bra.z    = EXPECTED_VALUE;
   4500  *     bulma.w  = EXPECTED_VALUE;
   4501  *
   4502  * Test pass when captured values of all assigned components match expected
   4503  * values, while not assigned ones are undefined.
   4504  *
   4505  * Test all shader stages.
   4506  **/
   4507 class XFBCaptureInactiveOutputComponentTest : public BufferTestBase
   4508 {
   4509 public:
   4510 	XFBCaptureInactiveOutputComponentTest(deqp::Context& context);
   4511 	~XFBCaptureInactiveOutputComponentTest()
   4512 	{
   4513 	}
   4514 
   4515 protected:
   4516 	/* Protected methods */
   4517 	using BufferTestBase::executeDrawCall;
   4518 	virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index);
   4519 
   4520 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   4521 
   4522 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   4523 							   std::string& out_calculations);
   4524 
   4525 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   4526 									std::string& out_interface);
   4527 
   4528 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4529 
   4530 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4531 	virtual glw::GLuint getTestCaseNumber();
   4532 	virtual bool verifyBuffers(bufferCollection& buffers);
   4533 
   4534 private:
   4535 	enum test_cases
   4536 	{
   4537 		TEST_VS = 0,
   4538 		TEST_TES,
   4539 		TEST_GS,
   4540 
   4541 		/* */
   4542 		TEST_MAX
   4543 	};
   4544 };
   4545 
   4546 /** Implementation of test XFBCaptureInactiveOutputBlockMember. Description follows:
   4547  *
   4548  * Test verifies behaviour of inactive block member.
   4549  *
   4550  * This test implements Buffer algorithm. Rasterization can be disabled. Draw
   4551  * two vertices instead of one. Test following code snippet:
   4552  *
   4553  *     layout (xfb_offset = 16)  out Goku {
   4554  *         vec4 gohan;
   4555  *         vec4 goten;
   4556  *         vec4 chichi;
   4557  *     };
   4558  *
   4559  *     gohan  = EXPECTED_VALUE;
   4560  *     chichi = EXPECTED_VALUE;
   4561  *
   4562  * Test pass when captured values of gohan and chichi match expected values.
   4563  * It is expected that goten will receive undefined value.
   4564  *
   4565  * Test all shader stages.
   4566  **/
   4567 class XFBCaptureInactiveOutputBlockMemberTest : public BufferTestBase
   4568 {
   4569 public:
   4570 	XFBCaptureInactiveOutputBlockMemberTest(deqp::Context& context);
   4571 
   4572 	~XFBCaptureInactiveOutputBlockMemberTest()
   4573 	{
   4574 	}
   4575 
   4576 protected:
   4577 	/* Protected methods */
   4578 	using BufferTestBase::executeDrawCall;
   4579 	virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index);
   4580 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   4581 
   4582 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   4583 							   std::string& out_calculations);
   4584 
   4585 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   4586 									std::string& out_interface);
   4587 
   4588 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4589 
   4590 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4591 	virtual glw::GLuint getTestCaseNumber();
   4592 	virtual bool verifyBuffers(bufferCollection& buffers);
   4593 
   4594 private:
   4595 	enum test_cases
   4596 	{
   4597 		TEST_VS = 0,
   4598 		TEST_TES,
   4599 		TEST_GS,
   4600 
   4601 		/* */
   4602 		TEST_MAX
   4603 	};
   4604 };
   4605 
   4606 /** Implementation of test XFBCaptureStruct. Description follows:
   4607  *
   4608  * Test verifies that structures are captured as expected.
   4609  *
   4610  * This test implements Buffer algorithm. Rasterization can be disabled. Draw
   4611  * two vertices instead of one. Test following code snippet:
   4612  *
   4613  *     struct Goku {
   4614  *         vec4 gohan;
   4615  *         vec4 goten;
   4616  *         vec4 chichi;
   4617  *     };
   4618  *
   4619  *     layout (xfb_offset = 16) out Goku goku;
   4620  *
   4621  *     goku.gohan  = EXPECTED_VALUE;
   4622  *     goku.chichi = EXPECTED_VALUE;
   4623  *
   4624  * Test pass when captured values of gohan and chichi match expected values.
   4625  * It is expected that goten will receive undefined value.
   4626  *
   4627  * Test all shader stages.
   4628  **/
   4629 class XFBCaptureStructTest : public BufferTestBase
   4630 {
   4631 public:
   4632 	XFBCaptureStructTest(deqp::Context& context);
   4633 
   4634 	~XFBCaptureStructTest()
   4635 	{
   4636 	}
   4637 
   4638 protected:
   4639 	/* Protected methods */
   4640 	using BufferTestBase::executeDrawCall;
   4641 	virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index);
   4642 
   4643 	virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector& out_descriptors);
   4644 
   4645 	virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string& out_assignments,
   4646 							   std::string& out_calculations);
   4647 
   4648 	virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage,
   4649 									std::string& out_interface);
   4650 
   4651 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4652 
   4653 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4654 	virtual glw::GLuint getTestCaseNumber();
   4655 	virtual bool verifyBuffers(bufferCollection& buffers);
   4656 
   4657 private:
   4658 	enum test_cases
   4659 	{
   4660 		TEST_VS = 0,
   4661 		TEST_TES,
   4662 		TEST_GS,
   4663 
   4664 		/* */
   4665 		TEST_MAX
   4666 	};
   4667 };
   4668 
   4669 /** Implementation of test XFBCaptureUnsizedArray. Description follows:
   4670  *
   4671  * Test verifies this is not allowed to qualify unsized array with "xfb".
   4672  *
   4673  * Test following code snippet:
   4674  *
   4675  *     layout (xfb_offset = 0) out vec4 goku[];
   4676  *
   4677  *     goku[0] = EXPECTED_VALUE;
   4678  *
   4679  * It is expected that compilation will fail.
   4680  *
   4681  * Test all shader stages.
   4682  **/
   4683 class XFBCaptureUnsizedArrayTest : public NegativeTestBase
   4684 {
   4685 public:
   4686 	/* Public methods */
   4687 	XFBCaptureUnsizedArrayTest(deqp::Context& context);
   4688 	virtual ~XFBCaptureUnsizedArrayTest()
   4689 	{
   4690 	}
   4691 
   4692 protected:
   4693 	/* Methods to be implemented by child class */
   4694 	virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
   4695 
   4696 	virtual std::string getTestCaseName(glw::GLuint test_case_index);
   4697 	virtual glw::GLuint getTestCaseNumber();
   4698 	virtual bool isComputeRelevant(glw::GLuint test_case_index);
   4699 	virtual void testInit();
   4700 
   4701 private:
   4702 	/* Private types */
   4703 	struct testCase
   4704 	{
   4705 		Utils::Shader::STAGES m_stage;
   4706 	};
   4707 
   4708 	/* Private fields */
   4709 	std::vector<testCase> m_test_cases;
   4710 };
   4711 
   4712 } /* EnhancedLayouts namespace */
   4713 
   4714 /** Group class for Shader Language 420Pack conformance tests */
   4715 class EnhancedLayoutsTests : public deqp::TestCaseGroup
   4716 {
   4717 public:
   4718 	/* Public methods */
   4719 	EnhancedLayoutsTests(deqp::Context& context);
   4720 
   4721 	virtual ~EnhancedLayoutsTests(void)
   4722 	{
   4723 	}
   4724 
   4725 	virtual void init(void);
   4726 
   4727 private:
   4728 	/* Private methods */
   4729 	EnhancedLayoutsTests(const EnhancedLayoutsTests& other);
   4730 	EnhancedLayoutsTests& operator=(const EnhancedLayoutsTests& other);
   4731 };
   4732 
   4733 } // gl4cts
   4734 
   4735 #endif // _GL4CENHANCEDLAYOUTSTESTS_HPP
   4736