diff options
author | Bastiaan Olij <mux213@gmail.com> | 2024-01-22 20:32:41 +1100 |
---|---|---|
committer | Bastiaan Olij <mux213@gmail.com> | 2024-04-09 16:56:39 +1000 |
commit | c388fe2ba770ff51295151dcafb80c701e229574 (patch) | |
tree | 90505944d243b145d9c6a0717aec5c2af6df1dc4 /modules/openxr/openxr_api.h | |
parent | 9d6bdbc56e0ac99a6cc3aaed1c114a6528cb87fc (diff) | |
download | redot-engine-c388fe2ba770ff51295151dcafb80c701e229574.tar.gz |
OpenXR: Improve swapchain logic and fix swapchain update when render target multiplier is changed.
Diffstat (limited to 'modules/openxr/openxr_api.h')
-rw-r--r-- | modules/openxr/openxr_api.h | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/modules/openxr/openxr_api.h b/modules/openxr/openxr_api.h index 9eb51eee7a..e835366200 100644 --- a/modules/openxr/openxr_api.h +++ b/modules/openxr/openxr_api.h @@ -58,12 +58,28 @@ class OpenXRInterface; class OpenXRAPI { public: - struct OpenXRSwapChainInfo { + class OpenXRSwapChainInfo { + private: XrSwapchain swapchain = XR_NULL_HANDLE; void *swapchain_graphics_data = nullptr; uint32_t image_index = 0; bool image_acquired = false; bool skip_acquire_swapchain = false; + + static Vector<OpenXRSwapChainInfo> free_queue; + + public: + _FORCE_INLINE_ XrSwapchain get_swapchain() const { return swapchain; } + _FORCE_INLINE_ bool is_image_acquired() const { return image_acquired; } + + bool create(XrSwapchainCreateFlags p_create_flags, XrSwapchainUsageFlags p_usage_flags, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size); + void queue_free(); + static void free_queued(); + void free(); + + bool acquire(XrBool32 &p_should_render); + bool release(); + RID get_image(); }; private: @@ -148,12 +164,14 @@ private: int64_t color_swapchain_format = 0; int64_t depth_swapchain_format = 0; - OpenXRSwapChainInfo swapchains[OPENXR_SWAPCHAIN_MAX]; + Size2i main_swapchain_size = { 0, 0 }; + OpenXRSwapChainInfo main_swapchains[OPENXR_SWAPCHAIN_MAX]; XrSpace play_space = XR_NULL_HANDLE; XrSpace view_space = XR_NULL_HANDLE; bool view_pose_valid = false; XRPose::TrackingConfidence head_pose_confidence = XRPose::XR_TRACKING_CONFIDENCE_NONE; + bool has_xr_viewport = false; bool emulating_local_floor = false; bool should_reset_emulated_floor_height = false; @@ -241,7 +259,9 @@ private: bool setup_view_space(); bool load_supported_swapchain_formats(); bool is_swapchain_format_supported(int64_t p_swapchain_format); - bool create_swapchains(); + bool obtain_swapchain_formats(); + bool create_main_swapchains(Size2i p_size); + void free_main_swapchains(); void destroy_session(); // action map @@ -312,6 +332,7 @@ public: XrInstance get_instance() const { return instance; }; XrSystemId get_system_id() const { return system_id; }; XrSession get_session() const { return session; }; + OpenXRGraphicsExtensionWrapper *get_graphics_extension() const { return graphics_extension; }; String get_runtime_name() const { return runtime_name; }; String get_runtime_version() const { return runtime_version; }; @@ -406,11 +427,7 @@ public: // swapchains int64_t get_color_swapchain_format() const { return color_swapchain_format; } - bool create_swapchain(XrSwapchainCreateFlags p_create_flags, XrSwapchainUsageFlags p_usage_flags, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, XrSwapchain &r_swapchain, void **r_swapchain_graphics_data); - void free_swapchain(OpenXRSwapChainInfo &p_swapchain); - bool acquire_image(OpenXRSwapChainInfo &p_swapchain); - RID get_image(OpenXRSwapChainInfo &p_swapchain); - bool release_image(OpenXRSwapChainInfo &p_swapchain); + int64_t get_depth_swapchain_format() const { return depth_swapchain_format; } // action map String get_default_action_map_resource_name(); |