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: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Tomeu Vizoso 6 years ago committed by Dave Airlie
parent 04751276fc
commit ff7794611b
  1. 2
      src/virgl_egl.h
  2. 10
      src/virgl_egl_context.c
  3. 3
      src/virglrenderer.c
  4. 1
      src/virglrenderer.h
  5. 8
      vtest/vtest_renderer.c

@ -27,7 +27,7 @@
#include "vrend_renderer.h" #include "vrend_renderer.h"
struct virgl_egl; 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); 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); 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; 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[] = { static EGLint conf_att[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
@ -148,6 +148,9 @@ struct virgl_egl *virgl_egl_init(int fd, bool surfaceless)
if (!d) if (!d)
return NULL; return NULL;
if (gles)
conf_att[3] = EGL_OPENGL_ES_BIT;
if (surfaceless) { if (surfaceless) {
conf_att[1] = EGL_PBUFFER_BIT; conf_att[1] = EGL_PBUFFER_BIT;
d->fd = -1; d->fd = -1;
@ -230,7 +233,10 @@ struct virgl_egl *virgl_egl_init(int fd, bool surfaceless)
goto fail; goto fail;
} }
api = EGL_OPENGL_API; if (gles)
api = EGL_OPENGL_ES_API;
else
api = EGL_OPENGL_API;
b = eglBindAPI(api); b = eglBindAPI(api);
if (!b) if (!b)
goto fail; 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) { if (cbs->version >= 2 && cbs->get_drm_fd) {
fd = cbs->get_drm_fd(cookie); 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) if (!egl_info)
return -1; return -1;
use_context = CONTEXT_EGL; use_context = CONTEXT_EGL;

@ -67,6 +67,7 @@ struct virgl_renderer_callbacks {
#define VIRGL_RENDERER_THREAD_SYNC 2 #define VIRGL_RENDERER_THREAD_SYNC 2
#define VIRGL_RENDERER_USE_GLX (1 << 2) #define VIRGL_RENDERER_USE_GLX (1 << 2)
#define VIRGL_RENDERER_USE_SURFACELESS (1 << 3) #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 int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cb);
VIRGL_EXPORT void virgl_renderer_poll(void); /* force fences */ 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; 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, ret = virgl_renderer_init(&renderer,
ctx | VIRGL_RENDERER_THREAD_SYNC, &vtest_cbs); ctx | VIRGL_RENDERER_THREAD_SYNC, &vtest_cbs);
if (ret) { if (ret) {

Loading…
Cancel
Save