mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
st/oxr: Use new xrt_instance object
This commit is contained in:
parent
bbc07ed5f2
commit
c39cb39643
|
@ -13,7 +13,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "xrt/xrt_compiler.h"
|
||||
#include "xrt/xrt_prober.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#include "util/u_misc.h"
|
||||
#include "util/u_debug.h"
|
||||
|
||||
#include "xrt/xrt_compiler.h"
|
||||
#include "xrt/xrt_prober.h"
|
||||
#include "xrt/xrt_instance.h"
|
||||
|
||||
#include "oxr_objects.h"
|
||||
#include "oxr_logger.h"
|
||||
|
@ -41,7 +40,7 @@ extern int
|
|||
oxr_sdl2_hack_create(void **out_hack);
|
||||
|
||||
extern void
|
||||
oxr_sdl2_hack_start(void *hack, struct xrt_prober *xp);
|
||||
oxr_sdl2_hack_start(void *hack, struct xrt_instance *xinst);
|
||||
|
||||
extern void
|
||||
oxr_sdl2_hack_stop(void **hack_ptr);
|
||||
|
@ -75,7 +74,7 @@ oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
|
|||
oxr_sdl2_hack_stop(&inst->hack);
|
||||
/* ---- HACK ---- */
|
||||
|
||||
xrt_prober_destroy(&inst->prober);
|
||||
xrt_instance_destroy(&inst->xinst);
|
||||
|
||||
// Does null checking and sets to null.
|
||||
time_state_destroy(&inst->timekeeping);
|
||||
|
@ -103,7 +102,7 @@ oxr_instance_create(struct oxr_logger *log,
|
|||
{
|
||||
struct oxr_instance *inst = NULL;
|
||||
struct xrt_device *xdevs[NUM_XDEVS] = {0};
|
||||
int h_ret, p_ret;
|
||||
int h_ret, xinst_ret;
|
||||
XrResult ret;
|
||||
|
||||
OXR_ALLOCATE_HANDLE_OR_RETURN(log, inst, OXR_XR_DEBUG_INSTANCE,
|
||||
|
@ -144,26 +143,19 @@ oxr_instance_create(struct oxr_logger *log,
|
|||
cache_path(log, inst, "/interaction_profiles/mnd/ball_on_stick_controller", &inst->path_cache.mnd_ball_on_stick_controller);
|
||||
// clang-format on
|
||||
|
||||
p_ret = xrt_prober_create(&inst->prober);
|
||||
if (p_ret != 0) {
|
||||
xinst_ret = xrt_instance_create(&inst->xinst);
|
||||
if (xinst_ret != 0) {
|
||||
ret = oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
||||
"Failed to create prober");
|
||||
oxr_instance_destroy(log, &inst->handle);
|
||||
return ret;
|
||||
}
|
||||
|
||||
p_ret = xrt_prober_probe(inst->prober);
|
||||
if (p_ret != 0) {
|
||||
ret = oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
||||
"Failed to probe device(s)");
|
||||
oxr_instance_destroy(log, &inst->handle);
|
||||
return ret;
|
||||
}
|
||||
|
||||
p_ret = xrt_prober_select(inst->prober, xdevs, NUM_XDEVS);
|
||||
if (p_ret != 0) {
|
||||
xinst_ret = xrt_instance_select(inst->xinst, xdevs, NUM_XDEVS);
|
||||
if (xinst_ret != 0) {
|
||||
ret = oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
||||
"Failed to select device");
|
||||
"Failed to select device(s)");
|
||||
oxr_instance_destroy(log, &inst->handle);
|
||||
return ret;
|
||||
}
|
||||
|
@ -247,7 +239,7 @@ oxr_instance_create(struct oxr_logger *log,
|
|||
u_var_add_root((void *)inst, "XrInstance", true);
|
||||
|
||||
/* ---- HACK ---- */
|
||||
oxr_sdl2_hack_start(inst->hack, inst->prober);
|
||||
oxr_sdl2_hack_start(inst->hack, inst->xinst);
|
||||
/* ---- HACK ---- */
|
||||
|
||||
*out_instance = inst;
|
||||
|
|
|
@ -63,6 +63,7 @@ extern "C" {
|
|||
*
|
||||
*/
|
||||
|
||||
struct xrt_instance;
|
||||
struct oxr_logger;
|
||||
struct oxr_instance;
|
||||
struct oxr_system;
|
||||
|
@ -886,7 +887,7 @@ struct oxr_instance
|
|||
void *hack;
|
||||
/* ---- HACK ---- */
|
||||
|
||||
struct xrt_prober *prober;
|
||||
struct xrt_instance *xinst;
|
||||
|
||||
//! Enabled extensions
|
||||
struct oxr_extension_status extensions;
|
||||
|
|
|
@ -18,13 +18,15 @@
|
|||
#include "oxr_two_call.h"
|
||||
#include "oxr_handle.h"
|
||||
|
||||
#include "xrt/xrt_instance.h"
|
||||
|
||||
#ifdef XR_USE_PLATFORM_EGL
|
||||
#define EGL_NO_X11 // libglvnd
|
||||
#define MESA_EGL_NO_X11_HEADERS // mesa
|
||||
#include <EGL/egl.h>
|
||||
#include "xrt/xrt_gfx_fd.h"
|
||||
#include "xrt/xrt_gfx_egl.h"
|
||||
|
||||
|
||||
// Not forward declared by mesa
|
||||
typedef EGLBoolean(EGLAPIENTRYP PFNEGLQUERYCONTEXTPROC)(EGLDisplay dpy,
|
||||
EGLContext ctx,
|
||||
|
@ -62,11 +64,12 @@ oxr_session_populate_egl(struct oxr_logger *log,
|
|||
"unsupported EGL client type");
|
||||
}
|
||||
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
xrt_gfx_provider_create_fd(sys->head, true);
|
||||
if (xcfd == NULL) {
|
||||
struct xrt_compositor_fd *xcfd = NULL;
|
||||
int ret = xrt_instance_create_fd_compositor(sys->inst->xinst, sys->head,
|
||||
true, &xcfd);
|
||||
if (ret < 0 || xcfd == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a fd compositor");
|
||||
" failed create a fd compositor '%i'", ret);
|
||||
}
|
||||
|
||||
struct xrt_compositor_gl *xcgl =
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
#include "oxr_two_call.h"
|
||||
#include "oxr_handle.h"
|
||||
|
||||
#include "xrt/xrt_gfx_fd.h"
|
||||
#include "xrt/xrt_instance.h"
|
||||
|
||||
#ifdef XR_USE_PLATFORM_XLIB
|
||||
#include "xrt/xrt_gfx_xlib.h"
|
||||
#endif
|
||||
|
@ -25,19 +26,22 @@
|
|||
#ifdef XR_USE_GRAPHICS_API_OPENGL
|
||||
#ifdef XR_USE_PLATFORM_XLIB
|
||||
|
||||
|
||||
XrResult
|
||||
oxr_session_populate_gl_xlib(struct oxr_logger *log,
|
||||
struct oxr_system *sys,
|
||||
XrGraphicsBindingOpenGLXlibKHR const *next,
|
||||
struct oxr_session *sess)
|
||||
{
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
xrt_gfx_provider_create_fd(sys->head, true);
|
||||
if (xcfd == NULL) {
|
||||
struct xrt_compositor_fd *xcfd = NULL;
|
||||
int ret = xrt_instance_create_fd_compositor(sys->inst->xinst, sys->head,
|
||||
true, &xcfd);
|
||||
if (ret < 0 || xcfd == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a fd compositor");
|
||||
" failed create a fd compositor '%i'", ret);
|
||||
}
|
||||
|
||||
|
||||
struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_xlib(
|
||||
xcfd, next->xDisplay, next->visualid, next->glxFBConfig,
|
||||
next->glxDrawable, next->glxContext);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "util/u_misc.h"
|
||||
|
||||
#include "xrt/xrt_gfx_fd.h"
|
||||
#include "xrt/xrt_instance.h"
|
||||
#include "xrt/xrt_gfx_vk.h"
|
||||
|
||||
#include "oxr_objects.h"
|
||||
|
@ -20,17 +20,19 @@
|
|||
#include "oxr_two_call.h"
|
||||
#include "oxr_handle.h"
|
||||
|
||||
|
||||
XrResult
|
||||
oxr_session_populate_vk(struct oxr_logger *log,
|
||||
struct oxr_system *sys,
|
||||
XrGraphicsBindingVulkanKHR const *next,
|
||||
struct oxr_session *sess)
|
||||
{
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
xrt_gfx_provider_create_fd(sys->head, false);
|
||||
if (xcfd == NULL) {
|
||||
struct xrt_compositor_fd *xcfd = NULL;
|
||||
int ret = xrt_instance_create_fd_compositor(sys->inst->xinst, sys->head,
|
||||
false, &xcfd);
|
||||
if (ret < 0 || xcfd == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a fd compositor");
|
||||
" failed create a fd compositor '%i'", ret);
|
||||
}
|
||||
|
||||
struct xrt_compositor_vk *xcvk = xrt_gfx_vk_provider_create(
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
*/
|
||||
|
||||
#include "xrt/xrt_instance.h"
|
||||
#include "xrt/xrt_config_have.h"
|
||||
|
||||
#include "util/u_var.h"
|
||||
#include "util/u_misc.h"
|
||||
#include "util/u_debug.h"
|
||||
|
@ -18,6 +20,8 @@
|
|||
#include "gui/gui_imgui.h"
|
||||
|
||||
|
||||
struct xrt_instance;
|
||||
|
||||
#ifndef XRT_HAVE_SDL2
|
||||
|
||||
int
|
||||
|
@ -27,7 +31,7 @@ oxr_sdl2_hack_create(void **out_hack)
|
|||
}
|
||||
|
||||
void
|
||||
oxr_sdl2_hack_start(void *hack, struct xrt_prober *xp)
|
||||
oxr_sdl2_hack_start(void *hack, struct xrt_instance *xinst)
|
||||
{}
|
||||
|
||||
void
|
||||
|
@ -259,15 +263,14 @@ oxr_sdl2_hack_create(void **out_hack)
|
|||
}
|
||||
|
||||
void
|
||||
oxr_sdl2_hack_start(void *hack, struct xrt_prober *xp)
|
||||
oxr_sdl2_hack_start(void *hack, struct xrt_instance *xinst)
|
||||
{
|
||||
struct sdl2_program *p = (struct sdl2_program *)hack;
|
||||
if (p == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p->base.xp = xp;
|
||||
|
||||
xrt_instance_get_prober(xinst, &p->base.xp);
|
||||
|
||||
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
|
||||
fprintf(stderr, "Failed to init SDL2!\n");
|
||||
|
|
Loading…
Reference in a new issue