| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
#include "../openxr_api.h" |
| 39 |
#include "../util.h" |
| 40 |
#include "openxr_extension_wrapper.h" |
| 41 |
#include "openxr_fb_update_swapchain_extension.h" |
| 42 |
|
| 43 |
#include "../openxr_platform_inc.h" |
| 44 |
|
| 45 |
class OpenXRFBFoveationExtension : public OpenXRExtensionWrapper { |
| 46 |
GDCLASS(OpenXRFBFoveationExtension, OpenXRExtensionWrapper); |
| 47 |
|
| 48 |
protected: |
| 49 |
static void _bind_methods() {} |
| 50 |
|
| 51 |
public: |
| 52 |
static OpenXRFBFoveationExtension *get_singleton(); |
| 53 |
|
| 54 |
OpenXRFBFoveationExtension(const String &p_rendering_driver); |
| 55 |
virtual ~OpenXRFBFoveationExtension() override; |
| 56 |
|
| 57 |
virtual HashMap<String, bool *> get_requested_extensions(XrVersion p_version) override; |
| 58 |
|
| 59 |
virtual void on_instance_created(const XrInstance p_instance) override; |
| 60 |
virtual void on_instance_destroyed() override; |
| 61 |
|
| 62 |
virtual void *set_system_properties_and_get_next_pointer(void *p_next_pointer) override; |
| 63 |
virtual void *set_swapchain_create_info_and_get_next_pointer(void *p_next_pointer) override; |
| 64 |
|
| 65 |
virtual void on_main_swapchains_created() override; |
| 66 |
|
| 67 |
bool is_enabled() const; |
| 68 |
|
| 69 |
XrFoveationLevelFB get_foveation_level() const; |
| 70 |
void set_foveation_level(XrFoveationLevelFB p_foveation_level); |
| 71 |
|
| 72 |
XrFoveationDynamicFB get_foveation_dynamic() const; |
| 73 |
void set_foveation_dynamic(XrFoveationDynamicFB p_foveation_dynamic); |
| 74 |
|
| 75 |
bool is_foveation_eye_tracked_enabled() const; |
| 76 |
void get_fragment_density_offsets(LocalVector<Vector2i> &r_offsets); |
| 77 |
|
| 78 |
private: |
| 79 |
static OpenXRFBFoveationExtension *singleton; |
| 80 |
|
| 81 |
|
| 82 |
String rendering_driver; |
| 83 |
bool fb_foveation_ext = false; |
| 84 |
bool fb_foveation_configuration_ext = false; |
| 85 |
bool fb_foveation_vulkan_ext = false; |
| 86 |
bool meta_foveation_eye_tracked_ext = false; |
| 87 |
bool meta_vulkan_swapchain_create_info_ext = false; |
| 88 |
|
| 89 |
|
| 90 |
XrFoveationLevelFB foveation_level = XR_FOVEATION_LEVEL_NONE_FB; |
| 91 |
XrFoveationDynamicFB foveation_dynamic = XR_FOVEATION_DYNAMIC_DISABLED_FB; |
| 92 |
|
| 93 |
void _update_profile_rt(); |
| 94 |
|
| 95 |
void update_profile() { |
| 96 |
|
| 97 |
RenderingServer *rendering_server = RenderingServer::get_singleton(); |
| 98 |
ERR_FAIL_NULL(rendering_server); |
| 99 |
|
| 100 |
rendering_server->call_on_render_thread(callable_mp(this, &OpenXRFBFoveationExtension::_update_profile_rt)); |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
XrSwapchainCreateInfoFoveationFB swapchain_create_info_foveation_fb; |
| 105 |
OpenXRFBUpdateSwapchainExtension *swapchain_update_state_ext = nullptr; |
| 106 |
|
| 107 |
|
| 108 |
XrSystemFoveationEyeTrackedPropertiesMETA meta_foveation_eye_tracked_properties; |
| 109 |
XrFoveationEyeTrackedProfileCreateInfoMETA meta_foveation_eye_tracked_create_info; |
| 110 |
#ifdef VULKAN_ENABLED |
| 111 |
XrVulkanSwapchainCreateInfoMETA meta_vulkan_swapchain_create_info; |
| 112 |
#endif |
| 113 |
|
| 114 |
|
| 115 |
EXT_PROTO_XRRESULT_FUNC3(xrCreateFoveationProfileFB, (XrSession), session, (const XrFoveationProfileCreateInfoFB *), create_info, (XrFoveationProfileFB *), profile); |
| 116 |
EXT_PROTO_XRRESULT_FUNC1(xrDestroyFoveationProfileFB, (XrFoveationProfileFB), profile); |
| 117 |
EXT_PROTO_XRRESULT_FUNC2(xrGetFoveationEyeTrackedStateMETA, (XrSession), session, (XrFoveationEyeTrackedStateMETA *), foveationState); |
| 118 |
}; |