tcuTexture.hpp revision 93df37596ea66700965094b3aa2830cf4f2ca5aa
1#ifndef _TCUTEXTURE_HPP
2#define _TCUTEXTURE_HPP
3/*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
5 * ----------------------------------------
6 *
7 * Copyright 2014 The Android Open Source Project
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 *      http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 *//*!
22 * \file
23 * \brief Reference Texture Implementation.
24 *//*--------------------------------------------------------------------*/
25
26#include "tcuDefs.hpp"
27#include "tcuVector.hpp"
28#include "deArrayBuffer.hpp"
29
30#include <vector>
31#include <ostream>
32
33namespace tcu
34{
35
36/*--------------------------------------------------------------------*//*!
37 * \brief Texture format
38 *//*--------------------------------------------------------------------*/
39class TextureFormat
40{
41public:
42	enum ChannelOrder
43	{
44		R = 0,
45		A,
46		I,
47		L,
48		LA,
49		RG,
50		RA,
51		RGB,
52		RGBA,
53		ARGB,
54		BGRA,
55
56		sRGB,
57		sRGBA,
58
59		D,
60		S,
61		DS,
62
63		CHANNELORDER_LAST
64	};
65
66	enum ChannelType
67	{
68		SNORM_INT8 = 0,
69		SNORM_INT16,
70		SNORM_INT32,
71		UNORM_INT8,
72		UNORM_INT16,
73		UNORM_INT32,
74		UNORM_SHORT_565,
75		UNORM_SHORT_555,
76		UNORM_SHORT_4444,
77		UNORM_SHORT_5551,
78		UNORM_INT_101010,
79		UNORM_INT_1010102_REV,
80		UNSIGNED_INT_1010102_REV,
81		UNSIGNED_INT_11F_11F_10F_REV,
82		UNSIGNED_INT_999_E5_REV,
83		UNSIGNED_INT_24_8,
84		SIGNED_INT8,
85		SIGNED_INT16,
86		SIGNED_INT32,
87		UNSIGNED_INT8,
88		UNSIGNED_INT16,
89		UNSIGNED_INT32,
90		HALF_FLOAT,
91		FLOAT,
92		FLOAT_UNSIGNED_INT_24_8_REV,
93
94		CHANNELTYPE_LAST
95	};
96
97	ChannelOrder	order;
98	ChannelType		type;
99
100	TextureFormat (ChannelOrder order_, ChannelType type_)
101		: order	(order_)
102		, type	(type_)
103	{
104	}
105
106	TextureFormat (void)
107		: order	(CHANNELORDER_LAST)
108		, type	(CHANNELTYPE_LAST)
109	{
110	}
111
112	int getPixelSize (void) const;
113
114	bool operator== (const TextureFormat& other) const { return !(*this != other); }
115	bool operator!= (const TextureFormat& other) const
116	{
117		return (order != other.order || type != other.type);
118	}
119} DE_WARN_UNUSED_TYPE;
120
121/*--------------------------------------------------------------------*//*!
122 * \brief Sampling parameters
123 *//*--------------------------------------------------------------------*/
124class Sampler
125{
126public:
127	enum WrapMode
128	{
129		CLAMP_TO_EDGE = 0,	//! Clamp to edge
130		CLAMP_TO_BORDER,	//! Use border color at edge
131		REPEAT_GL,			//! Repeat with OpenGL semantics
132		REPEAT_CL,			//! Repeat with OpenCL semantics
133		MIRRORED_REPEAT_GL,	//! Mirrored repeat with OpenGL semantics
134		MIRRORED_REPEAT_CL, //! Mirrored repeat with OpenCL semantics
135
136		WRAPMODE_LAST
137	};
138
139	enum FilterMode
140	{
141		NEAREST = 0,
142		LINEAR,
143
144		NEAREST_MIPMAP_NEAREST,
145		NEAREST_MIPMAP_LINEAR,
146		LINEAR_MIPMAP_NEAREST,
147		LINEAR_MIPMAP_LINEAR,
148
149		FILTERMODE_LAST
150	};
151
152	enum CompareMode
153	{
154		COMPAREMODE_NONE = 0,
155		COMPAREMODE_LESS,
156		COMPAREMODE_LESS_OR_EQUAL,
157		COMPAREMODE_GREATER,
158		COMPAREMODE_GREATER_OR_EQUAL,
159		COMPAREMODE_EQUAL,
160		COMPAREMODE_NOT_EQUAL,
161		COMPAREMODE_ALWAYS,
162		COMPAREMODE_NEVER,
163
164		COMPAREMODE_LAST
165	};
166
167	// Wrap control
168	WrapMode		wrapS;
169	WrapMode		wrapT;
170	WrapMode		wrapR;
171
172	// Minifcation & magnification
173	FilterMode		minFilter;
174	FilterMode		magFilter;
175	float			lodThreshold;		// lod <= lodThreshold ? magnified : minified
176
177	// Coordinate normalization
178	bool			normalizedCoords;
179
180	// Shadow comparison
181	CompareMode		compare;
182	int				compareChannel;
183
184	// Border color
185	Vec4			borderColor;
186
187	// Seamless cube map filtering
188	bool			seamlessCubeMap;
189
190	Sampler (WrapMode		wrapS_,
191			 WrapMode		wrapT_,
192			 WrapMode		wrapR_,
193			 FilterMode		minFilter_,
194			 FilterMode		magFilter_,
195			 float			lodThreshold_		= 0.0f,
196			 bool			normalizedCoords_	= true,
197			 CompareMode	compare_			= COMPAREMODE_NONE,
198			 int			compareChannel_		= 0,
199			 const Vec4&	borderColor_		= Vec4(0.0f, 0.0f, 0.0f, 0.0f),
200			 bool			seamlessCubeMap_	= false)
201		: wrapS				(wrapS_)
202		, wrapT				(wrapT_)
203		, wrapR				(wrapR_)
204		, minFilter			(minFilter_)
205		, magFilter			(magFilter_)
206		, lodThreshold		(lodThreshold_)
207		, normalizedCoords	(normalizedCoords_)
208		, compare			(compare_)
209		, compareChannel	(compareChannel_)
210		, borderColor		(borderColor_)
211		, seamlessCubeMap	(seamlessCubeMap_)
212	{
213	}
214
215	Sampler (void)
216		: wrapS				(WRAPMODE_LAST)
217		, wrapT				(WRAPMODE_LAST)
218		, wrapR				(WRAPMODE_LAST)
219		, minFilter			(FILTERMODE_LAST)
220		, magFilter			(FILTERMODE_LAST)
221		, lodThreshold		(0.0f)
222		, normalizedCoords	(true)
223		, compare			(COMPAREMODE_NONE)
224		, compareChannel	(0)
225		, borderColor		(0.0f, 0.0f, 0.0f, 0.0f)
226		, seamlessCubeMap	(false)
227	{
228	}
229} DE_WARN_UNUSED_TYPE;
230
231// Calculate pitches for pixel data with no padding.
232IVec3 calculatePackedPitch (const TextureFormat& format, const IVec3& size);
233
234class TextureLevel;
235
236/*--------------------------------------------------------------------*//*!
237 * \brief Read-only pixel data access
238 *
239 * ConstPixelBufferAccess encapsulates pixel data pointer along with
240 * format and layout information. It can be used for read-only access
241 * to arbitrary pixel buffers.
242 *
243 * Access objects are like iterators or pointers. They can be passed around
244 * as values and are valid as long as the storage doesn't change.
245 *//*--------------------------------------------------------------------*/
246class ConstPixelBufferAccess
247{
248public:
249							ConstPixelBufferAccess		(void);
250							ConstPixelBufferAccess		(const TextureLevel& level);
251							ConstPixelBufferAccess		(const TextureFormat& format, int width, int height, int depth, const void* data);
252							ConstPixelBufferAccess		(const TextureFormat& format, const IVec3& size, const void* data);
253							ConstPixelBufferAccess		(const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, const void* data);
254							ConstPixelBufferAccess		(const TextureFormat& format, const IVec3& size, const IVec3& pitch, const void* data);
255
256	const TextureFormat&	getFormat					(void) const	{ return m_format;					}
257	const IVec3&			getSize						(void) const	{ return m_size;					}
258	int						getWidth					(void) const	{ return m_size.x();				}
259	int						getHeight					(void) const	{ return m_size.y();				}
260	int						getDepth					(void) const	{ return m_size.z();				}
261	int						getRowPitch					(void) const	{ return m_pitch.y();				}
262	int						getSlicePitch				(void) const	{ return m_pitch.z();				}
263
264	const void*				getDataPtr					(void) const	{ return m_data;					}
265	int						getDataSize					(void) const	{ return m_size.z()*m_pitch.z();	}
266
267	Vec4					getPixel					(int x, int y, int z = 0) const;
268	IVec4					getPixelInt					(int x, int y, int z = 0) const;
269	UVec4					getPixelUint				(int x, int y, int z = 0) const { return getPixelInt(x, y, z).cast<deUint32>(); }
270
271	template<typename T>
272	Vector<T, 4>			getPixelT					(int x, int y, int z = 0) const;
273
274	float					getPixDepth					(int x, int y, int z = 0) const;
275	int						getPixStencil				(int x, int y, int z = 0) const;
276
277	Vec4					sample1D					(const Sampler& sampler, Sampler::FilterMode filter, float s, int level) const;
278	Vec4					sample2D					(const Sampler& sampler, Sampler::FilterMode filter, float s, float t, int depth) const;
279	Vec4					sample3D					(const Sampler& sampler, Sampler::FilterMode filter, float s, float t, float r) const;
280
281	Vec4					sample1DOffset				(const Sampler& sampler, Sampler::FilterMode filter, float s, const IVec2& offset) const;
282	Vec4					sample2DOffset				(const Sampler& sampler, Sampler::FilterMode filter, float s, float t, const IVec3& offset) const;
283	Vec4					sample3DOffset				(const Sampler& sampler, Sampler::FilterMode filter, float s, float t, float r, const IVec3& offset) const;
284
285	float					sample1DCompare				(const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, const IVec2& offset) const;
286	float					sample2DCompare				(const Sampler& sampler, Sampler::FilterMode filter, float ref, float s, float t, const IVec3& offset) const;
287
288protected:
289	TextureFormat			m_format;
290	IVec3					m_size;
291	IVec3					m_pitch;	//!< (pixelPitch, rowPitch, slicePitch)
292	mutable void*			m_data;
293} DE_WARN_UNUSED_TYPE;
294
295/*--------------------------------------------------------------------*//*!
296 * \brief Read-write pixel data access
297 *
298 * This class extends read-only access object by providing write functionality.
299 *
300 * \note PixelBufferAccess may not have any data members nor add any
301 *		 virtual functions. It must be possible to reinterpret_cast<>
302 *		 PixelBufferAccess to ConstPixelBufferAccess.
303 *//*--------------------------------------------------------------------*/
304class PixelBufferAccess : public ConstPixelBufferAccess
305{
306public:
307						PixelBufferAccess	(void) {}
308						PixelBufferAccess	(TextureLevel& level);
309						PixelBufferAccess	(const TextureFormat& format, int width, int height, int depth, void* data);
310						PixelBufferAccess	(const TextureFormat& format, const IVec3& size, void* data);
311						PixelBufferAccess	(const TextureFormat& format, int width, int height, int depth, int rowPitch, int slicePitch, void* data);
312						PixelBufferAccess	(const TextureFormat& format, const IVec3& size, const IVec3& pitch, void* data);
313
314	void*				getDataPtr			(void) const { return m_data; }
315
316	void				setPixels			(const void* buf, int bufSize) const;
317	void				setPixel			(const tcu::Vec4& color, int x, int y, int z = 0) const;
318	void				setPixel			(const tcu::IVec4& color, int x, int y, int z = 0) const;
319	void				setPixel			(const tcu::UVec4& color, int x, int y, int z = 0) const { setPixel(color.cast<int>(), x, y, z); }
320
321	void				setPixDepth			(float depth, int x, int y, int z = 0) const;
322	void				setPixStencil		(int stencil, int x, int y, int z = 0) const;
323} DE_WARN_UNUSED_TYPE;
324
325/*--------------------------------------------------------------------*//*!
326 * \brief Generic pixel data container
327 *
328 * This container supports all valid TextureFormat combinations and
329 * both 2D and 3D textures. To read or manipulate data access object must
330 * be queried using getAccess().
331 *//*--------------------------------------------------------------------*/
332class TextureLevel
333{
334public:
335								TextureLevel		(void);
336								TextureLevel		(const TextureFormat& format);
337								TextureLevel		(const TextureFormat& format, int width, int height, int depth = 1);
338								~TextureLevel		(void);
339
340	const IVec3&				getSize				(void) const	{ return m_size;		}
341	int							getWidth			(void) const	{ return m_size.x();	}
342	int							getHeight			(void) const	{ return m_size.y();	}
343	int							getDepth			(void) const	{ return m_size.z();	}
344	bool						isEmpty				(void) const	{ return m_size.x() * m_size.y() * m_size.z() == 0; }
345	const TextureFormat			getFormat			(void) const	{ return m_format;	}
346
347	void						setStorage			(const TextureFormat& format, int width, int heigth, int depth = 1);
348	void						setSize				(int width, int height, int depth = 1);
349
350	PixelBufferAccess			getAccess			(void)			{ return PixelBufferAccess(m_format, m_size, calculatePackedPitch(m_format, m_size), getPtr());			}
351	ConstPixelBufferAccess		getAccess			(void) const	{ return ConstPixelBufferAccess(m_format, m_size, calculatePackedPitch(m_format, m_size), getPtr());	}
352
353private:
354	void*						getPtr				(void)			{ return m_data.getPtr(); }
355	const void*					getPtr				(void) const	{ return m_data.getPtr(); }
356
357	TextureFormat				m_format;
358	IVec3						m_size;
359	de::ArrayBuffer<deUint8>	m_data;
360
361	friend class ConstPixelBufferAccess;
362} DE_WARN_UNUSED_TYPE;
363
364Vec4	sampleLevelArray1D				(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, int level, float lod);
365Vec4	sampleLevelArray2D				(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, int depth, float lod);
366Vec4	sampleLevelArray3D				(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float r, float lod);
367
368Vec4	sampleLevelArray1DOffset		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float lod, const IVec2& offset);
369Vec4	sampleLevelArray2DOffset		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float lod, const IVec3& offset);
370Vec4	sampleLevelArray3DOffset		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset);
371
372float	sampleLevelArray1DCompare		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float ref, float s, float lod, const IVec2& offset);
373float	sampleLevelArray2DCompare		(const ConstPixelBufferAccess* levels, int numLevels, const Sampler& sampler, float ref, float s, float t, float lod, const IVec3& offset);
374
375Vec4	gatherArray2DOffsets			(const ConstPixelBufferAccess& src, const Sampler& sampler, float s, float t, int depth, int componentNdx, const IVec2 (&offsets)[4]);
376Vec4	gatherArray2DOffsetsCompare		(const ConstPixelBufferAccess& src, const Sampler& sampler, float ref, float s, float t, int depth, const IVec2 (&offsets)[4]);
377
378enum CubeFace
379{
380	CUBEFACE_NEGATIVE_X = 0,
381	CUBEFACE_POSITIVE_X,
382	CUBEFACE_NEGATIVE_Y,
383	CUBEFACE_POSITIVE_Y,
384	CUBEFACE_NEGATIVE_Z,
385	CUBEFACE_POSITIVE_Z,
386
387	CUBEFACE_LAST
388};
389
390/*--------------------------------------------------------------------*//*!
391 * \brief Coordinates projected onto cube face.
392 *//*--------------------------------------------------------------------*/
393template<typename T>
394struct CubeFaceCoords
395{
396	CubeFace		face;
397	T				s;
398	T				t;
399
400					CubeFaceCoords		(CubeFace face_, T s_, T t_) : face(face_), s(s_), t(t_) {}
401					CubeFaceCoords		(CubeFace face_, const Vector<T, 2>& c) : face(face_), s(c.x()), t(c.y()) {}
402} DE_WARN_UNUSED_TYPE;
403
404typedef CubeFaceCoords<float>	CubeFaceFloatCoords;
405typedef CubeFaceCoords<int>		CubeFaceIntCoords;
406
407CubeFace				selectCubeFace			(const Vec3& coords);
408Vec2					projectToFace			(CubeFace face, const Vec3& coords);
409CubeFaceFloatCoords		getCubeFaceCoords		(const Vec3& coords);
410CubeFaceIntCoords		remapCubeEdgeCoords		(const CubeFaceIntCoords& coords, int size);
411
412/*--------------------------------------------------------------------*//*!
413 * \brief 1D Texture View
414 *//*--------------------------------------------------------------------*/
415class Texture1DView
416{
417public:
418									Texture1DView		(int numLevels, const ConstPixelBufferAccess* levels);
419
420	int								getNumLevels		(void) const	{ return m_numLevels;										}
421	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
422	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
423	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
424
425	Vec4							sample				(const Sampler& sampler, float s, float lod) const;
426	Vec4							sampleOffset		(const Sampler& sampler, float s, float lod, deInt32 offset) const;
427	float							sampleCompare		(const Sampler& sampler, float ref, float s, float lod) const;
428	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float lod, deInt32 offset) const;
429
430protected:
431	int								m_numLevels;
432	const ConstPixelBufferAccess*	m_levels;
433} DE_WARN_UNUSED_TYPE;
434
435inline Texture1DView::Texture1DView (int numLevels, const ConstPixelBufferAccess* levels)
436	: m_numLevels	(numLevels)
437	, m_levels		(levels)
438{
439	DE_ASSERT(m_numLevels >= 0 && ((m_numLevels == 0) == !m_levels));
440}
441
442inline Vec4 Texture1DView::sample (const Sampler& sampler, float s, float lod) const
443{
444	return sampleLevelArray1D(m_levels, m_numLevels, sampler, s, 0 /* depth */, lod);
445}
446
447inline Vec4 Texture1DView::sampleOffset (const Sampler& sampler, float s, float lod, deInt32 offset) const
448{
449	return sampleLevelArray1DOffset(m_levels, m_numLevels, sampler, s, lod, IVec2(offset, 0));
450}
451
452inline float Texture1DView::sampleCompare (const Sampler& sampler, float ref, float s, float lod) const
453{
454	return sampleLevelArray1DCompare(m_levels, m_numLevels, sampler, ref, s, lod, IVec2(0, 0));
455}
456
457inline float Texture1DView::sampleCompareOffset (const Sampler& sampler, float ref, float s, float lod, deInt32 offset) const
458{
459	return sampleLevelArray1DCompare(m_levels, m_numLevels, sampler, ref, s, lod, IVec2(offset, 0));
460}
461
462/*--------------------------------------------------------------------*//*!
463 * \brief 2D Texture View
464 *//*--------------------------------------------------------------------*/
465class Texture2DView
466{
467public:
468									Texture2DView		(int numLevels, const ConstPixelBufferAccess* levels);
469
470	int								getNumLevels		(void) const	{ return m_numLevels;										}
471	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
472	int								getHeight			(void) const	{ return m_numLevels > 0 ? m_levels[0].getHeight()	: 0;	}
473	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
474	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
475
476	Vec4							sample				(const Sampler& sampler, float s, float t, float lod) const;
477	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const;
478	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float lod) const;
479	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const;
480
481	Vec4							gatherOffsets		(const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const;
482	Vec4							gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const;
483
484protected:
485	int								m_numLevels;
486	const ConstPixelBufferAccess*	m_levels;
487} DE_WARN_UNUSED_TYPE;
488
489inline Texture2DView::Texture2DView (int numLevels, const ConstPixelBufferAccess* levels)
490	: m_numLevels	(numLevels)
491	, m_levels		(levels)
492{
493	DE_ASSERT(m_numLevels >= 0 && ((m_numLevels == 0) == !m_levels));
494}
495
496inline Vec4 Texture2DView::sample (const Sampler& sampler, float s, float t, float lod) const
497{
498	return sampleLevelArray2D(m_levels, m_numLevels, sampler, s, t, 0 /* depth */, lod);
499}
500
501inline Vec4 Texture2DView::sampleOffset (const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const
502{
503	return sampleLevelArray2DOffset(m_levels, m_numLevels, sampler, s, t, lod, IVec3(offset.x(), offset.y(), 0));
504}
505
506inline float Texture2DView::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const
507{
508	return sampleLevelArray2DCompare(m_levels, m_numLevels, sampler, ref, s, t, lod, IVec3(0, 0, 0));
509}
510
511inline float Texture2DView::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const
512{
513	return sampleLevelArray2DCompare(m_levels, m_numLevels, sampler, ref, s, t, lod, IVec3(offset.x(), offset.y(), 0));
514}
515
516inline Vec4 Texture2DView::gatherOffsets (const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const
517{
518	return gatherArray2DOffsets(m_levels[0], sampler, s, t, 0, componentNdx, offsets);
519}
520
521inline Vec4 Texture2DView::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const
522{
523	return gatherArray2DOffsetsCompare(m_levels[0], sampler, ref, s, t, 0, offsets);
524}
525
526/*--------------------------------------------------------------------*//*!
527 * \brief Base class for textures that have single mip-map pyramid
528 *//*--------------------------------------------------------------------*/
529class TextureLevelPyramid
530{
531public:
532									TextureLevelPyramid	(const TextureFormat& format, int numLevels);
533									TextureLevelPyramid	(const TextureLevelPyramid& other);
534									~TextureLevelPyramid(void);
535
536	const TextureFormat&			getFormat			(void) const			{ return m_format;					}
537	bool							isLevelEmpty		(int levelNdx) const	{ return m_data[levelNdx].empty();	}
538
539	int								getNumLevels		(void) const			{ return (int)m_access.size();		}
540	const ConstPixelBufferAccess&	getLevel			(int ndx) const			{ return m_access[ndx];				}
541	const PixelBufferAccess&		getLevel			(int ndx)				{ return m_access[ndx];				}
542
543	const ConstPixelBufferAccess*	getLevels			(void) const			{ return &m_access[0];				}
544	const PixelBufferAccess*		getLevels			(void)					{ return &m_access[0];				}
545
546	void							allocLevel			(int levelNdx, int width, int height, int depth);
547	void							clearLevel			(int levelNdx);
548
549	TextureLevelPyramid&			operator=			(const TextureLevelPyramid& other);
550
551private:
552	typedef de::ArrayBuffer<deUint8> LevelData;
553
554	TextureFormat					m_format;
555	std::vector<LevelData>			m_data;
556	std::vector<PixelBufferAccess>	m_access;
557} DE_WARN_UNUSED_TYPE;
558
559/*--------------------------------------------------------------------*//*!
560 * \brief 1D Texture reference implementation
561 *//*--------------------------------------------------------------------*/
562class Texture1D : private TextureLevelPyramid
563{
564public:
565									Texture1D			(const TextureFormat& format, int width);
566									Texture1D			(const Texture1D& other);
567									~Texture1D			(void);
568
569	int								getWidth			(void) const	{ return m_width;	}
570	const Texture1DView&			getView				(void) const	{ return m_view;	}
571
572	void							allocLevel			(int levelNdx);
573
574	// Sampling
575	Vec4							sample				(const Sampler& sampler, float s, float lod) const;
576	Vec4							sampleOffset		(const Sampler& sampler, float s, float lod, deInt32 offset) const;
577
578	using TextureLevelPyramid::getFormat;
579	using TextureLevelPyramid::getNumLevels;
580	using TextureLevelPyramid::getLevel;
581	using TextureLevelPyramid::clearLevel;
582	using TextureLevelPyramid::isLevelEmpty;
583
584	Texture1D&						operator=			(const Texture1D& other);
585
586	operator Texture1DView (void) const { return m_view; }
587
588private:
589	int								m_width;
590	Texture1DView					m_view;
591} DE_WARN_UNUSED_TYPE;
592
593inline Vec4 Texture1D::sample (const Sampler& sampler, float s, float lod) const
594{
595	return m_view.sample(sampler, s, lod);
596}
597
598inline Vec4 Texture1D::sampleOffset (const Sampler& sampler, float s, float lod, deInt32 offset) const
599{
600	return m_view.sampleOffset(sampler, s, lod, offset);
601}
602
603/*--------------------------------------------------------------------*//*!
604 * \brief 2D Texture reference implementation
605 *//*--------------------------------------------------------------------*/
606class Texture2D : private TextureLevelPyramid
607{
608public:
609									Texture2D			(const TextureFormat& format, int width, int height);
610									Texture2D			(const Texture2D& other);
611									~Texture2D			(void);
612
613	int								getWidth			(void) const	{ return m_width;	}
614	int								getHeight			(void) const	{ return m_height;	}
615	const Texture2DView&			getView				(void) const	{ return m_view;	}
616
617	void							allocLevel			(int levelNdx);
618
619	// Sampling
620	Vec4							sample				(const Sampler& sampler, float s, float t, float lod) const;
621	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const;
622	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float lod) const;
623	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const;
624
625	Vec4							gatherOffsets		(const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const;
626	Vec4							gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const;
627
628	using TextureLevelPyramid::getFormat;
629	using TextureLevelPyramid::getNumLevels;
630	using TextureLevelPyramid::getLevel;
631	using TextureLevelPyramid::clearLevel;
632	using TextureLevelPyramid::isLevelEmpty;
633
634	Texture2D&						operator=			(const Texture2D& other);
635
636	operator Texture2DView (void) const { return m_view; }
637
638private:
639	int								m_width;
640	int								m_height;
641	Texture2DView					m_view;
642} DE_WARN_UNUSED_TYPE;
643
644inline Vec4 Texture2D::sample (const Sampler& sampler, float s, float t, float lod) const
645{
646	return m_view.sample(sampler, s, t, lod);
647}
648
649inline Vec4 Texture2D::sampleOffset (const Sampler& sampler, float s, float t, float lod, const IVec2& offset) const
650{
651	return m_view.sampleOffset(sampler, s, t, lod, offset);
652}
653
654inline float Texture2D::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const
655{
656	return m_view.sampleCompare(sampler, ref, s, t, lod);
657}
658
659inline float Texture2D::sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, const IVec2& offset) const
660{
661	return m_view.sampleCompareOffset(sampler, ref, s, t, lod, offset);
662}
663
664inline Vec4 Texture2D::gatherOffsets (const Sampler& sampler, float s, float t, int componentNdx, const IVec2 (&offsets)[4]) const
665{
666	return m_view.gatherOffsets(sampler, s, t, componentNdx, offsets);
667}
668
669inline Vec4 Texture2D::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, const IVec2 (&offsets)[4]) const
670{
671	return m_view.gatherOffsetsCompare(sampler, ref, s, t, offsets);
672}
673
674/*--------------------------------------------------------------------*//*!
675 * \brief Cube Map Texture View
676 *//*--------------------------------------------------------------------*/
677class TextureCubeView
678{
679public:
680									TextureCubeView		(void);
681									TextureCubeView		(int numLevels, const ConstPixelBufferAccess* const (&levels)[CUBEFACE_LAST]);
682
683	int								getNumLevels		(void) const	{ return m_numLevels;										}
684	int								getSize				(void) const	{ return m_numLevels > 0 ? m_levels[0][0].getWidth() : 0;	}
685	const ConstPixelBufferAccess&	getLevelFace		(int ndx, CubeFace face) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[face][ndx];	}
686	const ConstPixelBufferAccess*	getFaceLevels		(CubeFace face) const			{ return m_levels[face];					}
687
688	Vec4							sample				(const Sampler& sampler, float s, float t, float p, float lod) const;
689	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float lod) const;
690
691	Vec4							gather				(const Sampler& sampler, float s, float t, float r, int componentNdx) const;
692	Vec4							gatherCompare		(const Sampler& sampler, float ref, float s, float t, float r) const;
693
694protected:
695	int								m_numLevels;
696	const ConstPixelBufferAccess*	m_levels[CUBEFACE_LAST];
697} DE_WARN_UNUSED_TYPE;
698
699/*--------------------------------------------------------------------*//*!
700 * \brief Cube Map Texture reference implementation
701 *//*--------------------------------------------------------------------*/
702class TextureCube
703{
704public:
705									TextureCube			(const TextureFormat& format, int size);
706									TextureCube			(const TextureCube& other);
707									~TextureCube		(void);
708
709	const TextureFormat&			getFormat			(void) const	{ return m_format;	}
710	int								getSize				(void) const	{ return m_size;	}
711
712	int								getNumLevels		(void) const					{ return (int)m_access[0].size();	}
713	const ConstPixelBufferAccess&	getLevelFace		(int ndx, CubeFace face) const	{ return m_access[face][ndx];		}
714	const PixelBufferAccess&		getLevelFace		(int ndx, CubeFace face)		{ return m_access[face][ndx];		}
715
716	void							allocLevel			(CubeFace face, int levelNdx);
717	void							clearLevel			(CubeFace face, int levelNdx);
718	bool							isLevelEmpty		(CubeFace face, int levelNdx) const		{ return m_data[face][levelNdx].empty();	}
719
720	Vec4							sample				(const Sampler& sampler, float s, float t, float p, float lod) const;
721	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float lod) const;
722
723	Vec4							gather				(const Sampler& sampler, float s, float t, float r, int componentNdx) const;
724	Vec4							gatherCompare		(const Sampler& sampler, float ref, float s, float t, float r) const;
725
726	TextureCube&					operator=			(const TextureCube& other);
727
728	operator TextureCubeView (void) const { return m_view; }
729
730private:
731	typedef de::ArrayBuffer<deUint8> LevelData;
732
733	TextureFormat					m_format;
734	int								m_size;
735	std::vector<LevelData>			m_data[CUBEFACE_LAST];
736	std::vector<PixelBufferAccess>	m_access[CUBEFACE_LAST];
737	TextureCubeView					m_view;
738} DE_WARN_UNUSED_TYPE;
739
740inline Vec4 TextureCube::sample (const Sampler& sampler, float s, float t, float p, float lod) const
741{
742	return m_view.sample(sampler, s, t, p, lod);
743}
744
745inline float TextureCube::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const
746{
747	return m_view.sampleCompare(sampler, ref, s, t, r, lod);
748}
749
750inline Vec4 TextureCube::gather (const Sampler& sampler, float s, float t, float r, int componentNdx) const
751{
752	return m_view.gather(sampler, s, t, r, componentNdx);
753}
754
755inline Vec4 TextureCube::gatherCompare (const Sampler& sampler, float ref, float s, float t, float r) const
756{
757	return m_view.gatherCompare(sampler, ref, s, t, r);
758}
759
760/*--------------------------------------------------------------------*//*!
761 * \brief 1D Array Texture View
762 *//*--------------------------------------------------------------------*/
763class Texture1DArrayView
764{
765public:
766									Texture1DArrayView	(int numLevels, const ConstPixelBufferAccess* levels);
767
768	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
769	int								getNumLayers		(void) const	{ return m_numLevels > 0 ? m_levels[0].getHeight()	: 0;	}
770	int								getNumLevels		(void) const	{ return m_numLevels;										}
771	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
772	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
773
774	Vec4							sample				(const Sampler& sampler, float s, float t, float lod) const;
775	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float lod, deInt32 offset) const;
776	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float lod) const;
777	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const;
778
779protected:
780	int								selectLayer			(float r) const;
781
782	int								m_numLevels;
783	const ConstPixelBufferAccess*	m_levels;
784} DE_WARN_UNUSED_TYPE;
785
786/*--------------------------------------------------------------------*//*!
787 * \brief 2D Array Texture View
788 *//*--------------------------------------------------------------------*/
789class Texture2DArrayView
790{
791public:
792									Texture2DArrayView	(int numLevels, const ConstPixelBufferAccess* levels);
793
794	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
795	int								getHeight			(void) const	{ return m_numLevels > 0 ? m_levels[0].getHeight()	: 0;	}
796	int								getNumLayers		(void) const	{ return m_numLevels > 0 ? m_levels[0].getDepth()	: 0;	}
797	int								getNumLevels		(void) const	{ return m_numLevels;										}
798	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
799	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
800
801	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float lod) const;
802	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const;
803	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float lod) const;
804	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const;
805
806	Vec4							gatherOffsets		(const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const;
807	Vec4							gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const;
808
809protected:
810	int								selectLayer			(float r) const;
811
812	int								m_numLevels;
813	const ConstPixelBufferAccess*	m_levels;
814} DE_WARN_UNUSED_TYPE;
815
816/*--------------------------------------------------------------------*//*!
817 * \brief 1D Array Texture reference implementation
818 *//*--------------------------------------------------------------------*/
819class Texture1DArray : private TextureLevelPyramid
820{
821public:
822									Texture1DArray		(const TextureFormat& format, int width, int numLayers);
823									Texture1DArray		(const Texture1DArray& other);
824									~Texture1DArray		(void);
825
826	int								getWidth			(void) const	{ return m_width;		}
827	int								getNumLayers		(void) const	{ return m_numLayers;	}
828
829	void							allocLevel			(int levelNdx);
830
831	using TextureLevelPyramid::getFormat;
832	using TextureLevelPyramid::getNumLevels;
833	using TextureLevelPyramid::getLevel;
834	using TextureLevelPyramid::clearLevel;
835	using TextureLevelPyramid::isLevelEmpty;
836
837	Vec4							sample				(const Sampler& sampler, float s, float t, float lod) const;
838	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float lod, deInt32 offset) const;
839	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float lod) const;
840	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const;
841
842	Texture1DArray&					operator=			(const Texture1DArray& other);
843
844	operator Texture1DArrayView (void) const { return m_view; }
845
846private:
847	int								m_width;
848	int								m_numLayers;
849	Texture1DArrayView				m_view;
850} DE_WARN_UNUSED_TYPE;
851
852inline Vec4 Texture1DArray::sample (const Sampler& sampler, float s, float t, float lod) const
853{
854	return m_view.sample(sampler, s, t, lod);
855}
856
857inline Vec4 Texture1DArray::sampleOffset (const Sampler& sampler, float s, float t, float lod, deInt32 offset) const
858{
859	return m_view.sampleOffset(sampler, s, t, lod, offset);
860}
861
862inline float Texture1DArray::sampleCompare (const Sampler& sampler, float ref, float s, float t, float lod) const
863{
864	return m_view.sampleCompare(sampler, ref, s, t, lod);
865}
866
867inline float Texture1DArray::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float lod, deInt32 offset) const
868{
869	return m_view.sampleCompareOffset(sampler, ref, s, t, lod, offset);
870}
871
872/*--------------------------------------------------------------------*//*!
873 * \brief 2D Array Texture reference implementation
874 *//*--------------------------------------------------------------------*/
875class Texture2DArray : private TextureLevelPyramid
876{
877public:
878									Texture2DArray		(const TextureFormat& format, int width, int height, int numLayers);
879									Texture2DArray		(const Texture2DArray& other);
880									~Texture2DArray		(void);
881
882	int								getWidth			(void) const	{ return m_width;		}
883	int								getHeight			(void) const	{ return m_height;		}
884	int								getNumLayers		(void) const	{ return m_numLayers;	}
885
886	void							allocLevel			(int levelNdx);
887
888	using TextureLevelPyramid::getFormat;
889	using TextureLevelPyramid::getNumLevels;
890	using TextureLevelPyramid::getLevel;
891	using TextureLevelPyramid::clearLevel;
892	using TextureLevelPyramid::isLevelEmpty;
893
894	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float lod) const;
895	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const;
896	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float lod) const;
897	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const;
898
899	Vec4							gatherOffsets		(const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const;
900	Vec4							gatherOffsetsCompare(const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const;
901
902	Texture2DArray&					operator=			(const Texture2DArray& other);
903
904	operator Texture2DArrayView (void) const { return m_view; }
905
906private:
907	int								m_width;
908	int								m_height;
909	int								m_numLayers;
910	Texture2DArrayView				m_view;
911} DE_WARN_UNUSED_TYPE;
912
913inline Vec4 Texture2DArray::sample (const Sampler& sampler, float s, float t, float r, float lod) const
914{
915	return m_view.sample(sampler, s, t, r, lod);
916}
917
918inline Vec4 Texture2DArray::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec2& offset) const
919{
920	return m_view.sampleOffset(sampler, s, t, r, lod, offset);
921}
922
923inline float Texture2DArray::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float lod) const
924{
925	return m_view.sampleCompare(sampler, ref, s, t, r, lod);
926}
927
928inline float Texture2DArray::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float lod, const IVec2& offset) const
929{
930	return m_view.sampleCompareOffset(sampler, ref, s, t, r, lod, offset);
931}
932
933inline Vec4 Texture2DArray::gatherOffsets (const Sampler& sampler, float s, float t, float r, int componentNdx, const IVec2 (&offsets)[4]) const
934{
935	return m_view.gatherOffsets(sampler, s, t, r, componentNdx, offsets);
936}
937
938inline Vec4 Texture2DArray::gatherOffsetsCompare (const Sampler& sampler, float ref, float s, float t, float r, const IVec2 (&offsets)[4]) const
939{
940	return m_view.gatherOffsetsCompare(sampler, ref, s, t, r, offsets);
941}
942
943/*--------------------------------------------------------------------*//*!
944 * \brief 3D Texture View
945 *//*--------------------------------------------------------------------*/
946class Texture3DView
947{
948public:
949									Texture3DView		(int numLevels, const ConstPixelBufferAccess* levels);
950
951	int								getWidth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
952	int								getHeight			(void) const	{ return m_numLevels > 0 ? m_levels[0].getHeight()	: 0;	}
953	int								getDepth			(void) const	{ return m_numLevels > 0 ? m_levels[0].getDepth()	: 0;	}
954	int								getNumLevels		(void) const	{ return m_numLevels;										}
955	const ConstPixelBufferAccess&	getLevel			(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
956	const ConstPixelBufferAccess*	getLevels			(void) const	{ return m_levels;											}
957
958	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float lod) const;
959	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const;
960
961protected:
962	int								m_numLevels;
963	const ConstPixelBufferAccess*	m_levels;
964} DE_WARN_UNUSED_TYPE;
965
966inline Vec4 Texture3DView::sample (const Sampler& sampler, float s, float t, float r, float lod) const
967{
968	return sampleLevelArray3D(m_levels, m_numLevels, sampler, s, t, r, lod);
969}
970
971inline Vec4 Texture3DView::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const
972{
973	return sampleLevelArray3DOffset(m_levels, m_numLevels, sampler, s, t, r, lod, offset);
974}
975
976/*--------------------------------------------------------------------*//*!
977 * \brief 3D Texture reference implementation
978 *//*--------------------------------------------------------------------*/
979class Texture3D : private TextureLevelPyramid
980{
981public:
982									Texture3D			(const TextureFormat& format, int width, int height, int depth);
983									Texture3D			(const Texture3D& other);
984									~Texture3D			(void);
985
986	int								getWidth			(void) const	{ return m_width;	}
987	int								getHeight			(void) const	{ return m_height;	}
988	int								getDepth			(void) const	{ return m_depth;	}
989
990	void							allocLevel			(int levelNdx);
991
992	using TextureLevelPyramid::getFormat;
993	using TextureLevelPyramid::getNumLevels;
994	using TextureLevelPyramid::getLevel;
995	using TextureLevelPyramid::clearLevel;
996	using TextureLevelPyramid::isLevelEmpty;
997
998	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float lod) const;
999	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const;
1000
1001	Texture3D&						operator=			(const Texture3D& other);
1002
1003	operator Texture3DView (void) const { return m_view; }
1004
1005private:
1006	int								m_width;
1007	int								m_height;
1008	int								m_depth;
1009	Texture3DView					m_view;
1010} DE_WARN_UNUSED_TYPE;
1011
1012inline Vec4 Texture3D::sample (const Sampler& sampler, float s, float t, float r, float lod) const
1013{
1014	return m_view.sample(sampler, s, t, r, lod);
1015}
1016
1017inline Vec4 Texture3D::sampleOffset (const Sampler& sampler, float s, float t, float r, float lod, const IVec3& offset) const
1018{
1019	return m_view.sampleOffset(sampler, s, t, r, lod, offset);
1020}
1021
1022/*--------------------------------------------------------------------*//*!
1023 * \brief Cube Map Array Texture View
1024 *//*--------------------------------------------------------------------*/
1025class TextureCubeArrayView
1026{
1027public:
1028									TextureCubeArrayView	(int numLevels, const ConstPixelBufferAccess* levels);
1029
1030	int								getSize					(void) const	{ return m_numLevels > 0 ? m_levels[0].getWidth()	: 0;	}
1031	int								getDepth				(void) const	{ return m_numLevels > 0 ? m_levels[0].getDepth()	: 0;	}
1032	int								getNumLayers			(void) const	{ return getDepth()	/ 6;	}
1033	int								getNumLevels			(void) const	{ return m_numLevels;										}
1034	const ConstPixelBufferAccess&	getLevel				(int ndx) const	{ DE_ASSERT(de::inBounds(ndx, 0, m_numLevels)); return m_levels[ndx];	}
1035	const ConstPixelBufferAccess*	getLevels				(void) const	{ return m_levels;											}
1036
1037	Vec4							sample					(const Sampler& sampler, float s, float t, float r, float q, float lod) const;
1038	Vec4							sampleOffset			(const Sampler& sampler, float s, float t, float r, float q, float lod, const IVec2& offset) const;
1039	float							sampleCompare			(const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const;
1040	float							sampleCompareOffset		(const Sampler& sampler, float ref, float s, float t, float r, float q, float lod, const IVec2& offset) const;
1041
1042protected:
1043	int								selectLayer				(float q) const;
1044
1045	int								m_numLevels;
1046	const ConstPixelBufferAccess*	m_levels;
1047} DE_WARN_UNUSED_TYPE;
1048
1049/*--------------------------------------------------------------------*//*!
1050 * \brief Cube Map Array Texture reference implementation
1051 *//*--------------------------------------------------------------------*/
1052class TextureCubeArray : private TextureLevelPyramid
1053{
1054public:
1055									TextureCubeArray	(const TextureFormat& format, int size, int depth);
1056									TextureCubeArray	(const TextureCubeArray& other);
1057									~TextureCubeArray	(void);
1058
1059	int								getSize				(void) const	{ return m_size;	}
1060	int								getDepth			(void) const	{ return m_depth;	}
1061
1062	void							allocLevel			(int levelNdx);
1063
1064	using TextureLevelPyramid::getFormat;
1065	using TextureLevelPyramid::getNumLevels;
1066	using TextureLevelPyramid::getLevel;
1067	using TextureLevelPyramid::clearLevel;
1068	using TextureLevelPyramid::isLevelEmpty;
1069
1070	Vec4							sample				(const Sampler& sampler, float s, float t, float r, float q, float lod) const;
1071	Vec4							sampleOffset		(const Sampler& sampler, float s, float t, float r, float q, float lod, const IVec2& offset) const;
1072	float							sampleCompare		(const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const;
1073	float							sampleCompareOffset	(const Sampler& sampler, float ref, float s, float t, float r, float q, float lod, const IVec2& offset) const;
1074
1075	TextureCubeArray&				operator=			(const TextureCubeArray& other);
1076
1077	operator TextureCubeArrayView (void) const { return m_view; }
1078
1079private:
1080	int								m_size;
1081	int								m_depth;
1082	TextureCubeArrayView			m_view;
1083} DE_WARN_UNUSED_TYPE;
1084
1085inline Vec4 TextureCubeArray::sample (const Sampler& sampler, float s, float t, float r, float q, float lod) const
1086{
1087	return m_view.sample(sampler, s, t, r, q, lod);
1088}
1089
1090inline Vec4 TextureCubeArray::sampleOffset (const Sampler& sampler, float s, float t, float r, float q, float lod, const IVec2& offset) const
1091{
1092	return m_view.sampleOffset(sampler, s, t, r, q, lod, offset);
1093}
1094
1095inline float TextureCubeArray::sampleCompare (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod) const
1096{
1097	return m_view.sampleCompare(sampler, ref, s, t, r, q, lod);
1098}
1099
1100inline float TextureCubeArray::sampleCompareOffset (const Sampler& sampler, float ref, float s, float t, float r, float q, float lod, const IVec2& offset) const
1101{
1102	return m_view.sampleCompareOffset(sampler, ref, s, t, r, q, lod, offset);
1103}
1104
1105// Stream operators.
1106std::ostream&		operator<<		(std::ostream& str, TextureFormat::ChannelOrder order);
1107std::ostream&		operator<<		(std::ostream& str, TextureFormat::ChannelType type);
1108std::ostream&		operator<<		(std::ostream& str, TextureFormat format);
1109std::ostream&		operator<<		(std::ostream& str, CubeFace face);
1110std::ostream&		operator<<		(std::ostream& str, const ConstPixelBufferAccess& access);
1111
1112} // tcu
1113
1114#endif // _TCUTEXTURE_HPP
1115