• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Texture format tests.
22  *
23  * Constants:
24  *  + nearest-neighbor filtering
25  *  + no mipmaps
26  *  + full texture coordinate range (but not outside) tested
27  *  + accessed from fragment shader
28  *  + texture unit 0
29  *  + named texture object
30  *
31  * Variables:
32  *  + texture format
33  *  + texture type: 2D or cubemap
34  *//*--------------------------------------------------------------------*/
35 
36 #include "es3fTextureFormatTests.hpp"
37 #include "gluPixelTransfer.hpp"
38 #include "gluStrUtil.hpp"
39 #include "gluTexture.hpp"
40 #include "gluTextureUtil.hpp"
41 #include "glsTextureTestUtil.hpp"
42 #include "tcuTextureUtil.hpp"
43 #include "deStringUtil.hpp"
44 #include "deRandom.hpp"
45 #include "glwEnums.hpp"
46 #include "glwFunctions.hpp"
47 #include "gluContextInfo.hpp"
48 #include "deUniquePtr.hpp"
49 
50 using std::vector;
51 using std::string;
52 using tcu::TestLog;
53 
54 using de::MovePtr;
55 using glu::ContextInfo;
56 
57 namespace deqp
58 {
59 namespace gles3
60 {
61 namespace Functional
62 {
63 
64 using namespace deqp::gls;
65 using namespace deqp::gls::TextureTestUtil;
66 using namespace glu::TextureTestUtil;
67 using tcu::Sampler;
68 
69 namespace
70 {
71 
checkSupport(const glu::ContextInfo & info,deUint32 internalFormat)72 void checkSupport (const glu::ContextInfo& info, deUint32 internalFormat)
73 {
74 	if (internalFormat == GL_SR8_EXT && !info.isExtensionSupported("GL_EXT_texture_sRGB_R8"))
75 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
76 }
77 
78 } // anonymous
79 
80 // Texture2DFormatCase
81 
82 class Texture2DFormatCase : public tcu::TestCase
83 {
84 public:
85 							Texture2DFormatCase		(tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height);
86 							Texture2DFormatCase		(tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 internalFormat, int width, int height);
87 							~Texture2DFormatCase	(void);
88 
89 	void					init					(void);
90 	void					deinit					(void);
91 	IterateResult			iterate					(void);
92 
93 private:
94 							Texture2DFormatCase		(const Texture2DFormatCase& other);
95 	Texture2DFormatCase&	operator=				(const Texture2DFormatCase& other);
96 
97 	glu::RenderContext&		m_renderCtx;
98 	const glu::ContextInfo&	m_renderCtxInfo;
99 
100 	deUint32				m_format;
101 	deUint32				m_dataType;
102 	int						m_width;
103 	int						m_height;
104 
105 	glu::Texture2D*			m_texture;
106 	TextureRenderer			m_renderer;
107 };
108 
Texture2DFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,deUint32 format,deUint32 dataType,int width,int height)109 Texture2DFormatCase::Texture2DFormatCase (tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height)
110 	: TestCase			(testCtx, name, description)
111 	, m_renderCtx		(context.getRenderContext())
112 	, m_renderCtxInfo	(context.getContextInfo())
113 	, m_format			(format)
114 	, m_dataType		(dataType)
115 	, m_width			(width)
116 	, m_height			(height)
117 	, m_texture			(DE_NULL)
118 	, m_renderer		(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
119 {
120 }
121 
Texture2DFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,deUint32 internalFormat,int width,int height)122 Texture2DFormatCase::Texture2DFormatCase (tcu::TestContext& testCtx,  Context& context, const char* name, const char* description, deUint32 internalFormat, int width, int height)
123 	: TestCase			(testCtx, name, description)
124 	, m_renderCtx		(context.getRenderContext())
125 	, m_renderCtxInfo	(context.getContextInfo())
126 	, m_format			(internalFormat)
127 	, m_dataType		(GL_NONE)
128 	, m_width			(width)
129 	, m_height			(height)
130 	, m_texture			(DE_NULL)
131 	, m_renderer		(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
132 {
133 }
134 
~Texture2DFormatCase(void)135 Texture2DFormatCase::~Texture2DFormatCase (void)
136 {
137 	deinit();
138 }
139 
init(void)140 void Texture2DFormatCase::init (void)
141 {
142 	checkSupport(m_renderCtxInfo, m_format);
143 
144 	TestLog&				log		= m_testCtx.getLog();
145 	tcu::TextureFormat		fmt		= m_dataType ? glu::mapGLTransferFormat(m_format, m_dataType) : glu::mapGLInternalFormat(m_format);
146 	tcu::TextureFormatInfo	spec	= tcu::getTextureFormatInfo(fmt);
147 	std::ostringstream		fmtName;
148 
149 	if (m_dataType)
150 		fmtName << glu::getTextureFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType);
151 	else
152 		fmtName << glu::getTextureFormatStr(m_format);
153 
154 	log << TestLog::Message << "2D texture, " << fmtName.str() << ", " << m_width << "x" << m_height
155 							<< ",\n  fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient"
156 		<< TestLog::EndMessage;
157 
158 	m_texture = m_dataType != GL_NONE
159 			  ? new glu::Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height)	// Implicit internal format.
160 			  : new glu::Texture2D(m_renderCtx, m_format, m_width, m_height);				// Explicit internal format.
161 
162 	// Fill level 0.
163 	m_texture->getRefTexture().allocLevel(0);
164 	tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
165 }
166 
deinit(void)167 void Texture2DFormatCase::deinit (void)
168 {
169 	delete m_texture;
170 	m_texture = DE_NULL;
171 
172 	m_renderer.clear();
173 }
174 
iterate(void)175 Texture2DFormatCase::IterateResult Texture2DFormatCase::iterate (void)
176 {
177 	TestLog&				log					= m_testCtx.getLog();
178 	const glw::Functions&	gl					= m_renderCtx.getFunctions();
179 	RandomViewport			viewport			(m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName()));
180 	tcu::Surface			renderedFrame		(viewport.width, viewport.height);
181 	tcu::Surface			referenceFrame		(viewport.width, viewport.height);
182 	tcu::RGBA				threshold			= m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
183 	vector<float>			texCoord;
184 	ReferenceParams			renderParams		(TEXTURETYPE_2D);
185 	tcu::TextureFormatInfo	spec				= tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
186 	const deUint32			wrapS				= GL_CLAMP_TO_EDGE;
187 	const deUint32			wrapT				= GL_CLAMP_TO_EDGE;
188 	const deUint32			minFilter			= GL_NEAREST;
189 	const deUint32			magFilter			= GL_NEAREST;
190 
191 	renderParams.flags			|= RenderParams::LOG_ALL;
192 	renderParams.samplerType	= getSamplerType(m_texture->getRefTexture().getFormat());
193 	renderParams.sampler		= Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
194 	renderParams.colorScale		= spec.lookupScale;
195 	renderParams.colorBias		= spec.lookupBias;
196 
197 	computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
198 
199 	log << TestLog::Message << "Texture parameters:"
200 							<< "\n  WRAP_S = " << glu::getTextureParameterValueStr(GL_TEXTURE_WRAP_S, wrapS)
201 							<< "\n  WRAP_T = " << glu::getTextureParameterValueStr(GL_TEXTURE_WRAP_T, wrapT)
202 							<< "\n  MIN_FILTER = " << glu::getTextureParameterValueStr(GL_TEXTURE_MIN_FILTER, minFilter)
203 							<< "\n  MAG_FILTER = " << glu::getTextureParameterValueStr(GL_TEXTURE_MAG_FILTER, magFilter)
204 		<< TestLog::EndMessage;
205 
206 	// Setup base viewport.
207 	gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
208 
209 	// Upload texture data to GL.
210 	m_texture->upload();
211 
212 	// Bind to unit 0.
213 	gl.activeTexture(GL_TEXTURE0);
214 	gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
215 
216 	// Setup nearest neighbor filtering and clamp-to-edge.
217 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS);
218 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT);
219 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
220 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter);
221 
222 	GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
223 
224 	// Draw.
225 	m_renderer.renderQuad(0, &texCoord[0], renderParams);
226 	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
227 	GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
228 
229 	// Compute reference.
230 	sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams);
231 
232 	// Compare and log.
233 	bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold);
234 
235 	m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
236 							isOk ? "Pass"				: "Image comparison failed");
237 
238 	return STOP;
239 }
240 
241 // TextureCubeFormatCase
242 
243 class TextureCubeFormatCase : public tcu::TestCase
244 {
245 public:
246 							TextureCubeFormatCase	(tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height);
247 							TextureCubeFormatCase	(tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 internalFormat, int width, int height);
248 							~TextureCubeFormatCase	(void);
249 
250 	void					init					(void);
251 	void					deinit					(void);
252 	IterateResult			iterate					(void);
253 
254 private:
255 							TextureCubeFormatCase	(const TextureCubeFormatCase& other);
256 	TextureCubeFormatCase&	operator=				(const TextureCubeFormatCase& other);
257 
258 	bool					testFace				(tcu::CubeFace face);
259 
260 	glu::RenderContext&		m_renderCtx;
261 	const glu::ContextInfo&	m_renderCtxInfo;
262 
263 	deUint32				m_format;
264 	deUint32				m_dataType;
265 	int						m_width;
266 	int						m_height;
267 
268 	glu::TextureCube*		m_texture;
269 	TextureRenderer			m_renderer;
270 
271 	int						m_curFace;
272 	bool					m_isOk;
273 };
274 
TextureCubeFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,deUint32 format,deUint32 dataType,int width,int height)275 TextureCubeFormatCase::TextureCubeFormatCase (tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height)
276 	: TestCase			(testCtx, name, description)
277 	, m_renderCtx		(context.getRenderContext())
278 	, m_renderCtxInfo	(context.getContextInfo())
279 	, m_format			(format)
280 	, m_dataType		(dataType)
281 	, m_width			(width)
282 	, m_height			(height)
283 	, m_texture			(DE_NULL)
284 	, m_renderer		(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
285 	, m_curFace			(0)
286 	, m_isOk			(false)
287 {
288 }
289 
TextureCubeFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,deUint32 internalFormat,int width,int height)290 TextureCubeFormatCase::TextureCubeFormatCase (tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 internalFormat, int width, int height)
291 	: TestCase			(testCtx, name, description)
292 	, m_renderCtx		(context.getRenderContext())
293 	, m_renderCtxInfo	(context.getContextInfo())
294 	, m_format			(internalFormat)
295 	, m_dataType		(GL_NONE)
296 	, m_width			(width)
297 	, m_height			(height)
298 	, m_texture			(DE_NULL)
299 	, m_renderer		(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
300 	, m_curFace			(0)
301 	, m_isOk			(false)
302 {
303 }
304 
~TextureCubeFormatCase(void)305 TextureCubeFormatCase::~TextureCubeFormatCase (void)
306 {
307 	deinit();
308 }
309 
init(void)310 void TextureCubeFormatCase::init (void)
311 {
312 	checkSupport(m_renderCtxInfo, m_format);
313 
314 	TestLog&				log		= m_testCtx.getLog();
315 	tcu::TextureFormat		fmt		= m_dataType ? glu::mapGLTransferFormat(m_format, m_dataType) : glu::mapGLInternalFormat(m_format);
316 	tcu::TextureFormatInfo	spec	= tcu::getTextureFormatInfo(fmt);
317 	std::ostringstream		fmtName;
318 
319 	if (m_dataType)
320 		fmtName << glu::getTextureFormatStr(m_format) << ", " << glu::getTypeStr(m_dataType);
321 	else
322 		fmtName << glu::getTextureFormatStr(m_format);
323 
324 	log << TestLog::Message << "Cube map texture, " << fmtName.str() << ", " << m_width << "x" << m_height
325 							<< ",\n  fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient"
326 		<< TestLog::EndMessage;
327 
328 	DE_ASSERT(m_width == m_height);
329 	m_texture = m_dataType != GL_NONE
330 			  ? new glu::TextureCube(m_renderCtx, m_format, m_dataType, m_width)	// Implicit internal format.
331 		      : new glu::TextureCube(m_renderCtx, m_format, m_width);				// Explicit internal format.
332 
333 	// Fill level 0.
334 	for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
335 	{
336 		tcu::Vec4 gMin, gMax;
337 
338 		switch (face)
339 		{
340 			case 0: gMin = spec.valueMin.swizzle(0, 1, 2, 3); gMax = spec.valueMax.swizzle(0, 1, 2, 3); break;
341 			case 1: gMin = spec.valueMin.swizzle(2, 1, 0, 3); gMax = spec.valueMax.swizzle(2, 1, 0, 3); break;
342 			case 2: gMin = spec.valueMin.swizzle(1, 2, 0, 3); gMax = spec.valueMax.swizzle(1, 2, 0, 3); break;
343 			case 3: gMin = spec.valueMax.swizzle(0, 1, 2, 3); gMax = spec.valueMin.swizzle(0, 1, 2, 3); break;
344 			case 4: gMin = spec.valueMax.swizzle(2, 1, 0, 3); gMax = spec.valueMin.swizzle(2, 1, 0, 3); break;
345 			case 5: gMin = spec.valueMax.swizzle(1, 2, 0, 3); gMax = spec.valueMin.swizzle(1, 2, 0, 3); break;
346 			default:
347 				DE_ASSERT(false);
348 		}
349 
350 		m_texture->getRefTexture().allocLevel((tcu::CubeFace)face, 0);
351 		tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevelFace(0, (tcu::CubeFace)face), gMin, gMax);
352 	}
353 
354 	// Upload texture data to GL.
355 	m_texture->upload();
356 
357 	// Initialize iteration state.
358 	m_curFace	= 0;
359 	m_isOk		= true;
360 }
361 
deinit(void)362 void TextureCubeFormatCase::deinit (void)
363 {
364 	delete m_texture;
365 	m_texture = DE_NULL;
366 
367 	m_renderer.clear();
368 }
369 
testFace(tcu::CubeFace face)370 bool TextureCubeFormatCase::testFace (tcu::CubeFace face)
371 {
372 	TestLog&				log					= m_testCtx.getLog();
373 	const glw::Functions&	gl					= m_renderCtx.getFunctions();
374 	RandomViewport			viewport			(m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName())+(deUint32)face);
375 	tcu::Surface			renderedFrame		(viewport.width, viewport.height);
376 	tcu::Surface			referenceFrame		(viewport.width, viewport.height);
377 	tcu::RGBA				threshold			= m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
378 	vector<float>			texCoord;
379 	ReferenceParams			renderParams		(TEXTURETYPE_CUBE);
380 	tcu::TextureFormatInfo	spec				= tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
381 
382 	renderParams.samplerType				= getSamplerType(m_texture->getRefTexture().getFormat());
383 	renderParams.sampler					= Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
384 	renderParams.sampler.seamlessCubeMap	= true;
385 	renderParams.colorScale					= spec.lookupScale;
386 	renderParams.colorBias					= spec.lookupBias;
387 
388 	// Log render info on first face.
389 	if (face == tcu::CUBEFACE_NEGATIVE_X)
390 		renderParams.flags |= RenderParams::LOG_ALL;
391 
392 	computeQuadTexCoordCube(texCoord, face);
393 
394 	// \todo [2011-10-28 pyry] Image set name / section?
395 	log << TestLog::Message << face << TestLog::EndMessage;
396 
397 	// Setup base viewport.
398 	gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
399 
400 	// Bind to unit 0.
401 	gl.activeTexture(GL_TEXTURE0);
402 	gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
403 
404 	// Setup nearest neighbor filtering and clamp-to-edge.
405 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
406 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
407 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
408 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
409 
410 	GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
411 
412 	m_renderer.renderQuad(0, &texCoord[0], renderParams);
413 	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
414 	GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
415 
416 	// Compute reference.
417 	sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams);
418 
419 	// Compare and log.
420 	return compareImages(log, referenceFrame, renderedFrame, threshold);
421 }
422 
iterate(void)423 TextureCubeFormatCase::IterateResult TextureCubeFormatCase::iterate (void)
424 {
425 	// Execute test for all faces.
426 	if (!testFace((tcu::CubeFace)m_curFace))
427 		m_isOk = false;
428 
429 	m_curFace += 1;
430 
431 	if (m_curFace == tcu::CUBEFACE_LAST)
432 	{
433 		m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
434 								m_isOk ? "Pass"					: "Image comparison failed");
435 		return STOP;
436 	}
437 	else
438 		return CONTINUE;
439 }
440 
441 // Texture2DArrayFormatCase
442 
443 class Texture2DArrayFormatCase : public tcu::TestCase
444 {
445 public:
446 										Texture2DArrayFormatCase	(tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height, int numLayers);
447 										Texture2DArrayFormatCase	(tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 internalFormat, int width, int height, int numLayers);
448 										~Texture2DArrayFormatCase	(void);
449 
450 	void								init						(void);
451 	void								deinit						(void);
452 	IterateResult						iterate						(void);
453 
454 private:
455 										Texture2DArrayFormatCase	(const Texture2DArrayFormatCase& other);
456 	Texture2DArrayFormatCase&			operator=					(const Texture2DArrayFormatCase& other);
457 
458 	bool								testLayer					(int layerNdx);
459 
460 	glu::RenderContext&					m_renderCtx;
461 	const glu::ContextInfo&				m_renderCtxInfo;
462 
463 	deUint32							m_format;
464 	deUint32							m_dataType;
465 	int									m_width;
466 	int									m_height;
467 	int									m_numLayers;
468 
469 	glu::Texture2DArray*				m_texture;
470 	TextureTestUtil::TextureRenderer	m_renderer;
471 
472 	int									m_curLayer;
473 };
474 
Texture2DArrayFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,deUint32 format,deUint32 dataType,int width,int height,int numLayers)475 Texture2DArrayFormatCase::Texture2DArrayFormatCase (tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height, int numLayers)
476 	: TestCase			(testCtx, name, description)
477 	, m_renderCtx		(context.getRenderContext())
478 	, m_renderCtxInfo	(context.getContextInfo())
479 	, m_format			(format)
480 	, m_dataType		(dataType)
481 	, m_width			(width)
482 	, m_height			(height)
483 	, m_numLayers		(numLayers)
484 	, m_texture			(DE_NULL)
485 	, m_renderer		(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
486 	, m_curLayer		(0)
487 {
488 }
489 
Texture2DArrayFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,deUint32 internalFormat,int width,int height,int numLayers)490 Texture2DArrayFormatCase::Texture2DArrayFormatCase (tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 internalFormat, int width, int height, int numLayers)
491 	: TestCase			(testCtx, name, description)
492 	, m_renderCtx		(context.getRenderContext())
493 	, m_renderCtxInfo	(context.getContextInfo())
494 	, m_format			(internalFormat)
495 	, m_dataType		(GL_NONE)
496 	, m_width			(width)
497 	, m_height			(height)
498 	, m_numLayers		(numLayers)
499 	, m_texture			(DE_NULL)
500 	, m_renderer		(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
501 	, m_curLayer		(0)
502 {
503 }
504 
~Texture2DArrayFormatCase(void)505 Texture2DArrayFormatCase::~Texture2DArrayFormatCase (void)
506 {
507 	deinit();
508 }
509 
init(void)510 void Texture2DArrayFormatCase::init (void)
511 {
512 	checkSupport(m_renderCtxInfo, m_format);
513 
514 	m_texture = m_dataType != GL_NONE
515 			  ? new glu::Texture2DArray(m_renderCtx, m_format, m_dataType, m_width, m_height, m_numLayers)	// Implicit internal format.
516 			  : new glu::Texture2DArray(m_renderCtx, m_format, m_width, m_height, m_numLayers);				// Explicit internal format.
517 
518 	tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
519 
520 	// Fill level 0.
521 	m_texture->getRefTexture().allocLevel(0);
522 	tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
523 
524 	// Initialize state.
525 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
526 	m_curLayer = 0;
527 }
528 
deinit(void)529 void Texture2DArrayFormatCase::deinit (void)
530 {
531 	delete m_texture;
532 	m_texture = DE_NULL;
533 
534 	m_renderer.clear();
535 }
536 
testLayer(int layerNdx)537 bool Texture2DArrayFormatCase::testLayer (int layerNdx)
538 {
539 	const glw::Functions&	gl					= m_renderCtx.getFunctions();
540 	TestLog&				log					= m_testCtx.getLog();
541 	RandomViewport			viewport			(m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName()));
542 	tcu::Surface			renderedFrame		(viewport.width, viewport.height);
543 	tcu::Surface			referenceFrame		(viewport.width, viewport.height);
544 	tcu::RGBA				threshold			= m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
545 	vector<float>			texCoord;
546 	ReferenceParams			renderParams		(TEXTURETYPE_2D_ARRAY);
547 	tcu::TextureFormatInfo	spec				= tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
548 
549 	renderParams.samplerType	= getSamplerType(m_texture->getRefTexture().getFormat());
550 	renderParams.sampler		= Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
551 	renderParams.colorScale		= spec.lookupScale;
552 	renderParams.colorBias		= spec.lookupBias;
553 
554 	computeQuadTexCoord2DArray(texCoord, layerNdx, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
555 
556 	// Setup base viewport.
557 	gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
558 
559 	// Upload texture data to GL.
560 	m_texture->upload();
561 
562 	// Bind to unit 0.
563 	gl.activeTexture(GL_TEXTURE0);
564 	gl.bindTexture(GL_TEXTURE_2D_ARRAY, m_texture->getGLTexture());
565 
566 	// Setup nearest neighbor filtering and clamp-to-edge.
567 	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
568 	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
569 	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
570 	gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
571 
572 	GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
573 
574 	// Draw.
575 	m_renderer.renderQuad(0, &texCoord[0], renderParams);
576 	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
577 
578 	// Compute reference.
579 	sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams);
580 
581 	// Compare and log.
582 	return compareImages(log, (string("Layer" + de::toString(layerNdx))).c_str(), (string("Layer " + de::toString(layerNdx))).c_str(), referenceFrame, renderedFrame, threshold);
583 }
584 
iterate(void)585 Texture2DArrayFormatCase::IterateResult Texture2DArrayFormatCase::iterate (void)
586 {
587 	// Execute test for all layers.
588 	bool isOk = testLayer(m_curLayer);
589 
590 	if (!isOk && m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
591 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
592 
593 	m_curLayer += 1;
594 
595 	return m_curLayer < m_texture->getRefTexture().getNumLayers() ? CONTINUE : STOP;
596 }
597 
598 // Texture2DFormatCase
599 
600 class Texture3DFormatCase : public tcu::TestCase
601 {
602 public:
603 										Texture3DFormatCase		(tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height, int depth);
604 										Texture3DFormatCase		(tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 internalFormat, int width, int height, int depth);
605 										~Texture3DFormatCase	(void);
606 
607 	void								init					(void);
608 	void								deinit					(void);
609 	IterateResult						iterate					(void);
610 
611 private:
612 										Texture3DFormatCase		(const Texture3DFormatCase& other);
613 	Texture3DFormatCase&				operator=				(const Texture3DFormatCase& other);
614 
615 	bool								testSlice				(int sliceNdx);
616 
617 	glu::RenderContext&					m_renderCtx;
618 	const glu::ContextInfo&				m_renderCtxInfo;
619 
620 	deUint32							m_format;
621 	deUint32							m_dataType;
622 	int									m_width;
623 	int									m_height;
624 	int									m_depth;
625 
626 	glu::Texture3D*						m_texture;
627 	TextureTestUtil::TextureRenderer	m_renderer;
628 
629 	int									m_curSlice;
630 };
631 
Texture3DFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,deUint32 format,deUint32 dataType,int width,int height,int depth)632 Texture3DFormatCase::Texture3DFormatCase (tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height, int depth)
633 	: TestCase			(testCtx, name, description)
634 	, m_renderCtx		(context.getRenderContext())
635 	, m_renderCtxInfo	(context.getContextInfo())
636 	, m_format			(format)
637 	, m_dataType		(dataType)
638 	, m_width			(width)
639 	, m_height			(height)
640 	, m_depth			(depth)
641 	, m_texture			(DE_NULL)
642 	, m_renderer		(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
643 	, m_curSlice		(0)
644 {
645 }
646 
Texture3DFormatCase(tcu::TestContext & testCtx,Context & context,const char * name,const char * description,deUint32 internalFormat,int width,int height,int depth)647 Texture3DFormatCase::Texture3DFormatCase (tcu::TestContext& testCtx, Context& context, const char* name, const char* description, deUint32 internalFormat, int width, int height, int depth)
648 	: TestCase			(testCtx, name, description)
649 	, m_renderCtx		(context.getRenderContext())
650 	, m_renderCtxInfo	(context.getContextInfo())
651 	, m_format			(internalFormat)
652 	, m_dataType		(GL_NONE)
653 	, m_width			(width)
654 	, m_height			(height)
655 	, m_depth			(depth)
656 	, m_texture			(DE_NULL)
657 	, m_renderer		(context.getRenderContext(), testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
658 	, m_curSlice		(0)
659 {
660 }
661 
~Texture3DFormatCase(void)662 Texture3DFormatCase::~Texture3DFormatCase (void)
663 {
664 	deinit();
665 }
666 
init(void)667 void Texture3DFormatCase::init (void)
668 {
669 	checkSupport(m_renderCtxInfo, m_format);
670 
671 	m_texture = m_dataType != GL_NONE
672 			  ? new glu::Texture3D(m_renderCtx, m_format, m_dataType, m_width, m_height, m_depth)	// Implicit internal format.
673 			  : new glu::Texture3D(m_renderCtx, m_format, m_width, m_height, m_depth);				// Explicit internal format.
674 
675 	tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
676 
677 	// Fill level 0.
678 	m_texture->getRefTexture().allocLevel(0);
679 	tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
680 
681 	// Initialize state.
682 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
683 	m_curSlice = 0;
684 }
685 
deinit(void)686 void Texture3DFormatCase::deinit (void)
687 {
688 	delete m_texture;
689 	m_texture = DE_NULL;
690 
691 	m_renderer.clear();
692 }
693 
testSlice(int sliceNdx)694 bool Texture3DFormatCase::testSlice (int sliceNdx)
695 {
696 	TestLog&				log					= m_testCtx.getLog();
697 	const glw::Functions&	gl					= m_renderCtx.getFunctions();
698 	RandomViewport			viewport			(m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName()));
699 	tcu::Surface			renderedFrame		(viewport.width, viewport.height);
700 	tcu::Surface			referenceFrame		(viewport.width, viewport.height);
701 	tcu::RGBA				threshold			= m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
702 	vector<float>			texCoord;
703 	ReferenceParams			renderParams		(TEXTURETYPE_3D);
704 	tcu::TextureFormatInfo	spec				= tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
705 	float					r					= ((float)sliceNdx + 0.5f) / (float)m_depth;
706 
707 	renderParams.samplerType	= getSamplerType(m_texture->getRefTexture().getFormat());
708 	renderParams.sampler		= Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
709 	renderParams.colorScale		= spec.lookupScale;
710 	renderParams.colorBias		= spec.lookupBias;
711 
712 	computeQuadTexCoord3D(texCoord, tcu::Vec3(0.0f, 0.0f, r), tcu::Vec3(1.0f, 1.0f, r), tcu::IVec3(0,1,2));
713 
714 	// Setup base viewport.
715 	gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
716 
717 	// Upload texture data to GL.
718 	m_texture->upload();
719 
720 	// Bind to unit 0.
721 	gl.activeTexture(GL_TEXTURE0);
722 	gl.bindTexture(GL_TEXTURE_3D, m_texture->getGLTexture());
723 
724 	// Setup nearest neighbor filtering and clamp-to-edge.
725 	gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
726 	gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
727 	gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
728 	gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
729 
730 	GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
731 
732 	// Draw.
733 	m_renderer.renderQuad(0, &texCoord[0], renderParams);
734 	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
735 
736 	// Compute reference.
737 	sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams);
738 
739 	// Compare and log.
740 	return compareImages(log, (string("Slice" + de::toString(sliceNdx))).c_str(), (string("Slice " + de::toString(sliceNdx))).c_str(), referenceFrame, renderedFrame, threshold);
741 }
742 
iterate(void)743 Texture3DFormatCase::IterateResult Texture3DFormatCase::iterate (void)
744 {
745 	// Execute test for all slices.
746 	bool isOk = testSlice(m_curSlice);
747 
748 	if (!isOk && m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
749 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed");
750 
751 	m_curSlice += 1;
752 
753 	return m_curSlice < m_texture->getRefTexture().getDepth() ? CONTINUE : STOP;
754 }
755 
756 // Compressed2FormatCase
757 
758 class Compressed2DFormatCase : public tcu::TestCase
759 {
760 public:
761 										Compressed2DFormatCase		(tcu::TestContext&				testCtx,
762 																	 glu::RenderContext&			renderCtx,
763 																	 const glu::ContextInfo&		renderCtxInfo,
764 																	 const char*					name,
765 																	 const char*					description,
766 																	 tcu::CompressedTexFormat		format,
767 																	 deUint32						randomSeed,
768 																	 int							width,
769 																	 int							height);
770 										~Compressed2DFormatCase		(void);
771 
772 	void								init						(void);
773 	void								deinit						(void);
774 	IterateResult						iterate						(void);
775 
776 private:
777 										Compressed2DFormatCase		(const Compressed2DFormatCase& other);
778 	Compressed2DFormatCase&				operator=					(const Compressed2DFormatCase& other);
779 
780 	glu::RenderContext&					m_renderCtx;
781 	const glu::ContextInfo&				m_renderCtxInfo;
782 
783 	tcu::CompressedTexFormat			m_format;
784 
785 	deUint32							m_randomSeed;
786 	int									m_width;
787 	int									m_height;
788 
789 	glu::Texture2D*						m_texture;
790 	TextureTestUtil::TextureRenderer	m_renderer;
791 };
792 
Compressed2DFormatCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & renderCtxInfo,const char * name,const char * description,tcu::CompressedTexFormat format,deUint32 randomSeed,int width,int height)793 Compressed2DFormatCase::Compressed2DFormatCase (tcu::TestContext&			testCtx,
794 												glu::RenderContext&			renderCtx,
795 												const glu::ContextInfo&		renderCtxInfo,
796 												const char*					name,
797 												const char*					description,
798 												tcu::CompressedTexFormat	format,
799 												deUint32					randomSeed,
800 												int							width,
801 												int							height)
802 	: TestCase			(testCtx, name, description)
803 	, m_renderCtx		(renderCtx)
804 	, m_renderCtxInfo	(renderCtxInfo)
805 	, m_format			(format)
806 	, m_randomSeed		(randomSeed)
807 	, m_width			(width)
808 	, m_height			(height)
809 	, m_texture			(DE_NULL)
810 	, m_renderer		(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
811 {
812 }
813 
~Compressed2DFormatCase(void)814 Compressed2DFormatCase::~Compressed2DFormatCase (void)
815 {
816 	deinit();
817 }
818 
init(void)819 void Compressed2DFormatCase::init (void)
820 {
821 	// Create texture.
822 	tcu::CompressedTexture	compressedTexture	(m_format, m_width, m_height);
823 	int						dataSize			= compressedTexture.getDataSize();
824 	deUint8*				data				= (deUint8*)compressedTexture.getData();
825 	de::Random				rnd					(m_randomSeed);
826 
827 	for (int i = 0; i < dataSize; i++)
828 		data[i] = rnd.getUint32() & 0xff;
829 
830 	m_texture = new glu::Texture2D(m_renderCtx, m_renderCtxInfo, 1, &compressedTexture);
831 }
832 
deinit(void)833 void Compressed2DFormatCase::deinit (void)
834 {
835 	delete m_texture;
836 	m_texture = DE_NULL;
837 
838 	m_renderer.clear();
839 }
840 
iterate(void)841 Compressed2DFormatCase::IterateResult Compressed2DFormatCase::iterate (void)
842 {
843 	const glw::Functions&	gl					= m_renderCtx.getFunctions();
844 	TestLog&				log					= m_testCtx.getLog();
845 	RandomViewport			viewport			(m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getWidth(), m_texture->getRefTexture().getHeight(), deStringHash(getName()));
846 	tcu::Surface			renderedFrame		(viewport.width, viewport.height);
847 	tcu::Surface			referenceFrame		(viewport.width, viewport.height);
848 	tcu::RGBA				threshold			= m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
849 	vector<float>			texCoord;
850 	ReferenceParams			renderParams		(TEXTURETYPE_2D);
851 	tcu::TextureFormatInfo	spec				= tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
852 
853 	renderParams.samplerType	= getSamplerType(m_texture->getRefTexture().getFormat());
854 	renderParams.sampler		= Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
855 	renderParams.colorScale		= spec.lookupScale;
856 	renderParams.colorBias		= spec.lookupBias;
857 
858 	computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
859 
860 	// Setup base viewport.
861 	gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
862 
863 	// Bind to unit 0.
864 	gl.activeTexture(GL_TEXTURE0);
865 	gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
866 
867 	// Setup nearest neighbor filtering and clamp-to-edge.
868 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_CLAMP_TO_EDGE);
869 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_CLAMP_TO_EDGE);
870 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST);
871 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
872 
873 	GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
874 
875 	// Draw.
876 	m_renderer.renderQuad(0, &texCoord[0], renderParams);
877 	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
878 
879 	// Compute reference.
880 	sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams);
881 
882 	// Compare and log.
883 	bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold);
884 
885 	m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
886 							isOk ? "Pass"				: "Image comparison failed");
887 
888 	return STOP;
889 }
890 
891 // CompressedCubeFormatCase
892 
893 class CompressedCubeFormatCase : public tcu::TestCase
894 {
895 public:
896 										CompressedCubeFormatCase	(tcu::TestContext&			testCtx,
897 																	 glu::RenderContext&		renderCtx,
898 																	 const glu::ContextInfo&	renderCtxInfo,
899 																	 const char*				name,
900 																	 const char*				description,
901 																	 tcu::CompressedTexFormat	format,
902 																	 deUint32					randomSeed,
903 																	 int						width,
904 																	 int						height);
905 
906 										~CompressedCubeFormatCase	(void);
907 
908 	void								init						(void);
909 	void								deinit						(void);
910 	IterateResult						iterate						(void);
911 
912 private:
913 										CompressedCubeFormatCase	(const CompressedCubeFormatCase& other);
914 	CompressedCubeFormatCase&			operator=					(const CompressedCubeFormatCase& other);
915 
916 	bool								testFace					(tcu::CubeFace face);
917 
918 	glu::RenderContext&					m_renderCtx;
919 	const glu::ContextInfo&				m_renderCtxInfo;
920 
921 	tcu::CompressedTexFormat			m_format;
922 
923 	deUint32							m_randomSeed;
924 	int									m_width;
925 	int									m_height;
926 
927 	glu::TextureCube*					m_texture;
928 	TextureTestUtil::TextureRenderer	m_renderer;
929 
930 	int									m_curFace;
931 	bool								m_isOk;
932 };
933 
CompressedCubeFormatCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & renderCtxInfo,const char * name,const char * description,tcu::CompressedTexFormat format,deUint32 randomSeed,int width,int height)934 CompressedCubeFormatCase::CompressedCubeFormatCase (tcu::TestContext&			testCtx,
935 													glu::RenderContext&			renderCtx,
936 													const glu::ContextInfo&		renderCtxInfo,
937 													const char*					name,
938 													const char*					description,
939 													tcu::CompressedTexFormat	format,
940 													deUint32					randomSeed,
941 													int							width,
942 													int							height)
943 	: TestCase			(testCtx, name, description)
944 	, m_renderCtx		(renderCtx)
945 	, m_renderCtxInfo	(renderCtxInfo)
946 	, m_format			(format)
947 	, m_randomSeed		(randomSeed)
948 	, m_width			(width)
949 	, m_height			(height)
950 	, m_texture			(DE_NULL)
951 	, m_renderer		(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
952 	, m_curFace			(0)
953 	, m_isOk			(false)
954 {
955 }
956 
~CompressedCubeFormatCase(void)957 CompressedCubeFormatCase::~CompressedCubeFormatCase (void)
958 {
959 	deinit();
960 }
961 
init(void)962 void CompressedCubeFormatCase::init (void)
963 {
964 	vector<tcu::CompressedTexture>	levels	(tcu::CUBEFACE_LAST);
965 	de::Random						rnd		(m_randomSeed);
966 
967 	for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
968 	{
969 		levels[face].setStorage(m_format, m_width, m_height);
970 
971 		int			dataSize	= levels[face].getDataSize();
972 		deUint8*	data		= (deUint8*)levels[face].getData();
973 
974 		for (int i = 0; i < dataSize; i++)
975 			data[i] = rnd.getUint32() & 0xff;
976 	}
977 
978 	m_texture = new glu::TextureCube(m_renderCtx, m_renderCtxInfo, 1, &levels[0]);
979 
980 	m_curFace	= 0;
981 	m_isOk		= true;
982 }
983 
deinit(void)984 void CompressedCubeFormatCase::deinit (void)
985 {
986 	delete m_texture;
987 	m_texture = DE_NULL;
988 
989 	m_renderer.clear();
990 }
991 
testFace(tcu::CubeFace face)992 bool CompressedCubeFormatCase::testFace (tcu::CubeFace face)
993 {
994 	const glw::Functions&	gl					= m_renderCtx.getFunctions();
995 	TestLog&				log					= m_testCtx.getLog();
996 	RandomViewport			viewport			(m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getSize(), m_texture->getRefTexture().getSize(), deStringHash(getName())+(deUint32)face);
997 	tcu::Surface			renderedFrame		(viewport.width, viewport.height);
998 	tcu::Surface			referenceFrame		(viewport.width, viewport.height);
999 	tcu::RGBA				threshold			= m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
1000 	vector<float>			texCoord;
1001 	ReferenceParams			renderParams		(TEXTURETYPE_CUBE);
1002 	tcu::TextureFormatInfo	spec				= tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
1003 
1004 	renderParams.samplerType				= getSamplerType(m_texture->getRefTexture().getFormat());
1005 	renderParams.sampler					= Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
1006 	renderParams.sampler.seamlessCubeMap	= true;
1007 	renderParams.colorScale					= spec.lookupScale;
1008 	renderParams.colorBias					= spec.lookupBias;
1009 
1010 	computeQuadTexCoordCube(texCoord, face);
1011 
1012 	log << TestLog::Message << face << TestLog::EndMessage;
1013 
1014 	// Setup base viewport.
1015 	gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
1016 
1017 	// Bind to unit 0.
1018 	gl.activeTexture(GL_TEXTURE0);
1019 	gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
1020 
1021 	// Setup nearest neighbor filtering and clamp-to-edge.
1022 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1023 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1024 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1025 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1026 
1027 	GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
1028 
1029 	m_renderer.renderQuad(0, &texCoord[0], renderParams);
1030 	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
1031 
1032 	// Compute reference.
1033 	sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams);
1034 
1035 	// Compare and log.
1036 	return compareImages(log, referenceFrame, renderedFrame, threshold);
1037 }
1038 
iterate(void)1039 CompressedCubeFormatCase::IterateResult CompressedCubeFormatCase::iterate (void)
1040 {
1041 	// Execute test for all faces.
1042 	if (!testFace((tcu::CubeFace)m_curFace))
1043 		m_isOk = false;
1044 
1045 	m_curFace += 1;
1046 
1047 	if (m_curFace == tcu::CUBEFACE_LAST)
1048 	{
1049 		m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
1050 								m_isOk ? "Pass"					: "Image comparison failed");
1051 		return STOP;
1052 	}
1053 	else
1054 		return CONTINUE;
1055 }
1056 
1057 // Texture2DFileCase
1058 
1059 class Texture2DFileCase : public tcu::TestCase
1060 {
1061 public:
1062 								Texture2DFileCase		(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames);
1063 								~Texture2DFileCase		(void);
1064 
1065 	void						init					(void);
1066 	void						deinit					(void);
1067 	IterateResult				iterate					(void);
1068 
1069 private:
1070 								Texture2DFileCase		(const Texture2DFileCase& other);
1071 	Texture2DFileCase&			operator=				(const Texture2DFileCase& other);
1072 
1073 	glu::RenderContext&			m_renderCtx;
1074 	const glu::ContextInfo&		m_renderCtxInfo;
1075 
1076 	std::vector<std::string>	m_filenames;
1077 
1078 	glu::Texture2D*				m_texture;
1079 	TextureRenderer				m_renderer;
1080 };
1081 
Texture2DFileCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & renderCtxInfo,const char * name,const char * description,const std::vector<std::string> & filenames)1082 Texture2DFileCase::Texture2DFileCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames)
1083 	: TestCase			(testCtx, name, description)
1084 	, m_renderCtx		(renderCtx)
1085 	, m_renderCtxInfo	(renderCtxInfo)
1086 	, m_filenames		(filenames)
1087 	, m_texture			(DE_NULL)
1088 	, m_renderer		(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
1089 {
1090 }
1091 
~Texture2DFileCase(void)1092 Texture2DFileCase::~Texture2DFileCase (void)
1093 {
1094 	deinit();
1095 }
1096 
init(void)1097 void Texture2DFileCase::init (void)
1098 {
1099 	// Create texture.
1100 	m_texture = glu::Texture2D::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(), (int)m_filenames.size(), m_filenames);
1101 }
1102 
deinit(void)1103 void Texture2DFileCase::deinit (void)
1104 {
1105 	delete m_texture;
1106 	m_texture = DE_NULL;
1107 
1108 	m_renderer.clear();
1109 }
1110 
iterate(void)1111 Texture2DFileCase::IterateResult Texture2DFileCase::iterate (void)
1112 {
1113 	const glw::Functions&	gl					= m_renderCtx.getFunctions();
1114 	TestLog&				log					= m_testCtx.getLog();
1115 	RandomViewport			viewport			(m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getWidth(), m_texture->getRefTexture().getHeight(), deStringHash(getName()));
1116 	tcu::Surface			renderedFrame		(viewport.width, viewport.height);
1117 	tcu::Surface			referenceFrame		(viewport.width, viewport.height);
1118 	tcu::RGBA				threshold			= m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
1119 	vector<float>			texCoord;
1120 
1121 	computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
1122 
1123 	// Setup base viewport.
1124 	gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
1125 
1126 	// Bind to unit 0.
1127 	gl.activeTexture(GL_TEXTURE0);
1128 	gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
1129 
1130 	// Setup nearest neighbor filtering and clamp-to-edge.
1131 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		GL_CLAMP_TO_EDGE);
1132 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		GL_CLAMP_TO_EDGE);
1133 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	GL_NEAREST);
1134 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	GL_NEAREST);
1135 
1136 	GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
1137 
1138 	// Draw.
1139 	m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_2D);
1140 	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
1141 	GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
1142 
1143 	// Compute reference.
1144 	ReferenceParams refParams(TEXTURETYPE_2D);
1145 	refParams.sampler = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
1146 	sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], refParams);
1147 
1148 	// Compare and log.
1149 	bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold);
1150 
1151 	m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
1152 							isOk ? "Pass"				: "Image comparison failed");
1153 
1154 	return STOP;
1155 }
1156 
1157 // TextureCubeFileCase
1158 
1159 class TextureCubeFileCase : public tcu::TestCase
1160 {
1161 public:
1162 								TextureCubeFileCase		(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames);
1163 								~TextureCubeFileCase	(void);
1164 
1165 	void						init					(void);
1166 	void						deinit					(void);
1167 	IterateResult				iterate					(void);
1168 
1169 private:
1170 								TextureCubeFileCase		(const TextureCubeFileCase& other);
1171 	TextureCubeFileCase&		operator=				(const TextureCubeFileCase& other);
1172 
1173 	bool						testFace				(tcu::CubeFace face);
1174 
1175 	glu::RenderContext&			m_renderCtx;
1176 	const glu::ContextInfo&		m_renderCtxInfo;
1177 
1178 	std::vector<std::string>	m_filenames;
1179 
1180 	glu::TextureCube*			m_texture;
1181 	TextureRenderer				m_renderer;
1182 
1183 	int							m_curFace;
1184 	bool						m_isOk;
1185 };
1186 
TextureCubeFileCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & renderCtxInfo,const char * name,const char * description,const std::vector<std::string> & filenames)1187 TextureCubeFileCase::TextureCubeFileCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames)
1188 	: TestCase			(testCtx, name, description)
1189 	, m_renderCtx		(renderCtx)
1190 	, m_renderCtxInfo	(renderCtxInfo)
1191 	, m_filenames		(filenames)
1192 	, m_texture			(DE_NULL)
1193 	, m_renderer		(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_HIGHP)
1194 	, m_curFace			(0)
1195 	, m_isOk			(false)
1196 {
1197 }
1198 
~TextureCubeFileCase(void)1199 TextureCubeFileCase::~TextureCubeFileCase (void)
1200 {
1201 	deinit();
1202 }
1203 
init(void)1204 void TextureCubeFileCase::init (void)
1205 {
1206 	// Create texture.
1207 	DE_ASSERT(m_filenames.size() % 6 == 0);
1208 	m_texture = glu::TextureCube::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(), (int)m_filenames.size()/6, m_filenames);
1209 
1210 	m_curFace	= 0;
1211 	m_isOk		= true;
1212 }
1213 
deinit(void)1214 void TextureCubeFileCase::deinit (void)
1215 {
1216 	delete m_texture;
1217 	m_texture = DE_NULL;
1218 
1219 	m_renderer.clear();
1220 }
1221 
testFace(tcu::CubeFace face)1222 bool TextureCubeFileCase::testFace (tcu::CubeFace face)
1223 {
1224 	const glw::Functions&	gl					= m_renderCtx.getFunctions();
1225 	TestLog&				log					= m_testCtx.getLog();
1226 	RandomViewport			viewport			(m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getSize(), m_texture->getRefTexture().getSize(), deStringHash(getName())+(deUint32)face);
1227 	tcu::Surface			renderedFrame		(viewport.width, viewport.height);
1228 	tcu::Surface			referenceFrame		(viewport.width, viewport.height);
1229 	Sampler					sampler				(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
1230 	tcu::RGBA				threshold			= m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
1231 	vector<float>			texCoord;
1232 
1233 	computeQuadTexCoordCube(texCoord, face);
1234 
1235 	// \todo [2011-10-28 pyry] Image set name / section?
1236 	log << TestLog::Message << face << TestLog::EndMessage;
1237 
1238 	// Setup base viewport.
1239 	gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
1240 
1241 	// Bind to unit 0.
1242 	gl.activeTexture(GL_TEXTURE0);
1243 	gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
1244 
1245 	// Setup nearest neighbor filtering and clamp-to-edge.
1246 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1247 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1248 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1249 	gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1250 
1251 	GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
1252 
1253 	m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_CUBE);
1254 	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
1255 	GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
1256 
1257 	// Compute reference.
1258 	sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], ReferenceParams(TEXTURETYPE_CUBE, sampler));
1259 
1260 	// Compare and log.
1261 	return compareImages(log, referenceFrame, renderedFrame, threshold);
1262 }
1263 
iterate(void)1264 TextureCubeFileCase::IterateResult TextureCubeFileCase::iterate (void)
1265 {
1266 	// Execute test for all faces.
1267 	if (!testFace((tcu::CubeFace)m_curFace))
1268 		m_isOk = false;
1269 
1270 	m_curFace += 1;
1271 
1272 	if (m_curFace == tcu::CUBEFACE_LAST)
1273 	{
1274 		m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS	: QP_TEST_RESULT_FAIL,
1275 								m_isOk ? "Pass"					: "Image comparison failed");
1276 		return STOP;
1277 	}
1278 	else
1279 		return CONTINUE;
1280 }
1281 
1282 // TextureFormatTests
1283 
TextureFormatTests(Context & context)1284 TextureFormatTests::TextureFormatTests (Context& context)
1285 	: TestCaseGroup(context, "format", "Texture Format Tests")
1286 {
1287 }
1288 
~TextureFormatTests(void)1289 TextureFormatTests::~TextureFormatTests (void)
1290 {
1291 }
1292 
toStringVector(const char * const * str,int numStr)1293 vector<string> toStringVector (const char* const* str, int numStr)
1294 {
1295 	vector<string> v;
1296 	v.resize(numStr);
1297 	for (int i = 0; i < numStr; i++)
1298 		v[i] = str[i];
1299 	return v;
1300 }
1301 
init(void)1302 void TextureFormatTests::init (void)
1303 {
1304 	tcu::TestCaseGroup* unsizedGroup	= DE_NULL;
1305 	tcu::TestCaseGroup*	sizedGroup		= DE_NULL;
1306 	tcu::TestCaseGroup* compressedGroup	= DE_NULL;
1307 	addChild((unsizedGroup		= new tcu::TestCaseGroup(m_testCtx, "unsized",		"Unsized formats")));
1308 	addChild((sizedGroup		= new tcu::TestCaseGroup(m_testCtx, "sized",		"Sized formats")));
1309 	addChild((compressedGroup	= new tcu::TestCaseGroup(m_testCtx, "compressed",	"Compressed formats")));
1310 
1311 	tcu::TestCaseGroup*	sized2DGroup		= DE_NULL;
1312 	tcu::TestCaseGroup*	sizedCubeGroup		= DE_NULL;
1313 	tcu::TestCaseGroup*	sized2DArrayGroup	= DE_NULL;
1314 	tcu::TestCaseGroup*	sized3DGroup		= DE_NULL;
1315 	sizedGroup->addChild((sized2DGroup			= new tcu::TestCaseGroup(m_testCtx, "2d",			"Sized formats (2D)")));
1316 	sizedGroup->addChild((sizedCubeGroup		= new tcu::TestCaseGroup(m_testCtx, "cube",			"Sized formats (Cubemap)")));
1317 	sizedGroup->addChild((sized2DArrayGroup		= new tcu::TestCaseGroup(m_testCtx, "2d_array",		"Sized formats (2D Array)")));
1318 	sizedGroup->addChild((sized3DGroup			= new tcu::TestCaseGroup(m_testCtx, "3d",			"Sized formats (3D)")));
1319 
1320 	struct
1321 	{
1322 		const char*	name;
1323 		deUint32		format;
1324 		deUint32		dataType;
1325 	} texFormats[] =
1326 	{
1327 		{ "alpha",							GL_ALPHA,			GL_UNSIGNED_BYTE },
1328 		{ "luminance",						GL_LUMINANCE,		GL_UNSIGNED_BYTE },
1329 		{ "luminance_alpha",				GL_LUMINANCE_ALPHA,	GL_UNSIGNED_BYTE },
1330 		{ "rgb_unsigned_short_5_6_5",		GL_RGB,				GL_UNSIGNED_SHORT_5_6_5 },
1331 		{ "rgb_unsigned_byte",				GL_RGB,				GL_UNSIGNED_BYTE },
1332 		{ "rgba_unsigned_short_4_4_4_4",	GL_RGBA,			GL_UNSIGNED_SHORT_4_4_4_4 },
1333 		{ "rgba_unsigned_short_5_5_5_1",	GL_RGBA,			GL_UNSIGNED_SHORT_5_5_5_1 },
1334 		{ "rgba_unsigned_byte",				GL_RGBA,			GL_UNSIGNED_BYTE }
1335 	};
1336 
1337 	for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
1338 	{
1339 		deUint32	format			= texFormats[formatNdx].format;
1340 		deUint32	dataType		= texFormats[formatNdx].dataType;
1341 		string	nameBase		= texFormats[formatNdx].name;
1342 		string	descriptionBase	= string(glu::getTextureFormatName(format)) + ", " + glu::getTypeName(dataType);
1343 
1344 		unsizedGroup->addChild(new Texture2DFormatCase			(m_testCtx, m_context,	(nameBase + "_2d_pot").c_str(),			(descriptionBase + ", GL_TEXTURE_2D").c_str(),			format, dataType, 128, 128));
1345 		unsizedGroup->addChild(new Texture2DFormatCase			(m_testCtx, m_context,	(nameBase + "_2d_npot").c_str(),		(descriptionBase + ", GL_TEXTURE_2D").c_str(),			format, dataType,  63, 112));
1346 		unsizedGroup->addChild(new TextureCubeFormatCase		(m_testCtx, m_context,	(nameBase + "_cube_pot").c_str(),		(descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),	format, dataType,  64,  64));
1347 		unsizedGroup->addChild(new TextureCubeFormatCase		(m_testCtx, m_context,	(nameBase + "_cube_npot").c_str(),		(descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),	format, dataType,  57,  57));
1348 		unsizedGroup->addChild(new Texture2DArrayFormatCase		(m_testCtx, m_context,	(nameBase + "_2d_array_pot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),	format, dataType,  64,  64,  8));
1349 		unsizedGroup->addChild(new Texture2DArrayFormatCase		(m_testCtx, m_context,	(nameBase + "_2d_array_npot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),	format, dataType,  63,  57,  7));
1350 		unsizedGroup->addChild(new Texture3DFormatCase			(m_testCtx, m_context,	(nameBase + "_3d_pot").c_str(),			(descriptionBase + ", GL_TEXTURE_3D").c_str(),			format, dataType,   8,  32, 16));
1351 		unsizedGroup->addChild(new Texture3DFormatCase			(m_testCtx, m_context,	(nameBase + "_3d_npot").c_str(),		(descriptionBase + ", GL_TEXTURE_3D").c_str(),			format, dataType,  11,  31,  7));
1352 	}
1353 
1354 	struct
1355 	{
1356 		const char*	name;
1357 		deUint32		internalFormat;
1358 	} sizedColorFormats[] =
1359 	{
1360 		{ "rgba32f",			GL_RGBA32F,			},
1361 		{ "rgba32i",			GL_RGBA32I,			},
1362 		{ "rgba32ui",			GL_RGBA32UI,		},
1363 		{ "rgba16f",			GL_RGBA16F,			},
1364 		{ "rgba16i",			GL_RGBA16I,			},
1365 		{ "rgba16ui",			GL_RGBA16UI,		},
1366 		{ "rgba8",				GL_RGBA8,			},
1367 		{ "rgba8i",				GL_RGBA8I,			},
1368 		{ "rgba8ui",			GL_RGBA8UI,			},
1369 		{ "srgb8_alpha8",		GL_SRGB8_ALPHA8,	},
1370 		{ "srgb_r8",			GL_SR8_EXT,			},
1371 		{ "rgb10_a2",			GL_RGB10_A2,		},
1372 		{ "rgb10_a2ui",			GL_RGB10_A2UI,		},
1373 		{ "rgba4",				GL_RGBA4,			},
1374 		{ "rgb5_a1",			GL_RGB5_A1,			},
1375 		{ "rgba8_snorm",		GL_RGBA8_SNORM,		},
1376 		{ "rgb8",				GL_RGB8,			},
1377 		{ "rgb565",				GL_RGB565,			},
1378 		{ "r11f_g11f_b10f",		GL_R11F_G11F_B10F,	},
1379 		{ "rgb32f",				GL_RGB32F,			},
1380 		{ "rgb32i",				GL_RGB32I,			},
1381 		{ "rgb32ui",			GL_RGB32UI,			},
1382 		{ "rgb16f",				GL_RGB16F,			},
1383 		{ "rgb16i",				GL_RGB16I,			},
1384 		{ "rgb16ui",			GL_RGB16UI,			},
1385 		{ "rgb8_snorm",			GL_RGB8_SNORM,		},
1386 		{ "rgb8i",				GL_RGB8I,			},
1387 		{ "rgb8ui",				GL_RGB8UI,			},
1388 		{ "srgb8",				GL_SRGB8,			},
1389 		{ "rgb9_e5",			GL_RGB9_E5,			},
1390 		{ "rg32f",				GL_RG32F,			},
1391 		{ "rg32i",				GL_RG32I,			},
1392 		{ "rg32ui",				GL_RG32UI,			},
1393 		{ "rg16f",				GL_RG16F,			},
1394 		{ "rg16i",				GL_RG16I,			},
1395 		{ "rg16ui",				GL_RG16UI,			},
1396 		{ "rg8",				GL_RG8,				},
1397 		{ "rg8i",				GL_RG8I,			},
1398 		{ "rg8ui",				GL_RG8UI,			},
1399 		{ "rg8_snorm",			GL_RG8_SNORM,		},
1400 		{ "r32f",				GL_R32F,			},
1401 		{ "r32i",				GL_R32I,			},
1402 		{ "r32ui",				GL_R32UI,			},
1403 		{ "r16f",				GL_R16F,			},
1404 		{ "r16i",				GL_R16I,			},
1405 		{ "r16ui",				GL_R16UI,			},
1406 		{ "r8",					GL_R8,				},
1407 		{ "r8i",				GL_R8I,				},
1408 		{ "r8ui",				GL_R8UI,			},
1409 		{ "r8_snorm",			GL_R8_SNORM,		}
1410 	};
1411 
1412 	struct
1413 	{
1414 		const char*	name;
1415 		deUint32		internalFormat;
1416 	} sizedDepthStencilFormats[] =
1417 	{
1418 		// Depth and stencil formats
1419 		{ "depth_component32f",	GL_DEPTH_COMPONENT32F	},
1420 		{ "depth_component24",	GL_DEPTH_COMPONENT24	},
1421 		{ "depth_component16",	GL_DEPTH_COMPONENT16	},
1422 		{ "depth32f_stencil8",	GL_DEPTH32F_STENCIL8	},
1423 		{ "depth24_stencil8",	GL_DEPTH24_STENCIL8		}
1424 	};
1425 
1426 	for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(sizedColorFormats); formatNdx++)
1427 	{
1428 		deUint32	internalFormat	= sizedColorFormats[formatNdx].internalFormat;
1429 		string	nameBase		= sizedColorFormats[formatNdx].name;
1430 		string	descriptionBase	= glu::getTextureFormatName(internalFormat);
1431 
1432 		sized2DGroup->addChild		(new Texture2DFormatCase		(m_testCtx, m_context,	(nameBase + "_pot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D").c_str(),			internalFormat, 128, 128));
1433 		sized2DGroup->addChild		(new Texture2DFormatCase		(m_testCtx, m_context,	(nameBase + "_npot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D").c_str(),			internalFormat,  63, 112));
1434 		sizedCubeGroup->addChild	(new TextureCubeFormatCase		(m_testCtx, m_context,	(nameBase + "_pot").c_str(),	(descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),	internalFormat,  64,  64));
1435 		sizedCubeGroup->addChild	(new TextureCubeFormatCase		(m_testCtx, m_context,	(nameBase + "_npot").c_str(),	(descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),	internalFormat,  57,  57));
1436 		sized2DArrayGroup->addChild	(new Texture2DArrayFormatCase	(m_testCtx, m_context,	(nameBase + "_pot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),	internalFormat,  64,  64,  8));
1437 		sized2DArrayGroup->addChild	(new Texture2DArrayFormatCase	(m_testCtx, m_context,	(nameBase + "_npot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),	internalFormat,  63,  57,  7));
1438 		sized3DGroup->addChild		(new Texture3DFormatCase		(m_testCtx, m_context,	(nameBase + "_pot").c_str(),	(descriptionBase + ", GL_TEXTURE_3D").c_str(),			internalFormat,   8,  32, 16));
1439 		sized3DGroup->addChild		(new Texture3DFormatCase		(m_testCtx, m_context,	(nameBase + "_npot").c_str(),	(descriptionBase + ", GL_TEXTURE_3D").c_str(),			internalFormat,  11,  31,  7));
1440 	}
1441 
1442 	for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(sizedDepthStencilFormats); formatNdx++)
1443 	{
1444 		deUint32	internalFormat	= sizedDepthStencilFormats[formatNdx].internalFormat;
1445 		string	nameBase		= sizedDepthStencilFormats[formatNdx].name;
1446 		string	descriptionBase	= glu::getTextureFormatName(internalFormat);
1447 
1448 		sized2DGroup->addChild		(new Texture2DFormatCase		(m_testCtx, m_context,	(nameBase + "_pot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D").c_str(),			internalFormat, 128, 128));
1449 		sized2DGroup->addChild		(new Texture2DFormatCase		(m_testCtx, m_context,	(nameBase + "_npot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D").c_str(),			internalFormat,  63, 112));
1450 		sizedCubeGroup->addChild	(new TextureCubeFormatCase		(m_testCtx, m_context,	(nameBase + "_pot").c_str(),	(descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),	internalFormat,  64,  64));
1451 		sizedCubeGroup->addChild	(new TextureCubeFormatCase		(m_testCtx, m_context,	(nameBase + "_npot").c_str(),	(descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),	internalFormat,  57,  57));
1452 		sized2DArrayGroup->addChild	(new Texture2DArrayFormatCase	(m_testCtx, m_context,	(nameBase + "_pot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),	internalFormat,  64,  64,  8));
1453 		sized2DArrayGroup->addChild	(new Texture2DArrayFormatCase	(m_testCtx, m_context,	(nameBase + "_npot").c_str(),	(descriptionBase + ", GL_TEXTURE_2D_ARRAY").c_str(),	internalFormat,  63,  57,  7));
1454 	}
1455 
1456 	// ETC-1 compressed formats.
1457 	{
1458 		static const char* filenames[] =
1459 		{
1460 			"data/etc1/photo_helsinki_mip_0.pkm",
1461 			"data/etc1/photo_helsinki_mip_1.pkm",
1462 			"data/etc1/photo_helsinki_mip_2.pkm",
1463 			"data/etc1/photo_helsinki_mip_3.pkm",
1464 			"data/etc1/photo_helsinki_mip_4.pkm",
1465 			"data/etc1/photo_helsinki_mip_5.pkm",
1466 			"data/etc1/photo_helsinki_mip_6.pkm",
1467 			"data/etc1/photo_helsinki_mip_7.pkm"
1468 		};
1469 		compressedGroup->addChild(new Texture2DFileCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_2d_pot", "GL_ETC1_RGB8_OES, GL_TEXTURE_2D", toStringVector(filenames, DE_LENGTH_OF_ARRAY(filenames))));
1470 	}
1471 
1472 	{
1473 		vector<string> filenames;
1474 		filenames.push_back("data/etc1/photo_helsinki_113x89.pkm");
1475 		compressedGroup->addChild(new Texture2DFileCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_2d_npot", "GL_ETC1_RGB8_OES, GL_TEXTURE_2D", filenames));
1476 	}
1477 
1478 	{
1479 		static const char* faceExt[] = { "neg_x", "pos_x", "neg_y", "pos_y", "neg_z", "pos_z" };
1480 
1481 		const int		potNumLevels	= 7;
1482 		vector<string>	potFilenames;
1483 		for (int level = 0; level < potNumLevels; level++)
1484 			for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1485 				potFilenames.push_back(string("data/etc1/skybox_") + faceExt[face] + "_mip_" + de::toString(level) + ".pkm");
1486 
1487 		compressedGroup->addChild(new TextureCubeFileCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_cube_pot", "GL_ETC1_RGB8_OES, GL_TEXTURE_CUBE_MAP", potFilenames));
1488 
1489 		vector<string> npotFilenames;
1490 		for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
1491 			npotFilenames.push_back(string("data/etc1/skybox_61x61_") + faceExt[face] + ".pkm");
1492 
1493 		compressedGroup->addChild(new TextureCubeFileCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_cube_npot", "GL_ETC_RGB8_OES, GL_TEXTURE_CUBE_MAP", npotFilenames));
1494 	}
1495 
1496 	// ETC-2 and EAC compressed formats.
1497 	struct {
1498 		const char*					descriptionBase;
1499 		const char*					nameBase;
1500 		tcu::CompressedTexFormat	format;
1501 	} etc2Formats[] =
1502 	{
1503 		{ "GL_COMPRESSED_R11_EAC",							"eac_r11",							tcu::COMPRESSEDTEXFORMAT_EAC_R11,							},
1504 		{ "GL_COMPRESSED_SIGNED_R11_EAC",					"eac_signed_r11",					tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_R11,					},
1505 		{ "GL_COMPRESSED_RG11_EAC",							"eac_rg11",							tcu::COMPRESSEDTEXFORMAT_EAC_RG11,							},
1506 		{ "GL_COMPRESSED_SIGNED_RG11_EAC",					"eac_signed_rg11",					tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_RG11,					},
1507 		{ "GL_COMPRESSED_RGB8_ETC2",						"etc2_rgb8",						tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8,							},
1508 		{ "GL_COMPRESSED_SRGB8_ETC2",						"etc2_srgb8",						tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8,						},
1509 		{ "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",	"etc2_rgb8_punchthrough_alpha1",	tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,		},
1510 		{ "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",	"etc2_srgb8_punchthrough_alpha1",	tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,	},
1511 		{ "GL_COMPRESSED_RGBA8_ETC2_EAC",					"etc2_eac_rgba8",					tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_RGBA8,					},
1512 		{ "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",			"etc2_eac_srgb8_alpha8",			tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_SRGB8_ALPHA8,				}
1513 	};
1514 
1515 	for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(etc2Formats); formatNdx++)
1516 	{
1517 		string descriptionBase	= etc2Formats[formatNdx].descriptionBase;
1518 		string nameBase			= etc2Formats[formatNdx].nameBase;
1519 
1520 		compressedGroup->addChild(new Compressed2DFormatCase	(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), (nameBase + "_2d_pot").c_str(),		(descriptionBase + ", GL_TEXTURE_2D").c_str(),			etc2Formats[formatNdx].format,	1,	128,	64));
1521 		compressedGroup->addChild(new CompressedCubeFormatCase	(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), (nameBase + "_cube_pot").c_str(),		(descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),	etc2Formats[formatNdx].format,	1,	64,		64));
1522 		compressedGroup->addChild(new Compressed2DFormatCase	(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), (nameBase + "_2d_npot").c_str(),		(descriptionBase + ", GL_TEXTURE_2D").c_str(),			etc2Formats[formatNdx].format,	1,	51,		65));
1523 		compressedGroup->addChild(new CompressedCubeFormatCase	(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), (nameBase + "_cube_npot").c_str(),	(descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(),	etc2Formats[formatNdx].format,	1,	51,		51));
1524 	}
1525 
1526 
1527 }
1528 
1529 } // Functional
1530 } // gles3
1531 } // deqp
1532