[Mesa-dev] [PATCH 4/7] mesa/main: add USAGE_PERSISTENT_WRITE_MAP flag to buffer UsageHistory

Ian Romanick idr at freedesktop.org
Fri Jan 8 15:09:11 PST 2016


On 01/07/2016 04:57 PM, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
> 
> We will want to disable minmax index caching for buffers that are used in this
> way.

I think this is too heavy handed.  It seems like what you want is to
disable caching of draws in the mapped range while it is mapped.  If an
app has a 16mb buffer, maps the last 8mb, unmaps it, then draws, it
would be a shame to lose the cache forever.  To avoid having to do all
the range checking in the draw and cache-invalidate code, you could just
clear the USAGE_PERSISTENT_WRITE_MAP bit in the unmap.  Right?

> ---
>  src/mesa/main/bufferobj.c | 6 +++++-
>  src/mesa/main/mtypes.h    | 1 +
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index 8fd9a06..ef2b495 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -2474,9 +2474,13 @@ _mesa_map_buffer_range(struct gl_context *ctx,
>        assert(bufObj->Mappings[MAP_USER].AccessFlags == access);
>     }
>  
> -   if (access & GL_MAP_WRITE_BIT)
> +   if (access & GL_MAP_WRITE_BIT) {
>        bufObj->Written = GL_TRUE;
>  
> +      if (access & GL_MAP_PERSISTENT_BIT)
> +         bufObj->UsageHistory |= USAGE_PERSISTENT_WRITE_MAP;
> +   }
> +
>  #ifdef VBO_DEBUG
>     if (strstr(func, "Range") == NULL) { /* If not MapRange */
>        printf("glMapBuffer(%u, sz %ld, access 0x%x)\n",
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 9e4b2c8..4d625da 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -1255,6 +1255,7 @@ typedef enum {
>     USAGE_SHADER_STORAGE_BUFFER = 0x8,
>     USAGE_TRANSFORM_FEEDBACK_BUFFER = 0x10,
>     USAGE_PIXEL_PACK_BUFFER = 0x20,
> +   USAGE_PERSISTENT_WRITE_MAP = 0x40,
>  } gl_buffer_usage;
>  
>  
> 



More information about the mesa-dev mailing list