Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/openxr/extensions/openxr_frame_synthesis_extension.h
22057 views
1
/**************************************************************************/
2
/* openxr_frame_synthesis_extension.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "../openxr_api.h"
34
#include "openxr_extension_wrapper.h"
35
36
#include <openxr/openxr.h>
37
38
class OpenXRFrameSynthesisExtension : public OpenXRExtensionWrapper {
39
GDCLASS(OpenXRFrameSynthesisExtension, OpenXRExtensionWrapper);
40
41
public:
42
static OpenXRFrameSynthesisExtension *get_singleton();
43
44
OpenXRFrameSynthesisExtension();
45
virtual ~OpenXRFrameSynthesisExtension() override;
46
47
virtual HashMap<String, bool *> get_requested_extensions(XrVersion p_version) override;
48
49
virtual void on_instance_created(const XrInstance p_instance) override;
50
virtual void on_instance_destroyed() override;
51
52
virtual void prepare_view_configuration(uint32_t p_view_count) override;
53
virtual void *set_view_configuration_and_get_next_pointer(uint32_t p_view, void *p_next_pointer) override;
54
virtual void print_view_configuration_info(uint32_t p_view) const override;
55
56
virtual void on_session_destroyed() override;
57
58
virtual void on_main_swapchains_created() override;
59
virtual void on_pre_render() override;
60
virtual void on_post_draw_viewport(RID p_render_target) override;
61
virtual void *set_projection_views_and_get_next_pointer(int p_view_index, void *p_next_pointer) override;
62
63
bool is_available() const;
64
65
bool is_enabled() const;
66
void set_enabled(bool p_enabled);
67
68
bool get_relax_frame_interval() const;
69
void set_relax_frame_interval(bool p_relax_frame_interval);
70
71
void skip_next_frame();
72
73
protected:
74
static void _bind_methods();
75
76
void _set_render_state_enabled_rt(bool p_enabled);
77
void _set_relax_frame_interval_rt(bool p_relax_frame_interval);
78
void _set_skip_next_frame_rt();
79
80
private:
81
enum SwapchainTypes {
82
SWAPCHAIN_MOTION_VECTOR,
83
SWAPCHAIN_DEPTH,
84
SWAPCHAIN_MAX
85
};
86
void free_swapchains();
87
88
static OpenXRFrameSynthesisExtension *singleton;
89
90
bool frame_synthesis_ext = false;
91
bool enabled = true;
92
bool relax_frame_interval = false;
93
94
// Frame synthesis render state, only accessible on render thread
95
struct RenderState {
96
bool enabled = true;
97
bool relax_frame_interval = false;
98
bool skip_next_frame = false;
99
100
LocalVector<XrFrameSynthesisConfigViewEXT> config_views;
101
OpenXRAPI::OpenXRSwapChainInfo swapchains[SWAPCHAIN_MAX];
102
LocalVector<XrFrameSynthesisInfoEXT> frame_synthesis_info;
103
Transform3D previous_transform;
104
} render_state;
105
};
106
107