Commit ff779461 authored by Tomeu Vizoso's avatar Tomeu Vizoso Committed by Dave Airlie

virgl/egl: Add option to use GLES

Adds a VIRGL_RENDERER_USE_GLES flag for specifying the API to request
when creating the EGL context.

Users can enable this flag when using vtest with the VTEST_USE_GLES
environment variable.
Signed-off-by: default avatarTomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 04751276
......@@ -27,7 +27,7 @@
#include "vrend_renderer.h"
struct virgl_egl;
struct virgl_egl *virgl_egl_init(int fd, bool surfaceless);
struct virgl_egl *virgl_egl_init(int fd, bool surfaceless, bool gles);
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(int fd, bool surfaceless)
struct virgl_egl *virgl_egl_init(int fd, bool surfaceless, bool gles)
{
static EGLint conf_att[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
......@@ -148,6 +148,9 @@ struct virgl_egl *virgl_egl_init(int fd, bool surfaceless)
if (!d)
return NULL;
if (gles)
conf_att[3] = EGL_OPENGL_ES_BIT;
if (surfaceless) {
conf_att[1] = EGL_PBUFFER_BIT;
d->fd = -1;
......@@ -230,7 +233,10 @@ struct virgl_egl *virgl_egl_init(int fd, bool surfaceless)
goto fail;
}
api = EGL_OPENGL_API;
if (gles)
api = EGL_OPENGL_ES_API;
else
api = EGL_OPENGL_API;
b = eglBindAPI(api);
if (!b)
goto fail;
......
......@@ -315,7 +315,8 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks
if (cbs->version >= 2 && cbs->get_drm_fd) {
fd = cbs->get_drm_fd(cookie);
}
egl_info = virgl_egl_init(fd, flags & VIRGL_RENDERER_USE_SURFACELESS);
egl_info = virgl_egl_init(fd, flags & VIRGL_RENDERER_USE_SURFACELESS,
flags & VIRGL_RENDERER_USE_GLES);
if (!egl_info)
return -1;
use_context = CONTEXT_EGL;
......
......@@ -67,6 +67,7 @@ struct virgl_renderer_callbacks {
#define VIRGL_RENDERER_THREAD_SYNC 2
#define VIRGL_RENDERER_USE_GLX (1 << 2)
#define VIRGL_RENDERER_USE_SURFACELESS (1 << 3)
#define VIRGL_RENDERER_USE_GLES (1 << 4)
VIRGL_EXPORT int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cb);
VIRGL_EXPORT void virgl_renderer_poll(void); /* force fences */
......
......@@ -130,6 +130,14 @@ int vtest_create_renderer(int in_fd, int out_fd, uint32_t length)
ctx |= VIRGL_RENDERER_USE_SURFACELESS;
}
if (getenv("VTEST_USE_GLES")) {
if (ctx & VIRGL_RENDERER_USE_GLX) {
fprintf(stderr, "Cannot use GLES with GLX.\n");
return -1;
}
ctx |= VIRGL_RENDERER_USE_GLES;
}
ret = virgl_renderer_init(&renderer,
ctx | VIRGL_RENDERER_THREAD_SYNC, &vtest_cbs);
if (ret) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment