1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 3.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 Draw stress tests
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es3sDrawTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "tcuVector.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluCallLogWrapper.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "gluObjectWrapper.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "glsDrawTest.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "deUniquePtr.hpp"
41*35238bceSAndroid Build Coastguard Worker
42*35238bceSAndroid Build Coastguard Worker #include <set>
43*35238bceSAndroid Build Coastguard Worker
44*35238bceSAndroid Build Coastguard Worker namespace deqp
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker namespace gles3
47*35238bceSAndroid Build Coastguard Worker {
48*35238bceSAndroid Build Coastguard Worker namespace Stress
49*35238bceSAndroid Build Coastguard Worker {
50*35238bceSAndroid Build Coastguard Worker namespace
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker
53*35238bceSAndroid Build Coastguard Worker static const char *const s_vertexSource = "#version 300 es\n"
54*35238bceSAndroid Build Coastguard Worker "in highp vec4 a_position;\n"
55*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
56*35238bceSAndroid Build Coastguard Worker "{\n"
57*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
58*35238bceSAndroid Build Coastguard Worker "}\n";
59*35238bceSAndroid Build Coastguard Worker static const char *const s_fragmentSource = "#version 300 es\n"
60*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out mediump vec4 fragColor;\n"
61*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
62*35238bceSAndroid Build Coastguard Worker "{\n"
63*35238bceSAndroid Build Coastguard Worker " fragColor = vec4(1.0, 1.0, 1.0, 1.0);\n"
64*35238bceSAndroid Build Coastguard Worker "}\n";
65*35238bceSAndroid Build Coastguard Worker
66*35238bceSAndroid Build Coastguard Worker class DrawInvalidRangeCase : public TestCase
67*35238bceSAndroid Build Coastguard Worker {
68*35238bceSAndroid Build Coastguard Worker public:
69*35238bceSAndroid Build Coastguard Worker DrawInvalidRangeCase(Context &ctx, const char *name, const char *desc, uint32_t min, uint32_t max,
70*35238bceSAndroid Build Coastguard Worker bool useLimitMin = false, bool useLimitMax = false);
71*35238bceSAndroid Build Coastguard Worker ~DrawInvalidRangeCase(void);
72*35238bceSAndroid Build Coastguard Worker
73*35238bceSAndroid Build Coastguard Worker void init(void);
74*35238bceSAndroid Build Coastguard Worker void deinit(void);
75*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
76*35238bceSAndroid Build Coastguard Worker
77*35238bceSAndroid Build Coastguard Worker private:
78*35238bceSAndroid Build Coastguard Worker const int m_min;
79*35238bceSAndroid Build Coastguard Worker const int m_max;
80*35238bceSAndroid Build Coastguard Worker const int m_bufferedElements;
81*35238bceSAndroid Build Coastguard Worker const int m_numIndices;
82*35238bceSAndroid Build Coastguard Worker const bool m_useLimitMin;
83*35238bceSAndroid Build Coastguard Worker const bool m_useLimitMax;
84*35238bceSAndroid Build Coastguard Worker
85*35238bceSAndroid Build Coastguard Worker uint32_t m_buffer;
86*35238bceSAndroid Build Coastguard Worker uint32_t m_indexBuffer;
87*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram *m_program;
88*35238bceSAndroid Build Coastguard Worker };
89*35238bceSAndroid Build Coastguard Worker
DrawInvalidRangeCase(Context & ctx,const char * name,const char * desc,uint32_t min,uint32_t max,bool useLimitMin,bool useLimitMax)90*35238bceSAndroid Build Coastguard Worker DrawInvalidRangeCase::DrawInvalidRangeCase(Context &ctx, const char *name, const char *desc, uint32_t min, uint32_t max,
91*35238bceSAndroid Build Coastguard Worker bool useLimitMin, bool useLimitMax)
92*35238bceSAndroid Build Coastguard Worker : TestCase(ctx, name, desc)
93*35238bceSAndroid Build Coastguard Worker , m_min(min)
94*35238bceSAndroid Build Coastguard Worker , m_max(max)
95*35238bceSAndroid Build Coastguard Worker , m_bufferedElements(128)
96*35238bceSAndroid Build Coastguard Worker , m_numIndices(64)
97*35238bceSAndroid Build Coastguard Worker , m_useLimitMin(useLimitMin)
98*35238bceSAndroid Build Coastguard Worker , m_useLimitMax(useLimitMax)
99*35238bceSAndroid Build Coastguard Worker , m_buffer(0)
100*35238bceSAndroid Build Coastguard Worker , m_indexBuffer(0)
101*35238bceSAndroid Build Coastguard Worker , m_program(DE_NULL)
102*35238bceSAndroid Build Coastguard Worker {
103*35238bceSAndroid Build Coastguard Worker }
104*35238bceSAndroid Build Coastguard Worker
~DrawInvalidRangeCase(void)105*35238bceSAndroid Build Coastguard Worker DrawInvalidRangeCase::~DrawInvalidRangeCase(void)
106*35238bceSAndroid Build Coastguard Worker {
107*35238bceSAndroid Build Coastguard Worker deinit();
108*35238bceSAndroid Build Coastguard Worker }
109*35238bceSAndroid Build Coastguard Worker
init(void)110*35238bceSAndroid Build Coastguard Worker void DrawInvalidRangeCase::init(void)
111*35238bceSAndroid Build Coastguard Worker {
112*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
113*35238bceSAndroid Build Coastguard Worker std::vector<tcu::Vec4> data(m_bufferedElements); // !< some junk data to make sure buffer is really allocated
114*35238bceSAndroid Build Coastguard Worker std::vector<uint32_t> indices(m_numIndices);
115*35238bceSAndroid Build Coastguard Worker
116*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < m_numIndices; ++ndx)
117*35238bceSAndroid Build Coastguard Worker indices[ndx] = ndx;
118*35238bceSAndroid Build Coastguard Worker
119*35238bceSAndroid Build Coastguard Worker gl.genBuffers(1, &m_buffer);
120*35238bceSAndroid Build Coastguard Worker gl.bindBuffer(GL_ARRAY_BUFFER, m_buffer);
121*35238bceSAndroid Build Coastguard Worker gl.bufferData(GL_ARRAY_BUFFER, int(m_bufferedElements * sizeof(tcu::Vec4)), &data[0], GL_STATIC_DRAW);
122*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "buffer gen");
123*35238bceSAndroid Build Coastguard Worker
124*35238bceSAndroid Build Coastguard Worker gl.genBuffers(1, &m_indexBuffer);
125*35238bceSAndroid Build Coastguard Worker gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer);
126*35238bceSAndroid Build Coastguard Worker gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, int(m_numIndices * sizeof(uint32_t)), &indices[0], GL_STATIC_DRAW);
127*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "buffer gen");
128*35238bceSAndroid Build Coastguard Worker
129*35238bceSAndroid Build Coastguard Worker m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::ProgramSources()
130*35238bceSAndroid Build Coastguard Worker << glu::VertexSource(s_vertexSource)
131*35238bceSAndroid Build Coastguard Worker << glu::FragmentSource(s_fragmentSource));
132*35238bceSAndroid Build Coastguard Worker if (!m_program->isOk())
133*35238bceSAndroid Build Coastguard Worker {
134*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << *m_program;
135*35238bceSAndroid Build Coastguard Worker throw tcu::TestError("could not build program");
136*35238bceSAndroid Build Coastguard Worker }
137*35238bceSAndroid Build Coastguard Worker }
138*35238bceSAndroid Build Coastguard Worker
deinit(void)139*35238bceSAndroid Build Coastguard Worker void DrawInvalidRangeCase::deinit(void)
140*35238bceSAndroid Build Coastguard Worker {
141*35238bceSAndroid Build Coastguard Worker if (m_buffer)
142*35238bceSAndroid Build Coastguard Worker {
143*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_buffer);
144*35238bceSAndroid Build Coastguard Worker m_buffer = 0;
145*35238bceSAndroid Build Coastguard Worker }
146*35238bceSAndroid Build Coastguard Worker
147*35238bceSAndroid Build Coastguard Worker if (m_indexBuffer)
148*35238bceSAndroid Build Coastguard Worker {
149*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_indexBuffer);
150*35238bceSAndroid Build Coastguard Worker m_indexBuffer = 0;
151*35238bceSAndroid Build Coastguard Worker }
152*35238bceSAndroid Build Coastguard Worker
153*35238bceSAndroid Build Coastguard Worker delete m_program;
154*35238bceSAndroid Build Coastguard Worker m_program = DE_NULL;
155*35238bceSAndroid Build Coastguard Worker }
156*35238bceSAndroid Build Coastguard Worker
iterate(void)157*35238bceSAndroid Build Coastguard Worker DrawInvalidRangeCase::IterateResult DrawInvalidRangeCase::iterate(void)
158*35238bceSAndroid Build Coastguard Worker {
159*35238bceSAndroid Build Coastguard Worker glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
160*35238bceSAndroid Build Coastguard Worker const int32_t positionLoc = gl.glGetAttribLocation(m_program->getProgram(), "a_position");
161*35238bceSAndroid Build Coastguard Worker tcu::Surface dst(m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight());
162*35238bceSAndroid Build Coastguard Worker glu::VertexArray vao(m_context.getRenderContext());
163*35238bceSAndroid Build Coastguard Worker
164*35238bceSAndroid Build Coastguard Worker int64_t indexLimit = 0;
165*35238bceSAndroid Build Coastguard Worker uint32_t min = m_min;
166*35238bceSAndroid Build Coastguard Worker uint32_t max = m_max;
167*35238bceSAndroid Build Coastguard Worker
168*35238bceSAndroid Build Coastguard Worker gl.enableLogging(true);
169*35238bceSAndroid Build Coastguard Worker
170*35238bceSAndroid Build Coastguard Worker if (m_useLimitMin || m_useLimitMax)
171*35238bceSAndroid Build Coastguard Worker {
172*35238bceSAndroid Build Coastguard Worker gl.glGetInteger64v(GL_MAX_ELEMENT_INDEX, &indexLimit);
173*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.glGetError(), "query limit");
174*35238bceSAndroid Build Coastguard Worker }
175*35238bceSAndroid Build Coastguard Worker
176*35238bceSAndroid Build Coastguard Worker if (m_useLimitMin)
177*35238bceSAndroid Build Coastguard Worker {
178*35238bceSAndroid Build Coastguard Worker if ((uint64_t)indexLimit > 0xFFFFFFFFULL)
179*35238bceSAndroid Build Coastguard Worker min = 0xFFFFFFF0;
180*35238bceSAndroid Build Coastguard Worker else
181*35238bceSAndroid Build Coastguard Worker min = (uint32_t)(indexLimit - 16);
182*35238bceSAndroid Build Coastguard Worker }
183*35238bceSAndroid Build Coastguard Worker
184*35238bceSAndroid Build Coastguard Worker if (m_useLimitMax)
185*35238bceSAndroid Build Coastguard Worker {
186*35238bceSAndroid Build Coastguard Worker if ((uint64_t)indexLimit > 0xFFFFFFFFULL)
187*35238bceSAndroid Build Coastguard Worker max = 0xFFFFFFFF;
188*35238bceSAndroid Build Coastguard Worker else
189*35238bceSAndroid Build Coastguard Worker max = (uint32_t)indexLimit;
190*35238bceSAndroid Build Coastguard Worker }
191*35238bceSAndroid Build Coastguard Worker
192*35238bceSAndroid Build Coastguard Worker gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
193*35238bceSAndroid Build Coastguard Worker gl.glClear(GL_COLOR_BUFFER_BIT);
194*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.glGetError(), "setup");
195*35238bceSAndroid Build Coastguard Worker
196*35238bceSAndroid Build Coastguard Worker gl.glUseProgram(m_program->getProgram());
197*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.glGetError(), "use program");
198*35238bceSAndroid Build Coastguard Worker
199*35238bceSAndroid Build Coastguard Worker gl.glBindVertexArray(*vao);
200*35238bceSAndroid Build Coastguard Worker gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer);
201*35238bceSAndroid Build Coastguard Worker
202*35238bceSAndroid Build Coastguard Worker gl.glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
203*35238bceSAndroid Build Coastguard Worker gl.glEnableVertexAttribArray(positionLoc);
204*35238bceSAndroid Build Coastguard Worker gl.glVertexAttribPointer(positionLoc, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
205*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.glGetError(), "set buffer");
206*35238bceSAndroid Build Coastguard Worker
207*35238bceSAndroid Build Coastguard Worker gl.glDrawRangeElements(GL_POINTS, min, max, m_numIndices, GL_UNSIGNED_INT, DE_NULL);
208*35238bceSAndroid Build Coastguard Worker
209*35238bceSAndroid Build Coastguard Worker // Indexing outside range is an error, but it doesnt need to be checked. Causes implementation-dependent behavior.
210*35238bceSAndroid Build Coastguard Worker // Even if the indices are in range (m_min = 0), the specification allows partial processing of vertices in the range,
211*35238bceSAndroid Build Coastguard Worker // which might cause access over buffer bounds. Causes implementation-dependent behavior.
212*35238bceSAndroid Build Coastguard Worker
213*35238bceSAndroid Build Coastguard Worker // allow errors
214*35238bceSAndroid Build Coastguard Worker {
215*35238bceSAndroid Build Coastguard Worker const uint32_t error = gl.glGetError();
216*35238bceSAndroid Build Coastguard Worker
217*35238bceSAndroid Build Coastguard Worker if (error != GL_NO_ERROR)
218*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "Got error: " << glu::getErrorStr(error) << ", ignoring..."
219*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
220*35238bceSAndroid Build Coastguard Worker }
221*35238bceSAndroid Build Coastguard Worker
222*35238bceSAndroid Build Coastguard Worker // read pixels to wait for rendering
223*35238bceSAndroid Build Coastguard Worker gl.glFinish();
224*35238bceSAndroid Build Coastguard Worker glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess());
225*35238bceSAndroid Build Coastguard Worker
226*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
227*35238bceSAndroid Build Coastguard Worker return STOP;
228*35238bceSAndroid Build Coastguard Worker }
229*35238bceSAndroid Build Coastguard Worker
genBasicSpec(gls::DrawTestSpec & spec,gls::DrawTestSpec::DrawMethod method)230*35238bceSAndroid Build Coastguard Worker static void genBasicSpec(gls::DrawTestSpec &spec, gls::DrawTestSpec::DrawMethod method)
231*35238bceSAndroid Build Coastguard Worker {
232*35238bceSAndroid Build Coastguard Worker spec.apiType = glu::ApiType::es(3, 0);
233*35238bceSAndroid Build Coastguard Worker spec.primitive = gls::DrawTestSpec::PRIMITIVE_TRIANGLES;
234*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = 5;
235*35238bceSAndroid Build Coastguard Worker spec.drawMethod = method;
236*35238bceSAndroid Build Coastguard Worker spec.indexType = gls::DrawTestSpec::INDEXTYPE_LAST;
237*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = 0;
238*35238bceSAndroid Build Coastguard Worker spec.indexStorage = gls::DrawTestSpec::STORAGE_LAST;
239*35238bceSAndroid Build Coastguard Worker spec.first = 0;
240*35238bceSAndroid Build Coastguard Worker spec.indexMin = 0;
241*35238bceSAndroid Build Coastguard Worker spec.indexMax = 0;
242*35238bceSAndroid Build Coastguard Worker spec.instanceCount = 1;
243*35238bceSAndroid Build Coastguard Worker
244*35238bceSAndroid Build Coastguard Worker spec.attribs.resize(2);
245*35238bceSAndroid Build Coastguard Worker
246*35238bceSAndroid Build Coastguard Worker spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT;
247*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2;
248*35238bceSAndroid Build Coastguard Worker spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER;
249*35238bceSAndroid Build Coastguard Worker spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW;
250*35238bceSAndroid Build Coastguard Worker spec.attribs[0].componentCount = 4;
251*35238bceSAndroid Build Coastguard Worker spec.attribs[0].offset = 0;
252*35238bceSAndroid Build Coastguard Worker spec.attribs[0].stride = 0;
253*35238bceSAndroid Build Coastguard Worker spec.attribs[0].normalize = false;
254*35238bceSAndroid Build Coastguard Worker spec.attribs[0].instanceDivisor = 0;
255*35238bceSAndroid Build Coastguard Worker spec.attribs[0].useDefaultAttribute = false;
256*35238bceSAndroid Build Coastguard Worker
257*35238bceSAndroid Build Coastguard Worker spec.attribs[1].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT;
258*35238bceSAndroid Build Coastguard Worker spec.attribs[1].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2;
259*35238bceSAndroid Build Coastguard Worker spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER;
260*35238bceSAndroid Build Coastguard Worker spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW;
261*35238bceSAndroid Build Coastguard Worker spec.attribs[1].componentCount = 2;
262*35238bceSAndroid Build Coastguard Worker spec.attribs[1].offset = 0;
263*35238bceSAndroid Build Coastguard Worker spec.attribs[1].stride = 0;
264*35238bceSAndroid Build Coastguard Worker spec.attribs[1].normalize = false;
265*35238bceSAndroid Build Coastguard Worker spec.attribs[1].instanceDivisor = 0;
266*35238bceSAndroid Build Coastguard Worker spec.attribs[1].useDefaultAttribute = false;
267*35238bceSAndroid Build Coastguard Worker }
268*35238bceSAndroid Build Coastguard Worker
269*35238bceSAndroid Build Coastguard Worker class IndexGroup : public TestCaseGroup
270*35238bceSAndroid Build Coastguard Worker {
271*35238bceSAndroid Build Coastguard Worker public:
272*35238bceSAndroid Build Coastguard Worker IndexGroup(Context &context, const char *name, const char *descr, gls::DrawTestSpec::DrawMethod drawMethod);
273*35238bceSAndroid Build Coastguard Worker ~IndexGroup(void);
274*35238bceSAndroid Build Coastguard Worker
275*35238bceSAndroid Build Coastguard Worker void init(void);
276*35238bceSAndroid Build Coastguard Worker
277*35238bceSAndroid Build Coastguard Worker private:
278*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod m_method;
279*35238bceSAndroid Build Coastguard Worker };
280*35238bceSAndroid Build Coastguard Worker
IndexGroup(Context & context,const char * name,const char * descr,gls::DrawTestSpec::DrawMethod drawMethod)281*35238bceSAndroid Build Coastguard Worker IndexGroup::IndexGroup(Context &context, const char *name, const char *descr, gls::DrawTestSpec::DrawMethod drawMethod)
282*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, name, descr)
283*35238bceSAndroid Build Coastguard Worker , m_method(drawMethod)
284*35238bceSAndroid Build Coastguard Worker {
285*35238bceSAndroid Build Coastguard Worker }
286*35238bceSAndroid Build Coastguard Worker
~IndexGroup(void)287*35238bceSAndroid Build Coastguard Worker IndexGroup::~IndexGroup(void)
288*35238bceSAndroid Build Coastguard Worker {
289*35238bceSAndroid Build Coastguard Worker }
290*35238bceSAndroid Build Coastguard Worker
init(void)291*35238bceSAndroid Build Coastguard Worker void IndexGroup::init(void)
292*35238bceSAndroid Build Coastguard Worker {
293*35238bceSAndroid Build Coastguard Worker struct IndexTest
294*35238bceSAndroid Build Coastguard Worker {
295*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Storage storage;
296*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::IndexType type;
297*35238bceSAndroid Build Coastguard Worker bool aligned;
298*35238bceSAndroid Build Coastguard Worker int offsets[3];
299*35238bceSAndroid Build Coastguard Worker };
300*35238bceSAndroid Build Coastguard Worker
301*35238bceSAndroid Build Coastguard Worker const IndexTest tests[] = {
302*35238bceSAndroid Build Coastguard Worker {gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_SHORT, false, {1, 3, -1}},
303*35238bceSAndroid Build Coastguard Worker {gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_INT, false, {2, 3, -1}},
304*35238bceSAndroid Build Coastguard Worker };
305*35238bceSAndroid Build Coastguard Worker
306*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec;
307*35238bceSAndroid Build Coastguard Worker
308*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const unalignedBufferGroup =
309*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "unaligned_buffer", "unaligned buffer");
310*35238bceSAndroid Build Coastguard Worker const bool isRangedMethod = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED ||
311*35238bceSAndroid Build Coastguard Worker m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED_BASEVERTEX);
312*35238bceSAndroid Build Coastguard Worker
313*35238bceSAndroid Build Coastguard Worker genBasicSpec(spec, m_method);
314*35238bceSAndroid Build Coastguard Worker
315*35238bceSAndroid Build Coastguard Worker this->addChild(unalignedBufferGroup);
316*35238bceSAndroid Build Coastguard Worker
317*35238bceSAndroid Build Coastguard Worker for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(tests); ++testNdx)
318*35238bceSAndroid Build Coastguard Worker {
319*35238bceSAndroid Build Coastguard Worker const IndexTest &indexTest = tests[testNdx];
320*35238bceSAndroid Build Coastguard Worker
321*35238bceSAndroid Build Coastguard Worker DE_ASSERT(indexTest.storage != gls::DrawTestSpec::STORAGE_USER);
322*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!indexTest.aligned);
323*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *group = unalignedBufferGroup;
324*35238bceSAndroid Build Coastguard Worker
325*35238bceSAndroid Build Coastguard Worker const std::string name = std::string("index_") + gls::DrawTestSpec::indexTypeToString(indexTest.type);
326*35238bceSAndroid Build Coastguard Worker const std::string desc = std::string("index ") + gls::DrawTestSpec::indexTypeToString(indexTest.type) + " in " +
327*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::storageToString(indexTest.storage);
328*35238bceSAndroid Build Coastguard Worker de::MovePtr<gls::DrawTest> test(
329*35238bceSAndroid Build Coastguard Worker new gls::DrawTest(m_testCtx, m_context.getRenderContext(), name.c_str(), desc.c_str()));
330*35238bceSAndroid Build Coastguard Worker
331*35238bceSAndroid Build Coastguard Worker spec.indexType = indexTest.type;
332*35238bceSAndroid Build Coastguard Worker spec.indexStorage = indexTest.storage;
333*35238bceSAndroid Build Coastguard Worker
334*35238bceSAndroid Build Coastguard Worker if (isRangedMethod)
335*35238bceSAndroid Build Coastguard Worker {
336*35238bceSAndroid Build Coastguard Worker spec.indexMin = 0;
337*35238bceSAndroid Build Coastguard Worker spec.indexMax = 55;
338*35238bceSAndroid Build Coastguard Worker }
339*35238bceSAndroid Build Coastguard Worker
340*35238bceSAndroid Build Coastguard Worker for (int iterationNdx = 0;
341*35238bceSAndroid Build Coastguard Worker iterationNdx < DE_LENGTH_OF_ARRAY(indexTest.offsets) && indexTest.offsets[iterationNdx] != -1;
342*35238bceSAndroid Build Coastguard Worker ++iterationNdx)
343*35238bceSAndroid Build Coastguard Worker {
344*35238bceSAndroid Build Coastguard Worker const std::string iterationDesc = std::string("offset ") + de::toString(indexTest.offsets[iterationNdx]);
345*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = indexTest.offsets[iterationNdx];
346*35238bceSAndroid Build Coastguard Worker test->addIteration(spec, iterationDesc.c_str());
347*35238bceSAndroid Build Coastguard Worker }
348*35238bceSAndroid Build Coastguard Worker
349*35238bceSAndroid Build Coastguard Worker DE_ASSERT(spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET ||
350*35238bceSAndroid Build Coastguard Worker spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE);
351*35238bceSAndroid Build Coastguard Worker group->addChild(test.release());
352*35238bceSAndroid Build Coastguard Worker }
353*35238bceSAndroid Build Coastguard Worker }
354*35238bceSAndroid Build Coastguard Worker
355*35238bceSAndroid Build Coastguard Worker class MethodGroup : public TestCaseGroup
356*35238bceSAndroid Build Coastguard Worker {
357*35238bceSAndroid Build Coastguard Worker public:
358*35238bceSAndroid Build Coastguard Worker MethodGroup(Context &context, const char *name, const char *descr, gls::DrawTestSpec::DrawMethod drawMethod);
359*35238bceSAndroid Build Coastguard Worker ~MethodGroup(void);
360*35238bceSAndroid Build Coastguard Worker
361*35238bceSAndroid Build Coastguard Worker void init(void);
362*35238bceSAndroid Build Coastguard Worker
363*35238bceSAndroid Build Coastguard Worker private:
364*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod m_method;
365*35238bceSAndroid Build Coastguard Worker };
366*35238bceSAndroid Build Coastguard Worker
MethodGroup(Context & context,const char * name,const char * descr,gls::DrawTestSpec::DrawMethod drawMethod)367*35238bceSAndroid Build Coastguard Worker MethodGroup::MethodGroup(Context &context, const char *name, const char *descr,
368*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod drawMethod)
369*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(context, name, descr)
370*35238bceSAndroid Build Coastguard Worker , m_method(drawMethod)
371*35238bceSAndroid Build Coastguard Worker {
372*35238bceSAndroid Build Coastguard Worker }
373*35238bceSAndroid Build Coastguard Worker
~MethodGroup(void)374*35238bceSAndroid Build Coastguard Worker MethodGroup::~MethodGroup(void)
375*35238bceSAndroid Build Coastguard Worker {
376*35238bceSAndroid Build Coastguard Worker }
377*35238bceSAndroid Build Coastguard Worker
init(void)378*35238bceSAndroid Build Coastguard Worker void MethodGroup::init(void)
379*35238bceSAndroid Build Coastguard Worker {
380*35238bceSAndroid Build Coastguard Worker const bool indexed = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS) ||
381*35238bceSAndroid Build Coastguard Worker (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INSTANCED) ||
382*35238bceSAndroid Build Coastguard Worker (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED);
383*35238bceSAndroid Build Coastguard Worker
384*35238bceSAndroid Build Coastguard Worker DE_ASSERT(indexed);
385*35238bceSAndroid Build Coastguard Worker DE_UNREF(indexed);
386*35238bceSAndroid Build Coastguard Worker
387*35238bceSAndroid Build Coastguard Worker this->addChild(new IndexGroup(m_context, "indices", "Index tests", m_method));
388*35238bceSAndroid Build Coastguard Worker }
389*35238bceSAndroid Build Coastguard Worker
390*35238bceSAndroid Build Coastguard Worker class RandomGroup : public TestCaseGroup
391*35238bceSAndroid Build Coastguard Worker {
392*35238bceSAndroid Build Coastguard Worker public:
393*35238bceSAndroid Build Coastguard Worker RandomGroup(Context &context, const char *name, const char *descr);
394*35238bceSAndroid Build Coastguard Worker ~RandomGroup(void);
395*35238bceSAndroid Build Coastguard Worker
396*35238bceSAndroid Build Coastguard Worker void init(void);
397*35238bceSAndroid Build Coastguard Worker };
398*35238bceSAndroid Build Coastguard Worker
399*35238bceSAndroid Build Coastguard Worker template <int SIZE>
400*35238bceSAndroid Build Coastguard Worker struct UniformWeightArray
401*35238bceSAndroid Build Coastguard Worker {
402*35238bceSAndroid Build Coastguard Worker float weights[SIZE];
403*35238bceSAndroid Build Coastguard Worker
UniformWeightArraydeqp::gles3::Stress::__anon697865380111::UniformWeightArray404*35238bceSAndroid Build Coastguard Worker UniformWeightArray(void)
405*35238bceSAndroid Build Coastguard Worker {
406*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < SIZE; ++i)
407*35238bceSAndroid Build Coastguard Worker weights[i] = 1.0f;
408*35238bceSAndroid Build Coastguard Worker }
409*35238bceSAndroid Build Coastguard Worker };
410*35238bceSAndroid Build Coastguard Worker
RandomGroup(Context & context,const char * name,const char * descr)411*35238bceSAndroid Build Coastguard Worker RandomGroup::RandomGroup(Context &context, const char *name, const char *descr) : TestCaseGroup(context, name, descr)
412*35238bceSAndroid Build Coastguard Worker {
413*35238bceSAndroid Build Coastguard Worker }
414*35238bceSAndroid Build Coastguard Worker
~RandomGroup(void)415*35238bceSAndroid Build Coastguard Worker RandomGroup::~RandomGroup(void)
416*35238bceSAndroid Build Coastguard Worker {
417*35238bceSAndroid Build Coastguard Worker }
418*35238bceSAndroid Build Coastguard Worker
init(void)419*35238bceSAndroid Build Coastguard Worker void RandomGroup::init(void)
420*35238bceSAndroid Build Coastguard Worker {
421*35238bceSAndroid Build Coastguard Worker const int numAttempts = 300;
422*35238bceSAndroid Build Coastguard Worker
423*35238bceSAndroid Build Coastguard Worker const int attribCounts[] = {1, 2, 5};
424*35238bceSAndroid Build Coastguard Worker const float attribWeights[] = {30, 10, 1};
425*35238bceSAndroid Build Coastguard Worker const int primitiveCounts[] = {1, 5, 64};
426*35238bceSAndroid Build Coastguard Worker const float primitiveCountWeights[] = {20, 10, 1};
427*35238bceSAndroid Build Coastguard Worker const int indexOffsets[] = {0, 7, 13};
428*35238bceSAndroid Build Coastguard Worker const float indexOffsetWeights[] = {20, 20, 1};
429*35238bceSAndroid Build Coastguard Worker const int firsts[] = {0, 7, 13};
430*35238bceSAndroid Build Coastguard Worker const float firstWeights[] = {20, 20, 1};
431*35238bceSAndroid Build Coastguard Worker const int instanceCounts[] = {1, 2, 16, 17};
432*35238bceSAndroid Build Coastguard Worker const float instanceWeights[] = {20, 10, 5, 1};
433*35238bceSAndroid Build Coastguard Worker const int indexMins[] = {0, 1, 3, 8};
434*35238bceSAndroid Build Coastguard Worker const int indexMaxs[] = {4, 8, 128, 257};
435*35238bceSAndroid Build Coastguard Worker const float indexWeights[] = {50, 50, 50, 50};
436*35238bceSAndroid Build Coastguard Worker const int offsets[] = {0, 1, 5, 12};
437*35238bceSAndroid Build Coastguard Worker const float offsetWeights[] = {50, 10, 10, 10};
438*35238bceSAndroid Build Coastguard Worker const int strides[] = {0, 7, 16, 17};
439*35238bceSAndroid Build Coastguard Worker const float strideWeights[] = {50, 10, 10, 10};
440*35238bceSAndroid Build Coastguard Worker const int instanceDivisors[] = {0, 1, 3, 129};
441*35238bceSAndroid Build Coastguard Worker const float instanceDivisorWeights[] = {70, 30, 10, 10};
442*35238bceSAndroid Build Coastguard Worker
443*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Primitive primitives[] = {
444*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_POINTS, gls::DrawTestSpec::PRIMITIVE_TRIANGLES,
445*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN, gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP,
446*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_LINES, gls::DrawTestSpec::PRIMITIVE_LINE_STRIP,
447*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_LINE_LOOP};
448*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(primitives)> primitiveWeights;
449*35238bceSAndroid Build Coastguard Worker
450*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod drawMethods[] = {
451*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS, gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INSTANCED,
452*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS, gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED,
453*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INSTANCED};
454*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(drawMethods)> drawMethodWeights;
455*35238bceSAndroid Build Coastguard Worker
456*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::IndexType indexTypes[] = {
457*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INDEXTYPE_BYTE,
458*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INDEXTYPE_SHORT,
459*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INDEXTYPE_INT,
460*35238bceSAndroid Build Coastguard Worker };
461*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(indexTypes)> indexTypeWeights;
462*35238bceSAndroid Build Coastguard Worker
463*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Storage storages[] = {
464*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::STORAGE_USER,
465*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::STORAGE_BUFFER,
466*35238bceSAndroid Build Coastguard Worker };
467*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(storages)> storageWeights;
468*35238bceSAndroid Build Coastguard Worker
469*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::InputType inputTypes[] = {
470*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_FLOAT,
471*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_FIXED,
472*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_BYTE,
473*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_SHORT,
474*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_UNSIGNED_BYTE,
475*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_UNSIGNED_SHORT,
476*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_INT,
477*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_UNSIGNED_INT,
478*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_HALF,
479*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_UNSIGNED_INT_2_10_10_10,
480*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_INT_2_10_10_10,
481*35238bceSAndroid Build Coastguard Worker };
482*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(inputTypes)> inputTypeWeights;
483*35238bceSAndroid Build Coastguard Worker
484*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OutputType outputTypes[] = {
485*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_FLOAT, gls::DrawTestSpec::OUTPUTTYPE_VEC2, gls::DrawTestSpec::OUTPUTTYPE_VEC3,
486*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_VEC4, gls::DrawTestSpec::OUTPUTTYPE_INT, gls::DrawTestSpec::OUTPUTTYPE_UINT,
487*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_IVEC2, gls::DrawTestSpec::OUTPUTTYPE_IVEC3, gls::DrawTestSpec::OUTPUTTYPE_IVEC4,
488*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_UVEC2, gls::DrawTestSpec::OUTPUTTYPE_UVEC3, gls::DrawTestSpec::OUTPUTTYPE_UVEC4,
489*35238bceSAndroid Build Coastguard Worker };
490*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(outputTypes)> outputTypeWeights;
491*35238bceSAndroid Build Coastguard Worker
492*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Usage usages[] = {
493*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_DYNAMIC_DRAW, gls::DrawTestSpec::USAGE_STATIC_DRAW,
494*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_STREAM_DRAW, gls::DrawTestSpec::USAGE_STREAM_READ,
495*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_STREAM_COPY, gls::DrawTestSpec::USAGE_STATIC_READ,
496*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_STATIC_COPY, gls::DrawTestSpec::USAGE_DYNAMIC_READ,
497*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_DYNAMIC_COPY,
498*35238bceSAndroid Build Coastguard Worker };
499*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(usages)> usageWeights;
500*35238bceSAndroid Build Coastguard Worker
501*35238bceSAndroid Build Coastguard Worker std::set<uint32_t> insertedHashes;
502*35238bceSAndroid Build Coastguard Worker size_t insertedCount = 0;
503*35238bceSAndroid Build Coastguard Worker
504*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numAttempts; ++ndx)
505*35238bceSAndroid Build Coastguard Worker {
506*35238bceSAndroid Build Coastguard Worker de::Random random(0xc551393 + ndx); // random does not depend on previous cases
507*35238bceSAndroid Build Coastguard Worker
508*35238bceSAndroid Build Coastguard Worker int attributeCount = random.chooseWeighted<int, const int *, const float *>(
509*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(attribCounts), DE_ARRAY_END(attribCounts), attribWeights);
510*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec;
511*35238bceSAndroid Build Coastguard Worker
512*35238bceSAndroid Build Coastguard Worker spec.apiType = glu::ApiType::es(3, 0);
513*35238bceSAndroid Build Coastguard Worker spec.primitive = random.chooseWeighted<gls::DrawTestSpec::Primitive>(
514*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(primitives), DE_ARRAY_END(primitives), primitiveWeights.weights);
515*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = random.chooseWeighted<int, const int *, const float *>(
516*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(primitiveCounts), DE_ARRAY_END(primitiveCounts), primitiveCountWeights);
517*35238bceSAndroid Build Coastguard Worker spec.drawMethod = random.chooseWeighted<gls::DrawTestSpec::DrawMethod>(
518*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(drawMethods), DE_ARRAY_END(drawMethods), drawMethodWeights.weights);
519*35238bceSAndroid Build Coastguard Worker spec.indexType = random.chooseWeighted<gls::DrawTestSpec::IndexType>(
520*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(indexTypes), DE_ARRAY_END(indexTypes), indexTypeWeights.weights);
521*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = random.chooseWeighted<int, const int *, const float *>(
522*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(indexOffsets), DE_ARRAY_END(indexOffsets), indexOffsetWeights);
523*35238bceSAndroid Build Coastguard Worker spec.indexStorage = random.chooseWeighted<gls::DrawTestSpec::Storage>(
524*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(storages), DE_ARRAY_END(storages), storageWeights.weights);
525*35238bceSAndroid Build Coastguard Worker spec.first = random.chooseWeighted<int, const int *, const float *>(DE_ARRAY_BEGIN(firsts),
526*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(firsts), firstWeights);
527*35238bceSAndroid Build Coastguard Worker spec.indexMin = random.chooseWeighted<int, const int *, const float *>(DE_ARRAY_BEGIN(indexMins),
528*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(indexMins), indexWeights);
529*35238bceSAndroid Build Coastguard Worker spec.indexMax = random.chooseWeighted<int, const int *, const float *>(DE_ARRAY_BEGIN(indexMaxs),
530*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(indexMaxs), indexWeights);
531*35238bceSAndroid Build Coastguard Worker spec.instanceCount = random.chooseWeighted<int, const int *, const float *>(
532*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(instanceCounts), DE_ARRAY_END(instanceCounts), instanceWeights);
533*35238bceSAndroid Build Coastguard Worker
534*35238bceSAndroid Build Coastguard Worker // check spec is legal
535*35238bceSAndroid Build Coastguard Worker if (!spec.valid())
536*35238bceSAndroid Build Coastguard Worker continue;
537*35238bceSAndroid Build Coastguard Worker
538*35238bceSAndroid Build Coastguard Worker for (int attrNdx = 0; attrNdx < attributeCount;)
539*35238bceSAndroid Build Coastguard Worker {
540*35238bceSAndroid Build Coastguard Worker bool valid;
541*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::AttributeSpec attribSpec;
542*35238bceSAndroid Build Coastguard Worker
543*35238bceSAndroid Build Coastguard Worker attribSpec.inputType = random.chooseWeighted<gls::DrawTestSpec::InputType>(
544*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(inputTypes), DE_ARRAY_END(inputTypes), inputTypeWeights.weights);
545*35238bceSAndroid Build Coastguard Worker attribSpec.outputType = random.chooseWeighted<gls::DrawTestSpec::OutputType>(
546*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(outputTypes), DE_ARRAY_END(outputTypes), outputTypeWeights.weights);
547*35238bceSAndroid Build Coastguard Worker attribSpec.storage = random.chooseWeighted<gls::DrawTestSpec::Storage>(
548*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(storages), DE_ARRAY_END(storages), storageWeights.weights);
549*35238bceSAndroid Build Coastguard Worker attribSpec.usage = random.chooseWeighted<gls::DrawTestSpec::Usage>(
550*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(usages), DE_ARRAY_END(usages), usageWeights.weights);
551*35238bceSAndroid Build Coastguard Worker attribSpec.componentCount = random.getInt(1, 4);
552*35238bceSAndroid Build Coastguard Worker attribSpec.offset = random.chooseWeighted<int, const int *, const float *>(
553*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(offsets), DE_ARRAY_END(offsets), offsetWeights);
554*35238bceSAndroid Build Coastguard Worker attribSpec.stride = random.chooseWeighted<int, const int *, const float *>(
555*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(strides), DE_ARRAY_END(strides), strideWeights);
556*35238bceSAndroid Build Coastguard Worker attribSpec.normalize = random.getBool();
557*35238bceSAndroid Build Coastguard Worker attribSpec.instanceDivisor = random.chooseWeighted<int, const int *, const float *>(
558*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(instanceDivisors), DE_ARRAY_END(instanceDivisors), instanceDivisorWeights);
559*35238bceSAndroid Build Coastguard Worker attribSpec.useDefaultAttribute = random.getBool();
560*35238bceSAndroid Build Coastguard Worker
561*35238bceSAndroid Build Coastguard Worker // check spec is legal
562*35238bceSAndroid Build Coastguard Worker valid = attribSpec.valid(spec.apiType);
563*35238bceSAndroid Build Coastguard Worker
564*35238bceSAndroid Build Coastguard Worker // we do not want interleaved elements. (Might result in some weird floating point values)
565*35238bceSAndroid Build Coastguard Worker if (attribSpec.stride &&
566*35238bceSAndroid Build Coastguard Worker attribSpec.componentCount * gls::DrawTestSpec::inputTypeSize(attribSpec.inputType) > attribSpec.stride)
567*35238bceSAndroid Build Coastguard Worker valid = false;
568*35238bceSAndroid Build Coastguard Worker
569*35238bceSAndroid Build Coastguard Worker // try again if not valid
570*35238bceSAndroid Build Coastguard Worker if (valid)
571*35238bceSAndroid Build Coastguard Worker {
572*35238bceSAndroid Build Coastguard Worker spec.attribs.push_back(attribSpec);
573*35238bceSAndroid Build Coastguard Worker ++attrNdx;
574*35238bceSAndroid Build Coastguard Worker }
575*35238bceSAndroid Build Coastguard Worker }
576*35238bceSAndroid Build Coastguard Worker
577*35238bceSAndroid Build Coastguard Worker // Do not collapse all vertex positions to a single positions
578*35238bceSAndroid Build Coastguard Worker if (spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS)
579*35238bceSAndroid Build Coastguard Worker spec.attribs[0].instanceDivisor = 0;
580*35238bceSAndroid Build Coastguard Worker
581*35238bceSAndroid Build Coastguard Worker // Is render result meaningful?
582*35238bceSAndroid Build Coastguard Worker {
583*35238bceSAndroid Build Coastguard Worker // Only one vertex
584*35238bceSAndroid Build Coastguard Worker if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED &&
585*35238bceSAndroid Build Coastguard Worker spec.indexMin == spec.indexMax && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS)
586*35238bceSAndroid Build Coastguard Worker continue;
587*35238bceSAndroid Build Coastguard Worker if (spec.attribs[0].useDefaultAttribute && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS)
588*35238bceSAndroid Build Coastguard Worker continue;
589*35238bceSAndroid Build Coastguard Worker
590*35238bceSAndroid Build Coastguard Worker // Triangle only on one axis
591*35238bceSAndroid Build Coastguard Worker if (spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLES ||
592*35238bceSAndroid Build Coastguard Worker spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN ||
593*35238bceSAndroid Build Coastguard Worker spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP)
594*35238bceSAndroid Build Coastguard Worker {
595*35238bceSAndroid Build Coastguard Worker if (spec.attribs[0].componentCount == 1)
596*35238bceSAndroid Build Coastguard Worker continue;
597*35238bceSAndroid Build Coastguard Worker if (spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_FLOAT ||
598*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_INT ||
599*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_UINT)
600*35238bceSAndroid Build Coastguard Worker continue;
601*35238bceSAndroid Build Coastguard Worker if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED &&
602*35238bceSAndroid Build Coastguard Worker (spec.indexMax - spec.indexMin) < 2)
603*35238bceSAndroid Build Coastguard Worker continue;
604*35238bceSAndroid Build Coastguard Worker }
605*35238bceSAndroid Build Coastguard Worker }
606*35238bceSAndroid Build Coastguard Worker
607*35238bceSAndroid Build Coastguard Worker // Add case
608*35238bceSAndroid Build Coastguard Worker {
609*35238bceSAndroid Build Coastguard Worker uint32_t hash = spec.hash();
610*35238bceSAndroid Build Coastguard Worker for (int attrNdx = 0; attrNdx < attributeCount; ++attrNdx)
611*35238bceSAndroid Build Coastguard Worker hash = (hash << 2) ^ (uint32_t)spec.attribs[attrNdx].hash();
612*35238bceSAndroid Build Coastguard Worker
613*35238bceSAndroid Build Coastguard Worker if (insertedHashes.find(hash) == insertedHashes.end())
614*35238bceSAndroid Build Coastguard Worker {
615*35238bceSAndroid Build Coastguard Worker // Only unaligned cases
616*35238bceSAndroid Build Coastguard Worker if (spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET ||
617*35238bceSAndroid Build Coastguard Worker spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE)
618*35238bceSAndroid Build Coastguard Worker this->addChild(new gls::DrawTest(m_testCtx, m_context.getRenderContext(), spec,
619*35238bceSAndroid Build Coastguard Worker de::toString(insertedCount).c_str(), spec.getDesc().c_str()));
620*35238bceSAndroid Build Coastguard Worker insertedHashes.insert(hash);
621*35238bceSAndroid Build Coastguard Worker
622*35238bceSAndroid Build Coastguard Worker ++insertedCount;
623*35238bceSAndroid Build Coastguard Worker }
624*35238bceSAndroid Build Coastguard Worker }
625*35238bceSAndroid Build Coastguard Worker }
626*35238bceSAndroid Build Coastguard Worker }
627*35238bceSAndroid Build Coastguard Worker
628*35238bceSAndroid Build Coastguard Worker } // namespace
629*35238bceSAndroid Build Coastguard Worker
DrawTests(Context & context)630*35238bceSAndroid Build Coastguard Worker DrawTests::DrawTests(Context &context) : TestCaseGroup(context, "draw", "Draw stress tests")
631*35238bceSAndroid Build Coastguard Worker {
632*35238bceSAndroid Build Coastguard Worker }
633*35238bceSAndroid Build Coastguard Worker
~DrawTests(void)634*35238bceSAndroid Build Coastguard Worker DrawTests::~DrawTests(void)
635*35238bceSAndroid Build Coastguard Worker {
636*35238bceSAndroid Build Coastguard Worker }
637*35238bceSAndroid Build Coastguard Worker
init(void)638*35238bceSAndroid Build Coastguard Worker void DrawTests::init(void)
639*35238bceSAndroid Build Coastguard Worker {
640*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const unalignedGroup =
641*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "unaligned_data", "Test with unaligned data");
642*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const drawRangeGroup =
643*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "draw_range_elements", "Test drawRangeElements");
644*35238bceSAndroid Build Coastguard Worker
645*35238bceSAndroid Build Coastguard Worker addChild(unalignedGroup);
646*35238bceSAndroid Build Coastguard Worker addChild(drawRangeGroup);
647*35238bceSAndroid Build Coastguard Worker
648*35238bceSAndroid Build Coastguard Worker // .unaligned_data
649*35238bceSAndroid Build Coastguard Worker {
650*35238bceSAndroid Build Coastguard Worker const gls::DrawTestSpec::DrawMethod basicMethods[] = {
651*35238bceSAndroid Build Coastguard Worker // gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS,
652*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS,
653*35238bceSAndroid Build Coastguard Worker // gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INSTANCED,
654*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INSTANCED,
655*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED,
656*35238bceSAndroid Build Coastguard Worker };
657*35238bceSAndroid Build Coastguard Worker
658*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(basicMethods); ++ndx)
659*35238bceSAndroid Build Coastguard Worker {
660*35238bceSAndroid Build Coastguard Worker const std::string name = gls::DrawTestSpec::drawMethodToString(basicMethods[ndx]);
661*35238bceSAndroid Build Coastguard Worker const std::string desc = gls::DrawTestSpec::drawMethodToString(basicMethods[ndx]);
662*35238bceSAndroid Build Coastguard Worker
663*35238bceSAndroid Build Coastguard Worker unalignedGroup->addChild(new MethodGroup(m_context, name.c_str(), desc.c_str(), basicMethods[ndx]));
664*35238bceSAndroid Build Coastguard Worker }
665*35238bceSAndroid Build Coastguard Worker
666*35238bceSAndroid Build Coastguard Worker // Random
667*35238bceSAndroid Build Coastguard Worker
668*35238bceSAndroid Build Coastguard Worker unalignedGroup->addChild(new RandomGroup(m_context, "random", "random draw commands."));
669*35238bceSAndroid Build Coastguard Worker }
670*35238bceSAndroid Build Coastguard Worker
671*35238bceSAndroid Build Coastguard Worker // .draw_range_elements
672*35238bceSAndroid Build Coastguard Worker {
673*35238bceSAndroid Build Coastguard Worker // use a larger range than the buffer size is
674*35238bceSAndroid Build Coastguard Worker drawRangeGroup->addChild(new DrawInvalidRangeCase(m_context, "range_max_over_bounds",
675*35238bceSAndroid Build Coastguard Worker "Range over buffer bounds", 0x00000000, 0x00210000));
676*35238bceSAndroid Build Coastguard Worker drawRangeGroup->addChild(new DrawInvalidRangeCase(m_context, "range_max_over_bounds_near_signed_wrap",
677*35238bceSAndroid Build Coastguard Worker "Range over buffer bounds", 0x00000000, 0x7FFFFFFF));
678*35238bceSAndroid Build Coastguard Worker drawRangeGroup->addChild(new DrawInvalidRangeCase(m_context, "range_max_over_bounds_near_unsigned_wrap",
679*35238bceSAndroid Build Coastguard Worker "Range over buffer bounds", 0x00000000, 0xFFFFFFFF));
680*35238bceSAndroid Build Coastguard Worker drawRangeGroup->addChild(new DrawInvalidRangeCase(m_context, "range_max_over_bounds_near_max",
681*35238bceSAndroid Build Coastguard Worker "Range over buffer bounds", 0x00000000, 0x00000000, false,
682*35238bceSAndroid Build Coastguard Worker true));
683*35238bceSAndroid Build Coastguard Worker
684*35238bceSAndroid Build Coastguard Worker drawRangeGroup->addChild(new DrawInvalidRangeCase(m_context, "range_min_max_over_bounds",
685*35238bceSAndroid Build Coastguard Worker "Range over buffer bounds", 0x00200000, 0x00210000));
686*35238bceSAndroid Build Coastguard Worker drawRangeGroup->addChild(new DrawInvalidRangeCase(m_context, "range_min_max_over_bounds_near_signed_wrap",
687*35238bceSAndroid Build Coastguard Worker "Range over buffer bounds", 0x7FFFFFF0, 0x7FFFFFFF));
688*35238bceSAndroid Build Coastguard Worker drawRangeGroup->addChild(new DrawInvalidRangeCase(m_context, "range_min_max_over_bounds_near_unsigned_wrap",
689*35238bceSAndroid Build Coastguard Worker "Range over buffer bounds", 0xFFFFFFF0, 0xFFFFFFFF));
690*35238bceSAndroid Build Coastguard Worker drawRangeGroup->addChild(new DrawInvalidRangeCase(m_context, "range_min_max_over_bounds_near_max",
691*35238bceSAndroid Build Coastguard Worker "Range over buffer bounds", 0x00000000, 0x00000000, true,
692*35238bceSAndroid Build Coastguard Worker true));
693*35238bceSAndroid Build Coastguard Worker }
694*35238bceSAndroid Build Coastguard Worker }
695*35238bceSAndroid Build Coastguard Worker
696*35238bceSAndroid Build Coastguard Worker } // namespace Stress
697*35238bceSAndroid Build Coastguard Worker } // namespace gles3
698*35238bceSAndroid Build Coastguard Worker } // namespace deqp
699