The open source OpenXR runtime

c/client: Implement XR_FB_passthrough APIs in client side

dengkail 6c033272 c57976c2

+179
+45
src/xrt/compositor/client/comp_d3d11_client.cpp
··· 461 461 return XRT_ERROR_ALLOCATION; 462 462 } 463 463 464 + static xrt_result_t 465 + client_d3d11_compositor_passthrough_create(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info) 466 + { 467 + struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc); 468 + 469 + // Pipe down call into native compositor. 470 + return xrt_comp_create_passthrough(&c->xcn->base, info); 471 + } 472 + 473 + static xrt_result_t 474 + client_d3d11_compositor_passthrough_layer_create(struct xrt_compositor *xc, 475 + const struct xrt_passthrough_layer_create_info *info) 476 + { 477 + struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc); 478 + 479 + // Pipe down call into native compositor. 480 + return xrt_comp_create_passthrough_layer(&c->xcn->base, info); 481 + } 482 + 483 + static xrt_result_t 484 + client_d3d11_compositor_passthrough_destroy(struct xrt_compositor *xc) 485 + { 486 + struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc); 487 + 488 + // Pipe down call into native compositor. 489 + return xrt_comp_destroy_passthrough(&c->xcn->base); 490 + } 491 + 464 492 /* 465 493 * 466 494 * Compositor functions. ··· 646 674 } 647 675 648 676 static xrt_result_t 677 + client_d3d11_compositor_layer_passthrough(struct xrt_compositor *xc, 678 + struct xrt_device *xdev, 679 + const struct xrt_layer_data *data) 680 + { 681 + struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc); 682 + 683 + assert(data->type == XRT_LAYER_PASSTHROUGH); 684 + 685 + // No flip required: D3D11 swapchain image convention matches Vulkan. 686 + return xrt_comp_layer_passthrough(&c->xcn->base, xdev, data); 687 + } 688 + 689 + static xrt_result_t 649 690 client_d3d11_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle) 650 691 { 651 692 struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc); ··· 829 870 } 830 871 c->base.base.get_swapchain_create_properties = client_d3d11_compositor_get_swapchain_create_properties; 831 872 c->base.base.create_swapchain = client_d3d11_create_swapchain; 873 + c->base.base.create_passthrough = client_d3d11_compositor_passthrough_create; 874 + c->base.base.create_passthrough_layer = client_d3d11_compositor_passthrough_layer_create; 875 + c->base.base.destroy_passthrough = client_d3d11_compositor_passthrough_destroy; 832 876 c->base.base.begin_session = client_d3d11_compositor_begin_session; 833 877 c->base.base.end_session = client_d3d11_compositor_end_session; 834 878 c->base.base.wait_frame = client_d3d11_compositor_wait_frame; ··· 842 886 c->base.base.layer_cylinder = client_d3d11_compositor_layer_cylinder; 843 887 c->base.base.layer_equirect1 = client_d3d11_compositor_layer_equirect1; 844 888 c->base.base.layer_equirect2 = client_d3d11_compositor_layer_equirect2; 889 + c->base.base.layer_passthrough = client_d3d11_compositor_layer_passthrough; 845 890 c->base.base.layer_commit = client_d3d11_compositor_layer_commit; 846 891 c->base.base.destroy = client_d3d11_compositor_destroy; 847 892
+44
src/xrt/compositor/client/comp_d3d12_client.cpp
··· 690 690 return XRT_ERROR_ALLOCATION; 691 691 } 692 692 693 + static xrt_result_t 694 + client_d3d12_compositor_passthrough_create(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info) 695 + { 696 + struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc); 697 + 698 + // Pipe down call into native compositor. 699 + return xrt_comp_create_passthrough(&c->xcn->base, info); 700 + } 701 + 702 + static xrt_result_t 703 + client_d3d12_compositor_passthrough_layer_create(struct xrt_compositor *xc, 704 + const struct xrt_passthrough_layer_create_info *info) 705 + { 706 + struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc); 707 + 708 + // Pipe down call into native compositor. 709 + return xrt_comp_create_passthrough_layer(&c->xcn->base, info); 710 + } 711 + 712 + static xrt_result_t 713 + client_d3d12_compositor_passthrough_destroy(struct xrt_compositor *xc) 714 + { 715 + struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc); 716 + 717 + // Pipe down call into native compositor. 718 + return xrt_comp_destroy_passthrough(&c->xcn->base); 719 + } 693 720 694 721 /* 695 722 * ··· 900 927 } 901 928 902 929 static xrt_result_t 930 + client_d3d12_compositor_layer_passthrough(struct xrt_compositor *xc, 931 + struct xrt_device *xdev, 932 + const struct xrt_layer_data *data) 933 + { 934 + struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc); 935 + 936 + assert(data->type == XRT_LAYER_PASSTHROUGH); 937 + 938 + // No flip required: D3D12 swapchain image convention matches Vulkan. 939 + return xrt_comp_layer_passthrough(&c->xcn->base, xdev, data); 940 + } 941 + 942 + static xrt_result_t 903 943 client_d3d12_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle) 904 944 { 905 945 struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc); ··· 1088 1128 } 1089 1129 c->base.base.get_swapchain_create_properties = client_d3d12_compositor_get_swapchain_create_properties; 1090 1130 c->base.base.create_swapchain = client_d3d12_create_swapchain; 1131 + c->base.base.create_passthrough = client_d3d12_compositor_passthrough_create; 1132 + c->base.base.create_passthrough_layer = client_d3d12_compositor_passthrough_layer_create; 1133 + c->base.base.destroy_passthrough = client_d3d12_compositor_passthrough_destroy; 1091 1134 c->base.base.begin_session = client_d3d12_compositor_begin_session; 1092 1135 c->base.base.end_session = client_d3d12_compositor_end_session; 1093 1136 c->base.base.wait_frame = client_d3d12_compositor_wait_frame; ··· 1101 1144 c->base.base.layer_cylinder = client_d3d12_compositor_layer_cylinder; 1102 1145 c->base.base.layer_equirect1 = client_d3d12_compositor_layer_equirect1; 1103 1146 c->base.base.layer_equirect2 = client_d3d12_compositor_layer_equirect2; 1147 + c->base.base.layer_passthrough = client_d3d12_compositor_layer_passthrough; 1104 1148 c->base.base.layer_commit = client_d3d12_compositor_layer_commit; 1105 1149 c->base.base.destroy = client_d3d12_compositor_destroy; 1106 1150
+47
src/xrt/compositor/client/comp_gl_client.c
··· 381 381 } 382 382 383 383 static xrt_result_t 384 + client_gl_compositor_layer_passthrough(struct xrt_compositor *xc, 385 + struct xrt_device *xdev, 386 + const struct xrt_layer_data *data) 387 + { 388 + struct client_gl_compositor *c = client_gl_compositor(xc); 389 + 390 + assert(data->type == XRT_LAYER_PASSTHROUGH); 391 + 392 + struct xrt_layer_data d = *data; 393 + d.flip_y = !d.flip_y; 394 + 395 + return xrt_comp_layer_passthrough(&c->xcn->base, xdev, &d); 396 + } 397 + 398 + static xrt_result_t 384 399 client_gl_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle) 385 400 { 386 401 COMP_TRACE_MARKER(); ··· 529 544 return XRT_SUCCESS; 530 545 } 531 546 547 + static xrt_result_t 548 + client_gl_compositor_passthrough_create(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info) 549 + { 550 + struct client_gl_compositor *c = client_gl_compositor(xc); 551 + 552 + // Pipe down call into native compositor. 553 + return xrt_comp_create_passthrough(&c->xcn->base, info); 554 + } 555 + 556 + static xrt_result_t 557 + client_gl_compositor_passthrough_layer_create(struct xrt_compositor *xc, 558 + const struct xrt_passthrough_layer_create_info *info) 559 + { 560 + struct client_gl_compositor *c = client_gl_compositor(xc); 561 + 562 + // Pipe down call into native compositor. 563 + return xrt_comp_create_passthrough_layer(&c->xcn->base, info); 564 + } 565 + 566 + static xrt_result_t 567 + client_gl_compositor_passthrough_destroy(struct xrt_compositor *xc) 568 + { 569 + struct client_gl_compositor *c = client_gl_compositor(xc); 570 + 571 + // Pipe down call into native compositor. 572 + return xrt_comp_destroy_passthrough(&c->xcn->base); 573 + } 574 + 532 575 static void 533 576 client_gl_compositor_destroy(struct xrt_compositor *xc) 534 577 { ··· 561 604 562 605 c->base.base.get_swapchain_create_properties = client_gl_compositor_get_swapchain_create_properties; 563 606 c->base.base.create_swapchain = client_gl_swapchain_create; 607 + c->base.base.create_passthrough = client_gl_compositor_passthrough_create; 608 + c->base.base.create_passthrough_layer = client_gl_compositor_passthrough_layer_create; 609 + c->base.base.destroy_passthrough = client_gl_compositor_passthrough_destroy; 564 610 c->base.base.begin_session = client_gl_compositor_begin_session; 565 611 c->base.base.end_session = client_gl_compositor_end_session; 566 612 c->base.base.wait_frame = client_gl_compositor_wait_frame; ··· 574 620 c->base.base.layer_cylinder = client_gl_compositor_layer_cylinder; 575 621 c->base.base.layer_equirect1 = client_gl_compositor_layer_equirect1; 576 622 c->base.base.layer_equirect2 = client_gl_compositor_layer_equirect2; 623 + c->base.base.layer_passthrough = client_gl_compositor_layer_passthrough; 577 624 c->base.base.layer_commit = client_gl_compositor_layer_commit; 578 625 c->base.base.destroy = client_gl_compositor_destroy; 579 626 c->context_begin_locked = context_begin_locked;
+43
src/xrt/compositor/client/comp_vk_client.c
··· 353 353 return xrt_swapchain_release_image(to_native_swapchain(xsc), index); 354 354 } 355 355 356 + static xrt_result_t 357 + client_vk_compositor_passthrough_create(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info) 358 + { 359 + struct client_vk_compositor *c = client_vk_compositor(xc); 360 + 361 + // Pipe down call into native compositor. 362 + return xrt_comp_create_passthrough(&c->xcn->base, info); 363 + } 364 + 365 + static xrt_result_t 366 + client_vk_compositor_passthrough_layer_create(struct xrt_compositor *xc, 367 + const struct xrt_passthrough_layer_create_info *info) 368 + { 369 + struct client_vk_compositor *c = client_vk_compositor(xc); 370 + 371 + // Pipe down call into native compositor. 372 + return xrt_comp_create_passthrough_layer(&c->xcn->base, info); 373 + } 374 + 375 + static xrt_result_t 376 + client_vk_compositor_passthrough_destroy(struct xrt_compositor *xc) 377 + { 378 + struct client_vk_compositor *c = client_vk_compositor(xc); 379 + 380 + // Pipe down call into native compositor. 381 + return xrt_comp_destroy_passthrough(&c->xcn->base); 382 + } 356 383 357 384 /* 358 385 * ··· 579 606 } 580 607 581 608 static xrt_result_t 609 + client_vk_compositor_layer_passthrough(struct xrt_compositor *xc, 610 + struct xrt_device *xdev, 611 + const struct xrt_layer_data *data) 612 + { 613 + struct client_vk_compositor *c = client_vk_compositor(xc); 614 + 615 + assert(data->type == XRT_LAYER_PASSTHROUGH); 616 + 617 + return xrt_comp_layer_passthrough(&c->xcn->base, xdev, data); 618 + } 619 + 620 + static xrt_result_t 582 621 client_vk_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle) 583 622 { 584 623 COMP_TRACE_MARKER(); ··· 794 833 795 834 c->base.base.get_swapchain_create_properties = client_vk_compositor_get_swapchain_create_properties; 796 835 c->base.base.create_swapchain = client_vk_swapchain_create; 836 + c->base.base.create_passthrough = client_vk_compositor_passthrough_create; 837 + c->base.base.create_passthrough_layer = client_vk_compositor_passthrough_layer_create; 838 + c->base.base.destroy_passthrough = client_vk_compositor_passthrough_destroy; 797 839 c->base.base.begin_session = client_vk_compositor_begin_session; 798 840 c->base.base.end_session = client_vk_compositor_end_session; 799 841 c->base.base.wait_frame = client_vk_compositor_wait_frame; ··· 807 849 c->base.base.layer_cylinder = client_vk_compositor_layer_cylinder; 808 850 c->base.base.layer_equirect1 = client_vk_compositor_layer_equirect1; 809 851 c->base.base.layer_equirect2 = client_vk_compositor_layer_equirect2; 852 + c->base.base.layer_passthrough = client_vk_compositor_layer_passthrough; 810 853 c->base.base.layer_commit = client_vk_compositor_layer_commit; 811 854 c->base.base.destroy = client_vk_compositor_destroy; 812 855