[virglrenderer-devel] [PATCH v2] virglrenderer: Add method to import EGLImageKHRs as resources.
Dave Airlie
airlied at gmail.com
Fri Jun 8 01:37:54 UTC 2018
On 8 June 2018 at 03:47, David Riley <davidriley at chromium.org> wrote:
> Allow resources created externally (eg gbm created buffers as
> dma bufs) to be used.
>
> v2: Handle missing extension better.
It would be good to note some use cases for this in the commit msg,
and maybe have some pointer
to the code that is going to use it, as this is a new API and it won't
be used by qemu code primarily.
Dave.
>
> Signed-off-by: David Riley <davidriley at chromium.org>
> ---
> src/virglrenderer.c | 11 ++++++++++-
> src/virglrenderer.h | 1 +
> src/vrend_renderer.c | 12 ++++++++++--
> src/vrend_renderer.h | 2 +-
> 4 files changed, 22 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 5ef3555..236687c 100644
> --- a/src/vrend_renderer.c
> +++ b/src/vrend_renderer.c
> @@ -4595,7 +4595,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;
> @@ -4700,7 +4700,15 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a
> return EINVAL;
> }
>
> - if (args->nr_samples > 1) {
> + if (image_oes) {
> + if (epoxy_has_gl_extension("GL_OES_EGL_image_external")) {
> + glEGLImageTargetTexture2DOES(gr->target, (GLeglImageOES) image_oes);
> + } else {
> + fprintf(stderr, "missing GL_OES_EGL_image_external extension\n");
> + FREE(gr);
> + return EINVAL;
> + }
> + } else if (args->nr_samples > 1) {
> if (vrend_state.use_gles || vrend_state.have_texture_storage) {
> 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 5554edb..e23f78f 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.17.1.1185.g55be947832-goog
>
> _______________________________________________
> virglrenderer-devel mailing list
> virglrenderer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel
More information about the virglrenderer-devel
mailing list