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
34 using std::string;
35 using tcu::CompressedTexFormat;
36 using tcu::CompressedTexture;
37 using tcu::IVec3;
38
39 namespace deqp
40 {
41 namespace gles3
42 {
43 namespace Functional
44 {
45
getASTCFormatShortName(CompressedTexFormat format)46 static const string getASTCFormatShortName(CompressedTexFormat format)
47 {
48 DE_ASSERT(tcu::isAstcFormat(format));
49 const IVec3 blockSize = tcu::getBlockPixelSize(format);
50 DE_ASSERT(blockSize.z() == 1);
51
52 return de::toString(blockSize.x()) + "x" + de::toString(blockSize.y()) +
53 (tcu::isAstcSRGBFormat(format) ? "_srgb" : "");
54 }
55
CompressedTextureTests(Context & context)56 CompressedTextureTests::CompressedTextureTests(Context &context)
57 : TestCaseGroup(context, "compressed", "Compressed Texture Tests")
58 {
59 }
60
~CompressedTextureTests(void)61 CompressedTextureTests::~CompressedTextureTests(void)
62 {
63 }
64
init(void)65 void CompressedTextureTests::init(void)
66 {
67 // ASTC cases.
68 {
69 TestCaseGroup *const astcGroup = new TestCaseGroup(m_context, "astc", "ASTC Tests");
70 addChild(astcGroup);
71
72 // Block test cases.
73
74 for (int astcTestTypeI = 0; astcTestTypeI < tcu::astc::BLOCK_TEST_TYPE_LAST; astcTestTypeI++)
75 {
76 const tcu::astc::BlockTestType astcTestType = (tcu::astc::BlockTestType)astcTestTypeI;
77 TestCaseGroup *const testTypeGroup = new TestCaseGroup(m_context, getBlockTestTypeName(astcTestType),
78 getBlockTestTypeDescription(astcTestType));
79 astcGroup->addChild(testTypeGroup);
80
81 for (int formatI = 0; formatI < tcu::COMPRESSEDTEXFORMAT_LAST; formatI++)
82 {
83 const CompressedTexFormat format = (CompressedTexFormat)formatI;
84
85 if (!tcu::isAstcFormat(format))
86 continue;
87 if (tcu::isAstcSRGBFormat(format) && tcu::astc::isBlockTestTypeHDROnly(astcTestType))
88 continue;
89
90 testTypeGroup->addChild(new ASTCBlockCase2D(
91 m_context, getASTCFormatShortName(format).c_str(),
92 glu::getCompressedTextureFormatName(glu::getGLFormat(format)), astcTestType, format));
93 }
94 }
95
96 // Image size/block size remainder cases.
97
98 {
99 TestCaseGroup *const blockSizeRemainderGroup =
100 new TestCaseGroup(m_context, "block_size_remainder", "Test image size/block size remainders");
101 astcGroup->addChild(blockSizeRemainderGroup);
102
103 for (int formatI = 0; formatI < tcu::COMPRESSEDTEXFORMAT_LAST; formatI++)
104 {
105 const CompressedTexFormat format = (CompressedTexFormat)formatI;
106
107 if (!tcu::isAstcFormat(format))
108 continue;
109
110 blockSizeRemainderGroup->addChild(new ASTCBlockSizeRemainderCase2D(
111 m_context, getASTCFormatShortName(format).c_str(),
112 glu::getCompressedTextureFormatName(glu::getGLFormat(format)), format));
113 }
114 }
115 }
116 }
117
118 } // namespace Functional
119 } // namespace gles3
120 } // namespace deqp
121