From b5df7f1761b057f48d7b820c55fb38a279efc46f Mon Sep 17 00:00:00 2001 From: Pingping Meng Date: Thu, 1 Feb 2024 10:55:26 +0800 Subject: [PATCH] doc: Document !2129 --- doc/changes/state_trackers/mr.2129.md | 1 + src/xrt/include/xrt/xrt_compositor.h | 30 +++++------ .../oxr/oxr_extension_support.h | 7 +-- .../oxr/oxr_session_frame_end.c | 54 +++++++++---------- 4 files changed, 47 insertions(+), 45 deletions(-) create mode 100644 doc/changes/state_trackers/mr.2129.md diff --git a/doc/changes/state_trackers/mr.2129.md b/doc/changes/state_trackers/mr.2129.md new file mode 100644 index 000000000..1bb931389 --- /dev/null +++ b/doc/changes/state_trackers/mr.2129.md @@ -0,0 +1 @@ +OpenXR: Add extension XR_FB_composition_layer_depth_test. diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index a0028d0ad..16fc8c600 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -124,11 +124,11 @@ enum xrt_layer_composition_flags */ XRT_LAYER_COMPOSITION_ADVANCED_BLENDING_BIT = 1u << 9u, - /*! + /*! * Depth testing is requested when composing this layer if this flag is set, * see XrCompositionLayerDepthTestFB. */ - XRT_LAYER_COMPOSITION_DEPTH_TEST = 1u << 10u, + XRT_LAYER_COMPOSITION_DEPTH_TEST = 1u << 10u, }; /*! @@ -136,15 +136,15 @@ enum xrt_layer_composition_flags */ enum xrt_compare_op_fb { - XRT_COMPARE_OP_NEVER_FB = 0, - XRT_COMPARE_OP_LESS_FB = 1, - XRT_COMPARE_OP_EQUAL_FB = 2, - XRT_COMPARE_OP_LESS_OR_EQUAL_FB = 3, - XRT_COMPARE_OP_GREATER_FB = 4, - XRT_COMPARE_OP_NOT_EQUAL_FB = 5, - XRT_COMPARE_OP_GREATER_OR_EQUAL_FB = 6, - XRT_COMPARE_OP_ALWAYS_FB = 7, - XRT_COMPARE_OP_MAX_ENUM_FB = 0x7FFFFFFF + XRT_COMPARE_OP_NEVER_FB = 0, + XRT_COMPARE_OP_LESS_FB = 1, + XRT_COMPARE_OP_EQUAL_FB = 2, + XRT_COMPARE_OP_LESS_OR_EQUAL_FB = 3, + XRT_COMPARE_OP_GREATER_FB = 4, + XRT_COMPARE_OP_NOT_EQUAL_FB = 5, + XRT_COMPARE_OP_GREATER_OR_EQUAL_FB = 6, + XRT_COMPARE_OP_ALWAYS_FB = 7, + XRT_COMPARE_OP_MAX_ENUM_FB = 0x7FFFFFFF }; /*! @@ -251,8 +251,8 @@ struct xrt_layer_depth_data struct xrt_layer_depth_test_data { - bool depth_mask; - enum xrt_compare_op_fb compare_op; + bool depth_mask; + enum xrt_compare_op_fb compare_op; }; /*! @@ -386,10 +386,10 @@ struct xrt_layer_data */ enum xrt_layer_composition_flags flags; - /*! + /*! * Depth test data */ - struct xrt_layer_depth_test_data depth_test; + struct xrt_layer_depth_test_data depth_test; /*! * Whether the main compositor should flip the direction of y when diff --git a/src/xrt/state_trackers/oxr/oxr_extension_support.h b/src/xrt/state_trackers/oxr/oxr_extension_support.h index 3464020f4..cc60daf39 100644 --- a/src/xrt/state_trackers/oxr/oxr_extension_support.h +++ b/src/xrt/state_trackers/oxr/oxr_extension_support.h @@ -419,11 +419,12 @@ #endif /* -* XR_FB_composition_layer_depth_test -*/ + * XR_FB_composition_layer_depth_test + */ #if defined(XR_FB_composition_layer_depth_test) && defined(XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST) #define OXR_HAVE_FB_composition_layer_depth_test -#define OXR_EXTENSION_SUPPORT_FB_composition_layer_depth_test(_) _(FB_composition_layer_depth_test, FB_COMPOSITION_LAYER_DEPTH_TEST) +#define OXR_EXTENSION_SUPPORT_FB_composition_layer_depth_test(_) \ + _(FB_composition_layer_depth_test, FB_COMPOSITION_LAYER_DEPTH_TEST) #else #define OXR_EXTENSION_SUPPORT_FB_composition_layer_depth_test(_) #endif 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 8e8907446..32ce26b32 100644 --- a/src/xrt/state_trackers/oxr/oxr_session_frame_end.c +++ b/src/xrt/state_trackers/oxr/oxr_session_frame_end.c @@ -132,17 +132,17 @@ convert_layer_flags(XrSwapchainUsageFlags xr_flags) static enum xrt_compare_op_fb convert_compare_op(XrCompareOpFB xr_compare_op) { - switch (xr_compare_op) { - case XR_COMPARE_OP_NEVER_FB: return XRT_COMPARE_OP_NEVER_FB; - case XR_COMPARE_OP_LESS_FB: return XRT_COMPARE_OP_LESS_FB; - case XR_COMPARE_OP_EQUAL_FB: return XRT_COMPARE_OP_EQUAL_FB; - case XR_COMPARE_OP_LESS_OR_EQUAL_FB: return XRT_COMPARE_OP_LESS_OR_EQUAL_FB; - case XR_COMPARE_OP_GREATER_FB: return XRT_COMPARE_OP_GREATER_FB; - case XR_COMPARE_OP_NOT_EQUAL_FB: return XRT_COMPARE_OP_NOT_EQUAL_FB; - case XR_COMPARE_OP_GREATER_OR_EQUAL_FB: return XRT_COMPARE_OP_GREATER_OR_EQUAL_FB; - case XR_COMPARE_OP_ALWAYS_FB: return XRT_COMPARE_OP_ALWAYS_FB; - default: return XRT_COMPARE_OP_MAX_ENUM_FB; - } + switch (xr_compare_op) { + case XR_COMPARE_OP_NEVER_FB: return XRT_COMPARE_OP_NEVER_FB; + case XR_COMPARE_OP_LESS_FB: return XRT_COMPARE_OP_LESS_FB; + case XR_COMPARE_OP_EQUAL_FB: return XRT_COMPARE_OP_EQUAL_FB; + case XR_COMPARE_OP_LESS_OR_EQUAL_FB: return XRT_COMPARE_OP_LESS_OR_EQUAL_FB; + case XR_COMPARE_OP_GREATER_FB: return XRT_COMPARE_OP_GREATER_FB; + case XR_COMPARE_OP_NOT_EQUAL_FB: return XRT_COMPARE_OP_NOT_EQUAL_FB; + case XR_COMPARE_OP_GREATER_OR_EQUAL_FB: return XRT_COMPARE_OP_GREATER_OR_EQUAL_FB; + case XR_COMPARE_OP_ALWAYS_FB: return XRT_COMPARE_OP_ALWAYS_FB; + default: return XRT_COMPARE_OP_MAX_ENUM_FB; + } } static enum xrt_layer_eye_visibility @@ -299,17 +299,17 @@ static void fill_in_depth_test(struct oxr_session *sess, const XrCompositionLayerBaseHeader *layer, struct xrt_layer_data *data) { #ifdef OXR_HAVE_FB_composition_layer_depth_test - // Is the extension enabled? - if (!sess->sys->inst->extensions.FB_composition_layer_depth_test) { - return; - } - const XrCompositionLayerDepthTestFB *depthTest = OXR_GET_INPUT_FROM_CHAIN( - layer, (XrStructureType)XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB, XrCompositionLayerDepthTestFB); - if (depthTest != NULL) { + // Is the extension enabled? + if (!sess->sys->inst->extensions.FB_composition_layer_depth_test) { + return; + } + const XrCompositionLayerDepthTestFB *depthTest = OXR_GET_INPUT_FROM_CHAIN( + layer, (XrStructureType)XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB, XrCompositionLayerDepthTestFB); + if (depthTest != NULL) { data->flags |= XRT_LAYER_COMPOSITION_DEPTH_TEST; - data->depth_test.depth_mask = depthTest->depthMask; - data->depth_test.compare_op = convert_compare_op(depthTest->compareOp); - } + data->depth_test.depth_mask = depthTest->depthMask; + data->depth_test.compare_op = convert_compare_op(depthTest->compareOp); + } #endif // OXR_HAVE_FB_composition_layer_depth_test } @@ -1181,7 +1181,7 @@ submit_quad_layer(struct oxr_session *sess, fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)quad, &data); fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)quad, &data); fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)quad, &data); - fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)quad, &data); + fill_in_depth_test(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); @@ -1278,7 +1278,7 @@ submit_projection_layer(struct oxr_session *sess, if (d_scs[0] != NULL && d_scs[1] != NULL) { #ifdef OXR_HAVE_KHR_composition_layer_depth - fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)proj, &data); + fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)proj, &data); data.type = XRT_LAYER_STEREO_PROJECTION_DEPTH; xrt_result_t xret = xrt_comp_layer_stereo_projection_depth( // xc, // compositor @@ -1337,7 +1337,7 @@ submit_cube_layer(struct oxr_session *sess, fill_in_color_scale_bias(sess, (XrCompositionLayerBaseHeader *)cube, &data); fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)cube, &data); fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)cube, &data); - fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)cube, &data); + fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)cube, &data); struct xrt_pose pose = { .orientation = @@ -1404,7 +1404,7 @@ submit_cylinder_layer(struct oxr_session *sess, fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); - fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); + fill_in_depth_test(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); @@ -1452,7 +1452,7 @@ submit_equirect1_layer(struct oxr_session *sess, fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)equirect, &data); fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)equirect, &data); fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)equirect, &data); - fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)equirect, &data); + fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)equirect, &data); struct xrt_vec2 *scale = (struct xrt_vec2 *)&equirect->scale; struct xrt_vec2 *bias = (struct xrt_vec2 *)&equirect->bias; @@ -1518,7 +1518,7 @@ submit_equirect2_layer(struct oxr_session *sess, fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)equirect, &data); fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)equirect, &data); fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)equirect, &data); - fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)equirect, &data); + fill_in_depth_test(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);