c/client: Implement XR_FB_passthrough APIs in client side

This commit is contained in:
dengkail 2024-02-29 11:15:59 +08:00
parent c57976c2af
commit 6c03327253
4 changed files with 179 additions and 0 deletions

View file

@ -461,6 +461,34 @@ try {
return XRT_ERROR_ALLOCATION;
}
static xrt_result_t
client_d3d11_compositor_passthrough_create(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
{
struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_create_passthrough(&c->xcn->base, info);
}
static xrt_result_t
client_d3d11_compositor_passthrough_layer_create(struct xrt_compositor *xc,
const struct xrt_passthrough_layer_create_info *info)
{
struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_create_passthrough_layer(&c->xcn->base, info);
}
static xrt_result_t
client_d3d11_compositor_passthrough_destroy(struct xrt_compositor *xc)
{
struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_destroy_passthrough(&c->xcn->base);
}
/*
*
* Compositor functions.
@ -645,6 +673,19 @@ client_d3d11_compositor_layer_equirect2(struct xrt_compositor *xc,
return xrt_comp_layer_equirect2(&c->xcn->base, xdev, xscfb, data);
}
static xrt_result_t
client_d3d11_compositor_layer_passthrough(struct xrt_compositor *xc,
struct xrt_device *xdev,
const struct xrt_layer_data *data)
{
struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc);
assert(data->type == XRT_LAYER_PASSTHROUGH);
// No flip required: D3D11 swapchain image convention matches Vulkan.
return xrt_comp_layer_passthrough(&c->xcn->base, xdev, data);
}
static xrt_result_t
client_d3d11_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
{
@ -829,6 +870,9 @@ try {
}
c->base.base.get_swapchain_create_properties = client_d3d11_compositor_get_swapchain_create_properties;
c->base.base.create_swapchain = client_d3d11_create_swapchain;
c->base.base.create_passthrough = client_d3d11_compositor_passthrough_create;
c->base.base.create_passthrough_layer = client_d3d11_compositor_passthrough_layer_create;
c->base.base.destroy_passthrough = client_d3d11_compositor_passthrough_destroy;
c->base.base.begin_session = client_d3d11_compositor_begin_session;
c->base.base.end_session = client_d3d11_compositor_end_session;
c->base.base.wait_frame = client_d3d11_compositor_wait_frame;
@ -842,6 +886,7 @@ try {
c->base.base.layer_cylinder = client_d3d11_compositor_layer_cylinder;
c->base.base.layer_equirect1 = client_d3d11_compositor_layer_equirect1;
c->base.base.layer_equirect2 = client_d3d11_compositor_layer_equirect2;
c->base.base.layer_passthrough = client_d3d11_compositor_layer_passthrough;
c->base.base.layer_commit = client_d3d11_compositor_layer_commit;
c->base.base.destroy = client_d3d11_compositor_destroy;

View file

@ -690,6 +690,33 @@ try {
return XRT_ERROR_ALLOCATION;
}
static xrt_result_t
client_d3d12_compositor_passthrough_create(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
{
struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_create_passthrough(&c->xcn->base, info);
}
static xrt_result_t
client_d3d12_compositor_passthrough_layer_create(struct xrt_compositor *xc,
const struct xrt_passthrough_layer_create_info *info)
{
struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_create_passthrough_layer(&c->xcn->base, info);
}
static xrt_result_t
client_d3d12_compositor_passthrough_destroy(struct xrt_compositor *xc)
{
struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_destroy_passthrough(&c->xcn->base);
}
/*
*
@ -899,6 +926,19 @@ client_d3d12_compositor_layer_equirect2(struct xrt_compositor *xc,
return xrt_comp_layer_equirect2(&c->xcn->base, xdev, xscfb, &d);
}
static xrt_result_t
client_d3d12_compositor_layer_passthrough(struct xrt_compositor *xc,
struct xrt_device *xdev,
const struct xrt_layer_data *data)
{
struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc);
assert(data->type == XRT_LAYER_PASSTHROUGH);
// No flip required: D3D12 swapchain image convention matches Vulkan.
return xrt_comp_layer_passthrough(&c->xcn->base, xdev, data);
}
static xrt_result_t
client_d3d12_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
{
@ -1088,6 +1128,9 @@ try {
}
c->base.base.get_swapchain_create_properties = client_d3d12_compositor_get_swapchain_create_properties;
c->base.base.create_swapchain = client_d3d12_create_swapchain;
c->base.base.create_passthrough = client_d3d12_compositor_passthrough_create;
c->base.base.create_passthrough_layer = client_d3d12_compositor_passthrough_layer_create;
c->base.base.destroy_passthrough = client_d3d12_compositor_passthrough_destroy;
c->base.base.begin_session = client_d3d12_compositor_begin_session;
c->base.base.end_session = client_d3d12_compositor_end_session;
c->base.base.wait_frame = client_d3d12_compositor_wait_frame;
@ -1101,6 +1144,7 @@ try {
c->base.base.layer_cylinder = client_d3d12_compositor_layer_cylinder;
c->base.base.layer_equirect1 = client_d3d12_compositor_layer_equirect1;
c->base.base.layer_equirect2 = client_d3d12_compositor_layer_equirect2;
c->base.base.layer_passthrough = client_d3d12_compositor_layer_passthrough;
c->base.base.layer_commit = client_d3d12_compositor_layer_commit;
c->base.base.destroy = client_d3d12_compositor_destroy;

View file

@ -380,6 +380,21 @@ client_gl_compositor_layer_equirect2(struct xrt_compositor *xc,
return xrt_comp_layer_equirect2(xcn, xdev, xscfb, &d);
}
static xrt_result_t
client_gl_compositor_layer_passthrough(struct xrt_compositor *xc,
struct xrt_device *xdev,
const struct xrt_layer_data *data)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
assert(data->type == XRT_LAYER_PASSTHROUGH);
struct xrt_layer_data d = *data;
d.flip_y = !d.flip_y;
return xrt_comp_layer_passthrough(&c->xcn->base, xdev, &d);
}
static xrt_result_t
client_gl_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
{
@ -529,6 +544,34 @@ client_gl_swapchain_create(struct xrt_compositor *xc,
return XRT_SUCCESS;
}
static xrt_result_t
client_gl_compositor_passthrough_create(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_create_passthrough(&c->xcn->base, info);
}
static xrt_result_t
client_gl_compositor_passthrough_layer_create(struct xrt_compositor *xc,
const struct xrt_passthrough_layer_create_info *info)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_create_passthrough_layer(&c->xcn->base, info);
}
static xrt_result_t
client_gl_compositor_passthrough_destroy(struct xrt_compositor *xc)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_destroy_passthrough(&c->xcn->base);
}
static void
client_gl_compositor_destroy(struct xrt_compositor *xc)
{
@ -561,6 +604,9 @@ client_gl_compositor_init(struct client_gl_compositor *c,
c->base.base.get_swapchain_create_properties = client_gl_compositor_get_swapchain_create_properties;
c->base.base.create_swapchain = client_gl_swapchain_create;
c->base.base.create_passthrough = client_gl_compositor_passthrough_create;
c->base.base.create_passthrough_layer = client_gl_compositor_passthrough_layer_create;
c->base.base.destroy_passthrough = client_gl_compositor_passthrough_destroy;
c->base.base.begin_session = client_gl_compositor_begin_session;
c->base.base.end_session = client_gl_compositor_end_session;
c->base.base.wait_frame = client_gl_compositor_wait_frame;
@ -574,6 +620,7 @@ client_gl_compositor_init(struct client_gl_compositor *c,
c->base.base.layer_cylinder = client_gl_compositor_layer_cylinder;
c->base.base.layer_equirect1 = client_gl_compositor_layer_equirect1;
c->base.base.layer_equirect2 = client_gl_compositor_layer_equirect2;
c->base.base.layer_passthrough = client_gl_compositor_layer_passthrough;
c->base.base.layer_commit = client_gl_compositor_layer_commit;
c->base.base.destroy = client_gl_compositor_destroy;
c->context_begin_locked = context_begin_locked;

View file

@ -353,6 +353,33 @@ client_vk_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
return xrt_swapchain_release_image(to_native_swapchain(xsc), index);
}
static xrt_result_t
client_vk_compositor_passthrough_create(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_create_passthrough(&c->xcn->base, info);
}
static xrt_result_t
client_vk_compositor_passthrough_layer_create(struct xrt_compositor *xc,
const struct xrt_passthrough_layer_create_info *info)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_create_passthrough_layer(&c->xcn->base, info);
}
static xrt_result_t
client_vk_compositor_passthrough_destroy(struct xrt_compositor *xc)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_destroy_passthrough(&c->xcn->base);
}
/*
*
@ -578,6 +605,18 @@ client_vk_compositor_layer_equirect2(struct xrt_compositor *xc,
return xrt_comp_layer_equirect2(xcn, xdev, xscfb, data);
}
static xrt_result_t
client_vk_compositor_layer_passthrough(struct xrt_compositor *xc,
struct xrt_device *xdev,
const struct xrt_layer_data *data)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
assert(data->type == XRT_LAYER_PASSTHROUGH);
return xrt_comp_layer_passthrough(&c->xcn->base, xdev, data);
}
static xrt_result_t
client_vk_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
{
@ -794,6 +833,9 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn,
c->base.base.get_swapchain_create_properties = client_vk_compositor_get_swapchain_create_properties;
c->base.base.create_swapchain = client_vk_swapchain_create;
c->base.base.create_passthrough = client_vk_compositor_passthrough_create;
c->base.base.create_passthrough_layer = client_vk_compositor_passthrough_layer_create;
c->base.base.destroy_passthrough = client_vk_compositor_passthrough_destroy;
c->base.base.begin_session = client_vk_compositor_begin_session;
c->base.base.end_session = client_vk_compositor_end_session;
c->base.base.wait_frame = client_vk_compositor_wait_frame;
@ -807,6 +849,7 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn,
c->base.base.layer_cylinder = client_vk_compositor_layer_cylinder;
c->base.base.layer_equirect1 = client_vk_compositor_layer_equirect1;
c->base.base.layer_equirect2 = client_vk_compositor_layer_equirect2;
c->base.base.layer_passthrough = client_vk_compositor_layer_passthrough;
c->base.base.layer_commit = client_vk_compositor_layer_commit;
c->base.base.destroy = client_vk_compositor_destroy;