1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Adding support for the OpenXR futures extension

This commit is contained in:
Bastiaan Olij
2025-01-23 17:50:07 +11:00
parent 28102e6682
commit d6312188d7
42 changed files with 987 additions and 366 deletions

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="OpenXRExtensionWrapper" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Abstract wrapper class for OpenXR extension classes.
</brief_description>
<description>
This abstract wrapper class is used for all wrapper classes that implement the various OpenXR extensions.
</description>
<tutorials>
</tutorials>
</class>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="OpenXRExtensionWrapperExtension" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<class name="OpenXRExtensionWrapperExtension" inherits="OpenXRExtensionWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Allows clients to implement OpenXR extensions with GDExtension.
</brief_description>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="OpenXRFutureExtension" inherits="OpenXRExtensionWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
The OpenXR Future extension allows for asynchronous APIs to be used.
</brief_description>
<description>
This is a support extension in OpenXR that allows other OpenXR extensions to start asynchronous functions and get a callback after this function finishes. It is not intended for consumption within GDScript but can be accessed from GDExtension.
</description>
<tutorials>
</tutorials>
<methods>
<method name="cancel_future">
<return type="void" />
<param index="0" name="future" type="int" />
<description>
Cancels an in-progress future. [param future] must be an [code]XrFutureEXT[/code] value previously returned by an API that started an asynchronous function.
</description>
</method>
<method name="is_active" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if futures are available in the OpenXR runtime used. This function will only return a usable result after OpenXR has been initialized.
</description>
</method>
<method name="register_future">
<return type="OpenXRFutureResult" />
<param index="0" name="future" type="int" />
<param index="1" name="on_success" type="Callable" default="Callable()" />
<description>
Register an OpenXR Future object so we monitor for completion. [param future] must be an [code]XrFutureEXT[/code] value previously returned by an API that started an asynchronous function.
You can optionally specify [param on_success], it will be invoked on successful completion of the future.
Or you can use the returned [OpenXRFutureResult] object to [code]await[/code] its [signal OpenXRFutureResult.completed] signal.
[codeblock]
var future_result = OpenXRFutureExtension.register_future(future)
await future_result.completed
if future_result.get_status() == OpenXRFutureResult.RESULT_FINISHED:
# Handle your success
pass
[/codeblock]
</description>
</method>
</methods>
</class>

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="OpenXRFutureResult" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Result object tracking the asynchronous result of an OpenXR Future object.
</brief_description>
<description>
Result object tracking the asynchronous result of an OpenXR Future object, you can use this object to track the result status.
</description>
<tutorials>
</tutorials>
<methods>
<method name="cancel_future">
<return type="void" />
<description>
Cancel this future, this will interrupt and stop the asynchronous function.
</description>
</method>
<method name="get_future" qualifiers="const">
<return type="int" />
<description>
Return the [code]XrFutureEXT[/code] value this result relates to.
</description>
</method>
<method name="get_status" qualifiers="const">
<return type="int" enum="OpenXRFutureResult.ResultStatus" />
<description>
Returns the status of this result.
</description>
</method>
</methods>
<signals>
<signal name="completed">
<param index="0" name="result" type="OpenXRFutureResult" />
<description>
Emitted when the asynchronous function is finished or has been cancelled.
</description>
</signal>
</signals>
<constants>
<constant name="RESULT_RUNNING" value="0" enum="ResultStatus">
The asynchronous function is running.
</constant>
<constant name="RESULT_FINISHED" value="1" enum="ResultStatus">
The asynchronous function has finished.
</constant>
<constant name="RESULT_CANCELLED" value="2" enum="ResultStatus">
The asynchronous function has been cancelled.
</constant>
</constants>
</class>