1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
4 *
5 * Copyright (c) 2021 The Khronos Group Inc.
6 * Copyright (c) 2021 Google LLC
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */ /*!
21 * \file
22 * \brief
23 */ /*-------------------------------------------------------------------*/
24
25 /*!
26 * \file esextDisjointTimerQueryHandleReuse.cpp
27 * \brief Timer query handle reuse tests
28 */ /*-------------------------------------------------------------------*/
29
30 #include "esextcDisjointTimerQueryHandleReuse.hpp"
31 #include "gluContextInfo.hpp"
32 #include "gluDefs.hpp"
33 #include "glwEnums.hpp"
34 #include "glwFunctions.hpp"
35 #include "tcuTestLog.hpp"
36 #include <vector>
37
38 namespace glcts
39 {
40
41 /** Constructor
42 *
43 * @param context Test context
44 * @param name Test case's name
45 * @param description Test case's description
46 **/
DisjointTimerQueryHandleReuse(Context & context,const ExtParameters & extParams,const char * name,const char * description)47 DisjointTimerQueryHandleReuse::DisjointTimerQueryHandleReuse (Context& context, const ExtParameters& extParams,
48 const char* name, const char* description)
49 : DisjointTimerQueryBase(context, extParams, name, description)
50 {
51 }
52
53 /** Initializes GLES objects used during the test */
initTest(void)54 void DisjointTimerQueryHandleReuse::initTest (void)
55 {
56 if (!isExtensionSupported("GL_EXT_disjoint_timer_query"))
57 {
58 throw tcu::NotSupportedError(DISJOINT_TIMER_QUERY_NOT_SUPPORTED);
59 }
60 }
61
62 /** Executes the test.
63 *
64 * Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise.
65 *
66 * Note the function throws exception should an error occur!
67 *
68 * @return STOP if the test has finished, CONTINUE to indicate iterate should be called once again.
69 **/
iterate(void)70 tcu::TestNode::IterateResult DisjointTimerQueryHandleReuse::iterate(void)
71 {
72 /* Initialize */
73 initTest();
74
75 /* Get Gl entry points */
76 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
77 /* Running tests. */
78 bool is_ok = true;
79
80 glw::GLuint query_id_a = 0;
81 glw::GLuint query_id_b = 0;
82 /* Allocate query object */
83 glGenQueriesEXT(1, &query_id_a);
84 /* Associate object with GL_TIMESTAMP */
85 glQueryCounterEXT(query_id_a, GL_TIMESTAMP);
86 /* Deallocate query object */
87 glDeleteQueriesEXT(1, &query_id_a);
88
89 /* Allocate query object again - should result in the same id */
90 glGenQueriesEXT(1, &query_id_b);
91 /* Use the id with something else */
92 glBeginQueryEXT(GL_TIME_ELAPSED, query_id_b);
93 if (gl.getError() != 0) /* Crash was reported here. */
94 is_ok = false;
95 glEndQueryEXT(GL_TIME_ELAPSED);
96 /* Clean up */
97 glDeleteQueriesEXT(1, &query_id_b);
98
99 if (query_id_a != query_id_b)
100 {
101 m_context.getTestContext().getLog()
102 << tcu::TestLog::Message << "Note: Queries got different id:s, so no actual reuse occurred."
103 << tcu::TestLog::EndMessage;
104 }
105
106 /* Result's setup. */
107 if (is_ok)
108 {
109 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
110 }
111 else
112 {
113 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
114 }
115 return STOP;
116 }
117
118 } // namespace glcts
119