mesa: add support for glMapNamedBufferRangeEXT()
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 25 May 2018 03:24:47 +0000 (13:24 +1000)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 28 Jun 2019 19:41:16 +0000 (15:41 -0400)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/mapi/glapi/gen/EXT_direct_state_access.xml
src/mapi/glapi/gen/static_data.py
src/mesa/main/bufferobj.c
src/mesa/main/bufferobj.h
src/mesa/main/tests/dispatch_sanity.cpp

index a19677cde10893ee1f347fca924157b9505c9bee..6a6a118a2bddf8d7be036081e015bad219c19b43 100644 (file)
       <param name="size" type="GLsizeiptr" />
       <param name="data" type="const GLvoid *" />
    </function>
+
+   <!-- OpenGL 3.0 -->
+
+   <function name="MapNamedBufferRangeEXT">
+      <return type="GLvoid *" />
+      <param name="buffer" type="GLuint" />
+      <param name="offset" type="GLintptr" />
+      <param name="length" type="GLsizeiptr" />
+      <param name="access" type="GLbitfield" />
+   </function>
+
 </category>
 </OpenGLAPI>
index 582530c046a691714ed4f2cbf96f518b2b30b32e..3970452b0cbe33806b1fd1ce0e7dd3cec9193350 100644 (file)
@@ -1477,6 +1477,7 @@ offsets = {
     "NamedBufferDataEXT": 1441,
     "NamedBufferSubDataEXT": 1442,
     "NamedBufferStorageEXT": 1443,
+    "MapNamedBufferRangeEXT": 1444,
 }
 
 functions = [
index 0d350dbabd585781f31d90817a2dc658c31da40f..a751e41d6e8e7593efa17d384944bd9a8773e234 100644 (file)
@@ -3277,30 +3277,49 @@ _mesa_MapNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
                            "glMapNamedBufferRange");
 }
 
-void * GLAPIENTRY
-_mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
-                          GLbitfield access)
+static void *
+map_named_buffer_range(GLuint buffer, GLintptr offset, GLsizeiptr length,
+                       GLbitfield access, bool dst_ext, const char *func)
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *bufObj;
+   struct gl_buffer_object *bufObj = NULL;
 
    if (!ctx->Extensions.ARB_map_buffer_range) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glMapNamedBufferRange("
-                  "ARB_map_buffer_range not supported)");
+                  "%s(ARB_map_buffer_range not supported)", func);
       return NULL;
    }
 
-   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glMapNamedBufferRange");
-   if (!bufObj)
-      return NULL;
+   if (dst_ext) {
+      bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+      if (!_mesa_handle_bind_buffer_gen(ctx, buffer, &bufObj, func))
+         return NULL;
+   } else {
+      bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
+      if (!bufObj)
+         return NULL;
+   }
 
-   if (!validate_map_buffer_range(ctx, bufObj, offset, length, access,
-                                  "glMapNamedBufferRange"))
+   if (!validate_map_buffer_range(ctx, bufObj, offset, length, access, func))
       return NULL;
 
-   return map_buffer_range(ctx, bufObj, offset, length, access,
-                           "glMapNamedBufferRange");
+   return map_buffer_range(ctx, bufObj, offset, length, access, func);
+}
+
+void * GLAPIENTRY
+_mesa_MapNamedBufferRangeEXT(GLuint buffer, GLintptr offset, GLsizeiptr length,
+                             GLbitfield access)
+{
+   return map_named_buffer_range(buffer, offset, length, access, true,
+                                 "glMapNamedBufferRangeEXT");
+}
+
+void * GLAPIENTRY
+_mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
+                          GLbitfield access)
+{
+   return map_named_buffer_range(buffer, offset, length, access, false,
+                                 "glMapNamedBufferRange");
 }
 
 /**
index 6b35d70606f66c4aec395fc2851320045cc93fa4..c3b57ef7fe6955dc46b6f27040d75fd7f3b6067e 100644 (file)
@@ -357,6 +357,9 @@ _mesa_MapNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
 void * GLAPIENTRY
 _mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
                           GLbitfield access);
+void * GLAPIENTRY
+_mesa_MapNamedBufferRangeEXT(GLuint buffer, GLintptr offset,
+                             GLsizeiptr length, GLbitfield access);
 
 void * GLAPIENTRY
 _mesa_MapBuffer_no_error(GLenum target, GLenum access);
index c789a2d513b6a6f062afc83d6ad2277ca6e4a858..8813e945bfcfb53b16a58e77c912ddf201c4ae1d 100644 (file)
@@ -1222,7 +1222,7 @@ const struct function common_desktop_functions_possible[] = {
    //{ "glGetVertexArrayPointervEXT", 30, -1 },
    //{ "glGetVertexArrayIntegeri_vEXT", 30, -1 },
    //{ "glGetVertexArrayPointeri_vEXT", 30, -1 },
-   //{ "glMapNamedBufferRangeEXT", 30, -1 },
+   { "glMapNamedBufferRangeEXT", 30, -1 },
    //{ "glFlushMappedNamedBufferRangeEXT", 30, -1 },
 
    /* GL_ARB_internalformat_query */