You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-20 14:45:44 +00:00
OpenXR: Add OpenXRAPIExtension::update_main_swapchain_size()
This commit is contained in:
@@ -329,6 +329,12 @@
|
||||
[b]Note:[/b] This cannot be called while the OpenXR session is still running.
|
||||
</description>
|
||||
</method>
|
||||
<method name="update_main_swapchain_size">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Request the recommended resolution from the OpenXR runtime and update the main swapchain size if it has changed.
|
||||
</description>
|
||||
</method>
|
||||
<method name="xr_result">
|
||||
<return type="bool" />
|
||||
<param index="0" name="result" type="int" />
|
||||
|
||||
@@ -2228,6 +2228,27 @@ void OpenXRAPI::_set_render_state_render_region_rt(const Rect2i &p_render_region
|
||||
openxr_api->render_state.render_region = p_render_region;
|
||||
}
|
||||
|
||||
void OpenXRAPI::_update_main_swapchain_size_rt() {
|
||||
ERR_NOT_ON_RENDER_THREAD;
|
||||
|
||||
OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
|
||||
ERR_FAIL_NULL(openxr_api);
|
||||
|
||||
uint32_t view_count_output = 0;
|
||||
XrResult result = openxr_api->xrEnumerateViewConfigurationViews(openxr_api->instance, openxr_api->system_id, openxr_api->view_configuration, openxr_api->get_view_count(), &view_count_output, openxr_api->view_configuration_views.ptr());
|
||||
if (XR_FAILED(result)) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
for (uint32_t i = 0; i < view_count_output; i++) {
|
||||
print_verbose("OpenXR: Recommended resolution changed");
|
||||
print_verbose(String(" - recommended render width: ") + itos(openxr_api->view_configuration_views[i].recommendedImageRectWidth));
|
||||
print_verbose(String(" - recommended render height: ") + itos(openxr_api->view_configuration_views[i].recommendedImageRectHeight));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool OpenXRAPI::process() {
|
||||
ERR_FAIL_COND_V(instance == XR_NULL_HANDLE, false);
|
||||
|
||||
|
||||
@@ -371,6 +371,7 @@ private:
|
||||
static void _set_render_environment_blend_mode_rt(int32_t p_environment_blend_mode);
|
||||
static void _set_render_state_multiplier_rt(double p_render_target_size_multiplier);
|
||||
static void _set_render_state_render_region_rt(const Rect2i &p_render_region);
|
||||
static void _update_main_swapchain_size_rt();
|
||||
|
||||
_FORCE_INLINE_ void allocate_view_buffers(uint32_t p_view_count, bool p_submit_depth_buffer) {
|
||||
// If we're rendering on a separate thread, we may still be processing the last frame, don't communicate this till we're ready...
|
||||
@@ -428,6 +429,13 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
_FORCE_INLINE_ void update_main_swapchain_size() {
|
||||
RenderingServer *rendering_server = RenderingServer::get_singleton();
|
||||
ERR_FAIL_NULL(rendering_server);
|
||||
|
||||
rendering_server->call_on_render_thread(callable_mp_static(&OpenXRAPI::_update_main_swapchain_size_rt));
|
||||
}
|
||||
|
||||
XrInstance get_instance() const { return instance; }
|
||||
XrSystemId get_system_id() const { return system_id; }
|
||||
XrSession get_session() const { return session; }
|
||||
@@ -607,6 +615,7 @@ public:
|
||||
void unregister_frame_info_extension(OpenXRExtensionWrapper *p_extension);
|
||||
|
||||
const Vector<XrEnvironmentBlendMode> get_supported_environment_blend_modes();
|
||||
|
||||
bool is_environment_blend_mode_supported(XrEnvironmentBlendMode p_blend_mode) const;
|
||||
bool set_environment_blend_mode(XrEnvironmentBlendMode p_blend_mode);
|
||||
XrEnvironmentBlendMode get_environment_blend_mode() const { return requested_environment_blend_mode; }
|
||||
|
||||
@@ -95,6 +95,8 @@ void OpenXRAPIExtension::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_emulate_environment_blend_mode_alpha_blend", "enabled"), &OpenXRAPIExtension::set_emulate_environment_blend_mode_alpha_blend);
|
||||
ClassDB::bind_method(D_METHOD("is_environment_blend_mode_alpha_supported"), &OpenXRAPIExtension::is_environment_blend_mode_alpha_blend_supported);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("update_main_swapchain_size"), &OpenXRAPIExtension::update_main_swapchain_size);
|
||||
|
||||
BIND_ENUM_CONSTANT(OPENXR_ALPHA_BLEND_MODE_SUPPORT_NONE);
|
||||
BIND_ENUM_CONSTANT(OPENXR_ALPHA_BLEND_MODE_SUPPORT_REAL);
|
||||
BIND_ENUM_CONSTANT(OPENXR_ALPHA_BLEND_MODE_SUPPORT_EMULATING);
|
||||
@@ -348,6 +350,11 @@ void OpenXRAPIExtension::set_render_region(const Rect2i &p_render_region) {
|
||||
OpenXRAPI::get_singleton()->set_render_region(p_render_region);
|
||||
}
|
||||
|
||||
void OpenXRAPIExtension::update_main_swapchain_size() {
|
||||
ERR_FAIL_NULL(OpenXRAPI::get_singleton());
|
||||
OpenXRAPI::get_singleton()->update_main_swapchain_size();
|
||||
}
|
||||
|
||||
void OpenXRAPIExtension::set_emulate_environment_blend_mode_alpha_blend(bool p_enabled) {
|
||||
ERR_FAIL_NULL(OpenXRAPI::get_singleton());
|
||||
OpenXRAPI::get_singleton()->set_emulate_environment_blend_mode_alpha_blend(p_enabled);
|
||||
|
||||
@@ -119,6 +119,8 @@ public:
|
||||
|
||||
void set_render_region(const Rect2i &p_render_region);
|
||||
|
||||
void update_main_swapchain_size();
|
||||
|
||||
enum OpenXRAlphaBlendModeSupport {
|
||||
OPENXR_ALPHA_BLEND_MODE_SUPPORT_NONE = 0,
|
||||
OPENXR_ALPHA_BLEND_MODE_SUPPORT_REAL = 1,
|
||||
|
||||
Reference in New Issue
Block a user