Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2019-08-07 04:22:33 +0300
committerJulian Eisel <eiseljulian@gmail.com>2019-08-07 04:22:33 +0300
commit3483aa57b34fc439f50b6576c26c11fb6cbb37f8 (patch)
tree4778ccbc815adf0410cbb8b5f877b83c81ded63d
parent44a220f721285005d94f4a55a530037f781686d0 (diff)
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.
-rw-r--r--intern/ghost/intern/GHOST_XrContext.cpp36
-rw-r--r--intern/ghost/intern/GHOST_XrContext.h15
2 files changed, 43 insertions, 8 deletions
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
@@ -36,6 +36,17 @@ struct GHOST_XrCustomFuncs {
};
/**
+ * 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.
*
* Creating a context using #GHOST_XrContextCreate involves dynamically connecting to the OpenXR
@@ -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();