diff --git a/src/xrt/compositor/client/comp_egl_glue.c b/src/xrt/compositor/client/comp_egl_glue.c index 7635d0b7c..87df8c78a 100644 --- a/src/xrt/compositor/client/comp_egl_glue.c +++ b/src/xrt/compositor/client/comp_egl_glue.c @@ -216,12 +216,13 @@ client_egl_compositor_destroy(struct xrt_compositor *xc) free(ceglc); } -struct xrt_compositor_gl * +xrt_result_t xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn, EGLDisplay display, EGLConfig config, EGLContext context, - PFNEGLGETPROCADDRESSPROC get_gl_procaddr) + PFNEGLGETPROCADDRESSPROC get_gl_procaddr, + struct xrt_compositor_gl **out_xcgl) { ll = debug_get_log_option_egl_log(); @@ -236,13 +237,13 @@ xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn, if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, context)) { EGL_ERROR("Failed to make EGL context current"); // No need to restore on failure. - return NULL; + return XRT_ERROR_OPENGL; } EGLint egl_client_type; if (!eglQueryContext(display, context, EGL_CONTEXT_CLIENT_TYPE, &egl_client_type)) { old_restore(&old); - return NULL; + return XRT_ERROR_OPENGL; } switch (egl_client_type) { @@ -253,7 +254,7 @@ xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn, #else EGL_ERROR("OpenGL support not including in this runtime build"); old_restore(&old); - return NULL; + return XRT_ERROR_OPENGL; #endif case EGL_OPENGL_ES_API: @@ -263,9 +264,9 @@ xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn, #else EGL_ERROR("OpenGL|ES support not including in this runtime build"); old_restore(&old); - return NULL; + return XRT_ERROR_OPENGL; #endif - default: EGL_ERROR("Unsupported EGL client type"); return NULL; + default: EGL_ERROR("Unsupported EGL client type"); return XRT_ERROR_OPENGL; } struct client_egl_compositor *ceglc = U_TYPED_CALLOC(struct client_egl_compositor); @@ -307,7 +308,7 @@ xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn, "EGL_EXT_image_dma_buf_import or " "GL_EXT_memory_object_fd"); old_restore(&old); - return NULL; + return XRT_ERROR_OPENGL; } #elif defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_AHARDWAREBUFFER) EGL_INFO("Using EGL_Image swapchain implementation with AHardwareBuffer"); @@ -318,10 +319,11 @@ xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn, free(ceglc); U_LOG_E("Failed to initialize compositor"); old_restore(&old); - return NULL; + return XRT_ERROR_OPENGL; } ceglc->base.base.base.destroy = client_egl_compositor_destroy; old_restore(&old); - return &ceglc->base.base; + *out_xcgl = &ceglc->base.base; + return XRT_SUCCESS; } diff --git a/src/xrt/include/xrt/xrt_gfx_egl.h b/src/xrt/include/xrt/xrt_gfx_egl.h index 44af50142..10c3b0735 100644 --- a/src/xrt/include/xrt/xrt_gfx_egl.h +++ b/src/xrt/include/xrt/xrt_gfx_egl.h @@ -29,12 +29,13 @@ struct time_state; * @ingroup xrt_iface * @public @memberof xrt_compositor_native */ -struct xrt_compositor_gl * +xrt_result_t xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn, EGLDisplay display, EGLConfig config, EGLContext context, - PFNEGLGETPROCADDRESSPROC getProcAddress); + PFNEGLGETPROCADDRESSPROC getProcAddress, + struct xrt_compositor_gl **out_xcgl); #ifdef __cplusplus } diff --git a/src/xrt/state_trackers/oxr/oxr_session_egl.c b/src/xrt/state_trackers/oxr/oxr_session_egl.c index b16246a41..26cfdead1 100644 --- a/src/xrt/state_trackers/oxr/oxr_session_egl.c +++ b/src/xrt/state_trackers/oxr/oxr_session_egl.c @@ -1,4 +1,4 @@ -// Copyright 2018-2020, Collabora, Ltd. +// Copyright 2018-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -60,14 +60,16 @@ oxr_session_populate_egl(struct oxr_logger *log, } struct xrt_compositor_native *xcn = sess->xcn; - struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_egl( // - xcn, // - next->display, // - next->config, // - next->context, // - next->getProcAddress); // + struct xrt_compositor_gl *xcgl = NULL; + xrt_result_t xret = xrt_gfx_provider_create_gl_egl( // + xcn, // + next->display, // + next->config, // + next->context, // + next->getProcAddress, // + &xcgl); // - if (xcgl == NULL) { + if (xret != XR_SUCCESS || xcgl == NULL) { return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, "Failed to create an egl client compositor"); } diff --git a/src/xrt/state_trackers/oxr/oxr_session_gles_android.c b/src/xrt/state_trackers/oxr/oxr_session_gles_android.c index 1b5b850ff..615ed39e8 100644 --- a/src/xrt/state_trackers/oxr/oxr_session_gles_android.c +++ b/src/xrt/state_trackers/oxr/oxr_session_gles_android.c @@ -1,4 +1,4 @@ -// Copyright 2018-2020, Collabora, Ltd. +// Copyright 2018-2021, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -68,14 +68,16 @@ oxr_session_populate_gles_android(struct oxr_logger *log, struct xrt_compositor_native *xcn = sess->xcn; - struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_egl( // - xcn, // - next->display, // - next->config, // - next->context, // - get_proc_addr); // + struct xrt_compositor_gl *xcgl = NULL; + xrt_result_t xret = xrt_gfx_provider_create_gl_egl( // + xcn, // + next->display, // + next->config, // + next->context, // + get_proc_addr, // + &xcgl); // - if (xcgl == NULL) { + if (xret != XR_SUCCESS || xcgl == NULL) { return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, "Failed to create an egl client compositor"); }