virgl_renderer_callbacks: add get_drm_fd()

Allow the caller to provide a pre-opened DRM file descriptor, to be
used by the EGL context.

Bump callback interface version for compatibility.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Marc-André Lureau 6 years ago committed by Dave Airlie
parent 805d69e168
commit b358bb41f0
  1. 2
      src/virgl_egl.h
  2. 8
      src/virgl_egl_context.c
  3. 8
      src/virglrenderer.c
  4. 4
      src/virglrenderer.h

@ -27,7 +27,7 @@
#include "vrend_renderer.h"
struct virgl_egl;
struct virgl_egl *virgl_egl_init(void);
struct virgl_egl *virgl_egl_init(int fd);
void virgl_egl_destroy(struct virgl_egl *ve);
virgl_renderer_gl_context virgl_egl_create_context(struct virgl_egl *ve, struct virgl_gl_ctx_param *vparams);

@ -123,7 +123,7 @@ static bool virgl_egl_has_extension_in_string(const char *haystack, const char *
return false;
}
struct virgl_egl *virgl_egl_init(void)
struct virgl_egl *virgl_egl_init(int fd)
{
static const EGLint conf_att[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
@ -148,7 +148,11 @@ struct virgl_egl *virgl_egl_init(void)
if (!d)
return NULL;
d->fd = egl_rendernode_open();
if (fd >= 0) {
d->fd = fd;
} else {
d->fd = egl_rendernode_open();
}
if (d->fd == -1)
goto fail;
d->gbm_dev = gbm_create_device(d->fd);

@ -303,7 +303,7 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks
if (!cookie || !cbs)
return -1;
if (cbs->version != 1)
if (cbs->version < 1 || cbs->version > VIRGL_RENDERER_CALLBACKS_VERSION)
return -1;
dev_cookie = cookie;
@ -311,7 +311,11 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks
if (flags & VIRGL_RENDERER_USE_EGL) {
#ifdef HAVE_EPOXY_EGL_H
egl_info = virgl_egl_init();
int fd = -1;
if (cbs->version >= 2 && cbs->get_drm_fd) {
fd = cbs->get_drm_fd(cookie);
}
egl_info = virgl_egl_init(fd);
if (!egl_info)
return -1;
use_context = CONTEXT_EGL;

@ -44,6 +44,8 @@ struct virgl_renderer_gl_ctx_param {
int minor_ver;
};
#define VIRGL_RENDERER_CALLBACKS_VERSION 2
struct virgl_renderer_callbacks {
int version;
void (*write_fence)(void *cookie, uint32_t fence);
@ -52,6 +54,8 @@ struct virgl_renderer_callbacks {
virgl_renderer_gl_context (*create_gl_context)(void *cookie, int scanout_idx, struct virgl_renderer_gl_ctx_param *param);
void (*destroy_gl_context)(void *cookie, virgl_renderer_gl_context ctx);
int (*make_current)(void *cookie, int scanout_idx, virgl_renderer_gl_context ctx);
int (*get_drm_fd)(void *cookie); /* v2, used with flags & VIRGL_RENDERER_USE_EGL */
};
/* virtio-gpu compatible interface */

Loading…
Cancel
Save