1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.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 "es3fTextureSpecificationTests.hpp"
30 #include "tcuTestLog.hpp"
31 #include "tcuImageCompare.hpp"
32 #include "tcuTextureUtil.hpp"
33 #include "tcuVectorUtil.hpp"
34 #include "gluStrUtil.hpp"
35 #include "gluTexture.hpp"
36 #include "gluTextureUtil.hpp"
37 #include "sglrContextUtil.hpp"
38 #include "sglrContextWrapper.hpp"
39 #include "sglrGLContext.hpp"
40 #include "sglrReferenceContext.hpp"
41 #include "glsTextureTestUtil.hpp"
42 #include "deRandom.hpp"
43 #include "deStringUtil.hpp"
45 // \todo [2012-04-29 pyry] Should be named SglrUtil
46 #include "es3fFboTestUtil.hpp"
48 #include "glwEnums.hpp"
64 using namespace FboTestUtil;
66 tcu::TextureFormat mapGLUnsizedInternalFormat (deUint32 internalFormat)
68 using tcu::TextureFormat;
69 switch (internalFormat)
71 case GL_ALPHA: return TextureFormat(TextureFormat::A, TextureFormat::UNORM_INT8);
72 case GL_LUMINANCE: return TextureFormat(TextureFormat::L, TextureFormat::UNORM_INT8);
73 case GL_LUMINANCE_ALPHA: return TextureFormat(TextureFormat::LA, TextureFormat::UNORM_INT8);
74 case GL_RGB: return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8);
75 case GL_RGBA: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8);
77 throw tcu::InternalError(string("Can't map GL unsized internal format (") + tcu::toHex(internalFormat).toString() + ") to texture format");
87 static inline int maxLevelCount (int width, int height)
89 return (int)deLog2Floor32(de::max(width, height))+1;
92 static inline int maxLevelCount (int width, int height, int depth)
94 return (int)deLog2Floor32(de::max(width, de::max(height, depth)))+1;
98 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))
100 tcu::Vector<float, Size> res;
101 for (int ndx = 0; ndx < Size; ndx++)
102 res[ndx] = rnd.getFloat(minVal[ndx], maxVal[ndx]);
106 static const deUint32 s_cubeMapFaces[] =
108 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
109 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
110 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
111 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
112 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
113 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
116 static tcu::IVec4 getPixelFormatCompareDepth (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat)
118 switch (textureFormat.order)
120 case tcu::TextureFormat::L:
121 case tcu::TextureFormat::LA:
122 return tcu::IVec4(pixelFormat.redBits, pixelFormat.redBits, pixelFormat.redBits, pixelFormat.alphaBits);
124 return tcu::IVec4(pixelFormat.redBits, pixelFormat.greenBits, pixelFormat.blueBits, pixelFormat.alphaBits);
128 static IVec4 getEffectiveTextureFormatBitDepth (tcu::TextureFormat textureFormat)
130 if (textureFormat.order == tcu::TextureFormat::DS)
132 // When sampling depth-stencil texture, we actually sample just
133 // the depth component.
134 return tcu::getTextureFormatBitDepth(tcu::getEffectiveDepthStencilTextureFormat(textureFormat, tcu::Sampler::MODE_DEPTH));
137 return tcu::getTextureFormatBitDepth(textureFormat);
140 static tcu::UVec4 computeCompareThreshold (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat)
142 const IVec4 texFormatBits = getEffectiveTextureFormatBitDepth(textureFormat);
143 const IVec4 pixelFormatBits = getPixelFormatCompareDepth(pixelFormat, textureFormat);
144 const IVec4 accurateFmtBits = min(pixelFormatBits, texFormatBits);
145 const IVec4 compareBits = select(accurateFmtBits, IVec4(8), greaterThan(accurateFmtBits, IVec4(0))) - 1;
147 return (IVec4(1) << (8-compareBits)).asUint();
150 class TextureSpecCase : public TestCase, public sglr::ContextWrapper
153 TextureSpecCase (Context& context, const char* name, const char* desc);
154 ~TextureSpecCase (void);
156 IterateResult iterate (void);
159 virtual void createTexture (void) = DE_NULL;
160 virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext) = DE_NULL;
163 void renderTex (tcu::Surface& dst, deUint32 program, int width, int height);
164 void readPixels (tcu::Surface& dst, int x, int y, int width, int height);
167 TextureSpecCase (const TextureSpecCase& other);
168 TextureSpecCase& operator= (const TextureSpecCase& other);
171 TextureSpecCase::TextureSpecCase (Context& context, const char* name, const char* desc)
172 : TestCase(context, name, desc)
176 TextureSpecCase::~TextureSpecCase (void)
180 TextureSpecCase::IterateResult TextureSpecCase::iterate (void)
182 glu::RenderContext& renderCtx = TestCase::m_context.getRenderContext();
183 const tcu::RenderTarget& renderTarget = renderCtx.getRenderTarget();
184 tcu::TestLog& log = m_testCtx.getLog();
186 if (renderTarget.getWidth() < VIEWPORT_WIDTH || renderTarget.getHeight() < VIEWPORT_HEIGHT)
187 throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__);
189 // Context size, and viewport for GLES3
190 de::Random rnd (deStringHash(getName()));
191 int width = deMin32(renderTarget.getWidth(), VIEWPORT_WIDTH);
192 int height = deMin32(renderTarget.getHeight(), VIEWPORT_HEIGHT);
193 int x = rnd.getInt(0, renderTarget.getWidth() - width);
194 int y = rnd.getInt(0, renderTarget.getHeight() - height);
197 sglr::GLContext gles3Context (renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height));
198 sglr::ReferenceContextBuffers refBuffers (tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), 0 /* depth */, 0 /* stencil */, width, height);
199 sglr::ReferenceContext refContext (sglr::ReferenceContextLimits(renderCtx), refBuffers.getColorbuffer(), refBuffers.getDepthbuffer(), refBuffers.getStencilbuffer());
201 // Clear color buffer.
202 for (int ndx = 0; ndx < 2; ndx++)
204 setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles3Context);
205 glClearColor(0.125f, 0.25f, 0.5f, 1.0f);
206 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
209 // Construct texture using both GLES3 and reference contexts.
210 for (int ndx = 0; ndx < 2; ndx++)
212 setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles3Context);
214 TCU_CHECK(glGetError() == GL_NO_ERROR);
217 // Initialize case result to pass.
218 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
221 gles3Context.enableLogging(0);
224 verifyTexture(gles3Context, refContext);
229 void TextureSpecCase::renderTex (tcu::Surface& dst, deUint32 program, int width, int height)
231 int targetW = getWidth();
232 int targetH = getHeight();
234 float w = (float)width / (float)targetW;
235 float h = (float)height / (float)targetH;
237 sglr::drawQuad(*getCurrentContext(), program, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(-1.0f + w*2.0f, -1.0f + h*2.0f, 0.0f));
240 readPixels(dst, 0, 0, width, height);
243 void TextureSpecCase::readPixels (tcu::Surface& dst, int x, int y, int width, int height)
245 dst.setSize(width, height);
246 glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());
249 class Texture2DSpecCase : public TextureSpecCase
252 Texture2DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLevels);
253 ~Texture2DSpecCase (void);
256 virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext);
258 tcu::TextureFormat m_texFormat;
259 tcu::TextureFormatInfo m_texFormatInfo;
265 Texture2DSpecCase::Texture2DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLevels)
266 : TextureSpecCase (context, name, desc)
267 , m_texFormat (format)
268 , m_texFormatInfo (tcu::getTextureFormatInfo(format))
271 , m_numLevels (numLevels)
275 Texture2DSpecCase::~Texture2DSpecCase (void)
279 void Texture2DSpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)
281 Texture2DShader shader (DataTypes() << glu::getSampler2DType(m_texFormat), glu::TYPE_FLOAT_VEC4);
282 deUint32 shaderIDgles = gles3Context.createProgram(&shader);
283 deUint32 shaderIDRef = refContext.createProgram(&shader);
285 shader.setTexScaleBias(0, m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
288 for (int ndx = 0; ndx < 2; ndx++)
290 sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
294 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
295 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
296 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
297 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
298 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, m_numLevels-1);
301 for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
303 int levelW = de::max(1, m_width >> levelNdx);
304 int levelH = de::max(1, m_height >> levelNdx);
305 tcu::Surface reference;
308 for (int ndx = 0; ndx < 2; ndx++)
310 tcu::Surface& dst = ndx ? reference : result;
311 sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
312 deUint32 shaderID = ndx ? shaderIDRef : shaderIDgles;
315 shader.setUniforms(*ctx, shaderID);
316 renderTex(dst, shaderID, levelW, levelH);
319 UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
320 string levelStr = de::toString(levelNdx);
321 string name = string("Level") + levelStr;
322 string desc = string("Level ") + levelStr;
323 bool isOk = tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold,
324 levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
328 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
334 class TextureCubeSpecCase : public TextureSpecCase
337 TextureCubeSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int size, int numLevels);
338 ~TextureCubeSpecCase (void);
341 virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext);
343 tcu::TextureFormat m_texFormat;
344 tcu::TextureFormatInfo m_texFormatInfo;
349 TextureCubeSpecCase::TextureCubeSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int size, int numLevels)
350 : TextureSpecCase (context, name, desc)
351 , m_texFormat (format)
352 , m_texFormatInfo (tcu::getTextureFormatInfo(format))
354 , m_numLevels (numLevels)
358 TextureCubeSpecCase::~TextureCubeSpecCase (void)
362 void TextureCubeSpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)
364 TextureCubeShader shader (glu::getSamplerCubeType(m_texFormat), glu::TYPE_FLOAT_VEC4);
365 deUint32 shaderIDgles = gles3Context.createProgram(&shader);
366 deUint32 shaderIDRef = refContext.createProgram(&shader);
368 shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
371 for (int ndx = 0; ndx < 2; ndx++)
373 sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
377 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
378 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
379 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
380 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
381 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, m_numLevels-1);
384 for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
386 int levelSize = de::max(1, m_size >> levelNdx);
389 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
391 tcu::Surface reference;
395 continue; // Fuzzy compare doesn't work for images this small.
397 shader.setFace((tcu::CubeFace)face);
399 for (int ndx = 0; ndx < 2; ndx++)
401 tcu::Surface& dst = ndx ? reference : result;
402 sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
403 deUint32 shaderID = ndx ? shaderIDRef : shaderIDgles;
406 shader.setUniforms(*ctx, shaderID);
407 renderTex(dst, shaderID, levelSize, levelSize);
410 const float threshold = 0.02f;
411 string faceStr = de::toString((tcu::CubeFace)face);
412 string levelStr = de::toString(levelNdx);
413 string name = string("Level") + levelStr;
414 string desc = string("Level ") + levelStr + ", face " + faceStr;
415 bool isFaceOk = tcu::fuzzyCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference, result, threshold,
416 levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
420 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
431 class Texture2DArraySpecCase : public TextureSpecCase
434 Texture2DArraySpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLayers, int numLevels);
435 ~Texture2DArraySpecCase (void);
438 virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext);
440 tcu::TextureFormat m_texFormat;
441 tcu::TextureFormatInfo m_texFormatInfo;
448 Texture2DArraySpecCase::Texture2DArraySpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLayers, int numLevels)
449 : TextureSpecCase (context, name, desc)
450 , m_texFormat (format)
451 , m_texFormatInfo (tcu::getTextureFormatInfo(format))
454 , m_numLayers (numLayers)
455 , m_numLevels (numLevels)
459 Texture2DArraySpecCase::~Texture2DArraySpecCase (void)
463 void Texture2DArraySpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)
465 Texture2DArrayShader shader (glu::getSampler2DArrayType(m_texFormat), glu::TYPE_FLOAT_VEC4);
466 deUint32 shaderIDgles = gles3Context.createProgram(&shader);
467 deUint32 shaderIDRef = refContext.createProgram(&shader);
469 shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
472 for (int ndx = 0; ndx < 2; ndx++)
474 sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
478 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
479 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
480 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
481 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
482 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
483 glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, m_numLevels-1);
486 for (int layerNdx = 0; layerNdx < m_numLayers; layerNdx++)
490 shader.setLayer(layerNdx);
492 for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
494 int levelW = de::max(1, m_width >> levelNdx);
495 int levelH = de::max(1, m_height >> levelNdx);
496 tcu::Surface reference;
499 for (int ndx = 0; ndx < 2; ndx++)
501 tcu::Surface& dst = ndx ? reference : result;
502 sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
503 deUint32 shaderID = ndx ? shaderIDRef : shaderIDgles;
506 shader.setUniforms(*ctx, shaderID);
507 renderTex(dst, shaderID, levelW, levelH);
510 UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
511 string levelStr = de::toString(levelNdx);
512 string layerStr = de::toString(layerNdx);
513 string name = string("Layer") + layerStr + "Level" + levelStr;
514 string desc = string("Layer ") + layerStr + ", Level " + levelStr;
515 bool depthOk = tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold,
516 (levelNdx == 0 && layerNdx == 0) ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
520 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
531 class Texture3DSpecCase : public TextureSpecCase
534 Texture3DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int depth, int numLevels);
535 ~Texture3DSpecCase (void);
538 virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext);
540 tcu::TextureFormat m_texFormat;
541 tcu::TextureFormatInfo m_texFormatInfo;
548 Texture3DSpecCase::Texture3DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int depth, int numLevels)
549 : TextureSpecCase (context, name, desc)
550 , m_texFormat (format)
551 , m_texFormatInfo (tcu::getTextureFormatInfo(format))
555 , m_numLevels (numLevels)
559 Texture3DSpecCase::~Texture3DSpecCase (void)
563 void Texture3DSpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext)
565 Texture3DShader shader (glu::getSampler3DType(m_texFormat), glu::TYPE_FLOAT_VEC4);
566 deUint32 shaderIDgles = gles3Context.createProgram(&shader);
567 deUint32 shaderIDRef = refContext.createProgram(&shader);
569 shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias);
572 for (int ndx = 0; ndx < 2; ndx++)
574 sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
578 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
579 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
580 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
581 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
582 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
583 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, m_numLevels-1);
586 for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++)
588 int levelW = de::max(1, m_width >> levelNdx);
589 int levelH = de::max(1, m_height >> levelNdx);
590 int levelD = de::max(1, m_depth >> levelNdx);
593 for (int depth = 0; depth < levelD; depth++)
595 tcu::Surface reference;
598 shader.setDepth(((float)depth + 0.5f) / (float)levelD);
600 for (int ndx = 0; ndx < 2; ndx++)
602 tcu::Surface& dst = ndx ? reference : result;
603 sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context);
604 deUint32 shaderID = ndx ? shaderIDRef : shaderIDgles;
607 shader.setUniforms(*ctx, shaderID);
608 renderTex(dst, shaderID, levelW, levelH);
611 UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat);
612 string levelStr = de::toString(levelNdx);
613 string sliceStr = de::toString(depth);
614 string name = string("Level") + levelStr + "Slice" + sliceStr;
615 string desc = string("Level ") + levelStr + ", Slice " + sliceStr;
616 bool depthOk = tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold,
617 (levelNdx == 0 && depth == 0) ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR);
621 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
632 // Basic TexImage2D() with 2D texture usage
633 class BasicTexImage2DCase : public Texture2DSpecCase
636 // Unsized internal format.
637 BasicTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
638 : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
639 , m_internalFormat (format)
641 , m_dataType (dataType)
645 // Sized internal format.
646 BasicTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
647 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height))
648 , m_internalFormat (internalFormat)
650 , m_dataType (GL_NONE)
652 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
653 m_format = fmt.format;
654 m_dataType = fmt.dataType;
658 void createTexture (void)
661 tcu::TextureLevel levelData (glu::mapGLTransferFormat(m_format, m_dataType));
662 de::Random rnd (deStringHash(getName()));
664 glGenTextures(1, &tex);
665 glBindTexture(GL_TEXTURE_2D, tex);
666 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
668 for (int ndx = 0; ndx < m_numLevels; ndx++)
670 int levelW = de::max(1, m_width >> ndx);
671 int levelH = de::max(1, m_height >> ndx);
672 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
673 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
675 levelData.setSize(levelW, levelH);
676 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
678 glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
682 deUint32 m_internalFormat;
687 // Basic TexImage2D() with cubemap usage
688 class BasicTexImageCubeCase : public TextureCubeSpecCase
692 BasicTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
693 : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
694 , m_internalFormat (format)
696 , m_dataType (dataType)
700 // Sized internal formats.
701 BasicTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
702 : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1)
703 , m_internalFormat (internalFormat)
705 , m_dataType (GL_NONE)
707 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
708 m_format = fmt.format;
709 m_dataType = fmt.dataType;
713 void createTexture (void)
716 tcu::TextureLevel levelData (glu::mapGLTransferFormat(m_format, m_dataType));
717 de::Random rnd (deStringHash(getName()));
719 glGenTextures(1, &tex);
720 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
721 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
723 for (int ndx = 0; ndx < m_numLevels; ndx++)
725 int levelSize = de::max(1, m_size >> ndx);
727 levelData.setSize(levelSize, levelSize);
729 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
731 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
732 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
734 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
736 glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
741 deUint32 m_internalFormat;
746 // Basic TexImage3D() with 2D array texture usage
747 class BasicTexImage2DArrayCase : public Texture2DArraySpecCase
750 BasicTexImage2DArrayCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLayers)
751 : Texture2DArraySpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLayers, maxLevelCount(width, height))
752 , m_internalFormat (internalFormat)
757 void createTexture (void)
760 de::Random rnd (deStringHash(getName()));
761 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
762 tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
764 glGenTextures(1, &tex);
765 glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
766 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
768 for (int ndx = 0; ndx < m_numLevels; ndx++)
770 int levelW = de::max(1, m_width >> ndx);
771 int levelH = de::max(1, m_height >> ndx);
772 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
773 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
775 levelData.setSize(levelW, levelH, m_numLayers);
776 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
778 glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
782 deUint32 m_internalFormat;
785 // Basic TexImage3D() with 3D texture usage
786 class BasicTexImage3DCase : public Texture3DSpecCase
789 BasicTexImage3DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int depth)
790 : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, maxLevelCount(width, height, depth))
791 , m_internalFormat (internalFormat)
796 void createTexture (void)
799 de::Random rnd (deStringHash(getName()));
800 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
801 tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
803 glGenTextures(1, &tex);
804 glBindTexture(GL_TEXTURE_3D, tex);
805 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
807 for (int ndx = 0; ndx < m_numLevels; ndx++)
809 int levelW = de::max(1, m_width >> ndx);
810 int levelH = de::max(1, m_height >> ndx);
811 int levelD = de::max(1, m_depth >> ndx);
812 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
813 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
815 levelData.setSize(levelW, levelH, levelD);
816 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
818 glTexImage3D(GL_TEXTURE_3D, ndx, m_internalFormat, levelW, levelH, levelD, 0, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
822 deUint32 m_internalFormat;
825 // Randomized 2D texture specification using TexImage2D
826 class RandomOrderTexImage2DCase : public Texture2DSpecCase
829 RandomOrderTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
830 : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
831 , m_internalFormat (format)
833 , m_dataType (dataType)
837 RandomOrderTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
838 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height))
839 , m_internalFormat (internalFormat)
841 , m_dataType (GL_NONE)
843 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
844 m_format = fmt.format;
845 m_dataType = fmt.dataType;
849 void createTexture (void)
852 tcu::TextureLevel levelData (glu::mapGLTransferFormat(m_format, m_dataType));
853 de::Random rnd (deStringHash(getName()));
855 glGenTextures(1, &tex);
856 glBindTexture(GL_TEXTURE_2D, tex);
857 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
859 vector<int> levels (m_numLevels);
861 for (int i = 0; i < m_numLevels; i++)
863 rnd.shuffle(levels.begin(), levels.end());
865 for (int ndx = 0; ndx < m_numLevels; ndx++)
867 int levelNdx = levels[ndx];
868 int levelW = de::max(1, m_width >> levelNdx);
869 int levelH = de::max(1, m_height >> levelNdx);
870 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
871 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
873 levelData.setSize(levelW, levelH);
874 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
876 glTexImage2D(GL_TEXTURE_2D, levelNdx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
880 deUint32 m_internalFormat;
885 // Randomized cubemap texture specification using TexImage2D
886 class RandomOrderTexImageCubeCase : public TextureCubeSpecCase
889 RandomOrderTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
890 : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
891 , m_internalFormat (GL_NONE)
893 , m_dataType (dataType)
897 RandomOrderTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
898 : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1)
899 , m_internalFormat (internalFormat)
901 , m_dataType (GL_NONE)
903 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
904 m_format = fmt.format;
905 m_dataType = fmt.dataType;
909 void createTexture (void)
912 tcu::TextureLevel levelData (glu::mapGLTransferFormat(m_format, m_dataType));
913 de::Random rnd (deStringHash(getName()));
915 glGenTextures(1, &tex);
916 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
917 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
920 vector<pair<int, tcu::CubeFace> > images (m_numLevels*6);
922 for (int ndx = 0; ndx < m_numLevels; ndx++)
923 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
924 images[ndx*6 + face] = std::make_pair(ndx, (tcu::CubeFace)face);
926 rnd.shuffle(images.begin(), images.end());
928 for (int ndx = 0; ndx < (int)images.size(); ndx++)
930 int levelNdx = images[ndx].first;
931 tcu::CubeFace face = images[ndx].second;
932 int levelSize = de::max(1, m_size >> levelNdx);
933 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
934 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
936 levelData.setSize(levelSize, levelSize);
937 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
939 glTexImage2D(s_cubeMapFaces[face], levelNdx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, levelData.getAccess().getDataPtr());
943 deUint32 m_internalFormat;
948 // TexImage2D() unpack alignment case.
949 class TexImage2DAlignCase : public Texture2DSpecCase
952 TexImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height, int numLevels, int alignment)
953 : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, numLevels)
954 , m_internalFormat (format)
956 , m_dataType (dataType)
957 , m_alignment (alignment)
961 TexImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLevels, int alignment)
962 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLevels)
963 , m_internalFormat (internalFormat)
965 , m_dataType (GL_NONE)
966 , m_alignment (alignment)
968 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
969 m_format = fmt.format;
970 m_dataType = fmt.dataType;
974 void createTexture (void)
977 vector<deUint8> data;
979 glGenTextures(1, &tex);
980 glBindTexture(GL_TEXTURE_2D, tex);
981 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
983 for (int ndx = 0; ndx < m_numLevels; ndx++)
985 int levelW = de::max(1, m_width >> ndx);
986 int levelH = de::max(1, m_height >> ndx);
987 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin;
988 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin;
989 int rowPitch = deAlign32(levelW*m_texFormat.getPixelSize(), m_alignment);
990 int cellSize = de::max(1, de::min(levelW >> 2, levelH >> 2));
992 data.resize(rowPitch*levelH);
993 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB);
995 glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, &data[0]);
999 deUint32 m_internalFormat;
1001 deUint32 m_dataType;
1005 // TexImage2D() unpack alignment case.
1006 class TexImageCubeAlignCase : public TextureCubeSpecCase
1009 TexImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size, int numLevels, int alignment)
1010 : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, numLevels)
1011 , m_internalFormat (format)
1013 , m_dataType (dataType)
1014 , m_alignment (alignment)
1018 TexImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int numLevels, int alignment)
1019 : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLevels)
1020 , m_internalFormat (internalFormat)
1021 , m_format (GL_NONE)
1022 , m_dataType (GL_NONE)
1023 , m_alignment (alignment)
1025 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1026 m_format = fmt.format;
1027 m_dataType = fmt.dataType;
1031 void createTexture (void)
1034 vector<deUint8> data;
1036 glGenTextures(1, &tex);
1037 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1038 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1040 for (int ndx = 0; ndx < m_numLevels; ndx++)
1042 int levelSize = de::max(1, m_size >> ndx);
1043 int rowPitch = deAlign32(m_texFormat.getPixelSize()*levelSize, m_alignment);
1044 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin;
1045 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin;
1046 int cellSize = de::max(1, levelSize >> 2);
1048 data.resize(rowPitch*levelSize);
1049 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, levelSize, levelSize, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB);
1051 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1052 glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, &data[0]);
1056 deUint32 m_internalFormat;
1058 deUint32 m_dataType;
1062 // TexImage2D() unpack parameters case.
1063 class TexImage2DParamsCase : public Texture2DSpecCase
1066 TexImage2DParamsCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int rowLength, int skipRows, int skipPixels, int alignment)
1067 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
1068 , m_internalFormat (internalFormat)
1069 , m_rowLength (rowLength)
1070 , m_skipRows (skipRows)
1071 , m_skipPixels (skipPixels)
1072 , m_alignment (alignment)
1077 void createTexture (void)
1079 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1080 int pixelSize = m_texFormat.getPixelSize();
1081 int rowLength = m_rowLength > 0 ? m_rowLength : m_width;
1082 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
1083 int height = m_height + m_skipRows;
1085 vector<deUint8> data;
1087 DE_ASSERT(m_numLevels == 1);
1089 // Fill data with grid.
1090 data.resize(rowPitch*height);
1092 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
1093 Vec4 cBias = m_texFormatInfo.valueMin;
1094 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
1095 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
1097 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB);
1100 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
1101 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
1102 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
1103 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1105 glGenTextures(1, &tex);
1106 glBindTexture(GL_TEXTURE_2D, tex);
1107 glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, &data[0]);
1110 deUint32 m_internalFormat;
1117 // TexImage3D() unpack parameters case.
1118 class TexImage3DParamsCase : public Texture3DSpecCase
1121 TexImage3DParamsCase (Context& context,
1124 deUint32 internalFormat,
1134 : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
1135 , m_internalFormat (internalFormat)
1136 , m_imageHeight (imageHeight)
1137 , m_rowLength (rowLength)
1138 , m_skipImages (skipImages)
1139 , m_skipRows (skipRows)
1140 , m_skipPixels (skipPixels)
1141 , m_alignment (alignment)
1146 void createTexture (void)
1148 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1149 int pixelSize = m_texFormat.getPixelSize();
1150 int rowLength = m_rowLength > 0 ? m_rowLength : m_width;
1151 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
1152 int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_height;
1153 int slicePitch = imageHeight*rowPitch;
1155 vector<deUint8> data;
1157 DE_ASSERT(m_numLevels == 1);
1159 // Fill data with grid.
1160 data.resize(slicePitch*(m_depth+m_skipImages));
1162 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
1163 Vec4 cBias = m_texFormatInfo.valueMin;
1164 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
1165 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
1167 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB);
1170 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
1171 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
1172 glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
1173 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
1174 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
1175 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1177 glGenTextures(1, &tex);
1178 glBindTexture(GL_TEXTURE_3D, tex);
1179 glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, &data[0]);
1182 deUint32 m_internalFormat;
1191 // Basic TexSubImage2D() with 2D texture usage
1192 class BasicTexSubImage2DCase : public Texture2DSpecCase
1195 BasicTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
1196 : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
1197 , m_internalFormat (format)
1199 , m_dataType (dataType)
1203 BasicTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
1204 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height))
1205 , m_internalFormat (internalFormat)
1206 , m_format (GL_NONE)
1207 , m_dataType (GL_NONE)
1209 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1210 m_format = fmt.format;
1211 m_dataType = fmt.dataType;
1215 void createTexture (void)
1218 tcu::TextureLevel data (m_texFormat);
1219 de::Random rnd (deStringHash(getName()));
1221 glGenTextures(1, &tex);
1222 glBindTexture(GL_TEXTURE_2D, tex);
1223 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1225 // First specify full texture.
1226 for (int ndx = 0; ndx < m_numLevels; ndx++)
1228 int levelW = de::max(1, m_width >> ndx);
1229 int levelH = de::max(1, m_height >> ndx);
1230 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1231 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1233 data.setSize(levelW, levelH);
1234 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1236 glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
1239 // Re-specify parts of each level.
1240 for (int ndx = 0; ndx < m_numLevels; ndx++)
1242 int levelW = de::max(1, m_width >> ndx);
1243 int levelH = de::max(1, m_height >> ndx);
1245 int w = rnd.getInt(1, levelW);
1246 int h = rnd.getInt(1, levelH);
1247 int x = rnd.getInt(0, levelW-w);
1248 int y = rnd.getInt(0, levelH-h);
1250 Vec4 colorA = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1251 Vec4 colorB = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1252 int cellSize = rnd.getInt(2, 16);
1255 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1257 glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
1261 deUint32 m_internalFormat;
1263 deUint32 m_dataType;
1266 // Basic TexSubImage2D() with cubemap usage
1267 class BasicTexSubImageCubeCase : public TextureCubeSpecCase
1270 BasicTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
1271 : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
1272 , m_internalFormat (format)
1274 , m_dataType (dataType)
1278 BasicTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
1279 : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1)
1280 , m_internalFormat (internalFormat)
1281 , m_format (GL_NONE)
1282 , m_dataType (GL_NONE)
1284 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1285 m_format = fmt.format;
1286 m_dataType = fmt.dataType;
1290 void createTexture (void)
1293 tcu::TextureLevel data (m_texFormat);
1294 de::Random rnd (deStringHash(getName()));
1296 glGenTextures(1, &tex);
1297 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1298 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1300 for (int ndx = 0; ndx < m_numLevels; ndx++)
1302 int levelSize = de::max(1, m_size >> ndx);
1304 data.setSize(levelSize, levelSize);
1306 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1308 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1309 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1311 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1313 glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, data.getAccess().getDataPtr());
1317 // Re-specify parts of each face and level.
1318 for (int ndx = 0; ndx < m_numLevels; ndx++)
1320 int levelSize = de::max(1, m_size >> ndx);
1322 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1324 int w = rnd.getInt(1, levelSize);
1325 int h = rnd.getInt(1, levelSize);
1326 int x = rnd.getInt(0, levelSize-w);
1327 int y = rnd.getInt(0, levelSize-h);
1329 Vec4 colorA = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1330 Vec4 colorB = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1331 int cellSize = rnd.getInt(2, 16);
1334 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1336 glTexSubImage2D(s_cubeMapFaces[face], ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr());
1341 deUint32 m_internalFormat;
1343 deUint32 m_dataType;
1346 // TexSubImage2D() unpack parameters case.
1347 class TexSubImage2DParamsCase : public Texture2DSpecCase
1350 TexSubImage2DParamsCase (Context& context,
1353 deUint32 internalFormat,
1364 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
1365 , m_internalFormat (internalFormat)
1370 , m_rowLength (rowLength)
1371 , m_skipRows (skipRows)
1372 , m_skipPixels (skipPixels)
1373 , m_alignment (alignment)
1378 void createTexture (void)
1380 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1381 int pixelSize = m_texFormat.getPixelSize();
1383 vector<deUint8> data;
1385 DE_ASSERT(m_numLevels == 1);
1387 glGenTextures(1, &tex);
1388 glBindTexture(GL_TEXTURE_2D, tex);
1390 // First fill texture with gradient.
1391 data.resize(deAlign32(m_width*pixelSize, 4)*m_height);
1392 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, deAlign32(m_width*pixelSize, 4), 0, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1393 glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, &data[0]);
1395 // Fill data with grid.
1397 int rowLength = m_rowLength > 0 ? m_rowLength : m_subW;
1398 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
1399 int height = m_subH + m_skipRows;
1400 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
1401 Vec4 cBias = m_texFormatInfo.valueMin;
1402 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
1403 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
1405 data.resize(rowPitch*height);
1406 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB);
1409 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
1410 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
1411 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
1412 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1413 glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format, transferFmt.dataType, &data[0]);
1416 deUint32 m_internalFormat;
1427 // Basic TexSubImage3D() with 3D texture usage
1428 class BasicTexSubImage3DCase : public Texture3DSpecCase
1431 BasicTexSubImage3DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int depth)
1432 : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, maxLevelCount(width, height, depth))
1433 , m_internalFormat (internalFormat)
1438 void createTexture (void)
1441 tcu::TextureLevel data (m_texFormat);
1442 de::Random rnd (deStringHash(getName()));
1443 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1445 glGenTextures(1, &tex);
1446 glBindTexture(GL_TEXTURE_3D, tex);
1447 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1449 // First specify full texture.
1450 for (int ndx = 0; ndx < m_numLevels; ndx++)
1452 int levelW = de::max(1, m_width >> ndx);
1453 int levelH = de::max(1, m_height >> ndx);
1454 int levelD = de::max(1, m_depth >> ndx);
1455 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1456 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1458 data.setSize(levelW, levelH, levelD);
1459 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1461 glTexImage3D(GL_TEXTURE_3D, ndx, m_internalFormat, levelW, levelH, levelD, 0, transferFmt.format, transferFmt.dataType, data.getAccess().getDataPtr());
1464 // Re-specify parts of each level.
1465 for (int ndx = 0; ndx < m_numLevels; ndx++)
1467 int levelW = de::max(1, m_width >> ndx);
1468 int levelH = de::max(1, m_height >> ndx);
1469 int levelD = de::max(1, m_depth >> ndx);
1471 int w = rnd.getInt(1, levelW);
1472 int h = rnd.getInt(1, levelH);
1473 int d = rnd.getInt(1, levelD);
1474 int x = rnd.getInt(0, levelW-w);
1475 int y = rnd.getInt(0, levelH-h);
1476 int z = rnd.getInt(0, levelD-d);
1478 Vec4 colorA = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1479 Vec4 colorB = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1480 int cellSize = rnd.getInt(2, 16);
1482 data.setSize(w, h, d);
1483 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
1485 glTexSubImage3D(GL_TEXTURE_3D, ndx, x, y, z, w, h, d, transferFmt.format, transferFmt.dataType, data.getAccess().getDataPtr());
1489 deUint32 m_internalFormat;
1492 // TexSubImage2D() to texture initialized with empty data
1493 class TexSubImage2DEmptyTexCase : public Texture2DSpecCase
1496 TexSubImage2DEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
1497 : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
1498 , m_internalFormat (format)
1500 , m_dataType (dataType)
1504 TexSubImage2DEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
1505 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height))
1506 , m_internalFormat (internalFormat)
1507 , m_format (GL_NONE)
1508 , m_dataType (GL_NONE)
1510 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1511 m_format = fmt.format;
1512 m_dataType = fmt.dataType;
1516 void createTexture (void)
1519 tcu::TextureLevel data (m_texFormat);
1520 de::Random rnd (deStringHash(getName()));
1522 glGenTextures(1, &tex);
1523 glBindTexture(GL_TEXTURE_2D, tex);
1524 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1526 // First allocate storage for each level.
1527 for (int ndx = 0; ndx < m_numLevels; ndx++)
1529 int levelW = de::max(1, m_width >> ndx);
1530 int levelH = de::max(1, m_height >> ndx);
1532 glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, DE_NULL);
1535 // Specify pixel data to all levels using glTexSubImage2D()
1536 for (int ndx = 0; ndx < m_numLevels; ndx++)
1538 int levelW = de::max(1, m_width >> ndx);
1539 int levelH = de::max(1, m_height >> ndx);
1540 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1541 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1543 data.setSize(levelW, levelH);
1544 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1546 glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, m_format, m_dataType, data.getAccess().getDataPtr());
1550 deUint32 m_internalFormat;
1552 deUint32 m_dataType;
1555 // TexSubImage2D() to empty cubemap texture
1556 class TexSubImageCubeEmptyTexCase : public TextureCubeSpecCase
1559 TexSubImageCubeEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
1560 : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
1561 , m_internalFormat (format)
1563 , m_dataType (dataType)
1567 TexSubImageCubeEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
1568 : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1)
1569 , m_internalFormat (internalFormat)
1570 , m_format (GL_NONE)
1571 , m_dataType (GL_NONE)
1573 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1574 m_format = fmt.format;
1575 m_dataType = fmt.dataType;
1579 void createTexture (void)
1582 tcu::TextureLevel data (m_texFormat);
1583 de::Random rnd (deStringHash(getName()));
1585 glGenTextures(1, &tex);
1586 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1587 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1589 // Specify storage for each level.
1590 for (int ndx = 0; ndx < m_numLevels; ndx++)
1592 int levelSize = de::max(1, m_size >> ndx);
1594 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1595 glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, DE_NULL);
1598 // Specify data using glTexSubImage2D()
1599 for (int ndx = 0; ndx < m_numLevels; ndx++)
1601 int levelSize = de::max(1, m_size >> ndx);
1603 data.setSize(levelSize, levelSize);
1605 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1607 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1608 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1610 tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax);
1612 glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelSize, levelSize, m_format, m_dataType, data.getAccess().getDataPtr());
1617 deUint32 m_internalFormat;
1619 deUint32 m_dataType;
1622 // TexSubImage2D() unpack alignment with 2D texture
1623 class TexSubImage2DAlignCase : public Texture2DSpecCase
1626 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)
1627 : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, 1)
1628 , m_internalFormat (format)
1630 , m_dataType (dataType)
1635 , m_alignment (alignment)
1639 TexSubImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int subX, int subY, int subW, int subH, int alignment)
1640 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
1641 , m_internalFormat (internalFormat)
1642 , m_format (GL_NONE)
1643 , m_dataType (GL_NONE)
1648 , m_alignment (alignment)
1650 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1651 m_format = fmt.format;
1652 m_dataType = fmt.dataType;
1656 void createTexture (void)
1659 vector<deUint8> data;
1661 glGenTextures(1, &tex);
1662 glBindTexture(GL_TEXTURE_2D, tex);
1664 // Specify base level.
1665 data.resize(m_texFormat.getPixelSize()*m_width*m_height);
1666 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, &data[0]), Vec4(0.0f), Vec4(1.0f));
1668 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1669 glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, m_format, m_dataType, &data[0]);
1671 // Re-specify subrectangle.
1672 int rowPitch = deAlign32(m_texFormat.getPixelSize()*m_subW, m_alignment);
1673 data.resize(rowPitch*m_subH);
1674 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, 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));
1676 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1677 glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
1680 deUint32 m_internalFormat;
1682 deUint32 m_dataType;
1690 // TexSubImage2D() unpack alignment with cubemap texture
1691 class TexSubImageCubeAlignCase : public TextureCubeSpecCase
1694 TexSubImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size, int subX, int subY, int subW, int subH, int alignment)
1695 : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, 1)
1696 , m_internalFormat (format)
1698 , m_dataType (dataType)
1703 , m_alignment (alignment)
1707 TexSubImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int subX, int subY, int subW, int subH, int alignment)
1708 : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1)
1709 , m_internalFormat (internalFormat)
1710 , m_format (GL_NONE)
1711 , m_dataType (GL_NONE)
1716 , m_alignment (alignment)
1718 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
1719 m_format = fmt.format;
1720 m_dataType = fmt.dataType;
1724 void createTexture (void)
1727 vector<deUint8> data;
1729 glGenTextures(1, &tex);
1730 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1732 // Specify base level.
1733 data.resize(m_texFormat.getPixelSize()*m_size*m_size);
1734 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, &data[0]), Vec4(0.0f), Vec4(1.0f));
1736 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1737 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1738 glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, m_format, m_dataType, &data[0]);
1740 // Re-specify subrectangle.
1741 int rowPitch = deAlign32(m_texFormat.getPixelSize()*m_subW, m_alignment);
1742 data.resize(rowPitch*m_subH);
1743 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, 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));
1745 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1746 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1747 glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]);
1750 deUint32 m_internalFormat;
1752 deUint32 m_dataType;
1760 // TexSubImage3D() unpack parameters case.
1761 class TexSubImage3DParamsCase : public Texture3DSpecCase
1764 TexSubImage3DParamsCase (Context& context,
1767 deUint32 internalFormat,
1783 : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
1784 , m_internalFormat (internalFormat)
1791 , m_imageHeight (imageHeight)
1792 , m_rowLength (rowLength)
1793 , m_skipImages (skipImages)
1794 , m_skipRows (skipRows)
1795 , m_skipPixels (skipPixels)
1796 , m_alignment (alignment)
1801 void createTexture (void)
1803 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
1804 int pixelSize = m_texFormat.getPixelSize();
1806 vector<deUint8> data;
1808 DE_ASSERT(m_numLevels == 1);
1810 glGenTextures(1, &tex);
1811 glBindTexture(GL_TEXTURE_3D, tex);
1813 // Fill with gradient.
1815 int rowPitch = deAlign32(pixelSize*m_width, 4);
1816 int slicePitch = rowPitch*m_height;
1818 data.resize(slicePitch*m_depth);
1819 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
1822 glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, &data[0]);
1824 // Fill data with grid.
1826 int rowLength = m_rowLength > 0 ? m_rowLength : m_subW;
1827 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
1828 int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_subH;
1829 int slicePitch = imageHeight*rowPitch;
1830 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
1831 Vec4 cBias = m_texFormatInfo.valueMin;
1832 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
1833 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
1835 data.resize(slicePitch*(m_depth+m_skipImages));
1836 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, m_subD, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB);
1839 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
1840 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
1841 glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
1842 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
1843 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
1844 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
1845 glTexSubImage3D(GL_TEXTURE_3D, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format, transferFmt.dataType, &data[0]);
1848 deUint32 m_internalFormat;
1863 // Basic CopyTexImage2D() with 2D texture usage
1864 class BasicCopyTexImage2DCase : public Texture2DSpecCase
1867 BasicCopyTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height)
1868 : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(internalFormat, GL_UNSIGNED_BYTE), width, height, maxLevelCount(width, height))
1869 , m_internalFormat (internalFormat)
1874 void createTexture (void)
1876 const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1877 bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
1878 bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1879 tcu::TextureFormat fmt = mapGLUnsizedInternalFormat(m_internalFormat);
1880 bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1881 bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
1883 de::Random rnd (deStringHash(getName()));
1884 GradientShader shader (glu::TYPE_FLOAT_VEC4);
1885 deUint32 shaderID = getCurrentContext()->createProgram(&shader);
1887 if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1888 throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1890 // Fill render target with gradient.
1891 shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
1892 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1894 glGenTextures(1, &tex);
1895 glBindTexture(GL_TEXTURE_2D, tex);
1897 for (int ndx = 0; ndx < m_numLevels; ndx++)
1899 int levelW = de::max(1, m_width >> ndx);
1900 int levelH = de::max(1, m_height >> ndx);
1901 int x = rnd.getInt(0, getWidth() - levelW);
1902 int y = rnd.getInt(0, getHeight() - levelH);
1904 glCopyTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, x, y, levelW, levelH, 0);
1908 deUint32 m_internalFormat;
1911 // Basic CopyTexImage2D() with cubemap usage
1912 class BasicCopyTexImageCubeCase : public TextureCubeSpecCase
1915 BasicCopyTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size)
1916 : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(internalFormat, GL_UNSIGNED_BYTE), size, deLog2Floor32(size)+1)
1917 , m_internalFormat (internalFormat)
1922 void createTexture (void)
1924 const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1925 bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
1926 bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1927 tcu::TextureFormat fmt = mapGLUnsizedInternalFormat(m_internalFormat);
1928 bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1929 bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
1931 de::Random rnd (deStringHash(getName()));
1932 GradientShader shader (glu::TYPE_FLOAT_VEC4);
1933 deUint32 shaderID = getCurrentContext()->createProgram(&shader);
1935 if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1936 throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1938 // Fill render target with gradient.
1939 shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
1940 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
1942 glGenTextures(1, &tex);
1943 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
1945 for (int ndx = 0; ndx < m_numLevels; ndx++)
1947 int levelSize = de::max(1, m_size >> ndx);
1949 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
1951 int x = rnd.getInt(0, getWidth() - levelSize);
1952 int y = rnd.getInt(0, getHeight() - levelSize);
1954 glCopyTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, x, y, levelSize, levelSize, 0);
1959 deUint32 m_internalFormat;
1962 // Basic CopyTexSubImage2D() with 2D texture usage
1963 class BasicCopyTexSubImage2DCase : public Texture2DSpecCase
1966 BasicCopyTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height)
1967 : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height))
1969 , m_dataType (dataType)
1974 void createTexture (void)
1976 const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
1977 bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
1978 bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
1979 tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType);
1980 bool texHasRGB = fmt.order != tcu::TextureFormat::A;
1981 bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
1983 tcu::TextureLevel data (fmt);
1984 de::Random rnd (deStringHash(getName()));
1985 GradientShader shader (glu::TYPE_FLOAT_VEC4);
1986 deUint32 shaderID = getCurrentContext()->createProgram(&shader);
1988 if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
1989 throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
1991 glGenTextures(1, &tex);
1992 glBindTexture(GL_TEXTURE_2D, tex);
1993 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1995 // First specify full texture.
1996 for (int ndx = 0; ndx < m_numLevels; ndx++)
1998 int levelW = de::max(1, m_width >> ndx);
1999 int levelH = de::max(1, m_height >> ndx);
2001 Vec4 colorA = randomVector<4>(rnd);
2002 Vec4 colorB = randomVector<4>(rnd);
2003 int cellSize = rnd.getInt(2, 16);
2005 data.setSize(levelW, levelH);
2006 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
2008 glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr());
2011 // Fill render target with gradient.
2012 shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
2013 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
2015 // Re-specify parts of each level.
2016 for (int ndx = 0; ndx < m_numLevels; ndx++)
2018 int levelW = de::max(1, m_width >> ndx);
2019 int levelH = de::max(1, m_height >> ndx);
2021 int w = rnd.getInt(1, levelW);
2022 int h = rnd.getInt(1, levelH);
2023 int xo = rnd.getInt(0, levelW-w);
2024 int yo = rnd.getInt(0, levelH-h);
2026 int x = rnd.getInt(0, getWidth() - w);
2027 int y = rnd.getInt(0, getHeight() - h);
2029 glCopyTexSubImage2D(GL_TEXTURE_2D, ndx, xo, yo, x, y, w, h);
2034 deUint32 m_dataType;
2037 // Basic CopyTexSubImage2D() with cubemap usage
2038 class BasicCopyTexSubImageCubeCase : public TextureCubeSpecCase
2041 BasicCopyTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size)
2042 : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1)
2044 , m_dataType (dataType)
2049 void createTexture (void)
2051 const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget();
2052 bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0;
2053 bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0;
2054 tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType);
2055 bool texHasRGB = fmt.order != tcu::TextureFormat::A;
2056 bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A;
2058 tcu::TextureLevel data (fmt);
2059 de::Random rnd (deStringHash(getName()));
2060 GradientShader shader (glu::TYPE_FLOAT_VEC4);
2061 deUint32 shaderID = getCurrentContext()->createProgram(&shader);
2063 if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha))
2064 throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__);
2066 glGenTextures(1, &tex);
2067 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
2068 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2070 for (int ndx = 0; ndx < m_numLevels; ndx++)
2072 int levelSize = de::max(1, m_size >> ndx);
2074 data.setSize(levelSize, levelSize);
2076 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2078 Vec4 colorA = randomVector<4>(rnd);
2079 Vec4 colorB = randomVector<4>(rnd);
2080 int cellSize = rnd.getInt(2, 16);
2082 tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB);
2083 glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelSize, levelSize, 0, m_format, m_dataType, data.getAccess().getDataPtr());
2087 // Fill render target with gradient.
2088 shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f));
2089 sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f));
2091 // Re-specify parts of each face and level.
2092 for (int ndx = 0; ndx < m_numLevels; ndx++)
2094 int levelSize = de::max(1, m_size >> ndx);
2096 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2098 int w = rnd.getInt(1, levelSize);
2099 int h = rnd.getInt(1, levelSize);
2100 int xo = rnd.getInt(0, levelSize-w);
2101 int yo = rnd.getInt(0, levelSize-h);
2103 int x = rnd.getInt(0, getWidth() - w);
2104 int y = rnd.getInt(0, getHeight() - h);
2106 glCopyTexSubImage2D(s_cubeMapFaces[face], ndx, xo, yo, x, y, w, h);
2112 deUint32 m_dataType;
2115 // Basic glTexStorage2D() with 2D texture usage
2116 class BasicTexStorage2DCase : public Texture2DSpecCase
2119 BasicTexStorage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLevels)
2120 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLevels)
2121 , m_internalFormat (internalFormat)
2126 void createTexture (void)
2128 tcu::TextureFormat fmt = glu::mapGLInternalFormat(m_internalFormat);
2129 glu::TransferFormat transferFmt = glu::getTransferFormat(fmt);
2131 tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
2132 de::Random rnd (deStringHash(getName()));
2134 glGenTextures(1, &tex);
2135 glBindTexture(GL_TEXTURE_2D, tex);
2136 glTexStorage2D(GL_TEXTURE_2D, m_numLevels, m_internalFormat, m_width, m_height);
2138 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2140 for (int ndx = 0; ndx < m_numLevels; ndx++)
2142 int levelW = de::max(1, m_width >> ndx);
2143 int levelH = de::max(1, m_height >> ndx);
2144 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2145 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2147 levelData.setSize(levelW, levelH);
2148 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
2150 glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
2154 deUint32 m_internalFormat;
2157 // Basic glTexStorage2D() with cubemap usage
2158 class BasicTexStorageCubeCase : public TextureCubeSpecCase
2161 BasicTexStorageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int numLevels)
2162 : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLevels)
2163 , m_internalFormat (internalFormat)
2168 void createTexture (void)
2170 tcu::TextureFormat fmt = glu::mapGLInternalFormat(m_internalFormat);
2171 glu::TransferFormat transferFmt = glu::getTransferFormat(fmt);
2173 tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
2174 de::Random rnd (deStringHash(getName()));
2176 glGenTextures(1, &tex);
2177 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
2178 glTexStorage2D(GL_TEXTURE_CUBE_MAP, m_numLevels, m_internalFormat, m_size, m_size);
2180 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2182 for (int ndx = 0; ndx < m_numLevels; ndx++)
2184 int levelSize = de::max(1, m_size >> ndx);
2186 levelData.setSize(levelSize, levelSize);
2188 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2190 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2191 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2193 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
2195 glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelSize, levelSize, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
2200 deUint32 m_internalFormat;
2203 // Basic glTexStorage3D() with 2D array texture usage
2204 class BasicTexStorage2DArrayCase : public Texture2DArraySpecCase
2207 BasicTexStorage2DArrayCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLayers, int numLevels)
2208 : Texture2DArraySpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLayers, numLevels)
2209 , m_internalFormat (internalFormat)
2214 void createTexture (void)
2217 de::Random rnd (deStringHash(getName()));
2218 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2219 tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
2221 glGenTextures (1, &tex);
2222 glBindTexture (GL_TEXTURE_2D_ARRAY, tex);
2223 glTexStorage3D (GL_TEXTURE_2D_ARRAY, m_numLevels, m_internalFormat, m_width, m_height, m_numLayers);
2225 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
2227 for (int ndx = 0; ndx < m_numLevels; ndx++)
2229 int levelW = de::max(1, m_width >> ndx);
2230 int levelH = de::max(1, m_height >> ndx);
2231 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2232 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2234 levelData.setSize(levelW, levelH, m_numLayers);
2235 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
2237 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, ndx, 0, 0, 0, levelW, levelH, m_numLayers, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
2241 deUint32 m_internalFormat;
2244 // Basic TexStorage3D() with 3D texture usage
2245 class BasicTexStorage3DCase : public Texture3DSpecCase
2248 BasicTexStorage3DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int depth, int numLevels)
2249 : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, numLevels)
2250 , m_internalFormat (internalFormat)
2255 void createTexture (void)
2258 de::Random rnd (deStringHash(getName()));
2259 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2260 tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType));
2262 glGenTextures (1, &tex);
2263 glBindTexture (GL_TEXTURE_3D, tex);
2264 glTexStorage3D (GL_TEXTURE_3D, m_numLevels, m_internalFormat, m_width, m_height, m_depth);
2266 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
2268 for (int ndx = 0; ndx < m_numLevels; ndx++)
2270 int levelW = de::max(1, m_width >> ndx);
2271 int levelH = de::max(1, m_height >> ndx);
2272 int levelD = de::max(1, m_depth >> ndx);
2273 Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2274 Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2276 levelData.setSize(levelW, levelH, levelD);
2277 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
2279 glTexSubImage3D(GL_TEXTURE_3D, ndx, 0, 0, 0, levelW, levelH, levelD, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr());
2283 deUint32 m_internalFormat;
2286 // Pixel buffer object cases.
2288 // TexImage2D() from pixel buffer object.
2289 class TexImage2DBufferCase : public Texture2DSpecCase
2292 TexImage2DBufferCase (Context& context,
2295 deUint32 internalFormat,
2303 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
2304 , m_internalFormat (internalFormat)
2305 , m_rowLength (rowLength)
2306 , m_skipRows (skipRows)
2307 , m_skipPixels (skipPixels)
2308 , m_alignment (alignment)
2314 void createTexture (void)
2316 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2317 int pixelSize = m_texFormat.getPixelSize();
2318 int rowLength = m_rowLength > 0 ? m_rowLength : m_width + m_skipPixels;
2319 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
2320 int height = m_height + m_skipRows;
2323 vector<deUint8> data;
2325 DE_ASSERT(m_numLevels == 1);
2327 // Fill data with grid.
2328 data.resize(rowPitch*height + m_offset);
2330 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
2331 Vec4 cBias = m_texFormatInfo.valueMin;
2332 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
2333 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
2335 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
2338 // Create buffer and upload.
2339 glGenBuffers(1, &buf);
2340 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2341 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2343 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2344 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2345 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2346 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2348 glGenTextures(1, &tex);
2349 glBindTexture(GL_TEXTURE_2D, tex);
2350 glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
2353 deUint32 m_internalFormat;
2361 // TexImage2D() cubemap from pixel buffer object case
2362 class TexImageCubeBufferCase : public TextureCubeSpecCase
2365 TexImageCubeBufferCase (Context& context,
2368 deUint32 internalFormat,
2375 : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1)
2376 , m_internalFormat (internalFormat)
2377 , m_rowLength (rowLength)
2378 , m_skipRows (skipRows)
2379 , m_skipPixels (skipPixels)
2380 , m_alignment (alignment)
2386 void createTexture (void)
2388 de::Random rnd (deStringHash(getName()));
2390 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
2391 const int pixelSize = m_texFormat.getPixelSize();
2392 const int rowLength = m_rowLength > 0 ? m_rowLength : m_size + m_skipPixels;
2393 const int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
2394 const int height = m_size + m_skipRows;
2395 vector<vector<deUint8> > data (DE_LENGTH_OF_ARRAY(s_cubeMapFaces));
2397 DE_ASSERT(m_numLevels == 1);
2399 glGenTextures(1, &tex);
2400 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
2401 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2403 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2408 const Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2409 const Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2411 data[face].resize(rowPitch*height + m_offset);
2412 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, rowPitch, 0, &data[face][0] + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), gMin, gMax);
2415 // Create buffer and upload.
2416 glGenBuffers(1, &buf);
2417 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2418 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data[face].size(), &data[face][0], GL_STATIC_DRAW);
2420 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2421 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2422 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2423 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2425 glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, fmt.format, fmt.dataType, (const void*)(deUintptr)m_offset);
2429 deUint32 m_internalFormat;
2437 // TexImage3D() 2D array from pixel buffer object.
2438 class TexImage2DArrayBufferCase : public Texture2DArraySpecCase
2441 TexImage2DArrayBufferCase (Context& context,
2444 deUint32 internalFormat,
2455 : Texture2DArraySpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
2456 , m_internalFormat (internalFormat)
2457 , m_imageHeight (imageHeight)
2458 , m_rowLength (rowLength)
2459 , m_skipImages (skipImages)
2460 , m_skipRows (skipRows)
2461 , m_skipPixels (skipPixels)
2462 , m_alignment (alignment)
2468 void createTexture (void)
2470 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2471 int pixelSize = m_texFormat.getPixelSize();
2472 int rowLength = m_rowLength > 0 ? m_rowLength : m_width;
2473 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
2474 int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_height;
2475 int slicePitch = imageHeight*rowPitch;
2478 vector<deUint8> data;
2480 DE_ASSERT(m_numLevels == 1);
2482 // Fill data with grid.
2483 data.resize(slicePitch*(m_numLayers+m_skipImages) + m_offset);
2485 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
2486 Vec4 cBias = m_texFormatInfo.valueMin;
2487 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
2488 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
2490 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_numLayers, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
2493 glGenBuffers(1, &buf);
2494 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2495 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2497 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
2498 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2499 glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
2500 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2501 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2502 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2504 glGenTextures(1, &tex);
2505 glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
2506 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
2509 deUint32 m_internalFormat;
2519 // TexImage3D() from pixel buffer object.
2520 class TexImage3DBufferCase : public Texture3DSpecCase
2523 TexImage3DBufferCase (Context& context,
2526 deUint32 internalFormat,
2537 : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
2538 , m_internalFormat (internalFormat)
2539 , m_imageHeight (imageHeight)
2540 , m_rowLength (rowLength)
2541 , m_skipImages (skipImages)
2542 , m_skipRows (skipRows)
2543 , m_skipPixels (skipPixels)
2544 , m_alignment (alignment)
2550 void createTexture (void)
2552 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2553 int pixelSize = m_texFormat.getPixelSize();
2554 int rowLength = m_rowLength > 0 ? m_rowLength : m_width;
2555 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
2556 int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_height;
2557 int slicePitch = imageHeight*rowPitch;
2560 vector<deUint8> data;
2562 DE_ASSERT(m_numLevels == 1);
2564 // Fill data with grid.
2565 data.resize(slicePitch*(m_depth+m_skipImages) + m_offset);
2567 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
2568 Vec4 cBias = m_texFormatInfo.valueMin;
2569 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
2570 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
2572 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
2575 glGenBuffers(1, &buf);
2576 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2577 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2579 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
2580 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2581 glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
2582 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2583 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2584 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2586 glGenTextures(1, &tex);
2587 glBindTexture(GL_TEXTURE_3D, tex);
2588 glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
2591 deUint32 m_internalFormat;
2601 // TexSubImage2D() PBO case.
2602 class TexSubImage2DBufferCase : public Texture2DSpecCase
2605 TexSubImage2DBufferCase (Context& context,
2608 deUint32 internalFormat,
2620 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1)
2621 , m_internalFormat (internalFormat)
2626 , m_rowLength (rowLength)
2627 , m_skipRows (skipRows)
2628 , m_skipPixels (skipPixels)
2629 , m_alignment (alignment)
2635 void createTexture (void)
2637 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2638 int pixelSize = m_texFormat.getPixelSize();
2641 vector<deUint8> data;
2643 DE_ASSERT(m_numLevels == 1);
2645 glGenTextures(1, &tex);
2646 glBindTexture(GL_TEXTURE_2D, tex);
2648 // First fill texture with gradient.
2649 data.resize(deAlign32(m_width*pixelSize, 4)*m_height);
2650 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, deAlign32(m_width*pixelSize, 4), 0, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2651 glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, &data[0]);
2653 // Fill data with grid.
2655 int rowLength = m_rowLength > 0 ? m_rowLength : m_subW;
2656 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
2657 int height = m_subH + m_skipRows;
2658 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
2659 Vec4 cBias = m_texFormatInfo.valueMin;
2660 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
2661 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
2663 data.resize(rowPitch*height + m_offset);
2664 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
2667 glGenBuffers(1, &buf);
2668 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2669 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2671 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2672 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2673 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2674 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2675 glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
2678 deUint32 m_internalFormat;
2690 // TexSubImage2D() cubemap PBO case.
2691 class TexSubImageCubeBufferCase : public TextureCubeSpecCase
2694 TexSubImageCubeBufferCase (Context& context,
2697 deUint32 internalFormat,
2708 : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1)
2709 , m_internalFormat (internalFormat)
2714 , m_rowLength (rowLength)
2715 , m_skipRows (skipRows)
2716 , m_skipPixels (skipPixels)
2717 , m_alignment (alignment)
2723 void createTexture (void)
2725 de::Random rnd (deStringHash(getName()));
2726 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2727 int pixelSize = m_texFormat.getPixelSize();
2730 vector<deUint8> data;
2732 DE_ASSERT(m_numLevels == 1);
2734 glGenTextures(1, &tex);
2735 glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
2737 // Fill faces with different gradients.
2739 data.resize(deAlign32(m_size*pixelSize, 4)*m_size);
2740 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
2742 for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++)
2744 const Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2745 const Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2747 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, deAlign32(m_size*pixelSize, 4), 0, &data[0]), gMin, gMax);
2749 glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, transferFmt.format, transferFmt.dataType, &data[0]);
2752 // Fill data with grid.
2754 int rowLength = m_rowLength > 0 ? m_rowLength : m_subW;
2755 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
2756 int height = m_subH + m_skipRows;
2757 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
2758 Vec4 cBias = m_texFormatInfo.valueMin;
2759 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
2760 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
2762 data.resize(rowPitch*height + m_offset);
2763 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
2766 glGenBuffers(1, &buf);
2767 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2768 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2770 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2771 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2772 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2773 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2775 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
2776 glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset);
2779 deUint32 m_internalFormat;
2791 // TexSubImage3D() 2D array PBO case.
2792 class TexSubImage2DArrayBufferCase : public Texture2DArraySpecCase
2795 TexSubImage2DArrayBufferCase (Context& context,
2798 deUint32 internalFormat,
2815 : Texture2DArraySpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
2816 , m_internalFormat (internalFormat)
2823 , m_imageHeight (imageHeight)
2824 , m_rowLength (rowLength)
2825 , m_skipImages (skipImages)
2826 , m_skipRows (skipRows)
2827 , m_skipPixels (skipPixels)
2828 , m_alignment (alignment)
2834 void createTexture (void)
2836 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2837 int pixelSize = m_texFormat.getPixelSize();
2840 vector<deUint8> data;
2842 DE_ASSERT(m_numLevels == 1);
2844 glGenTextures(1, &tex);
2845 glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
2847 // Fill with gradient.
2849 int rowPitch = deAlign32(pixelSize*m_width, 4);
2850 int slicePitch = rowPitch*m_height;
2852 data.resize(slicePitch*m_numLayers);
2853 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_numLayers, rowPitch, slicePitch, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2856 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format, transferFmt.dataType, &data[0]);
2858 // Fill data with grid.
2860 int rowLength = m_rowLength > 0 ? m_rowLength : m_subW;
2861 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
2862 int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_subH;
2863 int slicePitch = imageHeight*rowPitch;
2864 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
2865 Vec4 cBias = m_texFormatInfo.valueMin;
2866 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
2867 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
2869 data.resize(slicePitch*(m_numLayers+m_skipImages) + m_offset);
2870 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, m_subD, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
2873 glGenBuffers(1, &buf);
2874 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2875 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2877 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
2878 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2879 glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
2880 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2881 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2882 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2883 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format, transferFmt.dataType, (const void*)(deIntptr)m_offset);
2886 deUint32 m_internalFormat;
2902 // TexSubImage3D() PBO case.
2903 class TexSubImage3DBufferCase : public Texture3DSpecCase
2906 TexSubImage3DBufferCase (Context& context,
2909 deUint32 internalFormat,
2926 : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1)
2927 , m_internalFormat (internalFormat)
2934 , m_imageHeight (imageHeight)
2935 , m_rowLength (rowLength)
2936 , m_skipImages (skipImages)
2937 , m_skipRows (skipRows)
2938 , m_skipPixels (skipPixels)
2939 , m_alignment (alignment)
2945 void createTexture (void)
2947 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
2948 int pixelSize = m_texFormat.getPixelSize();
2951 vector<deUint8> data;
2953 DE_ASSERT(m_numLevels == 1);
2955 glGenTextures(1, &tex);
2956 glBindTexture(GL_TEXTURE_3D, tex);
2958 // Fill with gradient.
2960 int rowPitch = deAlign32(pixelSize*m_width, 4);
2961 int slicePitch = rowPitch*m_height;
2963 data.resize(slicePitch*m_depth);
2964 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax);
2967 glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, &data[0]);
2969 // Fill data with grid.
2971 int rowLength = m_rowLength > 0 ? m_rowLength : m_subW;
2972 int rowPitch = deAlign32(rowLength*pixelSize, m_alignment);
2973 int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_subH;
2974 int slicePitch = imageHeight*rowPitch;
2975 Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin;
2976 Vec4 cBias = m_texFormatInfo.valueMin;
2977 Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias;
2978 Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias;
2980 data.resize(slicePitch*(m_depth+m_skipImages) + m_offset);
2981 tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, m_subD, rowPitch, slicePitch, &data[0] + m_skipImages*slicePitch + m_skipRows*rowPitch + m_skipPixels*pixelSize + m_offset), 4, colorA, colorB);
2984 glGenBuffers(1, &buf);
2985 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
2986 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
2988 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight);
2989 glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength);
2990 glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages);
2991 glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows);
2992 glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels);
2993 glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment);
2994 glTexSubImage3D(GL_TEXTURE_3D, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format, transferFmt.dataType, (const void*)(deIntptr)m_offset);
2997 deUint32 m_internalFormat;
3013 // TexImage2D() depth case.
3014 class TexImage2DDepthCase : public Texture2DSpecCase
3017 TexImage2DDepthCase (Context& context,
3020 deUint32 internalFormat,
3023 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, maxLevelCount(imageWidth, imageHeight))
3024 , m_internalFormat (internalFormat)
3026 // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3027 m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3028 m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3031 void createTexture (void)
3033 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
3035 tcu::TextureLevel levelData (glu::mapGLTransferFormat(fmt.format, fmt.dataType));
3037 glGenTextures(1, &tex);
3038 glBindTexture(GL_TEXTURE_2D, tex);
3039 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3042 for (int ndx = 0; ndx < m_numLevels; ndx++)
3044 const int levelW = de::max(1, m_width >> ndx);
3045 const int levelH = de::max(1, m_height >> ndx);
3046 const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3047 const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3049 levelData.setSize(levelW, levelH);
3050 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3052 glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
3056 const deUint32 m_internalFormat;
3059 // TexImage3D() depth case.
3060 class TexImage2DArrayDepthCase : public Texture2DArraySpecCase
3063 TexImage2DArrayDepthCase (Context& context,
3066 deUint32 internalFormat,
3070 : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, numLayers, maxLevelCount(imageWidth, imageHeight))
3071 , m_internalFormat (internalFormat)
3073 // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3074 m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3075 m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3078 void createTexture (void)
3080 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
3082 tcu::TextureLevel levelData (glu::mapGLTransferFormat(fmt.format, fmt.dataType));
3084 glGenTextures(1, &tex);
3085 glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
3086 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3089 for (int ndx = 0; ndx < m_numLevels; ndx++)
3091 const int levelW = de::max(1, m_width >> ndx);
3092 const int levelH = de::max(1, m_height >> ndx);
3093 const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3094 const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3096 levelData.setSize(levelW, levelH, m_numLayers);
3097 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3099 glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
3103 const deUint32 m_internalFormat;
3106 // TexSubImage2D() depth case.
3107 class TexSubImage2DDepthCase : public Texture2DSpecCase
3110 TexSubImage2DDepthCase (Context& context,
3113 deUint32 internalFormat,
3116 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, maxLevelCount(imageWidth, imageHeight))
3117 , m_internalFormat (internalFormat)
3119 // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3120 m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3121 m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3124 void createTexture (void)
3126 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
3127 de::Random rnd (deStringHash(getName()));
3129 tcu::TextureLevel levelData (glu::mapGLTransferFormat(fmt.format, fmt.dataType));
3131 glGenTextures(1, &tex);
3132 glBindTexture(GL_TEXTURE_2D, tex);
3133 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3136 // First specify full texture.
3137 for (int ndx = 0; ndx < m_numLevels; ndx++)
3139 const int levelW = de::max(1, m_width >> ndx);
3140 const int levelH = de::max(1, m_height >> ndx);
3141 const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3142 const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3144 levelData.setSize(levelW, levelH);
3145 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3147 glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
3150 // Re-specify parts of each level.
3151 for (int ndx = 0; ndx < m_numLevels; ndx++)
3153 const int levelW = de::max(1, m_width >> ndx);
3154 const int levelH = de::max(1, m_height >> ndx);
3156 const int w = rnd.getInt(1, levelW);
3157 const int h = rnd.getInt(1, levelH);
3158 const int x = rnd.getInt(0, levelW-w);
3159 const int y = rnd.getInt(0, levelH-h);
3161 const Vec4 colorA = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3162 const Vec4 colorB = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3163 const int cellSize = rnd.getInt(2, 16);
3165 levelData.setSize(w, h);
3166 tcu::fillWithGrid(levelData.getAccess(), cellSize, colorA, colorB);
3168 glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
3172 const deUint32 m_internalFormat;
3175 // TexSubImage3D() depth case.
3176 class TexSubImage2DArrayDepthCase : public Texture2DArraySpecCase
3179 TexSubImage2DArrayDepthCase (Context& context,
3182 deUint32 internalFormat,
3186 : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, numLayers, maxLevelCount(imageWidth, imageHeight))
3187 , m_internalFormat (internalFormat)
3189 // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3190 m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3191 m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3194 void createTexture (void)
3196 glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat);
3197 de::Random rnd (deStringHash(getName()));
3199 tcu::TextureLevel levelData (glu::mapGLTransferFormat(fmt.format, fmt.dataType));
3201 glGenTextures(1, &tex);
3202 glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
3203 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
3206 // First specify full texture.
3207 for (int ndx = 0; ndx < m_numLevels; ndx++)
3209 const int levelW = de::max(1, m_width >> ndx);
3210 const int levelH = de::max(1, m_height >> ndx);
3211 const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3212 const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3214 levelData.setSize(levelW, levelH, m_numLayers);
3215 tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax);
3217 glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
3220 // Re-specify parts of each level.
3221 for (int ndx = 0; ndx < m_numLevels; ndx++)
3223 const int levelW = de::max(1, m_width >> ndx);
3224 const int levelH = de::max(1, m_height >> ndx);
3226 const int w = rnd.getInt(1, levelW);
3227 const int h = rnd.getInt(1, levelH);
3228 const int d = rnd.getInt(1, m_numLayers);
3229 const int x = rnd.getInt(0, levelW-w);
3230 const int y = rnd.getInt(0, levelH-h);
3231 const int z = rnd.getInt(0, m_numLayers-d);
3233 const Vec4 colorA = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3234 const Vec4 colorB = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3235 const int cellSize = rnd.getInt(2, 16);
3237 levelData.setSize(w, h, d);
3238 tcu::fillWithGrid(levelData.getAccess(), cellSize, colorA, colorB);
3240 glTexSubImage3D(GL_TEXTURE_2D_ARRAY, ndx, x, y, z, w, h, d, fmt.format, fmt.dataType, levelData.getAccess().getDataPtr());
3244 const deUint32 m_internalFormat;
3247 // TexImage2D() depth case with pbo.
3248 class TexImage2DDepthBufferCase : public Texture2DSpecCase
3251 TexImage2DDepthBufferCase (Context& context,
3254 deUint32 internalFormat,
3257 : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, 1)
3258 , m_internalFormat (internalFormat)
3260 // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3261 m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3262 m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3265 void createTexture (void)
3267 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
3268 int pixelSize = m_texFormat.getPixelSize();
3269 int rowLength = m_width;
3271 int rowPitch = deAlign32(rowLength*pixelSize, alignment);
3272 int height = m_height;
3275 vector<deUint8> data;
3277 DE_ASSERT(m_numLevels == 1);
3279 // Fill data with gradient
3280 data.resize(rowPitch*height);
3282 const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3283 const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3285 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0, &data[0]), gMin, gMax);
3288 // Create buffer and upload.
3289 glGenBuffers(1, &buf);
3290 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
3291 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
3293 glPixelStorei(GL_UNPACK_ROW_LENGTH, rowLength);
3294 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
3295 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
3296 glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
3298 glGenTextures(1, &tex);
3299 glBindTexture(GL_TEXTURE_2D, tex);
3300 glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, DE_NULL);
3301 glDeleteBuffers(1, &buf);
3304 const deUint32 m_internalFormat;
3307 // TexImage3D() depth case with pbo.
3308 class TexImage2DArrayDepthBufferCase : public Texture2DArraySpecCase
3311 TexImage2DArrayDepthBufferCase (Context& context,
3314 deUint32 internalFormat,
3318 : Texture2DArraySpecCase(context, name, desc, glu::mapGLInternalFormat(internalFormat), imageWidth, imageHeight, numLayers, 1)
3319 , m_internalFormat (internalFormat)
3321 // we are interested in the behavior near [-2, 2], map it to visible range [0, 1]
3322 m_texFormatInfo.lookupBias = Vec4(0.25f, 0.0f, 0.0f, 1.0f);
3323 m_texFormatInfo.lookupScale = Vec4(0.5f, 1.0f, 1.0f, 0.0f);
3326 void createTexture (void)
3328 glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat);
3329 int pixelSize = m_texFormat.getPixelSize();
3330 int rowLength = m_width;
3332 int rowPitch = deAlign32(rowLength*pixelSize, alignment);
3333 int imageHeight = m_height;
3334 int slicePitch = imageHeight*rowPitch;
3337 vector<deUint8> data;
3339 DE_ASSERT(m_numLevels == 1);
3341 // Fill data with grid.
3342 data.resize(slicePitch*m_numLayers);
3344 const Vec4 gMin = Vec4(-1.5f, -2.0f, 1.7f, -1.5f);
3345 const Vec4 gMax = Vec4(2.0f, 1.5f, -1.0f, 2.0f);
3347 tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_numLayers, rowPitch, slicePitch, &data[0]), gMin, gMax);
3350 glGenBuffers(1, &buf);
3351 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf);
3352 glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW);
3354 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, imageHeight);
3355 glPixelStorei(GL_UNPACK_ROW_LENGTH, rowLength);
3356 glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0);
3357 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
3358 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
3359 glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
3361 glGenTextures(1, &tex);
3362 glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
3363 glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format, transferFmt.dataType, DE_NULL);
3364 glDeleteBuffers(1, &buf);
3367 const deUint32 m_internalFormat;
3370 TextureSpecificationTests::TextureSpecificationTests (Context& context)
3371 : TestCaseGroup(context, "specification", "Texture Specification Tests")
3375 TextureSpecificationTests::~TextureSpecificationTests (void)
3379 void TextureSpecificationTests::init (void)
3386 } unsizedFormats[] =
3388 { "alpha_unsigned_byte", GL_ALPHA, GL_UNSIGNED_BYTE },
3389 { "luminance_unsigned_byte", GL_LUMINANCE, GL_UNSIGNED_BYTE },
3390 { "luminance_alpha_unsigned_byte", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
3391 { "rgb_unsigned_short_5_6_5", GL_RGB, GL_UNSIGNED_SHORT_5_6_5 },
3392 { "rgb_unsigned_byte", GL_RGB, GL_UNSIGNED_BYTE },
3393 { "rgba_unsigned_short_4_4_4_4", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 },
3394 { "rgba_unsigned_short_5_5_5_1", GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 },
3395 { "rgba_unsigned_byte", GL_RGBA, GL_UNSIGNED_BYTE }
3401 deUint32 internalFormat;
3404 { "rgba32f", GL_RGBA32F, },
3405 { "rgba32i", GL_RGBA32I, },
3406 { "rgba32ui", GL_RGBA32UI, },
3407 { "rgba16f", GL_RGBA16F, },
3408 { "rgba16i", GL_RGBA16I, },
3409 { "rgba16ui", GL_RGBA16UI, },
3410 { "rgba8", GL_RGBA8, },
3411 { "rgba8i", GL_RGBA8I, },
3412 { "rgba8ui", GL_RGBA8UI, },
3413 { "srgb8_alpha8", GL_SRGB8_ALPHA8, },
3414 { "rgb10_a2", GL_RGB10_A2, },
3415 { "rgb10_a2ui", GL_RGB10_A2UI, },
3416 { "rgba4", GL_RGBA4, },
3417 { "rgb5_a1", GL_RGB5_A1, },
3418 { "rgba8_snorm", GL_RGBA8_SNORM, },
3419 { "rgb8", GL_RGB8, },
3420 { "rgb565", GL_RGB565, },
3421 { "r11f_g11f_b10f", GL_R11F_G11F_B10F, },
3422 { "rgb32f", GL_RGB32F, },
3423 { "rgb32i", GL_RGB32I, },
3424 { "rgb32ui", GL_RGB32UI, },
3425 { "rgb16f", GL_RGB16F, },
3426 { "rgb16i", GL_RGB16I, },
3427 { "rgb16ui", GL_RGB16UI, },
3428 { "rgb8_snorm", GL_RGB8_SNORM, },
3429 { "rgb8i", GL_RGB8I, },
3430 { "rgb8ui", GL_RGB8UI, },
3431 { "srgb8", GL_SRGB8, },
3432 { "rgb9_e5", GL_RGB9_E5, },
3433 { "rg32f", GL_RG32F, },
3434 { "rg32i", GL_RG32I, },
3435 { "rg32ui", GL_RG32UI, },
3436 { "rg16f", GL_RG16F, },
3437 { "rg16i", GL_RG16I, },
3438 { "rg16ui", GL_RG16UI, },
3440 { "rg8i", GL_RG8I, },
3441 { "rg8ui", GL_RG8UI, },
3442 { "rg8_snorm", GL_RG8_SNORM, },
3443 { "r32f", GL_R32F, },
3444 { "r32i", GL_R32I, },
3445 { "r32ui", GL_R32UI, },
3446 { "r16f", GL_R16F, },
3447 { "r16i", GL_R16I, },
3448 { "r16ui", GL_R16UI, },
3451 { "r8ui", GL_R8UI, },
3452 { "r8_snorm", GL_R8_SNORM, }
3458 deUint32 internalFormat;
3459 } depthStencilFormats[] =
3461 // Depth and stencil formats
3462 { "depth_component32f", GL_DEPTH_COMPONENT32F },
3463 { "depth_component24", GL_DEPTH_COMPONENT24 },
3464 { "depth_component16", GL_DEPTH_COMPONENT16 },
3465 { "depth32f_stencil8", GL_DEPTH32F_STENCIL8 },
3466 { "depth24_stencil8", GL_DEPTH24_STENCIL8 }
3469 // Basic TexImage2D usage.
3471 tcu::TestCaseGroup* basicTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_teximage2d", "Basic glTexImage2D() usage");
3472 addChild(basicTexImageGroup);
3473 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
3475 const char* fmtName = colorFormats[formatNdx].name;
3476 deUint32 format = colorFormats[formatNdx].internalFormat;
3477 const int tex2DWidth = 64;
3478 const int tex2DHeight = 128;
3479 const int texCubeSize = 64;
3481 basicTexImageGroup->addChild(new BasicTexImage2DCase (m_context, (string(fmtName) + "_2d").c_str(), "", format, tex2DWidth, tex2DHeight));
3482 basicTexImageGroup->addChild(new BasicTexImageCubeCase (m_context, (string(fmtName) + "_cube").c_str(), "", format, texCubeSize));
3486 // Randomized TexImage2D order.
3488 tcu::TestCaseGroup* randomTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "random_teximage2d", "Randomized glTexImage2D() usage");
3489 addChild(randomTexImageGroup);
3494 for (int ndx = 0; ndx < 10; ndx++)
3496 int formatNdx = rnd.getInt(0, DE_LENGTH_OF_ARRAY(colorFormats)-1);
3497 int width = 1 << rnd.getInt(2, 8);
3498 int height = 1 << rnd.getInt(2, 8);
3500 randomTexImageGroup->addChild(new RandomOrderTexImage2DCase(m_context, (string("2d_") + de::toString(ndx)).c_str(), "", colorFormats[formatNdx].internalFormat, width, height));
3504 for (int ndx = 0; ndx < 10; ndx++)
3506 int formatNdx = rnd.getInt(0, DE_LENGTH_OF_ARRAY(colorFormats)-1);
3507 int size = 1 << rnd.getInt(2, 8);
3509 randomTexImageGroup->addChild(new RandomOrderTexImageCubeCase(m_context, (string("cube_") + de::toString(ndx)).c_str(), "", colorFormats[formatNdx].internalFormat, size));
3513 // TexImage2D unpack alignment.
3515 tcu::TestCaseGroup* alignGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_align", "glTexImage2D() unpack alignment tests");
3516 addChild(alignGroup);
3518 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_r8_4_8", "", GL_R8, 4, 8, 4, 8));
3519 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_r8_63_1", "", GL_R8, 63, 30, 1, 1));
3520 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_r8_63_2", "", GL_R8, 63, 30, 1, 2));
3521 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_r8_63_4", "", GL_R8, 63, 30, 1, 4));
3522 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_r8_63_8", "", GL_R8, 63, 30, 1, 8));
3523 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba4_51_1", "", GL_RGBA4, 51, 30, 1, 1));
3524 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba4_51_2", "", GL_RGBA4, 51, 30, 1, 2));
3525 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba4_51_4", "", GL_RGBA4, 51, 30, 1, 4));
3526 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba4_51_8", "", GL_RGBA4, 51, 30, 1, 8));
3527 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgb8_39_1", "", GL_RGB8, 39, 43, 1, 1));
3528 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgb8_39_2", "", GL_RGB8, 39, 43, 1, 2));
3529 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgb8_39_4", "", GL_RGB8, 39, 43, 1, 4));
3530 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgb8_39_8", "", GL_RGB8, 39, 43, 1, 8));
3531 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba8_47_1", "", GL_RGBA8, 47, 27, 1, 1));
3532 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba8_47_2", "", GL_RGBA8, 47, 27, 1, 2));
3533 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba8_47_4", "", GL_RGBA8, 47, 27, 1, 4));
3534 alignGroup->addChild(new TexImage2DAlignCase (m_context, "2d_rgba8_47_8", "", GL_RGBA8, 47, 27, 1, 8));
3536 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_r8_4_8", "", GL_R8, 4, 3, 8));
3537 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_r8_63_1", "", GL_R8, 63, 1, 1));
3538 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_r8_63_2", "", GL_R8, 63, 1, 2));
3539 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_r8_63_4", "", GL_R8, 63, 1, 4));
3540 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_r8_63_8", "", GL_R8, 63, 1, 8));
3541 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba4_51_1", "", GL_RGBA4, 51, 1, 1));
3542 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba4_51_2", "", GL_RGBA4, 51, 1, 2));
3543 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba4_51_4", "", GL_RGBA4, 51, 1, 4));
3544 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba4_51_8", "", GL_RGBA4, 51, 1, 8));
3545 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgb8_39_1", "", GL_RGB8, 39, 1, 1));
3546 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgb8_39_2", "", GL_RGB8, 39, 1, 2));
3547 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgb8_39_4", "", GL_RGB8, 39, 1, 4));
3548 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgb8_39_8", "", GL_RGB8, 39, 1, 8));
3549 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba8_47_1", "", GL_RGBA8, 47, 1, 1));
3550 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba8_47_2", "", GL_RGBA8, 47, 1, 2));
3551 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba8_47_4", "", GL_RGBA8, 47, 1, 4));
3552 alignGroup->addChild(new TexImageCubeAlignCase (m_context, "cube_rgba8_47_8", "", GL_RGBA8, 47, 1, 8));
3555 // glTexImage2D() unpack parameter cases.
3557 tcu::TestCaseGroup* paramGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_unpack_params", "glTexImage2D() pixel transfer mode cases");
3558 addChild(paramGroup);
3572 { "rgb8_alignment", GL_RGB8, 31, 30, 0, 0, 0, 2 },
3573 { "rgb8_row_length", GL_RGB8, 31, 30, 50, 0, 0, 4 },
3574 { "rgb8_skip_rows", GL_RGB8, 31, 30, 0, 3, 0, 4 },
3575 { "rgb8_skip_pixels", GL_RGB8, 31, 30, 36, 0, 5, 4 },
3576 { "r8_complex1", GL_R8, 31, 30, 64, 1, 3, 1 },
3577 { "r8_complex2", GL_R8, 31, 30, 64, 1, 3, 2 },
3578 { "r8_complex3", GL_R8, 31, 30, 64, 1, 3, 4 },
3579 { "r8_complex4", GL_R8, 31, 30, 64, 1, 3, 8 },
3580 { "rgba8_complex1", GL_RGBA8, 56, 61, 69, 0, 0, 8 },
3581 { "rgba8_complex2", GL_RGBA8, 56, 61, 69, 0, 7, 8 },
3582 { "rgba8_complex3", GL_RGBA8, 56, 61, 69, 3, 0, 8 },
3583 { "rgba8_complex4", GL_RGBA8, 56, 61, 69, 3, 7, 8 },
3584 { "rgba32f_complex", GL_RGBA32F, 19, 10, 27, 1, 7, 8 }
3587 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
3588 paramGroup->addChild(new TexImage2DParamsCase(m_context, cases[ndx].name, "",
3592 cases[ndx].rowLength,
3593 cases[ndx].skipRows,
3594 cases[ndx].skipPixels,
3595 cases[ndx].alignment));
3598 // glTexImage2D() pbo cases.
3600 tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_pbo", "glTexImage2D() from PBO");
3615 } parameterCases[] =
3617 { "rgb8_offset", GL_RGB8, 31, 30, 0, 0, 0, 4, 67 },
3618 { "rgb8_alignment", GL_RGB8, 31, 30, 0, 0, 0, 2, 0 },
3619 { "rgb8_row_length", GL_RGB8, 31, 30, 50, 0, 0, 4, 0 },
3620 { "rgb8_skip_rows", GL_RGB8, 31, 30, 0, 3, 0, 4, 0 },
3621 { "rgb8_skip_pixels", GL_RGB8, 31, 30, 36, 0, 5, 4, 0 }
3624 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
3626 const string fmtName = colorFormats[formatNdx].name;
3627 const deUint32 format = colorFormats[formatNdx].internalFormat;
3628 const int tex2DWidth = 65;
3629 const int tex2DHeight = 37;
3630 const int texCubeSize = 64;
3632 pboGroup->addChild(new TexImage2DBufferCase (m_context, (fmtName + "_2d").c_str(), "", format, tex2DWidth, tex2DHeight, 0, 0, 0, 4, 0));
3633 pboGroup->addChild(new TexImageCubeBufferCase (m_context, (fmtName + "_cube").c_str(), "", format, texCubeSize, 0, 0, 0, 4, 0));
3636 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(parameterCases); ndx++)
3638 pboGroup->addChild(new TexImage2DBufferCase(m_context, (string(parameterCases[ndx].name) + "_2d").c_str(), "",
3639 parameterCases[ndx].format,
3640 parameterCases[ndx].width,
3641 parameterCases[ndx].height,
3642 parameterCases[ndx].rowLength,
3643 parameterCases[ndx].skipRows,
3644 parameterCases[ndx].skipPixels,
3645 parameterCases[ndx].alignment,
3646 parameterCases[ndx].offset));
3647 pboGroup->addChild(new TexImageCubeBufferCase(m_context, (string(parameterCases[ndx].name) + "_cube").c_str(), "",
3648 parameterCases[ndx].format,
3649 parameterCases[ndx].width,
3650 parameterCases[ndx].rowLength,
3651 parameterCases[ndx].skipRows,
3652 parameterCases[ndx].skipPixels,
3653 parameterCases[ndx].alignment,
3654 parameterCases[ndx].offset));
3658 // glTexImage2D() depth cases.
3660 tcu::TestCaseGroup* shadow2dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_depth", "glTexImage2D() with depth or depth/stencil format");
3661 addChild(shadow2dGroup);
3663 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
3665 const int tex2DWidth = 64;
3666 const int tex2DHeight = 128;
3668 shadow2dGroup->addChild(new TexImage2DDepthCase(m_context, depthStencilFormats[ndx].name, "", depthStencilFormats[ndx].internalFormat, tex2DWidth, tex2DHeight));
3672 // glTexImage2D() depth cases with pbo.
3674 tcu::TestCaseGroup* shadow2dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage2d_depth_pbo", "glTexImage2D() with depth or depth/stencil format with pbo");
3675 addChild(shadow2dGroup);
3677 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
3679 const int tex2DWidth = 64;
3680 const int tex2DHeight = 128;
3682 shadow2dGroup->addChild(new TexImage2DDepthBufferCase(m_context, depthStencilFormats[ndx].name, "", depthStencilFormats[ndx].internalFormat, tex2DWidth, tex2DHeight));
3686 // Basic TexSubImage2D usage.
3688 tcu::TestCaseGroup* basicTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_texsubimage2d", "Basic glTexSubImage2D() usage");
3689 addChild(basicTexSubImageGroup);
3690 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
3692 const char* fmtName = colorFormats[formatNdx].name;
3693 deUint32 format = colorFormats[formatNdx].internalFormat;
3694 const int tex2DWidth = 64;
3695 const int tex2DHeight = 128;
3696 const int texCubeSize = 64;
3698 basicTexSubImageGroup->addChild(new BasicTexSubImage2DCase (m_context, (string(fmtName) + "_2d").c_str(), "", format, tex2DWidth, tex2DHeight));
3699 basicTexSubImageGroup->addChild(new BasicTexSubImageCubeCase (m_context, (string(fmtName) + "_cube").c_str(), "", format, texCubeSize));
3703 // TexSubImage2D to empty texture.
3705 tcu::TestCaseGroup* texSubImageEmptyTexGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_empty_tex", "glTexSubImage2D() to texture that has storage but no data");
3706 addChild(texSubImageEmptyTexGroup);
3707 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(unsizedFormats); formatNdx++)
3709 const char* fmtName = unsizedFormats[formatNdx].name;
3710 deUint32 format = unsizedFormats[formatNdx].format;
3711 deUint32 dataType = unsizedFormats[formatNdx].dataType;
3712 const int tex2DWidth = 64;
3713 const int tex2DHeight = 32;
3714 const int texCubeSize = 32;
3716 texSubImageEmptyTexGroup->addChild(new TexSubImage2DEmptyTexCase (m_context, (string(fmtName) + "_2d").c_str(), "", format, dataType, tex2DWidth, tex2DHeight));
3717 texSubImageEmptyTexGroup->addChild(new TexSubImageCubeEmptyTexCase (m_context, (string(fmtName) + "_cube").c_str(), "", format, dataType, texCubeSize));
3721 // TexSubImage2D alignment cases.
3723 tcu::TestCaseGroup* alignGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_align", "glTexSubImage2D() unpack alignment tests");
3724 addChild(alignGroup);
3726 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_r8_1_1", "", GL_R8, 64, 64, 13, 17, 1, 6, 1));
3727 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_r8_1_2", "", GL_R8, 64, 64, 13, 17, 1, 6, 2));
3728 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_r8_1_4", "", GL_R8, 64, 64, 13, 17, 1, 6, 4));
3729 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_r8_1_8", "", GL_R8, 64, 64, 13, 17, 1, 6, 8));
3730 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_r8_63_1", "", GL_R8, 64, 64, 1, 9, 63, 30, 1));
3731 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_r8_63_2", "", GL_R8, 64, 64, 1, 9, 63, 30, 2));
3732 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_r8_63_4", "", GL_R8, 64, 64, 1, 9, 63, 30, 4));
3733 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_r8_63_8", "", GL_R8, 64, 64, 1, 9, 63, 30, 8));
3734 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba4_51_1", "", GL_RGBA4, 64, 64, 7, 29, 51, 30, 1));
3735 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba4_51_2", "", GL_RGBA4, 64, 64, 7, 29, 51, 30, 2));
3736 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba4_51_4", "", GL_RGBA4, 64, 64, 7, 29, 51, 30, 4));
3737 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba4_51_8", "", GL_RGBA4, 64, 64, 7, 29, 51, 30, 8));
3738 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgb8_39_1", "", GL_RGB8, 64, 64, 11, 8, 39, 43, 1));
3739 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgb8_39_2", "", GL_RGB8, 64, 64, 11, 8, 39, 43, 2));
3740 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgb8_39_4", "", GL_RGB8, 64, 64, 11, 8, 39, 43, 4));
3741 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgb8_39_8", "", GL_RGB8, 64, 64, 11, 8, 39, 43, 8));
3742 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba8_47_1", "", GL_RGBA8, 64, 64, 10, 1, 47, 27, 1));
3743 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba8_47_2", "", GL_RGBA8, 64, 64, 10, 1, 47, 27, 2));
3744 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba8_47_4", "", GL_RGBA8, 64, 64, 10, 1, 47, 27, 4));
3745 alignGroup->addChild(new TexSubImage2DAlignCase (m_context, "2d_rgba8_47_8", "", GL_RGBA8, 64, 64, 10, 1, 47, 27, 8));
3747 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_r8_1_1", "", GL_R8, 64, 13, 17, 1, 6, 1));
3748 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_r8_1_2", "", GL_R8, 64, 13, 17, 1, 6, 2));
3749 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_r8_1_4", "", GL_R8, 64, 13, 17, 1, 6, 4));
3750 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_r8_1_8", "", GL_R8, 64, 13, 17, 1, 6, 8));
3751 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_r8_63_1", "", GL_R8, 64, 1, 9, 63, 30, 1));
3752 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_r8_63_2", "", GL_R8, 64, 1, 9, 63, 30, 2));
3753 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_r8_63_4", "", GL_R8, 64, 1, 9, 63, 30, 4));
3754 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_r8_63_8", "", GL_R8, 64, 1, 9, 63, 30, 8));
3755 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba4_51_1", "", GL_RGBA4, 64, 7, 29, 51, 30, 1));
3756 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba4_51_2", "", GL_RGBA4, 64, 7, 29, 51, 30, 2));
3757 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba4_51_4", "", GL_RGBA4, 64, 7, 29, 51, 30, 4));
3758 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba4_51_8", "", GL_RGBA4, 64, 7, 29, 51, 30, 8));
3759 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgb8_39_1", "", GL_RGB8, 64, 11, 8, 39, 43, 1));
3760 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgb8_39_2", "", GL_RGB8, 64, 11, 8, 39, 43, 2));
3761 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgb8_39_4", "", GL_RGB8, 64, 11, 8, 39, 43, 4));
3762 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgb8_39_8", "", GL_RGB8, 64, 11, 8, 39, 43, 8));
3763 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba8_47_1", "", GL_RGBA8, 64, 10, 1, 47, 27, 1));
3764 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba8_47_2", "", GL_RGBA8, 64, 10, 1, 47, 27, 2));
3765 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba8_47_4", "", GL_RGBA8, 64, 10, 1, 47, 27, 4));
3766 alignGroup->addChild(new TexSubImageCubeAlignCase (m_context, "cube_rgba8_47_8", "", GL_RGBA8, 64, 10, 1, 47, 27, 8));
3769 // glTexSubImage2D() pixel transfer mode cases.
3771 tcu::TestCaseGroup* paramGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_unpack_params", "glTexSubImage2D() pixel transfer mode cases");
3772 addChild(paramGroup);
3790 { "rgb8_alignment", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 0, 0, 2 },
3791 { "rgb8_row_length", GL_RGB8, 54, 60, 11, 7, 31, 30, 50, 0, 0, 4 },
3792 { "rgb8_skip_rows", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 3, 0, 4 },
3793 { "rgb8_skip_pixels", GL_RGB8, 54, 60, 11, 7, 31, 30, 36, 0, 5, 4 },
3794 { "r8_complex1", GL_R8, 54, 60, 11, 7, 31, 30, 64, 1, 3, 1 },
3795 { "r8_complex2", GL_R8, 54, 60, 11, 7, 31, 30, 64, 1, 3, 2 },
3796 { "r8_complex3", GL_R8, 54, 60, 11, 7, 31, 30, 64, 1, 3, 4 },
3797 { "r8_complex4", GL_R8, 54, 60, 11, 7, 31, 30, 64, 1, 3, 8 },
3798 { "rgba8_complex1", GL_RGBA8, 92, 84, 13, 19, 56, 61, 69, 0, 0, 8 },
3799 { "rgba8_complex2", GL_RGBA8, 92, 84, 13, 19, 56, 61, 69, 0, 7, 8 },
3800 { "rgba8_complex3", GL_RGBA8, 92, 84, 13, 19, 56, 61, 69, 3, 0, 8 },
3801 { "rgba8_complex4", GL_RGBA8, 92, 84, 13, 19, 56, 61, 69, 3, 7, 8 },
3802 { "rgba32f_complex", GL_RGBA32F, 92, 84, 13, 19, 56, 61, 69, 3, 7, 8 }
3805 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
3806 paramGroup->addChild(new TexSubImage2DParamsCase(m_context, cases[ndx].name, "",
3814 cases[ndx].rowLength,
3815 cases[ndx].skipRows,
3816 cases[ndx].skipPixels,
3817 cases[ndx].alignment));
3820 // glTexSubImage2D() PBO cases.
3822 tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_pbo", "glTexSubImage2D() pixel buffer object tests");
3842 { "rgb8_offset", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 0, 0, 4, 67 },
3843 { "rgb8_alignment", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 0, 0, 2, 0 },
3844 { "rgb8_row_length", GL_RGB8, 54, 60, 11, 7, 31, 30, 50, 0, 0, 4, 0 },
3845 { "rgb8_skip_rows", GL_RGB8, 54, 60, 11, 7, 31, 30, 0, 3, 0, 4, 0 },
3846 { "rgb8_skip_pixels", GL_RGB8, 54, 60, 11, 7, 31, 30, 36, 0, 5, 4, 0 }
3849 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorFormats); ndx++)
3851 pboGroup->addChild(new TexSubImage2DBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_2d").c_str(), "",
3852 colorFormats[ndx].internalFormat,
3864 pboGroup->addChild(new TexSubImageCubeBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_cube").c_str(), "",
3865 colorFormats[ndx].internalFormat,
3878 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(paramCases); ndx++)
3880 pboGroup->addChild(new TexSubImage2DBufferCase(m_context, (std::string(paramCases[ndx].name) + "_2d").c_str(), "",
3881 paramCases[ndx].format,
3882 paramCases[ndx].width,
3883 paramCases[ndx].height,
3884 paramCases[ndx].subX,
3885 paramCases[ndx].subY,
3886 paramCases[ndx].subW,
3887 paramCases[ndx].subH,
3888 paramCases[ndx].rowLength,
3889 paramCases[ndx].skipRows,
3890 paramCases[ndx].skipPixels,
3891 paramCases[ndx].alignment,
3892 paramCases[ndx].offset));
3893 pboGroup->addChild(new TexSubImageCubeBufferCase(m_context, (std::string(paramCases[ndx].name) + "_cube").c_str(), "",
3894 paramCases[ndx].format,
3895 paramCases[ndx].width,
3896 paramCases[ndx].subX,
3897 paramCases[ndx].subY,
3898 paramCases[ndx].subW,
3899 paramCases[ndx].subH,
3900 paramCases[ndx].rowLength,
3901 paramCases[ndx].skipRows,
3902 paramCases[ndx].skipPixels,
3903 paramCases[ndx].alignment,
3904 paramCases[ndx].offset));
3908 // glTexSubImage2D() depth cases.
3910 tcu::TestCaseGroup* shadow2dGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage2d_depth", "glTexSubImage2D() with depth or depth/stencil format");
3911 addChild(shadow2dGroup);
3913 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
3915 const int tex2DWidth = 64;
3916 const int tex2DHeight = 32;
3918 shadow2dGroup->addChild(new TexSubImage2DDepthCase(m_context, depthStencilFormats[ndx].name, "", depthStencilFormats[ndx].internalFormat, tex2DWidth, tex2DHeight));
3922 // Basic glCopyTexImage2D() cases
3924 tcu::TestCaseGroup* copyTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_copyteximage2d", "Basic glCopyTexImage2D() usage");
3925 addChild(copyTexImageGroup);
3927 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_alpha", "", GL_ALPHA, 128, 64));
3928 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_luminance", "", GL_LUMINANCE, 128, 64));
3929 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_luminance_alpha", "", GL_LUMINANCE_ALPHA, 128, 64));
3930 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_rgb", "", GL_RGB, 128, 64));
3931 copyTexImageGroup->addChild(new BasicCopyTexImage2DCase (m_context, "2d_rgba", "", GL_RGBA, 128, 64));
3933 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_alpha", "", GL_ALPHA, 64));
3934 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_luminance", "", GL_LUMINANCE, 64));
3935 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_luminance_alpha", "", GL_LUMINANCE_ALPHA, 64));
3936 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_rgb", "", GL_RGB, 64));
3937 copyTexImageGroup->addChild(new BasicCopyTexImageCubeCase (m_context, "cube_rgba", "", GL_RGBA, 64));
3940 // Basic glCopyTexSubImage2D() cases
3942 tcu::TestCaseGroup* copyTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_copytexsubimage2d", "Basic glCopyTexSubImage2D() usage");
3943 addChild(copyTexSubImageGroup);
3945 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_alpha", "", GL_ALPHA, GL_UNSIGNED_BYTE, 128, 64));
3946 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_luminance", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 128, 64));
3947 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_luminance_alpha", "", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 128, 64));
3948 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_rgb", "", GL_RGB, GL_UNSIGNED_BYTE, 128, 64));
3949 copyTexSubImageGroup->addChild(new BasicCopyTexSubImage2DCase (m_context, "2d_rgba", "", GL_RGBA, GL_UNSIGNED_BYTE, 128, 64));
3951 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_alpha", "", GL_ALPHA, GL_UNSIGNED_BYTE, 64));
3952 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_luminance", "", GL_LUMINANCE, GL_UNSIGNED_BYTE, 64));
3953 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_luminance_alpha", "", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 64));
3954 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_rgb", "", GL_RGB, GL_UNSIGNED_BYTE, 64));
3955 copyTexSubImageGroup->addChild(new BasicCopyTexSubImageCubeCase (m_context, "cube_rgba", "", GL_RGBA, GL_UNSIGNED_BYTE, 64));
3958 // Basic TexImage3D usage.
3960 tcu::TestCaseGroup* basicTexImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_teximage3d", "Basic glTexImage3D() usage");
3961 addChild(basicTexImageGroup);
3962 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
3964 const char* fmtName = colorFormats[formatNdx].name;
3965 deUint32 format = colorFormats[formatNdx].internalFormat;
3966 const int tex2DArrayWidth = 57;
3967 const int tex2DArrayHeight = 44;
3968 const int tex2DArrayLevels = 5;
3969 const int tex3DWidth = 63;
3970 const int tex3DHeight = 29;
3971 const int tex3DDepth = 11;
3973 basicTexImageGroup->addChild(new BasicTexImage2DArrayCase (m_context, (string(fmtName) + "_2d_array").c_str(), "", format, tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLevels));
3974 basicTexImageGroup->addChild(new BasicTexImage3DCase (m_context, (string(fmtName) + "_3d").c_str(), "", format, tex3DWidth, tex3DHeight, tex3DDepth));
3978 // glTexImage3D() unpack params cases.
3980 tcu::TestCaseGroup* paramGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_unpack_params", "glTexImage3D() unpack parameters");
3981 addChild(paramGroup);
3998 { "rgb8_image_height", GL_RGB8, 23, 19, 8, 26, 0, 0, 0, 0, 4 },
3999 { "rgb8_row_length", GL_RGB8, 23, 19, 8, 0, 27, 0, 0, 0, 4 },
4000 { "rgb8_skip_images", GL_RGB8, 23, 19, 8, 0, 0, 3, 0, 0, 4 },
4001 { "rgb8_skip_rows", GL_RGB8, 23, 19, 8, 22, 0, 0, 3, 0, 4 },
4002 { "rgb8_skip_pixels", GL_RGB8, 23, 19, 8, 0, 25, 0, 0, 2, 4 },
4003 { "r8_complex1", GL_R8, 13, 17, 11, 23, 15, 2, 3, 1, 1 },
4004 { "r8_complex2", GL_R8, 13, 17, 11, 23, 15, 2, 3, 1, 2 },
4005 { "r8_complex3", GL_R8, 13, 17, 11, 23, 15, 2, 3, 1, 4 },
4006 { "r8_complex4", GL_R8, 13, 17, 11, 23, 15, 2, 3, 1, 8 },
4007 { "rgba8_complex1", GL_RGBA8, 11, 20, 8, 25, 14, 0, 0, 0, 8 },
4008 { "rgba8_complex2", GL_RGBA8, 11, 20, 8, 25, 14, 0, 2, 0, 8 },
4009 { "rgba8_complex3", GL_RGBA8, 11, 20, 8, 25, 14, 0, 0, 3, 8 },
4010 { "rgba8_complex4", GL_RGBA8, 11, 20, 8, 25, 14, 0, 2, 3, 8 },
4011 { "rgba32f_complex", GL_RGBA32F, 11, 20, 8, 25, 14, 0, 2, 3, 8 }
4014 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
4015 paramGroup->addChild(new TexImage3DParamsCase(m_context, cases[ndx].name, "",
4020 cases[ndx].imageHeight,
4021 cases[ndx].rowLength,
4022 cases[ndx].skipImages,
4023 cases[ndx].skipRows,
4024 cases[ndx].skipPixels,
4025 cases[ndx].alignment));
4028 // glTexImage3D() pbo cases.
4030 tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_pbo", "glTexImage3D() from PBO");
4048 } parameterCases[] =
4050 { "rgb8_offset", GL_RGB8, 23, 19, 8, 0, 0, 0, 0, 0, 1, 67 },
4051 { "rgb8_alignment", GL_RGB8, 23, 19, 8, 0, 0, 0, 0, 0, 2, 0 },
4052 { "rgb8_image_height", GL_RGB8, 23, 19, 8, 26, 0, 0, 0, 0, 4, 0 },
4053 { "rgb8_row_length", GL_RGB8, 23, 19, 8, 0, 27, 0, 0, 0, 4, 0 },
4054 { "rgb8_skip_images", GL_RGB8, 23, 19, 8, 0, 0, 3, 0, 0, 4, 0 },
4055 { "rgb8_skip_rows", GL_RGB8, 23, 19, 8, 22, 0, 0, 3, 0, 4, 0 },
4056 { "rgb8_skip_pixels", GL_RGB8, 23, 19, 8, 0, 25, 0, 0, 2, 4, 0 }
4059 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
4061 const string fmtName = colorFormats[formatNdx].name;
4062 const deUint32 format = colorFormats[formatNdx].internalFormat;
4063 const int tex3DWidth = 11;
4064 const int tex3DHeight = 20;
4065 const int tex3DDepth = 8;
4067 pboGroup->addChild(new TexImage2DArrayBufferCase (m_context, (fmtName + "_2d_array").c_str(), "", format, tex3DWidth, tex3DHeight, tex3DDepth, 0, 0, 0, 0, 0, 4, 0));
4068 pboGroup->addChild(new TexImage3DBufferCase (m_context, (fmtName + "_3d").c_str(), "", format, tex3DWidth, tex3DHeight, tex3DDepth, 0, 0, 0, 0, 0, 4, 0));
4071 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(parameterCases); ndx++)
4073 pboGroup->addChild(new TexImage2DArrayBufferCase(m_context, (string(parameterCases[ndx].name) + "_2d_array").c_str(), "",
4074 parameterCases[ndx].format,
4075 parameterCases[ndx].width,
4076 parameterCases[ndx].depth,
4077 parameterCases[ndx].height,
4078 parameterCases[ndx].imageHeight,
4079 parameterCases[ndx].rowLength,
4080 parameterCases[ndx].skipImages,
4081 parameterCases[ndx].skipRows,
4082 parameterCases[ndx].skipPixels,
4083 parameterCases[ndx].alignment,
4084 parameterCases[ndx].offset));
4085 pboGroup->addChild(new TexImage3DBufferCase(m_context, (string(parameterCases[ndx].name) + "_3d").c_str(), "",
4086 parameterCases[ndx].format,
4087 parameterCases[ndx].width,
4088 parameterCases[ndx].depth,
4089 parameterCases[ndx].height,
4090 parameterCases[ndx].imageHeight,
4091 parameterCases[ndx].rowLength,
4092 parameterCases[ndx].skipImages,
4093 parameterCases[ndx].skipRows,
4094 parameterCases[ndx].skipPixels,
4095 parameterCases[ndx].alignment,
4096 parameterCases[ndx].offset));
4100 // glTexImage3D() depth cases.
4102 tcu::TestCaseGroup* shadow3dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_depth", "glTexImage3D() with depth or depth/stencil format");
4103 addChild(shadow3dGroup);
4105 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
4107 const int tex3DWidth = 32;
4108 const int tex3DHeight = 64;
4109 const int tex3DDepth = 8;
4111 shadow3dGroup->addChild(new TexImage2DArrayDepthCase(m_context, (std::string(depthStencilFormats[ndx].name) + "_2d_array").c_str(), "", depthStencilFormats[ndx].internalFormat, tex3DWidth, tex3DHeight, tex3DDepth));
4115 // glTexImage3D() depth cases with pbo.
4117 tcu::TestCaseGroup* shadow3dGroup = new tcu::TestCaseGroup(m_testCtx, "teximage3d_depth_pbo", "glTexImage3D() with depth or depth/stencil format with pbo");
4118 addChild(shadow3dGroup);
4120 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
4122 const int tex3DWidth = 32;
4123 const int tex3DHeight = 64;
4124 const int tex3DDepth = 8;
4126 shadow3dGroup->addChild(new TexImage2DArrayDepthBufferCase(m_context, (std::string(depthStencilFormats[ndx].name) + "_2d_array").c_str(), "", depthStencilFormats[ndx].internalFormat, tex3DWidth, tex3DHeight, tex3DDepth));
4130 // Basic TexSubImage3D usage.
4132 tcu::TestCaseGroup* basicTexSubImageGroup = new tcu::TestCaseGroup(m_testCtx, "basic_texsubimage3d", "Basic glTexSubImage3D() usage");
4133 addChild(basicTexSubImageGroup);
4134 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
4136 const char* fmtName = colorFormats[formatNdx].name;
4137 deUint32 format = colorFormats[formatNdx].internalFormat;
4138 const int tex3DWidth = 32;
4139 const int tex3DHeight = 64;
4140 const int tex3DDepth = 8;
4142 basicTexSubImageGroup->addChild(new BasicTexSubImage3DCase(m_context, (string(fmtName) + "_3d").c_str(), "", format, tex3DWidth, tex3DHeight, tex3DDepth));
4146 // glTexSubImage3D() unpack params cases.
4148 tcu::TestCaseGroup* paramGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_unpack_params", "glTexSubImage3D() unpack parameters");
4149 addChild(paramGroup);
4172 { "rgb8_image_height", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 26, 0, 0, 0, 0, 4 },
4173 { "rgb8_row_length", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 27, 0, 0, 0, 4 },
4174 { "rgb8_skip_images", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 0, 3, 0, 0, 4 },
4175 { "rgb8_skip_rows", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 22, 0, 0, 3, 0, 4 },
4176 { "rgb8_skip_pixels", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 25, 0, 0, 2, 4 },
4177 { "r8_complex1", GL_R8, 15, 20, 11, 1, 1, 0, 13, 17, 11, 23, 15, 2, 3, 1, 1 },
4178 { "r8_complex2", GL_R8, 15, 20, 11, 1, 1, 0, 13, 17, 11, 23, 15, 2, 3, 1, 2 },
4179 { "r8_complex3", GL_R8, 15, 20, 11, 1, 1, 0, 13, 17, 11, 23, 15, 2, 3, 1, 4 },
4180 { "r8_complex4", GL_R8, 15, 20, 11, 1, 1, 0, 13, 17, 11, 23, 15, 2, 3, 1, 8 },
4181 { "rgba8_complex1", GL_RGBA8, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 0, 0, 8 },
4182 { "rgba8_complex2", GL_RGBA8, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 2, 0, 8 },
4183 { "rgba8_complex3", GL_RGBA8, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 0, 3, 8 },
4184 { "rgba8_complex4", GL_RGBA8, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 2, 3, 8 },
4185 { "rgba32f_complex", GL_RGBA32F, 15, 25, 10, 0, 5, 1, 11, 20, 8, 25, 14, 0, 2, 3, 8 }
4188 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cases); ndx++)
4189 paramGroup->addChild(new TexSubImage3DParamsCase(m_context, cases[ndx].name, "",
4200 cases[ndx].imageHeight,
4201 cases[ndx].rowLength,
4202 cases[ndx].skipImages,
4203 cases[ndx].skipRows,
4204 cases[ndx].skipPixels,
4205 cases[ndx].alignment));
4208 // glTexSubImage3D() PBO cases.
4210 tcu::TestCaseGroup* pboGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_pbo", "glTexSubImage3D() pixel buffer object tests");
4235 { "rgb8_offset", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 0, 0, 0, 0, 4, 67 },
4236 { "rgb8_image_height", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 26, 0, 0, 0, 0, 4, 0 },
4237 { "rgb8_row_length", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 27, 0, 0, 0, 4, 0 },
4238 { "rgb8_skip_images", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 0, 3, 0, 0, 4, 0 },
4239 { "rgb8_skip_rows", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 22, 0, 0, 3, 0, 4, 0 },
4240 { "rgb8_skip_pixels", GL_RGB8, 26, 25, 10, 1, 2, 1, 23, 19, 8, 0, 25, 0, 0, 2, 4, 0 }
4243 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorFormats); ndx++)
4245 pboGroup->addChild(new TexSubImage2DArrayBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_2d_array").c_str(), "",
4246 colorFormats[ndx].internalFormat,
4263 pboGroup->addChild(new TexSubImage3DBufferCase(m_context, (std::string(colorFormats[ndx].name) + "_3d").c_str(), "",
4264 colorFormats[ndx].internalFormat,
4283 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(paramCases); ndx++)
4285 pboGroup->addChild(new TexSubImage2DArrayBufferCase(m_context, (std::string(paramCases[ndx].name) + "_2d_array").c_str(), "",
4286 paramCases[ndx].format,
4287 paramCases[ndx].width,
4288 paramCases[ndx].height,
4289 paramCases[ndx].depth,
4290 paramCases[ndx].subX,
4291 paramCases[ndx].subY,
4292 paramCases[ndx].subZ,
4293 paramCases[ndx].subW,
4294 paramCases[ndx].subH,
4295 paramCases[ndx].subD,
4296 paramCases[ndx].imageHeight,
4297 paramCases[ndx].rowLength,
4298 paramCases[ndx].skipImages,
4299 paramCases[ndx].skipRows,
4300 paramCases[ndx].skipPixels,
4301 paramCases[ndx].alignment,
4302 paramCases[ndx].offset));
4303 pboGroup->addChild(new TexSubImage3DBufferCase(m_context, (std::string(paramCases[ndx].name) + "_3d").c_str(), "",
4304 paramCases[ndx].format,
4305 paramCases[ndx].width,
4306 paramCases[ndx].height,
4307 paramCases[ndx].depth,
4308 paramCases[ndx].subX,
4309 paramCases[ndx].subY,
4310 paramCases[ndx].subZ,
4311 paramCases[ndx].subW,
4312 paramCases[ndx].subH,
4313 paramCases[ndx].subD,
4314 paramCases[ndx].imageHeight,
4315 paramCases[ndx].rowLength,
4316 paramCases[ndx].skipImages,
4317 paramCases[ndx].skipRows,
4318 paramCases[ndx].skipPixels,
4319 paramCases[ndx].alignment,
4320 paramCases[ndx].offset));
4324 // glTexSubImage3D() depth cases.
4326 tcu::TestCaseGroup* shadow3dGroup = new tcu::TestCaseGroup(m_testCtx, "texsubimage3d_depth", "glTexSubImage3D() with depth or depth/stencil format");
4327 addChild(shadow3dGroup);
4329 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthStencilFormats); ndx++)
4331 const int tex2DArrayWidth = 57;
4332 const int tex2DArrayHeight = 44;
4333 const int tex2DArrayLevels = 5;
4335 shadow3dGroup->addChild(new TexSubImage2DArrayDepthCase(m_context, (std::string(depthStencilFormats[ndx].name) + "_2d_array").c_str(), "", depthStencilFormats[ndx].internalFormat, tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLevels));
4339 // glTexStorage2D() cases.
4341 tcu::TestCaseGroup* texStorageGroup = new tcu::TestCaseGroup(m_testCtx, "texstorage2d", "Basic glTexStorage2D() usage");
4342 addChild(texStorageGroup);
4345 tcu::TestCaseGroup* formatGroup = new tcu::TestCaseGroup(m_testCtx, "format", "glTexStorage2D() with all formats");
4346 texStorageGroup->addChild(formatGroup);
4349 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
4351 const char* fmtName = colorFormats[formatNdx].name;
4352 deUint32 internalFormat = colorFormats[formatNdx].internalFormat;
4353 const int tex2DWidth = 117;
4354 const int tex2DHeight = 97;
4355 int tex2DLevels = maxLevelCount(tex2DWidth, tex2DHeight);
4356 const int cubeSize = 57;
4357 int cubeLevels = maxLevelCount(cubeSize, cubeSize);
4359 formatGroup->addChild(new BasicTexStorage2DCase (m_context, (string(fmtName) + "_2d").c_str(), "", internalFormat, tex2DWidth, tex2DHeight, tex2DLevels));
4360 formatGroup->addChild(new BasicTexStorageCubeCase (m_context, (string(fmtName) + "_cube").c_str(), "", internalFormat, cubeSize, cubeLevels));
4363 // Depth / stencil formats.
4364 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); formatNdx++)
4366 const char* fmtName = depthStencilFormats[formatNdx].name;
4367 deUint32 internalFormat = depthStencilFormats[formatNdx].internalFormat;
4368 const int tex2DWidth = 117;
4369 const int tex2DHeight = 97;
4370 int tex2DLevels = maxLevelCount(tex2DWidth, tex2DHeight);
4371 const int cubeSize = 57;
4372 int cubeLevels = maxLevelCount(cubeSize, cubeSize);
4374 formatGroup->addChild(new BasicTexStorage2DCase (m_context, (string(fmtName) + "_2d").c_str(), "", internalFormat, tex2DWidth, tex2DHeight, tex2DLevels));
4375 formatGroup->addChild(new BasicTexStorageCubeCase (m_context, (string(fmtName) + "_cube").c_str(), "", internalFormat, cubeSize, cubeLevels));
4411 tcu::TestCaseGroup* sizeGroup = new tcu::TestCaseGroup(m_testCtx, "size", "glTexStorage2D() with various sizes");
4412 texStorageGroup->addChild(sizeGroup);
4414 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(tex2DSizes); ndx++)
4416 const deUint32 format = GL_RGBA8;
4417 int width = tex2DSizes[ndx].width;
4418 int height = tex2DSizes[ndx].height;
4419 int levels = tex2DSizes[ndx].levels;
4420 string name = string("2d_") + de::toString(width) + "x" + de::toString(height) + "_" + de::toString(levels) + "_levels";
4422 sizeGroup->addChild(new BasicTexStorage2DCase(m_context, name.c_str(), "", format, width, height, levels));
4425 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cubeSizes); ndx++)
4427 const deUint32 format = GL_RGBA8;
4428 int size = cubeSizes[ndx].size;
4429 int levels = cubeSizes[ndx].levels;
4430 string name = string("cube_") + de::toString(size) + "x" + de::toString(size) + "_" + de::toString(levels) + "_levels";
4432 sizeGroup->addChild(new BasicTexStorageCubeCase(m_context, name.c_str(), "", format, size, levels));
4436 // glTexStorage3D() cases.
4438 tcu::TestCaseGroup* texStorageGroup = new tcu::TestCaseGroup(m_testCtx, "texstorage3d", "Basic glTexStorage3D() usage");
4439 addChild(texStorageGroup);
4442 tcu::TestCaseGroup* formatGroup = new tcu::TestCaseGroup(m_testCtx, "format", "glTexStorage3D() with all formats");
4443 texStorageGroup->addChild(formatGroup);
4446 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(colorFormats); formatNdx++)
4448 const char* fmtName = colorFormats[formatNdx].name;
4449 deUint32 internalFormat = colorFormats[formatNdx].internalFormat;
4450 const int tex2DArrayWidth = 57;
4451 const int tex2DArrayHeight = 13;
4452 const int tex2DArrayLayers = 7;
4453 int tex2DArrayLevels = maxLevelCount(tex2DArrayWidth, tex2DArrayHeight);
4454 const int tex3DWidth = 59;
4455 const int tex3DHeight = 37;
4456 const int tex3DDepth = 11;
4457 int tex3DLevels = maxLevelCount(tex3DWidth, tex3DHeight, tex3DDepth);
4459 formatGroup->addChild(new BasicTexStorage2DArrayCase (m_context, (string(fmtName) + "_2d_array").c_str(), "", internalFormat, tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLayers, tex2DArrayLevels));
4460 formatGroup->addChild(new BasicTexStorage3DCase (m_context, (string(fmtName) + "_3d").c_str(), "", internalFormat, tex3DWidth, tex3DHeight, tex3DDepth, tex3DLevels));
4463 // Depth/stencil formats (only 2D texture array is supported).
4464 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(depthStencilFormats); formatNdx++)
4466 const char* fmtName = depthStencilFormats[formatNdx].name;
4467 deUint32 internalFormat = depthStencilFormats[formatNdx].internalFormat;
4468 const int tex2DArrayWidth = 57;
4469 const int tex2DArrayHeight = 13;
4470 const int tex2DArrayLayers = 7;
4471 int tex2DArrayLevels = maxLevelCount(tex2DArrayWidth, tex2DArrayHeight);
4473 formatGroup->addChild(new BasicTexStorage2DArrayCase (m_context, (string(fmtName) + "_2d_array").c_str(), "", internalFormat, tex2DArrayWidth, tex2DArrayHeight, tex2DArrayLayers, tex2DArrayLevels));
4483 } tex2DArraySizes[] =
4513 tcu::TestCaseGroup* sizeGroup = new tcu::TestCaseGroup(m_testCtx, "size", "glTexStorage2D() with various sizes");
4514 texStorageGroup->addChild(sizeGroup);
4516 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(tex2DArraySizes); ndx++)
4518 const deUint32 format = GL_RGBA8;
4519 int width = tex2DArraySizes[ndx].width;
4520 int height = tex2DArraySizes[ndx].height;
4521 int layers = tex2DArraySizes[ndx].layers;
4522 int levels = tex2DArraySizes[ndx].levels;
4523 string name = string("2d_array_") + de::toString(width) + "x" + de::toString(height) + "x" + de::toString(layers) + "_" + de::toString(levels) + "_levels";
4525 sizeGroup->addChild(new BasicTexStorage2DArrayCase(m_context, name.c_str(), "", format, width, height, layers, levels));
4528 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(tex3DSizes); ndx++)
4530 const deUint32 format = GL_RGBA8;
4531 int width = tex3DSizes[ndx].width;
4532 int height = tex3DSizes[ndx].height;
4533 int depth = tex3DSizes[ndx].depth;
4534 int levels = tex3DSizes[ndx].levels;
4535 string name = string("3d_") + de::toString(width) + "x" + de::toString(height) + "x" + de::toString(depth) + "_" + de::toString(levels) + "_levels";
4537 sizeGroup->addChild(new BasicTexStorage3DCase(m_context, name.c_str(), "", format, width, height, depth, levels));