Merge branch 'default-to-gles' into 'main'

Use GLES by default

Closes #6170

See merge request GNOME/gtk!6520
This commit is contained in:
Matthias Clasen 2023-11-19 16:14:04 +00:00
commit 833d307695
9 changed files with 76 additions and 31 deletions

View File

@ -66,7 +66,7 @@ style-check-diff:
junit:
- "${CI_PROJECT_DIR}/_build/report-x11.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland_gles.xml"
- "${CI_PROJECT_DIR}/_build/report-wayland_gles2.xml"
- "${CI_PROJECT_DIR}/_build/report-broadway.xml"
name: "gtk-${CI_COMMIT_REF_NAME}"
paths:
@ -103,8 +103,8 @@ fedora-x86_64:
${FEATURE_FLAGS}
_build
- meson compile -C _build
- .gitlab-ci/run-tests.sh _build wayland
- .gitlab-ci/run-tests.sh _build wayland_gles
- .gitlab-ci/run-tests.sh _build wayland_gl
- .gitlab-ci/run-tests.sh _build wayland_gles2
release-build:
extends: .build-fedora-default
@ -129,6 +129,7 @@ release-build:
- meson install -C _build
- PKG_CONFIG_PATH=${CI_PROJECT_DIR}/_install/lib64/pkgconfig:${CI_PROJECT_DIR}/_install/share/pkgconfig meson setup _build_hello examples/hello
- LD_LIBRARY_PATH=${CI_PROJECT_DIR}/_install/lib64 meson compile -C _build_hello
- .gitlab-ci/run-tests.sh _build wayland
- .gitlab-ci/run-tests.sh _build x11
fedora-clang:
@ -424,7 +425,7 @@ asan-build:
_build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build wayland
- .gitlab-ci/run-tests.sh _build wayland_gles
- .gitlab-ci/run-tests.sh _build wayland_gles2
- .gitlab-ci/run-tests.sh _build x11
artifacts:
when: always

View File

@ -232,8 +232,14 @@ A number of options affect behavior instead of logging:
`gl-legacy`
: Use a legacy OpenGL context
`gl-gles`
: Use a GLES OpenGL context
`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

View File

@ -127,7 +127,9 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "gl-fractional", GDK_DEBUG_GL_FRACTIONAL, "Enable fractional scaling for OpenGL (experimental)" },
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
{ "gl-legacy", GDK_DEBUG_GL_LEGACY, "Use a legacy OpenGL context" },
{ "gl-gles", GDK_DEBUG_GL_GLES, "Only allow OpenGL GLES API" },
{ "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" },

View File

@ -46,17 +46,19 @@ typedef enum {
GDK_DEBUG_GL_DISABLE = 1 << 16,
GDK_DEBUG_GL_FRACTIONAL = 1 << 17,
GDK_DEBUG_GL_LEGACY = 1 << 18,
GDK_DEBUG_GL_GLES = 1 << 19,
GDK_DEBUG_GL_DEBUG = 1 << 20,
GDK_DEBUG_GL_EGL = 1 << 21,
GDK_DEBUG_GL_GLX = 1 << 22,
GDK_DEBUG_GL_WGL = 1 << 23,
GDK_DEBUG_VULKAN_DISABLE = 1 << 24,
GDK_DEBUG_VULKAN_VALIDATE = 1 << 25,
GDK_DEBUG_DEFAULT_SETTINGS= 1 << 26,
GDK_DEBUG_HIGH_DEPTH = 1 << 27,
GDK_DEBUG_NO_VSYNC = 1 << 28,
GDK_DEBUG_DMABUF_DISABLE = 1 << 29,
GDK_DEBUG_GL_DISABLE_GL = 1 << 19,
GDK_DEBUG_GL_DISABLE_GLES = 1 << 20,
GDK_DEBUG_GL_PREFER_GL = 1 << 21,
GDK_DEBUG_GL_DEBUG = 1 << 22,
GDK_DEBUG_GL_EGL = 1 << 23,
GDK_DEBUG_GL_GLX = 1 << 24,
GDK_DEBUG_GL_WGL = 1 << 25,
GDK_DEBUG_VULKAN_DISABLE = 1 << 26,
GDK_DEBUG_VULKAN_VALIDATE = 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,
} GdkDebugFlags;
extern guint _gdk_debug_flags;

View File

@ -389,17 +389,24 @@ gdk_gl_context_realize_egl (GdkGLContext *context,
{
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkGLContext *share = gdk_display_get_gl_context (display);
GdkDebugFlags flags;
GdkGLAPI api, preferred_api;
gboolean prefer_legacy;
flags = gdk_display_get_debug_flags(display);
if (share && gdk_gl_context_is_api_allowed (context,
gdk_gl_context_get_api (share),
NULL))
preferred_api = gdk_gl_context_get_api (share);
else if (gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL))
else if ((flags & GDK_DEBUG_GL_PREFER_GL) != 0 &&
gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL))
preferred_api = GDK_GL_API_GL;
else if (gdk_gl_context_is_api_allowed (context, GDK_GL_API_GLES, NULL))
preferred_api = GDK_GL_API_GLES;
else if ((flags & GDK_DEBUG_GL_PREFER_GL) == 0 &&
gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL))
preferred_api = GDK_GL_API_GL;
else
{
g_set_error_literal (error, GDK_GL_ERROR,
@ -408,7 +415,7 @@ gdk_gl_context_realize_egl (GdkGLContext *context,
return 0;
}
prefer_legacy = (gdk_display_get_debug_flags(display) & GDK_DEBUG_GL_LEGACY) ||
prefer_legacy = (flags & GDK_DEBUG_GL_LEGACY) ||
(share != NULL && gdk_gl_context_is_legacy (share));
if (preferred_api == GDK_GL_API_GL)
@ -1277,18 +1284,38 @@ gdk_gl_context_is_api_allowed (GdkGLContext *self,
GError **error)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
GdkDebugFlags flags;
GdkGLAPI allowed_apis;
if (gdk_display_get_debug_flags (gdk_gl_context_get_display (self)) & GDK_DEBUG_GL_GLES)
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 (!(api & GDK_GL_API_GLES))
if (api == GDK_GL_API_GLES)
{
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
_("Anything but OpenGL ES disabled via GDK_DEBUG"));
_("OpenGL ES disabled via GDK_DEBUG"));
return FALSE;
}
allowed_apis &= ~GDK_GL_API_GLES;
}
if (priv->allowed_apis & api)
if (flags & GDK_DEBUG_GL_DISABLE_GL)
{
if (api == GDK_GL_API_GL)
{
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
_("OpenGL disabled via GDK_DEBUG"));
return FALSE;
}
allowed_apis &= ~GDK_GL_API_GL;
}
if (allowed_apis & api)
return TRUE;
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,

View File

@ -1198,7 +1198,7 @@ gdk_win32_display_init_gl (GdkDisplay *display,
* Disable defaulting to EGL as EGL is used more as a compatibility layer
* on Windows rather than being a native citizen on Windows
*/
if (gdk_display_get_debug_flags (display) & (GDK_DEBUG_GL_EGL|GDK_DEBUG_GL_GLES))
if (gdk_display_get_debug_flags (display) & (GDK_DEBUG_GL_EGL|GDK_DEBUG_GL_DISABLE_GL))
{
init_gl_hdc = GetDC (display_win32->hwnd);

View File

@ -734,7 +734,9 @@ get_inspector_display (void)
flags = gdk_display_get_debug_flags (gdk_display_get_default ());
gdk_display_set_debug_flags (display, flags & (GDK_DEBUG_GL_GLES | GDK_DEBUG_GL_GLX));
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);
}

View File

@ -159,7 +159,7 @@ foreach renderer : renderers
endif
if compare_xfails_small_texture.contains(testname)
suites += 'wayland_gles_failing'
suites += 'wayland_gles2_failing'
endif
test_env = [

View File

@ -16,12 +16,16 @@ exclude_unstable = ['flaky', 'failing']
setups = [
{ 'backend': 'x11', 'if': x11_enabled, },
{ 'backend': 'wayland', 'if': wayland_enabled, 'is_default': true, },
{ 'name': 'wayland_gles',
{ 'name': 'wayland_gles2',
'backend': 'wayland', 'if': wayland_enabled,
'env': ['GDK_DEBUG=gl-gles,default-settings',
'env': ['GDK_DEBUG=default-settings',
'MESA_GLES_VERSION_OVERRIDE=2.0',
'GSK_MAX_TEXTURE_SIZE=1024',
], },
{ 'name': 'wayland_gl',
'backend': 'wayland', 'if': wayland_enabled,
'env': ['GDK_DEBUG=gl-prefer-gl,default-settings',
], },
{ 'backend': 'win32', 'if': os_win32 },
{ 'backend': 'broadway', 'if': broadway_enabled, },
{ 'backend': 'win32', 'if': os_win32 },
@ -37,8 +41,9 @@ foreach setup : setups
exclude += 'gsk-compare-broadway'
endif
if name == 'wayland_gles'
exclude += 'wayland_gles_failing'
if name == 'wayland_gles2'
# exclude tests that are failing with the small texture size in this setup
exclude += 'wayland_gles2_failing'
endif
env = common_env + [