-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for XR_FB_android_surface_swapchain_create
- Loading branch information
Showing
7 changed files
with
4,832 additions
and
178 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
126 changes: 126 additions & 0 deletions
126
.../src/main/cpp/extensions/openxr_fb_android_surface_swapchain_create_extension_wrapper.cpp
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,126 @@ | ||
/**************************************************************************/ | ||
/* openxr_fb_android_surface_swapchain_create_extension_wrapper.cpp */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT XR */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.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 "extensions/openxr_fb_android_surface_swapchain_create_extension_wrapper.h" | ||
|
||
#include <godot_cpp/classes/object.hpp> | ||
#include <godot_cpp/classes/open_xrapi_extension.hpp> | ||
|
||
using namespace godot; | ||
|
||
static const char *SYNCHRONOUS_PROPERTY_NAME = "XR_FB_android_surface_swapchain_create/synchronous"; | ||
static const char *USE_TIMESTAMPS_PROPERTY_NAME = "XR_FB_android_surface_swapchain_create/use_timestamps"; | ||
|
||
OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper *OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::singleton = nullptr; | ||
|
||
OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper *OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::get_singleton() { | ||
if (singleton == nullptr) { | ||
singleton = memnew(OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper()); | ||
} | ||
return singleton; | ||
} | ||
|
||
OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper() : | ||
OpenXRExtensionWrapperExtension() { | ||
ERR_FAIL_COND_MSG(singleton != nullptr, "An OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper singleton already exists."); | ||
|
||
#ifdef ANDROID_ENABLED | ||
request_extensions[XR_FB_ANDROID_SURFACE_SWAPCHAIN_CREATE_EXTENSION_NAME] = &fb_android_surface_swapchain_create_ext; | ||
#endif | ||
singleton = this; | ||
} | ||
|
||
OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::~OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper() { | ||
} | ||
|
||
void OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::_bind_methods() { | ||
ClassDB::bind_method(D_METHOD("is_enabled"), &OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::is_enabled); | ||
} | ||
|
||
Dictionary OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::_get_requested_extensions() { | ||
Dictionary result; | ||
for (auto ext : request_extensions) { | ||
uint64_t value = reinterpret_cast<uint64_t>(ext.value); | ||
result[ext.key] = (Variant)value; | ||
} | ||
return result; | ||
} | ||
|
||
TypedArray<Dictionary> OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::_get_viewport_composition_layer_extension_properties() { | ||
TypedArray<Dictionary> properties; | ||
|
||
{ | ||
Dictionary synchronous; | ||
synchronous["name"] = SYNCHRONOUS_PROPERTY_NAME; | ||
synchronous["type"] = Variant::BOOL; | ||
synchronous["hint"] = PROPERTY_HINT_NONE; | ||
synchronous["hint_string"] = ""; | ||
properties.push_back(synchronous); | ||
} | ||
|
||
{ | ||
Dictionary use_timestamps; | ||
use_timestamps["name"] = USE_TIMESTAMPS_PROPERTY_NAME; | ||
use_timestamps["type"] = Variant::BOOL; | ||
use_timestamps["hint"] = PROPERTY_HINT_NONE; | ||
use_timestamps["hint_string"] = ""; | ||
properties.push_back(use_timestamps); | ||
} | ||
|
||
return properties; | ||
} | ||
|
||
Dictionary OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::_get_viewport_composition_layer_extension_property_defaults() { | ||
Dictionary defaults; | ||
defaults[SYNCHRONOUS_PROPERTY_NAME] = false; | ||
defaults[USE_TIMESTAMPS_PROPERTY_NAME] = false; | ||
return defaults; | ||
} | ||
|
||
uint64_t OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper::_set_android_surface_swapchain_create_info_and_get_next_pointer(const Dictionary &p_property_values, void *p_next_pointer) { | ||
#ifdef ANDROID_ENABLED | ||
if (fb_android_surface_swapchain_create_ext) { | ||
create_info.next = p_next_pointer; | ||
create_info.createFlags = 0; | ||
|
||
if ((bool)p_property_values.get(SYNCHRONOUS_PROPERTY_NAME, false)) { | ||
create_info.createFlags |= XR_ANDROID_SURFACE_SWAPCHAIN_SYNCHRONOUS_BIT_FB; | ||
} | ||
if ((bool)p_property_values.get(USE_TIMESTAMPS_PROPERTY_NAME, false)) { | ||
create_info.createFlags |= XR_ANDROID_SURFACE_SWAPCHAIN_USE_TIMESTAMPS_BIT_FB; | ||
} | ||
|
||
if (create_info.createFlags != 0) { | ||
return reinterpret_cast<uint64_t>(&create_info); | ||
} | ||
} | ||
#endif | ||
|
||
return reinterpret_cast<uint64_t>(p_next_pointer); | ||
} |
81 changes: 81 additions & 0 deletions
81
...ain/cpp/include/extensions/openxr_fb_android_surface_swapchain_create_extension_wrapper.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,81 @@ | ||
/**************************************************************************/ | ||
/* openxr_fb_android_surface_swapchain_create_extension_wrapper.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT XR */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.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. */ | ||
/**************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <openxr/openxr.h> | ||
#include <godot_cpp/classes/open_xr_extension_wrapper_extension.hpp> | ||
#include <godot_cpp/templates/hash_map.hpp> | ||
|
||
#ifdef ANDROID_ENABLED | ||
#define XR_USE_PLATFORM_ANDROID | ||
#include <jni.h> | ||
#include <openxr/openxr_platform.h> | ||
#endif | ||
|
||
using namespace godot; | ||
|
||
// Wrapper for the XR_FB_android_surface_swapchain_create extension. | ||
class OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper : public OpenXRExtensionWrapperExtension { | ||
GDCLASS(OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper, OpenXRExtensionWrapperExtension); | ||
|
||
public: | ||
Dictionary _get_requested_extensions() override; | ||
|
||
bool is_enabled() const { | ||
return fb_android_surface_swapchain_create_ext; | ||
} | ||
|
||
virtual TypedArray<Dictionary> _get_viewport_composition_layer_extension_properties() override; | ||
virtual Dictionary _get_viewport_composition_layer_extension_property_defaults() override; | ||
virtual uint64_t _set_android_surface_swapchain_create_info_and_get_next_pointer(const Dictionary &p_property_values, void *p_next_pointer) override; | ||
|
||
static OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper *get_singleton(); | ||
|
||
OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper(); | ||
~OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper(); | ||
|
||
protected: | ||
static void _bind_methods(); | ||
|
||
private: | ||
HashMap<String, bool *> request_extensions; | ||
|
||
static OpenXRFbAndroidSurfaceSwapchainCreateExtensionWrapper *singleton; | ||
|
||
bool fb_android_surface_swapchain_create_ext = false; | ||
|
||
#ifdef ANDROID_ENABLED | ||
XrAndroidSurfaceSwapchainCreateInfoFB create_info = { | ||
XR_TYPE_ANDROID_SURFACE_SWAPCHAIN_CREATE_INFO_FB, // type | ||
nullptr, // next | ||
0, // createFlags | ||
}; | ||
#endif | ||
}; |
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
Submodule godot-cpp
updated
17 files
+52 −32 | CMakeLists.txt | |
+225 −70 | binding_generator.py | |
+1 −1 | cmake/GodotCompilerWarnings.cmake | |
+3,940 −275 | gdextension/extension_api.json | |
+16 −0 | gdextension/gdextension_interface.h | |
+211 −9 | include/godot_cpp/core/type_info.hpp | |
+1 −0 | include/godot_cpp/godot.hpp | |
+1 −1 | include/godot_cpp/templates/safe_refcount.hpp | |
+238 −0 | include/godot_cpp/variant/typed_dictionary.hpp | |
+2 −0 | src/godot.cpp | |
+6 −0 | src/variant/packed_arrays.cpp | |
+11 −2 | test/project/main.gd | |
+41 −0 | test/src/example.cpp | |
+5 −0 | test/src/example.h | |
+1 −1 | tools/common_compiler_flags.py | |
+1 −1 | tools/web.py | |
+47 −7 | tools/windows.py |
Oops, something went wrong.