xref: /aosp_15_r20/external/deqp/modules/egl/teglNegativePartialUpdateTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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 negative use case of KHR_partial_update
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "teglNegativePartialUpdateTests.hpp"
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp"
28*35238bceSAndroid Build Coastguard Worker 
29*35238bceSAndroid Build Coastguard Worker #include "egluCallLogWrapper.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "egluConfigFilter.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "egluNativeWindow.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "egluStrUtil.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "egluUnique.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
35*35238bceSAndroid Build Coastguard Worker 
36*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
38*35238bceSAndroid Build Coastguard Worker 
39*35238bceSAndroid Build Coastguard Worker using namespace eglu;
40*35238bceSAndroid Build Coastguard Worker using namespace eglw;
41*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
42*35238bceSAndroid Build Coastguard Worker 
43*35238bceSAndroid Build Coastguard Worker namespace deqp
44*35238bceSAndroid Build Coastguard Worker {
45*35238bceSAndroid Build Coastguard Worker namespace egl
46*35238bceSAndroid Build Coastguard Worker {
47*35238bceSAndroid Build Coastguard Worker namespace
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker 
50*35238bceSAndroid Build Coastguard Worker class NegativePartialUpdateTest : public TestCase
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker public:
53*35238bceSAndroid Build Coastguard Worker     enum SurfaceType // used as a bit field when selecting a suitable EGL config
54*35238bceSAndroid Build Coastguard Worker     {
55*35238bceSAndroid Build Coastguard Worker         SURFACETYPE_WINDOW  = 1 << 0,
56*35238bceSAndroid Build Coastguard Worker         SURFACETYPE_PBUFFER = 1 << 1
57*35238bceSAndroid Build Coastguard Worker     };
58*35238bceSAndroid Build Coastguard Worker 
59*35238bceSAndroid Build Coastguard Worker     NegativePartialUpdateTest(EglTestContext &eglTestCtx, bool preserveBuffer, SurfaceType surfaceType,
60*35238bceSAndroid Build Coastguard Worker                               const char *name, const char *description);
61*35238bceSAndroid Build Coastguard Worker     ~NegativePartialUpdateTest(void);
62*35238bceSAndroid Build Coastguard Worker     void init(void);
63*35238bceSAndroid Build Coastguard Worker     void deinit(void);
64*35238bceSAndroid Build Coastguard Worker     virtual IterateResult iterate(void) = 0;
65*35238bceSAndroid Build Coastguard Worker 
66*35238bceSAndroid Build Coastguard Worker protected:
67*35238bceSAndroid Build Coastguard Worker     void expectError(eglw::EGLenum error);
68*35238bceSAndroid Build Coastguard Worker     void expectBoolean(EGLBoolean expected, EGLBoolean got);
expectTrue(eglw::EGLBoolean got)69*35238bceSAndroid Build Coastguard Worker     inline void expectTrue(eglw::EGLBoolean got)
70*35238bceSAndroid Build Coastguard Worker     {
71*35238bceSAndroid Build Coastguard Worker         expectBoolean(EGL_TRUE, got);
72*35238bceSAndroid Build Coastguard Worker     }
expectFalse(eglw::EGLBoolean got)73*35238bceSAndroid Build Coastguard Worker     inline void expectFalse(eglw::EGLBoolean got)
74*35238bceSAndroid Build Coastguard Worker     {
75*35238bceSAndroid Build Coastguard Worker         expectBoolean(EGL_FALSE, got);
76*35238bceSAndroid Build Coastguard Worker     }
77*35238bceSAndroid Build Coastguard Worker 
78*35238bceSAndroid Build Coastguard Worker     const bool m_preserveBuffer;
79*35238bceSAndroid Build Coastguard Worker     SurfaceType m_surfaceType;
80*35238bceSAndroid Build Coastguard Worker     EGLDisplay m_eglDisplay;
81*35238bceSAndroid Build Coastguard Worker     EGLConfig m_eglConfig;
82*35238bceSAndroid Build Coastguard Worker     NativeWindow *m_window;
83*35238bceSAndroid Build Coastguard Worker     EGLSurface m_eglSurface;
84*35238bceSAndroid Build Coastguard Worker     EGLContext m_eglContext;
85*35238bceSAndroid Build Coastguard Worker };
86*35238bceSAndroid Build Coastguard Worker 
isWindow(const CandidateConfig & c)87*35238bceSAndroid Build Coastguard Worker bool isWindow(const CandidateConfig &c)
88*35238bceSAndroid Build Coastguard Worker {
89*35238bceSAndroid Build Coastguard Worker     return (c.surfaceType() & EGL_WINDOW_BIT) == EGL_WINDOW_BIT;
90*35238bceSAndroid Build Coastguard Worker }
91*35238bceSAndroid Build Coastguard Worker 
isPbuffer(const CandidateConfig & c)92*35238bceSAndroid Build Coastguard Worker bool isPbuffer(const CandidateConfig &c)
93*35238bceSAndroid Build Coastguard Worker {
94*35238bceSAndroid Build Coastguard Worker     return (c.surfaceType() & EGL_PBUFFER_BIT) == EGL_PBUFFER_BIT;
95*35238bceSAndroid Build Coastguard Worker }
96*35238bceSAndroid Build Coastguard Worker 
isES2Renderable(const CandidateConfig & c)97*35238bceSAndroid Build Coastguard Worker bool isES2Renderable(const CandidateConfig &c)
98*35238bceSAndroid Build Coastguard Worker {
99*35238bceSAndroid Build Coastguard Worker     return (c.get(EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT) == EGL_OPENGL_ES2_BIT;
100*35238bceSAndroid Build Coastguard Worker }
101*35238bceSAndroid Build Coastguard Worker 
hasPreserveSwap(const CandidateConfig & c)102*35238bceSAndroid Build Coastguard Worker bool hasPreserveSwap(const CandidateConfig &c)
103*35238bceSAndroid Build Coastguard Worker {
104*35238bceSAndroid Build Coastguard Worker     return (c.surfaceType() & EGL_SWAP_BEHAVIOR_PRESERVED_BIT) == EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
105*35238bceSAndroid Build Coastguard Worker }
106*35238bceSAndroid Build Coastguard Worker 
getEGLConfig(const Library & egl,EGLDisplay eglDisplay,unsigned surfaceTypes,bool preserveBuffer)107*35238bceSAndroid Build Coastguard Worker EGLConfig getEGLConfig(const Library &egl, EGLDisplay eglDisplay, unsigned surfaceTypes, bool preserveBuffer)
108*35238bceSAndroid Build Coastguard Worker {
109*35238bceSAndroid Build Coastguard Worker     FilterList filters;
110*35238bceSAndroid Build Coastguard Worker     if ((surfaceTypes & NegativePartialUpdateTest::SURFACETYPE_WINDOW) != 0)
111*35238bceSAndroid Build Coastguard Worker         filters << isWindow;
112*35238bceSAndroid Build Coastguard Worker     if ((surfaceTypes & NegativePartialUpdateTest::SURFACETYPE_PBUFFER) != 0)
113*35238bceSAndroid Build Coastguard Worker         filters << isPbuffer;
114*35238bceSAndroid Build Coastguard Worker     if (((surfaceTypes & NegativePartialUpdateTest::SURFACETYPE_WINDOW) == 0) &&
115*35238bceSAndroid Build Coastguard Worker         ((surfaceTypes & NegativePartialUpdateTest::SURFACETYPE_PBUFFER) == 0))
116*35238bceSAndroid Build Coastguard Worker         DE_FATAL("Invalid surfaceType");
117*35238bceSAndroid Build Coastguard Worker 
118*35238bceSAndroid Build Coastguard Worker     filters << isES2Renderable;
119*35238bceSAndroid Build Coastguard Worker 
120*35238bceSAndroid Build Coastguard Worker     if (preserveBuffer)
121*35238bceSAndroid Build Coastguard Worker         filters << hasPreserveSwap;
122*35238bceSAndroid Build Coastguard Worker 
123*35238bceSAndroid Build Coastguard Worker     return chooseSingleConfig(egl, eglDisplay, filters);
124*35238bceSAndroid Build Coastguard Worker }
125*35238bceSAndroid Build Coastguard Worker 
initAndMakeCurrentEGLContext(const Library & egl,EGLDisplay eglDisplay,EGLSurface eglSurface,EGLConfig eglConfig,const EGLint * attribList)126*35238bceSAndroid Build Coastguard Worker EGLContext initAndMakeCurrentEGLContext(const Library &egl, EGLDisplay eglDisplay, EGLSurface eglSurface,
127*35238bceSAndroid Build Coastguard Worker                                         EGLConfig eglConfig, const EGLint *attribList)
128*35238bceSAndroid Build Coastguard Worker {
129*35238bceSAndroid Build Coastguard Worker     EGLContext eglContext = EGL_NO_CONTEXT;
130*35238bceSAndroid Build Coastguard Worker 
131*35238bceSAndroid Build Coastguard Worker     egl.bindAPI(EGL_OPENGL_ES_API);
132*35238bceSAndroid Build Coastguard Worker     eglContext = egl.createContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, attribList);
133*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_MSG(egl, "eglCreateContext");
134*35238bceSAndroid Build Coastguard Worker     TCU_CHECK(eglSurface != EGL_NO_SURFACE);
135*35238bceSAndroid Build Coastguard Worker     egl.makeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
136*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_MSG(egl, "eglMakeCurrent");
137*35238bceSAndroid Build Coastguard Worker 
138*35238bceSAndroid Build Coastguard Worker     return eglContext;
139*35238bceSAndroid Build Coastguard Worker }
140*35238bceSAndroid Build Coastguard Worker 
NegativePartialUpdateTest(EglTestContext & eglTestCtx,bool preserveBuffer,SurfaceType surfaceType,const char * name,const char * description)141*35238bceSAndroid Build Coastguard Worker NegativePartialUpdateTest::NegativePartialUpdateTest(EglTestContext &eglTestCtx, bool preserveBuffer,
142*35238bceSAndroid Build Coastguard Worker                                                      SurfaceType surfaceType, const char *name, const char *description)
143*35238bceSAndroid Build Coastguard Worker     : TestCase(eglTestCtx, name, description)
144*35238bceSAndroid Build Coastguard Worker     , m_preserveBuffer(preserveBuffer)
145*35238bceSAndroid Build Coastguard Worker     , m_surfaceType(surfaceType)
146*35238bceSAndroid Build Coastguard Worker     , m_eglDisplay(EGL_NO_DISPLAY)
147*35238bceSAndroid Build Coastguard Worker     , m_window(DE_NULL)
148*35238bceSAndroid Build Coastguard Worker     , m_eglSurface(EGL_NO_SURFACE)
149*35238bceSAndroid Build Coastguard Worker     , m_eglContext(EGL_NO_CONTEXT)
150*35238bceSAndroid Build Coastguard Worker {
151*35238bceSAndroid Build Coastguard Worker }
152*35238bceSAndroid Build Coastguard Worker 
~NegativePartialUpdateTest(void)153*35238bceSAndroid Build Coastguard Worker NegativePartialUpdateTest::~NegativePartialUpdateTest(void)
154*35238bceSAndroid Build Coastguard Worker {
155*35238bceSAndroid Build Coastguard Worker     deinit();
156*35238bceSAndroid Build Coastguard Worker }
157*35238bceSAndroid Build Coastguard Worker 
init(void)158*35238bceSAndroid Build Coastguard Worker void NegativePartialUpdateTest::init(void)
159*35238bceSAndroid Build Coastguard Worker {
160*35238bceSAndroid Build Coastguard Worker     const Library &egl                      = m_eglTestCtx.getLibrary();
161*35238bceSAndroid Build Coastguard Worker     static const EGLint contextAttribList[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
162*35238bceSAndroid Build Coastguard Worker     const int width                         = 480;
163*35238bceSAndroid Build Coastguard Worker     const int height                        = 480;
164*35238bceSAndroid Build Coastguard Worker 
165*35238bceSAndroid Build Coastguard Worker     m_eglDisplay = getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
166*35238bceSAndroid Build Coastguard Worker 
167*35238bceSAndroid Build Coastguard Worker     if (!hasExtension(egl, m_eglDisplay, "EGL_KHR_partial_update"))
168*35238bceSAndroid Build Coastguard Worker         TCU_THROW(NotSupportedError, "EGL_KHR_partial_update is not supported");
169*35238bceSAndroid Build Coastguard Worker 
170*35238bceSAndroid Build Coastguard Worker     if (m_surfaceType == SURFACETYPE_PBUFFER)
171*35238bceSAndroid Build Coastguard Worker     {
172*35238bceSAndroid Build Coastguard Worker         m_eglConfig                      = getEGLConfig(egl, m_eglDisplay, SURFACETYPE_PBUFFER, m_preserveBuffer);
173*35238bceSAndroid Build Coastguard Worker         const EGLint pbufferAttribList[] = {EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE};
174*35238bceSAndroid Build Coastguard Worker         m_eglSurface                     = egl.createPbufferSurface(m_eglDisplay, m_eglConfig, pbufferAttribList);
175*35238bceSAndroid Build Coastguard Worker     }
176*35238bceSAndroid Build Coastguard Worker     else
177*35238bceSAndroid Build Coastguard Worker     {
178*35238bceSAndroid Build Coastguard Worker         m_eglConfig = getEGLConfig(egl, m_eglDisplay, SURFACETYPE_WINDOW | SURFACETYPE_PBUFFER, m_preserveBuffer);
179*35238bceSAndroid Build Coastguard Worker         const NativeWindowFactory &factory =
180*35238bceSAndroid Build Coastguard Worker             selectNativeWindowFactory(m_eglTestCtx.getNativeDisplayFactory(), m_testCtx.getCommandLine());
181*35238bceSAndroid Build Coastguard Worker         m_window = factory.createWindow(&m_eglTestCtx.getNativeDisplay(), m_eglDisplay, m_eglConfig, DE_NULL,
182*35238bceSAndroid Build Coastguard Worker                                         WindowParams(width, height, parseWindowVisibility(m_testCtx.getCommandLine())));
183*35238bceSAndroid Build Coastguard Worker         m_eglSurface =
184*35238bceSAndroid Build Coastguard Worker             createWindowSurface(m_eglTestCtx.getNativeDisplay(), *m_window, m_eglDisplay, m_eglConfig, DE_NULL);
185*35238bceSAndroid Build Coastguard Worker     }
186*35238bceSAndroid Build Coastguard Worker     m_eglContext = initAndMakeCurrentEGLContext(egl, m_eglDisplay, m_eglSurface, m_eglConfig, contextAttribList);
187*35238bceSAndroid Build Coastguard Worker }
188*35238bceSAndroid Build Coastguard Worker 
deinit(void)189*35238bceSAndroid Build Coastguard Worker void NegativePartialUpdateTest::deinit(void)
190*35238bceSAndroid Build Coastguard Worker {
191*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
192*35238bceSAndroid Build Coastguard Worker 
193*35238bceSAndroid Build Coastguard Worker     if (m_eglContext != EGL_NO_CONTEXT)
194*35238bceSAndroid Build Coastguard Worker     {
195*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
196*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, destroyContext(m_eglDisplay, m_eglContext));
197*35238bceSAndroid Build Coastguard Worker         m_eglContext = EGL_NO_CONTEXT;
198*35238bceSAndroid Build Coastguard Worker     }
199*35238bceSAndroid Build Coastguard Worker 
200*35238bceSAndroid Build Coastguard Worker     if (m_eglSurface != EGL_NO_SURFACE)
201*35238bceSAndroid Build Coastguard Worker     {
202*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, destroySurface(m_eglDisplay, m_eglSurface));
203*35238bceSAndroid Build Coastguard Worker         m_eglSurface = EGL_NO_SURFACE;
204*35238bceSAndroid Build Coastguard Worker     }
205*35238bceSAndroid Build Coastguard Worker 
206*35238bceSAndroid Build Coastguard Worker     if (m_eglDisplay != EGL_NO_DISPLAY)
207*35238bceSAndroid Build Coastguard Worker     {
208*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, terminate(m_eglDisplay));
209*35238bceSAndroid Build Coastguard Worker         m_eglDisplay = EGL_NO_DISPLAY;
210*35238bceSAndroid Build Coastguard Worker     }
211*35238bceSAndroid Build Coastguard Worker 
212*35238bceSAndroid Build Coastguard Worker     delete m_window;
213*35238bceSAndroid Build Coastguard Worker     m_window = DE_NULL;
214*35238bceSAndroid Build Coastguard Worker }
215*35238bceSAndroid Build Coastguard Worker 
expectError(EGLenum expected)216*35238bceSAndroid Build Coastguard Worker void NegativePartialUpdateTest::expectError(EGLenum expected)
217*35238bceSAndroid Build Coastguard Worker {
218*35238bceSAndroid Build Coastguard Worker     const EGLenum err = m_eglTestCtx.getLibrary().getError();
219*35238bceSAndroid Build Coastguard Worker 
220*35238bceSAndroid Build Coastguard Worker     if (err != expected)
221*35238bceSAndroid Build Coastguard Worker     {
222*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getErrorStr(expected)
223*35238bceSAndroid Build Coastguard Worker                            << ", Got: " << eglu::getErrorStr(err) << TestLog::EndMessage;
224*35238bceSAndroid Build Coastguard Worker         if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
225*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error");
226*35238bceSAndroid Build Coastguard Worker     }
227*35238bceSAndroid Build Coastguard Worker }
228*35238bceSAndroid Build Coastguard Worker 
expectBoolean(EGLBoolean expected,EGLBoolean got)229*35238bceSAndroid Build Coastguard Worker void NegativePartialUpdateTest::expectBoolean(EGLBoolean expected, EGLBoolean got)
230*35238bceSAndroid Build Coastguard Worker {
231*35238bceSAndroid Build Coastguard Worker     if (expected != got)
232*35238bceSAndroid Build Coastguard Worker     {
233*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getBooleanStr(expected)
234*35238bceSAndroid Build Coastguard Worker                            << ", Got: " << eglu::getBooleanStr(got) << TestLog::EndMessage;
235*35238bceSAndroid Build Coastguard Worker         if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
236*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value");
237*35238bceSAndroid Build Coastguard Worker     }
238*35238bceSAndroid Build Coastguard Worker }
239*35238bceSAndroid Build Coastguard Worker 
240*35238bceSAndroid Build Coastguard Worker class NotPostableTest : public NegativePartialUpdateTest
241*35238bceSAndroid Build Coastguard Worker {
242*35238bceSAndroid Build Coastguard Worker public:
243*35238bceSAndroid Build Coastguard Worker     NotPostableTest(EglTestContext &context);
244*35238bceSAndroid Build Coastguard Worker     TestCase::IterateResult iterate(void);
245*35238bceSAndroid Build Coastguard Worker };
246*35238bceSAndroid Build Coastguard Worker 
NotPostableTest(EglTestContext & context)247*35238bceSAndroid Build Coastguard Worker NotPostableTest::NotPostableTest(EglTestContext &context)
248*35238bceSAndroid Build Coastguard Worker     : NegativePartialUpdateTest(context, false, SURFACETYPE_PBUFFER, "not_postable_surface",
249*35238bceSAndroid Build Coastguard Worker                                 "Call setDamageRegion() on pbuffer")
250*35238bceSAndroid Build Coastguard Worker {
251*35238bceSAndroid Build Coastguard Worker }
252*35238bceSAndroid Build Coastguard Worker 
iterate(void)253*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult NotPostableTest::iterate(void)
254*35238bceSAndroid Build Coastguard Worker {
255*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
256*35238bceSAndroid Build Coastguard Worker     TestLog &log       = m_testCtx.getLog();
257*35238bceSAndroid Build Coastguard Worker     CallLogWrapper wrapper(egl, log);
258*35238bceSAndroid Build Coastguard Worker     EGLint damageRegion[] = {10, 10, 10, 10};
259*35238bceSAndroid Build Coastguard Worker     int bufferAge         = -1;
260*35238bceSAndroid Build Coastguard Worker 
261*35238bceSAndroid Build Coastguard Worker     wrapper.enableLogging(true);
262*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
263*35238bceSAndroid Build Coastguard Worker     {
264*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(log, "Test1", "If the surface is pbuffer (not postable) --> EGL_BAD_MATCH");
265*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
266*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, querySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
267*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion,
268*35238bceSAndroid Build Coastguard Worker                                                   DE_LENGTH_OF_ARRAY(damageRegion) / 4));
269*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_MATCH);
270*35238bceSAndroid Build Coastguard Worker     }
271*35238bceSAndroid Build Coastguard Worker 
272*35238bceSAndroid Build Coastguard Worker     return STOP;
273*35238bceSAndroid Build Coastguard Worker }
274*35238bceSAndroid Build Coastguard Worker 
275*35238bceSAndroid Build Coastguard Worker class NotCurrentSurfaceTest : public NegativePartialUpdateTest
276*35238bceSAndroid Build Coastguard Worker {
277*35238bceSAndroid Build Coastguard Worker public:
278*35238bceSAndroid Build Coastguard Worker     NotCurrentSurfaceTest(EglTestContext &context);
279*35238bceSAndroid Build Coastguard Worker     TestCase::IterateResult iterate(void);
280*35238bceSAndroid Build Coastguard Worker };
281*35238bceSAndroid Build Coastguard Worker 
NotCurrentSurfaceTest(EglTestContext & context)282*35238bceSAndroid Build Coastguard Worker NotCurrentSurfaceTest::NotCurrentSurfaceTest(EglTestContext &context)
283*35238bceSAndroid Build Coastguard Worker     : NegativePartialUpdateTest(context, false, SURFACETYPE_WINDOW, "not_current_surface",
284*35238bceSAndroid Build Coastguard Worker                                 "Call setDamageRegion() on pbuffer")
285*35238bceSAndroid Build Coastguard Worker {
286*35238bceSAndroid Build Coastguard Worker }
287*35238bceSAndroid Build Coastguard Worker 
iterate(void)288*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult NotCurrentSurfaceTest::iterate(void)
289*35238bceSAndroid Build Coastguard Worker {
290*35238bceSAndroid Build Coastguard Worker     const int impossibleBufferAge = -26084;
291*35238bceSAndroid Build Coastguard Worker     const Library &egl            = m_eglTestCtx.getLibrary();
292*35238bceSAndroid Build Coastguard Worker     const EGLint attribList[]     = {EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE};
293*35238bceSAndroid Build Coastguard Worker     const eglu::UniqueSurface unusedPbuffer(egl, m_eglDisplay,
294*35238bceSAndroid Build Coastguard Worker                                             egl.createPbufferSurface(m_eglDisplay, m_eglConfig, attribList));
295*35238bceSAndroid Build Coastguard Worker     TestLog &log = m_testCtx.getLog();
296*35238bceSAndroid Build Coastguard Worker     CallLogWrapper wrapper(egl, log);
297*35238bceSAndroid Build Coastguard Worker     EGLint damageRegion[] = {10, 10, 10, 10};
298*35238bceSAndroid Build Coastguard Worker     int bufferAge         = impossibleBufferAge;
299*35238bceSAndroid Build Coastguard Worker 
300*35238bceSAndroid Build Coastguard Worker     wrapper.enableLogging(true);
301*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
302*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, *unusedPbuffer, *unusedPbuffer, m_eglContext));
303*35238bceSAndroid Build Coastguard Worker     {
304*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(
305*35238bceSAndroid Build Coastguard Worker             log, "Test2.1",
306*35238bceSAndroid Build Coastguard Worker             "If query buffer age on a surface that is not the current draw surface --> EGL_BAD_SURFACE");
307*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
308*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
309*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_SURFACE);
310*35238bceSAndroid Build Coastguard Worker 
311*35238bceSAndroid Build Coastguard Worker         if (bufferAge != impossibleBufferAge)
312*35238bceSAndroid Build Coastguard Worker         {
313*35238bceSAndroid Build Coastguard Worker             log << tcu::TestLog::Message
314*35238bceSAndroid Build Coastguard Worker                 << "On failure, eglQuerySurface shouldn't change buffer age but buffer age has been changed to "
315*35238bceSAndroid Build Coastguard Worker                 << bufferAge << tcu::TestLog::EndMessage;
316*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail, bufferAge shouldn't be changed");
317*35238bceSAndroid Build Coastguard Worker         }
318*35238bceSAndroid Build Coastguard Worker     }
319*35238bceSAndroid Build Coastguard Worker     {
320*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(
321*35238bceSAndroid Build Coastguard Worker             log, "Test2.2",
322*35238bceSAndroid Build Coastguard Worker             "If call setDamageRegion() on a surface that is not the current draw surface --> EGL_BAD_MATCH");
323*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion, 1));
324*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_MATCH);
325*35238bceSAndroid Build Coastguard Worker     }
326*35238bceSAndroid Build Coastguard Worker 
327*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
328*35238bceSAndroid Build Coastguard Worker     {
329*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(
330*35238bceSAndroid Build Coastguard Worker             log, "Test3.1",
331*35238bceSAndroid Build Coastguard Worker             "If query buffer age on a surface that is not the current draw surface --> EGL_BAD_SURFACE");
332*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
333*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
334*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_SURFACE);
335*35238bceSAndroid Build Coastguard Worker 
336*35238bceSAndroid Build Coastguard Worker         if (bufferAge != impossibleBufferAge)
337*35238bceSAndroid Build Coastguard Worker         {
338*35238bceSAndroid Build Coastguard Worker             log << tcu::TestLog::Message
339*35238bceSAndroid Build Coastguard Worker                 << "On failure, eglQuerySurface shouldn't change buffer age but buffer age has been changed to "
340*35238bceSAndroid Build Coastguard Worker                 << bufferAge << tcu::TestLog::EndMessage;
341*35238bceSAndroid Build Coastguard Worker             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail, bufferAge shouldn't be changed");
342*35238bceSAndroid Build Coastguard Worker         }
343*35238bceSAndroid Build Coastguard Worker     }
344*35238bceSAndroid Build Coastguard Worker     {
345*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(
346*35238bceSAndroid Build Coastguard Worker             log, "Test3.2",
347*35238bceSAndroid Build Coastguard Worker             "If call setDamageRegion() on a surface that is not the current draw surface --> EGL_BAD_MATCH");
348*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion, 1));
349*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_MATCH);
350*35238bceSAndroid Build Coastguard Worker     }
351*35238bceSAndroid Build Coastguard Worker 
352*35238bceSAndroid Build Coastguard Worker     if (hasExtension(egl, m_eglDisplay, "EGL_KHR_surfaceless_context"))
353*35238bceSAndroid Build Coastguard Worker     {
354*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, m_eglContext));
355*35238bceSAndroid Build Coastguard Worker         {
356*35238bceSAndroid Build Coastguard Worker             tcu::ScopedLogSection(
357*35238bceSAndroid Build Coastguard Worker                 log, "Test4.1",
358*35238bceSAndroid Build Coastguard Worker                 "If query buffer age on a surface that is not the current draw surface --> EGL_BAD_SURFACE");
359*35238bceSAndroid Build Coastguard Worker             EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
360*35238bceSAndroid Build Coastguard Worker             expectFalse(wrapper.eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
361*35238bceSAndroid Build Coastguard Worker             expectError(EGL_BAD_SURFACE);
362*35238bceSAndroid Build Coastguard Worker 
363*35238bceSAndroid Build Coastguard Worker             if (bufferAge != impossibleBufferAge)
364*35238bceSAndroid Build Coastguard Worker             {
365*35238bceSAndroid Build Coastguard Worker                 log << tcu::TestLog::Message
366*35238bceSAndroid Build Coastguard Worker                     << "On failure, eglQuerySurface shouldn't change buffer age but buffer age has been changed to "
367*35238bceSAndroid Build Coastguard Worker                     << bufferAge << tcu::TestLog::EndMessage;
368*35238bceSAndroid Build Coastguard Worker                 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail, bufferAge shouldn't be changed");
369*35238bceSAndroid Build Coastguard Worker             }
370*35238bceSAndroid Build Coastguard Worker         }
371*35238bceSAndroid Build Coastguard Worker         {
372*35238bceSAndroid Build Coastguard Worker             tcu::ScopedLogSection(
373*35238bceSAndroid Build Coastguard Worker                 log, "Test4.2",
374*35238bceSAndroid Build Coastguard Worker                 "If call setDamageRegion() on a surface that is not the current draw surface --> EGL_BAD_MATCH");
375*35238bceSAndroid Build Coastguard Worker             expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion, 1));
376*35238bceSAndroid Build Coastguard Worker             expectError(EGL_BAD_MATCH);
377*35238bceSAndroid Build Coastguard Worker         }
378*35238bceSAndroid Build Coastguard Worker     }
379*35238bceSAndroid Build Coastguard Worker 
380*35238bceSAndroid Build Coastguard Worker     return STOP;
381*35238bceSAndroid Build Coastguard Worker }
382*35238bceSAndroid Build Coastguard Worker 
383*35238bceSAndroid Build Coastguard Worker class BufferPreservedTest : public NegativePartialUpdateTest
384*35238bceSAndroid Build Coastguard Worker {
385*35238bceSAndroid Build Coastguard Worker public:
386*35238bceSAndroid Build Coastguard Worker     BufferPreservedTest(EglTestContext &context);
387*35238bceSAndroid Build Coastguard Worker     TestCase::IterateResult iterate(void);
388*35238bceSAndroid Build Coastguard Worker };
389*35238bceSAndroid Build Coastguard Worker 
BufferPreservedTest(EglTestContext & context)390*35238bceSAndroid Build Coastguard Worker BufferPreservedTest::BufferPreservedTest(EglTestContext &context)
391*35238bceSAndroid Build Coastguard Worker     : NegativePartialUpdateTest(context, true, SURFACETYPE_WINDOW, "buffer_preserved",
392*35238bceSAndroid Build Coastguard Worker                                 "Call setDamageRegion() on pbuffer")
393*35238bceSAndroid Build Coastguard Worker {
394*35238bceSAndroid Build Coastguard Worker }
395*35238bceSAndroid Build Coastguard Worker 
iterate(void)396*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult BufferPreservedTest::iterate(void)
397*35238bceSAndroid Build Coastguard Worker {
398*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
399*35238bceSAndroid Build Coastguard Worker     TestLog &log       = m_testCtx.getLog();
400*35238bceSAndroid Build Coastguard Worker     CallLogWrapper wrapper(egl, log);
401*35238bceSAndroid Build Coastguard Worker     EGLint damageRegion[] = {10, 10, 10, 10};
402*35238bceSAndroid Build Coastguard Worker     int bufferAge         = -1;
403*35238bceSAndroid Build Coastguard Worker 
404*35238bceSAndroid Build Coastguard Worker     wrapper.enableLogging(true);
405*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
406*35238bceSAndroid Build Coastguard Worker     {
407*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(log, "Test3", "If buffer_preserved --> EGL_BAD_MATCH");
408*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED));
409*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, querySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
410*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion,
411*35238bceSAndroid Build Coastguard Worker                                                   DE_LENGTH_OF_ARRAY(damageRegion) / 4));
412*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_MATCH);
413*35238bceSAndroid Build Coastguard Worker     }
414*35238bceSAndroid Build Coastguard Worker 
415*35238bceSAndroid Build Coastguard Worker     return STOP;
416*35238bceSAndroid Build Coastguard Worker }
417*35238bceSAndroid Build Coastguard Worker 
418*35238bceSAndroid Build Coastguard Worker class SetTwiceTest : public NegativePartialUpdateTest
419*35238bceSAndroid Build Coastguard Worker {
420*35238bceSAndroid Build Coastguard Worker public:
421*35238bceSAndroid Build Coastguard Worker     SetTwiceTest(EglTestContext &context);
422*35238bceSAndroid Build Coastguard Worker     TestCase::IterateResult iterate(void);
423*35238bceSAndroid Build Coastguard Worker };
424*35238bceSAndroid Build Coastguard Worker 
SetTwiceTest(EglTestContext & context)425*35238bceSAndroid Build Coastguard Worker SetTwiceTest::SetTwiceTest(EglTestContext &context)
426*35238bceSAndroid Build Coastguard Worker     : NegativePartialUpdateTest(context, false, SURFACETYPE_WINDOW, "set_damage_region_twice",
427*35238bceSAndroid Build Coastguard Worker                                 "Call setDamageRegion() twice")
428*35238bceSAndroid Build Coastguard Worker {
429*35238bceSAndroid Build Coastguard Worker }
430*35238bceSAndroid Build Coastguard Worker 
iterate(void)431*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult SetTwiceTest::iterate(void)
432*35238bceSAndroid Build Coastguard Worker {
433*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
434*35238bceSAndroid Build Coastguard Worker     TestLog &log       = m_testCtx.getLog();
435*35238bceSAndroid Build Coastguard Worker     CallLogWrapper wrapper(egl, log);
436*35238bceSAndroid Build Coastguard Worker     EGLint damageRegion[] = {10, 10, 10, 10};
437*35238bceSAndroid Build Coastguard Worker     int bufferAge         = -1;
438*35238bceSAndroid Build Coastguard Worker 
439*35238bceSAndroid Build Coastguard Worker     wrapper.enableLogging(true);
440*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
441*35238bceSAndroid Build Coastguard Worker     {
442*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(log, "Test4", "If call setDamageRegion() twice --> EGL_BAD_ACCESS");
443*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
444*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, querySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
445*35238bceSAndroid Build Coastguard Worker         expectTrue(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion,
446*35238bceSAndroid Build Coastguard Worker                                                  DE_LENGTH_OF_ARRAY(damageRegion) / 4));
447*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion,
448*35238bceSAndroid Build Coastguard Worker                                                   DE_LENGTH_OF_ARRAY(damageRegion) / 4));
449*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_ACCESS);
450*35238bceSAndroid Build Coastguard Worker     }
451*35238bceSAndroid Build Coastguard Worker 
452*35238bceSAndroid Build Coastguard Worker     return STOP;
453*35238bceSAndroid Build Coastguard Worker }
454*35238bceSAndroid Build Coastguard Worker 
455*35238bceSAndroid Build Coastguard Worker class NoAgeTest : public NegativePartialUpdateTest
456*35238bceSAndroid Build Coastguard Worker {
457*35238bceSAndroid Build Coastguard Worker public:
458*35238bceSAndroid Build Coastguard Worker     NoAgeTest(EglTestContext &context);
459*35238bceSAndroid Build Coastguard Worker     TestCase::IterateResult iterate(void);
460*35238bceSAndroid Build Coastguard Worker };
461*35238bceSAndroid Build Coastguard Worker 
NoAgeTest(EglTestContext & context)462*35238bceSAndroid Build Coastguard Worker NoAgeTest::NoAgeTest(EglTestContext &context)
463*35238bceSAndroid Build Coastguard Worker     : NegativePartialUpdateTest(context, false, SURFACETYPE_WINDOW, "set_damage_region_before_query_age",
464*35238bceSAndroid Build Coastguard Worker                                 "Call setDamageRegion() without querying buffer age")
465*35238bceSAndroid Build Coastguard Worker {
466*35238bceSAndroid Build Coastguard Worker }
467*35238bceSAndroid Build Coastguard Worker 
iterate(void)468*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult NoAgeTest::iterate(void)
469*35238bceSAndroid Build Coastguard Worker {
470*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
471*35238bceSAndroid Build Coastguard Worker     TestLog &log       = m_testCtx.getLog();
472*35238bceSAndroid Build Coastguard Worker     CallLogWrapper wrapper(egl, log);
473*35238bceSAndroid Build Coastguard Worker     EGLint damageRegion[] = {10, 10, 10, 10};
474*35238bceSAndroid Build Coastguard Worker 
475*35238bceSAndroid Build Coastguard Worker     wrapper.enableLogging(true);
476*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
477*35238bceSAndroid Build Coastguard Worker     {
478*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(log, "Test5", "If buffer age is not queried --> EGL_BAD_ACCESS");
479*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
480*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion,
481*35238bceSAndroid Build Coastguard Worker                                                   DE_LENGTH_OF_ARRAY(damageRegion) / 4));
482*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_ACCESS);
483*35238bceSAndroid Build Coastguard Worker     }
484*35238bceSAndroid Build Coastguard Worker 
485*35238bceSAndroid Build Coastguard Worker     return STOP;
486*35238bceSAndroid Build Coastguard Worker }
487*35238bceSAndroid Build Coastguard Worker 
488*35238bceSAndroid Build Coastguard Worker class PassNullTest : public NegativePartialUpdateTest
489*35238bceSAndroid Build Coastguard Worker {
490*35238bceSAndroid Build Coastguard Worker public:
491*35238bceSAndroid Build Coastguard Worker     PassNullTest(EglTestContext &context);
492*35238bceSAndroid Build Coastguard Worker     TestCase::IterateResult iterate(void);
493*35238bceSAndroid Build Coastguard Worker };
494*35238bceSAndroid Build Coastguard Worker 
PassNullTest(EglTestContext & context)495*35238bceSAndroid Build Coastguard Worker PassNullTest::PassNullTest(EglTestContext &context)
496*35238bceSAndroid Build Coastguard Worker     : NegativePartialUpdateTest(context, false, SURFACETYPE_WINDOW, "pass_null_0_as_params",
497*35238bceSAndroid Build Coastguard Worker                                 "Call setDamageRegion() with (NULL, 0)")
498*35238bceSAndroid Build Coastguard Worker {
499*35238bceSAndroid Build Coastguard Worker }
500*35238bceSAndroid Build Coastguard Worker 
iterate(void)501*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult PassNullTest::iterate(void)
502*35238bceSAndroid Build Coastguard Worker {
503*35238bceSAndroid Build Coastguard Worker     const Library &egl = m_eglTestCtx.getLibrary();
504*35238bceSAndroid Build Coastguard Worker     TestLog &log       = m_testCtx.getLog();
505*35238bceSAndroid Build Coastguard Worker     CallLogWrapper wrapper(egl, log);
506*35238bceSAndroid Build Coastguard Worker     int bufferAge = -1;
507*35238bceSAndroid Build Coastguard Worker 
508*35238bceSAndroid Build Coastguard Worker     wrapper.enableLogging(true);
509*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
510*35238bceSAndroid Build Coastguard Worker     {
511*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(log, "Test6", "If pass (null, 0) to setDamageRegion(), no error");
512*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
513*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, querySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
514*35238bceSAndroid Build Coastguard Worker         expectTrue(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, DE_NULL, 0));
515*35238bceSAndroid Build Coastguard Worker         expectError(EGL_SUCCESS);
516*35238bceSAndroid Build Coastguard Worker     }
517*35238bceSAndroid Build Coastguard Worker 
518*35238bceSAndroid Build Coastguard Worker     return STOP;
519*35238bceSAndroid Build Coastguard Worker }
520*35238bceSAndroid Build Coastguard Worker 
521*35238bceSAndroid Build Coastguard Worker class NotCurrentSurfaceTest2 : public NegativePartialUpdateTest
522*35238bceSAndroid Build Coastguard Worker {
523*35238bceSAndroid Build Coastguard Worker public:
524*35238bceSAndroid Build Coastguard Worker     NotCurrentSurfaceTest2(EglTestContext &context);
525*35238bceSAndroid Build Coastguard Worker     TestCase::IterateResult iterate(void);
526*35238bceSAndroid Build Coastguard Worker };
527*35238bceSAndroid Build Coastguard Worker 
NotCurrentSurfaceTest2(EglTestContext & context)528*35238bceSAndroid Build Coastguard Worker NotCurrentSurfaceTest2::NotCurrentSurfaceTest2(EglTestContext &context)
529*35238bceSAndroid Build Coastguard Worker     : NegativePartialUpdateTest(context, false, SURFACETYPE_WINDOW, "not_current_surface2",
530*35238bceSAndroid Build Coastguard Worker                                 "Call setDamageRegion() on pbuffer")
531*35238bceSAndroid Build Coastguard Worker {
532*35238bceSAndroid Build Coastguard Worker }
533*35238bceSAndroid Build Coastguard Worker 
iterate(void)534*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult NotCurrentSurfaceTest2::iterate(void)
535*35238bceSAndroid Build Coastguard Worker {
536*35238bceSAndroid Build Coastguard Worker     const Library &egl        = m_eglTestCtx.getLibrary();
537*35238bceSAndroid Build Coastguard Worker     const EGLint attribList[] = {EGL_WIDTH, 64, EGL_HEIGHT, 64, EGL_NONE};
538*35238bceSAndroid Build Coastguard Worker     const eglu::UniqueSurface unusedPbuffer(egl, m_eglDisplay,
539*35238bceSAndroid Build Coastguard Worker                                             egl.createPbufferSurface(m_eglDisplay, m_eglConfig, attribList));
540*35238bceSAndroid Build Coastguard Worker     TestLog &log = m_testCtx.getLog();
541*35238bceSAndroid Build Coastguard Worker     CallLogWrapper wrapper(egl, log);
542*35238bceSAndroid Build Coastguard Worker     EGLint damageRegion[] = {10, 10, 10, 10};
543*35238bceSAndroid Build Coastguard Worker     int bufferAge         = -1;
544*35238bceSAndroid Build Coastguard Worker 
545*35238bceSAndroid Build Coastguard Worker     wrapper.enableLogging(true);
546*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
547*35238bceSAndroid Build Coastguard Worker 
548*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_CALL(egl, surfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED));
549*35238bceSAndroid Build Coastguard Worker     EGLU_CHECK_CALL(egl, querySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_KHR, &bufferAge));
550*35238bceSAndroid Build Coastguard Worker 
551*35238bceSAndroid Build Coastguard Worker     {
552*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(
553*35238bceSAndroid Build Coastguard Worker             log, "Test7",
554*35238bceSAndroid Build Coastguard Worker             "If call setDamageRegion() on a surface that is not the current draw surface --> EGL_BAD_MATCH");
555*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, *unusedPbuffer, *unusedPbuffer, m_eglContext));
556*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion, 1));
557*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_MATCH);
558*35238bceSAndroid Build Coastguard Worker     }
559*35238bceSAndroid Build Coastguard Worker     {
560*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(
561*35238bceSAndroid Build Coastguard Worker             log, "Test8",
562*35238bceSAndroid Build Coastguard Worker             "If call setDamageRegion() on a surface that is not the current draw surface --> EGL_BAD_MATCH");
563*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
564*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion, 1));
565*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_MATCH);
566*35238bceSAndroid Build Coastguard Worker     }
567*35238bceSAndroid Build Coastguard Worker     if (hasExtension(egl, m_eglDisplay, "EGL_KHR_surfaceless_context"))
568*35238bceSAndroid Build Coastguard Worker     {
569*35238bceSAndroid Build Coastguard Worker         tcu::ScopedLogSection(
570*35238bceSAndroid Build Coastguard Worker             log, "Test9",
571*35238bceSAndroid Build Coastguard Worker             "If call setDamageRegion() on a surface that is not the current draw surface --> EGL_BAD_MATCH");
572*35238bceSAndroid Build Coastguard Worker         EGLU_CHECK_CALL(egl, makeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, m_eglContext));
573*35238bceSAndroid Build Coastguard Worker         expectFalse(wrapper.eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, damageRegion, 1));
574*35238bceSAndroid Build Coastguard Worker         expectError(EGL_BAD_MATCH);
575*35238bceSAndroid Build Coastguard Worker     }
576*35238bceSAndroid Build Coastguard Worker 
577*35238bceSAndroid Build Coastguard Worker     return STOP;
578*35238bceSAndroid Build Coastguard Worker }
579*35238bceSAndroid Build Coastguard Worker 
580*35238bceSAndroid Build Coastguard Worker } // namespace
581*35238bceSAndroid Build Coastguard Worker 
NegativePartialUpdateTests(EglTestContext & eglTestCtx)582*35238bceSAndroid Build Coastguard Worker NegativePartialUpdateTests::NegativePartialUpdateTests(EglTestContext &eglTestCtx)
583*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(eglTestCtx, "negative_partial_update", "Negative partial update tests")
584*35238bceSAndroid Build Coastguard Worker {
585*35238bceSAndroid Build Coastguard Worker }
586*35238bceSAndroid Build Coastguard Worker 
init(void)587*35238bceSAndroid Build Coastguard Worker void NegativePartialUpdateTests::init(void)
588*35238bceSAndroid Build Coastguard Worker {
589*35238bceSAndroid Build Coastguard Worker     addChild(new NotPostableTest(m_eglTestCtx));
590*35238bceSAndroid Build Coastguard Worker     addChild(new NotCurrentSurfaceTest(m_eglTestCtx));
591*35238bceSAndroid Build Coastguard Worker     addChild(new BufferPreservedTest(m_eglTestCtx));
592*35238bceSAndroid Build Coastguard Worker     addChild(new SetTwiceTest(m_eglTestCtx));
593*35238bceSAndroid Build Coastguard Worker     addChild(new NoAgeTest(m_eglTestCtx));
594*35238bceSAndroid Build Coastguard Worker     addChild(new PassNullTest(m_eglTestCtx));
595*35238bceSAndroid Build Coastguard Worker     addChild(new NotCurrentSurfaceTest2(m_eglTestCtx));
596*35238bceSAndroid Build Coastguard Worker }
597*35238bceSAndroid Build Coastguard Worker 
598*35238bceSAndroid Build Coastguard Worker } // namespace egl
599*35238bceSAndroid Build Coastguard Worker } // namespace deqp
600