Discussion:
[Mesa-dev] [PATCH mesa 1/3] egl: let each platform decided how to handle LIBGL_ALWAYS_SOFTWARE
Eric Engestrom
2017-12-20 15:53:08 UTC
Permalink
My refactor in 47273d7312cb5b5b6b0b9 missed this early return; because
of it, setting UseFallback one layer above actually prevented the
software path from being used.

Remove this early return and let each platform's dri2_initialize_*()
decide what it can do with the LIBGL_ALWAYS_SOFTWARE restriction.

platform_{surfaceless,x11,wayland} were already handling it themselves.

Fixes: 47273d7312cb5b5b6b0b9 "egl: set UseFallback if LIBGL_ALWAYS_SOFTWARE is set"
Signed-off-by: Eric Engestrom <***@imgtec.com>
---
src/egl/drivers/dri2/egl_dri2.c | 4 ----
src/egl/drivers/dri2/platform_android.c | 4 ++++
src/egl/drivers/dri2/platform_drm.c | 4 ++++
3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 6260737bec107ea64ec3..da5101185b336756b220 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -910,10 +910,6 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
return EGL_TRUE;
}

- /* not until swrast_dri is supported */
- if (disp->Options.UseFallback)
- return EGL_FALSE;
-
switch (disp->Platform) {
case _EGL_PLATFORM_SURFACELESS:
ret = dri2_initialize_surfaceless(drv, disp);
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 7cf03b3467f285e36117..1b3092b7b3bf43324c9e 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1179,6 +1179,10 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
const char *err;
int ret;

+ /* Not supported yet */
+ if (disp->Options.UseFallback)
+ return EGL_FALSE;
+
loader_set_logger(_eglLog);

dri2_dpy = calloc(1, sizeof(*dri2_dpy));
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 416fd4cc657bb975e378..a2d18ef508938c7ec355 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -652,6 +652,10 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
struct gbm_device *gbm;
const char *err;

+ /* Not supported yet */
+ if (disp->Options.UseFallback)
+ return EGL_FALSE;
+
loader_set_logger(_eglLog);

dri2_dpy = calloc(1, sizeof *dri2_dpy);
--
Cheers,
Eric
Eric Engestrom
2017-12-20 15:53:09 UTC
Permalink
Signed-off-by: Eric Engestrom <***@imgtec.com>
---
src/egl/drivers/dri2/platform_android.c | 2 +-
src/egl/drivers/dri2/platform_drm.c | 2 +-
src/egl/drivers/dri2/platform_surfaceless.c | 2 +-
src/egl/drivers/dri2/platform_wayland.c | 2 +-
src/egl/drivers/dri2/platform_x11.c | 2 +-
src/egl/main/egldisplay.h | 2 +-
src/egl/main/egldriver.c | 4 ++--
7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 1b3092b7b3bf43324c9e..34e3ef66bfeb91f9c2fa 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1180,7 +1180,7 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
int ret;

/* Not supported yet */
- if (disp->Options.UseFallback)
+ if (disp->Options.ForceSoftware)
return EGL_FALSE;

loader_set_logger(_eglLog);
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index a2d18ef508938c7ec355..6e7403d9ab27ba938ece 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -653,7 +653,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
const char *err;

/* Not supported yet */
- if (disp->Options.UseFallback)
+ if (disp->Options.ForceSoftware)
return EGL_FALSE;

loader_set_logger(_eglLog);
diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c
index 977b046016665aa99148..70b302c0ce42f8ec8a5a 100644
--- a/src/egl/drivers/dri2/platform_surfaceless.c
+++ b/src/egl/drivers/dri2/platform_surfaceless.c
@@ -324,7 +324,7 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp)
dri2_dpy->fd = -1;
disp->DriverData = (void *) dri2_dpy;

- if (!disp->Options.UseFallback) {
+ if (!disp->Options.ForceSoftware) {
driver_loaded = surfaceless_probe_device(disp, false);
if (!driver_loaded)
_eglLog(_EGL_WARNING,
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 02b32f988858303a5013..05a347abfcec87bfe873 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1999,7 +1999,7 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
{
EGLBoolean initialized = EGL_FALSE;

- if (!disp->Options.UseFallback)
+ if (!disp->Options.ForceSoftware)
initialized = dri2_initialize_wayland_drm(drv, disp);

if (!initialized)
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 8ede590bfab383cff965..78a51ba0e53e8fe8b229 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -1459,7 +1459,7 @@ dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp)
{
EGLBoolean initialized = EGL_FALSE;

- if (!disp->Options.UseFallback) {
+ if (!disp->Options.ForceSoftware) {
#ifdef HAVE_DRI3
if (!env_var_as_boolean("LIBGL_DRI3_DISABLE", false))
initialized = dri2_initialize_x11_dri3(drv, disp);
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 0005c81836d45c917326..addf430ffed59937f147 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -160,7 +160,7 @@ struct _egl_display

/* options that affect how the driver initializes the display */
struct {
- EGLBoolean UseFallback; /**< Use fallback driver (sw or less features) */
+ EGLBoolean ForceSoftware; /**< Use software path only */
void *Platform; /**< Platform-specific options */
} Options;

diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index f1973bde274ec768c4cf..c7d5aa18056518c51fc0 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -89,12 +89,12 @@ _eglMatchDriver(_EGLDisplay *dpy)
assert(!dpy->Initialized);

/* set options */
- dpy->Options.UseFallback =
+ dpy->Options.ForceSoftware =
env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);

best_drv = _eglMatchAndInitialize(dpy);
if (!best_drv) {
- dpy->Options.UseFallback = EGL_TRUE;
+ dpy->Options.ForceSoftware = EGL_TRUE;
best_drv = _eglMatchAndInitialize(dpy);
}
--
Cheers,
Eric
Eric Engestrom
2017-12-20 15:53:10 UTC
Permalink
Signed-off-by: Eric Engestrom <***@imgtec.com>
---
src/egl/main/egldriver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index c7d5aa18056518c51fc0..b20652ed8c1d0182b5d5 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -93,7 +93,7 @@ _eglMatchDriver(_EGLDisplay *dpy)
env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);

best_drv = _eglMatchAndInitialize(dpy);
- if (!best_drv) {
+ if (!best_drv && !dpy->Options.ForceSoftware) {
dpy->Options.ForceSoftware = EGL_TRUE;
best_drv = _eglMatchAndInitialize(dpy);
}
--
Cheers,
Eric
Emil Velikov
2017-12-27 11:14:17 UTC
Permalink
For the series:

Reviewed-by: Emil Velikov <***@collabora.com>

Modulo any objections, I'll push it later on today.

-Emil
Eric Engestrom
2017-12-27 12:23:16 UTC
Permalink
Post by Emil Velikov
Modulo any objections, I'll push it later on today.
Thanks; can you also add to 1/3 and 3/3:
Reported-by: Brendan King <***@imgtec.com>

Cheers

Loading...