xref: /aosp_15_r20/external/deqp/modules/gles3/performance/es3pDepthTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.0 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Depth buffer performance tests.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es3pDepthTests.hpp"
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "glsCalibration.hpp"
27*35238bceSAndroid Build Coastguard Worker 
28*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluObjectWrapper.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "gluPixelTransfer.hpp"
31*35238bceSAndroid Build Coastguard Worker 
32*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
34*35238bceSAndroid Build Coastguard Worker 
35*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "tcuStringTemplate.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "tcuCPUWarmup.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "tcuResultCollector.hpp"
40*35238bceSAndroid Build Coastguard Worker 
41*35238bceSAndroid Build Coastguard Worker #include "deClock.h"
42*35238bceSAndroid Build Coastguard Worker #include "deString.h"
43*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
44*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
45*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
46*35238bceSAndroid Build Coastguard Worker #include "deUniquePtr.hpp"
47*35238bceSAndroid Build Coastguard Worker 
48*35238bceSAndroid Build Coastguard Worker #include <vector>
49*35238bceSAndroid Build Coastguard Worker #include <algorithm>
50*35238bceSAndroid Build Coastguard Worker 
51*35238bceSAndroid Build Coastguard Worker namespace deqp
52*35238bceSAndroid Build Coastguard Worker {
53*35238bceSAndroid Build Coastguard Worker namespace gles3
54*35238bceSAndroid Build Coastguard Worker {
55*35238bceSAndroid Build Coastguard Worker namespace Performance
56*35238bceSAndroid Build Coastguard Worker {
57*35238bceSAndroid Build Coastguard Worker namespace
58*35238bceSAndroid Build Coastguard Worker {
59*35238bceSAndroid Build Coastguard Worker using namespace glw;
60*35238bceSAndroid Build Coastguard Worker using de::MovePtr;
61*35238bceSAndroid Build Coastguard Worker using glu::ProgramSources;
62*35238bceSAndroid Build Coastguard Worker using glu::RenderContext;
63*35238bceSAndroid Build Coastguard Worker using glu::ShaderSource;
64*35238bceSAndroid Build Coastguard Worker using std::map;
65*35238bceSAndroid Build Coastguard Worker using std::string;
66*35238bceSAndroid Build Coastguard Worker using std::vector;
67*35238bceSAndroid Build Coastguard Worker using tcu::TestContext;
68*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
69*35238bceSAndroid Build Coastguard Worker using tcu::Vec2;
70*35238bceSAndroid Build Coastguard Worker using tcu::Vec3;
71*35238bceSAndroid Build Coastguard Worker using tcu::Vec4;
72*35238bceSAndroid Build Coastguard Worker 
73*35238bceSAndroid Build Coastguard Worker struct Sample
74*35238bceSAndroid Build Coastguard Worker {
75*35238bceSAndroid Build Coastguard Worker     int64_t nullTime;
76*35238bceSAndroid Build Coastguard Worker     int64_t baseTime;
77*35238bceSAndroid Build Coastguard Worker     int64_t testTime;
78*35238bceSAndroid Build Coastguard Worker     int order;
79*35238bceSAndroid Build Coastguard Worker     int workload;
80*35238bceSAndroid Build Coastguard Worker };
81*35238bceSAndroid Build Coastguard Worker 
82*35238bceSAndroid Build Coastguard Worker struct SampleParams
83*35238bceSAndroid Build Coastguard Worker {
84*35238bceSAndroid Build Coastguard Worker     int step;
85*35238bceSAndroid Build Coastguard Worker     int measurement;
86*35238bceSAndroid Build Coastguard Worker 
SampleParamsdeqp::gles3::Performance::__anon5a4bff6a0111::SampleParams87*35238bceSAndroid Build Coastguard Worker     SampleParams(int step_, int measurement_) : step(step_), measurement(measurement_)
88*35238bceSAndroid Build Coastguard Worker     {
89*35238bceSAndroid Build Coastguard Worker     }
90*35238bceSAndroid Build Coastguard Worker };
91*35238bceSAndroid Build Coastguard Worker 
92*35238bceSAndroid Build Coastguard Worker typedef vector<float> Geometry;
93*35238bceSAndroid Build Coastguard Worker 
94*35238bceSAndroid Build Coastguard Worker struct ObjectData
95*35238bceSAndroid Build Coastguard Worker {
96*35238bceSAndroid Build Coastguard Worker     ProgramSources shader;
97*35238bceSAndroid Build Coastguard Worker     Geometry geometry;
98*35238bceSAndroid Build Coastguard Worker 
ObjectDatadeqp::gles3::Performance::__anon5a4bff6a0111::ObjectData99*35238bceSAndroid Build Coastguard Worker     ObjectData(const ProgramSources &shader_, const Geometry &geometry_) : shader(shader_), geometry(geometry_)
100*35238bceSAndroid Build Coastguard Worker     {
101*35238bceSAndroid Build Coastguard Worker     }
102*35238bceSAndroid Build Coastguard Worker };
103*35238bceSAndroid Build Coastguard Worker 
104*35238bceSAndroid Build Coastguard Worker class RenderData
105*35238bceSAndroid Build Coastguard Worker {
106*35238bceSAndroid Build Coastguard Worker public:
107*35238bceSAndroid Build Coastguard Worker     RenderData(const ObjectData &object, const glu::RenderContext &renderCtx, TestLog &log);
~RenderData(void)108*35238bceSAndroid Build Coastguard Worker     ~RenderData(void)
109*35238bceSAndroid Build Coastguard Worker     {
110*35238bceSAndroid Build Coastguard Worker     }
111*35238bceSAndroid Build Coastguard Worker 
112*35238bceSAndroid Build Coastguard Worker     const glu::ShaderProgram m_program;
113*35238bceSAndroid Build Coastguard Worker     const glu::VertexArray m_vao;
114*35238bceSAndroid Build Coastguard Worker     const glu::Buffer m_vbo;
115*35238bceSAndroid Build Coastguard Worker 
116*35238bceSAndroid Build Coastguard Worker     const int m_numVertices;
117*35238bceSAndroid Build Coastguard Worker };
118*35238bceSAndroid Build Coastguard Worker 
RenderData(const ObjectData & object,const glu::RenderContext & renderCtx,TestLog & log)119*35238bceSAndroid Build Coastguard Worker RenderData::RenderData(const ObjectData &object, const glu::RenderContext &renderCtx, TestLog &log)
120*35238bceSAndroid Build Coastguard Worker     : m_program(renderCtx, object.shader)
121*35238bceSAndroid Build Coastguard Worker     , m_vao(renderCtx.getFunctions())
122*35238bceSAndroid Build Coastguard Worker     , m_vbo(renderCtx.getFunctions())
123*35238bceSAndroid Build Coastguard Worker     , m_numVertices(int(object.geometry.size()) / 4)
124*35238bceSAndroid Build Coastguard Worker {
125*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = renderCtx.getFunctions();
126*35238bceSAndroid Build Coastguard Worker 
127*35238bceSAndroid Build Coastguard Worker     if (!m_program.isOk())
128*35238bceSAndroid Build Coastguard Worker         log << m_program;
129*35238bceSAndroid Build Coastguard Worker 
130*35238bceSAndroid Build Coastguard Worker     gl.bindBuffer(GL_ARRAY_BUFFER, *m_vbo);
131*35238bceSAndroid Build Coastguard Worker     gl.bufferData(GL_ARRAY_BUFFER, object.geometry.size() * sizeof(float), &object.geometry[0], GL_STATIC_DRAW);
132*35238bceSAndroid Build Coastguard Worker     gl.bindAttribLocation(m_program.getProgram(), 0, "a_position");
133*35238bceSAndroid Build Coastguard Worker 
134*35238bceSAndroid Build Coastguard Worker     gl.bindVertexArray(*m_vao);
135*35238bceSAndroid Build Coastguard Worker     gl.vertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL);
136*35238bceSAndroid Build Coastguard Worker     gl.enableVertexAttribArray(0);
137*35238bceSAndroid Build Coastguard Worker     gl.bindVertexArray(0);
138*35238bceSAndroid Build Coastguard Worker }
139*35238bceSAndroid Build Coastguard Worker 
140*35238bceSAndroid Build Coastguard Worker namespace Utils
141*35238bceSAndroid Build Coastguard Worker {
getFullscreenQuad(float depth)142*35238bceSAndroid Build Coastguard Worker vector<float> getFullscreenQuad(float depth)
143*35238bceSAndroid Build Coastguard Worker {
144*35238bceSAndroid Build Coastguard Worker     const float data[] = {
145*35238bceSAndroid Build Coastguard Worker         +1.0f, +1.0f, depth, 0.0f, // .w is gl_VertexId%3 since Nexus 4&5 can't handle that on their own
146*35238bceSAndroid Build Coastguard Worker         +1.0f, -1.0f, depth, 1.0f,  -1.0f, -1.0f, depth, 2.0f,  -1.0f, -1.0f,
147*35238bceSAndroid Build Coastguard Worker         depth, 0.0f,  -1.0f, +1.0f, depth, 1.0f,  +1.0f, +1.0f, depth, 2.0f,
148*35238bceSAndroid Build Coastguard Worker     };
149*35238bceSAndroid Build Coastguard Worker 
150*35238bceSAndroid Build Coastguard Worker     return vector<float>(DE_ARRAY_BEGIN(data), DE_ARRAY_END(data));
151*35238bceSAndroid Build Coastguard Worker }
152*35238bceSAndroid Build Coastguard Worker 
getFullscreenQuadWithGradient(float depth0,float depth1)153*35238bceSAndroid Build Coastguard Worker vector<float> getFullscreenQuadWithGradient(float depth0, float depth1)
154*35238bceSAndroid Build Coastguard Worker {
155*35238bceSAndroid Build Coastguard Worker     const float data[] = {
156*35238bceSAndroid Build Coastguard Worker         +1.0f, +1.0f, depth0, 0.0f, +1.0f, -1.0f, depth0, 1.0f, -1.0f, -1.0f, depth1, 2.0f,
157*35238bceSAndroid Build Coastguard Worker         -1.0f, -1.0f, depth1, 0.0f, -1.0f, +1.0f, depth1, 1.0f, +1.0f, +1.0f, depth0, 2.0f,
158*35238bceSAndroid Build Coastguard Worker     };
159*35238bceSAndroid Build Coastguard Worker 
160*35238bceSAndroid Build Coastguard Worker     return vector<float>(DE_ARRAY_BEGIN(data), DE_ARRAY_END(data));
161*35238bceSAndroid Build Coastguard Worker }
162*35238bceSAndroid Build Coastguard Worker 
getPartScreenQuad(float coverage,float depth)163*35238bceSAndroid Build Coastguard Worker vector<float> getPartScreenQuad(float coverage, float depth)
164*35238bceSAndroid Build Coastguard Worker {
165*35238bceSAndroid Build Coastguard Worker     const float xMax   = -1.0f + 2.0f * coverage;
166*35238bceSAndroid Build Coastguard Worker     const float data[] = {
167*35238bceSAndroid Build Coastguard Worker         xMax,  +1.0f, depth, 0.0f, xMax,  -1.0f, depth, 1.0f, -1.0f, -1.0f, depth, 2.0f,
168*35238bceSAndroid Build Coastguard Worker         -1.0f, -1.0f, depth, 0.0f, -1.0f, +1.0f, depth, 1.0f, xMax,  +1.0f, depth, 2.0f,
169*35238bceSAndroid Build Coastguard Worker     };
170*35238bceSAndroid Build Coastguard Worker 
171*35238bceSAndroid Build Coastguard Worker     return vector<float>(DE_ARRAY_BEGIN(data), DE_ARRAY_END(data));
172*35238bceSAndroid Build Coastguard Worker }
173*35238bceSAndroid Build Coastguard Worker 
174*35238bceSAndroid Build Coastguard Worker // Axis aligned grid. Depth of vertices is baseDepth +/- depthNoise
getFullScreenGrid(int resolution,uint32_t seed,float baseDepth,float depthNoise,float xyNoise)175*35238bceSAndroid Build Coastguard Worker vector<float> getFullScreenGrid(int resolution, uint32_t seed, float baseDepth, float depthNoise, float xyNoise)
176*35238bceSAndroid Build Coastguard Worker {
177*35238bceSAndroid Build Coastguard Worker     const int gridsize = resolution + 1;
178*35238bceSAndroid Build Coastguard Worker     vector<Vec3> vertices(gridsize * gridsize);
179*35238bceSAndroid Build Coastguard Worker     vector<float> retval;
180*35238bceSAndroid Build Coastguard Worker     de::Random rng(seed);
181*35238bceSAndroid Build Coastguard Worker 
182*35238bceSAndroid Build Coastguard Worker     for (int y = 0; y < gridsize; y++)
183*35238bceSAndroid Build Coastguard Worker         for (int x = 0; x < gridsize; x++)
184*35238bceSAndroid Build Coastguard Worker         {
185*35238bceSAndroid Build Coastguard Worker             const bool isEdge = x == 0 || y == 0 || x == resolution || y == resolution;
186*35238bceSAndroid Build Coastguard Worker             const float x_ =
187*35238bceSAndroid Build Coastguard Worker                 float(x) / float(resolution) * 2.0f - 1.0f + (isEdge ? 0.0f : rng.getFloat(-xyNoise, +xyNoise));
188*35238bceSAndroid Build Coastguard Worker             const float y_ =
189*35238bceSAndroid Build Coastguard Worker                 float(y) / float(resolution) * 2.0f - 1.0f + (isEdge ? 0.0f : rng.getFloat(-xyNoise, +xyNoise));
190*35238bceSAndroid Build Coastguard Worker             const float z_ = baseDepth + rng.getFloat(-depthNoise, +depthNoise);
191*35238bceSAndroid Build Coastguard Worker 
192*35238bceSAndroid Build Coastguard Worker             vertices[y * gridsize + x] = Vec3(x_, y_, z_);
193*35238bceSAndroid Build Coastguard Worker         }
194*35238bceSAndroid Build Coastguard Worker 
195*35238bceSAndroid Build Coastguard Worker     retval.reserve(resolution * resolution * 6);
196*35238bceSAndroid Build Coastguard Worker 
197*35238bceSAndroid Build Coastguard Worker     for (int y = 0; y < resolution; y++)
198*35238bceSAndroid Build Coastguard Worker         for (int x = 0; x < resolution; x++)
199*35238bceSAndroid Build Coastguard Worker         {
200*35238bceSAndroid Build Coastguard Worker             const Vec3 &p0 = vertices[(y + 0) * gridsize + (x + 0)];
201*35238bceSAndroid Build Coastguard Worker             const Vec3 &p1 = vertices[(y + 0) * gridsize + (x + 1)];
202*35238bceSAndroid Build Coastguard Worker             const Vec3 &p2 = vertices[(y + 1) * gridsize + (x + 0)];
203*35238bceSAndroid Build Coastguard Worker             const Vec3 &p3 = vertices[(y + 1) * gridsize + (x + 1)];
204*35238bceSAndroid Build Coastguard Worker 
205*35238bceSAndroid Build Coastguard Worker             const float temp[6 * 4] = {
206*35238bceSAndroid Build Coastguard Worker                 p0.x(), p0.y(), p0.z(), 0.0f, p2.x(), p2.y(), p2.z(), 1.0f, p1.x(), p1.y(), p1.z(), 2.0f,
207*35238bceSAndroid Build Coastguard Worker 
208*35238bceSAndroid Build Coastguard Worker                 p3.x(), p3.y(), p3.z(), 0.0f, p1.x(), p1.y(), p1.z(), 1.0f, p2.x(), p2.y(), p2.z(), 2.0f,
209*35238bceSAndroid Build Coastguard Worker             };
210*35238bceSAndroid Build Coastguard Worker 
211*35238bceSAndroid Build Coastguard Worker             retval.insert(retval.end(), DE_ARRAY_BEGIN(temp), DE_ARRAY_END(temp));
212*35238bceSAndroid Build Coastguard Worker         }
213*35238bceSAndroid Build Coastguard Worker 
214*35238bceSAndroid Build Coastguard Worker     return retval;
215*35238bceSAndroid Build Coastguard Worker }
216*35238bceSAndroid Build Coastguard Worker 
217*35238bceSAndroid Build Coastguard Worker // Outputs barycentric coordinates as v_bcoords. Otherwise a passthrough shader
getBaseVertexShader(void)218*35238bceSAndroid Build Coastguard Worker string getBaseVertexShader(void)
219*35238bceSAndroid Build Coastguard Worker {
220*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
221*35238bceSAndroid Build Coastguard Worker            "in highp vec4 a_position;\n"
222*35238bceSAndroid Build Coastguard Worker            "out mediump vec3 v_bcoords;\n"
223*35238bceSAndroid Build Coastguard Worker            "void main()\n"
224*35238bceSAndroid Build Coastguard Worker            "{\n"
225*35238bceSAndroid Build Coastguard Worker            "    v_bcoords = vec3(0, 0, 0);\n"
226*35238bceSAndroid Build Coastguard Worker            "    v_bcoords[int(a_position.w)] = 1.0;\n"
227*35238bceSAndroid Build Coastguard Worker            "    gl_Position = vec4(a_position.xyz, 1.0);\n"
228*35238bceSAndroid Build Coastguard Worker            "}\n";
229*35238bceSAndroid Build Coastguard Worker }
230*35238bceSAndroid Build Coastguard Worker 
231*35238bceSAndroid Build Coastguard Worker // Adds noise to coordinates based on InstanceID Outputs barycentric coordinates as v_bcoords
getInstanceNoiseVertexShader(void)232*35238bceSAndroid Build Coastguard Worker string getInstanceNoiseVertexShader(void)
233*35238bceSAndroid Build Coastguard Worker {
234*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
235*35238bceSAndroid Build Coastguard Worker            "in highp vec4 a_position;\n"
236*35238bceSAndroid Build Coastguard Worker            "out mediump vec3 v_bcoords;\n"
237*35238bceSAndroid Build Coastguard Worker            "void main()\n"
238*35238bceSAndroid Build Coastguard Worker            "{\n"
239*35238bceSAndroid Build Coastguard Worker            "    v_bcoords = vec3(0, 0, 0);\n"
240*35238bceSAndroid Build Coastguard Worker            "    v_bcoords[int(a_position.w)] = 1.0;\n"
241*35238bceSAndroid Build Coastguard Worker            "    vec3 noise = vec3(sin(float(gl_InstanceID)*1.05), sin(float(gl_InstanceID)*1.23), "
242*35238bceSAndroid Build Coastguard Worker            "sin(float(gl_InstanceID)*1.71));\n"
243*35238bceSAndroid Build Coastguard Worker            "    gl_Position = vec4(a_position.xyz + noise * 0.005, 1.0);\n"
244*35238bceSAndroid Build Coastguard Worker            "}\n";
245*35238bceSAndroid Build Coastguard Worker }
246*35238bceSAndroid Build Coastguard Worker 
247*35238bceSAndroid Build Coastguard Worker // Renders green triangles with edges highlighted. Exact shade depends on depth.
getDepthAsGreenFragmentShader(void)248*35238bceSAndroid Build Coastguard Worker string getDepthAsGreenFragmentShader(void)
249*35238bceSAndroid Build Coastguard Worker {
250*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
251*35238bceSAndroid Build Coastguard Worker            "in mediump vec3 v_bcoords;\n"
252*35238bceSAndroid Build Coastguard Worker            "out mediump vec4 fragColor;\n"
253*35238bceSAndroid Build Coastguard Worker            "void main()\n"
254*35238bceSAndroid Build Coastguard Worker            "{\n"
255*35238bceSAndroid Build Coastguard Worker            "    mediump float d = gl_FragCoord.z;\n"
256*35238bceSAndroid Build Coastguard Worker            "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
257*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(d,1,d,1);\n"
258*35238bceSAndroid Build Coastguard Worker            "    else\n"
259*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(0,d,0,1);\n"
260*35238bceSAndroid Build Coastguard Worker            "}\n";
261*35238bceSAndroid Build Coastguard Worker }
262*35238bceSAndroid Build Coastguard Worker 
263*35238bceSAndroid Build Coastguard Worker // Renders green triangles with edges highlighted. Exact shade depends on depth.
getDepthAsRedFragmentShader(void)264*35238bceSAndroid Build Coastguard Worker string getDepthAsRedFragmentShader(void)
265*35238bceSAndroid Build Coastguard Worker {
266*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
267*35238bceSAndroid Build Coastguard Worker            "in mediump vec3 v_bcoords;\n"
268*35238bceSAndroid Build Coastguard Worker            "out mediump vec4 fragColor;\n"
269*35238bceSAndroid Build Coastguard Worker            "void main()\n"
270*35238bceSAndroid Build Coastguard Worker            "{\n"
271*35238bceSAndroid Build Coastguard Worker            "    mediump float d = gl_FragCoord.z;\n"
272*35238bceSAndroid Build Coastguard Worker            "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
273*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(1,d,d,1);\n"
274*35238bceSAndroid Build Coastguard Worker            "    else\n"
275*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(d,0,0,1);\n"
276*35238bceSAndroid Build Coastguard Worker            "}\n";
277*35238bceSAndroid Build Coastguard Worker }
278*35238bceSAndroid Build Coastguard Worker 
279*35238bceSAndroid Build Coastguard Worker // Basic time waster. Renders red triangles with edges highlighted. Exact shade depends on depth.
getArithmeticWorkloadFragmentShader(void)280*35238bceSAndroid Build Coastguard Worker string getArithmeticWorkloadFragmentShader(void)
281*35238bceSAndroid Build Coastguard Worker {
282*35238bceSAndroid Build Coastguard Worker 
283*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
284*35238bceSAndroid Build Coastguard Worker            "in mediump vec3 v_bcoords;\n"
285*35238bceSAndroid Build Coastguard Worker            "out mediump vec4 fragColor;\n"
286*35238bceSAndroid Build Coastguard Worker            "uniform mediump int u_iterations;\n"
287*35238bceSAndroid Build Coastguard Worker            "void main()\n"
288*35238bceSAndroid Build Coastguard Worker            "{\n"
289*35238bceSAndroid Build Coastguard Worker            "    mediump float d = gl_FragCoord.z;\n"
290*35238bceSAndroid Build Coastguard Worker            "    for (int i = 0; i<u_iterations; i++)\n"
291*35238bceSAndroid Build Coastguard Worker            // cos(a)^2 + sin(a)^2 == 1. since d is in range [0,1] this will lose a few ULP's of precision per iteration but should not significantly change the value of d without extreme iteration counts
292*35238bceSAndroid Build Coastguard Worker            "        d = d*sin(d)*sin(d) + d*cos(d)*cos(d);\n"
293*35238bceSAndroid Build Coastguard Worker            "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
294*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(1,d,d,1);\n"
295*35238bceSAndroid Build Coastguard Worker            "    else\n"
296*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(d,0,0,1);\n"
297*35238bceSAndroid Build Coastguard Worker            "}\n";
298*35238bceSAndroid Build Coastguard Worker }
299*35238bceSAndroid Build Coastguard Worker 
300*35238bceSAndroid Build Coastguard Worker // Arithmetic workload shader but contains discard
getArithmeticWorkloadDiscardFragmentShader(void)301*35238bceSAndroid Build Coastguard Worker string getArithmeticWorkloadDiscardFragmentShader(void)
302*35238bceSAndroid Build Coastguard Worker {
303*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
304*35238bceSAndroid Build Coastguard Worker            "in mediump vec3 v_bcoords;\n"
305*35238bceSAndroid Build Coastguard Worker            "out mediump vec4 fragColor;\n"
306*35238bceSAndroid Build Coastguard Worker            "uniform mediump int u_iterations;\n"
307*35238bceSAndroid Build Coastguard Worker            "void main()\n"
308*35238bceSAndroid Build Coastguard Worker            "{\n"
309*35238bceSAndroid Build Coastguard Worker            "    mediump float d = gl_FragCoord.z;\n"
310*35238bceSAndroid Build Coastguard Worker            "    for (int i = 0; i<u_iterations; i++)\n"
311*35238bceSAndroid Build Coastguard Worker            "        d = d*sin(d)*sin(d) + d*cos(d)*cos(d);\n"
312*35238bceSAndroid Build Coastguard Worker            "    if (d < 0.5) discard;\n"
313*35238bceSAndroid Build Coastguard Worker            "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
314*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(1,d,d,1);\n"
315*35238bceSAndroid Build Coastguard Worker            "    else\n"
316*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(d,0,0,1);\n"
317*35238bceSAndroid Build Coastguard Worker            "}\n";
318*35238bceSAndroid Build Coastguard Worker }
319*35238bceSAndroid Build Coastguard Worker 
320*35238bceSAndroid Build Coastguard Worker // Texture fetch based time waster. Renders red triangles with edges highlighted. Exact shade depends on depth.
getTextureWorkloadFragmentShader(void)321*35238bceSAndroid Build Coastguard Worker string getTextureWorkloadFragmentShader(void)
322*35238bceSAndroid Build Coastguard Worker {
323*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
324*35238bceSAndroid Build Coastguard Worker            "in mediump vec3 v_bcoords;\n"
325*35238bceSAndroid Build Coastguard Worker            "out mediump vec4 fragColor;\n"
326*35238bceSAndroid Build Coastguard Worker            "uniform mediump int u_iterations;\n"
327*35238bceSAndroid Build Coastguard Worker            "uniform sampler2D u_texture;\n"
328*35238bceSAndroid Build Coastguard Worker            "void main()\n"
329*35238bceSAndroid Build Coastguard Worker            "{\n"
330*35238bceSAndroid Build Coastguard Worker            "    mediump float d = gl_FragCoord.z;\n"
331*35238bceSAndroid Build Coastguard Worker            "    for (int i = 0; i<u_iterations; i++)\n"
332*35238bceSAndroid Build Coastguard Worker            "        d *= texture(u_texture, (gl_FragCoord.xy+vec2(i))/512.0).r;\n" // Texture is expected to be fully white
333*35238bceSAndroid Build Coastguard Worker            "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
334*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(1,1,1,1);\n"
335*35238bceSAndroid Build Coastguard Worker            "    else\n"
336*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(d,0,0,1);\n"
337*35238bceSAndroid Build Coastguard Worker            "}\n";
338*35238bceSAndroid Build Coastguard Worker }
339*35238bceSAndroid Build Coastguard Worker 
340*35238bceSAndroid Build Coastguard Worker // Discard fragments in a grid pattern
getGridDiscardFragmentShader(int gridsize)341*35238bceSAndroid Build Coastguard Worker string getGridDiscardFragmentShader(int gridsize)
342*35238bceSAndroid Build Coastguard Worker {
343*35238bceSAndroid Build Coastguard Worker     const string fragSrc =
344*35238bceSAndroid Build Coastguard Worker         "#version 300 es\n"
345*35238bceSAndroid Build Coastguard Worker         "in mediump vec3 v_bcoords;\n"
346*35238bceSAndroid Build Coastguard Worker         "out mediump vec4 fragColor;\n"
347*35238bceSAndroid Build Coastguard Worker         "void main()\n"
348*35238bceSAndroid Build Coastguard Worker         "{\n"
349*35238bceSAndroid Build Coastguard Worker         "    mediump float d = gl_FragCoord.z;\n"
350*35238bceSAndroid Build Coastguard Worker         "    if ((int(gl_FragCoord.x)/${GRIDRENDER_SIZE} + int(gl_FragCoord.y)/${GRIDRENDER_SIZE})%2 == 0)\n"
351*35238bceSAndroid Build Coastguard Worker         "        discard;\n"
352*35238bceSAndroid Build Coastguard Worker         "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
353*35238bceSAndroid Build Coastguard Worker         "        fragColor = vec4(d,1,d,1);\n"
354*35238bceSAndroid Build Coastguard Worker         "    else\n"
355*35238bceSAndroid Build Coastguard Worker         "        fragColor = vec4(0,d,0,1);\n"
356*35238bceSAndroid Build Coastguard Worker         "}\n";
357*35238bceSAndroid Build Coastguard Worker     map<string, string> params;
358*35238bceSAndroid Build Coastguard Worker 
359*35238bceSAndroid Build Coastguard Worker     params["GRIDRENDER_SIZE"] = de::toString(gridsize);
360*35238bceSAndroid Build Coastguard Worker 
361*35238bceSAndroid Build Coastguard Worker     return tcu::StringTemplate(fragSrc).specialize(params);
362*35238bceSAndroid Build Coastguard Worker }
363*35238bceSAndroid Build Coastguard Worker 
364*35238bceSAndroid Build Coastguard Worker // A static increment to frag depth
getStaticFragDepthFragmentShader(void)365*35238bceSAndroid Build Coastguard Worker string getStaticFragDepthFragmentShader(void)
366*35238bceSAndroid Build Coastguard Worker {
367*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
368*35238bceSAndroid Build Coastguard Worker            "in mediump vec3 v_bcoords;\n"
369*35238bceSAndroid Build Coastguard Worker            "out mediump vec4 fragColor;\n"
370*35238bceSAndroid Build Coastguard Worker            "void main()\n"
371*35238bceSAndroid Build Coastguard Worker            "{\n"
372*35238bceSAndroid Build Coastguard Worker            "    mediump float d = gl_FragCoord.z;\n"
373*35238bceSAndroid Build Coastguard Worker            "    gl_FragDepth = gl_FragCoord.z + 0.1;\n"
374*35238bceSAndroid Build Coastguard Worker            "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
375*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(d,1,d,1);\n"
376*35238bceSAndroid Build Coastguard Worker            "    else\n"
377*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(0,d,0,1);\n"
378*35238bceSAndroid Build Coastguard Worker            "}\n";
379*35238bceSAndroid Build Coastguard Worker }
380*35238bceSAndroid Build Coastguard Worker 
381*35238bceSAndroid Build Coastguard Worker // A trivial dynamic change to frag depth
getDynamicFragDepthFragmentShader(void)382*35238bceSAndroid Build Coastguard Worker string getDynamicFragDepthFragmentShader(void)
383*35238bceSAndroid Build Coastguard Worker {
384*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
385*35238bceSAndroid Build Coastguard Worker            "in mediump vec3 v_bcoords;\n"
386*35238bceSAndroid Build Coastguard Worker            "out mediump vec4 fragColor;\n"
387*35238bceSAndroid Build Coastguard Worker            "void main()\n"
388*35238bceSAndroid Build Coastguard Worker            "{\n"
389*35238bceSAndroid Build Coastguard Worker            "    mediump float d = gl_FragCoord.z;\n"
390*35238bceSAndroid Build Coastguard Worker            "    gl_FragDepth = gl_FragCoord.z + (v_bcoords.x + v_bcoords.y + v_bcoords.z)*0.05;\n" // Sum of v_bcoords components is allways 1
391*35238bceSAndroid Build Coastguard Worker            "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
392*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(d,1,d,1);\n"
393*35238bceSAndroid Build Coastguard Worker            "    else\n"
394*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(0,d,0,1);\n"
395*35238bceSAndroid Build Coastguard Worker            "}\n";
396*35238bceSAndroid Build Coastguard Worker }
397*35238bceSAndroid Build Coastguard Worker 
398*35238bceSAndroid Build Coastguard Worker // A static increment to frag depth
getStaticFragDepthArithmeticWorkloadFragmentShader(void)399*35238bceSAndroid Build Coastguard Worker string getStaticFragDepthArithmeticWorkloadFragmentShader(void)
400*35238bceSAndroid Build Coastguard Worker {
401*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
402*35238bceSAndroid Build Coastguard Worker            "in mediump vec3 v_bcoords;\n"
403*35238bceSAndroid Build Coastguard Worker            "out mediump vec4 fragColor;\n"
404*35238bceSAndroid Build Coastguard Worker            "uniform mediump int u_iterations;\n"
405*35238bceSAndroid Build Coastguard Worker            "void main()\n"
406*35238bceSAndroid Build Coastguard Worker            "{\n"
407*35238bceSAndroid Build Coastguard Worker            "    mediump float d = gl_FragCoord.z;\n"
408*35238bceSAndroid Build Coastguard Worker            "    gl_FragDepth = gl_FragCoord.z + 0.1;\n"
409*35238bceSAndroid Build Coastguard Worker            "    for (int i = 0; i<u_iterations; i++)\n"
410*35238bceSAndroid Build Coastguard Worker            "        d = d*sin(d)*sin(d) + d*cos(d)*cos(d);\n"
411*35238bceSAndroid Build Coastguard Worker            "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
412*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(1,d,d,1);\n"
413*35238bceSAndroid Build Coastguard Worker            "    else\n"
414*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(d,0,0,1);\n"
415*35238bceSAndroid Build Coastguard Worker            "}\n";
416*35238bceSAndroid Build Coastguard Worker }
417*35238bceSAndroid Build Coastguard Worker 
418*35238bceSAndroid Build Coastguard Worker // A trivial dynamic change to frag depth
getDynamicFragDepthArithmeticWorkloadFragmentShader(void)419*35238bceSAndroid Build Coastguard Worker string getDynamicFragDepthArithmeticWorkloadFragmentShader(void)
420*35238bceSAndroid Build Coastguard Worker {
421*35238bceSAndroid Build Coastguard Worker     return "#version 300 es\n"
422*35238bceSAndroid Build Coastguard Worker            "in mediump vec3 v_bcoords;\n"
423*35238bceSAndroid Build Coastguard Worker            "out mediump vec4 fragColor;\n"
424*35238bceSAndroid Build Coastguard Worker            "uniform mediump int u_iterations;\n"
425*35238bceSAndroid Build Coastguard Worker            "void main()\n"
426*35238bceSAndroid Build Coastguard Worker            "{\n"
427*35238bceSAndroid Build Coastguard Worker            "    mediump float d = gl_FragCoord.z;\n"
428*35238bceSAndroid Build Coastguard Worker            "    gl_FragDepth = gl_FragCoord.z + (v_bcoords.x + v_bcoords.y + v_bcoords.z)*0.05;\n" // Sum of v_bcoords components is allways 1
429*35238bceSAndroid Build Coastguard Worker            "    for (int i = 0; i<u_iterations; i++)\n"
430*35238bceSAndroid Build Coastguard Worker            "        d = d*sin(d)*sin(d) + d*cos(d)*cos(d);\n"
431*35238bceSAndroid Build Coastguard Worker            "    if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n"
432*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(1,d,d,1);\n"
433*35238bceSAndroid Build Coastguard Worker            "    else\n"
434*35238bceSAndroid Build Coastguard Worker            "        fragColor = vec4(d,0,0,1);\n"
435*35238bceSAndroid Build Coastguard Worker            "}\n";
436*35238bceSAndroid Build Coastguard Worker }
437*35238bceSAndroid Build Coastguard Worker 
getBaseShader(void)438*35238bceSAndroid Build Coastguard Worker glu::ProgramSources getBaseShader(void)
439*35238bceSAndroid Build Coastguard Worker {
440*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(getBaseVertexShader(), getDepthAsGreenFragmentShader());
441*35238bceSAndroid Build Coastguard Worker }
442*35238bceSAndroid Build Coastguard Worker 
getArithmeticWorkloadShader(void)443*35238bceSAndroid Build Coastguard Worker glu::ProgramSources getArithmeticWorkloadShader(void)
444*35238bceSAndroid Build Coastguard Worker {
445*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(getBaseVertexShader(), getArithmeticWorkloadFragmentShader());
446*35238bceSAndroid Build Coastguard Worker }
447*35238bceSAndroid Build Coastguard Worker 
getArithmeticWorkloadDiscardShader(void)448*35238bceSAndroid Build Coastguard Worker glu::ProgramSources getArithmeticWorkloadDiscardShader(void)
449*35238bceSAndroid Build Coastguard Worker {
450*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(getBaseVertexShader(), getArithmeticWorkloadDiscardFragmentShader());
451*35238bceSAndroid Build Coastguard Worker }
452*35238bceSAndroid Build Coastguard Worker 
getTextureWorkloadShader(void)453*35238bceSAndroid Build Coastguard Worker glu::ProgramSources getTextureWorkloadShader(void)
454*35238bceSAndroid Build Coastguard Worker {
455*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(getBaseVertexShader(), getTextureWorkloadFragmentShader());
456*35238bceSAndroid Build Coastguard Worker }
457*35238bceSAndroid Build Coastguard Worker 
getGridDiscardShader(int gridsize)458*35238bceSAndroid Build Coastguard Worker glu::ProgramSources getGridDiscardShader(int gridsize)
459*35238bceSAndroid Build Coastguard Worker {
460*35238bceSAndroid Build Coastguard Worker     return glu::makeVtxFragSources(getBaseVertexShader(), getGridDiscardFragmentShader(gridsize));
461*35238bceSAndroid Build Coastguard Worker }
462*35238bceSAndroid Build Coastguard Worker 
quadWith(const glu::ProgramSources & shader,float depth)463*35238bceSAndroid Build Coastguard Worker inline ObjectData quadWith(const glu::ProgramSources &shader, float depth)
464*35238bceSAndroid Build Coastguard Worker {
465*35238bceSAndroid Build Coastguard Worker     return ObjectData(shader, getFullscreenQuad(depth));
466*35238bceSAndroid Build Coastguard Worker }
467*35238bceSAndroid Build Coastguard Worker 
quadWith(const string & fragShader,float depth)468*35238bceSAndroid Build Coastguard Worker inline ObjectData quadWith(const string &fragShader, float depth)
469*35238bceSAndroid Build Coastguard Worker {
470*35238bceSAndroid Build Coastguard Worker     return ObjectData(glu::makeVtxFragSources(getBaseVertexShader(), fragShader), getFullscreenQuad(depth));
471*35238bceSAndroid Build Coastguard Worker }
472*35238bceSAndroid Build Coastguard Worker 
variableQuad(float depth)473*35238bceSAndroid Build Coastguard Worker inline ObjectData variableQuad(float depth)
474*35238bceSAndroid Build Coastguard Worker {
475*35238bceSAndroid Build Coastguard Worker     return ObjectData(glu::makeVtxFragSources(getInstanceNoiseVertexShader(), getDepthAsRedFragmentShader()),
476*35238bceSAndroid Build Coastguard Worker                       getFullscreenQuad(depth));
477*35238bceSAndroid Build Coastguard Worker }
478*35238bceSAndroid Build Coastguard Worker 
fastQuad(float depth)479*35238bceSAndroid Build Coastguard Worker inline ObjectData fastQuad(float depth)
480*35238bceSAndroid Build Coastguard Worker {
481*35238bceSAndroid Build Coastguard Worker     return ObjectData(getBaseShader(), getFullscreenQuad(depth));
482*35238bceSAndroid Build Coastguard Worker }
483*35238bceSAndroid Build Coastguard Worker 
slowQuad(float depth)484*35238bceSAndroid Build Coastguard Worker inline ObjectData slowQuad(float depth)
485*35238bceSAndroid Build Coastguard Worker {
486*35238bceSAndroid Build Coastguard Worker     return ObjectData(getArithmeticWorkloadShader(), getFullscreenQuad(depth));
487*35238bceSAndroid Build Coastguard Worker }
488*35238bceSAndroid Build Coastguard Worker 
fastQuadWithGradient(float depth0,float depth1)489*35238bceSAndroid Build Coastguard Worker inline ObjectData fastQuadWithGradient(float depth0, float depth1)
490*35238bceSAndroid Build Coastguard Worker {
491*35238bceSAndroid Build Coastguard Worker     return ObjectData(getBaseShader(), getFullscreenQuadWithGradient(depth0, depth1));
492*35238bceSAndroid Build Coastguard Worker }
493*35238bceSAndroid Build Coastguard Worker } // namespace Utils
494*35238bceSAndroid Build Coastguard Worker 
495*35238bceSAndroid Build Coastguard Worker // Shared base
496*35238bceSAndroid Build Coastguard Worker class BaseCase : public tcu::TestCase
497*35238bceSAndroid Build Coastguard Worker {
498*35238bceSAndroid Build Coastguard Worker public:
499*35238bceSAndroid Build Coastguard Worker     enum
500*35238bceSAndroid Build Coastguard Worker     {
501*35238bceSAndroid Build Coastguard Worker         RENDER_SIZE = 512
502*35238bceSAndroid Build Coastguard Worker     };
503*35238bceSAndroid Build Coastguard Worker 
504*35238bceSAndroid Build Coastguard Worker     BaseCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name, const char *desc);
~BaseCase(void)505*35238bceSAndroid Build Coastguard Worker     virtual ~BaseCase(void)
506*35238bceSAndroid Build Coastguard Worker     {
507*35238bceSAndroid Build Coastguard Worker     }
508*35238bceSAndroid Build Coastguard Worker 
509*35238bceSAndroid Build Coastguard Worker     virtual IterateResult iterate(void);
510*35238bceSAndroid Build Coastguard Worker 
511*35238bceSAndroid Build Coastguard Worker protected:
512*35238bceSAndroid Build Coastguard Worker     void logSamples(const vector<Sample> &samples, const string &name, const string &desc);
513*35238bceSAndroid Build Coastguard Worker     void logGeometry(const tcu::ConstPixelBufferAccess &sample, const glu::ShaderProgram &occluderProg,
514*35238bceSAndroid Build Coastguard Worker                      const glu::ShaderProgram &occludedProg);
515*35238bceSAndroid Build Coastguard Worker     virtual void logAnalysis(const vector<Sample> &samples) = 0;
516*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)                       = 0;
517*35238bceSAndroid Build Coastguard Worker 
518*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const = 0;
519*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const = 0;
520*35238bceSAndroid Build Coastguard Worker 
521*35238bceSAndroid Build Coastguard Worker     virtual int calibrate(void) const                                                                       = 0;
522*35238bceSAndroid Build Coastguard Worker     virtual Sample renderSample(const RenderData &occluder, const RenderData &occluded, int workload) const = 0;
523*35238bceSAndroid Build Coastguard Worker 
524*35238bceSAndroid Build Coastguard Worker     void render(const RenderData &data) const;
525*35238bceSAndroid Build Coastguard Worker     void render(const RenderData &data, int instances) const;
526*35238bceSAndroid Build Coastguard Worker 
527*35238bceSAndroid Build Coastguard Worker     const RenderContext &m_renderCtx;
528*35238bceSAndroid Build Coastguard Worker     tcu::ResultCollector m_results;
529*35238bceSAndroid Build Coastguard Worker 
530*35238bceSAndroid Build Coastguard Worker     enum
531*35238bceSAndroid Build Coastguard Worker     {
532*35238bceSAndroid Build Coastguard Worker         ITERATION_STEPS   = 10,
533*35238bceSAndroid Build Coastguard Worker         ITERATION_SAMPLES = 16
534*35238bceSAndroid Build Coastguard Worker     };
535*35238bceSAndroid Build Coastguard Worker };
536*35238bceSAndroid Build Coastguard Worker 
BaseCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)537*35238bceSAndroid Build Coastguard Worker BaseCase::BaseCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name, const char *desc)
538*35238bceSAndroid Build Coastguard Worker     : TestCase(testCtx, tcu::NODETYPE_PERFORMANCE, name, desc)
539*35238bceSAndroid Build Coastguard Worker     , m_renderCtx(renderCtx)
540*35238bceSAndroid Build Coastguard Worker {
541*35238bceSAndroid Build Coastguard Worker }
542*35238bceSAndroid Build Coastguard Worker 
iterate(void)543*35238bceSAndroid Build Coastguard Worker BaseCase::IterateResult BaseCase::iterate(void)
544*35238bceSAndroid Build Coastguard Worker {
545*35238bceSAndroid Build Coastguard Worker     typedef de::MovePtr<RenderData> RenderDataP;
546*35238bceSAndroid Build Coastguard Worker 
547*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
548*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
549*35238bceSAndroid Build Coastguard Worker 
550*35238bceSAndroid Build Coastguard Worker     const glu::Framebuffer framebuffer(gl);
551*35238bceSAndroid Build Coastguard Worker     const glu::Renderbuffer renderbuffer(gl);
552*35238bceSAndroid Build Coastguard Worker     const glu::Renderbuffer depthbuffer(gl);
553*35238bceSAndroid Build Coastguard Worker 
554*35238bceSAndroid Build Coastguard Worker     vector<Sample> results;
555*35238bceSAndroid Build Coastguard Worker     vector<int> params;
556*35238bceSAndroid Build Coastguard Worker     RenderDataP occluderData;
557*35238bceSAndroid Build Coastguard Worker     RenderDataP occludedData;
558*35238bceSAndroid Build Coastguard Worker     tcu::TextureLevel resultTex(tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8),
559*35238bceSAndroid Build Coastguard Worker                                 RENDER_SIZE, RENDER_SIZE);
560*35238bceSAndroid Build Coastguard Worker     int maxWorkload = 0;
561*35238bceSAndroid Build Coastguard Worker     de::Random rng(deInt32Hash(deStringHash(getName())) ^ m_testCtx.getCommandLine().getBaseSeed());
562*35238bceSAndroid Build Coastguard Worker 
563*35238bceSAndroid Build Coastguard Worker     logDescription();
564*35238bceSAndroid Build Coastguard Worker 
565*35238bceSAndroid Build Coastguard Worker     gl.bindRenderbuffer(GL_RENDERBUFFER, *renderbuffer);
566*35238bceSAndroid Build Coastguard Worker     gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, RENDER_SIZE, RENDER_SIZE);
567*35238bceSAndroid Build Coastguard Worker     gl.bindRenderbuffer(GL_RENDERBUFFER, *depthbuffer);
568*35238bceSAndroid Build Coastguard Worker     gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, RENDER_SIZE, RENDER_SIZE);
569*35238bceSAndroid Build Coastguard Worker 
570*35238bceSAndroid Build Coastguard Worker     gl.bindFramebuffer(GL_FRAMEBUFFER, *framebuffer);
571*35238bceSAndroid Build Coastguard Worker     gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *renderbuffer);
572*35238bceSAndroid Build Coastguard Worker     gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, *depthbuffer);
573*35238bceSAndroid Build Coastguard Worker     gl.viewport(0, 0, RENDER_SIZE, RENDER_SIZE);
574*35238bceSAndroid Build Coastguard Worker     gl.clearColor(0.125f, 0.25f, 0.5f, 1.0f);
575*35238bceSAndroid Build Coastguard Worker 
576*35238bceSAndroid Build Coastguard Worker     maxWorkload = calibrate();
577*35238bceSAndroid Build Coastguard Worker 
578*35238bceSAndroid Build Coastguard Worker     // Setup data
579*35238bceSAndroid Build Coastguard Worker     occluderData = RenderDataP(new RenderData(genOccluderGeometry(), m_renderCtx, log));
580*35238bceSAndroid Build Coastguard Worker     occludedData = RenderDataP(new RenderData(genOccludedGeometry(), m_renderCtx, log));
581*35238bceSAndroid Build Coastguard Worker 
582*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(occluderData->m_program.isOk());
583*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(occludedData->m_program.isOk());
584*35238bceSAndroid Build Coastguard Worker 
585*35238bceSAndroid Build Coastguard Worker     // Force initialization of GPU resources
586*35238bceSAndroid Build Coastguard Worker     gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
587*35238bceSAndroid Build Coastguard Worker     gl.enable(GL_DEPTH_TEST);
588*35238bceSAndroid Build Coastguard Worker 
589*35238bceSAndroid Build Coastguard Worker     render(*occluderData);
590*35238bceSAndroid Build Coastguard Worker     render(*occludedData);
591*35238bceSAndroid Build Coastguard Worker     glu::readPixels(m_renderCtx, 0, 0, resultTex.getAccess());
592*35238bceSAndroid Build Coastguard Worker 
593*35238bceSAndroid Build Coastguard Worker     logGeometry(resultTex.getAccess(), occluderData->m_program, occludedData->m_program);
594*35238bceSAndroid Build Coastguard Worker 
595*35238bceSAndroid Build Coastguard Worker     params.reserve(ITERATION_STEPS * ITERATION_SAMPLES);
596*35238bceSAndroid Build Coastguard Worker 
597*35238bceSAndroid Build Coastguard Worker     // Setup parameters
598*35238bceSAndroid Build Coastguard Worker     for (int step = 0; step < ITERATION_STEPS; step++)
599*35238bceSAndroid Build Coastguard Worker     {
600*35238bceSAndroid Build Coastguard Worker         const int workload = maxWorkload * step / ITERATION_STEPS;
601*35238bceSAndroid Build Coastguard Worker 
602*35238bceSAndroid Build Coastguard Worker         for (int count = 0; count < ITERATION_SAMPLES; count++)
603*35238bceSAndroid Build Coastguard Worker             params.push_back(workload);
604*35238bceSAndroid Build Coastguard Worker     }
605*35238bceSAndroid Build Coastguard Worker 
606*35238bceSAndroid Build Coastguard Worker     rng.shuffle(params.begin(), params.end());
607*35238bceSAndroid Build Coastguard Worker 
608*35238bceSAndroid Build Coastguard Worker     // Render samples
609*35238bceSAndroid Build Coastguard Worker     for (size_t ndx = 0; ndx < params.size(); ndx++)
610*35238bceSAndroid Build Coastguard Worker     {
611*35238bceSAndroid Build Coastguard Worker         const int workload = params[ndx];
612*35238bceSAndroid Build Coastguard Worker         Sample sample      = renderSample(*occluderData, *occludedData, workload);
613*35238bceSAndroid Build Coastguard Worker 
614*35238bceSAndroid Build Coastguard Worker         sample.workload = workload;
615*35238bceSAndroid Build Coastguard Worker         sample.order    = int(ndx);
616*35238bceSAndroid Build Coastguard Worker 
617*35238bceSAndroid Build Coastguard Worker         results.push_back(sample);
618*35238bceSAndroid Build Coastguard Worker     }
619*35238bceSAndroid Build Coastguard Worker 
620*35238bceSAndroid Build Coastguard Worker     logSamples(results, "Samples", "Samples");
621*35238bceSAndroid Build Coastguard Worker     logAnalysis(results);
622*35238bceSAndroid Build Coastguard Worker 
623*35238bceSAndroid Build Coastguard Worker     m_results.setTestContextResult(m_testCtx);
624*35238bceSAndroid Build Coastguard Worker 
625*35238bceSAndroid Build Coastguard Worker     return STOP;
626*35238bceSAndroid Build Coastguard Worker }
627*35238bceSAndroid Build Coastguard Worker 
logSamples(const vector<Sample> & samples,const string & name,const string & desc)628*35238bceSAndroid Build Coastguard Worker void BaseCase::logSamples(const vector<Sample> &samples, const string &name, const string &desc)
629*35238bceSAndroid Build Coastguard Worker {
630*35238bceSAndroid Build Coastguard Worker     TestLog &log = m_testCtx.getLog();
631*35238bceSAndroid Build Coastguard Worker 
632*35238bceSAndroid Build Coastguard Worker     bool testOnly = true;
633*35238bceSAndroid Build Coastguard Worker 
634*35238bceSAndroid Build Coastguard Worker     for (size_t ndx = 0; ndx < samples.size(); ndx++)
635*35238bceSAndroid Build Coastguard Worker     {
636*35238bceSAndroid Build Coastguard Worker         if (samples[ndx].baseTime != 0 || samples[ndx].nullTime != 0)
637*35238bceSAndroid Build Coastguard Worker         {
638*35238bceSAndroid Build Coastguard Worker             testOnly = false;
639*35238bceSAndroid Build Coastguard Worker             break;
640*35238bceSAndroid Build Coastguard Worker         }
641*35238bceSAndroid Build Coastguard Worker     }
642*35238bceSAndroid Build Coastguard Worker 
643*35238bceSAndroid Build Coastguard Worker     log << TestLog::SampleList(name, desc);
644*35238bceSAndroid Build Coastguard Worker 
645*35238bceSAndroid Build Coastguard Worker     if (testOnly)
646*35238bceSAndroid Build Coastguard Worker     {
647*35238bceSAndroid Build Coastguard Worker         log << TestLog::SampleInfo << TestLog::ValueInfo("Workload", "Workload", "", QP_SAMPLE_VALUE_TAG_PREDICTOR)
648*35238bceSAndroid Build Coastguard Worker             << TestLog::ValueInfo("Order", "Order of sample", "", QP_SAMPLE_VALUE_TAG_PREDICTOR)
649*35238bceSAndroid Build Coastguard Worker             << TestLog::ValueInfo("TestTime", "Test render time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE)
650*35238bceSAndroid Build Coastguard Worker             << TestLog::EndSampleInfo;
651*35238bceSAndroid Build Coastguard Worker 
652*35238bceSAndroid Build Coastguard Worker         for (size_t sampleNdx = 0; sampleNdx < samples.size(); sampleNdx++)
653*35238bceSAndroid Build Coastguard Worker         {
654*35238bceSAndroid Build Coastguard Worker             const Sample &sample = samples[sampleNdx];
655*35238bceSAndroid Build Coastguard Worker 
656*35238bceSAndroid Build Coastguard Worker             log << TestLog::Sample << sample.workload << sample.order << sample.testTime << TestLog::EndSample;
657*35238bceSAndroid Build Coastguard Worker         }
658*35238bceSAndroid Build Coastguard Worker     }
659*35238bceSAndroid Build Coastguard Worker     else
660*35238bceSAndroid Build Coastguard Worker     {
661*35238bceSAndroid Build Coastguard Worker         log << TestLog::SampleInfo << TestLog::ValueInfo("Workload", "Workload", "", QP_SAMPLE_VALUE_TAG_PREDICTOR)
662*35238bceSAndroid Build Coastguard Worker             << TestLog::ValueInfo("Order", "Order of sample", "", QP_SAMPLE_VALUE_TAG_PREDICTOR)
663*35238bceSAndroid Build Coastguard Worker             << TestLog::ValueInfo("TestTime", "Test render time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE)
664*35238bceSAndroid Build Coastguard Worker             << TestLog::ValueInfo("NullTime", "Read pixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE)
665*35238bceSAndroid Build Coastguard Worker             << TestLog::ValueInfo("BaseTime", "Base render time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE)
666*35238bceSAndroid Build Coastguard Worker             << TestLog::EndSampleInfo;
667*35238bceSAndroid Build Coastguard Worker 
668*35238bceSAndroid Build Coastguard Worker         for (size_t sampleNdx = 0; sampleNdx < samples.size(); sampleNdx++)
669*35238bceSAndroid Build Coastguard Worker         {
670*35238bceSAndroid Build Coastguard Worker             const Sample &sample = samples[sampleNdx];
671*35238bceSAndroid Build Coastguard Worker 
672*35238bceSAndroid Build Coastguard Worker             log << TestLog::Sample << sample.workload << sample.order << sample.testTime << sample.nullTime
673*35238bceSAndroid Build Coastguard Worker                 << sample.baseTime << TestLog::EndSample;
674*35238bceSAndroid Build Coastguard Worker         }
675*35238bceSAndroid Build Coastguard Worker     }
676*35238bceSAndroid Build Coastguard Worker 
677*35238bceSAndroid Build Coastguard Worker     log << TestLog::EndSampleList;
678*35238bceSAndroid Build Coastguard Worker }
679*35238bceSAndroid Build Coastguard Worker 
logGeometry(const tcu::ConstPixelBufferAccess & sample,const glu::ShaderProgram & occluderProg,const glu::ShaderProgram & occludedProg)680*35238bceSAndroid Build Coastguard Worker void BaseCase::logGeometry(const tcu::ConstPixelBufferAccess &sample, const glu::ShaderProgram &occluderProg,
681*35238bceSAndroid Build Coastguard Worker                            const glu::ShaderProgram &occludedProg)
682*35238bceSAndroid Build Coastguard Worker {
683*35238bceSAndroid Build Coastguard Worker     TestLog &log = m_testCtx.getLog();
684*35238bceSAndroid Build Coastguard Worker 
685*35238bceSAndroid Build Coastguard Worker     log << TestLog::Section("Geometry", "Geometry");
686*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Occluding geometry is green with shade dependent on depth (rgb == 0, depth, 0)"
687*35238bceSAndroid Build Coastguard Worker         << TestLog::EndMessage;
688*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Occluded geometry is red with shade dependent on depth (rgb == depth, 0, 0)"
689*35238bceSAndroid Build Coastguard Worker         << TestLog::EndMessage;
690*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Primitive edges are a lighter shade of red/green" << TestLog::EndMessage;
691*35238bceSAndroid Build Coastguard Worker 
692*35238bceSAndroid Build Coastguard Worker     log << TestLog::Image("Test Geometry", "Test Geometry", sample);
693*35238bceSAndroid Build Coastguard Worker     log << TestLog::EndSection;
694*35238bceSAndroid Build Coastguard Worker 
695*35238bceSAndroid Build Coastguard Worker     log << TestLog::Section("Occluder", "Occluder");
696*35238bceSAndroid Build Coastguard Worker     log << occluderProg;
697*35238bceSAndroid Build Coastguard Worker     log << TestLog::EndSection;
698*35238bceSAndroid Build Coastguard Worker 
699*35238bceSAndroid Build Coastguard Worker     log << TestLog::Section("Occluded", "Occluded");
700*35238bceSAndroid Build Coastguard Worker     log << occludedProg;
701*35238bceSAndroid Build Coastguard Worker     log << TestLog::EndSection;
702*35238bceSAndroid Build Coastguard Worker }
703*35238bceSAndroid Build Coastguard Worker 
render(const RenderData & data) const704*35238bceSAndroid Build Coastguard Worker void BaseCase::render(const RenderData &data) const
705*35238bceSAndroid Build Coastguard Worker {
706*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
707*35238bceSAndroid Build Coastguard Worker 
708*35238bceSAndroid Build Coastguard Worker     gl.useProgram(data.m_program.getProgram());
709*35238bceSAndroid Build Coastguard Worker 
710*35238bceSAndroid Build Coastguard Worker     gl.bindVertexArray(*data.m_vao);
711*35238bceSAndroid Build Coastguard Worker     gl.drawArrays(GL_TRIANGLES, 0, data.m_numVertices);
712*35238bceSAndroid Build Coastguard Worker     gl.bindVertexArray(0);
713*35238bceSAndroid Build Coastguard Worker }
714*35238bceSAndroid Build Coastguard Worker 
render(const RenderData & data,int instances) const715*35238bceSAndroid Build Coastguard Worker void BaseCase::render(const RenderData &data, int instances) const
716*35238bceSAndroid Build Coastguard Worker {
717*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
718*35238bceSAndroid Build Coastguard Worker 
719*35238bceSAndroid Build Coastguard Worker     gl.useProgram(data.m_program.getProgram());
720*35238bceSAndroid Build Coastguard Worker 
721*35238bceSAndroid Build Coastguard Worker     gl.bindVertexArray(*data.m_vao);
722*35238bceSAndroid Build Coastguard Worker     gl.drawArraysInstanced(GL_TRIANGLES, 0, data.m_numVertices, instances);
723*35238bceSAndroid Build Coastguard Worker     gl.bindVertexArray(0);
724*35238bceSAndroid Build Coastguard Worker }
725*35238bceSAndroid Build Coastguard Worker 
726*35238bceSAndroid Build Coastguard Worker // Render occluder once, then repeatedly render occluded geometry. Sample with multiple repetition counts & establish time per call with linear regression
727*35238bceSAndroid Build Coastguard Worker class RenderCountCase : public BaseCase
728*35238bceSAndroid Build Coastguard Worker {
729*35238bceSAndroid Build Coastguard Worker public:
730*35238bceSAndroid Build Coastguard Worker     RenderCountCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name, const char *desc);
~RenderCountCase(void)731*35238bceSAndroid Build Coastguard Worker     ~RenderCountCase(void)
732*35238bceSAndroid Build Coastguard Worker     {
733*35238bceSAndroid Build Coastguard Worker     }
734*35238bceSAndroid Build Coastguard Worker 
735*35238bceSAndroid Build Coastguard Worker protected:
736*35238bceSAndroid Build Coastguard Worker     virtual void logAnalysis(const vector<Sample> &samples);
737*35238bceSAndroid Build Coastguard Worker 
738*35238bceSAndroid Build Coastguard Worker private:
739*35238bceSAndroid Build Coastguard Worker     virtual int calibrate(void) const;
740*35238bceSAndroid Build Coastguard Worker     virtual Sample renderSample(const RenderData &occluder, const RenderData &occluded, int callcount) const;
741*35238bceSAndroid Build Coastguard Worker };
742*35238bceSAndroid Build Coastguard Worker 
RenderCountCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)743*35238bceSAndroid Build Coastguard Worker RenderCountCase::RenderCountCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
744*35238bceSAndroid Build Coastguard Worker                                  const char *desc)
745*35238bceSAndroid Build Coastguard Worker     : BaseCase(testCtx, renderCtx, name, desc)
746*35238bceSAndroid Build Coastguard Worker {
747*35238bceSAndroid Build Coastguard Worker }
748*35238bceSAndroid Build Coastguard Worker 
logAnalysis(const vector<Sample> & samples)749*35238bceSAndroid Build Coastguard Worker void RenderCountCase::logAnalysis(const vector<Sample> &samples)
750*35238bceSAndroid Build Coastguard Worker {
751*35238bceSAndroid Build Coastguard Worker     using namespace gls;
752*35238bceSAndroid Build Coastguard Worker 
753*35238bceSAndroid Build Coastguard Worker     TestLog &log    = m_testCtx.getLog();
754*35238bceSAndroid Build Coastguard Worker     int maxWorkload = 0;
755*35238bceSAndroid Build Coastguard Worker     vector<Vec2> testSamples(samples.size());
756*35238bceSAndroid Build Coastguard Worker 
757*35238bceSAndroid Build Coastguard Worker     for (size_t ndx = 0; ndx < samples.size(); ndx++)
758*35238bceSAndroid Build Coastguard Worker     {
759*35238bceSAndroid Build Coastguard Worker         const Sample &sample = samples[ndx];
760*35238bceSAndroid Build Coastguard Worker 
761*35238bceSAndroid Build Coastguard Worker         testSamples[ndx] = Vec2((float)sample.workload, (float)sample.testTime);
762*35238bceSAndroid Build Coastguard Worker 
763*35238bceSAndroid Build Coastguard Worker         maxWorkload = de::max(maxWorkload, sample.workload);
764*35238bceSAndroid Build Coastguard Worker     }
765*35238bceSAndroid Build Coastguard Worker 
766*35238bceSAndroid Build Coastguard Worker     {
767*35238bceSAndroid Build Coastguard Worker         const float confidence                       = 0.60f;
768*35238bceSAndroid Build Coastguard Worker         const LineParametersWithConfidence testParam = theilSenSiegelLinearRegression(testSamples, confidence);
769*35238bceSAndroid Build Coastguard Worker         const float usPerCall                        = testParam.coefficient;
770*35238bceSAndroid Build Coastguard Worker         const float pxPerCall                        = RENDER_SIZE * RENDER_SIZE;
771*35238bceSAndroid Build Coastguard Worker         const float pxPerUs                          = pxPerCall / usPerCall;
772*35238bceSAndroid Build Coastguard Worker         const float mpxPerS                          = pxPerUs;
773*35238bceSAndroid Build Coastguard Worker 
774*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Linear Regression", "Linear Regression");
775*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
776*35238bceSAndroid Build Coastguard Worker             << "Offset & coefficient presented as [confidence interval min, estimate, confidence interval max]. "
777*35238bceSAndroid Build Coastguard Worker                "Reported confidence interval for this test is "
778*35238bceSAndroid Build Coastguard Worker             << confidence << TestLog::EndMessage;
779*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Render time for scene with depth test was\n\t"
780*35238bceSAndroid Build Coastguard Worker             << "[" << testParam.offsetConfidenceLower << ", " << testParam.offset << ", "
781*35238bceSAndroid Build Coastguard Worker             << testParam.offsetConfidenceUpper << "]us +"
782*35238bceSAndroid Build Coastguard Worker             << "[" << testParam.coefficientConfidenceLower << ", " << testParam.coefficient << ", "
783*35238bceSAndroid Build Coastguard Worker             << testParam.coefficientConfidenceUpper << "]"
784*35238bceSAndroid Build Coastguard Worker             << "us/workload" << TestLog::EndMessage;
785*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
786*35238bceSAndroid Build Coastguard Worker 
787*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Result", "Result");
788*35238bceSAndroid Build Coastguard Worker 
789*35238bceSAndroid Build Coastguard Worker         if (testParam.coefficientConfidenceLower < 0.0f)
790*35238bceSAndroid Build Coastguard Worker         {
791*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message
792*35238bceSAndroid Build Coastguard Worker                 << "Coefficient confidence bounds include values below 0.0, the operation likely has neglible "
793*35238bceSAndroid Build Coastguard Worker                    "per-pixel cost"
794*35238bceSAndroid Build Coastguard Worker                 << TestLog::EndMessage;
795*35238bceSAndroid Build Coastguard Worker             m_results.addResult(QP_TEST_RESULT_PASS, "Pass");
796*35238bceSAndroid Build Coastguard Worker         }
797*35238bceSAndroid Build Coastguard Worker         else if (testParam.coefficientConfidenceLower < testParam.coefficientConfidenceUpper * 0.25)
798*35238bceSAndroid Build Coastguard Worker         {
799*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Coefficient confidence range is extremely large, cannot give reliable result"
800*35238bceSAndroid Build Coastguard Worker                 << TestLog::EndMessage;
801*35238bceSAndroid Build Coastguard Worker             m_results.addResult(QP_TEST_RESULT_PASS, "Result confidence extremely low");
802*35238bceSAndroid Build Coastguard Worker         }
803*35238bceSAndroid Build Coastguard Worker         else
804*35238bceSAndroid Build Coastguard Worker         {
805*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Culled hidden pixels @ " << mpxPerS << "Mpx/s" << TestLog::EndMessage;
806*35238bceSAndroid Build Coastguard Worker             m_results.addResult(QP_TEST_RESULT_PASS, de::floatToString(mpxPerS, 2));
807*35238bceSAndroid Build Coastguard Worker         }
808*35238bceSAndroid Build Coastguard Worker 
809*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
810*35238bceSAndroid Build Coastguard Worker     }
811*35238bceSAndroid Build Coastguard Worker }
812*35238bceSAndroid Build Coastguard Worker 
renderSample(const RenderData & occluder,const RenderData & occluded,int callcount) const813*35238bceSAndroid Build Coastguard Worker Sample RenderCountCase::renderSample(const RenderData &occluder, const RenderData &occluded, int callcount) const
814*35238bceSAndroid Build Coastguard Worker {
815*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
816*35238bceSAndroid Build Coastguard Worker     Sample sample;
817*35238bceSAndroid Build Coastguard Worker     uint64_t now  = 0;
818*35238bceSAndroid Build Coastguard Worker     uint64_t prev = 0;
819*35238bceSAndroid Build Coastguard Worker     uint8_t buffer[4];
820*35238bceSAndroid Build Coastguard Worker 
821*35238bceSAndroid Build Coastguard Worker     // Stabilize
822*35238bceSAndroid Build Coastguard Worker     {
823*35238bceSAndroid Build Coastguard Worker         gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
824*35238bceSAndroid Build Coastguard Worker         gl.enable(GL_DEPTH_TEST);
825*35238bceSAndroid Build Coastguard Worker         gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
826*35238bceSAndroid Build Coastguard Worker     }
827*35238bceSAndroid Build Coastguard Worker 
828*35238bceSAndroid Build Coastguard Worker     prev = deGetMicroseconds();
829*35238bceSAndroid Build Coastguard Worker 
830*35238bceSAndroid Build Coastguard Worker     gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
831*35238bceSAndroid Build Coastguard Worker     gl.enable(GL_DEPTH_TEST);
832*35238bceSAndroid Build Coastguard Worker 
833*35238bceSAndroid Build Coastguard Worker     render(occluder);
834*35238bceSAndroid Build Coastguard Worker     render(occluded, callcount);
835*35238bceSAndroid Build Coastguard Worker 
836*35238bceSAndroid Build Coastguard Worker     gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
837*35238bceSAndroid Build Coastguard Worker 
838*35238bceSAndroid Build Coastguard Worker     now = deGetMicroseconds();
839*35238bceSAndroid Build Coastguard Worker 
840*35238bceSAndroid Build Coastguard Worker     sample.testTime = now - prev;
841*35238bceSAndroid Build Coastguard Worker     sample.baseTime = 0;
842*35238bceSAndroid Build Coastguard Worker     sample.nullTime = 0;
843*35238bceSAndroid Build Coastguard Worker     sample.workload = callcount;
844*35238bceSAndroid Build Coastguard Worker 
845*35238bceSAndroid Build Coastguard Worker     return sample;
846*35238bceSAndroid Build Coastguard Worker }
847*35238bceSAndroid Build Coastguard Worker 
calibrate(void) const848*35238bceSAndroid Build Coastguard Worker int RenderCountCase::calibrate(void) const
849*35238bceSAndroid Build Coastguard Worker {
850*35238bceSAndroid Build Coastguard Worker     using namespace gls;
851*35238bceSAndroid Build Coastguard Worker 
852*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
853*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
854*35238bceSAndroid Build Coastguard Worker 
855*35238bceSAndroid Build Coastguard Worker     const RenderData occluderGeometry(genOccluderGeometry(), m_renderCtx, log);
856*35238bceSAndroid Build Coastguard Worker     const RenderData occludedGeometry(genOccludedGeometry(), m_renderCtx, log);
857*35238bceSAndroid Build Coastguard Worker 
858*35238bceSAndroid Build Coastguard Worker     TheilSenCalibrator calibrator(CalibratorParameters(20,     // Initial workload
859*35238bceSAndroid Build Coastguard Worker                                                        10,     // Max iteration frames
860*35238bceSAndroid Build Coastguard Worker                                                        20.0f,  // Iteration shortcut threshold ms
861*35238bceSAndroid Build Coastguard Worker                                                        20,     // Max iterations
862*35238bceSAndroid Build Coastguard Worker                                                        33.0f,  // Target frame time
863*35238bceSAndroid Build Coastguard Worker                                                        40.0f,  // Frame time cap
864*35238bceSAndroid Build Coastguard Worker                                                        1000.0f // Target measurement duration
865*35238bceSAndroid Build Coastguard Worker                                                        ));
866*35238bceSAndroid Build Coastguard Worker 
867*35238bceSAndroid Build Coastguard Worker     while (true)
868*35238bceSAndroid Build Coastguard Worker     {
869*35238bceSAndroid Build Coastguard Worker         switch (calibrator.getState())
870*35238bceSAndroid Build Coastguard Worker         {
871*35238bceSAndroid Build Coastguard Worker         case TheilSenCalibrator::STATE_FINISHED:
872*35238bceSAndroid Build Coastguard Worker             logCalibrationInfo(m_testCtx.getLog(), calibrator);
873*35238bceSAndroid Build Coastguard Worker             return calibrator.getCallCount();
874*35238bceSAndroid Build Coastguard Worker 
875*35238bceSAndroid Build Coastguard Worker         case TheilSenCalibrator::STATE_MEASURE:
876*35238bceSAndroid Build Coastguard Worker         {
877*35238bceSAndroid Build Coastguard Worker             uint8_t buffer[4];
878*35238bceSAndroid Build Coastguard Worker             int64_t now;
879*35238bceSAndroid Build Coastguard Worker             int64_t prev;
880*35238bceSAndroid Build Coastguard Worker 
881*35238bceSAndroid Build Coastguard Worker             prev = deGetMicroseconds();
882*35238bceSAndroid Build Coastguard Worker 
883*35238bceSAndroid Build Coastguard Worker             gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
884*35238bceSAndroid Build Coastguard Worker             gl.disable(GL_DEPTH_TEST);
885*35238bceSAndroid Build Coastguard Worker 
886*35238bceSAndroid Build Coastguard Worker             render(occluderGeometry);
887*35238bceSAndroid Build Coastguard Worker             render(occludedGeometry, calibrator.getCallCount());
888*35238bceSAndroid Build Coastguard Worker 
889*35238bceSAndroid Build Coastguard Worker             gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
890*35238bceSAndroid Build Coastguard Worker 
891*35238bceSAndroid Build Coastguard Worker             now = deGetMicroseconds();
892*35238bceSAndroid Build Coastguard Worker 
893*35238bceSAndroid Build Coastguard Worker             calibrator.recordIteration(now - prev);
894*35238bceSAndroid Build Coastguard Worker             break;
895*35238bceSAndroid Build Coastguard Worker         }
896*35238bceSAndroid Build Coastguard Worker 
897*35238bceSAndroid Build Coastguard Worker         case TheilSenCalibrator::STATE_RECOMPUTE_PARAMS:
898*35238bceSAndroid Build Coastguard Worker             calibrator.recomputeParameters();
899*35238bceSAndroid Build Coastguard Worker             break;
900*35238bceSAndroid Build Coastguard Worker         default:
901*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false);
902*35238bceSAndroid Build Coastguard Worker             return 1;
903*35238bceSAndroid Build Coastguard Worker         }
904*35238bceSAndroid Build Coastguard Worker     }
905*35238bceSAndroid Build Coastguard Worker }
906*35238bceSAndroid Build Coastguard Worker 
907*35238bceSAndroid Build Coastguard Worker // Compares time/workload gradients of same geometry with and without depth testing
908*35238bceSAndroid Build Coastguard Worker class RelativeChangeCase : public BaseCase
909*35238bceSAndroid Build Coastguard Worker {
910*35238bceSAndroid Build Coastguard Worker public:
911*35238bceSAndroid Build Coastguard Worker     RelativeChangeCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name, const char *desc);
~RelativeChangeCase(void)912*35238bceSAndroid Build Coastguard Worker     virtual ~RelativeChangeCase(void)
913*35238bceSAndroid Build Coastguard Worker     {
914*35238bceSAndroid Build Coastguard Worker     }
915*35238bceSAndroid Build Coastguard Worker 
916*35238bceSAndroid Build Coastguard Worker protected:
917*35238bceSAndroid Build Coastguard Worker     Sample renderSample(const RenderData &occluder, const RenderData &occluded, int workload) const;
918*35238bceSAndroid Build Coastguard Worker 
919*35238bceSAndroid Build Coastguard Worker     virtual void logAnalysis(const vector<Sample> &samples);
920*35238bceSAndroid Build Coastguard Worker 
921*35238bceSAndroid Build Coastguard Worker private:
922*35238bceSAndroid Build Coastguard Worker     int calibrate(void) const;
923*35238bceSAndroid Build Coastguard Worker };
924*35238bceSAndroid Build Coastguard Worker 
RelativeChangeCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)925*35238bceSAndroid Build Coastguard Worker RelativeChangeCase::RelativeChangeCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
926*35238bceSAndroid Build Coastguard Worker                                        const char *desc)
927*35238bceSAndroid Build Coastguard Worker     : BaseCase(testCtx, renderCtx, name, desc)
928*35238bceSAndroid Build Coastguard Worker {
929*35238bceSAndroid Build Coastguard Worker }
930*35238bceSAndroid Build Coastguard Worker 
calibrate(void) const931*35238bceSAndroid Build Coastguard Worker int RelativeChangeCase::calibrate(void) const
932*35238bceSAndroid Build Coastguard Worker {
933*35238bceSAndroid Build Coastguard Worker     using namespace gls;
934*35238bceSAndroid Build Coastguard Worker 
935*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
936*35238bceSAndroid Build Coastguard Worker     TestLog &log             = m_testCtx.getLog();
937*35238bceSAndroid Build Coastguard Worker 
938*35238bceSAndroid Build Coastguard Worker     const RenderData geom(genOccludedGeometry(), m_renderCtx, log);
939*35238bceSAndroid Build Coastguard Worker 
940*35238bceSAndroid Build Coastguard Worker     TheilSenCalibrator calibrator(CalibratorParameters(20,     // Initial workload
941*35238bceSAndroid Build Coastguard Worker                                                        10,     // Max iteration frames
942*35238bceSAndroid Build Coastguard Worker                                                        20.0f,  // Iteration shortcut threshold ms
943*35238bceSAndroid Build Coastguard Worker                                                        20,     // Max iterations
944*35238bceSAndroid Build Coastguard Worker                                                        33.0f,  // Target frame time
945*35238bceSAndroid Build Coastguard Worker                                                        40.0f,  // Frame time cap
946*35238bceSAndroid Build Coastguard Worker                                                        1000.0f // Target measurement duration
947*35238bceSAndroid Build Coastguard Worker                                                        ));
948*35238bceSAndroid Build Coastguard Worker 
949*35238bceSAndroid Build Coastguard Worker     while (true)
950*35238bceSAndroid Build Coastguard Worker     {
951*35238bceSAndroid Build Coastguard Worker         switch (calibrator.getState())
952*35238bceSAndroid Build Coastguard Worker         {
953*35238bceSAndroid Build Coastguard Worker         case TheilSenCalibrator::STATE_FINISHED:
954*35238bceSAndroid Build Coastguard Worker             logCalibrationInfo(m_testCtx.getLog(), calibrator);
955*35238bceSAndroid Build Coastguard Worker             return calibrator.getCallCount();
956*35238bceSAndroid Build Coastguard Worker 
957*35238bceSAndroid Build Coastguard Worker         case TheilSenCalibrator::STATE_MEASURE:
958*35238bceSAndroid Build Coastguard Worker         {
959*35238bceSAndroid Build Coastguard Worker             uint8_t buffer[4];
960*35238bceSAndroid Build Coastguard Worker             const GLuint program = geom.m_program.getProgram();
961*35238bceSAndroid Build Coastguard Worker 
962*35238bceSAndroid Build Coastguard Worker             gl.useProgram(program);
963*35238bceSAndroid Build Coastguard Worker             gl.uniform1i(gl.getUniformLocation(program, "u_iterations"), calibrator.getCallCount());
964*35238bceSAndroid Build Coastguard Worker 
965*35238bceSAndroid Build Coastguard Worker             const int64_t prev = deGetMicroseconds();
966*35238bceSAndroid Build Coastguard Worker 
967*35238bceSAndroid Build Coastguard Worker             gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
968*35238bceSAndroid Build Coastguard Worker             gl.disable(GL_DEPTH_TEST);
969*35238bceSAndroid Build Coastguard Worker 
970*35238bceSAndroid Build Coastguard Worker             render(geom);
971*35238bceSAndroid Build Coastguard Worker 
972*35238bceSAndroid Build Coastguard Worker             gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
973*35238bceSAndroid Build Coastguard Worker 
974*35238bceSAndroid Build Coastguard Worker             const int64_t now = deGetMicroseconds();
975*35238bceSAndroid Build Coastguard Worker 
976*35238bceSAndroid Build Coastguard Worker             calibrator.recordIteration(now - prev);
977*35238bceSAndroid Build Coastguard Worker             break;
978*35238bceSAndroid Build Coastguard Worker         }
979*35238bceSAndroid Build Coastguard Worker 
980*35238bceSAndroid Build Coastguard Worker         case TheilSenCalibrator::STATE_RECOMPUTE_PARAMS:
981*35238bceSAndroid Build Coastguard Worker             calibrator.recomputeParameters();
982*35238bceSAndroid Build Coastguard Worker             break;
983*35238bceSAndroid Build Coastguard Worker         default:
984*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false);
985*35238bceSAndroid Build Coastguard Worker             return 1;
986*35238bceSAndroid Build Coastguard Worker         }
987*35238bceSAndroid Build Coastguard Worker     }
988*35238bceSAndroid Build Coastguard Worker }
989*35238bceSAndroid Build Coastguard Worker 
renderSample(const RenderData & occluder,const RenderData & occluded,int workload) const990*35238bceSAndroid Build Coastguard Worker Sample RelativeChangeCase::renderSample(const RenderData &occluder, const RenderData &occluded, int workload) const
991*35238bceSAndroid Build Coastguard Worker {
992*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
993*35238bceSAndroid Build Coastguard Worker     const GLuint program     = occluded.m_program.getProgram();
994*35238bceSAndroid Build Coastguard Worker     Sample sample;
995*35238bceSAndroid Build Coastguard Worker     uint64_t now  = 0;
996*35238bceSAndroid Build Coastguard Worker     uint64_t prev = 0;
997*35238bceSAndroid Build Coastguard Worker     uint8_t buffer[4];
998*35238bceSAndroid Build Coastguard Worker 
999*35238bceSAndroid Build Coastguard Worker     gl.useProgram(program);
1000*35238bceSAndroid Build Coastguard Worker     gl.uniform1i(gl.getUniformLocation(program, "u_iterations"), workload);
1001*35238bceSAndroid Build Coastguard Worker 
1002*35238bceSAndroid Build Coastguard Worker     // Warmup (this workload seems to reduce variation in following workloads)
1003*35238bceSAndroid Build Coastguard Worker     {
1004*35238bceSAndroid Build Coastguard Worker         gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1005*35238bceSAndroid Build Coastguard Worker         gl.disable(GL_DEPTH_TEST);
1006*35238bceSAndroid Build Coastguard Worker 
1007*35238bceSAndroid Build Coastguard Worker         gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
1008*35238bceSAndroid Build Coastguard Worker     }
1009*35238bceSAndroid Build Coastguard Worker 
1010*35238bceSAndroid Build Coastguard Worker     // Null time
1011*35238bceSAndroid Build Coastguard Worker     {
1012*35238bceSAndroid Build Coastguard Worker         prev = deGetMicroseconds();
1013*35238bceSAndroid Build Coastguard Worker 
1014*35238bceSAndroid Build Coastguard Worker         gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1015*35238bceSAndroid Build Coastguard Worker         gl.disable(GL_DEPTH_TEST);
1016*35238bceSAndroid Build Coastguard Worker 
1017*35238bceSAndroid Build Coastguard Worker         gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
1018*35238bceSAndroid Build Coastguard Worker 
1019*35238bceSAndroid Build Coastguard Worker         now = deGetMicroseconds();
1020*35238bceSAndroid Build Coastguard Worker 
1021*35238bceSAndroid Build Coastguard Worker         sample.nullTime = now - prev;
1022*35238bceSAndroid Build Coastguard Worker     }
1023*35238bceSAndroid Build Coastguard Worker 
1024*35238bceSAndroid Build Coastguard Worker     // Test time
1025*35238bceSAndroid Build Coastguard Worker     {
1026*35238bceSAndroid Build Coastguard Worker         prev = deGetMicroseconds();
1027*35238bceSAndroid Build Coastguard Worker 
1028*35238bceSAndroid Build Coastguard Worker         gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1029*35238bceSAndroid Build Coastguard Worker         gl.enable(GL_DEPTH_TEST);
1030*35238bceSAndroid Build Coastguard Worker 
1031*35238bceSAndroid Build Coastguard Worker         render(occluder);
1032*35238bceSAndroid Build Coastguard Worker         render(occluded);
1033*35238bceSAndroid Build Coastguard Worker 
1034*35238bceSAndroid Build Coastguard Worker         gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
1035*35238bceSAndroid Build Coastguard Worker 
1036*35238bceSAndroid Build Coastguard Worker         now = deGetMicroseconds();
1037*35238bceSAndroid Build Coastguard Worker 
1038*35238bceSAndroid Build Coastguard Worker         sample.testTime = now - prev;
1039*35238bceSAndroid Build Coastguard Worker     }
1040*35238bceSAndroid Build Coastguard Worker 
1041*35238bceSAndroid Build Coastguard Worker     // Base time
1042*35238bceSAndroid Build Coastguard Worker     {
1043*35238bceSAndroid Build Coastguard Worker         prev = deGetMicroseconds();
1044*35238bceSAndroid Build Coastguard Worker 
1045*35238bceSAndroid Build Coastguard Worker         gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1046*35238bceSAndroid Build Coastguard Worker         gl.disable(GL_DEPTH_TEST);
1047*35238bceSAndroid Build Coastguard Worker 
1048*35238bceSAndroid Build Coastguard Worker         render(occluder);
1049*35238bceSAndroid Build Coastguard Worker         render(occluded);
1050*35238bceSAndroid Build Coastguard Worker 
1051*35238bceSAndroid Build Coastguard Worker         gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
1052*35238bceSAndroid Build Coastguard Worker 
1053*35238bceSAndroid Build Coastguard Worker         now = deGetMicroseconds();
1054*35238bceSAndroid Build Coastguard Worker 
1055*35238bceSAndroid Build Coastguard Worker         sample.baseTime = now - prev;
1056*35238bceSAndroid Build Coastguard Worker     }
1057*35238bceSAndroid Build Coastguard Worker 
1058*35238bceSAndroid Build Coastguard Worker     sample.workload = 0;
1059*35238bceSAndroid Build Coastguard Worker 
1060*35238bceSAndroid Build Coastguard Worker     return sample;
1061*35238bceSAndroid Build Coastguard Worker }
1062*35238bceSAndroid Build Coastguard Worker 
logAnalysis(const vector<Sample> & samples)1063*35238bceSAndroid Build Coastguard Worker void RelativeChangeCase::logAnalysis(const vector<Sample> &samples)
1064*35238bceSAndroid Build Coastguard Worker {
1065*35238bceSAndroid Build Coastguard Worker     using namespace gls;
1066*35238bceSAndroid Build Coastguard Worker 
1067*35238bceSAndroid Build Coastguard Worker     TestLog &log = m_testCtx.getLog();
1068*35238bceSAndroid Build Coastguard Worker 
1069*35238bceSAndroid Build Coastguard Worker     int maxWorkload = 0;
1070*35238bceSAndroid Build Coastguard Worker 
1071*35238bceSAndroid Build Coastguard Worker     vector<Vec2> nullSamples(samples.size());
1072*35238bceSAndroid Build Coastguard Worker     vector<Vec2> baseSamples(samples.size());
1073*35238bceSAndroid Build Coastguard Worker     vector<Vec2> testSamples(samples.size());
1074*35238bceSAndroid Build Coastguard Worker 
1075*35238bceSAndroid Build Coastguard Worker     for (size_t ndx = 0; ndx < samples.size(); ndx++)
1076*35238bceSAndroid Build Coastguard Worker     {
1077*35238bceSAndroid Build Coastguard Worker         const Sample &sample = samples[ndx];
1078*35238bceSAndroid Build Coastguard Worker 
1079*35238bceSAndroid Build Coastguard Worker         nullSamples[ndx] = Vec2((float)sample.workload, (float)sample.nullTime);
1080*35238bceSAndroid Build Coastguard Worker         baseSamples[ndx] = Vec2((float)sample.workload, (float)sample.baseTime);
1081*35238bceSAndroid Build Coastguard Worker         testSamples[ndx] = Vec2((float)sample.workload, (float)sample.testTime);
1082*35238bceSAndroid Build Coastguard Worker 
1083*35238bceSAndroid Build Coastguard Worker         maxWorkload = de::max(maxWorkload, sample.workload);
1084*35238bceSAndroid Build Coastguard Worker     }
1085*35238bceSAndroid Build Coastguard Worker 
1086*35238bceSAndroid Build Coastguard Worker     {
1087*35238bceSAndroid Build Coastguard Worker         const float confidence = 0.60f;
1088*35238bceSAndroid Build Coastguard Worker 
1089*35238bceSAndroid Build Coastguard Worker         const LineParametersWithConfidence nullParam = theilSenSiegelLinearRegression(nullSamples, confidence);
1090*35238bceSAndroid Build Coastguard Worker         const LineParametersWithConfidence baseParam = theilSenSiegelLinearRegression(baseSamples, confidence);
1091*35238bceSAndroid Build Coastguard Worker         const LineParametersWithConfidence testParam = theilSenSiegelLinearRegression(testSamples, confidence);
1092*35238bceSAndroid Build Coastguard Worker 
1093*35238bceSAndroid Build Coastguard Worker         if (!de::inRange(0.0f, nullParam.coefficientConfidenceLower, nullParam.coefficientConfidenceUpper))
1094*35238bceSAndroid Build Coastguard Worker         {
1095*35238bceSAndroid Build Coastguard Worker             m_results.addResult(QP_TEST_RESULT_FAIL, "Constant operation sequence duration not constant");
1096*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message
1097*35238bceSAndroid Build Coastguard Worker                 << "Constant operation sequence timing may vary as a function of workload. Result quality extremely low"
1098*35238bceSAndroid Build Coastguard Worker                 << TestLog::EndMessage;
1099*35238bceSAndroid Build Coastguard Worker         }
1100*35238bceSAndroid Build Coastguard Worker 
1101*35238bceSAndroid Build Coastguard Worker         if (de::inRange(0.0f, baseParam.coefficientConfidenceLower, baseParam.coefficientConfidenceUpper))
1102*35238bceSAndroid Build Coastguard Worker         {
1103*35238bceSAndroid Build Coastguard Worker             m_results.addResult(QP_TEST_RESULT_FAIL, "Workload has no effect on duration");
1104*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Workload factor has no effect on duration of sample (smart optimizer?)"
1105*35238bceSAndroid Build Coastguard Worker                 << TestLog::EndMessage;
1106*35238bceSAndroid Build Coastguard Worker         }
1107*35238bceSAndroid Build Coastguard Worker 
1108*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Linear Regression", "Linear Regression");
1109*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1110*35238bceSAndroid Build Coastguard Worker             << "Offset & coefficient presented as [confidence interval min, estimate, confidence interval max]. "
1111*35238bceSAndroid Build Coastguard Worker                "Reported confidence interval for this test is "
1112*35238bceSAndroid Build Coastguard Worker             << confidence << TestLog::EndMessage;
1113*35238bceSAndroid Build Coastguard Worker 
1114*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Render time for empty scene was\n\t"
1115*35238bceSAndroid Build Coastguard Worker             << "[" << nullParam.offsetConfidenceLower << ", " << nullParam.offset << ", "
1116*35238bceSAndroid Build Coastguard Worker             << nullParam.offsetConfidenceUpper << "]us +"
1117*35238bceSAndroid Build Coastguard Worker             << "[" << nullParam.coefficientConfidenceLower << ", " << nullParam.coefficient << ", "
1118*35238bceSAndroid Build Coastguard Worker             << nullParam.coefficientConfidenceUpper << "]"
1119*35238bceSAndroid Build Coastguard Worker             << "us/workload" << TestLog::EndMessage;
1120*35238bceSAndroid Build Coastguard Worker 
1121*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Render time for scene without depth test was\n\t"
1122*35238bceSAndroid Build Coastguard Worker             << "[" << baseParam.offsetConfidenceLower << ", " << baseParam.offset << ", "
1123*35238bceSAndroid Build Coastguard Worker             << baseParam.offsetConfidenceUpper << "]us +"
1124*35238bceSAndroid Build Coastguard Worker             << "[" << baseParam.coefficientConfidenceLower << ", " << baseParam.coefficient << ", "
1125*35238bceSAndroid Build Coastguard Worker             << baseParam.coefficientConfidenceUpper << "]"
1126*35238bceSAndroid Build Coastguard Worker             << "us/workload" << TestLog::EndMessage;
1127*35238bceSAndroid Build Coastguard Worker 
1128*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Render time for scene with depth test was\n\t"
1129*35238bceSAndroid Build Coastguard Worker             << "[" << testParam.offsetConfidenceLower << ", " << testParam.offset << ", "
1130*35238bceSAndroid Build Coastguard Worker             << testParam.offsetConfidenceUpper << "]us +"
1131*35238bceSAndroid Build Coastguard Worker             << "[" << testParam.coefficientConfidenceLower << ", " << testParam.coefficient << ", "
1132*35238bceSAndroid Build Coastguard Worker             << testParam.coefficientConfidenceUpper << "]"
1133*35238bceSAndroid Build Coastguard Worker             << "us/workload" << TestLog::EndMessage;
1134*35238bceSAndroid Build Coastguard Worker 
1135*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1136*35238bceSAndroid Build Coastguard Worker 
1137*35238bceSAndroid Build Coastguard Worker         if (de::inRange(0.0f, testParam.coefficientConfidenceLower, testParam.coefficientConfidenceUpper))
1138*35238bceSAndroid Build Coastguard Worker         {
1139*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Test duration not dependent on culled workload" << TestLog::EndMessage;
1140*35238bceSAndroid Build Coastguard Worker             m_results.addResult(QP_TEST_RESULT_PASS, "0.0");
1141*35238bceSAndroid Build Coastguard Worker         }
1142*35238bceSAndroid Build Coastguard Worker         else if (testParam.coefficientConfidenceLower < testParam.coefficientConfidenceUpper * 0.25)
1143*35238bceSAndroid Build Coastguard Worker         {
1144*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Coefficient confidence range is extremely large, cannot give reliable result"
1145*35238bceSAndroid Build Coastguard Worker                 << TestLog::EndMessage;
1146*35238bceSAndroid Build Coastguard Worker             m_results.addResult(QP_TEST_RESULT_PASS, "Result confidence extremely low");
1147*35238bceSAndroid Build Coastguard Worker         }
1148*35238bceSAndroid Build Coastguard Worker         else if (baseParam.coefficientConfidenceLower < baseParam.coefficientConfidenceUpper * 0.25)
1149*35238bceSAndroid Build Coastguard Worker         {
1150*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message
1151*35238bceSAndroid Build Coastguard Worker                 << "Coefficient confidence range for base render time is extremely large, cannot give reliable result"
1152*35238bceSAndroid Build Coastguard Worker                 << TestLog::EndMessage;
1153*35238bceSAndroid Build Coastguard Worker             m_results.addResult(QP_TEST_RESULT_PASS, "Result confidence extremely low");
1154*35238bceSAndroid Build Coastguard Worker         }
1155*35238bceSAndroid Build Coastguard Worker         else
1156*35238bceSAndroid Build Coastguard Worker         {
1157*35238bceSAndroid Build Coastguard Worker             log << TestLog::Message << "Test duration is dependent on culled workload" << TestLog::EndMessage;
1158*35238bceSAndroid Build Coastguard Worker             m_results.addResult(QP_TEST_RESULT_PASS,
1159*35238bceSAndroid Build Coastguard Worker                                 de::floatToString(de::abs(testParam.coefficient) / de::abs(baseParam.coefficient), 2));
1160*35238bceSAndroid Build Coastguard Worker         }
1161*35238bceSAndroid Build Coastguard Worker     }
1162*35238bceSAndroid Build Coastguard Worker }
1163*35238bceSAndroid Build Coastguard Worker 
1164*35238bceSAndroid Build Coastguard Worker // Speed of trivial culling
1165*35238bceSAndroid Build Coastguard Worker class BaseCostCase : public RenderCountCase
1166*35238bceSAndroid Build Coastguard Worker {
1167*35238bceSAndroid Build Coastguard Worker public:
BaseCostCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1168*35238bceSAndroid Build Coastguard Worker     BaseCostCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name, const char *desc)
1169*35238bceSAndroid Build Coastguard Worker         : RenderCountCase(testCtx, renderCtx, name, desc)
1170*35238bceSAndroid Build Coastguard Worker     {
1171*35238bceSAndroid Build Coastguard Worker     }
1172*35238bceSAndroid Build Coastguard Worker 
~BaseCostCase(void)1173*35238bceSAndroid Build Coastguard Worker     ~BaseCostCase(void)
1174*35238bceSAndroid Build Coastguard Worker     {
1175*35238bceSAndroid Build Coastguard Worker     }
1176*35238bceSAndroid Build Coastguard Worker 
1177*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1178*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1179*35238bceSAndroid Build Coastguard Worker     {
1180*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuad(0.2f);
1181*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1182*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1183*35238bceSAndroid Build Coastguard Worker     {
1184*35238bceSAndroid Build Coastguard Worker         return Utils::variableQuad(0.8f);
1185*35238bceSAndroid Build Coastguard Worker     }
1186*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1187*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1188*35238bceSAndroid Build Coastguard Worker     {
1189*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1190*35238bceSAndroid Build Coastguard Worker 
1191*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1192*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage;
1193*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1194*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second "
1195*35238bceSAndroid Build Coastguard Worker                "(occluded) is rendered repeatedly"
1196*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1197*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered"
1198*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1199*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1200*35238bceSAndroid Build Coastguard Worker             << "The time per culled pixel is estimated from the rate of change of rendering time as a function of "
1201*35238bceSAndroid Build Coastguard Worker                "workload"
1202*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1203*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1204*35238bceSAndroid Build Coastguard Worker     }
1205*35238bceSAndroid Build Coastguard Worker };
1206*35238bceSAndroid Build Coastguard Worker 
1207*35238bceSAndroid Build Coastguard Worker // Gradient
1208*35238bceSAndroid Build Coastguard Worker class GradientCostCase : public RenderCountCase
1209*35238bceSAndroid Build Coastguard Worker {
1210*35238bceSAndroid Build Coastguard Worker public:
GradientCostCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc,float gradientDistance)1211*35238bceSAndroid Build Coastguard Worker     GradientCostCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name, const char *desc,
1212*35238bceSAndroid Build Coastguard Worker                      float gradientDistance)
1213*35238bceSAndroid Build Coastguard Worker         : RenderCountCase(testCtx, renderCtx, name, desc)
1214*35238bceSAndroid Build Coastguard Worker         , m_gradientDistance(gradientDistance)
1215*35238bceSAndroid Build Coastguard Worker     {
1216*35238bceSAndroid Build Coastguard Worker     }
1217*35238bceSAndroid Build Coastguard Worker 
~GradientCostCase(void)1218*35238bceSAndroid Build Coastguard Worker     ~GradientCostCase(void)
1219*35238bceSAndroid Build Coastguard Worker     {
1220*35238bceSAndroid Build Coastguard Worker     }
1221*35238bceSAndroid Build Coastguard Worker 
1222*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1223*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1224*35238bceSAndroid Build Coastguard Worker     {
1225*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuadWithGradient(0.0f, 1.0f - m_gradientDistance);
1226*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1227*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1228*35238bceSAndroid Build Coastguard Worker     {
1229*35238bceSAndroid Build Coastguard Worker         return ObjectData(
1230*35238bceSAndroid Build Coastguard Worker             glu::makeVtxFragSources(Utils::getInstanceNoiseVertexShader(), Utils::getDepthAsRedFragmentShader()),
1231*35238bceSAndroid Build Coastguard Worker             Utils::getFullscreenQuadWithGradient(m_gradientDistance, 1.0f));
1232*35238bceSAndroid Build Coastguard Worker     }
1233*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1234*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1235*35238bceSAndroid Build Coastguard Worker     {
1236*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1237*35238bceSAndroid Build Coastguard Worker 
1238*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1239*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage;
1240*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1241*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second "
1242*35238bceSAndroid Build Coastguard Worker                "(occluded) is rendered repeatedly"
1243*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1244*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered"
1245*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1246*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1247*35238bceSAndroid Build Coastguard Worker             << "The quads are tilted so that the left edge of the occluded quad has a depth of 1.0 and the right edge "
1248*35238bceSAndroid Build Coastguard Worker                "of the occluding quad has a depth of 0.0."
1249*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1250*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The quads are spaced to have a depth difference of " << m_gradientDistance
1251*35238bceSAndroid Build Coastguard Worker             << " at all points." << TestLog::EndMessage;
1252*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1253*35238bceSAndroid Build Coastguard Worker             << "The time per culled pixel is estimated from the rate of change of rendering time as a function of "
1254*35238bceSAndroid Build Coastguard Worker                "workload"
1255*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1256*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1257*35238bceSAndroid Build Coastguard Worker     }
1258*35238bceSAndroid Build Coastguard Worker 
1259*35238bceSAndroid Build Coastguard Worker     const float m_gradientDistance;
1260*35238bceSAndroid Build Coastguard Worker };
1261*35238bceSAndroid Build Coastguard Worker 
1262*35238bceSAndroid Build Coastguard Worker // Constant offset to frag depth in occluder
1263*35238bceSAndroid Build Coastguard Worker class OccluderStaticFragDepthCostCase : public RenderCountCase
1264*35238bceSAndroid Build Coastguard Worker {
1265*35238bceSAndroid Build Coastguard Worker public:
OccluderStaticFragDepthCostCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1266*35238bceSAndroid Build Coastguard Worker     OccluderStaticFragDepthCostCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1267*35238bceSAndroid Build Coastguard Worker                                     const char *desc)
1268*35238bceSAndroid Build Coastguard Worker         : RenderCountCase(testCtx, renderCtx, name, desc)
1269*35238bceSAndroid Build Coastguard Worker     {
1270*35238bceSAndroid Build Coastguard Worker     }
1271*35238bceSAndroid Build Coastguard Worker 
~OccluderStaticFragDepthCostCase(void)1272*35238bceSAndroid Build Coastguard Worker     ~OccluderStaticFragDepthCostCase(void)
1273*35238bceSAndroid Build Coastguard Worker     {
1274*35238bceSAndroid Build Coastguard Worker     }
1275*35238bceSAndroid Build Coastguard Worker 
1276*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1277*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1278*35238bceSAndroid Build Coastguard Worker     {
1279*35238bceSAndroid Build Coastguard Worker         return Utils::quadWith(Utils::getStaticFragDepthFragmentShader(), 0.2f);
1280*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1281*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1282*35238bceSAndroid Build Coastguard Worker     {
1283*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuad(0.8f);
1284*35238bceSAndroid Build Coastguard Worker     }
1285*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1286*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1287*35238bceSAndroid Build Coastguard Worker     {
1288*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1289*35238bceSAndroid Build Coastguard Worker 
1290*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1291*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage;
1292*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1293*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second "
1294*35238bceSAndroid Build Coastguard Worker                "(occluded) is rendered repeatedly"
1295*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1296*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered"
1297*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1298*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The occluder quad has a static offset applied to gl_FragDepth"
1299*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1300*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1301*35238bceSAndroid Build Coastguard Worker             << "The time per culled pixel is estimated from the rate of change of rendering time as a function of "
1302*35238bceSAndroid Build Coastguard Worker                "workload"
1303*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1304*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1305*35238bceSAndroid Build Coastguard Worker     }
1306*35238bceSAndroid Build Coastguard Worker };
1307*35238bceSAndroid Build Coastguard Worker 
1308*35238bceSAndroid Build Coastguard Worker // Dynamic offset to frag depth in occluder
1309*35238bceSAndroid Build Coastguard Worker class OccluderDynamicFragDepthCostCase : public RenderCountCase
1310*35238bceSAndroid Build Coastguard Worker {
1311*35238bceSAndroid Build Coastguard Worker public:
OccluderDynamicFragDepthCostCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1312*35238bceSAndroid Build Coastguard Worker     OccluderDynamicFragDepthCostCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1313*35238bceSAndroid Build Coastguard Worker                                      const char *desc)
1314*35238bceSAndroid Build Coastguard Worker         : RenderCountCase(testCtx, renderCtx, name, desc)
1315*35238bceSAndroid Build Coastguard Worker     {
1316*35238bceSAndroid Build Coastguard Worker     }
1317*35238bceSAndroid Build Coastguard Worker 
~OccluderDynamicFragDepthCostCase(void)1318*35238bceSAndroid Build Coastguard Worker     ~OccluderDynamicFragDepthCostCase(void)
1319*35238bceSAndroid Build Coastguard Worker     {
1320*35238bceSAndroid Build Coastguard Worker     }
1321*35238bceSAndroid Build Coastguard Worker 
1322*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1323*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1324*35238bceSAndroid Build Coastguard Worker     {
1325*35238bceSAndroid Build Coastguard Worker         return Utils::quadWith(Utils::getDynamicFragDepthFragmentShader(), 0.2f);
1326*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1327*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1328*35238bceSAndroid Build Coastguard Worker     {
1329*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuad(0.8f);
1330*35238bceSAndroid Build Coastguard Worker     }
1331*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1332*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1333*35238bceSAndroid Build Coastguard Worker     {
1334*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1335*35238bceSAndroid Build Coastguard Worker 
1336*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1337*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage;
1338*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1339*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second "
1340*35238bceSAndroid Build Coastguard Worker                "(occluded) is rendered repeatedly"
1341*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1342*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered"
1343*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1344*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The occluder quad has a dynamic offset applied to gl_FragDepth"
1345*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1346*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1347*35238bceSAndroid Build Coastguard Worker             << "The time per culled pixel is estimated from the rate of change of rendering time as a function of "
1348*35238bceSAndroid Build Coastguard Worker                "workload"
1349*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1350*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1351*35238bceSAndroid Build Coastguard Worker     }
1352*35238bceSAndroid Build Coastguard Worker };
1353*35238bceSAndroid Build Coastguard Worker 
1354*35238bceSAndroid Build Coastguard Worker // Constant offset to frag depth in occluder
1355*35238bceSAndroid Build Coastguard Worker class OccludedStaticFragDepthCostCase : public RenderCountCase
1356*35238bceSAndroid Build Coastguard Worker {
1357*35238bceSAndroid Build Coastguard Worker public:
OccludedStaticFragDepthCostCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1358*35238bceSAndroid Build Coastguard Worker     OccludedStaticFragDepthCostCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1359*35238bceSAndroid Build Coastguard Worker                                     const char *desc)
1360*35238bceSAndroid Build Coastguard Worker         : RenderCountCase(testCtx, renderCtx, name, desc)
1361*35238bceSAndroid Build Coastguard Worker     {
1362*35238bceSAndroid Build Coastguard Worker     }
1363*35238bceSAndroid Build Coastguard Worker 
~OccludedStaticFragDepthCostCase(void)1364*35238bceSAndroid Build Coastguard Worker     ~OccludedStaticFragDepthCostCase(void)
1365*35238bceSAndroid Build Coastguard Worker     {
1366*35238bceSAndroid Build Coastguard Worker     }
1367*35238bceSAndroid Build Coastguard Worker 
1368*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1369*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1370*35238bceSAndroid Build Coastguard Worker     {
1371*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuad(0.2f);
1372*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1373*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1374*35238bceSAndroid Build Coastguard Worker     {
1375*35238bceSAndroid Build Coastguard Worker         return Utils::quadWith(Utils::getStaticFragDepthFragmentShader(), 0.2f);
1376*35238bceSAndroid Build Coastguard Worker     }
1377*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1378*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1379*35238bceSAndroid Build Coastguard Worker     {
1380*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1381*35238bceSAndroid Build Coastguard Worker 
1382*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1383*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage;
1384*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1385*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second "
1386*35238bceSAndroid Build Coastguard Worker                "(occluded) is rendered repeatedly"
1387*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1388*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered"
1389*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1390*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The occluded quad has a static offset applied to gl_FragDepth"
1391*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1392*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1393*35238bceSAndroid Build Coastguard Worker             << "The time per culled pixel is estimated from the rate of change of rendering time as a function of "
1394*35238bceSAndroid Build Coastguard Worker                "workload"
1395*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1396*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1397*35238bceSAndroid Build Coastguard Worker     }
1398*35238bceSAndroid Build Coastguard Worker };
1399*35238bceSAndroid Build Coastguard Worker 
1400*35238bceSAndroid Build Coastguard Worker // Dynamic offset to frag depth in occluder
1401*35238bceSAndroid Build Coastguard Worker class OccludedDynamicFragDepthCostCase : public RenderCountCase
1402*35238bceSAndroid Build Coastguard Worker {
1403*35238bceSAndroid Build Coastguard Worker public:
OccludedDynamicFragDepthCostCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1404*35238bceSAndroid Build Coastguard Worker     OccludedDynamicFragDepthCostCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1405*35238bceSAndroid Build Coastguard Worker                                      const char *desc)
1406*35238bceSAndroid Build Coastguard Worker         : RenderCountCase(testCtx, renderCtx, name, desc)
1407*35238bceSAndroid Build Coastguard Worker     {
1408*35238bceSAndroid Build Coastguard Worker     }
1409*35238bceSAndroid Build Coastguard Worker 
~OccludedDynamicFragDepthCostCase(void)1410*35238bceSAndroid Build Coastguard Worker     ~OccludedDynamicFragDepthCostCase(void)
1411*35238bceSAndroid Build Coastguard Worker     {
1412*35238bceSAndroid Build Coastguard Worker     }
1413*35238bceSAndroid Build Coastguard Worker 
1414*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1415*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1416*35238bceSAndroid Build Coastguard Worker     {
1417*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuad(0.2f);
1418*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1419*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1420*35238bceSAndroid Build Coastguard Worker     {
1421*35238bceSAndroid Build Coastguard Worker         return Utils::quadWith(Utils::getDynamicFragDepthFragmentShader(), 0.2f);
1422*35238bceSAndroid Build Coastguard Worker     }
1423*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1424*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1425*35238bceSAndroid Build Coastguard Worker     {
1426*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1427*35238bceSAndroid Build Coastguard Worker 
1428*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1429*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage;
1430*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1431*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second "
1432*35238bceSAndroid Build Coastguard Worker                "(occluded) is rendered repeatedly"
1433*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1434*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered"
1435*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1436*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The occluded quad has a dynamic offset applied to gl_FragDepth"
1437*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1438*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1439*35238bceSAndroid Build Coastguard Worker             << "The time per culled pixel is estimated from the rate of change of rendering time as a function of "
1440*35238bceSAndroid Build Coastguard Worker                "workload"
1441*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1442*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1443*35238bceSAndroid Build Coastguard Worker     }
1444*35238bceSAndroid Build Coastguard Worker };
1445*35238bceSAndroid Build Coastguard Worker 
1446*35238bceSAndroid Build Coastguard Worker // Culling speed with slightly less trivial geometry
1447*35238bceSAndroid Build Coastguard Worker class OccludingGeometryComplexityCostCase : public RenderCountCase
1448*35238bceSAndroid Build Coastguard Worker {
1449*35238bceSAndroid Build Coastguard Worker public:
OccludingGeometryComplexityCostCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc,int resolution,float xyNoise,float zNoise)1450*35238bceSAndroid Build Coastguard Worker     OccludingGeometryComplexityCostCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1451*35238bceSAndroid Build Coastguard Worker                                         const char *desc, int resolution, float xyNoise, float zNoise)
1452*35238bceSAndroid Build Coastguard Worker         : RenderCountCase(testCtx, renderCtx, name, desc)
1453*35238bceSAndroid Build Coastguard Worker         , m_resolution(resolution)
1454*35238bceSAndroid Build Coastguard Worker         , m_xyNoise(xyNoise)
1455*35238bceSAndroid Build Coastguard Worker         , m_zNoise(zNoise)
1456*35238bceSAndroid Build Coastguard Worker     {
1457*35238bceSAndroid Build Coastguard Worker     }
1458*35238bceSAndroid Build Coastguard Worker 
~OccludingGeometryComplexityCostCase(void)1459*35238bceSAndroid Build Coastguard Worker     ~OccludingGeometryComplexityCostCase(void)
1460*35238bceSAndroid Build Coastguard Worker     {
1461*35238bceSAndroid Build Coastguard Worker     }
1462*35238bceSAndroid Build Coastguard Worker 
1463*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1464*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1465*35238bceSAndroid Build Coastguard Worker     {
1466*35238bceSAndroid Build Coastguard Worker         return ObjectData(Utils::getBaseShader(), Utils::getFullScreenGrid(m_resolution,
1467*35238bceSAndroid Build Coastguard Worker                                                                            deInt32Hash(deStringHash(getName())) ^
1468*35238bceSAndroid Build Coastguard Worker                                                                                m_testCtx.getCommandLine().getBaseSeed(),
1469*35238bceSAndroid Build Coastguard Worker                                                                            0.2f, m_zNoise, m_xyNoise));
1470*35238bceSAndroid Build Coastguard Worker     }
1471*35238bceSAndroid Build Coastguard Worker 
genOccludedGeometry(void) const1472*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1473*35238bceSAndroid Build Coastguard Worker     {
1474*35238bceSAndroid Build Coastguard Worker         return Utils::variableQuad(0.8f);
1475*35238bceSAndroid Build Coastguard Worker     }
1476*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1477*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1478*35238bceSAndroid Build Coastguard Worker     {
1479*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1480*35238bceSAndroid Build Coastguard Worker 
1481*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1482*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage;
1483*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1484*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of an occluding grid and an occluded fullsceen quad. The occluding geometry is "
1485*35238bceSAndroid Build Coastguard Worker                "rendered once, the occluded one is rendered repeatedly"
1486*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1487*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered"
1488*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1489*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1490*35238bceSAndroid Build Coastguard Worker             << "The time per culled pixel is estimated from the rate of change of rendering time as a function of "
1491*35238bceSAndroid Build Coastguard Worker                "workload"
1492*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1493*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1494*35238bceSAndroid Build Coastguard Worker     }
1495*35238bceSAndroid Build Coastguard Worker 
1496*35238bceSAndroid Build Coastguard Worker     const int m_resolution;
1497*35238bceSAndroid Build Coastguard Worker     const float m_xyNoise;
1498*35238bceSAndroid Build Coastguard Worker     const float m_zNoise;
1499*35238bceSAndroid Build Coastguard Worker };
1500*35238bceSAndroid Build Coastguard Worker 
1501*35238bceSAndroid Build Coastguard Worker // Cases with varying workloads in the fragment shader
1502*35238bceSAndroid Build Coastguard Worker class FragmentWorkloadCullCase : public RelativeChangeCase
1503*35238bceSAndroid Build Coastguard Worker {
1504*35238bceSAndroid Build Coastguard Worker public:
1505*35238bceSAndroid Build Coastguard Worker     FragmentWorkloadCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name, const char *desc);
~FragmentWorkloadCullCase(void)1506*35238bceSAndroid Build Coastguard Worker     virtual ~FragmentWorkloadCullCase(void)
1507*35238bceSAndroid Build Coastguard Worker     {
1508*35238bceSAndroid Build Coastguard Worker     }
1509*35238bceSAndroid Build Coastguard Worker 
1510*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1511*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1512*35238bceSAndroid Build Coastguard Worker     {
1513*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuad(0.2f);
1514*35238bceSAndroid Build Coastguard Worker     }
1515*35238bceSAndroid Build Coastguard Worker 
1516*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void);
1517*35238bceSAndroid Build Coastguard Worker };
1518*35238bceSAndroid Build Coastguard Worker 
FragmentWorkloadCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1519*35238bceSAndroid Build Coastguard Worker FragmentWorkloadCullCase::FragmentWorkloadCullCase(TestContext &testCtx, const RenderContext &renderCtx,
1520*35238bceSAndroid Build Coastguard Worker                                                    const char *name, const char *desc)
1521*35238bceSAndroid Build Coastguard Worker     : RelativeChangeCase(testCtx, renderCtx, name, desc)
1522*35238bceSAndroid Build Coastguard Worker {
1523*35238bceSAndroid Build Coastguard Worker }
1524*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1525*35238bceSAndroid Build Coastguard Worker void FragmentWorkloadCullCase::logDescription(void)
1526*35238bceSAndroid Build Coastguard Worker {
1527*35238bceSAndroid Build Coastguard Worker     TestLog &log = m_testCtx.getLog();
1528*35238bceSAndroid Build Coastguard Worker 
1529*35238bceSAndroid Build Coastguard Worker     log << TestLog::Section("Description", "Test description");
1530*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "Testing effects of culled fragment workload on render time" << TestLog::EndMessage;
1531*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message
1532*35238bceSAndroid Build Coastguard Worker         << "Geometry consists of two fullsceen quads. The first (occluding) quad uses a trivial shader,"
1533*35238bceSAndroid Build Coastguard Worker            "the second (occluded) contains significant fragment shader work"
1534*35238bceSAndroid Build Coastguard Worker         << TestLog::EndMessage;
1535*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message
1536*35238bceSAndroid Build Coastguard Worker         << "Workload indicates the number of iterations of unused work done in the occluded quad's fragment shader"
1537*35238bceSAndroid Build Coastguard Worker         << TestLog::EndMessage;
1538*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared"
1539*35238bceSAndroid Build Coastguard Worker         << TestLog::EndMessage;
1540*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message
1541*35238bceSAndroid Build Coastguard Worker         << "Successfull early Z-testing should result in no correlation between workload and render time"
1542*35238bceSAndroid Build Coastguard Worker         << TestLog::EndMessage;
1543*35238bceSAndroid Build Coastguard Worker     log << TestLog::EndSection;
1544*35238bceSAndroid Build Coastguard Worker }
1545*35238bceSAndroid Build Coastguard Worker 
1546*35238bceSAndroid Build Coastguard Worker // Additional workload consists of texture lookups
1547*35238bceSAndroid Build Coastguard Worker class FragmentTextureWorkloadCullCase : public FragmentWorkloadCullCase
1548*35238bceSAndroid Build Coastguard Worker {
1549*35238bceSAndroid Build Coastguard Worker public:
1550*35238bceSAndroid Build Coastguard Worker     FragmentTextureWorkloadCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1551*35238bceSAndroid Build Coastguard Worker                                     const char *desc);
~FragmentTextureWorkloadCullCase(void)1552*35238bceSAndroid Build Coastguard Worker     virtual ~FragmentTextureWorkloadCullCase(void)
1553*35238bceSAndroid Build Coastguard Worker     {
1554*35238bceSAndroid Build Coastguard Worker     }
1555*35238bceSAndroid Build Coastguard Worker 
1556*35238bceSAndroid Build Coastguard Worker     virtual void init(void);
1557*35238bceSAndroid Build Coastguard Worker     virtual void deinit(void);
1558*35238bceSAndroid Build Coastguard Worker 
1559*35238bceSAndroid Build Coastguard Worker private:
1560*35238bceSAndroid Build Coastguard Worker     typedef MovePtr<glu::Texture> TexPtr;
1561*35238bceSAndroid Build Coastguard Worker 
genOccludedGeometry(void) const1562*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1563*35238bceSAndroid Build Coastguard Worker     {
1564*35238bceSAndroid Build Coastguard Worker         return ObjectData(Utils::getTextureWorkloadShader(), Utils::getFullscreenQuad(0.8f));
1565*35238bceSAndroid Build Coastguard Worker     }
1566*35238bceSAndroid Build Coastguard Worker 
1567*35238bceSAndroid Build Coastguard Worker     TexPtr m_texture;
1568*35238bceSAndroid Build Coastguard Worker };
1569*35238bceSAndroid Build Coastguard Worker 
FragmentTextureWorkloadCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1570*35238bceSAndroid Build Coastguard Worker FragmentTextureWorkloadCullCase::FragmentTextureWorkloadCullCase(TestContext &testCtx, const RenderContext &renderCtx,
1571*35238bceSAndroid Build Coastguard Worker                                                                  const char *name, const char *desc)
1572*35238bceSAndroid Build Coastguard Worker     : FragmentWorkloadCullCase(testCtx, renderCtx, name, desc)
1573*35238bceSAndroid Build Coastguard Worker {
1574*35238bceSAndroid Build Coastguard Worker }
1575*35238bceSAndroid Build Coastguard Worker 
init(void)1576*35238bceSAndroid Build Coastguard Worker void FragmentTextureWorkloadCullCase::init(void)
1577*35238bceSAndroid Build Coastguard Worker {
1578*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_renderCtx.getFunctions();
1579*35238bceSAndroid Build Coastguard Worker     const int size           = 128;
1580*35238bceSAndroid Build Coastguard Worker     const vector<uint8_t> data(size * size * 4, 255);
1581*35238bceSAndroid Build Coastguard Worker 
1582*35238bceSAndroid Build Coastguard Worker     m_texture = MovePtr<glu::Texture>(new glu::Texture(gl));
1583*35238bceSAndroid Build Coastguard Worker 
1584*35238bceSAndroid Build Coastguard Worker     gl.bindTexture(GL_TEXTURE_2D, m_texture);
1585*35238bceSAndroid Build Coastguard Worker     gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
1586*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1587*35238bceSAndroid Build Coastguard Worker     gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1588*35238bceSAndroid Build Coastguard Worker }
1589*35238bceSAndroid Build Coastguard Worker 
deinit(void)1590*35238bceSAndroid Build Coastguard Worker void FragmentTextureWorkloadCullCase::deinit(void)
1591*35238bceSAndroid Build Coastguard Worker {
1592*35238bceSAndroid Build Coastguard Worker     m_texture.clear();
1593*35238bceSAndroid Build Coastguard Worker }
1594*35238bceSAndroid Build Coastguard Worker 
1595*35238bceSAndroid Build Coastguard Worker // Additional workload consists of arithmetic
1596*35238bceSAndroid Build Coastguard Worker class FragmentArithmeticWorkloadCullCase : public FragmentWorkloadCullCase
1597*35238bceSAndroid Build Coastguard Worker {
1598*35238bceSAndroid Build Coastguard Worker public:
FragmentArithmeticWorkloadCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1599*35238bceSAndroid Build Coastguard Worker     FragmentArithmeticWorkloadCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1600*35238bceSAndroid Build Coastguard Worker                                        const char *desc)
1601*35238bceSAndroid Build Coastguard Worker         : FragmentWorkloadCullCase(testCtx, renderCtx, name, desc)
1602*35238bceSAndroid Build Coastguard Worker     {
1603*35238bceSAndroid Build Coastguard Worker     }
~FragmentArithmeticWorkloadCullCase(void)1604*35238bceSAndroid Build Coastguard Worker     virtual ~FragmentArithmeticWorkloadCullCase(void)
1605*35238bceSAndroid Build Coastguard Worker     {
1606*35238bceSAndroid Build Coastguard Worker     }
1607*35238bceSAndroid Build Coastguard Worker 
1608*35238bceSAndroid Build Coastguard Worker private:
genOccludedGeometry(void) const1609*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1610*35238bceSAndroid Build Coastguard Worker     {
1611*35238bceSAndroid Build Coastguard Worker         return ObjectData(Utils::getArithmeticWorkloadShader(), Utils::getFullscreenQuad(0.8f));
1612*35238bceSAndroid Build Coastguard Worker     }
1613*35238bceSAndroid Build Coastguard Worker };
1614*35238bceSAndroid Build Coastguard Worker 
1615*35238bceSAndroid Build Coastguard Worker // Contains dynamicly unused discard after a series of calculations
1616*35238bceSAndroid Build Coastguard Worker class FragmentDiscardArithmeticWorkloadCullCase : public FragmentWorkloadCullCase
1617*35238bceSAndroid Build Coastguard Worker {
1618*35238bceSAndroid Build Coastguard Worker public:
FragmentDiscardArithmeticWorkloadCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1619*35238bceSAndroid Build Coastguard Worker     FragmentDiscardArithmeticWorkloadCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1620*35238bceSAndroid Build Coastguard Worker                                               const char *desc)
1621*35238bceSAndroid Build Coastguard Worker         : FragmentWorkloadCullCase(testCtx, renderCtx, name, desc)
1622*35238bceSAndroid Build Coastguard Worker     {
1623*35238bceSAndroid Build Coastguard Worker     }
1624*35238bceSAndroid Build Coastguard Worker 
~FragmentDiscardArithmeticWorkloadCullCase(void)1625*35238bceSAndroid Build Coastguard Worker     virtual ~FragmentDiscardArithmeticWorkloadCullCase(void)
1626*35238bceSAndroid Build Coastguard Worker     {
1627*35238bceSAndroid Build Coastguard Worker     }
1628*35238bceSAndroid Build Coastguard Worker 
1629*35238bceSAndroid Build Coastguard Worker private:
genOccludedGeometry(void) const1630*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1631*35238bceSAndroid Build Coastguard Worker     {
1632*35238bceSAndroid Build Coastguard Worker         return ObjectData(Utils::getArithmeticWorkloadDiscardShader(), Utils::getFullscreenQuad(0.8f));
1633*35238bceSAndroid Build Coastguard Worker     }
1634*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1635*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1636*35238bceSAndroid Build Coastguard Worker     {
1637*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1638*35238bceSAndroid Build Coastguard Worker 
1639*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1640*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing effects of culled fragment workload on render time" << TestLog::EndMessage;
1641*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1642*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullsceen quads. The first (occluding) quad uses a trivial shader,"
1643*35238bceSAndroid Build Coastguard Worker                "the second (occluded) contains significant fragment shader work and a discard that is never triggers "
1644*35238bceSAndroid Build Coastguard Worker                "but has a dynamic condition"
1645*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1646*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1647*35238bceSAndroid Build Coastguard Worker             << "Workload indicates the number of iterations of unused work done in the occluded quad's fragment shader"
1648*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1649*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared"
1650*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1651*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1652*35238bceSAndroid Build Coastguard Worker             << "Successfull early Z-testing should result in no correlation between workload and render time"
1653*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1654*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1655*35238bceSAndroid Build Coastguard Worker     }
1656*35238bceSAndroid Build Coastguard Worker };
1657*35238bceSAndroid Build Coastguard Worker 
1658*35238bceSAndroid Build Coastguard Worker // Discards fragments from the occluder in a grid pattern
1659*35238bceSAndroid Build Coastguard Worker class PartialOccluderDiscardCullCase : public RelativeChangeCase
1660*35238bceSAndroid Build Coastguard Worker {
1661*35238bceSAndroid Build Coastguard Worker public:
PartialOccluderDiscardCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc,int gridsize)1662*35238bceSAndroid Build Coastguard Worker     PartialOccluderDiscardCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1663*35238bceSAndroid Build Coastguard Worker                                    const char *desc, int gridsize)
1664*35238bceSAndroid Build Coastguard Worker         : RelativeChangeCase(testCtx, renderCtx, name, desc)
1665*35238bceSAndroid Build Coastguard Worker         , m_gridsize(gridsize)
1666*35238bceSAndroid Build Coastguard Worker     {
1667*35238bceSAndroid Build Coastguard Worker     }
~PartialOccluderDiscardCullCase(void)1668*35238bceSAndroid Build Coastguard Worker     virtual ~PartialOccluderDiscardCullCase(void)
1669*35238bceSAndroid Build Coastguard Worker     {
1670*35238bceSAndroid Build Coastguard Worker     }
1671*35238bceSAndroid Build Coastguard Worker 
1672*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1673*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1674*35238bceSAndroid Build Coastguard Worker     {
1675*35238bceSAndroid Build Coastguard Worker         return Utils::quadWith(Utils::getGridDiscardShader(m_gridsize), 0.2f);
1676*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1677*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1678*35238bceSAndroid Build Coastguard Worker     {
1679*35238bceSAndroid Build Coastguard Worker         return Utils::slowQuad(0.8f);
1680*35238bceSAndroid Build Coastguard Worker     }
1681*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1682*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1683*35238bceSAndroid Build Coastguard Worker     {
1684*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1685*35238bceSAndroid Build Coastguard Worker 
1686*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1687*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing effects of partially discarded occluder on rendering time"
1688*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1689*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1690*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullsceen quads. The first (occluding) quad discards half the "
1691*35238bceSAndroid Build Coastguard Worker                "fragments in a grid pattern, the second (partially occluded) contains significant fragment shader work"
1692*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1693*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1694*35238bceSAndroid Build Coastguard Worker             << "Workload indicates the number of iterations of unused work done in the occluded quad's fragment shader"
1695*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1696*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared"
1697*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1698*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Successfull early Z-testing should result in depth testing halving the render time"
1699*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1700*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1701*35238bceSAndroid Build Coastguard Worker     }
1702*35238bceSAndroid Build Coastguard Worker 
1703*35238bceSAndroid Build Coastguard Worker     const int m_gridsize;
1704*35238bceSAndroid Build Coastguard Worker };
1705*35238bceSAndroid Build Coastguard Worker 
1706*35238bceSAndroid Build Coastguard Worker // Trivial occluder covering part of screen
1707*35238bceSAndroid Build Coastguard Worker class PartialOccluderCullCase : public RelativeChangeCase
1708*35238bceSAndroid Build Coastguard Worker {
1709*35238bceSAndroid Build Coastguard Worker public:
PartialOccluderCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc,float coverage)1710*35238bceSAndroid Build Coastguard Worker     PartialOccluderCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name, const char *desc,
1711*35238bceSAndroid Build Coastguard Worker                             float coverage)
1712*35238bceSAndroid Build Coastguard Worker         : RelativeChangeCase(testCtx, renderCtx, name, desc)
1713*35238bceSAndroid Build Coastguard Worker         , m_coverage(coverage)
1714*35238bceSAndroid Build Coastguard Worker     {
1715*35238bceSAndroid Build Coastguard Worker     }
~PartialOccluderCullCase(void)1716*35238bceSAndroid Build Coastguard Worker     ~PartialOccluderCullCase(void)
1717*35238bceSAndroid Build Coastguard Worker     {
1718*35238bceSAndroid Build Coastguard Worker     }
1719*35238bceSAndroid Build Coastguard Worker 
1720*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1721*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1722*35238bceSAndroid Build Coastguard Worker     {
1723*35238bceSAndroid Build Coastguard Worker         return ObjectData(Utils::getBaseShader(), Utils::getPartScreenQuad(m_coverage, 0.2f));
1724*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1725*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1726*35238bceSAndroid Build Coastguard Worker     {
1727*35238bceSAndroid Build Coastguard Worker         return Utils::slowQuad(0.8f);
1728*35238bceSAndroid Build Coastguard Worker     }
1729*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1730*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1731*35238bceSAndroid Build Coastguard Worker     {
1732*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1733*35238bceSAndroid Build Coastguard Worker 
1734*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1735*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing effects of partial occluder on rendering time" << TestLog::EndMessage;
1736*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Geometry consists of two quads. The first (occluding) quad covers "
1737*35238bceSAndroid Build Coastguard Worker             << m_coverage * 100.0f
1738*35238bceSAndroid Build Coastguard Worker             << "% of the screen, while the second (partially occluded, fullscreen) contains significant fragment "
1739*35238bceSAndroid Build Coastguard Worker                "shader work"
1740*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1741*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1742*35238bceSAndroid Build Coastguard Worker             << "Workload indicates the number of iterations of unused work done in the occluded quad's fragment shader"
1743*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1744*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared"
1745*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1746*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1747*35238bceSAndroid Build Coastguard Worker             << "Successfull early Z-testing should result in render time increasing proportionally with unoccluded area"
1748*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1749*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1750*35238bceSAndroid Build Coastguard Worker     }
1751*35238bceSAndroid Build Coastguard Worker 
1752*35238bceSAndroid Build Coastguard Worker     const float m_coverage;
1753*35238bceSAndroid Build Coastguard Worker };
1754*35238bceSAndroid Build Coastguard Worker 
1755*35238bceSAndroid Build Coastguard Worker // Constant offset to frag depth in occluder
1756*35238bceSAndroid Build Coastguard Worker class StaticOccluderFragDepthCullCase : public RelativeChangeCase
1757*35238bceSAndroid Build Coastguard Worker {
1758*35238bceSAndroid Build Coastguard Worker public:
StaticOccluderFragDepthCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1759*35238bceSAndroid Build Coastguard Worker     StaticOccluderFragDepthCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1760*35238bceSAndroid Build Coastguard Worker                                     const char *desc)
1761*35238bceSAndroid Build Coastguard Worker         : RelativeChangeCase(testCtx, renderCtx, name, desc)
1762*35238bceSAndroid Build Coastguard Worker     {
1763*35238bceSAndroid Build Coastguard Worker     }
1764*35238bceSAndroid Build Coastguard Worker 
~StaticOccluderFragDepthCullCase(void)1765*35238bceSAndroid Build Coastguard Worker     ~StaticOccluderFragDepthCullCase(void)
1766*35238bceSAndroid Build Coastguard Worker     {
1767*35238bceSAndroid Build Coastguard Worker     }
1768*35238bceSAndroid Build Coastguard Worker 
1769*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1770*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1771*35238bceSAndroid Build Coastguard Worker     {
1772*35238bceSAndroid Build Coastguard Worker         return Utils::quadWith(Utils::getStaticFragDepthFragmentShader(), 0.2f);
1773*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1774*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1775*35238bceSAndroid Build Coastguard Worker     {
1776*35238bceSAndroid Build Coastguard Worker         return Utils::slowQuad(0.8f);
1777*35238bceSAndroid Build Coastguard Worker     }
1778*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1779*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1780*35238bceSAndroid Build Coastguard Worker     {
1781*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1782*35238bceSAndroid Build Coastguard Worker 
1783*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1784*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing effects of non-default frag depth on culling efficiency"
1785*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1786*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1787*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullscreen quads. The first (occluding) quad is trivial, while the second "
1788*35238bceSAndroid Build Coastguard Worker                "(occluded) contains significant fragment shader work"
1789*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1790*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1791*35238bceSAndroid Build Coastguard Worker             << "Workload indicates the number of iterations of unused work done in the occluded quad's fragment shader"
1792*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1793*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The occluder quad has a static offset applied to gl_FragDepth"
1794*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1795*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared"
1796*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1797*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1798*35238bceSAndroid Build Coastguard Worker             << "Successfull early Z-testing should result in no correlation between workload and render time"
1799*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1800*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1801*35238bceSAndroid Build Coastguard Worker     }
1802*35238bceSAndroid Build Coastguard Worker };
1803*35238bceSAndroid Build Coastguard Worker 
1804*35238bceSAndroid Build Coastguard Worker // Dynamic offset to frag depth in occluder
1805*35238bceSAndroid Build Coastguard Worker class DynamicOccluderFragDepthCullCase : public RelativeChangeCase
1806*35238bceSAndroid Build Coastguard Worker {
1807*35238bceSAndroid Build Coastguard Worker public:
DynamicOccluderFragDepthCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1808*35238bceSAndroid Build Coastguard Worker     DynamicOccluderFragDepthCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1809*35238bceSAndroid Build Coastguard Worker                                      const char *desc)
1810*35238bceSAndroid Build Coastguard Worker         : RelativeChangeCase(testCtx, renderCtx, name, desc)
1811*35238bceSAndroid Build Coastguard Worker     {
1812*35238bceSAndroid Build Coastguard Worker     }
1813*35238bceSAndroid Build Coastguard Worker 
~DynamicOccluderFragDepthCullCase(void)1814*35238bceSAndroid Build Coastguard Worker     ~DynamicOccluderFragDepthCullCase(void)
1815*35238bceSAndroid Build Coastguard Worker     {
1816*35238bceSAndroid Build Coastguard Worker     }
1817*35238bceSAndroid Build Coastguard Worker 
1818*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1819*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1820*35238bceSAndroid Build Coastguard Worker     {
1821*35238bceSAndroid Build Coastguard Worker         return Utils::quadWith(Utils::getDynamicFragDepthFragmentShader(), 0.2f);
1822*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1823*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1824*35238bceSAndroid Build Coastguard Worker     {
1825*35238bceSAndroid Build Coastguard Worker         return Utils::slowQuad(0.8f);
1826*35238bceSAndroid Build Coastguard Worker     }
1827*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1828*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1829*35238bceSAndroid Build Coastguard Worker     {
1830*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1831*35238bceSAndroid Build Coastguard Worker 
1832*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1833*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing effects of non-default frag depth on culling efficiency"
1834*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1835*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1836*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullscreen quads. The first (occluding) quad is trivial, while the second "
1837*35238bceSAndroid Build Coastguard Worker                "(occluded) contains significant fragment shader work"
1838*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1839*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1840*35238bceSAndroid Build Coastguard Worker             << "Workload indicates the number of iterations of unused work done in the occluded quad's fragment shader"
1841*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1842*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The occluder quad has a dynamic offset applied to gl_FragDepth"
1843*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1844*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared"
1845*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1846*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1847*35238bceSAndroid Build Coastguard Worker             << "Successfull early Z-testing should result in no correlation between workload and render time"
1848*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1849*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1850*35238bceSAndroid Build Coastguard Worker     }
1851*35238bceSAndroid Build Coastguard Worker };
1852*35238bceSAndroid Build Coastguard Worker 
1853*35238bceSAndroid Build Coastguard Worker // Constant offset to frag depth in occluded
1854*35238bceSAndroid Build Coastguard Worker class StaticOccludedFragDepthCullCase : public RelativeChangeCase
1855*35238bceSAndroid Build Coastguard Worker {
1856*35238bceSAndroid Build Coastguard Worker public:
StaticOccludedFragDepthCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1857*35238bceSAndroid Build Coastguard Worker     StaticOccludedFragDepthCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1858*35238bceSAndroid Build Coastguard Worker                                     const char *desc)
1859*35238bceSAndroid Build Coastguard Worker         : RelativeChangeCase(testCtx, renderCtx, name, desc)
1860*35238bceSAndroid Build Coastguard Worker     {
1861*35238bceSAndroid Build Coastguard Worker     }
1862*35238bceSAndroid Build Coastguard Worker 
~StaticOccludedFragDepthCullCase(void)1863*35238bceSAndroid Build Coastguard Worker     ~StaticOccludedFragDepthCullCase(void)
1864*35238bceSAndroid Build Coastguard Worker     {
1865*35238bceSAndroid Build Coastguard Worker     }
1866*35238bceSAndroid Build Coastguard Worker 
1867*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1868*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1869*35238bceSAndroid Build Coastguard Worker     {
1870*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuad(0.2f);
1871*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1872*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1873*35238bceSAndroid Build Coastguard Worker     {
1874*35238bceSAndroid Build Coastguard Worker         return Utils::quadWith(Utils::getStaticFragDepthArithmeticWorkloadFragmentShader(), 0.2f);
1875*35238bceSAndroid Build Coastguard Worker     }
1876*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1877*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1878*35238bceSAndroid Build Coastguard Worker     {
1879*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1880*35238bceSAndroid Build Coastguard Worker 
1881*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1882*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing effects of non-default frag depth on rendering time" << TestLog::EndMessage;
1883*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1884*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullscreen quads. The first (occluding) quad is trivial, while the second "
1885*35238bceSAndroid Build Coastguard Worker                "(occluded) contains significant fragment shader work"
1886*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1887*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1888*35238bceSAndroid Build Coastguard Worker             << "Workload indicates the number of iterations of unused work done in the occluded quad's fragment shader"
1889*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1890*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The occluded quad has a static offset applied to gl_FragDepth"
1891*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1892*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared"
1893*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1894*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1895*35238bceSAndroid Build Coastguard Worker             << "Successfull early Z-testing should result in no correlation between workload and render time"
1896*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1897*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1898*35238bceSAndroid Build Coastguard Worker     }
1899*35238bceSAndroid Build Coastguard Worker };
1900*35238bceSAndroid Build Coastguard Worker 
1901*35238bceSAndroid Build Coastguard Worker // Dynamic offset to frag depth in occluded
1902*35238bceSAndroid Build Coastguard Worker class DynamicOccludedFragDepthCullCase : public RelativeChangeCase
1903*35238bceSAndroid Build Coastguard Worker {
1904*35238bceSAndroid Build Coastguard Worker public:
DynamicOccludedFragDepthCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1905*35238bceSAndroid Build Coastguard Worker     DynamicOccludedFragDepthCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name,
1906*35238bceSAndroid Build Coastguard Worker                                      const char *desc)
1907*35238bceSAndroid Build Coastguard Worker         : RelativeChangeCase(testCtx, renderCtx, name, desc)
1908*35238bceSAndroid Build Coastguard Worker     {
1909*35238bceSAndroid Build Coastguard Worker     }
1910*35238bceSAndroid Build Coastguard Worker 
~DynamicOccludedFragDepthCullCase(void)1911*35238bceSAndroid Build Coastguard Worker     ~DynamicOccludedFragDepthCullCase(void)
1912*35238bceSAndroid Build Coastguard Worker     {
1913*35238bceSAndroid Build Coastguard Worker     }
1914*35238bceSAndroid Build Coastguard Worker 
1915*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1916*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1917*35238bceSAndroid Build Coastguard Worker     {
1918*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuad(0.2f);
1919*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1920*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1921*35238bceSAndroid Build Coastguard Worker     {
1922*35238bceSAndroid Build Coastguard Worker         return Utils::quadWith(Utils::getDynamicFragDepthArithmeticWorkloadFragmentShader(), 0.2f);
1923*35238bceSAndroid Build Coastguard Worker     }
1924*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1925*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1926*35238bceSAndroid Build Coastguard Worker     {
1927*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1928*35238bceSAndroid Build Coastguard Worker 
1929*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1930*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing effects of non-default frag depth on rendering time" << TestLog::EndMessage;
1931*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1932*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullscreen quads. The first (occluding) quad is trivial, while the second "
1933*35238bceSAndroid Build Coastguard Worker                "(occluded) contains significant fragment shader work"
1934*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1935*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1936*35238bceSAndroid Build Coastguard Worker             << "Workload indicates the number of iterations of unused work done in the occluded quad's fragment shader"
1937*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1938*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The occluded quad has a dynamic offset applied to gl_FragDepth"
1939*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1940*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared"
1941*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1942*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1943*35238bceSAndroid Build Coastguard Worker             << "Successfull early Z-testing should result in no correlation between workload and render time"
1944*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1945*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1946*35238bceSAndroid Build Coastguard Worker     }
1947*35238bceSAndroid Build Coastguard Worker };
1948*35238bceSAndroid Build Coastguard Worker 
1949*35238bceSAndroid Build Coastguard Worker // Dynamic offset to frag depth in occluded
1950*35238bceSAndroid Build Coastguard Worker class ReversedDepthOrderCullCase : public RelativeChangeCase
1951*35238bceSAndroid Build Coastguard Worker {
1952*35238bceSAndroid Build Coastguard Worker public:
ReversedDepthOrderCullCase(TestContext & testCtx,const RenderContext & renderCtx,const char * name,const char * desc)1953*35238bceSAndroid Build Coastguard Worker     ReversedDepthOrderCullCase(TestContext &testCtx, const RenderContext &renderCtx, const char *name, const char *desc)
1954*35238bceSAndroid Build Coastguard Worker         : RelativeChangeCase(testCtx, renderCtx, name, desc)
1955*35238bceSAndroid Build Coastguard Worker     {
1956*35238bceSAndroid Build Coastguard Worker     }
1957*35238bceSAndroid Build Coastguard Worker 
~ReversedDepthOrderCullCase(void)1958*35238bceSAndroid Build Coastguard Worker     ~ReversedDepthOrderCullCase(void)
1959*35238bceSAndroid Build Coastguard Worker     {
1960*35238bceSAndroid Build Coastguard Worker     }
1961*35238bceSAndroid Build Coastguard Worker 
1962*35238bceSAndroid Build Coastguard Worker private:
genOccluderGeometry(void) const1963*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccluderGeometry(void) const
1964*35238bceSAndroid Build Coastguard Worker     {
1965*35238bceSAndroid Build Coastguard Worker         return Utils::fastQuad(0.2f);
1966*35238bceSAndroid Build Coastguard Worker     }
genOccludedGeometry(void) const1967*35238bceSAndroid Build Coastguard Worker     virtual ObjectData genOccludedGeometry(void) const
1968*35238bceSAndroid Build Coastguard Worker     {
1969*35238bceSAndroid Build Coastguard Worker         return Utils::slowQuad(0.8f);
1970*35238bceSAndroid Build Coastguard Worker     }
1971*35238bceSAndroid Build Coastguard Worker 
logDescription(void)1972*35238bceSAndroid Build Coastguard Worker     virtual void logDescription(void)
1973*35238bceSAndroid Build Coastguard Worker     {
1974*35238bceSAndroid Build Coastguard Worker         TestLog &log = m_testCtx.getLog();
1975*35238bceSAndroid Build Coastguard Worker 
1976*35238bceSAndroid Build Coastguard Worker         log << TestLog::Section("Description", "Test description");
1977*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "Testing effects of of back first rendering order on culling efficiency"
1978*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1979*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1980*35238bceSAndroid Build Coastguard Worker             << "Geometry consists of two fullscreen quads. The second (occluding) quad is trivial, while the first "
1981*35238bceSAndroid Build Coastguard Worker                "(occluded) contains significant fragment shader work"
1982*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1983*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1984*35238bceSAndroid Build Coastguard Worker             << "Workload indicates the number of iterations of unused work done in the occluded quad's fragment shader"
1985*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1986*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared"
1987*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1988*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message
1989*35238bceSAndroid Build Coastguard Worker             << "Successfull early Z-testing should result in no correlation between workload and render time"
1990*35238bceSAndroid Build Coastguard Worker             << TestLog::EndMessage;
1991*35238bceSAndroid Build Coastguard Worker         log << TestLog::EndSection;
1992*35238bceSAndroid Build Coastguard Worker     }
1993*35238bceSAndroid Build Coastguard Worker 
1994*35238bceSAndroid Build Coastguard Worker     // Rendering order of occluder & occluded is reversed, otherwise identical to parent version
renderSample(const RenderData & occluder,const RenderData & occluded,int workload) const1995*35238bceSAndroid Build Coastguard Worker     Sample renderSample(const RenderData &occluder, const RenderData &occluded, int workload) const
1996*35238bceSAndroid Build Coastguard Worker     {
1997*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl = m_renderCtx.getFunctions();
1998*35238bceSAndroid Build Coastguard Worker         const GLuint program     = occluded.m_program.getProgram();
1999*35238bceSAndroid Build Coastguard Worker         Sample sample;
2000*35238bceSAndroid Build Coastguard Worker         uint64_t now  = 0;
2001*35238bceSAndroid Build Coastguard Worker         uint64_t prev = 0;
2002*35238bceSAndroid Build Coastguard Worker         uint8_t buffer[4];
2003*35238bceSAndroid Build Coastguard Worker 
2004*35238bceSAndroid Build Coastguard Worker         gl.useProgram(program);
2005*35238bceSAndroid Build Coastguard Worker         gl.uniform1i(gl.getUniformLocation(program, "u_iterations"), workload);
2006*35238bceSAndroid Build Coastguard Worker 
2007*35238bceSAndroid Build Coastguard Worker         // Warmup (this workload seems to reduce variation in following workloads)
2008*35238bceSAndroid Build Coastguard Worker         {
2009*35238bceSAndroid Build Coastguard Worker             gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
2010*35238bceSAndroid Build Coastguard Worker             gl.disable(GL_DEPTH_TEST);
2011*35238bceSAndroid Build Coastguard Worker 
2012*35238bceSAndroid Build Coastguard Worker             gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
2013*35238bceSAndroid Build Coastguard Worker         }
2014*35238bceSAndroid Build Coastguard Worker 
2015*35238bceSAndroid Build Coastguard Worker         // Null time
2016*35238bceSAndroid Build Coastguard Worker         {
2017*35238bceSAndroid Build Coastguard Worker             prev = deGetMicroseconds();
2018*35238bceSAndroid Build Coastguard Worker 
2019*35238bceSAndroid Build Coastguard Worker             gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
2020*35238bceSAndroid Build Coastguard Worker             gl.disable(GL_DEPTH_TEST);
2021*35238bceSAndroid Build Coastguard Worker 
2022*35238bceSAndroid Build Coastguard Worker             gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
2023*35238bceSAndroid Build Coastguard Worker 
2024*35238bceSAndroid Build Coastguard Worker             now = deGetMicroseconds();
2025*35238bceSAndroid Build Coastguard Worker 
2026*35238bceSAndroid Build Coastguard Worker             sample.nullTime = now - prev;
2027*35238bceSAndroid Build Coastguard Worker         }
2028*35238bceSAndroid Build Coastguard Worker 
2029*35238bceSAndroid Build Coastguard Worker         // Test time
2030*35238bceSAndroid Build Coastguard Worker         {
2031*35238bceSAndroid Build Coastguard Worker             prev = deGetMicroseconds();
2032*35238bceSAndroid Build Coastguard Worker 
2033*35238bceSAndroid Build Coastguard Worker             gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
2034*35238bceSAndroid Build Coastguard Worker             gl.enable(GL_DEPTH_TEST);
2035*35238bceSAndroid Build Coastguard Worker 
2036*35238bceSAndroid Build Coastguard Worker             render(occluded);
2037*35238bceSAndroid Build Coastguard Worker             render(occluder);
2038*35238bceSAndroid Build Coastguard Worker 
2039*35238bceSAndroid Build Coastguard Worker             gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
2040*35238bceSAndroid Build Coastguard Worker 
2041*35238bceSAndroid Build Coastguard Worker             now = deGetMicroseconds();
2042*35238bceSAndroid Build Coastguard Worker 
2043*35238bceSAndroid Build Coastguard Worker             sample.testTime = now - prev;
2044*35238bceSAndroid Build Coastguard Worker         }
2045*35238bceSAndroid Build Coastguard Worker 
2046*35238bceSAndroid Build Coastguard Worker         // Base time
2047*35238bceSAndroid Build Coastguard Worker         {
2048*35238bceSAndroid Build Coastguard Worker             prev = deGetMicroseconds();
2049*35238bceSAndroid Build Coastguard Worker 
2050*35238bceSAndroid Build Coastguard Worker             gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
2051*35238bceSAndroid Build Coastguard Worker             gl.disable(GL_DEPTH_TEST);
2052*35238bceSAndroid Build Coastguard Worker 
2053*35238bceSAndroid Build Coastguard Worker             render(occluded);
2054*35238bceSAndroid Build Coastguard Worker             render(occluder);
2055*35238bceSAndroid Build Coastguard Worker 
2056*35238bceSAndroid Build Coastguard Worker             gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
2057*35238bceSAndroid Build Coastguard Worker 
2058*35238bceSAndroid Build Coastguard Worker             now = deGetMicroseconds();
2059*35238bceSAndroid Build Coastguard Worker 
2060*35238bceSAndroid Build Coastguard Worker             sample.baseTime = now - prev;
2061*35238bceSAndroid Build Coastguard Worker         }
2062*35238bceSAndroid Build Coastguard Worker 
2063*35238bceSAndroid Build Coastguard Worker         sample.workload = 0;
2064*35238bceSAndroid Build Coastguard Worker 
2065*35238bceSAndroid Build Coastguard Worker         return sample;
2066*35238bceSAndroid Build Coastguard Worker     }
2067*35238bceSAndroid Build Coastguard Worker };
2068*35238bceSAndroid Build Coastguard Worker 
2069*35238bceSAndroid Build Coastguard Worker } // namespace
2070*35238bceSAndroid Build Coastguard Worker 
DepthTests(Context & context)2071*35238bceSAndroid Build Coastguard Worker DepthTests::DepthTests(Context &context) : TestCaseGroup(context, "depth", "Depth culling performance")
2072*35238bceSAndroid Build Coastguard Worker {
2073*35238bceSAndroid Build Coastguard Worker }
2074*35238bceSAndroid Build Coastguard Worker 
init(void)2075*35238bceSAndroid Build Coastguard Worker void DepthTests::init(void)
2076*35238bceSAndroid Build Coastguard Worker {
2077*35238bceSAndroid Build Coastguard Worker     TestContext &testCtx           = m_context.getTestContext();
2078*35238bceSAndroid Build Coastguard Worker     const RenderContext &renderCtx = m_context.getRenderContext();
2079*35238bceSAndroid Build Coastguard Worker 
2080*35238bceSAndroid Build Coastguard Worker     {
2081*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const cullEfficiencyGroup =
2082*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "cull_efficiency", "Fragment cull efficiency");
2083*35238bceSAndroid Build Coastguard Worker 
2084*35238bceSAndroid Build Coastguard Worker         addChild(cullEfficiencyGroup);
2085*35238bceSAndroid Build Coastguard Worker 
2086*35238bceSAndroid Build Coastguard Worker         {
2087*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "workload", "Workload");
2088*35238bceSAndroid Build Coastguard Worker 
2089*35238bceSAndroid Build Coastguard Worker             cullEfficiencyGroup->addChild(group);
2090*35238bceSAndroid Build Coastguard Worker 
2091*35238bceSAndroid Build Coastguard Worker             group->addChild(new FragmentTextureWorkloadCullCase(testCtx, renderCtx, "workload_texture",
2092*35238bceSAndroid Build Coastguard Worker                                                                 "Fragment shader with texture lookup workload"));
2093*35238bceSAndroid Build Coastguard Worker             group->addChild(new FragmentArithmeticWorkloadCullCase(testCtx, renderCtx, "workload_arithmetic",
2094*35238bceSAndroid Build Coastguard Worker                                                                    "Fragment shader with arithmetic workload"));
2095*35238bceSAndroid Build Coastguard Worker             group->addChild(new FragmentDiscardArithmeticWorkloadCullCase(
2096*35238bceSAndroid Build Coastguard Worker                 testCtx, renderCtx, "workload_arithmetic_discard",
2097*35238bceSAndroid Build Coastguard Worker                 "Fragment shader that may discard with arithmetic workload"));
2098*35238bceSAndroid Build Coastguard Worker         }
2099*35238bceSAndroid Build Coastguard Worker 
2100*35238bceSAndroid Build Coastguard Worker         {
2101*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "occluder_discard", "Discard");
2102*35238bceSAndroid Build Coastguard Worker 
2103*35238bceSAndroid Build Coastguard Worker             cullEfficiencyGroup->addChild(group);
2104*35238bceSAndroid Build Coastguard Worker 
2105*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_256",
2106*35238bceSAndroid Build Coastguard Worker                                                                "Parts of occluder geometry discarded", 256));
2107*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_128",
2108*35238bceSAndroid Build Coastguard Worker                                                                "Parts of occluder geometry discarded", 128));
2109*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_64",
2110*35238bceSAndroid Build Coastguard Worker                                                                "Parts of occluder geometry discarded", 64));
2111*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_32",
2112*35238bceSAndroid Build Coastguard Worker                                                                "Parts of occluder geometry discarded", 32));
2113*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_16",
2114*35238bceSAndroid Build Coastguard Worker                                                                "Parts of occluder geometry discarded", 16));
2115*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_8",
2116*35238bceSAndroid Build Coastguard Worker                                                                "Parts of occluder geometry discarded", 8));
2117*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_4",
2118*35238bceSAndroid Build Coastguard Worker                                                                "Parts of occluder geometry discarded", 4));
2119*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_2",
2120*35238bceSAndroid Build Coastguard Worker                                                                "Parts of occluder geometry discarded", 2));
2121*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_1",
2122*35238bceSAndroid Build Coastguard Worker                                                                "Parts of occluder geometry discarded", 1));
2123*35238bceSAndroid Build Coastguard Worker         }
2124*35238bceSAndroid Build Coastguard Worker 
2125*35238bceSAndroid Build Coastguard Worker         {
2126*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "partial_coverage", "Partial Coverage");
2127*35238bceSAndroid Build Coastguard Worker 
2128*35238bceSAndroid Build Coastguard Worker             cullEfficiencyGroup->addChild(group);
2129*35238bceSAndroid Build Coastguard Worker 
2130*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "100",
2131*35238bceSAndroid Build Coastguard Worker                                                         "Occluder covering only part of occluded geometry", 1.00f));
2132*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "099",
2133*35238bceSAndroid Build Coastguard Worker                                                         "Occluder covering only part of occluded geometry", 0.99f));
2134*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "095",
2135*35238bceSAndroid Build Coastguard Worker                                                         "Occluder covering only part of occluded geometry", 0.95f));
2136*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "090",
2137*35238bceSAndroid Build Coastguard Worker                                                         "Occluder covering only part of occluded geometry", 0.90f));
2138*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "080",
2139*35238bceSAndroid Build Coastguard Worker                                                         "Occluder covering only part of occluded geometry", 0.80f));
2140*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "070",
2141*35238bceSAndroid Build Coastguard Worker                                                         "Occluder covering only part of occluded geometry", 0.70f));
2142*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "050",
2143*35238bceSAndroid Build Coastguard Worker                                                         "Occluder covering only part of occluded geometry", 0.50f));
2144*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "025",
2145*35238bceSAndroid Build Coastguard Worker                                                         "Occluder covering only part of occluded geometry", 0.25f));
2146*35238bceSAndroid Build Coastguard Worker             group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "010",
2147*35238bceSAndroid Build Coastguard Worker                                                         "Occluder covering only part of occluded geometry", 0.10f));
2148*35238bceSAndroid Build Coastguard Worker         }
2149*35238bceSAndroid Build Coastguard Worker 
2150*35238bceSAndroid Build Coastguard Worker         {
2151*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "frag_depth", "Partial Coverage");
2152*35238bceSAndroid Build Coastguard Worker 
2153*35238bceSAndroid Build Coastguard Worker             cullEfficiencyGroup->addChild(group);
2154*35238bceSAndroid Build Coastguard Worker 
2155*35238bceSAndroid Build Coastguard Worker             group->addChild(new StaticOccluderFragDepthCullCase(testCtx, renderCtx, "occluder_static", ""));
2156*35238bceSAndroid Build Coastguard Worker             group->addChild(new DynamicOccluderFragDepthCullCase(testCtx, renderCtx, "occluder_dynamic", ""));
2157*35238bceSAndroid Build Coastguard Worker             group->addChild(new StaticOccludedFragDepthCullCase(testCtx, renderCtx, "occluded_static", ""));
2158*35238bceSAndroid Build Coastguard Worker             group->addChild(new DynamicOccludedFragDepthCullCase(testCtx, renderCtx, "occluded_dynamic", ""));
2159*35238bceSAndroid Build Coastguard Worker         }
2160*35238bceSAndroid Build Coastguard Worker 
2161*35238bceSAndroid Build Coastguard Worker         {
2162*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "order", "Rendering order");
2163*35238bceSAndroid Build Coastguard Worker 
2164*35238bceSAndroid Build Coastguard Worker             cullEfficiencyGroup->addChild(group);
2165*35238bceSAndroid Build Coastguard Worker 
2166*35238bceSAndroid Build Coastguard Worker             group->addChild(
2167*35238bceSAndroid Build Coastguard Worker                 new ReversedDepthOrderCullCase(testCtx, renderCtx, "reversed", "Back to front rendering order"));
2168*35238bceSAndroid Build Coastguard Worker         }
2169*35238bceSAndroid Build Coastguard Worker     }
2170*35238bceSAndroid Build Coastguard Worker 
2171*35238bceSAndroid Build Coastguard Worker     {
2172*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const testCostGroup =
2173*35238bceSAndroid Build Coastguard Worker             new tcu::TestCaseGroup(m_testCtx, "culled_pixel_cost", "Fragment cull efficiency");
2174*35238bceSAndroid Build Coastguard Worker 
2175*35238bceSAndroid Build Coastguard Worker         addChild(testCostGroup);
2176*35238bceSAndroid Build Coastguard Worker 
2177*35238bceSAndroid Build Coastguard Worker         {
2178*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const group =
2179*35238bceSAndroid Build Coastguard Worker                 new tcu::TestCaseGroup(m_testCtx, "gradient", "Gradients with small depth differences");
2180*35238bceSAndroid Build Coastguard Worker 
2181*35238bceSAndroid Build Coastguard Worker             testCostGroup->addChild(group);
2182*35238bceSAndroid Build Coastguard Worker 
2183*35238bceSAndroid Build Coastguard Worker             group->addChild(new BaseCostCase(testCtx, renderCtx, "flat", ""));
2184*35238bceSAndroid Build Coastguard Worker             group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_050", "", 0.50f));
2185*35238bceSAndroid Build Coastguard Worker             group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_010", "", 0.10f));
2186*35238bceSAndroid Build Coastguard Worker             group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_005", "", 0.05f));
2187*35238bceSAndroid Build Coastguard Worker             group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_002", "", 0.02f));
2188*35238bceSAndroid Build Coastguard Worker             group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_001", "", 0.01f));
2189*35238bceSAndroid Build Coastguard Worker         }
2190*35238bceSAndroid Build Coastguard Worker 
2191*35238bceSAndroid Build Coastguard Worker         {
2192*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const group =
2193*35238bceSAndroid Build Coastguard Worker                 new tcu::TestCaseGroup(m_testCtx, "occluder_geometry", "Occluders with varying geometry complexity");
2194*35238bceSAndroid Build Coastguard Worker 
2195*35238bceSAndroid Build Coastguard Worker             testCostGroup->addChild(group);
2196*35238bceSAndroid Build Coastguard Worker 
2197*35238bceSAndroid Build Coastguard Worker             group->addChild(
2198*35238bceSAndroid Build Coastguard Worker                 new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_5", "", 5, 0.0f, 0.0f));
2199*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_15", "", 15,
2200*35238bceSAndroid Build Coastguard Worker                                                                     0.0f, 0.0f));
2201*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_25", "", 25,
2202*35238bceSAndroid Build Coastguard Worker                                                                     0.0f, 0.0f));
2203*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_50", "", 50,
2204*35238bceSAndroid Build Coastguard Worker                                                                     0.0f, 0.0f));
2205*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_100", "",
2206*35238bceSAndroid Build Coastguard Worker                                                                     100, 0.0f, 0.0f));
2207*35238bceSAndroid Build Coastguard Worker 
2208*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_5", "", 5,
2209*35238bceSAndroid Build Coastguard Worker                                                                     1.0f / 5.0f, 0.0f));
2210*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_15", "", 15,
2211*35238bceSAndroid Build Coastguard Worker                                                                     1.0f / 15.0f, 0.0f));
2212*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_25", "", 25,
2213*35238bceSAndroid Build Coastguard Worker                                                                     1.0f / 25.0f, 0.0f));
2214*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_50", "", 50,
2215*35238bceSAndroid Build Coastguard Worker                                                                     1.0f / 50.0f, 0.0f));
2216*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_100", "", 100,
2217*35238bceSAndroid Build Coastguard Worker                                                                     1.0f / 100.0f, 0.0f));
2218*35238bceSAndroid Build Coastguard Worker 
2219*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_5", "", 5,
2220*35238bceSAndroid Build Coastguard Worker                                                                     0.0f, 0.2f));
2221*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_15", "",
2222*35238bceSAndroid Build Coastguard Worker                                                                     15, 0.0f, 0.2f));
2223*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_25", "",
2224*35238bceSAndroid Build Coastguard Worker                                                                     25, 0.0f, 0.2f));
2225*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_50", "",
2226*35238bceSAndroid Build Coastguard Worker                                                                     50, 0.0f, 0.2f));
2227*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_100", "",
2228*35238bceSAndroid Build Coastguard Worker                                                                     100, 0.0f, 0.2f));
2229*35238bceSAndroid Build Coastguard Worker 
2230*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_5", "", 5,
2231*35238bceSAndroid Build Coastguard Worker                                                                     1.0f / 5.0f, 0.2f));
2232*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_15", "", 15,
2233*35238bceSAndroid Build Coastguard Worker                                                                     1.0f / 15.0f, 0.2f));
2234*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_25", "", 25,
2235*35238bceSAndroid Build Coastguard Worker                                                                     1.0f / 25.0f, 0.2f));
2236*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_50", "", 50,
2237*35238bceSAndroid Build Coastguard Worker                                                                     1.0f / 50.0f, 0.2f));
2238*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_100", "",
2239*35238bceSAndroid Build Coastguard Worker                                                                     100, 1.0f / 100.0f, 0.2f));
2240*35238bceSAndroid Build Coastguard Worker         }
2241*35238bceSAndroid Build Coastguard Worker 
2242*35238bceSAndroid Build Coastguard Worker         {
2243*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "frag_depth", "Modifying gl_FragDepth");
2244*35238bceSAndroid Build Coastguard Worker 
2245*35238bceSAndroid Build Coastguard Worker             testCostGroup->addChild(group);
2246*35238bceSAndroid Build Coastguard Worker 
2247*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccluderStaticFragDepthCostCase(testCtx, renderCtx, "occluder_static", ""));
2248*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccluderDynamicFragDepthCostCase(testCtx, renderCtx, "occluder_dynamic", ""));
2249*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludedStaticFragDepthCostCase(testCtx, renderCtx, "occluded_static", ""));
2250*35238bceSAndroid Build Coastguard Worker             group->addChild(new OccludedDynamicFragDepthCostCase(testCtx, renderCtx, "occluded_dynamic", ""));
2251*35238bceSAndroid Build Coastguard Worker         }
2252*35238bceSAndroid Build Coastguard Worker     }
2253*35238bceSAndroid Build Coastguard Worker }
2254*35238bceSAndroid Build Coastguard Worker 
2255*35238bceSAndroid Build Coastguard Worker } // namespace Performance
2256*35238bceSAndroid Build Coastguard Worker } // namespace gles3
2257*35238bceSAndroid Build Coastguard Worker } // namespace deqp
2258