vrend: add vrend_winsys_init

Move winsys init code to the new function.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Chia-I Wu 4 years ago
parent 1991666171
commit ce03b7a387
  1. 45
      src/virglrenderer.c
  2. 43
      src/vrend_winsys.c
  3. 1
      src/vrend_winsys.h

@ -442,7 +442,10 @@ void virgl_renderer_cleanup(UNUSED void *cookie)
int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cbs)
{
int drm_fd = -1;
uint32_t renderer_flags = 0;
int ret;
if (!cookie || !cbs)
return -1;
@ -453,47 +456,13 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks
rcbs = cbs;
if (flags & VIRGL_RENDERER_USE_EGL) {
#ifdef HAVE_EPOXY_EGL_H
int fd = -1;
if (cbs->version >= 2 && cbs->get_drm_fd) {
fd = cbs->get_drm_fd(cookie);
drm_fd = cbs->get_drm_fd(cookie);
}
/*
* If the user specifies a preferred DRM fd and we can't use it, fail. If the user doesn't
* specify an fd, it's possible to initialize EGL without one.
*/
gbm = virgl_gbm_init(fd);
if (fd > 0 && !gbm)
return -1;
egl = virgl_egl_init(gbm, flags & VIRGL_RENDERER_USE_SURFACELESS,
flags & VIRGL_RENDERER_USE_GLES);
if (!egl) {
if (gbm) {
virgl_gbm_fini(gbm);
gbm = NULL;
}
return -1;
}
use_context = CONTEXT_EGL;
#else
vrend_printf( "EGL is not supported on this platform\n");
return -1;
#endif
} else if (flags & VIRGL_RENDERER_USE_GLX) {
#ifdef HAVE_EPOXY_GLX_H
glx_info = virgl_glx_init();
if (!glx_info)
return -1;
use_context = CONTEXT_GLX;
#else
vrend_printf( "GLX is not supported on this platform\n");
return -1;
#endif
}
ret = vrend_winsys_init(flags, drm_fd);
if (ret)
return ret;
if (virgl_context_table_init())
return -1;

@ -37,6 +37,49 @@ struct virgl_gbm *gbm = NULL;
struct virgl_glx *glx_info = NULL;
#endif
int vrend_winsys_init(uint32_t flags, int preferred_fd)
{
if (flags & VIRGL_RENDERER_USE_EGL) {
#ifdef HAVE_EPOXY_EGL_H
/*
* If the user specifies a preferred DRM fd and we can't use it, fail. If the user doesn't
* specify an fd, it's possible to initialize EGL without one.
*/
gbm = virgl_gbm_init(preferred_fd);
if (preferred_fd > 0 && !gbm)
return -1;
egl = virgl_egl_init(gbm, flags & VIRGL_RENDERER_USE_SURFACELESS,
flags & VIRGL_RENDERER_USE_GLES);
if (!egl) {
if (gbm) {
virgl_gbm_fini(gbm);
gbm = NULL;
}
return -1;
}
use_context = CONTEXT_EGL;
#else
vrend_printf( "EGL is not supported on this platform\n");
return -1;
#endif
} else if (flags & VIRGL_RENDERER_USE_GLX) {
#ifdef HAVE_EPOXY_GLX_H
glx_info = virgl_glx_init();
if (!glx_info)
return -1;
use_context = CONTEXT_GLX;
#else
vrend_printf( "GLX is not supported on this platform\n");
return -1;
#endif
}
return 0;
}
void vrend_winsys_cleanup(void)
{
#ifdef HAVE_EPOXY_EGL_H

@ -57,6 +57,7 @@ extern struct virgl_gbm *gbm;
extern struct virgl_glx *glx_info;
#endif
int vrend_winsys_init(uint32_t flags, int preferred_fd);
void vrend_winsys_cleanup(void);
virgl_renderer_gl_context vrend_winsys_create_context(struct virgl_gl_ctx_param *param);

Loading…
Cancel
Save