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