1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program OpenGL ES 2.0 Module
3*35238bceSAndroid Build Coastguard Worker * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief Flush and finish tests.
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "es2fFlushFinishTests.hpp"
25*35238bceSAndroid Build Coastguard Worker
26*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluObjectWrapper.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluDrawUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker
31*35238bceSAndroid Build Coastguard Worker #include "glsCalibration.hpp"
32*35238bceSAndroid Build Coastguard Worker
33*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "tcuCPUWarmup.hpp"
36*35238bceSAndroid Build Coastguard Worker
37*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
39*35238bceSAndroid Build Coastguard Worker
40*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
41*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
42*35238bceSAndroid Build Coastguard Worker #include "deClock.h"
43*35238bceSAndroid Build Coastguard Worker #include "deThread.h"
44*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
45*35238bceSAndroid Build Coastguard Worker
46*35238bceSAndroid Build Coastguard Worker #include <algorithm>
47*35238bceSAndroid Build Coastguard Worker
48*35238bceSAndroid Build Coastguard Worker namespace deqp
49*35238bceSAndroid Build Coastguard Worker {
50*35238bceSAndroid Build Coastguard Worker namespace gles2
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker namespace Functional
53*35238bceSAndroid Build Coastguard Worker {
54*35238bceSAndroid Build Coastguard Worker
55*35238bceSAndroid Build Coastguard Worker using deqp::gls::LineParameters;
56*35238bceSAndroid Build Coastguard Worker using deqp::gls::theilSenLinearRegression;
57*35238bceSAndroid Build Coastguard Worker using std::string;
58*35238bceSAndroid Build Coastguard Worker using std::vector;
59*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
60*35238bceSAndroid Build Coastguard Worker using tcu::Vec2;
61*35238bceSAndroid Build Coastguard Worker
62*35238bceSAndroid Build Coastguard Worker namespace
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker
65*35238bceSAndroid Build Coastguard Worker enum
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker MAX_VIEWPORT_SIZE = 128,
68*35238bceSAndroid Build Coastguard Worker MAX_SAMPLE_DURATION_US = 1000 * 1000,
69*35238bceSAndroid Build Coastguard Worker WAIT_TIME_MS = 1200,
70*35238bceSAndroid Build Coastguard Worker NUM_SAMPLES = 25,
71*35238bceSAndroid Build Coastguard Worker MIN_DRAW_CALL_COUNT = 10,
72*35238bceSAndroid Build Coastguard Worker MAX_DRAW_CALL_COUNT = 1 << 20,
73*35238bceSAndroid Build Coastguard Worker NUM_ITERS_IN_SHADER = 10
74*35238bceSAndroid Build Coastguard Worker };
75*35238bceSAndroid Build Coastguard Worker
76*35238bceSAndroid Build Coastguard Worker const float NO_CORR_COEF_THRESHOLD = 0.1f;
77*35238bceSAndroid Build Coastguard Worker const float FLUSH_COEF_THRESHOLD = 0.2f;
78*35238bceSAndroid Build Coastguard Worker const float CORRELATED_COEF_THRESHOLD = 0.5f;
79*35238bceSAndroid Build Coastguard Worker
busyWait(int milliseconds)80*35238bceSAndroid Build Coastguard Worker static void busyWait(int milliseconds)
81*35238bceSAndroid Build Coastguard Worker {
82*35238bceSAndroid Build Coastguard Worker const uint64_t startTime = deGetMicroseconds();
83*35238bceSAndroid Build Coastguard Worker float v = 2.0f;
84*35238bceSAndroid Build Coastguard Worker
85*35238bceSAndroid Build Coastguard Worker for (;;)
86*35238bceSAndroid Build Coastguard Worker {
87*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < 10; i++)
88*35238bceSAndroid Build Coastguard Worker v = deFloatSin(v);
89*35238bceSAndroid Build Coastguard Worker
90*35238bceSAndroid Build Coastguard Worker if (deGetMicroseconds() - startTime >= uint64_t(1000 * milliseconds))
91*35238bceSAndroid Build Coastguard Worker break;
92*35238bceSAndroid Build Coastguard Worker }
93*35238bceSAndroid Build Coastguard Worker }
94*35238bceSAndroid Build Coastguard Worker
95*35238bceSAndroid Build Coastguard Worker class CalibrationFailedException : public std::runtime_error
96*35238bceSAndroid Build Coastguard Worker {
97*35238bceSAndroid Build Coastguard Worker public:
CalibrationFailedException(const std::string & reason)98*35238bceSAndroid Build Coastguard Worker CalibrationFailedException(const std::string &reason) : std::runtime_error(reason)
99*35238bceSAndroid Build Coastguard Worker {
100*35238bceSAndroid Build Coastguard Worker }
101*35238bceSAndroid Build Coastguard Worker };
102*35238bceSAndroid Build Coastguard Worker
103*35238bceSAndroid Build Coastguard Worker class FlushFinishCase : public TestCase
104*35238bceSAndroid Build Coastguard Worker {
105*35238bceSAndroid Build Coastguard Worker public:
106*35238bceSAndroid Build Coastguard Worker enum ExpectedBehavior
107*35238bceSAndroid Build Coastguard Worker {
108*35238bceSAndroid Build Coastguard Worker EXPECT_COEF_LESS_THAN = 0,
109*35238bceSAndroid Build Coastguard Worker EXPECT_COEF_GREATER_THAN,
110*35238bceSAndroid Build Coastguard Worker };
111*35238bceSAndroid Build Coastguard Worker
112*35238bceSAndroid Build Coastguard Worker FlushFinishCase(Context &context, const char *name, const char *description, ExpectedBehavior waitBehavior,
113*35238bceSAndroid Build Coastguard Worker float waitThreshold, ExpectedBehavior readBehavior, float readThreshold);
114*35238bceSAndroid Build Coastguard Worker ~FlushFinishCase(void);
115*35238bceSAndroid Build Coastguard Worker
116*35238bceSAndroid Build Coastguard Worker void init(void);
117*35238bceSAndroid Build Coastguard Worker void deinit(void);
118*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
119*35238bceSAndroid Build Coastguard Worker
120*35238bceSAndroid Build Coastguard Worker struct Sample
121*35238bceSAndroid Build Coastguard Worker {
122*35238bceSAndroid Build Coastguard Worker int numDrawCalls;
123*35238bceSAndroid Build Coastguard Worker uint64_t waitTime;
124*35238bceSAndroid Build Coastguard Worker uint64_t readPixelsTime;
125*35238bceSAndroid Build Coastguard Worker };
126*35238bceSAndroid Build Coastguard Worker
127*35238bceSAndroid Build Coastguard Worker struct CalibrationParams
128*35238bceSAndroid Build Coastguard Worker {
129*35238bceSAndroid Build Coastguard Worker int maxDrawCalls;
130*35238bceSAndroid Build Coastguard Worker };
131*35238bceSAndroid Build Coastguard Worker
132*35238bceSAndroid Build Coastguard Worker protected:
133*35238bceSAndroid Build Coastguard Worker virtual void waitForGL(void) = 0;
134*35238bceSAndroid Build Coastguard Worker
135*35238bceSAndroid Build Coastguard Worker private:
136*35238bceSAndroid Build Coastguard Worker FlushFinishCase(const FlushFinishCase &);
137*35238bceSAndroid Build Coastguard Worker FlushFinishCase &operator=(const FlushFinishCase &);
138*35238bceSAndroid Build Coastguard Worker
139*35238bceSAndroid Build Coastguard Worker CalibrationParams calibrate(void);
140*35238bceSAndroid Build Coastguard Worker void analyzeResults(const std::vector<Sample> &samples, const CalibrationParams &calibrationParams);
141*35238bceSAndroid Build Coastguard Worker
142*35238bceSAndroid Build Coastguard Worker void setupRenderState(void);
143*35238bceSAndroid Build Coastguard Worker void render(int numDrawCalls);
144*35238bceSAndroid Build Coastguard Worker void readPixels(void);
145*35238bceSAndroid Build Coastguard Worker
146*35238bceSAndroid Build Coastguard Worker const ExpectedBehavior m_waitBehavior;
147*35238bceSAndroid Build Coastguard Worker const float m_waitThreshold;
148*35238bceSAndroid Build Coastguard Worker const ExpectedBehavior m_readBehavior;
149*35238bceSAndroid Build Coastguard Worker const float m_readThreshold;
150*35238bceSAndroid Build Coastguard Worker
151*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram *m_program;
152*35238bceSAndroid Build Coastguard Worker };
153*35238bceSAndroid Build Coastguard Worker
FlushFinishCase(Context & context,const char * name,const char * description,ExpectedBehavior waitBehavior,float waitThreshold,ExpectedBehavior readBehavior,float readThreshold)154*35238bceSAndroid Build Coastguard Worker FlushFinishCase::FlushFinishCase(Context &context, const char *name, const char *description,
155*35238bceSAndroid Build Coastguard Worker ExpectedBehavior waitBehavior, float waitThreshold, ExpectedBehavior readBehavior,
156*35238bceSAndroid Build Coastguard Worker float readThreshold)
157*35238bceSAndroid Build Coastguard Worker : TestCase(context, name, description)
158*35238bceSAndroid Build Coastguard Worker , m_waitBehavior(waitBehavior)
159*35238bceSAndroid Build Coastguard Worker , m_waitThreshold(waitThreshold)
160*35238bceSAndroid Build Coastguard Worker , m_readBehavior(readBehavior)
161*35238bceSAndroid Build Coastguard Worker , m_readThreshold(readThreshold)
162*35238bceSAndroid Build Coastguard Worker , m_program(DE_NULL)
163*35238bceSAndroid Build Coastguard Worker {
164*35238bceSAndroid Build Coastguard Worker }
165*35238bceSAndroid Build Coastguard Worker
~FlushFinishCase(void)166*35238bceSAndroid Build Coastguard Worker FlushFinishCase::~FlushFinishCase(void)
167*35238bceSAndroid Build Coastguard Worker {
168*35238bceSAndroid Build Coastguard Worker FlushFinishCase::deinit();
169*35238bceSAndroid Build Coastguard Worker }
170*35238bceSAndroid Build Coastguard Worker
init(void)171*35238bceSAndroid Build Coastguard Worker void FlushFinishCase::init(void)
172*35238bceSAndroid Build Coastguard Worker {
173*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!m_program);
174*35238bceSAndroid Build Coastguard Worker
175*35238bceSAndroid Build Coastguard Worker m_program =
176*35238bceSAndroid Build Coastguard Worker new glu::ShaderProgram(m_context.getRenderContext(),
177*35238bceSAndroid Build Coastguard Worker glu::ProgramSources() << glu::VertexSource("attribute highp vec4 a_position;\n"
178*35238bceSAndroid Build Coastguard Worker "varying highp vec4 v_coord;\n"
179*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
180*35238bceSAndroid Build Coastguard Worker "{\n"
181*35238bceSAndroid Build Coastguard Worker " gl_Position = a_position;\n"
182*35238bceSAndroid Build Coastguard Worker " v_coord = a_position;\n"
183*35238bceSAndroid Build Coastguard Worker "}\n")
184*35238bceSAndroid Build Coastguard Worker << glu::FragmentSource("uniform mediump int u_numIters;\n"
185*35238bceSAndroid Build Coastguard Worker "varying mediump vec4 v_coord;\n"
186*35238bceSAndroid Build Coastguard Worker "void main (void)\n"
187*35238bceSAndroid Build Coastguard Worker "{\n"
188*35238bceSAndroid Build Coastguard Worker " highp vec4 color = v_coord;\n"
189*35238bceSAndroid Build Coastguard Worker " for (int i = 0; i < " +
190*35238bceSAndroid Build Coastguard Worker de::toString(int(NUM_ITERS_IN_SHADER)) +
191*35238bceSAndroid Build Coastguard Worker "; i++)\n"
192*35238bceSAndroid Build Coastguard Worker " color = sin(color);\n"
193*35238bceSAndroid Build Coastguard Worker " gl_FragColor = color;\n"
194*35238bceSAndroid Build Coastguard Worker "}\n"));
195*35238bceSAndroid Build Coastguard Worker
196*35238bceSAndroid Build Coastguard Worker if (!m_program->isOk())
197*35238bceSAndroid Build Coastguard Worker {
198*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << *m_program;
199*35238bceSAndroid Build Coastguard Worker delete m_program;
200*35238bceSAndroid Build Coastguard Worker m_program = DE_NULL;
201*35238bceSAndroid Build Coastguard Worker TCU_FAIL("Compile failed");
202*35238bceSAndroid Build Coastguard Worker }
203*35238bceSAndroid Build Coastguard Worker }
204*35238bceSAndroid Build Coastguard Worker
deinit(void)205*35238bceSAndroid Build Coastguard Worker void FlushFinishCase::deinit(void)
206*35238bceSAndroid Build Coastguard Worker {
207*35238bceSAndroid Build Coastguard Worker delete m_program;
208*35238bceSAndroid Build Coastguard Worker m_program = DE_NULL;
209*35238bceSAndroid Build Coastguard Worker }
210*35238bceSAndroid Build Coastguard Worker
operator <<(tcu::TestLog & log,const FlushFinishCase::Sample & sample)211*35238bceSAndroid Build Coastguard Worker tcu::TestLog &operator<<(tcu::TestLog &log, const FlushFinishCase::Sample &sample)
212*35238bceSAndroid Build Coastguard Worker {
213*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << sample.numDrawCalls << " calls:\t" << sample.waitTime << " us wait,\t"
214*35238bceSAndroid Build Coastguard Worker << sample.readPixelsTime << " us read" << TestLog::EndMessage;
215*35238bceSAndroid Build Coastguard Worker return log;
216*35238bceSAndroid Build Coastguard Worker }
217*35238bceSAndroid Build Coastguard Worker
setupRenderState(void)218*35238bceSAndroid Build Coastguard Worker void FlushFinishCase::setupRenderState(void)
219*35238bceSAndroid Build Coastguard Worker {
220*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
221*35238bceSAndroid Build Coastguard Worker const int posLoc = gl.getAttribLocation(m_program->getProgram(), "a_position");
222*35238bceSAndroid Build Coastguard Worker const int viewportW = de::min<int>(m_context.getRenderTarget().getWidth(), MAX_VIEWPORT_SIZE);
223*35238bceSAndroid Build Coastguard Worker const int viewportH = de::min<int>(m_context.getRenderTarget().getHeight(), MAX_VIEWPORT_SIZE);
224*35238bceSAndroid Build Coastguard Worker
225*35238bceSAndroid Build Coastguard Worker static const float s_positions[] = {-1.0f, -1.0f, +1.0f, -1.0f, -1.0f, +1.0f, +1.0f, +1.0f};
226*35238bceSAndroid Build Coastguard Worker
227*35238bceSAndroid Build Coastguard Worker TCU_CHECK(posLoc >= 0);
228*35238bceSAndroid Build Coastguard Worker
229*35238bceSAndroid Build Coastguard Worker gl.viewport(0, 0, viewportW, viewportH);
230*35238bceSAndroid Build Coastguard Worker gl.useProgram(m_program->getProgram());
231*35238bceSAndroid Build Coastguard Worker gl.enableVertexAttribArray(posLoc);
232*35238bceSAndroid Build Coastguard Worker gl.vertexAttribPointer(posLoc, 2, GL_FLOAT, GL_FALSE, 0, &s_positions[0]);
233*35238bceSAndroid Build Coastguard Worker gl.enable(GL_BLEND);
234*35238bceSAndroid Build Coastguard Worker gl.blendFunc(GL_ONE, GL_ONE);
235*35238bceSAndroid Build Coastguard Worker gl.blendEquation(GL_FUNC_ADD);
236*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to set up render state");
237*35238bceSAndroid Build Coastguard Worker }
238*35238bceSAndroid Build Coastguard Worker
render(int numDrawCalls)239*35238bceSAndroid Build Coastguard Worker void FlushFinishCase::render(int numDrawCalls)
240*35238bceSAndroid Build Coastguard Worker {
241*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
242*35238bceSAndroid Build Coastguard Worker
243*35238bceSAndroid Build Coastguard Worker const uint8_t indices[] = {0, 1, 2, 2, 1, 3};
244*35238bceSAndroid Build Coastguard Worker
245*35238bceSAndroid Build Coastguard Worker gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
246*35238bceSAndroid Build Coastguard Worker
247*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < numDrawCalls; ndx++)
248*35238bceSAndroid Build Coastguard Worker gl.drawElements(GL_TRIANGLES, DE_LENGTH_OF_ARRAY(indices), GL_UNSIGNED_BYTE, &indices[0]);
249*35238bceSAndroid Build Coastguard Worker }
250*35238bceSAndroid Build Coastguard Worker
readPixels(void)251*35238bceSAndroid Build Coastguard Worker void FlushFinishCase::readPixels(void)
252*35238bceSAndroid Build Coastguard Worker {
253*35238bceSAndroid Build Coastguard Worker const glw::Functions &gl = m_context.getRenderContext().getFunctions();
254*35238bceSAndroid Build Coastguard Worker uint8_t tmp[4];
255*35238bceSAndroid Build Coastguard Worker
256*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &tmp);
257*35238bceSAndroid Build Coastguard Worker }
258*35238bceSAndroid Build Coastguard Worker
calibrate(void)259*35238bceSAndroid Build Coastguard Worker FlushFinishCase::CalibrationParams FlushFinishCase::calibrate(void)
260*35238bceSAndroid Build Coastguard Worker {
261*35238bceSAndroid Build Coastguard Worker tcu::ScopedLogSection section(m_testCtx.getLog(), "CalibrationInfo", "Calibration info");
262*35238bceSAndroid Build Coastguard Worker CalibrationParams params;
263*35238bceSAndroid Build Coastguard Worker
264*35238bceSAndroid Build Coastguard Worker // Find draw call count that results in desired maximum time.
265*35238bceSAndroid Build Coastguard Worker {
266*35238bceSAndroid Build Coastguard Worker uint64_t prevDuration = 0;
267*35238bceSAndroid Build Coastguard Worker int prevDrawCount = 1;
268*35238bceSAndroid Build Coastguard Worker int curDrawCount = 1;
269*35238bceSAndroid Build Coastguard Worker
270*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message
271*35238bceSAndroid Build Coastguard Worker << "Calibrating maximum draw call count, target duration = " << int(MAX_SAMPLE_DURATION_US)
272*35238bceSAndroid Build Coastguard Worker << " us" << TestLog::EndMessage;
273*35238bceSAndroid Build Coastguard Worker
274*35238bceSAndroid Build Coastguard Worker for (;;)
275*35238bceSAndroid Build Coastguard Worker {
276*35238bceSAndroid Build Coastguard Worker uint64_t curDuration;
277*35238bceSAndroid Build Coastguard Worker
278*35238bceSAndroid Build Coastguard Worker {
279*35238bceSAndroid Build Coastguard Worker const uint64_t startTime = deGetMicroseconds();
280*35238bceSAndroid Build Coastguard Worker render(curDrawCount);
281*35238bceSAndroid Build Coastguard Worker readPixels();
282*35238bceSAndroid Build Coastguard Worker curDuration = deGetMicroseconds() - startTime;
283*35238bceSAndroid Build Coastguard Worker }
284*35238bceSAndroid Build Coastguard Worker
285*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Duration with " << curDrawCount
286*35238bceSAndroid Build Coastguard Worker << " draw calls = " << curDuration << " us" << TestLog::EndMessage;
287*35238bceSAndroid Build Coastguard Worker
288*35238bceSAndroid Build Coastguard Worker if (curDuration > MAX_SAMPLE_DURATION_US)
289*35238bceSAndroid Build Coastguard Worker {
290*35238bceSAndroid Build Coastguard Worker if (curDrawCount > 1)
291*35238bceSAndroid Build Coastguard Worker {
292*35238bceSAndroid Build Coastguard Worker // Compute final count by using linear estimation.
293*35238bceSAndroid Build Coastguard Worker const float a = float(curDuration - prevDuration) / float(curDrawCount - prevDrawCount);
294*35238bceSAndroid Build Coastguard Worker const float b = float(prevDuration) - a * float(prevDrawCount);
295*35238bceSAndroid Build Coastguard Worker const float est = (float(MAX_SAMPLE_DURATION_US) - b) / a;
296*35238bceSAndroid Build Coastguard Worker
297*35238bceSAndroid Build Coastguard Worker curDrawCount = de::clamp(deFloorFloatToInt32(est), 1, int(MAX_DRAW_CALL_COUNT));
298*35238bceSAndroid Build Coastguard Worker }
299*35238bceSAndroid Build Coastguard Worker // else: Settle on 1.
300*35238bceSAndroid Build Coastguard Worker
301*35238bceSAndroid Build Coastguard Worker break;
302*35238bceSAndroid Build Coastguard Worker }
303*35238bceSAndroid Build Coastguard Worker else if (curDrawCount >= MAX_DRAW_CALL_COUNT)
304*35238bceSAndroid Build Coastguard Worker break; // Settle on maximum.
305*35238bceSAndroid Build Coastguard Worker else
306*35238bceSAndroid Build Coastguard Worker {
307*35238bceSAndroid Build Coastguard Worker prevDrawCount = curDrawCount;
308*35238bceSAndroid Build Coastguard Worker prevDuration = curDuration;
309*35238bceSAndroid Build Coastguard Worker curDrawCount = curDrawCount * 2;
310*35238bceSAndroid Build Coastguard Worker }
311*35238bceSAndroid Build Coastguard Worker }
312*35238bceSAndroid Build Coastguard Worker
313*35238bceSAndroid Build Coastguard Worker params.maxDrawCalls = curDrawCount;
314*35238bceSAndroid Build Coastguard Worker
315*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Integer("MaxDrawCalls", "Maximum number of draw calls", "", QP_KEY_TAG_NONE,
316*35238bceSAndroid Build Coastguard Worker params.maxDrawCalls);
317*35238bceSAndroid Build Coastguard Worker }
318*35238bceSAndroid Build Coastguard Worker
319*35238bceSAndroid Build Coastguard Worker // Quick check.
320*35238bceSAndroid Build Coastguard Worker if (params.maxDrawCalls < MIN_DRAW_CALL_COUNT)
321*35238bceSAndroid Build Coastguard Worker throw CalibrationFailedException("Calibration failed, maximum draw call count is too low");
322*35238bceSAndroid Build Coastguard Worker
323*35238bceSAndroid Build Coastguard Worker return params;
324*35238bceSAndroid Build Coastguard Worker }
325*35238bceSAndroid Build Coastguard Worker
326*35238bceSAndroid Build Coastguard Worker struct CompareSampleDrawCount
327*35238bceSAndroid Build Coastguard Worker {
operator ()deqp::gles2::Functional::__anonc425510d0111::CompareSampleDrawCount328*35238bceSAndroid Build Coastguard Worker bool operator()(const FlushFinishCase::Sample &a, const FlushFinishCase::Sample &b) const
329*35238bceSAndroid Build Coastguard Worker {
330*35238bceSAndroid Build Coastguard Worker return a.numDrawCalls < b.numDrawCalls;
331*35238bceSAndroid Build Coastguard Worker }
332*35238bceSAndroid Build Coastguard Worker };
333*35238bceSAndroid Build Coastguard Worker
getPointsFromSamples(const std::vector<FlushFinishCase::Sample> & samples,const uint64_t FlushFinishCase::Sample::* field)334*35238bceSAndroid Build Coastguard Worker std::vector<Vec2> getPointsFromSamples(const std::vector<FlushFinishCase::Sample> &samples,
335*35238bceSAndroid Build Coastguard Worker const uint64_t FlushFinishCase::Sample::*field)
336*35238bceSAndroid Build Coastguard Worker {
337*35238bceSAndroid Build Coastguard Worker vector<Vec2> points(samples.size());
338*35238bceSAndroid Build Coastguard Worker
339*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < samples.size(); ndx++)
340*35238bceSAndroid Build Coastguard Worker points[ndx] = Vec2(float(samples[ndx].numDrawCalls), float(samples[ndx].*field));
341*35238bceSAndroid Build Coastguard Worker
342*35238bceSAndroid Build Coastguard Worker return points;
343*35238bceSAndroid Build Coastguard Worker }
344*35238bceSAndroid Build Coastguard Worker
345*35238bceSAndroid Build Coastguard Worker template <typename T>
getMaximumValue(const std::vector<FlushFinishCase::Sample> & samples,const T FlushFinishCase::Sample::* field)346*35238bceSAndroid Build Coastguard Worker T getMaximumValue(const std::vector<FlushFinishCase::Sample> &samples, const T FlushFinishCase::Sample::*field)
347*35238bceSAndroid Build Coastguard Worker {
348*35238bceSAndroid Build Coastguard Worker DE_ASSERT(!samples.empty());
349*35238bceSAndroid Build Coastguard Worker
350*35238bceSAndroid Build Coastguard Worker T maxVal = samples[0].*field;
351*35238bceSAndroid Build Coastguard Worker
352*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 1; ndx < samples.size(); ndx++)
353*35238bceSAndroid Build Coastguard Worker maxVal = de::max(maxVal, samples[ndx].*field);
354*35238bceSAndroid Build Coastguard Worker
355*35238bceSAndroid Build Coastguard Worker return maxVal;
356*35238bceSAndroid Build Coastguard Worker }
357*35238bceSAndroid Build Coastguard Worker
analyzeResults(const std::vector<Sample> & samples,const CalibrationParams & calibrationParams)358*35238bceSAndroid Build Coastguard Worker void FlushFinishCase::analyzeResults(const std::vector<Sample> &samples, const CalibrationParams &calibrationParams)
359*35238bceSAndroid Build Coastguard Worker {
360*35238bceSAndroid Build Coastguard Worker const vector<Vec2> waitTimes = getPointsFromSamples(samples, &Sample::waitTime);
361*35238bceSAndroid Build Coastguard Worker const vector<Vec2> readTimes = getPointsFromSamples(samples, &Sample::readPixelsTime);
362*35238bceSAndroid Build Coastguard Worker const LineParameters waitLine = theilSenLinearRegression(waitTimes);
363*35238bceSAndroid Build Coastguard Worker const LineParameters readLine = theilSenLinearRegression(readTimes);
364*35238bceSAndroid Build Coastguard Worker const float normWaitCoef =
365*35238bceSAndroid Build Coastguard Worker waitLine.coefficient * float(calibrationParams.maxDrawCalls) / float(MAX_SAMPLE_DURATION_US);
366*35238bceSAndroid Build Coastguard Worker const float normReadCoef =
367*35238bceSAndroid Build Coastguard Worker readLine.coefficient * float(calibrationParams.maxDrawCalls) / float(MAX_SAMPLE_DURATION_US);
368*35238bceSAndroid Build Coastguard Worker bool allOk = true;
369*35238bceSAndroid Build Coastguard Worker
370*35238bceSAndroid Build Coastguard Worker {
371*35238bceSAndroid Build Coastguard Worker tcu::ScopedLogSection section(m_testCtx.getLog(), "Samples", "Samples");
372*35238bceSAndroid Build Coastguard Worker vector<Sample> sortedSamples(samples.begin(), samples.end());
373*35238bceSAndroid Build Coastguard Worker
374*35238bceSAndroid Build Coastguard Worker std::sort(sortedSamples.begin(), sortedSamples.end(), CompareSampleDrawCount());
375*35238bceSAndroid Build Coastguard Worker
376*35238bceSAndroid Build Coastguard Worker for (vector<Sample>::const_iterator iter = sortedSamples.begin(); iter != sortedSamples.end(); ++iter)
377*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << *iter;
378*35238bceSAndroid Build Coastguard Worker }
379*35238bceSAndroid Build Coastguard Worker
380*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Float("WaitCoefficient", "Wait coefficient", "", QP_KEY_TAG_NONE,
381*35238bceSAndroid Build Coastguard Worker waitLine.coefficient)
382*35238bceSAndroid Build Coastguard Worker << TestLog::Float("ReadCoefficient", "Read coefficient", "", QP_KEY_TAG_NONE,
383*35238bceSAndroid Build Coastguard Worker readLine.coefficient)
384*35238bceSAndroid Build Coastguard Worker << TestLog::Float("NormalizedWaitCoefficient", "Normalized wait coefficient", "",
385*35238bceSAndroid Build Coastguard Worker QP_KEY_TAG_NONE, normWaitCoef)
386*35238bceSAndroid Build Coastguard Worker << TestLog::Float("NormalizedReadCoefficient", "Normalized read coefficient", "",
387*35238bceSAndroid Build Coastguard Worker QP_KEY_TAG_NONE, normReadCoef);
388*35238bceSAndroid Build Coastguard Worker
389*35238bceSAndroid Build Coastguard Worker {
390*35238bceSAndroid Build Coastguard Worker const bool waitCorrelated = normWaitCoef > CORRELATED_COEF_THRESHOLD;
391*35238bceSAndroid Build Coastguard Worker const bool readCorrelated = normReadCoef > CORRELATED_COEF_THRESHOLD;
392*35238bceSAndroid Build Coastguard Worker const bool waitNotCorr = normWaitCoef < NO_CORR_COEF_THRESHOLD;
393*35238bceSAndroid Build Coastguard Worker const bool readNotCorr = normReadCoef < NO_CORR_COEF_THRESHOLD;
394*35238bceSAndroid Build Coastguard Worker
395*35238bceSAndroid Build Coastguard Worker if (waitCorrelated || waitNotCorr)
396*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Wait time is" << (waitCorrelated ? "" : " NOT")
397*35238bceSAndroid Build Coastguard Worker << " correlated to rendering workload size." << TestLog::EndMessage;
398*35238bceSAndroid Build Coastguard Worker else
399*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message
400*35238bceSAndroid Build Coastguard Worker << "Warning: Wait time correlation to rendering workload size is unclear."
401*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
402*35238bceSAndroid Build Coastguard Worker
403*35238bceSAndroid Build Coastguard Worker if (readCorrelated || readNotCorr)
404*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Read time is" << (readCorrelated ? "" : " NOT")
405*35238bceSAndroid Build Coastguard Worker << " correlated to rendering workload size." << TestLog::EndMessage;
406*35238bceSAndroid Build Coastguard Worker else
407*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message
408*35238bceSAndroid Build Coastguard Worker << "Warning: Read time correlation to rendering workload size is unclear."
409*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
410*35238bceSAndroid Build Coastguard Worker }
411*35238bceSAndroid Build Coastguard Worker
412*35238bceSAndroid Build Coastguard Worker for (int ndx = 0; ndx < 2; ndx++)
413*35238bceSAndroid Build Coastguard Worker {
414*35238bceSAndroid Build Coastguard Worker const float coef = ndx == 0 ? normWaitCoef : normReadCoef;
415*35238bceSAndroid Build Coastguard Worker const char *name = ndx == 0 ? "wait" : "read";
416*35238bceSAndroid Build Coastguard Worker const ExpectedBehavior behavior = ndx == 0 ? m_waitBehavior : m_readBehavior;
417*35238bceSAndroid Build Coastguard Worker const float threshold = ndx == 0 ? m_waitThreshold : m_readThreshold;
418*35238bceSAndroid Build Coastguard Worker const bool isOk = behavior == EXPECT_COEF_GREATER_THAN ? coef > threshold :
419*35238bceSAndroid Build Coastguard Worker behavior == EXPECT_COEF_LESS_THAN ? coef < threshold :
420*35238bceSAndroid Build Coastguard Worker false;
421*35238bceSAndroid Build Coastguard Worker const char *cmpName = behavior == EXPECT_COEF_GREATER_THAN ? "greater than" :
422*35238bceSAndroid Build Coastguard Worker behavior == EXPECT_COEF_LESS_THAN ? "less than" :
423*35238bceSAndroid Build Coastguard Worker DE_NULL;
424*35238bceSAndroid Build Coastguard Worker
425*35238bceSAndroid Build Coastguard Worker if (!isOk)
426*35238bceSAndroid Build Coastguard Worker {
427*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "ERROR: Expected " << name << " coefficient to be " << cmpName
428*35238bceSAndroid Build Coastguard Worker << " " << threshold << TestLog::EndMessage;
429*35238bceSAndroid Build Coastguard Worker allOk = false;
430*35238bceSAndroid Build Coastguard Worker }
431*35238bceSAndroid Build Coastguard Worker }
432*35238bceSAndroid Build Coastguard Worker
433*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(allOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_COMPATIBILITY_WARNING,
434*35238bceSAndroid Build Coastguard Worker allOk ? "Pass" : "Suspicious performance behavior");
435*35238bceSAndroid Build Coastguard Worker }
436*35238bceSAndroid Build Coastguard Worker
iterate(void)437*35238bceSAndroid Build Coastguard Worker FlushFinishCase::IterateResult FlushFinishCase::iterate(void)
438*35238bceSAndroid Build Coastguard Worker {
439*35238bceSAndroid Build Coastguard Worker vector<Sample> samples(NUM_SAMPLES);
440*35238bceSAndroid Build Coastguard Worker CalibrationParams params;
441*35238bceSAndroid Build Coastguard Worker
442*35238bceSAndroid Build Coastguard Worker tcu::warmupCPU();
443*35238bceSAndroid Build Coastguard Worker
444*35238bceSAndroid Build Coastguard Worker setupRenderState();
445*35238bceSAndroid Build Coastguard Worker
446*35238bceSAndroid Build Coastguard Worker // Do one full render cycle.
447*35238bceSAndroid Build Coastguard Worker {
448*35238bceSAndroid Build Coastguard Worker render(1);
449*35238bceSAndroid Build Coastguard Worker readPixels();
450*35238bceSAndroid Build Coastguard Worker }
451*35238bceSAndroid Build Coastguard Worker
452*35238bceSAndroid Build Coastguard Worker // Calibrate.
453*35238bceSAndroid Build Coastguard Worker try
454*35238bceSAndroid Build Coastguard Worker {
455*35238bceSAndroid Build Coastguard Worker params = calibrate();
456*35238bceSAndroid Build Coastguard Worker }
457*35238bceSAndroid Build Coastguard Worker catch (const CalibrationFailedException &e)
458*35238bceSAndroid Build Coastguard Worker {
459*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, e.what());
460*35238bceSAndroid Build Coastguard Worker return STOP;
461*35238bceSAndroid Build Coastguard Worker }
462*35238bceSAndroid Build Coastguard Worker
463*35238bceSAndroid Build Coastguard Worker // Do measurement.
464*35238bceSAndroid Build Coastguard Worker {
465*35238bceSAndroid Build Coastguard Worker de::Random rnd(123);
466*35238bceSAndroid Build Coastguard Worker
467*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < samples.size(); ndx++)
468*35238bceSAndroid Build Coastguard Worker {
469*35238bceSAndroid Build Coastguard Worker const int drawCallCount = rnd.getInt(1, params.maxDrawCalls);
470*35238bceSAndroid Build Coastguard Worker uint64_t waitStartTime;
471*35238bceSAndroid Build Coastguard Worker uint64_t readStartTime;
472*35238bceSAndroid Build Coastguard Worker uint64_t readFinishTime;
473*35238bceSAndroid Build Coastguard Worker
474*35238bceSAndroid Build Coastguard Worker render(drawCallCount);
475*35238bceSAndroid Build Coastguard Worker
476*35238bceSAndroid Build Coastguard Worker waitStartTime = deGetMicroseconds();
477*35238bceSAndroid Build Coastguard Worker waitForGL();
478*35238bceSAndroid Build Coastguard Worker
479*35238bceSAndroid Build Coastguard Worker readStartTime = deGetMicroseconds();
480*35238bceSAndroid Build Coastguard Worker readPixels();
481*35238bceSAndroid Build Coastguard Worker readFinishTime = deGetMicroseconds();
482*35238bceSAndroid Build Coastguard Worker
483*35238bceSAndroid Build Coastguard Worker samples[ndx].numDrawCalls = drawCallCount;
484*35238bceSAndroid Build Coastguard Worker samples[ndx].waitTime = readStartTime - waitStartTime;
485*35238bceSAndroid Build Coastguard Worker samples[ndx].readPixelsTime = readFinishTime - readStartTime;
486*35238bceSAndroid Build Coastguard Worker
487*35238bceSAndroid Build Coastguard Worker if (m_testCtx.getWatchDog())
488*35238bceSAndroid Build Coastguard Worker qpWatchDog_touch(m_testCtx.getWatchDog());
489*35238bceSAndroid Build Coastguard Worker }
490*35238bceSAndroid Build Coastguard Worker }
491*35238bceSAndroid Build Coastguard Worker
492*35238bceSAndroid Build Coastguard Worker // Analyze - sets test case result.
493*35238bceSAndroid Build Coastguard Worker analyzeResults(samples, params);
494*35238bceSAndroid Build Coastguard Worker
495*35238bceSAndroid Build Coastguard Worker return STOP;
496*35238bceSAndroid Build Coastguard Worker }
497*35238bceSAndroid Build Coastguard Worker
498*35238bceSAndroid Build Coastguard Worker class WaitOnlyCase : public FlushFinishCase
499*35238bceSAndroid Build Coastguard Worker {
500*35238bceSAndroid Build Coastguard Worker public:
WaitOnlyCase(Context & context)501*35238bceSAndroid Build Coastguard Worker WaitOnlyCase(Context &context)
502*35238bceSAndroid Build Coastguard Worker : FlushFinishCase(context, "wait", "Wait only", EXPECT_COEF_LESS_THAN, NO_CORR_COEF_THRESHOLD,
503*35238bceSAndroid Build Coastguard Worker EXPECT_COEF_GREATER_THAN, -1000.0f /* practically nothing is expected */)
504*35238bceSAndroid Build Coastguard Worker {
505*35238bceSAndroid Build Coastguard Worker }
506*35238bceSAndroid Build Coastguard Worker
init(void)507*35238bceSAndroid Build Coastguard Worker void init(void)
508*35238bceSAndroid Build Coastguard Worker {
509*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << int(WAIT_TIME_MS) << " ms busy wait" << TestLog::EndMessage;
510*35238bceSAndroid Build Coastguard Worker FlushFinishCase::init();
511*35238bceSAndroid Build Coastguard Worker }
512*35238bceSAndroid Build Coastguard Worker
513*35238bceSAndroid Build Coastguard Worker protected:
waitForGL(void)514*35238bceSAndroid Build Coastguard Worker void waitForGL(void)
515*35238bceSAndroid Build Coastguard Worker {
516*35238bceSAndroid Build Coastguard Worker busyWait(WAIT_TIME_MS);
517*35238bceSAndroid Build Coastguard Worker }
518*35238bceSAndroid Build Coastguard Worker };
519*35238bceSAndroid Build Coastguard Worker
520*35238bceSAndroid Build Coastguard Worker class FlushOnlyCase : public FlushFinishCase
521*35238bceSAndroid Build Coastguard Worker {
522*35238bceSAndroid Build Coastguard Worker public:
FlushOnlyCase(Context & context)523*35238bceSAndroid Build Coastguard Worker FlushOnlyCase(Context &context)
524*35238bceSAndroid Build Coastguard Worker : FlushFinishCase(context, "flush", "Flush only", EXPECT_COEF_LESS_THAN, FLUSH_COEF_THRESHOLD,
525*35238bceSAndroid Build Coastguard Worker EXPECT_COEF_GREATER_THAN, CORRELATED_COEF_THRESHOLD)
526*35238bceSAndroid Build Coastguard Worker {
527*35238bceSAndroid Build Coastguard Worker }
528*35238bceSAndroid Build Coastguard Worker
init(void)529*35238bceSAndroid Build Coastguard Worker void init(void)
530*35238bceSAndroid Build Coastguard Worker {
531*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Single call to glFlush()" << TestLog::EndMessage;
532*35238bceSAndroid Build Coastguard Worker FlushFinishCase::init();
533*35238bceSAndroid Build Coastguard Worker }
534*35238bceSAndroid Build Coastguard Worker
535*35238bceSAndroid Build Coastguard Worker protected:
waitForGL(void)536*35238bceSAndroid Build Coastguard Worker void waitForGL(void)
537*35238bceSAndroid Build Coastguard Worker {
538*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().flush();
539*35238bceSAndroid Build Coastguard Worker }
540*35238bceSAndroid Build Coastguard Worker };
541*35238bceSAndroid Build Coastguard Worker
542*35238bceSAndroid Build Coastguard Worker class FlushWaitCase : public FlushFinishCase
543*35238bceSAndroid Build Coastguard Worker {
544*35238bceSAndroid Build Coastguard Worker public:
FlushWaitCase(Context & context)545*35238bceSAndroid Build Coastguard Worker FlushWaitCase(Context &context)
546*35238bceSAndroid Build Coastguard Worker : FlushFinishCase(context, "flush_wait", "Wait after flushing", EXPECT_COEF_LESS_THAN, FLUSH_COEF_THRESHOLD,
547*35238bceSAndroid Build Coastguard Worker EXPECT_COEF_LESS_THAN, NO_CORR_COEF_THRESHOLD)
548*35238bceSAndroid Build Coastguard Worker {
549*35238bceSAndroid Build Coastguard Worker }
550*35238bceSAndroid Build Coastguard Worker
init(void)551*35238bceSAndroid Build Coastguard Worker void init(void)
552*35238bceSAndroid Build Coastguard Worker {
553*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "glFlush() followed by " << int(WAIT_TIME_MS) << " ms busy wait"
554*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
555*35238bceSAndroid Build Coastguard Worker FlushFinishCase::init();
556*35238bceSAndroid Build Coastguard Worker }
557*35238bceSAndroid Build Coastguard Worker
558*35238bceSAndroid Build Coastguard Worker protected:
waitForGL(void)559*35238bceSAndroid Build Coastguard Worker void waitForGL(void)
560*35238bceSAndroid Build Coastguard Worker {
561*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().flush();
562*35238bceSAndroid Build Coastguard Worker busyWait(WAIT_TIME_MS);
563*35238bceSAndroid Build Coastguard Worker }
564*35238bceSAndroid Build Coastguard Worker };
565*35238bceSAndroid Build Coastguard Worker
566*35238bceSAndroid Build Coastguard Worker class FinishOnlyCase : public FlushFinishCase
567*35238bceSAndroid Build Coastguard Worker {
568*35238bceSAndroid Build Coastguard Worker public:
FinishOnlyCase(Context & context)569*35238bceSAndroid Build Coastguard Worker FinishOnlyCase(Context &context)
570*35238bceSAndroid Build Coastguard Worker : FlushFinishCase(context, "finish", "Finish only", EXPECT_COEF_GREATER_THAN, CORRELATED_COEF_THRESHOLD,
571*35238bceSAndroid Build Coastguard Worker EXPECT_COEF_LESS_THAN, NO_CORR_COEF_THRESHOLD)
572*35238bceSAndroid Build Coastguard Worker {
573*35238bceSAndroid Build Coastguard Worker }
574*35238bceSAndroid Build Coastguard Worker
init(void)575*35238bceSAndroid Build Coastguard Worker void init(void)
576*35238bceSAndroid Build Coastguard Worker {
577*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "Single call to glFinish()" << TestLog::EndMessage;
578*35238bceSAndroid Build Coastguard Worker FlushFinishCase::init();
579*35238bceSAndroid Build Coastguard Worker }
580*35238bceSAndroid Build Coastguard Worker
581*35238bceSAndroid Build Coastguard Worker protected:
waitForGL(void)582*35238bceSAndroid Build Coastguard Worker void waitForGL(void)
583*35238bceSAndroid Build Coastguard Worker {
584*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().finish();
585*35238bceSAndroid Build Coastguard Worker }
586*35238bceSAndroid Build Coastguard Worker };
587*35238bceSAndroid Build Coastguard Worker
588*35238bceSAndroid Build Coastguard Worker class FinishWaitCase : public FlushFinishCase
589*35238bceSAndroid Build Coastguard Worker {
590*35238bceSAndroid Build Coastguard Worker public:
FinishWaitCase(Context & context)591*35238bceSAndroid Build Coastguard Worker FinishWaitCase(Context &context)
592*35238bceSAndroid Build Coastguard Worker : FlushFinishCase(context, "finish_wait", "Finish and wait", EXPECT_COEF_GREATER_THAN,
593*35238bceSAndroid Build Coastguard Worker CORRELATED_COEF_THRESHOLD, EXPECT_COEF_LESS_THAN, NO_CORR_COEF_THRESHOLD)
594*35238bceSAndroid Build Coastguard Worker {
595*35238bceSAndroid Build Coastguard Worker }
596*35238bceSAndroid Build Coastguard Worker
init(void)597*35238bceSAndroid Build Coastguard Worker void init(void)
598*35238bceSAndroid Build Coastguard Worker {
599*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << TestLog::Message << "glFinish() followed by " << int(WAIT_TIME_MS) << " ms busy wait"
600*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
601*35238bceSAndroid Build Coastguard Worker FlushFinishCase::init();
602*35238bceSAndroid Build Coastguard Worker }
603*35238bceSAndroid Build Coastguard Worker
604*35238bceSAndroid Build Coastguard Worker protected:
waitForGL(void)605*35238bceSAndroid Build Coastguard Worker void waitForGL(void)
606*35238bceSAndroid Build Coastguard Worker {
607*35238bceSAndroid Build Coastguard Worker m_context.getRenderContext().getFunctions().finish();
608*35238bceSAndroid Build Coastguard Worker busyWait(WAIT_TIME_MS);
609*35238bceSAndroid Build Coastguard Worker }
610*35238bceSAndroid Build Coastguard Worker };
611*35238bceSAndroid Build Coastguard Worker
612*35238bceSAndroid Build Coastguard Worker } // namespace
613*35238bceSAndroid Build Coastguard Worker
FlushFinishTests(Context & context)614*35238bceSAndroid Build Coastguard Worker FlushFinishTests::FlushFinishTests(Context &context) : TestCaseGroup(context, "flush_finish", "Flush and Finish tests")
615*35238bceSAndroid Build Coastguard Worker {
616*35238bceSAndroid Build Coastguard Worker }
617*35238bceSAndroid Build Coastguard Worker
~FlushFinishTests(void)618*35238bceSAndroid Build Coastguard Worker FlushFinishTests::~FlushFinishTests(void)
619*35238bceSAndroid Build Coastguard Worker {
620*35238bceSAndroid Build Coastguard Worker }
621*35238bceSAndroid Build Coastguard Worker
init(void)622*35238bceSAndroid Build Coastguard Worker void FlushFinishTests::init(void)
623*35238bceSAndroid Build Coastguard Worker {
624*35238bceSAndroid Build Coastguard Worker addChild(new WaitOnlyCase(m_context));
625*35238bceSAndroid Build Coastguard Worker addChild(new FlushOnlyCase(m_context));
626*35238bceSAndroid Build Coastguard Worker addChild(new FlushWaitCase(m_context));
627*35238bceSAndroid Build Coastguard Worker addChild(new FinishOnlyCase(m_context));
628*35238bceSAndroid Build Coastguard Worker addChild(new FinishWaitCase(m_context));
629*35238bceSAndroid Build Coastguard Worker }
630*35238bceSAndroid Build Coastguard Worker
631*35238bceSAndroid Build Coastguard Worker } // namespace Functional
632*35238bceSAndroid Build Coastguard Worker } // namespace gles2
633*35238bceSAndroid Build Coastguard Worker } // namespace deqp
634