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 wrap mode tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es3fTextureWrapTests.hpp"
25 #include "glsTextureTestUtil.hpp"
26 #include "gluTexture.hpp"
27 #include "gluStrUtil.hpp"
28 #include "gluTextureUtil.hpp"
29 #include "gluPixelTransfer.hpp"
30 #include "tcuTestLog.hpp"
31 #include "tcuTextureUtil.hpp"
32 #include "tcuCompressedTexture.hpp"
33 #include "tcuVectorUtil.hpp"
34 #include "tcuTexLookupVerifier.hpp"
35 #include "deRandom.hpp"
36 #include "deStringUtil.hpp"
37 #include "deMemory.h"
38 
39 #include "glwEnums.hpp"
40 #include "glwFunctions.hpp"
41 
42 namespace deqp
43 {
44 namespace gles3
45 {
46 namespace Functional
47 {
48 
49 using tcu::TestLog;
50 using tcu::CompressedTexture;
51 using tcu::CompressedTexFormat;
52 using std::vector;
53 using std::string;
54 using tcu::Sampler;
55 using namespace glu;
56 using namespace gls::TextureTestUtil;
57 
58 //! Checks whether any ASTC version (LDR, HDR, full) is supported.
isASTCSupported(const glu::ContextInfo & contextInfo)59 static inline bool isASTCSupported (const glu::ContextInfo& contextInfo)
60 {
61 	const vector<string>& extensions = contextInfo.getExtensions();
62 
63 	for (int extNdx = 0; extNdx < (int)extensions.size(); extNdx++)
64 	{
65 		const string& ext = extensions[extNdx];
66 
67 		if (ext == "GL_KHR_texture_compression_astc_ldr" ||
68 			ext == "GL_KHR_texture_compression_astc_hdr" ||
69 			ext == "GL_OES_texture_compression_astc")
70 			return true;
71 	}
72 
73 	return false;
74 }
75 
76 enum
77 {
78 	VIEWPORT_WIDTH		= 256,
79 	VIEWPORT_HEIGHT		= 256
80 };
81 
82 class TextureWrapCase : public tcu::TestCase
83 {
84 public:
85 									TextureWrapCase			(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, deUint32 format, deUint32 dataType, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, int width, int height);
86 									TextureWrapCase			(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, const std::vector<std::string>& filenames);
87 									TextureWrapCase			(tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, CompressedTexFormat compressedFormat, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, int width, int height);
88 									~TextureWrapCase		(void);
89 
90 	void							init					(void);
91 	void							deinit					(void);
92 	IterateResult					iterate					(void);
93 
94 private:
95 									TextureWrapCase			(const TextureWrapCase& other);
96 	TextureWrapCase&				operator=				(const TextureWrapCase& other);
97 
98 	struct Case
99 	{
100 		tcu::Vec2 bottomLeft;
101 		tcu::Vec2 topRight;
102 
Casedeqp::gles3::Functional::TextureWrapCase::Case103 		Case (void) {}
Casedeqp::gles3::Functional::TextureWrapCase::Case104 		Case (const tcu::Vec2& bl, const tcu::Vec2& tr) : bottomLeft(bl), topRight(tr) {}
105 	};
106 
107 	glu::RenderContext&				m_renderCtx;
108 	const glu::ContextInfo&			m_renderCtxInfo;
109 
110 	const deUint32					m_format;
111 	const deUint32					m_dataType;
112 	const CompressedTexFormat		m_compressedFormat;
113 	const deUint32					m_wrapS;
114 	const deUint32					m_wrapT;
115 	const deUint32					m_minFilter;
116 	const deUint32					m_magFilter;
117 
118 	int								m_width;
119 	int								m_height;
120 	const std::vector<std::string>	m_filenames;
121 
122 	vector<Case>					m_cases;
123 	int								m_caseNdx;
124 
125 	glu::Texture2D*					m_texture;
126 	TextureRenderer					m_renderer;
127 };
128 
TextureWrapCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & ctxInfo,const char * name,const char * description,deUint32 format,deUint32 dataType,deUint32 wrapS,deUint32 wrapT,deUint32 minFilter,deUint32 magFilter,int width,int height)129 TextureWrapCase::TextureWrapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, deUint32 format, deUint32 dataType, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, int width, int height)
130 	: TestCase				(testCtx, name, description)
131 	, m_renderCtx			(renderCtx)
132 	, m_renderCtxInfo		(ctxInfo)
133 	, m_format				(format)
134 	, m_dataType			(dataType)
135 	, m_compressedFormat	(tcu::COMPRESSEDTEXFORMAT_LAST)
136 	, m_wrapS				(wrapS)
137 	, m_wrapT				(wrapT)
138 	, m_minFilter			(minFilter)
139 	, m_magFilter			(magFilter)
140 	, m_width				(width)
141 	, m_height				(height)
142 	, m_caseNdx				(0)
143 	, m_texture				(DE_NULL)
144 	, m_renderer			(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_MEDIUMP)
145 {
146 }
147 
TextureWrapCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & ctxInfo,const char * name,const char * description,deUint32 wrapS,deUint32 wrapT,deUint32 minFilter,deUint32 magFilter,const std::vector<std::string> & filenames)148 TextureWrapCase::TextureWrapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, const std::vector<std::string>& filenames)
149 	: TestCase				(testCtx, name, description)
150 	, m_renderCtx			(renderCtx)
151 	, m_renderCtxInfo		(ctxInfo)
152 	, m_format				(GL_NONE)
153 	, m_dataType			(GL_NONE)
154 	, m_compressedFormat	(tcu::COMPRESSEDTEXFORMAT_LAST)
155 	, m_wrapS				(wrapS)
156 	, m_wrapT				(wrapT)
157 	, m_minFilter			(minFilter)
158 	, m_magFilter			(magFilter)
159 	, m_width				(0)
160 	, m_height				(0)
161 	, m_filenames			(filenames)
162 	, m_caseNdx				(0)
163 	, m_texture				(DE_NULL)
164 	, m_renderer			(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_MEDIUMP)
165 {
166 }
167 
TextureWrapCase(tcu::TestContext & testCtx,glu::RenderContext & renderCtx,const glu::ContextInfo & ctxInfo,const char * name,const char * description,CompressedTexFormat compressedFormat,deUint32 wrapS,deUint32 wrapT,deUint32 minFilter,deUint32 magFilter,int width,int height)168 TextureWrapCase::TextureWrapCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& ctxInfo, const char* name, const char* description, CompressedTexFormat compressedFormat, deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter, int width, int height)
169 	: TestCase				(testCtx, name, description)
170 	, m_renderCtx			(renderCtx)
171 	, m_renderCtxInfo		(ctxInfo)
172 	, m_format				(GL_NONE)
173 	, m_dataType			(GL_NONE)
174 	, m_compressedFormat	(compressedFormat)
175 	, m_wrapS				(wrapS)
176 	, m_wrapT				(wrapT)
177 	, m_minFilter			(minFilter)
178 	, m_magFilter			(magFilter)
179 	, m_width				(width)
180 	, m_height				(height)
181 	, m_caseNdx				(0)
182 	, m_texture				(DE_NULL)
183 	, m_renderer			(renderCtx, testCtx.getLog(), glu::GLSL_VERSION_300_ES, glu::PRECISION_MEDIUMP)
184 {
185 }
186 
187 
~TextureWrapCase(void)188 TextureWrapCase::~TextureWrapCase (void)
189 {
190 	deinit();
191 }
192 
init(void)193 void TextureWrapCase::init (void)
194 {
195 	// Load or generate texture.
196 
197 	if (!m_filenames.empty())
198 	{
199 		// Load compressed texture from file.
200 
201 		DE_ASSERT(m_width == 0 && m_height == 0 && m_format == GL_NONE && m_dataType == GL_NONE);
202 
203 		m_texture	= glu::Texture2D::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(), (int)m_filenames.size(), m_filenames);
204 		m_width		= m_texture->getRefTexture().getWidth();
205 		m_height	= m_texture->getRefTexture().getHeight();
206 	}
207 	else if (m_compressedFormat != tcu::COMPRESSEDTEXFORMAT_LAST)
208 	{
209 		// Generate compressed texture.
210 
211 		DE_ASSERT(m_format == GL_NONE && m_dataType == GL_NONE);
212 
213 		if (tcu::isEtcFormat(m_compressedFormat))
214 		{
215 			// Create ETC texture. Any content is valid.
216 
217 			tcu::CompressedTexture	compressedTexture	(m_compressedFormat, m_width, m_height);
218 			const int				dataSize			= compressedTexture.getDataSize();
219 			deUint8* const			data				= (deUint8*)compressedTexture.getData();
220 			de::Random				rnd					(deStringHash(getName()));
221 
222 			for (int i = 0; i < dataSize; i++)
223 				data[i] = rnd.getUint32() & 0xff;
224 
225 			m_texture = new glu::Texture2D(m_renderCtx, m_renderCtxInfo, 1, &compressedTexture);
226 		}
227 		else if (tcu::isAstcFormat(m_compressedFormat))
228 		{
229 			// Create ASTC texture by picking from a set of pre-generated blocks.
230 
231 			static const int		BLOCK_SIZE				= 16;
232 			static const deUint8	blocks[][BLOCK_SIZE]	=
233 			{
234 				// \note All of the following blocks are valid in LDR mode.
235 				{ 252,	253,	255,	255,	255,	255,	255,	255,	8,		71,		90,		78,		22,		17,		26,		66,		},
236 				{ 252,	253,	255,	255,	255,	255,	255,	255,	220,	74,		139,	235,	249,	6,		145,	125		},
237 				{ 252,	253,	255,	255,	255,	255,	255,	255,	223,	251,	28,		206,	54,		251,	160,	174		},
238 				{ 252,	253,	255,	255,	255,	255,	255,	255,	39,		4,		153,	219,	180,	61,		51,		37		},
239 				{ 67,	2,		0,		254,	1,		0,		64,		215,	83,		211,	159,	105,	41,		140,	50,		2		},
240 				{ 67,	130,	0,		170,	84,		255,	65,		215,	83,		211,	159,	105,	41,		140,	50,		2		},
241 				{ 67,	2,		129,	38,		51,		229,	95,		215,	83,		211,	159,	105,	41,		140,	50,		2		},
242 				{ 67,	130,	193,	56,		213,	144,	95,		215,	83,		211,	159,	105,	41,		140,	50,		2		}
243 			};
244 
245 			if (!isASTCSupported(m_renderCtxInfo)) // \note Any level of ASTC support is enough, since we're only using LDR blocks.
246 				throw tcu::NotSupportedError("ASTC not supported");
247 
248 			tcu::CompressedTexture	compressedTexture	(m_compressedFormat, m_width, m_height);
249 			const int				dataSize			= compressedTexture.getDataSize();
250 			deUint8* const			data				= (deUint8*)compressedTexture.getData();
251 			de::Random				rnd					(deStringHash(getName()));
252 			DE_ASSERT(dataSize % BLOCK_SIZE == 0);
253 
254 			for (int i = 0; i < dataSize/BLOCK_SIZE; i++)
255 				deMemcpy(&data[i*BLOCK_SIZE], &blocks[rnd.getInt(0, DE_LENGTH_OF_ARRAY(blocks)-1)][0], BLOCK_SIZE);
256 
257 			// \note All blocks are valid LDR blocks so ASTCMODE_* doesn't change anything
258 			m_texture = new glu::Texture2D(m_renderCtx, m_renderCtxInfo, 1, &compressedTexture, tcu::TexDecompressionParams(tcu::TexDecompressionParams::ASTCMODE_LDR));
259 		}
260 		else
261 			DE_ASSERT(false);
262 	}
263 	else
264 	{
265 		m_texture = new Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height);
266 
267 		// Fill level 0.
268 		m_texture->getRefTexture().allocLevel(0);
269 		tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), tcu::Vec4(-0.5f, -0.5f, -0.5f, 2.0f), tcu::Vec4(1.0f, 1.0f, 1.0f, 0.0f));
270 
271 		m_texture->upload();
272 	}
273 
274 	// Sub-cases.
275 
276 	m_cases.push_back(Case(tcu::Vec2(-1.5f, -3.0f), tcu::Vec2(1.5f, 2.5f)));
277 	m_cases.push_back(Case(tcu::Vec2(-0.5f, 0.75f), tcu::Vec2(0.25f, 1.25f)));
278 	DE_ASSERT(m_caseNdx == 0);
279 
280 	// Initialize to success, set to failure later if needed.
281 
282 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
283 }
284 
deinit(void)285 void TextureWrapCase::deinit (void)
286 {
287 	delete m_texture;
288 	m_texture = DE_NULL;
289 
290 	m_renderer.clear();
291 }
292 
iterate(void)293 TextureWrapCase::IterateResult TextureWrapCase::iterate (void)
294 {
295 	const glw::Functions&			gl								= m_renderCtx.getFunctions();
296 	TestLog&						log								= m_testCtx.getLog();
297 	const RandomViewport			viewport						(m_renderCtx.getRenderTarget(), VIEWPORT_WIDTH, VIEWPORT_HEIGHT, deStringHash(getName()) + m_caseNdx);
298 	tcu::Surface					renderedFrame					(viewport.width, viewport.height);
299 	ReferenceParams					refParams						(TEXTURETYPE_2D);
300 	const tcu::TextureFormat		texFormat						= m_texture->getRefTexture().getFormat();
301 	vector<float>					texCoord;
302 	const tcu::TextureFormatInfo	texFormatInfo					= tcu::getTextureFormatInfo(texFormat);
303 	// \note For non-sRGB ASTC formats, the values are fp16 in range [0..1], not the range assumed given by tcu::getTextureFormatInfo().
304 	const bool						useDefaultColorScaleAndBias		= !tcu::isAstcFormat(m_compressedFormat) || tcu::isAstcSRGBFormat(m_compressedFormat);
305 
306 	// Bind to unit 0.
307 	gl.activeTexture(GL_TEXTURE0);
308 	gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
309 
310 	// Setup filtering and wrap modes.
311 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,		m_wrapS);
312 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,		m_wrapT);
313 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,	m_minFilter);
314 	gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,	m_magFilter);
315 
316 	GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
317 
318 	// Parameters for reference images.
319 	refParams.sampler		= mapGLSampler(m_wrapS, m_wrapT, m_minFilter, m_magFilter);
320 	refParams.lodMode		= LODMODE_EXACT;
321 	refParams.samplerType	= getSamplerType(m_texture->getRefTexture().getFormat());
322 	refParams.colorScale	= useDefaultColorScaleAndBias ? texFormatInfo.lookupScale	: tcu::Vec4(1.0f);
323 	refParams.colorBias		= useDefaultColorScaleAndBias ? texFormatInfo.lookupBias	: tcu::Vec4(0.0f);
324 
325 	gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
326 	computeQuadTexCoord2D(texCoord, m_cases[m_caseNdx].bottomLeft, m_cases[m_caseNdx].topRight);
327 	m_renderer.renderQuad(0, &texCoord[0], refParams);
328 	glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
329 
330 	{
331 		const tcu::ScopedLogSection		section			(log, string("Test") + de::toString(m_caseNdx), string("Test ") + de::toString(m_caseNdx));
332 		const bool						isNearestOnly	= m_minFilter == GL_NEAREST && m_magFilter == GL_NEAREST;
333 		const bool						isSRGB			= tcu::isSRGB(texFormat);
334 		const tcu::PixelFormat			pixelFormat		= m_renderCtx.getRenderTarget().getPixelFormat();
335 		const tcu::IVec4				colorBits		= tcu::max(getBitsVec(pixelFormat) - (isNearestOnly && !isSRGB ? 1 : 2), tcu::IVec4(0));
336 		tcu::LodPrecision				lodPrecision;
337 		tcu::LookupPrecision			lookupPrecision;
338 
339 		lodPrecision.derivateBits		= 18;
340 		lodPrecision.lodBits			= 5;
341 		lookupPrecision.colorThreshold	= tcu::computeFixedPointThreshold(colorBits) / refParams.colorScale;
342 		lookupPrecision.coordBits		= tcu::IVec3(20,20,0);
343 		lookupPrecision.uvwBits			= tcu::IVec3(5,5,0);
344 		lookupPrecision.colorMask		= getCompareMask(pixelFormat);
345 
346 		log << TestLog::Message << "Note: lookup coordinates: bottom-left " << m_cases[m_caseNdx].bottomLeft << ", top-right " << m_cases[m_caseNdx].topRight << TestLog::EndMessage;
347 
348 		const bool isOk = verifyTextureResult(m_testCtx, renderedFrame.getAccess(), m_texture->getRefTexture(),
349 											  &texCoord[0], refParams, lookupPrecision, lodPrecision, pixelFormat);
350 
351 		if (!isOk)
352 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image verification failed");
353 	}
354 
355 	m_caseNdx++;
356 	return m_caseNdx < (int)m_cases.size() ? CONTINUE : STOP;
357 }
358 
TextureWrapTests(Context & context)359 TextureWrapTests::TextureWrapTests (Context& context)
360 	: TestCaseGroup(context, "wrap", "Wrap Mode Tests")
361 {
362 }
363 
~TextureWrapTests(void)364 TextureWrapTests::~TextureWrapTests (void)
365 {
366 }
367 
init(void)368 void TextureWrapTests::init (void)
369 {
370 	static const struct
371 	{
372 		const char*		name;
373 		deUint32		mode;
374 	} wrapModes[] =
375 	{
376 		{ "clamp",		GL_CLAMP_TO_EDGE },
377 		{ "repeat",		GL_REPEAT },
378 		{ "mirror",		GL_MIRRORED_REPEAT }
379 	};
380 
381 	static const struct
382 	{
383 		const char*		name;
384 		deUint32		mode;
385 	} filteringModes[] =
386 	{
387 		{ "nearest",	GL_NEAREST },
388 		{ "linear",		GL_LINEAR }
389 	};
390 
391 #define FOR_EACH(ITERATOR, ARRAY, BODY)	\
392 	for (int ITERATOR = 0; ITERATOR < DE_LENGTH_OF_ARRAY(ARRAY); ITERATOR++)	\
393 		BODY
394 
395 	// RGBA8 cases.
396 	{
397 		static const struct
398 		{
399 			const char*		name;
400 			int				width;
401 			int				height;
402 		} rgba8Sizes[] =
403 		{
404 			{ "pot",		64, 128 },
405 			{ "npot",		63, 112 }
406 		};
407 
408 		{
409 			TestCaseGroup* const rgba8Group = new TestCaseGroup(m_context, "rgba8", "");
410 			addChild(rgba8Group);
411 
412 			FOR_EACH(size,		rgba8Sizes,
413 			FOR_EACH(wrapS,		wrapModes,
414 			FOR_EACH(wrapT,		wrapModes,
415 			FOR_EACH(filter,	filteringModes,
416 				{
417 					const string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_" + rgba8Sizes[size].name;
418 					rgba8Group->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "",
419 															 GL_RGBA, GL_UNSIGNED_BYTE,
420 															 wrapModes[wrapS].mode,
421 															 wrapModes[wrapT].mode,
422 															 filteringModes[filter].mode, filteringModes[filter].mode,
423 															 rgba8Sizes[size].width, rgba8Sizes[size].height));
424 
425 				}))));
426 		}
427 	}
428 
429 	// ETC1 cases.
430 	{
431 		TestCaseGroup* const etc1Group = new TestCaseGroup(m_context, "etc1", "");
432 		addChild(etc1Group);
433 
434 		// Power-of-two ETC1 texture
435 		std::vector<std::string> potFilenames;
436 		potFilenames.push_back("data/etc1/photo_helsinki_mip_0.pkm");
437 
438 		FOR_EACH(wrapS,		wrapModes,
439 		FOR_EACH(wrapT,		wrapModes,
440 		FOR_EACH(filter,	filteringModes,
441 			{
442 				const string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_pot";
443 				etc1Group->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "",
444 														wrapModes[wrapS].mode,
445 														wrapModes[wrapT].mode,
446 														filteringModes[filter].mode, filteringModes[filter].mode,
447 														potFilenames));
448 
449 			})));
450 
451 		std::vector<std::string> npotFilenames;
452 		npotFilenames.push_back("data/etc1/photo_helsinki_113x89.pkm");
453 
454 		// NPOT ETC1 texture
455 		FOR_EACH(wrapS,		wrapModes,
456 		FOR_EACH(wrapT,		wrapModes,
457 		FOR_EACH(filter,	filteringModes,
458 			{
459 				const string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_npot";
460 				etc1Group->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "",
461 														wrapModes[wrapS].mode,
462 														wrapModes[wrapT].mode,
463 														filteringModes[filter].mode, filteringModes[filter].mode,
464 														npotFilenames));
465 			})));
466 	}
467 
468 	// ETC-2 (and EAC) cases.
469 	{
470 		static const struct
471 		{
472 			const char*			name;
473 			CompressedTexFormat	format;
474 		} etc2Formats[] =
475 		{
476 			{ "eac_r11",							tcu::COMPRESSEDTEXFORMAT_EAC_R11,							},
477 			{ "eac_signed_r11",						tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_R11,					},
478 			{ "eac_rg11",							tcu::COMPRESSEDTEXFORMAT_EAC_RG11,							},
479 			{ "eac_signed_rg11",					tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_RG11,					},
480 			{ "etc2_rgb8",							tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8,							},
481 			{ "etc2_srgb8",							tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8,						},
482 			{ "etc2_rgb8_punchthrough_alpha1",		tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,		},
483 			{ "etc2_srgb8_punchthrough_alpha1",		tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,	},
484 			{ "etc2_eac_rgba8",						tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_RGBA8,					},
485 			{ "etc2_eac_srgb8_alpha8",				tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_SRGB8_ALPHA8,				}
486 		};
487 
488 		static const struct
489 		{
490 			const char*		name;
491 			int				width;
492 			int				height;
493 		} etc2Sizes[] =
494 		{
495 			{ "pot",	64,		128	},
496 			{ "npot",	123,	107	}
497 		};
498 
499 		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(etc2Formats); formatNdx++)
500 		{
501 			TestCaseGroup* const formatGroup = new TestCaseGroup(m_context, etc2Formats[formatNdx].name, "");
502 			addChild(formatGroup);
503 
504 			FOR_EACH(size,		etc2Sizes,
505 			FOR_EACH(wrapS,		wrapModes,
506 			FOR_EACH(wrapT,		wrapModes,
507 			FOR_EACH(filter,	filteringModes,
508 				{
509 					const string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_" + etc2Sizes[size].name;
510 					formatGroup->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "",
511 															  etc2Formats[formatNdx].format,
512 															  wrapModes[wrapS].mode,
513 															  wrapModes[wrapT].mode,
514 															  filteringModes[filter].mode, filteringModes[filter].mode,
515 															  etc2Sizes[size].width, etc2Sizes[size].height));
516 				}))));
517 		}
518 	}
519 
520 	// ASTC cases.
521 	{
522 		for (int formatI = 0; formatI < tcu::COMPRESSEDTEXFORMAT_LAST; formatI++)
523 		{
524 			const CompressedTexFormat format = (CompressedTexFormat)formatI;
525 
526 			if (!tcu::isAstcFormat(format))
527 				continue;
528 
529 			{
530 				const tcu::IVec3		blockSize		= tcu::getBlockPixelSize(format);
531 				const string			formatName		= "astc_" + de::toString(blockSize.x()) + "x" + de::toString(blockSize.y()) + (tcu::isAstcSRGBFormat(format) ? "_srgb" : "");
532 				TestCaseGroup* const	formatGroup		= new TestCaseGroup(m_context, formatName.c_str(), "");
533 				addChild(formatGroup);
534 
535 				DE_ASSERT(blockSize.z() == 1);
536 
537 				// \note This array is NOT static.
538 				const struct
539 				{
540 					const char*		name;
541 					int				width;
542 					int				height;
543 				} formatSizes[] =
544 				{
545 					{ "divisible",		blockSize.x()*10,		blockSize.y()*10	},
546 					{ "not_divisible",	blockSize.x()*10+1,		blockSize.y()*10+1	},
547 				};
548 
549 				FOR_EACH(size,		formatSizes,
550 				FOR_EACH(wrapS,		wrapModes,
551 				FOR_EACH(wrapT,		wrapModes,
552 				FOR_EACH(filter,	filteringModes,
553 					{
554 						string name = string("") + wrapModes[wrapS].name + "_" + wrapModes[wrapT].name + "_" + filteringModes[filter].name + "_" + formatSizes[size].name;
555 						formatGroup->addChild(new TextureWrapCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), name.c_str(), "",
556 																  format,
557 																  wrapModes[wrapS].mode,
558 																  wrapModes[wrapT].mode,
559 																  filteringModes[filter].mode, filteringModes[filter].mode,
560 																  formatSizes[size].width, formatSizes[size].height));
561 					}))));
562 			}
563 		}
564 	}
565 }
566 
567 } // Functional
568 } // gles3
569 } // deqp
570