mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
Add a GDK_DISABLE env var
This is taking over the feature-disabling keys from GDK_DEBUG.
This commit is contained in:
parent
7ce942d3fb
commit
cde094a0df
@ -223,36 +223,15 @@ A number of options affect behavior instead of logging:
|
||||
: Force graphics offload for all textures, even when slower. This allows
|
||||
to debug offloading in the absence of dmabufs.
|
||||
|
||||
`gl-disable`
|
||||
: Disable OpenGL support
|
||||
|
||||
`gl-no-fractional`
|
||||
: Disable fractional scaling for OpenGL.
|
||||
|
||||
`gl-debug`
|
||||
: Insert debugging information in OpenGL
|
||||
|
||||
`gl-disable-gl`
|
||||
: Don't allow the use of OpenGL GL API. This forces GLES to be used
|
||||
|
||||
`gl-disable-gles`
|
||||
: Don't allow the use of OpenGL GLES API. This forces GL to be used
|
||||
|
||||
`gl-prefer-gl`
|
||||
: Prefer OpenGL over OpenGL ES. This was the default behavior before GTK 4.14.
|
||||
|
||||
`gl-egl`
|
||||
: Use an EGL context on X11 or Windows
|
||||
|
||||
`gl-glx`
|
||||
: Use GLX on X11
|
||||
|
||||
`gl-wgl`
|
||||
: Use WGL on Windows
|
||||
|
||||
`vulkan-disable`
|
||||
: Disable Vulkan support
|
||||
|
||||
`vulkan-validate`
|
||||
: Load the Vulkan validation layer, if available
|
||||
|
||||
@ -271,9 +250,6 @@ A number of options affect behavior instead of logging:
|
||||
`no-vsync`
|
||||
: Repaint instantly (uses 100% CPU with animations)
|
||||
|
||||
`dmabuf-disable`
|
||||
: Disable dmabuf support
|
||||
|
||||
The special value `all` can be used to turn on all debug options. The special
|
||||
value `help` can be used to obtain a list of all supported debug options.
|
||||
|
||||
@ -353,6 +329,35 @@ a `*`, which means: try all remaining backends. The special value
|
||||
backends. For more information about selecting backends,
|
||||
see the [func@Gdk.DisplayManager.get] function.
|
||||
|
||||
### `GDK_DISABLE`
|
||||
|
||||
This variable can be set to a list of values, which cause GDK to
|
||||
disable certain features.
|
||||
|
||||
`gl`
|
||||
: Disable OpenGL support
|
||||
|
||||
`gl-api`
|
||||
: Don't allow the use of OpenGL GL API. This forces GLES to be used
|
||||
|
||||
`gles-api`
|
||||
: Don't allow the use of OpenGL GLES API. This forces GL to be used
|
||||
|
||||
`egl`
|
||||
: Don't allow the use of an EGL context
|
||||
|
||||
`glx`
|
||||
: Don't allow the use of GLX
|
||||
|
||||
`wgl`
|
||||
: Don't allow the use of WGL
|
||||
|
||||
`vulkan`
|
||||
: Disable Vulkan support
|
||||
|
||||
`dmabuf`
|
||||
: Disable dmabuf support
|
||||
|
||||
### `GDK_GL_DISABLE`
|
||||
|
||||
This variable can be set to a list of values, which cause GDK to
|
||||
|
41
gdk/gdk.c
41
gdk/gdk.c
@ -133,22 +133,33 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
||||
{ "portals", GDK_DEBUG_PORTALS, "Force use of portals" },
|
||||
{ "no-portals", GDK_DEBUG_NO_PORTALS, "Disable use of portals" },
|
||||
{ "force-offload", GDK_DEBUG_FORCE_OFFLOAD, "Force graphics offload for all textures" },
|
||||
{ "gl-disable", GDK_DEBUG_GL_DISABLE, "Disable OpenGL support" },
|
||||
{ "gl-no-fractional", GDK_DEBUG_GL_NO_FRACTIONAL, "Disable fractional scaling for OpenGL" },
|
||||
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
|
||||
{ "gl-disable-gl", GDK_DEBUG_GL_DISABLE_GL, "Only allow OpenGL GLES API" },
|
||||
{ "gl-disable-gles", GDK_DEBUG_GL_DISABLE_GLES, "Don't allow OpenGL GLES API" },
|
||||
{ "gl-prefer-gl", GDK_DEBUG_GL_PREFER_GL, "Prefer GL over GLES API" },
|
||||
{ "gl-egl", GDK_DEBUG_GL_EGL, "Use EGL on X11 or Windows" },
|
||||
{ "gl-glx", GDK_DEBUG_GL_GLX, "Use GLX on X11" },
|
||||
{ "gl-wgl", GDK_DEBUG_GL_WGL, "Use WGL on Windows" },
|
||||
{ "vulkan-disable", GDK_DEBUG_VULKAN_DISABLE, "Disable Vulkan support" },
|
||||
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings" },
|
||||
{ "high-depth", GDK_DEBUG_HIGH_DEPTH, "Use high bit depth rendering if possible" },
|
||||
{ "no-vsync", GDK_DEBUG_NO_VSYNC, "Repaint instantly (uses 100% CPU with animations)" },
|
||||
{ "dmabuf-disable", GDK_DEBUG_DMABUF_DISABLE, "Disable dmabuf support" },
|
||||
};
|
||||
|
||||
static const GdkDebugKey gdk_feature_keys[] = {
|
||||
{ "gl", GDK_FEATURE_OPENGL, "Disable OpenGL support" },
|
||||
{ "gl-api", GDK_FEATURE_GL_API, "Disable non-GLES GL API" },
|
||||
{ "gles-api", GDK_FEATURE_GLES_API, "Disable GLES GL API" },
|
||||
{ "egl", GDK_FEATURE_EGL, "Disable EGL" },
|
||||
{ "glx", GDK_FEATURE_GLX, "Disable GLX" },
|
||||
{ "wgl", GDK_FEATURE_WGL, "Disable WGL" },
|
||||
{ "vulkan", GDK_FEATURE_VULKAN, "Disable Vulkan support" },
|
||||
{ "dmabuf", GDK_FEATURE_DMABUF, "Disable dmabuf support" },
|
||||
};
|
||||
|
||||
|
||||
static GdkFeatures gdk_features;
|
||||
|
||||
gboolean
|
||||
gdk_has_feature (GdkFeatures features)
|
||||
{
|
||||
return (features & gdk_features) == features;
|
||||
}
|
||||
|
||||
#ifdef G_HAS_CONSTRUCTORS
|
||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||
@ -303,6 +314,8 @@ gdk_parse_debug_var (const char *variable,
|
||||
void
|
||||
gdk_pre_parse (void)
|
||||
{
|
||||
GdkFeatures disabled_features;
|
||||
|
||||
gdk_initialized = TRUE;
|
||||
|
||||
gdk_ensure_resources ();
|
||||
@ -311,13 +324,11 @@ gdk_pre_parse (void)
|
||||
gdk_debug_keys,
|
||||
G_N_ELEMENTS (gdk_debug_keys));
|
||||
|
||||
/* These are global */
|
||||
if (_gdk_debug_flags & GDK_DEBUG_GL_EGL)
|
||||
gdk_gl_backend_use (GDK_GL_EGL);
|
||||
else if (_gdk_debug_flags & GDK_DEBUG_GL_GLX)
|
||||
gdk_gl_backend_use (GDK_GL_GLX);
|
||||
else if (_gdk_debug_flags & GDK_DEBUG_GL_WGL)
|
||||
gdk_gl_backend_use (GDK_GL_WGL);
|
||||
disabled_features = gdk_parse_debug_var ("GDK_DISABLE",
|
||||
gdk_feature_keys,
|
||||
G_N_ELEMENTS (gdk_feature_keys));
|
||||
|
||||
gdk_features = GDK_ALL_FEATURES & ~disabled_features;
|
||||
|
||||
#ifndef G_HAS_CONSTRUCTORS
|
||||
stash_and_unset_environment ();
|
||||
|
@ -44,29 +44,36 @@ typedef enum {
|
||||
GDK_DEBUG_HDR = 1 << 14,
|
||||
GDK_DEBUG_PORTALS = 1 << 15,
|
||||
GDK_DEBUG_NO_PORTALS = 1 << 16,
|
||||
GDK_DEBUG_GL_DISABLE = 1 << 17,
|
||||
GDK_DEBUG_GL_NO_FRACTIONAL= 1 << 18,
|
||||
GDK_DEBUG_FORCE_OFFLOAD = 1 << 19,
|
||||
GDK_DEBUG_GL_DISABLE_GL = 1 << 20,
|
||||
GDK_DEBUG_GL_DISABLE_GLES = 1 << 21,
|
||||
GDK_DEBUG_GL_PREFER_GL = 1 << 22,
|
||||
GDK_DEBUG_GL_DEBUG = 1 << 23,
|
||||
GDK_DEBUG_GL_EGL = 1 << 24,
|
||||
GDK_DEBUG_GL_GLX = 1 << 25,
|
||||
GDK_DEBUG_GL_WGL = 1 << 26,
|
||||
GDK_DEBUG_VULKAN_DISABLE = 1 << 27,
|
||||
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 28,
|
||||
GDK_DEBUG_HIGH_DEPTH = 1 << 29,
|
||||
GDK_DEBUG_NO_VSYNC = 1 << 30,
|
||||
GDK_DEBUG_DMABUF_DISABLE = 1 << 31,
|
||||
GDK_DEBUG_GL_NO_FRACTIONAL= 1 << 17,
|
||||
GDK_DEBUG_FORCE_OFFLOAD = 1 << 18,
|
||||
GDK_DEBUG_GL_PREFER_GL = 1 << 19,
|
||||
GDK_DEBUG_GL_DEBUG = 1 << 20,
|
||||
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 21,
|
||||
GDK_DEBUG_HIGH_DEPTH = 1 << 22,
|
||||
GDK_DEBUG_NO_VSYNC = 1 << 23,
|
||||
} GdkDebugFlags;
|
||||
|
||||
typedef enum {
|
||||
GDK_FEATURE_OPENGL = 1 << 0,
|
||||
GDK_FEATURE_GL_API = 1 << 1,
|
||||
GDK_FEATURE_GLES_API = 1 << 2,
|
||||
GDK_FEATURE_EGL = 1 << 3,
|
||||
GDK_FEATURE_GLX = 1 << 4,
|
||||
GDK_FEATURE_WGL = 1 << 5,
|
||||
GDK_FEATURE_VULKAN = 1 << 6,
|
||||
GDK_FEATURE_DMABUF = 1 << 7,
|
||||
} GdkFeatures;
|
||||
|
||||
#define GDK_ALL_FEATURES ((1 << 8) - 1)
|
||||
|
||||
extern guint _gdk_debug_flags;
|
||||
|
||||
GdkDebugFlags gdk_display_get_debug_flags (GdkDisplay *display);
|
||||
void gdk_display_set_debug_flags (GdkDisplay *display,
|
||||
GdkDebugFlags flags);
|
||||
|
||||
gboolean gdk_has_feature (GdkFeatures feature);
|
||||
|
||||
static inline void
|
||||
gdk_debug_message (const char *format, ...) G_GNUC_PRINTF(1, 2);
|
||||
static inline void
|
||||
|
@ -1309,10 +1309,10 @@ gdk_display_create_vulkan_context (GdkDisplay *self,
|
||||
g_return_val_if_fail (surface == NULL || GDK_IS_SURFACE (surface), NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (gdk_display_get_debug_flags (self) & GDK_DEBUG_VULKAN_DISABLE)
|
||||
if (!gdk_has_feature (GDK_FEATURE_VULKAN))
|
||||
{
|
||||
g_set_error_literal (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_NOT_AVAILABLE,
|
||||
_("Vulkan support disabled via GDK_DEBUG"));
|
||||
_("Vulkan support disabled via GDK_DISABLE"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1362,11 +1362,11 @@ gdk_display_init_gl (GdkDisplay *self)
|
||||
|
||||
before = GDK_PROFILER_CURRENT_TIME;
|
||||
|
||||
if (gdk_display_get_debug_flags (self) & GDK_DEBUG_GL_DISABLE)
|
||||
if (!gdk_has_feature (GDK_FEATURE_OPENGL))
|
||||
{
|
||||
g_set_error_literal (&priv->gl_error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("GL support disabled via GDK_DEBUG"));
|
||||
_("OpenGL support disabled via GDK_DISABLE"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2006,7 +2006,7 @@ gdk_display_init_dmabuf (GdkDisplay *self)
|
||||
builder = gdk_dmabuf_formats_builder_new ();
|
||||
|
||||
#ifdef HAVE_DMABUF
|
||||
if (!GDK_DISPLAY_DEBUG_CHECK (self, DMABUF_DISABLE))
|
||||
if (gdk_has_feature (GDK_FEATURE_DMABUF))
|
||||
{
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
gdk_display_add_dmabuf_downloader (self, gdk_vulkan_get_dmabuf_downloader (self, builder));
|
||||
|
@ -1063,11 +1063,11 @@ gdk_dmabuf_texture_builder_build (GdkDmabufTextureBuilder *self,
|
||||
for (i = 0; i < self->dmabuf.n_planes; i++)
|
||||
g_return_val_if_fail (self->dmabuf.planes[i].fd != -1, NULL);
|
||||
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (self->display, DMABUF_DISABLE))
|
||||
if (!gdk_has_feature (GDK_FEATURE_DMABUF))
|
||||
{
|
||||
g_set_error_literal (error,
|
||||
GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
|
||||
"dmabuf support disabled via GDK_DEBUG environment variable");
|
||||
"dmabuf support disabled via GDK_DISABLE environment variable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1328,31 +1328,28 @@ gdk_gl_context_is_api_allowed (GdkGLContext *self,
|
||||
GError **error)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
|
||||
GdkDebugFlags flags;
|
||||
GdkGLAPI allowed_apis;
|
||||
|
||||
allowed_apis = priv->allowed_apis;
|
||||
|
||||
flags = gdk_display_get_debug_flags (gdk_gl_context_get_display (self));
|
||||
|
||||
if (flags & GDK_DEBUG_GL_DISABLE_GLES)
|
||||
if (!gdk_has_feature (GDK_FEATURE_GLES_API))
|
||||
{
|
||||
if (api == GDK_GL_API_GLES)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("OpenGL ES disabled via GDK_DEBUG"));
|
||||
_("OpenGL ES API disabled via GDK_DISABLE"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
allowed_apis &= ~GDK_GL_API_GLES;
|
||||
}
|
||||
|
||||
if (flags & GDK_DEBUG_GL_DISABLE_GL)
|
||||
if (!gdk_has_feature (GDK_FEATURE_GL_API))
|
||||
{
|
||||
if (api == GDK_GL_API_GL)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("OpenGL disabled via GDK_DEBUG"));
|
||||
_("OpenGL API disabled via GDK_DISABLE"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -2154,17 +2151,30 @@ gboolean
|
||||
gdk_gl_backend_can_be_used (GdkGLBackend backend_type,
|
||||
GError **error)
|
||||
{
|
||||
if (the_gl_backend_type == GDK_GL_NONE ||
|
||||
the_gl_backend_type == backend_type)
|
||||
return TRUE;
|
||||
if (the_gl_backend_type != GDK_GL_NONE &&
|
||||
the_gl_backend_type != backend_type)
|
||||
{
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
/* translators: This is about OpenGL backend names, like
|
||||
* "Trying to use X11 GLX, but EGL is already in use"
|
||||
*/
|
||||
_("Trying to use %s, but %s is already in use"),
|
||||
gl_backend_names[backend_type],
|
||||
gl_backend_names[the_gl_backend_type]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
/* translators: This is about OpenGL backend names, like
|
||||
* "Trying to use X11 GLX, but EGL is already in use" */
|
||||
_("Trying to use %s, but %s is already in use"),
|
||||
gl_backend_names[backend_type],
|
||||
gl_backend_names[the_gl_backend_type]);
|
||||
return FALSE;
|
||||
if ((backend_type == GDK_GL_EGL && !gdk_has_feature (GDK_FEATURE_EGL)) ||
|
||||
(backend_type == GDK_GL_GLX && !gdk_has_feature (GDK_FEATURE_GLX)) ||
|
||||
(backend_type == GDK_GL_WGL && !gdk_has_feature (GDK_FEATURE_WGL)))
|
||||
{
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
||||
_("Trying to use %s, but it is disabled via GDK_DISABLE"),
|
||||
gl_backend_names[backend_type]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*<private>
|
||||
|
@ -1626,10 +1626,10 @@ gdk_display_create_vulkan_instance (GdkDisplay *display,
|
||||
gboolean have_debug_report = FALSE;
|
||||
VkResult res;
|
||||
|
||||
if (gdk_display_get_debug_flags (display) & GDK_DEBUG_VULKAN_DISABLE)
|
||||
if (!gdk_has_feature (GDK_FEATURE_VULKAN))
|
||||
{
|
||||
g_set_error_literal (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_NOT_AVAILABLE,
|
||||
_("Vulkan support disabled via GDK_DEBUG"));
|
||||
_("Vulkan support disabled via GDK_DISABLE"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -520,7 +520,7 @@ static void
|
||||
init_vulkan (GtkInspectorGeneral *gen)
|
||||
{
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
if (gdk_display_get_debug_flags (gen->display) & GDK_DEBUG_VULKAN_DISABLE)
|
||||
if (!gdk_has_feature (GDK_FEATURE_VULKAN))
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (gen->vk_device), C_("Vulkan device", "Disabled"));
|
||||
gtk_label_set_text (GTK_LABEL (gen->vk_api_version), C_("Vulkan version", "Disabled"));
|
||||
|
@ -725,19 +725,10 @@ get_inspector_display (void)
|
||||
|
||||
if (display)
|
||||
{
|
||||
GdkDebugFlags flags;
|
||||
|
||||
name = g_getenv ("GTK_INSPECTOR_RENDERER");
|
||||
|
||||
g_object_set_data_full (G_OBJECT (display), "gsk-renderer",
|
||||
g_strdup (name), g_free);
|
||||
|
||||
flags = gdk_display_get_debug_flags (gdk_display_get_default ());
|
||||
|
||||
gdk_display_set_debug_flags (display, flags & (GDK_DEBUG_GL_DISABLE_GL |
|
||||
GDK_DEBUG_GL_DISABLE_GLES |
|
||||
GDK_DEBUG_GL_GLX));
|
||||
gtk_set_display_debug_flags (display, 0);
|
||||
}
|
||||
|
||||
if (!display)
|
||||
|
Loading…
Reference in New Issue
Block a user