1 #ifndef _GL4CCONTEXTFLUSHCONTROLTESTS_HPP 2 #define _GL4CCONTEXTFLUSHCONTROLTESTS_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 gl3cClipDistance.hpp 29 * \brief Conformance tests for Context Flush Control feature functionality. 30 */ /*-------------------------------------------------------------------*/ 31 32 #include "glcTestCase.hpp" 33 #include "glwDefs.hpp" 34 #include "tcuDefs.hpp" 35 36 /* Includes. */ 37 #include <map> 38 #include <string> 39 #include <typeinfo> 40 #include <vector> 41 42 #include "glwEnums.hpp" 43 #include "glwFunctions.hpp" 44 45 namespace gl4cts 46 { 47 namespace ContextFlushControl 48 { 49 /** @class Tests 50 * 51 * @brief Context Flush Control test group. 52 * 53 * The test checks that functions GetIntegerv, GetFloatv, GetBooleanv, GetDoublev and 54 * GetInteger64v accept parameter name GL_CONTEXT_RELEASE_BEHAVIOR and for 55 * default context returns GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH. 56 * 57 * If building target supports context flush (GLX framework which supports 58 * GLX_ARB_context_flush_control or WGL framework which supports 59 * WGL_ARB_context_flush_control) test makes new context with enabled context 60 * flush control functionality. Coverage test is repeated with this context and 61 * GL_NONE is expected to be returned. 62 * 63 * For reference see KHR_context_flush_control extension. 64 * 65 * The Pass result is returned when tests succeeded, Fail is returned otherwise. 66 */ 67 class Tests : public deqp::TestCaseGroup 68 { 69 public: 70 /* Public member functions */ 71 Tests(deqp::Context& context); 72 73 void init(); 74 75 private: 76 /* Private member functions */ 77 Tests(const Tests& other); 78 Tests& operator=(const Tests& other); 79 }; 80 81 /** @class CoverageTest 82 * 83 * @brief Context Flush Control API Coverage test. 84 */ 85 class CoverageTest : public deqp::TestCase 86 { 87 public: 88 /* Public member functions */ 89 CoverageTest(deqp::Context& context); 90 91 virtual tcu::TestNode::IterateResult iterate(); 92 93 private: 94 /* Private member functions */ 95 CoverageTest(const CoverageTest& other); 96 CoverageTest& operator=(const CoverageTest& other); 97 98 bool testQuery(glu::RenderContext& context, glw::GLenum expected_value); 99 glu::RenderContext* createNoFlushContext(); 100 }; 101 102 /** @class FunctionalTest 103 * 104 * @brief Context Flush Control Functional test. 105 * 106 * Test runs only if building target supports context flush (GLX framework 107 * which supports GLX_ARB_context_flush_control or WGL framework which 108 * supports WGL_ARB_context_flush_control). Test prepares 4 contexts: two with 109 * enabled context flush control and two with disabled context flush 110 * control. Next, run-time of following procedure is measured: 111 * 112 * for n times do 113 * draw triangle 114 * switch context 115 * 116 * The function is running using two contexts with enabled context control flush 117 * and using two contexts with disabled context control flush. It is expected that 118 * case without flush on context switch control will be faster than the with 119 * case which flushes functionality. Test sets pass if expected behavior has 120 * been measured. The quality warning is triggered when test fails. Not supported 121 * result is returned if context does not support contxt flush control. 122 * 123 * The test is based on KHR_context_flush_control extension overview, that the main reason 124 * for no-flush context is to increase the performance of the implementation. 125 */ 126 class FunctionalTest : public deqp::TestCase 127 { 128 public: 129 /* Public member functions */ 130 FunctionalTest(deqp::Context& context); 131 132 virtual tcu::TestNode::IterateResult iterate(); 133 134 private: 135 /* Private member functions */ 136 FunctionalTest(const FunctionalTest& other); 137 FunctionalTest& operator=(const FunctionalTest& other); 138 139 glw::GLfloat testTime(bool shall_flush_on_release); 140 141 /** @brief Draw Setup class to encapsulate context with framebuffer and shader program. 142 * 143 * The context and within framebuffer, renderbuffer, vertex array object, 144 * shader program is created on the construction. Using makeCurrent() one can swith to 145 * the encapsulated context. With draw() member function one can draw full screen quad. 146 * All objects are deallocated during object destruction. 147 * 148 * Context will flush or will not flush on makeCurrent() switch depending on 149 * constructor setup shall_flush_on_release. 150 */ 151 class DrawSetup 152 { 153 public: 154 DrawSetup(deqp::Context& test_context, bool shall_flush_on_release); 155 ~DrawSetup(); 156 157 void makeCurrent(); 158 void draw(); 159 160 private: 161 deqp::Context& m_test_context; //!< Test main context. 162 glu::RenderContext* m_context; //!< Render context of this draw setup. 163 glw::GLuint m_fbo; //!< OpenGL framebuffer object identifier (in m_context). 164 glw::GLuint m_rbo; //!< OpenGL renderbuffer object identifier (in m_context). 165 glw::GLuint m_vao; //!< OpenGL vertex array object identifier (in m_context). 166 glw::GLuint m_po; //!< OpenGL GLSL program object identifier (in m_context). 167 168 static const glw::GLuint s_view_size; //!< Framebuffer size (default 256). 169 static const glw::GLchar s_vertex_shader 170 []; //!< Vertex shader source code (it draws quad using triangle strip depending on gl_VertexID). 171 static const glw::GLchar s_fragment_shader[]; //!< Fragment shader source code (setup vec4(1.0) as a color). 172 173 void createContext(bool shall_flush_on_release); 174 void createView(); 175 void createGeometry(); 176 void createProgram(); 177 }; 178 }; 179 180 } /* ContextFlushControl namespace */ 181 } /* gl4cts namespace */ 182 #endif // _GL4CCONTEXTFLUSHCONTROLTESTS_HPP 183