13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.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 wrap mode tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fTextureWrapTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsTextureTestUtil.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTexture.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTextureUtil.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCompressedTexture.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexLookupVerifier.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMemory.h" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::CompressedTexture; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Sampler; 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glu; 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls::TextureTestUtil; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Checks whether any ASTC version (LDR, HDR, full) is supported. 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline bool isASTCSupported (const glu::ContextInfo& contextInfo) 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const vector<string>& extensions = contextInfo.getExtensions(); 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int extNdx = 0; extNdx < (int)extensions.size(); extNdx++) 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const string& ext = extensions[extNdx]; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ext == "GL_KHR_texture_compression_astc_ldr" || 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ext == "GL_KHR_texture_compression_astc_hdr" || 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ext == "GL_OES_texture_compression_astc") 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VIEWPORT_WIDTH = 256, 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VIEWPORT_HEIGHT = 256 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureWrapCase : public tcu::TestCase 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureWrapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, deUint32 format, deUint32 dataType, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, int width, int height); 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureWrapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, const std::vector<std::string>& filenames); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureWrapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, CompressedTexture::Format compressedFormat, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, int width, int height); 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TextureWrapCase (void); 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureWrapCase (const TextureWrapCase& other); 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureWrapCase& operator= (const TextureWrapCase& other); 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct Case 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec2 bottomLeft; 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec2 topRight; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Case (void) {} 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Case (const tcu::Vec2& bl, const tcu::Vec2& tr) : bottomLeft(bl), topRight(tr) {} 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& m_renderCtxInfo; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_format; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_dataType; 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const CompressedTexture::Format m_compressedFormat; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_wrapS; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_wrapT; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_minFilter; 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_magFilter; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_width; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_height; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<std::string> m_filenames; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<Case> m_cases; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_caseNdx; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::Texture2D* m_texture; 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureRenderer m_renderer; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureWrapCase::TextureWrapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, deUint32 format, deUint32 dataType, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, int width, int height) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, name, description) 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtxInfo (ctxInfo) 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (format) 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dataType (dataType) 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_compressedFormat (CompressedTexture::FORMAT_LAST) 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapS (wrapS) 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapT (wrapT) 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_minFilter (minFilter) 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_magFilter (magFilter) 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_width (width) 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_height (height) 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_caseNdx (0) 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_texture (DE_NULL) 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderer (renderCtx, testCtx, glu::GLSL_VERSION_300_ES, glu::PRECISION_MEDIUMP) 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureWrapCase::TextureWrapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, const std::vector<std::string>& filenames) 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, name, description) 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtxInfo (ctxInfo) 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (GL_NONE) 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dataType (GL_NONE) 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_compressedFormat (CompressedTexture::FORMAT_LAST) 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapS (wrapS) 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapT (wrapT) 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_minFilter (minFilter) 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_magFilter (magFilter) 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_width (0) 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_height (0) 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_filenames (filenames) 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_caseNdx (0) 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_texture (DE_NULL) 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderer (renderCtx, testCtx, glu::GLSL_VERSION_300_ES, glu::PRECISION_MEDIUMP) 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureWrapCase::TextureWrapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, CompressedTexture::Format compressedFormat, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, int width, int height) 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, name, description) 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtxInfo (ctxInfo) 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (GL_NONE) 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dataType (GL_NONE) 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_compressedFormat (compressedFormat) 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapS (wrapS) 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapT (wrapT) 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_minFilter (minFilter) 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_magFilter (magFilter) 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_width (width) 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_height (height) 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_caseNdx (0) 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_texture (DE_NULL) 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderer (renderCtx, testCtx, glu::GLSL_VERSION_300_ES, glu::PRECISION_MEDIUMP) 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureWrapCase::~TextureWrapCase (void) 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureWrapCase::init (void) 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Load or generate texture. 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_filenames.empty()) 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Load compressed texture from file. 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_width == 0 && m_height == 0 && m_format == GL_NONE && m_dataType == GL_NONE); 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = glu::Texture2D::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(), (int)m_filenames.size(), m_filenames); 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_width = m_texture->getRefTexture().getWidth(); 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_height = m_texture->getRefTexture().getHeight(); 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_compressedFormat != CompressedTexture::FORMAT_LAST) 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Generate compressed texture. 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_format == GL_NONE && m_dataType == GL_NONE); 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (tcu::isEtcFormat(m_compressedFormat)) 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create ETC texture. Any content is valid. 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::CompressedTexture compressedTexture (m_compressedFormat, m_width, m_height); 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int dataSize = compressedTexture.getDataSize(); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint8* const data = (deUint8*)compressedTexture.getData(); 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd (deStringHash(getName())); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < dataSize; i++) 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry data[i] = rnd.getUint32() & 0xff; 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = new glu::Texture2D(m_renderCtx, m_renderCtxInfo, 1, &compressedTexture); 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (tcu::isASTCFormat(m_compressedFormat)) 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create ASTC texture by picking from a set of pre-generated blocks. 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int BLOCK_SIZE = 16; 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const deUint8 blocks[][BLOCK_SIZE] = 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note All of the following blocks are valid in LDR mode. 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 252, 253, 255, 255, 255, 255, 255, 255, 8, 71, 90, 78, 22, 17, 26, 66, }, 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 252, 253, 255, 255, 255, 255, 255, 255, 220, 74, 139, 235, 249, 6, 145, 125 }, 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 252, 253, 255, 255, 255, 255, 255, 255, 223, 251, 28, 206, 54, 251, 160, 174 }, 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 252, 253, 255, 255, 255, 255, 255, 255, 39, 4, 153, 219, 180, 61, 51, 37 }, 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67, 2, 0, 254, 1, 0, 64, 215, 83, 211, 159, 105, 41, 140, 50, 2 }, 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67, 130, 0, 170, 84, 255, 65, 215, 83, 211, 159, 105, 41, 140, 50, 2 }, 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67, 2, 129, 38, 51, 229, 95, 215, 83, 211, 159, 105, 41, 140, 50, 2 }, 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67, 130, 193, 56, 213, 144, 95, 215, 83, 211, 159, 105, 41, 140, 50, 2 } 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isASTCSupported(m_renderCtxInfo)) // \note Any level of ASTC support is enough, since we're only using LDR blocks. 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("ASTC not supported"); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::CompressedTexture compressedTexture (m_compressedFormat, m_width, m_height); 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int dataSize = compressedTexture.getDataSize(); 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint8* const data = (deUint8*)compressedTexture.getData(); 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd (deStringHash(getName())); 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(dataSize % BLOCK_SIZE == 0); 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < dataSize/BLOCK_SIZE; i++) 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deMemcpy(&data[i*BLOCK_SIZE], &blocks[rnd.getInt(0, DE_LENGTH_OF_ARRAY(blocks)-1)][0], BLOCK_SIZE); 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = new glu::Texture2D(m_renderCtx, m_renderCtxInfo, 1, &compressedTexture); 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = new Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height); 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fill level 0. 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->getRefTexture().allocLevel(0); 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), tcu::Vec4(-0.5f, -0.5f, -0.5f, 2.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f)); 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->upload(); 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Sub-cases. 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_cases.push_back(Case(tcu::Vec2(-1.5f, -3.0f), tcu::Vec2(1.5f, 2.5f))); 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_cases.push_back(Case(tcu::Vec2(-0.5f, 0.75f), tcu::Vec2(0.25f, 1.25f))); 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_caseNdx == 0); 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Initialize to success, set to failure later if needed. 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureWrapCase::deinit (void) 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_texture; 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = DE_NULL; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.clear(); 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2913c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureWrapCase::IterateResult TextureWrapCase::iterate (void) 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const RandomViewport viewport (m_renderCtx.getRenderTarget(), VIEWPORT_WIDTH, VIEWPORT_HEIGHT, deStringHash(getName()) + m_caseNdx); 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedFrame (viewport.width, viewport.height); 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface referenceFrame (viewport.width, viewport.height); 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceParams refParams (TEXTURETYPE_2D); 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::TextureFormat texFormat = m_texture->getRefTexture().getFormat(); 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<float> texCoord; 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::TextureFormatInfo texFormatInfo = tcu::getTextureFormatInfo(texFormat); 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note For non-sRGB ASTC formats, the values are fp16 in range [0..1], not the range assumed given by tcu::getTextureFormatInfo(). 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool useDefaultColorScaleAndBias = !tcu::isASTCFormat(m_compressedFormat) || tcu::isASTCSRGBFormat(m_compressedFormat); 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bind to unit 0. 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.activeTexture(GL_TEXTURE0); 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture()); 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Setup filtering and wrap modes. 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_wrapS); 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_wrapT); 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_minFilter); 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_magFilter); 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state"); 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Parameters for reference images. 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refParams.sampler = mapGLSampler(m_wrapS, m_wrapT, m_minFilter, m_magFilter); 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refParams.lodMode = LODMODE_EXACT; 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat()); 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refParams.colorScale = useDefaultColorScaleAndBias ? texFormatInfo.lookupScale : tcu::Vec4(1.0f); 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refParams.colorBias = useDefaultColorScaleAndBias ? texFormatInfo.lookupBias : tcu::Vec4(0.0f); 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeQuadTexCoord2D(texCoord, m_cases[m_caseNdx].bottomLeft, m_cases[m_caseNdx].topRight); 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.renderQuad(0, &texCoord[0], refParams); 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess()); 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section (log, string("Test") + de::toString(m_caseNdx), string("Test ") + de::toString(m_caseNdx)); 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool isNearestOnly = m_minFilter == GL_NEAREST && m_magFilter == GL_NEAREST; 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool isSRGB = texFormat.order == tcu::TextureFormat::sRGB || texFormat.order == tcu::TextureFormat::sRGBA; 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::PixelFormat pixelFormat = m_renderCtx.getRenderTarget().getPixelFormat(); 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 colorBits = tcu::max(getBitsVec(pixelFormat) - (isNearestOnly && !isSRGB ? 1 : 2), tcu::IVec4(0)); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::LodPrecision lodPrecision; 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::LookupPrecision lookupPrecision; 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry lodPrecision.derivateBits = 18; 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry lodPrecision.lodBits = 5; 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry lookupPrecision.colorThreshold = tcu::computeFixedPointThreshold(colorBits) / refParams.colorScale; 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry lookupPrecision.coordBits = tcu::IVec3(20,20,0); 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry lookupPrecision.uvwBits = tcu::IVec3(5,5,0); 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry lookupPrecision.colorMask = getCompareMask(pixelFormat); 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Note: lookup coordinates: bottom-left " << m_cases[m_caseNdx].bottomLeft << ", top-right " << m_cases[m_caseNdx].topRight << TestLog::EndMessage; 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool isOk = verifyTextureResult(m_testCtx, renderedFrame.getAccess(), m_texture->getRefTexture(), 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry &texCoord[0], refParams, lookupPrecision, lodPrecision, pixelFormat); 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isOk) 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image verification failed"); 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_caseNdx++; 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_caseNdx < (int)m_cases.size() ? CONTINUE : STOP; 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureWrapTests::TextureWrapTests (Context& context) 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "wrap", "Wrap Mode Tests") 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3633c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureWrapTests::~TextureWrapTests (void) 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureWrapTests::init (void) 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 mode; 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } wrapModes[] = 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "clamp", GL_CLAMP_TO_EDGE }, 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "repeat", GL_REPEAT }, 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "mirror", GL_MIRRORED_REPEAT } 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 mode; 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } filteringModes[] = 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "nearest", GL_NEAREST }, 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "linear", GL_LINEAR } 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define FOR_EACH(ITERATOR, ARRAY, BODY) \ 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ITERATOR = 0; ITERATOR < DE_LENGTH_OF_ARRAY(ARRAY); ITERATOR++) \ 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BODY 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // RGBA8 cases. 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width; 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height; 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } rgba8Sizes[] = 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "pot", 64, 128 }, 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "npot", 63, 112 } 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* const rgba8Group = new TestCaseGroup(m_context, "rgba8", ""); 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(rgba8Group); 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(size, rgba8Sizes, 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapS, wrapModes, 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapT, wrapModes, 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(filter, filteringModes, 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_" + rgba8Sizes[size].name; 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rgba8Group->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "", 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RGBA, GL_UNSIGNED_BYTE, 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapS].mode, 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapT].mode, 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filteringModes[filter].mode, filteringModes[filter].mode, 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rgba8Sizes[size].width, rgba8Sizes[size].height)); 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry })))); 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // ETC1 cases. 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* const etc1Group = new TestCaseGroup(m_context, "etc1", ""); 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(etc1Group); 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Power-of-two ETC1 texture 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<std::string> potFilenames; 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry potFilenames.push_back("data/etc1/photo_helsinki_mip_0.pkm"); 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapS, wrapModes, 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapT, wrapModes, 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(filter, filteringModes, 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_pot"; 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry etc1Group->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "", 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapS].mode, 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapT].mode, 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filteringModes[filter].mode, filteringModes[filter].mode, 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry potFilenames)); 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }))); 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<std::string> npotFilenames; 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry npotFilenames.push_back("data/etc1/photo_helsinki_113x89.pkm"); 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // NPOT ETC1 texture 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapS, wrapModes, 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapT, wrapModes, 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(filter, filteringModes, 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_npot"; 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry etc1Group->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "", 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapS].mode, 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapT].mode, 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filteringModes[filter].mode, filteringModes[filter].mode, 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry npotFilenames)); 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }))); 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // ETC-2 (and EAC) cases. 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CompressedTexture::Format format; 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } etc2Formats[] = 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "eac_r11", CompressedTexture::EAC_R11, }, 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "eac_signed_r11", CompressedTexture::EAC_SIGNED_R11, }, 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "eac_rg11", CompressedTexture::EAC_RG11, }, 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "eac_signed_rg11", CompressedTexture::EAC_SIGNED_RG11, }, 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "etc2_rgb8", CompressedTexture::ETC2_RGB8, }, 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "etc2_srgb8", CompressedTexture::ETC2_SRGB8, }, 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "etc2_rgb8_punchthrough_alpha1", CompressedTexture::ETC2_RGB8_PUNCHTHROUGH_ALPHA1, }, 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "etc2_srgb8_punchthrough_alpha1", CompressedTexture::ETC2_SRGB8_PUNCHTHROUGH_ALPHA1, }, 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "etc2_eac_rgba8", CompressedTexture::ETC2_EAC_RGBA8, }, 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "etc2_eac_srgb8_alpha8", CompressedTexture::ETC2_EAC_SRGB8_ALPHA8, } 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width; 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height; 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } etc2Sizes[] = 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "pot", 64, 128 }, 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "npot", 123, 107 } 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(etc2Formats); formatNdx++) 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* const formatGroup = new TestCaseGroup(m_context, etc2Formats[formatNdx].name, ""); 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(formatGroup); 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(size, etc2Sizes, 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapS, wrapModes, 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapT, wrapModes, 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(filter, filteringModes, 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_" + etc2Sizes[size].name; 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry formatGroup->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "", 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry etc2Formats[formatNdx].format, 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapS].mode, 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapT].mode, 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filteringModes[filter].mode, filteringModes[filter].mode, 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry etc2Sizes[size].width, etc2Sizes[size].height)); 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry })))); 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // ASTC cases. 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int formatI = 0; formatI < CompressedTexture::FORMAT_LAST; formatI++) 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const CompressedTexture::Format format = (CompressedTexture::Format)formatI; 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!tcu::isASTCFormat(format)) 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec3 blockSize = tcu::getASTCBlockSize(format); 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const string formatName = "astc_" + de::toString(blockSize.x()) + "x" + de::toString(blockSize.y()) + (tcu::isASTCSRGBFormat(format) ? "_srgb" : ""); 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* const formatGroup = new TestCaseGroup(m_context, formatName.c_str(), ""); 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(formatGroup); 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(blockSize.z() == 1); 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note This array is NOT static. 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const struct 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width; 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height; 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } formatSizes[] = 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "divisible", blockSize.x()*10, blockSize.y()*10 }, 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "not_divisible", blockSize.x()*10+1, blockSize.y()*10+1 }, 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(size, formatSizes, 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapS, wrapModes, 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(wrapT, wrapModes, 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FOR_EACH(filter, filteringModes, 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_" + formatSizes[size].name; 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry formatGroup->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "", 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry format, 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapS].mode, 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapT].mode, 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry filteringModes[filter].mode, filteringModes[filter].mode, 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry formatSizes[size].width, formatSizes[size].height)); 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry })))); 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 568