[Bf-blender-cvs] [3483aa57b34] soc-2019-openxr: Allow querying OpenXR runtime ID
Julian Eisel
noreply at git.blender.org
Wed Aug 7 12:30:56 CEST 2019
Commit: 3483aa57b34fc439f50b6576c26c11fb6cbb37f8
Author: Julian Eisel
Date: Wed Aug 7 03:22:33 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rB3483aa57b34fc439f50b6576c26c11fb6cbb37f8
Allow querying OpenXR runtime ID
Useful in case special treatment is needed for certain runtimes.
Currently only WMR gets its ID assigned correctly, others are TODO.
===================================================================
M intern/ghost/intern/GHOST_XrContext.cpp
M intern/ghost/intern/GHOST_XrContext.h
===================================================================
diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp
index 03c3fed3b9e..07ed037fb5b 100644
--- a/intern/ghost/intern/GHOST_XrContext.cpp
+++ b/intern/ghost/intern/GHOST_XrContext.cpp
@@ -33,6 +33,7 @@
struct OpenXRInstanceData {
XrInstance instance{XR_NULL_HANDLE};
+ XrInstanceProperties instance_properties;
std::vector<XrExtensionProperties> extensions;
std::vector<XrApiLayerProperties> layers;
@@ -86,6 +87,7 @@ void GHOST_XrContext::initialize(const GHOST_XrContextCreateInfo *create_info)
assert(m_oxr->instance == XR_NULL_HANDLE);
createOpenXRInstance();
+ storeInstanceProperties();
printInstanceInfo();
XR_DEBUG_ONLY_CALL(this, initDebugMessenger());
}
@@ -110,6 +112,23 @@ void GHOST_XrContext::createOpenXRInstance()
"Failed to connect to an OpenXR runtime.");
}
+void GHOST_XrContext::storeInstanceProperties()
+{
+ const std::map<std::string, GHOST_TXrOpenXRRuntimeID> runtime_map{
+ // TODO other runtimes?
+ {"Windows Mixed Reality Runtime", OPENXR_RUNTIME_WMR}};
+ decltype(runtime_map)::const_iterator runtime_map_iter;
+
+ m_oxr->instance_properties.type = XR_TYPE_INSTANCE_PROPERTIES;
+ CHECK_XR(xrGetInstanceProperties(m_oxr->instance, &m_oxr->instance_properties),
+ "Failed to get OpenXR runtime information. Do you have an active runtime set up?");
+
+ runtime_map_iter = runtime_map.find(m_oxr->instance_properties.runtimeName);
+ if (runtime_map_iter != runtime_map.end()) {
+ m_runtime_id = runtime_map_iter->second;
+ }
+}
+
/** \} */ /* Create, Initialize and Destruct */
/* -------------------------------------------------------------------- */
@@ -121,15 +140,11 @@ void GHOST_XrContext::printInstanceInfo()
{
assert(m_oxr->instance != XR_NULL_HANDLE);
- XrInstanceProperties instance_properties{XR_TYPE_INSTANCE_PROPERTIES};
- CHECK_XR(xrGetInstanceProperties(m_oxr->instance, &instance_properties),
- "Failed to get OpenXR runtime information. Do you have an active runtime set up?");
-
printf("Connected to OpenXR runtime: %s (Version %u.%u.%u)\n",
- instance_properties.runtimeName,
- XR_VERSION_MAJOR(instance_properties.runtimeVersion),
- XR_VERSION_MINOR(instance_properties.runtimeVersion),
- XR_VERSION_PATCH(instance_properties.runtimeVersion));
+ m_oxr->instance_properties.runtimeName,
+ XR_VERSION_MAJOR(m_oxr->instance_properties.runtimeVersion),
+ XR_VERSION_MINOR(m_oxr->instance_properties.runtimeVersion),
+ XR_VERSION_PATCH(m_oxr->instance_properties.runtimeVersion));
}
void GHOST_XrContext::printAvailableAPILayersAndExtensionsInfo()
@@ -500,6 +515,11 @@ void GHOST_XrContext::setDrawViewFunc(GHOST_XrDrawViewFn draw_view_fn)
*
* \{ */
+GHOST_TXrOpenXRRuntimeID GHOST_XrContext::getOpenXRRuntimeID() const
+{
+ return m_runtime_id;
+}
+
const GHOST_XrCustomFuncs *GHOST_XrContext::getCustomFuncs() const
{
return &m_custom_funcs;
diff --git a/intern/ghost/intern/GHOST_XrContext.h b/intern/ghost/intern/GHOST_XrContext.h
index ec3b5d23f21..6f5c6ab425c 100644
--- a/intern/ghost/intern/GHOST_XrContext.h
+++ b/intern/ghost/intern/GHOST_XrContext.h
@@ -35,6 +35,17 @@ struct GHOST_XrCustomFuncs {
GHOST_XrDrawViewFn draw_view_fn{nullptr};
};
+/**
+ * In some occasions, runtime specific handling is needed, e.g. to work around runtime bugs.
+ */
+enum GHOST_TXrOpenXRRuntimeID {
+ OPENXR_RUNTIME_MONADO,
+ OPENXR_RUNTIME_OCULUS,
+ OPENXR_RUNTIME_WMR, /* Windows Mixed Reality */
+
+ OPENXR_RUNTIME_UNKNOWN
+};
+
/**
* \brief Main GHOST container to manage OpenXR through.
*
@@ -62,6 +73,7 @@ class GHOST_XrContext : public GHOST_IXrContext {
void handleSessionStateChange(const XrEventDataSessionStateChanged *lifecycle);
+ GHOST_TXrOpenXRRuntimeID getOpenXRRuntimeID() const;
const GHOST_XrCustomFuncs *getCustomFuncs() const;
GHOST_TXrGraphicsBinding getGraphicsBindingType() const;
XrInstance getInstance() const;
@@ -71,6 +83,8 @@ class GHOST_XrContext : public GHOST_IXrContext {
private:
std::unique_ptr<struct OpenXRInstanceData> m_oxr;
+ GHOST_TXrOpenXRRuntimeID m_runtime_id{OPENXR_RUNTIME_UNKNOWN};
+
/* The active GHOST XR Session. Null while no session runs. */
std::unique_ptr<class GHOST_XrSession> m_session;
@@ -91,6 +105,7 @@ class GHOST_XrContext : public GHOST_IXrContext {
bool m_debug_time{false};
void createOpenXRInstance();
+ void storeInstanceProperties();
void initDebugMessenger();
void printInstanceInfo();
More information about the Bf-blender-cvs
mailing list