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 Rbo state query tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es3fRboStateQueryTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "glsStateQueryUtil.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "es3fApiCase.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
32*35238bceSAndroid Build Coastguard Worker
33*35238bceSAndroid Build Coastguard Worker using namespace glw; // GLint and other GL types
34*35238bceSAndroid Build Coastguard Worker using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
35*35238bceSAndroid Build Coastguard Worker
36*35238bceSAndroid Build Coastguard Worker namespace deqp
37*35238bceSAndroid Build Coastguard Worker {
38*35238bceSAndroid Build Coastguard Worker namespace gles3
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker namespace Functional
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker namespace
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker
checkRenderbufferComponentSize(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,int r,int g,int b,int a,int d,int s)45*35238bceSAndroid Build Coastguard Worker void checkRenderbufferComponentSize(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, int r, int g, int b, int a,
46*35238bceSAndroid Build Coastguard Worker int d, int s)
47*35238bceSAndroid Build Coastguard Worker {
48*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
49*35238bceSAndroid Build Coastguard Worker
50*35238bceSAndroid Build Coastguard Worker const int referenceSizes[] = {r, g, b, a, d, s};
51*35238bceSAndroid Build Coastguard Worker const GLenum paramNames[] = {GL_RENDERBUFFER_RED_SIZE, GL_RENDERBUFFER_GREEN_SIZE, GL_RENDERBUFFER_BLUE_SIZE,
52*35238bceSAndroid Build Coastguard Worker GL_RENDERBUFFER_ALPHA_SIZE, GL_RENDERBUFFER_DEPTH_SIZE, GL_RENDERBUFFER_STENCIL_SIZE};
53*35238bceSAndroid Build Coastguard Worker
54*35238bceSAndroid Build Coastguard Worker DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(referenceSizes) == DE_LENGTH_OF_ARRAY(paramNames));
55*35238bceSAndroid Build Coastguard Worker
56*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceSizes); ++ndx)
57*35238bceSAndroid Build Coastguard Worker {
58*35238bceSAndroid Build Coastguard Worker if (referenceSizes[ndx] == -1)
59*35238bceSAndroid Build Coastguard Worker continue;
60*35238bceSAndroid Build Coastguard Worker
61*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
62*35238bceSAndroid Build Coastguard Worker gl.glGetRenderbufferParameteriv(GL_RENDERBUFFER, paramNames[ndx], &state);
63*35238bceSAndroid Build Coastguard Worker
64*35238bceSAndroid Build Coastguard Worker if (!state.verifyValidity(testCtx))
65*35238bceSAndroid Build Coastguard Worker return;
66*35238bceSAndroid Build Coastguard Worker
67*35238bceSAndroid Build Coastguard Worker if (state < referenceSizes[ndx])
68*35238bceSAndroid Build Coastguard Worker {
69*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected greater or equal to " << referenceSizes[ndx]
70*35238bceSAndroid Build Coastguard Worker << "; got " << state << TestLog::EndMessage;
71*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
72*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
73*35238bceSAndroid Build Coastguard Worker }
74*35238bceSAndroid Build Coastguard Worker }
75*35238bceSAndroid Build Coastguard Worker }
76*35238bceSAndroid Build Coastguard Worker
checkIntEquals(tcu::TestContext & testCtx,GLint got,GLint expected)77*35238bceSAndroid Build Coastguard Worker void checkIntEquals(tcu::TestContext &testCtx, GLint got, GLint expected)
78*35238bceSAndroid Build Coastguard Worker {
79*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
80*35238bceSAndroid Build Coastguard Worker
81*35238bceSAndroid Build Coastguard Worker if (got != expected)
82*35238bceSAndroid Build Coastguard Worker {
83*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got
84*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
85*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
86*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
87*35238bceSAndroid Build Coastguard Worker }
88*35238bceSAndroid Build Coastguard Worker }
89*35238bceSAndroid Build Coastguard Worker
checkIntGreaterOrEqual(tcu::TestContext & testCtx,GLint got,GLint expected)90*35238bceSAndroid Build Coastguard Worker void checkIntGreaterOrEqual(tcu::TestContext &testCtx, GLint got, GLint expected)
91*35238bceSAndroid Build Coastguard Worker {
92*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
93*35238bceSAndroid Build Coastguard Worker
94*35238bceSAndroid Build Coastguard Worker if (got < expected)
95*35238bceSAndroid Build Coastguard Worker {
96*35238bceSAndroid Build Coastguard Worker testCtx.getLog() << TestLog::Message << "// ERROR: Expected greater or equal to " << expected << "; got " << got
97*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
98*35238bceSAndroid Build Coastguard Worker if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
99*35238bceSAndroid Build Coastguard Worker testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
100*35238bceSAndroid Build Coastguard Worker }
101*35238bceSAndroid Build Coastguard Worker }
102*35238bceSAndroid Build Coastguard Worker
checkRenderbufferParam(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLenum pname,GLenum reference)103*35238bceSAndroid Build Coastguard Worker void checkRenderbufferParam(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLenum pname, GLenum reference)
104*35238bceSAndroid Build Coastguard Worker {
105*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
106*35238bceSAndroid Build Coastguard Worker gl.glGetRenderbufferParameteriv(GL_RENDERBUFFER, pname, &state);
107*35238bceSAndroid Build Coastguard Worker
108*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(testCtx))
109*35238bceSAndroid Build Coastguard Worker checkIntEquals(testCtx, state, reference);
110*35238bceSAndroid Build Coastguard Worker }
111*35238bceSAndroid Build Coastguard Worker
checkRenderbufferParamGreaterOrEqual(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLenum pname,GLenum reference)112*35238bceSAndroid Build Coastguard Worker void checkRenderbufferParamGreaterOrEqual(tcu::TestContext &testCtx, glu::CallLogWrapper &gl, GLenum pname,
113*35238bceSAndroid Build Coastguard Worker GLenum reference)
114*35238bceSAndroid Build Coastguard Worker {
115*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
116*35238bceSAndroid Build Coastguard Worker gl.glGetRenderbufferParameteriv(GL_RENDERBUFFER, pname, &state);
117*35238bceSAndroid Build Coastguard Worker
118*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(testCtx))
119*35238bceSAndroid Build Coastguard Worker checkIntGreaterOrEqual(testCtx, state, reference);
120*35238bceSAndroid Build Coastguard Worker }
121*35238bceSAndroid Build Coastguard Worker
122*35238bceSAndroid Build Coastguard Worker class RboSizeCase : public ApiCase
123*35238bceSAndroid Build Coastguard Worker {
124*35238bceSAndroid Build Coastguard Worker public:
RboSizeCase(Context & context,const char * name,const char * description)125*35238bceSAndroid Build Coastguard Worker RboSizeCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
126*35238bceSAndroid Build Coastguard Worker {
127*35238bceSAndroid Build Coastguard Worker }
128*35238bceSAndroid Build Coastguard Worker
test(void)129*35238bceSAndroid Build Coastguard Worker void test(void)
130*35238bceSAndroid Build Coastguard Worker {
131*35238bceSAndroid Build Coastguard Worker de::Random rnd(0xabcdef);
132*35238bceSAndroid Build Coastguard Worker
133*35238bceSAndroid Build Coastguard Worker GLuint renderbufferID = 0;
134*35238bceSAndroid Build Coastguard Worker glGenRenderbuffers(1, &renderbufferID);
135*35238bceSAndroid Build Coastguard Worker glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
136*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
137*35238bceSAndroid Build Coastguard Worker
138*35238bceSAndroid Build Coastguard Worker checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_WIDTH, 0);
139*35238bceSAndroid Build Coastguard Worker checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_HEIGHT, 0);
140*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
141*35238bceSAndroid Build Coastguard Worker
142*35238bceSAndroid Build Coastguard Worker const int numIterations = 60;
143*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < numIterations; ++i)
144*35238bceSAndroid Build Coastguard Worker {
145*35238bceSAndroid Build Coastguard Worker const GLint w = rnd.getInt(0, 128);
146*35238bceSAndroid Build Coastguard Worker const GLint h = rnd.getInt(0, 128);
147*35238bceSAndroid Build Coastguard Worker
148*35238bceSAndroid Build Coastguard Worker glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB8, w, h);
149*35238bceSAndroid Build Coastguard Worker
150*35238bceSAndroid Build Coastguard Worker checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_WIDTH, w);
151*35238bceSAndroid Build Coastguard Worker checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_HEIGHT, h);
152*35238bceSAndroid Build Coastguard Worker }
153*35238bceSAndroid Build Coastguard Worker
154*35238bceSAndroid Build Coastguard Worker glDeleteRenderbuffers(1, &renderbufferID);
155*35238bceSAndroid Build Coastguard Worker }
156*35238bceSAndroid Build Coastguard Worker };
157*35238bceSAndroid Build Coastguard Worker
158*35238bceSAndroid Build Coastguard Worker class RboInternalFormatCase : public ApiCase
159*35238bceSAndroid Build Coastguard Worker {
160*35238bceSAndroid Build Coastguard Worker public:
RboInternalFormatCase(Context & context,const char * name,const char * description)161*35238bceSAndroid Build Coastguard Worker RboInternalFormatCase(Context &context, const char *name, const char *description)
162*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
163*35238bceSAndroid Build Coastguard Worker {
164*35238bceSAndroid Build Coastguard Worker }
165*35238bceSAndroid Build Coastguard Worker
test(void)166*35238bceSAndroid Build Coastguard Worker void test(void)
167*35238bceSAndroid Build Coastguard Worker {
168*35238bceSAndroid Build Coastguard Worker GLuint renderbufferID = 0;
169*35238bceSAndroid Build Coastguard Worker glGenRenderbuffers(1, &renderbufferID);
170*35238bceSAndroid Build Coastguard Worker glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
171*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
172*35238bceSAndroid Build Coastguard Worker
173*35238bceSAndroid Build Coastguard Worker const glu::ContextType &contextType = m_context.getRenderContext().getType();
174*35238bceSAndroid Build Coastguard Worker const bool isCoreGL45 = glu::contextSupports(contextType, glu::ApiType::core(4, 5));
175*35238bceSAndroid Build Coastguard Worker
176*35238bceSAndroid Build Coastguard Worker GLenum initialValue = isCoreGL45 ? GL_RGBA : GL_RGBA4;
177*35238bceSAndroid Build Coastguard Worker checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_INTERNAL_FORMAT, initialValue);
178*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
179*35238bceSAndroid Build Coastguard Worker
180*35238bceSAndroid Build Coastguard Worker const GLenum requiredColorformats[] = {
181*35238bceSAndroid Build Coastguard Worker GL_R8, GL_RG8, GL_RGB8, GL_RGB565, GL_RGBA4, GL_RGB5_A1, GL_RGBA8,
182*35238bceSAndroid Build Coastguard Worker GL_RGB10_A2, GL_RGB10_A2UI, GL_SRGB8_ALPHA8, GL_R8I, GL_R8UI, GL_R16I, GL_R16UI,
183*35238bceSAndroid Build Coastguard Worker GL_R32I, GL_R32UI, GL_RG8I, GL_RG8UI, GL_RG16I, GL_RG16UI, GL_RG32I,
184*35238bceSAndroid Build Coastguard Worker GL_RG32UI, GL_RGBA8I, GL_RGBA8UI, GL_RGBA16I, GL_RGBA16UI, GL_RGBA32I, GL_RGBA32UI};
185*35238bceSAndroid Build Coastguard Worker
186*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(requiredColorformats); ++ndx)
187*35238bceSAndroid Build Coastguard Worker {
188*35238bceSAndroid Build Coastguard Worker glRenderbufferStorage(GL_RENDERBUFFER, requiredColorformats[ndx], 128, 128);
189*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
190*35238bceSAndroid Build Coastguard Worker
191*35238bceSAndroid Build Coastguard Worker checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_INTERNAL_FORMAT, requiredColorformats[ndx]);
192*35238bceSAndroid Build Coastguard Worker }
193*35238bceSAndroid Build Coastguard Worker
194*35238bceSAndroid Build Coastguard Worker glDeleteRenderbuffers(1, &renderbufferID);
195*35238bceSAndroid Build Coastguard Worker }
196*35238bceSAndroid Build Coastguard Worker };
197*35238bceSAndroid Build Coastguard Worker
198*35238bceSAndroid Build Coastguard Worker class RboComponentSizeColorCase : public ApiCase
199*35238bceSAndroid Build Coastguard Worker {
200*35238bceSAndroid Build Coastguard Worker public:
RboComponentSizeColorCase(Context & context,const char * name,const char * description)201*35238bceSAndroid Build Coastguard Worker RboComponentSizeColorCase(Context &context, const char *name, const char *description)
202*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
203*35238bceSAndroid Build Coastguard Worker {
204*35238bceSAndroid Build Coastguard Worker }
205*35238bceSAndroid Build Coastguard Worker
test(void)206*35238bceSAndroid Build Coastguard Worker void test(void)
207*35238bceSAndroid Build Coastguard Worker {
208*35238bceSAndroid Build Coastguard Worker GLuint renderbufferID = 0;
209*35238bceSAndroid Build Coastguard Worker glGenRenderbuffers(1, &renderbufferID);
210*35238bceSAndroid Build Coastguard Worker glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
211*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
212*35238bceSAndroid Build Coastguard Worker
213*35238bceSAndroid Build Coastguard Worker checkRenderbufferComponentSize(m_testCtx, *this, 0, 0, 0, 0, 0, 0);
214*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
215*35238bceSAndroid Build Coastguard Worker
216*35238bceSAndroid Build Coastguard Worker const struct ColorFormat
217*35238bceSAndroid Build Coastguard Worker {
218*35238bceSAndroid Build Coastguard Worker GLenum internalFormat;
219*35238bceSAndroid Build Coastguard Worker int bitsR, bitsG, bitsB, bitsA;
220*35238bceSAndroid Build Coastguard Worker } requiredColorFormats[] = {
221*35238bceSAndroid Build Coastguard Worker {GL_R8, 8, 0, 0, 0}, {GL_RG8, 8, 8, 0, 0}, {GL_RGB8, 8, 8, 8, 0},
222*35238bceSAndroid Build Coastguard Worker {GL_RGB565, 5, 6, 5, 0}, {GL_RGBA4, 4, 4, 4, 4}, {GL_RGB5_A1, 5, 5, 5, 1},
223*35238bceSAndroid Build Coastguard Worker {GL_RGBA8, 8, 8, 8, 8}, {GL_RGB10_A2, 10, 10, 10, 2}, {GL_RGB10_A2UI, 10, 10, 10, 2},
224*35238bceSAndroid Build Coastguard Worker {GL_SRGB8_ALPHA8, 8, 8, 8, 8}, {GL_R8I, 8, 0, 0, 0}, {GL_R8UI, 8, 0, 0, 0},
225*35238bceSAndroid Build Coastguard Worker {GL_R16I, 16, 0, 0, 0}, {GL_R16UI, 16, 0, 0, 0}, {GL_R32I, 32, 0, 0, 0},
226*35238bceSAndroid Build Coastguard Worker {GL_R32UI, 32, 0, 0, 0}, {GL_RG8I, 8, 8, 0, 0}, {GL_RG8UI, 8, 8, 0, 0},
227*35238bceSAndroid Build Coastguard Worker {GL_RG16I, 16, 16, 0, 0}, {GL_RG16UI, 16, 16, 0, 0}, {GL_RG32I, 32, 32, 0, 0},
228*35238bceSAndroid Build Coastguard Worker {GL_RG32UI, 32, 32, 0, 0}, {GL_RGBA8I, 8, 8, 8, 8}, {GL_RGBA8UI, 8, 8, 8, 8},
229*35238bceSAndroid Build Coastguard Worker {GL_RGBA16I, 16, 16, 16, 16}, {GL_RGBA16UI, 16, 16, 16, 16}, {GL_RGBA32I, 32, 32, 32, 32},
230*35238bceSAndroid Build Coastguard Worker {GL_RGBA32UI, 32, 32, 32, 32}};
231*35238bceSAndroid Build Coastguard Worker
232*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(requiredColorFormats); ++ndx)
233*35238bceSAndroid Build Coastguard Worker {
234*35238bceSAndroid Build Coastguard Worker glRenderbufferStorage(GL_RENDERBUFFER, requiredColorFormats[ndx].internalFormat, 128, 128);
235*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
236*35238bceSAndroid Build Coastguard Worker
237*35238bceSAndroid Build Coastguard Worker checkRenderbufferComponentSize(m_testCtx, *this, requiredColorFormats[ndx].bitsR,
238*35238bceSAndroid Build Coastguard Worker requiredColorFormats[ndx].bitsG, requiredColorFormats[ndx].bitsB,
239*35238bceSAndroid Build Coastguard Worker requiredColorFormats[ndx].bitsA, -1, -1);
240*35238bceSAndroid Build Coastguard Worker }
241*35238bceSAndroid Build Coastguard Worker
242*35238bceSAndroid Build Coastguard Worker glDeleteRenderbuffers(1, &renderbufferID);
243*35238bceSAndroid Build Coastguard Worker }
244*35238bceSAndroid Build Coastguard Worker };
245*35238bceSAndroid Build Coastguard Worker
246*35238bceSAndroid Build Coastguard Worker class RboComponentSizeDepthCase : public ApiCase
247*35238bceSAndroid Build Coastguard Worker {
248*35238bceSAndroid Build Coastguard Worker public:
RboComponentSizeDepthCase(Context & context,const char * name,const char * description)249*35238bceSAndroid Build Coastguard Worker RboComponentSizeDepthCase(Context &context, const char *name, const char *description)
250*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
251*35238bceSAndroid Build Coastguard Worker {
252*35238bceSAndroid Build Coastguard Worker }
253*35238bceSAndroid Build Coastguard Worker
test(void)254*35238bceSAndroid Build Coastguard Worker void test(void)
255*35238bceSAndroid Build Coastguard Worker {
256*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
257*35238bceSAndroid Build Coastguard Worker
258*35238bceSAndroid Build Coastguard Worker GLuint renderbufferID = 0;
259*35238bceSAndroid Build Coastguard Worker glGenRenderbuffers(1, &renderbufferID);
260*35238bceSAndroid Build Coastguard Worker glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
261*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
262*35238bceSAndroid Build Coastguard Worker
263*35238bceSAndroid Build Coastguard Worker const struct DepthFormat
264*35238bceSAndroid Build Coastguard Worker {
265*35238bceSAndroid Build Coastguard Worker GLenum internalFormat;
266*35238bceSAndroid Build Coastguard Worker int dbits;
267*35238bceSAndroid Build Coastguard Worker int sbits;
268*35238bceSAndroid Build Coastguard Worker } requiredDepthFormats[] = {
269*35238bceSAndroid Build Coastguard Worker {GL_DEPTH_COMPONENT16, 16, 0}, {GL_DEPTH_COMPONENT24, 24, 0}, {GL_DEPTH_COMPONENT32F, 32, 0},
270*35238bceSAndroid Build Coastguard Worker {GL_DEPTH24_STENCIL8, 24, 8}, {GL_DEPTH32F_STENCIL8, 32, 8},
271*35238bceSAndroid Build Coastguard Worker };
272*35238bceSAndroid Build Coastguard Worker
273*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(requiredDepthFormats); ++ndx)
274*35238bceSAndroid Build Coastguard Worker {
275*35238bceSAndroid Build Coastguard Worker glRenderbufferStorage(GL_RENDERBUFFER, requiredDepthFormats[ndx].internalFormat, 128, 128);
276*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
277*35238bceSAndroid Build Coastguard Worker
278*35238bceSAndroid Build Coastguard Worker checkRenderbufferComponentSize(m_testCtx, *this, -1, -1, -1, -1, requiredDepthFormats[ndx].dbits,
279*35238bceSAndroid Build Coastguard Worker requiredDepthFormats[ndx].sbits);
280*35238bceSAndroid Build Coastguard Worker }
281*35238bceSAndroid Build Coastguard Worker
282*35238bceSAndroid Build Coastguard Worker // STENCIL_INDEX8 is required, in that case sBits >= 8
283*35238bceSAndroid Build Coastguard Worker {
284*35238bceSAndroid Build Coastguard Worker glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 128, 128);
285*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
286*35238bceSAndroid Build Coastguard Worker
287*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> state;
288*35238bceSAndroid Build Coastguard Worker glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_STENCIL_SIZE, &state);
289*35238bceSAndroid Build Coastguard Worker
290*35238bceSAndroid Build Coastguard Worker if (state.verifyValidity(m_testCtx) && state < 8)
291*35238bceSAndroid Build Coastguard Worker {
292*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected greater or equal to 8; got " << state
293*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
294*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
295*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
296*35238bceSAndroid Build Coastguard Worker }
297*35238bceSAndroid Build Coastguard Worker }
298*35238bceSAndroid Build Coastguard Worker
299*35238bceSAndroid Build Coastguard Worker glDeleteRenderbuffers(1, &renderbufferID);
300*35238bceSAndroid Build Coastguard Worker }
301*35238bceSAndroid Build Coastguard Worker };
302*35238bceSAndroid Build Coastguard Worker
303*35238bceSAndroid Build Coastguard Worker class RboSamplesCase : public ApiCase
304*35238bceSAndroid Build Coastguard Worker {
305*35238bceSAndroid Build Coastguard Worker public:
RboSamplesCase(Context & context,const char * name,const char * description)306*35238bceSAndroid Build Coastguard Worker RboSamplesCase(Context &context, const char *name, const char *description) : ApiCase(context, name, description)
307*35238bceSAndroid Build Coastguard Worker {
308*35238bceSAndroid Build Coastguard Worker }
309*35238bceSAndroid Build Coastguard Worker
test(void)310*35238bceSAndroid Build Coastguard Worker void test(void)
311*35238bceSAndroid Build Coastguard Worker {
312*35238bceSAndroid Build Coastguard Worker GLuint renderbufferID = 0;
313*35238bceSAndroid Build Coastguard Worker glGenRenderbuffers(1, &renderbufferID);
314*35238bceSAndroid Build Coastguard Worker glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
315*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
316*35238bceSAndroid Build Coastguard Worker
317*35238bceSAndroid Build Coastguard Worker checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_SAMPLES, 0);
318*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
319*35238bceSAndroid Build Coastguard Worker
320*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> max_samples;
321*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
322*35238bceSAndroid Build Coastguard Worker if (!max_samples.verifyValidity(m_testCtx))
323*35238bceSAndroid Build Coastguard Worker return;
324*35238bceSAndroid Build Coastguard Worker
325*35238bceSAndroid Build Coastguard Worker // 0 samples is a special case
326*35238bceSAndroid Build Coastguard Worker {
327*35238bceSAndroid Build Coastguard Worker glRenderbufferStorageMultisample(GL_RENDERBUFFER, 0, GL_RGBA8, 128, 128);
328*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
329*35238bceSAndroid Build Coastguard Worker
330*35238bceSAndroid Build Coastguard Worker checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_SAMPLES, 0);
331*35238bceSAndroid Build Coastguard Worker }
332*35238bceSAndroid Build Coastguard Worker
333*35238bceSAndroid Build Coastguard Worker // test [1, n] samples
334*35238bceSAndroid Build Coastguard Worker for (int samples = 1; samples <= max_samples; ++samples)
335*35238bceSAndroid Build Coastguard Worker {
336*35238bceSAndroid Build Coastguard Worker glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_RGBA8, 128, 128);
337*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
338*35238bceSAndroid Build Coastguard Worker
339*35238bceSAndroid Build Coastguard Worker checkRenderbufferParamGreaterOrEqual(m_testCtx, *this, GL_RENDERBUFFER_SAMPLES, samples);
340*35238bceSAndroid Build Coastguard Worker }
341*35238bceSAndroid Build Coastguard Worker
342*35238bceSAndroid Build Coastguard Worker glDeleteRenderbuffers(1, &renderbufferID);
343*35238bceSAndroid Build Coastguard Worker }
344*35238bceSAndroid Build Coastguard Worker };
345*35238bceSAndroid Build Coastguard Worker
346*35238bceSAndroid Build Coastguard Worker } // namespace
347*35238bceSAndroid Build Coastguard Worker
RboStateQueryTests(Context & context)348*35238bceSAndroid Build Coastguard Worker RboStateQueryTests::RboStateQueryTests(Context &context) : TestCaseGroup(context, "rbo", "Rbo State Query tests")
349*35238bceSAndroid Build Coastguard Worker {
350*35238bceSAndroid Build Coastguard Worker }
351*35238bceSAndroid Build Coastguard Worker
init(void)352*35238bceSAndroid Build Coastguard Worker void RboStateQueryTests::init(void)
353*35238bceSAndroid Build Coastguard Worker {
354*35238bceSAndroid Build Coastguard Worker addChild(new RboSizeCase(m_context, "renderbuffer_size", "RENDERBUFFER_WIDTH and RENDERBUFFER_HEIGHT"));
355*35238bceSAndroid Build Coastguard Worker addChild(new RboInternalFormatCase(m_context, "renderbuffer_internal_format", "RENDERBUFFER_INTERNAL_FORMAT"));
356*35238bceSAndroid Build Coastguard Worker addChild(new RboComponentSizeColorCase(m_context, "renderbuffer_component_size_color", "RENDERBUFFER_x_SIZE"));
357*35238bceSAndroid Build Coastguard Worker addChild(new RboComponentSizeDepthCase(m_context, "renderbuffer_component_size_depth", "RENDERBUFFER_x_SIZE"));
358*35238bceSAndroid Build Coastguard Worker addChild(new RboSamplesCase(m_context, "renderbuffer_samples", "RENDERBUFFER_SAMPLES"));
359*35238bceSAndroid Build Coastguard Worker }
360*35238bceSAndroid Build Coastguard Worker
361*35238bceSAndroid Build Coastguard Worker } // namespace Functional
362*35238bceSAndroid Build Coastguard Worker } // namespace gles3
363*35238bceSAndroid Build Coastguard Worker } // namespace deqp
364