[Mesa-dev] [PATCH 18/21] main: Add entry points for GetNamedBufferParameteri[64]v.

Laura Ekstrand laura at jlekstrand.net
Wed Jan 21 17:40:31 PST 2015


---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  12 ++
 src/mesa/main/bufferobj.c                      | 170 +++++++++++++------------
 src/mesa/main/bufferobj.h                      |   7 +
 src/mesa/main/tests/dispatch_sanity.cpp        |   2 +
 4 files changed, 111 insertions(+), 80 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 1e6b9c4..46f4e9a 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -86,6 +86,18 @@
       <param name="length" type="GLsizeiptr" />
    </function>
 
+   <function name="GetNamedBufferParameteriv" offset="assign">
+      <param name="buffer" type="GLuint" />
+      <param name="pname" type="GLenum" />
+      <param name="params" type="GLint *" />
+   </function>
+
+   <function name="GetNamedBufferParameteri64v" offset="assign">
+      <param name="buffer" type="GLuint" />
+      <param name="pname" type="GLenum" />
+      <param name="params" type="GLint64 *" />
+   </function>
+
   <!-- Texture object functions -->
 
    <function name="CreateTextures" offset="assign">
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index e446f39..51b5d59 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1838,128 +1838,138 @@ _mesa_UnmapNamedBuffer(GLuint buffer)
    return _mesa_unmap_buffer(ctx, bufObj, "glUnmapNamedBuffer");
 }
 
-void GLAPIENTRY
-_mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *bufObj;
-
-   bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target,
-                       GL_INVALID_OPERATION);
-   if (!bufObj)
-      return;
 
+static bool
+get_buffer_parameter(struct gl_context *ctx,
+                     struct gl_buffer_object *bufObj, GLenum pname,
+                     GLint64 *param, const char *func)
+{
    switch (pname) {
    case GL_BUFFER_SIZE_ARB:
-      *params = (GLint) bufObj->Size;
-      return;
+      *param = bufObj->Size;
+      break;
    case GL_BUFFER_USAGE_ARB:
-      *params = bufObj->Usage;
-      return;
+      *param = bufObj->Usage;
+      break;
    case GL_BUFFER_ACCESS_ARB:
-      *params = simplified_access_mode(ctx,
-                            bufObj->Mappings[MAP_USER].AccessFlags);
-      return;
-   case GL_BUFFER_MAPPED_ARB:
-      *params = _mesa_bufferobj_mapped(bufObj, MAP_USER);
-      return;
+      *param = simplified_access_mode(ctx,
+                             bufObj->Mappings[MAP_USER].AccessFlags);
+      break;
    case GL_BUFFER_ACCESS_FLAGS:
       if (!ctx->Extensions.ARB_map_buffer_range)
          goto invalid_pname;
-      *params = bufObj->Mappings[MAP_USER].AccessFlags;
-      return;
+      *param = bufObj->Mappings[MAP_USER].AccessFlags;
+      break;
+   case GL_BUFFER_MAPPED_ARB:
+      *param = _mesa_bufferobj_mapped(bufObj, MAP_USER);
+      break;
    case GL_BUFFER_MAP_OFFSET:
       if (!ctx->Extensions.ARB_map_buffer_range)
          goto invalid_pname;
-      *params = (GLint) bufObj->Mappings[MAP_USER].Offset;
-      return;
+      *param = bufObj->Mappings[MAP_USER].Offset;
+      break;
    case GL_BUFFER_MAP_LENGTH:
       if (!ctx->Extensions.ARB_map_buffer_range)
          goto invalid_pname;
-      *params = (GLint) bufObj->Mappings[MAP_USER].Length;
-      return;
+      *param = bufObj->Mappings[MAP_USER].Length;
+      break;
    case GL_BUFFER_IMMUTABLE_STORAGE:
       if (!ctx->Extensions.ARB_buffer_storage)
          goto invalid_pname;
-      *params = bufObj->Immutable;
-      return;
+      *param = bufObj->Immutable;
+      break;
    case GL_BUFFER_STORAGE_FLAGS:
       if (!ctx->Extensions.ARB_buffer_storage)
          goto invalid_pname;
-      *params = bufObj->StorageFlags;
-      return;
+      *param = bufObj->StorageFlags;
+      break;
    default:
-      ; /* fall-through */
+      goto invalid_pname;
    }
 
+   return true;
+
 invalid_pname:
-   _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname=%s)",
+   _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid pname: %s)", func,
                _mesa_lookup_enum_by_nr(pname));
+   return false;
 }
 
