[virglrenderer-devel] [PATCH 1/2] virgl/egl: Add option to use the surfaceless platform
Tomeu Vizoso
tomeu.vizoso at collabora.com
Fri Apr 20 14:16:48 UTC 2018
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 at collabora.com>
---
src/virgl_egl_context.c | 43 ++++++++++++++++++++++++++++++-----------
1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/src/virgl_egl_context.c b/src/virgl_egl_context.c
index c1a1b9a7503b..3e50a3349a5b 100644
--- a/src/virgl_egl_context.c
+++ b/src/virgl_egl_context.c
@@ -125,7 +125,7 @@ static bool virgl_egl_has_extension_in_string(const char *haystack, const char *
struct virgl_egl *virgl_egl_init(void)
{
- 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,
@@ -143,17 +143,24 @@ struct virgl_egl *virgl_egl_init(void)
EGLint major, minor, n;
const char *extension_list;
struct virgl_egl *d;
+ bool surfaceless = getenv("VIRGL_EGL_SURFACELESS");
d = malloc(sizeof(struct virgl_egl));
if (!d)
return NULL;
- d->fd = egl_rendernode_open();
- if (d->fd == -1)
- goto fail;
- d->gbm_dev = gbm_create_device(d->fd);
- if (!d->gbm_dev)
- goto fail;
+ if (surfaceless) {
+ conf_att[1] = EGL_PBUFFER_BIT;
+ d->fd = -1;
+ d->gbm_dev = NULL;
+ } else {
+ d->fd = egl_rendernode_open();
+ if (d->fd == -1)
+ goto fail;
+ d->gbm_dev = gbm_create_device(d->fd);
+ if (!d->gbm_dev)
+ goto fail;
+ }
const char *client_extensions = eglQueryString (NULL, EGL_EXTENSIONS);
@@ -161,14 +168,26 @@ struct virgl_egl *virgl_egl_init(void)
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 {
@@ -241,8 +260,10 @@ void virgl_egl_destroy(struct virgl_egl *d)
EGL_NO_CONTEXT);
eglDestroyContext(d->egl_display, d->egl_ctx);
eglTerminate(d->egl_display);
- gbm_device_destroy(d->gbm_dev);
- close(d->fd);
+ if (d->gbm_dev)
+ gbm_device_destroy(d->gbm_dev);
+ if (d->fd >= 0)
+ close(d->fd);
free(d);
}
--
2.17.0
More information about the virglrenderer-devel
mailing list