Skip to content

Commit 3d10bf8

Browse files
committed
OpenXR: Add support for Foveated Inset
1 parent b56ca02 commit 3d10bf8

19 files changed

Lines changed: 879 additions & 44 deletions

doc/classes/ProjectSettings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3540,6 +3540,9 @@
35403540
<member name="xr/openxr/binding_modifiers/dpad_binding" type="bool" setter="" getter="" default="false">
35413541
If [code]true[/code], enables the D-pad binding modifier if supported by the XR runtime.
35423542
</member>
3543+
<member name="xr/openxr/create_default_foveated_inset_viewport" type="bool" setter="" getter="" default="true">
3544+
If [code]true[/code], and [member xr/openxr/view_configuration] is set to [code]Stereo with Foveated Inset[/code], and foveated inset is supported, Godot will add and configure an [OpenXRFoveatedInsetViewport] node for rendering the foveated inset.
3545+
</member>
35433546
<member name="xr/openxr/default_action_map" type="String" setter="" getter="" default="&quot;res://openxr_action_map.tres&quot;">
35443547
Action map configuration to load by default.
35453548
</member>

main/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2848,13 +2848,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
28482848
GLOBAL_DEF(PropertyInfo(Variant::STRING, "xr/openxr/target_api_version"), "");
28492849
GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "xr/openxr/default_action_map", PROPERTY_HINT_FILE, "*.tres"), "res://openxr_action_map.tres");
28502850
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/form_factor", PROPERTY_HINT_ENUM, "Head Mounted,Handheld"), "0");
2851-
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/view_configuration", PROPERTY_HINT_ENUM, "Mono,Stereo"), "1"); // "Mono,Stereo,Quad,Observer"
2851+
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/view_configuration", PROPERTY_HINT_ENUM, "Mono,Stereo,Stereo with Foveated Inset"), "1");
28522852
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/reference_space", PROPERTY_HINT_ENUM, "Local,Stage,Local Floor"), "1");
28532853
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/environment_blend_mode", PROPERTY_HINT_ENUM, "Opaque,Additive,Alpha"), "0");
28542854
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/foveation_level", PROPERTY_HINT_ENUM, "Off,Low,Medium,High"), "0");
28552855
GLOBAL_DEF_BASIC("xr/openxr/foveation_dynamic", false);
28562856
GLOBAL_DEF_BASIC("xr/openxr/foveation_eye_tracked", true);
28572857
GLOBAL_DEF_BASIC("xr/openxr/foveation_with_subsampled_images", true);
2858+
GLOBAL_DEF_BASIC("xr/openxr/create_default_foveated_inset_viewport", true);
28582859

28592860
GLOBAL_DEF_BASIC("xr/openxr/submit_depth_buffer", false);
28602861
GLOBAL_DEF_BASIC("xr/openxr/startup_alert", true);

modules/openxr/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def get_doc_classes():
2727
"OpenXRIPBinding",
2828
"OpenXRHand",
2929
"OpenXRVisibilityMask",
30+
"OpenXRFoveatedInsetViewport",
3031
"OpenXRCompositionLayer",
3132
"OpenXRCompositionLayerQuad",
3233
"OpenXRCompositionLayerCylinder",

