Skip to content

Commit 673f161

Browse files
committed
Merge pull request #87630 from dsnopek/openxr-passthrough-from-gdextension
OpenXR: Allow moving vendor passthrough extensions to GDExtension
2 parents 0465027 + e74a0f4 commit 673f161

14 files changed

+155
-497
lines changed

doc/classes/XRInterface.xml

+8-4
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,18 @@
102102
Is [code]true[/code] if this interface has been initialized.
103103
</description>
104104
</method>
105-
<method name="is_passthrough_enabled">
105+
<method name="is_passthrough_enabled" is_deprecated="true">
106106
<return type="bool" />
107107
<description>
108108
Is [code]true[/code] if passthrough is enabled.
109+
[i]Deprecated.[/i] Check if [member environment_blend_mode] is [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND], instead.
109110
</description>
110111
</method>
111-
<method name="is_passthrough_supported">
112+
<method name="is_passthrough_supported" is_deprecated="true">
112113
<return type="bool" />
113114
<description>
114115
Is [code]true[/code] if this interface supports passthrough.
116+
[i]Deprecated.[/i] Check that [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND] is supported using [method get_supported_environment_blend_modes], instead.
115117
</description>
116118
</method>
117119
<method name="set_environment_blend_mode">
@@ -144,17 +146,19 @@
144146
[b]Note:[/b] Changing this after the interface has already been initialized can be jarring for the player, so it's recommended to recenter on the HMD with [method XRServer.center_on_hmd] (if switching to [constant XRInterface.XR_PLAY_AREA_STAGE]) or make the switch during a scene change.
145147
</description>
146148
</method>
147-
<method name="start_passthrough">
149+
<method name="start_passthrough" is_deprecated="true">
148150
<return type="bool" />
149151
<description>
150152
Starts passthrough, will return [code]false[/code] if passthrough couldn't be started.
151153
[b]Note:[/b] The viewport used for XR must have a transparent background, otherwise passthrough may not properly render.
154+
[i]Deprecated.[/i] Set the [member environment_blend_mode] to [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND], instead.
152155
</description>
153156
</method>
154-
<method name="stop_passthrough">
157+
<method name="stop_passthrough" is_deprecated="true">
155158
<return type="void" />
156159
<description>
157160
Stops passthrough.
161+
[i]Deprecated.[/i] Set the [member environment_blend_mode] to [constant XRInterface.XR_ENV_BLEND_MODE_OPAQUE], instead.
158162
</description>
159163
</method>
160164
<method name="supports_play_area_mode">

modules/openxr/doc_classes/OpenXRAPIExtension.xml

+38
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@
7575
Returns the id of the system, which is a [url=https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrSystemId.html]XrSystemId[/url] cast to an integer.
7676
</description>
7777
</method>
78+
<method name="is_environment_blend_mode_alpha_supported">
79+
<return type="int" enum="OpenXRAPIExtension.OpenXRAlphaBlendModeSupport" />
80+
<description>
81+
Returns [enum OpenXRAPIExtension.OpenXRAlphaBlendModeSupport] denoting if [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND] is really support, emulated or not supported at all.
82+
</description>
83+
</method>
7884
<method name="is_initialized">
7985
<return type="bool" />
8086
<description>
@@ -94,13 +100,34 @@
94100
Returns [code]true[/code] if OpenXR is enabled.
95101
</description>
96102
</method>
103+
<method name="register_composition_layer_provider">
104+
<return type="void" />
105+
<param index="0" name="extension" type="OpenXRExtensionWrapperExtension" />
106+
<description>
107+
Registers the given extension as a composition layer provider.
108+
</description>
109+
</method>
110+
<method name="set_emulate_environment_blend_mode_alpha_blend">
111+
<return type="void" />
112+
<param index="0" name="enabled" type="bool" />
113+
<description>
114+
If set to [code]true[/code], an OpenXR extension is loaded which is capable of emulating the [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND] blend mode.
115+
</description>
116+
</method>
97117
<method name="transform_from_pose">
98118
<return type="Transform3D" />
99119
<param index="0" name="pose" type="const void*" />
100120
<description>
101121
Creates a [Transform3D] from an [url=https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrPosef.html]XrPosef[/url].
102122
</description>
103123
</method>
124+
<method name="unregister_composition_layer_provider">
125+
<return type="void" />
126+
<param index="0" name="extension" type="OpenXRExtensionWrapperExtension" />
127+
<description>
128+
Unregisters the given extension as a composition layer provider.
129+
</description>
130+
</method>
104131
<method name="xr_result">
105132
<return type="bool" />
106133
<param index="0" name="result" type="int" />
@@ -111,4 +138,15 @@
111138
</description>
112139
</method>
113140
</methods>
141+
<constants>
142+
<constant name="OPENXR_ALPHA_BLEND_MODE_SUPPORT_NONE" value="0" enum="OpenXRAlphaBlendModeSupport">
143+
Means that [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND] isn't supported at all.
144+
</constant>
145+
<constant name="OPENXR_ALPHA_BLEND_MODE_SUPPORT_REAL" value="1" enum="OpenXRAlphaBlendModeSupport">
146+
Means that [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND] is really supported.
147+
</constant>
148+
<constant name="OPENXR_ALPHA_BLEND_MODE_SUPPORT_EMULATING" value="2" enum="OpenXRAlphaBlendModeSupport">
149+
Means that [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND] is emulated.
150+
</constant>
151+
</constants>
114152
</class>

