virgl/egl: Add option to use the surfaceless platform

To make it easier to run the test suite on environments without graphics
hardware, add an environment variable VIRGL_EGL_SURFACELESS that will
force the use of the surfaceless platform.

Combined with the following flags, we can run virglrenderer and its
tests without any graphics hardware or windowing system present:

LIBGL_ALWAYS_SOFTWARE=true GALLIUM_DRIVER=llvmpipe VIRGL_EGL_SURFACELESS=yes

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 729162752e
commit 04751276fc
  1. 2
      src/virgl_egl.h
  2. 28
      src/virgl_egl_context.c
  3. 2
      src/virglrenderer.c
  4. 1
      src/virglrenderer.h
  5. 8
      vtest/vtest_renderer.c

@ -27,7 +27,7 @@
#include "vrend_renderer.h"
struct virgl_egl;
struct virgl_egl *virgl_egl_init(int fd);
struct virgl_egl *virgl_egl_init(int fd, bool surfaceless);
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,9 +123,9 @@ static bool virgl_egl_has_extension_in_string(const char *haystack, const char *
return false;
}
struct virgl_egl *virgl_egl_init(int fd)
struct virgl_egl *virgl_egl_init(int fd, bool surfaceless)
{
static const EGLint conf_att[] = {
static EGLint conf_att[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_RED_SIZE, 1,
@ -148,6 +148,11 @@ struct virgl_egl *virgl_egl_init(int fd)
if (!d)
return NULL;
if (surfaceless) {
conf_att[1] = EGL_PBUFFER_BIT;
d->fd = -1;
d->gbm_dev = NULL;
} else {
if (fd >= 0) {
d->fd = fd;
} else {
@ -158,6 +163,7 @@ struct virgl_egl *virgl_egl_init(int fd)
d->gbm_dev = gbm_create_device(d->fd);
if (!d->gbm_dev)
goto fail;
}
const char *client_extensions = eglQueryString (NULL, EGL_EXTENSIONS);
@ -165,14 +171,26 @@ struct virgl_egl *virgl_egl_init(int fd)
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display =
(PFNEGLGETPLATFORMDISPLAYEXTPROC) eglGetProcAddress ("eglGetPlatformDisplay");
if (get_platform_display)
if (!get_platform_display)
goto fail;
if (surfaceless) {
d->egl_display = get_platform_display (EGL_PLATFORM_SURFACELESS_MESA,
EGL_DEFAULT_DISPLAY, NULL);
} else
d->egl_display = get_platform_display (EGL_PLATFORM_GBM_KHR,
(EGLNativeDisplayType)d->gbm_dev, NULL);
} else if (strstr (client_extensions, "EGL_EXT_platform_base")) {
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display =
(PFNEGLGETPLATFORMDISPLAYEXTPROC) eglGetProcAddress ("eglGetPlatformDisplayEXT");
if (get_platform_display)
if (!get_platform_display)
goto fail;
if (surfaceless) {
d->egl_display = get_platform_display (EGL_PLATFORM_SURFACELESS_MESA,
EGL_DEFAULT_DISPLAY, NULL);
} else
d->egl_display = get_platform_display (EGL_PLATFORM_GBM_KHR,
(EGLNativeDisplayType)d->gbm_dev, NULL);
} else {
@ -245,7 +263,9 @@ void virgl_egl_destroy(struct virgl_egl *d)
EGL_NO_CONTEXT);
eglDestroyContext(d->egl_display, d->egl_ctx);
eglTerminate(d->egl_display);
if (d->gbm_dev)
gbm_device_destroy(d->gbm_dev);
if (d->fd >= 0)
close(d->fd);
free(d);
}

@ -315,7 +315,7 @@ 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);
egl_info = virgl_egl_init(fd, flags & VIRGL_RENDERER_USE_SURFACELESS);
if (!egl_info)
return -1;
use_context = CONTEXT_EGL;

@ -66,6 +66,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)
VIRGL_EXPORT int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cb);
VIRGL_EXPORT void virgl_renderer_poll(void); /* force fences */

@ -122,6 +122,14 @@ int vtest_create_renderer(int in_fd, int out_fd, uint32_t length)
if (getenv("VTEST_USE_GLX"))
ctx = VIRGL_RENDERER_USE_GLX;
if (getenv("VTEST_USE_EGL_SURFACELESS")) {
if (ctx & VIRGL_RENDERER_USE_GLX) {
fprintf(stderr, "Cannot use surfaceless with GLX.\n");
return -1;
}
ctx |= VIRGL_RENDERER_USE_SURFACELESS;
}
ret = virgl_renderer_init(&renderer,
ctx | VIRGL_RENDERER_THREAD_SYNC, &vtest_cbs);
if (ret) {

Loading…
Cancel
Save