mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-10 15:58:06 +00:00
c/client: make sure layer_commit passes complete frames in comp_gl_client
Make sure `layer_commit` passes on complete frames in `comp_gl_client.c` even when EGL_ANDROID_native_fence_sync is not available. The `insert_fence` function defined in `comp_egl_client.c` and passed as argument to `comp_egl_client::client_gl_compositor_init` is only setting up a proper fence when EGL_ANDROID_native_fence_sync is available, resulting in a no-op otherwise. However the fact that the insert_fence function is still valid results in the `glFlush` workaround from `comp_gl_client::client_gl_compositor_layer_commit` not kicking in. To fix this define a NULL `insert_fence` function when EGL_ANDROID_native_fence_sync is not available, and while at it turn the `glFlush` workaround into a `glFinish` for extra safety. This ensures that frames are always complete after `client_gl_compositor_layer_commit` has been called.
This commit is contained in:
parent
ac30e798d6
commit
2b456da531
src/xrt/compositor/client
|
@ -179,17 +179,13 @@ ensure_native_fence_is_loaded(EGLDisplay dpy, PFNEGLGETPROCADDRESSPROC get_gl_pr
|
|||
*/
|
||||
|
||||
static xrt_result_t
|
||||
insert_fence(struct xrt_compositor *xc, xrt_graphics_sync_handle_t *out_handle)
|
||||
insert_fence_android_native(struct xrt_compositor *xc, xrt_graphics_sync_handle_t *out_handle)
|
||||
{
|
||||
struct client_egl_compositor *ceglc = client_egl_compositor(xc);
|
||||
|
||||
*out_handle = XRT_GRAPHICS_SYNC_HANDLE_INVALID;
|
||||
EGLDisplay dpy = ceglc->dpy;
|
||||
|
||||
if (!GLAD_EGL_ANDROID_native_fence_sync) {
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef XRT_GRAPHICS_SYNC_HANDLE_IS_FD
|
||||
|
||||
EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
|
||||
|
@ -335,7 +331,17 @@ xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn,
|
|||
|
||||
#endif
|
||||
|
||||
if (!client_gl_compositor_init(&ceglc->base, xcn, sc_create, insert_fence)) {
|
||||
/*
|
||||
* For now, only use the insert_fence callback only if
|
||||
* EGL_ANDROID_native_fence_sync is available, revisit this when a more
|
||||
* generic synchronization mechanism is implemented.
|
||||
*/
|
||||
client_gl_insert_fence_func insert_fence_func = NULL;
|
||||
if (GLAD_EGL_ANDROID_native_fence_sync) {
|
||||
insert_fence_func = insert_fence_android_native;
|
||||
}
|
||||
|
||||
if (!client_gl_compositor_init(&ceglc->base, xcn, sc_create, insert_fence_func)) {
|
||||
free(ceglc);
|
||||
EGL_ERROR("Failed to initialize compositor");
|
||||
old_restore(&old, display);
|
||||
|
|
|
@ -298,7 +298,7 @@ client_gl_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, x
|
|||
/*!
|
||||
* @todo The swapchain images should have been externally synchronized.
|
||||
*/
|
||||
glFlush();
|
||||
glFinish();
|
||||
}
|
||||
|
||||
if (xret != XRT_SUCCESS) {
|
||||
|
|
Loading…
Reference in a new issue