modules/openxr/doc_classes/OpenXRExtensionWrapperExtension.xml

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
<tutorials>
1010
</tutorials>
1111
<methods>
12+
<method name="_get_composition_layer" qualifiers="virtual">
13+
<return type="int" />
14+
<description>
15+
Returns a pointer to a [code]XrCompositionLayerBaseHeader[/code] struct to provide a composition layer. This will only be called if the extension previously registered itself with [method OpenXRAPIExtension.register_composition_layer_provider].
16+
</description>
17+
</method>
1218
<method name="_get_requested_extensions" qualifiers="virtual">
1319
<return type="Dictionary" />
1420
<description>

modules/openxr/extensions/openxr_extension_wrapper_extension.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ void OpenXRExtensionWrapperExtension::_bind_methods() {
3939
GDVIRTUAL_BIND(_set_session_create_and_get_next_pointer, "next_pointer");
4040
GDVIRTUAL_BIND(_set_swapchain_create_info_and_get_next_pointer, "next_pointer");
4141
GDVIRTUAL_BIND(_set_hand_joint_locations_and_get_next_pointer, "hand_index", "next_pointer");
42+
GDVIRTUAL_BIND(_get_composition_layer);
4243
GDVIRTUAL_BIND(_on_register_metadata);
4344
GDVIRTUAL_BIND(_on_before_instance_created);
4445
GDVIRTUAL_BIND(_on_instance_created, "instance");
@@ -128,6 +129,16 @@ void *OpenXRExtensionWrapperExtension::set_hand_joint_locations_and_get_next_poi
128129
return nullptr;
129130
}
130131

132+
XrCompositionLayerBaseHeader *OpenXRExtensionWrapperExtension::get_composition_layer() {
133+
uint64_t pointer;
134+
135+
if (GDVIRTUAL_CALL(_get_composition_layer, pointer)) {
136+
return reinterpret_cast<XrCompositionLayerBaseHeader *>(pointer);
137+
}
138+
139+
return nullptr;
140+
}
141+
131142
void OpenXRExtensionWrapperExtension::on_register_metadata() {
132143
GDVIRTUAL_CALL(_on_register_metadata);
133144
}

modules/openxr/extensions/openxr_extension_wrapper_extension.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include "core/os/thread_safe.h"
4040
#include "core/variant/native_ptr.h"
4141

42-
class OpenXRExtensionWrapperExtension : public Object, OpenXRExtensionWrapper {
42+
class OpenXRExtensionWrapperExtension : public Object, public OpenXRExtensionWrapper, public OpenXRCompositionLayerProvider {
4343
GDCLASS(OpenXRExtensionWrapperExtension, Object);
4444

4545
protected:
@@ -59,13 +59,15 @@ class OpenXRExtensionWrapperExtension : public Object, OpenXRExtensionWrapper {
5959
virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override;
6060
virtual void *set_swapchain_create_info_and_get_next_pointer(void *p_next_pointer) override;
6161
virtual void *set_hand_joint_locations_and_get_next_pointer(int p_hand_index, void *p_next_pointer) override;
62+
virtual XrCompositionLayerBaseHeader *get_composition_layer() override;
6263

6364
//TODO workaround as GDExtensionPtr<void> return type results in build error in godot-cpp
6465
GDVIRTUAL1R(uint64_t, _set_system_properties_and_get_next_pointer, GDExtensionPtr<void>);
6566
GDVIRTUAL1R(uint64_t, _set_instance_create_info_and_get_next_pointer, GDExtensionPtr<void>);
6667
GDVIRTUAL1R(uint64_t, _set_session_create_and_get_next_pointer, GDExtensionPtr<void>);
6768
GDVIRTUAL1R(uint64_t, _set_swapchain_create_info_and_get_next_pointer, GDExtensionPtr<void>);
6869
GDVIRTUAL2R(uint64_t, _set_hand_joint_locations_and_get_next_pointer, int, GDExtensionPtr<void>);
70+
GDVIRTUAL0R(uint64_t, _get_composition_layer);
6971

7072
virtual void on_register_metadata() override;
7173
virtual void on_before_instance_created() override;

0 commit comments

Comments
 (0)