[Mesa-stable] [PATCH 2/2] mesa: Treat glBindFramebuffer and glBindFramebufferEXT more correctly

Ian Romanick idr at freedesktop.org
Fri Jul 26 22:55:08 PDT 2013


From: Ian Romanick <ian.d.romanick at intel.com>

Allow user-generated names for glBindFramebufferEXT on desktop GL.
Disallow its use altogether for core profiles.

Names bound with glBindFramebuffer in desktop OpenGL are still
(incorrectly) shared across the share group instead of being
per-context.  This gets us a bit closer to being strictly conformant.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: mesa-stable at lists.freedesktop.org
---
 src/mesa/main/fbobject.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 1cc0966..29c3c50 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1924,13 +1924,13 @@ check_end_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb)
 }
 
 
-void GLAPIENTRY
-_mesa_BindFramebuffer(GLenum target, GLuint framebuffer)
+static void
+bind_framebuffer(struct gl_context *ctx, GLenum target, GLuint framebuffer,
+                 bool allow_user_names)
 {
    struct gl_framebuffer *newDrawFb, *newReadFb;
    struct gl_framebuffer *oldDrawFb, *oldReadFb;
    GLboolean bindReadBuf, bindDrawBuf;
-   GET_CURRENT_CONTEXT(ctx);
 
 #ifdef DEBUG
    if (ctx->Extensions.ARB_framebuffer_object) {
@@ -1971,9 +1971,7 @@ _mesa_BindFramebuffer(GLenum target, GLuint framebuffer)
          /* ID was reserved, but no real framebuffer object made yet */
          newDrawFb = NULL;
       }
-      else if (!newDrawFb
-               && _mesa_is_desktop_gl(ctx)
-               && ctx->Extensions.ARB_framebuffer_object) {
+      else if (!newDrawFb && !allow_user_names) {
          /* All FBO IDs must be Gen'd */
          _mesa_error(ctx, GL_INVALID_OPERATION, "glBindFramebuffer(buffer)");
          return;
@@ -2051,12 +2049,31 @@ _mesa_BindFramebuffer(GLenum target, GLuint framebuffer)
 }
 
 void GLAPIENTRY
-_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
+_mesa_BindFramebuffer(GLenum target, GLuint framebuffer)
 {
-    _mesa_BindFramebuffer(target, framebuffer);
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* OpenGL ES glBindFramebuffer and glBindFramebufferOES use this same entry
+    * point, but they allow the use of user-generated names.
+    */
+   bind_framebuffer(ctx, target, framebuffer, _mesa_is_gles(ctx));
 }
 
+void GLAPIENTRY
+_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* Disallowing the EXT function altogether prevents a loop-hole from
+    * allowing user-generated names in a core profile / OpenGL 3.1.
+    */
+   if (ctx->API == API_OPENGL_CORE) {
+      _mesa_generic_nop();
+      return;
+   }
 
+   bind_framebuffer(ctx, target, framebuffer, true);
+}
 
 void GLAPIENTRY
 _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
-- 
1.8.1.4



More information about the mesa-stable mailing list