1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 2.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 "es2fTextureSpecificationTests.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuImageCompare.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "gluTextureUtil.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "sglrContextUtil.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "sglrContextWrapper.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "sglrGLContext.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "sglrReferenceContext.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "glsTextureTestUtil.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "tcuFormatUtil.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "tcuVectorUtil.hpp"
41*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
42*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
43*35238bceSAndroid Build Coastguard Worker
44*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
45*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
46*35238bceSAndroid Build Coastguard Worker
47*35238bceSAndroid Build Coastguard Worker namespace deqp
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker namespace gles2
50*35238bceSAndroid Build Coastguard Worker {
51*35238bceSAndroid Build Coastguard Worker namespace Functional
52*35238bceSAndroid Build Coastguard Worker {
53*35238bceSAndroid Build Coastguard Worker
54*35238bceSAndroid Build Coastguard Worker using std::pair;
55*35238bceSAndroid Build Coastguard Worker using std::string;
56*35238bceSAndroid Build Coastguard Worker using std::vector;
57*35238bceSAndroid Build Coastguard Worker using tcu::IVec4;
58*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
59*35238bceSAndroid Build Coastguard Worker using tcu::UVec4;
60*35238bceSAndroid Build Coastguard Worker using tcu::Vec4;
61*35238bceSAndroid Build Coastguard Worker
mapGLUnsizedInternalFormat(uint32_t internalFormat)62*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat mapGLUnsizedInternalFormat(uint32_t internalFormat)
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker using tcu::TextureFormat;
65*35238bceSAndroid Build Coastguard Worker switch (internalFormat)
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker case GL_ALPHA:
68*35238bceSAndroid Build Coastguard Worker return TextureFormat(TextureFormat::A, TextureFormat::UNORM_INT8);
69*35238bceSAndroid Build Coastguard Worker case GL_LUMINANCE:
70*35238bceSAndroid Build Coastguard Worker return TextureFormat(TextureFormat::L, TextureFormat::UNORM_INT8);
71*35238bceSAndroid Build Coastguard Worker case GL_LUMINANCE_ALPHA:
72*35238bceSAndroid Build Coastguard Worker return TextureFormat(TextureFormat::LA, TextureFormat::UNORM_INT8);
73*35238bceSAndroid Build Coastguard Worker case GL_RGB:
74*35238bceSAndroid Build Coastguard Worker return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8);
75*35238bceSAndroid Build Coastguard Worker case GL_RGBA:
76*35238bceSAndroid Build Coastguard Worker return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8);
77*35238bceSAndroid Build Coastguard Worker default:
78*35238bceSAndroid Build Coastguard Worker throw tcu::InternalError(string("Can't map GL unsized internal format (") +
79*35238bceSAndroid Build Coastguard Worker tcu::toHex(internalFormat).toString() + ") to texture format");
80*35238bceSAndroid Build Coastguard Worker }
81*35238bceSAndroid Build Coastguard Worker }
82*35238bceSAndroid Build Coastguard Worker
83*35238bceSAndroid Build Coastguard Worker template <int Size>
84*35238bceSAndroid Build Coastguard Worker static tcu::Vector<float, Size> randomVector(de::Random &rnd,
85*35238bceSAndroid Build Coastguard Worker const tcu::Vector<float, Size> &minVal = tcu::Vector<float, Size>(0.0f),
86*35238bceSAndroid Build Coastguard Worker const tcu::Vector<float, Size> &maxVal = tcu::Vector<float, Size>(1.0f))
87*35238bceSAndroid Build Coastguard Worker {
88*35238bceSAndroid Build Coastguard Worker tcu::Vector<float, Size> res;
89*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < Size; ndx++)
90*35238bceSAndroid Build Coastguard Worker res[ndx] = rnd.getFloat(minVal[ndx], maxVal[ndx]);
91*35238bceSAndroid Build Coastguard Worker return res;
92*35238bceSAndroid Build Coastguard Worker }
93*35238bceSAndroid Build Coastguard Worker
getPixelFormatCompareDepth(const tcu::PixelFormat & pixelFormat,tcu::TextureFormat textureFormat)94*35238bceSAndroid Build Coastguard Worker static tcu::IVec4 getPixelFormatCompareDepth(const tcu::PixelFormat &pixelFormat, tcu::TextureFormat textureFormat)
95*35238bceSAndroid Build Coastguard Worker {
96*35238bceSAndroid Build Coastguard Worker switch (textureFormat.order)
97*35238bceSAndroid Build Coastguard Worker {
98*35238bceSAndroid Build Coastguard Worker case tcu::TextureFormat::L:
99*35238bceSAndroid Build Coastguard Worker case tcu::TextureFormat::LA:
100*35238bceSAndroid Build Coastguard Worker return tcu::IVec4(pixelFormat.redBits, pixelFormat.redBits, pixelFormat.redBits, pixelFormat.alphaBits);
101*35238bceSAndroid Build Coastguard Worker default:
102*35238bceSAndroid Build Coastguard Worker return tcu::IVec4(pixelFormat.redBits, pixelFormat.greenBits, pixelFormat.blueBits, pixelFormat.alphaBits);
103*35238bceSAndroid Build Coastguard Worker }
104*35238bceSAndroid Build Coastguard Worker }
105*35238bceSAndroid Build Coastguard Worker
computeCompareThreshold(const tcu::PixelFormat & pixelFormat,tcu::TextureFormat textureFormat)106*35238bceSAndroid Build Coastguard Worker static tcu::UVec4 computeCompareThreshold(const tcu::PixelFormat &pixelFormat, tcu::TextureFormat textureFormat)
107*35238bceSAndroid Build Coastguard Worker {
108*35238bceSAndroid Build Coastguard Worker const IVec4 texFormatBits = tcu::getTextureFormatBitDepth(textureFormat);
109*35238bceSAndroid Build Coastguard Worker const IVec4 pixelFormatBits = getPixelFormatCompareDepth(pixelFormat, textureFormat);
110*35238bceSAndroid Build Coastguard Worker const IVec4 accurateFmtBits = min(pixelFormatBits, texFormatBits);
111*35238bceSAndroid Build Coastguard Worker const IVec4 compareBits = select(accurateFmtBits, IVec4(8), greaterThan(accurateFmtBits, IVec4(0))) - 1;
112*35238bceSAndroid Build Coastguard Worker
113*35238bceSAndroid Build Coastguard Worker return (IVec4(1) << (8 - compareBits)).asUint();
114*35238bceSAndroid Build Coastguard Worker }
115*35238bceSAndroid Build Coastguard Worker
116*35238bceSAndroid Build Coastguard Worker class GradientShader : public sglr::ShaderProgram
117*35238bceSAndroid Build Coastguard Worker {
118*35238bceSAndroid Build Coastguard Worker public:
GradientShader(void)119*35238bceSAndroid Build Coastguard Worker GradientShader(void)
120*35238bceSAndroid Build Coastguard Worker : ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
121*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
122*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexAttribute("a_coord", rr::GENERICVECTYPE_FLOAT)
123*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
124*35238bceSAndroid Build Coastguard Worker << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
125*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
126*35238bceSAndroid Build Coastguard Worker "attribute mediump vec2 a_coord;\n"
127*35238bceSAndroid Build Coastguard Worker "varying mediump vec2 v_coord;\n"
128*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
129*35238bceSAndroid Build Coastguard Worker "{\n"
130*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
131*35238bceSAndroid Build Coastguard Worker " v_coord = a_coord;\n"
132*35238bceSAndroid Build Coastguard Worker "}\n")
133*35238bceSAndroid Build Coastguard Worker << sglr::pdec::FragmentSource("varying mediump vec2 v_coord;\n"
134*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
135*35238bceSAndroid Build Coastguard Worker "{\n"
136*35238bceSAndroid Build Coastguard Worker " mediump float x = v_coord.x;\n"
137*35238bceSAndroid Build Coastguard Worker " mediump float y = v_coord.y;\n"
138*35238bceSAndroid Build Coastguard Worker " mediump float f0 = (x + y) * 0.5;\n"
139*35238bceSAndroid Build Coastguard Worker " mediump float f1 = 0.5 + (x - y) * 0.5;\n"
140*35238bceSAndroid Build Coastguard Worker " gl_FragColor = vec4(f0, f1, 1.0-f0, 1.0-f1);\n"
141*35238bceSAndroid Build Coastguard Worker "}\n"))
142*35238bceSAndroid Build Coastguard Worker {
143*35238bceSAndroid Build Coastguard Worker }
144*35238bceSAndroid Build Coastguard Worker
shadeVertices(const rr::VertexAttrib * inputs,rr::VertexPacket * const * packets,const int numPackets) const145*35238bceSAndroid Build Coastguard Worker void shadeVertices(const rr::VertexAttrib *inputs, rr::VertexPacket *const *packets, const int numPackets) const
146*35238bceSAndroid Build Coastguard Worker {
147*35238bceSAndroid Build Coastguard Worker for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
148*35238bceSAndroid Build Coastguard Worker {
149*35238bceSAndroid Build Coastguard Worker rr::VertexPacket &packet = *packets[packetNdx];
150*35238bceSAndroid Build Coastguard Worker
151*35238bceSAndroid Build Coastguard Worker packet.position = rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
152*35238bceSAndroid Build Coastguard Worker packet.outputs[0] = rr::readVertexAttribFloat(inputs[1], packet.instanceNdx, packet.vertexNdx);
153*35238bceSAndroid Build Coastguard Worker }
154*35238bceSAndroid Build Coastguard Worker }
155*35238bceSAndroid Build Coastguard Worker
shadeFragments(rr::FragmentPacket * packets,const int numPackets,const rr::FragmentShadingContext & context) const156*35238bceSAndroid Build Coastguard Worker void shadeFragments(rr::FragmentPacket *packets, const int numPackets,
157*35238bceSAndroid Build Coastguard Worker const rr::FragmentShadingContext &context) const
158*35238bceSAndroid Build Coastguard Worker {
159*35238bceSAndroid Build Coastguard Worker for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
160*35238bceSAndroid Build Coastguard Worker for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
161*35238bceSAndroid Build Coastguard Worker {
162*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 coord = rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
163*35238bceSAndroid Build Coastguard Worker const float x = coord.x();
164*35238bceSAndroid Build Coastguard Worker const float y = coord.y();
165*35238bceSAndroid Build Coastguard Worker const float f0 = (x + y) * 0.5f;
166*35238bceSAndroid Build Coastguard Worker const float f1 = 0.5f + (x - y) * 0.5f;
167*35238bceSAndroid Build Coastguard Worker
168*35238bceSAndroid Build Coastguard Worker rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, tcu::Vec4(f0, f1, 1.0f - f0, 1.0f - f1));
169*35238bceSAndroid Build Coastguard Worker }
170*35238bceSAndroid Build Coastguard Worker }
171*35238bceSAndroid Build Coastguard Worker };
172*35238bceSAndroid Build Coastguard Worker
173*35238bceSAndroid Build Coastguard Worker class Tex2DShader : public sglr::ShaderProgram
174*35238bceSAndroid Build Coastguard Worker {
175*35238bceSAndroid Build Coastguard Worker public:
Tex2DShader(void)176*35238bceSAndroid Build Coastguard Worker Tex2DShader(void)
177*35238bceSAndroid Build Coastguard Worker : ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
178*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
179*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexAttribute("a_coord", rr::GENERICVECTYPE_FLOAT)
180*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
181*35238bceSAndroid Build Coastguard Worker << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
182*35238bceSAndroid Build Coastguard Worker << sglr::pdec::Uniform("u_sampler0", glu::TYPE_SAMPLER_2D)
183*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
184*35238bceSAndroid Build Coastguard Worker "attribute mediump vec2 a_coord;\n"
185*35238bceSAndroid Build Coastguard Worker "varying mediump vec2 v_coord;\n"
186*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
187*35238bceSAndroid Build Coastguard Worker "{\n"
188*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
189*35238bceSAndroid Build Coastguard Worker " v_coord = a_coord;\n"
190*35238bceSAndroid Build Coastguard Worker "}\n")
191*35238bceSAndroid Build Coastguard Worker << sglr::pdec::FragmentSource("uniform sampler2D u_sampler0;\n"
192*35238bceSAndroid Build Coastguard Worker "varying mediump vec2 v_coord;\n"
193*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
194*35238bceSAndroid Build Coastguard Worker "{\n"
195*35238bceSAndroid Build Coastguard Worker " gl_FragColor = texture2D(u_sampler0, v_coord);\n"
196*35238bceSAndroid Build Coastguard Worker "}\n"))
197*35238bceSAndroid Build Coastguard Worker {
198*35238bceSAndroid Build Coastguard Worker }
199*35238bceSAndroid Build Coastguard Worker
setUniforms(sglr::Context & ctx,uint32_t program) const200*35238bceSAndroid Build Coastguard Worker void setUniforms(sglr::Context &ctx, uint32_t program) const
201*35238bceSAndroid Build Coastguard Worker {
202*35238bceSAndroid Build Coastguard Worker ctx.useProgram(program);
203*35238bceSAndroid Build Coastguard Worker ctx.uniform1i(ctx.getUniformLocation(program, "u_sampler0"), 0);
204*35238bceSAndroid Build Coastguard Worker }
205*35238bceSAndroid Build Coastguard Worker
shadeVertices(const rr::VertexAttrib * inputs,rr::VertexPacket * const * packets,const int numPackets) const206*35238bceSAndroid Build Coastguard Worker void shadeVertices(const rr::VertexAttrib *inputs, rr::VertexPacket *const *packets, const int numPackets) const
207*35238bceSAndroid Build Coastguard Worker {
208*35238bceSAndroid Build Coastguard Worker for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
209*35238bceSAndroid Build Coastguard Worker {
210*35238bceSAndroid Build Coastguard Worker rr::VertexPacket &packet = *packets[packetNdx];
211*35238bceSAndroid Build Coastguard Worker
212*35238bceSAndroid Build Coastguard Worker packet.position = rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
213*35238bceSAndroid Build Coastguard Worker packet.outputs[0] = rr::readVertexAttribFloat(inputs[1], packet.instanceNdx, packet.vertexNdx);
214*35238bceSAndroid Build Coastguard Worker }
215*35238bceSAndroid Build Coastguard Worker }
216*35238bceSAndroid Build Coastguard Worker
shadeFragments(rr::FragmentPacket * packets,const int numPackets,const rr::FragmentShadingContext & context) const217*35238bceSAndroid Build Coastguard Worker void shadeFragments(rr::FragmentPacket *packets, const int numPackets,
218*35238bceSAndroid Build Coastguard Worker const rr::FragmentShadingContext &context) const
219*35238bceSAndroid Build Coastguard Worker {
220*35238bceSAndroid Build Coastguard Worker tcu::Vec2 texCoords[4];
221*35238bceSAndroid Build Coastguard Worker tcu::Vec4 colors[4];
222*35238bceSAndroid Build Coastguard Worker
223*35238bceSAndroid Build Coastguard Worker for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
224*35238bceSAndroid Build Coastguard Worker {
225*35238bceSAndroid Build Coastguard Worker // setup tex coords
226*35238bceSAndroid Build Coastguard Worker for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
227*35238bceSAndroid Build Coastguard Worker {
228*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 coord = rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
229*35238bceSAndroid Build Coastguard Worker texCoords[fragNdx] = tcu::Vec2(coord.x(), coord.y());
230*35238bceSAndroid Build Coastguard Worker }
231*35238bceSAndroid Build Coastguard Worker
232*35238bceSAndroid Build Coastguard Worker // Sample
233*35238bceSAndroid Build Coastguard Worker m_uniforms[0].sampler.tex2D->sample4(colors, texCoords);
234*35238bceSAndroid Build Coastguard Worker
235*35238bceSAndroid Build Coastguard Worker // Write out
236*35238bceSAndroid Build Coastguard Worker for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
237*35238bceSAndroid Build Coastguard Worker rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, colors[fragNdx]);
238*35238bceSAndroid Build Coastguard Worker }
239*35238bceSAndroid Build Coastguard Worker }
240*35238bceSAndroid Build Coastguard Worker };
241*35238bceSAndroid Build Coastguard Worker
242*35238bceSAndroid Build Coastguard Worker static const char *s_cubeSwizzles[] = {"vec3(-1, -y, +x)", "vec3(+1, -y, -x)", "vec3(+x, -1, -y)",
243*35238bceSAndroid Build Coastguard Worker "vec3(+x, +1, +y)", "vec3(-x, -y, -1)", "vec3(+x, -y, +1)"};
244*35238bceSAndroid Build Coastguard Worker
245*35238bceSAndroid Build Coastguard Worker class TexCubeShader : public sglr::ShaderProgram
246*35238bceSAndroid Build Coastguard Worker {
247*35238bceSAndroid Build Coastguard Worker public:
TexCubeShader(tcu::CubeFace face)248*35238bceSAndroid Build Coastguard Worker TexCubeShader(tcu::CubeFace face)
249*35238bceSAndroid Build Coastguard Worker : ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
250*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
251*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexAttribute("a_coord", rr::GENERICVECTYPE_FLOAT)
252*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
253*35238bceSAndroid Build Coastguard Worker << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
254*35238bceSAndroid Build Coastguard Worker << sglr::pdec::Uniform("u_sampler0", glu::TYPE_SAMPLER_CUBE)
255*35238bceSAndroid Build Coastguard Worker << sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
256*35238bceSAndroid Build Coastguard Worker "attribute mediump vec2 a_coord;\n"
257*35238bceSAndroid Build Coastguard Worker "varying mediump vec2 v_coord;\n"
258*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
259*35238bceSAndroid Build Coastguard Worker "{\n"
260*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
261*35238bceSAndroid Build Coastguard Worker " v_coord = a_coord;\n"
262*35238bceSAndroid Build Coastguard Worker "}\n")
263*35238bceSAndroid Build Coastguard Worker << sglr::pdec::FragmentSource(string("") +
264*35238bceSAndroid Build Coastguard Worker "uniform samplerCube u_sampler0;\n"
265*35238bceSAndroid Build Coastguard Worker "varying mediump vec2 v_coord;\n"
266*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
267*35238bceSAndroid Build Coastguard Worker "{\n"
268*35238bceSAndroid Build Coastguard Worker " mediump float x = v_coord.x*2.0 - 1.0;\n"
269*35238bceSAndroid Build Coastguard Worker " mediump float y = v_coord.y*2.0 - 1.0;\n"
270*35238bceSAndroid Build Coastguard Worker " gl_FragColor = textureCube(u_sampler0, " +
271*35238bceSAndroid Build Coastguard Worker s_cubeSwizzles[face] +
272*35238bceSAndroid Build Coastguard Worker ");\n"
273*35238bceSAndroid Build Coastguard Worker "}\n"))
274*35238bceSAndroid Build Coastguard Worker , m_face(face)
275*35238bceSAndroid Build Coastguard Worker {
276*35238bceSAndroid Build Coastguard Worker }
277*35238bceSAndroid Build Coastguard Worker
setUniforms(sglr::Context & ctx,uint32_t program) const278*35238bceSAndroid Build Coastguard Worker void setUniforms(sglr::Context &ctx, uint32_t program) const
279*35238bceSAndroid Build Coastguard Worker {
280*35238bceSAndroid Build Coastguard Worker ctx.useProgram(program);
281*35238bceSAndroid Build Coastguard Worker ctx.uniform1i(ctx.getUniformLocation(program, "u_sampler0"), 0);
282*35238bceSAndroid Build Coastguard Worker }
283*35238bceSAndroid Build Coastguard Worker
shadeVertices(const rr::VertexAttrib * inputs,rr::VertexPacket * const * packets,const int numPackets) const284*35238bceSAndroid Build Coastguard Worker void shadeVertices(const rr::VertexAttrib *inputs, rr::VertexPacket *const *packets, const int numPackets) const
285*35238bceSAndroid Build Coastguard Worker {
286*35238bceSAndroid Build Coastguard Worker for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
287*35238bceSAndroid Build Coastguard Worker {
288*35238bceSAndroid Build Coastguard Worker rr::VertexPacket &packet = *packets[packetNdx];
289*35238bceSAndroid Build Coastguard Worker
290*35238bceSAndroid Build Coastguard Worker packet.position = rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
291*35238bceSAndroid Build Coastguard Worker packet.outputs[0] = rr::readVertexAttribFloat(inputs[1], packet.instanceNdx, packet.vertexNdx);
292*35238bceSAndroid Build Coastguard Worker }
293*35238bceSAndroid Build Coastguard Worker }
294*35238bceSAndroid Build Coastguard Worker
shadeFragments(rr::FragmentPacket * packets,const int numPackets,const rr::FragmentShadingContext & context) const295*35238bceSAndroid Build Coastguard Worker void shadeFragments(rr::FragmentPacket *packets, const int numPackets,
296*35238bceSAndroid Build Coastguard Worker const rr::FragmentShadingContext &context) const
297*35238bceSAndroid Build Coastguard Worker {
298*35238bceSAndroid Build Coastguard Worker tcu::Vec3 texCoords[4];
299*35238bceSAndroid Build Coastguard Worker tcu::Vec4 colors[4];
300*35238bceSAndroid Build Coastguard Worker
301*35238bceSAndroid Build Coastguard Worker for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
302*35238bceSAndroid Build Coastguard Worker {
303*35238bceSAndroid Build Coastguard Worker // setup tex coords
304*35238bceSAndroid Build Coastguard Worker for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
305*35238bceSAndroid Build Coastguard Worker {
306*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 coord = rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
307*35238bceSAndroid Build Coastguard Worker const float x = coord.x() * 2.0f - 1.0f;
308*35238bceSAndroid Build Coastguard Worker const float y = coord.y() * 2.0f - 1.0f;
309*35238bceSAndroid Build Coastguard Worker
310*35238bceSAndroid Build Coastguard Worker // Swizzle tex coords
311*35238bceSAndroid Build Coastguard Worker switch (m_face)
312*35238bceSAndroid Build Coastguard Worker {
313*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_NEGATIVE_X:
314*35238bceSAndroid Build Coastguard Worker texCoords[fragNdx] = tcu::Vec3(-1.0f, -y, +x);
315*35238bceSAndroid Build Coastguard Worker break;
316*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_POSITIVE_X:
317*35238bceSAndroid Build Coastguard Worker texCoords[fragNdx] = tcu::Vec3(+1.0f, -y, -x);
318*35238bceSAndroid Build Coastguard Worker break;
319*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_NEGATIVE_Y:
320*35238bceSAndroid Build Coastguard Worker texCoords[fragNdx] = tcu::Vec3(+x, -1.0f, -y);
321*35238bceSAndroid Build Coastguard Worker break;
322*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_POSITIVE_Y:
323*35238bceSAndroid Build Coastguard Worker texCoords[fragNdx] = tcu::Vec3(+x, +1.0f, +y);
324*35238bceSAndroid Build Coastguard Worker break;
325*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_NEGATIVE_Z:
326*35238bceSAndroid Build Coastguard Worker texCoords[fragNdx] = tcu::Vec3(-x, -y, -1.0f);
327*35238bceSAndroid Build Coastguard Worker break;
328*35238bceSAndroid Build Coastguard Worker case tcu::CUBEFACE_POSITIVE_Z:
329*35238bceSAndroid Build Coastguard Worker texCoords[fragNdx] = tcu::Vec3(+x, -y, +1.0f);
330*35238bceSAndroid Build Coastguard Worker break;
331*35238bceSAndroid Build Coastguard Worker default:
332*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
333*35238bceSAndroid Build Coastguard Worker }
334*35238bceSAndroid Build Coastguard Worker }
335*35238bceSAndroid Build Coastguard Worker
336*35238bceSAndroid Build Coastguard Worker // Sample
337*35238bceSAndroid Build Coastguard Worker m_uniforms[0].sampler.texCube->sample4(colors, texCoords);
338*35238bceSAndroid Build Coastguard Worker
339*35238bceSAndroid Build Coastguard Worker // Write out
340*35238bceSAndroid Build Coastguard Worker for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
341*35238bceSAndroid Build Coastguard Worker rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, colors[fragNdx]);
342*35238bceSAndroid Build Coastguard Worker }
343*35238bceSAndroid Build Coastguard Worker }
344*35238bceSAndroid Build Coastguard Worker
345*35238bceSAndroid Build Coastguard Worker private:
346*35238bceSAndroid Build Coastguard Worker tcu::CubeFace m_face;
347*35238bceSAndroid Build Coastguard Worker };
348*35238bceSAndroid Build Coastguard Worker
349*35238bceSAndroid Build Coastguard Worker enum TextureType
350*35238bceSAndroid Build Coastguard Worker {
351*35238bceSAndroid Build Coastguard Worker TEXTURETYPE_2D = 0,
352*35238bceSAndroid Build Coastguard Worker TEXTURETYPE_CUBE,
353*35238bceSAndroid Build Coastguard Worker
354*35238bceSAndroid Build Coastguard Worker TEXTURETYPE_LAST
355*35238bceSAndroid Build Coastguard Worker };
356*35238bceSAndroid Build Coastguard Worker
357*35238bceSAndroid Build Coastguard Worker enum Flags
358*35238bceSAndroid Build Coastguard Worker {
359*35238bceSAndroid Build Coastguard Worker MIPMAPS = (1 << 0)
360*35238bceSAndroid Build Coastguard Worker };
361*35238bceSAndroid Build Coastguard Worker
362*35238bceSAndroid Build Coastguard Worker static const uint32_t s_cubeMapFaces[] = {
363*35238bceSAndroid Build Coastguard Worker GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
364*35238bceSAndroid Build Coastguard Worker GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
365*35238bceSAndroid Build Coastguard Worker };
366*35238bceSAndroid Build Coastguard Worker
367*35238bceSAndroid Build Coastguard Worker class TextureSpecCase : public TestCase, public sglr::ContextWrapper
368*35238bceSAndroid Build Coastguard Worker {
369*35238bceSAndroid Build Coastguard Worker public:
370*35238bceSAndroid Build Coastguard Worker TextureSpecCase(Context &context, const char *name, const char *desc, const TextureType type,
371*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat format, const uint32_t flags, int width, int height);
372*35238bceSAndroid Build Coastguard Worker ~TextureSpecCase(void);
373*35238bceSAndroid Build Coastguard Worker
374*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
375*35238bceSAndroid Build Coastguard Worker
376*35238bceSAndroid Build Coastguard Worker protected:
377*35238bceSAndroid Build Coastguard Worker virtual void createTexture(void) = DE_NULL;
378*35238bceSAndroid Build Coastguard Worker
379*35238bceSAndroid Build Coastguard Worker const TextureType m_texType;
380*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat m_texFormat;
381*35238bceSAndroid Build Coastguard Worker const uint32_t m_flags;
382*35238bceSAndroid Build Coastguard Worker const int m_width;
383*35238bceSAndroid Build Coastguard Worker const int m_height;
384*35238bceSAndroid Build Coastguard Worker
385*35238bceSAndroid Build Coastguard Worker bool m_half_float_oes;
386*35238bceSAndroid Build Coastguard Worker
387*35238bceSAndroid Build Coastguard Worker private:
388*35238bceSAndroid Build Coastguard Worker TextureSpecCase(const TextureSpecCase &other);
389*35238bceSAndroid Build Coastguard Worker TextureSpecCase &operator=(const TextureSpecCase &other);
390*35238bceSAndroid Build Coastguard Worker
391*35238bceSAndroid Build Coastguard Worker void verifyTex2D(sglr::GLContext &gles2Context, sglr::ReferenceContext &refContext);
392*35238bceSAndroid Build Coastguard Worker void verifyTexCube(sglr::GLContext &gles2Context, sglr::ReferenceContext &refContext);
393*35238bceSAndroid Build Coastguard Worker
394*35238bceSAndroid Build Coastguard Worker void renderTex2D(tcu::Surface &dst, int width, int height);
395*35238bceSAndroid Build Coastguard Worker void renderTexCube(tcu::Surface &dst, int width, int height, tcu::CubeFace face);
396*35238bceSAndroid Build Coastguard Worker
397*35238bceSAndroid Build Coastguard Worker void readPixels(tcu::Surface &dst, int x, int y, int width, int height);
398*35238bceSAndroid Build Coastguard Worker
399*35238bceSAndroid Build Coastguard Worker // \todo [2012-03-27 pyry] Renderer should be extended to allow custom attributes, that would clean up this cubemap mess.
400*35238bceSAndroid Build Coastguard Worker Tex2DShader m_tex2DShader;
401*35238bceSAndroid Build Coastguard Worker TexCubeShader m_texCubeNegXShader;
402*35238bceSAndroid Build Coastguard Worker TexCubeShader m_texCubePosXShader;
403*35238bceSAndroid Build Coastguard Worker TexCubeShader m_texCubeNegYShader;
404*35238bceSAndroid Build Coastguard Worker TexCubeShader m_texCubePosYShader;
405*35238bceSAndroid Build Coastguard Worker TexCubeShader m_texCubeNegZShader;
406*35238bceSAndroid Build Coastguard Worker TexCubeShader m_texCubePosZShader;
407*35238bceSAndroid Build Coastguard Worker };
408*35238bceSAndroid Build Coastguard Worker
TextureSpecCase(Context & context,const char * name,const char * desc,const TextureType type,const tcu::TextureFormat format,const uint32_t flags,int width,int height)409*35238bceSAndroid Build Coastguard Worker TextureSpecCase::TextureSpecCase(Context &context, const char *name, const char *desc, const TextureType type,
410*35238bceSAndroid Build Coastguard Worker const tcu::TextureFormat format, const uint32_t flags, int width, int height)
411*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, desc)
412*35238bceSAndroid Build Coastguard Worker , m_texType(type)
413*35238bceSAndroid Build Coastguard Worker , m_texFormat(format)
414*35238bceSAndroid Build Coastguard Worker , m_flags(flags)
415*35238bceSAndroid Build Coastguard Worker , m_width(width)
416*35238bceSAndroid Build Coastguard Worker , m_height(height)
417*35238bceSAndroid Build Coastguard Worker , m_texCubeNegXShader(tcu::CUBEFACE_NEGATIVE_X)
418*35238bceSAndroid Build Coastguard Worker , m_texCubePosXShader(tcu::CUBEFACE_POSITIVE_X)
419*35238bceSAndroid Build Coastguard Worker , m_texCubeNegYShader(tcu::CUBEFACE_NEGATIVE_Y)
420*35238bceSAndroid Build Coastguard Worker , m_texCubePosYShader(tcu::CUBEFACE_POSITIVE_Y)
421*35238bceSAndroid Build Coastguard Worker , m_texCubeNegZShader(tcu::CUBEFACE_NEGATIVE_Z)
422*35238bceSAndroid Build Coastguard Worker , m_texCubePosZShader(tcu::CUBEFACE_POSITIVE_Z)
423*35238bceSAndroid Build Coastguard Worker {
424*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
425*35238bceSAndroid Build Coastguard Worker m_half_float_oes = glu::hasExtension(gl, glu::ApiType::es(2, 0), "GL_OES_texture_half_float");
426*35238bceSAndroid Build Coastguard Worker }
427*35238bceSAndroid Build Coastguard Worker
~TextureSpecCase(void)428*35238bceSAndroid Build Coastguard Worker TextureSpecCase::~TextureSpecCase(void)
429*35238bceSAndroid Build Coastguard Worker {
430*35238bceSAndroid Build Coastguard Worker }
431*35238bceSAndroid Build Coastguard Worker
iterate(void)432*35238bceSAndroid Build Coastguard Worker TextureSpecCase::IterateResult TextureSpecCase::iterate(void)
433*35238bceSAndroid Build Coastguard Worker {
434*35238bceSAndroid Build Coastguard Worker glu::RenderContext &renderCtx = TestCase::m_context.getRenderContext();
435*35238bceSAndroid Build Coastguard Worker const tcu::RenderTarget &renderTarget = renderCtx.getRenderTarget();
436*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
437*35238bceSAndroid Build Coastguard Worker
438*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width <= 256 && m_height <= 256);
439*35238bceSAndroid Build Coastguard Worker if (renderTarget.getWidth() < m_width || renderTarget.getHeight() < m_height)
440*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
441*35238bceSAndroid Build Coastguard Worker
442*35238bceSAndroid Build Coastguard Worker // Context size, and viewport for GLES2
443*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
444*35238bceSAndroid Build Coastguard Worker int width = deMin32(renderTarget.getWidth(), 256);
445*35238bceSAndroid Build Coastguard Worker int height = deMin32(renderTarget.getHeight(), 256);
446*35238bceSAndroid Build Coastguard Worker int x = rnd.getInt(0, renderTarget.getWidth() - width);
447*35238bceSAndroid Build Coastguard Worker int y = rnd.getInt(0, renderTarget.getHeight() - height);
448*35238bceSAndroid Build Coastguard Worker
449*35238bceSAndroid Build Coastguard Worker // Contexts.
450*35238bceSAndroid Build Coastguard Worker sglr::GLContext gles2Context(renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height));
451*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContextBuffers refBuffers(tcu::PixelFormat(8, 8, 8, renderTarget.getPixelFormat().alphaBits ? 8 : 0),
452*35238bceSAndroid Build Coastguard Worker 0 /* depth */, 0 /* stencil */, width, height);
453*35238bceSAndroid Build Coastguard Worker sglr::ReferenceContext refContext(sglr::ReferenceContextLimits(renderCtx), refBuffers.getColorbuffer(),
454*35238bceSAndroid Build Coastguard Worker refBuffers.getDepthbuffer(), refBuffers.getStencilbuffer());
455*35238bceSAndroid Build Coastguard Worker
456*35238bceSAndroid Build Coastguard Worker // Clear color buffer.
457*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < 2; ndx++)
458*35238bceSAndroid Build Coastguard Worker {
459*35238bceSAndroid Build Coastguard Worker setContext(ndx ? (sglr::Context *)&refContext : (sglr::Context *)&gles2Context);
460*35238bceSAndroid Build Coastguard Worker glClearColor(0.125f, 0.25f, 0.5f, 1.0f);
461*35238bceSAndroid Build Coastguard Worker glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
462*35238bceSAndroid Build Coastguard Worker }
463*35238bceSAndroid Build Coastguard Worker
464*35238bceSAndroid Build Coastguard Worker // Construct texture using both GLES2 and reference contexts.
465*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < 2; ndx++)
466*35238bceSAndroid Build Coastguard Worker {
467*35238bceSAndroid Build Coastguard Worker setContext(ndx ? (sglr::Context *)&refContext : (sglr::Context *)&gles2Context);
468*35238bceSAndroid Build Coastguard Worker createTexture();
469*35238bceSAndroid Build Coastguard Worker TCU_CHECK(glGetError() == GL_NO_ERROR);
470*35238bceSAndroid Build Coastguard Worker }
471*35238bceSAndroid Build Coastguard Worker
472*35238bceSAndroid Build Coastguard Worker // Setup texture filtering state.
473*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < 2; ndx++)
474*35238bceSAndroid Build Coastguard Worker {
475*35238bceSAndroid Build Coastguard Worker setContext(ndx ? (sglr::Context *)&refContext : (sglr::Context *)&gles2Context);
476*35238bceSAndroid Build Coastguard Worker
477*35238bceSAndroid Build Coastguard Worker uint32_t texTarget = m_texType == TEXTURETYPE_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP;
478*35238bceSAndroid Build Coastguard Worker glTexParameteri(texTarget, GL_TEXTURE_MIN_FILTER, (m_flags & MIPMAPS) ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST);
479*35238bceSAndroid Build Coastguard Worker glTexParameteri(texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
480*35238bceSAndroid Build Coastguard Worker glTexParameteri(texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
481*35238bceSAndroid Build Coastguard Worker glTexParameteri(texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
482*35238bceSAndroid Build Coastguard Worker }
483*35238bceSAndroid Build Coastguard Worker
484*35238bceSAndroid Build Coastguard Worker // Initialize case result to pass.
485*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
486*35238bceSAndroid Build Coastguard Worker
487*35238bceSAndroid Build Coastguard Worker // Disable logging.
488*35238bceSAndroid Build Coastguard Worker gles2Context.enableLogging(0);
489*35238bceSAndroid Build Coastguard Worker
490*35238bceSAndroid Build Coastguard Worker // Verify results.
491*35238bceSAndroid Build Coastguard Worker switch (m_texType)
492*35238bceSAndroid Build Coastguard Worker {
493*35238bceSAndroid Build Coastguard Worker case TEXTURETYPE_2D:
494*35238bceSAndroid Build Coastguard Worker verifyTex2D(gles2Context, refContext);
495*35238bceSAndroid Build Coastguard Worker break;
496*35238bceSAndroid Build Coastguard Worker case TEXTURETYPE_CUBE:
497*35238bceSAndroid Build Coastguard Worker verifyTexCube(gles2Context, refContext);
498*35238bceSAndroid Build Coastguard Worker break;
499*35238bceSAndroid Build Coastguard Worker default:
500*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
501*35238bceSAndroid Build Coastguard Worker }
502*35238bceSAndroid Build Coastguard Worker
503*35238bceSAndroid Build Coastguard Worker return STOP;
504*35238bceSAndroid Build Coastguard Worker }
505*35238bceSAndroid Build Coastguard Worker
verifyTex2D(sglr::GLContext & gles2Context,sglr::ReferenceContext & refContext)506*35238bceSAndroid Build Coastguard Worker void TextureSpecCase::verifyTex2D(sglr::GLContext &gles2Context, sglr::ReferenceContext &refContext)
507*35238bceSAndroid Build Coastguard Worker {
508*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
509*35238bceSAndroid Build Coastguard Worker
510*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_texType == TEXTURETYPE_2D);
511*35238bceSAndroid Build Coastguard Worker
512*35238bceSAndroid Build Coastguard Worker for (int levelNdx = 0; levelNdx < 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 if (levelW <= 2 || levelH <= 2)
520*35238bceSAndroid Build Coastguard Worker continue; // Don't bother checking.
521*35238bceSAndroid Build Coastguard Worker
522*35238bceSAndroid Build Coastguard Worker // Render with GLES2
523*35238bceSAndroid Build Coastguard Worker setContext(&gles2Context);
524*35238bceSAndroid Build Coastguard Worker renderTex2D(result, levelW, levelH);
525*35238bceSAndroid Build Coastguard Worker
526*35238bceSAndroid Build Coastguard Worker // Render reference.
527*35238bceSAndroid Build Coastguard Worker setContext(&refContext);
528*35238bceSAndroid Build Coastguard Worker renderTex2D(reference, levelW, levelH);
529*35238bceSAndroid Build Coastguard Worker
530*35238bceSAndroid Build Coastguard Worker {
531*35238bceSAndroid Build Coastguard Worker tcu::UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
532*35238bceSAndroid Build Coastguard Worker bool isOk = tcu::intThresholdCompare(m_testCtx.getLog(), "Result", "Image comparison result",
533*35238bceSAndroid Build Coastguard Worker reference.getAccess(), result.getAccess(), threshold,
534*35238bceSAndroid Build Coastguard Worker levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
535*35238bceSAndroid Build Coastguard Worker
536*35238bceSAndroid Build Coastguard Worker if (!isOk)
537*35238bceSAndroid Build Coastguard Worker {
538*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
539*35238bceSAndroid Build Coastguard Worker break;
540*35238bceSAndroid Build Coastguard Worker }
541*35238bceSAndroid Build Coastguard Worker }
542*35238bceSAndroid Build Coastguard Worker }
543*35238bceSAndroid Build Coastguard Worker }
544*35238bceSAndroid Build Coastguard Worker
verifyTexCube(sglr::GLContext & gles2Context,sglr::ReferenceContext & refContext)545*35238bceSAndroid Build Coastguard Worker void TextureSpecCase::verifyTexCube(sglr::GLContext &gles2Context, sglr::ReferenceContext &refContext)
546*35238bceSAndroid Build Coastguard Worker {
547*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
548*35238bceSAndroid Build Coastguard Worker
549*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_texType == TEXTURETYPE_CUBE);
550*35238bceSAndroid Build Coastguard Worker
551*35238bceSAndroid Build Coastguard Worker for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
552*35238bceSAndroid Build Coastguard Worker {
553*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> levelNdx);
554*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> levelNdx);
555*35238bceSAndroid Build Coastguard Worker bool isOk = true;
556*35238bceSAndroid Build Coastguard Worker
557*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
558*35238bceSAndroid Build Coastguard Worker {
559*35238bceSAndroid Build Coastguard Worker tcu::Surface reference;
560*35238bceSAndroid Build Coastguard Worker tcu::Surface result;
561*35238bceSAndroid Build Coastguard Worker
562*35238bceSAndroid Build Coastguard Worker if (levelW <= 2 || levelH <= 2)
563*35238bceSAndroid Build Coastguard Worker continue; // Don't bother checking.
564*35238bceSAndroid Build Coastguard Worker
565*35238bceSAndroid Build Coastguard Worker // Render with GLES2
566*35238bceSAndroid Build Coastguard Worker setContext(&gles2Context);
567*35238bceSAndroid Build Coastguard Worker renderTexCube(result, levelW, levelH, (tcu::CubeFace)face);
568*35238bceSAndroid Build Coastguard Worker
569*35238bceSAndroid Build Coastguard Worker // Render reference.
570*35238bceSAndroid Build Coastguard Worker setContext(&refContext);
571*35238bceSAndroid Build Coastguard Worker renderTexCube(reference, levelW, levelH, (tcu::CubeFace)face);
572*35238bceSAndroid Build Coastguard Worker
573*35238bceSAndroid Build Coastguard Worker const float threshold = 0.02f;
574*35238bceSAndroid Build Coastguard Worker isOk = tcu::fuzzyCompare(m_testCtx.getLog(), "Result",
575*35238bceSAndroid Build Coastguard Worker (string("Image comparison result: ") + de::toString((tcu::CubeFace)face)).c_str(),
576*35238bceSAndroid Build Coastguard Worker reference, result, threshold,
577*35238bceSAndroid Build Coastguard Worker levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
578*35238bceSAndroid Build Coastguard Worker
579*35238bceSAndroid Build Coastguard Worker if (!isOk)
580*35238bceSAndroid Build Coastguard Worker {
581*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
582*35238bceSAndroid Build Coastguard Worker break;
583*35238bceSAndroid Build Coastguard Worker }
584*35238bceSAndroid Build Coastguard Worker }
585*35238bceSAndroid Build Coastguard Worker
586*35238bceSAndroid Build Coastguard Worker if (!isOk)
587*35238bceSAndroid Build Coastguard Worker break;
588*35238bceSAndroid Build Coastguard Worker }
589*35238bceSAndroid Build Coastguard Worker }
590*35238bceSAndroid Build Coastguard Worker
renderTex2D(tcu::Surface & dst,int width,int height)591*35238bceSAndroid Build Coastguard Worker void TextureSpecCase::renderTex2D(tcu::Surface &dst, int width, int height)
592*35238bceSAndroid Build Coastguard Worker {
593*35238bceSAndroid Build Coastguard Worker int targetW = getWidth();
594*35238bceSAndroid Build Coastguard Worker int targetH = getHeight();
595*35238bceSAndroid Build Coastguard Worker
596*35238bceSAndroid Build Coastguard Worker float w = (float)width / (float)targetW;
597*35238bceSAndroid Build Coastguard Worker float h = (float)height / (float)targetH;
598*35238bceSAndroid Build Coastguard Worker
599*35238bceSAndroid Build Coastguard Worker uint32_t shaderID = getCurrentContext()->createProgram(&m_tex2DShader);
600*35238bceSAndroid Build Coastguard Worker
601*35238bceSAndroid Build Coastguard Worker m_tex2DShader.setUniforms(*getCurrentContext(), shaderID);
602*35238bceSAndroid Build Coastguard Worker sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f),
603*35238bceSAndroid Build Coastguard Worker tcu::Vec3(-1.0f + w * 2.0f, -1.0f + h * 2.0f, 0.0f));
604*35238bceSAndroid Build Coastguard Worker
605*35238bceSAndroid Build Coastguard Worker // Read pixels back.
606*35238bceSAndroid Build Coastguard Worker readPixels(dst, 0, 0, width, height);
607*35238bceSAndroid Build Coastguard Worker }
608*35238bceSAndroid Build Coastguard Worker
renderTexCube(tcu::Surface & dst,int width,int height,tcu::CubeFace face)609*35238bceSAndroid Build Coastguard Worker void TextureSpecCase::renderTexCube(tcu::Surface &dst, int width, int height, tcu::CubeFace face)
610*35238bceSAndroid Build Coastguard Worker {
611*35238bceSAndroid Build Coastguard Worker int targetW = getWidth();
612*35238bceSAndroid Build Coastguard Worker int targetH = getHeight();
613*35238bceSAndroid Build Coastguard Worker
614*35238bceSAndroid Build Coastguard Worker float w = (float)width / (float)targetW;
615*35238bceSAndroid Build Coastguard Worker float h = (float)height / (float)targetH;
616*35238bceSAndroid Build Coastguard Worker
617*35238bceSAndroid Build Coastguard Worker TexCubeShader *shaders[] = {&m_texCubeNegXShader, &m_texCubePosXShader, &m_texCubeNegYShader,
618*35238bceSAndroid Build Coastguard Worker &m_texCubePosYShader, &m_texCubeNegZShader, &m_texCubePosZShader};
619*35238bceSAndroid Build Coastguard Worker
620*35238bceSAndroid Build Coastguard Worker uint32_t shaderID = getCurrentContext()->createProgram(shaders[face]);
621*35238bceSAndroid Build Coastguard Worker
622*35238bceSAndroid Build Coastguard Worker shaders[face]->setUniforms(*getCurrentContext(), shaderID);
623*35238bceSAndroid Build Coastguard Worker sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f),
624*35238bceSAndroid Build Coastguard Worker tcu::Vec3(-1.0f + w * 2.0f, -1.0f + h * 2.0f, 0.0f));
625*35238bceSAndroid Build Coastguard Worker
626*35238bceSAndroid Build Coastguard Worker // Read pixels back.
627*35238bceSAndroid Build Coastguard Worker readPixels(dst, 0, 0, width, height);
628*35238bceSAndroid Build Coastguard Worker }
629*35238bceSAndroid Build Coastguard Worker
readPixels(tcu::Surface & dst,int x,int y,int width,int height)630*35238bceSAndroid Build Coastguard Worker void TextureSpecCase::readPixels(tcu::Surface &dst, int x, int y, int width, int height)
631*35238bceSAndroid Build Coastguard Worker {
632*35238bceSAndroid Build Coastguard Worker dst.setSize(width, height);
633*35238bceSAndroid Build Coastguard Worker glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
634*35238bceSAndroid Build Coastguard Worker }
635*35238bceSAndroid Build Coastguard Worker
636*35238bceSAndroid Build Coastguard Worker // Basic TexImage2D() with 2D texture usage
637*35238bceSAndroid Build Coastguard Worker class BasicTexImage2DCase : public TextureSpecCase
638*35238bceSAndroid Build Coastguard Worker {
639*35238bceSAndroid Build Coastguard Worker public:
BasicTexImage2DCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)640*35238bceSAndroid Build Coastguard Worker BasicTexImage2DCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
641*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height)
642*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width,
643*35238bceSAndroid Build Coastguard Worker height)
644*35238bceSAndroid Build Coastguard Worker , m_format(format)
645*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
646*35238bceSAndroid Build Coastguard Worker {
647*35238bceSAndroid Build Coastguard Worker }
648*35238bceSAndroid Build Coastguard Worker
649*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)650*35238bceSAndroid Build Coastguard Worker void createTexture(void)
651*35238bceSAndroid Build Coastguard Worker {
652*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
653*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
654*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
655*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel levelData(fmt);
656*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
657*35238bceSAndroid Build Coastguard Worker
658*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
659*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
660*35238bceSAndroid Build Coastguard Worker
661*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
662*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_2D, tex);
663*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
664*35238bceSAndroid Build Coastguard Worker
665*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
666*35238bceSAndroid Build Coastguard Worker {
667*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
668*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
669*35238bceSAndroid Build Coastguard Worker Vec4 gMin = randomVector<4>(rnd);
670*35238bceSAndroid Build Coastguard Worker Vec4 gMax = randomVector<4>(rnd);
671*35238bceSAndroid Build Coastguard Worker
672*35238bceSAndroid Build Coastguard Worker levelData.setSize(levelW, levelH);
673*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
674*35238bceSAndroid Build Coastguard Worker
675*35238bceSAndroid Build Coastguard Worker glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType,
676*35238bceSAndroid Build Coastguard Worker levelData.getAccess().getDataPtr());
677*35238bceSAndroid Build Coastguard Worker }
678*35238bceSAndroid Build Coastguard Worker }
679*35238bceSAndroid Build Coastguard Worker
680*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
681*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
682*35238bceSAndroid Build Coastguard Worker };
683*35238bceSAndroid Build Coastguard Worker
684*35238bceSAndroid Build Coastguard Worker // Basic TexImage2D() with cubemap usage
685*35238bceSAndroid Build Coastguard Worker class BasicTexImageCubeCase : public TextureSpecCase
686*35238bceSAndroid Build Coastguard Worker {
687*35238bceSAndroid Build Coastguard Worker public:
BasicTexImageCubeCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)688*35238bceSAndroid Build Coastguard Worker BasicTexImageCubeCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
689*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height)
690*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags,
691*35238bceSAndroid Build Coastguard Worker width, height)
692*35238bceSAndroid Build Coastguard Worker , m_format(format)
693*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
694*35238bceSAndroid Build Coastguard Worker {
695*35238bceSAndroid Build Coastguard Worker }
696*35238bceSAndroid Build Coastguard Worker
697*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)698*35238bceSAndroid Build Coastguard Worker void createTexture(void)
699*35238bceSAndroid Build Coastguard Worker {
700*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
701*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
702*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
703*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel levelData(fmt);
704*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
705*35238bceSAndroid Build Coastguard Worker
706*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
707*35238bceSAndroid Build Coastguard Worker
708*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
709*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
710*35238bceSAndroid Build Coastguard Worker
711*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
712*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
713*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
714*35238bceSAndroid Build Coastguard Worker
715*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
716*35238bceSAndroid Build Coastguard Worker {
717*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
718*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
719*35238bceSAndroid Build Coastguard Worker
720*35238bceSAndroid Build Coastguard Worker levelData.setSize(levelW, levelH);
721*35238bceSAndroid Build Coastguard Worker
722*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
723*35238bceSAndroid Build Coastguard Worker {
724*35238bceSAndroid Build Coastguard Worker Vec4 gMin = randomVector<4>(rnd);
725*35238bceSAndroid Build Coastguard Worker Vec4 gMax = randomVector<4>(rnd);
726*35238bceSAndroid Build Coastguard Worker
727*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
728*35238bceSAndroid Build Coastguard Worker
729*35238bceSAndroid Build Coastguard Worker glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType,
730*35238bceSAndroid Build Coastguard Worker levelData.getAccess().getDataPtr());
731*35238bceSAndroid Build Coastguard Worker }
732*35238bceSAndroid Build Coastguard Worker }
733*35238bceSAndroid Build Coastguard Worker }
734*35238bceSAndroid Build Coastguard Worker
735*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
736*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
737*35238bceSAndroid Build Coastguard Worker };
738*35238bceSAndroid Build Coastguard Worker
739*35238bceSAndroid Build Coastguard Worker // Randomized 2D texture specification using TexImage2D
740*35238bceSAndroid Build Coastguard Worker class RandomOrderTexImage2DCase : public TextureSpecCase
741*35238bceSAndroid Build Coastguard Worker {
742*35238bceSAndroid Build Coastguard Worker public:
RandomOrderTexImage2DCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)743*35238bceSAndroid Build Coastguard Worker RandomOrderTexImage2DCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
744*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height)
745*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width,
746*35238bceSAndroid Build Coastguard Worker height)
747*35238bceSAndroid Build Coastguard Worker , m_format(format)
748*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
749*35238bceSAndroid Build Coastguard Worker {
750*35238bceSAndroid Build Coastguard Worker }
751*35238bceSAndroid Build Coastguard Worker
752*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)753*35238bceSAndroid Build Coastguard Worker void createTexture(void)
754*35238bceSAndroid Build Coastguard Worker {
755*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
756*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
757*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
758*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel levelData(fmt);
759*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
760*35238bceSAndroid Build Coastguard Worker
761*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
762*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
763*35238bceSAndroid Build Coastguard Worker
764*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
765*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_2D, tex);
766*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
767*35238bceSAndroid Build Coastguard Worker
768*35238bceSAndroid Build Coastguard Worker vector<int> levels(numLevels);
769*35238bceSAndroid Build Coastguard Worker
770*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < numLevels; i++)
771*35238bceSAndroid Build Coastguard Worker levels[i] = i;
772*35238bceSAndroid Build Coastguard Worker rnd.shuffle(levels.begin(), levels.end());
773*35238bceSAndroid Build Coastguard Worker
774*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
775*35238bceSAndroid Build Coastguard Worker {
776*35238bceSAndroid Build Coastguard Worker int levelNdx = levels[ndx];
777*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> levelNdx);
778*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> levelNdx);
779*35238bceSAndroid Build Coastguard Worker Vec4 gMin = randomVector<4>(rnd);
780*35238bceSAndroid Build Coastguard Worker Vec4 gMax = randomVector<4>(rnd);
781*35238bceSAndroid Build Coastguard Worker
782*35238bceSAndroid Build Coastguard Worker levelData.setSize(levelW, levelH);
783*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
784*35238bceSAndroid Build Coastguard Worker
785*35238bceSAndroid Build Coastguard Worker glTexImage2D(GL_TEXTURE_2D, levelNdx, m_format, levelW, levelH, 0, m_format, m_dataType,
786*35238bceSAndroid Build Coastguard Worker levelData.getAccess().getDataPtr());
787*35238bceSAndroid Build Coastguard Worker }
788*35238bceSAndroid Build Coastguard Worker }
789*35238bceSAndroid Build Coastguard Worker
790*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
791*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
792*35238bceSAndroid Build Coastguard Worker };
793*35238bceSAndroid Build Coastguard Worker
794*35238bceSAndroid Build Coastguard Worker // Randomized cubemap texture specification using TexImage2D
795*35238bceSAndroid Build Coastguard Worker class RandomOrderTexImageCubeCase : public TextureSpecCase
796*35238bceSAndroid Build Coastguard Worker {
797*35238bceSAndroid Build Coastguard Worker public:
RandomOrderTexImageCubeCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)798*35238bceSAndroid Build Coastguard Worker RandomOrderTexImageCubeCase(Context &context, const char *name, const char *desc, uint32_t format,
799*35238bceSAndroid Build Coastguard Worker uint32_t dataType, uint32_t flags, int width, int height)
800*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags,
801*35238bceSAndroid Build Coastguard Worker width, height)
802*35238bceSAndroid Build Coastguard Worker , m_format(format)
803*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
804*35238bceSAndroid Build Coastguard Worker {
805*35238bceSAndroid Build Coastguard Worker }
806*35238bceSAndroid Build Coastguard Worker
807*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)808*35238bceSAndroid Build Coastguard Worker void createTexture(void)
809*35238bceSAndroid Build Coastguard Worker {
810*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
811*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
812*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
813*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel levelData(fmt);
814*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
815*35238bceSAndroid Build Coastguard Worker
816*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
817*35238bceSAndroid Build Coastguard Worker
818*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
819*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
820*35238bceSAndroid Build Coastguard Worker
821*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
822*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
823*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
824*35238bceSAndroid Build Coastguard Worker
825*35238bceSAndroid Build Coastguard Worker // Level-face pairs.
826*35238bceSAndroid Build Coastguard Worker vector<pair<int, tcu::CubeFace>> images(numLevels * 6);
827*35238bceSAndroid Build Coastguard Worker
828*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
829*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
830*35238bceSAndroid Build Coastguard Worker images[ndx * 6 + face] = std::make_pair(ndx, (tcu::CubeFace)face);
831*35238bceSAndroid Build Coastguard Worker
832*35238bceSAndroid Build Coastguard Worker rnd.shuffle(images.begin(), images.end());
833*35238bceSAndroid Build Coastguard Worker
834*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < (int)images.size(); ndx++)
835*35238bceSAndroid Build Coastguard Worker {
836*35238bceSAndroid Build Coastguard Worker int levelNdx = images[ndx].first;
837*35238bceSAndroid Build Coastguard Worker tcu::CubeFace face = images[ndx].second;
838*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> levelNdx);
839*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> levelNdx);
840*35238bceSAndroid Build Coastguard Worker Vec4 gMin = randomVector<4>(rnd);
841*35238bceSAndroid Build Coastguard Worker Vec4 gMax = randomVector<4>(rnd);
842*35238bceSAndroid Build Coastguard Worker
843*35238bceSAndroid Build Coastguard Worker levelData.setSize(levelW, levelH);
844*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
845*35238bceSAndroid Build Coastguard Worker
846*35238bceSAndroid Build Coastguard Worker glTexImage2D(s_cubeMapFaces[face], levelNdx, m_format, levelW, levelH, 0, m_format, m_dataType,
847*35238bceSAndroid Build Coastguard Worker levelData.getAccess().getDataPtr());
848*35238bceSAndroid Build Coastguard Worker }
849*35238bceSAndroid Build Coastguard Worker }
850*35238bceSAndroid Build Coastguard Worker
851*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
852*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
853*35238bceSAndroid Build Coastguard Worker };
854*35238bceSAndroid Build Coastguard Worker
getRowPitch(const tcu::TextureFormat & transferFmt,int rowLen,int alignment)855*35238bceSAndroid Build Coastguard Worker static inline int getRowPitch(const tcu::TextureFormat &transferFmt, int rowLen, int alignment)
856*35238bceSAndroid Build Coastguard Worker {
857*35238bceSAndroid Build Coastguard Worker int basePitch = transferFmt.getPixelSize() * rowLen;
858*35238bceSAndroid Build Coastguard Worker return alignment * (basePitch / alignment + ((basePitch % alignment) ? 1 : 0));
859*35238bceSAndroid Build Coastguard Worker }
860*35238bceSAndroid Build Coastguard Worker
861*35238bceSAndroid Build Coastguard Worker // TexImage2D() unpack alignment case.
862*35238bceSAndroid Build Coastguard Worker class TexImage2DAlignCase : public TextureSpecCase
863*35238bceSAndroid Build Coastguard Worker {
864*35238bceSAndroid Build Coastguard Worker public:
TexImage2DAlignCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height,int alignment)865*35238bceSAndroid Build Coastguard Worker TexImage2DAlignCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
866*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height, int alignment)
867*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width,
868*35238bceSAndroid Build Coastguard Worker height)
869*35238bceSAndroid Build Coastguard Worker , m_format(format)
870*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
871*35238bceSAndroid Build Coastguard Worker , m_alignment(alignment)
872*35238bceSAndroid Build Coastguard Worker {
873*35238bceSAndroid Build Coastguard Worker }
874*35238bceSAndroid Build Coastguard Worker
875*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)876*35238bceSAndroid Build Coastguard Worker void createTexture(void)
877*35238bceSAndroid Build Coastguard Worker {
878*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
879*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
880*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
881*35238bceSAndroid Build Coastguard Worker vector<uint8_t> data;
882*35238bceSAndroid Build Coastguard Worker
883*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
884*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
885*35238bceSAndroid Build Coastguard Worker
886*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
887*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_2D, tex);
888*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
889*35238bceSAndroid Build Coastguard Worker
890*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
891*35238bceSAndroid Build Coastguard Worker {
892*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
893*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
894*35238bceSAndroid Build Coastguard Worker Vec4 colorA(1.0f, 0.0f, 0.0f, 1.0f);
895*35238bceSAndroid Build Coastguard Worker Vec4 colorB(0.0f, 1.0f, 0.0f, 1.0f);
896*35238bceSAndroid Build Coastguard Worker int rowPitch = getRowPitch(fmt, levelW, m_alignment);
897*35238bceSAndroid Build Coastguard Worker int cellSize = de::max(1, de::min(levelW >> 2, levelH >> 2));
898*35238bceSAndroid Build Coastguard Worker
899*35238bceSAndroid Build Coastguard Worker data.resize(rowPitch * levelH);
900*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize, colorA,
901*35238bceSAndroid Build Coastguard Worker colorB);
902*35238bceSAndroid Build Coastguard Worker
903*35238bceSAndroid Build Coastguard Worker glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, &data[0]);
904*35238bceSAndroid Build Coastguard Worker }
905*35238bceSAndroid Build Coastguard Worker }
906*35238bceSAndroid Build Coastguard Worker
907*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
908*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
909*35238bceSAndroid Build Coastguard Worker int m_alignment;
910*35238bceSAndroid Build Coastguard Worker };
911*35238bceSAndroid Build Coastguard Worker
912*35238bceSAndroid Build Coastguard Worker // TexImage2D() unpack alignment case.
913*35238bceSAndroid Build Coastguard Worker class TexImageCubeAlignCase : public TextureSpecCase
914*35238bceSAndroid Build Coastguard Worker {
915*35238bceSAndroid Build Coastguard Worker public:
TexImageCubeAlignCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height,int alignment)916*35238bceSAndroid Build Coastguard Worker TexImageCubeAlignCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
917*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height, int alignment)
918*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags,
919*35238bceSAndroid Build Coastguard Worker width, height)
920*35238bceSAndroid Build Coastguard Worker , m_format(format)
921*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
922*35238bceSAndroid Build Coastguard Worker , m_alignment(alignment)
923*35238bceSAndroid Build Coastguard Worker {
924*35238bceSAndroid Build Coastguard Worker }
925*35238bceSAndroid Build Coastguard Worker
926*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)927*35238bceSAndroid Build Coastguard Worker void createTexture(void)
928*35238bceSAndroid Build Coastguard Worker {
929*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
930*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
931*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
932*35238bceSAndroid Build Coastguard Worker vector<uint8_t> data;
933*35238bceSAndroid Build Coastguard Worker
934*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
935*35238bceSAndroid Build Coastguard Worker
936*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
937*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
938*35238bceSAndroid Build Coastguard Worker
939*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
940*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
941*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
942*35238bceSAndroid Build Coastguard Worker
943*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
944*35238bceSAndroid Build Coastguard Worker {
945*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
946*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
947*35238bceSAndroid Build Coastguard Worker int rowPitch = getRowPitch(fmt, levelW, m_alignment);
948*35238bceSAndroid Build Coastguard Worker Vec4 colorA(1.0f, 0.0f, 0.0f, 1.0f);
949*35238bceSAndroid Build Coastguard Worker Vec4 colorB(0.0f, 1.0f, 0.0f, 1.0f);
950*35238bceSAndroid Build Coastguard Worker int cellSize = de::max(1, de::min(levelW >> 2, levelH >> 2));
951*35238bceSAndroid Build Coastguard Worker
952*35238bceSAndroid Build Coastguard Worker data.resize(rowPitch * levelH);
953*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize, colorA,
954*35238bceSAndroid Build Coastguard Worker colorB);
955*35238bceSAndroid Build Coastguard Worker
956*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
957*35238bceSAndroid Build Coastguard Worker glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, &data[0]);
958*35238bceSAndroid Build Coastguard Worker }
959*35238bceSAndroid Build Coastguard Worker }
960*35238bceSAndroid Build Coastguard Worker
961*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
962*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
963*35238bceSAndroid Build Coastguard Worker int m_alignment;
964*35238bceSAndroid Build Coastguard Worker };
965*35238bceSAndroid Build Coastguard Worker
966*35238bceSAndroid Build Coastguard Worker // Basic TexSubImage2D() with 2D texture usage
967*35238bceSAndroid Build Coastguard Worker class BasicTexSubImage2DCase : public TextureSpecCase
968*35238bceSAndroid Build Coastguard Worker {
969*35238bceSAndroid Build Coastguard Worker public:
BasicTexSubImage2DCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)970*35238bceSAndroid Build Coastguard Worker BasicTexSubImage2DCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
971*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height)
972*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width,
973*35238bceSAndroid Build Coastguard Worker height)
974*35238bceSAndroid Build Coastguard Worker , m_format(format)
975*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
976*35238bceSAndroid Build Coastguard Worker {
977*35238bceSAndroid Build Coastguard Worker }
978*35238bceSAndroid Build Coastguard Worker
979*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)980*35238bceSAndroid Build Coastguard Worker void createTexture(void)
981*35238bceSAndroid Build Coastguard Worker {
982*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
983*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
984*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
985*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel data(fmt);
986*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
987*35238bceSAndroid Build Coastguard Worker
988*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
989*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
990*35238bceSAndroid Build Coastguard Worker
991*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
992*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_2D, tex);
993*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
994*35238bceSAndroid Build Coastguard Worker
995*35238bceSAndroid Build Coastguard Worker // First specify full texture.
996*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
997*35238bceSAndroid Build Coastguard Worker {
998*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
999*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1000*35238bceSAndroid Build Coastguard Worker Vec4 gMin = randomVector<4>(rnd);
1001*35238bceSAndroid Build Coastguard Worker Vec4 gMax = randomVector<4>(rnd);
1002*35238bceSAndroid Build Coastguard Worker
1003*35238bceSAndroid Build Coastguard Worker data.setSize(levelW, levelH);
1004*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1005*35238bceSAndroid Build Coastguard Worker
1006*35238bceSAndroid Build Coastguard Worker glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType,
1007*35238bceSAndroid Build Coastguard Worker data.getAccess().getDataPtr());
1008*35238bceSAndroid Build Coastguard Worker }
1009*35238bceSAndroid Build Coastguard Worker
1010*35238bceSAndroid Build Coastguard Worker // Re-specify parts of each level.
1011*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1012*35238bceSAndroid Build Coastguard Worker {
1013*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1014*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1015*35238bceSAndroid Build Coastguard Worker
1016*35238bceSAndroid Build Coastguard Worker int w = rnd.getInt(1, levelW);
1017*35238bceSAndroid Build Coastguard Worker int h = rnd.getInt(1, levelH);
1018*35238bceSAndroid Build Coastguard Worker int x = rnd.getInt(0, levelW - w);
1019*35238bceSAndroid Build Coastguard Worker int y = rnd.getInt(0, levelH - h);
1020*35238bceSAndroid Build Coastguard Worker
1021*35238bceSAndroid Build Coastguard Worker Vec4 colorA = randomVector<4>(rnd);
1022*35238bceSAndroid Build Coastguard Worker Vec4 colorB = randomVector<4>(rnd);
1023*35238bceSAndroid Build Coastguard Worker int cellSize = rnd.getInt(2, 16);
1024*35238bceSAndroid Build Coastguard Worker
1025*35238bceSAndroid Build Coastguard Worker data.setSize(w, h);
1026*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1027*35238bceSAndroid Build Coastguard Worker
1028*35238bceSAndroid Build Coastguard Worker glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
1029*35238bceSAndroid Build Coastguard Worker }
1030*35238bceSAndroid Build Coastguard Worker }
1031*35238bceSAndroid Build Coastguard Worker
1032*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
1033*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
1034*35238bceSAndroid Build Coastguard Worker };
1035*35238bceSAndroid Build Coastguard Worker
1036*35238bceSAndroid Build Coastguard Worker // Basic TexSubImage2D() with cubemap usage
1037*35238bceSAndroid Build Coastguard Worker class BasicTexSubImageCubeCase : public TextureSpecCase
1038*35238bceSAndroid Build Coastguard Worker {
1039*35238bceSAndroid Build Coastguard Worker public:
BasicTexSubImageCubeCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)1040*35238bceSAndroid Build Coastguard Worker BasicTexSubImageCubeCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1041*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height)
1042*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags,
1043*35238bceSAndroid Build Coastguard Worker width, height)
1044*35238bceSAndroid Build Coastguard Worker , m_format(format)
1045*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
1046*35238bceSAndroid Build Coastguard Worker {
1047*35238bceSAndroid Build Coastguard Worker }
1048*35238bceSAndroid Build Coastguard Worker
1049*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1050*35238bceSAndroid Build Coastguard Worker void createTexture(void)
1051*35238bceSAndroid Build Coastguard Worker {
1052*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
1053*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
1054*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
1055*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel data(fmt);
1056*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
1057*35238bceSAndroid Build Coastguard Worker
1058*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
1059*35238bceSAndroid Build Coastguard Worker
1060*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
1061*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
1062*35238bceSAndroid Build Coastguard Worker
1063*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
1064*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1065*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1066*35238bceSAndroid Build Coastguard Worker
1067*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1068*35238bceSAndroid Build Coastguard Worker {
1069*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1070*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1071*35238bceSAndroid Build Coastguard Worker
1072*35238bceSAndroid Build Coastguard Worker data.setSize(levelW, levelH);
1073*35238bceSAndroid Build Coastguard Worker
1074*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1075*35238bceSAndroid Build Coastguard Worker {
1076*35238bceSAndroid Build Coastguard Worker Vec4 gMin = randomVector<4>(rnd);
1077*35238bceSAndroid Build Coastguard Worker Vec4 gMax = randomVector<4>(rnd);
1078*35238bceSAndroid Build Coastguard Worker
1079*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1080*35238bceSAndroid Build Coastguard Worker
1081*35238bceSAndroid Build Coastguard Worker glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType,
1082*35238bceSAndroid Build Coastguard Worker data.getAccess().getDataPtr());
1083*35238bceSAndroid Build Coastguard Worker }
1084*35238bceSAndroid Build Coastguard Worker }
1085*35238bceSAndroid Build Coastguard Worker
1086*35238bceSAndroid Build Coastguard Worker // Re-specify parts of each face and level.
1087*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1088*35238bceSAndroid Build Coastguard Worker {
1089*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1090*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1091*35238bceSAndroid Build Coastguard Worker
1092*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1093*35238bceSAndroid Build Coastguard Worker {
1094*35238bceSAndroid Build Coastguard Worker int w = rnd.getInt(1, levelW);
1095*35238bceSAndroid Build Coastguard Worker int h = rnd.getInt(1, levelH);
1096*35238bceSAndroid Build Coastguard Worker int x = rnd.getInt(0, levelW - w);
1097*35238bceSAndroid Build Coastguard Worker int y = rnd.getInt(0, levelH - h);
1098*35238bceSAndroid Build Coastguard Worker
1099*35238bceSAndroid Build Coastguard Worker Vec4 colorA = randomVector<4>(rnd);
1100*35238bceSAndroid Build Coastguard Worker Vec4 colorB = randomVector<4>(rnd);
1101*35238bceSAndroid Build Coastguard Worker int cellSize = rnd.getInt(2, 16);
1102*35238bceSAndroid Build Coastguard Worker
1103*35238bceSAndroid Build Coastguard Worker data.setSize(w, h);
1104*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1105*35238bceSAndroid Build Coastguard Worker
1106*35238bceSAndroid Build Coastguard Worker glTexSubImage2D(s_cubeMapFaces[face], ndx, x, y, w, h, m_format, m_dataType,
1107*35238bceSAndroid Build Coastguard Worker data.getAccess().getDataPtr());
1108*35238bceSAndroid Build Coastguard Worker }
1109*35238bceSAndroid Build Coastguard Worker }
1110*35238bceSAndroid Build Coastguard Worker }
1111*35238bceSAndroid Build Coastguard Worker
1112*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
1113*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
1114*35238bceSAndroid Build Coastguard Worker };
1115*35238bceSAndroid Build Coastguard Worker
1116*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() to texture initialized with empty data
1117*35238bceSAndroid Build Coastguard Worker class TexSubImage2DEmptyTexCase : public TextureSpecCase
1118*35238bceSAndroid Build Coastguard Worker {
1119*35238bceSAndroid Build Coastguard Worker public:
TexSubImage2DEmptyTexCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)1120*35238bceSAndroid Build Coastguard Worker TexSubImage2DEmptyTexCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1121*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height)
1122*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width,
1123*35238bceSAndroid Build Coastguard Worker height)
1124*35238bceSAndroid Build Coastguard Worker , m_format(format)
1125*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
1126*35238bceSAndroid Build Coastguard Worker {
1127*35238bceSAndroid Build Coastguard Worker }
1128*35238bceSAndroid Build Coastguard Worker
1129*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1130*35238bceSAndroid Build Coastguard Worker void createTexture(void)
1131*35238bceSAndroid Build Coastguard Worker {
1132*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
1133*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
1134*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
1135*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel data(fmt);
1136*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
1137*35238bceSAndroid Build Coastguard Worker
1138*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
1139*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
1140*35238bceSAndroid Build Coastguard Worker
1141*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
1142*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_2D, tex);
1143*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1144*35238bceSAndroid Build Coastguard Worker
1145*35238bceSAndroid Build Coastguard Worker // First allocate storage for each level.
1146*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1147*35238bceSAndroid Build Coastguard Worker {
1148*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1149*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1150*35238bceSAndroid Build Coastguard Worker
1151*35238bceSAndroid Build Coastguard Worker glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, DE_NULL);
1152*35238bceSAndroid Build Coastguard Worker }
1153*35238bceSAndroid Build Coastguard Worker
1154*35238bceSAndroid Build Coastguard Worker // Specify pixel data to all levels using glTexSubImage2D()
1155*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1156*35238bceSAndroid Build Coastguard Worker {
1157*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1158*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1159*35238bceSAndroid Build Coastguard Worker Vec4 gMin = randomVector<4>(rnd);
1160*35238bceSAndroid Build Coastguard Worker Vec4 gMax = randomVector<4>(rnd);
1161*35238bceSAndroid Build Coastguard Worker
1162*35238bceSAndroid Build Coastguard Worker data.setSize(levelW, levelH);
1163*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1164*35238bceSAndroid Build Coastguard Worker
1165*35238bceSAndroid Build Coastguard Worker glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, m_format, m_dataType,
1166*35238bceSAndroid Build Coastguard Worker data.getAccess().getDataPtr());
1167*35238bceSAndroid Build Coastguard Worker }
1168*35238bceSAndroid Build Coastguard Worker }
1169*35238bceSAndroid Build Coastguard Worker
1170*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
1171*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
1172*35238bceSAndroid Build Coastguard Worker };
1173*35238bceSAndroid Build Coastguard Worker
1174*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() to empty cubemap texture
1175*35238bceSAndroid Build Coastguard Worker class TexSubImageCubeEmptyTexCase : public TextureSpecCase
1176*35238bceSAndroid Build Coastguard Worker {
1177*35238bceSAndroid Build Coastguard Worker public:
TexSubImageCubeEmptyTexCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)1178*35238bceSAndroid Build Coastguard Worker TexSubImageCubeEmptyTexCase(Context &context, const char *name, const char *desc, uint32_t format,
1179*35238bceSAndroid Build Coastguard Worker uint32_t dataType, uint32_t flags, int width, int height)
1180*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags,
1181*35238bceSAndroid Build Coastguard Worker width, height)
1182*35238bceSAndroid Build Coastguard Worker , m_format(format)
1183*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
1184*35238bceSAndroid Build Coastguard Worker {
1185*35238bceSAndroid Build Coastguard Worker }
1186*35238bceSAndroid Build Coastguard Worker
1187*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1188*35238bceSAndroid Build Coastguard Worker void createTexture(void)
1189*35238bceSAndroid Build Coastguard Worker {
1190*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
1191*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
1192*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
1193*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel data(fmt);
1194*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
1195*35238bceSAndroid Build Coastguard Worker
1196*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
1197*35238bceSAndroid Build Coastguard Worker
1198*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
1199*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
1200*35238bceSAndroid Build Coastguard Worker
1201*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
1202*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1203*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1204*35238bceSAndroid Build Coastguard Worker
1205*35238bceSAndroid Build Coastguard Worker // Specify storage for each level.
1206*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1207*35238bceSAndroid Build Coastguard Worker {
1208*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1209*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1210*35238bceSAndroid Build Coastguard Worker
1211*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1212*35238bceSAndroid Build Coastguard Worker glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, DE_NULL);
1213*35238bceSAndroid Build Coastguard Worker }
1214*35238bceSAndroid Build Coastguard Worker
1215*35238bceSAndroid Build Coastguard Worker // Specify data using glTexSubImage2D()
1216*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1217*35238bceSAndroid Build Coastguard Worker {
1218*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1219*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1220*35238bceSAndroid Build Coastguard Worker
1221*35238bceSAndroid Build Coastguard Worker data.setSize(levelW, levelH);
1222*35238bceSAndroid Build Coastguard Worker
1223*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1224*35238bceSAndroid Build Coastguard Worker {
1225*35238bceSAndroid Build Coastguard Worker Vec4 gMin = randomVector<4>(rnd);
1226*35238bceSAndroid Build Coastguard Worker Vec4 gMax = randomVector<4>(rnd);
1227*35238bceSAndroid Build Coastguard Worker
1228*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1229*35238bceSAndroid Build Coastguard Worker
1230*35238bceSAndroid Build Coastguard Worker glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelW, levelH, m_format, m_dataType,
1231*35238bceSAndroid Build Coastguard Worker data.getAccess().getDataPtr());
1232*35238bceSAndroid Build Coastguard Worker }
1233*35238bceSAndroid Build Coastguard Worker }
1234*35238bceSAndroid Build Coastguard Worker }
1235*35238bceSAndroid Build Coastguard Worker
1236*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
1237*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
1238*35238bceSAndroid Build Coastguard Worker };
1239*35238bceSAndroid Build Coastguard Worker
1240*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() unpack alignment with 2D texture
1241*35238bceSAndroid Build Coastguard Worker class TexSubImage2DAlignCase : public TextureSpecCase
1242*35238bceSAndroid Build Coastguard Worker {
1243*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)1244*35238bceSAndroid Build Coastguard Worker TexSubImage2DAlignCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1245*35238bceSAndroid Build Coastguard Worker int width, int height, int subX, int subY, int subW, int subH, int alignment)
1246*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType),
1247*35238bceSAndroid Build Coastguard Worker 0 /* Mipmaps are never used */, width, height)
1248*35238bceSAndroid Build Coastguard Worker , m_format(format)
1249*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
1250*35238bceSAndroid Build Coastguard Worker , m_subX(subX)
1251*35238bceSAndroid Build Coastguard Worker , m_subY(subY)
1252*35238bceSAndroid Build Coastguard Worker , m_subW(subW)
1253*35238bceSAndroid Build Coastguard Worker , m_subH(subH)
1254*35238bceSAndroid Build Coastguard Worker , m_alignment(alignment)
1255*35238bceSAndroid Build Coastguard Worker {
1256*35238bceSAndroid Build Coastguard Worker }
1257*35238bceSAndroid Build Coastguard Worker
1258*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1259*35238bceSAndroid Build Coastguard Worker void createTexture(void)
1260*35238bceSAndroid Build Coastguard Worker {
1261*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
1262*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
1263*35238bceSAndroid Build Coastguard Worker vector<uint8_t> data;
1264*35238bceSAndroid Build Coastguard Worker
1265*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
1266*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
1267*35238bceSAndroid Build Coastguard Worker
1268*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
1269*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_2D, tex);
1270*35238bceSAndroid Build Coastguard Worker
1271*35238bceSAndroid Build Coastguard Worker // Specify base level.
1272*35238bceSAndroid Build Coastguard Worker data.resize(fmt.getPixelSize() * m_width * m_height);
1273*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(tcu::PixelBufferAccess(fmt, m_width, m_height, 1, &data[0]), Vec4(0.0f),
1274*35238bceSAndroid Build Coastguard Worker Vec4(1.0f));
1275*35238bceSAndroid Build Coastguard Worker
1276*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1277*35238bceSAndroid Build Coastguard Worker glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_width, m_height, 0, m_format, m_dataType, &data[0]);
1278*35238bceSAndroid Build Coastguard Worker
1279*35238bceSAndroid Build Coastguard Worker // Re-specify subrectangle.
1280*35238bceSAndroid Build Coastguard Worker int rowPitch = getRowPitch(fmt, m_subW, m_alignment);
1281*35238bceSAndroid Build Coastguard Worker data.resize(rowPitch * m_subH);
1282*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4,
1283*35238bceSAndroid Build Coastguard Worker Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
1284*35238bceSAndroid Build Coastguard Worker
1285*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1286*35238bceSAndroid Build Coastguard Worker glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
1287*35238bceSAndroid Build Coastguard Worker }
1288*35238bceSAndroid Build Coastguard Worker
1289*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
1290*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
1291*35238bceSAndroid Build Coastguard Worker int m_subX;
1292*35238bceSAndroid Build Coastguard Worker int m_subY;
1293*35238bceSAndroid Build Coastguard Worker int m_subW;
1294*35238bceSAndroid Build Coastguard Worker int m_subH;
1295*35238bceSAndroid Build Coastguard Worker int m_alignment;
1296*35238bceSAndroid Build Coastguard Worker };
1297*35238bceSAndroid Build Coastguard Worker
1298*35238bceSAndroid Build Coastguard Worker // TexSubImage2D() unpack alignment with cubemap texture
1299*35238bceSAndroid Build Coastguard Worker class TexSubImageCubeAlignCase : public TextureSpecCase
1300*35238bceSAndroid Build Coastguard Worker {
1301*35238bceSAndroid Build Coastguard Worker public:
TexSubImageCubeAlignCase(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)1302*35238bceSAndroid Build Coastguard Worker TexSubImageCubeAlignCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1303*35238bceSAndroid Build Coastguard Worker int width, int height, int subX, int subY, int subW, int subH, int alignment)
1304*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType),
1305*35238bceSAndroid Build Coastguard Worker 0 /* Mipmaps are never used */, width, height)
1306*35238bceSAndroid Build Coastguard Worker , m_format(format)
1307*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
1308*35238bceSAndroid Build Coastguard Worker , m_subX(subX)
1309*35238bceSAndroid Build Coastguard Worker , m_subY(subY)
1310*35238bceSAndroid Build Coastguard Worker , m_subW(subW)
1311*35238bceSAndroid Build Coastguard Worker , m_subH(subH)
1312*35238bceSAndroid Build Coastguard Worker , m_alignment(alignment)
1313*35238bceSAndroid Build Coastguard Worker {
1314*35238bceSAndroid Build Coastguard Worker }
1315*35238bceSAndroid Build Coastguard Worker
1316*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1317*35238bceSAndroid Build Coastguard Worker void createTexture(void)
1318*35238bceSAndroid Build Coastguard Worker {
1319*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
1320*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
1321*35238bceSAndroid Build Coastguard Worker vector<uint8_t> data;
1322*35238bceSAndroid Build Coastguard Worker
1323*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width == m_height);
1324*35238bceSAndroid Build Coastguard Worker
1325*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
1326*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
1327*35238bceSAndroid Build Coastguard Worker
1328*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
1329*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1330*35238bceSAndroid Build Coastguard Worker
1331*35238bceSAndroid Build Coastguard Worker // Specify base level.
1332*35238bceSAndroid Build Coastguard Worker data.resize(fmt.getPixelSize() * m_width * m_height);
1333*35238bceSAndroid Build Coastguard Worker tcu::fillWithComponentGradients(tcu::PixelBufferAccess(fmt, m_width, m_height, 1, &data[0]), Vec4(0.0f),
1334*35238bceSAndroid Build Coastguard Worker Vec4(1.0f));
1335*35238bceSAndroid Build Coastguard Worker
1336*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1337*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1338*35238bceSAndroid Build Coastguard Worker glTexImage2D(s_cubeMapFaces[face], 0, m_format, m_width, m_height, 0, m_format, m_dataType, &data[0]);
1339*35238bceSAndroid Build Coastguard Worker
1340*35238bceSAndroid Build Coastguard Worker // Re-specify subrectangle.
1341*35238bceSAndroid Build Coastguard Worker int rowPitch = getRowPitch(fmt, m_subW, m_alignment);
1342*35238bceSAndroid Build Coastguard Worker data.resize(rowPitch * m_subH);
1343*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4,
1344*35238bceSAndroid Build Coastguard Worker Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
1345*35238bceSAndroid Build Coastguard Worker
1346*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1347*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1348*35238bceSAndroid Build Coastguard Worker glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
1349*35238bceSAndroid Build Coastguard Worker }
1350*35238bceSAndroid Build Coastguard Worker
1351*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
1352*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
1353*35238bceSAndroid Build Coastguard Worker int m_subX;
1354*35238bceSAndroid Build Coastguard Worker int m_subY;
1355*35238bceSAndroid Build Coastguard Worker int m_subW;
1356*35238bceSAndroid Build Coastguard Worker int m_subH;
1357*35238bceSAndroid Build Coastguard Worker int m_alignment;
1358*35238bceSAndroid Build Coastguard Worker };
1359*35238bceSAndroid Build Coastguard Worker
1360*35238bceSAndroid Build Coastguard Worker // Basic CopyTexImage2D() with 2D texture usage
1361*35238bceSAndroid Build Coastguard Worker class BasicCopyTexImage2DCase : public TextureSpecCase
1362*35238bceSAndroid Build Coastguard Worker {
1363*35238bceSAndroid Build Coastguard Worker public:
BasicCopyTexImage2DCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,uint32_t flags,int width,int height)1364*35238bceSAndroid Build Coastguard Worker BasicCopyTexImage2DCase(Context &context, const char *name, const char *desc, uint32_t internalFormat,
1365*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height)
1366*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_2D, mapGLUnsizedInternalFormat(internalFormat), flags, width,
1367*35238bceSAndroid Build Coastguard Worker height)
1368*35238bceSAndroid Build Coastguard Worker , m_internalFormat(internalFormat)
1369*35238bceSAndroid Build Coastguard Worker {
1370*35238bceSAndroid Build Coastguard Worker }
1371*35238bceSAndroid Build Coastguard Worker
1372*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1373*35238bceSAndroid Build Coastguard Worker void createTexture(void)
1374*35238bceSAndroid Build Coastguard Worker {
1375*35238bceSAndroid Build Coastguard Worker const tcu::RenderTarget &renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1376*35238bceSAndroid Build Coastguard Worker bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 &&
1377*35238bceSAndroid Build Coastguard Worker renderTarget.getPixelFormat().blueBits > 0;
1378*35238bceSAndroid Build Coastguard Worker bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1379*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
1380*35238bceSAndroid Build Coastguard Worker bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1381*35238bceSAndroid Build Coastguard Worker bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA ||
1382*35238bceSAndroid Build Coastguard Worker fmt.order == tcu::TextureFormat::A;
1383*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
1384*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
1385*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
1386*35238bceSAndroid Build Coastguard Worker GradientShader shader;
1387*35238bceSAndroid Build Coastguard Worker uint32_t shaderID = getCurrentContext()->createProgram(&shader);
1388*35238bceSAndroid Build Coastguard Worker
1389*35238bceSAndroid Build Coastguard Worker if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1390*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1391*35238bceSAndroid Build Coastguard Worker
1392*35238bceSAndroid Build Coastguard Worker // Fill render target with gradient.
1393*35238bceSAndroid Build Coastguard Worker sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1394*35238bceSAndroid Build Coastguard Worker
1395*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
1396*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_2D, tex);
1397*35238bceSAndroid Build Coastguard Worker
1398*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1399*35238bceSAndroid Build Coastguard Worker {
1400*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1401*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1402*35238bceSAndroid Build Coastguard Worker int x = rnd.getInt(0, getWidth() - levelW);
1403*35238bceSAndroid Build Coastguard Worker int y = rnd.getInt(0, getHeight() - levelH);
1404*35238bceSAndroid Build Coastguard Worker
1405*35238bceSAndroid Build Coastguard Worker glCopyTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, x, y, levelW, levelH, 0);
1406*35238bceSAndroid Build Coastguard Worker }
1407*35238bceSAndroid Build Coastguard Worker }
1408*35238bceSAndroid Build Coastguard Worker
1409*35238bceSAndroid Build Coastguard Worker uint32_t m_internalFormat;
1410*35238bceSAndroid Build Coastguard Worker };
1411*35238bceSAndroid Build Coastguard Worker
1412*35238bceSAndroid Build Coastguard Worker // Basic CopyTexImage2D() with cubemap usage
1413*35238bceSAndroid Build Coastguard Worker class BasicCopyTexImageCubeCase : public TextureSpecCase
1414*35238bceSAndroid Build Coastguard Worker {
1415*35238bceSAndroid Build Coastguard Worker public:
BasicCopyTexImageCubeCase(Context & context,const char * name,const char * desc,uint32_t internalFormat,uint32_t flags,int width,int height)1416*35238bceSAndroid Build Coastguard Worker BasicCopyTexImageCubeCase(Context &context, const char *name, const char *desc, uint32_t internalFormat,
1417*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height)
1418*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_CUBE, mapGLUnsizedInternalFormat(internalFormat), flags,
1419*35238bceSAndroid Build Coastguard Worker width, height)
1420*35238bceSAndroid Build Coastguard Worker , m_internalFormat(internalFormat)
1421*35238bceSAndroid Build Coastguard Worker {
1422*35238bceSAndroid Build Coastguard Worker }
1423*35238bceSAndroid Build Coastguard Worker
1424*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1425*35238bceSAndroid Build Coastguard Worker void createTexture(void)
1426*35238bceSAndroid Build Coastguard Worker {
1427*35238bceSAndroid Build Coastguard Worker const tcu::RenderTarget &renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1428*35238bceSAndroid Build Coastguard Worker bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 &&
1429*35238bceSAndroid Build Coastguard Worker renderTarget.getPixelFormat().blueBits > 0;
1430*35238bceSAndroid Build Coastguard Worker bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1431*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
1432*35238bceSAndroid Build Coastguard Worker bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1433*35238bceSAndroid Build Coastguard Worker bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA ||
1434*35238bceSAndroid Build Coastguard Worker fmt.order == tcu::TextureFormat::A;
1435*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? deLog2Floor32(m_width) + 1 : 1;
1436*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
1437*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
1438*35238bceSAndroid Build Coastguard Worker GradientShader shader;
1439*35238bceSAndroid Build Coastguard Worker uint32_t shaderID = getCurrentContext()->createProgram(&shader);
1440*35238bceSAndroid Build Coastguard Worker
1441*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
1442*35238bceSAndroid Build Coastguard Worker
1443*35238bceSAndroid Build Coastguard Worker if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1444*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1445*35238bceSAndroid Build Coastguard Worker
1446*35238bceSAndroid Build Coastguard Worker // Fill render target with gradient.
1447*35238bceSAndroid Build Coastguard Worker sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1448*35238bceSAndroid Build Coastguard Worker
1449*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
1450*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1451*35238bceSAndroid Build Coastguard Worker
1452*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1453*35238bceSAndroid Build Coastguard Worker {
1454*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1455*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1456*35238bceSAndroid Build Coastguard Worker
1457*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1458*35238bceSAndroid Build Coastguard Worker {
1459*35238bceSAndroid Build Coastguard Worker int x = rnd.getInt(0, getWidth() - levelW);
1460*35238bceSAndroid Build Coastguard Worker int y = rnd.getInt(0, getHeight() - levelH);
1461*35238bceSAndroid Build Coastguard Worker
1462*35238bceSAndroid Build Coastguard Worker glCopyTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, x, y, levelW, levelH, 0);
1463*35238bceSAndroid Build Coastguard Worker }
1464*35238bceSAndroid Build Coastguard Worker }
1465*35238bceSAndroid Build Coastguard Worker }
1466*35238bceSAndroid Build Coastguard Worker
1467*35238bceSAndroid Build Coastguard Worker uint32_t m_internalFormat;
1468*35238bceSAndroid Build Coastguard Worker };
1469*35238bceSAndroid Build Coastguard Worker
1470*35238bceSAndroid Build Coastguard Worker // Basic CopyTexSubImage2D() with 2D texture usage
1471*35238bceSAndroid Build Coastguard Worker class BasicCopyTexSubImage2DCase : public TextureSpecCase
1472*35238bceSAndroid Build Coastguard Worker {
1473*35238bceSAndroid Build Coastguard Worker public:
BasicCopyTexSubImage2DCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)1474*35238bceSAndroid Build Coastguard Worker BasicCopyTexSubImage2DCase(Context &context, const char *name, const char *desc, uint32_t format, uint32_t dataType,
1475*35238bceSAndroid Build Coastguard Worker uint32_t flags, int width, int height)
1476*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width,
1477*35238bceSAndroid Build Coastguard Worker height)
1478*35238bceSAndroid Build Coastguard Worker , m_format(format)
1479*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
1480*35238bceSAndroid Build Coastguard Worker {
1481*35238bceSAndroid Build Coastguard Worker }
1482*35238bceSAndroid Build Coastguard Worker
1483*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1484*35238bceSAndroid Build Coastguard Worker void createTexture(void)
1485*35238bceSAndroid Build Coastguard Worker {
1486*35238bceSAndroid Build Coastguard Worker const tcu::RenderTarget &renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1487*35238bceSAndroid Build Coastguard Worker bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 &&
1488*35238bceSAndroid Build Coastguard Worker renderTarget.getPixelFormat().blueBits > 0;
1489*35238bceSAndroid Build Coastguard Worker bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1490*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
1491*35238bceSAndroid Build Coastguard Worker bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1492*35238bceSAndroid Build Coastguard Worker bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA ||
1493*35238bceSAndroid Build Coastguard Worker fmt.order == tcu::TextureFormat::A;
1494*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
1495*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
1496*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel data(fmt);
1497*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
1498*35238bceSAndroid Build Coastguard Worker GradientShader shader;
1499*35238bceSAndroid Build Coastguard Worker uint32_t shaderID = getCurrentContext()->createProgram(&shader);
1500*35238bceSAndroid Build Coastguard Worker
1501*35238bceSAndroid Build Coastguard Worker if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1502*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1503*35238bceSAndroid Build Coastguard Worker
1504*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
1505*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
1506*35238bceSAndroid Build Coastguard Worker
1507*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
1508*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_2D, tex);
1509*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1510*35238bceSAndroid Build Coastguard Worker
1511*35238bceSAndroid Build Coastguard Worker // First specify full texture.
1512*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1513*35238bceSAndroid Build Coastguard Worker {
1514*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1515*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1516*35238bceSAndroid Build Coastguard Worker
1517*35238bceSAndroid Build Coastguard Worker Vec4 colorA = randomVector<4>(rnd);
1518*35238bceSAndroid Build Coastguard Worker Vec4 colorB = randomVector<4>(rnd);
1519*35238bceSAndroid Build Coastguard Worker int cellSize = rnd.getInt(2, 16);
1520*35238bceSAndroid Build Coastguard Worker
1521*35238bceSAndroid Build Coastguard Worker data.setSize(levelW, levelH);
1522*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1523*35238bceSAndroid Build Coastguard Worker
1524*35238bceSAndroid Build Coastguard Worker glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType,
1525*35238bceSAndroid Build Coastguard Worker data.getAccess().getDataPtr());
1526*35238bceSAndroid Build Coastguard Worker }
1527*35238bceSAndroid Build Coastguard Worker
1528*35238bceSAndroid Build Coastguard Worker // Fill render target with gradient.
1529*35238bceSAndroid Build Coastguard Worker sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
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 < 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
1537*35238bceSAndroid Build Coastguard Worker int w = rnd.getInt(1, levelW);
1538*35238bceSAndroid Build Coastguard Worker int h = rnd.getInt(1, levelH);
1539*35238bceSAndroid Build Coastguard Worker int xo = rnd.getInt(0, levelW - w);
1540*35238bceSAndroid Build Coastguard Worker int yo = rnd.getInt(0, levelH - h);
1541*35238bceSAndroid Build Coastguard Worker
1542*35238bceSAndroid Build Coastguard Worker int x = rnd.getInt(0, getWidth() - w);
1543*35238bceSAndroid Build Coastguard Worker int y = rnd.getInt(0, getHeight() - h);
1544*35238bceSAndroid Build Coastguard Worker
1545*35238bceSAndroid Build Coastguard Worker glCopyTexSubImage2D(GL_TEXTURE_2D, ndx, xo, yo, x, y, w, h);
1546*35238bceSAndroid Build Coastguard Worker }
1547*35238bceSAndroid Build Coastguard Worker }
1548*35238bceSAndroid Build Coastguard Worker
1549*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
1550*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
1551*35238bceSAndroid Build Coastguard Worker };
1552*35238bceSAndroid Build Coastguard Worker
1553*35238bceSAndroid Build Coastguard Worker // Basic CopyTexSubImage2D() with cubemap usage
1554*35238bceSAndroid Build Coastguard Worker class BasicCopyTexSubImageCubeCase : public TextureSpecCase
1555*35238bceSAndroid Build Coastguard Worker {
1556*35238bceSAndroid Build Coastguard Worker public:
BasicCopyTexSubImageCubeCase(Context & context,const char * name,const char * desc,uint32_t format,uint32_t dataType,uint32_t flags,int width,int height)1557*35238bceSAndroid Build Coastguard Worker BasicCopyTexSubImageCubeCase(Context &context, const char *name, const char *desc, uint32_t format,
1558*35238bceSAndroid Build Coastguard Worker uint32_t dataType, uint32_t flags, int width, int height)
1559*35238bceSAndroid Build Coastguard Worker : TextureSpecCase(context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags,
1560*35238bceSAndroid Build Coastguard Worker width, height)
1561*35238bceSAndroid Build Coastguard Worker , m_format(format)
1562*35238bceSAndroid Build Coastguard Worker , m_dataType(dataType)
1563*35238bceSAndroid Build Coastguard Worker {
1564*35238bceSAndroid Build Coastguard Worker }
1565*35238bceSAndroid Build Coastguard Worker
1566*35238bceSAndroid Build Coastguard Worker protected:
createTexture(void)1567*35238bceSAndroid Build Coastguard Worker void createTexture(void)
1568*35238bceSAndroid Build Coastguard Worker {
1569*35238bceSAndroid Build Coastguard Worker const tcu::RenderTarget &renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1570*35238bceSAndroid Build Coastguard Worker bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 &&
1571*35238bceSAndroid Build Coastguard Worker renderTarget.getPixelFormat().blueBits > 0;
1572*35238bceSAndroid Build Coastguard Worker bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1573*35238bceSAndroid Build Coastguard Worker tcu::TextureFormat fmt = m_texFormat;
1574*35238bceSAndroid Build Coastguard Worker bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1575*35238bceSAndroid Build Coastguard Worker bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA ||
1576*35238bceSAndroid Build Coastguard Worker fmt.order == tcu::TextureFormat::A;
1577*35238bceSAndroid Build Coastguard Worker int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height)) + 1 : 1;
1578*35238bceSAndroid Build Coastguard Worker uint32_t tex = 0;
1579*35238bceSAndroid Build Coastguard Worker tcu::TextureLevel data(fmt);
1580*35238bceSAndroid Build Coastguard Worker de::Random rnd(deStringHash(getName()));
1581*35238bceSAndroid Build Coastguard Worker GradientShader shader;
1582*35238bceSAndroid Build Coastguard Worker uint32_t shaderID = getCurrentContext()->createProgram(&shader);
1583*35238bceSAndroid Build Coastguard Worker
1584*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
1585*35238bceSAndroid Build Coastguard Worker
1586*35238bceSAndroid Build Coastguard Worker if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1587*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1588*35238bceSAndroid Build Coastguard Worker
1589*35238bceSAndroid Build Coastguard Worker if (m_dataType == GL_HALF_FLOAT_OES && !m_half_float_oes)
1590*35238bceSAndroid Build Coastguard Worker throw tcu::NotSupportedError("GL_OES_texture_half_float is not supported", "", __FILE__, __LINE__);
1591*35238bceSAndroid Build Coastguard Worker
1592*35238bceSAndroid Build Coastguard Worker glGenTextures(1, &tex);
1593*35238bceSAndroid Build Coastguard Worker glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1594*35238bceSAndroid Build Coastguard Worker glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1595*35238bceSAndroid Build Coastguard Worker
1596*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1597*35238bceSAndroid Build Coastguard Worker {
1598*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1599*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1600*35238bceSAndroid Build Coastguard Worker
1601*35238bceSAndroid Build Coastguard Worker data.setSize(levelW, levelH);
1602*35238bceSAndroid Build Coastguard Worker
1603*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1604*35238bceSAndroid Build Coastguard Worker {
1605*35238bceSAndroid Build Coastguard Worker Vec4 colorA = randomVector<4>(rnd);
1606*35238bceSAndroid Build Coastguard Worker Vec4 colorB = randomVector<4>(rnd);
1607*35238bceSAndroid Build Coastguard Worker int cellSize = rnd.getInt(2, 16);
1608*35238bceSAndroid Build Coastguard Worker
1609*35238bceSAndroid Build Coastguard Worker tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1610*35238bceSAndroid Build Coastguard Worker glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType,
1611*35238bceSAndroid Build Coastguard Worker data.getAccess().getDataPtr());
1612*35238bceSAndroid Build Coastguard Worker }
1613*35238bceSAndroid Build Coastguard Worker }
1614*35238bceSAndroid Build Coastguard Worker
1615*35238bceSAndroid Build Coastguard Worker // Fill render target with gradient.
1616*35238bceSAndroid Build Coastguard Worker sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1617*35238bceSAndroid Build Coastguard Worker
1618*35238bceSAndroid Build Coastguard Worker // Re-specify parts of each face and level.
1619*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numLevels; ndx++)
1620*35238bceSAndroid Build Coastguard Worker {
1621*35238bceSAndroid Build Coastguard Worker int levelW = de::max(1, m_width >> ndx);
1622*35238bceSAndroid Build Coastguard Worker int levelH = de::max(1, m_height >> ndx);
1623*35238bceSAndroid Build Coastguard Worker
1624*35238bceSAndroid Build Coastguard Worker for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1625*35238bceSAndroid Build Coastguard Worker {
1626*35238bceSAndroid Build Coastguard Worker int w = rnd.getInt(1, levelW);
1627*35238bceSAndroid Build Coastguard Worker int h = rnd.getInt(1, levelH);
1628*35238bceSAndroid Build Coastguard Worker int xo = rnd.getInt(0, levelW - w);
1629*35238bceSAndroid Build Coastguard Worker int yo = rnd.getInt(0, levelH - h);
1630*35238bceSAndroid Build Coastguard Worker
1631*35238bceSAndroid Build Coastguard Worker int x = rnd.getInt(0, getWidth() - w);
1632*35238bceSAndroid Build Coastguard Worker int y = rnd.getInt(0, getHeight() - h);
1633*35238bceSAndroid Build Coastguard Worker
1634*35238bceSAndroid Build Coastguard Worker glCopyTexSubImage2D(s_cubeMapFaces[face], ndx, xo, yo, x, y, w, h);
1635*35238bceSAndroid Build Coastguard Worker }
1636*35238bceSAndroid Build Coastguard Worker }
1637*35238bceSAndroid Build Coastguard Worker }
1638*35238bceSAndroid Build Coastguard Worker
1639*35238bceSAndroid Build Coastguard Worker uint32_t m_format;
1640*35238bceSAndroid Build Coastguard Worker uint32_t m_dataType;
1641*35238bceSAndroid Build Coastguard Worker };
1642*35238bceSAndroid Build Coastguard Worker
TextureSpecificationTests(Context & context)1643*35238bceSAndroid Build Coastguard Worker TextureSpecificationTests::TextureSpecificationTests(Context &context)
1644*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, "specification", "Texture Specification Tests")
1645*35238bceSAndroid Build Coastguard Worker {
1646*35238bceSAndroid Build Coastguard Worker }
1647*35238bceSAndroid Build Coastguard Worker
~TextureSpecificationTests(void)1648*35238bceSAndroid Build Coastguard Worker TextureSpecificationTests::~TextureSpecificationTests(void)
1649*35238bceSAndroid Build Coastguard Worker {
1650*35238bceSAndroid Build Coastguard Worker }
1651*35238bceSAndroid Build Coastguard Worker
init(void)1652*35238bceSAndroid Build Coastguard Worker void TextureSpecificationTests::init(void)
1653*35238bceSAndroid Build Coastguard Worker {
1654*35238bceSAndroid Build Coastguard Worker struct
1655*35238bceSAndroid Build Coastguard Worker {
1656*35238bceSAndroid Build Coastguard Worker const char *name;
1657*35238bceSAndroid Build Coastguard Worker uint32_t format;
1658*35238bceSAndroid Build Coastguard Worker uint32_t dataType;
1659*35238bceSAndroid Build Coastguard Worker } texFormats[] = {{"a8", GL_ALPHA, GL_UNSIGNED_BYTE},
1660*35238bceSAndroid Build Coastguard Worker {"l8", GL_LUMINANCE, GL_UNSIGNED_BYTE},
1661*35238bceSAndroid Build Coastguard Worker {"la88", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE},
1662*35238bceSAndroid Build Coastguard Worker {"rgb565", GL_RGB, GL_UNSIGNED_SHORT_5_6_5},
1663*35238bceSAndroid Build Coastguard Worker {"rgb888", GL_RGB, GL_UNSIGNED_BYTE},
1664*35238bceSAndroid Build Coastguard Worker {"rgba4444", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4},
1665*35238bceSAndroid Build Coastguard Worker {"rgba5551", GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1},
1666*35238bceSAndroid Build Coastguard Worker {"rgba8888", GL_RGBA, GL_UNSIGNED_BYTE},
1667*35238bceSAndroid Build Coastguard Worker {"rgba16f", GL_RGBA, GL_HALF_FLOAT_OES},
1668*35238bceSAndroid Build Coastguard Worker {"rgb16f", GL_RGB, GL_HALF_FLOAT_OES},
1669*35238bceSAndroid Build Coastguard Worker {"la16f", GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES},
1670*35238bceSAndroid Build Coastguard Worker {"l16f", GL_LUMINANCE, GL_HALF_FLOAT_OES},
1671*35238bceSAndroid Build Coastguard Worker {"a16f", GL_ALPHA, GL_HALF_FLOAT_OES}};
1672*35238bceSAndroid Build Coastguard Worker
1673*35238bceSAndroid Build Coastguard Worker // Basic TexImage2D usage.
1674*35238bceSAndroid Build Coastguard Worker {
1675*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *basicTexImageGroup =
1676*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "basic_teximage2d", "Basic glTexImage2D() usage");
1677*35238bceSAndroid Build Coastguard Worker addChild(basicTexImageGroup);
1678*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
1679*35238bceSAndroid Build Coastguard Worker {
1680*35238bceSAndroid Build Coastguard Worker const char *fmtName = texFormats[formatNdx].name;
1681*35238bceSAndroid Build Coastguard Worker uint32_t format = texFormats[formatNdx].format;
1682*35238bceSAndroid Build Coastguard Worker uint32_t dataType = texFormats[formatNdx].dataType;
1683*35238bceSAndroid Build Coastguard Worker const int tex2DWidth = 64;
1684*35238bceSAndroid Build Coastguard Worker const int tex2DHeight = 128;
1685*35238bceSAndroid Build Coastguard Worker const int texCubeSize = 64;
1686*35238bceSAndroid Build Coastguard Worker
1687*35238bceSAndroid Build Coastguard Worker basicTexImageGroup->addChild(new BasicTexImage2DCase(m_context, (string(fmtName) + "_2d").c_str(), "",
1688*35238bceSAndroid Build Coastguard Worker format, dataType, MIPMAPS, tex2DWidth, tex2DHeight));
1689*35238bceSAndroid Build Coastguard Worker basicTexImageGroup->addChild(new BasicTexImageCubeCase(m_context, (string(fmtName) + "_cube").c_str(), "",
1690*35238bceSAndroid Build Coastguard Worker format, dataType, MIPMAPS, texCubeSize,
1691*35238bceSAndroid Build Coastguard Worker texCubeSize));
1692*35238bceSAndroid Build Coastguard Worker }
1693*35238bceSAndroid Build Coastguard Worker }
1694*35238bceSAndroid Build Coastguard Worker
1695*35238bceSAndroid Build Coastguard Worker // Randomized TexImage2D order.
1696*35238bceSAndroid Build Coastguard Worker {
1697*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *randomTexImageGroup =
1698*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "random_teximage2d", "Randomized glTexImage2D() usage");
1699*35238bceSAndroid Build Coastguard Worker addChild(randomTexImageGroup);
1700*35238bceSAndroid Build Coastguard Worker
1701*35238bceSAndroid Build Coastguard Worker de::Random rnd(9);
1702*35238bceSAndroid Build Coastguard Worker
1703*35238bceSAndroid Build Coastguard Worker // 2D cases.
1704*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < 10; ndx++)
1705*35238bceSAndroid Build Coastguard Worker {
1706*35238bceSAndroid Build Coastguard Worker int formatNdx = rnd.getInt(0, DE_LENGTH_OF_ARRAY(texFormats) - 1);
1707*35238bceSAndroid Build Coastguard Worker int width = 1 << rnd.getInt(2, 8);
1708*35238bceSAndroid Build Coastguard Worker int height = 1 << rnd.getInt(2, 8);
1709*35238bceSAndroid Build Coastguard Worker
1710*35238bceSAndroid Build Coastguard Worker randomTexImageGroup->addChild(new RandomOrderTexImage2DCase(
1711*35238bceSAndroid Build Coastguard Worker m_context, (string("2d_") + de::toString(ndx)).c_str(), "", texFormats[formatNdx].format,
1712*35238bceSAndroid Build Coastguard Worker texFormats[formatNdx].dataType, MIPMAPS, width, height));
1713*35238bceSAndroid Build Coastguard Worker }
1714*35238bceSAndroid Build Coastguard Worker
1715*35238bceSAndroid Build Coastguard Worker // Cubemap cases.
1716*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < 10; ndx++)
1717*35238bceSAndroid Build Coastguard Worker {
1718*35238bceSAndroid Build Coastguard Worker int formatNdx = rnd.getInt(0, DE_LENGTH_OF_ARRAY(texFormats) - 1);
1719*35238bceSAndroid Build Coastguard Worker int size = 1 << rnd.getInt(2, 8);
1720*35238bceSAndroid Build Coastguard Worker
1721*35238bceSAndroid Build Coastguard Worker randomTexImageGroup->addChild(new RandomOrderTexImageCubeCase(
1722*35238bceSAndroid Build Coastguard Worker m_context, (string("cube_") + de::toString(ndx)).c_str(), "", texFormats[formatNdx].format,
1723*35238bceSAndroid Build Coastguard Worker texFormats[formatNdx].dataType, MIPMAPS, size, size));
1724*35238bceSAndroid Build Coastguard Worker }
1725*35238bceSAndroid Build Coastguard Worker }
1726*35238bceSAndroid Build Coastguard Worker
1727*35238bceSAndroid Build Coastguard Worker // TexImage2D unpack alignment.
1728*35238bceSAndroid Build Coastguard Worker {
1729*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *alignGroup =
1730*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "teximage2d_align", "glTexImage2D() unpack alignment tests");
1731*35238bceSAndroid Build Coastguard Worker addChild(alignGroup);
1732*35238bceSAndroid Build Coastguard Worker
1733*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1734*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_l8_4_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, MIPMAPS, 4, 8, 8));
1735*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1736*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_l8_63_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 30, 1));
1737*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1738*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_l8_63_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 30, 2));
1739*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1740*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_l8_63_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 30, 4));
1741*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1742*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_l8_63_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 30, 8));
1743*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba4444_51_1", "", GL_RGBA,
1744*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 30, 1));
1745*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba4444_51_2", "", GL_RGBA,
1746*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 30, 2));
1747*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba4444_51_4", "", GL_RGBA,
1748*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 30, 4));
1749*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexImage2DAlignCase(m_context, "2d_rgba4444_51_8", "", GL_RGBA,
1750*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 30, 8));
1751*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1752*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_rgb888_39_1", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 43, 1));
1753*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1754*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_rgb888_39_2", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 43, 2));
1755*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1756*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_rgb888_39_4", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 43, 4));
1757*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1758*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_rgb888_39_8", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 43, 8));
1759*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1760*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_rgba8888_47_1", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 27, 1));
1761*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1762*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_rgba8888_47_2", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 27, 2));
1763*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1764*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_rgba8888_47_4", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 27, 4));
1765*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1766*35238bceSAndroid Build Coastguard Worker new TexImage2DAlignCase(m_context, "2d_rgba8888_47_8", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 27, 8));
1767*35238bceSAndroid Build Coastguard Worker
1768*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1769*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_l8_4_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, MIPMAPS, 4, 4, 8));
1770*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1771*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_l8_63_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 63, 1));
1772*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1773*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_l8_63_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 63, 2));
1774*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1775*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_l8_63_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 63, 4));
1776*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1777*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_l8_63_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 63, 8));
1778*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba4444_51_1", "", GL_RGBA,
1779*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 51, 1));
1780*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba4444_51_2", "", GL_RGBA,
1781*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 51, 2));
1782*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba4444_51_4", "", GL_RGBA,
1783*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 51, 4));
1784*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexImageCubeAlignCase(m_context, "cube_rgba4444_51_8", "", GL_RGBA,
1785*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 51, 8));
1786*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1787*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_rgb888_39_1", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 39, 1));
1788*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1789*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_rgb888_39_2", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 39, 2));
1790*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1791*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_rgb888_39_4", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 39, 4));
1792*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1793*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_rgb888_39_8", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 39, 8));
1794*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1795*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_rgba8888_47_1", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 47, 1));
1796*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1797*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_rgba8888_47_2", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 47, 2));
1798*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1799*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_rgba8888_47_4", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 47, 4));
1800*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(
1801*35238bceSAndroid Build Coastguard Worker new TexImageCubeAlignCase(m_context, "cube_rgba8888_47_8", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 47, 8));
1802*35238bceSAndroid Build Coastguard Worker }
1803*35238bceSAndroid Build Coastguard Worker
1804*35238bceSAndroid Build Coastguard Worker // Basic TexSubImage2D usage.
1805*35238bceSAndroid Build Coastguard Worker {
1806*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *basicTexSubImageGroup =
1807*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "basic_texsubimage2d", "Basic glTexSubImage2D() usage");
1808*35238bceSAndroid Build Coastguard Worker addChild(basicTexSubImageGroup);
1809*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
1810*35238bceSAndroid Build Coastguard Worker {
1811*35238bceSAndroid Build Coastguard Worker const char *fmtName = texFormats[formatNdx].name;
1812*35238bceSAndroid Build Coastguard Worker uint32_t format = texFormats[formatNdx].format;
1813*35238bceSAndroid Build Coastguard Worker uint32_t dataType = texFormats[formatNdx].dataType;
1814*35238bceSAndroid Build Coastguard Worker const int tex2DWidth = 64;
1815*35238bceSAndroid Build Coastguard Worker const int tex2DHeight = 128;
1816*35238bceSAndroid Build Coastguard Worker const int texCubeSize = 64;
1817*35238bceSAndroid Build Coastguard Worker
1818*35238bceSAndroid Build Coastguard Worker basicTexSubImageGroup->addChild(new BasicTexSubImage2DCase(
1819*35238bceSAndroid Build Coastguard Worker m_context, (string(fmtName) + "_2d").c_str(), "", format, dataType, MIPMAPS, tex2DWidth, tex2DHeight));
1820*35238bceSAndroid Build Coastguard Worker basicTexSubImageGroup->addChild(new BasicTexSubImageCubeCase(m_context, (string(fmtName) + "_cube").c_str(),
1821*35238bceSAndroid Build Coastguard Worker "", format, dataType, MIPMAPS, texCubeSize,
1822*35238bceSAndroid Build Coastguard Worker texCubeSize));
1823*35238bceSAndroid Build Coastguard Worker }
1824*35238bceSAndroid Build Coastguard Worker }
1825*35238bceSAndroid Build Coastguard Worker
1826*35238bceSAndroid Build Coastguard Worker // TexSubImage2D to empty texture.
1827*35238bceSAndroid Build Coastguard Worker {
1828*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *texSubImageEmptyTexGroup = new tcu::TestCaseGroup(
1829*35238bceSAndroid Build Coastguard Worker m_testCtx, "texsubimage2d_empty_tex", "glTexSubImage2D() to texture that has storage but no data");
1830*35238bceSAndroid Build Coastguard Worker addChild(texSubImageEmptyTexGroup);
1831*35238bceSAndroid Build Coastguard Worker for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
1832*35238bceSAndroid Build Coastguard Worker {
1833*35238bceSAndroid Build Coastguard Worker const char *fmtName = texFormats[formatNdx].name;
1834*35238bceSAndroid Build Coastguard Worker uint32_t format = texFormats[formatNdx].format;
1835*35238bceSAndroid Build Coastguard Worker uint32_t dataType = texFormats[formatNdx].dataType;
1836*35238bceSAndroid Build Coastguard Worker const int tex2DWidth = 64;
1837*35238bceSAndroid Build Coastguard Worker const int tex2DHeight = 32;
1838*35238bceSAndroid Build Coastguard Worker const int texCubeSize = 32;
1839*35238bceSAndroid Build Coastguard Worker
1840*35238bceSAndroid Build Coastguard Worker texSubImageEmptyTexGroup->addChild(new TexSubImage2DEmptyTexCase(
1841*35238bceSAndroid Build Coastguard Worker m_context, (string(fmtName) + "_2d").c_str(), "", format, dataType, MIPMAPS, tex2DWidth, tex2DHeight));
1842*35238bceSAndroid Build Coastguard Worker texSubImageEmptyTexGroup->addChild(
1843*35238bceSAndroid Build Coastguard Worker new TexSubImageCubeEmptyTexCase(m_context, (string(fmtName) + "_cube").c_str(), "", format, dataType,
1844*35238bceSAndroid Build Coastguard Worker MIPMAPS, texCubeSize, texCubeSize));
1845*35238bceSAndroid Build Coastguard Worker }
1846*35238bceSAndroid Build Coastguard Worker }
1847*35238bceSAndroid Build Coastguard Worker
1848*35238bceSAndroid Build Coastguard Worker // TexSubImage2D alignment cases.
1849*35238bceSAndroid Build Coastguard Worker {
1850*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *alignGroup =
1851*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_align", "glTexSubImage2D() unpack alignment tests");
1852*35238bceSAndroid Build Coastguard Worker addChild(alignGroup);
1853*35238bceSAndroid Build Coastguard Worker
1854*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_l8_1_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64,
1855*35238bceSAndroid Build Coastguard Worker 64, 13, 17, 1, 6, 1));
1856*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_l8_1_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64,
1857*35238bceSAndroid Build Coastguard Worker 64, 13, 17, 1, 6, 2));
1858*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_l8_1_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64,
1859*35238bceSAndroid Build Coastguard Worker 64, 13, 17, 1, 6, 4));
1860*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_l8_1_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64,
1861*35238bceSAndroid Build Coastguard Worker 64, 13, 17, 1, 6, 8));
1862*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_l8_63_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64,
1863*35238bceSAndroid Build Coastguard Worker 64, 1, 9, 63, 30, 1));
1864*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_l8_63_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64,
1865*35238bceSAndroid Build Coastguard Worker 64, 1, 9, 63, 30, 2));
1866*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_l8_63_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64,
1867*35238bceSAndroid Build Coastguard Worker 64, 1, 9, 63, 30, 4));
1868*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_l8_63_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64,
1869*35238bceSAndroid Build Coastguard Worker 64, 1, 9, 63, 30, 8));
1870*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgba4444_51_1", "", GL_RGBA,
1871*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 1));
1872*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgba4444_51_2", "", GL_RGBA,
1873*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 2));
1874*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgba4444_51_4", "", GL_RGBA,
1875*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 4));
1876*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgba4444_51_8", "", GL_RGBA,
1877*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 8));
1878*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgb888_39_1", "", GL_RGB, GL_UNSIGNED_BYTE, 64,
1879*35238bceSAndroid Build Coastguard Worker 64, 11, 8, 39, 43, 1));
1880*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgb888_39_2", "", GL_RGB, GL_UNSIGNED_BYTE, 64,
1881*35238bceSAndroid Build Coastguard Worker 64, 11, 8, 39, 43, 2));
1882*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgb888_39_4", "", GL_RGB, GL_UNSIGNED_BYTE, 64,
1883*35238bceSAndroid Build Coastguard Worker 64, 11, 8, 39, 43, 4));
1884*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgb888_39_8", "", GL_RGB, GL_UNSIGNED_BYTE, 64,
1885*35238bceSAndroid Build Coastguard Worker 64, 11, 8, 39, 43, 8));
1886*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgba8888_47_1", "", GL_RGBA, GL_UNSIGNED_BYTE,
1887*35238bceSAndroid Build Coastguard Worker 64, 64, 10, 1, 47, 27, 1));
1888*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgba8888_47_2", "", GL_RGBA, GL_UNSIGNED_BYTE,
1889*35238bceSAndroid Build Coastguard Worker 64, 64, 10, 1, 47, 27, 2));
1890*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgba8888_47_4", "", GL_RGBA, GL_UNSIGNED_BYTE,
1891*35238bceSAndroid Build Coastguard Worker 64, 64, 10, 1, 47, 27, 4));
1892*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImage2DAlignCase(m_context, "2d_rgba8888_47_8", "", GL_RGBA, GL_UNSIGNED_BYTE,
1893*35238bceSAndroid Build Coastguard Worker 64, 64, 10, 1, 47, 27, 8));
1894*35238bceSAndroid Build Coastguard Worker
1895*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_l8_1_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE,
1896*35238bceSAndroid Build Coastguard Worker 64, 64, 13, 17, 1, 6, 1));
1897*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_l8_1_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE,
1898*35238bceSAndroid Build Coastguard Worker 64, 64, 13, 17, 1, 6, 2));
1899*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_l8_1_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE,
1900*35238bceSAndroid Build Coastguard Worker 64, 64, 13, 17, 1, 6, 4));
1901*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_l8_1_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE,
1902*35238bceSAndroid Build Coastguard Worker 64, 64, 13, 17, 1, 6, 8));
1903*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_l8_63_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE,
1904*35238bceSAndroid Build Coastguard Worker 64, 64, 1, 9, 63, 30, 1));
1905*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_l8_63_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE,
1906*35238bceSAndroid Build Coastguard Worker 64, 64, 1, 9, 63, 30, 2));
1907*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_l8_63_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE,
1908*35238bceSAndroid Build Coastguard Worker 64, 64, 1, 9, 63, 30, 4));
1909*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_l8_63_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE,
1910*35238bceSAndroid Build Coastguard Worker 64, 64, 1, 9, 63, 30, 8));
1911*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgba4444_51_1", "", GL_RGBA,
1912*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 1));
1913*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgba4444_51_2", "", GL_RGBA,
1914*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 2));
1915*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgba4444_51_4", "", GL_RGBA,
1916*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 4));
1917*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgba4444_51_8", "", GL_RGBA,
1918*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 8));
1919*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgb888_39_1", "", GL_RGB, GL_UNSIGNED_BYTE,
1920*35238bceSAndroid Build Coastguard Worker 64, 64, 11, 8, 39, 43, 1));
1921*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgb888_39_2", "", GL_RGB, GL_UNSIGNED_BYTE,
1922*35238bceSAndroid Build Coastguard Worker 64, 64, 11, 8, 39, 43, 2));
1923*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgb888_39_4", "", GL_RGB, GL_UNSIGNED_BYTE,
1924*35238bceSAndroid Build Coastguard Worker 64, 64, 11, 8, 39, 43, 4));
1925*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgb888_39_8", "", GL_RGB, GL_UNSIGNED_BYTE,
1926*35238bceSAndroid Build Coastguard Worker 64, 64, 11, 8, 39, 43, 8));
1927*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgba8888_47_1", "", GL_RGBA,
1928*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 1));
1929*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgba8888_47_2", "", GL_RGBA,
1930*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 2));
1931*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgba8888_47_4", "", GL_RGBA,
1932*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 4));
1933*35238bceSAndroid Build Coastguard Worker alignGroup->addChild(new TexSubImageCubeAlignCase(m_context, "cube_rgba8888_47_8", "", GL_RGBA,
1934*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 8));
1935*35238bceSAndroid Build Coastguard Worker }
1936*35238bceSAndroid Build Coastguard Worker
1937*35238bceSAndroid Build Coastguard Worker // Basic glCopyTexImage2D() cases
1938*35238bceSAndroid Build Coastguard Worker {
1939*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *copyTexImageGroup =
1940*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "basic_copyteximage2d", "Basic glCopyTexImage2D() usage");
1941*35238bceSAndroid Build Coastguard Worker addChild(copyTexImageGroup);
1942*35238bceSAndroid Build Coastguard Worker
1943*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(new BasicCopyTexImage2DCase(m_context, "2d_alpha", "", GL_ALPHA, MIPMAPS, 128, 64));
1944*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(
1945*35238bceSAndroid Build Coastguard Worker new BasicCopyTexImage2DCase(m_context, "2d_luminance", "", GL_LUMINANCE, MIPMAPS, 128, 64));
1946*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(
1947*35238bceSAndroid Build Coastguard Worker new BasicCopyTexImage2DCase(m_context, "2d_luminance_alpha", "", GL_LUMINANCE_ALPHA, MIPMAPS, 128, 64));
1948*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(new BasicCopyTexImage2DCase(m_context, "2d_rgb", "", GL_RGB, MIPMAPS, 128, 64));
1949*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(new BasicCopyTexImage2DCase(m_context, "2d_rgba", "", GL_RGBA, MIPMAPS, 128, 64));
1950*35238bceSAndroid Build Coastguard Worker
1951*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(
1952*35238bceSAndroid Build Coastguard Worker new BasicCopyTexImageCubeCase(m_context, "cube_alpha", "", GL_ALPHA, MIPMAPS, 64, 64));
1953*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(
1954*35238bceSAndroid Build Coastguard Worker new BasicCopyTexImageCubeCase(m_context, "cube_luminance", "", GL_LUMINANCE, MIPMAPS, 64, 64));
1955*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(
1956*35238bceSAndroid Build Coastguard Worker new BasicCopyTexImageCubeCase(m_context, "cube_luminance_alpha", "", GL_LUMINANCE_ALPHA, MIPMAPS, 64, 64));
1957*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase(m_context, "cube_rgb", "", GL_RGB, MIPMAPS, 64, 64));
1958*35238bceSAndroid Build Coastguard Worker copyTexImageGroup->addChild(
1959*35238bceSAndroid Build Coastguard Worker new BasicCopyTexImageCubeCase(m_context, "cube_rgba", "", GL_RGBA, MIPMAPS, 64, 64));
1960*35238bceSAndroid Build Coastguard Worker }
1961*35238bceSAndroid Build Coastguard Worker
1962*35238bceSAndroid Build Coastguard Worker // Basic glCopyTexSubImage2D() cases
1963*35238bceSAndroid Build Coastguard Worker {
1964*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *copyTexSubImageGroup =
1965*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "basic_copytexsubimage2d", "Basic glCopyTexSubImage2D() usage");
1966*35238bceSAndroid Build Coastguard Worker addChild(copyTexSubImageGroup);
1967*35238bceSAndroid Build Coastguard Worker
1968*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(
1969*35238bceSAndroid Build Coastguard Worker new BasicCopyTexSubImage2DCase(m_context, "2d_alpha", "", GL_ALPHA, GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1970*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase(m_context, "2d_luminance", "", GL_LUMINANCE,
1971*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1972*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase(
1973*35238bceSAndroid Build Coastguard Worker m_context, "2d_luminance_alpha", "", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1974*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(
1975*35238bceSAndroid Build Coastguard Worker new BasicCopyTexSubImage2DCase(m_context, "2d_rgb", "", GL_RGB, GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1976*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(
1977*35238bceSAndroid Build Coastguard Worker new BasicCopyTexSubImage2DCase(m_context, "2d_rgba", "", GL_RGBA, GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1978*35238bceSAndroid Build Coastguard Worker
1979*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(
1980*35238bceSAndroid Build Coastguard Worker new BasicCopyTexSubImageCubeCase(m_context, "cube_alpha", "", GL_ALPHA, GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
1981*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase(m_context, "cube_luminance", "", GL_LUMINANCE,
1982*35238bceSAndroid Build Coastguard Worker GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
1983*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase(
1984*35238bceSAndroid Build Coastguard Worker m_context, "cube_luminance_alpha", "", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
1985*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(
1986*35238bceSAndroid Build Coastguard Worker new BasicCopyTexSubImageCubeCase(m_context, "cube_rgb", "", GL_RGB, GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
1987*35238bceSAndroid Build Coastguard Worker copyTexSubImageGroup->addChild(
1988*35238bceSAndroid Build Coastguard Worker new BasicCopyTexSubImageCubeCase(m_context, "cube_rgba", "", GL_RGBA, GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
1989*35238bceSAndroid Build Coastguard Worker }
1990*35238bceSAndroid Build Coastguard Worker }
1991*35238bceSAndroid Build Coastguard Worker
1992*35238bceSAndroid Build Coastguard Worker } // namespace Functional
1993*35238bceSAndroid Build Coastguard Worker } // namespace gles2
1994*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1995