[Bf-blender-cvs] [fac53c7bc2e] soc-2019-openxr: Core XR Support [part 1]: Add OpenXR-SDK dependency and WITH_XR build option

Julian Eisel noreply at git.blender.org
Fri Nov 15 11:29:34 CET 2019


Commit: fac53c7bc2e40201666cd9dc083f07a56ad5fbe5
Author: Julian Eisel
Date:   Tue Nov 5 12:32:33 2019 +0100
Branches: soc-2019-openxr
https://developer.blender.org/rBfac53c7bc2e40201666cd9dc083f07a56ad5fbe5

Core XR Support [part 1]: Add OpenXR-SDK dependency and WITH_XR build option

Some points on the OpenXR-SDK dependency:
* The repository is located at https://github.com/KhronosGroup/OpenXR-SDK (Apache 2).
* We use the OpenXR loader lib from it, the headers, and some CMake utilities.
* It contains a bunch of generated files, for which the sources are in a separate repository.
* 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.
* 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.
* I copied `presentation.cmake` and `xr_platform_defines.cmake` from the SDK. They contain logic that is not needed for us and prints at CMake generation. We could change that but figured it would also be helpful to keep the files equal to the SDK ones.
* For Windows a patch is needed to link the CRT in a compatible way.
* @LazyDodo already pushed the precompiled binaries for Windows.

All this is entirely untested on macOS.

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

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

M	CMakeLists.txt
M	build_files/build_environment/CMakeLists.txt
M	build_files/build_environment/cmake/harvest.cmake
A	build_files/build_environment/cmake/openxr.cmake
M	build_files/build_environment/cmake/versions.cmake
M	build_files/build_environment/install_deps.sh
A	build_files/build_environment/patches/openxr_sdk.diff
A	build_files/cmake/Modules/FindOpenXR-SDK.cmake
A	build_files/cmake/Modules/presentation.cmake
A	build_files/cmake/Modules/xr_platform_defines.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/macros.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
A	release/windows/batch/blender_oculus.cmd
A	release/windows/batch/oculus.json
D	source/CMakeLists.txt
D	source/blender/CMakeLists.txt
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 e468ae36906..bf962854b97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -237,6 +237,7 @@ 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" ${_init_OPENCOLORIO})
+option(WITH_OPENXR        "Enable VR features through the OpenXR specification" ON)
 
 # Compositor
 option(WITH_COMPOSITOR         "Enable the tile based nodal compositor" ON)
@@ -1785,6 +1786,7 @@ if(FIRST_RUN)
   info_cfg_option(WITH_CYCLES)
   info_cfg_option(WITH_FREESTYLE)
   info_cfg_option(WITH_OPENCOLORIO)
+  info_cfg_option(WITH_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 cdfa18ff4ff..623acbf4c18 100644
--- a/build_files/build_environment/CMakeLists.txt
+++ b/build_files/build_environment/CMakeLists.txt
@@ -98,6 +98,7 @@ else()
   include(cmake/pugixml.cmake)
 endif()
 include(cmake/openimagedenoise.cmake)
+include(cmake/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 cc596b2c786..3ed1e5cedd2 100644
--- a/build_files/build_environment/cmake/harvest.cmake
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -171,6 +171,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(openxr_sdk/include/openxr openxr_sdk/include/openxr "*.h")
+harvest(openxr_sdk/lib 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/openxr.cmake b/build_files/build_environment/cmake/openxr.cmake
new file mode 100644
index 00000000000..bf6c068bfc5
--- /dev/null
+++ b/build_files/build_environment/cmake/openxr.cmake
@@ -0,0 +1,53 @@
+# ***** 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 *****
+
+
+set(OPENXR_SDK_EXTRA_ARGS
+  -DBUILD_API_LAYERS=ON
+  -DBUILD_FORCE_GENERATION=ON
+  -DBUILD_LOADER=ON
+  -DBUILD_SPECIFICATION=OFF
+  -DBUILD_TESTS=OFF
+  -DDYNAMIC_LOADER=OFF
+)
+
+ExternalProject_Add(external_openxr_sdk
+  URL ${OPENXR_SDK_URI}
+  DOWNLOAD_DIR ${DOWNLOAD_DIR}
+  URL_HASH MD5=${OPENXR_SDK_HASH}
+  PREFIX ${BUILD_DIR}/openxr_sdk
+  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openxr_sdk ${DEFAULT_CMAKE_FLAGS} ${OPENXR_SDK_EXTRA_ARGS}
+  PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/openxr_sdk/src/external_openxr_sdk < ${PATCH_DIR}/openxr_sdk.diff
+  INSTALL_DIR ${LIBDIR}/openxr_sdk
+)
+
+if(WIN32)
+  if(BUILD_MODE STREQUAL Release)
+    ExternalProject_Add_Step(external_openxr_sdk after_install
+      COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openxr_sdk/include/openxr ${HARVEST_TARGET}/openxr_sdk/include/openxr
+      COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openxr_sdk/lib ${HARVEST_TARGET}/openxr_sdk/lib
+      DEPENDEES install
+    )
+  endif()
+  if(BUILD_MODE STREQUAL Debug)
+    ExternalProject_Add_Step(external_openxr_sdk after_install
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openxr_sdk/lib/openxr_loader-1_0.lib ${HARVEST_TARGET}/openxr_sdk/lib/openxr_loader-1_0_d.lib
+      DEPENDEES install
+    )
+  endif()
+endif()
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index a261b5fd504..269ace9c6a2 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(OPENXR_SDK_VERSION 1.0.0)
+set(OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK-Source/archive/release-${OPENXR_SDK_VERSION}.tar.gz)
+set(OPENXR_SDK_HASH 260bdc87b5a9b7ef35a540e39f875d79)
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index fd3ebe241a2..126e8258c0f 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -27,16 +27,16 @@ 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-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-ffmpeg,force-opencollada,force-alembic,force-embree,force-oidn,force-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-ffmpeg,build-opencollada,build-alembic,build-embree,build-oidn,build-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-ffmpeg,skip-opencollada,skip-alembic,skip-embree,skip-oidn,skip-openxr \
 -- "$@" \
 )
 
@@ -144,6 +144,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
     --ver-openvdb=<ver>
         Force version of OpenVDB library.
 
+    --ver-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).
@@ -196,6 +199,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
     --build-ffmpeg
         Force the build of FFMpeg.
 
+    --build-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
@@ -254,6 +260,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
     --force-ffmpeg
         Force the rebuild of FFMpeg.
 
+    --force-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)!
@@ -303,7 +312,10 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
         Unconditionally skip OpenImageDenoise installation/building.
 
     --skip-ffmpeg
