1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2014-2016 The Khronos Group Inc.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 */ /*-------------------------------------------------------------------*/
25 * \file glcViewportArrayTests.cpp
26 * \brief Implements conformance tests for "Viewport Array" functionality.
27 */ /*-------------------------------------------------------------------*/
29 #include "glcViewportArrayTests.hpp"
31 #include "gluContextInfo.hpp"
32 #include "gluDefs.hpp"
33 #include "gluStrUtil.hpp"
34 #include "glwEnums.hpp"
35 #include "glwFunctions.hpp"
36 #include "tcuRenderTarget.hpp"
37 #include "tcuTestLog.hpp"
49 namespace ViewportArray
53 * @param context CTS context.
55 Utils::buffer::buffer(deqp::Context& context) : m_id(0), m_context(context), m_target(0)
62 Utils::buffer::~buffer()
66 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
68 gl.deleteBuffers(1, &m_id);
73 /** Execute BindBuffer
76 void Utils::buffer::bind() const
78 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
80 gl.bindBuffer(m_target, m_id);
81 GLU_EXPECT_NO_ERROR(gl.getError(), "BindBuffer");
84 /** Execute BindBufferRange
86 * @param index <index> parameter
87 * @param offset <offset> parameter
88 * @param size <size> parameter
90 void Utils::buffer::bindRange(glw::GLuint index, glw::GLintptr offset, glw::GLsizeiptr size)
92 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
94 gl.bindBufferRange(m_target, index, m_id, offset, size);
95 GLU_EXPECT_NO_ERROR(gl.getError(), "BindBufferRange");
100 * @param target Target that will be used by this buffer
102 void Utils::buffer::generate(glw::GLenum target)
104 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
108 gl.genBuffers(1, &m_id);
109 GLU_EXPECT_NO_ERROR(gl.getError(), "GenBuffers");
112 /** Maps buffer content
114 * @param access Access rights for mapped region
116 * @return Mapped memory
118 void* Utils::buffer::map(GLenum access) const
120 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
122 gl.bindBuffer(m_target, m_id);
123 GLU_EXPECT_NO_ERROR(gl.getError(), "bindBuffer");
125 void* result = gl.mapBuffer(m_target, access);
126 GLU_EXPECT_NO_ERROR(gl.getError(), "MapBuffer");
134 void Utils::buffer::unmap() const
136 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
138 gl.bindBuffer(m_target, m_id);
139 GLU_EXPECT_NO_ERROR(gl.getError(), "bindBuffer");
141 gl.unmapBuffer(m_target);
142 GLU_EXPECT_NO_ERROR(gl.getError(), "UnmapBuffer");
145 /** Execute BufferData
147 * @param size <size> parameter
148 * @param data <data> parameter
149 * @param usage <usage> parameter
151 void Utils::buffer::update(glw::GLsizeiptr size, glw::GLvoid* data, glw::GLenum usage)
153 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
155 gl.bindBuffer(m_target, m_id);
156 GLU_EXPECT_NO_ERROR(gl.getError(), "bindBuffer");
158 gl.bufferData(m_target, size, data, usage);
159 GLU_EXPECT_NO_ERROR(gl.getError(), "bufferData");
164 * @param context CTS context
166 Utils::framebuffer::framebuffer(deqp::Context& context) : m_id(0), m_context(context)
168 /* Nothing to be done here */
174 Utils::framebuffer::~framebuffer()
178 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
180 gl.deleteFramebuffers(1, &m_id);
185 /** Attach texture to specified attachment
187 * @param attachment Attachment
188 * @param texture_id Texture id
189 * @param width Texture width
190 * @param height Texture height
192 void Utils::framebuffer::attachTexture(glw::GLenum attachment, glw::GLuint texture_id, glw::GLuint width,
195 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
199 gl.framebufferTexture(GL_DRAW_FRAMEBUFFER, attachment, texture_id, 0 /* level */);
200 GLU_EXPECT_NO_ERROR(gl.getError(), "FramebufferTexture");
202 gl.viewport(0 /* x */, 0 /* y */, width, height);
203 GLU_EXPECT_NO_ERROR(gl.getError(), "Viewport");
206 /** Binds framebuffer to DRAW_FRAMEBUFFER
209 void Utils::framebuffer::bind()
211 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
213 gl.bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_id);
214 GLU_EXPECT_NO_ERROR(gl.getError(), "BindFramebuffer");
217 /** Clear framebuffer
219 * @param mask <mask> parameter of glClear. Decides which shall be cleared
221 void Utils::framebuffer::clear(glw::GLenum mask)
223 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
226 GLU_EXPECT_NO_ERROR(gl.getError(), "Clear");
229 /** Specifies clear color
231 * @param red Red channel
232 * @param green Green channel
233 * @param blue Blue channel
234 * @param alpha Alpha channel
236 void Utils::framebuffer::clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
238 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
240 gl.clearColor(red, green, blue, alpha);
241 GLU_EXPECT_NO_ERROR(gl.getError(), "ClearColor");
244 /** Generate framebuffer
247 void Utils::framebuffer::generate()
249 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
251 gl.genFramebuffers(1, &m_id);
252 GLU_EXPECT_NO_ERROR(gl.getError(), "GenFramebuffers");
255 Utils::shaderCompilationException::shaderCompilationException(const glw::GLchar* source, const glw::GLchar* message)
256 : m_shader_source(source), m_error_message(message)
258 /* Nothing to be done */
261 const char* Utils::shaderCompilationException::what() const throw()
263 return "Shader compilation failed";
266 Utils::programLinkageException::programLinkageException(const glw::GLchar* message) : m_error_message(message)
268 /* Nothing to be done */
271 const char* Utils::programLinkageException::what() const throw()
273 return "Program linking failed";
276 const glw::GLenum Utils::program::ARB_COMPUTE_SHADER = 0x91B9;
280 * @param context CTS context.
282 Utils::program::program(deqp::Context& context)
283 : m_compute_shader_id(0)
284 , m_fragment_shader_id(0)
285 , m_geometry_shader_id(0)
286 , m_program_object_id(0)
287 , m_tesselation_control_shader_id(0)
288 , m_tesselation_evaluation_shader_id(0)
289 , m_vertex_shader_id(0)
292 /* Nothing to be done here */
298 Utils::program::~program()
305 * @param compute_shader_code Compute shader source code
306 * @param fragment_shader_code Fragment shader source code
307 * @param geometry_shader_code Geometry shader source code
308 * @param tesselation_control_shader_code Tesselation control shader source code
309 * @param tesselation_evaluation_shader_code Tesselation evaluation shader source code
310 * @param vertex_shader_code Vertex shader source code
311 * @param varying_names Array of strings containing names of varyings to be captured with transfrom feedback
312 * @param n_varying_names Number of varyings to be captured with transfrom feedback
313 * @param is_separable Selects if monolithis or separable program should be built. Defaults to false
315 void Utils::program::build(const glw::GLchar* compute_shader_code, const glw::GLchar* fragment_shader_code,
316 const glw::GLchar* geometry_shader_code, const glw::GLchar* tesselation_control_shader_code,
317 const glw::GLchar* tesselation_evaluation_shader_code, const glw::GLchar* vertex_shader_code,
318 const glw::GLchar* const* varying_names, glw::GLuint n_varying_names, bool is_separable)
320 /* GL entry points */
321 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
323 /* Create shader objects and compile */
324 if (0 != compute_shader_code)
326 m_compute_shader_id = gl.createShader(ARB_COMPUTE_SHADER);
327 GLU_EXPECT_NO_ERROR(gl.getError(), "CreateShader");
329 compile(m_compute_shader_id, compute_shader_code);
332 if (0 != fragment_shader_code)
334 m_fragment_shader_id = gl.createShader(GL_FRAGMENT_SHADER);
335 GLU_EXPECT_NO_ERROR(gl.getError(), "CreateShader");
337 compile(m_fragment_shader_id, fragment_shader_code);
340 if (0 != geometry_shader_code)
342 m_geometry_shader_id = gl.createShader(GL_GEOMETRY_SHADER);
343 GLU_EXPECT_NO_ERROR(gl.getError(), "CreateShader");
345 compile(m_geometry_shader_id, geometry_shader_code);
348 if (0 != tesselation_control_shader_code)
350 m_tesselation_control_shader_id = gl.createShader(GL_TESS_CONTROL_SHADER);
351 GLU_EXPECT_NO_ERROR(gl.getError(), "CreateShader");
353 compile(m_tesselation_control_shader_id, tesselation_control_shader_code);
356 if (0 != tesselation_evaluation_shader_code)
358 m_tesselation_evaluation_shader_id = gl.createShader(GL_TESS_EVALUATION_SHADER);
359 GLU_EXPECT_NO_ERROR(gl.getError(), "CreateShader");
361 compile(m_tesselation_evaluation_shader_id, tesselation_evaluation_shader_code);
364 if (0 != vertex_shader_code)
366 m_vertex_shader_id = gl.createShader(GL_VERTEX_SHADER);
367 GLU_EXPECT_NO_ERROR(gl.getError(), "CreateShader");
369 compile(m_vertex_shader_id, vertex_shader_code);
372 /* Create program object */
373 m_program_object_id = gl.createProgram();
374 GLU_EXPECT_NO_ERROR(gl.getError(), "CreateProgram");
376 /* Set up captyured varyings' names */
377 if (0 != n_varying_names)
379 gl.transformFeedbackVaryings(m_program_object_id, n_varying_names, varying_names, GL_INTERLEAVED_ATTRIBS);
380 GLU_EXPECT_NO_ERROR(gl.getError(), "TransformFeedbackVaryings");
383 /* Set separable parameter */
384 if (true == is_separable)
386 gl.programParameteri(m_program_object_id, GL_PROGRAM_SEPARABLE, GL_TRUE);
387 GLU_EXPECT_NO_ERROR(gl.getError(), "ProgramParameteri");
394 void Utils::program::compile(GLuint shader_id, const GLchar* source) const
396 /* GL entry points */
397 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
399 /* Compilation status */
400 glw::GLint status = GL_FALSE;
402 /* Set source code */
403 gl.shaderSource(shader_id, 1 /* count */, &source, 0 /* lengths */);
404 GLU_EXPECT_NO_ERROR(gl.getError(), "ShaderSource");
407 gl.compileShader(shader_id);
408 GLU_EXPECT_NO_ERROR(gl.getError(), "CompileShader");
410 /* Get compilation status */
411 gl.getShaderiv(shader_id, GL_COMPILE_STATUS, &status);
412 GLU_EXPECT_NO_ERROR(gl.getError(), "GetShaderiv");
414 /* Log compilation error */
415 if (GL_TRUE != status)
417 glw::GLint length = 0;
418 std::vector<glw::GLchar> message;
420 /* Error log length */
421 gl.getShaderiv(shader_id, GL_INFO_LOG_LENGTH, &length);
422 GLU_EXPECT_NO_ERROR(gl.getError(), "GetShaderiv");
424 /* Prepare storage */
425 message.resize(length);
428 gl.getShaderInfoLog(shader_id, length, 0, &message[0]);
429 GLU_EXPECT_NO_ERROR(gl.getError(), "GetShaderInfoLog");
431 throw shaderCompilationException(source, &message[0]);
435 glw::GLint Utils::program::getAttribLocation(const glw::GLchar* name) const
437 /* GL entry points */
438 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
440 GLint location = gl.getAttribLocation(m_program_object_id, name);
441 GLU_EXPECT_NO_ERROR(gl.getError(), "GetAttribLocation");
446 /** Get subroutine index
448 * @param subroutine_name Subroutine name
450 * @return Index of subroutine
452 GLuint Utils::program::getSubroutineIndex(const glw::GLchar* subroutine_name, glw::GLenum shader_stage) const
454 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
457 index = gl.getSubroutineIndex(m_program_object_id, shader_stage, subroutine_name);
458 GLU_EXPECT_NO_ERROR(gl.getError(), "GetSubroutineIndex");
460 if (GL_INVALID_INDEX == index)
462 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Subroutine: " << subroutine_name
463 << " is not available" << tcu::TestLog::EndMessage;
465 TCU_FAIL("Subroutine is not available");
471 /** Get subroutine uniform location
473 * @param uniform_name Subroutine uniform name
475 * @return Location of subroutine uniform
477 GLint Utils::program::getSubroutineUniformLocation(const glw::GLchar* uniform_name, glw::GLenum shader_stage) const
479 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
482 location = gl.getSubroutineUniformLocation(m_program_object_id, shader_stage, uniform_name);
483 GLU_EXPECT_NO_ERROR(gl.getError(), "GetSubroutineUniformLocation");
487 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Subroutine uniform: " << uniform_name
488 << " is not available" << tcu::TestLog::EndMessage;
490 TCU_FAIL("Subroutine uniform is not available");
496 /** Get uniform location
498 * @param uniform_name Subroutine uniform name
500 * @return Location of uniform
502 GLint Utils::program::getUniformLocation(const glw::GLchar* uniform_name) const
504 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
507 location = gl.getUniformLocation(m_program_object_id, uniform_name);
508 GLU_EXPECT_NO_ERROR(gl.getError(), "GetUniformLocation");
512 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Uniform: " << uniform_name
513 << " is not available" << tcu::TestLog::EndMessage;
515 TCU_FAIL("Uniform is not available");
521 /** Attach shaders and link program
524 void Utils::program::link() const
526 /* GL entry points */
527 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
530 glw::GLint status = GL_FALSE;
533 if (0 != m_compute_shader_id)
535 gl.attachShader(m_program_object_id, m_compute_shader_id);
536 GLU_EXPECT_NO_ERROR(gl.getError(), "AttachShader");
539 if (0 != m_fragment_shader_id)
541 gl.attachShader(m_program_object_id, m_fragment_shader_id);
542 GLU_EXPECT_NO_ERROR(gl.getError(), "AttachShader");
545 if (0 != m_geometry_shader_id)
547 gl.attachShader(m_program_object_id, m_geometry_shader_id);
548 GLU_EXPECT_NO_ERROR(gl.getError(), "AttachShader");
551 if (0 != m_tesselation_control_shader_id)
553 gl.attachShader(m_program_object_id, m_tesselation_control_shader_id);
554 GLU_EXPECT_NO_ERROR(gl.getError(), "AttachShader");
557 if (0 != m_tesselation_evaluation_shader_id)
559 gl.attachShader(m_program_object_id, m_tesselation_evaluation_shader_id);
560 GLU_EXPECT_NO_ERROR(gl.getError(), "AttachShader");
563 if (0 != m_vertex_shader_id)
565 gl.attachShader(m_program_object_id, m_vertex_shader_id);
566 GLU_EXPECT_NO_ERROR(gl.getError(), "AttachShader");
570 gl.linkProgram(m_program_object_id);
571 GLU_EXPECT_NO_ERROR(gl.getError(), "LinkProgram");
573 /* Get link status */
574 gl.getProgramiv(m_program_object_id, GL_LINK_STATUS, &status);
575 GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramiv");
578 if (GL_TRUE != status)
580 glw::GLint length = 0;
581 std::vector<glw::GLchar> message;
583 /* Get error log length */
584 gl.getProgramiv(m_program_object_id, GL_INFO_LOG_LENGTH, &length);
585 GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramiv");
587 message.resize(length);
590 gl.getProgramInfoLog(m_program_object_id, length, 0, &message[0]);
591 GLU_EXPECT_NO_ERROR(gl.getError(), "GetProgramInfoLog");
593 throw programLinkageException(&message[0]);
597 /** Delete program object and all attached shaders
600 void Utils::program::remove()
602 /* GL entry points */
603 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
605 /* Make sure program object is no longer used by GL */
608 /* Clean program object */
609 if (0 != m_program_object_id)
611 gl.deleteProgram(m_program_object_id);
612 m_program_object_id = 0;
616 if (0 != m_compute_shader_id)
618 gl.deleteShader(m_compute_shader_id);
619 m_compute_shader_id = 0;
622 if (0 != m_fragment_shader_id)
624 gl.deleteShader(m_fragment_shader_id);
625 m_fragment_shader_id = 0;
628 if (0 != m_geometry_shader_id)
630 gl.deleteShader(m_geometry_shader_id);
631 m_geometry_shader_id = 0;
634 if (0 != m_tesselation_control_shader_id)
636 gl.deleteShader(m_tesselation_control_shader_id);
637 m_tesselation_control_shader_id = 0;
640 if (0 != m_tesselation_evaluation_shader_id)
642 gl.deleteShader(m_tesselation_evaluation_shader_id);
643 m_tesselation_evaluation_shader_id = 0;
646 if (0 != m_vertex_shader_id)
648 gl.deleteShader(m_vertex_shader_id);
649 m_vertex_shader_id = 0;
653 /** Execute UseProgram
656 void Utils::program::use() const
658 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
660 gl.useProgram(m_program_object_id);
661 GLU_EXPECT_NO_ERROR(gl.getError(), "UseProgram");
664 void Utils::program::printShaderSource(const GLchar* source, tcu::MessageBuilder& log)
666 GLuint line_number = 0;
668 log << "Shader source.";
670 log << "\nLine||Source\n";
675 const GLchar* next_line = strchr(source, '\n');
680 line.assign(source, next_line - source);
689 log << std::setw(4) << line_number << "||" << line;
699 * @param context CTS context.
701 Utils::texture::texture(deqp::Context& context)
702 : m_id(0), m_width(0), m_height(0), m_depth(0), m_context(context), m_is_array(false)
704 /* Nothing to done here */
710 Utils::texture::~texture()
715 /** Bind texture to GL_TEXTURE_2D
718 void Utils::texture::bind() const
720 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
722 if (false == m_is_array)
724 gl.bindTexture(GL_TEXTURE_2D, m_id);
725 GLU_EXPECT_NO_ERROR(gl.getError(), "BindTexture");
729 gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_id);
730 GLU_EXPECT_NO_ERROR(gl.getError(), "BindTexture");
734 /** Create 2d texture
736 * @param width Width of texture
737 * @param height Height of texture
738 * @param internal_format Internal format of texture
740 void Utils::texture::create(GLuint width, GLuint height, GLenum internal_format)
742 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
751 gl.genTextures(1, &m_id);
752 GLU_EXPECT_NO_ERROR(gl.getError(), "GenTextures");
756 gl.texStorage2D(GL_TEXTURE_2D, 1 /* levels */, internal_format, width, height);
757 GLU_EXPECT_NO_ERROR(gl.getError(), "TexStorage2D");
760 /** Create 2d texture array
762 * @param width Width of texture
763 * @param height Height of texture
764 * @param depth Depth of texture
765 * @param internal_format Internal format of texture
767 void Utils::texture::create(GLuint width, GLuint height, GLuint depth, GLenum internal_format)
769 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
778 gl.genTextures(1, &m_id);
779 GLU_EXPECT_NO_ERROR(gl.getError(), "GenTextures");
783 gl.texStorage3D(GL_TEXTURE_2D_ARRAY, 1 /* levels */, internal_format, width, height, depth);
784 GLU_EXPECT_NO_ERROR(gl.getError(), "TexStorage3D");
787 /** Get contents of texture
789 * @param format Format of image
790 * @param type Type of image
791 * @param out_data Buffer for image
793 void Utils::texture::get(glw::GLenum format, glw::GLenum type, glw::GLvoid* out_data) const
795 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
796 const glu::ContextType& context_type = m_context.getRenderContext().getType();
800 GLenum textarget = GL_TEXTURE_2D;
802 if (true == m_is_array)
804 textarget = GL_TEXTURE_2D_ARRAY;
807 if (glu::isContextTypeGLCore(context_type))
809 gl.getTexImage(textarget, 0 /* level */, format, type, out_data);
810 GLU_EXPECT_NO_ERROR(gl.getError(), "GetTexImage");
814 DE_ASSERT(glu::isContextTypeES(context_type));
817 gl.genFramebuffers(1, &temp_fbo);
818 gl.bindFramebuffer(GL_READ_FRAMEBUFFER, temp_fbo);
820 /* OpenGL ES only guarantees support for RGBA formats of each type.
821 Since the tests are only expecting single-channel formats, we read them back
822 in RGBA to a temporary buffer and then copy only the first component
823 to the actual output buffer */
824 GLenum read_format = format;
828 read_format = GL_RGBA;
831 read_format = GL_RGBA_INTEGER;
834 TCU_FAIL("unexpected format");
836 /* we can get away just handling one type of data, as long as the components are the same size */
837 if (type != GL_INT && type != GL_FLOAT)
839 TCU_FAIL("unexpected type");
841 std::vector<GLint> read_data;
842 const GLuint layer_size = m_width * m_height * 4;
843 read_data.resize(layer_size * m_depth);
847 for (GLuint layer = 0; layer < m_depth; ++layer)
849 gl.framebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_id, 0, layer);
850 gl.readPixels(0, 0, m_width, m_height, read_format, type, &read_data[layer * layer_size]);
855 gl.framebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textarget, m_id, 0);
856 gl.readPixels(0, 0, m_width, m_height, read_format, type, &read_data[0]);
858 GLU_EXPECT_NO_ERROR(gl.getError(), "ReadPixels");
859 gl.deleteFramebuffers(1, &temp_fbo);
861 /* copy the first channel from the readback buffer to the output buffer */
862 GLint* out_data_int = (GLint*)out_data;
863 for (GLuint elem = 0; elem < (m_width * m_height * m_depth); ++elem)
865 out_data_int[elem] = read_data[elem * 4];
873 void Utils::texture::release()
877 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
879 gl.deleteTextures(1, &m_id);
884 /** Update contents of texture
886 * @param width Width of texture
887 * @param height Height of texture
888 * @param depth Depth of texture
889 * @param format Format of data
890 * @param type Type of data
891 * @param data Buffer with image
893 void Utils::texture::update(glw::GLuint width, glw::GLuint height, glw::GLuint depth, glw::GLenum format,
894 glw::GLenum type, glw::GLvoid* data)
896 static const GLuint level = 0;
898 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
902 if (false == m_is_array)
904 gl.texSubImage2D(GL_TEXTURE_2D, level, 0 /* x */, 0 /* y */, width, height, format, type, data);
905 GLU_EXPECT_NO_ERROR(gl.getError(), "TexStorage2D");
909 gl.texSubImage3D(GL_TEXTURE_2D_ARRAY, level, 0 /* x */, 0 /* y */, 0 /* z */, width, height, depth, format,
911 GLU_EXPECT_NO_ERROR(gl.getError(), "TexStorage2D");
917 * @param context CTS context.
919 Utils::vertexArray::vertexArray(deqp::Context& context) : m_id(0), m_context(context)
926 Utils::vertexArray::~vertexArray()
930 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
932 gl.deleteVertexArrays(1, &m_id);
938 /** Execute BindVertexArray
941 void Utils::vertexArray::bind()
943 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
945 gl.bindVertexArray(m_id);
946 GLU_EXPECT_NO_ERROR(gl.getError(), "BindVertexArray");
949 /** Execute GenVertexArrays
952 void Utils::vertexArray::generate()
954 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
956 gl.genVertexArrays(1, &m_id);
957 GLU_EXPECT_NO_ERROR(gl.getError(), "GenVertexArrays");
962 * @param context Test context
964 APIErrors::APIErrors(deqp::Context& context, const glcts::ExtParameters& extParams)
965 : TestCaseBase(context, extParams, "api_errors", "Test verifies error generated by API")
967 /* Nothing to be done here */
970 template <typename T>
971 void APIErrors::depthRangeArrayHelper(Utils::DepthFuncWrapper& depthFunc, GLint max_viewports, bool& test_result, T*)
974 data.resize(max_viewports * 2 /* near + far */);
976 for (GLint i = 0; i < max_viewports; ++i)
978 data[i * 2] = (T)0.0;
979 data[i * 2 + 1] = (T)1.0;
982 depthFunc.depthRangeArray(0, max_viewports - 1, &data[0]);
983 checkGLError(GL_NO_ERROR, "depthRangeArray, correct parameters", test_result);
985 depthFunc.depthRangeArray(max_viewports, 1, &data[0]);
986 checkGLError(GL_INVALID_VALUE, "depthRangeArray, <first> == GL_MAX_VIEWPORTS", test_result);
988 depthFunc.depthRangeArray(1, max_viewports - 1, &data[0]);
989 checkGLError(GL_NO_ERROR, "depthRangeArray, <first> + <count> == GL_MAX_VIEWPORTS", test_result);
991 depthFunc.depthRangeArray(1, max_viewports, &data[0]);
992 checkGLError(GL_INVALID_VALUE, "depthRangeArray, <first> + <count> > GL_MAX_VIEWPORTS", test_result);
995 template <typename T>
996 void APIErrors::depthRangeIndexedHelper(Utils::DepthFuncWrapper& depthFunc, GLint max_viewports, bool& test_result, T*)
998 depthFunc.depthRangeIndexed(0 /* index */, (T)0.0, (T)1.0);
999 checkGLError(GL_NO_ERROR, "depthRangeIndexed, <index> == 0", test_result);
1001 depthFunc.depthRangeIndexed(max_viewports - 1 /* index */, (T)0.0, (T)1.0);
1002 checkGLError(GL_NO_ERROR, "depthRangeIndexed, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1004 depthFunc.depthRangeIndexed(max_viewports /* index */, (T)0.0, (T)1.0);
1005 checkGLError(GL_INVALID_VALUE, "depthRangeIndexed, <index> == GL_MAX_VIEWPORTS", test_result);
1007 depthFunc.depthRangeIndexed(max_viewports + 1 /* index */, (T)0.0, (T)1.0);
1008 checkGLError(GL_INVALID_VALUE, "depthRangeIndexed, <index> > GL_MAX_VIEWPORTS", test_result);
1011 template <typename T>
1012 void APIErrors::getDepthHelper(Utils::DepthFuncWrapper& depthFunc, GLint max_viewports, bool& test_result, T*)
1016 depthFunc.getDepthi_v(GL_DEPTH_RANGE, max_viewports - 1, data);
1017 checkGLError(GL_NO_ERROR, "getDouble/Floati_v, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1019 depthFunc.getDepthi_v(GL_DEPTH_RANGE, max_viewports, data);
1020 checkGLError(GL_INVALID_VALUE, "getDouble/Floati_v, <index> == GL_MAX_VIEWPORTS", test_result);
1025 * @return tcu::TestNode::CONTINUE after executing test case, tcu::TestNode::STOP otherwise
1027 tcu::TestNode::IterateResult APIErrors::iterate()
1029 if (!m_is_viewport_array_supported)
1031 throw tcu::NotSupportedError(VIEWPORT_ARRAY_NOT_SUPPORTED, "", __FILE__, __LINE__);
1034 /* GL entry points */
1035 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1036 const glu::ContextType& context_type = m_context.getRenderContext().getType();
1037 Utils::DepthFuncWrapper depthFunc(m_context);
1040 bool test_result = true;
1042 GLint max_viewports = 0;
1043 gl.getIntegerv(GL_MAX_VIEWPORTS, &max_viewports);
1044 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
1047 * * DepthRangeArrayv generates INVALID_VALUE when <first> + <count> is greater
1048 * than or equal to the value of MAX_VIEWPORTS;
1050 if (glu::isContextTypeGLCore(context_type))
1052 depthRangeArrayHelper<GLdouble>(depthFunc, max_viewports, test_result);
1056 DE_ASSERT(glu::isContextTypeES(context_type));
1057 depthRangeArrayHelper<GLfloat>(depthFunc, max_viewports, test_result);
1061 * * DepthRangeIndexed generates INVALID_VALUE when <index> is greater than or
1062 * equal to the value of MAX_VIEWPORTS;
1064 if (glu::isContextTypeGLCore(context_type))
1066 depthRangeIndexedHelper<GLdouble>(depthFunc, max_viewports, test_result);
1070 DE_ASSERT(glu::isContextTypeES(context_type));
1071 depthRangeIndexedHelper<GLfloat>(depthFunc, max_viewports, test_result);
1075 * * ViewportArrayv generates INVALID_VALUE when <first> + <count> is greater
1076 * than or equal to the value of MAX_VIEWPORTS;
1079 std::vector<GLfloat> data;
1080 data.resize(max_viewports * 4 /* x + y + w + h */);
1082 for (GLint i = 0; i < max_viewports; ++i)
1084 data[i * 4 + 0] = 0.0f;
1085 data[i * 4 + 1] = 0.0f;
1086 data[i * 4 + 2] = 1.0f;
1087 data[i * 4 + 3] = 1.0f;
1090 gl.viewportArrayv(0, max_viewports - 1, &data[0]);
1091 checkGLError(GL_NO_ERROR, "viewportArrayv, correct parameters", test_result);
1093 gl.viewportArrayv(max_viewports, 1, &data[0]);
1094 checkGLError(GL_INVALID_VALUE, "viewportArrayv, <first> == GL_MAX_VIEWPORTS", test_result);
1096 gl.viewportArrayv(1, max_viewports - 1, &data[0]);
1097 checkGLError(GL_NO_ERROR, "viewportArrayv, <first> + <count> == GL_MAX_VIEWPORTS", test_result);
1099 gl.viewportArrayv(1, max_viewports, &data[0]);
1100 checkGLError(GL_INVALID_VALUE, "viewportArrayv, <first> + <count> > GL_MAX_VIEWPORTS", test_result);
1104 * * ViewportIndexedf and ViewportIndexedfv generate INVALID_VALUE when <index>
1105 * is greater than or equal to the value of MAX_VIEWPORTS;
1108 GLfloat data[4 /* x + y + w + h */];
1115 gl.viewportIndexedf(0 /* index */, 0.0f, 0.0f, 1.0f, 1.0f);
1116 checkGLError(GL_NO_ERROR, "viewportIndexedf, <index> == 0", test_result);
1118 gl.viewportIndexedf(max_viewports - 1 /* index */, 0.0f, 0.0f, 1.0f, 1.0f);
1119 checkGLError(GL_NO_ERROR, "viewportIndexedf, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1121 gl.viewportIndexedf(max_viewports /* index */, 0.0f, 0.0f, 1.0f, 1.0f);
1122 checkGLError(GL_INVALID_VALUE, "viewportIndexedf, <index> == GL_MAX_VIEWPORTS", test_result);
1124 gl.viewportIndexedf(max_viewports + 1 /* index */, 0.0f, 0.0f, 1.0f, 1.0f);
1125 checkGLError(GL_INVALID_VALUE, "viewportIndexedf, <index> > GL_MAX_VIEWPORTS", test_result);
1127 gl.viewportIndexedfv(0 /* index */, data);
1128 checkGLError(GL_NO_ERROR, "viewportIndexedfv, <index> == 0", test_result);
1130 gl.viewportIndexedfv(max_viewports - 1 /* index */, data);
1131 checkGLError(GL_NO_ERROR, "viewportIndexedfv, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1133 gl.viewportIndexedfv(max_viewports /* index */, data);
1134 checkGLError(GL_INVALID_VALUE, "viewportIndexedfv, <index> == GL_MAX_VIEWPORTS", test_result);
1136 gl.viewportIndexedfv(max_viewports + 1 /* index */, data);
1137 checkGLError(GL_INVALID_VALUE, "viewportIndexedfv, <index> > GL_MAX_VIEWPORTS", test_result);
1141 * * ViewportArrayv, Viewport, ViewportIndexedf and ViewportIndexedfv generate
1142 * INVALID_VALUE when <w> or <h> values are negative;
1145 gl.viewport(0, 0, -1, 1);
1146 checkGLError(GL_INVALID_VALUE, "viewport, negative width", test_result);
1148 gl.viewport(0, 0, 1, -1);
1149 checkGLError(GL_INVALID_VALUE, "viewport, negative height", test_result);
1151 for (GLint i = 0; i < max_viewports; ++i)
1153 std::vector<GLfloat> data;
1154 data.resize(max_viewports * 4 /* x + y + w + h */);
1156 for (GLint j = 0; j < max_viewports; ++j)
1158 data[j * 4 + 0] = 0.0f;
1159 data[j * 4 + 1] = 0.0f;
1160 data[j * 4 + 2] = 1.0f;
1161 data[j * 4 + 3] = 1.0f;
1164 /* Set width to -1 */
1165 data[i * 4 + 2] = -1.0f;
1167 gl.viewportArrayv(0, max_viewports, &data[0]);
1168 checkGLError(GL_INVALID_VALUE, "viewportArrayv, negative width", test_result);
1170 gl.viewportIndexedf(i /* index */, 0.0f, 0.0f, -1.0f, 1.0f);
1171 checkGLError(GL_INVALID_VALUE, "viewportIndexedf, negative width", test_result);
1173 gl.viewportIndexedfv(i /* index */, &data[i * 4]);
1174 checkGLError(GL_INVALID_VALUE, "viewportIndexedfv, negative width", test_result);
1176 /* Set width to 1 and height to -1*/
1177 data[i * 4 + 2] = 1.0f;
1178 data[i * 4 + 3] = -1.0f;
1180 gl.viewportArrayv(0, max_viewports, &data[0]);
1181 checkGLError(GL_INVALID_VALUE, "viewportArrayv, negative height", test_result);
1183 gl.viewportIndexedf(i /* index */, 0.0f, 0.0f, 1.0f, -1.0f);
1184 checkGLError(GL_INVALID_VALUE, "viewportIndexedf, negative height", test_result);
1186 gl.viewportIndexedfv(i /* index */, &data[i * 4]);
1187 checkGLError(GL_INVALID_VALUE, "viewportIndexedfv, negative height", test_result);
1192 * * ScissorArrayv generates INVALID_VALUE when <first> + <count> is greater
1193 * than or equal to the value of MAX_VIEWPORTS;
1196 std::vector<GLint> data;
1197 data.resize(max_viewports * 4 /* x + y + w + h */);
1199 for (GLint i = 0; i < max_viewports; ++i)
1201 data[i * 4 + 0] = 0;
1202 data[i * 4 + 1] = 0;
1203 data[i * 4 + 2] = 1;
1204 data[i * 4 + 3] = 1;
1207 gl.scissorArrayv(0, max_viewports - 1, &data[0]);
1208 checkGLError(GL_NO_ERROR, "scissorArrayv, correct parameters", test_result);
1210 gl.scissorArrayv(max_viewports, 1, &data[0]);
1211 checkGLError(GL_INVALID_VALUE, "scissorArrayv, <first> == GL_MAX_VIEWPORTS", test_result);
1213 gl.scissorArrayv(1, max_viewports - 1, &data[0]);
1214 checkGLError(GL_NO_ERROR, "scissorArrayv, <first> + <count> == GL_MAX_VIEWPORTS", test_result);
1216 gl.scissorArrayv(1, max_viewports, &data[0]);
1217 checkGLError(GL_INVALID_VALUE, "scissorArrayv, <first> + <count> > GL_MAX_VIEWPORTS", test_result);
1221 * * ScissorIndexed and ScissorIndexedv generate INVALID_VALUE when <index> is
1222 * greater than or equal to the value of MAX_VIEWPORTS;
1225 GLint data[4 /* x + y + w + h */];
1232 gl.scissorIndexed(0 /* index */, 0, 0, 1, 1);
1233 checkGLError(GL_NO_ERROR, "scissorIndexed, <index> == 0", test_result);
1235 gl.scissorIndexed(max_viewports - 1 /* index */, 0, 0, 1, 1);
1236 checkGLError(GL_NO_ERROR, "scissorIndexed, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1238 gl.scissorIndexed(max_viewports /* index */, 0, 0, 1, 1);
1239 checkGLError(GL_INVALID_VALUE, "scissorIndexed, <index> == GL_MAX_VIEWPORTS", test_result);
1241 gl.scissorIndexed(max_viewports + 1 /* index */, 0, 0, 1, 1);
1242 checkGLError(GL_INVALID_VALUE, "scissorIndexed, <index> > GL_MAX_VIEWPORTS", test_result);
1244 gl.scissorIndexedv(0 /* index */, data);
1245 checkGLError(GL_NO_ERROR, "scissorIndexedv, <index> == 0", test_result);
1247 gl.scissorIndexedv(max_viewports - 1 /* index */, data);
1248 checkGLError(GL_NO_ERROR, "scissorIndexedv, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1250 gl.scissorIndexedv(max_viewports /* index */, data);
1251 checkGLError(GL_INVALID_VALUE, "scissorIndexedv, <index> == GL_MAX_VIEWPORTS", test_result);
1253 gl.scissorIndexedv(max_viewports + 1 /* index */, data);
1254 checkGLError(GL_INVALID_VALUE, "scissorIndexedv, <index> > GL_MAX_VIEWPORTS", test_result);
1258 * * ScissorArrayv, ScissorIndexed, ScissorIndexedv and Scissor generate
1259 * INVALID_VALUE when <width> or <height> values are negative;
1262 gl.scissor(0, 0, -1, 1);
1263 checkGLError(GL_INVALID_VALUE, "scissor, negative width", test_result);
1265 gl.scissor(0, 0, 1, -1);
1266 checkGLError(GL_INVALID_VALUE, "scissor, negative height", test_result);
1268 for (GLint i = 0; i < max_viewports; ++i)
1270 std::vector<GLint> data;
1271 data.resize(max_viewports * 4 /* x + y + w + h */);
1273 for (GLint j = 0; j < max_viewports; ++j)
1275 data[j * 4 + 0] = 0;
1276 data[j * 4 + 1] = 0;
1277 data[j * 4 + 2] = 1;
1278 data[j * 4 + 3] = 1;
1281 /* Set width to -1 */
1282 data[i * 4 + 2] = -1;
1284 gl.scissorArrayv(0, max_viewports, &data[0]);
1285 checkGLError(GL_INVALID_VALUE, "scissorArrayv, negative width", test_result);
1287 gl.scissorIndexed(i /* index */, 0, 0, -1, 1);
1288 checkGLError(GL_INVALID_VALUE, "scissorIndexed, negative width", test_result);
1290 gl.scissorIndexedv(i /* index */, &data[i * 4]);
1291 checkGLError(GL_INVALID_VALUE, "scissorIndexedv, negative width", test_result);
1293 /* Set width to 1 and height to -1*/
1294 data[i * 4 + 2] = 1;
1295 data[i * 4 + 3] = -1;
1297 gl.scissorArrayv(0, max_viewports, &data[0]);
1298 checkGLError(GL_INVALID_VALUE, "scissorArrayv, negative height", test_result);
1300 gl.scissorIndexed(i /* index */, 0, 0, 1, -1);
1301 checkGLError(GL_INVALID_VALUE, "scissorIndexed, negative height", test_result);
1303 gl.scissorIndexedv(i /* index */, &data[i * 4]);
1304 checkGLError(GL_INVALID_VALUE, "scissorIndexedv, negative height", test_result);
1309 * * Disablei, Enablei and IsEnabledi generate INVALID_VALUE when <cap> is
1310 * SCISSOR_TEST and <index> is greater than or equal to the
1311 * value of MAX_VIEWPORTS;
1314 gl.disablei(GL_SCISSOR_TEST, max_viewports - 1);
1315 checkGLError(GL_NO_ERROR, "disablei, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1317 gl.disablei(GL_SCISSOR_TEST, max_viewports);
1318 checkGLError(GL_INVALID_VALUE, "disablei, <index> == GL_MAX_VIEWPORTS", test_result);
1320 gl.enablei(GL_SCISSOR_TEST, max_viewports - 1);
1321 checkGLError(GL_NO_ERROR, "enablei, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1323 gl.enablei(GL_SCISSOR_TEST, max_viewports);
1324 checkGLError(GL_INVALID_VALUE, "enablei, <index> == GL_MAX_VIEWPORTS", test_result);
1326 gl.isEnabledi(GL_SCISSOR_TEST, max_viewports - 1);
1327 checkGLError(GL_NO_ERROR, "isEnabledi, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1329 gl.isEnabledi(GL_SCISSOR_TEST, max_viewports);
1330 checkGLError(GL_INVALID_VALUE, "isEnabledi, <index> == GL_MAX_VIEWPORTS", test_result);
1334 * * GetIntegeri_v generates INVALID_VALUE when <target> is SCISSOR_BOX and
1335 * <index> is greater than or equal to the value of MAX_VIEWPORTS;
1340 gl.getIntegeri_v(GL_SCISSOR_BOX, max_viewports - 1, data);
1341 checkGLError(GL_NO_ERROR, "getIntegeri_v, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1343 gl.getIntegeri_v(GL_SCISSOR_BOX, max_viewports, data);
1344 checkGLError(GL_INVALID_VALUE, "getIntegeri_v, <index> == GL_MAX_VIEWPORTS", test_result);
1348 * * GetFloati_v generates INVALID_VALUE when <target> is VIEWPORT and <index>
1349 * is greater than or equal to the value of MAX_VIEWPORTS;
1354 gl.getFloati_v(GL_VIEWPORT, max_viewports - 1, data);
1355 checkGLError(GL_NO_ERROR, "getFloati_v, <index> == GL_MAX_VIEWPORTS - 1", test_result);
1357 gl.getFloati_v(GL_VIEWPORT, max_viewports, data);
1358 checkGLError(GL_INVALID_VALUE, "getFloati_v, <index> == GL_MAX_VIEWPORTS", test_result);
1362 * * GetDoublei_v generates INVALID_VALUE when <target> is DEPTH_RANGE and
1363 * <index> is greater than or equal to the value of MAX_VIEWPORTS;
1365 if (glu::isContextTypeGLCore(context_type))
1367 getDepthHelper<GLdouble>(depthFunc, max_viewports, test_result);
1371 DE_ASSERT(glu::isContextTypeES(context_type));
1372 getDepthHelper<GLfloat>(depthFunc, max_viewports, test_result);
1376 if (true == test_result)
1378 m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Pass");
1382 m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1386 return tcu::TestNode::STOP;
1389 /** Check if glGetError returns expected error
1391 * @param expected_error Expected error code
1392 * @param description Description of test case
1393 * @param out_result Set to false if the current error is not equal to expected one
1395 void APIErrors::checkGLError(GLenum expected_error, const GLchar* description, bool& out_result)
1397 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1399 GLenum error = gl.getError();
1401 if (expected_error != error)
1403 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Test case fail. Description: " << description
1404 << " Invalid error: " << glu::getErrorStr(error)
1405 << " expected: " << glu::getErrorStr(expected_error)
1406 << tcu::TestLog::EndMessage;
1414 * @param context Test context
1416 Queries::Queries(deqp::Context& context, const glcts::ExtParameters& extParams)
1417 : TestCaseBase(context, extParams, "queries", "Test verifies initial state of API")
1419 /* Nothing to be done here */
1422 template <typename T>
1423 void Queries::depthRangeInitialValuesHelper(Utils::DepthFuncWrapper& depthFunc, GLint max_viewports, bool& test_result,
1426 std::vector<T> data;
1427 data.resize(max_viewports * 2 /* near + far */);
1429 for (GLint i = 0; i < max_viewports; ++i)
1431 depthFunc.getDepthi_v(GL_DEPTH_RANGE, i, &data[i * 2]);
1432 GLU_EXPECT_NO_ERROR(depthFunc.getFunctions().getError(), "getDouble/Floati_v");
1435 for (GLint i = 0; i < max_viewports; ++i)
1437 GLint near = (GLint)data[2 * i + 0];
1438 GLint far = (GLint)data[2 * i + 1];
1440 if ((0.0 != near) || (1.0 != far))
1442 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Invalid initial depth range [" << i
1443 << "]: " << near << " : " << far << " expected: 0.0 : 1.0"
1444 << tcu::TestLog::EndMessage;
1446 test_result = false;
1453 * @return tcu::TestNode::CONTINUE after executing test case, tcu::TestNode::STOP otherwise
1455 tcu::TestNode::IterateResult Queries::iterate()
1457 if (!m_is_viewport_array_supported)
1459 throw tcu::NotSupportedError(VIEWPORT_ARRAY_NOT_SUPPORTED, "", __FILE__, __LINE__);
1462 /* GL entry points */
1463 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1464 const glu::ContextType& context_type = m_context.getRenderContext().getType();
1465 Utils::DepthFuncWrapper depthFunc(m_context);
1468 bool test_result = true;
1470 GLint layer_provoking_vertex = 0;
1471 GLint max_viewports = 0;
1472 GLfloat max_renderbuffer_size = 0.0f;
1473 GLfloat max_viewport_dims[2] = { 0.0f, 0.0f };
1474 GLfloat viewport_bounds_range[2] = { 0.0, 0.0f };
1475 GLint viewport_provoking_vertex = 0;
1476 GLint viewport_subpixel_bits = -1;
1478 gl.getIntegerv(GL_LAYER_PROVOKING_VERTEX, &layer_provoking_vertex);
1479 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
1481 gl.getIntegerv(GL_MAX_VIEWPORTS, &max_viewports);
1482 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
1484 gl.getFloatv(GL_MAX_RENDERBUFFER_SIZE, &max_renderbuffer_size);
1485 GLU_EXPECT_NO_ERROR(gl.getError(), "getFloatv");
1487 gl.getFloatv(GL_MAX_VIEWPORT_DIMS, max_viewport_dims);
1488 GLU_EXPECT_NO_ERROR(gl.getError(), "GetFloatv");
1490 gl.getFloatv(GL_VIEWPORT_BOUNDS_RANGE, viewport_bounds_range);
1491 GLU_EXPECT_NO_ERROR(gl.getError(), "GetFloatv");
1493 gl.getIntegerv(GL_VIEWPORT_INDEX_PROVOKING_VERTEX, &viewport_provoking_vertex);
1494 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
1496 gl.getIntegerv(GL_VIEWPORT_SUBPIXEL_BITS, &viewport_subpixel_bits);
1497 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
1499 const GLint window_width = m_context.getRenderContext().getRenderTarget().getWidth();
1500 const GLint window_height = m_context.getRenderContext().getRenderTarget().getHeight();
1503 * * Initial dimensions of VIEWPORT returned by GetFloati_v match dimensions of
1504 * the window into which GL is rendering;
1507 std::vector<GLfloat> data;
1508 data.resize(max_viewports * 4 /* x + y + w+ h */);
1510 for (GLint i = 0; i < max_viewports; ++i)
1512 gl.getFloati_v(GL_VIEWPORT, i, &data[i * 4]);
1513 GLU_EXPECT_NO_ERROR(gl.getError(), "GetFloati_v");
1516 for (GLint i = 0; i < max_viewports; ++i)
1518 GLint viewport_width = (GLint)data[4 * i + 2];
1519 GLint viewport_height = (GLint)data[4 * i + 3];
1521 if ((window_width != viewport_width) || (window_height != viewport_height))
1523 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Invalid initial viewport [" << i
1524 << "] dimennsions: " << viewport_width << " x " << viewport_height
1525 << " expected: " << window_width << " x " << window_height
1526 << tcu::TestLog::EndMessage;
1528 test_result = false;
1535 * * Initial values of DEPTH_RANGE returned by GetDoublei_v are [0, 1];
1537 if (glu::isContextTypeGLCore(context_type))
1539 depthRangeInitialValuesHelper<GLdouble>(depthFunc, max_viewports, test_result);
1543 DE_ASSERT(glu::isContextTypeES(context_type));
1544 depthRangeInitialValuesHelper<GLfloat>(depthFunc, max_viewports, test_result);
1548 * * Initial state of SCISSOR_TEST returned by IsEnabledi is FALSE;
1551 for (GLint i = 0; i < max_viewports; ++i)
1553 if (GL_FALSE != gl.isEnabledi(GL_SCISSOR_TEST, i))
1555 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Scissor test is enabled at " << i
1556 << ". Expected disabled." << tcu::TestLog::EndMessage;
1558 test_result = false;
1565 * * Initial dimensions of SCISSOR_BOX returned by GetIntegeri_v are either
1566 * zeros or match dimensions of the window into which GL is rendering;
1569 std::vector<GLint> data;
1570 data.resize(max_viewports * 4 /* x + y + w+ h */);
1572 for (GLint i = 0; i < max_viewports; ++i)
1574 gl.getIntegeri_v(GL_SCISSOR_BOX, i, &data[i * 4]);
1575 GLU_EXPECT_NO_ERROR(gl.getError(), "getIntegeri_v");
1578 for (GLint i = 0; i < max_viewports; ++i)
1580 GLint scissor_width = data[4 * i + 2];
1581 GLint scissor_height = data[4 * i + 3];
1583 if ((window_width != scissor_width) || (window_height != scissor_height))
1585 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Invalid initial scissor box [" << i
1586 << "] dimennsions: " << scissor_width << " x " << scissor_height
1587 << " expected: " << window_width << " x " << window_height
1588 << tcu::TestLog::EndMessage;
1590 test_result = false;
1597 * * Dimensions of MAX_VIEWPORT_DIMS returned by GetFloati_v are at least
1598 * as big as supported dimensions of render buffers, see MAX_RENDERBUFFER_SIZE;
1601 if ((max_viewport_dims[0] < max_renderbuffer_size) || (max_viewport_dims[1] < max_renderbuffer_size))
1603 m_context.getTestContext().getLog()
1604 << tcu::TestLog::Message << "Invalid MAX_VIEWPORT_DIMS: " << max_viewport_dims[0] << " x "
1605 << max_viewport_dims[1] << " expected: " << max_renderbuffer_size << " x " << max_renderbuffer_size
1606 << tcu::TestLog::EndMessage;
1608 test_result = false;
1613 * * Value of MAX_VIEWPORTS returned by GetIntegeri_v is at least 16;
1616 if (16 > max_viewports)
1618 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Invalid MAX_VIEWPORTS: " << max_viewports
1619 << " expected at least 16." << tcu::TestLog::EndMessage;
1621 test_result = false;
1626 * * Value of VIEWPORT_SUBPIXEL_BITS returned by GetIntegeri_v is at least 0;
1629 if (0 > viewport_subpixel_bits)
1631 m_context.getTestContext().getLog() << tcu::TestLog::Message
1632 << "Invalid VIEWPORT_SUBPIXEL_BITS: " << viewport_subpixel_bits
1633 << " expected at least 0." << tcu::TestLog::EndMessage;
1635 test_result = false;
1640 * * Values of VIEWPORT_BOUNDS_RANGE returned by GetFloatv are
1641 * at least [-32768, 32767];
1644 if ((-32768.0f < viewport_bounds_range[0]) || (32767.0f > viewport_bounds_range[1]))
1646 m_context.getTestContext().getLog()
1647 << tcu::TestLog::Message << "Invalid VIEWPORT_BOUNDS_RANGE: " << viewport_bounds_range[0] << " : "
1648 << viewport_bounds_range[1] << " expected at least: -32768.0f : 32767.0f" << tcu::TestLog::EndMessage;
1650 test_result = false;
1655 * * Values of LAYER_PROVOKING_VERTEX and VIEWPORT_INDEX_PROVOKING_VERTEX
1656 * returned by GetIntegerv are located in the following set
1657 * { FIRST_VERTEX_CONVENTION, LAST_VERTEX_CONVENTION, PROVOKING_VERTEX,
1658 * UNDEFINED_VERTEX };
1661 switch (layer_provoking_vertex)
1663 case GL_FIRST_VERTEX_CONVENTION:
1664 case GL_LAST_VERTEX_CONVENTION:
1665 case GL_PROVOKING_VERTEX:
1666 case GL_UNDEFINED_VERTEX:
1669 m_context.getTestContext().getLog() << tcu::TestLog::Message
1670 << "Invalid LAYER_PROVOKING_VERTEX: " << layer_provoking_vertex
1671 << tcu::TestLog::EndMessage;
1673 test_result = false;
1676 switch (viewport_provoking_vertex)
1678 case GL_FIRST_VERTEX_CONVENTION:
1679 case GL_LAST_VERTEX_CONVENTION:
1680 case GL_PROVOKING_VERTEX:
1681 case GL_UNDEFINED_VERTEX:
1684 m_context.getTestContext().getLog() << tcu::TestLog::Message
1685 << "Invalid LAYER_PROVOKING_VERTEX: " << layer_provoking_vertex
1686 << tcu::TestLog::EndMessage;
1688 test_result = false;
1693 if (true == test_result)
1695 m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Pass");
1699 m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1703 return tcu::TestNode::STOP;
1706 /* Constants used by ViewportAPI */
1707 const GLuint ViewportAPI::m_n_elements = 4;
1711 * @param context Test context
1713 ViewportAPI::ViewportAPI(deqp::Context& context, const glcts::ExtParameters& extParams)
1714 : TestCaseBase(context, extParams, "viewport_api", "Test verifies that \viewport api\" works as expected")
1716 /* Nothing to be done here */
1721 * @return tcu::TestNode::CONTINUE after executing test case, tcu::TestNode::STOP otherwise
1723 tcu::TestNode::IterateResult ViewportAPI::iterate()
1725 if (!m_is_viewport_array_supported)
1727 throw tcu::NotSupportedError(VIEWPORT_ARRAY_NOT_SUPPORTED, "", __FILE__, __LINE__);
1730 /* GL entry points */
1731 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1734 bool test_result = true;
1736 GLint max_viewports = 0;
1738 gl.getIntegerv(GL_MAX_VIEWPORTS, &max_viewports);
1739 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
1741 std::vector<GLfloat> scissor_box_data_a;
1742 std::vector<GLfloat> scissor_box_data_b;
1744 scissor_box_data_a.resize(max_viewports * m_n_elements);
1745 scissor_box_data_b.resize(max_viewports * m_n_elements);
1748 * - get initial dimensions of VIEWPORT for all MAX_VIEWPORTS indices;
1749 * - change location and dimensions of all indices at once with
1751 * - get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
1753 getViewports(max_viewports, scissor_box_data_a);
1755 for (GLint i = 0; i < max_viewports; ++i)
1757 scissor_box_data_a[i * m_n_elements + 0] += 0.125f;
1758 scissor_box_data_a[i * m_n_elements + 1] += 0.125f;
1759 scissor_box_data_a[i * m_n_elements + 2] -= 0.125f;
1760 scissor_box_data_a[i * m_n_elements + 3] -= 0.125f;
1763 gl.viewportArrayv(0, max_viewports, &scissor_box_data_a[0]);
1764 GLU_EXPECT_NO_ERROR(gl.getError(), "viewportArrayv");
1766 getViewports(max_viewports, scissor_box_data_b);
1767 compareViewports(scissor_box_data_a, scissor_box_data_b, "viewportArrayv", test_result);
1771 * * modify with ViewportIndexedf,
1772 * * get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
1774 for (GLint i = 0; i < max_viewports; ++i)
1776 scissor_box_data_b[i * m_n_elements + 0] = 0.25f;
1777 scissor_box_data_b[i * m_n_elements + 1] = 0.25f;
1778 scissor_box_data_b[i * m_n_elements + 2] = 0.75f;
1779 scissor_box_data_b[i * m_n_elements + 3] = 0.75f;
1781 gl.viewportIndexedf(i, 0.25f, 0.25f, 0.75f, 0.75f);
1782 GLU_EXPECT_NO_ERROR(gl.getError(), "viewportIndexedf");
1784 getViewports(max_viewports, scissor_box_data_a);
1785 compareViewports(scissor_box_data_a, scissor_box_data_b, "viewportIndexedf", test_result);
1790 * * modify with ViewportIndexedfv,
1791 * * get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
1793 for (GLint i = 0; i < max_viewports; ++i)
1795 scissor_box_data_a[i * m_n_elements + 0] = 0.375f;
1796 scissor_box_data_a[i * m_n_elements + 1] = 0.375f;
1797 scissor_box_data_a[i * m_n_elements + 2] = 0.625f;
1798 scissor_box_data_a[i * m_n_elements + 3] = 0.625f;
1800 gl.viewportIndexedfv(i, &scissor_box_data_a[i * m_n_elements]);
1801 GLU_EXPECT_NO_ERROR(gl.getError(), "viewportIndexedfv");
1803 getViewports(max_viewports, scissor_box_data_b);
1804 compareViewports(scissor_box_data_a, scissor_box_data_b, "viewportIndexedfv", test_result);
1809 * * modify all indices before and after current one with ViewportArrayv,
1810 * * get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
1812 for (GLint i = 0; i < max_viewports; ++i)
1814 const GLfloat value = (0 == i % 2) ? 1.0f : 0.25f;
1816 for (GLint j = 0; j < i; ++j)
1818 scissor_box_data_b[j * m_n_elements + 0] = value;
1819 scissor_box_data_b[j * m_n_elements + 1] = value;
1820 scissor_box_data_b[j * m_n_elements + 2] = value;
1821 scissor_box_data_b[j * m_n_elements + 3] = value;
1824 for (GLint j = i + 1; j < max_viewports; ++j)
1826 scissor_box_data_b[j * m_n_elements + 0] = value;
1827 scissor_box_data_b[j * m_n_elements + 1] = value;
1828 scissor_box_data_b[j * m_n_elements + 2] = value;
1829 scissor_box_data_b[j * m_n_elements + 3] = value;
1832 gl.viewportArrayv(0, max_viewports, &scissor_box_data_b[0]);
1833 GLU_EXPECT_NO_ERROR(gl.getError(), "viewportArrayv");
1835 getViewports(max_viewports, scissor_box_data_a);
1836 compareViewports(scissor_box_data_a, scissor_box_data_b, "viewportArrayv", test_result);
1840 * - change location and dimensions of all indices at once with Viewport;
1841 * - get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
1843 for (GLint i = 0; i < max_viewports; ++i)
1845 scissor_box_data_a[i * m_n_elements + 0] = 0.0f;
1846 scissor_box_data_a[i * m_n_elements + 1] = 0.0f;
1847 scissor_box_data_a[i * m_n_elements + 2] = 1.0f;
1848 scissor_box_data_a[i * m_n_elements + 3] = 1.0f;
1851 gl.viewport(0, 0, 1, 1);
1852 GLU_EXPECT_NO_ERROR(gl.getError(), "viewport");
1854 getViewports(max_viewports, scissor_box_data_b);
1855 compareViewports(scissor_box_data_a, scissor_box_data_b, "viewport", test_result);
1858 if (true == test_result)
1860 m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Pass");
1864 m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Fail");
1868 return tcu::TestNode::STOP;
1871 /** Compare two sets of viewport data (simple vector comparison)
1873 * @param left Left set
1874 * @param right Right set
1875 * @param description Test case description
1876 * @param out_result Set to false if sets are different, not modified otherwise
1878 void ViewportAPI::compareViewports(std::vector<GLfloat>& left, std::vector<GLfloat>& right, const GLchar* description,
1881 for (size_t i = 0; i < left.size(); ++i)
1883 if (left[i] != right[i])
1885 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Test case: " << description
1886 << " Invalid values [" << i << "] " << left[i] << " " << right[i]
1887 << tcu::TestLog::EndMessage;
1894 /** Get position of all viewports
1896 * @param max_viewports Number of viewports to capture, MAX_VIEWPORTS
1897 * @param data Memory buffer prepared for captured data
1899 void ViewportAPI::getViewports(GLint max_viewports, std::vector<GLfloat>& out_data)
1901 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1903 for (GLint i = 0; i < max_viewports; ++i)
1905 gl.getFloati_v(GL_VIEWPORT, i, &out_data[i * 4]);
1906 GLU_EXPECT_NO_ERROR(gl.getError(), "getFloati_v");
1910 /* Constants used by ScissorAPI */
1911 const GLuint ScissorAPI::m_n_elements = 4;
1915 * @param context Test context
1917 ScissorAPI::ScissorAPI(deqp::Context& context, const glcts::ExtParameters& extParams)
1918 : TestCaseBase(context, extParams, "scissor_api", "Test verifies that \"scissor api\" works as expected")
1920 /* Nothing to be done here */
1925 * @return tcu::TestNode::CONTINUE after executing test case, tcu::TestNode::STOP otherwise
1927 tcu::TestNode::IterateResult ScissorAPI::iterate()
1929 if (!m_is_viewport_array_supported)
1931 throw tcu::NotSupportedError(VIEWPORT_ARRAY_NOT_SUPPORTED, "", __FILE__, __LINE__);
1934 /* GL entry points */
1935 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
1938 bool test_result = true;
1940 GLint max_viewports = 0;
1942 gl.getIntegerv(GL_MAX_VIEWPORTS, &max_viewports);
1943 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
1945 std::vector<GLint> scissor_box_data_a;
1946 std::vector<GLint> scissor_box_data_b;
1948 scissor_box_data_a.resize(max_viewports * m_n_elements);
1949 scissor_box_data_b.resize(max_viewports * m_n_elements);
1952 * - get initial dimensions of SCISSOR_BOX for all MAX_VIEWPORTS indices;
1953 * - change location and dimensions of all indices at once with
1955 * - get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
1957 getScissorBoxes(max_viewports, scissor_box_data_a);
1959 for (GLint i = 0; i < max_viewports; ++i)
1961 scissor_box_data_a[i * m_n_elements + 0] += 1;
1962 scissor_box_data_a[i * m_n_elements + 1] += 1;
1963 scissor_box_data_a[i * m_n_elements + 2] -= 1;
1964 scissor_box_data_a[i * m_n_elements + 3] -= 1;
1967 gl.scissorArrayv(0, max_viewports, &scissor_box_data_a[0]);
1968 GLU_EXPECT_NO_ERROR(gl.getError(), "scissorArrayv");
1970 getScissorBoxes(max_viewports, scissor_box_data_b);
1971 compareScissorBoxes(scissor_box_data_a, scissor_box_data_b, "scissorArrayv", test_result);
1975 * * modify with ScissorIndexed,
1976 * * get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
1978 for (GLint i = 0; i < max_viewports; ++i)
1980 scissor_box_data_b[i * m_n_elements + 0] = 4;
1981 scissor_box_data_b[i * m_n_elements + 1] = 4;
1982 scissor_box_data_b[i * m_n_elements + 2] = 8;
1983 scissor_box_data_b[i * m_n_elements + 3] = 8;
1985 gl.scissorIndexed(i, 4, 4, 8, 8);
1986 GLU_EXPECT_NO_ERROR(gl.getError(), "scissorIndexed");
1988 getScissorBoxes(max_viewports, scissor_box_data_a);
1989 compareScissorBoxes(scissor_box_data_a, scissor_box_data_b, "scissorIndexed", test_result);
1994 * * modify with ScissorIndexedv,
1995 * * get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
1997 for (GLint i = 0; i < max_viewports; ++i)
1999 scissor_box_data_a[i * m_n_elements + 0] = 8;
2000 scissor_box_data_a[i * m_n_elements + 1] = 8;
2001 scissor_box_data_a[i * m_n_elements + 2] = 12;
2002 scissor_box_data_a[i * m_n_elements + 3] = 12;
2004 gl.scissorIndexedv(i, &scissor_box_data_a[i * m_n_elements]);
2005 GLU_EXPECT_NO_ERROR(gl.getError(), "scissorIndexedv");
2007 getScissorBoxes(max_viewports, scissor_box_data_b);
2008 compareScissorBoxes(scissor_box_data_a, scissor_box_data_b, "scissorIndexedv", test_result);
2013 * * modify all indices before and after current one with ScissorArrayv,
2014 * * get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
2016 for (GLint i = 0; i < max_viewports; ++i)
2018 const GLint value = (0 == i % 2) ? 1 : 4;
2020 for (GLint j = 0; j < i; ++j)
2022 scissor_box_data_b[j * m_n_elements + 0] = value;
2023 scissor_box_data_b[j * m_n_elements + 1] = value;
2024 scissor_box_data_b[j * m_n_elements + 2] = value;
2025 scissor_box_data_b[j * m_n_elements + 3] = value;
2028 for (GLint j = i + 1; j < max_viewports; ++j)
2030 scissor_box_data_b[j * m_n_elements + 0] = value;
2031 scissor_box_data_b[j * m_n_elements + 1] = value;
2032 scissor_box_data_b[j * m_n_elements + 2] = value;
2033 scissor_box_data_b[j * m_n_elements + 3] = value;
2036 gl.scissorArrayv(0, max_viewports, &scissor_box_data_b[0]);
2037 GLU_EXPECT_NO_ERROR(gl.getError(), "scissorArrayv");
2039 getScissorBoxes(max_viewports, scissor_box_data_a);
2040 compareScissorBoxes(scissor_box_data_a, scissor_box_data_b, "scissorArrayv", test_result);
2044 * - change location and dimensions of all indices at once with Scissor;
2045 * - get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
2047 for (GLint i = 0; i < max_viewports; ++i)
2049 scissor_box_data_a[i * m_n_elements + 0] = 0;
2050 scissor_box_data_a[i * m_n_elements + 1] = 0;
2051 scissor_box_data_a[i * m_n_elements + 2] = 1;
2052 scissor_box_data_a[i * m_n_elements + 3] = 1;
2055 gl.scissor(0, 0, 1, 1);
2056 GLU_EXPECT_NO_ERROR(gl.getError(), "scissor");
2058 getScissorBoxes(max_viewports, scissor_box_data_b);
2059 compareScissorBoxes(scissor_box_data_a, scissor_box_data_b, "scissor", test_result);
2062 if (true == test_result)
2064 m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Pass");
2068 m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2072 return tcu::TestNode::STOP;
2075 /** Compare two sets of scissor box data (simple vector comparison)
2077 * @param left Left set
2078 * @param right Right set
2079 * @param description Test case description
2080 * @param out_result Set to false if sets are different, not modified otherwise
2082 void ScissorAPI::compareScissorBoxes(std::vector<GLint>& left, std::vector<GLint>& right, const GLchar* description,
2085 for (size_t i = 0; i < left.size(); ++i)
2087 if (left[i] != right[i])
2089 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Test case: " << description
2090 << " Invalid values [" << i << "] " << left[i] << " " << right[i]
2091 << tcu::TestLog::EndMessage;
2098 /** Get position of all scissor boxes
2100 * @param max_viewports Number of scissor boxes to capture, MAX_VIEWPORTS
2101 * @param data Memory buffer prepared for captured data
2103 void ScissorAPI::getScissorBoxes(GLint max_viewports, std::vector<GLint>& out_data)
2105 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2107 for (GLint i = 0; i < max_viewports; ++i)
2109 gl.getIntegeri_v(GL_SCISSOR_BOX, i, &out_data[i * 4]);
2110 GLU_EXPECT_NO_ERROR(gl.getError(), "getIntegeri_v");
2114 /* Constants used by DepthRangeAPI */
2115 const GLuint DepthRangeAPI::m_n_elements = 2 /* near + far */;
2119 * @param context Test context
2121 DepthRangeAPI::DepthRangeAPI(deqp::Context& context, const glcts::ExtParameters& extParams)
2122 : TestCaseBase(context, extParams, "depth_range_api", "Test verifies that \"depth range api\" works as expected")
2124 /* Nothing to be done here */
2129 * @return tcu::TestNode::CONTINUE after executing test case, tcu::TestNode::STOP otherwise
2131 tcu::TestNode::IterateResult DepthRangeAPI::iterate()
2133 if (!m_is_viewport_array_supported)
2135 throw tcu::NotSupportedError(VIEWPORT_ARRAY_NOT_SUPPORTED, "", __FILE__, __LINE__);
2139 const glu::ContextType& context_type = m_context.getRenderContext().getType();
2141 if (glu::isContextTypeGLCore(context_type))
2143 test_result = iterateHelper<GLdouble>();
2147 DE_ASSERT(glu::isContextTypeES(context_type));
2148 test_result = iterateHelper<GLfloat>();
2152 if (true == test_result)
2154 m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Pass");
2158 m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2162 return tcu::TestNode::STOP;
2165 template <typename T>
2166 bool DepthRangeAPI::iterateHelper(T*)
2168 /* GL entry points */
2169 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2170 Utils::DepthFuncWrapper depthFunc(m_context);
2172 bool test_result = true;
2174 GLint max_viewports = 0;
2176 gl.getIntegerv(GL_MAX_VIEWPORTS, &max_viewports);
2177 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
2179 std::vector<T> depth_range_data_a;
2180 std::vector<T> depth_range_data_b;
2182 depth_range_data_a.resize(max_viewports * m_n_elements);
2183 depth_range_data_b.resize(max_viewports * m_n_elements);
2186 * - get initial values of DEPTH_RANGE for all MAX_VIEWPORTS indices;
2187 * - change values of all indices at once with DepthRangeArrayv;
2188 * - get DEPTH_RANGE for all MAX_VIEWPORTS indices and verify results;
2190 getDepthRanges(depthFunc, max_viewports, depth_range_data_a);
2192 for (GLint i = 0; i < max_viewports; ++i)
2194 depth_range_data_a[i * m_n_elements + 0] += 0.125;
2195 depth_range_data_a[i * m_n_elements + 1] -= 0.125;
2198 depthFunc.depthRangeArray(0, max_viewports, &depth_range_data_a[0]);
2199 GLU_EXPECT_NO_ERROR(gl.getError(), "depthRangeArray");
2201 getDepthRanges(depthFunc, max_viewports, depth_range_data_b);
2202 compareDepthRanges(depth_range_data_a, depth_range_data_b, "depthRangeArray", test_result);
2206 * * modify with DepthRangeIndexed,
2207 * * get DEPTH_RANGE for all MAX_VIEWPORTS indices and verify results;
2209 for (GLint i = 0; i < max_viewports; ++i)
2211 depth_range_data_b[i * m_n_elements + 0] = 0.25;
2212 depth_range_data_b[i * m_n_elements + 1] = 0.75;
2214 depthFunc.depthRangeIndexed(i, (T)0.25, (T)0.75);
2215 GLU_EXPECT_NO_ERROR(gl.getError(), "depthRangeIndexed");
2217 getDepthRanges(depthFunc, max_viewports, depth_range_data_a);
2218 compareDepthRanges(depth_range_data_a, depth_range_data_b, "depthRangeIndexed", test_result);
2223 * * modify all indices before and after current one with DepthRangeArrayv,
2224 * * get DEPTH_RANGE for all MAX_VIEWPORTS indices and verify results;
2226 for (GLint i = 0; i < max_viewports; ++i)
2228 const T value = (0 == i % 2) ? T(1.0) : T(0.25);
2230 for (GLint j = 0; j < i; ++j)
2232 depth_range_data_b[j * m_n_elements + 0] = value;
2233 depth_range_data_b[j * m_n_elements + 1] = value;
2236 for (GLint j = i + 1; j < max_viewports; ++j)
2238 depth_range_data_b[j * m_n_elements + 0] = value;
2239 depth_range_data_b[j * m_n_elements + 1] = value;
2242 depthFunc.depthRangeArray(0, max_viewports, &depth_range_data_b[0]);
2243 GLU_EXPECT_NO_ERROR(gl.getError(), "depthRangeArray");
2245 getDepthRanges(depthFunc, max_viewports, depth_range_data_a);
2246 compareDepthRanges(depth_range_data_a, depth_range_data_b, "depthRangeArray", test_result);
2250 * - change values of all indices at once with DepthRange;
2251 * - get DEPTH_RANGE for all MAX_VIEWPORTS indices and verify results;
2253 for (GLint i = 0; i < max_viewports; ++i)
2255 depth_range_data_a[i * m_n_elements + 0] = 0.0f;
2256 depth_range_data_a[i * m_n_elements + 1] = 1.0f;
2259 depthFunc.depthRange((T)0.0, (T)1.0);
2260 GLU_EXPECT_NO_ERROR(gl.getError(), "depthRange");
2262 getDepthRanges(depthFunc, max_viewports, depth_range_data_b);
2263 compareDepthRanges(depth_range_data_a, depth_range_data_b, "depthRange", test_result);
2268 /** Compare two sets of depth range data (simple vector comparison)
2270 * @param left Left set
2271 * @param right Right set
2272 * @param description Test case description
2273 * @param out_result Set to false if sets are different, not modified otherwise
2275 template <typename T>
2276 void DepthRangeAPI::compareDepthRanges(std::vector<T>& left, std::vector<T>& right, const GLchar* description,
2279 for (size_t i = 0; i < left.size(); ++i)
2281 if (left[i] != right[i])
2283 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Test case: " << description
2284 << " Invalid values [" << i << "] " << left[i] << " " << right[i]
2285 << tcu::TestLog::EndMessage;
2291 /** Get all depth ranges
2293 * @param max_viewports Number of viewports to capture, MAX_VIEWPORTS
2294 * @param data Memory buffer prepared for captured data
2296 template <typename T>
2297 void DepthRangeAPI::getDepthRanges(Utils::DepthFuncWrapper& depthFunc, GLint max_viewports, std::vector<T>& out_data)
2299 for (GLint i = 0; i < max_viewports; ++i)
2301 depthFunc.getDepthi_v(GL_DEPTH_RANGE, i, &out_data[i * m_n_elements]);
2302 GLU_EXPECT_NO_ERROR(depthFunc.getFunctions().getError(), "getDouble/Floati_v");
2308 * @param context Test context
2310 ScissorTestStateAPI::ScissorTestStateAPI(deqp::Context& context, const glcts::ExtParameters& extParams)
2311 : TestCaseBase(context, extParams, "scissor_test_state_api",
2312 "Test verifies that \"enable/disable api\" works as expected for scissor test")
2314 /* Nothing to be done here */
2319 * @return tcu::TestNode::CONTINUE after executing test case, tcu::TestNode::STOP otherwise
2321 tcu::TestNode::IterateResult ScissorTestStateAPI::iterate()
2323 if (!m_is_viewport_array_supported)
2325 throw tcu::NotSupportedError(VIEWPORT_ARRAY_NOT_SUPPORTED, "", __FILE__, __LINE__);
2328 /* GL entry points */
2329 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2332 bool test_result = true;
2334 GLint max_viewports = 0;
2336 gl.getIntegerv(GL_MAX_VIEWPORTS, &max_viewports);
2337 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
2339 std::vector<GLboolean> scissor_test_states_a;
2340 std::vector<GLboolean> scissor_test_states_b;
2342 scissor_test_states_a.resize(max_viewports);
2343 scissor_test_states_b.resize(max_viewports);
2346 * - get initial state of SCISSOR_TEST for all MAX_VIEWPORTS indices;
2348 * * toggle SCISSOR_TEST,
2349 * * get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
2351 * * toggle SCISSOR_TEST,
2352 * * get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
2354 getScissorTestStates(max_viewports, scissor_test_states_a);
2356 for (GLint i = 0; i < max_viewports; ++i)
2358 if (GL_FALSE == scissor_test_states_a[i])
2360 gl.enablei(GL_SCISSOR_TEST, i);
2361 GLU_EXPECT_NO_ERROR(gl.getError(), "Enablei");
2363 scissor_test_states_a[i] = GL_TRUE;
2367 gl.disablei(GL_SCISSOR_TEST, i);
2368 GLU_EXPECT_NO_ERROR(gl.getError(), "Disablei");
2370 scissor_test_states_a[i] = GL_FALSE;
2373 getScissorTestStates(max_viewports, scissor_test_states_b);
2374 compareScissorTestStates(scissor_test_states_a, scissor_test_states_b, "1st toggle", test_result);
2377 for (GLint i = 0; i < max_viewports; ++i)
2379 if (GL_FALSE == scissor_test_states_a[i])
2381 gl.enablei(GL_SCISSOR_TEST, i);
2382 GLU_EXPECT_NO_ERROR(gl.getError(), "Enablei");
2384 scissor_test_states_a[i] = GL_TRUE;
2388 gl.disablei(GL_SCISSOR_TEST, i);
2389 GLU_EXPECT_NO_ERROR(gl.getError(), "Disablei");
2391 scissor_test_states_a[i] = GL_FALSE;
2394 getScissorTestStates(max_viewports, scissor_test_states_b);
2395 compareScissorTestStates(scissor_test_states_a, scissor_test_states_b, "2nd toggle", test_result);
2399 * - enable SCISSOR_TEST for all indices at once with Enable;
2400 * - get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
2402 for (GLint i = 0; i < max_viewports; ++i)
2404 scissor_test_states_a[i] = GL_TRUE;
2407 gl.enable(GL_SCISSOR_TEST);
2408 GLU_EXPECT_NO_ERROR(gl.getError(), "Enable");
2410 getScissorTestStates(max_viewports, scissor_test_states_b);
2411 compareScissorTestStates(scissor_test_states_a, scissor_test_states_b, "1st enable all", test_result);
2414 * - disable SCISSOR_TEST for all indices at once with Disable;
2415 * - get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
2417 for (GLint i = 0; i < max_viewports; ++i)
2419 scissor_test_states_a[i] = GL_FALSE;
2422 gl.disable(GL_SCISSOR_TEST);
2423 GLU_EXPECT_NO_ERROR(gl.getError(), "Disable");
2425 getScissorTestStates(max_viewports, scissor_test_states_b);
2426 compareScissorTestStates(scissor_test_states_a, scissor_test_states_b, "Disable all", test_result);
2429 * - enable SCISSOR_TEST for all indices at once with Enable;
2430 * - get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
2432 for (GLint i = 0; i < max_viewports; ++i)
2434 scissor_test_states_a[i] = GL_TRUE;
2437 gl.enable(GL_SCISSOR_TEST);
2438 GLU_EXPECT_NO_ERROR(gl.getError(), "Enable");
2440 getScissorTestStates(max_viewports, scissor_test_states_b);
2441 compareScissorTestStates(scissor_test_states_a, scissor_test_states_b, "2nd enable all", test_result);
2444 if (true == test_result)
2446 m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Pass");
2450 m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2454 return tcu::TestNode::STOP;
2457 /** Compare two sets of depth range data (simple vector comparison)
2459 * @param left Left set
2460 * @param right Right set
2461 * @param description Test case description
2462 * @param out_result Set to false if sets are different, not modified otherwise
2464 void ScissorTestStateAPI::compareScissorTestStates(std::vector<GLboolean>& left, std::vector<GLboolean>& right,
2465 const GLchar* description, bool& out_result)
2467 for (size_t i = 0; i < left.size(); ++i)
2469 if (left[i] != right[i])
2471 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Test case: " << description
2472 << " Invalid values [" << i << "] " << left[i] << " " << right[i]
2473 << tcu::TestLog::EndMessage;
2480 /** Get all depth ranges
2482 * @param max_viewports Number of viewports to capture, MAX_VIEWPORTS
2483 * @param data Memory buffer prepared for captured data
2485 void ScissorTestStateAPI::getScissorTestStates(GLint max_viewports, std::vector<GLboolean>& out_data)
2487 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2489 for (GLint i = 0; i < max_viewports; ++i)
2491 out_data[i] = gl.isEnabledi(GL_SCISSOR_TEST, i);
2492 GLU_EXPECT_NO_ERROR(gl.getError(), "isEnabledi");
2496 /* Constants used by DrawTestBase */
2497 const GLuint DrawTestBase::m_depth = 16;
2498 const GLuint DrawTestBase::m_height = 128;
2499 const GLuint DrawTestBase::m_width = 128;
2500 const GLuint DrawTestBase::m_r32f_height = 2;
2501 const GLuint DrawTestBase::m_r32f_width = 16;
2502 const GLuint DrawTestBase::m_r32ix4_depth = 4;
2506 * @param context Test context
2507 * @param test_name Test name
2508 * @param test_description Test description
2510 DrawTestBase::DrawTestBase(deqp::Context& context, const glcts::ExtParameters& extParams, const GLchar* test_name,
2511 const GLchar* test_description)
2512 : TestCaseBase(context, extParams, test_name, test_description)
2514 /* Nothing to be done here */
2519 * @return tcu::TestNode::CONTINUE after executing test case, tcu::TestNode::STOP otherwise
2521 tcu::TestNode::IterateResult DrawTestBase::iterate()
2523 if (!m_is_viewport_array_supported)
2525 throw tcu::NotSupportedError(VIEWPORT_ARRAY_NOT_SUPPORTED, "", __FILE__, __LINE__);
2528 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
2529 const glu::ContextType& context_type = m_context.getRenderContext().getType();
2532 bool test_result = true;
2534 /* Get type of test */
2535 const TEST_TYPE test_type = getTestType();
2537 GLuint n_draw_calls = getDrawCallsNumber();
2538 GLuint n_iterations = 0;
2550 TCU_FAIL("Invalid enum");
2553 /* Get shader sources and specialize them */
2554 const std::string& frag = getFragmentShader();
2555 const std::string& geom = getGeometryShader();
2556 const std::string& vert = getVertexShader();
2558 const GLchar* frag_template = frag.c_str();
2559 const GLchar* geom_template = geom.c_str();
2560 const GLchar* vert_template = vert.c_str();
2562 std::string fragment = specializeShader(1, &frag_template);
2563 std::string geometry = specializeShader(1, &geom_template);
2564 std::string vertex = specializeShader(1, &vert_template);
2566 /* Prepare program */
2567 Utils::program program(m_context);
2571 program.build(0 /* compute */, fragment.c_str(), geometry.c_str(), 0 /* tess ctrl */, 0 /* tess eval */,
2572 vertex.c_str(), 0 /* varying names */, 0 /* n_varyings */);
2574 catch (Utils::shaderCompilationException& exc)
2576 /* Something wrong with compilation, test case failed */
2577 tcu::MessageBuilder message = m_context.getTestContext().getLog() << tcu::TestLog::Message;
2579 message << "Shader compilation failed. Error message: " << exc.m_error_message;
2581 Utils::program::printShaderSource(exc.m_shader_source.c_str(), message);
2583 message << tcu::TestLog::EndMessage;
2585 TCU_FAIL("Shader compilation failed");
2587 catch (Utils::programLinkageException& exc)
2589 /* Something wrong with linking, test case failed */
2590 m_context.getTestContext().getLog() << tcu::TestLog::Message
2591 << "Program linking failed. Error message: " << exc.m_error_message
2592 << tcu::TestLog::EndMessage;
2593 TCU_FAIL("Program linking failed");
2599 Utils::vertexArray vao(m_context);
2603 /* For each iteration from test type */
2604 for (GLuint i = 0; i < n_iterations; ++i)
2606 /* Prepare textures */
2607 Utils::texture texture_0(m_context);
2608 Utils::texture texture_1(m_context);
2610 prepareTextures(texture_0, texture_1);
2612 /* Prepare framebuffer */
2613 Utils::framebuffer framebuffer(m_context);
2614 framebuffer.generate();
2615 setupFramebuffer(framebuffer, texture_0, texture_1);
2618 /* Set up viewports */
2619 setupViewports(test_type, i);
2621 if (false == isClearTest())
2623 /* For each draw call */
2624 for (GLuint draw_call = 0; draw_call < n_draw_calls; ++draw_call)
2626 prepareUniforms(program, draw_call);
2629 GLfloat depth_value;
2631 getClearSettings(is_clear, draw_call, depth_value);
2633 if (true == is_clear)
2635 if (glu::isContextTypeGLCore(context_type))
2637 gl.clearDepth((GLdouble)depth_value);
2641 gl.clearDepthf(depth_value);
2643 GLU_EXPECT_NO_ERROR(gl.getError(), "ClearDepth");
2645 gl.clear(GL_DEPTH_BUFFER_BIT);
2646 GLU_EXPECT_NO_ERROR(gl.getError(), "Clear");
2649 gl.drawArrays(GL_POINTS, 0 /* first */, 1 /* count */);
2650 GLU_EXPECT_NO_ERROR(gl.getError(), "DrawArrays");
2652 bool result = checkResults(texture_0, texture_1, draw_call);
2654 if (false == result)
2656 test_result = false;
2663 gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
2664 GLU_EXPECT_NO_ERROR(gl.getError(), "ClearColor");
2666 gl.clear(GL_COLOR_BUFFER_BIT);
2667 GLU_EXPECT_NO_ERROR(gl.getError(), "Clear");
2669 bool result = checkResults(texture_0, texture_1, 0);
2671 if (false == result)
2673 test_result = false;
2681 if (true == test_result)
2683 m_context.getTestContext().setTestResult(QP_TEST_RESULT_PASS, "Pass");
2687 m_context.getTestContext().setTestResult(QP_TEST_RESULT_FAIL, "Fail");
2691 return tcu::TestNode::STOP;
2694 /** Check if R32I texture is filled with 4x4 regions of increasing values <0:15>
2696 * @param texture_0 Verified texture
2700 * @return True if texture_0 is filled with expected pattern
2702 bool DrawTestBase::checkResults(Utils::texture& texture_0, Utils::texture& /* texture_1 */, GLuint /*draw_call_index */)
2704 bool check_result = true;
2707 std::vector<GLint> texture_data;
2708 texture_data.resize(m_width * m_height);
2709 texture_0.get(GL_RED_INTEGER, GL_INT, &texture_data[0]);
2711 for (GLuint y = 0; y < 4; ++y)
2713 for (GLuint x = 0; x < 4; ++x)
2715 bool result = checkRegionR32I(x, y, index, &texture_data[0]);
2717 if (false == result)
2719 check_result = false;
2728 return check_result;
2731 /** Get settings of clear operation
2733 * @param clear_depth_before_draw Selects if clear depth should be executed before draw.
2737 void DrawTestBase::getClearSettings(bool& clear_depth_before_draw, GLuint /* iteration_index */,
2738 GLfloat& /* depth_value */)
2740 clear_depth_before_draw = false;
2743 /** Get number of draw call to be executed during test
2747 GLuint DrawTestBase::getDrawCallsNumber()
2756 DrawTestBase::TEST_TYPE DrawTestBase::getTestType()
2761 /** Selects if test should do draw or clear operation
2763 * @return false - draw operation
2765 bool DrawTestBase::isClearTest()
2770 /** Prepare textures used as framebuffer's attachments for current draw call
2772 * @param texture_0 R32I texture
2775 void DrawTestBase::prepareTextures(Utils::texture& texture_0, Utils::texture& /* texture_1 */)
2777 prepareTextureR32I(texture_0);
2780 /** Prepare uniforms for given draw call
2785 void DrawTestBase::prepareUniforms(Utils::program& /* program */, GLuint /* draw_call_index */)
2790 /** Attach textures to framebuffer
2792 * @param framebuffer Framebuffer instance
2793 * @param texture_0 Texture attached as color 0
2796 void DrawTestBase::setupFramebuffer(Utils::framebuffer& framebuffer, Utils::texture& texture_0,
2797 Utils::texture& /* texture_1 */)
2799 framebuffer.attachTexture(GL_COLOR_ATTACHMENT0, texture_0.m_id, m_width, m_height);
2802 /** Check if region specified with <x and <y> is filled with expected value.
2803 * Note: there is assumption that there are 4x4 regions
2805 * @param x X coordinate of region
2806 * @param y Y coordinate of region
2807 * @param expected_value Expected value
2808 * @param data Texture data (not region, but whole texture)
2810 * @return True if region is filled with <expected_value>, false otherwise
2812 bool DrawTestBase::checkRegionR32I(GLuint x, GLuint y, GLint expected_value, GLint* data)
2814 static GLuint width = m_width / 4;
2815 static GLuint height = m_height / 4;
2817 return checkRegionR32I(x, y, width, height, expected_value, data);
2820 /** Check if region specified with <x and <y> is filled with expected value.
2821 * Note: there is assumption that there are 4x4 regions
2823 * @param x X coordinate of region
2824 * @param y Y coordinate of region
2825 * @param width Width of region
2826 * @param height Height of region
2827 * @param expected_value Expected value
2828 * @param data Texture data (not region, but whole texture)
2830 * @return True if region is filled with <expected_value>, false otherwise
2832 bool DrawTestBase::checkRegionR32I(GLuint x, GLuint y, GLuint width, GLuint height, GLint expected_value, GLint* data)
2836 const GLuint offset = (y * height * m_width) + (x * width);
2838 for (GLuint line = 0; line < height; ++line)
2840 const GLuint line_offset = offset + line * m_width;
2842 for (GLuint texel = 0; texel < width; ++texel)
2844 const GLuint texel_offset = line_offset + texel;
2846 const GLint value = data[texel_offset];
2848 if (expected_value != value)
2850 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Invalid result. Region (" << x << "x"
2851 << y << "). Expected: " << expected_value << " got " << value
2852 << tcu::TestLog::EndMessage;
2864 /** Return boiler-plate vertex shader
2866 * @return Source code of vertex shader
2868 std::string DrawTestBase::getVertexShader()
2870 static const GLchar* source = "${VERSION}\n"
2878 std::string result = source;
2883 /** Set up viewports
2885 * @param type Type of test
2886 * @param iteration_index Index of iteration for given test type
2888 void DrawTestBase::setupViewports(TEST_TYPE type, GLuint iteration_index)
2894 VIEWPORT_METHOD method;
2895 switch (iteration_index)
2900 method = (VIEWPORT_METHOD)iteration_index;
2903 TCU_FAIL("Invalid value");
2905 setup4x4Viewport(method);
2910 SCISSOR_METHOD method;
2911 switch (iteration_index)
2916 method = (SCISSOR_METHOD)iteration_index;
2919 TCU_FAIL("Invalid value");
2921 setup4x4Scissor(method, false /* set_zeros */);
2926 DEPTH_RANGE_METHOD method;
2927 switch (iteration_index)
2931 method = (DEPTH_RANGE_METHOD)iteration_index;
2934 TCU_FAIL("Invalid value");
2936 setup16x2Depths(method);
2941 PROVOKING_VERTEX provoking;
2942 switch (iteration_index)
2946 provoking = (PROVOKING_VERTEX)iteration_index;
2949 TCU_FAIL("Invalid value");
2951 setup2x2Viewport(provoking);
2955 TCU_FAIL("Invalid enum");
2959 /** Prepare R32I texture filled with value -1
2961 * @param texture Texture instance
2963 void DrawTestBase::prepareTextureR32I(Utils::texture& texture)
2965 static const GLuint size = m_width * m_height;
2968 for (GLuint i = 0; i < size; ++i)
2973 texture.create(m_width, m_height, GL_R32I);
2974 texture.update(m_width, m_height, 0 /* depth */, GL_RED_INTEGER, GL_INT, data);
2977 /** Prepare R32I array texture filled with value -1, 4 layers
2979 * @param texture Texture instance
2981 void DrawTestBase::prepareTextureR32Ix4(Utils::texture& texture)
2983 static const GLuint size = m_width * m_height * m_r32ix4_depth;
2985 std::vector<GLint> data;
2988 for (GLuint i = 0; i < size; ++i)
2993 texture.create(m_width, m_height, m_r32ix4_depth, GL_R32I);
2994 texture.update(m_width, m_height, m_r32ix4_depth, GL_RED_INTEGER, GL_INT, &data[0]);
2997 /** Prepare R32I array texture filled with value -1
2999 * @param texture Texture instance
3001 void DrawTestBase::prepareTextureArrayR32I(Utils::texture& texture)
3003 static const GLuint size = m_width * m_height * m_depth;
3005 std::vector<GLint> data;
3008 for (GLuint i = 0; i < size; ++i)
3013 texture.create(m_width, m_height, m_depth, GL_R32I);
3014 texture.update(m_width, m_height, m_depth, GL_RED_INTEGER, GL_INT, &data[0]);
3017 /** Prepare R32F texture filled with value -1
3019 * @param texture Texture instance
3021 void DrawTestBase::prepareTextureR32F(Utils::texture& texture)
3023 static const GLuint size = m_r32f_width * m_r32f_height;
3026 for (GLuint i = 0; i < size; ++i)
3031 texture.create(m_r32f_width, m_r32f_height, GL_R32F);
3032 texture.update(m_r32f_width, m_r32f_height, 0 /* depth */, GL_RED, GL_FLOAT, data);
3035 /** Prepare D32F texture filled with value -1
3037 * @param texture Texture instance
3039 void DrawTestBase::prepareTextureD32F(Utils::texture& texture)
3041 static const GLuint size = m_width * m_height;
3044 for (GLuint i = 0; i < size; ++i)
3049 texture.create(m_width, m_height, GL_DEPTH_COMPONENT32F);
3050 texture.update(m_width, m_height, 0 /* depth */, GL_DEPTH_COMPONENT, GL_FLOAT, data);
3053 /** Set up 16 viewports and depth ranges horizontally
3055 * @param method Method used to set depth ranges
3057 void DrawTestBase::setup16x2Depths(DEPTH_RANGE_METHOD method)
3059 const glu::ContextType& context_type = m_context.getRenderContext().getType();
3061 if (glu::isContextTypeGLCore(context_type))
3063 setup16x2DepthsHelper<GLdouble>(method);
3067 DE_ASSERT(glu::isContextTypeES(context_type));
3068 setup16x2DepthsHelper<GLfloat>(method);
3072 template <typename T>
3073 void DrawTestBase::setup16x2DepthsHelper(DEPTH_RANGE_METHOD method, T*)
3075 static const T step = 1.0 / 16.0;
3077 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3078 Utils::DepthFuncWrapper depthFunc(m_context);
3080 T depth_data[16 * 2];
3081 GLfloat viewport_data[16 * 4];
3083 for (GLuint i = 0; i < 16; ++i)
3085 const T near = step * (T)i;
3087 depth_data[i * 2 + 0] = near;
3088 depth_data[i * 2 + 1] = T(1.0) - near;
3090 viewport_data[i * 4 + 0] = (GLfloat)i;
3091 viewport_data[i * 4 + 1] = 0.0f;
3092 viewport_data[i * 4 + 2] = 1.0f;
3093 viewport_data[i * 4 + 3] = 2.0f;
3096 gl.viewportArrayv(0 /* first */, 16 /* count */, viewport_data);
3097 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportArrayv");
3101 case DEPTHRANGEINDEXED:
3102 for (GLuint i = 0; i < 16; ++i)
3104 depthFunc.depthRangeIndexed(i, depth_data[i * 2 + 0], depth_data[i * 2 + 1]);
3105 GLU_EXPECT_NO_ERROR(gl.getError(), "DepthRangeIndexed");
3109 case DEPTHRANGEARRAYV:
3110 depthFunc.depthRangeArray(0 /* first */, 16 /* count */, depth_data);
3111 GLU_EXPECT_NO_ERROR(gl.getError(), "DepthRangeArray");
3115 TCU_FAIL("Invalid enum");
3119 /** Set up 4x4 scissor boxes with enabled test
3121 * @param method Method used to set scissor boxes
3122 * @param set_zeros Select if width and height should be 0 or image_dim / 4
3124 void DrawTestBase::setup4x4Scissor(SCISSOR_METHOD method, bool set_zeros)
3126 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3128 for (GLuint i = 0; i < 16; ++i)
3130 gl.enablei(GL_SCISSOR_TEST, i);
3131 GLU_EXPECT_NO_ERROR(gl.getError(), "Enablei");
3135 GLint data[16 * 4 /* 4x4 * (x + y + w + h) */];
3137 GLint width = m_width / 4;
3138 GLint height = m_height / 4;
3140 for (GLuint y = 0; y < 4; ++y)
3142 for (GLuint x = 0; x < 4; ++x)
3144 data[index * 4 + 0] = x * width;
3145 data[index * 4 + 1] = y * height;
3146 if (false == set_zeros)
3148 data[index * 4 + 2] = width;
3149 data[index * 4 + 3] = height;
3153 data[index * 4 + 2] = 0;
3154 data[index * 4 + 3] = 0;
3164 gl.scissorArrayv(0 /* first */, 16 /*count */, data);
3165 GLU_EXPECT_NO_ERROR(gl.getError(), "ScissorArrayv");
3167 case SCISSORINDEXEDF:
3168 for (GLuint i = 0; i < 16; ++i)
3170 const GLint x = data[i * 4 + 0];
3171 const GLint y = data[i * 4 + 1];
3172 const GLint w = data[i * 4 + 2];
3173 const GLint h = data[i * 4 + 3];
3175 gl.scissorIndexed(i, x, y, w, h);
3176 GLU_EXPECT_NO_ERROR(gl.getError(), "ScissorIndexed");
3179 case SCISSORINDEXEDF_V:
3180 for (GLuint i = 0; i < 16; ++i)
3182 gl.scissorIndexedv(i, &data[i * 4]);
3183 GLU_EXPECT_NO_ERROR(gl.getError(), "ScissorIndexedv");
3187 TCU_FAIL("Invalid enum");
3191 /** Set up 4x4 viewports
3193 * @param method Method used to set viewports
3195 void DrawTestBase::setup4x4Viewport(VIEWPORT_METHOD method)
3197 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3200 GLfloat data[16 * 4 /* 4x4 * (x + y + w + h) */];
3202 GLfloat width = (GLfloat)(m_width / 4);
3203 GLfloat height = (GLfloat)(m_height / 4);
3205 for (GLuint y = 0; y < 4; ++y)
3207 for (GLuint x = 0; x < 4; ++x)
3209 data[index * 4 + 0] = (GLfloat)((GLfloat)x * width);
3210 data[index * 4 + 1] = (GLfloat)((GLfloat)y * height);
3211 data[index * 4 + 2] = width;
3212 data[index * 4 + 3] = height;
3220 case VIEWPORTARRAYV:
3221 gl.viewportArrayv(0 /* first */, 16 /*count */, data);
3222 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportArrayv");
3224 case VIEWPORTINDEXEDF:
3225 for (GLuint i = 0; i < 16; ++i)
3227 const GLfloat x = data[i * 4 + 0];
3228 const GLfloat y = data[i * 4 + 1];
3229 const GLfloat w = data[i * 4 + 2];
3230 const GLfloat h = data[i * 4 + 3];
3232 gl.viewportIndexedf(i, x, y, w, h);
3233 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportIndexedf");
3236 case VIEWPORTINDEXEDF_V:
3237 for (GLuint i = 0; i < 16; ++i)
3239 gl.viewportIndexedfv(i, &data[i * 4]);
3240 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportIndexedfv");
3244 TCU_FAIL("Invalid enum");
3248 /** Set up 4x4 viewports
3250 * @param method Method used to set viewports
3252 void DrawTestBase::setup2x2Viewport(PROVOKING_VERTEX provoking)
3254 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3255 const glu::ContextType& context_type = m_context.getRenderContext().getType();
3258 GLfloat data[4 * 4 /* 4x4 * (x + y + w + h) */];
3260 GLfloat width = (GLfloat)(m_width / 2);
3261 GLfloat height = (GLfloat)(m_height / 2);
3263 for (GLuint y = 0; y < 2; ++y)
3265 for (GLuint x = 0; x < 2; ++x)
3267 data[index * 4 + 0] = (GLfloat)((GLfloat)x * width);
3268 data[index * 4 + 1] = (GLfloat)((GLfloat)y * height);
3269 data[index * 4 + 2] = width;
3270 data[index * 4 + 3] = height;
3276 gl.viewportArrayv(0 /* first */, 4 /*count */, data);
3277 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportArrayv");
3279 if (glu::isContextTypeGLCore(context_type))
3285 mode = GL_FIRST_VERTEX_CONVENTION;
3288 mode = GL_LAST_VERTEX_CONVENTION;
3291 TCU_FAIL("Invalid enum");
3294 gl.provokingVertex(mode);
3295 GLU_EXPECT_NO_ERROR(gl.getError(), "ProvokingVertex");
3299 /* can't control the provoking vertex in ES yet - it stays as LAST */
3300 DE_ASSERT(glu::isContextTypeES(context_type));
3301 DE_UNREF(provoking);
3307 * @param context Test context
3309 DrawToSingleLayerWithMultipleViewports::DrawToSingleLayerWithMultipleViewports(deqp::Context& context,
3310 const glcts::ExtParameters& extParams)
3311 : DrawTestBase(context, extParams, "draw_to_single_layer_with_multiple_viewports",
3312 "Test verifies that multiple viewports can be used to draw to single layer")
3314 /* Nothing to be done here */
3317 /** Get string with fragment shader source code
3319 * @return Fragment shader source
3321 std::string DrawToSingleLayerWithMultipleViewports::getFragmentShader()
3323 static const GLchar* source = "${VERSION}\n"
3325 "flat in int gs_fs_color;\n"
3326 " out int fs_out_color;\n"
3330 " fs_out_color = gs_fs_color;\n"
3334 std::string result = source;
3339 /** Get string with geometry shader source code
3341 * @return Geometry shader source
3343 std::string DrawToSingleLayerWithMultipleViewports::getGeometryShader()
3345 static const GLchar* source = "${VERSION}\n"
3347 "${GEOMETRY_SHADER_ENABLE}\n"
3348 "${VIEWPORT_ARRAY_ENABLE}\n"
3350 "layout(points, invocations = 16) in;\n"
3351 "layout(triangle_strip, max_vertices = 4) out;\n"
3353 "flat out int gs_fs_color;\n"
3357 " gs_fs_color = gl_InvocationID;\n"
3358 " gl_ViewportIndex = gl_InvocationID;\n"
3359 " gl_Position = vec4(-1, -1, 0, 1);\n"
3361 " gs_fs_color = gl_InvocationID;\n"
3362 " gl_ViewportIndex = gl_InvocationID;\n"
3363 " gl_Position = vec4(-1, 1, 0, 1);\n"
3365 " gs_fs_color = gl_InvocationID;\n"
3366 " gl_ViewportIndex = gl_InvocationID;\n"
3367 " gl_Position = vec4(1, -1, 0, 1);\n"
3369 " gs_fs_color = gl_InvocationID;\n"
3370 " gl_ViewportIndex = gl_InvocationID;\n"
3371 " gl_Position = vec4(1, 1, 0, 1);\n"
3376 std::string result = source;
3383 * @param context Test context
3385 DynamicViewportIndex::DynamicViewportIndex(deqp::Context& context, const glcts::ExtParameters& extParams)
3386 : DrawTestBase(context, extParams, "dynamic_viewport_index",
3387 "Test verifies that gl_ViewportIndex can be assigned with dynamic value")
3389 /* Nothing to be done here */
3392 /** Get string with fragment shader source code
3394 * @return Fragment shader source
3396 std::string DynamicViewportIndex::getFragmentShader()
3398 static const GLchar* source = "${VERSION}\n"
3400 "flat in int gs_fs_color;\n"
3401 " out int fs_out_color;\n"
3405 " fs_out_color = gs_fs_color;\n"
3409 std::string result = source;
3414 /** Get string with geometry shader source code
3416 * @return Geometry shader source
3418 std::string DynamicViewportIndex::getGeometryShader()
3420 static const GLchar* source = "${VERSION}\n"
3422 "${GEOMETRY_SHADER_ENABLE}\n"
3423 "${VIEWPORT_ARRAY_ENABLE}\n"
3425 "layout(points, invocations = 1) in;\n"
3426 "layout(triangle_strip, max_vertices = 4) out;\n"
3428 "uniform int uni_index;\n"
3430 "flat out int gs_fs_color;\n"
3434 " gs_fs_color = uni_index;\n"
3435 " gl_ViewportIndex = uni_index;\n"
3436 " gl_Position = vec4(-1, -1, 0, 1);\n"
3438 " gs_fs_color = uni_index;\n"
3439 " gl_ViewportIndex = uni_index;\n"
3440 " gl_Position = vec4(-1, 1, 0, 1);\n"
3442 " gs_fs_color = uni_index;\n"
3443 " gl_ViewportIndex = uni_index;\n"
3444 " gl_Position = vec4(1, -1, 0, 1);\n"
3446 " gs_fs_color = uni_index;\n"
3447 " gl_ViewportIndex = uni_index;\n"
3448 " gl_Position = vec4(1, 1, 0, 1);\n"
3453 std::string result = source;
3458 /** Check if R32I texture is filled with 4x4 regions of increasing values <0:15>
3460 * @param texture_0 Verified texture
3462 * @param draw_call_index Draw call that was executed
3464 * @return True if texture_0 is filled with expected pattern
3466 bool DynamicViewportIndex::checkResults(Utils::texture& texture_0, Utils::texture& /* texture_1 */,
3467 GLuint draw_call_index)
3469 bool check_result = true;
3472 std::vector<GLint> texture_data;
3473 texture_data.resize(m_width * m_height);
3474 texture_0.get(GL_RED_INTEGER, GL_INT, &texture_data[0]);
3476 for (GLuint y = 0; y < 4; ++y)
3478 for (GLuint x = 0; x < 4; ++x)
3480 GLint expected_value = -1;
3481 if (index <= draw_call_index)
3483 expected_value = index;
3486 bool result = checkRegionR32I(x, y, expected_value, &texture_data[0]);
3488 if (false == result)
3490 check_result = false;
3499 return check_result;
3502 /** Get number of draw call to be executed during test
3506 GLuint DynamicViewportIndex::getDrawCallsNumber()
3511 /** Prepare uniforms for given draw call
3513 * @param program Program object
3514 * @param draw_call_index Index of draw call to be executed
3516 void DynamicViewportIndex::prepareUniforms(Utils::program& program, GLuint draw_call_index)
3518 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3520 GLint location = program.getUniformLocation("uni_index");
3522 gl.uniform1i(location, (GLint)draw_call_index);
3523 GLU_EXPECT_NO_ERROR(gl.getError(), "Uniform1i");
3528 * @param context Test context
3530 DrawMulitpleViewportsWithSingleInvocation::DrawMulitpleViewportsWithSingleInvocation(
3531 deqp::Context& context, const glcts::ExtParameters& extParams)
3532 : DrawTestBase(context, extParams, "draw_mulitple_viewports_with_single_invocation",
3533 "Test verifies that single invocation can output to multiple viewports")
3535 /* Nothing to be done here */
3538 /** Get string with fragment shader source code
3540 * @return Fragment shader source
3542 std::string DrawMulitpleViewportsWithSingleInvocation::getFragmentShader()
3544 static const GLchar* source = "${VERSION}\n"
3546 "flat in int gs_fs_color;\n"
3547 " out int fs_out_color;\n"
3551 " fs_out_color = gs_fs_color;\n"
3555 std::string result = source;
3560 /** Get string with geometry shader source code
3562 * @return Geometry shader source
3564 std::string DrawMulitpleViewportsWithSingleInvocation::getGeometryShader()
3566 static const GLchar* source = "${VERSION}\n"
3568 "${GEOMETRY_SHADER_ENABLE}\n"
3569 "${VIEWPORT_ARRAY_ENABLE}\n"
3571 "layout(points, invocations = 1) in;\n"
3572 "layout(triangle_strip, max_vertices = 64) out;\n"
3574 "flat out int gs_fs_color;\n"
3576 "void routine(int index)\n"
3578 " gs_fs_color = index;\n"
3579 " gl_ViewportIndex = index;\n"
3580 " gl_Position = vec4(-1, -1, 0, 1);\n"
3582 " gs_fs_color = index;\n"
3583 " gl_ViewportIndex = index;\n"
3584 " gl_Position = vec4(-1, 1, 0, 1);\n"
3586 " gs_fs_color = index;\n"
3587 " gl_ViewportIndex = index;\n"
3588 " gl_Position = vec4(1, -1, 0, 1);\n"
3590 " gs_fs_color = index;\n"
3591 " gl_ViewportIndex = index;\n"
3592 " gl_Position = vec4(1, 1, 0, 1);\n"
3594 " EndPrimitive();\n"
3599 " for(int i = 0; i < 16; ++i)\n"
3606 std::string result = source;
3613 * @param context Test context
3615 ViewportIndexSubroutine::ViewportIndexSubroutine(deqp::Context& context, const glcts::ExtParameters& extParams)
3616 : DrawTestBase(context, extParams, "viewport_index_subroutine",
3617 "Test verifies subroutines can be used to output data to specific viewport")
3619 /* Nothing to be done here */
3624 * @return tcu::TestNode::CONTINUE after executing test case, tcu::TestNode::STOP otherwise
3626 tcu::TestNode::IterateResult ViewportIndexSubroutine::iterate()
3628 /* this exists solely to check for subroutine support, which is not supported in ES.
3629 The real work is done in DrawTestBase::iterate() */
3630 const glu::ContextType& context_type = m_context.getRenderContext().getType();
3631 if (!glu::isContextTypeGLCore(context_type))
3633 throw tcu::NotSupportedError("Subroutines not supported", "", __FILE__, __LINE__);
3636 return DrawTestBase::iterate();
3639 /** Get string with fragment shader source code
3641 * @return Fragment shader source
3643 std::string ViewportIndexSubroutine::getFragmentShader()
3645 static const GLchar* source = "${VERSION}\n"
3647 "flat in int gs_fs_color;\n"
3648 " out int fs_out_color;\n"
3652 " fs_out_color = gs_fs_color;\n"
3656 std::string result = source;
3661 /** Get string with geometry shader source code
3663 * @return Geometry shader source
3665 std::string ViewportIndexSubroutine::getGeometryShader()
3667 static const GLchar* source = "${VERSION}\n"
3669 "${GEOMETRY_SHADER_ENABLE}\n"
3670 "${VIEWPORT_ARRAY_ENABLE}\n"
3672 "layout(points, invocations = 1) in;\n"
3673 "layout(triangle_strip, max_vertices = 4) out;\n"
3675 "flat out int gs_fs_color;\n"
3677 "subroutine void indexSetter(void);\n"
3679 "subroutine(indexSetter) void four()\n"
3681 " gs_fs_color = 4;\n"
3682 " gl_ViewportIndex = 4;\n"
3685 "subroutine(indexSetter) void five()\n"
3687 " gs_fs_color = 5;\n"
3688 " gl_ViewportIndex = 5;\n"
3691 "subroutine uniform indexSetter routine;\n"
3696 " gl_Position = vec4(-1, -1, 0, 1);\n"
3699 " gl_Position = vec4(-1, 1, 0, 1);\n"
3702 " gl_Position = vec4(1, -1, 0, 1);\n"
3705 " gl_Position = vec4(1, 1, 0, 1);\n"
3710 std::string result = source;
3715 /** Check if R32I texture is filled with two halves, left is 4, right is either -1 or 5
3717 * @param texture_0 Verified texture
3719 * @param draw_call_index Draw call that was executed
3721 * @return True if texture_0 is filled with expected pattern
3723 bool ViewportIndexSubroutine::checkResults(Utils::texture& texture_0, Utils::texture& /* texture_1 */,
3724 GLuint draw_call_index)
3726 bool check_result = true;
3728 std::vector<GLint> texture_data;
3729 texture_data.resize(m_width * m_height);
3730 texture_0.get(GL_RED_INTEGER, GL_INT, &texture_data[0]);
3732 /* Left is 4 and right is -1, or left is 4 and right is 5 */
3733 GLint expected_left = 4;
3734 GLint expected_right = (1 == draw_call_index) ? 5 : -1;
3736 for (GLuint y = 0; y < 4; ++y)
3738 for (GLuint x = 0; x < 2; ++x)
3740 bool result = checkRegionR32I(x, y, expected_left, &texture_data[0]);
3742 if (false == result)
3744 check_result = false;
3750 for (GLuint y = 0; y < 4; ++y)
3752 for (GLuint x = 2; x < 4; ++x)
3754 bool result = checkRegionR32I(x, y, expected_right, &texture_data[0]);
3756 if (false == result)
3758 check_result = false;
3765 return check_result;
3768 /** Get number of draw call to be executed during test
3772 GLuint ViewportIndexSubroutine::getDrawCallsNumber()
3777 /** Prepare uniforms for given draw call
3779 * @param program Program object
3780 * @param draw_call_index Index of draw call to be executed
3782 void ViewportIndexSubroutine::prepareUniforms(Utils::program& program, GLuint draw_call_index)
3784 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3786 const GLchar* subroutine_name = (0 == draw_call_index) ? "four" : "five";
3788 GLint location = program.getSubroutineUniformLocation("routine", GL_GEOMETRY_SHADER);
3789 GLuint index = program.getSubroutineIndex(subroutine_name, GL_GEOMETRY_SHADER);
3793 TCU_FAIL("Something wrong, subroutine uniform location is not 0. Mistake in geometry shader?");
3796 gl.uniformSubroutinesuiv(GL_GEOMETRY_SHADER, 1, &index);
3797 GLU_EXPECT_NO_ERROR(gl.getError(), "UniformSubroutinesuiv");
3800 /** Set 4th viewport on left half and 5 on right half of framebuffer. Rest span over whole image.
3803 * @param iteration_index Index of iteration, used to select "viewport" method
3805 void ViewportIndexSubroutine::setupViewports(TEST_TYPE /* type */, glw::GLuint iteration_index)
3807 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
3809 GLfloat data[2 * 4] = { 0.0f, 0.0f, 64.0f, 128.0f, 64.0f, 0.0f, 64.0f, 128.0f };
3811 gl.viewport(0, 0, m_width, m_height);
3812 GLU_EXPECT_NO_ERROR(gl.getError(), "Viewport");
3814 switch (iteration_index)
3818 gl.viewportArrayv(4, 2, data);
3819 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportArrayv");
3825 gl.viewportIndexedf(4, data[0], data[1], data[2], data[3]);
3826 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportIndexedf");
3828 gl.viewportIndexedf(5, data[4], data[5], data[6], data[7]);
3829 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportIndexedf");
3835 gl.viewportIndexedfv(4, &data[0]);
3836 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportIndexedfv");
3838 gl.viewportIndexedfv(5, &data[4]);
3839 GLU_EXPECT_NO_ERROR(gl.getError(), "ViewportIndexedfv");
3844 TCU_FAIL("Invalid value");
3850 * @param context Test context
3852 DrawMultipleLayers::DrawMultipleLayers(deqp::Context& context, const glcts::ExtParameters& extParams)
3853 : DrawTestBase(context, extParams, "draw_multiple_layers",
3854 "Test verifies that single viewport affects multiple layers in the same way")
3856 /* Nothing to be done here */
3861 * @param context Test context
3862 * @param test_name Test name
3863 * @param test_description Test description
3865 DrawMultipleLayers::DrawMultipleLayers(deqp::Context& context, const glcts::ExtParameters& extParams,
3866 const GLchar* test_name, const GLchar* test_description)
3867 : DrawTestBase(context, extParams, test_name, test_description)
3869 /* Nothing to be done here */
3872 /** Get string with fragment shader source code
3874 * @return Fragment shader source
3876 std::string DrawMultipleLayers::getFragmentShader()
3878 static const GLchar* source = "${VERSION}\n"
3880 "flat in int gs_fs_color;\n"
3881 " out int fs_out_color;\n"
3885 " fs_out_color = gs_fs_color;\n"
3889 std::string result = source;
3894 /** Get string with geometry shader source code
3896 * @return Geometry shader source
3898 std::string DrawMultipleLayers::getGeometryShader()
3900 static const GLchar* source = "${VERSION}\n"
3902 "${GEOMETRY_SHADER_ENABLE}\n"
3903 "${VIEWPORT_ARRAY_ENABLE}\n"
3905 "layout(points, invocations = 16) in;\n"
3906 "layout(triangle_strip, max_vertices = 4) out;\n"
3908 "flat out int gs_fs_color;\n"
3912 " gs_fs_color = gl_InvocationID;\n"
3913 " gl_ViewportIndex = gl_InvocationID;\n"
3914 " gl_Layer = gl_InvocationID;\n"
3915 " gl_Position = vec4(-1, -1, 0, 1);\n"
3917 " gs_fs_color = gl_InvocationID;\n"
3918 " gl_ViewportIndex = gl_InvocationID;\n"
3919 " gl_Layer = gl_InvocationID;\n"
3920 " gl_Position = vec4(-1, 1, 0, 1);\n"
3922 " gs_fs_color = gl_InvocationID;\n"
3923 " gl_ViewportIndex = gl_InvocationID;\n"
3924 " gl_Layer = gl_InvocationID;\n"
3925 " gl_Position = vec4(1, -1, 0, 1);\n"
3927 " gs_fs_color = gl_InvocationID;\n"
3928 " gl_ViewportIndex = gl_InvocationID;\n"
3929 " gl_Layer = gl_InvocationID;\n"
3930 " gl_Position = vec4(1, 1, 0, 1);\n"
3935 std::string result = source;
3940 /** Check if R32I texture is filled with 4x4 regions of increasing values <0:15>
3942 * @param texture_0 Verified texture
3946 * @return True if texture_0 is filled with expected pattern
3948 bool DrawMultipleLayers::checkResults(Utils::texture& texture_0, Utils::texture& /* texture_1 */,
3949 GLuint /* draw_call_index */)
3951 static const GLuint layer_size = m_width * m_height;
3953 bool check_result = true;
3955 std::vector<GLint> texture_data;
3956 texture_data.resize(layer_size * m_depth);
3957 texture_0.get(GL_RED_INTEGER, GL_INT, &texture_data[0]);
3959 /* 16 layers, only region corresponding with layer index should be modified */
3960 for (GLuint layer = 0; layer < m_depth; ++layer)
3964 for (GLuint y = 0; y < 4; ++y)
3966 for (GLuint x = 0; x < 4; ++x)
3968 GLint* layer_data = &texture_data[layer * layer_size];
3970 GLint expected_value = -1;
3973 expected_value = index;
3976 bool result = checkRegionR32I(x, y, expected_value, layer_data);
3978 if (false == result)
3980 check_result = false;
3990 return check_result;
3993 /** Prepare textures used as framebuffer's attachments for current draw call
3995 * @param texture_0 R32I texture
3998 void DrawMultipleLayers::prepareTextures(Utils::texture& texture_0, Utils::texture& /* texture_1 */)
4000 prepareTextureArrayR32I(texture_0);
4005 * @param context Test context
4006 * @param test_name Test name
4007 * @param test_description Test description
4009 Scissor::Scissor(deqp::Context& context, const glcts::ExtParameters& extParams)
4010 : DrawMultipleLayers(context, extParams, "scissor", "Test verifies that scissor test is applied as expected")
4012 /* Nothing to be done here */
4019 DrawTestBase::TEST_TYPE Scissor::getTestType()
4026 * @param context Test context
4027 * @param test_name Test name
4028 * @param test_description Test description
4030 ScissorZeroDimension::ScissorZeroDimension(deqp::Context& context, const glcts::ExtParameters& extParams)
4031 : DrawMultipleLayers(context, extParams, "scissor_zero_dimension",
4032 "Test verifies that scissor test discard all fragments when width and height is set to zero")
4034 /* Nothing to be done here */
4037 /** Check if R32I texture is filled with 4x4 regions of increasing values <0:15>
4039 * @param texture_0 Verified texture
4043 * @return True if texture_0 is filled with expected pattern
4045 bool ScissorZeroDimension::checkResults(Utils::texture& texture_0, Utils::texture& /* texture_1 */,
4046 GLuint /* draw_call_index */)
4048 static const GLuint layer_size = m_width * m_height;
4050 bool check_result = true;
4052 std::vector<GLint> texture_data;
4053 texture_data.resize(layer_size * m_depth);
4054 texture_0.get(GL_RED_INTEGER, GL_INT, &texture_data[0]);
4056 /* 16 layers, all regions were not modified */
4057 for (GLuint layer = 0; layer < m_depth; ++layer)
4059 for (GLuint y = 0; y < 4; ++y)
4061 for (GLuint x = 0; x < 4; ++x)
4063 GLint* layer_data = &texture_data[layer * layer_size];
4065 GLint expected_value = -1;
4067 bool result = checkRegionR32I(x, y, expected_value, layer_data);
4069 if (false == result)
4071 check_result = false;
4079 return check_result;
4086 DrawTestBase::TEST_TYPE ScissorZeroDimension::getTestType()
4091 /** Set up viewports
4094 * @param iteration_index Index of iteration for given test type
4096 void ScissorZeroDimension::setupViewports(TEST_TYPE /* type */, GLuint iteration_index)
4098 SCISSOR_METHOD method;
4099 switch (iteration_index)
4104 method = (SCISSOR_METHOD)iteration_index;
4107 TCU_FAIL("Invalid value");
4110 setup4x4Scissor(method, true /* set_zeros */);
4115 * @param context Test context
4116 * @param test_name Test name
4117 * @param test_description Test description
4119 ScissorClear::ScissorClear(deqp::Context& context, const glcts::ExtParameters& extParams)
4120 : DrawMultipleLayers(context, extParams, "scissor_clear",
4121 "Test verifies that Clear is affected only by settings of scissor test in first viewport")
4123 /* Nothing to be done here */
4126 /** Check if R32I texture is filled with 4x4 regions of increasing values <0:15>
4128 * @param texture_0 Verified texture
4132 * @return True if texture_0 is filled with expected pattern
4134 bool ScissorClear::checkResults(Utils::texture& texture_0, Utils::texture& /* texture_1 */, GLuint /*draw_call_index */)
4136 static const GLuint layer_size = m_width * m_height;
4138 bool check_result = true;
4140 std::vector<GLint> texture_data;
4141 texture_data.resize(layer_size * m_depth);
4142 texture_0.get(GL_RED_INTEGER, GL_INT, &texture_data[0]);
4144 /* 16 layers, only region corresponding with scissor box 0 should be modified */
4145 for (GLuint layer = 0; layer < m_depth; ++layer)
4147 for (GLuint y = 0; y < 4; ++y)
4149 for (GLuint x = 0; x < 4; ++x)
4151 GLint* layer_data = &texture_data[layer * layer_size];
4153 GLint expected_value = -1;
4154 if ((0 == x) && (0 == y))
4159 bool result = checkRegionR32I(x, y, expected_value, layer_data);
4161 if (false == result)
4163 check_result = false;
4171 return check_result;
4178 DrawTestBase::TEST_TYPE ScissorClear::getTestType()
4183 /** Selects if test should do draw or clear operation
4185 * @return true - clear operation
4187 bool ScissorClear::isClearTest()
4194 * @param context Test context
4195 * @param test_name Test name
4196 * @param test_description Test description
4198 DepthRange::DepthRange(deqp::Context& context, const glcts::ExtParameters& extParams)
4199 : DrawTestBase(context, extParams, "depth_range", "Test verifies that depth range is applied as expected")
4201 /* Nothing to be done here */
4204 /** Check if R32F texture is filled with two rows, top with decreasing values, bottom with incresing values
4206 * @param texture_0 Verified texture
4210 * @return True if texture_0 is filled with expected pattern
4212 bool DepthRange::checkResults(Utils::texture& texture_0, Utils::texture& /* texture_1 */, GLuint /*draw_call_index */)
4214 static const GLfloat step = 1.0f / 16.0f;
4216 bool check_result = true;
4218 std::vector<GLfloat> texture_data;
4219 texture_data.resize(m_r32f_width * m_r32f_height);
4220 texture_0.get(GL_RED, GL_FLOAT, &texture_data[0]);
4222 GLfloat depth_data[16 * 2];
4224 for (GLuint i = 0; i < 16; ++i)
4226 const GLfloat near = step * (GLfloat)i;
4228 depth_data[i * 2 + 0] = near;
4229 depth_data[i * 2 + 1] = 1.0f - near;
4232 for (GLuint i = 0; i < 16; ++i)
4234 const GLfloat expected_near = depth_data[i * 2 + 0];
4235 const GLfloat expected_far = depth_data[i * 2 + 1];
4237 /* Bottom row should contain near values, top one should contain far values */
4238 const GLfloat near = texture_data[i];
4239 const GLfloat far = texture_data[i + 16];
4241 if ((expected_near != near) || (expected_far != far))
4243 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Invalid values at " << i << " expected ["
4244 << expected_near << ", " << expected_far << "] got [" << near << ", "
4245 << far << "]" << tcu::TestLog::EndMessage;
4247 check_result = false;
4252 return check_result;
4255 /** Get string with fragment shader source code
4257 * @return Fragment shader source
4259 std::string DepthRange::getFragmentShader()
4261 static const GLchar* source = "${VERSION}\n"
4264 "precision highp float;\n"
4266 "out float fs_out_color;\n"
4270 " fs_out_color = gl_FragCoord.z;\n"
4274 std::string result = source;
4279 /** Get string with geometry shader source code
4281 * @return Geometry shader source
4283 std::string DepthRange::getGeometryShader()
4285 static const GLchar* source = "${VERSION}\n"
4287 "${GEOMETRY_SHADER_ENABLE}\n"
4288 "${VIEWPORT_ARRAY_ENABLE}\n"
4290 "layout(points, invocations = 16) in;\n"
4291 "layout(triangle_strip, max_vertices = 8) out;\n"
4295 " const float top_z = 1.0;\n"
4296 " const float bottom_z = -1.0;\n"
4299 " gl_ViewportIndex = gl_InvocationID;\n"
4300 " gl_Position = vec4(-1, -1, bottom_z, 1);\n"
4302 " gl_ViewportIndex = gl_InvocationID;\n"
4303 " gl_Position = vec4(-1, 0, bottom_z, 1);\n"
4305 " gl_ViewportIndex = gl_InvocationID;\n"
4306 " gl_Position = vec4(1, -1, bottom_z, 1);\n"
4308 " gl_ViewportIndex = gl_InvocationID;\n"
4309 " gl_Position = vec4(1, 0, bottom_z, 1);\n"
4311 " EndPrimitive();\n"
4314 " gl_ViewportIndex = gl_InvocationID;\n"
4315 " gl_Position = vec4(-1, 0, top_z, 1);\n"
4317 " gl_ViewportIndex = gl_InvocationID;\n"
4318 " gl_Position = vec4(-1, 1, top_z, 1);\n"
4320 " gl_ViewportIndex = gl_InvocationID;\n"
4321 " gl_Position = vec4(1, 0, top_z, 1);\n"
4323 " gl_ViewportIndex = gl_InvocationID;\n"
4324 " gl_Position = vec4(1, 1, top_z, 1);\n"
4326 " EndPrimitive();\n"
4330 std::string result = source;
4337 * @return DEPTHRANGE
4339 DrawTestBase::TEST_TYPE DepthRange::getTestType()
4344 /** Prepare textures used as framebuffer's attachments for current draw call
4346 * @param texture_0 R32F texture
4349 void DepthRange::prepareTextures(Utils::texture& texture_0, Utils::texture& /* texture_1 */)
4351 prepareTextureR32F(texture_0);
4356 * @param context Test context
4357 * @param test_name Test name
4358 * @param test_description Test description
4360 DepthRangeDepthTest::DepthRangeDepthTest(deqp::Context& context, const glcts::ExtParameters& extParams)
4361 : DrawTestBase(context, extParams, "depth_range_depth_test",
4362 "Test verifies that depth test work as expected with multiple viewports")
4364 /* Nothing to be done here */
4367 /** Check if R32F texture is filled with two rows of values less than expected depth
4369 * @param texture_0 Verified texture
4371 * @param draw_call_index Index of draw call
4373 * @return True if texture_0 is filled with expected pattern
4375 bool DepthRangeDepthTest::checkResults(Utils::texture& texture_0, Utils::texture& /* texture_1 */,
4376 GLuint draw_call_index)
4378 static const GLfloat step = 1.0f / 16.0f;
4380 const GLfloat depth_value = step * (GLfloat)draw_call_index;
4382 bool check_result = true;
4384 std::vector<GLfloat> texture_data;
4385 texture_data.resize(m_r32f_width * m_r32f_height);
4386 texture_0.get(GL_RED, GL_FLOAT, &texture_data[0]);
4388 for (GLuint i = 0; i < 16; ++i)
4390 /* Bottom row should contain near values, top one should contain far values */
4391 const GLfloat near = texture_data[i];
4392 const GLfloat far = texture_data[i + 16];
4394 if ((depth_value <= near) || (depth_value <= far))
4396 m_context.getTestContext().getLog() << tcu::TestLog::Message << "Invalid values at " << i << " depth value "
4397 << depth_value << " got [" << near << ", " << far << "]"
4398 << tcu::TestLog::EndMessage;
4400 check_result = false;
4405 return check_result;
4408 /** Get settings of clear operation
4410 * @param clear_depth_before_draw Selects if clear should be executed before draw.
4411 * @param iteration_index Index of draw call
4412 * @param depth_value Value that will be used to clear depth buffer
4414 void DepthRangeDepthTest::getClearSettings(bool& clear_depth_before_draw, GLuint iteration_index, GLfloat& depth_value)
4416 static const GLfloat step = 1.0 / 16.0;
4418 clear_depth_before_draw = true;
4420 depth_value = step * (GLfloat)iteration_index;
4423 /** Get number of draw call to be executed during test
4427 GLuint DepthRangeDepthTest::getDrawCallsNumber()
4432 /** Get string with fragment shader source code
4434 * @return Fragment shader source
4436 std::string DepthRangeDepthTest::getFragmentShader()
4438 static const GLchar* source = "${VERSION}\n"
4441 "precision highp float;\n"
4443 "out float fs_out_color;\n"
4447 " fs_out_color = gl_FragCoord.z;\n"
4451 std::string result = source;
4456 /** Get string with geometry shader source code
4458 * @return Geometry shader source
4460 std::string DepthRangeDepthTest::getGeometryShader()
4462 static const GLchar* source = "${VERSION}\n"
4464 "${GEOMETRY_SHADER_ENABLE}\n"
4465 "${VIEWPORT_ARRAY_ENABLE}\n"
4467 "layout(points, invocations = 16) in;\n"
4468 "layout(triangle_strip, max_vertices = 8) out;\n"
4472 " const float top_z = 1.0;\n"
4473 " const float bottom_z = -1.0;\n"
4476 " gl_ViewportIndex = gl_InvocationID;\n"
4477 " gl_Position = vec4(-1, -1, bottom_z, 1);\n"
4479 " gl_ViewportIndex = gl_InvocationID;\n"
4480 " gl_Position = vec4(-1, 0, bottom_z, 1);\n"
4482 " gl_ViewportIndex = gl_InvocationID;\n"
4483 " gl_Position = vec4(1, -1, bottom_z, 1);\n"
4485 " gl_ViewportIndex = gl_InvocationID;\n"
4486 " gl_Position = vec4(1, 0, bottom_z, 1);\n"
4490 " gl_ViewportIndex = gl_InvocationID;\n"
4491 " gl_Position = vec4(-1, 0, top_z, 1);\n"
4493 " gl_ViewportIndex = gl_InvocationID;\n"
4494 " gl_Position = vec4(-1, 1, top_z, 1);\n"
4496 " gl_ViewportIndex = gl_InvocationID;\n"
4497 " gl_Position = vec4(1, 0, top_z, 1);\n"
4499 " gl_ViewportIndex = gl_InvocationID;\n"
4500 " gl_Position = vec4(1, 1, top_z, 1);\n"
4502 " EndPrimitive();\n"
4506 std::string result = source;
4513 * @return DEPTHRANGE
4515 DrawTestBase::TEST_TYPE DepthRangeDepthTest::getTestType()
4520 /** Prepare textures used as framebuffer's attachments for current draw call
4522 * @param texture_0 R32F texture
4523 * @param texture_1 D32F texture
4525 void DepthRangeDepthTest::prepareTextures(Utils::texture& texture_0, Utils::texture& texture_1)
4527 prepareTextureR32F(texture_0);
4528 prepareTextureD32F(texture_1);
4531 /** Attach textures to framebuffer
4533 * @param framebuffer Framebuffer instance
4534 * @param texture_0 Texture attached as color 0
4535 * @param texture_1 Texture attached as depth
4537 void DepthRangeDepthTest::setupFramebuffer(Utils::framebuffer& framebuffer, Utils::texture& texture_0,
4538 Utils::texture& texture_1)
4540 framebuffer.attachTexture(GL_COLOR_ATTACHMENT0, texture_0.m_id, m_width, m_height);
4541 framebuffer.attachTexture(GL_DEPTH_ATTACHMENT, texture_1.m_id, m_width, m_height);
4544 /** Set up viewports
4547 * @param iteration_index Index of iteration for given test type
4549 void DepthRangeDepthTest::setupViewports(TEST_TYPE /* type */, GLuint iteration_index)
4551 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4553 DEPTH_RANGE_METHOD method;
4554 switch (iteration_index)
4558 method = (DEPTH_RANGE_METHOD)iteration_index;
4561 TCU_FAIL("Invalid value");
4563 setup16x2Depths(method);
4565 gl.enable(GL_DEPTH_TEST);
4566 GLU_EXPECT_NO_ERROR(gl.getError(), "Enable");
4571 * @param context Test context
4572 * @param test_name Test name
4573 * @param test_description Test description
4575 ProvokingVertex::ProvokingVertex(deqp::Context& context, const glcts::ExtParameters& extParams)
4576 : DrawTestBase(context, extParams, "provoking_vertex", "Test verifies that provoking vertex work as expected")
4578 /* Nothing to be done here */
4581 /** Check if R32I texture is filled with 4x4 regions of increasing values <0:15>
4583 * @param texture_0 Verified texture
4587 * @return True if texture_0 is filled with expected pattern
4589 bool ProvokingVertex::checkResults(Utils::texture& texture_0, Utils::texture& /* texture_1 */,
4590 GLuint /*draw_call_index */)
4592 static const GLuint layer_size = m_width * m_height;
4594 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
4595 const glu::ContextType& context_type = m_context.getRenderContext().getType();
4597 GLint layer_mode = 0;
4598 GLint viewport_mode = 0;
4599 gl.getIntegerv(GL_LAYER_PROVOKING_VERTEX, &layer_mode);
4600 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
4601 gl.getIntegerv(GL_VIEWPORT_INDEX_PROVOKING_VERTEX, &viewport_mode);
4602 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
4604 if ((GL_UNDEFINED_VERTEX == layer_mode) || (GL_UNDEFINED_VERTEX == viewport_mode))
4606 /* Results are undefined, therefore it does not make sense to verify them */
4610 bool check_result = true;
4611 GLint provoking = 0;
4613 std::vector<GLint> texture_data;
4614 texture_data.resize(layer_size * m_r32ix4_depth);
4615 texture_0.get(GL_RED_INTEGER, GL_INT, &texture_data[0]);
4617 if (glu::isContextTypeGLCore(context_type))
4619 gl.getIntegerv(GL_PROVOKING_VERTEX, &provoking);
4620 GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
4624 DE_ASSERT(glu::isContextTypeES(context_type));
4625 /* ES doesn't have provoking vertex control, so it's always LAST */
4626 provoking = GL_LAST_VERTEX_CONVENTION;
4629 GLuint expected_layer = 0;
4630 GLint expected_viewport = 0;
4632 /* Mode is 1st, or mode is provoking and provoking is 1st */
4633 if ((GL_FIRST_VERTEX_CONVENTION == layer_mode) ||
4634 ((GL_PROVOKING_VERTEX == layer_mode) && (GL_FIRST_VERTEX_CONVENTION == provoking)))
4643 if ((GL_FIRST_VERTEX_CONVENTION == viewport_mode) ||
4644 ((GL_PROVOKING_VERTEX == viewport_mode) && (GL_FIRST_VERTEX_CONVENTION == provoking)))
4646 expected_viewport = 0;
4650 expected_viewport = 2;
4653 for (GLuint layer = 0; layer < m_r32ix4_depth; ++layer)
4655 GLint* layer_data = &texture_data[layer * layer_size];
4658 for (GLuint y = 0; y < 2; ++y)
4660 for (GLuint x = 0; x < 2; ++x)
4662 /* If layer and viewport are expected ones, than result shall be 1, otherwise -1. */
4663 const GLint expected_value = ((expected_viewport == viewport) && (expected_layer == layer)) ? 1 : -1;
4665 bool result = checkRegionR32I(x, y, m_width / 2, m_height / 2, expected_value, layer_data);
4667 if (false == result)
4669 check_result = false;
4679 return check_result;
4682 /** Get string with fragment shader source code
4684 * @return Fragment shader source
4686 std::string ProvokingVertex::getFragmentShader()
4688 static const GLchar* source = "${VERSION}\n"
4690 "flat in int gs_fs_color;\n"
4691 " out int fs_out_color;\n"
4695 " fs_out_color = gs_fs_color;\n"
4699 std::string result = source;
4704 /** Get string with geometry shader source code
4706 * @return Geometry shader source
4708 std::string ProvokingVertex::getGeometryShader()
4710 static const GLchar* source = "${VERSION}\n"
4712 "${GEOMETRY_SHADER_ENABLE}\n"
4713 "${VIEWPORT_ARRAY_ENABLE}\n"
4715 "layout(points, invocations = 1) in;\n"
4716 "layout(triangle_strip, max_vertices = 6) out;\n"
4718 "flat out int gs_fs_color;\n"
4722 " /* Left-bottom half */\n"
4723 " gs_fs_color = 1;\n"
4724 " gl_ViewportIndex = 0;\n"
4726 " gl_Position = vec4(-1, -1, 0, 1);\n"
4728 " gs_fs_color = 1;\n"
4729 " gl_ViewportIndex = 1;\n"
4731 " gl_Position = vec4(-1, 1, 0, 1);\n"
4733 " gs_fs_color = 1;\n"
4734 " gl_ViewportIndex = 2;\n"
4736 " gl_Position = vec4(1, -1, 0, 1);\n"
4738 " EndPrimitive();\n"
4740 " /* Right-top half */\n"
4741 " gs_fs_color = 1;\n"
4742 " gl_ViewportIndex = 0;\n"
4744 " gl_Position = vec4(-1, 1, 0, 1);\n"
4746 " gs_fs_color = 1;\n"
4747 " gl_ViewportIndex = 1;\n"
4749 " gl_Position = vec4(1, 1, 0, 1);\n"
4751 " gs_fs_color = 1;\n"
4752 " gl_ViewportIndex = 2;\n"
4754 " gl_Position = vec4(1, -1, 0, 1);\n"
4756 " EndPrimitive();\n"
4760 std::string result = source;
4769 DrawTestBase::TEST_TYPE ProvokingVertex::getTestType()
4774 /** Prepare textures used as framebuffer's attachments for current draw call
4776 * @param texture_0 R32I texture
4779 void ProvokingVertex::prepareTextures(Utils::texture& texture_0, Utils::texture& /* texture_1 */)
4781 prepareTextureR32Ix4(texture_0);
4784 } /* ViewportArray namespace */
4788 * @param context Rendering context.
4790 ViewportArrayTests::ViewportArrayTests(deqp::Context& context, const glcts::ExtParameters& extParams)
4791 : TestCaseGroupBase(context, extParams, "viewport_array", "Verifies \"viewport_array\" functionality")
4793 /* Left blank on purpose */
4796 /** Initializes a texture_storage_multisample test group.
4799 void ViewportArrayTests::init(void)
4801 addChild(new ViewportArray::APIErrors(m_context, m_extParams));
4802 addChild(new ViewportArray::Queries(m_context, m_extParams));
4803 addChild(new ViewportArray::ViewportAPI(m_context, m_extParams));
4804 addChild(new ViewportArray::ScissorAPI(m_context, m_extParams));
4805 addChild(new ViewportArray::DepthRangeAPI(m_context, m_extParams));
4806 addChild(new ViewportArray::ScissorTestStateAPI(m_context, m_extParams));
4807 addChild(new ViewportArray::DrawToSingleLayerWithMultipleViewports(m_context, m_extParams));
4808 addChild(new ViewportArray::DynamicViewportIndex(m_context, m_extParams));
4809 addChild(new ViewportArray::DrawMulitpleViewportsWithSingleInvocation(m_context, m_extParams));
4810 addChild(new ViewportArray::ViewportIndexSubroutine(m_context, m_extParams));
4811 addChild(new ViewportArray::DrawMultipleLayers(m_context, m_extParams));
4812 addChild(new ViewportArray::Scissor(m_context, m_extParams));
4813 addChild(new ViewportArray::ScissorZeroDimension(m_context, m_extParams));
4814 addChild(new ViewportArray::ScissorClear(m_context, m_extParams));
4815 addChild(new ViewportArray::DepthRange(m_context, m_extParams));
4816 addChild(new ViewportArray::DepthRangeDepthTest(m_context, m_extParams));
4817 addChild(new ViewportArray::ProvokingVertex(m_context, m_extParams));
4820 } /* glcts namespace */