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