From 2c5531c0a521119a2f5c88b4ba2a67234c537d2b Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Wed, 7 Nov 2018 12:58:12 +0100 Subject: Cycles: Added Embree as BVH option for CPU renders. Note that this is turned off by default and must be enabled at build time with the CMake WITH_CYCLES_EMBREE flag. Embree must be built as a static library with ray masking turned on, the `make deps` scripts have been updated accordingly. There, Embree is off by default too and must be enabled with the WITH_EMBREE flag. Using Embree allows for much faster rendering of deformation motion blur while reducing the memory footprint. TODO: GPU implementation, deduplication of data, leveraging more of Embrees features (e.g. tessellation cache). Differential Revision: https://developer.blender.org/D3682 --- build_files/build_environment/CMakeLists.txt | 4 ++ build_files/build_environment/cmake/embree.cmake | 46 ++++++++++++++++++++++ build_files/build_environment/cmake/harvest.cmake | 6 ++- build_files/build_environment/cmake/options.cmake | 1 + build_files/build_environment/cmake/versions.cmake | 4 ++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 build_files/build_environment/cmake/embree.cmake (limited to 'build_files/build_environment') diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt index 00e486bbb40..8c1d38c0635 100644 --- a/build_files/build_environment/CMakeLists.txt +++ b/build_files/build_environment/CMakeLists.txt @@ -97,6 +97,10 @@ if(WITH_WEBP) include(cmake/webp.cmake) endif() +if(WITH_EMBREE) + include(cmake/embree.cmake) +endif() + if(WIN32) # HMD branch deps include(cmake/hidapi.cmake) diff --git a/build_files/build_environment/cmake/embree.cmake b/build_files/build_environment/cmake/embree.cmake new file mode 100644 index 00000000000..34e5904db5e --- /dev/null +++ b/build_files/build_environment/cmake/embree.cmake @@ -0,0 +1,46 @@ +# ***** 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 ***** + +# Note the utility apps may use png/tiff/gif system libraries, but the +# library itself does not depend on them, so should give no problems. + +set(EMBREE_EXTRA_ARGS + -DEMBREE_ISPC_SUPPORT=OFF + -DEMBREE_TUTORIALS=OFF + -DEMBREE_STATIC_LIB=ON + -DEMBREE_RAY_MASK=ON + -DEMBREE_FILTER_FUNCTION=ON + -DEMBREE_BACKFACE_CULLING=OFF + -DEMBREE_TASKING_SYSTEM=INTERNAL + -DEMBREE_MAX_ISA=AVX2 +) + +if(WIN32) + set(EMBREE_BUILD_DIR ${BUILD_MODE}/) +else() + set(EMBREE_BUILD_DIR) +endif() + +ExternalProject_Add(external_embree + URL ${EMBREE_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${EMBREE_HASH} + PREFIX ${BUILD_DIR}/embree + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/embree ${DEFAULT_CMAKE_FLAGS} ${EMBREE_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/embree +) diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake index 4ec71bf2ed2..d0d8b4cefb9 100644 --- a/build_files/build_environment/cmake/harvest.cmake +++ b/build_files/build_environment/cmake/harvest.cmake @@ -57,7 +57,9 @@ if(BUILD_MODE STREQUAL Release) # hidapi ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hidapi/ ${HARVEST_TARGET}/hidapi/ && # webp, straight up copy - ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/webp ${HARVEST_TARGET}/webp + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/webp ${HARVEST_TARGET}/webp && + # embree + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/embree ${HARVEST_TARGET}/embree DEPENDS ) endif() @@ -191,5 +193,7 @@ harvest(vpx/lib ffmpeg/lib "*.a") harvest(webp/lib ffmpeg/lib "*.a") harvest(x264/lib ffmpeg/lib "*.a") harvest(xvidcore/lib ffmpeg/lib "*.a") +harvest(embree/include embree/include "*.h") +harvest(embree/lib embree/lib "*.a") endif() diff --git a/build_files/build_environment/cmake/options.cmake b/build_files/build_environment/cmake/options.cmake index f3125551972..20e9750bed6 100644 --- a/build_files/build_environment/cmake/options.cmake +++ b/build_files/build_environment/cmake/options.cmake @@ -20,6 +20,7 @@ if(WIN32) option(ENABLE_MINGW64 "Enable building of ffmpeg/iconv/libsndfile/lapack/fftw3 by installing mingw64" ON) endif() option(WITH_WEBP "Enable building of oiio with webp support" OFF) +option(WITH_EMBREE "Enable building of Embree" OFF) set(MAKE_THREADS 1 CACHE STRING "Number of threads to run make with") if(NOT BUILD_MODE) diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index 7bd994c3491..85f59762ef2 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -298,3 +298,7 @@ set(SSL_HASH ebbfc844a8c8cc0ea5dc10b86c9ce97f401837f3fa08c17b2cdadc118253cf99) set(SQLITE_VERSION 3.24.0) set(SQLITE_URI https://www.sqlite.org/2018/sqlite-src-3240000.zip) set(SQLITE_HASH fb558c49ee21a837713c4f1e7e413309aabdd9c7) + +set(EMBREE_VERSION 3.2.4) +set(EMBREE_URI https://github.com/embree/embree/archive/v${EMBREE_VERSION}.zip) +set(EMBREE_HASH 3d4a1147002ff43939d45140aa9d6fb8) -- cgit v1.2.3