gl-renderer: Add explicit sync feature flag

This feature flag is for explicit sync support.

We replace the explicit sync warning by logging supported fence syncs
along with the report EGL features report.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
Loïc Molinari 2024-10-10 17:52:59 +02:00 committed by Daniel Stone
parent c29e2a7928
commit 94ca770c2a
3 changed files with 19 additions and 6 deletions

View file

@ -710,9 +710,6 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
if (egl_display_has(gr, EXTENSION_KHR_WAIT_SYNC))
GET_PROC_ADDRESS(gr->wait_sync, "eglWaitSyncKHR");
else
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) ||
@ -724,6 +721,11 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
egl_display_has(gr, EXTENSION_EXT_SWAP_BUFFERS_WITH_DAMAGE))
gr->features |= FEATURE_SWAP_BUFFERS_WITH_DAMAGE;
/* Explicit sync feature. */
if (egl_display_has(gr, EXTENSION_ANDROID_NATIVE_FENCE_SYNC) &&
egl_display_has(gr, EXTENSION_KHR_WAIT_SYNC))
gr->features |= FEATURE_EXPLICIT_SYNC;
weston_log("EGL features:\n");
weston_log_continue(STAMP_SPACE "EGL Wayland extension: %s\n",
yesno(has_bind_display));
@ -743,6 +745,13 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
!egl_display_has(gr, EXTENSION_EXT_IMAGE_DMA_BUF_IMPORT) ? "no" :
!egl_display_has(gr, EXTENSION_EXT_IMAGE_DMA_BUF_IMPORT_MODIFIERS) ? "legacy" :
"modifiers");
weston_log_continue(STAMP_SPACE "fence sync: %s\n",
!egl_display_has(gr, EXTENSION_KHR_FENCE_SYNC) ? "no" :
!egl_display_has(gr, EXTENSION_ANDROID_NATIVE_FENCE_SYNC) &&
!egl_display_has(gr, EXTENSION_KHR_WAIT_SYNC) ? "yes" :
!egl_display_has(gr, EXTENSION_ANDROID_NATIVE_FENCE_SYNC) ? "yes (wait)" :
!egl_display_has(gr, EXTENSION_KHR_WAIT_SYNC) ? "yes (native)" :
"yes (native, wait)");
return 0;
}

View file

@ -106,6 +106,10 @@ enum gl_feature_flag {
/* GL renderer can pass a list of damage rectangles at buffer swap in
* order to reduce recomposition costs. */
FEATURE_SWAP_BUFFERS_WITH_DAMAGE = 1ull << 1,
/* GL renderer can create native sync objects and wait on them. This
* enables support for the Linux explicit sync Wayland protocol. */
FEATURE_EXPLICIT_SYNC = 1ull << 2,
};
/* Keep the following in sync with vertex.glsl. */

View file

@ -1158,7 +1158,8 @@ ensure_surface_buffer_is_ready(struct gl_renderer *gr,
/* We should only get a fence if we support EGLSyncKHR, since
* we don't advertise the explicit sync protocol otherwise. */
assert(egl_display_has(gr, EXTENSION_ANDROID_NATIVE_FENCE_SYNC));
assert(gl_features_has(gr, FEATURE_EXPLICIT_SYNC));
/* We should only get a fence for non-SHM buffers, since surface
* commit would have failed otherwise. */
assert(buffer->type != WESTON_BUFFER_SHM);
@ -4589,8 +4590,7 @@ gl_renderer_display_create(struct weston_compositor *ec,
ec->capabilities |= WESTON_CAP_ROTATION_ANY;
ec->capabilities |= WESTON_CAP_CAPTURE_YFLIP;
ec->capabilities |= WESTON_CAP_VIEW_CLIP_MASK;
if (egl_display_has(gr, EXTENSION_ANDROID_NATIVE_FENCE_SYNC) &&
egl_display_has(gr, EXTENSION_KHR_WAIT_SYNC))
if (gl_features_has(gr, FEATURE_EXPLICIT_SYNC))
ec->capabilities |= WESTON_CAP_EXPLICIT_SYNC;
if (gr->allocator)