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 Common utilities for EGL images.
22 *//*--------------------------------------------------------------------*/
23
24
25 #include "teglImageUtil.hpp"
26
27 #include "tcuTexture.hpp"
28 #include "tcuTextureUtil.hpp"
29
30 #include "egluGLUtil.hpp"
31 #include "egluNativeWindow.hpp"
32 #include "egluNativePixmap.hpp"
33
34 #include "eglwLibrary.hpp"
35 #include "eglwEnums.hpp"
36
37 #include "glwEnums.hpp"
38
39 #include "gluObjectWrapper.hpp"
40 #include "gluTextureUtil.hpp"
41
42 namespace deqp
43 {
44 namespace egl
45 {
46 namespace Image
47 {
48
49 using std::string;
50 using std::vector;
51
52 using de::UniquePtr;
53 using de::MovePtr;
54
55 using tcu::TextureFormat;
56 using tcu::Texture2D;
57 using tcu::Vec4;
58
59 using glu::Framebuffer;
60 using glu::Texture;
61
62 using eglu::AttribMap;
63 using eglu::UniqueSurface;
64 using eglu::NativeDisplay;
65 using eglu::NativeWindow;
66 using eglu::NativePixmap;
67 using eglu::NativeDisplayFactory;
68 using eglu::NativeWindowFactory;
69 using eglu::NativePixmapFactory;
70 using eglu::WindowParams;
71
72 using namespace glw;
73 using namespace eglw;
74
75 enum {
76 IMAGE_WIDTH = 64,
77 IMAGE_HEIGHT = 64,
78 };
79
80
81 template <typename T>
82 struct NativeSurface : public ManagedSurface
83 {
84 public:
NativeSurfacedeqp::egl::Image::NativeSurface85 explicit NativeSurface (MovePtr<UniqueSurface> surface,
86 MovePtr<T> native)
87 : ManagedSurface (surface)
88 , m_native (native) {}
89
90 private:
91 UniquePtr<T> m_native;
92 };
93
94 typedef NativeSurface<NativeWindow> NativeWindowSurface;
95 typedef NativeSurface<NativePixmap> NativePixmapSurface;
96
createSurface(EglTestContext & eglTestCtx,EGLDisplay dpy,EGLConfig config,int width,int height)97 MovePtr<ManagedSurface> createSurface (EglTestContext& eglTestCtx, EGLDisplay dpy, EGLConfig config, int width, int height)
98 {
99 const Library& egl = eglTestCtx.getLibrary();
100 EGLint surfaceTypeBits = eglu::getConfigAttribInt(egl, dpy, config, EGL_SURFACE_TYPE);
101 const NativeDisplayFactory& displayFactory = eglTestCtx.getNativeDisplayFactory();
102 NativeDisplay& nativeDisplay = eglTestCtx.getNativeDisplay();
103
104 if (surfaceTypeBits & EGL_PBUFFER_BIT)
105 {
106 static const EGLint attribs[] = { EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE };
107 const EGLSurface surface = egl.createPbufferSurface(dpy, config, attribs);
108
109 EGLU_CHECK_MSG(egl, "eglCreatePbufferSurface()");
110
111 return de::newMovePtr<ManagedSurface>(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)));
112 }
113 else if (surfaceTypeBits & EGL_WINDOW_BIT)
114 {
115 const NativeWindowFactory& windowFactory = selectNativeWindowFactory(displayFactory, eglTestCtx.getTestContext().getCommandLine());
116
117 MovePtr<NativeWindow> window (windowFactory.createWindow(&nativeDisplay, dpy, config, DE_NULL, WindowParams(width, height, WindowParams::VISIBILITY_DONT_CARE)));
118 const EGLSurface surface = eglu::createWindowSurface(nativeDisplay, *window, dpy, config, DE_NULL);
119
120 return MovePtr<ManagedSurface>(new NativeWindowSurface(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)), window));
121 }
122 else if (surfaceTypeBits & EGL_PIXMAP_BIT)
123 {
124 const NativePixmapFactory& pixmapFactory = selectNativePixmapFactory(displayFactory, eglTestCtx.getTestContext().getCommandLine());
125
126 MovePtr<NativePixmap> pixmap (pixmapFactory.createPixmap(&nativeDisplay, dpy, config, DE_NULL, width, height));
127 const EGLSurface surface = eglu::createPixmapSurface(eglTestCtx.getNativeDisplay(), *pixmap, dpy, config, DE_NULL);
128
129 return MovePtr<ManagedSurface>(new NativePixmapSurface(MovePtr<UniqueSurface>(new UniqueSurface(egl, dpy, surface)), pixmap));
130 }
131 else
132 TCU_FAIL("No valid surface types supported in config");
133 }
134
135 class GLClientBuffer : public ClientBuffer
136 {
get(void) const137 EGLClientBuffer get (void) const { return reinterpret_cast<EGLClientBuffer>(static_cast<deUintptr>(getName())); }
138
139 protected:
140 virtual GLuint getName (void) const = 0;
141 };
142
143 class TextureClientBuffer : public GLClientBuffer
144 {
145 public:
TextureClientBuffer(const glw::Functions & gl)146 TextureClientBuffer (const glw::Functions& gl) : m_texture (gl) {}
getName(void) const147 GLuint getName (void) const { return *m_texture; }
148
149 private:
150 glu::Texture m_texture;
151 };
152
153 class GLImageSource : public ImageSource
154 {
155 public:
156 EGLImageKHR createImage (const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
157
158 protected:
159 virtual AttribMap getCreateAttribs (void) const = 0;
160 virtual EGLenum getSource (void) const = 0;
161 };
162
createImage(const Library & egl,EGLDisplay dpy,EGLContext ctx,EGLClientBuffer clientBuffer) const163 EGLImageKHR GLImageSource::createImage (const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const
164 {
165 AttribMap attribMap = getCreateAttribs();
166
167 attribMap[EGL_IMAGE_PRESERVED_KHR] = EGL_TRUE;
168
169 {
170 const vector<EGLint> attribs = eglu::attribMapToList(attribMap);
171 const EGLImageKHR image = egl.createImageKHR(dpy, ctx, getSource(),
172 clientBuffer, &attribs.front());
173 EGLU_CHECK_MSG(egl, "eglCreateImageKHR()");
174 return image;
175 }
176 }
177
178 class TextureImageSource : public GLImageSource
179 {
180 public:
TextureImageSource(GLenum format,GLenum type,bool useTexLevel0)181 TextureImageSource (GLenum format, GLenum type, bool useTexLevel0) : m_format(format), m_type(type), m_useTexLevel0(useTexLevel0) {}
182 MovePtr<ClientBuffer> createBuffer (const glw::Functions& gl, Texture2D* reference) const;
getFormat(void) const183 GLenum getFormat (void) const { return m_format; }
184
185 protected:
186 AttribMap getCreateAttribs (void) const;
187 virtual void initTexture (const glw::Functions& gl) const = 0;
188 virtual GLenum getGLTarget (void) const = 0;
189
190 GLenum m_format;
191 GLenum m_type;
192 bool m_useTexLevel0;
193 };
194
getCreateAttribs(void) const195 AttribMap TextureImageSource::getCreateAttribs (void) const
196 {
197 AttribMap ret;
198
199 ret[EGL_GL_TEXTURE_LEVEL_KHR] = 0;
200
201 return ret;
202 }
203
createBuffer(const glw::Functions & gl,Texture2D * ref) const204 MovePtr<ClientBuffer> TextureImageSource::createBuffer (const glw::Functions& gl, Texture2D* ref) const
205 {
206 MovePtr<TextureClientBuffer> clientBuffer (new TextureClientBuffer(gl));
207 const GLuint texture = clientBuffer->getName();
208 const GLenum target = getGLTarget();
209
210 GLU_CHECK_GLW_CALL(gl, bindTexture(target, texture));
211 initTexture(gl);
212
213 if (!m_useTexLevel0)
214 {
215 // Set minification filter to linear. This makes the texture complete.
216 GLU_CHECK_GLW_CALL(gl, texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
217 }
218
219 if (ref != DE_NULL)
220 {
221 GLenum imgTarget = eglu::getImageGLTarget(getSource());
222
223 *ref = Texture2D(glu::mapGLTransferFormat(m_format, m_type), IMAGE_WIDTH, IMAGE_HEIGHT);
224 ref->allocLevel(0);
225 tcu::fillWithComponentGradients(ref->getLevel(0),
226 tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f),
227 tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
228
229 GLU_CHECK_GLW_CALL(gl, texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
230 GLU_CHECK_GLW_CALL(gl, texParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
231 GLU_CHECK_GLW_CALL(gl, texParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
232 GLU_CHECK_GLW_CALL(gl, texParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
233
234 GLU_CHECK_GLW_CALL(gl, texImage2D(imgTarget, 0, m_format, IMAGE_WIDTH, IMAGE_HEIGHT,
235 0, m_format, m_type, ref->getLevel(0).getDataPtr()));
236 }
237 GLU_CHECK_GLW_CALL(gl, bindTexture(target, 0));
238 return MovePtr<ClientBuffer>(clientBuffer);
239 }
240
241 class Texture2DImageSource : public TextureImageSource
242 {
243 public:
Texture2DImageSource(GLenum format,GLenum type,bool useTexLevel0)244 Texture2DImageSource (GLenum format, GLenum type, bool useTexLevel0) : TextureImageSource(format, type, useTexLevel0) {}
getSource(void) const245 EGLenum getSource (void) const { return EGL_GL_TEXTURE_2D_KHR; }
getRequiredExtension(void) const246 string getRequiredExtension (void) const { return "EGL_KHR_gl_texture_2D_image"; }
getGLTarget(void) const247 GLenum getGLTarget (void) const { return GL_TEXTURE_2D; }
248
249 protected:
250 void initTexture (const glw::Functions& gl) const;
251 };
252
initTexture(const glw::Functions & gl) const253 void Texture2DImageSource::initTexture (const glw::Functions& gl) const
254 {
255 // Specify mipmap level 0
256 GLU_CHECK_CALL_ERROR(gl.texImage2D(GL_TEXTURE_2D, 0, m_format, IMAGE_WIDTH, IMAGE_HEIGHT, 0, m_format, m_type, DE_NULL),
257 gl.getError());
258 }
259
260 class TextureCubeMapImageSource : public TextureImageSource
261 {
262 public:
TextureCubeMapImageSource(EGLenum source,GLenum format,GLenum type,bool useTexLevel0)263 TextureCubeMapImageSource (EGLenum source, GLenum format, GLenum type, bool useTexLevel0) : TextureImageSource(format, type, useTexLevel0), m_source(source) {}
getSource(void) const264 EGLenum getSource (void) const { return m_source; }
getRequiredExtension(void) const265 string getRequiredExtension (void) const { return "EGL_KHR_gl_texture_cubemap_image"; }
getGLTarget(void) const266 GLenum getGLTarget (void) const { return GL_TEXTURE_CUBE_MAP; }
267
268 protected:
269 void initTexture (const glw::Functions& gl) const;
270
271 EGLenum m_source;
272 };
273
initTexture(const glw::Functions & gl) const274 void TextureCubeMapImageSource::initTexture (const glw::Functions& gl) const
275 {
276 // Specify mipmap level 0 for all faces
277 static const GLenum faces[] =
278 {
279 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
280 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
281 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
282 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
283 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
284 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
285 };
286
287 for (int faceNdx = 0; faceNdx < DE_LENGTH_OF_ARRAY(faces); faceNdx++)
288 GLU_CHECK_GLW_CALL(gl, texImage2D(faces[faceNdx], 0, m_format, IMAGE_WIDTH, IMAGE_HEIGHT, 0, m_format, m_type, DE_NULL));
289 }
290
291 class RenderbufferClientBuffer : public GLClientBuffer
292 {
293 public:
RenderbufferClientBuffer(const glw::Functions & gl)294 RenderbufferClientBuffer (const glw::Functions& gl) : m_rbo (gl) {}
getName(void) const295 GLuint getName (void) const { return *m_rbo; }
296
297 private:
298 glu::Renderbuffer m_rbo;
299 };
300
301 class RenderbufferImageSource : public GLImageSource
302 {
303 public:
RenderbufferImageSource(GLenum format)304 RenderbufferImageSource (GLenum format) : m_format(format) {}
305
getRequiredExtension(void) const306 string getRequiredExtension (void) const { return "EGL_KHR_gl_renderbuffer_image"; }
307 MovePtr<ClientBuffer> createBuffer (const glw::Functions& gl, Texture2D* reference) const;
getFormat(void) const308 GLenum getFormat (void) const { return m_format; }
309
310 protected:
getSource(void) const311 EGLenum getSource (void) const { return EGL_GL_RENDERBUFFER_KHR; }
getCreateAttribs(void) const312 AttribMap getCreateAttribs (void) const { return AttribMap(); }
313
314 GLenum m_format;
315 };
316
initializeStencilRbo(const glw::Functions & gl,GLuint rbo,Texture2D & ref)317 void initializeStencilRbo(const glw::Functions& gl, GLuint rbo, Texture2D& ref)
318 {
319 static const deUint32 stencilValues[] =
320 {
321 0xBF688C11u,
322 0xB43D2922u,
323 0x055D5FFBu,
324 0x9300655Eu,
325 0x63BE0DF2u,
326 0x0345C13Bu,
327 0x1C184832u,
328 0xD107040Fu,
329 0x9B91569Fu,
330 0x0F0CFDC7u,
331 };
332
333 const deUint32 numStencilBits = tcu::getTextureFormatBitDepth(tcu::getEffectiveDepthStencilTextureFormat(ref.getLevel(0).getFormat(), tcu::Sampler::MODE_STENCIL)).x();
334 const deUint32 stencilMask = deBitMask32(0, numStencilBits);
335
336 GLU_CHECK_GLW_CALL(gl, framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
337 GL_RENDERBUFFER, rbo));
338 GLU_CHECK_GLW_CALL(gl, clearStencil(0));
339 GLU_CHECK_GLW_CALL(gl, clear(GL_STENCIL_BUFFER_BIT));
340 tcu::clearStencil(ref.getLevel(0), 0);
341
342 // create a pattern
343 GLU_CHECK_GLW_CALL(gl, enable(GL_SCISSOR_TEST));
344 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilValues); ++ndx)
345 {
346 const deUint32 stencil = stencilValues[ndx] & stencilMask;
347 const tcu::IVec2 size = tcu::IVec2((int)((DE_LENGTH_OF_ARRAY(stencilValues) - ndx) * (ref.getWidth() / float(DE_LENGTH_OF_ARRAY(stencilValues)))),
348 (int)((DE_LENGTH_OF_ARRAY(stencilValues) - ndx) * (ref.getHeight() / float(DE_LENGTH_OF_ARRAY(stencilValues) + 4)))); // not symmetric
349
350 if (size.x() == 0 || size.y() == 0)
351 break;
352
353 GLU_CHECK_GLW_CALL(gl, scissor(0, 0, size.x(), size.y()));
354 GLU_CHECK_GLW_CALL(gl, clearStencil(stencil));
355 GLU_CHECK_GLW_CALL(gl, clear(GL_STENCIL_BUFFER_BIT));
356
357 tcu::clearStencil(tcu::getSubregion(ref.getLevel(0), 0, 0, size.x(), size.y()), stencil);
358 }
359
360 GLU_CHECK_GLW_CALL(gl, disable(GL_SCISSOR_TEST));
361 GLU_CHECK_GLW_CALL(gl, framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
362 GL_RENDERBUFFER, 0));
363 }
364
initializeDepthRbo(const glw::Functions & gl,GLuint rbo,Texture2D & ref)365 void initializeDepthRbo(const glw::Functions& gl, GLuint rbo, Texture2D& ref)
366 {
367 const int NUM_STEPS = 13;
368
369 GLU_CHECK_GLW_CALL(gl, framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
370 GL_RENDERBUFFER, rbo));
371
372 GLU_CHECK_GLW_CALL(gl, clearDepthf(0.0f));
373 GLU_CHECK_GLW_CALL(gl, clear(GL_DEPTH_BUFFER_BIT));
374 tcu::clearDepth(ref.getLevel(0), 0.0f);
375
376 // create a pattern
377 GLU_CHECK_GLW_CALL(gl, enable(GL_SCISSOR_TEST));
378 for (int ndx = 0; ndx < NUM_STEPS; ++ndx)
379 {
380 const float depth = ndx / float(NUM_STEPS);
381 const tcu::IVec2 size = tcu::IVec2((int)((NUM_STEPS - ndx) * (ref.getWidth() / float(NUM_STEPS))),
382 (int)((NUM_STEPS - ndx) * (ref.getHeight() / float(NUM_STEPS + 4)))); // not symmetric
383
384 if (size.x() == 0 || size.y() == 0)
385 break;
386
387 GLU_CHECK_GLW_CALL(gl, scissor(0, 0, size.x(), size.y()));
388 GLU_CHECK_GLW_CALL(gl, clearDepthf(depth));
389 GLU_CHECK_GLW_CALL(gl, clear(GL_DEPTH_BUFFER_BIT));
390
391 tcu::clearDepth(tcu::getSubregion(ref.getLevel(0), 0, 0, size.x(), size.y()), depth);
392 }
393
394 GLU_CHECK_GLW_CALL(gl, disable(GL_SCISSOR_TEST));
395 GLU_CHECK_GLW_CALL(gl, framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
396 GL_RENDERBUFFER, 0));
397
398 }
399
initializeColorRbo(const glw::Functions & gl,GLuint rbo,Texture2D & ref)400 void initializeColorRbo(const glw::Functions& gl, GLuint rbo, Texture2D& ref)
401 {
402 static const tcu::Vec4 colorValues[] =
403 {
404 tcu::Vec4(0.9f, 0.5f, 0.65f, 1.0f),
405 tcu::Vec4(0.5f, 0.7f, 0.65f, 1.0f),
406 tcu::Vec4(0.2f, 0.5f, 0.65f, 1.0f),
407 tcu::Vec4(0.3f, 0.1f, 0.5f, 1.0f),
408 tcu::Vec4(0.8f, 0.2f, 0.3f, 1.0f),
409 tcu::Vec4(0.9f, 0.4f, 0.8f, 1.0f),
410 };
411
412 GLU_CHECK_GLW_CALL(gl, framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
413 GL_RENDERBUFFER, rbo));
414 GLU_CHECK_GLW_CALL(gl, clearColor(1.0f, 1.0f, 0.0f, 1.0f));
415 GLU_CHECK_GLW_CALL(gl, clear(GL_COLOR_BUFFER_BIT));
416 tcu::clear(ref.getLevel(0), Vec4(1.0f, 1.0f, 0.0f, 1.0f));
417
418 // create a pattern
419 GLU_CHECK_GLW_CALL(gl, enable(GL_SCISSOR_TEST));
420 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorValues); ++ndx)
421 {
422 const tcu::IVec2 size = tcu::IVec2((int)((DE_LENGTH_OF_ARRAY(colorValues) - ndx) * (ref.getWidth() / float(DE_LENGTH_OF_ARRAY(colorValues)))),
423 (int)((DE_LENGTH_OF_ARRAY(colorValues) - ndx) * (ref.getHeight() / float(DE_LENGTH_OF_ARRAY(colorValues) + 4)))); // not symmetric
424
425 if (size.x() == 0 || size.y() == 0)
426 break;
427
428 GLU_CHECK_GLW_CALL(gl, scissor(0, 0, size.x(), size.y()));
429 GLU_CHECK_GLW_CALL(gl, clearColor(colorValues[ndx].x(), colorValues[ndx].y(), colorValues[ndx].z(), colorValues[ndx].w()));
430 GLU_CHECK_GLW_CALL(gl, clear(GL_COLOR_BUFFER_BIT));
431
432 tcu::clear(tcu::getSubregion(ref.getLevel(0), 0, 0, size.x(), size.y()), colorValues[ndx]);
433 }
434
435 GLU_CHECK_GLW_CALL(gl, disable(GL_SCISSOR_TEST));
436 GLU_CHECK_GLW_CALL(gl, framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
437 GL_RENDERBUFFER, 0));
438 }
439
createBuffer(const glw::Functions & gl,Texture2D * ref) const440 MovePtr<ClientBuffer> RenderbufferImageSource::createBuffer (const glw::Functions& gl, Texture2D* ref) const
441 {
442 MovePtr<RenderbufferClientBuffer> buffer (new RenderbufferClientBuffer(gl));
443 const GLuint rbo = buffer->getName();
444
445 GLU_CHECK_CALL_ERROR(gl.bindRenderbuffer(GL_RENDERBUFFER, rbo), gl.getError());
446
447 // Specify storage.
448 GLU_CHECK_CALL_ERROR(gl.renderbufferStorage(GL_RENDERBUFFER, m_format, 64, 64), gl.getError());
449
450 if (ref != DE_NULL)
451 {
452 Framebuffer fbo (gl);
453 const TextureFormat texFormat = glu::mapGLInternalFormat(m_format);
454
455 *ref = tcu::Texture2D(texFormat, 64, 64);
456 ref->allocLevel(0);
457
458 gl.bindFramebuffer(GL_FRAMEBUFFER, *fbo);
459 switch (m_format)
460 {
461 case GL_STENCIL_INDEX8:
462 initializeStencilRbo(gl, rbo, *ref);
463 break;
464 case GL_DEPTH_COMPONENT16:
465 initializeDepthRbo(gl, rbo, *ref);
466 break;
467 case GL_RGBA4:
468 initializeColorRbo(gl, rbo, *ref);
469 break;
470 case GL_RGB5_A1:
471 initializeColorRbo(gl, rbo, *ref);
472 break;
473 case GL_RGB565:
474 initializeColorRbo(gl, rbo, *ref);
475 break;
476 default:
477 DE_ASSERT(!"Impossible");
478 }
479
480 gl.bindFramebuffer(GL_FRAMEBUFFER, 0);
481 }
482
483 return MovePtr<ClientBuffer>(buffer);
484 }
485
486 class UnsupportedImageSource : public ImageSource
487 {
488 public:
UnsupportedImageSource(const string & message,GLenum format)489 UnsupportedImageSource (const string& message, GLenum format) : m_message(message), m_format(format) {}
getRequiredExtension(void) const490 string getRequiredExtension (void) const { fail(); return ""; }
createBuffer(const glw::Functions &,tcu::Texture2D *) const491 MovePtr<ClientBuffer> createBuffer (const glw::Functions&, tcu::Texture2D*) const { fail(); return de::MovePtr<ClientBuffer>(); }
492 EGLImageKHR createImage (const Library& egl, EGLDisplay dpy, EGLContext ctx, EGLClientBuffer clientBuffer) const;
getFormat(void) const493 GLenum getFormat (void) const { return m_format; }
494
495 private:
496 const string m_message;
497 GLenum m_format;
498
fail(void) const499 void fail (void) const { TCU_THROW(NotSupportedError, m_message.c_str()); }
500 };
501
createImage(const Library &,EGLDisplay,EGLContext,EGLClientBuffer) const502 EGLImageKHR UnsupportedImageSource::createImage (const Library&, EGLDisplay, EGLContext, EGLClientBuffer) const
503 {
504 fail();
505 return EGL_NO_IMAGE_KHR;
506 }
507
createTextureImageSource(EGLenum source,GLenum format,GLenum type,bool useTexLevel0)508 MovePtr<ImageSource> createTextureImageSource (EGLenum source, GLenum format, GLenum type, bool useTexLevel0)
509 {
510 if (source == EGL_GL_TEXTURE_2D_KHR)
511 return MovePtr<ImageSource>(new Texture2DImageSource(format, type, useTexLevel0));
512 else
513 return MovePtr<ImageSource>(new TextureCubeMapImageSource(source, format, type, useTexLevel0));
514 }
515
createRenderbufferImageSource(GLenum format)516 MovePtr<ImageSource> createRenderbufferImageSource (GLenum format)
517 {
518 return MovePtr<ImageSource>(new RenderbufferImageSource(format));
519 }
520
createUnsupportedImageSource(const string & message,GLenum format)521 MovePtr<ImageSource> createUnsupportedImageSource (const string& message, GLenum format)
522 {
523 return MovePtr<ImageSource>(new UnsupportedImageSource(message, format));
524 }
525
526 } // Image
527 } // egl
528 } // deqp
529