Home | History | Annotate | Download | only in gl
      1 #ifndef _GL4CCONDITIONALRENDERINVERTEDTESTS_HPP
      2 #define _GL4CCONDITIONALRENDERINVERTEDTESTS_HPP
      3 /*-------------------------------------------------------------------------
      4  * OpenGL Conformance Test Suite
      5  * -----------------------------
      6  *
      7  * Copyright (c) 2015-2016 The Khronos Group Inc.
      8  *
      9  * Licensed under the Apache License, Version 2.0 (the "License");
     10  * you may not use this file except in compliance with the License.
     11  * You may obtain a copy of the License at
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     15  * Unless required by applicable law or agreed to in writing, software
     16  * distributed under the License is distributed on an "AS IS" BASIS,
     17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18  * See the License for the specific language governing permissions and
     19  * limitations under the License.
     20  *
     21  */ /*!
     22  * \file
     23  * \brief
     24  */ /*-------------------------------------------------------------------*/
     25 
     26 /**
     27  */ /*!
     28  * \file  gl4cConditionalRenderInvertedTests.hpp
     29  * \brief Conformance tests for Conditional Render Inverted feature functionality.
     30  */ /*------------------------------------------------------------------------------*/
     31 
     32 /* Includes. */
     33 
     34 #include "glcTestCase.hpp"
     35 #include "glwDefs.hpp"
     36 #include "tcuDefs.hpp"
     37 
     38 #include "glwEnums.hpp"
     39 #include "glwFunctions.hpp"
     40 
     41 /* Interface. */
     42 
     43 namespace gl4cts
     44 {
     45 namespace ConditionalRenderInverted
     46 {
     47 /** @class Tests
     48  *
     49  *  @brief Conditional Render Inverted Test Group.
     50  */
     51 class Tests : public deqp::TestCaseGroup
     52 {
     53 public:
     54 	/* Public member functions. */
     55 	Tests(deqp::Context& context);
     56 
     57 	void init();
     58 
     59 private:
     60 	/* Private member functions. */
     61 	Tests(const Tests& other);
     62 	Tests& operator=(const Tests& other);
     63 };
     64 
     65 /** @class CoverageTest
     66  *
     67  *  @brief Conditional Render Inverted API Coverage Test.
     68  *
     69  *  The test checks that following modes:
     70  *      QUERY_WAIT_INVERTED                             0x8E17,
     71  *      QUERY_NO_WAIT_INVERTED                          0x8E18,
     72  *      QUERY_BY_REGION_WAIT_INVERTED                   0x8E19,
     73  *      QUERY_BY_REGION_NO_WAIT_INVERTED                0x8E1A,
     74  *   are accepted by BeginConditionalRender.
     75  *
     76  *  See reference: ARB_conditional_render_inverted extension specification or
     77  *                 Chapter 10 of the OpenGL 4.4 (Core Profile) Specification.
     78  */
     79 class CoverageTest : public deqp::TestCase
     80 {
     81 public:
     82 	/* Public member functions. */
     83 	CoverageTest(deqp::Context& context);
     84 
     85 	virtual tcu::TestNode::IterateResult iterate();
     86 
     87 private:
     88 	/* Private member functions */
     89 	CoverageTest(const CoverageTest& other);
     90 	CoverageTest& operator=(const CoverageTest& other);
     91 
     92 	void createQueryObject();
     93 	void clean();
     94 	bool test(glw::GLenum mode);
     95 
     96 	/* Private member variables. */
     97 	glw::GLuint m_qo_id;
     98 };
     99 /* class CoverageTest */
    100 
    101 /** @class FunctionalTest
    102  *
    103  *  @brief Conditional Render Inverted Functional Test.
    104  *
    105  *  The test runs as follows:
    106  *
    107  *  Prepare program consisting of vertex and fragment shader which draws
    108  *  full screen quad depending on vertex ID. Fragment shader shall be able
    109  *  discard fragments depending on uniform value. Return color shall also be
    110  *  controlled by uniform. Prepare 1x1 pixels' size framebuffer object with
    111  *  R8 format.
    112  *
    113  *  For each render case,
    114  *      for each query case,
    115  *          for each conditional render inverted mode,
    116  *              do the following:
    117  *              - create query object;
    118  *              - setup program to pass or discard fragments depending on
    119  *                render case;
    120  *              - setup color uniform to red component equal to 1;
    121  *              - clear framebuffer with red color component equal to 0.5;
    122  *              - draw quad using query object;
    123  *              - check that fragments passed or not using query object
    124  *                query;
    125  *                if program behaved not as expected return failure;
    126  *                note: query shall finish;
    127  *              - setup program to pass all fragments;
    128  *              - setup color uniform to red component equal to 0;
    129  *              - draw using the conditional rendering;
    130  *              - read framebuffer pixel;
    131  *              - expect that red component of the pixel is 1.0 if render
    132  *                case passes all pixels or 0.0 otherwise; if read color is
    133  *                different than expected, return failure;
    134  *              - cleanup query object.
    135  *  After loop, cleanup program and framebuffer. Return pass if all tests
    136  *  passed.
    137  *
    138  *  Test for following render cases:
    139  *  - all fragments passes,
    140  *  - all fragments are discarded.
    141  *
    142  *  Test for following query cases:
    143  *  - SAMPLES_PASSED,
    144  *  - GL_ANY_SAMPLES_PASSED.
    145  *
    146  *  Test for following conditional render inverted modes:
    147  *  - QUERY_WAIT_INVERTED,
    148  *  - QUERY_NO_WAIT_INVERTED,
    149  *  - QUERY_BY_REGION_WAIT_INVERTED,
    150  *  - QUERY_BY_REGION_NO_WAIT_INVERTED.
    151  *
    152  *  See reference: ARB_conditional_render_inverted extension specification or
    153  *                 Chapter 10 of the OpenGL 4.4 (Core Profile) Specification.
    154  */
    155 class FunctionalTest : public deqp::TestCase
    156 {
    157 public:
    158 	/* Public member functions. */
    159 	FunctionalTest(deqp::Context& context);
    160 
    161 	virtual tcu::TestNode::IterateResult iterate();
    162 
    163 private:
    164 	/* Private member functions. */
    165 	FunctionalTest(const FunctionalTest& other);
    166 	FunctionalTest& operator=(const FunctionalTest& other);
    167 
    168 	void createProgram();
    169 	void createVertexArrayObject();
    170 	void createView();
    171 	void createQueryObject();
    172 	void setupColor(const glw::GLfloat red);
    173 	void setupPassSwitch(const bool shall_pass);
    174 	void clearView();
    175 
    176 	void draw(const bool conditional_or_query_draw, const glw::GLenum condition_mode_or_query_target);
    177 
    178 	bool		 fragmentsPassed();
    179 	glw::GLfloat readPixel();
    180 	void		 cleanQueryObject();
    181 	void		 cleanProgramViewAndVAO();
    182 
    183 	/* Private member variables. */
    184 	glw::GLuint m_fbo_id; //!<    Test's framebuffer object id.
    185 	glw::GLuint m_rbo_id; //!<    Test's renderbuffer object id.
    186 	glw::GLuint m_vao_id; //!<    Test's vertex array object id.
    187 	glw::GLuint m_po_id;  //!<    Test's program object id.
    188 	glw::GLuint m_qo_id;  //!<    Test's query object id.
    189 
    190 	/* Private static constants. */
    191 	static const glw::GLchar s_vertex_shader[];		 //!<    Vertex shader source code.
    192 	static const glw::GLchar s_fragment_shader[];	//!<    Fragment shader source code.
    193 	static const glw::GLchar s_color_uniform_name[]; //!<    Name of the color uniform.
    194 	static const glw::GLchar
    195 							 s_pass_switch_uniform_name[]; //!<    Name of the fragment pass or discarded uniform switch.
    196 	static const glw::GLuint s_view_size;				   //!<    Size of view (1 by design).
    197 };
    198 /* class FunctionalTest*/
    199 
    200 namespace Utilities
    201 {
    202 const glw::GLchar* modeToChars(glw::GLenum mode);
    203 const glw::GLchar* queryTargetToChars(glw::GLenum mode);
    204 }
    205 
    206 } /* ConditionalRenderInverted namespace */
    207 } /* gl4cts namespace */
    208 
    209 #endif // _GL4CCONDITIONALRENDERINVERTEDTESTS_HPP
    210