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