The open source OpenXR runtime
0
fork

Configure Feed

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

xrt: Refactor out main compositor creating into own interface

+81 -82
-33
src/xrt/compositor/main/comp_client_interface.h
··· 1 - // Copyright 2019, Collabora, Ltd. 2 - // SPDX-License-Identifier: BSL-1.0 3 - /*! 4 - * @file 5 - * @brief Interface for client code to compositor. 6 - * @author Jakob Bornecrantz <jakob@collabora.com> 7 - * @ingroup comp 8 - */ 9 - 10 - #pragma once 11 - 12 - #include "xrt/xrt_device.h" 13 - #include "xrt/xrt_compositor.h" 14 - 15 - #ifdef __cplusplus 16 - extern "C" { 17 - #endif 18 - 19 - struct time_state; 20 - 21 - /*! 22 - * Create the compositor instance using the given device. Used by the client 23 - * code and implemented by the main compositor code. 24 - */ 25 - struct xrt_compositor_fd * 26 - comp_compositor_create(struct xrt_device *xdev, 27 - struct time_state *timekeeping, 28 - bool flip_y); 29 - 30 - 31 - #ifdef __cplusplus 32 - } 33 - #endif
+3 -4
src/xrt/compositor/main/comp_compositor.c
··· 54 54 #include "util/u_time.h" 55 55 56 56 #include "main/comp_compositor.h" 57 - #include "main/comp_client_interface.h" 58 57 59 58 #include <unistd.h> 60 59 #include <math.h> ··· 755 754 756 755 757 756 struct xrt_compositor_fd * 758 - comp_compositor_create(struct xrt_device *xdev, 759 - struct time_state *timekeeping, 760 - bool flip_y) 757 + xrt_gfx_provider_create_fd(struct xrt_device *xdev, 758 + struct time_state *timekeeping, 759 + bool flip_y) 761 760 { 762 761 struct comp_compositor *c = U_TYPED_CALLOC(struct comp_compositor); 763 762
+1 -10
src/xrt/compositor/main/comp_glue_egl.c
··· 16 16 #include <stdlib.h> 17 17 18 18 #include "client/comp_gl_client.h" 19 - #include "main/comp_client_interface.h" 20 19 #include "util/u_misc.h" 21 20 #include "xrt/xrt_gfx_egl.h" 22 21 ··· 37 36 } 38 37 39 38 struct xrt_compositor_gl * 40 - xrt_gfx_provider_create_gl_egl(struct xrt_device *xdev, 41 - struct time_state *timekeeping, 39 + xrt_gfx_provider_create_gl_egl(struct xrt_compositor_fd *xcfd, 42 40 EGLDisplay display, 43 41 EGLConfig config, 44 42 EGLContext context, ··· 54 52 55 53 if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, context)) { 56 54 fprintf(stderr, "Failed to make EGL context current\n"); 57 - return NULL; 58 - } 59 - 60 - struct xrt_compositor_fd *xcfd = 61 - comp_compositor_create(xdev, timekeeping, true); 62 - if (xcfd == NULL) { 63 - fprintf(stderr, "Failed to create compositor\n"); 64 55 return NULL; 65 56 } 66 57
+1 -9
src/xrt/compositor/main/comp_glue_gl_xlib.c
··· 12 12 13 13 #include "xrt/xrt_gfx_xlib.h" 14 14 15 - #include "main/comp_client_interface.h" 16 15 #include "client/comp_gl_xlib_client.h" 17 16 18 17 19 18 struct xrt_compositor_gl * 20 - xrt_gfx_provider_create_gl_xlib(struct xrt_device *xdev, 21 - struct time_state *timekeeping, 19 + xrt_gfx_provider_create_gl_xlib(struct xrt_compositor_fd *xcfd, 22 20 Display *xDisplay, 23 21 uint32_t visualid, 24 22 GLXFBConfig glxFBConfig, 25 23 GLXDrawable glxDrawable, 26 24 GLXContext glxContext) 27 25 { 28 - struct xrt_compositor_fd *xcfd = 29 - comp_compositor_create(xdev, timekeeping, true); 30 - if (xcfd == NULL) { 31 - return NULL; 32 - } 33 - 34 26 struct client_gl_xlib_compositor *xcc = 35 27 client_gl_xlib_compositor_create( 36 28 xcfd, xDisplay, visualid, glxFBConfig, glxDrawable, glxContext);
+1 -9
src/xrt/compositor/main/comp_glue_vk.c
··· 9 9 10 10 #include <stdlib.h> 11 11 12 - #include "main/comp_client_interface.h" 13 12 #include "client/comp_vk_client.h" 14 13 15 14 ··· 44 43 } 45 44 46 45 struct xrt_compositor_vk * 47 - xrt_gfx_vk_provider_create(struct xrt_device *xdev, 48 - struct time_state *timekeeping, 46 + xrt_gfx_vk_provider_create(struct xrt_compositor_fd *xcfd, 49 47 VkInstance instance, 50 48 PFN_vkGetInstanceProcAddr get_instance_proc_addr, 51 49 VkPhysicalDevice physical_device, ··· 53 51 uint32_t queue_family_index, 54 52 uint32_t queue_index) 55 53 { 56 - struct xrt_compositor_fd *xcfd = 57 - comp_compositor_create(xdev, timekeeping, false); 58 - if (xcfd == NULL) { 59 - return NULL; 60 - } 61 - 62 54 struct client_vk_compositor *vcc = client_vk_compositor_create( 63 55 xcfd, instance, get_instance_proc_addr, physical_device, device, 64 56 queue_family_index, queue_index);
+1 -2
src/xrt/include/xrt/xrt_gfx_egl.h
··· 28 28 * @ingroup xrt_iface 29 29 */ 30 30 struct xrt_compositor_gl * 31 - xrt_gfx_provider_create_gl_egl(struct xrt_device *xdev, 32 - struct time_state *timekeeping, 31 + xrt_gfx_provider_create_gl_egl(struct xrt_compositor_fd *xcfd, 33 32 EGLDisplay display, 34 33 EGLConfig config, 35 34 EGLContext context,
+35
src/xrt/include/xrt/xrt_gfx_fd.h
··· 1 + // Copyright 2019-2020, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Header defining a XRT graphics provider. 6 + * @author Jakob Bornecrantz <jakob@collabora.com> 7 + * @ingroup xrt_iface 8 + */ 9 + 10 + #pragma once 11 + 12 + #include "xrt/xrt_device.h" 13 + #include "xrt/xrt_compositor.h" 14 + 15 + #ifdef __cplusplus 16 + extern "C" { 17 + #endif 18 + 19 + 20 + struct time_state; 21 + 22 + /*! 23 + * Creates the main fd compositor. 24 + * 25 + * @ingroup xrt_iface 26 + */ 27 + struct xrt_compositor_fd * 28 + xrt_gfx_provider_create_fd(struct xrt_device *xdev, 29 + struct time_state *timekeeping, 30 + bool flip_y); 31 + 32 + 33 + #ifdef __cplusplus 34 + } 35 + #endif
+1 -2
src/xrt/include/xrt/xrt_gfx_vk.h
··· 41 41 * @ingroup xrt_iface 42 42 */ 43 43 struct xrt_compositor_vk * 44 - xrt_gfx_vk_provider_create(struct xrt_device *xdev, 45 - struct time_state *timekeeping, 44 + xrt_gfx_vk_provider_create(struct xrt_compositor_fd *xcfd, 46 45 VkInstance instance, 47 46 PFN_vkGetInstanceProcAddr get_instance_proc_addr, 48 47 VkPhysicalDevice physical_device,
+1 -2
src/xrt/include/xrt/xrt_gfx_xlib.h
··· 27 27 * @ingroup xrt_iface 28 28 */ 29 29 struct xrt_compositor_gl * 30 - xrt_gfx_provider_create_gl_xlib(struct xrt_device *xdev, 31 - struct time_state *timekeeping, 30 + xrt_gfx_provider_create_gl_xlib(struct xrt_compositor_fd *xcfd, 32 31 Display *xDisplay, 33 32 uint32_t visualid, 34 33 GLXFBConfig glxFBConfig,
+13 -4
src/xrt/state_trackers/oxr/oxr_session_egl.c
··· 22 22 #define EGL_NO_X11 // libglvnd 23 23 #define MESA_EGL_NO_X11_HEADERS // mesa 24 24 #include <EGL/egl.h> 25 + #include "xrt/xrt_gfx_fd.h" 25 26 #include "xrt/xrt_gfx_egl.h" 26 27 27 28 // Not forward declared by mesa ··· 61 62 "unsupported EGL client type"); 62 63 } 63 64 64 - struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_egl( 65 - sys->head, sys->inst->timekeeping, next->display, next->config, 66 - next->context, next->getProcAddress); 65 + struct xrt_compositor_fd *xcfd = 66 + xrt_gfx_provider_create_fd(sys->head, sys->inst->timekeeping, true); 67 + if (xcfd == NULL) { 68 + return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, 69 + " failed create a fd compositor"); 70 + } 71 + 72 + struct xrt_compositor_gl *xcgl = 73 + xrt_gfx_provider_create_gl_egl(xcfd, next->display, next->config, 74 + next->context, next->getProcAddress); 67 75 68 76 if (xcgl == NULL) { 77 + xcfd->base.destroy(&xcfd->base); 69 78 return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, 70 - " failed create a compositor"); 79 + " failed create a egl client compositor"); 71 80 } 72 81 73 82 sess->compositor = &xcgl->base;
+12 -3
src/xrt/state_trackers/oxr/oxr_session_gl.c
··· 17 17 #include "oxr_two_call.h" 18 18 #include "oxr_handle.h" 19 19 20 + #include "xrt/xrt_gfx_fd.h" 20 21 #ifdef XR_USE_PLATFORM_XLIB 21 22 #include "xrt/xrt_gfx_xlib.h" 22 23 #endif ··· 30 31 XrGraphicsBindingOpenGLXlibKHR const *next, 31 32 struct oxr_session *sess) 32 33 { 34 + struct xrt_compositor_fd *xcfd = 35 + xrt_gfx_provider_create_fd(sys->head, sys->inst->timekeeping, true); 36 + if (xcfd == NULL) { 37 + return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, 38 + " failed create a fd compositor"); 39 + } 40 + 33 41 struct xrt_compositor_gl *xcgl = xrt_gfx_provider_create_gl_xlib( 34 - sys->head, sys->inst->timekeeping, next->xDisplay, next->visualid, 35 - next->glxFBConfig, next->glxDrawable, next->glxContext); 42 + xcfd, next->xDisplay, next->visualid, next->glxFBConfig, 43 + next->glxDrawable, next->glxContext); 36 44 37 45 if (xcgl == NULL) { 46 + xcfd->base.destroy(&xcfd->base); 38 47 return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, 39 - " failed create a compositor"); 48 + " failed create a xlib client compositor"); 40 49 } 41 50 42 51 sess->compositor = &xcgl->base;
+12 -4
src/xrt/state_trackers/oxr/oxr_session_vk.c
··· 12 12 13 13 #include "util/u_misc.h" 14 14 15 + #include "xrt/xrt_gfx_fd.h" 15 16 #include "xrt/xrt_gfx_vk.h" 16 17 17 18 #include "oxr_objects.h" ··· 25 26 XrGraphicsBindingVulkanKHR const *next, 26 27 struct oxr_session *sess) 27 28 { 29 + struct xrt_compositor_fd *xcfd = xrt_gfx_provider_create_fd( 30 + sys->head, sys->inst->timekeeping, false); 31 + if (xcfd == NULL) { 32 + return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, 33 + " failed create a fd compositor"); 34 + } 35 + 28 36 struct xrt_compositor_vk *xcvk = xrt_gfx_vk_provider_create( 29 - sys->head, sys->inst->timekeeping, next->instance, 30 - vkGetInstanceProcAddr, next->physicalDevice, next->device, 31 - next->queueFamilyIndex, next->queueIndex); 37 + xcfd, next->instance, vkGetInstanceProcAddr, next->physicalDevice, 38 + next->device, next->queueFamilyIndex, next->queueIndex); 32 39 33 40 if (xcvk == NULL) { 41 + xcfd->base.destroy(&xcfd->base); 34 42 return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, 35 - " failed create a compositor"); 43 + " failed create a vk client compositor"); 36 44 } 37 45 38 46 sess->compositor = &xcvk->base;