-        Unconditionally skip FFMpeg installation/building.\""
+        Unconditionally skip FFMpeg installation/building.
+
+    --skip-openxr
+        Unconditionally skip OpenXR-SDK installation/building.\""
 
 ##### Main Vars #####
 
@@ -416,6 +428,11 @@ FFMPEG_FORCE_REBUILD=false
 FFMPEG_SKIP=false
 _ffmpeg_list_sep=";"
 
+OPENXR_VERSION="1.0.0"
+OPENXR_FORCE_BUILD=false
+OPENXR_FORCE_REBUILD=false
+OPENXR_SKIP=false
+
 # FFMPEG optional libs.
 VORBIS_USE=false
 VORBIS_DEV=""
@@ -584,6 +601,11 @@ while true; do
       OPENVDB_VERSION_MIN=$OPENVDB_VERSION
       shift; shift; continue
     ;;
+    --ver-openxr)
+      OPENXR_VERSION="$2"
+      OPENXR_VERSION_MIN=$OPENXR_VERSION
+      shift; shift; continue
+    ;;
     --build-all)
       PYTHON_FORCE_BUILD=true
       NUMPY_FORCE_BUILD=true
@@ -600,6 +622,7 @@ while true; do
       OIDN_FORCE_BUILD=true
       FFMPEG_FORCE_BUILD=true
       ALEMBIC_FORCE_BUILD=true
+      OPENXR_FORCE_BUILD=true
       shift; continue
     ;;
     --build-python)
@@ -651,6 +674,9 @@ while true; do
     --build-alembic)
       ALEMBIC_FORCE_BUILD=true; shift; continue
     ;;
+    --build-openxr)
+      OPENXR_FORCE_BUILD=true; shift; continue
+    ;;
     --force-all)
       PYTHON_FORCE_REBUILD=true
       NUMPY_FORCE_REBUILD=true
@@ -667,6 +693,7 @@ while true; do
       OIDN_FORCE_REBUILD=true
       FFMPEG_FORCE_REBUILD=true
       ALEMBIC_FORCE_REBUILD=true
+      OPENXR_FORCE_REBUILD=true
       shift; continue
     ;;
     --force-python)
@@ -716,6 +743,9 @@ while true; do
     --force-alembic)
       ALEMBIC_FORCE_REBUILD=true; shift; continue
     ;;
+    --force-openxr)
+      OPENXR_FORCE_REBUILD=true; shift; continue
+    ;;
     --skip-python)
       PYTHON_SKIP=true; shift; continue
     ;;
@@ -761,6 +791,9 @@ while true; do
     --skip-alembic)
       ALEMBIC_SKIP=true; shift; continue
     ;;
+    --skip-openxr)
+      OPENXR_SKIP=true; shift; continue
+    ;;
     --)
       # no more arguments to parse
       break
@@ -887,6 +920,12 @@ OIDN_SOURCE=( "https://github.com/OpenImageDenoise/oidn/releases/download/v${OID
 
 FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
 
+OPENXR_USE_REPO=false
+OPENXR_SOURCE=("https://git

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list