On Sat, Sep 8, 2018 at 12:33 AM Timothy Arceri <tarc...@itsqueeze.com> wrote:
>
> ---
>  .../glapi/gen/EXT_direct_state_access.xml     | 10 +++++
>  src/mesa/main/bufferobj.c                     | 45 +++++++++++++------
>  src/mesa/main/bufferobj.h                     |  3 ++
>  src/mesa/main/tests/dispatch_sanity.cpp       |  2 +-
>  4 files changed, 46 insertions(+), 14 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/EXT_direct_state_access.xml 
> b/src/mapi/glapi/gen/EXT_direct_state_access.xml
> index 203730b0242..d8fdf8921da 100644
> --- a/src/mapi/glapi/gen/EXT_direct_state_access.xml
> +++ b/src/mapi/glapi/gen/EXT_direct_state_access.xml
> @@ -124,5 +124,15 @@
>        <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>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index de809d31f35..23f2f713815 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -3270,30 +3270,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)

dsa_ext?

>  {
>     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");
>  }
>
>  /**
> diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
> index 6b35d70606f..c3b57ef7fe6 100644
> --- a/src/mesa/main/bufferobj.h
> +++ b/src/mesa/main/bufferobj.h
> @@ -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);
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
> b/src/mesa/main/tests/dispatch_sanity.cpp
> index 5a0cdfd78f2..ba020c31e70 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -1231,7 +1231,7 @@ const struct function 
> common_desktop_functions_possible[] = {
>     //{ "glGetVertexArrayPointervEXT", 10, -1 },
>     //{ "glGetVertexArrayIntegeri_vEXT", 10, -1 },
>     //{ "glGetVertexArrayPointeri_vEXT", 10, -1 },
> -   //{ "glMapNamedBufferRangeEXT", 10, -1 },
> +   { "glMapNamedBufferRangeEXT", 10, -1 },
>     //{ "glFlushMappedNamedBufferRangeEXT", 10, -1 },
>
>     /* GL_ARB_internalformat_query */
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to