tcuTexture.hpp revision 199c73a9eb28e6ef553e30bdf6b766198a65e796
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"
28222c1cfbf44db3a0bd251ef230e55c3602e518ccJarkko Pöyry#include "rrGenericVector.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deArrayBuffer.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <ostream>
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Texture format
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureFormat
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum ChannelOrder
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		R = 0,
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		A,
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		I,
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		L,
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LA,
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		RG,
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		RA,
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		RGB,
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		RGBA,
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ARGB,
55725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		BGR,
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		BGRA,
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5816d404b8653856a3a402c67c36425e24afe456adJarkko Pöyry		sR,
5916d404b8653856a3a402c67c36425e24afe456adJarkko Pöyry		sRG,
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sRGB,
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sRGBA,
62725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		sBGR,
63725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		sBGRA,
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		D,
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		S,
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DS,
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		CHANNELORDER_LAST
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum ChannelType
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		SNORM_INT8 = 0,
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		SNORM_INT16,
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		SNORM_INT32,
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNORM_INT8,
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNORM_INT16,
7907104dfa13013a73a59a93cbd8d132254a5a171dJarkko Pöyry		UNORM_INT24,
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNORM_INT32,
81725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		UNORM_BYTE_44,
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNORM_SHORT_565,
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNORM_SHORT_555,
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNORM_SHORT_4444,
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNORM_SHORT_5551,
865b2b45177edf5062ce3a76a885e60e3fb5044002Pyry Haulos		UNORM_SHORT_1555,
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNORM_INT_101010,
88725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		SNORM_INT_1010102_REV,
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNORM_INT_1010102_REV,
90725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		UNSIGNED_BYTE_44,
91725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		UNSIGNED_SHORT_565,
92725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		UNSIGNED_SHORT_4444,
93725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		UNSIGNED_SHORT_5551,
94725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		SIGNED_INT_1010102_REV,
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNSIGNED_INT_1010102_REV,
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNSIGNED_INT_11F_11F_10F_REV,
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNSIGNED_INT_999_E5_REV,
98725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		UNSIGNED_INT_16_8_8,
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNSIGNED_INT_24_8,
100725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		UNSIGNED_INT_24_8_REV,
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		SIGNED_INT8,
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		SIGNED_INT16,
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		SIGNED_INT32,
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNSIGNED_INT8,
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNSIGNED_INT16,
106db6ba452c1213fd1c2b03369fdf4c1d23f07cfadJarkko Pöyry		UNSIGNED_INT24,
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		UNSIGNED_INT32,
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		HALF_FLOAT,
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FLOAT,
110725691d12fb107f6ba64aa8ab5aafa0a1cea2847Pyry Haulos		FLOAT64,
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FLOAT_UNSIGNED_INT_24_8_REV,
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		CHANNELTYPE_LAST
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ChannelOrder	order;
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ChannelType		type;
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureFormat (ChannelOrder order_, ChannelType type_)
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: order	(order_)
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, type	(type_)
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureFormat (void)
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: order	(CHANNELORDER_LAST)
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, type	(CHANNELTYPE_LAST)
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
13125977694b814e285649d6a60c148cb3b5a04ef30Pyry Haulos	int getPixelSize (void) const; //!< Deprecated, use tcu::getPixelSize(fmt)
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool operator== (const TextureFormat& other) const { return !(*this != other); }
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool operator!= (const TextureFormat& other) const
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return (order != other.order || type != other.type);
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
13893df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
140199c73a9eb28e6ef553e30bdf6b766198a65e796Kantochbool	isValid				(TextureFormat format);
141199c73a9eb28e6ef553e30bdf6b766198a65e796Kantochint		getPixelSize		(TextureFormat format);
142199c73a9eb28e6ef553e30bdf6b766198a65e796Kantochint		getNumUsedChannels	(TextureFormat::ChannelOrder order);
14325977694b814e285649d6a60c148cb3b5a04ef30Pyry Haulos
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1456d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry * \brief Texture swizzle
1466d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry *//*--------------------------------------------------------------------*/
1476d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyrystruct TextureSwizzle
1486d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry{
1496d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry	enum Channel
1506d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry	{
1516d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry		// \note CHANNEL_N must equal int N
1526d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry		CHANNEL_0 = 0,
1536d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry		CHANNEL_1,
1546d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry		CHANNEL_2,
1556d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry		CHANNEL_3,
1566d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry
1576d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry		CHANNEL_ZERO,
1586d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry		CHANNEL_ONE,
1596d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry
1606d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry		CHANNEL_LAST
1616d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry	};
1626d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry
1636d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry	Channel components[4];
1646d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry};
1656d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry
1666d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry//! get the swizzle used to expand texture data with a given channel order to RGBA form
1676d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyryconst TextureSwizzle& getChannelReadSwizzle		(TextureFormat::ChannelOrder order);
1686d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry
1696d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry//! get the swizzle used to narrow RGBA form data to native texture data with a given channel order
1706d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyryconst TextureSwizzle& getChannelWriteSwizzle	(TextureFormat::ChannelOrder order);
1716d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry
1726d31105cb879614b2cf87193ea90215efd13bcceJarkko Pöyry/*--------------------------------------------------------------------*//*!
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Sampling parameters
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Sampler
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum WrapMode
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		CLAMP_TO_EDGE = 0,	//! Clamp to edge
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		CLAMP_TO_BORDER,	//! Use border color at edge
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REPEAT_GL,			//! Repeat with OpenGL semantics
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		REPEAT_CL,			//! Repeat with OpenCL semantics
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		MIRRORED_REPEAT_GL,	//! Mirrored repeat with OpenGL semantics
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		MIRRORED_REPEAT_CL, //! Mirrored repeat with OpenCL semantics
18673fd35f3b995f065863c495364f03a52699c2d4aPyry Haulos		MIRRORED_ONCE,		//! Mirrored once in negative directions
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		WRAPMODE_LAST
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum FilterMode
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NEAREST = 0,
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LINEAR,
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NEAREST_MIPMAP_NEAREST,
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NEAREST_MIPMAP_LINEAR,
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LINEAR_MIPMAP_NEAREST,
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LINEAR_MIPMAP_LINEAR,
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FILTERMODE_LAST
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum CompareMode
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_NONE = 0,
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_LESS,
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_LESS_OR_EQUAL,
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_GREATER,
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_GREATER_OR_EQUAL,
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_EQUAL,
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_NOT_EQUAL,
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_ALWAYS,
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_NEVER,
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		COMPAREMODE_LAST
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
21941920d7e0d1833907249009d156f6eb2361df97eJarkko Pöyry	enum DepthStencilMode
22041920d7e0d1833907249009d156f6eb2361df97eJarkko Pöyry	{
22141920d7e0d1833907249009d156f6eb2361df97eJarkko Pöyry		MODE_DEPTH = 0,
22241920d7e0d1833907249009d156f6eb2361df97eJarkko Pöyry		MODE_STENCIL,
22341920d7e0d1833907249009d156f6eb2361df97eJarkko Pöyry
22441920d7e0d1833907249009d156f6eb2361df97eJarkko Pöyry		MODE_LAST
22541920d7e0d1833907249009d156f6eb2361df97eJarkko Pöyry	};
22641920d7e0d1833907249009d156f6eb2361df97eJarkko Pöyry
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Wrap control
22823da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	WrapMode			wrapS;
22923da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	WrapMode			wrapT;
23023da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	WrapMode			wrapR;
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Minifcation & magnification
23323da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	FilterMode			minFilter;
23423da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	FilterMode			magFilter;
23523da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	float				lodThreshold;		// lod <= lodThreshold ? magnified : minified
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Coordinate normalization
23823da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	bool				normalizedCoords;
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Shadow comparison
24123da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	CompareMode			compare;
24223da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	int					compareChannel;
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
244222c1cfbf44db3a0bd251ef230e55c3602e518ccJarkko Pöyry	// Border color.
245222c1cfbf44db3a0bd251ef230e55c3602e518ccJarkko Pöyry	// \note It is setter's responsibility to guarantee that the values are representable
246222c1cfbf44db3a0bd251ef230e55c3602e518ccJarkko Pöyry	//       in sampled texture's internal format.
247222c1cfbf44db3a0bd251ef230e55c3602e518ccJarkko Pöyry	// \note It is setter's responsibility to guarantee that the format is compatible with the
248222c1cfbf44db3a0bd251ef230e55c3602e518ccJarkko Pöyry	//       sampled texture's internal format. Otherwise results are undefined.
249222c1cfbf44db3a0bd251ef230e55c3602e518ccJarkko Pöyry	rr::GenericVec4		borderColor;
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Seamless cube map filtering
25223da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	bool				seamlessCubeMap;
25323da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry
25423da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	// Depth stencil mode
25523da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	DepthStencilMode	depthStencilMode;
25623da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry
25723da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry	Sampler (WrapMode			wrapS_,
25823da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 WrapMode			wrapT_,
25923da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 WrapMode			wrapR_,
26023da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 FilterMode			minFilter_,
26123da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 FilterMode			magFilter_,
26223da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 float				lodThreshold_		= 0.0f,
26323da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 bool				normalizedCoords_	= true,
26423da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 CompareMode		compare_			= COMPAREMODE_NONE,
26523da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 int				compareChannel_		= 0,
26623da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 const Vec4&		borderColor_		= Vec4(0.0f, 0.0f, 0.0f, 0.0f),
26723da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 bool				seamlessCubeMap_	= false,
26823da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry			 DepthStencilMode	depthStencilMode_	= MODE_DEPTH)
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: wrapS				(wrapS_)
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, wrapT				(wrapT_)
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, wrapR				(wrapR_)
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, minFilter			(minFilter_)
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, magFilter			(magFilter_)
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, lodThreshold		(lodThreshold_)
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, normalizedCoords	(normalizedCoords_)
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, compare			(compare_)
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, compareChannel	(compareChannel_)
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, borderColor		(borderColor_)
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, seamlessCubeMap	(seamlessCubeMap_)
28023da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry		, depthStencilMode	(depthStencilMode_)
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Sampler (void)
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: wrapS				(WRAPMODE_LAST)
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, wrapT				(WRAPMODE_LAST)
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, wrapR				(WRAPMODE_LAST)
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, minFilter			(FILTERMODE_LAST)
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, magFilter			(FILTERMODE_LAST)
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, lodThreshold		(0.0f)
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, normalizedCoords	(true)
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, compare			(COMPAREMODE_NONE)
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, compareChannel	(0)
294222c1cfbf44db3a0bd251ef230e55c3602e518ccJarkko Pöyry		, borderColor		(Vec4(0.0f, 0.0f, 0.0f, 0.0f))
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, seamlessCubeMap	(false)
29623da2952459e6df3511da00f2a6c548a1b442c92Jarkko Pöyry		, depthStencilMode	(MODE_DEPTH)
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
29993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
30129340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi// Calculate pitches for pixel data with no padding.
30229340067e919854db7d50bb8c0b666117b229f5eMika IsojärviIVec3 calculatePackedPitch (const TextureFormat& format, const IVec3& size);
30329340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureLevel;
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Read-only pixel data access
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ConstPixelBufferAccess encapsulates pixel data pointer along with
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * format and layout information. It can be used for read-only access
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * to arbitrary pixel buffers.
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Access objects are like iterators or pointers. They can be passed around
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * as values and are valid as long as the storage doesn't change.
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ConstPixelBufferAccess
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							ConstPixelBufferAccess		(void);
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							ConstPixelBufferAccess		(const TextureLevel& level);
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							ConstPixelBufferAccess		(const TextureFormat& format, int width, int height, int depth, const void* data);
32229340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi							ConstPixelBufferAccess		(const TextureFormat& format, const IVec3& size, const void* data);
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							ConstPixelBufferAccess		(const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, const void* data);
32429340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi							ConstPixelBufferAccess		(const TextureFormat& format, const IVec3& size, const IVec3& pitch, const void* data);
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
32629340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	const TextureFormat&	getFormat					(void) const	{ return m_format;					}
32729340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	const IVec3&			getSize						(void) const	{ return m_size;					}
32829340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	int						getWidth					(void) const	{ return m_size.x();				}
32929340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	int						getHeight					(void) const	{ return m_size.y();				}
33029340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	int						getDepth					(void) const	{ return m_size.z();				}
3316c307165131fb7249bb044fc79ff0c2747263b3dJarkko Pöyry	int						getPixelPitch				(void) const	{ return m_pitch.x();				}
33229340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	int						getRowPitch					(void) const	{ return m_pitch.y();				}
33329340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	int						getSlicePitch				(void) const	{ return m_pitch.z();				}
3346c307165131fb7249bb044fc79ff0c2747263b3dJarkko Pöyry	const IVec3&			getPitch					(void) const	{ return m_pitch;					}
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
33629340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	const void*				getDataPtr					(void) const	{ return m_data;					}
3376c307165131fb7249bb044fc79ff0c2747263b3dJarkko 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(); }
3386c307165131fb7249bb044fc79ff0c2747263b3dJarkko Pöyry
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4					getPixel					(int x, int y, int z = 0) const;
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IVec4					getPixelInt					(int x, int y, int z = 0) const;
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	UVec4					getPixelUint				(int x, int y, int z = 0) const { return getPixelInt(x, y, z).cast<deUint32>(); }
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template<typename T>
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vector<T, 4>			getPixelT					(int x, int y, int z = 0) const;
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float					getPixDepth					(int x, int y, int z = 0) const;
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						getPixStencil				(int x, int y, int z = 0) const;
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4					sample1D					(const Sampler& sampler, Sampler::FilterMode filter, float s, int level) const;
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4					sample2D					(const Sampler& sampler, Sampler::FilterMode filter, float s, float t, int depth) const;
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4					sample3D					(const Sampler& sampler, Sampler::FilterMode filter, float s, float t, float r) const;
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4					sample1DOffset				(const Sampler& sampler, Sampler::FilterMode filter, float s, const IVec2& offset) const;
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4					sample2DOffset				(const Sampler& sampler, Sampler::FilterMode filter, float s, float t, const IVec3& offset) const;
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4					sample3DOffset				(const Sampler& sampler, Sampler::FilterMode filter, float s, float t, float r, const IVec3& offset) const;
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float					sample1DCompare				(const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, const IVec2& offset) const;
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float					sample2DCompare				(const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, float t, const IVec3& offset) const;
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureFormat			m_format;
36229340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	IVec3					m_size;
36329340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	IVec3					m_pitch;	//!< (pixelPitch, rowPitch, slicePitch)
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	mutable void*			m_data;
36593df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Read-write pixel data access
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * This class extends read-only access object by providing write functionality.
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \note PixelBufferAccess may not have any data members nor add any
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *		 virtual functions. It must be possible to reinterpret_cast<>
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *		 PixelBufferAccess to ConstPixelBufferAccess.
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PixelBufferAccess : public ConstPixelBufferAccess
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
379becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi						PixelBufferAccess	(void) {}
380becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi						PixelBufferAccess	(TextureLevel& level);
381becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi						PixelBufferAccess	(const TextureFormat& format, int width, int height, int depth, void* data);
38229340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi						PixelBufferAccess	(const TextureFormat& format, const IVec3& size, void* data);
383becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi						PixelBufferAccess	(const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, void* data);
38429340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi						PixelBufferAccess	(const TextureFormat& format, const IVec3& size, const IVec3& pitch, void* data);
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
386becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	void*				getDataPtr			(void) const { return m_data; }
3876c307165131fb7249bb044fc79ff0c2747263b3dJarkko 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(); }
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
389becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	void				setPixel			(const tcu::Vec4& color, int x, int y, int z = 0) const;
390becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	void				setPixel			(const tcu::IVec4& color, int x, int y, int z = 0) const;
391becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	void				setPixel			(const tcu::UVec4& color, int x, int y, int z = 0) const { setPixel(color.cast<int>(), x, y, z); }
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
393becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	void				setPixDepth			(float depth, int x, int y, int z = 0) const;
394becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	void				setPixStencil		(int stencil, int x, int y, int z = 0) const;
39593df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Generic pixel data container
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * This container supports all valid TextureFormat combinations and
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * both 2D and 3D textures. To read or manipulate data access object must
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * be queried using getAccess().
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureLevel
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
407becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi								TextureLevel		(void);
408becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi								TextureLevel		(const TextureFormat& format);
409becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi								TextureLevel		(const TextureFormat& format, int width, int height, int depth = 1);
410becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi								~TextureLevel		(void);
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
41229340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	const IVec3&				getSize				(void) const	{ return m_size;		}
41329340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	int							getWidth			(void) const	{ return m_size.x();	}
41429340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	int							getHeight			(void) const	{ return m_size.y();	}
41529340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	int							getDepth			(void) const	{ return m_size.z();	}
41629340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	bool						isEmpty				(void) const	{ return m_size.x() * m_size.y() * m_size.z() == 0; }
417becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	const TextureFormat			getFormat			(void) const	{ return m_format;	}
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
419becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	void						setStorage			(const TextureFormat& format, int width, int heigth, int depth = 1);
420becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	void						setSize				(int width, int height, int depth = 1);
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
422b5d323b0daefbf7f7f4cb5e9cc631e2ab837b6edPyry Haulos	PixelBufferAccess			getAccess			(void)			{ return isEmpty() ? PixelBufferAccess() : PixelBufferAccess(m_format, m_size, calculatePackedPitch(m_format, m_size), getPtr());			}
423b5d323b0daefbf7f7f4cb5e9cc631e2ab837b6edPyry Haulos	ConstPixelBufferAccess		getAccess			(void) const	{ return isEmpty() ? ConstPixelBufferAccess() : ConstPixelBufferAccess(m_format, m_size, calculatePackedPitch(m_format, m_size), getPtr());	}
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
426becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	void*						getPtr				(void)			{ return m_data.getPtr(); }
427becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	const void*					getPtr				(void) const	{ return m_data.getPtr(); }
428becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi
429becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	TextureFormat				m_format;
43029340067e919854db7d50bb8c0b666117b229f5eMika Isojärvi	IVec3						m_size;
431becd5d53015521acf7536ba754de326d8b1da2f3Mika Isojärvi	de::ArrayBuffer<deUint8>	m_data;
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	friend class ConstPixelBufferAccess;
43493df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4363c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4	sampleLevelArray1D				(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, int level, float lod);
4373c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4	sampleLevelArray2D				(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, int depth, float lod);
4383c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4	sampleLevelArray3D				(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float r, float lod);
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4403c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4	sampleLevelArray1DOffset		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float lod, const IVec2& offset);
4413c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4	sampleLevelArray2DOffset		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float lod, const IVec3& offset);
4423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4	sampleLevelArray3DOffset		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset);
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryfloat	sampleLevelArray1DCompare		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float ref, float s, float lod, const IVec2& offset);
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryfloat	sampleLevelArray2DCompare		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float ref, float s, float t, float lod, const IVec3& offset);
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4473c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4	gatherArray2DOffsets			(const ConstPixelBufferAccess& src, const Sampler& sampler, float s, float t, int depth, int componentNdx, const IVec2 (&offsets)[4]);
4483c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec4	gatherArray2DOffsetsCompare		(const ConstPixelBufferAccess& src, const Sampler& sampler, float ref, float s, float t, int depth, const IVec2 (&offsets)[4]);
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum CubeFace
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CUBEFACE_NEGATIVE_X = 0,
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CUBEFACE_POSITIVE_X,
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CUBEFACE_NEGATIVE_Y,
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CUBEFACE_POSITIVE_Y,
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CUBEFACE_NEGATIVE_Z,
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CUBEFACE_POSITIVE_Z,
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CUBEFACE_LAST
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Coordinates projected onto cube face.
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename T>
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct CubeFaceCoords
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CubeFace		face;
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	T				s;
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	T				t;
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					CubeFaceCoords		(CubeFace face_, T s_, T t_) : face(face_), s(s_), t(t_) {}
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					CubeFaceCoords		(CubeFace face_, const Vector<T, 2>& c) : face(face_), s(c.x()), t(c.y()) {}
47493df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef CubeFaceCoords<float>	CubeFaceFloatCoords;
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef CubeFaceCoords<int>		CubeFaceIntCoords;
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4793c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCubeFace				selectCubeFace			(const Vec3& coords);
4803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVec2					projectToFace			(CubeFace face, const Vec3& coords);
4813c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCubeFaceFloatCoords		getCubeFaceCoords		(const Vec3& coords);
4823c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCubeFaceIntCoords		remapCubeEdgeCoords		(const CubeFaceIntCoords& coords, int size);
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 1D Texture View
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1DView
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture1DView		(int numLevels, const ConstPixelBufferAccess* levels);
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLevels		(void) const	{ return m_numLevels;										}
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float lod) const;
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float lod, deInt32 offset) const;
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float lod) const;
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float lod, deInt32 offset) const;
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_numLevels;
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	m_levels;
50593df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Texture1DView::Texture1DView (int numLevels, const ConstPixelBufferAccess* levels)
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: m_numLevels	(numLevels)
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_levels		(levels)
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_numLevels >= 0 && ((m_numLevels == 0) == !m_levels));
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1DView::sample (const Sampler& sampler, float s, float lod) const
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray1D(m_levels, m_numLevels, sampler, s, 0 /* depth */, lod);
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1DView::sampleOffset (const Sampler& sampler, float s, float lod, deInt32 offset) const
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray1DOffset(m_levels, m_numLevels, sampler, s, lod, IVec2(offset, 0));
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture1DView::sampleCompare (const Sampler& sampler, float ref, float s, float lod) const
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray1DCompare(m_levels, m_numLevels, sampler, ref, s, lod, IVec2(0, 0));
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture1DView::sampleCompareOffset (const Sampler& sampler, float ref, float s, float lod, deInt32 offset) const
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray1DCompare(m_levels, m_numLevels, sampler, ref, s, lod, IVec2(offset, 0));
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 2D Texture View
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DView
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture2DView		(int numLevels, const ConstPixelBufferAccess* levels);
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLevels		(void) const	{ return m_numLevels;										}
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getHeight			(void) const	{ return m_numLevels > 0 ? m_levels[0].getHeight()	: 0;	}
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float lod) const;
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const;
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float lod) const;
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const;
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherOffsets		(const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const;
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const;
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_numLevels;
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	m_levels;
55993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Texture2DView::Texture2DView (int numLevels, const ConstPixelBufferAccess* levels)
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: m_numLevels	(numLevels)
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_levels		(levels)
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_numLevels >= 0 && ((m_numLevels == 0) == !m_levels));
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DView::sample (const Sampler& sampler, float s, float t, float lod) const
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray2D(m_levels, m_numLevels, sampler, s, t, 0 /* depth */, lod);
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DView::sampleOffset (const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray2DOffset(m_levels, m_numLevels, sampler, s, t, lod, IVec3(offset.x(), offset.y(), 0));
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2DView::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray2DCompare(m_levels, m_numLevels, sampler, ref, s, t, lod, IVec3(0, 0, 0));
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2DView::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray2DCompare(m_levels, m_numLevels, sampler, ref, s, t, lod, IVec3(offset.x(), offset.y(), 0));
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DView::gatherOffsets (const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return gatherArray2DOffsets(m_levels[0], sampler, s, t, 0, componentNdx, offsets);
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DView::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return gatherArray2DOffsetsCompare(m_levels[0], sampler, ref, s, t, 0, offsets);
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Base class for textures that have single mip-map pyramid
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureLevelPyramid
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									TextureLevelPyramid	(const TextureFormat& format, int numLevels);
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									TextureLevelPyramid	(const TextureLevelPyramid& other);
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~TextureLevelPyramid(void);
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const TextureFormat&			getFormat			(void) const			{ return m_format;					}
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLevels		(void) const			{ return (int)m_access.size();		}
61024ceed3e1acf66512ee25ee75002198b6672879dJarkko Pöyry
61124ceed3e1acf66512ee25ee75002198b6672879dJarkko Pöyry	bool							isLevelEmpty		(int levelNdx) const	{ DE_ASSERT(de::inBounds(levelNdx, 0, getNumLevels())); return m_data[(size_t)levelNdx].empty();	}
61224ceed3e1acf66512ee25ee75002198b6672879dJarkko Pöyry	const ConstPixelBufferAccess&	getLevel			(int levelNdx) const	{ DE_ASSERT(de::inBounds(levelNdx, 0, getNumLevels())); return m_access[(size_t)levelNdx];			}
61324ceed3e1acf66512ee25ee75002198b6672879dJarkko Pöyry	const PixelBufferAccess&		getLevel			(int levelNdx)			{ DE_ASSERT(de::inBounds(levelNdx, 0, getNumLevels())); return m_access[(size_t)levelNdx];			}
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	getLevels			(void) const			{ return &m_access[0];				}
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const PixelBufferAccess*		getLevels			(void)					{ return &m_access[0];				}
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							allocLevel			(int levelNdx, int width, int height, int depth);
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							clearLevel			(int levelNdx);
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureLevelPyramid&			operator=			(const TextureLevelPyramid& other);
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	typedef de::ArrayBuffer<deUint8> LevelData;
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureFormat					m_format;
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<LevelData>			m_data;
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<PixelBufferAccess>	m_access;
62993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 1D Texture reference implementation
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1D : private TextureLevelPyramid
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture1D			(const TextureFormat& format, int width);
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture1D			(const Texture1D& other);
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~Texture1D			(void);
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_width;	}
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Texture1DView&			getView				(void) const	{ return m_view;	}
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							allocLevel			(int levelNdx);
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Sampling
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float lod) const;
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float lod, deInt32 offset) const;
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getFormat;
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getNumLevels;
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getLevel;
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::clearLevel;
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::isLevelEmpty;
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture1D&						operator=			(const Texture1D& other);
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	operator Texture1DView (void) const { return m_view; }
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_width;
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture1DView					m_view;
66393df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1D::sample (const Sampler& sampler, float s, float lod) const
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sample(sampler, s, lod);
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1D::sampleOffset (const Sampler& sampler, float s, float lod, deInt32 offset) const
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleOffset(sampler, s, lod, offset);
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 2D Texture reference implementation
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2D : private TextureLevelPyramid
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture2D			(const TextureFormat& format, int width, int height);
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture2D			(const Texture2D& other);
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~Texture2D			(void);
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_width;	}
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getHeight			(void) const	{ return m_height;	}
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Texture2DView&			getView				(void) const	{ return m_view;	}
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							allocLevel			(int levelNdx);
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Sampling
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float lod) const;
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const;
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float lod) const;
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const;
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherOffsets		(const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const;
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const;
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getFormat;
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getNumLevels;
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getLevel;
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::clearLevel;
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::isLevelEmpty;
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture2D&						operator=			(const Texture2D& other);
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	operator Texture2DView (void) const { return m_view; }
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_width;
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_height;
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture2DView					m_view;
71493df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2D::sample (const Sampler& sampler, float s, float t, float lod) const
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sample(sampler, s, t, lod);
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2D::sampleOffset (const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleOffset(sampler, s, t, lod, offset);
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2D::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleCompare(sampler, ref, s, t, lod);
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2D::sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleCompareOffset(sampler, ref, s, t, lod, offset);
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2D::gatherOffsets (const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.gatherOffsets(sampler, s, t, componentNdx, offsets);
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2D::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.gatherOffsetsCompare(sampler, ref, s, t, offsets);
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Cube Map Texture View
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeView
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									TextureCubeView		(void);
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									TextureCubeView		(int numLevels, const ConstPixelBufferAccess* const (&levels)[CUBEFACE_LAST]);
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLevels		(void) const	{ return m_numLevels;										}
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getSize				(void) const	{ return m_numLevels > 0 ? m_levels[0][0].getWidth() : 0;	}
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess&	getLevelFace		(int ndx, CubeFace face) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[face][ndx];	}
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	getFaceLevels		(CubeFace face) const			{ return m_levels[face];					}
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float p, float lod) const;
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float lod) const;
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gather				(const Sampler& sampler, float s, float t, float r, int componentNdx) const;
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherCompare		(const Sampler& sampler, float ref, float s, float t, float r) const;
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_numLevels;
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	m_levels[CUBEFACE_LAST];
76993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Cube Map Texture reference implementation
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCube
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									TextureCube			(const TextureFormat& format, int size);
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									TextureCube			(const TextureCube& other);
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~TextureCube		(void);
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const TextureFormat&			getFormat			(void) const	{ return m_format;	}
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getSize				(void) const	{ return m_size;	}
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLevels		(void) const					{ return (int)m_access[0].size();	}
78524ceed3e1acf66512ee25ee75002198b6672879dJarkko Pöyry	const ConstPixelBufferAccess&	getLevelFace		(int ndx, CubeFace face) const	{ DE_ASSERT(de::inBounds(ndx, 0, getNumLevels())); return m_access[face][(size_t)ndx];	}
78624ceed3e1acf66512ee25ee75002198b6672879dJarkko Pöyry	const PixelBufferAccess&		getLevelFace		(int ndx, CubeFace face)		{ DE_ASSERT(de::inBounds(ndx, 0, getNumLevels())); return m_access[face][(size_t)ndx];	}
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							allocLevel			(CubeFace face, int levelNdx);
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							clearLevel			(CubeFace face, int levelNdx);
79024ceed3e1acf66512ee25ee75002198b6672879dJarkko Pöyry	bool							isLevelEmpty		(CubeFace face, int levelNdx) const	{ DE_ASSERT(de::inBounds(levelNdx, 0, getNumLevels())); return m_data[face][(size_t)levelNdx].empty();	}
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float p, float lod) const;
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float lod) const;
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gather				(const Sampler& sampler, float s, float t, float r, int componentNdx) const;
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherCompare		(const Sampler& sampler, float ref, float s, float t, float r) const;
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCube&					operator=			(const TextureCube& other);
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	operator TextureCubeView (void) const { return m_view; }
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	typedef de::ArrayBuffer<deUint8> LevelData;
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureFormat					m_format;
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_size;
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<LevelData>			m_data[CUBEFACE_LAST];
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<PixelBufferAccess>	m_access[CUBEFACE_LAST];
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCubeView					m_view;
81093df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCube::sample (const Sampler& sampler, float s, float t, float p, float lod) const
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sample(sampler, s, t, p, lod);
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float TextureCube::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleCompare(sampler, ref, s, t, r, lod);
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCube::gather (const Sampler& sampler, float s, float t, float r, int componentNdx) const
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.gather(sampler, s, t, r, componentNdx);
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCube::gatherCompare (const Sampler& sampler, float ref, float s, float t, float r) const
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.gatherCompare(sampler, ref, s, t, r);
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 1D Array Texture View
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1DArrayView
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture1DArrayView	(int numLevels, const ConstPixelBufferAccess* levels);
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLayers		(void) const	{ return m_numLevels > 0 ? m_levels[0].getHeight()	: 0;	}
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLevels		(void) const	{ return m_numLevels;										}
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float lod) const;
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float lod, deInt32 offset) const;
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float lod) const;
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const;
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								selectLayer			(float r) const;
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_numLevels;
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	m_levels;
85693df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 2D Array Texture View
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DArrayView
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture2DArrayView	(int numLevels, const ConstPixelBufferAccess* levels);
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getHeight			(void) const	{ return m_numLevels > 0 ? m_levels[0].getHeight()	: 0;	}
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLayers		(void) const	{ return m_numLevels > 0 ? m_levels[0].getDepth()	: 0;	}
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLevels		(void) const	{ return m_numLevels;										}
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float lod) const;
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const;
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float lod) const;
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const;
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherOffsets		(const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const;
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const;
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								selectLayer			(float r) const;
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_numLevels;
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	m_levels;
88693df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 1D Array Texture reference implementation
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1DArray : private TextureLevelPyramid
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture1DArray		(const TextureFormat& format, int width, int numLayers);
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture1DArray		(const Texture1DArray& other);
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~Texture1DArray		(void);
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_width;		}
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLayers		(void) const	{ return m_numLayers;	}
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							allocLevel			(int levelNdx);
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getFormat;
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getNumLevels;
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getLevel;
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::clearLevel;
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::isLevelEmpty;
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float lod) const;
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float lod, deInt32 offset) const;
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float lod) const;
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const;
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture1DArray&					operator=			(const Texture1DArray& other);
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	operator Texture1DArrayView (void) const { return m_view; }
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_width;
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_numLayers;
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture1DArrayView				m_view;
92293df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1DArray::sample (const Sampler& sampler, float s, float t, float lod) const
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sample(sampler, s, t, lod);
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture1DArray::sampleOffset (const Sampler& sampler, float s, float t, float lod, deInt32 offset) const
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleOffset(sampler, s, t, lod, offset);
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture1DArray::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleCompare(sampler, ref, s, t, lod);
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture1DArray::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleCompareOffset(sampler, ref, s, t, lod, offset);
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 2D Array Texture reference implementation
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DArray : private TextureLevelPyramid
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture2DArray		(const TextureFormat& format, int width, int height, int numLayers);
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture2DArray		(const Texture2DArray& other);
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~Texture2DArray		(void);
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_width;		}
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getHeight			(void) const	{ return m_height;		}
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLayers		(void) const	{ return m_numLayers;	}
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							allocLevel			(int levelNdx);
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getFormat;
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getNumLevels;
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getLevel;
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::clearLevel;
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::isLevelEmpty;
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float lod) const;
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const;
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float lod) const;
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const;
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherOffsets		(const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const;
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const;
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture2DArray&					operator=			(const Texture2DArray& other);
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	operator Texture2DArrayView (void) const { return m_view; }
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_width;
9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_height;
9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_numLayers;
9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture2DArrayView				m_view;
98393df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DArray::sample (const Sampler& sampler, float s, float t, float r, float lod) const
9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sample(sampler, s, t, r, lod);
9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DArray::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const
9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleOffset(sampler, s, t, r, lod, offset);
9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2DArray::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleCompare(sampler, ref, s, t, r, lod);
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float Texture2DArray::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleCompareOffset(sampler, ref, s, t, r, lod, offset);
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DArray::gatherOffsets (const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.gatherOffsets(sampler, s, t, r, componentNdx, offsets);
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture2DArray::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.gatherOffsetsCompare(sampler, ref, s, t, r, offsets);
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 3D Texture View
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture3DView
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture3DView		(int numLevels, const ConstPixelBufferAccess* levels);
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getHeight			(void) const	{ return m_numLevels > 0 ? m_levels[0].getHeight()	: 0;	}
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getDepth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getDepth()	: 0;	}
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLevels		(void) const	{ return m_numLevels;										}
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float lod) const;
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const;
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_numLevels;
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	m_levels;
103693df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture3DView::sample (const Sampler& sampler, float s, float t, float r, float lod) const
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray3D(m_levels, m_numLevels, sampler, s, t, r, lod);
10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture3DView::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const
10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return sampleLevelArray3DOffset(m_levels, m_numLevels, sampler, s, t, r, lod, offset);
10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief 3D Texture reference implementation
10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture3D : private TextureLevelPyramid
10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture3D			(const TextureFormat& format, int width, int height, int depth);
10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									Texture3D			(const Texture3D& other);
10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~Texture3D			(void);
10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getWidth			(void) const	{ return m_width;	}
10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getHeight			(void) const	{ return m_height;	}
10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getDepth			(void) const	{ return m_depth;	}
10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							allocLevel			(int levelNdx);
10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getFormat;
10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getNumLevels;
10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getLevel;
10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::clearLevel;
10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::isLevelEmpty;
10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float lod) const;
10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const;
10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture3D&						operator=			(const Texture3D& other);
10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	operator Texture3DView (void) const { return m_view; }
10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_width;
10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_height;
10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_depth;
10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Texture3DView					m_view;
108293df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture3D::sample (const Sampler& sampler, float s, float t, float r, float lod) const
10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sample(sampler, s, t, r, lod);
10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 Texture3D::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const
10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleOffset(sampler, s, t, r, lod, offset);
10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Cube Map Array Texture View
10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeArrayView
10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									TextureCubeArrayView	(int numLevels, const ConstPixelBufferAccess* levels);
11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry	int								getSize					(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
11038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry	int								getDepth				(void) const	{ return m_numLevels > 0 ? m_levels[0].getDepth()	: 0;	}
11048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry	int								getNumLayers			(void) const	{ return getDepth()	/ 6;	}
11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								getNumLevels			(void) const	{ return m_numLevels;										}
11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess&	getLevel				(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	getLevels				(void) const	{ return m_levels;											}
11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample					(const Sampler& sampler, float s, float t, float r, float q, float lod) const;
11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset			(const Sampler& sampler, float s, float t, float r, float q, float lod, const IVec2& offset) const;
11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare			(const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const;
11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompareOffset		(const Sampler& sampler, float ref, float s, float t, float r, float q, float lod, const IVec2& offset) const;
11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
11158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry	int								selectLayer				(float q) const;
11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_numLevels;
11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const ConstPixelBufferAccess*	m_levels;
111993df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Cube Map Array Texture reference implementation
11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeArray : private TextureLevelPyramid
11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
11278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry									TextureCubeArray	(const TextureFormat& format, int size, int depth);
11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									TextureCubeArray	(const TextureCubeArray& other);
11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~TextureCubeArray	(void);
11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry	int								getSize				(void) const	{ return m_size;	}
11328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry	int								getDepth			(void) const	{ return m_depth;	}
11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							allocLevel			(int levelNdx);
11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getFormat;
11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getNumLevels;
11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::getLevel;
11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::clearLevel;
11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using TextureLevelPyramid::isLevelEmpty;
11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float q, float lod) const;
11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float q, float lod, const IVec2& offset) const;
11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const;
11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float r, float q, float lod, const IVec2& offset) const;
11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCubeArray&				operator=			(const TextureCubeArray& other);
11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	operator TextureCubeArrayView (void) const { return m_view; }
11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int								m_size;
11538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry	int								m_depth;
11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureCubeArrayView			m_view;
115593df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCubeArray::sample (const Sampler& sampler, float s, float t, float r, float q, float lod) const
11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sample(sampler, s, t, r, q, lod);
11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline Vec4 TextureCubeArray::sampleOffset (const Sampler& sampler, float s, float t, float r, float q, float lod, const IVec2& offset) const
11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleOffset(sampler, s, t, r, q, lod, offset);
11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float TextureCubeArray::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const
11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleCompare(sampler, ref, s, t, r, q, lod);
11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline float TextureCubeArray::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod, const IVec2& offset) const
11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_view.sampleCompareOffset(sampler, ref, s, t, r, q, lod, offset);
11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Stream operators.
11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&		operator<<		(std::ostream& str, TextureFormat::ChannelOrder order);
11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&		operator<<		(std::ostream& str, TextureFormat::ChannelType type);
11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&		operator<<		(std::ostream& str, TextureFormat format);
11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&		operator<<		(std::ostream& str, CubeFace face);
11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::ostream&		operator<<		(std::ostream& str, const ConstPixelBufferAccess& access);
11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // tcu
11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _TCUTEXTURE_HPP
1187