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