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 Internal Format Query tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es3fInternalFormatQueryTests.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 "deMath.h"
31*35238bceSAndroid Build Coastguard Worker
32*35238bceSAndroid Build Coastguard Worker using namespace glw; // GLint and other GL types
33*35238bceSAndroid Build Coastguard Worker using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker namespace deqp
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker namespace gles3
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker namespace Functional
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker namespace
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker
44*35238bceSAndroid Build Coastguard Worker class SamplesCase : public ApiCase
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker public:
SamplesCase(Context & context,const char * name,const char * description,GLenum internalFormat,bool isIntegerInternalFormat)47*35238bceSAndroid Build Coastguard Worker SamplesCase(Context &context, const char *name, const char *description, GLenum internalFormat,
48*35238bceSAndroid Build Coastguard Worker bool isIntegerInternalFormat)
49*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
50*35238bceSAndroid Build Coastguard Worker , m_internalFormat(internalFormat)
51*35238bceSAndroid Build Coastguard Worker , m_isIntegerInternalFormat(isIntegerInternalFormat)
52*35238bceSAndroid Build Coastguard Worker {
53*35238bceSAndroid Build Coastguard Worker }
54*35238bceSAndroid Build Coastguard Worker
test(void)55*35238bceSAndroid Build Coastguard Worker void test(void)
56*35238bceSAndroid Build Coastguard Worker {
57*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
58*35238bceSAndroid Build Coastguard Worker
59*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> sampleCounts;
60*35238bceSAndroid Build Coastguard Worker glGetInternalformativ(GL_RENDERBUFFER, m_internalFormat, GL_NUM_SAMPLE_COUNTS, 1, &sampleCounts);
61*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
62*35238bceSAndroid Build Coastguard Worker
63*35238bceSAndroid Build Coastguard Worker if (!sampleCounts.verifyValidity(m_testCtx))
64*35238bceSAndroid Build Coastguard Worker return;
65*35238bceSAndroid Build Coastguard Worker
66*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// sample counts is " << sampleCounts << TestLog::EndMessage;
67*35238bceSAndroid Build Coastguard Worker
68*35238bceSAndroid Build Coastguard Worker if (sampleCounts == 0)
69*35238bceSAndroid Build Coastguard Worker return;
70*35238bceSAndroid Build Coastguard Worker
71*35238bceSAndroid Build Coastguard Worker std::vector<GLint> samples;
72*35238bceSAndroid Build Coastguard Worker samples.resize(sampleCounts, -1);
73*35238bceSAndroid Build Coastguard Worker glGetInternalformativ(GL_RENDERBUFFER, m_internalFormat, GL_SAMPLES, sampleCounts, &samples[0]);
74*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
75*35238bceSAndroid Build Coastguard Worker
76*35238bceSAndroid Build Coastguard Worker GLint prevSampleCount = 0;
77*35238bceSAndroid Build Coastguard Worker GLint sampleCount = 0;
78*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < samples.size(); ++ndx, prevSampleCount = sampleCount)
79*35238bceSAndroid Build Coastguard Worker {
80*35238bceSAndroid Build Coastguard Worker sampleCount = samples[ndx];
81*35238bceSAndroid Build Coastguard Worker
82*35238bceSAndroid Build Coastguard Worker // sample count must be > 0
83*35238bceSAndroid Build Coastguard Worker if (sampleCount <= 0)
84*35238bceSAndroid Build Coastguard Worker {
85*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected sample count to be at least one; got "
86*35238bceSAndroid Build Coastguard Worker << sampleCount << TestLog::EndMessage;
87*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
88*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
89*35238bceSAndroid Build Coastguard Worker }
90*35238bceSAndroid Build Coastguard Worker
91*35238bceSAndroid Build Coastguard Worker // samples must be ordered descending
92*35238bceSAndroid Build Coastguard Worker if (ndx != 0 && !(sampleCount < prevSampleCount))
93*35238bceSAndroid Build Coastguard Worker {
94*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message
95*35238bceSAndroid Build Coastguard Worker << "// ERROR: Expected sample count to be ordered in descending order;"
96*35238bceSAndroid Build Coastguard Worker << "got " << prevSampleCount << " at index " << (ndx - 1) << ", and " << sampleCount
97*35238bceSAndroid Build Coastguard Worker << " at index " << ndx << TestLog::EndMessage;
98*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
99*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid order");
100*35238bceSAndroid Build Coastguard Worker }
101*35238bceSAndroid Build Coastguard Worker }
102*35238bceSAndroid Build Coastguard Worker
103*35238bceSAndroid Build Coastguard Worker if (!m_isIntegerInternalFormat)
104*35238bceSAndroid Build Coastguard Worker {
105*35238bceSAndroid Build Coastguard Worker // the maximum value in SAMPLES is guaranteed to be at least the value of MAX_SAMPLES
106*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> maxSamples;
107*35238bceSAndroid Build Coastguard Worker glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
108*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
109*35238bceSAndroid Build Coastguard Worker
110*35238bceSAndroid Build Coastguard Worker if (maxSamples.verifyValidity(m_testCtx))
111*35238bceSAndroid Build Coastguard Worker {
112*35238bceSAndroid Build Coastguard Worker const GLint maximumFormatSampleCount = samples[0];
113*35238bceSAndroid Build Coastguard Worker if (!(maximumFormatSampleCount >= maxSamples))
114*35238bceSAndroid Build Coastguard Worker {
115*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected maximum value in SAMPLES ("
116*35238bceSAndroid Build Coastguard Worker << maximumFormatSampleCount << ") to be at least the value of MAX_SAMPLES ("
117*35238bceSAndroid Build Coastguard Worker << maxSamples << ")" << TestLog::EndMessage;
118*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
119*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid maximum sample count");
120*35238bceSAndroid Build Coastguard Worker }
121*35238bceSAndroid Build Coastguard Worker }
122*35238bceSAndroid Build Coastguard Worker }
123*35238bceSAndroid Build Coastguard Worker }
124*35238bceSAndroid Build Coastguard Worker
125*35238bceSAndroid Build Coastguard Worker private:
126*35238bceSAndroid Build Coastguard Worker const GLenum m_internalFormat;
127*35238bceSAndroid Build Coastguard Worker const bool m_isIntegerInternalFormat;
128*35238bceSAndroid Build Coastguard Worker };
129*35238bceSAndroid Build Coastguard Worker
130*35238bceSAndroid Build Coastguard Worker class SamplesBufferSizeCase : public ApiCase
131*35238bceSAndroid Build Coastguard Worker {
132*35238bceSAndroid Build Coastguard Worker public:
SamplesBufferSizeCase(Context & context,const char * name,const char * description,GLenum internalFormat)133*35238bceSAndroid Build Coastguard Worker SamplesBufferSizeCase(Context &context, const char *name, const char *description, GLenum internalFormat)
134*35238bceSAndroid Build Coastguard Worker : ApiCase(context, name, description)
135*35238bceSAndroid Build Coastguard Worker , m_internalFormat(internalFormat)
136*35238bceSAndroid Build Coastguard Worker {
137*35238bceSAndroid Build Coastguard Worker }
138*35238bceSAndroid Build Coastguard Worker
test(void)139*35238bceSAndroid Build Coastguard Worker void test(void)
140*35238bceSAndroid Build Coastguard Worker {
141*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
142*35238bceSAndroid Build Coastguard Worker
143*35238bceSAndroid Build Coastguard Worker StateQueryMemoryWriteGuard<GLint> sampleCounts;
144*35238bceSAndroid Build Coastguard Worker glGetInternalformativ(GL_RENDERBUFFER, m_internalFormat, GL_NUM_SAMPLE_COUNTS, 1, &sampleCounts);
145*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
146*35238bceSAndroid Build Coastguard Worker
147*35238bceSAndroid Build Coastguard Worker if (!sampleCounts.verifyValidity(m_testCtx))
148*35238bceSAndroid Build Coastguard Worker return;
149*35238bceSAndroid Build Coastguard Worker
150*35238bceSAndroid Build Coastguard Worker // test with bufSize = 0
151*35238bceSAndroid Build Coastguard Worker GLint queryTargetValue = -1;
152*35238bceSAndroid Build Coastguard Worker glGetInternalformativ(GL_RENDERBUFFER, m_internalFormat, GL_NUM_SAMPLE_COUNTS, 0, &queryTargetValue);
153*35238bceSAndroid Build Coastguard Worker expectError(GL_NO_ERROR);
154*35238bceSAndroid Build Coastguard Worker
155*35238bceSAndroid Build Coastguard Worker if (queryTargetValue != -1)
156*35238bceSAndroid Build Coastguard Worker {
157*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected output variable not to be written to."
158*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
159*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
160*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid write");
161*35238bceSAndroid Build Coastguard Worker }
162*35238bceSAndroid Build Coastguard Worker }
163*35238bceSAndroid Build Coastguard Worker
164*35238bceSAndroid Build Coastguard Worker private:
165*35238bceSAndroid Build Coastguard Worker GLenum m_internalFormat;
166*35238bceSAndroid Build Coastguard Worker };
167*35238bceSAndroid Build Coastguard Worker
168*35238bceSAndroid Build Coastguard Worker } // namespace
169*35238bceSAndroid Build Coastguard Worker
InternalFormatQueryTests(Context & context)170*35238bceSAndroid Build Coastguard Worker InternalFormatQueryTests::InternalFormatQueryTests(Context &context)
171*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "internal_format", "Internal Format Query tests.")
172*35238bceSAndroid Build Coastguard Worker {
173*35238bceSAndroid Build Coastguard Worker }
174*35238bceSAndroid Build Coastguard Worker
init(void)175*35238bceSAndroid Build Coastguard Worker void InternalFormatQueryTests::init(void)
176*35238bceSAndroid Build Coastguard Worker {
177*35238bceSAndroid Build Coastguard Worker const struct InternalFormat
178*35238bceSAndroid Build Coastguard Worker {
179*35238bceSAndroid Build Coastguard Worker const char *name;
180*35238bceSAndroid Build Coastguard Worker GLenum format;
181*35238bceSAndroid Build Coastguard Worker bool isIntegerFormat;
182*35238bceSAndroid Build Coastguard Worker } internalFormats[] = {
183*35238bceSAndroid Build Coastguard Worker // color renderable
184*35238bceSAndroid Build Coastguard Worker {"r8", GL_R8, false},
185*35238bceSAndroid Build Coastguard Worker {"rg8", GL_RG8, false},
186*35238bceSAndroid Build Coastguard Worker {"rgb8", GL_RGB8, false},
187*35238bceSAndroid Build Coastguard Worker {"rgb565", GL_RGB565, false},
188*35238bceSAndroid Build Coastguard Worker {"rgba4", GL_RGBA4, false},
189*35238bceSAndroid Build Coastguard Worker {"rgb5_a1", GL_RGB5_A1, false},
190*35238bceSAndroid Build Coastguard Worker {"rgba8", GL_RGBA8, false},
191*35238bceSAndroid Build Coastguard Worker {"rgb10_a2", GL_RGB10_A2, false},
192*35238bceSAndroid Build Coastguard Worker {"rgb10_a2ui", GL_RGB10_A2UI, true},
193*35238bceSAndroid Build Coastguard Worker {"srgb8_alpha8", GL_SRGB8_ALPHA8, false},
194*35238bceSAndroid Build Coastguard Worker {"r8i", GL_R8I, true},
195*35238bceSAndroid Build Coastguard Worker {"r8ui", GL_R8UI, true},
196*35238bceSAndroid Build Coastguard Worker {"r16i", GL_R16I, true},
197*35238bceSAndroid Build Coastguard Worker {"r16ui", GL_R16UI, true},
198*35238bceSAndroid Build Coastguard Worker {"r32i", GL_R32I, true},
199*35238bceSAndroid Build Coastguard Worker {"r32ui", GL_R32UI, true},
200*35238bceSAndroid Build Coastguard Worker {"rg8i", GL_RG8I, true},
201*35238bceSAndroid Build Coastguard Worker {"rg8ui", GL_RG8UI, true},
202*35238bceSAndroid Build Coastguard Worker {"rg16i", GL_RG16I, true},
203*35238bceSAndroid Build Coastguard Worker {"rg16ui", GL_RG16UI, true},
204*35238bceSAndroid Build Coastguard Worker {"rg32i", GL_RG32I, true},
205*35238bceSAndroid Build Coastguard Worker {"rg32ui", GL_RG32UI, true},
206*35238bceSAndroid Build Coastguard Worker {"rgba8i", GL_RGBA8I, true},
207*35238bceSAndroid Build Coastguard Worker {"rgba8ui", GL_RGBA8UI, true},
208*35238bceSAndroid Build Coastguard Worker {"rgba16i", GL_RGBA16I, true},
209*35238bceSAndroid Build Coastguard Worker {"rgba16ui", GL_RGBA16UI, true},
210*35238bceSAndroid Build Coastguard Worker {"rgba32i", GL_RGBA32I, true},
211*35238bceSAndroid Build Coastguard Worker {"rgba32ui", GL_RGBA32UI, true},
212*35238bceSAndroid Build Coastguard Worker
213*35238bceSAndroid Build Coastguard Worker // depth renderable
214*35238bceSAndroid Build Coastguard Worker {"depth_component16", GL_DEPTH_COMPONENT16, false},
215*35238bceSAndroid Build Coastguard Worker {"depth_component24", GL_DEPTH_COMPONENT24, false},
216*35238bceSAndroid Build Coastguard Worker {"depth_component32f", GL_DEPTH_COMPONENT32F, false},
217*35238bceSAndroid Build Coastguard Worker {"depth24_stencil8", GL_DEPTH24_STENCIL8, false},
218*35238bceSAndroid Build Coastguard Worker {"depth32f_stencil8", GL_DEPTH32F_STENCIL8, false},
219*35238bceSAndroid Build Coastguard Worker
220*35238bceSAndroid Build Coastguard Worker // stencil renderable
221*35238bceSAndroid Build Coastguard Worker {"stencil_index8", GL_STENCIL_INDEX8, false}
222*35238bceSAndroid Build Coastguard Worker // DEPTH24_STENCIL8, duplicate
223*35238bceSAndroid Build Coastguard Worker // DEPTH32F_STENCIL8 duplicate
224*35238bceSAndroid Build Coastguard Worker };
225*35238bceSAndroid Build Coastguard Worker
226*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(internalFormats); ++ndx)
227*35238bceSAndroid Build Coastguard Worker {
228*35238bceSAndroid Build Coastguard Worker const InternalFormat internalFormat = internalFormats[ndx];
229*35238bceSAndroid Build Coastguard Worker
230*35238bceSAndroid Build Coastguard Worker addChild(new SamplesCase(m_context, (std::string(internalFormat.name) + "_samples").c_str(),
231*35238bceSAndroid Build Coastguard Worker "SAMPLES and NUM_SAMPLE_COUNTS", internalFormat.format,
232*35238bceSAndroid Build Coastguard Worker internalFormat.isIntegerFormat));
233*35238bceSAndroid Build Coastguard Worker }
234*35238bceSAndroid Build Coastguard Worker
235*35238bceSAndroid Build Coastguard Worker addChild(new SamplesBufferSizeCase(m_context, "rgba8_samples_buffer", "SAMPLES bufSize parameter", GL_RGBA8));
236*35238bceSAndroid Build Coastguard Worker }
237*35238bceSAndroid Build Coastguard Worker
238*35238bceSAndroid Build Coastguard Worker } // namespace Functional
239*35238bceSAndroid Build Coastguard Worker } // namespace gles3
240*35238bceSAndroid Build Coastguard Worker } // namespace deqp
241