[Mesa-dev] [PATCH] i965: Naive implementation of gbm_bo_map
Emil Velikov
emil.l.velikov at gmail.com
Mon Apr 24 10:52:12 UTC 2017
Hi Ben,
Just realised that the CrOS team might be interested in this as well -
adding Tomasz.
On 21 April 2017 at 18:17, Ben Widawsky <ben at bwidawsk.net> wrote:
> Could do smarter stuff with the mappings. I decided not to.
>
> Tested with kmscube. No current clients seem to use non-zero x0, y0, so
> that's untested.
>
> Cc: Tapani Pälli <tapani.palli at intel.com> (AndroidIA?)
Tomasz, Tapani,
With this in place you should be able to drop the [patched] 3.3Kloc
drm_gralloc in favour of the 0.6Kloc gbm_gralloc [1].
Latter is what the cool kids are using ;-)
[1] https://github.com/robherring/gbm_gralloc
> Cc: Emil Velikov <emil.velikov at collabora.com>
> Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
> ---
> src/mesa/drivers/dri/i965/intel_screen.c | 39 ++++++++++++++++++++++++++++++--
> 1 file changed, 37 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
> index 34a5f18af2..f89de3c9d4 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -926,6 +926,41 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
> return image;
> }
>
> +static void *
> +intel_map_image(__DRIcontext *context, __DRIimage *image,
> + int x0, int y0, int width, int height,
> + unsigned int flags, int *stride, void **data)
> +{
> + if (!image || !data || *data)
> + return NULL;
> +
> + /* FIXME: add width/height check */
> +
> + brw_bo_reference(image->bo);
> +
> + uintptr_t offset =
> + y0 * image->pitch + x0 * _mesa_get_format_bytes(image->format);
> + void *bo_map = brw_bo_map__wc(image->bo);
> +
> + if (bo_map) {
> + *data = image->bo;
> + *stride = image->pitch;
> + } else {
> + *data = NULL;
> + *stride = 0;
We shouldn't be touching these if the function fails.
> + brw_bo_unreference(image->bo);
Please explicitly return NULL here, since offset can be non-zero
should brw_bo_map__wc() fail.
> + }
> +
> + return bo_map + offset;
Thanks
Emil
More information about the mesa-dev
mailing list