xref: /aosp_15_r20/external/deqp/modules/internal/ditFrameworkTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Internal Test Module
3*35238bceSAndroid Build Coastguard Worker  * ---------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Miscellaneous framework tests.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "ditFrameworkTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "ditTextureFormatTests.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "ditAstcTests.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "ditVulkanTests.hpp"
28*35238bceSAndroid Build Coastguard Worker 
29*35238bceSAndroid Build Coastguard Worker #include "tcuFloatFormat.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuEither.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
33*35238bceSAndroid Build Coastguard Worker 
34*35238bceSAndroid Build Coastguard Worker #include "rrRenderer.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "tcuVectorUtil.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "tcuFloat.hpp"
38*35238bceSAndroid Build Coastguard Worker 
39*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "deArrayUtil.hpp"
41*35238bceSAndroid Build Coastguard Worker 
42*35238bceSAndroid Build Coastguard Worker #include <stdexcept>
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker namespace dit
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker 
47*35238bceSAndroid Build Coastguard Worker namespace
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker 
50*35238bceSAndroid Build Coastguard Worker using std::string;
51*35238bceSAndroid Build Coastguard Worker using std::vector;
52*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
53*35238bceSAndroid Build Coastguard Worker 
54*35238bceSAndroid Build Coastguard Worker struct MatchCase
55*35238bceSAndroid Build Coastguard Worker {
56*35238bceSAndroid Build Coastguard Worker     enum Expected
57*35238bceSAndroid Build Coastguard Worker     {
58*35238bceSAndroid Build Coastguard Worker         NO_MATCH,
59*35238bceSAndroid Build Coastguard Worker         MATCH_GROUP,
60*35238bceSAndroid Build Coastguard Worker         MATCH_CASE,
61*35238bceSAndroid Build Coastguard Worker         EXPECTED_LAST
62*35238bceSAndroid Build Coastguard Worker     };
63*35238bceSAndroid Build Coastguard Worker 
64*35238bceSAndroid Build Coastguard Worker     const char *path;
65*35238bceSAndroid Build Coastguard Worker     Expected expected;
66*35238bceSAndroid Build Coastguard Worker };
67*35238bceSAndroid Build Coastguard Worker 
getMatchCaseExpectedDesc(MatchCase::Expected expected)68*35238bceSAndroid Build Coastguard Worker const char *getMatchCaseExpectedDesc(MatchCase::Expected expected)
69*35238bceSAndroid Build Coastguard Worker {
70*35238bceSAndroid Build Coastguard Worker     static const char *descs[] = {"no match", "group to match", "case to match"};
71*35238bceSAndroid Build Coastguard Worker     return de::getSizedArrayElement<MatchCase::EXPECTED_LAST>(descs, expected);
72*35238bceSAndroid Build Coastguard Worker }
73*35238bceSAndroid Build Coastguard Worker 
74*35238bceSAndroid Build Coastguard Worker class CaseListParserCase : public tcu::TestCase
75*35238bceSAndroid Build Coastguard Worker {
76*35238bceSAndroid Build Coastguard Worker public:
CaseListParserCase(tcu::TestContext & testCtx,const char * name,const char * caseList,const MatchCase * subCases,int numSubCases)77*35238bceSAndroid Build Coastguard Worker     CaseListParserCase(tcu::TestContext &testCtx, const char *name, const char *caseList, const MatchCase *subCases,
78*35238bceSAndroid Build Coastguard Worker                        int numSubCases)
79*35238bceSAndroid Build Coastguard Worker         : tcu::TestCase(testCtx, name, "")
80*35238bceSAndroid Build Coastguard Worker         , m_caseList(caseList)
81*35238bceSAndroid Build Coastguard Worker         , m_subCases(subCases)
82*35238bceSAndroid Build Coastguard Worker         , m_numSubCases(numSubCases)
83*35238bceSAndroid Build Coastguard Worker     {
84*35238bceSAndroid Build Coastguard Worker     }
85*35238bceSAndroid Build Coastguard Worker 
iterate(void)86*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
87*35238bceSAndroid Build Coastguard Worker     {
88*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
89*35238bceSAndroid Build Coastguard Worker         tcu::CommandLine cmdLine;
90*35238bceSAndroid Build Coastguard Worker         de::MovePtr<tcu::CaseListFilter> caseListFilter;
91*35238bceSAndroid Build Coastguard Worker         int numPass = 0;
92*35238bceSAndroid Build Coastguard Worker 
93*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Input:\n\"" << m_caseList << "\"" << TestLog::EndMessage;
94*35238bceSAndroid Build Coastguard Worker 
95*35238bceSAndroid Build Coastguard Worker         {
96*35238bceSAndroid Build Coastguard Worker             const char *argv[] = {"deqp", "--deqp-caselist", m_caseList};
97*35238bceSAndroid Build Coastguard Worker 
98*35238bceSAndroid Build Coastguard Worker             if (!cmdLine.parse(DE_LENGTH_OF_ARRAY(argv), argv))
99*35238bceSAndroid Build Coastguard Worker                 TCU_FAIL("Failed to parse command line");
100*35238bceSAndroid Build Coastguard Worker         }
101*35238bceSAndroid Build Coastguard Worker 
102*35238bceSAndroid Build Coastguard Worker         caseListFilter = cmdLine.createCaseListFilter(m_testCtx.getArchive());
103*35238bceSAndroid Build Coastguard Worker 
104*35238bceSAndroid Build Coastguard Worker         for (int subCaseNdx = 0; subCaseNdx < m_numSubCases; subCaseNdx++)
105*35238bceSAndroid Build Coastguard Worker         {
106*35238bceSAndroid Build Coastguard Worker             const MatchCase &curCase = m_subCases[subCaseNdx];
107*35238bceSAndroid Build Coastguard Worker             bool matchGroup;
108*35238bceSAndroid Build Coastguard Worker             bool matchCase;
109*35238bceSAndroid Build Coastguard Worker 
110*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Checking \"" << curCase.path << "\""
111*35238bceSAndroid Build Coastguard Worker                 << ", expecting " << getMatchCaseExpectedDesc(curCase.expected) << TestLog::EndMessage;
112*35238bceSAndroid Build Coastguard Worker 
113*35238bceSAndroid Build Coastguard Worker             matchGroup = caseListFilter->checkTestGroupName(curCase.path);
114*35238bceSAndroid Build Coastguard Worker             matchCase  = caseListFilter->checkTestCaseName(curCase.path);
115*35238bceSAndroid Build Coastguard Worker 
116*35238bceSAndroid Build Coastguard Worker             if ((matchGroup == (curCase.expected == MatchCase::MATCH_GROUP)) &&
117*35238bceSAndroid Build Coastguard Worker                 (matchCase == (curCase.expected == MatchCase::MATCH_CASE)))
118*35238bceSAndroid Build Coastguard Worker             {
119*35238bceSAndroid Build Coastguard Worker                 log << TestLog::Message << "   pass" << TestLog::EndMessage;
120*35238bceSAndroid Build Coastguard Worker                 numPass += 1;
121*35238bceSAndroid Build Coastguard Worker             }
122*35238bceSAndroid Build Coastguard Worker             else
123*35238bceSAndroid Build Coastguard Worker                 log << TestLog::Message << "   FAIL!" << TestLog::EndMessage;
124*35238bceSAndroid Build Coastguard Worker         }
125*35238bceSAndroid Build Coastguard Worker 
126*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult((numPass == m_numSubCases) ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
127*35238bceSAndroid Build Coastguard Worker                                 (numPass == m_numSubCases) ? "All passed" : "Unexpected match result");
128*35238bceSAndroid Build Coastguard Worker 
129*35238bceSAndroid Build Coastguard Worker         return STOP;
130*35238bceSAndroid Build Coastguard Worker     }
131*35238bceSAndroid Build Coastguard Worker 
132*35238bceSAndroid Build Coastguard Worker private:
133*35238bceSAndroid Build Coastguard Worker     const char *const m_caseList;
134*35238bceSAndroid Build Coastguard Worker     const MatchCase *const m_subCases;
135*35238bceSAndroid Build Coastguard Worker     const int m_numSubCases;
136*35238bceSAndroid Build Coastguard Worker };
137*35238bceSAndroid Build Coastguard Worker 
138*35238bceSAndroid Build Coastguard Worker class NegativeCaseListCase : public tcu::TestCase
139*35238bceSAndroid Build Coastguard Worker {
140*35238bceSAndroid Build Coastguard Worker public:
NegativeCaseListCase(tcu::TestContext & testCtx,const char * name,const char * caseList)141*35238bceSAndroid Build Coastguard Worker     NegativeCaseListCase(tcu::TestContext &testCtx, const char *name, const char *caseList)
142*35238bceSAndroid Build Coastguard Worker         : tcu::TestCase(testCtx, name, "")
143*35238bceSAndroid Build Coastguard Worker         , m_caseList(caseList)
144*35238bceSAndroid Build Coastguard Worker     {
145*35238bceSAndroid Build Coastguard Worker     }
146*35238bceSAndroid Build Coastguard Worker 
iterate(void)147*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
148*35238bceSAndroid Build Coastguard Worker     {
149*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
150*35238bceSAndroid Build Coastguard Worker         tcu::CommandLine cmdLine;
151*35238bceSAndroid Build Coastguard Worker 
152*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Input:\n\"" << m_caseList << "\"" << TestLog::EndMessage;
153*35238bceSAndroid Build Coastguard Worker 
154*35238bceSAndroid Build Coastguard Worker         {
155*35238bceSAndroid Build Coastguard Worker             const char *argv[] = {"deqp", "--deqp-caselist", m_caseList};
156*35238bceSAndroid Build Coastguard Worker 
157*35238bceSAndroid Build Coastguard Worker             TCU_CHECK(cmdLine.parse(DE_LENGTH_OF_ARRAY(argv), argv));
158*35238bceSAndroid Build Coastguard Worker 
159*35238bceSAndroid Build Coastguard Worker             try
160*35238bceSAndroid Build Coastguard Worker             {
161*35238bceSAndroid Build Coastguard Worker                 de::UniquePtr<tcu::CaseListFilter> filter(cmdLine.createCaseListFilter(m_testCtx.getArchive()));
162*35238bceSAndroid Build Coastguard Worker 
163*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Parsing passed, should have failed");
164*35238bceSAndroid Build Coastguard Worker             }
165*35238bceSAndroid Build Coastguard Worker             catch (const std::invalid_argument &e)
166*35238bceSAndroid Build Coastguard Worker             {
167*35238bceSAndroid Build Coastguard Worker                 log << TestLog::Message << e.what() << TestLog::EndMessage;
168*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Parsing failed as expected");
169*35238bceSAndroid Build Coastguard Worker             }
170*35238bceSAndroid Build Coastguard Worker         }
171*35238bceSAndroid Build Coastguard Worker 
172*35238bceSAndroid Build Coastguard Worker         return STOP;
173*35238bceSAndroid Build Coastguard Worker     }
174*35238bceSAndroid Build Coastguard Worker 
175*35238bceSAndroid Build Coastguard Worker private:
176*35238bceSAndroid Build Coastguard Worker     const char *const m_caseList;
177*35238bceSAndroid Build Coastguard Worker };
178*35238bceSAndroid Build Coastguard Worker 
179*35238bceSAndroid Build Coastguard Worker class TrieParserTests : public tcu::TestCaseGroup
180*35238bceSAndroid Build Coastguard Worker {
181*35238bceSAndroid Build Coastguard Worker public:
TrieParserTests(tcu::TestContext & testCtx)182*35238bceSAndroid Build Coastguard Worker     TrieParserTests(tcu::TestContext &testCtx) : tcu::TestCaseGroup(testCtx, "trie", "Test case trie parser tests")
183*35238bceSAndroid Build Coastguard Worker     {
184*35238bceSAndroid Build Coastguard Worker     }
185*35238bceSAndroid Build Coastguard Worker 
init(void)186*35238bceSAndroid Build Coastguard Worker     void init(void)
187*35238bceSAndroid Build Coastguard Worker     {
188*35238bceSAndroid Build Coastguard Worker         {
189*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "{test}";
190*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
191*35238bceSAndroid Build Coastguard Worker                 {"test", MatchCase::MATCH_CASE},
192*35238bceSAndroid Build Coastguard Worker                 {"test.cd", MatchCase::NO_MATCH},
193*35238bceSAndroid Build Coastguard Worker             };
194*35238bceSAndroid Build Coastguard Worker             addChild(
195*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "single_case", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
196*35238bceSAndroid Build Coastguard Worker         }
197*35238bceSAndroid Build Coastguard Worker         {
198*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "{a{b}}";
199*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
200*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP},
201*35238bceSAndroid Build Coastguard Worker                 {"b", MatchCase::NO_MATCH},
202*35238bceSAndroid Build Coastguard Worker                 {"a.b", MatchCase::MATCH_CASE},
203*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},
204*35238bceSAndroid Build Coastguard Worker             };
205*35238bceSAndroid Build Coastguard Worker             addChild(
206*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "simple_group_1", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
207*35238bceSAndroid Build Coastguard Worker         }
208*35238bceSAndroid Build Coastguard Worker         {
209*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "{a{b,c}}";
210*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
211*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP}, {"b", MatchCase::NO_MATCH},     {"a.b", MatchCase::MATCH_CASE},
212*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},  {"a.c", MatchCase::MATCH_CASE},
213*35238bceSAndroid Build Coastguard Worker             };
214*35238bceSAndroid Build Coastguard Worker             addChild(
215*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "simple_group_2", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
216*35238bceSAndroid Build Coastguard Worker         }
217*35238bceSAndroid Build Coastguard Worker         {
218*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "{a{b},c{d,e}}";
219*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
220*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP},  {"b", MatchCase::NO_MATCH},   {"a.b", MatchCase::MATCH_CASE},
221*35238bceSAndroid Build Coastguard Worker                 {"a.c", MatchCase::NO_MATCH},   {"a.d", MatchCase::NO_MATCH}, {"a.e", MatchCase::NO_MATCH},
222*35238bceSAndroid Build Coastguard Worker                 {"c", MatchCase::MATCH_GROUP},  {"c.b", MatchCase::NO_MATCH}, {"c.d", MatchCase::MATCH_CASE},
223*35238bceSAndroid Build Coastguard Worker                 {"c.e", MatchCase::MATCH_CASE},
224*35238bceSAndroid Build Coastguard Worker             };
225*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "two_groups", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
226*35238bceSAndroid Build Coastguard Worker         }
227*35238bceSAndroid Build Coastguard Worker         {
228*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "{a,c{d,e}}";
229*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
230*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_CASE},   {"b", MatchCase::NO_MATCH},   {"a.b", MatchCase::NO_MATCH},
231*35238bceSAndroid Build Coastguard Worker                 {"a.c", MatchCase::NO_MATCH},   {"a.d", MatchCase::NO_MATCH}, {"a.e", MatchCase::NO_MATCH},
232*35238bceSAndroid Build Coastguard Worker                 {"c", MatchCase::MATCH_GROUP},  {"c.b", MatchCase::NO_MATCH}, {"c.d", MatchCase::MATCH_CASE},
233*35238bceSAndroid Build Coastguard Worker                 {"c.e", MatchCase::MATCH_CASE},
234*35238bceSAndroid Build Coastguard Worker             };
235*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "case_group", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
236*35238bceSAndroid Build Coastguard Worker         }
237*35238bceSAndroid Build Coastguard Worker         {
238*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "{c{d,e},a}";
239*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
240*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_CASE},   {"b", MatchCase::NO_MATCH},   {"a.b", MatchCase::NO_MATCH},
241*35238bceSAndroid Build Coastguard Worker                 {"a.c", MatchCase::NO_MATCH},   {"a.d", MatchCase::NO_MATCH}, {"a.e", MatchCase::NO_MATCH},
242*35238bceSAndroid Build Coastguard Worker                 {"c", MatchCase::MATCH_GROUP},  {"c.b", MatchCase::NO_MATCH}, {"c.d", MatchCase::MATCH_CASE},
243*35238bceSAndroid Build Coastguard Worker                 {"c.e", MatchCase::MATCH_CASE},
244*35238bceSAndroid Build Coastguard Worker             };
245*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "group_case", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
246*35238bceSAndroid Build Coastguard Worker         }
247*35238bceSAndroid Build Coastguard Worker         {
248*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "{test}\r";
249*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
250*35238bceSAndroid Build Coastguard Worker                 {"test", MatchCase::MATCH_CASE},
251*35238bceSAndroid Build Coastguard Worker                 {"test.cd", MatchCase::NO_MATCH},
252*35238bceSAndroid Build Coastguard Worker             };
253*35238bceSAndroid Build Coastguard Worker             addChild(
254*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "trailing_cr", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
255*35238bceSAndroid Build Coastguard Worker         }
256*35238bceSAndroid Build Coastguard Worker         {
257*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "{test}\n";
258*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
259*35238bceSAndroid Build Coastguard Worker                 {"test", MatchCase::MATCH_CASE},
260*35238bceSAndroid Build Coastguard Worker                 {"test.cd", MatchCase::NO_MATCH},
261*35238bceSAndroid Build Coastguard Worker             };
262*35238bceSAndroid Build Coastguard Worker             addChild(
263*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "trailing_lf", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
264*35238bceSAndroid Build Coastguard Worker         }
265*35238bceSAndroid Build Coastguard Worker         {
266*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "{test}\r\n";
267*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
268*35238bceSAndroid Build Coastguard Worker                 {"test", MatchCase::MATCH_CASE},
269*35238bceSAndroid Build Coastguard Worker                 {"test.cd", MatchCase::NO_MATCH},
270*35238bceSAndroid Build Coastguard Worker             };
271*35238bceSAndroid Build Coastguard Worker             addChild(
272*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "trailing_crlf", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
273*35238bceSAndroid Build Coastguard Worker         }
274*35238bceSAndroid Build Coastguard Worker 
275*35238bceSAndroid Build Coastguard Worker         // Negative tests
276*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_string", ""));
277*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_line", "\n"));
278*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_root", "{}"));
279*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_group", "{test{}}"));
280*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_group_name_1", "{{}}"));
281*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_group_name_2", "{{test}}"));
282*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "unterminated_root_1", "{"));
283*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "unterminated_root_2", "{test"));
284*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "unterminated_root_3", "{test,"));
285*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "unterminated_root_4", "{test{a}"));
286*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "unterminated_root_5", "{a,b"));
287*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "unterminated_group_1", "{test{"));
288*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "unterminated_group_2", "{test{a"));
289*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "unterminated_group_3", "{test{a,"));
290*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "unterminated_group_4", "{test{a,b"));
291*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_case_name_1", "{a,,b}"));
292*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_case_name_2", "{,b}"));
293*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_case_name_3", "{a,}"));
294*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "no_separator", "{a{b}c}"));
295*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "invalid_char_1", "{a.b}"));
296*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "invalid_char_2", "{a[]}"));
297*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "trailing_char_1", "{a}}"));
298*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "trailing_char_2", "{a}x"));
299*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "embedded_newline_1", "{\na}"));
300*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "embedded_newline_2", "{a\n,b}"));
301*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "embedded_newline_3", "{a,\nb}"));
302*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "embedded_newline_4", "{a{b\n}}"));
303*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "embedded_newline_5", "{a{b}\n}"));
304*35238bceSAndroid Build Coastguard Worker     }
305*35238bceSAndroid Build Coastguard Worker };
306*35238bceSAndroid Build Coastguard Worker 
307*35238bceSAndroid Build Coastguard Worker class ListParserTests : public tcu::TestCaseGroup
308*35238bceSAndroid Build Coastguard Worker {
309*35238bceSAndroid Build Coastguard Worker public:
ListParserTests(tcu::TestContext & testCtx)310*35238bceSAndroid Build Coastguard Worker     ListParserTests(tcu::TestContext &testCtx) : tcu::TestCaseGroup(testCtx, "list", "Test case list parser tests")
311*35238bceSAndroid Build Coastguard Worker     {
312*35238bceSAndroid Build Coastguard Worker     }
313*35238bceSAndroid Build Coastguard Worker 
init(void)314*35238bceSAndroid Build Coastguard Worker     void init(void)
315*35238bceSAndroid Build Coastguard Worker     {
316*35238bceSAndroid Build Coastguard Worker         {
317*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "test";
318*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
319*35238bceSAndroid Build Coastguard Worker                 {"test", MatchCase::MATCH_CASE},
320*35238bceSAndroid Build Coastguard Worker                 {"test.cd", MatchCase::NO_MATCH},
321*35238bceSAndroid Build Coastguard Worker             };
322*35238bceSAndroid Build Coastguard Worker             addChild(
323*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "single_case", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
324*35238bceSAndroid Build Coastguard Worker         }
325*35238bceSAndroid Build Coastguard Worker         {
326*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b";
327*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
328*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP},
329*35238bceSAndroid Build Coastguard Worker                 {"b", MatchCase::NO_MATCH},
330*35238bceSAndroid Build Coastguard Worker                 {"a.b", MatchCase::MATCH_CASE},
331*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},
332*35238bceSAndroid Build Coastguard Worker             };
333*35238bceSAndroid Build Coastguard Worker             addChild(
334*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "simple_group_1", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
335*35238bceSAndroid Build Coastguard Worker         }
336*35238bceSAndroid Build Coastguard Worker         {
337*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b\na.c";
338*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
339*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP}, {"b", MatchCase::NO_MATCH},     {"a.b", MatchCase::MATCH_CASE},
340*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},  {"a.c", MatchCase::MATCH_CASE},
341*35238bceSAndroid Build Coastguard Worker             };
342*35238bceSAndroid Build Coastguard Worker             addChild(
343*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "simple_group_2", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
344*35238bceSAndroid Build Coastguard Worker         }
345*35238bceSAndroid Build Coastguard Worker         {
346*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b\na.c";
347*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
348*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP}, {"b", MatchCase::NO_MATCH},     {"a.b", MatchCase::MATCH_CASE},
349*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},  {"a.c", MatchCase::MATCH_CASE},
350*35238bceSAndroid Build Coastguard Worker             };
351*35238bceSAndroid Build Coastguard Worker             addChild(
352*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "separator_ln", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
353*35238bceSAndroid Build Coastguard Worker         }
354*35238bceSAndroid Build Coastguard Worker         {
355*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b\ra.c";
356*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
357*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP}, {"b", MatchCase::NO_MATCH},     {"a.b", MatchCase::MATCH_CASE},
358*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},  {"a.c", MatchCase::MATCH_CASE},
359*35238bceSAndroid Build Coastguard Worker             };
360*35238bceSAndroid Build Coastguard Worker             addChild(
361*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "separator_cr", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
362*35238bceSAndroid Build Coastguard Worker         }
363*35238bceSAndroid Build Coastguard Worker         {
364*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b\r\na.c";
365*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
366*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP}, {"b", MatchCase::NO_MATCH},     {"a.b", MatchCase::MATCH_CASE},
367*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},  {"a.c", MatchCase::MATCH_CASE},
368*35238bceSAndroid Build Coastguard Worker             };
369*35238bceSAndroid Build Coastguard Worker             addChild(
370*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "separator_crlf", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
371*35238bceSAndroid Build Coastguard Worker         }
372*35238bceSAndroid Build Coastguard Worker         {
373*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b\na.c\n";
374*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
375*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP}, {"b", MatchCase::NO_MATCH},     {"a.b", MatchCase::MATCH_CASE},
376*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},  {"a.c", MatchCase::MATCH_CASE},
377*35238bceSAndroid Build Coastguard Worker             };
378*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "end_ln", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
379*35238bceSAndroid Build Coastguard Worker         }
380*35238bceSAndroid Build Coastguard Worker         {
381*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b\na.c\r";
382*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
383*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP}, {"b", MatchCase::NO_MATCH},     {"a.b", MatchCase::MATCH_CASE},
384*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},  {"a.c", MatchCase::MATCH_CASE},
385*35238bceSAndroid Build Coastguard Worker             };
386*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "end_cr", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
387*35238bceSAndroid Build Coastguard Worker         }
388*35238bceSAndroid Build Coastguard Worker         {
389*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b\na.c\r\n";
390*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
391*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP}, {"b", MatchCase::NO_MATCH},     {"a.b", MatchCase::MATCH_CASE},
392*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::NO_MATCH},  {"a.c", MatchCase::MATCH_CASE},
393*35238bceSAndroid Build Coastguard Worker             };
394*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "end_crlf", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
395*35238bceSAndroid Build Coastguard Worker         }
396*35238bceSAndroid Build Coastguard Worker         {
397*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b\nc.d\nc.e";
398*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
399*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP},  {"b", MatchCase::NO_MATCH},   {"a.b", MatchCase::MATCH_CASE},
400*35238bceSAndroid Build Coastguard Worker                 {"a.c", MatchCase::NO_MATCH},   {"a.d", MatchCase::NO_MATCH}, {"a.e", MatchCase::NO_MATCH},
401*35238bceSAndroid Build Coastguard Worker                 {"c", MatchCase::MATCH_GROUP},  {"c.b", MatchCase::NO_MATCH}, {"c.d", MatchCase::MATCH_CASE},
402*35238bceSAndroid Build Coastguard Worker                 {"c.e", MatchCase::MATCH_CASE},
403*35238bceSAndroid Build Coastguard Worker             };
404*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "two_groups", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
405*35238bceSAndroid Build Coastguard Worker         }
406*35238bceSAndroid Build Coastguard Worker         {
407*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a\nc.d\nc.e";
408*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
409*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_CASE},   {"b", MatchCase::NO_MATCH},   {"a.b", MatchCase::NO_MATCH},
410*35238bceSAndroid Build Coastguard Worker                 {"a.c", MatchCase::NO_MATCH},   {"a.d", MatchCase::NO_MATCH}, {"a.e", MatchCase::NO_MATCH},
411*35238bceSAndroid Build Coastguard Worker                 {"c", MatchCase::MATCH_GROUP},  {"c.b", MatchCase::NO_MATCH}, {"c.d", MatchCase::MATCH_CASE},
412*35238bceSAndroid Build Coastguard Worker                 {"c.e", MatchCase::MATCH_CASE},
413*35238bceSAndroid Build Coastguard Worker             };
414*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "case_group", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
415*35238bceSAndroid Build Coastguard Worker         }
416*35238bceSAndroid Build Coastguard Worker         {
417*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "c.d\nc.e\na";
418*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
419*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_CASE},   {"b", MatchCase::NO_MATCH},   {"a.b", MatchCase::NO_MATCH},
420*35238bceSAndroid Build Coastguard Worker                 {"a.c", MatchCase::NO_MATCH},   {"a.d", MatchCase::NO_MATCH}, {"a.e", MatchCase::NO_MATCH},
421*35238bceSAndroid Build Coastguard Worker                 {"c", MatchCase::MATCH_GROUP},  {"c.b", MatchCase::NO_MATCH}, {"c.d", MatchCase::MATCH_CASE},
422*35238bceSAndroid Build Coastguard Worker                 {"c.e", MatchCase::MATCH_CASE},
423*35238bceSAndroid Build Coastguard Worker             };
424*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "group_case", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
425*35238bceSAndroid Build Coastguard Worker         }
426*35238bceSAndroid Build Coastguard Worker         {
427*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.x";
428*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
429*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP},
430*35238bceSAndroid Build Coastguard Worker                 {"b", MatchCase::NO_MATCH},
431*35238bceSAndroid Build Coastguard Worker                 {"a.b", MatchCase::MATCH_GROUP},
432*35238bceSAndroid Build Coastguard Worker                 {"a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.x", MatchCase::MATCH_CASE},
433*35238bceSAndroid Build Coastguard Worker             };
434*35238bceSAndroid Build Coastguard Worker             addChild(new CaseListParserCase(m_testCtx, "long_name", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
435*35238bceSAndroid Build Coastguard Worker         }
436*35238bceSAndroid Build Coastguard Worker         {
437*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.b.c.d.e\n"
438*35238bceSAndroid Build Coastguard Worker                                                 "a.b.c.f\n"
439*35238bceSAndroid Build Coastguard Worker                                                 "x.y.z\n"
440*35238bceSAndroid Build Coastguard Worker                                                 "a.b.c.d.g\n"
441*35238bceSAndroid Build Coastguard Worker                                                 "a.b.c.x\n";
442*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
443*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP},        {"a.b", MatchCase::MATCH_GROUP},
444*35238bceSAndroid Build Coastguard Worker                 {"a.b.c.d.e", MatchCase::MATCH_CASE}, {"a.b.c.d.g", MatchCase::MATCH_CASE},
445*35238bceSAndroid Build Coastguard Worker                 {"x.y", MatchCase::MATCH_GROUP},      {"x.y.z", MatchCase::MATCH_CASE},
446*35238bceSAndroid Build Coastguard Worker                 {"a.b.c.f", MatchCase::MATCH_CASE},   {"a.b.c.x", MatchCase::MATCH_CASE},
447*35238bceSAndroid Build Coastguard Worker             };
448*35238bceSAndroid Build Coastguard Worker             addChild(
449*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "partial_prefix", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
450*35238bceSAndroid Build Coastguard Worker         }
451*35238bceSAndroid Build Coastguard Worker         {
452*35238bceSAndroid Build Coastguard Worker             static const char *const caseList = "a.a.c.d\n"
453*35238bceSAndroid Build Coastguard Worker                                                 "a.b.c.d\n";
454*35238bceSAndroid Build Coastguard Worker             static const MatchCase subCases[] = {
455*35238bceSAndroid Build Coastguard Worker                 {"a", MatchCase::MATCH_GROUP},
456*35238bceSAndroid Build Coastguard Worker                 {"a.a", MatchCase::MATCH_GROUP},
457*35238bceSAndroid Build Coastguard Worker                 {"a.b.c.d", MatchCase::MATCH_CASE},
458*35238bceSAndroid Build Coastguard Worker                 {"a.b.c.d", MatchCase::MATCH_CASE},
459*35238bceSAndroid Build Coastguard Worker             };
460*35238bceSAndroid Build Coastguard Worker             addChild(
461*35238bceSAndroid Build Coastguard Worker                 new CaseListParserCase(m_testCtx, "reparenting", caseList, subCases, DE_LENGTH_OF_ARRAY(subCases)));
462*35238bceSAndroid Build Coastguard Worker         }
463*35238bceSAndroid Build Coastguard Worker 
464*35238bceSAndroid Build Coastguard Worker         // Negative tests
465*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_string", ""));
466*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_line", "\n"));
467*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_group_name", ".test"));
468*35238bceSAndroid Build Coastguard Worker         addChild(new NegativeCaseListCase(m_testCtx, "empty_case_name", "test."));
469*35238bceSAndroid Build Coastguard Worker     }
470*35238bceSAndroid Build Coastguard Worker };
471*35238bceSAndroid Build Coastguard Worker 
472*35238bceSAndroid Build Coastguard Worker class CaseListParserTests : public tcu::TestCaseGroup
473*35238bceSAndroid Build Coastguard Worker {
474*35238bceSAndroid Build Coastguard Worker public:
CaseListParserTests(tcu::TestContext & testCtx)475*35238bceSAndroid Build Coastguard Worker     CaseListParserTests(tcu::TestContext &testCtx)
476*35238bceSAndroid Build Coastguard Worker         : tcu::TestCaseGroup(testCtx, "case_list_parser", "Test case list parser tests")
477*35238bceSAndroid Build Coastguard Worker     {
478*35238bceSAndroid Build Coastguard Worker     }
479*35238bceSAndroid Build Coastguard Worker 
init(void)480*35238bceSAndroid Build Coastguard Worker     void init(void)
481*35238bceSAndroid Build Coastguard Worker     {
482*35238bceSAndroid Build Coastguard Worker         addChild(new TrieParserTests(m_testCtx));
483*35238bceSAndroid Build Coastguard Worker         addChild(new ListParserTests(m_testCtx));
484*35238bceSAndroid Build Coastguard Worker     }
485*35238bceSAndroid Build Coastguard Worker };
486*35238bceSAndroid Build Coastguard Worker 
ulpDiff(float a,float b)487*35238bceSAndroid Build Coastguard Worker inline uint32_t ulpDiff(float a, float b)
488*35238bceSAndroid Build Coastguard Worker {
489*35238bceSAndroid Build Coastguard Worker     const uint32_t ab = tcu::Float32(a).bits();
490*35238bceSAndroid Build Coastguard Worker     const uint32_t bb = tcu::Float32(b).bits();
491*35238bceSAndroid Build Coastguard Worker     return de::max(ab, bb) - de::min(ab, bb);
492*35238bceSAndroid Build Coastguard Worker }
493*35238bceSAndroid Build Coastguard Worker 
494*35238bceSAndroid Build Coastguard Worker template <int Size>
ulpDiff(const tcu::Vector<float,Size> & a,const tcu::Vector<float,Size> & b)495*35238bceSAndroid Build Coastguard Worker inline tcu::Vector<uint32_t, Size> ulpDiff(const tcu::Vector<float, Size> &a, const tcu::Vector<float, Size> &b)
496*35238bceSAndroid Build Coastguard Worker {
497*35238bceSAndroid Build Coastguard Worker     tcu::Vector<uint32_t, Size> res;
498*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < Size; ndx++)
499*35238bceSAndroid Build Coastguard Worker         res[ndx] = ulpDiff(a[ndx], b[ndx]);
500*35238bceSAndroid Build Coastguard Worker     return res;
501*35238bceSAndroid Build Coastguard Worker }
502*35238bceSAndroid Build Coastguard Worker 
503*35238bceSAndroid Build Coastguard Worker class ConstantInterpolationTest : public tcu::TestCase
504*35238bceSAndroid Build Coastguard Worker {
505*35238bceSAndroid Build Coastguard Worker public:
ConstantInterpolationTest(tcu::TestContext & testCtx)506*35238bceSAndroid Build Coastguard Worker     ConstantInterpolationTest(tcu::TestContext &testCtx)
507*35238bceSAndroid Build Coastguard Worker         : tcu::TestCase(testCtx, "const_interpolation", "Constant value interpolation")
508*35238bceSAndroid Build Coastguard Worker     {
509*35238bceSAndroid Build Coastguard Worker         const int supportedMsaaLevels[] = {1, 2, 4, 8, 16};
510*35238bceSAndroid Build Coastguard Worker 
511*35238bceSAndroid Build Coastguard Worker         for (int msaaNdx = 0; msaaNdx < DE_LENGTH_OF_ARRAY(supportedMsaaLevels); msaaNdx++)
512*35238bceSAndroid Build Coastguard Worker         {
513*35238bceSAndroid Build Coastguard Worker             const int numSamples = supportedMsaaLevels[msaaNdx];
514*35238bceSAndroid Build Coastguard Worker             {
515*35238bceSAndroid Build Coastguard Worker                 SubCase c;
516*35238bceSAndroid Build Coastguard Worker                 c.rtSize  = tcu::IVec3(128, 128, numSamples);
517*35238bceSAndroid Build Coastguard Worker                 c.vtx[0]  = tcu::Vec4(-1.0f, -1.0f, 0.5f, 1.0f);
518*35238bceSAndroid Build Coastguard Worker                 c.vtx[1]  = tcu::Vec4(-1.0f, +1.0f, 0.5f, 1.0f);
519*35238bceSAndroid Build Coastguard Worker                 c.vtx[2]  = tcu::Vec4(+1.0f, -1.0f, 0.5f, 1.0f);
520*35238bceSAndroid Build Coastguard Worker                 c.varying = tcu::Vec4(0.0f, 1.0f, 8.0f, -8.0f);
521*35238bceSAndroid Build Coastguard Worker                 m_cases.push_back(c);
522*35238bceSAndroid Build Coastguard Worker             }
523*35238bceSAndroid Build Coastguard Worker 
524*35238bceSAndroid Build Coastguard Worker             {
525*35238bceSAndroid Build Coastguard Worker                 SubCase c;
526*35238bceSAndroid Build Coastguard Worker                 c.rtSize  = tcu::IVec3(128, 128, numSamples);
527*35238bceSAndroid Build Coastguard Worker                 c.vtx[0]  = tcu::Vec4(-1.0f, +1.0f, 0.5f, 1.0f);
528*35238bceSAndroid Build Coastguard Worker                 c.vtx[1]  = tcu::Vec4(+1.0f, -1.0f, 0.5f, 1.0f);
529*35238bceSAndroid Build Coastguard Worker                 c.vtx[2]  = tcu::Vec4(+1.0f, +1.0f, 0.5f, 1.0f);
530*35238bceSAndroid Build Coastguard Worker                 c.varying = tcu::Vec4(0.0f, 1.0f, 8.0f, -8.0f);
531*35238bceSAndroid Build Coastguard Worker                 m_cases.push_back(c);
532*35238bceSAndroid Build Coastguard Worker             }
533*35238bceSAndroid Build Coastguard Worker             {
534*35238bceSAndroid Build Coastguard Worker                 SubCase c;
535*35238bceSAndroid Build Coastguard Worker                 c.rtSize  = tcu::IVec3(129, 113, numSamples);
536*35238bceSAndroid Build Coastguard Worker                 c.vtx[0]  = tcu::Vec4(-1.0f, -1.0f, 0.5f, 1.0f);
537*35238bceSAndroid Build Coastguard Worker                 c.vtx[1]  = tcu::Vec4(-1.0f, +1.0f, 0.5f, 1.0f);
538*35238bceSAndroid Build Coastguard Worker                 c.vtx[2]  = tcu::Vec4(+1.0f, -1.0f, 0.5f, 1.0f);
539*35238bceSAndroid Build Coastguard Worker                 c.varying = tcu::Vec4(0.0f, 1.0f, 8.0f, -8.0f);
540*35238bceSAndroid Build Coastguard Worker                 m_cases.push_back(c);
541*35238bceSAndroid Build Coastguard Worker             }
542*35238bceSAndroid Build Coastguard Worker             {
543*35238bceSAndroid Build Coastguard Worker                 SubCase c;
544*35238bceSAndroid Build Coastguard Worker                 c.rtSize  = tcu::IVec3(107, 131, numSamples);
545*35238bceSAndroid Build Coastguard Worker                 c.vtx[0]  = tcu::Vec4(-1.0f, +1.0f, 0.5f, 1.0f);
546*35238bceSAndroid Build Coastguard Worker                 c.vtx[1]  = tcu::Vec4(+1.0f, -1.0f, 0.5f, 1.0f);
547*35238bceSAndroid Build Coastguard Worker                 c.vtx[2]  = tcu::Vec4(+1.0f, +1.0f, 0.5f, 1.0f);
548*35238bceSAndroid Build Coastguard Worker                 c.varying = tcu::Vec4(0.0f, 1.0f, 8.0f, -8.0f);
549*35238bceSAndroid Build Coastguard Worker                 m_cases.push_back(c);
550*35238bceSAndroid Build Coastguard Worker             }
551*35238bceSAndroid Build Coastguard Worker         }
552*35238bceSAndroid Build Coastguard Worker 
553*35238bceSAndroid Build Coastguard Worker         {
554*35238bceSAndroid Build Coastguard Worker             de::Random rnd(0x89423f);
555*35238bceSAndroid Build Coastguard Worker             for (int ndx = 0; ndx < 25; ndx++)
556*35238bceSAndroid Build Coastguard Worker             {
557*35238bceSAndroid Build Coastguard Worker                 const float depth = rnd.getFloat() * 2.0f - 1.0f;
558*35238bceSAndroid Build Coastguard Worker                 SubCase c;
559*35238bceSAndroid Build Coastguard Worker 
560*35238bceSAndroid Build Coastguard Worker                 c.rtSize.x() = rnd.getInt(16, 256);
561*35238bceSAndroid Build Coastguard Worker                 c.rtSize.y() = rnd.getInt(16, 256);
562*35238bceSAndroid Build Coastguard Worker                 c.rtSize.z() = rnd.choose<int>(DE_ARRAY_BEGIN(supportedMsaaLevels), DE_ARRAY_END(supportedMsaaLevels));
563*35238bceSAndroid Build Coastguard Worker 
564*35238bceSAndroid Build Coastguard Worker                 for (int vtxNdx = 0; vtxNdx < DE_LENGTH_OF_ARRAY(c.vtx); vtxNdx++)
565*35238bceSAndroid Build Coastguard Worker                 {
566*35238bceSAndroid Build Coastguard Worker                     c.vtx[vtxNdx].x() = rnd.getFloat() * 2.0f - 1.0f;
567*35238bceSAndroid Build Coastguard Worker                     c.vtx[vtxNdx].y() = rnd.getFloat() * 2.0f - 1.0f;
568*35238bceSAndroid Build Coastguard Worker                     c.vtx[vtxNdx].z() = depth;
569*35238bceSAndroid Build Coastguard Worker                     c.vtx[vtxNdx].w() = 1.0f;
570*35238bceSAndroid Build Coastguard Worker                 }
571*35238bceSAndroid Build Coastguard Worker 
572*35238bceSAndroid Build Coastguard Worker                 for (int compNdx = 0; compNdx < 4; compNdx++)
573*35238bceSAndroid Build Coastguard Worker                 {
574*35238bceSAndroid Build Coastguard Worker                     float v;
575*35238bceSAndroid Build Coastguard Worker                     do
576*35238bceSAndroid Build Coastguard Worker                     {
577*35238bceSAndroid Build Coastguard Worker                         v = tcu::Float32(rnd.getUint32()).asFloat();
578*35238bceSAndroid Build Coastguard Worker                     } while (deFloatIsInf(v) || deFloatIsNaN(v));
579*35238bceSAndroid Build Coastguard Worker                     c.varying[compNdx] = v;
580*35238bceSAndroid Build Coastguard Worker                 }
581*35238bceSAndroid Build Coastguard Worker                 m_cases.push_back(c);
582*35238bceSAndroid Build Coastguard Worker             }
583*35238bceSAndroid Build Coastguard Worker         }
584*35238bceSAndroid Build Coastguard Worker     }
585*35238bceSAndroid Build Coastguard Worker 
init(void)586*35238bceSAndroid Build Coastguard Worker     void init(void)
587*35238bceSAndroid Build Coastguard Worker     {
588*35238bceSAndroid Build Coastguard Worker         m_caseIter = m_cases.begin();
589*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "All iterations passed");
590*35238bceSAndroid Build Coastguard Worker     }
591*35238bceSAndroid Build Coastguard Worker 
iterate(void)592*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void)
593*35238bceSAndroid Build Coastguard Worker     {
594*35238bceSAndroid Build Coastguard Worker         {
595*35238bceSAndroid Build Coastguard Worker             tcu::ScopedLogSection section(m_testCtx.getLog(), "SubCase", "");
596*35238bceSAndroid Build Coastguard Worker             runCase(*m_caseIter);
597*35238bceSAndroid Build Coastguard Worker         }
598*35238bceSAndroid Build Coastguard Worker         return (++m_caseIter != m_cases.end()) ? CONTINUE : STOP;
599*35238bceSAndroid Build Coastguard Worker     }
600*35238bceSAndroid Build Coastguard Worker 
601*35238bceSAndroid Build Coastguard Worker protected:
602*35238bceSAndroid Build Coastguard Worker     struct SubCase
603*35238bceSAndroid Build Coastguard Worker     {
604*35238bceSAndroid Build Coastguard Worker         tcu::IVec3 rtSize; // (width, height, samples)
605*35238bceSAndroid Build Coastguard Worker         tcu::Vec4 vtx[3];
606*35238bceSAndroid Build Coastguard Worker         tcu::Vec4 varying;
607*35238bceSAndroid Build Coastguard Worker     };
608*35238bceSAndroid Build Coastguard Worker 
runCase(const SubCase & subCase)609*35238bceSAndroid Build Coastguard Worker     void runCase(const SubCase &subCase)
610*35238bceSAndroid Build Coastguard Worker     {
611*35238bceSAndroid Build Coastguard Worker         using namespace tcu;
612*35238bceSAndroid Build Coastguard Worker 
613*35238bceSAndroid Build Coastguard Worker         const uint32_t maxColorUlpDiff = 2;
614*35238bceSAndroid Build Coastguard Worker         const uint32_t maxDepthUlpDiff = 0;
615*35238bceSAndroid Build Coastguard Worker 
616*35238bceSAndroid Build Coastguard Worker         const int width      = subCase.rtSize.x();
617*35238bceSAndroid Build Coastguard Worker         const int height     = subCase.rtSize.y();
618*35238bceSAndroid Build Coastguard Worker         const int numSamples = subCase.rtSize.z();
619*35238bceSAndroid Build Coastguard Worker         const float zn       = 0.0f;
620*35238bceSAndroid Build Coastguard Worker         const float zf       = 1.0f;
621*35238bceSAndroid Build Coastguard Worker 
622*35238bceSAndroid Build Coastguard Worker         TextureLevel interpolated(TextureFormat(TextureFormat::RGBA, TextureFormat::FLOAT), numSamples, width, height);
623*35238bceSAndroid Build Coastguard Worker         TextureLevel depthStencil(TextureFormat(TextureFormat::DS, TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV),
624*35238bceSAndroid Build Coastguard Worker                                   numSamples, width, height);
625*35238bceSAndroid Build Coastguard Worker 
626*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << TestLog::Message << "RT size (w, h, #samples) = " << subCase.rtSize << "\n"
627*35238bceSAndroid Build Coastguard Worker                            << "vtx[0] = " << subCase.vtx[0] << "\n"
628*35238bceSAndroid Build Coastguard Worker                            << "vtx[1] = " << subCase.vtx[1] << "\n"
629*35238bceSAndroid Build Coastguard Worker                            << "vtx[2] = " << subCase.vtx[2] << "\n"
630*35238bceSAndroid Build Coastguard Worker                            << "color = " << subCase.varying << TestLog::EndMessage;
631*35238bceSAndroid Build Coastguard Worker 
632*35238bceSAndroid Build Coastguard Worker         clear(interpolated.getAccess(), subCase.varying - Vec4(0.0f, 0.0f, 0.0f, 1.0f));
633*35238bceSAndroid Build Coastguard Worker         clearDepth(depthStencil.getAccess(), 0.0f);
634*35238bceSAndroid Build Coastguard Worker         clearStencil(depthStencil.getAccess(), 0);
635*35238bceSAndroid Build Coastguard Worker 
636*35238bceSAndroid Build Coastguard Worker         {
637*35238bceSAndroid Build Coastguard Worker             class VtxShader : public rr::VertexShader
638*35238bceSAndroid Build Coastguard Worker             {
639*35238bceSAndroid Build Coastguard Worker             public:
640*35238bceSAndroid Build Coastguard Worker                 VtxShader(void) : rr::VertexShader(2, 1)
641*35238bceSAndroid Build Coastguard Worker                 {
642*35238bceSAndroid Build Coastguard Worker                     m_inputs[0].type  = rr::GENERICVECTYPE_FLOAT;
643*35238bceSAndroid Build Coastguard Worker                     m_inputs[1].type  = rr::GENERICVECTYPE_FLOAT;
644*35238bceSAndroid Build Coastguard Worker                     m_outputs[0].type = rr::GENERICVECTYPE_FLOAT;
645*35238bceSAndroid Build Coastguard Worker                 }
646*35238bceSAndroid Build Coastguard Worker 
647*35238bceSAndroid Build Coastguard Worker                 void shadeVertices(const rr::VertexAttrib *inputs, rr::VertexPacket *const *packets,
648*35238bceSAndroid Build Coastguard Worker                                    const int numPackets) const
649*35238bceSAndroid Build Coastguard Worker                 {
650*35238bceSAndroid Build Coastguard Worker                     for (int packetNdx = 0; packetNdx < numPackets; packetNdx++)
651*35238bceSAndroid Build Coastguard Worker                     {
652*35238bceSAndroid Build Coastguard Worker                         rr::readVertexAttrib(packets[packetNdx]->position, inputs[0], packets[packetNdx]->instanceNdx,
653*35238bceSAndroid Build Coastguard Worker                                              packets[packetNdx]->vertexNdx);
654*35238bceSAndroid Build Coastguard Worker                         packets[packetNdx]->outputs[0] = rr::readVertexAttribFloat(
655*35238bceSAndroid Build Coastguard Worker                             inputs[1], packets[packetNdx]->instanceNdx, packets[packetNdx]->vertexNdx);
656*35238bceSAndroid Build Coastguard Worker                     }
657*35238bceSAndroid Build Coastguard Worker                 }
658*35238bceSAndroid Build Coastguard Worker             } vtxShader;
659*35238bceSAndroid Build Coastguard Worker 
660*35238bceSAndroid Build Coastguard Worker             class FragShader : public rr::FragmentShader
661*35238bceSAndroid Build Coastguard Worker             {
662*35238bceSAndroid Build Coastguard Worker             public:
663*35238bceSAndroid Build Coastguard Worker                 FragShader(void) : rr::FragmentShader(1, 1)
664*35238bceSAndroid Build Coastguard Worker                 {
665*35238bceSAndroid Build Coastguard Worker                     m_inputs[0].type  = rr::GENERICVECTYPE_FLOAT;
666*35238bceSAndroid Build Coastguard Worker                     m_outputs[0].type = rr::GENERICVECTYPE_FLOAT;
667*35238bceSAndroid Build Coastguard Worker                 }
668*35238bceSAndroid Build Coastguard Worker 
669*35238bceSAndroid Build Coastguard Worker                 void shadeFragments(rr::FragmentPacket *packets, const int numPackets,
670*35238bceSAndroid Build Coastguard Worker                                     const rr::FragmentShadingContext &context) const
671*35238bceSAndroid Build Coastguard Worker                 {
672*35238bceSAndroid Build Coastguard Worker                     for (int packetNdx = 0; packetNdx < numPackets; packetNdx++)
673*35238bceSAndroid Build Coastguard Worker                     {
674*35238bceSAndroid Build Coastguard Worker                         for (int fragNdx = 0; fragNdx < rr::NUM_FRAGMENTS_PER_PACKET; fragNdx++)
675*35238bceSAndroid Build Coastguard Worker                         {
676*35238bceSAndroid Build Coastguard Worker                             const tcu::Vec4 interp =
677*35238bceSAndroid Build Coastguard Worker                                 rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx);
678*35238bceSAndroid Build Coastguard Worker                             rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, interp);
679*35238bceSAndroid Build Coastguard Worker                         }
680*35238bceSAndroid Build Coastguard Worker                     }
681*35238bceSAndroid Build Coastguard Worker                 }
682*35238bceSAndroid Build Coastguard Worker             } fragShader;
683*35238bceSAndroid Build Coastguard Worker 
684*35238bceSAndroid Build Coastguard Worker             const rr::Program program(&vtxShader, &fragShader);
685*35238bceSAndroid Build Coastguard Worker 
686*35238bceSAndroid Build Coastguard Worker             const rr::MultisamplePixelBufferAccess colorAccess =
687*35238bceSAndroid Build Coastguard Worker                 rr::MultisamplePixelBufferAccess::fromMultisampleAccess(interpolated.getAccess());
688*35238bceSAndroid Build Coastguard Worker             const rr::MultisamplePixelBufferAccess dsAccess =
689*35238bceSAndroid Build Coastguard Worker                 rr::MultisamplePixelBufferAccess::fromMultisampleAccess(depthStencil.getAccess());
690*35238bceSAndroid Build Coastguard Worker             const rr::RenderTarget renderTarget(colorAccess, dsAccess, dsAccess);
691*35238bceSAndroid Build Coastguard Worker             const rr::VertexAttrib vertexAttribs[] = {
692*35238bceSAndroid Build Coastguard Worker                 rr::VertexAttrib(rr::VERTEXATTRIBTYPE_FLOAT, 4, 0, 0, subCase.vtx), rr::VertexAttrib(subCase.varying)};
693*35238bceSAndroid Build Coastguard Worker             rr::ViewportState viewport(colorAccess);
694*35238bceSAndroid Build Coastguard Worker             rr::RenderState state(viewport, rr::RenderState::DEFAULT_SUBPIXEL_BITS);
695*35238bceSAndroid Build Coastguard Worker             const rr::PrimitiveList primitives(rr::PRIMITIVETYPE_TRIANGLES, 3, 0);
696*35238bceSAndroid Build Coastguard Worker             const rr::DrawCommand drawCmd(state, renderTarget, program, DE_LENGTH_OF_ARRAY(vertexAttribs),
697*35238bceSAndroid Build Coastguard Worker                                           vertexAttribs, primitives);
698*35238bceSAndroid Build Coastguard Worker             const rr::Renderer renderer;
699*35238bceSAndroid Build Coastguard Worker 
700*35238bceSAndroid Build Coastguard Worker             viewport.zn = zn;
701*35238bceSAndroid Build Coastguard Worker             viewport.zf = zf;
702*35238bceSAndroid Build Coastguard Worker 
703*35238bceSAndroid Build Coastguard Worker             state.fragOps.depthTestEnabled                        = true;
704*35238bceSAndroid Build Coastguard Worker             state.fragOps.depthFunc                               = rr::TESTFUNC_ALWAYS;
705*35238bceSAndroid Build Coastguard Worker             state.fragOps.stencilTestEnabled                      = true;
706*35238bceSAndroid Build Coastguard Worker             state.fragOps.stencilStates[rr::FACETYPE_BACK].func   = rr::TESTFUNC_ALWAYS;
707*35238bceSAndroid Build Coastguard Worker             state.fragOps.stencilStates[rr::FACETYPE_BACK].dpPass = rr::STENCILOP_INCR;
708*35238bceSAndroid Build Coastguard Worker             state.fragOps.stencilStates[rr::FACETYPE_FRONT]       = state.fragOps.stencilStates[rr::FACETYPE_BACK];
709*35238bceSAndroid Build Coastguard Worker 
710*35238bceSAndroid Build Coastguard Worker             renderer.draw(drawCmd);
711*35238bceSAndroid Build Coastguard Worker         }
712*35238bceSAndroid Build Coastguard Worker 
713*35238bceSAndroid Build Coastguard Worker         // Verify interpolated values
714*35238bceSAndroid Build Coastguard Worker         {
715*35238bceSAndroid Build Coastguard Worker             TextureLevel resolvedColor(interpolated.getFormat(), width, height);        // For debugging
716*35238bceSAndroid Build Coastguard Worker             TextureLevel resolvedDepthStencil(depthStencil.getFormat(), width, height); // For debugging
717*35238bceSAndroid Build Coastguard Worker             TextureLevel errorMask(TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), width, height);
718*35238bceSAndroid Build Coastguard Worker             const ConstPixelBufferAccess interpAccess = interpolated.getAccess();
719*35238bceSAndroid Build Coastguard Worker             const ConstPixelBufferAccess dsAccess     = depthStencil.getAccess();
720*35238bceSAndroid Build Coastguard Worker             const PixelBufferAccess errorAccess       = errorMask.getAccess();
721*35238bceSAndroid Build Coastguard Worker             int numCoveredSamples                     = 0;
722*35238bceSAndroid Build Coastguard Worker             int numFailedColorSamples                 = 0;
723*35238bceSAndroid Build Coastguard Worker             int numFailedDepthSamples                 = 0;
724*35238bceSAndroid Build Coastguard Worker             const bool verifyDepth =
725*35238bceSAndroid Build Coastguard Worker                 (subCase.vtx[0].z() == subCase.vtx[1].z()) && (subCase.vtx[1].z() == subCase.vtx[2].z());
726*35238bceSAndroid Build Coastguard Worker             const float refDepth = subCase.vtx[0].z() * (zf - zn) / 2.0f + (zn + zf) / 2.0f;
727*35238bceSAndroid Build Coastguard Worker 
728*35238bceSAndroid Build Coastguard Worker             rr::resolveMultisampleBuffer(
729*35238bceSAndroid Build Coastguard Worker                 resolvedColor.getAccess(),
730*35238bceSAndroid Build Coastguard Worker                 rr::MultisampleConstPixelBufferAccess::fromMultisampleAccess(interpolated.getAccess()));
731*35238bceSAndroid Build Coastguard Worker             rr::resolveMultisampleBuffer(
732*35238bceSAndroid Build Coastguard Worker                 resolvedDepthStencil.getAccess(),
733*35238bceSAndroid Build Coastguard Worker                 rr::MultisampleConstPixelBufferAccess::fromMultisampleAccess(depthStencil.getAccess()));
734*35238bceSAndroid Build Coastguard Worker             clear(errorAccess, Vec4(0.0f, 1.0f, 0.0f, 1.0f));
735*35238bceSAndroid Build Coastguard Worker 
736*35238bceSAndroid Build Coastguard Worker             for (int y = 0; y < height; y++)
737*35238bceSAndroid Build Coastguard Worker             {
738*35238bceSAndroid Build Coastguard Worker                 for (int x = 0; x < width; x++)
739*35238bceSAndroid Build Coastguard Worker                 {
740*35238bceSAndroid Build Coastguard Worker                     for (int sampleNdx = 0; sampleNdx < numSamples; sampleNdx++)
741*35238bceSAndroid Build Coastguard Worker                     {
742*35238bceSAndroid Build Coastguard Worker                         if (dsAccess.getPixStencil(sampleNdx, x, y) != 0)
743*35238bceSAndroid Build Coastguard Worker                         {
744*35238bceSAndroid Build Coastguard Worker                             const Vec4 color      = interpAccess.getPixel(sampleNdx, x, y);
745*35238bceSAndroid Build Coastguard Worker                             const UVec4 colorDiff = ulpDiff(color, subCase.varying);
746*35238bceSAndroid Build Coastguard Worker                             const bool colorOk    = boolAll(lessThanEqual(colorDiff, tcu::UVec4(maxColorUlpDiff)));
747*35238bceSAndroid Build Coastguard Worker 
748*35238bceSAndroid Build Coastguard Worker                             const float depth        = dsAccess.getPixDepth(sampleNdx, x, y);
749*35238bceSAndroid Build Coastguard Worker                             const uint32_t depthDiff = ulpDiff(depth, refDepth);
750*35238bceSAndroid Build Coastguard Worker                             const bool depthOk       = verifyDepth && (depthDiff <= maxDepthUlpDiff);
751*35238bceSAndroid Build Coastguard Worker 
752*35238bceSAndroid Build Coastguard Worker                             const int maxMsgs = 10;
753*35238bceSAndroid Build Coastguard Worker 
754*35238bceSAndroid Build Coastguard Worker                             numCoveredSamples += 1;
755*35238bceSAndroid Build Coastguard Worker 
756*35238bceSAndroid Build Coastguard Worker                             if (!colorOk)
757*35238bceSAndroid Build Coastguard Worker                             {
758*35238bceSAndroid Build Coastguard Worker                                 numFailedColorSamples += 1;
759*35238bceSAndroid Build Coastguard Worker 
760*35238bceSAndroid Build Coastguard Worker                                 if (numFailedColorSamples <= maxMsgs)
761*35238bceSAndroid Build Coastguard Worker                                     m_testCtx.getLog() << TestLog::Message << "FAIL: " << tcu::IVec3(x, y, sampleNdx)
762*35238bceSAndroid Build Coastguard Worker                                                        << " color ulp diff = " << colorDiff << TestLog::EndMessage;
763*35238bceSAndroid Build Coastguard Worker                             }
764*35238bceSAndroid Build Coastguard Worker 
765*35238bceSAndroid Build Coastguard Worker                             if (!depthOk)
766*35238bceSAndroid Build Coastguard Worker                                 numFailedDepthSamples += 1;
767*35238bceSAndroid Build Coastguard Worker 
768*35238bceSAndroid Build Coastguard Worker                             if (!colorOk || !depthOk)
769*35238bceSAndroid Build Coastguard Worker                                 errorAccess.setPixel(errorAccess.getPixel(x, y) +
770*35238bceSAndroid Build Coastguard Worker                                                          Vec4(1.0f, -1.0f, 0.0f, 0.0f) / float(numSamples - 1),
771*35238bceSAndroid Build Coastguard Worker                                                      x, y);
772*35238bceSAndroid Build Coastguard Worker                         }
773*35238bceSAndroid Build Coastguard Worker                     }
774*35238bceSAndroid Build Coastguard Worker                 }
775*35238bceSAndroid Build Coastguard Worker             }
776*35238bceSAndroid Build Coastguard Worker 
777*35238bceSAndroid Build Coastguard Worker             m_testCtx.getLog() << TestLog::Image("ResolvedColor", "Resolved colorbuffer", resolvedColor)
778*35238bceSAndroid Build Coastguard Worker                                << TestLog::Image("ResolvedDepthStencil", "Resolved depth- & stencilbuffer",
779*35238bceSAndroid Build Coastguard Worker                                                  resolvedDepthStencil);
780*35238bceSAndroid Build Coastguard Worker 
781*35238bceSAndroid Build Coastguard Worker             if (numFailedColorSamples != 0 || numFailedDepthSamples != 0)
782*35238bceSAndroid Build Coastguard Worker             {
783*35238bceSAndroid Build Coastguard Worker                 m_testCtx.getLog() << TestLog::Image("ErrorMask", "Error mask", errorMask);
784*35238bceSAndroid Build Coastguard Worker 
785*35238bceSAndroid Build Coastguard Worker                 if (numFailedColorSamples != 0)
786*35238bceSAndroid Build Coastguard Worker                     m_testCtx.getLog() << TestLog::Message << "FAIL: Found " << numFailedColorSamples
787*35238bceSAndroid Build Coastguard Worker                                        << " invalid color samples!" << TestLog::EndMessage;
788*35238bceSAndroid Build Coastguard Worker 
789*35238bceSAndroid Build Coastguard Worker                 if (numFailedDepthSamples != 0)
790*35238bceSAndroid Build Coastguard Worker                     m_testCtx.getLog() << TestLog::Message << "FAIL: Found " << numFailedDepthSamples
791*35238bceSAndroid Build Coastguard Worker                                        << " invalid depth samples!" << TestLog::EndMessage;
792*35238bceSAndroid Build Coastguard Worker 
793*35238bceSAndroid Build Coastguard Worker                 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
794*35238bceSAndroid Build Coastguard Worker                     m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid samples found");
795*35238bceSAndroid Build Coastguard Worker             }
796*35238bceSAndroid Build Coastguard Worker 
797*35238bceSAndroid Build Coastguard Worker             m_testCtx.getLog() << TestLog::Message << (numCoveredSamples - numFailedColorSamples) << " / "
798*35238bceSAndroid Build Coastguard Worker                                << numCoveredSamples << " color samples passed" << TestLog::EndMessage;
799*35238bceSAndroid Build Coastguard Worker             m_testCtx.getLog() << TestLog::Message << (numCoveredSamples - numFailedDepthSamples) << " / "
800*35238bceSAndroid Build Coastguard Worker                                << numCoveredSamples << " depth samples passed" << TestLog::EndMessage;
801*35238bceSAndroid Build Coastguard Worker         }
802*35238bceSAndroid Build Coastguard Worker     }
803*35238bceSAndroid Build Coastguard Worker 
804*35238bceSAndroid Build Coastguard Worker     vector<SubCase> m_cases;
805*35238bceSAndroid Build Coastguard Worker     vector<SubCase>::const_iterator m_caseIter;
806*35238bceSAndroid Build Coastguard Worker };
807*35238bceSAndroid Build Coastguard Worker 
808*35238bceSAndroid Build Coastguard Worker class CommonFrameworkTests : public tcu::TestCaseGroup
809*35238bceSAndroid Build Coastguard Worker {
810*35238bceSAndroid Build Coastguard Worker public:
CommonFrameworkTests(tcu::TestContext & testCtx)811*35238bceSAndroid Build Coastguard Worker     CommonFrameworkTests(tcu::TestContext &testCtx)
812*35238bceSAndroid Build Coastguard Worker         : tcu::TestCaseGroup(testCtx, "common", "Tests for the common utility framework")
813*35238bceSAndroid Build Coastguard Worker     {
814*35238bceSAndroid Build Coastguard Worker     }
815*35238bceSAndroid Build Coastguard Worker 
init(void)816*35238bceSAndroid Build Coastguard Worker     void init(void)
817*35238bceSAndroid Build Coastguard Worker     {
818*35238bceSAndroid Build Coastguard Worker         addChild(
819*35238bceSAndroid Build Coastguard Worker             new SelfCheckCase(m_testCtx, "float_format", "tcu::FloatFormat_selfTest()", tcu::FloatFormat_selfTest));
820*35238bceSAndroid Build Coastguard Worker         addChild(new SelfCheckCase(m_testCtx, "either", "tcu::Either_selfTest()", tcu::Either_selfTest));
821*35238bceSAndroid Build Coastguard Worker     }
822*35238bceSAndroid Build Coastguard Worker };
823*35238bceSAndroid Build Coastguard Worker 
824*35238bceSAndroid Build Coastguard Worker class ReferenceRendererTests : public tcu::TestCaseGroup
825*35238bceSAndroid Build Coastguard Worker {
826*35238bceSAndroid Build Coastguard Worker public:
ReferenceRendererTests(tcu::TestContext & testCtx)827*35238bceSAndroid Build Coastguard Worker     ReferenceRendererTests(tcu::TestContext &testCtx)
828*35238bceSAndroid Build Coastguard Worker         : tcu::TestCaseGroup(testCtx, "reference_renderer", "Reference renderer tests")
829*35238bceSAndroid Build Coastguard Worker     {
830*35238bceSAndroid Build Coastguard Worker     }
831*35238bceSAndroid Build Coastguard Worker 
init(void)832*35238bceSAndroid Build Coastguard Worker     void init(void)
833*35238bceSAndroid Build Coastguard Worker     {
834*35238bceSAndroid Build Coastguard Worker         addChild(new ConstantInterpolationTest(m_testCtx));
835*35238bceSAndroid Build Coastguard Worker     }
836*35238bceSAndroid Build Coastguard Worker };
837*35238bceSAndroid Build Coastguard Worker 
838*35238bceSAndroid Build Coastguard Worker } // namespace
839*35238bceSAndroid Build Coastguard Worker 
FrameworkTests(tcu::TestContext & testCtx)840*35238bceSAndroid Build Coastguard Worker FrameworkTests::FrameworkTests(tcu::TestContext &testCtx)
841*35238bceSAndroid Build Coastguard Worker     : tcu::TestCaseGroup(testCtx, "framework", "Miscellaneous framework tests")
842*35238bceSAndroid Build Coastguard Worker {
843*35238bceSAndroid Build Coastguard Worker }
844*35238bceSAndroid Build Coastguard Worker 
~FrameworkTests(void)845*35238bceSAndroid Build Coastguard Worker FrameworkTests::~FrameworkTests(void)
846*35238bceSAndroid Build Coastguard Worker {
847*35238bceSAndroid Build Coastguard Worker }
848*35238bceSAndroid Build Coastguard Worker 
init(void)849*35238bceSAndroid Build Coastguard Worker void FrameworkTests::init(void)
850*35238bceSAndroid Build Coastguard Worker {
851*35238bceSAndroid Build Coastguard Worker     addChild(new CommonFrameworkTests(m_testCtx));
852*35238bceSAndroid Build Coastguard Worker     addChild(new CaseListParserTests(m_testCtx));
853*35238bceSAndroid Build Coastguard Worker     addChild(new ReferenceRendererTests(m_testCtx));
854*35238bceSAndroid Build Coastguard Worker     addChild(createTextureFormatTests(m_testCtx));
855*35238bceSAndroid Build Coastguard Worker     addChild(createAstcTests(m_testCtx));
856*35238bceSAndroid Build Coastguard Worker     addChild(createVulkanTests(m_testCtx));
857*35238bceSAndroid Build Coastguard Worker }
858*35238bceSAndroid Build Coastguard Worker 
859*35238bceSAndroid Build Coastguard Worker } // namespace dit
860