xref: /aosp_15_r20/external/deqp/modules/gles3/functional/es3fTextureSpecificationTests.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 specification tests.
22*35238bceSAndroid Build Coastguard Worker  *
23*35238bceSAndroid Build Coastguard Worker  * \todo [pyry] Following tests are missing:
24*35238bceSAndroid Build Coastguard Worker  *  - Specify mipmap incomplete texture, use without mipmaps, re-specify
25*35238bceSAndroid Build Coastguard Worker  *    as complete and render.
26*35238bceSAndroid Build Coastguard Worker  *  - Randomly re-specify levels to eventually reach mipmap-complete texture.
27*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
28*35238bceSAndroid Build Coastguard Worker 
29*35238bceSAndroid Build Coastguard Worker #include "es3fTextureSpecificationTests.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuImageCompare.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "tcuVectorUtil.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "gluTexture.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "gluTextureUtil.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "sglrContextUtil.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "sglrContextWrapper.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "sglrGLContext.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "sglrReferenceContext.hpp"
41*35238bceSAndroid Build Coastguard Worker #include "glsTextureTestUtil.hpp"
42*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
43*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
44*35238bceSAndroid Build Coastguard Worker 
45*35238bceSAndroid Build Coastguard Worker // \todo [2012-04-29 pyry] Should be named SglrUtil
46*35238bceSAndroid Build Coastguard Worker #include "es3fFboTestUtil.hpp"
47*35238bceSAndroid Build Coastguard Worker 
48*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
49*35238bceSAndroid Build Coastguard Worker 
50*35238bceSAndroid Build Coastguard Worker namespace deqp
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker namespace gles3
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker namespace Functional
55*35238bceSAndroid Build Coastguard Worker {
56*35238bceSAndroid Build Coastguard Worker 
57*35238bceSAndroid Build Coastguard Worker using std::pair;
58*35238bceSAndroid Build Coastguard Worker using std::string;
59*35238bceSAndroid Build Coastguard Worker using std::vector;
60*35238bceSAndroid Build Coastguard Worker using tcu::IVec4;
61*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
62*35238bceSAndroid Build Coastguard Worker using tcu::UVec4;
63*35238bceSAndroid Build Coastguard Worker using tcu::Vec4;
64*35238bceSAndroid Build Coastguard Worker using namespace FboTestUtil;
65*35238bceSAndroid Build Coastguard Worker 
mapGLUnsizedInternalFormat(uint32_t internalFormat)66*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat mapGLUnsizedInternalFormat(uint32_t internalFormat)
67*35238bceSAndroid Build Coastguard Worker {
68*35238bceSAndroid Build Coastguard Worker     using tcu::TextureFormat;
69*35238bceSAndroid Build Coastguard Worker     switch (internalFormat)
70*35238bceSAndroid Build Coastguard Worker     {
71*35238bceSAndroid Build Coastguard Worker     case GL_ALPHA:
72*35238bceSAndroid Build Coastguard Worker         return TextureFormat(TextureFormat::A, TextureFormat::UNORM_INT8);
73*35238bceSAndroid Build Coastguard Worker     case GL_LUMINANCE:
74*35238bceSAndroid Build Coastguard Worker         return TextureFormat(TextureFormat::L, TextureFormat::UNORM_INT8);
75*35238bceSAndroid Build Coastguard Worker     case GL_LUMINANCE_ALPHA:
76*35238bceSAndroid Build Coastguard Worker         return TextureFormat(TextureFormat::LA, TextureFormat::UNORM_INT8);
77*35238bceSAndroid Build Coastguard Worker     case GL_RGB:
78*35238bceSAndroid Build Coastguard Worker         return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8);
79*35238bceSAndroid Build Coastguard Worker     case GL_RGBA:
80*35238bceSAndroid Build Coastguard Worker         return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8);
81*35238bceSAndroid Build Coastguard Worker     default:
82*35238bceSAndroid Build Coastguard Worker         throw tcu::InternalError(string("Can't map GL unsized internal format (") +
83*35238bceSAndroid Build Coastguard Worker                                  tcu::toHex(internalFormat).toString() + ") to texture format");
84*35238bceSAndroid Build Coastguard Worker     }
85*35238bceSAndroid Build Coastguard Worker }
86*35238bceSAndroid Build Coastguard Worker 
87*35238bceSAndroid Build Coastguard Worker enum
88*35238bceSAndroid Build Coastguard Worker {
89*35238bceSAndroid Build Coastguard Worker     VIEWPORT_WIDTH  = 256,
90*35238bceSAndroid Build Coastguard Worker     VIEWPORT_HEIGHT = 256
91*35238bceSAndroid Build Coastguard Worker };
92*35238bceSAndroid Build Coastguard Worker 
maxLevelCount(int width,int height)93*35238bceSAndroid Build Coastguard Worker static inline int maxLevelCount(int width, int height)
94*35238bceSAndroid Build Coastguard Worker {
95*35238bceSAndroid Build Coastguard Worker     return (int)deLog2Floor32(de::max(width, height)) + 1;
96*35238bceSAndroid Build Coastguard Worker }
97*35238bceSAndroid Build Coastguard Worker 
maxLevelCount(int width,int height,int depth)98*35238bceSAndroid Build Coastguard Worker static inline int maxLevelCount(int width, int height, int depth)
99*35238bceSAndroid Build Coastguard Worker {
100*35238bceSAndroid Build Coastguard Worker     return (int)deLog2Floor32(de::max(width, de::max(height, depth))) + 1;
101*35238bceSAndroid Build Coastguard Worker }
102*35238bceSAndroid Build Coastguard Worker 
103*35238bceSAndroid Build Coastguard Worker template <int Size>
104*35238bceSAndroid Build Coastguard Worker static tcu::Vector<float, Size> randomVector(de::Random &rnd,
105*35238bceSAndroid Build Coastguard Worker                                              const tcu::Vector<float, Size> &minVal = tcu::Vector<float, Size>(0.0f),
106*35238bceSAndroid Build Coastguard Worker                                              const tcu::Vector<float, Size> &maxVal = tcu::Vector<float, Size>(1.0f))
107*35238bceSAndroid Build Coastguard Worker {
108*35238bceSAndroid Build Coastguard Worker     tcu::Vector<float, Size> res;
109*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < Size; ndx++)
110*35238bceSAndroid Build Coastguard Worker         res[ndx] = rnd.getFloat(minVal[ndx], maxVal[ndx]);
111*35238bceSAndroid Build Coastguard Worker     return res;
112*35238bceSAndroid Build Coastguard Worker }
113*35238bceSAndroid Build Coastguard Worker 
114*35238bceSAndroid Build Coastguard Worker static const uint32_t s_cubeMapFaces[] = {
115*35238bceSAndroid Build Coastguard Worker     GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
116*35238bceSAndroid Build Coastguard Worker     GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
117*35238bceSAndroid Build Coastguard Worker };
118*35238bceSAndroid Build Coastguard Worker 
getPixelFormatCompareDepth(const tcu::PixelFormat & pixelFormat,tcu::TextureFormat textureFormat)119*35238bceSAndroid Build Coastguard Worker static tcu::IVec4 getPixelFormatCompareDepth(const tcu::PixelFormat &pixelFormat, tcu::TextureFormat textureFormat)
120*35238bceSAndroid Build Coastguard Worker {
121*35238bceSAndroid Build Coastguard Worker     switch (textureFormat.order)
122*35238bceSAndroid Build Coastguard Worker     {
123*35238bceSAndroid Build Coastguard Worker     case tcu::TextureFormat::L:
124*35238bceSAndroid Build Coastguard Worker     case tcu::TextureFormat::LA:
125*35238bceSAndroid Build Coastguard Worker         return tcu::IVec4(pixelFormat.redBits, pixelFormat.redBits, pixelFormat.redBits, pixelFormat.alphaBits);
126*35238bceSAndroid Build Coastguard Worker     default:
127*35238bceSAndroid Build Coastguard Worker         return tcu::IVec4(pixelFormat.redBits, pixelFormat.greenBits, pixelFormat.blueBits, pixelFormat.alphaBits);
128*35238bceSAndroid Build Coastguard Worker     }
129*35238bceSAndroid Build Coastguard Worker }
130*35238bceSAndroid Build Coastguard Worker 
getEffectiveTextureFormatBitDepth(tcu::TextureFormat textureFormat)131*35238bceSAndroid Build Coastguard Worker static IVec4 getEffectiveTextureFormatBitDepth(tcu::TextureFormat textureFormat)
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker     if (textureFormat.order == tcu::TextureFormat::DS)
134*35238bceSAndroid Build Coastguard Worker     {
135*35238bceSAndroid Build Coastguard Worker         // When sampling depth-stencil texture, we actually sample just
136*35238bceSAndroid Build Coastguard Worker         // the depth component.
137*35238bceSAndroid Build Coastguard Worker         return tcu::getTextureFormatBitDepth(
138*35238bceSAndroid Build Coastguard Worker             tcu::getEffectiveDepthStencilTextureFormat(textureFormat, tcu::Sampler::MODE_DEPTH));
139*35238bceSAndroid Build Coastguard Worker     }
140*35238bceSAndroid Build Coastguard Worker     else
141*35238bceSAndroid Build Coastguard Worker         return tcu::getTextureFormatBitDepth(textureFormat);
142*35238bceSAndroid Build Coastguard Worker }
143*35238bceSAndroid Build Coastguard Worker 
computeCompareThreshold(const tcu::PixelFormat & pixelFormat,tcu::TextureFormat textureFormat)144*35238bceSAndroid Build Coastguard Worker static tcu::UVec4 computeCompareThreshold(const tcu::PixelFormat &pixelFormat, tcu::TextureFormat textureFormat)
145*35238bceSAndroid Build Coastguard Worker {
146*35238bceSAndroid Build Coastguard Worker     const IVec4 texFormatBits   = getEffectiveTextureFormatBitDepth(textureFormat);
147*35238bceSAndroid Build Coastguard Worker     const IVec4 pixelFormatBits = getPixelFormatCompareDepth(pixelFormat, textureFormat);
148*35238bceSAndroid Build Coastguard Worker     const IVec4 accurateFmtBits = min(pixelFormatBits, texFormatBits);
149*35238bceSAndroid Build Coastguard Worker     const IVec4 compareBits     = select(accurateFmtBits, IVec4(8), greaterThan(accurateFmtBits, IVec4(0))) - 1;
150*35238bceSAndroid Build Coastguard Worker 
151*35238bceSAndroid Build Coastguard Worker     return (IVec4(1) << (8 - compareBits)).asUint();
152*35238bceSAndroid Build Coastguard Worker }
153*35238bceSAndroid Build Coastguard Worker 
154*35238bceSAndroid Build Coastguard Worker class TextureSpecCase : public TestCase, public sglr::ContextWrapper
155*35238bceSAndroid Build Coastguard Worker {
156*35238bceSAndroid Build Coastguard Worker public:
157*35238bceSAndroid Build Coastguard Worker     TextureSpecCase(Context &context, const char *name, const char *desc);
158*35238bceSAndroid Build Coastguard Worker     ~TextureSpecCase(void);
159*35238bceSAndroid Build Coastguard Worker 
160*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
161*35238bceSAndroid Build Coastguard Worker 
162*35238bceSAndroid Build Coastguard Worker protected:
163*35238bceSAndroid Build Coastguard Worker     virtual void createTexture(void)                                                              = DE_NULL;
164*35238bceSAndroid Build Coastguard Worker     virtual void verifyTexture(sglr::GLContext &gles3Context, sglr::ReferenceContext &refContext) = DE_NULL;
165*35238bceSAndroid Build Coastguard Worker 
166*35238bceSAndroid Build Coastguard Worker     // Utilities.
167*35238bceSAndroid Build Coastguard Worker     void renderTex(tcu::Surface &dst, uint32_t program, int width, int height);
168*35238bceSAndroid Build Coastguard Worker     void readPixels(tcu::Surface &dst, int x, int y, int width, int height);
169*35238bceSAndroid Build Coastguard Worker 
170*35238bceSAndroid Build Coastguard Worker private:
171*35238bceSAndroid Build Coastguard Worker     TextureSpecCase(const TextureSpecCase &other);
172*35238bceSAndroid Build Coastguard Worker     TextureSpecCase &operator=(const TextureSpecCase &other);
173*35238bceSAndroid Build Coastguard Worker };
174*35238bceSAndroid Build Coastguard Worker 
TextureSpecCase(Context & context,const char * name,const char * desc)175*35238bceSAndroid Build Coastguard Worker TextureSpecCase::TextureSpecCase(Context &context, const char *name, const char *desc) : TestCase(context, name, desc)
176*35238bceSAndroid Build Coastguard Worker {
177*35238bceSAndroid Build Coastguard Worker }
178*35238bceSAndroid Build Coastguard Worker 
~TextureSpecCase(void)179*35238bceSAndroid Build Coastguard Worker TextureSpecCase::~TextureSpecCase(void)
180*35238bceSAndroid Build Coastguard Worker {
181*35238bceSAndroid Build Coastguard Worker }
182*35238bceSAndroid Build Coastguard Worker 
iterate(void)183*35238bceSAndroid Build Coastguard Worker TextureSpecCase::IterateResult TextureSpecCase::iterate(void)
184*35238bceSAndroid Build Coastguard Worker {
185*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &renderCtx         = TestCase::m_context.getRenderContext();
186*35238bceSAndroid Build Coastguard Worker     const tcu::RenderTarget &renderTarget = renderCtx.getRenderTarget();
187*35238bceSAndroid Build Coastguard Worker     tcu::TestLog &log                     = m_testCtx.getLog();
188*35238bceSAndroid Build Coastguard Worker 
189*35238bceSAndroid Build Coastguard Worker     if (renderTarget.getWidth() < VIEWPORT_WIDTH || renderTarget.getHeight() < VIEWPORT_HEIGHT)
190*35238bceSAndroid Build Coastguard Worker         throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
191*35238bceSAndroid Build Coastguard Worker 
192*35238bceSAndroid Build Coastguard Worker     // Context size, and viewport for GLES3
193*35238bceSAndroid Build Coastguard Worker     de::Random rnd(deStringHash(getName()));
194*35238bceSAndroid Build Coastguard Worker     int width  = deMin32(renderTarget.getWidth(), VIEWPORT_WIDTH);
195*35238bceSAndroid Build Coastguard Worker     int height = deMin32(renderTarget.getHeight(), VIEWPORT_HEIGHT);
196*35238bceSAndroid Build Coastguard Worker     int x      = rnd.getInt(0, renderTarget.getWidth() - width);
197*35238bceSAndroid Build Coastguard Worker     int y      = rnd.getInt(0, renderTarget.getHeight() - height);
198*35238bceSAndroid Build Coastguard Worker 
199*35238bceSAndroid Build Coastguard Worker     // Contexts.
200*35238bceSAndroid Build Coastguard Worker     sglr::GLContext gles3Context(renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height));
201*35238bceSAndroid Build Coastguard Worker     sglr::ReferenceContextBuffers refBuffers(tcu::PixelFormat(8, 8, 8, renderTarget.getPixelFormat().alphaBits ? 8 : 0),
202*35238bceSAndroid Build Coastguard Worker                                              0 /* depth */, 0 /* stencil */, width, height);
203*35238bceSAndroid Build Coastguard Worker     sglr::ReferenceContext refContext(sglr::ReferenceContextLimits(renderCtx), refBuffers.getColorbuffer(),
204*35238bceSAndroid Build Coastguard Worker                                       refBuffers.getDepthbuffer(), refBuffers.getStencilbuffer());
205*35238bceSAndroid Build Coastguard Worker 
206*35238bceSAndroid Build Coastguard Worker     // Clear color buffer.
207*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < 2; ndx++)
208*35238bceSAndroid Build Coastguard Worker     {
209*35238bceSAndroid Build Coastguard Worker         setContext(ndx ? (sglr::Context *)&refContext : (sglr::Context *)&gles3Context);
210*35238bceSAndroid Build Coastguard Worker         glClearColor(0.125f, 0.25f, 0.5f, 1.0f);
211*35238bceSAndroid Build Coastguard Worker         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
212*35238bceSAndroid Build Coastguard Worker     }
213*35238bceSAndroid Build Coastguard Worker 
214*35238bceSAndroid Build Coastguard Worker     // Construct texture using both GLES3 and reference contexts.
215*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < 2; ndx++)
216*35238bceSAndroid Build Coastguard Worker     {
217*35238bceSAndroid Build Coastguard Worker         setContext(ndx ? (sglr::Context *)&refContext : (sglr::Context *)&gles3Context);
218*35238bceSAndroid Build Coastguard Worker         createTexture();
219*35238bceSAndroid Build Coastguard Worker         TCU_CHECK(glGetError() == GL_NO_ERROR);
220*35238bceSAndroid Build Coastguard Worker     }
221*35238bceSAndroid Build Coastguard Worker 
222*35238bceSAndroid Build Coastguard Worker     // Initialize case result to pass.
223*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
224*35238bceSAndroid Build Coastguard Worker 
225*35238bceSAndroid Build Coastguard Worker     // Disable logging.
226*35238bceSAndroid Build Coastguard Worker     gles3Context.enableLogging(0);
227*35238bceSAndroid Build Coastguard Worker 
228*35238bceSAndroid Build Coastguard Worker     // Verify results.
229*35238bceSAndroid Build Coastguard Worker     verifyTexture(gles3Context, refContext);
230*35238bceSAndroid Build Coastguard Worker 
231*35238bceSAndroid Build Coastguard Worker     return STOP;
232*35238bceSAndroid Build Coastguard Worker }
233*35238bceSAndroid Build Coastguard Worker 
renderTex(tcu::Surface & dst,uint32_t program,int width,int height)234*35238bceSAndroid Build Coastguard Worker void TextureSpecCase::renderTex(tcu::Surface &dst, uint32_t program, int width, int height)
235*35238bceSAndroid Build Coastguard Worker {
236*35238bceSAndroid Build Coastguard Worker     int targetW = getWidth();
237*35238bceSAndroid Build Coastguard Worker     int targetH = getHeight();
238*35238bceSAndroid Build Coastguard Worker 
239*35238bceSAndroid Build Coastguard Worker     float w = (float)width / (float)targetW;
240*35238bceSAndroid Build Coastguard Worker     float h = (float)height / (float)targetH;
241*35238bceSAndroid Build Coastguard Worker 
242*35238bceSAndroid Build Coastguard Worker     sglr::drawQuad(*getCurrentContext(), program, tcu::Vec3(-1.0f, -1.0f, 0.0f),
243*35238bceSAndroid Build Coastguard Worker                    tcu::Vec3(-1.0f + w * 2.0f, -1.0f + h * 2.0f, 0.0f));
244*35238bceSAndroid Build Coastguard Worker 
245*35238bceSAndroid Build Coastguard Worker     // Read pixels back.
246*35238bceSAndroid Build Coastguard Worker     readPixels(dst, 0, 0, width, height);
247*35238bceSAndroid Build Coastguard Worker }
248*35238bceSAndroid Build Coastguard Worker 
readPixels(tcu::Surface & dst,int x,int y,int width,int height)249*35238bceSAndroid Build Coastguard Worker void TextureSpecCase::readPixels(tcu::Surface &dst, int x, int y, int width, int height)
250*35238bceSAndroid Build Coastguard Worker {
251*35238bceSAndroid Build Coastguard Worker     dst.setSize(width, height);
252*35238bceSAndroid Build Coastguard Worker     glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
253*35238bceSAndroid Build Coastguard Worker }
254*35238bceSAndroid Build Coastguard Worker 
255*35238bceSAndroid Build Coastguard Worker class Texture2DSpecCase : public TextureSpecCase
256*35238bceSAndroid Build Coastguard Worker {
257*35238bceSAndroid Build Coastguard Worker public:
258*35238bceSAndroid Build Coastguard Worker     Texture2DSpecCase(Context &context, const char *name, const char *desc, const tcu::TextureFormat &format, int width,
259*35238bceSAndroid Build Coastguard Worker                       int height, int numLevels);
260*35238bceSAndroid Build Coastguard Worker     ~Texture2DSpecCase(void);
261*35238bceSAndroid Build Coastguard Worker 
262*35238bceSAndroid Build Coastguard Worker protected:
263*35238bceSAndroid Build Coastguard Worker     virtual void verifyTexture(sglr::GLContext &gles3Context, sglr::ReferenceContext &refContext);
264*35238bceSAndroid Build Coastguard Worker 
265*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormat m_texFormat;
266*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo m_texFormatInfo;
267*35238bceSAndroid Build Coastguard Worker     int m_width;
268*35238bceSAndroid Build Coastguard Worker     int m_height;
269*35238bceSAndroid Build Coastguard Worker     int m_numLevels;
270*35238bceSAndroid Build Coastguard Worker };
271*35238bceSAndroid Build Coastguard Worker 
Texture2DSpecCase(Context & context,const char * name,const char * desc,const tcu::TextureFormat & format,int width,int height,int numLevels)272*35238bceSAndroid Build Coastguard Worker Texture2DSpecCase::Texture2DSpecCase(Context &context, const char *name, const char *desc,
273*35238bceSAndroid Build Coastguard Worker                                      const tcu::TextureFormat &format, int width, int height, int numLevels)
274*35238bceSAndroid Build Coastguard Worker     : TextureSpecCase(context, name, desc)
275*35238bceSAndroid Build Coastguard Worker     , m_texFormat(format)
276*35238bceSAndroid Build Coastguard Worker     , m_texFormatInfo(tcu::getTextureFormatInfo(format))
277*35238bceSAndroid Build Coastguard Worker     , m_width(width)
278*35238bceSAndroid Build Coastguard Worker     , m_height(height)
279*35238bceSAndroid Build Coastguard Worker     , m_numLevels(numLevels)
280*35238bceSAndroid Build Coastguard Worker {
281*35238bceSAndroid Build Coastguard Worker }
282*35238bceSAndroid Build Coastguard Worker 
~Texture2DSpecCase(void)283*35238bceSAndroid Build Coastguard Worker Texture2DSpecCase::~Texture2DSpecCase(void)
284*35238bceSAndroid Build Coastguard Worker {
285*35238bceSAndroid Build Coastguard Worker }
286*35238bceSAndroid Build Coastguard Worker 
verifyTexture(sglr::GLContext & gles3Context,sglr::ReferenceContext & refContext)287*35238bceSAndroid Build Coastguard Worker void Texture2DSpecCase::verifyTexture(sglr::GLContext &gles3Context, sglr::ReferenceContext &refContext)
288*35238bceSAndroid Build Coastguard Worker {
289*35238bceSAndroid Build Coastguard Worker     Texture2DShader shader(DataTypes() << glu::getSampler2DType(m_texFormat), glu::TYPE_FLOAT_VEC4);
290*35238bceSAndroid Build Coastguard Worker     uint32_t shaderIDgles = gles3Context.createProgram(&shader);
291*35238bceSAndroid Build Coastguard Worker     uint32_t shaderIDRef  = refContext.createProgram(&shader);
292*35238bceSAndroid Build Coastguard Worker 
293*35238bceSAndroid Build Coastguard Worker     shader.setTexScaleBias(0, m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
294*35238bceSAndroid Build Coastguard Worker 
295*35238bceSAndroid Build Coastguard Worker     // Set state.
296*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < 2; ndx++)
297*35238bceSAndroid Build Coastguard Worker     {
298*35238bceSAndroid Build Coastguard Worker         sglr::Context *ctx =
299*35238bceSAndroid Build Coastguard Worker             ndx ? static_cast<sglr::Context *>(&refContext) : static_cast<sglr::Context *>(&gles3Context);
300*35238bceSAndroid Build Coastguard Worker 
301*35238bceSAndroid Build Coastguard Worker         setContext(ctx);
302*35238bceSAndroid Build Coastguard Worker 
303*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
304*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
305*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
306*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
307*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, m_numLevels - 1);
308*35238bceSAndroid Build Coastguard Worker     }
309*35238bceSAndroid Build Coastguard Worker 
310*35238bceSAndroid Build Coastguard Worker     for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
311*35238bceSAndroid Build Coastguard Worker     {
312*35238bceSAndroid Build Coastguard Worker         int levelW = de::max(1, m_width >> levelNdx);
313*35238bceSAndroid Build Coastguard Worker         int levelH = de::max(1, m_height >> levelNdx);
314*35238bceSAndroid Build Coastguard Worker         tcu::Surface reference;
315*35238bceSAndroid Build Coastguard Worker         tcu::Surface result;
316*35238bceSAndroid Build Coastguard Worker 
317*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < 2; ndx++)
318*35238bceSAndroid Build Coastguard Worker         {
319*35238bceSAndroid Build Coastguard Worker             tcu::Surface &dst = ndx ? reference : result;
320*35238bceSAndroid Build Coastguard Worker             sglr::Context *ctx =
321*35238bceSAndroid Build Coastguard Worker                 ndx ? static_cast<sglr::Context *>(&refContext) : static_cast<sglr::Context *>(&gles3Context);
322*35238bceSAndroid Build Coastguard Worker             uint32_t shaderID = ndx ? shaderIDRef : shaderIDgles;
323*35238bceSAndroid Build Coastguard Worker 
324*35238bceSAndroid Build Coastguard Worker             setContext(ctx);
325*35238bceSAndroid Build Coastguard Worker             shader.setUniforms(*ctx, shaderID);
326*35238bceSAndroid Build Coastguard Worker             renderTex(dst, shaderID, levelW, levelH);
327*35238bceSAndroid Build Coastguard Worker         }
328*35238bceSAndroid Build Coastguard Worker 
329*35238bceSAndroid Build Coastguard Worker         UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
330*35238bceSAndroid Build Coastguard Worker         string levelStr = de::toString(levelNdx);
331*35238bceSAndroid Build Coastguard Worker         string name     = string("Level") + levelStr;
332*35238bceSAndroid Build Coastguard Worker         string desc     = string("Level ") + levelStr;
333*35238bceSAndroid Build Coastguard Worker         bool isOk = tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(),
334*35238bceSAndroid Build Coastguard Worker                                              result.getAccess(), threshold,
335*35238bceSAndroid Build Coastguard Worker                                              levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
336*35238bceSAndroid Build Coastguard Worker 
337*35238bceSAndroid Build Coastguard Worker         if (!isOk)
338*35238bceSAndroid Build Coastguard Worker         {
339*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
340*35238bceSAndroid Build Coastguard Worker             break;
341*35238bceSAndroid Build Coastguard Worker         }
342*35238bceSAndroid Build Coastguard Worker     }
343*35238bceSAndroid Build Coastguard Worker }
344*35238bceSAndroid Build Coastguard Worker 
345*35238bceSAndroid Build Coastguard Worker class TextureCubeSpecCase : public TextureSpecCase
346*35238bceSAndroid Build Coastguard Worker {
347*35238bceSAndroid Build Coastguard Worker public:
348*35238bceSAndroid Build Coastguard Worker     TextureCubeSpecCase(Context &context, const char *name, const char *desc, const tcu::TextureFormat &format,
349*35238bceSAndroid Build Coastguard Worker                         int size, int numLevels);
350*35238bceSAndroid Build Coastguard Worker     ~TextureCubeSpecCase(void);
351*35238bceSAndroid Build Coastguard Worker 
352*35238bceSAndroid Build Coastguard Worker protected:
353*35238bceSAndroid Build Coastguard Worker     virtual void verifyTexture(sglr::GLContext &gles3Context, sglr::ReferenceContext &refContext);
354*35238bceSAndroid Build Coastguard Worker 
355*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormat m_texFormat;
356*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo m_texFormatInfo;
357*35238bceSAndroid Build Coastguard Worker     int m_size;
358*35238bceSAndroid Build Coastguard Worker     int m_numLevels;
359*35238bceSAndroid Build Coastguard Worker };
360*35238bceSAndroid Build Coastguard Worker 
TextureCubeSpecCase(Context & context,const char * name,const char * desc,const tcu::TextureFormat & format,int size,int numLevels)361*35238bceSAndroid Build Coastguard Worker TextureCubeSpecCase::TextureCubeSpecCase(Context &context, const char *name, const char *desc,
362*35238bceSAndroid Build Coastguard Worker                                          const tcu::TextureFormat &format, int size, int numLevels)
363*35238bceSAndroid Build Coastguard Worker     : TextureSpecCase(context, name, desc)
364*35238bceSAndroid Build Coastguard Worker     , m_texFormat(format)
365*35238bceSAndroid Build Coastguard Worker     , m_texFormatInfo(tcu::getTextureFormatInfo(format))
366*35238bceSAndroid Build Coastguard Worker     , m_size(size)
367*35238bceSAndroid Build Coastguard Worker     , m_numLevels(numLevels)
368*35238bceSAndroid Build Coastguard Worker {
369*35238bceSAndroid Build Coastguard Worker }
370*35238bceSAndroid Build Coastguard Worker 
~TextureCubeSpecCase(void)371*35238bceSAndroid Build Coastguard Worker TextureCubeSpecCase::~TextureCubeSpecCase(void)
372*35238bceSAndroid Build Coastguard Worker {
373*35238bceSAndroid Build Coastguard Worker }
374*35238bceSAndroid Build Coastguard Worker 
verifyTexture(sglr::GLContext & gles3Context,sglr::ReferenceContext & refContext)375*35238bceSAndroid Build Coastguard Worker void TextureCubeSpecCase::verifyTexture(sglr::GLContext &gles3Context, sglr::ReferenceContext &refContext)
376*35238bceSAndroid Build Coastguard Worker {
377*35238bceSAndroid Build Coastguard Worker     TextureCubeShader shader(glu::getSamplerCubeType(m_texFormat), glu::TYPE_FLOAT_VEC4);
378*35238bceSAndroid Build Coastguard Worker     uint32_t shaderIDgles = gles3Context.createProgram(&shader);
379*35238bceSAndroid Build Coastguard Worker     uint32_t shaderIDRef  = refContext.createProgram(&shader);
380*35238bceSAndroid Build Coastguard Worker 
381*35238bceSAndroid Build Coastguard Worker     shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
382*35238bceSAndroid Build Coastguard Worker 
383*35238bceSAndroid Build Coastguard Worker     // Set state.
384*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < 2; ndx++)
385*35238bceSAndroid Build Coastguard Worker     {
386*35238bceSAndroid Build Coastguard Worker         sglr::Context *ctx =
387*35238bceSAndroid Build Coastguard Worker             ndx ? static_cast<sglr::Context *>(&refContext) : static_cast<sglr::Context *>(&gles3Context);
388*35238bceSAndroid Build Coastguard Worker 
389*35238bceSAndroid Build Coastguard Worker         setContext(ctx);
390*35238bceSAndroid Build Coastguard Worker 
391*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
392*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
393*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
394*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
395*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, m_numLevels - 1);
396*35238bceSAndroid Build Coastguard Worker     }
397*35238bceSAndroid Build Coastguard Worker 
398*35238bceSAndroid Build Coastguard Worker     for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
399*35238bceSAndroid Build Coastguard Worker     {
400*35238bceSAndroid Build Coastguard Worker         int levelSize = de::max(1, m_size >> levelNdx);
401*35238bceSAndroid Build Coastguard Worker         bool isOk     = true;
402*35238bceSAndroid Build Coastguard Worker 
403*35238bceSAndroid Build Coastguard Worker         for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
404*35238bceSAndroid Build Coastguard Worker         {
405*35238bceSAndroid Build Coastguard Worker             tcu::Surface reference;
406*35238bceSAndroid Build Coastguard Worker             tcu::Surface result;
407*35238bceSAndroid Build Coastguard Worker 
408*35238bceSAndroid Build Coastguard Worker             if (levelSize <= 2)
409*35238bceSAndroid Build Coastguard Worker                 continue; // Fuzzy compare doesn't work for images this small.
410*35238bceSAndroid Build Coastguard Worker 
411*35238bceSAndroid Build Coastguard Worker             shader.setFace((tcu::CubeFace)face);
412*35238bceSAndroid Build Coastguard Worker 
413*35238bceSAndroid Build Coastguard Worker             for (int ndx = 0; ndx < 2; ndx++)
414*35238bceSAndroid Build Coastguard Worker             {
415*35238bceSAndroid Build Coastguard Worker                 tcu::Surface &dst = ndx ? reference : result;
416*35238bceSAndroid Build Coastguard Worker                 sglr::Context *ctx =
417*35238bceSAndroid Build Coastguard Worker                     ndx ? static_cast<sglr::Context *>(&refContext) : static_cast<sglr::Context *>(&gles3Context);
418*35238bceSAndroid Build Coastguard Worker                 uint32_t shaderID = ndx ? shaderIDRef : shaderIDgles;
419*35238bceSAndroid Build Coastguard Worker 
420*35238bceSAndroid Build Coastguard Worker                 setContext(ctx);
421*35238bceSAndroid Build Coastguard Worker                 shader.setUniforms(*ctx, shaderID);
422*35238bceSAndroid Build Coastguard Worker                 renderTex(dst, shaderID, levelSize, levelSize);
423*35238bceSAndroid Build Coastguard Worker             }
424*35238bceSAndroid Build Coastguard Worker 
425*35238bceSAndroid Build Coastguard Worker             const float threshold = 0.02f;
426*35238bceSAndroid Build Coastguard Worker             string faceStr        = de::toString((tcu::CubeFace)face);
427*35238bceSAndroid Build Coastguard Worker             string levelStr       = de::toString(levelNdx);
428*35238bceSAndroid Build Coastguard Worker             string name           = string("Level") + levelStr;
429*35238bceSAndroid Build Coastguard Worker             string desc           = string("Level ") + levelStr + ", face " + faceStr;
430*35238bceSAndroid Build Coastguard Worker             bool isFaceOk =
431*35238bceSAndroid Build Coastguard Worker                 tcu::fuzzyCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference, result, threshold,
432*35238bceSAndroid Build Coastguard Worker                                   levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
433*35238bceSAndroid Build Coastguard Worker 
434*35238bceSAndroid Build Coastguard Worker             if (!isFaceOk)
435*35238bceSAndroid Build Coastguard Worker             {
436*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
437*35238bceSAndroid Build Coastguard Worker                 isOk = false;
438*35238bceSAndroid Build Coastguard Worker                 break;
439*35238bceSAndroid Build Coastguard Worker             }
440*35238bceSAndroid Build Coastguard Worker         }
441*35238bceSAndroid Build Coastguard Worker 
442*35238bceSAndroid Build Coastguard Worker         if (!isOk)
443*35238bceSAndroid Build Coastguard Worker             break;
444*35238bceSAndroid Build Coastguard Worker     }
445*35238bceSAndroid Build Coastguard Worker }
446*35238bceSAndroid Build Coastguard Worker 
447*35238bceSAndroid Build Coastguard Worker class Texture2DArraySpecCase : public TextureSpecCase
448*35238bceSAndroid Build Coastguard Worker {
449*35238bceSAndroid Build Coastguard Worker public:
450*35238bceSAndroid Build Coastguard Worker     Texture2DArraySpecCase(Context &context, const char *name, const char *desc, const tcu::TextureFormat &format,
451*35238bceSAndroid Build Coastguard Worker                            int width, int height, int numLayers, int numLevels);
452*35238bceSAndroid Build Coastguard Worker     ~Texture2DArraySpecCase(void);
453*35238bceSAndroid Build Coastguard Worker 
454*35238bceSAndroid Build Coastguard Worker protected:
455*35238bceSAndroid Build Coastguard Worker     virtual void verifyTexture(sglr::GLContext &gles3Context, sglr::ReferenceContext &refContext);
456*35238bceSAndroid Build Coastguard Worker 
457*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormat m_texFormat;
458*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo m_texFormatInfo;
459*35238bceSAndroid Build Coastguard Worker     int m_width;
460*35238bceSAndroid Build Coastguard Worker     int m_height;
461*35238bceSAndroid Build Coastguard Worker     int m_numLayers;
462*35238bceSAndroid Build Coastguard Worker     int m_numLevels;
463*35238bceSAndroid Build Coastguard Worker };
464*35238bceSAndroid Build Coastguard Worker 
Texture2DArraySpecCase(Context & context,const char * name,const char * desc,const tcu::TextureFormat & format,int width,int height,int numLayers,int numLevels)465*35238bceSAndroid Build Coastguard Worker Texture2DArraySpecCase::Texture2DArraySpecCase(Context &context, const char *name, const char *desc,
466*35238bceSAndroid Build Coastguard Worker                                                const tcu::TextureFormat &format, int width, int height, int numLayers,
467*35238bceSAndroid Build Coastguard Worker                                                int numLevels)
468*35238bceSAndroid Build Coastguard Worker     : TextureSpecCase(context, name, desc)
469*35238bceSAndroid Build Coastguard Worker     , m_texFormat(format)
470*35238bceSAndroid Build Coastguard Worker     , m_texFormatInfo(tcu::getTextureFormatInfo(format))
471*35238bceSAndroid Build Coastguard Worker     , m_width(width)
472*35238bceSAndroid Build Coastguard Worker     , m_height(height)
473*35238bceSAndroid Build Coastguard Worker     , m_numLayers(numLayers)
474*35238bceSAndroid Build Coastguard Worker     , m_numLevels(numLevels)
475*35238bceSAndroid Build Coastguard Worker {
476*35238bceSAndroid Build Coastguard Worker }
477*35238bceSAndroid Build Coastguard Worker 
~Texture2DArraySpecCase(void)478*35238bceSAndroid Build Coastguard Worker Texture2DArraySpecCase::~Texture2DArraySpecCase(void)
479*35238bceSAndroid Build Coastguard Worker {
480*35238bceSAndroid Build Coastguard Worker }
481*35238bceSAndroid Build Coastguard Worker 
verifyTexture(sglr::GLContext & gles3Context,sglr::ReferenceContext & refContext)482*35238bceSAndroid Build Coastguard Worker void Texture2DArraySpecCase::verifyTexture(sglr::GLContext &gles3Context, sglr::ReferenceContext &refContext)
483*35238bceSAndroid Build Coastguard Worker {
484*35238bceSAndroid Build Coastguard Worker     Texture2DArrayShader shader(glu::getSampler2DArrayType(m_texFormat), glu::TYPE_FLOAT_VEC4);
485*35238bceSAndroid Build Coastguard Worker     uint32_t shaderIDgles = gles3Context.createProgram(&shader);
486*35238bceSAndroid Build Coastguard Worker     uint32_t shaderIDRef  = refContext.createProgram(&shader);
487*35238bceSAndroid Build Coastguard Worker 
488*35238bceSAndroid Build Coastguard Worker     shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
489*35238bceSAndroid Build Coastguard Worker 
490*35238bceSAndroid Build Coastguard Worker     // Set state.
491*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < 2; ndx++)
492*35238bceSAndroid Build Coastguard Worker     {
493*35238bceSAndroid Build Coastguard Worker         sglr::Context *ctx =
494*35238bceSAndroid Build Coastguard Worker             ndx ? static_cast<sglr::Context *>(&refContext) : static_cast<sglr::Context *>(&gles3Context);
495*35238bceSAndroid Build Coastguard Worker 
496*35238bceSAndroid Build Coastguard Worker         setContext(ctx);
497*35238bceSAndroid Build Coastguard Worker 
498*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
499*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
500*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
501*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
502*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
503*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, m_numLevels - 1);
504*35238bceSAndroid Build Coastguard Worker     }
505*35238bceSAndroid Build Coastguard Worker 
506*35238bceSAndroid Build Coastguard Worker     for (int layerNdx = 0; layerNdx < m_numLayers; layerNdx++)
507*35238bceSAndroid Build Coastguard Worker     {
508*35238bceSAndroid Build Coastguard Worker         bool layerOk = true;
509*35238bceSAndroid Build Coastguard Worker 
510*35238bceSAndroid Build Coastguard Worker         shader.setLayer(layerNdx);
511*35238bceSAndroid Build Coastguard Worker 
512*35238bceSAndroid Build Coastguard Worker         for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
513*35238bceSAndroid Build Coastguard Worker         {
514*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> levelNdx);
515*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> levelNdx);
516*35238bceSAndroid Build Coastguard Worker             tcu::Surface reference;
517*35238bceSAndroid Build Coastguard Worker             tcu::Surface result;
518*35238bceSAndroid Build Coastguard Worker 
519*35238bceSAndroid Build Coastguard Worker             for (int ndx = 0; ndx < 2; ndx++)
520*35238bceSAndroid Build Coastguard Worker             {
521*35238bceSAndroid Build Coastguard Worker                 tcu::Surface &dst = ndx ? reference : result;
522*35238bceSAndroid Build Coastguard Worker                 sglr::Context *ctx =
523*35238bceSAndroid Build Coastguard Worker                     ndx ? static_cast<sglr::Context *>(&refContext) : static_cast<sglr::Context *>(&gles3Context);
524*35238bceSAndroid Build Coastguard Worker                 uint32_t shaderID = ndx ? shaderIDRef : shaderIDgles;
525*35238bceSAndroid Build Coastguard Worker 
526*35238bceSAndroid Build Coastguard Worker                 setContext(ctx);
527*35238bceSAndroid Build Coastguard Worker                 shader.setUniforms(*ctx, shaderID);
528*35238bceSAndroid Build Coastguard Worker                 renderTex(dst, shaderID, levelW, levelH);
529*35238bceSAndroid Build Coastguard Worker             }
530*35238bceSAndroid Build Coastguard Worker 
531*35238bceSAndroid Build Coastguard Worker             UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
532*35238bceSAndroid Build Coastguard Worker             string levelStr = de::toString(levelNdx);
533*35238bceSAndroid Build Coastguard Worker             string layerStr = de::toString(layerNdx);
534*35238bceSAndroid Build Coastguard Worker             string name     = string("Layer") + layerStr + "Level" + levelStr;
535*35238bceSAndroid Build Coastguard Worker             string desc     = string("Layer ") + layerStr + ", Level " + levelStr;
536*35238bceSAndroid Build Coastguard Worker             bool depthOk    = tcu::intThresholdCompare(
537*35238bceSAndroid Build Coastguard Worker                 m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold,
538*35238bceSAndroid Build Coastguard Worker                 (levelNdx == 0 && layerNdx == 0) ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
539*35238bceSAndroid Build Coastguard Worker 
540*35238bceSAndroid Build Coastguard Worker             if (!depthOk)
541*35238bceSAndroid Build Coastguard Worker             {
542*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
543*35238bceSAndroid Build Coastguard Worker                 layerOk = false;
544*35238bceSAndroid Build Coastguard Worker                 break;
545*35238bceSAndroid Build Coastguard Worker             }
546*35238bceSAndroid Build Coastguard Worker         }
547*35238bceSAndroid Build Coastguard Worker 
548*35238bceSAndroid Build Coastguard Worker         if (!layerOk)
549*35238bceSAndroid Build Coastguard Worker             break;
550*35238bceSAndroid Build Coastguard Worker     }
551*35238bceSAndroid Build Coastguard Worker }
552*35238bceSAndroid Build Coastguard Worker 
553*35238bceSAndroid Build Coastguard Worker class Texture3DSpecCase : public TextureSpecCase
554*35238bceSAndroid Build Coastguard Worker {
555*35238bceSAndroid Build Coastguard Worker public:
556*35238bceSAndroid Build Coastguard Worker     Texture3DSpecCase(Context &context, const char *name, const char *desc, const tcu::TextureFormat &format, int width,
557*35238bceSAndroid Build Coastguard Worker                       int height, int depth, int numLevels);
558*35238bceSAndroid Build Coastguard Worker     ~Texture3DSpecCase(void);
559*35238bceSAndroid Build Coastguard Worker 
560*35238bceSAndroid Build Coastguard Worker protected:
561*35238bceSAndroid Build Coastguard Worker     virtual void verifyTexture(sglr::GLContext &gles3Context, sglr::ReferenceContext &refContext);
562*35238bceSAndroid Build Coastguard Worker 
563*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormat m_texFormat;
564*35238bceSAndroid Build Coastguard Worker     tcu::TextureFormatInfo m_texFormatInfo;
565*35238bceSAndroid Build Coastguard Worker     int m_width;
566*35238bceSAndroid Build Coastguard Worker     int m_height;
567*35238bceSAndroid Build Coastguard Worker     int m_depth;
568*35238bceSAndroid Build Coastguard Worker     int m_numLevels;
569*35238bceSAndroid Build Coastguard Worker };
570*35238bceSAndroid Build Coastguard Worker 
Texture3DSpecCase(Context & context,const char * name,const char * desc,const tcu::TextureFormat & format,int width,int height,int depth,int numLevels)571*35238bceSAndroid Build Coastguard Worker Texture3DSpecCase::Texture3DSpecCase(Context &context, const char *name, const char *desc,
572*35238bceSAndroid Build Coastguard Worker                                      const tcu::TextureFormat &format, int width, int height, int depth, int numLevels)
573*35238bceSAndroid Build Coastguard Worker     : TextureSpecCase(context, name, desc)
574*35238bceSAndroid Build Coastguard Worker     , m_texFormat(format)
575*35238bceSAndroid Build Coastguard Worker     , m_texFormatInfo(tcu::getTextureFormatInfo(format))
576*35238bceSAndroid Build Coastguard Worker     , m_width(width)
577*35238bceSAndroid Build Coastguard Worker     , m_height(height)
578*35238bceSAndroid Build Coastguard Worker     , m_depth(depth)
579*35238bceSAndroid Build Coastguard Worker     , m_numLevels(numLevels)
580*35238bceSAndroid Build Coastguard Worker {
581*35238bceSAndroid Build Coastguard Worker }
582*35238bceSAndroid Build Coastguard Worker 
~Texture3DSpecCase(void)583*35238bceSAndroid Build Coastguard Worker Texture3DSpecCase::~Texture3DSpecCase(void)
584*35238bceSAndroid Build Coastguard Worker {
585*35238bceSAndroid Build Coastguard Worker }
586*35238bceSAndroid Build Coastguard Worker 
verifyTexture(sglr::GLContext & gles3Context,sglr::ReferenceContext & refContext)587*35238bceSAndroid Build Coastguard Worker void Texture3DSpecCase::verifyTexture(sglr::GLContext &gles3Context, sglr::ReferenceContext &refContext)
588*35238bceSAndroid Build Coastguard Worker {
589*35238bceSAndroid Build Coastguard Worker     Texture3DShader shader(glu::getSampler3DType(m_texFormat), glu::TYPE_FLOAT_VEC4);
590*35238bceSAndroid Build Coastguard Worker     uint32_t shaderIDgles = gles3Context.createProgram(&shader);
591*35238bceSAndroid Build Coastguard Worker     uint32_t shaderIDRef  = refContext.createProgram(&shader);
592*35238bceSAndroid Build Coastguard Worker 
593*35238bceSAndroid Build Coastguard Worker     shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
594*35238bceSAndroid Build Coastguard Worker 
595*35238bceSAndroid Build Coastguard Worker     // Set state.
596*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < 2; ndx++)
597*35238bceSAndroid Build Coastguard Worker     {
598*35238bceSAndroid Build Coastguard Worker         sglr::Context *ctx =
599*35238bceSAndroid Build Coastguard Worker             ndx ? static_cast<sglr::Context *>(&refContext) : static_cast<sglr::Context *>(&gles3Context);
600*35238bceSAndroid Build Coastguard Worker 
601*35238bceSAndroid Build Coastguard Worker         setContext(ctx);
602*35238bceSAndroid Build Coastguard Worker 
603*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
604*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
605*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
606*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
607*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
608*35238bceSAndroid Build Coastguard Worker         glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, m_numLevels - 1);
609*35238bceSAndroid Build Coastguard Worker     }
610*35238bceSAndroid Build Coastguard Worker 
611*35238bceSAndroid Build Coastguard Worker     for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
612*35238bceSAndroid Build Coastguard Worker     {
613*35238bceSAndroid Build Coastguard Worker         int levelW   = de::max(1, m_width >> levelNdx);
614*35238bceSAndroid Build Coastguard Worker         int levelH   = de::max(1, m_height >> levelNdx);
615*35238bceSAndroid Build Coastguard Worker         int levelD   = de::max(1, m_depth >> levelNdx);
616*35238bceSAndroid Build Coastguard Worker         bool levelOk = true;
617*35238bceSAndroid Build Coastguard Worker 
618*35238bceSAndroid Build Coastguard Worker         for (int depth = 0; depth < levelD; depth++)
619*35238bceSAndroid Build Coastguard Worker         {
620*35238bceSAndroid Build Coastguard Worker             tcu::Surface reference;
621*35238bceSAndroid Build Coastguard Worker             tcu::Surface result;
622*35238bceSAndroid Build Coastguard Worker 
623*35238bceSAndroid Build Coastguard Worker             shader.setDepth(((float)depth + 0.5f) / (float)levelD);
624*35238bceSAndroid Build Coastguard Worker 
625*35238bceSAndroid Build Coastguard Worker             for (int ndx = 0; ndx < 2; ndx++)
626*35238bceSAndroid Build Coastguard Worker             {
627*35238bceSAndroid Build Coastguard Worker                 tcu::Surface &dst = ndx ? reference : result;
628*35238bceSAndroid Build Coastguard Worker                 sglr::Context *ctx =
629*35238bceSAndroid Build Coastguard Worker                     ndx ? static_cast<sglr::Context *>(&refContext) : static_cast<sglr::Context *>(&gles3Context);
630*35238bceSAndroid Build Coastguard Worker                 uint32_t shaderID = ndx ? shaderIDRef : shaderIDgles;
631*35238bceSAndroid Build Coastguard Worker 
632*35238bceSAndroid Build Coastguard Worker                 setContext(ctx);
633*35238bceSAndroid Build Coastguard Worker                 shader.setUniforms(*ctx, shaderID);
634*35238bceSAndroid Build Coastguard Worker                 renderTex(dst, shaderID, levelW, levelH);
635*35238bceSAndroid Build Coastguard Worker             }
636*35238bceSAndroid Build Coastguard Worker 
637*35238bceSAndroid Build Coastguard Worker             UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
638*35238bceSAndroid Build Coastguard Worker             string levelStr = de::toString(levelNdx);
639*35238bceSAndroid Build Coastguard Worker             string sliceStr = de::toString(depth);
640*35238bceSAndroid Build Coastguard Worker             string name     = string("Level") + levelStr + "Slice" + sliceStr;
641*35238bceSAndroid Build Coastguard Worker             string desc     = string("Level ") + levelStr + ", Slice " + sliceStr;
642*35238bceSAndroid Build Coastguard Worker             bool depthOk    = tcu::intThresholdCompare(
643*35238bceSAndroid Build Coastguard Worker                 m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold,
644*35238bceSAndroid Build Coastguard Worker                 (levelNdx == 0 && depth == 0) ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
645*35238bceSAndroid Build Coastguard Worker 
646*35238bceSAndroid Build Coastguard Worker             if (!depthOk)
647*35238bceSAndroid Build Coastguard Worker             {
648*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
649*35238bceSAndroid Build Coastguard Worker                 levelOk = false;
650*35238bceSAndroid Build Coastguard Worker                 break;
651*35238bceSAndroid Build Coastguard Worker             }
652*35238bceSAndroid Build Coastguard Worker         }
653*35238bceSAndroid Build Coastguard Worker 
654*35238bceSAndroid Build Coastguard Worker         if (!levelOk)
655*35238bceSAndroid Build Coastguard Worker             break;
656*35238bceSAndroid Build Coastguard Worker     }
657*35238bceSAndroid Build Coastguard Worker }
658*35238bceSAndroid Build Coastguard Worker 
659*35238bceSAndroid Build Coastguard Worker // Basic TexImage2D() with 2D texture usage
660*35238bceSAndroid Build Coastguard Worker class BasicTexImage2DCase : public Texture2DSpecCase
661*35238bceSAndroid Build Coastguard Worker {
662*35238bceSAndroid Build Coastguard Worker public:
663*35238bceSAndroid Build Coastguard Worker     // Unsized internal format.
BasicTexImage2DCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int width,int height)664*35238bceSAndroid Build Coastguard Worker     BasicTexImage2DCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
665*35238bceSAndroid Build Coastguard Worker                         int width, int height)
666*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height,
667*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height))
668*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
669*35238bceSAndroid Build Coastguard Worker         , m_format(format)
670*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
671*35238bceSAndroid Build Coastguard Worker     {
672*35238bceSAndroid Build Coastguard Worker     }
673*35238bceSAndroid Build Coastguard Worker 
674*35238bceSAndroid Build Coastguard Worker     // Sized internal format.
BasicTexImage2DCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height)675*35238bceSAndroid Build Coastguard Worker     BasicTexImage2DCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
676*35238bceSAndroid Build Coastguard Worker                         int height)
677*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height,
678*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height))
679*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
680*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
681*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
682*35238bceSAndroid Build Coastguard Worker     {
683*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
684*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
685*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
686*35238bceSAndroid Build Coastguard Worker     }
687*35238bceSAndroid Build Coastguard Worker 
688*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)689*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
690*35238bceSAndroid Build Coastguard Worker     {
691*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
692*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(m_format, m_dataType));
693*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
694*35238bceSAndroid Build Coastguard Worker 
695*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
696*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
697*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
698*35238bceSAndroid Build Coastguard Worker 
699*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
700*35238bceSAndroid Build Coastguard Worker         {
701*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
702*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
703*35238bceSAndroid Build Coastguard Worker             Vec4 gMin  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
704*35238bceSAndroid Build Coastguard Worker             Vec4 gMax  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
705*35238bceSAndroid Build Coastguard Worker 
706*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH);
707*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
708*35238bceSAndroid Build Coastguard Worker 
709*35238bceSAndroid Build Coastguard Worker             glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType,
710*35238bceSAndroid Build Coastguard Worker                          levelData.getAccess().getDataPtr());
711*35238bceSAndroid Build Coastguard Worker         }
712*35238bceSAndroid Build Coastguard Worker     }
713*35238bceSAndroid Build Coastguard Worker 
714*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
715*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
716*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
717*35238bceSAndroid Build Coastguard Worker };
718*35238bceSAndroid Build Coastguard Worker 
719*35238bceSAndroid Build Coastguard Worker // Basic TexImage2D() with cubemap usage
720*35238bceSAndroid Build Coastguard Worker class BasicTexImageCubeCase : public TextureCubeSpecCase
721*35238bceSAndroid Build Coastguard Worker {
722*35238bceSAndroid Build Coastguard Worker public:
723*35238bceSAndroid Build Coastguard Worker     // Unsized formats.
BasicTexImageCubeCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int size)724*35238bceSAndroid Build Coastguard Worker     BasicTexImageCubeCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
725*35238bceSAndroid Build Coastguard Worker                           int size)
726*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), size,
727*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
728*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
729*35238bceSAndroid Build Coastguard Worker         , m_format(format)
730*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
731*35238bceSAndroid Build Coastguard Worker     {
732*35238bceSAndroid Build Coastguard Worker     }
733*35238bceSAndroid Build Coastguard Worker 
734*35238bceSAndroid Build Coastguard Worker     // Sized internal formats.
BasicTexImageCubeCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size)735*35238bceSAndroid Build Coastguard Worker     BasicTexImageCubeCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size)
736*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), size,
737*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
738*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
739*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
740*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
741*35238bceSAndroid Build Coastguard Worker     {
742*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
743*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
744*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
745*35238bceSAndroid Build Coastguard Worker     }
746*35238bceSAndroid Build Coastguard Worker 
747*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)748*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
749*35238bceSAndroid Build Coastguard Worker     {
750*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
751*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(m_format, m_dataType));
752*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
753*35238bceSAndroid Build Coastguard Worker 
754*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
755*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
756*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
757*35238bceSAndroid Build Coastguard Worker 
758*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
759*35238bceSAndroid Build Coastguard Worker         {
760*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
761*35238bceSAndroid Build Coastguard Worker 
762*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelSize, levelSize);
763*35238bceSAndroid Build Coastguard Worker 
764*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
765*35238bceSAndroid Build Coastguard Worker             {
766*35238bceSAndroid Build Coastguard Worker                 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
767*35238bceSAndroid Build Coastguard Worker                 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
768*35238bceSAndroid Build Coastguard Worker 
769*35238bceSAndroid Build Coastguard Worker                 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
770*35238bceSAndroid Build Coastguard Worker 
771*35238bceSAndroid Build Coastguard Worker                 glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType,
772*35238bceSAndroid Build Coastguard Worker                              levelData.getAccess().getDataPtr());
773*35238bceSAndroid Build Coastguard Worker             }
774*35238bceSAndroid Build Coastguard Worker         }
775*35238bceSAndroid Build Coastguard Worker     }
776*35238bceSAndroid Build Coastguard Worker 
777*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
778*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
779*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
780*35238bceSAndroid Build Coastguard Worker };
781*35238bceSAndroid Build Coastguard Worker 
782*35238bceSAndroid Build Coastguard Worker // Basic TexImage3D() with 2D array texture usage
783*35238bceSAndroid Build Coastguard Worker class BasicTexImage2DArrayCase : public Texture2DArraySpecCase
784*35238bceSAndroid Build Coastguard Worker {
785*35238bceSAndroid Build Coastguard Worker public:
BasicTexImage2DArrayCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int numLayers)786*35238bceSAndroid Build Coastguard Worker     BasicTexImage2DArrayCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
787*35238bceSAndroid Build Coastguard Worker                              int height, int numLayers)
788*35238bceSAndroid Build Coastguard Worker         : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height,
789*35238bceSAndroid Build Coastguard Worker                                  numLayers, maxLevelCount(width, height))
790*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
791*35238bceSAndroid Build Coastguard Worker     {
792*35238bceSAndroid Build Coastguard Worker     }
793*35238bceSAndroid Build Coastguard Worker 
794*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)795*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
796*35238bceSAndroid Build Coastguard Worker     {
797*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
798*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
799*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
800*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
801*35238bceSAndroid Build Coastguard Worker 
802*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
803*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
804*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
805*35238bceSAndroid Build Coastguard Worker 
806*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
807*35238bceSAndroid Build Coastguard Worker         {
808*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
809*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
810*35238bceSAndroid Build Coastguard Worker             Vec4 gMin  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
811*35238bceSAndroid Build Coastguard Worker             Vec4 gMax  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
812*35238bceSAndroid Build Coastguard Worker 
813*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH, m_numLayers);
814*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
815*35238bceSAndroid Build Coastguard Worker 
816*35238bceSAndroid Build Coastguard Worker             glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, transferFmt.format,
817*35238bceSAndroid Build Coastguard Worker                          transferFmt.dataType, levelData.getAccess().getDataPtr());
818*35238bceSAndroid Build Coastguard Worker         }
819*35238bceSAndroid Build Coastguard Worker     }
820*35238bceSAndroid Build Coastguard Worker 
821*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
822*35238bceSAndroid Build Coastguard Worker };
823*35238bceSAndroid Build Coastguard Worker 
824*35238bceSAndroid Build Coastguard Worker // Basic TexImage3D() with 3D texture usage
825*35238bceSAndroid Build Coastguard Worker class BasicTexImage3DCase : public Texture3DSpecCase
826*35238bceSAndroid Build Coastguard Worker {
827*35238bceSAndroid Build Coastguard Worker public:
BasicTexImage3DCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int depth)828*35238bceSAndroid Build Coastguard Worker     BasicTexImage3DCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
829*35238bceSAndroid Build Coastguard Worker                         int height, int depth)
830*35238bceSAndroid Build Coastguard Worker         : Texture3DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth,
831*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height, depth))
832*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
833*35238bceSAndroid Build Coastguard Worker     {
834*35238bceSAndroid Build Coastguard Worker     }
835*35238bceSAndroid Build Coastguard Worker 
836*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)837*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
838*35238bceSAndroid Build Coastguard Worker     {
839*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
840*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
841*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
842*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
843*35238bceSAndroid Build Coastguard Worker 
844*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
845*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_3D, tex);
846*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
847*35238bceSAndroid Build Coastguard Worker 
848*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
849*35238bceSAndroid Build Coastguard Worker         {
850*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
851*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
852*35238bceSAndroid Build Coastguard Worker             int levelD = de::max(1, m_depth >> ndx);
853*35238bceSAndroid Build Coastguard Worker             Vec4 gMin  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
854*35238bceSAndroid Build Coastguard Worker             Vec4 gMax  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
855*35238bceSAndroid Build Coastguard Worker 
856*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH, levelD);
857*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
858*35238bceSAndroid Build Coastguard Worker 
859*35238bceSAndroid Build Coastguard Worker             glTexImage3D(GL_TEXTURE_3D, ndx, m_internalFormat, levelW, levelH, levelD, 0, transferFmt.format,
860*35238bceSAndroid Build Coastguard Worker                          transferFmt.dataType, levelData.getAccess().getDataPtr());
861*35238bceSAndroid Build Coastguard Worker         }
862*35238bceSAndroid Build Coastguard Worker     }
863*35238bceSAndroid Build Coastguard Worker 
864*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
865*35238bceSAndroid Build Coastguard Worker };
866*35238bceSAndroid Build Coastguard Worker 
867*35238bceSAndroid Build Coastguard Worker // Randomized 2D texture specification using TexImage2D
868*35238bceSAndroid Build Coastguard Worker class RandomOrderTexImage2DCase : public Texture2DSpecCase
869*35238bceSAndroid Build Coastguard Worker {
870*35238bceSAndroid Build Coastguard Worker public:
RandomOrderTexImage2DCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int width,int height)871*35238bceSAndroid Build Coastguard Worker     RandomOrderTexImage2DCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
872*35238bceSAndroid Build Coastguard Worker                               int width, int height)
873*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height,
874*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height))
875*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
876*35238bceSAndroid Build Coastguard Worker         , m_format(format)
877*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
878*35238bceSAndroid Build Coastguard Worker     {
879*35238bceSAndroid Build Coastguard Worker     }
880*35238bceSAndroid Build Coastguard Worker 
RandomOrderTexImage2DCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height)881*35238bceSAndroid Build Coastguard Worker     RandomOrderTexImage2DCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
882*35238bceSAndroid Build Coastguard Worker                               int height)
883*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height,
884*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height))
885*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
886*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
887*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
888*35238bceSAndroid Build Coastguard Worker     {
889*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
890*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
891*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
892*35238bceSAndroid Build Coastguard Worker     }
893*35238bceSAndroid Build Coastguard Worker 
894*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)895*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
896*35238bceSAndroid Build Coastguard Worker     {
897*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
898*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(m_format, m_dataType));
899*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
900*35238bceSAndroid Build Coastguard Worker 
901*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
902*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
903*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
904*35238bceSAndroid Build Coastguard Worker 
905*35238bceSAndroid Build Coastguard Worker         vector<int> levels(m_numLevels);
906*35238bceSAndroid Build Coastguard Worker 
907*35238bceSAndroid Build Coastguard Worker         for (int i = 0; i < m_numLevels; i++)
908*35238bceSAndroid Build Coastguard Worker             levels[i] = i;
909*35238bceSAndroid Build Coastguard Worker         rnd.shuffle(levels.begin(), levels.end());
910*35238bceSAndroid Build Coastguard Worker 
911*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
912*35238bceSAndroid Build Coastguard Worker         {
913*35238bceSAndroid Build Coastguard Worker             int levelNdx = levels[ndx];
914*35238bceSAndroid Build Coastguard Worker             int levelW   = de::max(1, m_width >> levelNdx);
915*35238bceSAndroid Build Coastguard Worker             int levelH   = de::max(1, m_height >> levelNdx);
916*35238bceSAndroid Build Coastguard Worker             Vec4 gMin    = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
917*35238bceSAndroid Build Coastguard Worker             Vec4 gMax    = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
918*35238bceSAndroid Build Coastguard Worker 
919*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH);
920*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
921*35238bceSAndroid Build Coastguard Worker 
922*35238bceSAndroid Build Coastguard Worker             glTexImage2D(GL_TEXTURE_2D, levelNdx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType,
923*35238bceSAndroid Build Coastguard Worker                          levelData.getAccess().getDataPtr());
924*35238bceSAndroid Build Coastguard Worker         }
925*35238bceSAndroid Build Coastguard Worker     }
926*35238bceSAndroid Build Coastguard Worker 
927*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
928*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
929*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
930*35238bceSAndroid Build Coastguard Worker };
931*35238bceSAndroid Build Coastguard Worker 
932*35238bceSAndroid Build Coastguard Worker // Randomized cubemap texture specification using TexImage2D
933*35238bceSAndroid Build Coastguard Worker class RandomOrderTexImageCubeCase : public TextureCubeSpecCase
934*35238bceSAndroid Build Coastguard Worker {
935*35238bceSAndroid Build Coastguard Worker public:
RandomOrderTexImageCubeCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int size)936*35238bceSAndroid Build Coastguard Worker     RandomOrderTexImageCubeCase(Context &context, const char *name, const char *desc, uint32_t format,
937*35238bceSAndroid Build Coastguard Worker                                 uint32_t dataType, int size)
938*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), size,
939*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
940*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(GL_NONE)
941*35238bceSAndroid Build Coastguard Worker         , m_format(format)
942*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
943*35238bceSAndroid Build Coastguard Worker     {
944*35238bceSAndroid Build Coastguard Worker     }
945*35238bceSAndroid Build Coastguard Worker 
RandomOrderTexImageCubeCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size)946*35238bceSAndroid Build Coastguard Worker     RandomOrderTexImageCubeCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size)
947*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), size,
948*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
949*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
950*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
951*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
952*35238bceSAndroid Build Coastguard Worker     {
953*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
954*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
955*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
956*35238bceSAndroid Build Coastguard Worker     }
957*35238bceSAndroid Build Coastguard Worker 
958*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)959*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
960*35238bceSAndroid Build Coastguard Worker     {
961*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
962*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(m_format, m_dataType));
963*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
964*35238bceSAndroid Build Coastguard Worker 
965*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
966*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
967*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
968*35238bceSAndroid Build Coastguard Worker 
969*35238bceSAndroid Build Coastguard Worker         // Level-face pairs.
970*35238bceSAndroid Build Coastguard Worker         vector<pair<int, tcu::CubeFace>> images(m_numLevels * 6);
971*35238bceSAndroid Build Coastguard Worker 
972*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
973*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
974*35238bceSAndroid Build Coastguard Worker                 images[ndx * 6 + face] = std::make_pair(ndx, (tcu::CubeFace)face);
975*35238bceSAndroid Build Coastguard Worker 
976*35238bceSAndroid Build Coastguard Worker         rnd.shuffle(images.begin(), images.end());
977*35238bceSAndroid Build Coastguard Worker 
978*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < (int)images.size(); ndx++)
979*35238bceSAndroid Build Coastguard Worker         {
980*35238bceSAndroid Build Coastguard Worker             int levelNdx       = images[ndx].first;
981*35238bceSAndroid Build Coastguard Worker             tcu::CubeFace face = images[ndx].second;
982*35238bceSAndroid Build Coastguard Worker             int levelSize      = de::max(1, m_size >> levelNdx);
983*35238bceSAndroid Build Coastguard Worker             Vec4 gMin          = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
984*35238bceSAndroid Build Coastguard Worker             Vec4 gMax          = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
985*35238bceSAndroid Build Coastguard Worker 
986*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelSize, levelSize);
987*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
988*35238bceSAndroid Build Coastguard Worker 
989*35238bceSAndroid Build Coastguard Worker             glTexImage2D(s_cubeMapFaces[face], levelNdx, m_internalFormat, levelSize, levelSize, 0, m_format,
990*35238bceSAndroid Build Coastguard Worker                          m_dataType, levelData.getAccess().getDataPtr());
991*35238bceSAndroid Build Coastguard Worker         }
992*35238bceSAndroid Build Coastguard Worker     }
993*35238bceSAndroid Build Coastguard Worker 
994*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
995*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
996*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
997*35238bceSAndroid Build Coastguard Worker };
998*35238bceSAndroid Build Coastguard Worker 
999*35238bceSAndroid Build Coastguard Worker // TexImage2D() unpack alignment case.
1000*35238bceSAndroid Build Coastguard Worker class TexImage2DAlignCase : public Texture2DSpecCase
1001*35238bceSAndroid Build Coastguard Worker {
1002*35238bceSAndroid Build Coastguard Worker public:
TexImage2DAlignCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int width,int height,int numLevels,int alignment)1003*35238bceSAndroid Build Coastguard Worker     TexImage2DAlignCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1004*35238bceSAndroid Build Coastguard Worker                         int width, int height, int numLevels, int alignment)
1005*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, numLevels)
1006*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
1007*35238bceSAndroid Build Coastguard Worker         , m_format(format)
1008*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
1009*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1010*35238bceSAndroid Build Coastguard Worker     {
1011*35238bceSAndroid Build Coastguard Worker     }
1012*35238bceSAndroid Build Coastguard Worker 
TexImage2DAlignCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int numLevels,int alignment)1013*35238bceSAndroid Build Coastguard Worker     TexImage2DAlignCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1014*35238bceSAndroid Build Coastguard Worker                         int height, int numLevels, int alignment)
1015*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLevels)
1016*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1017*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
1018*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
1019*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1020*35238bceSAndroid Build Coastguard Worker     {
1021*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1022*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
1023*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
1024*35238bceSAndroid Build Coastguard Worker     }
1025*35238bceSAndroid Build Coastguard Worker 
1026*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1027*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1028*35238bceSAndroid Build Coastguard Worker     {
1029*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1030*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
1031*35238bceSAndroid Build Coastguard Worker 
1032*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1033*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
1034*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1035*35238bceSAndroid Build Coastguard Worker 
1036*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1037*35238bceSAndroid Build Coastguard Worker         {
1038*35238bceSAndroid Build Coastguard Worker             int levelW  = de::max(1, m_width >> ndx);
1039*35238bceSAndroid Build Coastguard Worker             int levelH  = de::max(1, m_height >> ndx);
1040*35238bceSAndroid Build Coastguard Worker             Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * (m_texFormatInfo.valueMax - m_texFormatInfo.valueMin) +
1041*35238bceSAndroid Build Coastguard Worker                           m_texFormatInfo.valueMin;
1042*35238bceSAndroid Build Coastguard Worker             Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * (m_texFormatInfo.valueMax - m_texFormatInfo.valueMin) +
1043*35238bceSAndroid Build Coastguard Worker                           m_texFormatInfo.valueMin;
1044*35238bceSAndroid Build Coastguard Worker             int rowPitch = deAlign32(levelW * m_texFormat.getPixelSize(), m_alignment);
1045*35238bceSAndroid Build Coastguard Worker             int cellSize = de::max(1, de::min(levelW >> 2, levelH >> 2));
1046*35238bceSAndroid Build Coastguard Worker 
1047*35238bceSAndroid Build Coastguard Worker             data.resize(rowPitch * levelH);
1048*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize,
1049*35238bceSAndroid Build Coastguard Worker                               colorA, colorB);
1050*35238bceSAndroid Build Coastguard Worker 
1051*35238bceSAndroid Build Coastguard Worker             glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, &data[0]);
1052*35238bceSAndroid Build Coastguard Worker         }
1053*35238bceSAndroid Build Coastguard Worker     }
1054*35238bceSAndroid Build Coastguard Worker 
1055*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1056*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
1057*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
1058*35238bceSAndroid Build Coastguard Worker     int m_alignment;
1059*35238bceSAndroid Build Coastguard Worker };
1060*35238bceSAndroid Build Coastguard Worker 
1061*35238bceSAndroid Build Coastguard Worker // TexImage2D() unpack alignment case.
1062*35238bceSAndroid Build Coastguard Worker class TexImageCubeAlignCase : public TextureCubeSpecCase
1063*35238bceSAndroid Build Coastguard Worker {
1064*35238bceSAndroid Build Coastguard Worker public:
TexImageCubeAlignCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int size,int numLevels,int alignment)1065*35238bceSAndroid Build Coastguard Worker     TexImageCubeAlignCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1066*35238bceSAndroid Build Coastguard Worker                           int size, int numLevels, int alignment)
1067*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), size, numLevels)
1068*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
1069*35238bceSAndroid Build Coastguard Worker         , m_format(format)
1070*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
1071*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1072*35238bceSAndroid Build Coastguard Worker     {
1073*35238bceSAndroid Build Coastguard Worker     }
1074*35238bceSAndroid Build Coastguard Worker 
TexImageCubeAlignCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size,int numLevels,int alignment)1075*35238bceSAndroid Build Coastguard Worker     TexImageCubeAlignCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size,
1076*35238bceSAndroid Build Coastguard Worker                           int numLevels, int alignment)
1077*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLevels)
1078*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1079*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
1080*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
1081*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1082*35238bceSAndroid Build Coastguard Worker     {
1083*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1084*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
1085*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
1086*35238bceSAndroid Build Coastguard Worker     }
1087*35238bceSAndroid Build Coastguard Worker 
1088*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1089*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1090*35238bceSAndroid Build Coastguard Worker     {
1091*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1092*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
1093*35238bceSAndroid Build Coastguard Worker 
1094*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1095*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1096*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1097*35238bceSAndroid Build Coastguard Worker 
1098*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1099*35238bceSAndroid Build Coastguard Worker         {
1100*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
1101*35238bceSAndroid Build Coastguard Worker             int rowPitch  = deAlign32(m_texFormat.getPixelSize() * levelSize, m_alignment);
1102*35238bceSAndroid Build Coastguard Worker             Vec4 colorA   = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * (m_texFormatInfo.valueMax - m_texFormatInfo.valueMin) +
1103*35238bceSAndroid Build Coastguard Worker                           m_texFormatInfo.valueMin;
1104*35238bceSAndroid Build Coastguard Worker             Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * (m_texFormatInfo.valueMax - m_texFormatInfo.valueMin) +
1105*35238bceSAndroid Build Coastguard Worker                           m_texFormatInfo.valueMin;
1106*35238bceSAndroid Build Coastguard Worker             int cellSize = de::max(1, levelSize >> 2);
1107*35238bceSAndroid Build Coastguard Worker 
1108*35238bceSAndroid Build Coastguard Worker             data.resize(rowPitch * levelSize);
1109*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, levelSize, levelSize, 1, rowPitch, 0, &data[0]),
1110*35238bceSAndroid Build Coastguard Worker                               cellSize, colorA, colorB);
1111*35238bceSAndroid Build Coastguard Worker 
1112*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1113*35238bceSAndroid Build Coastguard Worker                 glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType,
1114*35238bceSAndroid Build Coastguard Worker                              &data[0]);
1115*35238bceSAndroid Build Coastguard Worker         }
1116*35238bceSAndroid Build Coastguard Worker     }
1117*35238bceSAndroid Build Coastguard Worker 
1118*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1119*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
1120*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
1121*35238bceSAndroid Build Coastguard Worker     int m_alignment;
1122*35238bceSAndroid Build Coastguard Worker };
1123*35238bceSAndroid Build Coastguard Worker 
1124*35238bceSAndroid Build Coastguard Worker // TexImage2D() unpack parameters case.
1125*35238bceSAndroid Build Coastguard Worker class TexImage2DParamsCase : public Texture2DSpecCase
1126*35238bceSAndroid Build Coastguard Worker {
1127*35238bceSAndroid Build Coastguard Worker public:
TexImage2DParamsCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int rowLength,int skipRows,int skipPixels,int alignment)1128*35238bceSAndroid Build Coastguard Worker     TexImage2DParamsCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1129*35238bceSAndroid Build Coastguard Worker                          int height, int rowLength, int skipRows, int skipPixels, int alignment)
1130*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
1131*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1132*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
1133*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
1134*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
1135*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1136*35238bceSAndroid Build Coastguard Worker     {
1137*35238bceSAndroid Build Coastguard Worker     }
1138*35238bceSAndroid Build Coastguard Worker 
1139*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1140*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1141*35238bceSAndroid Build Coastguard Worker     {
1142*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1143*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
1144*35238bceSAndroid Build Coastguard Worker         int rowLength                   = m_rowLength > 0 ? m_rowLength : m_width;
1145*35238bceSAndroid Build Coastguard Worker         int rowPitch                    = deAlign32(rowLength * pixelSize, m_alignment);
1146*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
1147*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
1148*35238bceSAndroid Build Coastguard Worker 
1149*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
1150*35238bceSAndroid Build Coastguard Worker 
1151*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
1152*35238bceSAndroid Build Coastguard Worker         data.resize(pixelSize * m_skipPixels + rowPitch * (m_height + m_skipRows));
1153*35238bceSAndroid Build Coastguard Worker         {
1154*35238bceSAndroid Build Coastguard Worker             Vec4 cScale = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
1155*35238bceSAndroid Build Coastguard Worker             Vec4 cBias  = m_texFormatInfo.valueMin;
1156*35238bceSAndroid Build Coastguard Worker             Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
1157*35238bceSAndroid Build Coastguard Worker             Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
1158*35238bceSAndroid Build Coastguard Worker 
1159*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0,
1160*35238bceSAndroid Build Coastguard Worker                                                      &data[0] + m_skipRows * rowPitch + m_skipPixels * pixelSize),
1161*35238bceSAndroid Build Coastguard Worker                               4, colorA, colorB);
1162*35238bceSAndroid Build Coastguard Worker         }
1163*35238bceSAndroid Build Coastguard Worker 
1164*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
1165*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
1166*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
1167*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1168*35238bceSAndroid Build Coastguard Worker 
1169*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1170*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
1171*35238bceSAndroid Build Coastguard Worker         glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType,
1172*35238bceSAndroid Build Coastguard Worker                      &data[0]);
1173*35238bceSAndroid Build Coastguard Worker     }
1174*35238bceSAndroid Build Coastguard Worker 
1175*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1176*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
1177*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
1178*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
1179*35238bceSAndroid Build Coastguard Worker     int m_alignment;
1180*35238bceSAndroid Build Coastguard Worker };
1181*35238bceSAndroid Build Coastguard Worker 
1182*35238bceSAndroid Build Coastguard Worker // TexImage3D() unpack parameters case.
1183*35238bceSAndroid Build Coastguard Worker class TexImage3DParamsCase : public Texture3DSpecCase
1184*35238bceSAndroid Build Coastguard Worker {
1185*35238bceSAndroid Build Coastguard Worker public:
TexImage3DParamsCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int depth,int imageHeight,int rowLength,int skipImages,int skipRows,int skipPixels,int alignment)1186*35238bceSAndroid Build Coastguard Worker     TexImage3DParamsCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1187*35238bceSAndroid Build Coastguard Worker                          int height, int depth, int imageHeight, int rowLength, int skipImages, int skipRows,
1188*35238bceSAndroid Build Coastguard Worker                          int skipPixels, int alignment)
1189*35238bceSAndroid Build Coastguard Worker         : Texture3DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
1190*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1191*35238bceSAndroid Build Coastguard Worker         , m_imageHeight(imageHeight)
1192*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
1193*35238bceSAndroid Build Coastguard Worker         , m_skipImages(skipImages)
1194*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
1195*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
1196*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1197*35238bceSAndroid Build Coastguard Worker     {
1198*35238bceSAndroid Build Coastguard Worker     }
1199*35238bceSAndroid Build Coastguard Worker 
1200*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1201*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1202*35238bceSAndroid Build Coastguard Worker     {
1203*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1204*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
1205*35238bceSAndroid Build Coastguard Worker         int rowLength                   = m_rowLength > 0 ? m_rowLength : m_width;
1206*35238bceSAndroid Build Coastguard Worker         int rowPitch                    = deAlign32(rowLength * pixelSize, m_alignment);
1207*35238bceSAndroid Build Coastguard Worker         int imageHeight                 = m_imageHeight > 0 ? m_imageHeight : m_height;
1208*35238bceSAndroid Build Coastguard Worker         int slicePitch                  = imageHeight * rowPitch;
1209*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
1210*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
1211*35238bceSAndroid Build Coastguard Worker 
1212*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
1213*35238bceSAndroid Build Coastguard Worker 
1214*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
1215*35238bceSAndroid Build Coastguard Worker         data.resize(pixelSize * m_skipPixels + rowPitch * m_skipRows + slicePitch * (m_skipImages + m_depth));
1216*35238bceSAndroid Build Coastguard Worker         {
1217*35238bceSAndroid Build Coastguard Worker             Vec4 cScale = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
1218*35238bceSAndroid Build Coastguard Worker             Vec4 cBias  = m_texFormatInfo.valueMin;
1219*35238bceSAndroid Build Coastguard Worker             Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
1220*35238bceSAndroid Build Coastguard Worker             Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
1221*35238bceSAndroid Build Coastguard Worker 
1222*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch,
1223*35238bceSAndroid Build Coastguard Worker                                                      &data[0] + m_skipImages * slicePitch + m_skipRows * rowPitch +
1224*35238bceSAndroid Build Coastguard Worker                                                          m_skipPixels * pixelSize),
1225*35238bceSAndroid Build Coastguard Worker                               4, colorA, colorB);
1226*35238bceSAndroid Build Coastguard Worker         }
1227*35238bceSAndroid Build Coastguard Worker 
1228*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
1229*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
1230*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
1231*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
1232*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
1233*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1234*35238bceSAndroid Build Coastguard Worker 
1235*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1236*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_3D, tex);
1237*35238bceSAndroid Build Coastguard Worker         glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format,
1238*35238bceSAndroid Build Coastguard Worker                      transferFmt.dataType, &data[0]);
1239*35238bceSAndroid Build Coastguard Worker     }
1240*35238bceSAndroid Build Coastguard Worker 
1241*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1242*35238bceSAndroid Build Coastguard Worker     int m_imageHeight;
1243*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
1244*35238bceSAndroid Build Coastguard Worker     int m_skipImages;
1245*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
1246*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
1247*35238bceSAndroid Build Coastguard Worker     int m_alignment;
1248*35238bceSAndroid Build Coastguard Worker };
1249*35238bceSAndroid Build Coastguard Worker 
1250*35238bceSAndroid Build Coastguard Worker // Basic TexSubImage2D() with 2D texture usage
1251*35238bceSAndroid Build Coastguard Worker class BasicTexSubImage2DCase : public Texture2DSpecCase
1252*35238bceSAndroid Build Coastguard Worker {
1253*35238bceSAndroid Build Coastguard Worker public:
BasicTexSubImage2DCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int width,int height)1254*35238bceSAndroid Build Coastguard Worker     BasicTexSubImage2DCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1255*35238bceSAndroid Build Coastguard Worker                            int width, int height)
1256*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height,
1257*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height))
1258*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
1259*35238bceSAndroid Build Coastguard Worker         , m_format(format)
1260*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
1261*35238bceSAndroid Build Coastguard Worker     {
1262*35238bceSAndroid Build Coastguard Worker     }
1263*35238bceSAndroid Build Coastguard Worker 
BasicTexSubImage2DCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height)1264*35238bceSAndroid Build Coastguard Worker     BasicTexSubImage2DCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1265*35238bceSAndroid Build Coastguard Worker                            int height)
1266*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height,
1267*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height))
1268*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1269*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
1270*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
1271*35238bceSAndroid Build Coastguard Worker     {
1272*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1273*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
1274*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
1275*35238bceSAndroid Build Coastguard Worker     }
1276*35238bceSAndroid Build Coastguard Worker 
1277*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1278*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1279*35238bceSAndroid Build Coastguard Worker     {
1280*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1281*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel data(m_texFormat);
1282*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
1283*35238bceSAndroid Build Coastguard Worker 
1284*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1285*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
1286*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1287*35238bceSAndroid Build Coastguard Worker 
1288*35238bceSAndroid Build Coastguard Worker         // First specify full texture.
1289*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1290*35238bceSAndroid Build Coastguard Worker         {
1291*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
1292*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
1293*35238bceSAndroid Build Coastguard Worker             Vec4 gMin  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1294*35238bceSAndroid Build Coastguard Worker             Vec4 gMax  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1295*35238bceSAndroid Build Coastguard Worker 
1296*35238bceSAndroid Build Coastguard Worker             data.setSize(levelW, levelH);
1297*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1298*35238bceSAndroid Build Coastguard Worker 
1299*35238bceSAndroid Build Coastguard Worker             glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType,
1300*35238bceSAndroid Build Coastguard Worker                          data.getAccess().getDataPtr());
1301*35238bceSAndroid Build Coastguard Worker         }
1302*35238bceSAndroid Build Coastguard Worker 
1303*35238bceSAndroid Build Coastguard Worker         // Re-specify parts of each level.
1304*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1305*35238bceSAndroid Build Coastguard Worker         {
1306*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
1307*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
1308*35238bceSAndroid Build Coastguard Worker 
1309*35238bceSAndroid Build Coastguard Worker             int w = rnd.getInt(1, levelW);
1310*35238bceSAndroid Build Coastguard Worker             int h = rnd.getInt(1, levelH);
1311*35238bceSAndroid Build Coastguard Worker             int x = rnd.getInt(0, levelW - w);
1312*35238bceSAndroid Build Coastguard Worker             int y = rnd.getInt(0, levelH - h);
1313*35238bceSAndroid Build Coastguard Worker 
1314*35238bceSAndroid Build Coastguard Worker             Vec4 colorA  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1315*35238bceSAndroid Build Coastguard Worker             Vec4 colorB  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1316*35238bceSAndroid Build Coastguard Worker             int cellSize = rnd.getInt(2, 16);
1317*35238bceSAndroid Build Coastguard Worker 
1318*35238bceSAndroid Build Coastguard Worker             data.setSize(w, h);
1319*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1320*35238bceSAndroid Build Coastguard Worker 
1321*35238bceSAndroid Build Coastguard Worker             glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
1322*35238bceSAndroid Build Coastguard Worker         }
1323*35238bceSAndroid Build Coastguard Worker     }
1324*35238bceSAndroid Build Coastguard Worker 
1325*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1326*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
1327*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
1328*35238bceSAndroid Build Coastguard Worker };
1329*35238bceSAndroid Build Coastguard Worker 
1330*35238bceSAndroid Build Coastguard Worker // Basic TexSubImage2D() with cubemap usage
1331*35238bceSAndroid Build Coastguard Worker class BasicTexSubImageCubeCase : public TextureCubeSpecCase
1332*35238bceSAndroid Build Coastguard Worker {
1333*35238bceSAndroid Build Coastguard Worker public:
BasicTexSubImageCubeCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int size)1334*35238bceSAndroid Build Coastguard Worker     BasicTexSubImageCubeCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1335*35238bceSAndroid Build Coastguard Worker                              int size)
1336*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), size,
1337*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
1338*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
1339*35238bceSAndroid Build Coastguard Worker         , m_format(format)
1340*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
1341*35238bceSAndroid Build Coastguard Worker     {
1342*35238bceSAndroid Build Coastguard Worker     }
1343*35238bceSAndroid Build Coastguard Worker 
BasicTexSubImageCubeCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size)1344*35238bceSAndroid Build Coastguard Worker     BasicTexSubImageCubeCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size)
1345*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), size,
1346*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
1347*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1348*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
1349*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
1350*35238bceSAndroid Build Coastguard Worker     {
1351*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1352*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
1353*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
1354*35238bceSAndroid Build Coastguard Worker     }
1355*35238bceSAndroid Build Coastguard Worker 
1356*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1357*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1358*35238bceSAndroid Build Coastguard Worker     {
1359*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1360*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel data(m_texFormat);
1361*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
1362*35238bceSAndroid Build Coastguard Worker 
1363*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1364*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1365*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1366*35238bceSAndroid Build Coastguard Worker 
1367*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1368*35238bceSAndroid Build Coastguard Worker         {
1369*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
1370*35238bceSAndroid Build Coastguard Worker 
1371*35238bceSAndroid Build Coastguard Worker             data.setSize(levelSize, levelSize);
1372*35238bceSAndroid Build Coastguard Worker 
1373*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1374*35238bceSAndroid Build Coastguard Worker             {
1375*35238bceSAndroid Build Coastguard Worker                 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1376*35238bceSAndroid Build Coastguard Worker                 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1377*35238bceSAndroid Build Coastguard Worker 
1378*35238bceSAndroid Build Coastguard Worker                 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1379*35238bceSAndroid Build Coastguard Worker 
1380*35238bceSAndroid Build Coastguard Worker                 glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType,
1381*35238bceSAndroid Build Coastguard Worker                              data.getAccess().getDataPtr());
1382*35238bceSAndroid Build Coastguard Worker             }
1383*35238bceSAndroid Build Coastguard Worker         }
1384*35238bceSAndroid Build Coastguard Worker 
1385*35238bceSAndroid Build Coastguard Worker         // Re-specify parts of each face and level.
1386*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1387*35238bceSAndroid Build Coastguard Worker         {
1388*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
1389*35238bceSAndroid Build Coastguard Worker 
1390*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1391*35238bceSAndroid Build Coastguard Worker             {
1392*35238bceSAndroid Build Coastguard Worker                 int w = rnd.getInt(1, levelSize);
1393*35238bceSAndroid Build Coastguard Worker                 int h = rnd.getInt(1, levelSize);
1394*35238bceSAndroid Build Coastguard Worker                 int x = rnd.getInt(0, levelSize - w);
1395*35238bceSAndroid Build Coastguard Worker                 int y = rnd.getInt(0, levelSize - h);
1396*35238bceSAndroid Build Coastguard Worker 
1397*35238bceSAndroid Build Coastguard Worker                 Vec4 colorA  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1398*35238bceSAndroid Build Coastguard Worker                 Vec4 colorB  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1399*35238bceSAndroid Build Coastguard Worker                 int cellSize = rnd.getInt(2, 16);
1400*35238bceSAndroid Build Coastguard Worker 
1401*35238bceSAndroid Build Coastguard Worker                 data.setSize(w, h);
1402*35238bceSAndroid Build Coastguard Worker                 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1403*35238bceSAndroid Build Coastguard Worker 
1404*35238bceSAndroid Build Coastguard Worker                 glTexSubImage2D(s_cubeMapFaces[face], ndx, x, y, w, h, m_format, m_dataType,
1405*35238bceSAndroid Build Coastguard Worker                                 data.getAccess().getDataPtr());
1406*35238bceSAndroid Build Coastguard Worker             }
1407*35238bceSAndroid Build Coastguard Worker         }
1408*35238bceSAndroid Build Coastguard Worker     }
1409*35238bceSAndroid Build Coastguard Worker 
1410*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1411*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
1412*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
1413*35238bceSAndroid Build Coastguard Worker };
1414*35238bceSAndroid Build Coastguard Worker 
1415*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() unpack parameters case.
1416*35238bceSAndroid Build Coastguard Worker class TexSubImage2DParamsCase : public Texture2DSpecCase
1417*35238bceSAndroid Build Coastguard Worker {
1418*35238bceSAndroid Build Coastguard Worker public:
TexSubImage2DParamsCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int subX,int subY,int subW,int subH,int rowLength,int skipRows,int skipPixels,int alignment)1419*35238bceSAndroid Build Coastguard Worker     TexSubImage2DParamsCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1420*35238bceSAndroid Build Coastguard Worker                             int height, int subX, int subY, int subW, int subH, int rowLength, int skipRows,
1421*35238bceSAndroid Build Coastguard Worker                             int skipPixels, int alignment)
1422*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
1423*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1424*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
1425*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
1426*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
1427*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
1428*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
1429*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
1430*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
1431*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1432*35238bceSAndroid Build Coastguard Worker     {
1433*35238bceSAndroid Build Coastguard Worker     }
1434*35238bceSAndroid Build Coastguard Worker 
1435*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1436*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1437*35238bceSAndroid Build Coastguard Worker     {
1438*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1439*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
1440*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
1441*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
1442*35238bceSAndroid Build Coastguard Worker 
1443*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
1444*35238bceSAndroid Build Coastguard Worker 
1445*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1446*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
1447*35238bceSAndroid Build Coastguard Worker 
1448*35238bceSAndroid Build Coastguard Worker         // First fill texture with gradient.
1449*35238bceSAndroid Build Coastguard Worker         data.resize(deAlign32(m_width * pixelSize, 4) * m_height);
1450*35238bceSAndroid Build Coastguard Worker         tcu::fillWithComponentGradients(
1451*35238bceSAndroid Build Coastguard Worker             tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, deAlign32(m_width * pixelSize, 4), 0, &data[0]),
1452*35238bceSAndroid Build Coastguard Worker             m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1453*35238bceSAndroid Build Coastguard Worker         glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType,
1454*35238bceSAndroid Build Coastguard Worker                      &data[0]);
1455*35238bceSAndroid Build Coastguard Worker 
1456*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
1457*35238bceSAndroid Build Coastguard Worker         {
1458*35238bceSAndroid Build Coastguard Worker             int rowLength = m_rowLength > 0 ? m_rowLength : m_subW;
1459*35238bceSAndroid Build Coastguard Worker             int rowPitch  = deAlign32(rowLength * pixelSize, m_alignment);
1460*35238bceSAndroid Build Coastguard Worker             int height    = m_subH + m_skipRows;
1461*35238bceSAndroid Build Coastguard Worker             Vec4 cScale   = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
1462*35238bceSAndroid Build Coastguard Worker             Vec4 cBias    = m_texFormatInfo.valueMin;
1463*35238bceSAndroid Build Coastguard Worker             Vec4 colorA   = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
1464*35238bceSAndroid Build Coastguard Worker             Vec4 colorB   = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
1465*35238bceSAndroid Build Coastguard Worker 
1466*35238bceSAndroid Build Coastguard Worker             data.resize(rowPitch * height);
1467*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0,
1468*35238bceSAndroid Build Coastguard Worker                                                      &data[0] + m_skipRows * rowPitch + m_skipPixels * pixelSize),
1469*35238bceSAndroid Build Coastguard Worker                               4, colorA, colorB);
1470*35238bceSAndroid Build Coastguard Worker         }
1471*35238bceSAndroid Build Coastguard Worker 
1472*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
1473*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
1474*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
1475*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1476*35238bceSAndroid Build Coastguard Worker         glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format, transferFmt.dataType,
1477*35238bceSAndroid Build Coastguard Worker                         &data[0]);
1478*35238bceSAndroid Build Coastguard Worker     }
1479*35238bceSAndroid Build Coastguard Worker 
1480*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1481*35238bceSAndroid Build Coastguard Worker     int m_subX;
1482*35238bceSAndroid Build Coastguard Worker     int m_subY;
1483*35238bceSAndroid Build Coastguard Worker     int m_subW;
1484*35238bceSAndroid Build Coastguard Worker     int m_subH;
1485*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
1486*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
1487*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
1488*35238bceSAndroid Build Coastguard Worker     int m_alignment;
1489*35238bceSAndroid Build Coastguard Worker };
1490*35238bceSAndroid Build Coastguard Worker 
1491*35238bceSAndroid Build Coastguard Worker // Basic TexSubImage3D() with 3D texture usage
1492*35238bceSAndroid Build Coastguard Worker class BasicTexSubImage3DCase : public Texture3DSpecCase
1493*35238bceSAndroid Build Coastguard Worker {
1494*35238bceSAndroid Build Coastguard Worker public:
BasicTexSubImage3DCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int depth)1495*35238bceSAndroid Build Coastguard Worker     BasicTexSubImage3DCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1496*35238bceSAndroid Build Coastguard Worker                            int height, int depth)
1497*35238bceSAndroid Build Coastguard Worker         : Texture3DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth,
1498*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height, depth))
1499*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1500*35238bceSAndroid Build Coastguard Worker     {
1501*35238bceSAndroid Build Coastguard Worker     }
1502*35238bceSAndroid Build Coastguard Worker 
1503*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1504*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1505*35238bceSAndroid Build Coastguard Worker     {
1506*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1507*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel data(m_texFormat);
1508*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
1509*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1510*35238bceSAndroid Build Coastguard Worker 
1511*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1512*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_3D, tex);
1513*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1514*35238bceSAndroid Build Coastguard Worker 
1515*35238bceSAndroid Build Coastguard Worker         // First specify full texture.
1516*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1517*35238bceSAndroid Build Coastguard Worker         {
1518*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
1519*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
1520*35238bceSAndroid Build Coastguard Worker             int levelD = de::max(1, m_depth >> ndx);
1521*35238bceSAndroid Build Coastguard Worker             Vec4 gMin  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1522*35238bceSAndroid Build Coastguard Worker             Vec4 gMax  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1523*35238bceSAndroid Build Coastguard Worker 
1524*35238bceSAndroid Build Coastguard Worker             data.setSize(levelW, levelH, levelD);
1525*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1526*35238bceSAndroid Build Coastguard Worker 
1527*35238bceSAndroid Build Coastguard Worker             glTexImage3D(GL_TEXTURE_3D, ndx, m_internalFormat, levelW, levelH, levelD, 0, transferFmt.format,
1528*35238bceSAndroid Build Coastguard Worker                          transferFmt.dataType, data.getAccess().getDataPtr());
1529*35238bceSAndroid Build Coastguard Worker         }
1530*35238bceSAndroid Build Coastguard Worker 
1531*35238bceSAndroid Build Coastguard Worker         // Re-specify parts of each level.
1532*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1533*35238bceSAndroid Build Coastguard Worker         {
1534*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
1535*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
1536*35238bceSAndroid Build Coastguard Worker             int levelD = de::max(1, m_depth >> ndx);
1537*35238bceSAndroid Build Coastguard Worker 
1538*35238bceSAndroid Build Coastguard Worker             int w = rnd.getInt(1, levelW);
1539*35238bceSAndroid Build Coastguard Worker             int h = rnd.getInt(1, levelH);
1540*35238bceSAndroid Build Coastguard Worker             int d = rnd.getInt(1, levelD);
1541*35238bceSAndroid Build Coastguard Worker             int x = rnd.getInt(0, levelW - w);
1542*35238bceSAndroid Build Coastguard Worker             int y = rnd.getInt(0, levelH - h);
1543*35238bceSAndroid Build Coastguard Worker             int z = rnd.getInt(0, levelD - d);
1544*35238bceSAndroid Build Coastguard Worker 
1545*35238bceSAndroid Build Coastguard Worker             Vec4 colorA  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1546*35238bceSAndroid Build Coastguard Worker             Vec4 colorB  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1547*35238bceSAndroid Build Coastguard Worker             int cellSize = rnd.getInt(2, 16);
1548*35238bceSAndroid Build Coastguard Worker 
1549*35238bceSAndroid Build Coastguard Worker             data.setSize(w, h, d);
1550*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1551*35238bceSAndroid Build Coastguard Worker 
1552*35238bceSAndroid Build Coastguard Worker             glTexSubImage3D(GL_TEXTURE_3D, ndx, x, y, z, w, h, d, transferFmt.format, transferFmt.dataType,
1553*35238bceSAndroid Build Coastguard Worker                             data.getAccess().getDataPtr());
1554*35238bceSAndroid Build Coastguard Worker         }
1555*35238bceSAndroid Build Coastguard Worker     }
1556*35238bceSAndroid Build Coastguard Worker 
1557*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1558*35238bceSAndroid Build Coastguard Worker };
1559*35238bceSAndroid Build Coastguard Worker 
1560*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() to texture initialized with empty data
1561*35238bceSAndroid Build Coastguard Worker class TexSubImage2DEmptyTexCase : public Texture2DSpecCase
1562*35238bceSAndroid Build Coastguard Worker {
1563*35238bceSAndroid Build Coastguard Worker public:
TexSubImage2DEmptyTexCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int width,int height)1564*35238bceSAndroid Build Coastguard Worker     TexSubImage2DEmptyTexCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1565*35238bceSAndroid Build Coastguard Worker                               int width, int height)
1566*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height,
1567*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height))
1568*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
1569*35238bceSAndroid Build Coastguard Worker         , m_format(format)
1570*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
1571*35238bceSAndroid Build Coastguard Worker     {
1572*35238bceSAndroid Build Coastguard Worker     }
1573*35238bceSAndroid Build Coastguard Worker 
TexSubImage2DEmptyTexCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height)1574*35238bceSAndroid Build Coastguard Worker     TexSubImage2DEmptyTexCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1575*35238bceSAndroid Build Coastguard Worker                               int height)
1576*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height,
1577*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height))
1578*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1579*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
1580*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
1581*35238bceSAndroid Build Coastguard Worker     {
1582*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1583*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
1584*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
1585*35238bceSAndroid Build Coastguard Worker     }
1586*35238bceSAndroid Build Coastguard Worker 
1587*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1588*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1589*35238bceSAndroid Build Coastguard Worker     {
1590*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1591*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel data(m_texFormat);
1592*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
1593*35238bceSAndroid Build Coastguard Worker 
1594*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1595*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
1596*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1597*35238bceSAndroid Build Coastguard Worker 
1598*35238bceSAndroid Build Coastguard Worker         // First allocate storage for each level.
1599*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1600*35238bceSAndroid Build Coastguard Worker         {
1601*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
1602*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
1603*35238bceSAndroid Build Coastguard Worker 
1604*35238bceSAndroid Build Coastguard Worker             glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, DE_NULL);
1605*35238bceSAndroid Build Coastguard Worker         }
1606*35238bceSAndroid Build Coastguard Worker 
1607*35238bceSAndroid Build Coastguard Worker         // Specify pixel data to all levels using glTexSubImage2D()
1608*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1609*35238bceSAndroid Build Coastguard Worker         {
1610*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
1611*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
1612*35238bceSAndroid Build Coastguard Worker             Vec4 gMin  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1613*35238bceSAndroid Build Coastguard Worker             Vec4 gMax  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1614*35238bceSAndroid Build Coastguard Worker 
1615*35238bceSAndroid Build Coastguard Worker             data.setSize(levelW, levelH);
1616*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1617*35238bceSAndroid Build Coastguard Worker 
1618*35238bceSAndroid Build Coastguard Worker             glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, m_format, m_dataType,
1619*35238bceSAndroid Build Coastguard Worker                             data.getAccess().getDataPtr());
1620*35238bceSAndroid Build Coastguard Worker         }
1621*35238bceSAndroid Build Coastguard Worker     }
1622*35238bceSAndroid Build Coastguard Worker 
1623*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1624*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
1625*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
1626*35238bceSAndroid Build Coastguard Worker };
1627*35238bceSAndroid Build Coastguard Worker 
1628*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() to empty cubemap texture
1629*35238bceSAndroid Build Coastguard Worker class TexSubImageCubeEmptyTexCase : public TextureCubeSpecCase
1630*35238bceSAndroid Build Coastguard Worker {
1631*35238bceSAndroid Build Coastguard Worker public:
TexSubImageCubeEmptyTexCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int size)1632*35238bceSAndroid Build Coastguard Worker     TexSubImageCubeEmptyTexCase(Context &context, const char *name, const char *desc, uint32_t format,
1633*35238bceSAndroid Build Coastguard Worker                                 uint32_t dataType, int size)
1634*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), size,
1635*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
1636*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
1637*35238bceSAndroid Build Coastguard Worker         , m_format(format)
1638*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
1639*35238bceSAndroid Build Coastguard Worker     {
1640*35238bceSAndroid Build Coastguard Worker     }
1641*35238bceSAndroid Build Coastguard Worker 
TexSubImageCubeEmptyTexCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size)1642*35238bceSAndroid Build Coastguard Worker     TexSubImageCubeEmptyTexCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size)
1643*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), size,
1644*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
1645*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1646*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
1647*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
1648*35238bceSAndroid Build Coastguard Worker     {
1649*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1650*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
1651*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
1652*35238bceSAndroid Build Coastguard Worker     }
1653*35238bceSAndroid Build Coastguard Worker 
1654*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1655*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1656*35238bceSAndroid Build Coastguard Worker     {
1657*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1658*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel data(m_texFormat);
1659*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
1660*35238bceSAndroid Build Coastguard Worker 
1661*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1662*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1663*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1664*35238bceSAndroid Build Coastguard Worker 
1665*35238bceSAndroid Build Coastguard Worker         // Specify storage for each level.
1666*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1667*35238bceSAndroid Build Coastguard Worker         {
1668*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
1669*35238bceSAndroid Build Coastguard Worker 
1670*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1671*35238bceSAndroid Build Coastguard Worker                 glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType,
1672*35238bceSAndroid Build Coastguard Worker                              DE_NULL);
1673*35238bceSAndroid Build Coastguard Worker         }
1674*35238bceSAndroid Build Coastguard Worker 
1675*35238bceSAndroid Build Coastguard Worker         // Specify data using glTexSubImage2D()
1676*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1677*35238bceSAndroid Build Coastguard Worker         {
1678*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
1679*35238bceSAndroid Build Coastguard Worker 
1680*35238bceSAndroid Build Coastguard Worker             data.setSize(levelSize, levelSize);
1681*35238bceSAndroid Build Coastguard Worker 
1682*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1683*35238bceSAndroid Build Coastguard Worker             {
1684*35238bceSAndroid Build Coastguard Worker                 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1685*35238bceSAndroid Build Coastguard Worker                 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1686*35238bceSAndroid Build Coastguard Worker 
1687*35238bceSAndroid Build Coastguard Worker                 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1688*35238bceSAndroid Build Coastguard Worker 
1689*35238bceSAndroid Build Coastguard Worker                 glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelSize, levelSize, m_format, m_dataType,
1690*35238bceSAndroid Build Coastguard Worker                                 data.getAccess().getDataPtr());
1691*35238bceSAndroid Build Coastguard Worker             }
1692*35238bceSAndroid Build Coastguard Worker         }
1693*35238bceSAndroid Build Coastguard Worker     }
1694*35238bceSAndroid Build Coastguard Worker 
1695*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1696*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
1697*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
1698*35238bceSAndroid Build Coastguard Worker };
1699*35238bceSAndroid Build Coastguard Worker 
1700*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() unpack alignment with 2D texture
1701*35238bceSAndroid Build Coastguard Worker class TexSubImage2DAlignCase : public Texture2DSpecCase
1702*35238bceSAndroid Build Coastguard Worker {
1703*35238bceSAndroid Build Coastguard Worker public:
TexSubImage2DAlignCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int width,int height,int subX,int subY,int subW,int subH,int alignment)1704*35238bceSAndroid Build Coastguard Worker     TexSubImage2DAlignCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1705*35238bceSAndroid Build Coastguard Worker                            int width, int height, int subX, int subY, int subW, int subH, int alignment)
1706*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, 1)
1707*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
1708*35238bceSAndroid Build Coastguard Worker         , m_format(format)
1709*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
1710*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
1711*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
1712*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
1713*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
1714*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1715*35238bceSAndroid Build Coastguard Worker     {
1716*35238bceSAndroid Build Coastguard Worker     }
1717*35238bceSAndroid Build Coastguard Worker 
TexSubImage2DAlignCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int subX,int subY,int subW,int subH,int alignment)1718*35238bceSAndroid Build Coastguard Worker     TexSubImage2DAlignCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1719*35238bceSAndroid Build Coastguard Worker                            int height, int subX, int subY, int subW, int subH, int alignment)
1720*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
1721*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1722*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
1723*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
1724*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
1725*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
1726*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
1727*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
1728*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1729*35238bceSAndroid Build Coastguard Worker     {
1730*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1731*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
1732*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
1733*35238bceSAndroid Build Coastguard Worker     }
1734*35238bceSAndroid Build Coastguard Worker 
1735*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1736*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1737*35238bceSAndroid Build Coastguard Worker     {
1738*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1739*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
1740*35238bceSAndroid Build Coastguard Worker 
1741*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1742*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
1743*35238bceSAndroid Build Coastguard Worker 
1744*35238bceSAndroid Build Coastguard Worker         // Specify base level.
1745*35238bceSAndroid Build Coastguard Worker         data.resize(m_texFormat.getPixelSize() * m_width * m_height);
1746*35238bceSAndroid Build Coastguard Worker         tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, &data[0]), Vec4(0.0f),
1747*35238bceSAndroid Build Coastguard Worker                                         Vec4(1.0f));
1748*35238bceSAndroid Build Coastguard Worker 
1749*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1750*35238bceSAndroid Build Coastguard Worker         glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, m_format, m_dataType, &data[0]);
1751*35238bceSAndroid Build Coastguard Worker 
1752*35238bceSAndroid Build Coastguard Worker         // Re-specify subrectangle.
1753*35238bceSAndroid Build Coastguard Worker         int rowPitch = deAlign32(m_texFormat.getPixelSize() * m_subW, m_alignment);
1754*35238bceSAndroid Build Coastguard Worker         data.resize(rowPitch * m_subH);
1755*35238bceSAndroid Build Coastguard Worker         tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4,
1756*35238bceSAndroid Build Coastguard Worker                           Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
1757*35238bceSAndroid Build Coastguard Worker 
1758*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1759*35238bceSAndroid Build Coastguard Worker         glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
1760*35238bceSAndroid Build Coastguard Worker     }
1761*35238bceSAndroid Build Coastguard Worker 
1762*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1763*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
1764*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
1765*35238bceSAndroid Build Coastguard Worker     int m_subX;
1766*35238bceSAndroid Build Coastguard Worker     int m_subY;
1767*35238bceSAndroid Build Coastguard Worker     int m_subW;
1768*35238bceSAndroid Build Coastguard Worker     int m_subH;
1769*35238bceSAndroid Build Coastguard Worker     int m_alignment;
1770*35238bceSAndroid Build Coastguard Worker };
1771*35238bceSAndroid Build Coastguard Worker 
1772*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() unpack alignment with cubemap texture
1773*35238bceSAndroid Build Coastguard Worker class TexSubImageCubeAlignCase : public TextureCubeSpecCase
1774*35238bceSAndroid Build Coastguard Worker {
1775*35238bceSAndroid Build Coastguard Worker public:
TexSubImageCubeAlignCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int size,int subX,int subY,int subW,int subH,int alignment)1776*35238bceSAndroid Build Coastguard Worker     TexSubImageCubeAlignCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1777*35238bceSAndroid Build Coastguard Worker                              int size, int subX, int subY, int subW, int subH, int alignment)
1778*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), size, 1)
1779*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(format)
1780*35238bceSAndroid Build Coastguard Worker         , m_format(format)
1781*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
1782*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
1783*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
1784*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
1785*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
1786*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1787*35238bceSAndroid Build Coastguard Worker     {
1788*35238bceSAndroid Build Coastguard Worker     }
1789*35238bceSAndroid Build Coastguard Worker 
TexSubImageCubeAlignCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size,int subX,int subY,int subW,int subH,int alignment)1790*35238bceSAndroid Build Coastguard Worker     TexSubImageCubeAlignCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size,
1791*35238bceSAndroid Build Coastguard Worker                              int subX, int subY, int subW, int subH, int alignment)
1792*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1)
1793*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1794*35238bceSAndroid Build Coastguard Worker         , m_format(GL_NONE)
1795*35238bceSAndroid Build Coastguard Worker         , m_dataType(GL_NONE)
1796*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
1797*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
1798*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
1799*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
1800*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1801*35238bceSAndroid Build Coastguard Worker     {
1802*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1803*35238bceSAndroid Build Coastguard Worker         m_format                = fmt.format;
1804*35238bceSAndroid Build Coastguard Worker         m_dataType              = fmt.dataType;
1805*35238bceSAndroid Build Coastguard Worker     }
1806*35238bceSAndroid Build Coastguard Worker 
1807*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1808*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1809*35238bceSAndroid Build Coastguard Worker     {
1810*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1811*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
1812*35238bceSAndroid Build Coastguard Worker 
1813*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1814*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1815*35238bceSAndroid Build Coastguard Worker 
1816*35238bceSAndroid Build Coastguard Worker         // Specify base level.
1817*35238bceSAndroid Build Coastguard Worker         data.resize(m_texFormat.getPixelSize() * m_size * m_size);
1818*35238bceSAndroid Build Coastguard Worker         tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, &data[0]), Vec4(0.0f),
1819*35238bceSAndroid Build Coastguard Worker                                         Vec4(1.0f));
1820*35238bceSAndroid Build Coastguard Worker 
1821*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1822*35238bceSAndroid Build Coastguard Worker         for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1823*35238bceSAndroid Build Coastguard Worker             glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, m_format, m_dataType, &data[0]);
1824*35238bceSAndroid Build Coastguard Worker 
1825*35238bceSAndroid Build Coastguard Worker         // Re-specify subrectangle.
1826*35238bceSAndroid Build Coastguard Worker         int rowPitch = deAlign32(m_texFormat.getPixelSize() * m_subW, m_alignment);
1827*35238bceSAndroid Build Coastguard Worker         data.resize(rowPitch * m_subH);
1828*35238bceSAndroid Build Coastguard Worker         tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4,
1829*35238bceSAndroid Build Coastguard Worker                           Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
1830*35238bceSAndroid Build Coastguard Worker 
1831*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1832*35238bceSAndroid Build Coastguard Worker         for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1833*35238bceSAndroid Build Coastguard Worker             glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
1834*35238bceSAndroid Build Coastguard Worker     }
1835*35238bceSAndroid Build Coastguard Worker 
1836*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1837*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
1838*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
1839*35238bceSAndroid Build Coastguard Worker     int m_subX;
1840*35238bceSAndroid Build Coastguard Worker     int m_subY;
1841*35238bceSAndroid Build Coastguard Worker     int m_subW;
1842*35238bceSAndroid Build Coastguard Worker     int m_subH;
1843*35238bceSAndroid Build Coastguard Worker     int m_alignment;
1844*35238bceSAndroid Build Coastguard Worker };
1845*35238bceSAndroid Build Coastguard Worker 
1846*35238bceSAndroid Build Coastguard Worker // TexSubImage3D() unpack parameters case.
1847*35238bceSAndroid Build Coastguard Worker class TexSubImage3DParamsCase : public Texture3DSpecCase
1848*35238bceSAndroid Build Coastguard Worker {
1849*35238bceSAndroid Build Coastguard Worker public:
TexSubImage3DParamsCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int depth,int subX,int subY,int subZ,int subW,int subH,int subD,int imageHeight,int rowLength,int skipImages,int skipRows,int skipPixels,int alignment)1850*35238bceSAndroid Build Coastguard Worker     TexSubImage3DParamsCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1851*35238bceSAndroid Build Coastguard Worker                             int height, int depth, int subX, int subY, int subZ, int subW, int subH, int subD,
1852*35238bceSAndroid Build Coastguard Worker                             int imageHeight, int rowLength, int skipImages, int skipRows, int skipPixels, int alignment)
1853*35238bceSAndroid Build Coastguard Worker         : Texture3DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
1854*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1855*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
1856*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
1857*35238bceSAndroid Build Coastguard Worker         , m_subZ(subZ)
1858*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
1859*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
1860*35238bceSAndroid Build Coastguard Worker         , m_subD(subD)
1861*35238bceSAndroid Build Coastguard Worker         , m_imageHeight(imageHeight)
1862*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
1863*35238bceSAndroid Build Coastguard Worker         , m_skipImages(skipImages)
1864*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
1865*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
1866*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
1867*35238bceSAndroid Build Coastguard Worker     {
1868*35238bceSAndroid Build Coastguard Worker     }
1869*35238bceSAndroid Build Coastguard Worker 
1870*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1871*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1872*35238bceSAndroid Build Coastguard Worker     {
1873*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1874*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
1875*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
1876*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
1877*35238bceSAndroid Build Coastguard Worker 
1878*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
1879*35238bceSAndroid Build Coastguard Worker 
1880*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1881*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_3D, tex);
1882*35238bceSAndroid Build Coastguard Worker 
1883*35238bceSAndroid Build Coastguard Worker         // Fill with gradient.
1884*35238bceSAndroid Build Coastguard Worker         {
1885*35238bceSAndroid Build Coastguard Worker             int rowPitch   = deAlign32(pixelSize * m_width, 4);
1886*35238bceSAndroid Build Coastguard Worker             int slicePitch = rowPitch * m_height;
1887*35238bceSAndroid Build Coastguard Worker 
1888*35238bceSAndroid Build Coastguard Worker             data.resize(slicePitch * m_depth);
1889*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(
1890*35238bceSAndroid Build Coastguard Worker                 tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0]),
1891*35238bceSAndroid Build Coastguard Worker                 m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1892*35238bceSAndroid Build Coastguard Worker         }
1893*35238bceSAndroid Build Coastguard Worker 
1894*35238bceSAndroid Build Coastguard Worker         glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format,
1895*35238bceSAndroid Build Coastguard Worker                      transferFmt.dataType, &data[0]);
1896*35238bceSAndroid Build Coastguard Worker 
1897*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
1898*35238bceSAndroid Build Coastguard Worker         {
1899*35238bceSAndroid Build Coastguard Worker             int rowLength   = m_rowLength > 0 ? m_rowLength : m_subW;
1900*35238bceSAndroid Build Coastguard Worker             int rowPitch    = deAlign32(rowLength * pixelSize, m_alignment);
1901*35238bceSAndroid Build Coastguard Worker             int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_subH;
1902*35238bceSAndroid Build Coastguard Worker             int slicePitch  = imageHeight * rowPitch;
1903*35238bceSAndroid Build Coastguard Worker             Vec4 cScale     = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
1904*35238bceSAndroid Build Coastguard Worker             Vec4 cBias      = m_texFormatInfo.valueMin;
1905*35238bceSAndroid Build Coastguard Worker             Vec4 colorA     = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
1906*35238bceSAndroid Build Coastguard Worker             Vec4 colorB     = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
1907*35238bceSAndroid Build Coastguard Worker 
1908*35238bceSAndroid Build Coastguard Worker             data.resize(slicePitch * (m_depth + m_skipImages));
1909*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, m_subD, rowPitch, slicePitch,
1910*35238bceSAndroid Build Coastguard Worker                                                      &data[0] + m_skipImages * slicePitch + m_skipRows * rowPitch +
1911*35238bceSAndroid Build Coastguard Worker                                                          m_skipPixels * pixelSize),
1912*35238bceSAndroid Build Coastguard Worker                               4, colorA, colorB);
1913*35238bceSAndroid Build Coastguard Worker         }
1914*35238bceSAndroid Build Coastguard Worker 
1915*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
1916*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
1917*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
1918*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
1919*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
1920*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1921*35238bceSAndroid Build Coastguard Worker         glTexSubImage3D(GL_TEXTURE_3D, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format,
1922*35238bceSAndroid Build Coastguard Worker                         transferFmt.dataType, &data[0]);
1923*35238bceSAndroid Build Coastguard Worker     }
1924*35238bceSAndroid Build Coastguard Worker 
1925*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1926*35238bceSAndroid Build Coastguard Worker     int m_subX;
1927*35238bceSAndroid Build Coastguard Worker     int m_subY;
1928*35238bceSAndroid Build Coastguard Worker     int m_subZ;
1929*35238bceSAndroid Build Coastguard Worker     int m_subW;
1930*35238bceSAndroid Build Coastguard Worker     int m_subH;
1931*35238bceSAndroid Build Coastguard Worker     int m_subD;
1932*35238bceSAndroid Build Coastguard Worker     int m_imageHeight;
1933*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
1934*35238bceSAndroid Build Coastguard Worker     int m_skipImages;
1935*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
1936*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
1937*35238bceSAndroid Build Coastguard Worker     int m_alignment;
1938*35238bceSAndroid Build Coastguard Worker };
1939*35238bceSAndroid Build Coastguard Worker 
1940*35238bceSAndroid Build Coastguard Worker // Basic CopyTexImage2D() with 2D texture usage
1941*35238bceSAndroid Build Coastguard Worker class BasicCopyTexImage2DCase : public Texture2DSpecCase
1942*35238bceSAndroid Build Coastguard Worker {
1943*35238bceSAndroid Build Coastguard Worker public:
BasicCopyTexImage2DCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height)1944*35238bceSAndroid Build Coastguard Worker     BasicCopyTexImage2DCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
1945*35238bceSAndroid Build Coastguard Worker                             int height)
1946*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLTransferFormat(internalFormat, GL_UNSIGNED_BYTE), width,
1947*35238bceSAndroid Build Coastguard Worker                             height, maxLevelCount(width, height))
1948*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
1949*35238bceSAndroid Build Coastguard Worker     {
1950*35238bceSAndroid Build Coastguard Worker     }
1951*35238bceSAndroid Build Coastguard Worker 
1952*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1953*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
1954*35238bceSAndroid Build Coastguard Worker     {
1955*35238bceSAndroid Build Coastguard Worker         const tcu::RenderTarget &renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1956*35238bceSAndroid Build Coastguard Worker         bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 &&
1957*35238bceSAndroid Build Coastguard Worker                             renderTarget.getPixelFormat().blueBits > 0;
1958*35238bceSAndroid Build Coastguard Worker         bool targetHasAlpha    = renderTarget.getPixelFormat().alphaBits > 0;
1959*35238bceSAndroid Build Coastguard Worker         tcu::TextureFormat fmt = mapGLUnsizedInternalFormat(m_internalFormat);
1960*35238bceSAndroid Build Coastguard Worker         bool texHasRGB         = fmt.order != tcu::TextureFormat::A;
1961*35238bceSAndroid Build Coastguard Worker         bool texHasAlpha       = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA ||
1962*35238bceSAndroid Build Coastguard Worker                            fmt.order == tcu::TextureFormat::A;
1963*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
1964*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
1965*35238bceSAndroid Build Coastguard Worker         GradientShader shader(glu::TYPE_FLOAT_VEC4);
1966*35238bceSAndroid Build Coastguard Worker         uint32_t shaderID = getCurrentContext()->createProgram(&shader);
1967*35238bceSAndroid Build Coastguard Worker 
1968*35238bceSAndroid Build Coastguard Worker         if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1969*35238bceSAndroid Build Coastguard Worker             throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1970*35238bceSAndroid Build Coastguard Worker 
1971*35238bceSAndroid Build Coastguard Worker         // Fill render target with gradient.
1972*35238bceSAndroid Build Coastguard Worker         shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
1973*35238bceSAndroid Build Coastguard Worker         sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1974*35238bceSAndroid Build Coastguard Worker 
1975*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
1976*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
1977*35238bceSAndroid Build Coastguard Worker 
1978*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
1979*35238bceSAndroid Build Coastguard Worker         {
1980*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
1981*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
1982*35238bceSAndroid Build Coastguard Worker             int x      = rnd.getInt(0, getWidth() - levelW);
1983*35238bceSAndroid Build Coastguard Worker             int y      = rnd.getInt(0, getHeight() - levelH);
1984*35238bceSAndroid Build Coastguard Worker 
1985*35238bceSAndroid Build Coastguard Worker             glCopyTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, x, y, levelW, levelH, 0);
1986*35238bceSAndroid Build Coastguard Worker         }
1987*35238bceSAndroid Build Coastguard Worker     }
1988*35238bceSAndroid Build Coastguard Worker 
1989*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
1990*35238bceSAndroid Build Coastguard Worker };
1991*35238bceSAndroid Build Coastguard Worker 
1992*35238bceSAndroid Build Coastguard Worker // Basic CopyTexImage2D() with cubemap usage
1993*35238bceSAndroid Build Coastguard Worker class BasicCopyTexImageCubeCase : public TextureCubeSpecCase
1994*35238bceSAndroid Build Coastguard Worker {
1995*35238bceSAndroid Build Coastguard Worker public:
BasicCopyTexImageCubeCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size)1996*35238bceSAndroid Build Coastguard Worker     BasicCopyTexImageCubeCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size)
1997*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLTransferFormat(internalFormat, GL_UNSIGNED_BYTE), size,
1998*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
1999*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2000*35238bceSAndroid Build Coastguard Worker     {
2001*35238bceSAndroid Build Coastguard Worker     }
2002*35238bceSAndroid Build Coastguard Worker 
2003*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2004*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2005*35238bceSAndroid Build Coastguard Worker     {
2006*35238bceSAndroid Build Coastguard Worker         const tcu::RenderTarget &renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
2007*35238bceSAndroid Build Coastguard Worker         bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 &&
2008*35238bceSAndroid Build Coastguard Worker                             renderTarget.getPixelFormat().blueBits > 0;
2009*35238bceSAndroid Build Coastguard Worker         bool targetHasAlpha    = renderTarget.getPixelFormat().alphaBits > 0;
2010*35238bceSAndroid Build Coastguard Worker         tcu::TextureFormat fmt = mapGLUnsizedInternalFormat(m_internalFormat);
2011*35238bceSAndroid Build Coastguard Worker         bool texHasRGB         = fmt.order != tcu::TextureFormat::A;
2012*35238bceSAndroid Build Coastguard Worker         bool texHasAlpha       = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA ||
2013*35238bceSAndroid Build Coastguard Worker                            fmt.order == tcu::TextureFormat::A;
2014*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
2015*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
2016*35238bceSAndroid Build Coastguard Worker         GradientShader shader(glu::TYPE_FLOAT_VEC4);
2017*35238bceSAndroid Build Coastguard Worker         uint32_t shaderID = getCurrentContext()->createProgram(&shader);
2018*35238bceSAndroid Build Coastguard Worker 
2019*35238bceSAndroid Build Coastguard Worker         if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
2020*35238bceSAndroid Build Coastguard Worker             throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
2021*35238bceSAndroid Build Coastguard Worker 
2022*35238bceSAndroid Build Coastguard Worker         // Fill render target with gradient.
2023*35238bceSAndroid Build Coastguard Worker         shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
2024*35238bceSAndroid Build Coastguard Worker         sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
2025*35238bceSAndroid Build Coastguard Worker 
2026*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2027*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
2028*35238bceSAndroid Build Coastguard Worker 
2029*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
2030*35238bceSAndroid Build Coastguard Worker         {
2031*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
2032*35238bceSAndroid Build Coastguard Worker 
2033*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2034*35238bceSAndroid Build Coastguard Worker             {
2035*35238bceSAndroid Build Coastguard Worker                 int x = rnd.getInt(0, getWidth() - levelSize);
2036*35238bceSAndroid Build Coastguard Worker                 int y = rnd.getInt(0, getHeight() - levelSize);
2037*35238bceSAndroid Build Coastguard Worker 
2038*35238bceSAndroid Build Coastguard Worker                 glCopyTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, x, y, levelSize, levelSize, 0);
2039*35238bceSAndroid Build Coastguard Worker             }
2040*35238bceSAndroid Build Coastguard Worker         }
2041*35238bceSAndroid Build Coastguard Worker     }
2042*35238bceSAndroid Build Coastguard Worker 
2043*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2044*35238bceSAndroid Build Coastguard Worker };
2045*35238bceSAndroid Build Coastguard Worker 
2046*35238bceSAndroid Build Coastguard Worker // Basic CopyTexSubImage2D() with 2D texture usage
2047*35238bceSAndroid Build Coastguard Worker class BasicCopyTexSubImage2DCase : public Texture2DSpecCase
2048*35238bceSAndroid Build Coastguard Worker {
2049*35238bceSAndroid Build Coastguard Worker public:
BasicCopyTexSubImage2DCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int width,int height)2050*35238bceSAndroid Build Coastguard Worker     BasicCopyTexSubImage2DCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
2051*35238bceSAndroid Build Coastguard Worker                                int width, int height)
2052*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height,
2053*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(width, height))
2054*35238bceSAndroid Build Coastguard Worker         , m_format(format)
2055*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
2056*35238bceSAndroid Build Coastguard Worker     {
2057*35238bceSAndroid Build Coastguard Worker     }
2058*35238bceSAndroid Build Coastguard Worker 
2059*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2060*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2061*35238bceSAndroid Build Coastguard Worker     {
2062*35238bceSAndroid Build Coastguard Worker         const tcu::RenderTarget &renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
2063*35238bceSAndroid Build Coastguard Worker         bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 &&
2064*35238bceSAndroid Build Coastguard Worker                             renderTarget.getPixelFormat().blueBits > 0;
2065*35238bceSAndroid Build Coastguard Worker         bool targetHasAlpha    = renderTarget.getPixelFormat().alphaBits > 0;
2066*35238bceSAndroid Build Coastguard Worker         tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType);
2067*35238bceSAndroid Build Coastguard Worker         bool texHasRGB         = fmt.order != tcu::TextureFormat::A;
2068*35238bceSAndroid Build Coastguard Worker         bool texHasAlpha       = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA ||
2069*35238bceSAndroid Build Coastguard Worker                            fmt.order == tcu::TextureFormat::A;
2070*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
2071*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel data(fmt);
2072*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
2073*35238bceSAndroid Build Coastguard Worker         GradientShader shader(glu::TYPE_FLOAT_VEC4);
2074*35238bceSAndroid Build Coastguard Worker         uint32_t shaderID = getCurrentContext()->createProgram(&shader);
2075*35238bceSAndroid Build Coastguard Worker 
2076*35238bceSAndroid Build Coastguard Worker         if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
2077*35238bceSAndroid Build Coastguard Worker             throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
2078*35238bceSAndroid Build Coastguard Worker 
2079*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2080*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
2081*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2082*35238bceSAndroid Build Coastguard Worker 
2083*35238bceSAndroid Build Coastguard Worker         // First specify full texture.
2084*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
2085*35238bceSAndroid Build Coastguard Worker         {
2086*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
2087*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
2088*35238bceSAndroid Build Coastguard Worker 
2089*35238bceSAndroid Build Coastguard Worker             Vec4 colorA  = randomVector<4>(rnd);
2090*35238bceSAndroid Build Coastguard Worker             Vec4 colorB  = randomVector<4>(rnd);
2091*35238bceSAndroid Build Coastguard Worker             int cellSize = rnd.getInt(2, 16);
2092*35238bceSAndroid Build Coastguard Worker 
2093*35238bceSAndroid Build Coastguard Worker             data.setSize(levelW, levelH);
2094*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
2095*35238bceSAndroid Build Coastguard Worker 
2096*35238bceSAndroid Build Coastguard Worker             glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType,
2097*35238bceSAndroid Build Coastguard Worker                          data.getAccess().getDataPtr());
2098*35238bceSAndroid Build Coastguard Worker         }
2099*35238bceSAndroid Build Coastguard Worker 
2100*35238bceSAndroid Build Coastguard Worker         // Fill render target with gradient.
2101*35238bceSAndroid Build Coastguard Worker         shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
2102*35238bceSAndroid Build Coastguard Worker         sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
2103*35238bceSAndroid Build Coastguard Worker 
2104*35238bceSAndroid Build Coastguard Worker         // Re-specify parts of each level.
2105*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
2106*35238bceSAndroid Build Coastguard Worker         {
2107*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
2108*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
2109*35238bceSAndroid Build Coastguard Worker 
2110*35238bceSAndroid Build Coastguard Worker             int w  = rnd.getInt(1, levelW);
2111*35238bceSAndroid Build Coastguard Worker             int h  = rnd.getInt(1, levelH);
2112*35238bceSAndroid Build Coastguard Worker             int xo = rnd.getInt(0, levelW - w);
2113*35238bceSAndroid Build Coastguard Worker             int yo = rnd.getInt(0, levelH - h);
2114*35238bceSAndroid Build Coastguard Worker 
2115*35238bceSAndroid Build Coastguard Worker             int x = rnd.getInt(0, getWidth() - w);
2116*35238bceSAndroid Build Coastguard Worker             int y = rnd.getInt(0, getHeight() - h);
2117*35238bceSAndroid Build Coastguard Worker 
2118*35238bceSAndroid Build Coastguard Worker             glCopyTexSubImage2D(GL_TEXTURE_2D, ndx, xo, yo, x, y, w, h);
2119*35238bceSAndroid Build Coastguard Worker         }
2120*35238bceSAndroid Build Coastguard Worker     }
2121*35238bceSAndroid Build Coastguard Worker 
2122*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
2123*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
2124*35238bceSAndroid Build Coastguard Worker };
2125*35238bceSAndroid Build Coastguard Worker 
2126*35238bceSAndroid Build Coastguard Worker // Basic CopyTexSubImage2D() with cubemap usage
2127*35238bceSAndroid Build Coastguard Worker class BasicCopyTexSubImageCubeCase : public TextureCubeSpecCase
2128*35238bceSAndroid Build Coastguard Worker {
2129*35238bceSAndroid Build Coastguard Worker public:
BasicCopyTexSubImageCubeCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,int size)2130*35238bceSAndroid Build Coastguard Worker     BasicCopyTexSubImageCubeCase(Context &context, const char *name, const char *desc, uint32_t format,
2131*35238bceSAndroid Build Coastguard Worker                                  uint32_t dataType, int size)
2132*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLTransferFormat(format, dataType), size,
2133*35238bceSAndroid Build Coastguard Worker                               deLog2Floor32(size) + 1)
2134*35238bceSAndroid Build Coastguard Worker         , m_format(format)
2135*35238bceSAndroid Build Coastguard Worker         , m_dataType(dataType)
2136*35238bceSAndroid Build Coastguard Worker     {
2137*35238bceSAndroid Build Coastguard Worker     }
2138*35238bceSAndroid Build Coastguard Worker 
2139*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2140*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2141*35238bceSAndroid Build Coastguard Worker     {
2142*35238bceSAndroid Build Coastguard Worker         const tcu::RenderTarget &renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
2143*35238bceSAndroid Build Coastguard Worker         bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 &&
2144*35238bceSAndroid Build Coastguard Worker                             renderTarget.getPixelFormat().blueBits > 0;
2145*35238bceSAndroid Build Coastguard Worker         bool targetHasAlpha    = renderTarget.getPixelFormat().alphaBits > 0;
2146*35238bceSAndroid Build Coastguard Worker         tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType);
2147*35238bceSAndroid Build Coastguard Worker         bool texHasRGB         = fmt.order != tcu::TextureFormat::A;
2148*35238bceSAndroid Build Coastguard Worker         bool texHasAlpha       = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA ||
2149*35238bceSAndroid Build Coastguard Worker                            fmt.order == tcu::TextureFormat::A;
2150*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
2151*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel data(fmt);
2152*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
2153*35238bceSAndroid Build Coastguard Worker         GradientShader shader(glu::TYPE_FLOAT_VEC4);
2154*35238bceSAndroid Build Coastguard Worker         uint32_t shaderID = getCurrentContext()->createProgram(&shader);
2155*35238bceSAndroid Build Coastguard Worker 
2156*35238bceSAndroid Build Coastguard Worker         if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
2157*35238bceSAndroid Build Coastguard Worker             throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
2158*35238bceSAndroid Build Coastguard Worker 
2159*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2160*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
2161*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2162*35238bceSAndroid Build Coastguard Worker 
2163*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
2164*35238bceSAndroid Build Coastguard Worker         {
2165*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
2166*35238bceSAndroid Build Coastguard Worker 
2167*35238bceSAndroid Build Coastguard Worker             data.setSize(levelSize, levelSize);
2168*35238bceSAndroid Build Coastguard Worker 
2169*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2170*35238bceSAndroid Build Coastguard Worker             {
2171*35238bceSAndroid Build Coastguard Worker                 Vec4 colorA  = randomVector<4>(rnd);
2172*35238bceSAndroid Build Coastguard Worker                 Vec4 colorB  = randomVector<4>(rnd);
2173*35238bceSAndroid Build Coastguard Worker                 int cellSize = rnd.getInt(2, 16);
2174*35238bceSAndroid Build Coastguard Worker 
2175*35238bceSAndroid Build Coastguard Worker                 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
2176*35238bceSAndroid Build Coastguard Worker                 glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelSize, levelSize, 0, m_format, m_dataType,
2177*35238bceSAndroid Build Coastguard Worker                              data.getAccess().getDataPtr());
2178*35238bceSAndroid Build Coastguard Worker             }
2179*35238bceSAndroid Build Coastguard Worker         }
2180*35238bceSAndroid Build Coastguard Worker 
2181*35238bceSAndroid Build Coastguard Worker         // Fill render target with gradient.
2182*35238bceSAndroid Build Coastguard Worker         shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
2183*35238bceSAndroid Build Coastguard Worker         sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
2184*35238bceSAndroid Build Coastguard Worker 
2185*35238bceSAndroid Build Coastguard Worker         // Re-specify parts of each face and level.
2186*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
2187*35238bceSAndroid Build Coastguard Worker         {
2188*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
2189*35238bceSAndroid Build Coastguard Worker 
2190*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2191*35238bceSAndroid Build Coastguard Worker             {
2192*35238bceSAndroid Build Coastguard Worker                 int w  = rnd.getInt(1, levelSize);
2193*35238bceSAndroid Build Coastguard Worker                 int h  = rnd.getInt(1, levelSize);
2194*35238bceSAndroid Build Coastguard Worker                 int xo = rnd.getInt(0, levelSize - w);
2195*35238bceSAndroid Build Coastguard Worker                 int yo = rnd.getInt(0, levelSize - h);
2196*35238bceSAndroid Build Coastguard Worker 
2197*35238bceSAndroid Build Coastguard Worker                 int x = rnd.getInt(0, getWidth() - w);
2198*35238bceSAndroid Build Coastguard Worker                 int y = rnd.getInt(0, getHeight() - h);
2199*35238bceSAndroid Build Coastguard Worker 
2200*35238bceSAndroid Build Coastguard Worker                 glCopyTexSubImage2D(s_cubeMapFaces[face], ndx, xo, yo, x, y, w, h);
2201*35238bceSAndroid Build Coastguard Worker             }
2202*35238bceSAndroid Build Coastguard Worker         }
2203*35238bceSAndroid Build Coastguard Worker     }
2204*35238bceSAndroid Build Coastguard Worker 
2205*35238bceSAndroid Build Coastguard Worker     uint32_t m_format;
2206*35238bceSAndroid Build Coastguard Worker     uint32_t m_dataType;
2207*35238bceSAndroid Build Coastguard Worker };
2208*35238bceSAndroid Build Coastguard Worker 
2209*35238bceSAndroid Build Coastguard Worker // Basic glTexStorage2D() with 2D texture usage
2210*35238bceSAndroid Build Coastguard Worker class BasicTexStorage2DCase : public Texture2DSpecCase
2211*35238bceSAndroid Build Coastguard Worker {
2212*35238bceSAndroid Build Coastguard Worker public:
BasicTexStorage2DCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int numLevels)2213*35238bceSAndroid Build Coastguard Worker     BasicTexStorage2DCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
2214*35238bceSAndroid Build Coastguard Worker                           int height, int numLevels)
2215*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLevels)
2216*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2217*35238bceSAndroid Build Coastguard Worker     {
2218*35238bceSAndroid Build Coastguard Worker     }
2219*35238bceSAndroid Build Coastguard Worker 
2220*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2221*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2222*35238bceSAndroid Build Coastguard Worker     {
2223*35238bceSAndroid Build Coastguard Worker         tcu::TextureFormat fmt          = glu::mapGLInternalFormat(m_internalFormat);
2224*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(fmt);
2225*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
2226*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
2227*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
2228*35238bceSAndroid Build Coastguard Worker 
2229*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2230*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
2231*35238bceSAndroid Build Coastguard Worker         glTexStorage2D(GL_TEXTURE_2D, m_numLevels, m_internalFormat, m_width, m_height);
2232*35238bceSAndroid Build Coastguard Worker 
2233*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2234*35238bceSAndroid Build Coastguard Worker 
2235*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
2236*35238bceSAndroid Build Coastguard Worker         {
2237*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
2238*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
2239*35238bceSAndroid Build Coastguard Worker             Vec4 gMin  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2240*35238bceSAndroid Build Coastguard Worker             Vec4 gMax  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2241*35238bceSAndroid Build Coastguard Worker 
2242*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH);
2243*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
2244*35238bceSAndroid Build Coastguard Worker 
2245*35238bceSAndroid Build Coastguard Worker             glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, transferFmt.format, transferFmt.dataType,
2246*35238bceSAndroid Build Coastguard Worker                             levelData.getAccess().getDataPtr());
2247*35238bceSAndroid Build Coastguard Worker         }
2248*35238bceSAndroid Build Coastguard Worker     }
2249*35238bceSAndroid Build Coastguard Worker 
2250*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2251*35238bceSAndroid Build Coastguard Worker };
2252*35238bceSAndroid Build Coastguard Worker 
2253*35238bceSAndroid Build Coastguard Worker // Basic glTexStorage2D() with cubemap usage
2254*35238bceSAndroid Build Coastguard Worker class BasicTexStorageCubeCase : public TextureCubeSpecCase
2255*35238bceSAndroid Build Coastguard Worker {
2256*35238bceSAndroid Build Coastguard Worker public:
BasicTexStorageCubeCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size,int numLevels)2257*35238bceSAndroid Build Coastguard Worker     BasicTexStorageCubeCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size,
2258*35238bceSAndroid Build Coastguard Worker                             int numLevels)
2259*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLevels)
2260*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2261*35238bceSAndroid Build Coastguard Worker     {
2262*35238bceSAndroid Build Coastguard Worker     }
2263*35238bceSAndroid Build Coastguard Worker 
2264*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2265*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2266*35238bceSAndroid Build Coastguard Worker     {
2267*35238bceSAndroid Build Coastguard Worker         tcu::TextureFormat fmt          = glu::mapGLInternalFormat(m_internalFormat);
2268*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(fmt);
2269*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
2270*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
2271*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
2272*35238bceSAndroid Build Coastguard Worker 
2273*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2274*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
2275*35238bceSAndroid Build Coastguard Worker         glTexStorage2D(GL_TEXTURE_CUBE_MAP, m_numLevels, m_internalFormat, m_size, m_size);
2276*35238bceSAndroid Build Coastguard Worker 
2277*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2278*35238bceSAndroid Build Coastguard Worker 
2279*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
2280*35238bceSAndroid Build Coastguard Worker         {
2281*35238bceSAndroid Build Coastguard Worker             int levelSize = de::max(1, m_size >> ndx);
2282*35238bceSAndroid Build Coastguard Worker 
2283*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelSize, levelSize);
2284*35238bceSAndroid Build Coastguard Worker 
2285*35238bceSAndroid Build Coastguard Worker             for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2286*35238bceSAndroid Build Coastguard Worker             {
2287*35238bceSAndroid Build Coastguard Worker                 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2288*35238bceSAndroid Build Coastguard Worker                 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2289*35238bceSAndroid Build Coastguard Worker 
2290*35238bceSAndroid Build Coastguard Worker                 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
2291*35238bceSAndroid Build Coastguard Worker 
2292*35238bceSAndroid Build Coastguard Worker                 glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelSize, levelSize, transferFmt.format,
2293*35238bceSAndroid Build Coastguard Worker                                 transferFmt.dataType, levelData.getAccess().getDataPtr());
2294*35238bceSAndroid Build Coastguard Worker             }
2295*35238bceSAndroid Build Coastguard Worker         }
2296*35238bceSAndroid Build Coastguard Worker     }
2297*35238bceSAndroid Build Coastguard Worker 
2298*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2299*35238bceSAndroid Build Coastguard Worker };
2300*35238bceSAndroid Build Coastguard Worker 
2301*35238bceSAndroid Build Coastguard Worker // Basic glTexStorage3D() with 2D array texture usage
2302*35238bceSAndroid Build Coastguard Worker class BasicTexStorage2DArrayCase : public Texture2DArraySpecCase
2303*35238bceSAndroid Build Coastguard Worker {
2304*35238bceSAndroid Build Coastguard Worker public:
BasicTexStorage2DArrayCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int numLayers,int numLevels)2305*35238bceSAndroid Build Coastguard Worker     BasicTexStorage2DArrayCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
2306*35238bceSAndroid Build Coastguard Worker                                int height, int numLayers, int numLevels)
2307*35238bceSAndroid Build Coastguard Worker         : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height,
2308*35238bceSAndroid Build Coastguard Worker                                  numLayers, numLevels)
2309*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2310*35238bceSAndroid Build Coastguard Worker     {
2311*35238bceSAndroid Build Coastguard Worker     }
2312*35238bceSAndroid Build Coastguard Worker 
2313*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2314*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2315*35238bceSAndroid Build Coastguard Worker     {
2316*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
2317*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
2318*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2319*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
2320*35238bceSAndroid Build Coastguard Worker 
2321*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2322*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
2323*35238bceSAndroid Build Coastguard Worker         glTexStorage3D(GL_TEXTURE_2D_ARRAY, m_numLevels, m_internalFormat, m_width, m_height, m_numLayers);
2324*35238bceSAndroid Build Coastguard Worker 
2325*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2326*35238bceSAndroid Build Coastguard Worker 
2327*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
2328*35238bceSAndroid Build Coastguard Worker         {
2329*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
2330*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
2331*35238bceSAndroid Build Coastguard Worker             Vec4 gMin  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2332*35238bceSAndroid Build Coastguard Worker             Vec4 gMax  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2333*35238bceSAndroid Build Coastguard Worker 
2334*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH, m_numLayers);
2335*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
2336*35238bceSAndroid Build Coastguard Worker 
2337*35238bceSAndroid Build Coastguard Worker             glTexSubImage3D(GL_TEXTURE_2D_ARRAY, ndx, 0, 0, 0, levelW, levelH, m_numLayers, transferFmt.format,
2338*35238bceSAndroid Build Coastguard Worker                             transferFmt.dataType, levelData.getAccess().getDataPtr());
2339*35238bceSAndroid Build Coastguard Worker         }
2340*35238bceSAndroid Build Coastguard Worker     }
2341*35238bceSAndroid Build Coastguard Worker 
2342*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2343*35238bceSAndroid Build Coastguard Worker };
2344*35238bceSAndroid Build Coastguard Worker 
2345*35238bceSAndroid Build Coastguard Worker // Basic TexStorage3D() with 3D texture usage
2346*35238bceSAndroid Build Coastguard Worker class BasicTexStorage3DCase : public Texture3DSpecCase
2347*35238bceSAndroid Build Coastguard Worker {
2348*35238bceSAndroid Build Coastguard Worker public:
BasicTexStorage3DCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int depth,int numLevels)2349*35238bceSAndroid Build Coastguard Worker     BasicTexStorage3DCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
2350*35238bceSAndroid Build Coastguard Worker                           int height, int depth, int numLevels)
2351*35238bceSAndroid Build Coastguard Worker         : Texture3DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth,
2352*35238bceSAndroid Build Coastguard Worker                             numLevels)
2353*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2354*35238bceSAndroid Build Coastguard Worker     {
2355*35238bceSAndroid Build Coastguard Worker     }
2356*35238bceSAndroid Build Coastguard Worker 
2357*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2358*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2359*35238bceSAndroid Build Coastguard Worker     {
2360*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
2361*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
2362*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2363*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
2364*35238bceSAndroid Build Coastguard Worker 
2365*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2366*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_3D, tex);
2367*35238bceSAndroid Build Coastguard Worker         glTexStorage3D(GL_TEXTURE_3D, m_numLevels, m_internalFormat, m_width, m_height, m_depth);
2368*35238bceSAndroid Build Coastguard Worker 
2369*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2370*35238bceSAndroid Build Coastguard Worker 
2371*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
2372*35238bceSAndroid Build Coastguard Worker         {
2373*35238bceSAndroid Build Coastguard Worker             int levelW = de::max(1, m_width >> ndx);
2374*35238bceSAndroid Build Coastguard Worker             int levelH = de::max(1, m_height >> ndx);
2375*35238bceSAndroid Build Coastguard Worker             int levelD = de::max(1, m_depth >> ndx);
2376*35238bceSAndroid Build Coastguard Worker             Vec4 gMin  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2377*35238bceSAndroid Build Coastguard Worker             Vec4 gMax  = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2378*35238bceSAndroid Build Coastguard Worker 
2379*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH, levelD);
2380*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
2381*35238bceSAndroid Build Coastguard Worker 
2382*35238bceSAndroid Build Coastguard Worker             glTexSubImage3D(GL_TEXTURE_3D, ndx, 0, 0, 0, levelW, levelH, levelD, transferFmt.format,
2383*35238bceSAndroid Build Coastguard Worker                             transferFmt.dataType, levelData.getAccess().getDataPtr());
2384*35238bceSAndroid Build Coastguard Worker         }
2385*35238bceSAndroid Build Coastguard Worker     }
2386*35238bceSAndroid Build Coastguard Worker 
2387*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2388*35238bceSAndroid Build Coastguard Worker };
2389*35238bceSAndroid Build Coastguard Worker 
2390*35238bceSAndroid Build Coastguard Worker // Pixel buffer object cases.
2391*35238bceSAndroid Build Coastguard Worker 
2392*35238bceSAndroid Build Coastguard Worker // TexImage2D() from pixel buffer object.
2393*35238bceSAndroid Build Coastguard Worker class TexImage2DBufferCase : public Texture2DSpecCase
2394*35238bceSAndroid Build Coastguard Worker {
2395*35238bceSAndroid Build Coastguard Worker public:
TexImage2DBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int rowLength,int skipRows,int skipPixels,int alignment,int offset)2396*35238bceSAndroid Build Coastguard Worker     TexImage2DBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
2397*35238bceSAndroid Build Coastguard Worker                          int height, int rowLength, int skipRows, int skipPixels, int alignment, int offset)
2398*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
2399*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2400*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
2401*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
2402*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
2403*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
2404*35238bceSAndroid Build Coastguard Worker         , m_offset(offset)
2405*35238bceSAndroid Build Coastguard Worker     {
2406*35238bceSAndroid Build Coastguard Worker     }
2407*35238bceSAndroid Build Coastguard Worker 
2408*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2409*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2410*35238bceSAndroid Build Coastguard Worker     {
2411*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2412*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
2413*35238bceSAndroid Build Coastguard Worker         int rowLength                   = m_rowLength > 0 ? m_rowLength : m_width + m_skipPixels;
2414*35238bceSAndroid Build Coastguard Worker         int rowPitch                    = deAlign32(rowLength * pixelSize, m_alignment);
2415*35238bceSAndroid Build Coastguard Worker         int height                      = m_height + m_skipRows;
2416*35238bceSAndroid Build Coastguard Worker         uint32_t buf                    = 0;
2417*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
2418*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
2419*35238bceSAndroid Build Coastguard Worker 
2420*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
2421*35238bceSAndroid Build Coastguard Worker 
2422*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
2423*35238bceSAndroid Build Coastguard Worker         data.resize(rowPitch * height + m_offset);
2424*35238bceSAndroid Build Coastguard Worker         {
2425*35238bceSAndroid Build Coastguard Worker             Vec4 cScale = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
2426*35238bceSAndroid Build Coastguard Worker             Vec4 cBias  = m_texFormatInfo.valueMin;
2427*35238bceSAndroid Build Coastguard Worker             Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
2428*35238bceSAndroid Build Coastguard Worker             Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
2429*35238bceSAndroid Build Coastguard Worker 
2430*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(
2431*35238bceSAndroid Build Coastguard Worker                 tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0,
2432*35238bceSAndroid Build Coastguard Worker                                        &data[0] + m_skipRows * rowPitch + m_skipPixels * pixelSize + m_offset),
2433*35238bceSAndroid Build Coastguard Worker                 4, colorA, colorB);
2434*35238bceSAndroid Build Coastguard Worker         }
2435*35238bceSAndroid Build Coastguard Worker 
2436*35238bceSAndroid Build Coastguard Worker         // Create buffer and upload.
2437*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &buf);
2438*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2439*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2440*35238bceSAndroid Build Coastguard Worker 
2441*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2442*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2443*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2444*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2445*35238bceSAndroid Build Coastguard Worker 
2446*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2447*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
2448*35238bceSAndroid Build Coastguard Worker         glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType,
2449*35238bceSAndroid Build Coastguard Worker                      (const void *)(uintptr_t)m_offset);
2450*35238bceSAndroid Build Coastguard Worker     }
2451*35238bceSAndroid Build Coastguard Worker 
2452*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2453*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
2454*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
2455*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
2456*35238bceSAndroid Build Coastguard Worker     int m_alignment;
2457*35238bceSAndroid Build Coastguard Worker     int m_offset;
2458*35238bceSAndroid Build Coastguard Worker };
2459*35238bceSAndroid Build Coastguard Worker 
2460*35238bceSAndroid Build Coastguard Worker // TexImage2D() cubemap from pixel buffer object case
2461*35238bceSAndroid Build Coastguard Worker class TexImageCubeBufferCase : public TextureCubeSpecCase
2462*35238bceSAndroid Build Coastguard Worker {
2463*35238bceSAndroid Build Coastguard Worker public:
TexImageCubeBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size,int rowLength,int skipRows,int skipPixels,int alignment,int offset)2464*35238bceSAndroid Build Coastguard Worker     TexImageCubeBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size,
2465*35238bceSAndroid Build Coastguard Worker                            int rowLength, int skipRows, int skipPixels, int alignment, int offset)
2466*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1)
2467*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2468*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
2469*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
2470*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
2471*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
2472*35238bceSAndroid Build Coastguard Worker         , m_offset(offset)
2473*35238bceSAndroid Build Coastguard Worker     {
2474*35238bceSAndroid Build Coastguard Worker     }
2475*35238bceSAndroid Build Coastguard Worker 
2476*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2477*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2478*35238bceSAndroid Build Coastguard Worker     {
2479*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
2480*35238bceSAndroid Build Coastguard Worker         uint32_t tex            = 0;
2481*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
2482*35238bceSAndroid Build Coastguard Worker         const int pixelSize     = m_texFormat.getPixelSize();
2483*35238bceSAndroid Build Coastguard Worker         const int rowLength     = m_rowLength > 0 ? m_rowLength : m_size + m_skipPixels;
2484*35238bceSAndroid Build Coastguard Worker         const int rowPitch      = deAlign32(rowLength * pixelSize, m_alignment);
2485*35238bceSAndroid Build Coastguard Worker         const int height        = m_size + m_skipRows;
2486*35238bceSAndroid Build Coastguard Worker         vector<vector<uint8_t>> data(DE_LENGTH_OF_ARRAY(s_cubeMapFaces));
2487*35238bceSAndroid Build Coastguard Worker 
2488*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
2489*35238bceSAndroid Build Coastguard Worker 
2490*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2491*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
2492*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2493*35238bceSAndroid Build Coastguard Worker 
2494*35238bceSAndroid Build Coastguard Worker         for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2495*35238bceSAndroid Build Coastguard Worker         {
2496*35238bceSAndroid Build Coastguard Worker             uint32_t buf = 0;
2497*35238bceSAndroid Build Coastguard Worker 
2498*35238bceSAndroid Build Coastguard Worker             {
2499*35238bceSAndroid Build Coastguard Worker                 const Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2500*35238bceSAndroid Build Coastguard Worker                 const Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2501*35238bceSAndroid Build Coastguard Worker 
2502*35238bceSAndroid Build Coastguard Worker                 data[face].resize(rowPitch * height + m_offset);
2503*35238bceSAndroid Build Coastguard Worker                 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, rowPitch, 0,
2504*35238bceSAndroid Build Coastguard Worker                                                                        &data[face][0] + m_skipRows * rowPitch +
2505*35238bceSAndroid Build Coastguard Worker                                                                            m_skipPixels * pixelSize + m_offset),
2506*35238bceSAndroid Build Coastguard Worker                                                 gMin, gMax);
2507*35238bceSAndroid Build Coastguard Worker             }
2508*35238bceSAndroid Build Coastguard Worker 
2509*35238bceSAndroid Build Coastguard Worker             // Create buffer and upload.
2510*35238bceSAndroid Build Coastguard Worker             glGenBuffers(1, &buf);
2511*35238bceSAndroid Build Coastguard Worker             glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2512*35238bceSAndroid Build Coastguard Worker             glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data[face].size(), &data[face][0], GL_STATIC_DRAW);
2513*35238bceSAndroid Build Coastguard Worker 
2514*35238bceSAndroid Build Coastguard Worker             glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2515*35238bceSAndroid Build Coastguard Worker             glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2516*35238bceSAndroid Build Coastguard Worker             glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2517*35238bceSAndroid Build Coastguard Worker             glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2518*35238bceSAndroid Build Coastguard Worker 
2519*35238bceSAndroid Build Coastguard Worker             glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, fmt.format, fmt.dataType,
2520*35238bceSAndroid Build Coastguard Worker                          (const void *)(uintptr_t)m_offset);
2521*35238bceSAndroid Build Coastguard Worker         }
2522*35238bceSAndroid Build Coastguard Worker     }
2523*35238bceSAndroid Build Coastguard Worker 
2524*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2525*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
2526*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
2527*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
2528*35238bceSAndroid Build Coastguard Worker     int m_alignment;
2529*35238bceSAndroid Build Coastguard Worker     int m_offset;
2530*35238bceSAndroid Build Coastguard Worker };
2531*35238bceSAndroid Build Coastguard Worker 
2532*35238bceSAndroid Build Coastguard Worker // TexImage3D() 2D array from pixel buffer object.
2533*35238bceSAndroid Build Coastguard Worker class TexImage2DArrayBufferCase : public Texture2DArraySpecCase
2534*35238bceSAndroid Build Coastguard Worker {
2535*35238bceSAndroid Build Coastguard Worker public:
TexImage2DArrayBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int depth,int imageHeight,int rowLength,int skipImages,int skipRows,int skipPixels,int alignment,int offset)2536*35238bceSAndroid Build Coastguard Worker     TexImage2DArrayBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
2537*35238bceSAndroid Build Coastguard Worker                               int height, int depth, int imageHeight, int rowLength, int skipImages, int skipRows,
2538*35238bceSAndroid Build Coastguard Worker                               int skipPixels, int alignment, int offset)
2539*35238bceSAndroid Build Coastguard Worker         : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
2540*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2541*35238bceSAndroid Build Coastguard Worker         , m_imageHeight(imageHeight)
2542*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
2543*35238bceSAndroid Build Coastguard Worker         , m_skipImages(skipImages)
2544*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
2545*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
2546*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
2547*35238bceSAndroid Build Coastguard Worker         , m_offset(offset)
2548*35238bceSAndroid Build Coastguard Worker     {
2549*35238bceSAndroid Build Coastguard Worker     }
2550*35238bceSAndroid Build Coastguard Worker 
2551*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2552*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2553*35238bceSAndroid Build Coastguard Worker     {
2554*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2555*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
2556*35238bceSAndroid Build Coastguard Worker         int rowLength                   = m_rowLength > 0 ? m_rowLength : m_width;
2557*35238bceSAndroid Build Coastguard Worker         int rowPitch                    = deAlign32(rowLength * pixelSize, m_alignment);
2558*35238bceSAndroid Build Coastguard Worker         int imageHeight                 = m_imageHeight > 0 ? m_imageHeight : m_height;
2559*35238bceSAndroid Build Coastguard Worker         int slicePitch                  = imageHeight * rowPitch;
2560*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
2561*35238bceSAndroid Build Coastguard Worker         uint32_t buf                    = 0;
2562*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
2563*35238bceSAndroid Build Coastguard Worker 
2564*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
2565*35238bceSAndroid Build Coastguard Worker 
2566*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
2567*35238bceSAndroid Build Coastguard Worker         data.resize(slicePitch * (m_numLayers + m_skipImages) + m_offset);
2568*35238bceSAndroid Build Coastguard Worker         {
2569*35238bceSAndroid Build Coastguard Worker             Vec4 cScale = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
2570*35238bceSAndroid Build Coastguard Worker             Vec4 cBias  = m_texFormatInfo.valueMin;
2571*35238bceSAndroid Build Coastguard Worker             Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
2572*35238bceSAndroid Build Coastguard Worker             Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
2573*35238bceSAndroid Build Coastguard Worker 
2574*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_numLayers, rowPitch, slicePitch,
2575*35238bceSAndroid Build Coastguard Worker                                                      &data[0] + m_skipImages * slicePitch + m_skipRows * rowPitch +
2576*35238bceSAndroid Build Coastguard Worker                                                          m_skipPixels * pixelSize + m_offset),
2577*35238bceSAndroid Build Coastguard Worker                               4, colorA, colorB);
2578*35238bceSAndroid Build Coastguard Worker         }
2579*35238bceSAndroid Build Coastguard Worker 
2580*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &buf);
2581*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2582*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2583*35238bceSAndroid Build Coastguard Worker 
2584*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
2585*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2586*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
2587*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2588*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2589*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2590*35238bceSAndroid Build Coastguard Worker 
2591*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2592*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
2593*35238bceSAndroid Build Coastguard Worker         glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format,
2594*35238bceSAndroid Build Coastguard Worker                      transferFmt.dataType, (const void *)(uintptr_t)m_offset);
2595*35238bceSAndroid Build Coastguard Worker     }
2596*35238bceSAndroid Build Coastguard Worker 
2597*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2598*35238bceSAndroid Build Coastguard Worker     int m_imageHeight;
2599*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
2600*35238bceSAndroid Build Coastguard Worker     int m_skipImages;
2601*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
2602*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
2603*35238bceSAndroid Build Coastguard Worker     int m_alignment;
2604*35238bceSAndroid Build Coastguard Worker     int m_offset;
2605*35238bceSAndroid Build Coastguard Worker };
2606*35238bceSAndroid Build Coastguard Worker 
2607*35238bceSAndroid Build Coastguard Worker // TexImage3D() from pixel buffer object.
2608*35238bceSAndroid Build Coastguard Worker class TexImage3DBufferCase : public Texture3DSpecCase
2609*35238bceSAndroid Build Coastguard Worker {
2610*35238bceSAndroid Build Coastguard Worker public:
TexImage3DBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int depth,int imageHeight,int rowLength,int skipImages,int skipRows,int skipPixels,int alignment,int offset)2611*35238bceSAndroid Build Coastguard Worker     TexImage3DBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
2612*35238bceSAndroid Build Coastguard Worker                          int height, int depth, int imageHeight, int rowLength, int skipImages, int skipRows,
2613*35238bceSAndroid Build Coastguard Worker                          int skipPixels, int alignment, int offset)
2614*35238bceSAndroid Build Coastguard Worker         : Texture3DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
2615*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2616*35238bceSAndroid Build Coastguard Worker         , m_imageHeight(imageHeight)
2617*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
2618*35238bceSAndroid Build Coastguard Worker         , m_skipImages(skipImages)
2619*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
2620*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
2621*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
2622*35238bceSAndroid Build Coastguard Worker         , m_offset(offset)
2623*35238bceSAndroid Build Coastguard Worker     {
2624*35238bceSAndroid Build Coastguard Worker     }
2625*35238bceSAndroid Build Coastguard Worker 
2626*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2627*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2628*35238bceSAndroid Build Coastguard Worker     {
2629*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2630*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
2631*35238bceSAndroid Build Coastguard Worker         int rowLength                   = m_rowLength > 0 ? m_rowLength : m_width;
2632*35238bceSAndroid Build Coastguard Worker         int rowPitch                    = deAlign32(rowLength * pixelSize, m_alignment);
2633*35238bceSAndroid Build Coastguard Worker         int imageHeight                 = m_imageHeight > 0 ? m_imageHeight : m_height;
2634*35238bceSAndroid Build Coastguard Worker         int slicePitch                  = imageHeight * rowPitch;
2635*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
2636*35238bceSAndroid Build Coastguard Worker         uint32_t buf                    = 0;
2637*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
2638*35238bceSAndroid Build Coastguard Worker 
2639*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
2640*35238bceSAndroid Build Coastguard Worker 
2641*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
2642*35238bceSAndroid Build Coastguard Worker         data.resize(slicePitch * (m_depth + m_skipImages) + m_offset);
2643*35238bceSAndroid Build Coastguard Worker         {
2644*35238bceSAndroid Build Coastguard Worker             Vec4 cScale = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
2645*35238bceSAndroid Build Coastguard Worker             Vec4 cBias  = m_texFormatInfo.valueMin;
2646*35238bceSAndroid Build Coastguard Worker             Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
2647*35238bceSAndroid Build Coastguard Worker             Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
2648*35238bceSAndroid Build Coastguard Worker 
2649*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch,
2650*35238bceSAndroid Build Coastguard Worker                                                      &data[0] + m_skipImages * slicePitch + m_skipRows * rowPitch +
2651*35238bceSAndroid Build Coastguard Worker                                                          m_skipPixels * pixelSize + m_offset),
2652*35238bceSAndroid Build Coastguard Worker                               4, colorA, colorB);
2653*35238bceSAndroid Build Coastguard Worker         }
2654*35238bceSAndroid Build Coastguard Worker 
2655*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &buf);
2656*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2657*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2658*35238bceSAndroid Build Coastguard Worker 
2659*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
2660*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2661*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
2662*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2663*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2664*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2665*35238bceSAndroid Build Coastguard Worker 
2666*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2667*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_3D, tex);
2668*35238bceSAndroid Build Coastguard Worker         glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format,
2669*35238bceSAndroid Build Coastguard Worker                      transferFmt.dataType, (const void *)(uintptr_t)m_offset);
2670*35238bceSAndroid Build Coastguard Worker     }
2671*35238bceSAndroid Build Coastguard Worker 
2672*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2673*35238bceSAndroid Build Coastguard Worker     int m_imageHeight;
2674*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
2675*35238bceSAndroid Build Coastguard Worker     int m_skipImages;
2676*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
2677*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
2678*35238bceSAndroid Build Coastguard Worker     int m_alignment;
2679*35238bceSAndroid Build Coastguard Worker     int m_offset;
2680*35238bceSAndroid Build Coastguard Worker };
2681*35238bceSAndroid Build Coastguard Worker 
2682*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() PBO case.
2683*35238bceSAndroid Build Coastguard Worker class TexSubImage2DBufferCase : public Texture2DSpecCase
2684*35238bceSAndroid Build Coastguard Worker {
2685*35238bceSAndroid Build Coastguard Worker public:
TexSubImage2DBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int subX,int subY,int subW,int subH,int rowLength,int skipRows,int skipPixels,int alignment,int offset)2686*35238bceSAndroid Build Coastguard Worker     TexSubImage2DBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
2687*35238bceSAndroid Build Coastguard Worker                             int height, int subX, int subY, int subW, int subH, int rowLength, int skipRows,
2688*35238bceSAndroid Build Coastguard Worker                             int skipPixels, int alignment, int offset)
2689*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
2690*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2691*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
2692*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
2693*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
2694*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
2695*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
2696*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
2697*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
2698*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
2699*35238bceSAndroid Build Coastguard Worker         , m_offset(offset)
2700*35238bceSAndroid Build Coastguard Worker     {
2701*35238bceSAndroid Build Coastguard Worker     }
2702*35238bceSAndroid Build Coastguard Worker 
2703*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2704*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2705*35238bceSAndroid Build Coastguard Worker     {
2706*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2707*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
2708*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
2709*35238bceSAndroid Build Coastguard Worker         uint32_t buf                    = 0;
2710*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
2711*35238bceSAndroid Build Coastguard Worker 
2712*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
2713*35238bceSAndroid Build Coastguard Worker 
2714*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2715*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
2716*35238bceSAndroid Build Coastguard Worker 
2717*35238bceSAndroid Build Coastguard Worker         // First fill texture with gradient.
2718*35238bceSAndroid Build Coastguard Worker         data.resize(deAlign32(m_width * pixelSize, 4) * m_height);
2719*35238bceSAndroid Build Coastguard Worker         tcu::fillWithComponentGradients(
2720*35238bceSAndroid Build Coastguard Worker             tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, deAlign32(m_width * pixelSize, 4), 0, &data[0]),
2721*35238bceSAndroid Build Coastguard Worker             m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2722*35238bceSAndroid Build Coastguard Worker         glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType,
2723*35238bceSAndroid Build Coastguard Worker                      &data[0]);
2724*35238bceSAndroid Build Coastguard Worker 
2725*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
2726*35238bceSAndroid Build Coastguard Worker         {
2727*35238bceSAndroid Build Coastguard Worker             int rowLength = m_rowLength > 0 ? m_rowLength : m_subW;
2728*35238bceSAndroid Build Coastguard Worker             int rowPitch  = deAlign32(rowLength * pixelSize, m_alignment);
2729*35238bceSAndroid Build Coastguard Worker             int height    = m_subH + m_skipRows;
2730*35238bceSAndroid Build Coastguard Worker             Vec4 cScale   = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
2731*35238bceSAndroid Build Coastguard Worker             Vec4 cBias    = m_texFormatInfo.valueMin;
2732*35238bceSAndroid Build Coastguard Worker             Vec4 colorA   = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
2733*35238bceSAndroid Build Coastguard Worker             Vec4 colorB   = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
2734*35238bceSAndroid Build Coastguard Worker 
2735*35238bceSAndroid Build Coastguard Worker             data.resize(rowPitch * height + m_offset);
2736*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(
2737*35238bceSAndroid Build Coastguard Worker                 tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0,
2738*35238bceSAndroid Build Coastguard Worker                                        &data[0] + m_skipRows * rowPitch + m_skipPixels * pixelSize + m_offset),
2739*35238bceSAndroid Build Coastguard Worker                 4, colorA, colorB);
2740*35238bceSAndroid Build Coastguard Worker         }
2741*35238bceSAndroid Build Coastguard Worker 
2742*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &buf);
2743*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2744*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2745*35238bceSAndroid Build Coastguard Worker 
2746*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2747*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2748*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2749*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2750*35238bceSAndroid Build Coastguard Worker         glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format, transferFmt.dataType,
2751*35238bceSAndroid Build Coastguard Worker                         (const void *)(uintptr_t)m_offset);
2752*35238bceSAndroid Build Coastguard Worker     }
2753*35238bceSAndroid Build Coastguard Worker 
2754*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2755*35238bceSAndroid Build Coastguard Worker     int m_subX;
2756*35238bceSAndroid Build Coastguard Worker     int m_subY;
2757*35238bceSAndroid Build Coastguard Worker     int m_subW;
2758*35238bceSAndroid Build Coastguard Worker     int m_subH;
2759*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
2760*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
2761*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
2762*35238bceSAndroid Build Coastguard Worker     int m_alignment;
2763*35238bceSAndroid Build Coastguard Worker     int m_offset;
2764*35238bceSAndroid Build Coastguard Worker };
2765*35238bceSAndroid Build Coastguard Worker 
2766*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() cubemap PBO case.
2767*35238bceSAndroid Build Coastguard Worker class TexSubImageCubeBufferCase : public TextureCubeSpecCase
2768*35238bceSAndroid Build Coastguard Worker {
2769*35238bceSAndroid Build Coastguard Worker public:
TexSubImageCubeBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int size,int subX,int subY,int subW,int subH,int rowLength,int skipRows,int skipPixels,int alignment,int offset)2770*35238bceSAndroid Build Coastguard Worker     TexSubImageCubeBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int size,
2771*35238bceSAndroid Build Coastguard Worker                               int subX, int subY, int subW, int subH, int rowLength, int skipRows, int skipPixels,
2772*35238bceSAndroid Build Coastguard Worker                               int alignment, int offset)
2773*35238bceSAndroid Build Coastguard Worker         : TextureCubeSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1)
2774*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2775*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
2776*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
2777*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
2778*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
2779*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
2780*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
2781*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
2782*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
2783*35238bceSAndroid Build Coastguard Worker         , m_offset(offset)
2784*35238bceSAndroid Build Coastguard Worker     {
2785*35238bceSAndroid Build Coastguard Worker     }
2786*35238bceSAndroid Build Coastguard Worker 
2787*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2788*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2789*35238bceSAndroid Build Coastguard Worker     {
2790*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
2791*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2792*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
2793*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
2794*35238bceSAndroid Build Coastguard Worker         uint32_t buf                    = 0;
2795*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
2796*35238bceSAndroid Build Coastguard Worker 
2797*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
2798*35238bceSAndroid Build Coastguard Worker 
2799*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2800*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
2801*35238bceSAndroid Build Coastguard Worker 
2802*35238bceSAndroid Build Coastguard Worker         // Fill faces with different gradients.
2803*35238bceSAndroid Build Coastguard Worker 
2804*35238bceSAndroid Build Coastguard Worker         data.resize(deAlign32(m_size * pixelSize, 4) * m_size);
2805*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2806*35238bceSAndroid Build Coastguard Worker 
2807*35238bceSAndroid Build Coastguard Worker         for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2808*35238bceSAndroid Build Coastguard Worker         {
2809*35238bceSAndroid Build Coastguard Worker             const Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2810*35238bceSAndroid Build Coastguard Worker             const Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2811*35238bceSAndroid Build Coastguard Worker 
2812*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(
2813*35238bceSAndroid Build Coastguard Worker                 tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, deAlign32(m_size * pixelSize, 4), 0, &data[0]),
2814*35238bceSAndroid Build Coastguard Worker                 gMin, gMax);
2815*35238bceSAndroid Build Coastguard Worker 
2816*35238bceSAndroid Build Coastguard Worker             glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, transferFmt.format,
2817*35238bceSAndroid Build Coastguard Worker                          transferFmt.dataType, &data[0]);
2818*35238bceSAndroid Build Coastguard Worker         }
2819*35238bceSAndroid Build Coastguard Worker 
2820*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
2821*35238bceSAndroid Build Coastguard Worker         {
2822*35238bceSAndroid Build Coastguard Worker             int rowLength = m_rowLength > 0 ? m_rowLength : m_subW;
2823*35238bceSAndroid Build Coastguard Worker             int rowPitch  = deAlign32(rowLength * pixelSize, m_alignment);
2824*35238bceSAndroid Build Coastguard Worker             int height    = m_subH + m_skipRows;
2825*35238bceSAndroid Build Coastguard Worker             Vec4 cScale   = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
2826*35238bceSAndroid Build Coastguard Worker             Vec4 cBias    = m_texFormatInfo.valueMin;
2827*35238bceSAndroid Build Coastguard Worker             Vec4 colorA   = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
2828*35238bceSAndroid Build Coastguard Worker             Vec4 colorB   = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
2829*35238bceSAndroid Build Coastguard Worker 
2830*35238bceSAndroid Build Coastguard Worker             data.resize(rowPitch * height + m_offset);
2831*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(
2832*35238bceSAndroid Build Coastguard Worker                 tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0,
2833*35238bceSAndroid Build Coastguard Worker                                        &data[0] + m_skipRows * rowPitch + m_skipPixels * pixelSize + m_offset),
2834*35238bceSAndroid Build Coastguard Worker                 4, colorA, colorB);
2835*35238bceSAndroid Build Coastguard Worker         }
2836*35238bceSAndroid Build Coastguard Worker 
2837*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &buf);
2838*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2839*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2840*35238bceSAndroid Build Coastguard Worker 
2841*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2842*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2843*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2844*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2845*35238bceSAndroid Build Coastguard Worker 
2846*35238bceSAndroid Build Coastguard Worker         for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
2847*35238bceSAndroid Build Coastguard Worker             glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format,
2848*35238bceSAndroid Build Coastguard Worker                             transferFmt.dataType, (const void *)(uintptr_t)m_offset);
2849*35238bceSAndroid Build Coastguard Worker     }
2850*35238bceSAndroid Build Coastguard Worker 
2851*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2852*35238bceSAndroid Build Coastguard Worker     int m_subX;
2853*35238bceSAndroid Build Coastguard Worker     int m_subY;
2854*35238bceSAndroid Build Coastguard Worker     int m_subW;
2855*35238bceSAndroid Build Coastguard Worker     int m_subH;
2856*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
2857*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
2858*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
2859*35238bceSAndroid Build Coastguard Worker     int m_alignment;
2860*35238bceSAndroid Build Coastguard Worker     int m_offset;
2861*35238bceSAndroid Build Coastguard Worker };
2862*35238bceSAndroid Build Coastguard Worker 
2863*35238bceSAndroid Build Coastguard Worker // TexSubImage3D() 2D array PBO case.
2864*35238bceSAndroid Build Coastguard Worker class TexSubImage2DArrayBufferCase : public Texture2DArraySpecCase
2865*35238bceSAndroid Build Coastguard Worker {
2866*35238bceSAndroid Build Coastguard Worker public:
TexSubImage2DArrayBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int depth,int subX,int subY,int subZ,int subW,int subH,int subD,int imageHeight,int rowLength,int skipImages,int skipRows,int skipPixels,int alignment,int offset)2867*35238bceSAndroid Build Coastguard Worker     TexSubImage2DArrayBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat,
2868*35238bceSAndroid Build Coastguard Worker                                  int width, int height, int depth, int subX, int subY, int subZ, int subW, int subH,
2869*35238bceSAndroid Build Coastguard Worker                                  int subD, int imageHeight, int rowLength, int skipImages, int skipRows, int skipPixels,
2870*35238bceSAndroid Build Coastguard Worker                                  int alignment, int offset)
2871*35238bceSAndroid Build Coastguard Worker         : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
2872*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
2873*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
2874*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
2875*35238bceSAndroid Build Coastguard Worker         , m_subZ(subZ)
2876*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
2877*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
2878*35238bceSAndroid Build Coastguard Worker         , m_subD(subD)
2879*35238bceSAndroid Build Coastguard Worker         , m_imageHeight(imageHeight)
2880*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
2881*35238bceSAndroid Build Coastguard Worker         , m_skipImages(skipImages)
2882*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
2883*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
2884*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
2885*35238bceSAndroid Build Coastguard Worker         , m_offset(offset)
2886*35238bceSAndroid Build Coastguard Worker     {
2887*35238bceSAndroid Build Coastguard Worker     }
2888*35238bceSAndroid Build Coastguard Worker 
2889*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2890*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2891*35238bceSAndroid Build Coastguard Worker     {
2892*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2893*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
2894*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
2895*35238bceSAndroid Build Coastguard Worker         uint32_t buf                    = 0;
2896*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
2897*35238bceSAndroid Build Coastguard Worker 
2898*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
2899*35238bceSAndroid Build Coastguard Worker 
2900*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
2901*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
2902*35238bceSAndroid Build Coastguard Worker 
2903*35238bceSAndroid Build Coastguard Worker         // Fill with gradient.
2904*35238bceSAndroid Build Coastguard Worker         {
2905*35238bceSAndroid Build Coastguard Worker             int rowPitch   = deAlign32(pixelSize * m_width, 4);
2906*35238bceSAndroid Build Coastguard Worker             int slicePitch = rowPitch * m_height;
2907*35238bceSAndroid Build Coastguard Worker 
2908*35238bceSAndroid Build Coastguard Worker             data.resize(slicePitch * m_numLayers);
2909*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(
2910*35238bceSAndroid Build Coastguard Worker                 tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_numLayers, rowPitch, slicePitch, &data[0]),
2911*35238bceSAndroid Build Coastguard Worker                 m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2912*35238bceSAndroid Build Coastguard Worker         }
2913*35238bceSAndroid Build Coastguard Worker 
2914*35238bceSAndroid Build Coastguard Worker         glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format,
2915*35238bceSAndroid Build Coastguard Worker                      transferFmt.dataType, &data[0]);
2916*35238bceSAndroid Build Coastguard Worker 
2917*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
2918*35238bceSAndroid Build Coastguard Worker         {
2919*35238bceSAndroid Build Coastguard Worker             int rowLength   = m_rowLength > 0 ? m_rowLength : m_subW;
2920*35238bceSAndroid Build Coastguard Worker             int rowPitch    = deAlign32(rowLength * pixelSize, m_alignment);
2921*35238bceSAndroid Build Coastguard Worker             int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_subH;
2922*35238bceSAndroid Build Coastguard Worker             int slicePitch  = imageHeight * rowPitch;
2923*35238bceSAndroid Build Coastguard Worker             Vec4 cScale     = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
2924*35238bceSAndroid Build Coastguard Worker             Vec4 cBias      = m_texFormatInfo.valueMin;
2925*35238bceSAndroid Build Coastguard Worker             Vec4 colorA     = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
2926*35238bceSAndroid Build Coastguard Worker             Vec4 colorB     = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
2927*35238bceSAndroid Build Coastguard Worker 
2928*35238bceSAndroid Build Coastguard Worker             data.resize(slicePitch * (m_numLayers + m_skipImages) + m_offset);
2929*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, m_subD, rowPitch, slicePitch,
2930*35238bceSAndroid Build Coastguard Worker                                                      &data[0] + m_skipImages * slicePitch + m_skipRows * rowPitch +
2931*35238bceSAndroid Build Coastguard Worker                                                          m_skipPixels * pixelSize + m_offset),
2932*35238bceSAndroid Build Coastguard Worker                               4, colorA, colorB);
2933*35238bceSAndroid Build Coastguard Worker         }
2934*35238bceSAndroid Build Coastguard Worker 
2935*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &buf);
2936*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2937*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2938*35238bceSAndroid Build Coastguard Worker 
2939*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
2940*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2941*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
2942*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2943*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2944*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2945*35238bceSAndroid Build Coastguard Worker         glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format,
2946*35238bceSAndroid Build Coastguard Worker                         transferFmt.dataType, (const void *)(intptr_t)m_offset);
2947*35238bceSAndroid Build Coastguard Worker     }
2948*35238bceSAndroid Build Coastguard Worker 
2949*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
2950*35238bceSAndroid Build Coastguard Worker     int m_subX;
2951*35238bceSAndroid Build Coastguard Worker     int m_subY;
2952*35238bceSAndroid Build Coastguard Worker     int m_subZ;
2953*35238bceSAndroid Build Coastguard Worker     int m_subW;
2954*35238bceSAndroid Build Coastguard Worker     int m_subH;
2955*35238bceSAndroid Build Coastguard Worker     int m_subD;
2956*35238bceSAndroid Build Coastguard Worker     int m_imageHeight;
2957*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
2958*35238bceSAndroid Build Coastguard Worker     int m_skipImages;
2959*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
2960*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
2961*35238bceSAndroid Build Coastguard Worker     int m_alignment;
2962*35238bceSAndroid Build Coastguard Worker     int m_offset;
2963*35238bceSAndroid Build Coastguard Worker };
2964*35238bceSAndroid Build Coastguard Worker 
2965*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() test case for PBO bounds.
2966*35238bceSAndroid Build Coastguard Worker class CopyTexFromPBOCase : public Texture2DSpecCase
2967*35238bceSAndroid Build Coastguard Worker {
2968*35238bceSAndroid Build Coastguard Worker public:
CopyTexFromPBOCase(Context & context,const char * name,const char * desc)2969*35238bceSAndroid Build Coastguard Worker     CopyTexFromPBOCase(Context &context, const char *name, const char *desc)
2970*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(GL_RGBA8), 4, 4, 1)
2971*35238bceSAndroid Build Coastguard Worker     {
2972*35238bceSAndroid Build Coastguard Worker     }
2973*35238bceSAndroid Build Coastguard Worker 
2974*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)2975*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
2976*35238bceSAndroid Build Coastguard Worker     {
2977*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2978*35238bceSAndroid Build Coastguard Worker 
2979*35238bceSAndroid Build Coastguard Worker         const glw::GLuint red   = 0xff0000ff; // alpha, blue, green, red
2980*35238bceSAndroid Build Coastguard Worker         const glw::GLuint green = 0xff00ff00;
2981*35238bceSAndroid Build Coastguard Worker         const glw::GLuint blue  = 0xffff0000;
2982*35238bceSAndroid Build Coastguard Worker         const glw::GLuint black = 0xff000000;
2983*35238bceSAndroid Build Coastguard Worker 
2984*35238bceSAndroid Build Coastguard Worker         glw::GLuint texId = 0;
2985*35238bceSAndroid Build Coastguard Worker         glw::GLuint fboId = 0;
2986*35238bceSAndroid Build Coastguard Worker         glw::GLuint pboId = 0;
2987*35238bceSAndroid Build Coastguard Worker 
2988*35238bceSAndroid Build Coastguard Worker         const uint32_t texWidth      = 4;
2989*35238bceSAndroid Build Coastguard Worker         const uint32_t texHeight     = 4;
2990*35238bceSAndroid Build Coastguard Worker         const uint32_t texSubWidth   = 2;
2991*35238bceSAndroid Build Coastguard Worker         const uint32_t texSubHeight  = 4;
2992*35238bceSAndroid Build Coastguard Worker         const uint32_t texSubOffsetX = 2;
2993*35238bceSAndroid Build Coastguard Worker         const uint32_t texSubOffsetY = 0;
2994*35238bceSAndroid Build Coastguard Worker 
2995*35238bceSAndroid Build Coastguard Worker         const uint32_t pboRowLength      = 4;
2996*35238bceSAndroid Build Coastguard Worker         const glw::GLuint pboOffset      = 2;
2997*35238bceSAndroid Build Coastguard Worker         const glw::GLintptr pboOffsetPtr = pboOffset * sizeof(glw::GLuint);
2998*35238bceSAndroid Build Coastguard Worker         const uint32_t halfWidth         = pboRowLength / 2;
2999*35238bceSAndroid Build Coastguard Worker 
3000*35238bceSAndroid Build Coastguard Worker         bool imageOk = true;
3001*35238bceSAndroid Build Coastguard Worker 
3002*35238bceSAndroid Build Coastguard Worker         glw::GLuint tex_data[texHeight][texWidth];
3003*35238bceSAndroid Build Coastguard Worker         glw::GLuint pixel_data[texHeight][texWidth];
3004*35238bceSAndroid Build Coastguard Worker         glw::GLuint color_data[texHeight][texWidth];
3005*35238bceSAndroid Build Coastguard Worker 
3006*35238bceSAndroid Build Coastguard Worker         // Fill pixel data.
3007*35238bceSAndroid Build Coastguard Worker         for (uint32_t row = 0; row < texHeight; row++)
3008*35238bceSAndroid Build Coastguard Worker         {
3009*35238bceSAndroid Build Coastguard Worker             for (uint32_t column = 0; column < texWidth; column++)
3010*35238bceSAndroid Build Coastguard Worker             {
3011*35238bceSAndroid Build Coastguard Worker                 tex_data[row][column] = red;
3012*35238bceSAndroid Build Coastguard Worker 
3013*35238bceSAndroid Build Coastguard Worker                 if (column < halfWidth)
3014*35238bceSAndroid Build Coastguard Worker                     pixel_data[row][column] = blue;
3015*35238bceSAndroid Build Coastguard Worker                 else
3016*35238bceSAndroid Build Coastguard Worker                     pixel_data[row][column] = green;
3017*35238bceSAndroid Build Coastguard Worker 
3018*35238bceSAndroid Build Coastguard Worker                 color_data[row][column] = black;
3019*35238bceSAndroid Build Coastguard Worker             }
3020*35238bceSAndroid Build Coastguard Worker         }
3021*35238bceSAndroid Build Coastguard Worker 
3022*35238bceSAndroid Build Coastguard Worker         // Create main texture.
3023*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &texId);
3024*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(glGetError(), "glGenTextures() failed");
3025*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, texId);
3026*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(glGetError(), "glBindTexture() failed");
3027*35238bceSAndroid Build Coastguard Worker         glTexImage2D(GL_TEXTURE_2D, 0, transferFmt.format, texWidth, texHeight, 0, transferFmt.format,
3028*35238bceSAndroid Build Coastguard Worker                      transferFmt.dataType, (void *)tex_data[0]);
3029*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(glGetError(), "glTexImage2D() failed");
3030*35238bceSAndroid Build Coastguard Worker 
3031*35238bceSAndroid Build Coastguard Worker         // Create pixel buffer object.
3032*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &pboId);
3033*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pboId);
3034*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(glGetError(), "glBindBuffer() failed");
3035*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, pboRowLength);
3036*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3037*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(glGetError(), "glPixelStorei() failed");
3038*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeof(pixel_data), (void *)pixel_data, GL_STREAM_DRAW);
3039*35238bceSAndroid Build Coastguard Worker 
3040*35238bceSAndroid Build Coastguard Worker         // The very last pixel of the PBO should be available for TexSubImage.
3041*35238bceSAndroid Build Coastguard Worker         glTexSubImage2D(GL_TEXTURE_2D, 0, texSubOffsetX, texSubOffsetY, texSubWidth, texSubHeight, transferFmt.format,
3042*35238bceSAndroid Build Coastguard Worker                         transferFmt.dataType, reinterpret_cast<void *>(pboOffsetPtr));
3043*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(glGetError(), "glTexSubImage2D() failed");
3044*35238bceSAndroid Build Coastguard Worker 
3045*35238bceSAndroid Build Coastguard Worker         // Create a framebuffer.
3046*35238bceSAndroid Build Coastguard Worker         glGenFramebuffers(1, &fboId);
3047*35238bceSAndroid Build Coastguard Worker         glBindFramebuffer(GL_FRAMEBUFFER, fboId);
3048*35238bceSAndroid Build Coastguard Worker         glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texId, 0);
3049*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(glGetError(), "glFramebufferTexture2D() failed");
3050*35238bceSAndroid Build Coastguard Worker 
3051*35238bceSAndroid Build Coastguard Worker         // Read pixels for pixel comparison.
3052*35238bceSAndroid Build Coastguard Worker         glReadPixels(0, 0, texWidth, texHeight, transferFmt.format, transferFmt.dataType, &color_data);
3053*35238bceSAndroid Build Coastguard Worker         GLU_EXPECT_NO_ERROR(glGetError(), "glReadPixels() failed");
3054*35238bceSAndroid Build Coastguard Worker 
3055*35238bceSAndroid Build Coastguard Worker         // Run pixel to pixel comparison tests to confirm all the stored data is there and correctly aligned.
3056*35238bceSAndroid Build Coastguard Worker         for (uint32_t row = 0; row < texSubHeight; row++)
3057*35238bceSAndroid Build Coastguard Worker         {
3058*35238bceSAndroid Build Coastguard Worker             for (uint32_t column = 0; column < pboOffset; column++)
3059*35238bceSAndroid Build Coastguard Worker             {
3060*35238bceSAndroid Build Coastguard Worker                 if (color_data[row][column] != tex_data[row][column])
3061*35238bceSAndroid Build Coastguard Worker                     imageOk = false;
3062*35238bceSAndroid Build Coastguard Worker             }
3063*35238bceSAndroid Build Coastguard Worker         }
3064*35238bceSAndroid Build Coastguard Worker 
3065*35238bceSAndroid Build Coastguard Worker         if (!imageOk)
3066*35238bceSAndroid Build Coastguard Worker             TCU_FAIL("Color data versus texture data comparison failed.");
3067*35238bceSAndroid Build Coastguard Worker 
3068*35238bceSAndroid Build Coastguard Worker         for (uint32_t row = texSubOffsetY; row < texSubHeight; row++)
3069*35238bceSAndroid Build Coastguard Worker         {
3070*35238bceSAndroid Build Coastguard Worker             for (uint32_t column = 0; column < texSubWidth; column++)
3071*35238bceSAndroid Build Coastguard Worker             {
3072*35238bceSAndroid Build Coastguard Worker                 if (color_data[row][column + texSubWidth] != pixel_data[row][column + pboOffset])
3073*35238bceSAndroid Build Coastguard Worker                     imageOk = false;
3074*35238bceSAndroid Build Coastguard Worker             }
3075*35238bceSAndroid Build Coastguard Worker         }
3076*35238bceSAndroid Build Coastguard Worker 
3077*35238bceSAndroid Build Coastguard Worker         if (!imageOk)
3078*35238bceSAndroid Build Coastguard Worker             TCU_FAIL("Color data versus pixel data comparison failed.");
3079*35238bceSAndroid Build Coastguard Worker 
3080*35238bceSAndroid Build Coastguard Worker         // Cleanup
3081*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
3082*35238bceSAndroid Build Coastguard Worker         glDeleteBuffers(1, &pboId);
3083*35238bceSAndroid Build Coastguard Worker     }
3084*35238bceSAndroid Build Coastguard Worker };
3085*35238bceSAndroid Build Coastguard Worker 
3086*35238bceSAndroid Build Coastguard Worker // TexSubImage3D() PBO case.
3087*35238bceSAndroid Build Coastguard Worker class TexSubImage3DBufferCase : public Texture3DSpecCase
3088*35238bceSAndroid Build Coastguard Worker {
3089*35238bceSAndroid Build Coastguard Worker public:
TexSubImage3DBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int width,int height,int depth,int subX,int subY,int subZ,int subW,int subH,int subD,int imageHeight,int rowLength,int skipImages,int skipRows,int skipPixels,int alignment,int offset)3090*35238bceSAndroid Build Coastguard Worker     TexSubImage3DBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int width,
3091*35238bceSAndroid Build Coastguard Worker                             int height, int depth, int subX, int subY, int subZ, int subW, int subH, int subD,
3092*35238bceSAndroid Build Coastguard Worker                             int imageHeight, int rowLength, int skipImages, int skipRows, int skipPixels, int alignment,
3093*35238bceSAndroid Build Coastguard Worker                             int offset)
3094*35238bceSAndroid Build Coastguard Worker         : Texture3DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
3095*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
3096*35238bceSAndroid Build Coastguard Worker         , m_subX(subX)
3097*35238bceSAndroid Build Coastguard Worker         , m_subY(subY)
3098*35238bceSAndroid Build Coastguard Worker         , m_subZ(subZ)
3099*35238bceSAndroid Build Coastguard Worker         , m_subW(subW)
3100*35238bceSAndroid Build Coastguard Worker         , m_subH(subH)
3101*35238bceSAndroid Build Coastguard Worker         , m_subD(subD)
3102*35238bceSAndroid Build Coastguard Worker         , m_imageHeight(imageHeight)
3103*35238bceSAndroid Build Coastguard Worker         , m_rowLength(rowLength)
3104*35238bceSAndroid Build Coastguard Worker         , m_skipImages(skipImages)
3105*35238bceSAndroid Build Coastguard Worker         , m_skipRows(skipRows)
3106*35238bceSAndroid Build Coastguard Worker         , m_skipPixels(skipPixels)
3107*35238bceSAndroid Build Coastguard Worker         , m_alignment(alignment)
3108*35238bceSAndroid Build Coastguard Worker         , m_offset(offset)
3109*35238bceSAndroid Build Coastguard Worker     {
3110*35238bceSAndroid Build Coastguard Worker     }
3111*35238bceSAndroid Build Coastguard Worker 
3112*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)3113*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
3114*35238bceSAndroid Build Coastguard Worker     {
3115*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
3116*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
3117*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
3118*35238bceSAndroid Build Coastguard Worker         uint32_t buf                    = 0;
3119*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
3120*35238bceSAndroid Build Coastguard Worker 
3121*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
3122*35238bceSAndroid Build Coastguard Worker 
3123*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
3124*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_3D, tex);
3125*35238bceSAndroid Build Coastguard Worker 
3126*35238bceSAndroid Build Coastguard Worker         // Fill with gradient.
3127*35238bceSAndroid Build Coastguard Worker         {
3128*35238bceSAndroid Build Coastguard Worker             int rowPitch   = deAlign32(pixelSize * m_width, 4);
3129*35238bceSAndroid Build Coastguard Worker             int slicePitch = rowPitch * m_height;
3130*35238bceSAndroid Build Coastguard Worker 
3131*35238bceSAndroid Build Coastguard Worker             data.resize(slicePitch * m_depth);
3132*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(
3133*35238bceSAndroid Build Coastguard Worker                 tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0]),
3134*35238bceSAndroid Build Coastguard Worker                 m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
3135*35238bceSAndroid Build Coastguard Worker         }
3136*35238bceSAndroid Build Coastguard Worker 
3137*35238bceSAndroid Build Coastguard Worker         glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format,
3138*35238bceSAndroid Build Coastguard Worker                      transferFmt.dataType, &data[0]);
3139*35238bceSAndroid Build Coastguard Worker 
3140*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
3141*35238bceSAndroid Build Coastguard Worker         {
3142*35238bceSAndroid Build Coastguard Worker             int rowLength   = m_rowLength > 0 ? m_rowLength : m_subW;
3143*35238bceSAndroid Build Coastguard Worker             int rowPitch    = deAlign32(rowLength * pixelSize, m_alignment);
3144*35238bceSAndroid Build Coastguard Worker             int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_subH;
3145*35238bceSAndroid Build Coastguard Worker             int slicePitch  = imageHeight * rowPitch;
3146*35238bceSAndroid Build Coastguard Worker             Vec4 cScale     = m_texFormatInfo.valueMax - m_texFormatInfo.valueMin;
3147*35238bceSAndroid Build Coastguard Worker             Vec4 cBias      = m_texFormatInfo.valueMin;
3148*35238bceSAndroid Build Coastguard Worker             Vec4 colorA     = Vec4(1.0f, 0.0f, 0.0f, 1.0f) * cScale + cBias;
3149*35238bceSAndroid Build Coastguard Worker             Vec4 colorB     = Vec4(0.0f, 1.0f, 0.0f, 1.0f) * cScale + cBias;
3150*35238bceSAndroid Build Coastguard Worker 
3151*35238bceSAndroid Build Coastguard Worker             data.resize(slicePitch * (m_depth + m_skipImages) + m_offset);
3152*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, m_subD, rowPitch, slicePitch,
3153*35238bceSAndroid Build Coastguard Worker                                                      &data[0] + m_skipImages * slicePitch + m_skipRows * rowPitch +
3154*35238bceSAndroid Build Coastguard Worker                                                          m_skipPixels * pixelSize + m_offset),
3155*35238bceSAndroid Build Coastguard Worker                               4, colorA, colorB);
3156*35238bceSAndroid Build Coastguard Worker         }
3157*35238bceSAndroid Build Coastguard Worker 
3158*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &buf);
3159*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
3160*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
3161*35238bceSAndroid Build Coastguard Worker 
3162*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
3163*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
3164*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
3165*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
3166*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
3167*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
3168*35238bceSAndroid Build Coastguard Worker         glTexSubImage3D(GL_TEXTURE_3D, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format,
3169*35238bceSAndroid Build Coastguard Worker                         transferFmt.dataType, (const void *)(intptr_t)m_offset);
3170*35238bceSAndroid Build Coastguard Worker     }
3171*35238bceSAndroid Build Coastguard Worker 
3172*35238bceSAndroid Build Coastguard Worker     uint32_t m_internalFormat;
3173*35238bceSAndroid Build Coastguard Worker     int m_subX;
3174*35238bceSAndroid Build Coastguard Worker     int m_subY;
3175*35238bceSAndroid Build Coastguard Worker     int m_subZ;
3176*35238bceSAndroid Build Coastguard Worker     int m_subW;
3177*35238bceSAndroid Build Coastguard Worker     int m_subH;
3178*35238bceSAndroid Build Coastguard Worker     int m_subD;
3179*35238bceSAndroid Build Coastguard Worker     int m_imageHeight;
3180*35238bceSAndroid Build Coastguard Worker     int m_rowLength;
3181*35238bceSAndroid Build Coastguard Worker     int m_skipImages;
3182*35238bceSAndroid Build Coastguard Worker     int m_skipRows;
3183*35238bceSAndroid Build Coastguard Worker     int m_skipPixels;
3184*35238bceSAndroid Build Coastguard Worker     int m_alignment;
3185*35238bceSAndroid Build Coastguard Worker     int m_offset;
3186*35238bceSAndroid Build Coastguard Worker };
3187*35238bceSAndroid Build Coastguard Worker 
3188*35238bceSAndroid Build Coastguard Worker // TexImage2D() depth case.
3189*35238bceSAndroid Build Coastguard Worker class TexImage2DDepthCase : public Texture2DSpecCase
3190*35238bceSAndroid Build Coastguard Worker {
3191*35238bceSAndroid Build Coastguard Worker public:
TexImage2DDepthCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int imageWidth,int imageHeight)3192*35238bceSAndroid Build Coastguard Worker     TexImage2DDepthCase(Context &context, const char *name, const char *desc, uint32_t internalFormat, int imageWidth,
3193*35238bceSAndroid Build Coastguard Worker                         int imageHeight)
3194*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight,
3195*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(imageWidth, imageHeight))
3196*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
3197*35238bceSAndroid Build Coastguard Worker     {
3198*35238bceSAndroid Build Coastguard Worker         // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3199*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupBias  = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3200*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3201*35238bceSAndroid Build Coastguard Worker     }
3202*35238bceSAndroid Build Coastguard Worker 
createTexture(void)3203*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
3204*35238bceSAndroid Build Coastguard Worker     {
3205*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
3206*35238bceSAndroid Build Coastguard Worker         uint32_t tex            = 0;
3207*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(fmt.format, fmt.dataType));
3208*35238bceSAndroid Build Coastguard Worker 
3209*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
3210*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
3211*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3212*35238bceSAndroid Build Coastguard Worker         GLU_CHECK();
3213*35238bceSAndroid Build Coastguard Worker 
3214*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
3215*35238bceSAndroid Build Coastguard Worker         {
3216*35238bceSAndroid Build Coastguard Worker             const int levelW = de::max(1, m_width >> ndx);
3217*35238bceSAndroid Build Coastguard Worker             const int levelH = de::max(1, m_height >> ndx);
3218*35238bceSAndroid Build Coastguard Worker             const Vec4 gMin  = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3219*35238bceSAndroid Build Coastguard Worker             const Vec4 gMax  = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3220*35238bceSAndroid Build Coastguard Worker 
3221*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH);
3222*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3223*35238bceSAndroid Build Coastguard Worker 
3224*35238bceSAndroid Build Coastguard Worker             glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, fmt.format, fmt.dataType,
3225*35238bceSAndroid Build Coastguard Worker                          levelData.getAccess().getDataPtr());
3226*35238bceSAndroid Build Coastguard Worker         }
3227*35238bceSAndroid Build Coastguard Worker     }
3228*35238bceSAndroid Build Coastguard Worker 
3229*35238bceSAndroid Build Coastguard Worker     const uint32_t m_internalFormat;
3230*35238bceSAndroid Build Coastguard Worker };
3231*35238bceSAndroid Build Coastguard Worker 
3232*35238bceSAndroid Build Coastguard Worker // TexImage3D() depth case.
3233*35238bceSAndroid Build Coastguard Worker class TexImage2DArrayDepthCase : public Texture2DArraySpecCase
3234*35238bceSAndroid Build Coastguard Worker {
3235*35238bceSAndroid Build Coastguard Worker public:
TexImage2DArrayDepthCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int imageWidth,int imageHeight,int numLayers)3236*35238bceSAndroid Build Coastguard Worker     TexImage2DArrayDepthCase(Context &context, const char *name, const char *desc, uint32_t internalFormat,
3237*35238bceSAndroid Build Coastguard Worker                              int imageWidth, int imageHeight, int numLayers)
3238*35238bceSAndroid Build Coastguard Worker         : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight,
3239*35238bceSAndroid Build Coastguard Worker                                  numLayers, maxLevelCount(imageWidth, imageHeight))
3240*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
3241*35238bceSAndroid Build Coastguard Worker     {
3242*35238bceSAndroid Build Coastguard Worker         // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3243*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupBias  = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3244*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3245*35238bceSAndroid Build Coastguard Worker     }
3246*35238bceSAndroid Build Coastguard Worker 
createTexture(void)3247*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
3248*35238bceSAndroid Build Coastguard Worker     {
3249*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
3250*35238bceSAndroid Build Coastguard Worker         uint32_t tex            = 0;
3251*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(fmt.format, fmt.dataType));
3252*35238bceSAndroid Build Coastguard Worker 
3253*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
3254*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
3255*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3256*35238bceSAndroid Build Coastguard Worker         GLU_CHECK();
3257*35238bceSAndroid Build Coastguard Worker 
3258*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
3259*35238bceSAndroid Build Coastguard Worker         {
3260*35238bceSAndroid Build Coastguard Worker             const int levelW = de::max(1, m_width >> ndx);
3261*35238bceSAndroid Build Coastguard Worker             const int levelH = de::max(1, m_height >> ndx);
3262*35238bceSAndroid Build Coastguard Worker             const Vec4 gMin  = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3263*35238bceSAndroid Build Coastguard Worker             const Vec4 gMax  = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3264*35238bceSAndroid Build Coastguard Worker 
3265*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH, m_numLayers);
3266*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3267*35238bceSAndroid Build Coastguard Worker 
3268*35238bceSAndroid Build Coastguard Worker             glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, fmt.format,
3269*35238bceSAndroid Build Coastguard Worker                          fmt.dataType, levelData.getAccess().getDataPtr());
3270*35238bceSAndroid Build Coastguard Worker         }
3271*35238bceSAndroid Build Coastguard Worker     }
3272*35238bceSAndroid Build Coastguard Worker 
3273*35238bceSAndroid Build Coastguard Worker     const uint32_t m_internalFormat;
3274*35238bceSAndroid Build Coastguard Worker };
3275*35238bceSAndroid Build Coastguard Worker 
3276*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() depth case.
3277*35238bceSAndroid Build Coastguard Worker class TexSubImage2DDepthCase : public Texture2DSpecCase
3278*35238bceSAndroid Build Coastguard Worker {
3279*35238bceSAndroid Build Coastguard Worker public:
TexSubImage2DDepthCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int imageWidth,int imageHeight)3280*35238bceSAndroid Build Coastguard Worker     TexSubImage2DDepthCase(Context &context, const char *name, const char *desc, uint32_t internalFormat,
3281*35238bceSAndroid Build Coastguard Worker                            int imageWidth, int imageHeight)
3282*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight,
3283*35238bceSAndroid Build Coastguard Worker                             maxLevelCount(imageWidth, imageHeight))
3284*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
3285*35238bceSAndroid Build Coastguard Worker     {
3286*35238bceSAndroid Build Coastguard Worker         // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3287*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupBias  = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3288*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3289*35238bceSAndroid Build Coastguard Worker     }
3290*35238bceSAndroid Build Coastguard Worker 
createTexture(void)3291*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
3292*35238bceSAndroid Build Coastguard Worker     {
3293*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
3294*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
3295*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
3296*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(fmt.format, fmt.dataType));
3297*35238bceSAndroid Build Coastguard Worker 
3298*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
3299*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
3300*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3301*35238bceSAndroid Build Coastguard Worker         GLU_CHECK();
3302*35238bceSAndroid Build Coastguard Worker 
3303*35238bceSAndroid Build Coastguard Worker         // First specify full texture.
3304*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
3305*35238bceSAndroid Build Coastguard Worker         {
3306*35238bceSAndroid Build Coastguard Worker             const int levelW = de::max(1, m_width >> ndx);
3307*35238bceSAndroid Build Coastguard Worker             const int levelH = de::max(1, m_height >> ndx);
3308*35238bceSAndroid Build Coastguard Worker             const Vec4 gMin  = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3309*35238bceSAndroid Build Coastguard Worker             const Vec4 gMax  = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3310*35238bceSAndroid Build Coastguard Worker 
3311*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH);
3312*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3313*35238bceSAndroid Build Coastguard Worker 
3314*35238bceSAndroid Build Coastguard Worker             glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, fmt.format, fmt.dataType,
3315*35238bceSAndroid Build Coastguard Worker                          levelData.getAccess().getDataPtr());
3316*35238bceSAndroid Build Coastguard Worker         }
3317*35238bceSAndroid Build Coastguard Worker 
3318*35238bceSAndroid Build Coastguard Worker         // Re-specify parts of each level.
3319*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
3320*35238bceSAndroid Build Coastguard Worker         {
3321*35238bceSAndroid Build Coastguard Worker             const int levelW = de::max(1, m_width >> ndx);
3322*35238bceSAndroid Build Coastguard Worker             const int levelH = de::max(1, m_height >> ndx);
3323*35238bceSAndroid Build Coastguard Worker 
3324*35238bceSAndroid Build Coastguard Worker             const int w = rnd.getInt(1, levelW);
3325*35238bceSAndroid Build Coastguard Worker             const int h = rnd.getInt(1, levelH);
3326*35238bceSAndroid Build Coastguard Worker             const int x = rnd.getInt(0, levelW - w);
3327*35238bceSAndroid Build Coastguard Worker             const int y = rnd.getInt(0, levelH - h);
3328*35238bceSAndroid Build Coastguard Worker 
3329*35238bceSAndroid Build Coastguard Worker             const Vec4 colorA  = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3330*35238bceSAndroid Build Coastguard Worker             const Vec4 colorB  = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3331*35238bceSAndroid Build Coastguard Worker             const int cellSize = rnd.getInt(2, 16);
3332*35238bceSAndroid Build Coastguard Worker 
3333*35238bceSAndroid Build Coastguard Worker             levelData.setSize(w, h);
3334*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(levelData.getAccess(), cellSize, colorA, colorB);
3335*35238bceSAndroid Build Coastguard Worker 
3336*35238bceSAndroid Build Coastguard Worker             glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, fmt.format, fmt.dataType,
3337*35238bceSAndroid Build Coastguard Worker                             levelData.getAccess().getDataPtr());
3338*35238bceSAndroid Build Coastguard Worker         }
3339*35238bceSAndroid Build Coastguard Worker     }
3340*35238bceSAndroid Build Coastguard Worker 
3341*35238bceSAndroid Build Coastguard Worker     const uint32_t m_internalFormat;
3342*35238bceSAndroid Build Coastguard Worker };
3343*35238bceSAndroid Build Coastguard Worker 
3344*35238bceSAndroid Build Coastguard Worker // TexSubImage3D() depth case.
3345*35238bceSAndroid Build Coastguard Worker class TexSubImage2DArrayDepthCase : public Texture2DArraySpecCase
3346*35238bceSAndroid Build Coastguard Worker {
3347*35238bceSAndroid Build Coastguard Worker public:
TexSubImage2DArrayDepthCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int imageWidth,int imageHeight,int numLayers)3348*35238bceSAndroid Build Coastguard Worker     TexSubImage2DArrayDepthCase(Context &context, const char *name, const char *desc, uint32_t internalFormat,
3349*35238bceSAndroid Build Coastguard Worker                                 int imageWidth, int imageHeight, int numLayers)
3350*35238bceSAndroid Build Coastguard Worker         : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight,
3351*35238bceSAndroid Build Coastguard Worker                                  numLayers, maxLevelCount(imageWidth, imageHeight))
3352*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
3353*35238bceSAndroid Build Coastguard Worker     {
3354*35238bceSAndroid Build Coastguard Worker         // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3355*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupBias  = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3356*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3357*35238bceSAndroid Build Coastguard Worker     }
3358*35238bceSAndroid Build Coastguard Worker 
createTexture(void)3359*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
3360*35238bceSAndroid Build Coastguard Worker     {
3361*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
3362*35238bceSAndroid Build Coastguard Worker         de::Random rnd(deStringHash(getName()));
3363*35238bceSAndroid Build Coastguard Worker         uint32_t tex = 0;
3364*35238bceSAndroid Build Coastguard Worker         tcu::TextureLevel levelData(glu::mapGLTransferFormat(fmt.format, fmt.dataType));
3365*35238bceSAndroid Build Coastguard Worker 
3366*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
3367*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
3368*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3369*35238bceSAndroid Build Coastguard Worker         GLU_CHECK();
3370*35238bceSAndroid Build Coastguard Worker 
3371*35238bceSAndroid Build Coastguard Worker         // First specify full texture.
3372*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
3373*35238bceSAndroid Build Coastguard Worker         {
3374*35238bceSAndroid Build Coastguard Worker             const int levelW = de::max(1, m_width >> ndx);
3375*35238bceSAndroid Build Coastguard Worker             const int levelH = de::max(1, m_height >> ndx);
3376*35238bceSAndroid Build Coastguard Worker             const Vec4 gMin  = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3377*35238bceSAndroid Build Coastguard Worker             const Vec4 gMax  = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3378*35238bceSAndroid Build Coastguard Worker 
3379*35238bceSAndroid Build Coastguard Worker             levelData.setSize(levelW, levelH, m_numLayers);
3380*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3381*35238bceSAndroid Build Coastguard Worker 
3382*35238bceSAndroid Build Coastguard Worker             glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, fmt.format,
3383*35238bceSAndroid Build Coastguard Worker                          fmt.dataType, levelData.getAccess().getDataPtr());
3384*35238bceSAndroid Build Coastguard Worker         }
3385*35238bceSAndroid Build Coastguard Worker 
3386*35238bceSAndroid Build Coastguard Worker         // Re-specify parts of each level.
3387*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < m_numLevels; ndx++)
3388*35238bceSAndroid Build Coastguard Worker         {
3389*35238bceSAndroid Build Coastguard Worker             const int levelW = de::max(1, m_width >> ndx);
3390*35238bceSAndroid Build Coastguard Worker             const int levelH = de::max(1, m_height >> ndx);
3391*35238bceSAndroid Build Coastguard Worker 
3392*35238bceSAndroid Build Coastguard Worker             const int w = rnd.getInt(1, levelW);
3393*35238bceSAndroid Build Coastguard Worker             const int h = rnd.getInt(1, levelH);
3394*35238bceSAndroid Build Coastguard Worker             const int d = rnd.getInt(1, m_numLayers);
3395*35238bceSAndroid Build Coastguard Worker             const int x = rnd.getInt(0, levelW - w);
3396*35238bceSAndroid Build Coastguard Worker             const int y = rnd.getInt(0, levelH - h);
3397*35238bceSAndroid Build Coastguard Worker             const int z = rnd.getInt(0, m_numLayers - d);
3398*35238bceSAndroid Build Coastguard Worker 
3399*35238bceSAndroid Build Coastguard Worker             const Vec4 colorA  = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3400*35238bceSAndroid Build Coastguard Worker             const Vec4 colorB  = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3401*35238bceSAndroid Build Coastguard Worker             const int cellSize = rnd.getInt(2, 16);
3402*35238bceSAndroid Build Coastguard Worker 
3403*35238bceSAndroid Build Coastguard Worker             levelData.setSize(w, h, d);
3404*35238bceSAndroid Build Coastguard Worker             tcu::fillWithGrid(levelData.getAccess(), cellSize, colorA, colorB);
3405*35238bceSAndroid Build Coastguard Worker 
3406*35238bceSAndroid Build Coastguard Worker             glTexSubImage3D(GL_TEXTURE_2D_ARRAY, ndx, x, y, z, w, h, d, fmt.format, fmt.dataType,
3407*35238bceSAndroid Build Coastguard Worker                             levelData.getAccess().getDataPtr());
3408*35238bceSAndroid Build Coastguard Worker         }
3409*35238bceSAndroid Build Coastguard Worker     }
3410*35238bceSAndroid Build Coastguard Worker 
3411*35238bceSAndroid Build Coastguard Worker     const uint32_t m_internalFormat;
3412*35238bceSAndroid Build Coastguard Worker };
3413*35238bceSAndroid Build Coastguard Worker 
3414*35238bceSAndroid Build Coastguard Worker // TexImage2D() depth case with pbo.
3415*35238bceSAndroid Build Coastguard Worker class TexImage2DDepthBufferCase : public Texture2DSpecCase
3416*35238bceSAndroid Build Coastguard Worker {
3417*35238bceSAndroid Build Coastguard Worker public:
TexImage2DDepthBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int imageWidth,int imageHeight)3418*35238bceSAndroid Build Coastguard Worker     TexImage2DDepthBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat,
3419*35238bceSAndroid Build Coastguard Worker                               int imageWidth, int imageHeight)
3420*35238bceSAndroid Build Coastguard Worker         : Texture2DSpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, 1)
3421*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
3422*35238bceSAndroid Build Coastguard Worker     {
3423*35238bceSAndroid Build Coastguard Worker         // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3424*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupBias  = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3425*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3426*35238bceSAndroid Build Coastguard Worker     }
3427*35238bceSAndroid Build Coastguard Worker 
createTexture(void)3428*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
3429*35238bceSAndroid Build Coastguard Worker     {
3430*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
3431*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
3432*35238bceSAndroid Build Coastguard Worker         int rowLength                   = m_width;
3433*35238bceSAndroid Build Coastguard Worker         int alignment                   = 4;
3434*35238bceSAndroid Build Coastguard Worker         int rowPitch                    = deAlign32(rowLength * pixelSize, alignment);
3435*35238bceSAndroid Build Coastguard Worker         int height                      = m_height;
3436*35238bceSAndroid Build Coastguard Worker         uint32_t buf                    = 0;
3437*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
3438*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
3439*35238bceSAndroid Build Coastguard Worker 
3440*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
3441*35238bceSAndroid Build Coastguard Worker 
3442*35238bceSAndroid Build Coastguard Worker         // Fill data with gradient
3443*35238bceSAndroid Build Coastguard Worker         data.resize(rowPitch * height);
3444*35238bceSAndroid Build Coastguard Worker         {
3445*35238bceSAndroid Build Coastguard Worker             const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3446*35238bceSAndroid Build Coastguard Worker             const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3447*35238bceSAndroid Build Coastguard Worker 
3448*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(
3449*35238bceSAndroid Build Coastguard Worker                 tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0, &data[0]), gMin, gMax);
3450*35238bceSAndroid Build Coastguard Worker         }
3451*35238bceSAndroid Build Coastguard Worker 
3452*35238bceSAndroid Build Coastguard Worker         // Create buffer and upload.
3453*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &buf);
3454*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
3455*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
3456*35238bceSAndroid Build Coastguard Worker 
3457*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, rowLength);
3458*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
3459*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
3460*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
3461*35238bceSAndroid Build Coastguard Worker 
3462*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
3463*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D, tex);
3464*35238bceSAndroid Build Coastguard Worker         glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType,
3465*35238bceSAndroid Build Coastguard Worker                      DE_NULL);
3466*35238bceSAndroid Build Coastguard Worker         glDeleteBuffers(1, &buf);
3467*35238bceSAndroid Build Coastguard Worker     }
3468*35238bceSAndroid Build Coastguard Worker 
3469*35238bceSAndroid Build Coastguard Worker     const uint32_t m_internalFormat;
3470*35238bceSAndroid Build Coastguard Worker };
3471*35238bceSAndroid Build Coastguard Worker 
3472*35238bceSAndroid Build Coastguard Worker // TexImage3D() depth case with pbo.
3473*35238bceSAndroid Build Coastguard Worker class TexImage2DArrayDepthBufferCase : public Texture2DArraySpecCase
3474*35238bceSAndroid Build Coastguard Worker {
3475*35238bceSAndroid Build Coastguard Worker public:
TexImage2DArrayDepthBufferCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,int imageWidth,int imageHeight,int numLayers)3476*35238bceSAndroid Build Coastguard Worker     TexImage2DArrayDepthBufferCase(Context &context, const char *name, const char *desc, uint32_t internalFormat,
3477*35238bceSAndroid Build Coastguard Worker                                    int imageWidth, int imageHeight, int numLayers)
3478*35238bceSAndroid Build Coastguard Worker         : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight,
3479*35238bceSAndroid Build Coastguard Worker                                  numLayers, 1)
3480*35238bceSAndroid Build Coastguard Worker         , m_internalFormat(internalFormat)
3481*35238bceSAndroid Build Coastguard Worker     {
3482*35238bceSAndroid Build Coastguard Worker         // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3483*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupBias  = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3484*35238bceSAndroid Build Coastguard Worker         m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3485*35238bceSAndroid Build Coastguard Worker     }
3486*35238bceSAndroid Build Coastguard Worker 
createTexture(void)3487*35238bceSAndroid Build Coastguard Worker     void createTexture(void)
3488*35238bceSAndroid Build Coastguard Worker     {
3489*35238bceSAndroid Build Coastguard Worker         glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
3490*35238bceSAndroid Build Coastguard Worker         int pixelSize                   = m_texFormat.getPixelSize();
3491*35238bceSAndroid Build Coastguard Worker         int rowLength                   = m_width;
3492*35238bceSAndroid Build Coastguard Worker         int alignment                   = 4;
3493*35238bceSAndroid Build Coastguard Worker         int rowPitch                    = deAlign32(rowLength * pixelSize, alignment);
3494*35238bceSAndroid Build Coastguard Worker         int imageHeight                 = m_height;
3495*35238bceSAndroid Build Coastguard Worker         int slicePitch                  = imageHeight * rowPitch;
3496*35238bceSAndroid Build Coastguard Worker         uint32_t tex                    = 0;
3497*35238bceSAndroid Build Coastguard Worker         uint32_t buf                    = 0;
3498*35238bceSAndroid Build Coastguard Worker         vector<uint8_t> data;
3499*35238bceSAndroid Build Coastguard Worker 
3500*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_numLevels == 1);
3501*35238bceSAndroid Build Coastguard Worker 
3502*35238bceSAndroid Build Coastguard Worker         // Fill data with grid.
3503*35238bceSAndroid Build Coastguard Worker         data.resize(slicePitch * m_numLayers);
3504*35238bceSAndroid Build Coastguard Worker         {
3505*35238bceSAndroid Build Coastguard Worker             const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3506*35238bceSAndroid Build Coastguard Worker             const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3507*35238bceSAndroid Build Coastguard Worker 
3508*35238bceSAndroid Build Coastguard Worker             tcu::fillWithComponentGradients(
3509*35238bceSAndroid Build Coastguard Worker                 tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_numLayers, rowPitch, slicePitch, &data[0]),
3510*35238bceSAndroid Build Coastguard Worker                 gMin, gMax);
3511*35238bceSAndroid Build Coastguard Worker         }
3512*35238bceSAndroid Build Coastguard Worker 
3513*35238bceSAndroid Build Coastguard Worker         glGenBuffers(1, &buf);
3514*35238bceSAndroid Build Coastguard Worker         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
3515*35238bceSAndroid Build Coastguard Worker         glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
3516*35238bceSAndroid Build Coastguard Worker 
3517*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, imageHeight);
3518*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ROW_LENGTH, rowLength);
3519*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0);
3520*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
3521*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
3522*35238bceSAndroid Build Coastguard Worker         glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
3523*35238bceSAndroid Build Coastguard Worker 
3524*35238bceSAndroid Build Coastguard Worker         glGenTextures(1, &tex);
3525*35238bceSAndroid Build Coastguard Worker         glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
3526*35238bceSAndroid Build Coastguard Worker         glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format,
3527*35238bceSAndroid Build Coastguard Worker                      transferFmt.dataType, DE_NULL);
3528*35238bceSAndroid Build Coastguard Worker         glDeleteBuffers(1, &buf);
3529*35238bceSAndroid Build Coastguard Worker     }
3530*35238bceSAndroid Build Coastguard Worker 
3531*35238bceSAndroid Build Coastguard Worker     const uint32_t m_internalFormat;
3532*35238bceSAndroid Build Coastguard Worker };
3533*35238bceSAndroid Build Coastguard Worker 
TextureSpecificationTests(Context & context)3534*35238bceSAndroid Build Coastguard Worker TextureSpecificationTests::TextureSpecificationTests(Context &context)
3535*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(context, "specification", "Texture Specification Tests")
3536*35238bceSAndroid Build Coastguard Worker {
3537*35238bceSAndroid Build Coastguard Worker }
3538*35238bceSAndroid Build Coastguard Worker 
~TextureSpecificationTests(void)3539*35238bceSAndroid Build Coastguard Worker TextureSpecificationTests::~TextureSpecificationTests(void)
3540*35238bceSAndroid Build Coastguard Worker {
3541*35238bceSAndroid Build Coastguard Worker }
3542*35238bceSAndroid Build Coastguard Worker 
init(void)3543*35238bceSAndroid Build Coastguard Worker void TextureSpecificationTests::init(void)
3544*35238bceSAndroid Build Coastguard Worker {
3545*35238bceSAndroid Build Coastguard Worker     struct
3546*35238bceSAndroid Build Coastguard Worker     {
3547*35238bceSAndroid Build Coastguard Worker         const char *name;
3548*35238bceSAndroid Build Coastguard Worker         uint32_t format;
3549*35238bceSAndroid Build Coastguard Worker         uint32_t dataType;
3550*35238bceSAndroid Build Coastguard Worker     } unsizedFormats[] = {{"alpha_unsigned_byte", GL_ALPHA, GL_UNSIGNED_BYTE},
3551*35238bceSAndroid Build Coastguard Worker                           {"luminance_unsigned_byte", GL_LUMINANCE, GL_UNSIGNED_BYTE},
3552*35238bceSAndroid Build Coastguard Worker                           {"luminance_alpha_unsigned_byte", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE},
3553*35238bceSAndroid Build Coastguard Worker                           {"rgb_unsigned_short_5_6_5", GL_RGB, GL_UNSIGNED_SHORT_5_6_5},
3554*35238bceSAndroid Build Coastguard Worker                           {"rgb_unsigned_byte", GL_RGB, GL_UNSIGNED_BYTE},
3555*35238bceSAndroid Build Coastguard Worker                           {"rgba_unsigned_short_4_4_4_4", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4},
3556*35238bceSAndroid Build Coastguard Worker                           {"rgba_unsigned_short_5_5_5_1", GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1},
3557*35238bceSAndroid Build Coastguard Worker                           {"rgba_unsigned_byte", GL_RGBA, GL_UNSIGNED_BYTE}};
3558*35238bceSAndroid Build Coastguard Worker 
3559*35238bceSAndroid Build Coastguard Worker     struct
3560*35238bceSAndroid Build Coastguard Worker     {
3561*35238bceSAndroid Build Coastguard Worker         const char *name;
3562*35238bceSAndroid Build Coastguard Worker         uint32_t internalFormat;
3563*35238bceSAndroid Build Coastguard Worker     } colorFormats[] = {{
3564*35238bceSAndroid Build Coastguard Worker                             "rgba32f",
3565*35238bceSAndroid Build Coastguard Worker                             GL_RGBA32F,
3566*35238bceSAndroid Build Coastguard Worker                         },
3567*35238bceSAndroid Build Coastguard Worker                         {
3568*35238bceSAndroid Build Coastguard Worker                             "rgba32i",
3569*35238bceSAndroid Build Coastguard Worker                             GL_RGBA32I,
3570*35238bceSAndroid Build Coastguard Worker                         },
3571*35238bceSAndroid Build Coastguard Worker                         {
3572*35238bceSAndroid Build Coastguard Worker                             "rgba32ui",
3573*35238bceSAndroid Build Coastguard Worker                             GL_RGBA32UI,
3574*35238bceSAndroid Build Coastguard Worker                         },
3575*35238bceSAndroid Build Coastguard Worker                         {
3576*35238bceSAndroid Build Coastguard Worker                             "rgba16f",
3577*35238bceSAndroid Build Coastguard Worker                             GL_RGBA16F,
3578*35238bceSAndroid Build Coastguard Worker                         },
3579*35238bceSAndroid Build Coastguard Worker                         {
3580*35238bceSAndroid Build Coastguard Worker                             "rgba16i",
3581*35238bceSAndroid Build Coastguard Worker                             GL_RGBA16I,
3582*35238bceSAndroid Build Coastguard Worker                         },
3583*35238bceSAndroid Build Coastguard Worker                         {
3584*35238bceSAndroid Build Coastguard Worker                             "rgba16ui",
3585*35238bceSAndroid Build Coastguard Worker                             GL_RGBA16UI,
3586*35238bceSAndroid Build Coastguard Worker                         },
3587*35238bceSAndroid Build Coastguard Worker                         {
3588*35238bceSAndroid Build Coastguard Worker                             "rgba8",
3589*35238bceSAndroid Build Coastguard Worker                             GL_RGBA8,
3590*35238bceSAndroid Build Coastguard Worker                         },
3591*35238bceSAndroid Build Coastguard Worker                         {
3592*35238bceSAndroid Build Coastguard Worker                             "rgba8i",
3593*35238bceSAndroid Build Coastguard Worker                             GL_RGBA8I,
3594*35238bceSAndroid Build Coastguard Worker                         },
3595*35238bceSAndroid Build Coastguard Worker                         {
3596*35238bceSAndroid Build Coastguard Worker                             "rgba8ui",
3597*35238bceSAndroid Build Coastguard Worker                             GL_RGBA8UI,
3598*35238bceSAndroid Build Coastguard Worker                         },
3599*35238bceSAndroid Build Coastguard Worker                         {
3600*35238bceSAndroid Build Coastguard Worker                             "srgb8_alpha8",
3601*35238bceSAndroid Build Coastguard Worker                             GL_SRGB8_ALPHA8,
3602*35238bceSAndroid Build Coastguard Worker                         },
3603*35238bceSAndroid Build Coastguard Worker                         {
3604*35238bceSAndroid Build Coastguard Worker                             "rgb10_a2",
3605*35238bceSAndroid Build Coastguard Worker                             GL_RGB10_A2,
3606*35238bceSAndroid Build Coastguard Worker                         },
3607*35238bceSAndroid Build Coastguard Worker                         {
3608*35238bceSAndroid Build Coastguard Worker                             "rgb10_a2ui",
3609*35238bceSAndroid Build Coastguard Worker                             GL_RGB10_A2UI,
3610*35238bceSAndroid Build Coastguard Worker                         },
3611*35238bceSAndroid Build Coastguard Worker                         {
3612*35238bceSAndroid Build Coastguard Worker                             "rgba4",
3613*35238bceSAndroid Build Coastguard Worker                             GL_RGBA4,
3614*35238bceSAndroid Build Coastguard Worker                         },
3615*35238bceSAndroid Build Coastguard Worker                         {
3616*35238bceSAndroid Build Coastguard Worker                             "rgb5_a1",
3617*35238bceSAndroid Build Coastguard Worker                             GL_RGB5_A1,
3618*35238bceSAndroid Build Coastguard Worker                         },
3619*35238bceSAndroid Build Coastguard Worker                         {
3620*35238bceSAndroid Build Coastguard Worker                             "rgba8_snorm",
3621*35238bceSAndroid Build Coastguard Worker                             GL_RGBA8_SNORM,
3622*35238bceSAndroid Build Coastguard Worker                         },
3623*35238bceSAndroid Build Coastguard Worker                         {
3624*35238bceSAndroid Build Coastguard Worker                             "rgb8",
3625*35238bceSAndroid Build Coastguard Worker                             GL_RGB8,
3626*35238bceSAndroid Build Coastguard Worker                         },
3627*35238bceSAndroid Build Coastguard Worker                         {
3628*35238bceSAndroid Build Coastguard Worker                             "rgb565",
3629*35238bceSAndroid Build Coastguard Worker                             GL_RGB565,
3630*35238bceSAndroid Build Coastguard Worker                         },
3631*35238bceSAndroid Build Coastguard Worker                         {
3632*35238bceSAndroid Build Coastguard Worker                             "r11f_g11f_b10f",
3633*35238bceSAndroid Build Coastguard Worker                             GL_R11F_G11F_B10F,
3634*35238bceSAndroid Build Coastguard Worker                         },
3635*35238bceSAndroid Build Coastguard Worker                         {
3636*35238bceSAndroid Build Coastguard Worker                             "rgb32f",
3637*35238bceSAndroid Build Coastguard Worker                             GL_RGB32F,
3638*35238bceSAndroid Build Coastguard Worker                         },
3639*35238bceSAndroid Build Coastguard Worker                         {
3640*35238bceSAndroid Build Coastguard Worker                             "rgb32i",
3641*35238bceSAndroid Build Coastguard Worker                             GL_RGB32I,
3642*35238bceSAndroid Build Coastguard Worker                         },
3643*35238bceSAndroid Build Coastguard Worker                         {
3644*35238bceSAndroid Build Coastguard Worker                             "rgb32ui",
3645*35238bceSAndroid Build Coastguard Worker                             GL_RGB32UI,
3646*35238bceSAndroid Build Coastguard Worker                         },
3647*35238bceSAndroid Build Coastguard Worker                         {
3648*35238bceSAndroid Build Coastguard Worker                             "rgb16f",
3649*35238bceSAndroid Build Coastguard Worker                             GL_RGB16F,
3650*35238bceSAndroid Build Coastguard Worker                         },
3651*35238bceSAndroid Build Coastguard Worker                         {
3652*35238bceSAndroid Build Coastguard Worker                             "rgb16i",
3653*35238bceSAndroid Build Coastguard Worker                             GL_RGB16I,
3654*35238bceSAndroid Build Coastguard Worker                         },
3655*35238bceSAndroid Build Coastguard Worker                         {
3656*35238bceSAndroid Build Coastguard Worker                             "rgb16ui",
3657*35238bceSAndroid Build Coastguard Worker                             GL_RGB16UI,
3658*35238bceSAndroid Build Coastguard Worker                         },
3659*35238bceSAndroid Build Coastguard Worker                         {
3660*35238bceSAndroid Build Coastguard Worker                             "rgb8_snorm",
3661*35238bceSAndroid Build Coastguard Worker                             GL_RGB8_SNORM,
3662*35238bceSAndroid Build Coastguard Worker                         },
3663*35238bceSAndroid Build Coastguard Worker                         {
3664*35238bceSAndroid Build Coastguard Worker                             "rgb8i",
3665*35238bceSAndroid Build Coastguard Worker                             GL_RGB8I,
3666*35238bceSAndroid Build Coastguard Worker                         },
3667*35238bceSAndroid Build Coastguard Worker                         {
3668*35238bceSAndroid Build Coastguard Worker                             "rgb8ui",
3669*35238bceSAndroid Build Coastguard Worker                             GL_RGB8UI,
3670*35238bceSAndroid Build Coastguard Worker                         },
3671*35238bceSAndroid Build Coastguard Worker                         {
3672*35238bceSAndroid Build Coastguard Worker                             "srgb8",
3673*35238bceSAndroid Build Coastguard Worker                             GL_SRGB8,
3674*35238bceSAndroid Build Coastguard Worker                         },
3675*35238bceSAndroid Build Coastguard Worker                         {
3676*35238bceSAndroid Build Coastguard Worker                             "rgb9_e5",
3677*35238bceSAndroid Build Coastguard Worker                             GL_RGB9_E5,
3678*35238bceSAndroid Build Coastguard Worker                         },
3679*35238bceSAndroid Build Coastguard Worker                         {
3680*35238bceSAndroid Build Coastguard Worker                             "rg32f",
3681*35238bceSAndroid Build Coastguard Worker                             GL_RG32F,
3682*35238bceSAndroid Build Coastguard Worker                         },
3683*35238bceSAndroid Build Coastguard Worker                         {
3684*35238bceSAndroid Build Coastguard Worker                             "rg32i",
3685*35238bceSAndroid Build Coastguard Worker                             GL_RG32I,
3686*35238bceSAndroid Build Coastguard Worker                         },
3687*35238bceSAndroid Build Coastguard Worker                         {
3688*35238bceSAndroid Build Coastguard Worker                             "rg32ui",
3689*35238bceSAndroid Build Coastguard Worker                             GL_RG32UI,
3690*35238bceSAndroid Build Coastguard Worker                         },
3691*35238bceSAndroid Build Coastguard Worker                         {
3692*35238bceSAndroid Build Coastguard Worker                             "rg16f",
3693*35238bceSAndroid Build Coastguard Worker                             GL_RG16F,
3694*35238bceSAndroid Build Coastguard Worker                         },
3695*35238bceSAndroid Build Coastguard Worker                         {
3696*35238bceSAndroid Build Coastguard Worker                             "rg16i",
3697*35238bceSAndroid Build Coastguard Worker                             GL_RG16I,
3698*35238bceSAndroid Build Coastguard Worker                         },
3699*35238bceSAndroid Build Coastguard Worker                         {
3700*35238bceSAndroid Build Coastguard Worker                             "rg16ui",
3701*35238bceSAndroid Build Coastguard Worker                             GL_RG16UI,
3702*35238bceSAndroid Build Coastguard Worker                         },
3703*35238bceSAndroid Build Coastguard Worker                         {
3704*35238bceSAndroid Build Coastguard Worker                             "rg8",
3705*35238bceSAndroid Build Coastguard Worker                             GL_RG8,
3706*35238bceSAndroid Build Coastguard Worker                         },
3707*35238bceSAndroid Build Coastguard Worker                         {
3708*35238bceSAndroid Build Coastguard Worker                             "rg8i",
3709*35238bceSAndroid Build Coastguard Worker                             GL_RG8I,
3710*35238bceSAndroid Build Coastguard Worker                         },
3711*35238bceSAndroid Build Coastguard Worker                         {
3712*35238bceSAndroid Build Coastguard Worker                             "rg8ui",
3713*35238bceSAndroid Build Coastguard Worker                             GL_RG8UI,
3714*35238bceSAndroid Build Coastguard Worker                         },
3715*35238bceSAndroid Build Coastguard Worker                         {
3716*35238bceSAndroid Build Coastguard Worker                             "rg8_snorm",
3717*35238bceSAndroid Build Coastguard Worker                             GL_RG8_SNORM,
3718*35238bceSAndroid Build Coastguard Worker                         },
3719*35238bceSAndroid Build Coastguard Worker                         {
3720*35238bceSAndroid Build Coastguard Worker                             "r32f",
3721*35238bceSAndroid Build Coastguard Worker                             GL_R32F,
3722*35238bceSAndroid Build Coastguard Worker                         },
3723*35238bceSAndroid Build Coastguard Worker                         {
3724*35238bceSAndroid Build Coastguard Worker                             "r32i",
3725*35238bceSAndroid Build Coastguard Worker                             GL_R32I,
3726*35238bceSAndroid Build Coastguard Worker                         },
3727*35238bceSAndroid Build Coastguard Worker                         {
3728*35238bceSAndroid Build Coastguard Worker                             "r32ui",
3729*35238bceSAndroid Build Coastguard Worker                             GL_R32UI,
3730*35238bceSAndroid Build Coastguard Worker                         },
3731*35238bceSAndroid Build Coastguard Worker                         {
3732*35238bceSAndroid Build Coastguard Worker                             "r16f",
3733*35238bceSAndroid Build Coastguard Worker                             GL_R16F,
3734*35238bceSAndroid Build Coastguard Worker                         },
3735*35238bceSAndroid Build Coastguard Worker                         {
3736*35238bceSAndroid Build Coastguard Worker                             "r16i",
3737*35238bceSAndroid Build Coastguard Worker                             GL_R16I,
3738*35238bceSAndroid Build Coastguard Worker                         },
3739*35238bceSAndroid Build Coastguard Worker                         {
3740*35238bceSAndroid Build Coastguard Worker                             "r16ui",
3741*35238bceSAndroid Build Coastguard Worker                             GL_R16UI,
3742*35238bceSAndroid Build Coastguard Worker                         },
3743*35238bceSAndroid Build Coastguard Worker                         {
3744*35238bceSAndroid Build Coastguard Worker                             "r8",
3745*35238bceSAndroid Build Coastguard Worker                             GL_R8,
3746*35238bceSAndroid Build Coastguard Worker                         },
3747*35238bceSAndroid Build Coastguard Worker                         {
3748*35238bceSAndroid Build Coastguard Worker                             "r8i",
3749*35238bceSAndroid Build Coastguard Worker                             GL_R8I,
3750*35238bceSAndroid Build Coastguard Worker                         },
3751*35238bceSAndroid Build Coastguard Worker                         {
3752*35238bceSAndroid Build Coastguard Worker                             "r8ui",
3753*35238bceSAndroid Build Coastguard Worker                             GL_R8UI,
3754*35238bceSAndroid Build Coastguard Worker                         },
3755*35238bceSAndroid Build Coastguard Worker                         {
3756*35238bceSAndroid Build Coastguard Worker                             "r8_snorm",
3757*35238bceSAndroid Build Coastguard Worker                             GL_R8_SNORM,
3758*35238bceSAndroid Build Coastguard Worker                         }};
3759*35238bceSAndroid Build Coastguard Worker 
3760*35238bceSAndroid Build Coastguard Worker     static const struct
3761*35238bceSAndroid Build Coastguard Worker     {
3762*35238bceSAndroid Build Coastguard Worker         const char *name;
3763*35238bceSAndroid Build Coastguard Worker         uint32_t internalFormat;
3764*35238bceSAndroid Build Coastguard Worker     } depthStencilFormats[] = {// Depth and stencil formats
3765*35238bceSAndroid Build Coastguard Worker                                {"depth_component32f", GL_DEPTH_COMPONENT32F},
3766*35238bceSAndroid Build Coastguard Worker                                {"depth_component24", GL_DEPTH_COMPONENT24},
3767*35238bceSAndroid Build Coastguard Worker                                {"depth_component16", GL_DEPTH_COMPONENT16},
3768*35238bceSAndroid Build Coastguard Worker                                {"depth32f_stencil8", GL_DEPTH32F_STENCIL8},
3769*35238bceSAndroid Build Coastguard Worker                                {"depth24_stencil8", GL_DEPTH24_STENCIL8}};
3770*35238bceSAndroid Build Coastguard Worker 
3771*35238bceSAndroid Build Coastguard Worker     // Basic TexImage2D usage.
3772*35238bceSAndroid Build Coastguard Worker     {
3773*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *basicTexImageGroup =
3774*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "basic_teximage2d", "Basic glTexImage2D() usage");
3775*35238bceSAndroid Build Coastguard Worker         addChild(basicTexImageGroup);
3776*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
3777*35238bceSAndroid Build Coastguard Worker         {
3778*35238bceSAndroid Build Coastguard Worker             const char *fmtName   = colorFormats[formatNdx].name;
3779*35238bceSAndroid Build Coastguard Worker             uint32_t format       = colorFormats[formatNdx].internalFormat;
3780*35238bceSAndroid Build Coastguard Worker             const int tex2DWidth  = 64;
3781*35238bceSAndroid Build Coastguard Worker             const int tex2DHeight = 128;
3782*35238bceSAndroid Build Coastguard Worker             const int texCubeSize = 64;
3783*35238bceSAndroid Build Coastguard Worker 
3784*35238bceSAndroid Build Coastguard Worker             basicTexImageGroup->addChild(new BasicTexImage2DCase(m_context, (string(fmtName) + "_2d").c_str(), "",
3785*35238bceSAndroid Build Coastguard Worker                                                                  format, tex2DWidth, tex2DHeight));
3786*35238bceSAndroid Build Coastguard Worker             basicTexImageGroup->addChild(
3787*35238bceSAndroid Build Coastguard Worker                 new BasicTexImageCubeCase(m_context, (string(fmtName) + "_cube").c_str(), "", format, texCubeSize));
3788*35238bceSAndroid Build Coastguard Worker         }
3789*35238bceSAndroid Build Coastguard Worker     }
3790*35238bceSAndroid Build Coastguard Worker 
3791*35238bceSAndroid Build Coastguard Worker     // Randomized TexImage2D order.
3792*35238bceSAndroid Build Coastguard Worker     {
3793*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *randomTexImageGroup =
3794*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "random_teximage2d", "Randomized glTexImage2D() usage");
3795*35238bceSAndroid Build Coastguard Worker         addChild(randomTexImageGroup);
3796*35238bceSAndroid Build Coastguard Worker 
3797*35238bceSAndroid Build Coastguard Worker         de::Random rnd(9);
3798*35238bceSAndroid Build Coastguard Worker 
3799*35238bceSAndroid Build Coastguard Worker         // 2D cases.
3800*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < 10; ndx++)
3801*35238bceSAndroid Build Coastguard Worker         {
3802*35238bceSAndroid Build Coastguard Worker             int formatNdx = rnd.getInt(0, DE_LENGTH_OF_ARRAY(colorFormats) - 1);
3803*35238bceSAndroid Build Coastguard Worker             int width     = 1 << rnd.getInt(2, 8);
3804*35238bceSAndroid Build Coastguard Worker             int height    = 1 << rnd.getInt(2, 8);
3805*35238bceSAndroid Build Coastguard Worker 
3806*35238bceSAndroid Build Coastguard Worker             randomTexImageGroup->addChild(
3807*35238bceSAndroid Build Coastguard Worker                 new RandomOrderTexImage2DCase(m_context, (string("2d_") + de::toString(ndx)).c_str(), "",
3808*35238bceSAndroid Build Coastguard Worker                                               colorFormats[formatNdx].internalFormat, width, height));
3809*35238bceSAndroid Build Coastguard Worker         }
3810*35238bceSAndroid Build Coastguard Worker 
3811*35238bceSAndroid Build Coastguard Worker         // Cubemap cases.
3812*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < 10; ndx++)
3813*35238bceSAndroid Build Coastguard Worker         {
3814*35238bceSAndroid Build Coastguard Worker             int formatNdx = rnd.getInt(0, DE_LENGTH_OF_ARRAY(colorFormats) - 1);
3815*35238bceSAndroid Build Coastguard Worker             int size      = 1 << rnd.getInt(2, 8);
3816*35238bceSAndroid Build Coastguard Worker 
3817*35238bceSAndroid Build Coastguard Worker             randomTexImageGroup->addChild(
3818*35238bceSAndroid Build Coastguard Worker                 new RandomOrderTexImageCubeCase(m_context, (string("cube_") + de::toString(ndx)).c_str(), "",
3819*35238bceSAndroid Build Coastguard Worker                                                 colorFormats[formatNdx].internalFormat, size));
3820*35238bceSAndroid Build Coastguard Worker         }
3821*35238bceSAndroid Build Coastguard Worker     }
3822*35238bceSAndroid Build Coastguard Worker 
3823*35238bceSAndroid Build Coastguard Worker     // TexImage2D unpack alignment.
3824*35238bceSAndroid Build Coastguard Worker     {
3825*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *alignGroup =
3826*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "teximage2d_align", "glTexImage2D() unpack alignment tests");
3827*35238bceSAndroid Build Coastguard Worker         addChild(alignGroup);
3828*35238bceSAndroid Build Coastguard Worker 
3829*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_r8_4_8", "", GL_R8, 4, 8, 4, 8));
3830*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_r8_63_1", "", GL_R8, 63, 30, 1, 1));
3831*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_r8_63_2", "", GL_R8, 63, 30, 1, 2));
3832*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_r8_63_4", "", GL_R8, 63, 30, 1, 4));
3833*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_r8_63_8", "", GL_R8, 63, 30, 1, 8));
3834*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba4_51_1", "", GL_RGBA4, 51, 30, 1, 1));
3835*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba4_51_2", "", GL_RGBA4, 51, 30, 1, 2));
3836*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba4_51_4", "", GL_RGBA4, 51, 30, 1, 4));
3837*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba4_51_8", "", GL_RGBA4, 51, 30, 1, 8));
3838*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgb8_39_1", "", GL_RGB8, 39, 43, 1, 1));
3839*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgb8_39_2", "", GL_RGB8, 39, 43, 1, 2));
3840*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgb8_39_4", "", GL_RGB8, 39, 43, 1, 4));
3841*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgb8_39_8", "", GL_RGB8, 39, 43, 1, 8));
3842*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba8_47_1", "", GL_RGBA8, 47, 27, 1, 1));
3843*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba8_47_2", "", GL_RGBA8, 47, 27, 1, 2));
3844*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba8_47_4", "", GL_RGBA8, 47, 27, 1, 4));
3845*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba8_47_8", "", GL_RGBA8, 47, 27, 1, 8));
3846*35238bceSAndroid Build Coastguard Worker 
3847*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_r8_4_8", "", GL_R8, 4, 3, 8));
3848*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_r8_63_1", "", GL_R8, 63, 1, 1));
3849*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_r8_63_2", "", GL_R8, 63, 1, 2));
3850*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_r8_63_4", "", GL_R8, 63, 1, 4));
3851*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_r8_63_8", "", GL_R8, 63, 1, 8));
3852*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba4_51_1", "", GL_RGBA4, 51, 1, 1));
3853*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba4_51_2", "", GL_RGBA4, 51, 1, 2));
3854*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba4_51_4", "", GL_RGBA4, 51, 1, 4));
3855*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba4_51_8", "", GL_RGBA4, 51, 1, 8));
3856*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgb8_39_1", "", GL_RGB8, 39, 1, 1));
3857*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgb8_39_2", "", GL_RGB8, 39, 1, 2));
3858*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgb8_39_4", "", GL_RGB8, 39, 1, 4));
3859*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgb8_39_8", "", GL_RGB8, 39, 1, 8));
3860*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba8_47_1", "", GL_RGBA8, 47, 1, 1));
3861*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba8_47_2", "", GL_RGBA8, 47, 1, 2));
3862*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba8_47_4", "", GL_RGBA8, 47, 1, 4));
3863*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba8_47_8", "", GL_RGBA8, 47, 1, 8));
3864*35238bceSAndroid Build Coastguard Worker     }
3865*35238bceSAndroid Build Coastguard Worker 
3866*35238bceSAndroid Build Coastguard Worker     // glTexImage2D() unpack parameter cases.
3867*35238bceSAndroid Build Coastguard Worker     {
3868*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *paramGroup =
3869*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "teximage2d_unpack_params", "glTexImage2D() pixel transfer mode cases");
3870*35238bceSAndroid Build Coastguard Worker         addChild(paramGroup);
3871*35238bceSAndroid Build Coastguard Worker 
3872*35238bceSAndroid Build Coastguard Worker         static const struct
3873*35238bceSAndroid Build Coastguard Worker         {
3874*35238bceSAndroid Build Coastguard Worker             const char *name;
3875*35238bceSAndroid Build Coastguard Worker             uint32_t format;
3876*35238bceSAndroid Build Coastguard Worker             int width;
3877*35238bceSAndroid Build Coastguard Worker             int height;
3878*35238bceSAndroid Build Coastguard Worker             int rowLength;
3879*35238bceSAndroid Build Coastguard Worker             int skipRows;
3880*35238bceSAndroid Build Coastguard Worker             int skipPixels;
3881*35238bceSAndroid Build Coastguard Worker             int alignment;
3882*35238bceSAndroid Build Coastguard Worker         } cases[] = {
3883*35238bceSAndroid Build Coastguard Worker             {"rgb8_alignment", GL_RGB8, 31, 30, 0, 0, 0, 2},     {"rgb8_row_length", GL_RGB8, 31, 30, 50, 0, 0, 4},
3884*35238bceSAndroid Build Coastguard Worker             {"rgb8_skip_rows", GL_RGB8, 31, 30, 0, 3, 0, 4},     {"rgb8_skip_pixels", GL_RGB8, 31, 30, 36, 0, 5, 4},
3885*35238bceSAndroid Build Coastguard Worker             {"r8_complex1", GL_R8, 31, 30, 64, 1, 3, 1},         {"r8_complex2", GL_R8, 31, 30, 64, 1, 3, 2},
3886*35238bceSAndroid Build Coastguard Worker             {"r8_complex3", GL_R8, 31, 30, 64, 1, 3, 4},         {"r8_complex4", GL_R8, 31, 30, 64, 1, 3, 8},
3887*35238bceSAndroid Build Coastguard Worker             {"rgba8_complex1", GL_RGBA8, 56, 61, 69, 0, 0, 8},   {"rgba8_complex2", GL_RGBA8, 56, 61, 69, 0, 7, 8},
3888*35238bceSAndroid Build Coastguard Worker             {"rgba8_complex3", GL_RGBA8, 56, 61, 69, 3, 0, 8},   {"rgba8_complex4", GL_RGBA8, 56, 61, 69, 3, 7, 8},
3889*35238bceSAndroid Build Coastguard Worker             {"rgba32f_complex", GL_RGBA32F, 19, 10, 27, 1, 7, 8}};
3890*35238bceSAndroid Build Coastguard Worker 
3891*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
3892*35238bceSAndroid Build Coastguard Worker             paramGroup->addChild(new TexImage2DParamsCase(
3893*35238bceSAndroid Build Coastguard Worker                 m_context, cases[ndx].name, "", cases[ndx].format, cases[ndx].width, cases[ndx].height,
3894*35238bceSAndroid Build Coastguard Worker                 cases[ndx].rowLength, cases[ndx].skipRows, cases[ndx].skipPixels, cases[ndx].alignment));
3895*35238bceSAndroid Build Coastguard Worker     }
3896*35238bceSAndroid Build Coastguard Worker 
3897*35238bceSAndroid Build Coastguard Worker     // glTexImage2D() pbo cases.
3898*35238bceSAndroid Build Coastguard Worker     {
3899*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *pboGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_pbo", "glTexImage2D() from PBO");
3900*35238bceSAndroid Build Coastguard Worker         addChild(pboGroup);
3901*35238bceSAndroid Build Coastguard Worker 
3902*35238bceSAndroid Build Coastguard Worker         // Parameter cases
3903*35238bceSAndroid Build Coastguard Worker         static const struct
3904*35238bceSAndroid Build Coastguard Worker         {
3905*35238bceSAndroid Build Coastguard Worker             const char *name;
3906*35238bceSAndroid Build Coastguard Worker             uint32_t format;
3907*35238bceSAndroid Build Coastguard Worker             int width;
3908*35238bceSAndroid Build Coastguard Worker             int height;
3909*35238bceSAndroid Build Coastguard Worker             int rowLength;
3910*35238bceSAndroid Build Coastguard Worker             int skipRows;
3911*35238bceSAndroid Build Coastguard Worker             int skipPixels;
3912*35238bceSAndroid Build Coastguard Worker             int alignment;
3913*35238bceSAndroid Build Coastguard Worker             int offset;
3914*35238bceSAndroid Build Coastguard Worker         } parameterCases[] = {{"rgb8_offset", GL_RGB8, 31, 30, 0, 0, 0, 4, 67},
3915*35238bceSAndroid Build Coastguard Worker                               {"rgb8_alignment", GL_RGB8, 31, 30, 0, 0, 0, 2, 0},
3916*35238bceSAndroid Build Coastguard Worker                               {"rgb8_row_length", GL_RGB8, 31, 30, 50, 0, 0, 4, 0},
3917*35238bceSAndroid Build Coastguard Worker                               {"rgb8_skip_rows", GL_RGB8, 31, 30, 0, 3, 0, 4, 0},
3918*35238bceSAndroid Build Coastguard Worker                               {"rgb8_skip_pixels", GL_RGB8, 31, 30, 36, 0, 5, 4, 0}};
3919*35238bceSAndroid Build Coastguard Worker 
3920*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
3921*35238bceSAndroid Build Coastguard Worker         {
3922*35238bceSAndroid Build Coastguard Worker             const string fmtName  = colorFormats[formatNdx].name;
3923*35238bceSAndroid Build Coastguard Worker             const uint32_t format = colorFormats[formatNdx].internalFormat;
3924*35238bceSAndroid Build Coastguard Worker             const int tex2DWidth  = 65;
3925*35238bceSAndroid Build Coastguard Worker             const int tex2DHeight = 37;
3926*35238bceSAndroid Build Coastguard Worker             const int texCubeSize = 64;
3927*35238bceSAndroid Build Coastguard Worker 
3928*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexImage2DBufferCase(m_context, (fmtName + "_2d").c_str(), "", format, tex2DWidth,
3929*35238bceSAndroid Build Coastguard Worker                                                         tex2DHeight, 0, 0, 0, 4, 0));
3930*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexImageCubeBufferCase(m_context, (fmtName + "_cube").c_str(), "", format,
3931*35238bceSAndroid Build Coastguard Worker                                                           texCubeSize, 0, 0, 0, 4, 0));
3932*35238bceSAndroid Build Coastguard Worker         }
3933*35238bceSAndroid Build Coastguard Worker 
3934*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(parameterCases); ndx++)
3935*35238bceSAndroid Build Coastguard Worker         {
3936*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexImage2DBufferCase(m_context, (string(parameterCases[ndx].name) + "_2d").c_str(),
3937*35238bceSAndroid Build Coastguard Worker                                                         "", parameterCases[ndx].format, parameterCases[ndx].width,
3938*35238bceSAndroid Build Coastguard Worker                                                         parameterCases[ndx].height, parameterCases[ndx].rowLength,
3939*35238bceSAndroid Build Coastguard Worker                                                         parameterCases[ndx].skipRows, parameterCases[ndx].skipPixels,
3940*35238bceSAndroid Build Coastguard Worker                                                         parameterCases[ndx].alignment, parameterCases[ndx].offset));
3941*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexImageCubeBufferCase(
3942*35238bceSAndroid Build Coastguard Worker                 m_context, (string(parameterCases[ndx].name) + "_cube").c_str(), "", parameterCases[ndx].format,
3943*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].width, parameterCases[ndx].rowLength, parameterCases[ndx].skipRows,
3944*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].skipPixels, parameterCases[ndx].alignment, parameterCases[ndx].offset));
3945*35238bceSAndroid Build Coastguard Worker         }
3946*35238bceSAndroid Build Coastguard Worker     }
3947*35238bceSAndroid Build Coastguard Worker 
3948*35238bceSAndroid Build Coastguard Worker     // glTexImage2D() depth cases.
3949*35238bceSAndroid Build Coastguard Worker     {
3950*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *shadow2dGroup =
3951*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "teximage2d_depth", "glTexImage2D() with depth or depth/stencil format");
3952*35238bceSAndroid Build Coastguard Worker         addChild(shadow2dGroup);
3953*35238bceSAndroid Build Coastguard Worker 
3954*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
3955*35238bceSAndroid Build Coastguard Worker         {
3956*35238bceSAndroid Build Coastguard Worker             const int tex2DWidth  = 64;
3957*35238bceSAndroid Build Coastguard Worker             const int tex2DHeight = 128;
3958*35238bceSAndroid Build Coastguard Worker 
3959*35238bceSAndroid Build Coastguard Worker             shadow2dGroup->addChild(new TexImage2DDepthCase(m_context, depthStencilFormats[ndx].name, "",
3960*35238bceSAndroid Build Coastguard Worker                                                             depthStencilFormats[ndx].internalFormat, tex2DWidth,
3961*35238bceSAndroid Build Coastguard Worker                                                             tex2DHeight));
3962*35238bceSAndroid Build Coastguard Worker         }
3963*35238bceSAndroid Build Coastguard Worker     }
3964*35238bceSAndroid Build Coastguard Worker 
3965*35238bceSAndroid Build Coastguard Worker     // glTexImage2D() depth cases with pbo.
3966*35238bceSAndroid Build Coastguard Worker     {
3967*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *shadow2dGroup = new tcu::TestCaseGroup(
3968*35238bceSAndroid Build Coastguard Worker             m_testCtx, "teximage2d_depth_pbo", "glTexImage2D() with depth or depth/stencil format with pbo");
3969*35238bceSAndroid Build Coastguard Worker         addChild(shadow2dGroup);
3970*35238bceSAndroid Build Coastguard Worker 
3971*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
3972*35238bceSAndroid Build Coastguard Worker         {
3973*35238bceSAndroid Build Coastguard Worker             const int tex2DWidth  = 64;
3974*35238bceSAndroid Build Coastguard Worker             const int tex2DHeight = 128;
3975*35238bceSAndroid Build Coastguard Worker 
3976*35238bceSAndroid Build Coastguard Worker             shadow2dGroup->addChild(new TexImage2DDepthBufferCase(m_context, depthStencilFormats[ndx].name, "",
3977*35238bceSAndroid Build Coastguard Worker                                                                   depthStencilFormats[ndx].internalFormat, tex2DWidth,
3978*35238bceSAndroid Build Coastguard Worker                                                                   tex2DHeight));
3979*35238bceSAndroid Build Coastguard Worker         }
3980*35238bceSAndroid Build Coastguard Worker     }
3981*35238bceSAndroid Build Coastguard Worker 
3982*35238bceSAndroid Build Coastguard Worker     // Basic TexSubImage2D usage.
3983*35238bceSAndroid Build Coastguard Worker     {
3984*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *basicTexSubImageGroup =
3985*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "basic_texsubimage2d", "Basic glTexSubImage2D() usage");
3986*35238bceSAndroid Build Coastguard Worker         addChild(basicTexSubImageGroup);
3987*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
3988*35238bceSAndroid Build Coastguard Worker         {
3989*35238bceSAndroid Build Coastguard Worker             const char *fmtName   = colorFormats[formatNdx].name;
3990*35238bceSAndroid Build Coastguard Worker             uint32_t format       = colorFormats[formatNdx].internalFormat;
3991*35238bceSAndroid Build Coastguard Worker             const int tex2DWidth  = 64;
3992*35238bceSAndroid Build Coastguard Worker             const int tex2DHeight = 128;
3993*35238bceSAndroid Build Coastguard Worker             const int texCubeSize = 64;
3994*35238bceSAndroid Build Coastguard Worker 
3995*35238bceSAndroid Build Coastguard Worker             basicTexSubImageGroup->addChild(new BasicTexSubImage2DCase(m_context, (string(fmtName) + "_2d").c_str(), "",
3996*35238bceSAndroid Build Coastguard Worker                                                                        format, tex2DWidth, tex2DHeight));
3997*35238bceSAndroid Build Coastguard Worker             basicTexSubImageGroup->addChild(
3998*35238bceSAndroid Build Coastguard Worker                 new BasicTexSubImageCubeCase(m_context, (string(fmtName) + "_cube").c_str(), "", format, texCubeSize));
3999*35238bceSAndroid Build Coastguard Worker         }
4000*35238bceSAndroid Build Coastguard Worker     }
4001*35238bceSAndroid Build Coastguard Worker 
4002*35238bceSAndroid Build Coastguard Worker     // TexSubImage2D to empty texture.
4003*35238bceSAndroid Build Coastguard Worker     {
4004*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *texSubImageEmptyTexGroup = new tcu::TestCaseGroup(
4005*35238bceSAndroid Build Coastguard Worker             m_testCtx, "texsubimage2d_empty_tex", "glTexSubImage2D() to texture that has storage but no data");
4006*35238bceSAndroid Build Coastguard Worker         addChild(texSubImageEmptyTexGroup);
4007*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(unsizedFormats); formatNdx++)
4008*35238bceSAndroid Build Coastguard Worker         {
4009*35238bceSAndroid Build Coastguard Worker             const char *fmtName   = unsizedFormats[formatNdx].name;
4010*35238bceSAndroid Build Coastguard Worker             uint32_t format       = unsizedFormats[formatNdx].format;
4011*35238bceSAndroid Build Coastguard Worker             uint32_t dataType     = unsizedFormats[formatNdx].dataType;
4012*35238bceSAndroid Build Coastguard Worker             const int tex2DWidth  = 64;
4013*35238bceSAndroid Build Coastguard Worker             const int tex2DHeight = 32;
4014*35238bceSAndroid Build Coastguard Worker             const int texCubeSize = 32;
4015*35238bceSAndroid Build Coastguard Worker 
4016*35238bceSAndroid Build Coastguard Worker             texSubImageEmptyTexGroup->addChild(new TexSubImage2DEmptyTexCase(
4017*35238bceSAndroid Build Coastguard Worker                 m_context, (string(fmtName) + "_2d").c_str(), "", format, dataType, tex2DWidth, tex2DHeight));
4018*35238bceSAndroid Build Coastguard Worker             texSubImageEmptyTexGroup->addChild(new TexSubImageCubeEmptyTexCase(
4019*35238bceSAndroid Build Coastguard Worker                 m_context, (string(fmtName) + "_cube").c_str(), "", format, dataType, texCubeSize));
4020*35238bceSAndroid Build Coastguard Worker         }
4021*35238bceSAndroid Build Coastguard Worker     }
4022*35238bceSAndroid Build Coastguard Worker 
4023*35238bceSAndroid Build Coastguard Worker     // TexSubImage2D alignment cases.
4024*35238bceSAndroid Build Coastguard Worker     {
4025*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *alignGroup =
4026*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_align", "glTexSubImage2D() unpack alignment tests");
4027*35238bceSAndroid Build Coastguard Worker         addChild(alignGroup);
4028*35238bceSAndroid Build Coastguard Worker 
4029*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_r8_1_1", "", GL_R8, 64, 64, 13, 17, 1, 6, 1));
4030*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_r8_1_2", "", GL_R8, 64, 64, 13, 17, 1, 6, 2));
4031*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_r8_1_4", "", GL_R8, 64, 64, 13, 17, 1, 6, 4));
4032*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_r8_1_8", "", GL_R8, 64, 64, 13, 17, 1, 6, 8));
4033*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_r8_63_1", "", GL_R8, 64, 64, 1, 9, 63, 30, 1));
4034*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_r8_63_2", "", GL_R8, 64, 64, 1, 9, 63, 30, 2));
4035*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_r8_63_4", "", GL_R8, 64, 64, 1, 9, 63, 30, 4));
4036*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_r8_63_8", "", GL_R8, 64, 64, 1, 9, 63, 30, 8));
4037*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4038*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgba4_51_1", "", GL_RGBA4, 64, 64, 7, 29, 51, 30, 1));
4039*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4040*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgba4_51_2", "", GL_RGBA4, 64, 64, 7, 29, 51, 30, 2));
4041*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4042*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgba4_51_4", "", GL_RGBA4, 64, 64, 7, 29, 51, 30, 4));
4043*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4044*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgba4_51_8", "", GL_RGBA4, 64, 64, 7, 29, 51, 30, 8));
4045*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4046*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgb8_39_1", "", GL_RGB8, 64, 64, 11, 8, 39, 43, 1));
4047*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4048*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgb8_39_2", "", GL_RGB8, 64, 64, 11, 8, 39, 43, 2));
4049*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4050*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgb8_39_4", "", GL_RGB8, 64, 64, 11, 8, 39, 43, 4));
4051*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4052*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgb8_39_8", "", GL_RGB8, 64, 64, 11, 8, 39, 43, 8));
4053*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4054*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgba8_47_1", "", GL_RGBA8, 64, 64, 10, 1, 47, 27, 1));
4055*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4056*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgba8_47_2", "", GL_RGBA8, 64, 64, 10, 1, 47, 27, 2));
4057*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4058*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgba8_47_4", "", GL_RGBA8, 64, 64, 10, 1, 47, 27, 4));
4059*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4060*35238bceSAndroid Build Coastguard Worker             new TexSubImage2DAlignCase(m_context, "2d_rgba8_47_8", "", GL_RGBA8, 64, 64, 10, 1, 47, 27, 8));
4061*35238bceSAndroid Build Coastguard Worker 
4062*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_r8_1_1", "", GL_R8, 64, 13, 17, 1, 6, 1));
4063*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_r8_1_2", "", GL_R8, 64, 13, 17, 1, 6, 2));
4064*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_r8_1_4", "", GL_R8, 64, 13, 17, 1, 6, 4));
4065*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_r8_1_8", "", GL_R8, 64, 13, 17, 1, 6, 8));
4066*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_r8_63_1", "", GL_R8, 64, 1, 9, 63, 30, 1));
4067*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_r8_63_2", "", GL_R8, 64, 1, 9, 63, 30, 2));
4068*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_r8_63_4", "", GL_R8, 64, 1, 9, 63, 30, 4));
4069*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_r8_63_8", "", GL_R8, 64, 1, 9, 63, 30, 8));
4070*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4071*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgba4_51_1", "", GL_RGBA4, 64, 7, 29, 51, 30, 1));
4072*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4073*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgba4_51_2", "", GL_RGBA4, 64, 7, 29, 51, 30, 2));
4074*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4075*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgba4_51_4", "", GL_RGBA4, 64, 7, 29, 51, 30, 4));
4076*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4077*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgba4_51_8", "", GL_RGBA4, 64, 7, 29, 51, 30, 8));
4078*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4079*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgb8_39_1", "", GL_RGB8, 64, 11, 8, 39, 43, 1));
4080*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4081*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgb8_39_2", "", GL_RGB8, 64, 11, 8, 39, 43, 2));
4082*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4083*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgb8_39_4", "", GL_RGB8, 64, 11, 8, 39, 43, 4));
4084*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4085*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgb8_39_8", "", GL_RGB8, 64, 11, 8, 39, 43, 8));
4086*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4087*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgba8_47_1", "", GL_RGBA8, 64, 10, 1, 47, 27, 1));
4088*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4089*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgba8_47_2", "", GL_RGBA8, 64, 10, 1, 47, 27, 2));
4090*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4091*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgba8_47_4", "", GL_RGBA8, 64, 10, 1, 47, 27, 4));
4092*35238bceSAndroid Build Coastguard Worker         alignGroup->addChild(
4093*35238bceSAndroid Build Coastguard Worker             new TexSubImageCubeAlignCase(m_context, "cube_rgba8_47_8", "", GL_RGBA8, 64, 10, 1, 47, 27, 8));
4094*35238bceSAndroid Build Coastguard Worker     }
4095*35238bceSAndroid Build Coastguard Worker 
4096*35238bceSAndroid Build Coastguard Worker     // glTexSubImage2D() pixel transfer mode cases.
4097*35238bceSAndroid Build Coastguard Worker     {
4098*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *paramGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_unpack_params",
4099*35238bceSAndroid Build Coastguard Worker                                                                 "glTexSubImage2D() pixel transfer mode cases");
4100*35238bceSAndroid Build Coastguard Worker         addChild(paramGroup);
4101*35238bceSAndroid Build Coastguard Worker 
4102*35238bceSAndroid Build Coastguard Worker         static const struct
4103*35238bceSAndroid Build Coastguard Worker         {
4104*35238bceSAndroid Build Coastguard Worker             const char *name;
4105*35238bceSAndroid Build Coastguard Worker             uint32_t format;
4106*35238bceSAndroid Build Coastguard Worker             int width;
4107*35238bceSAndroid Build Coastguard Worker             int height;
4108*35238bceSAndroid Build Coastguard Worker             int subX;
4109*35238bceSAndroid Build Coastguard Worker             int subY;
4110*35238bceSAndroid Build Coastguard Worker             int subW;
4111*35238bceSAndroid Build Coastguard Worker             int subH;
4112*35238bceSAndroid Build Coastguard Worker             int rowLength;
4113*35238bceSAndroid Build Coastguard Worker             int skipRows;
4114*35238bceSAndroid Build Coastguard Worker             int skipPixels;
4115*35238bceSAndroid Build Coastguard Worker             int alignment;
4116*35238bceSAndroid Build Coastguard Worker         } cases[] = {{"rgb8_alignment", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 0, 0, 2},
4117*35238bceSAndroid Build Coastguard Worker                      {"rgb8_row_length", GL_RGB8, 54, 60, 11, 7, 31, 30, 50, 0, 0, 4},
4118*35238bceSAndroid Build Coastguard Worker                      {"rgb8_skip_rows", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 3, 0, 4},
4119*35238bceSAndroid Build Coastguard Worker                      {"rgb8_skip_pixels", GL_RGB8, 54, 60, 11, 7, 31, 30, 36, 0, 5, 4},
4120*35238bceSAndroid Build Coastguard Worker                      {"r8_complex1", GL_R8, 54, 60, 11, 7, 31, 30, 64, 1, 3, 1},
4121*35238bceSAndroid Build Coastguard Worker                      {"r8_complex2", GL_R8, 54, 60, 11, 7, 31, 30, 64, 1, 3, 2},
4122*35238bceSAndroid Build Coastguard Worker                      {"r8_complex3", GL_R8, 54, 60, 11, 7, 31, 30, 64, 1, 3, 4},
4123*35238bceSAndroid Build Coastguard Worker                      {"r8_complex4", GL_R8, 54, 60, 11, 7, 31, 30, 64, 1, 3, 8},
4124*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex1", GL_RGBA8, 92, 84, 13, 19, 56, 61, 69, 0, 0, 8},
4125*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex2", GL_RGBA8, 92, 84, 13, 19, 56, 61, 69, 0, 7, 8},
4126*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex3", GL_RGBA8, 92, 84, 13, 19, 56, 61, 69, 3, 0, 8},
4127*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex4", GL_RGBA8, 92, 84, 13, 19, 56, 61, 69, 3, 7, 8},
4128*35238bceSAndroid Build Coastguard Worker                      {"rgba32f_complex", GL_RGBA32F, 92, 84, 13, 19, 56, 61, 69, 3, 7, 8}};
4129*35238bceSAndroid Build Coastguard Worker 
4130*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
4131*35238bceSAndroid Build Coastguard Worker             paramGroup->addChild(new TexSubImage2DParamsCase(
4132*35238bceSAndroid Build Coastguard Worker                 m_context, cases[ndx].name, "", cases[ndx].format, cases[ndx].width, cases[ndx].height, cases[ndx].subX,
4133*35238bceSAndroid Build Coastguard Worker                 cases[ndx].subY, cases[ndx].subW, cases[ndx].subH, cases[ndx].rowLength, cases[ndx].skipRows,
4134*35238bceSAndroid Build Coastguard Worker                 cases[ndx].skipPixels, cases[ndx].alignment));
4135*35238bceSAndroid Build Coastguard Worker     }
4136*35238bceSAndroid Build Coastguard Worker 
4137*35238bceSAndroid Build Coastguard Worker     // glTexSubImage2D() PBO cases.
4138*35238bceSAndroid Build Coastguard Worker     {
4139*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *pboGroup =
4140*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_pbo", "glTexSubImage2D() pixel buffer object tests");
4141*35238bceSAndroid Build Coastguard Worker         addChild(pboGroup);
4142*35238bceSAndroid Build Coastguard Worker 
4143*35238bceSAndroid Build Coastguard Worker         static const struct
4144*35238bceSAndroid Build Coastguard Worker         {
4145*35238bceSAndroid Build Coastguard Worker             const char *name;
4146*35238bceSAndroid Build Coastguard Worker             uint32_t format;
4147*35238bceSAndroid Build Coastguard Worker             int width;
4148*35238bceSAndroid Build Coastguard Worker             int height;
4149*35238bceSAndroid Build Coastguard Worker             int subX;
4150*35238bceSAndroid Build Coastguard Worker             int subY;
4151*35238bceSAndroid Build Coastguard Worker             int subW;
4152*35238bceSAndroid Build Coastguard Worker             int subH;
4153*35238bceSAndroid Build Coastguard Worker             int rowLength;
4154*35238bceSAndroid Build Coastguard Worker             int skipRows;
4155*35238bceSAndroid Build Coastguard Worker             int skipPixels;
4156*35238bceSAndroid Build Coastguard Worker             int alignment;
4157*35238bceSAndroid Build Coastguard Worker             int offset;
4158*35238bceSAndroid Build Coastguard Worker         } paramCases[] = {{"rgb8_offset", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 0, 0, 4, 67},
4159*35238bceSAndroid Build Coastguard Worker                           {"rgb8_alignment", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 0, 0, 2, 0},
4160*35238bceSAndroid Build Coastguard Worker                           {"rgb8_row_length", GL_RGB8, 54, 60, 11, 7, 31, 30, 50, 0, 0, 4, 0},
4161*35238bceSAndroid Build Coastguard Worker                           {"rgb8_skip_rows", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 3, 0, 4, 0},
4162*35238bceSAndroid Build Coastguard Worker                           {"rgb8_skip_pixels", GL_RGB8, 54, 60, 11, 7, 31, 30, 36, 0, 5, 4, 0}};
4163*35238bceSAndroid Build Coastguard Worker 
4164*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorFormats); ndx++)
4165*35238bceSAndroid Build Coastguard Worker         {
4166*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexSubImage2DBufferCase(
4167*35238bceSAndroid Build Coastguard Worker                 m_context, (std::string(colorFormats[ndx].name) + "_2d").c_str(), "", colorFormats[ndx].internalFormat,
4168*35238bceSAndroid Build Coastguard Worker                 54, // Width
4169*35238bceSAndroid Build Coastguard Worker                 60, // Height
4170*35238bceSAndroid Build Coastguard Worker                 11, // Sub X
4171*35238bceSAndroid Build Coastguard Worker                 7,  // Sub Y
4172*35238bceSAndroid Build Coastguard Worker                 31, // Sub W
4173*35238bceSAndroid Build Coastguard Worker                 30, // Sub H
4174*35238bceSAndroid Build Coastguard Worker                 0,  // Row len
4175*35238bceSAndroid Build Coastguard Worker                 0,  // Skip rows
4176*35238bceSAndroid Build Coastguard Worker                 0,  // Skip pixels
4177*35238bceSAndroid Build Coastguard Worker                 4,  // Alignment
4178*35238bceSAndroid Build Coastguard Worker                 0 /* offset */));
4179*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexSubImageCubeBufferCase(m_context,
4180*35238bceSAndroid Build Coastguard Worker                                                              (std::string(colorFormats[ndx].name) + "_cube").c_str(),
4181*35238bceSAndroid Build Coastguard Worker                                                              "", colorFormats[ndx].internalFormat,
4182*35238bceSAndroid Build Coastguard Worker                                                              64, // Size
4183*35238bceSAndroid Build Coastguard Worker                                                              11, // Sub X
4184*35238bceSAndroid Build Coastguard Worker                                                              7,  // Sub Y
4185*35238bceSAndroid Build Coastguard Worker                                                              31, // Sub W
4186*35238bceSAndroid Build Coastguard Worker                                                              30, // Sub H
4187*35238bceSAndroid Build Coastguard Worker                                                              0,  // Row len
4188*35238bceSAndroid Build Coastguard Worker                                                              0,  // Skip rows
4189*35238bceSAndroid Build Coastguard Worker                                                              0,  // Skip pixels
4190*35238bceSAndroid Build Coastguard Worker                                                              4,  // Alignment
4191*35238bceSAndroid Build Coastguard Worker                                                              0 /* offset */));
4192*35238bceSAndroid Build Coastguard Worker         }
4193*35238bceSAndroid Build Coastguard Worker 
4194*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(paramCases); ndx++)
4195*35238bceSAndroid Build Coastguard Worker         {
4196*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexSubImage2DBufferCase(
4197*35238bceSAndroid Build Coastguard Worker                 m_context, (std::string(paramCases[ndx].name) + "_2d").c_str(), "", paramCases[ndx].format,
4198*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].width, paramCases[ndx].height, paramCases[ndx].subX, paramCases[ndx].subY,
4199*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].subW, paramCases[ndx].subH, paramCases[ndx].rowLength, paramCases[ndx].skipRows,
4200*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].skipPixels, paramCases[ndx].alignment, paramCases[ndx].offset));
4201*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexSubImageCubeBufferCase(
4202*35238bceSAndroid Build Coastguard Worker                 m_context, (std::string(paramCases[ndx].name) + "_cube").c_str(), "", paramCases[ndx].format,
4203*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].width, paramCases[ndx].subX, paramCases[ndx].subY, paramCases[ndx].subW,
4204*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].subH, paramCases[ndx].rowLength, paramCases[ndx].skipRows, paramCases[ndx].skipPixels,
4205*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].alignment, paramCases[ndx].offset));
4206*35238bceSAndroid Build Coastguard Worker         }
4207*35238bceSAndroid Build Coastguard Worker 
4208*35238bceSAndroid Build Coastguard Worker         // This test makes sure the last bits from the PBO data can be read without errors.
4209*35238bceSAndroid Build Coastguard Worker         pboGroup->addChild(new CopyTexFromPBOCase(m_context, "pbo_bounds_2d",
4210*35238bceSAndroid Build Coastguard Worker                                                   "Checks the last bits are read from the PBO without errors"));
4211*35238bceSAndroid Build Coastguard Worker     }
4212*35238bceSAndroid Build Coastguard Worker 
4213*35238bceSAndroid Build Coastguard Worker     // glTexSubImage2D() depth cases.
4214*35238bceSAndroid Build Coastguard Worker     {
4215*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *shadow2dGroup = new tcu::TestCaseGroup(
4216*35238bceSAndroid Build Coastguard Worker             m_testCtx, "texsubimage2d_depth", "glTexSubImage2D() with depth or depth/stencil format");
4217*35238bceSAndroid Build Coastguard Worker         addChild(shadow2dGroup);
4218*35238bceSAndroid Build Coastguard Worker 
4219*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
4220*35238bceSAndroid Build Coastguard Worker         {
4221*35238bceSAndroid Build Coastguard Worker             const int tex2DWidth  = 64;
4222*35238bceSAndroid Build Coastguard Worker             const int tex2DHeight = 32;
4223*35238bceSAndroid Build Coastguard Worker 
4224*35238bceSAndroid Build Coastguard Worker             shadow2dGroup->addChild(new TexSubImage2DDepthCase(m_context, depthStencilFormats[ndx].name, "",
4225*35238bceSAndroid Build Coastguard Worker                                                                depthStencilFormats[ndx].internalFormat, tex2DWidth,
4226*35238bceSAndroid Build Coastguard Worker                                                                tex2DHeight));
4227*35238bceSAndroid Build Coastguard Worker         }
4228*35238bceSAndroid Build Coastguard Worker     }
4229*35238bceSAndroid Build Coastguard Worker 
4230*35238bceSAndroid Build Coastguard Worker     // Basic glCopyTexImage2D() cases
4231*35238bceSAndroid Build Coastguard Worker     {
4232*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *copyTexImageGroup =
4233*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "basic_copyteximage2d", "Basic glCopyTexImage2D() usage");
4234*35238bceSAndroid Build Coastguard Worker         addChild(copyTexImageGroup);
4235*35238bceSAndroid Build Coastguard Worker 
4236*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(new BasicCopyTexImage2DCase(m_context, "2d_alpha", "", GL_ALPHA, 128, 64));
4237*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(new BasicCopyTexImage2DCase(m_context, "2d_luminance", "", GL_LUMINANCE, 128, 64));
4238*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(
4239*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexImage2DCase(m_context, "2d_luminance_alpha", "", GL_LUMINANCE_ALPHA, 128, 64));
4240*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(new BasicCopyTexImage2DCase(m_context, "2d_rgb", "", GL_RGB, 128, 64));
4241*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(new BasicCopyTexImage2DCase(m_context, "2d_rgba", "", GL_RGBA, 128, 64));
4242*35238bceSAndroid Build Coastguard Worker 
4243*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase(m_context, "cube_alpha", "", GL_ALPHA, 64));
4244*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase(m_context, "cube_luminance", "", GL_LUMINANCE, 64));
4245*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(
4246*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexImageCubeCase(m_context, "cube_luminance_alpha", "", GL_LUMINANCE_ALPHA, 64));
4247*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase(m_context, "cube_rgb", "", GL_RGB, 64));
4248*35238bceSAndroid Build Coastguard Worker         copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase(m_context, "cube_rgba", "", GL_RGBA, 64));
4249*35238bceSAndroid Build Coastguard Worker     }
4250*35238bceSAndroid Build Coastguard Worker 
4251*35238bceSAndroid Build Coastguard Worker     // Basic glCopyTexSubImage2D() cases
4252*35238bceSAndroid Build Coastguard Worker     {
4253*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *copyTexSubImageGroup =
4254*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "basic_copytexsubimage2d", "Basic glCopyTexSubImage2D() usage");
4255*35238bceSAndroid Build Coastguard Worker         addChild(copyTexSubImageGroup);
4256*35238bceSAndroid Build Coastguard Worker 
4257*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(
4258*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexSubImage2DCase(m_context, "2d_alpha", "", GL_ALPHA, GL_UNSIGNED_BYTE, 128, 64));
4259*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(
4260*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexSubImage2DCase(m_context, "2d_luminance", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 128, 64));
4261*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase(m_context, "2d_luminance_alpha", "",
4262*35238bceSAndroid Build Coastguard Worker                                                                       GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 128, 64));
4263*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(
4264*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexSubImage2DCase(m_context, "2d_rgb", "", GL_RGB, GL_UNSIGNED_BYTE, 128, 64));
4265*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(
4266*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexSubImage2DCase(m_context, "2d_rgba", "", GL_RGBA, GL_UNSIGNED_BYTE, 128, 64));
4267*35238bceSAndroid Build Coastguard Worker 
4268*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(
4269*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexSubImageCubeCase(m_context, "cube_alpha", "", GL_ALPHA, GL_UNSIGNED_BYTE, 64));
4270*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(
4271*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexSubImageCubeCase(m_context, "cube_luminance", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64));
4272*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase(m_context, "cube_luminance_alpha", "",
4273*35238bceSAndroid Build Coastguard Worker                                                                         GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 64));
4274*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(
4275*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexSubImageCubeCase(m_context, "cube_rgb", "", GL_RGB, GL_UNSIGNED_BYTE, 64));
4276*35238bceSAndroid Build Coastguard Worker         copyTexSubImageGroup->addChild(
4277*35238bceSAndroid Build Coastguard Worker             new BasicCopyTexSubImageCubeCase(m_context, "cube_rgba", "", GL_RGBA, GL_UNSIGNED_BYTE, 64));
4278*35238bceSAndroid Build Coastguard Worker     }
4279*35238bceSAndroid Build Coastguard Worker 
4280*35238bceSAndroid Build Coastguard Worker     // Basic TexImage3D usage.
4281*35238bceSAndroid Build Coastguard Worker     {
4282*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *basicTexImageGroup =
4283*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "basic_teximage3d", "Basic glTexImage3D() usage");
4284*35238bceSAndroid Build Coastguard Worker         addChild(basicTexImageGroup);
4285*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
4286*35238bceSAndroid Build Coastguard Worker         {
4287*35238bceSAndroid Build Coastguard Worker             const char *fmtName        = colorFormats[formatNdx].name;
4288*35238bceSAndroid Build Coastguard Worker             uint32_t format            = colorFormats[formatNdx].internalFormat;
4289*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayWidth  = 57;
4290*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayHeight = 44;
4291*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayLevels = 5;
4292*35238bceSAndroid Build Coastguard Worker             const int tex3DWidth       = 63;
4293*35238bceSAndroid Build Coastguard Worker             const int tex3DHeight      = 29;
4294*35238bceSAndroid Build Coastguard Worker             const int tex3DDepth       = 11;
4295*35238bceSAndroid Build Coastguard Worker 
4296*35238bceSAndroid Build Coastguard Worker             basicTexImageGroup->addChild(
4297*35238bceSAndroid Build Coastguard Worker                 new BasicTexImage2DArrayCase(m_context, (string(fmtName) + "_2d_array").c_str(), "", format,
4298*35238bceSAndroid Build Coastguard Worker                                              tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLevels));
4299*35238bceSAndroid Build Coastguard Worker             basicTexImageGroup->addChild(new BasicTexImage3DCase(m_context, (string(fmtName) + "_3d").c_str(), "",
4300*35238bceSAndroid Build Coastguard Worker                                                                  format, tex3DWidth, tex3DHeight, tex3DDepth));
4301*35238bceSAndroid Build Coastguard Worker         }
4302*35238bceSAndroid Build Coastguard Worker     }
4303*35238bceSAndroid Build Coastguard Worker 
4304*35238bceSAndroid Build Coastguard Worker     // glTexImage3D() unpack params cases.
4305*35238bceSAndroid Build Coastguard Worker     {
4306*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *paramGroup =
4307*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "teximage3d_unpack_params", "glTexImage3D() unpack parameters");
4308*35238bceSAndroid Build Coastguard Worker         addChild(paramGroup);
4309*35238bceSAndroid Build Coastguard Worker 
4310*35238bceSAndroid Build Coastguard Worker         static const struct
4311*35238bceSAndroid Build Coastguard Worker         {
4312*35238bceSAndroid Build Coastguard Worker             const char *name;
4313*35238bceSAndroid Build Coastguard Worker             uint32_t format;
4314*35238bceSAndroid Build Coastguard Worker             int width;
4315*35238bceSAndroid Build Coastguard Worker             int height;
4316*35238bceSAndroid Build Coastguard Worker             int depth;
4317*35238bceSAndroid Build Coastguard Worker             int imageHeight;
4318*35238bceSAndroid Build Coastguard Worker             int rowLength;
4319*35238bceSAndroid Build Coastguard Worker             int skipImages;
4320*35238bceSAndroid Build Coastguard Worker             int skipRows;
4321*35238bceSAndroid Build Coastguard Worker             int skipPixels;
4322*35238bceSAndroid Build Coastguard Worker             int alignment;
4323*35238bceSAndroid Build Coastguard Worker         } cases[] = {{"rgb8_image_height", GL_RGB8, 23, 19, 8, 26, 0, 0, 0, 0, 4},
4324*35238bceSAndroid Build Coastguard Worker                      {"rgb8_row_length", GL_RGB8, 23, 19, 8, 0, 27, 0, 0, 0, 4},
4325*35238bceSAndroid Build Coastguard Worker                      {"rgb8_skip_images", GL_RGB8, 23, 19, 8, 0, 0, 3, 0, 0, 4},
4326*35238bceSAndroid Build Coastguard Worker                      {"rgb8_skip_rows", GL_RGB8, 23, 19, 8, 22, 0, 0, 3, 0, 4},
4327*35238bceSAndroid Build Coastguard Worker                      {"rgb8_skip_pixels", GL_RGB8, 23, 19, 8, 0, 25, 0, 0, 2, 4},
4328*35238bceSAndroid Build Coastguard Worker                      {"r8_complex1", GL_R8, 13, 17, 11, 23, 15, 2, 3, 1, 1},
4329*35238bceSAndroid Build Coastguard Worker                      {"r8_complex2", GL_R8, 13, 17, 11, 23, 15, 2, 3, 1, 2},
4330*35238bceSAndroid Build Coastguard Worker                      {"r8_complex3", GL_R8, 13, 17, 11, 23, 15, 2, 3, 1, 4},
4331*35238bceSAndroid Build Coastguard Worker                      {"r8_complex4", GL_R8, 13, 17, 11, 23, 15, 2, 3, 1, 8},
4332*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex1", GL_RGBA8, 11, 20, 8, 25, 14, 0, 0, 0, 8},
4333*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex2", GL_RGBA8, 11, 20, 8, 25, 14, 0, 2, 0, 8},
4334*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex3", GL_RGBA8, 11, 20, 8, 25, 14, 0, 0, 3, 8},
4335*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex4", GL_RGBA8, 11, 20, 8, 25, 14, 0, 2, 3, 8},
4336*35238bceSAndroid Build Coastguard Worker                      {"rgba32f_complex", GL_RGBA32F, 11, 20, 8, 25, 14, 0, 2, 3, 8}};
4337*35238bceSAndroid Build Coastguard Worker 
4338*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
4339*35238bceSAndroid Build Coastguard Worker             paramGroup->addChild(new TexImage3DParamsCase(
4340*35238bceSAndroid Build Coastguard Worker                 m_context, cases[ndx].name, "", cases[ndx].format, cases[ndx].width, cases[ndx].height,
4341*35238bceSAndroid Build Coastguard Worker                 cases[ndx].depth, cases[ndx].imageHeight, cases[ndx].rowLength, cases[ndx].skipImages,
4342*35238bceSAndroid Build Coastguard Worker                 cases[ndx].skipRows, cases[ndx].skipPixels, cases[ndx].alignment));
4343*35238bceSAndroid Build Coastguard Worker     }
4344*35238bceSAndroid Build Coastguard Worker 
4345*35238bceSAndroid Build Coastguard Worker     // glTexImage3D() pbo cases.
4346*35238bceSAndroid Build Coastguard Worker     {
4347*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *pboGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_pbo", "glTexImage3D() from PBO");
4348*35238bceSAndroid Build Coastguard Worker         addChild(pboGroup);
4349*35238bceSAndroid Build Coastguard Worker 
4350*35238bceSAndroid Build Coastguard Worker         // Parameter cases
4351*35238bceSAndroid Build Coastguard Worker         static const struct
4352*35238bceSAndroid Build Coastguard Worker         {
4353*35238bceSAndroid Build Coastguard Worker             const char *name;
4354*35238bceSAndroid Build Coastguard Worker             uint32_t format;
4355*35238bceSAndroid Build Coastguard Worker             int width;
4356*35238bceSAndroid Build Coastguard Worker             int height;
4357*35238bceSAndroid Build Coastguard Worker             int depth;
4358*35238bceSAndroid Build Coastguard Worker             int imageHeight;
4359*35238bceSAndroid Build Coastguard Worker             int rowLength;
4360*35238bceSAndroid Build Coastguard Worker             int skipImages;
4361*35238bceSAndroid Build Coastguard Worker             int skipRows;
4362*35238bceSAndroid Build Coastguard Worker             int skipPixels;
4363*35238bceSAndroid Build Coastguard Worker             int alignment;
4364*35238bceSAndroid Build Coastguard Worker             int offset;
4365*35238bceSAndroid Build Coastguard Worker         } parameterCases[] = {{"rgb8_offset", GL_RGB8, 23, 19, 8, 0, 0, 0, 0, 0, 1, 67},
4366*35238bceSAndroid Build Coastguard Worker                               {"rgb8_alignment", GL_RGB8, 23, 19, 8, 0, 0, 0, 0, 0, 2, 0},
4367*35238bceSAndroid Build Coastguard Worker                               {"rgb8_image_height", GL_RGB8, 23, 19, 8, 26, 0, 0, 0, 0, 4, 0},
4368*35238bceSAndroid Build Coastguard Worker                               {"rgb8_row_length", GL_RGB8, 23, 19, 8, 0, 27, 0, 0, 0, 4, 0},
4369*35238bceSAndroid Build Coastguard Worker                               {"rgb8_skip_images", GL_RGB8, 23, 19, 8, 0, 0, 3, 0, 0, 4, 0},
4370*35238bceSAndroid Build Coastguard Worker                               {"rgb8_skip_rows", GL_RGB8, 23, 19, 8, 22, 0, 0, 3, 0, 4, 0},
4371*35238bceSAndroid Build Coastguard Worker                               {"rgb8_skip_pixels", GL_RGB8, 23, 19, 8, 0, 25, 0, 0, 2, 4, 0}};
4372*35238bceSAndroid Build Coastguard Worker 
4373*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
4374*35238bceSAndroid Build Coastguard Worker         {
4375*35238bceSAndroid Build Coastguard Worker             const string fmtName  = colorFormats[formatNdx].name;
4376*35238bceSAndroid Build Coastguard Worker             const uint32_t format = colorFormats[formatNdx].internalFormat;
4377*35238bceSAndroid Build Coastguard Worker             const int tex3DWidth  = 11;
4378*35238bceSAndroid Build Coastguard Worker             const int tex3DHeight = 20;
4379*35238bceSAndroid Build Coastguard Worker             const int tex3DDepth  = 8;
4380*35238bceSAndroid Build Coastguard Worker 
4381*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexImage2DArrayBufferCase(m_context, (fmtName + "_2d_array").c_str(), "", format,
4382*35238bceSAndroid Build Coastguard Worker                                                              tex3DWidth, tex3DHeight, tex3DDepth, 0, 0, 0, 0, 0, 4, 0));
4383*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexImage3DBufferCase(m_context, (fmtName + "_3d").c_str(), "", format, tex3DWidth,
4384*35238bceSAndroid Build Coastguard Worker                                                         tex3DHeight, tex3DDepth, 0, 0, 0, 0, 0, 4, 0));
4385*35238bceSAndroid Build Coastguard Worker         }
4386*35238bceSAndroid Build Coastguard Worker 
4387*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(parameterCases); ndx++)
4388*35238bceSAndroid Build Coastguard Worker         {
4389*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexImage2DArrayBufferCase(
4390*35238bceSAndroid Build Coastguard Worker                 m_context, (string(parameterCases[ndx].name) + "_2d_array").c_str(), "", parameterCases[ndx].format,
4391*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].width, parameterCases[ndx].depth, parameterCases[ndx].height,
4392*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].imageHeight, parameterCases[ndx].rowLength, parameterCases[ndx].skipImages,
4393*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].skipRows, parameterCases[ndx].skipPixels, parameterCases[ndx].alignment,
4394*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].offset));
4395*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexImage3DBufferCase(
4396*35238bceSAndroid Build Coastguard Worker                 m_context, (string(parameterCases[ndx].name) + "_3d").c_str(), "", parameterCases[ndx].format,
4397*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].width, parameterCases[ndx].depth, parameterCases[ndx].height,
4398*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].imageHeight, parameterCases[ndx].rowLength, parameterCases[ndx].skipImages,
4399*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].skipRows, parameterCases[ndx].skipPixels, parameterCases[ndx].alignment,
4400*35238bceSAndroid Build Coastguard Worker                 parameterCases[ndx].offset));
4401*35238bceSAndroid Build Coastguard Worker         }
4402*35238bceSAndroid Build Coastguard Worker     }
4403*35238bceSAndroid Build Coastguard Worker 
4404*35238bceSAndroid Build Coastguard Worker     // glTexImage3D() depth cases.
4405*35238bceSAndroid Build Coastguard Worker     {
4406*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *shadow3dGroup =
4407*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "teximage3d_depth", "glTexImage3D() with depth or depth/stencil format");
4408*35238bceSAndroid Build Coastguard Worker         addChild(shadow3dGroup);
4409*35238bceSAndroid Build Coastguard Worker 
4410*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
4411*35238bceSAndroid Build Coastguard Worker         {
4412*35238bceSAndroid Build Coastguard Worker             const int tex3DWidth  = 32;
4413*35238bceSAndroid Build Coastguard Worker             const int tex3DHeight = 64;
4414*35238bceSAndroid Build Coastguard Worker             const int tex3DDepth  = 8;
4415*35238bceSAndroid Build Coastguard Worker 
4416*35238bceSAndroid Build Coastguard Worker             shadow3dGroup->addChild(new TexImage2DArrayDepthCase(
4417*35238bceSAndroid Build Coastguard Worker                 m_context, (std::string(depthStencilFormats[ndx].name) + "_2d_array").c_str(), "",
4418*35238bceSAndroid Build Coastguard Worker                 depthStencilFormats[ndx].internalFormat, tex3DWidth, tex3DHeight, tex3DDepth));
4419*35238bceSAndroid Build Coastguard Worker         }
4420*35238bceSAndroid Build Coastguard Worker     }
4421*35238bceSAndroid Build Coastguard Worker 
4422*35238bceSAndroid Build Coastguard Worker     // glTexImage3D() depth cases with pbo.
4423*35238bceSAndroid Build Coastguard Worker     {
4424*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *shadow3dGroup = new tcu::TestCaseGroup(
4425*35238bceSAndroid Build Coastguard Worker             m_testCtx, "teximage3d_depth_pbo", "glTexImage3D() with depth or depth/stencil format with pbo");
4426*35238bceSAndroid Build Coastguard Worker         addChild(shadow3dGroup);
4427*35238bceSAndroid Build Coastguard Worker 
4428*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
4429*35238bceSAndroid Build Coastguard Worker         {
4430*35238bceSAndroid Build Coastguard Worker             const int tex3DWidth  = 32;
4431*35238bceSAndroid Build Coastguard Worker             const int tex3DHeight = 64;
4432*35238bceSAndroid Build Coastguard Worker             const int tex3DDepth  = 8;
4433*35238bceSAndroid Build Coastguard Worker 
4434*35238bceSAndroid Build Coastguard Worker             shadow3dGroup->addChild(new TexImage2DArrayDepthBufferCase(
4435*35238bceSAndroid Build Coastguard Worker                 m_context, (std::string(depthStencilFormats[ndx].name) + "_2d_array").c_str(), "",
4436*35238bceSAndroid Build Coastguard Worker                 depthStencilFormats[ndx].internalFormat, tex3DWidth, tex3DHeight, tex3DDepth));
4437*35238bceSAndroid Build Coastguard Worker         }
4438*35238bceSAndroid Build Coastguard Worker     }
4439*35238bceSAndroid Build Coastguard Worker 
4440*35238bceSAndroid Build Coastguard Worker     // Basic TexSubImage3D usage.
4441*35238bceSAndroid Build Coastguard Worker     {
4442*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *basicTexSubImageGroup =
4443*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "basic_texsubimage3d", "Basic glTexSubImage3D() usage");
4444*35238bceSAndroid Build Coastguard Worker         addChild(basicTexSubImageGroup);
4445*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
4446*35238bceSAndroid Build Coastguard Worker         {
4447*35238bceSAndroid Build Coastguard Worker             const char *fmtName   = colorFormats[formatNdx].name;
4448*35238bceSAndroid Build Coastguard Worker             uint32_t format       = colorFormats[formatNdx].internalFormat;
4449*35238bceSAndroid Build Coastguard Worker             const int tex3DWidth  = 32;
4450*35238bceSAndroid Build Coastguard Worker             const int tex3DHeight = 64;
4451*35238bceSAndroid Build Coastguard Worker             const int tex3DDepth  = 8;
4452*35238bceSAndroid Build Coastguard Worker 
4453*35238bceSAndroid Build Coastguard Worker             basicTexSubImageGroup->addChild(new BasicTexSubImage3DCase(m_context, (string(fmtName) + "_3d").c_str(), "",
4454*35238bceSAndroid Build Coastguard Worker                                                                        format, tex3DWidth, tex3DHeight, tex3DDepth));
4455*35238bceSAndroid Build Coastguard Worker         }
4456*35238bceSAndroid Build Coastguard Worker     }
4457*35238bceSAndroid Build Coastguard Worker 
4458*35238bceSAndroid Build Coastguard Worker     // glTexSubImage3D() unpack params cases.
4459*35238bceSAndroid Build Coastguard Worker     {
4460*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *paramGroup =
4461*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_unpack_params", "glTexSubImage3D() unpack parameters");
4462*35238bceSAndroid Build Coastguard Worker         addChild(paramGroup);
4463*35238bceSAndroid Build Coastguard Worker 
4464*35238bceSAndroid Build Coastguard Worker         static const struct
4465*35238bceSAndroid Build Coastguard Worker         {
4466*35238bceSAndroid Build Coastguard Worker             const char *name;
4467*35238bceSAndroid Build Coastguard Worker             uint32_t format;
4468*35238bceSAndroid Build Coastguard Worker             int width;
4469*35238bceSAndroid Build Coastguard Worker             int height;
4470*35238bceSAndroid Build Coastguard Worker             int depth;
4471*35238bceSAndroid Build Coastguard Worker             int subX;
4472*35238bceSAndroid Build Coastguard Worker             int subY;
4473*35238bceSAndroid Build Coastguard Worker             int subZ;
4474*35238bceSAndroid Build Coastguard Worker             int subW;
4475*35238bceSAndroid Build Coastguard Worker             int subH;
4476*35238bceSAndroid Build Coastguard Worker             int subD;
4477*35238bceSAndroid Build Coastguard Worker             int imageHeight;
4478*35238bceSAndroid Build Coastguard Worker             int rowLength;
4479*35238bceSAndroid Build Coastguard Worker             int skipImages;
4480*35238bceSAndroid Build Coastguard Worker             int skipRows;
4481*35238bceSAndroid Build Coastguard Worker             int skipPixels;
4482*35238bceSAndroid Build Coastguard Worker             int alignment;
4483*35238bceSAndroid Build Coastguard Worker         } cases[] = {{"rgb8_image_height", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 26, 0, 0, 0, 0, 4},
4484*35238bceSAndroid Build Coastguard Worker                      {"rgb8_row_length", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 27, 0, 0, 0, 4},
4485*35238bceSAndroid Build Coastguard Worker                      {"rgb8_skip_images", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 0, 3, 0, 0, 4},
4486*35238bceSAndroid Build Coastguard Worker                      {"rgb8_skip_rows", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 22, 0, 0, 3, 0, 4},
4487*35238bceSAndroid Build Coastguard Worker                      {"rgb8_skip_pixels", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 25, 0, 0, 2, 4},
4488*35238bceSAndroid Build Coastguard Worker                      {"r8_complex1", GL_R8, 15, 20, 11, 1, 1, 0, 13, 17, 11, 23, 15, 2, 3, 1, 1},
4489*35238bceSAndroid Build Coastguard Worker                      {"r8_complex2", GL_R8, 15, 20, 11, 1, 1, 0, 13, 17, 11, 23, 15, 2, 3, 1, 2},
4490*35238bceSAndroid Build Coastguard Worker                      {"r8_complex3", GL_R8, 15, 20, 11, 1, 1, 0, 13, 17, 11, 23, 15, 2, 3, 1, 4},
4491*35238bceSAndroid Build Coastguard Worker                      {"r8_complex4", GL_R8, 15, 20, 11, 1, 1, 0, 13, 17, 11, 23, 15, 2, 3, 1, 8},
4492*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex1", GL_RGBA8, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 0, 0, 8},
4493*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex2", GL_RGBA8, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 2, 0, 8},
4494*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex3", GL_RGBA8, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 0, 3, 8},
4495*35238bceSAndroid Build Coastguard Worker                      {"rgba8_complex4", GL_RGBA8, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 2, 3, 8},
4496*35238bceSAndroid Build Coastguard Worker                      {"rgba32f_complex", GL_RGBA32F, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 2, 3, 8}};
4497*35238bceSAndroid Build Coastguard Worker 
4498*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
4499*35238bceSAndroid Build Coastguard Worker             paramGroup->addChild(new TexSubImage3DParamsCase(
4500*35238bceSAndroid Build Coastguard Worker                 m_context, cases[ndx].name, "", cases[ndx].format, cases[ndx].width, cases[ndx].height,
4501*35238bceSAndroid Build Coastguard Worker                 cases[ndx].depth, cases[ndx].subX, cases[ndx].subY, cases[ndx].subZ, cases[ndx].subW, cases[ndx].subH,
4502*35238bceSAndroid Build Coastguard Worker                 cases[ndx].subD, cases[ndx].imageHeight, cases[ndx].rowLength, cases[ndx].skipImages,
4503*35238bceSAndroid Build Coastguard Worker                 cases[ndx].skipRows, cases[ndx].skipPixels, cases[ndx].alignment));
4504*35238bceSAndroid Build Coastguard Worker     }
4505*35238bceSAndroid Build Coastguard Worker 
4506*35238bceSAndroid Build Coastguard Worker     // glTexSubImage3D() PBO cases.
4507*35238bceSAndroid Build Coastguard Worker     {
4508*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *pboGroup =
4509*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_pbo", "glTexSubImage3D() pixel buffer object tests");
4510*35238bceSAndroid Build Coastguard Worker         addChild(pboGroup);
4511*35238bceSAndroid Build Coastguard Worker 
4512*35238bceSAndroid Build Coastguard Worker         static const struct
4513*35238bceSAndroid Build Coastguard Worker         {
4514*35238bceSAndroid Build Coastguard Worker             const char *name;
4515*35238bceSAndroid Build Coastguard Worker             uint32_t format;
4516*35238bceSAndroid Build Coastguard Worker             int width;
4517*35238bceSAndroid Build Coastguard Worker             int height;
4518*35238bceSAndroid Build Coastguard Worker             int depth;
4519*35238bceSAndroid Build Coastguard Worker             int subX;
4520*35238bceSAndroid Build Coastguard Worker             int subY;
4521*35238bceSAndroid Build Coastguard Worker             int subZ;
4522*35238bceSAndroid Build Coastguard Worker             int subW;
4523*35238bceSAndroid Build Coastguard Worker             int subH;
4524*35238bceSAndroid Build Coastguard Worker             int subD;
4525*35238bceSAndroid Build Coastguard Worker             int imageHeight;
4526*35238bceSAndroid Build Coastguard Worker             int rowLength;
4527*35238bceSAndroid Build Coastguard Worker             int skipImages;
4528*35238bceSAndroid Build Coastguard Worker             int skipRows;
4529*35238bceSAndroid Build Coastguard Worker             int skipPixels;
4530*35238bceSAndroid Build Coastguard Worker             int alignment;
4531*35238bceSAndroid Build Coastguard Worker             int offset;
4532*35238bceSAndroid Build Coastguard Worker         } paramCases[] = {{"rgb8_offset", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 0, 0, 0, 0, 4, 67},
4533*35238bceSAndroid Build Coastguard Worker                           {"rgb8_image_height", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 26, 0, 0, 0, 0, 4, 0},
4534*35238bceSAndroid Build Coastguard Worker                           {"rgb8_row_length", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 27, 0, 0, 0, 4, 0},
4535*35238bceSAndroid Build Coastguard Worker                           {"rgb8_skip_images", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 0, 3, 0, 0, 4, 0},
4536*35238bceSAndroid Build Coastguard Worker                           {"rgb8_skip_rows", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 22, 0, 0, 3, 0, 4, 0},
4537*35238bceSAndroid Build Coastguard Worker                           {"rgb8_skip_pixels", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 25, 0, 0, 2, 4, 0}};
4538*35238bceSAndroid Build Coastguard Worker 
4539*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorFormats); ndx++)
4540*35238bceSAndroid Build Coastguard Worker         {
4541*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(
4542*35238bceSAndroid Build Coastguard Worker                 new TexSubImage2DArrayBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_2d_array").c_str(),
4543*35238bceSAndroid Build Coastguard Worker                                                  "", colorFormats[ndx].internalFormat,
4544*35238bceSAndroid Build Coastguard Worker                                                  26, // Width
4545*35238bceSAndroid Build Coastguard Worker                                                  25, // Height
4546*35238bceSAndroid Build Coastguard Worker                                                  10, // Depth
4547*35238bceSAndroid Build Coastguard Worker                                                  1,  // Sub X
4548*35238bceSAndroid Build Coastguard Worker                                                  2,  // Sub Y
4549*35238bceSAndroid Build Coastguard Worker                                                  0,  // Sub Z
4550*35238bceSAndroid Build Coastguard Worker                                                  23, // Sub W
4551*35238bceSAndroid Build Coastguard Worker                                                  19, // Sub H
4552*35238bceSAndroid Build Coastguard Worker                                                  8,  // Sub D
4553*35238bceSAndroid Build Coastguard Worker                                                  0,  // Image height
4554*35238bceSAndroid Build Coastguard Worker                                                  0,  // Row length
4555*35238bceSAndroid Build Coastguard Worker                                                  0,  // Skip images
4556*35238bceSAndroid Build Coastguard Worker                                                  0,  // Skip rows
4557*35238bceSAndroid Build Coastguard Worker                                                  0,  // Skip pixels
4558*35238bceSAndroid Build Coastguard Worker                                                  4,  // Alignment
4559*35238bceSAndroid Build Coastguard Worker                                                  0 /* offset */));
4560*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexSubImage3DBufferCase(
4561*35238bceSAndroid Build Coastguard Worker                 m_context, (std::string(colorFormats[ndx].name) + "_3d").c_str(), "", colorFormats[ndx].internalFormat,
4562*35238bceSAndroid Build Coastguard Worker                 26, // Width
4563*35238bceSAndroid Build Coastguard Worker                 25, // Height
4564*35238bceSAndroid Build Coastguard Worker                 10, // Depth
4565*35238bceSAndroid Build Coastguard Worker                 1,  // Sub X
4566*35238bceSAndroid Build Coastguard Worker                 2,  // Sub Y
4567*35238bceSAndroid Build Coastguard Worker                 0,  // Sub Z
4568*35238bceSAndroid Build Coastguard Worker                 23, // Sub W
4569*35238bceSAndroid Build Coastguard Worker                 19, // Sub H
4570*35238bceSAndroid Build Coastguard Worker                 8,  // Sub D
4571*35238bceSAndroid Build Coastguard Worker                 0,  // Image height
4572*35238bceSAndroid Build Coastguard Worker                 0,  // Row length
4573*35238bceSAndroid Build Coastguard Worker                 0,  // Skip images
4574*35238bceSAndroid Build Coastguard Worker                 0,  // Skip rows
4575*35238bceSAndroid Build Coastguard Worker                 0,  // Skip pixels
4576*35238bceSAndroid Build Coastguard Worker                 4,  // Alignment
4577*35238bceSAndroid Build Coastguard Worker                 0 /* offset */));
4578*35238bceSAndroid Build Coastguard Worker         }
4579*35238bceSAndroid Build Coastguard Worker 
4580*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(paramCases); ndx++)
4581*35238bceSAndroid Build Coastguard Worker         {
4582*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexSubImage2DArrayBufferCase(
4583*35238bceSAndroid Build Coastguard Worker                 m_context, (std::string(paramCases[ndx].name) + "_2d_array").c_str(), "", paramCases[ndx].format,
4584*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].width, paramCases[ndx].height, paramCases[ndx].depth, paramCases[ndx].subX,
4585*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].subY, paramCases[ndx].subZ, paramCases[ndx].subW, paramCases[ndx].subH,
4586*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].subD, paramCases[ndx].imageHeight, paramCases[ndx].rowLength,
4587*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].skipImages, paramCases[ndx].skipRows, paramCases[ndx].skipPixels,
4588*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].alignment, paramCases[ndx].offset));
4589*35238bceSAndroid Build Coastguard Worker             pboGroup->addChild(new TexSubImage3DBufferCase(
4590*35238bceSAndroid Build Coastguard Worker                 m_context, (std::string(paramCases[ndx].name) + "_3d").c_str(), "", paramCases[ndx].format,
4591*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].width, paramCases[ndx].height, paramCases[ndx].depth, paramCases[ndx].subX,
4592*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].subY, paramCases[ndx].subZ, paramCases[ndx].subW, paramCases[ndx].subH,
4593*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].subD, paramCases[ndx].imageHeight, paramCases[ndx].rowLength,
4594*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].skipImages, paramCases[ndx].skipRows, paramCases[ndx].skipPixels,
4595*35238bceSAndroid Build Coastguard Worker                 paramCases[ndx].alignment, paramCases[ndx].offset));
4596*35238bceSAndroid Build Coastguard Worker         }
4597*35238bceSAndroid Build Coastguard Worker     }
4598*35238bceSAndroid Build Coastguard Worker 
4599*35238bceSAndroid Build Coastguard Worker     // glTexSubImage3D() depth cases.
4600*35238bceSAndroid Build Coastguard Worker     {
4601*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *shadow3dGroup = new tcu::TestCaseGroup(
4602*35238bceSAndroid Build Coastguard Worker             m_testCtx, "texsubimage3d_depth", "glTexSubImage3D() with depth or depth/stencil format");
4603*35238bceSAndroid Build Coastguard Worker         addChild(shadow3dGroup);
4604*35238bceSAndroid Build Coastguard Worker 
4605*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
4606*35238bceSAndroid Build Coastguard Worker         {
4607*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayWidth  = 57;
4608*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayHeight = 44;
4609*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayLevels = 5;
4610*35238bceSAndroid Build Coastguard Worker 
4611*35238bceSAndroid Build Coastguard Worker             shadow3dGroup->addChild(new TexSubImage2DArrayDepthCase(
4612*35238bceSAndroid Build Coastguard Worker                 m_context, (std::string(depthStencilFormats[ndx].name) + "_2d_array").c_str(), "",
4613*35238bceSAndroid Build Coastguard Worker                 depthStencilFormats[ndx].internalFormat, tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLevels));
4614*35238bceSAndroid Build Coastguard Worker         }
4615*35238bceSAndroid Build Coastguard Worker     }
4616*35238bceSAndroid Build Coastguard Worker 
4617*35238bceSAndroid Build Coastguard Worker     // glTexStorage2D() cases.
4618*35238bceSAndroid Build Coastguard Worker     {
4619*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *texStorageGroup =
4620*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "texstorage2d", "Basic glTexStorage2D() usage");
4621*35238bceSAndroid Build Coastguard Worker         addChild(texStorageGroup);
4622*35238bceSAndroid Build Coastguard Worker 
4623*35238bceSAndroid Build Coastguard Worker         // All formats.
4624*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *formatGroup =
4625*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "format", "glTexStorage2D() with all formats");
4626*35238bceSAndroid Build Coastguard Worker         texStorageGroup->addChild(formatGroup);
4627*35238bceSAndroid Build Coastguard Worker 
4628*35238bceSAndroid Build Coastguard Worker         // Color formats.
4629*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
4630*35238bceSAndroid Build Coastguard Worker         {
4631*35238bceSAndroid Build Coastguard Worker             const char *fmtName     = colorFormats[formatNdx].name;
4632*35238bceSAndroid Build Coastguard Worker             uint32_t internalFormat = colorFormats[formatNdx].internalFormat;
4633*35238bceSAndroid Build Coastguard Worker             const int tex2DWidth    = 117;
4634*35238bceSAndroid Build Coastguard Worker             const int tex2DHeight   = 97;
4635*35238bceSAndroid Build Coastguard Worker             int tex2DLevels         = maxLevelCount(tex2DWidth, tex2DHeight);
4636*35238bceSAndroid Build Coastguard Worker             const int cubeSize      = 57;
4637*35238bceSAndroid Build Coastguard Worker             int cubeLevels          = maxLevelCount(cubeSize, cubeSize);
4638*35238bceSAndroid Build Coastguard Worker 
4639*35238bceSAndroid Build Coastguard Worker             formatGroup->addChild(new BasicTexStorage2DCase(m_context, (string(fmtName) + "_2d").c_str(), "",
4640*35238bceSAndroid Build Coastguard Worker                                                             internalFormat, tex2DWidth, tex2DHeight, tex2DLevels));
4641*35238bceSAndroid Build Coastguard Worker             formatGroup->addChild(new BasicTexStorageCubeCase(m_context, (string(fmtName) + "_cube").c_str(), "",
4642*35238bceSAndroid Build Coastguard Worker                                                               internalFormat, cubeSize, cubeLevels));
4643*35238bceSAndroid Build Coastguard Worker         }
4644*35238bceSAndroid Build Coastguard Worker 
4645*35238bceSAndroid Build Coastguard Worker         // Depth / stencil formats.
4646*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); formatNdx++)
4647*35238bceSAndroid Build Coastguard Worker         {
4648*35238bceSAndroid Build Coastguard Worker             const char *fmtName     = depthStencilFormats[formatNdx].name;
4649*35238bceSAndroid Build Coastguard Worker             uint32_t internalFormat = depthStencilFormats[formatNdx].internalFormat;
4650*35238bceSAndroid Build Coastguard Worker             const int tex2DWidth    = 117;
4651*35238bceSAndroid Build Coastguard Worker             const int tex2DHeight   = 97;
4652*35238bceSAndroid Build Coastguard Worker             int tex2DLevels         = maxLevelCount(tex2DWidth, tex2DHeight);
4653*35238bceSAndroid Build Coastguard Worker             const int cubeSize      = 57;
4654*35238bceSAndroid Build Coastguard Worker             int cubeLevels          = maxLevelCount(cubeSize, cubeSize);
4655*35238bceSAndroid Build Coastguard Worker 
4656*35238bceSAndroid Build Coastguard Worker             formatGroup->addChild(new BasicTexStorage2DCase(m_context, (string(fmtName) + "_2d").c_str(), "",
4657*35238bceSAndroid Build Coastguard Worker                                                             internalFormat, tex2DWidth, tex2DHeight, tex2DLevels));
4658*35238bceSAndroid Build Coastguard Worker             formatGroup->addChild(new BasicTexStorageCubeCase(m_context, (string(fmtName) + "_cube").c_str(), "",
4659*35238bceSAndroid Build Coastguard Worker                                                               internalFormat, cubeSize, cubeLevels));
4660*35238bceSAndroid Build Coastguard Worker         }
4661*35238bceSAndroid Build Coastguard Worker 
4662*35238bceSAndroid Build Coastguard Worker         // Sizes.
4663*35238bceSAndroid Build Coastguard Worker         static const struct
4664*35238bceSAndroid Build Coastguard Worker         {
4665*35238bceSAndroid Build Coastguard Worker             int width;
4666*35238bceSAndroid Build Coastguard Worker             int height;
4667*35238bceSAndroid Build Coastguard Worker             int levels;
4668*35238bceSAndroid Build Coastguard Worker         } tex2DSizes[] = {//    W    H    L
4669*35238bceSAndroid Build Coastguard Worker                           {1, 1, 1}, {2, 2, 2}, {64, 32, 7}, {32, 64, 4}, {57, 63, 1}, {57, 63, 2}, {57, 63, 6}};
4670*35238bceSAndroid Build Coastguard Worker         static const struct
4671*35238bceSAndroid Build Coastguard Worker         {
4672*35238bceSAndroid Build Coastguard Worker             int size;
4673*35238bceSAndroid Build Coastguard Worker             int levels;
4674*35238bceSAndroid Build Coastguard Worker         } cubeSizes[] = {
4675*35238bceSAndroid Build Coastguard Worker             //    S    L
4676*35238bceSAndroid Build Coastguard Worker             {1, 1}, {2, 2}, {57, 1}, {57, 2}, {57, 6}, {64, 4}, {64, 7},
4677*35238bceSAndroid Build Coastguard Worker         };
4678*35238bceSAndroid Build Coastguard Worker 
4679*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *sizeGroup =
4680*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "size", "glTexStorage2D() with various sizes");
4681*35238bceSAndroid Build Coastguard Worker         texStorageGroup->addChild(sizeGroup);
4682*35238bceSAndroid Build Coastguard Worker 
4683*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(tex2DSizes); ndx++)
4684*35238bceSAndroid Build Coastguard Worker         {
4685*35238bceSAndroid Build Coastguard Worker             const uint32_t format = GL_RGBA8;
4686*35238bceSAndroid Build Coastguard Worker             int width             = tex2DSizes[ndx].width;
4687*35238bceSAndroid Build Coastguard Worker             int height            = tex2DSizes[ndx].height;
4688*35238bceSAndroid Build Coastguard Worker             int levels            = tex2DSizes[ndx].levels;
4689*35238bceSAndroid Build Coastguard Worker             string name           = string("2d_") + de::toString(width) + "x" + de::toString(height) + "_" +
4690*35238bceSAndroid Build Coastguard Worker                           de::toString(levels) + "_levels";
4691*35238bceSAndroid Build Coastguard Worker 
4692*35238bceSAndroid Build Coastguard Worker             sizeGroup->addChild(new BasicTexStorage2DCase(m_context, name.c_str(), "", format, width, height, levels));
4693*35238bceSAndroid Build Coastguard Worker         }
4694*35238bceSAndroid Build Coastguard Worker 
4695*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cubeSizes); ndx++)
4696*35238bceSAndroid Build Coastguard Worker         {
4697*35238bceSAndroid Build Coastguard Worker             const uint32_t format = GL_RGBA8;
4698*35238bceSAndroid Build Coastguard Worker             int size              = cubeSizes[ndx].size;
4699*35238bceSAndroid Build Coastguard Worker             int levels            = cubeSizes[ndx].levels;
4700*35238bceSAndroid Build Coastguard Worker             string name = string("cube_") + de::toString(size) + "x" + de::toString(size) + "_" + de::toString(levels) +
4701*35238bceSAndroid Build Coastguard Worker                           "_levels";
4702*35238bceSAndroid Build Coastguard Worker 
4703*35238bceSAndroid Build Coastguard Worker             sizeGroup->addChild(new BasicTexStorageCubeCase(m_context, name.c_str(), "", format, size, levels));
4704*35238bceSAndroid Build Coastguard Worker         }
4705*35238bceSAndroid Build Coastguard Worker     }
4706*35238bceSAndroid Build Coastguard Worker 
4707*35238bceSAndroid Build Coastguard Worker     // glTexStorage3D() cases.
4708*35238bceSAndroid Build Coastguard Worker     {
4709*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *texStorageGroup =
4710*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "texstorage3d", "Basic glTexStorage3D() usage");
4711*35238bceSAndroid Build Coastguard Worker         addChild(texStorageGroup);
4712*35238bceSAndroid Build Coastguard Worker 
4713*35238bceSAndroid Build Coastguard Worker         // All formats.
4714*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *formatGroup =
4715*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "format", "glTexStorage3D() with all formats");
4716*35238bceSAndroid Build Coastguard Worker         texStorageGroup->addChild(formatGroup);
4717*35238bceSAndroid Build Coastguard Worker 
4718*35238bceSAndroid Build Coastguard Worker         // Color formats.
4719*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
4720*35238bceSAndroid Build Coastguard Worker         {
4721*35238bceSAndroid Build Coastguard Worker             const char *fmtName        = colorFormats[formatNdx].name;
4722*35238bceSAndroid Build Coastguard Worker             uint32_t internalFormat    = colorFormats[formatNdx].internalFormat;
4723*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayWidth  = 57;
4724*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayHeight = 13;
4725*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayLayers = 7;
4726*35238bceSAndroid Build Coastguard Worker             int tex2DArrayLevels       = maxLevelCount(tex2DArrayWidth, tex2DArrayHeight);
4727*35238bceSAndroid Build Coastguard Worker             const int tex3DWidth       = 59;
4728*35238bceSAndroid Build Coastguard Worker             const int tex3DHeight      = 37;
4729*35238bceSAndroid Build Coastguard Worker             const int tex3DDepth       = 11;
4730*35238bceSAndroid Build Coastguard Worker             int tex3DLevels            = maxLevelCount(tex3DWidth, tex3DHeight, tex3DDepth);
4731*35238bceSAndroid Build Coastguard Worker 
4732*35238bceSAndroid Build Coastguard Worker             formatGroup->addChild(new BasicTexStorage2DArrayCase(m_context, (string(fmtName) + "_2d_array").c_str(), "",
4733*35238bceSAndroid Build Coastguard Worker                                                                  internalFormat, tex2DArrayWidth, tex2DArrayHeight,
4734*35238bceSAndroid Build Coastguard Worker                                                                  tex2DArrayLayers, tex2DArrayLevels));
4735*35238bceSAndroid Build Coastguard Worker             formatGroup->addChild(new BasicTexStorage3DCase(m_context, (string(fmtName) + "_3d").c_str(), "",
4736*35238bceSAndroid Build Coastguard Worker                                                             internalFormat, tex3DWidth, tex3DHeight, tex3DDepth,
4737*35238bceSAndroid Build Coastguard Worker                                                             tex3DLevels));
4738*35238bceSAndroid Build Coastguard Worker         }
4739*35238bceSAndroid Build Coastguard Worker 
4740*35238bceSAndroid Build Coastguard Worker         // Depth/stencil formats (only 2D texture array is supported).
4741*35238bceSAndroid Build Coastguard Worker         for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); formatNdx++)
4742*35238bceSAndroid Build Coastguard Worker         {
4743*35238bceSAndroid Build Coastguard Worker             const char *fmtName        = depthStencilFormats[formatNdx].name;
4744*35238bceSAndroid Build Coastguard Worker             uint32_t internalFormat    = depthStencilFormats[formatNdx].internalFormat;
4745*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayWidth  = 57;
4746*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayHeight = 13;
4747*35238bceSAndroid Build Coastguard Worker             const int tex2DArrayLayers = 7;
4748*35238bceSAndroid Build Coastguard Worker             int tex2DArrayLevels       = maxLevelCount(tex2DArrayWidth, tex2DArrayHeight);
4749*35238bceSAndroid Build Coastguard Worker 
4750*35238bceSAndroid Build Coastguard Worker             formatGroup->addChild(new BasicTexStorage2DArrayCase(m_context, (string(fmtName) + "_2d_array").c_str(), "",
4751*35238bceSAndroid Build Coastguard Worker                                                                  internalFormat, tex2DArrayWidth, tex2DArrayHeight,
4752*35238bceSAndroid Build Coastguard Worker                                                                  tex2DArrayLayers, tex2DArrayLevels));
4753*35238bceSAndroid Build Coastguard Worker         }
4754*35238bceSAndroid Build Coastguard Worker 
4755*35238bceSAndroid Build Coastguard Worker         // Sizes.
4756*35238bceSAndroid Build Coastguard Worker         static const struct
4757*35238bceSAndroid Build Coastguard Worker         {
4758*35238bceSAndroid Build Coastguard Worker             int width;
4759*35238bceSAndroid Build Coastguard Worker             int height;
4760*35238bceSAndroid Build Coastguard Worker             int layers;
4761*35238bceSAndroid Build Coastguard Worker             int levels;
4762*35238bceSAndroid Build Coastguard Worker         } tex2DArraySizes[] = {//    W    H    La    Le
4763*35238bceSAndroid Build Coastguard Worker                                {1, 1, 1, 1},   {2, 2, 2, 2},   {64, 32, 3, 7}, {32, 64, 3, 4},
4764*35238bceSAndroid Build Coastguard Worker                                {57, 63, 5, 1}, {57, 63, 5, 2}, {57, 63, 5, 6}};
4765*35238bceSAndroid Build Coastguard Worker         static const struct
4766*35238bceSAndroid Build Coastguard Worker         {
4767*35238bceSAndroid Build Coastguard Worker             int width;
4768*35238bceSAndroid Build Coastguard Worker             int height;
4769*35238bceSAndroid Build Coastguard Worker             int depth;
4770*35238bceSAndroid Build Coastguard Worker             int levels;
4771*35238bceSAndroid Build Coastguard Worker         } tex3DSizes[] = {//    W    H    D    L
4772*35238bceSAndroid Build Coastguard Worker                           {1, 1, 1, 1},    {2, 2, 2, 2},    {64, 32, 16, 7}, {32, 64, 16, 4},
4773*35238bceSAndroid Build Coastguard Worker                           {32, 16, 64, 4}, {57, 63, 11, 1}, {57, 63, 11, 2}, {57, 63, 11, 6}};
4774*35238bceSAndroid Build Coastguard Worker 
4775*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *sizeGroup =
4776*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "size", "glTexStorage2D() with various sizes");
4777*35238bceSAndroid Build Coastguard Worker         texStorageGroup->addChild(sizeGroup);
4778*35238bceSAndroid Build Coastguard Worker 
4779*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(tex2DArraySizes); ndx++)
4780*35238bceSAndroid Build Coastguard Worker         {
4781*35238bceSAndroid Build Coastguard Worker             const uint32_t format = GL_RGBA8;
4782*35238bceSAndroid Build Coastguard Worker             int width             = tex2DArraySizes[ndx].width;
4783*35238bceSAndroid Build Coastguard Worker             int height            = tex2DArraySizes[ndx].height;
4784*35238bceSAndroid Build Coastguard Worker             int layers            = tex2DArraySizes[ndx].layers;
4785*35238bceSAndroid Build Coastguard Worker             int levels            = tex2DArraySizes[ndx].levels;
4786*35238bceSAndroid Build Coastguard Worker             string name           = string("2d_array_") + de::toString(width) + "x" + de::toString(height) + "x" +
4787*35238bceSAndroid Build Coastguard Worker                           de::toString(layers) + "_" + de::toString(levels) + "_levels";
4788*35238bceSAndroid Build Coastguard Worker 
4789*35238bceSAndroid Build Coastguard Worker             sizeGroup->addChild(
4790*35238bceSAndroid Build Coastguard Worker                 new BasicTexStorage2DArrayCase(m_context, name.c_str(), "", format, width, height, layers, levels));
4791*35238bceSAndroid Build Coastguard Worker         }
4792*35238bceSAndroid Build Coastguard Worker 
4793*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(tex3DSizes); ndx++)
4794*35238bceSAndroid Build Coastguard Worker         {
4795*35238bceSAndroid Build Coastguard Worker             const uint32_t format = GL_RGBA8;
4796*35238bceSAndroid Build Coastguard Worker             int width             = tex3DSizes[ndx].width;
4797*35238bceSAndroid Build Coastguard Worker             int height            = tex3DSizes[ndx].height;
4798*35238bceSAndroid Build Coastguard Worker             int depth             = tex3DSizes[ndx].depth;
4799*35238bceSAndroid Build Coastguard Worker             int levels            = tex3DSizes[ndx].levels;
4800*35238bceSAndroid Build Coastguard Worker             string name = string("3d_") + de::toString(width) + "x" + de::toString(height) + "x" + de::toString(depth) +
4801*35238bceSAndroid Build Coastguard Worker                           "_" + de::toString(levels) + "_levels";
4802*35238bceSAndroid Build Coastguard Worker 
4803*35238bceSAndroid Build Coastguard Worker             sizeGroup->addChild(
4804*35238bceSAndroid Build Coastguard Worker                 new BasicTexStorage3DCase(m_context, name.c_str(), "", format, width, height, depth, levels));
4805*35238bceSAndroid Build Coastguard Worker         }
4806*35238bceSAndroid Build Coastguard Worker     }
4807*35238bceSAndroid Build Coastguard Worker }
4808*35238bceSAndroid Build Coastguard Worker 
4809*35238bceSAndroid Build Coastguard Worker } // namespace Functional
4810*35238bceSAndroid Build Coastguard Worker } // namespace gles3
4811*35238bceSAndroid Build Coastguard Worker } // namespace deqp
4812