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:
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/GHOST_Types.h3
-rw-r--r--intern/ghost/intern/GHOST_XrContext.cpp36
-rw-r--r--intern/ghost/intern/GHOST_XrContext.h15
-rw-r--r--intern/ghost/intern/GHOST_XrSession.cpp8
4 files changed, 54 insertions, 8 deletions
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index b7ccb59a3a5..ede2de1f6da 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -615,6 +615,9 @@ typedef struct {
float angle_left, angle_right;
float angle_up, angle_down;
} fov;
+
+ /** Set if the buffer should be submitted with a srgb transfer applied. */
+ char expects_srgb_buffer;
} GHOST_XrDrawViewInfo;
typedef struct {
diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp
index 813fdf19f5a..541e23312ea 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()
@@ -505,6 +520,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 3cf33fb6950..c260e95eb08 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
@@ -63,6 +74,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;
@@ -72,6 +84,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;
@@ -92,6 +106,7 @@ class GHOST_XrContext : public GHOST_IXrContext {
bool m_debug_time{false};
void createOpenXRInstance();
+ void storeInstanceProperties();
void initDebugMessenger();
void printInstanceInfo();
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index a5eb7a891d7..f2f94d8f47d 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -420,6 +420,13 @@ static void ghost_xr_draw_view_info_from_view(const XrView &view, GHOST_XrDrawVi
r_info.fov.angle_down = view.fov.angleDown;
}
+bool ghost_xr_draw_view_expects_srgb_buffer(const GHOST_XrContext *context)
+{
+ /* WMR seems to be faulty and doesn't do OETF transform correctly. So expect a SRGB buffer to
+ * compensate. */
+ return context->getOpenXRRuntimeID() == OPENXR_RUNTIME_WMR;
+}
+
void GHOST_XrSession::drawView(XrSwapchain swapchain,
XrCompositionLayerProjectionView &proj_layer_view,
XrView &view,
@@ -449,6 +456,7 @@ void GHOST_XrSession::drawView(XrSwapchain swapchain,
swapchain_image = m_oxr->swapchain_images[swapchain][swapchain_idx];
+ draw_view_info.expects_srgb_buffer = ghost_xr_draw_view_expects_srgb_buffer(m_context);
draw_view_info.ofsx = proj_layer_view.subImage.imageRect.offset.x;
draw_view_info.ofsy = proj_layer_view.subImage.imageRect.offset.y;
draw_view_info.width = proj_layer_view.subImage.imageRect.extent.width;