xref: /aosp_15_r20/external/deqp/modules/glshared/glsStateQueryUtil.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker #ifndef _GLSSTATEQUERYUTIL_HPP
2*35238bceSAndroid Build Coastguard Worker #define _GLSSTATEQUERYUTIL_HPP
3*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL (ES) Module
5*35238bceSAndroid Build Coastguard Worker  * -----------------------------------------------
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
8*35238bceSAndroid Build Coastguard Worker  *
9*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
10*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
11*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
14*35238bceSAndroid Build Coastguard Worker  *
15*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
16*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
17*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
19*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
20*35238bceSAndroid Build Coastguard Worker  *
21*35238bceSAndroid Build Coastguard Worker  *//*!
22*35238bceSAndroid Build Coastguard Worker  * \file
23*35238bceSAndroid Build Coastguard Worker  * \brief State Query test utils.
24*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "tcuDefs.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuTestContext.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuResultCollector.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "glwDefs.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
32*35238bceSAndroid Build Coastguard Worker 
33*35238bceSAndroid Build Coastguard Worker namespace glu
34*35238bceSAndroid Build Coastguard Worker {
35*35238bceSAndroid Build Coastguard Worker class CallLogWrapper;
36*35238bceSAndroid Build Coastguard Worker } // namespace glu
37*35238bceSAndroid Build Coastguard Worker 
38*35238bceSAndroid Build Coastguard Worker namespace deqp
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker namespace gls
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker namespace StateQueryUtil
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker 
45*35238bceSAndroid Build Coastguard Worker #define GLS_COLLECT_GL_ERROR(RES, ERR, MSG)                                                          \
46*35238bceSAndroid Build Coastguard Worker     do                                                                                               \
47*35238bceSAndroid Build Coastguard Worker     {                                                                                                \
48*35238bceSAndroid Build Coastguard Worker         const uint32_t err = (ERR);                                                                  \
49*35238bceSAndroid Build Coastguard Worker         if (err != GL_NO_ERROR)                                                                      \
50*35238bceSAndroid Build Coastguard Worker             (RES).fail(std::string("Got Error ") + glu::getErrorStr(err).toString() + ": " + (MSG)); \
51*35238bceSAndroid Build Coastguard Worker     } while (false)
52*35238bceSAndroid Build Coastguard Worker 
53*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
54*35238bceSAndroid Build Coastguard Worker  * \brief Rounds given float to the nearest integer (half up).
55*35238bceSAndroid Build Coastguard Worker  *
56*35238bceSAndroid Build Coastguard Worker  * Returns the nearest integer for a float argument. In the case that there
57*35238bceSAndroid Build Coastguard Worker  * are two nearest integers at the equal distance (aka. the argument is of
58*35238bceSAndroid Build Coastguard Worker  * form x.5), the integer with the higher value is chosen. (x.5 rounds to x+1)
59*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
60*35238bceSAndroid Build Coastguard Worker template <typename T>
roundGLfloatToNearestIntegerHalfUp(float val)61*35238bceSAndroid Build Coastguard Worker T roundGLfloatToNearestIntegerHalfUp(float val)
62*35238bceSAndroid Build Coastguard Worker {
63*35238bceSAndroid Build Coastguard Worker     return (T)(deFloatFloor(val + 0.5f));
64*35238bceSAndroid Build Coastguard Worker }
65*35238bceSAndroid Build Coastguard Worker 
66*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
67*35238bceSAndroid Build Coastguard Worker  * \brief Rounds given float to the nearest integer (half down).
68*35238bceSAndroid Build Coastguard Worker  *
69*35238bceSAndroid Build Coastguard Worker  * Returns the nearest integer for a float argument. In the case that there
70*35238bceSAndroid Build Coastguard Worker  * are two nearest integers at the equal distance (aka. the argument is of
71*35238bceSAndroid Build Coastguard Worker  * form x.5), the integer with the higher value is chosen. (x.5 rounds to x)
72*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
73*35238bceSAndroid Build Coastguard Worker template <typename T>
roundGLfloatToNearestIntegerHalfDown(float val)74*35238bceSAndroid Build Coastguard Worker T roundGLfloatToNearestIntegerHalfDown(float val)
75*35238bceSAndroid Build Coastguard Worker {
76*35238bceSAndroid Build Coastguard Worker     return (T)(deFloatCeil(val - 0.5f));
77*35238bceSAndroid Build Coastguard Worker }
78*35238bceSAndroid Build Coastguard Worker 
79*35238bceSAndroid Build Coastguard Worker template <typename T>
80*35238bceSAndroid Build Coastguard Worker class StateQueryMemoryWriteGuard
81*35238bceSAndroid Build Coastguard Worker {
82*35238bceSAndroid Build Coastguard Worker public:
83*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard(void);
84*35238bceSAndroid Build Coastguard Worker 
85*35238bceSAndroid Build Coastguard Worker     operator T &(void);
86*35238bceSAndroid Build Coastguard Worker     T *operator&(void);
87*35238bceSAndroid Build Coastguard Worker 
88*35238bceSAndroid Build Coastguard Worker     bool isUndefined(void) const;
89*35238bceSAndroid Build Coastguard Worker     bool isMemoryContaminated(void) const;
90*35238bceSAndroid Build Coastguard Worker     bool isPreguardContaminated(void) const;
91*35238bceSAndroid Build Coastguard Worker     bool isPostguardContaminated(void) const;
92*35238bceSAndroid Build Coastguard Worker     bool verifyValidity(tcu::TestContext &testCtx) const;
93*35238bceSAndroid Build Coastguard Worker     bool verifyValidity(tcu::ResultCollector &result) const;
94*35238bceSAndroid Build Coastguard Worker 
get(void) const95*35238bceSAndroid Build Coastguard Worker     const T &get(void) const
96*35238bceSAndroid Build Coastguard Worker     {
97*35238bceSAndroid Build Coastguard Worker         return m_value;
98*35238bceSAndroid Build Coastguard Worker     }
99*35238bceSAndroid Build Coastguard Worker 
100*35238bceSAndroid Build Coastguard Worker private:
101*35238bceSAndroid Build Coastguard Worker     enum
102*35238bceSAndroid Build Coastguard Worker     {
103*35238bceSAndroid Build Coastguard Worker         WRITE_GUARD_VALUE = 0xDE
104*35238bceSAndroid Build Coastguard Worker     };
105*35238bceSAndroid Build Coastguard Worker 
106*35238bceSAndroid Build Coastguard Worker     T m_preguard;
107*35238bceSAndroid Build Coastguard Worker     T m_value;
108*35238bceSAndroid Build Coastguard Worker     T m_postguard; // \note guards are not const qualified since the GL implementation might modify them
109*35238bceSAndroid Build Coastguard Worker };
110*35238bceSAndroid Build Coastguard Worker 
111*35238bceSAndroid Build Coastguard Worker template <typename T>
StateQueryMemoryWriteGuard(void)112*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<T>::StateQueryMemoryWriteGuard(void)
113*35238bceSAndroid Build Coastguard Worker {
114*35238bceSAndroid Build Coastguard Worker     DE_STATIC_ASSERT(sizeof(T) * 3 == sizeof(StateQueryMemoryWriteGuard<T>)); // tightly packed
115*35238bceSAndroid Build Coastguard Worker 
116*35238bceSAndroid Build Coastguard Worker     deMemset(&m_preguard, WRITE_GUARD_VALUE, sizeof(m_preguard));
117*35238bceSAndroid Build Coastguard Worker     deMemset(&m_value, WRITE_GUARD_VALUE, sizeof(m_value));
118*35238bceSAndroid Build Coastguard Worker     deMemset(&m_postguard, WRITE_GUARD_VALUE, sizeof(m_postguard));
119*35238bceSAndroid Build Coastguard Worker }
120*35238bceSAndroid Build Coastguard Worker 
121*35238bceSAndroid Build Coastguard Worker template <typename T>
operator T&(void)122*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<T>::operator T &(void)
123*35238bceSAndroid Build Coastguard Worker {
124*35238bceSAndroid Build Coastguard Worker     return m_value;
125*35238bceSAndroid Build Coastguard Worker }
126*35238bceSAndroid Build Coastguard Worker 
127*35238bceSAndroid Build Coastguard Worker template <typename T>
operator &(void)128*35238bceSAndroid Build Coastguard Worker T *StateQueryMemoryWriteGuard<T>::operator&(void)
129*35238bceSAndroid Build Coastguard Worker {
130*35238bceSAndroid Build Coastguard Worker     return &m_value;
131*35238bceSAndroid Build Coastguard Worker }
132*35238bceSAndroid Build Coastguard Worker 
133*35238bceSAndroid Build Coastguard Worker template <typename T>
isUndefined() const134*35238bceSAndroid Build Coastguard Worker bool StateQueryMemoryWriteGuard<T>::isUndefined() const
135*35238bceSAndroid Build Coastguard Worker {
136*35238bceSAndroid Build Coastguard Worker     for (size_t i = 0; i < sizeof(T); ++i)
137*35238bceSAndroid Build Coastguard Worker         if (((uint8_t *)&m_value)[i] != (uint8_t)WRITE_GUARD_VALUE)
138*35238bceSAndroid Build Coastguard Worker             return false;
139*35238bceSAndroid Build Coastguard Worker     return true;
140*35238bceSAndroid Build Coastguard Worker }
141*35238bceSAndroid Build Coastguard Worker 
142*35238bceSAndroid Build Coastguard Worker template <typename T>
isMemoryContaminated() const143*35238bceSAndroid Build Coastguard Worker bool StateQueryMemoryWriteGuard<T>::isMemoryContaminated() const
144*35238bceSAndroid Build Coastguard Worker {
145*35238bceSAndroid Build Coastguard Worker     return isPreguardContaminated() || isPostguardContaminated();
146*35238bceSAndroid Build Coastguard Worker }
147*35238bceSAndroid Build Coastguard Worker 
148*35238bceSAndroid Build Coastguard Worker template <typename T>
isPreguardContaminated(void) const149*35238bceSAndroid Build Coastguard Worker bool StateQueryMemoryWriteGuard<T>::isPreguardContaminated(void) const
150*35238bceSAndroid Build Coastguard Worker {
151*35238bceSAndroid Build Coastguard Worker     for (size_t i = 0; i < sizeof(T); ++i)
152*35238bceSAndroid Build Coastguard Worker         if (((uint8_t *)&m_preguard)[i] != (uint8_t)WRITE_GUARD_VALUE)
153*35238bceSAndroid Build Coastguard Worker             return true;
154*35238bceSAndroid Build Coastguard Worker     return false;
155*35238bceSAndroid Build Coastguard Worker }
156*35238bceSAndroid Build Coastguard Worker 
157*35238bceSAndroid Build Coastguard Worker template <typename T>
isPostguardContaminated(void) const158*35238bceSAndroid Build Coastguard Worker bool StateQueryMemoryWriteGuard<T>::isPostguardContaminated(void) const
159*35238bceSAndroid Build Coastguard Worker {
160*35238bceSAndroid Build Coastguard Worker     for (size_t i = 0; i < sizeof(T); ++i)
161*35238bceSAndroid Build Coastguard Worker         if (((uint8_t *)&m_postguard)[i] != (uint8_t)WRITE_GUARD_VALUE)
162*35238bceSAndroid Build Coastguard Worker             return true;
163*35238bceSAndroid Build Coastguard Worker     return false;
164*35238bceSAndroid Build Coastguard Worker }
165*35238bceSAndroid Build Coastguard Worker 
166*35238bceSAndroid Build Coastguard Worker template <typename T>
verifyValidity(tcu::TestContext & testCtx) const167*35238bceSAndroid Build Coastguard Worker bool StateQueryMemoryWriteGuard<T>::verifyValidity(tcu::TestContext &testCtx) const
168*35238bceSAndroid Build Coastguard Worker {
169*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
170*35238bceSAndroid Build Coastguard Worker 
171*35238bceSAndroid Build Coastguard Worker     if (isPreguardContaminated())
172*35238bceSAndroid Build Coastguard Worker     {
173*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: Pre-guard value was modified " << TestLog::EndMessage;
174*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS || testCtx.getTestResult() == QP_TEST_RESULT_LAST)
175*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Get* did an illegal memory write");
176*35238bceSAndroid Build Coastguard Worker 
177*35238bceSAndroid Build Coastguard Worker         return false;
178*35238bceSAndroid Build Coastguard Worker     }
179*35238bceSAndroid Build Coastguard Worker     else if (isPostguardContaminated())
180*35238bceSAndroid Build Coastguard Worker     {
181*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: Post-guard value was modified " << TestLog::EndMessage;
182*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS || testCtx.getTestResult() == QP_TEST_RESULT_LAST)
183*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Get* did an illegal memory write");
184*35238bceSAndroid Build Coastguard Worker 
185*35238bceSAndroid Build Coastguard Worker         return false;
186*35238bceSAndroid Build Coastguard Worker     }
187*35238bceSAndroid Build Coastguard Worker     else if (isUndefined())
188*35238bceSAndroid Build Coastguard Worker     {
189*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: Get* did not return a value" << TestLog::EndMessage;
190*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS || testCtx.getTestResult() == QP_TEST_RESULT_LAST)
191*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Get* did not return a value");
192*35238bceSAndroid Build Coastguard Worker 
193*35238bceSAndroid Build Coastguard Worker         return false;
194*35238bceSAndroid Build Coastguard Worker     }
195*35238bceSAndroid Build Coastguard Worker 
196*35238bceSAndroid Build Coastguard Worker     return true;
197*35238bceSAndroid Build Coastguard Worker }
198*35238bceSAndroid Build Coastguard Worker 
199*35238bceSAndroid Build Coastguard Worker template <typename T>
verifyValidity(tcu::ResultCollector & result) const200*35238bceSAndroid Build Coastguard Worker bool StateQueryMemoryWriteGuard<T>::verifyValidity(tcu::ResultCollector &result) const
201*35238bceSAndroid Build Coastguard Worker {
202*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
203*35238bceSAndroid Build Coastguard Worker 
204*35238bceSAndroid Build Coastguard Worker     if (isPreguardContaminated())
205*35238bceSAndroid Build Coastguard Worker     {
206*35238bceSAndroid Build Coastguard Worker         result.fail("pre-guard value was modified");
207*35238bceSAndroid Build Coastguard Worker         return false;
208*35238bceSAndroid Build Coastguard Worker     }
209*35238bceSAndroid Build Coastguard Worker     else if (isPostguardContaminated())
210*35238bceSAndroid Build Coastguard Worker     {
211*35238bceSAndroid Build Coastguard Worker         result.fail("post-guard value was modified");
212*35238bceSAndroid Build Coastguard Worker         return false;
213*35238bceSAndroid Build Coastguard Worker     }
214*35238bceSAndroid Build Coastguard Worker     else if (isUndefined())
215*35238bceSAndroid Build Coastguard Worker     {
216*35238bceSAndroid Build Coastguard Worker         result.fail("Get* did not return a value");
217*35238bceSAndroid Build Coastguard Worker         return false;
218*35238bceSAndroid Build Coastguard Worker     }
219*35238bceSAndroid Build Coastguard Worker 
220*35238bceSAndroid Build Coastguard Worker     return true;
221*35238bceSAndroid Build Coastguard Worker }
222*35238bceSAndroid Build Coastguard Worker 
223*35238bceSAndroid Build Coastguard Worker template <typename T>
operator <<(std::ostream & str,const StateQueryMemoryWriteGuard<T> & guard)224*35238bceSAndroid Build Coastguard Worker std::ostream &operator<<(std::ostream &str, const StateQueryMemoryWriteGuard<T> &guard)
225*35238bceSAndroid Build Coastguard Worker {
226*35238bceSAndroid Build Coastguard Worker     return str << guard.get();
227*35238bceSAndroid Build Coastguard Worker }
228*35238bceSAndroid Build Coastguard Worker 
229*35238bceSAndroid Build Coastguard Worker // Verifiers
230*35238bceSAndroid Build Coastguard Worker 
231*35238bceSAndroid Build Coastguard Worker enum QueryType
232*35238bceSAndroid Build Coastguard Worker {
233*35238bceSAndroid Build Coastguard Worker     QUERY_BOOLEAN = 0,
234*35238bceSAndroid Build Coastguard Worker     QUERY_BOOLEAN_VEC4,
235*35238bceSAndroid Build Coastguard Worker     QUERY_ISENABLED,
236*35238bceSAndroid Build Coastguard Worker     QUERY_INTEGER,
237*35238bceSAndroid Build Coastguard Worker     QUERY_INTEGER64,
238*35238bceSAndroid Build Coastguard Worker     QUERY_FLOAT,
239*35238bceSAndroid Build Coastguard Worker 
240*35238bceSAndroid Build Coastguard Worker     // indexed
241*35238bceSAndroid Build Coastguard Worker     QUERY_INDEXED_BOOLEAN,
242*35238bceSAndroid Build Coastguard Worker     QUERY_INDEXED_BOOLEAN_VEC4,
243*35238bceSAndroid Build Coastguard Worker     QUERY_INDEXED_ISENABLED,
244*35238bceSAndroid Build Coastguard Worker     QUERY_INDEXED_INTEGER,
245*35238bceSAndroid Build Coastguard Worker     QUERY_INDEXED_INTEGER_VEC4,
246*35238bceSAndroid Build Coastguard Worker     QUERY_INDEXED_INTEGER64,
247*35238bceSAndroid Build Coastguard Worker     QUERY_INDEXED_INTEGER64_VEC4,
248*35238bceSAndroid Build Coastguard Worker 
249*35238bceSAndroid Build Coastguard Worker     // attributes
250*35238bceSAndroid Build Coastguard Worker     QUERY_ATTRIBUTE_INTEGER,
251*35238bceSAndroid Build Coastguard Worker     QUERY_ATTRIBUTE_FLOAT,
252*35238bceSAndroid Build Coastguard Worker     QUERY_ATTRIBUTE_PURE_INTEGER,
253*35238bceSAndroid Build Coastguard Worker     QUERY_ATTRIBUTE_PURE_UNSIGNED_INTEGER,
254*35238bceSAndroid Build Coastguard Worker 
255*35238bceSAndroid Build Coastguard Worker     // fb
256*35238bceSAndroid Build Coastguard Worker     QUERY_FRAMEBUFFER_INTEGER,
257*35238bceSAndroid Build Coastguard Worker 
258*35238bceSAndroid Build Coastguard Worker     // program
259*35238bceSAndroid Build Coastguard Worker     QUERY_PROGRAM_INTEGER,
260*35238bceSAndroid Build Coastguard Worker     QUERY_PROGRAM_INTEGER_VEC3,
261*35238bceSAndroid Build Coastguard Worker 
262*35238bceSAndroid Build Coastguard Worker     // program pipeline
263*35238bceSAndroid Build Coastguard Worker     QUERY_PIPELINE_INTEGER,
264*35238bceSAndroid Build Coastguard Worker 
265*35238bceSAndroid Build Coastguard Worker     // texture param
266*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_PARAM_INTEGER,
267*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_PARAM_FLOAT,
268*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_PARAM_PURE_INTEGER,
269*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER,
270*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_PARAM_INTEGER_VEC4,
271*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_PARAM_FLOAT_VEC4,
272*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_PARAM_PURE_INTEGER_VEC4,
273*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER_VEC4,
274*35238bceSAndroid Build Coastguard Worker 
275*35238bceSAndroid Build Coastguard Worker     // texture level
276*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_LEVEL_INTEGER,
277*35238bceSAndroid Build Coastguard Worker     QUERY_TEXTURE_LEVEL_FLOAT,
278*35238bceSAndroid Build Coastguard Worker 
279*35238bceSAndroid Build Coastguard Worker     // pointer
280*35238bceSAndroid Build Coastguard Worker     QUERY_POINTER,
281*35238bceSAndroid Build Coastguard Worker 
282*35238bceSAndroid Build Coastguard Worker     // object states
283*35238bceSAndroid Build Coastguard Worker     QUERY_ISTEXTURE,
284*35238bceSAndroid Build Coastguard Worker 
285*35238bceSAndroid Build Coastguard Worker     // query queries
286*35238bceSAndroid Build Coastguard Worker     QUERY_QUERY,
287*35238bceSAndroid Build Coastguard Worker 
288*35238bceSAndroid Build Coastguard Worker     // sampler state
289*35238bceSAndroid Build Coastguard Worker     QUERY_SAMPLER_PARAM_INTEGER,
290*35238bceSAndroid Build Coastguard Worker     QUERY_SAMPLER_PARAM_FLOAT,
291*35238bceSAndroid Build Coastguard Worker     QUERY_SAMPLER_PARAM_PURE_INTEGER,
292*35238bceSAndroid Build Coastguard Worker     QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER,
293*35238bceSAndroid Build Coastguard Worker     QUERY_SAMPLER_PARAM_INTEGER_VEC4,
294*35238bceSAndroid Build Coastguard Worker     QUERY_SAMPLER_PARAM_FLOAT_VEC4,
295*35238bceSAndroid Build Coastguard Worker     QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4,
296*35238bceSAndroid Build Coastguard Worker     QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4,
297*35238bceSAndroid Build Coastguard Worker 
298*35238bceSAndroid Build Coastguard Worker     QUERY_LAST
299*35238bceSAndroid Build Coastguard Worker };
300*35238bceSAndroid Build Coastguard Worker 
301*35238bceSAndroid Build Coastguard Worker enum DataType
302*35238bceSAndroid Build Coastguard Worker {
303*35238bceSAndroid Build Coastguard Worker     DATATYPE_BOOLEAN = 0,
304*35238bceSAndroid Build Coastguard Worker     DATATYPE_INTEGER,
305*35238bceSAndroid Build Coastguard Worker     DATATYPE_INTEGER64,
306*35238bceSAndroid Build Coastguard Worker     DATATYPE_FLOAT16,
307*35238bceSAndroid Build Coastguard Worker     DATATYPE_FLOAT,
308*35238bceSAndroid Build Coastguard Worker     DATATYPE_UNSIGNED_INTEGER,
309*35238bceSAndroid Build Coastguard Worker     DATATYPE_INTEGER_VEC3,
310*35238bceSAndroid Build Coastguard Worker     DATATYPE_FLOAT_VEC4,
311*35238bceSAndroid Build Coastguard Worker     DATATYPE_INTEGER_VEC4,
312*35238bceSAndroid Build Coastguard Worker     DATATYPE_INTEGER64_VEC4,
313*35238bceSAndroid Build Coastguard Worker     DATATYPE_UNSIGNED_INTEGER_VEC4,
314*35238bceSAndroid Build Coastguard Worker     DATATYPE_BOOLEAN_VEC4,
315*35238bceSAndroid Build Coastguard Worker     DATATYPE_POINTER,
316*35238bceSAndroid Build Coastguard Worker 
317*35238bceSAndroid Build Coastguard Worker     DATATYPE_LAST
318*35238bceSAndroid Build Coastguard Worker };
319*35238bceSAndroid Build Coastguard Worker 
320*35238bceSAndroid Build Coastguard Worker class QueriedState
321*35238bceSAndroid Build Coastguard Worker {
322*35238bceSAndroid Build Coastguard Worker public:
323*35238bceSAndroid Build Coastguard Worker     typedef glw::GLint GLIntVec3[3];
324*35238bceSAndroid Build Coastguard Worker     typedef glw::GLint GLIntVec4[4];
325*35238bceSAndroid Build Coastguard Worker     typedef glw::GLuint GLUintVec4[4];
326*35238bceSAndroid Build Coastguard Worker     typedef glw::GLfloat GLFloatVec4[4];
327*35238bceSAndroid Build Coastguard Worker     typedef bool BooleanVec4[4];
328*35238bceSAndroid Build Coastguard Worker     typedef glw::GLint64 GLInt64Vec4[4];
329*35238bceSAndroid Build Coastguard Worker 
330*35238bceSAndroid Build Coastguard Worker     QueriedState(void);
331*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(glw::GLint);
332*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(glw::GLint64);
333*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(bool);
334*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(glw::GLfloat);
335*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(glw::GLuint);
336*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(const GLIntVec3 &);
337*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(void *);
338*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(const GLIntVec4 &);
339*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(const GLUintVec4 &);
340*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(const GLFloatVec4 &);
341*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(const BooleanVec4 &);
342*35238bceSAndroid Build Coastguard Worker     explicit QueriedState(const GLInt64Vec4 &);
343*35238bceSAndroid Build Coastguard Worker 
344*35238bceSAndroid Build Coastguard Worker     bool isUndefined(void) const;
345*35238bceSAndroid Build Coastguard Worker     DataType getType(void) const;
346*35238bceSAndroid Build Coastguard Worker 
347*35238bceSAndroid Build Coastguard Worker     glw::GLint &getIntAccess(void);
348*35238bceSAndroid Build Coastguard Worker     glw::GLint64 &getInt64Access(void);
349*35238bceSAndroid Build Coastguard Worker     bool &getBoolAccess(void);
350*35238bceSAndroid Build Coastguard Worker     glw::GLfloat &getFloatAccess(void);
351*35238bceSAndroid Build Coastguard Worker     glw::GLuint &getUintAccess(void);
352*35238bceSAndroid Build Coastguard Worker     GLIntVec3 &getIntVec3Access(void);
353*35238bceSAndroid Build Coastguard Worker     void *&getPtrAccess(void);
354*35238bceSAndroid Build Coastguard Worker     GLIntVec4 &getIntVec4Access(void);
355*35238bceSAndroid Build Coastguard Worker     GLUintVec4 &getUintVec4Access(void);
356*35238bceSAndroid Build Coastguard Worker     GLFloatVec4 &getFloatVec4Access(void);
357*35238bceSAndroid Build Coastguard Worker     BooleanVec4 &getBooleanVec4Access(void);
358*35238bceSAndroid Build Coastguard Worker     GLInt64Vec4 &getInt64Vec4Access(void);
359*35238bceSAndroid Build Coastguard Worker 
360*35238bceSAndroid Build Coastguard Worker private:
361*35238bceSAndroid Build Coastguard Worker     DataType m_type;
362*35238bceSAndroid Build Coastguard Worker     union
363*35238bceSAndroid Build Coastguard Worker     {
364*35238bceSAndroid Build Coastguard Worker         glw::GLint vInt;
365*35238bceSAndroid Build Coastguard Worker         glw::GLint64 vInt64;
366*35238bceSAndroid Build Coastguard Worker         bool vBool;
367*35238bceSAndroid Build Coastguard Worker         glw::GLfloat vFloat;
368*35238bceSAndroid Build Coastguard Worker         glw::GLuint vUint;
369*35238bceSAndroid Build Coastguard Worker         GLIntVec3 vIntVec3;
370*35238bceSAndroid Build Coastguard Worker         void *vPtr;
371*35238bceSAndroid Build Coastguard Worker         GLIntVec4 vIntVec4;
372*35238bceSAndroid Build Coastguard Worker         GLUintVec4 vUintVec4;
373*35238bceSAndroid Build Coastguard Worker         GLFloatVec4 vFloatVec4;
374*35238bceSAndroid Build Coastguard Worker         BooleanVec4 vBooleanVec4;
375*35238bceSAndroid Build Coastguard Worker         GLInt64Vec4 vInt64Vec4;
376*35238bceSAndroid Build Coastguard Worker     } m_v;
377*35238bceSAndroid Build Coastguard Worker };
378*35238bceSAndroid Build Coastguard Worker 
379*35238bceSAndroid Build Coastguard Worker // query functions
380*35238bceSAndroid Build Coastguard Worker 
381*35238bceSAndroid Build Coastguard Worker void queryState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLenum pname,
382*35238bceSAndroid Build Coastguard Worker                 QueriedState &state);
383*35238bceSAndroid Build Coastguard Worker void queryIndexedState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLenum target,
384*35238bceSAndroid Build Coastguard Worker                        int index, QueriedState &state);
385*35238bceSAndroid Build Coastguard Worker void queryAttributeState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLenum target,
386*35238bceSAndroid Build Coastguard Worker                          int index, QueriedState &state);
387*35238bceSAndroid Build Coastguard Worker void queryFramebufferState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLenum target,
388*35238bceSAndroid Build Coastguard Worker                            glw::GLenum pname, QueriedState &state);
389*35238bceSAndroid Build Coastguard Worker void queryProgramState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLuint program,
390*35238bceSAndroid Build Coastguard Worker                        glw::GLenum pname, QueriedState &state);
391*35238bceSAndroid Build Coastguard Worker void queryPipelineState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLuint pipeline,
392*35238bceSAndroid Build Coastguard Worker                         glw::GLenum pname, QueriedState &state);
393*35238bceSAndroid Build Coastguard Worker void queryTextureParamState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLenum target,
394*35238bceSAndroid Build Coastguard Worker                             glw::GLenum pname, QueriedState &state);
395*35238bceSAndroid Build Coastguard Worker void queryTextureLevelState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLenum target,
396*35238bceSAndroid Build Coastguard Worker                             int level, glw::GLenum pname, QueriedState &state);
397*35238bceSAndroid Build Coastguard Worker void queryPointerState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLenum pname,
398*35238bceSAndroid Build Coastguard Worker                        QueriedState &state);
399*35238bceSAndroid Build Coastguard Worker void queryObjectState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLuint handle,
400*35238bceSAndroid Build Coastguard Worker                       QueriedState &state);
401*35238bceSAndroid Build Coastguard Worker void queryQueryState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLenum target,
402*35238bceSAndroid Build Coastguard Worker                      glw::GLenum pname, QueriedState &state);
403*35238bceSAndroid Build Coastguard Worker void querySamplerState(tcu::ResultCollector &result, glu::CallLogWrapper &gl, QueryType type, glw::GLuint sampler,
404*35238bceSAndroid Build Coastguard Worker                        glw::GLenum pname, QueriedState &state);
405*35238bceSAndroid Build Coastguard Worker 
406*35238bceSAndroid Build Coastguard Worker // verification functions
407*35238bceSAndroid Build Coastguard Worker 
408*35238bceSAndroid Build Coastguard Worker void verifyBoolean(tcu::ResultCollector &result, QueriedState &state, bool expected);
409*35238bceSAndroid Build Coastguard Worker void verifyInteger(tcu::ResultCollector &result, QueriedState &state, int expected);
410*35238bceSAndroid Build Coastguard Worker void verifyIntegerMin(tcu::ResultCollector &result, QueriedState &state, int minValue);
411*35238bceSAndroid Build Coastguard Worker void verifyIntegerMax(tcu::ResultCollector &result, QueriedState &state, int maxValue);
412*35238bceSAndroid Build Coastguard Worker void verifyIntegersEqual(tcu::ResultCollector &result, QueriedState &stateA, QueriedState &stateB);
413*35238bceSAndroid Build Coastguard Worker void verifyFloat(tcu::ResultCollector &result, QueriedState &state, float expected);
414*35238bceSAndroid Build Coastguard Worker void verifyFloatMin(tcu::ResultCollector &result, QueriedState &state, float minValue);
415*35238bceSAndroid Build Coastguard Worker void verifyFloatMax(tcu::ResultCollector &result, QueriedState &state, float maxValue);
416*35238bceSAndroid Build Coastguard Worker void verifyIntegerVec3(tcu::ResultCollector &result, QueriedState &state, const tcu::IVec3 &expected);
417*35238bceSAndroid Build Coastguard Worker void verifyIntegerVec4(tcu::ResultCollector &result, QueriedState &state, const tcu::IVec4 &expected);
418*35238bceSAndroid Build Coastguard Worker void verifyUnsignedIntegerVec4(tcu::ResultCollector &result, QueriedState &state, const tcu::UVec4 &expected);
419*35238bceSAndroid Build Coastguard Worker void verifyFloatVec4(tcu::ResultCollector &result, QueriedState &state, const tcu::Vec4 &expected);
420*35238bceSAndroid Build Coastguard Worker void verifyBooleanVec4(tcu::ResultCollector &result, QueriedState &state, const tcu::BVec4 &expected);
421*35238bceSAndroid Build Coastguard Worker void verifyPointer(tcu::ResultCollector &result, QueriedState &state, const void *expected);
422*35238bceSAndroid Build Coastguard Worker void verifyNormalizedI32Vec4(tcu::ResultCollector &result, QueriedState &state, const tcu::IVec4 &expected);
423*35238bceSAndroid Build Coastguard Worker 
424*35238bceSAndroid Build Coastguard Worker // Helper functions that both query and verify
425*35238bceSAndroid Build Coastguard Worker 
426*35238bceSAndroid Build Coastguard Worker void verifyStateBoolean(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, bool expected,
427*35238bceSAndroid Build Coastguard Worker                         QueryType type);
428*35238bceSAndroid Build Coastguard Worker void verifyStateInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, int expected,
429*35238bceSAndroid Build Coastguard Worker                         QueryType type);
430*35238bceSAndroid Build Coastguard Worker void verifyStateIntegerMin(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, int minValue,
431*35238bceSAndroid Build Coastguard Worker                            QueryType type);
432*35238bceSAndroid Build Coastguard Worker void verifyStateIntegerMax(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, int maxValue,
433*35238bceSAndroid Build Coastguard Worker                            QueryType type);
434*35238bceSAndroid Build Coastguard Worker void verifyStateIntegerEqualToOther(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
435*35238bceSAndroid Build Coastguard Worker                                     glw::GLenum other, QueryType type);
436*35238bceSAndroid Build Coastguard Worker void verifyStateFloat(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, float reference,
437*35238bceSAndroid Build Coastguard Worker                       QueryType type);
438*35238bceSAndroid Build Coastguard Worker void verifyStateFloatMin(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, float minValue,
439*35238bceSAndroid Build Coastguard Worker                          QueryType type);
440*35238bceSAndroid Build Coastguard Worker void verifyStateFloatMax(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, float maxValue,
441*35238bceSAndroid Build Coastguard Worker                          QueryType type);
442*35238bceSAndroid Build Coastguard Worker void verifyStatePointer(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, const void *expected,
443*35238bceSAndroid Build Coastguard Worker                         QueryType type);
444*35238bceSAndroid Build Coastguard Worker void verifyStateIndexedBoolean(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, int index,
445*35238bceSAndroid Build Coastguard Worker                                bool expected, QueryType type);
446*35238bceSAndroid Build Coastguard Worker void verifyStateIndexedBooleanVec4(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, int index,
447*35238bceSAndroid Build Coastguard Worker                                    const tcu::BVec4 &expected, QueryType type);
448*35238bceSAndroid Build Coastguard Worker void verifyStateIndexedInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, int index,
449*35238bceSAndroid Build Coastguard Worker                                int expected, QueryType type);
450*35238bceSAndroid Build Coastguard Worker void verifyStateIndexedIntegerMin(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, int index,
451*35238bceSAndroid Build Coastguard Worker                                   int minValue, QueryType type);
452*35238bceSAndroid Build Coastguard Worker void verifyStateAttributeInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target, int index,
453*35238bceSAndroid Build Coastguard Worker                                  int expected, QueryType type);
454*35238bceSAndroid Build Coastguard Worker void verifyStateFramebufferInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
455*35238bceSAndroid Build Coastguard Worker                                    glw::GLenum pname, int expected, QueryType type);
456*35238bceSAndroid Build Coastguard Worker void verifyStateFramebufferIntegerMin(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
457*35238bceSAndroid Build Coastguard Worker                                       glw::GLenum pname, int minValue, QueryType type);
458*35238bceSAndroid Build Coastguard Worker void verifyStateProgramInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLuint program,
459*35238bceSAndroid Build Coastguard Worker                                glw::GLenum pname, int expected, QueryType type);
460*35238bceSAndroid Build Coastguard Worker void verifyStateProgramIntegerVec3(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLuint program,
461*35238bceSAndroid Build Coastguard Worker                                    glw::GLenum pname, const tcu::IVec3 &expected, QueryType type);
462*35238bceSAndroid Build Coastguard Worker void verifyStatePipelineInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLuint pipeline,
463*35238bceSAndroid Build Coastguard Worker                                 glw::GLenum pname, int expected, QueryType type);
464*35238bceSAndroid Build Coastguard Worker void verifyStateTextureParamInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
465*35238bceSAndroid Build Coastguard Worker                                     glw::GLenum pname, int expected, QueryType type);
466*35238bceSAndroid Build Coastguard Worker void verifyStateTextureParamFloat(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
467*35238bceSAndroid Build Coastguard Worker                                   glw::GLenum pname, float expected, QueryType type);
468*35238bceSAndroid Build Coastguard Worker void verifyStateTextureParamFloatVec4(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
469*35238bceSAndroid Build Coastguard Worker                                       glw::GLenum pname, const tcu::Vec4 &expected, QueryType type);
470*35238bceSAndroid Build Coastguard Worker void verifyStateTextureParamNormalizedI32Vec4(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
471*35238bceSAndroid Build Coastguard Worker                                               glw::GLenum pname, const tcu::IVec4 &expected, QueryType type);
472*35238bceSAndroid Build Coastguard Worker void verifyStateTextureParamIntegerVec4(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
473*35238bceSAndroid Build Coastguard Worker                                         glw::GLenum pname, const tcu::IVec4 &expected, QueryType type);
474*35238bceSAndroid Build Coastguard Worker void verifyStateTextureParamUnsignedIntegerVec4(tcu::ResultCollector &result, glu::CallLogWrapper &gl,
475*35238bceSAndroid Build Coastguard Worker                                                 glw::GLenum target, glw::GLenum pname, const tcu::UVec4 &expected,
476*35238bceSAndroid Build Coastguard Worker                                                 QueryType type);
477*35238bceSAndroid Build Coastguard Worker void verifyStateTextureLevelInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
478*35238bceSAndroid Build Coastguard Worker                                     int level, glw::GLenum pname, int expected, QueryType type);
479*35238bceSAndroid Build Coastguard Worker void verifyStateObjectBoolean(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLuint handle, bool expected,
480*35238bceSAndroid Build Coastguard Worker                               QueryType type);
481*35238bceSAndroid Build Coastguard Worker void verifyStateQueryInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLenum target,
482*35238bceSAndroid Build Coastguard Worker                              glw::GLenum pname, int expected, QueryType type);
483*35238bceSAndroid Build Coastguard Worker void verifyStateSamplerParamInteger(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLuint sampler,
484*35238bceSAndroid Build Coastguard Worker                                     glw::GLenum pname, int expected, QueryType type);
485*35238bceSAndroid Build Coastguard Worker void verifyStateSamplerParamFloat(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLuint sampler,
486*35238bceSAndroid Build Coastguard Worker                                   glw::GLenum pname, float expected, QueryType type);
487*35238bceSAndroid Build Coastguard Worker void verifyStateSamplerParamFloatVec4(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLuint sampler,
488*35238bceSAndroid Build Coastguard Worker                                       glw::GLenum pname, const tcu::Vec4 &expected, QueryType type);
489*35238bceSAndroid Build Coastguard Worker void verifyStateSamplerParamNormalizedI32Vec4(tcu::ResultCollector &result, glu::CallLogWrapper &gl,
490*35238bceSAndroid Build Coastguard Worker                                               glw::GLuint sampler, glw::GLenum pname, const tcu::IVec4 &expected,
491*35238bceSAndroid Build Coastguard Worker                                               QueryType type);
492*35238bceSAndroid Build Coastguard Worker void verifyStateSamplerParamIntegerVec4(tcu::ResultCollector &result, glu::CallLogWrapper &gl, glw::GLuint sampler,
493*35238bceSAndroid Build Coastguard Worker                                         glw::GLenum pname, const tcu::IVec4 &expected, QueryType type);
494*35238bceSAndroid Build Coastguard Worker void verifyStateSamplerParamUnsignedIntegerVec4(tcu::ResultCollector &result, glu::CallLogWrapper &gl,
495*35238bceSAndroid Build Coastguard Worker                                                 glw::GLuint sampler, glw::GLenum pname, const tcu::UVec4 &expected,
496*35238bceSAndroid Build Coastguard Worker                                                 QueryType type);
497*35238bceSAndroid Build Coastguard Worker 
498*35238bceSAndroid Build Coastguard Worker } // namespace StateQueryUtil
499*35238bceSAndroid Build Coastguard Worker } // namespace gls
500*35238bceSAndroid Build Coastguard Worker } // namespace deqp
501*35238bceSAndroid Build Coastguard Worker 
502*35238bceSAndroid Build Coastguard Worker #endif // _GLSSTATEQUERYUTIL_HPP
503