1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Texture specification tests.
23 * \todo [pyry] Following tests are missing:
24 * - Specify mipmap incomplete texture, use without mipmaps, re-specify
25 * as complete and render.
26 * - Randomly re-specify levels to eventually reach mipmap-complete texture.
27 *//*--------------------------------------------------------------------*/
29 #include "es2fTextureSpecificationTests.hpp"
30 #include "tcuTestLog.hpp"
31 #include "tcuImageCompare.hpp"
32 #include "gluTextureUtil.hpp"
33 #include "sglrContextUtil.hpp"
34 #include "sglrContextWrapper.hpp"
35 #include "sglrGLContext.hpp"
36 #include "sglrReferenceContext.hpp"
37 #include "glsTextureTestUtil.hpp"
38 #include "tcuTextureUtil.hpp"
39 #include "tcuFormatUtil.hpp"
40 #include "tcuVectorUtil.hpp"
41 #include "deRandom.hpp"
42 #include "deStringUtil.hpp"
44 #include "glwEnums.hpp"
45 #include "glwFunctions.hpp"
62 tcu::TextureFormat mapGLUnsizedInternalFormat (deUint32 internalFormat)
64 using tcu::TextureFormat;
65 switch (internalFormat)
67 case GL_ALPHA: return TextureFormat(TextureFormat::A, TextureFormat::UNORM_INT8);
68 case GL_LUMINANCE: return TextureFormat(TextureFormat::L, TextureFormat::UNORM_INT8);
69 case GL_LUMINANCE_ALPHA: return TextureFormat(TextureFormat::LA, TextureFormat::UNORM_INT8);
70 case GL_RGB: return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8);
71 case GL_RGBA: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8);
73 throw tcu::InternalError(string("Can't map GL unsized internal format (") + tcu::toHex(internalFormat).toString() + ") to texture format");
78 static tcu::Vector<float, Size> randomVector (de::Random& rnd, const tcu::Vector<float, Size>& minVal = tcu::Vector<float, Size>(0.0f), const tcu::Vector<float, Size>& maxVal = tcu::Vector<float, Size>(1.0f))
80 tcu::Vector<float, Size> res;
81 for (int ndx = 0; ndx < Size; ndx++)
82 res[ndx] = rnd.getFloat(minVal[ndx], maxVal[ndx]);
86 static tcu::IVec4 getPixelFormatCompareDepth (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat)
88 switch (textureFormat.order)
90 case tcu::TextureFormat::L:
91 case tcu::TextureFormat::LA:
92 return tcu::IVec4(pixelFormat.redBits, pixelFormat.redBits, pixelFormat.redBits, pixelFormat.alphaBits);
94 return tcu::IVec4(pixelFormat.redBits, pixelFormat.greenBits, pixelFormat.blueBits, pixelFormat.alphaBits);
98 static tcu::UVec4 computeCompareThreshold (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat)
100 const IVec4 texFormatBits = tcu::getTextureFormatBitDepth(textureFormat);
101 const IVec4 pixelFormatBits = getPixelFormatCompareDepth(pixelFormat, textureFormat);
102 const IVec4 accurateFmtBits = min(pixelFormatBits, texFormatBits);
103 const IVec4 compareBits = select(accurateFmtBits, IVec4(8), greaterThan(accurateFmtBits, IVec4(0))) - 1;
105 return (IVec4(1) << (8-compareBits)).asUint();
108 class GradientShader : public sglr::ShaderProgram
111 GradientShader (void)
112 : ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
113 << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
114 << sglr::pdec::VertexAttribute("a_coord", rr::GENERICVECTYPE_FLOAT)
115 << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
116 << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
117 << sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
118 "attribute mediump vec2 a_coord;\n"
119 "varying mediump vec2 v_coord;\n"
122 " gl_Position = a_position;\n"
123 " v_coord = a_coord;\n"
125 << sglr::pdec::FragmentSource("varying mediump vec2 v_coord;\n"
128 " mediump float x = v_coord.x;\n"
129 " mediump float y = v_coord.y;\n"
130 " mediump float f0 = (x + y) * 0.5;\n"
131 " mediump float f1 = 0.5 + (x - y) * 0.5;\n"
132 " gl_FragColor = vec4(f0, f1, 1.0-f0, 1.0-f1);\n"
137 void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const
139 for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
141 rr::VertexPacket& packet = *packets[packetNdx];
143 packet.position = rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
144 packet.outputs[0] = rr::readVertexAttribFloat(inputs[1], packet.instanceNdx, packet.vertexNdx);
148 void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const
150 for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
151 for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
153 const tcu::Vec4 coord = rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
154 const float x = coord.x();
155 const float y = coord.y();
156 const float f0 = (x + y) * 0.5f;
157 const float f1 = 0.5f + (x - y) * 0.5f;
159 rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, tcu::Vec4(f0, f1, 1.0f-f0, 1.0f-f1));
164 class Tex2DShader : public sglr::ShaderProgram
168 : ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
169 << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
170 << sglr::pdec::VertexAttribute("a_coord", rr::GENERICVECTYPE_FLOAT)
171 << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
172 << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
173 << sglr::pdec::Uniform("u_sampler0", glu::TYPE_SAMPLER_2D)
174 << sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
175 "attribute mediump vec2 a_coord;\n"
176 "varying mediump vec2 v_coord;\n"
179 " gl_Position = a_position;\n"
180 " v_coord = a_coord;\n"
182 << sglr::pdec::FragmentSource("uniform sampler2D u_sampler0;\n"
183 "varying mediump vec2 v_coord;\n"
186 " gl_FragColor = texture2D(u_sampler0, v_coord);\n"
191 void setUniforms (sglr::Context& ctx, deUint32 program) const
193 ctx.useProgram(program);
194 ctx.uniform1i(ctx.getUniformLocation(program, "u_sampler0"), 0);
197 void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const
199 for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
201 rr::VertexPacket& packet = *packets[packetNdx];
203 packet.position = rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
204 packet.outputs[0] = rr::readVertexAttribFloat(inputs[1], packet.instanceNdx, packet.vertexNdx);
208 void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const
210 tcu::Vec2 texCoords[4];
213 for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
216 for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
218 const tcu::Vec4 coord = rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
219 texCoords[fragNdx] = tcu::Vec2(coord.x(), coord.y());
223 m_uniforms[0].sampler.tex2D->sample4(colors, texCoords);
226 for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
227 rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, colors[fragNdx]);
232 static const char* s_cubeSwizzles[] =
242 class TexCubeShader : public sglr::ShaderProgram
245 TexCubeShader (tcu::CubeFace face)
246 : ShaderProgram(sglr::pdec::ShaderProgramDeclaration()
247 << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT)
248 << sglr::pdec::VertexAttribute("a_coord", rr::GENERICVECTYPE_FLOAT)
249 << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT)
250 << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT)
251 << sglr::pdec::Uniform("u_sampler0", glu::TYPE_SAMPLER_CUBE)
252 << sglr::pdec::VertexSource("attribute highp vec4 a_position;\n"
253 "attribute mediump vec2 a_coord;\n"
254 "varying mediump vec2 v_coord;\n"
257 " gl_Position = a_position;\n"
258 " v_coord = a_coord;\n"
260 << sglr::pdec::FragmentSource(string("") +
261 "uniform samplerCube u_sampler0;\n"
262 "varying mediump vec2 v_coord;\n"
265 " mediump float x = v_coord.x*2.0 - 1.0;\n"
266 " mediump float y = v_coord.y*2.0 - 1.0;\n"
267 " gl_FragColor = textureCube(u_sampler0, " + s_cubeSwizzles[face] + ");\n"
273 void setUniforms (sglr::Context& ctx, deUint32 program) const
275 ctx.useProgram(program);
276 ctx.uniform1i(ctx.getUniformLocation(program, "u_sampler0"), 0);
279 void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const
281 for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
283 rr::VertexPacket& packet = *packets[packetNdx];
285 packet.position = rr::readVertexAttribFloat(inputs[0], packet.instanceNdx, packet.vertexNdx);
286 packet.outputs[0] = rr::readVertexAttribFloat(inputs[1], packet.instanceNdx, packet.vertexNdx);
290 void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const
292 tcu::Vec3 texCoords[4];
295 for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx)
298 for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
300 const tcu::Vec4 coord = rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
301 const float x = coord.x()*2.0f - 1.0f;
302 const float y = coord.y()*2.0f - 1.0f;
304 // Swizzle tex coords
307 case tcu::CUBEFACE_NEGATIVE_X: texCoords[fragNdx] = tcu::Vec3(-1.0f, -y, +x); break;
308 case tcu::CUBEFACE_POSITIVE_X: texCoords[fragNdx] = tcu::Vec3(+1.0f, -y, -x); break;
309 case tcu::CUBEFACE_NEGATIVE_Y: texCoords[fragNdx] = tcu::Vec3( +x, -1.0f, -y); break;
310 case tcu::CUBEFACE_POSITIVE_Y: texCoords[fragNdx] = tcu::Vec3( +x, +1.0f, +y); break;
311 case tcu::CUBEFACE_NEGATIVE_Z: texCoords[fragNdx] = tcu::Vec3( -x, -y, -1.0f); break;
312 case tcu::CUBEFACE_POSITIVE_Z: texCoords[fragNdx] = tcu::Vec3( +x, -y, +1.0f); break;
319 m_uniforms[0].sampler.texCube->sample4(colors, texCoords);
322 for (int fragNdx = 0; fragNdx < 4; ++fragNdx)
323 rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, colors[fragNdx]);
327 tcu::CubeFace m_face;
343 static const deUint32 s_cubeMapFaces[] =
345 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
346 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
347 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
348 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
349 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
350 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
353 class TextureSpecCase : public TestCase, public sglr::ContextWrapper
356 TextureSpecCase (Context& context, const char* name, const char* desc, const TextureType type, const tcu::TextureFormat format, const deUint32 flags, int width, int height);
357 ~TextureSpecCase (void);
359 IterateResult iterate (void);
362 virtual void createTexture (void) = DE_NULL;
364 const TextureType m_texType;
365 const tcu::TextureFormat m_texFormat;
366 const deUint32 m_flags;
371 TextureSpecCase (const TextureSpecCase& other);
372 TextureSpecCase& operator= (const TextureSpecCase& other);
374 void verifyTex2D (sglr::GLContext& gles2Context, sglr::ReferenceContext& refContext);
375 void verifyTexCube (sglr::GLContext& gles2Context, sglr::ReferenceContext& refContext);
377 void renderTex2D (tcu::Surface& dst, int width, int height);
378 void renderTexCube (tcu::Surface& dst, int width, int height, tcu::CubeFace face);
380 void readPixels (tcu::Surface& dst, int x, int y, int width, int height);
382 // \todo [2012-03-27 pyry] Renderer should be extended to allow custom attributes, that would clean up this cubemap mess.
383 Tex2DShader m_tex2DShader;
384 TexCubeShader m_texCubeNegXShader;
385 TexCubeShader m_texCubePosXShader;
386 TexCubeShader m_texCubeNegYShader;
387 TexCubeShader m_texCubePosYShader;
388 TexCubeShader m_texCubeNegZShader;
389 TexCubeShader m_texCubePosZShader;
392 TextureSpecCase::TextureSpecCase (Context& context, const char* name, const char* desc, const TextureType type, const tcu::TextureFormat format, const deUint32 flags, int width, int height)
393 : TestCase (context, name, desc)
395 , m_texFormat (format)
399 , m_texCubeNegXShader (tcu::CUBEFACE_NEGATIVE_X)
400 , m_texCubePosXShader (tcu::CUBEFACE_POSITIVE_X)
401 , m_texCubeNegYShader (tcu::CUBEFACE_NEGATIVE_Y)
402 , m_texCubePosYShader (tcu::CUBEFACE_POSITIVE_Y)
403 , m_texCubeNegZShader (tcu::CUBEFACE_NEGATIVE_Z)
404 , m_texCubePosZShader (tcu::CUBEFACE_POSITIVE_Z)
408 TextureSpecCase::~TextureSpecCase (void)
412 TextureSpecCase::IterateResult TextureSpecCase::iterate (void)
414 glu::RenderContext& renderCtx = TestCase::m_context.getRenderContext();
415 const tcu::RenderTarget& renderTarget = renderCtx.getRenderTarget();
416 tcu::TestLog& log = m_testCtx.getLog();
418 DE_ASSERT(m_width <= 256 && m_height <= 256);
419 if (renderTarget.getWidth() < m_width || renderTarget.getHeight() < m_height)
420 throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
422 // Context size, and viewport for GLES2
423 de::Random rnd (deStringHash(getName()));
424 int width = deMin32(renderTarget.getWidth(), 256);
425 int height = deMin32(renderTarget.getHeight(), 256);
426 int x = rnd.getInt(0, renderTarget.getWidth() - width);
427 int y = rnd.getInt(0, renderTarget.getHeight() - height);
430 sglr::GLContext gles2Context (renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height));
431 sglr::ReferenceContextBuffers refBuffers (tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), 0 /* depth */, 0 /* stencil */, width, height);
432 sglr::ReferenceContext refContext (sglr::ReferenceContextLimits(renderCtx), refBuffers.getColorbuffer(), refBuffers.getDepthbuffer(), refBuffers.getStencilbuffer());
434 // Clear color buffer.
435 for (int ndx = 0; ndx < 2; ndx++)
437 setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles2Context);
438 glClearColor(0.125f, 0.25f, 0.5f, 1.0f);
439 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
442 // Construct texture using both GLES2 and reference contexts.
443 for (int ndx = 0; ndx < 2; ndx++)
445 setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles2Context);
447 TCU_CHECK(glGetError() == GL_NO_ERROR);
450 // Setup texture filtering state.
451 for (int ndx = 0; ndx < 2; ndx++)
453 setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles2Context);
455 deUint32 texTarget = m_texType == TEXTURETYPE_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP;
456 glTexParameteri(texTarget, GL_TEXTURE_MIN_FILTER, (m_flags & MIPMAPS) ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST);
457 glTexParameteri(texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
458 glTexParameteri(texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
459 glTexParameteri(texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
462 // Initialize case result to pass.
463 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
466 gles2Context.enableLogging(0);
471 case TEXTURETYPE_2D: verifyTex2D (gles2Context, refContext); break;
472 case TEXTURETYPE_CUBE: verifyTexCube (gles2Context, refContext); break;
480 void TextureSpecCase::verifyTex2D (sglr::GLContext& gles2Context, sglr::ReferenceContext& refContext)
482 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
484 DE_ASSERT(m_texType == TEXTURETYPE_2D);
486 for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
488 int levelW = de::max(1, m_width >> levelNdx);
489 int levelH = de::max(1, m_height >> levelNdx);
490 tcu::Surface reference;
493 if (levelW <= 2 || levelH <= 2)
494 continue; // Don't bother checking.
497 setContext(&gles2Context);
498 renderTex2D(result, levelW, levelH);
501 setContext(&refContext);
502 renderTex2D(reference, levelW, levelH);
505 tcu::UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
506 bool isOk = tcu::intThresholdCompare(m_testCtx.getLog(), "Result", "Image comparison result", reference.getAccess(), result.getAccess(), threshold,
507 levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
511 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
518 void TextureSpecCase::verifyTexCube (sglr::GLContext& gles2Context, sglr::ReferenceContext& refContext)
520 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
522 DE_ASSERT(m_texType == TEXTURETYPE_CUBE);
524 for (int levelNdx = 0; levelNdx < numLevels; levelNdx++)
526 int levelW = de::max(1, m_width >> levelNdx);
527 int levelH = de::max(1, m_height >> levelNdx);
530 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
532 tcu::Surface reference;
535 if (levelW <= 2 || levelH <= 2)
536 continue; // Don't bother checking.
539 setContext(&gles2Context);
540 renderTexCube(result, levelW, levelH, (tcu::CubeFace)face);
543 setContext(&refContext);
544 renderTexCube(reference, levelW, levelH, (tcu::CubeFace)face);
546 const float threshold = 0.02f;
547 isOk = tcu::fuzzyCompare(m_testCtx.getLog(), "Result", (string("Image comparison result: ") + de::toString((tcu::CubeFace)face)).c_str(), reference, result, threshold,
548 levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
552 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
562 void TextureSpecCase::renderTex2D (tcu::Surface& dst, int width, int height)
564 int targetW = getWidth();
565 int targetH = getHeight();
567 float w = (float)width / (float)targetW;
568 float h = (float)height / (float)targetH;
570 deUint32 shaderID = getCurrentContext()->createProgram(&m_tex2DShader);
572 m_tex2DShader.setUniforms(*getCurrentContext(), shaderID);
573 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(-1.0f + w*2.0f, -1.0f + h*2.0f, 0.0f));
576 readPixels(dst, 0, 0, width, height);
579 void TextureSpecCase::renderTexCube (tcu::Surface& dst, int width, int height, tcu::CubeFace face)
581 int targetW = getWidth();
582 int targetH = getHeight();
584 float w = (float)width / (float)targetW;
585 float h = (float)height / (float)targetH;
587 TexCubeShader* shaders[] =
589 &m_texCubeNegXShader,
590 &m_texCubePosXShader,
591 &m_texCubeNegYShader,
592 &m_texCubePosYShader,
593 &m_texCubeNegZShader,
597 deUint32 shaderID = getCurrentContext()->createProgram(shaders[face]);
599 shaders[face]->setUniforms(*getCurrentContext(), shaderID);
600 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(-1.0f + w*2.0f, -1.0f + h*2.0f, 0.0f));
603 readPixels(dst, 0, 0, width, height);
606 void TextureSpecCase::readPixels (tcu::Surface& dst, int x, int y, int width, int height)
608 dst.setSize(width, height);
609 glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
612 // Basic TexImage2D() with 2D texture usage
613 class BasicTexImage2DCase : public TextureSpecCase
616 BasicTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
617 : TextureSpecCase (context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
619 , m_dataType (dataType)
624 void createTexture (void)
626 tcu::TextureFormat fmt = m_texFormat;
627 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
629 tcu::TextureLevel levelData (fmt);
630 de::Random rnd (deStringHash(getName()));
632 glGenTextures(1, &tex);
633 glBindTexture(GL_TEXTURE_2D, tex);
634 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
636 for (int ndx = 0; ndx < numLevels; ndx++)
638 int levelW = de::max(1, m_width >> ndx);
639 int levelH = de::max(1, m_height >> ndx);
640 Vec4 gMin = randomVector<4>(rnd);
641 Vec4 gMax = randomVector<4>(rnd);
643 levelData.setSize(levelW, levelH);
644 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
646 glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
654 // Basic TexImage2D() with cubemap usage
655 class BasicTexImageCubeCase : public TextureSpecCase
658 BasicTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
659 : TextureSpecCase (context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
661 , m_dataType (dataType)
666 void createTexture (void)
668 tcu::TextureFormat fmt = m_texFormat;
669 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
671 tcu::TextureLevel levelData (fmt);
672 de::Random rnd (deStringHash(getName()));
674 DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
676 glGenTextures(1, &tex);
677 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
678 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
680 for (int ndx = 0; ndx < numLevels; ndx++)
682 int levelW = de::max(1, m_width >> ndx);
683 int levelH = de::max(1, m_height >> ndx);
685 levelData.setSize(levelW, levelH);
687 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
689 Vec4 gMin = randomVector<4>(rnd);
690 Vec4 gMax = randomVector<4>(rnd);
692 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
694 glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
703 // Randomized 2D texture specification using TexImage2D
704 class RandomOrderTexImage2DCase : public TextureSpecCase
707 RandomOrderTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
708 : TextureSpecCase (context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
710 , m_dataType (dataType)
715 void createTexture (void)
717 tcu::TextureFormat fmt = m_texFormat;
718 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
720 tcu::TextureLevel levelData (fmt);
721 de::Random rnd (deStringHash(getName()));
723 glGenTextures(1, &tex);
724 glBindTexture(GL_TEXTURE_2D, tex);
725 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
727 vector<int> levels (numLevels);
729 for (int i = 0; i < numLevels; i++)
731 rnd.shuffle(levels.begin(), levels.end());
733 for (int ndx = 0; ndx < numLevels; ndx++)
735 int levelNdx = levels[ndx];
736 int levelW = de::max(1, m_width >> levelNdx);
737 int levelH = de::max(1, m_height >> levelNdx);
738 Vec4 gMin = randomVector<4>(rnd);
739 Vec4 gMax = randomVector<4>(rnd);
741 levelData.setSize(levelW, levelH);
742 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
744 glTexImage2D(GL_TEXTURE_2D, levelNdx, m_format, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
752 // Randomized cubemap texture specification using TexImage2D
753 class RandomOrderTexImageCubeCase : public TextureSpecCase
756 RandomOrderTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
757 : TextureSpecCase (context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
759 , m_dataType (dataType)
764 void createTexture (void)
766 tcu::TextureFormat fmt = m_texFormat;
767 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
769 tcu::TextureLevel levelData (fmt);
770 de::Random rnd (deStringHash(getName()));
772 DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
774 glGenTextures(1, &tex);
775 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
776 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
779 vector<pair<int, tcu::CubeFace> > images (numLevels*6);
781 for (int ndx = 0; ndx < numLevels; ndx++)
782 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
783 images[ndx*6 + face] = std::make_pair(ndx, (tcu::CubeFace)face);
785 rnd.shuffle(images.begin(), images.end());
787 for (int ndx = 0; ndx < (int)images.size(); ndx++)
789 int levelNdx = images[ndx].first;
790 tcu::CubeFace face = images[ndx].second;
791 int levelW = de::max(1, m_width >> levelNdx);
792 int levelH = de::max(1, m_height >> levelNdx);
793 Vec4 gMin = randomVector<4>(rnd);
794 Vec4 gMax = randomVector<4>(rnd);
796 levelData.setSize(levelW, levelH);
797 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
799 glTexImage2D(s_cubeMapFaces[face], levelNdx, m_format, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
807 static inline int getRowPitch (const tcu::TextureFormat& transferFmt, int rowLen, int alignment)
809 int basePitch = transferFmt.getPixelSize()*rowLen;
810 return alignment*(basePitch/alignment + ((basePitch % alignment) ? 1 : 0));
813 // TexImage2D() unpack alignment case.
814 class TexImage2DAlignCase : public TextureSpecCase
817 TexImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height, int alignment)
818 : TextureSpecCase (context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
820 , m_dataType (dataType)
821 , m_alignment (alignment)
826 void createTexture (void)
828 tcu::TextureFormat fmt = m_texFormat;
829 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
831 vector<deUint8> data;
833 glGenTextures(1, &tex);
834 glBindTexture(GL_TEXTURE_2D, tex);
835 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
837 for (int ndx = 0; ndx < numLevels; ndx++)
839 int levelW = de::max(1, m_width >> ndx);
840 int levelH = de::max(1, m_height >> ndx);
841 Vec4 colorA (1.0f, 0.0f, 0.0f, 1.0f);
842 Vec4 colorB (0.0f, 1.0f, 0.0f, 1.0f);
843 int rowPitch = getRowPitch(fmt, levelW, m_alignment);
844 int cellSize = de::max(1, de::min(levelW >> 2, levelH >> 2));
846 data.resize(rowPitch*levelH);
847 tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB);
849 glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, &data[0]);
858 // TexImage2D() unpack alignment case.
859 class TexImageCubeAlignCase : public TextureSpecCase
862 TexImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height, int alignment)
863 : TextureSpecCase (context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
865 , m_dataType (dataType)
866 , m_alignment (alignment)
871 void createTexture (void)
873 tcu::TextureFormat fmt = m_texFormat;
874 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
876 vector<deUint8> data;
878 DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
880 glGenTextures(1, &tex);
881 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
882 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
884 for (int ndx = 0; ndx < numLevels; ndx++)
886 int levelW = de::max(1, m_width >> ndx);
887 int levelH = de::max(1, m_height >> ndx);
888 int rowPitch = getRowPitch(fmt, levelW, m_alignment);
889 Vec4 colorA (1.0f, 0.0f, 0.0f, 1.0f);
890 Vec4 colorB (0.0f, 1.0f, 0.0f, 1.0f);
891 int cellSize = de::max(1, de::min(levelW >> 2, levelH >> 2));
893 data.resize(rowPitch*levelH);
894 tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB);
896 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
897 glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, &data[0]);
906 // Basic TexSubImage2D() with 2D texture usage
907 class BasicTexSubImage2DCase : public TextureSpecCase
910 BasicTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
911 : TextureSpecCase (context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
913 , m_dataType (dataType)
918 void createTexture (void)
920 tcu::TextureFormat fmt = m_texFormat;
921 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
923 tcu::TextureLevel data (fmt);
924 de::Random rnd (deStringHash(getName()));
926 glGenTextures(1, &tex);
927 glBindTexture(GL_TEXTURE_2D, tex);
928 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
930 // First specify full texture.
931 for (int ndx = 0; ndx < numLevels; ndx++)
933 int levelW = de::max(1, m_width >> ndx);
934 int levelH = de::max(1, m_height >> ndx);
935 Vec4 gMin = randomVector<4>(rnd);
936 Vec4 gMax = randomVector<4>(rnd);
938 data.setSize(levelW, levelH);
939 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
941 glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
944 // Re-specify parts of each level.
945 for (int ndx = 0; ndx < numLevels; ndx++)
947 int levelW = de::max(1, m_width >> ndx);
948 int levelH = de::max(1, m_height >> ndx);
950 int w = rnd.getInt(1, levelW);
951 int h = rnd.getInt(1, levelH);
952 int x = rnd.getInt(0, levelW-w);
953 int y = rnd.getInt(0, levelH-h);
955 Vec4 colorA = randomVector<4>(rnd);
956 Vec4 colorB = randomVector<4>(rnd);
957 int cellSize = rnd.getInt(2, 16);
960 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
962 glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
970 // Basic TexSubImage2D() with cubemap usage
971 class BasicTexSubImageCubeCase : public TextureSpecCase
974 BasicTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
975 : TextureSpecCase (context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
977 , m_dataType (dataType)
982 void createTexture (void)
984 tcu::TextureFormat fmt = m_texFormat;
985 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
987 tcu::TextureLevel data (fmt);
988 de::Random rnd (deStringHash(getName()));
990 DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
992 glGenTextures(1, &tex);
993 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
994 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
996 for (int ndx = 0; ndx < numLevels; ndx++)
998 int levelW = de::max(1, m_width >> ndx);
999 int levelH = de::max(1, m_height >> ndx);
1001 data.setSize(levelW, levelH);
1003 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1005 Vec4 gMin = randomVector<4>(rnd);
1006 Vec4 gMax = randomVector<4>(rnd);
1008 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1010 glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
1014 // Re-specify parts of each face and level.
1015 for (int ndx = 0; ndx < numLevels; ndx++)
1017 int levelW = de::max(1, m_width >> ndx);
1018 int levelH = de::max(1, m_height >> ndx);
1020 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1022 int w = rnd.getInt(1, levelW);
1023 int h = rnd.getInt(1, levelH);
1024 int x = rnd.getInt(0, levelW-w);
1025 int y = rnd.getInt(0, levelH-h);
1027 Vec4 colorA = randomVector<4>(rnd);
1028 Vec4 colorB = randomVector<4>(rnd);
1029 int cellSize = rnd.getInt(2, 16);
1032 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1034 glTexSubImage2D(s_cubeMapFaces[face], ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
1040 deUint32 m_dataType;
1043 // TexSubImage2D() to texture initialized with empty data
1044 class TexSubImage2DEmptyTexCase : public TextureSpecCase
1047 TexSubImage2DEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
1048 : TextureSpecCase (context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
1050 , m_dataType (dataType)
1055 void createTexture (void)
1057 tcu::TextureFormat fmt = m_texFormat;
1058 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
1060 tcu::TextureLevel data (fmt);
1061 de::Random rnd (deStringHash(getName()));
1063 glGenTextures(1, &tex);
1064 glBindTexture(GL_TEXTURE_2D, tex);
1065 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1067 // First allocate storage for each level.
1068 for (int ndx = 0; ndx < numLevels; ndx++)
1070 int levelW = de::max(1, m_width >> ndx);
1071 int levelH = de::max(1, m_height >> ndx);
1073 glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, DE_NULL);
1076 // Specify pixel data to all levels using glTexSubImage2D()
1077 for (int ndx = 0; ndx < numLevels; ndx++)
1079 int levelW = de::max(1, m_width >> ndx);
1080 int levelH = de::max(1, m_height >> ndx);
1081 Vec4 gMin = randomVector<4>(rnd);
1082 Vec4 gMax = randomVector<4>(rnd);
1084 data.setSize(levelW, levelH);
1085 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1087 glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, m_format, m_dataType, data.getAccess().getDataPtr());
1092 deUint32 m_dataType;
1095 // TexSubImage2D() to empty cubemap texture
1096 class TexSubImageCubeEmptyTexCase : public TextureSpecCase
1099 TexSubImageCubeEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
1100 : TextureSpecCase (context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
1102 , m_dataType (dataType)
1107 void createTexture (void)
1109 tcu::TextureFormat fmt = m_texFormat;
1110 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
1112 tcu::TextureLevel data (fmt);
1113 de::Random rnd (deStringHash(getName()));
1115 DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
1117 glGenTextures(1, &tex);
1118 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1119 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1121 // Specify storage for each level.
1122 for (int ndx = 0; ndx < numLevels; ndx++)
1124 int levelW = de::max(1, m_width >> ndx);
1125 int levelH = de::max(1, m_height >> ndx);
1127 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1128 glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, DE_NULL);
1131 // Specify data using glTexSubImage2D()
1132 for (int ndx = 0; ndx < numLevels; ndx++)
1134 int levelW = de::max(1, m_width >> ndx);
1135 int levelH = de::max(1, m_height >> ndx);
1137 data.setSize(levelW, levelH);
1139 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1141 Vec4 gMin = randomVector<4>(rnd);
1142 Vec4 gMax = randomVector<4>(rnd);
1144 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1146 glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelW, levelH, m_format, m_dataType, data.getAccess().getDataPtr());
1152 deUint32 m_dataType;
1155 // TexSubImage2D() unpack alignment with 2D texture
1156 class TexSubImage2DAlignCase : public TextureSpecCase
1159 TexSubImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height, int subX, int subY, int subW, int subH, int alignment)
1160 : TextureSpecCase (context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), 0 /* Mipmaps are never used */, width, height)
1162 , m_dataType (dataType)
1167 , m_alignment (alignment)
1172 void createTexture (void)
1174 tcu::TextureFormat fmt = m_texFormat;
1176 vector<deUint8> data;
1178 glGenTextures(1, &tex);
1179 glBindTexture(GL_TEXTURE_2D, tex);
1181 // Specify base level.
1182 data.resize(fmt.getPixelSize()*m_width*m_height);
1183 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(fmt, m_width, m_height, 1, &data[0]), Vec4(0.0f), Vec4(1.0f));
1185 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1186 glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_width, m_height, 0, m_format, m_dataType, &data[0]);
1188 // Re-specify subrectangle.
1189 int rowPitch = getRowPitch(fmt, m_subW, m_alignment);
1190 data.resize(rowPitch*m_subH);
1191 tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4, Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
1193 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1194 glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
1198 deUint32 m_dataType;
1206 // TexSubImage2D() unpack alignment with cubemap texture
1207 class TexSubImageCubeAlignCase : public TextureSpecCase
1210 TexSubImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height, int subX, int subY, int subW, int subH, int alignment)
1211 : TextureSpecCase (context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), 0 /* Mipmaps are never used */, width, height)
1213 , m_dataType (dataType)
1218 , m_alignment (alignment)
1223 void createTexture (void)
1225 tcu::TextureFormat fmt = m_texFormat;
1227 vector<deUint8> data;
1229 DE_ASSERT(m_width == m_height);
1231 glGenTextures(1, &tex);
1232 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1234 // Specify base level.
1235 data.resize(fmt.getPixelSize()*m_width*m_height);
1236 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(fmt, m_width, m_height, 1, &data[0]), Vec4(0.0f), Vec4(1.0f));
1238 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1239 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1240 glTexImage2D(s_cubeMapFaces[face], 0, m_format, m_width, m_height, 0, m_format, m_dataType, &data[0]);
1242 // Re-specify subrectangle.
1243 int rowPitch = getRowPitch(fmt, m_subW, m_alignment);
1244 data.resize(rowPitch*m_subH);
1245 tcu::fillWithGrid(tcu::PixelBufferAccess(fmt, m_subW, m_subH, 1, rowPitch, 0, &data[0]), 4, Vec4(1.0f, 0.0f, 0.0f, 1.0f), Vec4(0.0f, 1.0f, 0.0f, 1.0f));
1247 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1248 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1249 glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
1253 deUint32 m_dataType;
1263 // Basic CopyTexImage2D() with 2D texture usage
1264 class BasicCopyTexImage2DCase : public TextureSpecCase
1267 BasicCopyTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, deUint32 flags, int width, int height)
1268 : TextureSpecCase (context, name, desc, TEXTURETYPE_2D, mapGLUnsizedInternalFormat(internalFormat), flags, width, height)
1269 , m_internalFormat (internalFormat)
1274 void createTexture (void)
1276 const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1277 bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
1278 bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1279 tcu::TextureFormat fmt = m_texFormat;
1280 bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1281 bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
1282 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
1284 de::Random rnd (deStringHash(getName()));
1285 GradientShader shader;
1286 deUint32 shaderID = getCurrentContext()->createProgram(&shader);
1288 if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1289 throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1291 // Fill render target with gradient.
1292 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1294 glGenTextures(1, &tex);
1295 glBindTexture(GL_TEXTURE_2D, tex);
1297 for (int ndx = 0; ndx < numLevels; ndx++)
1299 int levelW = de::max(1, m_width >> ndx);
1300 int levelH = de::max(1, m_height >> ndx);
1301 int x = rnd.getInt(0, getWidth() - levelW);
1302 int y = rnd.getInt(0, getHeight() - levelH);
1304 glCopyTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, x, y, levelW, levelH, 0);
1308 deUint32 m_internalFormat;
1311 // Basic CopyTexImage2D() with cubemap usage
1312 class BasicCopyTexImageCubeCase : public TextureSpecCase
1315 BasicCopyTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, deUint32 flags, int width, int height)
1316 : TextureSpecCase (context, name, desc, TEXTURETYPE_CUBE, mapGLUnsizedInternalFormat(internalFormat), flags, width, height)
1317 , m_internalFormat (internalFormat)
1322 void createTexture (void)
1324 const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1325 bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
1326 bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1327 tcu::TextureFormat fmt = m_texFormat;
1328 bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1329 bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
1330 int numLevels = (m_flags & MIPMAPS) ? deLog2Floor32(m_width)+1 : 1;
1332 de::Random rnd (deStringHash(getName()));
1333 GradientShader shader;
1334 deUint32 shaderID = getCurrentContext()->createProgram(&shader);
1336 DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
1338 if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1339 throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1341 // Fill render target with gradient.
1342 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1344 glGenTextures(1, &tex);
1345 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1347 for (int ndx = 0; ndx < numLevels; ndx++)
1349 int levelW = de::max(1, m_width >> ndx);
1350 int levelH = de::max(1, m_height >> ndx);
1352 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1354 int x = rnd.getInt(0, getWidth() - levelW);
1355 int y = rnd.getInt(0, getHeight() - levelH);
1357 glCopyTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, x, y, levelW, levelH, 0);
1362 deUint32 m_internalFormat;
1367 // Basic CopyTexSubImage2D() with 2D texture usage
1368 class BasicCopyTexSubImage2DCase : public TextureSpecCase
1371 BasicCopyTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
1372 : TextureSpecCase (context, name, desc, TEXTURETYPE_2D, glu::mapGLTransferFormat(format, dataType), flags, width, height)
1374 , m_dataType (dataType)
1379 void createTexture (void)
1381 const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1382 bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
1383 bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1384 tcu::TextureFormat fmt = m_texFormat;
1385 bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1386 bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
1387 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
1389 tcu::TextureLevel data (fmt);
1390 de::Random rnd (deStringHash(getName()));
1391 GradientShader shader;
1392 deUint32 shaderID = getCurrentContext()->createProgram(&shader);
1394 if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1395 throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1397 glGenTextures(1, &tex);
1398 glBindTexture(GL_TEXTURE_2D, tex);
1399 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1401 // First specify full texture.
1402 for (int ndx = 0; ndx < numLevels; ndx++)
1404 int levelW = de::max(1, m_width >> ndx);
1405 int levelH = de::max(1, m_height >> ndx);
1407 Vec4 colorA = randomVector<4>(rnd);
1408 Vec4 colorB = randomVector<4>(rnd);
1409 int cellSize = rnd.getInt(2, 16);
1411 data.setSize(levelW, levelH);
1412 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1414 glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
1417 // Fill render target with gradient.
1418 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1420 // Re-specify parts of each level.
1421 for (int ndx = 0; ndx < numLevels; ndx++)
1423 int levelW = de::max(1, m_width >> ndx);
1424 int levelH = de::max(1, m_height >> ndx);
1426 int w = rnd.getInt(1, levelW);
1427 int h = rnd.getInt(1, levelH);
1428 int xo = rnd.getInt(0, levelW-w);
1429 int yo = rnd.getInt(0, levelH-h);
1431 int x = rnd.getInt(0, getWidth() - w);
1432 int y = rnd.getInt(0, getHeight() - h);
1434 glCopyTexSubImage2D(GL_TEXTURE_2D, ndx, xo, yo, x, y, w, h);
1439 deUint32 m_dataType;
1442 // Basic CopyTexSubImage2D() with cubemap usage
1443 class BasicCopyTexSubImageCubeCase : public TextureSpecCase
1446 BasicCopyTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, deUint32 flags, int width, int height)
1447 : TextureSpecCase (context, name, desc, TEXTURETYPE_CUBE, glu::mapGLTransferFormat(format, dataType), flags, width, height)
1449 , m_dataType (dataType)
1454 void createTexture (void)
1456 const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1457 bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
1458 bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1459 tcu::TextureFormat fmt = m_texFormat;
1460 bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1461 bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
1462 int numLevels = (m_flags & MIPMAPS) ? de::max(deLog2Floor32(m_width), deLog2Floor32(m_height))+1 : 1;
1464 tcu::TextureLevel data (fmt);
1465 de::Random rnd (deStringHash(getName()));
1466 GradientShader shader;
1467 deUint32 shaderID = getCurrentContext()->createProgram(&shader);
1469 DE_ASSERT(m_width == m_height); // Non-square cubemaps are not supported by GLES2.
1471 if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1472 throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1474 glGenTextures(1, &tex);
1475 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1476 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1478 for (int ndx = 0; ndx < numLevels; ndx++)
1480 int levelW = de::max(1, m_width >> ndx);
1481 int levelH = de::max(1, m_height >> ndx);
1483 data.setSize(levelW, levelH);
1485 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1487 Vec4 colorA = randomVector<4>(rnd);
1488 Vec4 colorB = randomVector<4>(rnd);
1489 int cellSize = rnd.getInt(2, 16);
1491 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1492 glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
1496 // Fill render target with gradient.
1497 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1499 // Re-specify parts of each face and level.
1500 for (int ndx = 0; ndx < numLevels; ndx++)
1502 int levelW = de::max(1, m_width >> ndx);
1503 int levelH = de::max(1, m_height >> ndx);
1505 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1507 int w = rnd.getInt(1, levelW);
1508 int h = rnd.getInt(1, levelH);
1509 int xo = rnd.getInt(0, levelW-w);
1510 int yo = rnd.getInt(0, levelH-h);
1512 int x = rnd.getInt(0, getWidth() - w);
1513 int y = rnd.getInt(0, getHeight() - h);
1515 glCopyTexSubImage2D(s_cubeMapFaces[face], ndx, xo, yo, x, y, w, h);
1521 deUint32 m_dataType;
1524 TextureSpecificationTests::TextureSpecificationTests (Context& context)
1525 : TestCaseGroup(context, "specification", "Texture Specification Tests")
1529 TextureSpecificationTests::~TextureSpecificationTests (void)
1533 void TextureSpecificationTests::init (void)
1542 { "a8", GL_ALPHA, GL_UNSIGNED_BYTE },
1543 { "l8", GL_LUMINANCE, GL_UNSIGNED_BYTE },
1544 { "la88", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
1545 { "rgb565", GL_RGB, GL_UNSIGNED_SHORT_5_6_5 },
1546 { "rgb888", GL_RGB, GL_UNSIGNED_BYTE },
1547 { "rgba4444", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 },
1548 { "rgba5551", GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 },
1549 { "rgba8888", GL_RGBA, GL_UNSIGNED_BYTE }
1552 // Basic TexImage2D usage.
1554 tcu::TestCaseGroup* basicTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_teximage2d", "Basic glTexImage2D() usage");
1555 addChild(basicTexImageGroup);
1556 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
1558 const char* fmtName = texFormats[formatNdx].name;
1559 deUint32 format = texFormats[formatNdx].format;
1560 deUint32 dataType = texFormats[formatNdx].dataType;
1561 const int tex2DWidth = 64;
1562 const int tex2DHeight = 128;
1563 const int texCubeSize = 64;
1565 basicTexImageGroup->addChild(new BasicTexImage2DCase (m_context, (string(fmtName) + "_2d").c_str(), "", format, dataType, MIPMAPS, tex2DWidth, tex2DHeight));
1566 basicTexImageGroup->addChild(new BasicTexImageCubeCase (m_context, (string(fmtName) + "_cube").c_str(), "", format, dataType, MIPMAPS, texCubeSize, texCubeSize));
1570 // Randomized TexImage2D order.
1572 tcu::TestCaseGroup* randomTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "random_teximage2d", "Randomized glTexImage2D() usage");
1573 addChild(randomTexImageGroup);
1578 for (int ndx = 0; ndx < 10; ndx++)
1580 int formatNdx = rnd.getInt(0, DE_LENGTH_OF_ARRAY(texFormats)-1);
1581 int width = 1 << rnd.getInt(2, 8);
1582 int height = 1 << rnd.getInt(2, 8);
1584 randomTexImageGroup->addChild(new RandomOrderTexImage2DCase(m_context, (string("2d_") + de::toString(ndx)).c_str(), "", texFormats[formatNdx].format, texFormats[formatNdx].dataType, MIPMAPS, width, height));
1588 for (int ndx = 0; ndx < 10; ndx++)
1590 int formatNdx = rnd.getInt(0, DE_LENGTH_OF_ARRAY(texFormats)-1);
1591 int size = 1 << rnd.getInt(2, 8);
1593 randomTexImageGroup->addChild(new RandomOrderTexImageCubeCase(m_context, (string("cube_") + de::toString(ndx)).c_str(), "", texFormats[formatNdx].format, texFormats[formatNdx].dataType, MIPMAPS, size, size));
1597 // TexImage2D unpack alignment.
1599 tcu::TestCaseGroup* alignGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_align", "glTexImage2D() unpack alignment tests");
1600 addChild(alignGroup);
1602 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_l8_4_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, MIPMAPS, 4, 8, 8));
1603 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_l8_63_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 30, 1));
1604 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_l8_63_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 30, 2));
1605 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_l8_63_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 30, 4));
1606 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_l8_63_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 30, 8));
1607 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba4444_51_1", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 30, 1));
1608 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba4444_51_2", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 30, 2));
1609 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba4444_51_4", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 30, 4));
1610 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba4444_51_8", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 30, 8));
1611 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgb888_39_1", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 43, 1));
1612 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgb888_39_2", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 43, 2));
1613 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgb888_39_4", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 43, 4));
1614 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgb888_39_8", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 43, 8));
1615 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba8888_47_1", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 27, 1));
1616 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba8888_47_2", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 27, 2));
1617 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba8888_47_4", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 27, 4));
1618 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba8888_47_8", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 27, 8));
1620 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_l8_4_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, MIPMAPS, 4, 4, 8));
1621 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_l8_63_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 63, 1));
1622 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_l8_63_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 63, 2));
1623 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_l8_63_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 63, 4));
1624 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_l8_63_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, 63, 63, 8));
1625 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba4444_51_1", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 51, 1));
1626 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba4444_51_2", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 51, 2));
1627 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba4444_51_4", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 51, 4));
1628 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba4444_51_8", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 0, 51, 51, 8));
1629 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgb888_39_1", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 39, 1));
1630 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgb888_39_2", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 39, 2));
1631 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgb888_39_4", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 39, 4));
1632 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgb888_39_8", "", GL_RGB, GL_UNSIGNED_BYTE, 0, 39, 39, 8));
1633 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba8888_47_1", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 47, 1));
1634 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba8888_47_2", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 47, 2));
1635 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba8888_47_4", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 47, 4));
1636 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba8888_47_8", "", GL_RGBA, GL_UNSIGNED_BYTE, 0, 47, 47, 8));
1639 // Basic TexSubImage2D usage.
1641 tcu::TestCaseGroup* basicTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_texsubimage2d", "Basic glTexSubImage2D() usage");
1642 addChild(basicTexSubImageGroup);
1643 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
1645 const char* fmtName = texFormats[formatNdx].name;
1646 deUint32 format = texFormats[formatNdx].format;
1647 deUint32 dataType = texFormats[formatNdx].dataType;
1648 const int tex2DWidth = 64;
1649 const int tex2DHeight = 128;
1650 const int texCubeSize = 64;
1652 basicTexSubImageGroup->addChild(new BasicTexSubImage2DCase (m_context, (string(fmtName) + "_2d").c_str(), "", format, dataType, MIPMAPS, tex2DWidth, tex2DHeight));
1653 basicTexSubImageGroup->addChild(new BasicTexSubImageCubeCase (m_context, (string(fmtName) + "_cube").c_str(), "", format, dataType, MIPMAPS, texCubeSize, texCubeSize));
1657 // TexSubImage2D to empty texture.
1659 tcu::TestCaseGroup* texSubImageEmptyTexGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_empty_tex", "glTexSubImage2D() to texture that has storage but no data");
1660 addChild(texSubImageEmptyTexGroup);
1661 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
1663 const char* fmtName = texFormats[formatNdx].name;
1664 deUint32 format = texFormats[formatNdx].format;
1665 deUint32 dataType = texFormats[formatNdx].dataType;
1666 const int tex2DWidth = 64;
1667 const int tex2DHeight = 32;
1668 const int texCubeSize = 32;
1670 texSubImageEmptyTexGroup->addChild(new TexSubImage2DEmptyTexCase (m_context, (string(fmtName) + "_2d").c_str(), "", format, dataType, MIPMAPS, tex2DWidth, tex2DHeight));
1671 texSubImageEmptyTexGroup->addChild(new TexSubImageCubeEmptyTexCase (m_context, (string(fmtName) + "_cube").c_str(), "", format, dataType, MIPMAPS, texCubeSize, texCubeSize));
1675 // TexSubImage2D alignment cases.
1677 tcu::TestCaseGroup* alignGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_align", "glTexSubImage2D() unpack alignment tests");
1678 addChild(alignGroup);
1680 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_l8_1_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 13, 17, 1, 6, 1));
1681 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_l8_1_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 13, 17, 1, 6, 2));
1682 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_l8_1_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 13, 17, 1, 6, 4));
1683 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_l8_1_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 13, 17, 1, 6, 8));
1684 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_l8_63_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 1, 9, 63, 30, 1));
1685 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_l8_63_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 1, 9, 63, 30, 2));
1686 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_l8_63_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 1, 9, 63, 30, 4));
1687 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_l8_63_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 1, 9, 63, 30, 8));
1688 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba4444_51_1", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 1));
1689 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba4444_51_2", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 2));
1690 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba4444_51_4", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 4));
1691 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba4444_51_8", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 8));
1692 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgb888_39_1", "", GL_RGB, GL_UNSIGNED_BYTE, 64, 64, 11, 8, 39, 43, 1));
1693 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgb888_39_2", "", GL_RGB, GL_UNSIGNED_BYTE, 64, 64, 11, 8, 39, 43, 2));
1694 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgb888_39_4", "", GL_RGB, GL_UNSIGNED_BYTE, 64, 64, 11, 8, 39, 43, 4));
1695 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgb888_39_8", "", GL_RGB, GL_UNSIGNED_BYTE, 64, 64, 11, 8, 39, 43, 8));
1696 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba8888_47_1", "", GL_RGBA, GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 1));
1697 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba8888_47_2", "", GL_RGBA, GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 2));
1698 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba8888_47_4", "", GL_RGBA, GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 4));
1699 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba8888_47_8", "", GL_RGBA, GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 8));
1701 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_l8_1_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 13, 17, 1, 6, 1));
1702 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_l8_1_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 13, 17, 1, 6, 2));
1703 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_l8_1_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 13, 17, 1, 6, 4));
1704 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_l8_1_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 13, 17, 1, 6, 8));
1705 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_l8_63_1", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 1, 9, 63, 30, 1));
1706 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_l8_63_2", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 1, 9, 63, 30, 2));
1707 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_l8_63_4", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 1, 9, 63, 30, 4));
1708 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_l8_63_8", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64, 64, 1, 9, 63, 30, 8));
1709 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba4444_51_1", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 1));
1710 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba4444_51_2", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 2));
1711 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba4444_51_4", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 4));
1712 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba4444_51_8", "", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 64, 64, 7, 29, 51, 30, 8));
1713 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgb888_39_1", "", GL_RGB, GL_UNSIGNED_BYTE, 64, 64, 11, 8, 39, 43, 1));
1714 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgb888_39_2", "", GL_RGB, GL_UNSIGNED_BYTE, 64, 64, 11, 8, 39, 43, 2));
1715 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgb888_39_4", "", GL_RGB, GL_UNSIGNED_BYTE, 64, 64, 11, 8, 39, 43, 4));
1716 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgb888_39_8", "", GL_RGB, GL_UNSIGNED_BYTE, 64, 64, 11, 8, 39, 43, 8));
1717 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba8888_47_1", "", GL_RGBA, GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 1));
1718 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba8888_47_2", "", GL_RGBA, GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 2));
1719 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba8888_47_4", "", GL_RGBA, GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 4));
1720 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba8888_47_8", "", GL_RGBA, GL_UNSIGNED_BYTE, 64, 64, 10, 1, 47, 27, 8));
1723 // Basic glCopyTexImage2D() cases
1725 tcu::TestCaseGroup* copyTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_copyteximage2d", "Basic glCopyTexImage2D() usage");
1726 addChild(copyTexImageGroup);
1728 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_alpha", "", GL_ALPHA, MIPMAPS, 128, 64));
1729 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_luminance", "", GL_LUMINANCE, MIPMAPS, 128, 64));
1730 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_luminance_alpha", "", GL_LUMINANCE_ALPHA, MIPMAPS, 128, 64));
1731 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_rgb", "", GL_RGB, MIPMAPS, 128, 64));
1732 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_rgba", "", GL_RGBA, MIPMAPS, 128, 64));
1734 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_alpha", "", GL_ALPHA, MIPMAPS, 64, 64));
1735 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_luminance", "", GL_LUMINANCE, MIPMAPS, 64, 64));
1736 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_luminance_alpha", "", GL_LUMINANCE_ALPHA, MIPMAPS, 64, 64));
1737 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_rgb", "", GL_RGB, MIPMAPS, 64, 64));
1738 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_rgba", "", GL_RGBA, MIPMAPS, 64, 64));
1741 // Basic glCopyTexSubImage2D() cases
1743 tcu::TestCaseGroup* copyTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_copytexsubimage2d", "Basic glCopyTexSubImage2D() usage");
1744 addChild(copyTexSubImageGroup);
1746 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_alpha", "", GL_ALPHA, GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1747 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_luminance", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1748 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_luminance_alpha", "", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1749 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_rgb", "", GL_RGB, GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1750 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_rgba", "", GL_RGBA, GL_UNSIGNED_BYTE, MIPMAPS, 128, 64));
1752 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_alpha", "", GL_ALPHA, GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
1753 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_luminance", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
1754 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_luminance_alpha", "", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
1755 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_rgb", "", GL_RGB, GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));
1756 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_rgba", "", GL_RGBA, GL_UNSIGNED_BYTE, MIPMAPS, 64, 64));