[Mesa-dev] [PATCH 2/4] DRI: Add DRIimage map and unmap functions

Eric Anholt eric at anholt.net
Fri Apr 22 18:12:58 UTC 2016


Rob Herring <robh at kernel.org> writes:

> Add mapImage and unmapImage functions to DRIimage extension for mapping
> and unmapping DRIimages for CPU access. The caller provides the region of
> the image to map and is returned a pointer to the beginning of the region
> and the stride (which could be different from the original).
>
> Signed-off-by: Rob Herring <robh at kernel.org>
> ---
>  include/GL/internal/dri_interface.h | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
> index b38f87f..082dc10 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -1094,7 +1094,7 @@ struct __DRIdri2ExtensionRec {
>   * extensions.
>   */
>  #define __DRI_IMAGE "DRI_IMAGE"
> -#define __DRI_IMAGE_VERSION 11
> +#define __DRI_IMAGE_VERSION 12
>  
>  /**
>   * These formats correspond to the similarly named MESA_FORMAT_*
> @@ -1133,6 +1133,11 @@ struct __DRIdri2ExtensionRec {
>  #define __DRI_IMAGE_USE_BACKBUFFER      0x0010
>  
>  
> +#define __DRI_IMAGE_TRANSFER_READ            0x1
> +#define __DRI_IMAGE_TRANSFER_WRITE           0x2
> +#define __DRI_IMAGE_TRANSFER_READ_WRITE      \
> +        (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)
> +
>  /**
>   * Four CC formats that matches with WL_DRM_FORMAT_* from wayland_drm.h,
>   * GBM_FORMAT_* from gbm.h, and DRM_FORMAT_* from drm_fourcc.h. Used with
> @@ -1381,6 +1386,23 @@ struct __DRIimageExtensionRec {
>      * \since 10
>      */
>     int (*getCapabilities)(__DRIscreen *screen);
> +
> +   /**
> +    * Map specified region of a __DRIimage for specified usage
> +    *
> +    * \since 12
> +    */
> +   void *(*mapImage)(__DRIcontext *context, __DRIimage *image,
> +                     int x0, int y0, int width, int height,
> +                     unsigned int flags, int *stride, void **data);

I think this needs a longer comment to explain what the interface does:

"Returns a map of the specified region of a __DRIimage for the specified
usage.

flags must always include __DRI_IMAGE_TRANSFER_READ and may include
__DRI_IMAGE_TRANSFER_WRITE if the mapping is written[*].  If
__DRI_IMAGE_TRANSFER_WRITE is not included, behavior when writing the
mapping is undefined.

Returns the byte stride in *stride, and an opaque pointer to data
tracking the mapping in **data, which must be passed to unmapImage()."

I don't know how the READ flag is actually intended to be used, and 3/4
doesn't look at it at all, so it should probably either be used or
deleted.

At some point we may want the other usual mapping flags
(invalidate_buffer/range/unsync), but I think we can bolt those on
afterward when we need them.

> +
> +   /**
> +    * Unmap a previously mapped __DRIimage
> +    *
> +    * \since 12
> +    */
> +   void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);
> +
>  };

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160422/1f131a30/attachment.sig>


More information about the mesa-dev mailing list