mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
OpenXR: Allow GDExtensions to provide multiple, ordered composition layers
Co-authored-by: Bastiaan Olij <mux213@gmail.com>
This commit is contained in:
parent
da945ce626
commit
308a6a4734
8 changed files with 91 additions and 16 deletions
|
@ -2080,18 +2080,29 @@ void OpenXRAPI::end_frame() {
|
|||
projection_views[eye].pose = views[eye].pose;
|
||||
}
|
||||
|
||||
Vector<const XrCompositionLayerBaseHeader *> layers_list;
|
||||
Vector<OrderedCompositionLayer> ordered_layers_list;
|
||||
bool projection_layer_is_first = true;
|
||||
|
||||
// Add composition layers from providers
|
||||
for (OpenXRCompositionLayerProvider *provider : composition_layer_providers) {
|
||||
XrCompositionLayerBaseHeader *layer = provider->get_composition_layer();
|
||||
if (layer) {
|
||||
layers_list.push_back(layer);
|
||||
for (int i = 0; i < provider->get_composition_layer_count(); i++) {
|
||||
OrderedCompositionLayer layer = {
|
||||
provider->get_composition_layer(i),
|
||||
provider->get_composition_layer_order(i),
|
||||
};
|
||||
if (layer.composition_layer) {
|
||||
ordered_layers_list.push_back(layer);
|
||||
if (layer.sort_order == 0) {
|
||||
WARN_PRINT_ONCE_ED("Composition layer returned sort order 0, it may be overwritten by projection layer.");
|
||||
} else if (layer.sort_order < 0) {
|
||||
projection_layer_is_first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XrCompositionLayerFlags layer_flags = XR_COMPOSITION_LAYER_CORRECT_CHROMATIC_ABERRATION_BIT;
|
||||
if (layers_list.size() > 0 || environment_blend_mode != XR_ENVIRONMENT_BLEND_MODE_OPAQUE) {
|
||||
if (!projection_layer_is_first || environment_blend_mode != XR_ENVIRONMENT_BLEND_MODE_OPAQUE) {
|
||||
layer_flags |= XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT;
|
||||
}
|
||||
|
||||
|
@ -2103,7 +2114,16 @@ void OpenXRAPI::end_frame() {
|
|||
view_count, // viewCount
|
||||
projection_views, // views
|
||||
};
|
||||
layers_list.push_back((const XrCompositionLayerBaseHeader *)&projection_layer);
|
||||
ordered_layers_list.push_back({ (const XrCompositionLayerBaseHeader *)&projection_layer, 0 });
|
||||
|
||||
// Sort our layers.
|
||||
ordered_layers_list.sort_custom<OrderedCompositionLayer>();
|
||||
|
||||
// Now make a list we can pass on to OpenXR.
|
||||
Vector<const XrCompositionLayerBaseHeader *> layers_list;
|
||||
for (OrderedCompositionLayer &ordered_layer : ordered_layers_list) {
|
||||
layers_list.push_back(ordered_layer.composition_layer);
|
||||
}
|
||||
|
||||
XrFrameEndInfo frame_end_info = {
|
||||
XR_TYPE_FRAME_END_INFO, // type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue