es2fTextureFormatTests.cpp revision b2e583dfcd8aa0d4ef254f841213fcf724b2b193
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 format tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Constants: 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * + nearest-neighbor filtering 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * + no mipmaps 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * + full texture coordinate range (but not outside) tested 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * + accessed from fragment shader 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * + texture unit 0 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * + named texture object 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Variables: 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * + texture format 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * + texture type: 2D or cubemap 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fTextureFormatTests.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsTextureTestUtil.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTexture.hpp" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp" 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp" 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Sampler; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glu; 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls::TextureTestUtil; 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Texture2DFormatCase 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DFormatCase : public tcu::TestCase 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height); 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Texture2DFormatCase (void); 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DFormatCase (const Texture2DFormatCase& other); 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DFormatCase& operator= (const Texture2DFormatCase& other); 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_format; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_dataType; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_width; 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_height; 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::Texture2D* m_texture; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureRenderer m_renderer; 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 913c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DFormatCase::Texture2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height) 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, name, description) 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (format) 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dataType (dataType) 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_width (width) 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_height (height) 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_texture (DE_NULL) 99469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry , m_renderer (renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP) 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1033c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DFormatCase::~Texture2DFormatCase (void) 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DFormatCase::init (void) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType); 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(fmt); 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::ostringstream fmtName; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 115b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry fmtName << getTextureFormatStr(m_format) << ", " << getTypeStr(m_dataType); 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "2D texture, " << fmtName.str() << ", " << m_width << "x" << m_height 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ",\n fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient" 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndMessage; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = new Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height); 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fill level 0. 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->getRefTexture().allocLevel(0); 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), spec.valueMin, spec.valueMax); 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DFormatCase::deinit (void) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_texture; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = DE_NULL; 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.clear(); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1363c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DFormatCase::IterateResult Texture2DFormatCase::iterate (void) 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomViewport viewport (m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName())); 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedFrame (viewport.width, viewport.height); 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface referenceFrame (viewport.width, viewport.height); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<float> texCoord; 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceParams renderParams (TEXTURETYPE_2D); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat()); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 wrapS = GL_CLAMP_TO_EDGE; 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 wrapT = GL_CLAMP_TO_EDGE; 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 minFilter = GL_NEAREST; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 magFilter = GL_NEAREST; 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.flags |= RenderParams::LOG_ALL; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat()); 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.sampler = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST); 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.colorScale = spec.lookupScale; 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.colorBias = spec.lookupBias; 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f)); 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Texture parameters:" 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n WRAP_S = " << getTextureParameterValueStr(GL_TEXTURE_WRAP_S, wrapS) 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n WRAP_T = " << getTextureParameterValueStr(GL_TEXTURE_WRAP_T, wrapT) 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n MIN_FILTER = " << getTextureParameterValueStr(GL_TEXTURE_MIN_FILTER, minFilter) 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n MAG_FILTER = " << getTextureParameterValueStr(GL_TEXTURE_MAG_FILTER, magFilter) 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndMessage; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup base viewport. 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Upload texture data to GL. 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->upload(); 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bind to unit 0. 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.activeTexture(GL_TEXTURE0); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture()); 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup nearest neighbor filtering and clamp-to-edge. 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS); 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT); 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state"); 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw. 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.renderQuad(0, &texCoord[0], renderParams); 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess()); 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()"); 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compute reference. 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleTexture(SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams); 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare and log. 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk ? "Pass" : "Image comparison failed"); 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TextureCubeFormatCase 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeFormatCase : public tcu::TestCase 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height); 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TextureCubeFormatCase (void); 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeFormatCase (const TextureCubeFormatCase& other); 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeFormatCase& operator= (const TextureCubeFormatCase& other); 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool testFace (tcu::CubeFace face); 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_format; 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_dataType; 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_width; 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_height; 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::TextureCube* m_texture; 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureRenderer m_renderer; 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_curFace; 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_isOk; 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2353c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeFormatCase::TextureCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height) 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, name, description) 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (format) 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dataType (dataType) 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_width (width) 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_height (height) 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_texture (DE_NULL) 243469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry , m_renderer (renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP) 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_curFace (0) 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_isOk (false) 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeFormatCase::~TextureCubeFormatCase (void) 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeFormatCase::init (void) 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType); 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(fmt); 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::ostringstream fmtName; 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_dataType) 262b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry fmtName << getTextureFormatStr(m_format) << ", " << getTypeStr(m_dataType); 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 264b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry fmtName << getTextureFormatStr(m_format); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Cube map texture, " << fmtName.str() << ", " << m_width << "x" << m_height 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ",\n fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient" 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndMessage; 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_width == m_height); 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = m_dataType != GL_NONE 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ? new TextureCube(m_renderCtx, m_format, m_dataType, m_width) // Implicit internal format. 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : new TextureCube(m_renderCtx, m_format, m_width); // Explicit internal format. 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fill level 0. 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int face = 0; face < tcu::CUBEFACE_LAST; face++) 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 gMin, gMax; 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (face) 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: gMin = spec.valueMin.swizzle(0, 1, 2, 3); gMax = spec.valueMax.swizzle(0, 1, 2, 3); break; 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: gMin = spec.valueMin.swizzle(2, 1, 0, 3); gMax = spec.valueMax.swizzle(2, 1, 0, 3); break; 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: gMin = spec.valueMin.swizzle(1, 2, 0, 3); gMax = spec.valueMax.swizzle(1, 2, 0, 3); break; 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 3: gMin = spec.valueMax.swizzle(0, 1, 2, 3); gMax = spec.valueMin.swizzle(0, 1, 2, 3); break; 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 4: gMin = spec.valueMax.swizzle(2, 1, 0, 3); gMax = spec.valueMin.swizzle(2, 1, 0, 3); break; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 5: gMin = spec.valueMax.swizzle(1, 2, 0, 3); gMax = spec.valueMin.swizzle(1, 2, 0, 3); break; 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->getRefTexture().allocLevel((tcu::CubeFace)face, 0); 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevelFace(0, (tcu::CubeFace)face), gMin, gMax); 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Upload texture data to GL. 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->upload(); 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Initialize iteration state. 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_curFace = 0; 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_isOk = true; 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeFormatCase::deinit (void) 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_texture; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = DE_NULL; 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.clear(); 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool TextureCubeFormatCase::testFace (tcu::CubeFace face) 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomViewport viewport (m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName())+(deUint32)face); 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedFrame (viewport.width, viewport.height); 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface referenceFrame (viewport.width, viewport.height); 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<float> texCoord; 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceParams renderParams (TEXTURETYPE_CUBE); 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat()); 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat()); 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.sampler = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST); 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.sampler.seamlessCubeMap = false; 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.colorScale = spec.lookupScale; 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.colorBias = spec.lookupBias; 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Log render info on first face. 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (face == tcu::CUBEFACE_NEGATIVE_X) 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderParams.flags |= RenderParams::LOG_ALL; 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeQuadTexCoordCube(texCoord, face); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \todo [2011-10-28 pyry] Image set name / section? 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << face << TestLog::EndMessage; 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup base viewport. 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bind to unit 0. 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.activeTexture(GL_TEXTURE0); 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture()); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup nearest neighbor filtering and clamp-to-edge. 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state"); 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.renderQuad(0, &texCoord[0], renderParams); 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess()); 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()"); 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compute reference. 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleTexture(SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams); 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare and log. 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return compareImages(log, referenceFrame, renderedFrame, threshold); 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3653c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeFormatCase::IterateResult TextureCubeFormatCase::iterate (void) 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Execute test for all faces. 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!testFace((tcu::CubeFace)m_curFace)) 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_isOk = false; 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_curFace += 1; 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_curFace == tcu::CUBEFACE_LAST) 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_isOk ? "Pass" : "Image comparison failed"); 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3833c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureFormatTests::TextureFormatTests (Context& context) 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "format", "Texture Format Tests") 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3883c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureFormatTests::~TextureFormatTests (void) 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Compressed2DFormatCase 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Compressed2DFormatCase : public tcu::TestCase 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Compressed2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames); 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Compressed2DFormatCase (void); 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Compressed2DFormatCase (const Compressed2DFormatCase& other); 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Compressed2DFormatCase& operator= (const Compressed2DFormatCase& other); 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& m_renderCtxInfo; 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<std::string> m_filenames; 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::Texture2D* m_texture; 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureRenderer m_renderer; 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4173c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCompressed2DFormatCase::Compressed2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames) 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, name, description) 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtxInfo (renderCtxInfo) 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_filenames (filenames) 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_texture (DE_NULL) 423469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry , m_renderer (renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP) 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCompressed2DFormatCase::~Compressed2DFormatCase (void) 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Compressed2DFormatCase::init (void) 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create texture. 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = Texture2D::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(), (int)m_filenames.size(), m_filenames); 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Compressed2DFormatCase::deinit (void) 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_texture; 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = DE_NULL; 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.clear(); 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCompressed2DFormatCase::IterateResult Compressed2DFormatCase::iterate (void) 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomViewport viewport (m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getWidth(), m_texture->getRefTexture().getHeight(), deStringHash(getName())); 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedFrame (viewport.width, viewport.height); 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface referenceFrame (viewport.width, viewport.height); 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<float> texCoord; 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f)); 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup base viewport. 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bind to unit 0. 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.activeTexture(GL_TEXTURE0); 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture()); 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup nearest neighbor filtering and clamp-to-edge. 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state"); 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw. 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_2D); 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess()); 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()"); 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compute reference. 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceParams refParams(TEXTURETYPE_2D); 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refParams.sampler = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST); 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleTexture(SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], refParams); 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare and log. 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold); 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk ? "Pass" : "Image comparison failed"); 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// CompressedCubeFormatCase 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CompressedCubeFormatCase : public tcu::TestCase 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CompressedCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames); 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~CompressedCubeFormatCase (void); 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CompressedCubeFormatCase (const CompressedCubeFormatCase& other); 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CompressedCubeFormatCase& operator= (const CompressedCubeFormatCase& other); 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool testFace (tcu::CubeFace face); 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& m_renderCtxInfo; 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<std::string> m_filenames; 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::TextureCube* m_texture; 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureRenderer m_renderer; 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_curFace; 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_isOk; 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5223c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCompressedCubeFormatCase::CompressedCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames) 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, name, description) 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtxInfo (renderCtxInfo) 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_filenames (filenames) 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_texture (DE_NULL) 528469002caa1ccd58f59f53a1bf3dbac4cf6a5d817Jarkko Pöyry , m_renderer (renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP) 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_curFace (0) 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_isOk (false) 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5343c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCompressedCubeFormatCase::~CompressedCubeFormatCase (void) 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid CompressedCubeFormatCase::init (void) 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create texture. 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_filenames.size() % 6 == 0); 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = TextureCube::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(), (int)m_filenames.size()/6, m_filenames); 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_curFace = 0; 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_isOk = true; 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid CompressedCubeFormatCase::deinit (void) 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_texture; 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = DE_NULL; 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.clear(); 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool CompressedCubeFormatCase::testFace (tcu::CubeFace face) 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomViewport viewport (m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getSize(), m_texture->getRefTexture().getSize(), deStringHash(getName())+(deUint32)face); 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedFrame (viewport.width, viewport.height); 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface referenceFrame (viewport.width, viewport.height); 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Sampler sampler (Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST); 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1); 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<float> texCoord; 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeQuadTexCoordCube(texCoord, face); 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \todo [2011-10-28 pyry] Image set name / section? 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << face << TestLog::EndMessage; 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup base viewport. 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bind to unit 0. 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.activeTexture(GL_TEXTURE0); 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture()); 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup nearest neighbor filtering and clamp-to-edge. 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state"); 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_CUBE); 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess()); 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()"); 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compute reference. 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleTexture(SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], ReferenceParams(TEXTURETYPE_CUBE, sampler)); 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare and log. 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return compareImages(log, referenceFrame, renderedFrame, threshold); 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5993c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCompressedCubeFormatCase::IterateResult CompressedCubeFormatCase::iterate (void) 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Execute test for all faces. 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!testFace((tcu::CubeFace)m_curFace)) 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_isOk = false; 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_curFace += 1; 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_curFace == tcu::CUBEFACE_LAST) 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_isOk ? "Pass" : "Image comparison failed"); 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvector<string> toStringVector (const char* const* str, int numStr) 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<string> v; 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v.resize(numStr); 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < numStr; i++) 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry v[i] = str[i]; 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return v; 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureFormatTests::init (void) 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format; 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 dataType; 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } texFormats[] = 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "a8", GL_ALPHA, GL_UNSIGNED_BYTE }, 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "l8", GL_LUMINANCE, GL_UNSIGNED_BYTE }, 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "la88", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE }, 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "rgb565", GL_RGB, GL_UNSIGNED_SHORT_5_6_5 }, 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "rgb888", GL_RGB, GL_UNSIGNED_BYTE }, 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "rgba4444", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 }, 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "rgba5551", GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 }, 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "rgba8888", GL_RGBA, GL_UNSIGNED_BYTE } 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++) 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format = texFormats[formatNdx].format; 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 dataType = texFormats[formatNdx].dataType; 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string nameBase = texFormats[formatNdx].name; 650b2e583dfcd8aa0d4ef254f841213fcf724b2b193Jarkko Pöyry string descriptionBase = string(glu::getTextureFormatName(format)) + ", " + glu::getTypeName(dataType); 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new Texture2DFormatCase (m_testCtx, m_context.getRenderContext(), (nameBase + "_2d_pot").c_str(), (descriptionBase + ", GL_TEXTURE_2D").c_str(), format, dataType, 128, 128)); 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new Texture2DFormatCase (m_testCtx, m_context.getRenderContext(), (nameBase + "_2d_npot").c_str(), (descriptionBase + ", GL_TEXTURE_2D").c_str(), format, dataType, 63, 112)); 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TextureCubeFormatCase (m_testCtx, m_context.getRenderContext(), (nameBase + "_cube_pot").c_str(), (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(), format, dataType, 64, 64)); 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TextureCubeFormatCase (m_testCtx, m_context.getRenderContext(), (nameBase + "_cube_npot").c_str(), (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(), format, dataType, 57, 57)); 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // ETC-1 compressed formats. 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const char* filenames[] = 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "data/etc1/photo_helsinki_mip_0.pkm", 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "data/etc1/photo_helsinki_mip_1.pkm", 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "data/etc1/photo_helsinki_mip_2.pkm", 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "data/etc1/photo_helsinki_mip_3.pkm", 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "data/etc1/photo_helsinki_mip_4.pkm", 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "data/etc1/photo_helsinki_mip_5.pkm", 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "data/etc1/photo_helsinki_mip_6.pkm", 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "data/etc1/photo_helsinki_mip_7.pkm" 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new Compressed2DFormatCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_2d_pot", "GL_ETC1_RGB8_OES, GL_TEXTURE_2D", toStringVector(filenames, DE_LENGTH_OF_ARRAY(filenames)))); 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<string> filenames; 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filenames.push_back("data/etc1/photo_helsinki_113x89.pkm"); 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new Compressed2DFormatCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_2d_npot", "GL_ETC1_RGB8_OES, GL_TEXTURE_2D", filenames)); 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const char* faceExt[] = { "neg_x", "pos_x", "neg_y", "pos_y", "neg_z", "pos_z" }; 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int potNumLevels = 7; 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<string> potFilenames; 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int level = 0; level < potNumLevels; level++) 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int face = 0; face < tcu::CUBEFACE_LAST; face++) 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry potFilenames.push_back(string("data/etc1/skybox_") + faceExt[face] + "_mip_" + de::toString(level) + ".pkm"); 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new CompressedCubeFormatCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_cube_pot", "GL_ETC1_RGB8_OES, GL_TEXTURE_CUBE_MAP", potFilenames)); 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<string> npotFilenames; 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int face = 0; face < tcu::CUBEFACE_LAST; face++) 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry npotFilenames.push_back(string("data/etc1/skybox_61x61_") + faceExt[face] + ".pkm"); 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new CompressedCubeFormatCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_cube_npot", "GL_ETC_RGB8_OES, GL_TEXTURE_CUBE_MAP", npotFilenames)); 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 702