Skip to content
Snippets Groups Projects
Commit 6f56d91c authored by Ryan Pavlik's avatar Ryan Pavlik
Browse files

xrt: Add separate build config for OpenGL ES

parent 4c5b38c8
No related branches found
No related tags found
No related merge requests found
Showing
with 159 additions and 44 deletions
...@@ -83,8 +83,9 @@ cmake_dependent_option(XRT_HAVE_WAYLAND "Enable Wayland support" ON "WAYLAND_FOU ...@@ -83,8 +83,9 @@ cmake_dependent_option(XRT_HAVE_WAYLAND "Enable Wayland support" ON "WAYLAND_FOU
cmake_dependent_option(XRT_HAVE_XLIB "Enable xlib support" ON "X11_FOUND" OFF) cmake_dependent_option(XRT_HAVE_XLIB "Enable xlib support" ON "X11_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_XCB "Enable xcb support" ON "XCB_FOUND" OFF) cmake_dependent_option(XRT_HAVE_XCB "Enable xcb support" ON "XCB_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_OPENGL "Enable OpenGL Graphics API support" ON "OPENGL_FOUND" OFF) cmake_dependent_option(XRT_HAVE_OPENGL "Enable OpenGL Graphics API support" ON "OPENGL_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_OPENGLES "Enable OpenGL-ES Graphics API support" ON "XRT_HAVE_OPENGL OR ANDROID" OFF)
cmake_dependent_option(XRT_HAVE_VULKAN "Enable Vulkan Graphics API support (also needed for compositor)" ON "VULKAN_FOUND" OFF) cmake_dependent_option(XRT_HAVE_VULKAN "Enable Vulkan Graphics API support (also needed for compositor)" ON "VULKAN_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_EGL "Enable OpenGL on EGL Graphics API support" ON "XRT_HAVE_OPENGL AND EGL_FOUND" OFF) cmake_dependent_option(XRT_HAVE_EGL "Enable OpenGL on EGL Graphics API support" ON "EGL_FOUND; XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES" OFF)
cmake_dependent_option(XRT_HAVE_DBUS "Enable dbus support (for BLE support)" ON "DBUS_FOUND" OFF) cmake_dependent_option(XRT_HAVE_DBUS "Enable dbus support (for BLE support)" ON "DBUS_FOUND" OFF)
cmake_dependent_option(XRT_FEATURE_COMPOSITOR_MAIN "Build main compositor host functionality" ON "XRT_HAVE_VULKAN; XRT_HAVE_WAYLAND OR XRT_HAVE_XCB" OFF) cmake_dependent_option(XRT_FEATURE_COMPOSITOR_MAIN "Build main compositor host functionality" ON "XRT_HAVE_VULKAN; XRT_HAVE_WAYLAND OR XRT_HAVE_XCB" OFF)
cmake_dependent_option(XRT_FEATURE_OPENXR "Build OpenXR runtime target" ON "XRT_FEATURE_COMPOSITOR_MAIN" OFF) cmake_dependent_option(XRT_FEATURE_OPENXR "Build OpenXR runtime target" ON "XRT_FEATURE_COMPOSITOR_MAIN" OFF)
...@@ -194,6 +195,7 @@ message(STATUS "# WAYLAND: ${XRT_HAVE_WAYLAND}") ...@@ -194,6 +195,7 @@ message(STATUS "# WAYLAND: ${XRT_HAVE_WAYLAND}")
message(STATUS "# XLIB: ${XRT_HAVE_XLIB}") message(STATUS "# XLIB: ${XRT_HAVE_XLIB}")
message(STATUS "# XCB: ${XRT_HAVE_XCB}") message(STATUS "# XCB: ${XRT_HAVE_XCB}")
message(STATUS "# OPENGL: ${XRT_HAVE_OPENGL}") message(STATUS "# OPENGL: ${XRT_HAVE_OPENGL}")
message(STATUS "# OPENGLES: ${XRT_HAVE_OPENGLES}")
message(STATUS "# VULKAN: ${XRT_HAVE_VULKAN}") message(STATUS "# VULKAN: ${XRT_HAVE_VULKAN}")
message(STATUS "# EGL: ${XRT_HAVE_EGL}") message(STATUS "# EGL: ${XRT_HAVE_EGL}")
message(STATUS "# DBUS: ${XRT_HAVE_DBUS}") message(STATUS "# DBUS: ${XRT_HAVE_DBUS}")
......
...@@ -61,6 +61,7 @@ eigen3 = dependency('eigen3') ...@@ -61,6 +61,7 @@ eigen3 = dependency('eigen3')
libjpeg = dependency('libjpeg', required: false) libjpeg = dependency('libjpeg', required: false)
libusb = dependency('libusb-1.0', required: false) libusb = dependency('libusb-1.0', required: false)
opengl = dependency('gl', required: get_option('opengl')) opengl = dependency('gl', required: get_option('opengl'))
opengles = dependency('glesv2', required: get_option('opengles'))
rs = dependency('realsense2', required: false) rs = dependency('realsense2', required: false)
sdl2 = dependency('sdl2', required: get_option('gui')) sdl2 = dependency('sdl2', required: get_option('gui'))
udev = dependency('libudev', required: false) udev = dependency('libudev', required: false)
...@@ -100,6 +101,11 @@ if get_option('opengl').enabled() or get_option('opengl').auto() ...@@ -100,6 +101,11 @@ if get_option('opengl').enabled() or get_option('opengl').auto()
build_opengl = opengl.found() build_opengl = opengl.found()
endif endif
build_opengles = false
if get_option('opengles').enabled() or get_option('opengles').auto()
build_opengles = opengles.found() and egl.found()
endif
build_egl = false build_egl = false
if get_option('egl').enabled() or get_option('egl').auto() if get_option('egl').enabled() or get_option('egl').auto()
......
...@@ -40,7 +40,12 @@ option('install-active-runtime', ...@@ -40,7 +40,12 @@ option('install-active-runtime',
option('opengl', option('opengl',
type: 'feature', type: 'feature',
value: 'auto', value: 'auto',
description: 'Enable OpenGL/GLES application support.') description: 'Enable OpenGL application support.')
option('opengles',
type: 'feature',
value: 'auto',
description: 'Enable OpenGL|ES application support.')
option('egl', option('egl',
type: 'feature', type: 'feature',
......
...@@ -19,10 +19,20 @@ set(MATH_SOURCE_FILES ...@@ -19,10 +19,20 @@ set(MATH_SOURCE_FILES
) )
set(OGL_SOURCE_FILES set(OGL_SOURCE_FILES
ogl/ogl_documentation.h
)
if(XRT_HAVE_OPENGL)
list(APPEND OGL_SOURCE_FILES
ogl/ogl_api.c ogl/ogl_api.c
ogl/ogl_api.h ogl/ogl_api.h
ogl/ogl_documentation.h
) )
elseif(XRT_HAVE_OPENGLES)
# Only want one of these two sets of files, to avoid duplicate definitions.
list(APPEND OGL_SOURCE_FILES
ogl/ogles_api.c
ogl/ogles_api.h
)
endif()
set(OS_SOURCE_FILES set(OS_SOURCE_FILES
os/os_ble.h os/os_ble.h
...@@ -116,7 +126,7 @@ add_library(aux-includes INTERFACE) ...@@ -116,7 +126,7 @@ add_library(aux-includes INTERFACE)
target_include_directories(aux-includes INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(aux-includes INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(aux-includes INTERFACE xrt-interfaces) target_link_libraries(aux-includes INTERFACE xrt-interfaces)
if(XRT_HAVE_OPENGL) if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
# OpenGL library. # OpenGL library.
add_library(aux_ogl STATIC ${OGL_SOURCE_FILES}) add_library(aux_ogl STATIC ${OGL_SOURCE_FILES})
target_link_libraries(aux_ogl PUBLIC aux-includes) target_link_libraries(aux_ogl PUBLIC aux-includes)
......
...@@ -58,13 +58,26 @@ aux_util = declare_dependency( ...@@ -58,13 +58,26 @@ aux_util = declare_dependency(
link_with: lib_aux_util, link_with: lib_aux_util,
) )
lib_aux_ogl = static_library( if build_opengl or build_opengles
'aux_ogl', ogl_files = [
files( 'ogl/ogl_documentation.h',
]
if build_opengl
ogl_files += [
'ogl/ogl_api.h', 'ogl/ogl_api.h',
'ogl/ogl_api.c', 'ogl/ogl_api.c',
'ogl/ogl_documentation.h', ]
), elif build_opengles
ogl_files += [
'ogl/ogles_api.h',
'ogl/ogles_api.c',
]
endif
lib_aux_ogl = static_library(
'aux_ogl',
files(ogl_files),
include_directories: [ include_directories: [
xrt_include, xrt_include,
glad_include, glad_include,
...@@ -75,6 +88,7 @@ aux_ogl = declare_dependency( ...@@ -75,6 +88,7 @@ aux_ogl = declare_dependency(
include_directories: aux_include, include_directories: aux_include,
link_with: lib_aux_ogl, link_with: lib_aux_ogl,
) )
endif
lib_aux_os = static_library( lib_aux_os = static_library(
'aux_os', 'aux_os',
......
// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief OpenGL-ES API wrapper.
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
* @ingroup aux_ogl
*/
#include "../../external/glad/src/gles2.c"
// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief OpenGL API wrapper header.
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
* @ingroup aux_ogl
*/
#pragma once
#include "glad/gles2.h"
...@@ -45,12 +45,20 @@ if(XRT_HAVE_VULKAN) ...@@ -45,12 +45,20 @@ if(XRT_HAVE_VULKAN)
client/comp_vk_glue.c client/comp_vk_glue.c
) )
endif() endif()
if(XRT_HAVE_OPENGL) if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
list(APPEND CLIENT_SOURCE_FILES list(APPEND CLIENT_SOURCE_FILES
client/comp_gl_client.c client/comp_gl_client.c
client/comp_gl_client.h client/comp_gl_client.h
)
endif()
if(XRT_HAVE_OPENGL)
list(APPEND CLIENT_SOURCE_FILES
client/comp_gl_glue.c client/comp_gl_glue.c
client/comp_gles_glue.c # TODO separate config for GLES )
endif()
if(XRT_HAVE_OPENGLES)
list(APPEND CLIENT_SOURCE_FILES
client/comp_gles_glue.c
) )
endif() endif()
if(XRT_HAVE_OPENGL AND XRT_HAVE_XLIB) if(XRT_HAVE_OPENGL AND XRT_HAVE_XLIB)
...@@ -60,7 +68,7 @@ if(XRT_HAVE_OPENGL AND XRT_HAVE_XLIB) ...@@ -60,7 +68,7 @@ if(XRT_HAVE_OPENGL AND XRT_HAVE_XLIB)
client/comp_gl_xlib_glue.c client/comp_gl_xlib_glue.c
) )
endif() endif()
if(XRT_HAVE_OPENGL AND XRT_HAVE_EGL) if(XRT_HAVE_EGL)
list(APPEND CLIENT_SOURCE_FILES list(APPEND CLIENT_SOURCE_FILES
client/comp_egl_glue.c client/comp_egl_glue.c
) )
...@@ -73,7 +81,7 @@ target_include_directories(comp_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) ...@@ -73,7 +81,7 @@ target_include_directories(comp_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
if(XRT_HAVE_VULKAN) if(XRT_HAVE_VULKAN)
target_link_libraries(comp_client PRIVATE aux_vk) target_link_libraries(comp_client PRIVATE aux_vk)
endif() endif()
if(XRT_HAVE_OPENGL) if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
target_link_libraries(comp_client PRIVATE aux_ogl) target_link_libraries(comp_client PRIVATE aux_ogl)
endif() endif()
......
...@@ -12,9 +12,16 @@ ...@@ -12,9 +12,16 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <xrt/xrt_config_have.h>
#include "util/u_misc.h" #include "util/u_misc.h"
#if defined(XRT_HAVE_OPENGL)
// or both OpenGL and GL-ES
#include "ogl/ogl_api.h" #include "ogl/ogl_api.h"
#elif defined(XRT_HAVE_OPENGLES)
#include "ogl/ogles_api.h"
#endif
#include "client/comp_gl_client.h" #include "client/comp_gl_client.h"
#include <inttypes.h> #include <inttypes.h>
...@@ -379,7 +386,11 @@ client_gl_compositor_init(struct client_gl_compositor *c, ...@@ -379,7 +386,11 @@ client_gl_compositor_init(struct client_gl_compositor *c,
} }
c->base.base.num_formats = count; c->base.base.num_formats = count;
#if defined(XRT_HAVE_OPENGL)
gladLoadGL(get_gl_procaddr); gladLoadGL(get_gl_procaddr);
#elif defined(XRT_HAVE_OPENGLES)
gladLoadGLES2(get_gl_procaddr);
#endif
// @todo log this to a proper logger. // @todo log this to a proper logger.
#define CHECK_REQUIRED_EXTENSION(EXT) \ #define CHECK_REQUIRED_EXTENSION(EXT) \
do { \ do { \
......
...@@ -44,16 +44,27 @@ if build_xcb_xrandr_direct ...@@ -44,16 +44,27 @@ if build_xcb_xrandr_direct
compositor_deps += [xcb_randr, x11_xcb] compositor_deps += [xcb_randr, x11_xcb]
endif endif
if build_opengl if build_opengl or build_opengles
compositor_srcs += [ compositor_srcs += [
'client/comp_gl_client.c', 'client/comp_gl_client.c',
'client/comp_gl_client.h', 'client/comp_gl_client.h',
]
endif
if build_opengl
compositor_srcs += [
'client/comp_gl_glue.c', 'client/comp_gl_glue.c',
'client/comp_gles_glue.c',
] ]
compositor_deps += [opengl] compositor_deps += [opengl]
compositor_includes += [glad_include] compositor_includes += [glad_include]
endif endif
if build_opengles
compositor_srcs += [
'client/comp_gles_glue.c',
]
compositor_deps += [opengles]
compositor_includes += [glad_include]
endif
if build_opengl and build_xlib if build_opengl and build_xlib
compositor_srcs += [ compositor_srcs += [
......
...@@ -53,6 +53,14 @@ if opencv.found() ...@@ -53,6 +53,14 @@ if opencv.found()
have_conf.set('XRT_HAVE_OPENCV', true) have_conf.set('XRT_HAVE_OPENCV', true)
endif endif
if build_opengl
have_conf.set('XRT_HAVE_OPENGL', true)
endif
if build_opengles
have_conf.set('XRT_HAVE_OPENGLES', true)
endif
if sdl2.found() if sdl2.found()
have_conf.set('XRT_HAVE_SDL2', true) have_conf.set('XRT_HAVE_SDL2', true)
endif endif
......
...@@ -9,12 +9,15 @@ ...@@ -9,12 +9,15 @@
#pragma once #pragma once
#cmakedefine XRT_HAVE_EGL
#cmakedefine XRT_HAVE_FFMPEG #cmakedefine XRT_HAVE_FFMPEG
#cmakedefine XRT_HAVE_JPEG #cmakedefine XRT_HAVE_JPEG
#cmakedefine XRT_HAVE_LIBUDEV #cmakedefine XRT_HAVE_LIBUDEV
#cmakedefine XRT_HAVE_LIBUSB #cmakedefine XRT_HAVE_LIBUSB
#cmakedefine XRT_HAVE_LIBUVC #cmakedefine XRT_HAVE_LIBUVC
#cmakedefine XRT_HAVE_OPENCV #cmakedefine XRT_HAVE_OPENCV
#cmakedefine XRT_HAVE_OPENGL
#cmakedefine XRT_HAVE_OPENGLES
#cmakedefine XRT_HAVE_SDL2 #cmakedefine XRT_HAVE_SDL2
#cmakedefine XRT_HAVE_SYSTEMD #cmakedefine XRT_HAVE_SYSTEMD
#cmakedefine XRT_HAVE_V4L2 #cmakedefine XRT_HAVE_V4L2
......
...@@ -29,7 +29,7 @@ typedef void *GLXDrawable; ...@@ -29,7 +29,7 @@ typedef void *GLXDrawable;
typedef void *GLXContext; typedef void *GLXContext;
#endif #endif
#ifdef XR_USE_PLATFORM_EGL #if defined(XR_USE_PLATFORM_EGL) || defined(XR_USE_GRAPHICS_API_OPENGL_ES)
typedef void *EGLDisplay; typedef void *EGLDisplay;
typedef void *EGLContext; typedef void *EGLContext;
typedef void *EGLConfig; typedef void *EGLConfig;
......
...@@ -67,7 +67,13 @@ if(XRT_HAVE_VULKAN) ...@@ -67,7 +67,13 @@ if(XRT_HAVE_VULKAN)
endif() endif()
if(XRT_HAVE_OPENGL) if(XRT_HAVE_OPENGL)
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL -DXR_USE_GRAPHICS_API_OPENGL_ES) add_definitions(-DXR_USE_GRAPHICS_API_OPENGL)
endif()
if(XRT_HAVE_OPENGLES)
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL_ES)
endif()
if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
list(APPEND OXR_SOURCE_FILES list(APPEND OXR_SOURCE_FILES
oxr_session_gl.c oxr_session_gl.c
oxr_swapchain_gl.c oxr_swapchain_gl.c
......
...@@ -24,7 +24,11 @@ generated = custom_target('bindings code', ...@@ -24,7 +24,11 @@ generated = custom_target('bindings code',
compile_args = [] compile_args = []
if build_opengl if build_opengl
compile_args += ['-DXR_USE_GRAPHICS_API_OPENGL', '-DXR_USE_GRAPHICS_API_OPENGL_ES'] compile_args += ['-DXR_USE_GRAPHICS_API_OPENGL']
endif
if build_opengles
compile_args += ['-DXR_USE_GRAPHICS_API_OPENGL_ES']
endif endif
if build_egl if build_egl
......
...@@ -911,13 +911,18 @@ oxr_session_populate_gl_xlib(struct oxr_logger *log, ...@@ -911,13 +911,18 @@ oxr_session_populate_gl_xlib(struct oxr_logger *log,
struct oxr_session *sess); struct oxr_session *sess);
#endif // XR_USE_PLATFORM_XLIB #endif // XR_USE_PLATFORM_XLIB
#endif // XR_USE_GRAPHICS_API_OPENGL
#if defined(XR_USE_GRAPHICS_API_OPENGL) || \
defined(XR_USE_GRAPHICS_API_OPENGL_ES)
XrResult XrResult
oxr_swapchain_gl_create(struct oxr_logger *, oxr_swapchain_gl_create(struct oxr_logger *,
struct oxr_session *sess, struct oxr_session *sess,
const XrSwapchainCreateInfo *, const XrSwapchainCreateInfo *,
struct oxr_swapchain **out_swapchain); struct oxr_swapchain **out_swapchain);
#endif // XR_USE_GRAPHICS_API_OPENGL #endif // XR_USE_GRAPHICS_API_OPENGL || XR_USE_GRAPHICS_API_OPENGL_ES
/* /*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment