gl-renderer: Add no config context feature flag

This commit introduces feature flags. While an extension flag only
ensures the availability of an extension at run-time, a feature flag
ensures the availability of a minimal OpenGL ES version and/or
extensions in order to easily check for the availability of a specific
feature at run-time.

This first feature ensures the availability of either the
EGL_KHR_no_config_context or EGL_MESA_configless_context extensions.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
Loïc Molinari 2024-10-10 16:01:44 +02:00 committed by Daniel Stone
parent 9d9d09a04d
commit 4a4a9b94d6
3 changed files with 21 additions and 4 deletions

View file

@ -720,6 +720,11 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
weston_log("warning: Disabling explicit synchronization due "
"to missing EGL_KHR_wait_sync extension\n");
/* No config context feature. */
if (egl_display_has(gr, EXTENSION_KHR_NO_CONFIG_CONTEXT) ||
egl_display_has(gr, EXTENSION_MESA_CONFIGLESS_CONTEXT))
gr->features |= FEATURE_NO_CONFIG_CONTEXT;
weston_log("EGL features:\n");
weston_log_continue(STAMP_SPACE "EGL Wayland extension: %s\n",
yesno(has_bind_display));
@ -732,8 +737,7 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
weston_log_continue(STAMP_SPACE "swap buffers with damage: %s\n",
yesno(gr->swap_buffers_with_damage));
weston_log_continue(STAMP_SPACE "configless context: %s\n",
yesno(egl_display_has(gr, EXTENSION_KHR_NO_CONFIG_CONTEXT) ||
egl_display_has(gr, EXTENSION_MESA_CONFIGLESS_CONTEXT)));
yesno(gl_features_has(gr, FEATURE_NO_CONFIG_CONTEXT)));
weston_log_continue(STAMP_SPACE "surfaceless context: %s\n",
yesno(egl_display_has(gr, EXTENSION_KHR_SURFACELESS_CONTEXT)));
weston_log_continue(STAMP_SPACE "dmabuf support: %s\n",

View file

@ -98,6 +98,11 @@ enum egl_display_extension_flag {
EXTENSION_WL_BIND_WAYLAND_DISPLAY = 1ull << 13,
};
enum gl_feature_flag {
/* GL renderer can create contexts without specifying an EGLConfig. */
FEATURE_NO_CONFIG_CONTEXT = 1ull << 0,
};
/* Keep the following in sync with vertex.glsl. */
enum gl_shader_texcoord_input {
SHADER_TEXCOORD_INPUT_ATTRIB = 0,
@ -310,6 +315,8 @@ struct gl_renderer {
/* EGL_KHR_wait_sync */
PFNEGLWAITSYNCKHRPROC wait_sync;
uint64_t features;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
PFNGLTEXIMAGE3DOESPROC tex_image_3d;
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC image_target_renderbuffer_storage;
@ -404,6 +411,13 @@ egl_display_has(struct gl_renderer *gr,
return (bool) (gr->egl_display_extensions & ((uint64_t) flag));
}
static inline bool
gl_features_has(struct gl_renderer *gr,
enum gl_feature_flag flag)
{
return (bool) (gr->features & ((uint64_t) flag));
}
static inline struct gl_renderer *
get_renderer(struct weston_compositor *ec)
{

View file

@ -4570,8 +4570,7 @@ gl_renderer_display_create(struct weston_compositor *ec,
if (!egl_display_has(gr, EXTENSION_KHR_SURFACELESS_CONTEXT))
goto fail_terminate;
if (!egl_display_has(gr, EXTENSION_KHR_NO_CONFIG_CONTEXT) &&
!egl_display_has(gr, EXTENSION_MESA_CONFIGLESS_CONTEXT)) {
if (!gl_features_has(gr, FEATURE_NO_CONFIG_CONTEXT)) {
EGLint egl_surface_type = options->egl_surface_type;
if (!egl_display_has(gr, EXTENSION_KHR_SURFACELESS_CONTEXT))