1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief EGL image tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "teglImageTests.hpp"
25
26 #include "teglImageUtil.hpp"
27 #include "teglAndroidUtil.hpp"
28 #include "teglImageFormatTests.hpp"
29
30 #include "egluNativeDisplay.hpp"
31 #include "egluNativeWindow.hpp"
32 #include "egluNativePixmap.hpp"
33 #include "egluStrUtil.hpp"
34 #include "egluUnique.hpp"
35 #include "egluUtil.hpp"
36 #include "egluGLUtil.hpp"
37
38 #include "eglwLibrary.hpp"
39 #include "eglwEnums.hpp"
40
41 #include "gluDefs.hpp"
42 #include "gluCallLogWrapper.hpp"
43 #include "gluObjectWrapper.hpp"
44 #include "gluStrUtil.hpp"
45
46 #include "glwDefs.hpp"
47 #include "glwEnums.hpp"
48
49 #include "tcuTestLog.hpp"
50 #include "tcuCommandLine.hpp"
51
52 #include "deUniquePtr.hpp"
53
54 #include <algorithm>
55 #include <sstream>
56 #include <string>
57 #include <vector>
58 #include <set>
59
60 using tcu::TestLog;
61
62 using std::string;
63 using std::vector;
64 using std::set;
65 using std::ostringstream;
66
67 using de::MovePtr;
68 using de::UniquePtr;
69 using glu::ApiType;
70 using glu::ContextType;
71 using glu::Texture;
72 using eglu::AttribMap;
73 using eglu::NativeWindow;
74 using eglu::NativePixmap;
75 using eglu::UniqueImage;
76 using eglu::UniqueSurface;
77 using eglu::ScopedCurrentContext;
78
79 using namespace glw;
80 using namespace eglw;
81
82 namespace deqp
83 {
84 namespace egl
85 {
86
87 namespace Image
88 {
89
90 #define CHECK_EXTENSION(DPY, EXTNAME) \
91 TCU_CHECK_AND_THROW(NotSupportedError, eglu::hasExtension(m_eglTestCtx.getLibrary(), DPY, EXTNAME), (string("Unsupported extension: ") + (EXTNAME)).c_str())
92
93 template <typename RetVal>
checkCallError(EglTestContext & eglTestCtx,const char * call,RetVal returnValue,EGLint expectError)94 RetVal checkCallError (EglTestContext& eglTestCtx, const char* call, RetVal returnValue, EGLint expectError)
95 {
96 tcu::TestContext& testCtx = eglTestCtx.getTestContext();
97 TestLog& log = testCtx.getLog();
98 EGLint error;
99
100 log << TestLog::Message << call << TestLog::EndMessage;
101
102 error = eglTestCtx.getLibrary().getError();
103
104 if (error != expectError)
105 {
106 log << TestLog::Message << " Fail: Error code mismatch! Expected " << eglu::getErrorStr(expectError) << ", got " << eglu::getErrorStr(error) << TestLog::EndMessage;
107 log << TestLog::Message << " " << returnValue << " was returned" << TestLog::EndMessage;
108
109 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
110 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid error code");
111 }
112
113 return returnValue;
114 }
115
116 template <typename RetVal>
checkCallReturn(EglTestContext & eglTestCtx,const char * call,RetVal returnValue,RetVal expectReturnValue,EGLint expectError)117 void checkCallReturn (EglTestContext& eglTestCtx, const char* call, RetVal returnValue, RetVal expectReturnValue, EGLint expectError)
118 {
119 tcu::TestContext& testCtx = eglTestCtx.getTestContext();
120 TestLog& log = testCtx.getLog();
121 EGLint error;
122
123 log << TestLog::Message << call << TestLog::EndMessage;
124
125 error = eglTestCtx.getLibrary().getError();
126
127 if (returnValue != expectReturnValue)
128 {
129 log << TestLog::Message << " Fail: Return value mismatch! Expected " << expectReturnValue << ", got " << returnValue << TestLog::EndMessage;
130
131 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
132 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid return value");
133 }
134
135 if (error != expectError)
136 {
137 log << TestLog::Message << " Fail: Error code mismatch! Expected " << eglu::getErrorStr(expectError) << ", got " << eglu::getErrorStr(error) << TestLog::EndMessage;
138
139 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
140 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid error code");
141 }
142 }
143
144 // \note These macros expect "EglTestContext m_eglTestCtx" to be defined.
145 #define CHECK_EXT_CALL_RET(CALL, EXPECT_RETURN_VALUE, EXPECT_ERROR) checkCallReturn(m_eglTestCtx, #CALL, CALL, (EXPECT_RETURN_VALUE), (EXPECT_ERROR))
146 #define CHECK_EXT_CALL_ERR(CALL, EXPECT_ERROR) checkCallError(m_eglTestCtx, #CALL, CALL, (EXPECT_ERROR))
147
148 class ImageTestCase : public TestCase, public glu::CallLogWrapper
149 {
150 public:
ImageTestCase(EglTestContext & eglTestCtx,ApiType api,const string & name,const string & desc)151 ImageTestCase (EglTestContext& eglTestCtx, ApiType api, const string& name, const string& desc)
152 : TestCase (eglTestCtx, name.c_str(), desc.c_str())
153 , glu::CallLogWrapper (m_gl, m_testCtx.getLog())
154 , m_api (api)
155 , m_display (EGL_NO_DISPLAY)
156 {
157 }
158
init(void)159 void init (void)
160 {
161 DE_ASSERT(m_display == EGL_NO_DISPLAY);
162 m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
163
164 const char* extensions[] = { "GL_OES_EGL_image" };
165 m_eglTestCtx.initGLFunctions(&m_gl, m_api, DE_LENGTH_OF_ARRAY(extensions), &extensions[0]);
166 }
167
deinit(void)168 void deinit (void)
169 {
170 m_eglTestCtx.getLibrary().terminate(m_display);
171 m_display = EGL_NO_DISPLAY;
172 }
173
isGLRedSupported(void)174 bool isGLRedSupported (void)
175 {
176 return m_api.getMajorVersion() >= 3 || glu::hasExtension(m_gl, m_api, "GL_EXT_texture_rg");
177 }
178
179 protected:
180 glw::Functions m_gl;
181 ApiType m_api;
182 EGLDisplay m_display;
183 };
184
185 class InvalidCreateImage : public ImageTestCase
186 {
187 public:
InvalidCreateImage(EglTestContext & eglTestCtx)188 InvalidCreateImage (EglTestContext& eglTestCtx)
189 : ImageTestCase(eglTestCtx, ApiType::es(2, 0), "invalid_create_image", "eglCreateImageKHR() with invalid arguments")
190 {
191 }
192
193 void checkCreate (const char* desc, EGLDisplay dpy, const char* dpyStr, EGLContext context, const char* ctxStr, EGLenum source, const char* srcStr, EGLint expectError);
194
iterate(void)195 IterateResult iterate (void)
196 {
197 const Library& egl = m_eglTestCtx.getLibrary();
198
199 if (eglu::getVersion(egl, m_display) < eglu::Version(1, 5) &&
200 !eglu::hasExtension(egl, m_display, "EGL_KHR_image") &&
201 !eglu::hasExtension(egl, m_display, "EGL_KHR_image_base"))
202 {
203 TCU_THROW(NotSupportedError, "EGLimages not supported");
204 }
205
206 #define CHECK_CREATE(MSG, DPY, CONTEXT, SOURCE, ERR) checkCreate(MSG, DPY, #DPY, CONTEXT, #CONTEXT, SOURCE, #SOURCE, ERR)
207 CHECK_CREATE("Testing bad display (-1)...", (EGLDisplay)-1, EGL_NO_CONTEXT, EGL_NONE, EGL_BAD_DISPLAY);
208 CHECK_CREATE("Testing bad context (-1)...", m_display, (EGLContext)-1, EGL_NONE, EGL_BAD_CONTEXT);
209 CHECK_CREATE("Testing bad source (-1)...", m_display, EGL_NO_CONTEXT, (EGLenum)-1, EGL_BAD_PARAMETER);
210 #undef CHECK_CREATE
211
212 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
213 return STOP;
214 }
215
216 };
217
checkCreate(const char * msg,EGLDisplay dpy,const char * dpyStr,EGLContext context,const char * ctxStr,EGLenum source,const char * srcStr,EGLint expectError)218 void InvalidCreateImage::checkCreate (const char* msg, EGLDisplay dpy, const char* dpyStr, EGLContext context, const char* ctxStr, EGLenum source, const char* srcStr, EGLint expectError)
219 {
220 m_testCtx.getLog() << TestLog::Message << msg << TestLog::EndMessage;
221 {
222 const Library& egl = m_eglTestCtx.getLibrary();
223 const EGLImageKHR image = egl.createImageKHR(dpy, context, source, 0, DE_NULL);
224 ostringstream call;
225
226 call << "eglCreateImage(" << dpyStr << ", " << ctxStr << ", " << srcStr << ", 0, DE_NULL)";
227 checkCallReturn(m_eglTestCtx, call.str().c_str(), image, EGL_NO_IMAGE_KHR, expectError);
228 }
229 }
230
chooseConfig(const Library & egl,EGLDisplay display,ApiType apiType)231 EGLConfig chooseConfig (const Library& egl, EGLDisplay display, ApiType apiType)
232 {
233 AttribMap attribs;
234 vector<EGLConfig> configs;
235 // Prefer configs in order: pbuffer, window, pixmap
236 static const EGLenum s_surfaceTypes[] = { EGL_PBUFFER_BIT, EGL_WINDOW_BIT, EGL_PIXMAP_BIT };
237
238 attribs[EGL_RENDERABLE_TYPE] = eglu::apiRenderableType(apiType);
239
240 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_surfaceTypes); ++ndx)
241 {
242 attribs[EGL_SURFACE_TYPE] = s_surfaceTypes[ndx];
243 configs = eglu::chooseConfigs(egl, display, attribs);
244
245 if (!configs.empty())
246 return configs.front();
247 }
248
249 TCU_THROW(NotSupportedError, "No compatible EGL configs found");
250 return (EGLConfig)0;
251 }
252
253 class Context
254 {
255 public:
Context(EglTestContext & eglTestCtx,EGLDisplay display,ContextType ctxType,int width,int height)256 Context (EglTestContext& eglTestCtx, EGLDisplay display, ContextType ctxType, int width, int height)
257 : m_eglTestCtx (eglTestCtx)
258 , m_display (display)
259 , m_config (chooseConfig(eglTestCtx.getLibrary(), display, ctxType.getAPI()))
260 , m_context (m_eglTestCtx.getLibrary(), m_display, eglu::createGLContext(eglTestCtx.getLibrary(), m_display, m_config, ctxType))
261 , m_surface (createSurface(eglTestCtx, m_display, m_config, width, height))
262 , m_current (eglTestCtx.getLibrary(), m_display, m_surface->get(), m_surface->get(), *m_context)
263 {
264 m_eglTestCtx.initGLFunctions(&m_gl, ctxType.getAPI());
265 }
266
getConfig(void) const267 EGLConfig getConfig (void) const { return m_config; }
getEglDisplay(void) const268 EGLDisplay getEglDisplay (void) const { return m_display; }
getEglContext(void) const269 EGLContext getEglContext (void) const { return *m_context; }
gl(void) const270 const glw::Functions& gl (void) const { return m_gl; }
271
272 private:
273 EglTestContext& m_eglTestCtx;
274 EGLDisplay m_display;
275 EGLConfig m_config;
276 eglu::UniqueContext m_context;
277 UniquePtr<ManagedSurface> m_surface;
278 ScopedCurrentContext m_current;
279 glw::Functions m_gl;
280
281 Context (const Context&);
282 Context& operator= (const Context&);
283 };
284
285 class CreateImageGLES2 : public ImageTestCase
286 {
287 public:
getTargetName(EGLint target)288 static const char* getTargetName (EGLint target)
289 {
290 switch (target)
291 {
292 case EGL_GL_TEXTURE_2D_KHR: return "tex2d";
293 case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR: return "cubemap_pos_x";
294 case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR: return "cubemap_neg_x";
295 case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR: return "cubemap_pos_y";
296 case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR: return "cubemap_neg_y";
297 case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR: return "cubemap_pos_z";
298 case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR: return "cubemap_neg_z";
299 case EGL_GL_RENDERBUFFER_KHR: return "renderbuffer";
300 case EGL_NATIVE_BUFFER_ANDROID: return "android_native";
301 default: DE_ASSERT(DE_FALSE); return "";
302 }
303 }
304
getStorageName(GLenum storage)305 static const char* getStorageName (GLenum storage)
306 {
307 switch (storage)
308 {
309 case GL_RED: return "red";
310 case GL_RG: return "rg";
311 case GL_LUMINANCE: return "luminance";
312 case GL_LUMINANCE_ALPHA: return "luminance_alpha";
313 case GL_RGB: return "rgb";
314 case GL_RGBA: return "rgba";
315 case GL_DEPTH_COMPONENT16: return "depth_component_16";
316 case GL_RGBA4: return "rgba4";
317 case GL_RGB5_A1: return "rgb5_a1";
318 case GL_RGB565: return "rgb565";
319 case GL_RGB8: return "rgb8";
320 case GL_RGBA8: return "rgba8";
321 case GL_STENCIL_INDEX8: return "stencil_index8";
322 default:
323 DE_ASSERT(DE_FALSE);
324 return "";
325 }
326 }
327
getImageSource(EGLint target,GLenum internalFormat,GLenum format,GLenum type,bool useTexLevel0)328 MovePtr<ImageSource> getImageSource (EGLint target, GLenum internalFormat, GLenum format, GLenum type, bool useTexLevel0)
329 {
330 switch (target)
331 {
332 case EGL_GL_TEXTURE_2D_KHR:
333 case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR:
334 case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR:
335 case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR:
336 case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR:
337 case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR:
338 case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR:
339 DE_ASSERT(format != 0u && type != 0u);
340 return createTextureImageSource(target, internalFormat, format, type, useTexLevel0);
341
342 case EGL_GL_RENDERBUFFER_KHR:
343 DE_ASSERT(format == 0u && type == 0u);
344 return createRenderbufferImageSource(internalFormat);
345
346 case EGL_NATIVE_BUFFER_ANDROID:
347 DE_ASSERT(format == 0u && type == 0u);
348 return createAndroidNativeImageSource(internalFormat);
349
350 default:
351 DE_FATAL("Impossible");
352 return MovePtr<ImageSource>();
353 }
354 }
355
CreateImageGLES2(EglTestContext & eglTestCtx,EGLint target,GLenum internalFormat,GLenum format,GLenum type,bool useTexLevel0=false)356 CreateImageGLES2 (EglTestContext& eglTestCtx, EGLint target, GLenum internalFormat, GLenum format, GLenum type, bool useTexLevel0 = false)
357 : ImageTestCase (eglTestCtx, ApiType::es(2, 0), string("create_image_gles2_") + getTargetName(target) + "_" + getStorageName(internalFormat) + (useTexLevel0 ? "_level0_only" : ""), "Create EGLImage from GLES2 object")
358 , m_source (getImageSource(target, internalFormat, format, type, useTexLevel0))
359 , m_internalFormat (internalFormat)
360 {
361 }
362
iterate(void)363 IterateResult iterate (void)
364 {
365 const Library& egl = m_eglTestCtx.getLibrary();
366 const EGLDisplay dpy = m_display;
367
368 if (eglu::getVersion(egl, dpy) < eglu::Version(1, 5))
369 CHECK_EXTENSION(dpy, m_source->getRequiredExtension());
370
371 // Initialize result.
372 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
373
374 // Create GLES2 context
375 TestLog& log = m_testCtx.getLog();
376 const ContextType contextType (ApiType::es(2, 0));
377 Context context (m_eglTestCtx, dpy, contextType, 64, 64);
378 const EGLContext eglContext = context.getEglContext();
379
380 if ((m_internalFormat == GL_RED || m_internalFormat == GL_RG) && !isGLRedSupported())
381 TCU_THROW(NotSupportedError, "Unsupported extension: GL_EXT_texture_rg");
382
383 log << TestLog::Message << "Using EGL config " << eglu::getConfigID(egl, dpy, context.getConfig()) << TestLog::EndMessage;
384
385 UniquePtr<ClientBuffer> clientBuffer (m_source->createBuffer(context.gl()));
386 const EGLImageKHR image = m_source->createImage(egl, dpy, eglContext, clientBuffer->get());
387
388 if (image == EGL_NO_IMAGE_KHR)
389 {
390 log << TestLog::Message << " Fail: Got EGL_NO_IMAGE_KHR!" << TestLog::EndMessage;
391
392 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
393 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got EGL_NO_IMAGE_KHR");
394 }
395
396 // Destroy image
397 CHECK_EXT_CALL_RET(egl.destroyImageKHR(context.getEglDisplay(), image), (EGLBoolean)EGL_TRUE, EGL_SUCCESS);
398
399 return STOP;
400 }
401
402 private:
403 const UniquePtr<ImageSource> m_source;
404 const GLenum m_internalFormat;
405 };
406
407 class ImageTargetGLES2 : public ImageTestCase
408 {
409 public:
getTargetName(GLenum target)410 static const char* getTargetName (GLenum target)
411 {
412 switch (target)
413 {
414 case GL_TEXTURE_2D: return "tex2d";
415 case GL_RENDERBUFFER: return "renderbuffer";
416 default:
417 DE_ASSERT(DE_FALSE);
418 return "";
419 }
420 }
421
ImageTargetGLES2(EglTestContext & eglTestCtx,GLenum target)422 ImageTargetGLES2 (EglTestContext& eglTestCtx, GLenum target)
423 : ImageTestCase (eglTestCtx, ApiType::es(2, 0), string("image_target_gles2_") + getTargetName(target), "Use EGLImage as GLES2 object")
424 , m_target (target)
425 {
426 }
427
iterate(void)428 IterateResult iterate (void)
429 {
430 const Library& egl = m_eglTestCtx.getLibrary();
431 TestLog& log = m_testCtx.getLog();
432
433 // \todo [2011-07-21 pyry] Try all possible EGLImage sources
434 CHECK_EXTENSION(m_display, "EGL_KHR_gl_texture_2D_image");
435
436 // Initialize result.
437 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
438
439 // Create GLES2 context
440
441 Context context(m_eglTestCtx, m_display, ContextType(ApiType::es(2, 0)), 64, 64);
442 log << TestLog::Message << "Using EGL config " << eglu::getConfigID(m_eglTestCtx.getLibrary(), context.getEglDisplay(), context.getConfig()) << TestLog::EndMessage;
443
444 // Check for OES_EGL_image
445 {
446 const char* glExt = (const char*)glGetString(GL_EXTENSIONS);
447
448 if (string(glExt).find("GL_OES_EGL_image") == string::npos)
449 throw tcu::NotSupportedError("Extension not supported", "GL_OES_EGL_image", __FILE__, __LINE__);
450
451 TCU_CHECK(m_gl.eglImageTargetTexture2DOES);
452 TCU_CHECK(m_gl.eglImageTargetRenderbufferStorageOES);
453 }
454
455 // Create GL_TEXTURE_2D and EGLImage from it.
456 log << TestLog::Message << "Creating EGLImage using GL_TEXTURE_2D with GL_RGBA storage" << TestLog::EndMessage;
457
458 deUint32 srcTex = 1;
459 GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, srcTex));
460 GLU_CHECK_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL));
461 GLU_CHECK_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
462
463 // Create EGL image
464 EGLint attribs[] = { EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE };
465 EGLImageKHR image = CHECK_EXT_CALL_ERR(egl.createImageKHR(context.getEglDisplay(), context.getEglContext(), EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(deUintptr)srcTex, attribs), EGL_SUCCESS);
466 if (image == EGL_NO_IMAGE_KHR)
467 {
468 log << TestLog::Message << " Fail: Got EGL_NO_IMAGE_KHR!" << TestLog::EndMessage;
469
470 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
471 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got EGL_NO_IMAGE_KHR");
472 }
473
474 // Create texture or renderbuffer
475 if (m_target == GL_TEXTURE_2D)
476 {
477 log << TestLog::Message << "Creating GL_TEXTURE_2D from EGLimage" << TestLog::EndMessage;
478
479 deUint32 dstTex = 2;
480 GLU_CHECK_CALL(glBindTexture(GL_TEXTURE_2D, dstTex));
481 GLU_CHECK_CALL(glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image));
482 GLU_CHECK_CALL(glDeleteTextures(1, &dstTex));
483 }
484 else
485 {
486 DE_ASSERT(m_target == GL_RENDERBUFFER);
487
488 log << TestLog::Message << "Creating GL_RENDERBUFFER from EGLimage" << TestLog::EndMessage;
489
490 deUint32 dstRbo = 2;
491 GLU_CHECK_CALL(glBindRenderbuffer(GL_RENDERBUFFER, dstRbo));
492 GLU_CHECK_CALL(glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, (GLeglImageOES)image));
493 GLU_CHECK_CALL(glDeleteRenderbuffers(1, &dstRbo));
494 }
495
496 // Destroy image
497 CHECK_EXT_CALL_RET(egl.destroyImageKHR(context.getEglDisplay(), image), (EGLBoolean)EGL_TRUE, EGL_SUCCESS);
498
499 // Destroy source texture object
500 GLU_CHECK_CALL(glDeleteTextures(1, &srcTex));
501
502 return STOP;
503 }
504
505 private:
506 GLenum m_target;
507 };
508
509 class ApiTests : public TestCaseGroup
510 {
511 public:
ApiTests(EglTestContext & eglTestCtx,const string & name,const string & desc)512 ApiTests (EglTestContext& eglTestCtx, const string& name, const string& desc) : TestCaseGroup(eglTestCtx, name.c_str(), desc.c_str()) {}
513
init(void)514 void init (void)
515 {
516 addChild(new Image::InvalidCreateImage(m_eglTestCtx));
517
518 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RED, GL_RED, GL_UNSIGNED_BYTE, false));
519 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RG, GL_RG, GL_UNSIGNED_BYTE, false));
520
521 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE));
522 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE));
523
524 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE));
525 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE));
526 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, true));
527
528 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE));
529 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE));
530 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, true));
531
532 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE));
533 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE));
534 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE));
535 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE));
536 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE));
537
538 static const GLenum rboStorages[] =
539 {
540 GL_DEPTH_COMPONENT16,
541 GL_RGBA4,
542 GL_RGB5_A1,
543 GL_RGB565,
544 GL_STENCIL_INDEX8
545 };
546 for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(rboStorages); storageNdx++)
547 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_RENDERBUFFER_KHR, rboStorages[storageNdx], (GLenum)0, (GLenum)0));
548
549 static const GLenum androidFormats[] =
550 {
551 GL_RGB565,
552 GL_RGB8,
553 GL_RGBA4,
554 GL_RGB5_A1,
555 GL_RGBA8,
556 };
557
558 for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(androidFormats); ++formatNdx)
559 addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_NATIVE_BUFFER_ANDROID, androidFormats[formatNdx], (GLenum)0, (GLenum)0));
560
561 addChild(new Image::ImageTargetGLES2(m_eglTestCtx, GL_TEXTURE_2D));
562 addChild(new Image::ImageTargetGLES2(m_eglTestCtx, GL_RENDERBUFFER));
563 }
564 };
565
566 } // Image
567
ImageTests(EglTestContext & eglTestCtx)568 ImageTests::ImageTests (EglTestContext& eglTestCtx)
569 : TestCaseGroup(eglTestCtx, "image", "EGLImage Tests")
570 {
571 }
572
~ImageTests(void)573 ImageTests::~ImageTests (void)
574 {
575 }
576
init(void)577 void ImageTests::init (void)
578 {
579 addChild(new Image::ApiTests(m_eglTestCtx, "api", "EGLImage API tests"));
580 addChild(Image::createSimpleCreationTests(m_eglTestCtx, "create", "EGLImage creation tests"));
581 addChild(Image::createModifyTests(m_eglTestCtx, "modify", "EGLImage modifying tests"));
582 addChild(Image::createMultiContextRenderTests(m_eglTestCtx, "render_multiple_contexts", "EGLImage render tests on multiple contexts"));
583 }
584
585 } // egl
586 } // deqp
587