13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.0 Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Texture completeness tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fTextureCompletenessTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsTextureTestUtil.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deInt32.h" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluContextInfo.hpp" 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glw.h" 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <cstdlib> 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TextureFormat; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Sampler; 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec2; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::RGBA; 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::TextureTestUtil::TextureRenderer; 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::TextureTestUtil::computeQuadTexCoord2D; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::TextureTestUtil::computeQuadTexCoordCube; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing gls::TextureTestUtil::clear; 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const GLenum s_cubeTargets[] = 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_TEXTURE_CUBE_MAP_POSITIVE_X, 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_TEXTURE_CUBE_MAP_POSITIVE_Z 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool isExtensionSupported (const glu::ContextInfo& ctxInfo, const char* extension) 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<string> extensions = ctxInfo.getExtensions(); 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<string>::iterator iter = extensions.begin(); iter != extensions.end(); ++iter) 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (iter->compare(extension) == 0) 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool compareToConstantColor (TestLog& log, const char* imageSetName, const char* imageSetDesc, const tcu::Surface& result, tcu::CompareLogMode logMode, RGBA color) 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = true; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < result.getHeight(); y++) 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < result.getWidth(); x++) 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (result.getPixel(x, y).getRed() != color.getRed() || 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.getPixel(x, y).getGreen() != color.getGreen() || 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.getPixel(x, y).getBlue() != color.getBlue() || 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.getPixel(x, y).getAlpha() != color.getAlpha()) 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk = false; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isOk || logMode == tcu::COMPARE_LOG_EVERYTHING) 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isOk) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Image comparison failed" << TestLog::EndMessage; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet(imageSetName, imageSetDesc) 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("Result", "Result", result) 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (logMode == tcu::COMPARE_LOG_RESULT) 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet(imageSetName, imageSetDesc) 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("Result", "Result", result) 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return isOk; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Base classes. 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Tex2DCompletenessCase : public tcu::TestCase 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Tex2DCompletenessCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description); 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Tex2DCompletenessCase (void) {}; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void) = 0; 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestContext& m_testCtx; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGBA m_compareColor; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1413c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTex2DCompletenessCase::Tex2DCompletenessCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description) 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, name, description) 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_testCtx (testCtx) 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_compareColor (RGBA(0,0,0,255)) 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTex2DCompletenessCase::IterateResult Tex2DCompletenessCase::iterate (void) 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportWidth = de::min(64, m_renderCtx.getRenderTarget().getWidth()); 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportHeight = de::min(64, m_renderCtx.getRenderTarget().getHeight()); 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureRenderer renderer (m_renderCtx, m_testCtx, glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP); 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedFrame (viewportWidth, viewportHeight); 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<float> texCoord; 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random random (deStringHash(getName())); 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int offsetX = random.getInt(0, m_renderCtx.getRenderTarget().getWidth() - viewportWidth ); 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int offsetY = random.getInt(0, m_renderCtx.getRenderTarget().getHeight() - viewportHeight); 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeQuadTexCoord2D (texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f)); 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glViewport (offsetX, offsetY, viewportWidth, viewportHeight); 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createTexture (); 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderer.renderQuad (0, &texCoord[0], gls::TextureTestUtil::TEXTURETYPE_2D); 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels (m_renderCtx, offsetX, offsetY, renderedFrame.getAccess()); 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = compareToConstantColor(log, "Result", "Image comparison result", renderedFrame, tcu::COMPARE_LOG_RESULT, m_compareColor); 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk ? "Pass" : "Image comparison failed"); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TexCubeCompletenessCase : public tcu::TestCase 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TexCubeCompletenessCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description); 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TexCubeCompletenessCase (void) {}; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void) = 0; 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestContext& m_testCtx; 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGBA m_compareColor; 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexCubeCompletenessCase::TexCubeCompletenessCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description) 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, name, description) 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_testCtx (testCtx) 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_compareColor (RGBA(0,0,0,255)) 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2013c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexCubeCompletenessCase::IterateResult TexCubeCompletenessCase::iterate (void) 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportWidth = de::min(64, m_renderCtx.getRenderTarget().getWidth()); 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportHeight = de::min(64, m_renderCtx.getRenderTarget().getHeight()); 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool allFacesOk = true; 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureRenderer renderer (m_renderCtx, m_testCtx, glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP); 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedFrame (viewportWidth, viewportHeight); 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<float> texCoord; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random random (deStringHash(getName())); 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int offsetX = random.getInt(0, de::max(0,m_renderCtx.getRenderTarget().getWidth() - 64)); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int offsetY = random.getInt(0, de::max(0,m_renderCtx.getRenderTarget().getHeight() - 64)); 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createTexture(); 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int face = 0; face < tcu::CUBEFACE_LAST; face++) 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeQuadTexCoordCube (texCoord, (tcu::CubeFace)face); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glViewport (offsetX, offsetY, viewportWidth, viewportHeight); 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderer.renderQuad (0, &texCoord[0], gls::TextureTestUtil::TEXTURETYPE_CUBE); 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels (m_renderCtx, offsetX, offsetY, renderedFrame.getAccess()); 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = compareToConstantColor(log, "Result", "Image comparison result", renderedFrame, tcu::COMPARE_LOG_RESULT, m_compareColor); 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isOk) 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry allFacesOk = false; 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(allFacesOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry allFacesOk ? "Pass" : "Image comparison failed"); 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Texture 2D tests. 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DSizeCase : public Tex2DCompletenessCase 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Incomplete2DSizeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx, const glu::ContextInfo& ctxInfo); 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Incomplete2DSizeCase (void) {} 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_invalidLevelNdx; 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_invalidLevelSize; 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& m_ctxInfo; 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2543c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DSizeCase::Incomplete2DSizeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx, const glu::ContextInfo& ctxInfo) 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : Tex2DCompletenessCase (testCtx, renderCtx, name, description) 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidLevelNdx (invalidLevelNdx) 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidLevelSize (invalidLevelSize) 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_ctxInfo (ctxInfo) 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DSizeCase::createTexture (void) 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_2D, texture); 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y())); 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelW = (levelNdx == m_invalidLevelNdx) ? m_invalidLevelSize.x() : de::max(1, m_size.x() >> levelNdx); 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelH = (levelNdx == m_invalidLevelNdx) ? m_invalidLevelSize.y() : de::max(1, m_size.y() >> levelNdx); 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(GL_TEXTURE_2D, levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* extension = "GL_NV_texture_npot_2D_mipmap"; 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isExtensionSupported(m_ctxInfo, extension) && !deIsPowerOfTwo32(m_size.x()) && !deIsPowerOfTwo32(m_size.y())) 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << extension << " supported, assuming completeness test to pass." << TestLog::EndMessage; 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_compareColor = RGBA(0,0,255,255); 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DFormatCase : public Tex2DCompletenessCase 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Incomplete2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat, int invalidLevelNdx); 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Incomplete2DFormatCase (void) {} 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_invalidLevelNdx; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_format; 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_invalidFormat; 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DFormatCase::Incomplete2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat, int invalidLevelNdx) 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : Tex2DCompletenessCase (testCtx, renderCtx, name, description) 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidLevelNdx (invalidLevelNdx) 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (format) 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidFormat (invalidFormat) 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DFormatCase::createTexture (void) 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, GL_UNSIGNED_BYTE); 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_2D, texture); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y())); 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelW = de::max(1, m_size.x() >> levelNdx); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelH = de::max(1, m_size.y() >> levelNdx); 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format = levelNdx == m_invalidLevelNdx ? m_invalidFormat : m_format; 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(GL_TEXTURE_2D, levelNdx, format, levelW, levelH, 0, format, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DMissingLevelCase : public Tex2DCompletenessCase 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Incomplete2DMissingLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int missingLevelNdx); 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Incomplete2DMissingLevelCase (void) {} 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_missingLevelNdx; 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3723c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DMissingLevelCase::Incomplete2DMissingLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int missingLevelNdx) 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : Tex2DCompletenessCase (testCtx, renderCtx, name, description) 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_missingLevelNdx (missingLevelNdx) 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DMissingLevelCase::createTexture (void) 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_2D, texture); 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y())); 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelW = de::max(1, m_size.x() >> levelNdx); 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelH = de::max(1, m_size.y() >> levelNdx); 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Skip specified level. 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (levelNdx != m_missingLevelNdx) 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(GL_TEXTURE_2D, levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DWrapModeCase : public Tex2DCompletenessCase 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Incomplete2DWrapModeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 wrapT, deUint32 wrapS, const glu::ContextInfo& ctxInfo); 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Incomplete2DWrapModeCase (void) {} 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_wrapT; 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_wrapS; 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& m_ctxInfo; 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DWrapModeCase::Incomplete2DWrapModeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 wrapT, deUint32 wrapS, const glu::ContextInfo& ctxInfo) 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : Tex2DCompletenessCase (testCtx, renderCtx, name, description) 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapT (wrapT) 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapS (wrapS) 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_ctxInfo (ctxInfo) 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DWrapModeCase::createTexture (void) 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures(1, &texture); 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture(GL_TEXTURE_2D, texture); 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_wrapS); 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_wrapT); 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_size.x(), m_size.y(), 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* extension = "GL_OES_texture_npot"; 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isExtensionSupported(m_ctxInfo, extension)) 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << extension << " supported, assuming completeness test to pass." << TestLog::EndMessage; 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_compareColor = RGBA(0,0,255,255); 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Complete2DExtraLevelCase : public Tex2DCompletenessCase 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Complete2DExtraLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size); 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Complete2DExtraLevelCase (void) {} 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4793c827367444ee418f129b2c238299f49d3264554Jarkko PoyryComplete2DExtraLevelCase::Complete2DExtraLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size) 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : Tex2DCompletenessCase (testCtx, renderCtx, name, description) 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Complete2DExtraLevelCase::createTexture (void) 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_2D, texture); 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y())); 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelW = de::max(1, m_size.x() >> levelNdx); 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelH = de::max(1, m_size.y() >> levelNdx); 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(GL_TEXTURE_2D, levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Specify extra level. 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(GL_TEXTURE_2D, numLevels+1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_compareColor = RGBA(0,0,255,255); 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Incomplete2DEmptyObjectCase : public Tex2DCompletenessCase 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Incomplete2DEmptyObjectCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size); 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Incomplete2DEmptyObjectCase (void) {} 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5323c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncomplete2DEmptyObjectCase::Incomplete2DEmptyObjectCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size) 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : Tex2DCompletenessCase (testCtx, renderCtx, name, description) 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Incomplete2DEmptyObjectCase::createTexture (void) 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_2D, texture); 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Cube texture tests. 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeSizeCase : public TexCubeCompletenessCase 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IncompleteCubeSizeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx); 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IncompleteCubeSizeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx, tcu::CubeFace invalidCubeFace); 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~IncompleteCubeSizeCase (void) {} 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_invalidLevelNdx; 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_invalidLevelSize; 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::CubeFace m_invalidCubeFace; 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5743c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeSizeCase::IncompleteCubeSizeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx) 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TexCubeCompletenessCase (testCtx, renderCtx, name, description) 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidLevelNdx (invalidLevelNdx) 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidLevelSize (invalidLevelSize) 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidCubeFace (tcu::CUBEFACE_LAST) 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5833c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeSizeCase::IncompleteCubeSizeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, IVec2 invalidLevelSize, int invalidLevelNdx, tcu::CubeFace invalidCubeFace) 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TexCubeCompletenessCase (testCtx, renderCtx, name, description) 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidLevelNdx (invalidLevelNdx) 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidLevelSize (invalidLevelSize) 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidCubeFace (invalidCubeFace) 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeSizeCase::createTexture (void) 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_CUBE_MAP, texture); 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT); 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT); 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y())); 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++) 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelW = de::max(1, m_size.x() >> levelNdx); 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelH = de::max(1, m_size.y() >> levelNdx); 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (levelNdx == m_invalidLevelNdx && (m_invalidCubeFace == tcu::CUBEFACE_LAST || m_invalidCubeFace == targetNdx)) 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelW = m_invalidLevelSize.x(); 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelH = m_invalidLevelSize.y(); 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(s_cubeTargets[targetNdx], levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeFormatCase : public TexCubeCompletenessCase 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IncompleteCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat); 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IncompleteCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat, tcu::CubeFace invalidCubeFace); 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~IncompleteCubeFormatCase (void) {} 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_format; 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_invalidFormat; 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::CubeFace m_invalidCubeFace; 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeFormatCase::IncompleteCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat) 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TexCubeCompletenessCase (testCtx, renderCtx, name, description) 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (format) 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidFormat (invalidFormat) 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidCubeFace (tcu::CUBEFACE_LAST) 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6553c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeFormatCase::IncompleteCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 format, deUint32 invalidFormat, tcu::CubeFace invalidCubeFace) 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TexCubeCompletenessCase (testCtx, renderCtx, name, description) 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (format) 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidFormat (invalidFormat) 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidCubeFace (invalidCubeFace) 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeFormatCase::createTexture (void) 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_CUBE_MAP, texture); 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT); 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT); 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y())); 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelW = de::max(1, m_size.x() >> levelNdx); 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelH = de::max(1, m_size.y() >> levelNdx); 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++) 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format = m_format; 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (levelNdx == 0 && (m_invalidCubeFace == tcu::CUBEFACE_LAST || m_invalidCubeFace == targetNdx)) 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry format = m_invalidFormat; 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(s_cubeTargets[targetNdx], levelNdx, format, levelW, levelH, 0, format, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeMissingLevelCase : public TexCubeCompletenessCase 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IncompleteCubeMissingLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int invalidLevelNdx); 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IncompleteCubeMissingLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int invalidLevelNdx, tcu::CubeFace invalidCubeFace); 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~IncompleteCubeMissingLevelCase (void) {} 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_invalidLevelNdx; 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::CubeFace m_invalidCubeFace; 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7173c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeMissingLevelCase::IncompleteCubeMissingLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int invalidLevelNdx) 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TexCubeCompletenessCase (testCtx, renderCtx, name, description) 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidLevelNdx (invalidLevelNdx) 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidCubeFace (tcu::CUBEFACE_LAST) 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7253c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeMissingLevelCase::IncompleteCubeMissingLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, int invalidLevelNdx, tcu::CubeFace invalidCubeFace) 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TexCubeCompletenessCase (testCtx, renderCtx, name, description) 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidLevelNdx (invalidLevelNdx) 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidCubeFace (invalidCubeFace) 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeMissingLevelCase::createTexture (void) 7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_CUBE_MAP, texture); 7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT); 7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT); 7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y())); 7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelW = (levelNdx == m_invalidLevelNdx) ? m_size.x() : de::max(1, m_size.x() >> levelNdx); 7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelH = (levelNdx == m_invalidLevelNdx) ? m_size.y() : de::max(1, m_size.y() >> levelNdx); 7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (levelNdx != m_invalidLevelNdx || m_invalidCubeFace != tcu::CUBEFACE_LAST) 7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++) 7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // If single cubeface is specified then skip only that one. 7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_invalidCubeFace != targetNdx) 7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(s_cubeTargets[targetNdx], levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeWrapModeCase : public TexCubeCompletenessCase 7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IncompleteCubeWrapModeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 wrapT, deUint32 wrapS, const glu::ContextInfo& ctxInfo); 7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~IncompleteCubeWrapModeCase (void) {} 7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_wrapT; 7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_wrapS; 7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& m_ctxInfo; 7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeWrapModeCase::IncompleteCubeWrapModeCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size, deUint32 wrapT, deUint32 wrapS, const glu::ContextInfo& ctxInfo) 7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TexCubeCompletenessCase (testCtx, renderCtx, name, description) 7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapT (wrapT) 7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapS (wrapS) 7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_ctxInfo (ctxInfo) 7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeWrapModeCase::createTexture (void) 7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures(1, &texture); 8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture(GL_TEXTURE_2D, texture); 8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, m_wrapS); 8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, m_wrapT); 8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++) 8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(s_cubeTargets[targetNdx], 0, GL_RGBA, m_size.x(), m_size.y(), 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* extension = "GL_OES_texture_npot"; 8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isExtensionSupported(m_ctxInfo, extension)) 8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << extension << " supported, assuming completeness test to pass." << TestLog::EndMessage; 8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_compareColor = RGBA(0,0,255,255); 8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CompleteCubeExtraLevelCase : public TexCubeCompletenessCase 8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CompleteCubeExtraLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size); 8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~CompleteCubeExtraLevelCase (void) {} 8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8403c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCompleteCubeExtraLevelCase::CompleteCubeExtraLevelCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size) 8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TexCubeCompletenessCase (testCtx, renderCtx, name, description) 8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid CompleteCubeExtraLevelCase::createTexture (void) 8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_2D, texture); 8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = 1 + de::max(deLog2Floor32(m_size.x()), deLog2Floor32(m_size.y())); 8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry levelData.setSize(m_size.x(), m_size.y()); 8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clear(levelData.getAccess(), tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); 8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelW = de::max(1, m_size.x() >> levelNdx); 8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int levelH = de::max(1, m_size.y() >> levelNdx); 8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++) 8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(s_cubeTargets[targetNdx], levelNdx, GL_RGBA, levelW, levelH, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Specify extra level. 8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(s_cubeTargets); targetNdx++) 8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D(s_cubeTargets[targetNdx], numLevels+1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, levelData.getAccess().getDataPtr()); 8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_compareColor = RGBA(0,0,255,255); 8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IncompleteCubeEmptyObjectCase : public TexCubeCompletenessCase 8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IncompleteCubeEmptyObjectCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size); 8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~IncompleteCubeEmptyObjectCase (void) {} 8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createTexture (void); 8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec2 m_size; 8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8963c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIncompleteCubeEmptyObjectCase::IncompleteCubeEmptyObjectCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, IVec2 size) 8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TexCubeCompletenessCase (testCtx, renderCtx, name, description) 8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IncompleteCubeEmptyObjectCase::createTexture (void) 9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(GL_RGBA, GL_UNSIGNED_BYTE); 9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel levelData (fmt); 9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &texture); 9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glPixelStorei (GL_UNPACK_ALIGNMENT, 1); 9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_2D, texture); 9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG("Set texturing state"); 9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Texture completeness group. 921