Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions modules/openxr/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if env["builtin_openxr"]:
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_jsoncpp_dir + "json_value.cpp")
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_jsoncpp_dir + "json_writer.cpp")

# add in load
# add in loader
if env["platform"] != "android":
# On Android the openxr_loader is provided by separate plugins for each device
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should it be changed to?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well after this PR, the loader will no longer be provided by separate plugins.

# Build the engine using object files
Expand All @@ -93,7 +93,6 @@ if env["builtin_openxr"]:
env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/loader_properties.cpp")
env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/manifest_file.cpp")
env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/runtime_interface.cpp")
env_thirdparty.add_source_files(khrloader_obj, thirdparty_dir + "/src/loader/xr_generated_loader.cpp")
env.modules_sources += khrloader_obj

env.modules_sources += thirdparty_obj
Expand Down
127 changes: 127 additions & 0 deletions modules/openxr/editor/openxr_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,117 @@
#include "editor/editor_node.h"
#include "editor/gui/editor_bottom_panel.h"
#include "editor/settings/editor_command_palette.h"
#include "platform/android/export/export_plugin.h"

#include <openxr/openxr.h>

////////////////////////////////////////////////////////////////////////////
// OpenXRExportPlugin

bool OpenXRExportPlugin::supports_platform(const Ref<EditorExportPlatform> &p_export_platform) const {
return p_export_platform->is_class(EditorExportPlatformAndroid::get_class_static());
}

bool OpenXRExportPlugin::is_openxr_mode() const {
int xr_mode_index = get_option("xr_features/xr_mode");

return xr_mode_index == XR_MODE_OPENXR;
}

String OpenXRExportPlugin::_get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const {
if (!supports_platform(p_export_platform)) {
return String();
}

bool gradle_build = get_option("gradle_build/use_gradle_build");
if (is_openxr_mode() && !gradle_build) {
return "\"Use Gradle Build\" must be enabled when xr_mode is set to \"OpenXR\".";
}

return String();
}

PackedStringArray OpenXRExportPlugin::get_android_dependencies(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const {
PackedStringArray ret;

if (!supports_platform(p_export_platform)) {
return ret;
}

if (is_openxr_mode()) {
// Loader is always identified by the full API version even if we're initializing for OpenXR 1.0.
int major = XR_VERSION_MAJOR(XR_CURRENT_API_VERSION);
int minor = XR_VERSION_MINOR(XR_CURRENT_API_VERSION);
int patch = XR_VERSION_PATCH(XR_CURRENT_API_VERSION);
String openxr_loader = "org.khronos.openxr:openxr_loader_for_android:" + String::num_int64(major) + "." + String::num_int64(minor) + "." + String::num_int64(patch);

ret.push_back(openxr_loader);
}

return ret;
}

PackedStringArray OpenXRExportPlugin::_get_export_features(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const {
PackedStringArray features;

if (!supports_platform(p_export_platform) || !is_openxr_mode()) {
return features;
}

// Placeholder for now

return features;
}

String OpenXRExportPlugin::get_android_manifest_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const {
String contents;

if (!supports_platform(p_export_platform) || !is_openxr_mode()) {
return contents;
}

contents += R"n(
<uses-permission android:name="org.khronos.openxr.permission.OPENXR" />
<uses-permission android:name="org.khronos.openxr.permission.OPENXR_SYSTEM" />

<queries>
<provider android:authorities="org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker" />

<intent>
<action android:name="org.khronos.openxr.OpenXRRuntimeService" />
</intent>
<intent>
<action android:name="org.khronos.openxr.OpenXRApiLayerService" />
</intent>

</queries>

<uses-feature android:name="android.hardware.vr.headtracking" android:required="false" android:version="1" />
)n";

return contents;
}

String OpenXRExportPlugin::get_android_manifest_activity_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const {
String contents;

if (!supports_platform(p_export_platform) || !is_openxr_mode()) {
return contents;
}

contents += R"n(
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />
</intent-filter>
)n";

return contents;
}

