void vigs_backend_cleanup(struct vigs_backend *backend);
-struct vigs_backend *vigs_gl_backend_create(void *display);
+struct vigs_backend *vigs_gl_backend_create(void *display,
+ const char *gl_version);
struct vigs_backend *vigs_sw_backend_create(void);
#endif
char *render_queue;
char *backend;
char *wsi;
+ char *gl_version;
MemoryRegion vram_bar;
uint32_t vram_size;
pci_register_bar(&s->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->io_bar);
if (!strcmp(s->backend, "gl")) {
- backend = vigs_gl_backend_create(dobj->dpy);
+ backend = vigs_gl_backend_create(dobj->dpy, s->gl_version);
} else if (!strcmp(s->backend, "sw")) {
backend = vigs_sw_backend_create();
}
DEFINE_PROP_STRING("render_queue", VIGSState, render_queue),
DEFINE_PROP_STRING("backend", VIGSState, backend),
DEFINE_PROP_STRING("wsi", VIGSState, wsi),
+ DEFINE_PROP_STRING("gl_version", VIGSState, gl_version),
DEFINE_PROP_UINT32("vram_size", VIGSState, vram_size,
32 * 1024 * 1024),
DEFINE_PROP_UINT32("ram_size", VIGSState, ram_size,
};
static bool vigs_gl_backend_cgl_check_gl_version(struct vigs_gl_backend_cgl *gl_backend_cgl,
+ const char *gl_version,
bool *is_gl_2)
{
CGLError error;
bool res = false;
- const char *tmp;
CGLPixelFormatObj pixel_format;
int n;
unsigned int i;
- tmp = getenv("GL_VERSION");
-
- if (tmp) {
- if (strcmp(tmp, "2") == 0) {
+ if (gl_version) {
+ if (strcmp(gl_version, "2") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 2.1");
*is_gl_2 = true;
res = true;
- } else if (strcmp(tmp, "3_2") == 0) {
+ } else if (strcmp(gl_version, "3_2") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 3.2");
*is_gl_2 = false;
res = true;
} else {
- VIGS_LOG_CRITICAL("Bad GL_VERSION value = %s", tmp);
+ VIGS_LOG_CRITICAL("Bad GL_VERSION value = %s", gl_version);
}
goto out;
VIGS_LOG_DEBUG("destroyed");
}
-struct vigs_backend *vigs_gl_backend_create(void *display)
+struct vigs_backend *vigs_gl_backend_create(void *display,
+ const char *gl_version)
{
struct vigs_gl_backend_cgl *gl_backend_cgl;
CGLError error;
VIGS_GL_GET_PROC_OPTIONAL(MapBufferRange, glMapBufferRange);
if (!vigs_gl_backend_cgl_check_gl_version(gl_backend_cgl,
+ gl_version,
&gl_backend_cgl->base.is_gl_2)) {
goto fail2;
}
};
static bool vigs_gl_backend_glx_check_gl_version(struct vigs_gl_backend_glx *gl_backend_glx,
+ const char *gl_version,
bool *is_gl_2)
{
int config_attribs[] =
None
};
bool res = false;
- const char *tmp;
int n = 0;
GLXFBConfig *configs = NULL;
GLXContext ctx = NULL;
unsigned int i;
- tmp = getenv("GL_VERSION");
-
- if (tmp) {
- if (strcmp(tmp, "2") == 0) {
+ if (gl_version) {
+ if (strcmp(gl_version, "2") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 2.1");
*is_gl_2 = true;
res = true;
- } else if (strcmp(tmp, "3_1") == 0) {
+ } else if (strcmp(gl_version, "3_1") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 3.1");
*is_gl_2 = false;
res = true;
- } else if (strcmp(tmp, "3_1_es3") == 0) {
+ } else if (strcmp(gl_version, "3_1_es3") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 3.1 ES3");
*is_gl_2 = false;
res = true;
- } else if (strcmp(tmp, "3_2") == 0) {
+ } else if (strcmp(gl_version, "3_2") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 3.2");
*is_gl_2 = false;
res = true;
} else {
- VIGS_LOG_CRITICAL("Bad GL_VERSION value = %s", tmp);
+ VIGS_LOG_CRITICAL("Bad GL_VERSION value = %s", gl_version);
}
goto out;
VIGS_LOG_DEBUG("destroyed");
}
-struct vigs_backend *vigs_gl_backend_create(void *display)
+struct vigs_backend *vigs_gl_backend_create(void *display,
+ const char *gl_version)
{
struct vigs_gl_backend_glx *gl_backend_glx;
GLXFBConfig config;
gl_backend_glx->dpy = x_display;
if (!vigs_gl_backend_glx_check_gl_version(gl_backend_glx,
+ gl_version,
&gl_backend_glx->base.is_gl_2)) {
goto fail2;
}
};
static bool vigs_gl_backend_wgl_check_gl_version(struct vigs_gl_backend_wgl *gl_backend_wgl,
+ const char *gl_version,
bool *is_gl_2)
{
int config_attribs[] = {
0
};
bool res = false;
- const char *tmp;
HWND win;
HDC dc;
int config_id = 0;
HGLRC ctx;
unsigned int i;
- tmp = getenv("GL_VERSION");
-
- if (tmp) {
- if (strcmp(tmp, "2") == 0) {
+ if (gl_version) {
+ if (strcmp(gl_version, "2") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 2.1");
*is_gl_2 = true;
res = true;
- } else if (strcmp(tmp, "3_1") == 0) {
+ } else if (strcmp(gl_version, "3_1") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 3.1");
*is_gl_2 = false;
res = true;
- } else if (strcmp(tmp, "3_1_es3") == 0) {
+ } else if (strcmp(gl_version, "3_1_es3") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 3.1 ES3");
*is_gl_2 = false;
res = true;
- } else if (strcmp(tmp, "3_2") == 0) {
+ } else if (strcmp(gl_version, "3_2") == 0) {
VIGS_LOG_INFO("GL_VERSION forces OpenGL version to 3.2");
*is_gl_2 = false;
res = true;
} else {
- VIGS_LOG_CRITICAL("Bad GL_VERSION value = %s", tmp);
+ VIGS_LOG_CRITICAL("Bad GL_VERSION value = %s", gl_version);
}
goto out1;
VIGS_LOG_DEBUG("destroyed");
}
-struct vigs_backend *vigs_gl_backend_create(void *display)
+struct vigs_backend *vigs_gl_backend_create(void *display,
+ const char *gl_version)
{
WNDCLASSEXA vigs_win_class;
HWND tmp_win = NULL;
VIGS_GL_GET_PROC_OPTIONAL(MapBufferRange, glMapBufferRange);
if (!vigs_gl_backend_wgl_check_gl_version(gl_backend_wgl,
+ gl_version,
&gl_backend_wgl->base.is_gl_2)) {
goto fail;
}
char *display;
char *render_queue;
char *wsi;
+ char *gl_version;
MemoryRegion iomem;
struct yagl_server_state *ss;
struct yagl_user users[YAGL_MAX_USERS];
yagl_handle_gen_init();
- egl_driver = yagl_egl_driver_create(dobj->dpy);
+ egl_driver = yagl_egl_driver_create(dobj->dpy, s->gl_version);
if (!egl_driver) {
goto fail;
DEFINE_PROP_STRING("display", YaGLState, display),
DEFINE_PROP_STRING("render_queue", YaGLState, render_queue),
DEFINE_PROP_STRING("wsi", YaGLState, wsi),
+ DEFINE_PROP_STRING("gl_version", YaGLState, gl_version),
DEFINE_PROP_END_OF_LIST(),
};
}
static bool yagl_egl_cgl_get_gl_version(struct yagl_egl_cgl *egl_cgl,
+ const char *gl_version,
yagl_gl_version *version)
{
CGLError error;
bool res = false;
- const char *tmp;
CGLPixelFormatObj pixel_format;
int n;
unsigned int i;
YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_get_gl_version, NULL);
- tmp = getenv("GL_VERSION");
-
- if (tmp) {
- if (strcmp(tmp, "2") == 0) {
+ if (gl_version) {
+ if (strcmp(gl_version, "2") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 2.1");
*version = yagl_gl_2;
res = true;
- } else if (strcmp(tmp, "3_2") == 0) {
+ } else if (strcmp(gl_version, "3_2") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 3.2");
*version = yagl_gl_3_2;
res = true;
} else {
- YAGL_LOG_CRITICAL("Bad GL_VERSION value = %s", tmp);
+ YAGL_LOG_CRITICAL("Bad GL_VERSION value = %s", gl_version);
}
goto out;
YAGL_LOG_FUNC_EXIT(NULL);
}
-struct yagl_egl_driver *yagl_egl_driver_create(void *display)
+struct yagl_egl_driver *yagl_egl_driver_create(void *display,
+ const char *gl_version)
{
CGLError error;
struct yagl_egl_cgl *egl_cgl;
goto fail;
}
- if (!yagl_egl_cgl_get_gl_version(egl_cgl, &egl_cgl->base.gl_version)) {
+ if (!yagl_egl_cgl_get_gl_version(egl_cgl,
+ gl_version,
+ &egl_cgl->base.gl_version)) {
goto fail;
}
};
static bool yagl_egl_glx_get_gl_version(struct yagl_egl_glx *egl_glx,
+ const char *gl_version,
yagl_gl_version *version)
{
int config_attribs[] =
None
};
bool res = false;
- const char *tmp;
int n = 0;
GLXFBConfig *configs = NULL;
GLXContext ctx = NULL;
YAGL_EGL_GLX_ENTER(yagl_egl_glx_get_gl_version, NULL);
- tmp = getenv("GL_VERSION");
-
- if (tmp) {
- if (strcmp(tmp, "2") == 0) {
+ if (gl_version) {
+ if (strcmp(gl_version, "2") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 2.1");
*version = yagl_gl_2;
res = true;
- } else if (strcmp(tmp, "3_1") == 0) {
+ } else if (strcmp(gl_version, "3_1") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 3.1");
*version = yagl_gl_3_1;
res = true;
- } else if (strcmp(tmp, "3_1_es3") == 0) {
+ } else if (strcmp(gl_version, "3_1_es3") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 3.1 ES3");
*version = yagl_gl_3_1_es3;
res = true;
- } else if (strcmp(tmp, "3_2") == 0) {
+ } else if (strcmp(gl_version, "3_2") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 3.2");
*version = yagl_gl_3_2;
res = true;
} else {
- YAGL_LOG_CRITICAL("Bad GL_VERSION value = %s", tmp);
+ YAGL_LOG_CRITICAL("Bad GL_VERSION value = %s", gl_version);
}
goto out;
GetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
for (i = 0; i < num_extensions; ++i) {
- tmp = (const char*)GetStringi(GL_EXTENSIONS, i);
+ const char *tmp = (const char *)GetStringi(GL_EXTENSIONS, i);
if (strcmp(tmp, "GL_ARB_ES3_compatibility") == 0) {
YAGL_LOG_INFO("GL_ARB_ES3_compatibility supported, using OpenGL 3.1 ES3");
*version = yagl_gl_3_1_es3;
YAGL_LOG_FUNC_EXIT(NULL);
}
-struct yagl_egl_driver *yagl_egl_driver_create(void *display)
+struct yagl_egl_driver *yagl_egl_driver_create(void *display,
+ const char *gl_version)
{
struct yagl_egl_driver *egl_driver;
struct yagl_egl_glx *egl_glx;
/* GLX_ARB_create_context */
YAGL_EGL_GLX_GET_PROC(PFNGLXCREATECONTEXTATTRIBSARBPROC, glXCreateContextAttribsARB);
- if (!yagl_egl_glx_get_gl_version(egl_glx, &egl_glx->base.gl_version)) {
+ if (!yagl_egl_glx_get_gl_version(egl_glx,
+ gl_version,
+ &egl_glx->base.gl_version)) {
goto fail;
}
};
static bool yagl_egl_wgl_get_gl_version(YaglEglWglDriver *egl_wgl,
+ const char *gl_version,
yagl_gl_version *version)
{
int config_attribs[] = {
0
};
bool res = false;
- const char *tmp;
HWND win;
HDC dc;
int config_id = 0;
YAGL_EGL_WGL_ENTER(yagl_egl_wgl_get_gl_version, NULL);
- tmp = getenv("GL_VERSION");
-
- if (tmp) {
- if (strcmp(tmp, "2") == 0) {
+ if (gl_version) {
+ if (strcmp(gl_version, "2") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 2.1");
*version = yagl_gl_2;
res = true;
- } else if (strcmp(tmp, "3_1") == 0) {
+ } else if (strcmp(gl_version, "3_1") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 3.1");
*version = yagl_gl_3_1;
res = true;
- } else if (strcmp(tmp, "3_1_es3") == 0) {
+ } else if (strcmp(gl_version, "3_1_es3") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 3.1 ES3");
*version = yagl_gl_3_1_es3;
res = true;
- } else if (strcmp(tmp, "3_2") == 0) {
+ } else if (strcmp(gl_version, "3_2") == 0) {
YAGL_LOG_INFO("GL_VERSION forces OpenGL version to 3.2");
*version = yagl_gl_3_2;
res = true;
} else {
- YAGL_LOG_CRITICAL("Bad GL_VERSION value = %s", tmp);
+ YAGL_LOG_CRITICAL("Bad GL_VERSION value = %s", gl_version);
}
goto out1;
GetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
for (i = 0; i < num_extensions; ++i) {
- tmp = (const char*)GetStringi(GL_EXTENSIONS, i);
+ const char *tmp = (const char *)GetStringi(GL_EXTENSIONS, i);
if (strcmp(tmp, "GL_ARB_ES3_compatibility") == 0) {
YAGL_LOG_INFO("GL_ARB_ES3_compatibility supported, using OpenGL 3.1 ES3");
*version = yagl_gl_3_1_es3;
return ext_initialized;
}
-struct yagl_egl_driver *yagl_egl_driver_create(void *display)
+struct yagl_egl_driver *yagl_egl_driver_create(void *display,
+ const char *gl_version)
{
YaglEglWglDriver *egl_wgl;
struct yagl_egl_driver *egl_driver;
goto fail;
}
- if (!yagl_egl_wgl_get_gl_version(egl_wgl, &egl_wgl->base.gl_version)) {
+ if (!yagl_egl_wgl_get_gl_version(egl_wgl,
+ gl_version,
+ &egl_wgl->base.gl_version)) {
goto fail;
}
/*
* 'display' is Display* on linux and HWND on windows.
*/
-struct yagl_egl_driver *yagl_egl_driver_create(void *display);
+struct yagl_egl_driver *yagl_egl_driver_create(void *display,
+ const char *gl_version);
void yagl_egl_driver_init(struct yagl_egl_driver *driver);
void yagl_egl_driver_cleanup(struct yagl_egl_driver *driver);