mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Make OpenXRCompositionLayer and its children safe for multithreaded rendering
This commit is contained in:
parent
d413181b8a
commit
093d191909
13 changed files with 777 additions and 538 deletions
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#include "../extensions/openxr_composition_layer_extension.h"
|
||||
#include "scene/3d/node_3d.h"
|
||||
|
||||
class JavaObject;
|
||||
|
|
@ -40,28 +39,27 @@ class MeshInstance3D;
|
|||
class Mesh;
|
||||
class OpenXRAPI;
|
||||
class OpenXRCompositionLayerExtension;
|
||||
class OpenXRViewportCompositionLayerProvider;
|
||||
class SubViewport;
|
||||
|
||||
class OpenXRCompositionLayer : public Node3D {
|
||||
GDCLASS(OpenXRCompositionLayer, Node3D);
|
||||
|
||||
public:
|
||||
// Must be identical to Filter enum definition in OpenXRViewportCompositionLayerProvider.
|
||||
// Must be identical to Filter enum definition in OpenXRCompositionLayerExtension.
|
||||
enum Filter {
|
||||
FILTER_NEAREST,
|
||||
FILTER_LINEAR,
|
||||
FILTER_CUBIC,
|
||||
};
|
||||
|
||||
// Must be identical to MipmapMode enum definition in OpenXRViewportCompositionLayerProvider.
|
||||
// Must be identical to MipmapMode enum definition in OpenXRCompositionLayerExtension.
|
||||
enum MipmapMode {
|
||||
MIPMAP_MODE_DISABLED,
|
||||
MIPMAP_MODE_NEAREST,
|
||||
MIPMAP_MODE_LINEAR,
|
||||
};
|
||||
|
||||
// Must be identical to Wrap enum definition in OpenXRViewportCompositionLayerProvider.
|
||||
// Must be identical to Wrap enum definition in OpenXRCompositionLayerExtension.
|
||||
enum Wrap {
|
||||
WRAP_CLAMP_TO_BORDER,
|
||||
WRAP_CLAMP_TO_EDGE,
|
||||
|
|
@ -70,7 +68,7 @@ public:
|
|||
WRAP_MIRROR_CLAMP_TO_EDGE,
|
||||
};
|
||||
|
||||
// Must be identical to Swizzle enum definition in OpenXRViewportCompositionLayerProvider.
|
||||
// Must be identical to Swizzle enum definition in OpenXRCompositionLayerExtension.
|
||||
enum Swizzle {
|
||||
SWIZZLE_RED,
|
||||
SWIZZLE_GREEN,
|
||||
|
|
@ -80,30 +78,42 @@ public:
|
|||
SWIZZLE_ONE,
|
||||
};
|
||||
|
||||
private:
|
||||
XrCompositionLayerBaseHeader *composition_layer_base_header = nullptr;
|
||||
OpenXRViewportCompositionLayerProvider *openxr_layer_provider = nullptr;
|
||||
protected:
|
||||
RID composition_layer;
|
||||
|
||||
private:
|
||||
SubViewport *layer_viewport = nullptr;
|
||||
bool use_android_surface = false;
|
||||
Size2i android_surface_size = Size2i(1024, 1024);
|
||||
bool enable_hole_punch = false;
|
||||
bool alpha_blend = false;
|
||||
int sort_order = 1;
|
||||
bool protected_content = false;
|
||||
MeshInstance3D *fallback = nullptr;
|
||||
bool should_update_fallback_mesh = false;
|
||||
bool openxr_session_running = false;
|
||||
bool registered = false;
|
||||
|
||||
OpenXRViewportCompositionLayerProvider::SwapchainState *swapchain_state = nullptr;
|
||||
|
||||
Dictionary extension_property_values;
|
||||
|
||||
Filter min_filter = FILTER_LINEAR;
|
||||
Filter mag_filter = FILTER_LINEAR;
|
||||
MipmapMode mipmap_mode = MIPMAP_MODE_LINEAR;
|
||||
Wrap horizontal_wrap = WRAP_CLAMP_TO_BORDER;
|
||||
Wrap vertical_wrap = WRAP_CLAMP_TO_BORDER;
|
||||
Swizzle red_swizzle = SWIZZLE_RED;
|
||||
Swizzle green_swizzle = SWIZZLE_GREEN;
|
||||
Swizzle blue_swizzle = SWIZZLE_BLUE;
|
||||
Swizzle alpha_swizzle = SWIZZLE_ALPHA;
|
||||
float max_anisotropy = 1.0;
|
||||
Color border_color = { 0.0, 0.0, 0.0, 0.0 };
|
||||
|
||||
bool _should_use_fallback_node();
|
||||
void _create_fallback_node();
|
||||
void _reset_fallback_material();
|
||||
void _remove_fallback_node();
|
||||
|
||||
void _setup_composition_layer_provider();
|
||||
void _clear_composition_layer_provider();
|
||||
void _setup_composition_layer();
|
||||
void _clear_composition_layer();
|
||||
|
||||
protected:
|
||||
OpenXRAPI *openxr_api = nullptr;
|
||||
|
|
@ -123,15 +133,15 @@ protected:
|
|||
bool _should_register();
|
||||
|
||||
virtual Ref<Mesh> _create_fallback_mesh() = 0;
|
||||
virtual XrStructureType _get_openxr_type() const = 0;
|
||||
|
||||
void update_transform();
|
||||
void update_fallback_mesh();
|
||||
|
||||
XrPosef get_openxr_pose();
|
||||
|
||||
static Vector<OpenXRCompositionLayer *> composition_layer_nodes;
|
||||
bool is_viewport_in_use(SubViewport *p_viewport);
|
||||
|
||||
OpenXRCompositionLayer(XrCompositionLayerBaseHeader *p_composition_layer);
|
||||
OpenXRCompositionLayer();
|
||||
|
||||
public:
|
||||
void set_layer_viewport(SubViewport *p_viewport);
|
||||
|
|
@ -188,7 +198,7 @@ public:
|
|||
void set_max_anisotropy(float p_value);
|
||||
float get_max_anisotropy() const;
|
||||
|
||||
void set_border_color(Color p_color);
|
||||
void set_border_color(const Color &p_color);
|
||||
Color get_border_color() const;
|
||||
|
||||
virtual PackedStringArray get_configuration_warnings() const override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue