main: Added entry point for glCreateRenderbuffers
authorMartin Peres <martin.peres@linux.intel.com>
Thu, 12 Feb 2015 16:52:10 +0000 (18:52 +0200)
committerMartin Peres <martin.peres@linux.intel.com>
Wed, 25 Mar 2015 08:05:45 +0000 (10:05 +0200)
v2:
- refactor bindRenderBuffer and create_render_buffers to fix an assertion

Reviewed-by: Laura Ekstrand <laura@jlekstrand.net>
Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
src/mapi/glapi/gen/ARB_direct_state_access.xml
src/mesa/main/fbobject.c
src/mesa/main/fbobject.h
src/mesa/main/tests/dispatch_sanity.cpp

index 9bba64bc3c885bf603b266cc6e1e323ff4f7ad6a..976dcc8d1611fd0bfd315aefe1150c45dcaf32ac 100644 (file)
       <param name="data" type="GLvoid *" />
    </function>
 
+   <!-- Renderbuffer object functions -->
+
+   <function name="CreateRenderbuffers" offset="assign">
+      <param name="n" type="GLsizei" />
+      <param name="renderbuffers" type="GLuint *" />
+   </function>
+
    <!-- Texture object functions -->
 
    <function name="CreateTextures" offset="assign">
index bccac91c634a008a1ba3ba20633731c65f75165c..8083bc1780e75a95695adbeca3131ecfbefe254d 100644 (file)
@@ -1205,6 +1205,26 @@ _mesa_IsRenderbuffer(GLuint renderbuffer)
 }
 
 
+static struct gl_renderbuffer *
+allocate_renderbuffer(struct gl_context *ctx, GLuint renderbuffer,
+                      const char *func)
+{
+   struct gl_renderbuffer *newRb;
+
+   /* create new renderbuffer object */
+   newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer);
+   if (!newRb) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
+      return NULL;
+   }
+   assert(newRb->AllocStorage);
+   _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb);
+   newRb->RefCount = 1; /* referenced by hash table */
+
+   return newRb;
+}
+
+
 static void
 bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names)
 {
@@ -1233,15 +1253,7 @@ bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names)
       }
 
       if (!newRb) {
-         /* create new renderbuffer object */
-         newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer);
-         if (!newRb) {
-            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT");
-            return;
-         }
-         assert(newRb->AllocStorage);
-         _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb);
-         newRb->RefCount = 1; /* referenced by hash table */
+         newRb = allocate_renderbuffer(ctx, renderbuffer, "glBindRenderbufferEXT");
       }
    }
    else {
@@ -1383,16 +1395,17 @@ _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
    }
 }
 
-
-void GLAPIENTRY
-_mesa_GenRenderbuffers(GLsizei n, GLuint *renderbuffers)
+static void
+create_render_buffers(struct gl_context *ctx, GLsizei n, GLuint *renderbuffers,
+                      bool dsa)
 {
-   GET_CURRENT_CONTEXT(ctx);
+   const char *func = dsa ? "glCreateRenderbuffers" : "glGenRenderbuffers";
+   struct gl_renderbuffer *obj;
    GLuint first;
    GLint i;
 
    if (n < 0) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glGenRenderbuffersEXT(n)");
+      _mesa_error(ctx, GL_INVALID_VALUE, "%s(n<0)", func);
       return;
    }
 
@@ -1404,14 +1417,37 @@ _mesa_GenRenderbuffers(GLsizei n, GLuint *renderbuffers)
    for (i = 0; i < n; i++) {
       GLuint name = first + i;
       renderbuffers[i] = name;
-      /* insert dummy placeholder into hash table */
-      mtx_lock(&ctx->Shared->Mutex);
-      _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer);
-      mtx_unlock(&ctx->Shared->Mutex);
+
+      if (dsa) {
+         obj = allocate_renderbuffer(ctx, name, func);
+      } else {
+         obj = &DummyRenderbuffer;
+
+         /* insert the object into the hash table */
+         mtx_lock(&ctx->Shared->Mutex);
+         _mesa_HashInsert(ctx->Shared->RenderBuffers, name, obj);
+         mtx_unlock(&ctx->Shared->Mutex);
+      }
    }
 }
 
 
+void GLAPIENTRY
+_mesa_GenRenderbuffers(GLsizei n, GLuint *renderbuffers)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   create_render_buffers(ctx, n, renderbuffers, false);
+}
+
+
+void GLAPIENTRY
+_mesa_CreateRenderbuffers(GLsizei n, GLuint *renderbuffers)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   create_render_buffers(ctx, n, renderbuffers, true);
+}
+
+
 /**
  * Given an internal format token for a render buffer, return the
  * corresponding base format (one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX,
index 77fdef415bed4afe2ad80179b908117843b625d0..9ab6b0bc64fc285e5d872a0227cfe8173f17423b 100644 (file)
@@ -114,6 +114,9 @@ _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers);
 extern void GLAPIENTRY
 _mesa_GenRenderbuffers(GLsizei n, GLuint *renderbuffers);
 
+extern void GLAPIENTRY
+_mesa_CreateRenderbuffers(GLsizei n, GLuint *renderbuffers);
+
 extern void GLAPIENTRY
 _mesa_RenderbufferStorage(GLenum target, GLenum internalformat,
                              GLsizei width, GLsizei height);
index 67c3b3347361742297ff1a4d9f61b9e497085a7b..5383865e0e869ef16b00ea792cf14c9033490ed2 100644 (file)
@@ -943,6 +943,7 @@ const struct function gl_core_functions_possible[] = {
    { "glGetNamedBufferParameteri64v", 45, -1 },
    { "glGetNamedBufferPointerv", 45, -1 },
    { "glGetNamedBufferSubData", 45, -1 },
+   { "glCreateRenderbuffers", 45, -1 },
    { "glCreateTextures", 45, -1 },
    { "glTextureStorage1D", 45, -1 },
    { "glTextureStorage2D", 45, -1 },