[Mesa-dev] [RFC PATCH] mesa: add support for multiple buffer mappings
Brian Paul
brianp at vmware.com
Thu Feb 6 14:43:14 PST 2014
On 02/05/2014 03: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.
>
> ---
> 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
> +};
We've been doing typedefs for the enums in mtypes.h and I'd probably use
shorter names. Maybe this:
typedef enum
{
MAP_USER,
MAP_INTERNAL,
MAP_BUFFER_COUNT;
} gl_map_buffer_index;
> +
> +/**
> + * 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 */
> +};
I agree with Eric's naming suggestion here.
Otherwise, this looks OK to me, though I haven't really thought it
through very much.
-Brian
More information about the mesa-dev
mailing list