xref: /aosp_15_r20/external/deqp/modules/gles3/functional/es3fTextureFormatTests.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 Texture format tests.
22*35238bceSAndroid Build Coastguard Worker  *
23*35238bceSAndroid Build Coastguard Worker  * Constants:
24*35238bceSAndroid Build Coastguard Worker  *  + nearest-neighbor filtering
25*35238bceSAndroid Build Coastguard Worker  *  + no mipmaps
26*35238bceSAndroid Build Coastguard Worker  *  + full texture coordinate range (but not outside) tested
27*35238bceSAndroid Build Coastguard Worker  *  + accessed from fragment shader
28*35238bceSAndroid Build Coastguard Worker  *  + texture unit 0
29*35238bceSAndroid Build Coastguard Worker  *  + named texture object
30*35238bceSAndroid Build Coastguard Worker  *
31*35238bceSAndroid Build Coastguard Worker  * Variables:
32*35238bceSAndroid Build Coastguard Worker  *  + texture format
33*35238bceSAndroid Build Coastguard Worker  *  + texture type: 2D or cubemap
34*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
35*35238bceSAndroid Build Coastguard Worker 
36*35238bceSAndroid Build Coastguard Worker #include "es3fTextureFormatTests.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "gluTexture.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "gluTextureUtil.hpp"
41*35238bceSAndroid Build Coastguard Worker #include "glsTextureTestUtil.hpp"
42*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
43*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
44*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
45*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
46*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
47*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
48*35238bceSAndroid Build Coastguard Worker #include "deUniquePtr.hpp"
49*35238bceSAndroid Build Coastguard Worker 
50*35238bceSAndroid Build Coastguard Worker using std::string;
51*35238bceSAndroid Build Coastguard Worker using std::vector;
52*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
53*35238bceSAndroid Build Coastguard Worker 
54*35238bceSAndroid Build Coastguard Worker using de::MovePtr;
55*35238bceSAndroid Build Coastguard Worker using glu::ContextInfo;
56*35238bceSAndroid Build Coastguard Worker 
57*35238bceSAndroid Build Coastguard Worker namespace deqp
58*35238bceSAndroid Build Coastguard Worker {
59*35238bceSAndroid Build Coastguard Worker namespace gles3
60*35238bceSAndroid Build Coastguard Worker {
61*35238bceSAndroid Build Coastguard Worker namespace Functional
62*35238bceSAndroid Build Coastguard Worker {
63*35238bceSAndroid Build Coastguard Worker 
64*35238bceSAndroid Build Coastguard Worker using namespace deqp::gls;
65*35238bceSAndroid Build Coastguard Worker using namespace deqp::gls::TextureTestUtil;
66*35238bceSAndroid Build Coastguard Worker using namespace glu::TextureTestUtil;
67*35238bceSAndroid Build Coastguard Worker using tcu::Sampler;
68*35238bceSAndroid Build Coastguard Worker 
69*35238bceSAndroid Build Coastguard Worker namespace
70*35238bceSAndroid Build Coastguard Worker {
71*35238bceSAndroid Build Coastguard Worker 
checkSupport(const glu::ContextInfo & info,uint32_t internalFormat)72*35238bceSAndroid Build Coastguard Worker void checkSupport(const glu::ContextInfo &info, uint32_t internalFormat)
73*35238bceSAndroid Build Coastguard Worker {
74*35238bceSAndroid Build Coastguard Worker     if (internalFormat == GL_SR8_EXT && !info.isExtensionSupported("GL_EXT_texture_sRGB_R8"))
75*35238bceSAndroid Build Coastguard Worker         TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_R8 is not supported.");
76*35238bceSAndroid Build Coastguard Worker 
77*35238bceSAndroid Build Coastguard Worker     if (internalFormat == GL_SRG8_EXT && !info.isExtensionSupported("GL_EXT_texture_sRGB_RG8"))
78*35238bceSAndroid Build Coastguard Worker         TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_RG8 is not supported.");
79*35238bceSAndroid Build Coastguard Worker }
80*35238bceSAndroid Build Coastguard Worker 
81*35238bceSAndroid Build Coastguard Worker } // namespace
82*35238bceSAndroid Build Coastguard Worker 
83*35238bceSAndroid Build Coastguard Worker // Texture2DFormatCase
84*35238bceSAndroid Build Coastguard Worker 
85*35238bceSAndroid Build Coastguard Worker class Texture2DFormatCase : public tcu::TestCase
86*35238bceSAndroid Build Coastguard Worker {
87*35238bceSAndroid Build Coastguard Worker public:
88*35238bceSAndroid Build Coastguard Worker     Texture2DFormatCase(tcu::TestContext &testCtx, Context &context, const char *name, const char *description,
89*35238bceSAndroid Build Coastguard Worker                         uint32_t format, uint32_t dataType, int width, int height);
90*35238bceSAndroid Build Coastguard Worker     Texture2DFormatCase(tcu::TestContext &testCtx, Context &context, const char *name, const char *description,
91*35238bceSAndroid Build Coastguard Worker                         uint32_t internalFormat, int width, int height);
92*35238bceSAndroid Build Coastguard Worker     ~Texture2DFormatCase(void);
93*35238bceSAndroid Build Coastguard Worker 
94*35238bceSAndroid Build Coastguard Worker     void init(void);
95*35238bceSAndroid Build Coastguard Worker     void deinit(void);
96*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
97*35238bceSAndroid Build Coastguard Worker 
98*35238bceSAndroid Build Coastguard Worker private:
99*35238bceSAndroid Build Coastguard Worker     Texture2DFormatCase(const Texture2DFormatCase &other);
100*35238bceSAndroid Build Coastguard Worker     Texture2DFormatCase &operator=(const Texture2DFormatCase &other);
101*35238bceSAndroid Build Coastguard Worker 
102*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
103*35238bceSAndroid Build Coastguard Worker     const glu::ContextInfo &m_renderCtxInfo;
104*35238bceSAndroid Build Coastguard Worker 
105*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
106*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
107*35238bceSAndroid Build Coastguard Worker     int m_width;
108*35238bceSAndroid Build Coastguard Worker     int m_height;
109*35238bceSAndroid Build Coastguard Worker 
110*35238bceSAndroid Build Coastguard Worker     glu::Texture2D *m_texture;
111*35238bceSAndroid Build Coastguard Worker     TextureRenderer m_renderer;
112*35238bceSAndroid Build Coastguard Worker };
113*35238bceSAndroid Build Coastguard Worker 
Texture2DFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,uint32_t format,uint32_t dataType,int width,int height)114*35238bceSAndroid Build Coastguard Worker Texture2DFormatCase::Texture2DFormatCase(tcu::TestContext &testCtx, Context &context, const char *name,
115*35238bceSAndroid Build Coastguard Worker                                          const char *description, uint32_t format, uint32_t dataType, int width,
116*35238bceSAndroid Build Coastguard Worker                                          int height)
117*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
118*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(context.getRenderContext())
119*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(context.getContextInfo())
120*35238bceSAndroid Build Coastguard Worker     , m_format(format)
121*35238bceSAndroid Build Coastguard Worker     , m_dataType(dataType)
122*35238bceSAndroid Build Coastguard Worker     , m_width(width)
123*35238bceSAndroid Build Coastguard Worker     , m_height(height)
124*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
125*35238bceSAndroid Build Coastguard Worker     , m_renderer(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
126*35238bceSAndroid Build Coastguard Worker {
127*35238bceSAndroid Build Coastguard Worker }
128*35238bceSAndroid Build Coastguard Worker 
Texture2DFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,uint32_t internalFormat,int width,int height)129*35238bceSAndroid Build Coastguard Worker Texture2DFormatCase::Texture2DFormatCase(tcu::TestContext &testCtx, Context &context, const char *name,
130*35238bceSAndroid Build Coastguard Worker                                          const char *description, uint32_t internalFormat, int width, int height)
131*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
132*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(context.getRenderContext())
133*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(context.getContextInfo())
134*35238bceSAndroid Build Coastguard Worker     , m_format(internalFormat)
135*35238bceSAndroid Build Coastguard Worker     , m_dataType(GL_NONE)
136*35238bceSAndroid Build Coastguard Worker     , m_width(width)
137*35238bceSAndroid Build Coastguard Worker     , m_height(height)
138*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
139*35238bceSAndroid Build Coastguard Worker     , m_renderer(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
140*35238bceSAndroid Build Coastguard Worker {
141*35238bceSAndroid Build Coastguard Worker }
142*35238bceSAndroid Build Coastguard Worker 
~Texture2DFormatCase(void)143*35238bceSAndroid Build Coastguard Worker Texture2DFormatCase::~Texture2DFormatCase(void)
144*35238bceSAndroid Build Coastguard Worker {
145*35238bceSAndroid Build Coastguard Worker     deinit();
146*35238bceSAndroid Build Coastguard Worker }
147*35238bceSAndroid Build Coastguard Worker 
init(void)148*35238bceSAndroid Build Coastguard Worker void Texture2DFormatCase::init(void)
149*35238bceSAndroid Build Coastguard Worker {
150*35238bceSAndroid Build Coastguard Worker     checkSupport(m_renderCtxInfo, m_format);
151*35238bceSAndroid Build Coastguard Worker 
152*35238bceSAndroid Build Coastguard Worker     TestLog &log = m_testCtx.getLog();
153*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormat fmt =
154*35238bceSAndroid Build Coastguard Worker         m_dataType ? glu::mapGLTransferFormat(m_format, m_dataType) : glu::mapGLInternalFormat(m_format);
155*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(fmt);
156*35238bceSAndroid Build Coastguard Worker     std::ostringstream fmtName;
157*35238bceSAndroid Build Coastguard Worker 
158*35238bceSAndroid Build Coastguard Worker     if (m_dataType)
159*35238bceSAndroid Build Coastguard Worker         fmtName << glu::getTextureFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType);
160*35238bceSAndroid Build Coastguard Worker     else
161*35238bceSAndroid Build Coastguard Worker         fmtName << glu::getTextureFormatStr(m_format);
162*35238bceSAndroid Build Coastguard Worker 
163*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "2D texture, " << fmtName.str() << ", " << m_width << "x" << m_height
164*35238bceSAndroid Build Coastguard Worker         << ",\n  fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient" << TestLog::EndMessage;
165*35238bceSAndroid Build Coastguard Worker 
166*35238bceSAndroid Build Coastguard Worker     m_texture =
167*35238bceSAndroid Build Coastguard Worker         m_dataType != GL_NONE ?
168*35238bceSAndroid Build Coastguard Worker             new glu::Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height) // Implicit internal format.
169*35238bceSAndroid Build Coastguard Worker             :
170*35238bceSAndroid Build Coastguard Worker             new glu::Texture2D(m_renderCtx, m_format, m_width, m_height); // Explicit internal format.
171*35238bceSAndroid Build Coastguard Worker 
172*35238bceSAndroid Build Coastguard Worker     // Fill level 0.
173*35238bceSAndroid Build Coastguard Worker     m_texture->getRefTexture().allocLevel(0);
174*35238bceSAndroid Build Coastguard Worker     tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
175*35238bceSAndroid Build Coastguard Worker }
176*35238bceSAndroid Build Coastguard Worker 
deinit(void)177*35238bceSAndroid Build Coastguard Worker void Texture2DFormatCase::deinit(void)
178*35238bceSAndroid Build Coastguard Worker {
179*35238bceSAndroid Build Coastguard Worker     delete m_texture;
180*35238bceSAndroid Build Coastguard Worker     m_texture = DE_NULL;
181*35238bceSAndroid Build Coastguard Worker 
182*35238bceSAndroid Build Coastguard Worker     m_renderer.clear();
183*35238bceSAndroid Build Coastguard Worker }
184*35238bceSAndroid Build Coastguard Worker 
iterate(void)185*35238bceSAndroid Build Coastguard Worker Texture2DFormatCase::IterateResult Texture2DFormatCase::iterate(void)
186*35238bceSAndroid Build Coastguard Worker {
187*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
188*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
189*35238bceSAndroid Build Coastguard Worker     RandomViewport viewport(m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName()));
190*35238bceSAndroid Build Coastguard Worker     tcu::Surface renderedFrame(viewport.width, viewport.height);
191*35238bceSAndroid Build Coastguard Worker     tcu::Surface referenceFrame(viewport.width, viewport.height);
192*35238bceSAndroid Build Coastguard Worker     tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1, 1, 1, 1);
193*35238bceSAndroid Build Coastguard Worker     vector<float> texCoord;
194*35238bceSAndroid Build Coastguard Worker     ReferenceParams renderParams(TEXTURETYPE_2D);
195*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
196*35238bceSAndroid Build Coastguard Worker     const uint32_t wrapS        = GL_CLAMP_TO_EDGE;
197*35238bceSAndroid Build Coastguard Worker     const uint32_t wrapT        = GL_CLAMP_TO_EDGE;
198*35238bceSAndroid Build Coastguard Worker     const uint32_t minFilter    = GL_NEAREST;
199*35238bceSAndroid Build Coastguard Worker     const uint32_t magFilter    = GL_NEAREST;
200*35238bceSAndroid Build Coastguard Worker 
201*35238bceSAndroid Build Coastguard Worker     renderParams.flags |= RenderParams::LOG_ALL;
202*35238bceSAndroid Build Coastguard Worker     renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat());
203*35238bceSAndroid Build Coastguard Worker     renderParams.sampler     = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE,
204*35238bceSAndroid Build Coastguard Worker                                        Sampler::NEAREST, Sampler::NEAREST);
205*35238bceSAndroid Build Coastguard Worker     renderParams.colorScale  = spec.lookupScale;
206*35238bceSAndroid Build Coastguard Worker     renderParams.colorBias   = spec.lookupBias;
207*35238bceSAndroid Build Coastguard Worker 
208*35238bceSAndroid Build Coastguard Worker     computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
209*35238bceSAndroid Build Coastguard Worker 
210*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Texture parameters:"
211*35238bceSAndroid Build Coastguard Worker         << "\n  WRAP_S = " << glu::getTextureParameterValueStr(GL_TEXTURE_WRAP_S, wrapS)
212*35238bceSAndroid Build Coastguard Worker         << "\n  WRAP_T = " << glu::getTextureParameterValueStr(GL_TEXTURE_WRAP_T, wrapT)
213*35238bceSAndroid Build Coastguard Worker         << "\n  MIN_FILTER = " << glu::getTextureParameterValueStr(GL_TEXTURE_MIN_FILTER, minFilter)
214*35238bceSAndroid Build Coastguard Worker         << "\n  MAG_FILTER = " << glu::getTextureParameterValueStr(GL_TEXTURE_MAG_FILTER, magFilter)
215*35238bceSAndroid Build Coastguard Worker         << TestLog::EndMessage;
216*35238bceSAndroid Build Coastguard Worker 
217*35238bceSAndroid Build Coastguard Worker     // Setup base viewport.
218*35238bceSAndroid Build Coastguard Worker     gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
219*35238bceSAndroid Build Coastguard Worker 
220*35238bceSAndroid Build Coastguard Worker     // Upload texture data to GL.
221*35238bceSAndroid Build Coastguard Worker     m_texture->upload();
222*35238bceSAndroid Build Coastguard Worker 
223*35238bceSAndroid Build Coastguard Worker     // Bind to unit 0.
224*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
225*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
226*35238bceSAndroid Build Coastguard Worker 
227*35238bceSAndroid Build Coastguard Worker     // Setup nearest neighbor filtering and clamp-to-edge.
228*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS);
229*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT);
230*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
231*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter);
232*35238bceSAndroid Build Coastguard Worker 
233*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
234*35238bceSAndroid Build Coastguard Worker 
235*35238bceSAndroid Build Coastguard Worker     // Draw.
236*35238bceSAndroid Build Coastguard Worker     m_renderer.renderQuad(0, &texCoord[0], renderParams);
237*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
238*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
239*35238bceSAndroid Build Coastguard Worker 
240*35238bceSAndroid Build Coastguard Worker     // Compute reference.
241*35238bceSAndroid Build Coastguard Worker     sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()),
242*35238bceSAndroid Build Coastguard Worker                   m_texture->getRefTexture(), &texCoord[0], renderParams);
243*35238bceSAndroid Build Coastguard Worker 
244*35238bceSAndroid Build Coastguard Worker     // Compare and log.
245*35238bceSAndroid Build Coastguard Worker     bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold);
246*35238bceSAndroid Build Coastguard Worker 
247*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
248*35238bceSAndroid Build Coastguard Worker                             isOk ? "Pass" : "Image comparison failed");
249*35238bceSAndroid Build Coastguard Worker 
250*35238bceSAndroid Build Coastguard Worker     return STOP;
251*35238bceSAndroid Build Coastguard Worker }
252*35238bceSAndroid Build Coastguard Worker 
253*35238bceSAndroid Build Coastguard Worker // TextureCubeFormatCase
254*35238bceSAndroid Build Coastguard Worker 
255*35238bceSAndroid Build Coastguard Worker class TextureCubeFormatCase : public tcu::TestCase
256*35238bceSAndroid Build Coastguard Worker {
257*35238bceSAndroid Build Coastguard Worker public:
258*35238bceSAndroid Build Coastguard Worker     TextureCubeFormatCase(tcu::TestContext &testCtx, Context &context, const char *name, const char *description,
259*35238bceSAndroid Build Coastguard Worker                           uint32_t format, uint32_t dataType, int width, int height);
260*35238bceSAndroid Build Coastguard Worker     TextureCubeFormatCase(tcu::TestContext &testCtx, Context &context, const char *name, const char *description,
261*35238bceSAndroid Build Coastguard Worker                           uint32_t internalFormat, int width, int height);
262*35238bceSAndroid Build Coastguard Worker     ~TextureCubeFormatCase(void);
263*35238bceSAndroid Build Coastguard Worker 
264*35238bceSAndroid Build Coastguard Worker     void init(void);
265*35238bceSAndroid Build Coastguard Worker     void deinit(void);
266*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
267*35238bceSAndroid Build Coastguard Worker 
268*35238bceSAndroid Build Coastguard Worker private:
269*35238bceSAndroid Build Coastguard Worker     TextureCubeFormatCase(const TextureCubeFormatCase &other);
270*35238bceSAndroid Build Coastguard Worker     TextureCubeFormatCase &operator=(const TextureCubeFormatCase &other);
271*35238bceSAndroid Build Coastguard Worker 
272*35238bceSAndroid Build Coastguard Worker     bool testFace(tcu::CubeFace face);
273*35238bceSAndroid Build Coastguard Worker 
274*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
275*35238bceSAndroid Build Coastguard Worker     const glu::ContextInfo &m_renderCtxInfo;
276*35238bceSAndroid Build Coastguard Worker 
277*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
278*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
279*35238bceSAndroid Build Coastguard Worker     int m_width;
280*35238bceSAndroid Build Coastguard Worker     int m_height;
281*35238bceSAndroid Build Coastguard Worker 
282*35238bceSAndroid Build Coastguard Worker     glu::TextureCube *m_texture;
283*35238bceSAndroid Build Coastguard Worker     TextureRenderer m_renderer;
284*35238bceSAndroid Build Coastguard Worker 
285*35238bceSAndroid Build Coastguard Worker     int m_curFace;
286*35238bceSAndroid Build Coastguard Worker     bool m_isOk;
287*35238bceSAndroid Build Coastguard Worker };
288*35238bceSAndroid Build Coastguard Worker 
TextureCubeFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,uint32_t format,uint32_t dataType,int width,int height)289*35238bceSAndroid Build Coastguard Worker TextureCubeFormatCase::TextureCubeFormatCase(tcu::TestContext &testCtx, Context &context, const char *name,
290*35238bceSAndroid Build Coastguard Worker                                              const char *description, uint32_t format, uint32_t dataType, int width,
291*35238bceSAndroid Build Coastguard Worker                                              int height)
292*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
293*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(context.getRenderContext())
294*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(context.getContextInfo())
295*35238bceSAndroid Build Coastguard Worker     , m_format(format)
296*35238bceSAndroid Build Coastguard Worker     , m_dataType(dataType)
297*35238bceSAndroid Build Coastguard Worker     , m_width(width)
298*35238bceSAndroid Build Coastguard Worker     , m_height(height)
299*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
300*35238bceSAndroid Build Coastguard Worker     , m_renderer(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
301*35238bceSAndroid Build Coastguard Worker     , m_curFace(0)
302*35238bceSAndroid Build Coastguard Worker     , m_isOk(false)
303*35238bceSAndroid Build Coastguard Worker {
304*35238bceSAndroid Build Coastguard Worker }
305*35238bceSAndroid Build Coastguard Worker 
TextureCubeFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,uint32_t internalFormat,int width,int height)306*35238bceSAndroid Build Coastguard Worker TextureCubeFormatCase::TextureCubeFormatCase(tcu::TestContext &testCtx, Context &context, const char *name,
307*35238bceSAndroid Build Coastguard Worker                                              const char *description, uint32_t internalFormat, int width, int height)
308*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
309*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(context.getRenderContext())
310*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(context.getContextInfo())
311*35238bceSAndroid Build Coastguard Worker     , m_format(internalFormat)
312*35238bceSAndroid Build Coastguard Worker     , m_dataType(GL_NONE)
313*35238bceSAndroid Build Coastguard Worker     , m_width(width)
314*35238bceSAndroid Build Coastguard Worker     , m_height(height)
315*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
316*35238bceSAndroid Build Coastguard Worker     , m_renderer(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
317*35238bceSAndroid Build Coastguard Worker     , m_curFace(0)
318*35238bceSAndroid Build Coastguard Worker     , m_isOk(false)
319*35238bceSAndroid Build Coastguard Worker {
320*35238bceSAndroid Build Coastguard Worker }
321*35238bceSAndroid Build Coastguard Worker 
~TextureCubeFormatCase(void)322*35238bceSAndroid Build Coastguard Worker TextureCubeFormatCase::~TextureCubeFormatCase(void)
323*35238bceSAndroid Build Coastguard Worker {
324*35238bceSAndroid Build Coastguard Worker     deinit();
325*35238bceSAndroid Build Coastguard Worker }
326*35238bceSAndroid Build Coastguard Worker 
init(void)327*35238bceSAndroid Build Coastguard Worker void TextureCubeFormatCase::init(void)
328*35238bceSAndroid Build Coastguard Worker {
329*35238bceSAndroid Build Coastguard Worker     checkSupport(m_renderCtxInfo, m_format);
330*35238bceSAndroid Build Coastguard Worker 
331*35238bceSAndroid Build Coastguard Worker     TestLog &log = m_testCtx.getLog();
332*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormat fmt =
333*35238bceSAndroid Build Coastguard Worker         m_dataType ? glu::mapGLTransferFormat(m_format, m_dataType) : glu::mapGLInternalFormat(m_format);
334*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(fmt);
335*35238bceSAndroid Build Coastguard Worker     std::ostringstream fmtName;
336*35238bceSAndroid Build Coastguard Worker 
337*35238bceSAndroid Build Coastguard Worker     if (m_dataType)
338*35238bceSAndroid Build Coastguard Worker         fmtName << glu::getTextureFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType);
339*35238bceSAndroid Build Coastguard Worker     else
340*35238bceSAndroid Build Coastguard Worker         fmtName << glu::getTextureFormatStr(m_format);
341*35238bceSAndroid Build Coastguard Worker 
342*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Cube map texture, " << fmtName.str() << ", " << m_width << "x" << m_height
343*35238bceSAndroid Build Coastguard Worker         << ",\n  fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient" << TestLog::EndMessage;
344*35238bceSAndroid Build Coastguard Worker 
345*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_width == m_height);
346*35238bceSAndroid Build Coastguard Worker     m_texture = m_dataType != GL_NONE ?
347*35238bceSAndroid Build Coastguard Worker                     new glu::TextureCube(m_renderCtx, m_format, m_dataType, m_width) // Implicit internal format.
348*35238bceSAndroid Build Coastguard Worker                     :
349*35238bceSAndroid Build Coastguard Worker                     new glu::TextureCube(m_renderCtx, m_format, m_width); // Explicit internal format.
350*35238bceSAndroid Build Coastguard Worker 
351*35238bceSAndroid Build Coastguard Worker     // Fill level 0.
352*35238bceSAndroid Build Coastguard Worker     for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
353*35238bceSAndroid Build Coastguard Worker     {
354*35238bceSAndroid Build Coastguard Worker         tcu::Vec4 gMin, gMax;
355*35238bceSAndroid Build Coastguard Worker 
356*35238bceSAndroid Build Coastguard Worker         switch (face)
357*35238bceSAndroid Build Coastguard Worker         {
358*35238bceSAndroid Build Coastguard Worker         case 0:
359*35238bceSAndroid Build Coastguard Worker             gMin = spec.valueMin.swizzle(0, 1, 2, 3);
360*35238bceSAndroid Build Coastguard Worker             gMax = spec.valueMax.swizzle(0, 1, 2, 3);
361*35238bceSAndroid Build Coastguard Worker             break;
362*35238bceSAndroid Build Coastguard Worker         case 1:
363*35238bceSAndroid Build Coastguard Worker             gMin = spec.valueMin.swizzle(2, 1, 0, 3);
364*35238bceSAndroid Build Coastguard Worker             gMax = spec.valueMax.swizzle(2, 1, 0, 3);
365*35238bceSAndroid Build Coastguard Worker             break;
366*35238bceSAndroid Build Coastguard Worker         case 2:
367*35238bceSAndroid Build Coastguard Worker             gMin = spec.valueMin.swizzle(1, 2, 0, 3);
368*35238bceSAndroid Build Coastguard Worker             gMax = spec.valueMax.swizzle(1, 2, 0, 3);
369*35238bceSAndroid Build Coastguard Worker             break;
370*35238bceSAndroid Build Coastguard Worker         case 3:
371*35238bceSAndroid Build Coastguard Worker             gMin = spec.valueMax.swizzle(0, 1, 2, 3);
372*35238bceSAndroid Build Coastguard Worker             gMax = spec.valueMin.swizzle(0, 1, 2, 3);
373*35238bceSAndroid Build Coastguard Worker             break;
374*35238bceSAndroid Build Coastguard Worker         case 4:
375*35238bceSAndroid Build Coastguard Worker             gMin = spec.valueMax.swizzle(2, 1, 0, 3);
376*35238bceSAndroid Build Coastguard Worker             gMax = spec.valueMin.swizzle(2, 1, 0, 3);
377*35238bceSAndroid Build Coastguard Worker             break;
378*35238bceSAndroid Build Coastguard Worker         case 5:
379*35238bceSAndroid Build Coastguard Worker             gMin = spec.valueMax.swizzle(1, 2, 0, 3);
380*35238bceSAndroid Build Coastguard Worker             gMax = spec.valueMin.swizzle(1, 2, 0, 3);
381*35238bceSAndroid Build Coastguard Worker             break;
382*35238bceSAndroid Build Coastguard Worker         default:
383*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false);
384*35238bceSAndroid Build Coastguard Worker         }
385*35238bceSAndroid Build Coastguard Worker 
386*35238bceSAndroid Build Coastguard Worker         m_texture->getRefTexture().allocLevel((tcu::CubeFace)face, 0);
387*35238bceSAndroid Build Coastguard Worker         tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevelFace(0, (tcu::CubeFace)face), gMin, gMax);
388*35238bceSAndroid Build Coastguard Worker     }
389*35238bceSAndroid Build Coastguard Worker 
390*35238bceSAndroid Build Coastguard Worker     // Upload texture data to GL.
391*35238bceSAndroid Build Coastguard Worker     m_texture->upload();
392*35238bceSAndroid Build Coastguard Worker 
393*35238bceSAndroid Build Coastguard Worker     // Initialize iteration state.
394*35238bceSAndroid Build Coastguard Worker     m_curFace = 0;
395*35238bceSAndroid Build Coastguard Worker     m_isOk    = true;
396*35238bceSAndroid Build Coastguard Worker }
397*35238bceSAndroid Build Coastguard Worker 
deinit(void)398*35238bceSAndroid Build Coastguard Worker void TextureCubeFormatCase::deinit(void)
399*35238bceSAndroid Build Coastguard Worker {
400*35238bceSAndroid Build Coastguard Worker     delete m_texture;
401*35238bceSAndroid Build Coastguard Worker     m_texture = DE_NULL;
402*35238bceSAndroid Build Coastguard Worker 
403*35238bceSAndroid Build Coastguard Worker     m_renderer.clear();
404*35238bceSAndroid Build Coastguard Worker }
405*35238bceSAndroid Build Coastguard Worker 
testFace(tcu::CubeFace face)406*35238bceSAndroid Build Coastguard Worker bool TextureCubeFormatCase::testFace(tcu::CubeFace face)
407*35238bceSAndroid Build Coastguard Worker {
408*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
409*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
410*35238bceSAndroid Build Coastguard Worker     RandomViewport viewport(m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName()) + (uint32_t)face);
411*35238bceSAndroid Build Coastguard Worker     tcu::Surface renderedFrame(viewport.width, viewport.height);
412*35238bceSAndroid Build Coastguard Worker     tcu::Surface referenceFrame(viewport.width, viewport.height);
413*35238bceSAndroid Build Coastguard Worker     tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1, 1, 1, 1);
414*35238bceSAndroid Build Coastguard Worker     vector<float> texCoord;
415*35238bceSAndroid Build Coastguard Worker     ReferenceParams renderParams(TEXTURETYPE_CUBE);
416*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
417*35238bceSAndroid Build Coastguard Worker 
418*35238bceSAndroid Build Coastguard Worker     renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat());
419*35238bceSAndroid Build Coastguard Worker     renderParams.sampler     = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE,
420*35238bceSAndroid Build Coastguard Worker                                        Sampler::NEAREST, Sampler::NEAREST);
421*35238bceSAndroid Build Coastguard Worker     renderParams.sampler.seamlessCubeMap = true;
422*35238bceSAndroid Build Coastguard Worker     renderParams.colorScale              = spec.lookupScale;
423*35238bceSAndroid Build Coastguard Worker     renderParams.colorBias               = spec.lookupBias;
424*35238bceSAndroid Build Coastguard Worker 
425*35238bceSAndroid Build Coastguard Worker     // Log render info on first face.
426*35238bceSAndroid Build Coastguard Worker     if (face == tcu::CUBEFACE_NEGATIVE_X)
427*35238bceSAndroid Build Coastguard Worker         renderParams.flags |= RenderParams::LOG_ALL;
428*35238bceSAndroid Build Coastguard Worker 
429*35238bceSAndroid Build Coastguard Worker     computeQuadTexCoordCube(texCoord, face);
430*35238bceSAndroid Build Coastguard Worker 
431*35238bceSAndroid Build Coastguard Worker     // \todo [2011-10-28 pyry] Image set name / section?
432*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << face << TestLog::EndMessage;
433*35238bceSAndroid Build Coastguard Worker 
434*35238bceSAndroid Build Coastguard Worker     // Setup base viewport.
435*35238bceSAndroid Build Coastguard Worker     gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
436*35238bceSAndroid Build Coastguard Worker 
437*35238bceSAndroid Build Coastguard Worker     // Bind to unit 0.
438*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
439*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
440*35238bceSAndroid Build Coastguard Worker 
441*35238bceSAndroid Build Coastguard Worker     // Setup nearest neighbor filtering and clamp-to-edge.
442*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
443*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
444*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
445*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
446*35238bceSAndroid Build Coastguard Worker 
447*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
448*35238bceSAndroid Build Coastguard Worker 
449*35238bceSAndroid Build Coastguard Worker     m_renderer.renderQuad(0, &texCoord[0], renderParams);
450*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
451*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
452*35238bceSAndroid Build Coastguard Worker 
453*35238bceSAndroid Build Coastguard Worker     // Compute reference.
454*35238bceSAndroid Build Coastguard Worker     sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()),
455*35238bceSAndroid Build Coastguard Worker                   m_texture->getRefTexture(), &texCoord[0], renderParams);
456*35238bceSAndroid Build Coastguard Worker 
457*35238bceSAndroid Build Coastguard Worker     // Compare and log.
458*35238bceSAndroid Build Coastguard Worker     return compareImages(log, referenceFrame, renderedFrame, threshold);
459*35238bceSAndroid Build Coastguard Worker }
460*35238bceSAndroid Build Coastguard Worker 
iterate(void)461*35238bceSAndroid Build Coastguard Worker TextureCubeFormatCase::IterateResult TextureCubeFormatCase::iterate(void)
462*35238bceSAndroid Build Coastguard Worker {
463*35238bceSAndroid Build Coastguard Worker     // Execute test for all faces.
464*35238bceSAndroid Build Coastguard Worker     if (!testFace((tcu::CubeFace)m_curFace))
465*35238bceSAndroid Build Coastguard Worker         m_isOk = false;
466*35238bceSAndroid Build Coastguard Worker 
467*35238bceSAndroid Build Coastguard Worker     m_curFace += 1;
468*35238bceSAndroid Build Coastguard Worker 
469*35238bceSAndroid Build Coastguard Worker     if (m_curFace == tcu::CUBEFACE_LAST)
470*35238bceSAndroid Build Coastguard Worker     {
471*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
472*35238bceSAndroid Build Coastguard Worker                                 m_isOk ? "Pass" : "Image comparison failed");
473*35238bceSAndroid Build Coastguard Worker         return STOP;
474*35238bceSAndroid Build Coastguard Worker     }
475*35238bceSAndroid Build Coastguard Worker     else
476*35238bceSAndroid Build Coastguard Worker         return CONTINUE;
477*35238bceSAndroid Build Coastguard Worker }
478*35238bceSAndroid Build Coastguard Worker 
479*35238bceSAndroid Build Coastguard Worker // Texture2DArrayFormatCase
480*35238bceSAndroid Build Coastguard Worker 
481*35238bceSAndroid Build Coastguard Worker class Texture2DArrayFormatCase : public tcu::TestCase
482*35238bceSAndroid Build Coastguard Worker {
483*35238bceSAndroid Build Coastguard Worker public:
484*35238bceSAndroid Build Coastguard Worker     Texture2DArrayFormatCase(tcu::TestContext &testCtx, Context &context, const char *name, const char *description,
485*35238bceSAndroid Build Coastguard Worker                              uint32_t format, uint32_t dataType, int width, int height, int numLayers);
486*35238bceSAndroid Build Coastguard Worker     Texture2DArrayFormatCase(tcu::TestContext &testCtx, Context &context, const char *name, const char *description,
487*35238bceSAndroid Build Coastguard Worker                              uint32_t internalFormat, int width, int height, int numLayers);
488*35238bceSAndroid Build Coastguard Worker     ~Texture2DArrayFormatCase(void);
489*35238bceSAndroid Build Coastguard Worker 
490*35238bceSAndroid Build Coastguard Worker     void init(void);
491*35238bceSAndroid Build Coastguard Worker     void deinit(void);
492*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
493*35238bceSAndroid Build Coastguard Worker 
494*35238bceSAndroid Build Coastguard Worker private:
495*35238bceSAndroid Build Coastguard Worker     Texture2DArrayFormatCase(const Texture2DArrayFormatCase &other);
496*35238bceSAndroid Build Coastguard Worker     Texture2DArrayFormatCase &operator=(const Texture2DArrayFormatCase &other);
497*35238bceSAndroid Build Coastguard Worker 
498*35238bceSAndroid Build Coastguard Worker     bool testLayer(int layerNdx);
499*35238bceSAndroid Build Coastguard Worker 
500*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
501*35238bceSAndroid Build Coastguard Worker     const glu::ContextInfo &m_renderCtxInfo;
502*35238bceSAndroid Build Coastguard Worker 
503*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
504*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
505*35238bceSAndroid Build Coastguard Worker     int m_width;
506*35238bceSAndroid Build Coastguard Worker     int m_height;
507*35238bceSAndroid Build Coastguard Worker     int m_numLayers;
508*35238bceSAndroid Build Coastguard Worker 
509*35238bceSAndroid Build Coastguard Worker     glu::Texture2DArray *m_texture;
510*35238bceSAndroid Build Coastguard Worker     TextureTestUtil::TextureRenderer m_renderer;
511*35238bceSAndroid Build Coastguard Worker 
512*35238bceSAndroid Build Coastguard Worker     int m_curLayer;
513*35238bceSAndroid Build Coastguard Worker };
514*35238bceSAndroid Build Coastguard Worker 
Texture2DArrayFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,uint32_t format,uint32_t dataType,int width,int height,int numLayers)515*35238bceSAndroid Build Coastguard Worker Texture2DArrayFormatCase::Texture2DArrayFormatCase(tcu::TestContext &testCtx, Context &context, const char *name,
516*35238bceSAndroid Build Coastguard Worker                                                    const char *description, uint32_t format, uint32_t dataType,
517*35238bceSAndroid Build Coastguard Worker                                                    int width, int height, int numLayers)
518*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
519*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(context.getRenderContext())
520*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(context.getContextInfo())
521*35238bceSAndroid Build Coastguard Worker     , m_format(format)
522*35238bceSAndroid Build Coastguard Worker     , m_dataType(dataType)
523*35238bceSAndroid Build Coastguard Worker     , m_width(width)
524*35238bceSAndroid Build Coastguard Worker     , m_height(height)
525*35238bceSAndroid Build Coastguard Worker     , m_numLayers(numLayers)
526*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
527*35238bceSAndroid Build Coastguard Worker     , m_renderer(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
528*35238bceSAndroid Build Coastguard Worker     , m_curLayer(0)
529*35238bceSAndroid Build Coastguard Worker {
530*35238bceSAndroid Build Coastguard Worker }
531*35238bceSAndroid Build Coastguard Worker 
Texture2DArrayFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,uint32_t internalFormat,int width,int height,int numLayers)532*35238bceSAndroid Build Coastguard Worker Texture2DArrayFormatCase::Texture2DArrayFormatCase(tcu::TestContext &testCtx, Context &context, const char *name,
533*35238bceSAndroid Build Coastguard Worker                                                    const char *description, uint32_t internalFormat, int width,
534*35238bceSAndroid Build Coastguard Worker                                                    int height, int numLayers)
535*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
536*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(context.getRenderContext())
537*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(context.getContextInfo())
538*35238bceSAndroid Build Coastguard Worker     , m_format(internalFormat)
539*35238bceSAndroid Build Coastguard Worker     , m_dataType(GL_NONE)
540*35238bceSAndroid Build Coastguard Worker     , m_width(width)
541*35238bceSAndroid Build Coastguard Worker     , m_height(height)
542*35238bceSAndroid Build Coastguard Worker     , m_numLayers(numLayers)
543*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
544*35238bceSAndroid Build Coastguard Worker     , m_renderer(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
545*35238bceSAndroid Build Coastguard Worker     , m_curLayer(0)
546*35238bceSAndroid Build Coastguard Worker {
547*35238bceSAndroid Build Coastguard Worker }
548*35238bceSAndroid Build Coastguard Worker 
~Texture2DArrayFormatCase(void)549*35238bceSAndroid Build Coastguard Worker Texture2DArrayFormatCase::~Texture2DArrayFormatCase(void)
550*35238bceSAndroid Build Coastguard Worker {
551*35238bceSAndroid Build Coastguard Worker     deinit();
552*35238bceSAndroid Build Coastguard Worker }
553*35238bceSAndroid Build Coastguard Worker 
init(void)554*35238bceSAndroid Build Coastguard Worker void Texture2DArrayFormatCase::init(void)
555*35238bceSAndroid Build Coastguard Worker {
556*35238bceSAndroid Build Coastguard Worker     checkSupport(m_renderCtxInfo, m_format);
557*35238bceSAndroid Build Coastguard Worker 
558*35238bceSAndroid Build Coastguard Worker     m_texture = m_dataType != GL_NONE ? new glu::Texture2DArray(m_renderCtx, m_format, m_dataType, m_width, m_height,
559*35238bceSAndroid Build Coastguard Worker                                                                 m_numLayers) // Implicit internal format.
560*35238bceSAndroid Build Coastguard Worker                                         :
561*35238bceSAndroid Build Coastguard Worker                                         new glu::Texture2DArray(m_renderCtx, m_format, m_width, m_height,
562*35238bceSAndroid Build Coastguard Worker                                                                 m_numLayers); // Explicit internal format.
563*35238bceSAndroid Build Coastguard Worker 
564*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
565*35238bceSAndroid Build Coastguard Worker 
566*35238bceSAndroid Build Coastguard Worker     // Fill level 0.
567*35238bceSAndroid Build Coastguard Worker     m_texture->getRefTexture().allocLevel(0);
568*35238bceSAndroid Build Coastguard Worker     tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
569*35238bceSAndroid Build Coastguard Worker 
570*35238bceSAndroid Build Coastguard Worker     // Initialize state.
571*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
572*35238bceSAndroid Build Coastguard Worker     m_curLayer = 0;
573*35238bceSAndroid Build Coastguard Worker }
574*35238bceSAndroid Build Coastguard Worker 
deinit(void)575*35238bceSAndroid Build Coastguard Worker void Texture2DArrayFormatCase::deinit(void)
576*35238bceSAndroid Build Coastguard Worker {
577*35238bceSAndroid Build Coastguard Worker     delete m_texture;
578*35238bceSAndroid Build Coastguard Worker     m_texture = DE_NULL;
579*35238bceSAndroid Build Coastguard Worker 
580*35238bceSAndroid Build Coastguard Worker     m_renderer.clear();
581*35238bceSAndroid Build Coastguard Worker }
582*35238bceSAndroid Build Coastguard Worker 
testLayer(int layerNdx)583*35238bceSAndroid Build Coastguard Worker bool Texture2DArrayFormatCase::testLayer(int layerNdx)
584*35238bceSAndroid Build Coastguard Worker {
585*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
586*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
587*35238bceSAndroid Build Coastguard Worker     RandomViewport viewport(m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName()));
588*35238bceSAndroid Build Coastguard Worker     tcu::Surface renderedFrame(viewport.width, viewport.height);
589*35238bceSAndroid Build Coastguard Worker     tcu::Surface referenceFrame(viewport.width, viewport.height);
590*35238bceSAndroid Build Coastguard Worker     tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1, 1, 1, 1);
591*35238bceSAndroid Build Coastguard Worker     vector<float> texCoord;
592*35238bceSAndroid Build Coastguard Worker     ReferenceParams renderParams(TEXTURETYPE_2D_ARRAY);
593*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
594*35238bceSAndroid Build Coastguard Worker 
595*35238bceSAndroid Build Coastguard Worker     renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat());
596*35238bceSAndroid Build Coastguard Worker     renderParams.sampler     = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE,
597*35238bceSAndroid Build Coastguard Worker                                        Sampler::NEAREST, Sampler::NEAREST);
598*35238bceSAndroid Build Coastguard Worker     renderParams.colorScale  = spec.lookupScale;
599*35238bceSAndroid Build Coastguard Worker     renderParams.colorBias   = spec.lookupBias;
600*35238bceSAndroid Build Coastguard Worker 
601*35238bceSAndroid Build Coastguard Worker     computeQuadTexCoord2DArray(texCoord, layerNdx, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
602*35238bceSAndroid Build Coastguard Worker 
603*35238bceSAndroid Build Coastguard Worker     // Setup base viewport.
604*35238bceSAndroid Build Coastguard Worker     gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
605*35238bceSAndroid Build Coastguard Worker 
606*35238bceSAndroid Build Coastguard Worker     // Upload texture data to GL.
607*35238bceSAndroid Build Coastguard Worker     m_texture->upload();
608*35238bceSAndroid Build Coastguard Worker 
609*35238bceSAndroid Build Coastguard Worker     // Bind to unit 0.
610*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
611*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_texture->getGLTexture());
612*35238bceSAndroid Build Coastguard Worker 
613*35238bceSAndroid Build Coastguard Worker     // Setup nearest neighbor filtering and clamp-to-edge.
614*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
615*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
616*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
617*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
618*35238bceSAndroid Build Coastguard Worker 
619*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
620*35238bceSAndroid Build Coastguard Worker 
621*35238bceSAndroid Build Coastguard Worker     // Draw.
622*35238bceSAndroid Build Coastguard Worker     m_renderer.renderQuad(0, &texCoord[0], renderParams);
623*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
624*35238bceSAndroid Build Coastguard Worker 
625*35238bceSAndroid Build Coastguard Worker     // Compute reference.
626*35238bceSAndroid Build Coastguard Worker     sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()),
627*35238bceSAndroid Build Coastguard Worker                   m_texture->getRefTexture(), &texCoord[0], renderParams);
628*35238bceSAndroid Build Coastguard Worker 
629*35238bceSAndroid Build Coastguard Worker     // Compare and log.
630*35238bceSAndroid Build Coastguard Worker     return compareImages(log, (string("Layer" + de::toString(layerNdx))).c_str(),
631*35238bceSAndroid Build Coastguard Worker                          (string("Layer " + de::toString(layerNdx))).c_str(), referenceFrame, renderedFrame, threshold);
632*35238bceSAndroid Build Coastguard Worker }
633*35238bceSAndroid Build Coastguard Worker 
iterate(void)634*35238bceSAndroid Build Coastguard Worker Texture2DArrayFormatCase::IterateResult Texture2DArrayFormatCase::iterate(void)
635*35238bceSAndroid Build Coastguard Worker {
636*35238bceSAndroid Build Coastguard Worker     // Execute test for all layers.
637*35238bceSAndroid Build Coastguard Worker     bool isOk = testLayer(m_curLayer);
638*35238bceSAndroid Build Coastguard Worker 
639*35238bceSAndroid Build Coastguard Worker     if (!isOk && m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
640*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
641*35238bceSAndroid Build Coastguard Worker 
642*35238bceSAndroid Build Coastguard Worker     m_curLayer += 1;
643*35238bceSAndroid Build Coastguard Worker 
644*35238bceSAndroid Build Coastguard Worker     return m_curLayer < m_texture->getRefTexture().getNumLayers() ? CONTINUE : STOP;
645*35238bceSAndroid Build Coastguard Worker }
646*35238bceSAndroid Build Coastguard Worker 
647*35238bceSAndroid Build Coastguard Worker // Texture2DFormatCase
648*35238bceSAndroid Build Coastguard Worker 
649*35238bceSAndroid Build Coastguard Worker class Texture3DFormatCase : public tcu::TestCase
650*35238bceSAndroid Build Coastguard Worker {
651*35238bceSAndroid Build Coastguard Worker public:
652*35238bceSAndroid Build Coastguard Worker     Texture3DFormatCase(tcu::TestContext &testCtx, Context &context, const char *name, const char *description,
653*35238bceSAndroid Build Coastguard Worker                         uint32_t format, uint32_t dataType, int width, int height, int depth);
654*35238bceSAndroid Build Coastguard Worker     Texture3DFormatCase(tcu::TestContext &testCtx, Context &context, const char *name, const char *description,
655*35238bceSAndroid Build Coastguard Worker                         uint32_t internalFormat, int width, int height, int depth);
656*35238bceSAndroid Build Coastguard Worker     ~Texture3DFormatCase(void);
657*35238bceSAndroid Build Coastguard Worker 
658*35238bceSAndroid Build Coastguard Worker     void init(void);
659*35238bceSAndroid Build Coastguard Worker     void deinit(void);
660*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
661*35238bceSAndroid Build Coastguard Worker 
662*35238bceSAndroid Build Coastguard Worker private:
663*35238bceSAndroid Build Coastguard Worker     Texture3DFormatCase(const Texture3DFormatCase &other);
664*35238bceSAndroid Build Coastguard Worker     Texture3DFormatCase &operator=(const Texture3DFormatCase &other);
665*35238bceSAndroid Build Coastguard Worker 
666*35238bceSAndroid Build Coastguard Worker     bool testSlice(int sliceNdx);
667*35238bceSAndroid Build Coastguard Worker 
668*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
669*35238bceSAndroid Build Coastguard Worker     const glu::ContextInfo &m_renderCtxInfo;
670*35238bceSAndroid Build Coastguard Worker 
671*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
672*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
673*35238bceSAndroid Build Coastguard Worker     int m_width;
674*35238bceSAndroid Build Coastguard Worker     int m_height;
675*35238bceSAndroid Build Coastguard Worker     int m_depth;
676*35238bceSAndroid Build Coastguard Worker 
677*35238bceSAndroid Build Coastguard Worker     glu::Texture3D *m_texture;
678*35238bceSAndroid Build Coastguard Worker     TextureTestUtil::TextureRenderer m_renderer;
679*35238bceSAndroid Build Coastguard Worker 
680*35238bceSAndroid Build Coastguard Worker     int m_curSlice;
681*35238bceSAndroid Build Coastguard Worker };
682*35238bceSAndroid Build Coastguard Worker 
Texture3DFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,uint32_t format,uint32_t dataType,int width,int height,int depth)683*35238bceSAndroid Build Coastguard Worker Texture3DFormatCase::Texture3DFormatCase(tcu::TestContext &testCtx, Context &context, const char *name,
684*35238bceSAndroid Build Coastguard Worker                                          const char *description, uint32_t format, uint32_t dataType, int width,
685*35238bceSAndroid Build Coastguard Worker                                          int height, int depth)
686*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
687*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(context.getRenderContext())
688*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(context.getContextInfo())
689*35238bceSAndroid Build Coastguard Worker     , m_format(format)
690*35238bceSAndroid Build Coastguard Worker     , m_dataType(dataType)
691*35238bceSAndroid Build Coastguard Worker     , m_width(width)
692*35238bceSAndroid Build Coastguard Worker     , m_height(height)
693*35238bceSAndroid Build Coastguard Worker     , m_depth(depth)
694*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
695*35238bceSAndroid Build Coastguard Worker     , m_renderer(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
696*35238bceSAndroid Build Coastguard Worker     , m_curSlice(0)
697*35238bceSAndroid Build Coastguard Worker {
698*35238bceSAndroid Build Coastguard Worker }
699*35238bceSAndroid Build Coastguard Worker 
Texture3DFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,uint32_t internalFormat,int width,int height,int depth)700*35238bceSAndroid Build Coastguard Worker Texture3DFormatCase::Texture3DFormatCase(tcu::TestContext &testCtx, Context &context, const char *name,
701*35238bceSAndroid Build Coastguard Worker                                          const char *description, uint32_t internalFormat, int width, int height,
702*35238bceSAndroid Build Coastguard Worker                                          int depth)
703*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
704*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(context.getRenderContext())
705*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(context.getContextInfo())
706*35238bceSAndroid Build Coastguard Worker     , m_format(internalFormat)
707*35238bceSAndroid Build Coastguard Worker     , m_dataType(GL_NONE)
708*35238bceSAndroid Build Coastguard Worker     , m_width(width)
709*35238bceSAndroid Build Coastguard Worker     , m_height(height)
710*35238bceSAndroid Build Coastguard Worker     , m_depth(depth)
711*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
712*35238bceSAndroid Build Coastguard Worker     , m_renderer(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
713*35238bceSAndroid Build Coastguard Worker     , m_curSlice(0)
714*35238bceSAndroid Build Coastguard Worker {
715*35238bceSAndroid Build Coastguard Worker }
716*35238bceSAndroid Build Coastguard Worker 
~Texture3DFormatCase(void)717*35238bceSAndroid Build Coastguard Worker Texture3DFormatCase::~Texture3DFormatCase(void)
718*35238bceSAndroid Build Coastguard Worker {
719*35238bceSAndroid Build Coastguard Worker     deinit();
720*35238bceSAndroid Build Coastguard Worker }
721*35238bceSAndroid Build Coastguard Worker 
init(void)722*35238bceSAndroid Build Coastguard Worker void Texture3DFormatCase::init(void)
723*35238bceSAndroid Build Coastguard Worker {
724*35238bceSAndroid Build Coastguard Worker     checkSupport(m_renderCtxInfo, m_format);
725*35238bceSAndroid Build Coastguard Worker 
726*35238bceSAndroid Build Coastguard Worker     m_texture = m_dataType != GL_NONE ?
727*35238bceSAndroid Build Coastguard Worker                     new glu::Texture3D(m_renderCtx, m_format, m_dataType, m_width, m_height,
728*35238bceSAndroid Build Coastguard Worker                                        m_depth) // Implicit internal format.
729*35238bceSAndroid Build Coastguard Worker                     :
730*35238bceSAndroid Build Coastguard Worker                     new glu::Texture3D(m_renderCtx, m_format, m_width, m_height, m_depth); // Explicit internal format.
731*35238bceSAndroid Build Coastguard Worker 
732*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
733*35238bceSAndroid Build Coastguard Worker 
734*35238bceSAndroid Build Coastguard Worker     // Fill level 0.
735*35238bceSAndroid Build Coastguard Worker     m_texture->getRefTexture().allocLevel(0);
736*35238bceSAndroid Build Coastguard Worker     tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
737*35238bceSAndroid Build Coastguard Worker 
738*35238bceSAndroid Build Coastguard Worker     // Initialize state.
739*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
740*35238bceSAndroid Build Coastguard Worker     m_curSlice = 0;
741*35238bceSAndroid Build Coastguard Worker }
742*35238bceSAndroid Build Coastguard Worker 
deinit(void)743*35238bceSAndroid Build Coastguard Worker void Texture3DFormatCase::deinit(void)
744*35238bceSAndroid Build Coastguard Worker {
745*35238bceSAndroid Build Coastguard Worker     delete m_texture;
746*35238bceSAndroid Build Coastguard Worker     m_texture = DE_NULL;
747*35238bceSAndroid Build Coastguard Worker 
748*35238bceSAndroid Build Coastguard Worker     m_renderer.clear();
749*35238bceSAndroid Build Coastguard Worker }
750*35238bceSAndroid Build Coastguard Worker 
testSlice(int sliceNdx)751*35238bceSAndroid Build Coastguard Worker bool Texture3DFormatCase::testSlice(int sliceNdx)
752*35238bceSAndroid Build Coastguard Worker {
753*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
754*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
755*35238bceSAndroid Build Coastguard Worker     RandomViewport viewport(m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName()));
756*35238bceSAndroid Build Coastguard Worker     tcu::Surface renderedFrame(viewport.width, viewport.height);
757*35238bceSAndroid Build Coastguard Worker     tcu::Surface referenceFrame(viewport.width, viewport.height);
758*35238bceSAndroid Build Coastguard Worker     tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1, 1, 1, 1);
759*35238bceSAndroid Build Coastguard Worker     vector<float> texCoord;
760*35238bceSAndroid Build Coastguard Worker     ReferenceParams renderParams(TEXTURETYPE_3D);
761*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
762*35238bceSAndroid Build Coastguard Worker     float r                     = ((float)sliceNdx + 0.5f) / (float)m_depth;
763*35238bceSAndroid Build Coastguard Worker 
764*35238bceSAndroid Build Coastguard Worker     renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat());
765*35238bceSAndroid Build Coastguard Worker     renderParams.sampler     = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE,
766*35238bceSAndroid Build Coastguard Worker                                        Sampler::NEAREST, Sampler::NEAREST);
767*35238bceSAndroid Build Coastguard Worker     renderParams.colorScale  = spec.lookupScale;
768*35238bceSAndroid Build Coastguard Worker     renderParams.colorBias   = spec.lookupBias;
769*35238bceSAndroid Build Coastguard Worker 
770*35238bceSAndroid Build Coastguard Worker     computeQuadTexCoord3D(texCoord, tcu::Vec3(0.0f, 0.0f, r), tcu::Vec3(1.0f, 1.0f, r), tcu::IVec3(0, 1, 2));
771*35238bceSAndroid Build Coastguard Worker 
772*35238bceSAndroid Build Coastguard Worker     // Setup base viewport.
773*35238bceSAndroid Build Coastguard Worker     gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
774*35238bceSAndroid Build Coastguard Worker 
775*35238bceSAndroid Build Coastguard Worker     // Upload texture data to GL.
776*35238bceSAndroid Build Coastguard Worker     m_texture->upload();
777*35238bceSAndroid Build Coastguard Worker 
778*35238bceSAndroid Build Coastguard Worker     // Bind to unit 0.
779*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
780*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_3D, m_texture->getGLTexture());
781*35238bceSAndroid Build Coastguard Worker 
782*35238bceSAndroid Build Coastguard Worker     // Setup nearest neighbor filtering and clamp-to-edge.
783*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
784*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
785*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
786*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
787*35238bceSAndroid Build Coastguard Worker 
788*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
789*35238bceSAndroid Build Coastguard Worker 
790*35238bceSAndroid Build Coastguard Worker     // Draw.
791*35238bceSAndroid Build Coastguard Worker     m_renderer.renderQuad(0, &texCoord[0], renderParams);
792*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
793*35238bceSAndroid Build Coastguard Worker 
794*35238bceSAndroid Build Coastguard Worker     // Compute reference.
795*35238bceSAndroid Build Coastguard Worker     sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()),
796*35238bceSAndroid Build Coastguard Worker                   m_texture->getRefTexture(), &texCoord[0], renderParams);
797*35238bceSAndroid Build Coastguard Worker 
798*35238bceSAndroid Build Coastguard Worker     // Compare and log.
799*35238bceSAndroid Build Coastguard Worker     return compareImages(log, (string("Slice" + de::toString(sliceNdx))).c_str(),
800*35238bceSAndroid Build Coastguard Worker                          (string("Slice " + de::toString(sliceNdx))).c_str(), referenceFrame, renderedFrame, threshold);
801*35238bceSAndroid Build Coastguard Worker }
802*35238bceSAndroid Build Coastguard Worker 
iterate(void)803*35238bceSAndroid Build Coastguard Worker Texture3DFormatCase::IterateResult Texture3DFormatCase::iterate(void)
804*35238bceSAndroid Build Coastguard Worker {
805*35238bceSAndroid Build Coastguard Worker     // Execute test for all slices.
806*35238bceSAndroid Build Coastguard Worker     bool isOk = testSlice(m_curSlice);
807*35238bceSAndroid Build Coastguard Worker 
808*35238bceSAndroid Build Coastguard Worker     if (!isOk && m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
809*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
810*35238bceSAndroid Build Coastguard Worker 
811*35238bceSAndroid Build Coastguard Worker     m_curSlice += 1;
812*35238bceSAndroid Build Coastguard Worker 
813*35238bceSAndroid Build Coastguard Worker     return m_curSlice < m_texture->getRefTexture().getDepth() ? CONTINUE : STOP;
814*35238bceSAndroid Build Coastguard Worker }
815*35238bceSAndroid Build Coastguard Worker 
816*35238bceSAndroid Build Coastguard Worker // Compressed2FormatCase
817*35238bceSAndroid Build Coastguard Worker 
818*35238bceSAndroid Build Coastguard Worker class Compressed2DFormatCase : public tcu::TestCase
819*35238bceSAndroid Build Coastguard Worker {
820*35238bceSAndroid Build Coastguard Worker public:
821*35238bceSAndroid Build Coastguard Worker     Compressed2DFormatCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx,
822*35238bceSAndroid Build Coastguard Worker                            const glu::ContextInfo &renderCtxInfo, const char *name, const char *description,
823*35238bceSAndroid Build Coastguard Worker                            tcu::CompressedTexFormat format, uint32_t randomSeed, int width, int height);
824*35238bceSAndroid Build Coastguard Worker     ~Compressed2DFormatCase(void);
825*35238bceSAndroid Build Coastguard Worker 
826*35238bceSAndroid Build Coastguard Worker     void init(void);
827*35238bceSAndroid Build Coastguard Worker     void deinit(void);
828*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
829*35238bceSAndroid Build Coastguard Worker 
830*35238bceSAndroid Build Coastguard Worker private:
831*35238bceSAndroid Build Coastguard Worker     Compressed2DFormatCase(const Compressed2DFormatCase &other);
832*35238bceSAndroid Build Coastguard Worker     Compressed2DFormatCase &operator=(const Compressed2DFormatCase &other);
833*35238bceSAndroid Build Coastguard Worker 
834*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
835*35238bceSAndroid Build Coastguard Worker     const glu::ContextInfo &m_renderCtxInfo;
836*35238bceSAndroid Build Coastguard Worker 
837*35238bceSAndroid Build Coastguard Worker     tcu::CompressedTexFormat m_format;
838*35238bceSAndroid Build Coastguard Worker 
839*35238bceSAndroid Build Coastguard Worker     uint32_t m_randomSeed;
840*35238bceSAndroid Build Coastguard Worker     int m_width;
841*35238bceSAndroid Build Coastguard Worker     int m_height;
842*35238bceSAndroid Build Coastguard Worker 
843*35238bceSAndroid Build Coastguard Worker     glu::Texture2D *m_texture;
844*35238bceSAndroid Build Coastguard Worker     TextureTestUtil::TextureRenderer m_renderer;
845*35238bceSAndroid Build Coastguard Worker };
846*35238bceSAndroid Build Coastguard Worker 
Compressed2DFormatCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & renderCtxInfo,const char * name,const char * description,tcu::CompressedTexFormat format,uint32_t randomSeed,int width,int height)847*35238bceSAndroid Build Coastguard Worker Compressed2DFormatCase::Compressed2DFormatCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx,
848*35238bceSAndroid Build Coastguard Worker                                                const glu::ContextInfo &renderCtxInfo, const char *name,
849*35238bceSAndroid Build Coastguard Worker                                                const char *description, tcu::CompressedTexFormat format,
850*35238bceSAndroid Build Coastguard Worker                                                uint32_t randomSeed, int width, int height)
851*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
852*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(renderCtx)
853*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(renderCtxInfo)
854*35238bceSAndroid Build Coastguard Worker     , m_format(format)
855*35238bceSAndroid Build Coastguard Worker     , m_randomSeed(randomSeed)
856*35238bceSAndroid Build Coastguard Worker     , m_width(width)
857*35238bceSAndroid Build Coastguard Worker     , m_height(height)
858*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
859*35238bceSAndroid Build Coastguard Worker     , m_renderer(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
860*35238bceSAndroid Build Coastguard Worker {
861*35238bceSAndroid Build Coastguard Worker }
862*35238bceSAndroid Build Coastguard Worker 
~Compressed2DFormatCase(void)863*35238bceSAndroid Build Coastguard Worker Compressed2DFormatCase::~Compressed2DFormatCase(void)
864*35238bceSAndroid Build Coastguard Worker {
865*35238bceSAndroid Build Coastguard Worker     deinit();
866*35238bceSAndroid Build Coastguard Worker }
867*35238bceSAndroid Build Coastguard Worker 
init(void)868*35238bceSAndroid Build Coastguard Worker void Compressed2DFormatCase::init(void)
869*35238bceSAndroid Build Coastguard Worker {
870*35238bceSAndroid Build Coastguard Worker     // Create texture.
871*35238bceSAndroid Build Coastguard Worker     tcu::CompressedTexture compressedTexture(m_format, m_width, m_height);
872*35238bceSAndroid Build Coastguard Worker     int dataSize  = compressedTexture.getDataSize();
873*35238bceSAndroid Build Coastguard Worker     uint8_t *data = (uint8_t *)compressedTexture.getData();
874*35238bceSAndroid Build Coastguard Worker     de::Random rnd(m_randomSeed);
875*35238bceSAndroid Build Coastguard Worker 
876*35238bceSAndroid Build Coastguard Worker     for (int i = 0; i < dataSize; i++)
877*35238bceSAndroid Build Coastguard Worker         data[i] = rnd.getUint32() & 0xff;
878*35238bceSAndroid Build Coastguard Worker 
879*35238bceSAndroid Build Coastguard Worker     m_texture = new glu::Texture2D(m_renderCtx, m_renderCtxInfo, 1, &compressedTexture);
880*35238bceSAndroid Build Coastguard Worker }
881*35238bceSAndroid Build Coastguard Worker 
deinit(void)882*35238bceSAndroid Build Coastguard Worker void Compressed2DFormatCase::deinit(void)
883*35238bceSAndroid Build Coastguard Worker {
884*35238bceSAndroid Build Coastguard Worker     delete m_texture;
885*35238bceSAndroid Build Coastguard Worker     m_texture = DE_NULL;
886*35238bceSAndroid Build Coastguard Worker 
887*35238bceSAndroid Build Coastguard Worker     m_renderer.clear();
888*35238bceSAndroid Build Coastguard Worker }
889*35238bceSAndroid Build Coastguard Worker 
iterate(void)890*35238bceSAndroid Build Coastguard Worker Compressed2DFormatCase::IterateResult Compressed2DFormatCase::iterate(void)
891*35238bceSAndroid Build Coastguard Worker {
892*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
893*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
894*35238bceSAndroid Build Coastguard Worker     RandomViewport viewport(m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getWidth(),
895*35238bceSAndroid Build Coastguard Worker                             m_texture->getRefTexture().getHeight(), deStringHash(getName()));
896*35238bceSAndroid Build Coastguard Worker     tcu::Surface renderedFrame(viewport.width, viewport.height);
897*35238bceSAndroid Build Coastguard Worker     tcu::Surface referenceFrame(viewport.width, viewport.height);
898*35238bceSAndroid Build Coastguard Worker     tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1, 1, 1, 1);
899*35238bceSAndroid Build Coastguard Worker     vector<float> texCoord;
900*35238bceSAndroid Build Coastguard Worker     ReferenceParams renderParams(TEXTURETYPE_2D);
901*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
902*35238bceSAndroid Build Coastguard Worker 
903*35238bceSAndroid Build Coastguard Worker     renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat());
904*35238bceSAndroid Build Coastguard Worker     renderParams.sampler     = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE,
905*35238bceSAndroid Build Coastguard Worker                                        Sampler::NEAREST, Sampler::NEAREST);
906*35238bceSAndroid Build Coastguard Worker     renderParams.colorScale  = spec.lookupScale;
907*35238bceSAndroid Build Coastguard Worker     renderParams.colorBias   = spec.lookupBias;
908*35238bceSAndroid Build Coastguard Worker 
909*35238bceSAndroid Build Coastguard Worker     computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
910*35238bceSAndroid Build Coastguard Worker 
911*35238bceSAndroid Build Coastguard Worker     // Setup base viewport.
912*35238bceSAndroid Build Coastguard Worker     gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
913*35238bceSAndroid Build Coastguard Worker 
914*35238bceSAndroid Build Coastguard Worker     // Bind to unit 0.
915*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
916*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
917*35238bceSAndroid Build Coastguard Worker 
918*35238bceSAndroid Build Coastguard Worker     // Setup nearest neighbor filtering and clamp-to-edge.
919*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
920*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
921*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
922*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
923*35238bceSAndroid Build Coastguard Worker 
924*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
925*35238bceSAndroid Build Coastguard Worker 
926*35238bceSAndroid Build Coastguard Worker     // Draw.
927*35238bceSAndroid Build Coastguard Worker     m_renderer.renderQuad(0, &texCoord[0], renderParams);
928*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
929*35238bceSAndroid Build Coastguard Worker 
930*35238bceSAndroid Build Coastguard Worker     // Compute reference.
931*35238bceSAndroid Build Coastguard Worker     sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()),
932*35238bceSAndroid Build Coastguard Worker                   m_texture->getRefTexture(), &texCoord[0], renderParams);
933*35238bceSAndroid Build Coastguard Worker 
934*35238bceSAndroid Build Coastguard Worker     // Compare and log.
935*35238bceSAndroid Build Coastguard Worker     bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold);
936*35238bceSAndroid Build Coastguard Worker 
937*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
938*35238bceSAndroid Build Coastguard Worker                             isOk ? "Pass" : "Image comparison failed");
939*35238bceSAndroid Build Coastguard Worker 
940*35238bceSAndroid Build Coastguard Worker     return STOP;
941*35238bceSAndroid Build Coastguard Worker }
942*35238bceSAndroid Build Coastguard Worker 
943*35238bceSAndroid Build Coastguard Worker // CompressedCubeFormatCase
944*35238bceSAndroid Build Coastguard Worker 
945*35238bceSAndroid Build Coastguard Worker class CompressedCubeFormatCase : public tcu::TestCase
946*35238bceSAndroid Build Coastguard Worker {
947*35238bceSAndroid Build Coastguard Worker public:
948*35238bceSAndroid Build Coastguard Worker     CompressedCubeFormatCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx,
949*35238bceSAndroid Build Coastguard Worker                              const glu::ContextInfo &renderCtxInfo, const char *name, const char *description,
950*35238bceSAndroid Build Coastguard Worker                              tcu::CompressedTexFormat format, uint32_t randomSeed, int width, int height);
951*35238bceSAndroid Build Coastguard Worker 
952*35238bceSAndroid Build Coastguard Worker     ~CompressedCubeFormatCase(void);
953*35238bceSAndroid Build Coastguard Worker 
954*35238bceSAndroid Build Coastguard Worker     void init(void);
955*35238bceSAndroid Build Coastguard Worker     void deinit(void);
956*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
957*35238bceSAndroid Build Coastguard Worker 
958*35238bceSAndroid Build Coastguard Worker private:
959*35238bceSAndroid Build Coastguard Worker     CompressedCubeFormatCase(const CompressedCubeFormatCase &other);
960*35238bceSAndroid Build Coastguard Worker     CompressedCubeFormatCase &operator=(const CompressedCubeFormatCase &other);
961*35238bceSAndroid Build Coastguard Worker 
962*35238bceSAndroid Build Coastguard Worker     bool testFace(tcu::CubeFace face);
963*35238bceSAndroid Build Coastguard Worker 
964*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
965*35238bceSAndroid Build Coastguard Worker     const glu::ContextInfo &m_renderCtxInfo;
966*35238bceSAndroid Build Coastguard Worker 
967*35238bceSAndroid Build Coastguard Worker     tcu::CompressedTexFormat m_format;
968*35238bceSAndroid Build Coastguard Worker 
969*35238bceSAndroid Build Coastguard Worker     uint32_t m_randomSeed;
970*35238bceSAndroid Build Coastguard Worker     int m_width;
971*35238bceSAndroid Build Coastguard Worker     int m_height;
972*35238bceSAndroid Build Coastguard Worker 
973*35238bceSAndroid Build Coastguard Worker     glu::TextureCube *m_texture;
974*35238bceSAndroid Build Coastguard Worker     TextureTestUtil::TextureRenderer m_renderer;
975*35238bceSAndroid Build Coastguard Worker 
976*35238bceSAndroid Build Coastguard Worker     int m_curFace;
977*35238bceSAndroid Build Coastguard Worker     bool m_isOk;
978*35238bceSAndroid Build Coastguard Worker };
979*35238bceSAndroid Build Coastguard Worker 
CompressedCubeFormatCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & renderCtxInfo,const char * name,const char * description,tcu::CompressedTexFormat format,uint32_t randomSeed,int width,int height)980*35238bceSAndroid Build Coastguard Worker CompressedCubeFormatCase::CompressedCubeFormatCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx,
981*35238bceSAndroid Build Coastguard Worker                                                    const glu::ContextInfo &renderCtxInfo, const char *name,
982*35238bceSAndroid Build Coastguard Worker                                                    const char *description, tcu::CompressedTexFormat format,
983*35238bceSAndroid Build Coastguard Worker                                                    uint32_t randomSeed, int width, int height)
984*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
985*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(renderCtx)
986*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(renderCtxInfo)
987*35238bceSAndroid Build Coastguard Worker     , m_format(format)
988*35238bceSAndroid Build Coastguard Worker     , m_randomSeed(randomSeed)
989*35238bceSAndroid Build Coastguard Worker     , m_width(width)
990*35238bceSAndroid Build Coastguard Worker     , m_height(height)
991*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
992*35238bceSAndroid Build Coastguard Worker     , m_renderer(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
993*35238bceSAndroid Build Coastguard Worker     , m_curFace(0)
994*35238bceSAndroid Build Coastguard Worker     , m_isOk(false)
995*35238bceSAndroid Build Coastguard Worker {
996*35238bceSAndroid Build Coastguard Worker }
997*35238bceSAndroid Build Coastguard Worker 
~CompressedCubeFormatCase(void)998*35238bceSAndroid Build Coastguard Worker CompressedCubeFormatCase::~CompressedCubeFormatCase(void)
999*35238bceSAndroid Build Coastguard Worker {
1000*35238bceSAndroid Build Coastguard Worker     deinit();
1001*35238bceSAndroid Build Coastguard Worker }
1002*35238bceSAndroid Build Coastguard Worker 
init(void)1003*35238bceSAndroid Build Coastguard Worker void CompressedCubeFormatCase::init(void)
1004*35238bceSAndroid Build Coastguard Worker {
1005*35238bceSAndroid Build Coastguard Worker     vector<tcu::CompressedTexture> levels(tcu::CUBEFACE_LAST);
1006*35238bceSAndroid Build Coastguard Worker     de::Random rnd(m_randomSeed);
1007*35238bceSAndroid Build Coastguard Worker 
1008*35238bceSAndroid Build Coastguard Worker     for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1009*35238bceSAndroid Build Coastguard Worker     {
1010*35238bceSAndroid Build Coastguard Worker         levels[face].setStorage(m_format, m_width, m_height);
1011*35238bceSAndroid Build Coastguard Worker 
1012*35238bceSAndroid Build Coastguard Worker         int dataSize  = levels[face].getDataSize();
1013*35238bceSAndroid Build Coastguard Worker         uint8_t *data = (uint8_t *)levels[face].getData();
1014*35238bceSAndroid Build Coastguard Worker 
1015*35238bceSAndroid Build Coastguard Worker         for (int i = 0; i < dataSize; i++)
1016*35238bceSAndroid Build Coastguard Worker             data[i] = rnd.getUint32() & 0xff;
1017*35238bceSAndroid Build Coastguard Worker     }
1018*35238bceSAndroid Build Coastguard Worker 
1019*35238bceSAndroid Build Coastguard Worker     m_texture = new glu::TextureCube(m_renderCtx, m_renderCtxInfo, 1, &levels[0]);
1020*35238bceSAndroid Build Coastguard Worker 
1021*35238bceSAndroid Build Coastguard Worker     m_curFace = 0;
1022*35238bceSAndroid Build Coastguard Worker     m_isOk    = true;
1023*35238bceSAndroid Build Coastguard Worker }
1024*35238bceSAndroid Build Coastguard Worker 
deinit(void)1025*35238bceSAndroid Build Coastguard Worker void CompressedCubeFormatCase::deinit(void)
1026*35238bceSAndroid Build Coastguard Worker {
1027*35238bceSAndroid Build Coastguard Worker     delete m_texture;
1028*35238bceSAndroid Build Coastguard Worker     m_texture = DE_NULL;
1029*35238bceSAndroid Build Coastguard Worker 
1030*35238bceSAndroid Build Coastguard Worker     m_renderer.clear();
1031*35238bceSAndroid Build Coastguard Worker }
1032*35238bceSAndroid Build Coastguard Worker 
testFace(tcu::CubeFace face)1033*35238bceSAndroid Build Coastguard Worker bool CompressedCubeFormatCase::testFace(tcu::CubeFace face)
1034*35238bceSAndroid Build Coastguard Worker {
1035*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
1036*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
1037*35238bceSAndroid Build Coastguard Worker     RandomViewport viewport(m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getSize(),
1038*35238bceSAndroid Build Coastguard Worker                             m_texture->getRefTexture().getSize(), deStringHash(getName()) + (uint32_t)face);
1039*35238bceSAndroid Build Coastguard Worker     tcu::Surface renderedFrame(viewport.width, viewport.height);
1040*35238bceSAndroid Build Coastguard Worker     tcu::Surface referenceFrame(viewport.width, viewport.height);
1041*35238bceSAndroid Build Coastguard Worker     tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1, 1, 1, 1);
1042*35238bceSAndroid Build Coastguard Worker     vector<float> texCoord;
1043*35238bceSAndroid Build Coastguard Worker     ReferenceParams renderParams(TEXTURETYPE_CUBE);
1044*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
1045*35238bceSAndroid Build Coastguard Worker 
1046*35238bceSAndroid Build Coastguard Worker     renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat());
1047*35238bceSAndroid Build Coastguard Worker     renderParams.sampler     = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE,
1048*35238bceSAndroid Build Coastguard Worker                                        Sampler::NEAREST, Sampler::NEAREST);
1049*35238bceSAndroid Build Coastguard Worker     renderParams.sampler.seamlessCubeMap = true;
1050*35238bceSAndroid Build Coastguard Worker     renderParams.colorScale              = spec.lookupScale;
1051*35238bceSAndroid Build Coastguard Worker     renderParams.colorBias               = spec.lookupBias;
1052*35238bceSAndroid Build Coastguard Worker 
1053*35238bceSAndroid Build Coastguard Worker     computeQuadTexCoordCube(texCoord, face);
1054*35238bceSAndroid Build Coastguard Worker 
1055*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << face << TestLog::EndMessage;
1056*35238bceSAndroid Build Coastguard Worker 
1057*35238bceSAndroid Build Coastguard Worker     // Setup base viewport.
1058*35238bceSAndroid Build Coastguard Worker     gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
1059*35238bceSAndroid Build Coastguard Worker 
1060*35238bceSAndroid Build Coastguard Worker     // Bind to unit 0.
1061*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
1062*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
1063*35238bceSAndroid Build Coastguard Worker 
1064*35238bceSAndroid Build Coastguard Worker     // Setup nearest neighbor filtering and clamp-to-edge.
1065*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1066*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1067*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1068*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1069*35238bceSAndroid Build Coastguard Worker 
1070*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
1071*35238bceSAndroid Build Coastguard Worker 
1072*35238bceSAndroid Build Coastguard Worker     m_renderer.renderQuad(0, &texCoord[0], renderParams);
1073*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
1074*35238bceSAndroid Build Coastguard Worker 
1075*35238bceSAndroid Build Coastguard Worker     // Compute reference.
1076*35238bceSAndroid Build Coastguard Worker     sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()),
1077*35238bceSAndroid Build Coastguard Worker                   m_texture->getRefTexture(), &texCoord[0], renderParams);
1078*35238bceSAndroid Build Coastguard Worker 
1079*35238bceSAndroid Build Coastguard Worker     // Compare and log.
1080*35238bceSAndroid Build Coastguard Worker     return compareImages(log, referenceFrame, renderedFrame, threshold);
1081*35238bceSAndroid Build Coastguard Worker }
1082*35238bceSAndroid Build Coastguard Worker 
iterate(void)1083*35238bceSAndroid Build Coastguard Worker CompressedCubeFormatCase::IterateResult CompressedCubeFormatCase::iterate(void)
1084*35238bceSAndroid Build Coastguard Worker {
1085*35238bceSAndroid Build Coastguard Worker     // Execute test for all faces.
1086*35238bceSAndroid Build Coastguard Worker     if (!testFace((tcu::CubeFace)m_curFace))
1087*35238bceSAndroid Build Coastguard Worker         m_isOk = false;
1088*35238bceSAndroid Build Coastguard Worker 
1089*35238bceSAndroid Build Coastguard Worker     m_curFace += 1;
1090*35238bceSAndroid Build Coastguard Worker 
1091*35238bceSAndroid Build Coastguard Worker     if (m_curFace == tcu::CUBEFACE_LAST)
1092*35238bceSAndroid Build Coastguard Worker     {
1093*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
1094*35238bceSAndroid Build Coastguard Worker                                 m_isOk ? "Pass" : "Image comparison failed");
1095*35238bceSAndroid Build Coastguard Worker         return STOP;
1096*35238bceSAndroid Build Coastguard Worker     }
1097*35238bceSAndroid Build Coastguard Worker     else
1098*35238bceSAndroid Build Coastguard Worker         return CONTINUE;
1099*35238bceSAndroid Build Coastguard Worker }
1100*35238bceSAndroid Build Coastguard Worker 
1101*35238bceSAndroid Build Coastguard Worker // Texture2DFileCase
1102*35238bceSAndroid Build Coastguard Worker 
1103*35238bceSAndroid Build Coastguard Worker class Texture2DFileCase : public tcu::TestCase
1104*35238bceSAndroid Build Coastguard Worker {
1105*35238bceSAndroid Build Coastguard Worker public:
1106*35238bceSAndroid Build Coastguard Worker     Texture2DFileCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const glu::ContextInfo &renderCtxInfo,
1107*35238bceSAndroid Build Coastguard Worker                       const char *name, const char *description, const std::vector<std::string> &filenames);
1108*35238bceSAndroid Build Coastguard Worker     ~Texture2DFileCase(void);
1109*35238bceSAndroid Build Coastguard Worker 
1110*35238bceSAndroid Build Coastguard Worker     void init(void);
1111*35238bceSAndroid Build Coastguard Worker     void deinit(void);
1112*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
1113*35238bceSAndroid Build Coastguard Worker 
1114*35238bceSAndroid Build Coastguard Worker private:
1115*35238bceSAndroid Build Coastguard Worker     Texture2DFileCase(const Texture2DFileCase &other);
1116*35238bceSAndroid Build Coastguard Worker     Texture2DFileCase &operator=(const Texture2DFileCase &other);
1117*35238bceSAndroid Build Coastguard Worker 
1118*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
1119*35238bceSAndroid Build Coastguard Worker     const glu::ContextInfo &m_renderCtxInfo;
1120*35238bceSAndroid Build Coastguard Worker 
1121*35238bceSAndroid Build Coastguard Worker     std::vector<std::string> m_filenames;
1122*35238bceSAndroid Build Coastguard Worker 
1123*35238bceSAndroid Build Coastguard Worker     glu::Texture2D *m_texture;
1124*35238bceSAndroid Build Coastguard Worker     TextureRenderer m_renderer;
1125*35238bceSAndroid Build Coastguard Worker };
1126*35238bceSAndroid Build Coastguard Worker 
Texture2DFileCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & renderCtxInfo,const char * name,const char * description,const std::vector<std::string> & filenames)1127*35238bceSAndroid Build Coastguard Worker Texture2DFileCase::Texture2DFileCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx,
1128*35238bceSAndroid Build Coastguard Worker                                      const glu::ContextInfo &renderCtxInfo, const char *name, const char *description,
1129*35238bceSAndroid Build Coastguard Worker                                      const std::vector<std::string> &filenames)
1130*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
1131*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(renderCtx)
1132*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(renderCtxInfo)
1133*35238bceSAndroid Build Coastguard Worker     , m_filenames(filenames)
1134*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
1135*35238bceSAndroid Build Coastguard Worker     , m_renderer(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
1136*35238bceSAndroid Build Coastguard Worker {
1137*35238bceSAndroid Build Coastguard Worker }
1138*35238bceSAndroid Build Coastguard Worker 
~Texture2DFileCase(void)1139*35238bceSAndroid Build Coastguard Worker Texture2DFileCase::~Texture2DFileCase(void)
1140*35238bceSAndroid Build Coastguard Worker {
1141*35238bceSAndroid Build Coastguard Worker     deinit();
1142*35238bceSAndroid Build Coastguard Worker }
1143*35238bceSAndroid Build Coastguard Worker 
init(void)1144*35238bceSAndroid Build Coastguard Worker void Texture2DFileCase::init(void)
1145*35238bceSAndroid Build Coastguard Worker {
1146*35238bceSAndroid Build Coastguard Worker     // Create texture.
1147*35238bceSAndroid Build Coastguard Worker     m_texture = glu::Texture2D::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(), (int)m_filenames.size(),
1148*35238bceSAndroid Build Coastguard Worker                                        m_filenames);
1149*35238bceSAndroid Build Coastguard Worker }
1150*35238bceSAndroid Build Coastguard Worker 
deinit(void)1151*35238bceSAndroid Build Coastguard Worker void Texture2DFileCase::deinit(void)
1152*35238bceSAndroid Build Coastguard Worker {
1153*35238bceSAndroid Build Coastguard Worker     delete m_texture;
1154*35238bceSAndroid Build Coastguard Worker     m_texture = DE_NULL;
1155*35238bceSAndroid Build Coastguard Worker 
1156*35238bceSAndroid Build Coastguard Worker     m_renderer.clear();
1157*35238bceSAndroid Build Coastguard Worker }
1158*35238bceSAndroid Build Coastguard Worker 
iterate(void)1159*35238bceSAndroid Build Coastguard Worker Texture2DFileCase::IterateResult Texture2DFileCase::iterate(void)
1160*35238bceSAndroid Build Coastguard Worker {
1161*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
1162*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
1163*35238bceSAndroid Build Coastguard Worker     RandomViewport viewport(m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getWidth(),
1164*35238bceSAndroid Build Coastguard Worker                             m_texture->getRefTexture().getHeight(), deStringHash(getName()));
1165*35238bceSAndroid Build Coastguard Worker     tcu::Surface renderedFrame(viewport.width, viewport.height);
1166*35238bceSAndroid Build Coastguard Worker     tcu::Surface referenceFrame(viewport.width, viewport.height);
1167*35238bceSAndroid Build Coastguard Worker     tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1, 1, 1, 1);
1168*35238bceSAndroid Build Coastguard Worker     vector<float> texCoord;
1169*35238bceSAndroid Build Coastguard Worker 
1170*35238bceSAndroid Build Coastguard Worker     computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
1171*35238bceSAndroid Build Coastguard Worker 
1172*35238bceSAndroid Build Coastguard Worker     // Setup base viewport.
1173*35238bceSAndroid Build Coastguard Worker     gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
1174*35238bceSAndroid Build Coastguard Worker 
1175*35238bceSAndroid Build Coastguard Worker     // Bind to unit 0.
1176*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
1177*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
1178*35238bceSAndroid Build Coastguard Worker 
1179*35238bceSAndroid Build Coastguard Worker     // Setup nearest neighbor filtering and clamp-to-edge.
1180*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1181*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1182*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1183*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1184*35238bceSAndroid Build Coastguard Worker 
1185*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
1186*35238bceSAndroid Build Coastguard Worker 
1187*35238bceSAndroid Build Coastguard Worker     // Draw.
1188*35238bceSAndroid Build Coastguard Worker     m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_2D);
1189*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
1190*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
1191*35238bceSAndroid Build Coastguard Worker 
1192*35238bceSAndroid Build Coastguard Worker     // Compute reference.
1193*35238bceSAndroid Build Coastguard Worker     ReferenceParams refParams(TEXTURETYPE_2D);
1194*35238bceSAndroid Build Coastguard Worker     refParams.sampler = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE,
1195*35238bceSAndroid Build Coastguard Worker                                 Sampler::NEAREST, Sampler::NEAREST);
1196*35238bceSAndroid Build Coastguard Worker     sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()),
1197*35238bceSAndroid Build Coastguard Worker                   m_texture->getRefTexture(), &texCoord[0], refParams);
1198*35238bceSAndroid Build Coastguard Worker 
1199*35238bceSAndroid Build Coastguard Worker     // Compare and log.
1200*35238bceSAndroid Build Coastguard Worker     bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold);
1201*35238bceSAndroid Build Coastguard Worker 
1202*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
1203*35238bceSAndroid Build Coastguard Worker                             isOk ? "Pass" : "Image comparison failed");
1204*35238bceSAndroid Build Coastguard Worker 
1205*35238bceSAndroid Build Coastguard Worker     return STOP;
1206*35238bceSAndroid Build Coastguard Worker }
1207*35238bceSAndroid Build Coastguard Worker 
1208*35238bceSAndroid Build Coastguard Worker // TextureCubeFileCase
1209*35238bceSAndroid Build Coastguard Worker 
1210*35238bceSAndroid Build Coastguard Worker class TextureCubeFileCase : public tcu::TestCase
1211*35238bceSAndroid Build Coastguard Worker {
1212*35238bceSAndroid Build Coastguard Worker public:
1213*35238bceSAndroid Build Coastguard Worker     TextureCubeFileCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx, const glu::ContextInfo &renderCtxInfo,
1214*35238bceSAndroid Build Coastguard Worker                         const char *name, const char *description, const std::vector<std::string> &filenames);
1215*35238bceSAndroid Build Coastguard Worker     ~TextureCubeFileCase(void);
1216*35238bceSAndroid Build Coastguard Worker 
1217*35238bceSAndroid Build Coastguard Worker     void init(void);
1218*35238bceSAndroid Build Coastguard Worker     void deinit(void);
1219*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
1220*35238bceSAndroid Build Coastguard Worker 
1221*35238bceSAndroid Build Coastguard Worker private:
1222*35238bceSAndroid Build Coastguard Worker     TextureCubeFileCase(const TextureCubeFileCase &other);
1223*35238bceSAndroid Build Coastguard Worker     TextureCubeFileCase &operator=(const TextureCubeFileCase &other);
1224*35238bceSAndroid Build Coastguard Worker 
1225*35238bceSAndroid Build Coastguard Worker     bool testFace(tcu::CubeFace face);
1226*35238bceSAndroid Build Coastguard Worker 
1227*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &m_renderCtx;
1228*35238bceSAndroid Build Coastguard Worker     const glu::ContextInfo &m_renderCtxInfo;
1229*35238bceSAndroid Build Coastguard Worker 
1230*35238bceSAndroid Build Coastguard Worker     std::vector<std::string> m_filenames;
1231*35238bceSAndroid Build Coastguard Worker 
1232*35238bceSAndroid Build Coastguard Worker     glu::TextureCube *m_texture;
1233*35238bceSAndroid Build Coastguard Worker     TextureRenderer m_renderer;
1234*35238bceSAndroid Build Coastguard Worker 
1235*35238bceSAndroid Build Coastguard Worker     int m_curFace;
1236*35238bceSAndroid Build Coastguard Worker     bool m_isOk;
1237*35238bceSAndroid Build Coastguard Worker };
1238*35238bceSAndroid Build Coastguard Worker 
TextureCubeFileCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & renderCtxInfo,const char * name,const char * description,const std::vector<std::string> & filenames)1239*35238bceSAndroid Build Coastguard Worker TextureCubeFileCase::TextureCubeFileCase(tcu::TestContext &testCtx, glu::RenderContext &renderCtx,
1240*35238bceSAndroid Build Coastguard Worker                                          const glu::ContextInfo &renderCtxInfo, const char *name,
1241*35238bceSAndroid Build Coastguard Worker                                          const char *description, const std::vector<std::string> &filenames)
1242*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, name, description)
1243*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(renderCtx)
1244*35238bceSAndroid Build Coastguard Worker     , m_renderCtxInfo(renderCtxInfo)
1245*35238bceSAndroid Build Coastguard Worker     , m_filenames(filenames)
1246*35238bceSAndroid Build Coastguard Worker     , m_texture(DE_NULL)
1247*35238bceSAndroid Build Coastguard Worker     , m_renderer(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
1248*35238bceSAndroid Build Coastguard Worker     , m_curFace(0)
1249*35238bceSAndroid Build Coastguard Worker     , m_isOk(false)
1250*35238bceSAndroid Build Coastguard Worker {
1251*35238bceSAndroid Build Coastguard Worker }
1252*35238bceSAndroid Build Coastguard Worker 
~TextureCubeFileCase(void)1253*35238bceSAndroid Build Coastguard Worker TextureCubeFileCase::~TextureCubeFileCase(void)
1254*35238bceSAndroid Build Coastguard Worker {
1255*35238bceSAndroid Build Coastguard Worker     deinit();
1256*35238bceSAndroid Build Coastguard Worker }
1257*35238bceSAndroid Build Coastguard Worker 
init(void)1258*35238bceSAndroid Build Coastguard Worker void TextureCubeFileCase::init(void)
1259*35238bceSAndroid Build Coastguard Worker {
1260*35238bceSAndroid Build Coastguard Worker     // Create texture.
1261*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_filenames.size() % 6 == 0);
1262*35238bceSAndroid Build Coastguard Worker     m_texture = glu::TextureCube::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(),
1263*35238bceSAndroid Build Coastguard Worker                                          (int)m_filenames.size() / 6, m_filenames);
1264*35238bceSAndroid Build Coastguard Worker 
1265*35238bceSAndroid Build Coastguard Worker     m_curFace = 0;
1266*35238bceSAndroid Build Coastguard Worker     m_isOk    = true;
1267*35238bceSAndroid Build Coastguard Worker }
1268*35238bceSAndroid Build Coastguard Worker 
deinit(void)1269*35238bceSAndroid Build Coastguard Worker void TextureCubeFileCase::deinit(void)
1270*35238bceSAndroid Build Coastguard Worker {
1271*35238bceSAndroid Build Coastguard Worker     delete m_texture;
1272*35238bceSAndroid Build Coastguard Worker     m_texture = DE_NULL;
1273*35238bceSAndroid Build Coastguard Worker 
1274*35238bceSAndroid Build Coastguard Worker     m_renderer.clear();
1275*35238bceSAndroid Build Coastguard Worker }
1276*35238bceSAndroid Build Coastguard Worker 
testFace(tcu::CubeFace face)1277*35238bceSAndroid Build Coastguard Worker bool TextureCubeFileCase::testFace(tcu::CubeFace face)
1278*35238bceSAndroid Build Coastguard Worker {
1279*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
1280*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
1281*35238bceSAndroid Build Coastguard Worker     RandomViewport viewport(m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getSize(),
1282*35238bceSAndroid Build Coastguard Worker                             m_texture->getRefTexture().getSize(), deStringHash(getName()) + (uint32_t)face);
1283*35238bceSAndroid Build Coastguard Worker     tcu::Surface renderedFrame(viewport.width, viewport.height);
1284*35238bceSAndroid Build Coastguard Worker     tcu::Surface referenceFrame(viewport.width, viewport.height);
1285*35238bceSAndroid Build Coastguard Worker     Sampler sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST,
1286*35238bceSAndroid Build Coastguard Worker                     Sampler::NEAREST);
1287*35238bceSAndroid Build Coastguard Worker     tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1, 1, 1, 1);
1288*35238bceSAndroid Build Coastguard Worker     vector<float> texCoord;
1289*35238bceSAndroid Build Coastguard Worker 
1290*35238bceSAndroid Build Coastguard Worker     computeQuadTexCoordCube(texCoord, face);
1291*35238bceSAndroid Build Coastguard Worker 
1292*35238bceSAndroid Build Coastguard Worker     // \todo [2011-10-28 pyry] Image set name / section?
1293*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << face << TestLog::EndMessage;
1294*35238bceSAndroid Build Coastguard Worker 
1295*35238bceSAndroid Build Coastguard Worker     // Setup base viewport.
1296*35238bceSAndroid Build Coastguard Worker     gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
1297*35238bceSAndroid Build Coastguard Worker 
1298*35238bceSAndroid Build Coastguard Worker     // Bind to unit 0.
1299*35238bceSAndroid Build Coastguard Worker     gl.activeTexture(GL_TEXTURE0);
1300*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
1301*35238bceSAndroid Build Coastguard Worker 
1302*35238bceSAndroid Build Coastguard Worker     // Setup nearest neighbor filtering and clamp-to-edge.
1303*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1304*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1305*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1306*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1307*35238bceSAndroid Build Coastguard Worker 
1308*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
1309*35238bceSAndroid Build Coastguard Worker 
1310*35238bceSAndroid Build Coastguard Worker     m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_CUBE);
1311*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
1312*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
1313*35238bceSAndroid Build Coastguard Worker 
1314*35238bceSAndroid Build Coastguard Worker     // Compute reference.
1315*35238bceSAndroid Build Coastguard Worker     sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()),
1316*35238bceSAndroid Build Coastguard Worker                   m_texture->getRefTexture(), &texCoord[0], ReferenceParams(TEXTURETYPE_CUBE, sampler));
1317*35238bceSAndroid Build Coastguard Worker 
1318*35238bceSAndroid Build Coastguard Worker     // Compare and log.
1319*35238bceSAndroid Build Coastguard Worker     return compareImages(log, referenceFrame, renderedFrame, threshold);
1320*35238bceSAndroid Build Coastguard Worker }
1321*35238bceSAndroid Build Coastguard Worker 
iterate(void)1322*35238bceSAndroid Build Coastguard Worker TextureCubeFileCase::IterateResult TextureCubeFileCase::iterate(void)
1323*35238bceSAndroid Build Coastguard Worker {
1324*35238bceSAndroid Build Coastguard Worker     // Execute test for all faces.
1325*35238bceSAndroid Build Coastguard Worker     if (!testFace((tcu::CubeFace)m_curFace))
1326*35238bceSAndroid Build Coastguard Worker         m_isOk = false;
1327*35238bceSAndroid Build Coastguard Worker 
1328*35238bceSAndroid Build Coastguard Worker     m_curFace += 1;
1329*35238bceSAndroid Build Coastguard Worker 
1330*35238bceSAndroid Build Coastguard Worker     if (m_curFace == tcu::CUBEFACE_LAST)
1331*35238bceSAndroid Build Coastguard Worker     {
1332*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
1333*35238bceSAndroid Build Coastguard Worker                                 m_isOk ? "Pass" : "Image comparison failed");
1334*35238bceSAndroid Build Coastguard Worker         return STOP;
1335*35238bceSAndroid Build Coastguard Worker     }
1336*35238bceSAndroid Build Coastguard Worker     else
1337*35238bceSAndroid Build Coastguard Worker         return CONTINUE;
1338*35238bceSAndroid Build Coastguard Worker }
1339*35238bceSAndroid Build Coastguard Worker 
1340*35238bceSAndroid Build Coastguard Worker // TextureFormatTests
1341*35238bceSAndroid Build Coastguard Worker 
TextureFormatTests(Context & context)1342*35238bceSAndroid Build Coastguard Worker TextureFormatTests::TextureFormatTests(Context &context) : TestCaseGroup(context, "format", "Texture Format Tests")
1343*35238bceSAndroid Build Coastguard Worker {
1344*35238bceSAndroid Build Coastguard Worker }
1345*35238bceSAndroid Build Coastguard Worker 
~TextureFormatTests(void)1346*35238bceSAndroid Build Coastguard Worker TextureFormatTests::~TextureFormatTests(void)
1347*35238bceSAndroid Build Coastguard Worker {
1348*35238bceSAndroid Build Coastguard Worker }
1349*35238bceSAndroid Build Coastguard Worker 
toStringVector(const char * const * str,int numStr)1350*35238bceSAndroid Build Coastguard Worker vector<string> toStringVector(const char *const *str, int numStr)
1351*35238bceSAndroid Build Coastguard Worker {
1352*35238bceSAndroid Build Coastguard Worker     vector<string> v;
1353*35238bceSAndroid Build Coastguard Worker     v.resize(numStr);
1354*35238bceSAndroid Build Coastguard Worker     for (int i = 0; i < numStr; i++)
1355*35238bceSAndroid Build Coastguard Worker         v[i] = str[i];
1356*35238bceSAndroid Build Coastguard Worker     return v;
1357*35238bceSAndroid Build Coastguard Worker }
1358*35238bceSAndroid Build Coastguard Worker 
init(void)1359*35238bceSAndroid Build Coastguard Worker void TextureFormatTests::init(void)
1360*35238bceSAndroid Build Coastguard Worker {
1361*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *unsizedGroup    = DE_NULL;
1362*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *sizedGroup      = DE_NULL;
1363*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *compressedGroup = DE_NULL;
1364*35238bceSAndroid Build Coastguard Worker     addChild((unsizedGroup = new tcu::TestCaseGroup(m_testCtx, "unsized", "Unsized formats")));
1365*35238bceSAndroid Build Coastguard Worker     addChild((sizedGroup = new tcu::TestCaseGroup(m_testCtx, "sized", "Sized formats")));
1366*35238bceSAndroid Build Coastguard Worker     addChild((compressedGroup = new tcu::TestCaseGroup(m_testCtx, "compressed", "Compressed formats")));
1367*35238bceSAndroid Build Coastguard Worker 
1368*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *sized2DGroup      = DE_NULL;
1369*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *sizedCubeGroup    = DE_NULL;
1370*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *sized2DArrayGroup = DE_NULL;
1371*35238bceSAndroid Build Coastguard Worker     tcu::TestCaseGroup *sized3DGroup      = DE_NULL;
1372*35238bceSAndroid Build Coastguard Worker     sizedGroup->addChild((sized2DGroup = new tcu::TestCaseGroup(m_testCtx, "2d", "Sized formats (2D)")));
1373*35238bceSAndroid Build Coastguard Worker     sizedGroup->addChild((sizedCubeGroup = new tcu::TestCaseGroup(m_testCtx, "cube", "Sized formats (Cubemap)")));
1374*35238bceSAndroid Build Coastguard Worker     sizedGroup->addChild(
1375*35238bceSAndroid Build Coastguard Worker         (sized2DArrayGroup = new tcu::TestCaseGroup(m_testCtx, "2d_array", "Sized formats (2D Array)")));
1376*35238bceSAndroid Build Coastguard Worker     sizedGroup->addChild((sized3DGroup = new tcu::TestCaseGroup(m_testCtx, "3d", "Sized formats (3D)")));
1377*35238bceSAndroid Build Coastguard Worker 
1378*35238bceSAndroid Build Coastguard Worker     struct
1379*35238bceSAndroid Build Coastguard Worker     {
1380*35238bceSAndroid Build Coastguard Worker         const char *name;
1381*35238bceSAndroid Build Coastguard Worker         uint32_t format;
1382*35238bceSAndroid Build Coastguard Worker         uint32_t dataType;
1383*35238bceSAndroid Build Coastguard Worker     } texFormats[] = {{"alpha", GL_ALPHA, GL_UNSIGNED_BYTE},
1384*35238bceSAndroid Build Coastguard Worker                       {"luminance", GL_LUMINANCE, GL_UNSIGNED_BYTE},
1385*35238bceSAndroid Build Coastguard Worker                       {"luminance_alpha", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE},
1386*35238bceSAndroid Build Coastguard Worker                       {"rgb_unsigned_short_5_6_5", GL_RGB, GL_UNSIGNED_SHORT_5_6_5},
1387*35238bceSAndroid Build Coastguard Worker                       {"rgb_unsigned_byte", GL_RGB, GL_UNSIGNED_BYTE},
1388*35238bceSAndroid Build Coastguard Worker                       {"rgba_unsigned_short_4_4_4_4", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4},
1389*35238bceSAndroid Build Coastguard Worker                       {"rgba_unsigned_short_5_5_5_1", GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1},
1390*35238bceSAndroid Build Coastguard Worker                       {"rgba_unsigned_byte", GL_RGBA, GL_UNSIGNED_BYTE}};
1391*35238bceSAndroid Build Coastguard Worker 
1392*35238bceSAndroid Build Coastguard Worker     for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
1393*35238bceSAndroid Build Coastguard Worker     {
1394*35238bceSAndroid Build Coastguard Worker         uint32_t format        = texFormats[formatNdx].format;
1395*35238bceSAndroid Build Coastguard Worker         uint32_t dataType      = texFormats[formatNdx].dataType;
1396*35238bceSAndroid Build Coastguard Worker         string nameBase        = texFormats[formatNdx].name;
1397*35238bceSAndroid Build Coastguard Worker         string descriptionBase = string(glu::getTextureFormatName(format)) + ", " + glu::getTypeName(dataType);
1398*35238bceSAndroid Build Coastguard Worker 
1399*35238bceSAndroid Build Coastguard Worker         unsizedGroup->addChild(new Texture2DFormatCase(m_testCtx, m_context, (nameBase + "_2d_pot").c_str(),
1400*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_2D").c_str(), format, dataType,
1401*35238bceSAndroid Build Coastguard Worker                                                        128, 128));
1402*35238bceSAndroid Build Coastguard Worker         unsizedGroup->addChild(new Texture2DFormatCase(m_testCtx, m_context, (nameBase + "_2d_npot").c_str(),
1403*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_2D").c_str(), format, dataType,
1404*35238bceSAndroid Build Coastguard Worker                                                        63, 112));
1405*35238bceSAndroid Build Coastguard Worker         unsizedGroup->addChild(new TextureCubeFormatCase(m_testCtx, m_context, (nameBase + "_cube_pot").c_str(),
1406*35238bceSAndroid Build Coastguard Worker                                                          (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(), format,
1407*35238bceSAndroid Build Coastguard Worker                                                          dataType, 64, 64));
1408*35238bceSAndroid Build Coastguard Worker         unsizedGroup->addChild(new TextureCubeFormatCase(m_testCtx, m_context, (nameBase + "_cube_npot").c_str(),
1409*35238bceSAndroid Build Coastguard Worker                                                          (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(), format,
1410*35238bceSAndroid Build Coastguard Worker                                                          dataType, 57, 57));
1411*35238bceSAndroid Build Coastguard Worker         unsizedGroup->addChild(new Texture2DArrayFormatCase(m_testCtx, m_context, (nameBase + "_2d_array_pot").c_str(),
1412*35238bceSAndroid Build Coastguard Worker                                                             (descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(), format,
1413*35238bceSAndroid Build Coastguard Worker                                                             dataType, 64, 64, 8));
1414*35238bceSAndroid Build Coastguard Worker         unsizedGroup->addChild(new Texture2DArrayFormatCase(m_testCtx, m_context, (nameBase + "_2d_array_npot").c_str(),
1415*35238bceSAndroid Build Coastguard Worker                                                             (descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(), format,
1416*35238bceSAndroid Build Coastguard Worker                                                             dataType, 63, 57, 7));
1417*35238bceSAndroid Build Coastguard Worker         unsizedGroup->addChild(new Texture3DFormatCase(m_testCtx, m_context, (nameBase + "_3d_pot").c_str(),
1418*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_3D").c_str(), format, dataType,
1419*35238bceSAndroid Build Coastguard Worker                                                        8, 32, 16));
1420*35238bceSAndroid Build Coastguard Worker         unsizedGroup->addChild(new Texture3DFormatCase(m_testCtx, m_context, (nameBase + "_3d_npot").c_str(),
1421*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_3D").c_str(), format, dataType,
1422*35238bceSAndroid Build Coastguard Worker                                                        11, 31, 7));
1423*35238bceSAndroid Build Coastguard Worker     }
1424*35238bceSAndroid Build Coastguard Worker 
1425*35238bceSAndroid Build Coastguard Worker     struct
1426*35238bceSAndroid Build Coastguard Worker     {
1427*35238bceSAndroid Build Coastguard Worker         const char *name;
1428*35238bceSAndroid Build Coastguard Worker         uint32_t internalFormat;
1429*35238bceSAndroid Build Coastguard Worker     } sizedColorFormats[] = {{
1430*35238bceSAndroid Build Coastguard Worker                                  "rgba32f",
1431*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA32F,
1432*35238bceSAndroid Build Coastguard Worker                              },
1433*35238bceSAndroid Build Coastguard Worker                              {
1434*35238bceSAndroid Build Coastguard Worker                                  "rgba32i",
1435*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA32I,
1436*35238bceSAndroid Build Coastguard Worker                              },
1437*35238bceSAndroid Build Coastguard Worker                              {
1438*35238bceSAndroid Build Coastguard Worker                                  "rgba32ui",
1439*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA32UI,
1440*35238bceSAndroid Build Coastguard Worker                              },
1441*35238bceSAndroid Build Coastguard Worker                              {
1442*35238bceSAndroid Build Coastguard Worker                                  "rgba16f",
1443*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA16F,
1444*35238bceSAndroid Build Coastguard Worker                              },
1445*35238bceSAndroid Build Coastguard Worker                              {
1446*35238bceSAndroid Build Coastguard Worker                                  "rgba16i",
1447*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA16I,
1448*35238bceSAndroid Build Coastguard Worker                              },
1449*35238bceSAndroid Build Coastguard Worker                              {
1450*35238bceSAndroid Build Coastguard Worker                                  "rgba16ui",
1451*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA16UI,
1452*35238bceSAndroid Build Coastguard Worker                              },
1453*35238bceSAndroid Build Coastguard Worker                              {
1454*35238bceSAndroid Build Coastguard Worker                                  "rgba8",
1455*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA8,
1456*35238bceSAndroid Build Coastguard Worker                              },
1457*35238bceSAndroid Build Coastguard Worker                              {
1458*35238bceSAndroid Build Coastguard Worker                                  "rgba8i",
1459*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA8I,
1460*35238bceSAndroid Build Coastguard Worker                              },
1461*35238bceSAndroid Build Coastguard Worker                              {
1462*35238bceSAndroid Build Coastguard Worker                                  "rgba8ui",
1463*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA8UI,
1464*35238bceSAndroid Build Coastguard Worker                              },
1465*35238bceSAndroid Build Coastguard Worker                              {
1466*35238bceSAndroid Build Coastguard Worker                                  "srgb8_alpha8",
1467*35238bceSAndroid Build Coastguard Worker                                  GL_SRGB8_ALPHA8,
1468*35238bceSAndroid Build Coastguard Worker                              },
1469*35238bceSAndroid Build Coastguard Worker                              {
1470*35238bceSAndroid Build Coastguard Worker                                  "srgb_r8",
1471*35238bceSAndroid Build Coastguard Worker                                  GL_SR8_EXT,
1472*35238bceSAndroid Build Coastguard Worker                              },
1473*35238bceSAndroid Build Coastguard Worker                              {
1474*35238bceSAndroid Build Coastguard Worker                                  "srgb_rg8",
1475*35238bceSAndroid Build Coastguard Worker                                  GL_SRG8_EXT,
1476*35238bceSAndroid Build Coastguard Worker                              },
1477*35238bceSAndroid Build Coastguard Worker                              {
1478*35238bceSAndroid Build Coastguard Worker                                  "rgb10_a2",
1479*35238bceSAndroid Build Coastguard Worker                                  GL_RGB10_A2,
1480*35238bceSAndroid Build Coastguard Worker                              },
1481*35238bceSAndroid Build Coastguard Worker                              {
1482*35238bceSAndroid Build Coastguard Worker                                  "rgb10_a2ui",
1483*35238bceSAndroid Build Coastguard Worker                                  GL_RGB10_A2UI,
1484*35238bceSAndroid Build Coastguard Worker                              },
1485*35238bceSAndroid Build Coastguard Worker                              {
1486*35238bceSAndroid Build Coastguard Worker                                  "rgba4",
1487*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA4,
1488*35238bceSAndroid Build Coastguard Worker                              },
1489*35238bceSAndroid Build Coastguard Worker                              {
1490*35238bceSAndroid Build Coastguard Worker                                  "rgb5_a1",
1491*35238bceSAndroid Build Coastguard Worker                                  GL_RGB5_A1,
1492*35238bceSAndroid Build Coastguard Worker                              },
1493*35238bceSAndroid Build Coastguard Worker                              {
1494*35238bceSAndroid Build Coastguard Worker                                  "rgba8_snorm",
1495*35238bceSAndroid Build Coastguard Worker                                  GL_RGBA8_SNORM,
1496*35238bceSAndroid Build Coastguard Worker                              },
1497*35238bceSAndroid Build Coastguard Worker                              {
1498*35238bceSAndroid Build Coastguard Worker                                  "rgb8",
1499*35238bceSAndroid Build Coastguard Worker                                  GL_RGB8,
1500*35238bceSAndroid Build Coastguard Worker                              },
1501*35238bceSAndroid Build Coastguard Worker                              {
1502*35238bceSAndroid Build Coastguard Worker                                  "rgb565",
1503*35238bceSAndroid Build Coastguard Worker                                  GL_RGB565,
1504*35238bceSAndroid Build Coastguard Worker                              },
1505*35238bceSAndroid Build Coastguard Worker                              {
1506*35238bceSAndroid Build Coastguard Worker                                  "r11f_g11f_b10f",
1507*35238bceSAndroid Build Coastguard Worker                                  GL_R11F_G11F_B10F,
1508*35238bceSAndroid Build Coastguard Worker                              },
1509*35238bceSAndroid Build Coastguard Worker                              {
1510*35238bceSAndroid Build Coastguard Worker                                  "rgb32f",
1511*35238bceSAndroid Build Coastguard Worker                                  GL_RGB32F,
1512*35238bceSAndroid Build Coastguard Worker                              },
1513*35238bceSAndroid Build Coastguard Worker                              {
1514*35238bceSAndroid Build Coastguard Worker                                  "rgb32i",
1515*35238bceSAndroid Build Coastguard Worker                                  GL_RGB32I,
1516*35238bceSAndroid Build Coastguard Worker                              },
1517*35238bceSAndroid Build Coastguard Worker                              {
1518*35238bceSAndroid Build Coastguard Worker                                  "rgb32ui",
1519*35238bceSAndroid Build Coastguard Worker                                  GL_RGB32UI,
1520*35238bceSAndroid Build Coastguard Worker                              },
1521*35238bceSAndroid Build Coastguard Worker                              {
1522*35238bceSAndroid Build Coastguard Worker                                  "rgb16f",
1523*35238bceSAndroid Build Coastguard Worker                                  GL_RGB16F,
1524*35238bceSAndroid Build Coastguard Worker                              },
1525*35238bceSAndroid Build Coastguard Worker                              {
1526*35238bceSAndroid Build Coastguard Worker                                  "rgb16i",
1527*35238bceSAndroid Build Coastguard Worker                                  GL_RGB16I,
1528*35238bceSAndroid Build Coastguard Worker                              },
1529*35238bceSAndroid Build Coastguard Worker                              {
1530*35238bceSAndroid Build Coastguard Worker                                  "rgb16ui",
1531*35238bceSAndroid Build Coastguard Worker                                  GL_RGB16UI,
1532*35238bceSAndroid Build Coastguard Worker                              },
1533*35238bceSAndroid Build Coastguard Worker                              {
1534*35238bceSAndroid Build Coastguard Worker                                  "rgb8_snorm",
1535*35238bceSAndroid Build Coastguard Worker                                  GL_RGB8_SNORM,
1536*35238bceSAndroid Build Coastguard Worker                              },
1537*35238bceSAndroid Build Coastguard Worker                              {
1538*35238bceSAndroid Build Coastguard Worker                                  "rgb8i",
1539*35238bceSAndroid Build Coastguard Worker                                  GL_RGB8I,
1540*35238bceSAndroid Build Coastguard Worker                              },
1541*35238bceSAndroid Build Coastguard Worker                              {
1542*35238bceSAndroid Build Coastguard Worker                                  "rgb8ui",
1543*35238bceSAndroid Build Coastguard Worker                                  GL_RGB8UI,
1544*35238bceSAndroid Build Coastguard Worker                              },
1545*35238bceSAndroid Build Coastguard Worker                              {
1546*35238bceSAndroid Build Coastguard Worker                                  "srgb8",
1547*35238bceSAndroid Build Coastguard Worker                                  GL_SRGB8,
1548*35238bceSAndroid Build Coastguard Worker                              },
1549*35238bceSAndroid Build Coastguard Worker                              {
1550*35238bceSAndroid Build Coastguard Worker                                  "rgb9_e5",
1551*35238bceSAndroid Build Coastguard Worker                                  GL_RGB9_E5,
1552*35238bceSAndroid Build Coastguard Worker                              },
1553*35238bceSAndroid Build Coastguard Worker                              {
1554*35238bceSAndroid Build Coastguard Worker                                  "rg32f",
1555*35238bceSAndroid Build Coastguard Worker                                  GL_RG32F,
1556*35238bceSAndroid Build Coastguard Worker                              },
1557*35238bceSAndroid Build Coastguard Worker                              {
1558*35238bceSAndroid Build Coastguard Worker                                  "rg32i",
1559*35238bceSAndroid Build Coastguard Worker                                  GL_RG32I,
1560*35238bceSAndroid Build Coastguard Worker                              },
1561*35238bceSAndroid Build Coastguard Worker                              {
1562*35238bceSAndroid Build Coastguard Worker                                  "rg32ui",
1563*35238bceSAndroid Build Coastguard Worker                                  GL_RG32UI,
1564*35238bceSAndroid Build Coastguard Worker                              },
1565*35238bceSAndroid Build Coastguard Worker                              {
1566*35238bceSAndroid Build Coastguard Worker                                  "rg16f",
1567*35238bceSAndroid Build Coastguard Worker                                  GL_RG16F,
1568*35238bceSAndroid Build Coastguard Worker                              },
1569*35238bceSAndroid Build Coastguard Worker                              {
1570*35238bceSAndroid Build Coastguard Worker                                  "rg16i",
1571*35238bceSAndroid Build Coastguard Worker                                  GL_RG16I,
1572*35238bceSAndroid Build Coastguard Worker                              },
1573*35238bceSAndroid Build Coastguard Worker                              {
1574*35238bceSAndroid Build Coastguard Worker                                  "rg16ui",
1575*35238bceSAndroid Build Coastguard Worker                                  GL_RG16UI,
1576*35238bceSAndroid Build Coastguard Worker                              },
1577*35238bceSAndroid Build Coastguard Worker                              {
1578*35238bceSAndroid Build Coastguard Worker                                  "rg8",
1579*35238bceSAndroid Build Coastguard Worker                                  GL_RG8,
1580*35238bceSAndroid Build Coastguard Worker                              },
1581*35238bceSAndroid Build Coastguard Worker                              {
1582*35238bceSAndroid Build Coastguard Worker                                  "rg8i",
1583*35238bceSAndroid Build Coastguard Worker                                  GL_RG8I,
1584*35238bceSAndroid Build Coastguard Worker                              },
1585*35238bceSAndroid Build Coastguard Worker                              {
1586*35238bceSAndroid Build Coastguard Worker                                  "rg8ui",
1587*35238bceSAndroid Build Coastguard Worker                                  GL_RG8UI,
1588*35238bceSAndroid Build Coastguard Worker                              },
1589*35238bceSAndroid Build Coastguard Worker                              {
1590*35238bceSAndroid Build Coastguard Worker                                  "rg8_snorm",
1591*35238bceSAndroid Build Coastguard Worker                                  GL_RG8_SNORM,
1592*35238bceSAndroid Build Coastguard Worker                              },
1593*35238bceSAndroid Build Coastguard Worker                              {
1594*35238bceSAndroid Build Coastguard Worker                                  "r32f",
1595*35238bceSAndroid Build Coastguard Worker                                  GL_R32F,
1596*35238bceSAndroid Build Coastguard Worker                              },
1597*35238bceSAndroid Build Coastguard Worker                              {
1598*35238bceSAndroid Build Coastguard Worker                                  "r32i",
1599*35238bceSAndroid Build Coastguard Worker                                  GL_R32I,
1600*35238bceSAndroid Build Coastguard Worker                              },
1601*35238bceSAndroid Build Coastguard Worker                              {
1602*35238bceSAndroid Build Coastguard Worker                                  "r32ui",
1603*35238bceSAndroid Build Coastguard Worker                                  GL_R32UI,
1604*35238bceSAndroid Build Coastguard Worker                              },
1605*35238bceSAndroid Build Coastguard Worker                              {
1606*35238bceSAndroid Build Coastguard Worker                                  "r16f",
1607*35238bceSAndroid Build Coastguard Worker                                  GL_R16F,
1608*35238bceSAndroid Build Coastguard Worker                              },
1609*35238bceSAndroid Build Coastguard Worker                              {
1610*35238bceSAndroid Build Coastguard Worker                                  "r16i",
1611*35238bceSAndroid Build Coastguard Worker                                  GL_R16I,
1612*35238bceSAndroid Build Coastguard Worker                              },
1613*35238bceSAndroid Build Coastguard Worker                              {
1614*35238bceSAndroid Build Coastguard Worker                                  "r16ui",
1615*35238bceSAndroid Build Coastguard Worker                                  GL_R16UI,
1616*35238bceSAndroid Build Coastguard Worker                              },
1617*35238bceSAndroid Build Coastguard Worker                              {
1618*35238bceSAndroid Build Coastguard Worker                                  "r8",
1619*35238bceSAndroid Build Coastguard Worker                                  GL_R8,
1620*35238bceSAndroid Build Coastguard Worker                              },
1621*35238bceSAndroid Build Coastguard Worker                              {
1622*35238bceSAndroid Build Coastguard Worker                                  "r8i",
1623*35238bceSAndroid Build Coastguard Worker                                  GL_R8I,
1624*35238bceSAndroid Build Coastguard Worker                              },
1625*35238bceSAndroid Build Coastguard Worker                              {
1626*35238bceSAndroid Build Coastguard Worker                                  "r8ui",
1627*35238bceSAndroid Build Coastguard Worker                                  GL_R8UI,
1628*35238bceSAndroid Build Coastguard Worker                              },
1629*35238bceSAndroid Build Coastguard Worker                              {
1630*35238bceSAndroid Build Coastguard Worker                                  "r8_snorm",
1631*35238bceSAndroid Build Coastguard Worker                                  GL_R8_SNORM,
1632*35238bceSAndroid Build Coastguard Worker                              }};
1633*35238bceSAndroid Build Coastguard Worker 
1634*35238bceSAndroid Build Coastguard Worker     struct
1635*35238bceSAndroid Build Coastguard Worker     {
1636*35238bceSAndroid Build Coastguard Worker         const char *name;
1637*35238bceSAndroid Build Coastguard Worker         uint32_t internalFormat;
1638*35238bceSAndroid Build Coastguard Worker     } sizedDepthStencilFormats[] = {// Depth and stencil formats
1639*35238bceSAndroid Build Coastguard Worker                                     {"depth_component32f", GL_DEPTH_COMPONENT32F},
1640*35238bceSAndroid Build Coastguard Worker                                     {"depth_component24", GL_DEPTH_COMPONENT24},
1641*35238bceSAndroid Build Coastguard Worker                                     {"depth_component16", GL_DEPTH_COMPONENT16},
1642*35238bceSAndroid Build Coastguard Worker                                     {"depth32f_stencil8", GL_DEPTH32F_STENCIL8},
1643*35238bceSAndroid Build Coastguard Worker                                     {"depth24_stencil8", GL_DEPTH24_STENCIL8}};
1644*35238bceSAndroid Build Coastguard Worker 
1645*35238bceSAndroid Build Coastguard Worker     for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(sizedColorFormats); formatNdx++)
1646*35238bceSAndroid Build Coastguard Worker     {
1647*35238bceSAndroid Build Coastguard Worker         uint32_t internalFormat = sizedColorFormats[formatNdx].internalFormat;
1648*35238bceSAndroid Build Coastguard Worker         string nameBase         = sizedColorFormats[formatNdx].name;
1649*35238bceSAndroid Build Coastguard Worker         string descriptionBase  = glu::getTextureFormatName(internalFormat);
1650*35238bceSAndroid Build Coastguard Worker 
1651*35238bceSAndroid Build Coastguard Worker         sized2DGroup->addChild(new Texture2DFormatCase(m_testCtx, m_context, (nameBase + "_pot").c_str(),
1652*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_2D").c_str(), internalFormat,
1653*35238bceSAndroid Build Coastguard Worker                                                        128, 128));
1654*35238bceSAndroid Build Coastguard Worker         sized2DGroup->addChild(new Texture2DFormatCase(m_testCtx, m_context, (nameBase + "_npot").c_str(),
1655*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_2D").c_str(), internalFormat,
1656*35238bceSAndroid Build Coastguard Worker                                                        63, 112));
1657*35238bceSAndroid Build Coastguard Worker         sizedCubeGroup->addChild(new TextureCubeFormatCase(m_testCtx, m_context, (nameBase + "_pot").c_str(),
1658*35238bceSAndroid Build Coastguard Worker                                                            (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),
1659*35238bceSAndroid Build Coastguard Worker                                                            internalFormat, 64, 64));
1660*35238bceSAndroid Build Coastguard Worker         sizedCubeGroup->addChild(new TextureCubeFormatCase(m_testCtx, m_context, (nameBase + "_npot").c_str(),
1661*35238bceSAndroid Build Coastguard Worker                                                            (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),
1662*35238bceSAndroid Build Coastguard Worker                                                            internalFormat, 57, 57));
1663*35238bceSAndroid Build Coastguard Worker         sized2DArrayGroup->addChild(new Texture2DArrayFormatCase(m_testCtx, m_context, (nameBase + "_pot").c_str(),
1664*35238bceSAndroid Build Coastguard Worker                                                                  (descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),
1665*35238bceSAndroid Build Coastguard Worker                                                                  internalFormat, 64, 64, 8));
1666*35238bceSAndroid Build Coastguard Worker         sized2DArrayGroup->addChild(new Texture2DArrayFormatCase(m_testCtx, m_context, (nameBase + "_npot").c_str(),
1667*35238bceSAndroid Build Coastguard Worker                                                                  (descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),
1668*35238bceSAndroid Build Coastguard Worker                                                                  internalFormat, 63, 57, 7));
1669*35238bceSAndroid Build Coastguard Worker         sized3DGroup->addChild(new Texture3DFormatCase(m_testCtx, m_context, (nameBase + "_pot").c_str(),
1670*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_3D").c_str(), internalFormat, 8,
1671*35238bceSAndroid Build Coastguard Worker                                                        32, 16));
1672*35238bceSAndroid Build Coastguard Worker         sized3DGroup->addChild(new Texture3DFormatCase(m_testCtx, m_context, (nameBase + "_npot").c_str(),
1673*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_3D").c_str(), internalFormat,
1674*35238bceSAndroid Build Coastguard Worker                                                        11, 31, 7));
1675*35238bceSAndroid Build Coastguard Worker     }
1676*35238bceSAndroid Build Coastguard Worker 
1677*35238bceSAndroid Build Coastguard Worker     for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(sizedDepthStencilFormats); formatNdx++)
1678*35238bceSAndroid Build Coastguard Worker     {
1679*35238bceSAndroid Build Coastguard Worker         uint32_t internalFormat = sizedDepthStencilFormats[formatNdx].internalFormat;
1680*35238bceSAndroid Build Coastguard Worker         string nameBase         = sizedDepthStencilFormats[formatNdx].name;
1681*35238bceSAndroid Build Coastguard Worker         string descriptionBase  = glu::getTextureFormatName(internalFormat);
1682*35238bceSAndroid Build Coastguard Worker 
1683*35238bceSAndroid Build Coastguard Worker         sized2DGroup->addChild(new Texture2DFormatCase(m_testCtx, m_context, (nameBase + "_pot").c_str(),
1684*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_2D").c_str(), internalFormat,
1685*35238bceSAndroid Build Coastguard Worker                                                        128, 128));
1686*35238bceSAndroid Build Coastguard Worker         sized2DGroup->addChild(new Texture2DFormatCase(m_testCtx, m_context, (nameBase + "_npot").c_str(),
1687*35238bceSAndroid Build Coastguard Worker                                                        (descriptionBase + ", GL_TEXTURE_2D").c_str(), internalFormat,
1688*35238bceSAndroid Build Coastguard Worker                                                        63, 112));
1689*35238bceSAndroid Build Coastguard Worker         sizedCubeGroup->addChild(new TextureCubeFormatCase(m_testCtx, m_context, (nameBase + "_pot").c_str(),
1690*35238bceSAndroid Build Coastguard Worker                                                            (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),
1691*35238bceSAndroid Build Coastguard Worker                                                            internalFormat, 64, 64));
1692*35238bceSAndroid Build Coastguard Worker         sizedCubeGroup->addChild(new TextureCubeFormatCase(m_testCtx, m_context, (nameBase + "_npot").c_str(),
1693*35238bceSAndroid Build Coastguard Worker                                                            (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),
1694*35238bceSAndroid Build Coastguard Worker                                                            internalFormat, 57, 57));
1695*35238bceSAndroid Build Coastguard Worker         sized2DArrayGroup->addChild(new Texture2DArrayFormatCase(m_testCtx, m_context, (nameBase + "_pot").c_str(),
1696*35238bceSAndroid Build Coastguard Worker                                                                  (descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),
1697*35238bceSAndroid Build Coastguard Worker                                                                  internalFormat, 64, 64, 8));
1698*35238bceSAndroid Build Coastguard Worker         sized2DArrayGroup->addChild(new Texture2DArrayFormatCase(m_testCtx, m_context, (nameBase + "_npot").c_str(),
1699*35238bceSAndroid Build Coastguard Worker                                                                  (descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),
1700*35238bceSAndroid Build Coastguard Worker                                                                  internalFormat, 63, 57, 7));
1701*35238bceSAndroid Build Coastguard Worker     }
1702*35238bceSAndroid Build Coastguard Worker 
1703*35238bceSAndroid Build Coastguard Worker     // ETC-1 compressed formats.
1704*35238bceSAndroid Build Coastguard Worker     {
1705*35238bceSAndroid Build Coastguard Worker         static const char *filenames[] = {"data/etc1/photo_helsinki_mip_0.pkm", "data/etc1/photo_helsinki_mip_1.pkm",
1706*35238bceSAndroid Build Coastguard Worker                                           "data/etc1/photo_helsinki_mip_2.pkm", "data/etc1/photo_helsinki_mip_3.pkm",
1707*35238bceSAndroid Build Coastguard Worker                                           "data/etc1/photo_helsinki_mip_4.pkm", "data/etc1/photo_helsinki_mip_5.pkm",
1708*35238bceSAndroid Build Coastguard Worker                                           "data/etc1/photo_helsinki_mip_6.pkm", "data/etc1/photo_helsinki_mip_7.pkm"};
1709*35238bceSAndroid Build Coastguard Worker         compressedGroup->addChild(new Texture2DFileCase(
1710*35238bceSAndroid Build Coastguard Worker             m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_2d_pot",
1711*35238bceSAndroid Build Coastguard Worker             "GL_ETC1_RGB8_OES, GL_TEXTURE_2D", toStringVector(filenames, DE_LENGTH_OF_ARRAY(filenames))));
1712*35238bceSAndroid Build Coastguard Worker     }
1713*35238bceSAndroid Build Coastguard Worker 
1714*35238bceSAndroid Build Coastguard Worker     {
1715*35238bceSAndroid Build Coastguard Worker         vector<string> filenames;
1716*35238bceSAndroid Build Coastguard Worker         filenames.push_back("data/etc1/photo_helsinki_113x89.pkm");
1717*35238bceSAndroid Build Coastguard Worker         compressedGroup->addChild(new Texture2DFileCase(m_testCtx, m_context.getRenderContext(),
1718*35238bceSAndroid Build Coastguard Worker                                                         m_context.getContextInfo(), "etc1_2d_npot",
1719*35238bceSAndroid Build Coastguard Worker                                                         "GL_ETC1_RGB8_OES, GL_TEXTURE_2D", filenames));
1720*35238bceSAndroid Build Coastguard Worker     }
1721*35238bceSAndroid Build Coastguard Worker 
1722*35238bceSAndroid Build Coastguard Worker     {
1723*35238bceSAndroid Build Coastguard Worker         static const char *faceExt[] = {"neg_x", "pos_x", "neg_y", "pos_y", "neg_z", "pos_z"};
1724*35238bceSAndroid Build Coastguard Worker 
1725*35238bceSAndroid Build Coastguard Worker         const int potNumLevels = 7;
1726*35238bceSAndroid Build Coastguard Worker         vector<string> potFilenames;
1727*35238bceSAndroid Build Coastguard Worker         for (int level = 0; level < potNumLevels; level++)
1728*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1729*35238bceSAndroid Build Coastguard Worker                 potFilenames.push_back(string("data/etc1/skybox_") + faceExt[face] + "_mip_" + de::toString(level) +
1730*35238bceSAndroid Build Coastguard Worker                                        ".pkm");
1731*35238bceSAndroid Build Coastguard Worker 
1732*35238bceSAndroid Build Coastguard Worker         compressedGroup->addChild(new TextureCubeFileCase(m_testCtx, m_context.getRenderContext(),
1733*35238bceSAndroid Build Coastguard Worker                                                           m_context.getContextInfo(), "etc1_cube_pot",
1734*35238bceSAndroid Build Coastguard Worker                                                           "GL_ETC1_RGB8_OES, GL_TEXTURE_CUBE_MAP", potFilenames));
1735*35238bceSAndroid Build Coastguard Worker 
1736*35238bceSAndroid Build Coastguard Worker         vector<string> npotFilenames;
1737*35238bceSAndroid Build Coastguard Worker         for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1738*35238bceSAndroid Build Coastguard Worker             npotFilenames.push_back(string("data/etc1/skybox_61x61_") + faceExt[face] + ".pkm");
1739*35238bceSAndroid Build Coastguard Worker 
1740*35238bceSAndroid Build Coastguard Worker         compressedGroup->addChild(new TextureCubeFileCase(m_testCtx, m_context.getRenderContext(),
1741*35238bceSAndroid Build Coastguard Worker                                                           m_context.getContextInfo(), "etc1_cube_npot",
1742*35238bceSAndroid Build Coastguard Worker                                                           "GL_ETC_RGB8_OES, GL_TEXTURE_CUBE_MAP", npotFilenames));
1743*35238bceSAndroid Build Coastguard Worker     }
1744*35238bceSAndroid Build Coastguard Worker 
1745*35238bceSAndroid Build Coastguard Worker     // ETC-2 and EAC compressed formats.
1746*35238bceSAndroid Build Coastguard Worker     struct
1747*35238bceSAndroid Build Coastguard Worker     {
1748*35238bceSAndroid Build Coastguard Worker         const char *descriptionBase;
1749*35238bceSAndroid Build Coastguard Worker         const char *nameBase;
1750*35238bceSAndroid Build Coastguard Worker         tcu::CompressedTexFormat format;
1751*35238bceSAndroid Build Coastguard Worker     } etc2Formats[] = {{
1752*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_R11_EAC",
1753*35238bceSAndroid Build Coastguard Worker                            "eac_r11",
1754*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_EAC_R11,
1755*35238bceSAndroid Build Coastguard Worker                        },
1756*35238bceSAndroid Build Coastguard Worker                        {
1757*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_SIGNED_R11_EAC",
1758*35238bceSAndroid Build Coastguard Worker                            "eac_signed_r11",
1759*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_R11,
1760*35238bceSAndroid Build Coastguard Worker                        },
1761*35238bceSAndroid Build Coastguard Worker                        {
1762*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_RG11_EAC",
1763*35238bceSAndroid Build Coastguard Worker                            "eac_rg11",
1764*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_EAC_RG11,
1765*35238bceSAndroid Build Coastguard Worker                        },
1766*35238bceSAndroid Build Coastguard Worker                        {
1767*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_SIGNED_RG11_EAC",
1768*35238bceSAndroid Build Coastguard Worker                            "eac_signed_rg11",
1769*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_RG11,
1770*35238bceSAndroid Build Coastguard Worker                        },
1771*35238bceSAndroid Build Coastguard Worker                        {
1772*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_RGB8_ETC2",
1773*35238bceSAndroid Build Coastguard Worker                            "etc2_rgb8",
1774*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8,
1775*35238bceSAndroid Build Coastguard Worker                        },
1776*35238bceSAndroid Build Coastguard Worker                        {
1777*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_SRGB8_ETC2",
1778*35238bceSAndroid Build Coastguard Worker                            "etc2_srgb8",
1779*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8,
1780*35238bceSAndroid Build Coastguard Worker                        },
1781*35238bceSAndroid Build Coastguard Worker                        {
1782*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",
1783*35238bceSAndroid Build Coastguard Worker                            "etc2_rgb8_punchthrough_alpha1",
1784*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
1785*35238bceSAndroid Build Coastguard Worker                        },
1786*35238bceSAndroid Build Coastguard Worker                        {
1787*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",
1788*35238bceSAndroid Build Coastguard Worker                            "etc2_srgb8_punchthrough_alpha1",
1789*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
1790*35238bceSAndroid Build Coastguard Worker                        },
1791*35238bceSAndroid Build Coastguard Worker                        {
1792*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_RGBA8_ETC2_EAC",
1793*35238bceSAndroid Build Coastguard Worker                            "etc2_eac_rgba8",
1794*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_RGBA8,
1795*35238bceSAndroid Build Coastguard Worker                        },
1796*35238bceSAndroid Build Coastguard Worker                        {
1797*35238bceSAndroid Build Coastguard Worker                            "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",
1798*35238bceSAndroid Build Coastguard Worker                            "etc2_eac_srgb8_alpha8",
1799*35238bceSAndroid Build Coastguard Worker                            tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_SRGB8_ALPHA8,
1800*35238bceSAndroid Build Coastguard Worker                        }};
1801*35238bceSAndroid Build Coastguard Worker 
1802*35238bceSAndroid Build Coastguard Worker     for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(etc2Formats); formatNdx++)
1803*35238bceSAndroid Build Coastguard Worker     {
1804*35238bceSAndroid Build Coastguard Worker         string descriptionBase = etc2Formats[formatNdx].descriptionBase;
1805*35238bceSAndroid Build Coastguard Worker         string nameBase        = etc2Formats[formatNdx].nameBase;
1806*35238bceSAndroid Build Coastguard Worker 
1807*35238bceSAndroid Build Coastguard Worker         compressedGroup->addChild(new Compressed2DFormatCase(
1808*35238bceSAndroid Build Coastguard Worker             m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), (nameBase + "_2d_pot").c_str(),
1809*35238bceSAndroid Build Coastguard Worker             (descriptionBase + ", GL_TEXTURE_2D").c_str(), etc2Formats[formatNdx].format, 1, 128, 64));
1810*35238bceSAndroid Build Coastguard Worker         compressedGroup->addChild(new CompressedCubeFormatCase(
1811*35238bceSAndroid Build Coastguard Worker             m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), (nameBase + "_cube_pot").c_str(),
1812*35238bceSAndroid Build Coastguard Worker             (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(), etc2Formats[formatNdx].format, 1, 64, 64));
1813*35238bceSAndroid Build Coastguard Worker         compressedGroup->addChild(new Compressed2DFormatCase(
1814*35238bceSAndroid Build Coastguard Worker             m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), (nameBase + "_2d_npot").c_str(),
1815*35238bceSAndroid Build Coastguard Worker             (descriptionBase + ", GL_TEXTURE_2D").c_str(), etc2Formats[formatNdx].format, 1, 51, 65));
1816*35238bceSAndroid Build Coastguard Worker         compressedGroup->addChild(new CompressedCubeFormatCase(
1817*35238bceSAndroid Build Coastguard Worker             m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), (nameBase + "_cube_npot").c_str(),
1818*35238bceSAndroid Build Coastguard Worker             (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(), etc2Formats[formatNdx].format, 1, 51, 51));
1819*35238bceSAndroid Build Coastguard Worker     }
1820*35238bceSAndroid Build Coastguard Worker }
1821*35238bceSAndroid Build Coastguard Worker 
1822*35238bceSAndroid Build Coastguard Worker } // namespace Functional
1823*35238bceSAndroid Build Coastguard Worker } // namespace gles3
1824*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1825