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 Compressed texture tests
22 *//*--------------------------------------------------------------------*/
23
24#include "es3fCompressedTextureTests.hpp"
25#include "es3fASTCDecompressionCases.hpp"
26#include "gluStrUtil.hpp"
27#include "gluTextureUtil.hpp"
28#include "tcuCompressedTexture.hpp"
29#include "tcuVector.hpp"
30#include "deStringUtil.hpp"
31
32#include <string>
33
34using std::string;
35using tcu::IVec3;
36using tcu::CompressedTexture;
37
38namespace deqp
39{
40namespace gles3
41{
42namespace Functional
43{
44
45static const string getASTCFormatShortName (CompressedTexture::Format format)
46{
47	DE_ASSERT(tcu::isASTCFormat(format));
48	const IVec3 blockSize = tcu::getASTCBlockSize(format);
49	DE_ASSERT(blockSize.z() == 1);
50
51	return de::toString(blockSize.x()) + "x" + de::toString(blockSize.y()) + (tcu::isASTCSRGBFormat(format) ? "_srgb" : "");
52}
53
54CompressedTextureTests::CompressedTextureTests (Context& context)
55	: TestCaseGroup (context, "compressed", "Compressed Texture Tests")
56{
57}
58
59CompressedTextureTests::~CompressedTextureTests (void)
60{
61}
62
63void CompressedTextureTests::init (void)
64{
65	// ASTC cases.
66	{
67		TestCaseGroup* const astcGroup = new TestCaseGroup(m_context, "astc", "ASTC Tests");
68		addChild(astcGroup);
69
70		// Block test cases.
71
72		for (int astcTestTypeI = 0; astcTestTypeI < ASTCBLOCKTESTTYPE_LAST; astcTestTypeI++)
73		{
74			const ASTCBlockTestType		astcTestType	= (ASTCBlockTestType)astcTestTypeI;
75			TestCaseGroup* const		testTypeGroup	= new TestCaseGroup(m_context, getBlockTestTypeName(astcTestType), getBlockTestTypeDescription(astcTestType));
76			astcGroup->addChild(testTypeGroup);
77
78			for (int formatI = 0; formatI < CompressedTexture::FORMAT_LAST; formatI++)
79			{
80				const CompressedTexture::Format format = (CompressedTexture::Format)formatI;
81
82				if (!tcu::isASTCFormat(format))
83					continue;
84				if (tcu::isASTCSRGBFormat(format) && isBlockTestTypeHDROnly(astcTestType))
85					continue;
86
87				testTypeGroup->addChild(new ASTCBlockCase2D(m_context, getASTCFormatShortName(format).c_str(), glu::getCompressedTexFormatName(glu::getGLFormat(format)), astcTestType, format));
88			}
89		}
90
91		// Image size/block size remainder cases.
92
93		{
94			TestCaseGroup* const blockSizeRemainderGroup = new TestCaseGroup(m_context, "block_size_remainder", "Test image size/block size remainders");
95			astcGroup->addChild(blockSizeRemainderGroup);
96
97			for (int formatI = 0; formatI < CompressedTexture::FORMAT_LAST; formatI++)
98			{
99				const CompressedTexture::Format format = (CompressedTexture::Format)formatI;
100
101				if (!tcu::isASTCFormat(format))
102					continue;
103
104				blockSizeRemainderGroup->addChild(new ASTCBlockSizeRemainderCase2D(m_context, getASTCFormatShortName(format).c_str(), glu::getCompressedTexFormatName(glu::getGLFormat(format)), format));
105			}
106		}
107	}
108}
109
110} // Functional
111} // gles3
112} // deqp
113