From 0a6e3dfd49e196af57b30109f91490bc140c2272 Mon Sep 17 00:00:00 2001 From: "AP\\shuaxia" Date: Tue, 26 Dec 2023 15:27:53 +0800 Subject: [PATCH] st/oxr: Add extension XR_FB_composition_layer_settings --- CMakeLists.txt | 4 ++ scripts/generate_oxr_ext_support.py | 1 + src/xrt/include/xrt/xrt_compositor.h | 11 +++++ .../include/xrt/xrt_config_build.h.cmake_in | 1 + .../oxr/oxr_extension_support.h | 11 +++++ .../oxr/oxr_session_frame_end.c | 49 ++++++++++++++++++- 6 files changed, 76 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a653aaa16..a4451b144 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -413,6 +413,9 @@ if(NOT DEFINED XRT_FEATURE_OPENXR_INTERACTION_WINMR) endif() # Defaults for OpenXR layer support +if(NOT DEFINED XRT_FEATURE_OPENXR_LAYER_FB_COMPOSITION_SETTINGS) + set(XRT_FEATURE_OPENXR_LAYER_FB_COMPOSITION_SETTINGS OFF) +endif() if(NOT DEFINED XRT_FEATURE_OPENXR_LAYER_DEPTH) set(XRT_FEATURE_OPENXR_LAYER_DEPTH ON) endif() @@ -646,6 +649,7 @@ message(STATUS "# FEATURE_OPENXR_LAYER_CYLINDER: ${XRT_FEATURE message(STATUS "# FEATURE_OPENXR_LAYER_DEPTH: ${XRT_FEATURE_OPENXR_LAYER_DEPTH}") message(STATUS "# FEATURE_OPENXR_LAYER_EQUIRECT1: ${XRT_FEATURE_OPENXR_LAYER_EQUIRECT1}") message(STATUS "# FEATURE_OPENXR_LAYER_EQUIRECT2: ${XRT_FEATURE_OPENXR_LAYER_EQUIRECT2}") +message(STATUS "# FEATURE_OPENXR_COMPOSITION_LAYER_SETTINGS: ${XRT_FEATURE_OPENXR_LAYER_FB_COMPOSITION_SETTINGS}") message(STATUS "# FEATURE_OPENXR_LAYER_FB_LAYER_IMAGE_LAYOUT ${XRT_FEATURE_OPENXR_LAYER_FB_LAYER_IMAGE_LAYOUT}") message(STATUS "# FEATURE_OPENXR_OVERLAY: ${XRT_FEATURE_OPENXR_OVERLAY}") message(STATUS "# FEATURE_OPENXR_SPACE_LOCAL_FLOOR: ${XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR}") diff --git a/scripts/generate_oxr_ext_support.py b/scripts/generate_oxr_ext_support.py index af604a948..57926d862 100755 --- a/scripts/generate_oxr_ext_support.py +++ b/scripts/generate_oxr_ext_support.py @@ -65,6 +65,7 @@ EXTENSIONS = ( ['XR_EXT_palm_pose', 'XRT_FEATURE_OPENXR_INTERACTION_EXT_PALM_POSE'], ['XR_EXT_samsung_odyssey_controller', 'XRT_FEATURE_OPENXR_INTERACTION_WINMR'], ['XR_FB_composition_layer_image_layout', 'XRT_FEATURE_OPENXR_LAYER_FB_LAYER_IMAGE_LAYOUT'], + ['XR_FB_composition_layer_settings', 'XRT_FEATURE_OPENXR_LAYER_FB_COMPOSITION_SETTINGS'], ['XR_FB_display_refresh_rate', 'XRT_FEATURE_OPENXR_DISPLAY_REFRESH_RATE'], ['XR_ML_ml2_controller_interaction', 'XRT_FEATURE_OPENXR_INTERACTION_ML2'], ['XR_MND_headless', 'XRT_FEATURE_OPENXR_HEADLESS'], diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index 8c25a9dcc..869fdc565 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -104,6 +104,17 @@ enum xrt_layer_composition_flags */ XRT_LAYER_COMPOSITION_COLOR_BIAS_SCALE = 1u << 4u, + //! Normal super sampling, see XrCompositionLayerSettingsFlagsFB. + XRT_COMPOSITION_LAYER_PROCESSING_NORMAL_SUPER_SAMPLING_BIT_FB = 1u << 5u, + + //! Quality super sampling, see XrCompositionLayerSettingsFlagsFB. + XRT_COMPOSITION_LAYER_PROCESSING_QUALITY_SUPER_SAMPLING_BIT_FB = 1u << 6u, + + //! Normal sharpening, see XrCompositionLayerSettingsFlagsFB. + XRT_COMPOSITION_LAYER_PROCESSING_NORMAL_SHARPENING_BIT_FB = 1u << 7u, + + //! Quality sharpening, see XrCompositionLayerSettingsFlagsFB. + XRT_COMPOSITION_LAYER_PROCESSING_QUALITY_SHARPENING_BIT_FB = 1u << 8u, }; /*! diff --git a/src/xrt/include/xrt/xrt_config_build.h.cmake_in b/src/xrt/include/xrt/xrt_config_build.h.cmake_in index 537e738b2..e6801c85a 100644 --- a/src/xrt/include/xrt/xrt_config_build.h.cmake_in +++ b/src/xrt/include/xrt/xrt_config_build.h.cmake_in @@ -46,6 +46,7 @@ #cmakedefine XRT_FEATURE_OPENXR_LAYER_DEPTH #cmakedefine XRT_FEATURE_OPENXR_LAYER_EQUIRECT1 #cmakedefine XRT_FEATURE_OPENXR_LAYER_EQUIRECT2 +#cmakedefine XRT_FEATURE_OPENXR_LAYER_FB_COMPOSITION_SETTINGS #cmakedefine XRT_FEATURE_OPENXR_LAYER_FB_LAYER_IMAGE_LAYOUT #cmakedefine XRT_FEATURE_OPENXR_OVERLAY #cmakedefine XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR diff --git a/src/xrt/state_trackers/oxr/oxr_extension_support.h b/src/xrt/state_trackers/oxr/oxr_extension_support.h index 92fe1fbed..d7b027b31 100644 --- a/src/xrt/state_trackers/oxr/oxr_extension_support.h +++ b/src/xrt/state_trackers/oxr/oxr_extension_support.h @@ -394,6 +394,16 @@ #define OXR_EXTENSION_SUPPORT_FB_display_refresh_rate(_) #endif +/* + * XR_FB_composition_layer_settings + */ +#if defined(XR_FB_composition_layer_settings) && defined(XRT_FEATURE_OPENXR_LAYER_FB_COMPOSITION_SETTINGS) +#define OXR_HAVE_FB_composition_layer_settings +#define OXR_EXTENSION_SUPPORT_FB_composition_layer_settings(_) \ + _(FB_composition_layer_settings, FB_COMPOSITION_LAYER_SETTINGS) +#else +#define OXR_EXTENSION_SUPPORT_FB_composition_layer_settings(_) +#endif /* * XR_ML_ml2_controller_interaction @@ -598,6 +608,7 @@ OXR_EXTENSION_SUPPORT_EXT_palm_pose(_) \ OXR_EXTENSION_SUPPORT_EXT_samsung_odyssey_controller(_) \ OXR_EXTENSION_SUPPORT_FB_composition_layer_image_layout(_) \ + OXR_EXTENSION_SUPPORT_FB_composition_layer_settings(_) \ OXR_EXTENSION_SUPPORT_FB_display_refresh_rate(_) \ OXR_EXTENSION_SUPPORT_ML_ml2_controller_interaction(_) \ OXR_EXTENSION_SUPPORT_MND_headless(_) \ diff --git a/src/xrt/state_trackers/oxr/oxr_session_frame_end.c b/src/xrt/state_trackers/oxr/oxr_session_frame_end.c index 3bae884c6..fc1afc633 100644 --- a/src/xrt/state_trackers/oxr/oxr_session_frame_end.c +++ b/src/xrt/state_trackers/oxr/oxr_session_frame_end.c @@ -161,6 +161,30 @@ fill_in_color_scale_bias(struct oxr_session *sess, #endif // OXR_HAVE_KHR_composition_layer_color_scale_bias } +static enum xrt_layer_composition_flags +convert_layer_settings_flags(XrCompositionLayerSettingsFlagsFB xr_layer_settings_flags) +{ + enum xrt_layer_composition_flags layer_settings_flags = 0; + + if ((xr_layer_settings_flags & XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SUPER_SAMPLING_BIT_FB) != 0) { + layer_settings_flags |= XRT_COMPOSITION_LAYER_PROCESSING_NORMAL_SUPER_SAMPLING_BIT_FB; + } + + if ((xr_layer_settings_flags & XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SUPER_SAMPLING_BIT_FB) != 0) { + layer_settings_flags |= XRT_COMPOSITION_LAYER_PROCESSING_QUALITY_SUPER_SAMPLING_BIT_FB; + } + + if ((xr_layer_settings_flags & XR_COMPOSITION_LAYER_SETTINGS_NORMAL_SHARPENING_BIT_FB) != 0) { + layer_settings_flags |= XRT_COMPOSITION_LAYER_PROCESSING_NORMAL_SHARPENING_BIT_FB; + } + + if ((xr_layer_settings_flags & XR_COMPOSITION_LAYER_SETTINGS_QUALITY_SHARPENING_BIT_FB) != 0) { + layer_settings_flags |= XRT_COMPOSITION_LAYER_PROCESSING_QUALITY_SHARPENING_BIT_FB; + } + + return layer_settings_flags; +} + static void fill_in_y_flip(struct oxr_session *sess, const XrCompositionLayerBaseHeader *layer, struct xrt_layer_data *xlayer_data) { @@ -199,6 +223,23 @@ fill_in_sub_image(const struct oxr_swapchain *sc, const XrSwapchainSubImage *oxr xsub->norm_rect.y = (float)(rect->offset.h / (double)sc->height); } +static void +fill_in_layer_settings(struct oxr_session *sess, + const XrCompositionLayerBaseHeader *layer, + struct xrt_layer_data *xlayer_data) +{ +#ifdef OXR_HAVE_FB_composition_layer_settings + // Is the extension enabled? + if (!sess->sys->inst->extensions.FB_composition_layer_settings) { + return; + } + const XrCompositionLayerSettingsFB *layer_settings = + OXR_GET_INPUT_FROM_CHAIN(layer->next, XR_TYPE_COMPOSITION_LAYER_SETTINGS_FB, XrCompositionLayerSettingsFB); + if (layer_settings != NULL) { + xlayer_data->flags |= convert_layer_settings_flags(layer_settings->layerFlags); + } +#endif // OXR_HAVE_FB_composition_layer_settings +} /* * @@ -987,6 +1028,7 @@ submit_quad_layer(struct oxr_session *sess, fill_in_sub_image(sc, &quad->subImage, &data.quad.sub); fill_in_color_scale_bias(sess, (XrCompositionLayerBaseHeader *)quad, &data); fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)quad, &data); + fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)quad, &data); xrt_result_t xret = xrt_comp_layer_quad(xc, head, sc->swapchain, &data); OXR_CHECK_XRET(log, sess, xret, xrt_comp_layer_quad); @@ -1044,6 +1086,8 @@ submit_projection_layer(struct oxr_session *sess, fill_in_color_scale_bias(sess, (XrCompositionLayerBaseHeader *)proj, &data); fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)proj, &data); + fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)proj, &data); + #ifdef OXR_HAVE_KHR_composition_layer_depth const XrCompositionLayerDepthInfoKHR *d_l = OXR_GET_INPUT_FROM_CHAIN( &proj->views[0], XR_TYPE_COMPOSITION_LAYER_DEPTH_INFO_KHR, XrCompositionLayerDepthInfoKHR); @@ -1126,6 +1170,7 @@ submit_cube_layer(struct oxr_session *sess, data.name = XRT_INPUT_GENERIC_HEAD_POSE; data.timestamp = xrt_timestamp; data.flags = convert_layer_flags(cube->layerFlags); + fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)cube, &data); if (spc->space_type == OXR_SPACE_TYPE_REFERENCE_VIEW) { data.flags |= XRT_LAYER_COMPOSITION_VIEW_SPACE_BIT; @@ -1201,6 +1246,7 @@ submit_cylinder_layer(struct oxr_session *sess, fill_in_sub_image(sc, &cylinder->subImage, &data.cylinder.sub); fill_in_color_scale_bias(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); + fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); xrt_result_t xret = xrt_comp_layer_cylinder(xc, head, sc->swapchain, &data); OXR_CHECK_XRET(log, sess, xret, xrt_comp_layer_cylinder); @@ -1246,7 +1292,7 @@ submit_equirect1_layer(struct oxr_session *sess, fill_in_sub_image(sc, &equirect->subImage, &data.equirect1.sub); fill_in_color_scale_bias(sess, (XrCompositionLayerBaseHeader *)equirect, &data); fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)equirect, &data); - + fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)equirect, &data); struct xrt_vec2 *scale = (struct xrt_vec2 *)&equirect->scale; struct xrt_vec2 *bias = (struct xrt_vec2 *)&equirect->bias; @@ -1310,6 +1356,7 @@ submit_equirect2_layer(struct oxr_session *sess, fill_in_sub_image(sc, &equirect->subImage, &data.equirect2.sub); fill_in_color_scale_bias(sess, (XrCompositionLayerBaseHeader *)equirect, &data); fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)equirect, &data); + fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)equirect, &data); xrt_result_t xret = xrt_comp_layer_equirect2(xc, head, sc->swapchain, &data); OXR_CHECK_XRET(log, sess, xret, xrt_comp_layer_equirect2);