[Mesa-dev] [PATCH 17/23] main: Refactor FlushMappedBufferRange.

Fredrik Höglund fredrik at kde.org
Mon Mar 16 13:03:43 PDT 2015


This patch is:

Reviewed-by: Fredrik Höglund <fredrik at kde.org>

On Thursday 12 February 2015, Laura Ekstrand wrote:
> v2:-Remove "_mesa" from in front of static software fallback.
>    -Split out the refactor from the addition of the DSA entry points.
> ---
>  src/mesa/main/bufferobj.c | 60 +++++++++++++++++++++++++++--------------------
>  src/mesa/main/bufferobj.h |  6 +++++
>  2 files changed, 40 insertions(+), 26 deletions(-)
> 
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index bb7ecdd..992e940 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -722,10 +722,10 @@ map_buffer_range_fallback(struct gl_context *ctx, GLintptr offset,
>   * Called via glFlushMappedBufferRange().
>   */
>  static void
> -_mesa_buffer_flush_mapped_range( struct gl_context *ctx,
> -                                 GLintptr offset, GLsizeiptr length,
> -                                 struct gl_buffer_object *obj,
> -                                 gl_map_buffer_index index)
> +flush_mapped_buffer_range_fallback(struct gl_context *ctx,
> +                                   GLintptr offset, GLsizeiptr length,
> +                                   struct gl_buffer_object *obj,
> +                                   gl_map_buffer_index index)
>  {
>     (void) ctx;
>     (void) offset;
> @@ -1117,7 +1117,7 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver)
>  
>     /* GL_ARB_map_buffer_range */
>     driver->MapBufferRange = map_buffer_range_fallback;
> -   driver->FlushMappedBufferRange = _mesa_buffer_flush_mapped_range;
> +   driver->FlushMappedBufferRange = flush_mapped_buffer_range_fallback;
>  
>     /* GL_ARB_copy_buffer */
>     driver->CopyBufferSubData = copy_buffer_sub_data_fallback;
> @@ -2424,57 +2424,49 @@ _mesa_MapNamedBuffer(GLuint buffer, GLenum access)
>  }
>  
>  
> -/**
> - * See GL_ARB_map_buffer_range spec
> - */
> -void GLAPIENTRY
> -_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
> +void
> +_mesa_flush_mapped_buffer_range(struct gl_context *ctx,
> +                                struct gl_buffer_object *bufObj,
> +                                GLintptr offset, GLsizeiptr length,
> +                                const char *func)
>  {
> -   GET_CURRENT_CONTEXT(ctx);
> -   struct gl_buffer_object *bufObj;
> -
>     if (!ctx->Extensions.ARB_map_buffer_range) {
>        _mesa_error(ctx, GL_INVALID_OPERATION,
> -                  "glFlushMappedBufferRange(extension not supported)");
> +                  "%s(ARB_map_buffer_range not supported)", func);
>        return;
>     }
>  
>     if (offset < 0) {
>        _mesa_error(ctx, GL_INVALID_VALUE,
> -                  "glFlushMappedBufferRange(offset = %ld)", (long)offset);
> +                  "%s(offset %ld < 0)", func, (long) offset);
>        return;
>     }
>  
>     if (length < 0) {
>        _mesa_error(ctx, GL_INVALID_VALUE,
> -                  "glFlushMappedBufferRange(length = %ld)", (long)length);
> +                  "%s(length %ld < 0)", func, (long) length);
>        return;
>     }
>  
> -   bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target,
> -                       GL_INVALID_OPERATION);
> -   if (!bufObj)
> -      return;
> -
>     if (!_mesa_bufferobj_mapped(bufObj, MAP_USER)) {
>        /* buffer is not mapped */
>        _mesa_error(ctx, GL_INVALID_OPERATION,
> -                  "glFlushMappedBufferRange(buffer is not mapped)");
> +                  "%s(buffer is not mapped)", func);
>        return;
>     }
>  
>     if ((bufObj->Mappings[MAP_USER].AccessFlags &
>          GL_MAP_FLUSH_EXPLICIT_BIT) == 0) {
>        _mesa_error(ctx, GL_INVALID_OPERATION,
> -                  "glFlushMappedBufferRange(GL_MAP_FLUSH_EXPLICIT_BIT not set)");
> +                  "%s(GL_MAP_FLUSH_EXPLICIT_BIT not set)", func);
>        return;
>     }
>  
>     if (offset + length > bufObj->Mappings[MAP_USER].Length) {
>        _mesa_error(ctx, GL_INVALID_VALUE,
> -		  "glFlushMappedBufferRange(offset %ld + length %ld > mapped length %ld)",
> -		  (long)offset, (long)length,
> -                  (long)bufObj->Mappings[MAP_USER].Length);
> +                  "%s(offset %ld + length %ld > mapped length %ld)", func,
> +                  (long) offset, (long) length,
> +                  (long) bufObj->Mappings[MAP_USER].Length);
>        return;
>     }
>  
> @@ -2485,6 +2477,22 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
>                                           MAP_USER);
>  }
>  
> +void GLAPIENTRY
> +_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset,
> +                             GLsizeiptr length)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_buffer_object *bufObj;
> +
> +   bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target,
> +                       GL_INVALID_OPERATION);
> +   if (!bufObj)
> +      return;
> +
> +   _mesa_flush_mapped_buffer_range(ctx, bufObj, offset, length,
> +                                   "glFlushMappedBufferRange");
> +}
> +
>  
>  static GLenum
>  buffer_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option)
> diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
> index 40bd9fc..f51bf36 100644
> --- a/src/mesa/main/bufferobj.h
> +++ b/src/mesa/main/bufferobj.h
> @@ -162,6 +162,12 @@ _mesa_map_buffer_range(struct gl_context *ctx,
>                         GLbitfield access, const char *func);
>  
>  extern void
> +_mesa_flush_mapped_buffer_range(struct gl_context *ctx,
> +                                struct gl_buffer_object *bufObj,
> +                                GLintptr offset, GLsizeiptr length,
> +                                const char *func);
> +
> +extern void
>  _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
>                              GLintptr offset, GLsizeiptr size,
>                              const GLvoid *clearValue,
> 



More information about the mesa-dev mailing list