tcuTexture.hpp revision 6c307165131fb7249bb044fc79ff0c2747263b3d
13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _TCUTEXTURE_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _TCUTEXTURE_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Tester Core 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ---------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Reference Texture Implementation. 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deArrayBuffer.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <ostream> 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Texture format 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureFormat 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum ChannelOrder 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry R = 0, 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry A, 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry I, 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry L, 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LA, 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RG, 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RA, 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGB, 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RGBA, 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ARGB, 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BGRA, 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5616d404b8653856a3a402c67c36425e24afe456adJarkko Pöyry sR, 5716d404b8653856a3a402c67c36425e24afe456adJarkko Pöyry sRG, 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sRGB, 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sRGBA, 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry D, 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry S, 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DS, 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CHANNELORDER_LAST 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum ChannelType 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SNORM_INT8 = 0, 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SNORM_INT16, 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SNORM_INT32, 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNORM_INT8, 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNORM_INT16, 7507104dfa13013a73a59a93cbd8d132254a5a171dJarkko Pöyry UNORM_INT24, 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNORM_INT32, 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNORM_SHORT_565, 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNORM_SHORT_555, 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNORM_SHORT_4444, 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNORM_SHORT_5551, 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNORM_INT_101010, 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNORM_INT_1010102_REV, 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNSIGNED_INT_1010102_REV, 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNSIGNED_INT_11F_11F_10F_REV, 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNSIGNED_INT_999_E5_REV, 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNSIGNED_INT_24_8, 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SIGNED_INT8, 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SIGNED_INT16, 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SIGNED_INT32, 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNSIGNED_INT8, 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNSIGNED_INT16, 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNSIGNED_INT32, 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry HALF_FLOAT, 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLOAT, 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLOAT_UNSIGNED_INT_24_8_REV, 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CHANNELTYPE_LAST 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ChannelOrder order; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ChannelType type; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureFormat (ChannelOrder order_, ChannelType type_) 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : order (order_) 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , type (type_) 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureFormat (void) 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : order (CHANNELORDER_LAST) 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , type (CHANNELTYPE_LAST) 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getPixelSize (void) const; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool operator== (const TextureFormat& other) const { return !(*this != other); } 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool operator!= (const TextureFormat& other) const 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (order != other.order || type != other.type); 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12293df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 1256d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry * \brief Texture swizzle 1266d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry *//*--------------------------------------------------------------------*/ 1276d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyrystruct TextureSwizzle 1286d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry{ 1296d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry enum Channel 1306d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry { 1316d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry // \note CHANNEL_N must equal int N 1326d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry CHANNEL_0 = 0, 1336d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry CHANNEL_1, 1346d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry CHANNEL_2, 1356d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry CHANNEL_3, 1366d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry 1376d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry CHANNEL_ZERO, 1386d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry CHANNEL_ONE, 1396d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry 1406d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry CHANNEL_LAST 1416d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry }; 1426d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry 1436d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry Channel components[4]; 1446d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry}; 1456d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry 1466d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry//! get the swizzle used to expand texture data with a given channel order to RGBA form 1476d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyryconst TextureSwizzle& getChannelReadSwizzle (TextureFormat::ChannelOrder order); 1486d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry 1496d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry//! get the swizzle used to narrow RGBA form data to native texture data with a given channel order 1506d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyryconst TextureSwizzle& getChannelWriteSwizzle (TextureFormat::ChannelOrder order); 1516d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry 1526d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry/*--------------------------------------------------------------------*//*! 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Sampling parameters 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Sampler 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum WrapMode 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CLAMP_TO_EDGE = 0, //! Clamp to edge 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CLAMP_TO_BORDER, //! Use border color at edge 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry REPEAT_GL, //! Repeat with OpenGL semantics 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry REPEAT_CL, //! Repeat with OpenCL semantics 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MIRRORED_REPEAT_GL, //! Mirrored repeat with OpenGL semantics 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MIRRORED_REPEAT_CL, //! Mirrored repeat with OpenCL semantics 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry WRAPMODE_LAST 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum FilterMode 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NEAREST = 0, 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LINEAR, 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NEAREST_MIPMAP_NEAREST, 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NEAREST_MIPMAP_LINEAR, 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LINEAR_MIPMAP_NEAREST, 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LINEAR_MIPMAP_LINEAR, 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FILTERMODE_LAST 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum CompareMode 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_NONE = 0, 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_LESS, 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_LESS_OR_EQUAL, 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_GREATER, 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_GREATER_OR_EQUAL, 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_EQUAL, 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_NOT_EQUAL, 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_ALWAYS, 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_NEVER, 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry COMPAREMODE_LAST 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Wrap control 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry WrapMode wrapS; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry WrapMode wrapT; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry WrapMode wrapR; 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Minifcation & magnification 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterMode minFilter; 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterMode magFilter; 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float lodThreshold; // lod <= lodThreshold ? magnified : minified 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Coordinate normalization 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool normalizedCoords; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Shadow comparison 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CompareMode compare; 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int compareChannel; 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Border color 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 borderColor; 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Seamless cube map filtering 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool seamlessCubeMap; 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Sampler (WrapMode wrapS_, 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry WrapMode wrapT_, 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry WrapMode wrapR_, 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterMode minFilter_, 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FilterMode magFilter_, 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float lodThreshold_ = 0.0f, 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool normalizedCoords_ = true, 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CompareMode compare_ = COMPAREMODE_NONE, 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int compareChannel_ = 0, 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Vec4& borderColor_ = Vec4(0.0f, 0.0f, 0.0f, 0.0f), 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool seamlessCubeMap_ = false) 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : wrapS (wrapS_) 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , wrapT (wrapT_) 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , wrapR (wrapR_) 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , minFilter (minFilter_) 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , magFilter (magFilter_) 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , lodThreshold (lodThreshold_) 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , normalizedCoords (normalizedCoords_) 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , compare (compare_) 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , compareChannel (compareChannel_) 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , borderColor (borderColor_) 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , seamlessCubeMap (seamlessCubeMap_) 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Sampler (void) 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : wrapS (WRAPMODE_LAST) 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , wrapT (WRAPMODE_LAST) 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , wrapR (WRAPMODE_LAST) 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , minFilter (FILTERMODE_LAST) 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , magFilter (FILTERMODE_LAST) 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , lodThreshold (0.0f) 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , normalizedCoords (true) 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , compare (COMPAREMODE_NONE) 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , compareChannel (0) 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , borderColor (0.0f, 0.0f, 0.0f, 0.0f) 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , seamlessCubeMap (false) 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 26093df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26229340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi// Calculate pitches for pixel data with no padding. 26329340067e919854db7d50bb8c0b666117b229f5eMika IsojärviIVec3 calculatePackedPitch (const TextureFormat& format, const IVec3& size); 26429340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureLevel; 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Read-only pixel data access 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ConstPixelBufferAccess encapsulates pixel data pointer along with 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * format and layout information. It can be used for read-only access 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * to arbitrary pixel buffers. 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Access objects are like iterators or pointers. They can be passed around 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * as values and are valid as long as the storage doesn't change. 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ConstPixelBufferAccess 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ConstPixelBufferAccess (void); 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ConstPixelBufferAccess (const TextureLevel& level); 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ConstPixelBufferAccess (const TextureFormat& format, int width, int height, int depth, const void* data); 28329340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi ConstPixelBufferAccess (const TextureFormat& format, const IVec3& size, const void* data); 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ConstPixelBufferAccess (const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, const void* data); 28529340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi ConstPixelBufferAccess (const TextureFormat& format, const IVec3& size, const IVec3& pitch, const void* data); 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28729340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi const TextureFormat& getFormat (void) const { return m_format; } 28829340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi const IVec3& getSize (void) const { return m_size; } 28929340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi int getWidth (void) const { return m_size.x(); } 29029340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi int getHeight (void) const { return m_size.y(); } 29129340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi int getDepth (void) const { return m_size.z(); } 2926c307165131fb7249bb044fc79ff0c2747263b3dJarkko Pöyry int getPixelPitch (void) const { return m_pitch.x(); } 29329340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi int getRowPitch (void) const { return m_pitch.y(); } 29429340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi int getSlicePitch (void) const { return m_pitch.z(); } 2956c307165131fb7249bb044fc79ff0c2747263b3dJarkko Pöyry const IVec3& getPitch (void) const { return m_pitch; } 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29729340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi const void* getDataPtr (void) const { return m_data; } 29829340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi int getDataSize (void) const { return m_size.z()*m_pitch.z(); } 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3006c307165131fb7249bb044fc79ff0c2747263b3dJarkko Pöyry const void* getPixelPtr (int x, int y, int z = 0) const { return (const deUint8*)m_data + x * m_pitch.x() + y * m_pitch.y() + z * m_pitch.z(); } 3016c307165131fb7249bb044fc79ff0c2747263b3dJarkko Pöyry 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 getPixel (int x, int y, int z = 0) const; 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IVec4 getPixelInt (int x, int y, int z = 0) const; 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UVec4 getPixelUint (int x, int y, int z = 0) const { return getPixelInt(x, y, z).cast<deUint32>(); } 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry template<typename T> 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vector<T, 4> getPixelT (int x, int y, int z = 0) const; 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float getPixDepth (int x, int y, int z = 0) const; 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getPixStencil (int x, int y, int z = 0) const; 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample1D (const Sampler& sampler, Sampler::FilterMode filter, float s, int level) const; 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample2D (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, int depth) const; 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample3D (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, float r) const; 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample1DOffset (const Sampler& sampler, Sampler::FilterMode filter, float s, const IVec2& offset) const; 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample2DOffset (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, const IVec3& offset) const; 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample3DOffset (const Sampler& sampler, Sampler::FilterMode filter, float s, float t, float r, const IVec3& offset) const; 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sample1DCompare (const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, const IVec2& offset) const; 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sample2DCompare (const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, float t, const IVec3& offset) const; 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureFormat m_format; 32529340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi IVec3 m_size; 32629340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi IVec3 m_pitch; //!< (pixelPitch, rowPitch, slicePitch) 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mutable void* m_data; 32893df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Read-write pixel data access 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * This class extends read-only access object by providing write functionality. 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \note PixelBufferAccess may not have any data members nor add any 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * virtual functions. It must be possible to reinterpret_cast<> 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * PixelBufferAccess to ConstPixelBufferAccess. 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PixelBufferAccess : public ConstPixelBufferAccess 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 342becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi PixelBufferAccess (void) {} 343becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi PixelBufferAccess (TextureLevel& level); 344becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi PixelBufferAccess (const TextureFormat& format, int width, int height, int depth, void* data); 34529340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi PixelBufferAccess (const TextureFormat& format, const IVec3& size, void* data); 346becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi PixelBufferAccess (const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, void* data); 34729340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi PixelBufferAccess (const TextureFormat& format, const IVec3& size, const IVec3& pitch, void* data); 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 349becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void* getDataPtr (void) const { return m_data; } 3506c307165131fb7249bb044fc79ff0c2747263b3dJarkko Pöyry void* getPixelPtr (int x, int y, int z = 0) const { return (deUint8*)m_data + x * m_pitch.x() + y * m_pitch.y() + z * m_pitch.z(); } 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 352becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void setPixels (const void* buf, int bufSize) const; 353becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void setPixel (const tcu::Vec4& color, int x, int y, int z = 0) const; 354becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void setPixel (const tcu::IVec4& color, int x, int y, int z = 0) const; 355becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void setPixel (const tcu::UVec4& color, int x, int y, int z = 0) const { setPixel(color.cast<int>(), x, y, z); } 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 357becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void setPixDepth (float depth, int x, int y, int z = 0) const; 358becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void setPixStencil (int stencil, int x, int y, int z = 0) const; 35993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Generic pixel data container 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * This container supports all valid TextureFormat combinations and 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * both 2D and 3D textures. To read or manipulate data access object must 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * be queried using getAccess(). 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureLevel 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 371becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi TextureLevel (void); 372becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi TextureLevel (const TextureFormat& format); 373becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi TextureLevel (const TextureFormat& format, int width, int height, int depth = 1); 374becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi ~TextureLevel (void); 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37629340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi const IVec3& getSize (void) const { return m_size; } 37729340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi int getWidth (void) const { return m_size.x(); } 37829340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi int getHeight (void) const { return m_size.y(); } 37929340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi int getDepth (void) const { return m_size.z(); } 38029340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi bool isEmpty (void) const { return m_size.x() * m_size.y() * m_size.z() == 0; } 381becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi const TextureFormat getFormat (void) const { return m_format; } 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void setStorage (const TextureFormat& format, int width, int heigth, int depth = 1); 384becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void setSize (int width, int height, int depth = 1); 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38629340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi PixelBufferAccess getAccess (void) { return PixelBufferAccess(m_format, m_size, calculatePackedPitch(m_format, m_size), getPtr()); } 38729340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi ConstPixelBufferAccess getAccess (void) const { return ConstPixelBufferAccess(m_format, m_size, calculatePackedPitch(m_format, m_size), getPtr()); } 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 390becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi void* getPtr (void) { return m_data.getPtr(); } 391becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi const void* getPtr (void) const { return m_data.getPtr(); } 392becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi 393becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi TextureFormat m_format; 39429340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi IVec3 m_size; 395becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi de::ArrayBuffer<deUint8> m_data; 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry friend class ConstPixelBufferAccess; 39893df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4003c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4 sampleLevelArray1D (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, int level, float lod); 4013c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4 sampleLevelArray2D (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, int depth, float lod); 4023c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4 sampleLevelArray3D (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float r, float lod); 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4043c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4 sampleLevelArray1DOffset (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float lod, const IVec2& offset); 4053c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4 sampleLevelArray2DOffset (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float lod, const IVec3& offset); 4063c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4 sampleLevelArray3DOffset (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset); 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryfloat sampleLevelArray1DCompare (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float ref, float s, float lod, const IVec2& offset); 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryfloat sampleLevelArray2DCompare (const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float ref, float s, float t, float lod, const IVec3& offset); 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4113c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4 gatherArray2DOffsets (const ConstPixelBufferAccess& src, const Sampler& sampler, float s, float t, int depth, int componentNdx, const IVec2 (&offsets)[4]); 4123c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4 gatherArray2DOffsetsCompare (const ConstPixelBufferAccess& src, const Sampler& sampler, float ref, float s, float t, int depth, const IVec2 (&offsets)[4]); 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum CubeFace 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CUBEFACE_NEGATIVE_X = 0, 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CUBEFACE_POSITIVE_X, 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CUBEFACE_NEGATIVE_Y, 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CUBEFACE_POSITIVE_Y, 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CUBEFACE_NEGATIVE_Z, 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CUBEFACE_POSITIVE_Z, 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CUBEFACE_LAST 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Coordinates projected onto cube face. 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename T> 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct CubeFaceCoords 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CubeFace face; 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry T s; 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry T t; 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CubeFaceCoords (CubeFace face_, T s_, T t_) : face(face_), s(s_), t(t_) {} 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CubeFaceCoords (CubeFace face_, const Vector<T, 2>& c) : face(face_), s(c.x()), t(c.y()) {} 43893df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef CubeFaceCoords<float> CubeFaceFloatCoords; 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef CubeFaceCoords<int> CubeFaceIntCoords; 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4433c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCubeFace selectCubeFace (const Vec3& coords); 4443c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec2 projectToFace (CubeFace face, const Vec3& coords); 4453c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCubeFaceFloatCoords getCubeFaceCoords (const Vec3& coords); 4463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCubeFaceIntCoords remapCubeEdgeCoords (const CubeFaceIntCoords& coords, int size); 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 1D Texture View 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1DView 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1DView (int numLevels, const ConstPixelBufferAccess* levels); 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLevels (void) const { return m_numLevels; } 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_numLevels > 0 ? m_levels[0].getWidth() : 0; } 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess& getLevel (int ndx) const { DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx]; } 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* getLevels (void) const { return m_levels; } 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float lod) const; 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float lod, deInt32 offset) const; 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float lod) const; 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompareOffset (const Sampler& sampler, float ref, float s, float lod, deInt32 offset) const; 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numLevels; 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* m_levels; 46993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Texture1DView::Texture1DView (int numLevels, const ConstPixelBufferAccess* levels) 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_numLevels (numLevels) 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_levels (levels) 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_numLevels >= 0 && ((m_numLevels == 0) == !m_levels)); 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1DView::sample (const Sampler& sampler, float s, float lod) const 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray1D(m_levels, m_numLevels, sampler, s, 0 /* depth */, lod); 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1DView::sampleOffset (const Sampler& sampler, float s, float lod, deInt32 offset) const 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray1DOffset(m_levels, m_numLevels, sampler, s, lod, IVec2(offset, 0)); 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture1DView::sampleCompare (const Sampler& sampler, float ref, float s, float lod) const 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray1DCompare(m_levels, m_numLevels, sampler, ref, s, lod, IVec2(0, 0)); 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture1DView::sampleCompareOffset (const Sampler& sampler, float ref, float s, float lod, deInt32 offset) const 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray1DCompare(m_levels, m_numLevels, sampler, ref, s, lod, IVec2(offset, 0)); 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 2D Texture View 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DView 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DView (int numLevels, const ConstPixelBufferAccess* levels); 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLevels (void) const { return m_numLevels; } 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_numLevels > 0 ? m_levels[0].getWidth() : 0; } 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getHeight (void) const { return m_numLevels > 0 ? m_levels[0].getHeight() : 0; } 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess& getLevel (int ndx) const { DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx]; } 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* getLevels (void) const { return m_levels; } 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float lod) const; 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const; 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const; 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const; 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherOffsets (const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const; 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const; 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numLevels; 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* m_levels; 52393df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Texture2DView::Texture2DView (int numLevels, const ConstPixelBufferAccess* levels) 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_numLevels (numLevels) 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_levels (levels) 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_numLevels >= 0 && ((m_numLevels == 0) == !m_levels)); 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DView::sample (const Sampler& sampler, float s, float t, float lod) const 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray2D(m_levels, m_numLevels, sampler, s, t, 0 /* depth */, lod); 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DView::sampleOffset (const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray2DOffset(m_levels, m_numLevels, sampler, s, t, lod, IVec3(offset.x(), offset.y(), 0)); 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2DView::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray2DCompare(m_levels, m_numLevels, sampler, ref, s, t, lod, IVec3(0, 0, 0)); 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2DView::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray2DCompare(m_levels, m_numLevels, sampler, ref, s, t, lod, IVec3(offset.x(), offset.y(), 0)); 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DView::gatherOffsets (const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return gatherArray2DOffsets(m_levels[0], sampler, s, t, 0, componentNdx, offsets); 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DView::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return gatherArray2DOffsetsCompare(m_levels[0], sampler, ref, s, t, 0, offsets); 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Base class for textures that have single mip-map pyramid 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureLevelPyramid 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureLevelPyramid (const TextureFormat& format, int numLevels); 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureLevelPyramid (const TextureLevelPyramid& other); 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TextureLevelPyramid(void); 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TextureFormat& getFormat (void) const { return m_format; } 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isLevelEmpty (int levelNdx) const { return m_data[levelNdx].empty(); } 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLevels (void) const { return (int)m_access.size(); } 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess& getLevel (int ndx) const { return m_access[ndx]; } 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const PixelBufferAccess& getLevel (int ndx) { return m_access[ndx]; } 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* getLevels (void) const { return &m_access[0]; } 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const PixelBufferAccess* getLevels (void) { return &m_access[0]; } 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocLevel (int levelNdx, int width, int height, int depth); 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void clearLevel (int levelNdx); 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureLevelPyramid& operator= (const TextureLevelPyramid& other); 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef de::ArrayBuffer<deUint8> LevelData; 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureFormat m_format; 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<LevelData> m_data; 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<PixelBufferAccess> m_access; 59393df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 1D Texture reference implementation 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1D : private TextureLevelPyramid 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1D (const TextureFormat& format, int width); 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1D (const Texture1D& other); 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Texture1D (void); 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_width; } 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Texture1DView& getView (void) const { return m_view; } 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocLevel (int levelNdx); 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Sampling 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float lod) const; 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float lod, deInt32 offset) const; 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getFormat; 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getNumLevels; 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getLevel; 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::clearLevel; 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::isLevelEmpty; 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1D& operator= (const Texture1D& other); 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry operator Texture1DView (void) const { return m_view; } 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_width; 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1DView m_view; 62793df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1D::sample (const Sampler& sampler, float s, float lod) const 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sample(sampler, s, lod); 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1D::sampleOffset (const Sampler& sampler, float s, float lod, deInt32 offset) const 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleOffset(sampler, s, lod, offset); 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 2D Texture reference implementation 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2D : private TextureLevelPyramid 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2D (const TextureFormat& format, int width, int height); 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2D (const Texture2D& other); 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Texture2D (void); 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_width; } 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getHeight (void) const { return m_height; } 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Texture2DView& getView (void) const { return m_view; } 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocLevel (int levelNdx); 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Sampling 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float lod) const; 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const; 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const; 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const; 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherOffsets (const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const; 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const; 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getFormat; 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getNumLevels; 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getLevel; 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::clearLevel; 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::isLevelEmpty; 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2D& operator= (const Texture2D& other); 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry operator Texture2DView (void) const { return m_view; } 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_width; 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_height; 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DView m_view; 67893df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2D::sample (const Sampler& sampler, float s, float t, float lod) const 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sample(sampler, s, t, lod); 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2D::sampleOffset (const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleOffset(sampler, s, t, lod, offset); 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2D::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleCompare(sampler, ref, s, t, lod); 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2D::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleCompareOffset(sampler, ref, s, t, lod, offset); 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2D::gatherOffsets (const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.gatherOffsets(sampler, s, t, componentNdx, offsets); 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2D::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.gatherOffsetsCompare(sampler, ref, s, t, offsets); 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Cube Map Texture View 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeView 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeView (void); 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeView (int numLevels, const ConstPixelBufferAccess* const (&levels)[CUBEFACE_LAST]); 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLevels (void) const { return m_numLevels; } 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getSize (void) const { return m_numLevels > 0 ? m_levels[0][0].getWidth() : 0; } 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess& getLevelFace (int ndx, CubeFace face) const { DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[face][ndx]; } 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* getFaceLevels (CubeFace face) const { return m_levels[face]; } 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float p, float lod) const; 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const; 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gather (const Sampler& sampler, float s, float t, float r, int componentNdx) const; 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherCompare (const Sampler& sampler, float ref, float s, float t, float r) const; 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numLevels; 7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* m_levels[CUBEFACE_LAST]; 73393df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Cube Map Texture reference implementation 7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCube 7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCube (const TextureFormat& format, int size); 7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCube (const TextureCube& other); 7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TextureCube (void); 7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TextureFormat& getFormat (void) const { return m_format; } 7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getSize (void) const { return m_size; } 7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLevels (void) const { return (int)m_access[0].size(); } 7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess& getLevelFace (int ndx, CubeFace face) const { return m_access[face][ndx]; } 7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const PixelBufferAccess& getLevelFace (int ndx, CubeFace face) { return m_access[face][ndx]; } 7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocLevel (CubeFace face, int levelNdx); 7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void clearLevel (CubeFace face, int levelNdx); 7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isLevelEmpty (CubeFace face, int levelNdx) const { return m_data[face][levelNdx].empty(); } 7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float p, float lod) const; 7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const; 7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gather (const Sampler& sampler, float s, float t, float r, int componentNdx) const; 7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherCompare (const Sampler& sampler, float ref, float s, float t, float r) const; 7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCube& operator= (const TextureCube& other); 7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry operator TextureCubeView (void) const { return m_view; } 7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef de::ArrayBuffer<deUint8> LevelData; 7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureFormat m_format; 7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_size; 7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<LevelData> m_data[CUBEFACE_LAST]; 7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<PixelBufferAccess> m_access[CUBEFACE_LAST]; 7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeView m_view; 77493df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCube::sample (const Sampler& sampler, float s, float t, float p, float lod) const 7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sample(sampler, s, t, p, lod); 7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float TextureCube::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const 7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleCompare(sampler, ref, s, t, r, lod); 7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCube::gather (const Sampler& sampler, float s, float t, float r, int componentNdx) const 7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.gather(sampler, s, t, r, componentNdx); 7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCube::gatherCompare (const Sampler& sampler, float ref, float s, float t, float r) const 7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.gatherCompare(sampler, ref, s, t, r); 7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 1D Array Texture View 7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1DArrayView 8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1DArrayView (int numLevels, const ConstPixelBufferAccess* levels); 8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_numLevels > 0 ? m_levels[0].getWidth() : 0; } 8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLayers (void) const { return m_numLevels > 0 ? m_levels[0].getHeight() : 0; } 8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLevels (void) const { return m_numLevels; } 8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess& getLevel (int ndx) const { DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx]; } 8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* getLevels (void) const { return m_levels; } 8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float lod) const; 8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float lod, deInt32 offset) const; 8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const; 8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const; 8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int selectLayer (float r) const; 8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numLevels; 8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* m_levels; 82093df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 2D Array Texture View 8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DArrayView 8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DArrayView (int numLevels, const ConstPixelBufferAccess* levels); 8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_numLevels > 0 ? m_levels[0].getWidth() : 0; } 8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getHeight (void) const { return m_numLevels > 0 ? m_levels[0].getHeight() : 0; } 8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLayers (void) const { return m_numLevels > 0 ? m_levels[0].getDepth() : 0; } 8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLevels (void) const { return m_numLevels; } 8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess& getLevel (int ndx) const { DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx]; } 8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* getLevels (void) const { return m_levels; } 8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float r, float lod) const; 8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const; 8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const; 8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const; 8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherOffsets (const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const; 8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const; 8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int selectLayer (float r) const; 8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numLevels; 8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* m_levels; 85093df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 1D Array Texture reference implementation 8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1DArray : private TextureLevelPyramid 8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1DArray (const TextureFormat& format, int width, int numLayers); 8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1DArray (const Texture1DArray& other); 8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Texture1DArray (void); 8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_width; } 8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLayers (void) const { return m_numLayers; } 8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocLevel (int levelNdx); 8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getFormat; 8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getNumLevels; 8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getLevel; 8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::clearLevel; 8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::isLevelEmpty; 8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float lod) const; 8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float lod, deInt32 offset) const; 8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const; 8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const; 8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1DArray& operator= (const Texture1DArray& other); 8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry operator Texture1DArrayView (void) const { return m_view; } 8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_width; 8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numLayers; 8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture1DArrayView m_view; 88693df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1DArray::sample (const Sampler& sampler, float s, float t, float lod) const 8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sample(sampler, s, t, lod); 8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1DArray::sampleOffset (const Sampler& sampler, float s, float t, float lod, deInt32 offset) const 8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleOffset(sampler, s, t, lod, offset); 8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture1DArray::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const 8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleCompare(sampler, ref, s, t, lod); 9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture1DArray::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const 9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleCompareOffset(sampler, ref, s, t, lod, offset); 9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 2D Array Texture reference implementation 9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DArray : private TextureLevelPyramid 9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DArray (const TextureFormat& format, int width, int height, int numLayers); 9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DArray (const Texture2DArray& other); 9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Texture2DArray (void); 9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_width; } 9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getHeight (void) const { return m_height; } 9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLayers (void) const { return m_numLayers; } 9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocLevel (int levelNdx); 9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getFormat; 9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getNumLevels; 9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getLevel; 9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::clearLevel; 9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::isLevelEmpty; 9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float r, float lod) const; 9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const; 9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const; 9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const; 9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherOffsets (const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const; 9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const; 9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DArray& operator= (const Texture2DArray& other); 9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry operator Texture2DArrayView (void) const { return m_view; } 9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_width; 9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_height; 9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numLayers; 9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture2DArrayView m_view; 94793df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DArray::sample (const Sampler& sampler, float s, float t, float r, float lod) const 9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sample(sampler, s, t, r, lod); 9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DArray::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const 9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleOffset(sampler, s, t, r, lod, offset); 9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2DArray::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const 9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleCompare(sampler, ref, s, t, r, lod); 9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2DArray::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const 9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleCompareOffset(sampler, ref, s, t, r, lod, offset); 9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DArray::gatherOffsets (const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const 9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.gatherOffsets(sampler, s, t, r, componentNdx, offsets); 9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DArray::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const 9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.gatherOffsetsCompare(sampler, ref, s, t, r, offsets); 9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 3D Texture View 9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture3DView 9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture3DView (int numLevels, const ConstPixelBufferAccess* levels); 9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_numLevels > 0 ? m_levels[0].getWidth() : 0; } 9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getHeight (void) const { return m_numLevels > 0 ? m_levels[0].getHeight() : 0; } 9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getDepth (void) const { return m_numLevels > 0 ? m_levels[0].getDepth() : 0; } 9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLevels (void) const { return m_numLevels; } 9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess& getLevel (int ndx) const { DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx]; } 9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* getLevels (void) const { return m_levels; } 9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float r, float lod) const; 9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const; 9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numLevels; 9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* m_levels; 100093df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture3DView::sample (const Sampler& sampler, float s, float t, float r, float lod) const 10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray3D(m_levels, m_numLevels, sampler, s, t, r, lod); 10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture3DView::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const 10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleLevelArray3DOffset(m_levels, m_numLevels, sampler, s, t, r, lod, offset); 10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 3D Texture reference implementation 10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture3D : private TextureLevelPyramid 10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture3D (const TextureFormat& format, int width, int height, int depth); 10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture3D (const Texture3D& other); 10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~Texture3D (void); 10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_width; } 10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getHeight (void) const { return m_height; } 10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getDepth (void) const { return m_depth; } 10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocLevel (int levelNdx); 10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getFormat; 10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getNumLevels; 10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getLevel; 10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::clearLevel; 10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::isLevelEmpty; 10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float r, float lod) const; 10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const; 10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture3D& operator= (const Texture3D& other); 10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry operator Texture3DView (void) const { return m_view; } 10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_width; 10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_height; 10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_depth; 10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Texture3DView m_view; 104693df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture3D::sample (const Sampler& sampler, float s, float t, float r, float lod) const 10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sample(sampler, s, t, r, lod); 10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture3D::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const 10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleOffset(sampler, s, t, r, lod, offset); 10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Cube Map Array Texture View 10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeArrayView 10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeArrayView (int numLevels, const ConstPixelBufferAccess* levels); 10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int getSize (void) const { return m_numLevels > 0 ? m_levels[0].getWidth() : 0; } 10678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int getDepth (void) const { return m_numLevels > 0 ? m_levels[0].getDepth() : 0; } 10688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int getNumLayers (void) const { return getDepth() / 6; } 10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumLevels (void) const { return m_numLevels; } 10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess& getLevel (int ndx) const { DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx]; } 10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* getLevels (void) const { return m_levels; } 10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float r, float q, float lod) const; 10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float r, float q, float lod, const IVec2& offset) const; 10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const; 10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod, const IVec2& offset) const; 10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 10798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int selectLayer (float q) const; 10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numLevels; 10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ConstPixelBufferAccess* m_levels; 108393df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Cube Map Array Texture reference implementation 10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeArray : private TextureLevelPyramid 10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 10918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TextureCubeArray (const TextureFormat& format, int size, int depth); 10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeArray (const TextureCubeArray& other); 10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TextureCubeArray (void); 10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int getSize (void) const { return m_size; } 10968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int getDepth (void) const { return m_depth; } 10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void allocLevel (int levelNdx); 10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getFormat; 11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getNumLevels; 11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::getLevel; 11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::clearLevel; 11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using TextureLevelPyramid::isLevelEmpty; 11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sample (const Sampler& sampler, float s, float t, float r, float q, float lod) const; 11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Vec4 sampleOffset (const Sampler& sampler, float s, float t, float r, float q, float lod, const IVec2& offset) const; 11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const; 11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod, const IVec2& offset) const; 11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeArray& operator= (const TextureCubeArray& other); 11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry operator TextureCubeArrayView (void) const { return m_view; } 11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_size; 11178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int m_depth; 11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureCubeArrayView m_view; 111993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE; 11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCubeArray::sample (const Sampler& sampler, float s, float t, float r, float q, float lod) const 11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sample(sampler, s, t, r, q, lod); 11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCubeArray::sampleOffset (const Sampler& sampler, float s, float t, float r, float q, float lod, const IVec2& offset) const 11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleOffset(sampler, s, t, r, q, lod, offset); 11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float TextureCubeArray::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const 11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleCompare(sampler, ref, s, t, r, q, lod); 11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float TextureCubeArray::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod, const IVec2& offset) const 11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_view.sampleCompareOffset(sampler, ref, s, t, r, q, lod, offset); 11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Stream operators. 11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream& operator<< (std::ostream& str, TextureFormat::ChannelOrder order); 11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream& operator<< (std::ostream& str, TextureFormat::ChannelType type); 11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream& operator<< (std::ostream& str, TextureFormat format); 11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream& operator<< (std::ostream& str, CubeFace face); 11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream& operator<< (std::ostream& str, const ConstPixelBufferAccess& access); 11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // tcu 11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _TCUTEXTURE_HPP 1151