[Mesa-dev] [PATCH v3] st/va: ensure linear memory for dmabuf
Christian König
deathsimple at vodafone.de
Mon Jun 13 08:37:25 UTC 2016
Am 13.06.2016 um 10:12 schrieb Julien Isorce:
> In order to do zero-copy between two different devices
> the memory should not be tiled.
>
> Tested with GStreamer on a laptop that has 2 GPUs:
> 1- gstvaapidecode:
> HW decoding and dmabuf export with nouveau driver on Nvidia GPU.
> 2- glimagesink:
> EGLImage imports dmabuf on Intel GPU.
>
> TEST: DRI_PRIME=1 gst-launch vaapidecodebin ! glimagesink
>
> Signed-off-by: Julien Isorce <j.isorce at samsung.com>
> ---
> src/gallium/auxiliary/vl/vl_video_buffer.c | 3 +++
> src/gallium/include/pipe/p_video_codec.h | 1 +
> src/gallium/state_trackers/va/surface.c | 8 ++++++++
> 3 files changed, 12 insertions(+)
>
> diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c
> index 4a68ac1..b383ad2 100644
> --- a/src/gallium/auxiliary/vl/vl_video_buffer.c
> +++ b/src/gallium/auxiliary/vl/vl_video_buffer.c
> @@ -253,6 +253,9 @@ vl_video_buffer_template(struct pipe_resource *templ,
> templ->bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
> templ->usage = usage;
>
> + if (tmpl->bind)
The "if" here is probably superfluous.
With that fixed the patch is Reviewed-by: Christian König
<christian.koenig at amd.com>.
Regards,
Christian.
> + templ->bind |= tmpl->bind;
> +
> vl_video_buffer_adjust_size(&templ->width0, &templ->height0, plane,
> tmpl->chroma_format, false);
> }
> diff --git a/src/gallium/include/pipe/p_video_codec.h b/src/gallium/include/pipe/p_video_codec.h
> index b5575ab..b4b2b9c 100644
> --- a/src/gallium/include/pipe/p_video_codec.h
> +++ b/src/gallium/include/pipe/p_video_codec.h
> @@ -126,6 +126,7 @@ struct pipe_video_buffer
> unsigned width;
> unsigned height;
> bool interlaced;
> + unsigned bind;
>
> /**
> * destroy this video buffer
> diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
> index 8a6a397..5efb893 100644
> --- a/src/gallium/state_trackers/va/surface.c
> +++ b/src/gallium/state_trackers/va/surface.c
> @@ -621,6 +621,14 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
>
> switch (memory_type) {
> case VA_SURFACE_ATTRIB_MEM_TYPE_VA:
> + /* The application will clear the TILING flag when the surface is
> + * intended to be exported as dmabuf. Adding shared flag because not
> + * null memory_attibute means VASurfaceAttribExternalBuffers is used.
> + */
> + if (memory_attibute &&
> + !(memory_attibute->flags & VA_SURFACE_EXTBUF_DESC_ENABLE_TILING))
> + templat.bind = PIPE_BIND_LINEAR | PIPE_BIND_SHARED;
> +
> surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat);
> if (!surf->buffer) {
> FREE(surf);
More information about the mesa-dev
mailing list