forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71d1ab5
commit 23be0da
Showing
44 changed files
with
5,478 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env python | ||
|
||
Import("env") | ||
|
||
is_supported_on_platform = True | ||
if env["platform"] == "android": | ||
# may need to set OPENXR_ANDROID_VERSION_SUFFIX | ||
env.AppendUnique(CPPDEFINES=["XR_OS_ANDROID", "XR_USE_PLATFORM_ANDROID"]) | ||
|
||
# may need to include java parts of the openxr loader | ||
elif env["platform"] == "linuxbsd": | ||
env.AppendUnique(CPPDEFINES=["XR_OS_LINUX", "XR_USE_PLATFORM_XLIB"]) | ||
elif env["platform"] == "windows": | ||
env.AppendUnique(CPPDEFINES=["XR_OS_WINDOWS", "NOMINMAX", "XR_USE_PLATFORM_WIN32", "HAVE_SECURE_GETENV"]) | ||
else: | ||
# don't build anything, OpenXR not supported on this platform | ||
is_supported_on_platform = False | ||
|
||
if is_supported_on_platform: | ||
thirdparty_obj = [] | ||
thirdparty_dir = "#thirdparty/openxr" | ||
|
||
# Use bundled Vulkan headers | ||
env.Prepend( | ||
CPPPATH=[ | ||
thirdparty_dir, | ||
thirdparty_dir + "/include", | ||
thirdparty_dir + "/src", | ||
thirdparty_dir + "/src/common", | ||
thirdparty_dir + "/src/external/jsoncpp/include", | ||
thirdparty_dir + "/src/loader", | ||
] | ||
) | ||
|
||
# may need to check and set: | ||
# - XR_USE_TIMESPEC | ||
|
||
# need to redo this to something more elegant | ||
|
||
env_thirdparty = env.Clone() | ||
env_thirdparty.disable_warnings() | ||
|
||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/xr_generated_dispatch_table.c") | ||
|
||
# add in common files (hope these don't clash with us) | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/common/filesystem_utils.cpp") | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/common/object_info.cpp") | ||
|
||
# add in JSON | ||
env_thirdparty.add_source_files( | ||
thirdparty_obj, thirdparty_dir + "/src/external/jsoncpp/src/lib_json/json_reader.cpp" | ||
) | ||
env_thirdparty.add_source_files( | ||
thirdparty_obj, thirdparty_dir + "/src/external/jsoncpp/src/lib_json/json_value.cpp" | ||
) | ||
env_thirdparty.add_source_files( | ||
thirdparty_obj, thirdparty_dir + "/src/external/jsoncpp/src/lib_json/json_writer.cpp" | ||
) | ||
|
||
# add in load | ||
if env["platform"] == "android": | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/loader/android_utilities.cpp") | ||
|
||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/loader/api_layer_interface.cpp") | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/loader/loader_core.cpp") | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/loader/loader_instance.cpp") | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/loader/loader_logger_recorders.cpp") | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/loader/loader_logger.cpp") | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/loader/manifest_file.cpp") | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/loader/runtime_interface.cpp") | ||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "/src/loader/xr_generated_loader.cpp") | ||
|
||
env.drivers_sources += thirdparty_obj | ||
|
||
# Godot source files | ||
|
||
driver_obj = [] | ||
|
||
env.add_source_files(driver_obj, "openxr_device.cpp") | ||
|
||
if env["platform"] == "android": | ||
env.add_source_files(driver_obj, "openxr_android_extension.cpp") | ||
if env["vulkan"]: | ||
env.add_source_files(driver_obj, "openxr_vulkan_extension.cpp") | ||
# if env["opengl3"]: | ||
# # might need XR_USE_GRAPHICS_API_OPENGL_ES on Android | ||
# env.add_source_files(driver_obj, "openxr_opengl_extension.cpp") | ||
|
||
env.drivers_sources += driver_obj | ||
|
||
# Needed to force rebuilding the driver files when the thirdparty code is updated. | ||
env.Depends(driver_obj, thirdparty_obj) | ||
|
||
else: | ||
# add in dummy driver so we can compile platforms that do not support OpenXR | ||
driver_obj = [] | ||
|
||
env.AppendUnique(CPPDEFINES=["OPENXR_DUMMY"]) | ||
|
||
# env.add_source_files(driver_obj, "openxr_device_dummy.cpp") | ||
# env.add_source_files(driver_obj, "openxr_vulkan_extension_dummy.cpp") | ||
# env.add_source_files(driver_obj, "openxr_opengl_extension_dummy.cpp") | ||
|
||
# env.drivers_sources += driver_obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*************************************************************************/ | ||
/* openxr_android_extension.cpp */ | ||
/*************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/*************************************************************************/ | ||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ | ||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ | ||
/* */ | ||
/* 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_android_extension.h" | ||
|
||
#include <openxr/openxr.h> | ||
#include <openxr/openxr_platform.h> | ||
|
||
OpenXRAndroidExtension *OpenXRAndroidExtension::singleton = nullptr; | ||
|
||
OpenXRAndroidExtension *OpenXRAndroidExtension::get_singleton() { | ||
return singleton; | ||
} | ||
|
||
OpenXRAndroidExtension::OpenXRAndroidExtension(OpenXRDevice *p_openxr_device) : | ||
OpenXRExtensionWrapper(p_openxr_device) { | ||
singleton = this; | ||
|
||
request_extensions[XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME] = nullptr; // must be available | ||
|
||
// Initialize the loader | ||
PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR; | ||
result = xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction *)(&xrInitializeLoaderKHR)); | ||
ERR_FAIL_COND_MSG(XR_FAILED(result), "Failed to retrieve pointer to xrInitializeLoaderKHR"); | ||
|
||
// TODO fix this code, this is still code from GDNative! | ||
JNIEnv *env = android_api->godot_android_get_env(); | ||
JavaVM *vm; | ||
env->GetJavaVM(&vm); | ||
jobject activity_object = env->NewGlobalRef(android_api->godot_android_get_activity()); | ||
|
||
XrLoaderInitInfoAndroidKHR loader_init_info_android = { | ||
.type = XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR, | ||
.next = nullptr, | ||
.applicationVM = vm, | ||
.applicationContext = activity_object | ||
}; | ||
xrInitializeLoaderKHR((const XrLoaderInitInfoBaseHeaderKHR *)&loader_init_info_android); | ||
ERR_FAIL_COND_MSG(XR_FAILED(result), "Failed to call xrInitializeLoaderKHR"); | ||
} | ||
|
||
OpenXRAndroidExtension::~OpenXRAndroidExtension() { | ||
singleton = nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*************************************************************************/ | ||
/* openxr_android_extension.h */ | ||
/*************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/*************************************************************************/ | ||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ | ||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ | ||
/* */ | ||
/* 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. */ | ||
/*************************************************************************/ | ||
|
||
#ifndef OPENXR_ANDROID_EXTENSION_H | ||
#define OPENXR_ANDROID_EXTENSION_H | ||
|
||
#include "openxr_extension_wrapper.h" | ||
|
||
class OpenXRAndroidExtension : public OpenXRExtensionWrapper { | ||
public: | ||
static OpenXRAndroidExtension *get_singleton(); | ||
|
||
OpenXRAndroidExtension(OpenXRDevice *p_openxr_device); | ||
virtual ~OpenXRAndroidExtension() override; | ||
|
||
private: | ||
static OpenXRAndroidExtension *singleton; | ||
}; | ||
|
||
#endif // !OPENXR_ANDROID_EXTENSION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*************************************************************************/ | ||
/* openxr_composition_layer_provider.h */ | ||
/*************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/*************************************************************************/ | ||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ | ||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ | ||
/* */ | ||
/* 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. */ | ||
/*************************************************************************/ | ||
|
||
#ifndef OPENXR_COMPOSITION_LAYER_PROVIDER_H | ||
#define OPENXR_COMPOSITION_LAYER_PROVIDER_H | ||
|
||
#include <openxr/openxr.h> | ||
|
||
// Interface for OpenXR extensions that provide a composition layer. | ||
class OpenXRCompositionLayerProvider { | ||
public: | ||
// TODO changed to normal method definition for now | ||
// CI complains until we implement this, haven't ported it yet from plugin | ||
// virtual XrCompositionLayerBaseHeader *get_composition_layer() = 0; | ||
XrCompositionLayerBaseHeader *get_composition_layer() { return nullptr; }; | ||
}; | ||
|
||
#endif // OPENXR_COMPOSITION_LAYER_PROVIDER_H |
Oops, something went wrong.