xref: /aosp_15_r20/external/deqp/modules/gles3/functional/es3fIntegerStateQueryTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.0 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief State Query tests.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es3fIntegerStateQueryTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "es3fApiCase.hpp"
26*35238bceSAndroid Build Coastguard Worker 
27*35238bceSAndroid Build Coastguard Worker #include "glsStateQueryUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker 
29*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
32*35238bceSAndroid Build Coastguard Worker 
33*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
34*35238bceSAndroid Build Coastguard Worker 
35*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
36*35238bceSAndroid Build Coastguard Worker 
37*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
38*35238bceSAndroid Build Coastguard Worker 
39*35238bceSAndroid Build Coastguard Worker using namespace glw; // GLint and other GL types
40*35238bceSAndroid Build Coastguard Worker using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
41*35238bceSAndroid Build Coastguard Worker 
42*35238bceSAndroid Build Coastguard Worker #ifndef GL_SLUMINANCE_NV
43*35238bceSAndroid Build Coastguard Worker #define GL_SLUMINANCE_NV 0x8C46
44*35238bceSAndroid Build Coastguard Worker #endif
45*35238bceSAndroid Build Coastguard Worker #ifndef GL_SLUMINANCE_ALPHA_NV
46*35238bceSAndroid Build Coastguard Worker #define GL_SLUMINANCE_ALPHA_NV 0x8C44
47*35238bceSAndroid Build Coastguard Worker #endif
48*35238bceSAndroid Build Coastguard Worker #ifndef GL_BGR_NV
49*35238bceSAndroid Build Coastguard Worker #define GL_BGR_NV 0x80E0
50*35238bceSAndroid Build Coastguard Worker #endif
51*35238bceSAndroid Build Coastguard Worker 
52*35238bceSAndroid Build Coastguard Worker namespace deqp
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker namespace gles3
55*35238bceSAndroid Build Coastguard Worker {
56*35238bceSAndroid Build Coastguard Worker namespace Functional
57*35238bceSAndroid Build Coastguard Worker {
58*35238bceSAndroid Build Coastguard Worker namespace IntegerStateQueryVerifiers
59*35238bceSAndroid Build Coastguard Worker {
60*35238bceSAndroid Build Coastguard Worker 
61*35238bceSAndroid Build Coastguard Worker // StateVerifier
62*35238bceSAndroid Build Coastguard Worker 
63*35238bceSAndroid Build Coastguard Worker class StateVerifier : protected glu::CallLogWrapper
64*35238bceSAndroid Build Coastguard Worker {
65*35238bceSAndroid Build Coastguard Worker public:
66*35238bceSAndroid Build Coastguard Worker     StateVerifier(const glw::Functions &gl, tcu::TestLog &log, const char *testNamePostfix);
67*35238bceSAndroid Build Coastguard Worker     virtual ~StateVerifier(); // make GCC happy
68*35238bceSAndroid Build Coastguard Worker 
69*35238bceSAndroid Build Coastguard Worker     const char *getTestNamePostfix(void) const;
70*35238bceSAndroid Build Coastguard Worker 
71*35238bceSAndroid Build Coastguard Worker     virtual void verifyInteger(tcu::TestContext &testCtx, GLenum name, GLint reference)               = DE_NULL;
72*35238bceSAndroid Build Coastguard Worker     virtual void verifyInteger4(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1,
73*35238bceSAndroid Build Coastguard Worker                                 GLint reference2, GLint reference3)                                   = DE_NULL;
74*35238bceSAndroid Build Coastguard Worker     virtual void verifyInteger4Mask(tcu::TestContext &testCtx, GLenum name, GLint reference0, bool enableRef0,
75*35238bceSAndroid Build Coastguard Worker                                     GLint reference1, bool enableRef1, GLint reference2, bool enableRef2,
76*35238bceSAndroid Build Coastguard Worker                                     GLint reference3, bool enableRef3)                                = DE_NULL;
77*35238bceSAndroid Build Coastguard Worker     virtual void verifyIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference) = DE_NULL;
78*35238bceSAndroid Build Coastguard Worker     virtual void verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name,
79*35238bceSAndroid Build Coastguard Worker                                                      GLuint reference)                                = DE_NULL;
80*35238bceSAndroid Build Coastguard Worker     virtual void verifyIntegerLessOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference)    = DE_NULL;
81*35238bceSAndroid Build Coastguard Worker     virtual void verifyIntegerGreaterOrEqual2(tcu::TestContext &testCtx, GLenum name, GLint reference0,
82*35238bceSAndroid Build Coastguard Worker                                               GLint reference1)                                       = DE_NULL;
83*35238bceSAndroid Build Coastguard Worker     virtual void verifyIntegerAnyOf(tcu::TestContext &testCtx, GLenum name, const GLint references[],
84*35238bceSAndroid Build Coastguard Worker                                     size_t referencesLength)                                          = DE_NULL;
85*35238bceSAndroid Build Coastguard Worker     virtual void verifyStencilMaskInitial(tcu::TestContext &testCtx, GLenum name, int stencilBits)    = DE_NULL;
86*35238bceSAndroid Build Coastguard Worker 
87*35238bceSAndroid Build Coastguard Worker private:
88*35238bceSAndroid Build Coastguard Worker     const char *const m_testNamePostfix;
89*35238bceSAndroid Build Coastguard Worker };
90*35238bceSAndroid Build Coastguard Worker 
StateVerifier(const glw::Functions & gl,tcu::TestLog & log,const char * testNamePostfix)91*35238bceSAndroid Build Coastguard Worker StateVerifier::StateVerifier(const glw::Functions &gl, tcu::TestLog &log, const char *testNamePostfix)
92*35238bceSAndroid Build Coastguard Worker     : glu::CallLogWrapper(gl, log)
93*35238bceSAndroid Build Coastguard Worker     , m_testNamePostfix(testNamePostfix)
94*35238bceSAndroid Build Coastguard Worker {
95*35238bceSAndroid Build Coastguard Worker     enableLogging(true);
96*35238bceSAndroid Build Coastguard Worker }
97*35238bceSAndroid Build Coastguard Worker 
~StateVerifier()98*35238bceSAndroid Build Coastguard Worker StateVerifier::~StateVerifier()
99*35238bceSAndroid Build Coastguard Worker {
100*35238bceSAndroid Build Coastguard Worker }
101*35238bceSAndroid Build Coastguard Worker 
getTestNamePostfix(void) const102*35238bceSAndroid Build Coastguard Worker const char *StateVerifier::getTestNamePostfix(void) const
103*35238bceSAndroid Build Coastguard Worker {
104*35238bceSAndroid Build Coastguard Worker     return m_testNamePostfix;
105*35238bceSAndroid Build Coastguard Worker }
106*35238bceSAndroid Build Coastguard Worker 
107*35238bceSAndroid Build Coastguard Worker // GetBooleanVerifier
108*35238bceSAndroid Build Coastguard Worker 
109*35238bceSAndroid Build Coastguard Worker class GetBooleanVerifier : public StateVerifier
110*35238bceSAndroid Build Coastguard Worker {
111*35238bceSAndroid Build Coastguard Worker public:
112*35238bceSAndroid Build Coastguard Worker     GetBooleanVerifier(const glw::Functions &gl, tcu::TestLog &log);
113*35238bceSAndroid Build Coastguard Worker     void verifyInteger(tcu::TestContext &testCtx, GLenum name, GLint reference);
114*35238bceSAndroid Build Coastguard Worker     void verifyInteger4(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2,
115*35238bceSAndroid Build Coastguard Worker                         GLint reference3);
116*35238bceSAndroid Build Coastguard Worker     void verifyInteger4Mask(tcu::TestContext &testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1,
117*35238bceSAndroid Build Coastguard Worker                             bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
118*35238bceSAndroid Build Coastguard Worker     void verifyIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference);
119*35238bceSAndroid Build Coastguard Worker     void verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLuint reference);
120*35238bceSAndroid Build Coastguard Worker     void verifyIntegerLessOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference);
121*35238bceSAndroid Build Coastguard Worker     void verifyIntegerGreaterOrEqual2(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1);
122*35238bceSAndroid Build Coastguard Worker     void verifyIntegerAnyOf(tcu::TestContext &testCtx, GLenum name, const GLint references[], size_t referencesLength);
123*35238bceSAndroid Build Coastguard Worker     void verifyStencilMaskInitial(tcu::TestContext &testCtx, GLenum name, int stencilBits);
124*35238bceSAndroid Build Coastguard Worker };
125*35238bceSAndroid Build Coastguard Worker 
GetBooleanVerifier(const glw::Functions & gl,tcu::TestLog & log)126*35238bceSAndroid Build Coastguard Worker GetBooleanVerifier::GetBooleanVerifier(const glw::Functions &gl, tcu::TestLog &log)
127*35238bceSAndroid Build Coastguard Worker     : StateVerifier(gl, log, "_getboolean")
128*35238bceSAndroid Build Coastguard Worker {
129*35238bceSAndroid Build Coastguard Worker }
130*35238bceSAndroid Build Coastguard Worker 
verifyInteger(tcu::TestContext & testCtx,GLenum name,GLint reference)131*35238bceSAndroid Build Coastguard Worker void GetBooleanVerifier::verifyInteger(tcu::TestContext &testCtx, GLenum name, GLint reference)
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
134*35238bceSAndroid Build Coastguard Worker 
135*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLboolean> state;
136*35238bceSAndroid Build Coastguard Worker     glGetBooleanv(name, &state);
137*35238bceSAndroid Build Coastguard Worker 
138*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
139*35238bceSAndroid Build Coastguard Worker         return;
140*35238bceSAndroid Build Coastguard Worker 
141*35238bceSAndroid Build Coastguard Worker     const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE;
142*35238bceSAndroid Build Coastguard Worker 
143*35238bceSAndroid Build Coastguard Worker     if (state != expectedGLState)
144*35238bceSAndroid Build Coastguard Worker     {
145*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected "
146*35238bceSAndroid Build Coastguard Worker                          << (expectedGLState == GL_TRUE ? "GL_TRUE" : "GL_FALSE") << "; got "
147*35238bceSAndroid Build Coastguard Worker                          << (state == GL_TRUE ? "GL_TRUE" : (state == GL_FALSE ? "GL_FALSE" : "non-boolean"))
148*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
149*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
150*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
151*35238bceSAndroid Build Coastguard Worker     }
152*35238bceSAndroid Build Coastguard Worker }
153*35238bceSAndroid Build Coastguard Worker 
verifyInteger4(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1,GLint reference2,GLint reference3)154*35238bceSAndroid Build Coastguard Worker void GetBooleanVerifier::verifyInteger4(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1,
155*35238bceSAndroid Build Coastguard Worker                                         GLint reference2, GLint reference3)
156*35238bceSAndroid Build Coastguard Worker {
157*35238bceSAndroid Build Coastguard Worker     verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
158*35238bceSAndroid Build Coastguard Worker }
159*35238bceSAndroid Build Coastguard Worker 
verifyInteger4Mask(tcu::TestContext & testCtx,GLenum name,GLint reference0,bool enableRef0,GLint reference1,bool enableRef1,GLint reference2,bool enableRef2,GLint reference3,bool enableRef3)160*35238bceSAndroid Build Coastguard Worker void GetBooleanVerifier::verifyInteger4Mask(tcu::TestContext &testCtx, GLenum name, GLint reference0, bool enableRef0,
161*35238bceSAndroid Build Coastguard Worker                                             GLint reference1, bool enableRef1, GLint reference2, bool enableRef2,
162*35238bceSAndroid Build Coastguard Worker                                             GLint reference3, bool enableRef3)
163*35238bceSAndroid Build Coastguard Worker {
164*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
165*35238bceSAndroid Build Coastguard Worker 
166*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4;
167*35238bceSAndroid Build Coastguard Worker     glGetBooleanv(name, boolVector4);
168*35238bceSAndroid Build Coastguard Worker 
169*35238bceSAndroid Build Coastguard Worker     if (!boolVector4.verifyValidity(testCtx))
170*35238bceSAndroid Build Coastguard Worker         return;
171*35238bceSAndroid Build Coastguard Worker 
172*35238bceSAndroid Build Coastguard Worker     const GLboolean referenceAsGLBoolean[] = {
173*35238bceSAndroid Build Coastguard Worker         reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
174*35238bceSAndroid Build Coastguard Worker         reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
175*35238bceSAndroid Build Coastguard Worker         reference2 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
176*35238bceSAndroid Build Coastguard Worker         reference3 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
177*35238bceSAndroid Build Coastguard Worker     };
178*35238bceSAndroid Build Coastguard Worker 
179*35238bceSAndroid Build Coastguard Worker     if ((enableRef0 && (boolVector4[0] != referenceAsGLBoolean[0])) ||
180*35238bceSAndroid Build Coastguard Worker         (enableRef1 && (boolVector4[1] != referenceAsGLBoolean[1])) ||
181*35238bceSAndroid Build Coastguard Worker         (enableRef2 && (boolVector4[2] != referenceAsGLBoolean[2])) ||
182*35238bceSAndroid Build Coastguard Worker         (enableRef3 && (boolVector4[3] != referenceAsGLBoolean[3])))
183*35238bceSAndroid Build Coastguard Worker     {
184*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected "
185*35238bceSAndroid Build Coastguard Worker                          << (enableRef0 ? (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
186*35238bceSAndroid Build Coastguard Worker                          << (enableRef1 ? (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
187*35238bceSAndroid Build Coastguard Worker                          << (enableRef2 ? (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
188*35238bceSAndroid Build Coastguard Worker                          << (enableRef3 ? (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") : " - ")
189*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
190*35238bceSAndroid Build Coastguard Worker 
191*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
192*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
193*35238bceSAndroid Build Coastguard Worker     }
194*35238bceSAndroid Build Coastguard Worker }
195*35238bceSAndroid Build Coastguard Worker 
verifyIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)196*35238bceSAndroid Build Coastguard Worker void GetBooleanVerifier::verifyIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference)
197*35238bceSAndroid Build Coastguard Worker {
198*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
199*35238bceSAndroid Build Coastguard Worker 
200*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLboolean> state;
201*35238bceSAndroid Build Coastguard Worker     glGetBooleanv(name, &state);
202*35238bceSAndroid Build Coastguard Worker 
203*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
204*35238bceSAndroid Build Coastguard Worker         return;
205*35238bceSAndroid Build Coastguard Worker 
206*35238bceSAndroid Build Coastguard Worker     if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct)
207*35238bceSAndroid Build Coastguard Worker         return;
208*35238bceSAndroid Build Coastguard Worker 
209*35238bceSAndroid Build Coastguard Worker     if (state == GL_FALSE) // state is zero
210*35238bceSAndroid Build Coastguard Worker     {
211*35238bceSAndroid Build Coastguard Worker         if (reference > 0) // and reference is greater than zero?
212*35238bceSAndroid Build Coastguard Worker         {
213*35238bceSAndroid Build Coastguard Worker             testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
214*35238bceSAndroid Build Coastguard Worker             if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
215*35238bceSAndroid Build Coastguard Worker                 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
216*35238bceSAndroid Build Coastguard Worker         }
217*35238bceSAndroid Build Coastguard Worker     }
218*35238bceSAndroid Build Coastguard Worker     else
219*35238bceSAndroid Build Coastguard Worker     {
220*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
221*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
222*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
223*35238bceSAndroid Build Coastguard Worker     }
224*35238bceSAndroid Build Coastguard Worker }
225*35238bceSAndroid Build Coastguard Worker 
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLuint reference)226*35238bceSAndroid Build Coastguard Worker void GetBooleanVerifier::verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLuint reference)
227*35238bceSAndroid Build Coastguard Worker {
228*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
229*35238bceSAndroid Build Coastguard Worker 
230*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLboolean> state;
231*35238bceSAndroid Build Coastguard Worker     glGetBooleanv(name, &state);
232*35238bceSAndroid Build Coastguard Worker 
233*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
234*35238bceSAndroid Build Coastguard Worker         return;
235*35238bceSAndroid Build Coastguard Worker 
236*35238bceSAndroid Build Coastguard Worker     if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct)
237*35238bceSAndroid Build Coastguard Worker         return;
238*35238bceSAndroid Build Coastguard Worker 
239*35238bceSAndroid Build Coastguard Worker     if (state == GL_FALSE) // state is zero
240*35238bceSAndroid Build Coastguard Worker     {
241*35238bceSAndroid Build Coastguard Worker         if (reference > 0) // and reference is greater than zero?
242*35238bceSAndroid Build Coastguard Worker         {
243*35238bceSAndroid Build Coastguard Worker             testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
244*35238bceSAndroid Build Coastguard Worker             if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
245*35238bceSAndroid Build Coastguard Worker                 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
246*35238bceSAndroid Build Coastguard Worker         }
247*35238bceSAndroid Build Coastguard Worker     }
248*35238bceSAndroid Build Coastguard Worker     else
249*35238bceSAndroid Build Coastguard Worker     {
250*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
251*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
252*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
253*35238bceSAndroid Build Coastguard Worker     }
254*35238bceSAndroid Build Coastguard Worker }
255*35238bceSAndroid Build Coastguard Worker 
verifyIntegerLessOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)256*35238bceSAndroid Build Coastguard Worker void GetBooleanVerifier::verifyIntegerLessOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference)
257*35238bceSAndroid Build Coastguard Worker {
258*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
259*35238bceSAndroid Build Coastguard Worker 
260*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLboolean> state;
261*35238bceSAndroid Build Coastguard Worker     glGetBooleanv(name, &state);
262*35238bceSAndroid Build Coastguard Worker 
263*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
264*35238bceSAndroid Build Coastguard Worker         return;
265*35238bceSAndroid Build Coastguard Worker 
266*35238bceSAndroid Build Coastguard Worker     if (state == GL_TRUE) // state is non-zero, could be less than reference (correct)
267*35238bceSAndroid Build Coastguard Worker         return;
268*35238bceSAndroid Build Coastguard Worker 
269*35238bceSAndroid Build Coastguard Worker     if (state == GL_FALSE) // state is zero
270*35238bceSAndroid Build Coastguard Worker     {
271*35238bceSAndroid Build Coastguard Worker         if (reference < 0) // and reference is less than zero?
272*35238bceSAndroid Build Coastguard Worker         {
273*35238bceSAndroid Build Coastguard Worker             testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
274*35238bceSAndroid Build Coastguard Worker             if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
275*35238bceSAndroid Build Coastguard Worker                 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
276*35238bceSAndroid Build Coastguard Worker         }
277*35238bceSAndroid Build Coastguard Worker     }
278*35238bceSAndroid Build Coastguard Worker     else
279*35238bceSAndroid Build Coastguard Worker     {
280*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
281*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
282*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
283*35238bceSAndroid Build Coastguard Worker     }
284*35238bceSAndroid Build Coastguard Worker }
285*35238bceSAndroid Build Coastguard Worker 
verifyIntegerGreaterOrEqual2(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1)286*35238bceSAndroid Build Coastguard Worker void GetBooleanVerifier::verifyIntegerGreaterOrEqual2(tcu::TestContext &testCtx, GLenum name, GLint reference0,
287*35238bceSAndroid Build Coastguard Worker                                                       GLint reference1)
288*35238bceSAndroid Build Coastguard Worker {
289*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
290*35238bceSAndroid Build Coastguard Worker 
291*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLboolean[2]> boolVector;
292*35238bceSAndroid Build Coastguard Worker     glGetBooleanv(name, boolVector);
293*35238bceSAndroid Build Coastguard Worker 
294*35238bceSAndroid Build Coastguard Worker     if (!boolVector.verifyValidity(testCtx))
295*35238bceSAndroid Build Coastguard Worker         return;
296*35238bceSAndroid Build Coastguard Worker 
297*35238bceSAndroid Build Coastguard Worker     const GLboolean referenceAsGLBoolean[2] = {reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
298*35238bceSAndroid Build Coastguard Worker                                                reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE};
299*35238bceSAndroid Build Coastguard Worker 
300*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceAsGLBoolean); ++ndx)
301*35238bceSAndroid Build Coastguard Worker     {
302*35238bceSAndroid Build Coastguard Worker         if (boolVector[ndx] == GL_TRUE) // state is non-zero, could be greater than any integer
303*35238bceSAndroid Build Coastguard Worker         {
304*35238bceSAndroid Build Coastguard Worker             continue;
305*35238bceSAndroid Build Coastguard Worker         }
306*35238bceSAndroid Build Coastguard Worker         else if (boolVector[ndx] == GL_FALSE) // state is zero
307*35238bceSAndroid Build Coastguard Worker         {
308*35238bceSAndroid Build Coastguard Worker             if (referenceAsGLBoolean[ndx] > 0) // and reference is greater than zero?
309*35238bceSAndroid Build Coastguard Worker             {
310*35238bceSAndroid Build Coastguard Worker                 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
311*35238bceSAndroid Build Coastguard Worker                 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
312*35238bceSAndroid Build Coastguard Worker                     testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
313*35238bceSAndroid Build Coastguard Worker             }
314*35238bceSAndroid Build Coastguard Worker         }
315*35238bceSAndroid Build Coastguard Worker         else
316*35238bceSAndroid Build Coastguard Worker         {
317*35238bceSAndroid Build Coastguard Worker             testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
318*35238bceSAndroid Build Coastguard Worker             if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
319*35238bceSAndroid Build Coastguard Worker                 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
320*35238bceSAndroid Build Coastguard Worker         }
321*35238bceSAndroid Build Coastguard Worker     }
322*35238bceSAndroid Build Coastguard Worker }
323*35238bceSAndroid Build Coastguard Worker 
verifyIntegerAnyOf(tcu::TestContext & testCtx,GLenum name,const GLint references[],size_t referencesLength)324*35238bceSAndroid Build Coastguard Worker void GetBooleanVerifier::verifyIntegerAnyOf(tcu::TestContext &testCtx, GLenum name, const GLint references[],
325*35238bceSAndroid Build Coastguard Worker                                             size_t referencesLength)
326*35238bceSAndroid Build Coastguard Worker {
327*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
328*35238bceSAndroid Build Coastguard Worker 
329*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLboolean> state;
330*35238bceSAndroid Build Coastguard Worker     glGetBooleanv(name, &state);
331*35238bceSAndroid Build Coastguard Worker 
332*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
333*35238bceSAndroid Build Coastguard Worker         return;
334*35238bceSAndroid Build Coastguard Worker 
335*35238bceSAndroid Build Coastguard Worker     for (size_t ndx = 0; ndx < referencesLength; ++ndx)
336*35238bceSAndroid Build Coastguard Worker     {
337*35238bceSAndroid Build Coastguard Worker         const GLboolean expectedGLState = references[ndx] ? GL_TRUE : GL_FALSE;
338*35238bceSAndroid Build Coastguard Worker 
339*35238bceSAndroid Build Coastguard Worker         if (state == expectedGLState)
340*35238bceSAndroid Build Coastguard Worker             return;
341*35238bceSAndroid Build Coastguard Worker     }
342*35238bceSAndroid Build Coastguard Worker 
343*35238bceSAndroid Build Coastguard Worker     testCtx.getLog() << TestLog::Message << "// ERROR: got " << (state == GL_TRUE ? "GL_TRUE" : "GL_FALSE")
344*35238bceSAndroid Build Coastguard Worker                      << TestLog::EndMessage;
345*35238bceSAndroid Build Coastguard Worker     if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
346*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
347*35238bceSAndroid Build Coastguard Worker }
348*35238bceSAndroid Build Coastguard Worker 
verifyStencilMaskInitial(tcu::TestContext & testCtx,GLenum name,int stencilBits)349*35238bceSAndroid Build Coastguard Worker void GetBooleanVerifier::verifyStencilMaskInitial(tcu::TestContext &testCtx, GLenum name, int stencilBits)
350*35238bceSAndroid Build Coastguard Worker {
351*35238bceSAndroid Build Coastguard Worker     // if stencilBits == 0, the mask is allowed to be either GL_TRUE or GL_FALSE
352*35238bceSAndroid Build Coastguard Worker     // otherwise it must be GL_TRUE
353*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
354*35238bceSAndroid Build Coastguard Worker 
355*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLboolean> state;
356*35238bceSAndroid Build Coastguard Worker     glGetBooleanv(name, &state);
357*35238bceSAndroid Build Coastguard Worker 
358*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
359*35238bceSAndroid Build Coastguard Worker         return;
360*35238bceSAndroid Build Coastguard Worker 
361*35238bceSAndroid Build Coastguard Worker     if (stencilBits > 0 && state != GL_TRUE)
362*35238bceSAndroid Build Coastguard Worker     {
363*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
364*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
365*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
366*35238bceSAndroid Build Coastguard Worker     }
367*35238bceSAndroid Build Coastguard Worker }
368*35238bceSAndroid Build Coastguard Worker 
369*35238bceSAndroid Build Coastguard Worker //GetIntegerVerifier
370*35238bceSAndroid Build Coastguard Worker 
371*35238bceSAndroid Build Coastguard Worker class GetIntegerVerifier : public StateVerifier
372*35238bceSAndroid Build Coastguard Worker {
373*35238bceSAndroid Build Coastguard Worker public:
374*35238bceSAndroid Build Coastguard Worker     GetIntegerVerifier(const glw::Functions &gl, tcu::TestLog &log);
375*35238bceSAndroid Build Coastguard Worker     void verifyInteger(tcu::TestContext &testCtx, GLenum name, GLint reference);
376*35238bceSAndroid Build Coastguard Worker     void verifyInteger4(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2,
377*35238bceSAndroid Build Coastguard Worker                         GLint reference3);
378*35238bceSAndroid Build Coastguard Worker     void verifyInteger4Mask(tcu::TestContext &testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1,
379*35238bceSAndroid Build Coastguard Worker                             bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
380*35238bceSAndroid Build Coastguard Worker     void verifyIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference);
381*35238bceSAndroid Build Coastguard Worker     void verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLuint reference);
382*35238bceSAndroid Build Coastguard Worker     void verifyIntegerLessOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference);
383*35238bceSAndroid Build Coastguard Worker     void verifyIntegerGreaterOrEqual2(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1);
384*35238bceSAndroid Build Coastguard Worker     void verifyIntegerAnyOf(tcu::TestContext &testCtx, GLenum name, const GLint references[], size_t referencesLength);
385*35238bceSAndroid Build Coastguard Worker     void verifyStencilMaskInitial(tcu::TestContext &testCtx, GLenum name, int stencilBits);
386*35238bceSAndroid Build Coastguard Worker };
387*35238bceSAndroid Build Coastguard Worker 
GetIntegerVerifier(const glw::Functions & gl,tcu::TestLog & log)388*35238bceSAndroid Build Coastguard Worker GetIntegerVerifier::GetIntegerVerifier(const glw::Functions &gl, tcu::TestLog &log)
389*35238bceSAndroid Build Coastguard Worker     : StateVerifier(gl, log, "_getinteger")
390*35238bceSAndroid Build Coastguard Worker {
391*35238bceSAndroid Build Coastguard Worker }
392*35238bceSAndroid Build Coastguard Worker 
verifyInteger(tcu::TestContext & testCtx,GLenum name,GLint reference)393*35238bceSAndroid Build Coastguard Worker void GetIntegerVerifier::verifyInteger(tcu::TestContext &testCtx, GLenum name, GLint reference)
394*35238bceSAndroid Build Coastguard Worker {
395*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
396*35238bceSAndroid Build Coastguard Worker 
397*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint> state;
398*35238bceSAndroid Build Coastguard Worker     glGetIntegerv(name, &state);
399*35238bceSAndroid Build Coastguard Worker 
400*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
401*35238bceSAndroid Build Coastguard Worker         return;
402*35238bceSAndroid Build Coastguard Worker 
403*35238bceSAndroid Build Coastguard Worker     if (state != reference)
404*35238bceSAndroid Build Coastguard Worker     {
405*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state
406*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
407*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
408*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
409*35238bceSAndroid Build Coastguard Worker     }
410*35238bceSAndroid Build Coastguard Worker }
411*35238bceSAndroid Build Coastguard Worker 
verifyInteger4(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1,GLint reference2,GLint reference3)412*35238bceSAndroid Build Coastguard Worker void GetIntegerVerifier::verifyInteger4(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1,
413*35238bceSAndroid Build Coastguard Worker                                         GLint reference2, GLint reference3)
414*35238bceSAndroid Build Coastguard Worker {
415*35238bceSAndroid Build Coastguard Worker     verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
416*35238bceSAndroid Build Coastguard Worker }
417*35238bceSAndroid Build Coastguard Worker 
verifyInteger4Mask(tcu::TestContext & testCtx,GLenum name,GLint reference0,bool enableRef0,GLint reference1,bool enableRef1,GLint reference2,bool enableRef2,GLint reference3,bool enableRef3)418*35238bceSAndroid Build Coastguard Worker void GetIntegerVerifier::verifyInteger4Mask(tcu::TestContext &testCtx, GLenum name, GLint reference0, bool enableRef0,
419*35238bceSAndroid Build Coastguard Worker                                             GLint reference1, bool enableRef1, GLint reference2, bool enableRef2,
420*35238bceSAndroid Build Coastguard Worker                                             GLint reference3, bool enableRef3)
421*35238bceSAndroid Build Coastguard Worker {
422*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
423*35238bceSAndroid Build Coastguard Worker 
424*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint[4]> intVector4;
425*35238bceSAndroid Build Coastguard Worker     glGetIntegerv(name, intVector4);
426*35238bceSAndroid Build Coastguard Worker 
427*35238bceSAndroid Build Coastguard Worker     if (!intVector4.verifyValidity(testCtx))
428*35238bceSAndroid Build Coastguard Worker         return;
429*35238bceSAndroid Build Coastguard Worker 
430*35238bceSAndroid Build Coastguard Worker     if ((enableRef0 && (intVector4[0] != reference0)) || (enableRef1 && (intVector4[1] != reference1)) ||
431*35238bceSAndroid Build Coastguard Worker         (enableRef2 && (intVector4[2] != reference2)) || (enableRef3 && (intVector4[3] != reference3)))
432*35238bceSAndroid Build Coastguard Worker     {
433*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (enableRef0 ? "" : "(") << reference0
434*35238bceSAndroid Build Coastguard Worker                          << (enableRef0 ? "" : ")") << ", " << (enableRef1 ? "" : "(") << reference1
435*35238bceSAndroid Build Coastguard Worker                          << (enableRef1 ? "" : ")") << ", " << (enableRef2 ? "" : "(") << reference2
436*35238bceSAndroid Build Coastguard Worker                          << (enableRef2 ? "" : ")") << ", " << (enableRef3 ? "" : "(") << reference3
437*35238bceSAndroid Build Coastguard Worker                          << (enableRef3 ? "" : ")") << TestLog::EndMessage;
438*35238bceSAndroid Build Coastguard Worker 
439*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
440*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
441*35238bceSAndroid Build Coastguard Worker     }
442*35238bceSAndroid Build Coastguard Worker }
443*35238bceSAndroid Build Coastguard Worker 
verifyIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)444*35238bceSAndroid Build Coastguard Worker void GetIntegerVerifier::verifyIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference)
445*35238bceSAndroid Build Coastguard Worker {
446*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
447*35238bceSAndroid Build Coastguard Worker 
448*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint> state;
449*35238bceSAndroid Build Coastguard Worker     glGetIntegerv(name, &state);
450*35238bceSAndroid Build Coastguard Worker 
451*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
452*35238bceSAndroid Build Coastguard Worker         return;
453*35238bceSAndroid Build Coastguard Worker 
454*35238bceSAndroid Build Coastguard Worker     if (state < reference)
455*35238bceSAndroid Build Coastguard Worker     {
456*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got "
457*35238bceSAndroid Build Coastguard Worker                          << state << TestLog::EndMessage;
458*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
459*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
460*35238bceSAndroid Build Coastguard Worker     }
461*35238bceSAndroid Build Coastguard Worker }
462*35238bceSAndroid Build Coastguard Worker 
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLuint reference)463*35238bceSAndroid Build Coastguard Worker void GetIntegerVerifier::verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLuint reference)
464*35238bceSAndroid Build Coastguard Worker {
465*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
466*35238bceSAndroid Build Coastguard Worker 
467*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint> state;
468*35238bceSAndroid Build Coastguard Worker     glGetIntegerv(name, &state);
469*35238bceSAndroid Build Coastguard Worker 
470*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
471*35238bceSAndroid Build Coastguard Worker         return;
472*35238bceSAndroid Build Coastguard Worker 
473*35238bceSAndroid Build Coastguard Worker     if (GLuint(state) < reference)
474*35238bceSAndroid Build Coastguard Worker     {
475*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got "
476*35238bceSAndroid Build Coastguard Worker                          << GLuint(state) << TestLog::EndMessage;
477*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
478*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
479*35238bceSAndroid Build Coastguard Worker     }
480*35238bceSAndroid Build Coastguard Worker }
481*35238bceSAndroid Build Coastguard Worker 
verifyIntegerLessOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)482*35238bceSAndroid Build Coastguard Worker void GetIntegerVerifier::verifyIntegerLessOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference)
483*35238bceSAndroid Build Coastguard Worker {
484*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
485*35238bceSAndroid Build Coastguard Worker 
486*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint> state;
487*35238bceSAndroid Build Coastguard Worker     glGetIntegerv(name, &state);
488*35238bceSAndroid Build Coastguard Worker 
489*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
490*35238bceSAndroid Build Coastguard Worker         return;
491*35238bceSAndroid Build Coastguard Worker 
492*35238bceSAndroid Build Coastguard Worker     if (state > reference)
493*35238bceSAndroid Build Coastguard Worker     {
494*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << reference << "; got " << state
495*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
496*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
497*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
498*35238bceSAndroid Build Coastguard Worker     }
499*35238bceSAndroid Build Coastguard Worker }
500*35238bceSAndroid Build Coastguard Worker 
verifyIntegerGreaterOrEqual2(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1)501*35238bceSAndroid Build Coastguard Worker void GetIntegerVerifier::verifyIntegerGreaterOrEqual2(tcu::TestContext &testCtx, GLenum name, GLint reference0,
502*35238bceSAndroid Build Coastguard Worker                                                       GLint reference1)
503*35238bceSAndroid Build Coastguard Worker {
504*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
505*35238bceSAndroid Build Coastguard Worker 
506*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint[2]> intVector2;
507*35238bceSAndroid Build Coastguard Worker     glGetIntegerv(name, intVector2);
508*35238bceSAndroid Build Coastguard Worker 
509*35238bceSAndroid Build Coastguard Worker     if (!intVector2.verifyValidity(testCtx))
510*35238bceSAndroid Build Coastguard Worker         return;
511*35238bceSAndroid Build Coastguard Worker 
512*35238bceSAndroid Build Coastguard Worker     if (intVector2[0] < reference0 || intVector2[1] < reference1)
513*35238bceSAndroid Build Coastguard Worker     {
514*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference0 << ", "
515*35238bceSAndroid Build Coastguard Worker                          << reference1 << "; got " << intVector2[0] << ", " << intVector2[0] << TestLog::EndMessage;
516*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
517*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
518*35238bceSAndroid Build Coastguard Worker     }
519*35238bceSAndroid Build Coastguard Worker }
520*35238bceSAndroid Build Coastguard Worker 
verifyIntegerAnyOf(tcu::TestContext & testCtx,GLenum name,const GLint references[],size_t referencesLength)521*35238bceSAndroid Build Coastguard Worker void GetIntegerVerifier::verifyIntegerAnyOf(tcu::TestContext &testCtx, GLenum name, const GLint references[],
522*35238bceSAndroid Build Coastguard Worker                                             size_t referencesLength)
523*35238bceSAndroid Build Coastguard Worker {
524*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
525*35238bceSAndroid Build Coastguard Worker 
526*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint> state;
527*35238bceSAndroid Build Coastguard Worker     glGetIntegerv(name, &state);
528*35238bceSAndroid Build Coastguard Worker 
529*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
530*35238bceSAndroid Build Coastguard Worker         return;
531*35238bceSAndroid Build Coastguard Worker 
532*35238bceSAndroid Build Coastguard Worker     for (size_t ndx = 0; ndx < referencesLength; ++ndx)
533*35238bceSAndroid Build Coastguard Worker     {
534*35238bceSAndroid Build Coastguard Worker         const GLint expectedGLState = references[ndx];
535*35238bceSAndroid Build Coastguard Worker 
536*35238bceSAndroid Build Coastguard Worker         if (state == expectedGLState)
537*35238bceSAndroid Build Coastguard Worker             return;
538*35238bceSAndroid Build Coastguard Worker     }
539*35238bceSAndroid Build Coastguard Worker 
540*35238bceSAndroid Build Coastguard Worker     testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
541*35238bceSAndroid Build Coastguard Worker     if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
542*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
543*35238bceSAndroid Build Coastguard Worker }
544*35238bceSAndroid Build Coastguard Worker 
verifyStencilMaskInitial(tcu::TestContext & testCtx,GLenum name,int stencilBits)545*35238bceSAndroid Build Coastguard Worker void GetIntegerVerifier::verifyStencilMaskInitial(tcu::TestContext &testCtx, GLenum name, int stencilBits)
546*35238bceSAndroid Build Coastguard Worker {
547*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
548*35238bceSAndroid Build Coastguard Worker 
549*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint> state;
550*35238bceSAndroid Build Coastguard Worker     glGetIntegerv(name, &state);
551*35238bceSAndroid Build Coastguard Worker 
552*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
553*35238bceSAndroid Build Coastguard Worker         return;
554*35238bceSAndroid Build Coastguard Worker 
555*35238bceSAndroid Build Coastguard Worker     const GLint reference = (1 << stencilBits) - 1;
556*35238bceSAndroid Build Coastguard Worker 
557*35238bceSAndroid Build Coastguard Worker     if ((state & reference) != reference) // the least significant stencilBits bits should be on
558*35238bceSAndroid Build Coastguard Worker     {
559*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected minimum mask of " << reference << "; got " << state
560*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
561*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
562*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value");
563*35238bceSAndroid Build Coastguard Worker     }
564*35238bceSAndroid Build Coastguard Worker }
565*35238bceSAndroid Build Coastguard Worker 
566*35238bceSAndroid Build Coastguard Worker //GetInteger64Verifier
567*35238bceSAndroid Build Coastguard Worker 
568*35238bceSAndroid Build Coastguard Worker class GetInteger64Verifier : public StateVerifier
569*35238bceSAndroid Build Coastguard Worker {
570*35238bceSAndroid Build Coastguard Worker public:
571*35238bceSAndroid Build Coastguard Worker     GetInteger64Verifier(const glw::Functions &gl, tcu::TestLog &log);
572*35238bceSAndroid Build Coastguard Worker     void verifyInteger(tcu::TestContext &testCtx, GLenum name, GLint reference);
573*35238bceSAndroid Build Coastguard Worker     void verifyInteger4(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2,
574*35238bceSAndroid Build Coastguard Worker                         GLint reference3);
575*35238bceSAndroid Build Coastguard Worker     void verifyInteger4Mask(tcu::TestContext &testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1,
576*35238bceSAndroid Build Coastguard Worker                             bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
577*35238bceSAndroid Build Coastguard Worker     void verifyIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference);
578*35238bceSAndroid Build Coastguard Worker     void verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLuint reference);
579*35238bceSAndroid Build Coastguard Worker     void verifyIntegerLessOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference);
580*35238bceSAndroid Build Coastguard Worker     void verifyIntegerGreaterOrEqual2(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1);
581*35238bceSAndroid Build Coastguard Worker     void verifyIntegerAnyOf(tcu::TestContext &testCtx, GLenum name, const GLint references[], size_t referencesLength);
582*35238bceSAndroid Build Coastguard Worker     void verifyStencilMaskInitial(tcu::TestContext &testCtx, GLenum name, int stencilBits);
583*35238bceSAndroid Build Coastguard Worker };
584*35238bceSAndroid Build Coastguard Worker 
GetInteger64Verifier(const glw::Functions & gl,tcu::TestLog & log)585*35238bceSAndroid Build Coastguard Worker GetInteger64Verifier::GetInteger64Verifier(const glw::Functions &gl, tcu::TestLog &log)
586*35238bceSAndroid Build Coastguard Worker     : StateVerifier(gl, log, "_getinteger64")
587*35238bceSAndroid Build Coastguard Worker {
588*35238bceSAndroid Build Coastguard Worker }
589*35238bceSAndroid Build Coastguard Worker 
verifyInteger(tcu::TestContext & testCtx,GLenum name,GLint reference)590*35238bceSAndroid Build Coastguard Worker void GetInteger64Verifier::verifyInteger(tcu::TestContext &testCtx, GLenum name, GLint reference)
591*35238bceSAndroid Build Coastguard Worker {
592*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
593*35238bceSAndroid Build Coastguard Worker 
594*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint64> state;
595*35238bceSAndroid Build Coastguard Worker     glGetInteger64v(name, &state);
596*35238bceSAndroid Build Coastguard Worker 
597*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
598*35238bceSAndroid Build Coastguard Worker         return;
599*35238bceSAndroid Build Coastguard Worker 
600*35238bceSAndroid Build Coastguard Worker     if (state != GLint64(reference))
601*35238bceSAndroid Build Coastguard Worker     {
602*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state
603*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
604*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
605*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
606*35238bceSAndroid Build Coastguard Worker     }
607*35238bceSAndroid Build Coastguard Worker }
608*35238bceSAndroid Build Coastguard Worker 
verifyInteger4(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1,GLint reference2,GLint reference3)609*35238bceSAndroid Build Coastguard Worker void GetInteger64Verifier::verifyInteger4(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1,
610*35238bceSAndroid Build Coastguard Worker                                           GLint reference2, GLint reference3)
611*35238bceSAndroid Build Coastguard Worker {
612*35238bceSAndroid Build Coastguard Worker     verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
613*35238bceSAndroid Build Coastguard Worker }
614*35238bceSAndroid Build Coastguard Worker 
verifyInteger4Mask(tcu::TestContext & testCtx,GLenum name,GLint reference0,bool enableRef0,GLint reference1,bool enableRef1,GLint reference2,bool enableRef2,GLint reference3,bool enableRef3)615*35238bceSAndroid Build Coastguard Worker void GetInteger64Verifier::verifyInteger4Mask(tcu::TestContext &testCtx, GLenum name, GLint reference0, bool enableRef0,
616*35238bceSAndroid Build Coastguard Worker                                               GLint reference1, bool enableRef1, GLint reference2, bool enableRef2,
617*35238bceSAndroid Build Coastguard Worker                                               GLint reference3, bool enableRef3)
618*35238bceSAndroid Build Coastguard Worker {
619*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
620*35238bceSAndroid Build Coastguard Worker 
621*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint64[4]> intVector4;
622*35238bceSAndroid Build Coastguard Worker     glGetInteger64v(name, intVector4);
623*35238bceSAndroid Build Coastguard Worker 
624*35238bceSAndroid Build Coastguard Worker     if (!intVector4.verifyValidity(testCtx))
625*35238bceSAndroid Build Coastguard Worker         return;
626*35238bceSAndroid Build Coastguard Worker 
627*35238bceSAndroid Build Coastguard Worker     if ((enableRef0 && (intVector4[0] != GLint64(reference0))) ||
628*35238bceSAndroid Build Coastguard Worker         (enableRef1 && (intVector4[1] != GLint64(reference1))) ||
629*35238bceSAndroid Build Coastguard Worker         (enableRef2 && (intVector4[2] != GLint64(reference2))) ||
630*35238bceSAndroid Build Coastguard Worker         (enableRef3 && (intVector4[3] != GLint64(reference3))))
631*35238bceSAndroid Build Coastguard Worker     {
632*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (enableRef0 ? "" : "(") << reference0
633*35238bceSAndroid Build Coastguard Worker                          << (enableRef0 ? "" : ")") << ", " << (enableRef1 ? "" : "(") << reference1
634*35238bceSAndroid Build Coastguard Worker                          << (enableRef1 ? "" : ")") << ", " << (enableRef2 ? "" : "(") << reference2
635*35238bceSAndroid Build Coastguard Worker                          << (enableRef2 ? "" : ")") << ", " << (enableRef3 ? "" : "(") << reference3
636*35238bceSAndroid Build Coastguard Worker                          << (enableRef3 ? "" : ")") << TestLog::EndMessage;
637*35238bceSAndroid Build Coastguard Worker 
638*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
639*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
640*35238bceSAndroid Build Coastguard Worker     }
641*35238bceSAndroid Build Coastguard Worker }
642*35238bceSAndroid Build Coastguard Worker 
verifyIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)643*35238bceSAndroid Build Coastguard Worker void GetInteger64Verifier::verifyIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference)
644*35238bceSAndroid Build Coastguard Worker {
645*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
646*35238bceSAndroid Build Coastguard Worker 
647*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint64> state;
648*35238bceSAndroid Build Coastguard Worker     glGetInteger64v(name, &state);
649*35238bceSAndroid Build Coastguard Worker 
650*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
651*35238bceSAndroid Build Coastguard Worker         return;
652*35238bceSAndroid Build Coastguard Worker 
653*35238bceSAndroid Build Coastguard Worker     if (state < GLint64(reference))
654*35238bceSAndroid Build Coastguard Worker     {
655*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference)
656*35238bceSAndroid Build Coastguard Worker                          << "; got " << state << TestLog::EndMessage;
657*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
658*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
659*35238bceSAndroid Build Coastguard Worker     }
660*35238bceSAndroid Build Coastguard Worker }
661*35238bceSAndroid Build Coastguard Worker 
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLuint reference)662*35238bceSAndroid Build Coastguard Worker void GetInteger64Verifier::verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLuint reference)
663*35238bceSAndroid Build Coastguard Worker {
664*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
665*35238bceSAndroid Build Coastguard Worker 
666*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint64> state;
667*35238bceSAndroid Build Coastguard Worker     glGetInteger64v(name, &state);
668*35238bceSAndroid Build Coastguard Worker 
669*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
670*35238bceSAndroid Build Coastguard Worker         return;
671*35238bceSAndroid Build Coastguard Worker 
672*35238bceSAndroid Build Coastguard Worker     if (GLuint(state) < GLint64(reference))
673*35238bceSAndroid Build Coastguard Worker     {
674*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference)
675*35238bceSAndroid Build Coastguard Worker                          << "; got " << GLuint(state) << TestLog::EndMessage;
676*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
677*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
678*35238bceSAndroid Build Coastguard Worker     }
679*35238bceSAndroid Build Coastguard Worker }
680*35238bceSAndroid Build Coastguard Worker 
verifyIntegerLessOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)681*35238bceSAndroid Build Coastguard Worker void GetInteger64Verifier::verifyIntegerLessOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference)
682*35238bceSAndroid Build Coastguard Worker {
683*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
684*35238bceSAndroid Build Coastguard Worker 
685*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint64> state;
686*35238bceSAndroid Build Coastguard Worker     glGetInteger64v(name, &state);
687*35238bceSAndroid Build Coastguard Worker 
688*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
689*35238bceSAndroid Build Coastguard Worker         return;
690*35238bceSAndroid Build Coastguard Worker 
691*35238bceSAndroid Build Coastguard Worker     if (state > GLint64(reference))
692*35238bceSAndroid Build Coastguard Worker     {
693*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << GLint64(reference) << "; got "
694*35238bceSAndroid Build Coastguard Worker                          << state << TestLog::EndMessage;
695*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
696*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
697*35238bceSAndroid Build Coastguard Worker     }
698*35238bceSAndroid Build Coastguard Worker }
699*35238bceSAndroid Build Coastguard Worker 
verifyIntegerGreaterOrEqual2(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1)700*35238bceSAndroid Build Coastguard Worker void GetInteger64Verifier::verifyIntegerGreaterOrEqual2(tcu::TestContext &testCtx, GLenum name, GLint reference0,
701*35238bceSAndroid Build Coastguard Worker                                                         GLint reference1)
702*35238bceSAndroid Build Coastguard Worker {
703*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
704*35238bceSAndroid Build Coastguard Worker 
705*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint64[2]> intVector2;
706*35238bceSAndroid Build Coastguard Worker     glGetInteger64v(name, intVector2);
707*35238bceSAndroid Build Coastguard Worker 
708*35238bceSAndroid Build Coastguard Worker     if (!intVector2.verifyValidity(testCtx))
709*35238bceSAndroid Build Coastguard Worker         return;
710*35238bceSAndroid Build Coastguard Worker 
711*35238bceSAndroid Build Coastguard Worker     if (intVector2[0] < GLint64(reference0) || intVector2[1] < GLint64(reference1))
712*35238bceSAndroid Build Coastguard Worker     {
713*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference0) << ", "
714*35238bceSAndroid Build Coastguard Worker                          << GLint64(reference1) << "; got " << intVector2[0] << ", " << intVector2[1]
715*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
716*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
717*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
718*35238bceSAndroid Build Coastguard Worker     }
719*35238bceSAndroid Build Coastguard Worker }
720*35238bceSAndroid Build Coastguard Worker 
verifyIntegerAnyOf(tcu::TestContext & testCtx,GLenum name,const GLint references[],size_t referencesLength)721*35238bceSAndroid Build Coastguard Worker void GetInteger64Verifier::verifyIntegerAnyOf(tcu::TestContext &testCtx, GLenum name, const GLint references[],
722*35238bceSAndroid Build Coastguard Worker                                               size_t referencesLength)
723*35238bceSAndroid Build Coastguard Worker {
724*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
725*35238bceSAndroid Build Coastguard Worker 
726*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint64> state;
727*35238bceSAndroid Build Coastguard Worker     glGetInteger64v(name, &state);
728*35238bceSAndroid Build Coastguard Worker 
729*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
730*35238bceSAndroid Build Coastguard Worker         return;
731*35238bceSAndroid Build Coastguard Worker 
732*35238bceSAndroid Build Coastguard Worker     for (size_t ndx = 0; ndx < referencesLength; ++ndx)
733*35238bceSAndroid Build Coastguard Worker     {
734*35238bceSAndroid Build Coastguard Worker         const GLint64 expectedGLState = GLint64(references[ndx]);
735*35238bceSAndroid Build Coastguard Worker 
736*35238bceSAndroid Build Coastguard Worker         if (state == expectedGLState)
737*35238bceSAndroid Build Coastguard Worker             return;
738*35238bceSAndroid Build Coastguard Worker     }
739*35238bceSAndroid Build Coastguard Worker 
740*35238bceSAndroid Build Coastguard Worker     testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
741*35238bceSAndroid Build Coastguard Worker     if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
742*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
743*35238bceSAndroid Build Coastguard Worker }
744*35238bceSAndroid Build Coastguard Worker 
verifyStencilMaskInitial(tcu::TestContext & testCtx,GLenum name,int stencilBits)745*35238bceSAndroid Build Coastguard Worker void GetInteger64Verifier::verifyStencilMaskInitial(tcu::TestContext &testCtx, GLenum name, int stencilBits)
746*35238bceSAndroid Build Coastguard Worker {
747*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
748*35238bceSAndroid Build Coastguard Worker 
749*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLint64> state;
750*35238bceSAndroid Build Coastguard Worker     glGetInteger64v(name, &state);
751*35238bceSAndroid Build Coastguard Worker 
752*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
753*35238bceSAndroid Build Coastguard Worker         return;
754*35238bceSAndroid Build Coastguard Worker 
755*35238bceSAndroid Build Coastguard Worker     const GLint64 reference = (1ULL << stencilBits) - 1;
756*35238bceSAndroid Build Coastguard Worker 
757*35238bceSAndroid Build Coastguard Worker     if ((state & reference) != reference) // the least significant stencilBits bits should be on
758*35238bceSAndroid Build Coastguard Worker     {
759*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected mimimum mask of " << reference << "; got " << state
760*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
761*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
762*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value");
763*35238bceSAndroid Build Coastguard Worker     }
764*35238bceSAndroid Build Coastguard Worker }
765*35238bceSAndroid Build Coastguard Worker 
766*35238bceSAndroid Build Coastguard Worker //GetFloatVerifier
767*35238bceSAndroid Build Coastguard Worker 
768*35238bceSAndroid Build Coastguard Worker class GetFloatVerifier : public StateVerifier
769*35238bceSAndroid Build Coastguard Worker {
770*35238bceSAndroid Build Coastguard Worker public:
771*35238bceSAndroid Build Coastguard Worker     GetFloatVerifier(const glw::Functions &gl, tcu::TestLog &log);
772*35238bceSAndroid Build Coastguard Worker     void verifyInteger(tcu::TestContext &testCtx, GLenum name, GLint reference);
773*35238bceSAndroid Build Coastguard Worker     void verifyInteger4(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2,
774*35238bceSAndroid Build Coastguard Worker                         GLint reference3);
775*35238bceSAndroid Build Coastguard Worker     void verifyInteger4Mask(tcu::TestContext &testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1,
776*35238bceSAndroid Build Coastguard Worker                             bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
777*35238bceSAndroid Build Coastguard Worker     void verifyIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference);
778*35238bceSAndroid Build Coastguard Worker     void verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLuint reference);
779*35238bceSAndroid Build Coastguard Worker     void verifyIntegerLessOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference);
780*35238bceSAndroid Build Coastguard Worker     void verifyIntegerGreaterOrEqual2(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1);
781*35238bceSAndroid Build Coastguard Worker     void verifyIntegerAnyOf(tcu::TestContext &testCtx, GLenum name, const GLint references[], size_t referencesLength);
782*35238bceSAndroid Build Coastguard Worker     void verifyStencilMaskInitial(tcu::TestContext &testCtx, GLenum name, int stencilBits);
783*35238bceSAndroid Build Coastguard Worker };
784*35238bceSAndroid Build Coastguard Worker 
GetFloatVerifier(const glw::Functions & gl,tcu::TestLog & log)785*35238bceSAndroid Build Coastguard Worker GetFloatVerifier::GetFloatVerifier(const glw::Functions &gl, tcu::TestLog &log) : StateVerifier(gl, log, "_getfloat")
786*35238bceSAndroid Build Coastguard Worker {
787*35238bceSAndroid Build Coastguard Worker }
788*35238bceSAndroid Build Coastguard Worker 
verifyInteger(tcu::TestContext & testCtx,GLenum name,GLint reference)789*35238bceSAndroid Build Coastguard Worker void GetFloatVerifier::verifyInteger(tcu::TestContext &testCtx, GLenum name, GLint reference)
790*35238bceSAndroid Build Coastguard Worker {
791*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
792*35238bceSAndroid Build Coastguard Worker 
793*35238bceSAndroid Build Coastguard Worker     const GLfloat referenceAsFloat = GLfloat(reference);
794*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(
795*35238bceSAndroid Build Coastguard Worker         reference ==
796*35238bceSAndroid Build Coastguard Worker         GLint(
797*35238bceSAndroid Build Coastguard Worker             referenceAsFloat)); // reference integer must have 1:1 mapping to float for this to work. Reference value is always such value in these tests
798*35238bceSAndroid Build Coastguard Worker 
799*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLfloat> state;
800*35238bceSAndroid Build Coastguard Worker     glGetFloatv(name, &state);
801*35238bceSAndroid Build Coastguard Worker 
802*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
803*35238bceSAndroid Build Coastguard Worker         return;
804*35238bceSAndroid Build Coastguard Worker 
805*35238bceSAndroid Build Coastguard Worker     if (state != referenceAsFloat)
806*35238bceSAndroid Build Coastguard Worker     {
807*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsFloat << "; got " << state
808*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
809*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
810*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
811*35238bceSAndroid Build Coastguard Worker     }
812*35238bceSAndroid Build Coastguard Worker }
813*35238bceSAndroid Build Coastguard Worker 
verifyInteger4(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1,GLint reference2,GLint reference3)814*35238bceSAndroid Build Coastguard Worker void GetFloatVerifier::verifyInteger4(tcu::TestContext &testCtx, GLenum name, GLint reference0, GLint reference1,
815*35238bceSAndroid Build Coastguard Worker                                       GLint reference2, GLint reference3)
816*35238bceSAndroid Build Coastguard Worker {
817*35238bceSAndroid Build Coastguard Worker     verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
818*35238bceSAndroid Build Coastguard Worker }
819*35238bceSAndroid Build Coastguard Worker 
verifyInteger4Mask(tcu::TestContext & testCtx,GLenum name,GLint reference0,bool enableRef0,GLint reference1,bool enableRef1,GLint reference2,bool enableRef2,GLint reference3,bool enableRef3)820*35238bceSAndroid Build Coastguard Worker void GetFloatVerifier::verifyInteger4Mask(tcu::TestContext &testCtx, GLenum name, GLint reference0, bool enableRef0,
821*35238bceSAndroid Build Coastguard Worker                                           GLint reference1, bool enableRef1, GLint reference2, bool enableRef2,
822*35238bceSAndroid Build Coastguard Worker                                           GLint reference3, bool enableRef3)
823*35238bceSAndroid Build Coastguard Worker {
824*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
825*35238bceSAndroid Build Coastguard Worker 
826*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLfloat[4]> floatVector4;
827*35238bceSAndroid Build Coastguard Worker     glGetFloatv(name, floatVector4);
828*35238bceSAndroid Build Coastguard Worker 
829*35238bceSAndroid Build Coastguard Worker     if (!floatVector4.verifyValidity(testCtx))
830*35238bceSAndroid Build Coastguard Worker         return;
831*35238bceSAndroid Build Coastguard Worker 
832*35238bceSAndroid Build Coastguard Worker     if ((enableRef0 && (floatVector4[0] != GLfloat(reference0))) ||
833*35238bceSAndroid Build Coastguard Worker         (enableRef1 && (floatVector4[1] != GLfloat(reference1))) ||
834*35238bceSAndroid Build Coastguard Worker         (enableRef2 && (floatVector4[2] != GLfloat(reference2))) ||
835*35238bceSAndroid Build Coastguard Worker         (enableRef3 && (floatVector4[3] != GLfloat(reference3))))
836*35238bceSAndroid Build Coastguard Worker     {
837*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (enableRef0 ? "" : "(") << GLfloat(reference0)
838*35238bceSAndroid Build Coastguard Worker                          << (enableRef0 ? "" : ")") << ", " << (enableRef1 ? "" : "(") << GLfloat(reference1)
839*35238bceSAndroid Build Coastguard Worker                          << (enableRef1 ? "" : ")") << ", " << (enableRef2 ? "" : "(") << GLfloat(reference2)
840*35238bceSAndroid Build Coastguard Worker                          << (enableRef2 ? "" : ")") << ", " << (enableRef3 ? "" : "(") << GLfloat(reference3)
841*35238bceSAndroid Build Coastguard Worker                          << (enableRef3 ? "" : ")") << TestLog::EndMessage;
842*35238bceSAndroid Build Coastguard Worker 
843*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
844*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
845*35238bceSAndroid Build Coastguard Worker     }
846*35238bceSAndroid Build Coastguard Worker }
847*35238bceSAndroid Build Coastguard Worker 
verifyIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)848*35238bceSAndroid Build Coastguard Worker void GetFloatVerifier::verifyIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference)
849*35238bceSAndroid Build Coastguard Worker {
850*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
851*35238bceSAndroid Build Coastguard Worker 
852*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLfloat> state;
853*35238bceSAndroid Build Coastguard Worker     glGetFloatv(name, &state);
854*35238bceSAndroid Build Coastguard Worker 
855*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
856*35238bceSAndroid Build Coastguard Worker         return;
857*35238bceSAndroid Build Coastguard Worker 
858*35238bceSAndroid Build Coastguard Worker     if (state < GLfloat(reference))
859*35238bceSAndroid Build Coastguard Worker     {
860*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference)
861*35238bceSAndroid Build Coastguard Worker                          << "; got " << state << TestLog::EndMessage;
862*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
863*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
864*35238bceSAndroid Build Coastguard Worker     }
865*35238bceSAndroid Build Coastguard Worker }
866*35238bceSAndroid Build Coastguard Worker 
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext & testCtx,GLenum name,GLuint reference)867*35238bceSAndroid Build Coastguard Worker void GetFloatVerifier::verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext &testCtx, GLenum name, GLuint reference)
868*35238bceSAndroid Build Coastguard Worker {
869*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
870*35238bceSAndroid Build Coastguard Worker 
871*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLfloat> state;
872*35238bceSAndroid Build Coastguard Worker     glGetFloatv(name, &state);
873*35238bceSAndroid Build Coastguard Worker 
874*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
875*35238bceSAndroid Build Coastguard Worker         return;
876*35238bceSAndroid Build Coastguard Worker 
877*35238bceSAndroid Build Coastguard Worker     if (state < GLfloat(reference))
878*35238bceSAndroid Build Coastguard Worker     {
879*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference)
880*35238bceSAndroid Build Coastguard Worker                          << "; got " << state << TestLog::EndMessage;
881*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
882*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
883*35238bceSAndroid Build Coastguard Worker     }
884*35238bceSAndroid Build Coastguard Worker }
885*35238bceSAndroid Build Coastguard Worker 
verifyIntegerLessOrEqual(tcu::TestContext & testCtx,GLenum name,GLint reference)886*35238bceSAndroid Build Coastguard Worker void GetFloatVerifier::verifyIntegerLessOrEqual(tcu::TestContext &testCtx, GLenum name, GLint reference)
887*35238bceSAndroid Build Coastguard Worker {
888*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
889*35238bceSAndroid Build Coastguard Worker 
890*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLfloat> state;
891*35238bceSAndroid Build Coastguard Worker     glGetFloatv(name, &state);
892*35238bceSAndroid Build Coastguard Worker 
893*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
894*35238bceSAndroid Build Coastguard Worker         return;
895*35238bceSAndroid Build Coastguard Worker 
896*35238bceSAndroid Build Coastguard Worker     if (state > GLfloat(reference))
897*35238bceSAndroid Build Coastguard Worker     {
898*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << GLfloat(reference) << "; got "
899*35238bceSAndroid Build Coastguard Worker                          << state << TestLog::EndMessage;
900*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
901*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
902*35238bceSAndroid Build Coastguard Worker     }
903*35238bceSAndroid Build Coastguard Worker }
904*35238bceSAndroid Build Coastguard Worker 
verifyIntegerGreaterOrEqual2(tcu::TestContext & testCtx,GLenum name,GLint reference0,GLint reference1)905*35238bceSAndroid Build Coastguard Worker void GetFloatVerifier::verifyIntegerGreaterOrEqual2(tcu::TestContext &testCtx, GLenum name, GLint reference0,
906*35238bceSAndroid Build Coastguard Worker                                                     GLint reference1)
907*35238bceSAndroid Build Coastguard Worker {
908*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
909*35238bceSAndroid Build Coastguard Worker 
910*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLfloat[2]> floatVector2;
911*35238bceSAndroid Build Coastguard Worker     glGetFloatv(name, floatVector2);
912*35238bceSAndroid Build Coastguard Worker 
913*35238bceSAndroid Build Coastguard Worker     if (!floatVector2.verifyValidity(testCtx))
914*35238bceSAndroid Build Coastguard Worker         return;
915*35238bceSAndroid Build Coastguard Worker 
916*35238bceSAndroid Build Coastguard Worker     if (floatVector2[0] < GLfloat(reference0) || floatVector2[1] < GLfloat(reference1))
917*35238bceSAndroid Build Coastguard Worker     {
918*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference0) << ", "
919*35238bceSAndroid Build Coastguard Worker                          << GLfloat(reference1) << "; got " << floatVector2[0] << ", " << floatVector2[1]
920*35238bceSAndroid Build Coastguard Worker                          << TestLog::EndMessage;
921*35238bceSAndroid Build Coastguard Worker         if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
922*35238bceSAndroid Build Coastguard Worker             testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
923*35238bceSAndroid Build Coastguard Worker     }
924*35238bceSAndroid Build Coastguard Worker }
925*35238bceSAndroid Build Coastguard Worker 
verifyIntegerAnyOf(tcu::TestContext & testCtx,GLenum name,const GLint references[],size_t referencesLength)926*35238bceSAndroid Build Coastguard Worker void GetFloatVerifier::verifyIntegerAnyOf(tcu::TestContext &testCtx, GLenum name, const GLint references[],
927*35238bceSAndroid Build Coastguard Worker                                           size_t referencesLength)
928*35238bceSAndroid Build Coastguard Worker {
929*35238bceSAndroid Build Coastguard Worker     using tcu::TestLog;
930*35238bceSAndroid Build Coastguard Worker 
931*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<GLfloat> state;
932*35238bceSAndroid Build Coastguard Worker     glGetFloatv(name, &state);
933*35238bceSAndroid Build Coastguard Worker 
934*35238bceSAndroid Build Coastguard Worker     if (!state.verifyValidity(testCtx))
935*35238bceSAndroid Build Coastguard Worker         return;
936*35238bceSAndroid Build Coastguard Worker 
937*35238bceSAndroid Build Coastguard Worker     for (size_t ndx = 0; ndx < referencesLength; ++ndx)
938*35238bceSAndroid Build Coastguard Worker     {
939*35238bceSAndroid Build Coastguard Worker         const GLfloat expectedGLState = GLfloat(references[ndx]);
940*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(
941*35238bceSAndroid Build Coastguard Worker             references[ndx] ==
942*35238bceSAndroid Build Coastguard Worker             GLint(
943*35238bceSAndroid Build Coastguard Worker                 expectedGLState)); // reference integer must have 1:1 mapping to float for this to work. Reference value is always such value in these tests
944*35238bceSAndroid Build Coastguard Worker 
945*35238bceSAndroid Build Coastguard Worker         if (state == expectedGLState)
946*35238bceSAndroid Build Coastguard Worker             return;
947*35238bceSAndroid Build Coastguard Worker     }
948*35238bceSAndroid Build Coastguard Worker 
949*35238bceSAndroid Build Coastguard Worker     testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
950*35238bceSAndroid Build Coastguard Worker     if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
951*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
952*35238bceSAndroid Build Coastguard Worker }
953*35238bceSAndroid Build Coastguard Worker 
verifyStencilMaskInitial(tcu::TestContext & testCtx,GLenum name,int stencilBits)954*35238bceSAndroid Build Coastguard Worker void GetFloatVerifier::verifyStencilMaskInitial(tcu::TestContext &testCtx, GLenum name, int stencilBits)
955*35238bceSAndroid Build Coastguard Worker {
956*35238bceSAndroid Build Coastguard Worker     // checking the mask bits with float doesn't make much sense because of conversion errors
957*35238bceSAndroid Build Coastguard Worker     // just verify that the value is greater or equal to the minimum value
958*35238bceSAndroid Build Coastguard Worker     const GLint reference = (1 << stencilBits) - 1;
959*35238bceSAndroid Build Coastguard Worker     verifyIntegerGreaterOrEqual(testCtx, name, reference);
960*35238bceSAndroid Build Coastguard Worker }
961*35238bceSAndroid Build Coastguard Worker 
962*35238bceSAndroid Build Coastguard Worker } // namespace IntegerStateQueryVerifiers
963*35238bceSAndroid Build Coastguard Worker 
964*35238bceSAndroid Build Coastguard Worker namespace
965*35238bceSAndroid Build Coastguard Worker {
966*35238bceSAndroid Build Coastguard Worker 
967*35238bceSAndroid Build Coastguard Worker using namespace IntegerStateQueryVerifiers;
968*35238bceSAndroid Build Coastguard Worker using namespace deqp::gls::StateQueryUtil;
969*35238bceSAndroid Build Coastguard Worker 
970*35238bceSAndroid Build Coastguard Worker class ConstantMinimumValueTestCase : public ApiCase
971*35238bceSAndroid Build Coastguard Worker {
972*35238bceSAndroid Build Coastguard Worker public:
ConstantMinimumValueTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum targetName,GLint minValue)973*35238bceSAndroid Build Coastguard Worker     ConstantMinimumValueTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
974*35238bceSAndroid Build Coastguard Worker                                  GLenum targetName, GLint minValue)
975*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
976*35238bceSAndroid Build Coastguard Worker         , m_targetName(targetName)
977*35238bceSAndroid Build Coastguard Worker         , m_minValue(minValue)
978*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
979*35238bceSAndroid Build Coastguard Worker     {
980*35238bceSAndroid Build Coastguard Worker     }
981*35238bceSAndroid Build Coastguard Worker 
test(void)982*35238bceSAndroid Build Coastguard Worker     void test(void)
983*35238bceSAndroid Build Coastguard Worker     {
984*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyUnsignedIntegerGreaterOrEqual(m_testCtx, m_targetName, m_minValue);
985*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
986*35238bceSAndroid Build Coastguard Worker     }
987*35238bceSAndroid Build Coastguard Worker 
988*35238bceSAndroid Build Coastguard Worker private:
989*35238bceSAndroid Build Coastguard Worker     GLenum m_targetName;
990*35238bceSAndroid Build Coastguard Worker     GLint m_minValue;
991*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
992*35238bceSAndroid Build Coastguard Worker };
993*35238bceSAndroid Build Coastguard Worker 
994*35238bceSAndroid Build Coastguard Worker class ConstantMaximumValueTestCase : public ApiCase
995*35238bceSAndroid Build Coastguard Worker {
996*35238bceSAndroid Build Coastguard Worker public:
ConstantMaximumValueTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum targetName,GLint minValue)997*35238bceSAndroid Build Coastguard Worker     ConstantMaximumValueTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
998*35238bceSAndroid Build Coastguard Worker                                  GLenum targetName, GLint minValue)
999*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1000*35238bceSAndroid Build Coastguard Worker         , m_targetName(targetName)
1001*35238bceSAndroid Build Coastguard Worker         , m_minValue(minValue)
1002*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1003*35238bceSAndroid Build Coastguard Worker     {
1004*35238bceSAndroid Build Coastguard Worker     }
1005*35238bceSAndroid Build Coastguard Worker 
test(void)1006*35238bceSAndroid Build Coastguard Worker     void test(void)
1007*35238bceSAndroid Build Coastguard Worker     {
1008*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyIntegerLessOrEqual(m_testCtx, m_targetName, m_minValue);
1009*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1010*35238bceSAndroid Build Coastguard Worker     }
1011*35238bceSAndroid Build Coastguard Worker 
1012*35238bceSAndroid Build Coastguard Worker private:
1013*35238bceSAndroid Build Coastguard Worker     GLenum m_targetName;
1014*35238bceSAndroid Build Coastguard Worker     GLint m_minValue;
1015*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1016*35238bceSAndroid Build Coastguard Worker };
1017*35238bceSAndroid Build Coastguard Worker 
1018*35238bceSAndroid Build Coastguard Worker class SampleBuffersTestCase : public ApiCase
1019*35238bceSAndroid Build Coastguard Worker {
1020*35238bceSAndroid Build Coastguard Worker public:
SampleBuffersTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1021*35238bceSAndroid Build Coastguard Worker     SampleBuffersTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
1022*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1023*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1024*35238bceSAndroid Build Coastguard Worker     {
1025*35238bceSAndroid Build Coastguard Worker     }
1026*35238bceSAndroid Build Coastguard Worker 
test(void)1027*35238bceSAndroid Build Coastguard Worker     void test(void)
1028*35238bceSAndroid Build Coastguard Worker     {
1029*35238bceSAndroid Build Coastguard Worker         const int expectedSampleBuffers = (m_context.getRenderTarget().getNumSamples() > 1) ? 1 : 0;
1030*35238bceSAndroid Build Coastguard Worker 
1031*35238bceSAndroid Build Coastguard Worker         m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples())
1032*35238bceSAndroid Build Coastguard Worker               << ", expecting GL_SAMPLE_BUFFERS to be " << expectedSampleBuffers << tcu::TestLog::EndMessage;
1033*35238bceSAndroid Build Coastguard Worker 
1034*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_SAMPLE_BUFFERS, expectedSampleBuffers);
1035*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1036*35238bceSAndroid Build Coastguard Worker     }
1037*35238bceSAndroid Build Coastguard Worker 
1038*35238bceSAndroid Build Coastguard Worker private:
1039*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1040*35238bceSAndroid Build Coastguard Worker };
1041*35238bceSAndroid Build Coastguard Worker 
1042*35238bceSAndroid Build Coastguard Worker class SamplesTestCase : public ApiCase
1043*35238bceSAndroid Build Coastguard Worker {
1044*35238bceSAndroid Build Coastguard Worker public:
SamplesTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1045*35238bceSAndroid Build Coastguard Worker     SamplesTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
1046*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1047*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1048*35238bceSAndroid Build Coastguard Worker     {
1049*35238bceSAndroid Build Coastguard Worker     }
1050*35238bceSAndroid Build Coastguard Worker 
test(void)1051*35238bceSAndroid Build Coastguard Worker     void test(void)
1052*35238bceSAndroid Build Coastguard Worker     {
1053*35238bceSAndroid Build Coastguard Worker         // MSAA?
1054*35238bceSAndroid Build Coastguard Worker         if (m_context.getRenderTarget().getNumSamples() > 1)
1055*35238bceSAndroid Build Coastguard Worker         {
1056*35238bceSAndroid Build Coastguard Worker             m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples())
1057*35238bceSAndroid Build Coastguard Worker                   << tcu::TestLog::EndMessage;
1058*35238bceSAndroid Build Coastguard Worker 
1059*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, GL_SAMPLES, m_context.getRenderTarget().getNumSamples());
1060*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1061*35238bceSAndroid Build Coastguard Worker         }
1062*35238bceSAndroid Build Coastguard Worker         else
1063*35238bceSAndroid Build Coastguard Worker         {
1064*35238bceSAndroid Build Coastguard Worker             const glw::GLint validSamples[] = {0, 1};
1065*35238bceSAndroid Build Coastguard Worker 
1066*35238bceSAndroid Build Coastguard Worker             m_log << tcu::TestLog::Message << "Expecting GL_SAMPLES to be 0 or 1" << tcu::TestLog::EndMessage;
1067*35238bceSAndroid Build Coastguard Worker 
1068*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyIntegerAnyOf(m_testCtx, GL_SAMPLES, validSamples, DE_LENGTH_OF_ARRAY(validSamples));
1069*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1070*35238bceSAndroid Build Coastguard Worker         }
1071*35238bceSAndroid Build Coastguard Worker     }
1072*35238bceSAndroid Build Coastguard Worker 
1073*35238bceSAndroid Build Coastguard Worker private:
1074*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1075*35238bceSAndroid Build Coastguard Worker };
1076*35238bceSAndroid Build Coastguard Worker 
1077*35238bceSAndroid Build Coastguard Worker class HintTestCase : public ApiCase
1078*35238bceSAndroid Build Coastguard Worker {
1079*35238bceSAndroid Build Coastguard Worker public:
HintTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum targetName)1080*35238bceSAndroid Build Coastguard Worker     HintTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1081*35238bceSAndroid Build Coastguard Worker                  GLenum targetName)
1082*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1083*35238bceSAndroid Build Coastguard Worker         , m_targetName(targetName)
1084*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1085*35238bceSAndroid Build Coastguard Worker     {
1086*35238bceSAndroid Build Coastguard Worker     }
1087*35238bceSAndroid Build Coastguard Worker 
test(void)1088*35238bceSAndroid Build Coastguard Worker     void test(void)
1089*35238bceSAndroid Build Coastguard Worker     {
1090*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE);
1091*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1092*35238bceSAndroid Build Coastguard Worker 
1093*35238bceSAndroid Build Coastguard Worker         glHint(m_targetName, GL_NICEST);
1094*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_targetName, GL_NICEST);
1095*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1096*35238bceSAndroid Build Coastguard Worker 
1097*35238bceSAndroid Build Coastguard Worker         glHint(m_targetName, GL_FASTEST);
1098*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_targetName, GL_FASTEST);
1099*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1100*35238bceSAndroid Build Coastguard Worker 
1101*35238bceSAndroid Build Coastguard Worker         glHint(m_targetName, GL_DONT_CARE);
1102*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE);
1103*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1104*35238bceSAndroid Build Coastguard Worker     }
1105*35238bceSAndroid Build Coastguard Worker 
1106*35238bceSAndroid Build Coastguard Worker private:
1107*35238bceSAndroid Build Coastguard Worker     GLenum m_targetName;
1108*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1109*35238bceSAndroid Build Coastguard Worker };
1110*35238bceSAndroid Build Coastguard Worker 
1111*35238bceSAndroid Build Coastguard Worker class DepthFuncTestCase : public ApiCase
1112*35238bceSAndroid Build Coastguard Worker {
1113*35238bceSAndroid Build Coastguard Worker public:
DepthFuncTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1114*35238bceSAndroid Build Coastguard Worker     DepthFuncTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
1115*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1116*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1117*35238bceSAndroid Build Coastguard Worker     {
1118*35238bceSAndroid Build Coastguard Worker     }
1119*35238bceSAndroid Build Coastguard Worker 
test(void)1120*35238bceSAndroid Build Coastguard Worker     void test(void)
1121*35238bceSAndroid Build Coastguard Worker     {
1122*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, GL_LESS);
1123*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1124*35238bceSAndroid Build Coastguard Worker 
1125*35238bceSAndroid Build Coastguard Worker         const GLenum depthFunctions[] = {GL_NEVER, GL_ALWAYS,  GL_LESS,   GL_LEQUAL,
1126*35238bceSAndroid Build Coastguard Worker                                          GL_EQUAL, GL_GREATER, GL_GEQUAL, GL_NOTEQUAL};
1127*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthFunctions); ndx++)
1128*35238bceSAndroid Build Coastguard Worker         {
1129*35238bceSAndroid Build Coastguard Worker             glDepthFunc(depthFunctions[ndx]);
1130*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1131*35238bceSAndroid Build Coastguard Worker 
1132*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, depthFunctions[ndx]);
1133*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1134*35238bceSAndroid Build Coastguard Worker         }
1135*35238bceSAndroid Build Coastguard Worker     }
1136*35238bceSAndroid Build Coastguard Worker 
1137*35238bceSAndroid Build Coastguard Worker private:
1138*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1139*35238bceSAndroid Build Coastguard Worker };
1140*35238bceSAndroid Build Coastguard Worker 
1141*35238bceSAndroid Build Coastguard Worker class CullFaceTestCase : public ApiCase
1142*35238bceSAndroid Build Coastguard Worker {
1143*35238bceSAndroid Build Coastguard Worker public:
CullFaceTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1144*35238bceSAndroid Build Coastguard Worker     CullFaceTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
1145*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1146*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1147*35238bceSAndroid Build Coastguard Worker     {
1148*35238bceSAndroid Build Coastguard Worker     }
1149*35238bceSAndroid Build Coastguard Worker 
test(void)1150*35238bceSAndroid Build Coastguard Worker     void test(void)
1151*35238bceSAndroid Build Coastguard Worker     {
1152*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, GL_BACK);
1153*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1154*35238bceSAndroid Build Coastguard Worker 
1155*35238bceSAndroid Build Coastguard Worker         const GLenum cullFaces[] = {GL_FRONT, GL_BACK, GL_FRONT_AND_BACK};
1156*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cullFaces); ndx++)
1157*35238bceSAndroid Build Coastguard Worker         {
1158*35238bceSAndroid Build Coastguard Worker             glCullFace(cullFaces[ndx]);
1159*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1160*35238bceSAndroid Build Coastguard Worker 
1161*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, cullFaces[ndx]);
1162*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1163*35238bceSAndroid Build Coastguard Worker         }
1164*35238bceSAndroid Build Coastguard Worker     }
1165*35238bceSAndroid Build Coastguard Worker 
1166*35238bceSAndroid Build Coastguard Worker private:
1167*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1168*35238bceSAndroid Build Coastguard Worker };
1169*35238bceSAndroid Build Coastguard Worker 
1170*35238bceSAndroid Build Coastguard Worker class FrontFaceTestCase : public ApiCase
1171*35238bceSAndroid Build Coastguard Worker {
1172*35238bceSAndroid Build Coastguard Worker public:
FrontFaceTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1173*35238bceSAndroid Build Coastguard Worker     FrontFaceTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
1174*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1175*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1176*35238bceSAndroid Build Coastguard Worker     {
1177*35238bceSAndroid Build Coastguard Worker     }
1178*35238bceSAndroid Build Coastguard Worker 
test(void)1179*35238bceSAndroid Build Coastguard Worker     void test(void)
1180*35238bceSAndroid Build Coastguard Worker     {
1181*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, GL_CCW);
1182*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1183*35238bceSAndroid Build Coastguard Worker 
1184*35238bceSAndroid Build Coastguard Worker         const GLenum frontFaces[] = {GL_CW, GL_CCW};
1185*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(frontFaces); ndx++)
1186*35238bceSAndroid Build Coastguard Worker         {
1187*35238bceSAndroid Build Coastguard Worker             glFrontFace(frontFaces[ndx]);
1188*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1189*35238bceSAndroid Build Coastguard Worker 
1190*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, frontFaces[ndx]);
1191*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1192*35238bceSAndroid Build Coastguard Worker         }
1193*35238bceSAndroid Build Coastguard Worker     }
1194*35238bceSAndroid Build Coastguard Worker 
1195*35238bceSAndroid Build Coastguard Worker private:
1196*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1197*35238bceSAndroid Build Coastguard Worker };
1198*35238bceSAndroid Build Coastguard Worker 
1199*35238bceSAndroid Build Coastguard Worker class ViewPortTestCase : public ApiCase
1200*35238bceSAndroid Build Coastguard Worker {
1201*35238bceSAndroid Build Coastguard Worker public:
ViewPortTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1202*35238bceSAndroid Build Coastguard Worker     ViewPortTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
1203*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1204*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1205*35238bceSAndroid Build Coastguard Worker     {
1206*35238bceSAndroid Build Coastguard Worker     }
1207*35238bceSAndroid Build Coastguard Worker 
test(void)1208*35238bceSAndroid Build Coastguard Worker     void test(void)
1209*35238bceSAndroid Build Coastguard Worker     {
1210*35238bceSAndroid Build Coastguard Worker         de::Random rnd(0xabcdef);
1211*35238bceSAndroid Build Coastguard Worker 
1212*35238bceSAndroid Build Coastguard Worker         GLint maxViewportDimensions[2] = {0};
1213*35238bceSAndroid Build Coastguard Worker         GLfloat viewportBoundsRange[2] = {0.0f};
1214*35238bceSAndroid Build Coastguard Worker         GLboolean hasViewportArray     = false;
1215*35238bceSAndroid Build Coastguard Worker         glGetIntegerv(GL_MAX_VIEWPORT_DIMS, maxViewportDimensions);
1216*35238bceSAndroid Build Coastguard Worker         hasViewportArray = m_context.getContextInfo().isExtensionSupported("GL_OES_viewport_array") ||
1217*35238bceSAndroid Build Coastguard Worker                            m_context.getContextInfo().isExtensionSupported("GL_NV_viewport_array") ||
1218*35238bceSAndroid Build Coastguard Worker                            m_context.getContextInfo().isExtensionSupported("GL_ARB_viewport_array");
1219*35238bceSAndroid Build Coastguard Worker         if (hasViewportArray)
1220*35238bceSAndroid Build Coastguard Worker         {
1221*35238bceSAndroid Build Coastguard Worker             glGetFloatv(GL_VIEWPORT_BOUNDS_RANGE, viewportBoundsRange);
1222*35238bceSAndroid Build Coastguard Worker         }
1223*35238bceSAndroid Build Coastguard Worker 
1224*35238bceSAndroid Build Coastguard Worker         // verify initial value of first two values
1225*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, 0, 0, m_context.getRenderTarget().getWidth(),
1226*35238bceSAndroid Build Coastguard Worker                                    m_context.getRenderTarget().getHeight());
1227*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1228*35238bceSAndroid Build Coastguard Worker 
1229*35238bceSAndroid Build Coastguard Worker         const int numIterations = 120;
1230*35238bceSAndroid Build Coastguard Worker         for (int i = 0; i < numIterations; ++i)
1231*35238bceSAndroid Build Coastguard Worker         {
1232*35238bceSAndroid Build Coastguard Worker             GLint x        = rnd.getInt(-64000, 64000);
1233*35238bceSAndroid Build Coastguard Worker             GLint y        = rnd.getInt(-64000, 64000);
1234*35238bceSAndroid Build Coastguard Worker             GLsizei width  = rnd.getInt(0, maxViewportDimensions[0]);
1235*35238bceSAndroid Build Coastguard Worker             GLsizei height = rnd.getInt(0, maxViewportDimensions[1]);
1236*35238bceSAndroid Build Coastguard Worker 
1237*35238bceSAndroid Build Coastguard Worker             glViewport(x, y, width, height);
1238*35238bceSAndroid Build Coastguard Worker 
1239*35238bceSAndroid Build Coastguard Worker             if (hasViewportArray)
1240*35238bceSAndroid Build Coastguard Worker             {
1241*35238bceSAndroid Build Coastguard Worker                 m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT,
1242*35238bceSAndroid Build Coastguard Worker                                            de::clamp(x, deFloorFloatToInt32(viewportBoundsRange[0]),
1243*35238bceSAndroid Build Coastguard Worker                                                      deFloorFloatToInt32(viewportBoundsRange[1])),
1244*35238bceSAndroid Build Coastguard Worker                                            de::clamp(y, deFloorFloatToInt32(viewportBoundsRange[0]),
1245*35238bceSAndroid Build Coastguard Worker                                                      deFloorFloatToInt32(viewportBoundsRange[1])),
1246*35238bceSAndroid Build Coastguard Worker                                            width, height);
1247*35238bceSAndroid Build Coastguard Worker             }
1248*35238bceSAndroid Build Coastguard Worker             else
1249*35238bceSAndroid Build Coastguard Worker             {
1250*35238bceSAndroid Build Coastguard Worker                 m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, x, y, width, height);
1251*35238bceSAndroid Build Coastguard Worker             }
1252*35238bceSAndroid Build Coastguard Worker 
1253*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1254*35238bceSAndroid Build Coastguard Worker         }
1255*35238bceSAndroid Build Coastguard Worker     }
1256*35238bceSAndroid Build Coastguard Worker 
1257*35238bceSAndroid Build Coastguard Worker private:
1258*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1259*35238bceSAndroid Build Coastguard Worker };
1260*35238bceSAndroid Build Coastguard Worker 
1261*35238bceSAndroid Build Coastguard Worker class ScissorBoxTestCase : public ApiCase
1262*35238bceSAndroid Build Coastguard Worker {
1263*35238bceSAndroid Build Coastguard Worker public:
ScissorBoxTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1264*35238bceSAndroid Build Coastguard Worker     ScissorBoxTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
1265*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1266*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1267*35238bceSAndroid Build Coastguard Worker     {
1268*35238bceSAndroid Build Coastguard Worker     }
1269*35238bceSAndroid Build Coastguard Worker 
test(void)1270*35238bceSAndroid Build Coastguard Worker     void test(void)
1271*35238bceSAndroid Build Coastguard Worker     {
1272*35238bceSAndroid Build Coastguard Worker         de::Random rnd(0xabcdef);
1273*35238bceSAndroid Build Coastguard Worker 
1274*35238bceSAndroid Build Coastguard Worker         // verify initial value of first two values
1275*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger4Mask(m_testCtx, GL_SCISSOR_BOX, 0, true, 0, true, 0, false, 0, false);
1276*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1277*35238bceSAndroid Build Coastguard Worker 
1278*35238bceSAndroid Build Coastguard Worker         const int numIterations = 120;
1279*35238bceSAndroid Build Coastguard Worker         for (int i = 0; i < numIterations; ++i)
1280*35238bceSAndroid Build Coastguard Worker         {
1281*35238bceSAndroid Build Coastguard Worker             GLint left     = rnd.getInt(-64000, 64000);
1282*35238bceSAndroid Build Coastguard Worker             GLint bottom   = rnd.getInt(-64000, 64000);
1283*35238bceSAndroid Build Coastguard Worker             GLsizei width  = rnd.getInt(0, 64000);
1284*35238bceSAndroid Build Coastguard Worker             GLsizei height = rnd.getInt(0, 64000);
1285*35238bceSAndroid Build Coastguard Worker 
1286*35238bceSAndroid Build Coastguard Worker             glScissor(left, bottom, width, height);
1287*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger4(m_testCtx, GL_SCISSOR_BOX, left, bottom, width, height);
1288*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1289*35238bceSAndroid Build Coastguard Worker         }
1290*35238bceSAndroid Build Coastguard Worker     }
1291*35238bceSAndroid Build Coastguard Worker 
1292*35238bceSAndroid Build Coastguard Worker private:
1293*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1294*35238bceSAndroid Build Coastguard Worker };
1295*35238bceSAndroid Build Coastguard Worker 
1296*35238bceSAndroid Build Coastguard Worker class MaxViewportDimsTestCase : public ApiCase
1297*35238bceSAndroid Build Coastguard Worker {
1298*35238bceSAndroid Build Coastguard Worker public:
MaxViewportDimsTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1299*35238bceSAndroid Build Coastguard Worker     MaxViewportDimsTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
1300*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1301*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1302*35238bceSAndroid Build Coastguard Worker     {
1303*35238bceSAndroid Build Coastguard Worker     }
1304*35238bceSAndroid Build Coastguard Worker 
test(void)1305*35238bceSAndroid Build Coastguard Worker     void test(void)
1306*35238bceSAndroid Build Coastguard Worker     {
1307*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyIntegerGreaterOrEqual2(m_testCtx, GL_MAX_VIEWPORT_DIMS,
1308*35238bceSAndroid Build Coastguard Worker                                                  m_context.getRenderTarget().getWidth(),
1309*35238bceSAndroid Build Coastguard Worker                                                  m_context.getRenderTarget().getHeight());
1310*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1311*35238bceSAndroid Build Coastguard Worker     }
1312*35238bceSAndroid Build Coastguard Worker 
1313*35238bceSAndroid Build Coastguard Worker private:
1314*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1315*35238bceSAndroid Build Coastguard Worker };
1316*35238bceSAndroid Build Coastguard Worker 
1317*35238bceSAndroid Build Coastguard Worker class StencilRefTestCase : public ApiCase
1318*35238bceSAndroid Build Coastguard Worker {
1319*35238bceSAndroid Build Coastguard Worker public:
StencilRefTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName)1320*35238bceSAndroid Build Coastguard Worker     StencilRefTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1321*35238bceSAndroid Build Coastguard Worker                        GLenum testTargetName)
1322*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1323*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1324*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1325*35238bceSAndroid Build Coastguard Worker     {
1326*35238bceSAndroid Build Coastguard Worker     }
1327*35238bceSAndroid Build Coastguard Worker 
test(void)1328*35238bceSAndroid Build Coastguard Worker     void test(void)
1329*35238bceSAndroid Build Coastguard Worker     {
1330*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0);
1331*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1332*35238bceSAndroid Build Coastguard Worker 
1333*35238bceSAndroid Build Coastguard Worker         const int stencilBits = m_context.getRenderTarget().getStencilBits();
1334*35238bceSAndroid Build Coastguard Worker 
1335*35238bceSAndroid Build Coastguard Worker         for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1336*35238bceSAndroid Build Coastguard Worker         {
1337*35238bceSAndroid Build Coastguard Worker             const int ref = 1 << stencilBit;
1338*35238bceSAndroid Build Coastguard Worker 
1339*35238bceSAndroid Build Coastguard Worker             glStencilFunc(GL_ALWAYS, ref, 0); // mask should not affect the REF
1340*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1341*35238bceSAndroid Build Coastguard Worker 
1342*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1343*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1344*35238bceSAndroid Build Coastguard Worker 
1345*35238bceSAndroid Build Coastguard Worker             glStencilFunc(GL_ALWAYS, ref, ref);
1346*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1347*35238bceSAndroid Build Coastguard Worker 
1348*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1349*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1350*35238bceSAndroid Build Coastguard Worker         }
1351*35238bceSAndroid Build Coastguard Worker     }
1352*35238bceSAndroid Build Coastguard Worker 
1353*35238bceSAndroid Build Coastguard Worker private:
1354*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1355*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1356*35238bceSAndroid Build Coastguard Worker };
1357*35238bceSAndroid Build Coastguard Worker 
1358*35238bceSAndroid Build Coastguard Worker class StencilRefSeparateTestCase : public ApiCase
1359*35238bceSAndroid Build Coastguard Worker {
1360*35238bceSAndroid Build Coastguard Worker public:
StencilRefSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,GLenum stencilFuncTargetFace)1361*35238bceSAndroid Build Coastguard Worker     StencilRefSeparateTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1362*35238bceSAndroid Build Coastguard Worker                                GLenum testTargetName, GLenum stencilFuncTargetFace)
1363*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1364*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1365*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1366*35238bceSAndroid Build Coastguard Worker         , m_stencilFuncTargetFace(stencilFuncTargetFace)
1367*35238bceSAndroid Build Coastguard Worker     {
1368*35238bceSAndroid Build Coastguard Worker     }
1369*35238bceSAndroid Build Coastguard Worker 
test(void)1370*35238bceSAndroid Build Coastguard Worker     void test(void)
1371*35238bceSAndroid Build Coastguard Worker     {
1372*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0);
1373*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1374*35238bceSAndroid Build Coastguard Worker 
1375*35238bceSAndroid Build Coastguard Worker         const int stencilBits = m_context.getRenderTarget().getStencilBits();
1376*35238bceSAndroid Build Coastguard Worker 
1377*35238bceSAndroid Build Coastguard Worker         for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1378*35238bceSAndroid Build Coastguard Worker         {
1379*35238bceSAndroid Build Coastguard Worker             const int ref = 1 << stencilBit;
1380*35238bceSAndroid Build Coastguard Worker 
1381*35238bceSAndroid Build Coastguard Worker             glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, 0);
1382*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1383*35238bceSAndroid Build Coastguard Worker 
1384*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1385*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1386*35238bceSAndroid Build Coastguard Worker 
1387*35238bceSAndroid Build Coastguard Worker             glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, ref);
1388*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1389*35238bceSAndroid Build Coastguard Worker 
1390*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1391*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1392*35238bceSAndroid Build Coastguard Worker         }
1393*35238bceSAndroid Build Coastguard Worker     }
1394*35238bceSAndroid Build Coastguard Worker 
1395*35238bceSAndroid Build Coastguard Worker private:
1396*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1397*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1398*35238bceSAndroid Build Coastguard Worker     GLenum m_stencilFuncTargetFace;
1399*35238bceSAndroid Build Coastguard Worker };
1400*35238bceSAndroid Build Coastguard Worker 
1401*35238bceSAndroid Build Coastguard Worker class StencilOpTestCase : public ApiCase
1402*35238bceSAndroid Build Coastguard Worker {
1403*35238bceSAndroid Build Coastguard Worker public:
StencilOpTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum stencilOpName)1404*35238bceSAndroid Build Coastguard Worker     StencilOpTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1405*35238bceSAndroid Build Coastguard Worker                       GLenum stencilOpName)
1406*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1407*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1408*35238bceSAndroid Build Coastguard Worker         , m_stencilOpName(stencilOpName)
1409*35238bceSAndroid Build Coastguard Worker     {
1410*35238bceSAndroid Build Coastguard Worker     }
1411*35238bceSAndroid Build Coastguard Worker 
test(void)1412*35238bceSAndroid Build Coastguard Worker     void test(void)
1413*35238bceSAndroid Build Coastguard Worker     {
1414*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_stencilOpName, GL_KEEP);
1415*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1416*35238bceSAndroid Build Coastguard Worker 
1417*35238bceSAndroid Build Coastguard Worker         const GLenum stencilOpValues[] = {GL_KEEP, GL_ZERO,   GL_REPLACE,   GL_INCR,
1418*35238bceSAndroid Build Coastguard Worker                                           GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP};
1419*35238bceSAndroid Build Coastguard Worker 
1420*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilOpValues); ++ndx)
1421*35238bceSAndroid Build Coastguard Worker         {
1422*35238bceSAndroid Build Coastguard Worker             SetStencilOp(stencilOpValues[ndx]);
1423*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1424*35238bceSAndroid Build Coastguard Worker 
1425*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_stencilOpName, stencilOpValues[ndx]);
1426*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1427*35238bceSAndroid Build Coastguard Worker         }
1428*35238bceSAndroid Build Coastguard Worker     }
1429*35238bceSAndroid Build Coastguard Worker 
1430*35238bceSAndroid Build Coastguard Worker protected:
SetStencilOp(GLenum stencilOpValue)1431*35238bceSAndroid Build Coastguard Worker     virtual void SetStencilOp(GLenum stencilOpValue)
1432*35238bceSAndroid Build Coastguard Worker     {
1433*35238bceSAndroid Build Coastguard Worker         switch (m_stencilOpName)
1434*35238bceSAndroid Build Coastguard Worker         {
1435*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_FAIL:
1436*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_BACK_FAIL:
1437*35238bceSAndroid Build Coastguard Worker             glStencilOp(stencilOpValue, GL_KEEP, GL_KEEP);
1438*35238bceSAndroid Build Coastguard Worker             break;
1439*35238bceSAndroid Build Coastguard Worker 
1440*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_PASS_DEPTH_FAIL:
1441*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1442*35238bceSAndroid Build Coastguard Worker             glStencilOp(GL_KEEP, stencilOpValue, GL_KEEP);
1443*35238bceSAndroid Build Coastguard Worker             break;
1444*35238bceSAndroid Build Coastguard Worker 
1445*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_PASS_DEPTH_PASS:
1446*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1447*35238bceSAndroid Build Coastguard Worker             glStencilOp(GL_KEEP, GL_KEEP, stencilOpValue);
1448*35238bceSAndroid Build Coastguard Worker             break;
1449*35238bceSAndroid Build Coastguard Worker 
1450*35238bceSAndroid Build Coastguard Worker         default:
1451*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false && "should not happen");
1452*35238bceSAndroid Build Coastguard Worker             break;
1453*35238bceSAndroid Build Coastguard Worker         }
1454*35238bceSAndroid Build Coastguard Worker     }
1455*35238bceSAndroid Build Coastguard Worker 
1456*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1457*35238bceSAndroid Build Coastguard Worker     GLenum m_stencilOpName;
1458*35238bceSAndroid Build Coastguard Worker };
1459*35238bceSAndroid Build Coastguard Worker 
1460*35238bceSAndroid Build Coastguard Worker class StencilOpSeparateTestCase : public StencilOpTestCase
1461*35238bceSAndroid Build Coastguard Worker {
1462*35238bceSAndroid Build Coastguard Worker public:
StencilOpSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum stencilOpName,GLenum stencilOpFace)1463*35238bceSAndroid Build Coastguard Worker     StencilOpSeparateTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1464*35238bceSAndroid Build Coastguard Worker                               GLenum stencilOpName, GLenum stencilOpFace)
1465*35238bceSAndroid Build Coastguard Worker         : StencilOpTestCase(context, verifier, name, description, stencilOpName)
1466*35238bceSAndroid Build Coastguard Worker         , m_stencilOpFace(stencilOpFace)
1467*35238bceSAndroid Build Coastguard Worker     {
1468*35238bceSAndroid Build Coastguard Worker     }
1469*35238bceSAndroid Build Coastguard Worker 
1470*35238bceSAndroid Build Coastguard Worker private:
SetStencilOp(GLenum stencilOpValue)1471*35238bceSAndroid Build Coastguard Worker     void SetStencilOp(GLenum stencilOpValue)
1472*35238bceSAndroid Build Coastguard Worker     {
1473*35238bceSAndroid Build Coastguard Worker         switch (m_stencilOpName)
1474*35238bceSAndroid Build Coastguard Worker         {
1475*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_FAIL:
1476*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_BACK_FAIL:
1477*35238bceSAndroid Build Coastguard Worker             glStencilOpSeparate(m_stencilOpFace, stencilOpValue, GL_KEEP, GL_KEEP);
1478*35238bceSAndroid Build Coastguard Worker             break;
1479*35238bceSAndroid Build Coastguard Worker 
1480*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_PASS_DEPTH_FAIL:
1481*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1482*35238bceSAndroid Build Coastguard Worker             glStencilOpSeparate(m_stencilOpFace, GL_KEEP, stencilOpValue, GL_KEEP);
1483*35238bceSAndroid Build Coastguard Worker             break;
1484*35238bceSAndroid Build Coastguard Worker 
1485*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_PASS_DEPTH_PASS:
1486*35238bceSAndroid Build Coastguard Worker         case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1487*35238bceSAndroid Build Coastguard Worker             glStencilOpSeparate(m_stencilOpFace, GL_KEEP, GL_KEEP, stencilOpValue);
1488*35238bceSAndroid Build Coastguard Worker             break;
1489*35238bceSAndroid Build Coastguard Worker 
1490*35238bceSAndroid Build Coastguard Worker         default:
1491*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false && "should not happen");
1492*35238bceSAndroid Build Coastguard Worker             break;
1493*35238bceSAndroid Build Coastguard Worker         }
1494*35238bceSAndroid Build Coastguard Worker     }
1495*35238bceSAndroid Build Coastguard Worker 
1496*35238bceSAndroid Build Coastguard Worker     GLenum m_stencilOpFace;
1497*35238bceSAndroid Build Coastguard Worker };
1498*35238bceSAndroid Build Coastguard Worker 
1499*35238bceSAndroid Build Coastguard Worker class StencilFuncTestCase : public ApiCase
1500*35238bceSAndroid Build Coastguard Worker {
1501*35238bceSAndroid Build Coastguard Worker public:
StencilFuncTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)1502*35238bceSAndroid Build Coastguard Worker     StencilFuncTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
1503*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1504*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1505*35238bceSAndroid Build Coastguard Worker     {
1506*35238bceSAndroid Build Coastguard Worker     }
1507*35238bceSAndroid Build Coastguard Worker 
test(void)1508*35238bceSAndroid Build Coastguard Worker     void test(void)
1509*35238bceSAndroid Build Coastguard Worker     {
1510*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, GL_ALWAYS);
1511*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1512*35238bceSAndroid Build Coastguard Worker 
1513*35238bceSAndroid Build Coastguard Worker         const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS,    GL_LEQUAL,
1514*35238bceSAndroid Build Coastguard Worker                                             GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL};
1515*35238bceSAndroid Build Coastguard Worker 
1516*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx)
1517*35238bceSAndroid Build Coastguard Worker         {
1518*35238bceSAndroid Build Coastguard Worker             glStencilFunc(stencilfuncValues[ndx], 0, 0);
1519*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1520*35238bceSAndroid Build Coastguard Worker 
1521*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, stencilfuncValues[ndx]);
1522*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1523*35238bceSAndroid Build Coastguard Worker 
1524*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, GL_STENCIL_BACK_FUNC, stencilfuncValues[ndx]);
1525*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1526*35238bceSAndroid Build Coastguard Worker         }
1527*35238bceSAndroid Build Coastguard Worker     }
1528*35238bceSAndroid Build Coastguard Worker 
1529*35238bceSAndroid Build Coastguard Worker private:
1530*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1531*35238bceSAndroid Build Coastguard Worker };
1532*35238bceSAndroid Build Coastguard Worker 
1533*35238bceSAndroid Build Coastguard Worker class StencilFuncSeparateTestCase : public ApiCase
1534*35238bceSAndroid Build Coastguard Worker {
1535*35238bceSAndroid Build Coastguard Worker public:
StencilFuncSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum stencilFuncName,GLenum stencilFuncFace)1536*35238bceSAndroid Build Coastguard Worker     StencilFuncSeparateTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1537*35238bceSAndroid Build Coastguard Worker                                 GLenum stencilFuncName, GLenum stencilFuncFace)
1538*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1539*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1540*35238bceSAndroid Build Coastguard Worker         , m_stencilFuncName(stencilFuncName)
1541*35238bceSAndroid Build Coastguard Worker         , m_stencilFuncFace(stencilFuncFace)
1542*35238bceSAndroid Build Coastguard Worker     {
1543*35238bceSAndroid Build Coastguard Worker     }
1544*35238bceSAndroid Build Coastguard Worker 
test(void)1545*35238bceSAndroid Build Coastguard Worker     void test(void)
1546*35238bceSAndroid Build Coastguard Worker     {
1547*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, GL_ALWAYS);
1548*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1549*35238bceSAndroid Build Coastguard Worker 
1550*35238bceSAndroid Build Coastguard Worker         const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS,    GL_LEQUAL,
1551*35238bceSAndroid Build Coastguard Worker                                             GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL};
1552*35238bceSAndroid Build Coastguard Worker 
1553*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx)
1554*35238bceSAndroid Build Coastguard Worker         {
1555*35238bceSAndroid Build Coastguard Worker             glStencilFuncSeparate(m_stencilFuncFace, stencilfuncValues[ndx], 0, 0);
1556*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1557*35238bceSAndroid Build Coastguard Worker 
1558*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, stencilfuncValues[ndx]);
1559*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1560*35238bceSAndroid Build Coastguard Worker         }
1561*35238bceSAndroid Build Coastguard Worker     }
1562*35238bceSAndroid Build Coastguard Worker 
1563*35238bceSAndroid Build Coastguard Worker private:
1564*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1565*35238bceSAndroid Build Coastguard Worker     GLenum m_stencilFuncName;
1566*35238bceSAndroid Build Coastguard Worker     GLenum m_stencilFuncFace;
1567*35238bceSAndroid Build Coastguard Worker };
1568*35238bceSAndroid Build Coastguard Worker 
1569*35238bceSAndroid Build Coastguard Worker class StencilMaskTestCase : public ApiCase
1570*35238bceSAndroid Build Coastguard Worker {
1571*35238bceSAndroid Build Coastguard Worker public:
StencilMaskTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName)1572*35238bceSAndroid Build Coastguard Worker     StencilMaskTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1573*35238bceSAndroid Build Coastguard Worker                         GLenum testTargetName)
1574*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1575*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1576*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1577*35238bceSAndroid Build Coastguard Worker     {
1578*35238bceSAndroid Build Coastguard Worker     }
1579*35238bceSAndroid Build Coastguard Worker 
test(void)1580*35238bceSAndroid Build Coastguard Worker     void test(void)
1581*35238bceSAndroid Build Coastguard Worker     {
1582*35238bceSAndroid Build Coastguard Worker         const int stencilBits = m_context.getRenderTarget().getStencilBits();
1583*35238bceSAndroid Build Coastguard Worker 
1584*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits);
1585*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1586*35238bceSAndroid Build Coastguard Worker 
1587*35238bceSAndroid Build Coastguard Worker         for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1588*35238bceSAndroid Build Coastguard Worker         {
1589*35238bceSAndroid Build Coastguard Worker             const int mask = 1 << stencilBit;
1590*35238bceSAndroid Build Coastguard Worker 
1591*35238bceSAndroid Build Coastguard Worker             glStencilFunc(GL_ALWAYS, 0, mask);
1592*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1593*35238bceSAndroid Build Coastguard Worker 
1594*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1595*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1596*35238bceSAndroid Build Coastguard Worker         }
1597*35238bceSAndroid Build Coastguard Worker     }
1598*35238bceSAndroid Build Coastguard Worker 
1599*35238bceSAndroid Build Coastguard Worker private:
1600*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1601*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1602*35238bceSAndroid Build Coastguard Worker };
1603*35238bceSAndroid Build Coastguard Worker 
1604*35238bceSAndroid Build Coastguard Worker class StencilMaskSeparateTestCase : public ApiCase
1605*35238bceSAndroid Build Coastguard Worker {
1606*35238bceSAndroid Build Coastguard Worker public:
StencilMaskSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,GLenum stencilFuncTargetFace)1607*35238bceSAndroid Build Coastguard Worker     StencilMaskSeparateTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1608*35238bceSAndroid Build Coastguard Worker                                 GLenum testTargetName, GLenum stencilFuncTargetFace)
1609*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1610*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1611*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1612*35238bceSAndroid Build Coastguard Worker         , m_stencilFuncTargetFace(stencilFuncTargetFace)
1613*35238bceSAndroid Build Coastguard Worker     {
1614*35238bceSAndroid Build Coastguard Worker     }
1615*35238bceSAndroid Build Coastguard Worker 
test(void)1616*35238bceSAndroid Build Coastguard Worker     void test(void)
1617*35238bceSAndroid Build Coastguard Worker     {
1618*35238bceSAndroid Build Coastguard Worker         const int stencilBits = m_context.getRenderTarget().getStencilBits();
1619*35238bceSAndroid Build Coastguard Worker 
1620*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits);
1621*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1622*35238bceSAndroid Build Coastguard Worker 
1623*35238bceSAndroid Build Coastguard Worker         for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1624*35238bceSAndroid Build Coastguard Worker         {
1625*35238bceSAndroid Build Coastguard Worker             const int mask = 1 << stencilBit;
1626*35238bceSAndroid Build Coastguard Worker 
1627*35238bceSAndroid Build Coastguard Worker             glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, 0, mask);
1628*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1629*35238bceSAndroid Build Coastguard Worker 
1630*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1631*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1632*35238bceSAndroid Build Coastguard Worker         }
1633*35238bceSAndroid Build Coastguard Worker     }
1634*35238bceSAndroid Build Coastguard Worker 
1635*35238bceSAndroid Build Coastguard Worker private:
1636*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1637*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1638*35238bceSAndroid Build Coastguard Worker     GLenum m_stencilFuncTargetFace;
1639*35238bceSAndroid Build Coastguard Worker };
1640*35238bceSAndroid Build Coastguard Worker 
1641*35238bceSAndroid Build Coastguard Worker class StencilWriteMaskTestCase : public ApiCase
1642*35238bceSAndroid Build Coastguard Worker {
1643*35238bceSAndroid Build Coastguard Worker public:
StencilWriteMaskTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName)1644*35238bceSAndroid Build Coastguard Worker     StencilWriteMaskTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1645*35238bceSAndroid Build Coastguard Worker                              GLenum testTargetName)
1646*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1647*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1648*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1649*35238bceSAndroid Build Coastguard Worker     {
1650*35238bceSAndroid Build Coastguard Worker     }
1651*35238bceSAndroid Build Coastguard Worker 
test(void)1652*35238bceSAndroid Build Coastguard Worker     void test(void)
1653*35238bceSAndroid Build Coastguard Worker     {
1654*35238bceSAndroid Build Coastguard Worker         const int stencilBits = m_context.getRenderTarget().getStencilBits();
1655*35238bceSAndroid Build Coastguard Worker 
1656*35238bceSAndroid Build Coastguard Worker         for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1657*35238bceSAndroid Build Coastguard Worker         {
1658*35238bceSAndroid Build Coastguard Worker             const int mask = 1 << stencilBit;
1659*35238bceSAndroid Build Coastguard Worker 
1660*35238bceSAndroid Build Coastguard Worker             glStencilMask(mask);
1661*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1662*35238bceSAndroid Build Coastguard Worker 
1663*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1664*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1665*35238bceSAndroid Build Coastguard Worker         }
1666*35238bceSAndroid Build Coastguard Worker     }
1667*35238bceSAndroid Build Coastguard Worker 
1668*35238bceSAndroid Build Coastguard Worker private:
1669*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1670*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1671*35238bceSAndroid Build Coastguard Worker };
1672*35238bceSAndroid Build Coastguard Worker 
1673*35238bceSAndroid Build Coastguard Worker class StencilWriteMaskSeparateTestCase : public ApiCase
1674*35238bceSAndroid Build Coastguard Worker {
1675*35238bceSAndroid Build Coastguard Worker public:
StencilWriteMaskSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,GLenum stencilTargetFace)1676*35238bceSAndroid Build Coastguard Worker     StencilWriteMaskSeparateTestCase(Context &context, StateVerifier *verifier, const char *name,
1677*35238bceSAndroid Build Coastguard Worker                                      const char *description, GLenum testTargetName, GLenum stencilTargetFace)
1678*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1679*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1680*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1681*35238bceSAndroid Build Coastguard Worker         , m_stencilTargetFace(stencilTargetFace)
1682*35238bceSAndroid Build Coastguard Worker     {
1683*35238bceSAndroid Build Coastguard Worker     }
1684*35238bceSAndroid Build Coastguard Worker 
test(void)1685*35238bceSAndroid Build Coastguard Worker     void test(void)
1686*35238bceSAndroid Build Coastguard Worker     {
1687*35238bceSAndroid Build Coastguard Worker         const int stencilBits = m_context.getRenderTarget().getStencilBits();
1688*35238bceSAndroid Build Coastguard Worker 
1689*35238bceSAndroid Build Coastguard Worker         for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1690*35238bceSAndroid Build Coastguard Worker         {
1691*35238bceSAndroid Build Coastguard Worker             const int mask = 1 << stencilBit;
1692*35238bceSAndroid Build Coastguard Worker 
1693*35238bceSAndroid Build Coastguard Worker             glStencilMaskSeparate(m_stencilTargetFace, mask);
1694*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1695*35238bceSAndroid Build Coastguard Worker 
1696*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1697*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1698*35238bceSAndroid Build Coastguard Worker         }
1699*35238bceSAndroid Build Coastguard Worker     }
1700*35238bceSAndroid Build Coastguard Worker 
1701*35238bceSAndroid Build Coastguard Worker private:
1702*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1703*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1704*35238bceSAndroid Build Coastguard Worker     GLenum m_stencilTargetFace;
1705*35238bceSAndroid Build Coastguard Worker };
1706*35238bceSAndroid Build Coastguard Worker 
1707*35238bceSAndroid Build Coastguard Worker class PixelStoreTestCase : public ApiCase
1708*35238bceSAndroid Build Coastguard Worker {
1709*35238bceSAndroid Build Coastguard Worker public:
PixelStoreTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1710*35238bceSAndroid Build Coastguard Worker     PixelStoreTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1711*35238bceSAndroid Build Coastguard Worker                        GLenum testTargetName, int initialValue)
1712*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1713*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1714*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1715*35238bceSAndroid Build Coastguard Worker         , m_initialValue(initialValue)
1716*35238bceSAndroid Build Coastguard Worker     {
1717*35238bceSAndroid Build Coastguard Worker     }
1718*35238bceSAndroid Build Coastguard Worker 
test(void)1719*35238bceSAndroid Build Coastguard Worker     void test(void)
1720*35238bceSAndroid Build Coastguard Worker     {
1721*35238bceSAndroid Build Coastguard Worker         de::Random rnd(0xabcdef);
1722*35238bceSAndroid Build Coastguard Worker 
1723*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
1724*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1725*35238bceSAndroid Build Coastguard Worker 
1726*35238bceSAndroid Build Coastguard Worker         const int numIterations = 120;
1727*35238bceSAndroid Build Coastguard Worker         for (int i = 0; i < numIterations; ++i)
1728*35238bceSAndroid Build Coastguard Worker         {
1729*35238bceSAndroid Build Coastguard Worker             const int referenceValue = rnd.getInt(0, 64000);
1730*35238bceSAndroid Build Coastguard Worker 
1731*35238bceSAndroid Build Coastguard Worker             glPixelStorei(m_testTargetName, referenceValue);
1732*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1733*35238bceSAndroid Build Coastguard Worker 
1734*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1735*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1736*35238bceSAndroid Build Coastguard Worker         }
1737*35238bceSAndroid Build Coastguard Worker     }
1738*35238bceSAndroid Build Coastguard Worker 
1739*35238bceSAndroid Build Coastguard Worker private:
1740*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1741*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1742*35238bceSAndroid Build Coastguard Worker     int m_initialValue;
1743*35238bceSAndroid Build Coastguard Worker };
1744*35238bceSAndroid Build Coastguard Worker 
1745*35238bceSAndroid Build Coastguard Worker class PixelStoreAlignTestCase : public ApiCase
1746*35238bceSAndroid Build Coastguard Worker {
1747*35238bceSAndroid Build Coastguard Worker public:
PixelStoreAlignTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName)1748*35238bceSAndroid Build Coastguard Worker     PixelStoreAlignTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1749*35238bceSAndroid Build Coastguard Worker                             GLenum testTargetName)
1750*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1751*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1752*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1753*35238bceSAndroid Build Coastguard Worker     {
1754*35238bceSAndroid Build Coastguard Worker     }
1755*35238bceSAndroid Build Coastguard Worker 
test(void)1756*35238bceSAndroid Build Coastguard Worker     void test(void)
1757*35238bceSAndroid Build Coastguard Worker     {
1758*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_testTargetName, 4);
1759*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1760*35238bceSAndroid Build Coastguard Worker 
1761*35238bceSAndroid Build Coastguard Worker         const int alignments[] = {1, 2, 4, 8};
1762*35238bceSAndroid Build Coastguard Worker 
1763*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(alignments); ++ndx)
1764*35238bceSAndroid Build Coastguard Worker         {
1765*35238bceSAndroid Build Coastguard Worker             const int referenceValue = alignments[ndx];
1766*35238bceSAndroid Build Coastguard Worker 
1767*35238bceSAndroid Build Coastguard Worker             glPixelStorei(m_testTargetName, referenceValue);
1768*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1769*35238bceSAndroid Build Coastguard Worker 
1770*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1771*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1772*35238bceSAndroid Build Coastguard Worker         }
1773*35238bceSAndroid Build Coastguard Worker     }
1774*35238bceSAndroid Build Coastguard Worker 
1775*35238bceSAndroid Build Coastguard Worker private:
1776*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1777*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1778*35238bceSAndroid Build Coastguard Worker };
1779*35238bceSAndroid Build Coastguard Worker 
1780*35238bceSAndroid Build Coastguard Worker class BlendFuncTestCase : public ApiCase
1781*35238bceSAndroid Build Coastguard Worker {
1782*35238bceSAndroid Build Coastguard Worker public:
BlendFuncTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1783*35238bceSAndroid Build Coastguard Worker     BlendFuncTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1784*35238bceSAndroid Build Coastguard Worker                       GLenum testTargetName, int initialValue)
1785*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1786*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1787*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1788*35238bceSAndroid Build Coastguard Worker         , m_initialValue(initialValue)
1789*35238bceSAndroid Build Coastguard Worker     {
1790*35238bceSAndroid Build Coastguard Worker     }
1791*35238bceSAndroid Build Coastguard Worker 
test(void)1792*35238bceSAndroid Build Coastguard Worker     void test(void)
1793*35238bceSAndroid Build Coastguard Worker     {
1794*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
1795*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1796*35238bceSAndroid Build Coastguard Worker 
1797*35238bceSAndroid Build Coastguard Worker         const GLenum blendFuncValues[] = {GL_ZERO,
1798*35238bceSAndroid Build Coastguard Worker                                           GL_ONE,
1799*35238bceSAndroid Build Coastguard Worker                                           GL_SRC_COLOR,
1800*35238bceSAndroid Build Coastguard Worker                                           GL_ONE_MINUS_SRC_COLOR,
1801*35238bceSAndroid Build Coastguard Worker                                           GL_DST_COLOR,
1802*35238bceSAndroid Build Coastguard Worker                                           GL_ONE_MINUS_DST_COLOR,
1803*35238bceSAndroid Build Coastguard Worker                                           GL_SRC_ALPHA,
1804*35238bceSAndroid Build Coastguard Worker                                           GL_ONE_MINUS_SRC_ALPHA,
1805*35238bceSAndroid Build Coastguard Worker                                           GL_DST_ALPHA,
1806*35238bceSAndroid Build Coastguard Worker                                           GL_ONE_MINUS_DST_ALPHA,
1807*35238bceSAndroid Build Coastguard Worker                                           GL_CONSTANT_COLOR,
1808*35238bceSAndroid Build Coastguard Worker                                           GL_ONE_MINUS_CONSTANT_COLOR,
1809*35238bceSAndroid Build Coastguard Worker                                           GL_CONSTANT_ALPHA,
1810*35238bceSAndroid Build Coastguard Worker                                           GL_ONE_MINUS_CONSTANT_ALPHA,
1811*35238bceSAndroid Build Coastguard Worker                                           GL_SRC_ALPHA_SATURATE};
1812*35238bceSAndroid Build Coastguard Worker 
1813*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx)
1814*35238bceSAndroid Build Coastguard Worker         {
1815*35238bceSAndroid Build Coastguard Worker             const GLenum referenceValue = blendFuncValues[ndx];
1816*35238bceSAndroid Build Coastguard Worker 
1817*35238bceSAndroid Build Coastguard Worker             SetBlendFunc(referenceValue);
1818*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1819*35238bceSAndroid Build Coastguard Worker 
1820*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1821*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1822*35238bceSAndroid Build Coastguard Worker         }
1823*35238bceSAndroid Build Coastguard Worker     }
1824*35238bceSAndroid Build Coastguard Worker 
1825*35238bceSAndroid Build Coastguard Worker protected:
SetBlendFunc(GLenum func)1826*35238bceSAndroid Build Coastguard Worker     virtual void SetBlendFunc(GLenum func)
1827*35238bceSAndroid Build Coastguard Worker     {
1828*35238bceSAndroid Build Coastguard Worker         switch (m_testTargetName)
1829*35238bceSAndroid Build Coastguard Worker         {
1830*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_SRC_RGB:
1831*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_SRC_ALPHA:
1832*35238bceSAndroid Build Coastguard Worker             glBlendFunc(func, GL_ZERO);
1833*35238bceSAndroid Build Coastguard Worker             break;
1834*35238bceSAndroid Build Coastguard Worker 
1835*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_DST_RGB:
1836*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_DST_ALPHA:
1837*35238bceSAndroid Build Coastguard Worker             glBlendFunc(GL_ZERO, func);
1838*35238bceSAndroid Build Coastguard Worker             break;
1839*35238bceSAndroid Build Coastguard Worker 
1840*35238bceSAndroid Build Coastguard Worker         default:
1841*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false && "should not happen");
1842*35238bceSAndroid Build Coastguard Worker             break;
1843*35238bceSAndroid Build Coastguard Worker         }
1844*35238bceSAndroid Build Coastguard Worker     }
1845*35238bceSAndroid Build Coastguard Worker 
1846*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1847*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1848*35238bceSAndroid Build Coastguard Worker     int m_initialValue;
1849*35238bceSAndroid Build Coastguard Worker };
1850*35238bceSAndroid Build Coastguard Worker 
1851*35238bceSAndroid Build Coastguard Worker class BlendFuncSeparateTestCase : public BlendFuncTestCase
1852*35238bceSAndroid Build Coastguard Worker {
1853*35238bceSAndroid Build Coastguard Worker public:
BlendFuncSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1854*35238bceSAndroid Build Coastguard Worker     BlendFuncSeparateTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1855*35238bceSAndroid Build Coastguard Worker                               GLenum testTargetName, int initialValue)
1856*35238bceSAndroid Build Coastguard Worker         : BlendFuncTestCase(context, verifier, name, description, testTargetName, initialValue)
1857*35238bceSAndroid Build Coastguard Worker     {
1858*35238bceSAndroid Build Coastguard Worker     }
1859*35238bceSAndroid Build Coastguard Worker 
SetBlendFunc(GLenum func)1860*35238bceSAndroid Build Coastguard Worker     void SetBlendFunc(GLenum func)
1861*35238bceSAndroid Build Coastguard Worker     {
1862*35238bceSAndroid Build Coastguard Worker         switch (m_testTargetName)
1863*35238bceSAndroid Build Coastguard Worker         {
1864*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_SRC_RGB:
1865*35238bceSAndroid Build Coastguard Worker             glBlendFuncSeparate(func, GL_ZERO, GL_ZERO, GL_ZERO);
1866*35238bceSAndroid Build Coastguard Worker             break;
1867*35238bceSAndroid Build Coastguard Worker 
1868*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_DST_RGB:
1869*35238bceSAndroid Build Coastguard Worker             glBlendFuncSeparate(GL_ZERO, func, GL_ZERO, GL_ZERO);
1870*35238bceSAndroid Build Coastguard Worker             break;
1871*35238bceSAndroid Build Coastguard Worker 
1872*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_SRC_ALPHA:
1873*35238bceSAndroid Build Coastguard Worker             glBlendFuncSeparate(GL_ZERO, GL_ZERO, func, GL_ZERO);
1874*35238bceSAndroid Build Coastguard Worker             break;
1875*35238bceSAndroid Build Coastguard Worker 
1876*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_DST_ALPHA:
1877*35238bceSAndroid Build Coastguard Worker             glBlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, func);
1878*35238bceSAndroid Build Coastguard Worker             break;
1879*35238bceSAndroid Build Coastguard Worker 
1880*35238bceSAndroid Build Coastguard Worker         default:
1881*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false && "should not happen");
1882*35238bceSAndroid Build Coastguard Worker             break;
1883*35238bceSAndroid Build Coastguard Worker         }
1884*35238bceSAndroid Build Coastguard Worker     }
1885*35238bceSAndroid Build Coastguard Worker };
1886*35238bceSAndroid Build Coastguard Worker 
1887*35238bceSAndroid Build Coastguard Worker class BlendEquationTestCase : public ApiCase
1888*35238bceSAndroid Build Coastguard Worker {
1889*35238bceSAndroid Build Coastguard Worker public:
BlendEquationTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1890*35238bceSAndroid Build Coastguard Worker     BlendEquationTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1891*35238bceSAndroid Build Coastguard Worker                           GLenum testTargetName, int initialValue)
1892*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1893*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1894*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1895*35238bceSAndroid Build Coastguard Worker         , m_initialValue(initialValue)
1896*35238bceSAndroid Build Coastguard Worker     {
1897*35238bceSAndroid Build Coastguard Worker     }
1898*35238bceSAndroid Build Coastguard Worker 
test(void)1899*35238bceSAndroid Build Coastguard Worker     void test(void)
1900*35238bceSAndroid Build Coastguard Worker     {
1901*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
1902*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1903*35238bceSAndroid Build Coastguard Worker 
1904*35238bceSAndroid Build Coastguard Worker         const GLenum blendFuncValues[] = {GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MIN, GL_MAX};
1905*35238bceSAndroid Build Coastguard Worker 
1906*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx)
1907*35238bceSAndroid Build Coastguard Worker         {
1908*35238bceSAndroid Build Coastguard Worker             const GLenum referenceValue = blendFuncValues[ndx];
1909*35238bceSAndroid Build Coastguard Worker 
1910*35238bceSAndroid Build Coastguard Worker             SetBlendEquation(referenceValue);
1911*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1912*35238bceSAndroid Build Coastguard Worker 
1913*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1914*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1915*35238bceSAndroid Build Coastguard Worker         }
1916*35238bceSAndroid Build Coastguard Worker     }
1917*35238bceSAndroid Build Coastguard Worker 
1918*35238bceSAndroid Build Coastguard Worker protected:
SetBlendEquation(GLenum equation)1919*35238bceSAndroid Build Coastguard Worker     virtual void SetBlendEquation(GLenum equation)
1920*35238bceSAndroid Build Coastguard Worker     {
1921*35238bceSAndroid Build Coastguard Worker         glBlendEquation(equation);
1922*35238bceSAndroid Build Coastguard Worker     }
1923*35238bceSAndroid Build Coastguard Worker 
1924*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1925*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1926*35238bceSAndroid Build Coastguard Worker     int m_initialValue;
1927*35238bceSAndroid Build Coastguard Worker };
1928*35238bceSAndroid Build Coastguard Worker class BlendEquationSeparateTestCase : public BlendEquationTestCase
1929*35238bceSAndroid Build Coastguard Worker {
1930*35238bceSAndroid Build Coastguard Worker public:
BlendEquationSeparateTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,int initialValue)1931*35238bceSAndroid Build Coastguard Worker     BlendEquationSeparateTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1932*35238bceSAndroid Build Coastguard Worker                                   GLenum testTargetName, int initialValue)
1933*35238bceSAndroid Build Coastguard Worker         : BlendEquationTestCase(context, verifier, name, description, testTargetName, initialValue)
1934*35238bceSAndroid Build Coastguard Worker     {
1935*35238bceSAndroid Build Coastguard Worker     }
1936*35238bceSAndroid Build Coastguard Worker 
1937*35238bceSAndroid Build Coastguard Worker protected:
SetBlendEquation(GLenum equation)1938*35238bceSAndroid Build Coastguard Worker     void SetBlendEquation(GLenum equation)
1939*35238bceSAndroid Build Coastguard Worker     {
1940*35238bceSAndroid Build Coastguard Worker         switch (m_testTargetName)
1941*35238bceSAndroid Build Coastguard Worker         {
1942*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_EQUATION_RGB:
1943*35238bceSAndroid Build Coastguard Worker             glBlendEquationSeparate(equation, GL_FUNC_ADD);
1944*35238bceSAndroid Build Coastguard Worker             break;
1945*35238bceSAndroid Build Coastguard Worker 
1946*35238bceSAndroid Build Coastguard Worker         case GL_BLEND_EQUATION_ALPHA:
1947*35238bceSAndroid Build Coastguard Worker             glBlendEquationSeparate(GL_FUNC_ADD, equation);
1948*35238bceSAndroid Build Coastguard Worker             break;
1949*35238bceSAndroid Build Coastguard Worker 
1950*35238bceSAndroid Build Coastguard Worker         default:
1951*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false && "should not happen");
1952*35238bceSAndroid Build Coastguard Worker             break;
1953*35238bceSAndroid Build Coastguard Worker         }
1954*35238bceSAndroid Build Coastguard Worker     }
1955*35238bceSAndroid Build Coastguard Worker };
1956*35238bceSAndroid Build Coastguard Worker 
1957*35238bceSAndroid Build Coastguard Worker class ImplementationArrayTestCase : public ApiCase
1958*35238bceSAndroid Build Coastguard Worker {
1959*35238bceSAndroid Build Coastguard Worker public:
ImplementationArrayTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description,GLenum testTargetName,GLenum testTargetLengthTargetName,int minValue)1960*35238bceSAndroid Build Coastguard Worker     ImplementationArrayTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description,
1961*35238bceSAndroid Build Coastguard Worker                                 GLenum testTargetName, GLenum testTargetLengthTargetName, int minValue)
1962*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
1963*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
1964*35238bceSAndroid Build Coastguard Worker         , m_testTargetName(testTargetName)
1965*35238bceSAndroid Build Coastguard Worker         , m_testTargetLengthTargetName(testTargetLengthTargetName)
1966*35238bceSAndroid Build Coastguard Worker         , m_minValue(minValue)
1967*35238bceSAndroid Build Coastguard Worker     {
1968*35238bceSAndroid Build Coastguard Worker     }
1969*35238bceSAndroid Build Coastguard Worker 
test(void)1970*35238bceSAndroid Build Coastguard Worker     void test(void)
1971*35238bceSAndroid Build Coastguard Worker     {
1972*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, m_testTargetLengthTargetName, m_minValue);
1973*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1974*35238bceSAndroid Build Coastguard Worker 
1975*35238bceSAndroid Build Coastguard Worker         GLint targetArrayLength = 0;
1976*35238bceSAndroid Build Coastguard Worker         glGetIntegerv(m_testTargetLengthTargetName, &targetArrayLength);
1977*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
1978*35238bceSAndroid Build Coastguard Worker 
1979*35238bceSAndroid Build Coastguard Worker         if (targetArrayLength)
1980*35238bceSAndroid Build Coastguard Worker         {
1981*35238bceSAndroid Build Coastguard Worker             std::vector<GLint> queryResult;
1982*35238bceSAndroid Build Coastguard Worker             queryResult.resize(targetArrayLength, 0);
1983*35238bceSAndroid Build Coastguard Worker 
1984*35238bceSAndroid Build Coastguard Worker             glGetIntegerv(m_testTargetName, &queryResult[0]);
1985*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
1986*35238bceSAndroid Build Coastguard Worker         }
1987*35238bceSAndroid Build Coastguard Worker     }
1988*35238bceSAndroid Build Coastguard Worker 
1989*35238bceSAndroid Build Coastguard Worker private:
1990*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
1991*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetName;
1992*35238bceSAndroid Build Coastguard Worker     GLenum m_testTargetLengthTargetName;
1993*35238bceSAndroid Build Coastguard Worker     int m_minValue;
1994*35238bceSAndroid Build Coastguard Worker };
1995*35238bceSAndroid Build Coastguard Worker 
1996*35238bceSAndroid Build Coastguard Worker class BindingTest : public TestCase
1997*35238bceSAndroid Build Coastguard Worker {
1998*35238bceSAndroid Build Coastguard Worker public:
1999*35238bceSAndroid Build Coastguard Worker     BindingTest(Context &context, const char *name, const char *desc, QueryType type);
2000*35238bceSAndroid Build Coastguard Worker 
2001*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
2002*35238bceSAndroid Build Coastguard Worker 
2003*35238bceSAndroid Build Coastguard Worker     virtual void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const = 0;
2004*35238bceSAndroid Build Coastguard Worker 
2005*35238bceSAndroid Build Coastguard Worker protected:
2006*35238bceSAndroid Build Coastguard Worker     const QueryType m_type;
2007*35238bceSAndroid Build Coastguard Worker };
2008*35238bceSAndroid Build Coastguard Worker 
BindingTest(Context & context,const char * name,const char * desc,QueryType type)2009*35238bceSAndroid Build Coastguard Worker BindingTest::BindingTest(Context &context, const char *name, const char *desc, QueryType type)
2010*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, desc)
2011*35238bceSAndroid Build Coastguard Worker     , m_type(type)
2012*35238bceSAndroid Build Coastguard Worker {
2013*35238bceSAndroid Build Coastguard Worker }
2014*35238bceSAndroid Build Coastguard Worker 
iterate(void)2015*35238bceSAndroid Build Coastguard Worker BindingTest::IterateResult BindingTest::iterate(void)
2016*35238bceSAndroid Build Coastguard Worker {
2017*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2018*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector result(m_context.getTestContext().getLog(), " // ERROR: ");
2019*35238bceSAndroid Build Coastguard Worker 
2020*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
2021*35238bceSAndroid Build Coastguard Worker 
2022*35238bceSAndroid Build Coastguard Worker     test(gl, result);
2023*35238bceSAndroid Build Coastguard Worker 
2024*35238bceSAndroid Build Coastguard Worker     result.setTestContextResult(m_testCtx);
2025*35238bceSAndroid Build Coastguard Worker     return STOP;
2026*35238bceSAndroid Build Coastguard Worker }
2027*35238bceSAndroid Build Coastguard Worker 
2028*35238bceSAndroid Build Coastguard Worker class TransformFeedbackBindingTestCase : public BindingTest
2029*35238bceSAndroid Build Coastguard Worker {
2030*35238bceSAndroid Build Coastguard Worker public:
TransformFeedbackBindingTestCase(Context & context,QueryType type,const char * name)2031*35238bceSAndroid Build Coastguard Worker     TransformFeedbackBindingTestCase(Context &context, QueryType type, const char *name)
2032*35238bceSAndroid Build Coastguard Worker         : BindingTest(context, name, "GL_TRANSFORM_FEEDBACK_BINDING", type)
2033*35238bceSAndroid Build Coastguard Worker     {
2034*35238bceSAndroid Build Coastguard Worker     }
2035*35238bceSAndroid Build Coastguard Worker 
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2036*35238bceSAndroid Build Coastguard Worker     void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const
2037*35238bceSAndroid Build Coastguard Worker     {
2038*35238bceSAndroid Build Coastguard Worker         static const char *transformFeedbackTestVertSource = "#version 300 es\n"
2039*35238bceSAndroid Build Coastguard Worker                                                              "void main (void)\n"
2040*35238bceSAndroid Build Coastguard Worker                                                              "{\n"
2041*35238bceSAndroid Build Coastguard Worker                                                              "    gl_Position = vec4(0.0);\n"
2042*35238bceSAndroid Build Coastguard Worker                                                              "}\n\0";
2043*35238bceSAndroid Build Coastguard Worker         static const char *transformFeedbackTestFragSource = "#version 300 es\n"
2044*35238bceSAndroid Build Coastguard Worker                                                              "layout(location = 0) out mediump vec4 fragColor;"
2045*35238bceSAndroid Build Coastguard Worker                                                              "void main (void)\n"
2046*35238bceSAndroid Build Coastguard Worker                                                              "{\n"
2047*35238bceSAndroid Build Coastguard Worker                                                              "    fragColor = vec4(0.0);\n"
2048*35238bceSAndroid Build Coastguard Worker                                                              "}\n\0";
2049*35238bceSAndroid Build Coastguard Worker 
2050*35238bceSAndroid Build Coastguard Worker         GLuint shaderVert;
2051*35238bceSAndroid Build Coastguard Worker         GLuint shaderFrag;
2052*35238bceSAndroid Build Coastguard Worker         GLuint shaderProg;
2053*35238bceSAndroid Build Coastguard Worker         GLuint transformfeedback = 0;
2054*35238bceSAndroid Build Coastguard Worker         GLuint feedbackBufferId  = 0;
2055*35238bceSAndroid Build Coastguard Worker 
2056*35238bceSAndroid Build Coastguard Worker         {
2057*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "Initial", "Initial");
2058*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, 0, m_type);
2059*35238bceSAndroid Build Coastguard Worker         }
2060*35238bceSAndroid Build Coastguard Worker 
2061*35238bceSAndroid Build Coastguard Worker         gl.glGenTransformFeedbacks(1, &transformfeedback);
2062*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenTransformFeedbacks");
2063*35238bceSAndroid Build Coastguard Worker 
2064*35238bceSAndroid Build Coastguard Worker         {
2065*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "VertexShader", "Vertex Shader");
2066*35238bceSAndroid Build Coastguard Worker 
2067*35238bceSAndroid Build Coastguard Worker             GLint compileStatus = -1;
2068*35238bceSAndroid Build Coastguard Worker 
2069*35238bceSAndroid Build Coastguard Worker             shaderVert = gl.glCreateShader(GL_VERTEX_SHADER);
2070*35238bceSAndroid Build Coastguard Worker             gl.glShaderSource(shaderVert, 1, &transformFeedbackTestVertSource, DE_NULL);
2071*35238bceSAndroid Build Coastguard Worker             gl.glCompileShader(shaderVert);
2072*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
2073*35238bceSAndroid Build Coastguard Worker 
2074*35238bceSAndroid Build Coastguard Worker             gl.glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus);
2075*35238bceSAndroid Build Coastguard Worker             if (compileStatus != GL_TRUE)
2076*35238bceSAndroid Build Coastguard Worker                 result.fail("expected GL_TRUE");
2077*35238bceSAndroid Build Coastguard Worker         }
2078*35238bceSAndroid Build Coastguard Worker         {
2079*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "FragmentShader", "Fragment Shader");
2080*35238bceSAndroid Build Coastguard Worker 
2081*35238bceSAndroid Build Coastguard Worker             GLint compileStatus = -1;
2082*35238bceSAndroid Build Coastguard Worker 
2083*35238bceSAndroid Build Coastguard Worker             shaderFrag = gl.glCreateShader(GL_FRAGMENT_SHADER);
2084*35238bceSAndroid Build Coastguard Worker             gl.glShaderSource(shaderFrag, 1, &transformFeedbackTestFragSource, DE_NULL);
2085*35238bceSAndroid Build Coastguard Worker             gl.glCompileShader(shaderFrag);
2086*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
2087*35238bceSAndroid Build Coastguard Worker 
2088*35238bceSAndroid Build Coastguard Worker             gl.glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus);
2089*35238bceSAndroid Build Coastguard Worker             if (compileStatus != GL_TRUE)
2090*35238bceSAndroid Build Coastguard Worker                 result.fail("expected GL_TRUE");
2091*35238bceSAndroid Build Coastguard Worker         }
2092*35238bceSAndroid Build Coastguard Worker         {
2093*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "Program", "Create and bind program");
2094*35238bceSAndroid Build Coastguard Worker 
2095*35238bceSAndroid Build Coastguard Worker             const char *transform_feedback_outputs = "gl_Position";
2096*35238bceSAndroid Build Coastguard Worker             GLint linkStatus                       = -1;
2097*35238bceSAndroid Build Coastguard Worker 
2098*35238bceSAndroid Build Coastguard Worker             shaderProg = gl.glCreateProgram();
2099*35238bceSAndroid Build Coastguard Worker             gl.glAttachShader(shaderProg, shaderVert);
2100*35238bceSAndroid Build Coastguard Worker             gl.glAttachShader(shaderProg, shaderFrag);
2101*35238bceSAndroid Build Coastguard Worker             gl.glTransformFeedbackVaryings(shaderProg, 1, &transform_feedback_outputs, GL_INTERLEAVED_ATTRIBS);
2102*35238bceSAndroid Build Coastguard Worker             gl.glLinkProgram(shaderProg);
2103*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glLinkProgram");
2104*35238bceSAndroid Build Coastguard Worker 
2105*35238bceSAndroid Build Coastguard Worker             gl.glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus);
2106*35238bceSAndroid Build Coastguard Worker             if (linkStatus != GL_TRUE)
2107*35238bceSAndroid Build Coastguard Worker                 result.fail("expected GL_TRUE");
2108*35238bceSAndroid Build Coastguard Worker         }
2109*35238bceSAndroid Build Coastguard Worker 
2110*35238bceSAndroid Build Coastguard Worker         gl.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformfeedback);
2111*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTransformFeedback");
2112*35238bceSAndroid Build Coastguard Worker 
2113*35238bceSAndroid Build Coastguard Worker         gl.glGenBuffers(1, &feedbackBufferId);
2114*35238bceSAndroid Build Coastguard Worker         gl.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackBufferId);
2115*35238bceSAndroid Build Coastguard Worker         gl.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_DYNAMIC_READ);
2116*35238bceSAndroid Build Coastguard Worker         gl.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, feedbackBufferId);
2117*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind buffers");
2118*35238bceSAndroid Build Coastguard Worker 
2119*35238bceSAndroid Build Coastguard Worker         gl.glUseProgram(shaderProg);
2120*35238bceSAndroid Build Coastguard Worker 
2121*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, transformfeedback, m_type);
2122*35238bceSAndroid Build Coastguard Worker 
2123*35238bceSAndroid Build Coastguard Worker         gl.glUseProgram(0);
2124*35238bceSAndroid Build Coastguard Worker         gl.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
2125*35238bceSAndroid Build Coastguard Worker         gl.glDeleteTransformFeedbacks(1, &transformfeedback);
2126*35238bceSAndroid Build Coastguard Worker 
2127*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, 0, m_type);
2128*35238bceSAndroid Build Coastguard Worker 
2129*35238bceSAndroid Build Coastguard Worker         gl.glDeleteBuffers(1, &feedbackBufferId);
2130*35238bceSAndroid Build Coastguard Worker         gl.glDeleteShader(shaderVert);
2131*35238bceSAndroid Build Coastguard Worker         gl.glDeleteShader(shaderFrag);
2132*35238bceSAndroid Build Coastguard Worker         gl.glDeleteProgram(shaderProg);
2133*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteProgram");
2134*35238bceSAndroid Build Coastguard Worker     }
2135*35238bceSAndroid Build Coastguard Worker };
2136*35238bceSAndroid Build Coastguard Worker 
2137*35238bceSAndroid Build Coastguard Worker class CurrentProgramBindingTestCase : public BindingTest
2138*35238bceSAndroid Build Coastguard Worker {
2139*35238bceSAndroid Build Coastguard Worker public:
CurrentProgramBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2140*35238bceSAndroid Build Coastguard Worker     CurrentProgramBindingTestCase(Context &context, QueryType type, const char *name, const char *description)
2141*35238bceSAndroid Build Coastguard Worker         : BindingTest(context, name, description, type)
2142*35238bceSAndroid Build Coastguard Worker     {
2143*35238bceSAndroid Build Coastguard Worker     }
2144*35238bceSAndroid Build Coastguard Worker 
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2145*35238bceSAndroid Build Coastguard Worker     void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const
2146*35238bceSAndroid Build Coastguard Worker     {
2147*35238bceSAndroid Build Coastguard Worker         static const char *testVertSource = "#version 300 es\n"
2148*35238bceSAndroid Build Coastguard Worker                                             "void main (void)\n"
2149*35238bceSAndroid Build Coastguard Worker                                             "{\n"
2150*35238bceSAndroid Build Coastguard Worker                                             "    gl_Position = vec4(0.0);\n"
2151*35238bceSAndroid Build Coastguard Worker                                             "}\n\0";
2152*35238bceSAndroid Build Coastguard Worker         static const char *testFragSource = "#version 300 es\n"
2153*35238bceSAndroid Build Coastguard Worker                                             "layout(location = 0) out mediump vec4 fragColor;"
2154*35238bceSAndroid Build Coastguard Worker                                             "void main (void)\n"
2155*35238bceSAndroid Build Coastguard Worker                                             "{\n"
2156*35238bceSAndroid Build Coastguard Worker                                             "    fragColor = vec4(0.0);\n"
2157*35238bceSAndroid Build Coastguard Worker                                             "}\n\0";
2158*35238bceSAndroid Build Coastguard Worker 
2159*35238bceSAndroid Build Coastguard Worker         GLuint shaderVert;
2160*35238bceSAndroid Build Coastguard Worker         GLuint shaderFrag;
2161*35238bceSAndroid Build Coastguard Worker         GLuint shaderProg;
2162*35238bceSAndroid Build Coastguard Worker 
2163*35238bceSAndroid Build Coastguard Worker         {
2164*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "Initial", "Initial");
2165*35238bceSAndroid Build Coastguard Worker 
2166*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type);
2167*35238bceSAndroid Build Coastguard Worker         }
2168*35238bceSAndroid Build Coastguard Worker         {
2169*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "VertexShader", "Vertex Shader");
2170*35238bceSAndroid Build Coastguard Worker 
2171*35238bceSAndroid Build Coastguard Worker             GLint compileStatus = -1;
2172*35238bceSAndroid Build Coastguard Worker 
2173*35238bceSAndroid Build Coastguard Worker             shaderVert = gl.glCreateShader(GL_VERTEX_SHADER);
2174*35238bceSAndroid Build Coastguard Worker             gl.glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
2175*35238bceSAndroid Build Coastguard Worker             gl.glCompileShader(shaderVert);
2176*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
2177*35238bceSAndroid Build Coastguard Worker 
2178*35238bceSAndroid Build Coastguard Worker             gl.glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus);
2179*35238bceSAndroid Build Coastguard Worker             if (compileStatus != GL_TRUE)
2180*35238bceSAndroid Build Coastguard Worker                 result.fail("expected GL_TRUE");
2181*35238bceSAndroid Build Coastguard Worker         }
2182*35238bceSAndroid Build Coastguard Worker         {
2183*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "FragmentShader", "Fragment Shader");
2184*35238bceSAndroid Build Coastguard Worker 
2185*35238bceSAndroid Build Coastguard Worker             GLint compileStatus = -1;
2186*35238bceSAndroid Build Coastguard Worker 
2187*35238bceSAndroid Build Coastguard Worker             shaderFrag = gl.glCreateShader(GL_FRAGMENT_SHADER);
2188*35238bceSAndroid Build Coastguard Worker             gl.glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
2189*35238bceSAndroid Build Coastguard Worker             gl.glCompileShader(shaderFrag);
2190*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
2191*35238bceSAndroid Build Coastguard Worker 
2192*35238bceSAndroid Build Coastguard Worker             gl.glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus);
2193*35238bceSAndroid Build Coastguard Worker             if (compileStatus != GL_TRUE)
2194*35238bceSAndroid Build Coastguard Worker                 result.fail("expected GL_TRUE");
2195*35238bceSAndroid Build Coastguard Worker         }
2196*35238bceSAndroid Build Coastguard Worker         {
2197*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "Program", "Create and bind program");
2198*35238bceSAndroid Build Coastguard Worker 
2199*35238bceSAndroid Build Coastguard Worker             GLint linkStatus = -1;
2200*35238bceSAndroid Build Coastguard Worker 
2201*35238bceSAndroid Build Coastguard Worker             shaderProg = gl.glCreateProgram();
2202*35238bceSAndroid Build Coastguard Worker             gl.glAttachShader(shaderProg, shaderVert);
2203*35238bceSAndroid Build Coastguard Worker             gl.glAttachShader(shaderProg, shaderFrag);
2204*35238bceSAndroid Build Coastguard Worker             gl.glLinkProgram(shaderProg);
2205*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glLinkProgram");
2206*35238bceSAndroid Build Coastguard Worker 
2207*35238bceSAndroid Build Coastguard Worker             gl.glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus);
2208*35238bceSAndroid Build Coastguard Worker             if (linkStatus != GL_TRUE)
2209*35238bceSAndroid Build Coastguard Worker                 result.fail("expected GL_TRUE");
2210*35238bceSAndroid Build Coastguard Worker 
2211*35238bceSAndroid Build Coastguard Worker             gl.glUseProgram(shaderProg);
2212*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram");
2213*35238bceSAndroid Build Coastguard Worker 
2214*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type);
2215*35238bceSAndroid Build Coastguard Worker         }
2216*35238bceSAndroid Build Coastguard Worker         {
2217*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "Delete", "Delete program while in use");
2218*35238bceSAndroid Build Coastguard Worker 
2219*35238bceSAndroid Build Coastguard Worker             gl.glDeleteShader(shaderVert);
2220*35238bceSAndroid Build Coastguard Worker             gl.glDeleteShader(shaderFrag);
2221*35238bceSAndroid Build Coastguard Worker             gl.glDeleteProgram(shaderProg);
2222*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteProgram");
2223*35238bceSAndroid Build Coastguard Worker 
2224*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type);
2225*35238bceSAndroid Build Coastguard Worker         }
2226*35238bceSAndroid Build Coastguard Worker         {
2227*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "Unbind", "Unbind program");
2228*35238bceSAndroid Build Coastguard Worker             gl.glUseProgram(0);
2229*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram");
2230*35238bceSAndroid Build Coastguard Worker 
2231*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type);
2232*35238bceSAndroid Build Coastguard Worker         }
2233*35238bceSAndroid Build Coastguard Worker     }
2234*35238bceSAndroid Build Coastguard Worker };
2235*35238bceSAndroid Build Coastguard Worker 
2236*35238bceSAndroid Build Coastguard Worker class VertexArrayBindingTestCase : public BindingTest
2237*35238bceSAndroid Build Coastguard Worker {
2238*35238bceSAndroid Build Coastguard Worker public:
VertexArrayBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2239*35238bceSAndroid Build Coastguard Worker     VertexArrayBindingTestCase(Context &context, QueryType type, const char *name, const char *description)
2240*35238bceSAndroid Build Coastguard Worker         : BindingTest(context, name, description, type)
2241*35238bceSAndroid Build Coastguard Worker     {
2242*35238bceSAndroid Build Coastguard Worker     }
2243*35238bceSAndroid Build Coastguard Worker 
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2244*35238bceSAndroid Build Coastguard Worker     void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const
2245*35238bceSAndroid Build Coastguard Worker     {
2246*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, 0, m_type);
2247*35238bceSAndroid Build Coastguard Worker 
2248*35238bceSAndroid Build Coastguard Worker         GLuint vertexArrayObject = 0;
2249*35238bceSAndroid Build Coastguard Worker         gl.glGenVertexArrays(1, &vertexArrayObject);
2250*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenVertexArrays");
2251*35238bceSAndroid Build Coastguard Worker 
2252*35238bceSAndroid Build Coastguard Worker         gl.glBindVertexArray(vertexArrayObject);
2253*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, vertexArrayObject, m_type);
2254*35238bceSAndroid Build Coastguard Worker 
2255*35238bceSAndroid Build Coastguard Worker         gl.glDeleteVertexArrays(1, &vertexArrayObject);
2256*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, 0, m_type);
2257*35238bceSAndroid Build Coastguard Worker     }
2258*35238bceSAndroid Build Coastguard Worker };
2259*35238bceSAndroid Build Coastguard Worker 
2260*35238bceSAndroid Build Coastguard Worker class BufferBindingTestCase : public BindingTest
2261*35238bceSAndroid Build Coastguard Worker {
2262*35238bceSAndroid Build Coastguard Worker public:
BufferBindingTestCase(Context & context,QueryType type,const char * name,const char * description,GLenum bufferBindingName,GLenum bufferType)2263*35238bceSAndroid Build Coastguard Worker     BufferBindingTestCase(Context &context, QueryType type, const char *name, const char *description,
2264*35238bceSAndroid Build Coastguard Worker                           GLenum bufferBindingName, GLenum bufferType)
2265*35238bceSAndroid Build Coastguard Worker         : BindingTest(context, name, description, type)
2266*35238bceSAndroid Build Coastguard Worker         , m_bufferBindingName(bufferBindingName)
2267*35238bceSAndroid Build Coastguard Worker         , m_bufferType(bufferType)
2268*35238bceSAndroid Build Coastguard Worker     {
2269*35238bceSAndroid Build Coastguard Worker     }
2270*35238bceSAndroid Build Coastguard Worker 
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2271*35238bceSAndroid Build Coastguard Worker     void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const
2272*35238bceSAndroid Build Coastguard Worker     {
2273*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type);
2274*35238bceSAndroid Build Coastguard Worker 
2275*35238bceSAndroid Build Coastguard Worker         GLuint bufferObject = 0;
2276*35238bceSAndroid Build Coastguard Worker         gl.glGenBuffers(1, &bufferObject);
2277*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
2278*35238bceSAndroid Build Coastguard Worker 
2279*35238bceSAndroid Build Coastguard Worker         gl.glBindBuffer(m_bufferType, bufferObject);
2280*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, m_bufferBindingName, bufferObject, m_type);
2281*35238bceSAndroid Build Coastguard Worker 
2282*35238bceSAndroid Build Coastguard Worker         gl.glDeleteBuffers(1, &bufferObject);
2283*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteBuffers");
2284*35238bceSAndroid Build Coastguard Worker 
2285*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type);
2286*35238bceSAndroid Build Coastguard Worker     }
2287*35238bceSAndroid Build Coastguard Worker 
2288*35238bceSAndroid Build Coastguard Worker private:
2289*35238bceSAndroid Build Coastguard Worker     const GLenum m_bufferBindingName;
2290*35238bceSAndroid Build Coastguard Worker     const GLenum m_bufferType;
2291*35238bceSAndroid Build Coastguard Worker };
2292*35238bceSAndroid Build Coastguard Worker 
2293*35238bceSAndroid Build Coastguard Worker class ElementArrayBufferBindingTestCase : public BindingTest
2294*35238bceSAndroid Build Coastguard Worker {
2295*35238bceSAndroid Build Coastguard Worker public:
ElementArrayBufferBindingTestCase(Context & context,QueryType type,const char * name)2296*35238bceSAndroid Build Coastguard Worker     ElementArrayBufferBindingTestCase(Context &context, QueryType type, const char *name)
2297*35238bceSAndroid Build Coastguard Worker         : BindingTest(context, name, "GL_ELEMENT_ARRAY_BUFFER_BINDING", type)
2298*35238bceSAndroid Build Coastguard Worker     {
2299*35238bceSAndroid Build Coastguard Worker     }
2300*35238bceSAndroid Build Coastguard Worker 
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2301*35238bceSAndroid Build Coastguard Worker     void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const
2302*35238bceSAndroid Build Coastguard Worker     {
2303*35238bceSAndroid Build Coastguard Worker         // Test with default VAO
2304*35238bceSAndroid Build Coastguard Worker         {
2305*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "DefaultVAO", "Test with default VAO");
2306*35238bceSAndroid Build Coastguard Worker 
2307*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2308*35238bceSAndroid Build Coastguard Worker 
2309*35238bceSAndroid Build Coastguard Worker             GLuint bufferObject = 0;
2310*35238bceSAndroid Build Coastguard Worker             gl.glGenBuffers(1, &bufferObject);
2311*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
2312*35238bceSAndroid Build Coastguard Worker 
2313*35238bceSAndroid Build Coastguard Worker             gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObject);
2314*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, bufferObject, m_type);
2315*35238bceSAndroid Build Coastguard Worker 
2316*35238bceSAndroid Build Coastguard Worker             gl.glDeleteBuffers(1, &bufferObject);
2317*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2318*35238bceSAndroid Build Coastguard Worker         }
2319*35238bceSAndroid Build Coastguard Worker 
2320*35238bceSAndroid Build Coastguard Worker         // Test with multiple VAOs
2321*35238bceSAndroid Build Coastguard Worker         {
2322*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "WithVAO", "Test with VAO");
2323*35238bceSAndroid Build Coastguard Worker 
2324*35238bceSAndroid Build Coastguard Worker             GLuint vaos[2]    = {0};
2325*35238bceSAndroid Build Coastguard Worker             GLuint buffers[2] = {0};
2326*35238bceSAndroid Build Coastguard Worker 
2327*35238bceSAndroid Build Coastguard Worker             gl.glGenVertexArrays(2, vaos);
2328*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenVertexArrays");
2329*35238bceSAndroid Build Coastguard Worker 
2330*35238bceSAndroid Build Coastguard Worker             gl.glGenBuffers(2, buffers);
2331*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
2332*35238bceSAndroid Build Coastguard Worker 
2333*35238bceSAndroid Build Coastguard Worker             // initial
2334*35238bceSAndroid Build Coastguard Worker             gl.glBindVertexArray(vaos[0]);
2335*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2336*35238bceSAndroid Build Coastguard Worker 
2337*35238bceSAndroid Build Coastguard Worker             // after setting
2338*35238bceSAndroid Build Coastguard Worker             gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[0]);
2339*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[0], m_type);
2340*35238bceSAndroid Build Coastguard Worker 
2341*35238bceSAndroid Build Coastguard Worker             // initial of vao 2
2342*35238bceSAndroid Build Coastguard Worker             gl.glBindVertexArray(vaos[1]);
2343*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2344*35238bceSAndroid Build Coastguard Worker 
2345*35238bceSAndroid Build Coastguard Worker             // after setting to 2
2346*35238bceSAndroid Build Coastguard Worker             gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
2347*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[1], m_type);
2348*35238bceSAndroid Build Coastguard Worker 
2349*35238bceSAndroid Build Coastguard Worker             // vao 1 still has buffer 1 bound?
2350*35238bceSAndroid Build Coastguard Worker             gl.glBindVertexArray(vaos[0]);
2351*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[0], m_type);
2352*35238bceSAndroid Build Coastguard Worker 
2353*35238bceSAndroid Build Coastguard Worker             // deleting clears from bound vaos ...
2354*35238bceSAndroid Build Coastguard Worker             gl.glDeleteBuffers(2, buffers);
2355*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2356*35238bceSAndroid Build Coastguard Worker 
2357*35238bceSAndroid Build Coastguard Worker             // ... but does not from non-bound vaos?
2358*35238bceSAndroid Build Coastguard Worker             gl.glBindVertexArray(vaos[1]);
2359*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[1], m_type);
2360*35238bceSAndroid Build Coastguard Worker 
2361*35238bceSAndroid Build Coastguard Worker             gl.glDeleteVertexArrays(2, vaos);
2362*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteVertexArrays");
2363*35238bceSAndroid Build Coastguard Worker         }
2364*35238bceSAndroid Build Coastguard Worker     }
2365*35238bceSAndroid Build Coastguard Worker };
2366*35238bceSAndroid Build Coastguard Worker 
2367*35238bceSAndroid Build Coastguard Worker class StencilClearValueTestCase : public ApiCase
2368*35238bceSAndroid Build Coastguard Worker {
2369*35238bceSAndroid Build Coastguard Worker public:
StencilClearValueTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2370*35238bceSAndroid Build Coastguard Worker     StencilClearValueTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
2371*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
2372*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
2373*35238bceSAndroid Build Coastguard Worker     {
2374*35238bceSAndroid Build Coastguard Worker     }
2375*35238bceSAndroid Build Coastguard Worker 
test(void)2376*35238bceSAndroid Build Coastguard Worker     void test(void)
2377*35238bceSAndroid Build Coastguard Worker     {
2378*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, 0);
2379*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2380*35238bceSAndroid Build Coastguard Worker 
2381*35238bceSAndroid Build Coastguard Worker         const int stencilBits = m_context.getRenderTarget().getStencilBits();
2382*35238bceSAndroid Build Coastguard Worker 
2383*35238bceSAndroid Build Coastguard Worker         for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
2384*35238bceSAndroid Build Coastguard Worker         {
2385*35238bceSAndroid Build Coastguard Worker             const int ref = 1 << stencilBit;
2386*35238bceSAndroid Build Coastguard Worker 
2387*35238bceSAndroid Build Coastguard Worker             glClearStencil(ref); // mask should not affect the REF
2388*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
2389*35238bceSAndroid Build Coastguard Worker 
2390*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, ref);
2391*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
2392*35238bceSAndroid Build Coastguard Worker         }
2393*35238bceSAndroid Build Coastguard Worker     }
2394*35238bceSAndroid Build Coastguard Worker 
2395*35238bceSAndroid Build Coastguard Worker private:
2396*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
2397*35238bceSAndroid Build Coastguard Worker };
2398*35238bceSAndroid Build Coastguard Worker 
2399*35238bceSAndroid Build Coastguard Worker class ActiveTextureTestCase : public ApiCase
2400*35238bceSAndroid Build Coastguard Worker {
2401*35238bceSAndroid Build Coastguard Worker public:
ActiveTextureTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2402*35238bceSAndroid Build Coastguard Worker     ActiveTextureTestCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
2403*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
2404*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
2405*35238bceSAndroid Build Coastguard Worker     {
2406*35238bceSAndroid Build Coastguard Worker     }
2407*35238bceSAndroid Build Coastguard Worker 
test(void)2408*35238bceSAndroid Build Coastguard Worker     void test(void)
2409*35238bceSAndroid Build Coastguard Worker     {
2410*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0);
2411*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2412*35238bceSAndroid Build Coastguard Worker 
2413*35238bceSAndroid Build Coastguard Worker         GLint textureUnits = 0;
2414*35238bceSAndroid Build Coastguard Worker         glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &textureUnits);
2415*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2416*35238bceSAndroid Build Coastguard Worker 
2417*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < textureUnits; ++ndx)
2418*35238bceSAndroid Build Coastguard Worker         {
2419*35238bceSAndroid Build Coastguard Worker             glActiveTexture(GL_TEXTURE0 + ndx);
2420*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
2421*35238bceSAndroid Build Coastguard Worker 
2422*35238bceSAndroid Build Coastguard Worker             m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0 + ndx);
2423*35238bceSAndroid Build Coastguard Worker             expectError(GL_NO_ERROR);
2424*35238bceSAndroid Build Coastguard Worker         }
2425*35238bceSAndroid Build Coastguard Worker     }
2426*35238bceSAndroid Build Coastguard Worker 
2427*35238bceSAndroid Build Coastguard Worker private:
2428*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
2429*35238bceSAndroid Build Coastguard Worker };
2430*35238bceSAndroid Build Coastguard Worker 
2431*35238bceSAndroid Build Coastguard Worker class RenderbufferBindingTestCase : public BindingTest
2432*35238bceSAndroid Build Coastguard Worker {
2433*35238bceSAndroid Build Coastguard Worker public:
RenderbufferBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2434*35238bceSAndroid Build Coastguard Worker     RenderbufferBindingTestCase(Context &context, QueryType type, const char *name, const char *description)
2435*35238bceSAndroid Build Coastguard Worker         : BindingTest(context, name, description, type)
2436*35238bceSAndroid Build Coastguard Worker     {
2437*35238bceSAndroid Build Coastguard Worker     }
2438*35238bceSAndroid Build Coastguard Worker 
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2439*35238bceSAndroid Build Coastguard Worker     void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const
2440*35238bceSAndroid Build Coastguard Worker     {
2441*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type);
2442*35238bceSAndroid Build Coastguard Worker 
2443*35238bceSAndroid Build Coastguard Worker         GLuint renderBuffer = 0;
2444*35238bceSAndroid Build Coastguard Worker         gl.glGenRenderbuffers(1, &renderBuffer);
2445*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenRenderbuffers");
2446*35238bceSAndroid Build Coastguard Worker 
2447*35238bceSAndroid Build Coastguard Worker         gl.glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
2448*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindRenderbuffer");
2449*35238bceSAndroid Build Coastguard Worker 
2450*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, renderBuffer, m_type);
2451*35238bceSAndroid Build Coastguard Worker 
2452*35238bceSAndroid Build Coastguard Worker         gl.glDeleteRenderbuffers(1, &renderBuffer);
2453*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteRenderbuffers");
2454*35238bceSAndroid Build Coastguard Worker 
2455*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type);
2456*35238bceSAndroid Build Coastguard Worker     }
2457*35238bceSAndroid Build Coastguard Worker };
2458*35238bceSAndroid Build Coastguard Worker 
2459*35238bceSAndroid Build Coastguard Worker class SamplerObjectBindingTestCase : public BindingTest
2460*35238bceSAndroid Build Coastguard Worker {
2461*35238bceSAndroid Build Coastguard Worker public:
SamplerObjectBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2462*35238bceSAndroid Build Coastguard Worker     SamplerObjectBindingTestCase(Context &context, QueryType type, const char *name, const char *description)
2463*35238bceSAndroid Build Coastguard Worker         : BindingTest(context, name, description, type)
2464*35238bceSAndroid Build Coastguard Worker     {
2465*35238bceSAndroid Build Coastguard Worker     }
2466*35238bceSAndroid Build Coastguard Worker 
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2467*35238bceSAndroid Build Coastguard Worker     void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const
2468*35238bceSAndroid Build Coastguard Worker     {
2469*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type);
2470*35238bceSAndroid Build Coastguard Worker 
2471*35238bceSAndroid Build Coastguard Worker         {
2472*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "SingleUnit", "Single unit");
2473*35238bceSAndroid Build Coastguard Worker 
2474*35238bceSAndroid Build Coastguard Worker             GLuint sampler = 0;
2475*35238bceSAndroid Build Coastguard Worker             gl.glGenSamplers(1, &sampler);
2476*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenSamplers");
2477*35238bceSAndroid Build Coastguard Worker 
2478*35238bceSAndroid Build Coastguard Worker             gl.glBindSampler(0, sampler);
2479*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindSampler");
2480*35238bceSAndroid Build Coastguard Worker 
2481*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_SAMPLER_BINDING, sampler, m_type);
2482*35238bceSAndroid Build Coastguard Worker 
2483*35238bceSAndroid Build Coastguard Worker             gl.glDeleteSamplers(1, &sampler);
2484*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type);
2485*35238bceSAndroid Build Coastguard Worker         }
2486*35238bceSAndroid Build Coastguard Worker 
2487*35238bceSAndroid Build Coastguard Worker         {
2488*35238bceSAndroid Build Coastguard Worker             const tcu::ScopedLogSection section(gl.getLog(), "MultipleUnits", "Multiple units");
2489*35238bceSAndroid Build Coastguard Worker 
2490*35238bceSAndroid Build Coastguard Worker             GLuint samplerA = 0;
2491*35238bceSAndroid Build Coastguard Worker             GLuint samplerB = 0;
2492*35238bceSAndroid Build Coastguard Worker             gl.glGenSamplers(1, &samplerA);
2493*35238bceSAndroid Build Coastguard Worker             gl.glGenSamplers(1, &samplerB);
2494*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenSamplers");
2495*35238bceSAndroid Build Coastguard Worker 
2496*35238bceSAndroid Build Coastguard Worker             gl.glBindSampler(1, samplerA);
2497*35238bceSAndroid Build Coastguard Worker             gl.glBindSampler(2, samplerB);
2498*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindSampler");
2499*35238bceSAndroid Build Coastguard Worker 
2500*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type);
2501*35238bceSAndroid Build Coastguard Worker 
2502*35238bceSAndroid Build Coastguard Worker             gl.glActiveTexture(GL_TEXTURE1);
2503*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_SAMPLER_BINDING, samplerA, m_type);
2504*35238bceSAndroid Build Coastguard Worker 
2505*35238bceSAndroid Build Coastguard Worker             gl.glActiveTexture(GL_TEXTURE2);
2506*35238bceSAndroid Build Coastguard Worker             verifyStateInteger(result, gl, GL_SAMPLER_BINDING, samplerB, m_type);
2507*35238bceSAndroid Build Coastguard Worker 
2508*35238bceSAndroid Build Coastguard Worker             gl.glDeleteSamplers(1, &samplerB);
2509*35238bceSAndroid Build Coastguard Worker             gl.glDeleteSamplers(1, &samplerA);
2510*35238bceSAndroid Build Coastguard Worker             GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteSamplers");
2511*35238bceSAndroid Build Coastguard Worker         }
2512*35238bceSAndroid Build Coastguard Worker     }
2513*35238bceSAndroid Build Coastguard Worker };
2514*35238bceSAndroid Build Coastguard Worker 
2515*35238bceSAndroid Build Coastguard Worker class TextureBindingTestCase : public BindingTest
2516*35238bceSAndroid Build Coastguard Worker {
2517*35238bceSAndroid Build Coastguard Worker public:
TextureBindingTestCase(Context & context,QueryType type,const char * name,const char * description,GLenum testBindingName,GLenum textureType)2518*35238bceSAndroid Build Coastguard Worker     TextureBindingTestCase(Context &context, QueryType type, const char *name, const char *description,
2519*35238bceSAndroid Build Coastguard Worker                            GLenum testBindingName, GLenum textureType)
2520*35238bceSAndroid Build Coastguard Worker         : BindingTest(context, name, description, type)
2521*35238bceSAndroid Build Coastguard Worker         , m_testBindingName(testBindingName)
2522*35238bceSAndroid Build Coastguard Worker         , m_textureType(textureType)
2523*35238bceSAndroid Build Coastguard Worker     {
2524*35238bceSAndroid Build Coastguard Worker     }
2525*35238bceSAndroid Build Coastguard Worker 
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2526*35238bceSAndroid Build Coastguard Worker     void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const
2527*35238bceSAndroid Build Coastguard Worker     {
2528*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, m_testBindingName, 0, m_type);
2529*35238bceSAndroid Build Coastguard Worker 
2530*35238bceSAndroid Build Coastguard Worker         GLuint texture = 0;
2531*35238bceSAndroid Build Coastguard Worker         gl.glGenTextures(1, &texture);
2532*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenTextures");
2533*35238bceSAndroid Build Coastguard Worker 
2534*35238bceSAndroid Build Coastguard Worker         gl.glBindTexture(m_textureType, texture);
2535*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
2536*35238bceSAndroid Build Coastguard Worker 
2537*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, m_testBindingName, texture, m_type);
2538*35238bceSAndroid Build Coastguard Worker 
2539*35238bceSAndroid Build Coastguard Worker         gl.glDeleteTextures(1, &texture);
2540*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
2541*35238bceSAndroid Build Coastguard Worker 
2542*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, m_testBindingName, 0, m_type);
2543*35238bceSAndroid Build Coastguard Worker     }
2544*35238bceSAndroid Build Coastguard Worker 
2545*35238bceSAndroid Build Coastguard Worker private:
2546*35238bceSAndroid Build Coastguard Worker     const GLenum m_testBindingName;
2547*35238bceSAndroid Build Coastguard Worker     const GLenum m_textureType;
2548*35238bceSAndroid Build Coastguard Worker };
2549*35238bceSAndroid Build Coastguard Worker 
2550*35238bceSAndroid Build Coastguard Worker class FrameBufferBindingTestCase : public BindingTest
2551*35238bceSAndroid Build Coastguard Worker {
2552*35238bceSAndroid Build Coastguard Worker public:
FrameBufferBindingTestCase(Context & context,QueryType type,const char * name,const char * description)2553*35238bceSAndroid Build Coastguard Worker     FrameBufferBindingTestCase(Context &context, QueryType type, const char *name, const char *description)
2554*35238bceSAndroid Build Coastguard Worker         : BindingTest(context, name, description, type)
2555*35238bceSAndroid Build Coastguard Worker     {
2556*35238bceSAndroid Build Coastguard Worker     }
2557*35238bceSAndroid Build Coastguard Worker 
test(glu::CallLogWrapper & gl,tcu::ResultCollector & result) const2558*35238bceSAndroid Build Coastguard Worker     void test(glu::CallLogWrapper &gl, tcu::ResultCollector &result) const
2559*35238bceSAndroid Build Coastguard Worker     {
2560*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type);
2561*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
2562*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, 0, m_type);
2563*35238bceSAndroid Build Coastguard Worker 
2564*35238bceSAndroid Build Coastguard Worker         GLuint framebufferId = 0;
2565*35238bceSAndroid Build Coastguard Worker         gl.glGenFramebuffers(1, &framebufferId);
2566*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenFramebuffers");
2567*35238bceSAndroid Build Coastguard Worker 
2568*35238bceSAndroid Build Coastguard Worker         gl.glBindFramebuffer(GL_FRAMEBUFFER, framebufferId);
2569*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_FRAMEBUFFER");
2570*35238bceSAndroid Build Coastguard Worker 
2571*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, framebufferId, m_type);
2572*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, framebufferId, m_type);
2573*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, framebufferId, m_type);
2574*35238bceSAndroid Build Coastguard Worker 
2575*35238bceSAndroid Build Coastguard Worker         gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
2576*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "unbind GL_FRAMEBUFFER");
2577*35238bceSAndroid Build Coastguard Worker 
2578*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type);
2579*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
2580*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, 0, m_type);
2581*35238bceSAndroid Build Coastguard Worker 
2582*35238bceSAndroid Build Coastguard Worker         gl.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferId);
2583*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_READ_FRAMEBUFFER");
2584*35238bceSAndroid Build Coastguard Worker 
2585*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type);
2586*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
2587*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, framebufferId, m_type);
2588*35238bceSAndroid Build Coastguard Worker 
2589*35238bceSAndroid Build Coastguard Worker         gl.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferId);
2590*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_DRAW_FRAMEBUFFER");
2591*35238bceSAndroid Build Coastguard Worker 
2592*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, framebufferId, m_type);
2593*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, framebufferId, m_type);
2594*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, framebufferId, m_type);
2595*35238bceSAndroid Build Coastguard Worker 
2596*35238bceSAndroid Build Coastguard Worker         gl.glDeleteFramebuffers(1, &framebufferId);
2597*35238bceSAndroid Build Coastguard Worker         GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteFramebuffers");
2598*35238bceSAndroid Build Coastguard Worker 
2599*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type);
2600*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
2601*35238bceSAndroid Build Coastguard Worker         verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, 0, m_type);
2602*35238bceSAndroid Build Coastguard Worker     }
2603*35238bceSAndroid Build Coastguard Worker };
2604*35238bceSAndroid Build Coastguard Worker 
2605*35238bceSAndroid Build Coastguard Worker class ImplementationColorReadTestCase : public ApiCase
2606*35238bceSAndroid Build Coastguard Worker {
2607*35238bceSAndroid Build Coastguard Worker public:
ImplementationColorReadTestCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2608*35238bceSAndroid Build Coastguard Worker     ImplementationColorReadTestCase(Context &context, StateVerifier *verifier, const char *name,
2609*35238bceSAndroid Build Coastguard Worker                                     const char *description)
2610*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
2611*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
2612*35238bceSAndroid Build Coastguard Worker     {
2613*35238bceSAndroid Build Coastguard Worker     }
2614*35238bceSAndroid Build Coastguard Worker 
test(void)2615*35238bceSAndroid Build Coastguard Worker     void test(void)
2616*35238bceSAndroid Build Coastguard Worker     {
2617*35238bceSAndroid Build Coastguard Worker         const GLint defaultColorTypes[]   = {GL_UNSIGNED_BYTE,
2618*35238bceSAndroid Build Coastguard Worker                                              GL_BYTE,
2619*35238bceSAndroid Build Coastguard Worker                                              GL_UNSIGNED_SHORT,
2620*35238bceSAndroid Build Coastguard Worker                                              GL_SHORT,
2621*35238bceSAndroid Build Coastguard Worker                                              GL_UNSIGNED_INT,
2622*35238bceSAndroid Build Coastguard Worker                                              GL_INT,
2623*35238bceSAndroid Build Coastguard Worker                                              GL_HALF_FLOAT,
2624*35238bceSAndroid Build Coastguard Worker                                              GL_FLOAT,
2625*35238bceSAndroid Build Coastguard Worker                                              GL_UNSIGNED_SHORT_5_6_5,
2626*35238bceSAndroid Build Coastguard Worker                                              GL_UNSIGNED_SHORT_4_4_4_4,
2627*35238bceSAndroid Build Coastguard Worker                                              GL_UNSIGNED_SHORT_5_5_5_1,
2628*35238bceSAndroid Build Coastguard Worker                                              GL_UNSIGNED_INT_2_10_10_10_REV,
2629*35238bceSAndroid Build Coastguard Worker                                              GL_UNSIGNED_INT_10F_11F_11F_REV};
2630*35238bceSAndroid Build Coastguard Worker         const GLint defaultColorFormats[] = {GL_RGBA, GL_RGBA_INTEGER, GL_RGB, GL_RGB_INTEGER,
2631*35238bceSAndroid Build Coastguard Worker                                              GL_RG,   GL_RG_INTEGER,   GL_RED, GL_RED_INTEGER};
2632*35238bceSAndroid Build Coastguard Worker 
2633*35238bceSAndroid Build Coastguard Worker         std::vector<GLint> validColorTypes;
2634*35238bceSAndroid Build Coastguard Worker         std::vector<GLint> validColorFormats;
2635*35238bceSAndroid Build Coastguard Worker 
2636*35238bceSAndroid Build Coastguard Worker         // Defined by the spec
2637*35238bceSAndroid Build Coastguard Worker 
2638*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorTypes); ++ndx)
2639*35238bceSAndroid Build Coastguard Worker             validColorTypes.push_back(defaultColorTypes[ndx]);
2640*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorFormats); ++ndx)
2641*35238bceSAndroid Build Coastguard Worker             validColorFormats.push_back(defaultColorFormats[ndx]);
2642*35238bceSAndroid Build Coastguard Worker 
2643*35238bceSAndroid Build Coastguard Worker         // Extensions
2644*35238bceSAndroid Build Coastguard Worker 
2645*35238bceSAndroid Build Coastguard Worker         if (m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_format_BGRA8888") ||
2646*35238bceSAndroid Build Coastguard Worker             m_context.getContextInfo().isExtensionSupported("GL_APPLE_texture_format_BGRA8888"))
2647*35238bceSAndroid Build Coastguard Worker             validColorFormats.push_back(GL_BGRA);
2648*35238bceSAndroid Build Coastguard Worker 
2649*35238bceSAndroid Build Coastguard Worker         if (m_context.getContextInfo().isExtensionSupported("GL_EXT_read_format_bgra"))
2650*35238bceSAndroid Build Coastguard Worker         {
2651*35238bceSAndroid Build Coastguard Worker             validColorFormats.push_back(GL_BGRA);
2652*35238bceSAndroid Build Coastguard Worker             validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV);
2653*35238bceSAndroid Build Coastguard Worker             validColorTypes.push_back(GL_UNSIGNED_SHORT_1_5_5_5_REV);
2654*35238bceSAndroid Build Coastguard Worker         }
2655*35238bceSAndroid Build Coastguard Worker 
2656*35238bceSAndroid Build Coastguard Worker         if (m_context.getContextInfo().isExtensionSupported("GL_IMG_read_format"))
2657*35238bceSAndroid Build Coastguard Worker         {
2658*35238bceSAndroid Build Coastguard Worker             validColorFormats.push_back(GL_BGRA);
2659*35238bceSAndroid Build Coastguard Worker             validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV);
2660*35238bceSAndroid Build Coastguard Worker         }
2661*35238bceSAndroid Build Coastguard Worker 
2662*35238bceSAndroid Build Coastguard Worker         if (m_context.getContextInfo().isExtensionSupported("GL_NV_sRGB_formats"))
2663*35238bceSAndroid Build Coastguard Worker         {
2664*35238bceSAndroid Build Coastguard Worker             validColorFormats.push_back(GL_SLUMINANCE_NV);
2665*35238bceSAndroid Build Coastguard Worker             validColorFormats.push_back(GL_SLUMINANCE_ALPHA_NV);
2666*35238bceSAndroid Build Coastguard Worker         }
2667*35238bceSAndroid Build Coastguard Worker 
2668*35238bceSAndroid Build Coastguard Worker         if (m_context.getContextInfo().isExtensionSupported("GL_NV_bgr"))
2669*35238bceSAndroid Build Coastguard Worker         {
2670*35238bceSAndroid Build Coastguard Worker             validColorFormats.push_back(GL_BGR_NV);
2671*35238bceSAndroid Build Coastguard Worker         }
2672*35238bceSAndroid Build Coastguard Worker 
2673*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_TYPE, &validColorTypes[0],
2674*35238bceSAndroid Build Coastguard Worker                                        validColorTypes.size());
2675*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &validColorFormats[0],
2676*35238bceSAndroid Build Coastguard Worker                                        validColorFormats.size());
2677*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2678*35238bceSAndroid Build Coastguard Worker     }
2679*35238bceSAndroid Build Coastguard Worker 
2680*35238bceSAndroid Build Coastguard Worker private:
2681*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
2682*35238bceSAndroid Build Coastguard Worker };
2683*35238bceSAndroid Build Coastguard Worker 
2684*35238bceSAndroid Build Coastguard Worker class ReadBufferCase : public ApiCase
2685*35238bceSAndroid Build Coastguard Worker {
2686*35238bceSAndroid Build Coastguard Worker public:
ReadBufferCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2687*35238bceSAndroid Build Coastguard Worker     ReadBufferCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
2688*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
2689*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
2690*35238bceSAndroid Build Coastguard Worker     {
2691*35238bceSAndroid Build Coastguard Worker     }
2692*35238bceSAndroid Build Coastguard Worker 
test(void)2693*35238bceSAndroid Build Coastguard Worker     void test(void)
2694*35238bceSAndroid Build Coastguard Worker     {
2695*35238bceSAndroid Build Coastguard Worker         const bool isGlCore45 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5));
2696*35238bceSAndroid Build Coastguard Worker         const GLenum colorAttachment     = isGlCore45 ? GL_FRONT : GL_BACK;
2697*35238bceSAndroid Build Coastguard Worker         const GLint validInitialValues[] = {(GLint)colorAttachment, GL_BACK, GL_NONE};
2698*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyIntegerAnyOf(m_testCtx, GL_READ_BUFFER, validInitialValues,
2699*35238bceSAndroid Build Coastguard Worker                                        DE_LENGTH_OF_ARRAY(validInitialValues));
2700*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2701*35238bceSAndroid Build Coastguard Worker 
2702*35238bceSAndroid Build Coastguard Worker         glReadBuffer(GL_NONE);
2703*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_NONE);
2704*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2705*35238bceSAndroid Build Coastguard Worker 
2706*35238bceSAndroid Build Coastguard Worker         glReadBuffer(colorAttachment);
2707*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, colorAttachment);
2708*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2709*35238bceSAndroid Build Coastguard Worker 
2710*35238bceSAndroid Build Coastguard Worker         // test GL_READ_BUFFER with framebuffers
2711*35238bceSAndroid Build Coastguard Worker 
2712*35238bceSAndroid Build Coastguard Worker         GLuint framebufferId = 0;
2713*35238bceSAndroid Build Coastguard Worker         glGenFramebuffers(1, &framebufferId);
2714*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2715*35238bceSAndroid Build Coastguard Worker 
2716*35238bceSAndroid Build Coastguard Worker         GLuint renderbuffer_id = 0;
2717*35238bceSAndroid Build Coastguard Worker         glGenRenderbuffers(1, &renderbuffer_id);
2718*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2719*35238bceSAndroid Build Coastguard Worker 
2720*35238bceSAndroid Build Coastguard Worker         glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_id);
2721*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2722*35238bceSAndroid Build Coastguard Worker 
2723*35238bceSAndroid Build Coastguard Worker         glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128);
2724*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2725*35238bceSAndroid Build Coastguard Worker 
2726*35238bceSAndroid Build Coastguard Worker         glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferId);
2727*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2728*35238bceSAndroid Build Coastguard Worker 
2729*35238bceSAndroid Build Coastguard Worker         glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer_id);
2730*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2731*35238bceSAndroid Build Coastguard Worker 
2732*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_COLOR_ATTACHMENT0);
2733*35238bceSAndroid Build Coastguard Worker 
2734*35238bceSAndroid Build Coastguard Worker         glDeleteFramebuffers(1, &framebufferId);
2735*35238bceSAndroid Build Coastguard Worker         glDeleteRenderbuffers(1, &renderbuffer_id);
2736*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2737*35238bceSAndroid Build Coastguard Worker 
2738*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, colorAttachment);
2739*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2740*35238bceSAndroid Build Coastguard Worker     }
2741*35238bceSAndroid Build Coastguard Worker 
2742*35238bceSAndroid Build Coastguard Worker private:
2743*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
2744*35238bceSAndroid Build Coastguard Worker };
2745*35238bceSAndroid Build Coastguard Worker 
2746*35238bceSAndroid Build Coastguard Worker class DrawBufferCase : public ApiCase
2747*35238bceSAndroid Build Coastguard Worker {
2748*35238bceSAndroid Build Coastguard Worker public:
DrawBufferCase(Context & context,StateVerifier * verifier,const char * name,const char * description)2749*35238bceSAndroid Build Coastguard Worker     DrawBufferCase(Context &context, StateVerifier *verifier, const char *name, const char *description)
2750*35238bceSAndroid Build Coastguard Worker         : ApiCase(context, name, description)
2751*35238bceSAndroid Build Coastguard Worker         , m_verifier(verifier)
2752*35238bceSAndroid Build Coastguard Worker     {
2753*35238bceSAndroid Build Coastguard Worker     }
2754*35238bceSAndroid Build Coastguard Worker 
test(void)2755*35238bceSAndroid Build Coastguard Worker     void test(void)
2756*35238bceSAndroid Build Coastguard Worker     {
2757*35238bceSAndroid Build Coastguard Worker         const GLint validInitialValues[] = {GL_FRONT, GL_BACK, GL_NONE};
2758*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyIntegerAnyOf(m_testCtx, GL_DRAW_BUFFER0, validInitialValues,
2759*35238bceSAndroid Build Coastguard Worker                                        DE_LENGTH_OF_ARRAY(validInitialValues));
2760*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2761*35238bceSAndroid Build Coastguard Worker 
2762*35238bceSAndroid Build Coastguard Worker         GLenum bufs = GL_NONE;
2763*35238bceSAndroid Build Coastguard Worker         glDrawBuffers(1, &bufs);
2764*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_NONE);
2765*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2766*35238bceSAndroid Build Coastguard Worker 
2767*35238bceSAndroid Build Coastguard Worker         bufs = GL_BACK;
2768*35238bceSAndroid Build Coastguard Worker         glDrawBuffers(1, &bufs);
2769*35238bceSAndroid Build Coastguard Worker         const GLint validDraw0Values[] = {GL_FRONT_LEFT, GL_BACK};
2770*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyIntegerAnyOf(m_testCtx, GL_DRAW_BUFFER0, validDraw0Values,
2771*35238bceSAndroid Build Coastguard Worker                                        DE_LENGTH_OF_ARRAY(validDraw0Values));
2772*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2773*35238bceSAndroid Build Coastguard Worker 
2774*35238bceSAndroid Build Coastguard Worker         // test GL_DRAW_BUFFER with framebuffers
2775*35238bceSAndroid Build Coastguard Worker 
2776*35238bceSAndroid Build Coastguard Worker         GLuint framebufferId = 0;
2777*35238bceSAndroid Build Coastguard Worker         glGenFramebuffers(1, &framebufferId);
2778*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2779*35238bceSAndroid Build Coastguard Worker 
2780*35238bceSAndroid Build Coastguard Worker         GLuint renderbuffer_ids[2] = {0};
2781*35238bceSAndroid Build Coastguard Worker         glGenRenderbuffers(2, renderbuffer_ids);
2782*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2783*35238bceSAndroid Build Coastguard Worker 
2784*35238bceSAndroid Build Coastguard Worker         glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_ids[0]);
2785*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2786*35238bceSAndroid Build Coastguard Worker         glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128);
2787*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2788*35238bceSAndroid Build Coastguard Worker 
2789*35238bceSAndroid Build Coastguard Worker         glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_ids[1]);
2790*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2791*35238bceSAndroid Build Coastguard Worker         glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128);
2792*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2793*35238bceSAndroid Build Coastguard Worker 
2794*35238bceSAndroid Build Coastguard Worker         glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferId);
2795*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2796*35238bceSAndroid Build Coastguard Worker 
2797*35238bceSAndroid Build Coastguard Worker         glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer_ids[0]);
2798*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2799*35238bceSAndroid Build Coastguard Worker         glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, renderbuffer_ids[1]);
2800*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2801*35238bceSAndroid Build Coastguard Worker 
2802*35238bceSAndroid Build Coastguard Worker         // only the initial state the draw buffer for fragment color zero is defined
2803*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_COLOR_ATTACHMENT0);
2804*35238bceSAndroid Build Coastguard Worker 
2805*35238bceSAndroid Build Coastguard Worker         GLenum bufTargets[2] = {GL_NONE, GL_COLOR_ATTACHMENT1};
2806*35238bceSAndroid Build Coastguard Worker         glDrawBuffers(2, bufTargets);
2807*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_NONE);
2808*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER1, GL_COLOR_ATTACHMENT1);
2809*35238bceSAndroid Build Coastguard Worker 
2810*35238bceSAndroid Build Coastguard Worker         glDeleteFramebuffers(1, &framebufferId);
2811*35238bceSAndroid Build Coastguard Worker         glDeleteRenderbuffers(2, renderbuffer_ids);
2812*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2813*35238bceSAndroid Build Coastguard Worker 
2814*35238bceSAndroid Build Coastguard Worker         m_verifier->verifyIntegerAnyOf(m_testCtx, GL_DRAW_BUFFER0, validDraw0Values,
2815*35238bceSAndroid Build Coastguard Worker                                        DE_LENGTH_OF_ARRAY(validDraw0Values));
2816*35238bceSAndroid Build Coastguard Worker         expectError(GL_NO_ERROR);
2817*35238bceSAndroid Build Coastguard Worker     }
2818*35238bceSAndroid Build Coastguard Worker 
2819*35238bceSAndroid Build Coastguard Worker private:
2820*35238bceSAndroid Build Coastguard Worker     StateVerifier *m_verifier;
2821*35238bceSAndroid Build Coastguard Worker };
2822*35238bceSAndroid Build Coastguard Worker 
getQueryTypeSuffix(QueryType type)2823*35238bceSAndroid Build Coastguard Worker static const char *getQueryTypeSuffix(QueryType type)
2824*35238bceSAndroid Build Coastguard Worker {
2825*35238bceSAndroid Build Coastguard Worker     switch (type)
2826*35238bceSAndroid Build Coastguard Worker     {
2827*35238bceSAndroid Build Coastguard Worker     case QUERY_BOOLEAN:
2828*35238bceSAndroid Build Coastguard Worker         return "_getboolean";
2829*35238bceSAndroid Build Coastguard Worker     case QUERY_INTEGER:
2830*35238bceSAndroid Build Coastguard Worker         return "_getinteger";
2831*35238bceSAndroid Build Coastguard Worker     case QUERY_INTEGER64:
2832*35238bceSAndroid Build Coastguard Worker         return "_getinteger64";
2833*35238bceSAndroid Build Coastguard Worker     case QUERY_FLOAT:
2834*35238bceSAndroid Build Coastguard Worker         return "_getfloat";
2835*35238bceSAndroid Build Coastguard Worker     default:
2836*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(false);
2837*35238bceSAndroid Build Coastguard Worker         return DE_NULL;
2838*35238bceSAndroid Build Coastguard Worker     }
2839*35238bceSAndroid Build Coastguard Worker }
2840*35238bceSAndroid Build Coastguard Worker 
2841*35238bceSAndroid Build Coastguard Worker #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK)                                                 \
2842*35238bceSAndroid Build Coastguard Worker     do                                                                                           \
2843*35238bceSAndroid Build Coastguard Worker     {                                                                                            \
2844*35238bceSAndroid Build Coastguard Worker         for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++) \
2845*35238bceSAndroid Build Coastguard Worker         {                                                                                        \
2846*35238bceSAndroid Build Coastguard Worker             StateVerifier *verifier = (VERIFIERS)[_verifierNdx];                                 \
2847*35238bceSAndroid Build Coastguard Worker             CODE_BLOCK;                                                                          \
2848*35238bceSAndroid Build Coastguard Worker         }                                                                                        \
2849*35238bceSAndroid Build Coastguard Worker     } while (0)
2850*35238bceSAndroid Build Coastguard Worker 
2851*35238bceSAndroid Build Coastguard Worker #define FOR_EACH_QUERYTYPE(QUERYTYPES, CODE_BLOCK)                                                   \
2852*35238bceSAndroid Build Coastguard Worker     do                                                                                               \
2853*35238bceSAndroid Build Coastguard Worker     {                                                                                                \
2854*35238bceSAndroid Build Coastguard Worker         for (int _queryTypeNdx = 0; _queryTypeNdx < DE_LENGTH_OF_ARRAY(QUERYTYPES); _queryTypeNdx++) \
2855*35238bceSAndroid Build Coastguard Worker         {                                                                                            \
2856*35238bceSAndroid Build Coastguard Worker             const QueryType queryType = (QUERYTYPES)[_queryTypeNdx];                                 \
2857*35238bceSAndroid Build Coastguard Worker             CODE_BLOCK;                                                                              \
2858*35238bceSAndroid Build Coastguard Worker         }                                                                                            \
2859*35238bceSAndroid Build Coastguard Worker     } while (0)
2860*35238bceSAndroid Build Coastguard Worker 
2861*35238bceSAndroid Build Coastguard Worker } // namespace
2862*35238bceSAndroid Build Coastguard Worker 
IntegerStateQueryTests(Context & context)2863*35238bceSAndroid Build Coastguard Worker IntegerStateQueryTests::IntegerStateQueryTests(Context &context)
2864*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(context, "integers", "Integer Values")
2865*35238bceSAndroid Build Coastguard Worker     , m_verifierBoolean(DE_NULL)
2866*35238bceSAndroid Build Coastguard Worker     , m_verifierInteger(DE_NULL)
2867*35238bceSAndroid Build Coastguard Worker     , m_verifierInteger64(DE_NULL)
2868*35238bceSAndroid Build Coastguard Worker     , m_verifierFloat(DE_NULL)
2869*35238bceSAndroid Build Coastguard Worker {
2870*35238bceSAndroid Build Coastguard Worker }
2871*35238bceSAndroid Build Coastguard Worker 
~IntegerStateQueryTests(void)2872*35238bceSAndroid Build Coastguard Worker IntegerStateQueryTests::~IntegerStateQueryTests(void)
2873*35238bceSAndroid Build Coastguard Worker {
2874*35238bceSAndroid Build Coastguard Worker     deinit();
2875*35238bceSAndroid Build Coastguard Worker }
2876*35238bceSAndroid Build Coastguard Worker 
init(void)2877*35238bceSAndroid Build Coastguard Worker void IntegerStateQueryTests::init(void)
2878*35238bceSAndroid Build Coastguard Worker {
2879*35238bceSAndroid Build Coastguard Worker     static const QueryType queryTypes[] = {
2880*35238bceSAndroid Build Coastguard Worker         QUERY_BOOLEAN,
2881*35238bceSAndroid Build Coastguard Worker         QUERY_INTEGER,
2882*35238bceSAndroid Build Coastguard Worker         QUERY_INTEGER64,
2883*35238bceSAndroid Build Coastguard Worker         QUERY_FLOAT,
2884*35238bceSAndroid Build Coastguard Worker     };
2885*35238bceSAndroid Build Coastguard Worker 
2886*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_verifierBoolean == DE_NULL);
2887*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_verifierInteger == DE_NULL);
2888*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_verifierInteger64 == DE_NULL);
2889*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_verifierFloat == DE_NULL);
2890*35238bceSAndroid Build Coastguard Worker 
2891*35238bceSAndroid Build Coastguard Worker     m_verifierBoolean =
2892*35238bceSAndroid Build Coastguard Worker         new GetBooleanVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2893*35238bceSAndroid Build Coastguard Worker     m_verifierInteger =
2894*35238bceSAndroid Build Coastguard Worker         new GetIntegerVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2895*35238bceSAndroid Build Coastguard Worker     m_verifierInteger64 =
2896*35238bceSAndroid Build Coastguard Worker         new GetInteger64Verifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2897*35238bceSAndroid Build Coastguard Worker     m_verifierFloat =
2898*35238bceSAndroid Build Coastguard Worker         new GetFloatVerifier(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2899*35238bceSAndroid Build Coastguard Worker 
2900*35238bceSAndroid Build Coastguard Worker     const struct LimitedStateInteger
2901*35238bceSAndroid Build Coastguard Worker     {
2902*35238bceSAndroid Build Coastguard Worker         const char *name;
2903*35238bceSAndroid Build Coastguard Worker         const char *description;
2904*35238bceSAndroid Build Coastguard Worker         GLenum targetName;
2905*35238bceSAndroid Build Coastguard Worker         GLint value;
2906*35238bceSAndroid Build Coastguard Worker         bool skipForGl;
2907*35238bceSAndroid Build Coastguard Worker     } implementationMinLimits[] = {
2908*35238bceSAndroid Build Coastguard Worker         {"subpixel_bits", "SUBPIXEL_BITS has minimum value of 4", GL_SUBPIXEL_BITS, 4, false},
2909*35238bceSAndroid Build Coastguard Worker         {"max_3d_texture_size", "MAX_3D_TEXTURE_SIZE has minimum value of 256", GL_MAX_3D_TEXTURE_SIZE, 256, false},
2910*35238bceSAndroid Build Coastguard Worker         {"max_texture_size", "MAX_TEXTURE_SIZE has minimum value of 2048", GL_MAX_TEXTURE_SIZE, 2048, false},
2911*35238bceSAndroid Build Coastguard Worker         {"max_array_texture_layers", "MAX_ARRAY_TEXTURE_LAYERS has minimum value of 256", GL_MAX_ARRAY_TEXTURE_LAYERS,
2912*35238bceSAndroid Build Coastguard Worker          256, false},
2913*35238bceSAndroid Build Coastguard Worker         {"max_cube_map_texture_size", "MAX_CUBE_MAP_TEXTURE_SIZE has minimum value of 2048",
2914*35238bceSAndroid Build Coastguard Worker          GL_MAX_CUBE_MAP_TEXTURE_SIZE, 2048, false},
2915*35238bceSAndroid Build Coastguard Worker         {"max_renderbuffer_size", "MAX_RENDERBUFFER_SIZE has minimum value of 2048", GL_MAX_RENDERBUFFER_SIZE, 2048,
2916*35238bceSAndroid Build Coastguard Worker          false},
2917*35238bceSAndroid Build Coastguard Worker         {"max_draw_buffers", "MAX_DRAW_BUFFERS has minimum value of 4", GL_MAX_DRAW_BUFFERS, 4, false},
2918*35238bceSAndroid Build Coastguard Worker         {"max_color_attachments", "MAX_COLOR_ATTACHMENTS has minimum value of 4", GL_MAX_COLOR_ATTACHMENTS, 4, false},
2919*35238bceSAndroid Build Coastguard Worker         {"max_elements_indices", "MAX_ELEMENTS_INDICES has minimum value of 0", GL_MAX_ELEMENTS_INDICES, 0, false},
2920*35238bceSAndroid Build Coastguard Worker         {"max_elements_vertices", "MAX_ELEMENTS_VERTICES has minimum value of 0", GL_MAX_ELEMENTS_VERTICES, 0, false},
2921*35238bceSAndroid Build Coastguard Worker         {"num_extensions", "NUM_EXTENSIONS has minimum value of 0", GL_NUM_EXTENSIONS, 0, false},
2922*35238bceSAndroid Build Coastguard Worker         {"major_version", "MAJOR_VERSION has minimum value of 3", GL_MAJOR_VERSION, 3, false},
2923*35238bceSAndroid Build Coastguard Worker         {"minor_version", "MINOR_VERSION has minimum value of 0", GL_MINOR_VERSION, 0, false},
2924*35238bceSAndroid Build Coastguard Worker         {"max_vertex_attribs", "MAX_VERTEX_ATTRIBS has minimum value of 16", GL_MAX_VERTEX_ATTRIBS, 16, false},
2925*35238bceSAndroid Build Coastguard Worker         {"max_vertex_uniform_components", "MAX_VERTEX_UNIFORM_COMPONENTS has minimum value of 1024",
2926*35238bceSAndroid Build Coastguard Worker          GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1024, false},
2927*35238bceSAndroid Build Coastguard Worker         {"max_vertex_uniform_vectors", "MAX_VERTEX_UNIFORM_VECTORS has minimum value of 256",
2928*35238bceSAndroid Build Coastguard Worker          GL_MAX_VERTEX_UNIFORM_VECTORS, 256, false},
2929*35238bceSAndroid Build Coastguard Worker         {"max_vertex_uniform_blocks", "MAX_VERTEX_UNIFORM_BLOCKS has minimum value of 12", GL_MAX_VERTEX_UNIFORM_BLOCKS,
2930*35238bceSAndroid Build Coastguard Worker          12, false},
2931*35238bceSAndroid Build Coastguard Worker         {"max_vertex_output_components", "MAX_VERTEX_OUTPUT_COMPONENTS has minimum value of 64",
2932*35238bceSAndroid Build Coastguard Worker          GL_MAX_VERTEX_OUTPUT_COMPONENTS, 64, false},
2933*35238bceSAndroid Build Coastguard Worker         {"max_vertex_texture_image_units", "MAX_VERTEX_TEXTURE_IMAGE_UNITS has minimum value of 16",
2934*35238bceSAndroid Build Coastguard Worker          GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 16, false},
2935*35238bceSAndroid Build Coastguard Worker         {"max_fragment_uniform_components", "MAX_FRAGMENT_UNIFORM_COMPONENTS has minimum value of 896",
2936*35238bceSAndroid Build Coastguard Worker          GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 896, false},
2937*35238bceSAndroid Build Coastguard Worker         {"max_fragment_uniform_vectors", "MAX_FRAGMENT_UNIFORM_VECTORS has minimum value of 224",
2938*35238bceSAndroid Build Coastguard Worker          GL_MAX_FRAGMENT_UNIFORM_VECTORS, 224, false},
2939*35238bceSAndroid Build Coastguard Worker         {"max_fragment_uniform_blocks", "MAX_FRAGMENT_UNIFORM_BLOCKS has minimum value of 12",
2940*35238bceSAndroid Build Coastguard Worker          GL_MAX_FRAGMENT_UNIFORM_BLOCKS, 12, false},
2941*35238bceSAndroid Build Coastguard Worker         {"max_fragment_input_components", "MAX_FRAGMENT_INPUT_COMPONENTS has minimum value of 60",
2942*35238bceSAndroid Build Coastguard Worker          GL_MAX_FRAGMENT_INPUT_COMPONENTS, 60, false},
2943*35238bceSAndroid Build Coastguard Worker         {"max_texture_image_units", "MAX_TEXTURE_IMAGE_UNITS has minimum value of 16", GL_MAX_TEXTURE_IMAGE_UNITS, 16,
2944*35238bceSAndroid Build Coastguard Worker          false},
2945*35238bceSAndroid Build Coastguard Worker         {"max_program_texel_offset", "MAX_PROGRAM_TEXEL_OFFSET has minimum value of 7", GL_MAX_PROGRAM_TEXEL_OFFSET, 7,
2946*35238bceSAndroid Build Coastguard Worker          false},
2947*35238bceSAndroid Build Coastguard Worker         {"max_uniform_buffer_bindings", "MAX_UNIFORM_BUFFER_BINDINGS has minimum value of 24",
2948*35238bceSAndroid Build Coastguard Worker          GL_MAX_UNIFORM_BUFFER_BINDINGS, 24, false},
2949*35238bceSAndroid Build Coastguard Worker         {"max_combined_uniform_blocks", "MAX_COMBINED_UNIFORM_BLOCKS has minimum value of 24",
2950*35238bceSAndroid Build Coastguard Worker          GL_MAX_COMBINED_UNIFORM_BLOCKS, 24, false},
2951*35238bceSAndroid Build Coastguard Worker         {"max_varying_components", "MAX_VARYING_COMPONENTS has minimum value of 60", GL_MAX_VARYING_COMPONENTS, 60,
2952*35238bceSAndroid Build Coastguard Worker          false},
2953*35238bceSAndroid Build Coastguard Worker         {"max_varying_vectors", "MAX_VARYING_VECTORS has minimum value of 15", GL_MAX_VARYING_VECTORS, 15, false},
2954*35238bceSAndroid Build Coastguard Worker         {"max_combined_texture_image_units", "MAX_COMBINED_TEXTURE_IMAGE_UNITS has minimum value of 32",
2955*35238bceSAndroid Build Coastguard Worker          GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 32, false},
2956*35238bceSAndroid Build Coastguard Worker         {"max_transform_feedback_interleaved_components",
2957*35238bceSAndroid Build Coastguard Worker          "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS has minimum value of 64",
2958*35238bceSAndroid Build Coastguard Worker          GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, 64, false},
2959*35238bceSAndroid Build Coastguard Worker         {"max_transform_feedback_separate_attribs", "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS has minimum value of 4",
2960*35238bceSAndroid Build Coastguard Worker          GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, 4, false},
2961*35238bceSAndroid Build Coastguard Worker         {"max_transform_feedback_separate_components",
2962*35238bceSAndroid Build Coastguard Worker          "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS has minimum value of 4",
2963*35238bceSAndroid Build Coastguard Worker          GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, 4, false},
2964*35238bceSAndroid Build Coastguard Worker         {"max_samples", "MAX_SAMPLES has minimum value of 4", GL_MAX_SAMPLES, 4, false},
2965*35238bceSAndroid Build Coastguard Worker         {"red_bits", "RED_BITS has minimum value of 0", GL_RED_BITS, 0, true},
2966*35238bceSAndroid Build Coastguard Worker         {"green_bits", "GREEN_BITS has minimum value of 0", GL_GREEN_BITS, 0, true},
2967*35238bceSAndroid Build Coastguard Worker         {"blue_bits", "BLUE_BITS has minimum value of 0", GL_BLUE_BITS, 0, true},
2968*35238bceSAndroid Build Coastguard Worker         {"alpha_bits", "ALPHA_BITS has minimum value of 0", GL_ALPHA_BITS, 0, true},
2969*35238bceSAndroid Build Coastguard Worker         {"depth_bits", "DEPTH_BITS has minimum value of 0", GL_DEPTH_BITS, 0, true},
2970*35238bceSAndroid Build Coastguard Worker         {"stencil_bits", "STENCIL_BITS has minimum value of 0", GL_STENCIL_BITS, 0, true},
2971*35238bceSAndroid Build Coastguard Worker     };
2972*35238bceSAndroid Build Coastguard Worker     const LimitedStateInteger implementationMaxLimits[] = {
2973*35238bceSAndroid Build Coastguard Worker         {"min_program_texel_offset", "MIN_PROGRAM_TEXEL_OFFSET has maximum value of -8", GL_MIN_PROGRAM_TEXEL_OFFSET,
2974*35238bceSAndroid Build Coastguard Worker          -8, false},
2975*35238bceSAndroid Build Coastguard Worker         {"uniform_buffer_offset_alignment", "UNIFORM_BUFFER_OFFSET_ALIGNMENT has minimum value of 1",
2976*35238bceSAndroid Build Coastguard Worker          GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, 256, false},
2977*35238bceSAndroid Build Coastguard Worker     };
2978*35238bceSAndroid Build Coastguard Worker 
2979*35238bceSAndroid Build Coastguard Worker     // \note implementation defined limits have their own tests so just check the conversions to boolean, int64 and float
2980*35238bceSAndroid Build Coastguard Worker     StateVerifier *implementationLimitVerifiers[] = {m_verifierBoolean, m_verifierInteger64, m_verifierFloat};
2981*35238bceSAndroid Build Coastguard Worker 
2982*35238bceSAndroid Build Coastguard Worker     const bool isGlCore45 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5));
2983*35238bceSAndroid Build Coastguard Worker     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMinLimits); testNdx++)
2984*35238bceSAndroid Build Coastguard Worker     {
2985*35238bceSAndroid Build Coastguard Worker         if (implementationMinLimits[testNdx].skipForGl && isGlCore45)
2986*35238bceSAndroid Build Coastguard Worker             continue;
2987*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
2988*35238bceSAndroid Build Coastguard Worker             implementationLimitVerifiers,
2989*35238bceSAndroid Build Coastguard Worker             addChild(new ConstantMinimumValueTestCase(
2990*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
2991*35238bceSAndroid Build Coastguard Worker                 (std::string(implementationMinLimits[testNdx].name) + verifier->getTestNamePostfix()).c_str(),
2992*35238bceSAndroid Build Coastguard Worker                 implementationMinLimits[testNdx].description, implementationMinLimits[testNdx].targetName,
2993*35238bceSAndroid Build Coastguard Worker                 implementationMinLimits[testNdx].value)));
2994*35238bceSAndroid Build Coastguard Worker     }
2995*35238bceSAndroid Build Coastguard Worker     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMaxLimits); testNdx++)
2996*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
2997*35238bceSAndroid Build Coastguard Worker             implementationLimitVerifiers,
2998*35238bceSAndroid Build Coastguard Worker             addChild(new ConstantMaximumValueTestCase(
2999*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
3000*35238bceSAndroid Build Coastguard Worker                 (std::string(implementationMaxLimits[testNdx].name) + verifier->getTestNamePostfix()).c_str(),
3001*35238bceSAndroid Build Coastguard Worker                 implementationMaxLimits[testNdx].description, implementationMaxLimits[testNdx].targetName,
3002*35238bceSAndroid Build Coastguard Worker                 implementationMaxLimits[testNdx].value)));
3003*35238bceSAndroid Build Coastguard Worker 
3004*35238bceSAndroid Build Coastguard Worker     StateVerifier *normalVerifiers[] = {m_verifierBoolean, m_verifierInteger, m_verifierInteger64, m_verifierFloat};
3005*35238bceSAndroid Build Coastguard Worker 
3006*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(implementationLimitVerifiers,
3007*35238bceSAndroid Build Coastguard Worker                       addChild(new SampleBuffersTestCase(
3008*35238bceSAndroid Build Coastguard Worker                           m_context, verifier, (std::string("sample_buffers") + verifier->getTestNamePostfix()).c_str(),
3009*35238bceSAndroid Build Coastguard Worker                           "SAMPLE_BUFFERS")));
3010*35238bceSAndroid Build Coastguard Worker 
3011*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3012*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3013*35238bceSAndroid Build Coastguard Worker         addChild(new SamplesTestCase(m_context, verifier,
3014*35238bceSAndroid Build Coastguard Worker                                      (std::string("samples") + verifier->getTestNamePostfix()).c_str(), "SAMPLES")));
3015*35238bceSAndroid Build Coastguard Worker     if (!isGlCore45)
3016*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
3017*35238bceSAndroid Build Coastguard Worker             normalVerifiers,
3018*35238bceSAndroid Build Coastguard Worker             addChild(new HintTestCase(m_context, verifier,
3019*35238bceSAndroid Build Coastguard Worker                                       (std::string("generate_mipmap_hint") + verifier->getTestNamePostfix()).c_str(),
3020*35238bceSAndroid Build Coastguard Worker                                       "GENERATE_MIPMAP_HINT", GL_GENERATE_MIPMAP_HINT)));
3021*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3022*35238bceSAndroid Build Coastguard Worker                       addChild(new HintTestCase(
3023*35238bceSAndroid Build Coastguard Worker                           m_context, verifier,
3024*35238bceSAndroid Build Coastguard Worker                           (std::string("fragment_shader_derivative_hint") + verifier->getTestNamePostfix()).c_str(),
3025*35238bceSAndroid Build Coastguard Worker                           "FRAGMENT_SHADER_DERIVATIVE_HINT", GL_FRAGMENT_SHADER_DERIVATIVE_HINT)));
3026*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3027*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3028*35238bceSAndroid Build Coastguard Worker         addChild(new DepthFuncTestCase(
3029*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("depth_func") + verifier->getTestNamePostfix()).c_str(), "DEPTH_FUNC")));
3030*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3031*35238bceSAndroid Build Coastguard Worker                       addChild(new CullFaceTestCase(
3032*35238bceSAndroid Build Coastguard Worker                           m_context, verifier, (std::string("cull_face_mode") + verifier->getTestNamePostfix()).c_str(),
3033*35238bceSAndroid Build Coastguard Worker                           "CULL_FACE_MODE")));
3034*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3035*35238bceSAndroid Build Coastguard Worker                       addChild(new FrontFaceTestCase(
3036*35238bceSAndroid Build Coastguard Worker                           m_context, verifier,
3037*35238bceSAndroid Build Coastguard Worker                           (std::string("front_face_mode") + verifier->getTestNamePostfix()).c_str(), "FRONT_FACE")));
3038*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3039*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3040*35238bceSAndroid Build Coastguard Worker         addChild(new ViewPortTestCase(m_context, verifier,
3041*35238bceSAndroid Build Coastguard Worker                                       (std::string("viewport") + verifier->getTestNamePostfix()).c_str(), "VIEWPORT")));
3042*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3043*35238bceSAndroid Build Coastguard Worker                       addChild(new ScissorBoxTestCase(
3044*35238bceSAndroid Build Coastguard Worker                           m_context, verifier, (std::string("scissor_box") + verifier->getTestNamePostfix()).c_str(),
3045*35238bceSAndroid Build Coastguard Worker                           "SCISSOR_BOX")));
3046*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers, addChild(new MaxViewportDimsTestCase(
3047*35238bceSAndroid Build Coastguard Worker                                            m_context, verifier,
3048*35238bceSAndroid Build Coastguard Worker                                            (std::string("max_viewport_dims") + verifier->getTestNamePostfix()).c_str(),
3049*35238bceSAndroid Build Coastguard Worker                                            "MAX_VIEWPORT_DIMS")));
3050*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3051*35238bceSAndroid Build Coastguard Worker                       addChild(new StencilRefTestCase(
3052*35238bceSAndroid Build Coastguard Worker                           m_context, verifier, (std::string("stencil_ref") + verifier->getTestNamePostfix()).c_str(),
3053*35238bceSAndroid Build Coastguard Worker                           "STENCIL_REF", GL_STENCIL_REF)));
3054*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefTestCase(
3055*35238bceSAndroid Build Coastguard Worker                                            m_context, verifier,
3056*35238bceSAndroid Build Coastguard Worker                                            (std::string("stencil_back_ref") + verifier->getTestNamePostfix()).c_str(),
3057*35238bceSAndroid Build Coastguard Worker                                            "STENCIL_BACK_REF", GL_STENCIL_BACK_REF)));
3058*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3059*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3060*35238bceSAndroid Build Coastguard Worker         addChild(new StencilRefSeparateTestCase(
3061*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_ref_separate") + verifier->getTestNamePostfix()).c_str(),
3062*35238bceSAndroid Build Coastguard Worker             "STENCIL_REF (separate)", GL_STENCIL_REF, GL_FRONT)));
3063*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3064*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3065*35238bceSAndroid Build Coastguard Worker         addChild(new StencilRefSeparateTestCase(
3066*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_ref_separate_both") + verifier->getTestNamePostfix()).c_str(),
3067*35238bceSAndroid Build Coastguard Worker             "STENCIL_REF (separate)", GL_STENCIL_REF, GL_FRONT_AND_BACK)));
3068*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3069*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3070*35238bceSAndroid Build Coastguard Worker         addChild(new StencilRefSeparateTestCase(
3071*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_back_ref_separate") + verifier->getTestNamePostfix()).c_str(),
3072*35238bceSAndroid Build Coastguard Worker             "STENCIL_BACK_REF (separate)", GL_STENCIL_BACK_REF, GL_BACK)));
3073*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3074*35238bceSAndroid Build Coastguard Worker                       addChild(new StencilRefSeparateTestCase(
3075*35238bceSAndroid Build Coastguard Worker                           m_context, verifier,
3076*35238bceSAndroid Build Coastguard Worker                           (std::string("stencil_back_ref_separate_both") + verifier->getTestNamePostfix()).c_str(),
3077*35238bceSAndroid Build Coastguard Worker                           "STENCIL_BACK_REF (separate)", GL_STENCIL_BACK_REF, GL_FRONT_AND_BACK)));
3078*35238bceSAndroid Build Coastguard Worker 
3079*35238bceSAndroid Build Coastguard Worker     const struct NamedStencilOp
3080*35238bceSAndroid Build Coastguard Worker     {
3081*35238bceSAndroid Build Coastguard Worker         const char *name;
3082*35238bceSAndroid Build Coastguard Worker 
3083*35238bceSAndroid Build Coastguard Worker         const char *frontDescription;
3084*35238bceSAndroid Build Coastguard Worker         GLenum frontTarget;
3085*35238bceSAndroid Build Coastguard Worker         const char *backDescription;
3086*35238bceSAndroid Build Coastguard Worker         GLenum backTarget;
3087*35238bceSAndroid Build Coastguard Worker     } stencilOps[] = {{"fail", "STENCIL_FAIL", GL_STENCIL_FAIL, "STENCIL_BACK_FAIL", GL_STENCIL_BACK_FAIL},
3088*35238bceSAndroid Build Coastguard Worker                       {"depth_fail", "STENCIL_PASS_DEPTH_FAIL", GL_STENCIL_PASS_DEPTH_FAIL,
3089*35238bceSAndroid Build Coastguard Worker                        "STENCIL_BACK_PASS_DEPTH_FAIL", GL_STENCIL_BACK_PASS_DEPTH_FAIL},
3090*35238bceSAndroid Build Coastguard Worker                       {"depth_pass", "STENCIL_PASS_DEPTH_PASS", GL_STENCIL_PASS_DEPTH_PASS,
3091*35238bceSAndroid Build Coastguard Worker                        "STENCIL_BACK_PASS_DEPTH_PASS", GL_STENCIL_BACK_PASS_DEPTH_PASS}};
3092*35238bceSAndroid Build Coastguard Worker 
3093*35238bceSAndroid Build Coastguard Worker     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(stencilOps); testNdx++)
3094*35238bceSAndroid Build Coastguard Worker     {
3095*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
3096*35238bceSAndroid Build Coastguard Worker             normalVerifiers,
3097*35238bceSAndroid Build Coastguard Worker             addChild(new StencilOpTestCase(
3098*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
3099*35238bceSAndroid Build Coastguard Worker                 (std::string("stencil_") + stencilOps[testNdx].name + verifier->getTestNamePostfix()).c_str(),
3100*35238bceSAndroid Build Coastguard Worker                 stencilOps[testNdx].frontDescription, stencilOps[testNdx].frontTarget)));
3101*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
3102*35238bceSAndroid Build Coastguard Worker             normalVerifiers,
3103*35238bceSAndroid Build Coastguard Worker             addChild(new StencilOpTestCase(
3104*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
3105*35238bceSAndroid Build Coastguard Worker                 (std::string("stencil_back_") + stencilOps[testNdx].name + verifier->getTestNamePostfix()).c_str(),
3106*35238bceSAndroid Build Coastguard Worker                 stencilOps[testNdx].backDescription, stencilOps[testNdx].backTarget)));
3107*35238bceSAndroid Build Coastguard Worker 
3108*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
3109*35238bceSAndroid Build Coastguard Worker             normalVerifiers,
3110*35238bceSAndroid Build Coastguard Worker             addChild(new StencilOpSeparateTestCase(
3111*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
3112*35238bceSAndroid Build Coastguard Worker                 (std::string("stencil_") + stencilOps[testNdx].name + "_separate_both" + verifier->getTestNamePostfix())
3113*35238bceSAndroid Build Coastguard Worker                     .c_str(),
3114*35238bceSAndroid Build Coastguard Worker                 stencilOps[testNdx].frontDescription, stencilOps[testNdx].frontTarget, GL_FRONT_AND_BACK)));
3115*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(normalVerifiers,
3116*35238bceSAndroid Build Coastguard Worker                           addChild(new StencilOpSeparateTestCase(
3117*35238bceSAndroid Build Coastguard Worker                               m_context, verifier,
3118*35238bceSAndroid Build Coastguard Worker                               (std::string("stencil_back_") + stencilOps[testNdx].name + "_separate_both" +
3119*35238bceSAndroid Build Coastguard Worker                                verifier->getTestNamePostfix())
3120*35238bceSAndroid Build Coastguard Worker                                   .c_str(),
3121*35238bceSAndroid Build Coastguard Worker                               stencilOps[testNdx].backDescription, stencilOps[testNdx].backTarget, GL_FRONT_AND_BACK)));
3122*35238bceSAndroid Build Coastguard Worker 
3123*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
3124*35238bceSAndroid Build Coastguard Worker             normalVerifiers,
3125*35238bceSAndroid Build Coastguard Worker             addChild(new StencilOpSeparateTestCase(
3126*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
3127*35238bceSAndroid Build Coastguard Worker                 (std::string("stencil_") + stencilOps[testNdx].name + "_separate" + verifier->getTestNamePostfix())
3128*35238bceSAndroid Build Coastguard Worker                     .c_str(),
3129*35238bceSAndroid Build Coastguard Worker                 stencilOps[testNdx].frontDescription, stencilOps[testNdx].frontTarget, GL_FRONT)));
3130*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
3131*35238bceSAndroid Build Coastguard Worker             normalVerifiers,
3132*35238bceSAndroid Build Coastguard Worker             addChild(new StencilOpSeparateTestCase(
3133*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
3134*35238bceSAndroid Build Coastguard Worker                 (std::string("stencil_back_") + stencilOps[testNdx].name + "_separate" + verifier->getTestNamePostfix())
3135*35238bceSAndroid Build Coastguard Worker                     .c_str(),
3136*35238bceSAndroid Build Coastguard Worker                 stencilOps[testNdx].backDescription, stencilOps[testNdx].backTarget, GL_BACK)));
3137*35238bceSAndroid Build Coastguard Worker     }
3138*35238bceSAndroid Build Coastguard Worker 
3139*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3140*35238bceSAndroid Build Coastguard Worker                       addChild(new StencilFuncTestCase(
3141*35238bceSAndroid Build Coastguard Worker                           m_context, verifier, (std::string("stencil_func") + verifier->getTestNamePostfix()).c_str(),
3142*35238bceSAndroid Build Coastguard Worker                           "STENCIL_FUNC")));
3143*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3144*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3145*35238bceSAndroid Build Coastguard Worker         addChild(new StencilFuncSeparateTestCase(
3146*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_func_separate") + verifier->getTestNamePostfix()).c_str(),
3147*35238bceSAndroid Build Coastguard Worker             "STENCIL_FUNC (separate)", GL_STENCIL_FUNC, GL_FRONT)));
3148*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3149*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3150*35238bceSAndroid Build Coastguard Worker         addChild(new StencilFuncSeparateTestCase(
3151*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_func_separate_both") + verifier->getTestNamePostfix()).c_str(),
3152*35238bceSAndroid Build Coastguard Worker             "STENCIL_FUNC (separate)", GL_STENCIL_FUNC, GL_FRONT_AND_BACK)));
3153*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3154*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3155*35238bceSAndroid Build Coastguard Worker         addChild(new StencilFuncSeparateTestCase(
3156*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_back_func_separate") + verifier->getTestNamePostfix()).c_str(),
3157*35238bceSAndroid Build Coastguard Worker             "STENCIL_FUNC (separate)", GL_STENCIL_BACK_FUNC, GL_BACK)));
3158*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3159*35238bceSAndroid Build Coastguard Worker                       addChild(new StencilFuncSeparateTestCase(
3160*35238bceSAndroid Build Coastguard Worker                           m_context, verifier,
3161*35238bceSAndroid Build Coastguard Worker                           (std::string("stencil_back_func_separate_both") + verifier->getTestNamePostfix()).c_str(),
3162*35238bceSAndroid Build Coastguard Worker                           "STENCIL_FUNC (separate)", GL_STENCIL_BACK_FUNC, GL_FRONT_AND_BACK)));
3163*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskTestCase(
3164*35238bceSAndroid Build Coastguard Worker                                            m_context, verifier,
3165*35238bceSAndroid Build Coastguard Worker                                            (std::string("stencil_value_mask") + verifier->getTestNamePostfix()).c_str(),
3166*35238bceSAndroid Build Coastguard Worker                                            "STENCIL_VALUE_MASK", GL_STENCIL_VALUE_MASK)));
3167*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3168*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3169*35238bceSAndroid Build Coastguard Worker         addChild(new StencilMaskTestCase(
3170*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_back_value_mask") + verifier->getTestNamePostfix()).c_str(),
3171*35238bceSAndroid Build Coastguard Worker             "STENCIL_BACK_VALUE_MASK", GL_STENCIL_BACK_VALUE_MASK)));
3172*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3173*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3174*35238bceSAndroid Build Coastguard Worker         addChild(new StencilMaskSeparateTestCase(
3175*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_value_mask_separate") + verifier->getTestNamePostfix()).c_str(),
3176*35238bceSAndroid Build Coastguard Worker             "STENCIL_VALUE_MASK (separate)", GL_STENCIL_VALUE_MASK, GL_FRONT)));
3177*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3178*35238bceSAndroid Build Coastguard Worker                       addChild(new StencilMaskSeparateTestCase(
3179*35238bceSAndroid Build Coastguard Worker                           m_context, verifier,
3180*35238bceSAndroid Build Coastguard Worker                           (std::string("stencil_value_mask_separate_both") + verifier->getTestNamePostfix()).c_str(),
3181*35238bceSAndroid Build Coastguard Worker                           "STENCIL_VALUE_MASK (separate)", GL_STENCIL_VALUE_MASK, GL_FRONT_AND_BACK)));
3182*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3183*35238bceSAndroid Build Coastguard Worker                       addChild(new StencilMaskSeparateTestCase(
3184*35238bceSAndroid Build Coastguard Worker                           m_context, verifier,
3185*35238bceSAndroid Build Coastguard Worker                           (std::string("stencil_back_value_mask_separate") + verifier->getTestNamePostfix()).c_str(),
3186*35238bceSAndroid Build Coastguard Worker                           "STENCIL_BACK_VALUE_MASK (separate)", GL_STENCIL_BACK_VALUE_MASK, GL_BACK)));
3187*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3188*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3189*35238bceSAndroid Build Coastguard Worker         addChild(new StencilMaskSeparateTestCase(
3190*35238bceSAndroid Build Coastguard Worker             m_context, verifier,
3191*35238bceSAndroid Build Coastguard Worker             (std::string("stencil_back_value_mask_separate_both") + verifier->getTestNamePostfix()).c_str(),
3192*35238bceSAndroid Build Coastguard Worker             "STENCIL_BACK_VALUE_MASK (separate)", GL_STENCIL_BACK_VALUE_MASK, GL_FRONT_AND_BACK)));
3193*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskTestCase(
3194*35238bceSAndroid Build Coastguard Worker                                            m_context, verifier,
3195*35238bceSAndroid Build Coastguard Worker                                            (std::string("stencil_writemask") + verifier->getTestNamePostfix()).c_str(),
3196*35238bceSAndroid Build Coastguard Worker                                            "STENCIL_WRITEMASK", GL_STENCIL_WRITEMASK)));
3197*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3198*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3199*35238bceSAndroid Build Coastguard Worker         addChild(new StencilWriteMaskTestCase(
3200*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_back_writemask") + verifier->getTestNamePostfix()).c_str(),
3201*35238bceSAndroid Build Coastguard Worker             "STENCIL_BACK_WRITEMASK", GL_STENCIL_BACK_WRITEMASK)));
3202*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3203*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3204*35238bceSAndroid Build Coastguard Worker         addChild(new StencilWriteMaskSeparateTestCase(
3205*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_writemask_separate") + verifier->getTestNamePostfix()).c_str(),
3206*35238bceSAndroid Build Coastguard Worker             "STENCIL_WRITEMASK (separate)", GL_STENCIL_WRITEMASK, GL_FRONT)));
3207*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3208*35238bceSAndroid Build Coastguard Worker                       addChild(new StencilWriteMaskSeparateTestCase(
3209*35238bceSAndroid Build Coastguard Worker                           m_context, verifier,
3210*35238bceSAndroid Build Coastguard Worker                           (std::string("stencil_writemask_separate_both") + verifier->getTestNamePostfix()).c_str(),
3211*35238bceSAndroid Build Coastguard Worker                           "STENCIL_WRITEMASK (separate)", GL_STENCIL_WRITEMASK, GL_FRONT_AND_BACK)));
3212*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3213*35238bceSAndroid Build Coastguard Worker                       addChild(new StencilWriteMaskSeparateTestCase(
3214*35238bceSAndroid Build Coastguard Worker                           m_context, verifier,
3215*35238bceSAndroid Build Coastguard Worker                           (std::string("stencil_back_writemask_separate") + verifier->getTestNamePostfix()).c_str(),
3216*35238bceSAndroid Build Coastguard Worker                           "STENCIL_BACK_WRITEMASK (separate)", GL_STENCIL_BACK_WRITEMASK, GL_BACK)));
3217*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3218*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3219*35238bceSAndroid Build Coastguard Worker         addChild(new StencilWriteMaskSeparateTestCase(
3220*35238bceSAndroid Build Coastguard Worker             m_context, verifier,
3221*35238bceSAndroid Build Coastguard Worker             (std::string("stencil_back_writemask_separate_both") + verifier->getTestNamePostfix()).c_str(),
3222*35238bceSAndroid Build Coastguard Worker             "STENCIL_BACK_WRITEMASK (separate)", GL_STENCIL_BACK_WRITEMASK, GL_FRONT_AND_BACK)));
3223*35238bceSAndroid Build Coastguard Worker 
3224*35238bceSAndroid Build Coastguard Worker     const struct PixelStoreState
3225*35238bceSAndroid Build Coastguard Worker     {
3226*35238bceSAndroid Build Coastguard Worker         const char *name;
3227*35238bceSAndroid Build Coastguard Worker         const char *description;
3228*35238bceSAndroid Build Coastguard Worker         GLenum target;
3229*35238bceSAndroid Build Coastguard Worker         int initialValue;
3230*35238bceSAndroid Build Coastguard Worker     } pixelStoreStates[] = {{"unpack_image_height", "UNPACK_IMAGE_HEIGHT", GL_UNPACK_IMAGE_HEIGHT, 0},
3231*35238bceSAndroid Build Coastguard Worker                             {"unpack_skip_images", "UNPACK_SKIP_IMAGES", GL_UNPACK_SKIP_IMAGES, 0},
3232*35238bceSAndroid Build Coastguard Worker                             {"unpack_row_length", "UNPACK_ROW_LENGTH", GL_UNPACK_ROW_LENGTH, 0},
3233*35238bceSAndroid Build Coastguard Worker                             {"unpack_skip_rows", "UNPACK_SKIP_ROWS", GL_UNPACK_SKIP_ROWS, 0},
3234*35238bceSAndroid Build Coastguard Worker                             {"unpack_skip_pixels", "UNPACK_SKIP_PIXELS", GL_UNPACK_SKIP_PIXELS, 0},
3235*35238bceSAndroid Build Coastguard Worker                             {"pack_row_length", "PACK_ROW_LENGTH", GL_PACK_ROW_LENGTH, 0},
3236*35238bceSAndroid Build Coastguard Worker                             {"pack_skip_rows", "PACK_SKIP_ROWS", GL_PACK_SKIP_ROWS, 0},
3237*35238bceSAndroid Build Coastguard Worker                             {"pack_skip_pixels", "PACK_SKIP_PIXELS", GL_PACK_SKIP_PIXELS, 0}};
3238*35238bceSAndroid Build Coastguard Worker     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(pixelStoreStates); testNdx++)
3239*35238bceSAndroid Build Coastguard Worker     {
3240*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(normalVerifiers,
3241*35238bceSAndroid Build Coastguard Worker                           addChild(new PixelStoreTestCase(
3242*35238bceSAndroid Build Coastguard Worker                               m_context, verifier,
3243*35238bceSAndroid Build Coastguard Worker                               (std::string(pixelStoreStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(),
3244*35238bceSAndroid Build Coastguard Worker                               pixelStoreStates[testNdx].description, pixelStoreStates[testNdx].target,
3245*35238bceSAndroid Build Coastguard Worker                               pixelStoreStates[testNdx].initialValue)));
3246*35238bceSAndroid Build Coastguard Worker     }
3247*35238bceSAndroid Build Coastguard Worker 
3248*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(
3249*35238bceSAndroid Build Coastguard Worker                                            m_context, verifier,
3250*35238bceSAndroid Build Coastguard Worker                                            (std::string("unpack_alignment") + verifier->getTestNamePostfix()).c_str(),
3251*35238bceSAndroid Build Coastguard Worker                                            "UNPACK_ALIGNMENT", GL_UNPACK_ALIGNMENT)));
3252*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3253*35238bceSAndroid Build Coastguard Worker                       addChild(new PixelStoreAlignTestCase(
3254*35238bceSAndroid Build Coastguard Worker                           m_context, verifier, (std::string("pack_alignment") + verifier->getTestNamePostfix()).c_str(),
3255*35238bceSAndroid Build Coastguard Worker                           "PACK_ALIGNMENT", GL_PACK_ALIGNMENT)));
3256*35238bceSAndroid Build Coastguard Worker 
3257*35238bceSAndroid Build Coastguard Worker     const struct BlendColorState
3258*35238bceSAndroid Build Coastguard Worker     {
3259*35238bceSAndroid Build Coastguard Worker         const char *name;
3260*35238bceSAndroid Build Coastguard Worker         const char *description;
3261*35238bceSAndroid Build Coastguard Worker         GLenum target;
3262*35238bceSAndroid Build Coastguard Worker         int initialValue;
3263*35238bceSAndroid Build Coastguard Worker     } blendColorStates[] = {{"blend_src_rgb", "BLEND_SRC_RGB", GL_BLEND_SRC_RGB, GL_ONE},
3264*35238bceSAndroid Build Coastguard Worker                             {"blend_src_alpha", "BLEND_SRC_ALPHA", GL_BLEND_SRC_ALPHA, GL_ONE},
3265*35238bceSAndroid Build Coastguard Worker                             {"blend_dst_rgb", "BLEND_DST_RGB", GL_BLEND_DST_RGB, GL_ZERO},
3266*35238bceSAndroid Build Coastguard Worker                             {"blend_dst_alpha", "BLEND_DST_ALPHA", GL_BLEND_DST_ALPHA, GL_ZERO}};
3267*35238bceSAndroid Build Coastguard Worker     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendColorStates); testNdx++)
3268*35238bceSAndroid Build Coastguard Worker     {
3269*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(normalVerifiers,
3270*35238bceSAndroid Build Coastguard Worker                           addChild(new BlendFuncTestCase(
3271*35238bceSAndroid Build Coastguard Worker                               m_context, verifier,
3272*35238bceSAndroid Build Coastguard Worker                               (std::string(blendColorStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(),
3273*35238bceSAndroid Build Coastguard Worker                               blendColorStates[testNdx].description, blendColorStates[testNdx].target,
3274*35238bceSAndroid Build Coastguard Worker                               blendColorStates[testNdx].initialValue)));
3275*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
3276*35238bceSAndroid Build Coastguard Worker             normalVerifiers,
3277*35238bceSAndroid Build Coastguard Worker             addChild(new BlendFuncSeparateTestCase(
3278*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
3279*35238bceSAndroid Build Coastguard Worker                 (std::string(blendColorStates[testNdx].name) + "_separate" + verifier->getTestNamePostfix()).c_str(),
3280*35238bceSAndroid Build Coastguard Worker                 blendColorStates[testNdx].description, blendColorStates[testNdx].target,
3281*35238bceSAndroid Build Coastguard Worker                 blendColorStates[testNdx].initialValue)));
3282*35238bceSAndroid Build Coastguard Worker     }
3283*35238bceSAndroid Build Coastguard Worker 
3284*35238bceSAndroid Build Coastguard Worker     const struct BlendEquationState
3285*35238bceSAndroid Build Coastguard Worker     {
3286*35238bceSAndroid Build Coastguard Worker         const char *name;
3287*35238bceSAndroid Build Coastguard Worker         const char *description;
3288*35238bceSAndroid Build Coastguard Worker         GLenum target;
3289*35238bceSAndroid Build Coastguard Worker         int initialValue;
3290*35238bceSAndroid Build Coastguard Worker     } blendEquationStates[] = {{"blend_equation_rgb", "BLEND_EQUATION_RGB", GL_BLEND_EQUATION_RGB, GL_FUNC_ADD},
3291*35238bceSAndroid Build Coastguard Worker                                {"blend_equation_alpha", "BLEND_EQUATION_ALPHA", GL_BLEND_EQUATION_ALPHA, GL_FUNC_ADD}};
3292*35238bceSAndroid Build Coastguard Worker     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendEquationStates); testNdx++)
3293*35238bceSAndroid Build Coastguard Worker     {
3294*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
3295*35238bceSAndroid Build Coastguard Worker             normalVerifiers,
3296*35238bceSAndroid Build Coastguard Worker             addChild(new BlendEquationTestCase(
3297*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
3298*35238bceSAndroid Build Coastguard Worker                 (std::string(blendEquationStates[testNdx].name) + +verifier->getTestNamePostfix()).c_str(),
3299*35238bceSAndroid Build Coastguard Worker                 blendEquationStates[testNdx].description, blendEquationStates[testNdx].target,
3300*35238bceSAndroid Build Coastguard Worker                 blendEquationStates[testNdx].initialValue)));
3301*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(
3302*35238bceSAndroid Build Coastguard Worker             normalVerifiers,
3303*35238bceSAndroid Build Coastguard Worker             addChild(new BlendEquationSeparateTestCase(
3304*35238bceSAndroid Build Coastguard Worker                 m_context, verifier,
3305*35238bceSAndroid Build Coastguard Worker                 (std::string(blendEquationStates[testNdx].name) + "_separate" + verifier->getTestNamePostfix()).c_str(),
3306*35238bceSAndroid Build Coastguard Worker                 blendEquationStates[testNdx].description, blendEquationStates[testNdx].target,
3307*35238bceSAndroid Build Coastguard Worker                 blendEquationStates[testNdx].initialValue)));
3308*35238bceSAndroid Build Coastguard Worker     }
3309*35238bceSAndroid Build Coastguard Worker 
3310*35238bceSAndroid Build Coastguard Worker     const struct ImplementationArrayReturningState
3311*35238bceSAndroid Build Coastguard Worker     {
3312*35238bceSAndroid Build Coastguard Worker         const char *name;
3313*35238bceSAndroid Build Coastguard Worker         const char *description;
3314*35238bceSAndroid Build Coastguard Worker         GLenum target;
3315*35238bceSAndroid Build Coastguard Worker         GLenum targetLengthTarget;
3316*35238bceSAndroid Build Coastguard Worker         int minLength;
3317*35238bceSAndroid Build Coastguard Worker     } implementationArrayReturningStates[] = {
3318*35238bceSAndroid Build Coastguard Worker         {"compressed_texture_formats", "COMPRESSED_TEXTURE_FORMATS", GL_COMPRESSED_TEXTURE_FORMATS,
3319*35238bceSAndroid Build Coastguard Worker          GL_NUM_COMPRESSED_TEXTURE_FORMATS, 10},
3320*35238bceSAndroid Build Coastguard Worker         {"program_binary_formats", "PROGRAM_BINARY_FORMATS", GL_PROGRAM_BINARY_FORMATS, GL_NUM_PROGRAM_BINARY_FORMATS,
3321*35238bceSAndroid Build Coastguard Worker          0},
3322*35238bceSAndroid Build Coastguard Worker         {"shader_binary_formats", "SHADER_BINARY_FORMATS", GL_SHADER_BINARY_FORMATS, GL_NUM_SHADER_BINARY_FORMATS, 0}};
3323*35238bceSAndroid Build Coastguard Worker     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationArrayReturningStates); testNdx++)
3324*35238bceSAndroid Build Coastguard Worker     {
3325*35238bceSAndroid Build Coastguard Worker         FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationArrayTestCase(
3326*35238bceSAndroid Build Coastguard Worker                                                m_context, verifier,
3327*35238bceSAndroid Build Coastguard Worker                                                (std::string(implementationArrayReturningStates[testNdx].name) +
3328*35238bceSAndroid Build Coastguard Worker                                                 verifier->getTestNamePostfix())
3329*35238bceSAndroid Build Coastguard Worker                                                    .c_str(),
3330*35238bceSAndroid Build Coastguard Worker                                                implementationArrayReturningStates[testNdx].description,
3331*35238bceSAndroid Build Coastguard Worker                                                implementationArrayReturningStates[testNdx].target,
3332*35238bceSAndroid Build Coastguard Worker                                                implementationArrayReturningStates[testNdx].targetLengthTarget,
3333*35238bceSAndroid Build Coastguard Worker                                                implementationArrayReturningStates[testNdx].minLength)));
3334*35238bceSAndroid Build Coastguard Worker     }
3335*35238bceSAndroid Build Coastguard Worker 
3336*35238bceSAndroid Build Coastguard Worker     const struct BufferBindingState
3337*35238bceSAndroid Build Coastguard Worker     {
3338*35238bceSAndroid Build Coastguard Worker         const char *name;
3339*35238bceSAndroid Build Coastguard Worker         const char *description;
3340*35238bceSAndroid Build Coastguard Worker         GLenum target;
3341*35238bceSAndroid Build Coastguard Worker         GLenum type;
3342*35238bceSAndroid Build Coastguard Worker     } bufferBindingStates[] = {
3343*35238bceSAndroid Build Coastguard Worker         {"array_buffer_binding", "ARRAY_BUFFER_BINDING", GL_ARRAY_BUFFER_BINDING, GL_ARRAY_BUFFER},
3344*35238bceSAndroid Build Coastguard Worker         {"uniform_buffer_binding", "UNIFORM_BUFFER_BINDING", GL_UNIFORM_BUFFER_BINDING, GL_UNIFORM_BUFFER},
3345*35238bceSAndroid Build Coastguard Worker         {"pixel_pack_buffer_binding", "PIXEL_PACK_BUFFER_BINDING", GL_PIXEL_PACK_BUFFER_BINDING, GL_PIXEL_PACK_BUFFER},
3346*35238bceSAndroid Build Coastguard Worker         {"pixel_unpack_buffer_binding", "PIXEL_UNPACK_BUFFER_BINDING", GL_PIXEL_UNPACK_BUFFER_BINDING,
3347*35238bceSAndroid Build Coastguard Worker          GL_PIXEL_UNPACK_BUFFER},
3348*35238bceSAndroid Build Coastguard Worker         {"transform_feedback_buffer_binding", "TRANSFORM_FEEDBACK_BUFFER_BINDING", GL_TRANSFORM_FEEDBACK_BUFFER_BINDING,
3349*35238bceSAndroid Build Coastguard Worker          GL_TRANSFORM_FEEDBACK_BUFFER},
3350*35238bceSAndroid Build Coastguard Worker         {"copy_read_buffer_binding", "COPY_READ_BUFFER_BINDING", GL_COPY_READ_BUFFER_BINDING, GL_COPY_READ_BUFFER},
3351*35238bceSAndroid Build Coastguard Worker         {"copy_write_buffer_binding", "COPY_WRITE_BUFFER_BINDING", GL_COPY_WRITE_BUFFER_BINDING, GL_COPY_WRITE_BUFFER}};
3352*35238bceSAndroid Build Coastguard Worker     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(bufferBindingStates); testNdx++)
3353*35238bceSAndroid Build Coastguard Worker     {
3354*35238bceSAndroid Build Coastguard Worker         FOR_EACH_QUERYTYPE(queryTypes,
3355*35238bceSAndroid Build Coastguard Worker                            addChild(new BufferBindingTestCase(
3356*35238bceSAndroid Build Coastguard Worker                                m_context, queryType,
3357*35238bceSAndroid Build Coastguard Worker                                (std::string(bufferBindingStates[testNdx].name) + getQueryTypeSuffix(queryType)).c_str(),
3358*35238bceSAndroid Build Coastguard Worker                                bufferBindingStates[testNdx].description, bufferBindingStates[testNdx].target,
3359*35238bceSAndroid Build Coastguard Worker                                bufferBindingStates[testNdx].type)));
3360*35238bceSAndroid Build Coastguard Worker     }
3361*35238bceSAndroid Build Coastguard Worker 
3362*35238bceSAndroid Build Coastguard Worker     FOR_EACH_QUERYTYPE(queryTypes,
3363*35238bceSAndroid Build Coastguard Worker                        addChild(new ElementArrayBufferBindingTestCase(
3364*35238bceSAndroid Build Coastguard Worker                            m_context, queryType,
3365*35238bceSAndroid Build Coastguard Worker                            (std::string("element_array_buffer_binding") + getQueryTypeSuffix(queryType)).c_str())));
3366*35238bceSAndroid Build Coastguard Worker     FOR_EACH_QUERYTYPE(queryTypes,
3367*35238bceSAndroid Build Coastguard Worker                        addChild(new TransformFeedbackBindingTestCase(
3368*35238bceSAndroid Build Coastguard Worker                            m_context, queryType,
3369*35238bceSAndroid Build Coastguard Worker                            (std::string("transform_feedback_binding") + getQueryTypeSuffix(queryType)).c_str())));
3370*35238bceSAndroid Build Coastguard Worker     FOR_EACH_QUERYTYPE(queryTypes, addChild(new CurrentProgramBindingTestCase(
3371*35238bceSAndroid Build Coastguard Worker                                        m_context, queryType,
3372*35238bceSAndroid Build Coastguard Worker                                        (std::string("current_program_binding") + getQueryTypeSuffix(queryType)).c_str(),
3373*35238bceSAndroid Build Coastguard Worker                                        "CURRENT_PROGRAM")));
3374*35238bceSAndroid Build Coastguard Worker     FOR_EACH_QUERYTYPE(queryTypes, addChild(new VertexArrayBindingTestCase(
3375*35238bceSAndroid Build Coastguard Worker                                        m_context, queryType,
3376*35238bceSAndroid Build Coastguard Worker                                        (std::string("vertex_array_binding") + getQueryTypeSuffix(queryType)).c_str(),
3377*35238bceSAndroid Build Coastguard Worker                                        "VERTEX_ARRAY_BINDING")));
3378*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3379*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3380*35238bceSAndroid Build Coastguard Worker         addChild(new StencilClearValueTestCase(
3381*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("stencil_clear_value") + verifier->getTestNamePostfix()).c_str(),
3382*35238bceSAndroid Build Coastguard Worker             "STENCIL_CLEAR_VALUE")));
3383*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3384*35238bceSAndroid Build Coastguard Worker                       addChild(new ActiveTextureTestCase(
3385*35238bceSAndroid Build Coastguard Worker                           m_context, verifier, (std::string("active_texture") + verifier->getTestNamePostfix()).c_str(),
3386*35238bceSAndroid Build Coastguard Worker                           "ACTIVE_TEXTURE")));
3387*35238bceSAndroid Build Coastguard Worker     FOR_EACH_QUERYTYPE(queryTypes, addChild(new RenderbufferBindingTestCase(
3388*35238bceSAndroid Build Coastguard Worker                                        m_context, queryType,
3389*35238bceSAndroid Build Coastguard Worker                                        (std::string("renderbuffer_binding") + getQueryTypeSuffix(queryType)).c_str(),
3390*35238bceSAndroid Build Coastguard Worker                                        "RENDERBUFFER_BINDING")));
3391*35238bceSAndroid Build Coastguard Worker     FOR_EACH_QUERYTYPE(
3392*35238bceSAndroid Build Coastguard Worker         queryTypes, addChild(new SamplerObjectBindingTestCase(
3393*35238bceSAndroid Build Coastguard Worker                         m_context, queryType, (std::string("sampler_binding") + getQueryTypeSuffix(queryType)).c_str(),
3394*35238bceSAndroid Build Coastguard Worker                         "SAMPLER_BINDING")));
3395*35238bceSAndroid Build Coastguard Worker 
3396*35238bceSAndroid Build Coastguard Worker     const struct TextureBinding
3397*35238bceSAndroid Build Coastguard Worker     {
3398*35238bceSAndroid Build Coastguard Worker         const char *name;
3399*35238bceSAndroid Build Coastguard Worker         const char *description;
3400*35238bceSAndroid Build Coastguard Worker         GLenum target;
3401*35238bceSAndroid Build Coastguard Worker         GLenum type;
3402*35238bceSAndroid Build Coastguard Worker     } textureBindings[] = {
3403*35238bceSAndroid Build Coastguard Worker         {"texture_binding_2d", "TEXTURE_BINDING_2D", GL_TEXTURE_BINDING_2D, GL_TEXTURE_2D},
3404*35238bceSAndroid Build Coastguard Worker         {"texture_binding_3d", "TEXTURE_BINDING_3D", GL_TEXTURE_BINDING_3D, GL_TEXTURE_3D},
3405*35238bceSAndroid Build Coastguard Worker         {"texture_binding_2d_array", "TEXTURE_BINDING_2D_ARRAY", GL_TEXTURE_BINDING_2D_ARRAY, GL_TEXTURE_2D_ARRAY},
3406*35238bceSAndroid Build Coastguard Worker         {"texture_binding_cube_map", "TEXTURE_BINDING_CUBE_MAP", GL_TEXTURE_BINDING_CUBE_MAP, GL_TEXTURE_CUBE_MAP}};
3407*35238bceSAndroid Build Coastguard Worker 
3408*35238bceSAndroid Build Coastguard Worker     for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(textureBindings); testNdx++)
3409*35238bceSAndroid Build Coastguard Worker     {
3410*35238bceSAndroid Build Coastguard Worker         FOR_EACH_QUERYTYPE(
3411*35238bceSAndroid Build Coastguard Worker             queryTypes,
3412*35238bceSAndroid Build Coastguard Worker             addChild(new TextureBindingTestCase(
3413*35238bceSAndroid Build Coastguard Worker                 m_context, queryType,
3414*35238bceSAndroid Build Coastguard Worker                 (std::string(textureBindings[testNdx].name) + getQueryTypeSuffix(queryType)).c_str(),
3415*35238bceSAndroid Build Coastguard Worker                 textureBindings[testNdx].description, textureBindings[testNdx].target, textureBindings[testNdx].type)));
3416*35238bceSAndroid Build Coastguard Worker     }
3417*35238bceSAndroid Build Coastguard Worker 
3418*35238bceSAndroid Build Coastguard Worker     FOR_EACH_QUERYTYPE(queryTypes, addChild(new FrameBufferBindingTestCase(
3419*35238bceSAndroid Build Coastguard Worker                                        m_context, queryType,
3420*35238bceSAndroid Build Coastguard Worker                                        (std::string("framebuffer_binding") + getQueryTypeSuffix(queryType)).c_str(),
3421*35238bceSAndroid Build Coastguard Worker                                        "DRAW_FRAMEBUFFER_BINDING and READ_FRAMEBUFFER_BINDING")));
3422*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(
3423*35238bceSAndroid Build Coastguard Worker         normalVerifiers,
3424*35238bceSAndroid Build Coastguard Worker         addChild(new ImplementationColorReadTestCase(
3425*35238bceSAndroid Build Coastguard Worker             m_context, verifier, (std::string("implementation_color_read") + verifier->getTestNamePostfix()).c_str(),
3426*35238bceSAndroid Build Coastguard Worker             "IMPLEMENTATION_COLOR_READ_TYPE and IMPLEMENTATION_COLOR_READ_FORMAT")));
3427*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3428*35238bceSAndroid Build Coastguard Worker                       addChild(new ReadBufferCase(m_context, verifier,
3429*35238bceSAndroid Build Coastguard Worker                                                   (std::string("read_buffer") + verifier->getTestNamePostfix()).c_str(),
3430*35238bceSAndroid Build Coastguard Worker                                                   "READ_BUFFER")));
3431*35238bceSAndroid Build Coastguard Worker     FOR_EACH_VERIFIER(normalVerifiers,
3432*35238bceSAndroid Build Coastguard Worker                       addChild(new DrawBufferCase(m_context, verifier,
3433*35238bceSAndroid Build Coastguard Worker                                                   (std::string("draw_buffer") + verifier->getTestNamePostfix()).c_str(),
3434*35238bceSAndroid Build Coastguard Worker                                                   "DRAW_BUFFER")));
3435*35238bceSAndroid Build Coastguard Worker }
3436*35238bceSAndroid Build Coastguard Worker 
deinit(void)3437*35238bceSAndroid Build Coastguard Worker void IntegerStateQueryTests::deinit(void)
3438*35238bceSAndroid Build Coastguard Worker {
3439*35238bceSAndroid Build Coastguard Worker     if (m_verifierBoolean)
3440*35238bceSAndroid Build Coastguard Worker     {
3441*35238bceSAndroid Build Coastguard Worker         delete m_verifierBoolean;
3442*35238bceSAndroid Build Coastguard Worker         m_verifierBoolean = DE_NULL;
3443*35238bceSAndroid Build Coastguard Worker     }
3444*35238bceSAndroid Build Coastguard Worker     if (m_verifierInteger)
3445*35238bceSAndroid Build Coastguard Worker     {
3446*35238bceSAndroid Build Coastguard Worker         delete m_verifierInteger;
3447*35238bceSAndroid Build Coastguard Worker         m_verifierInteger = DE_NULL;
3448*35238bceSAndroid Build Coastguard Worker     }
3449*35238bceSAndroid Build Coastguard Worker     if (m_verifierInteger64)
3450*35238bceSAndroid Build Coastguard Worker     {
3451*35238bceSAndroid Build Coastguard Worker         delete m_verifierInteger64;
3452*35238bceSAndroid Build Coastguard Worker         m_verifierInteger64 = DE_NULL;
3453*35238bceSAndroid Build Coastguard Worker     }
3454*35238bceSAndroid Build Coastguard Worker     if (m_verifierFloat)
3455*35238bceSAndroid Build Coastguard Worker     {
3456*35238bceSAndroid Build Coastguard Worker         delete m_verifierFloat;
3457*35238bceSAndroid Build Coastguard Worker         m_verifierFloat = DE_NULL;
3458*35238bceSAndroid Build Coastguard Worker     }
3459*35238bceSAndroid Build Coastguard Worker 
3460*35238bceSAndroid Build Coastguard Worker     this->TestCaseGroup::deinit();
3461*35238bceSAndroid Build Coastguard Worker }
3462*35238bceSAndroid Build Coastguard Worker 
3463*35238bceSAndroid Build Coastguard Worker } // namespace Functional
3464*35238bceSAndroid Build Coastguard Worker } // namespace gles3
3465*35238bceSAndroid Build Coastguard Worker } // namespace deqp
3466