[Mesa-dev] [PATCH 1/2] mesa: Treat glBindRenderbuffer and glBindRenderbufferEXT correctly

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


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

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

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

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index a29f1ab..1cc0966 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1104,11 +1104,11 @@ _mesa_IsRenderbuffer(GLuint renderbuffer)
 }
 
 
-void GLAPIENTRY
-_mesa_BindRenderbuffer(GLenum target, GLuint renderbuffer)
+static void
+bind_renderbuffer(struct gl_context *ctx, GLenum target, GLuint renderbuffer,
+                  bool allow_user_names)
 {
    struct gl_renderbuffer *newRb;
-   GET_CURRENT_CONTEXT(ctx);
 
    if (target != GL_RENDERBUFFER_EXT) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glBindRenderbufferEXT(target)");
@@ -1125,9 +1125,7 @@ _mesa_BindRenderbuffer(GLenum target, GLuint renderbuffer)
          /* ID was reserved, but no real renderbuffer object made yet */
          newRb = NULL;
       }
-      else if (!newRb
-               && _mesa_is_desktop_gl(ctx)
-               && ctx->Extensions.ARB_framebuffer_object) {
+      else if (!newRb && !allow_user_names) {
          /* All RB IDs must be Gen'd */
          _mesa_error(ctx, GL_INVALID_OPERATION, "glBindRenderbuffer(buffer)");
          return;
@@ -1154,11 +1152,31 @@ _mesa_BindRenderbuffer(GLenum target, GLuint renderbuffer)
    _mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb);
 }
 
+void GLAPIENTRY
+_mesa_BindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* OpenGL ES glBindRenderbuffer and glBindRenderbufferOES use this same
+    * entry point, but they allow the use of user-generated names.
+    */
+   bind_renderbuffer(ctx, target, renderbuffer, _mesa_is_gles(ctx));
+}
 
 void GLAPIENTRY
 _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
 {
-    _mesa_BindRenderbuffer(target, renderbuffer);
+   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_renderbuffer(ctx, target, renderbuffer, true);
 }
 
 
-- 
1.8.1.4



More information about the mesa-dev mailing list