mesa: add ARB_framebuffer_no_attachments named functions
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 5 Nov 2019 13:47:53 +0000 (14:47 +0100)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 19 Nov 2019 07:49:44 +0000 (08:49 +0100)
The wording in ARB_framebuffer_no_attachments and EXT_direct_state_access
is different.
In the former framebuffer names must have been generated using glGenFramebuffers
before using the named functions.
In the latter framebuffer names have no such constraints, so we can't use
the _mesa_lookup_framebuffer_dsa function.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
docs/features.txt
src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml
src/mapi/glapi/gen/static_data.py
src/mesa/main/fbobject.c
src/mesa/main/fbobject.h
src/mesa/main/tests/dispatch_sanity.cpp

index 9cf76533fc28cf9bd0f25d6d0c8b9bef78dae4c9..9463b17a0435cf1e61ac34c7777fc23dc5a19f68 100644 (file)
@@ -378,7 +378,7 @@ GL_EXT_direct_state_access additions from other extensions (complete list):
   GL_ARB_bindless_texture                               DONE
   GL_ARB_buffer_storage                                 DONE
   GL_ARB_clear_buffer_object                            not started
-  GL_ARB_framebuffer_no_attachments                     not started
+  GL_ARB_framebuffer_no_attachments                     DONE
   GL_ARB_gpu_shader_fp64                                not started
   GL_ARB_instanced_arrays                               not started
   GL_ARB_internalformat_query2                          DONE
index 55ad7642ff519e744e7ec125557f0dbce4fa0f2b..13c2501702c9b51ba8ba78aa65f599491e746d25 100644 (file)
        <param name="params" type="GLint *" output="true" />
     </function>
 
+    <function name="NamedFramebufferParameteriEXT">
+      <param name="framebuffer" type="GLuint" />
+      <param name="pname" type="GLenum" />
+      <param name="param" type="GLint" />
+    </function>
+
+    <function name="GetNamedFramebufferParameterivEXT">
+      <param name="framebuffer" type="GLuint" />
+      <param name="pname" type="GLenum" />
+      <param name="params" type="GLint*" />
+    </function>
+
 </category>
 
 </OpenGLAPI>
index 6e84132e5635e7eb9871cb432185cb8f12a658bb..fe9f94ae97f08c1ad56c7dd3252a4d777e6a656b 100644 (file)
@@ -1615,7 +1615,9 @@ offsets = {
     "GetVertexArrayIntegervEXT": 1579,
     "GetVertexArrayPointervEXT": 1580,
     "GetVertexArrayIntegeri_vEXT": 1581,
-    "GetVertexArrayPointeri_vEXT": 1582
+    "GetVertexArrayPointeri_vEXT": 1582,
+    "NamedFramebufferParameteriEXT": 1583,
+    "GetNamedFramebufferParameterivEXT": 1584,
 }
 
 functions = [
index 2aeb48dfe7dece85d716f003b65dd20d3d61c4bd..ea89565cfe2a4ee45f8ed5e8fafc9f0e90cfdba1 100644 (file)
@@ -4733,6 +4733,65 @@ _mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
 }
 
 