modules/openxr/doc_classes/OpenXRAPIExtension.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
Returns the predicted display timing for the current frame.
104104
</description>
105105
</method>
106+
<method name="get_primary_view_count" qualifiers="const">
107+
<return type="int" />
108+
<description>
109+
Returns the view count for the primary viewport.
110+
</description>
111+
</method>
106112
<method name="get_projection_layer">
107113
<return type="int" />
108114
<description>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="OpenXRFoveatedInsetViewport" inherits="SubViewport" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
3+
<brief_description>
4+
This viewport is used for rendering our foveated inset.
5+
</brief_description>
6+
<description>
7+
This viewport is used for rendering our foveated inset. When foveated inset rendering is supported OpenXR will create and configure this viewport correctly and use its output. The viewport will be available after OpenXR reaches the "begun" state. You can access it by calling [code]get_tree().get_root().get_node("OpenXRFoveatedInsetViewport")[/code] at this time.
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
<methods>
12+
<method name="get_xr_camera3d" qualifiers="const">
13+
<return type="XRCamera3D" />
14+
<description>
15+
Returns the [XRCamera3D] node used for rendering the foveated inset.
16+
</description>
17+
</method>
18+
<method name="get_xr_origin3d" qualifiers="const">
19+
<return type="XROrigin3D" />
20+
<description>
21+
Returns the [XROrigin3D] node used for tracking the foveated inset. Our built-in logic handles positioning this node. It will copy the position and orientation of the [XROrigin3D] node marked as current.
22+
</description>
23+
</method>
24+
</methods>
25+
<members>
26+
<member name="process_priority" type="int" setter="set_process_priority" getter="get_process_priority" overrides="Node" default="99999" />
27+
<member name="render_target_update_mode" type="int" setter="set_update_mode" getter="get_update_mode" overrides="SubViewport" enum="SubViewport.UpdateMode" default="0" />
28+
</members>
29+
</class>

modules/openxr/doc_classes/OpenXRInterface.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
Returns a list of action sets registered with Godot (loaded from the action map at runtime).
1818
</description>
1919
</method>
20+
<method name="get_active_view_configuration" qualifiers="const">
21+
<return type="int" enum="OpenXRInterface.ViewConfiguration" />
22+
<description>
23+
Gets the active view configuration.
24+
[b]Note:[/b] This will only return a valid value after OpenXR is initialized.
25+
</description>
26+
</method>
2027
<method name="get_available_display_refresh_rates" qualifiers="const">
2128
<return type="Array" />
2229
<description>
@@ -297,6 +304,21 @@
297304
<constant name="SESSION_STATE_EXITING" value="8" enum="SessionState">
298305
The OpenXR instance is about to be destroyed and we're exiting. [signal instance_exiting] is emitted when we change to this state.
299306
</constant>
307+
<constant name="VIEW_CONFIGURATION_MONO" value="0" enum="ViewConfiguration">
308+
Our XR output configuration is monoscopic.
309+
</constant>
310+
<constant name="VIEW_CONFIGURATION_STEREO" value="1" enum="ViewConfiguration">
311+
Our XR output configuration is stereoscopic.
312+
</constant>
313+
<constant name="VIEW_CONFIGURATION_STEREO_WITH_INSET" value="2" enum="ViewConfiguration">
314+
Our XR output configuration is stereoscopic with an additional foveated inset render.
315+
</constant>
316+
<constant name="VIEW_CONFIGURATION_UNSET" value="254" enum="ViewConfiguration">
317+
Our XR output configuration has not yet been determined.
318+
</constant>
319+
<constant name="VIEW_CONFIGURATION_UNKNOWN" value="255" enum="ViewConfiguration">
320+
Our XR output configuration is unknown.
321+
</constant>
300322
<constant name="HAND_LEFT" value="0" enum="Hand">
301323
Left hand.
302324
</constant>

modules/openxr/extensions/openxr_extension_wrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ class OpenXRExtensionWrapper : public Object {
154154
virtual void on_main_swapchains_created(); // `on_main_swapchains_created` is called right after our main swapchains are (re)created.
155155
virtual void on_pre_draw_viewport(RID p_render_target); // `on_pre_draw_viewport` is called right before we start rendering this viewport
156156
virtual void on_post_draw_viewport(RID p_render_target); // `on_port_draw_viewport` is called right after we start rendering this viewport (note that on Vulkan draw commands may only be queued)
157+
virtual void on_post_render() {} // `on_post_render` is called right before we submit our XR viewports to the XR compositor.
157158

158159
GDVIRTUAL1(_on_register_metadata, OpenXRInteractionProfileMetadata *);
159160
GDVIRTUAL0(_on_before_instance_created);

0 commit comments

Comments
 (0)