1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 2.0 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 Drawing tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es2fDrawTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "glsDrawTest.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "deUniquePtr.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "deSTLUtil.hpp"
31*35238bceSAndroid Build Coastguard Worker
32*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
33*35238bceSAndroid Build Coastguard Worker
34*35238bceSAndroid Build Coastguard Worker #include <set>
35*35238bceSAndroid Build Coastguard Worker
36*35238bceSAndroid Build Coastguard Worker namespace deqp
37*35238bceSAndroid Build Coastguard Worker {
38*35238bceSAndroid Build Coastguard Worker namespace gles2
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker namespace Functional
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker namespace
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker
45*35238bceSAndroid Build Coastguard Worker enum TestIterationType
46*35238bceSAndroid Build Coastguard Worker {
47*35238bceSAndroid Build Coastguard Worker TYPE_DRAW_COUNT, // !< test with 1, 5, and 25 primitives
48*35238bceSAndroid Build Coastguard Worker
49*35238bceSAndroid Build Coastguard Worker TYPE_LAST
50*35238bceSAndroid Build Coastguard Worker };
51*35238bceSAndroid Build Coastguard Worker
addTestIterations(gls::DrawTest * test,const gls::DrawTestSpec & baseSpec,TestIterationType type)52*35238bceSAndroid Build Coastguard Worker static void addTestIterations(gls::DrawTest *test, const gls::DrawTestSpec &baseSpec, TestIterationType type)
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec(baseSpec);
55*35238bceSAndroid Build Coastguard Worker
56*35238bceSAndroid Build Coastguard Worker if (type == TYPE_DRAW_COUNT)
57*35238bceSAndroid Build Coastguard Worker {
58*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = 1;
59*35238bceSAndroid Build Coastguard Worker test->addIteration(spec, "draw count = 1");
60*35238bceSAndroid Build Coastguard Worker
61*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = 5;
62*35238bceSAndroid Build Coastguard Worker test->addIteration(spec, "draw count = 5");
63*35238bceSAndroid Build Coastguard Worker
64*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = 25;
65*35238bceSAndroid Build Coastguard Worker test->addIteration(spec, "draw count = 25");
66*35238bceSAndroid Build Coastguard Worker }
67*35238bceSAndroid Build Coastguard Worker else
68*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
69*35238bceSAndroid Build Coastguard Worker }
70*35238bceSAndroid Build Coastguard Worker
genBasicSpec(gls::DrawTestSpec & spec,gls::DrawTestSpec::DrawMethod method)71*35238bceSAndroid Build Coastguard Worker static void genBasicSpec(gls::DrawTestSpec &spec, gls::DrawTestSpec::DrawMethod method)
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker spec.apiType = glu::ApiType::es(2, 0);
74*35238bceSAndroid Build Coastguard Worker spec.primitive = gls::DrawTestSpec::PRIMITIVE_TRIANGLES;
75*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = 5;
76*35238bceSAndroid Build Coastguard Worker spec.drawMethod = method;
77*35238bceSAndroid Build Coastguard Worker spec.indexType = gls::DrawTestSpec::INDEXTYPE_LAST;
78*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = 0;
79*35238bceSAndroid Build Coastguard Worker spec.indexStorage = gls::DrawTestSpec::STORAGE_LAST;
80*35238bceSAndroid Build Coastguard Worker spec.first = 0;
81*35238bceSAndroid Build Coastguard Worker spec.indexMin = 0;
82*35238bceSAndroid Build Coastguard Worker spec.indexMax = 0;
83*35238bceSAndroid Build Coastguard Worker spec.instanceCount = 1;
84*35238bceSAndroid Build Coastguard Worker
85*35238bceSAndroid Build Coastguard Worker spec.attribs.resize(2);
86*35238bceSAndroid Build Coastguard Worker
87*35238bceSAndroid Build Coastguard Worker spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT;
88*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2;
89*35238bceSAndroid Build Coastguard Worker spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER;
90*35238bceSAndroid Build Coastguard Worker spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW;
91*35238bceSAndroid Build Coastguard Worker spec.attribs[0].componentCount = 4;
92*35238bceSAndroid Build Coastguard Worker spec.attribs[0].offset = 0;
93*35238bceSAndroid Build Coastguard Worker spec.attribs[0].stride = 0;
94*35238bceSAndroid Build Coastguard Worker spec.attribs[0].normalize = false;
95*35238bceSAndroid Build Coastguard Worker spec.attribs[0].instanceDivisor = 0;
96*35238bceSAndroid Build Coastguard Worker spec.attribs[0].useDefaultAttribute = false;
97*35238bceSAndroid Build Coastguard Worker
98*35238bceSAndroid Build Coastguard Worker spec.attribs[1].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT;
99*35238bceSAndroid Build Coastguard Worker spec.attribs[1].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2;
100*35238bceSAndroid Build Coastguard Worker spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER;
101*35238bceSAndroid Build Coastguard Worker spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW;
102*35238bceSAndroid Build Coastguard Worker spec.attribs[1].componentCount = 2;
103*35238bceSAndroid Build Coastguard Worker spec.attribs[1].offset = 0;
104*35238bceSAndroid Build Coastguard Worker spec.attribs[1].stride = 0;
105*35238bceSAndroid Build Coastguard Worker spec.attribs[1].normalize = false;
106*35238bceSAndroid Build Coastguard Worker spec.attribs[1].instanceDivisor = 0;
107*35238bceSAndroid Build Coastguard Worker spec.attribs[1].useDefaultAttribute = false;
108*35238bceSAndroid Build Coastguard Worker }
109*35238bceSAndroid Build Coastguard Worker
110*35238bceSAndroid Build Coastguard Worker class AttributeGroup : public TestCaseGroup
111*35238bceSAndroid Build Coastguard Worker {
112*35238bceSAndroid Build Coastguard Worker public:
113*35238bceSAndroid Build Coastguard Worker AttributeGroup(Context &context, const char *name, const char *descr, gls::DrawTestSpec::DrawMethod drawMethod,
114*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Primitive primitive, gls::DrawTestSpec::IndexType indexType,
115*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Storage indexStorage);
116*35238bceSAndroid Build Coastguard Worker ~AttributeGroup(void);
117*35238bceSAndroid Build Coastguard Worker
118*35238bceSAndroid Build Coastguard Worker void init(void);
119*35238bceSAndroid Build Coastguard Worker
120*35238bceSAndroid Build Coastguard Worker private:
121*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod m_method;
122*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Primitive m_primitive;
123*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::IndexType m_indexType;
124*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Storage m_indexStorage;
125*35238bceSAndroid Build Coastguard Worker };
126*35238bceSAndroid Build Coastguard Worker
AttributeGroup(Context & context,const char * name,const char * descr,gls::DrawTestSpec::DrawMethod drawMethod,gls::DrawTestSpec::Primitive primitive,gls::DrawTestSpec::IndexType indexType,gls::DrawTestSpec::Storage indexStorage)127*35238bceSAndroid Build Coastguard Worker AttributeGroup::AttributeGroup(Context &context, const char *name, const char *descr,
128*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod drawMethod, gls::DrawTestSpec::Primitive primitive,
129*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::IndexType indexType, gls::DrawTestSpec::Storage indexStorage)
130*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, name, descr)
131*35238bceSAndroid Build Coastguard Worker , m_method(drawMethod)
132*35238bceSAndroid Build Coastguard Worker , m_primitive(primitive)
133*35238bceSAndroid Build Coastguard Worker , m_indexType(indexType)
134*35238bceSAndroid Build Coastguard Worker , m_indexStorage(indexStorage)
135*35238bceSAndroid Build Coastguard Worker {
136*35238bceSAndroid Build Coastguard Worker }
137*35238bceSAndroid Build Coastguard Worker
~AttributeGroup(void)138*35238bceSAndroid Build Coastguard Worker AttributeGroup::~AttributeGroup(void)
139*35238bceSAndroid Build Coastguard Worker {
140*35238bceSAndroid Build Coastguard Worker }
141*35238bceSAndroid Build Coastguard Worker
init(void)142*35238bceSAndroid Build Coastguard Worker void AttributeGroup::init(void)
143*35238bceSAndroid Build Coastguard Worker {
144*35238bceSAndroid Build Coastguard Worker // Single attribute
145*35238bceSAndroid Build Coastguard Worker {
146*35238bceSAndroid Build Coastguard Worker gls::DrawTest *test =
147*35238bceSAndroid Build Coastguard Worker new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "single_attribute", "Single attribute array.");
148*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec;
149*35238bceSAndroid Build Coastguard Worker
150*35238bceSAndroid Build Coastguard Worker spec.apiType = glu::ApiType::es(2, 0);
151*35238bceSAndroid Build Coastguard Worker spec.primitive = m_primitive;
152*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = 0;
153*35238bceSAndroid Build Coastguard Worker spec.drawMethod = m_method;
154*35238bceSAndroid Build Coastguard Worker spec.indexType = m_indexType;
155*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = 0;
156*35238bceSAndroid Build Coastguard Worker spec.indexStorage = m_indexStorage;
157*35238bceSAndroid Build Coastguard Worker spec.first = 0;
158*35238bceSAndroid Build Coastguard Worker spec.indexMin = 0;
159*35238bceSAndroid Build Coastguard Worker spec.indexMax = 0;
160*35238bceSAndroid Build Coastguard Worker spec.instanceCount = 1;
161*35238bceSAndroid Build Coastguard Worker
162*35238bceSAndroid Build Coastguard Worker spec.attribs.resize(1);
163*35238bceSAndroid Build Coastguard Worker
164*35238bceSAndroid Build Coastguard Worker spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT;
165*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2;
166*35238bceSAndroid Build Coastguard Worker spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER;
167*35238bceSAndroid Build Coastguard Worker spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW;
168*35238bceSAndroid Build Coastguard Worker spec.attribs[0].componentCount = 2;
169*35238bceSAndroid Build Coastguard Worker spec.attribs[0].offset = 0;
170*35238bceSAndroid Build Coastguard Worker spec.attribs[0].stride = 0;
171*35238bceSAndroid Build Coastguard Worker spec.attribs[0].normalize = false;
172*35238bceSAndroid Build Coastguard Worker spec.attribs[0].instanceDivisor = 0;
173*35238bceSAndroid Build Coastguard Worker spec.attribs[0].useDefaultAttribute = false;
174*35238bceSAndroid Build Coastguard Worker
175*35238bceSAndroid Build Coastguard Worker addTestIterations(test, spec, TYPE_DRAW_COUNT);
176*35238bceSAndroid Build Coastguard Worker
177*35238bceSAndroid Build Coastguard Worker this->addChild(test);
178*35238bceSAndroid Build Coastguard Worker }
179*35238bceSAndroid Build Coastguard Worker
180*35238bceSAndroid Build Coastguard Worker // Multiple attribute
181*35238bceSAndroid Build Coastguard Worker {
182*35238bceSAndroid Build Coastguard Worker gls::DrawTest *test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "multiple_attributes",
183*35238bceSAndroid Build Coastguard Worker "Multiple attribute arrays");
184*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec;
185*35238bceSAndroid Build Coastguard Worker
186*35238bceSAndroid Build Coastguard Worker spec.apiType = glu::ApiType::es(2, 0);
187*35238bceSAndroid Build Coastguard Worker spec.primitive = m_primitive;
188*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = 0;
189*35238bceSAndroid Build Coastguard Worker spec.drawMethod = m_method;
190*35238bceSAndroid Build Coastguard Worker spec.indexType = m_indexType;
191*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = 0;
192*35238bceSAndroid Build Coastguard Worker spec.indexStorage = m_indexStorage;
193*35238bceSAndroid Build Coastguard Worker spec.first = 0;
194*35238bceSAndroid Build Coastguard Worker spec.indexMin = 0;
195*35238bceSAndroid Build Coastguard Worker spec.indexMax = 0;
196*35238bceSAndroid Build Coastguard Worker spec.instanceCount = 1;
197*35238bceSAndroid Build Coastguard Worker
198*35238bceSAndroid Build Coastguard Worker spec.attribs.resize(2);
199*35238bceSAndroid Build Coastguard Worker
200*35238bceSAndroid Build Coastguard Worker spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT;
201*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2;
202*35238bceSAndroid Build Coastguard Worker spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER;
203*35238bceSAndroid Build Coastguard Worker spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW;
204*35238bceSAndroid Build Coastguard Worker spec.attribs[0].componentCount = 4;
205*35238bceSAndroid Build Coastguard Worker spec.attribs[0].offset = 0;
206*35238bceSAndroid Build Coastguard Worker spec.attribs[0].stride = 0;
207*35238bceSAndroid Build Coastguard Worker spec.attribs[0].normalize = false;
208*35238bceSAndroid Build Coastguard Worker spec.attribs[0].instanceDivisor = 0;
209*35238bceSAndroid Build Coastguard Worker spec.attribs[0].useDefaultAttribute = false;
210*35238bceSAndroid Build Coastguard Worker
211*35238bceSAndroid Build Coastguard Worker spec.attribs[1].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT;
212*35238bceSAndroid Build Coastguard Worker spec.attribs[1].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2;
213*35238bceSAndroid Build Coastguard Worker spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER;
214*35238bceSAndroid Build Coastguard Worker spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW;
215*35238bceSAndroid Build Coastguard Worker spec.attribs[1].componentCount = 2;
216*35238bceSAndroid Build Coastguard Worker spec.attribs[1].offset = 0;
217*35238bceSAndroid Build Coastguard Worker spec.attribs[1].stride = 0;
218*35238bceSAndroid Build Coastguard Worker spec.attribs[1].normalize = false;
219*35238bceSAndroid Build Coastguard Worker spec.attribs[1].instanceDivisor = 0;
220*35238bceSAndroid Build Coastguard Worker spec.attribs[1].useDefaultAttribute = false;
221*35238bceSAndroid Build Coastguard Worker
222*35238bceSAndroid Build Coastguard Worker addTestIterations(test, spec, TYPE_DRAW_COUNT);
223*35238bceSAndroid Build Coastguard Worker
224*35238bceSAndroid Build Coastguard Worker this->addChild(test);
225*35238bceSAndroid Build Coastguard Worker }
226*35238bceSAndroid Build Coastguard Worker
227*35238bceSAndroid Build Coastguard Worker // Multiple attribute, second one default.
228*35238bceSAndroid Build Coastguard Worker {
229*35238bceSAndroid Build Coastguard Worker gls::DrawTest *test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "default_attribute",
230*35238bceSAndroid Build Coastguard Worker "Attribute specified with glVertexAttrib*.");
231*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec;
232*35238bceSAndroid Build Coastguard Worker
233*35238bceSAndroid Build Coastguard Worker spec.apiType = glu::ApiType::es(2, 0);
234*35238bceSAndroid Build Coastguard Worker spec.primitive = m_primitive;
235*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = 5;
236*35238bceSAndroid Build Coastguard Worker spec.drawMethod = m_method;
237*35238bceSAndroid Build Coastguard Worker spec.indexType = m_indexType;
238*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = 0;
239*35238bceSAndroid Build Coastguard Worker spec.indexStorage = m_indexStorage;
240*35238bceSAndroid Build Coastguard Worker spec.first = 0;
241*35238bceSAndroid Build Coastguard Worker spec.indexMin = 0;
242*35238bceSAndroid Build Coastguard Worker spec.indexMax = 0;
243*35238bceSAndroid Build Coastguard Worker spec.instanceCount = 1;
244*35238bceSAndroid Build Coastguard Worker
245*35238bceSAndroid Build Coastguard Worker spec.attribs.resize(2);
246*35238bceSAndroid Build Coastguard Worker
247*35238bceSAndroid Build Coastguard Worker spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT;
248*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2;
249*35238bceSAndroid Build Coastguard Worker spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER;
250*35238bceSAndroid Build Coastguard Worker spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW;
251*35238bceSAndroid Build Coastguard Worker spec.attribs[0].componentCount = 2;
252*35238bceSAndroid Build Coastguard Worker spec.attribs[0].offset = 0;
253*35238bceSAndroid Build Coastguard Worker spec.attribs[0].stride = 0;
254*35238bceSAndroid Build Coastguard Worker spec.attribs[0].normalize = false;
255*35238bceSAndroid Build Coastguard Worker spec.attribs[0].instanceDivisor = 0;
256*35238bceSAndroid Build Coastguard Worker spec.attribs[0].useDefaultAttribute = false;
257*35238bceSAndroid Build Coastguard Worker
258*35238bceSAndroid Build Coastguard Worker struct IOPair
259*35238bceSAndroid Build Coastguard Worker {
260*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::InputType input;
261*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OutputType output;
262*35238bceSAndroid Build Coastguard Worker int componentCount;
263*35238bceSAndroid Build Coastguard Worker } iopairs[] = {
264*35238bceSAndroid Build Coastguard Worker {gls::DrawTestSpec::INPUTTYPE_FLOAT, gls::DrawTestSpec::OUTPUTTYPE_VEC2, 4},
265*35238bceSAndroid Build Coastguard Worker {gls::DrawTestSpec::INPUTTYPE_FLOAT, gls::DrawTestSpec::OUTPUTTYPE_VEC4, 2},
266*35238bceSAndroid Build Coastguard Worker };
267*35238bceSAndroid Build Coastguard Worker
268*35238bceSAndroid Build Coastguard Worker for (int ioNdx = 0; ioNdx < DE_LENGTH_OF_ARRAY(iopairs); ++ioNdx)
269*35238bceSAndroid Build Coastguard Worker {
270*35238bceSAndroid Build Coastguard Worker const std::string desc = gls::DrawTestSpec::inputTypeToString(iopairs[ioNdx].input) +
271*35238bceSAndroid Build Coastguard Worker de::toString(iopairs[ioNdx].componentCount) + " to " +
272*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::outputTypeToString(iopairs[ioNdx].output);
273*35238bceSAndroid Build Coastguard Worker
274*35238bceSAndroid Build Coastguard Worker spec.attribs[1].inputType = iopairs[ioNdx].input;
275*35238bceSAndroid Build Coastguard Worker spec.attribs[1].outputType = iopairs[ioNdx].output;
276*35238bceSAndroid Build Coastguard Worker spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER;
277*35238bceSAndroid Build Coastguard Worker spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW;
278*35238bceSAndroid Build Coastguard Worker spec.attribs[1].componentCount = iopairs[ioNdx].componentCount;
279*35238bceSAndroid Build Coastguard Worker spec.attribs[1].offset = 0;
280*35238bceSAndroid Build Coastguard Worker spec.attribs[1].stride = 0;
281*35238bceSAndroid Build Coastguard Worker spec.attribs[1].normalize = false;
282*35238bceSAndroid Build Coastguard Worker spec.attribs[1].instanceDivisor = 0;
283*35238bceSAndroid Build Coastguard Worker spec.attribs[1].useDefaultAttribute = true;
284*35238bceSAndroid Build Coastguard Worker
285*35238bceSAndroid Build Coastguard Worker test->addIteration(spec, desc.c_str());
286*35238bceSAndroid Build Coastguard Worker }
287*35238bceSAndroid Build Coastguard Worker
288*35238bceSAndroid Build Coastguard Worker this->addChild(test);
289*35238bceSAndroid Build Coastguard Worker }
290*35238bceSAndroid Build Coastguard Worker }
291*35238bceSAndroid Build Coastguard Worker
292*35238bceSAndroid Build Coastguard Worker class IndexGroup : public TestCaseGroup
293*35238bceSAndroid Build Coastguard Worker {
294*35238bceSAndroid Build Coastguard Worker public:
295*35238bceSAndroid Build Coastguard Worker IndexGroup(Context &context, const char *name, const char *descr, gls::DrawTestSpec::DrawMethod drawMethod);
296*35238bceSAndroid Build Coastguard Worker ~IndexGroup(void);
297*35238bceSAndroid Build Coastguard Worker
298*35238bceSAndroid Build Coastguard Worker void init(void);
299*35238bceSAndroid Build Coastguard Worker
300*35238bceSAndroid Build Coastguard Worker private:
301*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod m_method;
302*35238bceSAndroid Build Coastguard Worker };
303*35238bceSAndroid Build Coastguard Worker
IndexGroup(Context & context,const char * name,const char * descr,gls::DrawTestSpec::DrawMethod drawMethod)304*35238bceSAndroid Build Coastguard Worker IndexGroup::IndexGroup(Context &context, const char *name, const char *descr, gls::DrawTestSpec::DrawMethod drawMethod)
305*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, name, descr)
306*35238bceSAndroid Build Coastguard Worker , m_method(drawMethod)
307*35238bceSAndroid Build Coastguard Worker {
308*35238bceSAndroid Build Coastguard Worker }
309*35238bceSAndroid Build Coastguard Worker
~IndexGroup(void)310*35238bceSAndroid Build Coastguard Worker IndexGroup::~IndexGroup(void)
311*35238bceSAndroid Build Coastguard Worker {
312*35238bceSAndroid Build Coastguard Worker }
313*35238bceSAndroid Build Coastguard Worker
init(void)314*35238bceSAndroid Build Coastguard Worker void IndexGroup::init(void)
315*35238bceSAndroid Build Coastguard Worker {
316*35238bceSAndroid Build Coastguard Worker struct IndexTest
317*35238bceSAndroid Build Coastguard Worker {
318*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Storage storage;
319*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::IndexType type;
320*35238bceSAndroid Build Coastguard Worker bool aligned;
321*35238bceSAndroid Build Coastguard Worker int offsets[3];
322*35238bceSAndroid Build Coastguard Worker };
323*35238bceSAndroid Build Coastguard Worker
324*35238bceSAndroid Build Coastguard Worker const IndexTest tests[] = {
325*35238bceSAndroid Build Coastguard Worker {gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_BYTE, true, {0, 1, -1}},
326*35238bceSAndroid Build Coastguard Worker {gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_SHORT, true, {0, 2, -1}},
327*35238bceSAndroid Build Coastguard Worker
328*35238bceSAndroid Build Coastguard Worker {gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_SHORT, false, {1, 3, -1}},
329*35238bceSAndroid Build Coastguard Worker
330*35238bceSAndroid Build Coastguard Worker {gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_BYTE, true, {0, 1, -1}},
331*35238bceSAndroid Build Coastguard Worker {gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_SHORT, true, {0, 2, -1}},
332*35238bceSAndroid Build Coastguard Worker };
333*35238bceSAndroid Build Coastguard Worker
334*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec;
335*35238bceSAndroid Build Coastguard Worker
336*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *userPtrGroup = new tcu::TestCaseGroup(m_testCtx, "user_ptr", "user pointer");
337*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *unalignedUserPtrGroup =
338*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "unaligned_user_ptr", "unaligned user pointer");
339*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *bufferGroup = new tcu::TestCaseGroup(m_testCtx, "buffer", "buffer");
340*35238bceSAndroid Build Coastguard Worker
341*35238bceSAndroid Build Coastguard Worker genBasicSpec(spec, m_method);
342*35238bceSAndroid Build Coastguard Worker
343*35238bceSAndroid Build Coastguard Worker this->addChild(userPtrGroup);
344*35238bceSAndroid Build Coastguard Worker this->addChild(unalignedUserPtrGroup);
345*35238bceSAndroid Build Coastguard Worker this->addChild(bufferGroup);
346*35238bceSAndroid Build Coastguard Worker
347*35238bceSAndroid Build Coastguard Worker for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(tests); ++testNdx)
348*35238bceSAndroid Build Coastguard Worker {
349*35238bceSAndroid Build Coastguard Worker const IndexTest &indexTest = tests[testNdx];
350*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *group = (indexTest.storage == gls::DrawTestSpec::STORAGE_USER) ?
351*35238bceSAndroid Build Coastguard Worker ((indexTest.aligned) ? (userPtrGroup) : (unalignedUserPtrGroup)) :
352*35238bceSAndroid Build Coastguard Worker ((indexTest.aligned) ? (bufferGroup) : (DE_NULL));
353*35238bceSAndroid Build Coastguard Worker
354*35238bceSAndroid Build Coastguard Worker const std::string name = std::string("index_") + gls::DrawTestSpec::indexTypeToString(indexTest.type);
355*35238bceSAndroid Build Coastguard Worker const std::string desc = std::string("index ") + gls::DrawTestSpec::indexTypeToString(indexTest.type) + " in " +
356*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::storageToString(indexTest.storage);
357*35238bceSAndroid Build Coastguard Worker de::MovePtr<gls::DrawTest> test(
358*35238bceSAndroid Build Coastguard Worker new gls::DrawTest(m_testCtx, m_context.getRenderContext(), name.c_str(), desc.c_str()));
359*35238bceSAndroid Build Coastguard Worker
360*35238bceSAndroid Build Coastguard Worker spec.indexType = indexTest.type;
361*35238bceSAndroid Build Coastguard Worker spec.indexStorage = indexTest.storage;
362*35238bceSAndroid Build Coastguard Worker
363*35238bceSAndroid Build Coastguard Worker for (int iterationNdx = 0;
364*35238bceSAndroid Build Coastguard Worker iterationNdx < DE_LENGTH_OF_ARRAY(indexTest.offsets) && indexTest.offsets[iterationNdx] != -1;
365*35238bceSAndroid Build Coastguard Worker ++iterationNdx)
366*35238bceSAndroid Build Coastguard Worker {
367*35238bceSAndroid Build Coastguard Worker const std::string iterationDesc = std::string("offset ") + de::toString(indexTest.offsets[iterationNdx]);
368*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = indexTest.offsets[iterationNdx];
369*35238bceSAndroid Build Coastguard Worker test->addIteration(spec, iterationDesc.c_str());
370*35238bceSAndroid Build Coastguard Worker }
371*35238bceSAndroid Build Coastguard Worker
372*35238bceSAndroid Build Coastguard Worker DE_ASSERT(spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET);
373*35238bceSAndroid Build Coastguard Worker DE_ASSERT(spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE);
374*35238bceSAndroid Build Coastguard Worker group->addChild(test.release());
375*35238bceSAndroid Build Coastguard Worker }
376*35238bceSAndroid Build Coastguard Worker }
377*35238bceSAndroid Build Coastguard Worker
378*35238bceSAndroid Build Coastguard Worker class FirstGroup : public TestCaseGroup
379*35238bceSAndroid Build Coastguard Worker {
380*35238bceSAndroid Build Coastguard Worker public:
381*35238bceSAndroid Build Coastguard Worker FirstGroup(Context &context, const char *name, const char *descr, gls::DrawTestSpec::DrawMethod drawMethod);
382*35238bceSAndroid Build Coastguard Worker ~FirstGroup(void);
383*35238bceSAndroid Build Coastguard Worker
384*35238bceSAndroid Build Coastguard Worker void init(void);
385*35238bceSAndroid Build Coastguard Worker
386*35238bceSAndroid Build Coastguard Worker private:
387*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod m_method;
388*35238bceSAndroid Build Coastguard Worker };
389*35238bceSAndroid Build Coastguard Worker
FirstGroup(Context & context,const char * name,const char * descr,gls::DrawTestSpec::DrawMethod drawMethod)390*35238bceSAndroid Build Coastguard Worker FirstGroup::FirstGroup(Context &context, const char *name, const char *descr, gls::DrawTestSpec::DrawMethod drawMethod)
391*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, name, descr)
392*35238bceSAndroid Build Coastguard Worker , m_method(drawMethod)
393*35238bceSAndroid Build Coastguard Worker {
394*35238bceSAndroid Build Coastguard Worker }
395*35238bceSAndroid Build Coastguard Worker
~FirstGroup(void)396*35238bceSAndroid Build Coastguard Worker FirstGroup::~FirstGroup(void)
397*35238bceSAndroid Build Coastguard Worker {
398*35238bceSAndroid Build Coastguard Worker }
399*35238bceSAndroid Build Coastguard Worker
init(void)400*35238bceSAndroid Build Coastguard Worker void FirstGroup::init(void)
401*35238bceSAndroid Build Coastguard Worker {
402*35238bceSAndroid Build Coastguard Worker const int firsts[] = {0, 1, 17};
403*35238bceSAndroid Build Coastguard Worker
404*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec;
405*35238bceSAndroid Build Coastguard Worker genBasicSpec(spec, m_method);
406*35238bceSAndroid Build Coastguard Worker
407*35238bceSAndroid Build Coastguard Worker for (int firstNdx = 0; firstNdx < DE_LENGTH_OF_ARRAY(firsts); ++firstNdx)
408*35238bceSAndroid Build Coastguard Worker {
409*35238bceSAndroid Build Coastguard Worker const std::string name = std::string("first_") + de::toString(firsts[firstNdx]);
410*35238bceSAndroid Build Coastguard Worker const std::string desc = std::string("first ") + de::toString(firsts[firstNdx]);
411*35238bceSAndroid Build Coastguard Worker gls::DrawTest *test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), name.c_str(), desc.c_str());
412*35238bceSAndroid Build Coastguard Worker
413*35238bceSAndroid Build Coastguard Worker spec.first = firsts[firstNdx];
414*35238bceSAndroid Build Coastguard Worker
415*35238bceSAndroid Build Coastguard Worker addTestIterations(test, spec, TYPE_DRAW_COUNT);
416*35238bceSAndroid Build Coastguard Worker
417*35238bceSAndroid Build Coastguard Worker this->addChild(test);
418*35238bceSAndroid Build Coastguard Worker }
419*35238bceSAndroid Build Coastguard Worker }
420*35238bceSAndroid Build Coastguard Worker
421*35238bceSAndroid Build Coastguard Worker class MethodGroup : public TestCaseGroup
422*35238bceSAndroid Build Coastguard Worker {
423*35238bceSAndroid Build Coastguard Worker public:
424*35238bceSAndroid Build Coastguard Worker MethodGroup(Context &context, const char *name, const char *descr, gls::DrawTestSpec::DrawMethod drawMethod);
425*35238bceSAndroid Build Coastguard Worker ~MethodGroup(void);
426*35238bceSAndroid Build Coastguard Worker
427*35238bceSAndroid Build Coastguard Worker void init(void);
428*35238bceSAndroid Build Coastguard Worker
429*35238bceSAndroid Build Coastguard Worker private:
430*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod m_method;
431*35238bceSAndroid Build Coastguard Worker };
432*35238bceSAndroid Build Coastguard Worker
MethodGroup(Context & context,const char * name,const char * descr,gls::DrawTestSpec::DrawMethod drawMethod)433*35238bceSAndroid Build Coastguard Worker MethodGroup::MethodGroup(Context &context, const char *name, const char *descr,
434*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod drawMethod)
435*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, name, descr)
436*35238bceSAndroid Build Coastguard Worker , m_method(drawMethod)
437*35238bceSAndroid Build Coastguard Worker {
438*35238bceSAndroid Build Coastguard Worker }
439*35238bceSAndroid Build Coastguard Worker
~MethodGroup(void)440*35238bceSAndroid Build Coastguard Worker MethodGroup::~MethodGroup(void)
441*35238bceSAndroid Build Coastguard Worker {
442*35238bceSAndroid Build Coastguard Worker }
443*35238bceSAndroid Build Coastguard Worker
init(void)444*35238bceSAndroid Build Coastguard Worker void MethodGroup::init(void)
445*35238bceSAndroid Build Coastguard Worker {
446*35238bceSAndroid Build Coastguard Worker const bool indexed = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS) ||
447*35238bceSAndroid Build Coastguard Worker (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INSTANCED) ||
448*35238bceSAndroid Build Coastguard Worker (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED);
449*35238bceSAndroid Build Coastguard Worker const bool hasFirst = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS) ||
450*35238bceSAndroid Build Coastguard Worker (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INSTANCED);
451*35238bceSAndroid Build Coastguard Worker
452*35238bceSAndroid Build Coastguard Worker const gls::DrawTestSpec::Primitive primitive[] = {
453*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_POINTS, gls::DrawTestSpec::PRIMITIVE_TRIANGLES,
454*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN, gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP,
455*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_LINES, gls::DrawTestSpec::PRIMITIVE_LINE_STRIP,
456*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_LINE_LOOP};
457*35238bceSAndroid Build Coastguard Worker
458*35238bceSAndroid Build Coastguard Worker if (hasFirst)
459*35238bceSAndroid Build Coastguard Worker {
460*35238bceSAndroid Build Coastguard Worker // First-tests
461*35238bceSAndroid Build Coastguard Worker this->addChild(new FirstGroup(m_context, "first", "First tests", m_method));
462*35238bceSAndroid Build Coastguard Worker }
463*35238bceSAndroid Build Coastguard Worker
464*35238bceSAndroid Build Coastguard Worker if (indexed)
465*35238bceSAndroid Build Coastguard Worker {
466*35238bceSAndroid Build Coastguard Worker // Index-tests
467*35238bceSAndroid Build Coastguard Worker if (m_method != gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED)
468*35238bceSAndroid Build Coastguard Worker this->addChild(new IndexGroup(m_context, "indices", "Index tests", m_method));
469*35238bceSAndroid Build Coastguard Worker }
470*35238bceSAndroid Build Coastguard Worker
471*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(primitive); ++ndx)
472*35238bceSAndroid Build Coastguard Worker {
473*35238bceSAndroid Build Coastguard Worker const std::string name = gls::DrawTestSpec::primitiveToString(primitive[ndx]);
474*35238bceSAndroid Build Coastguard Worker const std::string desc = gls::DrawTestSpec::primitiveToString(primitive[ndx]);
475*35238bceSAndroid Build Coastguard Worker
476*35238bceSAndroid Build Coastguard Worker this->addChild(new AttributeGroup(m_context, name.c_str(), desc.c_str(), m_method, primitive[ndx],
477*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INDEXTYPE_SHORT, gls::DrawTestSpec::STORAGE_BUFFER));
478*35238bceSAndroid Build Coastguard Worker }
479*35238bceSAndroid Build Coastguard Worker }
480*35238bceSAndroid Build Coastguard Worker
481*35238bceSAndroid Build Coastguard Worker class RandomGroup : public TestCaseGroup
482*35238bceSAndroid Build Coastguard Worker {
483*35238bceSAndroid Build Coastguard Worker public:
484*35238bceSAndroid Build Coastguard Worker RandomGroup(Context &context, const char *name, const char *descr);
485*35238bceSAndroid Build Coastguard Worker ~RandomGroup(void);
486*35238bceSAndroid Build Coastguard Worker
487*35238bceSAndroid Build Coastguard Worker void init(void);
488*35238bceSAndroid Build Coastguard Worker };
489*35238bceSAndroid Build Coastguard Worker
490*35238bceSAndroid Build Coastguard Worker template <int SIZE>
491*35238bceSAndroid Build Coastguard Worker struct UniformWeightArray
492*35238bceSAndroid Build Coastguard Worker {
493*35238bceSAndroid Build Coastguard Worker float weights[SIZE];
494*35238bceSAndroid Build Coastguard Worker
UniformWeightArraydeqp::gles2::Functional::__anon5cf4d8b80111::UniformWeightArray495*35238bceSAndroid Build Coastguard Worker UniformWeightArray(void)
496*35238bceSAndroid Build Coastguard Worker {
497*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < SIZE; ++i)
498*35238bceSAndroid Build Coastguard Worker weights[i] = 1.0f;
499*35238bceSAndroid Build Coastguard Worker }
500*35238bceSAndroid Build Coastguard Worker };
501*35238bceSAndroid Build Coastguard Worker
RandomGroup(Context & context,const char * name,const char * descr)502*35238bceSAndroid Build Coastguard Worker RandomGroup::RandomGroup(Context &context, const char *name, const char *descr) : TestCaseGroup(context, name, descr)
503*35238bceSAndroid Build Coastguard Worker {
504*35238bceSAndroid Build Coastguard Worker }
505*35238bceSAndroid Build Coastguard Worker
~RandomGroup(void)506*35238bceSAndroid Build Coastguard Worker RandomGroup::~RandomGroup(void)
507*35238bceSAndroid Build Coastguard Worker {
508*35238bceSAndroid Build Coastguard Worker }
509*35238bceSAndroid Build Coastguard Worker
init(void)510*35238bceSAndroid Build Coastguard Worker void RandomGroup::init(void)
511*35238bceSAndroid Build Coastguard Worker {
512*35238bceSAndroid Build Coastguard Worker const int numAttempts = 100;
513*35238bceSAndroid Build Coastguard Worker
514*35238bceSAndroid Build Coastguard Worker static const int attribCounts[] = {1, 2, 5};
515*35238bceSAndroid Build Coastguard Worker static const float attribWeights[] = {30, 10, 1};
516*35238bceSAndroid Build Coastguard Worker static const int primitiveCounts[] = {1, 5, 64};
517*35238bceSAndroid Build Coastguard Worker static const float primitiveCountWeights[] = {20, 10, 1};
518*35238bceSAndroid Build Coastguard Worker static const int indexOffsets[] = {0, 7, 13};
519*35238bceSAndroid Build Coastguard Worker static const float indexOffsetWeights[] = {20, 20, 1};
520*35238bceSAndroid Build Coastguard Worker static const int firsts[] = {0, 7, 13};
521*35238bceSAndroid Build Coastguard Worker static const float firstWeights[] = {20, 20, 1};
522*35238bceSAndroid Build Coastguard Worker static const int offsets[] = {0, 1, 5, 12};
523*35238bceSAndroid Build Coastguard Worker static const float offsetWeights[] = {50, 10, 10, 10};
524*35238bceSAndroid Build Coastguard Worker static const int strides[] = {0, 7, 16, 17};
525*35238bceSAndroid Build Coastguard Worker static const float strideWeights[] = {50, 10, 10, 10};
526*35238bceSAndroid Build Coastguard Worker
527*35238bceSAndroid Build Coastguard Worker static const gls::DrawTestSpec::Primitive primitives[] = {
528*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_POINTS, gls::DrawTestSpec::PRIMITIVE_TRIANGLES,
529*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN, gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP,
530*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_LINES, gls::DrawTestSpec::PRIMITIVE_LINE_STRIP,
531*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_LINE_LOOP};
532*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(primitives)> primitiveWeights;
533*35238bceSAndroid Build Coastguard Worker
534*35238bceSAndroid Build Coastguard Worker static const gls::DrawTestSpec::DrawMethod drawMethods[] = {
535*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS,
536*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS,
537*35238bceSAndroid Build Coastguard Worker };
538*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(drawMethods)> drawMethodWeights;
539*35238bceSAndroid Build Coastguard Worker
540*35238bceSAndroid Build Coastguard Worker static const gls::DrawTestSpec::IndexType indexTypes[] = {
541*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INDEXTYPE_BYTE,
542*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INDEXTYPE_SHORT,
543*35238bceSAndroid Build Coastguard Worker };
544*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(indexTypes)> indexTypeWeights;
545*35238bceSAndroid Build Coastguard Worker
546*35238bceSAndroid Build Coastguard Worker static const gls::DrawTestSpec::Storage storages[] = {
547*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::STORAGE_USER,
548*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::STORAGE_BUFFER,
549*35238bceSAndroid Build Coastguard Worker };
550*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(storages)> storageWeights;
551*35238bceSAndroid Build Coastguard Worker
552*35238bceSAndroid Build Coastguard Worker static const gls::DrawTestSpec::InputType inputTypes[] = {
553*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_FLOAT, gls::DrawTestSpec::INPUTTYPE_FIXED,
554*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_BYTE, gls::DrawTestSpec::INPUTTYPE_SHORT,
555*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_UNSIGNED_BYTE, gls::DrawTestSpec::INPUTTYPE_UNSIGNED_SHORT};
556*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(inputTypes)> inputTypeWeights;
557*35238bceSAndroid Build Coastguard Worker
558*35238bceSAndroid Build Coastguard Worker static const gls::DrawTestSpec::OutputType outputTypes[] = {
559*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_FLOAT,
560*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_VEC2,
561*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_VEC3,
562*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_VEC4,
563*35238bceSAndroid Build Coastguard Worker };
564*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(outputTypes)> outputTypeWeights;
565*35238bceSAndroid Build Coastguard Worker
566*35238bceSAndroid Build Coastguard Worker static const gls::DrawTestSpec::Usage usages[] = {
567*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_STATIC_DRAW,
568*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_DYNAMIC_DRAW,
569*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_STREAM_DRAW,
570*35238bceSAndroid Build Coastguard Worker };
571*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(usages)> usageWeights;
572*35238bceSAndroid Build Coastguard Worker
573*35238bceSAndroid Build Coastguard Worker static const uint32_t disallowedCases[] = {
574*35238bceSAndroid Build Coastguard Worker 3153, //!< extremely narrow triangle, results depend on sample positions
575*35238bceSAndroid Build Coastguard Worker };
576*35238bceSAndroid Build Coastguard Worker
577*35238bceSAndroid Build Coastguard Worker std::set<uint32_t> insertedHashes;
578*35238bceSAndroid Build Coastguard Worker size_t insertedCount = 0;
579*35238bceSAndroid Build Coastguard Worker
580*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numAttempts; ++ndx)
581*35238bceSAndroid Build Coastguard Worker {
582*35238bceSAndroid Build Coastguard Worker de::Random random(0xc551393 + ndx); // random does not depend on previous cases
583*35238bceSAndroid Build Coastguard Worker
584*35238bceSAndroid Build Coastguard Worker int attributeCount = random.chooseWeighted<int, const int *, const float *>(
585*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(attribCounts), DE_ARRAY_END(attribCounts), attribWeights);
586*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec;
587*35238bceSAndroid Build Coastguard Worker
588*35238bceSAndroid Build Coastguard Worker spec.apiType = glu::ApiType::es(2, 0);
589*35238bceSAndroid Build Coastguard Worker spec.primitive = random.chooseWeighted<gls::DrawTestSpec::Primitive>(
590*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(primitives), DE_ARRAY_END(primitives), primitiveWeights.weights);
591*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = random.chooseWeighted<int, const int *, const float *>(
592*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(primitiveCounts), DE_ARRAY_END(primitiveCounts), primitiveCountWeights);
593*35238bceSAndroid Build Coastguard Worker spec.drawMethod = random.chooseWeighted<gls::DrawTestSpec::DrawMethod>(
594*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(drawMethods), DE_ARRAY_END(drawMethods), drawMethodWeights.weights);
595*35238bceSAndroid Build Coastguard Worker spec.indexType = random.chooseWeighted<gls::DrawTestSpec::IndexType>(
596*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(indexTypes), DE_ARRAY_END(indexTypes), indexTypeWeights.weights);
597*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = random.chooseWeighted<int, const int *, const float *>(
598*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(indexOffsets), DE_ARRAY_END(indexOffsets), indexOffsetWeights);
599*35238bceSAndroid Build Coastguard Worker spec.indexStorage = random.chooseWeighted<gls::DrawTestSpec::Storage>(
600*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(storages), DE_ARRAY_END(storages), storageWeights.weights);
601*35238bceSAndroid Build Coastguard Worker spec.first = random.chooseWeighted<int, const int *, const float *>(DE_ARRAY_BEGIN(firsts),
602*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(firsts), firstWeights);
603*35238bceSAndroid Build Coastguard Worker spec.indexMin = 0;
604*35238bceSAndroid Build Coastguard Worker spec.indexMax = 0;
605*35238bceSAndroid Build Coastguard Worker spec.instanceCount = 0;
606*35238bceSAndroid Build Coastguard Worker
607*35238bceSAndroid Build Coastguard Worker // check spec is legal
608*35238bceSAndroid Build Coastguard Worker if (!spec.valid())
609*35238bceSAndroid Build Coastguard Worker continue;
610*35238bceSAndroid Build Coastguard Worker
611*35238bceSAndroid Build Coastguard Worker for (int attrNdx = 0; attrNdx < attributeCount;)
612*35238bceSAndroid Build Coastguard Worker {
613*35238bceSAndroid Build Coastguard Worker bool valid;
614*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::AttributeSpec attribSpec;
615*35238bceSAndroid Build Coastguard Worker
616*35238bceSAndroid Build Coastguard Worker attribSpec.inputType = random.chooseWeighted<gls::DrawTestSpec::InputType>(
617*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(inputTypes), DE_ARRAY_END(inputTypes), inputTypeWeights.weights);
618*35238bceSAndroid Build Coastguard Worker attribSpec.outputType = random.chooseWeighted<gls::DrawTestSpec::OutputType>(
619*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(outputTypes), DE_ARRAY_END(outputTypes), outputTypeWeights.weights);
620*35238bceSAndroid Build Coastguard Worker attribSpec.storage = random.chooseWeighted<gls::DrawTestSpec::Storage>(
621*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(storages), DE_ARRAY_END(storages), storageWeights.weights);
622*35238bceSAndroid Build Coastguard Worker attribSpec.usage = random.chooseWeighted<gls::DrawTestSpec::Usage>(
623*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(usages), DE_ARRAY_END(usages), usageWeights.weights);
624*35238bceSAndroid Build Coastguard Worker attribSpec.componentCount = random.getInt(1, 4);
625*35238bceSAndroid Build Coastguard Worker attribSpec.offset = random.chooseWeighted<int, const int *, const float *>(
626*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(offsets), DE_ARRAY_END(offsets), offsetWeights);
627*35238bceSAndroid Build Coastguard Worker attribSpec.stride = random.chooseWeighted<int, const int *, const float *>(
628*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(strides), DE_ARRAY_END(strides), strideWeights);
629*35238bceSAndroid Build Coastguard Worker attribSpec.normalize = random.getBool();
630*35238bceSAndroid Build Coastguard Worker attribSpec.instanceDivisor = 0;
631*35238bceSAndroid Build Coastguard Worker attribSpec.useDefaultAttribute = random.getBool();
632*35238bceSAndroid Build Coastguard Worker
633*35238bceSAndroid Build Coastguard Worker // check spec is legal
634*35238bceSAndroid Build Coastguard Worker valid = attribSpec.valid(spec.apiType);
635*35238bceSAndroid Build Coastguard Worker
636*35238bceSAndroid Build Coastguard Worker // we do not want interleaved elements. (Might result in some weird floating point values)
637*35238bceSAndroid Build Coastguard Worker if (attribSpec.stride &&
638*35238bceSAndroid Build Coastguard Worker attribSpec.componentCount * gls::DrawTestSpec::inputTypeSize(attribSpec.inputType) > attribSpec.stride)
639*35238bceSAndroid Build Coastguard Worker valid = false;
640*35238bceSAndroid Build Coastguard Worker
641*35238bceSAndroid Build Coastguard Worker // try again if not valid
642*35238bceSAndroid Build Coastguard Worker if (valid)
643*35238bceSAndroid Build Coastguard Worker {
644*35238bceSAndroid Build Coastguard Worker spec.attribs.push_back(attribSpec);
645*35238bceSAndroid Build Coastguard Worker ++attrNdx;
646*35238bceSAndroid Build Coastguard Worker }
647*35238bceSAndroid Build Coastguard Worker }
648*35238bceSAndroid Build Coastguard Worker
649*35238bceSAndroid Build Coastguard Worker // Do not collapse all vertex positions to a single positions
650*35238bceSAndroid Build Coastguard Worker if (spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS)
651*35238bceSAndroid Build Coastguard Worker spec.attribs[0].instanceDivisor = 0;
652*35238bceSAndroid Build Coastguard Worker
653*35238bceSAndroid Build Coastguard Worker // Is render result meaningful?
654*35238bceSAndroid Build Coastguard Worker {
655*35238bceSAndroid Build Coastguard Worker // Only one vertex
656*35238bceSAndroid Build Coastguard Worker if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED &&
657*35238bceSAndroid Build Coastguard Worker spec.indexMin == spec.indexMax && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS)
658*35238bceSAndroid Build Coastguard Worker continue;
659*35238bceSAndroid Build Coastguard Worker if (spec.attribs[0].useDefaultAttribute && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS)
660*35238bceSAndroid Build Coastguard Worker continue;
661*35238bceSAndroid Build Coastguard Worker
662*35238bceSAndroid Build Coastguard Worker // Triangle only on one axis
663*35238bceSAndroid Build Coastguard Worker if (spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLES ||
664*35238bceSAndroid Build Coastguard Worker spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN ||
665*35238bceSAndroid Build Coastguard Worker spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP)
666*35238bceSAndroid Build Coastguard Worker {
667*35238bceSAndroid Build Coastguard Worker if (spec.attribs[0].componentCount == 1)
668*35238bceSAndroid Build Coastguard Worker continue;
669*35238bceSAndroid Build Coastguard Worker if (spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_FLOAT ||
670*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_INT ||
671*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_UINT)
672*35238bceSAndroid Build Coastguard Worker continue;
673*35238bceSAndroid Build Coastguard Worker if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED &&
674*35238bceSAndroid Build Coastguard Worker (spec.indexMax - spec.indexMin) < 2)
675*35238bceSAndroid Build Coastguard Worker continue;
676*35238bceSAndroid Build Coastguard Worker }
677*35238bceSAndroid Build Coastguard Worker }
678*35238bceSAndroid Build Coastguard Worker
679*35238bceSAndroid Build Coastguard Worker // Add case
680*35238bceSAndroid Build Coastguard Worker {
681*35238bceSAndroid Build Coastguard Worker uint32_t hash = spec.hash();
682*35238bceSAndroid Build Coastguard Worker for (int attrNdx = 0; attrNdx < attributeCount; ++attrNdx)
683*35238bceSAndroid Build Coastguard Worker hash = (hash << 2) ^ (uint32_t)spec.attribs[attrNdx].hash();
684*35238bceSAndroid Build Coastguard Worker
685*35238bceSAndroid Build Coastguard Worker if (insertedHashes.find(hash) == insertedHashes.end() &&
686*35238bceSAndroid Build Coastguard Worker !de::contains(DE_ARRAY_BEGIN(disallowedCases), DE_ARRAY_END(disallowedCases), hash))
687*35238bceSAndroid Build Coastguard Worker {
688*35238bceSAndroid Build Coastguard Worker // Only aligned cases
689*35238bceSAndroid Build Coastguard Worker if (spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET &&
690*35238bceSAndroid Build Coastguard Worker spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE)
691*35238bceSAndroid Build Coastguard Worker this->addChild(new gls::DrawTest(m_testCtx, m_context.getRenderContext(), spec,
692*35238bceSAndroid Build Coastguard Worker de::toString(insertedCount).c_str(), spec.getDesc().c_str()));
693*35238bceSAndroid Build Coastguard Worker insertedHashes.insert(hash);
694*35238bceSAndroid Build Coastguard Worker
695*35238bceSAndroid Build Coastguard Worker ++insertedCount;
696*35238bceSAndroid Build Coastguard Worker }
697*35238bceSAndroid Build Coastguard Worker }
698*35238bceSAndroid Build Coastguard Worker }
699*35238bceSAndroid Build Coastguard Worker }
700*35238bceSAndroid Build Coastguard Worker
701*35238bceSAndroid Build Coastguard Worker } // namespace
702*35238bceSAndroid Build Coastguard Worker
DrawTests(Context & context)703*35238bceSAndroid Build Coastguard Worker DrawTests::DrawTests(Context &context) : TestCaseGroup(context, "draw", "Drawing tests")
704*35238bceSAndroid Build Coastguard Worker {
705*35238bceSAndroid Build Coastguard Worker }
706*35238bceSAndroid Build Coastguard Worker
~DrawTests(void)707*35238bceSAndroid Build Coastguard Worker DrawTests::~DrawTests(void)
708*35238bceSAndroid Build Coastguard Worker {
709*35238bceSAndroid Build Coastguard Worker }
710*35238bceSAndroid Build Coastguard Worker
init(void)711*35238bceSAndroid Build Coastguard Worker void DrawTests::init(void)
712*35238bceSAndroid Build Coastguard Worker {
713*35238bceSAndroid Build Coastguard Worker // Basic
714*35238bceSAndroid Build Coastguard Worker {
715*35238bceSAndroid Build Coastguard Worker const gls::DrawTestSpec::DrawMethod basicMethods[] = {
716*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS,
717*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS,
718*35238bceSAndroid Build Coastguard Worker };
719*35238bceSAndroid Build Coastguard Worker
720*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(basicMethods); ++ndx)
721*35238bceSAndroid Build Coastguard Worker {
722*35238bceSAndroid Build Coastguard Worker std::string name = gls::DrawTestSpec::drawMethodToString(basicMethods[ndx]);
723*35238bceSAndroid Build Coastguard Worker std::string desc = gls::DrawTestSpec::drawMethodToString(basicMethods[ndx]);
724*35238bceSAndroid Build Coastguard Worker
725*35238bceSAndroid Build Coastguard Worker this->addChild(new MethodGroup(m_context, name.c_str(), desc.c_str(), basicMethods[ndx]));
726*35238bceSAndroid Build Coastguard Worker }
727*35238bceSAndroid Build Coastguard Worker }
728*35238bceSAndroid Build Coastguard Worker
729*35238bceSAndroid Build Coastguard Worker // Random
730*35238bceSAndroid Build Coastguard Worker
731*35238bceSAndroid Build Coastguard Worker this->addChild(new RandomGroup(m_context, "random", "random draw commands."));
732*35238bceSAndroid Build Coastguard Worker }
733*35238bceSAndroid Build Coastguard Worker
734*35238bceSAndroid Build Coastguard Worker } // namespace Functional
735*35238bceSAndroid Build Coastguard Worker } // namespace gles2
736*35238bceSAndroid Build Coastguard Worker } // namespace deqp
737