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 Mipmapping accuracy tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2aTextureMipmapTests.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 "tcuVector.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuMatrix.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuMatrixUtil.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Accuracy 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Sampler; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec2; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Mat2; 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4; 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec2; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec4; 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glu; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls::TextureTestUtil; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum CoordType 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COORDTYPE_BASIC, //!< texCoord = translateScale(position). 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COORDTYPE_BASIC_BIAS, //!< Like basic, but with bias values. 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COORDTYPE_AFFINE, //!< texCoord = translateScaleRotateShear(position). 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COORDTYPE_PROJECTED, //!< Projected coordinates, w != 1 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COORDTYPE_LAST 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Texture2DMipmapCase 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DMipmapCase : public tcu::TestCase 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DMipmapCase (tcu::TestContext& testCtx, 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& renderCtx, 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& renderCtxInfo, 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* desc, 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CoordType coordType, 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 minFilter, 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 wrapS, 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 wrapT, 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format, 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 dataType, 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width, 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height); 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Texture2DMipmapCase (void); 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DMipmapCase (const Texture2DMipmapCase& other); 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DMipmapCase& operator= (const Texture2DMipmapCase& other); 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& m_renderCtxInfo; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CoordType m_coordType; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_minFilter; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_wrapS; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_wrapT; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_format; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_dataType; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_width; 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_height; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::Texture2D* m_texture; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureRenderer m_renderer; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1153c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DMipmapCase::Texture2DMipmapCase (tcu::TestContext& testCtx, 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& renderCtx, 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& renderCtxInfo, 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* desc, 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CoordType coordType, 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 minFilter, 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 wrapS, 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 wrapT, 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format, 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 dataType, 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width, 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height) 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, tcu::NODETYPE_ACCURACY, name, desc) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtxInfo (renderCtxInfo) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_coordType (coordType) 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_minFilter (minFilter) 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapS (wrapS) 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapT (wrapT) 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (format) 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dataType (dataType) 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_width (width) 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_height (height) 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_texture (DE_NULL) 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderer (renderCtx, testCtx, glu::GLSL_VERSION_100_ES, 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderCtxInfo.isFragmentHighPrecisionSupported() ? glu::PRECISION_HIGHP // Use highp if available. 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : glu::PRECISION_MEDIUMP) 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DMipmapCase::~Texture2DMipmapCase (void) 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DMipmapCase::init (void) 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_renderCtxInfo.isFragmentHighPrecisionSupported()) 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << TestLog::Message << "Warning: High precision not supported in fragment shaders." << TestLog::EndMessage; 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = new Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height); 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = deLog2Floor32(de::max(m_width, m_height))+1; 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fill texture with colored grid. 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 step = 0xff / (numLevels-1); 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 inc = deClamp32(step*levelNdx, 0x00, 0xff); 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 dec = 0xff - inc; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 rgb = (inc << 16) | (dec << 8) | 0xff; 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 color = 0xff000000 | rgb; 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->getRefTexture().allocLevel(levelNdx); 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::clear(m_texture->getRefTexture().getLevel(levelNdx), toVec4(tcu::RGBA(color))); 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid Texture2DMipmapCase::deinit (void) 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_texture; 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = DE_NULL; 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.clear(); 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void getBasicTexCoord2D (std::vector<float>& dst, int cellNdx) 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec2 bottomLeft; 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec2 topRight; 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } s_basicCoords[] = 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2(-0.1f, 0.1f), Vec2( 0.8f, 1.0f) }, 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2(-0.3f, -0.6f), Vec2( 0.7f, 0.4f) }, 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2(-0.3f, 0.6f), Vec2( 0.7f, -0.9f) }, 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2(-0.8f, 0.6f), Vec2( 0.7f, -0.9f) }, 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2(-0.5f, -0.5f), Vec2( 1.5f, 1.5f) }, 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2( 1.0f, -1.0f), Vec2(-1.3f, 1.0f) }, 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2( 1.2f, -1.0f), Vec2(-1.3f, 1.6f) }, 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2( 2.2f, -1.1f), Vec2(-1.3f, 0.8f) }, 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2(-1.5f, 1.6f), Vec2( 1.7f, -1.4f) }, 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2( 2.0f, 1.6f), Vec2( 2.3f, -1.4f) }, 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2( 1.3f, -2.6f), Vec2(-2.7f, 2.9f) }, 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2(-0.8f, -6.6f), Vec2( 6.0f, -0.9f) }, 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2( -8.0f, 9.0f), Vec2( 8.3f, -7.0f) }, 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2(-16.0f, 10.0f), Vec2( 18.3f, 24.0f) }, 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2( 30.2f, 55.0f), Vec2(-24.3f, -1.6f) }, 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { Vec2(-33.2f, 64.1f), Vec2( 32.1f, -64.1f) }, 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(de::inBounds(cellNdx, 0, DE_LENGTH_OF_ARRAY(s_basicCoords))); 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Vec2& bottomLeft = s_basicCoords[cellNdx].bottomLeft; 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Vec2& topRight = s_basicCoords[cellNdx].topRight; 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeQuadTexCoord2D(dst, bottomLeft, topRight); 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void getAffineTexCoord2D (std::vector<float>& dst, int cellNdx) 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Use basic coords as base. 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry getBasicTexCoord2D(dst, cellNdx); 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Rotate based on cell index. 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float angle = 2.0f*DE_PI * ((float)cellNdx / 16.0f); 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Mat2 rotMatrix = tcu::rotationMatrix(angle); 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Second and third row are sheared. 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float shearX = de::inRange(cellNdx, 4, 11) ? (float)(15-cellNdx) / 16.0f : 0.0f; 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Mat2 shearMatrix = tcu::shearMatrix(tcu::Vec2(shearX, 0.0f)); 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Mat2 transform = rotMatrix * shearMatrix; 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec2 p0 = transform * Vec2(dst[0], dst[1]); 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec2 p1 = transform * Vec2(dst[2], dst[3]); 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec2 p2 = transform * Vec2(dst[4], dst[5]); 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec2 p3 = transform * Vec2(dst[6], dst[7]); 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[0] = p0.x(); dst[1] = p0.y(); 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[2] = p1.x(); dst[3] = p1.y(); 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[4] = p2.x(); dst[5] = p2.y(); 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[6] = p3.x(); dst[7] = p3.y(); 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2443c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTexture2DMipmapCase::IterateResult Texture2DMipmapCase::iterate (void) 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Constants. 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 magFilter = GL_NEAREST; 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Texture2D& refTexture = m_texture->getRefTexture(); 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::TextureFormat& texFmt = refTexture.getFormat(); 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureFormatInfo fmtInfo = tcu::getTextureFormatInfo(texFmt); 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int texWidth = refTexture.getWidth(); 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int texHeight = refTexture.getHeight(); 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int defViewportWidth = texWidth*4; 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int defViewportHeight = texHeight*4; 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomViewport viewport (m_renderCtx.getRenderTarget(), defViewportWidth, defViewportHeight, deStringHash(getName())); 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceParams sampleParams (TEXTURETYPE_2D); 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<float> texCoord; 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isProjected = m_coordType == COORDTYPE_PROJECTED; 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool useLodBias = m_coordType == COORDTYPE_BASIC_BIAS; 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedFrame (viewport.width, viewport.height); 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Accuracy cases test against ideal lod computation. 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface idealFrame (viewport.width, viewport.height); 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Viewport is divided into 4x4 grid. 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int gridWidth = 4; 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int gridHeight = 4; 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int cellWidth = viewport.width / gridWidth; 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int cellHeight = viewport.height / gridHeight; 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Accuracy measurements are off unless we get the expected viewport size. 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (viewport.width < defViewportWidth || viewport.height < defViewportHeight) 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__); 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Sampling parameters. 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleParams.sampler = glu::mapGLSampler(m_wrapS, m_wrapT, m_minFilter, magFilter); 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleParams.samplerType = gls::TextureTestUtil::getSamplerType(m_texture->getRefTexture().getFormat()); 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleParams.colorBias = fmtInfo.lookupBias; 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleParams.colorScale = fmtInfo.lookupScale; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleParams.flags = (isProjected ? ReferenceParams::PROJECTED : 0) | (useLodBias ? ReferenceParams::USE_BIAS : 0); 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Upload texture data. 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->upload(); 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Use unit 0. 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.activeTexture(GL_TEXTURE0); 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bind gradient texture and setup sampler parameters. 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture()); 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_wrapS); 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_wrapT); 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_minFilter); 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "After texture setup"); 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bias values. 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float s_bias[] = { 1.0f, -2.0f, 0.8f, -0.5f, 1.5f, 0.9f, 2.0f, 4.0f }; 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Projection values. 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const Vec4 s_projections[] = 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(1.2f, 1.0f, 0.7f, 1.0f), 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(1.3f, 0.8f, 0.6f, 2.0f), 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(0.8f, 1.0f, 1.7f, 0.6f), 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(1.2f, 1.0f, 1.7f, 1.5f) 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render cells. 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int gridY = 0; gridY < gridHeight; gridY++) 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int gridX = 0; gridX < gridWidth; gridX++) 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int curX = cellWidth*gridX; 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int curY = cellHeight*gridY; 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int curW = gridX+1 == gridWidth ? (viewport.width-curX) : cellWidth; 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int curH = gridY+1 == gridHeight ? (viewport.height-curY) : cellHeight; 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int cellNdx = gridY*gridWidth + gridX; 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compute texcoord. 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_coordType) 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case COORDTYPE_BASIC_BIAS: // Fall-through. 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case COORDTYPE_PROJECTED: 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case COORDTYPE_BASIC: getBasicTexCoord2D (texCoord, cellNdx); break; 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case COORDTYPE_AFFINE: getAffineTexCoord2D (texCoord, cellNdx); break; 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: DE_ASSERT(DE_FALSE); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isProjected) 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleParams.w = s_projections[cellNdx % DE_LENGTH_OF_ARRAY(s_projections)]; 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (useLodBias) 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleParams.bias = s_bias[cellNdx % DE_LENGTH_OF_ARRAY(s_bias)]; 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render with GL. 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(viewport.x+curX, viewport.y+curY, curW, curH); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.renderQuad(0, &texCoord[0], sampleParams); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render reference(s). 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SurfaceAccess idealDst(idealFrame, m_renderCtx.getRenderTarget().getPixelFormat(), curX, curY, curW, curH); 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleParams.lodMode = LODMODE_EXACT; 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleTexture(idealDst, m_texture->getRefTexture(), &texCoord[0], sampleParams); 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Read result. 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess()); 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare and log. 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bestScoreDiff = (texWidth/16)*(texHeight/16); 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int worstScoreDiff = texWidth*texHeight; 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int score = measureAccuracy(log, idealFrame, renderedFrame, bestScoreDiff, worstScoreDiff); 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::toString(score).c_str()); 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TextureCubeMipmapCase 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeMipmapCase : public tcu::TestCase 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeMipmapCase (tcu::TestContext& testCtx, 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& renderCtx, 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& renderCtxInfo, 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* desc, 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CoordType coordType, 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 minFilter, 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 wrapS, 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 wrapT, 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format, 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 dataType, 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int size); 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TextureCubeMipmapCase (void); 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeMipmapCase (const TextureCubeMipmapCase& other); 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeMipmapCase& operator= (const TextureCubeMipmapCase& other); 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& m_renderCtxInfo; 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CoordType m_coordType; 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_minFilter; 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_wrapS; 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_wrapT; 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_format; 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_dataType; 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_size; 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::TextureCube* m_texture; 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureRenderer m_renderer; 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4143c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeMipmapCase::TextureCubeMipmapCase (tcu::TestContext& testCtx, 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& renderCtx, 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::ContextInfo& renderCtxInfo, 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* desc, 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CoordType coordType, 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 minFilter, 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 wrapS, 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 wrapT, 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 format, 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 dataType, 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int size) 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (testCtx, tcu::NODETYPE_ACCURACY, name, desc) 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtxInfo (renderCtxInfo) 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_coordType (coordType) 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_minFilter (minFilter) 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapS (wrapS) 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_wrapT (wrapT) 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_format (format) 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dataType (dataType) 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_size (size) 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_texture (DE_NULL) 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderer (renderCtx, testCtx, glu::GLSL_VERSION_100_ES, 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderCtxInfo.isFragmentHighPrecisionSupported() ? glu::PRECISION_HIGHP // Use highp if available. 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : glu::PRECISION_MEDIUMP) 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4433c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeMipmapCase::~TextureCubeMipmapCase (void) 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeMipmapCase::init (void) 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_renderCtxInfo.isFragmentHighPrecisionSupported()) 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << TestLog::Message << "Warning: High precision not supported in fragment shaders." << TestLog::EndMessage; 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = new TextureCube(m_renderCtx, m_format, m_dataType, m_size); 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numLevels = deLog2Floor32(m_size)+1; 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Fill texture with colored grid. 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int faceNdx = 0; faceNdx < tcu::CUBEFACE_LAST; faceNdx++) 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int levelNdx = 0; levelNdx < numLevels; levelNdx++) 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 step = 0xff / (numLevels-1); 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 inc = deClamp32(step*levelNdx, 0x00, 0xff); 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 dec = 0xff - inc; 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 rgb = 0; 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (faceNdx) 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: rgb = (inc << 16) | (dec << 8) | 255; break; 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: rgb = (255 << 16) | (inc << 8) | dec; break; 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: rgb = (dec << 16) | (255 << 8) | inc; break; 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 3: rgb = (dec << 16) | (inc << 8) | 255; break; 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 4: rgb = (255 << 16) | (dec << 8) | inc; break; 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 5: rgb = (inc << 16) | (255 << 8) | dec; break; 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 color = 0xff000000 | rgb; 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->getRefTexture().allocLevel((tcu::CubeFace)faceNdx, levelNdx); 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::clear(m_texture->getRefTexture().getLevelFace(levelNdx, (tcu::CubeFace)faceNdx), toVec4(tcu::RGBA(color))); 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureCubeMipmapCase::deinit (void) 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_texture; 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture = DE_NULL; 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.clear(); 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void randomPartition (vector<IVec4>& dst, de::Random& rnd, int x, int y, int width, int height) 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int minWidth = 8; 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int minHeight = 8; 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool partition = rnd.getFloat() > 0.4f; 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool partitionX = partition && width > minWidth && rnd.getBool(); 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool partitionY = partition && height > minHeight && !partitionX; 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (partitionX) 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int split = width/2 + rnd.getInt(-width/4, +width/4); 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry randomPartition(dst, rnd, x, y, split, height); 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry randomPartition(dst, rnd, x+split, y, width-split, height); 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (partitionY) 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int split = height/2 + rnd.getInt(-height/4, +height/4); 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry randomPartition(dst, rnd, x, y, width, split); 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry randomPartition(dst, rnd, x, y+split, width, height-split); 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.push_back(IVec4(x, y, width, height)); 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void computeGridLayout (vector<IVec4>& dst, int width, int height) 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd(7); 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry randomPartition(dst, rnd, 0, 0, width, height); 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5243c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureCubeMipmapCase::IterateResult TextureCubeMipmapCase::iterate (void) 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Constants. 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 magFilter = GL_NEAREST; 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int texWidth = m_texture->getRefTexture().getSize(); 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int texHeight = m_texture->getRefTexture().getSize(); 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int defViewportWidth = texWidth*2; 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int defViewportHeight = texHeight*2; 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomViewport viewport (m_renderCtx.getRenderTarget(), defViewportWidth, defViewportHeight, deStringHash(getName())); 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Sampler sampler = mapGLSampler(m_wrapS, m_wrapT, m_minFilter, magFilter); 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<float> texCoord; 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isProjected = m_coordType == COORDTYPE_PROJECTED; 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool useLodBias = m_coordType == COORDTYPE_BASIC_BIAS; 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedFrame (viewport.width, viewport.height); 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Accuracy cases test against ideal lod computation. 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface idealFrame (viewport.width, viewport.height); 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Accuracy measurements are off unless we get the expected viewport size. 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (viewport.width < defViewportWidth || viewport.height < defViewportHeight) 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Too small viewport", "", __FILE__, __LINE__); 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Upload texture data. 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_texture->upload(); 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Use unit 0. 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.activeTexture(GL_TEXTURE0); 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bind gradient texture and setup sampler parameters. 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture()); 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, m_wrapS); 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, m_wrapT); 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, m_minFilter); 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, magFilter); 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "After texture setup"); 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compute grid. 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<IVec4> gridLayout; 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeGridLayout(gridLayout, viewport.width, viewport.height); 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Bias values. 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float s_bias[] = { 1.0f, -2.0f, 0.8f, -0.5f, 1.5f, 0.9f, 2.0f, 4.0f }; 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Projection values \note Less agressive than in 2D case due to smaller quads. 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const Vec4 s_projections[] = 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(1.2f, 1.0f, 0.7f, 1.0f), 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(1.3f, 0.8f, 0.6f, 1.1f), 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(0.8f, 1.0f, 1.2f, 0.8f), 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4(1.2f, 1.0f, 1.3f, 0.9f) 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int cellNdx = 0; cellNdx < (int)gridLayout.size(); cellNdx++) 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int curX = gridLayout[cellNdx].x(); 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int curY = gridLayout[cellNdx].y(); 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int curW = gridLayout[cellNdx].z(); 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int curH = gridLayout[cellNdx].w(); 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::CubeFace cubeFace = (tcu::CubeFace)(cellNdx % tcu::CUBEFACE_LAST); 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceParams params (TEXTURETYPE_CUBE); 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry params.sampler = sampler; 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_coordType != COORDTYPE_AFFINE); // Not supported. 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeQuadTexCoordCube(texCoord, cubeFace); 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isProjected) 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry params.flags |= ReferenceParams::PROJECTED; 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry params.w = s_projections[cellNdx % DE_LENGTH_OF_ARRAY(s_projections)]; 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (useLodBias) 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry params.flags |= ReferenceParams::USE_BIAS; 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry params.bias = s_bias[cellNdx % DE_LENGTH_OF_ARRAY(s_bias)]; 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render with GL. 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(viewport.x+curX, viewport.y+curY, curW, curH); 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer.renderQuad(0, &texCoord[0], params); 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render reference(s). 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SurfaceAccess idealDst(idealFrame, m_renderCtx.getRenderTarget().getPixelFormat(), curX, curY, curW, curH); 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry params.lodMode = LODMODE_EXACT; 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleTexture(idealDst, m_texture->getRefTexture(), &texCoord[0], params); 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Read result. 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess()); 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare and log. 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bestScoreDiff = (texWidth/16)*(texHeight/16); 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int worstScoreDiff = texWidth*texHeight; 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int score = measureAccuracy(log, idealFrame, renderedFrame, bestScoreDiff, worstScoreDiff); 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::toString(score).c_str()); 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6383c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureMipmapTests::TextureMipmapTests (Context& context) 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "mipmap", "Mipmapping accuracy tests") 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6433c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTextureMipmapTests::~TextureMipmapTests (void) 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TextureMipmapTests::init (void) 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* group2D = new tcu::TestCaseGroup(m_testCtx, "2d", "2D Texture Mipmapping"); 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* groupCube = new tcu::TestCaseGroup(m_testCtx, "cube", "Cube Map Filtering"); 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(group2D); 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(groupCube); 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 mode; 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } wrapModes[] = 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "clamp", GL_CLAMP_TO_EDGE }, 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "repeat", GL_REPEAT }, 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "mirror", GL_MIRRORED_REPEAT } 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 mode; 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } minFilterModes[] = 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "nearest_nearest", GL_NEAREST_MIPMAP_NEAREST }, 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "linear_nearest", GL_LINEAR_MIPMAP_NEAREST }, 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "nearest_linear", GL_NEAREST_MIPMAP_LINEAR }, 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "linear_linear", GL_LINEAR_MIPMAP_LINEAR } 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CoordType type; 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* desc; 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } coordTypes[] = 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { COORDTYPE_BASIC, "basic", "Mipmapping with translated and scaled coordinates" }, 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { COORDTYPE_AFFINE, "affine", "Mipmapping with affine coordinate transform" }, 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { COORDTYPE_PROJECTED, "projected", "Mipmapping with perspective projection" } 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int tex2DWidth = 64; 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int tex2DHeight = 64; 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // 2D cases. 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int coordType = 0; coordType < DE_LENGTH_OF_ARRAY(coordTypes); coordType++) 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* coordTypeGroup = new tcu::TestCaseGroup(m_testCtx, coordTypes[coordType].name, coordTypes[coordType].desc); 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group2D->addChild(coordTypeGroup); 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int minFilter = 0; minFilter < DE_LENGTH_OF_ARRAY(minFilterModes); minFilter++) 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int wrapMode = 0; wrapMode < DE_LENGTH_OF_ARRAY(wrapModes); wrapMode++) 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::ostringstream name; 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name << minFilterModes[minFilter].name 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "_" << wrapModes[wrapMode].name; 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coordTypeGroup->addChild(new Texture2DMipmapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name.str().c_str(), "", 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coordTypes[coordType].type, 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry minFilterModes[minFilter].mode, 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapMode].mode, 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapModes[wrapMode].mode, 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RGBA, GL_UNSIGNED_BYTE, 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tex2DWidth, tex2DHeight)); 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int cubeMapSize = 64; 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CoordType type; 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* desc; 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } cubeCoordTypes[] = 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { COORDTYPE_BASIC, "basic", "Mipmapping with translated and scaled coordinates" }, 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { COORDTYPE_PROJECTED, "projected", "Mipmapping with perspective projection" } 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Cubemap cases. 7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int coordType = 0; coordType < DE_LENGTH_OF_ARRAY(cubeCoordTypes); coordType++) 7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* coordTypeGroup = new tcu::TestCaseGroup(m_testCtx, cubeCoordTypes[coordType].name, cubeCoordTypes[coordType].desc); 7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groupCube->addChild(coordTypeGroup); 7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int minFilter = 0; minFilter < DE_LENGTH_OF_ARRAY(minFilterModes); minFilter++) 7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coordTypeGroup->addChild(new TextureCubeMipmapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), 7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry minFilterModes[minFilter].name, "", 7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cubeCoordTypes[coordType].type, 7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry minFilterModes[minFilter].mode, 7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_CLAMP_TO_EDGE, 7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_CLAMP_TO_EDGE, 7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RGBA, GL_UNSIGNED_BYTE, cubeMapSize)); 7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Accuracy 7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 753