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