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