From 2edf222abdc3d01aacdf9995c5a70bf944dc38f0 Mon Sep 17 00:00:00 2001 From: Italo Nicola Date: Tue, 6 Jun 2023 02:25:46 -0300 Subject: [PATCH] egl: reenable partial redraw with a warning when using gallium hud Partial revert of e516a0a94f ("egl: disable partial redraw when gallium hud is active"). We shouldn't change the behavior of the application when the hud is enabled, doing so could make it harder do diagnose issues. Instead, now we warn and ask the user to manually disable the extension if he considers it to be worth it. Fixes: e516a0a94f ("egl: disable partial redraw when gallium hud is active") Signed-off-by: Italo Nicola Reviewed-by: Eric Engestrom Part-of: --- src/egl/main/eglapi.c | 3 ++- src/egl/main/egldisplay.h | 10 +++++----- src/egl/main/eglsurface.c | 13 ++++++++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 109612faafd..6053eb7b8a0 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -684,7 +684,8 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) disp->Options.ForceSoftware |= disp->Options.Zink; const char *gallium_hud_env = getenv("GALLIUM_HUD"); - disp->Options.GalliumHud = gallium_hud_env && gallium_hud_env[0] != '\0'; + disp->Options.GalliumHudWarn = + gallium_hud_env && gallium_hud_env[0] != '\0'; /** * Initialize the display using the driver's function. diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index ac4b05b30dd..8310d63a805 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -194,11 +194,11 @@ struct _egl_display { /* options that affect how the driver initializes the display */ struct { - EGLBoolean Zink; /**< Use kopper only */ - EGLBoolean ForceSoftware; /**< Use software path only */ - EGLBoolean GalliumHud; /**< Using gallium hud, disable buffer age */ - EGLAttrib *Attribs; /**< Platform-specific options */ - int fd; /**< Platform device specific, local fd */ + EGLBoolean Zink; /**< Use kopper only */ + EGLBoolean ForceSoftware; /**< Use software path only */ + EGLBoolean GalliumHudWarn; /**< Using hud, warn when querying buffer age */ + EGLAttrib *Attribs; /**< Platform-specific options */ + int fd; /**< Platform device specific, local fd */ } Options; /* these fields are set by the driver during init */ diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 45407cdf427..2f637210246 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -562,12 +562,19 @@ _eglQuerySurface(_EGLDisplay *disp, _EGLSurface *surface, EGLint attribute, ctx->DrawSurface != surface) return _eglError(EGL_BAD_SURFACE, "eglQuerySurface"); - EGLint result = 0; - if (!disp->Options.GalliumHud) - result = disp->Driver->QueryBufferAge(disp, surface); + EGLint result = disp->Driver->QueryBufferAge(disp, surface); if (result < 0) return EGL_FALSE; + if (disp->Options.GalliumHudWarn && result > 0) { + _eglLog(_EGL_WARNING, + "GALLIUM_HUD is not accounted for when querying " + "buffer age, possibly causing artifacts, try running with " + "MESA_EXTENSION_OVERRIDE=\"-EGL_EXT_buffer_age " + "-EGL_KHR_partial_update\""); + disp->Options.GalliumHudWarn = EGL_FALSE; + } + *value = result; surface->BufferAgeRead = EGL_TRUE; break;