1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Texture format tests.
24 * + nearest-neighbor filtering
26 * + full texture coordinate range (but not outside) tested
27 * + accessed from fragment shader
29 * + named texture object
33 * + texture type: 2D or cubemap
34 *//*--------------------------------------------------------------------*/
36 #include "es2fTextureFormatTests.hpp"
37 #include "glsTextureTestUtil.hpp"
38 #include "gluTexture.hpp"
39 #include "gluStrUtil.hpp"
40 #include "gluTextureUtil.hpp"
41 #include "gluPixelTransfer.hpp"
42 #include "tcuSurfaceAccess.hpp"
43 #include "tcuTestLog.hpp"
44 #include "tcuTextureUtil.hpp"
46 #include "deStringUtil.hpp"
48 #include "glwEnums.hpp"
49 #include "glwFunctions.hpp"
63 using namespace gls::TextureTestUtil;
64 using namespace glu::TextureTestUtil;
66 // Texture2DFormatCase
68 class Texture2DFormatCase : public tcu::TestCase
71 Texture2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height);
72 ~Texture2DFormatCase (void);
76 IterateResult iterate (void);
79 Texture2DFormatCase (const Texture2DFormatCase& other);
80 Texture2DFormatCase& operator= (const Texture2DFormatCase& other);
82 glu::RenderContext& m_renderCtx;
84 const deUint32 m_format;
85 const deUint32 m_dataType;
89 glu::Texture2D* m_texture;
90 TextureRenderer m_renderer;
93 Texture2DFormatCase::Texture2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height)
94 : TestCase (testCtx, name, description)
95 , m_renderCtx (renderCtx)
97 , m_dataType (dataType)
100 , m_texture (DE_NULL)
101 , m_renderer (renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP)
105 Texture2DFormatCase::~Texture2DFormatCase (void)
110 void Texture2DFormatCase::init (void)
112 TestLog& log = m_testCtx.getLog();
113 tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType);
114 tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(fmt);
115 std::ostringstream fmtName;
117 fmtName << getTextureFormatStr(m_format) << ", " << getTypeStr(m_dataType);
119 log << TestLog::Message << "2D texture, " << fmtName.str() << ", " << m_width << "x" << m_height
120 << ",\n fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient"
121 << TestLog::EndMessage;
123 m_texture = new Texture2D(m_renderCtx, m_format, m_dataType, m_width, m_height);
126 m_texture->getRefTexture().allocLevel(0);
127 tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevel(0), spec.valueMin, spec.valueMax);
130 void Texture2DFormatCase::deinit (void)
138 Texture2DFormatCase::IterateResult Texture2DFormatCase::iterate (void)
140 TestLog& log = m_testCtx.getLog();
141 const glw::Functions& gl = m_renderCtx.getFunctions();
142 RandomViewport viewport (m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName()));
143 tcu::Surface renderedFrame (viewport.width, viewport.height);
144 tcu::Surface referenceFrame (viewport.width, viewport.height);
145 tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
146 vector<float> texCoord;
147 ReferenceParams renderParams (TEXTURETYPE_2D);
148 tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
149 const deUint32 wrapS = GL_CLAMP_TO_EDGE;
150 const deUint32 wrapT = GL_CLAMP_TO_EDGE;
151 const deUint32 minFilter = GL_NEAREST;
152 const deUint32 magFilter = GL_NEAREST;
154 renderParams.flags |= RenderParams::LOG_ALL;
155 renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat());
156 renderParams.sampler = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
157 renderParams.colorScale = spec.lookupScale;
158 renderParams.colorBias = spec.lookupBias;
160 computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
162 log << TestLog::Message << "Texture parameters:"
163 << "\n WRAP_S = " << getTextureParameterValueStr(GL_TEXTURE_WRAP_S, wrapS)
164 << "\n WRAP_T = " << getTextureParameterValueStr(GL_TEXTURE_WRAP_T, wrapT)
165 << "\n MIN_FILTER = " << getTextureParameterValueStr(GL_TEXTURE_MIN_FILTER, minFilter)
166 << "\n MAG_FILTER = " << getTextureParameterValueStr(GL_TEXTURE_MAG_FILTER, magFilter)
167 << TestLog::EndMessage;
169 // Setup base viewport.
170 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
172 // Upload texture data to GL.
176 gl.activeTexture(GL_TEXTURE0);
177 gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
179 // Setup nearest neighbor filtering and clamp-to-edge.
180 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS);
181 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT);
182 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
183 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter);
185 GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
188 m_renderer.renderQuad(0, &texCoord[0], renderParams);
189 glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
190 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
192 // Compute reference.
193 sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams);
196 bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold);
198 m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
199 isOk ? "Pass" : "Image comparison failed");
204 // TextureCubeFormatCase
206 class TextureCubeFormatCase : public tcu::TestCase
209 TextureCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height);
210 ~TextureCubeFormatCase (void);
214 IterateResult iterate (void);
217 TextureCubeFormatCase (const TextureCubeFormatCase& other);
218 TextureCubeFormatCase& operator= (const TextureCubeFormatCase& other);
220 bool testFace (tcu::CubeFace face);
222 glu::RenderContext& m_renderCtx;
224 const deUint32 m_format;
225 const deUint32 m_dataType;
229 glu::TextureCube* m_texture;
230 TextureRenderer m_renderer;
237 TextureCubeFormatCase::TextureCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, deUint32 format, deUint32 dataType, int width, int height)
238 : TestCase (testCtx, name, description)
239 , m_renderCtx (renderCtx)
241 , m_dataType (dataType)
244 , m_texture (DE_NULL)
245 , m_renderer (renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP)
251 TextureCubeFormatCase::~TextureCubeFormatCase (void)
256 void TextureCubeFormatCase::init (void)
258 TestLog& log = m_testCtx.getLog();
259 tcu::TextureFormat fmt = glu::mapGLTransferFormat(m_format, m_dataType);
260 tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(fmt);
261 std::ostringstream fmtName;
264 fmtName << getTextureFormatStr(m_format) << ", " << getTypeStr(m_dataType);
266 fmtName << getTextureFormatStr(m_format);
268 log << TestLog::Message << "Cube map texture, " << fmtName.str() << ", " << m_width << "x" << m_height
269 << ",\n fill with " << formatGradient(&spec.valueMin, &spec.valueMax) << " gradient"
270 << TestLog::EndMessage;
272 DE_ASSERT(m_width == m_height);
273 m_texture = m_dataType != GL_NONE
274 ? new TextureCube(m_renderCtx, m_format, m_dataType, m_width) // Implicit internal format.
275 : new TextureCube(m_renderCtx, m_format, m_width); // Explicit internal format.
278 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
280 tcu::Vec4 gMin, gMax;
284 case 0: gMin = spec.valueMin.swizzle(0, 1, 2, 3); gMax = spec.valueMax.swizzle(0, 1, 2, 3); break;
285 case 1: gMin = spec.valueMin.swizzle(2, 1, 0, 3); gMax = spec.valueMax.swizzle(2, 1, 0, 3); break;
286 case 2: gMin = spec.valueMin.swizzle(1, 2, 0, 3); gMax = spec.valueMax.swizzle(1, 2, 0, 3); break;
287 case 3: gMin = spec.valueMax.swizzle(0, 1, 2, 3); gMax = spec.valueMin.swizzle(0, 1, 2, 3); break;
288 case 4: gMin = spec.valueMax.swizzle(2, 1, 0, 3); gMax = spec.valueMin.swizzle(2, 1, 0, 3); break;
289 case 5: gMin = spec.valueMax.swizzle(1, 2, 0, 3); gMax = spec.valueMin.swizzle(1, 2, 0, 3); break;
294 m_texture->getRefTexture().allocLevel((tcu::CubeFace)face, 0);
295 tcu::fillWithComponentGradients(m_texture->getRefTexture().getLevelFace(0, (tcu::CubeFace)face), gMin, gMax);
298 // Upload texture data to GL.
301 // Initialize iteration state.
306 void TextureCubeFormatCase::deinit (void)
314 bool TextureCubeFormatCase::testFace (tcu::CubeFace face)
316 const glw::Functions& gl = m_renderCtx.getFunctions();
317 TestLog& log = m_testCtx.getLog();
318 RandomViewport viewport (m_renderCtx.getRenderTarget(), m_width, m_height, deStringHash(getName())+(deUint32)face);
319 tcu::Surface renderedFrame (viewport.width, viewport.height);
320 tcu::Surface referenceFrame (viewport.width, viewport.height);
321 tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
322 vector<float> texCoord;
323 ReferenceParams renderParams (TEXTURETYPE_CUBE);
324 tcu::TextureFormatInfo spec = tcu::getTextureFormatInfo(m_texture->getRefTexture().getFormat());
326 renderParams.samplerType = getSamplerType(m_texture->getRefTexture().getFormat());
327 renderParams.sampler = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
328 renderParams.sampler.seamlessCubeMap = false;
329 renderParams.colorScale = spec.lookupScale;
330 renderParams.colorBias = spec.lookupBias;
332 // Log render info on first face.
333 if (face == tcu::CUBEFACE_NEGATIVE_X)
334 renderParams.flags |= RenderParams::LOG_ALL;
336 computeQuadTexCoordCube(texCoord, face);
338 // \todo [2011-10-28 pyry] Image set name / section?
339 log << TestLog::Message << face << TestLog::EndMessage;
341 // Setup base viewport.
342 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
345 gl.activeTexture(GL_TEXTURE0);
346 gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
348 // Setup nearest neighbor filtering and clamp-to-edge.
349 gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
350 gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
351 gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
352 gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
354 GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
356 m_renderer.renderQuad(0, &texCoord[0], renderParams);
357 glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
358 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
360 // Compute reference.
361 sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], renderParams);
364 return compareImages(log, referenceFrame, renderedFrame, threshold);
367 TextureCubeFormatCase::IterateResult TextureCubeFormatCase::iterate (void)
369 // Execute test for all faces.
370 if (!testFace((tcu::CubeFace)m_curFace))
375 if (m_curFace == tcu::CUBEFACE_LAST)
377 m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
378 m_isOk ? "Pass" : "Image comparison failed");
385 TextureFormatTests::TextureFormatTests (Context& context)
386 : TestCaseGroup(context, "format", "Texture Format Tests")
390 TextureFormatTests::~TextureFormatTests (void)
394 // Compressed2DFormatCase
396 class Compressed2DFormatCase : public tcu::TestCase
399 Compressed2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames);
400 ~Compressed2DFormatCase (void);
404 IterateResult iterate (void);
407 Compressed2DFormatCase (const Compressed2DFormatCase& other);
408 Compressed2DFormatCase& operator= (const Compressed2DFormatCase& other);
410 glu::RenderContext& m_renderCtx;
411 const glu::ContextInfo& m_renderCtxInfo;
413 std::vector<std::string> m_filenames;
415 glu::Texture2D* m_texture;
416 TextureRenderer m_renderer;
419 Compressed2DFormatCase::Compressed2DFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames)
420 : TestCase (testCtx, name, description)
421 , m_renderCtx (renderCtx)
422 , m_renderCtxInfo (renderCtxInfo)
423 , m_filenames (filenames)
424 , m_texture (DE_NULL)
425 , m_renderer (renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP)
429 Compressed2DFormatCase::~Compressed2DFormatCase (void)
434 void Compressed2DFormatCase::init (void)
437 m_texture = Texture2D::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(), (int)m_filenames.size(), m_filenames);
440 void Compressed2DFormatCase::deinit (void)
448 Compressed2DFormatCase::IterateResult Compressed2DFormatCase::iterate (void)
450 const glw::Functions& gl = m_renderCtx.getFunctions();
451 TestLog& log = m_testCtx.getLog();
452 RandomViewport viewport (m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getWidth(), m_texture->getRefTexture().getHeight(), deStringHash(getName()));
453 tcu::Surface renderedFrame (viewport.width, viewport.height);
454 tcu::Surface referenceFrame (viewport.width, viewport.height);
455 tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
456 vector<float> texCoord;
458 computeQuadTexCoord2D(texCoord, tcu::Vec2(0.0f, 0.0f), tcu::Vec2(1.0f, 1.0f));
460 // Setup base viewport.
461 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
464 gl.activeTexture(GL_TEXTURE0);
465 gl.bindTexture(GL_TEXTURE_2D, m_texture->getGLTexture());
467 // Setup nearest neighbor filtering and clamp-to-edge.
468 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
469 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
470 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
471 gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
473 GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
476 m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_2D);
477 glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
478 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
480 // Compute reference.
481 ReferenceParams refParams(TEXTURETYPE_2D);
482 refParams.sampler = Sampler(Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
483 sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], refParams);
486 bool isOk = compareImages(log, referenceFrame, renderedFrame, threshold);
488 m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
489 isOk ? "Pass" : "Image comparison failed");
494 // CompressedCubeFormatCase
496 class CompressedCubeFormatCase : public tcu::TestCase
499 CompressedCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames);
500 ~CompressedCubeFormatCase (void);
504 IterateResult iterate (void);
507 CompressedCubeFormatCase (const CompressedCubeFormatCase& other);
508 CompressedCubeFormatCase& operator= (const CompressedCubeFormatCase& other);
510 bool testFace (tcu::CubeFace face);
512 glu::RenderContext& m_renderCtx;
513 const glu::ContextInfo& m_renderCtxInfo;
515 std::vector<std::string> m_filenames;
517 glu::TextureCube* m_texture;
518 TextureRenderer m_renderer;
524 CompressedCubeFormatCase::CompressedCubeFormatCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const glu::ContextInfo& renderCtxInfo, const char* name, const char* description, const std::vector<std::string>& filenames)
525 : TestCase (testCtx, name, description)
526 , m_renderCtx (renderCtx)
527 , m_renderCtxInfo (renderCtxInfo)
528 , m_filenames (filenames)
529 , m_texture (DE_NULL)
530 , m_renderer (renderCtx, testCtx.getLog(), glu::GLSL_VERSION_100_ES, glu::PRECISION_MEDIUMP)
536 CompressedCubeFormatCase::~CompressedCubeFormatCase (void)
541 void CompressedCubeFormatCase::init (void)
544 DE_ASSERT(m_filenames.size() % 6 == 0);
545 m_texture = TextureCube::create(m_renderCtx, m_renderCtxInfo, m_testCtx.getArchive(), (int)m_filenames.size()/6, m_filenames);
551 void CompressedCubeFormatCase::deinit (void)
559 bool CompressedCubeFormatCase::testFace (tcu::CubeFace face)
561 const glw::Functions& gl = m_renderCtx.getFunctions();
562 TestLog& log = m_testCtx.getLog();
563 RandomViewport viewport (m_renderCtx.getRenderTarget(), m_texture->getRefTexture().getSize(), m_texture->getRefTexture().getSize(), deStringHash(getName())+(deUint32)face);
564 tcu::Surface renderedFrame (viewport.width, viewport.height);
565 tcu::Surface referenceFrame (viewport.width, viewport.height);
566 Sampler sampler (Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE, Sampler::NEAREST, Sampler::NEAREST);
567 tcu::RGBA threshold = m_renderCtx.getRenderTarget().getPixelFormat().getColorThreshold() + tcu::RGBA(1,1,1,1);
568 vector<float> texCoord;
570 computeQuadTexCoordCube(texCoord, face);
572 // \todo [2011-10-28 pyry] Image set name / section?
573 log << TestLog::Message << face << TestLog::EndMessage;
575 // Setup base viewport.
576 gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
579 gl.activeTexture(GL_TEXTURE0);
580 gl.bindTexture(GL_TEXTURE_CUBE_MAP, m_texture->getGLTexture());
582 // Setup nearest neighbor filtering and clamp-to-edge.
583 gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
584 gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
585 gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
586 gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
588 GLU_EXPECT_NO_ERROR(gl.getError(), "Set texturing state");
590 m_renderer.renderQuad(0, &texCoord[0], TEXTURETYPE_CUBE);
591 glu::readPixels(m_renderCtx, viewport.x, viewport.y, renderedFrame.getAccess());
592 GLU_EXPECT_NO_ERROR(gl.getError(), "glReadPixels()");
594 // Compute reference.
595 sampleTexture(tcu::SurfaceAccess(referenceFrame, m_renderCtx.getRenderTarget().getPixelFormat()), m_texture->getRefTexture(), &texCoord[0], ReferenceParams(TEXTURETYPE_CUBE, sampler));
598 return compareImages(log, referenceFrame, renderedFrame, threshold);
601 CompressedCubeFormatCase::IterateResult CompressedCubeFormatCase::iterate (void)
603 // Execute test for all faces.
604 if (!testFace((tcu::CubeFace)m_curFace))
609 if (m_curFace == tcu::CUBEFACE_LAST)
611 m_testCtx.setTestResult(m_isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
612 m_isOk ? "Pass" : "Image comparison failed");
619 vector<string> toStringVector (const char* const* str, int numStr)
623 for (int i = 0; i < numStr; i++)
628 void TextureFormatTests::init (void)
637 { "a8", GL_ALPHA, GL_UNSIGNED_BYTE },
638 { "l8", GL_LUMINANCE, GL_UNSIGNED_BYTE },
639 { "la88", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
640 { "rgb565", GL_RGB, GL_UNSIGNED_SHORT_5_6_5 },
641 { "rgb888", GL_RGB, GL_UNSIGNED_BYTE },
642 { "rgba4444", GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 },
643 { "rgba5551", GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 },
644 { "rgba8888", GL_RGBA, GL_UNSIGNED_BYTE }
647 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
649 deUint32 format = texFormats[formatNdx].format;
650 deUint32 dataType = texFormats[formatNdx].dataType;
651 string nameBase = texFormats[formatNdx].name;
652 string descriptionBase = string(glu::getTextureFormatName(format)) + ", " + glu::getTypeName(dataType);
654 addChild(new Texture2DFormatCase (m_testCtx, m_context.getRenderContext(), (nameBase + "_2d_pot").c_str(), (descriptionBase + ", GL_TEXTURE_2D").c_str(), format, dataType, 128, 128));
655 addChild(new Texture2DFormatCase (m_testCtx, m_context.getRenderContext(), (nameBase + "_2d_npot").c_str(), (descriptionBase + ", GL_TEXTURE_2D").c_str(), format, dataType, 63, 112));
656 addChild(new TextureCubeFormatCase (m_testCtx, m_context.getRenderContext(), (nameBase + "_cube_pot").c_str(), (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(), format, dataType, 64, 64));
657 addChild(new TextureCubeFormatCase (m_testCtx, m_context.getRenderContext(), (nameBase + "_cube_npot").c_str(), (descriptionBase + ", GL_TEXTURE_CUBE_MAP").c_str(), format, dataType, 57, 57));
660 // ETC-1 compressed formats.
662 static const char* filenames[] =
664 "data/etc1/photo_helsinki_mip_0.pkm",
665 "data/etc1/photo_helsinki_mip_1.pkm",
666 "data/etc1/photo_helsinki_mip_2.pkm",
667 "data/etc1/photo_helsinki_mip_3.pkm",
668 "data/etc1/photo_helsinki_mip_4.pkm",
669 "data/etc1/photo_helsinki_mip_5.pkm",
670 "data/etc1/photo_helsinki_mip_6.pkm",
671 "data/etc1/photo_helsinki_mip_7.pkm"
673 addChild(new Compressed2DFormatCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_2d_pot", "GL_ETC1_RGB8_OES, GL_TEXTURE_2D", toStringVector(filenames, DE_LENGTH_OF_ARRAY(filenames))));
677 vector<string> filenames;
678 filenames.push_back("data/etc1/photo_helsinki_113x89.pkm");
679 addChild(new Compressed2DFormatCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_2d_npot", "GL_ETC1_RGB8_OES, GL_TEXTURE_2D", filenames));
683 static const char* faceExt[] = { "neg_x", "pos_x", "neg_y", "pos_y", "neg_z", "pos_z" };
685 const int potNumLevels = 7;
686 vector<string> potFilenames;
687 for (int level = 0; level < potNumLevels; level++)
688 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
689 potFilenames.push_back(string("data/etc1/skybox_") + faceExt[face] + "_mip_" + de::toString(level) + ".pkm");
691 addChild(new CompressedCubeFormatCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_cube_pot", "GL_ETC1_RGB8_OES, GL_TEXTURE_CUBE_MAP", potFilenames));
693 vector<string> npotFilenames;
694 for (int face = 0; face < tcu::CUBEFACE_LAST; face++)
695 npotFilenames.push_back(string("data/etc1/skybox_61x61_") + faceExt[face] + ".pkm");
697 addChild(new CompressedCubeFormatCase(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo(), "etc1_cube_npot", "GL_ETC_RGB8_OES, GL_TEXTURE_CUBE_MAP", npotFilenames));