1 #ifndef _GLSTEXTURETESTUTIL_HPP
2 #define _GLSTEXTURETESTUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program OpenGL (ES) Module
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 Texture test utilities.
24  *
25  * About coordinates:
26  *  + Quads consist of 2 triangles, rendered using explicit indices.
27  *  + All TextureTestUtil functions and classes expect texture coordinates
28  *    for quads to be specified in order (-1, -1), (-1, 1), (1, -1), (1, 1).
29  *//*--------------------------------------------------------------------*/
30 
31 #include "tcuDefs.hpp"
32 #include "tcuTexture.hpp"
33 #include "tcuSurface.hpp"
34 #include "tcuPixelFormat.hpp"
35 #include "tcuRenderTarget.hpp"
36 #include "tcuTestContext.hpp"
37 #include "tcuTestLog.hpp"
38 #include "tcuCompressedTexture.hpp"
39 #include "tcuTextureUtil.hpp"
40 
41 #include "gluShaderProgram.hpp"
42 #include "gluShaderUtil.hpp"
43 
44 #include "deMath.h"
45 #include "deInt32.h"
46 
47 #include <map>
48 
49 namespace tcu
50 {
51 struct LookupPrecision;
52 struct LodPrecision;
53 struct TexComparePrecision;
54 }
55 
56 namespace deqp
57 {
58 namespace gls
59 {
60 namespace TextureTestUtil
61 {
62 
63 enum TextureType
64 {
65 	TEXTURETYPE_2D = 0,
66 	TEXTURETYPE_CUBE,
67 	TEXTURETYPE_2D_ARRAY,
68 	TEXTURETYPE_3D,
69 	TEXTURETYPE_CUBE_ARRAY,
70 	TEXTURETYPE_1D,
71 	TEXTURETYPE_1D_ARRAY,
72 	TEXTURETYPE_BUFFER,
73 
74 	TEXTURETYPE_LAST
75 };
76 
77 enum SamplerType
78 {
79 	SAMPLERTYPE_FLOAT,
80 	SAMPLERTYPE_INT,
81 	SAMPLERTYPE_UINT,
82 	SAMPLERTYPE_SHADOW,
83 
84 	SAMPLERTYPE_FETCH_FLOAT,
85 	SAMPLERTYPE_FETCH_INT,
86 	SAMPLERTYPE_FETCH_UINT,
87 
88 	SAMPLERTYPE_LAST
89 };
90 
91 SamplerType		getSamplerType		(tcu::TextureFormat format);
92 SamplerType		getFetchSamplerType	(tcu::TextureFormat format);
93 
94 struct RenderParams
95 {
96 	enum Flags
97 	{
98 		PROJECTED		= (1<<0),
99 		USE_BIAS		= (1<<1),
100 		LOG_PROGRAMS	= (1<<2),
101 		LOG_UNIFORMS	= (1<<3),
102 
103 		LOG_ALL			= LOG_PROGRAMS|LOG_UNIFORMS
104 	};
105 
RenderParamsdeqp::gls::TextureTestUtil::RenderParams106 	RenderParams (TextureType texType_)
107 		: texType		(texType_)
108 		, samplerType	(SAMPLERTYPE_FLOAT)
109 		, flags			(0)
110 		, w				(1.0f)
111 		, bias			(0.0f)
112 		, ref			(0.0f)
113 		, colorScale	(1.0f)
114 		, colorBias		(0.0f)
115 	{
116 	}
117 
118 	TextureType		texType;		//!< Texture type.
119 	SamplerType		samplerType;	//!< Sampler type.
120 	deUint32		flags;			//!< Feature flags.
121 	tcu::Vec4		w;				//!< w coordinates for quad vertices.
122 	float			bias;			//!< User-supplied bias.
123 	float			ref;			//!< Reference value for shadow lookups.
124 
125 	// color = lookup() * scale + bias
126 	tcu::Vec4		colorScale;		//!< Scale for texture color values.
127 	tcu::Vec4		colorBias;		//!< Bias for texture color values.
128 };
129 
130 enum Program
131 {
132 	PROGRAM_2D_FLOAT = 0,
133 	PROGRAM_2D_INT,
134 	PROGRAM_2D_UINT,
135 	PROGRAM_2D_SHADOW,
136 
137 	PROGRAM_2D_FLOAT_BIAS,
138 	PROGRAM_2D_INT_BIAS,
139 	PROGRAM_2D_UINT_BIAS,
140 	PROGRAM_2D_SHADOW_BIAS,
141 
142 	PROGRAM_1D_FLOAT,
143 	PROGRAM_1D_INT,
144 	PROGRAM_1D_UINT,
145 	PROGRAM_1D_SHADOW,
146 
147 	PROGRAM_1D_FLOAT_BIAS,
148 	PROGRAM_1D_INT_BIAS,
149 	PROGRAM_1D_UINT_BIAS,
150 	PROGRAM_1D_SHADOW_BIAS,
151 
152 	PROGRAM_CUBE_FLOAT,
153 	PROGRAM_CUBE_INT,
154 	PROGRAM_CUBE_UINT,
155 	PROGRAM_CUBE_SHADOW,
156 
157 	PROGRAM_CUBE_FLOAT_BIAS,
158 	PROGRAM_CUBE_INT_BIAS,
159 	PROGRAM_CUBE_UINT_BIAS,
160 	PROGRAM_CUBE_SHADOW_BIAS,
161 
162 	PROGRAM_1D_ARRAY_FLOAT,
163 	PROGRAM_1D_ARRAY_INT,
164 	PROGRAM_1D_ARRAY_UINT,
165 	PROGRAM_1D_ARRAY_SHADOW,
166 
167 	PROGRAM_2D_ARRAY_FLOAT,
168 	PROGRAM_2D_ARRAY_INT,
169 	PROGRAM_2D_ARRAY_UINT,
170 	PROGRAM_2D_ARRAY_SHADOW,
171 
172 	PROGRAM_3D_FLOAT,
173 	PROGRAM_3D_INT,
174 	PROGRAM_3D_UINT,
175 
176 	PROGRAM_3D_FLOAT_BIAS,
177 	PROGRAM_3D_INT_BIAS,
178 	PROGRAM_3D_UINT_BIAS,
179 
180 	PROGRAM_CUBE_ARRAY_FLOAT,
181 	PROGRAM_CUBE_ARRAY_INT,
182 	PROGRAM_CUBE_ARRAY_UINT,
183 	PROGRAM_CUBE_ARRAY_SHADOW,
184 
185 	PROGRAM_BUFFER_FLOAT,
186 	PROGRAM_BUFFER_INT,
187 	PROGRAM_BUFFER_UINT,
188 
189 	PROGRAM_LAST
190 };
191 
192 class ProgramLibrary
193 {
194 public:
195 											ProgramLibrary			(const glu::RenderContext& context, tcu::TestLog& log, glu::GLSLVersion glslVersion, glu::Precision texCoordPrecision);
196 											~ProgramLibrary			(void);
197 
198 	glu::ShaderProgram*						getProgram				(Program program);
199 	void									clear					(void);
200 
201 private:
202 											ProgramLibrary			(const ProgramLibrary& other);
203 	ProgramLibrary&							operator=				(const ProgramLibrary& other);
204 
205 	const glu::RenderContext&				m_context;
206 	tcu::TestLog&							m_log;
207 	glu::GLSLVersion						m_glslVersion;
208 	glu::Precision							m_texCoordPrecision;
209 	std::map<Program, glu::ShaderProgram*>	m_programs;
210 };
211 
212 class TextureRenderer
213 {
214 public:
215 								TextureRenderer			(const glu::RenderContext& context, tcu::TestLog& log, glu::GLSLVersion glslVersion, glu::Precision texCoordPrecision);
216 								~TextureRenderer		(void);
217 
218 	void						clear					(void); //!< Frees allocated resources. Destructor will call clear() as well.
219 
220 	void						renderQuad				(int texUnit, const float* texCoord, TextureType texType);
221 	void						renderQuad				(int texUnit, const float* texCoord, const RenderParams& params);
222 
223 private:
224 								TextureRenderer			(const TextureRenderer& other);
225 	TextureRenderer&			operator=				(const TextureRenderer& other);
226 
227 	const glu::RenderContext&	m_renderCtx;
228 	tcu::TestLog&				m_log;
229 	ProgramLibrary				m_programLibrary;
230 };
231 
232 class RandomViewport
233 {
234 public:
235 	int		x;
236 	int		y;
237 	int		width;
238 	int		height;
239 
240 	RandomViewport (const tcu::RenderTarget& renderTarget, int preferredWidth, int preferredHeight, deUint32 seed);
241 };
242 
toRGBA(const tcu::Vec4 & v)243 inline tcu::RGBA toRGBA (const tcu::Vec4& v)
244 {
245 	return tcu::RGBA(tcu::floatToU8(v.x()),
246 					 tcu::floatToU8(v.y()),
247 					 tcu::floatToU8(v.z()),
248 					 tcu::floatToU8(v.w()));
249 }
250 
toRGBAMasked(const tcu::Vec4 & v,deUint8 mask)251 inline tcu::RGBA toRGBAMasked (const tcu::Vec4& v, deUint8 mask)
252 {
253 	return tcu::RGBA((mask&tcu::RGBA::RED_MASK)		? tcu::floatToU8(v.x()) : 0,
254 					 (mask&tcu::RGBA::GREEN_MASK)	? tcu::floatToU8(v.y()) : 0,
255 					 (mask&tcu::RGBA::BLUE_MASK)	? tcu::floatToU8(v.z()) : 0,
256 					 (mask&tcu::RGBA::ALPHA_MASK)	? tcu::floatToU8(v.w()) : 0xFF); //!< \note Alpha defaults to full saturation when reading masked format
257 }
258 
toVec4(const tcu::RGBA & c)259 inline tcu::Vec4 toVec4 (const tcu::RGBA& c)
260 {
261 	return tcu::Vec4(c.getRed()		/ 255.0f,
262 					 c.getGreen()	/ 255.0f,
263 					 c.getBlue()	/ 255.0f,
264 					 c.getAlpha()	/ 255.0f);
265 }
266 
getColorMask(const tcu::PixelFormat & format)267 inline deUint8 getColorMask (const tcu::PixelFormat& format)
268 {
269 	return (format.redBits		? tcu::RGBA::RED_MASK	: 0) |
270 		   (format.greenBits	? tcu::RGBA::GREEN_MASK	: 0) |
271 		   (format.blueBits		? tcu::RGBA::BLUE_MASK	: 0) |
272 		   (format.alphaBits	? tcu::RGBA::ALPHA_MASK	: 0);
273 }
274 
getBitsVec(const tcu::PixelFormat & format)275 inline tcu::IVec4 getBitsVec (const tcu::PixelFormat& format)
276 {
277 	return tcu::IVec4(format.redBits, format.greenBits, format.blueBits, format.alphaBits);
278 }
279 
getCompareMask(const tcu::PixelFormat & format)280 inline tcu::BVec4 getCompareMask (const tcu::PixelFormat& format)
281 {
282 	return tcu::BVec4(format.redBits	> 0,
283 					  format.greenBits	> 0,
284 					  format.blueBits	> 0,
285 					  format.alphaBits	> 0);
286 }
287 
288 // \todo [2012-02-09 pyry] Move to tcuSurfaceAccess?
289 class SurfaceAccess
290 {
291 public:
292 							SurfaceAccess		(tcu::Surface& surface, const tcu::PixelFormat& colorFmt);
293 							SurfaceAccess		(tcu::Surface& surface, const tcu::PixelFormat& colorFmt, int x, int y, int width, int height);
294 							SurfaceAccess		(const SurfaceAccess& parent, int x, int y, int width, int height);
295 
getWidth(void) const296 	int						getWidth			(void) const	{ return m_width;	}
getHeight(void) const297 	int						getHeight			(void) const	{ return m_height;	}
298 
299 	void					setPixel			(const tcu::Vec4& color, int x, int y) const;
300 
301 private:
302 	mutable tcu::Surface*	m_surface;
303 	deUint8					m_colorMask;
304 	int						m_x;
305 	int						m_y;
306 	int						m_width;
307 	int						m_height;
308 };
309 
setPixel(const tcu::Vec4 & color,int x,int y) const310 inline void SurfaceAccess::setPixel (const tcu::Vec4& color, int x, int y) const
311 {
312 	DE_ASSERT(de::inBounds(x, 0, m_width) && de::inBounds(y, 0, m_height));
313 	m_surface->setPixel(m_x+x, m_y+y, toRGBAMasked(color, m_colorMask));
314 }
315 
316 enum LodMode
317 {
318 	LODMODE_EXACT = 0,		//!< Ideal lod computation.
319 	LODMODE_MIN_BOUND,		//!< Use estimation range minimum bound.
320 	LODMODE_MAX_BOUND,		//!< Use estimation range maximum bound.
321 
322 	LODMODE_LAST
323 };
324 
325 struct ReferenceParams : public RenderParams
326 {
ReferenceParamsdeqp::gls::TextureTestUtil::ReferenceParams327 	ReferenceParams (TextureType texType_)
328 		: RenderParams	(texType_)
329 		, sampler		()
330 		, lodMode		(LODMODE_EXACT)
331 		, minLod		(-1000.0f)
332 		, maxLod		(1000.0f)
333 		, baseLevel		(0)
334 		, maxLevel		(1000)
335 	{
336 	}
337 
ReferenceParamsdeqp::gls::TextureTestUtil::ReferenceParams338 	ReferenceParams (TextureType texType_, const tcu::Sampler& sampler_, LodMode lodMode_ = LODMODE_EXACT)
339 		: RenderParams	(texType_)
340 		, sampler		(sampler_)
341 		, lodMode		(lodMode_)
342 		, minLod		(-1000.0f)
343 		, maxLod		(1000.0f)
344 		, baseLevel		(0)
345 		, maxLevel		(1000)
346 	{
347 	}
348 
349 	tcu::Sampler		sampler;
350 	LodMode				lodMode;
351 	float				minLod;
352 	float				maxLod;
353 	int					baseLevel;
354 	int					maxLevel;
355 };
356 
357 void			clear						(const SurfaceAccess& dst, const tcu::Vec4& color);
358 
359 // Similar to sampleTexture() except uses texelFetch.
360 void			fetchTexture				(const SurfaceAccess& dst, const tcu::ConstPixelBufferAccess& src, const float* texCoord, const tcu::Vec4& colorScale, const tcu::Vec4& colorBias);
361 
362 void			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture2DView&		src, const float* texCoord, const ReferenceParams& params);
363 void			sampleTexture				(const SurfaceAccess& dst, const tcu::TextureCubeView&		src, const float* texCoord, const ReferenceParams& params);
364 void			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture2DArrayView&	src, const float* texCoord, const ReferenceParams& params);
365 void			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture3DView&		src, const float* texCoord, const ReferenceParams& params);
366 void			sampleTexture				(const SurfaceAccess& dst, const tcu::TextureCubeArrayView&	src, const float* texCoord, const ReferenceParams& params);
367 void			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture1DView&		src, const float* texCoord, const ReferenceParams& params);
368 void			sampleTexture				(const SurfaceAccess& dst, const tcu::Texture1DArrayView&	src, const float* texCoord, const ReferenceParams& params);
369 
370 void			computeQuadTexCoord1D			(std::vector<float>& dst, float left, float right);
371 void			computeQuadTexCoord1DArray		(std::vector<float>& dst, int layerNdx, float left, float right);
372 void			computeQuadTexCoord2D			(std::vector<float>& dst, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight);
373 void			computeQuadTexCoord2DArray		(std::vector<float>& dst, int layerNdx, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight);
374 void			computeQuadTexCoord3D			(std::vector<float>& dst, const tcu::Vec3& p0, const tcu::Vec3& p1, const tcu::IVec3& dirSwz);
375 void			computeQuadTexCoordCube			(std::vector<float>& dst, tcu::CubeFace face);
376 void			computeQuadTexCoordCube			(std::vector<float>& dst, tcu::CubeFace face, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight);
377 void			computeQuadTexCoordCubeArray	(std::vector<float>& dst, tcu::CubeFace face, const tcu::Vec2& bottomLeft, const tcu::Vec2& topRight, const tcu::Vec2& layerRange);
378 
379 bool			compareImages				(tcu::TestLog& log, const char* name, const char* desc, const tcu::Surface& reference, const tcu::Surface& rendered, tcu::RGBA threshold);
380 bool			compareImages				(tcu::TestLog& log, const tcu::Surface& reference, const tcu::Surface& rendered, tcu::RGBA threshold);
381 int				measureAccuracy				(tcu::TestLog& log, const tcu::Surface& reference, const tcu::Surface& rendered, int bestScoreDiff, int worstScoreDiff);
382 
383 int				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
384 											 const tcu::ConstPixelBufferAccess&	reference,
385 											 const tcu::PixelBufferAccess&		errorMask,
386 											 const tcu::Texture1DView&			src,
387 											 const float*						texCoord,
388 											 const ReferenceParams&				sampleParams,
389 											 const tcu::LookupPrecision&		lookupPrec,
390 											 const tcu::LodPrecision&			lodPrec,
391 											 qpWatchDog*						watchDog);
392 
393 int				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
394 											 const tcu::ConstPixelBufferAccess&	reference,
395 											 const tcu::PixelBufferAccess&		errorMask,
396 											 const tcu::Texture2DView&			src,
397 											 const float*						texCoord,
398 											 const ReferenceParams&				sampleParams,
399 											 const tcu::LookupPrecision&		lookupPrec,
400 											 const tcu::LodPrecision&			lodPrec,
401 											 qpWatchDog*						watchDog);
402 
403 int				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
404 											 const tcu::ConstPixelBufferAccess&	reference,
405 											 const tcu::PixelBufferAccess&		errorMask,
406 											 const tcu::TextureCubeView&		src,
407 											 const float*						texCoord,
408 											 const ReferenceParams&				sampleParams,
409 											 const tcu::LookupPrecision&		lookupPrec,
410 											 const tcu::LodPrecision&			lodPrec,
411 											 qpWatchDog*						watchDog);
412 
413 int				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
414 											 const tcu::ConstPixelBufferAccess&	reference,
415 											 const tcu::PixelBufferAccess&		errorMask,
416 											 const tcu::Texture1DArrayView&		src,
417 											 const float*						texCoord,
418 											 const ReferenceParams&				sampleParams,
419 											 const tcu::LookupPrecision&		lookupPrec,
420 											 const tcu::LodPrecision&			lodPrec,
421 											 qpWatchDog*						watchDog);
422 
423 int				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
424 											 const tcu::ConstPixelBufferAccess&	reference,
425 											 const tcu::PixelBufferAccess&		errorMask,
426 											 const tcu::Texture2DArrayView&		src,
427 											 const float*						texCoord,
428 											 const ReferenceParams&				sampleParams,
429 											 const tcu::LookupPrecision&		lookupPrec,
430 											 const tcu::LodPrecision&			lodPrec,
431 											 qpWatchDog*						watchDog);
432 
433 int				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
434 											 const tcu::ConstPixelBufferAccess&	reference,
435 											 const tcu::PixelBufferAccess&		errorMask,
436 											 const tcu::Texture3DView&			src,
437 											 const float*						texCoord,
438 											 const ReferenceParams&				sampleParams,
439 											 const tcu::LookupPrecision&		lookupPrec,
440 											 const tcu::LodPrecision&			lodPrec,
441 											 qpWatchDog*						watchDog);
442 
443 int				computeTextureLookupDiff	(const tcu::ConstPixelBufferAccess&	result,
444 											 const tcu::ConstPixelBufferAccess&	reference,
445 											 const tcu::PixelBufferAccess&		errorMask,
446 											 const tcu::TextureCubeArrayView&	src,
447 											 const float*						texCoord,
448 											 const ReferenceParams&				sampleParams,
449 											 const tcu::LookupPrecision&		lookupPrec,
450 											 const tcu::IVec4&					coordBits,
451 											 const tcu::LodPrecision&			lodPrec,
452 											 qpWatchDog*						watchDog);
453 
454 bool			verifyTextureResult			(tcu::TestContext&					testCtx,
455 											 const tcu::ConstPixelBufferAccess&	result,
456 											 const tcu::Texture1DView&			src,
457 											 const float*						texCoord,
458 											 const ReferenceParams&				sampleParams,
459 											 const tcu::LookupPrecision&		lookupPrec,
460 											 const tcu::LodPrecision&			lodPrec,
461 											 const tcu::PixelFormat&			pixelFormat);
462 
463 bool			verifyTextureResult			(tcu::TestContext&					testCtx,
464 											 const tcu::ConstPixelBufferAccess&	result,
465 											 const tcu::Texture2DView&			src,
466 											 const float*						texCoord,
467 											 const ReferenceParams&				sampleParams,
468 											 const tcu::LookupPrecision&		lookupPrec,
469 											 const tcu::LodPrecision&			lodPrec,
470 											 const tcu::PixelFormat&			pixelFormat);
471 
472 bool			verifyTextureResult			(tcu::TestContext&					testCtx,
473 											 const tcu::ConstPixelBufferAccess&	result,
474 											 const tcu::TextureCubeView&		src,
475 											 const float*						texCoord,
476 											 const ReferenceParams&				sampleParams,
477 											 const tcu::LookupPrecision&		lookupPrec,
478 											 const tcu::LodPrecision&			lodPrec,
479 											 const tcu::PixelFormat&			pixelFormat);
480 
481 bool			verifyTextureResult			(tcu::TestContext&					testCtx,
482 											 const tcu::ConstPixelBufferAccess&	result,
483 											 const tcu::Texture1DArrayView&		src,
484 											 const float*						texCoord,
485 											 const ReferenceParams&				sampleParams,
486 											 const tcu::LookupPrecision&		lookupPrec,
487 											 const tcu::LodPrecision&			lodPrec,
488 											 const tcu::PixelFormat&			pixelFormat);
489 
490 bool			verifyTextureResult			(tcu::TestContext&					testCtx,
491 											 const tcu::ConstPixelBufferAccess&	result,
492 											 const tcu::Texture2DArrayView&		src,
493 											 const float*						texCoord,
494 											 const ReferenceParams&				sampleParams,
495 											 const tcu::LookupPrecision&		lookupPrec,
496 											 const tcu::LodPrecision&			lodPrec,
497 											 const tcu::PixelFormat&			pixelFormat);
498 
499 bool			verifyTextureResult			(tcu::TestContext&					testCtx,
500 											 const tcu::ConstPixelBufferAccess&	result,
501 											 const tcu::Texture3DView&			src,
502 											 const float*						texCoord,
503 											 const ReferenceParams&				sampleParams,
504 											 const tcu::LookupPrecision&		lookupPrec,
505 											 const tcu::LodPrecision&			lodPrec,
506 											 const tcu::PixelFormat&			pixelFormat);
507 
508 bool			verifyTextureResult			(tcu::TestContext&					testCtx,
509 											 const tcu::ConstPixelBufferAccess&	result,
510 											 const tcu::TextureCubeArrayView&	src,
511 											 const float*						texCoord,
512 											 const ReferenceParams&				sampleParams,
513 											 const tcu::LookupPrecision&		lookupPrec,
514 											 const tcu::IVec4&					coordBits,
515 											 const tcu::LodPrecision&			lodPrec,
516 											 const tcu::PixelFormat&			pixelFormat);
517 
518 int				computeTextureCompareDiff	(const tcu::ConstPixelBufferAccess&	result,
519 											 const tcu::ConstPixelBufferAccess&	reference,
520 											 const tcu::PixelBufferAccess&		errorMask,
521 											 const tcu::Texture2DView&			src,
522 											 const float*						texCoord,
523 											 const ReferenceParams&				sampleParams,
524 											 const tcu::TexComparePrecision&	comparePrec,
525 											 const tcu::LodPrecision&			lodPrec,
526 											 const tcu::Vec3&					nonShadowThreshold);
527 
528 int				computeTextureCompareDiff	(const tcu::ConstPixelBufferAccess&	result,
529 											 const tcu::ConstPixelBufferAccess&	reference,
530 											 const tcu::PixelBufferAccess&		errorMask,
531 											 const tcu::TextureCubeView&		src,
532 											 const float*						texCoord,
533 											 const ReferenceParams&				sampleParams,
534 											 const tcu::TexComparePrecision&	comparePrec,
535 											 const tcu::LodPrecision&			lodPrec,
536 											 const tcu::Vec3&					nonShadowThreshold);
537 
538 int				computeTextureCompareDiff	(const tcu::ConstPixelBufferAccess&	result,
539 											 const tcu::ConstPixelBufferAccess&	reference,
540 											 const tcu::PixelBufferAccess&		errorMask,
541 											 const tcu::Texture2DArrayView&		src,
542 											 const float*						texCoord,
543 											 const ReferenceParams&				sampleParams,
544 											 const tcu::TexComparePrecision&	comparePrec,
545 											 const tcu::LodPrecision&			lodPrec,
546 											 const tcu::Vec3&					nonShadowThreshold);
547 
548 // Mipmap generation comparison.
549 
550 struct GenMipmapPrecision
551 {
552 	tcu::IVec3			filterBits;			//!< Bits in filtering parameters (fixed-point).
553 	tcu::Vec4			colorThreshold;		//!< Threshold for color value comparison.
554 	tcu::BVec4			colorMask;			//!< Color channel comparison mask.
555 };
556 
557 qpTestResult	compareGenMipmapResult		(tcu::TestLog& log, const tcu::Texture2D& resultTexture, const tcu::Texture2D& level0Reference, const GenMipmapPrecision& precision);
558 qpTestResult	compareGenMipmapResult		(tcu::TestLog& log, const tcu::TextureCube& resultTexture, const tcu::TextureCube& level0Reference, const GenMipmapPrecision& precision);
559 
560 // Utility for logging texture gradient ranges.
561 struct LogGradientFmt
562 {
LogGradientFmtdeqp::gls::TextureTestUtil::LogGradientFmt563 	LogGradientFmt (const tcu::Vec4* min_, const tcu::Vec4* max_) : valueMin(min_), valueMax(max_) {}
564 	const tcu::Vec4* valueMin;
565 	const tcu::Vec4* valueMax;
566 };
567 
568 std::ostream&			operator<<		(std::ostream& str, const LogGradientFmt& fmt);
formatGradient(const tcu::Vec4 * minVal,const tcu::Vec4 * maxVal)569 inline LogGradientFmt	formatGradient	(const tcu::Vec4* minVal, const tcu::Vec4* maxVal) { return LogGradientFmt(minVal, maxVal); }
570 
571 } // TextureTestUtil
572 } // gls
573 } // deqp
574 
575 #endif // _GLSTEXTURETESTUTIL_HPP
576