xrt: Rename references to compositor/swapchain/image_fd to ..._native.

Reflecting that the native buffer isn't an FD on all platforms.
This commit is contained in:
Ryan Pavlik 2020-07-14 17:13:07 -05:00
parent 92e4b24b8f
commit 54f56716fd
31 changed files with 290 additions and 279 deletions

View file

@ -265,16 +265,16 @@ vk_create_image_simple(struct vk_bundle *vk,
} }
VkResult VkResult
vk_create_image_from_fd(struct vk_bundle *vk, vk_create_image_from_native(struct vk_bundle *vk,
enum xrt_swapchain_usage_bits swapchain_usage, enum xrt_swapchain_usage_bits swapchain_usage,
int64_t format, int64_t format,
uint32_t width, uint32_t width,
uint32_t height, uint32_t height,
uint32_t array_size, uint32_t array_size,
uint32_t mip_count, uint32_t mip_count,
struct xrt_image_fd *image_fd, struct xrt_image_native *image_native,
VkImage *out_image, VkImage *out_image,
VkDeviceMemory *out_mem) VkDeviceMemory *out_mem)
{ {
VkImageUsageFlags image_usage = VkImageUsageFlags image_usage =
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
@ -327,7 +327,7 @@ vk_create_image_from_fd(struct vk_bundle *vk,
VkImportMemoryFdInfoKHR import_memory_info = { VkImportMemoryFdInfoKHR import_memory_info = {
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR, .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR, .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
.fd = image_fd->fd, .fd = image_native->fd,
}; };
VkMemoryDedicatedAllocateInfoKHR dedicated_memory_info = { VkMemoryDedicatedAllocateInfoKHR dedicated_memory_info = {
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR, .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR,
@ -335,8 +335,9 @@ vk_create_image_from_fd(struct vk_bundle *vk,
.image = image, .image = image,
.buffer = VK_NULL_HANDLE, .buffer = VK_NULL_HANDLE,
}; };
ret = vk_alloc_and_bind_image_memory( ret = vk_alloc_and_bind_image_memory(vk, image, image_native->size,
vk, image, image_fd->size, &dedicated_memory_info, out_mem, NULL); &dedicated_memory_info, out_mem,
NULL);
if (ret != VK_SUCCESS) { if (ret != VK_SUCCESS) {
vk->vkDestroyImage(vk->device, image, NULL); vk->vkDestroyImage(vk->device, image, NULL);
return ret; return ret;

View file

@ -343,16 +343,16 @@ vk_alloc_and_bind_image_memory(struct vk_bundle *vk,
* @ingroup aux_vk * @ingroup aux_vk
*/ */
VkResult VkResult
vk_create_image_from_fd(struct vk_bundle *vk, vk_create_image_from_native(struct vk_bundle *vk,
enum xrt_swapchain_usage_bits swapchain_usage, enum xrt_swapchain_usage_bits swapchain_usage,
int64_t format, int64_t format,
uint32_t width, uint32_t width,
uint32_t height, uint32_t height,
uint32_t array_size, uint32_t array_size,
uint32_t mip_count, uint32_t mip_count,
struct xrt_image_fd *image_fd, struct xrt_image_native *image_native,
VkImage *out_image, VkImage *out_image,
VkDeviceMemory *out_mem); VkDeviceMemory *out_mem);
/*! /*!
* @ingroup aux_vk * @ingroup aux_vk

View file

@ -30,13 +30,13 @@ static void
client_egl_compositor_destroy(struct xrt_compositor *xc) client_egl_compositor_destroy(struct xrt_compositor *xc)
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
xrt_comp_fd_destroy(&c->xcfd); xrt_comp_native_destroy(&c->xcn);
free(c); free(c);
} }
struct xrt_compositor_gl * struct xrt_compositor_gl *
xrt_gfx_provider_create_gl_egl(struct xrt_compositor_fd *xcfd, xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn,
EGLDisplay display, EGLDisplay display,
EGLConfig config, EGLConfig config,
EGLContext context, EGLContext context,
@ -57,7 +57,7 @@ xrt_gfx_provider_create_gl_egl(struct xrt_compositor_fd *xcfd,
struct client_gl_compositor *c = struct client_gl_compositor *c =
U_TYPED_CALLOC(struct client_gl_compositor); U_TYPED_CALLOC(struct client_gl_compositor);
if (!client_gl_compositor_init(c, xcfd, getProcAddress)) { if (!client_gl_compositor_init(c, xcn, getProcAddress)) {
free(c); free(c);
fprintf(stderr, "Failed to initialize compositor\n"); fprintf(stderr, "Failed to initialize compositor\n");
return NULL; return NULL;

View file

@ -49,8 +49,8 @@ client_gl_swapchain_destroy(struct xrt_swapchain *xsc)
sc->base.base.num_images = 0; sc->base.base.num_images = 0;
} }
// Destroy the fd swapchain as well. // Destroy the native swapchain as well.
xrt_swapchain_destroy((struct xrt_swapchain **)&sc->xscfd); xrt_swapchain_destroy((struct xrt_swapchain **)&sc->xscn);
free(sc); free(sc);
} }
@ -61,8 +61,8 @@ client_gl_swapchain_acquire_image(struct xrt_swapchain *xsc,
{ {
struct client_gl_swapchain *sc = client_gl_swapchain(xsc); struct client_gl_swapchain *sc = client_gl_swapchain(xsc);
// Pipe down call into fd swapchain. // Pipe down call into native swapchain.
return xrt_swapchain_acquire_image(&sc->xscfd->base, out_index); return xrt_swapchain_acquire_image(&sc->xscn->base, out_index);
} }
static xrt_result_t static xrt_result_t
@ -72,8 +72,8 @@ client_gl_swapchain_wait_image(struct xrt_swapchain *xsc,
{ {
struct client_gl_swapchain *sc = client_gl_swapchain(xsc); struct client_gl_swapchain *sc = client_gl_swapchain(xsc);
// Pipe down call into fd swapchain. // Pipe down call into native swapchain.
return xrt_swapchain_wait_image(&sc->xscfd->base, timeout, index); return xrt_swapchain_wait_image(&sc->xscn->base, timeout, index);
} }
static xrt_result_t static xrt_result_t
@ -81,8 +81,8 @@ client_gl_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
{ {
struct client_gl_swapchain *sc = client_gl_swapchain(xsc); struct client_gl_swapchain *sc = client_gl_swapchain(xsc);
// Pipe down call into fd swapchain. // Pipe down call into native swapchain.
return xrt_swapchain_release_image(&sc->xscfd->base, index); return xrt_swapchain_release_image(&sc->xscn->base, index);
} }
@ -98,8 +98,8 @@ client_gl_compositor_prepare_session(struct xrt_compositor *xc,
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_prepare_session(&c->xcfd->base, xspi); return xrt_comp_prepare_session(&c->xcn->base, xspi);
} }
@ -109,8 +109,8 @@ client_gl_compositor_begin_session(struct xrt_compositor *xc,
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_begin_session(&c->xcfd->base, type); return xrt_comp_begin_session(&c->xcn->base, type);
} }
static xrt_result_t static xrt_result_t
@ -118,8 +118,8 @@ client_gl_compositor_end_session(struct xrt_compositor *xc)
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_end_session(&c->xcfd->base); return xrt_comp_end_session(&c->xcn->base);
} }
static xrt_result_t static xrt_result_t
@ -130,8 +130,8 @@ client_gl_compositor_wait_frame(struct xrt_compositor *xc,
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_wait_frame(&c->xcfd->base, out_frame_id, return xrt_comp_wait_frame(&c->xcn->base, out_frame_id,
predicted_display_time, predicted_display_time,
predicted_display_period); predicted_display_period);
} }
@ -141,8 +141,8 @@ client_gl_compositor_begin_frame(struct xrt_compositor *xc, int64_t frame_id)
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_begin_frame(&c->xcfd->base, frame_id); return xrt_comp_begin_frame(&c->xcn->base, frame_id);
} }
static xrt_result_t static xrt_result_t
@ -150,8 +150,8 @@ client_gl_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_discard_frame(&c->xcfd->base, frame_id); return xrt_comp_discard_frame(&c->xcn->base, frame_id);
} }
static xrt_result_t static xrt_result_t
@ -161,7 +161,7 @@ client_gl_compositor_layer_begin(struct xrt_compositor *xc,
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
return xrt_comp_layer_begin(&c->xcfd->base, frame_id, env_blend_mode); return xrt_comp_layer_begin(&c->xcn->base, frame_id, env_blend_mode);
} }
static xrt_result_t static xrt_result_t
@ -172,16 +172,16 @@ client_gl_compositor_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_layer_data *data) struct xrt_layer_data *data)
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain *l_xscfd, *r_xscfd; struct xrt_swapchain *l_xscn, *r_xscn;
assert(data->type == XRT_LAYER_STEREO_PROJECTION); assert(data->type == XRT_LAYER_STEREO_PROJECTION);
l_xscfd = &client_gl_swapchain(l_xsc)->xscfd->base; l_xscn = &client_gl_swapchain(l_xsc)->xscn->base;
r_xscfd = &client_gl_swapchain(r_xsc)->xscfd->base; r_xscn = &client_gl_swapchain(r_xsc)->xscn->base;
data->flip_y = true; data->flip_y = true;
return xrt_comp_layer_stereo_projection(&c->xcfd->base, xdev, l_xscfd, return xrt_comp_layer_stereo_projection(&c->xcn->base, xdev, l_xscn,
r_xscfd, data); r_xscn, data);
} }
static xrt_result_t static xrt_result_t
@ -195,10 +195,10 @@ client_gl_compositor_layer_quad(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_QUAD); assert(data->type == XRT_LAYER_QUAD);
xscfb = &client_gl_swapchain(xsc)->xscfd->base; xscfb = &client_gl_swapchain(xsc)->xscn->base;
data->flip_y = true; data->flip_y = true;
return xrt_comp_layer_quad(&c->xcfd->base, xdev, xscfb, data); return xrt_comp_layer_quad(&c->xcn->base, xdev, xscfb, data);
} }
static xrt_result_t static xrt_result_t
@ -206,7 +206,7 @@ client_gl_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id)
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
return xrt_comp_layer_commit(&c->xcfd->base, frame_id); return xrt_comp_layer_commit(&c->xcn->base, frame_id);
} }
static int64_t static int64_t
@ -264,14 +264,14 @@ client_gl_swapchain_create(struct xrt_compositor *xc,
struct xrt_swapchain_create_info vk_info = *info; struct xrt_swapchain_create_info vk_info = *info;
vk_info.format = vk_format; vk_info.format = vk_format;
struct xrt_swapchain_fd *xscfd = struct xrt_swapchain_native *xscn =
xrt_comp_fd_create_swapchain(c->xcfd, &vk_info); xrt_comp_native_create_swapchain(c->xcn, &vk_info);
if (xscfd == NULL) { if (xscn == NULL) {
return NULL; return NULL;
} }
struct xrt_swapchain *xsc = &xscfd->base; struct xrt_swapchain *xsc = &xscn->base;
struct client_gl_swapchain *sc = struct client_gl_swapchain *sc =
U_TYPED_CALLOC(struct client_gl_swapchain); U_TYPED_CALLOC(struct client_gl_swapchain);
@ -279,9 +279,9 @@ client_gl_swapchain_create(struct xrt_compositor *xc,
sc->base.base.acquire_image = client_gl_swapchain_acquire_image; sc->base.base.acquire_image = client_gl_swapchain_acquire_image;
sc->base.base.wait_image = client_gl_swapchain_wait_image; sc->base.base.wait_image = client_gl_swapchain_wait_image;
sc->base.base.release_image = client_gl_swapchain_release_image; sc->base.base.release_image = client_gl_swapchain_release_image;
// Fetch the number of images from the fd swapchain. // Fetch the number of images from the native swapchain.
sc->base.base.num_images = xsc->num_images; sc->base.base.num_images = xsc->num_images;
sc->xscfd = xscfd; sc->xscn = xscn;
GLuint prev_texture = 0; GLuint prev_texture = 0;
glGetIntegerv(info->array_size == 1 ? GL_TEXTURE_BINDING_2D glGetIntegerv(info->array_size == 1 ? GL_TEXTURE_BINDING_2D
@ -300,12 +300,12 @@ client_gl_swapchain_create(struct xrt_compositor *xc,
glMemoryObjectParameterivEXT(sc->base.memory[i], glMemoryObjectParameterivEXT(sc->base.memory[i],
GL_DEDICATED_MEMORY_OBJECT_EXT, GL_DEDICATED_MEMORY_OBJECT_EXT,
&dedicated); &dedicated);
glImportMemoryFdEXT(sc->base.memory[i], xscfd->images[i].size, glImportMemoryFdEXT(sc->base.memory[i], xscn->images[i].size,
GL_HANDLE_TYPE_OPAQUE_FD_EXT, GL_HANDLE_TYPE_OPAQUE_FD_EXT,
xscfd->images[i].fd); xscn->images[i].fd);
// We have consumed this fd now, make sure it's not freed again. // We have consumed this fd now, make sure it's not freed again.
xscfd->images[i].fd = -1; xscn->images[i].fd = -1;
if (info->array_size == 1) { if (info->array_size == 1) {
glTextureStorageMem2DEXT( glTextureStorageMem2DEXT(
@ -333,8 +333,8 @@ client_gl_compositor_poll_events(struct xrt_compositor *xc,
{ {
struct client_gl_compositor *c = client_gl_compositor(xc); struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_poll_events(&c->xcfd->base, out_xce); return xrt_comp_poll_events(&c->xcn->base, out_xce);
} }
static void static void
@ -345,7 +345,7 @@ client_gl_compositor_destroy(struct xrt_compositor *xc)
bool bool
client_gl_compositor_init(struct client_gl_compositor *c, client_gl_compositor_init(struct client_gl_compositor *c,
struct xrt_compositor_fd *xcfd, struct xrt_compositor_native *xcn,
client_gl_get_procaddr get_gl_procaddr) client_gl_get_procaddr get_gl_procaddr)
{ {
c->base.base.create_swapchain = client_gl_swapchain_create; c->base.base.create_swapchain = client_gl_swapchain_create;
@ -362,12 +362,12 @@ client_gl_compositor_init(struct client_gl_compositor *c,
c->base.base.layer_commit = client_gl_compositor_layer_commit; c->base.base.layer_commit = client_gl_compositor_layer_commit;
c->base.base.destroy = client_gl_compositor_destroy; c->base.base.destroy = client_gl_compositor_destroy;
c->base.base.poll_events = client_gl_compositor_poll_events; c->base.base.poll_events = client_gl_compositor_poll_events;
c->xcfd = xcfd; c->xcn = xcn;
// Passthrough our formats from the fd compositor to the client. // Passthrough our formats from the native compositor to the client.
size_t count = 0; size_t count = 0;
for (uint32_t i = 0; i < xcfd->base.num_formats; i++) { for (uint32_t i = 0; i < xcn->base.num_formats; i++) {
int64_t f = vk_format_to_gl(xcfd->base.formats[i]); int64_t f = vk_format_to_gl(xcn->base.formats[i]);
if (f == 0) { if (f == 0) {
continue; continue;
} }

View file

@ -36,7 +36,7 @@ struct client_gl_swapchain
{ {
struct xrt_swapchain_gl base; struct xrt_swapchain_gl base;
struct xrt_swapchain_fd *xscfd; struct xrt_swapchain_native *xscn;
}; };
/*! /*!
@ -51,7 +51,7 @@ struct client_gl_compositor
{ {
struct xrt_compositor_gl base; struct xrt_compositor_gl base;
struct xrt_compositor_fd *xcfd; struct xrt_compositor_native *xcn;
}; };
@ -82,14 +82,14 @@ typedef client_gl_void_ptr_func (*client_gl_get_procaddr)(const char *name);
* OpenGL can have multiple backing window systems we have to interact with, so * OpenGL can have multiple backing window systems we have to interact with, so
* there isn't just one unified OpenGL client constructor. * there isn't just one unified OpenGL client constructor.
* *
* Moves owenership of provided xcfd to the client_gl_compositor. * Moves ownership of provided xcn to the client_gl_compositor.
* *
* @public @memberof client_gl_compositor * @public @memberof client_gl_compositor
* @relatesalso xrt_compositor_fd * @relatesalso xrt_compositor_native
*/ */
bool bool
client_gl_compositor_init(struct client_gl_compositor *c, client_gl_compositor_init(struct client_gl_compositor *c,
struct xrt_compositor_fd *xcfd, struct xrt_compositor_native *xcn,
client_gl_get_procaddr get_gl_procaddr); client_gl_get_procaddr get_gl_procaddr);

View file

@ -32,8 +32,8 @@ static void
client_gl_xlib_compositor_destroy(struct xrt_compositor *xc) client_gl_xlib_compositor_destroy(struct xrt_compositor *xc)
{ {
struct client_gl_xlib_compositor *c = client_gl_xlib_compositor(xc); struct client_gl_xlib_compositor *c = client_gl_xlib_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
xrt_comp_fd_destroy(&c->base.xcfd); xrt_comp_native_destroy(&c->base.xcn);
free(c); free(c);
} }
@ -46,7 +46,7 @@ extern "C"
glXGetProcAddress(const char *procName); glXGetProcAddress(const char *procName);
struct client_gl_xlib_compositor * struct client_gl_xlib_compositor *
client_gl_xlib_compositor_create(struct xrt_compositor_fd *xcfd, client_gl_xlib_compositor_create(struct xrt_compositor_native *xcn,
Display *xDisplay, Display *xDisplay,
uint32_t visualid, uint32_t visualid,
GLXFBConfig glxFBConfig, GLXFBConfig glxFBConfig,
@ -56,7 +56,7 @@ client_gl_xlib_compositor_create(struct xrt_compositor_fd *xcfd,
struct client_gl_xlib_compositor *c = struct client_gl_xlib_compositor *c =
U_TYPED_CALLOC(struct client_gl_xlib_compositor); U_TYPED_CALLOC(struct client_gl_xlib_compositor);
if (!client_gl_compositor_init(&c->base, xcfd, glXGetProcAddress)) { if (!client_gl_compositor_init(&c->base, xcn, glXGetProcAddress)) {
free(c); free(c);
return NULL; return NULL;
} }

View file

@ -34,10 +34,10 @@ struct client_gl_xlib_compositor
* Create a new client_gl_xlib_compositor. * Create a new client_gl_xlib_compositor.
* *
* @public @memberof client_gl_xlib_compositor * @public @memberof client_gl_xlib_compositor
* @relatesalso xrt_compositor_fd * @relatesalso xrt_compositor_native
*/ */
struct client_gl_xlib_compositor * struct client_gl_xlib_compositor *
client_gl_xlib_compositor_create(struct xrt_compositor_fd *xcfd, client_gl_xlib_compositor_create(struct xrt_compositor_native *xcn,
Display *xDisplay, Display *xDisplay,
uint32_t visualid, uint32_t visualid,
GLXFBConfig glxFBConfig, GLXFBConfig glxFBConfig,

View file

@ -16,7 +16,7 @@
struct xrt_compositor_gl * struct xrt_compositor_gl *
xrt_gfx_provider_create_gl_xlib(struct xrt_compositor_fd *xcfd, xrt_gfx_provider_create_gl_xlib(struct xrt_compositor_native *xcn,
Display *xDisplay, Display *xDisplay,
uint32_t visualid, uint32_t visualid,
GLXFBConfig glxFBConfig, GLXFBConfig glxFBConfig,
@ -25,7 +25,7 @@ xrt_gfx_provider_create_gl_xlib(struct xrt_compositor_fd *xcfd,
{ {
struct client_gl_xlib_compositor *xcc = struct client_gl_xlib_compositor *xcc =
client_gl_xlib_compositor_create( client_gl_xlib_compositor_create(
xcfd, xDisplay, visualid, glxFBConfig, glxDrawable, glxContext); xcn, xDisplay, visualid, glxFBConfig, glxDrawable, glxContext);
return &xcc->base.base; return &xcc->base.base;
} }

View file

@ -64,8 +64,8 @@ client_vk_swapchain_destroy(struct xrt_swapchain *xsc)
} }
} }
// Destroy the fd swapchain as well. // Destroy the native swapchain as well.
xrt_swapchain_destroy((struct xrt_swapchain **)&sc->xscfd); xrt_swapchain_destroy((struct xrt_swapchain **)&sc->xscn);
free(sc); free(sc);
} }
@ -77,9 +77,9 @@ client_vk_swapchain_acquire_image(struct xrt_swapchain *xsc,
struct client_vk_swapchain *sc = client_vk_swapchain(xsc); struct client_vk_swapchain *sc = client_vk_swapchain(xsc);
struct vk_bundle *vk = &sc->c->vk; struct vk_bundle *vk = &sc->c->vk;
// Pipe down call into fd swapchain. // Pipe down call into native swapchain.
xrt_result_t xret = xrt_result_t xret =
xrt_swapchain_acquire_image(&sc->xscfd->base, out_index); xrt_swapchain_acquire_image(&sc->xscn->base, out_index);
if (xret != XRT_SUCCESS) { if (xret != XRT_SUCCESS) {
return xret; return xret;
} }
@ -106,8 +106,8 @@ client_vk_swapchain_wait_image(struct xrt_swapchain *xsc,
{ {
struct client_vk_swapchain *sc = client_vk_swapchain(xsc); struct client_vk_swapchain *sc = client_vk_swapchain(xsc);
// Pipe down call into fd swapchain. // Pipe down call into native swapchain.
return xrt_swapchain_wait_image(&sc->xscfd->base, timeout, index); return xrt_swapchain_wait_image(&sc->xscn->base, timeout, index);
} }
static xrt_result_t static xrt_result_t
@ -129,8 +129,8 @@ client_vk_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
return XRT_ERROR_FAILED_TO_SUBMIT_VULKAN_COMMANDS; return XRT_ERROR_FAILED_TO_SUBMIT_VULKAN_COMMANDS;
} }
// Pipe down call into fd swapchain. // Pipe down call into native swapchain.
return xrt_swapchain_release_image(&sc->xscfd->base, index); return xrt_swapchain_release_image(&sc->xscn->base, index);
} }
@ -146,8 +146,8 @@ client_vk_compositor_poll_events(struct xrt_compositor *xc,
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_poll_events(&c->xcfd->base, out_xce); return xrt_comp_poll_events(&c->xcn->base, out_xce);
} }
static void static void
@ -164,8 +164,8 @@ client_vk_compositor_destroy(struct xrt_compositor *xc)
c->vk.cmd_pool = VK_NULL_HANDLE; c->vk.cmd_pool = VK_NULL_HANDLE;
} }
// Pipe down call into fd compositor. // Pipe down call into native compositor.
xrt_comp_fd_destroy(&c->xcfd); xrt_comp_native_destroy(&c->xcn);
free(c); free(c);
} }
@ -175,8 +175,8 @@ client_vk_compositor_prepare_session(struct xrt_compositor *xc,
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_prepare_session(&c->xcfd->base, xspi); return xrt_comp_prepare_session(&c->xcn->base, xspi);
} }
static xrt_result_t static xrt_result_t
@ -185,8 +185,8 @@ client_vk_compositor_begin_session(struct xrt_compositor *xc,
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_begin_session(&c->xcfd->base, type); return xrt_comp_begin_session(&c->xcn->base, type);
} }
static xrt_result_t static xrt_result_t
@ -194,8 +194,8 @@ client_vk_compositor_end_session(struct xrt_compositor *xc)
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_end_session(&c->xcfd->base); return xrt_comp_end_session(&c->xcn->base);
} }
static xrt_result_t static xrt_result_t
@ -206,8 +206,8 @@ client_vk_compositor_wait_frame(struct xrt_compositor *xc,
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_wait_frame(&c->xcfd->base, out_frame_id, return xrt_comp_wait_frame(&c->xcn->base, out_frame_id,
predicted_display_time, predicted_display_time,
predicted_display_period); predicted_display_period);
} }
@ -217,8 +217,8 @@ client_vk_compositor_begin_frame(struct xrt_compositor *xc, int64_t frame_id)
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_begin_frame(&c->xcfd->base, frame_id); return xrt_comp_begin_frame(&c->xcn->base, frame_id);
} }
static xrt_result_t static xrt_result_t
@ -226,8 +226,8 @@ client_vk_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into fd compositor. // Pipe down call into native compositor.
return xrt_comp_discard_frame(&c->xcfd->base, frame_id); return xrt_comp_discard_frame(&c->xcn->base, frame_id);
} }
static xrt_result_t static xrt_result_t
@ -237,7 +237,7 @@ client_vk_compositor_layer_begin(struct xrt_compositor *xc,
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
return xrt_comp_layer_begin(&c->xcfd->base, frame_id, env_blend_mode); return xrt_comp_layer_begin(&c->xcn->base, frame_id, env_blend_mode);
} }
static xrt_result_t static xrt_result_t
@ -248,16 +248,16 @@ client_vk_compositor_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_layer_data *data) struct xrt_layer_data *data)
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
struct xrt_swapchain *l_xscfd, *r_xscfd; struct xrt_swapchain *l_xscn, *r_xscn;
assert(data->type == XRT_LAYER_STEREO_PROJECTION); assert(data->type == XRT_LAYER_STEREO_PROJECTION);
l_xscfd = &client_vk_swapchain(l_xsc)->xscfd->base; l_xscn = &client_vk_swapchain(l_xsc)->xscn->base;
r_xscfd = &client_vk_swapchain(r_xsc)->xscfd->base; r_xscn = &client_vk_swapchain(r_xsc)->xscn->base;
data->flip_y = false; data->flip_y = false;
return xrt_comp_layer_stereo_projection(&c->xcfd->base, xdev, l_xscfd, return xrt_comp_layer_stereo_projection(&c->xcn->base, xdev, l_xscn,
r_xscfd, data); r_xscn, data);
} }
static xrt_result_t static xrt_result_t
@ -271,10 +271,10 @@ client_vk_compositor_layer_quad(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_QUAD); assert(data->type == XRT_LAYER_QUAD);
xscfb = &client_vk_swapchain(xsc)->xscfd->base; xscfb = &client_vk_swapchain(xsc)->xscn->base;
data->flip_y = false; data->flip_y = false;
return xrt_comp_layer_quad(&c->xcfd->base, xdev, xscfb, data); return xrt_comp_layer_quad(&c->xcn->base, xdev, xscfb, data);
} }
static xrt_result_t static xrt_result_t
@ -282,7 +282,7 @@ client_vk_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id)
{ {
struct client_vk_compositor *c = client_vk_compositor(xc); struct client_vk_compositor *c = client_vk_compositor(xc);
return xrt_comp_layer_commit(&c->xcfd->base, frame_id); return xrt_comp_layer_commit(&c->xcn->base, frame_id);
} }
static struct xrt_swapchain * static struct xrt_swapchain *
@ -293,13 +293,13 @@ client_vk_swapchain_create(struct xrt_compositor *xc,
VkCommandBuffer cmd_buffer; VkCommandBuffer cmd_buffer;
VkResult ret; VkResult ret;
struct xrt_swapchain_fd *xscfd = struct xrt_swapchain_native *xscn =
xrt_comp_fd_create_swapchain(c->xcfd, info); xrt_comp_native_create_swapchain(c->xcn, info);
if (xscfd == NULL) { if (xscn == NULL) {
return NULL; return NULL;
} }
struct xrt_swapchain *xsc = &xscfd->base; struct xrt_swapchain *xsc = &xscn->base;
ret = vk_init_cmd_buffer(&c->vk, &cmd_buffer); ret = vk_init_cmd_buffer(&c->vk, &cmd_buffer);
if (ret != VK_SUCCESS) { if (ret != VK_SUCCESS) {
@ -320,19 +320,19 @@ client_vk_swapchain_create(struct xrt_compositor *xc,
sc->base.base.acquire_image = client_vk_swapchain_acquire_image; sc->base.base.acquire_image = client_vk_swapchain_acquire_image;
sc->base.base.wait_image = client_vk_swapchain_wait_image; sc->base.base.wait_image = client_vk_swapchain_wait_image;
sc->base.base.release_image = client_vk_swapchain_release_image; sc->base.base.release_image = client_vk_swapchain_release_image;
// Fetch the number of images from the fd swapchain. // Fetch the number of images from the native swapchain.
sc->base.base.num_images = xsc->num_images; sc->base.base.num_images = xsc->num_images;
sc->c = c; sc->c = c;
sc->xscfd = xscfd; sc->xscn = xscn;
for (uint32_t i = 0; i < xsc->num_images; i++) { for (uint32_t i = 0; i < xsc->num_images; i++) {
ret = vk_create_image_from_fd( ret = vk_create_image_from_native(
&c->vk, info->bits, info->format, info->width, info->height, &c->vk, info->bits, info->format, info->width, info->height,
info->array_size, info->mip_count, &xscfd->images[i], info->array_size, info->mip_count, &xscn->images[i],
&sc->base.images[i], &sc->base.mems[i]); &sc->base.images[i], &sc->base.mems[i]);
// We have consumed this fd now, make sure it's not freed again. // We have consumed this fd now, make sure it's not freed again.
xscfd->images[i].fd = -1; xscn->images[i].fd = -1;
if (ret != VK_SUCCESS) { if (ret != VK_SUCCESS) {
return NULL; return NULL;
@ -443,7 +443,7 @@ client_vk_swapchain_create(struct xrt_compositor *xc,
} }
struct client_vk_compositor * struct client_vk_compositor *
client_vk_compositor_create(struct xrt_compositor_fd *xcfd, client_vk_compositor_create(struct xrt_compositor_native *xcn,
VkInstance instance, VkInstance instance,
PFN_vkGetInstanceProcAddr getProc, PFN_vkGetInstanceProcAddr getProc,
VkPhysicalDevice physicalDevice, VkPhysicalDevice physicalDevice,
@ -470,13 +470,13 @@ client_vk_compositor_create(struct xrt_compositor_fd *xcfd,
c->base.base.destroy = client_vk_compositor_destroy; c->base.base.destroy = client_vk_compositor_destroy;
c->base.base.poll_events = client_vk_compositor_poll_events; c->base.base.poll_events = client_vk_compositor_poll_events;
c->xcfd = xcfd; c->xcn = xcn;
// passthrough our formats from the fd compositor to the client // passthrough our formats from the native compositor to the client
for (uint32_t i = 0; i < xcfd->base.num_formats; i++) { for (uint32_t i = 0; i < xcn->base.num_formats; i++) {
c->base.base.formats[i] = xcfd->base.formats[i]; c->base.base.formats[i] = xcn->base.formats[i];
} }
c->base.base.num_formats = xcfd->base.num_formats; c->base.base.num_formats = xcn->base.num_formats;
ret = vk_init_from_given(&c->vk, getProc, instance, physicalDevice, ret = vk_init_from_given(&c->vk, getProc, instance, physicalDevice,
device, queueFamilyIndex, queueIndex); device, queueFamilyIndex, queueIndex);

View file

@ -38,8 +38,8 @@ struct client_vk_swapchain
{ {
struct xrt_swapchain_vk base; struct xrt_swapchain_vk base;
//! Owning reference to the backing fd swapchain. //! Owning reference to the backing native swapchain.
struct xrt_swapchain_fd *xscfd; struct xrt_swapchain_native *xscn;
//! Non-owning reference to our parent compositor. //! Non-owning reference to our parent compositor.
struct client_vk_compositor *c; struct client_vk_compositor *c;
@ -57,8 +57,8 @@ struct client_vk_compositor
{ {
struct xrt_compositor_vk base; struct xrt_compositor_vk base;
//! Owning reference to the backing fd compositor //! Owning reference to the backing native compositor
struct xrt_compositor_fd *xcfd; struct xrt_compositor_native *xcn;
struct vk_bundle vk; struct vk_bundle vk;
}; };
@ -74,13 +74,13 @@ struct client_vk_compositor
/*! /*!
* Create a new client_vk_compositor. * Create a new client_vk_compositor.
* *
* Takes owenership of provided xcfd. * Takes owenership of provided xcn.
* *
* @public @memberof client_vk_compositor * @public @memberof client_vk_compositor
* @relatesalso xrt_compositor_fd * @relatesalso xrt_compositor_native
*/ */
struct client_vk_compositor * struct client_vk_compositor *
client_vk_compositor_create(struct xrt_compositor_fd *xcfd, client_vk_compositor_create(struct xrt_compositor_native *xcn,
VkInstance instance, VkInstance instance,
PFN_vkGetInstanceProcAddr getProc, PFN_vkGetInstanceProcAddr getProc,
VkPhysicalDevice physicalDevice, VkPhysicalDevice physicalDevice,

View file

@ -43,7 +43,7 @@ xrt_gfx_vk_get_versions(struct xrt_api_requirements *ver)
} }
struct xrt_compositor_vk * struct xrt_compositor_vk *
xrt_gfx_vk_provider_create(struct xrt_compositor_fd *xcfd, xrt_gfx_vk_provider_create(struct xrt_compositor_native *xcn,
VkInstance instance, VkInstance instance,
PFN_vkGetInstanceProcAddr get_instance_proc_addr, PFN_vkGetInstanceProcAddr get_instance_proc_addr,
VkPhysicalDevice physical_device, VkPhysicalDevice physical_device,
@ -52,7 +52,7 @@ xrt_gfx_vk_provider_create(struct xrt_compositor_fd *xcfd,
uint32_t queue_index) uint32_t queue_index)
{ {
struct client_vk_compositor *vcc = client_vk_compositor_create( struct client_vk_compositor *vcc = client_vk_compositor_create(
xcfd, instance, get_instance_proc_addr, physical_device, device, xcn, instance, get_instance_proc_addr, physical_device, device,
queue_family_index, queue_index); queue_family_index, queue_index);
return &vcc->base; return &vcc->base;

View file

@ -927,8 +927,8 @@ compositor_init_renderer(struct comp_compositor *c)
return c->r != NULL; return c->r != NULL;
} }
struct xrt_compositor_fd * struct xrt_compositor_native *
xrt_gfx_provider_create_fd(struct xrt_device *xdev, bool flip_y) xrt_gfx_provider_create_native(struct xrt_device *xdev, bool flip_y)
{ {
struct comp_compositor *c = U_TYPED_CALLOC(struct comp_compositor); struct comp_compositor *c = U_TYPED_CALLOC(struct comp_compositor);

View file

@ -64,12 +64,12 @@ struct comp_swapchain_image
* Not used by the window backend that uses the vk_swapchain to render to. * Not used by the window backend that uses the vk_swapchain to render to.
* *
* @ingroup comp_main * @ingroup comp_main
* @implements xrt_swapchain_fd * @implements xrt_swapchain_native
* @see comp_compositor * @see comp_compositor
*/ */
struct comp_swapchain struct comp_swapchain
{ {
struct xrt_swapchain_fd base; struct xrt_swapchain_native base;
struct comp_compositor *c; struct comp_compositor *c;
@ -136,11 +136,11 @@ enum comp_state
* Main compositor struct tying everything in the compositor together. * Main compositor struct tying everything in the compositor together.
* *
* @ingroup comp_main * @ingroup comp_main
* @implements xrt_compositor_fd * @implements xrt_compositor_native
*/ */
struct comp_compositor struct comp_compositor
{ {
struct xrt_compositor_fd base; struct xrt_compositor_native base;
//! A link back to the compositor we are presenting to the client. //! A link back to the compositor we are presenting to the client.
struct xrt_compositor *client; struct xrt_compositor *client;

View file

@ -94,16 +94,16 @@ get_device_memory_fd(struct comp_compositor *c,
} }
static VkResult static VkResult
create_image_fd(struct comp_compositor *c, create_image_native(struct comp_compositor *c,
enum xrt_swapchain_usage_bits swapchain_usage, enum xrt_swapchain_usage_bits swapchain_usage,
int64_t format, int64_t format,
uint32_t width, uint32_t width,
uint32_t height, uint32_t height,
uint32_t array_size, uint32_t array_size,
uint32_t mip_count, uint32_t mip_count,
VkImage *out_image, VkImage *out_image,
VkDeviceMemory *out_mem, VkDeviceMemory *out_mem,
struct xrt_image_fd *out_image_fd) struct xrt_image_native *out_image_native)
{ {
VkImageUsageFlags image_usage = VkImageUsageFlags image_usage =
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
@ -202,8 +202,8 @@ create_image_fd(struct comp_compositor *c,
*out_image = image; *out_image = image;
*out_mem = device_memory; *out_mem = device_memory;
out_image_fd->fd = fd; out_image_native->fd = fd;
out_image_fd->size = size; out_image_native->size = size;
return ret; return ret;
@ -251,7 +251,7 @@ comp_swapchain_create(struct xrt_compositor *xc,
} }
for (uint32_t i = 0; i < num_images; i++) { for (uint32_t i = 0; i < num_images; i++) {
ret = create_image_fd( ret = create_image_native(
c, info->bits, info->format, info->width, info->height, c, info->bits, info->format, info->width, info->height,
info->array_size, info->mip_count, &sc->images[i].image, info->array_size, info->mip_count, &sc->images[i].image,
&sc->images[i].memory, &sc->base.images[i]); &sc->images[i].memory, &sc->base.images[i]);

View file

@ -213,8 +213,9 @@ struct xrt_layer_data
* comp_compositor. It is overwritten by the various client * comp_compositor. It is overwritten by the various client
* implementations of the @ref xrt_compositor interface depending on the * implementations of the @ref xrt_compositor interface depending on the
* conventions of the associated graphics API. Other @ref * conventions of the associated graphics API. Other @ref
* xrt_compositor_fd implementations that are not the main compositor * xrt_compositor_native implementations that are not the main
* just pass this field along unchanged to the "real" compositor. * compositor just pass this field along unchanged to the "real"
* compositor.
*/ */
bool flip_y; bool flip_y;
@ -860,17 +861,20 @@ xrt_compositor_vk(struct xrt_compositor *xc)
/* /*
* *
* FD interface, aka DMABUF. * Native interface.
*
* These types are supported by underlying native buffers, which are DMABUF file
* descriptors on Linux.
* *
*/ */
/*! /*!
* A single image of a fd based swapchain. * A single image of a swapchain based on native buffer handles.
* *
* @ingroup xrt_iface comp * @ingroup xrt_iface comp
* @see xrt_swapchain_fd * @see xrt_swapchain_native
*/ */
struct xrt_image_fd struct xrt_image_native
{ {
size_t size; size_t size;
int fd; int fd;
@ -878,72 +882,72 @@ struct xrt_image_fd
}; };
/*! /*!
* @interface xrt_swapchain_fd * @interface xrt_swapchain_native
* Base class for a swapchain that exposes fd to be imported into a client API. * Base class for a swapchain that exposes a native buffer handle to be imported
* into a client API.
* *
* @ingroup xrt_iface comp * @ingroup xrt_iface comp
* @extends xrt_swapchain * @extends xrt_swapchain
*/ */
struct xrt_swapchain_fd struct xrt_swapchain_native
{ {
//! @public Base //! @public Base
struct xrt_swapchain base; struct xrt_swapchain base;
struct xrt_image_fd images[XRT_MAX_SWAPCHAIN_IMAGES]; struct xrt_image_native images[XRT_MAX_SWAPCHAIN_IMAGES];
}; };
/*! /*!
* @interface xrt_compositor_fd * @interface xrt_compositor_native
* *
* Main compositor server interface. * Main compositor server interface.
* *
* @ingroup xrt_iface comp * @ingroup xrt_iface comp
* @extends xrt_compositor * @extends xrt_compositor
*/ */
struct xrt_compositor_fd struct xrt_compositor_native
{ {
//! @public Base //! @public Base
struct xrt_compositor base; struct xrt_compositor base;
}; };
/*! /*!
* @brief Create an FD swapchain with a set of images. * @brief Create a native swapchain with a set of images.
* *
* A specialized version of @ref xrt_comp_create_swapchain, for use only on @ref * A specialized version of @ref xrt_comp_create_swapchain, for use only on @ref
* xrt_compositor_fd. * xrt_compositor_native.
* *
* Helper for calling through the base's function pointer then performing the * Helper for calling through the base's function pointer then performing the
* known-safe downcast. * known-safe downcast.
* *
* @public @memberof xrt_compositor_fd * @public @memberof xrt_compositor_native
*/ */
static inline struct xrt_swapchain_fd * static inline struct xrt_swapchain_native *
xrt_comp_fd_create_swapchain(struct xrt_compositor_fd *xcfd, xrt_comp_native_create_swapchain(struct xrt_compositor_native *xcn,
struct xrt_swapchain_create_info *info) struct xrt_swapchain_create_info *info)
{ {
struct xrt_swapchain *xsc = struct xrt_swapchain *xsc = xrt_comp_create_swapchain(&xcn->base, info);
xrt_comp_create_swapchain(&xcfd->base, info); return (struct xrt_swapchain_native *)xsc;
return (struct xrt_swapchain_fd *)xsc;
} }
/*! /*!
* @copydoc xrt_compositor::destroy * @copydoc xrt_compositor::destroy
* *
* Helper for calling through the function pointer: does a null check and sets * Helper for calling through the function pointer: does a null check and sets
* xcfd_ptr to null if freed. * xcn_ptr to null if freed.
* *
* @public @memberof xrt_compositor_fd * @public @memberof xrt_compositor_native
*/ */
static inline void static inline void
xrt_comp_fd_destroy(struct xrt_compositor_fd **xcfd_ptr) xrt_comp_native_destroy(struct xrt_compositor_native **xcn_ptr)
{ {
struct xrt_compositor_fd *xcfd = *xcfd_ptr; struct xrt_compositor_native *xcn = *xcn_ptr;
if (xcfd == NULL) { if (xcn == NULL) {
return; return;
} }
xcfd->base.destroy(&xcfd->base); xcn->base.destroy(&xcn->base);
*xcfd_ptr = NULL; *xcn_ptr = NULL;
} }

View file

@ -28,10 +28,10 @@ struct time_state;
* Create an OpenGL(ES) compositor client using EGL. * Create an OpenGL(ES) compositor client using EGL.
* *
* @ingroup xrt_iface * @ingroup xrt_iface
* @public @memberof xrt_compositor_fd * @public @memberof xrt_compositor_native
*/ */
struct xrt_compositor_gl * struct xrt_compositor_gl *
xrt_gfx_provider_create_gl_egl(struct xrt_compositor_fd *xcfd, xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn,
EGLDisplay display, EGLDisplay display,
EGLConfig config, EGLConfig config,
EGLContext context, EGLContext context,

View file

@ -20,13 +20,13 @@ extern "C" {
struct time_state; struct time_state;
/*! /*!
* Creates the main fd compositor. * Creates the main native compositor.
* *
* @ingroup xrt_iface * @ingroup xrt_iface
* @relates xrt_compositor_fd * @relates xrt_compositor_native
*/ */
struct xrt_compositor_fd * struct xrt_compositor_native *
xrt_gfx_provider_create_fd(struct xrt_device *xdev, bool flip_y); xrt_gfx_provider_create_native(struct xrt_device *xdev, bool flip_y);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -41,10 +41,10 @@ xrt_gfx_vk_get_versions(struct xrt_api_requirements *ver);
* Create a Vulkan compositor client. * Create a Vulkan compositor client.
* *
* @ingroup xrt_iface * @ingroup xrt_iface
* @public @memberof xrt_compositor_fd * @public @memberof xrt_compositor_native
*/ */
struct xrt_compositor_vk * struct xrt_compositor_vk *
xrt_gfx_vk_provider_create(struct xrt_compositor_fd *xcfd, xrt_gfx_vk_provider_create(struct xrt_compositor_native *xcn,
VkInstance instance, VkInstance instance,
PFN_vkGetInstanceProcAddr get_instance_proc_addr, PFN_vkGetInstanceProcAddr get_instance_proc_addr,
VkPhysicalDevice physical_device, VkPhysicalDevice physical_device,

View file

@ -27,10 +27,10 @@ struct time_state;
* Create an OpenGL compositor client using xlib. * Create an OpenGL compositor client using xlib.
* *
* @ingroup xrt_iface * @ingroup xrt_iface
* @public @memberof xrt_compositor_fd * @public @memberof xrt_compositor_native
*/ */
struct xrt_compositor_gl * struct xrt_compositor_gl *
xrt_gfx_provider_create_gl_xlib(struct xrt_compositor_fd *xcfd, xrt_gfx_provider_create_gl_xlib(struct xrt_compositor_native *xcn,
Display *xDisplay, Display *xDisplay,
uint32_t visualid, uint32_t visualid,
GLXFBConfig glxFBConfig, GLXFBConfig glxFBConfig,

View file

@ -20,7 +20,7 @@ extern "C" {
struct xrt_prober; struct xrt_prober;
struct xrt_device; struct xrt_device;
struct xrt_compositor_fd; struct xrt_compositor_native;
/*! /*!
@ -86,27 +86,27 @@ struct xrt_instance
size_t num_xdevs); size_t num_xdevs);
/*! /*!
* Creates a @ref xrt_compositor_fd. * Creates a @ref xrt_compositor_native.
* *
* Should only be called once. * Should only be called once.
* *
* @note Code consuming this interface should use * @note Code consuming this interface should use
* xrt_instance_create_fd_compositor() * xrt_instance_create_native_compositor()
* *
* @param xinst Pointer to self * @param xinst Pointer to self
* @param[in] xdev Device to use for creating the compositor * @param[in] xdev Device to use for creating the compositor
* @param[in] flip_y Whether to flip the direction of the y axis * @param[in] flip_y Whether to flip the direction of the y axis
* @param[out] out_xcfd Pointer to xrt_compositor_fd pointer, will be * @param[out] out_xcn Pointer to xrt_compositor_native pointer, will
* populated. * be populated.
* *
* @return 0 on success, <0 on error. * @return 0 on success, <0 on error.
* *
* @see xrt_gfx_provider_create_fd * @see xrt_gfx_provider_create_native
*/ */
int (*create_fd_compositor)(struct xrt_instance *xinst, int (*create_native_compositor)(struct xrt_instance *xinst,
struct xrt_device *xdev, struct xrt_device *xdev,
bool flip_y, bool flip_y,
struct xrt_compositor_fd **out_xcfd); struct xrt_compositor_native **out_xcn);
/*! /*!
* Get the instance @ref xrt_prober, if any. * Get the instance @ref xrt_prober, if any.
@ -163,19 +163,19 @@ xrt_instance_select(struct xrt_instance *xinst,
} }
/*! /*!
* @copydoc xrt_instance::create_fd_compositor * @copydoc xrt_instance::create_native_compositor
* *
* Helper for calling through the function pointer. * Helper for calling through the function pointer.
* *
* @public @memberof xrt_instance * @public @memberof xrt_instance
*/ */
static inline int static inline int
xrt_instance_create_fd_compositor(struct xrt_instance *xinst, xrt_instance_create_native_compositor(struct xrt_instance *xinst,
struct xrt_device *xdev, struct xrt_device *xdev,
bool flip_y, bool flip_y,
struct xrt_compositor_fd **out_xcfd) struct xrt_compositor_native **out_xcn)
{ {
return xinst->create_fd_compositor(xinst, xdev, flip_y, out_xcfd); return xinst->create_native_compositor(xinst, xdev, flip_y, out_xcn);
} }
/*! /*!

View file

@ -67,7 +67,7 @@
* *
*/ */
struct xrt_compositor_fd; struct xrt_compositor_native;
/*! /*!
@ -96,7 +96,7 @@ int
ipc_client_compositor_create(struct ipc_connection *ipc_c, ipc_client_compositor_create(struct ipc_connection *ipc_c,
struct xrt_device *xdev, struct xrt_device *xdev,
bool flip_y, bool flip_y,
struct xrt_compositor_fd **out_xcfd); struct xrt_compositor_native **out_xcn);
struct xrt_device * struct xrt_device *
ipc_client_hmd_create(struct ipc_connection *ipc_c, ipc_client_hmd_create(struct ipc_connection *ipc_c,

View file

@ -35,12 +35,12 @@
* *
*/ */
/*! /*!
* Client proxy for an xrt_compositor_fd implementation over IPC. * Client proxy for an xrt_compositor_native implementation over IPC.
* @implements xrt_compositor_fd * @implements xrt_compositor_native
*/ */
struct ipc_client_compositor struct ipc_client_compositor
{ {
struct xrt_compositor_fd base; struct xrt_compositor_native base;
struct ipc_connection *ipc_c; struct ipc_connection *ipc_c;
@ -56,12 +56,12 @@ struct ipc_client_compositor
}; };
/*! /*!
* Client proxy for an xrt_swapchain_fd implementation over IPC. * Client proxy for an xrt_swapchain_native implementation over IPC.
* @implements xrt_swapchain_fd * @implements xrt_swapchain_native
*/ */
struct ipc_client_swapchain struct ipc_client_swapchain
{ {
struct xrt_swapchain_fd base; struct xrt_swapchain_native base;
struct ipc_client_compositor *icc; struct ipc_client_compositor *icc;
@ -456,7 +456,7 @@ int
ipc_client_compositor_create(struct ipc_connection *ipc_c, ipc_client_compositor_create(struct ipc_connection *ipc_c,
struct xrt_device *xdev, struct xrt_device *xdev,
bool flip_y, bool flip_y,
struct xrt_compositor_fd **out_xcfd) struct xrt_compositor_native **out_xcn)
{ {
struct ipc_client_compositor *c = struct ipc_client_compositor *c =
U_TYPED_CALLOC(struct ipc_client_compositor); U_TYPED_CALLOC(struct ipc_client_compositor);
@ -490,7 +490,7 @@ ipc_client_compositor_create(struct ipc_connection *ipc_c,
} }
} }
*out_xcfd = &c->base; *out_xcn = &c->base;
return 0; return 0;
} }

View file

@ -122,20 +122,21 @@ ipc_client_instance_select(struct xrt_instance *xinst,
} }
static int static int
ipc_client_instance_create_fd_compositor(struct xrt_instance *xinst, ipc_client_instance_create_native_compositor(
struct xrt_device *xdev, struct xrt_instance *xinst,
bool flip_y, struct xrt_device *xdev,
struct xrt_compositor_fd **out_xcfd) bool flip_y,
struct xrt_compositor_native **out_xcn)
{ {
struct ipc_client_instance *ii = ipc_client_instance(xinst); struct ipc_client_instance *ii = ipc_client_instance(xinst);
struct xrt_compositor_fd *xcfd = NULL; struct xrt_compositor_native *xcn = NULL;
int ret = ipc_client_compositor_create(&ii->ipc_c, xdev, flip_y, &xcfd); int ret = ipc_client_compositor_create(&ii->ipc_c, xdev, flip_y, &xcn);
if (ret < 0 || xcfd == NULL) { if (ret < 0 || xcn == NULL) {
return -1; return -1;
} }
*out_xcfd = xcfd; *out_xcn = xcn;
return 0; return 0;
} }
@ -188,8 +189,8 @@ ipc_instance_create(struct xrt_instance_info *i_info,
struct ipc_client_instance *ii = struct ipc_client_instance *ii =
U_TYPED_CALLOC(struct ipc_client_instance); U_TYPED_CALLOC(struct ipc_client_instance);
ii->base.select = ipc_client_instance_select; ii->base.select = ipc_client_instance_select;
ii->base.create_fd_compositor = ii->base.create_native_compositor =
ipc_client_instance_create_fd_compositor; ipc_client_instance_create_native_compositor;
ii->base.get_prober = ipc_client_instance_get_prober; ii->base.get_prober = ipc_client_instance_get_prober;
ii->base.destroy = ipc_client_instance_destroy; ii->base.destroy = ipc_client_instance_destroy;

View file

@ -69,7 +69,7 @@ extern "C" {
struct xrt_instance; struct xrt_instance;
struct xrt_compositor; struct xrt_compositor;
struct xrt_compositor_fd; struct xrt_compositor_native;
/*! /*!
@ -160,7 +160,7 @@ struct ipc_server
struct xrt_instance *xinst; struct xrt_instance *xinst;
struct xrt_compositor *xc; struct xrt_compositor *xc;
struct xrt_compositor_fd *xcfd; struct xrt_compositor_native *xcn;
struct xrt_device *xdevs[IPC_SERVER_NUM_XDEVS]; struct xrt_device *xdevs[IPC_SERVER_NUM_XDEVS];
struct xrt_tracking_origin *xtracks[IPC_SERVER_NUM_XDEVS]; struct xrt_tracking_origin *xtracks[IPC_SERVER_NUM_XDEVS];

View file

@ -311,20 +311,20 @@ ipc_handle_swapchain_create(volatile struct ipc_client_state *ics,
ics->swapchain_data[index].num_images = num_images; ics->swapchain_data[index].num_images = num_images;
// return our result to the caller. // return our result to the caller.
struct xrt_swapchain_fd *xcsfd = (struct xrt_swapchain_fd *)xsc; struct xrt_swapchain_native *xscn = (struct xrt_swapchain_native *)xsc;
// Sanity checking. // Sanity checking.
assert(num_images <= IPC_MAX_SWAPCHAIN_FDS); assert(num_images <= IPC_MAX_SWAPCHAIN_FDS);
assert(num_images <= max_num_fds); assert(num_images <= max_num_fds);
*out_id = index; *out_id = index;
*out_size = xcsfd->images[0].size; *out_size = xscn->images[0].size;
*out_num_images = num_images; *out_num_images = num_images;
// Setup the fds. // Setup the fds.
*out_num_handles = num_images; *out_num_handles = num_images;
for (size_t i = 0; i < num_images; i++) { for (size_t i = 0; i < num_images; i++) {
out_handles[i] = xcsfd->images[i].fd; out_handles[i] = xscn->images[i].fd;
} }
return XRT_SUCCESS; return XRT_SUCCESS;

View file

@ -412,8 +412,8 @@ init_all(struct ipc_server *s)
return -1; return -1;
} }
ret = xrt_instance_create_fd_compositor(s->xinst, s->xdevs[0], false, ret = xrt_instance_create_native_compositor(s->xinst, s->xdevs[0],
&s->xcfd); false, &s->xcn);
if (ret < 0) { if (ret < 0) {
teardown_all(s); teardown_all(s);
return ret; return ret;
@ -449,7 +449,7 @@ init_all(struct ipc_server *s)
} }
// Easier to use. // Easier to use.
s->xc = &s->xcfd->base; s->xc = &s->xcn->base;
u_var_add_root(s, "IPC Server", false); u_var_add_root(s, "IPC Server", false);
u_var_add_bool(s, &s->print_debug, "print.debug"); u_var_add_bool(s, &s->print_debug, "print.debug");

View file

@ -65,22 +65,23 @@ oxr_session_populate_egl(struct oxr_logger *log,
"Unsupported EGL client type"); "Unsupported EGL client type");
} }
struct xrt_compositor_fd *xcfd = NULL; struct xrt_compositor_native *xcn = NULL;
struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head); struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head);
int ret = xrt_instance_create_fd_compositor(sys->inst->xinst, xdev, int ret = xrt_instance_create_native_compositor(sys->inst->xinst, xdev,
true, &xcfd); true, &xcn);
if (ret < 0 || xcfd == NULL) { if (ret < 0 || xcn == NULL) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
"Failed to create an fd compositor '%i'", ret); "Failed to create a native compositor '%i'",
ret);
} }
struct xrt_compositor_gl *xcgl = struct xrt_compositor_gl *xcgl =
xrt_gfx_provider_create_gl_egl(xcfd, next->display, next->config, xrt_gfx_provider_create_gl_egl(xcn, next->display, next->config,
next->context, next->getProcAddress); next->context, next->getProcAddress);
if (xcgl == NULL) { if (xcgl == NULL) {
xcfd->base.destroy(&xcfd->base); xcn->base.destroy(&xcn->base);
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
"Failed to create an egl client compositor"); "Failed to create an egl client compositor");
} }

View file

@ -33,23 +33,24 @@ oxr_session_populate_gl_xlib(struct oxr_logger *log,
XrGraphicsBindingOpenGLXlibKHR const *next, XrGraphicsBindingOpenGLXlibKHR const *next,
struct oxr_session *sess) struct oxr_session *sess)
{ {
struct xrt_compositor_fd *xcfd = NULL; struct xrt_compositor_native *xcn = NULL;
struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head); struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head);
int ret = xrt_instance_create_fd_compositor(sys->inst->xinst, xdev, int ret = xrt_instance_create_native_compositor(sys->inst->xinst, xdev,
true, &xcfd); true, &xcn);
if (ret < 0 || xcfd == NULL) { if (ret < 0 || xcn == NULL) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
"Failed to create an fd compositor '%i'", ret); "Failed to create a native compositor '%i'",
ret);
} }
struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_xlib( struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_xlib(
xcfd, next->xDisplay, next->visualid, next->glxFBConfig, xcn, next->xDisplay, next->visualid, next->glxFBConfig,
next->glxDrawable, next->glxContext); next->glxDrawable, next->glxContext);
if (xcgl == NULL) { if (xcgl == NULL) {
xcfd->base.destroy(&xcfd->base); xcn->base.destroy(&xcn->base);
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
"Failed to create an xlib client compositor"); "Failed to create an xlib client compositor");
} }

View file

@ -27,22 +27,23 @@ oxr_session_populate_vk(struct oxr_logger *log,
XrGraphicsBindingVulkanKHR const *next, XrGraphicsBindingVulkanKHR const *next,
struct oxr_session *sess) struct oxr_session *sess)
{ {
struct xrt_compositor_fd *xcfd = NULL; struct xrt_compositor_native *xcn = NULL;
struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head); struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head);
int ret = xrt_instance_create_fd_compositor(sys->inst->xinst, xdev, int ret = xrt_instance_create_native_compositor(sys->inst->xinst, xdev,
false, &xcfd); false, &xcn);
if (ret < 0 || xcfd == NULL) { if (ret < 0 || xcn == NULL) {
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
"Failed to create an fd compositor '%i'", ret); "Failed to create a native compositor '%i'",
ret);
} }
struct xrt_compositor_vk *xcvk = xrt_gfx_vk_provider_create( struct xrt_compositor_vk *xcvk = xrt_gfx_vk_provider_create(
xcfd, next->instance, vkGetInstanceProcAddr, next->physicalDevice, xcn, next->instance, vkGetInstanceProcAddr, next->physicalDevice,
next->device, next->queueFamilyIndex, next->queueIndex); next->device, next->queueFamilyIndex, next->queueIndex);
if (xcvk == NULL) { if (xcvk == NULL) {
xcfd->base.destroy(&xcfd->base); xcn->base.destroy(&xcn->base);
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
"Failed to create an vk client compositor"); "Failed to create an vk client compositor");
} }

View file

@ -11,19 +11,19 @@
#include "xrt/xrt_gfx_fd.h" #include "xrt/xrt_gfx_fd.h"
static int static int
t_instance_create_fd_compositor(struct xrt_instance *xinst, t_instance_create_native_compositor(struct xrt_instance *xinst,
struct xrt_device *xdev, struct xrt_device *xdev,
bool flip_y, bool flip_y,
struct xrt_compositor_fd **out_xcfd) struct xrt_compositor_native **out_xcn)
{ {
struct xrt_compositor_fd *xcfd = struct xrt_compositor_native *xcn =
xrt_gfx_provider_create_fd(xdev, flip_y); xrt_gfx_provider_create_native(xdev, flip_y);
if (xcfd == NULL) { if (xcn == NULL) {
return -1; return -1;
} }
*out_xcfd = xcfd; *out_xcn = xcn;
return 0; return 0;
} }
@ -47,7 +47,8 @@ xrt_instance_create(struct xrt_instance_info *i_info,
struct t_instance *tinst = U_TYPED_CALLOC(struct t_instance); struct t_instance *tinst = U_TYPED_CALLOC(struct t_instance);
tinst->base.select = t_instance_select; tinst->base.select = t_instance_select;
tinst->base.create_fd_compositor = t_instance_create_fd_compositor; tinst->base.create_native_compositor =
t_instance_create_native_compositor;
tinst->base.get_prober = t_instance_get_prober; tinst->base.get_prober = t_instance_get_prober;
tinst->base.destroy = t_instance_destroy; tinst->base.destroy = t_instance_destroy;
tinst->xp = xp; tinst->xp = xp;

View file

@ -11,12 +11,12 @@
static int static int
t_instance_create_fd_compositor_stub(struct xrt_instance *xinst, t_instance_create_native_compositor_stub(struct xrt_instance *xinst,
struct xrt_device *xdev, struct xrt_device *xdev,
bool flip_y, bool flip_y,
struct xrt_compositor_fd **out_xcfd) struct xrt_compositor_native **out_xcn)
{ {
*out_xcfd = NULL; *out_xcn = NULL;
return -1; return -1;
} }
@ -41,7 +41,8 @@ xrt_instance_create(struct xrt_instance_info *i_info,
struct t_instance *tinst = U_TYPED_CALLOC(struct t_instance); struct t_instance *tinst = U_TYPED_CALLOC(struct t_instance);
tinst->base.select = t_instance_select; tinst->base.select = t_instance_select;
tinst->base.create_fd_compositor = t_instance_create_fd_compositor_stub; tinst->base.create_native_compositor =
t_instance_create_native_compositor_stub;
tinst->base.get_prober = t_instance_get_prober; tinst->base.get_prober = t_instance_get_prober;
tinst->base.destroy = t_instance_destroy; tinst->base.destroy = t_instance_destroy;
tinst->xp = xp; tinst->xp = xp;