You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
Implement XR_EXT_performance_settings OpenXR extension
This commit is contained in:
@@ -128,6 +128,20 @@
|
|||||||
Sets the given action set as active or inactive.
|
Sets the given action set as active or inactive.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="set_cpu_level">
|
||||||
|
<return type="void" />
|
||||||
|
<param index="0" name="level" type="int" enum="OpenXRInterface.PerfSettingsLevel" />
|
||||||
|
<description>
|
||||||
|
Sets the CPU performance level of the OpenXR device.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
|
<method name="set_gpu_level">
|
||||||
|
<return type="void" />
|
||||||
|
<param index="0" name="level" type="int" enum="OpenXRInterface.PerfSettingsLevel" />
|
||||||
|
<description>
|
||||||
|
Sets the GPU performance level of the OpenXR device.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="set_motion_range">
|
<method name="set_motion_range">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="hand" type="int" enum="OpenXRInterface.Hand" />
|
<param index="0" name="hand" type="int" enum="OpenXRInterface.Hand" />
|
||||||
@@ -162,6 +176,22 @@
|
|||||||
</member>
|
</member>
|
||||||
</members>
|
</members>
|
||||||
<signals>
|
<signals>
|
||||||
|
<signal name="cpu_level_changed">
|
||||||
|
<param index="0" name="sub_domain" type="int" />
|
||||||
|
<param index="1" name="from_level" type="int" />
|
||||||
|
<param index="2" name="to_level" type="int" />
|
||||||
|
<description>
|
||||||
|
Informs the device CPU performance level has changed in the specified subdomain.
|
||||||
|
</description>
|
||||||
|
</signal>
|
||||||
|
<signal name="gpu_level_changed">
|
||||||
|
<param index="0" name="sub_domain" type="int" />
|
||||||
|
<param index="1" name="from_level" type="int" />
|
||||||
|
<param index="2" name="to_level" type="int" />
|
||||||
|
<description>
|
||||||
|
Informs the device GPU performance level has changed in the specified subdomain.
|
||||||
|
</description>
|
||||||
|
</signal>
|
||||||
<signal name="instance_exiting">
|
<signal name="instance_exiting">
|
||||||
<description>
|
<description>
|
||||||
Informs our OpenXR instance is exiting.
|
Informs our OpenXR instance is exiting.
|
||||||
@@ -317,6 +347,36 @@
|
|||||||
<constant name="HAND_JOINT_MAX" value="26" enum="HandJoints">
|
<constant name="HAND_JOINT_MAX" value="26" enum="HandJoints">
|
||||||
Maximum value for the hand joint enum.
|
Maximum value for the hand joint enum.
|
||||||
</constant>
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_LEVEL_POWER_SAVINGS" value="0" enum="PerfSettingsLevel">
|
||||||
|
The application has entered a non-XR section (head-locked / static screen), during which power savings are to be prioritized.
|
||||||
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_LEVEL_SUSTAINED_LOW" value="1" enum="PerfSettingsLevel">
|
||||||
|
The application has entered a low and stable complexity section, during which reducing power is more important than occasional late rendering frames.
|
||||||
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_LEVEL_SUSTAINED_HIGH" value="2" enum="PerfSettingsLevel">
|
||||||
|
The application has entered a high or dynamic complexity section, during which the XR Runtime strives for consistent XR compositing and frame rendering within a thermally sustainable range.
|
||||||
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_LEVEL_BOOST" value="3" enum="PerfSettingsLevel">
|
||||||
|
The application has entered a section with very high complexity, during which the XR Runtime is allowed to step up beyond the thermally sustainable range.
|
||||||
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_SUB_DOMAIN_COMPOSITING" value="0" enum="PerfSettingsSubDomain">
|
||||||
|
The compositing performance within the runtime has reached a new level.
|
||||||
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_SUB_DOMAIN_RENDERING" value="1" enum="PerfSettingsSubDomain">
|
||||||
|
The application rendering performance has reached a new level.
|
||||||
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_SUB_DOMAIN_THERMAL" value="2" enum="PerfSettingsSubDomain">
|
||||||
|
The temperature of the device has reached a new level.
|
||||||
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_NOTIF_LEVEL_NORMAL" value="0" enum="PerfSettingsNotificationLevel">
|
||||||
|
The sub-domain has reached a level where no further actions other than currently applied are necessary.
|
||||||
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_NOTIF_LEVEL_WARNING" value="1" enum="PerfSettingsNotificationLevel">
|
||||||
|
The sub-domain has reached an early warning level where the application should start proactive mitigation actions.
|
||||||
|
</constant>
|
||||||
|
<constant name="PERF_SETTINGS_NOTIF_LEVEL_IMPAIRED" value="2" enum="PerfSettingsNotificationLevel">
|
||||||
|
The sub-domain has reached a critical level where the application should start drastic mitigation actions.
|
||||||
|
</constant>
|
||||||
<constant name="HAND_JOINT_NONE" value="0" enum="HandJointFlags" is_bitfield="true">
|
<constant name="HAND_JOINT_NONE" value="0" enum="HandJointFlags" is_bitfield="true">
|
||||||
No flags are set.
|
No flags are set.
|
||||||
</constant>
|
</constant>
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
/**************************************************************************/
|
||||||
|
/* openxr_performance_settings_extension.cpp */
|
||||||
|
/**************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/**************************************************************************/
|
||||||
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* */
|
||||||
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
|
/* a copy of this software and associated documentation files (the */
|
||||||
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
|
/* the following conditions: */
|
||||||
|
/* */
|
||||||
|
/* The above copyright notice and this permission notice shall be */
|
||||||
|
/* included in all copies or substantial portions of the Software. */
|
||||||
|
/* */
|
||||||
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
/**************************************************************************/
|
||||||
|
|
||||||
|
#include "openxr_performance_settings_extension.h"
|
||||||
|
|
||||||
|
#include "../openxr_api.h"
|
||||||
|
|
||||||
|
OpenXRPerformanceSettingsExtension *OpenXRPerformanceSettingsExtension::singleton = nullptr;
|
||||||
|
|
||||||
|
OpenXRPerformanceSettingsExtension *OpenXRPerformanceSettingsExtension::get_singleton() {
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenXRPerformanceSettingsExtension::OpenXRPerformanceSettingsExtension() {
|
||||||
|
singleton = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenXRPerformanceSettingsExtension::~OpenXRPerformanceSettingsExtension() {
|
||||||
|
singleton = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String, bool *> OpenXRPerformanceSettingsExtension::get_requested_extensions() {
|
||||||
|
HashMap<String, bool *> request_extensions;
|
||||||
|
|
||||||
|
request_extensions[XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME] = &available;
|
||||||
|
|
||||||
|
return request_extensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenXRPerformanceSettingsExtension::on_instance_created(const XrInstance p_instance) {
|
||||||
|
if (available) {
|
||||||
|
EXT_INIT_XR_FUNC(xrPerfSettingsSetPerformanceLevelEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenXRPerformanceSettingsExtension::on_event_polled(const XrEventDataBuffer &event) {
|
||||||
|
switch (event.type) {
|
||||||
|
case XR_TYPE_EVENT_DATA_PERF_SETTINGS_EXT: {
|
||||||
|
const XrEventDataPerfSettingsEXT *perf_settings_event = (XrEventDataPerfSettingsEXT *)&event;
|
||||||
|
|
||||||
|
OpenXRInterface::PerfSettingsSubDomain sub_domain = openxr_to_sub_domain(perf_settings_event->subDomain);
|
||||||
|
OpenXRInterface::PerfSettingsNotificationLevel from_level = openxr_to_notification_level(perf_settings_event->fromLevel);
|
||||||
|
OpenXRInterface::PerfSettingsNotificationLevel to_level = openxr_to_notification_level(perf_settings_event->toLevel);
|
||||||
|
|
||||||
|
OpenXRInterface *openxr_interface = OpenXRAPI::get_singleton()->get_xr_interface();
|
||||||
|
|
||||||
|
if (perf_settings_event->domain == XR_PERF_SETTINGS_DOMAIN_CPU_EXT) {
|
||||||
|
openxr_interface->on_cpu_level_changed(sub_domain, from_level, to_level);
|
||||||
|
} else if (perf_settings_event->domain == XR_PERF_SETTINGS_DOMAIN_GPU_EXT) {
|
||||||
|
openxr_interface->on_gpu_level_changed(sub_domain, from_level, to_level);
|
||||||
|
} else {
|
||||||
|
print_error(vformat("OpenXR: no matching performance settings domain for %s", perf_settings_event->domain));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenXRPerformanceSettingsExtension::is_available() {
|
||||||
|
return available;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenXRPerformanceSettingsExtension::set_cpu_level(OpenXRInterface::PerfSettingsLevel p_level) {
|
||||||
|
XrSession session = OpenXRAPI::get_singleton()->get_session();
|
||||||
|
XrPerfSettingsLevelEXT xr_level = level_to_openxr(p_level);
|
||||||
|
|
||||||
|
XrResult result = xrPerfSettingsSetPerformanceLevelEXT(session, XR_PERF_SETTINGS_DOMAIN_CPU_EXT, xr_level);
|
||||||
|
if (XR_FAILED(result)) {
|
||||||
|
print_error(vformat("OpenXR: failed to set CPU performance level [%s]", OpenXRAPI::get_singleton()->get_error_string(result)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenXRPerformanceSettingsExtension::set_gpu_level(OpenXRInterface::PerfSettingsLevel p_level) {
|
||||||
|
XrSession session = OpenXRAPI::get_singleton()->get_session();
|
||||||
|
XrPerfSettingsLevelEXT xr_level = level_to_openxr(p_level);
|
||||||
|
|
||||||
|
XrResult result = xrPerfSettingsSetPerformanceLevelEXT(session, XR_PERF_SETTINGS_DOMAIN_GPU_EXT, xr_level);
|
||||||
|
if (XR_FAILED(result)) {
|
||||||
|
print_error(vformat("OpenXR: failed to set GPU performance level [%s]", OpenXRAPI::get_singleton()->get_error_string(result)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XrPerfSettingsLevelEXT OpenXRPerformanceSettingsExtension::level_to_openxr(OpenXRInterface::PerfSettingsLevel p_level) {
|
||||||
|
switch (p_level) {
|
||||||
|
case OpenXRInterface::PerfSettingsLevel::PERF_SETTINGS_LEVEL_POWER_SAVINGS:
|
||||||
|
return XR_PERF_SETTINGS_LEVEL_POWER_SAVINGS_EXT;
|
||||||
|
break;
|
||||||
|
case OpenXRInterface::PerfSettingsLevel::PERF_SETTINGS_LEVEL_SUSTAINED_LOW:
|
||||||
|
return XR_PERF_SETTINGS_LEVEL_SUSTAINED_LOW_EXT;
|
||||||
|
break;
|
||||||
|
case OpenXRInterface::PerfSettingsLevel::PERF_SETTINGS_LEVEL_SUSTAINED_HIGH:
|
||||||
|
return XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT;
|
||||||
|
case OpenXRInterface::PerfSettingsLevel::PERF_SETTINGS_LEVEL_BOOST:
|
||||||
|
return XR_PERF_SETTINGS_LEVEL_BOOST_EXT;
|
||||||
|
default:
|
||||||
|
print_error("Invalid performance settings level.");
|
||||||
|
return XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenXRInterface::PerfSettingsSubDomain OpenXRPerformanceSettingsExtension::openxr_to_sub_domain(XrPerfSettingsSubDomainEXT p_sub_domain) {
|
||||||
|
switch (p_sub_domain) {
|
||||||
|
case XR_PERF_SETTINGS_SUB_DOMAIN_COMPOSITING_EXT:
|
||||||
|
return OpenXRInterface::PerfSettingsSubDomain::PERF_SETTINGS_SUB_DOMAIN_COMPOSITING;
|
||||||
|
case XR_PERF_SETTINGS_SUB_DOMAIN_RENDERING_EXT:
|
||||||
|
return OpenXRInterface::PerfSettingsSubDomain::PERF_SETTINGS_SUB_DOMAIN_RENDERING;
|
||||||
|
case XR_PERF_SETTINGS_SUB_DOMAIN_THERMAL_EXT:
|
||||||
|
return OpenXRInterface::PerfSettingsSubDomain::PERF_SETTINGS_SUB_DOMAIN_THERMAL;
|
||||||
|
default:
|
||||||
|
print_error("Invalid performance settings sub domain.");
|
||||||
|
return OpenXRInterface::PerfSettingsSubDomain::PERF_SETTINGS_SUB_DOMAIN_COMPOSITING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenXRInterface::PerfSettingsNotificationLevel OpenXRPerformanceSettingsExtension::openxr_to_notification_level(XrPerfSettingsNotificationLevelEXT p_notification_level) {
|
||||||
|
switch (p_notification_level) {
|
||||||
|
case XR_PERF_SETTINGS_NOTIF_LEVEL_NORMAL_EXT:
|
||||||
|
return OpenXRInterface::PerfSettingsNotificationLevel::PERF_SETTINGS_NOTIF_LEVEL_NORMAL;
|
||||||
|
case XR_PERF_SETTINGS_NOTIF_LEVEL_WARNING_EXT:
|
||||||
|
return OpenXRInterface::PerfSettingsNotificationLevel::PERF_SETTINGS_NOTIF_LEVEL_WARNING;
|
||||||
|
case XR_PERF_SETTINGS_NOTIF_LEVEL_IMPAIRED_EXT:
|
||||||
|
return OpenXRInterface::PerfSettingsNotificationLevel::PERF_SETTINGS_NOTIF_LEVEL_IMPAIRED;
|
||||||
|
default:
|
||||||
|
print_error("Invalid performance settings notification level.");
|
||||||
|
return OpenXRInterface::PerfSettingsNotificationLevel::PERF_SETTINGS_NOTIF_LEVEL_NORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/**************************************************************************/
|
||||||
|
/* openxr_performance_settings_extension.h */
|
||||||
|
/**************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/**************************************************************************/
|
||||||
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* */
|
||||||
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
|
/* a copy of this software and associated documentation files (the */
|
||||||
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
|
/* the following conditions: */
|
||||||
|
/* */
|
||||||
|
/* The above copyright notice and this permission notice shall be */
|
||||||
|
/* included in all copies or substantial portions of the Software. */
|
||||||
|
/* */
|
||||||
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
/**************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../openxr_interface.h"
|
||||||
|
#include "../util.h"
|
||||||
|
#include "openxr_extension_wrapper.h"
|
||||||
|
|
||||||
|
class OpenXRPerformanceSettingsExtension : public OpenXRExtensionWrapper {
|
||||||
|
public:
|
||||||
|
static OpenXRPerformanceSettingsExtension *get_singleton();
|
||||||
|
|
||||||
|
OpenXRPerformanceSettingsExtension();
|
||||||
|
virtual ~OpenXRPerformanceSettingsExtension() override;
|
||||||
|
|
||||||
|
virtual HashMap<String, bool *> get_requested_extensions() override;
|
||||||
|
|
||||||
|
virtual void on_instance_created(const XrInstance p_instance) override;
|
||||||
|
virtual bool on_event_polled(const XrEventDataBuffer &event) override;
|
||||||
|
|
||||||
|
bool is_available();
|
||||||
|
|
||||||
|
void set_cpu_level(OpenXRInterface::PerfSettingsLevel p_level);
|
||||||
|
void set_gpu_level(OpenXRInterface::PerfSettingsLevel p_level);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static OpenXRPerformanceSettingsExtension *singleton;
|
||||||
|
|
||||||
|
bool available = false;
|
||||||
|
|
||||||
|
XrPerfSettingsLevelEXT level_to_openxr(OpenXRInterface::PerfSettingsLevel p_level);
|
||||||
|
OpenXRInterface::PerfSettingsSubDomain openxr_to_sub_domain(XrPerfSettingsSubDomainEXT p_sub_domain);
|
||||||
|
OpenXRInterface::PerfSettingsNotificationLevel openxr_to_notification_level(XrPerfSettingsNotificationLevelEXT p_notification_level);
|
||||||
|
|
||||||
|
EXT_PROTO_XRRESULT_FUNC3(xrPerfSettingsSetPerformanceLevelEXT, (XrSession), session, (XrPerfSettingsDomainEXT), domain, (XrPerfSettingsLevelEXT), level)
|
||||||
|
};
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "extensions/openxr_eye_gaze_interaction.h"
|
#include "extensions/openxr_eye_gaze_interaction.h"
|
||||||
#include "extensions/openxr_hand_interaction_extension.h"
|
#include "extensions/openxr_hand_interaction_extension.h"
|
||||||
|
#include "extensions/openxr_performance_settings_extension.h"
|
||||||
#include "servers/rendering/renderer_compositor.h"
|
#include "servers/rendering/renderer_compositor.h"
|
||||||
|
|
||||||
#include <openxr/openxr.h>
|
#include <openxr/openxr.h>
|
||||||
@@ -50,6 +51,9 @@ void OpenXRInterface::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("pose_recentered"));
|
ADD_SIGNAL(MethodInfo("pose_recentered"));
|
||||||
ADD_SIGNAL(MethodInfo("refresh_rate_changed", PropertyInfo(Variant::FLOAT, "refresh_rate")));
|
ADD_SIGNAL(MethodInfo("refresh_rate_changed", PropertyInfo(Variant::FLOAT, "refresh_rate")));
|
||||||
|
|
||||||
|
ADD_SIGNAL(MethodInfo("cpu_level_changed", PropertyInfo(Variant::INT, "sub_domain"), PropertyInfo(Variant::INT, "from_level"), PropertyInfo(Variant::INT, "to_level")));
|
||||||
|
ADD_SIGNAL(MethodInfo("gpu_level_changed", PropertyInfo(Variant::INT, "sub_domain"), PropertyInfo(Variant::INT, "from_level"), PropertyInfo(Variant::INT, "to_level")));
|
||||||
|
|
||||||
// Display refresh rate
|
// Display refresh rate
|
||||||
ClassDB::bind_method(D_METHOD("get_display_refresh_rate"), &OpenXRInterface::get_display_refresh_rate);
|
ClassDB::bind_method(D_METHOD("get_display_refresh_rate"), &OpenXRInterface::get_display_refresh_rate);
|
||||||
ClassDB::bind_method(D_METHOD("set_display_refresh_rate", "refresh_rate"), &OpenXRInterface::set_display_refresh_rate);
|
ClassDB::bind_method(D_METHOD("set_display_refresh_rate", "refresh_rate"), &OpenXRInterface::set_display_refresh_rate);
|
||||||
@@ -104,6 +108,10 @@ void OpenXRInterface::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("get_vrs_strength"), &OpenXRInterface::get_vrs_strength);
|
ClassDB::bind_method(D_METHOD("get_vrs_strength"), &OpenXRInterface::get_vrs_strength);
|
||||||
ClassDB::bind_method(D_METHOD("set_vrs_strength", "strength"), &OpenXRInterface::set_vrs_strength);
|
ClassDB::bind_method(D_METHOD("set_vrs_strength", "strength"), &OpenXRInterface::set_vrs_strength);
|
||||||
|
|
||||||
|
// Performance settings.
|
||||||
|
ClassDB::bind_method(D_METHOD("set_cpu_level", "level"), &OpenXRInterface::set_cpu_level);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_gpu_level", "level"), &OpenXRInterface::set_gpu_level);
|
||||||
|
|
||||||
ADD_GROUP("Vulkan VRS", "vrs_");
|
ADD_GROUP("Vulkan VRS", "vrs_");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "vrs_min_radius", PROPERTY_HINT_RANGE, "1.0,100.0,1.0"), "set_vrs_min_radius", "get_vrs_min_radius");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "vrs_min_radius", PROPERTY_HINT_RANGE, "1.0,100.0,1.0"), "set_vrs_min_radius", "get_vrs_min_radius");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "vrs_strength", PROPERTY_HINT_RANGE, "0.1,10.0,0.1"), "set_vrs_strength", "get_vrs_strength");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "vrs_strength", PROPERTY_HINT_RANGE, "0.1,10.0,0.1"), "set_vrs_strength", "get_vrs_strength");
|
||||||
@@ -149,6 +157,19 @@ void OpenXRInterface::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(HAND_JOINT_LITTLE_TIP);
|
BIND_ENUM_CONSTANT(HAND_JOINT_LITTLE_TIP);
|
||||||
BIND_ENUM_CONSTANT(HAND_JOINT_MAX);
|
BIND_ENUM_CONSTANT(HAND_JOINT_MAX);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_LEVEL_POWER_SAVINGS);
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_LEVEL_SUSTAINED_LOW);
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_LEVEL_SUSTAINED_HIGH);
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_LEVEL_BOOST);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_SUB_DOMAIN_COMPOSITING);
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_SUB_DOMAIN_RENDERING);
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_SUB_DOMAIN_THERMAL);
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_NOTIF_LEVEL_NORMAL);
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_NOTIF_LEVEL_WARNING);
|
||||||
|
BIND_ENUM_CONSTANT(PERF_SETTINGS_NOTIF_LEVEL_IMPAIRED);
|
||||||
|
|
||||||
BIND_BITFIELD_FLAG(HAND_JOINT_NONE);
|
BIND_BITFIELD_FLAG(HAND_JOINT_NONE);
|
||||||
BIND_BITFIELD_FLAG(HAND_JOINT_ORIENTATION_VALID);
|
BIND_BITFIELD_FLAG(HAND_JOINT_ORIENTATION_VALID);
|
||||||
BIND_BITFIELD_FLAG(HAND_JOINT_ORIENTATION_TRACKED);
|
BIND_BITFIELD_FLAG(HAND_JOINT_ORIENTATION_TRACKED);
|
||||||
@@ -1538,6 +1559,28 @@ RID OpenXRInterface::get_vrs_texture() {
|
|||||||
return xr_vrs.make_vrs_texture(target_size, eye_foci);
|
return xr_vrs.make_vrs_texture(target_size, eye_foci);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenXRInterface::set_cpu_level(PerfSettingsLevel p_level) {
|
||||||
|
OpenXRPerformanceSettingsExtension *performance_settings_ext = OpenXRPerformanceSettingsExtension::get_singleton();
|
||||||
|
if (performance_settings_ext && performance_settings_ext->is_available()) {
|
||||||
|
performance_settings_ext->set_cpu_level(p_level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenXRInterface::set_gpu_level(PerfSettingsLevel p_level) {
|
||||||
|
OpenXRPerformanceSettingsExtension *performance_settings_ext = OpenXRPerformanceSettingsExtension::get_singleton();
|
||||||
|
if (performance_settings_ext && performance_settings_ext->is_available()) {
|
||||||
|
performance_settings_ext->set_gpu_level(p_level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenXRInterface::on_cpu_level_changed(PerfSettingsSubDomain p_sub_domain, PerfSettingsNotificationLevel p_from_level, PerfSettingsNotificationLevel p_to_level) {
|
||||||
|
emit_signal(SNAME("cpu_level_changed"), p_sub_domain, p_from_level, p_to_level);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenXRInterface::on_gpu_level_changed(PerfSettingsSubDomain p_sub_domain, PerfSettingsNotificationLevel p_from_level, PerfSettingsNotificationLevel p_to_level) {
|
||||||
|
emit_signal(SNAME("gpu_level_changed"), p_sub_domain, p_from_level, p_to_level);
|
||||||
|
}
|
||||||
|
|
||||||
OpenXRInterface::OpenXRInterface() {
|
OpenXRInterface::OpenXRInterface() {
|
||||||
openxr_api = OpenXRAPI::get_singleton();
|
openxr_api = OpenXRAPI::get_singleton();
|
||||||
if (openxr_api) {
|
if (openxr_api) {
|
||||||
|
|||||||
@@ -291,6 +291,31 @@ public:
|
|||||||
|
|
||||||
virtual RID get_vrs_texture() override;
|
virtual RID get_vrs_texture() override;
|
||||||
|
|
||||||
|
// Performance settings.
|
||||||
|
enum PerfSettingsLevel {
|
||||||
|
PERF_SETTINGS_LEVEL_POWER_SAVINGS,
|
||||||
|
PERF_SETTINGS_LEVEL_SUSTAINED_LOW,
|
||||||
|
PERF_SETTINGS_LEVEL_SUSTAINED_HIGH,
|
||||||
|
PERF_SETTINGS_LEVEL_BOOST,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum PerfSettingsSubDomain {
|
||||||
|
PERF_SETTINGS_SUB_DOMAIN_COMPOSITING,
|
||||||
|
PERF_SETTINGS_SUB_DOMAIN_RENDERING,
|
||||||
|
PERF_SETTINGS_SUB_DOMAIN_THERMAL,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum PerfSettingsNotificationLevel {
|
||||||
|
PERF_SETTINGS_NOTIF_LEVEL_NORMAL,
|
||||||
|
PERF_SETTINGS_NOTIF_LEVEL_WARNING,
|
||||||
|
PERF_SETTINGS_NOTIF_LEVEL_IMPAIRED,
|
||||||
|
};
|
||||||
|
|
||||||
|
void set_cpu_level(PerfSettingsLevel p_level);
|
||||||
|
void set_gpu_level(PerfSettingsLevel p_level);
|
||||||
|
void on_cpu_level_changed(PerfSettingsSubDomain p_sub_domain, PerfSettingsNotificationLevel p_from_level, PerfSettingsNotificationLevel p_to_level);
|
||||||
|
void on_gpu_level_changed(PerfSettingsSubDomain p_sub_domain, PerfSettingsNotificationLevel p_from_level, PerfSettingsNotificationLevel p_to_level);
|
||||||
|
|
||||||
OpenXRInterface();
|
OpenXRInterface();
|
||||||
~OpenXRInterface();
|
~OpenXRInterface();
|
||||||
};
|
};
|
||||||
@@ -299,4 +324,7 @@ VARIANT_ENUM_CAST(OpenXRInterface::Hand)
|
|||||||
VARIANT_ENUM_CAST(OpenXRInterface::HandMotionRange)
|
VARIANT_ENUM_CAST(OpenXRInterface::HandMotionRange)
|
||||||
VARIANT_ENUM_CAST(OpenXRInterface::HandTrackedSource)
|
VARIANT_ENUM_CAST(OpenXRInterface::HandTrackedSource)
|
||||||
VARIANT_ENUM_CAST(OpenXRInterface::HandJoints)
|
VARIANT_ENUM_CAST(OpenXRInterface::HandJoints)
|
||||||
|
VARIANT_ENUM_CAST(OpenXRInterface::PerfSettingsLevel)
|
||||||
|
VARIANT_ENUM_CAST(OpenXRInterface::PerfSettingsSubDomain)
|
||||||
|
VARIANT_ENUM_CAST(OpenXRInterface::PerfSettingsNotificationLevel)
|
||||||
VARIANT_BITFIELD_CAST(OpenXRInterface::HandJointFlags)
|
VARIANT_BITFIELD_CAST(OpenXRInterface::HandJointFlags)
|
||||||
|
|||||||
@@ -63,6 +63,7 @@
|
|||||||
#include "extensions/openxr_ml2_controller_extension.h"
|
#include "extensions/openxr_ml2_controller_extension.h"
|
||||||
#include "extensions/openxr_mxink_extension.h"
|
#include "extensions/openxr_mxink_extension.h"
|
||||||
#include "extensions/openxr_palm_pose_extension.h"
|
#include "extensions/openxr_palm_pose_extension.h"
|
||||||
|
#include "extensions/openxr_performance_settings_extension.h"
|
||||||
#include "extensions/openxr_pico_controller_extension.h"
|
#include "extensions/openxr_pico_controller_extension.h"
|
||||||
#include "extensions/openxr_valve_analog_threshold_extension.h"
|
#include "extensions/openxr_valve_analog_threshold_extension.h"
|
||||||
#include "extensions/openxr_visibility_mask_extension.h"
|
#include "extensions/openxr_visibility_mask_extension.h"
|
||||||
@@ -139,6 +140,7 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) {
|
|||||||
OpenXRAPI::register_extension_wrapper(memnew(OpenXRHandInteractionExtension));
|
OpenXRAPI::register_extension_wrapper(memnew(OpenXRHandInteractionExtension));
|
||||||
OpenXRAPI::register_extension_wrapper(memnew(OpenXRMxInkExtension));
|
OpenXRAPI::register_extension_wrapper(memnew(OpenXRMxInkExtension));
|
||||||
OpenXRAPI::register_extension_wrapper(memnew(OpenXRVisibilityMaskExtension));
|
OpenXRAPI::register_extension_wrapper(memnew(OpenXRVisibilityMaskExtension));
|
||||||
|
OpenXRAPI::register_extension_wrapper(memnew(OpenXRPerformanceSettingsExtension));
|
||||||
|
|
||||||
// register gated extensions
|
// register gated extensions
|
||||||
if (int(GLOBAL_GET("xr/openxr/extensions/debug_utils")) > 0) {
|
if (int(GLOBAL_GET("xr/openxr/extensions/debug_utils")) > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user