The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/oxr: Add extension XR_FB_composition_layer_depth_test

authored by

Pingping Meng and committed by
pingping meng
fd816c83 fcdc2064

+88
+4
CMakeLists.txt
··· 419 419 if(NOT DEFINED XRT_FEATURE_OPENXR_LAYER_FB_SETTINGS) 420 420 set(XRT_FEATURE_OPENXR_LAYER_FB_SETTINGS OFF) 421 421 endif() 422 + if(NOT DEFINED XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST) 423 + set(XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST OFF) 424 + endif() 422 425 423 426 # Defaults for OpenXR spaces 424 427 if(NOT DEFINED XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR) ··· 631 634 message(STATUS "# FEATURE_OPENXR_LAYER_FB_ALPHA_BLEND: ${XRT_FEATURE_OPENXR_LAYER_FB_ALPHA_BLEND}") 632 635 message(STATUS "# FEATURE_OPENXR_LAYER_FB_IMAGE_LAYOUT ${XRT_FEATURE_OPENXR_LAYER_FB_IMAGE_LAYOUT}") 633 636 message(STATUS "# FEATURE_OPENXR_LAYER_FB_SETTINGS: ${XRT_FEATURE_OPENXR_LAYER_FB_SETTINGS}") 637 + message(STATUS "# FEATURE_OPENXR_LAYER_FB_DEPTH_TEST: ${XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST}") 634 638 message(STATUS "# FEATURE_OPENXR_OVERLAY: ${XRT_FEATURE_OPENXR_OVERLAY}") 635 639 message(STATUS "# FEATURE_OPENXR_PERFORMANCE_SETTINGS: ${XRT_FEATURE_OPENXR_PERFORMANCE_SETTINGS}") 636 640 message(STATUS "# FEATURE_OPENXR_SPACE_LOCAL_FLOOR: ${XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR}")
+1
scripts/generate_oxr_ext_support.py
··· 68 68 ['XR_FB_composition_layer_alpha_blend', 'XRT_FEATURE_OPENXR_LAYER_FB_ALPHA_BLEND'], 69 69 ['XR_FB_composition_layer_image_layout', 'XRT_FEATURE_OPENXR_LAYER_FB_IMAGE_LAYOUT'], 70 70 ['XR_FB_composition_layer_settings', 'XRT_FEATURE_OPENXR_LAYER_FB_SETTINGS'], 71 + ['XR_FB_composition_layer_depth_test', 'XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST'], 71 72 ['XR_FB_display_refresh_rate', 'XRT_FEATURE_OPENXR_DISPLAY_REFRESH_RATE'], 72 73 ['XR_ML_ml2_controller_interaction', 'XRT_FEATURE_OPENXR_INTERACTION_ML2'], 73 74 ['XR_MND_headless', 'XRT_FEATURE_OPENXR_HEADLESS'],
+33
src/xrt/include/xrt/xrt_compositor.h
··· 123 123 * see @p XrCompositionLayerAlphaBlendFB. 124 124 */ 125 125 XRT_LAYER_COMPOSITION_ADVANCED_BLENDING_BIT = 1u << 9u, 126 + 127 + /*! 128 + * Depth testing is requested when composing this layer if this flag is set, 129 + * see XrCompositionLayerDepthTestFB. 130 + */ 131 + XRT_LAYER_COMPOSITION_DEPTH_TEST = 1u << 10u, 132 + }; 133 + 134 + /*! 135 + * XrCompareOpFB 136 + */ 137 + enum xrt_compare_op_fb 138 + { 139 + XRT_COMPARE_OP_NEVER_FB = 0, 140 + XRT_COMPARE_OP_LESS_FB = 1, 141 + XRT_COMPARE_OP_EQUAL_FB = 2, 142 + XRT_COMPARE_OP_LESS_OR_EQUAL_FB = 3, 143 + XRT_COMPARE_OP_GREATER_FB = 4, 144 + XRT_COMPARE_OP_NOT_EQUAL_FB = 5, 145 + XRT_COMPARE_OP_GREATER_OR_EQUAL_FB = 6, 146 + XRT_COMPARE_OP_ALWAYS_FB = 7, 147 + XRT_COMPARE_OP_MAX_ENUM_FB = 0x7FFFFFFF 126 148 }; 127 149 128 150 /*! ··· 225 247 float max_depth; 226 248 float near_z; 227 249 float far_z; 250 + }; 251 + 252 + struct xrt_layer_depth_test_data 253 + { 254 + bool depth_mask; 255 + enum xrt_compare_op_fb compare_op; 228 256 }; 229 257 230 258 /*! ··· 357 385 * Composition flags 358 386 */ 359 387 enum xrt_layer_composition_flags flags; 388 + 389 + /*! 390 + * Depth test data 391 + */ 392 + struct xrt_layer_depth_test_data depth_test; 360 393 361 394 /*! 362 395 * Whether the main compositor should flip the direction of y when
+1
src/xrt/include/xrt/xrt_config_build.h.cmake_in
··· 49 49 #cmakedefine XRT_FEATURE_OPENXR_LAYER_FB_ALPHA_BLEND 50 50 #cmakedefine XRT_FEATURE_OPENXR_LAYER_FB_IMAGE_LAYOUT 51 51 #cmakedefine XRT_FEATURE_OPENXR_LAYER_FB_SETTINGS 52 + #cmakedefine XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST 52 53 #cmakedefine XRT_FEATURE_OPENXR_OVERLAY 53 54 #cmakedefine XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR 54 55 #cmakedefine XRT_FEATURE_OPENXR_SPACE_UNBOUNDED
+10
src/xrt/state_trackers/oxr/oxr_extension_support.h
··· 418 418 #define OXR_EXTENSION_SUPPORT_FB_composition_layer_settings(_) 419 419 #endif 420 420 421 + /* 422 + * XR_FB_composition_layer_depth_test 423 + */ 424 + #if defined(XR_FB_composition_layer_depth_test) && defined(XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST) 425 + #define OXR_HAVE_FB_composition_layer_depth_test 426 + #define OXR_EXTENSION_SUPPORT_FB_composition_layer_depth_test(_) _(FB_composition_layer_depth_test, FB_COMPOSITION_LAYER_DEPTH_TEST) 427 + #else 428 + #define OXR_EXTENSION_SUPPORT_FB_composition_layer_depth_test(_) 429 + #endif 421 430 422 431 /* 423 432 * XR_FB_display_refresh_rate ··· 636 645 OXR_EXTENSION_SUPPORT_FB_composition_layer_alpha_blend(_) \ 637 646 OXR_EXTENSION_SUPPORT_FB_composition_layer_image_layout(_) \ 638 647 OXR_EXTENSION_SUPPORT_FB_composition_layer_settings(_) \ 648 + OXR_EXTENSION_SUPPORT_FB_composition_layer_depth_test(_) \ 639 649 OXR_EXTENSION_SUPPORT_FB_display_refresh_rate(_) \ 640 650 OXR_EXTENSION_SUPPORT_ML_ml2_controller_interaction(_) \ 641 651 OXR_EXTENSION_SUPPORT_MND_headless(_) \
+39
src/xrt/state_trackers/oxr/oxr_session_frame_end.c
··· 129 129 return flags; 130 130 } 131 131 132 + static enum xrt_compare_op_fb 133 + convert_compare_op(XrCompareOpFB xr_compare_op) 134 + { 135 + switch (xr_compare_op) { 136 + case XR_COMPARE_OP_NEVER_FB: return XRT_COMPARE_OP_NEVER_FB; 137 + case XR_COMPARE_OP_LESS_FB: return XRT_COMPARE_OP_LESS_FB; 138 + case XR_COMPARE_OP_EQUAL_FB: return XRT_COMPARE_OP_EQUAL_FB; 139 + case XR_COMPARE_OP_LESS_OR_EQUAL_FB: return XRT_COMPARE_OP_LESS_OR_EQUAL_FB; 140 + case XR_COMPARE_OP_GREATER_FB: return XRT_COMPARE_OP_GREATER_FB; 141 + case XR_COMPARE_OP_NOT_EQUAL_FB: return XRT_COMPARE_OP_NOT_EQUAL_FB; 142 + case XR_COMPARE_OP_GREATER_OR_EQUAL_FB: return XRT_COMPARE_OP_GREATER_OR_EQUAL_FB; 143 + case XR_COMPARE_OP_ALWAYS_FB: return XRT_COMPARE_OP_ALWAYS_FB; 144 + default: return XRT_COMPARE_OP_MAX_ENUM_FB; 145 + } 146 + } 147 + 132 148 static enum xrt_layer_eye_visibility 133 149 convert_eye_visibility(XrSwapchainUsageFlags xr_visibility) 134 150 { ··· 279 295 #endif // OXR_HAVE_FB_composition_layer_settings 280 296 } 281 297 298 + static void 299 + fill_in_depth_test(struct oxr_session *sess, const XrCompositionLayerBaseHeader *layer, struct xrt_layer_data *data) 300 + { 301 + #ifdef OXR_HAVE_FB_composition_layer_depth_test 302 + // Is the extension enabled? 303 + if (!sess->sys->inst->extensions.FB_composition_layer_depth_test) { 304 + return; 305 + } 306 + const XrCompositionLayerDepthTestFB *depthTest = OXR_GET_INPUT_FROM_CHAIN( 307 + layer, (XrStructureType)XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB, XrCompositionLayerDepthTestFB); 308 + if (depthTest != NULL) { 309 + data->flags |= XRT_LAYER_COMPOSITION_DEPTH_TEST; 310 + data->depth_test.depth_mask = depthTest->depthMask; 311 + data->depth_test.compare_op = convert_compare_op(depthTest->compareOp); 312 + } 313 + #endif // OXR_HAVE_FB_composition_layer_depth_test 314 + } 282 315 283 316 /* 284 317 * ··· 1148 1181 fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)quad, &data); 1149 1182 fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)quad, &data); 1150 1183 fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)quad, &data); 1184 + fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)quad, &data); 1151 1185 1152 1186 xrt_result_t xret = xrt_comp_layer_quad(xc, head, sc->swapchain, &data); 1153 1187 OXR_CHECK_XRET(log, sess, xret, xrt_comp_layer_quad); ··· 1244 1278 1245 1279 if (d_scs[0] != NULL && d_scs[1] != NULL) { 1246 1280 #ifdef OXR_HAVE_KHR_composition_layer_depth 1281 + fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)proj, &data); 1247 1282 data.type = XRT_LAYER_STEREO_PROJECTION_DEPTH; 1248 1283 xrt_result_t xret = xrt_comp_layer_stereo_projection_depth( // 1249 1284 xc, // compositor ··· 1302 1337 fill_in_color_scale_bias(sess, (XrCompositionLayerBaseHeader *)cube, &data); 1303 1338 fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)cube, &data); 1304 1339 fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)cube, &data); 1340 + fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)cube, &data); 1305 1341 1306 1342 struct xrt_pose pose = { 1307 1343 .orientation = ··· 1368 1404 fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); 1369 1405 fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); 1370 1406 fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); 1407 + fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)cylinder, &data); 1371 1408 1372 1409 xrt_result_t xret = xrt_comp_layer_cylinder(xc, head, sc->swapchain, &data); 1373 1410 OXR_CHECK_XRET(log, sess, xret, xrt_comp_layer_cylinder); ··· 1415 1452 fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)equirect, &data); 1416 1453 fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)equirect, &data); 1417 1454 fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)equirect, &data); 1455 + fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)equirect, &data); 1418 1456 1419 1457 struct xrt_vec2 *scale = (struct xrt_vec2 *)&equirect->scale; 1420 1458 struct xrt_vec2 *bias = (struct xrt_vec2 *)&equirect->bias; ··· 1480 1518 fill_in_y_flip(sess, (XrCompositionLayerBaseHeader *)equirect, &data); 1481 1519 fill_in_blend_factors(sess, (XrCompositionLayerBaseHeader *)equirect, &data); 1482 1520 fill_in_layer_settings(sess, (XrCompositionLayerBaseHeader *)equirect, &data); 1521 + fill_in_depth_test(sess, (XrCompositionLayerBaseHeader *)equirect, &data); 1483 1522 1484 1523 xrt_result_t xret = xrt_comp_layer_equirect2(xc, head, sc->swapchain, &data); 1485 1524 OXR_CHECK_XRET(log, sess, xret, xrt_comp_layer_equirect2);