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>
This commit is contained in:
parent
9b09655a58
commit
fc3ef76eec
|
@ -44,6 +44,7 @@ DRI_CONF_SECTION_DEBUG
|
||||||
DRI_CONF_INDIRECT_GL_EXTENSION_OVERRIDE()
|
DRI_CONF_INDIRECT_GL_EXTENSION_OVERRIDE()
|
||||||
DRI_CONF_DISABLE_PROTECTED_CONTENT_CHECK(false)
|
DRI_CONF_DISABLE_PROTECTED_CONTENT_CHECK(false)
|
||||||
DRI_CONF_IGNORE_MAP_UNSYNCHRONIZED(false)
|
DRI_CONF_IGNORE_MAP_UNSYNCHRONIZED(false)
|
||||||
|
DRI_CONF_FORCE_DIRECT_GLX_CONTEXT(false)
|
||||||
DRI_CONF_SECTION_END
|
DRI_CONF_SECTION_END
|
||||||
|
|
||||||
DRI_CONF_SECTION_MISCELLANEOUS
|
DRI_CONF_SECTION_MISCELLANEOUS
|
||||||
|
|
|
@ -92,6 +92,15 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
|
||||||
|
|
||||||
assert(screen == psc->scr);
|
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) {
|
if (direct && psc->vtable->create_context_attribs) {
|
||||||
/* GLX drops the error returned by the driver. The expectation is that
|
/* 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
|
* an error will also be returned by the server. The server's error
|
||||||
|
|
|
@ -1280,6 +1280,14 @@ dri2CreateScreen(int screen, struct glx_display * priv)
|
||||||
&tmp) == 0)
|
&tmp) == 0)
|
||||||
__IndirectGlParseExtensionOverride(&psc->base, tmp);
|
__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
|
/* DRI2 supports SubBuffer through DRI2CopyRegion, so it's always
|
||||||
* available.*/
|
* available.*/
|
||||||
psp->copySubBuffer = dri2CopySubBuffer;
|
psp->copySubBuffer = dri2CopySubBuffer;
|
||||||
|
|
|
@ -1014,6 +1014,14 @@ dri3_create_screen(int screen, struct glx_display * priv)
|
||||||
&tmp) == 0)
|
&tmp) == 0)
|
||||||
__IndirectGlParseExtensionOverride(&psc->base, tmp);
|
__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);
|
free(driverName);
|
||||||
|
|
||||||
tmp = getenv("LIBGL_SHOW_FPS");
|
tmp = getenv("LIBGL_SHOW_FPS");
|
||||||
|
|
|
@ -521,6 +521,7 @@ struct glx_screen
|
||||||
|
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
int scr;
|
int scr;
|
||||||
|
bool force_direct_context;
|
||||||
|
|
||||||
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
|
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -339,6 +339,14 @@ CreateContext(Display *dpy, int generic_id, struct glx_config *config,
|
||||||
if (generic_id == None)
|
if (generic_id == None)
|
||||||
return NULL;
|
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;
|
gc = NULL;
|
||||||
#ifdef GLX_USE_APPLEGL
|
#ifdef GLX_USE_APPLEGL
|
||||||
gc = applegl_create_context(psc, config, shareList, renderType);
|
gc = applegl_create_context(psc, config, shareList, renderType);
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
this->scr = num;
|
this->scr = num;
|
||||||
this->visuals = 0;
|
this->visuals = 0;
|
||||||
this->configs = 0;
|
this->configs = 0;
|
||||||
|
this->force_direct_context = false;
|
||||||
|
|
||||||
this->display = glx_dpy;
|
this->display = glx_dpy;
|
||||||
this->dpy = (glx_dpy != NULL) ? glx_dpy->dpy : NULL;
|
this->dpy = (glx_dpy != NULL) ? glx_dpy->dpy : NULL;
|
||||||
|
|
|
@ -234,6 +234,10 @@
|
||||||
DRI_CONF_OPT_B(force_compat_profile, def, \
|
DRI_CONF_OPT_B(force_compat_profile, def, \
|
||||||
"Force an OpenGL compatibility context")
|
"Force an OpenGL compatibility context")
|
||||||
|
|
||||||
|
#define DRI_CONF_FORCE_DIRECT_GLX_CONTEXT(def) \
|
||||||
|
DRI_CONF_OPT_B(force_direct_glx_context, def, \
|
||||||
|
"Force direct GLX context (even if indirect is requested)")
|
||||||
|
|
||||||
#define DRI_CONF_OVERRIDE_VRAM_SIZE() \
|
#define DRI_CONF_OVERRIDE_VRAM_SIZE() \
|
||||||
DRI_CONF_OPT_I(override_vram_size, -1, -1, 2147483647, \
|
DRI_CONF_OPT_I(override_vram_size, -1, -1, 2147483647, \
|
||||||
"Override the VRAM size advertised to the application in MiB (-1 = default)")
|
"Override the VRAM size advertised to the application in MiB (-1 = default)")
|
||||||
|
|
|
@ -320,7 +320,7 @@ driParseOptionInfo(driOptionCache *info,
|
||||||
/* Make the hash table big enough to fit more than the maximum number of
|
/* Make the hash table big enough to fit more than the maximum number of
|
||||||
* config options we've ever seen in a driver.
|
* config options we've ever seen in a driver.
|
||||||
*/
|
*/
|
||||||
info->tableSize = 6;
|
info->tableSize = 7;
|
||||||
info->info = calloc((size_t)1 << info->tableSize, sizeof(driOptionInfo));
|
info->info = calloc((size_t)1 << info->tableSize, sizeof(driOptionInfo));
|
||||||
info->values = calloc((size_t)1 << info->tableSize, sizeof(driOptionValue));
|
info->values = calloc((size_t)1 << info->tableSize, sizeof(driOptionValue));
|
||||||
if (info->info == NULL || info->values == NULL) {
|
if (info->info == NULL || info->values == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue