1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program EGL Module
3*35238bceSAndroid Build Coastguard Worker * ---------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2015 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 Test KHR_partial_update
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "teglPartialUpdateTests.hpp"
25*35238bceSAndroid Build Coastguard Worker
26*35238bceSAndroid Build Coastguard Worker #include "tcuImageCompare.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuTextureUtil.hpp"
30*35238bceSAndroid Build Coastguard Worker
31*35238bceSAndroid Build Coastguard Worker #include "egluNativeWindow.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "egluConfigFilter.hpp"
34*35238bceSAndroid Build Coastguard Worker
35*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
37*35238bceSAndroid Build Coastguard Worker
38*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
39*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
40*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
41*35238bceSAndroid Build Coastguard Worker
42*35238bceSAndroid Build Coastguard Worker #include "glwDefs.hpp"
43*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
44*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
45*35238bceSAndroid Build Coastguard Worker
46*35238bceSAndroid Build Coastguard Worker #include "deRandom.hpp"
47*35238bceSAndroid Build Coastguard Worker #include "deString.h"
48*35238bceSAndroid Build Coastguard Worker
49*35238bceSAndroid Build Coastguard Worker #include <string>
50*35238bceSAndroid Build Coastguard Worker #include <vector>
51*35238bceSAndroid Build Coastguard Worker #include <sstream>
52*35238bceSAndroid Build Coastguard Worker
53*35238bceSAndroid Build Coastguard Worker using glw::GLubyte;
54*35238bceSAndroid Build Coastguard Worker using std::string;
55*35238bceSAndroid Build Coastguard Worker using std::vector;
56*35238bceSAndroid Build Coastguard Worker using tcu::IVec2;
57*35238bceSAndroid Build Coastguard Worker
58*35238bceSAndroid Build Coastguard Worker using namespace eglw;
59*35238bceSAndroid Build Coastguard Worker
60*35238bceSAndroid Build Coastguard Worker namespace deqp
61*35238bceSAndroid Build Coastguard Worker {
62*35238bceSAndroid Build Coastguard Worker namespace egl
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker namespace
65*35238bceSAndroid Build Coastguard Worker {
66*35238bceSAndroid Build Coastguard Worker
67*35238bceSAndroid Build Coastguard Worker typedef tcu::Vector<GLubyte, 3> Color;
68*35238bceSAndroid Build Coastguard Worker
69*35238bceSAndroid Build Coastguard Worker class GLES2Renderer;
70*35238bceSAndroid Build Coastguard Worker
71*35238bceSAndroid Build Coastguard Worker class ReferenceRenderer;
72*35238bceSAndroid Build Coastguard Worker
73*35238bceSAndroid Build Coastguard Worker class PartialUpdateTest : public TestCase
74*35238bceSAndroid Build Coastguard Worker {
75*35238bceSAndroid Build Coastguard Worker public:
76*35238bceSAndroid Build Coastguard Worker enum DrawType
77*35238bceSAndroid Build Coastguard Worker {
78*35238bceSAndroid Build Coastguard Worker DRAWTYPE_GLES2_CLEAR,
79*35238bceSAndroid Build Coastguard Worker DRAWTYPE_GLES2_RENDER
80*35238bceSAndroid Build Coastguard Worker };
81*35238bceSAndroid Build Coastguard Worker
82*35238bceSAndroid Build Coastguard Worker PartialUpdateTest(EglTestContext &eglTestCtx, const vector<DrawType> &oddFrameDrawType,
83*35238bceSAndroid Build Coastguard Worker const vector<DrawType> &evenFrameDrawType, const char *name, const char *description);
84*35238bceSAndroid Build Coastguard Worker ~PartialUpdateTest(void);
85*35238bceSAndroid Build Coastguard Worker
86*35238bceSAndroid Build Coastguard Worker void init(void);
87*35238bceSAndroid Build Coastguard Worker void deinit(void);
88*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void);
89*35238bceSAndroid Build Coastguard Worker
90*35238bceSAndroid Build Coastguard Worker private:
91*35238bceSAndroid Build Coastguard Worker eglu::NativeWindow *m_window;
92*35238bceSAndroid Build Coastguard Worker EGLConfig m_eglConfig;
93*35238bceSAndroid Build Coastguard Worker EGLContext m_eglContext;
94*35238bceSAndroid Build Coastguard Worker
95*35238bceSAndroid Build Coastguard Worker protected:
96*35238bceSAndroid Build Coastguard Worker void initEGLSurface(EGLConfig config);
97*35238bceSAndroid Build Coastguard Worker void initEGLContext(EGLConfig config);
98*35238bceSAndroid Build Coastguard Worker
99*35238bceSAndroid Build Coastguard Worker const int m_seed;
100*35238bceSAndroid Build Coastguard Worker const vector<DrawType> m_oddFrameDrawType;
101*35238bceSAndroid Build Coastguard Worker const vector<DrawType> m_evenFrameDrawType;
102*35238bceSAndroid Build Coastguard Worker
103*35238bceSAndroid Build Coastguard Worker bool m_supportBufferAge;
104*35238bceSAndroid Build Coastguard Worker EGLDisplay m_eglDisplay;
105*35238bceSAndroid Build Coastguard Worker EGLSurface m_eglSurface;
106*35238bceSAndroid Build Coastguard Worker glw::Functions m_gl;
107*35238bceSAndroid Build Coastguard Worker
108*35238bceSAndroid Build Coastguard Worker GLES2Renderer *m_gles2Renderer;
109*35238bceSAndroid Build Coastguard Worker ReferenceRenderer *m_refRenderer;
110*35238bceSAndroid Build Coastguard Worker };
111*35238bceSAndroid Build Coastguard Worker
112*35238bceSAndroid Build Coastguard Worker struct ColoredRect
113*35238bceSAndroid Build Coastguard Worker {
114*35238bceSAndroid Build Coastguard Worker public:
115*35238bceSAndroid Build Coastguard Worker ColoredRect(const IVec2 &bottomLeft_, const IVec2 &topRight_, const Color &color_);
116*35238bceSAndroid Build Coastguard Worker IVec2 bottomLeft;
117*35238bceSAndroid Build Coastguard Worker IVec2 topRight;
118*35238bceSAndroid Build Coastguard Worker Color color;
119*35238bceSAndroid Build Coastguard Worker };
120*35238bceSAndroid Build Coastguard Worker
ColoredRect(const IVec2 & bottomLeft_,const IVec2 & topRight_,const Color & color_)121*35238bceSAndroid Build Coastguard Worker ColoredRect::ColoredRect(const IVec2 &bottomLeft_, const IVec2 &topRight_, const Color &color_)
122*35238bceSAndroid Build Coastguard Worker : bottomLeft(bottomLeft_)
123*35238bceSAndroid Build Coastguard Worker , topRight(topRight_)
124*35238bceSAndroid Build Coastguard Worker , color(color_)
125*35238bceSAndroid Build Coastguard Worker {
126*35238bceSAndroid Build Coastguard Worker }
127*35238bceSAndroid Build Coastguard Worker
128*35238bceSAndroid Build Coastguard Worker struct DrawCommand
129*35238bceSAndroid Build Coastguard Worker {
130*35238bceSAndroid Build Coastguard Worker DrawCommand(const PartialUpdateTest::DrawType drawType_, const ColoredRect &rect_);
131*35238bceSAndroid Build Coastguard Worker PartialUpdateTest::DrawType drawType;
132*35238bceSAndroid Build Coastguard Worker ColoredRect rect;
133*35238bceSAndroid Build Coastguard Worker };
134*35238bceSAndroid Build Coastguard Worker
DrawCommand(const PartialUpdateTest::DrawType drawType_,const ColoredRect & rect_)135*35238bceSAndroid Build Coastguard Worker DrawCommand::DrawCommand(const PartialUpdateTest::DrawType drawType_, const ColoredRect &rect_)
136*35238bceSAndroid Build Coastguard Worker : drawType(drawType_)
137*35238bceSAndroid Build Coastguard Worker , rect(rect_)
138*35238bceSAndroid Build Coastguard Worker {
139*35238bceSAndroid Build Coastguard Worker }
140*35238bceSAndroid Build Coastguard Worker
141*35238bceSAndroid Build Coastguard Worker struct Frame
142*35238bceSAndroid Build Coastguard Worker {
143*35238bceSAndroid Build Coastguard Worker Frame(int width_, int height_);
144*35238bceSAndroid Build Coastguard Worker int width;
145*35238bceSAndroid Build Coastguard Worker int height;
146*35238bceSAndroid Build Coastguard Worker vector<DrawCommand> draws;
147*35238bceSAndroid Build Coastguard Worker };
148*35238bceSAndroid Build Coastguard Worker
Frame(int width_,int height_)149*35238bceSAndroid Build Coastguard Worker Frame::Frame(int width_, int height_) : width(width_), height(height_)
150*35238bceSAndroid Build Coastguard Worker {
151*35238bceSAndroid Build Coastguard Worker }
152*35238bceSAndroid Build Coastguard Worker
153*35238bceSAndroid Build Coastguard Worker // (x1,y1) lie in the lower-left quadrant while (x2,y2) lie in the upper-right.
154*35238bceSAndroid Build Coastguard Worker // the coords are multiplied by 4 to amplify the minimial difference between coords to 4 (if not zero)
155*35238bceSAndroid Build Coastguard Worker // to avoid the situation where two edges are too close to each other which makes the rounding error
156*35238bceSAndroid Build Coastguard Worker // intoleratable by compareToReference()
generateRandomFrame(Frame & dst,const vector<PartialUpdateTest::DrawType> & drawTypes,de::Random & rnd)157*35238bceSAndroid Build Coastguard Worker void generateRandomFrame(Frame &dst, const vector<PartialUpdateTest::DrawType> &drawTypes, de::Random &rnd)
158*35238bceSAndroid Build Coastguard Worker {
159*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < drawTypes.size(); ndx++)
160*35238bceSAndroid Build Coastguard Worker {
161*35238bceSAndroid Build Coastguard Worker const int x1 = rnd.getInt(0, (dst.width - 1) / 8) * 4;
162*35238bceSAndroid Build Coastguard Worker const int y1 = rnd.getInt(0, (dst.height - 1) / 8) * 4;
163*35238bceSAndroid Build Coastguard Worker const int x2 = rnd.getInt((dst.width - 1) / 8, (dst.width - 1) / 4) * 4;
164*35238bceSAndroid Build Coastguard Worker const int y2 = rnd.getInt((dst.height - 1) / 8, (dst.height - 1) / 4) * 4;
165*35238bceSAndroid Build Coastguard Worker const GLubyte r = rnd.getUint8();
166*35238bceSAndroid Build Coastguard Worker const GLubyte g = rnd.getUint8();
167*35238bceSAndroid Build Coastguard Worker const GLubyte b = rnd.getUint8();
168*35238bceSAndroid Build Coastguard Worker const ColoredRect coloredRect(IVec2(x1, y1), IVec2(x2, y2), Color(r, g, b));
169*35238bceSAndroid Build Coastguard Worker const DrawCommand drawCommand(drawTypes[ndx], coloredRect);
170*35238bceSAndroid Build Coastguard Worker
171*35238bceSAndroid Build Coastguard Worker dst.draws.push_back(drawCommand);
172*35238bceSAndroid Build Coastguard Worker }
173*35238bceSAndroid Build Coastguard Worker }
174*35238bceSAndroid Build Coastguard Worker
175*35238bceSAndroid Build Coastguard Worker typedef vector<Frame> FrameSequence;
176*35238bceSAndroid Build Coastguard Worker
177*35238bceSAndroid Build Coastguard Worker //helper function declaration
178*35238bceSAndroid Build Coastguard Worker EGLConfig getEGLConfig(const Library &egl, EGLDisplay eglDisplay);
179*35238bceSAndroid Build Coastguard Worker void clearColorScreen(const glw::Functions &gl, const tcu::Vec4 &clearColor);
180*35238bceSAndroid Build Coastguard Worker void clearColorReference(tcu::Surface *ref, const tcu::Vec4 &clearColor);
181*35238bceSAndroid Build Coastguard Worker void readPixels(const glw::Functions &gl, tcu::Surface *screen);
182*35238bceSAndroid Build Coastguard Worker float windowToDeviceCoordinates(int x, int length);
183*35238bceSAndroid Build Coastguard Worker bool compareToReference(tcu::TestLog &log, const tcu::Surface &reference, const tcu::Surface &buffer, int frameNdx,
184*35238bceSAndroid Build Coastguard Worker int bufferNum);
185*35238bceSAndroid Build Coastguard Worker vector<int> getFramesOnBuffer(const vector<int> &bufferAges, int frameNdx);
186*35238bceSAndroid Build Coastguard Worker
187*35238bceSAndroid Build Coastguard Worker class GLES2Renderer
188*35238bceSAndroid Build Coastguard Worker {
189*35238bceSAndroid Build Coastguard Worker public:
190*35238bceSAndroid Build Coastguard Worker GLES2Renderer(const glw::Functions &gl);
191*35238bceSAndroid Build Coastguard Worker ~GLES2Renderer(void);
192*35238bceSAndroid Build Coastguard Worker void render(int width, int height, const Frame &frame) const;
193*35238bceSAndroid Build Coastguard Worker
194*35238bceSAndroid Build Coastguard Worker private:
195*35238bceSAndroid Build Coastguard Worker GLES2Renderer(const GLES2Renderer &);
196*35238bceSAndroid Build Coastguard Worker GLES2Renderer &operator=(const GLES2Renderer &);
197*35238bceSAndroid Build Coastguard Worker
198*35238bceSAndroid Build Coastguard Worker const glw::Functions &m_gl;
199*35238bceSAndroid Build Coastguard Worker glu::ShaderProgram m_glProgram;
200*35238bceSAndroid Build Coastguard Worker glw::GLuint m_coordLoc;
201*35238bceSAndroid Build Coastguard Worker glw::GLuint m_colorLoc;
202*35238bceSAndroid Build Coastguard Worker };
203*35238bceSAndroid Build Coastguard Worker
204*35238bceSAndroid Build Coastguard Worker // generate sources for vertex and fragment buffer
getSources(void)205*35238bceSAndroid Build Coastguard Worker glu::ProgramSources getSources(void)
206*35238bceSAndroid Build Coastguard Worker {
207*35238bceSAndroid Build Coastguard Worker const char *const vertexShaderSource = "attribute mediump vec2 a_pos;\n"
208*35238bceSAndroid Build Coastguard Worker "attribute mediump vec4 a_color;\n"
209*35238bceSAndroid Build Coastguard Worker "varying mediump vec4 v_color;\n"
210*35238bceSAndroid Build Coastguard Worker "void main(void)\n"
211*35238bceSAndroid Build Coastguard Worker "{\n"
212*35238bceSAndroid Build Coastguard Worker "\tv_color = a_color;\n"
213*35238bceSAndroid Build Coastguard Worker "\tgl_Position = vec4(a_pos, 0.0, 1.0);\n"
214*35238bceSAndroid Build Coastguard Worker "}";
215*35238bceSAndroid Build Coastguard Worker
216*35238bceSAndroid Build Coastguard Worker const char *const fragmentShaderSource = "varying mediump vec4 v_color;\n"
217*35238bceSAndroid Build Coastguard Worker "void main(void)\n"
218*35238bceSAndroid Build Coastguard Worker "{\n"
219*35238bceSAndroid Build Coastguard Worker "\tgl_FragColor = v_color;\n"
220*35238bceSAndroid Build Coastguard Worker "}";
221*35238bceSAndroid Build Coastguard Worker
222*35238bceSAndroid Build Coastguard Worker return glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource);
223*35238bceSAndroid Build Coastguard Worker }
224*35238bceSAndroid Build Coastguard Worker
GLES2Renderer(const glw::Functions & gl)225*35238bceSAndroid Build Coastguard Worker GLES2Renderer::GLES2Renderer(const glw::Functions &gl)
226*35238bceSAndroid Build Coastguard Worker : m_gl(gl)
227*35238bceSAndroid Build Coastguard Worker , m_glProgram(gl, getSources())
228*35238bceSAndroid Build Coastguard Worker , m_coordLoc((glw::GLuint)-1)
229*35238bceSAndroid Build Coastguard Worker , m_colorLoc((glw::GLuint)-1)
230*35238bceSAndroid Build Coastguard Worker {
231*35238bceSAndroid Build Coastguard Worker m_colorLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_color");
232*35238bceSAndroid Build Coastguard Worker m_coordLoc = m_gl.getAttribLocation(m_glProgram.getProgram(), "a_pos");
233*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to get attribute locations");
234*35238bceSAndroid Build Coastguard Worker }
235*35238bceSAndroid Build Coastguard Worker
~GLES2Renderer(void)236*35238bceSAndroid Build Coastguard Worker GLES2Renderer::~GLES2Renderer(void)
237*35238bceSAndroid Build Coastguard Worker {
238*35238bceSAndroid Build Coastguard Worker }
239*35238bceSAndroid Build Coastguard Worker
render(int width,int height,const Frame & frame) const240*35238bceSAndroid Build Coastguard Worker void GLES2Renderer::render(int width, int height, const Frame &frame) const
241*35238bceSAndroid Build Coastguard Worker {
242*35238bceSAndroid Build Coastguard Worker for (size_t drawNdx = 0; drawNdx < frame.draws.size(); drawNdx++)
243*35238bceSAndroid Build Coastguard Worker {
244*35238bceSAndroid Build Coastguard Worker const ColoredRect &coloredRect = frame.draws[drawNdx].rect;
245*35238bceSAndroid Build Coastguard Worker
246*35238bceSAndroid Build Coastguard Worker if (frame.draws[drawNdx].drawType == PartialUpdateTest::DRAWTYPE_GLES2_RENDER)
247*35238bceSAndroid Build Coastguard Worker {
248*35238bceSAndroid Build Coastguard Worker const float x1 = windowToDeviceCoordinates(coloredRect.bottomLeft.x(), width);
249*35238bceSAndroid Build Coastguard Worker const float y1 = windowToDeviceCoordinates(coloredRect.bottomLeft.y(), height);
250*35238bceSAndroid Build Coastguard Worker const float x2 = windowToDeviceCoordinates(coloredRect.topRight.x(), width);
251*35238bceSAndroid Build Coastguard Worker const float y2 = windowToDeviceCoordinates(coloredRect.topRight.y(), height);
252*35238bceSAndroid Build Coastguard Worker
253*35238bceSAndroid Build Coastguard Worker const glw::GLfloat coords[] = {
254*35238bceSAndroid Build Coastguard Worker x1, y1, x1, y2, x2, y2,
255*35238bceSAndroid Build Coastguard Worker
256*35238bceSAndroid Build Coastguard Worker x2, y2, x2, y1, x1, y1,
257*35238bceSAndroid Build Coastguard Worker };
258*35238bceSAndroid Build Coastguard Worker
259*35238bceSAndroid Build Coastguard Worker const glw::GLubyte colors[] = {
260*35238bceSAndroid Build Coastguard Worker coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), 255,
261*35238bceSAndroid Build Coastguard Worker coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), 255,
262*35238bceSAndroid Build Coastguard Worker coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), 255,
263*35238bceSAndroid Build Coastguard Worker
264*35238bceSAndroid Build Coastguard Worker coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), 255,
265*35238bceSAndroid Build Coastguard Worker coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), 255,
266*35238bceSAndroid Build Coastguard Worker coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), 255,
267*35238bceSAndroid Build Coastguard Worker };
268*35238bceSAndroid Build Coastguard Worker
269*35238bceSAndroid Build Coastguard Worker m_gl.useProgram(m_glProgram.getProgram());
270*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "glUseProgram() failed");
271*35238bceSAndroid Build Coastguard Worker
272*35238bceSAndroid Build Coastguard Worker m_gl.enableVertexAttribArray(m_coordLoc);
273*35238bceSAndroid Build Coastguard Worker m_gl.enableVertexAttribArray(m_colorLoc);
274*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to enable attributes");
275*35238bceSAndroid Build Coastguard Worker
276*35238bceSAndroid Build Coastguard Worker m_gl.vertexAttribPointer(m_coordLoc, 2, GL_FLOAT, GL_FALSE, 0, coords);
277*35238bceSAndroid Build Coastguard Worker m_gl.vertexAttribPointer(m_colorLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, colors);
278*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to set attribute pointers");
279*35238bceSAndroid Build Coastguard Worker
280*35238bceSAndroid Build Coastguard Worker m_gl.drawArrays(GL_TRIANGLES, 0, DE_LENGTH_OF_ARRAY(coords) / 2);
281*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "glDrawArrays(), failed");
282*35238bceSAndroid Build Coastguard Worker
283*35238bceSAndroid Build Coastguard Worker m_gl.disableVertexAttribArray(m_coordLoc);
284*35238bceSAndroid Build Coastguard Worker m_gl.disableVertexAttribArray(m_colorLoc);
285*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "Failed to disable attributes");
286*35238bceSAndroid Build Coastguard Worker
287*35238bceSAndroid Build Coastguard Worker m_gl.useProgram(0);
288*35238bceSAndroid Build Coastguard Worker GLU_EXPECT_NO_ERROR(m_gl.getError(), "glUseProgram() failed");
289*35238bceSAndroid Build Coastguard Worker }
290*35238bceSAndroid Build Coastguard Worker else if (frame.draws[drawNdx].drawType == PartialUpdateTest::DRAWTYPE_GLES2_CLEAR)
291*35238bceSAndroid Build Coastguard Worker {
292*35238bceSAndroid Build Coastguard Worker m_gl.enable(GL_SCISSOR_TEST);
293*35238bceSAndroid Build Coastguard Worker m_gl.scissor(coloredRect.bottomLeft.x(), coloredRect.bottomLeft.y(),
294*35238bceSAndroid Build Coastguard Worker coloredRect.topRight.x() - coloredRect.bottomLeft.x(),
295*35238bceSAndroid Build Coastguard Worker coloredRect.topRight.y() - coloredRect.bottomLeft.y());
296*35238bceSAndroid Build Coastguard Worker m_gl.clearColor(coloredRect.color.x() / 255.0f, coloredRect.color.y() / 255.0f,
297*35238bceSAndroid Build Coastguard Worker coloredRect.color.z() / 255.0f, 1.0f);
298*35238bceSAndroid Build Coastguard Worker m_gl.clear(GL_COLOR_BUFFER_BIT);
299*35238bceSAndroid Build Coastguard Worker m_gl.disable(GL_SCISSOR_TEST);
300*35238bceSAndroid Build Coastguard Worker }
301*35238bceSAndroid Build Coastguard Worker else
302*35238bceSAndroid Build Coastguard Worker DE_FATAL("Invalid drawtype");
303*35238bceSAndroid Build Coastguard Worker }
304*35238bceSAndroid Build Coastguard Worker }
305*35238bceSAndroid Build Coastguard Worker
306*35238bceSAndroid Build Coastguard Worker class ReferenceRenderer
307*35238bceSAndroid Build Coastguard Worker {
308*35238bceSAndroid Build Coastguard Worker public:
309*35238bceSAndroid Build Coastguard Worker ReferenceRenderer(void);
310*35238bceSAndroid Build Coastguard Worker void render(tcu::Surface *target, const Frame &frame) const;
311*35238bceSAndroid Build Coastguard Worker
312*35238bceSAndroid Build Coastguard Worker private:
313*35238bceSAndroid Build Coastguard Worker ReferenceRenderer(const ReferenceRenderer &);
314*35238bceSAndroid Build Coastguard Worker ReferenceRenderer &operator=(const ReferenceRenderer &);
315*35238bceSAndroid Build Coastguard Worker };
316*35238bceSAndroid Build Coastguard Worker
ReferenceRenderer(void)317*35238bceSAndroid Build Coastguard Worker ReferenceRenderer::ReferenceRenderer(void)
318*35238bceSAndroid Build Coastguard Worker {
319*35238bceSAndroid Build Coastguard Worker }
320*35238bceSAndroid Build Coastguard Worker
render(tcu::Surface * target,const Frame & frame) const321*35238bceSAndroid Build Coastguard Worker void ReferenceRenderer::render(tcu::Surface *target, const Frame &frame) const
322*35238bceSAndroid Build Coastguard Worker {
323*35238bceSAndroid Build Coastguard Worker for (size_t drawNdx = 0; drawNdx < frame.draws.size(); drawNdx++)
324*35238bceSAndroid Build Coastguard Worker {
325*35238bceSAndroid Build Coastguard Worker const ColoredRect &coloredRect = frame.draws[drawNdx].rect;
326*35238bceSAndroid Build Coastguard Worker if (frame.draws[drawNdx].drawType == PartialUpdateTest::DRAWTYPE_GLES2_RENDER ||
327*35238bceSAndroid Build Coastguard Worker frame.draws[drawNdx].drawType == PartialUpdateTest::DRAWTYPE_GLES2_CLEAR)
328*35238bceSAndroid Build Coastguard Worker {
329*35238bceSAndroid Build Coastguard Worker // tcu does not support degenerate subregions. Since they correspond to no-op rendering, just skip them.
330*35238bceSAndroid Build Coastguard Worker if (coloredRect.bottomLeft.x() == coloredRect.topRight.x() ||
331*35238bceSAndroid Build Coastguard Worker coloredRect.bottomLeft.y() == coloredRect.topRight.y())
332*35238bceSAndroid Build Coastguard Worker continue;
333*35238bceSAndroid Build Coastguard Worker
334*35238bceSAndroid Build Coastguard Worker const tcu::UVec4 color(coloredRect.color.x(), coloredRect.color.y(), coloredRect.color.z(), 255);
335*35238bceSAndroid Build Coastguard Worker tcu::clear(tcu::getSubregion(target->getAccess(), coloredRect.bottomLeft.x(), coloredRect.bottomLeft.y(),
336*35238bceSAndroid Build Coastguard Worker coloredRect.topRight.x() - coloredRect.bottomLeft.x(),
337*35238bceSAndroid Build Coastguard Worker coloredRect.topRight.y() - coloredRect.bottomLeft.y()),
338*35238bceSAndroid Build Coastguard Worker color);
339*35238bceSAndroid Build Coastguard Worker }
340*35238bceSAndroid Build Coastguard Worker else
341*35238bceSAndroid Build Coastguard Worker DE_FATAL("Invalid drawtype");
342*35238bceSAndroid Build Coastguard Worker }
343*35238bceSAndroid Build Coastguard Worker }
344*35238bceSAndroid Build Coastguard Worker
PartialUpdateTest(EglTestContext & eglTestCtx,const vector<DrawType> & oddFrameDrawType,const vector<DrawType> & evenFrameDrawType,const char * name,const char * description)345*35238bceSAndroid Build Coastguard Worker PartialUpdateTest::PartialUpdateTest(EglTestContext &eglTestCtx, const vector<DrawType> &oddFrameDrawType,
346*35238bceSAndroid Build Coastguard Worker const vector<DrawType> &evenFrameDrawType, const char *name,
347*35238bceSAndroid Build Coastguard Worker const char *description)
348*35238bceSAndroid Build Coastguard Worker : TestCase(eglTestCtx, name, description)
349*35238bceSAndroid Build Coastguard Worker , m_window(DE_NULL)
350*35238bceSAndroid Build Coastguard Worker , m_eglContext(EGL_NO_CONTEXT)
351*35238bceSAndroid Build Coastguard Worker , m_seed(deStringHash(name))
352*35238bceSAndroid Build Coastguard Worker , m_oddFrameDrawType(oddFrameDrawType)
353*35238bceSAndroid Build Coastguard Worker , m_evenFrameDrawType(evenFrameDrawType)
354*35238bceSAndroid Build Coastguard Worker , m_supportBufferAge(false)
355*35238bceSAndroid Build Coastguard Worker , m_eglDisplay(EGL_NO_DISPLAY)
356*35238bceSAndroid Build Coastguard Worker , m_eglSurface(EGL_NO_SURFACE)
357*35238bceSAndroid Build Coastguard Worker , m_gles2Renderer(DE_NULL)
358*35238bceSAndroid Build Coastguard Worker , m_refRenderer(DE_NULL)
359*35238bceSAndroid Build Coastguard Worker {
360*35238bceSAndroid Build Coastguard Worker }
361*35238bceSAndroid Build Coastguard Worker
~PartialUpdateTest(void)362*35238bceSAndroid Build Coastguard Worker PartialUpdateTest::~PartialUpdateTest(void)
363*35238bceSAndroid Build Coastguard Worker {
364*35238bceSAndroid Build Coastguard Worker deinit();
365*35238bceSAndroid Build Coastguard Worker }
366*35238bceSAndroid Build Coastguard Worker
init(void)367*35238bceSAndroid Build Coastguard Worker void PartialUpdateTest::init(void)
368*35238bceSAndroid Build Coastguard Worker {
369*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
370*35238bceSAndroid Build Coastguard Worker
371*35238bceSAndroid Build Coastguard Worker m_eglDisplay = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
372*35238bceSAndroid Build Coastguard Worker
373*35238bceSAndroid Build Coastguard Worker if (!eglu::hasExtension(egl, m_eglDisplay, "EGL_KHR_partial_update"))
374*35238bceSAndroid Build Coastguard Worker {
375*35238bceSAndroid Build Coastguard Worker egl.terminate(m_eglDisplay);
376*35238bceSAndroid Build Coastguard Worker m_eglDisplay = EGL_NO_DISPLAY;
377*35238bceSAndroid Build Coastguard Worker TCU_THROW(NotSupportedError, "EGL_KHR_partial_update is not supported");
378*35238bceSAndroid Build Coastguard Worker }
379*35238bceSAndroid Build Coastguard Worker
380*35238bceSAndroid Build Coastguard Worker m_eglConfig = getEGLConfig(m_eglTestCtx.getLibrary(), m_eglDisplay);
381*35238bceSAndroid Build Coastguard Worker
382*35238bceSAndroid Build Coastguard Worker //create surface and context and make them current
383*35238bceSAndroid Build Coastguard Worker initEGLSurface(m_eglConfig);
384*35238bceSAndroid Build Coastguard Worker initEGLContext(m_eglConfig);
385*35238bceSAndroid Build Coastguard Worker
386*35238bceSAndroid Build Coastguard Worker m_eglTestCtx.initGLFunctions(&m_gl, glu::ApiType::es(2, 0));
387*35238bceSAndroid Build Coastguard Worker
388*35238bceSAndroid Build Coastguard Worker m_supportBufferAge = eglu::hasExtension(egl, m_eglDisplay, "EGL_EXT_buffer_age");
389*35238bceSAndroid Build Coastguard Worker
390*35238bceSAndroid Build Coastguard Worker m_gles2Renderer = new GLES2Renderer(m_gl);
391*35238bceSAndroid Build Coastguard Worker m_refRenderer = new ReferenceRenderer();
392*35238bceSAndroid Build Coastguard Worker }
393*35238bceSAndroid Build Coastguard Worker
deinit(void)394*35238bceSAndroid Build Coastguard Worker void PartialUpdateTest::deinit(void)
395*35238bceSAndroid Build Coastguard Worker {
396*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
397*35238bceSAndroid Build Coastguard Worker
398*35238bceSAndroid Build Coastguard Worker delete m_refRenderer;
399*35238bceSAndroid Build Coastguard Worker m_refRenderer = DE_NULL;
400*35238bceSAndroid Build Coastguard Worker
401*35238bceSAndroid Build Coastguard Worker delete m_gles2Renderer;
402*35238bceSAndroid Build Coastguard Worker m_gles2Renderer = DE_NULL;
403*35238bceSAndroid Build Coastguard Worker
404*35238bceSAndroid Build Coastguard Worker if (m_eglContext != EGL_NO_CONTEXT)
405*35238bceSAndroid Build Coastguard Worker {
406*35238bceSAndroid Build Coastguard Worker egl.makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
407*35238bceSAndroid Build Coastguard Worker egl.destroyContext(m_eglDisplay, m_eglContext);
408*35238bceSAndroid Build Coastguard Worker m_eglContext = EGL_NO_CONTEXT;
409*35238bceSAndroid Build Coastguard Worker }
410*35238bceSAndroid Build Coastguard Worker
411*35238bceSAndroid Build Coastguard Worker if (m_eglSurface != EGL_NO_SURFACE)
412*35238bceSAndroid Build Coastguard Worker {
413*35238bceSAndroid Build Coastguard Worker egl.destroySurface(m_eglDisplay, m_eglSurface);
414*35238bceSAndroid Build Coastguard Worker m_eglSurface = EGL_NO_SURFACE;
415*35238bceSAndroid Build Coastguard Worker }
416*35238bceSAndroid Build Coastguard Worker
417*35238bceSAndroid Build Coastguard Worker if (m_eglDisplay != EGL_NO_DISPLAY)
418*35238bceSAndroid Build Coastguard Worker {
419*35238bceSAndroid Build Coastguard Worker egl.terminate(m_eglDisplay);
420*35238bceSAndroid Build Coastguard Worker m_eglDisplay = EGL_NO_DISPLAY;
421*35238bceSAndroid Build Coastguard Worker }
422*35238bceSAndroid Build Coastguard Worker
423*35238bceSAndroid Build Coastguard Worker delete m_window;
424*35238bceSAndroid Build Coastguard Worker m_window = DE_NULL;
425*35238bceSAndroid Build Coastguard Worker }
426*35238bceSAndroid Build Coastguard Worker
initEGLSurface(EGLConfig config)427*35238bceSAndroid Build Coastguard Worker void PartialUpdateTest::initEGLSurface(EGLConfig config)
428*35238bceSAndroid Build Coastguard Worker {
429*35238bceSAndroid Build Coastguard Worker const eglu::NativeWindowFactory &factory =
430*35238bceSAndroid Build Coastguard Worker eglu::selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
431*35238bceSAndroid Build Coastguard Worker m_window =
432*35238bceSAndroid Build Coastguard Worker factory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay, config, DE_NULL,
433*35238bceSAndroid Build Coastguard Worker eglu::WindowParams(480, 480, eglu::parseWindowVisibility(m_testCtx.getCommandLine())));
434*35238bceSAndroid Build Coastguard Worker m_eglSurface = eglu::createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_window, m_eglDisplay, config, DE_NULL);
435*35238bceSAndroid Build Coastguard Worker }
436*35238bceSAndroid Build Coastguard Worker
initEGLContext(EGLConfig config)437*35238bceSAndroid Build Coastguard Worker void PartialUpdateTest::initEGLContext(EGLConfig config)
438*35238bceSAndroid Build Coastguard Worker {
439*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
440*35238bceSAndroid Build Coastguard Worker const EGLint attribList[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
441*35238bceSAndroid Build Coastguard Worker
442*35238bceSAndroid Build Coastguard Worker egl.bindAPI(EGL_OPENGL_ES_API);
443*35238bceSAndroid Build Coastguard Worker m_eglContext = egl.createContext(m_eglDisplay, config, EGL_NO_CONTEXT, attribList);
444*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglCreateContext");
445*35238bceSAndroid Build Coastguard Worker TCU_CHECK(m_eglSurface != EGL_NO_SURFACE);
446*35238bceSAndroid Build Coastguard Worker egl.makeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
447*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglMakeCurrent");
448*35238bceSAndroid Build Coastguard Worker }
449*35238bceSAndroid Build Coastguard Worker
450*35238bceSAndroid Build Coastguard Worker // return indices of frames that have been written to the given buffer
getFramesOnBuffer(const vector<int> & bufferAges,int frameNdx)451*35238bceSAndroid Build Coastguard Worker vector<int> getFramesOnBuffer(const vector<int> &bufferAges, int frameNdx)
452*35238bceSAndroid Build Coastguard Worker {
453*35238bceSAndroid Build Coastguard Worker DE_ASSERT(frameNdx < (int)bufferAges.size());
454*35238bceSAndroid Build Coastguard Worker vector<int> frameOnBuffer;
455*35238bceSAndroid Build Coastguard Worker int age = bufferAges[frameNdx];
456*35238bceSAndroid Build Coastguard Worker while (age != 0)
457*35238bceSAndroid Build Coastguard Worker {
458*35238bceSAndroid Build Coastguard Worker frameNdx = frameNdx - age;
459*35238bceSAndroid Build Coastguard Worker DE_ASSERT(frameNdx >= 0);
460*35238bceSAndroid Build Coastguard Worker frameOnBuffer.push_back(frameNdx);
461*35238bceSAndroid Build Coastguard Worker age = bufferAges[frameNdx];
462*35238bceSAndroid Build Coastguard Worker }
463*35238bceSAndroid Build Coastguard Worker
464*35238bceSAndroid Build Coastguard Worker reverse(frameOnBuffer.begin(), frameOnBuffer.end());
465*35238bceSAndroid Build Coastguard Worker return frameOnBuffer;
466*35238bceSAndroid Build Coastguard Worker }
467*35238bceSAndroid Build Coastguard Worker
getDamageRegion(const Frame & frame,int marginLeft,int marginBottom,int marginRight,int marginTop)468*35238bceSAndroid Build Coastguard Worker vector<EGLint> getDamageRegion(const Frame &frame, int marginLeft, int marginBottom, int marginRight, int marginTop)
469*35238bceSAndroid Build Coastguard Worker {
470*35238bceSAndroid Build Coastguard Worker vector<EGLint> damageRegion;
471*35238bceSAndroid Build Coastguard Worker for (size_t drawNdx = 0; drawNdx < frame.draws.size(); drawNdx++)
472*35238bceSAndroid Build Coastguard Worker {
473*35238bceSAndroid Build Coastguard Worker const ColoredRect &rect = frame.draws[drawNdx].rect;
474*35238bceSAndroid Build Coastguard Worker damageRegion.push_back(rect.bottomLeft.x() - marginLeft);
475*35238bceSAndroid Build Coastguard Worker damageRegion.push_back(rect.bottomLeft.y() - marginBottom);
476*35238bceSAndroid Build Coastguard Worker damageRegion.push_back(rect.topRight.x() - rect.bottomLeft.x() + marginLeft + marginRight);
477*35238bceSAndroid Build Coastguard Worker damageRegion.push_back(rect.topRight.y() - rect.bottomLeft.y() + marginBottom + marginTop);
478*35238bceSAndroid Build Coastguard Worker }
479*35238bceSAndroid Build Coastguard Worker
480*35238bceSAndroid Build Coastguard Worker DE_ASSERT(damageRegion.size() % 4 == 0);
481*35238bceSAndroid Build Coastguard Worker return damageRegion;
482*35238bceSAndroid Build Coastguard Worker }
483*35238bceSAndroid Build Coastguard Worker
iterate(void)484*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult PartialUpdateTest::iterate(void)
485*35238bceSAndroid Build Coastguard Worker {
486*35238bceSAndroid Build Coastguard Worker de::Random rnd(m_seed);
487*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
488*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
489*35238bceSAndroid Build Coastguard Worker const int width = eglu::querySurfaceInt(egl, m_eglDisplay, m_eglSurface, EGL_WIDTH);
490*35238bceSAndroid Build Coastguard Worker const int height = eglu::querySurfaceInt(egl, m_eglDisplay, m_eglSurface, EGL_HEIGHT);
491*35238bceSAndroid Build Coastguard Worker const float clearRed = rnd.getFloat();
492*35238bceSAndroid Build Coastguard Worker const float clearGreen = rnd.getFloat();
493*35238bceSAndroid Build Coastguard Worker const float clearBlue = rnd.getFloat();
494*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 clearColor(clearRed, clearGreen, clearBlue, 1.0f);
495*35238bceSAndroid Build Coastguard Worker const int numFrames = 20;
496*35238bceSAndroid Build Coastguard Worker FrameSequence frameSequence;
497*35238bceSAndroid Build Coastguard Worker vector<int> bufferAges;
498*35238bceSAndroid Build Coastguard Worker bool hasPositiveAge = false;
499*35238bceSAndroid Build Coastguard Worker
500*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
501*35238bceSAndroid Build Coastguard Worker
502*35238bceSAndroid Build Coastguard Worker for (int frameNdx = 0; frameNdx < numFrames; frameNdx++)
503*35238bceSAndroid Build Coastguard Worker {
504*35238bceSAndroid Build Coastguard Worker tcu::Surface currentBuffer(width, height);
505*35238bceSAndroid Build Coastguard Worker tcu::Surface refBuffer(width, height);
506*35238bceSAndroid Build Coastguard Worker Frame newFrame(width, height);
507*35238bceSAndroid Build Coastguard Worker EGLint currentBufferAge = -1;
508*35238bceSAndroid Build Coastguard Worker
509*35238bceSAndroid Build Coastguard Worker if (frameNdx % 2 == 0)
510*35238bceSAndroid Build Coastguard Worker generateRandomFrame(newFrame, m_evenFrameDrawType, rnd);
511*35238bceSAndroid Build Coastguard Worker else
512*35238bceSAndroid Build Coastguard Worker generateRandomFrame(newFrame, m_oddFrameDrawType, rnd);
513*35238bceSAndroid Build Coastguard Worker
514*35238bceSAndroid Build Coastguard Worker frameSequence.push_back(newFrame);
515*35238bceSAndroid Build Coastguard Worker
516*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, querySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, ¤tBufferAge));
517*35238bceSAndroid Build Coastguard Worker
518*35238bceSAndroid Build Coastguard Worker if (currentBufferAge > frameNdx || currentBufferAge < 0) // invalid buffer age
519*35238bceSAndroid Build Coastguard Worker {
520*35238bceSAndroid Build Coastguard Worker std::ostringstream stream;
521*35238bceSAndroid Build Coastguard Worker stream << "Fail, the age is invalid. Age: " << currentBufferAge << ", frameNdx: " << frameNdx;
522*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, stream.str().c_str());
523*35238bceSAndroid Build Coastguard Worker return STOP;
524*35238bceSAndroid Build Coastguard Worker }
525*35238bceSAndroid Build Coastguard Worker
526*35238bceSAndroid Build Coastguard Worker bufferAges.push_back(currentBufferAge);
527*35238bceSAndroid Build Coastguard Worker DE_ASSERT((int)bufferAges.size() == frameNdx + 1);
528*35238bceSAndroid Build Coastguard Worker
529*35238bceSAndroid Build Coastguard Worker if (currentBufferAge > 0)
530*35238bceSAndroid Build Coastguard Worker {
531*35238bceSAndroid Build Coastguard Worker vector<EGLint> damageRegion;
532*35238bceSAndroid Build Coastguard Worker
533*35238bceSAndroid Build Coastguard Worker hasPositiveAge = true;
534*35238bceSAndroid Build Coastguard Worker
535*35238bceSAndroid Build Coastguard Worker if (m_supportBufferAge)
536*35238bceSAndroid Build Coastguard Worker {
537*35238bceSAndroid Build Coastguard Worker damageRegion = getDamageRegion(newFrame, 10, 10, 10, 10);
538*35238bceSAndroid Build Coastguard Worker }
539*35238bceSAndroid Build Coastguard Worker else
540*35238bceSAndroid Build Coastguard Worker {
541*35238bceSAndroid Build Coastguard Worker damageRegion = getDamageRegion(newFrame, 0, 0, 0, 0);
542*35238bceSAndroid Build Coastguard Worker }
543*35238bceSAndroid Build Coastguard Worker
544*35238bceSAndroid Build Coastguard Worker // Set empty damage region to avoid invalidating the framebuffer. The damage area is invalidated
545*35238bceSAndroid Build Coastguard Worker // if the buffer age extension is not supported.
546*35238bceSAndroid Build Coastguard Worker if (damageRegion.size() == 0)
547*35238bceSAndroid Build Coastguard Worker damageRegion = vector<EGLint>(4, 0);
548*35238bceSAndroid Build Coastguard Worker
549*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(
550*35238bceSAndroid Build Coastguard Worker egl, setDamageRegionKHR(m_eglDisplay, m_eglSurface, &damageRegion[0], (EGLint)damageRegion.size() / 4));
551*35238bceSAndroid Build Coastguard Worker }
552*35238bceSAndroid Build Coastguard Worker else
553*35238bceSAndroid Build Coastguard Worker {
554*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, setDamageRegionKHR(m_eglDisplay, m_eglSurface, NULL, 0));
555*35238bceSAndroid Build Coastguard Worker clearColorScreen(m_gl, clearColor);
556*35238bceSAndroid Build Coastguard Worker }
557*35238bceSAndroid Build Coastguard Worker
558*35238bceSAndroid Build Coastguard Worker // during first half, just keep rendering without reading pixel back to mimic ordinary use case
559*35238bceSAndroid Build Coastguard Worker if (frameNdx < numFrames / 2)
560*35238bceSAndroid Build Coastguard Worker m_gles2Renderer->render(width, height, newFrame);
561*35238bceSAndroid Build Coastguard Worker else // do verification in the second half
562*35238bceSAndroid Build Coastguard Worker {
563*35238bceSAndroid Build Coastguard Worker const vector<int> framesOnBuffer = getFramesOnBuffer(bufferAges, frameNdx);
564*35238bceSAndroid Build Coastguard Worker
565*35238bceSAndroid Build Coastguard Worker clearColorReference(&refBuffer, clearColor);
566*35238bceSAndroid Build Coastguard Worker
567*35238bceSAndroid Build Coastguard Worker for (vector<int>::const_iterator it = framesOnBuffer.begin(); it != framesOnBuffer.end(); it++)
568*35238bceSAndroid Build Coastguard Worker m_refRenderer->render(&refBuffer, frameSequence[*it]);
569*35238bceSAndroid Build Coastguard Worker
570*35238bceSAndroid Build Coastguard Worker m_gles2Renderer->render(width, height, newFrame);
571*35238bceSAndroid Build Coastguard Worker m_refRenderer->render(&refBuffer, newFrame);
572*35238bceSAndroid Build Coastguard Worker
573*35238bceSAndroid Build Coastguard Worker readPixels(m_gl, ¤tBuffer);
574*35238bceSAndroid Build Coastguard Worker
575*35238bceSAndroid Build Coastguard Worker if (!compareToReference(log, refBuffer, currentBuffer, frameNdx, frameNdx))
576*35238bceSAndroid Build Coastguard Worker {
577*35238bceSAndroid Build Coastguard Worker string errorMessage("Fail, render result is wrong. Buffer age is ");
578*35238bceSAndroid Build Coastguard Worker errorMessage += (m_supportBufferAge ? "supported" : "not supported");
579*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, errorMessage.c_str());
580*35238bceSAndroid Build Coastguard Worker return STOP;
581*35238bceSAndroid Build Coastguard Worker }
582*35238bceSAndroid Build Coastguard Worker }
583*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, swapBuffers(m_eglDisplay, m_eglSurface));
584*35238bceSAndroid Build Coastguard Worker }
585*35238bceSAndroid Build Coastguard Worker
586*35238bceSAndroid Build Coastguard Worker if (!hasPositiveAge) // fraud behavior, pretend to support partial_update
587*35238bceSAndroid Build Coastguard Worker {
588*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL,
589*35238bceSAndroid Build Coastguard Worker "Fail, claim to support partial_update but buffer age is always 0");
590*35238bceSAndroid Build Coastguard Worker return STOP;
591*35238bceSAndroid Build Coastguard Worker }
592*35238bceSAndroid Build Coastguard Worker
593*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
594*35238bceSAndroid Build Coastguard Worker return STOP;
595*35238bceSAndroid Build Coastguard Worker }
596*35238bceSAndroid Build Coastguard Worker
generateDrawTypeName(const vector<PartialUpdateTest::DrawType> & drawTypes)597*35238bceSAndroid Build Coastguard Worker string generateDrawTypeName(const vector<PartialUpdateTest::DrawType> &drawTypes)
598*35238bceSAndroid Build Coastguard Worker {
599*35238bceSAndroid Build Coastguard Worker std::ostringstream stream;
600*35238bceSAndroid Build Coastguard Worker if (drawTypes.size() == 0)
601*35238bceSAndroid Build Coastguard Worker return string("_none");
602*35238bceSAndroid Build Coastguard Worker
603*35238bceSAndroid Build Coastguard Worker for (size_t ndx = 0; ndx < drawTypes.size(); ndx++)
604*35238bceSAndroid Build Coastguard Worker {
605*35238bceSAndroid Build Coastguard Worker if (drawTypes[ndx] == PartialUpdateTest::DRAWTYPE_GLES2_RENDER)
606*35238bceSAndroid Build Coastguard Worker stream << "_render";
607*35238bceSAndroid Build Coastguard Worker else if (drawTypes[ndx] == PartialUpdateTest::DRAWTYPE_GLES2_CLEAR)
608*35238bceSAndroid Build Coastguard Worker stream << "_clear";
609*35238bceSAndroid Build Coastguard Worker else
610*35238bceSAndroid Build Coastguard Worker DE_ASSERT(false);
611*35238bceSAndroid Build Coastguard Worker }
612*35238bceSAndroid Build Coastguard Worker return stream.str();
613*35238bceSAndroid Build Coastguard Worker }
614*35238bceSAndroid Build Coastguard Worker
generateTestName(const vector<PartialUpdateTest::DrawType> & oddFrameDrawType,const vector<PartialUpdateTest::DrawType> & evenFrameDrawType)615*35238bceSAndroid Build Coastguard Worker string generateTestName(const vector<PartialUpdateTest::DrawType> &oddFrameDrawType,
616*35238bceSAndroid Build Coastguard Worker const vector<PartialUpdateTest::DrawType> &evenFrameDrawType)
617*35238bceSAndroid Build Coastguard Worker {
618*35238bceSAndroid Build Coastguard Worker return "odd" + generateDrawTypeName(oddFrameDrawType) + "_even" + generateDrawTypeName(evenFrameDrawType);
619*35238bceSAndroid Build Coastguard Worker }
620*35238bceSAndroid Build Coastguard Worker
isWindow(const eglu::CandidateConfig & c)621*35238bceSAndroid Build Coastguard Worker bool isWindow(const eglu::CandidateConfig &c)
622*35238bceSAndroid Build Coastguard Worker {
623*35238bceSAndroid Build Coastguard Worker return (c.surfaceType() & EGL_WINDOW_BIT) == EGL_WINDOW_BIT;
624*35238bceSAndroid Build Coastguard Worker }
625*35238bceSAndroid Build Coastguard Worker
isES2Renderable(const eglu::CandidateConfig & c)626*35238bceSAndroid Build Coastguard Worker bool isES2Renderable(const eglu::CandidateConfig &c)
627*35238bceSAndroid Build Coastguard Worker {
628*35238bceSAndroid Build Coastguard Worker return (c.get(EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT) == EGL_OPENGL_ES2_BIT;
629*35238bceSAndroid Build Coastguard Worker }
630*35238bceSAndroid Build Coastguard Worker
getEGLConfig(const Library & egl,EGLDisplay eglDisplay)631*35238bceSAndroid Build Coastguard Worker EGLConfig getEGLConfig(const Library &egl, EGLDisplay eglDisplay)
632*35238bceSAndroid Build Coastguard Worker {
633*35238bceSAndroid Build Coastguard Worker eglu::FilterList filters;
634*35238bceSAndroid Build Coastguard Worker filters << isWindow << isES2Renderable;
635*35238bceSAndroid Build Coastguard Worker return eglu::chooseSingleConfig(egl, eglDisplay, filters);
636*35238bceSAndroid Build Coastguard Worker }
637*35238bceSAndroid Build Coastguard Worker
clearColorScreen(const glw::Functions & gl,const tcu::Vec4 & clearColor)638*35238bceSAndroid Build Coastguard Worker void clearColorScreen(const glw::Functions &gl, const tcu::Vec4 &clearColor)
639*35238bceSAndroid Build Coastguard Worker {
640*35238bceSAndroid Build Coastguard Worker gl.clearColor(clearColor.x(), clearColor.y(), clearColor.z(), clearColor.w());
641*35238bceSAndroid Build Coastguard Worker gl.clear(GL_COLOR_BUFFER_BIT);
642*35238bceSAndroid Build Coastguard Worker }
643*35238bceSAndroid Build Coastguard Worker
clearColorReference(tcu::Surface * ref,const tcu::Vec4 & clearColor)644*35238bceSAndroid Build Coastguard Worker void clearColorReference(tcu::Surface *ref, const tcu::Vec4 &clearColor)
645*35238bceSAndroid Build Coastguard Worker {
646*35238bceSAndroid Build Coastguard Worker tcu::clear(ref->getAccess(), clearColor);
647*35238bceSAndroid Build Coastguard Worker }
648*35238bceSAndroid Build Coastguard Worker
readPixels(const glw::Functions & gl,tcu::Surface * screen)649*35238bceSAndroid Build Coastguard Worker void readPixels(const glw::Functions &gl, tcu::Surface *screen)
650*35238bceSAndroid Build Coastguard Worker {
651*35238bceSAndroid Build Coastguard Worker gl.readPixels(0, 0, screen->getWidth(), screen->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE,
652*35238bceSAndroid Build Coastguard Worker screen->getAccess().getDataPtr());
653*35238bceSAndroid Build Coastguard Worker }
654*35238bceSAndroid Build Coastguard Worker
windowToDeviceCoordinates(int x,int length)655*35238bceSAndroid Build Coastguard Worker float windowToDeviceCoordinates(int x, int length)
656*35238bceSAndroid Build Coastguard Worker {
657*35238bceSAndroid Build Coastguard Worker return (2.0f * float(x) / float(length)) - 1.0f;
658*35238bceSAndroid Build Coastguard Worker }
659*35238bceSAndroid Build Coastguard Worker
compareToReference(tcu::TestLog & log,const tcu::Surface & reference,const tcu::Surface & buffer,int frameNdx,int bufferNum)660*35238bceSAndroid Build Coastguard Worker bool compareToReference(tcu::TestLog &log, const tcu::Surface &reference, const tcu::Surface &buffer, int frameNdx,
661*35238bceSAndroid Build Coastguard Worker int bufferNum)
662*35238bceSAndroid Build Coastguard Worker {
663*35238bceSAndroid Build Coastguard Worker std::ostringstream stream;
664*35238bceSAndroid Build Coastguard Worker stream << "FrameNdx = " << frameNdx << ", compare current buffer (numbered: " << bufferNum << ") to reference";
665*35238bceSAndroid Build Coastguard Worker return tcu::intThresholdPositionDeviationCompare(log, "partial update test", stream.str().c_str(),
666*35238bceSAndroid Build Coastguard Worker reference.getAccess(), buffer.getAccess(), tcu::UVec4(8, 8, 8, 0),
667*35238bceSAndroid Build Coastguard Worker tcu::IVec3(2, 2, 0), true, tcu::COMPARE_LOG_RESULT);
668*35238bceSAndroid Build Coastguard Worker }
669*35238bceSAndroid Build Coastguard Worker
670*35238bceSAndroid Build Coastguard Worker class RenderOutsideDamageRegion : public PartialUpdateTest
671*35238bceSAndroid Build Coastguard Worker {
672*35238bceSAndroid Build Coastguard Worker public:
673*35238bceSAndroid Build Coastguard Worker RenderOutsideDamageRegion(EglTestContext &eglTestCtx);
674*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult iterate(void);
675*35238bceSAndroid Build Coastguard Worker };
676*35238bceSAndroid Build Coastguard Worker
RenderOutsideDamageRegion(EglTestContext & eglTestCtx)677*35238bceSAndroid Build Coastguard Worker RenderOutsideDamageRegion::RenderOutsideDamageRegion(EglTestContext &eglTestCtx)
678*35238bceSAndroid Build Coastguard Worker : PartialUpdateTest(eglTestCtx, vector<DrawType>(1, DRAWTYPE_GLES2_RENDER),
679*35238bceSAndroid Build Coastguard Worker vector<DrawType>(1, DRAWTYPE_GLES2_RENDER), "render_outside_damage_region", "")
680*35238bceSAndroid Build Coastguard Worker {
681*35238bceSAndroid Build Coastguard Worker }
682*35238bceSAndroid Build Coastguard Worker
iterate(void)683*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult RenderOutsideDamageRegion::iterate(void)
684*35238bceSAndroid Build Coastguard Worker {
685*35238bceSAndroid Build Coastguard Worker de::Random rnd(m_seed);
686*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
687*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
688*35238bceSAndroid Build Coastguard Worker const int width = eglu::querySurfaceInt(egl, m_eglDisplay, m_eglSurface, EGL_WIDTH);
689*35238bceSAndroid Build Coastguard Worker const int height = eglu::querySurfaceInt(egl, m_eglDisplay, m_eglSurface, EGL_HEIGHT);
690*35238bceSAndroid Build Coastguard Worker const float clearRed = rnd.getFloat();
691*35238bceSAndroid Build Coastguard Worker const float clearGreen = rnd.getFloat();
692*35238bceSAndroid Build Coastguard Worker const float clearBlue = rnd.getFloat();
693*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 clearColor(clearRed, clearGreen, clearBlue, 1.0f);
694*35238bceSAndroid Build Coastguard Worker tcu::Surface currentBuffer(width, height);
695*35238bceSAndroid Build Coastguard Worker tcu::Surface refBuffer(width, height);
696*35238bceSAndroid Build Coastguard Worker Frame frame(width, height);
697*35238bceSAndroid Build Coastguard Worker
698*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
699*35238bceSAndroid Build Coastguard Worker
700*35238bceSAndroid Build Coastguard Worker generateRandomFrame(frame, m_evenFrameDrawType, rnd);
701*35238bceSAndroid Build Coastguard Worker
702*35238bceSAndroid Build Coastguard Worker {
703*35238bceSAndroid Build Coastguard Worker // render outside the region
704*35238bceSAndroid Build Coastguard Worker EGLint bufferAge = -1;
705*35238bceSAndroid Build Coastguard Worker vector<EGLint> damageRegion = getDamageRegion(frame, 0, 0, 0, 0);
706*35238bceSAndroid Build Coastguard Worker
707*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, querySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
708*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(
709*35238bceSAndroid Build Coastguard Worker egl, setDamageRegionKHR(m_eglDisplay, m_eglSurface, &damageRegion[0], (EGLint)damageRegion.size() / 4));
710*35238bceSAndroid Build Coastguard Worker clearColorScreen(m_gl, clearColor);
711*35238bceSAndroid Build Coastguard Worker m_gles2Renderer->render(width, height, frame);
712*35238bceSAndroid Build Coastguard Worker
713*35238bceSAndroid Build Coastguard Worker // next line will make the bug on Nexus 6 disappear
714*35238bceSAndroid Build Coastguard Worker // readPixels(m_gl, ¤tBuffer);
715*35238bceSAndroid Build Coastguard Worker }
716*35238bceSAndroid Build Coastguard Worker
717*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, swapBuffers(m_eglDisplay, m_eglSurface));
718*35238bceSAndroid Build Coastguard Worker
719*35238bceSAndroid Build Coastguard Worker // render a new frame
720*35238bceSAndroid Build Coastguard Worker clearColorScreen(m_gl, clearColor);
721*35238bceSAndroid Build Coastguard Worker m_gles2Renderer->render(width, height, frame);
722*35238bceSAndroid Build Coastguard Worker clearColorReference(&refBuffer, clearColor);
723*35238bceSAndroid Build Coastguard Worker m_refRenderer->render(&refBuffer, frame);
724*35238bceSAndroid Build Coastguard Worker readPixels(m_gl, ¤tBuffer);
725*35238bceSAndroid Build Coastguard Worker
726*35238bceSAndroid Build Coastguard Worker if (!compareToReference(log, refBuffer, currentBuffer, 0, 0))
727*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail, fail to recover after rendering outside damageRegion");
728*35238bceSAndroid Build Coastguard Worker else
729*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
730*35238bceSAndroid Build Coastguard Worker
731*35238bceSAndroid Build Coastguard Worker return STOP;
732*35238bceSAndroid Build Coastguard Worker }
733*35238bceSAndroid Build Coastguard Worker
734*35238bceSAndroid Build Coastguard Worker class RenderBeforeSetDamageRegion : public PartialUpdateTest
735*35238bceSAndroid Build Coastguard Worker {
736*35238bceSAndroid Build Coastguard Worker public:
737*35238bceSAndroid Build Coastguard Worker RenderBeforeSetDamageRegion(EglTestContext &eglTestCtx);
738*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult iterate(void);
739*35238bceSAndroid Build Coastguard Worker };
740*35238bceSAndroid Build Coastguard Worker
RenderBeforeSetDamageRegion(EglTestContext & eglTestCtx)741*35238bceSAndroid Build Coastguard Worker RenderBeforeSetDamageRegion::RenderBeforeSetDamageRegion(EglTestContext &eglTestCtx)
742*35238bceSAndroid Build Coastguard Worker : PartialUpdateTest(eglTestCtx, vector<DrawType>(1, DRAWTYPE_GLES2_RENDER),
743*35238bceSAndroid Build Coastguard Worker vector<DrawType>(1, DRAWTYPE_GLES2_RENDER), "render_before_set_damage_region", "")
744*35238bceSAndroid Build Coastguard Worker {
745*35238bceSAndroid Build Coastguard Worker }
746*35238bceSAndroid Build Coastguard Worker
iterate(void)747*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult RenderBeforeSetDamageRegion::iterate(void)
748*35238bceSAndroid Build Coastguard Worker {
749*35238bceSAndroid Build Coastguard Worker de::Random rnd(m_seed);
750*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
751*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
752*35238bceSAndroid Build Coastguard Worker const int width = eglu::querySurfaceInt(egl, m_eglDisplay, m_eglSurface, EGL_WIDTH);
753*35238bceSAndroid Build Coastguard Worker const int height = eglu::querySurfaceInt(egl, m_eglDisplay, m_eglSurface, EGL_HEIGHT);
754*35238bceSAndroid Build Coastguard Worker const float clearRed = rnd.getFloat();
755*35238bceSAndroid Build Coastguard Worker const float clearGreen = rnd.getFloat();
756*35238bceSAndroid Build Coastguard Worker const float clearBlue = rnd.getFloat();
757*35238bceSAndroid Build Coastguard Worker const tcu::Vec4 clearColor(clearRed, clearGreen, clearBlue, 1.0f);
758*35238bceSAndroid Build Coastguard Worker tcu::Surface currentBuffer(width, height);
759*35238bceSAndroid Build Coastguard Worker tcu::Surface refBuffer(width, height);
760*35238bceSAndroid Build Coastguard Worker Frame frame(width, height);
761*35238bceSAndroid Build Coastguard Worker
762*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
763*35238bceSAndroid Build Coastguard Worker
764*35238bceSAndroid Build Coastguard Worker generateRandomFrame(frame, m_evenFrameDrawType, rnd);
765*35238bceSAndroid Build Coastguard Worker
766*35238bceSAndroid Build Coastguard Worker {
767*35238bceSAndroid Build Coastguard Worker // render before setDamageRegion
768*35238bceSAndroid Build Coastguard Worker EGLint bufferAge = -1;
769*35238bceSAndroid Build Coastguard Worker vector<EGLint> damageRegion = getDamageRegion(frame, 0, 0, 0, 0);
770*35238bceSAndroid Build Coastguard Worker
771*35238bceSAndroid Build Coastguard Worker m_gles2Renderer->render(width, height, frame);
772*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, querySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
773*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(
774*35238bceSAndroid Build Coastguard Worker egl, setDamageRegionKHR(m_eglDisplay, m_eglSurface, &damageRegion[0], (EGLint)damageRegion.size() / 4));
775*35238bceSAndroid Build Coastguard Worker
776*35238bceSAndroid Build Coastguard Worker // next line will make the bug on Nexus 6 disappear
777*35238bceSAndroid Build Coastguard Worker // readPixels(m_gl, ¤tBuffer);
778*35238bceSAndroid Build Coastguard Worker }
779*35238bceSAndroid Build Coastguard Worker
780*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_CALL(egl, swapBuffers(m_eglDisplay, m_eglSurface));
781*35238bceSAndroid Build Coastguard Worker
782*35238bceSAndroid Build Coastguard Worker // render a new frame
783*35238bceSAndroid Build Coastguard Worker clearColorScreen(m_gl, clearColor);
784*35238bceSAndroid Build Coastguard Worker m_gles2Renderer->render(width, height, frame);
785*35238bceSAndroid Build Coastguard Worker clearColorReference(&refBuffer, clearColor);
786*35238bceSAndroid Build Coastguard Worker m_refRenderer->render(&refBuffer, frame);
787*35238bceSAndroid Build Coastguard Worker readPixels(m_gl, ¤tBuffer);
788*35238bceSAndroid Build Coastguard Worker
789*35238bceSAndroid Build Coastguard Worker if (!compareToReference(log, refBuffer, currentBuffer, 0, 0))
790*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
791*35238bceSAndroid Build Coastguard Worker else
792*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
793*35238bceSAndroid Build Coastguard Worker
794*35238bceSAndroid Build Coastguard Worker return STOP;
795*35238bceSAndroid Build Coastguard Worker }
796*35238bceSAndroid Build Coastguard Worker
797*35238bceSAndroid Build Coastguard Worker } // namespace
798*35238bceSAndroid Build Coastguard Worker
PartialUpdateTests(EglTestContext & eglTestCtx)799*35238bceSAndroid Build Coastguard Worker PartialUpdateTests::PartialUpdateTests(EglTestContext &eglTestCtx)
800*35238bceSAndroid Build Coastguard Worker : TestCaseGroup(eglTestCtx, "partial_update", "Partial update tests")
801*35238bceSAndroid Build Coastguard Worker {
802*35238bceSAndroid Build Coastguard Worker }
803*35238bceSAndroid Build Coastguard Worker
init(void)804*35238bceSAndroid Build Coastguard Worker void PartialUpdateTests::init(void)
805*35238bceSAndroid Build Coastguard Worker {
806*35238bceSAndroid Build Coastguard Worker const PartialUpdateTest::DrawType clearRender[2] = {PartialUpdateTest::DRAWTYPE_GLES2_CLEAR,
807*35238bceSAndroid Build Coastguard Worker PartialUpdateTest::DRAWTYPE_GLES2_RENDER};
808*35238bceSAndroid Build Coastguard Worker
809*35238bceSAndroid Build Coastguard Worker const PartialUpdateTest::DrawType renderClear[2] = {PartialUpdateTest::DRAWTYPE_GLES2_RENDER,
810*35238bceSAndroid Build Coastguard Worker PartialUpdateTest::DRAWTYPE_GLES2_CLEAR};
811*35238bceSAndroid Build Coastguard Worker
812*35238bceSAndroid Build Coastguard Worker vector<vector<PartialUpdateTest::DrawType>> frameDrawTypes;
813*35238bceSAndroid Build Coastguard Worker frameDrawTypes.push_back(vector<PartialUpdateTest::DrawType>());
814*35238bceSAndroid Build Coastguard Worker frameDrawTypes.push_back(vector<PartialUpdateTest::DrawType>(1, PartialUpdateTest::DRAWTYPE_GLES2_CLEAR));
815*35238bceSAndroid Build Coastguard Worker frameDrawTypes.push_back(vector<PartialUpdateTest::DrawType>(1, PartialUpdateTest::DRAWTYPE_GLES2_RENDER));
816*35238bceSAndroid Build Coastguard Worker frameDrawTypes.push_back(vector<PartialUpdateTest::DrawType>(2, PartialUpdateTest::DRAWTYPE_GLES2_CLEAR));
817*35238bceSAndroid Build Coastguard Worker frameDrawTypes.push_back(vector<PartialUpdateTest::DrawType>(2, PartialUpdateTest::DRAWTYPE_GLES2_RENDER));
818*35238bceSAndroid Build Coastguard Worker frameDrawTypes.push_back(
819*35238bceSAndroid Build Coastguard Worker vector<PartialUpdateTest::DrawType>(DE_ARRAY_BEGIN(clearRender), DE_ARRAY_END(clearRender)));
820*35238bceSAndroid Build Coastguard Worker frameDrawTypes.push_back(
821*35238bceSAndroid Build Coastguard Worker vector<PartialUpdateTest::DrawType>(DE_ARRAY_BEGIN(renderClear), DE_ARRAY_END(renderClear)));
822*35238bceSAndroid Build Coastguard Worker
823*35238bceSAndroid Build Coastguard Worker for (size_t evenNdx = 0; evenNdx < frameDrawTypes.size(); evenNdx++)
824*35238bceSAndroid Build Coastguard Worker {
825*35238bceSAndroid Build Coastguard Worker const vector<PartialUpdateTest::DrawType> &evenFrameDrawType = frameDrawTypes[evenNdx];
826*35238bceSAndroid Build Coastguard Worker
827*35238bceSAndroid Build Coastguard Worker for (size_t oddNdx = evenNdx; oddNdx < frameDrawTypes.size(); oddNdx++)
828*35238bceSAndroid Build Coastguard Worker {
829*35238bceSAndroid Build Coastguard Worker const vector<PartialUpdateTest::DrawType> &oddFrameDrawType = frameDrawTypes[oddNdx];
830*35238bceSAndroid Build Coastguard Worker const std::string name = generateTestName(oddFrameDrawType, evenFrameDrawType);
831*35238bceSAndroid Build Coastguard Worker if (oddFrameDrawType.size() == 0 && evenFrameDrawType.size() == 0)
832*35238bceSAndroid Build Coastguard Worker continue;
833*35238bceSAndroid Build Coastguard Worker
834*35238bceSAndroid Build Coastguard Worker addChild(new PartialUpdateTest(m_eglTestCtx, oddFrameDrawType, evenFrameDrawType, name.c_str(), ""));
835*35238bceSAndroid Build Coastguard Worker }
836*35238bceSAndroid Build Coastguard Worker }
837*35238bceSAndroid Build Coastguard Worker addChild(new RenderOutsideDamageRegion(m_eglTestCtx));
838*35238bceSAndroid Build Coastguard Worker addChild(new RenderBeforeSetDamageRegion(m_eglTestCtx));
839*35238bceSAndroid Build Coastguard Worker }
840*35238bceSAndroid Build Coastguard Worker
841*35238bceSAndroid Build Coastguard Worker } // namespace egl
842*35238bceSAndroid Build Coastguard Worker } // namespace deqp
843