vrend: move gl context functions to winsys

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 0f5e6ebf85
commit 5df70a5abe
  1. 35
      src/virglrenderer.c
  2. 42
      src/vrend_winsys.c
  3. 8
      src/vrend_winsys.h

@ -388,14 +388,9 @@ static virgl_renderer_gl_context create_gl_context(int scanout_idx, struct virgl
{
struct virgl_renderer_gl_ctx_param vparam;
#ifdef HAVE_EPOXY_EGL_H
if (use_context == CONTEXT_EGL)
return virgl_egl_create_context(egl, param);
#endif
#ifdef HAVE_EPOXY_GLX_H
if (use_context == CONTEXT_GLX)
return virgl_glx_create_context(glx_info, param);
#endif
if (use_context != CONTEXT_NONE)
return vrend_winsys_create_context(param);
vparam.version = 1;
vparam.shared = param->shared;
vparam.major_ver = param->major_ver;
@ -405,31 +400,19 @@ static virgl_renderer_gl_context create_gl_context(int scanout_idx, struct virgl
static void destroy_gl_context(virgl_renderer_gl_context ctx)
{
#ifdef HAVE_EPOXY_EGL_H
if (use_context == CONTEXT_EGL) {
virgl_egl_destroy_context(egl, ctx);
if (use_context != CONTEXT_NONE) {
vrend_winsys_destroy_context(ctx);
return;
}
#endif
#ifdef HAVE_EPOXY_GLX_H
if (use_context == CONTEXT_GLX) {
virgl_glx_destroy_context(glx_info, ctx);
return;
}
#endif
rcbs->destroy_gl_context(dev_cookie, ctx);
}
static int make_current(virgl_renderer_gl_context ctx)
{
#ifdef HAVE_EPOXY_EGL_H
if (use_context == CONTEXT_EGL)
return virgl_egl_make_context_current(egl, ctx);
#endif
#ifdef HAVE_EPOXY_GLX_H
if (use_context == CONTEXT_GLX)
return virgl_glx_make_context_current(glx_info, ctx);
#endif
if (use_context != CONTEXT_NONE)
return vrend_winsys_make_context_current(ctx);
return rcbs->make_current(dev_cookie, 0, ctx);
}

@ -37,6 +37,48 @@ struct virgl_gbm *gbm = NULL;
struct virgl_glx *glx_info = NULL;
#endif
virgl_renderer_gl_context vrend_winsys_create_context(struct virgl_gl_ctx_param *param)
{
#ifdef HAVE_EPOXY_EGL_H
if (use_context == CONTEXT_EGL)
return virgl_egl_create_context(egl, param);
#endif
#ifdef HAVE_EPOXY_GLX_H
if (use_context == CONTEXT_GLX)
return virgl_glx_create_context(glx_info, param);
#endif
return NULL;
}
void vrend_winsys_destroy_context(virgl_renderer_gl_context ctx)
{
#ifdef HAVE_EPOXY_EGL_H
if (use_context == CONTEXT_EGL) {
virgl_egl_destroy_context(egl, ctx);
return;
}
#endif
#ifdef HAVE_EPOXY_GLX_H
if (use_context == CONTEXT_GLX) {
virgl_glx_destroy_context(glx_info, ctx);
return;
}
#endif
}
int vrend_winsys_make_context_current(virgl_renderer_gl_context ctx)
{
#ifdef HAVE_EPOXY_EGL_H
if (use_context == CONTEXT_EGL)
return virgl_egl_make_context_current(egl, ctx);
#endif
#ifdef HAVE_EPOXY_GLX_H
if (use_context == CONTEXT_GLX)
return virgl_glx_make_context_current(glx_info, ctx);
#endif
return -1;
}
int vrend_winsys_has_gl_colorspace(void)
{
bool egl_colorspace = false;

@ -36,12 +36,16 @@
#include "vrend_winsys_glx.h"
#endif
#include "virglrenderer.h"
enum {
CONTEXT_NONE,
CONTEXT_EGL,
CONTEXT_GLX
};
struct virgl_gl_ctx_param;
extern int use_context;
#ifdef HAVE_EPOXY_EGL_H
@ -53,6 +57,10 @@ extern struct virgl_gbm *gbm;
extern struct virgl_glx *glx_info;
#endif
virgl_renderer_gl_context vrend_winsys_create_context(struct virgl_gl_ctx_param *param);
void vrend_winsys_destroy_context(virgl_renderer_gl_context ctx);
int vrend_winsys_make_context_current(virgl_renderer_gl_context ctx);
int vrend_winsys_has_gl_colorspace(void);
#endif /* VREND_WINSYS_H */

Loading…
Cancel
Save