1 #ifndef _GLCVIEWPORTARRAYTESTS_HPP
2 #define _GLCVIEWPORTARRAYTESTS_HPP
3 /*-------------------------------------------------------------------------
4 * OpenGL Conformance Test Suite
5 * -----------------------------
7 * Copyright (c) 2014-2016 The Khronos Group Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
24 */ /*-------------------------------------------------------------------*/
27 * \file glcViewportArrayTests.hpp
28 * \brief Declares test classes for "Viewport Array" functionality.
29 */ /*-------------------------------------------------------------------*/
31 #include "glcTestCase.hpp"
32 #include "glwDefs.hpp"
34 #include "esextcTestCaseBase.hpp"
43 namespace ViewportArray
65 buffer(deqp::Context& context);
70 void bindRange(glw::GLuint index, glw::GLintptr offset, glw::GLsizeiptr size);
72 void generate(glw::GLenum target);
73 void* map(glw::GLenum access) const;
76 void update(glw::GLsizeiptr size, glw::GLvoid* data, glw::GLenum usage);
81 deqp::Context& m_context;
87 framebuffer(deqp::Context& context);
90 void attachTexture(glw::GLenum attachment, glw::GLuint texture_id, glw::GLuint width, glw::GLuint height);
93 void clear(glw::GLenum mask);
95 void clearColor(glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue, glw::GLfloat alpha);
102 deqp::Context& m_context;
105 class shaderCompilationException : public std::exception
108 shaderCompilationException(const glw::GLchar* source, const glw::GLchar* message);
110 virtual ~shaderCompilationException() throw()
114 virtual const char* what() const throw();
116 std::string m_shader_source;
117 std::string m_error_message;
120 class programLinkageException : public std::exception
123 programLinkageException(const glw::GLchar* error_message);
125 virtual ~programLinkageException() throw()
129 virtual const char* what() const throw();
131 std::string m_error_message;
134 /** Store information about program object
139 program(deqp::Context& context);
142 void build(const glw::GLchar* compute_shader_code, const glw::GLchar* fragment_shader_code,
143 const glw::GLchar* geometry_shader_code, const glw::GLchar* tesselation_control_shader_code,
144 const glw::GLchar* tesselation_evaluation_shader_code, const glw::GLchar* vertex_shader_code,
145 const glw::GLchar* const* varying_names, glw::GLuint n_varying_names, bool is_separable = false);
147 void compile(glw::GLuint shader_id, const glw::GLchar* source) const;
149 glw::GLint getAttribLocation(const glw::GLchar* name) const;
151 glw::GLuint getSubroutineIndex(const glw::GLchar* subroutine_name, glw::GLenum shader_stage) const;
153 glw::GLint getSubroutineUniformLocation(const glw::GLchar* uniform_name, glw::GLenum shader_stage) const;
155 glw::GLint getUniformLocation(const glw::GLchar* uniform_name) const;
162 static void printShaderSource(const glw::GLchar* source, tcu::MessageBuilder& log);
164 static const glw::GLenum ARB_COMPUTE_SHADER;
166 glw::GLuint m_compute_shader_id;
167 glw::GLuint m_fragment_shader_id;
168 glw::GLuint m_geometry_shader_id;
169 glw::GLuint m_program_object_id;
170 glw::GLuint m_tesselation_control_shader_id;
171 glw::GLuint m_tesselation_evaluation_shader_id;
172 glw::GLuint m_vertex_shader_id;
175 deqp::Context& m_context;
180 texture(deqp::Context& context);
185 void create(glw::GLuint width, glw::GLuint height, glw::GLenum internal_format);
187 void create(glw::GLuint width, glw::GLuint height, glw::GLuint depth, glw::GLenum internal_format);
189 void get(glw::GLenum format, glw::GLenum type, glw::GLvoid* out_data) const;
193 void update(glw::GLuint width, glw::GLuint height, glw::GLuint depth, glw::GLenum format, glw::GLenum type,
198 glw::GLuint m_height;
202 deqp::Context& m_context;
208 vertexArray(deqp::Context& Context);
217 deqp::Context& m_context;
220 class DepthFuncWrapper
223 DepthFuncWrapper(deqp::Context& context) : m_gl(context.getRenderContext().getFunctions()){};
224 ~DepthFuncWrapper(){};
226 void depthRangeArray(glw::GLuint first, glw::GLsizei count, const glw::GLfloat* v)
228 m_gl.depthRangeArrayfvOES(first, count, v);
231 void depthRangeArray(glw::GLuint first, glw::GLsizei count, const glw::GLdouble* v)
233 m_gl.depthRangeArrayv(first, count, v);
236 void depthRangeIndexed(glw::GLuint index, glw::GLfloat n, glw::GLfloat f)
238 m_gl.depthRangeIndexedfOES(index, n, f);
241 void depthRangeIndexed(glw::GLuint index, glw::GLdouble n, glw::GLdouble f)
243 m_gl.depthRangeIndexed(index, n, f);
246 void depthRange(glw::GLfloat near, glw::GLfloat far)
248 m_gl.depthRangef(near, far);
251 void depthRange(glw::GLdouble near, glw::GLdouble far)
253 m_gl.depthRange(near, far);
256 void getDepthi_v(glw::GLenum target, glw::GLuint index, glw::GLfloat* data)
258 m_gl.getFloati_v(target, index, data);
261 void getDepthi_v(glw::GLenum target, glw::GLuint index, glw::GLdouble* data)
263 m_gl.getDoublei_v(target, index, data);
266 const glw::Functions& getFunctions()
272 const glw::Functions& m_gl;
276 /** Implements test APIErrors, description follows:
278 * Verify that API generate errors as specified. Check that:
279 * * DepthRangeArrayv generates INVALID_VALUE when <first> + <count> is greater
280 * than or equal to the value of MAX_VIEWPORTS;
281 * * DepthRangeIndexed generates INVALID_VALUE when <index> is greater than or
282 * equal to the value of MAX_VIEWPORTS;
283 * * ViewportArrayv generates INVALID_VALUE when <first> + <count> is greater
284 * than or equal to the value of MAX_VIEWPORTS;
285 * * ViewportIndexedf and ViewportIndexedfv generate INVALID_VALUE when <index>
286 * is greater than or equal to the value of MAX_VIEWPORTS;
287 * * ViewportArrayv, Viewport, ViewportIndexedf and ViewportIndexedfv generate
288 * INVALID_VALUE when <w> or <h> values are negative;
289 * * ScissorArrayv generates INVALID_VALUE when <first> + <count> is greater
290 * than or equal to the value of MAX_VIEWPORTS;
291 * * ScissorIndexed and ScissorIndexedv generate INVALID_VALUE when <index> is
292 * greater than or equal to the value of MAX_VIEWPORTS;
293 * * ScissorArrayv, ScissorIndexed, ScissorIndexedv and Scissor generate
294 * INVALID_VALUE when <width> or <height> values are negative;
295 * * Disablei, Enablei and IsEnabledi generate INVALID_VALUE when <cap> is
296 * SCISSOR_TEST and <index> is greater than or equal to the
297 * value of MAX_VIEWPORTS;
298 * * GetIntegeri_v generates INVALID_VALUE when <target> is SCISSOR_BOX and
299 * <index> is greater than or equal to the value of MAX_VIEWPORTS;
300 * * GetFloati_v generates INVALID_VALUE when <target> is VIEWPORT and <index>
301 * is greater than or equal to the value of MAX_VIEWPORTS;
302 * * GetDoublei_v generates INVALID_VALUE when <target> is DEPTH_RANGE and
303 * <index> is greater than or equal to the value of MAX_VIEWPORTS;
305 class APIErrors : public glcts::TestCaseBase
309 APIErrors(deqp::Context& context, const glcts::ExtParameters& extParams);
315 /* Public methods inherited from TestCaseBase */
316 virtual IterateResult iterate(void);
319 template <typename T>
320 void depthRangeArrayHelper(Utils::DepthFuncWrapper& depthFunc, glw::GLint max_viewports, bool& test_result,
323 template <typename T>
324 void depthRangeIndexedHelper(Utils::DepthFuncWrapper& depthFunc, glw::GLint max_viewports, bool& test_result,
327 template <typename T>
328 void getDepthHelper(Utils::DepthFuncWrapper& depthFunc, glw::GLint max_viewports, bool& test_result,
331 void checkGLError(glw::GLenum expected_error, const glw::GLchar* description, bool& out_result);
334 /** Implements test Queries, description follows:
337 * * Initial dimensions of VIEWPORT returned by GetFloati_v match dimensions of
338 * the window into which GL is rendering;
339 * * Initial values of DEPTH_RANGE returned by GetDoublei_v are [0, 1];
340 * * Initial state of SCISSOR_TEST returned by IsEnabledi is FALSE;
341 * * Initial dimensions of SCISSOR_BOX returned by GetIntegeri_v are either
342 * zeros or match dimensions of the window into which GL is rendering;
343 * * Dimensions of MAX_VIEWPORT_DIMS returned by GetFloati_v are at least
344 * as big as supported dimensions of render buffers, see MAX_RENDERBUFFER_SIZE;
345 * * Value of MAX_VIEWPORTS returned by GetIntegeri_v is at least 16;
346 * * Value of VIEWPORT_SUBPIXEL_BITS returned by GetIntegeri_v is at least 0;
347 * * Values of VIEWPORT_BOUNDS_RANGE returned by GetFloatv are
348 * at least [-32768, 32767];
349 * * Values of LAYER_PROVOKING_VERTEX and VIEWPORT_INDEX_PROVOKING_VERTEX
350 * returned by GetIntegerv are located in the following set
351 * { FIRST_VERTEX_CONVENTION, LAST_VERTEX_CONVENTION, PROVOKING_VERTEX,
352 * UNDEFINED_VERTEX };
354 class Queries : public glcts::TestCaseBase
358 Queries(deqp::Context& context, const glcts::ExtParameters& extParams);
364 /* Public methods inherited from TestCase */
365 virtual tcu::TestNode::IterateResult iterate(void);
368 template <typename T>
369 void depthRangeInitialValuesHelper(Utils::DepthFuncWrapper& depthFunc, glw::GLint max_viewports, bool& test_result,
373 /** Implements test ViewportAPI, description follows:
375 * Verify that VIEWPORT can be set and queried.
377 * - get initial dimensions of VIEWPORT for all MAX_VIEWPORTS indices;
378 * - change location and dimensions of all indices at once with
380 * - get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
382 * * modify with ViewportIndexedf,
383 * * get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
384 * * modify with ViewportIndexedfv,
385 * * get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
387 * * modify all indices before and after current one with ViewportArrayv,
388 * * get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
389 * - change location and dimensions of all indices at once with Viewport;
390 * - get VIEWPORT for all MAX_VIEWPORTS indices and verify results;
392 class ViewportAPI : public glcts::TestCaseBase
396 ViewportAPI(deqp::Context& context, const glcts::ExtParameters& extParams);
398 virtual ~ViewportAPI()
402 /* Public methods inherited from TestCase */
403 virtual tcu::TestNode::IterateResult iterate(void);
406 /* Private methods */
407 void compareViewports(std::vector<glw::GLfloat>& left, std::vector<glw::GLfloat>& right,
408 const glw::GLchar* description, bool& out_result);
410 void getViewports(glw::GLint max_viewports, std::vector<glw::GLfloat>& out_data);
412 /* Private constants */
413 static const glw::GLuint m_n_elements;
416 /** Implements test ScissorAPI, description follows:
418 * Verify that SCISSOR_BOX can be set and queried.
420 * - get initial dimensions of SCISSOR_BOX for all MAX_VIEWPORTS indices;
421 * - change location and dimensions of all indices at once with
423 * - get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
425 * * modify with ScissorIndexed,
426 * * get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
427 * * modify with ScissorIndexedv,
428 * * get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
430 * * modify all indices before and after current one with ScissorArrayv,
431 * * get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
432 * - change location and dimensions of all indices at once with Scissor;
433 * - get SCISSOR_BOX for all MAX_VIEWPORTS indices and verify results;
435 class ScissorAPI : public glcts::TestCaseBase
439 ScissorAPI(deqp::Context& context, const glcts::ExtParameters& extParams);
441 virtual ~ScissorAPI()
445 /* Public methods inherited from TestCase */
446 virtual tcu::TestNode::IterateResult iterate(void);
449 /* Private methods */
450 void compareScissorBoxes(std::vector<glw::GLint>& left, std::vector<glw::GLint>& right,
451 const glw::GLchar* description, bool& out_result);
453 void getScissorBoxes(glw::GLint max_viewports, std::vector<glw::GLint>& out_data);
455 /* Private constants */
456 static const glw::GLuint m_n_elements;
459 /** Implements test DepthRangeAPI, description follows:
461 * Verify that DEPTH_RANGE can be set and queried.
463 * - get initial values of DEPTH_RANGE for all MAX_VIEWPORTS indices;
464 * - change values of all indices at once with DepthRangeArrayv;
465 * - get DEPTH_RANGE for all MAX_VIEWPORTS indices and verify results;
467 * * modify with DepthRangeIndexed,
468 * * get DEPTH_RANGE for all MAX_VIEWPORTS indices and verify results;
470 * * modify all indices before and after current one with DepthRangeArrayv,
471 * * get DEPTH_RANGE for all MAX_VIEWPORTS indices and verify results;
472 * - change values of all indices at once with DepthRange;
473 * - get DEPTH_RANGE for all MAX_VIEWPORTS indices and verify results;
475 class DepthRangeAPI : public glcts::TestCaseBase
479 DepthRangeAPI(deqp::Context& context, const glcts::ExtParameters& extParams);
481 virtual ~DepthRangeAPI()
485 /* Public methods inherited from TestCase */
486 virtual tcu::TestNode::IterateResult iterate(void);
489 /* Private methods */
490 template <typename T>
491 void compareDepthRanges(std::vector<T>& left, std::vector<T>& right, const glw::GLchar* description,
494 template <typename T>
495 void getDepthRanges(Utils::DepthFuncWrapper& depthFunc, glw::GLint max_viewports, std::vector<T>& out_data);
497 template <typename T>
498 bool iterateHelper(T* data = NULL);
500 /* Private constants */
501 static const glw::GLuint m_n_elements;
504 /** Implements test ScissorTestStateAPI, description follows:
506 * Verify that state of SCISSOR_TEST can be set and queried.
508 * - get initial state of SCISSOR_TEST for all MAX_VIEWPORTS indices;
510 * * toggle SCISSOR_TEST,
511 * * get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
513 * * toggle SCISSOR_TEST,
514 * * get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
515 * - enable SCISSOR_TEST for all indices at once with Enable;
516 * - get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
517 * - disable SCISSOR_TEST for all indices at once with Disable;
518 * - get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
519 * - enable SCISSOR_TEST for all indices at once with Enable;
520 * - get state of SCISSOR_TEST for all MAX_VIEWPORTS indices and verify;
522 class ScissorTestStateAPI : public glcts::TestCaseBase
526 ScissorTestStateAPI(deqp::Context& context, const glcts::ExtParameters& extParams);
528 virtual ~ScissorTestStateAPI()
532 /* Public methods inherited from TestCase */
533 virtual tcu::TestNode::IterateResult iterate(void);
536 /* Private methods */
537 void compareScissorTestStates(std::vector<glw::GLboolean>& left, std::vector<glw::GLboolean>& right,
538 const glw::GLchar* description, bool& out_result);
540 void getScissorTestStates(glw::GLint max_viewports, std::vector<glw::GLboolean>& out_data);
543 class DrawTestBase : public glcts::TestCaseBase
547 DrawTestBase(deqp::Context& context, const glcts::ExtParameters& extParams, const glw::GLchar* test_name,
548 const glw::GLchar* test_description);
550 virtual ~DrawTestBase()
554 /* Public methods inherited from TestCase */
555 virtual tcu::TestNode::IterateResult iterate(void);
558 /* Protected enums */
571 enum DEPTH_RANGE_METHOD
573 DEPTHRANGEARRAYV = 0,
576 enum PROVOKING_VERTEX
589 /* Protected methods to be implemented by child class */
590 virtual bool checkResults(Utils::texture& texture_0, Utils::texture& texture_1, glw::GLuint draw_call_index);
592 virtual void getClearSettings(bool& clear_depth_before_draw, glw::GLuint iteration_index,
593 glw::GLfloat& depth_value);
595 virtual glw::GLuint getDrawCallsNumber();
596 virtual std::string getFragmentShader() = 0;
597 virtual std::string getGeometryShader() = 0;
598 virtual TEST_TYPE getTestType();
599 virtual bool isClearTest();
601 virtual void prepareTextures(Utils::texture& texture_0, Utils::texture& texture_1);
603 virtual void prepareUniforms(Utils::program& program, glw::GLuint draw_call_index);
605 virtual void setupFramebuffer(Utils::framebuffer& framebuffer, Utils::texture& texture_0,
606 Utils::texture& texture_1);
608 virtual void setupViewports(TEST_TYPE type, glw::GLuint iteration_index);
610 /* Methods available for child class */
611 bool checkRegionR32I(glw::GLuint x, glw::GLuint y, glw::GLint expected_value, glw::GLint* data);
613 bool checkRegionR32I(glw::GLuint x, glw::GLuint y, glw::GLuint width, glw::GLuint height, glw::GLint expected_value,
616 void prepareTextureR32I(Utils::texture& texture);
617 void prepareTextureR32Ix4(Utils::texture& texture);
618 void prepareTextureArrayR32I(Utils::texture& texture);
619 void prepareTextureR32F(Utils::texture& texture);
620 void prepareTextureD32F(Utils::texture& texture);
621 void setup16x2Depths(DEPTH_RANGE_METHOD method);
622 void setup4x4Scissor(SCISSOR_METHOD method, bool set_zeros);
623 void setup4x4Viewport(VIEWPORT_METHOD method);
624 void setup2x2Viewport(PROVOKING_VERTEX provoking);
626 /* Constants available to child class */
627 static const glw::GLuint m_depth;
628 static const glw::GLuint m_height;
629 static const glw::GLuint m_width;
630 static const glw::GLuint m_r32f_height;
631 static const glw::GLuint m_r32f_width;
632 static const glw::GLuint m_r32ix4_depth;
635 /* Private methods */
636 std::string getVertexShader();
638 template <typename T>
639 void setup16x2DepthsHelper(DEPTH_RANGE_METHOD method, T* data = NULL);
642 /** Implements test DrawToSingleLayerWithMultipleViewports, description follows:
644 * Verify that multiple viewports can be used to draw to single image.
646 * - prepare 2D R32I 128x128 texture filled with value -1 and set it up as
647 * COLOR_ATTACHMENT_0;
648 * - prepare program that consist of:
649 * * boilerplate vertex shader,
651 * * fragment shaders;
652 * Geometry shader should output a quad (-1,-1 : 1,1) made of
653 * triangle_strip; gl_ViewportIndex and declared integer varying "color"
654 * should be assigned the value of gl_InvocationID; Amount of geometry shader
655 * invocations should be set to 16; Fragment shader should output value of
656 * varying "color" to attachment 0.
657 * - set up first 16 viewports with following code snippet:
660 * for (y = 0; y < 4; ++y)
661 * for (x = 0; x < 4; ++x)
662 * ViewportIndexedf(index++,
667 * - draw single vertex;
668 * - inspect contents of COLOR_ATTACHMENT_0;
669 * - test pass if image is filled with the following pattern:
676 * Each area should be 32x32 pixels rectangle;
677 * - repeat test with functions ViewportIndexedf_v and ViewportArrayv;
679 class DrawToSingleLayerWithMultipleViewports : public DrawTestBase
683 DrawToSingleLayerWithMultipleViewports(deqp::Context& context, const glcts::ExtParameters& extParams);
685 virtual ~DrawToSingleLayerWithMultipleViewports()
690 /* Protected methods inherited from DrawTestBase */
691 virtual std::string getFragmentShader();
692 virtual std::string getGeometryShader();
695 /** Implements test DynamicViewportIndex, description follows:
697 * Verify that gl_ViewportIndex can be set in dynamic manner.
698 * Modify DrawToSingleLayerWithMultipleViewports in the following aspects:
699 * - geometry shader should declare unsigned integer uniform "index";
700 * - geometry shader should assign a value of "index" to gl_ViewportIndex and
702 * - amount of geometry shader invocations should be set to 1;
704 * * set "index" to unique value from range <0:15>;
705 * * draw single vertex;
706 * * verify that only area of viewport at "index" has been updated;
707 * - test pass if correct pixels were modified in each draw;
709 class DynamicViewportIndex : public DrawTestBase
713 DynamicViewportIndex(deqp::Context& context, const glcts::ExtParameters& extParams);
715 virtual ~DynamicViewportIndex()
720 /* Protected methods inherited from DrawTestBase */
721 virtual bool checkResults(Utils::texture& texture_0, Utils::texture& texture_1, glw::GLuint draw_call_index);
723 virtual std::string getFragmentShader();
724 virtual std::string getGeometryShader();
725 virtual glw::GLuint getDrawCallsNumber();
727 virtual void prepareUniforms(Utils::program& program, glw::GLuint draw_call_index);
730 /** Implements test DrawMulitpleViewportsWithSingleInvocation, description follows:
732 * Verify that multiple viewports can be affected by single invocation of
734 * Modify DrawToSingleLayerWithMultipleViewports in the following aspects:
735 * - geometry shader should output 16 quads, as separate primitives;
736 * - instead of gl_InvocationID, geometry shader should use predefined values
737 * from range <0:15>, unique per quad;
738 * - amount of geometry shader invocations should be set to 1;
740 class DrawMulitpleViewportsWithSingleInvocation : public DrawTestBase
744 DrawMulitpleViewportsWithSingleInvocation(deqp::Context& context, const glcts::ExtParameters& extParams);
746 virtual ~DrawMulitpleViewportsWithSingleInvocation()
751 /* Protected methods inherited from DrawTestBase */
752 virtual std::string getFragmentShader();
753 virtual std::string getGeometryShader();
756 /** Implements test ViewportIndexSubroutine, description follows:
758 * Verify that gl_ViewportIndex can be assigned by subroutine.
759 * Depends on: ARB_shader_subroutine.
760 * Modify DynamicViewportIndex in the following aspects:
761 * - geometry shader should define two subroutines and single subroutine
762 * uniform; First subroutine should assign value 4 to gl_ViewportIndex and
763 * "color"; Second subroutine should assign value 5 to gl_ViewportIndex and
764 * "color"; subroutine should be called once per emitted vertex;
765 * - uniform "index" should be removed;
766 * - viewport 4 should be configured to span over left half of image; viewport
767 * 5 should span over right half of image;
768 * - set up first subroutine and draw single vertex;
769 * - set up second subroutine and draw single vertex;
770 * - test pass if left half of image is filled with value 4 and right one with
773 class ViewportIndexSubroutine : public DrawTestBase
777 ViewportIndexSubroutine(deqp::Context& context, const glcts::ExtParameters& extParams);
779 virtual ~ViewportIndexSubroutine()
783 /* Public methods inherited from TestCase/DrawTestBase */
784 virtual tcu::TestNode::IterateResult iterate(void);
787 /* Protected methods inherited from DrawTestBase */
788 virtual bool checkResults(Utils::texture& texture_0, Utils::texture& texture_1, glw::GLuint draw_call_index);
790 virtual std::string getFragmentShader();
791 virtual std::string getGeometryShader();
792 virtual glw::GLuint getDrawCallsNumber();
794 virtual void prepareUniforms(Utils::program& program, glw::GLuint draw_call_index);
796 virtual void setupViewports(TEST_TYPE type, glw::GLuint iteration_index);
799 /** Implements test DrawMultipleLayers, description follows:
801 * Verify that single viewport affects multiple layers in the same way.
802 * Modify DynamicViewportIndex in the following aspects:
803 * - texture should be 2D array with 16 layers;
804 * - geometry shader should assign a value of gl_InvocationId to gl_Layer;
805 * - amount of geometry shader invocations should be set to 16;
806 * - verification should be applied to all 16 layers;
808 class DrawMultipleLayers : public DrawTestBase
812 DrawMultipleLayers(deqp::Context& context, const glcts::ExtParameters& extParams);
814 DrawMultipleLayers(deqp::Context& context, const glcts::ExtParameters& extParams, const glw::GLchar* test_name,
815 const glw::GLchar* test_description);
817 virtual ~DrawMultipleLayers()
822 /* Protected methods inherited from DrawTestBase */
823 virtual bool checkResults(Utils::texture& texture_0, Utils::texture& texture_1, glw::GLuint draw_call_index);
825 virtual std::string getFragmentShader();
826 virtual std::string getGeometryShader();
828 virtual void prepareTextures(Utils::texture& texture_0, Utils::texture& texture_1);
831 /** Implements test Scissor, description follows:
833 * Verify that scissor test is applied as expected.
834 * Modify DrawMultipleLayers in the following aspects:
835 * - set all viewports to location 0,0 and dimensions 128x128;
836 * - set up first 16 scissor boxes with following code snippet:
839 * for (y = 0; y < 4; ++y)
840 * for (x = 0; x < 4; ++x)
841 * ScissorIndexed(index++,
847 * - enable SCISSORT_TEST for first 16 indices;
848 * - verification should be concerned with areas of the scissor boxes not
850 * - repeat test with functions ScissorIndexedv and ScissorArrayv;
852 class Scissor : public DrawMultipleLayers
856 Scissor(deqp::Context& context, const glcts::ExtParameters& extParams);
863 /* Protected methods inherited from DrawTestBase */
864 virtual TEST_TYPE getTestType();
867 /** Implements test ScissorZeroDimension, description follows:
869 * Verify that scissor test discard all fragments when width and height is set
871 * Modify Scissor to set up width and height of scissor boxes to 0.
872 * Test pass if no pixel is modified.
874 class ScissorZeroDimension : public DrawMultipleLayers
878 ScissorZeroDimension(deqp::Context& context, const glcts::ExtParameters& extParams);
880 virtual ~ScissorZeroDimension()
885 /* Protected methods inherited from DrawTestBase */
886 virtual bool checkResults(Utils::texture& texture_0, Utils::texture& texture_1, glw::GLuint draw_call_index);
888 virtual TEST_TYPE getTestType();
890 virtual void setupViewports(TEST_TYPE type, glw::GLuint iteration_index);
893 /** Implements test ScissorClear, description follows:
895 * Verify that Clear is affected only by settings of scissor test in first
898 * - prepare 2D 128x128 R32I texture, filled with value -1 and set it as
899 * COLOR_ATTACHMENT_0;
900 * - configure first 16 viewports as in Scissor;
901 * - enable SCISSOR_TEST for first 16 indices;
902 * - clear framebuffer to (0, 0, 0, 0);
904 * - test pass if only area corresponding with first SCISSOR_BOX was filled
905 * with 0, while rest of image remain filled with value -1;
907 class ScissorClear : public DrawMultipleLayers
911 ScissorClear(deqp::Context& context, const glcts::ExtParameters& extParams);
913 virtual ~ScissorClear()
918 /* Protected methods inherited from DrawTestBase */
919 virtual bool checkResults(Utils::texture& texture_0, Utils::texture& texture_1, glw::GLuint draw_call_index);
921 virtual TEST_TYPE getTestType();
922 virtual bool isClearTest();
925 /** Implements test DepthRange, description follows:
927 * Verify that depth range is applied as expected.
929 * - prepate 2D 16x2 R32F texture filled with value -1.0 and set it up as
930 * COLOR_ATTACHMENT_0;
931 * - prepare program that consist of:
932 * * boilerplate vertex shader,
935 * Geometry shader should emit two quads:
936 * * -1,0 : 1,1 with z equal -1.0,
937 * * -1,-1 : 1,0 with z equal 1.0,
938 * made of triangle_strip; gl_ViewportIndex should be assigned an value of
939 * gl_InvocationId; Amount of geometry shader invocations should be set to 16;
940 * Fragment shader should output value of gl_FragCoord.z to attachment 0.
941 * - set up first 16 viewports with the following code snippet:
943 * const double step = 1.0 / 16.0;
944 * for (index = 0; index < 16; ++index)
946 * const double near = ((double) i) * step;
947 * VieportIndexed (i, (float) i, 0.0, 1.0, 2.0);
948 * DepthRangeIndexed(i, near, 1.0 - near);
951 * - draw single vertex;
952 * - inspect contents of COLOR_ATTACHMENT_0;
954 * * top row of image is filled with increasing values, starting at 0 with
956 * * bottom row of image is filled with decreasing values, starting at 1 with
958 * - repeat test with function DepthRangeArrayv;
960 class DepthRange : public DrawTestBase
964 DepthRange(deqp::Context& context, const glcts::ExtParameters& extParams);
965 virtual ~DepthRange()
970 /* Protected methods inherited from DrawTestBase */
971 virtual bool checkResults(Utils::texture& texture_0, Utils::texture& texture_1, glw::GLuint draw_call_index);
973 virtual std::string getFragmentShader();
974 virtual std::string getGeometryShader();
975 virtual TEST_TYPE getTestType();
977 virtual void prepareTextures(Utils::texture& texture_0, Utils::texture& texture_1);
980 /** Implements test DepthRangeDepthTest, description follows:
982 * Verify that depth test work as expected with multiple viewports.
983 * Modify DepthRange test in the following aspect:
984 * - add second 2D 16x2 DEPTH_COMPONENT32F texture and set it up as
986 * - enable DEPTH_TEST;
987 * - DepthFunc should be set to LESS (initial value);
989 * * set ClearDepth to "i" * 1/16, starting at 0 up to 17/16,
990 * * draw single vertex
991 * * verify contents of color attachment;
992 * - test pass when color attachment is filled only with values lower than
993 * current ClearDepth value;
995 class DepthRangeDepthTest : public DrawTestBase
999 DepthRangeDepthTest(deqp::Context& context, const glcts::ExtParameters& extParams);
1001 virtual ~DepthRangeDepthTest()
1006 /* Protected methods inherited from DrawTestBase */
1007 virtual bool checkResults(Utils::texture& texture_0, Utils::texture& texture_1, glw::GLuint draw_call_index);
1009 virtual void getClearSettings(bool& clear_depth_before_draw, glw::GLuint iteration_index,
1010 glw::GLfloat& depth_value);
1012 virtual glw::GLuint getDrawCallsNumber();
1013 virtual std::string getFragmentShader();
1014 virtual std::string getGeometryShader();
1015 virtual TEST_TYPE getTestType();
1017 virtual void prepareTextures(Utils::texture& texture_0, Utils::texture& texture_1);
1019 virtual void setupFramebuffer(Utils::framebuffer& framebuffer, Utils::texture& texture_0,
1020 Utils::texture& texture_1);
1022 virtual void setupViewports(TEST_TYPE type, glw::GLuint iteration_index);
1025 /** Implements test ProvokingVertex, description follows:
1027 * Verify that provoking vertex work as expected.
1029 * - prepare 2D array R32I 128x128x4 texture and configure it as
1030 * COLOR_ATTACHMENT_0;
1031 * - prepare program consisting of:
1032 * * boilerplate vertex shader,
1033 * * geometry shader,
1034 * * fragment shader;
1035 * Geometry shader should output a quad (-1,-1 : 1,1); Each vertex should
1036 * receive different gl_ViewportIndex value, first vertex should be assigned an
1037 * 0, second 1, third 2, fourth 3; gl_Layer should be set in the same way as
1038 * gl_ViewportIndex; Fragment shader should output integer of value 1;
1039 * - configure first four viewports to form 2x2 grid, spanning whole image;
1040 * - for each combination of LAYER_PROVOKING_VERTEX and
1041 * VIEWPORT_INDEX_PROVOKING_VERTEX:
1042 * * clear framebuffer to (0,0,0,0),
1043 * * draw single vertex
1045 * - test pass if correct area of correct layer is filled with value 1, while
1046 * rest of image remains "clean";
1048 * - for UNDEFINED_VERTEX any selection is correct;
1049 * - for PROVOKING_VERTEX convention is selected by function ProvokingVertex;
1050 * Test all possible combinations;
1052 class ProvokingVertex : public DrawTestBase
1055 /* Public methods */
1056 ProvokingVertex(deqp::Context& context, const glcts::ExtParameters& extParams);
1058 virtual ~ProvokingVertex()
1063 /* Protected methods inherited from DrawTestBase */
1064 virtual bool checkResults(Utils::texture& texture_0, Utils::texture& texture_1, glw::GLuint draw_call_index);
1066 virtual std::string getFragmentShader();
1067 virtual std::string getGeometryShader();
1068 virtual TEST_TYPE getTestType();
1070 virtual void prepareTextures(Utils::texture& texture_0, Utils::texture& texture_1);
1072 } /* ViewportArray namespace */
1074 /** Group class for Shader Language 420Pack conformance tests */
1075 class ViewportArrayTests : public glcts::TestCaseGroupBase
1078 /* Public methods */
1079 ViewportArrayTests(deqp::Context& context, const glcts::ExtParameters& extParams);
1081 virtual ~ViewportArrayTests(void)
1085 virtual void init(void);
1088 /* Private methods */
1089 ViewportArrayTests(const ViewportArrayTests& other);
1090 ViewportArrayTests& operator=(const ViewportArrayTests& other);
1095 #endif // _GLCVIEWPORTARRAYTESTS_HPP