1*35238bceSAndroid Build Coastguard Worker
2*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
3*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 3.1 Module
4*35238bceSAndroid Build Coastguard Worker * -------------------------------------------------
5*35238bceSAndroid Build Coastguard Worker *
6*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
7*35238bceSAndroid Build Coastguard Worker *
8*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
9*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
10*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
11*35238bceSAndroid Build Coastguard Worker *
12*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
13*35238bceSAndroid Build Coastguard Worker *
14*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
15*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
16*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
18*35238bceSAndroid Build Coastguard Worker * limitations under the License.
19*35238bceSAndroid Build Coastguard Worker *
20*35238bceSAndroid Build Coastguard Worker *//*!
21*35238bceSAndroid Build Coastguard Worker * \file
22*35238bceSAndroid Build Coastguard Worker * \brief Drawing stress tests.
23*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
24*35238bceSAndroid Build Coastguard Worker
25*35238bceSAndroid Build Coastguard Worker #include "es31sDrawTests.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "glsDrawTest.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluCallLogWrapper.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "deUniquePtr.hpp"
35*35238bceSAndroid Build Coastguard Worker
36*35238bceSAndroid Build Coastguard Worker #include <set>
37*35238bceSAndroid Build Coastguard Worker
38*35238bceSAndroid Build Coastguard Worker namespace deqp
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker namespace gles31
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker namespace Stress
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker namespace
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker
47*35238bceSAndroid Build Coastguard Worker static const char *s_colorVertexShaderSource = "#version 310 es\n"
48*35238bceSAndroid Build Coastguard Worker "in highp vec4 a_position;\n"
49*35238bceSAndroid Build Coastguard Worker "in highp vec4 a_color;\n"
50*35238bceSAndroid Build Coastguard Worker "out highp vec4 v_color;\n"
51*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
52*35238bceSAndroid Build Coastguard Worker "{\n"
53*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
54*35238bceSAndroid Build Coastguard Worker " v_color = a_color;\n"
55*35238bceSAndroid Build Coastguard Worker "}\n";
56*35238bceSAndroid Build Coastguard Worker static const char *s_colorFragmentShaderSource = "#version 310 es\n"
57*35238bceSAndroid Build Coastguard Worker "layout(location = 0) out highp vec4 fragColor;\n"
58*35238bceSAndroid Build Coastguard Worker "in highp vec4 v_color;\n"
59*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
60*35238bceSAndroid Build Coastguard Worker "{\n"
61*35238bceSAndroid Build Coastguard Worker " fragColor = v_color;\n"
62*35238bceSAndroid Build Coastguard Worker "}\n";
63*35238bceSAndroid Build Coastguard Worker struct DrawElementsCommand
64*35238bceSAndroid Build Coastguard Worker {
65*35238bceSAndroid Build Coastguard Worker uint32_t count;
66*35238bceSAndroid Build Coastguard Worker uint32_t primCount;
67*35238bceSAndroid Build Coastguard Worker uint32_t firstIndex;
68*35238bceSAndroid Build Coastguard Worker int32_t baseVertex;
69*35238bceSAndroid Build Coastguard Worker uint32_t reservedMustBeZero;
70*35238bceSAndroid Build Coastguard Worker };
71*35238bceSAndroid Build Coastguard Worker DE_STATIC_ASSERT(5 * sizeof(uint32_t) == sizeof(DrawElementsCommand)); // tight packing
72*35238bceSAndroid Build Coastguard Worker
73*35238bceSAndroid Build Coastguard Worker struct DrawArraysCommand
74*35238bceSAndroid Build Coastguard Worker {
75*35238bceSAndroid Build Coastguard Worker uint32_t count;
76*35238bceSAndroid Build Coastguard Worker uint32_t primCount;
77*35238bceSAndroid Build Coastguard Worker uint32_t first;
78*35238bceSAndroid Build Coastguard Worker uint32_t reservedMustBeZero;
79*35238bceSAndroid Build Coastguard Worker };
80*35238bceSAndroid Build Coastguard Worker DE_STATIC_ASSERT(4 * sizeof(uint32_t) == sizeof(DrawArraysCommand)); // tight packing
81*35238bceSAndroid Build Coastguard Worker
82*35238bceSAndroid Build Coastguard Worker class InvalidDrawCase : public TestCase
83*35238bceSAndroid Build Coastguard Worker {
84*35238bceSAndroid Build Coastguard Worker public:
85*35238bceSAndroid Build Coastguard Worker enum DrawType
86*35238bceSAndroid Build Coastguard Worker {
87*35238bceSAndroid Build Coastguard Worker DRAW_ARRAYS,
88*35238bceSAndroid Build Coastguard Worker DRAW_ELEMENTS,
89*35238bceSAndroid Build Coastguard Worker
90*35238bceSAndroid Build Coastguard Worker DRAW_LAST
91*35238bceSAndroid Build Coastguard Worker };
92*35238bceSAndroid Build Coastguard Worker enum InvalidOperation
93*35238bceSAndroid Build Coastguard Worker {
94*35238bceSAndroid Build Coastguard Worker INVALID_DATA_COUNT = 0,
95*35238bceSAndroid Build Coastguard Worker INVALID_DATA_FIRST,
96*35238bceSAndroid Build Coastguard Worker INVALID_DATA_INSTANCED,
97*35238bceSAndroid Build Coastguard Worker INVALID_INDEX_COUNT,
98*35238bceSAndroid Build Coastguard Worker INVALID_INDEX_FIRST,
99*35238bceSAndroid Build Coastguard Worker INVALID_RESERVED,
100*35238bceSAndroid Build Coastguard Worker INVALID_INDEX,
101*35238bceSAndroid Build Coastguard Worker
102*35238bceSAndroid Build Coastguard Worker INVALID_LAST
103*35238bceSAndroid Build Coastguard Worker };
104*35238bceSAndroid Build Coastguard Worker
105*35238bceSAndroid Build Coastguard Worker InvalidDrawCase(Context &context, const char *name, const char *desc, DrawType type, InvalidOperation op);
106*35238bceSAndroid Build Coastguard Worker ~InvalidDrawCase(void);
107*35238bceSAndroid Build Coastguard Worker
108*35238bceSAndroid Build Coastguard Worker void init(void);
109*35238bceSAndroid Build Coastguard Worker void deinit(void);
110*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
111*35238bceSAndroid Build Coastguard Worker
112*35238bceSAndroid Build Coastguard Worker private:
113*35238bceSAndroid Build Coastguard Worker const DrawType m_drawType;
114*35238bceSAndroid Build Coastguard Worker const InvalidOperation m_op;
115*35238bceSAndroid Build Coastguard Worker glw::GLuint m_dataBufferID;
116*35238bceSAndroid Build Coastguard Worker glw::GLuint m_indexBufferID;
117*35238bceSAndroid Build Coastguard Worker glw::GLuint m_cmdBufferID;
118*35238bceSAndroid Build Coastguard Worker glw::GLuint m_colorBufferID;
119*35238bceSAndroid Build Coastguard Worker glw::GLuint m_vao;
120*35238bceSAndroid Build Coastguard Worker };
121*35238bceSAndroid Build Coastguard Worker
InvalidDrawCase(Context & context,const char * name,const char * desc,DrawType type,InvalidOperation op)122*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::InvalidDrawCase(Context &context, const char *name, const char *desc, DrawType type,
123*35238bceSAndroid Build Coastguard Worker InvalidOperation op)
124*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, desc)
125*35238bceSAndroid Build Coastguard Worker , m_drawType(type)
126*35238bceSAndroid Build Coastguard Worker , m_op(op)
127*35238bceSAndroid Build Coastguard Worker , m_dataBufferID(0)
128*35238bceSAndroid Build Coastguard Worker , m_indexBufferID(0)
129*35238bceSAndroid Build Coastguard Worker , m_cmdBufferID(0)
130*35238bceSAndroid Build Coastguard Worker , m_colorBufferID(0)
131*35238bceSAndroid Build Coastguard Worker , m_vao(0)
132*35238bceSAndroid Build Coastguard Worker {
133*35238bceSAndroid Build Coastguard Worker DE_ASSERT(type < DRAW_LAST);
134*35238bceSAndroid Build Coastguard Worker DE_ASSERT(op < INVALID_LAST);
135*35238bceSAndroid Build Coastguard Worker }
136*35238bceSAndroid Build Coastguard Worker
~InvalidDrawCase(void)137*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::~InvalidDrawCase(void)
138*35238bceSAndroid Build Coastguard Worker {
139*35238bceSAndroid Build Coastguard Worker deinit();
140*35238bceSAndroid Build Coastguard Worker }
141*35238bceSAndroid Build Coastguard Worker
init(void)142*35238bceSAndroid Build Coastguard Worker void InvalidDrawCase::init(void)
143*35238bceSAndroid Build Coastguard Worker {
144*35238bceSAndroid Build Coastguard Worker }
145*35238bceSAndroid Build Coastguard Worker
deinit(void)146*35238bceSAndroid Build Coastguard Worker void InvalidDrawCase::deinit(void)
147*35238bceSAndroid Build Coastguard Worker {
148*35238bceSAndroid Build Coastguard Worker if (m_dataBufferID)
149*35238bceSAndroid Build Coastguard Worker {
150*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_dataBufferID);
151*35238bceSAndroid Build Coastguard Worker m_dataBufferID = 0;
152*35238bceSAndroid Build Coastguard Worker }
153*35238bceSAndroid Build Coastguard Worker if (m_indexBufferID)
154*35238bceSAndroid Build Coastguard Worker {
155*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_indexBufferID);
156*35238bceSAndroid Build Coastguard Worker m_indexBufferID = 0;
157*35238bceSAndroid Build Coastguard Worker }
158*35238bceSAndroid Build Coastguard Worker if (m_cmdBufferID)
159*35238bceSAndroid Build Coastguard Worker {
160*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_cmdBufferID);
161*35238bceSAndroid Build Coastguard Worker m_cmdBufferID = 0;
162*35238bceSAndroid Build Coastguard Worker }
163*35238bceSAndroid Build Coastguard Worker if (m_colorBufferID)
164*35238bceSAndroid Build Coastguard Worker {
165*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_colorBufferID);
166*35238bceSAndroid Build Coastguard Worker m_colorBufferID = 0;
167*35238bceSAndroid Build Coastguard Worker }
168*35238bceSAndroid Build Coastguard Worker if (m_vao)
169*35238bceSAndroid Build Coastguard Worker {
170*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().deleteVertexArrays(1, &m_vao);
171*35238bceSAndroid Build Coastguard Worker m_vao = 0;
172*35238bceSAndroid Build Coastguard Worker }
173*35238bceSAndroid Build Coastguard Worker }
174*35238bceSAndroid Build Coastguard Worker
iterate(void)175*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::IterateResult InvalidDrawCase::iterate(void)
176*35238bceSAndroid Build Coastguard Worker {
177*35238bceSAndroid Build Coastguard Worker const int drawCount = 10; //!< number of elements safe to draw (all buffers have this)
178*35238bceSAndroid Build Coastguard Worker const int overBoundDrawCount = 10000; //!< number of elements in all other buffers than our target buffer
179*35238bceSAndroid Build Coastguard Worker const int drawInstances = 1;
180*35238bceSAndroid Build Coastguard Worker const int overBoundInstances = 1000;
181*35238bceSAndroid Build Coastguard Worker
182*35238bceSAndroid Build Coastguard Worker glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
183*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram program(m_context.getRenderContext(), glu::ProgramSources()
184*35238bceSAndroid Build Coastguard Worker << glu::VertexSource(s_colorVertexShaderSource)
185*35238bceSAndroid Build Coastguard Worker << glu::FragmentSource(s_colorFragmentShaderSource));
186*35238bceSAndroid Build Coastguard Worker const uint32_t programID = program.getProgram();
187*35238bceSAndroid Build Coastguard Worker const int32_t posLocation = gl.glGetAttribLocation(programID, "a_position");
188*35238bceSAndroid Build Coastguard Worker const int32_t colorLocation = gl.glGetAttribLocation(programID, "a_color");
189*35238bceSAndroid Build Coastguard Worker
190*35238bceSAndroid Build Coastguard Worker gl.enableLogging(true);
191*35238bceSAndroid Build Coastguard Worker
192*35238bceSAndroid Build Coastguard Worker gl.glGenVertexArrays(1, &m_vao);
193*35238bceSAndroid Build Coastguard Worker gl.glBindVertexArray(m_vao);
194*35238bceSAndroid Build Coastguard Worker glu::checkError(gl.glGetError(), "gen vao", __FILE__, __LINE__);
195*35238bceSAndroid Build Coastguard Worker
196*35238bceSAndroid Build Coastguard Worker // indices
197*35238bceSAndroid Build Coastguard Worker if (m_drawType == DRAW_ELEMENTS)
198*35238bceSAndroid Build Coastguard Worker {
199*35238bceSAndroid Build Coastguard Worker const int indexBufferSize = (m_op == INVALID_INDEX_COUNT) ? (drawCount) : (overBoundDrawCount);
200*35238bceSAndroid Build Coastguard Worker std::vector<uint16_t> indices(indexBufferSize);
201*35238bceSAndroid Build Coastguard Worker
202*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < (int)indices.size(); ++ndx)
203*35238bceSAndroid Build Coastguard Worker indices[ndx] = (uint16_t)((m_op == INVALID_INDEX) ? (overBoundDrawCount + ndx) : (ndx));
204*35238bceSAndroid Build Coastguard Worker
205*35238bceSAndroid Build Coastguard Worker gl.glGenBuffers(1, &m_indexBufferID);
206*35238bceSAndroid Build Coastguard Worker gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferID);
207*35238bceSAndroid Build Coastguard Worker gl.glBufferData(GL_ELEMENT_ARRAY_BUFFER, (int)(indices.size() * sizeof(uint16_t)), &indices[0], GL_STATIC_DRAW);
208*35238bceSAndroid Build Coastguard Worker glu::checkError(gl.glGetError(), "", __FILE__, __LINE__);
209*35238bceSAndroid Build Coastguard Worker }
210*35238bceSAndroid Build Coastguard Worker
211*35238bceSAndroid Build Coastguard Worker // data
212*35238bceSAndroid Build Coastguard Worker {
213*35238bceSAndroid Build Coastguard Worker const int dataSize = (m_op == INVALID_DATA_COUNT) ? (drawCount) : (overBoundDrawCount);
214*35238bceSAndroid Build Coastguard Worker
215*35238bceSAndroid Build Coastguard Worker // any data is ok
216*35238bceSAndroid Build Coastguard Worker gl.glGenBuffers(1, &m_dataBufferID);
217*35238bceSAndroid Build Coastguard Worker gl.glBindBuffer(GL_ARRAY_BUFFER, m_dataBufferID);
218*35238bceSAndroid Build Coastguard Worker gl.glBufferData(GL_ARRAY_BUFFER, dataSize * sizeof(float[4]), DE_NULL, GL_STATIC_DRAW);
219*35238bceSAndroid Build Coastguard Worker gl.glVertexAttribPointer(posLocation, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
220*35238bceSAndroid Build Coastguard Worker gl.glEnableVertexAttribArray(posLocation);
221*35238bceSAndroid Build Coastguard Worker glu::checkError(gl.glGetError(), "", __FILE__, __LINE__);
222*35238bceSAndroid Build Coastguard Worker }
223*35238bceSAndroid Build Coastguard Worker
224*35238bceSAndroid Build Coastguard Worker // potentially instanced data
225*35238bceSAndroid Build Coastguard Worker {
226*35238bceSAndroid Build Coastguard Worker const int dataSize = drawInstances;
227*35238bceSAndroid Build Coastguard Worker
228*35238bceSAndroid Build Coastguard Worker gl.glGenBuffers(1, &m_colorBufferID);
229*35238bceSAndroid Build Coastguard Worker gl.glBindBuffer(GL_ARRAY_BUFFER, m_colorBufferID);
230*35238bceSAndroid Build Coastguard Worker gl.glBufferData(GL_ARRAY_BUFFER, dataSize * sizeof(float[4]), DE_NULL, GL_STATIC_DRAW);
231*35238bceSAndroid Build Coastguard Worker gl.glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
232*35238bceSAndroid Build Coastguard Worker gl.glEnableVertexAttribArray(colorLocation);
233*35238bceSAndroid Build Coastguard Worker gl.glVertexAttribDivisor(colorLocation, 1);
234*35238bceSAndroid Build Coastguard Worker glu::checkError(gl.glGetError(), "", __FILE__, __LINE__);
235*35238bceSAndroid Build Coastguard Worker }
236*35238bceSAndroid Build Coastguard Worker
237*35238bceSAndroid Build Coastguard Worker // command
238*35238bceSAndroid Build Coastguard Worker if (m_drawType == DRAW_ARRAYS)
239*35238bceSAndroid Build Coastguard Worker {
240*35238bceSAndroid Build Coastguard Worker DrawArraysCommand drawCommand;
241*35238bceSAndroid Build Coastguard Worker drawCommand.count = overBoundDrawCount;
242*35238bceSAndroid Build Coastguard Worker drawCommand.primCount = (m_op == INVALID_DATA_INSTANCED) ? (overBoundInstances) : (drawInstances);
243*35238bceSAndroid Build Coastguard Worker drawCommand.first = (m_op == INVALID_DATA_FIRST) ? (overBoundDrawCount) : (0);
244*35238bceSAndroid Build Coastguard Worker drawCommand.reservedMustBeZero = (m_op == INVALID_RESERVED) ? (5) : (0);
245*35238bceSAndroid Build Coastguard Worker
246*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "drawCommand:"
247*35238bceSAndroid Build Coastguard Worker << "\n\tcount:\t" << drawCommand.count << "\n\tprimCount\t" << drawCommand.primCount
248*35238bceSAndroid Build Coastguard Worker << "\n\tfirst\t" << drawCommand.first << "\n\treservedMustBeZero\t"
249*35238bceSAndroid Build Coastguard Worker << drawCommand.reservedMustBeZero << tcu::TestLog::EndMessage;
250*35238bceSAndroid Build Coastguard Worker
251*35238bceSAndroid Build Coastguard Worker gl.glGenBuffers(1, &m_cmdBufferID);
252*35238bceSAndroid Build Coastguard Worker gl.glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_cmdBufferID);
253*35238bceSAndroid Build Coastguard Worker gl.glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(drawCommand), &drawCommand, GL_STATIC_DRAW);
254*35238bceSAndroid Build Coastguard Worker glu::checkError(gl.glGetError(), "", __FILE__, __LINE__);
255*35238bceSAndroid Build Coastguard Worker }
256*35238bceSAndroid Build Coastguard Worker else if (m_drawType == DRAW_ELEMENTS)
257*35238bceSAndroid Build Coastguard Worker {
258*35238bceSAndroid Build Coastguard Worker DrawElementsCommand drawCommand;
259*35238bceSAndroid Build Coastguard Worker drawCommand.count = overBoundDrawCount;
260*35238bceSAndroid Build Coastguard Worker drawCommand.primCount = (m_op == INVALID_DATA_INSTANCED) ? (overBoundInstances) : (drawInstances);
261*35238bceSAndroid Build Coastguard Worker drawCommand.firstIndex = (m_op == INVALID_INDEX_FIRST) ? (overBoundDrawCount) : (0);
262*35238bceSAndroid Build Coastguard Worker drawCommand.baseVertex = (m_op == INVALID_DATA_FIRST) ? (overBoundDrawCount) : (0);
263*35238bceSAndroid Build Coastguard Worker drawCommand.reservedMustBeZero = (m_op == INVALID_RESERVED) ? (5) : (0);
264*35238bceSAndroid Build Coastguard Worker
265*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << "drawCommand:"
266*35238bceSAndroid Build Coastguard Worker << "\n\tcount:\t" << drawCommand.count << "\n\tprimCount\t" << drawCommand.primCount
267*35238bceSAndroid Build Coastguard Worker << "\n\tfirstIndex\t" << drawCommand.firstIndex << "\n\tbaseVertex\t"
268*35238bceSAndroid Build Coastguard Worker << drawCommand.baseVertex << "\n\treservedMustBeZero\t" << drawCommand.reservedMustBeZero
269*35238bceSAndroid Build Coastguard Worker << tcu::TestLog::EndMessage;
270*35238bceSAndroid Build Coastguard Worker
271*35238bceSAndroid Build Coastguard Worker gl.glGenBuffers(1, &m_cmdBufferID);
272*35238bceSAndroid Build Coastguard Worker gl.glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_cmdBufferID);
273*35238bceSAndroid Build Coastguard Worker gl.glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(drawCommand), &drawCommand, GL_STATIC_DRAW);
274*35238bceSAndroid Build Coastguard Worker glu::checkError(gl.glGetError(), "", __FILE__, __LINE__);
275*35238bceSAndroid Build Coastguard Worker }
276*35238bceSAndroid Build Coastguard Worker else
277*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
278*35238bceSAndroid Build Coastguard Worker
279*35238bceSAndroid Build Coastguard Worker gl.glViewport(0, 0, 1, 1);
280*35238bceSAndroid Build Coastguard Worker gl.glUseProgram(programID);
281*35238bceSAndroid Build Coastguard Worker
282*35238bceSAndroid Build Coastguard Worker if (m_drawType == DRAW_ELEMENTS)
283*35238bceSAndroid Build Coastguard Worker gl.glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, DE_NULL);
284*35238bceSAndroid Build Coastguard Worker else if (m_drawType == DRAW_ARRAYS)
285*35238bceSAndroid Build Coastguard Worker gl.glDrawArraysIndirect(GL_TRIANGLES, DE_NULL);
286*35238bceSAndroid Build Coastguard Worker else
287*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
288*35238bceSAndroid Build Coastguard Worker
289*35238bceSAndroid Build Coastguard Worker gl.glUseProgram(0);
290*35238bceSAndroid Build Coastguard Worker gl.glFinish();
291*35238bceSAndroid Build Coastguard Worker
292*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
293*35238bceSAndroid Build Coastguard Worker return STOP;
294*35238bceSAndroid Build Coastguard Worker }
295*35238bceSAndroid Build Coastguard Worker
296*35238bceSAndroid Build Coastguard Worker class RandomGroup : public TestCaseGroup
297*35238bceSAndroid Build Coastguard Worker {
298*35238bceSAndroid Build Coastguard Worker public:
299*35238bceSAndroid Build Coastguard Worker RandomGroup(Context &context, const char *name, const char *descr);
300*35238bceSAndroid Build Coastguard Worker ~RandomGroup(void);
301*35238bceSAndroid Build Coastguard Worker
302*35238bceSAndroid Build Coastguard Worker void init(void);
303*35238bceSAndroid Build Coastguard Worker };
304*35238bceSAndroid Build Coastguard Worker
305*35238bceSAndroid Build Coastguard Worker template <int SIZE>
306*35238bceSAndroid Build Coastguard Worker struct UniformWeightArray
307*35238bceSAndroid Build Coastguard Worker {
308*35238bceSAndroid Build Coastguard Worker float weights[SIZE];
309*35238bceSAndroid Build Coastguard Worker
UniformWeightArraydeqp::gles31::Stress::__anon9c7365ba0111::UniformWeightArray310*35238bceSAndroid Build Coastguard Worker UniformWeightArray(void)
311*35238bceSAndroid Build Coastguard Worker {
312*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < SIZE; ++i)
313*35238bceSAndroid Build Coastguard Worker weights[i] = 1.0f;
314*35238bceSAndroid Build Coastguard Worker }
315*35238bceSAndroid Build Coastguard Worker };
316*35238bceSAndroid Build Coastguard Worker
RandomGroup(Context & context,const char * name,const char * descr)317*35238bceSAndroid Build Coastguard Worker RandomGroup::RandomGroup(Context &context, const char *name, const char *descr) : TestCaseGroup(context, name, descr)
318*35238bceSAndroid Build Coastguard Worker {
319*35238bceSAndroid Build Coastguard Worker }
320*35238bceSAndroid Build Coastguard Worker
~RandomGroup(void)321*35238bceSAndroid Build Coastguard Worker RandomGroup::~RandomGroup(void)
322*35238bceSAndroid Build Coastguard Worker {
323*35238bceSAndroid Build Coastguard Worker }
324*35238bceSAndroid Build Coastguard Worker
init(void)325*35238bceSAndroid Build Coastguard Worker void RandomGroup::init(void)
326*35238bceSAndroid Build Coastguard Worker {
327*35238bceSAndroid Build Coastguard Worker const int numAttempts = 100;
328*35238bceSAndroid Build Coastguard Worker
329*35238bceSAndroid Build Coastguard Worker const int attribCounts[] = {1, 2, 5};
330*35238bceSAndroid Build Coastguard Worker const float attribWeights[] = {30, 10, 1};
331*35238bceSAndroid Build Coastguard Worker const int primitiveCounts[] = {1, 5, 64};
332*35238bceSAndroid Build Coastguard Worker const float primitiveCountWeights[] = {20, 10, 1};
333*35238bceSAndroid Build Coastguard Worker const int indexOffsets[] = {0, 7, 13};
334*35238bceSAndroid Build Coastguard Worker const float indexOffsetWeights[] = {20, 20, 1};
335*35238bceSAndroid Build Coastguard Worker const int firsts[] = {0, 7, 13};
336*35238bceSAndroid Build Coastguard Worker const float firstWeights[] = {20, 20, 1};
337*35238bceSAndroid Build Coastguard Worker
338*35238bceSAndroid Build Coastguard Worker const int instanceCounts[] = {1, 2, 16, 17};
339*35238bceSAndroid Build Coastguard Worker const float instanceWeights[] = {20, 10, 5, 1};
340*35238bceSAndroid Build Coastguard Worker const int indexMins[] = {0, 1, 3, 8};
341*35238bceSAndroid Build Coastguard Worker const int indexMaxs[] = {4, 8, 128, 257};
342*35238bceSAndroid Build Coastguard Worker const float indexWeights[] = {50, 50, 50, 50};
343*35238bceSAndroid Build Coastguard Worker const int offsets[] = {0, 1, 5, 12};
344*35238bceSAndroid Build Coastguard Worker const float offsetWeights[] = {50, 10, 10, 10};
345*35238bceSAndroid Build Coastguard Worker const int strides[] = {0, 7, 16, 17};
346*35238bceSAndroid Build Coastguard Worker const float strideWeights[] = {50, 10, 10, 10};
347*35238bceSAndroid Build Coastguard Worker const int instanceDivisors[] = {0, 1, 3, 129};
348*35238bceSAndroid Build Coastguard Worker const float instanceDivisorWeights[] = {70, 30, 10, 10};
349*35238bceSAndroid Build Coastguard Worker
350*35238bceSAndroid Build Coastguard Worker const int indirectOffsets[] = {0, 1, 2};
351*35238bceSAndroid Build Coastguard Worker const float indirectOffsetWeigths[] = {2, 1, 1};
352*35238bceSAndroid Build Coastguard Worker const int baseVertices[] = {0, 1, -2, 4, 3};
353*35238bceSAndroid Build Coastguard Worker const float baseVertexWeigths[] = {4, 1, 1, 1, 1};
354*35238bceSAndroid Build Coastguard Worker
355*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Primitive primitives[] = {
356*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_POINTS, gls::DrawTestSpec::PRIMITIVE_TRIANGLES,
357*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN, gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP,
358*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_LINES, gls::DrawTestSpec::PRIMITIVE_LINE_STRIP,
359*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::PRIMITIVE_LINE_LOOP};
360*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(primitives)> primitiveWeights;
361*35238bceSAndroid Build Coastguard Worker
362*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DrawMethod drawMethods[] = {
363*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INDIRECT,
364*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INDIRECT,
365*35238bceSAndroid Build Coastguard Worker };
366*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(drawMethods)> drawMethodWeights;
367*35238bceSAndroid Build Coastguard Worker
368*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::IndexType indexTypes[] = {
369*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INDEXTYPE_BYTE,
370*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INDEXTYPE_SHORT,
371*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INDEXTYPE_INT,
372*35238bceSAndroid Build Coastguard Worker };
373*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(indexTypes)> indexTypeWeights;
374*35238bceSAndroid Build Coastguard Worker
375*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::InputType inputTypes[] = {
376*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_FLOAT,
377*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_FIXED,
378*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_BYTE,
379*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_SHORT,
380*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_UNSIGNED_BYTE,
381*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_UNSIGNED_SHORT,
382*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_INT,
383*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_UNSIGNED_INT,
384*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_HALF,
385*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_UNSIGNED_INT_2_10_10_10,
386*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::INPUTTYPE_INT_2_10_10_10,
387*35238bceSAndroid Build Coastguard Worker };
388*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(inputTypes)> inputTypeWeights;
389*35238bceSAndroid Build Coastguard Worker
390*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OutputType outputTypes[] = {
391*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_FLOAT, gls::DrawTestSpec::OUTPUTTYPE_VEC2, gls::DrawTestSpec::OUTPUTTYPE_VEC3,
392*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_VEC4, gls::DrawTestSpec::OUTPUTTYPE_INT, gls::DrawTestSpec::OUTPUTTYPE_UINT,
393*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_IVEC2, gls::DrawTestSpec::OUTPUTTYPE_IVEC3, gls::DrawTestSpec::OUTPUTTYPE_IVEC4,
394*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::OUTPUTTYPE_UVEC2, gls::DrawTestSpec::OUTPUTTYPE_UVEC3, gls::DrawTestSpec::OUTPUTTYPE_UVEC4,
395*35238bceSAndroid Build Coastguard Worker };
396*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(outputTypes)> outputTypeWeights;
397*35238bceSAndroid Build Coastguard Worker
398*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::Usage usages[] = {
399*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_DYNAMIC_DRAW, gls::DrawTestSpec::USAGE_STATIC_DRAW,
400*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_STREAM_DRAW, gls::DrawTestSpec::USAGE_STREAM_READ,
401*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_STREAM_COPY, gls::DrawTestSpec::USAGE_STATIC_READ,
402*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_STATIC_COPY, gls::DrawTestSpec::USAGE_DYNAMIC_READ,
403*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::USAGE_DYNAMIC_COPY,
404*35238bceSAndroid Build Coastguard Worker };
405*35238bceSAndroid Build Coastguard Worker const UniformWeightArray<DE_LENGTH_OF_ARRAY(usages)> usageWeights;
406*35238bceSAndroid Build Coastguard Worker
407*35238bceSAndroid Build Coastguard Worker std::set<uint32_t> insertedHashes;
408*35238bceSAndroid Build Coastguard Worker size_t insertedCount = 0;
409*35238bceSAndroid Build Coastguard Worker
410*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numAttempts; ++ndx)
411*35238bceSAndroid Build Coastguard Worker {
412*35238bceSAndroid Build Coastguard Worker de::Random random(0xc551393 + ndx); // random does not depend on previous cases
413*35238bceSAndroid Build Coastguard Worker
414*35238bceSAndroid Build Coastguard Worker int attributeCount = random.chooseWeighted<int, const int *, const float *>(
415*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(attribCounts), DE_ARRAY_END(attribCounts), attribWeights);
416*35238bceSAndroid Build Coastguard Worker int drawCommandSize;
417*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec spec;
418*35238bceSAndroid Build Coastguard Worker
419*35238bceSAndroid Build Coastguard Worker spec.apiType = glu::ApiType::es(3, 1);
420*35238bceSAndroid Build Coastguard Worker spec.primitive = random.chooseWeighted<gls::DrawTestSpec::Primitive>(
421*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(primitives), DE_ARRAY_END(primitives), primitiveWeights.weights);
422*35238bceSAndroid Build Coastguard Worker spec.primitiveCount = random.chooseWeighted<int, const int *, const float *>(
423*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(primitiveCounts), DE_ARRAY_END(primitiveCounts), primitiveCountWeights);
424*35238bceSAndroid Build Coastguard Worker spec.drawMethod = random.chooseWeighted<gls::DrawTestSpec::DrawMethod>(
425*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(drawMethods), DE_ARRAY_END(drawMethods), drawMethodWeights.weights);
426*35238bceSAndroid Build Coastguard Worker
427*35238bceSAndroid Build Coastguard Worker if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INDIRECT)
428*35238bceSAndroid Build Coastguard Worker drawCommandSize = sizeof(uint32_t[4]);
429*35238bceSAndroid Build Coastguard Worker else if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INDIRECT)
430*35238bceSAndroid Build Coastguard Worker drawCommandSize = sizeof(uint32_t[5]);
431*35238bceSAndroid Build Coastguard Worker else
432*35238bceSAndroid Build Coastguard Worker {
433*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
434*35238bceSAndroid Build Coastguard Worker return;
435*35238bceSAndroid Build Coastguard Worker }
436*35238bceSAndroid Build Coastguard Worker
437*35238bceSAndroid Build Coastguard Worker spec.indexType = random.chooseWeighted<gls::DrawTestSpec::IndexType>(
438*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(indexTypes), DE_ARRAY_END(indexTypes), indexTypeWeights.weights);
439*35238bceSAndroid Build Coastguard Worker spec.indexPointerOffset = random.chooseWeighted<int, const int *, const float *>(
440*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(indexOffsets), DE_ARRAY_END(indexOffsets), indexOffsetWeights);
441*35238bceSAndroid Build Coastguard Worker spec.indexStorage = gls::DrawTestSpec::STORAGE_BUFFER;
442*35238bceSAndroid Build Coastguard Worker spec.first = random.chooseWeighted<int, const int *, const float *>(DE_ARRAY_BEGIN(firsts),
443*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(firsts), firstWeights);
444*35238bceSAndroid Build Coastguard Worker spec.indexMin = random.chooseWeighted<int, const int *, const float *>(DE_ARRAY_BEGIN(indexMins),
445*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(indexMins), indexWeights);
446*35238bceSAndroid Build Coastguard Worker spec.indexMax = random.chooseWeighted<int, const int *, const float *>(DE_ARRAY_BEGIN(indexMaxs),
447*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(indexMaxs), indexWeights);
448*35238bceSAndroid Build Coastguard Worker spec.instanceCount = random.chooseWeighted<int, const int *, const float *>(
449*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(instanceCounts), DE_ARRAY_END(instanceCounts), instanceWeights);
450*35238bceSAndroid Build Coastguard Worker spec.indirectOffset = random.chooseWeighted<int, const int *, const float *>(DE_ARRAY_BEGIN(indirectOffsets),
451*35238bceSAndroid Build Coastguard Worker DE_ARRAY_END(indirectOffsets),
452*35238bceSAndroid Build Coastguard Worker indirectOffsetWeigths) *
453*35238bceSAndroid Build Coastguard Worker drawCommandSize;
454*35238bceSAndroid Build Coastguard Worker spec.baseVertex = random.chooseWeighted<int, const int *, const float *>(
455*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(baseVertices), DE_ARRAY_END(baseVertices), baseVertexWeigths);
456*35238bceSAndroid Build Coastguard Worker
457*35238bceSAndroid Build Coastguard Worker // check spec is legal
458*35238bceSAndroid Build Coastguard Worker if (!spec.valid())
459*35238bceSAndroid Build Coastguard Worker continue;
460*35238bceSAndroid Build Coastguard Worker
461*35238bceSAndroid Build Coastguard Worker for (int attrNdx = 0; attrNdx < attributeCount;)
462*35238bceSAndroid Build Coastguard Worker {
463*35238bceSAndroid Build Coastguard Worker bool valid;
464*35238bceSAndroid Build Coastguard Worker gls::DrawTestSpec::AttributeSpec attribSpec;
465*35238bceSAndroid Build Coastguard Worker
466*35238bceSAndroid Build Coastguard Worker attribSpec.inputType = random.chooseWeighted<gls::DrawTestSpec::InputType>(
467*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(inputTypes), DE_ARRAY_END(inputTypes), inputTypeWeights.weights);
468*35238bceSAndroid Build Coastguard Worker attribSpec.outputType = random.chooseWeighted<gls::DrawTestSpec::OutputType>(
469*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(outputTypes), DE_ARRAY_END(outputTypes), outputTypeWeights.weights);
470*35238bceSAndroid Build Coastguard Worker attribSpec.storage = gls::DrawTestSpec::STORAGE_BUFFER;
471*35238bceSAndroid Build Coastguard Worker attribSpec.usage = random.chooseWeighted<gls::DrawTestSpec::Usage>(
472*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(usages), DE_ARRAY_END(usages), usageWeights.weights);
473*35238bceSAndroid Build Coastguard Worker attribSpec.componentCount = random.getInt(1, 4);
474*35238bceSAndroid Build Coastguard Worker attribSpec.offset = random.chooseWeighted<int, const int *, const float *>(
475*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(offsets), DE_ARRAY_END(offsets), offsetWeights);
476*35238bceSAndroid Build Coastguard Worker attribSpec.stride = random.chooseWeighted<int, const int *, const float *>(
477*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(strides), DE_ARRAY_END(strides), strideWeights);
478*35238bceSAndroid Build Coastguard Worker attribSpec.normalize = random.getBool();
479*35238bceSAndroid Build Coastguard Worker attribSpec.instanceDivisor = random.chooseWeighted<int, const int *, const float *>(
480*35238bceSAndroid Build Coastguard Worker DE_ARRAY_BEGIN(instanceDivisors), DE_ARRAY_END(instanceDivisors), instanceDivisorWeights);
481*35238bceSAndroid Build Coastguard Worker attribSpec.useDefaultAttribute = random.getBool();
482*35238bceSAndroid Build Coastguard Worker
483*35238bceSAndroid Build Coastguard Worker // check spec is legal
484*35238bceSAndroid Build Coastguard Worker valid = attribSpec.valid(spec.apiType);
485*35238bceSAndroid Build Coastguard Worker
486*35238bceSAndroid Build Coastguard Worker // we do not want interleaved elements. (Might result in some weird floating point values)
487*35238bceSAndroid Build Coastguard Worker if (attribSpec.stride &&
488*35238bceSAndroid Build Coastguard Worker attribSpec.componentCount * gls::DrawTestSpec::inputTypeSize(attribSpec.inputType) > attribSpec.stride)
489*35238bceSAndroid Build Coastguard Worker valid = false;
490*35238bceSAndroid Build Coastguard Worker
491*35238bceSAndroid Build Coastguard Worker // try again if not valid
492*35238bceSAndroid Build Coastguard Worker if (valid)
493*35238bceSAndroid Build Coastguard Worker {
494*35238bceSAndroid Build Coastguard Worker spec.attribs.push_back(attribSpec);
495*35238bceSAndroid Build Coastguard Worker ++attrNdx;
496*35238bceSAndroid Build Coastguard Worker }
497*35238bceSAndroid Build Coastguard Worker }
498*35238bceSAndroid Build Coastguard Worker
499*35238bceSAndroid Build Coastguard Worker // Do not collapse all vertex positions to a single positions
500*35238bceSAndroid Build Coastguard Worker if (spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS)
501*35238bceSAndroid Build Coastguard Worker spec.attribs[0].instanceDivisor = 0;
502*35238bceSAndroid Build Coastguard Worker
503*35238bceSAndroid Build Coastguard Worker // Is render result meaningful?
504*35238bceSAndroid Build Coastguard Worker {
505*35238bceSAndroid Build Coastguard Worker // Only one vertex
506*35238bceSAndroid Build Coastguard Worker if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED &&
507*35238bceSAndroid Build Coastguard Worker spec.indexMin == spec.indexMax && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS)
508*35238bceSAndroid Build Coastguard Worker continue;
509*35238bceSAndroid Build Coastguard Worker if (spec.attribs[0].useDefaultAttribute && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS)
510*35238bceSAndroid Build Coastguard Worker continue;
511*35238bceSAndroid Build Coastguard Worker
512*35238bceSAndroid Build Coastguard Worker // Triangle only on one axis
513*35238bceSAndroid Build Coastguard Worker if (spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLES ||
514*35238bceSAndroid Build Coastguard Worker spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN ||
515*35238bceSAndroid Build Coastguard Worker spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP)
516*35238bceSAndroid Build Coastguard Worker {
517*35238bceSAndroid Build Coastguard Worker if (spec.attribs[0].componentCount == 1)
518*35238bceSAndroid Build Coastguard Worker continue;
519*35238bceSAndroid Build Coastguard Worker if (spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_FLOAT ||
520*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_INT ||
521*35238bceSAndroid Build Coastguard Worker spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_UINT)
522*35238bceSAndroid Build Coastguard Worker continue;
523*35238bceSAndroid Build Coastguard Worker if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED &&
524*35238bceSAndroid Build Coastguard Worker (spec.indexMax - spec.indexMin) < 2)
525*35238bceSAndroid Build Coastguard Worker continue;
526*35238bceSAndroid Build Coastguard Worker }
527*35238bceSAndroid Build Coastguard Worker }
528*35238bceSAndroid Build Coastguard Worker
529*35238bceSAndroid Build Coastguard Worker // Add case
530*35238bceSAndroid Build Coastguard Worker {
531*35238bceSAndroid Build Coastguard Worker uint32_t hash = spec.hash();
532*35238bceSAndroid Build Coastguard Worker for (int attrNdx = 0; attrNdx < attributeCount; ++attrNdx)
533*35238bceSAndroid Build Coastguard Worker hash = (hash << 2) ^ (uint32_t)spec.attribs[attrNdx].hash();
534*35238bceSAndroid Build Coastguard Worker
535*35238bceSAndroid Build Coastguard Worker if (insertedHashes.find(hash) == insertedHashes.end())
536*35238bceSAndroid Build Coastguard Worker {
537*35238bceSAndroid Build Coastguard Worker // Only unaligned cases
538*35238bceSAndroid Build Coastguard Worker if (spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET ||
539*35238bceSAndroid Build Coastguard Worker spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE)
540*35238bceSAndroid Build Coastguard Worker this->addChild(new gls::DrawTest(m_testCtx, m_context.getRenderContext(), spec,
541*35238bceSAndroid Build Coastguard Worker de::toString(insertedCount).c_str(), spec.getDesc().c_str()));
542*35238bceSAndroid Build Coastguard Worker insertedHashes.insert(hash);
543*35238bceSAndroid Build Coastguard Worker
544*35238bceSAndroid Build Coastguard Worker ++insertedCount;
545*35238bceSAndroid Build Coastguard Worker }
546*35238bceSAndroid Build Coastguard Worker }
547*35238bceSAndroid Build Coastguard Worker }
548*35238bceSAndroid Build Coastguard Worker }
549*35238bceSAndroid Build Coastguard Worker
550*35238bceSAndroid Build Coastguard Worker } // namespace
551*35238bceSAndroid Build Coastguard Worker
DrawTests(Context & context)552*35238bceSAndroid Build Coastguard Worker DrawTests::DrawTests(Context &context) : TestCaseGroup(context, "draw_indirect", "Indirect drawing tests")
553*35238bceSAndroid Build Coastguard Worker {
554*35238bceSAndroid Build Coastguard Worker }
555*35238bceSAndroid Build Coastguard Worker
~DrawTests(void)556*35238bceSAndroid Build Coastguard Worker DrawTests::~DrawTests(void)
557*35238bceSAndroid Build Coastguard Worker {
558*35238bceSAndroid Build Coastguard Worker }
559*35238bceSAndroid Build Coastguard Worker
init(void)560*35238bceSAndroid Build Coastguard Worker void DrawTests::init(void)
561*35238bceSAndroid Build Coastguard Worker {
562*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const unalignedGroup =
563*35238bceSAndroid Build Coastguard Worker new tcu::TestCaseGroup(m_testCtx, "unaligned_data", "Test with unaligned data");
564*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const drawArraysGroup = new tcu::TestCaseGroup(m_testCtx, "drawarrays", "draw arrays");
565*35238bceSAndroid Build Coastguard Worker tcu::TestCaseGroup *const drawElementsGroup = new tcu::TestCaseGroup(m_testCtx, "drawelements", "draw elements");
566*35238bceSAndroid Build Coastguard Worker
567*35238bceSAndroid Build Coastguard Worker addChild(unalignedGroup);
568*35238bceSAndroid Build Coastguard Worker addChild(drawArraysGroup);
569*35238bceSAndroid Build Coastguard Worker addChild(drawElementsGroup);
570*35238bceSAndroid Build Coastguard Worker
571*35238bceSAndroid Build Coastguard Worker // .unaligned_data
572*35238bceSAndroid Build Coastguard Worker {
573*35238bceSAndroid Build Coastguard Worker unalignedGroup->addChild(new RandomGroup(m_context, "random", "random draw commands."));
574*35238bceSAndroid Build Coastguard Worker }
575*35238bceSAndroid Build Coastguard Worker
576*35238bceSAndroid Build Coastguard Worker // .drawarrays
577*35238bceSAndroid Build Coastguard Worker {
578*35238bceSAndroid Build Coastguard Worker drawArraysGroup->addChild(new InvalidDrawCase(
579*35238bceSAndroid Build Coastguard Worker m_context, "data_over_bounds_with_count", "Draw arrays vertex elements beyond the array end are accessed",
580*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ARRAYS, InvalidDrawCase::INVALID_DATA_COUNT));
581*35238bceSAndroid Build Coastguard Worker drawArraysGroup->addChild(new InvalidDrawCase(
582*35238bceSAndroid Build Coastguard Worker m_context, "data_over_bounds_with_first", "Draw arrays vertex elements beyond the array end are accessed",
583*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ARRAYS, InvalidDrawCase::INVALID_DATA_FIRST));
584*35238bceSAndroid Build Coastguard Worker drawArraysGroup->addChild(new InvalidDrawCase(m_context, "data_over_bounds_with_primcount",
585*35238bceSAndroid Build Coastguard Worker "Draw arrays vertex elements beyond the array end are accessed",
586*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ARRAYS,
587*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::INVALID_DATA_INSTANCED));
588*35238bceSAndroid Build Coastguard Worker drawArraysGroup->addChild(new InvalidDrawCase(m_context, "reserved_non_zero",
589*35238bceSAndroid Build Coastguard Worker "reservedMustBeZero is set to non-zero value",
590*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ARRAYS, InvalidDrawCase::INVALID_RESERVED));
591*35238bceSAndroid Build Coastguard Worker }
592*35238bceSAndroid Build Coastguard Worker
593*35238bceSAndroid Build Coastguard Worker // .drawelements
594*35238bceSAndroid Build Coastguard Worker {
595*35238bceSAndroid Build Coastguard Worker drawElementsGroup->addChild(new InvalidDrawCase(
596*35238bceSAndroid Build Coastguard Worker m_context, "data_over_bounds_with_count", "Draw elements vertex elements beyond the array end are accessed",
597*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_DATA_COUNT));
598*35238bceSAndroid Build Coastguard Worker drawElementsGroup->addChild(
599*35238bceSAndroid Build Coastguard Worker new InvalidDrawCase(m_context, "data_over_bounds_with_basevertex",
600*35238bceSAndroid Build Coastguard Worker "Draw elements vertex elements beyond the array end are accessed",
601*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_DATA_FIRST));
602*35238bceSAndroid Build Coastguard Worker drawElementsGroup->addChild(
603*35238bceSAndroid Build Coastguard Worker new InvalidDrawCase(m_context, "data_over_bounds_with_indices",
604*35238bceSAndroid Build Coastguard Worker "Draw elements vertex elements beyond the array end are accessed",
605*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_INDEX));
606*35238bceSAndroid Build Coastguard Worker drawElementsGroup->addChild(
607*35238bceSAndroid Build Coastguard Worker new InvalidDrawCase(m_context, "data_over_bounds_with_primcount",
608*35238bceSAndroid Build Coastguard Worker "Draw elements vertex elements beyond the array end are accessed",
609*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_DATA_INSTANCED));
610*35238bceSAndroid Build Coastguard Worker drawElementsGroup->addChild(new InvalidDrawCase(
611*35238bceSAndroid Build Coastguard Worker m_context, "index_over_bounds_with_count", "Draw elements index elements beyond the array end are accessed",
612*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_INDEX_COUNT));
613*35238bceSAndroid Build Coastguard Worker drawElementsGroup->addChild(
614*35238bceSAndroid Build Coastguard Worker new InvalidDrawCase(m_context, "index_over_bounds_with_firstindex",
615*35238bceSAndroid Build Coastguard Worker "Draw elements index elements beyond the array end are accessed",
616*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_INDEX_FIRST));
617*35238bceSAndroid Build Coastguard Worker drawElementsGroup->addChild(
618*35238bceSAndroid Build Coastguard Worker new InvalidDrawCase(m_context, "reserved_non_zero", "reservedMustBeZero is set to non-zero value",
619*35238bceSAndroid Build Coastguard Worker InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_RESERVED));
620*35238bceSAndroid Build Coastguard Worker }
621*35238bceSAndroid Build Coastguard Worker }
622*35238bceSAndroid Build Coastguard Worker
623*35238bceSAndroid Build Coastguard Worker } // namespace Stress
624*35238bceSAndroid Build Coastguard Worker } // namespace gles31
625*35238bceSAndroid Build Coastguard Worker } // namespace deqp
626