2020-06-01 20:32:43 +00:00
|
|
|
// Copyright 2018-2020, Collabora, Ltd.
|
2019-03-18 05:52:32 +00:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Holds OpenGL-specific session functions.
|
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
|
|
|
* @ingroup oxr_main
|
|
|
|
* @ingroup comp_client
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2019-03-21 20:19:52 +00:00
|
|
|
#include "util/u_misc.h"
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
#include "oxr_objects.h"
|
|
|
|
#include "oxr_logger.h"
|
|
|
|
#include "oxr_two_call.h"
|
2019-04-05 19:18:03 +00:00
|
|
|
#include "oxr_handle.h"
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2020-04-10 09:53:27 +00:00
|
|
|
#include "xrt/xrt_instance.h"
|
|
|
|
|
2019-10-29 16:11:48 +00:00
|
|
|
#ifdef XR_USE_PLATFORM_XLIB
|
|
|
|
#include "xrt/xrt_gfx_xlib.h"
|
|
|
|
#endif
|
|
|
|
|
2019-12-03 19:08:10 +00:00
|
|
|
#ifdef XR_USE_GRAPHICS_API_OPENGL
|
2019-10-29 16:11:48 +00:00
|
|
|
#ifdef XR_USE_PLATFORM_XLIB
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2020-04-10 09:53:27 +00:00
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
XrResult
|
2019-04-05 22:13:58 +00:00
|
|
|
oxr_session_populate_gl_xlib(struct oxr_logger *log,
|
|
|
|
struct oxr_system *sys,
|
2019-06-03 19:17:45 +00:00
|
|
|
XrGraphicsBindingOpenGLXlibKHR const *next,
|
2019-04-05 22:13:58 +00:00
|
|
|
struct oxr_session *sess)
|
2019-03-18 05:52:32 +00:00
|
|
|
{
|
2020-04-10 09:53:27 +00:00
|
|
|
struct xrt_compositor_fd *xcfd = NULL;
|
2020-07-07 00:14:29 +00:00
|
|
|
struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head);
|
|
|
|
|
|
|
|
int ret = xrt_instance_create_fd_compositor(sys->inst->xinst, xdev,
|
2020-04-10 09:53:27 +00:00
|
|
|
true, &xcfd);
|
|
|
|
if (ret < 0 || xcfd == NULL) {
|
2020-03-01 12:09:25 +00:00
|
|
|
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
2020-06-01 20:29:11 +00:00
|
|
|
"Failed to create an fd compositor '%i'", ret);
|
2020-03-01 12:09:25 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 09:53:27 +00:00
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_xlib(
|
2020-03-01 12:09:25 +00:00
|
|
|
xcfd, next->xDisplay, next->visualid, next->glxFBConfig,
|
|
|
|
next->glxDrawable, next->glxContext);
|
2019-03-18 05:52:32 +00:00
|
|
|
|
|
|
|
if (xcgl == NULL) {
|
2020-03-01 12:09:25 +00:00
|
|
|
xcfd->base.destroy(&xcfd->base);
|
2019-03-18 05:52:32 +00:00
|
|
|
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
2020-06-01 20:29:11 +00:00
|
|
|
"Failed to create an xlib client compositor");
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sess->compositor = &xcgl->base;
|
|
|
|
sess->create_swapchain = oxr_swapchain_gl_create;
|
|
|
|
|
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
2019-10-29 16:11:48 +00:00
|
|
|
|
2019-12-03 19:08:10 +00:00
|
|
|
#endif // XR_USE_PLATFORM_XLIB
|
|
|
|
|
|
|
|
//! @todo add the other OpenGL graphics binding structs here
|
|
|
|
|
|
|
|
#endif // XR_USE_GRAPHICS_API_OPENGL
|