[virglrenderer-devel] [PATCH] virglrenderer: Add method to import EGLImageKHRs as resources.

David Riley davidriley at chromium.org
Thu Jun 7 15:55:08 UTC 2018


Hi Elie,

Thanks for looking at this.  I'll get a fix for this up.

On Thu, Jun 7, 2018 at 6:43 AM Elie Tournier <tournier.elie at gmail.com>
wrote:

> Hello David,
>
> I had a look to your patch.
> See comment below.
>
> Elie
>
> On Wed, May 30, 2018 at 11:50:19AM -0700, David Riley wrote:
> > Allow resources created externally (eg gbm created buffers as
> > dma bufs) to be used.
> >
> > Signed-off-by: David Riley <davidriley at chromium.org>
> > ---
> >  src/virglrenderer.c  | 11 ++++++++++-
> >  src/virglrenderer.h  |  1 +
> >  src/vrend_renderer.c |  7 +++++--
> >  src/vrend_renderer.h |  2 +-
> >  4 files changed, 17 insertions(+), 4 deletions(-)
> >
> > diff --git a/src/virglrenderer.c b/src/virglrenderer.c
> > index c89cb60..7397cfa 100644
> > --- a/src/virglrenderer.c
> > +++ b/src/virglrenderer.c
> > @@ -60,7 +60,16 @@ static int use_context = CONTEXT_NONE;
> >
> >  int virgl_renderer_resource_create(struct
> virgl_renderer_resource_create_args *args, struct iovec *iov, uint32_t
> num_iovs)
> >  {
> > -   return vrend_renderer_resource_create((struct
> vrend_renderer_resource_create_args *)args, iov, num_iovs);
> > +   return vrend_renderer_resource_create((struct
> vrend_renderer_resource_create_args *)args, iov, num_iovs, NULL);
> > +}
> > +
> > +int virgl_renderer_resource_import_eglimage(struct
> virgl_renderer_resource_create_args *args, void *image)
> > +{
> > +#ifdef HAVE_EPOXY_EGL_H
> > +   return vrend_renderer_resource_create((struct
> vrend_renderer_resource_create_args *)args, 0, 0, image);
> > +#else
> > +   return EINVAL;
> > +#endif
> >  }
> >
> >  void virgl_renderer_resource_unref(uint32_t res_handle)
> > diff --git a/src/virglrenderer.h b/src/virglrenderer.h
> > index 9596dce..dc9036f 100644
> > --- a/src/virglrenderer.h
> > +++ b/src/virglrenderer.h
> > @@ -103,6 +103,7 @@ struct virgl_renderer_resource_create_args {
> >  /* new API */
> >
> >  VIRGL_EXPORT int virgl_renderer_resource_create(struct
> virgl_renderer_resource_create_args *args, struct iovec *iov, uint32_t
> num_iovs);
> > +VIRGL_EXPORT int virgl_renderer_resource_import_eglimage(struct
> virgl_renderer_resource_create_args *args, void *image);
> >  VIRGL_EXPORT void virgl_renderer_resource_unref(uint32_t res_handle);
> >
> >  VIRGL_EXPORT int virgl_renderer_context_create(uint32_t handle,
> uint32_t nlen, const char *name);
> > diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> > index df575b1..f8e5cda 100644
> > --- a/src/vrend_renderer.c
> > +++ b/src/vrend_renderer.c
> > @@ -4588,7 +4588,7 @@ static void vrend_create_buffer(struct
> vrend_resource *gr, uint32_t width)
> >     gr->is_buffer = true;
> >  }
> >
> > -int vrend_renderer_resource_create(struct
> vrend_renderer_resource_create_args *args, struct iovec *iov, uint32_t
> num_iovs)
> > +int vrend_renderer_resource_create(struct
> vrend_renderer_resource_create_args *args, struct iovec *iov, uint32_t
> num_iovs, void *image_oes)
> >  {
> >     struct vrend_resource *gr;
> >     int level;
> > @@ -4693,7 +4693,10 @@ int vrend_renderer_resource_create(struct
> vrend_renderer_resource_create_args *a
> >           return EINVAL;
> >        }
> >
> > -      if (args->nr_samples > 1) {
> > +      if (image_oes &&
> > +          epoxy_has_gl_extension("GL_OES_EGL_image_external")) {
>
> If we provide an image but the system doesn't support the extension, we
> fallback silently.
> With that fix, LGTM. (I didn't test this patch tho.)
>
> > +         glEGLImageTargetTexture2DOES(gr->target, (GLeglImageOES)
> image_oes);
> > +      } else if (args->nr_samples > 1) {
> >           if (vrend_state.use_gles) {
> >              if (gr->target == GL_TEXTURE_2D_MULTISAMPLE) {
> >                 glTexStorage2DMultisample(gr->target, args->nr_samples,
> > diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h
> > index 0235d50..8d1488c 100644
> > --- a/src/vrend_renderer.h
> > +++ b/src/vrend_renderer.h
> > @@ -164,7 +164,7 @@ struct vrend_renderer_resource_create_args {
> >     uint32_t flags;
> >  };
> >
> > -int vrend_renderer_resource_create(struct
> vrend_renderer_resource_create_args *args, struct iovec *iov, uint32_t
> num_iovs);
> > +int vrend_renderer_resource_create(struct
> vrend_renderer_resource_create_args *args, struct iovec *iov, uint32_t
> num_iovs, void *image_eos);
> >
> >  void vrend_renderer_resource_unref(uint32_t handle);
> >
> > --
> > 2.7.4
> >
> > _______________________________________________
> > virglrenderer-devel mailing list
> > virglrenderer-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/virglrenderer-devel/attachments/20180607/3967dc11/attachment.html>


More information about the virglrenderer-devel mailing list