main: Add entry points for MapNamedBuffer[Range].
authorLaura Ekstrand <laura@jlekstrand.net>
Wed, 11 Feb 2015 22:09:52 +0000 (14:09 -0800)
committerLaura Ekstrand <laura@jlekstrand.net>
Tue, 17 Mar 2015 17:18:34 +0000 (10:18 -0700)
Reviewed-by: Fredrik Höglund <fredrik@kde.org>
src/mapi/glapi/gen/ARB_direct_state_access.xml
src/mesa/main/bufferobj.c
src/mesa/main/bufferobj.h
src/mesa/main/tests/dispatch_sanity.cpp

index ce4017b29a8ca869e67e89712abdef79acfea263..557316a27a7b23431d6d732b5037e50ff1f162e6 100644 (file)
       <param name="data" type="const GLvoid *" />
    </function>
 
+   <function name="MapNamedBuffer" offset="assign">
+      <return type="GLvoid *" />
+      <param name="buffer" type="GLuint" />
+      <param name="access" type="GLenum" />
+   </function>
+
+   <function name="MapNamedBufferRange" offset="assign">
+      <return type="GLvoid *" />
+      <param name="buffer" type="GLuint" />
+      <param name="offset" type="GLintptr" />
+      <param name="length" type="GLsizeiptr" />
+      <param name="access" type="GLbitfield" />
+   </function>
+
    <!-- Texture object functions -->
 
    <function name="CreateTextures" offset="assign">
index d37e4a52b4351a8387936100c001bf019e2c1fc4..0d1a69053eccf0d1e9c7320413c04c425c8dcc53 100644 (file)
@@ -2346,6 +2346,28 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
                                  "glMapBufferRange");
 }
 
+void * GLAPIENTRY
+_mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
+                          GLbitfield access)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   if (!ctx->Extensions.ARB_map_buffer_range) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapNamedBufferRange("
+                  "ARB_map_buffer_range not supported)");
+      return NULL;
+   }
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glMapNamedBufferRange");
+   if (!bufObj)
+      return NULL;
+
+   return _mesa_map_buffer_range(ctx, bufObj, offset, length, access,
+                                 "glMapNamedBufferRange");
+}
+
 /**
  * Converts GLenum access from MapBuffer and MapNamedBuffer into
  * flags for input to _mesa_map_buffer_range.
@@ -2391,6 +2413,26 @@ _mesa_MapBuffer(GLenum target, GLenum access)
                                  "glMapBuffer");
 }
 
+void * GLAPIENTRY
+_mesa_MapNamedBuffer(GLuint buffer, GLenum access)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+   GLbitfield accessFlags;
+
+   if (!get_map_buffer_access_flags(ctx, access, &accessFlags)) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glMapNamedBuffer(invalid access)");
+      return NULL;
+   }
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glMapNamedBuffer");
+   if (!bufObj)
+      return NULL;
+
+   return _mesa_map_buffer_range(ctx, bufObj, 0, bufObj->Size, accessFlags,
+                                 "glMapNamedBuffer");
+}
+
 
 /**
  * See GL_ARB_map_buffer_range spec
index 3584a80f1ef77d13dc33cbfa68f30836a59ea6d3..6305b5cabeda5aa6b06d93592de8af093809c3e7 100644 (file)
@@ -245,9 +245,6 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
                               GLenum format, GLenum type,
                               const GLvoid *data);
 
-void * GLAPIENTRY
-_mesa_MapBuffer(GLenum target, GLenum access);
-
 GLboolean GLAPIENTRY
 _mesa_UnmapBuffer(GLenum target);
 
@@ -274,6 +271,17 @@ void * GLAPIENTRY
 _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
                      GLbitfield access);
 
+void * GLAPIENTRY
+_mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
+                          GLbitfield access);
+
+void * GLAPIENTRY
+_mesa_MapBuffer(GLenum target, GLenum access);
+
+void * GLAPIENTRY
+_mesa_MapNamedBuffer(GLuint buffer, GLenum access);
+
+
 void GLAPIENTRY
 _mesa_FlushMappedBufferRange(GLenum target,
                              GLintptr offset, GLsizeiptr length);
index aff5cd6319c028c7bc61e8eaf330b99e7300e98c..bda761ae543a03b11b3bb9158ff93be2c053ab32 100644 (file)
@@ -960,6 +960,8 @@ const struct function gl_core_functions_possible[] = {
    { "glCopyNamedBufferSubData", 45, -1 },
    { "glClearNamedBufferData", 45, -1 },
    { "glClearNamedBufferSubData", 45, -1 },
+   { "glMapNamedBuffer", 45, -1 },
+   { "glMapNamedBufferRange", 45, -1 },
    { "glCreateTextures", 45, -1 },
    { "glTextureStorage1D", 45, -1 },
    { "glTextureStorage2D", 45, -1 },