////////////////////////////////////////////////////////////////////////////
// OpenXREditorPlugin

void OpenXREditorPlugin::edit(Object *p_node) {
if (Object::cast_to<OpenXRActionMap>(p_node)) {
Expand Down Expand Up @@ -64,3 +175,19 @@ OpenXREditorPlugin::OpenXREditorPlugin() {
add_control_to_container(CONTAINER_TOOLBAR, select_runtime);
#endif
}

void OpenXREditorPlugin::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
// Initialize our export plugin
openxr_export_plugin.instantiate();
add_export_plugin(openxr_export_plugin);
} break;
case NOTIFICATION_EXIT_TREE: {
// Clean up our export plugin
remove_export_plugin(openxr_export_plugin);

openxr_export_plugin.unref();
}
}
}
25 changes: 25 additions & 0 deletions modules/openxr/editor/openxr_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,27 @@
#include "openxr_binding_modifier_editor.h"
#include "openxr_select_runtime.h"

#include "editor/export/editor_export_plugin.h"
#include "editor/plugins/editor_plugin.h"

class OpenXRExportPlugin : public EditorExportPlugin {
GDCLASS(OpenXRExportPlugin, EditorExportPlugin)

public:
virtual bool supports_platform(const Ref<EditorExportPlatform> &p_export_platform) const override;
virtual PackedStringArray get_android_dependencies(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const override;

protected:
virtual String _get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const override;

virtual PackedStringArray _get_export_features(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const override;
virtual String get_android_manifest_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const override;
virtual String get_android_manifest_activity_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const override;

private:
bool is_openxr_mode() const;
};

class OpenXREditorPlugin : public EditorPlugin {
GDCLASS(OpenXREditorPlugin, EditorPlugin);

Expand All @@ -53,4 +72,10 @@ class OpenXREditorPlugin : public EditorPlugin {
virtual void make_visible(bool p_visible) override;

OpenXREditorPlugin();

protected:
void _notification(int p_what);

private:
Ref<OpenXRExportPlugin> openxr_export_plugin;
};
2 changes: 2 additions & 0 deletions platform/android/java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ android {
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libopenxr_loader.so'
pickFirst 'lib/x86_64/libopenxr_loader.so'
}

signingConfigs {
Expand Down
1 change: 1 addition & 0 deletions platform/android/java/app/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ext.versions = [
// Also update 'platform/android/detect.py#get_ndk_version()' when this is updated.
ndkVersion : '28.1.13356709',
splashscreenVersion: '1.0.1',
openxrLoaderVersion: '1.1.53',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to describe this should match the XR_CURRENT_API_VERSION.

openxrVendorsVersion: '4.1.1-stable',
junitVersion : '1.3.0',
espressoCoreVersion: '3.7.0',
Expand Down
5 changes: 5 additions & 0 deletions platform/android/java/editor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ android {
keepDebugSymbols += '**/*.so'
}
}

pickFirst 'lib/arm64-v8a/libopenxr_loader.so'
pickFirst 'lib/x86_64/libopenxr_loader.so'
Comment on lines +162 to +163
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to describe why we're using pickFirst for the openxr loader.

}

flavorDimensions = ["android_distribution"]
Expand Down Expand Up @@ -203,6 +206,8 @@ dependencies {
implementation "androidx.constraintlayout:constraintlayout:2.2.1"
implementation "org.bouncycastle:bcprov-jdk15to18:1.78"

implementation "org.khronos.openxr:openxr_loader_for_android:$versions.openxrLoaderVersion"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we only include these for the horizonos/picoos configs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, implementation covers all the flavors.


// Meta dependencies
horizonosImplementation "org.godotengine:godot-openxr-vendors-meta:$versions.openxrVendorsVersion"
// Pico dependencies
Expand Down
2 changes: 2 additions & 0 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,8 @@ Exclude:
`*.{def,expsym,in,json,map,pom,rc,txt}`
- All dotfiles

Additional:
- Update `openxrLoaderVersion` in `platform/android/java/app/config.gradle`

## pcre2

Expand Down