[Mesa-dev] [PATCH] i965: implement (un)mapImage

Chris Wilson chris at chris-wilson.co.uk
Wed Nov 8 17:21:47 UTC 2017


Quoting Julien Isorce (2017-11-08 16:55:05)
> v2: add early return if (flag & MAP_INTERNAL_MASK)
> 
> Already implemented for Gallium drivers.
> 
> Useful for gbm_bo_(un)map.
> 
> Tested by porting wayland/weston/clients/simple-dmabuf-drm.c to GBM.
> 
> Signed-off-by: Julien Isorce <jisorce at oblong.com>
> ---
>  src/mesa/drivers/dri/i965/intel_screen.c | 51 ++++++++++++++++++++++++++++++--
>  1 file changed, 49 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
> index cdc36ad..b7b0e25 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -755,6 +755,53 @@ intel_create_image(__DRIscreen *dri_screen,
>                                 loaderPrivate);
>  }
>  
> +static void *
> +intel_map_image(__DRIcontext *context, __DRIimage *image,
> +                int x0, int y0, int width, int height,
> +                unsigned int flags, int *stride, void **map_info)
> +{
> +  struct brw_context *brw = NULL;
> +  struct brw_bo *bo = NULL;
> +  void *raw_data = NULL;
> +
> +  if (!context || !image || !stride || !map_info || *map_info)
> +     return NULL;
> +
> +  if (flags & MAP_INTERNAL_MASK)
> +     return NULL;
> +
> +  brw = context->driverPrivate;
> +  bo = image->bo;
> +
> +  assert(brw);
> +  assert(bo);
> +
> +  /* DRI flags and GL_MAP.*_BIT flags are the same, so just pass them on. */
> +  raw_data = brw_bo_map(brw, bo, flags);
> +
> +  if (raw_data) {
> +    *map_info = raw_data;
> +    *stride = image->pitch;
> +  }
> +
> +  return raw_data;

Did you not say the returned address is to pixel0 of the (x,y)x(w,h) rect
within the image? So raw_data + y0*image->pitch + x0*image->cpp?
Or something more like raw_data + y0/util_format_get_blockheight(image->format) * image->pitch +
x0/util_format_get_blockwidth(image->format) * util_format_get_blocksize(image->format);
-Chris
 


More information about the mesa-dev mailing list