1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
4 *
5 * Copyright (c) 2015-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 /* Includes. */
25 #include "gl4cES31CompatibilityTests.hpp"
26 #include "gluContextInfo.hpp"
27 #include "gluDefs.hpp"
28 #include "gluRenderContext.hpp"
29 #include "gluStrUtil.hpp"
30 #include "tcuTestLog.hpp"
31
32 /******************************** Test Group Implementation ********************************/
33
34 /** @brief ES3.1 Compatibility tests group constructor.
35 *
36 * @param [in] context OpenGL context.
37 */
Tests(deqp::Context & context)38 gl4cts::es31compatibility::Tests::Tests(deqp::Context &context)
39 : TestCaseGroup(context, "es_31_compatibility", "ES3.1 Compatibility Test Suite")
40 {
41 /* Intentionally left blank */
42 }
43
44 /** @brief ES3.1 Compatibility Tests initializer. */
init()45 void gl4cts::es31compatibility::Tests::init()
46 {
47 /* New tests. */
48 addChild(new gl4cts::es31compatibility::ShaderCompilationCompatibilityTests(m_context));
49 addChild(new gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest(m_context));
50
51 /* Ported tests. */
52 addChild(new gl4cts::es31compatibility::SampleVariablesTests(m_context, glu::GLSL_VERSION_310_ES));
53 addChild(new gl4cts::es31compatibility::ShaderImageLoadStoreTests(m_context));
54 addChild(new gl4cts::es31compatibility::ShaderStorageBufferObjectTests(m_context));
55 }
56
57 /******************************** Shader Compilation Compatibility Tests Implementation ********************************/
58
59 /** @brief ShaderCompilationCompatibilityTests constructor.
60 *
61 * @param [in] context OpenGL context.
62 */
ShaderCompilationCompatibilityTests(deqp::Context & context)63 gl4cts::es31compatibility::ShaderCompilationCompatibilityTests::ShaderCompilationCompatibilityTests(
64 deqp::Context &context)
65 : deqp::TestCase(context, "shader_compilation", "Shader Compilation Compatibility Test")
66 {
67 }
68
69 /** @brief ShaderCompilationCompatibilityTests test cases iterations.
70 */
iterate()71 tcu::TestNode::IterateResult gl4cts::es31compatibility::ShaderCompilationCompatibilityTests::iterate()
72 {
73 /* Shortcut for GL functionality. */
74 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
75
76 /* OpenGL support query. */
77 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
78 bool is_arb_es31_compatibility = m_context.getContextInfo().isExtensionSupported("GL_ARB_ES3_1_compatibility");
79
80 /* Running tests. */
81 bool is_ok = true;
82 bool is_error = false;
83
84 glw::GLuint shader = 0;
85
86 /* Test */
87 try
88 {
89 if (is_at_least_gl_45 || is_arb_es31_compatibility)
90 {
91 for (glw::GLsizei i = 0; i < s_shaders_count; ++i)
92 {
93 /* Shader compilation. */
94 shader = gl.createShader(s_shaders[i].type);
95
96 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
97
98 if (0 == shader)
99 {
100 throw 0;
101 }
102
103 gl.shaderSource(shader, 1, &(s_shaders[i].source), NULL);
104
105 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
106
107 gl.compileShader(shader);
108
109 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
110
111 /* Checking for errors. */
112 glw::GLint status = GL_FALSE;
113
114 gl.getShaderiv(shader, GL_COMPILE_STATUS, &status);
115 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
116
117 if (GL_FALSE == status)
118 {
119 /* Setup result. */
120 is_ok = false;
121
122 /* Getting compilation informations. */
123 glw::GLint log_size = 0;
124
125 gl.getShaderiv(shader, GL_INFO_LOG_LENGTH, &log_size);
126
127 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv() call failed.");
128
129 if (log_size)
130 {
131 glw::GLchar *log = new glw::GLchar[log_size];
132
133 if (log)
134 {
135 memset(log, 0, log_size);
136
137 gl.getShaderInfoLog(shader, log_size, DE_NULL, log);
138
139 /* Logging. */
140 m_context.getTestContext().getLog()
141 << tcu::TestLog::Message << "Compilation of " << s_shaders[i].type_name
142 << " shader have failed.\n Shader source was:\n"
143 << s_shaders[i].source << "\nCompillation log:\n"
144 << log << tcu::TestLog::EndMessage;
145
146 delete[] log;
147
148 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog() call failed.");
149 }
150 }
151 }
152
153 /* Cleanup. */
154 gl.deleteShader(shader);
155
156 shader = 0;
157
158 GLU_EXPECT_NO_ERROR(gl.getError(), "glDeleteShader call failed.");
159 }
160 }
161 }
162 catch (...)
163 {
164 is_ok = false;
165 is_error = true;
166 }
167
168 /* Cleanup. */
169 if (0 != shader)
170 {
171 gl.deleteShader(shader);
172
173 shader = 0;
174 }
175
176 /* Result's setup and logging. */
177 if (is_ok)
178 {
179 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
180 }
181 else
182 {
183 if (is_error)
184 {
185 m_context.getTestContext().getLog()
186 << tcu::TestLog::Message << "Internal error has occured during the Shader Version Test."
187 << tcu::TestLog::EndMessage;
188
189 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Test error.");
190 }
191 else
192 {
193 m_context.getTestContext().getLog()
194 << tcu::TestLog::Message << "The Shader Version Test has failed." << tcu::TestLog::EndMessage;
195
196 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
197 }
198 }
199
200 return STOP;
201 }
202
203 const gl4cts::es31compatibility::ShaderCompilationCompatibilityTests::TestShader
204 gl4cts::es31compatibility::ShaderCompilationCompatibilityTests::s_shaders[] = {
205 {/* Shader for testing ES 3.1 version string support.*/
206 GL_VERTEX_SHADER, "vertex",
207 "#version 310 es\n"
208 "\n"
209 "void main()\n"
210 "{\n"
211 " gl_Position = vec4(1.0);\n"
212 "}\n"},
213 {/* Shader for testing ES 3.1 version string support.*/
214 GL_FRAGMENT_SHADER, "fragment",
215 "#version 310 es\n"
216 "\n"
217 "out highp vec4 color;"
218 "\n"
219 "void main()\n"
220 "{\n"
221 " color = vec4(1.0);\n"
222 "}\n"},
223 {/* Shader for testing that gl_HelperInvocation variable is supported.*/
224 GL_FRAGMENT_SHADER, "fragment",
225 "#version 310 es\n"
226 "\n"
227 "out highp vec4 color;"
228 "\n"
229 "void main()\n"
230 "{\n"
231 " if(gl_HelperInvocation)\n"
232 " {\n"
233 " color = vec4(1.0);\n"
234 " }\n"
235 " else\n"
236 " {\n"
237 " color = vec4(0.0);\n"
238 " }\n"
239 "}\n"},
240 {/* Shader for testing ES 3.1 version string support.*/
241 GL_COMPUTE_SHADER, "compute",
242 "#version 310 es\n"
243 "\n"
244 "layout(local_size_x = 128) in;\n"
245 "layout(std140, binding = 0) buffer Output\n"
246 "{\n"
247 " uint elements[];\n"
248 "} output_data;\n"
249 "\n"
250 "void main()\n"
251 "{\n"
252 " output_data.elements[gl_GlobalInvocationID.x] = gl_GlobalInvocationID.x * gl_GlobalInvocationID.x;\n"
253 "}\n"}};
254
255 const glw::GLsizei gl4cts::es31compatibility::ShaderCompilationCompatibilityTests::s_shaders_count =
256 sizeof(s_shaders) / sizeof(s_shaders[0]);
257
258 /******************************** Shader Functional Compatibility Test Implementation ********************************/
259
260 /** @brief Shader Functional Compatibility Test constructor.
261 *
262 * @param [in] context OpenGL context.
263 */
ShaderFunctionalCompatibilityTest(deqp::Context & context)264 gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::ShaderFunctionalCompatibilityTest(deqp::Context &context)
265 : deqp::TestCase(context, "shader_functional", "Shader Functional Compatibility Test")
266 , m_po_id(0)
267 , m_fbo_id(0)
268 , m_rbo_id(0)
269 , m_vao_id(0)
270 {
271 }
272
273 /** @brief ShaderCompilationCompatibilityTests test cases iterations.
274 */
iterate()275 tcu::TestNode::IterateResult gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::iterate()
276 {
277 /* OpenGL support query. */
278 bool is_at_least_gl_45 = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)));
279 bool is_arb_es31_compatibility = m_context.getContextInfo().isExtensionSupported("GL_ARB_ES3_1_compatibility");
280
281 /* Running tests. */
282 bool is_ok = true;
283 bool is_error = false;
284
285 /* Test */
286 try
287 {
288 if (is_at_least_gl_45 || is_arb_es31_compatibility)
289 {
290 createFramebufferAndVertexArrayObject();
291
292 for (glw::GLsizei i = 0; i < s_shaders_count; ++i)
293 {
294 if (!createProgram(s_shaders[i]))
295 {
296 is_ok = false;
297
298 continue; /* if createProgram failed we shall omit this iteration */
299 }
300
301 is_ok &= test();
302
303 cleanProgram();
304 }
305
306 cleanFramebufferAndVertexArrayObject();
307 }
308 }
309 catch (...)
310 {
311 /* Result setup. */
312 is_ok = false;
313 is_error = true;
314
315 /* Cleanup. */
316 cleanProgram();
317 cleanFramebufferAndVertexArrayObject();
318 }
319
320 /* Result's setup. */
321 if (is_ok)
322 {
323 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
324 }
325 else
326 {
327 if (is_error)
328 {
329 m_context.getTestContext().getLog()
330 << tcu::TestLog::Message << "Internal error has occured during the Shader Version Test."
331 << tcu::TestLog::EndMessage;
332
333 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Test error.");
334 }
335 else
336 {
337 m_context.getTestContext().getLog()
338 << tcu::TestLog::Message << "The Shader Version Test has failed." << tcu::TestLog::EndMessage;
339
340 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
341 }
342 }
343
344 return STOP;
345 }
346
347 /** @brief Create program object
348 *
349 * @note Program object is going to be stored into m_po_id.
350 * If building succeeded program will be set current (glUseProgram).
351 *
352 * @param [in] shader_source Shader source to be builded.
353 *
354 * @return True if succeeded, false otherwise.
355 */
createProgram(const struct Shader shader_source)356 bool gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::createProgram(const struct Shader shader_source)
357 {
358 /* Shortcut for GL functionality. */
359 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
360
361 struct _Shader
362 {
363 const glw::GLchar *const *source;
364 const glw::GLenum type;
365 glw::GLuint id;
366 } shader[] = {{shader_source.vertex, GL_VERTEX_SHADER, 0}, {shader_source.fragment, GL_FRAGMENT_SHADER, 0}};
367
368 glw::GLuint const shader_count = sizeof(shader) / sizeof(shader[0]);
369
370 try
371 {
372 /* Make sure m_po_id is cleaned. */
373 if (m_po_id)
374 {
375 cleanProgram();
376 }
377
378 /* Create program. */
379 m_po_id = gl.createProgram();
380 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateProgram call failed.");
381
382 /* Shader compilation. */
383
384 for (glw::GLuint i = 0; i < shader_count; ++i)
385 {
386 if (DE_NULL != shader[i].source)
387 {
388 shader[i].id = gl.createShader(shader[i].type);
389
390 GLU_EXPECT_NO_ERROR(gl.getError(), "glCreateShader call failed.");
391
392 gl.attachShader(m_po_id, shader[i].id);
393
394 GLU_EXPECT_NO_ERROR(gl.getError(), "glAttachShader call failed.");
395
396 gl.shaderSource(shader[i].id, 3, shader[i].source, NULL);
397
398 GLU_EXPECT_NO_ERROR(gl.getError(), "glShaderSource call failed.");
399
400 gl.compileShader(shader[i].id);
401
402 GLU_EXPECT_NO_ERROR(gl.getError(), "glCompileShader call failed.");
403
404 glw::GLint status = GL_FALSE;
405
406 gl.getShaderiv(shader[i].id, GL_COMPILE_STATUS, &status);
407 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv call failed.");
408
409 if (GL_FALSE == status)
410 {
411 glw::GLint log_size = 0;
412
413 gl.getShaderiv(shader[i].id, GL_INFO_LOG_LENGTH, &log_size);
414
415 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderiv() call failed.");
416
417 if (log_size)
418 {
419 glw::GLchar *log = new glw::GLchar[log_size];
420
421 if (log)
422 {
423 memset(log, 0, log_size);
424
425 gl.getShaderInfoLog(shader[i].id, log_size, DE_NULL, log);
426
427 m_context.getTestContext().getLog()
428 << tcu::TestLog::Message << "Compilation of shader has failed.\nShader source:\n"
429 << shader[i].source[0] << shader[i].source[1] << shader[i].source[2]
430 << "\nCompillation log:\n"
431 << log << tcu::TestLog::EndMessage;
432
433 delete[] log;
434
435 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog() call failed.");
436 }
437 }
438
439 throw 0;
440 }
441 }
442 }
443
444 /* Link. */
445 gl.linkProgram(m_po_id);
446
447 GLU_EXPECT_NO_ERROR(gl.getError(), "glLinkProgram call failed.");
448
449 glw::GLint status = GL_FALSE;
450
451 gl.getProgramiv(m_po_id, GL_LINK_STATUS, &status);
452
453 if (GL_TRUE == status)
454 {
455 for (glw::GLuint i = 0; i < shader_count; ++i)
456 {
457 if (shader[i].id)
458 {
459 gl.detachShader(m_po_id, shader[i].id);
460
461 GLU_EXPECT_NO_ERROR(gl.getError(), "glDetachShader call failed.");
462 }
463 }
464 }
465 else
466 {
467 glw::GLint log_size = 0;
468
469 gl.getProgramiv(m_po_id, GL_INFO_LOG_LENGTH, &log_size);
470
471 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetProgramiv() call failed.");
472
473 if (log_size)
474 {
475 glw::GLchar *log = new glw::GLchar[log_size];
476
477 if (log)
478 {
479 memset(log, 0, log_size);
480
481 gl.getProgramInfoLog(m_po_id, log_size, DE_NULL, log);
482
483 m_context.getTestContext().getLog()
484 << tcu::TestLog::Message << "Linkage of shader program has failed.\nLinkage log:\n"
485 << log << tcu::TestLog::EndMessage;
486
487 delete[] log;
488
489 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetShaderInfoLog() call failed.");
490 }
491 }
492
493 throw 0;
494 }
495 }
496 catch (...)
497 {
498 if (m_po_id)
499 {
500 gl.deleteProgram(m_po_id);
501
502 m_po_id = 0;
503 }
504 }
505
506 for (glw::GLuint i = 0; i < shader_count; ++i)
507 {
508 if (0 != shader[i].id)
509 {
510 gl.deleteShader(shader[i].id);
511
512 shader[i].id = 0;
513 }
514 }
515
516 if (m_po_id)
517 {
518 gl.useProgram(m_po_id);
519
520 GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram call failed.");
521
522 return true;
523 }
524
525 return false;
526 }
527
528 /** @brief Create framebuffer and vertex array object.
529 *
530 * @note Frembuffer will be stored in m_fbo_id and m_rbo_id.
531 * Vertex array object will be stored in m_vao_id.
532 * Function will throw 0 if erro has occured.
533 */
createFramebufferAndVertexArrayObject()534 void gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::createFramebufferAndVertexArrayObject()
535 {
536 /* Shortcut for GL functionality. */
537 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
538
539 /* Prepare framebuffer. */
540 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
541 GLU_EXPECT_NO_ERROR(gl.getError(), "glClearColor call failed.");
542
543 gl.genFramebuffers(1, &m_fbo_id);
544 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers call failed.");
545
546 gl.genRenderbuffers(1, &m_rbo_id);
547 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers call failed.");
548
549 gl.bindFramebuffer(GL_FRAMEBUFFER, m_fbo_id);
550 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer call failed.");
551
552 gl.bindRenderbuffer(GL_RENDERBUFFER, m_rbo_id);
553 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer call failed.");
554
555 gl.renderbufferStorage(GL_RENDERBUFFER, GL_R8, 1 /* x size */, 1 /* y size */);
556 GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage call failed.");
557
558 gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo_id);
559 GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer call failed.");
560
561 /* Check if all went ok. */
562 if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
563 {
564 throw 0;
565 }
566
567 /* View Setup. */
568 gl.viewport(0, 0, 1 /* x size */, 1 /* y size */);
569 GLU_EXPECT_NO_ERROR(gl.getError(), "glViewport call failed.");
570
571 /* Create and bind empty vertex array object. */
572 gl.genVertexArrays(1, &m_vao_id);
573 GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays() call failed.");
574
575 if (0 == m_vao_id)
576 {
577 throw 0;
578 }
579
580 gl.bindVertexArray(m_vao_id);
581 GLU_EXPECT_NO_ERROR(gl.getError(), "glBindVertexArray() call failed.");
582 }
583
584 /** @brief Run test case.
585 *
586 * @note Test case run in following order:
587 * * clear screen with 0 value (color setup in createFramebufferAndVertexArrayObject);
588 * * draw full screen quad;
589 * * fetch pixel from screen using glReadPixel (view is 1x1 pixel in size);
590 * * compare results (1.0f is expected as the result of the shader).
591 */
test()592 bool gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::test()
593 {
594 /* Shortcut for GL functionality. */
595 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
596
597 /* Make sure objects are cleaned. */
598 if (m_fbo_id || m_rbo_id || m_vao_id)
599 {
600 cleanFramebufferAndVertexArrayObject();
601 }
602
603 /* Drawing quad which shall output result. */
604 gl.clear(GL_COLOR_BUFFER_BIT);
605 GLU_EXPECT_NO_ERROR(gl.getError(), "glClear() call failed.");
606
607 gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
608 GLU_EXPECT_NO_ERROR(gl.getError(), "glDrawArrays() call failed.");
609
610 /* Fetching result. */
611 glw::GLfloat red = -1.f;
612
613 gl.readPixels(0, 0, 1, 1, GL_RED, GL_FLOAT, &red);
614 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels() call failed.");
615
616 if (de::abs(1.f - red) <= 0.125 /* Precision. */)
617 {
618 return true;
619 }
620
621 return false;
622 }
623
624 /** @brief Release program object.
625 */
cleanProgram()626 void gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::cleanProgram()
627 {
628 /* Shortcut for GL functionality. */
629 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
630
631 /* Deleting program. */
632 if (m_po_id)
633 {
634 gl.useProgram(0);
635
636 gl.deleteProgram(m_po_id);
637
638 m_po_id = 0;
639 }
640 }
641
642 /** @brief Release framebuffer, renderbuffer and vertex array objects.
643 */
cleanFramebufferAndVertexArrayObject()644 void gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::cleanFramebufferAndVertexArrayObject()
645 {
646 /* Shortcut for GL functionality. */
647 const glw::Functions &gl = m_context.getRenderContext().getFunctions();
648
649 /* Deleting view. */
650 if (m_fbo_id)
651 {
652 gl.deleteFramebuffers(1, &m_fbo_id);
653
654 m_fbo_id = 0;
655 }
656
657 if (m_rbo_id)
658 {
659 gl.deleteRenderbuffers(1, &m_rbo_id);
660
661 m_rbo_id = 0;
662 }
663
664 if (m_vao_id)
665 {
666 gl.deleteVertexArrays(1, &m_vao_id);
667
668 m_vao_id = 0;
669 }
670 }
671
672 const glw::GLchar *gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::s_shader_version = "#version 310 es\n";
673
674 const glw::GLchar *gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::s_vertex_shader_body =
675 "\n"
676 "out highp float vout;\n"
677 "\n"
678 "void main()\n"
679 "{\n"
680 " switch(gl_VertexID % 4)\n"
681 " {\n"
682 " case 0:\n"
683 " gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);\n"
684 " break;\n"
685 " case 1:\n"
686 " gl_Position = vec4( 1.0, -1.0, 0.0, 1.0);\n"
687 " break;\n"
688 " case 2:\n"
689 " gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);\n"
690 " break;\n"
691 " case 3:\n"
692 " gl_Position = vec4( 1.0, 1.0, 0.0, 1.0);\n"
693 " break;\n"
694 " }\n"
695 "\n"
696 " vout = float(gl_VertexID % 4);\n /* Always less than 4. */"
697 "}\n";
698
699 const glw::GLchar *gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::s_fragment_shader_body =
700 "\n"
701 "in highp float vout;\n"
702 "\n"
703 "out highp vec4 result;\n"
704 "\n"
705 "void main()\n"
706 "{\n"
707 " TTYPE a = LEFT;\n"
708 " TTYPE b = RIGHT;\n"
709 " BTYPE c = BDATA && BTYPE(vout < 4.0);\n /* Making sure that expression is not compile time constant. */"
710 "\n"
711 " TTYPE mixed = mix(a, b, c);\n"
712 "\n"
713 " if(REFERENCE == mixed)\n"
714 " {\n"
715 " result = vec4(1.0);\n"
716 " }\n"
717 " else\n"
718 " {\n"
719 " result = vec4(0.0);\n"
720 " }\n"
721 "}\n";
722
723 const struct gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::Shader
724 gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::s_shaders[] = {
725 {{s_shader_version, "", s_vertex_shader_body},
726 {s_shader_version,
727 "#define TTYPE highp int\n"
728 "#define BTYPE bool\n"
729 "#define LEFT -1\n"
730 "#define RIGHT -2\n"
731 "#define BDATA true\n"
732 "#define REFERENCE -2\n",
733 s_fragment_shader_body}},
734 {{s_shader_version, "", s_vertex_shader_body},
735 {s_shader_version,
736 "#define TTYPE highp uint\n"
737 "#define BTYPE bool\n"
738 "#define LEFT 1u\n"
739 "#define RIGHT 2u\n"
740 "#define BDATA true\n"
741 "#define REFERENCE 2u\n",
742 s_fragment_shader_body}},
743 {{s_shader_version, "", s_vertex_shader_body},
744 {s_shader_version,
745 "#define TTYPE mediump int\n"
746 "#define BTYPE bool\n"
747 "#define LEFT -1\n"
748 "#define RIGHT -2\n"
749 "#define BDATA true\n"
750 "#define REFERENCE -2\n",
751 s_fragment_shader_body}},
752 {{s_shader_version, "", s_vertex_shader_body},
753 {s_shader_version,
754 "#define TTYPE mediump uint\n"
755 "#define BTYPE bool\n"
756 "#define LEFT 1u\n"
757 "#define RIGHT 2u\n"
758 "#define BDATA true\n"
759 "#define REFERENCE 2u\n",
760 s_fragment_shader_body}},
761 {{s_shader_version, "", s_vertex_shader_body},
762 {s_shader_version,
763 "#define TTYPE lowp int\n"
764 "#define BTYPE bool\n"
765 "#define LEFT -1\n"
766 "#define RIGHT -2\n"
767 "#define BDATA true\n"
768 "#define REFERENCE -2\n",
769 s_fragment_shader_body}},
770 {{s_shader_version, "", s_vertex_shader_body},
771 {s_shader_version,
772 "#define TTYPE lowp uint\n"
773 "#define BTYPE bool\n"
774 "#define LEFT 1u\n"
775 "#define RIGHT 2u\n"
776 "#define BDATA true\n"
777 "#define REFERENCE 2u\n",
778 s_fragment_shader_body}},
779 {{s_shader_version, "", s_vertex_shader_body},
780 {s_shader_version,
781 "#define TTYPE bool\n"
782 "#define BTYPE bool\n"
783 "#define LEFT false\n"
784 "#define RIGHT true\n"
785 "#define BDATA true\n"
786 "#define REFERENCE true\n",
787 s_fragment_shader_body}},
788 {{s_shader_version, "", s_vertex_shader_body},
789 {s_shader_version,
790 "#define TTYPE highp ivec2\n"
791 "#define BTYPE bvec2\n"
792 "#define LEFT ivec2(-1, -2)\n"
793 "#define RIGHT ivec2(-3, -4)\n"
794 "#define BDATA bvec2(true, false)\n"
795 "#define REFERENCE ivec2(-3, -2)\n",
796 s_fragment_shader_body}},
797 {{s_shader_version, "", s_vertex_shader_body},
798 {s_shader_version,
799 "#define TTYPE highp uvec2\n"
800 "#define BTYPE bvec2\n"
801 "#define LEFT uvec2(1, 2)\n"
802 "#define RIGHT uvec2(3, 4)\n"
803 "#define BDATA bvec2(true, false)\n"
804 "#define REFERENCE uvec2(3, 2)\n",
805 s_fragment_shader_body}},
806 {{s_shader_version, "", s_vertex_shader_body},
807 {s_shader_version,
808 "#define TTYPE mediump ivec2\n"
809 "#define BTYPE bvec2\n"
810 "#define LEFT ivec2(-1, -2)\n"
811 "#define RIGHT ivec2(-3, -4)\n"
812 "#define BDATA bvec2(true, false)\n"
813 "#define REFERENCE ivec2(-3, -2)\n",
814 s_fragment_shader_body}},
815 {{s_shader_version, "", s_vertex_shader_body},
816 {s_shader_version,
817 "#define TTYPE mediump uvec2\n"
818 "#define BTYPE bvec2\n"
819 "#define LEFT uvec2(1, 2)\n"
820 "#define RIGHT uvec2(3, 4)\n"
821 "#define BDATA bvec2(true, false)\n"
822 "#define REFERENCE uvec2(3, 2)\n",
823 s_fragment_shader_body}},
824 {{s_shader_version, "", s_vertex_shader_body},
825 {s_shader_version,
826 "#define TTYPE lowp ivec2\n"
827 "#define BTYPE bvec2\n"
828 "#define LEFT ivec2(-1, -2)\n"
829 "#define RIGHT ivec2(-3, -4)\n"
830 "#define BDATA bvec2(true, false)\n"
831 "#define REFERENCE ivec2(-3, -2)\n",
832 s_fragment_shader_body}},
833 {{s_shader_version, "", s_vertex_shader_body},
834 {s_shader_version,
835 "#define TTYPE lowp uvec2\n"
836 "#define BTYPE bvec2\n"
837 "#define LEFT uvec2(1, 2)\n"
838 "#define RIGHT uvec2(3, 4)\n"
839 "#define BDATA bvec2(true, false)\n"
840 "#define REFERENCE uvec2(3, 2)\n",
841 s_fragment_shader_body}},
842 {{s_shader_version, "", s_vertex_shader_body},
843 {s_shader_version,
844 "#define TTYPE bvec2\n"
845 "#define BTYPE bvec2\n"
846 "#define LEFT bvec2(true, true)\n"
847 "#define RIGHT bvec2(false, false)\n"
848 "#define BDATA bvec2(true, false)\n"
849 "#define REFERENCE bvec2(false, true)\n",
850 s_fragment_shader_body}},
851 {{s_shader_version, "", s_vertex_shader_body},
852 {s_shader_version,
853 "#define TTYPE highp ivec3\n"
854 "#define BTYPE bvec3\n"
855 "#define LEFT ivec3(-1, -2, -3)\n"
856 "#define RIGHT ivec3(-4, -5, -6)\n"
857 "#define BDATA bvec3(true, false, true)\n"
858 "#define REFERENCE ivec3(-4, -2, -6)\n",
859 s_fragment_shader_body}},
860 {{s_shader_version, "", s_vertex_shader_body},
861 {s_shader_version,
862 "#define TTYPE highp uvec3\n"
863 "#define BTYPE bvec3\n"
864 "#define LEFT uvec3(1, 2, 3)\n"
865 "#define RIGHT uvec3(4, 5, 6)\n"
866 "#define BDATA bvec3(true, false, true)\n"
867 "#define REFERENCE uvec3(4, 2, 6)\n",
868 s_fragment_shader_body}},
869 {{s_shader_version, "", s_vertex_shader_body},
870 {s_shader_version,
871 "#define TTYPE mediump ivec3\n"
872 "#define BTYPE bvec3\n"
873 "#define LEFT ivec3(-1, -2, -3)\n"
874 "#define RIGHT ivec3(-4, -5, -6)\n"
875 "#define BDATA bvec3(true, false, true)\n"
876 "#define REFERENCE ivec3(-4, -2, -6)\n",
877 s_fragment_shader_body}},
878 {{s_shader_version, "", s_vertex_shader_body},
879 {s_shader_version,
880 "#define TTYPE mediump uvec3\n"
881 "#define BTYPE bvec3\n"
882 "#define LEFT uvec3(1, 2, 3)\n"
883 "#define RIGHT uvec3(4, 5, 6)\n"
884 "#define BDATA bvec3(true, false, true)\n"
885 "#define REFERENCE uvec3(4, 2, 6)\n",
886 s_fragment_shader_body}},
887 {{s_shader_version, "", s_vertex_shader_body},
888 {s_shader_version,
889 "#define TTYPE lowp ivec3\n"
890 "#define BTYPE bvec3\n"
891 "#define LEFT ivec3(-1, -2, -3)\n"
892 "#define RIGHT ivec3(-4, -5, -6)\n"
893 "#define BDATA bvec3(true, false, true)\n"
894 "#define REFERENCE ivec3(-4, -2, -6)\n",
895 s_fragment_shader_body}},
896 {{s_shader_version, "", s_vertex_shader_body},
897 {s_shader_version,
898 "#define TTYPE lowp uvec3\n"
899 "#define BTYPE bvec3\n"
900 "#define LEFT uvec3(1, 2, 3)\n"
901 "#define RIGHT uvec3(4, 5, 6)\n"
902 "#define BDATA bvec3(true, false, true)\n"
903 "#define REFERENCE uvec3(4, 2, 6)\n",
904 s_fragment_shader_body}},
905 {{s_shader_version, "", s_vertex_shader_body},
906 {s_shader_version,
907 "#define TTYPE bvec3\n"
908 "#define BTYPE bvec3\n"
909 "#define LEFT bvec3(true, true, true)\n"
910 "#define RIGHT bvec3(false, false, false)\n"
911 "#define BDATA bvec3(true, false, true)\n"
912 "#define REFERENCE bvec3(false, true, false)\n",
913 s_fragment_shader_body}},
914 {{s_shader_version, "", s_vertex_shader_body},
915 {s_shader_version,
916 "#define TTYPE highp ivec4\n"
917 "#define BTYPE bvec4\n"
918 "#define LEFT ivec4(-1, -2, -3, -4)\n"
919 "#define RIGHT ivec4(-5, -6, -7, -8)\n"
920 "#define BDATA bvec4(true, false, true, false)\n"
921 "#define REFERENCE ivec4(-5, -2, -7, -4)\n",
922 s_fragment_shader_body}},
923 {{s_shader_version, "", s_vertex_shader_body},
924 {s_shader_version,
925 "#define TTYPE highp uvec4\n"
926 "#define BTYPE bvec4\n"
927 "#define LEFT uvec4(1, 2, 3, 4)\n"
928 "#define RIGHT uvec4(5, 6, 7, 8)\n"
929 "#define BDATA bvec4(true, false, true, false)\n"
930 "#define REFERENCE uvec4(5, 2, 7, 4)\n",
931 s_fragment_shader_body}},
932 {{s_shader_version, "", s_vertex_shader_body},
933 {s_shader_version,
934 "#define TTYPE mediump ivec4\n"
935 "#define BTYPE bvec4\n"
936 "#define LEFT ivec4(-1, -2, -3, -4)\n"
937 "#define RIGHT ivec4(-5, -6, -7, -8)\n"
938 "#define BDATA bvec4(true, false, true, false)\n"
939 "#define REFERENCE ivec4(-5, -2, -7, -4)\n",
940 s_fragment_shader_body}},
941 {{s_shader_version, "", s_vertex_shader_body},
942 {s_shader_version,
943 "#define TTYPE mediump uvec4\n"
944 "#define BTYPE bvec4\n"
945 "#define LEFT uvec4(1, 2, 3, 4)\n"
946 "#define RIGHT uvec4(5, 6, 7, 8)\n"
947 "#define BDATA bvec4(true, false, true, false)\n"
948 "#define REFERENCE uvec4(5, 2, 7, 4)\n",
949 s_fragment_shader_body}},
950 {{s_shader_version, "", s_vertex_shader_body},
951 {s_shader_version,
952 "#define TTYPE lowp ivec4\n"
953 "#define BTYPE bvec4\n"
954 "#define LEFT ivec4(-1, -2, -3, -4)\n"
955 "#define RIGHT ivec4(-5, -6, -7, -8)\n"
956 "#define BDATA bvec4(true, false, true, false)\n"
957 "#define REFERENCE ivec4(-5, -2, -7, -4)\n",
958 s_fragment_shader_body}},
959 {{s_shader_version, "", s_vertex_shader_body},
960 {s_shader_version,
961 "#define TTYPE lowp uvec4\n"
962 "#define BTYPE bvec4\n"
963 "#define LEFT uvec4(1, 2, 3, 4)\n"
964 "#define RIGHT uvec4(5, 6, 7, 8)\n"
965 "#define BDATA bvec4(true, false, true, false)\n"
966 "#define REFERENCE uvec4(5, 2, 7, 4)\n",
967 s_fragment_shader_body}},
968 {{s_shader_version, "", s_vertex_shader_body},
969 {s_shader_version,
970 "#define TTYPE bvec4\n"
971 "#define BTYPE bvec4\n"
972 "#define LEFT bvec4(true, true, true, true)\n"
973 "#define RIGHT bvec4(false, false, false, false)\n"
974 "#define BDATA bvec4(true, false, true, false)\n"
975 "#define REFERENCE bvec4(false, true, false, true)\n",
976 s_fragment_shader_body}}};
977
978 const glw::GLsizei gl4cts::es31compatibility::ShaderFunctionalCompatibilityTest::s_shaders_count =
979 sizeof(s_shaders) / sizeof(s_shaders[0]);
980