[Mesa-dev] [PATCH] i965: Allow creating image from different dma_buf fds
Gurchetan Singh
gurchetansingh at chromium.org
Fri Oct 21 03:20:08 UTC 2016
Friendly ping ... this is not in master yet.
On Wed, Aug 31, 2016 at 12:58 AM, Eric Engestrom <eric at engestrom.ch> wrote:
> On Tue, Aug 30, 2016 at 04:49:53PM -0700, krh at bitplanet.net wrote:
> > From: "Kristian H. Kristensen" <hoegsberg at chromium.org>
> >
> > As long as the dma_buf fds import to the same drm_intel_bo, we're fine.
> >
> > Reviewed-by: Stéphane Marchesin <marcheu at chromium.org>
>
> Looks good to me.
> Reviewed-by: Eric Engestrom <eric at engestrom.ch>
>
> > ---
> > src/mesa/drivers/dri/i965/intel_screen.c | 36
> +++++++++++++++++++++++---------
> > 1 file changed, 26 insertions(+), 10 deletions(-)
> >
> > diff --git a/src/mesa/drivers/dri/i965/intel_screen.c
> b/src/mesa/drivers/dri/i965/intel_screen.c
> > index 84977a7..560935d 100644
> > --- a/src/mesa/drivers/dri/i965/intel_screen.c
> > +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> > @@ -706,11 +706,6 @@ intel_create_image_from_fds(__DRIscreen *screen,
> > if (fds == NULL || num_fds < 1)
> > return NULL;
> >
> > - /* We only support all planes from the same bo */
> > - for (i = 0; i < num_fds; i++)
> > - if (fds[0] != fds[i])
> > - return NULL;
> > -
> > f = intel_image_format_lookup(fourcc);
> > if (f == NULL)
> > return NULL;
> > @@ -740,11 +735,25 @@ intel_create_image_from_fds(__DRIscreen *screen,
> > size = end;
> > }
> >
> > - image->bo = drm_intel_bo_gem_create_from_prime(intelScreen->bufmgr,
> > - fds[0], size);
> > - if (image->bo == NULL) {
> > - free(image);
> > - return NULL;
> > + /* We only support all planes from the same bo, but the fds may be
> > + * different. Make sure all fds import to the same bo. The kernel and
> > + * libdrm guarantees this, if the fds refer to the same kernel bo. */
> > + for (i = 0; i < num_fds; i++) {
> > + drm_intel_bo *bo =
> > + drm_intel_bo_gem_create_from_prime(intelScreen->bufmgr,
> fds[i], size);
> > + if (bo == NULL)
> > + goto err_out;
> > +
> > + if (i == 0) {
> > + image->bo = bo;
> > + } else {
> > + /* We need to unref the bo in either case, so do it up front.
> We can
> > + * still compare the pointers below to see if the bo matches.
> > + */
> > + drm_intel_bo_unreference(bo);
> > + if (image->bo != bo)
> > + goto err_out;
> > + }
> > }
> >
> > if (f->nplanes == 1) {
> > @@ -753,6 +762,13 @@ intel_create_image_from_fds(__DRIscreen *screen,
> > }
> >
> > return image;
> > +
> > +err_out:
> > + if (image->bo)
> > + drm_intel_bo_unreference(image->bo);
> > + free(image);
> > +
> > + return NULL;
> > }
> >
> > static __DRIimage *
> > --
> > 2.8.0.rc3.226.g39d4020
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161020/9b8bcf45/attachment-0001.html>
More information about the mesa-dev
mailing list