mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 04:36:07 +00:00
xrt: Refactor out main compositor creating into own interface
This commit is contained in:
parent
09aa8794b2
commit
aeef692e08
|
@ -1,33 +0,0 @@
|
|||
// Copyright 2019, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Interface for client code to compositor.
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup comp
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "xrt/xrt_device.h"
|
||||
#include "xrt/xrt_compositor.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct time_state;
|
||||
|
||||
/*!
|
||||
* Create the compositor instance using the given device. Used by the client
|
||||
* code and implemented by the main compositor code.
|
||||
*/
|
||||
struct xrt_compositor_fd *
|
||||
comp_compositor_create(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
bool flip_y);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -54,7 +54,6 @@
|
|||
#include "util/u_time.h"
|
||||
|
||||
#include "main/comp_compositor.h"
|
||||
#include "main/comp_client_interface.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
@ -755,9 +754,9 @@ compositor_init_renderer(struct comp_compositor *c)
|
|||
|
||||
|
||||
struct xrt_compositor_fd *
|
||||
comp_compositor_create(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
bool flip_y)
|
||||
xrt_gfx_provider_create_fd(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
bool flip_y)
|
||||
{
|
||||
struct comp_compositor *c = U_TYPED_CALLOC(struct comp_compositor);
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "client/comp_gl_client.h"
|
||||
#include "main/comp_client_interface.h"
|
||||
#include "util/u_misc.h"
|
||||
#include "xrt/xrt_gfx_egl.h"
|
||||
|
||||
|
@ -37,8 +36,7 @@ client_egl_compositor_destroy(struct xrt_compositor *xc)
|
|||
}
|
||||
|
||||
struct xrt_compositor_gl *
|
||||
xrt_gfx_provider_create_gl_egl(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
xrt_gfx_provider_create_gl_egl(struct xrt_compositor_fd *xcfd,
|
||||
EGLDisplay display,
|
||||
EGLConfig config,
|
||||
EGLContext context,
|
||||
|
@ -57,13 +55,6 @@ xrt_gfx_provider_create_gl_egl(struct xrt_device *xdev,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
comp_compositor_create(xdev, timekeeping, true);
|
||||
if (xcfd == NULL) {
|
||||
fprintf(stderr, "Failed to create compositor\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct client_gl_compositor *c =
|
||||
U_TYPED_CALLOC(struct client_gl_compositor);
|
||||
if (!client_gl_compositor_init(c, xcfd, getProcAddress)) {
|
||||
|
|
|
@ -12,25 +12,17 @@
|
|||
|
||||
#include "xrt/xrt_gfx_xlib.h"
|
||||
|
||||
#include "main/comp_client_interface.h"
|
||||
#include "client/comp_gl_xlib_client.h"
|
||||
|
||||
|
||||
struct xrt_compositor_gl *
|
||||
xrt_gfx_provider_create_gl_xlib(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
xrt_gfx_provider_create_gl_xlib(struct xrt_compositor_fd *xcfd,
|
||||
Display *xDisplay,
|
||||
uint32_t visualid,
|
||||
GLXFBConfig glxFBConfig,
|
||||
GLXDrawable glxDrawable,
|
||||
GLXContext glxContext)
|
||||
{
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
comp_compositor_create(xdev, timekeeping, true);
|
||||
if (xcfd == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct client_gl_xlib_compositor *xcc =
|
||||
client_gl_xlib_compositor_create(
|
||||
xcfd, xDisplay, visualid, glxFBConfig, glxDrawable, glxContext);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "main/comp_client_interface.h"
|
||||
#include "client/comp_vk_client.h"
|
||||
|
||||
|
||||
|
@ -44,8 +43,7 @@ xrt_gfx_vk_get_versions(struct xrt_api_requirements *ver)
|
|||
}
|
||||
|
||||
struct xrt_compositor_vk *
|
||||
xrt_gfx_vk_provider_create(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
xrt_gfx_vk_provider_create(struct xrt_compositor_fd *xcfd,
|
||||
VkInstance instance,
|
||||
PFN_vkGetInstanceProcAddr get_instance_proc_addr,
|
||||
VkPhysicalDevice physical_device,
|
||||
|
@ -53,12 +51,6 @@ xrt_gfx_vk_provider_create(struct xrt_device *xdev,
|
|||
uint32_t queue_family_index,
|
||||
uint32_t queue_index)
|
||||
{
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
comp_compositor_create(xdev, timekeeping, false);
|
||||
if (xcfd == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct client_vk_compositor *vcc = client_vk_compositor_create(
|
||||
xcfd, instance, get_instance_proc_addr, physical_device, device,
|
||||
queue_family_index, queue_index);
|
||||
|
|
|
@ -28,8 +28,7 @@ struct time_state;
|
|||
* @ingroup xrt_iface
|
||||
*/
|
||||
struct xrt_compositor_gl *
|
||||
xrt_gfx_provider_create_gl_egl(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
xrt_gfx_provider_create_gl_egl(struct xrt_compositor_fd *xcfd,
|
||||
EGLDisplay display,
|
||||
EGLConfig config,
|
||||
EGLContext context,
|
||||
|
|
35
src/xrt/include/xrt/xrt_gfx_fd.h
Normal file
35
src/xrt/include/xrt/xrt_gfx_fd.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2019-2020, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Header defining a XRT graphics provider.
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup xrt_iface
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "xrt/xrt_device.h"
|
||||
#include "xrt/xrt_compositor.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct time_state;
|
||||
|
||||
/*!
|
||||
* Creates the main fd compositor.
|
||||
*
|
||||
* @ingroup xrt_iface
|
||||
*/
|
||||
struct xrt_compositor_fd *
|
||||
xrt_gfx_provider_create_fd(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
bool flip_y);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -41,8 +41,7 @@ xrt_gfx_vk_get_versions(struct xrt_api_requirements *ver);
|
|||
* @ingroup xrt_iface
|
||||
*/
|
||||
struct xrt_compositor_vk *
|
||||
xrt_gfx_vk_provider_create(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
xrt_gfx_vk_provider_create(struct xrt_compositor_fd *xcfd,
|
||||
VkInstance instance,
|
||||
PFN_vkGetInstanceProcAddr get_instance_proc_addr,
|
||||
VkPhysicalDevice physical_device,
|
||||
|
|
|
@ -27,8 +27,7 @@ struct time_state;
|
|||
* @ingroup xrt_iface
|
||||
*/
|
||||
struct xrt_compositor_gl *
|
||||
xrt_gfx_provider_create_gl_xlib(struct xrt_device *xdev,
|
||||
struct time_state *timekeeping,
|
||||
xrt_gfx_provider_create_gl_xlib(struct xrt_compositor_fd *xcfd,
|
||||
Display *xDisplay,
|
||||
uint32_t visualid,
|
||||
GLXFBConfig glxFBConfig,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#define EGL_NO_X11 // libglvnd
|
||||
#define MESA_EGL_NO_X11_HEADERS // mesa
|
||||
#include <EGL/egl.h>
|
||||
#include "xrt/xrt_gfx_fd.h"
|
||||
#include "xrt/xrt_gfx_egl.h"
|
||||
|
||||
// Not forward declared by mesa
|
||||
|
@ -61,13 +62,21 @@ oxr_session_populate_egl(struct oxr_logger *log,
|
|||
"unsupported EGL client type");
|
||||
}
|
||||
|
||||
struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_egl(
|
||||
sys->head, sys->inst->timekeeping, next->display, next->config,
|
||||
next->context, next->getProcAddress);
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
xrt_gfx_provider_create_fd(sys->head, sys->inst->timekeeping, true);
|
||||
if (xcfd == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a fd compositor");
|
||||
}
|
||||
|
||||
struct xrt_compositor_gl *xcgl =
|
||||
xrt_gfx_provider_create_gl_egl(xcfd, next->display, next->config,
|
||||
next->context, next->getProcAddress);
|
||||
|
||||
if (xcgl == NULL) {
|
||||
xcfd->base.destroy(&xcfd->base);
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a compositor");
|
||||
" failed create a egl client compositor");
|
||||
}
|
||||
|
||||
sess->compositor = &xcgl->base;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "oxr_two_call.h"
|
||||
#include "oxr_handle.h"
|
||||
|
||||
#include "xrt/xrt_gfx_fd.h"
|
||||
#ifdef XR_USE_PLATFORM_XLIB
|
||||
#include "xrt/xrt_gfx_xlib.h"
|
||||
#endif
|
||||
|
@ -30,13 +31,21 @@ oxr_session_populate_gl_xlib(struct oxr_logger *log,
|
|||
XrGraphicsBindingOpenGLXlibKHR const *next,
|
||||
struct oxr_session *sess)
|
||||
{
|
||||
struct xrt_compositor_fd *xcfd =
|
||||
xrt_gfx_provider_create_fd(sys->head, sys->inst->timekeeping, true);
|
||||
if (xcfd == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a fd compositor");
|
||||
}
|
||||
|
||||
struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_xlib(
|
||||
sys->head, sys->inst->timekeeping, next->xDisplay, next->visualid,
|
||||
next->glxFBConfig, next->glxDrawable, next->glxContext);
|
||||
xcfd, next->xDisplay, next->visualid, next->glxFBConfig,
|
||||
next->glxDrawable, next->glxContext);
|
||||
|
||||
if (xcgl == NULL) {
|
||||
xcfd->base.destroy(&xcfd->base);
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a compositor");
|
||||
" failed create a xlib client compositor");
|
||||
}
|
||||
|
||||
sess->compositor = &xcgl->base;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "util/u_misc.h"
|
||||
|
||||
#include "xrt/xrt_gfx_fd.h"
|
||||
#include "xrt/xrt_gfx_vk.h"
|
||||
|
||||
#include "oxr_objects.h"
|
||||
|
@ -25,14 +26,21 @@ oxr_session_populate_vk(struct oxr_logger *log,
|
|||
XrGraphicsBindingVulkanKHR const *next,
|
||||
struct oxr_session *sess)
|
||||
{
|
||||
struct xrt_compositor_fd *xcfd = xrt_gfx_provider_create_fd(
|
||||
sys->head, sys->inst->timekeeping, false);
|
||||
if (xcfd == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a fd compositor");
|
||||
}
|
||||
|
||||
struct xrt_compositor_vk *xcvk = xrt_gfx_vk_provider_create(
|
||||
sys->head, sys->inst->timekeeping, next->instance,
|
||||
vkGetInstanceProcAddr, next->physicalDevice, next->device,
|
||||
next->queueFamilyIndex, next->queueIndex);
|
||||
xcfd, next->instance, vkGetInstanceProcAddr, next->physicalDevice,
|
||||
next->device, next->queueFamilyIndex, next->queueIndex);
|
||||
|
||||
if (xcvk == NULL) {
|
||||
xcfd->base.destroy(&xcfd->base);
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed create a compositor");
|
||||
" failed create a vk client compositor");
|
||||
}
|
||||
|
||||
sess->compositor = &xcvk->base;
|
||||
|
|
Loading…
Reference in a new issue