0007-egl-Be-stricter-when-making-a-context-current-withou.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From d2badaa4a36fdd2193faf40df67b3595f871ffd7 Mon Sep 17 00:00:00 2001
  2. From: Frank Binns <frank.binns@imgtec.com>
  3. Date: Wed, 18 Jun 2014 17:10:28 +0100
  4. Subject: [PATCH] egl: Be stricter when making a context current without any
  5. surfaces
  6. The EGL_KHR_surfaceless_context extension spec states for eglMakeCurrent:
  7. "If <ctx> does not support being bound without read and draw
  8. surfaces, and both <draw> and <read> are EGL_NO_SURFACE, an
  9. EGL_BAD_MATCH error is generated."
  10. Only OpenGLES contexts support this, via the GL_OES_surfaceless_context,
  11. so if EGL_KHR_surfaceless_context is supported and the context isn't an
  12. OpenGLES context then set the EGL error to EGL_BAD_MATCH.
  13. NOTE: This patch can't be upstreamed as is because we set the error to
  14. EGL_BAD_MATCH if we have an OpenGLES 1.x context but the
  15. GL_OES_surfaceless_context extension spec says:
  16. "This extension is written against the OpenGL ES 2.0 Specification
  17. but can apply to OpenGL ES 1.1 with the GL_OES_framebuffer_object
  18. extension."
  19. All Mesa OpenGLES drivers support GL_OES_framebuffer_object, but we
  20. don't, so there would never be a reason to check whether or not this
  21. extension is supported.
  22. In order to upstream this patch the check would need to be changed
  23. to set the error to EGL_BAD_MATCH if EGL_KHR_surfaceless_context is
  24. supported and the context API isn't OpenGLES or the OpenGLES version
  25. is 1.0.
  26. ---
  27. src/egl/main/eglapi.c | 3 +++
  28. 1 file changed, 3 insertions(+)
  29. diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
  30. index 6ffcff8..3cd69b9 100644
  31. --- a/src/egl/main/eglapi.c
  32. +++ b/src/egl/main/eglapi.c
  33. @@ -888,6 +888,9 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
  34. RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
  35. if (draw_surf || read_surf)
  36. RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE);
  37. + if (disp->Extensions.KHR_surfaceless_context && context &&
  38. + (context->ClientAPI != EGL_OPENGL_ES_API || context->ClientMajorVersion == 1))
  39. + RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE);
  40. }
  41. /* If a native window underlying either draw or read is no longer valid,