• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2014-2016 The Khronos Group Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */ /*!
20  * \file
21  * \brief
22  */ /*-------------------------------------------------------------------*/
23 
24 #include "esextcTessellationShaderErrors.hpp"
25 #include "gluContextInfo.hpp"
26 #include "gluDefs.hpp"
27 #include "glwEnums.hpp"
28 #include "glwFunctions.hpp"
29 #include "tcuTestLog.hpp"
30 #include <cstdarg>
31 #include <cstdio>
32 #include <cstring>
33 
34 namespace glcts
35 {
36 
37 /** Constructor
38  *
39  * @param context       Test context
40  * @param name          Test case's name
41  * @param description   Test case's description
42  **/
TessellationShaderErrors(Context & context,const ExtParameters & extParams)43 TessellationShaderErrors::TessellationShaderErrors(Context& context, const ExtParameters& extParams)
44 	: TestCaseGroupBase(context, extParams, "compilation_and_linking_errors",
45 						"Checks that the implementation correctly responds to"
46 						"various errors in shaders which should result in compilation"
47 						"or linking errors")
48 {
49 	/* Left blank on purpose */
50 }
51 
52 /* Instantiates all tests and adds them as children to the node */
init(void)53 void TessellationShaderErrors::init(void)
54 {
55 	addChild(new glcts::TessellationShaderError1InputBlocks(m_context, m_extParams));
56 	addChild(new glcts::TessellationShaderError1InputVariables(m_context, m_extParams));
57 	addChild(new glcts::TessellationShaderError2OutputBlocks(m_context, m_extParams));
58 	addChild(new glcts::TessellationShaderError2OutputVariables(m_context, m_extParams));
59 	addChild(new glcts::TessellationShaderError3InputBlocks(m_context, m_extParams));
60 	addChild(new glcts::TessellationShaderError3InputVariables(m_context, m_extParams));
61 	addChild(new glcts::TessellationShaderError4InputBlocks(m_context, m_extParams));
62 	addChild(new glcts::TessellationShaderError4InputVariables(m_context, m_extParams));
63 	addChild(new glcts::TessellationShaderError5InputBlocks(m_context, m_extParams));
64 	addChild(new glcts::TessellationShaderError5InputVariables(m_context, m_extParams));
65 	addChild(new glcts::TessellationShaderError6(m_context, m_extParams));
66 	addChild(new glcts::TessellationShaderError7(m_context, m_extParams));
67 	addChild(new glcts::TessellationShaderError8(m_context, m_extParams));
68 	addChild(new glcts::TessellationShaderError9(m_context, m_extParams));
69 	addChild(new glcts::TessellationShaderError10(m_context, m_extParams));
70 	addChild(new glcts::TessellationShaderError11(m_context, m_extParams));
71 	addChild(new glcts::TessellationShaderError12(m_context, m_extParams));
72 	addChild(new glcts::TessellationShaderError13(m_context, m_extParams));
73 }
74 
75 /** Constructor
76  *
77  * @param context       Test context
78  * @param name          Test case's name
79  * @param description   Test case's description
80  **/
TessellationShaderErrorsTestCaseBase(Context & context,const ExtParameters & extParams,const char * name,const char * description)81 TessellationShaderErrorsTestCaseBase::TessellationShaderErrorsTestCaseBase(Context&				context,
82 																		   const ExtParameters& extParams,
83 																		   const char* name, const char* description)
84 	: TestCaseBase(context, extParams, name, description)
85 	, m_fs_ids(DE_NULL)
86 	, m_n_program_objects(0)
87 	, m_po_ids(DE_NULL)
88 	, m_tc_ids(DE_NULL)
89 	, m_te_ids(DE_NULL)
90 	, m_vs_ids(DE_NULL)
91 {
92 	/* Left blank intentionally */
93 }
94 
95 /** Deinitializes all ES objects that were created for the test */
deinit()96 void TessellationShaderErrorsTestCaseBase::deinit()
97 {
98 	/* Call base class' deinit() */
99 	TestCaseBase::deinit();
100 
101 	if (!m_is_tessellation_shader_supported)
102 	{
103 		return;
104 	}
105 
106 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
107 
108 	/* Release all shader objects created for the test */
109 	for (unsigned int n_program_object = 0; n_program_object < m_n_program_objects; ++n_program_object)
110 	{
111 		if (m_fs_ids != DE_NULL && m_fs_ids[n_program_object] != 0)
112 		{
113 			gl.deleteShader(m_fs_ids[n_program_object]);
114 
115 			m_fs_ids[n_program_object] = 0;
116 		}
117 
118 		if (m_po_ids != DE_NULL && m_po_ids[n_program_object] != 0)
119 		{
120 			gl.deleteProgram(m_po_ids[n_program_object]);
121 
122 			m_po_ids[n_program_object] = 0;
123 		}
124 
125 		if (m_tc_ids != DE_NULL && m_tc_ids[n_program_object] != 0)
126 		{
127 			gl.deleteShader(m_tc_ids[n_program_object]);
128 
129 			m_tc_ids[n_program_object] = 0;
130 		}
131 
132 		if (m_te_ids != DE_NULL && m_te_ids[n_program_object] != 0)
133 		{
134 			gl.deleteShader(m_te_ids[n_program_object]);
135 
136 			m_te_ids[n_program_object] = 0;
137 		}
138 
139 		if (m_vs_ids != DE_NULL && m_vs_ids[n_program_object] != 0)
140 		{
141 			gl.deleteShader(m_vs_ids[n_program_object]);
142 
143 			m_vs_ids[n_program_object] = 0;
144 		}
145 	} /* for (all shader objects) */
146 
147 	/* Release buffers allocated for the test */
148 	if (m_fs_ids != DE_NULL)
149 	{
150 		delete[] m_fs_ids;
151 
152 		m_fs_ids = DE_NULL;
153 	}
154 
155 	if (m_po_ids != DE_NULL)
156 	{
157 		delete[] m_po_ids;
158 
159 		m_po_ids = DE_NULL;
160 	}
161 
162 	if (m_tc_ids != DE_NULL)
163 	{
164 		delete[] m_tc_ids;
165 
166 		m_tc_ids = DE_NULL;
167 	}
168 
169 	if (m_te_ids != DE_NULL)
170 	{
171 		delete[] m_te_ids;
172 
173 		m_te_ids = DE_NULL;
174 	}
175 
176 	if (m_vs_ids != DE_NULL)
177 	{
178 		delete[] m_vs_ids;
179 
180 		m_vs_ids = DE_NULL;
181 	}
182 }
183 
184 /** Executes the test.
185  *
186  *  Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise.
187  *
188  *  Note the function throws exception should an error occur!
189  *
190  *  @return STOP if the test has finished, CONTINUE to indicate iterate() should be called once again.
191  **/
iterate()192 tcu::TestNode::IterateResult TessellationShaderErrorsTestCaseBase::iterate()
193 {
194 	/* Do not execute if required extensions are not supported. */
195 	if (!m_is_tessellation_shader_supported)
196 	{
197 		throw tcu::NotSupportedError(TESSELLATION_SHADER_EXTENSION_NOT_SUPPORTED);
198 	}
199 
200 	/* Retrieve ES entry-points */
201 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
202 
203 	/* Create as many program objects as will be needed */
204 	m_n_program_objects = getAmountOfProgramObjects();
205 	m_po_ids			= new glw::GLuint[m_n_program_objects];
206 
207 	memset(m_po_ids, 0, sizeof(glw::GLuint) * m_n_program_objects);
208 
209 	for (unsigned int n_po = 0; n_po < m_n_program_objects; ++n_po)
210 	{
211 		m_po_ids[n_po] = gl.createProgram();
212 
213 		GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram() failed");
214 	}
215 
216 	/* Allocate space for shader IDs */
217 	bool is_fs_used = isPipelineStageUsed(PIPELINE_STAGE_FRAGMENT);
218 	bool is_tc_used = isPipelineStageUsed(PIPELINE_STAGE_TESSELLATION_CONTROL);
219 	bool is_te_used = isPipelineStageUsed(PIPELINE_STAGE_TESSELLATION_EVALUATION);
220 	bool is_vs_used = isPipelineStageUsed(PIPELINE_STAGE_VERTEX);
221 
222 	if (is_fs_used)
223 	{
224 		m_fs_ids = new glw::GLuint[m_n_program_objects];
225 
226 		memset(m_fs_ids, 0, sizeof(glw::GLuint) * m_n_program_objects);
227 	}
228 
229 	if (is_tc_used)
230 	{
231 		m_tc_ids = new glw::GLuint[m_n_program_objects];
232 
233 		memset(m_tc_ids, 0, sizeof(glw::GLuint) * m_n_program_objects);
234 	}
235 
236 	if (is_te_used)
237 	{
238 		m_te_ids = new glw::GLuint[m_n_program_objects];
239 
240 		memset(m_te_ids, 0, sizeof(glw::GLuint) * m_n_program_objects);
241 	}
242 
243 	if (is_vs_used)
244 	{
245 		m_vs_ids = new glw::GLuint[m_n_program_objects];
246 
247 		memset(m_vs_ids, 0, sizeof(glw::GLuint) * m_n_program_objects);
248 	}
249 
250 	/* Iterate through all program objects the test wants to check */
251 	for (unsigned int n_po = 0; n_po < m_n_program_objects; ++n_po)
252 	{
253 		_linking_result expected_linking_result = getLinkingResult();
254 		bool			should_try_to_link		= true;
255 
256 		/* Iterate through all shader types */
257 		for (int stage = static_cast<int>(PIPELINE_STAGE_FIRST); stage < static_cast<int>(PIPELINE_STAGE_COUNT);
258 			 stage++)
259 		{
260 			if (!isPipelineStageUsed(static_cast<_pipeline_stage>(stage)))
261 			{
262 				continue;
263 			}
264 
265 			_compilation_result expected_compilation_result = getCompilationResult(static_cast<_pipeline_stage>(stage));
266 			std::string			so_code;
267 			glw::GLuint*		so_id_ptr = DE_NULL;
268 			std::string			so_type;
269 
270 			switch (static_cast<_pipeline_stage>(stage))
271 			{
272 			case PIPELINE_STAGE_FRAGMENT:
273 			{
274 				so_code   = getFragmentShaderCode(n_po);
275 				so_id_ptr = m_fs_ids + n_po;
276 				so_type   = "fragment";
277 
278 				break;
279 			}
280 
281 			case PIPELINE_STAGE_TESSELLATION_CONTROL:
282 			{
283 				so_code   = getTessellationControlShaderCode(n_po);
284 				so_id_ptr = m_tc_ids + n_po;
285 				so_type   = "tessellation control";
286 
287 				break;
288 			}
289 
290 			case PIPELINE_STAGE_TESSELLATION_EVALUATION:
291 			{
292 				so_code   = getTessellationEvaluationShaderCode(n_po);
293 				so_id_ptr = m_te_ids + n_po;
294 				so_type   = "tessellation evaluation";
295 
296 				break;
297 			}
298 
299 			case PIPELINE_STAGE_VERTEX:
300 			{
301 				so_code   = getVertexShaderCode(n_po);
302 				so_id_ptr = m_vs_ids + n_po;
303 				so_type   = "vertex";
304 
305 				break;
306 			}
307 
308 			default:
309 			{
310 				TCU_FAIL("Unrecognized pipeline stage");
311 			}
312 			} /* switch (stage) */
313 
314 			/* Generate the shader object */
315 			*so_id_ptr = gl.createShader(getGLEnumForPipelineStage(static_cast<_pipeline_stage>(stage)));
316 			GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader() failed");
317 
318 			/* Assign source code to the object */
319 			const char* so_unspecialized_code_ptr = so_code.c_str();
320 			std::string so_specialized_code		  = specializeShader(1, &so_unspecialized_code_ptr);
321 			const char* so_code_ptr				  = so_specialized_code.c_str();
322 
323 			gl.shaderSource(*so_id_ptr, 1 /* count */, &so_code_ptr, NULL /* length */);
324 			GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource() failed");
325 
326 			/* Try to compile the shader object */
327 			glw::GLint compile_status = GL_FALSE;
328 
329 			gl.compileShader(*so_id_ptr);
330 			GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader() failed");
331 
332 			/* Retrieve the compile status and make sure it matches the desired outcome */
333 			gl.getShaderiv(*so_id_ptr, GL_COMPILE_STATUS, &compile_status);
334 			GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv() failed");
335 
336 			m_context.getTestContext().getLog() << tcu::TestLog::Message << so_type << " shader source:\n"
337 												<< so_code_ptr << tcu::TestLog::EndMessage;
338 
339 			glw::GLint length = 0;
340 			gl.getShaderiv(*so_id_ptr, GL_INFO_LOG_LENGTH, &length);
341 			if (length > 1)
342 			{
343 				std::vector<glw::GLchar> log(length);
344 				gl.getShaderInfoLog(*so_id_ptr, length, NULL, &log[0]);
345 				m_context.getTestContext().getLog() << tcu::TestLog::Message << "shader info log\n"
346 													<< &log[0] << tcu::TestLog::EndMessage;
347 			}
348 
349 			switch (expected_compilation_result)
350 			{
351 			case COMPILATION_RESULT_CAN_FAIL:
352 			{
353 				if (compile_status == GL_FALSE)
354 				{
355 					/* OK, this is valid. However, it no longer makes sense to try to
356 					 * link the program object at this point. */
357 					should_try_to_link = false;
358 					m_context.getTestContext().getLog()
359 						<< tcu::TestLog::Message << "Compilation failed as allowed." << tcu::TestLog::EndMessage;
360 				}
361 				else
362 				{
363 					/* That's fine. */
364 					m_context.getTestContext().getLog()
365 						<< tcu::TestLog::Message << "Compilation passed as allowed." << tcu::TestLog::EndMessage;
366 				}
367 
368 				break;
369 			}
370 
371 			case COMPILATION_RESULT_MUST_FAIL:
372 			{
373 				if (compile_status == GL_TRUE)
374 				{
375 					/* Test has failed */
376 					TCU_FAIL("A shader compiled successfully, even though it should have failed "
377 							 "to do so");
378 				}
379 				else
380 				{
381 					/* OK. Mark the program object as non-linkable */
382 					should_try_to_link = false;
383 					m_context.getTestContext().getLog()
384 						<< tcu::TestLog::Message << "Compilation failed as expected." << tcu::TestLog::EndMessage;
385 				}
386 
387 				break;
388 			}
389 
390 			case COMPILATION_RESULT_MUST_SUCCEED:
391 			{
392 				if (compile_status != GL_TRUE)
393 				{
394 					/* Test has failed */
395 					TCU_FAIL("A shader failed to compile, even though it should have succeeded "
396 							 "to do so");
397 				}
398 				else
399 				{
400 					/* That's fine. */
401 					m_context.getTestContext().getLog()
402 						<< tcu::TestLog::Message << "Compilation successful as expected." << tcu::TestLog::EndMessage;
403 				}
404 
405 				break;
406 			}
407 
408 			default:
409 			{
410 				TCU_FAIL("Unrecognized expected compilation result");
411 			}
412 			} /* switch (expected_compilation_result) */
413 
414 			/* If it still makes sense to do so, attach the shader object to
415 			 * the test program object */
416 			if (should_try_to_link)
417 			{
418 				gl.attachShader(m_po_ids[n_po], *so_id_ptr);
419 				GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader() failed");
420 			}
421 		} /* for (all pipeline stages) */
422 
423 		/* If it still makes sense, try to link the program object */
424 		if (should_try_to_link)
425 		{
426 			gl.linkProgram(m_po_ids[n_po]);
427 			GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram() failed");
428 
429 			/* Retrieve the link status and compare it against the expected linking result */
430 			glw::GLint link_status = GL_FALSE;
431 
432 			gl.getProgramiv(m_po_ids[n_po], GL_LINK_STATUS, &link_status);
433 			GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv() failed");
434 
435 			glw::GLint length = 0;
436 			gl.getProgramiv(m_po_ids[n_po], GL_INFO_LOG_LENGTH, &length);
437 			if (length > 1)
438 			{
439 				std::vector<glw::GLchar> log(length);
440 				gl.getProgramInfoLog(m_po_ids[n_po], length, NULL, &log[0]);
441 				m_context.getTestContext().getLog() << tcu::TestLog::Message << "program info log\n"
442 													<< &log[0] << tcu::TestLog::EndMessage;
443 			}
444 
445 			switch (expected_linking_result)
446 			{
447 			case LINKING_RESULT_MUST_FAIL:
448 			{
449 				if (link_status != GL_FALSE)
450 				{
451 					TCU_FAIL("Program object was expected not to link but linking operation succeeded.");
452 				}
453 				else
454 				{
455 					/* That's OK */
456 					m_context.getTestContext().getLog()
457 						<< tcu::TestLog::Message << "Linking failed as expected." << tcu::TestLog::EndMessage;
458 				}
459 
460 				break;
461 			}
462 
463 			case LINKING_RESULT_MUST_SUCCEED:
464 			{
465 				if (link_status != GL_TRUE)
466 				{
467 					TCU_FAIL("Program object was expected to link successfully but linking operation failed.");
468 				}
469 				else
470 				{
471 					/* That's OK */
472 					m_context.getTestContext().getLog()
473 						<< tcu::TestLog::Message << "Linking succeeded as expected." << tcu::TestLog::EndMessage;
474 				}
475 
476 				break;
477 			}
478 
479 			default:
480 			{
481 				TCU_FAIL("Unrecognized expected linking result");
482 			}
483 			} /* switch (expected_linking_result) */
484 		}	 /* if (should_try_to_link) */
485 	}		  /* for (all program objects) */
486 
487 	/* If this point was reached, the test executed successfully */
488 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
489 
490 	return STOP;
491 }
492 
493 /** Retrieves amount of program objects the test that should be linked for
494  *  the prupose of the test.
495  *
496  *  @return As per description.
497  */
getAmountOfProgramObjects()498 unsigned int TessellationShaderErrorsTestCaseBase::getAmountOfProgramObjects()
499 {
500 	return 1;
501 }
502 
503 /** Retrieves source code of fragment shader that should be attached to the test
504  *  program object.
505  *
506  *  @param n_program_object Index of the program object the source code should
507  *                          be returned for.
508  *
509  *  @return Fragment shader source code to be used for user-specified program object.
510  */
getFragmentShaderCode(unsigned int n_program_object)511 std::string TessellationShaderErrorsTestCaseBase::getFragmentShaderCode(unsigned int n_program_object)
512 {
513 	DE_UNREF(n_program_object);
514 
515 	return "${VERSION}\n"
516 		   "\n"
517 		   "void main()\n"
518 		   "{\n"
519 		   "}\n";
520 }
521 
522 /** Retrieves GLenum equivalent of a pipeline stage value.
523  *
524  *  Throws TestError exception if @param stage is invalid.
525  *
526  *  @param stage Pipeline stage to convert from
527  *
528  *  @return GL_*_SHADER equivalent of the user-provided value.
529  **/
getGLEnumForPipelineStage(_pipeline_stage stage)530 glw::GLenum TessellationShaderErrorsTestCaseBase::getGLEnumForPipelineStage(_pipeline_stage stage)
531 {
532 	glw::GLenum result = GL_NONE;
533 
534 	switch (stage)
535 	{
536 	case PIPELINE_STAGE_FRAGMENT:
537 		result = GL_FRAGMENT_SHADER;
538 		break;
539 	case PIPELINE_STAGE_TESSELLATION_CONTROL:
540 		result = m_glExtTokens.TESS_CONTROL_SHADER;
541 		break;
542 	case PIPELINE_STAGE_TESSELLATION_EVALUATION:
543 		result = m_glExtTokens.TESS_EVALUATION_SHADER;
544 		break;
545 	case PIPELINE_STAGE_VERTEX:
546 		result = GL_VERTEX_SHADER;
547 		break;
548 
549 	default:
550 	{
551 		TCU_FAIL("Unrecognized pipeline stage");
552 	}
553 	}
554 
555 	return result;
556 }
557 
558 /** Retrieves source code of vertex shader that should be attached to the test
559  *  program object.
560  *
561  *  @param n_program_object Index of the program object the source code should
562  *                          be returned for.
563  *
564  *  @return Vertex shader source code to be used for user-specified program object.
565  */
getVertexShaderCode(unsigned int n_program_object)566 std::string TessellationShaderErrorsTestCaseBase::getVertexShaderCode(unsigned int n_program_object)
567 {
568 	DE_UNREF(n_program_object);
569 
570 	return "${VERSION}\n"
571 		   "\n"
572 		   "void main()\n"
573 		   "{\n"
574 		   "}\n";
575 }
576 
577 /** Constructor
578  *
579  * @param context Test context
580  **/
TessellationShaderError1InputBlocks(Context & context,const ExtParameters & extParams)581 TessellationShaderError1InputBlocks::TessellationShaderError1InputBlocks(Context&			  context,
582 																		 const ExtParameters& extParams)
583 	: TessellationShaderErrorsTestCaseBase(context, extParams, "tc_non_arrayed_per_vertex_input_blocks",
584 										   "Tries to use non-arrayed per-vertex input blocks"
585 										   "in a tessellation control shader")
586 {
587 	/* Left blank on purpose */
588 }
589 
590 /** Determines what compilation result is anticipated for each of the pipeline stages.
591  *
592  *  @param pipeline_stage Pipeline stage to return compilation result for.
593  *
594  *  @return Requested compilation result.
595  **/
getCompilationResult(_pipeline_stage pipeline_stage)596 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError1InputBlocks::getCompilationResult(
597 	_pipeline_stage pipeline_stage)
598 {
599 	/* Tessellation control shader is allowed to fail to compile,
600 	 * shaders for all other stages should compile successfully
601 	 *
602 	 * NOTE: Vertex shader compilation can fail if underlying implementation does not support
603 	 *       GL_EXT_shader_io_blocks.
604 	 **/
605 	switch (pipeline_stage)
606 	{
607 	case PIPELINE_STAGE_VERTEX:
608 		return COMPILATION_RESULT_CAN_FAIL;
609 	case PIPELINE_STAGE_TESSELLATION_CONTROL:
610 		return COMPILATION_RESULT_CAN_FAIL;
611 	default:
612 		return COMPILATION_RESULT_MUST_SUCCEED;
613 	}
614 }
615 
616 /** Determines what linking result is anticipated for all program objects created by the test.
617  *
618  *  @return Expected linking result.
619  **/
getLinkingResult()620 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError1InputBlocks::getLinkingResult()
621 {
622 	return LINKING_RESULT_MUST_FAIL;
623 }
624 
625 /** Retrieves source code of tessellation control shader that should be attached to the test
626  *  program object.
627  *
628  *  @param n_program_object Index of the program object the source code should
629  *                          be returned for.
630  *
631  *  @return Tessellation control shader source code to be used for user-specified program object.
632  */
getTessellationControlShaderCode(unsigned int n_program_object)633 std::string TessellationShaderError1InputBlocks::getTessellationControlShaderCode(unsigned int n_program_object)
634 {
635 	DE_UNREF(n_program_object);
636 
637 	return "${VERSION}\n"
638 		   "\n"
639 		   "${TESSELLATION_SHADER_REQUIRE}\n"
640 		   "\n"
641 		   "layout (vertices=4) out;\n"
642 		   "\n"
643 		   /* Invalid input block declaration */
644 		   "in IN_TC\n"
645 		   "{\n"
646 		   "    vec4 test_block_field;\n"
647 		   "} test_block;\n"
648 		   "\n"
649 		   "void main()\n"
650 		   "{\n"
651 		   "    gl_out[gl_InvocationID].gl_Position = test_block.test_block_field;\n"
652 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
653 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
654 		   "    gl_TessLevelOuter[2]                = 1.0;\n"
655 		   "    gl_TessLevelOuter[3]                = 1.0;\n"
656 		   "    gl_TessLevelInner[0]                = 1.0;\n"
657 		   "    gl_TessLevelInner[1]                = 1.0;\n"
658 		   "}\n";
659 }
660 
661 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
662  *  program object.
663  *
664  *  @param n_program_object Index of the program object the source code should
665  *                          be returned for.
666  *
667  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
668  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)669 std::string TessellationShaderError1InputBlocks::getTessellationEvaluationShaderCode(unsigned int n_program_object)
670 {
671 	DE_UNREF(n_program_object);
672 
673 	return "${VERSION}\n"
674 		   "\n"
675 		   "${TESSELLATION_SHADER_REQUIRE}\n"
676 		   "\n"
677 		   "layout (quads) in;\n"
678 		   "\n"
679 		   "void main()\n"
680 		   "{\n"
681 		   "    gl_Position = gl_in[0].gl_Position;\n"
682 		   "}\n";
683 }
684 
685 /** Retrieves source code of vertex shader that should be attached to the test
686  *  program object.
687  *
688  *  @param n_program_object Index of the program object the source code should
689  *                          be returned for.
690  *
691  *  @return Vertex shader source code to be used for user-specified program object.
692  */
getVertexShaderCode(unsigned int n_program_object)693 std::string TessellationShaderError1InputBlocks::getVertexShaderCode(unsigned int n_program_object)
694 {
695 	DE_UNREF(n_program_object);
696 
697 	return "${VERSION}\n"
698 		   "\n"
699 		   "${SHADER_IO_BLOCKS_REQUIRE}\n"
700 		   "\n"
701 		   "out IN_TC\n"
702 		   "{\n"
703 		   "    vec4 test_block_field;\n"
704 		   "} test_block;\n"
705 		   "\n"
706 		   "void main()\n"
707 		   "{\n"
708 		   "    test_block.test_block_field = vec4(1.0, 2.0, 3.0, gl_VertexID);\n"
709 		   "}\n";
710 }
711 
712 /** Tells whether given pipeline stage should be used for the purpose of the test
713  *  (for all program objects).
714  *
715  *  @param Stage to query.
716  *
717  *  @return True if a shader object implementing the stage should be attached to
718  *          test program object;
719  *          False otherwise.
720  **/
isPipelineStageUsed(_pipeline_stage stage)721 bool TessellationShaderError1InputBlocks::isPipelineStageUsed(_pipeline_stage stage)
722 {
723 	DE_UNREF(stage);
724 
725 	/* All stages used */
726 	return true;
727 }
728 
729 /** Constructor
730  *
731  * @param context Test context
732  **/
TessellationShaderError1InputVariables(Context & context,const ExtParameters & extParams)733 TessellationShaderError1InputVariables::TessellationShaderError1InputVariables(Context&				context,
734 																			   const ExtParameters& extParams)
735 	: TessellationShaderErrorsTestCaseBase(context, extParams, "tc_non_arrayed_per_vertex_input_variables",
736 										   "Tries to use non-arrayed per-vertex input variables"
737 										   "in a tessellation control shader")
738 {
739 	/* Left blank on purpose */
740 }
741 
742 /** Determines what compilation result is anticipated for each of the pipeline stages.
743  *
744  *  @param pipeline_stage Pipeline stage to return compilation result for.
745  *
746  *  @return Requested compilation result.
747  **/
getCompilationResult(_pipeline_stage pipeline_stage)748 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError1InputVariables::getCompilationResult(
749 	_pipeline_stage pipeline_stage)
750 {
751 	/* Tessellation control shader is allowed to fail to compile,
752 	 * shaders for all other stages should compile successfully */
753 	switch (pipeline_stage)
754 	{
755 	case PIPELINE_STAGE_TESSELLATION_CONTROL:
756 		return COMPILATION_RESULT_CAN_FAIL;
757 	default:
758 		return COMPILATION_RESULT_MUST_SUCCEED;
759 	}
760 }
761 
762 /** Determines what linking result is anticipated for all program objects created by the test.
763  *
764  *  @return Expected linking result.
765  **/
getLinkingResult()766 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError1InputVariables::getLinkingResult()
767 {
768 	return LINKING_RESULT_MUST_FAIL;
769 }
770 
771 /** Retrieves source code of tessellation control shader that should be attached to the test
772  *  program object.
773  *
774  *  @param n_program_object Index of the program object the source code should
775  *                          be returned for.
776  *
777  *  @return Tessellation control shader source code to be used for user-specified program object.
778  */
getTessellationControlShaderCode(unsigned int n_program_object)779 std::string TessellationShaderError1InputVariables::getTessellationControlShaderCode(unsigned int n_program_object)
780 {
781 	DE_UNREF(n_program_object);
782 
783 	return "${VERSION}\n"
784 		   "\n"
785 		   "${TESSELLATION_SHADER_REQUIRE}\n"
786 		   "\n"
787 		   "layout (vertices=4) out;\n"
788 		   "\n"
789 		   /* Invalid input declaration */
790 		   "in vec4 test_field;\n"
791 		   "\n"
792 		   "void main()\n"
793 		   "{\n"
794 		   "    gl_out[gl_InvocationID].gl_Position = test_field;\n"
795 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
796 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
797 		   "    gl_TessLevelOuter[2]                = 1.0;\n"
798 		   "    gl_TessLevelOuter[3]                = 1.0;\n"
799 		   "    gl_TessLevelInner[0]                = 1.0;\n"
800 		   "    gl_TessLevelInner[1]                = 1.0;\n"
801 		   "}\n";
802 }
803 
804 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
805  *  program object.
806  *
807  *  @param n_program_object Index of the program object the source code should
808  *                          be returned for.
809  *
810  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
811  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)812 std::string TessellationShaderError1InputVariables::getTessellationEvaluationShaderCode(unsigned int n_program_object)
813 {
814 	DE_UNREF(n_program_object);
815 
816 	return "${VERSION}\n"
817 		   "\n"
818 		   "${TESSELLATION_SHADER_REQUIRE}\n"
819 		   "\n"
820 		   "layout (quads) in;\n"
821 		   "\n"
822 		   "void main()\n"
823 		   "{\n"
824 		   "    gl_Position = gl_in[0].gl_Position;\n"
825 		   "}\n";
826 }
827 
828 /** Retrieves source code of vertex shader that should be attached to the test
829  *  program object.
830  *
831  *  @param n_program_object Index of the program object the source code should
832  *                          be returned for.
833  *
834  *  @return Vertex shader source code to be used for user-specified program object.
835  */
getVertexShaderCode(unsigned int n_program_object)836 std::string TessellationShaderError1InputVariables::getVertexShaderCode(unsigned int n_program_object)
837 {
838 	DE_UNREF(n_program_object);
839 
840 	return "${VERSION}\n"
841 		   "\n"
842 		   "out vec4 test_field;\n"
843 		   "\n"
844 		   "void main()\n"
845 		   "{\n"
846 		   "    test_field = vec4(1.0, 2.0, 3.0, gl_VertexID);\n"
847 		   "}\n";
848 }
849 
850 /** Tells whether given pipeline stage should be used for the purpose of the test
851  *  (for all program objects).
852  *
853  *  @param Stage to query.
854  *
855  *  @return True if a shader object implementing the stage should be attached to
856  *          test program object;
857  *          False otherwise.
858  **/
isPipelineStageUsed(_pipeline_stage stage)859 bool TessellationShaderError1InputVariables::isPipelineStageUsed(_pipeline_stage stage)
860 {
861 	DE_UNREF(stage);
862 
863 	/* All stages used */
864 	return true;
865 }
866 
867 /** Constructor
868  *
869  * @param context Test context
870  **/
TessellationShaderError2OutputBlocks(Context & context,const ExtParameters & extParams)871 TessellationShaderError2OutputBlocks::TessellationShaderError2OutputBlocks(Context&				context,
872 																		   const ExtParameters& extParams)
873 	: TessellationShaderErrorsTestCaseBase(context, extParams, "tc_non_arrayed_per_vertex_output_blocks",
874 										   "Tries to use non-arrayed per-vertex output blocks"
875 										   "in a tessellation control shader")
876 {
877 	/* Left blank on purpose */
878 }
879 
880 /** Determines what compilation result is anticipated for each of the pipeline stages.
881  *
882  *  @param pipeline_stage Pipeline stage to return compilation result for.
883  *
884  *  @return Requested compilation result.
885  **/
getCompilationResult(_pipeline_stage pipeline_stage)886 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError2OutputBlocks::getCompilationResult(
887 	_pipeline_stage pipeline_stage)
888 {
889 	/* Tessellation control shader is allowed to fail to compile,
890 	 * shaders for all other stages should compile successfully */
891 	switch (pipeline_stage)
892 	{
893 	case PIPELINE_STAGE_TESSELLATION_CONTROL:
894 		return COMPILATION_RESULT_CAN_FAIL;
895 	default:
896 		return COMPILATION_RESULT_MUST_SUCCEED;
897 	}
898 }
899 
900 /** Determines what linking result is anticipated for all program objects created by the test.
901  *
902  *  @return Expected linking result.
903  **/
getLinkingResult()904 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError2OutputBlocks::getLinkingResult()
905 {
906 	return LINKING_RESULT_MUST_FAIL;
907 }
908 
909 /** Retrieves source code of tessellation control shader that should be attached to the test
910  *  program object.
911  *
912  *  @param n_program_object Index of the program object the source code should
913  *                          be returned for.
914  *
915  *  @return Tessellation control shader source code to be used for user-specified program object.
916  */
getTessellationControlShaderCode(unsigned int n_program_object)917 std::string TessellationShaderError2OutputBlocks::getTessellationControlShaderCode(unsigned int n_program_object)
918 {
919 	DE_UNREF(n_program_object);
920 
921 	return "${VERSION}\n"
922 		   "\n"
923 		   "${TESSELLATION_SHADER_REQUIRE}\n"
924 		   "\n"
925 		   "layout (vertices=4) out;\n"
926 		   "\n"
927 		   /* Invalid output block declaration */
928 		   "out OUT_TC\n"
929 		   "{\n"
930 		   "    vec4 test_block_field;\n"
931 		   "} test_block;\n"
932 		   "\n"
933 		   "void main()\n"
934 		   "{\n"
935 		   "    gl_out[gl_InvocationID].gl_Position = test_block.test_block_field;\n"
936 		   "    test_block.test_block_field         = gl_in[gl_InvocationID].gl_Position;\n"
937 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
938 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
939 		   "    gl_TessLevelOuter[2]                = 1.0;\n"
940 		   "    gl_TessLevelOuter[3]                = 1.0;\n"
941 		   "    gl_TessLevelInner[0]                = 1.0;\n"
942 		   "    gl_TessLevelInner[1]                = 1.0;\n"
943 		   "}\n";
944 }
945 
946 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
947  *  program object.
948  *
949  *  @param n_program_object Index of the program object the source code should
950  *                          be returned for.
951  *
952  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
953  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)954 std::string TessellationShaderError2OutputBlocks::getTessellationEvaluationShaderCode(unsigned int n_program_object)
955 {
956 	DE_UNREF(n_program_object);
957 
958 	return "${VERSION}\n"
959 		   "\n"
960 		   "${TESSELLATION_SHADER_REQUIRE}\n"
961 		   "\n"
962 		   "layout (quads) in;\n"
963 		   "\n"
964 		   "void main()\n"
965 		   "{\n"
966 		   "    gl_Position = gl_in[0].gl_Position;\n"
967 		   "}\n";
968 }
969 
970 /** Tells whether given pipeline stage should be used for the purpose of the test
971  *  (for all program objects).
972  *
973  *  @param Stage to query.
974  *
975  *  @return True if a shader object implementing the stage should be attached to
976  *          test program object;
977  *          False otherwise.
978  **/
isPipelineStageUsed(_pipeline_stage stage)979 bool TessellationShaderError2OutputBlocks::isPipelineStageUsed(_pipeline_stage stage)
980 {
981 	DE_UNREF(stage);
982 
983 	/* All stages used */
984 	return true;
985 }
986 
987 /** Constructor
988  *
989  * @param context Test context
990  **/
TessellationShaderError2OutputVariables(Context & context,const ExtParameters & extParams)991 TessellationShaderError2OutputVariables::TessellationShaderError2OutputVariables(Context&			  context,
992 																				 const ExtParameters& extParams)
993 	: TessellationShaderErrorsTestCaseBase(context, extParams, "tc_non_arrayed_per_vertex_output_variabless",
994 										   "Tries to use non-arrayed per-vertex output variables"
995 										   "in a tessellation control shader")
996 {
997 	/* Left blank on purpose */
998 }
999 
1000 /** Determines what compilation result is anticipated for each of the pipeline stages.
1001  *
1002  *  @param pipeline_stage Pipeline stage to return compilation result for.
1003  *
1004  *  @return Requested compilation result.
1005  **/
getCompilationResult(_pipeline_stage pipeline_stage)1006 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError2OutputVariables::getCompilationResult(
1007 	_pipeline_stage pipeline_stage)
1008 {
1009 	/* Tessellation control shader is allowed to fail to compile,
1010 	 * shaders for all other stages should compile successfully */
1011 	switch (pipeline_stage)
1012 	{
1013 	case PIPELINE_STAGE_TESSELLATION_CONTROL:
1014 		return COMPILATION_RESULT_CAN_FAIL;
1015 	default:
1016 		return COMPILATION_RESULT_MUST_SUCCEED;
1017 	}
1018 }
1019 
1020 /** Determines what linking result is anticipated for all program objects created by the test.
1021  *
1022  *  @return Expected linking result.
1023  **/
getLinkingResult()1024 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError2OutputVariables::getLinkingResult()
1025 {
1026 	return LINKING_RESULT_MUST_FAIL;
1027 }
1028 
1029 /** Retrieves source code of tessellation control shader that should be attached to the test
1030  *  program object.
1031  *
1032  *  @param n_program_object Index of the program object the source code should
1033  *                          be returned for.
1034  *
1035  *  @return Tessellation control shader source code to be used for user-specified program object.
1036  */
getTessellationControlShaderCode(unsigned int n_program_object)1037 std::string TessellationShaderError2OutputVariables::getTessellationControlShaderCode(unsigned int n_program_object)
1038 {
1039 	DE_UNREF(n_program_object);
1040 
1041 	return "${VERSION}\n"
1042 		   "\n"
1043 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1044 		   "\n"
1045 		   "layout (vertices=4) out;\n"
1046 		   "\n"
1047 		   /* Invalid output declaration */
1048 		   "out vec4 test_field;\n"
1049 		   "\n"
1050 		   "void main()\n"
1051 		   "{\n"
1052 		   "    gl_out[gl_InvocationID].gl_Position = vec4(2.0);\n"
1053 		   "    test_field                          = vec4(3.0);\n"
1054 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
1055 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
1056 		   "    gl_TessLevelOuter[2]                = 1.0;\n"
1057 		   "    gl_TessLevelOuter[3]                = 1.0;\n"
1058 		   "    gl_TessLevelInner[0]                = 1.0;\n"
1059 		   "    gl_TessLevelInner[1]                = 1.0;\n"
1060 		   "}\n";
1061 }
1062 
1063 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
1064  *  program object.
1065  *
1066  *  @param n_program_object Index of the program object the source code should
1067  *                          be returned for.
1068  *
1069  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
1070  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)1071 std::string TessellationShaderError2OutputVariables::getTessellationEvaluationShaderCode(unsigned int n_program_object)
1072 {
1073 	DE_UNREF(n_program_object);
1074 
1075 	return "${VERSION}\n"
1076 		   "\n"
1077 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1078 		   "\n"
1079 		   "layout (quads) in;\n"
1080 		   "\n"
1081 		   "void main()\n"
1082 		   "{\n"
1083 		   "    gl_Position = gl_in[0].gl_Position;\n"
1084 		   "}\n";
1085 }
1086 
1087 /** Tells whether given pipeline stage should be used for the purpose of the test
1088  *  (for all program objects).
1089  *
1090  *  @param Stage to query.
1091  *
1092  *  @return True if a shader object implementing the stage should be attached to
1093  *          test program object;
1094  *          False otherwise.
1095  **/
isPipelineStageUsed(_pipeline_stage stage)1096 bool TessellationShaderError2OutputVariables::isPipelineStageUsed(_pipeline_stage stage)
1097 {
1098 	DE_UNREF(stage);
1099 
1100 	/* All stages used */
1101 	return true;
1102 }
1103 
1104 /** Constructor
1105  *
1106  * @param context Test context
1107  **/
TessellationShaderError3InputBlocks(Context & context,const ExtParameters & extParams)1108 TessellationShaderError3InputBlocks::TessellationShaderError3InputBlocks(Context&			  context,
1109 																		 const ExtParameters& extParams)
1110 	: TessellationShaderErrorsTestCaseBase(context, extParams, "te_non_arrayed_per_vertex_input_blocks",
1111 										   "Tries to use non-arrayed per-vertex input blocks"
1112 										   "in a tessellation evaluation shader")
1113 {
1114 	/* Left blank on purpose */
1115 }
1116 
1117 /** Determines what compilation result is anticipated for each of the pipeline stages.
1118  *
1119  *  @param pipeline_stage Pipeline stage to return compilation result for.
1120  *
1121  *  @return Requested compilation result.
1122  **/
getCompilationResult(_pipeline_stage pipeline_stage)1123 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError3InputBlocks::getCompilationResult(
1124 	_pipeline_stage pipeline_stage)
1125 {
1126 	/* Tessellation evaluation shader is allowed to fail to compile,
1127 	 * shaders for all other stages should compile successfully */
1128 	switch (pipeline_stage)
1129 	{
1130 	case PIPELINE_STAGE_TESSELLATION_EVALUATION:
1131 		return COMPILATION_RESULT_CAN_FAIL;
1132 	default:
1133 		return COMPILATION_RESULT_MUST_SUCCEED;
1134 	}
1135 }
1136 
1137 /** Determines what linking result is anticipated for all program objects created by the test.
1138  *
1139  *  @return Expected linking result.
1140  **/
getLinkingResult()1141 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError3InputBlocks::getLinkingResult()
1142 {
1143 	return LINKING_RESULT_MUST_FAIL;
1144 }
1145 
1146 /** Retrieves source code of tessellation control shader that should be attached to the test
1147  *  program object.
1148  *
1149  *  @param n_program_object Index of the program object the source code should
1150  *                          be returned for.
1151  *
1152  *  @return Tessellation control shader source code to be used for user-specified program object.
1153  */
getTessellationControlShaderCode(unsigned int n_program_object)1154 std::string TessellationShaderError3InputBlocks::getTessellationControlShaderCode(unsigned int n_program_object)
1155 {
1156 	DE_UNREF(n_program_object);
1157 
1158 	return "${VERSION}\n"
1159 		   "\n"
1160 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1161 		   "\n"
1162 		   "layout (vertices=4) out;\n"
1163 		   "\n"
1164 		   "out IN_TE\n"
1165 		   "{\n"
1166 		   "    vec4 test_block_field;\n"
1167 		   "} test_block[];\n"
1168 		   "\n"
1169 		   "void main()\n"
1170 		   "{\n"
1171 		   "    gl_out           [gl_InvocationID].gl_Position      = gl_in[gl_InvocationID].gl_Position;\n"
1172 		   "    test_block       [gl_InvocationID].test_block_field = vec4(2.0);\n"
1173 		   "    gl_TessLevelOuter[0]                                = 1.0;\n"
1174 		   "    gl_TessLevelOuter[1]                                = 1.0;\n"
1175 		   "    gl_TessLevelOuter[2]                                = 1.0;\n"
1176 		   "    gl_TessLevelOuter[3]                                = 1.0;\n"
1177 		   "    gl_TessLevelInner[0]                                = 1.0;\n"
1178 		   "    gl_TessLevelInner[1]                                = 1.0;\n"
1179 		   "}\n";
1180 }
1181 
1182 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
1183  *  program object.
1184  *
1185  *  @param n_program_object Index of the program object the source code should
1186  *                          be returned for.
1187  *
1188  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
1189  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)1190 std::string TessellationShaderError3InputBlocks::getTessellationEvaluationShaderCode(unsigned int n_program_object)
1191 {
1192 	DE_UNREF(n_program_object);
1193 
1194 	return "${VERSION}\n"
1195 		   "\n"
1196 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1197 		   "\n"
1198 		   "layout (quads) in;\n"
1199 		   "\n"
1200 		   /* Invalid input block declaration */
1201 		   "in IN_TE\n"
1202 		   "{\n"
1203 		   "    vec4 test_block_field;\n"
1204 		   "} test_block;\n"
1205 		   "\n"
1206 		   "void main()\n"
1207 		   "{\n"
1208 		   "    gl_Position = gl_in[0].gl_Position * test_block.test_block_field;\n"
1209 		   "}\n";
1210 }
1211 
1212 /** Tells whether given pipeline stage should be used for the purpose of the test
1213  *  (for all program objects).
1214  *
1215  *  @param Stage to query.
1216  *
1217  *  @return True if a shader object implementing the stage should be attached to
1218  *          test program object;
1219  *          False otherwise.
1220  **/
isPipelineStageUsed(_pipeline_stage stage)1221 bool TessellationShaderError3InputBlocks::isPipelineStageUsed(_pipeline_stage stage)
1222 {
1223 	DE_UNREF(stage);
1224 
1225 	/* All stages used */
1226 	return true;
1227 }
1228 
1229 /** Constructor
1230  *
1231  * @param context Test context
1232  **/
TessellationShaderError3InputVariables(Context & context,const ExtParameters & extParams)1233 TessellationShaderError3InputVariables::TessellationShaderError3InputVariables(Context&				context,
1234 																			   const ExtParameters& extParams)
1235 	: TessellationShaderErrorsTestCaseBase(context, extParams, "te_non_arrayed_per_vertex_input_variables",
1236 										   "Tries to use non-arrayed per-vertex input variables "
1237 										   "in a tessellation evaluation shader")
1238 {
1239 	/* Left blank on purpose */
1240 }
1241 
1242 /** Determines what compilation result is anticipated for each of the pipeline stages.
1243  *
1244  *  @param pipeline_stage Pipeline stage to return compilation result for.
1245  *
1246  *  @return Requested compilation result.
1247  **/
getCompilationResult(_pipeline_stage pipeline_stage)1248 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError3InputVariables::getCompilationResult(
1249 	_pipeline_stage pipeline_stage)
1250 {
1251 	/* Tessellation evaluation shader is allowed to fail to compile,
1252 	 * shaders for all other stages should compile successfully */
1253 	switch (pipeline_stage)
1254 	{
1255 	case PIPELINE_STAGE_TESSELLATION_EVALUATION:
1256 		return COMPILATION_RESULT_CAN_FAIL;
1257 	default:
1258 		return COMPILATION_RESULT_MUST_SUCCEED;
1259 	}
1260 }
1261 
1262 /** Determines what linking result is anticipated for all program objects created by the test.
1263  *
1264  *  @return Expected linking result.
1265  **/
getLinkingResult()1266 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError3InputVariables::getLinkingResult()
1267 {
1268 	return LINKING_RESULT_MUST_FAIL;
1269 }
1270 
1271 /** Retrieves source code of tessellation control shader that should be attached to the test
1272  *  program object.
1273  *
1274  *  @param n_program_object Index of the program object the source code should
1275  *                          be returned for.
1276  *
1277  *  @return Tessellation control shader source code to be used for user-specified program object.
1278  */
getTessellationControlShaderCode(unsigned int n_program_object)1279 std::string TessellationShaderError3InputVariables::getTessellationControlShaderCode(unsigned int n_program_object)
1280 {
1281 	DE_UNREF(n_program_object);
1282 
1283 	return "${VERSION}\n"
1284 		   "\n"
1285 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1286 		   "\n"
1287 		   "layout (vertices=4) out;\n"
1288 		   "\n"
1289 		   "out vec4 test_field[];\n"
1290 		   "\n"
1291 		   "void main()\n"
1292 		   "{\n"
1293 		   "    gl_out           [gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
1294 		   "    test_field       [gl_InvocationID]             = vec4(4.0);\n"
1295 		   "    gl_TessLevelOuter[0]                           = 1.0;\n"
1296 		   "    gl_TessLevelOuter[1]                           = 1.0;\n"
1297 		   "    gl_TessLevelOuter[2]                           = 1.0;\n"
1298 		   "    gl_TessLevelOuter[3]                           = 1.0;\n"
1299 		   "    gl_TessLevelInner[0]                           = 1.0;\n"
1300 		   "    gl_TessLevelInner[1]                           = 1.0;\n"
1301 		   "}\n";
1302 }
1303 
1304 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
1305  *  program object.
1306  *
1307  *  @param n_program_object Index of the program object the source code should
1308  *                          be returned for.
1309  *
1310  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
1311  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)1312 std::string TessellationShaderError3InputVariables::getTessellationEvaluationShaderCode(unsigned int n_program_object)
1313 {
1314 	DE_UNREF(n_program_object);
1315 
1316 	return "${VERSION}\n"
1317 		   "\n"
1318 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1319 		   "\n"
1320 		   "layout (quads) in;\n"
1321 		   "\n"
1322 		   /* Invalid input declaration */
1323 		   "in vec4 test_field;\n"
1324 		   "\n"
1325 		   "void main()\n"
1326 		   "{\n"
1327 		   "    gl_Position = gl_in[0].gl_Position * test_field;\n"
1328 		   "}\n";
1329 }
1330 
1331 /** Tells whether given pipeline stage should be used for the purpose of the test
1332  *  (for all program objects).
1333  *
1334  *  @param Stage to query.
1335  *
1336  *  @return True if a shader object implementing the stage should be attached to
1337  *          test program object;
1338  *          False otherwise.
1339  **/
isPipelineStageUsed(_pipeline_stage stage)1340 bool TessellationShaderError3InputVariables::isPipelineStageUsed(_pipeline_stage stage)
1341 {
1342 	DE_UNREF(stage);
1343 
1344 	/* All stages used */
1345 	return true;
1346 }
1347 
1348 /** Constructor
1349  *
1350  * @param context Test context
1351  **/
TessellationShaderError4InputBlocks(Context & context,const ExtParameters & extParams)1352 TessellationShaderError4InputBlocks::TessellationShaderError4InputBlocks(Context&			  context,
1353 																		 const ExtParameters& extParams)
1354 	: TessellationShaderErrorsTestCaseBase(context, extParams, "tc_invalid_array_size_used_for_input_blocks",
1355 										   "Tries to use invalid array size when defining input blocks "
1356 										   "in a tessellation control shader")
1357 {
1358 	/* Left blank on purpose */
1359 }
1360 
1361 /** Determines what compilation result is anticipated for each of the pipeline stages.
1362  *
1363  *  @param pipeline_stage Pipeline stage to return compilation result for.
1364  *
1365  *  @return Requested compilation result.
1366  **/
getCompilationResult(_pipeline_stage pipeline_stage)1367 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError4InputBlocks::getCompilationResult(
1368 	_pipeline_stage pipeline_stage)
1369 {
1370 	/* Tessellation control shader is allowed to fail to compile,
1371 	 * shaders for all other stages should compile successfully */
1372 	switch (pipeline_stage)
1373 	{
1374 	case PIPELINE_STAGE_TESSELLATION_CONTROL:
1375 		return COMPILATION_RESULT_CAN_FAIL;
1376 	default:
1377 		return COMPILATION_RESULT_MUST_SUCCEED;
1378 	}
1379 }
1380 
1381 /** Determines what linking result is anticipated for all program objects created by the test.
1382  *
1383  *  @return Expected linking result.
1384  **/
getLinkingResult()1385 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError4InputBlocks::getLinkingResult()
1386 {
1387 	return LINKING_RESULT_MUST_FAIL;
1388 }
1389 
1390 /** Retrieves source code of tessellation control shader that should be attached to the test
1391  *  program object.
1392  *
1393  *  @param n_program_object Index of the program object the source code should
1394  *                          be returned for.
1395  *
1396  *  @return Tessellation control shader source code to be used for user-specified program object.
1397  */
getTessellationControlShaderCode(unsigned int n_program_object)1398 std::string TessellationShaderError4InputBlocks::getTessellationControlShaderCode(unsigned int n_program_object)
1399 {
1400 	DE_UNREF(n_program_object);
1401 
1402 	return "${VERSION}\n"
1403 		   "\n"
1404 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1405 		   "\n"
1406 		   "layout (vertices=4) out;\n"
1407 		   "\n"
1408 		   /* Invalid input block size */
1409 		   "in IN_TC\n"
1410 		   "{\n"
1411 		   "    vec4 input_block_input;\n"
1412 		   "} input_block[11];\n"
1413 		   "\n"
1414 		   "void main()\n"
1415 		   "{\n"
1416 		   "    gl_out[gl_InvocationID].gl_Position = input_block[gl_InvocationID].input_block_input;\n"
1417 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
1418 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
1419 		   "}\n";
1420 }
1421 
1422 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
1423  *  program object.
1424  *
1425  *  @param n_program_object Index of the program object the source code should
1426  *                          be returned for.
1427  *
1428  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
1429  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)1430 std::string TessellationShaderError4InputBlocks::getTessellationEvaluationShaderCode(unsigned int n_program_object)
1431 {
1432 	DE_UNREF(n_program_object);
1433 
1434 	return "${VERSION}\n"
1435 		   "\n"
1436 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1437 		   "\n"
1438 		   "layout(isolines) in;\n"
1439 		   "\n"
1440 		   "void main()\n"
1441 		   "{\n"
1442 		   "    gl_Position = gl_in[0].gl_Position;\n"
1443 		   "}\n";
1444 }
1445 
1446 /** Tells whether given pipeline stage should be used for the purpose of the test
1447  *  (for all program objects).
1448  *
1449  *  @param Stage to query.
1450  *
1451  *  @return True if a shader object implementing the stage should be attached to
1452  *          test program object;
1453  *          False otherwise.
1454  **/
isPipelineStageUsed(_pipeline_stage stage)1455 bool TessellationShaderError4InputBlocks::isPipelineStageUsed(_pipeline_stage stage)
1456 {
1457 	DE_UNREF(stage);
1458 
1459 	/* All stages used */
1460 	return true;
1461 }
1462 
1463 /** Constructor
1464  *
1465  * @param context Test context
1466  **/
TessellationShaderError4InputVariables(Context & context,const ExtParameters & extParams)1467 TessellationShaderError4InputVariables::TessellationShaderError4InputVariables(Context&				context,
1468 																			   const ExtParameters& extParams)
1469 	: TessellationShaderErrorsTestCaseBase(context, extParams, "tc_invalid_array_size_used_for_input_variables",
1470 										   "Tries to use invalid array size when defining input variables"
1471 										   " in a tessellation control shader")
1472 {
1473 	/* Left blank on purpose */
1474 }
1475 
1476 /** Determines what compilation result is anticipated for each of the pipeline stages.
1477  *
1478  *  @param pipeline_stage Pipeline stage to return compilation result for.
1479  *
1480  *  @return Requested compilation result.
1481  **/
getCompilationResult(_pipeline_stage pipeline_stage)1482 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError4InputVariables::getCompilationResult(
1483 	_pipeline_stage pipeline_stage)
1484 {
1485 	/* Tessellation control shader is allowed to fail to compile,
1486 	 * shaders for all other stages should compile successfully */
1487 	switch (pipeline_stage)
1488 	{
1489 	case PIPELINE_STAGE_TESSELLATION_CONTROL:
1490 		return COMPILATION_RESULT_CAN_FAIL;
1491 	default:
1492 		return COMPILATION_RESULT_MUST_SUCCEED;
1493 	}
1494 }
1495 
1496 /** Determines what linking result is anticipated for all program objects created by the test.
1497  *
1498  *  @return Expected linking result.
1499  **/
getLinkingResult()1500 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError4InputVariables::getLinkingResult()
1501 {
1502 	return LINKING_RESULT_MUST_FAIL;
1503 }
1504 
1505 /** Retrieves source code of tessellation control shader that should be attached to the test
1506  *  program object.
1507  *
1508  *  @param n_program_object Index of the program object the source code should
1509  *                          be returned for.
1510  *
1511  *  @return Tessellation control shader source code to be used for user-specified program object.
1512  */
getTessellationControlShaderCode(unsigned int n_program_object)1513 std::string TessellationShaderError4InputVariables::getTessellationControlShaderCode(unsigned int n_program_object)
1514 {
1515 	DE_UNREF(n_program_object);
1516 
1517 	return "${VERSION}\n"
1518 		   "\n"
1519 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1520 		   "\n"
1521 		   "layout (vertices=4) out;\n"
1522 		   "\n"
1523 		   /* Invalid array size */
1524 		   "in vec4 test_input[11];\n"
1525 		   "\n"
1526 		   "void main()\n"
1527 		   "{\n"
1528 		   "    gl_out[gl_InvocationID].gl_Position = test_input[gl_InvocationID];\n"
1529 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
1530 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
1531 		   "}\n";
1532 }
1533 
1534 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
1535  *  program object.
1536  *
1537  *  @param n_program_object Index of the program object the source code should
1538  *                          be returned for.
1539  *
1540  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
1541  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)1542 std::string TessellationShaderError4InputVariables::getTessellationEvaluationShaderCode(unsigned int n_program_object)
1543 {
1544 	DE_UNREF(n_program_object);
1545 
1546 	return "${VERSION}\n"
1547 		   "\n"
1548 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1549 		   "\n"
1550 		   "layout(isolines) in;\n"
1551 		   "\n"
1552 		   "void main()\n"
1553 		   "{\n"
1554 		   "    gl_Position = gl_in[0].gl_Position;\n"
1555 		   "}\n";
1556 }
1557 
1558 /** Tells whether given pipeline stage should be used for the purpose of the test
1559  *  (for all program objects).
1560  *
1561  *  @param Stage to query.
1562  *
1563  *  @return True if a shader object implementing the stage should be attached to
1564  *          test program object;
1565  *          False otherwise.
1566  **/
isPipelineStageUsed(_pipeline_stage stage)1567 bool TessellationShaderError4InputVariables::isPipelineStageUsed(_pipeline_stage stage)
1568 {
1569 	DE_UNREF(stage);
1570 
1571 	/* All stages used */
1572 	return true;
1573 }
1574 
1575 /** Constructor
1576  *
1577  * @param context Test context
1578  **/
TessellationShaderError5InputBlocks(Context & context,const ExtParameters & extParams)1579 TessellationShaderError5InputBlocks::TessellationShaderError5InputBlocks(Context&			  context,
1580 																		 const ExtParameters& extParams)
1581 	: TessellationShaderErrorsTestCaseBase(context, extParams, "te_invalid_array_size_used_for_input_blocks",
1582 										   "Tries to use invalid array size when defining input "
1583 										   "blocks in a tessellation evaluation shader")
1584 {
1585 	/* Left blank on purpose */
1586 }
1587 
1588 /** Determines what compilation result is anticipated for each of the pipeline stages.
1589  *
1590  *  @param pipeline_stage Pipeline stage to return compilation result for.
1591  *
1592  *  @return Requested compilation result.
1593  **/
getCompilationResult(_pipeline_stage pipeline_stage)1594 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError5InputBlocks::getCompilationResult(
1595 	_pipeline_stage pipeline_stage)
1596 {
1597 	/* Tessellation evaluation shader is allowed to fail to compile,
1598 	 * shaders for all other stages should compile successfully */
1599 	switch (pipeline_stage)
1600 	{
1601 	case PIPELINE_STAGE_TESSELLATION_EVALUATION:
1602 		return COMPILATION_RESULT_CAN_FAIL;
1603 	default:
1604 		return COMPILATION_RESULT_MUST_SUCCEED;
1605 	}
1606 }
1607 
1608 /** Determines what linking result is anticipated for all program objects created by the test.
1609  *
1610  *  @return Expected linking result.
1611  **/
getLinkingResult()1612 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError5InputBlocks::getLinkingResult()
1613 {
1614 	return LINKING_RESULT_MUST_FAIL;
1615 }
1616 
1617 /** Retrieves source code of tessellation control shader that should be attached to the test
1618  *  program object.
1619  *
1620  *  @param n_program_object Index of the program object the source code should
1621  *                          be returned for.
1622  *
1623  *  @return Tessellation control shader source code to be used for user-specified program object.
1624  */
getTessellationControlShaderCode(unsigned int n_program_object)1625 std::string TessellationShaderError5InputBlocks::getTessellationControlShaderCode(unsigned int n_program_object)
1626 {
1627 	DE_UNREF(n_program_object);
1628 
1629 	return "${VERSION}\n"
1630 		   "\n"
1631 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1632 		   "\n"
1633 		   "layout (vertices=4) out;\n"
1634 		   "\n"
1635 		   "void main()\n"
1636 		   "{\n"
1637 		   "    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
1638 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
1639 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
1640 		   "}\n";
1641 }
1642 
1643 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
1644  *  program object.
1645  *
1646  *  @param n_program_object Index of the program object the source code should
1647  *                          be returned for.
1648  *
1649  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
1650  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)1651 std::string TessellationShaderError5InputBlocks::getTessellationEvaluationShaderCode(unsigned int n_program_object)
1652 {
1653 	DE_UNREF(n_program_object);
1654 
1655 	return "${VERSION}\n"
1656 		   "\n"
1657 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1658 		   "\n"
1659 		   "layout(isolines) in;\n"
1660 		   "\n"
1661 		   /* Invalid input block size */
1662 		   "in IN_TC\n"
1663 		   "{\n"
1664 		   "    vec4 input_block_input;\n"
1665 		   "} input_block[11];\n"
1666 		   "\n"
1667 		   "void main()\n"
1668 		   "{\n"
1669 		   "    gl_Position = gl_in[0].gl_Position * input_block[0].input_block_input;\n"
1670 		   "}\n";
1671 }
1672 
1673 /** Tells whether given pipeline stage should be used for the purpose of the test
1674  *  (for all program objects).
1675  *
1676  *  @param Stage to query.
1677  *
1678  *  @return True if a shader object implementing the stage should be attached to
1679  *          test program object;
1680  *          False otherwise.
1681  **/
isPipelineStageUsed(_pipeline_stage stage)1682 bool TessellationShaderError5InputBlocks::isPipelineStageUsed(_pipeline_stage stage)
1683 {
1684 	DE_UNREF(stage);
1685 
1686 	/* All stages used */
1687 	return true;
1688 }
1689 
1690 /** Constructor
1691  *
1692  * @param context Test context
1693  **/
TessellationShaderError5InputVariables(Context & context,const ExtParameters & extParams)1694 TessellationShaderError5InputVariables::TessellationShaderError5InputVariables(Context&				context,
1695 																			   const ExtParameters& extParams)
1696 	: TessellationShaderErrorsTestCaseBase(context, extParams, "te_invalid_array_size_used_for_input_variables",
1697 										   "Tries to use invalid array size when defining input "
1698 										   "variables in a tessellation evaluation shader")
1699 {
1700 	/* Left blank on purpose */
1701 }
1702 
1703 /** Determines what compilation result is anticipated for each of the pipeline stages.
1704  *
1705  *  @param pipeline_stage Pipeline stage to return compilation result for.
1706  *
1707  *  @return Requested compilation result.
1708  **/
getCompilationResult(_pipeline_stage pipeline_stage)1709 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError5InputVariables::getCompilationResult(
1710 	_pipeline_stage pipeline_stage)
1711 {
1712 	/* Tessellation evaluation shader is allowed to fail to compile,
1713 	 * shaders for all other stages should compile successfully */
1714 	switch (pipeline_stage)
1715 	{
1716 	case PIPELINE_STAGE_TESSELLATION_EVALUATION:
1717 		return COMPILATION_RESULT_CAN_FAIL;
1718 	default:
1719 		return COMPILATION_RESULT_MUST_SUCCEED;
1720 	}
1721 }
1722 
1723 /** Determines what linking result is anticipated for all program objects created by the test.
1724  *
1725  *  @return Expected linking result.
1726  **/
getLinkingResult()1727 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError5InputVariables::getLinkingResult()
1728 {
1729 	return LINKING_RESULT_MUST_FAIL;
1730 }
1731 
1732 /** Retrieves source code of tessellation control shader that should be attached to the test
1733  *  program object.
1734  *
1735  *  @param n_program_object Index of the program object the source code should
1736  *                          be returned for.
1737  *
1738  *  @return Tessellation control shader source code to be used for user-specified program object.
1739  */
getTessellationControlShaderCode(unsigned int n_program_object)1740 std::string TessellationShaderError5InputVariables::getTessellationControlShaderCode(unsigned int n_program_object)
1741 {
1742 	DE_UNREF(n_program_object);
1743 
1744 	return "${VERSION}\n"
1745 		   "\n"
1746 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1747 		   "\n"
1748 		   "layout (vertices=4) out;\n"
1749 		   "\n"
1750 		   "void main()\n"
1751 		   "{\n"
1752 		   "    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
1753 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
1754 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
1755 		   "}\n";
1756 }
1757 
1758 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
1759  *  program object.
1760  *
1761  *  @param n_program_object Index of the program object the source code should
1762  *                          be returned for.
1763  *
1764  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
1765  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)1766 std::string TessellationShaderError5InputVariables::getTessellationEvaluationShaderCode(unsigned int n_program_object)
1767 {
1768 	DE_UNREF(n_program_object);
1769 
1770 	return "${VERSION}\n"
1771 		   "\n"
1772 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1773 		   "\n"
1774 		   "layout(isolines) in;\n"
1775 		   "\n"
1776 		   /* Invalid array size */
1777 		   "in vec4 test_input[11];\n"
1778 		   "\n"
1779 		   "void main()\n"
1780 		   "{\n"
1781 		   "    gl_Position = gl_in[0].gl_Position * test_input[0];\n"
1782 		   "}\n";
1783 }
1784 
1785 /** Tells whether given pipeline stage should be used for the purpose of the test
1786  *  (for all program objects).
1787  *
1788  *  @param Stage to query.
1789  *
1790  *  @return True if a shader object implementing the stage should be attached to
1791  *          test program object;
1792  *          False otherwise.
1793  **/
isPipelineStageUsed(_pipeline_stage stage)1794 bool TessellationShaderError5InputVariables::isPipelineStageUsed(_pipeline_stage stage)
1795 {
1796 	DE_UNREF(stage);
1797 
1798 	/* All stages used */
1799 	return true;
1800 }
1801 
1802 /** Constructor
1803  *
1804  * @param context Test context
1805  **/
TessellationShaderError6(Context & context,const ExtParameters & extParams)1806 TessellationShaderError6::TessellationShaderError6(Context& context, const ExtParameters& extParams)
1807 	: TessellationShaderErrorsTestCaseBase(context, extParams, "tc_invalid_output_patch_vertex_count",
1808 										   "Tries to use invalid output patch vertex count in"
1809 										   " a tessellation control shader")
1810 {
1811 	/* Left blank on purpose */
1812 }
1813 
1814 /** Retrieves amount of program objects the test that should be linked for
1815  *  the prupose of the test.
1816  *
1817  *  @return As per description.
1818  */
getAmountOfProgramObjects()1819 unsigned int TessellationShaderError6::getAmountOfProgramObjects()
1820 {
1821 	return 2;
1822 }
1823 
1824 /** Determines what compilation result is anticipated for each of the pipeline stages.
1825  *
1826  *  @param pipeline_stage Pipeline stage to return compilation result for.
1827  *
1828  *  @return Requested compilation result.
1829  **/
getCompilationResult(_pipeline_stage pipeline_stage)1830 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError6::getCompilationResult(
1831 	_pipeline_stage pipeline_stage)
1832 {
1833 	/* Tessellation control shader is allowed to fail to compile */
1834 	switch (pipeline_stage)
1835 	{
1836 	case PIPELINE_STAGE_TESSELLATION_CONTROL:
1837 		return COMPILATION_RESULT_CAN_FAIL;
1838 	default:
1839 		return COMPILATION_RESULT_MUST_SUCCEED;
1840 	}
1841 }
1842 
1843 /** Determines what linking result is anticipated for all program objects created by the test.
1844  *
1845  *  @return Expected linking result.
1846  **/
getLinkingResult()1847 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError6::getLinkingResult()
1848 {
1849 	return LINKING_RESULT_MUST_FAIL;
1850 }
1851 
1852 /** Retrieves source code of tessellation control shader that should be attached to the test
1853  *  program object.
1854  *
1855  *  @param n_program_object Index of the program object the source code should
1856  *                          be returned for.
1857  *
1858  *  @return Tessellation control shader source code to be used for user-specified program object.
1859  */
getTessellationControlShaderCode(unsigned int n_program_object)1860 std::string TessellationShaderError6::getTessellationControlShaderCode(unsigned int n_program_object)
1861 {
1862 	const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1863 	std::stringstream	 result;
1864 	const char*			  tc_code_preamble = "${VERSION}\n"
1865 								   "\n"
1866 								   "${TESSELLATION_SHADER_REQUIRE}\n"
1867 								   "\n";
1868 	const char* tc_code_body_excl_layout_qualifiers = "\n"
1869 													  "in vec4 test_input[];\n"
1870 													  "\n"
1871 													  "void main()\n"
1872 													  "{\n"
1873 													  "    gl_out[gl_InvocationID].gl_Position = test_input[0];\n"
1874 													  "    gl_TessLevelOuter[0]                = 1.0;\n"
1875 													  "    gl_TessLevelOuter[1]                = 1.0;\n"
1876 													  "}\n";
1877 
1878 	/* Prepare the line with layout qualifier */
1879 	std::stringstream tc_code_layout_qualifier_sstream;
1880 	std::string		  tc_code_layout_qualifier_string;
1881 
1882 	if (n_program_object == 0)
1883 	{
1884 		tc_code_layout_qualifier_string = "layout (vertices = 0) out;\n";
1885 	}
1886 	else
1887 	{
1888 		/* Retrieve GL_MAX_PATCH_VERTICES_EXT value first */
1889 		glw::GLint gl_max_patch_vertices_value = 0;
1890 
1891 		gl.getIntegerv(m_glExtTokens.MAX_PATCH_VERTICES, &gl_max_patch_vertices_value);
1892 		GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv() failed for GL_MAX_PATCH_VERTICES_EXT pname");
1893 
1894 		/* Construct the string */
1895 		tc_code_layout_qualifier_sstream << "layout (vertices = " << (gl_max_patch_vertices_value + 1) << ") out;\n";
1896 
1897 		tc_code_layout_qualifier_string = tc_code_layout_qualifier_sstream.str();
1898 	}
1899 
1900 	result << tc_code_preamble << tc_code_layout_qualifier_string << tc_code_body_excl_layout_qualifiers;
1901 
1902 	return result.str();
1903 }
1904 
1905 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
1906  *  program object.
1907  *
1908  *  @param n_program_object Index of the program object the source code should
1909  *                          be returned for.
1910  *
1911  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
1912  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)1913 std::string TessellationShaderError6::getTessellationEvaluationShaderCode(unsigned int n_program_object)
1914 {
1915 	DE_UNREF(n_program_object);
1916 
1917 	return "${VERSION}\n"
1918 		   "\n"
1919 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1920 		   "\n"
1921 		   "layout(isolines) in;\n"
1922 		   "\n"
1923 		   "void main()\n"
1924 		   "{\n"
1925 		   "    gl_Position = gl_in[0].gl_Position;\n"
1926 		   "}\n";
1927 }
1928 
1929 /** Tells whether given pipeline stage should be used for the purpose of the test
1930  *  (for all program objects).
1931  *
1932  *  @param Stage to query.
1933  *
1934  *  @return True if a shader object implementing the stage should be attached to
1935  *          test program object;
1936  *          False otherwise.
1937  **/
isPipelineStageUsed(_pipeline_stage stage)1938 bool TessellationShaderError6::isPipelineStageUsed(_pipeline_stage stage)
1939 {
1940 	DE_UNREF(stage);
1941 
1942 	/* All stages used */
1943 	return true;
1944 }
1945 
1946 /** Constructor
1947  *
1948  * @param context Test context
1949  **/
TessellationShaderError7(Context & context,const ExtParameters & extParams)1950 TessellationShaderError7::TessellationShaderError7(Context& context, const ExtParameters& extParams)
1951 	: TessellationShaderErrorsTestCaseBase(context, extParams,
1952 										   "tc_invalid_write_operation_at_non_gl_invocation_id_index",
1953 										   "Tries to write to a per-vertex output variable at index"
1954 										   " which is not equal to gl_InvocationID")
1955 {
1956 	/* Left blank on purpose */
1957 }
1958 
1959 /** Determines what compilation result is anticipated for each of the pipeline stages.
1960  *
1961  *  @param pipeline_stage Pipeline stage to return compilation result for.
1962  *
1963  *  @return Requested compilation result.
1964  **/
getCompilationResult(_pipeline_stage pipeline_stage)1965 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError7::getCompilationResult(
1966 	_pipeline_stage pipeline_stage)
1967 {
1968 	/* TC stage should _may_ fail to compile (but linking *must* fail) */
1969 	return (pipeline_stage == PIPELINE_STAGE_TESSELLATION_CONTROL) ? COMPILATION_RESULT_CAN_FAIL :
1970 																	 COMPILATION_RESULT_MUST_SUCCEED;
1971 }
1972 
1973 /** Determines what linking result is anticipated for all program objects created by the test.
1974  *
1975  *  @return Expected linking result.
1976  **/
getLinkingResult()1977 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError7::getLinkingResult()
1978 {
1979 	return LINKING_RESULT_MUST_FAIL;
1980 }
1981 
1982 /** Retrieves source code of tessellation control shader that should be attached to the test
1983  *  program object.
1984  *
1985  *  @param n_program_object Index of the program object the source code should
1986  *                          be returned for.
1987  *
1988  *  @return Tessellation control shader source code to be used for user-specified program object.
1989  */
getTessellationControlShaderCode(unsigned int n_program_object)1990 std::string TessellationShaderError7::getTessellationControlShaderCode(unsigned int n_program_object)
1991 {
1992 	DE_UNREF(n_program_object);
1993 
1994 	return "${VERSION}\n"
1995 		   "\n"
1996 		   "${TESSELLATION_SHADER_REQUIRE}\n"
1997 		   "\n"
1998 		   "layout (vertices=4) out;\n"
1999 		   "\n"
2000 		   "out vec4 test[];\n"
2001 		   "\n"
2002 		   "void main()\n"
2003 		   "{\n"
2004 		   "    gl_out[2].gl_Position = gl_in[0].gl_Position;\n"
2005 		   "    test[2]               = gl_in[1].gl_Position;\n"
2006 		   "}\n";
2007 }
2008 
2009 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
2010  *  program object.
2011  *
2012  *  @param n_program_object Index of the program object the source code should
2013  *                          be returned for.
2014  *
2015  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
2016  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)2017 std::string TessellationShaderError7::getTessellationEvaluationShaderCode(unsigned int n_program_object)
2018 {
2019 	DE_UNREF(n_program_object);
2020 
2021 	return "${VERSION}\n"
2022 		   "\n"
2023 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2024 		   "\n"
2025 		   "layout (quads) in;\n"
2026 		   "\n"
2027 		   "void main()\n"
2028 		   "{\n"
2029 		   "    gl_Position = gl_in[0].gl_Position;\n"
2030 		   "}\n";
2031 }
2032 
2033 /** Tells whether given pipeline stage should be used for the purpose of the test
2034  *  (for all program objects).
2035  *
2036  *  @param Stage to query.
2037  *
2038  *  @return True if a shader object implementing the stage should be attached to
2039  *          test program object;
2040  *          False otherwise.
2041  **/
isPipelineStageUsed(_pipeline_stage stage)2042 bool TessellationShaderError7::isPipelineStageUsed(_pipeline_stage stage)
2043 {
2044 	DE_UNREF(stage);
2045 
2046 	/* All stages used */
2047 	return true;
2048 }
2049 
2050 /** Constructor
2051  *
2052  * @param context Test context
2053  **/
TessellationShaderError8(Context & context,const ExtParameters & extParams)2054 TessellationShaderError8::TessellationShaderError8(Context& context, const ExtParameters& extParams)
2055 	: TessellationShaderErrorsTestCaseBase(context, extParams, "tc_invalid_input_per_patch_attribute_definition",
2056 										   "Tries to define input per-patch attributes in "
2057 										   "a tessellation control shader")
2058 {
2059 	/* Left blank on purpose */
2060 }
2061 
2062 /** Determines what compilation result is anticipated for each of the pipeline stages.
2063  *
2064  *  @param pipeline_stage Pipeline stage to return compilation result for.
2065  *
2066  *  @return Requested compilation result.
2067  **/
getCompilationResult(_pipeline_stage pipeline_stage)2068 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError8::getCompilationResult(
2069 	_pipeline_stage pipeline_stage)
2070 {
2071 	/* TC stage should never compile, all stages are out of scope */
2072 	return (pipeline_stage == PIPELINE_STAGE_TESSELLATION_CONTROL) ? COMPILATION_RESULT_MUST_FAIL :
2073 																	 COMPILATION_RESULT_UNKNOWN;
2074 }
2075 
2076 /** Determines what linking result is anticipated for all program objects created by the test.
2077  *
2078  *  @return Expected linking result.
2079  **/
getLinkingResult()2080 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError8::getLinkingResult()
2081 {
2082 	return LINKING_RESULT_MUST_FAIL;
2083 }
2084 
2085 /** Retrieves source code of tessellation control shader that should be attached to the test
2086  *  program object.
2087  *
2088  *  @param n_program_object Index of the program object the source code should
2089  *                          be returned for.
2090  *
2091  *  @return Tessellation control shader source code to be used for user-specified program object.
2092  */
getTessellationControlShaderCode(unsigned int n_program_object)2093 std::string TessellationShaderError8::getTessellationControlShaderCode(unsigned int n_program_object)
2094 {
2095 	DE_UNREF(n_program_object);
2096 
2097 	return "${VERSION}\n"
2098 		   "\n"
2099 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2100 		   "\n"
2101 		   "layout (vertices=4) out;\n"
2102 		   "\n"
2103 		   "patch in vec4 test;\n"
2104 		   "\n"
2105 		   "void main()\n"
2106 		   "{\n"
2107 		   "    gl_out[gl_InvocationID].gl_Position = test;\n"
2108 		   "}\n";
2109 }
2110 
2111 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
2112  *  program object.
2113  *
2114  *  @param n_program_object Index of the program object the source code should
2115  *                          be returned for.
2116  *
2117  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
2118  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)2119 std::string TessellationShaderError8::getTessellationEvaluationShaderCode(unsigned int n_program_object)
2120 {
2121 	DE_UNREF(n_program_object);
2122 
2123 	/* This function should never be called */
2124 	DE_ASSERT(false);
2125 
2126 	return "";
2127 }
2128 
2129 /** Tells whether given pipeline stage should be used for the purpose of the test
2130  *  (for all program objects).
2131  *
2132  *  @param Stage to query.
2133  *
2134  *  @return True if a shader object implementing the stage should be attached to
2135  *          test program object;
2136  *          False otherwise.
2137  **/
isPipelineStageUsed(_pipeline_stage stage)2138 bool TessellationShaderError8::isPipelineStageUsed(_pipeline_stage stage)
2139 {
2140 	/* Only TC stage is used */
2141 	return (stage == PIPELINE_STAGE_TESSELLATION_CONTROL);
2142 }
2143 
2144 /** Constructor
2145  *
2146  * @param context Test context
2147  **/
TessellationShaderError9(Context & context,const ExtParameters & extParams)2148 TessellationShaderError9::TessellationShaderError9(Context& context, const ExtParameters& extParams)
2149 	: TessellationShaderErrorsTestCaseBase(context, extParams, "te_invalid_output_per_patch_attribute_definition",
2150 										   "Tries to define output per-patch attributes in "
2151 										   "a tessellation evaluation shader")
2152 {
2153 	/* Left blank on purpose */
2154 }
2155 
2156 /** Determines what compilation result is anticipated for each of the pipeline stages.
2157  *
2158  *  @param pipeline_stage Pipeline stage to return compilation result for.
2159  *
2160  *  @return Requested compilation result.
2161  **/
getCompilationResult(_pipeline_stage pipeline_stage)2162 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError9::getCompilationResult(
2163 	_pipeline_stage pipeline_stage)
2164 {
2165 	/* TE stage should never compile, all stages are out of scope */
2166 	return (pipeline_stage == PIPELINE_STAGE_TESSELLATION_EVALUATION) ? COMPILATION_RESULT_MUST_FAIL :
2167 																		COMPILATION_RESULT_UNKNOWN;
2168 }
2169 
2170 /** Determines what linking result is anticipated for all program objects created by the test.
2171  *
2172  *  @return Expected linking result.
2173  **/
getLinkingResult()2174 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError9::getLinkingResult()
2175 {
2176 	return LINKING_RESULT_MUST_FAIL;
2177 }
2178 
2179 /** Retrieves source code of tessellation control shader that should be attached to the test
2180  *  program object.
2181  *
2182  *  @param n_program_object Index of the program object the source code should
2183  *                          be returned for.
2184  *
2185  *  @return Tessellation control shader source code to be used for user-specified program object.
2186  */
getTessellationControlShaderCode(unsigned int n_program_object)2187 std::string TessellationShaderError9::getTessellationControlShaderCode(unsigned int n_program_object)
2188 {
2189 	DE_UNREF(n_program_object);
2190 
2191 	/* This function should never be called */
2192 	DE_ASSERT(false);
2193 
2194 	return "";
2195 }
2196 
2197 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
2198  *  program object.
2199  *
2200  *  @param n_program_object Index of the program object the source code should
2201  *                          be returned for.
2202  *
2203  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
2204  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)2205 std::string TessellationShaderError9::getTessellationEvaluationShaderCode(unsigned int n_program_object)
2206 {
2207 	DE_UNREF(n_program_object);
2208 
2209 	return "${VERSION}\n"
2210 		   "\n"
2211 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2212 		   "\n"
2213 		   "layout (isolines) in;\n"
2214 		   "\n"
2215 		   "patch out vec4 test;\n"
2216 		   "\n"
2217 		   "void main()\n"
2218 		   "{\n"
2219 		   "    gl_Position = vec4(1.0, 0.0, 0.0, 0.0);\n"
2220 		   "    test        = vec4(0.0, 1.0, 0.0, 0.0);\n"
2221 		   "}\n";
2222 }
2223 
2224 /** Tells whether given pipeline stage should be used for the purpose of the test
2225  *  (for all program objects).
2226  *
2227  *  @param Stage to query.
2228  *
2229  *  @return True if a shader object implementing the stage should be attached to
2230  *          test program object;
2231  *          False otherwise.
2232  **/
isPipelineStageUsed(_pipeline_stage stage)2233 bool TessellationShaderError9::isPipelineStageUsed(_pipeline_stage stage)
2234 {
2235 	/* Only TE stage is used */
2236 	return (stage == PIPELINE_STAGE_TESSELLATION_EVALUATION);
2237 }
2238 
2239 /** Constructor
2240  *
2241  * @param context Test context
2242  **/
TessellationShaderError10(Context & context,const ExtParameters & extParams)2243 TessellationShaderError10::TessellationShaderError10(Context& context, const ExtParameters& extParams)
2244 	: TessellationShaderErrorsTestCaseBase(context, extParams, "tc_non_matching_variable_declarations",
2245 										   "Tries to define variables of different types/qualifications"
2246 										   " in tessellation control and tessellation evaluation shaders")
2247 {
2248 	/* Left blank on purpose */
2249 }
2250 
2251 /** Determines what compilation result is anticipated for each of the pipeline stages.
2252  *
2253  *  @param pipeline_stage Pipeline stage to return compilation result for.
2254  *
2255  *  @return Requested compilation result.
2256  **/
getCompilationResult(_pipeline_stage pipeline_stage)2257 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError10::getCompilationResult(
2258 	_pipeline_stage pipeline_stage)
2259 {
2260 	DE_UNREF(pipeline_stage);
2261 	/* All stages should compile */
2262 	return COMPILATION_RESULT_MUST_SUCCEED;
2263 }
2264 
2265 /** Determines what linking result is anticipated for all program objects created by the test.
2266  *
2267  *  @return Expected linking result.
2268  **/
getLinkingResult()2269 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError10::getLinkingResult()
2270 {
2271 	return LINKING_RESULT_MUST_FAIL;
2272 }
2273 
2274 /** Retrieves source code of tessellation control shader that should be attached to the test
2275  *  program object.
2276  *
2277  *  @param n_program_object Index of the program object the source code should
2278  *                          be returned for.
2279  *
2280  *  @return Tessellation control shader source code to be used for user-specified program object.
2281  */
getTessellationControlShaderCode(unsigned int n_program_object)2282 std::string TessellationShaderError10::getTessellationControlShaderCode(unsigned int n_program_object)
2283 {
2284 	DE_UNREF(n_program_object);
2285 
2286 	return "${VERSION}\n"
2287 		   "\n"
2288 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2289 		   "\n"
2290 		   "layout (vertices=4) out;\n"
2291 		   "\n"
2292 		   "patch out float test;\n"
2293 		   "patch out vec4  test2;\n"
2294 		   "\n"
2295 		   "void main()\n"
2296 		   "{\n"
2297 		   "    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
2298 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
2299 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
2300 		   "    test                                = 1.0;\n"
2301 		   "    test2                               = vec4(0.1, 0.2, 0.3, 0.4);\n"
2302 		   "}\n";
2303 }
2304 
2305 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
2306  *  program object.
2307  *
2308  *  @param n_program_object Index of the program object the source code should
2309  *                          be returned for.
2310  *
2311  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
2312  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)2313 std::string TessellationShaderError10::getTessellationEvaluationShaderCode(unsigned int n_program_object)
2314 {
2315 	DE_UNREF(n_program_object);
2316 
2317 	return "${VERSION}\n"
2318 		   "\n"
2319 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2320 		   "\n"
2321 		   "layout(isolines) in;\n"
2322 		   "\n"
2323 		   "patch in uint  test;\n"
2324 		   "patch in float test2;\n"
2325 		   "\n"
2326 		   "void main()\n"
2327 		   "{\n"
2328 		   "    gl_Position = gl_in[0].gl_Position * float(int(test)) * vec4(test2);\n"
2329 		   "}\n";
2330 }
2331 
2332 /** Tells whether given pipeline stage should be used for the purpose of the test
2333  *  (for all program objects).
2334  *
2335  *  @param Stage to query.
2336  *
2337  *  @return True if a shader object implementing the stage should be attached to
2338  *          test program object;
2339  *          False otherwise.
2340  **/
isPipelineStageUsed(_pipeline_stage stage)2341 bool TessellationShaderError10::isPipelineStageUsed(_pipeline_stage stage)
2342 {
2343 	DE_UNREF(stage);
2344 
2345 	return true;
2346 }
2347 
2348 /** Constructor
2349  *
2350  * @param context Test context
2351  **/
TessellationShaderError11(Context & context,const ExtParameters & extParams)2352 TessellationShaderError11::TessellationShaderError11(Context& context, const ExtParameters& extParams)
2353 	: TessellationShaderErrorsTestCaseBase(context, extParams, "te_lacking_primitive_mode_declaration",
2354 										   "Tries to link a tessellation evaluation shader"
2355 										   " without a primitive mode declaration")
2356 {
2357 	/* Left blank on purpose */
2358 }
2359 
2360 /** Determines what compilation result is anticipated for each of the pipeline stages.
2361  *
2362  *  @param pipeline_stage Pipeline stage to return compilation result for.
2363  *
2364  *  @return Requested compilation result.
2365  **/
getCompilationResult(_pipeline_stage pipeline_stage)2366 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError11::getCompilationResult(
2367 	_pipeline_stage pipeline_stage)
2368 {
2369 	DE_UNREF(pipeline_stage);
2370 
2371 	/* All stages should compile */
2372 	return COMPILATION_RESULT_MUST_SUCCEED;
2373 }
2374 
2375 /** Determines what linking result is anticipated for all program objects created by the test.
2376  *
2377  *  @return Expected linking result.
2378  **/
getLinkingResult()2379 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError11::getLinkingResult()
2380 {
2381 	return LINKING_RESULT_MUST_FAIL;
2382 }
2383 
2384 /** Retrieves source code of tessellation control shader that should be attached to the test
2385  *  program object.
2386  *
2387  *  @param n_program_object Index of the program object the source code should
2388  *                          be returned for.
2389  *
2390  *  @return Tessellation control shader source code to be used for user-specified program object.
2391  */
getTessellationControlShaderCode(unsigned int n_program_object)2392 std::string TessellationShaderError11::getTessellationControlShaderCode(unsigned int n_program_object)
2393 {
2394 	DE_UNREF(n_program_object);
2395 
2396 	return "${VERSION}\n"
2397 		   "\n"
2398 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2399 		   "\n"
2400 		   "layout (vertices=4) out;\n"
2401 		   "\n"
2402 		   "void main()\n"
2403 		   "{\n"
2404 		   "    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
2405 		   "    gl_TessLevelInner[0]                = 1.0;\n"
2406 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
2407 		   "}\n";
2408 }
2409 
2410 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
2411  *  program object.
2412  *
2413  *  @param n_program_object Index of the program object the source code should
2414  *                          be returned for.
2415  *
2416  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
2417  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)2418 std::string TessellationShaderError11::getTessellationEvaluationShaderCode(unsigned int n_program_object)
2419 {
2420 	DE_UNREF(n_program_object);
2421 
2422 	return "${VERSION}\n"
2423 		   "\n"
2424 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2425 		   "\n"
2426 		   "void main()\n"
2427 		   "{\n"
2428 		   "    gl_Position = gl_in[0].gl_Position;\n"
2429 		   "}\n";
2430 }
2431 
2432 /** Tells whether given pipeline stage should be used for the purpose of the test
2433  *  (for all program objects).
2434  *
2435  *  @param Stage to query.
2436  *
2437  *  @return True if a shader object implementing the stage should be attached to
2438  *          test program object;
2439  *          False otherwise.
2440  **/
isPipelineStageUsed(_pipeline_stage stage)2441 bool TessellationShaderError11::isPipelineStageUsed(_pipeline_stage stage)
2442 {
2443 	DE_UNREF(stage);
2444 
2445 	return true;
2446 }
2447 
2448 /** Constructor
2449  *
2450  * @param context Test context
2451  **/
TessellationShaderError12(Context & context,const ExtParameters & extParams)2452 TessellationShaderError12::TessellationShaderError12(Context& context, const ExtParameters& extParams)
2453 	: TessellationShaderErrorsTestCaseBase(context, extParams, "te_accessing_glTessCoord_as_array",
2454 										   "Tries to access gl_TessCoord as if it was an array")
2455 {
2456 	/* Left blank on purpose */
2457 }
2458 
2459 /** Determines what compilation result is anticipated for each of the pipeline stages.
2460  *
2461  *  @param pipeline_stage Pipeline stage to return compilation result for.
2462  *
2463  *  @return Requested compilation result.
2464  **/
getCompilationResult(_pipeline_stage pipeline_stage)2465 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError12::getCompilationResult(
2466 	_pipeline_stage pipeline_stage)
2467 {
2468 	/* It is OK for TE stage to fail to compile. Other stages must compile successfully */
2469 	/* All stages should compile */
2470 	return (pipeline_stage == PIPELINE_STAGE_TESSELLATION_EVALUATION) ? COMPILATION_RESULT_CAN_FAIL :
2471 																		COMPILATION_RESULT_MUST_SUCCEED;
2472 }
2473 
2474 /** Determines what linking result is anticipated for all program objects created by the test.
2475  *
2476  *  @return Expected linking result.
2477  **/
getLinkingResult()2478 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError12::getLinkingResult()
2479 {
2480 	return LINKING_RESULT_MUST_FAIL;
2481 }
2482 
2483 /** Retrieves source code of tessellation control shader that should be attached to the test
2484  *  program object.
2485  *
2486  *  @param n_program_object Index of the program object the source code should
2487  *                          be returned for.
2488  *
2489  *  @return Tessellation control shader source code to be used for user-specified program object.
2490  */
getTessellationControlShaderCode(unsigned int n_program_object)2491 std::string TessellationShaderError12::getTessellationControlShaderCode(unsigned int n_program_object)
2492 {
2493 	DE_UNREF(n_program_object);
2494 
2495 	return "${VERSION}\n"
2496 		   "\n"
2497 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2498 		   "\n"
2499 		   "layout (vertices=4) out;\n"
2500 		   "\n"
2501 		   "void main()\n"
2502 		   "{\n"
2503 		   "    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
2504 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
2505 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
2506 		   "}\n";
2507 }
2508 
2509 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
2510  *  program object.
2511  *
2512  *  @param n_program_object Index of the program object the source code should
2513  *                          be returned for.
2514  *
2515  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
2516  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)2517 std::string TessellationShaderError12::getTessellationEvaluationShaderCode(unsigned int n_program_object)
2518 {
2519 	DE_UNREF(n_program_object);
2520 
2521 	return "${VERSION}\n"
2522 		   "\n"
2523 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2524 		   "\n"
2525 		   "layout(isolines) in;\n"
2526 		   "\n"
2527 		   "out vec3 test;\n"
2528 		   "\n"
2529 		   "void main()\n"
2530 		   "{\n"
2531 		   "    test = gl_TessCoord[0].xyz;\n"
2532 		   "}\n";
2533 }
2534 
2535 /** Tells whether given pipeline stage should be used for the purpose of the test
2536  *  (for all program objects).
2537  *
2538  *  @param Stage to query.
2539  *
2540  *  @return True if a shader object implementing the stage should be attached to
2541  *          test program object;
2542  *          False otherwise.
2543  **/
isPipelineStageUsed(_pipeline_stage stage)2544 bool TessellationShaderError12::isPipelineStageUsed(_pipeline_stage stage)
2545 {
2546 	DE_UNREF(stage);
2547 
2548 	return true;
2549 }
2550 
2551 /** Constructor
2552  *
2553  * @param context Test context
2554  **/
TessellationShaderError13(Context & context,const ExtParameters & extParams)2555 TessellationShaderError13::TessellationShaderError13(Context& context, const ExtParameters& extParams)
2556 	: TessellationShaderErrorsTestCaseBase(context, extParams, "te_accessing_glTessCoord_as_gl_in_member",
2557 										   "Tries to access gl_TessCoord as if it was a gl_in[] member")
2558 {
2559 	/* Left blank on purpose */
2560 }
2561 
2562 /** Determines what compilation result is anticipated for each of the pipeline stages.
2563  *
2564  *  @param pipeline_stage Pipeline stage to return compilation result for.
2565  *
2566  *  @return Requested compilation result.
2567  **/
getCompilationResult(_pipeline_stage pipeline_stage)2568 TessellationShaderErrorsTestCaseBase::_compilation_result TessellationShaderError13::getCompilationResult(
2569 	_pipeline_stage pipeline_stage)
2570 {
2571 	/* It is OK for TE stage to fail to compile. Other stages must compile successfully */
2572 	/* All stages should compile */
2573 	return (pipeline_stage == PIPELINE_STAGE_TESSELLATION_EVALUATION) ? COMPILATION_RESULT_CAN_FAIL :
2574 																		COMPILATION_RESULT_MUST_SUCCEED;
2575 }
2576 
2577 /** Determines what linking result is anticipated for all program objects created by the test.
2578  *
2579  *  @return Expected linking result.
2580  **/
getLinkingResult()2581 TessellationShaderErrorsTestCaseBase::_linking_result TessellationShaderError13::getLinkingResult()
2582 {
2583 	return LINKING_RESULT_MUST_FAIL;
2584 }
2585 
2586 /** Retrieves source code of tessellation control shader that should be attached to the test
2587  *  program object.
2588  *
2589  *  @param n_program_object Index of the program object the source code should
2590  *                          be returned for.
2591  *
2592  *  @return Tessellation control shader source code to be used for user-specified program object.
2593  */
getTessellationControlShaderCode(unsigned int n_program_object)2594 std::string TessellationShaderError13::getTessellationControlShaderCode(unsigned int n_program_object)
2595 {
2596 	DE_UNREF(n_program_object);
2597 
2598 	return "${VERSION}\n"
2599 		   "\n"
2600 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2601 		   "\n"
2602 		   "layout (vertices=4) out;\n"
2603 		   "\n"
2604 		   "void main()\n"
2605 		   "{\n"
2606 		   "    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
2607 		   "    gl_TessLevelOuter[0]                = 1.0;\n"
2608 		   "    gl_TessLevelOuter[1]                = 1.0;\n"
2609 		   "}\n";
2610 }
2611 
2612 /** Retrieves source code of tessellation evaluation shader that should be attached to the test
2613  *  program object.
2614  *
2615  *  @param n_program_object Index of the program object the source code should
2616  *                          be returned for.
2617  *
2618  *  @return Tessellation evaluation shader source code to be used for user-specified program object.
2619  */
getTessellationEvaluationShaderCode(unsigned int n_program_object)2620 std::string TessellationShaderError13::getTessellationEvaluationShaderCode(unsigned int n_program_object)
2621 {
2622 	DE_UNREF(n_program_object);
2623 
2624 	return "${VERSION}\n"
2625 		   "\n"
2626 		   "${TESSELLATION_SHADER_REQUIRE}\n"
2627 		   "\n"
2628 		   "layout(isolines) in;\n"
2629 		   "\n"
2630 		   "out vec3 test;\n"
2631 		   "\n"
2632 		   "void main()\n"
2633 		   "{\n"
2634 		   "    test = gl_in[0].gl_TessCoord;\n"
2635 		   "}\n";
2636 }
2637 
2638 /** Tells whether given pipeline stage should be used for the purpose of the test
2639  *  (for all program objects).
2640  *
2641  *  @param Stage to query.
2642  *
2643  *  @return True if a shader object implementing the stage should be attached to
2644  *          test program object;
2645  *          False otherwise.
2646  **/
isPipelineStageUsed(_pipeline_stage stage)2647 bool TessellationShaderError13::isPipelineStageUsed(_pipeline_stage stage)
2648 {
2649 	DE_UNREF(stage);
2650 
2651 	return true;
2652 }
2653 
2654 } /* namespace glcts */
2655