[Mesa-dev] [PATCH] mesa/es: Enable GL_EXT_map_buffer_range

Fredrik Höglund fredrik at kde.org
Tue Sep 25 13:17:19 PDT 2012


This extension is functionally the same as GL_ARB_map_buffer_range.
---
 src/mapi/glapi/gen/es_EXT.xml  |   24 ++++++++++++++++++++++++
 src/mapi/glapi/gen/gles_api.py |    6 ++++++
 src/mesa/main/api_exec.c       |    7 +++----
 src/mesa/main/bufferobj.c      |   22 ++++++++++++++++------
 src/mesa/main/extensions.c     |    1 +
 5 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml
index fc2ec62..2c130f9 100644
--- a/src/mapi/glapi/gen/es_EXT.xml
+++ b/src/mapi/glapi/gen/es_EXT.xml
@@ -731,4 +731,28 @@
     <enum name="RG8_EXT"                                  value="0x822B"/>
 </category>
 
+<!-- 121. GL_EXT_map_buffer_range -->
+<category name="GL_EXT_map_buffer_range" number="121">
+    <enum name="MAP_READ_BIT_EXT"                         value="0x0001"/>
+    <enum name="MAP_WRITE_BIT_EXT"                        value="0x0002"/>
+    <enum name="MAP_INVALIDATE_RANGE_BIT_EXT"             value="0x0004"/>
+    <enum name="MAP_INVALIDATE_BUFFER_BIT_EXT"            value="0x0008"/>
+    <enum name="MAP_FLUSH_EXPLICIT_BIT_EXT"               value="0x0010"/>
+    <enum name="MAP_UNSYNCHRONIZED_BIT_EXT"               value="0x0020"/>
+
+    <function name="MapBufferRangeEXT" alias="MapBufferRange">
+        <param name="target" type="GLenum"/>
+        <param name="offset" type="GLintptr"/>
+        <param name="size" type="GLsizeiptr"/>
+        <param name="length" type="GLbitfield"/>
+        <return type="GLvoid *"/>
+    </function>
+
+    <function name="FlushMappedBufferRangeEXT" alias="FlushMappedBufferRange">
+        <param name="target" type="GLenum"/>
+        <param name="offset" type="GLintptr"/>
+        <param name="length" type="GLsizeiptr"/>
+    </function>
+</category>
+
 </OpenGLAPI>
diff --git a/src/mapi/glapi/gen/gles_api.py b/src/mapi/glapi/gen/gles_api.py
index 8dfef65..3bee1a6 100644
--- a/src/mapi/glapi/gen/gles_api.py
+++ b/src/mapi/glapi/gen/gles_api.py
@@ -185,6 +185,9 @@ es1_api = es1_core + (
         'GetBufferPointervOES',
         'MapBufferOES',
         'UnmapBufferOES',
+        # GL_EXT_map_buffer_range
+        'MapBufferRangeEXT',
+        'FlushMappedBufferRangeEXT',
         # GL_EXT_multi_draw_arrays
         'MultiDrawArraysEXT',
         'MultiDrawElementsEXT',
@@ -436,6 +439,9 @@ es2_api = es2_core + (
         'GetBufferPointervOES',
         'MapBufferOES',
         'UnmapBufferOES',
+        # GL_EXT_map_buffer_range
+        'MapBufferRangeEXT',
+        'FlushMappedBufferRangeEXT',
         # GL_EXT_multi_draw_arrays
         'MultiDrawArraysEXT',
         'MultiDrawElementsEXT',
diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c
index 1da0415..642bd93 100644
--- a/src/mesa/main/api_exec.c
+++ b/src/mesa/main/api_exec.c
@@ -757,10 +757,9 @@ _mesa_create_exec_table(struct gl_context *ctx)
       SET_RenderbufferStorageMultisample(exec, _mesa_RenderbufferStorageMultisample);
    }
 
-   if (ctx->API != API_OPENGLES2) {
-      SET_MapBufferRange(exec, _mesa_MapBufferRange);
-      SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange);
-   }
+   /* GL_ARB_map_buffer_range / GL_EXT_map_buffer_range */
+   SET_MapBufferRange(exec, _mesa_MapBufferRange);
+   SET_FlushMappedBufferRange(exec, _mesa_FlushMappedBufferRange);
 
    /* GL_ARB_copy_buffer */
    if (ctx->API != API_OPENGLES2) {
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0fc27e4..beb3af6 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1312,20 +1312,17 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
       *params = _mesa_bufferobj_mapped(bufObj);
       return;
    case GL_BUFFER_ACCESS_FLAGS:
-      if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_map_buffer_range)
-          && !_mesa_is_gles3(ctx))
+      if (!ctx->Extensions.ARB_map_buffer_range)
          goto invalid_pname;
       *params = bufObj->AccessFlags;
       return;
    case GL_BUFFER_MAP_OFFSET:
-      if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_map_buffer_range)
-          && !_mesa_is_gles3(ctx))
+      if (!ctx->Extensions.ARB_map_buffer_range)
          goto invalid_pname;
       *params = (GLint) bufObj->Offset;
       return;
    case GL_BUFFER_MAP_LENGTH:
-      if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_map_buffer_range)
-          && !_mesa_is_gles3(ctx))
+      if (!ctx->Extensions.ARB_map_buffer_range)
          goto invalid_pname;
       *params = (GLint) bufObj->Length;
       return;
@@ -1524,6 +1521,19 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
       return NULL;
    }
 
+   /* Page 38 of the PDF of the OpenGL ES 3.0 spec says:
+    *
+    *     "An INVALID_OPERATION error is generated for any of the following
+    *     conditions:
+    *
+    *     * <length> is zero."
+    */
+   if (_mesa_is_gles(ctx) && length == 0) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glMapBufferRange(length = %ld)", (long)length);
+      return NULL;
+   }
+
    if (access & ~(GL_MAP_READ_BIT |
                   GL_MAP_WRITE_BIT |
                   GL_MAP_INVALIDATE_RANGE_BIT |
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index bd7c7ba..9b9cb54 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -176,6 +176,7 @@ static const struct extension extension_table[] = {
    { "GL_EXT_framebuffer_sRGB",                    o(EXT_framebuffer_sRGB),                    GL,             1998 },
    { "GL_EXT_gpu_program_parameters",              o(EXT_gpu_program_parameters),              GLL,            2006 },
    { "GL_EXT_gpu_shader4",                         o(EXT_gpu_shader4),                         GL,             2006 },
+   { "GL_EXT_map_buffer_range",                    o(ARB_map_buffer_range),                    ES1 | ES2,      2012 },
    { "GL_EXT_multi_draw_arrays",                   o(dummy_true),                              GLL | ES1 | ES2, 1999 },
    { "GL_EXT_packed_depth_stencil",                o(EXT_packed_depth_stencil),                GL,             2005 },
    { "GL_EXT_packed_float",                        o(EXT_packed_float),                        GL,             2004 },
-- 
1.7.7.3



More information about the mesa-dev mailing list