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

Ian Romanick idr at freedesktop.org
Mon Oct 15 09:50:05 PDT 2012


On 10/10/2012 12:31 PM, Fredrik Höglund wrote:
> This extension is functionally the same as GL_ARB_map_buffer_range.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> ---
>
> v2: Add the new entry points to tests/dispatch_sanity.cpp
> v3: Incorporate feedback from Ian.
>
>   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 +
>   src/mesa/main/tests/dispatch_sanity.cpp |    2 ++
>   6 files changed, 52 insertions(+), 10 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml
> index 9e73583..22c087c 100644
> --- a/src/mapi/glapi/gen/es_EXT.xml
> +++ b/src/mapi/glapi/gen/es_EXT.xml
> @@ -737,4 +737,28 @@
>       <enum name="COMPRESSED_RGBA_S3TC_DXT5_ANGLE"        value="0x83F3"/>
>   </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 f42da94..587dd17 100644
> --- a/src/mesa/main/api_exec.c
> +++ b/src/mesa/main/api_exec.c
> @@ -767,10 +767,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 d9afe37..ac6bbc5 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 = 0)");
> +      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 4971ebc..510b2a6 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 },
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
> index a8839a5..ca753b3 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -195,6 +195,7 @@ const struct function gles2_functions_possible[] = {
>      { "glEnableVertexAttribArray", -1 },
>      { "glFinish", _gloffset_Finish },
>      { "glFlush", _gloffset_Flush },
> +   { "glFlushMappedBufferRangeEXT", -1 },
>      { "glFramebufferRenderbuffer", -1 },
>      { "glFramebufferTexture2D", -1 },
>      { "glFramebufferTexture3DOES", -1 },
> @@ -244,6 +245,7 @@ const struct function gles2_functions_possible[] = {
>      { "glLineWidth", _gloffset_LineWidth },
>      { "glLinkProgram", -1 },
>      { "glMapBufferOES", -1 },
> +   { "glMapBufferRangeEXT", -1 },
>      { "glMultiDrawArraysEXT", -1 },
>      { "glMultiDrawElementsEXT", -1 },
>      { "glPixelStorei", _gloffset_PixelStorei },
>



More information about the mesa-dev mailing list