+void GLAPIENTRY
+_mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+   GLint64 parameter;
+
+   bufObj = get_buffer(ctx, "glGetBufferParameteriv", target,
+                       GL_INVALID_OPERATION);
+   if (!bufObj)
+      return;
+
+   if (!get_buffer_parameter(ctx, bufObj, pname, &parameter,
+                             "glGetBufferParameteriv"))
+      return; /* Error already recorded. */
+
+   *params = (GLint) parameter;
+}
 
-/**
- * New in GL 3.2
- * This is pretty much a duplicate of GetBufferParameteriv() but the
- * GL_BUFFER_SIZE_ARB attribute will be 64-bits on a 64-bit system.
- */
 void GLAPIENTRY
 _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params)
 {
    GET_CURRENT_CONTEXT(ctx);
    struct gl_buffer_object *bufObj;
+   GLint64 parameter;
 
    bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target,
                        GL_INVALID_OPERATION);
    if (!bufObj)
       return;
 
-   switch (pname) {
-   case GL_BUFFER_SIZE_ARB:
-      *params = bufObj->Size;
-      return;
-   case GL_BUFFER_USAGE_ARB:
-      *params = bufObj->Usage;
-      return;
-   case GL_BUFFER_ACCESS_ARB:
-      *params = simplified_access_mode(ctx,
-                             bufObj->Mappings[MAP_USER].AccessFlags);
-      return;
-   case GL_BUFFER_ACCESS_FLAGS:
-      if (!ctx->Extensions.ARB_map_buffer_range)
-         goto invalid_pname;
-      *params = bufObj->Mappings[MAP_USER].AccessFlags;
-      return;
-   case GL_BUFFER_MAPPED_ARB:
-      *params = _mesa_bufferobj_mapped(bufObj, MAP_USER);
-      return;
-   case GL_BUFFER_MAP_OFFSET:
-      if (!ctx->Extensions.ARB_map_buffer_range)
-         goto invalid_pname;
-      *params = bufObj->Mappings[MAP_USER].Offset;
-      return;
-   case GL_BUFFER_MAP_LENGTH:
-      if (!ctx->Extensions.ARB_map_buffer_range)
-         goto invalid_pname;
-      *params = bufObj->Mappings[MAP_USER].Length;
-      return;
-   case GL_BUFFER_IMMUTABLE_STORAGE:
-      if (!ctx->Extensions.ARB_buffer_storage)
-         goto invalid_pname;
-      *params = bufObj->Immutable;
+   if (!get_buffer_parameter(ctx, bufObj, pname, &parameter,
+                             "glGetBufferParameteri64v"))
+      return; /* Error already recorded. */
+
+   *params = parameter;
+}
+
+void GLAPIENTRY
+_mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+   GLint64 parameter;
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+                                       "glGetNamedBufferParameteriv");
+   if (!bufObj)
       return;
-   case GL_BUFFER_STORAGE_FLAGS:
-      if (!ctx->Extensions.ARB_buffer_storage)
-         goto invalid_pname;
-      *params = bufObj->StorageFlags;
+
+   if (!get_buffer_parameter(ctx, bufObj, pname, &parameter,
+                             "glGetNamedBufferParameteriv"))
+      return; /* Error already recorded. */
+
+   *params = (GLint) parameter;
+}
+
+void GLAPIENTRY
+_mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname,
+                                  GLint64 *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+   GLint64 parameter;
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+                                       "glGetNamedBufferParameteri64v");
+   if (!bufObj)
       return;
-   default:
-      ; /* fall-through */
-   }
 
-invalid_pname:
-   _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(pname=%s)",
-               _mesa_lookup_enum_by_nr(pname));
+   if (!get_buffer_parameter(ctx, bufObj, pname, &parameter,
+                             "glGetNamedBufferParameteri64v"))
+      return; /* Error already recorded. */
+
+   *params = parameter;
 }
 
 
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 764f87a..e55de54 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -268,6 +268,13 @@ void GLAPIENTRY
 _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params);
 
 void GLAPIENTRY
+_mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params);
+
+void GLAPIENTRY
+_mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname,
+                                  GLint64 *params);
+
+void GLAPIENTRY
 _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params);
 
 void GLAPIENTRY
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index ce4dd30..7d53ba4 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -966,6 +966,8 @@ const struct function gl_core_functions_possible[] = {
    { "glMapNamedBufferRange", 45, -1 },
    { "glUnmapNamedBuffer", 45, -1 },
    { "glFlushMappedNamedBufferRange", 45, -1 },
+   { "glGetNamedBufferParameteriv", 45, -1 },
+   { "glGetNamedBufferParameteri64v", 45, -1 },
    { "glCreateTextures", 45, -1 },
    { "glTextureStorage1D", 45, -1 },
    { "glTextureStorage2D", 45, -1 },
-- 
2.1.0



More information about the mesa-dev mailing list