From 5eacb6f3090a8dfa4b2710a7f27e366a25c258fd Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 29 Oct 2019 11:08:11 +0100 Subject: [PATCH] xrt: add support for OpenGL ES This commit advertises the extension and adds support for xrGetOpenGLESGraphicsRequirementsKHR --- scripts/generate_oxr_ext_support.py | 1 + src/xrt/compositor/CMakeLists.txt | 1 + src/xrt/compositor/main/comp_glue_gles.c | 22 +++++++++++ src/xrt/compositor/meson.build | 1 + src/xrt/include/xrt/xrt_gfx_gles.h | 28 +++++++++++++ src/xrt/include/xrt/xrt_openxr_includes.h | 1 + src/xrt/state_trackers/oxr/oxr_api_funcs.h | 9 +++++ .../state_trackers/oxr/oxr_api_negotiate.c | 5 +++ src/xrt/state_trackers/oxr/oxr_api_system.c | 39 +++++++++++++++++++ .../oxr/oxr_extension_support.h | 13 +++++++ 10 files changed, 120 insertions(+) create mode 100644 src/xrt/compositor/main/comp_glue_gles.c create mode 100644 src/xrt/include/xrt/xrt_gfx_gles.h diff --git a/scripts/generate_oxr_ext_support.py b/scripts/generate_oxr_ext_support.py index 28177b729..f4c28868b 100755 --- a/scripts/generate_oxr_ext_support.py +++ b/scripts/generate_oxr_ext_support.py @@ -13,6 +13,7 @@ EXTENSIONS = ( ['XR_EXT_debug_utils'], ['XR_KHR_convert_timespec_time', 'XR_USE_TIMESPEC'], ['XR_KHR_opengl_enable', 'XR_USE_GRAPHICS_API_OPENGL'], + ['XR_KHR_opengl_es_enable', 'XR_USE_GRAPHICS_API_OPENGL_ES'], ['XR_KHR_vulkan_enable', 'XR_USE_GRAPHICS_API_VULKAN'], ['XR_MND_egl_enable', 'XR_USE_PLATFORM_EGL'], ['XR_MND_headless'], diff --git a/src/xrt/compositor/CMakeLists.txt b/src/xrt/compositor/CMakeLists.txt index 17a0e6740..ab822ba73 100644 --- a/src/xrt/compositor/CMakeLists.txt +++ b/src/xrt/compositor/CMakeLists.txt @@ -29,6 +29,7 @@ set(GL_SOURCE_FILES main/comp_documentation.h main/comp_glue_egl.c main/comp_glue_gl.c + main/comp_glue_gles.c main/comp_glue_vk.c main/comp_glue_xlib.c main/comp_renderer.c diff --git a/src/xrt/compositor/main/comp_glue_gles.c b/src/xrt/compositor/main/comp_glue_gles.c new file mode 100644 index 000000000..6dbfc99be --- /dev/null +++ b/src/xrt/compositor/main/comp_glue_gles.c @@ -0,0 +1,22 @@ +// Copyright 2019, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Glue code to OpenGL ES client side glue code. + * @author Simon Ser + * @ingroup comp + */ + +#include "xrt/xrt_gfx_gles.h" + + +void +xrt_gfx_gles_get_versions(struct xrt_api_requirements *ver) +{ + ver->min_major = 2; + ver->min_minor = 0; + ver->min_patch = 0; + ver->max_major = 3; + ver->max_minor = 2; + ver->max_patch = 1024 - 1; +} diff --git a/src/xrt/compositor/meson.build b/src/xrt/compositor/meson.build index 723586860..e9e27f892 100644 --- a/src/xrt/compositor/meson.build +++ b/src/xrt/compositor/meson.build @@ -24,6 +24,7 @@ compositor_srcs = [ 'main/comp_documentation.h', 'main/comp_glue_egl.c', 'main/comp_glue_gl.c', + 'main/comp_glue_gles.c', 'main/comp_glue_vk.c', 'main/comp_glue_xlib.c', 'main/comp_renderer.c', diff --git a/src/xrt/include/xrt/xrt_gfx_gles.h b/src/xrt/include/xrt/xrt_gfx_gles.h new file mode 100644 index 000000000..175f0bbe5 --- /dev/null +++ b/src/xrt/include/xrt/xrt_gfx_gles.h @@ -0,0 +1,28 @@ +// Copyright 2019, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Header for misc OpenGL ES code, not a complete graphics provider. + * @author Simon Ser + * @ingroup xrt_iface + */ + +#pragma once + +#include "xrt/xrt_defines.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*! + * @ingroup xrt_iface + */ +void +xrt_gfx_gles_get_versions(struct xrt_api_requirements *ver); + + +#ifdef __cplusplus +} +#endif diff --git a/src/xrt/include/xrt/xrt_openxr_includes.h b/src/xrt/include/xrt/xrt_openxr_includes.h index 6b37426b6..6818ce8d2 100644 --- a/src/xrt/include/xrt/xrt_openxr_includes.h +++ b/src/xrt/include/xrt/xrt_openxr_includes.h @@ -11,6 +11,7 @@ // Move these to the build system instead. #define XR_USE_GRAPHICS_API_OPENGL +#define XR_USE_GRAPHICS_API_OPENGL_ES #define XR_USE_GRAPHICS_API_VULKAN #define XR_USE_PLATFORM_XLIB #define XR_USE_PLATFORM_EGL diff --git a/src/xrt/state_trackers/oxr/oxr_api_funcs.h b/src/xrt/state_trackers/oxr/oxr_api_funcs.h index f158f0fdf..447dfc747 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_funcs.h +++ b/src/xrt/state_trackers/oxr/oxr_api_funcs.h @@ -177,6 +177,15 @@ oxr_xrGetOpenGLGraphicsRequirementsKHR( XrGraphicsRequirementsOpenGLKHR *graphicsRequirements); #endif +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES +//! OpenXR API function @ep{xrGetOpenGLESGraphicsRequirementsKHR} +XrResult +oxr_xrGetOpenGLESGraphicsRequirementsKHR( + XrInstance instance, + XrSystemId systemId, + XrGraphicsRequirementsOpenGLESKHR *graphicsRequirements); +#endif + #ifdef XR_USE_GRAPHICS_API_VULKAN //! OpenXR API function @ep{xrGetVulkanInstanceExtensionsKHR} XrResult diff --git a/src/xrt/state_trackers/oxr/oxr_api_negotiate.c b/src/xrt/state_trackers/oxr/oxr_api_negotiate.c index d61538049..feef2375d 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_negotiate.c +++ b/src/xrt/state_trackers/oxr/oxr_api_negotiate.c @@ -240,6 +240,11 @@ handle_non_null(struct oxr_instance *inst, ENTRY_IF_EXT(xrGetOpenGLGraphicsRequirementsKHR, KHR_opengl_enable); #endif // OXR_HAVE_KHR_opengl_enable +#ifdef OXR_HAVE_KHR_opengl_es_enable + ENTRY_IF_EXT(xrGetOpenGLESGraphicsRequirementsKHR, + KHR_opengl_es_enable); +#endif // OXR_HAVE_KHR_opengl_es_enable + #ifdef OXR_HAVE_KHR_vulkan_enable ENTRY_IF_EXT(xrGetVulkanInstanceExtensionsKHR, KHR_vulkan_enable); ENTRY_IF_EXT(xrGetVulkanDeviceExtensionsKHR, KHR_vulkan_enable); diff --git a/src/xrt/state_trackers/oxr/oxr_api_system.c b/src/xrt/state_trackers/oxr/oxr_api_system.c index ff8ddcb7d..7a593d0af 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_system.c +++ b/src/xrt/state_trackers/oxr/oxr_api_system.c @@ -14,6 +14,7 @@ #include "xrt/xrt_compiler.h" #include "xrt/xrt_gfx_gl.h" +#include "xrt/xrt_gfx_gles.h" #include "util/u_debug.h" #include "oxr_objects.h" @@ -160,6 +161,44 @@ oxr_xrEnumerateViewConfigurationViews( } +/* + * + * OpenGL ES + * + */ + +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES + +XrResult +oxr_xrGetOpenGLESGraphicsRequirementsKHR( + XrInstance instance, + XrSystemId systemId, + XrGraphicsRequirementsOpenGLESKHR *graphicsRequirements) +{ + struct oxr_instance *inst; + struct oxr_logger log; + OXR_VERIFY_INSTANCE_AND_INIT_LOG( + &log, instance, inst, "xrGetOpenGLESGraphicsRequirementsKHR"); + OXR_VERIFY_ARG_TYPE_AND_NOT_NULL( + &log, graphicsRequirements, + XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR); + OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys); + + struct xrt_api_requirements ver; + + xrt_gfx_gles_get_versions(&ver); + + graphicsRequirements->minApiVersionSupported = + XR_MAKE_VERSION(ver.min_major, ver.min_minor, ver.min_patch); + graphicsRequirements->maxApiVersionSupported = + XR_MAKE_VERSION(ver.max_major, ver.max_minor, ver.max_patch); + + return XR_SUCCESS; +} + +#endif + + /* * * OpenGL diff --git a/src/xrt/state_trackers/oxr/oxr_extension_support.h b/src/xrt/state_trackers/oxr/oxr_extension_support.h index 6436eb708..bc8106811 100644 --- a/src/xrt/state_trackers/oxr/oxr_extension_support.h +++ b/src/xrt/state_trackers/oxr/oxr_extension_support.h @@ -49,6 +49,18 @@ #endif +/* + * XR_KHR_opengl_es_enable + */ +#if defined(XR_KHR_opengl_es_enable) && defined(XR_USE_GRAPHICS_API_OPENGL_ES) +#define OXR_HAVE_KHR_opengl_es_enable +#define OXR_EXTENSION_SUPPORT_KHR_opengl_es_enable(_) \ + _(KHR_opengl_es_enable, KHR_OPENGL_ES_ENABLE) +#else +#define OXR_EXTENSION_SUPPORT_KHR_opengl_es_enable(_) +#endif + + /* * XR_KHR_vulkan_enable */ @@ -107,6 +119,7 @@ OXR_EXTENSION_SUPPORT_EXT_debug_utils(_) \ OXR_EXTENSION_SUPPORT_KHR_convert_timespec_time(_) \ OXR_EXTENSION_SUPPORT_KHR_opengl_enable(_) \ + OXR_EXTENSION_SUPPORT_KHR_opengl_es_enable(_) \ OXR_EXTENSION_SUPPORT_KHR_vulkan_enable(_) \ OXR_EXTENSION_SUPPORT_MND_egl_enable(_) \ OXR_EXTENSION_SUPPORT_MND_headless(_)