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