|
@@ -101,7 +101,7 @@ void *OpenXRFBFoveationExtension::set_swapchain_create_info_and_get_next_pointer
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void OpenXRFBFoveationExtension::on_state_ready() {
|
|
|
|
|
|
+void OpenXRFBFoveationExtension::on_main_swapchains_created() {
|
|
update_profile();
|
|
update_profile();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -127,26 +127,41 @@ void OpenXRFBFoveationExtension::set_foveation_dynamic(XrFoveationDynamicFB p_fo
|
|
update_profile();
|
|
update_profile();
|
|
}
|
|
}
|
|
|
|
|
|
-void OpenXRFBFoveationExtension::update_profile() {
|
|
|
|
- if (!is_enabled()) {
|
|
|
|
|
|
+void OpenXRFBFoveationExtension::_update_profile() {
|
|
|
|
+ // Must be called from rendering thread!
|
|
|
|
+ ERR_NOT_ON_RENDER_THREAD;
|
|
|
|
+
|
|
|
|
+ OpenXRFBFoveationExtension *fov_ext = OpenXRFBFoveationExtension::get_singleton();
|
|
|
|
+ ERR_FAIL_NULL(fov_ext);
|
|
|
|
+
|
|
|
|
+ if (!fov_ext->is_enabled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
|
|
|
|
+ ERR_FAIL_NULL(openxr_api);
|
|
|
|
+
|
|
|
|
+ XrSwapchain main_color_swapchain = openxr_api->get_color_swapchain();
|
|
|
|
+ if (main_color_swapchain == XR_NULL_HANDLE) {
|
|
|
|
+ // Our swapchain hasn't been created yet, we'll call this again once it has.
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
XrFoveationLevelProfileCreateInfoFB level_profile_create_info;
|
|
XrFoveationLevelProfileCreateInfoFB level_profile_create_info;
|
|
level_profile_create_info.type = XR_TYPE_FOVEATION_LEVEL_PROFILE_CREATE_INFO_FB;
|
|
level_profile_create_info.type = XR_TYPE_FOVEATION_LEVEL_PROFILE_CREATE_INFO_FB;
|
|
level_profile_create_info.next = nullptr;
|
|
level_profile_create_info.next = nullptr;
|
|
- level_profile_create_info.level = foveation_level;
|
|
|
|
|
|
+ level_profile_create_info.level = fov_ext->foveation_level;
|
|
level_profile_create_info.verticalOffset = 0.0f;
|
|
level_profile_create_info.verticalOffset = 0.0f;
|
|
- level_profile_create_info.dynamic = foveation_dynamic;
|
|
|
|
|
|
+ level_profile_create_info.dynamic = fov_ext->foveation_dynamic;
|
|
|
|
|
|
XrFoveationProfileCreateInfoFB profile_create_info;
|
|
XrFoveationProfileCreateInfoFB profile_create_info;
|
|
profile_create_info.type = XR_TYPE_FOVEATION_PROFILE_CREATE_INFO_FB;
|
|
profile_create_info.type = XR_TYPE_FOVEATION_PROFILE_CREATE_INFO_FB;
|
|
profile_create_info.next = &level_profile_create_info;
|
|
profile_create_info.next = &level_profile_create_info;
|
|
|
|
|
|
XrFoveationProfileFB foveation_profile;
|
|
XrFoveationProfileFB foveation_profile;
|
|
- XrResult result = xrCreateFoveationProfileFB(OpenXRAPI::get_singleton()->get_session(), &profile_create_info, &foveation_profile);
|
|
|
|
|
|
+ XrResult result = fov_ext->xrCreateFoveationProfileFB(openxr_api->get_session(), &profile_create_info, &foveation_profile);
|
|
if (XR_FAILED(result)) {
|
|
if (XR_FAILED(result)) {
|
|
- print_line("OpenXR: Unable to create the foveation profile [", OpenXRAPI::get_singleton()->get_error_string(result), "]");
|
|
|
|
|
|
+ print_line("OpenXR: Unable to create the foveation profile [", openxr_api->get_error_string(result), "]");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -154,15 +169,15 @@ void OpenXRFBFoveationExtension::update_profile() {
|
|
foveation_update_state.type = XR_TYPE_SWAPCHAIN_STATE_FOVEATION_FB;
|
|
foveation_update_state.type = XR_TYPE_SWAPCHAIN_STATE_FOVEATION_FB;
|
|
foveation_update_state.profile = foveation_profile;
|
|
foveation_update_state.profile = foveation_profile;
|
|
|
|
|
|
- result = swapchain_update_state_ext->xrUpdateSwapchainFB(OpenXRAPI::get_singleton()->get_color_swapchain(), (XrSwapchainStateBaseHeaderFB *)&foveation_update_state);
|
|
|
|
|
|
+ result = fov_ext->swapchain_update_state_ext->xrUpdateSwapchainFB(main_color_swapchain, (XrSwapchainStateBaseHeaderFB *)&foveation_update_state);
|
|
if (XR_FAILED(result)) {
|
|
if (XR_FAILED(result)) {
|
|
- print_line("OpenXR: Unable to update the swapchain [", OpenXRAPI::get_singleton()->get_error_string(result), "]");
|
|
|
|
|
|
+ print_line("OpenXR: Unable to update the swapchain [", openxr_api->get_error_string(result), "]");
|
|
|
|
|
|
// We still want to destroy our profile so keep going...
|
|
// We still want to destroy our profile so keep going...
|
|
}
|
|
}
|
|
|
|
|
|
- result = xrDestroyFoveationProfileFB(foveation_profile);
|
|
|
|
|
|
+ result = fov_ext->xrDestroyFoveationProfileFB(foveation_profile);
|
|
if (XR_FAILED(result)) {
|
|
if (XR_FAILED(result)) {
|
|
- print_line("OpenXR: Unable to destroy the foveation profile [", OpenXRAPI::get_singleton()->get_error_string(result), "]");
|
|
|
|
|
|
+ print_line("OpenXR: Unable to destroy the foveation profile [", openxr_api->get_error_string(result), "]");
|
|
}
|
|
}
|
|
}
|
|
}
|