| /*------------------------------------------------------------------------- |
| * drawElements Quality Program OpenGL ES 3.0 Module |
| * ------------------------------------------------- |
| * |
| * Copyright 2014 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| * |
| *//*! |
| * \file |
| * \brief Texture specification tests. |
| * |
| * \todo [pyry] Following tests are missing: |
| * - Specify mipmap incomplete texture, use without mipmaps, re-specify |
| * as complete and render. |
| * - Randomly re-specify levels to eventually reach mipmap-complete texture. |
| *//*--------------------------------------------------------------------*/ |
| |
| #include "es3fTextureSpecificationTests.hpp" |
| #include "tcuTestLog.hpp" |
| #include "tcuImageCompare.hpp" |
| #include "tcuTextureUtil.hpp" |
| #include "tcuVectorUtil.hpp" |
| #include "gluStrUtil.hpp" |
| #include "gluTexture.hpp" |
| #include "gluTextureUtil.hpp" |
| #include "sglrContextUtil.hpp" |
| #include "sglrContextWrapper.hpp" |
| #include "sglrGLContext.hpp" |
| #include "sglrReferenceContext.hpp" |
| #include "glsTextureTestUtil.hpp" |
| #include "deRandom.hpp" |
| #include "deStringUtil.hpp" |
| |
| // \todo [2012-04-29 pyry] Should be named SglrUtil |
| #include "es3fFboTestUtil.hpp" |
| |
| #include "glwEnums.hpp" |
| |
| namespace deqp |
| { |
| namespace gles3 |
| { |
| namespace Functional |
| { |
| |
| using std::string; |
| using std::vector; |
| using std::pair; |
| using tcu::TestLog; |
| using tcu::Vec4; |
| using tcu::IVec4; |
| using tcu::UVec4; |
| using namespace FboTestUtil; |
| |
| tcu::TextureFormat mapGLUnsizedInternalFormat (deUint32 internalFormat) |
| { |
| using tcu::TextureFormat; |
| switch (internalFormat) |
| { |
| case GL_ALPHA: return TextureFormat(TextureFormat::A, TextureFormat::UNORM_INT8); |
| case GL_LUMINANCE: return TextureFormat(TextureFormat::L, TextureFormat::UNORM_INT8); |
| case GL_LUMINANCE_ALPHA: return TextureFormat(TextureFormat::LA, TextureFormat::UNORM_INT8); |
| case GL_RGB: return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8); |
| case GL_RGBA: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8); |
| default: |
| throw tcu::InternalError(string("Can't map GL unsized internal format (") + tcu::toHex(internalFormat).toString() + ") to texture format"); |
| } |
| } |
| |
| enum |
| { |
| VIEWPORT_WIDTH = 256, |
| VIEWPORT_HEIGHT = 256 |
| }; |
| |
| static inline int maxLevelCount (int width, int height) |
| { |
| return (int)deLog2Floor32(de::max(width, height))+1; |
| } |
| |
| static inline int maxLevelCount (int width, int height, int depth) |
| { |
| return (int)deLog2Floor32(de::max(width, de::max(height, depth)))+1; |
| } |
| |
| template <int Size> |
| static tcu::Vector<float, Size> randomVector (de::Random& rnd, const tcu::Vector<float, Size>& minVal = tcu::Vector<float, Size>(0.0f), const tcu::Vector<float, Size>& maxVal = tcu::Vector<float, Size>(1.0f)) |
| { |
| tcu::Vector<float, Size> res; |
| for (int ndx = 0; ndx < Size; ndx++) |
| res[ndx] = rnd.getFloat(minVal[ndx], maxVal[ndx]); |
| return res; |
| } |
| |
| static const deUint32 s_cubeMapFaces[] = |
| { |
| GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
| GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
| GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, |
| GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
| GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, |
| GL_TEXTURE_CUBE_MAP_POSITIVE_Z, |
| }; |
| |
| static tcu::IVec4 getPixelFormatCompareDepth (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat) |
| { |
| switch (textureFormat.order) |
| { |
| case tcu::TextureFormat::L: |
| case tcu::TextureFormat::LA: |
| return tcu::IVec4(pixelFormat.redBits, pixelFormat.redBits, pixelFormat.redBits, pixelFormat.alphaBits); |
| default: |
| return tcu::IVec4(pixelFormat.redBits, pixelFormat.greenBits, pixelFormat.blueBits, pixelFormat.alphaBits); |
| } |
| } |
| |
| static IVec4 getEffectiveTextureFormatBitDepth (tcu::TextureFormat textureFormat) |
| { |
| if (textureFormat.order == tcu::TextureFormat::DS) |
| { |
| // When sampling depth-stencil texture, we actually sample just |
| // the depth component. |
| return tcu::getTextureFormatBitDepth(tcu::getEffectiveDepthStencilTextureFormat(textureFormat, tcu::Sampler::MODE_DEPTH)); |
| } |
| else |
| return tcu::getTextureFormatBitDepth(textureFormat); |
| } |
| |
| static tcu::UVec4 computeCompareThreshold (const tcu::PixelFormat& pixelFormat, tcu::TextureFormat textureFormat) |
| { |
| const IVec4 texFormatBits = getEffectiveTextureFormatBitDepth(textureFormat); |
| const IVec4 pixelFormatBits = getPixelFormatCompareDepth(pixelFormat, textureFormat); |
| const IVec4 accurateFmtBits = min(pixelFormatBits, texFormatBits); |
| const IVec4 compareBits = select(accurateFmtBits, IVec4(8), greaterThan(accurateFmtBits, IVec4(0))) - 1; |
| |
| return (IVec4(1) << (8-compareBits)).asUint(); |
| } |
| |
| class TextureSpecCase : public TestCase, public sglr::ContextWrapper |
| { |
| public: |
| TextureSpecCase (Context& context, const char* name, const char* desc); |
| ~TextureSpecCase (void); |
| |
| IterateResult iterate (void); |
| |
| protected: |
| virtual void createTexture (void) = DE_NULL; |
| virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext) = DE_NULL; |
| |
| // Utilities. |
| void renderTex (tcu::Surface& dst, deUint32 program, int width, int height); |
| void readPixels (tcu::Surface& dst, int x, int y, int width, int height); |
| |
| private: |
| TextureSpecCase (const TextureSpecCase& other); |
| TextureSpecCase& operator= (const TextureSpecCase& other); |
| }; |
| |
| TextureSpecCase::TextureSpecCase (Context& context, const char* name, const char* desc) |
| : TestCase(context, name, desc) |
| { |
| } |
| |
| TextureSpecCase::~TextureSpecCase (void) |
| { |
| } |
| |
| TextureSpecCase::IterateResult TextureSpecCase::iterate (void) |
| { |
| glu::RenderContext& renderCtx = TestCase::m_context.getRenderContext(); |
| const tcu::RenderTarget& renderTarget = renderCtx.getRenderTarget(); |
| tcu::TestLog& log = m_testCtx.getLog(); |
| |
| if (renderTarget.getWidth() < VIEWPORT_WIDTH || renderTarget.getHeight() < VIEWPORT_HEIGHT) |
| throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__); |
| |
| // Context size, and viewport for GLES3 |
| de::Random rnd (deStringHash(getName())); |
| int width = deMin32(renderTarget.getWidth(), VIEWPORT_WIDTH); |
| int height = deMin32(renderTarget.getHeight(), VIEWPORT_HEIGHT); |
| int x = rnd.getInt(0, renderTarget.getWidth() - width); |
| int y = rnd.getInt(0, renderTarget.getHeight() - height); |
| |
| // Contexts. |
| sglr::GLContext gles3Context (renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height)); |
| sglr::ReferenceContextBuffers refBuffers (tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), 0 /* depth */, 0 /* stencil */, width, height); |
| sglr::ReferenceContext refContext (sglr::ReferenceContextLimits(renderCtx), refBuffers.getColorbuffer(), refBuffers.getDepthbuffer(), refBuffers.getStencilbuffer()); |
| |
| // Clear color buffer. |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles3Context); |
| glClearColor(0.125f, 0.25f, 0.5f, 1.0f); |
| glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); |
| } |
| |
| // Construct texture using both GLES3 and reference contexts. |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| setContext(ndx ? (sglr::Context*)&refContext : (sglr::Context*)&gles3Context); |
| createTexture(); |
| TCU_CHECK(glGetError() == GL_NO_ERROR); |
| } |
| |
| // Initialize case result to pass. |
| m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); |
| |
| // Disable logging. |
| gles3Context.enableLogging(0); |
| |
| // Verify results. |
| verifyTexture(gles3Context, refContext); |
| |
| return STOP; |
| } |
| |
| void TextureSpecCase::renderTex (tcu::Surface& dst, deUint32 program, int width, int height) |
| { |
| int targetW = getWidth(); |
| int targetH = getHeight(); |
| |
| float w = (float)width / (float)targetW; |
| float h = (float)height / (float)targetH; |
| |
| 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)); |
| |
| // Read pixels back. |
| readPixels(dst, 0, 0, width, height); |
| } |
| |
| void TextureSpecCase::readPixels (tcu::Surface& dst, int x, int y, int width, int height) |
| { |
| dst.setSize(width, height); |
| glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr()); |
| } |
| |
| class Texture2DSpecCase : public TextureSpecCase |
| { |
| public: |
| Texture2DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLevels); |
| ~Texture2DSpecCase (void); |
| |
| protected: |
| virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext); |
| |
| tcu::TextureFormat m_texFormat; |
| tcu::TextureFormatInfo m_texFormatInfo; |
| int m_width; |
| int m_height; |
| int m_numLevels; |
| }; |
| |
| Texture2DSpecCase::Texture2DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLevels) |
| : TextureSpecCase (context, name, desc) |
| , m_texFormat (format) |
| , m_texFormatInfo (tcu::getTextureFormatInfo(format)) |
| , m_width (width) |
| , m_height (height) |
| , m_numLevels (numLevels) |
| { |
| } |
| |
| Texture2DSpecCase::~Texture2DSpecCase (void) |
| { |
| } |
| |
| void Texture2DSpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext) |
| { |
| Texture2DShader shader (DataTypes() << glu::getSampler2DType(m_texFormat), glu::TYPE_FLOAT_VEC4); |
| deUint32 shaderIDgles = gles3Context.createProgram(&shader); |
| deUint32 shaderIDRef = refContext.createProgram(&shader); |
| |
| shader.setTexScaleBias(0, m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias); |
| |
| // Set state. |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context); |
| |
| setContext(ctx); |
| |
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); |
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, m_numLevels-1); |
| } |
| |
| for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++) |
| { |
| int levelW = de::max(1, m_width >> levelNdx); |
| int levelH = de::max(1, m_height >> levelNdx); |
| tcu::Surface reference; |
| tcu::Surface result; |
| |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| tcu::Surface& dst = ndx ? reference : result; |
| sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context); |
| deUint32 shaderID = ndx ? shaderIDRef : shaderIDgles; |
| |
| setContext(ctx); |
| shader.setUniforms(*ctx, shaderID); |
| renderTex(dst, shaderID, levelW, levelH); |
| } |
| |
| UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat); |
| string levelStr = de::toString(levelNdx); |
| string name = string("Level") + levelStr; |
| string desc = string("Level ") + levelStr; |
| bool isOk = tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold, |
| levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR); |
| |
| if (!isOk) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed"); |
| break; |
| } |
| } |
| } |
| |
| class TextureCubeSpecCase : public TextureSpecCase |
| { |
| public: |
| TextureCubeSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int size, int numLevels); |
| ~TextureCubeSpecCase (void); |
| |
| protected: |
| virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext); |
| |
| tcu::TextureFormat m_texFormat; |
| tcu::TextureFormatInfo m_texFormatInfo; |
| int m_size; |
| int m_numLevels; |
| }; |
| |
| TextureCubeSpecCase::TextureCubeSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int size, int numLevels) |
| : TextureSpecCase (context, name, desc) |
| , m_texFormat (format) |
| , m_texFormatInfo (tcu::getTextureFormatInfo(format)) |
| , m_size (size) |
| , m_numLevels (numLevels) |
| { |
| } |
| |
| TextureCubeSpecCase::~TextureCubeSpecCase (void) |
| { |
| } |
| |
| void TextureCubeSpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext) |
| { |
| TextureCubeShader shader (glu::getSamplerCubeType(m_texFormat), glu::TYPE_FLOAT_VEC4); |
| deUint32 shaderIDgles = gles3Context.createProgram(&shader); |
| deUint32 shaderIDRef = refContext.createProgram(&shader); |
| |
| shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias); |
| |
| // Set state. |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context); |
| |
| setContext(ctx); |
| |
| glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); |
| glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, m_numLevels-1); |
| } |
| |
| for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++) |
| { |
| int levelSize = de::max(1, m_size >> levelNdx); |
| bool isOk = true; |
| |
| for (int face = 0; face < tcu::CUBEFACE_LAST; face++) |
| { |
| tcu::Surface reference; |
| tcu::Surface result; |
| |
| if (levelSize <= 2) |
| continue; // Fuzzy compare doesn't work for images this small. |
| |
| shader.setFace((tcu::CubeFace)face); |
| |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| tcu::Surface& dst = ndx ? reference : result; |
| sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context); |
| deUint32 shaderID = ndx ? shaderIDRef : shaderIDgles; |
| |
| setContext(ctx); |
| shader.setUniforms(*ctx, shaderID); |
| renderTex(dst, shaderID, levelSize, levelSize); |
| } |
| |
| const float threshold = 0.02f; |
| string faceStr = de::toString((tcu::CubeFace)face); |
| string levelStr = de::toString(levelNdx); |
| string name = string("Level") + levelStr; |
| string desc = string("Level ") + levelStr + ", face " + faceStr; |
| bool isFaceOk = tcu::fuzzyCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference, result, threshold, |
| levelNdx == 0 ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR); |
| |
| if (!isFaceOk) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed"); |
| isOk = false; |
| break; |
| } |
| } |
| |
| if (!isOk) |
| break; |
| } |
| } |
| |
| class Texture2DArraySpecCase : public TextureSpecCase |
| { |
| public: |
| Texture2DArraySpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLayers, int numLevels); |
| ~Texture2DArraySpecCase (void); |
| |
| protected: |
| virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext); |
| |
| tcu::TextureFormat m_texFormat; |
| tcu::TextureFormatInfo m_texFormatInfo; |
| int m_width; |
| int m_height; |
| int m_numLayers; |
| int m_numLevels; |
| }; |
| |
| Texture2DArraySpecCase::Texture2DArraySpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int numLayers, int numLevels) |
| : TextureSpecCase (context, name, desc) |
| , m_texFormat (format) |
| , m_texFormatInfo (tcu::getTextureFormatInfo(format)) |
| , m_width (width) |
| , m_height (height) |
| , m_numLayers (numLayers) |
| , m_numLevels (numLevels) |
| { |
| } |
| |
| Texture2DArraySpecCase::~Texture2DArraySpecCase (void) |
| { |
| } |
| |
| void Texture2DArraySpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext) |
| { |
| Texture2DArrayShader shader (glu::getSampler2DArrayType(m_texFormat), glu::TYPE_FLOAT_VEC4); |
| deUint32 shaderIDgles = gles3Context.createProgram(&shader); |
| deUint32 shaderIDRef = refContext.createProgram(&shader); |
| |
| shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias); |
| |
| // Set state. |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context); |
| |
| setContext(ctx); |
| |
| glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); |
| glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, m_numLevels-1); |
| } |
| |
| for (int layerNdx = 0; layerNdx < m_numLayers; layerNdx++) |
| { |
| bool layerOk = true; |
| |
| shader.setLayer(layerNdx); |
| |
| for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++) |
| { |
| int levelW = de::max(1, m_width >> levelNdx); |
| int levelH = de::max(1, m_height >> levelNdx); |
| tcu::Surface reference; |
| tcu::Surface result; |
| |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| tcu::Surface& dst = ndx ? reference : result; |
| sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context); |
| deUint32 shaderID = ndx ? shaderIDRef : shaderIDgles; |
| |
| setContext(ctx); |
| shader.setUniforms(*ctx, shaderID); |
| renderTex(dst, shaderID, levelW, levelH); |
| } |
| |
| UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat); |
| string levelStr = de::toString(levelNdx); |
| string layerStr = de::toString(layerNdx); |
| string name = string("Layer") + layerStr + "Level" + levelStr; |
| string desc = string("Layer ") + layerStr + ", Level " + levelStr; |
| bool depthOk = tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold, |
| (levelNdx == 0 && layerNdx == 0) ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR); |
| |
| if (!depthOk) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed"); |
| layerOk = false; |
| break; |
| } |
| } |
| |
| if (!layerOk) |
| break; |
| } |
| } |
| |
| class Texture3DSpecCase : public TextureSpecCase |
| { |
| public: |
| Texture3DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int depth, int numLevels); |
| ~Texture3DSpecCase (void); |
| |
| protected: |
| virtual void verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext); |
| |
| tcu::TextureFormat m_texFormat; |
| tcu::TextureFormatInfo m_texFormatInfo; |
| int m_width; |
| int m_height; |
| int m_depth; |
| int m_numLevels; |
| }; |
| |
| Texture3DSpecCase::Texture3DSpecCase (Context& context, const char* name, const char* desc, const tcu::TextureFormat& format, int width, int height, int depth, int numLevels) |
| : TextureSpecCase (context, name, desc) |
| , m_texFormat (format) |
| , m_texFormatInfo (tcu::getTextureFormatInfo(format)) |
| , m_width (width) |
| , m_height (height) |
| , m_depth (depth) |
| , m_numLevels (numLevels) |
| { |
| } |
| |
| Texture3DSpecCase::~Texture3DSpecCase (void) |
| { |
| } |
| |
| void Texture3DSpecCase::verifyTexture (sglr::GLContext& gles3Context, sglr::ReferenceContext& refContext) |
| { |
| Texture3DShader shader (glu::getSampler3DType(m_texFormat), glu::TYPE_FLOAT_VEC4); |
| deUint32 shaderIDgles = gles3Context.createProgram(&shader); |
| deUint32 shaderIDRef = refContext.createProgram(&shader); |
| |
| shader.setTexScaleBias(m_texFormatInfo.lookupScale, m_texFormatInfo.lookupBias); |
| |
| // Set state. |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context); |
| |
| setContext(ctx); |
| |
| glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); |
| glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); |
| glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, m_numLevels-1); |
| } |
| |
| for (int levelNdx = 0; levelNdx < m_numLevels; levelNdx++) |
| { |
| int levelW = de::max(1, m_width >> levelNdx); |
| int levelH = de::max(1, m_height >> levelNdx); |
| int levelD = de::max(1, m_depth >> levelNdx); |
| bool levelOk = true; |
| |
| for (int depth = 0; depth < levelD; depth++) |
| { |
| tcu::Surface reference; |
| tcu::Surface result; |
| |
| shader.setDepth(((float)depth + 0.5f) / (float)levelD); |
| |
| for (int ndx = 0; ndx < 2; ndx++) |
| { |
| tcu::Surface& dst = ndx ? reference : result; |
| sglr::Context* ctx = ndx ? static_cast<sglr::Context*>(&refContext) : static_cast<sglr::Context*>(&gles3Context); |
| deUint32 shaderID = ndx ? shaderIDRef : shaderIDgles; |
| |
| setContext(ctx); |
| shader.setUniforms(*ctx, shaderID); |
| renderTex(dst, shaderID, levelW, levelH); |
| } |
| |
| UVec4 threshold = computeCompareThreshold(m_context.getRenderTarget().getPixelFormat(), m_texFormat); |
| string levelStr = de::toString(levelNdx); |
| string sliceStr = de::toString(depth); |
| string name = string("Level") + levelStr + "Slice" + sliceStr; |
| string desc = string("Level ") + levelStr + ", Slice " + sliceStr; |
| bool depthOk = tcu::intThresholdCompare(m_testCtx.getLog(), name.c_str(), desc.c_str(), reference.getAccess(), result.getAccess(), threshold, |
| (levelNdx == 0 && depth == 0) ? tcu::COMPARE_LOG_RESULT : tcu::COMPARE_LOG_ON_ERROR); |
| |
| if (!depthOk) |
| { |
| m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed"); |
| levelOk = false; |
| break; |
| } |
| } |
| |
| if (!levelOk) |
| break; |
| } |
| } |
| |
| // Basic TexImage2D() with 2D texture usage |
| class BasicTexImage2DCase : public Texture2DSpecCase |
| { |
| public: |
| // Unsized internal format. |
| BasicTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height)) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| // Sized internal format. |
| BasicTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height)) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(m_format, m_dataType)); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| levelData.setSize(levelW, levelH); |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // Basic TexImage2D() with cubemap usage |
| class BasicTexImageCubeCase : public TextureCubeSpecCase |
| { |
| public: |
| // Unsized formats. |
| BasicTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| // Sized internal formats. |
| BasicTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(m_format, m_dataType)); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| |
| levelData.setSize(levelSize, levelSize); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| { |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // Basic TexImage3D() with 2D array texture usage |
| class BasicTexImage2DArrayCase : public Texture2DArraySpecCase |
| { |
| public: |
| BasicTexImage2DArrayCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLayers) |
| : Texture2DArraySpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLayers, maxLevelCount(width, height)) |
| , m_internalFormat (internalFormat) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| de::Random rnd (deStringHash(getName())); |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType)); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D_ARRAY, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| levelData.setSize(levelW, levelH, m_numLayers); |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexImage3D(GL_TEXTURE_2D_ARRAY, ndx, m_internalFormat, levelW, levelH, m_numLayers, 0, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| }; |
| |
| // Basic TexImage3D() with 3D texture usage |
| class BasicTexImage3DCase : public Texture3DSpecCase |
| { |
| public: |
| BasicTexImage3DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int depth) |
| : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, maxLevelCount(width, height, depth)) |
| , m_internalFormat (internalFormat) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| de::Random rnd (deStringHash(getName())); |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType)); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_3D, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| int levelD = de::max(1, m_depth >> ndx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| levelData.setSize(levelW, levelH, levelD); |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexImage3D(GL_TEXTURE_3D, ndx, m_internalFormat, levelW, levelH, levelD, 0, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| }; |
| |
| // Randomized 2D texture specification using TexImage2D |
| class RandomOrderTexImage2DCase : public Texture2DSpecCase |
| { |
| public: |
| RandomOrderTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height)) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| RandomOrderTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height)) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(m_format, m_dataType)); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| vector<int> levels (m_numLevels); |
| |
| for (int i = 0; i < m_numLevels; i++) |
| levels[i] = i; |
| rnd.shuffle(levels.begin(), levels.end()); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelNdx = levels[ndx]; |
| int levelW = de::max(1, m_width >> levelNdx); |
| int levelH = de::max(1, m_height >> levelNdx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| levelData.setSize(levelW, levelH); |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexImage2D(GL_TEXTURE_2D, levelNdx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // Randomized cubemap texture specification using TexImage2D |
| class RandomOrderTexImageCubeCase : public TextureCubeSpecCase |
| { |
| public: |
| RandomOrderTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1) |
| , m_internalFormat (GL_NONE) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| RandomOrderTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(m_format, m_dataType)); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| // Level-face pairs. |
| vector<pair<int, tcu::CubeFace> > images (m_numLevels*6); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| for (int face = 0; face < tcu::CUBEFACE_LAST; face++) |
| images[ndx*6 + face] = std::make_pair(ndx, (tcu::CubeFace)face); |
| |
| rnd.shuffle(images.begin(), images.end()); |
| |
| for (int ndx = 0; ndx < (int)images.size(); ndx++) |
| { |
| int levelNdx = images[ndx].first; |
| tcu::CubeFace face = images[ndx].second; |
| int levelSize = de::max(1, m_size >> levelNdx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| levelData.setSize(levelSize, levelSize); |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexImage2D(s_cubeMapFaces[face], levelNdx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // TexImage2D() unpack alignment case. |
| class TexImage2DAlignCase : public Texture2DSpecCase |
| { |
| public: |
| TexImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height, int numLevels, int alignment) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, numLevels) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| , m_alignment (alignment) |
| { |
| } |
| |
| TexImage2DAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLevels, int alignment) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLevels) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| , m_alignment (alignment) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| vector<deUint8> data; |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin; |
| Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin; |
| int rowPitch = deAlign32(levelW*m_texFormat.getPixelSize(), m_alignment); |
| int cellSize = de::max(1, de::min(levelW >> 2, levelH >> 2)); |
| |
| data.resize(rowPitch*levelH); |
| tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, levelW, levelH, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB); |
| |
| glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, &data[0]); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| int m_alignment; |
| }; |
| |
| // TexImage2D() unpack alignment case. |
| class TexImageCubeAlignCase : public TextureCubeSpecCase |
| { |
| public: |
| TexImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size, int numLevels, int alignment) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, numLevels) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| , m_alignment (alignment) |
| { |
| } |
| |
| TexImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int numLevels, int alignment) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLevels) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| , m_alignment (alignment) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| vector<deUint8> data; |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| int rowPitch = deAlign32(m_texFormat.getPixelSize()*levelSize, m_alignment); |
| Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin; |
| Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*(m_texFormatInfo.valueMax-m_texFormatInfo.valueMin) + m_texFormatInfo.valueMin; |
| int cellSize = de::max(1, levelSize >> 2); |
| |
| data.resize(rowPitch*levelSize); |
| tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, levelSize, levelSize, 1, rowPitch, 0, &data[0]), cellSize, colorA, colorB); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, &data[0]); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| int m_alignment; |
| }; |
| |
| // TexImage2D() unpack parameters case. |
| class TexImage2DParamsCase : public Texture2DSpecCase |
| { |
| public: |
| TexImage2DParamsCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int rowLength, int skipRows, int skipPixels, int alignment) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1) |
| , m_internalFormat (internalFormat) |
| , m_rowLength (rowLength) |
| , m_skipRows (skipRows) |
| , m_skipPixels (skipPixels) |
| , m_alignment (alignment) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| int pixelSize = m_texFormat.getPixelSize(); |
| int rowLength = m_rowLength > 0 ? m_rowLength : m_width; |
| int rowPitch = deAlign32(rowLength*pixelSize, m_alignment); |
| deUint32 tex = 0; |
| vector<deUint8> data; |
| |
| DE_ASSERT(m_numLevels == 1); |
| |
| // Fill data with grid. |
| data.resize(pixelSize * m_skipPixels + rowPitch * (m_height + m_skipRows)); |
| { |
| Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin; |
| Vec4 cBias = m_texFormatInfo.valueMin; |
| Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias; |
| Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias; |
| |
| tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB); |
| } |
| |
| glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength); |
| glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows); |
| glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, &data[0]); |
| } |
| |
| deUint32 m_internalFormat; |
| int m_rowLength; |
| int m_skipRows; |
| int m_skipPixels; |
| int m_alignment; |
| }; |
| |
| // TexImage3D() unpack parameters case. |
| class TexImage3DParamsCase : public Texture3DSpecCase |
| { |
| public: |
| TexImage3DParamsCase (Context& context, |
| const char* name, |
| const char* desc, |
| deUint32 internalFormat, |
| int width, |
| int height, |
| int depth, |
| int imageHeight, |
| int rowLength, |
| int skipImages, |
| int skipRows, |
| int skipPixels, |
| int alignment) |
| : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1) |
| , m_internalFormat (internalFormat) |
| , m_imageHeight (imageHeight) |
| , m_rowLength (rowLength) |
| , m_skipImages (skipImages) |
| , m_skipRows (skipRows) |
| , m_skipPixels (skipPixels) |
| , m_alignment (alignment) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| int pixelSize = m_texFormat.getPixelSize(); |
| int rowLength = m_rowLength > 0 ? m_rowLength : m_width; |
| int rowPitch = deAlign32(rowLength*pixelSize, m_alignment); |
| int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_height; |
| int slicePitch = imageHeight*rowPitch; |
| deUint32 tex = 0; |
| vector<deUint8> data; |
| |
| DE_ASSERT(m_numLevels == 1); |
| |
| // Fill data with grid. |
| data.resize(pixelSize * m_skipPixels + rowPitch * m_skipRows + slicePitch * (m_skipImages + m_depth)); |
| { |
| Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin; |
| Vec4 cBias = m_texFormatInfo.valueMin; |
| Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias; |
| Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias; |
| |
| 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); |
| } |
| |
| glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight); |
| glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength); |
| glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages); |
| glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows); |
| glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_3D, tex); |
| glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, &data[0]); |
| } |
| |
| deUint32 m_internalFormat; |
| int m_imageHeight; |
| int m_rowLength; |
| int m_skipImages; |
| int m_skipRows; |
| int m_skipPixels; |
| int m_alignment; |
| }; |
| |
| // Basic TexSubImage2D() with 2D texture usage |
| class BasicTexSubImage2DCase : public Texture2DSpecCase |
| { |
| public: |
| BasicTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height)) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| BasicTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height)) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| tcu::TextureLevel data (m_texFormat); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| // First specify full texture. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| data.setSize(levelW, levelH); |
| tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax); |
| |
| glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr()); |
| } |
| |
| // Re-specify parts of each level. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| |
| int w = rnd.getInt(1, levelW); |
| int h = rnd.getInt(1, levelH); |
| int x = rnd.getInt(0, levelW-w); |
| int y = rnd.getInt(0, levelH-h); |
| |
| Vec4 colorA = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 colorB = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| int cellSize = rnd.getInt(2, 16); |
| |
| data.setSize(w, h); |
| tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB); |
| |
| glTexSubImage2D(GL_TEXTURE_2D, ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // Basic TexSubImage2D() with cubemap usage |
| class BasicTexSubImageCubeCase : public TextureCubeSpecCase |
| { |
| public: |
| BasicTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| BasicTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| tcu::TextureLevel data (m_texFormat); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| |
| data.setSize(levelSize, levelSize); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| { |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax); |
| |
| glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, data.getAccess().getDataPtr()); |
| } |
| } |
| |
| // Re-specify parts of each face and level. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| { |
| int w = rnd.getInt(1, levelSize); |
| int h = rnd.getInt(1, levelSize); |
| int x = rnd.getInt(0, levelSize-w); |
| int y = rnd.getInt(0, levelSize-h); |
| |
| Vec4 colorA = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 colorB = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| int cellSize = rnd.getInt(2, 16); |
| |
| data.setSize(w, h); |
| tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB); |
| |
| glTexSubImage2D(s_cubeMapFaces[face], ndx, x, y, w, h, m_format, m_dataType, data.getAccess().getDataPtr()); |
| } |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // TexSubImage2D() unpack parameters case. |
| class TexSubImage2DParamsCase : public Texture2DSpecCase |
| { |
| public: |
| TexSubImage2DParamsCase (Context& context, |
| const char* name, |
| const char* desc, |
| deUint32 internalFormat, |
| int width, |
| int height, |
| int subX, |
| int subY, |
| int subW, |
| int subH, |
| int rowLength, |
| int skipRows, |
| int skipPixels, |
| int alignment) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1) |
| , m_internalFormat (internalFormat) |
| , m_subX (subX) |
| , m_subY (subY) |
| , m_subW (subW) |
| , m_subH (subH) |
| , m_rowLength (rowLength) |
| , m_skipRows (skipRows) |
| , m_skipPixels (skipPixels) |
| , m_alignment (alignment) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| int pixelSize = m_texFormat.getPixelSize(); |
| deUint32 tex = 0; |
| vector<deUint8> data; |
| |
| DE_ASSERT(m_numLevels == 1); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| |
| // First fill texture with gradient. |
| data.resize(deAlign32(m_width*pixelSize, 4)*m_height); |
| 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); |
| glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, &data[0]); |
| |
| // Fill data with grid. |
| { |
| int rowLength = m_rowLength > 0 ? m_rowLength : m_subW; |
| int rowPitch = deAlign32(rowLength*pixelSize, m_alignment); |
| int height = m_subH + m_skipRows; |
| Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin; |
| Vec4 cBias = m_texFormatInfo.valueMin; |
| Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias; |
| Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias; |
| |
| data.resize(rowPitch*height); |
| tcu::fillWithGrid(tcu::PixelBufferAccess(m_texFormat, m_subW, m_subH, 1, rowPitch, 0, &data[0] + m_skipRows*rowPitch + m_skipPixels*pixelSize), 4, colorA, colorB); |
| } |
| |
| glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength); |
| glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows); |
| glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, transferFmt.format, transferFmt.dataType, &data[0]); |
| } |
| |
| deUint32 m_internalFormat; |
| int m_subX; |
| int m_subY; |
| int m_subW; |
| int m_subH; |
| int m_rowLength; |
| int m_skipRows; |
| int m_skipPixels; |
| int m_alignment; |
| }; |
| |
| // Basic TexSubImage3D() with 3D texture usage |
| class BasicTexSubImage3DCase : public Texture3DSpecCase |
| { |
| public: |
| BasicTexSubImage3DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int depth) |
| : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, maxLevelCount(width, height, depth)) |
| , m_internalFormat (internalFormat) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| tcu::TextureLevel data (m_texFormat); |
| de::Random rnd (deStringHash(getName())); |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_3D, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| // First specify full texture. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| int levelD = de::max(1, m_depth >> ndx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| data.setSize(levelW, levelH, levelD); |
| tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax); |
| |
| glTexImage3D(GL_TEXTURE_3D, ndx, m_internalFormat, levelW, levelH, levelD, 0, transferFmt.format, transferFmt.dataType, data.getAccess().getDataPtr()); |
| } |
| |
| // Re-specify parts of each level. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| int levelD = de::max(1, m_depth >> ndx); |
| |
| int w = rnd.getInt(1, levelW); |
| int h = rnd.getInt(1, levelH); |
| int d = rnd.getInt(1, levelD); |
| int x = rnd.getInt(0, levelW-w); |
| int y = rnd.getInt(0, levelH-h); |
| int z = rnd.getInt(0, levelD-d); |
| |
| Vec4 colorA = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 colorB = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| int cellSize = rnd.getInt(2, 16); |
| |
| data.setSize(w, h, d); |
| tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB); |
| |
| glTexSubImage3D(GL_TEXTURE_3D, ndx, x, y, z, w, h, d, transferFmt.format, transferFmt.dataType, data.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| }; |
| |
| // TexSubImage2D() to texture initialized with empty data |
| class TexSubImage2DEmptyTexCase : public Texture2DSpecCase |
| { |
| public: |
| TexSubImage2DEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height)) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| TexSubImage2DEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, maxLevelCount(width, height)) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| tcu::TextureLevel data (m_texFormat); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| // First allocate storage for each level. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| |
| glTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, levelW, levelH, 0, m_format, m_dataType, DE_NULL); |
| } |
| |
| // Specify pixel data to all levels using glTexSubImage2D() |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| data.setSize(levelW, levelH); |
| tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax); |
| |
| glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, m_format, m_dataType, data.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // TexSubImage2D() to empty cubemap texture |
| class TexSubImageCubeEmptyTexCase : public TextureCubeSpecCase |
| { |
| public: |
| TexSubImageCubeEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| TexSubImageCubeEmptyTexCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, deLog2Floor32(size)+1) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| tcu::TextureLevel data (m_texFormat); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| // Specify storage for each level. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| glTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, levelSize, levelSize, 0, m_format, m_dataType, DE_NULL); |
| } |
| |
| // Specify data using glTexSubImage2D() |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| |
| data.setSize(levelSize, levelSize); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| { |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| tcu::fillWithComponentGradients(data.getAccess(), gMin, gMax); |
| |
| glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelSize, levelSize, m_format, m_dataType, data.getAccess().getDataPtr()); |
| } |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // TexSubImage2D() unpack alignment with 2D texture |
| class TexSubImage2DAlignCase : public Texture2DSpecCase |
| { |
| public: |
| 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) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, 1) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| , m_subX (subX) |
| , m_subY (subY) |
| , m_subW (subW) |
| , m_subH (subH) |
| , m_alignment (alignment) |
| { |
| } |
| |
| 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) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| , m_subX (subX) |
| , m_subY (subY) |
| , m_subW (subW) |
| , m_subH (subH) |
| , m_alignment (alignment) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| vector<deUint8> data; |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| |
| // Specify base level. |
| data.resize(m_texFormat.getPixelSize()*m_width*m_height); |
| tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, 1, &data[0]), Vec4(0.0f), Vec4(1.0f)); |
| |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, m_format, m_dataType, &data[0]); |
| |
| // Re-specify subrectangle. |
| int rowPitch = deAlign32(m_texFormat.getPixelSize()*m_subW, m_alignment); |
| data.resize(rowPitch*m_subH); |
| 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)); |
| |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| glTexSubImage2D(GL_TEXTURE_2D, 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]); |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| int m_subX; |
| int m_subY; |
| int m_subW; |
| int m_subH; |
| int m_alignment; |
| }; |
| |
| // TexSubImage2D() unpack alignment with cubemap texture |
| class TexSubImageCubeAlignCase : public TextureCubeSpecCase |
| { |
| public: |
| 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) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, 1) |
| , m_internalFormat (format) |
| , m_format (format) |
| , m_dataType (dataType) |
| , m_subX (subX) |
| , m_subY (subY) |
| , m_subW (subW) |
| , m_subH (subH) |
| , m_alignment (alignment) |
| { |
| } |
| |
| TexSubImageCubeAlignCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int subX, int subY, int subW, int subH, int alignment) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1) |
| , m_internalFormat (internalFormat) |
| , m_format (GL_NONE) |
| , m_dataType (GL_NONE) |
| , m_subX (subX) |
| , m_subY (subY) |
| , m_subW (subW) |
| , m_subH (subH) |
| , m_alignment (alignment) |
| { |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| m_format = fmt.format; |
| m_dataType = fmt.dataType; |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| vector<deUint8> data; |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| |
| // Specify base level. |
| data.resize(m_texFormat.getPixelSize()*m_size*m_size); |
| tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_size, m_size, 1, &data[0]), Vec4(0.0f), Vec4(1.0f)); |
| |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| for (int face = 0; face < tcu::CUBEFACE_LAST; face++) |
| glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, m_format, m_dataType, &data[0]); |
| |
| // Re-specify subrectangle. |
| int rowPitch = deAlign32(m_texFormat.getPixelSize()*m_subW, m_alignment); |
| data.resize(rowPitch*m_subH); |
| 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)); |
| |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| for (int face = 0; face < tcu::CUBEFACE_LAST; face++) |
| glTexSubImage2D(s_cubeMapFaces[face], 0, m_subX, m_subY, m_subW, m_subH, m_format, m_dataType, &data[0]); |
| } |
| |
| deUint32 m_internalFormat; |
| deUint32 m_format; |
| deUint32 m_dataType; |
| int m_subX; |
| int m_subY; |
| int m_subW; |
| int m_subH; |
| int m_alignment; |
| }; |
| |
| // TexSubImage3D() unpack parameters case. |
| class TexSubImage3DParamsCase : public Texture3DSpecCase |
| { |
| public: |
| TexSubImage3DParamsCase (Context& context, |
| const char* name, |
| const char* desc, |
| deUint32 internalFormat, |
| int width, |
| int height, |
| int depth, |
| int subX, |
| int subY, |
| int subZ, |
| int subW, |
| int subH, |
| int subD, |
| int imageHeight, |
| int rowLength, |
| int skipImages, |
| int skipRows, |
| int skipPixels, |
| int alignment) |
| : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1) |
| , m_internalFormat (internalFormat) |
| , m_subX (subX) |
| , m_subY (subY) |
| , m_subZ (subZ) |
| , m_subW (subW) |
| , m_subH (subH) |
| , m_subD (subD) |
| , m_imageHeight (imageHeight) |
| , m_rowLength (rowLength) |
| , m_skipImages (skipImages) |
| , m_skipRows (skipRows) |
| , m_skipPixels (skipPixels) |
| , m_alignment (alignment) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| int pixelSize = m_texFormat.getPixelSize(); |
| deUint32 tex = 0; |
| vector<deUint8> data; |
| |
| DE_ASSERT(m_numLevels == 1); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_3D, tex); |
| |
| // Fill with gradient. |
| { |
| int rowPitch = deAlign32(pixelSize*m_width, 4); |
| int slicePitch = rowPitch*m_height; |
| |
| data.resize(slicePitch*m_depth); |
| tcu::fillWithComponentGradients(tcu::PixelBufferAccess(m_texFormat, m_width, m_height, m_depth, rowPitch, slicePitch, &data[0]), m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| } |
| |
| glTexImage3D(GL_TEXTURE_3D, 0, m_internalFormat, m_width, m_height, m_depth, 0, transferFmt.format, transferFmt.dataType, &data[0]); |
| |
| // Fill data with grid. |
| { |
| int rowLength = m_rowLength > 0 ? m_rowLength : m_subW; |
| int rowPitch = deAlign32(rowLength*pixelSize, m_alignment); |
| int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_subH; |
| int slicePitch = imageHeight*rowPitch; |
| Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin; |
| Vec4 cBias = m_texFormatInfo.valueMin; |
| Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias; |
| Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias; |
| |
| data.resize(slicePitch*(m_depth+m_skipImages)); |
| 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); |
| } |
| |
| glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight); |
| glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength); |
| glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages); |
| glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows); |
| glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| glTexSubImage3D(GL_TEXTURE_3D, 0, m_subX, m_subY, m_subZ, m_subW, m_subH, m_subD, transferFmt.format, transferFmt.dataType, &data[0]); |
| } |
| |
| deUint32 m_internalFormat; |
| int m_subX; |
| int m_subY; |
| int m_subZ; |
| int m_subW; |
| int m_subH; |
| int m_subD; |
| int m_imageHeight; |
| int m_rowLength; |
| int m_skipImages; |
| int m_skipRows; |
| int m_skipPixels; |
| int m_alignment; |
| }; |
| |
| // Basic CopyTexImage2D() with 2D texture usage |
| class BasicCopyTexImage2DCase : public Texture2DSpecCase |
| { |
| public: |
| BasicCopyTexImage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(internalFormat, GL_UNSIGNED_BYTE), width, height, maxLevelCount(width, height)) |
| , m_internalFormat (internalFormat) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget(); |
| bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0; |
| bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0; |
| tcu::TextureFormat fmt = mapGLUnsizedInternalFormat(m_internalFormat); |
| bool texHasRGB = fmt.order != tcu::TextureFormat::A; |
| bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A; |
| deUint32 tex = 0; |
| de::Random rnd (deStringHash(getName())); |
| GradientShader shader (glu::TYPE_FLOAT_VEC4); |
| deUint32 shaderID = getCurrentContext()->createProgram(&shader); |
| |
| if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha)) |
| throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__); |
| |
| // Fill render target with gradient. |
| shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f)); |
| sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f)); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| int x = rnd.getInt(0, getWidth() - levelW); |
| int y = rnd.getInt(0, getHeight() - levelH); |
| |
| glCopyTexImage2D(GL_TEXTURE_2D, ndx, m_internalFormat, x, y, levelW, levelH, 0); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| }; |
| |
| // Basic CopyTexImage2D() with cubemap usage |
| class BasicCopyTexImageCubeCase : public TextureCubeSpecCase |
| { |
| public: |
| BasicCopyTexImageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(internalFormat, GL_UNSIGNED_BYTE), size, deLog2Floor32(size)+1) |
| , m_internalFormat (internalFormat) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget(); |
| bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0; |
| bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0; |
| tcu::TextureFormat fmt = mapGLUnsizedInternalFormat(m_internalFormat); |
| bool texHasRGB = fmt.order != tcu::TextureFormat::A; |
| bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A; |
| deUint32 tex = 0; |
| de::Random rnd (deStringHash(getName())); |
| GradientShader shader (glu::TYPE_FLOAT_VEC4); |
| deUint32 shaderID = getCurrentContext()->createProgram(&shader); |
| |
| if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha)) |
| throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__); |
| |
| // Fill render target with gradient. |
| shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f)); |
| sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f)); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| { |
| int x = rnd.getInt(0, getWidth() - levelSize); |
| int y = rnd.getInt(0, getHeight() - levelSize); |
| |
| glCopyTexImage2D(s_cubeMapFaces[face], ndx, m_internalFormat, x, y, levelSize, levelSize, 0); |
| } |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| }; |
| |
| // Basic CopyTexSubImage2D() with 2D texture usage |
| class BasicCopyTexSubImage2DCase : public Texture2DSpecCase |
| { |
| public: |
| BasicCopyTexSubImage2DCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int width, int height) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), width, height, maxLevelCount(width, height)) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget(); |
| bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0; |
| bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0; |
| tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType); |
| bool texHasRGB = fmt.order != tcu::TextureFormat::A; |
| bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A; |
| deUint32 tex = 0; |
| tcu::TextureLevel data (fmt); |
| de::Random rnd (deStringHash(getName())); |
| GradientShader shader (glu::TYPE_FLOAT_VEC4); |
| deUint32 shaderID = getCurrentContext()->createProgram(&shader); |
| |
| if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha)) |
| throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| // First specify full texture. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| |
| Vec4 colorA = randomVector<4>(rnd); |
| Vec4 colorB = randomVector<4>(rnd); |
| int cellSize = rnd.getInt(2, 16); |
| |
| data.setSize(levelW, levelH); |
| tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB); |
| |
| glTexImage2D(GL_TEXTURE_2D, ndx, m_format, levelW, levelH, 0, m_format, m_dataType, data.getAccess().getDataPtr()); |
| } |
| |
| // Fill render target with gradient. |
| shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f)); |
| sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f)); |
| |
| // Re-specify parts of each level. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| |
| int w = rnd.getInt(1, levelW); |
| int h = rnd.getInt(1, levelH); |
| int xo = rnd.getInt(0, levelW-w); |
| int yo = rnd.getInt(0, levelH-h); |
| |
| int x = rnd.getInt(0, getWidth() - w); |
| int y = rnd.getInt(0, getHeight() - h); |
| |
| glCopyTexSubImage2D(GL_TEXTURE_2D, ndx, xo, yo, x, y, w, h); |
| } |
| } |
| |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // Basic CopyTexSubImage2D() with cubemap usage |
| class BasicCopyTexSubImageCubeCase : public TextureCubeSpecCase |
| { |
| public: |
| BasicCopyTexSubImageCubeCase (Context& context, const char* name, const char* desc, deUint32 format, deUint32 dataType, int size) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLTransferFormat(format, dataType), size, deLog2Floor32(size)+1) |
| , m_format (format) |
| , m_dataType (dataType) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| const tcu::RenderTarget& renderTarget = TestCase::m_context.getRenderContext().getRenderTarget(); |
| bool targetHasRGB = renderTarget.getPixelFormat().redBits > 0 && renderTarget.getPixelFormat().greenBits > 0 && renderTarget.getPixelFormat().blueBits > 0; |
| bool targetHasAlpha = renderTarget.getPixelFormat().alphaBits > 0; |
| tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType); |
| bool texHasRGB = fmt.order != tcu::TextureFormat::A; |
| bool texHasAlpha = fmt.order == tcu::TextureFormat::RGBA || fmt.order == tcu::TextureFormat::LA || fmt.order == tcu::TextureFormat::A; |
| deUint32 tex = 0; |
| tcu::TextureLevel data (fmt); |
| de::Random rnd (deStringHash(getName())); |
| GradientShader shader (glu::TYPE_FLOAT_VEC4); |
| deUint32 shaderID = getCurrentContext()->createProgram(&shader); |
| |
| if ((texHasRGB && !targetHasRGB) || (texHasAlpha && !targetHasAlpha)) |
| throw tcu::NotSupportedError("Copying from current framebuffer is not supported", "", __FILE__, __LINE__); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| |
| data.setSize(levelSize, levelSize); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| { |
| Vec4 colorA = randomVector<4>(rnd); |
| Vec4 colorB = randomVector<4>(rnd); |
| int cellSize = rnd.getInt(2, 16); |
| |
| tcu::fillWithGrid(data.getAccess(), cellSize, colorA, colorB); |
| glTexImage2D(s_cubeMapFaces[face], ndx, m_format, levelSize, levelSize, 0, m_format, m_dataType, data.getAccess().getDataPtr()); |
| } |
| } |
| |
| // Fill render target with gradient. |
| shader.setGradient(*getCurrentContext(), shaderID, Vec4(0.0f), Vec4(1.0f)); |
| sglr::drawQuad(*getCurrentContext(), shaderID, tcu::Vec3(-1.0f, -1.0f, 0.0f), tcu::Vec3(1.0f, 1.0f, 0.0f)); |
| |
| // Re-specify parts of each face and level. |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| { |
| int w = rnd.getInt(1, levelSize); |
| int h = rnd.getInt(1, levelSize); |
| int xo = rnd.getInt(0, levelSize-w); |
| int yo = rnd.getInt(0, levelSize-h); |
| |
| int x = rnd.getInt(0, getWidth() - w); |
| int y = rnd.getInt(0, getHeight() - h); |
| |
| glCopyTexSubImage2D(s_cubeMapFaces[face], ndx, xo, yo, x, y, w, h); |
| } |
| } |
| } |
| |
| deUint32 m_format; |
| deUint32 m_dataType; |
| }; |
| |
| // Basic glTexStorage2D() with 2D texture usage |
| class BasicTexStorage2DCase : public Texture2DSpecCase |
| { |
| public: |
| BasicTexStorage2DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLevels) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLevels) |
| , m_internalFormat (internalFormat) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| tcu::TextureFormat fmt = glu::mapGLInternalFormat(m_internalFormat); |
| glu::TransferFormat transferFmt = glu::getTransferFormat(fmt); |
| deUint32 tex = 0; |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType)); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| glTexStorage2D(GL_TEXTURE_2D, m_numLevels, m_internalFormat, m_width, m_height); |
| |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| levelData.setSize(levelW, levelH); |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexSubImage2D(GL_TEXTURE_2D, ndx, 0, 0, levelW, levelH, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| }; |
| |
| // Basic glTexStorage2D() with cubemap usage |
| class BasicTexStorageCubeCase : public TextureCubeSpecCase |
| { |
| public: |
| BasicTexStorageCubeCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int size, int numLevels) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, numLevels) |
| , m_internalFormat (internalFormat) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| tcu::TextureFormat fmt = glu::mapGLInternalFormat(m_internalFormat); |
| glu::TransferFormat transferFmt = glu::getTransferFormat(fmt); |
| deUint32 tex = 0; |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType)); |
| de::Random rnd (deStringHash(getName())); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| glTexStorage2D(GL_TEXTURE_CUBE_MAP, m_numLevels, m_internalFormat, m_size, m_size); |
| |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelSize = de::max(1, m_size >> ndx); |
| |
| levelData.setSize(levelSize, levelSize); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| { |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexSubImage2D(s_cubeMapFaces[face], ndx, 0, 0, levelSize, levelSize, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| }; |
| |
| // Basic glTexStorage3D() with 2D array texture usage |
| class BasicTexStorage2DArrayCase : public Texture2DArraySpecCase |
| { |
| public: |
| BasicTexStorage2DArrayCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int numLayers, int numLevels) |
| : Texture2DArraySpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, numLayers, numLevels) |
| , m_internalFormat (internalFormat) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| de::Random rnd (deStringHash(getName())); |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType)); |
| |
| glGenTextures (1, &tex); |
| glBindTexture (GL_TEXTURE_2D_ARRAY, tex); |
| glTexStorage3D (GL_TEXTURE_2D_ARRAY, m_numLevels, m_internalFormat, m_width, m_height, m_numLayers); |
| |
| glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| levelData.setSize(levelW, levelH, m_numLayers); |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexSubImage3D(GL_TEXTURE_2D_ARRAY, ndx, 0, 0, 0, levelW, levelH, m_numLayers, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| }; |
| |
| // Basic TexStorage3D() with 3D texture usage |
| class BasicTexStorage3DCase : public Texture3DSpecCase |
| { |
| public: |
| BasicTexStorage3DCase (Context& context, const char* name, const char* desc, deUint32 internalFormat, int width, int height, int depth, int numLevels) |
| : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, numLevels) |
| , m_internalFormat (internalFormat) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| deUint32 tex = 0; |
| de::Random rnd (deStringHash(getName())); |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| tcu::TextureLevel levelData (glu::mapGLTransferFormat(transferFmt.format, transferFmt.dataType)); |
| |
| glGenTextures (1, &tex); |
| glBindTexture (GL_TEXTURE_3D, tex); |
| glTexStorage3D (GL_TEXTURE_3D, m_numLevels, m_internalFormat, m_width, m_height, m_depth); |
| |
| glPixelStorei (GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int ndx = 0; ndx < m_numLevels; ndx++) |
| { |
| int levelW = de::max(1, m_width >> ndx); |
| int levelH = de::max(1, m_height >> ndx); |
| int levelD = de::max(1, m_depth >> ndx); |
| Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| levelData.setSize(levelW, levelH, levelD); |
| tcu::fillWithComponentGradients(levelData.getAccess(), gMin, gMax); |
| |
| glTexSubImage3D(GL_TEXTURE_3D, ndx, 0, 0, 0, levelW, levelH, levelD, transferFmt.format, transferFmt.dataType, levelData.getAccess().getDataPtr()); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| }; |
| |
| // Pixel buffer object cases. |
| |
| // TexImage2D() from pixel buffer object. |
| class TexImage2DBufferCase : public Texture2DSpecCase |
| { |
| public: |
| TexImage2DBufferCase (Context& context, |
| const char* name, |
| const char* desc, |
| deUint32 internalFormat, |
| int width, |
| int height, |
| int rowLength, |
| int skipRows, |
| int skipPixels, |
| int alignment, |
| int offset) |
| : Texture2DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, 1) |
| , m_internalFormat (internalFormat) |
| , m_rowLength (rowLength) |
| , m_skipRows (skipRows) |
| , m_skipPixels (skipPixels) |
| , m_alignment (alignment) |
| , m_offset (offset) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| int pixelSize = m_texFormat.getPixelSize(); |
| int rowLength = m_rowLength > 0 ? m_rowLength : m_width + m_skipPixels; |
| int rowPitch = deAlign32(rowLength*pixelSize, m_alignment); |
| int height = m_height + m_skipRows; |
| deUint32 buf = 0; |
| deUint32 tex = 0; |
| vector<deUint8> data; |
| |
| DE_ASSERT(m_numLevels == 1); |
| |
| // Fill data with grid. |
| data.resize(rowPitch*height + m_offset); |
| { |
| Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin; |
| Vec4 cBias = m_texFormatInfo.valueMin; |
| Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias; |
| Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias; |
| |
| 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); |
| } |
| |
| // Create buffer and upload. |
| glGenBuffers(1, &buf); |
| glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf); |
| glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW); |
| |
| glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength); |
| glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows); |
| glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D, tex); |
| glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_width, m_height, 0, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset); |
| } |
| |
| deUint32 m_internalFormat; |
| int m_rowLength; |
| int m_skipRows; |
| int m_skipPixels; |
| int m_alignment; |
| int m_offset; |
| }; |
| |
| // TexImage2D() cubemap from pixel buffer object case |
| class TexImageCubeBufferCase : public TextureCubeSpecCase |
| { |
| public: |
| TexImageCubeBufferCase (Context& context, |
| const char* name, |
| const char* desc, |
| deUint32 internalFormat, |
| int size, |
| int rowLength, |
| int skipRows, |
| int skipPixels, |
| int alignment, |
| int offset) |
| : TextureCubeSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), size, 1) |
| , m_internalFormat (internalFormat) |
| , m_rowLength (rowLength) |
| , m_skipRows (skipRows) |
| , m_skipPixels (skipPixels) |
| , m_alignment (alignment) |
| , m_offset (offset) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| de::Random rnd (deStringHash(getName())); |
| deUint32 tex = 0; |
| glu::TransferFormat fmt = glu::getTransferFormat(m_texFormat); |
| const int pixelSize = m_texFormat.getPixelSize(); |
| const int rowLength = m_rowLength > 0 ? m_rowLength : m_size + m_skipPixels; |
| const int rowPitch = deAlign32(rowLength*pixelSize, m_alignment); |
| const int height = m_size + m_skipRows; |
| vector<vector<deUint8> > data (DE_LENGTH_OF_ARRAY(s_cubeMapFaces)); |
| |
| DE_ASSERT(m_numLevels == 1); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_CUBE_MAP, tex); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| |
| for (int face = 0; face < DE_LENGTH_OF_ARRAY(s_cubeMapFaces); face++) |
| { |
| deUint32 buf = 0; |
| |
| { |
| const Vec4 gMin = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| const Vec4 gMax = randomVector<4>(rnd, m_texFormatInfo.valueMin, m_texFormatInfo.valueMax); |
| |
| data[face].resize(rowPitch*height + m_offset); |
| 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); |
| } |
| |
| // Create buffer and upload. |
| glGenBuffers(1, &buf); |
| glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf); |
| glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data[face].size(), &data[face][0], GL_STATIC_DRAW); |
| |
| glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength); |
| glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows); |
| glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| |
| glTexImage2D(s_cubeMapFaces[face], 0, m_internalFormat, m_size, m_size, 0, fmt.format, fmt.dataType, (const void*)(deUintptr)m_offset); |
| } |
| } |
| |
| deUint32 m_internalFormat; |
| int m_rowLength; |
| int m_skipRows; |
| int m_skipPixels; |
| int m_alignment; |
| int m_offset; |
| }; |
| |
| // TexImage3D() 2D array from pixel buffer object. |
| class TexImage2DArrayBufferCase : public Texture2DArraySpecCase |
| { |
| public: |
| TexImage2DArrayBufferCase (Context& context, |
| const char* name, |
| const char* desc, |
| deUint32 internalFormat, |
| int width, |
| int height, |
| int depth, |
| int imageHeight, |
| int rowLength, |
| int skipImages, |
| int skipRows, |
| int skipPixels, |
| int alignment, |
| int offset) |
| : Texture2DArraySpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1) |
| , m_internalFormat (internalFormat) |
| , m_imageHeight (imageHeight) |
| , m_rowLength (rowLength) |
| , m_skipImages (skipImages) |
| , m_skipRows (skipRows) |
| , m_skipPixels (skipPixels) |
| , m_alignment (alignment) |
| , m_offset (offset) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| int pixelSize = m_texFormat.getPixelSize(); |
| int rowLength = m_rowLength > 0 ? m_rowLength : m_width; |
| int rowPitch = deAlign32(rowLength*pixelSize, m_alignment); |
| int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_height; |
| int slicePitch = imageHeight*rowPitch; |
| deUint32 tex = 0; |
| deUint32 buf = 0; |
| vector<deUint8> data; |
| |
| DE_ASSERT(m_numLevels == 1); |
| |
| // Fill data with grid. |
| data.resize(slicePitch*(m_numLayers+m_skipImages) + m_offset); |
| { |
| Vec4 cScale = m_texFormatInfo.valueMax-m_texFormatInfo.valueMin; |
| Vec4 cBias = m_texFormatInfo.valueMin; |
| Vec4 colorA = Vec4(1.0f, 0.0f, 0.0f, 1.0f)*cScale + cBias; |
| Vec4 colorB = Vec4(0.0f, 1.0f, 0.0f, 1.0f)*cScale + cBias; |
| |
| 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); |
| } |
| |
| glGenBuffers(1, &buf); |
| glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf); |
| glBufferData(GL_PIXEL_UNPACK_BUFFER, (int)data.size(), &data[0], GL_STATIC_DRAW); |
| |
| glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_imageHeight); |
| glPixelStorei(GL_UNPACK_ROW_LENGTH, m_rowLength); |
| glPixelStorei(GL_UNPACK_SKIP_IMAGES, m_skipImages); |
| glPixelStorei(GL_UNPACK_SKIP_ROWS, m_skipRows); |
| glPixelStorei(GL_UNPACK_SKIP_PIXELS, m_skipPixels); |
| glPixelStorei(GL_UNPACK_ALIGNMENT, m_alignment); |
| |
| glGenTextures(1, &tex); |
| glBindTexture(GL_TEXTURE_2D_ARRAY, tex); |
| glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, m_internalFormat, m_width, m_height, m_numLayers, 0, transferFmt.format, transferFmt.dataType, (const void*)(deUintptr)m_offset); |
| } |
| |
| deUint32 m_internalFormat; |
| int m_imageHeight; |
| int m_rowLength; |
| int m_skipImages; |
| int m_skipRows; |
| int m_skipPixels; |
| int m_alignment; |
| int m_offset; |
| }; |
| |
| // TexImage3D() from pixel buffer object. |
| class TexImage3DBufferCase : public Texture3DSpecCase |
| { |
| public: |
| TexImage3DBufferCase (Context& context, |
| const char* name, |
| const char* desc, |
| deUint32 internalFormat, |
| int width, |
| int height, |
| int depth, |
| int imageHeight, |
| int rowLength, |
| int skipImages, |
| int skipRows, |
| int skipPixels, |
| int alignment, |
| int offset) |
| : Texture3DSpecCase (context, name, desc, glu::mapGLInternalFormat(internalFormat), width, height, depth, 1) |
| , m_internalFormat (internalFormat) |
| , m_imageHeight (imageHeight) |
| , m_rowLength (rowLength) |
| , m_skipImages (skipImages) |
| , m_skipRows (skipRows) |
| , m_skipPixels (skipPixels) |
| , m_alignment (alignment) |
| , m_offset (offset) |
| { |
| } |
| |
| protected: |
| void createTexture (void) |
| { |
| glu::TransferFormat transferFmt = glu::getTransferFormat(m_texFormat); |
| int pixelSize = m_texFormat.getPixelSize(); |
| int rowLength = m_rowLength > 0 ? m_rowLength : m_width; |
| int rowPitch = deAlign32(rowLength*pixelSize, m_alignment); |
| int imageHeight = m_imageHeight > 0 ? m_imageHeight : m_height; |
| int slicePitch = imageHeight*rowPitch; |
| deUint32 tex = 0; |
| deUint32 buf = 0; |
| vector<deUint8> data; |
|