summaryrefslogtreecommitdiff
path: root/src/glx
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>2021-10-07 12:14:44 +0200
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>2021-11-04 13:59:00 +0100
commitfc3ef76eec61c97ba7c53622e4bca8e518749b09 (patch)
treeaeb4e19c3310bd28f1407069187106fe441b3dc1 /src/glx
parent9b09655a587f03b4096df0a4314e98a267816cfa (diff)
glx/drirc: add a force_direct_glx_context option
Some applications may request an indirect context but this feature is disabled by default on Xorg and thus context creation will fail. This commit adds a drirc setting to force the creation of direct glx context, regardless of what the app is requesting. Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13246>
Diffstat (limited to 'src/glx')
-rw-r--r--src/glx/create_context.c9
-rw-r--r--src/glx/dri2_glx.c8
-rw-r--r--src/glx/dri3_glx.c8
-rw-r--r--src/glx/glxclient.h1
-rw-r--r--src/glx/glxcmds.c8
-rw-r--r--src/glx/tests/fake_glx_screen.h1
6 files changed, 35 insertions, 0 deletions
diff --git a/src/glx/create_context.c b/src/glx/create_context.c
index 7e1cec98c64..c44d579c954 100644
--- a/src/glx/create_context.c
+++ b/src/glx/create_context.c
@@ -92,6 +92,15 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
assert(screen == psc->scr);
+ /* Some application may request an indirect context but we may want to force a direct
+ * one because Xorg only allows indirect contexts if they were enabled.
+ */
+ if (!direct &&
+ psc->force_direct_context) {
+ direct = true;
+ }
+
+
if (direct && psc->vtable->create_context_attribs) {
/* GLX drops the error returned by the driver. The expectation is that
* an error will also be returned by the server. The server's error
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index fbbfe1f6d57..4092842cccd 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -1280,6 +1280,14 @@ dri2CreateScreen(int screen, struct glx_display * priv)
&tmp) == 0)
__IndirectGlParseExtensionOverride(&psc->base, tmp);
+ if (psc->config->base.version > 1) {
+ uint8_t force = false;
+ if (psc->config->configQueryb(psc->driScreen, "force_direct_glx_context",
+ &force) == 0) {
+ psc->base.force_direct_context = force;
+ }
+ }
+
/* DRI2 supports SubBuffer through DRI2CopyRegion, so it's always
* available.*/
psp->copySubBuffer = dri2CopySubBuffer;
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index 3b3918cf6c1..3c0d60bdf21 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -1014,6 +1014,14 @@ dri3_create_screen(int screen, struct glx_display * priv)
&tmp) == 0)
__IndirectGlParseExtensionOverride(&psc->base, tmp);
+ if (psc->config->base.version > 1) {
+ uint8_t force = false;
+ if (psc->config->configQueryb(psc->driScreen, "force_direct_glx_context",
+ &force) == 0) {
+ psc->base.force_direct_context = force;
+ }
+ }
+
free(driverName);
tmp = getenv("LIBGL_SHOW_FPS");
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index 50aa4d892cb..880f4fbaefa 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -521,6 +521,7 @@ struct glx_screen
Display *dpy;
int scr;
+ bool force_direct_context;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/**
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index ecf94eeb04c..901de99f942 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -339,6 +339,14 @@ CreateContext(Display *dpy, int generic_id, struct glx_config *config,
if (generic_id == None)
return NULL;
+ /* Some application may request an indirect context but we may want to force a direct
+ * one because Xorg only allows indirect contexts if they were enabled.
+ */
+ if (!allowDirect &&
+ psc->force_direct_context) {
+ allowDirect = 1;
+ }
+
gc = NULL;
#ifdef GLX_USE_APPLEGL
gc = applegl_create_context(psc, config, shareList, renderType);
diff --git a/src/glx/tests/fake_glx_screen.h b/src/glx/tests/fake_glx_screen.h
index 39b250ffc8f..02b212ad7ec 100644
--- a/src/glx/tests/fake_glx_screen.h
+++ b/src/glx/tests/fake_glx_screen.h
@@ -34,6 +34,7 @@ public:
this->scr = num;
this->visuals = 0;
this->configs = 0;
+ this->force_direct_context = false;
this->display = glx_dpy;
this->dpy = (glx_dpy != NULL) ? glx_dpy->dpy : NULL;