[Bf-blender-cvs] [a22573e243d] master: Build System: Add OpenXR-SDK dependency and WITH_XR_OPENXR build option

Julian Eisel noreply at git.blender.org
Wed Mar 4 16:47:02 CET 2020


Commit: a22573e243d7eeda7c10c9afc59377d474c74e5e
Author: Julian Eisel
Date:   Wed Mar 4 16:39:00 2020 +0100
Branches: master
https://developer.blender.org/rBa22573e243d7eeda7c10c9afc59377d474c74e5e

Build System: Add OpenXR-SDK dependency and WITH_XR_OPENXR build option

The OpenXR-SDK contains utilities for using the OpenXR standard
(https://www.khronos.org/openxr/). Namely C-headers and a so called
"loader" to manage runtime linking to OpenXR platforms ("runtimes")
installed on the user's system.

The WITH_XR_OPENXR build option is disabled by default for now, as there
is no code using it yet. On macOS it will remain disabled for now, it's
untested and there's no OpenXR runtime in sight for it.

Some points on the OpenXR-SDK dependency:
* The repository is located at
  https://github.com/KhronosGroup/OpenXR-SDK (Apache 2).
* Notes on updating the dependency:
  https://wiki.blender.org/wiki/Source/OpenXR_SDK_Dependency
* It contains a bunch of generated files, for which the sources are in a
  separate repository
  (https://github.com/KhronosGroup/OpenXR-SDK-Source).
* We could use that other repo by default, but I'd rather go with the
  simpler solution and allow people to opt in if they want advanced dev
  features.
* We currently use the OpenXR loader lib from it and the headers.
* To use the injected OpenXR API-layers from the SDK (e.g. API
  validation layers), the SDK needs to be compiled from this other
  repository.

The extra "XR_" prefix in the build option is to avoid mix-ups of OpenXR
with OpenEXR.

Most of this comes from the 2019 GSoC project, "Core Support of Virtual
Reality Headsets through OpenXR"
(https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).

Differential Revision: https://developer.blender.org/D6188

Reviewed by: Campbell Barton, Sergey Sharybin, Bastien Montagne, Ray
Molenkamp

===================================================================

M	CMakeLists.txt
M	build_files/build_environment/CMakeLists.txt
M	build_files/build_environment/cmake/harvest.cmake
M	build_files/build_environment/cmake/versions.cmake
A	build_files/build_environment/cmake/xr_openxr.cmake
M	build_files/build_environment/install_deps.sh
A	build_files/cmake/Modules/FindXR-OpenXR-SDK.cmake
M	build_files/cmake/config/blender_full.cmake
M	build_files/cmake/config/blender_lite.cmake
M	build_files/cmake/config/blender_release.cmake
M	build_files/cmake/platform/platform_apple.cmake
M	build_files/cmake/platform/platform_unix.cmake
M	build_files/cmake/platform/platform_win32.cmake
M	source/blender/python/intern/CMakeLists.txt
M	source/blender/python/intern/bpy_app_build_options.c

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2b4721ff98f..b78b0e7d647 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -180,6 +180,15 @@ option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
 option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
 mark_as_advanced(WITH_SYSTEM_BULLET)
 option(WITH_OPENCOLORIO   "Enable OpenColorIO color management" ON)
+if(APPLE)
+  # There's no OpenXR runtime in sight for macOS, neither is code well
+  # tested there -> disable it by default.
+  option(WITH_XR_OPENXR   "Enable VR features through the OpenXR specification" OFF)
+  mark_as_advanced(WITH_XR_OPENXR)
+else()
+  # Disabled until there's more than just the build system stuff. Should be enabled soon.
+  option(WITH_XR_OPENXR   "Enable VR features through the OpenXR specification" OFF)
+endif()
 
 # Compositor
 option(WITH_COMPOSITOR         "Enable the tile based nodal compositor" ON)
@@ -1698,6 +1707,7 @@ if(FIRST_RUN)
   info_cfg_option(WITH_CYCLES)
   info_cfg_option(WITH_FREESTYLE)
   info_cfg_option(WITH_OPENCOLORIO)
+  info_cfg_option(WITH_XR_OPENXR)
   info_cfg_option(WITH_OPENIMAGEDENOISE)
   info_cfg_option(WITH_OPENVDB)
   info_cfg_option(WITH_ALEMBIC)
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt
index 34ad0599ce2..53d88b12129 100644
--- a/build_files/build_environment/CMakeLists.txt
+++ b/build_files/build_environment/CMakeLists.txt
@@ -99,6 +99,7 @@ else()
 endif()
 include(cmake/openimagedenoise.cmake)
 include(cmake/embree.cmake)
+include(cmake/xr_openxr.cmake)
 
 if(WITH_WEBP)
   include(cmake/webp.cmake)
diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake
index 5fb62e330af..6801ef284d0 100644
--- a/build_files/build_environment/cmake/harvest.cmake
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -161,6 +161,8 @@ harvest(opensubdiv/include opensubdiv/include "*.h")
 harvest(opensubdiv/lib opensubdiv/lib "*.a")
 harvest(openvdb/include/openvdb openvdb/include/openvdb "*.h")
 harvest(openvdb/lib openvdb/lib "*.a")
+harvest(xr_openxr_sdk/include/openxr xr_openxr_sdk/include/openxr "*.h")
+harvest(xr_openxr_sdk/lib xr_openxr_sdk/src/loader "*.a")
 harvest(osl/bin osl/bin "oslc")
 harvest(osl/include osl/include "*.h")
 harvest(osl/lib osl/lib "*.a")
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index 1f44601cd5a..af0d4e5571d 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -318,3 +318,7 @@ set(LIBGLU_HASH 151aef599b8259efe9acd599c96ea2a3)
 set(MESA_VERSION 18.3.1)
 set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa//mesa-${MESA_VERSION}.tar.xz)
 set(MESA_HASH d60828056d77bfdbae0970f9b15fb1be)
+
+set(XR_OPENXR_SDK_VERSION 1.0.6)
+set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
+set(XR_OPENXR_SDK_HASH 21daea7c3bfec365298d779a0e19caa1)
diff --git a/build_files/build_environment/cmake/xr_openxr.cmake b/build_files/build_environment/cmake/xr_openxr.cmake
new file mode 100644
index 00000000000..b0751e418b9
--- /dev/null
+++ b/build_files/build_environment/cmake/xr_openxr.cmake
@@ -0,0 +1,58 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+
+# Keep flags in sync with install_deps.sh ones in compile_XR_OpenXR_SDK()
+set(XR_OPENXR_SDK_EXTRA_ARGS
+  -DBUILD_FORCE_GENERATION=OFF
+  -DBUILD_LOADER=ON
+  -DDYNAMIC_LOADER=OFF
+)
+
+if(UNIX AND NOT APPLE)
+  list(APPEND XR_OPENXR_SDK_EXTRA_ARGS
+    -DBUILD_WITH_WAYLAND_HEADERS=OFF
+    -DBUILD_WITH_XCB_HEADERS=OFF
+    -DBUILD_WITH_XLIB_HEADERS=ON
+  )
+endif()
+
+ExternalProject_Add(external_xr_openxr_sdk
+  URL ${XR_OPENXR_SDK_URI}
+  DOWNLOAD_DIR ${DOWNLOAD_DIR}
+  URL_HASH MD5=${XR_OPENXR_SDK_HASH}
+  PREFIX ${BUILD_DIR}/xr_openxr_sdk
+  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/xr_openxr_sdk ${DEFAULT_CMAKE_FLAGS} ${XR_OPENXR_SDK_EXTRA_ARGS}
+  INSTALL_DIR ${LIBDIR}/xr_openxr_sdk
+)
+
+if(WIN32)
+  if(BUILD_MODE STREQUAL Release)
+    ExternalProject_Add_Step(external_xr_openxr_sdk after_install
+      COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/xr_openxr_sdk/include/openxr ${HARVEST_TARGET}/xr_openxr_sdk/include/openxr
+      COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/xr_openxr_sdk/lib ${HARVEST_TARGET}/xr_openxr_sdk/lib
+      DEPENDEES install
+    )
+  endif()
+  if(BUILD_MODE STREQUAL Debug)
+    ExternalProject_Add_Step(external_xr_openxr_sdk after_install
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/xr_openxr_sdk/lib/openxr_loader.lib ${HARVEST_TARGET}/xr_openxr_sdk/lib/openxr_loader_d.lib
+      DEPENDEES install
+    )
+  endif()
+endif()
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index 0553f615805..df2866a0e2c 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -52,16 +52,19 @@ getopt \
 -o s:i:t:h \
 --long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,\
 with-all,with-opencollada,with-jack,with-embree,with-oidn,\
-ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\
+ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,ver-xr-openxr:,\
 force-all,force-python,force-numpy,force-boost,\
 force-ocio,force-openexr,force-oiio,force-llvm,force-osl,force-osd,force-openvdb,\
 force-ffmpeg,force-opencollada,force-alembic,force-embree,force-oidn,force-usd,\
+force-xr-openxr,\
 build-all,build-python,build-numpy,build-boost,\
 build-ocio,build-openexr,build-oiio,build-llvm,build-osl,build-osd,build-openvdb,\
 build-ffmpeg,build-opencollada,build-alembic,build-embree,build-oidn,build-usd,\
+build-xr-openxr,\
 skip-python,skip-numpy,skip-boost,\
 skip-ocio,skip-openexr,skip-oiio,skip-llvm,skip-osl,skip-osd,skip-openvdb,\
-skip-ffmpeg,skip-opencollada,skip-alembic,skip-embree,skip-oidn,skip-usd \
+skip-ffmpeg,skip-opencollada,skip-alembic,skip-embree,skip-oidn,skip-usd, \
+skip-xr-openxr\
 -- "$@" \
 )
 
@@ -169,6 +172,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
     --ver-openvdb=<ver>
         Force version of OpenVDB library.
 
+    --ver-xr-openxr=<ver>
+        Force version of OpenXR-SDK.
+
     Note about the --ver-foo options:
         It may not always work as expected (some libs are actually checked out from a git rev...), yet it might help
         to fix some build issues (like LLVM mismatch with the version used by your graphic system).
@@ -224,6 +230,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
     --build-usd
         Force the build of Universal Scene Description.
 
+    --build-xr-openxr
+        Force the build of OpenXR-SDK.
+
     Note about the --build-foo options:
         * They force the script to prefer building dependencies rather than using available packages.
           This may make things simpler and allow working around some distribution bugs, but on the other hand it will
@@ -285,6 +294,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
     --force-usd
         Force the rebuild of Universal Scene Description.
 
+    --force-xr-openxr
+        Force the rebuild of OpenXR-SDK.
+
     Note about the --force-foo options:
         * They obviously only have an effect if those libraries are built by this script
           (i.e. if there is no available and satisfactory package)!
@@ -337,7 +349,10 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
         Unconditionally skip FFMpeg installation/building.
 
     --skip-usd
-        Unconditionally skip Universal Scene Description installation/building.\""
+        Unconditionally skip Universal Scene Description installation/building.
+
+    --skip-xr-openxr
+        Unconditionally skip OpenXR-SDK installation/building.\""
 
 # ----------------------------------------------------------------------------
 # Main Vars
@@ -454,6 +469,11 @@ FFMPEG_FORCE_REBUILD=false
 FFMPEG_SKIP=false
 _ffmpeg_list_sep=";"
 
+XR_OPENXR_VERSION="1.0.6"
+XR_OPENXR_FORCE_BUILD=false
+XR_OPENXR_FORCE_REBUILD=false
+XR_OPENXR_SKIP=false
+
 # FFMPEG optional libs.
 VORBIS_USE=false
 VORBIS_DEV=""
@@ -624,6 +644,11 @@ while true; do
       OPENVDB_VERSION_MIN=$OPENVDB_VERSION
       shift; shift; continue
     ;;
+    --ver-xr-openxr)
+      XR_OPENXR_VERSION="$2"
+      XR_OPENXR_VERSION_MIN=$XR_OPENXR_VERSION
+      shift; shift; continue
+    ;;
     --build-all)
       PYTHON_FORCE_BUILD=true
       NUMPY_FORCE_BUILD=true
@@ -641,6 +666,7 @@ while true; do
       FFMPEG_FORCE_BUILD=true
       ALEMBIC_FORCE_BUILD=true
       USD_FORCE_BUILD=true
+      XR_OPENXR_FORCE_BUILD=true
       shift; continue
     ;;
     --build-python)
@@ -695,6 +721,9 @@ while true; do
     --build-usd)
       USD_FORCE_BUILD=true; shift; continue
     ;;
+    --build-xr-openxr)
+      XR_OPENXR_FORCE_BUILD=true; shift; continue
+    ;;
     --force-all)
       PYTHON_FORCE_REBUILD=true
       NUMPY_FORCE_REBUILD=true
@@ -712,6 +741,7 @@ while true; do
       FFMPEG_FORCE_REBUILD=true
       ALEMBIC_FORCE_REBUILD=true
       USD_FORCE_REBUILD=true
+      XR_OPENXR_FORCE_REBUILD=true
       shift; continue
     ;;
     --force-python)
@@ -764,6 +794,9 @@ while true; do
     --force-usd)
       USD_FORCE_REBUILD=true; shift; continue
     ;;
+    --force-xr-openxr)
+      XR_OPENXR_FORCE_REBUILD=true; shift; cont

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list