From 8c42c353b6ed34d5824ff90163116b8ef8d9b5ac Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 5 Apr 2023 07:51:36 -0400 Subject: [PATCH] driconf: rework glthread enablement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this splits out glthread enablement into 3 settings: - driver - app - user which can then be modified with more granularity Reviewed-by: Marek Olšák Part-of: --- .../auxiliary/pipe-loader/driinfo_gallium.h | 4 +- .../drivers/radeonsi/driinfo_radeonsi.h | 2 +- src/gallium/drivers/zink/driinfo_zink.h | 2 +- src/gallium/frontends/dri/dri_context.c | 22 ++- src/util/00-mesa-defaults.conf | 144 +++++++++--------- src/util/driconf.h | 4 +- 6 files changed, 100 insertions(+), 78 deletions(-) diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h index 1eb9c886479..53440b60af7 100644 --- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h +++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h @@ -1,6 +1,8 @@ // DriConf options supported by all Gallium DRI drivers. DRI_CONF_SECTION_PERFORMANCE - DRI_CONF_MESA_GLTHREAD(false) + DRI_CONF_MESA_GLTHREAD_DRIVER(false) + DRI_CONF_OPT_I(mesa_glthread_app_profile, -1, -1, 1, \ + "Set an app profile enablement for glthread") DRI_CONF_MESA_NO_ERROR(false) DRI_CONF_SECTION_END diff --git a/src/gallium/drivers/radeonsi/driinfo_radeonsi.h b/src/gallium/drivers/radeonsi/driinfo_radeonsi.h index e8a2b4674a3..185f3716394 100644 --- a/src/gallium/drivers/radeonsi/driinfo_radeonsi.h +++ b/src/gallium/drivers/radeonsi/driinfo_radeonsi.h @@ -1,7 +1,7 @@ // DriConf options specific to radeonsi DRI_CONF_SECTION_PERFORMANCE DRI_CONF_ADAPTIVE_SYNC(true) -DRI_CONF_MESA_GLTHREAD(true) +DRI_CONF_MESA_GLTHREAD_DRIVER(true) DRI_CONF_SECTION_END DRI_CONF_SECTION_DEBUG diff --git a/src/gallium/drivers/zink/driinfo_zink.h b/src/gallium/drivers/zink/driinfo_zink.h index 27a0b244a6c..62de73cac59 100644 --- a/src/gallium/drivers/zink/driinfo_zink.h +++ b/src/gallium/drivers/zink/driinfo_zink.h @@ -8,7 +8,7 @@ DRI_CONF_SECTION_DEBUG DRI_CONF_SECTION_END DRI_CONF_SECTION_PERFORMANCE -DRI_CONF_MESA_GLTHREAD(true) +DRI_CONF_MESA_GLTHREAD_DRIVER(true) DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY diff --git a/src/gallium/frontends/dri/dri_context.c b/src/gallium/frontends/dri/dri_context.c index b74fa579bf4..1c1b82bfaa6 100644 --- a/src/gallium/frontends/dri/dri_context.c +++ b/src/gallium/frontends/dri/dri_context.c @@ -200,8 +200,28 @@ dri_create_context(struct dri_screen *screen, ctx->st, st_context_invalidate_state); } + /* order of precedence (least to most): + * - driver setting + * - app setting + * - user setting + */ + bool enable_glthread = driQueryOptionb(&screen->dev->option_cache, "mesa_glthread_driver"); + int app_enable_glthread = driQueryOptioni(&screen->dev->option_cache, "mesa_glthread_app_profile"); + if (app_enable_glthread != -1) { + /* if set (not -1), apply the app setting */ + enable_glthread = app_enable_glthread == 1; + } + if (getenv("mesa_glthread")) { + /* only apply the env var if set */ + bool user_enable_glthread = debug_get_bool_option("mesa_glthread", false); + if (user_enable_glthread != enable_glthread) { + /* print warning to mimic old behavior */ + fprintf(stderr, "ATTENTION: default value of option mesa_glthread overridden by environment."); + } + enable_glthread = user_enable_glthread; + } /* Do this last. */ - if (driQueryOptionb(&screen->dev->option_cache, "mesa_glthread")) { + if (enable_glthread) { bool safe = true; /* This is only needed by X11/DRI2, which can be unsafe. */ diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf index f39825cde5d..71baff048b3 100644 --- a/src/util/00-mesa-defaults.conf +++ b/src/util/00-mesa-defaults.conf @@ -137,13 +137,13 @@ TODO: document the other workarounds.