+/* Helper function for ARB_framebuffer_no_attachments functions interacting with EXT_direct_state_access */
+static struct gl_framebuffer *
+lookup_named_framebuffer_ext_dsa(struct gl_context *ctx, GLuint framebuffer, const char* caller)
+{
+   struct gl_framebuffer *fb = NULL;
+
+   if (framebuffer) {
+      /* The ARB_framebuffer_no_attachments spec says:
+       *
+       *     "The error INVALID_VALUE is generated if <framebuffer> is not
+       *     a name returned by GenFramebuffers.  If a framebuffer object
+       *     named <framebuffer> does not yet exist, it will be created."
+       *
+       * This is different from the EXT_direct_state_access spec which says:
+       *
+       *     "If the framebuffer object named by the framebuffer parameter has not
+       *      been previously bound or has been deleted since the last binding,
+       *     the GL first creates a new state vector in the same manner as when
+       *    BindFramebuffer creates a new framebuffer object"
+       *
+       * So first we verify that the name exists.
+       */
+      fb = _mesa_lookup_framebuffer(ctx, framebuffer);
+      if (!fb) {
+         _mesa_error(ctx, GL_INVALID_VALUE, "%s(frameBuffer)", caller);
+         return NULL;
+      }
+      /* Then, make sure it's initialized */
+      if (fb == &DummyFramebuffer) {
+         fb = ctx->Driver.NewFramebuffer(ctx, framebuffer);
+         _mesa_HashLockMutex(ctx->Shared->FrameBuffers);
+         _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, fb);
+         _mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
+      }
+   }
+   else
+      fb = ctx->WinSysDrawBuffer;
+
+   return fb;
+}
+
+
+void GLAPIENTRY
+_mesa_NamedFramebufferParameteriEXT(GLuint framebuffer, GLenum pname,
+                                    GLint param)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb =
+      lookup_named_framebuffer_ext_dsa(ctx, framebuffer,
+                                       "glNamedFramebufferParameteriEXT");
+
+   if (!fb)
+      return;
+
+   framebuffer_parameteri(ctx, fb, pname, param,
+                             "glNamedFramebufferParameteriEXT");
+}
+
+
 void GLAPIENTRY
 _mesa_GetFramebufferParameterivEXT(GLuint framebuffer, GLenum pname,
                                    GLint *param)
@@ -4798,6 +4857,23 @@ _mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
 }
 
 
+void GLAPIENTRY
+_mesa_GetNamedFramebufferParameterivEXT(GLuint framebuffer, GLenum pname,
+                                     GLint *param)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_framebuffer *fb =
+      lookup_named_framebuffer_ext_dsa(ctx, framebuffer,
+                                       "glGetNamedFramebufferParameterivEXT");
+
+   if (!fb)
+      return;
+
+   get_framebuffer_parameteriv(ctx, fb, pname, param,
+                               "glGetNamedFramebufferParameterivEXT");
+}
+
+
 static void
 invalidate_framebuffer_storage(struct gl_context *ctx,
                                struct gl_framebuffer *fb,
index bd1f7e4a537f0b8391bf2782f138d79a909605b0..6c8c4f0dc6165318fdc6f2e236dbb702bbeb3be1 100644 (file)
@@ -368,6 +368,10 @@ extern void GLAPIENTRY
 _mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
                                  GLint param);
 
+extern void GLAPIENTRY
+_mesa_NamedFramebufferParameteriEXT(GLuint framebuffer, GLenum pname,
+                                    GLint param);
+
 extern void GLAPIENTRY
 _mesa_GetNamedRenderbufferParameterivEXT(GLuint renderbuffer, GLenum pname,
                                          GLint *params);
@@ -380,6 +384,10 @@ extern void GLAPIENTRY
 _mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
                                      GLint *param);
 
+extern void GLAPIENTRY
+_mesa_GetNamedFramebufferParameterivEXT(GLuint framebuffer, GLenum pname,
+                                        GLint *param);
+
 void GLAPIENTRY
 _mesa_InvalidateSubFramebuffer_no_error(GLenum target, GLsizei numAttachments,
                                         const GLenum *attachments, GLint x,
index e6cefabd386ff27d293c81fa3d6271b166889423..390e3ef381f7adb6e2ce715a1a2af3ced2fa2366 100644 (file)
@@ -874,8 +874,8 @@ const struct function common_desktop_functions_possible[] = {
 // { "glVertexArrayVertexBindingDivisorEXT", 43, -1 },  // XXX: Add to xml
    { "glFramebufferParameteri", 43, -1 },
    { "glGetFramebufferParameteriv", 43, -1 },
-// { "glNamedFramebufferParameteriEXT", 43, -1 },       // XXX: Add to xml
-// { "glGetNamedFramebufferParameterivEXT", 43, -1 },   // XXX: Add to xml
+   { "glNamedFramebufferParameteriEXT", 43, -1 },
+   { "glGetNamedFramebufferParameterivEXT", 43, -1 },
 // { "glGetInternalformati64v", 43, -1 },               // XXX: Add to xml
    { "glInvalidateTexSubImage", 43, -1 },
    { "glInvalidateTexImage", 43, -1 },