[Mesa-dev] [RFC PATCH] mesa: add support for multiple buffer mappings
Ian Romanick
idr at freedesktop.org
Thu Feb 6 15:31:25 PST 2014
On 02/05/2014 02:06 PM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> OpenGL allows a buffer to be mapped only once, but we also map buffers
> internally, e.g. in the software primitive restart fallback, for PBOs,
> vbo_get_minmax_index, etc. This has always been a problem, but it will
> be a bigger problem with persistent buffer mappings, which will prevent
> all Mesa functions from mapping buffers for internal purposes.
>
> This adds a driver inteface to core Mesa which supports multiple buffer
> mappings and allows 2 mappings: one for the GL user and one for Mesa.
>
> Note that Gallium supports an unlimited number of buffer and texture
> mappings, so it's not really an issue for Gallium.
>
> This is just the interface change. Please review. If you don't like it,
> feel free to propose how you would do it. Thank you.
This seems like a reasonable enough interface to me. If we decide that
it's insufficient or ugly later, it should be easy enough to change. I
also like Eric's and Brian's suggestions.
> ---
> src/mesa/main/dd.h | 9 ++++++---
> src/mesa/main/mtypes.h | 25 ++++++++++++++++++-------
> 2 files changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> index ab135f4..fdd0d94 100644
> --- a/src/mesa/main/dd.h
> +++ b/src/mesa/main/dd.h
> @@ -598,14 +598,17 @@ struct dd_function_table {
> */
> void * (*MapBufferRange)( struct gl_context *ctx, GLintptr offset,
> GLsizeiptr length, GLbitfield access,
> - struct gl_buffer_object *obj);
> + struct gl_buffer_object *obj,
> + enum gl_map_buffer_index index);
>
> void (*FlushMappedBufferRange)(struct gl_context *ctx,
> GLintptr offset, GLsizeiptr length,
> - struct gl_buffer_object *obj);
> + struct gl_buffer_object *obj,
> + enum gl_map_buffer_index index);
>
> GLboolean (*UnmapBuffer)( struct gl_context *ctx,
> - struct gl_buffer_object *obj );
> + struct gl_buffer_object *obj,
> + enum gl_map_buffer_index index);
> /*@}*/
>
> /**
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 4aaad16..5200377 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -1437,6 +1437,22 @@ struct gl_viewport_attrib
> GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */
> };
>
> +enum gl_map_buffer_index {
> + MAP_CTX_USER,
> + MAP_CTX_INTERNAL,
> +
> + NUM_MAP_BUFFER_CONTEXTS
> +};
> +
> +/**
> + * Fields describing a mapped buffer range.
> + */
> +struct gl_map_buffer_context {
> + GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */
> + GLvoid *Pointer; /**< User-space address of mapping */
> + GLintptr Offset; /**< Mapped offset */
> + GLsizeiptr Length; /**< Mapped length */
> +};
>
> /**
> * GL_ARB_vertex/pixel_buffer_object buffer object
> @@ -1451,17 +1467,12 @@ struct gl_buffer_object
> GLbitfield StorageFlags; /**< GL_MAP_PERSISTENT_BIT, etc. */
> GLsizeiptrARB Size; /**< Size of buffer storage in bytes */
> GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
> - /** Fields describing a mapped buffer */
> - /*@{*/
> - GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */
> - GLvoid *Pointer; /**< User-space address of mapping */
> - GLintptr Offset; /**< Mapped offset */
> - GLsizeiptr Length; /**< Mapped length */
> - /*@}*/
> GLboolean DeletePending; /**< true if buffer object is removed from the hash */
> GLboolean Written; /**< Ever written to? (for debugging) */
> GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
> GLboolean Immutable; /**< GL_ARB_buffer_storage */
> +
> + struct gl_map_buffer_context Mappings[NUM_MAP_BUFFER_CONTEXTS];
> };
>
>
More information about the mesa-dev
mailing list