diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-08-10 16:43:52 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-08-10 16:43:52 +0300 |
commit | 496b510438b2f994cafcec6e36fe300be9fe015f (patch) | |
tree | 426f0e61c752535d2231459bcd2152c95c681e55 | |
parent | c116bb0c7fdae35fbb062260cc9581eb3b4f36cf (diff) | |
parent | 33ab011ae4928cbbb49115abf653d91b8f3ba4d2 (diff) |
Merge branch 'master' into id_copy_refactorid_copy_refactor
Conflicts:
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/sequencer.c
source/blender/editors/space_sequencer/sequencer_edit.c
199 files changed, 10309 insertions, 2211 deletions
diff --git a/.gitignore b/.gitignore index 3418afebb58..814b7661bc6 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ Desktop.ini /doc/python_api/sphinx-in/ /doc/python_api/sphinx-out/ /doc/python_api/rst/bmesh.ops.rst + +# in-source lib downloads +/build_files/build_environment/downloads diff --git a/GNUmakefile b/GNUmakefile index ba7f89c3097..d1e575cfc3c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -43,6 +43,11 @@ ifndef BUILD_DIR BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE) endif +# Dependencies DIR's +DEPS_SOURCE_DIR:=$(BLENDER_DIR)/build_files/build_environment +DEPS_BUILD_DIR:=$(BUILD_DIR)/deps +DEPS_INSTALL_DIR:=$(shell dirname "$(BLENDER_DIR)")/lib/$(OS_NCASE) + # Allow to use alternative binary (pypy3, etc) ifndef PYTHON PYTHON:=python3 @@ -86,13 +91,7 @@ ifndef NPROCS ifeq ($(OS), Linux) NPROCS:=$(shell nproc) endif - ifeq ($(OS), Darwin) - NPROCS:=$(shell sysctl -n hw.ncpu) - endif - ifeq ($(OS), FreeBSD) - NPROCS:=$(shell sysctl -n hw.ncpu) - endif - ifeq ($(OS), NetBSD) + ifneq (,$(filter $(OS),Darwin FreeBSD NetBSD)) NPROCS:=$(shell sysctl -n hw.ncpu) endif endif @@ -146,6 +145,27 @@ cycles: all headless: all bpy: all +# ----------------------------------------------------------------------------- +# Build dependencies +DEPS_TARGET = install +ifneq "$(findstring clean, $(MAKECMDGOALS))" "" + DEPS_TARGET = clean +endif + +deps: .FORCE + @echo + @echo Configuring dependencies in \"$(DEPS_BUILD_DIR)\" + + @cmake -H"$(DEPS_SOURCE_DIR)" \ + -B"$(DEPS_BUILD_DIR)" \ + -DHARVEST_TARGET=$(DEPS_INSTALL_DIR) + + @echo + @echo Building dependencies ... + $(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET) + @echo + @echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR). + @echo # ----------------------------------------------------------------------------- # Configuration (save some cd'ing around) @@ -164,6 +184,7 @@ help: .FORCE @echo " * headless - build without an interface (renderfarm or server automation)" @echo " * cycles - build Cycles standalone only, without Blender" @echo " * bpy - build as a python module which can be loaded from python directly" + @echo " * deps - build library dependencies (intended only for platform maintainers)" @echo "" @echo " * config - run cmake configuration tool to set build options" @echo "" diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt new file mode 100644 index 00000000000..5bcfd477d71 --- /dev/null +++ b/build_files/build_environment/CMakeLists.txt @@ -0,0 +1,130 @@ +# ***** 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 ***** + +#################################################################################################### +# +# This is a build system used by platform maintainers to build library dependencies on +# Windows and macOS. There is some support for Linux as well, but not ready for releases. +# +# Windows and macOS users should download the precompiled libraries in lib/, Linux users +# should run install_deps.sh for building dependencies. +# +# WINDOWS USAGE: +# Don't call this cmake file your self, use build_deps.cmd +# build_deps 2013 x64 / build_deps 2013 x86 +# build_deps 2015 x64 / build_deps 2015 x86 +# +# MAC OS X USAGE: +# Install with homebrew: brew install autoconf automake libtool yasm openssl xz +# Run "make deps" from main Blender directory +# +# LINUX USAGE: +# Install compiler, cmake, autoconf, automake, libtool, yasm +# Run "make deps" from main Blender directory +# +#################################################################################################### + +project("BlenderDependencies") +cmake_minimum_required(VERSION 3.5) + +include(ExternalProject) +include(cmake/options.cmake) +include(cmake/versions.cmake) +include(cmake/zlib.cmake) +include(cmake/blendthumb.cmake) +include(cmake/openal.cmake) +include(cmake/png.cmake) +include(cmake/jpeg.cmake) +include(cmake/boost.cmake) +include(cmake/blosc.cmake) +include(cmake/pthreads.cmake) +include(cmake/ilmbase.cmake) +include(cmake/openexr.cmake) +include(cmake/freetype.cmake) +include(cmake/freeglut.cmake) +include(cmake/glew.cmake) +include(cmake/hdf5.cmake) +include(cmake/alembic.cmake) +include(cmake/glfw.cmake) +include(cmake/clew.cmake) +include(cmake/cuew.cmake) +include(cmake/opensubdiv.cmake) +include(cmake/sdl.cmake) +include(cmake/opencollada.cmake) +include(cmake/opencolorio.cmake) +include(cmake/llvm.cmake) +include(cmake/clang.cmake) +include(cmake/openimageio.cmake) +include(cmake/tiff.cmake) +include(cmake/flexbison.cmake) +include(cmake/osl.cmake) +include(cmake/tbb.cmake) +include(cmake/openvdb.cmake) +include(cmake/python.cmake) +include(cmake/requests.cmake) +include(cmake/numpy.cmake) +include(cmake/webp.cmake) +if(WIN32) + include(cmake/hidapi.cmake) +endif() + +if(ENABLE_MINGW64) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + include(cmake/setup_mingw64.cmake) + else() + include(cmake/setup_mingw32.cmake) + endif() +else() + set(mingw_LIBDIR ${LIBDIR}) +endif() + +if(NOT WIN32 OR ENABLE_MINGW64) + if(BUILD_MODE STREQUAL Release) + if(WIN32) + include(cmake/zlib_mingw.cmake) + endif() + include(cmake/lame.cmake) + include(cmake/ogg.cmake) + include(cmake/vorbis.cmake) + include(cmake/theora.cmake) + include(cmake/vpx.cmake) + include(cmake/orc.cmake) + include(cmake/schroedinger.cmake) + include(cmake/x264.cmake) + include(cmake/xvidcore.cmake) + include(cmake/openjpeg.cmake) + include(cmake/faad.cmake) + include(cmake/ffmpeg.cmake) + include(cmake/fftw.cmake) + include(cmake/sndfile.cmake) + if(WIN32) + include(cmake/iconv.cmake) + include(cmake/lapack.cmake) + endif() + if(UNIX) + include(cmake/flac.cmake) + if(NOT APPLE) + include(cmake/spnav.cmake) + include(cmake/jemalloc.cmake) + include(cmake/xml2.cmake) + endif() + endif() + endif() +endif() + +include(cmake/harvest.cmake) diff --git a/build_files/build_environment/cmake/alembic.cmake b/build_files/build_environment/cmake/alembic.cmake new file mode 100644 index 00000000000..a49047ec102 --- /dev/null +++ b/build_files/build_environment/cmake/alembic.cmake @@ -0,0 +1,75 @@ +# ***** 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 ***** + +if(ALEMBIC_HDF5) + set(ALEMBIC_HDF5_HL) + # in debug mode we do not build HDF5_hdf5_hl_LIBRARY which makes cmake really + # unhappy, stub it with the debug mode lib. it's not linking it in at this + # point in time anyhow + if(BUILD_MODE STREQUAL Debug) + set(ALEMBIC_HDF5_HL -DHDF5_hdf5_hl_LIBRARY=${LIBDIR}/hdf5/lib/libhdf5_hl_D.${LIBEXT}) + endif() +endif() + +set(ALEMBIC_EXTRA_ARGS + -DBUILDSTATIC=ON + -DLINKSTATIC=ON + -DALEMBIC_LIB_USES_BOOST=ON + -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING} + -DBoost_USE_MULTITHREADED=ON + -DUSE_STATIC_BOOST=On + -DBoost_USE_STATIC_LIBS=ON + -DBoost_USE_STATIC_RUNTIME=ON + -DBoost_DEBUG=ON + -DBOOST_ROOT=${LIBDIR}/boost + -DBoost_NO_SYSTEM_PATHS=ON + -DILMBASE_ROOT=${LIBDIR}/ilmbase + -DALEMBIC_ILMBASE_INCLUDE_DIRECTORY=${LIBDIR}/ilmbase/include/OpenEXR + -DALEMBIC_ILMBASE_HALF_LIB=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Half${LIBEXT} + -DALEMBIC_ILMBASE_IMATH_LIB=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Imath-2_2${LIBEXT} + -DALEMBIC_ILMBASE_ILMTHREAD_LIB=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread-2_2${LIBEXT} + -DALEMBIC_ILMBASE_IEX_LIB=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex-2_2${LIBEXT} + -DUSE_PYILMBASE=0 + -DUSE_PYALEMBIC=0 + -DUSE_ARNOLD=0 + -DUSE_MAYA=0 + -DUSE_PRMAN=0 + -DUSE_HDF5=Off + -DUSE_STATIC_HDF5=Off + -DHDF5_ROOT=${LIBDIR}/hdf5 + -DUSE_TESTS=Off + -DALEMBIC_NO_OPENGL=1 + -DUSE_BINARIES=ON + -DALEMBIC_ILMBASE_LINK_STATIC=On + -DALEMBIC_SHARED_LIBS=OFF + -DGLUT_INCLUDE_DIR="" + -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} + -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/ + ${ALEMBIC_HDF5_HL} +) + +ExternalProject_Add(external_alembic + URL ${ALEMBIC_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${ALEMBIC_MD5} + PREFIX ${BUILD_DIR}/alembic + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/alembic -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${ALEMBIC_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/alembic +) + +add_dependencies(external_alembic external_boost external_zlib external_ilmbase) diff --git a/build_files/build_environment/cmake/blendthumb.cmake b/build_files/build_environment/cmake/blendthumb.cmake new file mode 100644 index 00000000000..624869971c6 --- /dev/null +++ b/build_files/build_environment/cmake/blendthumb.cmake @@ -0,0 +1,61 @@ +# ***** 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 ***** + +if(BUILD_MODE STREQUAL Release) + if(WIN32) + set(THUMB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../release/windows/blendthumb) + + ExternalProject_Add(external_zlib_32 + URL ${ZLIB_URI} + CMAKE_GENERATOR ${GENERATOR_32} + URL_HASH MD5=${ZLIB_HASH} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + PREFIX ${BUILD_DIR}/zlib32 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zlib32 ${DEFAULT_CMAKE_FLAGS} + INSTALL_DIR ${LIBDIR}/zlib32 + ) + + ExternalProject_Add(external_zlib_64 + URL ${ZLIB_URI} + CMAKE_GENERATOR ${GENERATOR_64} + URL_HASH MD5=${ZLIB_HASH} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + PREFIX ${BUILD_DIR}/zlib64 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zlib64 ${DEFAULT_CMAKE_FLAGS} + INSTALL_DIR ${LIBDIR}/zlib64 + ) + + ExternalProject_Add(external_blendthumb_32 + CMAKE_GENERATOR ${GENERATOR_32} + SOURCE_DIR ${THUMB_DIR} + PREFIX ${BUILD_DIR}/blendthumb32 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/blendThumb32 ${DEFAULT_CMAKE_FLAGS} -DZLIB_INCLUDE=${LIBDIR}/zlib32/include -DZLIB_LIBS=${LIBDIR}/zlib32/lib/zlibstatic.lib + INSTALL_DIR ${LIBDIR}/blendthumb32 + ) + add_dependencies(external_blendthumb_32 external_zlib_32) + + ExternalProject_Add(external_blendthumb_64 + CMAKE_GENERATOR ${GENERATOR_64} + SOURCE_DIR ${THUMB_DIR} + PREFIX ${BUILD_DIR}/blendthumb64 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/blendThumb64 ${DEFAULT_CMAKE_FLAGS} -DZLIB_INCLUDE=${LIBDIR}/zlib64/include -DZLIB_LIBS=${LIBDIR}/zlib64/lib/zlibstatic.lib + INSTALL_DIR ${LIBDIR}/blendthumb64 + ) + add_dependencies(external_blendthumb_64 external_zlib_64) + endif() +endif() diff --git a/build_files/build_environment/cmake/blosc.cmake b/build_files/build_environment/cmake/blosc.cmake new file mode 100644 index 00000000000..68df525b802 --- /dev/null +++ b/build_files/build_environment/cmake/blosc.cmake @@ -0,0 +1,43 @@ +# ***** 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(BLOSC_EXTRA_ARGS + -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/ + -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} + -DBUILD_TESTS=OFF + -DBUILD_BENCHMARKS=OFF + -DCMAKE_DEBUG_POSTFIX=_d + -DThreads_FOUND=1 + -DPTHREAD_LIBS=${LIBDIR}/pthreads/lib/pthreadVC2.lib + -DPTHREAD_INCLUDE_DIR=${LIBDIR}/pthreads/inc +) + +ExternalProject_Add(external_blosc + URL ${BLOSC_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${BLOSC_HASH} + PREFIX ${BUILD_DIR}/blosc + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/blosc/src/external_blosc < ${PATCH_DIR}/blosc.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/blosc ${DEFAULT_CMAKE_FLAGS} ${BLOSC_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/blosc +) + +add_dependencies(external_blosc external_zlib) +if(WIN32) + add_dependencies(external_blosc external_pthreads) +endif() diff --git a/build_files/build_environment/cmake/boost.cmake b/build_files/build_environment/cmake/boost.cmake new file mode 100644 index 00000000000..554db6583b7 --- /dev/null +++ b/build_files/build_environment/cmake/boost.cmake @@ -0,0 +1,99 @@ +# ***** 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 ***** + +if(WIN32) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(PYTHON_ARCH x64) + set(PYTHON_ARCH2 win-AMD64) + set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/amd64/) + else() + set(PYTHON_ARCH x86) + set(PYTHON_ARCH2 win32) + set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/win32/) + endif() + if(MSVC12) + set(BOOST_TOOLSET toolset=msvc-12.0) + set(BOOST_COMPILER_STRING -vc120) + set(PYTHON_COMPILER_STRING v120) + endif() + if(MSVC14) + set(BOOST_TOOLSET toolset=msvc-14.0) + set(BOOST_COMPILER_STRING -vc140) + set(PYTHON_COMPILER_STRING v140) + endif() + set(JAM_FILE ${BUILD_DIR}/boost/src/external_boost/user-config.jam) + set(semi_path "${PATCH_DIR}/semi.txt") + FILE(TO_NATIVE_PATH ${semi_path} semi_path) + set(BOOST_CONFIGURE_COMMAND bootstrap.bat && + echo using python : 3.5 : ${PYTHON_OUTPUTDIR}\\python.exe > "${JAM_FILE}" && + echo. : ${BUILD_DIR}/python/src/external_python/include ${BUILD_DIR}/python/src/external_python/pc >> "${JAM_FILE}" && + echo. : ${BUILD_DIR}/python/src/external_python/pcbuild >> "${JAM_FILE}" && + type ${semi_path} >> "${JAM_FILE}" + ) + set(BOOST_BUILD_COMMAND bjam) + set(BOOST_BUILD_OPTIONS runtime-link=static --user-config=user-config.jam) + set(BOOST_WITH_PYTHON --with-python) +elseif(APPLE) + set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh) + set(BOOST_BUILD_COMMAND ./bjam) + set(BOOST_BUILD_OPTIONS toolset=clang cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} --disable-icu boost.locale.icu=off) +else() + set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh) + set(BOOST_BUILD_COMMAND ./bjam) + set(BOOST_BUILD_OPTIONS cxxflags=${PLATFORM_CXXFLAGS} --disable-icu boost.locale.icu=off) +endif() + +set(BOOST_OPTIONS + --with-filesystem + --with-locale + --with-thread + --with-regex + --with-system + --with-date_time + --with-wave + --with-atomic + --with-serialization + --with-program_options + --with-iostreams + ${BOOST_WITH_PYTHON} + ${BOOST_TOOLSET} +) + +if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(BOOST_ADDRESS_MODEL 64) +else() + set(BOOST_ADDRESS_MODEL 32) +endif() + +string(TOLOWER ${BUILD_MODE} BOOST_BUILD_TYPE) + +ExternalProject_Add(external_boost + URL ${BOOST_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${BOOST_MD5} + PREFIX ${BUILD_DIR}/boost + UPDATE_COMMAND "" + CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND} + BUILD_COMMAND ${BOOST_BUILD_COMMAND} ${BOOST_BUILD_OPTIONS} -j${MAKE_THREADS} architecture=x86 address-model=${BOOST_ADDRESS_MODEL} variant=${BOOST_BUILD_TYPE} link=static threading=multi ${BOOST_OPTIONS} --prefix=${LIBDIR}/boost install + BUILD_IN_SOURCE 1 + INSTALL_COMMAND "" +) + +if(WIN32) + add_dependencies(external_boost Make_Python_Environment) +endif() diff --git a/build_files/build_environment/cmake/clang.cmake b/build_files/build_environment/cmake/clang.cmake new file mode 100644 index 00000000000..8d57c4dfc6f --- /dev/null +++ b/build_files/build_environment/cmake/clang.cmake @@ -0,0 +1,35 @@ +# ***** 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(CLANG_EXTRA_ARGS + -DCLANG_PATH_TO_LLVM_SOURCE=${BUILD_DIR}/ll/src/ll + -DCLANG_PATH_TO_LLVM_BUILD=${LIBDIR}/llvm + -DLLVM_USE_CRT_RELEASE=MT + -DLLVM_USE_CRT_DEBUG=MTd +) +ExternalProject_Add(external_clang + URL ${CLANG_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${CLANG_HASH} + PATCH_COMMAND ${PATCH_CMD} -p 2 -N -R -d ${BUILD_DIR}/clang/src/external_clang < ${PATCH_DIR}/clang.diff + PREFIX ${BUILD_DIR}/clang + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/llvm ${DEFAULT_CMAKE_FLAGS} ${CLANG_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/llvm +) + +add_dependencies(external_clang ll) diff --git a/build_files/build_environment/cmake/clew.cmake b/build_files/build_environment/cmake/clew.cmake new file mode 100644 index 00000000000..0dcc1f24db7 --- /dev/null +++ b/build_files/build_environment/cmake/clew.cmake @@ -0,0 +1,28 @@ +# ***** 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(CLEW_EXTRA_ARGS) + +ExternalProject_Add(external_clew + URL ${CLEW_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${CLEW_HASH} + PREFIX ${BUILD_DIR}/clew + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/clew -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${CLEW_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/clew +) diff --git a/build_files/build_environment/cmake/cuew.cmake b/build_files/build_environment/cmake/cuew.cmake new file mode 100644 index 00000000000..99b7bb5c06d --- /dev/null +++ b/build_files/build_environment/cmake/cuew.cmake @@ -0,0 +1,29 @@ +# ***** 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(CUEW_EXTRA_ARGS) + +ExternalProject_Add(external_cuew + URL ${CUEW_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${CUEW_HASH} + PREFIX ${BUILD_DIR}/cuew + PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/cuew/src/external_cuew < ${PATCH_DIR}/cuew.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/cuew -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${CUEW_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/cuew +) diff --git a/build_files/build_environment/cmake/faad.cmake b/build_files/build_environment/cmake/faad.cmake new file mode 100644 index 00000000000..3dd90971b84 --- /dev/null +++ b/build_files/build_environment/cmake/faad.cmake @@ -0,0 +1,35 @@ +# ***** 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(FAAD_EXTRA_ARGS) + +ExternalProject_Add(external_faad + URL ${FAAD_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${FAAD_HASH} + PREFIX ${BUILD_DIR}/faad + PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/faad/src/external_faad < ${PATCH_DIR}/libfaad.diff + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/faad/src/external_faad/ && ${CONFIGURE_COMMAND} --disable-shared --enable-static --prefix=${LIBDIR}/faad + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/faad/src/external_faad/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/faad/src/external_faad/ && make install + INSTALL_DIR ${LIBDIR}/faad +) + +if(MSVC) + set_target_properties(external_faad PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/ffmpeg.cmake b/build_files/build_environment/cmake/ffmpeg.cmake new file mode 100644 index 00000000000..3f9091b5ee3 --- /dev/null +++ b/build_files/build_environment/cmake/ffmpeg.cmake @@ -0,0 +1,112 @@ +# ***** 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(FFMPEG_CFLAGS "-I${mingw_LIBDIR}/lame/include -I${mingw_LIBDIR}/openjpeg/include/ -I${mingw_LIBDIR}/ogg/include -I${mingw_LIBDIR}/vorbis/include -I${mingw_LIBDIR}/theora/include -I${mingw_LIBDIR}/vpx/include -I${mingw_LIBDIR}/x264/include -I${mingw_LIBDIR}/xvidcore/include -I${mingw_LIBDIR}/dirac/include/dirac -I${mingw_LIBDIR}/schroedinger/include/schroedinger-1.0 -I${mingw_LIBDIR}/zlib/include") +set(FFMPEG_LDFLAGS "-L${mingw_LIBDIR}/lame/lib -L${mingw_LIBDIR}/openjpeg/lib -L${mingw_LIBDIR}/ogg/lib -L${mingw_LIBDIR}/vorbis/lib -L${mingw_LIBDIR}/theora/lib -L${mingw_LIBDIR}/vpx/lib -L${mingw_LIBDIR}/x264/lib -L${mingw_LIBDIR}/xvidcore/lib -L${mingw_LIBDIR}/dirac/lib -L${mingw_LIBDIR}/schroedinger/lib -L${mingw_LIBDIR}/orc/lib -L${mingw_LIBDIR}/zlib/lib") +set(FFMPEG_EXTRA_FLAGS --extra-cflags=${FFMPEG_CFLAGS} --extra-ldflags=${FFMPEG_LDFLAGS}) +set(FFMPEG_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/schroedinger/lib/pkgconfig:${mingw_LIBDIR}/orc/lib/pkgconfig:${mingw_LIBDIR}/x264/lib/pkgconfig:${mingw_LIBDIR}) + +if(WIN32) + set(FFMPEG_ENV set ${FFMPEG_ENV} &&) + set(FFMPEG_EXTRA_FLAGS + ${FFMPEG_EXTRA_FLAGS} + --disable-static + --enable-shared + --enable-w32threads + --disable-pthreads + --enable-libopenjpeg + ) +else() + set(FFMPEG_EXTRA_FLAGS + ${FFMPEG_EXTRA_FLAGS} + --enable-static + --disable-shared + --enable-libopenjpeg) +endif() + +ExternalProject_Add(external_ffmpeg + URL ${FFMPEG_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${FFMPEG_HASH} + PREFIX ${BUILD_DIR}/ffmpeg + CONFIGURE_COMMAND ${CONFIGURE_ENV_NO_PERL} && + cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && + ${FFMPEG_ENV} ${CONFIGURE_COMMAND} ${FFMPEG_EXTRA_FLAGS} + --disable-lzma + --disable-avfilter + --disable-vdpau + --disable-bzlib + --disable-libgsm + --disable-libspeex + --enable-libvpx + --prefix=${LIBDIR}/ffmpeg + --enable-libschroedinger + --enable-libtheora + --enable-libvorbis + --enable-zlib + --enable-stripping + --enable-runtime-cpudetect + --disable-vaapi + --disable-nonfree + --enable-gpl + --disable-postproc + --disable-x11grab + --enable-libmp3lame + --disable-librtmp + --enable-libx264 + --enable-libxvid + --disable-libopencore-amrnb + --disable-libopencore-amrwb + --disable-libdc1394 + --disable-version3 + --disable-debug + --enable-optimizations + --disable-sse + --disable-ssse3 + --enable-ffplay + --disable-openssl + --disable-securetransport + --disable-indev=avfoundation + --disable-indev=qtkit + --disable-sdl + --disable-gnutls + --disable-vda + --disable-videotoolbox + --disable-libxcb + --disable-xlib + --disable-audiotoolbox + --disable-cuvid + --disable-nvenc + --disable-indev=jack + --disable-indev=alsa + --disable-outdev=alsa + PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/ffmpeg/src/external_ffmpeg < ${PATCH_DIR}/ffmpeg.diff + BUILD_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make install + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ffmpeg ${DEFAULT_CMAKE_FLAGS} + INSTALL_DIR ${LIBDIR}/ffmpeg +) + +if(MSVC) + set_target_properties(external_ffmpeg PROPERTIES FOLDER Mingw) +endif(MSVC) + +add_dependencies(external_ffmpeg external_zlib external_faad external_openjpeg external_xvidcore external_x264 external_schroedinger external_vpx external_theora external_vorbis external_ogg external_lame) +if(WIN32) + add_dependencies(external_ffmpeg external_zlib_mingw) +endif() diff --git a/build_files/build_environment/cmake/fftw.cmake b/build_files/build_environment/cmake/fftw.cmake new file mode 100644 index 00000000000..e6e6165199c --- /dev/null +++ b/build_files/build_environment/cmake/fftw.cmake @@ -0,0 +1,40 @@ +# ***** 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(FFTW_EXTRA_ARGS) + +if(WIN32) + set(FFTW3_ENV set CFLAGS=-fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-lto &&) + set(FFTW3_PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/fftw3/src/external_fftw3 < ${PATCH_DIR}/fftw3.diff) +endif() + +ExternalProject_Add(external_fftw3 + URL ${FFTW_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${FFTW_HASH} + PREFIX ${BUILD_DIR}/fftw3 + CONFIGURE_COMMAND ${CONFIGURE_ENV} && ${FFTW3_ENV} cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && ${CONFIGURE_COMMAND} --enable-static --prefix=${mingw_LIBDIR}/fftw3 + PATCH_COMMAND ${FFTW3_PATCH_COMMAND} + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && make install + INSTALL_DIR ${LIBDIR}/fftw3 +) + +if(MSVC) + set_target_properties(external_fftw3 PROPERTIES FOLDER Mingw) +endif(MSVC) diff --git a/build_files/build_environment/cmake/flac.cmake b/build_files/build_environment/cmake/flac.cmake new file mode 100644 index 00000000000..74d222632d0 --- /dev/null +++ b/build_files/build_environment/cmake/flac.cmake @@ -0,0 +1,32 @@ +# ***** 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 ***** + +ExternalProject_Add(external_flac + URL ${FLAC_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${FLAC_HASH} + PREFIX ${BUILD_DIR}/flac + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flac/src/external_flac/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/flac --disable-shared --enable-static + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flac/src/external_flac/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flac/src/external_flac/ && make install + INSTALL_DIR ${LIBDIR}/flac +) + +if(MSVC) + set_target_properties(external_flac PROPERTIES FOLDER Mingw) +endif(MSVC) diff --git a/build_files/build_environment/cmake/flexbison.cmake b/build_files/build_environment/cmake/flexbison.cmake new file mode 100644 index 00000000000..f2908e1ce2c --- /dev/null +++ b/build_files/build_environment/cmake/flexbison.cmake @@ -0,0 +1,31 @@ +# ***** 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(FLEXBISON_EXTRA_ARGS) + +ExternalProject_Add(external_flexbison + URL ${FLEXBISON_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${FLEXBISON_HASH} + PREFIX ${BUILD_DIR}/flexbison + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/flexbison ${DEFAULT_CMAKE_FLAGS} ${FLEXBISON_EXTRA_ARGS} + CONFIGURE_COMMAND echo . + BUILD_COMMAND echo . + INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/flexbison/src/external_flexbison/ ${LIBDIR}/flexbison/ + INSTALL_DIR ${LIBDIR}/flexbison +) diff --git a/build_files/build_environment/cmake/freeglut.cmake b/build_files/build_environment/cmake/freeglut.cmake new file mode 100644 index 00000000000..043b382e8fd --- /dev/null +++ b/build_files/build_environment/cmake/freeglut.cmake @@ -0,0 +1,35 @@ +# ***** 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 ***** + +if(WIN32) + if(BUILD_MODE STREQUAL Release) + set(FREEGLUT_EXTRA_ARGS + -DFREEGLUT_BUILD_SHARED_LIBS=Off + -DFREEGLUT_BUILD_STATIC_LIBS=On + ) + + ExternalProject_Add(external_freeglut + URL ${FREEGLUT_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${FREEGLUT_HASH} + PREFIX ${BUILD_DIR}/freeglut + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/freeglut ${DEFAULT_C_FLAGS} ${DEFAULT_CXX_FLAGS} ${FREEGLUT_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/freeglut + ) + endif() +endif() diff --git a/build_files/build_environment/cmake/freetype.cmake b/build_files/build_environment/cmake/freetype.cmake new file mode 100644 index 00000000000..751b2b1f383 --- /dev/null +++ b/build_files/build_environment/cmake/freetype.cmake @@ -0,0 +1,28 @@ +# ***** 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(FREETYPE_EXTRA_ARGS -DCMAKE_RELEASE_POSTFIX:STRING=2ST -DCMAKE_DEBUG_POSTFIX:STRING=2ST_d -DWITH_BZip2=OFF -DWITH_HarfBuzz=OFF) + +ExternalProject_Add(external_freetype + URL ${FREETYPE_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${FREETYPE_HASH} + PREFIX ${BUILD_DIR}/freetype + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/freetype ${DEFAULT_CMAKE_FLAGS} ${FREETYPE_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/freetype +) diff --git a/build_files/build_environment/cmake/glew.cmake b/build_files/build_environment/cmake/glew.cmake new file mode 100644 index 00000000000..b5d9e4d3310 --- /dev/null +++ b/build_files/build_environment/cmake/glew.cmake @@ -0,0 +1,32 @@ +# ***** 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(GLEW_EXTRA_ARGS + -DBUILD_UTILS=Off + -DBUILD_SHARED_LIBS=Off +) + +ExternalProject_Add(external_glew + URL ${GLEW_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${GLEW_HASH} + PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_glew.txt ${BUILD_DIR}/glew/src/external_glew/CMakeLists.txt + PREFIX ${BUILD_DIR}/glew + CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${LIBDIR}/glew ${DEFAULT_CMAKE_FLAGS} ${GLEW_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/glew +) diff --git a/build_files/build_environment/cmake/glfw.cmake b/build_files/build_environment/cmake/glfw.cmake new file mode 100644 index 00000000000..ae80080525c --- /dev/null +++ b/build_files/build_environment/cmake/glfw.cmake @@ -0,0 +1,28 @@ +# ***** 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(GLFW_EXTRA_ARGS) + +ExternalProject_Add(external_glfw + URL ${GLFW_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${GLFW_HASH} + PREFIX ${BUILD_DIR}/glfw + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/glfw -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${GLFW_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/glfw +) diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake new file mode 100644 index 00000000000..dfdfe50ab49 --- /dev/null +++ b/build_files/build_environment/cmake/harvest.cmake @@ -0,0 +1,300 @@ +# ***** 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 ***** + +######################################################################## +# Copy all generated files to the proper strucure as blender prefers +######################################################################## + +if(NOT DEFINED HARVEST_TARGET) + set(HARVEST_TARGET ${CMAKE_CURRENT_SOURCE_DIR}/Harvest) +endif() +message("HARVEST_TARGET = ${HARVEST_TARGET}") + +if(WIN32) + +if(BUILD_MODE STREQUAL Release) + add_custom_target(Harvest_Release_Results + # Zlib Rename the lib file and copy the include/bin folders + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstatic.lib ${HARVEST_TARGET}/zlib/lib/libz_st.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/zlib/include/ ${HARVEST_TARGET}/zlib/include/ && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/zlib/bin/ ${HARVEST_TARGET}/zlib/bin/ && + # Boost copy lib + rename boost_1_60 to boost + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/ && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/include/boost-1_60/ ${HARVEST_TARGET}/boost/include/ && + # jpeg rename libfile + copy include + ${CMAKE_COMMAND} -E copy ${LIBDIR}/jpg/lib/jpeg-static.lib ${HARVEST_TARGET}/jpeg/lib/libjpeg.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/jpg/include/ ${HARVEST_TARGET}/jpeg/include/ && + # FreeType, straight up copy + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freetype ${HARVEST_TARGET}/freetype && + # pthreads, rename include dir + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/inc/ ${HARVEST_TARGET}/pthreads/include/ && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/lib/ ${HARVEST_TARGET}/pthreads/lib && + # ffmpeg copy include+bin + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/ffmpeg/include ${HARVEST_TARGET}/ffmpeg/include && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/ffmpeg/bin ${HARVEST_TARGET}/ffmpeg/lib && + # sdl merge bin/lib folder, copy include + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/sdl/include/sdl2 ${HARVEST_TARGET}/sdl/include && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/sdl/lib ${HARVEST_TARGET}/sdl/lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/sdl/bin ${HARVEST_TARGET}/sdl/lib && + # openal + ${CMAKE_COMMAND} -E copy ${LIBDIR}/openal/lib/openal32.lib ${HARVEST_TARGET}/openal/lib/openal32.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/openal/bin/openal32.dll ${HARVEST_TARGET}/openal/lib/openal32.dll && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openal/include/ ${HARVEST_TARGET}/openal/include/ && + # OpenImageIO + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/include ${HARVEST_TARGET}/OpenImageIO/include && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/lib ${HARVEST_TARGET}/OpenImageIO/lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/idiff.exe ${HARVEST_TARGET}/OpenImageIO/bin/idiff.exe && + # openEXR + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/ilmbase ${HARVEST_TARGET}/openexr && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openexr/lib ${HARVEST_TARGET}/openexr/lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openexr/include ${HARVEST_TARGET}/openexr/include && + # png + ${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_static.lib ${HARVEST_TARGET}/png/lib/libpng.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/png/include/ ${HARVEST_TARGET}/png/include/ && + # fftw3 + ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/lib/libfftw3.a ${HARVEST_TARGET}/fftw3/lib/libfftw.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/include/fftw3.h ${HARVEST_TARGET}/fftw3/include/fftw3.h && + # freeglut-> opengl + ${CMAKE_COMMAND} -E copy ${LIBDIR}/freeglut/lib/freeglut_static.lib ${HARVEST_TARGET}/opengl/lib/freeglut_static.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freeglut/include/ ${HARVEST_TARGET}/opengl/include/ && + # glew-> opengl + ${CMAKE_COMMAND} -E copy ${LIBDIR}/glew/lib/libglew32.lib ${HARVEST_TARGET}/opengl/lib/glew.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/glew/include/ ${HARVEST_TARGET}/opengl/include/ && + # sndfile + ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/lib/libsndfile.dll.a ${HARVEST_TARGET}/sndfile/lib/libsndfile-1.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/bin/libsndfile-1.dll ${HARVEST_TARGET}/sndfile/lib/libsndfile-1.dll && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/include/sndfile.h ${HARVEST_TARGET}/sndfile/include/sndfile.h && + # tiff + ${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiff.lib ${HARVEST_TARGET}/tiff/lib/libtiff.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/ && + # iconv + ${CMAKE_COMMAND} -E copy ${LIBDIR}/iconv/lib/libiconv.a ${HARVEST_TARGET}/iconv/lib/iconv.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/iconv/include/iconv.h ${HARVEST_TARGET}/iconv/include/iconv.h && + # opencolorIO + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenColorIO/ ${HARVEST_TARGET}/opencolorio && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenColorIO/lib/OpenColorIO.dll ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO.dll && + # Osl + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/osl/ ${HARVEST_TARGET}/osl && + # OpenVDB + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openVDB/ ${HARVEST_TARGET}/openVDB && + # blosc + ${CMAKE_COMMAND} -E copy ${LIBDIR}/blosc/lib/libblosc.lib ${HARVEST_TARGET}/blosc/lib/libblosc.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/blosc/include/ ${HARVEST_TARGET}/blosc/include/ && + # tbb + ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_static.lib ${HARVEST_TARGET}/tbb/lib/tbb.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tbb/include/ ${HARVEST_TARGET}/tbb/include/ && + # llvm + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/ ${HARVEST_TARGET}/llvm/ && + # opencollada + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencollada/ ${HARVEST_TARGET}/opencollada/ && + # opensubdiv + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opensubdiv ${HARVEST_TARGET}/opensubdiv && + # python + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/python/ ${HARVEST_TARGET}/python/ && + # alembic + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/alembic ${HARVEST_TARGET}/alembic && + # hdf5 + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hdf5 ${HARVEST_TARGET}/hdf5 && + # BlendThumb + ${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb64/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb64.dll && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/BlendThumb32/bin/blendthumb.dll ${HARVEST_TARGET}/ThumbHandler/lib/BlendThumb.dll && + # python + ${CMAKE_COMMAND} -E copy ${LIBDIR}/python35.tar.gz ${HARVEST_TARGET}/Release/python35.tar.gz && + # requests + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/requests ${HARVEST_TARGET}/Release/site-packages/requests && + # numpy + ${CMAKE_COMMAND} -E copy ${LIBDIR}/python35_numpy${PYTHON_POSTFIX}_1.10.tar.gz ${HARVEST_TARGET}/Release/python35_numpy_1.10.tar.gz && + # 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 + DEPENDS +) +endif(BUILD_MODE STREQUAL Release) + +if(BUILD_MODE STREQUAL Debug) + add_custom_target(Harvest_Debug_Results + # OpenImageIO + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO_Util.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_Util_d.lib && + # ilmbase+openexr + ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/Half.lib ${HARVEST_TARGET}/openexr/lib/Half_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/Iex-2_2.lib ${HARVEST_TARGET}/openexr/lib/Iex-2_2_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/IexMath-2_2.lib ${HARVEST_TARGET}/openexr/lib/IexMath-2_2_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/IlmThread-2_2.lib ${HARVEST_TARGET}/openexr/lib/IlmThread-2_2_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/ilmbase/lib/Imath-2_2.lib ${HARVEST_TARGET}/openexr/lib/Imath-2_2_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/openexr/lib/IlmImf-2_2.lib ${HARVEST_TARGET}/openexr/lib/IlmImf-2_2_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/openexr/lib/IlmImfUtil-2_2.lib ${HARVEST_TARGET}/openexr/lib/IlmImfUtil-2_2_d.lib && + # opencollada + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/buffer.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/buffer_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/ftoa.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/ftoa_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/GeneratedSaxParser.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/GeneratedSaxParser_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/MathMLSolver.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/MathMLSolver_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/OpenCOLLADABaseUtils.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/OpenCOLLADABaseUtils_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/OpenCOLLADAFramework.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/OpenCOLLADAFramework_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/OpenCOLLADASaxFrameworkLoader_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/OpenCOLLADAStreamWriter.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/OpenCOLLADAStreamWriter_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/pcre.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/pcre_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/UTF.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/UTF_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencollada/lib/opencollada/xml.lib ${HARVEST_TARGET}/opencollada/lib/opencollada/xml_d.lib && + # blosc + ${CMAKE_COMMAND} -E copy ${LIBDIR}/blosc/lib/libblosc_d.lib ${HARVEST_TARGET}/blosc/lib/libblosc_d.lib && + # boost + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/ && + # llvm + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/lib/ ${HARVEST_TARGET}/llvm/debug/lib/ && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/bin/ ${HARVEST_TARGET}/llvm/debug/bin/ && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/include/ ${HARVEST_TARGET}/llvm/debug/include/ && + # osl + ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslcomp.lib ${HARVEST_TARGET}/osl/lib/oslcomp_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslexec.lib ${HARVEST_TARGET}/osl/lib/oslexec_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslquery.lib ${HARVEST_TARGET}/osl/lib/oslquery_d.lib && + # opensubdiv + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opensubdiv/lib/osdCPU.lib ${HARVEST_TARGET}/opensubdiv/lib/osdCPU_d.lib && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/opensubdiv/lib/osdGPU.lib ${HARVEST_TARGET}/opensubdiv/lib/osdGPU_d.lib && + # tbb + ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_static.lib ${HARVEST_TARGET}/tbb/lib/tbb_debug.lib && + # openvdb + ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib && + # python + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/python/ ${HARVEST_TARGET}/python/ && + # alembic + ${CMAKE_COMMAND} -E copy ${LIBDIR}/alembic/lib/alembic.lib ${HARVEST_TARGET}/alembic/lib/alembic_d.lib && + # hdf5 + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hdf5/lib ${HARVEST_TARGET}/hdf5/lib && + # numpy + ${CMAKE_COMMAND} -E copy ${LIBDIR}/python35_numpy_1.10d.tar.gz ${HARVEST_TARGET}/Release/python35_numpy_1.10d.tar.gz && + # python + ${CMAKE_COMMAND} -E copy ${LIBDIR}/python35_d.tar.gz ${HARVEST_TARGET}/Release/python35_d.tar.gz + DEPENDS Package_Python +) +endif(BUILD_MODE STREQUAL Debug) + +else(WIN32) + +function(harvest from to) + set(pattern "") + foreach(f ${ARGN}) + set(pattern ${f}) + endforeach() + + if(pattern STREQUAL "") + get_filename_component(dirpath ${to} DIRECTORY) + get_filename_component(filename ${to} NAME) + install( + FILES ${LIBDIR}/${from} + DESTINATION ${HARVEST_TARGET}/${dirpath} + RENAME ${filename}) + else() + install( + DIRECTORY ${LIBDIR}/${from}/ + DESTINATION ${HARVEST_TARGET}/${to} + USE_SOURCE_PERMISSIONS + FILES_MATCHING PATTERN ${pattern} + PATTERN "pkgconfig" EXCLUDE + PATTERN "cmake" EXCLUDE + PATTERN "clang" EXCLUDE) + endif() +endfunction() + +harvest(alembic/include alembic/include "*.h") +harvest(alembic/lib/libAlembic.a alembic/lib/libAlembic.a) +harvest(alembic/bin alembic/bin "*") +harvest(blosc/lib openvdb/lib "*.a") +harvest(boost/include boost/include "*") +harvest(boost/lib boost/lib "*.a") +harvest(ffmpeg/include ffmpeg/include "*.h") +harvest(ffmpeg/lib ffmpeg/lib "*.a") +harvest(fftw3/include fftw3/include "*.h") +harvest(fftw3/lib fftw3/lib "*.a") +harvest(flac/lib sndfile/lib "libFLAC.a") +harvest(freetype/include freetype/include "*.h") +harvest(freetype/lib/libfreetype2ST.a freetype/lib/libfreetype.a) +harvest(glew/include glew/include "*.h") +harvest(glew/lib glew/lib "*.a") +harvest(ilmbase openexr "*") +harvest(ilmbase/include openexr/include "*.h") +harvest(jemalloc/include jemalloc/include "*.h") +harvest(jemalloc/lib jemalloc/lib "*.a") +harvest(jpg/include jpeg/include "*.h") +harvest(jpg/lib jpeg/lib "libjpeg.a") +harvest(lame/lib ffmpeg/lib "*.a") +harvest(llvm/bin llvm/bin "llvm-config") +harvest(llvm/lib llvm/lib "libLLVM*.a") +harvest(ogg/lib ffmpeg/lib "*.a") +harvest(openal/include openal/include "*.h") +if(UNIX AND NOT APPLE) + harvest(openal/lib openal/lib "*.a") +endif() +harvest(opencollada/include/opencollada opencollada/include "*.h") +harvest(opencollada/lib/opencollada opencollada/lib "*.a") +harvest(opencolorio/include opencolorio/include "*.h") +harvest(opencolorio/lib opencolorio/lib "*.a") +harvest(openexr/include openexr/include "*.h") +harvest(openexr/lib openexr/lib "*.a") +harvest(openimageio/bin openimageio/bin "idiff") +harvest(openimageio/bin openimageio/bin "maketx") +harvest(openimageio/bin openimageio/bin "oiiotool") +harvest(openimageio/include openimageio/include "*") +harvest(openimageio/lib openimageio/lib "*.a") +harvest(openjpeg/include/openjpeg-1.5 openjpeg/include "*.h") +harvest(openjpeg/lib openjpeg/lib "*.a") +harvest(opensubdiv/include opensubdiv/include "*.h") +harvest(opensubdiv/lib opensubdiv/lib "*.a") +harvest(openvdb/include/openvdb/openvdb openvdb/include/openvdb "*.h") +harvest(openvdb/lib openvdb/lib "*.a") +harvest(orc/lib/liborc-0.4.a ffmpeg/lib/liborc.a) +harvest(osl/bin osl/bin "oslc") +harvest(osl/include osl/include "*.h") +harvest(osl/lib osl/lib "*.a") +harvest(osl/shaders osl/shaders "*.h") +harvest(png/include png/include "*.h") +harvest(png/lib png/lib "*.a") +harvest(python/bin python/bin "python${PYTHON_SHORT_VERSION}m") +harvest(python/include python/include "*h") +if(UNIX AND NOT APPLE) + harvest(python/lib/libpython${PYTHON_SHORT_VERSION}m.a python/lib/libpython${PYTHON_SHORT_VERSION}m.a) + harvest(python/lib/python${PYTHON_SHORT_VERSION} python/lib/python${PYTHON_SHORT_VERSION} "*") + harvest(requests python/lib/python${PYTHON_SHORT_VERSION}/site-packages/requests "*") + harvest(numpy python/lib/python${PYTHON_SHORT_VERSION}/site-packages/numpy "*") +else() + harvest(python/lib/libpython${PYTHON_SHORT_VERSION}m.a python/lib/python${PYTHON_SHORT_VERSION}/libpython${PYTHON_SHORT_VERSION}m.a) + harvest(python/release release "*") + harvest(requests release/site-packages/requests "*") + harvest(numpy release/site-packages/numpy "*") +endif() +harvest(schroedinger/lib/libschroedinger-1.0.a ffmpeg/lib/libschroedinger.a) +harvest(sdl/include/SDL2 sdl/include "*.h") +harvest(sdl/lib sdl/lib "libSDL2.a") +harvest(sndfile/include sndfile/include "*.h") +harvest(sndfile/lib sndfile/lib "*.a") +harvest(spnav/include spnav/include "*.h") +harvest(spnav/lib spnav/lib "*.a") +harvest(tbb/include tbb/include "*.h") +harvest(tbb/lib/libtbb_static.a tbb/lib/libtbb.a) +harvest(theora/lib ffmpeg/lib "*.a") +harvest(tiff/include tiff/include "*.h") +harvest(tiff/lib tiff/lib "*.a") +harvest(vorbis/lib ffmpeg/lib "*.a") +harvest(vpx/lib ffmpeg/lib "*.a") +harvest(webp/lib ffmpeg/lib "*.a") +harvest(x264/lib ffmpeg/lib "*.a") +harvest(xml2/lib opencollada/lib "*.a") +harvest(xvidcore/lib ffmpeg/lib "*.a") + +endif(WIN32) diff --git a/build_files/build_environment/cmake/hdf5.cmake b/build_files/build_environment/cmake/hdf5.cmake new file mode 100644 index 00000000000..09d40d0605f --- /dev/null +++ b/build_files/build_environment/cmake/hdf5.cmake @@ -0,0 +1,42 @@ +# ***** 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(HDF5_EXTRA_ARGS + -DHDF5_ENABLE_THREADSAFE=Off + -DHDF5_BUILD_CPP_LIB=Off + -DBUILD_TESTING=Off + -DHDF5_BUILD_TOOLS=Off + -DHDF5_BUILD_EXAMPLES=Off + -DHDF5_BUILD_HL_LIB=On + -DBUILD_STATIC_CRT_LIBS=On + -DBUILD_SHARED_LIBS=On +) + +if(WIN32) + set(HDF5_PATCH ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/hdf5/src/external_hdf5 < ${PATCH_DIR}/hdf5.diff) +endif() + +ExternalProject_Add(external_hdf5 + URL ${HDF5_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${HDF5_HASH} + PREFIX ${BUILD_DIR}/hdf5 + PATCH_COMMAND ${HDF5_PATCH} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/hdf5 ${HDF5_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/hdf5 +) diff --git a/build_files/build_environment/cmake/hidapi.cmake b/build_files/build_environment/cmake/hidapi.cmake new file mode 100644 index 00000000000..cfa4cc53d2d --- /dev/null +++ b/build_files/build_environment/cmake/hidapi.cmake @@ -0,0 +1,29 @@ +# ***** 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(HIDAPI_EXTRA_ARGS) + +ExternalProject_Add(external_hidapi + URL ${HIDAPI_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${HIDAPI_HASH} + PREFIX ${BUILD_DIR}/hidapi + PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_hidapi.txt ${BUILD_DIR}/hidapi/src/external_hidapi/cmakelists.txt && ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/hidapi/src/external_hidapi < ${PATCH_DIR}/hidapi.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/hidapi -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${HIDAPI_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/hidapi +) diff --git a/build_files/build_environment/cmake/iconv.cmake b/build_files/build_environment/cmake/iconv.cmake new file mode 100644 index 00000000000..cd6cf9547df --- /dev/null +++ b/build_files/build_environment/cmake/iconv.cmake @@ -0,0 +1,34 @@ +# ***** 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(ICONV_EXTRA_ARGS) + +ExternalProject_Add(external_iconv + URL ${ICONV_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${ICONV_HASH} + PREFIX ${BUILD_DIR}/iconv + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/iconv/src/external_iconv/ && ${CONFIGURE_COMMAND} --enable-static --prefix=${mingw_LIBDIR}/iconv + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/iconv/src/external_iconv/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/iconv/src/external_iconv/ && make install + INSTALL_DIR ${LIBDIR}/iconv +) + +if(MSVC) + set_target_properties(external_iconv PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/ilmbase.cmake b/build_files/build_environment/cmake/ilmbase.cmake new file mode 100644 index 00000000000..0639848346f --- /dev/null +++ b/build_files/build_environment/cmake/ilmbase.cmake @@ -0,0 +1,35 @@ +# ***** 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 ***** + +if(WIN32) + set(ILMBASE_CMAKE_CXX_STANDARD_LIBRARIES "kernel32${LIBEXT} user32${LIBEXT} gdi32${LIBEXT} winspool${LIBEXT} shell32${LIBEXT} ole32${LIBEXT} oleaut32${LIBEXT} uuid${LIBEXT} comdlg32${LIBEXT} advapi32${LIBEXT} psapi${LIBEXT}") +endif() + +set(ILMBASE_EXTRA_ARGS + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_CXX_STANDARD_LIBRARIES=${ILMBASE_CMAKE_CXX_STANDARD_LIBRARIES} +) + +ExternalProject_Add(external_ilmbase + URL ${ILMBASE_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${ILMBASE_HASH} + PREFIX ${BUILD_DIR}/ilmbase + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ilmbase ${DEFAULT_CMAKE_FLAGS} ${ILMBASE_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/openexr +) diff --git a/build_files/build_environment/cmake/jemalloc.cmake b/build_files/build_environment/cmake/jemalloc.cmake new file mode 100644 index 00000000000..c39ba448917 --- /dev/null +++ b/build_files/build_environment/cmake/jemalloc.cmake @@ -0,0 +1,28 @@ +# ***** 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 ***** + +ExternalProject_Add(external_jemalloc + URL ${JEMALLOC_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${JEMALLOC_HASH} + PREFIX ${BUILD_DIR}/jemalloc + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/jemalloc --disable-shared --enable-static --with-pic + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && make install + INSTALL_DIR ${LIBDIR}/jemalloc +) diff --git a/build_files/build_environment/cmake/jpeg.cmake b/build_files/build_environment/cmake/jpeg.cmake new file mode 100644 index 00000000000..1f2b04387f0 --- /dev/null +++ b/build_files/build_environment/cmake/jpeg.cmake @@ -0,0 +1,65 @@ +# ***** 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 ***** + +if(WIN32) + # cmake for windows + set(JPEG_EXTRA_ARGS -DWITH_JPEG8=ON -DCMAKE_DEBUG_POSTFIX=d) + + ExternalProject_Add(external_jpeg + URL ${JPEG_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${JPEG_HASH} + PREFIX ${BUILD_DIR}/jpg + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/jpg ${DEFAULT_CMAKE_FLAGS} ${JPEG_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/jpg + ) + + if(BUILD_MODE STREQUAL Debug) + ExternalProject_Add_Step(external_jpeg after_install + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/jpg/lib/jpegd${LIBEXT} ${LIBDIR}/jpg/lib/jpeg${LIBEXT} + DEPENDEES install + ) + endif() + + if(BUILD_MODE STREQUAL Release) + set(JPEG_LIBRARY jpeg-static${LIBEXT}) + else() + set(JPEG_LIBRARY jpeg-staticd${LIBEXT}) + endif() +else(WIN32) + # autoconf for unix + if(APPLE) + set(JPEG_EXTRA_ARGS --host x86_64-apple-darwin --with-jpeg8) + else() + set(JPEG_EXTRA_ARGS --with-jpeg8) + endif() + + ExternalProject_Add(external_jpeg + URL ${JPEG_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${JPEG_HASH} + CONFIGURE_COMMAND ${CONFIGURE_ENV} && autoreconf -fiv && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/jpg NASM=yasm ${JPEG_EXTRA_ARGS} + BUILD_IN_SOURCE 1 + BUILD_COMMAND ${CONFIGURE_ENV} && make install + PREFIX ${BUILD_DIR}/jpg + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/jpg ${DEFAULT_CMAKE_FLAGS} ${JPEG_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/jpg + ) + + set(JPEG_LIBRARY libjpeg${LIBEXT}) +endif(WIN32) diff --git a/build_files/build_environment/cmake/lame.cmake b/build_files/build_environment/cmake/lame.cmake new file mode 100644 index 00000000000..a489b2302ce --- /dev/null +++ b/build_files/build_environment/cmake/lame.cmake @@ -0,0 +1,47 @@ +# ***** 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(LAME_EXTRA_ARGS) +if(MSVC) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") + set(LAME_EXTRA_ARGS CFLAGS=-msse) + endif() +endif() + +ExternalProject_Add(external_lame + URL ${LAME_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${LAME_HASH} + PREFIX ${BUILD_DIR}/lame + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lame/src/external_lame/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/lame --disable-shared --enable-static ${LAME_EXTRA_ARGS} + --enable-export=full + --with-fileio=sndfile + --without-vorbis + --with-pic + --disable-mp3x + --disable-mp3rtp + --disable-gtktest + --enable-export=full + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lame/src/external_lame/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lame/src/external_lame/ && make install + INSTALL_DIR ${LIBDIR}/lame +) + +if(MSVC) + set_target_properties(external_lame PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/lapack.cmake b/build_files/build_environment/cmake/lapack.cmake new file mode 100644 index 00000000000..3110503db52 --- /dev/null +++ b/build_files/build_environment/cmake/lapack.cmake @@ -0,0 +1,43 @@ +# ***** 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(LAPACK_EXTRA_ARGS) + +if(WIN32) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(LAPACK_EXTRA_ARGS -G "MSYS Makefiles" -DCMAKE_Fortran_COMPILER=${DOWNLOAD_DIR}/mingw/mingw64/bin/gfortran.exe) + else() + set(LAPACK_EXTRA_ARGS -G "MSYS Makefiles" -DCMAKE_Fortran_COMPILER=${DOWNLOAD_DIR}/mingw/mingw32/bin/gfortran.exe) + endif() +endif() + +ExternalProject_Add(external_lapack + URL ${LAPACK_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${LAPACK_HASH} + PREFIX ${BUILD_DIR}/lapack + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lapack/src/external_lapack/ && ${CMAKE_COMMAND} ${LAPACK_EXTRA_ARGS} -DBUILD_TESTING=Off -DCMAKE_INSTALL_PREFIX=${LIBDIR}/lapack . + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lapack/src/external_lapack/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lapack/src/external_lapack/ && make install + + INSTALL_DIR ${LIBDIR}/lapack +) + +if(MSVC) + set_target_properties(external_lapack PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/llvm.cmake b/build_files/build_environment/cmake/llvm.cmake new file mode 100644 index 00000000000..b9afa4d1b7b --- /dev/null +++ b/build_files/build_environment/cmake/llvm.cmake @@ -0,0 +1,44 @@ +# ***** 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(LLVM_EXTRA_ARGS + -DLLVM_USE_CRT_RELEASE=MT + -DLLVM_USE_CRT_DEBUG=MTd + -DLLVM_INCLUDE_TESTS=OFF + -DLLVM_TARGETS_TO_BUILD=X86 + -DLLVM_INCLUDE_EXAMPLES=OFF + -DLLVM_ENABLE_TERMINFO=OFF +) + +if(WIN32) + set(LLVM_GENERATOR "NMake Makefiles") +else() + set(LLVM_GENERATOR "Unix Makefiles") +endif() + +# short project name due to long filename issues on windows +ExternalProject_Add(ll + URL ${LLVM_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${LLVM_HASH} + CMAKE_GENERATOR ${LLVM_GENERATOR} + PREFIX ${BUILD_DIR}/ll + PATCH_COMMAND ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/ll/src/ll < ${PATCH_DIR}/llvm-alloca-fix.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/llvm ${DEFAULT_CMAKE_FLAGS} ${LLVM_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/llvm +) diff --git a/build_files/build_environment/cmake/mingw.cmake b/build_files/build_environment/cmake/mingw.cmake new file mode 100644 index 00000000000..d8b87d8bd4e --- /dev/null +++ b/build_files/build_environment/cmake/mingw.cmake @@ -0,0 +1,40 @@ +# ***** 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 ***** + +if(MSVC) + if(BUILD_MODE STREQUAL Release) + set(NUMPY_POSTFIX) + message("Python_binary = ${PYTHON_BINARY}") + message("Python_post = ${PYTHON_POSTFIX}") + + ExternalProject_Add(external_numpy + URL ${NUMPY_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${NUMPY_HASH} + PREFIX ${BUILD_DIR}/numpy + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff + CONFIGURE_COMMAND "" + LOG_BUILD 1 + BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build + INSTALL_COMMAND ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5" + ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python35_numpy${PYTHON_POSTFIX}_1.11.tar.gz" "." + ) + + add_dependencies(external_numpy Make_Python_Environment) + endif() +endif() diff --git a/build_files/build_environment/cmake/numpy.cmake b/build_files/build_environment/cmake/numpy.cmake new file mode 100644 index 00000000000..51cb30799a7 --- /dev/null +++ b/build_files/build_environment/cmake/numpy.cmake @@ -0,0 +1,56 @@ +# ***** 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 ***** + +if(MSVC) + if(BUILD_MODE STREQUAL Debug) + set(NUMPY_DIR_POSTFIX -pydebug) + set(NUMPY_ARCHIVE_POSTFIX d) + set(NUMPY_BUILD_OPTION --debug) + else() + set(NUMPY_DIR_POSTFIX) + set(NUMPY_ARCHIVE_POSTFIX) + set(NUMPY_BUILD_OPTION) + endif(BUILD_MODE STREQUAL Debug) +endif() + +set(NUMPY_POSTFIX) + +if(WIN32) + set(NUMPY_INSTALL + ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5${NUMPY_DIR_POSTFIX}" + ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python35_numpy_${NUMPY_SHORT_VERSION}${NUMPY_ARCHIVE_POSTFIX}.tar.gz" "." + ) +else() + set(NUMPY_INSTALL + ${CMAKE_COMMAND} -E copy_directory "${BUILD_DIR}/numpy/src/external_numpy/build/lib.${PYTHON_ARCH2}-3.5/numpy/" "${LIBDIR}/numpy/" + ) +endif() + +ExternalProject_Add(external_numpy + URL ${NUMPY_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${NUMPY_HASH} + PREFIX ${BUILD_DIR}/numpy + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/numpy/src/external_numpy < ${PATCH_DIR}/numpy.diff + CONFIGURE_COMMAND "" + LOG_BUILD 1 + BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build ${NUMPY_BUILD_OPTION} + INSTALL_COMMAND ${NUMPY_INSTALL} +) + +add_dependencies(external_numpy Make_Python_Environment) diff --git a/build_files/build_environment/cmake/ogg.cmake b/build_files/build_environment/cmake/ogg.cmake new file mode 100644 index 00000000000..1f69cee0996 --- /dev/null +++ b/build_files/build_environment/cmake/ogg.cmake @@ -0,0 +1,32 @@ +# ***** 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 ***** + +ExternalProject_Add(external_ogg + URL ${OGG_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${OGG_HASH} + PREFIX ${BUILD_DIR}/ogg + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/ogg --disable-shared --enable-static + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make install + INSTALL_DIR ${LIBDIR}/ogg +) + +if(MSVC) + set_target_properties(external_ogg PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/openal.cmake b/build_files/build_environment/cmake/openal.cmake new file mode 100644 index 00000000000..d63c4443ca0 --- /dev/null +++ b/build_files/build_environment/cmake/openal.cmake @@ -0,0 +1,42 @@ +# ***** 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 ***** + +if(BUILD_MODE STREQUAL Release) + set(OPENAL_EXTRA_ARGS + -DALSOFT_UTILS=Off + -DALSOFT_NO_CONFIG_UTIL=On + -DALSOFT_EXAMPLES=Off + -DALSOFT_TESTS=Off + -DALSOFT_CONFIG=Off + -DALSOFT_HRTF_DEFS=Off + -DALSOFT_INSTALL=On + ) + + if(UNIX) + set(OPENAL_EXTRA_ARGS ${OPENAL_EXTRA_ARGS} -DLIBTYPE=STATIC) + endif() + + ExternalProject_Add(external_openal + URL ${OPENAL_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${OPENAL_HASH} + PREFIX ${BUILD_DIR}/openal + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openal ${DEFAULT_CMAKE_FLAGS} ${OPENAL_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/openal + ) +endif() diff --git a/build_files/build_environment/cmake/opencollada.cmake b/build_files/build_environment/cmake/opencollada.cmake new file mode 100644 index 00000000000..9b2a2d9dc4d --- /dev/null +++ b/build_files/build_environment/cmake/opencollada.cmake @@ -0,0 +1,37 @@ +# ***** 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 ***** + +if(UNIX AND NOT APPLE) + set(OPENCOLLADA_EXTRA_ARGS + -DLIBXML2_INCLUDE_DIR=${LIBDIR}/xml2/include/libxml2 + -DLIBXML2_LIBRARIES=${LIBDIR}/xml2/lib/libxml2.a) +endif() + +ExternalProject_Add(external_opencollada + URL ${OPENCOLLADA_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${OPENCOLLADA_HASH} + PREFIX ${BUILD_DIR}/opencollada + PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/opencollada/src/external_opencollada < ${PATCH_DIR}/opencollada.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencollada ${DEFAULT_CMAKE_FLAGS} ${OPENCOLLADA_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/opencollada +) + +if(UNIX AND NOT APPLE) + add_dependencies(external_opencollada external_xml2) +endif() diff --git a/build_files/build_environment/cmake/opencolorio.cmake b/build_files/build_environment/cmake/opencolorio.cmake new file mode 100644 index 00000000000..14fb62af672 --- /dev/null +++ b/build_files/build_environment/cmake/opencolorio.cmake @@ -0,0 +1,70 @@ +# ***** 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(OPENCOLORIO_EXTRA_ARGS + -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING} + -DBoost_USE_MULTITHREADED=ON + -DBoost_USE_STATIC_LIBS=ON + -DBoost_USE_STATIC_RUNTIME=ON + -DBOOST_ROOT=${LIBDIR}/boost + -DBOOST_INCLUDEDIR=${LIBDIR}/boost/include/boost_1_60/boost + -DBoost_NO_SYSTEM_PATHS=ON + -DBoost_DEBUG=ON + -DBoost_MAJOR_VERSION=1 + -DBoost_MINOR_VERSION=60 + -DOCIO_BUILD_APPS=OFF + -DOCIO_BUILD_PYGLUE=OFF + -DOCIO_BUILD_NUKE=OFF +) + +if(WIN32) + set(OPENCOLORIO_EXTRA_ARGS + ${OPENCOLORIO_EXTRA_ARGS} + -DOCIO_USE_BOOST_PTR=ON + -DOCIO_BUILD_STATIC=OFF + -DOCIO_BUILD_SHARED=ON + ) +else() + set(OPENCOLORIO_EXTRA_ARGS + ${OPENCOLORIO_EXTRA_ARGS} + -DOCIO_USE_BOOST_PTR=OFF + -DOCIO_BUILD_STATIC=ON + -DOCIO_BUILD_SHARED=OFF + ) +endif() + +ExternalProject_Add(external_opencolorio + URL ${OPENCOLORIO_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${OPENCOLORIO_HASH} + PREFIX ${BUILD_DIR}/opencolorio + PATCH_COMMAND ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/opencolorio/src/external_opencolorio < ${PATCH_DIR}/opencolorio.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencolorio ${DEFAULT_CMAKE_FLAGS} ${OPENCOLORIO_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/opencolorio +) + +if(NOT WIN32) + add_custom_command( + OUTPUT ${LIBDIR}/opencolorio/lib/libtinyxml.a + COMMAND cp ${BUILD_DIR}/opencolorio/src/external_opencolorio-build/ext/dist/lib/libtinyxml.a ${LIBDIR}/opencolorio/lib/libtinyxml.a + COMMAND cp ${BUILD_DIR}/opencolorio/src/external_opencolorio-build/ext/dist/lib/libyaml-cpp.a ${LIBDIR}/opencolorio/lib/libyaml-cpp.a + ) + add_custom_target(external_opencolorio_extra ALL DEPENDS external_opencolorio ${LIBDIR}/opencolorio/lib/libtinyxml.a) +endif() + +add_dependencies(external_opencolorio external_boost) diff --git a/build_files/build_environment/cmake/openexr.cmake b/build_files/build_environment/cmake/openexr.cmake new file mode 100644 index 00000000000..53a1bc4c146 --- /dev/null +++ b/build_files/build_environment/cmake/openexr.cmake @@ -0,0 +1,41 @@ +# ***** 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 ***** + +if(WIN32) + set(OPENEXR_CMAKE_CXX_STANDARD_LIBRARIES "kernel32${LIBEXT} user32${LIBEXT} gdi32${LIBEXT} winspool${LIBEXT} shell32${LIBEXT} ole32${LIBEXT} oleaut32${LIBEXT} uuid${LIBEXT} comdlg32${LIBEXT} advapi32${LIBEXT} psapi${LIBEXT}") +endif() + +set(OPENEXR_EXTRA_ARGS + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_CXX_STANDARD_LIBRARIES=${OPENEXR_CMAKE_CXX_STANDARD_LIBRARIES} + -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} + -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/ + -DILMBASE_PACKAGE_PREFIX=${LIBDIR}/ilmbase +) + +ExternalProject_Add(external_openexr + URL ${OPENEXR_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${OPENEXR_HASH} + PREFIX ${BUILD_DIR}/openexr + PATCH_COMMAND ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/openexr/src/external_openexr < ${PATCH_DIR}/openexr.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openexr ${DEFAULT_CMAKE_FLAGS} ${OPENEXR_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/openexr +) + +add_dependencies(external_openexr external_zlib external_ilmbase) diff --git a/build_files/build_environment/cmake/openimageio.cmake b/build_files/build_environment/cmake/openimageio.cmake new file mode 100644 index 00000000000..f323161d5f2 --- /dev/null +++ b/build_files/build_environment/cmake/openimageio.cmake @@ -0,0 +1,113 @@ +# ***** 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 ***** + +if(BUILD_MODE STREQUAL Release) + set(OIIO_TOOLS ON) +else() + set(OIIO_TOOLS OFF) +endif() + +if(UNIX AND NOT APPLE) + # This causes linking to static pthread libraries which gives link errors. + # Since we manually specify library paths it should static link other libs. + set(OPENIMAGEIO_LINKSTATIC -DLINKSTATIC=OFF) +else() + set(OPENIMAGEIO_LINKSTATIC -DLINKSTATIC=ON) +endif() + +if(WIN32) + set(PNG_LIBNAME libpng16_static${LIBEXT}) + set(OIIO_SIMD_FLAGS -DUSE_SIMD=sse2) +else() + set(PNG_LIBNAME libpng${LIBEXT}) + set(OIIO_SIMD_FLAGS) +endif() + +set(OPENIMAGEIO_EXTRA_ARGS + -DBUILDSTATIC=ON + ${OPENIMAGEIO_LINKSTATIC} + -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/openexr/ + -DOPENEXR_ILMIMF_LIBRARIES=${LIBDIR}/openexr/lib/IlmImf-2_2${LIBEXT} + -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING} + -DBoost_USE_MULTITHREADED=ON + -DBoost_USE_STATIC_LIBS=ON + -DBoost_USE_STATIC_RUNTIME=ON + -DBOOST_ROOT=${LIBDIR}/boost + -DBOOST_LIBRARYDIR=${LIBDIR}/boost/lib/ + -DBoost_NO_SYSTEM_PATHS=ON + -OIIO_BUILD_CPP11=ON + -DUSE_OPENGL=OFF + -DUSE_TBB=OFF + -DUSE_FIELD3D=OFF + -DUSE_QT=OFF + -DUSE_PYTHON=OFF + -DUSE_GIF=OFF + -DUSE_OPENCV=OFF + -DUSE_OPENSSL=OFF + -DUSE_OPENJPEG=OFF + -DUSE_FFMPEG=OFF + -DUSE_PTEX=OFF + -DUSE_FREETYPE=OFF + -DUSE_LIBRAW=OFF + -DUSE_PYTHON=OFF + -DUSE_PYTHON3=OFF + -DUSE_OCIO=OFF + -DOIIO_BUILD_TOOLS=${OIIO_TOOLS} + -DOIIO_BUILD_TESTS=OFF + -DBUILD_TESTING=OFF + -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} + -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include + -DPNG_LIBRARY=${LIBDIR}/png/lib/${PNG_LIBNAME} + -DPNG_PNG_INCLUDE_DIR=${LIBDIR}/png/include + -DTIFF_LIBRARY=${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${LIBEXT} + -DTIFF_INCLUDE_DIR=${LIBDIR}/tiff/include + -DJPEG_LIBRARY=${LIBDIR}/jpg/lib/${JPEG_LIBRARY} + -DJPEG_INCLUDE_DIR=${LIBDIR}/jpg/include + -DOCIO_PATH=${LIBDIR}/opencolorio/ + -DOpenEXR_USE_STATIC_LIBS=On + -DOPENEXR_HOME=${LIBDIR}/openexr/ + -DILMBASE_INCLUDE_PATH=${LIBDIR}/ilmbase/ + -DILMBASE_PACKAGE_PREFIX=${LIBDIR}/ilmbase/ + -DILMBASE_INCLUDE_DIR=${LIBDIR}/ilmbase/include/ + -DOPENEXR_HALF_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Half${LIBEXT} + -DOPENEXR_IMATH_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Imath-2_2${LIBEXT} + -DOPENEXR_ILMTHREAD_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread-2_2${LIBEXT} + -DOPENEXR_IEX_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex-2_2${LIBEXT} + -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/ + -DOPENEXR_ILMIMF_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT} + -DSTOP_ON_WARNING=OFF + -DWEBP_INCLUDE_DIR=${LIBDIR}/webp/include + -DWEBP_LIBRARY=${LIBDIR}/webp/lib/${LIBPREFIX}webp${LIBEXT} + ${OIIO_SIMD_FLAGS} +) + +ExternalProject_Add(external_openimageio + URL ${OPENIMAGEIO_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${OPENIMAGEIO_HASH} + PREFIX ${BUILD_DIR}/openimageio + PATCH_COMMAND ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/src/include < ${PATCH_DIR}/openimageio_gdi.diff && + ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/openimageio_staticexr.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimageio ${DEFAULT_CMAKE_FLAGS} ${OPENIMAGEIO_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/openimageio +) + +add_dependencies(external_openimageio external_png external_zlib external_ilmbase external_openexr external_jpeg external_boost external_tiff external_webp external_opencolorio) +if(NOT WIN32) + add_dependencies(external_openimageio external_opencolorio_extra) +endif() diff --git a/build_files/build_environment/cmake/openjpeg.cmake b/build_files/build_environment/cmake/openjpeg.cmake new file mode 100644 index 00000000000..66f815034eb --- /dev/null +++ b/build_files/build_environment/cmake/openjpeg.cmake @@ -0,0 +1,43 @@ +# ***** 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 encoder/decoder may use png/tiff/lcms system libraries, but the +# library itself does not depend on them, so should give no problems. + +set(OPENJPEG_EXTRA_ARGS -DBUILD_SHARED_LIBS=OFF) + +if(WIN32) + set(OPENJPEG_EXTRA_ARGS -G "MSYS Makefiles") +else() + set(OPENJPEG_EXTRA_ARGS ${DEFAULT_CMAKE_FLAGS}) +endif() + +ExternalProject_Add(external_openjpeg + URL ${OPENJPEG_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${OPENJPEG_HASH} + PREFIX ${BUILD_DIR}/openjpeg + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build && ${CMAKE_COMMAND} ${OPENJPEG_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg -DBUILD_SHARED_LIBS=Off -DBUILD_THIRDPARTY=OFF ${BUILD_DIR}/openjpeg/src/external_openjpeg + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build/ && make install + INSTALL_DIR ${LIBDIR}/openjpeg +) + +if(MSVC) + set_target_properties(external_openjpeg PROPERTIES FOLDER Mingw) +endif(MSVC) diff --git a/build_files/build_environment/cmake/opensubdiv.cmake b/build_files/build_environment/cmake/opensubdiv.cmake new file mode 100644 index 00000000000..5a3a4d142fa --- /dev/null +++ b/build_files/build_environment/cmake/opensubdiv.cmake @@ -0,0 +1,71 @@ +# ***** 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(OPENSUBDIV_EXTRA_ARGS + -DNO_EXAMPLES=ON + -DNO_REGRESSION=ON + -DNO_PYTHON=ON + -DNO_MAYA=ON + -DNO_PTEX=ON + -DNO_DOC=ON + -DNO_CLEW=OFF + -DNO_OPENCL=OFF + -DNO_TUTORIALS=ON + -DGLEW_INCLUDE_DIR=${LIBDIR}/glew/include + -DGLEW_LIBRARY=${LIBDIR}/glew/lib/libGLEW${LIBEXT} + -DGLFW_INCLUDE_DIR=${LIBDIR}/glfw/include + -DGLFW_LIBRARIES=${LIBDIR}/glfw/lib/glfw3${LIBEXT} +) + +if(WIN32) + #no cuda support for vc15 yet + if(msvc15) + set(OPENSUBDIV_CUDA ON) + else() + set(OPENSUBDIV_CUDA ON) + endif() + + set(OPENSUBDIV_EXTRA_ARGS + ${OPENSUBDIV_EXTRA_ARGS} + -DNO_CUDA=${OPENSUBDIV_CUDA} + -DCLEW_INCLUDE_DIR=${LIBDIR}/clew/include/cl + -DCLEW_LIBRARY=${LIBDIR}/clew/lib/clew${LIBEXT} + -DCUEW_INCLUDE_DIR=${LIBDIR}/cuew/include + -DCUEW_LIBRARY=${LIBDIR}/cuew/lib/cuew${LIBEXT} + -DCMAKE_EXE_LINKER_FLAGS_RELEASE=libcmt.lib + ) +else() + set(OPENSUBDIV_EXTRA_ARGS + ${OPENSUBDIV_EXTRA_ARGS} + -DNO_CUDA=ON + -DCUEW_INCLUDE_DIR=${LIBDIR}/cuew/include + -DCLEW_LIBRARY=${LIBDIR}/clew/lib/static/${LIBPREFIX}clew${LIBEXT} + ) +endif() + +ExternalProject_Add(external_opensubdiv + URL ${OPENSUBDIV_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${OPENSUBDIV_Hash} + PREFIX ${BUILD_DIR}/opensubdiv + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/opensubdiv/src/external_opensubdiv < ${PATCH_DIR}/opensubdiv.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opensubdiv -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${OPENSUBDIV_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/opensubdiv +) + +add_dependencies(external_opensubdiv external_glew external_glfw external_clew external_cuew) diff --git a/build_files/build_environment/cmake/openvdb.cmake b/build_files/build_environment/cmake/openvdb.cmake new file mode 100644 index 00000000000..a71598c1a3b --- /dev/null +++ b/build_files/build_environment/cmake/openvdb.cmake @@ -0,0 +1,71 @@ +# ***** 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 ***** + +if(BUILD_MODE STREQUAL Debug) + set(BLOSC_POST _d) +endif() + +set(OPENVDB_EXTRA_ARGS + -DILMBASE_HOME=${LIBDIR}/ilmbase/ + -DILMBASE_CUSTOM=ON + -DILMBASE_CUSTOM_LIBRARIES=Half;Imath-2_2;IlmThread-2_2;Iex-2_2 + -DILMBASE_INCLUDE_DIR=${LIBDIR}/ilmbase/include/ + -DILMBASE_HALF_LIBRARIES=${LIBDIR}/ilmbase/lib/Half${LIBEXT} + -DILMBASE_IMATH_LIBRARIES=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Imath-2_2${LIBEXT} + -DILMBASE_ILMTHREAD_LIBRARIES=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread-2_2${LIBEXT} + -DILMBASE_IEX_LIBRARIES=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex-2_2${LIBEXT} + -DOPENEXR_HOME=${LIBDIR}/openexr/ + -DOPENEXR_USE_STATIC_LIBS=ON + -DOPENEXR_CUSTOM=ON + -DOPENEXR_CUSTOM_LIBRARY=IlmImf-2_2 + -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/ + -DOPENEXR_ILMIMF_LIBRARIES=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT} + -DTBB_ROOT_DIR=${LIBDIR}/tbb/ + -DTBB_INCLUDE_DIRS=${LIBDIR}/tbb/include + -DTBB_LIBRARY=${LIBDIR}/tbb/lib/tbb_static${LIBEXT} + -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING} + -DBoost_USE_MULTITHREADED=ON + -DBoost_USE_STATIC_LIBS=ON + -DBoost_USE_STATIC_RUNTIME=ON + -DBOOST_ROOT=${LIBDIR}/boost + -DBoost_NO_SYSTEM_PATHS=ON + -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} + -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/ + -DWITH_BLOSC=ON + -DBLOSC_INCLUDE_DIR=${LIBDIR}/blosc/include/ + -DBLOSC_LIBRARY=${LIBDIR}/blosc/lib/libblosc${BLOSC_POST}${LIBEXT} +) + +set(OPENVDB_EXTRA_ARGS ${OPENVDB_EXTRA_ARGS}) + +# CMake script for OpenVDB based on https://raw.githubusercontent.com/diekev/openvdb-cmake/master/CMakeLists.txt +# can't be in external_openvdb because of how the includes are setup. + +ExternalProject_Add(openvdb + URL ${OPENVDB_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${OPENVDB_HASH} + PREFIX ${BUILD_DIR}/openvdb + PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_openvdb.txt ${BUILD_DIR}/openvdb/src/openvdb/CMakeLists.txt && + ${CMAKE_COMMAND} -E copy_directory ${PATCH_DIR}/cmake/ ${BUILD_DIR}/openvdb/src/openvdb/cmake/ && + ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb_vc2013.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openvdb ${DEFAULT_CMAKE_FLAGS} ${OPENVDB_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/openvdb +) + +add_dependencies(openvdb external_tbb external_boost external_ilmbase external_openexr external_zlib external_blosc) diff --git a/build_files/build_environment/cmake/options.cmake b/build_files/build_environment/cmake/options.cmake new file mode 100644 index 00000000000..16d79d463f6 --- /dev/null +++ b/build_files/build_environment/cmake/options.cmake @@ -0,0 +1,202 @@ +# ***** 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 ***** + +if(WIN32) + option(ENABLE_MINGW64 "Enable building of ffmpeg/iconv/libsndfile/lapack/fftw3 by installing mingw64" ON) +endif() +set(MAKE_THREADS 1 CACHE STRING "Number of threads to run make with") + +if(NOT BUILD_MODE) + set(BUILD_MODE "Release") + message(STATUS "Build type not specified: defaulting to a release build.") +endif() +Message("BuildMode = ${BUILD_MODE}") + +if(BUILD_MODE STREQUAL "Debug") + set(LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/Debug) +ELSE(BUILD_MODE STREQUAL "Debug") + set(LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/Release) +ENDIF(BUILD_MODE STREQUAL "Debug") + +set(DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/downloads) +set(PATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/patches) +set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/build) + +message("LIBDIR = ${LIBDIR}") +message("DOWNLOAD_DIR = ${DOWNLOAD_DIR}") +message("PATCH_DIR = ${PATCH_DIR}") +message("BUILD_DIR = ${BUILD_DIR}") + +if(WIN32) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/patch.exe) + else() + set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/patch.exe) + endif() + set(LIBEXT ".lib") + set(LIBPREFIX "") + + # For OIIO and OSL + set(COMMON_DEFINES /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS) + + # TODO FIXME highly MSVC specific + if(WITH_OPTIMIZED_DEBUG) + set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + else() + set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd /Zi /Ob0 /Od /RTC1 /D_DEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + endif() + set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + set(BLENDER_CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + + if(WITH_OPTIMIZED_DEBUG) + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /D PLATFORM_WINDOWS /MTd /Zi /Ob0 /Od /RTC1 /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + else() + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/MTd /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + endif() + set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + set(BLENDER_CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + + set(PLATFORM_FLAGS) + set(PLATFORM_CXX_FLAGS) + set(PLATFORM_CMAKE_FLAGS) + + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(MINGW_PATH ${DOWNLOAD_DIR}/mingw/mingw64) + set(MINGW_SHELL ming64sh.cmd) + set(PERL_SHELL ${DOWNLOAD_DIR}/perl/portableshell.bat) + set(MINGW_HOST x86_64-w64-mingw32) + else() + set(MINGW_PATH ${DOWNLOAD_DIR}/mingw/mingw32) + set(MINGW_SHELL ming32sh.cmd) + set(PERL_SHELL ${DOWNLOAD_DIR}/perl32/portableshell.bat) + set(MINGW_HOST i686-w64-mingw32) + endif() + + set(CONFIGURE_ENV + cd ${MINGW_PATH} && + call ${MINGW_SHELL} && + call ${PERL_SHELL} && + set path && + set CFLAGS=-g && + set LDFLAGS=-Wl,--as-needed -static-libgcc + ) + + set(CONFIGURE_ENV_NO_PERL + cd ${MINGW_PATH} && + call ${MINGW_SHELL} && + set path && + set CFLAGS=-g && + set LDFLAGS=-Wl,--as-needed -static-libgcc + ) + + set(CONFIGURE_COMMAND sh ./configure) +else() + set(PATCH_CMD patch) + set(LIBEXT ".a") + set(LIBPREFIX "lib") + + if(APPLE) + set(OSX_ARCHITECTURES x86_64) + set(OSX_DEPLOYMENT_TARGET 10.9) + set(OSX_SDK_VERSION 10.12) + set(OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OSX_SDK_VERSION}.sdk) + + set(PLATFORM_CFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}") + set(PLATFORM_CXXFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -std=c++11 -stdlib=libc++") + set(PLATFORM_LDFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}") + set(PLATFORM_BUILD_TARGET --build=x86_64-apple-darwin13.0.0) # OS X 10.9 + set(PLATFORM_CMAKE_FLAGS + -DCMAKE_OSX_ARCHITECTURES:STRING=${OSX_ARCHITECTURES} + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_SYSROOT:PATH=${OSX_SYSROOT} + ) + else() + set(PLATFORM_CFLAGS "-fPIC") + set(PLATFORM_CXXFLAGS "-std=c++11 -fPIC") + set(PLATFORM_LDFLAGS) + set(PLATFORM_BUILD_TARGET) + set(PLATFORM_CMAKE_FLAGS) + endif() + + if(WITH_OPTIMIZED_DEBUG) + set(BLENDER_CMAKE_C_FLAGS_DEBUG "-O2 -DNDEBUG") + else() + set(BLENDER_CMAKE_C_FLAGS_DEBUG "-g") + endif() + set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") + set(BLENDER_CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") + set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") + + if(WITH_OPTIMIZED_DEBUG) + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "-O2 -DNDEBUG ${PLATFORM_CXXFLAGS}") + else() + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "-g ${PLATFORM_CXXFLAGS}") + endif() + + set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG ${PLATFORM_CXXFLAGS}") + set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${PLATFORM_CXXFLAGS}") + set(BLENDER_CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG ${PLATFORM_CXXFLAGS}") + + set(CONFIGURE_ENV + export MACOSX_DEPLOYMENT_TARGET=${OSX_DEPLOYMENT_TARGET} && + export CFLAGS=${PLATFORM_CFLAGS} && + export CXXFLAGS=${PLATFORM_CXXFLAGS} && + export LDFLAGS=${PLATFORM_LDFLAGS} + ) + set(CONFIGURE_ENV_NO_PERL ${CONFIGURE_ENV}) + set(CONFIGURE_COMMAND ./configure ${PLATFORM_BUILD_TARGET}) +endif() + +set(DEFAULT_CMAKE_FLAGS + -DCMAKE_BUILD_TYPE=${BUILD_MODE} + -DCMAKE_C_FLAGS_DEBUG=${BLENDER_CMAKE_C_FLAGS_DEBUG} + -DCMAKE_C_FLAGS_MINSIZEREL=${BLENDER_CMAKE_C_FLAGS_MINSIZEREL} + -DCMAKE_C_FLAGS_RELEASE=${BLENDER_CMAKE_C_FLAGS_RELEASE} + -DCMAKE_C_FLAGS_RELWITHDEBINFO=${BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO} + -DCMAKE_CXX_FLAGS_DEBUG=${BLENDER_CMAKE_CXX_FLAGS_DEBUG} + -DCMAKE_CXX_FLAGS_MINSIZEREL=${BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL} + -DCMAKE_CXX_FLAGS_RELEASE=${BLENDER_CMAKE_CXX_FLAGS_RELEASE} + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} + ${PLATFORM_CMAKE_FLAGS} +) + +if(WIN32) + #we need both flavors to build the thumbnail dlls + if(MSVC12) + set(GENERATOR_32 "Visual Studio 12 2013") + set(GENERATOR_64 "Visual Studio 12 2013 Win64") + elseif(MSVC14) + set(GENERATOR_32 "Visual Studio 14 2015") + set(GENERATOR_64 "Visual Studio 14 2015 Win64") + endif() +endif() + + +if(WIN32) + set(ZLIB_LIBRARY zlibstatic${LIBEXT}) +else() + set(ZLIB_LIBRARY libz${LIBEXT}) +endif() + +if(MSVC) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +endif() + +set(CMAKE_INSTALL_MESSAGE LAZY) diff --git a/build_files/build_environment/cmake/orc.cmake b/build_files/build_environment/cmake/orc.cmake new file mode 100644 index 00000000000..aac7884f49e --- /dev/null +++ b/build_files/build_environment/cmake/orc.cmake @@ -0,0 +1,32 @@ +# ***** 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 ***** + +ExternalProject_Add(external_orc + URL ${ORC_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${ORC_HASH} + PREFIX ${BUILD_DIR}/orc + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/orc/src/external_orc/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/orc --disable-shared --enable-static + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/orc/src/external_orc/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/orc/src/external_orc/ && make install + INSTALL_DIR ${LIBDIR}/orc +) + +if(MSVC) + set_target_properties(external_orc PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/osl.cmake b/build_files/build_environment/cmake/osl.cmake new file mode 100644 index 00000000000..97b86c39baa --- /dev/null +++ b/build_files/build_environment/cmake/osl.cmake @@ -0,0 +1,87 @@ +# ***** 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 ***** + +if(WIN32) + set(OSL_CMAKE_CXX_STANDARD_LIBRARIES "kernel32${LIBEXT} user32${LIBEXT} gdi32${LIBEXT} winspool${LIBEXT} shell32${LIBEXT} ole32${LIBEXT} oleaut32${LIBEXT} uuid${LIBEXT} comdlg32${LIBEXT} advapi32${LIBEXT} psapi${LIBEXT}") + set(OSL_FLEX_BISON -DFLEX_EXECUTABLE=${LIBDIR}/flexbison/win_flex.exe -DFLEX_EXTRA_OPTIONS="--wincompat" -DBISON_EXECUTABLE=${LIBDIR}/flexbison/win_bison.exe) + set(OSL_OPENIMAGEIO_LIBRARY "${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO${LIBEXT};${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO_Util${LIBEXT};${LIBDIR}/png/lib/libpng16${LIBEXT};${LIBDIR}/jpg/lib/${LIBPREFIX}jpeg${LIBEXT};${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${LIBEXT};${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT}") + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") + set(OSL_SIMD_FLAGS -DOIIO_SIMD=0) + else() + set(OSL_SIMD_FLAGS -DOIIO_SIMD=sse2) + endif() +else() + set(OSL_CMAKE_CXX_STANDARD_LIBRARIES) + set(OSL_FLEX_BISON) + set(OSL_OPENIMAGEIO_LIBRARY "${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO${LIBEXT};${LIBDIR}/openimageio/lib/${LIBPREFIX}OpenImageIO_Util${LIBEXT};${LIBDIR}/png/lib/${LIBPREFIX}png16${LIBEXT};${LIBDIR}/jpg/lib/${LIBPREFIX}jpeg${LIBEXT};${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${LIBEXT};${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT}") +endif() + +set(OSL_ILMBASE_CUSTOM_LIBRARIES "${LIBDIR}/ilmbase/lib/Imath-2_2.lib^^${LIBDIR}/ilmbase/lib/Half.lib^^${LIBDIR}/ilmbase/lib/IlmThread-2_2.lib^^${LIBDIR}/ilmbase/lib/Iex-2_2.lib") +set(OSL_LLVM_LIBRARY "${LIBDIR}/llvm/lib/LLVMAnalysis${LIBEXT};${LIBDIR}/llvm/lib/LLVMAsmParser${LIBEXT};${LIBDIR}/llvm/lib/LLVMAsmPrinter${LIBEXT};${LIBDIR}/llvm/lib/LLVMBitReader${LIBEXT};${LIBDIR}/llvm/lib/LLVMBitWriter${LIBEXT};${LIBDIR}/llvm/lib/LLVMCodeGen${LIBEXT};${LIBDIR}/llvm/lib/LLVMCore${LIBEXT};${LIBDIR}/llvm/lib/LLVMDebugInfo${LIBEXT};${LIBDIR}/llvm/lib/LLVMExecutionEngine${LIBEXT};${LIBDIR}/llvm/lib/LLVMInstCombine${LIBEXT};${LIBDIR}/llvm/lib/LLVMInstrumentation${LIBEXT};${LIBDIR}/llvm/lib/LLVMInterpreter${LIBEXT};${LIBDIR}/llvm/lib/LLVMJIT${LIBEXT};${LIBDIR}/llvm/lib/LLVMLinker${LIBEXT};${LIBDIR}/llvm/lib/LLVMMC${LIBEXT};${LIBDIR}/llvm/lib/LLVMMCDisassembler${LIBEXT};${LIBDIR}/llvm/lib/LLVMMCJIT${LIBEXT};${LIBDIR}/llvm/lib/LLVMMCParser${LIBEXT};${LIBDIR}/llvm/lib/LLVMObject${LIBEXT};${LIBDIR}/llvm/lib/LLVMRuntimeDyld${LIBEXT};${LIBDIR}/llvm/lib/LLVMScalarOpts${LIBEXT};${LIBDIR}/llvm/lib/LLVMSelectionDAG${LIBEXT};${LIBDIR}/llvm/lib/LLVMSupport${LIBEXT};${LIBDIR}/llvm/lib/LLVMTableGen${LIBEXT};${LIBDIR}/llvm/lib/LLVMTarget${LIBEXT};${LIBDIR}/llvm/lib/LLVMTransformUtils${LIBEXT};${LIBDIR}/llvm/lib/LLVMVectorize${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86AsmParser${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86AsmPrinter${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86CodeGen${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86Desc${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86Disassembler${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86Info${LIBEXT};${LIBDIR}/llvm/lib/LLVMX86Utils${LIBEXT};${LIBDIR}/llvm/lib/LLVMipa${LIBEXT};${LIBDIR}/llvm/lib/LLVMipo${LIBEXT}") + +set(OSL_EXTRA_ARGS + -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING} + -DBoost_USE_MULTITHREADED=ON + -DBoost_USE_STATIC_LIBS=ON + -DBoost_USE_STATIC_RUNTIME=ON + -DBOOST_ROOT=${LIBDIR}/boost + -DBOOST_LIBRARYDIR=${LIBDIR}/boost/lib/ + -DBoost_NO_SYSTEM_PATHS=ON + -DLLVM_DIRECTORY=${LIBDIR}/llvm + -DLLVM_INCLUDES=${LIBDIR}/llvm/include + -DLLVM_LIB_DIR=${LIBDIR}/llvm/lib + -DLLVM_VERSION=3.4 + -DLLVM_LIBRARY=${OSL_LLVM_LIBRARY} + -DOPENEXR_HOME=${LIBDIR}/openexr/ + -DILMBASE_HOME=${LIBDIR}/ilmbase/ + -DILMBASE_INCLUDE_DIR=${LIBDIR}/ilmbase/include/ + -DOPENEXR_IMATH_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Imath-2_2${LIBEXT} + -DOPENEXR_ILMTHREAD_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}IlmThread-2_2${LIBEXT} + -DOPENEXR_IEX_LIBRARY=${LIBDIR}/ilmbase/lib/${LIBPREFIX}Iex-2_2${LIBEXT} + -DOPENEXR_INCLUDE_DIR=${LIBDIR}/openexr/include/ + -DOPENEXR_ILMIMF_LIBRARY=${LIBDIR}/openexr/lib/${LIBPREFIX}IlmImf-2_2${LIBEXT} + -DOSL_BUILD_TESTS=OFF + -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} + -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/ + -DOPENIMAGEIOHOME=${LIBDIR}/openimageio/ + -DOPENIMAGEIO_LIBRARY=${OSL_OPENIMAGEIO_LIBRARY} + -DOPENIMAGEIO_INCLUDES=${LIBDIR}/openimageio/include + ${OSL_FLEX_BISON} + -DCMAKE_CXX_STANDARD_LIBRARIES=${OSL_CMAKE_CXX_STANDARD_LIBRARIES} + -DBUILDSTATIC=ON + -DLINKSTATIC=ON + -DOSL_BUILD_PLUGINS=Off + -DSTOP_ON_WARNING=OFF + -DOSL_BUILD_CPP11=ON + -DUSE_LLVM_BITCODE=OFF + ${OSL_SIMD_FLAGS} +) + +ExternalProject_Add(external_osl + URL ${OSL_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + LIST_SEPARATOR ^^ + URL_HASH MD5=${OSL_HASH} + PREFIX ${BUILD_DIR}/osl + PATCH_COMMAND ${PATCH_CMD} -p 3 -d ${BUILD_DIR}/osl/src/external_osl < ${PATCH_DIR}/osl.diff && + ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/osl/src/external_osl < ${PATCH_DIR}/osl_simd_oiio.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/osl -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${DEFAULT_CMAKE_FLAGS} ${OSL_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/osl +) + +add_dependencies(external_osl external_boost ll external_clang external_ilmbase external_openexr external_zlib external_flexbison external_openimageio) diff --git a/build_files/build_environment/cmake/png.cmake b/build_files/build_environment/cmake/png.cmake new file mode 100644 index 00000000000..8d6fee871f9 --- /dev/null +++ b/build_files/build_environment/cmake/png.cmake @@ -0,0 +1,41 @@ +# ***** 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(PNG_EXTRA_ARGS + -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} + -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/ + -DPNG_STATIC=ON +) + +ExternalProject_Add(external_png + URL ${PNG_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${PNG_HASH} + PREFIX ${BUILD_DIR}/png + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/png ${DEFAULT_CMAKE_FLAGS} ${PNG_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/png +) + +add_dependencies(external_png external_zlib) + +if(BUILD_MODE STREQUAL Debug) + ExternalProject_Add_Step(external_png after_install + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_staticd${LIBEXT} ${LIBDIR}/png/lib/libpng16${LIBEXT} + DEPENDEES install + ) +endif() diff --git a/build_files/build_environment/cmake/pthreads.cmake b/build_files/build_environment/cmake/pthreads.cmake new file mode 100644 index 00000000000..f4301b95f3a --- /dev/null +++ b/build_files/build_environment/cmake/pthreads.cmake @@ -0,0 +1,45 @@ +# ***** 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 ***** + +if(WIN32) + set(PTHREAD_XCFLAGS /MD) + + if(MSVC14) # vs2015 has timespec + set(PTHREAD_CPPFLAGS "/I. /DHAVE_PTW32_CONFIG_H /D_TIMESPEC_DEFINED ") + else() # everything before doesn't + set(PTHREAD_CPPFLAGS "/I. /DHAVE_PTW32_CONFIG_H ") + endif() + + set(PTHREADS_BUILD cd ${BUILD_DIR}/pthreads/src/external_pthreads/ && cd && nmake VC /e CPPFLAGS=${PTHREAD_CPPFLAGS} /e XCFLAGS=${PTHREAD_XCFLAGS} /e XLIBS=/NODEFAULTLIB:msvcr) + + ExternalProject_Add(external_pthreads + URL ${PTHREADS_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA512=${PTHREADS_SHA512} + PREFIX ${BUILD_DIR}/pthreads + CONFIGURE_COMMAND echo . + PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/pthreads/src/external_pthreads < ${PATCH_DIR}/pthreads.diff + BUILD_COMMAND ${PTHREADS_BUILD} + INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthreadVC2.dll ${LIBDIR}/pthreads/lib/pthreadVC2.dll && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthreadVC2${LIBEXT} ${LIBDIR}/pthreads/lib/pthreadVC2${LIBEXT} && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthread.h ${LIBDIR}/pthreads/inc/pthread.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/sched.h ${LIBDIR}/pthreads/inc/sched.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/semaphore.h ${LIBDIR}/pthreads/inc/semaphore.h + INSTALL_DIR ${LIBDIR}/pthreads + ) +endif() diff --git a/build_files/build_environment/cmake/python.cmake b/build_files/build_environment/cmake/python.cmake new file mode 100644 index 00000000000..a24bbbb6aea --- /dev/null +++ b/build_files/build_environment/cmake/python.cmake @@ -0,0 +1,144 @@ +# ***** 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(PYTHON_POSTFIX) +if(BUILD_MODE STREQUAL Debug) + set(PYTHON_POSTFIX _d) +endif() + +if(WIN32) + set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe) + + macro(cmake_to_dos_path MsysPath ResultingPath) + string(REPLACE "/" "\\" ${ResultingPath} "${MsysPath}") + endmacro() + + set(PYTHON_EXTERNALS_FOLDER ${BUILD_DIR}/python/src/external_python/externals) + set(DOWNLOADS_EXTERNALS_FOLDER ${DOWNLOAD_DIR}/externals) + + cmake_to_dos_path(${PYTHON_EXTERNALS_FOLDER} PYTHON_EXTERNALS_FOLDER_DOS) + cmake_to_dos_path(${DOWNLOADS_EXTERNALS_FOLDER} DOWNLOADS_EXTERNALS_FOLDER_DOS) + + message("Python externals = ${PYTHON_EXTERNALS_FOLDER}") + message("Python externals_dos = ${PYTHON_EXTERNALS_FOLDER_DOS}") + message("Python DOWNLOADS_EXTERNALS_FOLDER = ${DOWNLOADS_EXTERNALS_FOLDER}") + message("Python DOWNLOADS_EXTERNALS_FOLDER_DOS = ${DOWNLOADS_EXTERNALS_FOLDER_DOS}") + + ExternalProject_Add(external_python + URL ${PYTHON_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${PYTHON_HASH} + PREFIX ${BUILD_DIR}/python + PATCH_COMMAND echo mklink /D "${PYTHON_EXTERNALS_FOLDER_DOS}" "${DOWNLOADS_EXTERNALS_FOLDER_DOS}" && + mklink /D "${PYTHON_EXTERNALS_FOLDER_DOS}" "${DOWNLOADS_EXTERNALS_FOLDER_DOS}" && + ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python.diff && + ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python/pc < ${PATCH_DIR}/pyshell.diff + CONFIGURE_COMMAND "" + BUILD_COMMAND cd ${BUILD_DIR}/python/src/external_python/pcbuild/ && set IncludeTkinter=false && call build.bat -e -p ${PYTHON_ARCH} -c ${BUILD_MODE} -k ${PYTHON_COMPILER_STRING} + INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.dll ${LIBDIR}/python/lib/python35${PYTHON_POSTFIX}.dll && + ${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.lib ${LIBDIR}/python/lib/python35${PYTHON_POSTFIX}.lib && + ${CMAKE_COMMAND} -E copy ${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.exp ${LIBDIR}/python/lib/python35${PYTHON_POSTFIX}.exp && + ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/include ${LIBDIR}/python/include/Python3.5 && + ${CMAKE_COMMAND} -E copy "${BUILD_DIR}/python/src/external_python/PC/pyconfig.h" ${LIBDIR}/python/include/Python3.5/pyconfig.h + ) + Message("PythinRedist = ${BUILD_DIR}/python/src/external_python/redist") + Message("POutput = ${PYTHON_OUTPUTDIR}") +else() + if(APPLE) + # we need to manually add homebrew headers to get ssl module building + set(PYTHON_CFLAGS "-I/usr/local/opt/openssl/include -I${OSX_SYSROOT}/usr/include ${PLATFORM_CFLAGS}") + set(PYTHON_LDFLAGS "-L/usr/local/opt/openssl/lib ${PLATFORM_LDFLAGS}") + set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV} && export CFLAGS=${PYTHON_CFLAGS} && export LDFLAGS=${PYTHON_LDFLAGS}) + set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python.exe) + set(PYTHON_PATCH ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_apple.diff) + else() + set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV}) + set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python) + endif() + + ExternalProject_Add(external_python + URL ${PYTHON_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${PYTHON_HASH} + PREFIX ${BUILD_DIR}/python + PATCH_COMMAND ${PYTHON_PATCH} + CONFIGURE_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/python + BUILD_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && make install + INSTALL_DIR ${LIBDIR}/python) + + add_custom_command( + OUTPUT ${LIBDIR}/python/release/python_x86_64.zip + WORKING_DIRECTORY ${LIBDIR}/python + COMMAND mkdir -p release + COMMAND zip -r release/python_x86_64.zip lib/python${PYTHON_SHORT_VERSION} lib/pkgconfig --exclude *__pycache__*) + add_custom_target(Package_Python ALL DEPENDS external_python ${LIBDIR}/python/release/python_x86_64.zip) + add_custom_target(Make_Python_Environment ALL DEPENDS Package_Python) +endif() + +if(MSVC) + add_custom_command( + OUTPUT ${LIBDIR}/python35${PYTHON_POSTFIX}.tar.gz + OUTPUT ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe + COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/lib ${BUILD_DIR}/python/src/external_python/redist/lib + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_POSTFIX}.exe" ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_bz2${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_bz2${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_hashlib${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_hashlib${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_lzma${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_lzma${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_sqlite3${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_sqlite3${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_ssl${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_ssl${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/pyexpat${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/pyexpat${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/select${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/select${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/unicodedata${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/unicodedata${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/winsound${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/winsound${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_ctypes${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_ctypes${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_ctypes_test${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_ctypes_test${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_decimal${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_decimal${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_elementtree${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_elementtree${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_msi${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_msi${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_multiprocessing${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_multiprocessing${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_overlapped${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_overlapped${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_socket${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_socket${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testbuffer${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testbuffer${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testcapi${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testcapi${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testimportmultiple${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testimportmultiple${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/_testmultiphase${PYTHON_POSTFIX}.pyd" ${BUILD_DIR}/python/src/external_python/redist/lib/_testmultiphase${PYTHON_POSTFIX}.pyd + COMMAND ${CMAKE_COMMAND} -E chdir "${BUILD_DIR}/python/src/external_python/redist" ${CMAKE_COMMAND} -E tar "cfvz" "${LIBDIR}/python35${PYTHON_POSTFIX}.tar.gz" "." + ) + + add_custom_target(Package_Python ALL DEPENDS external_python ${LIBDIR}/python35${PYTHON_POSTFIX}.tar.gz ${BUILD_DIR}/python/src/external_python/redist/bin/python${PYTHON_POSTFIX}.exe) + + if(MSVC12) + set(PYTHON_DISTUTIL_PATCH ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/python/src/external_python/run/lib/distutils < ${PATCH_DIR}/python_runtime_vc2013.diff) + else() + set(PYTHON_DISTUTIL_PATCH echo "No patch needed") + endif() + + add_custom_command(OUTPUT ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe + COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/redist ${BUILD_DIR}/python/src/external_python/run + COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/python/src/external_python/include ${BUILD_DIR}/python/src/external_python/run/include + COMMAND ${CMAKE_COMMAND} -E copy "${BUILD_DIR}/python/src/external_python/PC/pyconfig.h" ${BUILD_DIR}/python/src/external_python/run/include/pyconfig.h + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.dll" ${BUILD_DIR}/python/src/external_python/run/python35${PYTHON_POSTFIX}.dll + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.lib" ${BUILD_DIR}/python/src/external_python/run/libs/python35.lib #missing postfix on purpose, distutils is not expecting it + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python35${PYTHON_POSTFIX}.lib" ${BUILD_DIR}/python/src/external_python/run/libs/python35${PYTHON_POSTFIX}.lib #other things like numpy still want it though. + COMMAND ${CMAKE_COMMAND} -E copy "${PYTHON_OUTPUTDIR}/python${PYTHON_POSTFIX}.exe" ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe + COMMAND ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe -m ensurepip --upgrade + COMMAND ${PYTHON_DISTUTIL_PATCH} + ) + add_custom_target(Make_Python_Environment ALL DEPENDS ${BUILD_DIR}/python/src/external_python/run/python${PYTHON_POSTFIX}.exe Package_Python) +endif(MSVC) diff --git a/build_files/build_environment/cmake/requests.cmake b/build_files/build_environment/cmake/requests.cmake new file mode 100644 index 00000000000..399bfe4009f --- /dev/null +++ b/build_files/build_environment/cmake/requests.cmake @@ -0,0 +1,29 @@ +# ***** 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 ***** + +if(BUILD_MODE STREQUAL Release) + ExternalProject_Add(external_requests + URL ${REQUESTS_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${REQUESTS_HASH} + PREFIX ${BUILD_DIR}/requests + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/requests/src/external_requests/requests ${LIBDIR}/requests + ) +endif(BUILD_MODE STREQUAL Release) diff --git a/build_files/build_environment/cmake/schroedinger.cmake b/build_files/build_environment/cmake/schroedinger.cmake new file mode 100644 index 00000000000..54a20db5b5e --- /dev/null +++ b/build_files/build_environment/cmake/schroedinger.cmake @@ -0,0 +1,45 @@ +# ***** 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 ***** + +if(WIN32) + set(SCHROEDINGER_EXTRA_FLAGS "CFLAGS=-g -I./ -I${LIBDIR}/orc/include/orc-0.4" "LDFLAGS=-Wl,--as-needed -static-libgcc -L${LIBDIR}/orc/lib" ORC_CFLAGS=-I${LIBDIR}/orc/include/orc-0.4 ORC_LDFLAGS=-L${LIBDIR}/orc/lib ORC_LIBS=${LIBDIR}/orc/lib/liborc-0.4.a ORCC=${LIBDIR}/orc/bin/orcc.exe) +else() + set(SCHROEDINGER_CFLAGS "${PLATFORM_CFLAGS} -I./ -I${LIBDIR}/orc/include/orc-0.4") + set(SCHROEDINGER_LDFLAGS "${PLATFORM_LDFLAGS} -L${LIBDIR}/orc/lib") + set(SCHROEDINGER_EXTRA_FLAGS CFLAGS=${SCHROEDINGER_CFLAGS} LDFLAGS=${SCHROEDINGER_LDFLAGS} ORC_CFLAGS=-I${LIBDIR}/orc/include/orc-0.4 ORC_LDFLAGS=-L${LIBDIR}/orc/lib ORCC=${LIBDIR}/orc/bin/orcc) # ORC_LIBS=${LIBDIR}/orc/lib/liborc-0.4.a +endif() + +ExternalProject_Add(external_schroedinger + URL ${SCHROEDINGER_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${SCHROEDINGER_HASH} + PREFIX ${BUILD_DIR}/schroedinger + PATCH_COMMAND ${PATCH_CMD} --verbose -p 0 -N -d ${BUILD_DIR}/schroedinger/src/external_schroedinger < ${PATCH_DIR}/schroedinger.diff + CONFIGURE_COMMAND ${CONFIGURE_ENV} && + cd ${BUILD_DIR}/schroedinger/src/external_schroedinger/ && + ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/schroedinger --disable-shared --enable-static ${SCHROEDINGER_EXTRA_FLAGS} + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/schroedinger/src/external_schroedinger/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/schroedinger/src/external_schroedinger/ && make install + INSTALL_DIR ${LIBDIR}/schroedinger +) + +add_dependencies(external_schroedinger external_orc) + +if(MSVC) + set_target_properties(external_schroedinger PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/sdl.cmake b/build_files/build_environment/cmake/sdl.cmake new file mode 100644 index 00000000000..0fbfa078eb1 --- /dev/null +++ b/build_files/build_environment/cmake/sdl.cmake @@ -0,0 +1,39 @@ +# ***** 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 ***** + +if(WIN32) + set(SDL_EXTRA_ARGS + -DSDL_STATIC=Off + ) +else() + set(SDL_EXTRA_ARGS + -DSDL_STATIC=ON + -DSDL_SHARED=OFF + -DSDL_VIDEO=OFF + ) +endif() + +ExternalProject_Add(external_sdl + URL ${SDL_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${SDL_HASH} + PREFIX ${BUILD_DIR}/sdl + PATCH_COMMAND ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/sdl/src/external_sdl < ${PATCH_DIR}/sdl.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/sdl ${DEFAULT_CMAKE_FLAGS} ${SDL_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/sdl +) diff --git a/build_files/build_environment/cmake/setup_mingw32.cmake b/build_files/build_environment/cmake/setup_mingw32.cmake new file mode 100644 index 00000000000..f0d99356da0 --- /dev/null +++ b/build_files/build_environment/cmake/setup_mingw32.cmake @@ -0,0 +1,219 @@ +# ***** 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 ***** + +#################################################################################################################### +# Mingw32 Builds +#################################################################################################################### +# This installs mingw32+msys to compile ffmpeg/iconv/libsndfile/lapack/fftw3 +#################################################################################################################### + +message("LIBDIR = ${LIBDIR}") +macro(cmake_to_msys_path MsysPath ResultingPath) + string(REPLACE ":" "" TmpPath "${MsysPath}") + string(SUBSTRING ${TmpPath} 0 1 Drive) + string(SUBSTRING ${TmpPath} 1 255 PathPart) + string(TOLOWER ${Drive} LowerDrive) + string(CONCAT ${ResultingPath} "/" ${LowerDrive} ${PathPart}) +endmacro() +cmake_to_msys_path(${LIBDIR} mingw_LIBDIR) +message("mingw_LIBDIR = ${mingw_LIBDIR}") + +message("Checking for mingw32") +# download mingw32 +if(NOT EXISTS "${DOWNLOAD_DIR}/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z") + message("Downloading mingw32") + file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.8-release/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z" "${DOWNLOAD_DIR}/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z") +endif() + +# make mingw root directory +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw") + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/mingw + WORKING_DIRECTORY ${DOWNLOAD_DIR} + ) +endif() + +# extract mingw32 +if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/mingw32env.cmd") AND (EXISTS "${DOWNLOAD_DIR}/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z")) + message("Extracting mingw32") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/i686-w64-mingw32-gcc-4.8.0-win32_rubenvb.7z + WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw + ) +endif() + +message("Checking for pkg-config") +if(NOT EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip") + message("Downloading pkg-config") + file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/pkgconfiglite/0.28-1/pkg-config-lite-0.28-1_bin-win32.zip" "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip") +endif() + +# extract pkgconfig +if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/pkg-config.exe") AND (EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")) + message("Extracting pkg-config") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip" + WORKING_DIRECTORY ${DOWNLOAD_DIR}/ + ) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1/bin/pkg-config.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/pkg-config.exe" + ) + +endif() + +message("Checking for nasm") +if(NOT EXISTS "${DOWNLOAD_DIR}/nasm-2.12.01-win32.zip") + message("Downloading nasm") + file(DOWNLOAD "http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win32/nasm-2.12.01-win32.zip" "${DOWNLOAD_DIR}/nasm-2.12.01-win32.zip") +endif() + +# extract nasm +if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe") AND (EXISTS "${DOWNLOAD_DIR}/nasm-2.12.01-win32.zip")) + message("Extracting nasm") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/nasm-2.12.01-win32.zip" + WORKING_DIRECTORY ${DOWNLOAD_DIR}/ + ) + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/nasm-2.12.01/nasm.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe" + ) + +endif() + +message("Checking for mingwGet") +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip") + message("Downloading mingw-get") + file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip") +endif() + +# extract mingw_get +if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")) + message("Extracting mingw-get") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" + WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/ + ) +endif() + +if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/make.exe")) + message("Installing MSYS") + execute_process( + COMMAND ${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get install msys msys-patch + WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/bin/ + ) +endif() + +message("Checking for CoreUtils") +# download old core_utils for pr.exe (ffmpeg needs it to build) +if(NOT EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") + message("Downloading CoreUtils 5.97") + file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/MSYS/Base/msys-core/_obsolete/coreutils-5.97-MSYS-1.0.11-2/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2" "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") +endif() + +if((EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/pr.exe")) + message("Installing pr from CoreUtils 5.97") + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/tmp_coreutils + WORKING_DIRECTORY ${DOWNLOAD_DIR} + ) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2 + WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/ + ) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy ${DOWNLOAD_DIR}/tmp_coreutils/coreutils-5.97/bin/pr.exe "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/pr.exe" + WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/ + ) +endif() + +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd") + message("Installing ming32sh.cmd") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/ming32sh.cmd ${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd + ) +endif() + +message("Checking for perl") +# download perl for libvpx +if(NOT EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip") + message("Downloading perl") + file(DOWNLOAD "http://strawberryperl.com/download/5.22.1.3/strawberry-perl-5.22.1.3-32bit-portable.zip" "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip") +endif() + +# make perl root directory +if(NOT EXISTS "${DOWNLOAD_DIR}/perl32") + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/perl32 + WORKING_DIRECTORY ${DOWNLOAD_DIR} + ) +endif() + +# extract perl +if((NOT EXISTS "${DOWNLOAD_DIR}/perl32/portable.perl") AND (EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip")) + message("Extracting perl") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip + WORKING_DIRECTORY ${DOWNLOAD_DIR}/perl32 + ) +endif() + +# get yasm for vpx +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/yasm.exe") + message("Downloading yasm") + file(DOWNLOAD "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win32.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/yasm.exe") +endif() + +message("checking i686-w64-mingw32-strings") +# copy strings.exe to i686-w64-mingw32-strings for x264 +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strings.exe") + message("fixing i686-w64-mingw32-strings.exe") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/strings.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strings.exe" + ) +endif() + +message("checking i686-w64-mingw32-ar.exe") +# copy ar.exe to i686-w64-mingw32-ar.exe for x264 +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ar.exe") + message("fixing i686-w64-mingw32-ar.exe") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/ar.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ar.exe" + ) +endif() + +message("checking i686-w64-mingw32-strip.exe") +# copy strip.exe to i686-w64-mingw32-strip.exe for x264 +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strip.exe") + message("fixing i686-w64-mingw32-strip.exe") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/strip.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strip.exe" + ) +endif() + +message("checking i686-w64-mingw32-ranlib.exe") +# copy ranlib.exe to i686-w64-mingw32-ranlib.exe for x264 +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe") + message("fixing i686-w64-mingw32-ranlib.exe") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/ranlib.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe" + ) +endif() + diff --git a/build_files/build_environment/cmake/setup_mingw64.cmake b/build_files/build_environment/cmake/setup_mingw64.cmake new file mode 100644 index 00000000000..14f75d410b4 --- /dev/null +++ b/build_files/build_environment/cmake/setup_mingw64.cmake @@ -0,0 +1,219 @@ +# ***** 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 ***** + +#################################################################################################################### +# Mingw64 Builds +#################################################################################################################### +# This installs mingw64+msys to compile ffmpeg/iconv/libsndfile/lapack/fftw3 +#################################################################################################################### + +message("LIBDIR = ${LIBDIR}") +macro(cmake_to_msys_path MsysPath ResultingPath) + string(REPLACE ":" "" TmpPath "${MsysPath}") + string(SUBSTRING ${TmpPath} 0 1 Drive) + string(SUBSTRING ${TmpPath} 1 255 PathPart) + string(TOLOWER ${Drive} LowerDrive) + string(CONCAT ${ResultingPath} "/" ${LowerDrive} ${PathPart}) +endmacro() +cmake_to_msys_path(${LIBDIR} mingw_LIBDIR) +message("mingw_LIBDIR = ${mingw_LIBDIR}") + +message("Checking for mingw64") +# download ming64 +if(NOT EXISTS "${DOWNLOAD_DIR}/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z") + message("Downloading mingw64") + file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/gcc-4.8-release/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z" "${DOWNLOAD_DIR}/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z") +endif() + +# make mingw root directory +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw") + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/mingw + WORKING_DIRECTORY ${DOWNLOAD_DIR} + ) +endif() + +# extract mingw64 +if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/mingw64env.cmd") AND (EXISTS "${DOWNLOAD_DIR}/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z")) + message("Extracting mingw64") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z + WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw + ) +endif() + +message("Checking for pkg-config") +if(NOT EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip") + message("Downloading pkg-config") + file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/pkgconfiglite/0.28-1/pkg-config-lite-0.28-1_bin-win32.zip" "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip") +endif() + +# extract pkgconfig +if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/pkg-config.exe") AND (EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")) + message("Extracting pkg-config") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip" + WORKING_DIRECTORY ${DOWNLOAD_DIR}/ + ) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1/bin/pkg-config.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/pkg-config.exe" + ) + +endif() + +message("Checking for nasm") +if(NOT EXISTS "${DOWNLOAD_DIR}/nasm-2.12.01-win64.zip") + message("Downloading nasm") + file(DOWNLOAD "http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip" "${DOWNLOAD_DIR}/nasm-2.12.01-win64.zip") +endif() + +# extract nasm +if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/nasm.exe") AND (EXISTS "${DOWNLOAD_DIR}/nasm-2.12.01-win64.zip")) + message("Extracting nasm") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/nasm-2.12.01-win64.zip" + WORKING_DIRECTORY ${DOWNLOAD_DIR}/ + ) + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/nasm-2.12.01/nasm.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/nasm.exe" + ) + +endif() + +message("Checking for mingwGet") +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip") + message("Downloading mingw-get") + file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip") +endif() + +# extract mingw_get +if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/mingw-get.exe") AND (EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")) + message("Extracting mingw-get") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" + WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw64/ + ) +endif() + +if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/mingw-get.exe") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/make.exe")) + message("Installing MSYS") + execute_process( + COMMAND ${DOWNLOAD_DIR}/mingw/mingw64/bin/mingw-get install msys msys-patch + WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw64/bin/ + ) +endif() + +message("Checking for CoreUtils") +# download old core_utils for pr.exe (ffmpeg needs it to build) +if(NOT EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") + message("Downloading CoreUtils 5.97") + file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/MSYS/Base/msys-core/_obsolete/coreutils-5.97-MSYS-1.0.11-2/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2" "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") +endif() + +if((EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/pr.exe")) + message("Installing pr from CoreUtils 5.97") + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/tmp_coreutils + WORKING_DIRECTORY ${DOWNLOAD_DIR} + ) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2 + WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/ + ) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy ${DOWNLOAD_DIR}/tmp_coreutils/coreutils-5.97/bin/pr.exe "${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/pr.exe" + WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/ + ) +endif() + +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/ming64sh.cmd") + message("Installing ming64sh.cmd") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/ming64sh.cmd ${DOWNLOAD_DIR}/mingw/mingw64/ming64sh.cmd + ) +endif() + +message("Checking for perl") +# download perl for libvpx +if(NOT EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-64bit-portable.zip") + message("Downloading perl") + file(DOWNLOAD "http://strawberryperl.com/download/5.22.1.3/strawberry-perl-5.22.1.3-64bit-portable.zip" "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-64bit-portable.zip") +endif() + +# make perl root directory +if(NOT EXISTS "${DOWNLOAD_DIR}/perl") + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/perl + WORKING_DIRECTORY ${DOWNLOAD_DIR} + ) +endif() + +# extract perl +if((NOT EXISTS "${DOWNLOAD_DIR}/perl/portable.perl") AND (EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-64bit-portable.zip")) + message("Extracting perl") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-64bit-portable.zip + WORKING_DIRECTORY ${DOWNLOAD_DIR}/perl + ) +endif() + +# get yasm for vpx +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/yasm.exe") + message("Downloading yasm") + file(DOWNLOAD "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/yasm.exe") +endif() + +message("checking x86_64-w64-mingw32-strings.exe") +# copy strings.exe to x86_64-w64-mingw32-strings.exe for x264 +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-strings.exe") + message("fixing x86_64-w64-mingw32-strings.exe") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw64/bin/strings.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-strings.exe" + ) +endif() + +message("checking x86_64-w64-mingw32-ar.exe") +# copy ar.exe to x86_64-w64-mingw32-ar.exe for x264 +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ar.exe") + message("fixing x86_64-w64-mingw32-ar.exe") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw64/bin/ar.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ar.exe" + ) +endif() + +message("checking x86_64-w64-mingw32-strip.exe") +# copy strip.exe to x86_64-w64-mingw32-strip.exe for x264 +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-strip.exe") + message("fixing x86_64-w64-mingw32-strip.exe") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw64/bin/strip.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-strip.exe" + ) +endif() + +message("checking x86_64-w64-mingw32-ranlib.exe") +# copy ranlib.exe to x86_64-w64-mingw32-ranlib.exe for x264 +if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ranlib.exe") + message("fixing x86_64-w64-mingw32-ranlib.exe") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw64/bin/ranlib.exe" "${DOWNLOAD_DIR}/mingw/mingw64/bin/x86_64-w64-mingw32-ranlib.exe" + ) +endif() + diff --git a/build_files/build_environment/cmake/sndfile.cmake b/build_files/build_environment/cmake/sndfile.cmake new file mode 100644 index 00000000000..13368c05fbe --- /dev/null +++ b/build_files/build_environment/cmake/sndfile.cmake @@ -0,0 +1,44 @@ +# ***** 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(SNDFILE_EXTRA_ARGS) +set(SNDFILE_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR}) + +if(WIN32) + set(SNDFILE_ENV set ${SNDFILE_ENV} &&) +endif() + +ExternalProject_Add(external_sndfile + URL ${SNDFILE_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${SNDFILE_HASH} + PREFIX ${BUILD_DIR}/sndfile + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && ${SNDFILE_ENV} ${CONFIGURE_COMMAND} --enable-static --disable-shared --prefix=${mingw_LIBDIR}/sndfile + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make install + INSTALL_DIR ${LIBDIR}/sndfile +) + +if(MSVC) + set_target_properties(external_sndfile PROPERTIES FOLDER Mingw) +endif() + +add_dependencies(external_sndfile external_ogg external_vorbis) +if(UNIX) + add_dependencies(external_sndfile external_flac) +endif() diff --git a/build_files/build_environment/cmake/spnav.cmake b/build_files/build_environment/cmake/spnav.cmake new file mode 100644 index 00000000000..0dec9799715 --- /dev/null +++ b/build_files/build_environment/cmake/spnav.cmake @@ -0,0 +1,28 @@ +# ***** 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 ***** + +ExternalProject_Add(external_spnav + URL ${SPNAV_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${SPNAV_HASH} + PREFIX ${BUILD_DIR}/spnav + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/spnav/src/external_spnav/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/spnav --disable-shared --enable-static --with-pic + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/spnav/src/external_spnav/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/spnav/src/external_spnav/ && make install + INSTALL_DIR ${LIBDIR}/spnav +) diff --git a/build_files/build_environment/cmake/tbb.cmake b/build_files/build_environment/cmake/tbb.cmake new file mode 100644 index 00000000000..c4055d55648 --- /dev/null +++ b/build_files/build_environment/cmake/tbb.cmake @@ -0,0 +1,36 @@ +# ***** 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(TBB_EXTRA_ARGS + -DTBB_BUILD_SHARED=Off + -DTBB_BUILD_TBBMALLOC=Off + -DTBB_BUILD_TBBMALLOC_PROXY=Off + -DTBB_BUILD_STATIC=On +) + +# CMake script for TBB from https://github.com/wjakob/tbb/blob/master/CMakeLists.txt +ExternalProject_Add(external_tbb + URL ${TBB_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${TBB_HASH} + PREFIX ${BUILD_DIR}/tbb + PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_tbb.txt ${BUILD_DIR}/tbb/src/external_tbb/CMakeLists.txt && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/tbb/src/external_tbb/build/vs2010/version_string.ver ${BUILD_DIR}/tbb/src/external_tbb/src/tbb/version_string.ver + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tbb ${DEFAULT_CMAKE_FLAGS} ${TBB_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/tbb +) diff --git a/build_files/build_environment/cmake/theora.cmake b/build_files/build_environment/cmake/theora.cmake new file mode 100644 index 00000000000..03aad42f2db --- /dev/null +++ b/build_files/build_environment/cmake/theora.cmake @@ -0,0 +1,40 @@ +# ***** 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 ***** + +ExternalProject_Add(external_theora + URL ${THEORA_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${THEORA_HASH} + PREFIX ${BUILD_DIR}/theora + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/theora + --disable-shared + --enable-static + --with-pic + --with-ogg=${LIBDIR}/ogg + --with-vorbis=${LIBDIR}/vorbis + --disable-examples + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make install + INSTALL_DIR ${LIBDIR}/theora +) + +add_dependencies(external_theora external_vorbis external_ogg) + +if(MSVC) + set_target_properties(external_theora PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/tiff.cmake b/build_files/build_environment/cmake/tiff.cmake new file mode 100644 index 00000000000..2c01341eb21 --- /dev/null +++ b/build_files/build_environment/cmake/tiff.cmake @@ -0,0 +1,44 @@ +# ***** 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(TIFF_EXTRA_ARGS + -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} + -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include + -DPNG_STATIC=ON + -DBUILD_SHARED_LIBS=OFF + -Dlzma=OFF + -Djbig=OFF +) + +ExternalProject_Add(external_tiff + URL ${TIFF_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${TIFF_HASH} + PREFIX ${BUILD_DIR}/tiff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tiff ${DEFAULT_CMAKE_FLAGS} ${TIFF_EXTRA_ARGS} + INSTALL_DIR ${LIBDIR}/tiff +) + +add_dependencies(external_tiff external_zlib) + +if(BUILD_MODE STREQUAL Debug) + ExternalProject_Add_Step(external_tiff after_install + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiffd${LIBEXT} ${LIBDIR}/tiff/lib/tiff${LIBEXT} + DEPENDEES install + ) +endif() diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake new file mode 100644 index 00000000000..f9f9fdcface --- /dev/null +++ b/build_files/build_environment/cmake/versions.cmake @@ -0,0 +1,245 @@ +# ***** 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(ZLIB_VERSION 1.2.8) +set(ZLIB_URI https://netcologne.dl.sourceforge.net/project/libpng/zlib/${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz) +set(ZLIB_HASH 44d667c142d7cda120332623eab69f40) + +set(OPENAL_VERSION 1.17.2) +set(OPENAL_URI http://kcat.strangesoft.net/openal-releases/openal-soft-${OPENAL_VERSION}.tar.bz2) +set(OPENAL_HASH 1764e0d8fec499589b47ebc724e0913d) + +set(PNG_VERSION 1.6.21) +set(PNG_URI http://prdownloads.sourceforge.net/libpng/libpng-${PNG_VERSION}.tar.gz) +set(PNG_HASH aca36ec8e0a3b406a5912243bc243717) + +set(JPEG_VERSION 1.4.2) +set(JPEG_URI https://github.com/libjpeg-turbo/libjpeg-turbo/archive/${JPEG_VERSION}.tar.gz) +set(JPEG_HASH f9804884c1c41eb7f4febb9353a2cb27) + +set(BOOST_VERSION 1.60.0) +set(BOOST_VERSION_NODOTS 1_60_0) +set(BOOST_URI http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION_NODOTS}.tar.bz2/download) +set(BOOST_MD5 65a840e1a0b13a558ff19eeb2c4f0cbe) + +set(BLOSC_VERSION 1.7.1) +set(BLOSC_URI https://github.com/Blosc/c-blosc/archive/v${BLOSC_VERSION}.zip) +set(BLOSC_HASH ff5cc729a5a25934ef714217218eed26) + +set(PTHREADS_VERSION 2-9-1) +set(PTHREADS_URI ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-${PTHREADS_VERSION}-release.tar.gz) +set(PTHREADS_SHA512 9c06e85310766834370c3dceb83faafd397da18a32411ca7645c8eb6b9495fea54ca2872f4a3e8d83cb5fdc5dea7f3f0464be5bb9af3222a6534574a184bd551) + +set(ILMBASE_VERSION 2.2.0) +set(ILMBASE_URI http://download.savannah.nongnu.org/releases/openexr/ilmbase-${ILMBASE_VERSION}.tar.gz) +set(ILMBASE_HASH b540db502c5fa42078249f43d18a4652) + +set(OPENEXR_VERSION 2.2.0) +set(OPENEXR_URI http://download.savannah.nongnu.org/releases/openexr/openexr-2.2.0.tar.gz) +set(OPENEXR_HASH b64e931c82aa3790329c21418373db4e) + +set(FREETYPE_VERSION 263) +set(FREETYPE_URI http://download.savannah.gnu.org/releases/freetype/ft${FREETYPE_VERSION}.zip) +set(FREETYPE_HASH 0db2a43301572e5c2b4a0864f237aeeb) + +set(GLEW_VERSION 1.13.0) +set(GLEW_URI http://prdownloads.sourceforge.net/glew/glew/${GLEW_VERSION}/glew-${GLEW_VERSION}.tgz) +set(GLEW_HASH 7cbada3166d2aadfc4169c4283701066) + +set(FREEGLUT_VERSION 3.0.0) +set(FREEGLUT_URI http://pilotfiber.dl.sourceforge.net/project/freeglut/freeglut/${FREEGLUT_VERSION}/freeglut-${FREEGLUT_VERSION}.tar.gz) +set(FREEGLUT_HASH 90c3ca4dd9d51cf32276bc5344ec9754) + +set(HDF5_VERSION 1.8.17) +set(HDF5_URI https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-${HDF5_VERSION}/src/hdf5-${HDF5_VERSION}.tar.gz) +set(HDF5_HASH 7d572f8f3b798a628b8245af0391a0ca) + +set(ALEMBIC_VERSION 1.7.1) +set(ALEMBIC_URI https://github.com/alembic/alembic/archive/${ALEMBIC_VERSION}.zip) +set(ALEMBIC_MD5 cf7705055501d5ea0cb8256866496f79) + +## hash is for 3.1.2 +set(GLFW_GIT_UID 30306e54705c3adae9fe082c816a3be71963485c) +set(GLFW_URI https://github.com/glfw/glfw/archive/${GLFW_GIT_UID}.zip) +set(GLFW_HASH 20cacb1613da7eeb092f3ac4f6b2b3d0) + +#latest uid in git as of 2016-04-01 +set(CLEW_GIT_UID 277db43f6cafe8b27c6f1055f69dc67da4aeb299) +set(CLEW_URI https://github.com/OpenCLWrangler/clew/archive/${CLEW_GIT_UID}.zip) +set(CLEW_HASH 2c699d10ed78362e71f56fae2a4c5f98) + +#latest uid in git as of 2016-04-01 +set(CUEW_GIT_UID 1744972026de9cf27c8a7dc39cf39cd83d5f922f) +set(CUEW_URI https://github.com/CudaWrangler/cuew/archive/${CUEW_GIT_UID}.zip) +set(CUEW_HASH 86760d62978ebfd96cd93f5aa1abaf4a) + +set(OPENSUBDIV_VERSION v3_1_1) +set(OPENSUBDIV_Hash 25a9a6a94136b0eb85ce69e9c8cb6ab3) +set(OPENSUBDIV_URI https://github.com/PixarAnimationStudios/OpenSubdiv/archive/${OPENSUBDIV_VERSION}.zip) + +set(SDL_VERSION 2.0.4) +set(SDL_URI https://www.libsdl.org/release/SDL2-${SDL_VERSION}.tar.gz) +set(SDL_HASH 44fc4a023349933e7f5d7a582f7b886e) + +set(OPENCOLLADA_VERSION v1.6.51) +set(OPENCOLLADA_URI https://github.com/KhronosGroup/OpenCOLLADA/archive/${OPENCOLLADA_VERSION}.tar.gz) +set(OPENCOLLADA_HASH 23db5087faed4bc4cc1dfe456c0d4701) + +set(OPENCOLORIO_URI https://github.com/imageworks/OpenColorIO/archive/6de971097c7f552300f669ed69ca0b6cf5a70843.zip) +set(OPENCOLORIO_HASH c9de0fd98f26ce6f2e08d617ca68b8e4) + +set(LLVM_VERSION 3.4.2) +set(LLVM_URI http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.gz) +set(LLVM_HASH a20669f75967440de949ac3b1bad439c) + +set(CLANG_URI http://llvm.org/releases/${LLVM_VERSION}/cfe-${LLVM_VERSION}.src.tar.gz) +set(CLANG_HASH 87945973b7c73038871c5f849a818588) + +set(OPENIMAGEIO_VERSION 1.7.15) +set(OPENIMAGEIO_URI https://github.com/OpenImageIO/oiio/archive/Release-${OPENIMAGEIO_VERSION}.zip) +set(OPENIMAGEIO_HASH_178 e156e3669af0e1373142ab5e8f13de66) +set(OPENIMAGEIO_HASH_179 4121cb0e0433bda6a7ef32c8628a149f) +set(OPENIMAGEIO_HASH_1713 42a662775b834161ba88c6abdb299360) +set(OPENIMAGEIO_HASH_1715 e2ece0f62c013d64c478f82265988b0b) +set(OPENIMAGEIO_HASH ${OPENIMAGEIO_HASH_1715}) + + +set(TIFF_VERSION 4.0.6) +set(TIFF_URI http://download.osgeo.org/libtiff/tiff-${TIFF_VERSION}.tar.gz) +set(TIFF_HASH d1d2e940dea0b5ad435f21f03d96dd72) + +set(FLEXBISON_VERSION 2.5.5) +set(FLEXBISON_URI http://prdownloads.sourceforge.net/winflexbison//win_flex_bison-2.5.5.zip) +set(FLEXBISON_HASH d87a3938194520d904013abef3df10ce) + +set(OSL_VERSION 1.7.5) +set(OSL_URI https://github.com/imageworks/OpenShadingLanguage/archive/Release-${OSL_VERSION}.zip) +set(OSL_HASH 6924dd5d453159e7b6eb106a08c358cf) + +set(PYTHON_VERSION 3.5.3) +set(PYTHON_SHORT_VERSION 3.5) +set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz) +set(PYTHON_HASH 57d1f8bfbabf4f2500273fb0706e6f21) + +set(TBB_VERSION 44_20160128) +set(TBB_URI https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb${TBB_VERSION}oss_src_0.tgz) +set(TBB_HASH 9d8a4cdf43496f1b3f7c473a5248e5cc) + +set(OPENVDB_VERSION 3.1.0) +set(OPENVDB_URI https://github.com/dreamworksanimation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz) +set(OPENVDB_HASH 30a7e9571a03ab7bcf1a39fb62aa436f) + +set(REQUESTS_VERSION v2.10.0) +set(REQUESTS_URI https://github.com/kennethreitz/requests/archive/${REQUESTS_VERSION}.zip) +set(REQUESTS_HASH 6ebefdf0210c7f0933f61501334e46c3) + +set(NUMPY_VERSION v1.10.1) +set(NUMPY_SHORT_VERSION 1.10) +set(NUMPY_URI https://pypi.python.org/packages/a5/2e/5412784108f5dc0f827fb460ccdeaa9d76286979fe5ddd070d526d168a59/numpy-1.10.1.zip) +set(NUMPY_HASH 6f57c58bc5b28440fbeccd505da63d58) + +set(LAME_VERSION 3.99.5) +set(LAME_URI http://downloads.sourceforge.net/project/lame/lame/3.99/lame-${LAME_VERSION}.tar.gz) +set(LAME_HASH 84835b313d4a8b68f5349816d33e07ce) + +set(OGG_VERSION 1.3.2) +set(OGG_URI http://downloads.xiph.org/releases/ogg/libogg-${OGG_VERSION}.tar.gz) +set(OGG_HASH e19ee34711d7af328cb26287f4137e70630e7261b17cbe3cd41011d73a654692) + +set(VORBIS_VERSION 1.3.5) +set(VORBIS_URI http://downloads.xiph.org/releases/vorbis/libvorbis-${VORBIS_VERSION}.tar.gz) +set(VORBIS_HASH 6efbcecdd3e5dfbf090341b485da9d176eb250d893e3eb378c428a2db38301ce) + +set(THEORA_VERSION 1.1.1) +set(THEORA_URI http://downloads.xiph.org/releases/theora/libtheora-${THEORA_VERSION}.tar.bz2) +set(THEORA_HASH b6ae1ee2fa3d42ac489287d3ec34c5885730b1296f0801ae577a35193d3affbc) + +set(FLAC_VERSION 1.3.1) +set(FLAC_URI http://downloads.xiph.org/releases/flac/flac-${FLAC_VERSION}.tar.xz) +set(FLAC_HASH 4773c0099dba767d963fd92143263be338c48702172e8754b9bc5103efe1c56c) + +set(VPX_VERSION 1.5.0) +set(VPX_URI http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-${VPX_VERSION}.tar.bz2) +set(VPX_HASH 306d67908625675f8e188d37a81fbfafdf5068b09d9aa52702b6fbe601c76797) + +set(ORC_VERSION 0.4.25) +set(ORC_URI https://gstreamer.freedesktop.org/src/orc/orc-${ORC_VERSION}.tar.xz) +set(ORC_HASH c1b1d54a58f26d483f0b3881538984789fe5d5460ab8fab74a1cacbd3d1c53d1) + +set(SCHROEDINGER_VERSION 1.0.11) +set(SCHROEDINGER_URI https://download.videolan.org/contrib/schroedinger/schroedinger-${SCHROEDINGER_VERSION}.tar.gz) +set(SCHROEDINGER_HASH 1e572a0735b92aca5746c4528f9bebd35aa0ccf8619b22fa2756137a8cc9f912) + +set(X264_URI http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20160401-2245-stable.tar.bz2) +set(X264_HASH 1e9a7b835e80313aade53a9b6ff353e099de3856bf5f30a4d8dfc91281f786f5) + +set(XVIDCORE_VERSION 1.3.4) +set(XVIDCORE_URI http://downloads.xvid.org/downloads/xvidcore-${XVIDCORE_VERSION}.tar.gz) +set(XVIDCORE_HASH 4e9fd62728885855bc5007fe1be58df42e5e274497591fec37249e1052ae316f) + +set(OPENJPEG_VERSION 1.5) +set(OPENJPEG_URI https://github.com/uclouvain/openjpeg/archive/version.${OPENJPEG_VERSION}.tar.gz) +set(OPENJPEG_HASH 60662566595e02104c0f6d1052f8b1669624c646e62b6280d5fd5a66d4e92f8d) + +set(FAAD_VERSION 2-2.7) +set(FAAD_URI http://downloads.sourceforge.net/faac/faad${FAAD_VERSION}.tar.bz2) +set(FAAD_HASH 4c332fa23febc0e4648064685a3d4332) + +set(FFMPEG_VERSION 3.2.1) +set(FFMPEG_URI http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2) +set(FFMPEG_HASH cede174178e61f882844f5870c35ce72) + +set(FFTW_VERSION 3.3.4) +set(FFTW_URI http://www.fftw.org/fftw-${FFTW_VERSION}.tar.gz) +set(FFTW_HASH 2edab8c06b24feeb3b82bbb3ebf3e7b3) + +set(ICONV_VERSION 1.14) +set(ICONV_URI http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${ICONV_VERSION}.tar.gz) +set(ICONV_HASH e34509b1623cec449dfeb73d7ce9c6c6) + +set(LAPACK_VERSION 3.6.0) +set(LAPACK_URI http://www.netlib.org/lapack/lapack-${LAPACK_VERSION}.tgz) +set(LAPACK_HASH f2f6c67134e851fe189bb3ca1fbb5101) + +set(SNDFILE_VERSION 1.0.26) +set(SNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${SNDFILE_VERSION}.tar.gz) +set(SNDFILE_HASH ec810a0c60c08772a8a5552704b63393) + +#set(HIDAPI_VERSION 0.8.0-rc1) +#set(HIDAPI_URI https://github.com/signal11/hidapi/archive/hidapi-${HIDAPI_VERSION}.tar.gz) +#set(HIDAPI_HASH 069f9dd746edc37b6b6d0e3656f47199) + +set(HIDAPI_UID 89a6c75dc6f45ecabd4ddfbd2bf5ba6ad8ba38b5) +set(HIDAPI_URI https://github.com/TheOnlyJoey/hidapi/archive/${HIDAPI_UID}.zip) +set(HIDAPI_HASH b6e22f6b514f8bcf594989f20ffc46fb) + +set(WEBP_VERSION 0.5.1) +set(WEBP_URI https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${WEBP_VERSION}.tar.gz) +set(WEBP_HASH 3d7db92ebba5b4f679413d25c6040881) + +set(SPNAV_VERSION 0.2.3) +set(SPNAV_URI http://downloads.sourceforge.net/project/spacenav/spacenav%20library%20%28SDK%29/libspnav%20${SPNAV_VERSION}/libspnav-${SPNAV_VERSION}.tar.gz) +set(SPNAV_HASH 44d840540d53326d4a119c0f1aa7bf0a) + +set(JEMALLOC_VERSION 5.0.1) +set(JEMALLOC_URI https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2) +set(JEMALLOC_HASH 507f7b6b882d868730d644510491d18f) + +set(XML2_VERSION 2.9.4) +set(XML2_URI ftp://xmlsoft.org/libxml2/libxml2-${XML2_VERSION}.tar.gz) +set(XML2_HASH ae249165c173b1ff386ee8ad676815f5) diff --git a/build_files/build_environment/cmake/vorbis.cmake b/build_files/build_environment/cmake/vorbis.cmake new file mode 100644 index 00000000000..d16c7c6a1bc --- /dev/null +++ b/build_files/build_environment/cmake/vorbis.cmake @@ -0,0 +1,38 @@ +# ***** 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 ***** + +ExternalProject_Add(external_vorbis + URL ${VORBIS_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${VORBIS_HASH} + PREFIX ${BUILD_DIR}/vorbis + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vorbis/src/external_vorbis/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/vorbis + --disable-shared + --enable-static + --with-pic + --with-ogg=${LIBDIR}/ogg + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vorbis/src/external_vorbis/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vorbis/src/external_vorbis/ && make install + INSTALL_DIR ${LIBDIR}/vorbis +) + +add_dependencies(external_vorbis external_ogg) + +if(MSVC) + set_target_properties(external_vorbis PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/vpx.cmake b/build_files/build_environment/cmake/vpx.cmake new file mode 100644 index 00000000000..6569708cb5f --- /dev/null +++ b/build_files/build_environment/cmake/vpx.cmake @@ -0,0 +1,56 @@ +# ***** 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 ***** + +if(WIN32) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(VPX_EXTRA_FLAGS --target=x86_64-win64-gcc) + else() + set(VPX_EXTRA_FLAGS --target=x86-win32-gcc) + endif() +else() + set(VPX_EXTRA_FLAGS --target=generic-gnu) +endif() + +ExternalProject_Add(external_vpx + URL ${VPX_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${VPX_HASH} + PREFIX ${BUILD_DIR}/vpx + CONFIGURE_COMMAND ${CONFIGURE_ENV} && + cd ${BUILD_DIR}/vpx/src/external_vpx/ && + ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/vpx + --disable-shared + --enable-static + --disable-install-bins + --disable-install-srcs + --disable-sse4_1 + --disable-sse3 + --disable-ssse3 + --disable-avx + --disable-avx2 + --disable-unit-tests + --disable-examples + ${VPX_EXTRA_FLAGS} + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make install + INSTALL_DIR ${LIBDIR}/vpx +) + +if(MSVC) + set_target_properties(external_vpx PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/webp.cmake b/build_files/build_environment/cmake/webp.cmake new file mode 100644 index 00000000000..0504988a088 --- /dev/null +++ b/build_files/build_environment/cmake/webp.cmake @@ -0,0 +1,50 @@ +# ***** 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(WEBP_EXTRA_ARGS + -DWEBP_HAVE_SSE2=ON + -DWEBP_HAVE_SSE41=OFF + -DWEBP_HAVE_AVX2=OFF +) + +if(WIN32) + set(WEBP_BUILD_DIR ${BUILD_MODE}/) +else() + set(WEBP_BUILD_DIR) +endif() + +ExternalProject_Add(external_webp + URL ${WEBP_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${WEBP_HASH} + PREFIX ${BUILD_DIR}/webp + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/webp -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${WEBP_EXTRA_ARGS} + INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp-build/${WEBP_BUILD_DIR}${LIBPREFIX}webp${LIBEXT} ${LIBDIR}/webp/lib/${LIBPREFIX}webp${LIBEXT} && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/decode.h ${LIBDIR}/webp/include/webp/decode.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/encode.h ${LIBDIR}/webp/include/webp/encode.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/demux.h ${LIBDIR}/webp/include/webp/demux.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/extras.h ${LIBDIR}/webp/include/webp/extras.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/format_constants.h ${LIBDIR}/webp/include/webp/format_constants.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/mux.h ${LIBDIR}/webp/include/webp/mux.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/mux_types.h ${LIBDIR}/webp/include/webp/mux_types.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/webp/src/external_webp/src/webp/types.h ${LIBDIR}/webp/include/webp/types.h + INSTALL_DIR ${LIBDIR}/webp +) diff --git a/build_files/build_environment/cmake/x264.cmake b/build_files/build_environment/cmake/x264.cmake new file mode 100644 index 00000000000..64029ca1b5e --- /dev/null +++ b/build_files/build_environment/cmake/x264.cmake @@ -0,0 +1,40 @@ +# ***** 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 ***** + +if(WIN32) + set(X264_EXTRA_ARGS --enable-win32thread --cross-prefix=${MINGW_HOST}- --host=${MINGW_HOST}) +endif() + +ExternalProject_Add(external_x264 + URL ${X264_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${X264_HASH} + PREFIX ${BUILD_DIR}/x264 + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264 + --enable-static + --enable-pic + --disable-lavf + ${X264_EXTRA_ARGS} + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && make install + INSTALL_DIR ${LIBDIR}/x264 +) + +if(MSVC) + set_target_properties(external_x264 PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/xml2.cmake b/build_files/build_environment/cmake/xml2.cmake new file mode 100644 index 00000000000..a8f87a67ad4 --- /dev/null +++ b/build_files/build_environment/cmake/xml2.cmake @@ -0,0 +1,36 @@ +# ***** 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 ***** + +ExternalProject_Add(external_xml2 + URL ${XML2_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH MD5=${XML2_HASH} + PREFIX ${BUILD_DIR}/xml2 + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xml2/src/external_xml2/ && ${CONFIGURE_COMMAND} + --prefix=${LIBDIR}/xml2 + --disable-shared + --enable-static + --with-pic + --with-python=no + --with-lzma=no + --with-zlib=no + --with-iconv=no + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xml2/src/external_xml2/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xml2/src/external_xml2/ && make install + INSTALL_DIR ${LIBDIR}/xml2 +) diff --git a/build_files/build_environment/cmake/xvidcore.cmake b/build_files/build_environment/cmake/xvidcore.cmake new file mode 100644 index 00000000000..a341275ea47 --- /dev/null +++ b/build_files/build_environment/cmake/xvidcore.cmake @@ -0,0 +1,44 @@ +# ***** 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 ***** + +if(WIN32) + set(XVIDCORE_EXTRA_ARGS --host=${MINGW_HOST}) +endif() + +ExternalProject_Add(external_xvidcore + URL ${XVIDCORE_URI} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH SHA256=${XVIDCORE_HASH} + PREFIX ${BUILD_DIR}/xvidcore + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xvidcore/src/external_xvidcore/build/generic && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/xvidcore ${XVIDCORE_EXTRA_ARGS} + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xvidcore/src/external_xvidcore/build/generic && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && + ${CMAKE_COMMAND} -E remove ${LIBDIR}/xvidcore/lib/* && # clean because re-installing fails otherwise + cd ${BUILD_DIR}/xvidcore/src/external_xvidcore/build/generic && make install + INSTALL_DIR ${LIBDIR}/xvidcore +) + +ExternalProject_Add_Step(external_xvidcore after_install + COMMAND ${CMAKE_COMMAND} -E rename ${LIBDIR}/xvidcore/lib/xvidcore.a ${LIBDIR}/xvidcore/lib/libxvidcore.a || true + COMMAND ${CMAKE_COMMAND} -E remove ${LIBDIR}/xvidcore/lib/xvidcore.dll.a + DEPENDEES install +) + +if(MSVC) + set_target_properties(external_xvidcore PROPERTIES FOLDER Mingw) +endif() diff --git a/build_files/build_environment/cmake/zlib.cmake b/build_files/build_environment/cmake/zlib.cmake new file mode 100644 index 00000000000..3307cb1f167 --- /dev/null +++ b/build_files/build_environment/cmake/zlib.cmake @@ -0,0 +1,33 @@ +# ***** 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 ***** + +ExternalProject_Add(external_zlib + URL ${ZLIB_URI} + URL_HASH MD5=${ZLIB_HASH} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + PREFIX ${BUILD_DIR}/zlib + CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zlib ${DEFAULT_CMAKE_FLAGS} + INSTALL_DIR ${LIBDIR}/zlib +) + +if(BUILD_MODE STREQUAL Debug) + ExternalProject_Add_Step(external_zlib after_install + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstaticd${LIBEXT} ${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} + DEPENDEES install + ) +endif() diff --git a/build_files/build_environment/cmake/zlib_mingw.cmake b/build_files/build_environment/cmake/zlib_mingw.cmake new file mode 100644 index 00000000000..13345f29ffa --- /dev/null +++ b/build_files/build_environment/cmake/zlib_mingw.cmake @@ -0,0 +1,40 @@ +# ***** 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 ***** + +ExternalProject_Add(external_zlib_mingw + URL ${ZLIB_URI} + URL_HASH MD5=${ZLIB_HASH} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + PREFIX ${BUILD_DIR}/zlib_mingw + CONFIGURE_COMMAND echo . + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/zlib_mingw/src/external_zlib_mingw/ && make -f win32/makefile.gcc -j${MAKE_THREADS} + INSTALL_COMMAND echo . + INSTALL_DIR ${LIBDIR}/zlib_mingw +) + +if(BUILD_MODE STREQUAL Release) + ExternalProject_Add_Step(external_zlib_mingw after_install + COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/zlib_mingw/src/external_zlib_mingw/libz.a ${LIBDIR}/zlib/lib/z.lib + DEPENDEES install + ) +endif() + +if(MSVC) + set_target_properties(external_zlib_mingw PROPERTIES FOLDER Mingw) +endif() + diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 3852b4fe705..db2a1246a60 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -1599,7 +1599,7 @@ compile_OIIO() { fi # To be changed each time we make edits that would modify the compiled result! - oiio_magic=16 + oiio_magic=17 _init_oiio # Clean install if needed! @@ -1663,6 +1663,9 @@ compile_OIIO() { INFO "ILMBASE_HOME=$INST/openexr" fi + # ptex is only needed when nicholas bishop is ready + cmake_d="$cmake_d -D USE_PTEX=OFF" + # Optional tests and cmd tools cmake_d="$cmake_d -D USE_QT=OFF" cmake_d="$cmake_d -D USE_PYTHON=OFF" @@ -1774,7 +1777,7 @@ compile_LLVM() { cd $_src # XXX Ugly patching hack! - patch -p1 -i "$SCRIPT_DIR/install_deps_patches/llvm.patch" + patch -p1 -i "$SCRIPT_DIR/patches/install_deps_llvm.patch" cd $CWD @@ -1880,7 +1883,7 @@ compile_OSL() { git reset --hard # XXX Ugly patching hack! - patch -p1 -i "$SCRIPT_DIR/install_deps_patches/osl.patch" + patch -p1 -i "$SCRIPT_DIR/patches/install_deps_osl.patch" fi # Always refresh the whole build! diff --git a/build_files/build_environment/patches/alembic.diff b/build_files/build_environment/patches/alembic.diff new file mode 100644 index 00000000000..f869858efb2 --- /dev/null +++ b/build_files/build_environment/patches/alembic.diff @@ -0,0 +1,35 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3e09c57..26565ae 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -116,7 +116,7 @@ IF (NOT ${ALEMBIC_LIB_USES_TR1} AND NOT ${ALEMBIC_LIB_USES_BOOST}) + INCLUDE(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) +- IF (COMPILER_SUPPORTS_CXX1X) ++ IF (COMPILER_SUPPORTS_CXX11) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + ELSEIF (COMPILER_SUPPORTS_CXX0X) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +--- a/lib/Alembic/AbcCoreOgawa/StreamManager.cpp ++++ b/lib/Alembic/AbcCoreOgawa/StreamManager.cpp +@@ -47,7 +47,18 @@ + #define COMPARE_EXCHANGE( V, COMP, EXCH ) V.compare_exchange_weak( COMP, EXCH, std::memory_order_seq_cst, std::memory_order_seq_cst ) + // Windows + #elif defined( _MSC_VER ) +-#define COMPARE_EXCHANGE( V, COMP, EXCH ) InterlockedCompareExhange64( &V, EXCH, COMP ) == COMP ++#define COMPARE_EXCHANGE( V, COMP, EXCH ) InterlockedCompareExchange64( &V, EXCH, COMP ) == COMP ++int ffsll(long long value) ++{ ++ if (!value) ++ return 0; ++ ++ for (int bit = 0; bit < 63; bit++) ++ { ++ if (value & (1 << bit)) ++ return bit + 1; ++ } ++} + // gcc 4.8 and above not using C++11 + #elif defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 + #define COMPARE_EXCHANGE( V, COMP, EXCH ) __atomic_compare_exchange_n( &V, &COMP, EXCH, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) diff --git a/build_files/build_environment/patches/blosc.diff b/build_files/build_environment/patches/blosc.diff new file mode 100644 index 00000000000..3bd6ef28144 --- /dev/null +++ b/build_files/build_environment/patches/blosc.diff @@ -0,0 +1,33 @@ +diff -Naur src/blosc/CMakeLists.txt external_blosc/blosc/CMakeLists.txt +--- src/blosc/CMakeLists.txt 2016-02-03 10:26:28 -0700 ++++ external_blosc/blosc/CMakeLists.txt 2017-03-03 09:03:31 -0700 +@@ -61,6 +61,8 @@ + set(SOURCES ${SOURCES} win32/pthread.c) + else(NOT Threads_FOUND) + set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT}) ++ set(LIBS ${LIBS} ${PTHREAD_LIBS}) ++ include_directories( ${PTHREAD_INCLUDE_DIR} ) + endif(NOT Threads_FOUND) + else(WIN32) + find_package(Threads REQUIRED) +diff -Naur src/blosc/blosc.c external_blosc/blosc/blosc.c +--- src/blosc/blosc.c 2016-02-03 10:26:28 -0700 ++++ external_blosc/blosc/blosc.c 2017-03-03 09:01:50 -0700 +@@ -49,12 +49,12 @@ + #include <inttypes.h> + #endif /* _WIN32 */ + +-#if defined(_WIN32) && !defined(__GNUC__) +- #include "win32/pthread.h" +- #include "win32/pthread.c" +-#else ++//#if defined(_WIN32) && !defined(__GNUC__) ++// #include "win32/pthread.h" ++ //#include "win32/pthread.c" ++//#else + #include <pthread.h> +-#endif ++//#endif + + /* If C11 is supported, use it's built-in aligned allocation. */ + #if __STDC_VERSION__ >= 201112L diff --git a/build_files/build_environment/patches/clang.diff b/build_files/build_environment/patches/clang.diff new file mode 100644 index 00000000000..724e92f8163 --- /dev/null +++ b/build_files/build_environment/patches/clang.diff @@ -0,0 +1,127 @@ +--- cfe/trunk/lib/Serialization/ASTWriter.cpp ++++ cfe/trunk/lib/Serialization/ASTWriter.cpp +@@ -56,14 +56,14 @@ + using namespace clang::serialization; + + template <typename T, typename Allocator> +-static StringRef bytes(const std::vector<T, Allocator> &v) { ++static StringRef data(const std::vector<T, Allocator> &v) { + if (v.empty()) return StringRef(); + return StringRef(reinterpret_cast<const char*>(&v[0]), + sizeof(T) * v.size()); + } + + template <typename T> +-static StringRef bytes(const SmallVectorImpl<T> &v) { ++static StringRef data(const SmallVectorImpl<T> &v) { + return StringRef(reinterpret_cast<const char*>(v.data()), + sizeof(T) * v.size()); + } +@@ -1385,7 +1385,7 @@ + Record.push_back(INPUT_FILE_OFFSETS); + Record.push_back(InputFileOffsets.size()); + Record.push_back(UserFilesNum); +- Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record, bytes(InputFileOffsets)); ++ Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record, data(InputFileOffsets)); + } + + //===----------------------------------------------------------------------===// +@@ -1771,7 +1771,7 @@ + Record.push_back(SOURCE_LOCATION_OFFSETS); + Record.push_back(SLocEntryOffsets.size()); + Record.push_back(SourceMgr.getNextLocalOffset() - 1); // skip dummy +- Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record, bytes(SLocEntryOffsets)); ++ Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record, data(SLocEntryOffsets)); + + // Write the source location entry preloads array, telling the AST + // reader which source locations entries it should load eagerly. +@@ -2087,7 +2087,7 @@ + Record.push_back(MacroOffsets.size()); + Record.push_back(FirstMacroID - NUM_PREDEF_MACRO_IDS); + Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record, +- bytes(MacroOffsets)); ++ data(MacroOffsets)); + } + + void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { +@@ -2185,7 +2185,7 @@ + Record.push_back(PPD_ENTITIES_OFFSETS); + Record.push_back(FirstPreprocessorEntityID - NUM_PREDEF_PP_ENTITY_IDS); + Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record, +- bytes(PreprocessedEntityOffsets)); ++ data(PreprocessedEntityOffsets)); + } + } + +@@ -2548,7 +2548,7 @@ + Record.push_back(CXX_BASE_SPECIFIER_OFFSETS); + Record.push_back(CXXBaseSpecifiersOffsets.size()); + Stream.EmitRecordWithBlob(BaseSpecifierOffsetAbbrev, Record, +- bytes(CXXBaseSpecifiersOffsets)); ++ data(CXXBaseSpecifiersOffsets)); + } + + //===----------------------------------------------------------------------===// +@@ -2623,7 +2623,7 @@ + Decls.push_back(std::make_pair((*D)->getKind(), GetDeclRef(*D))); + + ++NumLexicalDeclContexts; +- Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record, bytes(Decls)); ++ Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record, data(Decls)); + return Offset; + } + +@@ -2642,7 +2642,7 @@ + Record.push_back(TYPE_OFFSET); + Record.push_back(TypeOffsets.size()); + Record.push_back(FirstTypeID - NUM_PREDEF_TYPE_IDS); +- Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record, bytes(TypeOffsets)); ++ Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record, data(TypeOffsets)); + + // Write the declaration offsets array + Abbrev = new BitCodeAbbrev(); +@@ -2655,7 +2655,7 @@ + Record.push_back(DECL_OFFSET); + Record.push_back(DeclOffsets.size()); + Record.push_back(FirstDeclID - NUM_PREDEF_DECL_IDS); +- Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record, bytes(DeclOffsets)); ++ Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record, data(DeclOffsets)); + } + + void ASTWriter::WriteFileDeclIDsMap() { +@@ -2680,7 +2680,7 @@ + unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev); + Record.push_back(FILE_SORTED_DECLS); + Record.push_back(FileSortedIDs.size()); +- Stream.EmitRecordWithBlob(AbbrevCode, Record, bytes(FileSortedIDs)); ++ Stream.EmitRecordWithBlob(AbbrevCode, Record, data(FileSortedIDs)); + } + + void ASTWriter::WriteComments() { +@@ -2893,7 +2893,7 @@ + Record.push_back(SelectorOffsets.size()); + Record.push_back(FirstSelectorID - NUM_PREDEF_SELECTOR_IDS); + Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record, +- bytes(SelectorOffsets)); ++ data(SelectorOffsets)); + } + } + +@@ -3253,7 +3253,7 @@ + Record.push_back(IdentifierOffsets.size()); + Record.push_back(FirstIdentID - NUM_PREDEF_IDENT_IDS); + Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record, +- bytes(IdentifierOffsets)); ++ data(IdentifierOffsets)); + } + + //===----------------------------------------------------------------------===// +@@ -4046,7 +4046,7 @@ + Record.clear(); + Record.push_back(TU_UPDATE_LEXICAL); + Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record, +- bytes(NewGlobalDecls)); ++ data(NewGlobalDecls)); + + // And a visible updates block for the translation unit. + Abv = new llvm::BitCodeAbbrev(); diff --git a/build_files/build_environment/patches/cmake/modules/FindBlosc.cmake b/build_files/build_environment/patches/cmake/modules/FindBlosc.cmake new file mode 100644 index 00000000000..d490b7a2ff3 --- /dev/null +++ b/build_files/build_environment/patches/cmake/modules/FindBlosc.cmake @@ -0,0 +1,73 @@ +# - Find BLOSC library +# Find the native BLOSC includes and library +# This module defines +# BLOSC_INCLUDE_DIRS, where to find blosc.h, Set when +# BLOSC is found. +# BLOSC_LIBRARIES, libraries to link against to use BLOSC. +# BLOSC_ROOT_DIR, The base directory to search for BLOSC. +# This can also be an environment variable. +# BLOSC_FOUND, If false, do not try to use BLOSC. +# +# also defined, but not for general use are +# BLOSC_LIBRARY, where to find the BLOSC library. + +#============================================================================= +# Copyright 2016 Blender Foundation. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# If BLOSC_ROOT_DIR was defined in the environment, use it. +IF(NOT BLOSC_ROOT_DIR AND NOT $ENV{BLOSC_ROOT_DIR} STREQUAL "") + SET(BLOSC_ROOT_DIR $ENV{BLOSC_ROOT_DIR}) +ENDIF() + +SET(_blosc_SEARCH_DIRS + ${BLOSC_ROOT_DIR} + /usr/local + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt/lib/blosc +) + +FIND_PATH(BLOSC_INCLUDE_DIR + NAMES + blosc.h + HINTS + ${_blosc_SEARCH_DIRS} + PATH_SUFFIXES + include +) + +FIND_LIBRARY(BLOSC_LIBRARY + NAMES + blosc + HINTS + ${_blosc_SEARCH_DIRS} + PATH_SUFFIXES + lib64 lib +) + +# handle the QUIETLY and REQUIRED arguments and set BLOSC_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(BLOSC DEFAULT_MSG + BLOSC_LIBRARY BLOSC_INCLUDE_DIR) + +IF(BLOSC_FOUND) + SET(BLOSC_LIBRARIES ${BLOSC_LIBRARY}) + SET(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIR}) +ELSE() + SET(BLOSC_FOUND FALSE) +ENDIF() + +MARK_AS_ADVANCED( + BLOSC_INCLUDE_DIR + BLOSC_LIBRARY +) diff --git a/build_files/build_environment/patches/cmake/modules/FindCppUnit.cmake b/build_files/build_environment/patches/cmake/modules/FindCppUnit.cmake new file mode 100644 index 00000000000..3dd480356af --- /dev/null +++ b/build_files/build_environment/patches/cmake/modules/FindCppUnit.cmake @@ -0,0 +1,73 @@ +# - Find CPPUNIT library +# Find the native CPPUNIT includes and library +# This module defines +# CPPUNIT_INCLUDE_DIRS, where to find cppunit.h, Set when +# CPPUNIT is found. +# CPPUNIT_LIBRARIES, libraries to link against to use CPPUNIT. +# CPPUNIT_ROOT_DIR, The base directory to search for CPPUNIT. +# This can also be an environment variable. +# CPPUNIT_FOUND, If false, do not try to use CPPUNIT. +# +# also defined, but not for general use are +# CPPUNIT_LIBRARY, where to find the CPPUNIT library. + +#============================================================================= +# Copyright 2016 Blender Foundation. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# If CPPUNIT_ROOT_DIR was defined in the environment, use it. +IF(NOT CPPUNIT_ROOT_DIR AND NOT $ENV{CPPUNIT_ROOT_DIR} STREQUAL "") + SET(CPPUNIT_ROOT_DIR $ENV{CPPUNIT_ROOT_DIR}) +ENDIF() + +SET(_cppunit_SEARCH_DIRS + ${CPPUNIT_ROOT_DIR} + /usr/local + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt/lib/cppunit +) + +FIND_PATH(CPPUNIT_INCLUDE_DIR + NAMES + cppunit/Test.h + HINTS + ${_cppunit_SEARCH_DIRS} + PATH_SUFFIXES + include +) + +FIND_LIBRARY(CPPUNIT_LIBRARY + NAMES + cppunit + HINTS + ${_cppunit_SEARCH_DIRS} + PATH_SUFFIXES + lib64 lib +) + +# handle the QUIETLY and REQUIRED arguments and set CPPUNIT_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG + CPPUNIT_LIBRARY CPPUNIT_INCLUDE_DIR) + +IF(CPPUNIT_FOUND) + SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY}) + SET(CPPUNIT_INCLUDE_DIRS ${CPPUNIT_INCLUDE_DIR}) +ELSE() + SET(CPPUNIT_FOUND FALSE) +ENDIF() + +MARK_AS_ADVANCED( + CPPUNIT_INCLUDE_DIR + CPPUNIT_LIBRARY +) diff --git a/build_files/build_environment/patches/cmake/modules/FindIlmBase.cmake b/build_files/build_environment/patches/cmake/modules/FindIlmBase.cmake new file mode 100644 index 00000000000..f1a45228128 --- /dev/null +++ b/build_files/build_environment/patches/cmake/modules/FindIlmBase.cmake @@ -0,0 +1,260 @@ +# Module to find IlmBase +# +# This module will first look into the directories defined by the variables: +# - ILMBASE_HOME, ILMBASE_VERSION, ILMBASE_LIB_AREA +# +# It also supports non-standard names for the library components. +# +# To use a custom IlmBase: +# - Set the variable ILMBASE_CUSTOM to True +# - Set the variable ILMBASE_CUSTOM_LIBRARIES to a list of the libraries to +# use, e.g. "SpiImath SpiHalf SpiIlmThread SpiIex" +# - Optionally set the variable ILMBASE_CUSTOM_INCLUDE_DIR to any +# particularly weird place that the OpenEXR/*.h files may be found +# - Optionally set the variable ILMBASE_CUSTOM_LIB_DIR to any +# particularly weird place that the libraries files may be found +# +# This module defines the following variables: +# +# ILMBASE_INCLUDE_DIR - where to find half.h, IlmBaseConfig.h, etc. +# ILMBASE_LIBRARIES - list of libraries to link against when using IlmBase. +# ILMBASE_FOUND - True if IlmBase was found. + +# Other standarnd issue macros +include (FindPackageHandleStandardArgs) +include (FindPackageMessage) +include (SelectLibraryConfigurations) + + +if( ILMBASE_USE_STATIC_LIBS ) + set( _ilmbase_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) + endif() +endif() + +# Macro to assemble a helper state variable +macro (SET_STATE_VAR varname) + set (tmp_ilmbaselibs ${ILMBASE_CUSTOM_LIBRARIES}) + separate_arguments (tmp_ilmbaselibs) + set (tmp_lst + ${ILMBASE_CUSTOM} | ${tmp_ilmbaselibs} | + ${ILMBASE_HOME} | ${ILMBASE_VERSION} | ${ILMBASE_LIB_AREA} + ) + set (${varname} "${tmp_lst}") + unset (tmp_ilmbaselibs) + unset (tmp_lst) +endmacro () + +# To enforce that find_* functions do not use inadvertently existing versions +if (ILMBASE_CUSTOM) + set (ILMBASE_FIND_OPTIONS "NO_DEFAULT_PATH") +endif () + +# Macro to search for an include directory +macro (PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var) + string (TOUPPER ${prefix}_INCLUDE_DIR tmp_varname) + find_path(${tmp_varname} ${includefile} + HINTS ${${libpath_var}} + PATH_SUFFIXES include + ${ILMBASE_FIND_OPTIONS} + ) + if (${tmp_varname}) + mark_as_advanced (${tmp_varname}) + endif () + unset (tmp_varname) +endmacro () + + +# Macro to search for the given library and adds the cached +# variable names to the specified list +macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var) + string (TOUPPER ${prefix}_${libname} tmp_prefix) + # Handle new library names for OpenEXR 2.1 build via cmake + string(REPLACE "." "_" _ILMBASE_VERSION ${ILMBASE_VERSION}) + string(SUBSTRING ${_ILMBASE_VERSION} 0 3 _ILMBASE_VERSION ) + + find_library(${tmp_prefix}_LIBRARY_RELEASE + NAMES ${libname} ${libname}-${_ILMBASE_VERSION} + HINTS ${${libpath_var}} + PATH_SUFFIXES lib + ${ILMBASE_FIND_OPTIONS} + ) + find_library(${tmp_prefix}_LIBRARY_DEBUG + NAMES ${libname}d ${libname}_d ${libname}debug ${libname}_debug + HINTS ${${libpath_var}} + PATH_SUFFIXES lib + ${ILMBASE_FIND_OPTIONS} + ) + # Properly define ${tmp_prefix}_LIBRARY (cached) and ${tmp_prefix}_LIBRARIES + select_library_configurations (${tmp_prefix}) + list (APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES) + + # Add to the list of variables which should be reset + list (APPEND ${cachelist_var} + ${tmp_prefix}_LIBRARY + ${tmp_prefix}_LIBRARY_RELEASE + ${tmp_prefix}_LIBRARY_DEBUG) + mark_as_advanced ( + ${tmp_prefix}_LIBRARY + ${tmp_prefix}_LIBRARY_RELEASE + ${tmp_prefix}_LIBRARY_DEBUG) + unset (tmp_prefix) +endmacro () + + +# Encode the current state of the external variables into a string +SET_STATE_VAR (ILMBASE_CURRENT_STATE) + +# If the state has changed, clear the cached variables +if (ILMBASE_CACHED_STATE AND + NOT ILMBASE_CACHED_STATE STREQUAL ILMBASE_CURRENT_STATE) + + foreach (libvar ${ILMBASE_CACHED_VARS}) + unset (${libvar} CACHE) + endforeach () +endif () + + +# Generic search paths +set (IlmBase_generic_include_paths + ${ILMBASE_CUSTOM_INCLUDE_DIR} + /usr/include + /usr/include/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/local/include + /sw/include + /opt/local/include) +set (IlmBase_generic_library_paths + ${ILMBASE_CUSTOM_LIB_DIR} + /usr/lib + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/local/lib + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /sw/lib + /opt/local/lib) + +# Search paths for the IlmBase files +if (ILMBASE_HOME) + if (ILMBASE_VERSION) + set (IlmBase_include_paths + ${ILMBASE_HOME}/ilmbase-${ILMBASE_VERSION}/include + ${ILMBASE_HOME}/include/ilmbase-${ILMBASE_VERSION}) + set (IlmBase_library_paths + ${ILMBASE_HOME}/ilmbase-${ILMBASE_VERSION}/lib + ${ILMBASE_HOME}/lib/ilmbase-${ILMBASE_VERSION}) + endif() + list (APPEND IlmBase_include_paths ${ILMBASE_HOME}/include) + set (IlmBase_library_paths + ${ILMBASE_HOME}/lib + ${ILMBASE_HOME}/lib64 + ${ILMBASE_LIB_AREA} + ${IlmBase_library_paths}) +endif () +list (APPEND IlmBase_include_paths ${IlmBase_generic_include_paths}) +list (APPEND IlmBase_library_paths ${IlmBase_generic_library_paths}) + +# Locate the header files +PREFIX_FIND_INCLUDE_DIR (IlmBase + OpenEXR/IlmBaseConfig.h IlmBase_include_paths) + +if (ILMBASE_INCLUDE_DIR) + # Get the version from config file, if not already set. + if (NOT ILMBASE_VERSION) + FILE(STRINGS "${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h" ILMBASE_BUILD_SPECIFICATION + REGEX "^[ \t]*#define[ \t]+ILMBASE_VERSION_STRING[ \t]+\"[.0-9]+\".*$") + + if(ILMBASE_BUILD_SPECIFICATION) + if (NOT IlmBase_FIND_QUIETLY) + message(STATUS "${ILMBASE_BUILD_SPECIFICATION}") + endif () + string(REGEX REPLACE ".*#define[ \t]+ILMBASE_VERSION_STRING[ \t]+\"([.0-9]+)\".*" + "\\1" XYZ ${ILMBASE_BUILD_SPECIFICATION}) + set("ILMBASE_VERSION" ${XYZ} CACHE STRING "Version of ILMBase lib") + else() + # Old versions (before 2.0?) do not have any version string, just assuming 2.0 should be fine though. + message(WARNING "Could not determine ILMBase library version, assuming 2.0.") + set("ILMBASE_VERSION" "2.0" CACHE STRING "Version of ILMBase lib") + endif() + endif() +endif () + + +if (ILMBASE_CUSTOM) + if (NOT ILMBASE_CUSTOM_LIBRARIES) + message (FATAL_ERROR "Custom IlmBase libraries requested but ILMBASE_CUSTOM_LIBRARIES is not set.") + endif() + set (IlmBase_Libraries ${ILMBASE_CUSTOM_LIBRARIES}) + separate_arguments(IlmBase_Libraries) +else () +#elseif (${ILMBASE_VERSION} VERSION_LESS "2.1") + set (IlmBase_Libraries Half Iex Imath IlmThread) +#else () +# string(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _ilmbase_libs_ver ${ILMBASE_VERSION}) +# set (IlmBase_Libraries Half Iex-${_ilmbase_libs_ver} Imath-${_ilmbase_libs_ver} IlmThread-${_ilmbase_libs_ver}) +endif () + + +# Locate the IlmBase libraries +set (IlmBase_libvars "") +set (IlmBase_cachevars "") +foreach (ilmbase_lib ${IlmBase_Libraries}) + PREFIX_FIND_LIB (IlmBase ${ilmbase_lib} + IlmBase_library_paths IlmBase_libvars IlmBase_cachevars) +endforeach () +# Create the list of variables that might need to be cleared +set (ILMBASE_CACHED_VARS + ILMBASE_INCLUDE_DIR ${IlmBase_cachevars} + CACHE INTERNAL "Variables set by FindIlmBase.cmake" FORCE) + +# Store the current state so that variables might be cleared if required +set (ILMBASE_CACHED_STATE ${ILMBASE_CURRENT_STATE} + CACHE INTERNAL "State last seen by FindIlmBase.cmake" FORCE) + +# Link with pthreads if required +if (NOT WIN32 AND EXISTS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h) + file (STRINGS ${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h + ILMBASE_HAVE_PTHREAD + REGEX "^[ \\t]*#define[ \\t]+HAVE_PTHREAD[ \\t]1[ \\t]*\$" + ) + if (ILMBASE_HAVE_PTHREAD) + find_package (Threads) + if (CMAKE_USE_PTHREADS_INIT) + set (ILMBASE_PTHREADS ${CMAKE_THREAD_LIBS_INIT}) + endif () + endif () +endif () + +# Use the standard function to handle ILMBASE_FOUND +FIND_PACKAGE_HANDLE_STANDARD_ARGS (IlmBase DEFAULT_MSG + ILMBASE_INCLUDE_DIR ${IlmBase_libvars}) + +if (ILMBASE_FOUND) + set (ILMBASE_LIBRARIES "") + foreach (tmplib ${IlmBase_libvars}) + list (APPEND ILMBASE_LIBRARIES ${${tmplib}}) + endforeach () + list (APPEND ILMBASE_LIBRARIES ${ILMBASE_PTHREADS}) + if (NOT IlmBase_FIND_QUIETLY) + FIND_PACKAGE_MESSAGE (ILMBASE + "Found IlmBase: ${ILMBASE_LIBRARIES}" + "[${ILMBASE_INCLUDE_DIR}][${ILMBASE_LIBRARIES}][${ILMBASE_CURRENT_STATE}]" + ) + endif () +endif () + +# Restore the original find library ordering +if( ILMBASE_USE_STATIC_LIBS ) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ilmbase_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +endif() + +# Unset the helper variables to avoid pollution +unset (ILMBASE_CURRENT_STATE) +unset (IlmBase_include_paths) +unset (IlmBase_library_paths) +unset (IlmBase_generic_include_paths) +unset (IlmBase_generic_library_paths) +unset (IlmBase_libvars) +unset (IlmBase_cachevars) +unset (ILMBASE_PTHREADS) diff --git a/build_files/build_environment/patches/cmake/modules/FindLogC4Plus.cmake b/build_files/build_environment/patches/cmake/modules/FindLogC4Plus.cmake new file mode 100644 index 00000000000..2002419cc75 --- /dev/null +++ b/build_files/build_environment/patches/cmake/modules/FindLogC4Plus.cmake @@ -0,0 +1,73 @@ +# - Find LOGC4PLUS library +# Find the native LOGC4PLUS includes and library +# This module defines +# LOGC4PLUS_INCLUDE_DIRS, where to find logc4plus.h, Set when +# LOGC4PLUS is found. +# LOGC4PLUS_LIBRARIES, libraries to link against to use LOGC4PLUS. +# LOGC4PLUS_ROOT_DIR, The base directory to search for LOGC4PLUS. +# This can also be an environment variable. +# LOGC4PLUS_FOUND, If false, do not try to use LOGC4PLUS. +# +# also defined, but not for general use are +# LOGC4PLUS_LIBRARY, where to find the LOGC4PLUS library. + +#============================================================================= +# Copyright 2016 Blender Foundation. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# If LOGC4PLUS_ROOT_DIR was defined in the environment, use it. +IF(NOT LOGC4PLUS_ROOT_DIR AND NOT $ENV{LOGC4PLUS_ROOT_DIR} STREQUAL "") + SET(LOGC4PLUS_ROOT_DIR $ENV{LOGC4PLUS_ROOT_DIR}) +ENDIF() + +SET(_logc4plus_SEARCH_DIRS + ${LOGC4PLUS_ROOT_DIR} + /usr/local + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt/lib/logc4plus +) + +FIND_PATH(LOGC4PLUS_INCLUDE_DIR + NAMES + logc4plus.h + HINTS + ${_logc4plus_SEARCH_DIRS} + PATH_SUFFIXES + include +) + +FIND_LIBRARY(LOGC4PLUS_LIBRARY + NAMES + logc4plus + HINTS + ${_logc4plus_SEARCH_DIRS} + PATH_SUFFIXES + lib64 lib + ) + +# handle the QUIETLY and REQUIRED arguments and set LOGC4PLUS_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LOGC4PLUS DEFAULT_MSG + LOGC4PLUS_LIBRARY LOGC4PLUS_INCLUDE_DIR) + +IF(LOGC4PLUS_FOUND) + SET(LOGC4PLUS_LIBRARIES ${LOGC4PLUS_LIBRARY}) + SET(LOGC4PLUS_INCLUDE_DIRS ${LOGC4PLUS_INCLUDE_DIR}) +ELSE() + SET(LOGC4PLUS_LOGC4PLUS_FOUND FALSE) +ENDIF() + +MARK_AS_ADVANCED( + LOGC4PLUS_INCLUDE_DIR + LOGC4PLUS_LIBRARY +) diff --git a/build_files/build_environment/patches/cmake/modules/FindOpenEXR.cmake b/build_files/build_environment/patches/cmake/modules/FindOpenEXR.cmake new file mode 100644 index 00000000000..08d872445d7 --- /dev/null +++ b/build_files/build_environment/patches/cmake/modules/FindOpenEXR.cmake @@ -0,0 +1,244 @@ +# Module to find OpenEXR. +# +# This module will first look into the directories defined by the variables: +# - OPENEXR_HOME, OPENEXR_VERSION, OPENEXR_LIB_AREA +# +# It also supports non-standard names for the library components. +# +# To use a custom OpenEXR +# - Set the variable OPENEXR_CUSTOM to True +# - Set the variable OPENEXR_CUSTOM_LIBRARY to the name of the library to +# use, e.g. "SpiIlmImf" +# - Optionally set the variable OPENEXR_CUSTOM_INCLUDE_DIR to any +# particularly weird place that the OpenEXR/*.h files may be found +# - Optionally set the variable OPENEXR_CUSTOM_LIB_DIR to any +# particularly weird place that the libraries files may be found +# +# This module defines the following variables: +# +# OPENEXR_INCLUDE_DIR - where to find ImfRgbaFile.h, OpenEXRConfig, etc. +# OPENEXR_LIBRARIES - list of libraries to link against when using OpenEXR. +# This list does NOT include the IlmBase libraries. +# These are defined by the FindIlmBase module. +# OPENEXR_FOUND - True if OpenEXR was found. + +# Other standarnd issue macros +include (SelectLibraryConfigurations) +include (FindPackageHandleStandardArgs) +include (FindPackageMessage) + +if( OPENEXR_USE_STATIC_LIBS ) + set( _openexr_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) + endif() +endif() + +# Macro to assemble a helper state variable +macro (SET_STATE_VAR varname) + set (tmp_lst + ${OPENEXR_CUSTOM} | ${OPENEXR_CUSTOM_LIBRARY} | + ${OPENEXR_HOME} | ${OPENEXR_VERSION} | ${OPENEXR_LIB_AREA} + ) + set (${varname} "${tmp_lst}") + unset (tmp_lst) +endmacro () + +# To enforce that find_* functions do not use inadvertently existing versions +if (OPENEXR_CUSTOM) + set (OPENEXR_FIND_OPTIONS "NO_DEFAULT_PATH") +endif () + +# Macro to search for an include directory +macro (PREFIX_FIND_INCLUDE_DIR prefix includefile libpath_var) + string (TOUPPER ${prefix}_INCLUDE_DIR tmp_varname) + find_path(${tmp_varname} ${includefile} + HINTS ${${libpath_var}} + PATH_SUFFIXES include + ${OPENEXR_FIND_OPTIONS} + ) + if (${tmp_varname}) + mark_as_advanced (${tmp_varname}) + endif () + unset (tmp_varname) +endmacro () + + +# Macro to search for the given library and adds the cached +# variable names to the specified list +macro (PREFIX_FIND_LIB prefix libname libpath_var liblist_var cachelist_var) + string (TOUPPER ${prefix}_${libname} tmp_prefix) + # Handle new library names for OpenEXR 2.1 build via cmake + string(REPLACE "." "_" _ILMBASE_VERSION ${ILMBASE_VERSION}) + string(SUBSTRING ${_ILMBASE_VERSION} 0 3 _ILMBASE_VERSION ) + find_library(${tmp_prefix}_LIBRARY_RELEASE + NAMES ${libname} ${libname}-${_ILMBASE_VERSION} + HINTS ${${libpath_var}} + PATH_SUFFIXES lib + ${OPENEXR_FIND_OPTIONS} + ) + find_library(${tmp_prefix}_LIBRARY_DEBUG + NAMES ${libname}d ${libname}_d ${libname}debug ${libname}_debug + HINTS ${${libpath_var}} + PATH_SUFFIXES lib + ${OPENEXR_FIND_OPTIONS} + ) + # Properly define ${tmp_prefix}_LIBRARY (cached) and ${tmp_prefix}_LIBRARIES + select_library_configurations (${tmp_prefix}) + list (APPEND ${liblist_var} ${tmp_prefix}_LIBRARIES) + + # Add to the list of variables which should be reset + list (APPEND ${cachelist_var} + ${tmp_prefix}_LIBRARY + ${tmp_prefix}_LIBRARY_RELEASE + ${tmp_prefix}_LIBRARY_DEBUG) + mark_as_advanced ( + ${tmp_prefix}_LIBRARY + ${tmp_prefix}_LIBRARY_RELEASE + ${tmp_prefix}_LIBRARY_DEBUG) + unset (tmp_prefix) +endmacro () + + +# Encode the current state of the external variables into a string +SET_STATE_VAR (OPENEXR_CURRENT_STATE) + +# If the state has changed, clear the cached variables +if (OPENEXR_CACHED_STATE AND + NOT OPENEXR_CACHED_STATE STREQUAL OPENEXR_CURRENT_STATE) + foreach (libvar ${OPENEXR_CACHED_VARS}) + unset (${libvar} CACHE) + endforeach () +endif () + +# Generic search paths +set (OpenEXR_generic_include_paths + ${OPENEXR_CUSTOM_INCLUDE_DIR} + /usr/include + /usr/include/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/local/include + /sw/include + /opt/local/include) +set (OpenEXR_generic_library_paths + ${OPENEXR_CUSTOM_LIB_DIR} + /usr/lib + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/local/lib + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /sw/lib + /opt/local/lib) + +# Search paths for the OpenEXR files +if (OPENEXR_HOME) + set (OpenEXR_library_paths + ${OPENEXR_HOME}/lib + ${OPENEXR_HOME}/lib64) + if (OPENEXR_VERSION) + set (OpenEXR_include_paths + ${OPENEXR_HOME}/openexr-${OPENEXR_VERSION}/include + ${OPENEXR_HOME}/include/openexr-${OPENEXR_VERSION}) + list (APPEND OpenEXR_library_paths + ${OPENEXR_HOME}/openexr-${OPENEXR_VERSION}/lib + ${OPENEXR_HOME}/lib/openexr-${OPENEXR_VERSION}) + endif() + list (APPEND OpenEXR_include_paths ${OPENEXR_HOME}/include) + if (OPENEXR_LIB_AREA) + list (INSERT OpenEXR_library_paths 2 ${OPENEXR_LIB_AREA}) + endif () +endif () +if (ILMBASE_HOME AND OPENEXR_VERSION) + list (APPEND OpenEXR_include_paths + ${ILMBASE_HOME}/include/openexr-${OPENEXR_VERSION}) +endif() +list (APPEND OpenEXR_include_paths ${OpenEXR_generic_include_paths}) +list (APPEND OpenEXR_library_paths ${OpenEXR_generic_library_paths}) + +# Locate the header files +PREFIX_FIND_INCLUDE_DIR (OpenEXR + OpenEXR/ImfArray.h OpenEXR_include_paths) + +if (OPENEXR_INCLUDE_DIR) + # Get the version from config file, if not already set. + if (NOT OPENEXR_VERSION) + FILE(STRINGS "${OPENEXR_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h" OPENEXR_BUILD_SPECIFICATION + REGEX "^[ \t]*#define[ \t]+OPENEXR_VERSION_STRING[ \t]+\"[.0-9]+\".*$") + + if(OPENEXR_BUILD_SPECIFICATION) + if (NOT OpenEXR_FIND_QUIETLY) + message(STATUS "${OPENEXR_BUILD_SPECIFICATION}") + endif () + string(REGEX REPLACE ".*#define[ \t]+OPENEXR_VERSION_STRING[ \t]+\"([.0-9]+)\".*" + "\\1" XYZ ${OPENEXR_BUILD_SPECIFICATION}) + set("OPENEXR_VERSION" ${XYZ} CACHE STRING "Version of OpenEXR lib") + else() + # Old versions (before 2.0?) do not have any version string, just assuming 2.0 should be fine though. + message(WARNING "Could not determine ILMBase library version, assuming 2.0.") + set("OPENEXR_VERSION" "2.0" CACHE STRING "Version of OpenEXR lib") + endif() + endif() +endif () + +if (OPENEXR_CUSTOM) + if (NOT OPENEXR_CUSTOM_LIBRARY) + message (FATAL_ERROR "Custom OpenEXR library requested but OPENEXR_CUSTOM_LIBRARY is not set.") + endif() + set (OpenEXR_Library ${OPENEXR_CUSTOM_LIBRARY}) +else () +#elseif (${OPENEXR_VERSION} VERSION_LESS "2.1") + set (OpenEXR_Library IlmImf) +#else () +# string(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _openexr_libs_ver ${OPENEXR_VERSION}) +# set (OpenEXR_Library IlmImf-${_openexr_libs_ver}) +endif () + +# Locate the OpenEXR library +set (OpenEXR_libvars "") +set (OpenEXR_cachevars "") +PREFIX_FIND_LIB (OpenEXR ${OpenEXR_Library} + OpenEXR_library_paths OpenEXR_libvars OpenEXR_cachevars) + +# Create the list of variables that might need to be cleared +set (OPENEXR_CACHED_VARS + OPENEXR_INCLUDE_DIR ${OpenEXR_cachevars} + CACHE INTERNAL "Variables set by FindOpenEXR.cmake" FORCE) + +# Store the current state so that variables might be cleared if required +set (OPENEXR_CACHED_STATE ${OPENEXR_CURRENT_STATE} + CACHE INTERNAL "State last seen by FindOpenEXR.cmake" FORCE) + +# Always link explicitly with zlib +set (OPENEXR_ZLIB ${ZLIB_LIBRARIES}) + +# Use the standard function to handle OPENEXR_FOUND +FIND_PACKAGE_HANDLE_STANDARD_ARGS (OpenEXR DEFAULT_MSG + OPENEXR_INCLUDE_DIR ${OpenEXR_libvars}) + +if (OPENEXR_FOUND) + set (OPENEXR_LIBRARIES "") + foreach (tmplib ${OpenEXR_libvars}) + list (APPEND OPENEXR_LIBRARIES ${${tmplib}}) + endforeach () + list (APPEND OPENEXR_LIBRARIES ${ZLIB_LIBRARIES}) + if (NOT OpenEXR_FIND_QUIETLY) + FIND_PACKAGE_MESSAGE (OPENEXR + "Found OpenEXR: ${OPENEXR_LIBRARIES}" + "[${OPENEXR_INCLUDE_DIR}][${OPENEXR_LIBRARIES}][${OPENEXR_CURRENT_STATE}]" + ) + endif () +endif () + +# Restore the original find library ordering +if( OPENEXR_USE_STATIC_LIBS ) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_openexr_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +endif() + +# Unset the helper variables to avoid pollution +unset (OPENEXR_CURRENT_STATE) +unset (OpenEXR_include_paths) +unset (OpenEXR_library_paths) +unset (OpenEXR_generic_include_paths) +unset (OpenEXR_generic_library_paths) +unset (OpenEXR_libvars) +unset (OpenEXR_cachevars) diff --git a/build_files/build_environment/patches/cmake/modules/FindTBB.cmake b/build_files/build_environment/patches/cmake/modules/FindTBB.cmake new file mode 100644 index 00000000000..8a821f8092e --- /dev/null +++ b/build_files/build_environment/patches/cmake/modules/FindTBB.cmake @@ -0,0 +1,73 @@ +# - Find TBB library +# Find the native TBB includes and library +# This module defines +# TBB_INCLUDE_DIRS, where to find tbb.h, Set when +# TBB is found. +# TBB_LIBRARIES, libraries to link against to use TBB. +# TBB_ROOT_DIR, The base directory to search for TBB. +# This can also be an environment variable. +# TBB_FOUND, If false, do not try to use TBB. +# +# also defined, but not for general use are +# TBB_LIBRARY, where to find the TBB library. + +#============================================================================= +# Copyright 2016 Blender Foundation. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# If TBB_ROOT_DIR was defined in the environment, use it. +IF(NOT TBB_ROOT_DIR AND NOT $ENV{TBB_ROOT_DIR} STREQUAL "") + SET(TBB_ROOT_DIR $ENV{TBB_ROOT_DIR}) +ENDIF() + +SET(_tbb_SEARCH_DIRS + ${TBB_ROOT_DIR} + /usr/local + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt/lib/tbb +) + +FIND_PATH(TBB_INCLUDE_DIR + NAMES + tbb/tbb.h + HINTS + ${_tbb_SEARCH_DIRS} + PATH_SUFFIXES + include +) + +FIND_LIBRARY(TBB_LIBRARY + NAMES + tbb + HINTS + ${_tbb_SEARCH_DIRS} + PATH_SUFFIXES + lib64 lib + ) + +# handle the QUIETLY and REQUIRED arguments and set TBB_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(TBB DEFAULT_MSG + TBB_LIBRARY TBB_INCLUDE_DIR) + +IF(TBB_FOUND) + SET(TBB_LIBRARIES ${TBB_LIBRARY}) + SET(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR}) +ELSE() + SET(TBB_TBB_FOUND FALSE) +ENDIF() + +MARK_AS_ADVANCED( + TBB_INCLUDE_DIR + TBB_LIBRARY +) diff --git a/build_files/build_environment/patches/cmake/modules/SelectLibraryConfigurations.cmake b/build_files/build_environment/patches/cmake/modules/SelectLibraryConfigurations.cmake new file mode 100644 index 00000000000..51b4dda0653 --- /dev/null +++ b/build_files/build_environment/patches/cmake/modules/SelectLibraryConfigurations.cmake @@ -0,0 +1,82 @@ +# select_library_configurations( basename ) +# +# This macro takes a library base name as an argument, and will choose good +# values for basename_LIBRARY, basename_LIBRARIES, basename_LIBRARY_DEBUG, and +# basename_LIBRARY_RELEASE depending on what has been found and set. If only +# basename_LIBRARY_RELEASE is defined, basename_LIBRARY, basename_LIBRARY_DEBUG, +# and basename_LIBRARY_RELEASE will be set to the release value. If only +# basename_LIBRARY_DEBUG is defined, then basename_LIBRARY, +# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value. +# +# If the generator supports configuration types, then basename_LIBRARY and +# basename_LIBRARIES will be set with debug and optimized flags specifying the +# library to be used for the given configuration. If no build type has been set +# or the generator in use does not support configuration types, then +# basename_LIBRARY and basename_LIBRARIES will take only the release values. + +#============================================================================= +# Copyright 2009 Kitware, Inc. +# Copyright 2009 Will Dicharry <wdicharry@stellarscience.com> +# Copyright 2005-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This macro was adapted from the FindQt4 CMake module and is maintained by Will +# Dicharry <wdicharry@stellarscience.com>. + +# Utility macro to check if one variable exists while another doesn't, and set +# one that doesn't exist to the one that exists. +macro( _set_library_name basename GOOD BAD ) + if( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} ) + set( ${basename}_LIBRARY_${BAD} ${${basename}_LIBRARY_${GOOD}} ) + set( ${basename}_LIBRARY ${${basename}_LIBRARY_${GOOD}} ) + set( ${basename}_LIBRARIES ${${basename}_LIBRARY_${GOOD}} ) + endif( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} ) +endmacro( _set_library_name ) + +macro( select_library_configurations basename ) + # if only the release version was found, set the debug to be the release + # version. + _set_library_name( ${basename} RELEASE DEBUG ) + # if only the debug version was found, set the release value to be the + # debug value. + _set_library_name( ${basename} DEBUG RELEASE ) + if (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE ) + # if the generator supports configuration types or CMAKE_BUILD_TYPE + # is set, then set optimized and debug options. + if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) + set( ${basename}_LIBRARY + optimized ${${basename}_LIBRARY_RELEASE} + debug ${${basename}_LIBRARY_DEBUG} ) + set( ${basename}_LIBRARIES + optimized ${${basename}_LIBRARY_RELEASE} + debug ${${basename}_LIBRARY_DEBUG} ) + else( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) + # If there are no configuration types or build type, just use + # the release version + set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) + set( ${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE} ) + endif( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) + endif( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE ) + + set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH + "The ${basename} library" ) + + if( ${basename}_LIBRARY ) + set( ${basename}_FOUND TRUE ) + endif( ${basename}_LIBRARY ) + + mark_as_advanced( ${basename}_LIBRARY + ${basename}_LIBRARY_RELEASE + ${basename}_LIBRARY_DEBUG + ) +endmacro( select_library_configurations ) + diff --git a/build_files/build_environment/patches/cmakelists_glew.txt b/build_files/build_environment/patches/cmakelists_glew.txt new file mode 100644 index 00000000000..ec36d4bde63 --- /dev/null +++ b/build_files/build_environment/patches/cmakelists_glew.txt @@ -0,0 +1,2 @@ +cmake_minimum_required (VERSION 2.4) +add_subdirectory(build/cmake)
\ No newline at end of file diff --git a/build_files/build_environment/patches/cmakelists_hidapi.txt b/build_files/build_environment/patches/cmakelists_hidapi.txt new file mode 100644 index 00000000000..239b9d88b16 --- /dev/null +++ b/build_files/build_environment/patches/cmakelists_hidapi.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.8) +project(hidapi) + +set(SRC_FILES + windows/hid.c +) + +set(HEADER_FILES + hidapi/hidapi.h +) +include_directories(hidapi) +add_definitions(-DHID_API_STATIC) +add_library(hidapi STATIC ${SRC_FILES} ${HEADER_FILES}) + +install(TARGETS hidapi DESTINATION lib) + +INSTALL(FILES hidapi/hidapi.h + DESTINATION "include" + ) + diff --git a/build_files/build_environment/patches/cmakelists_openvdb.txt b/build_files/build_environment/patches/cmakelists_openvdb.txt new file mode 100644 index 00000000000..dd3e9c1a887 --- /dev/null +++ b/build_files/build_environment/patches/cmakelists_openvdb.txt @@ -0,0 +1,398 @@ +# -------------------------------------------------------------------------------- + +cmake_minimum_required(VERSION 2.8) + +# -------------------------------------------------------------------------------- + +project(OpenVDB) + +# -------------------------------------------------------------------------------- + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") + +# -------------------------------------------------------------------------------- + +set(CMAKE_BUILD_TYPE_INIT "Release") + +# -------------------------------------------------------------------------------- +# Options + +option(WITH_BLOSC "Enable Blosc support for compression" OFF) +option(WITH_LOGC4PLUS "Enable logging" OFF) +option(WITH_OPENVDB_2_ABI "Enable building the library to be compability with the OpenVDB 2 ABI" OFF) +option(WITH_PRINTER "Enable building the OpenVDB print executable" OFF) +option(WITH_PYTHON "Enable building the OpenVDB python API" OFF) +option(WITH_RENDERER "Enable building the OpenVDB render executable" OFF) +option(WITH_UNITTEST "Enable building the unit tests" OFF) +option(WITH_VIEWER "Enable building the OpenVDB viewer executable" OFF) + +# -------------------------------------------------------------------------------- +# Find packages +#set(BOOST_LIBRARIES boost_iostreams boost_system boost_thread) + +find_package(IlmBase) +find_package(OpenEXR) +find_package(TBB) +find_package(Boost) + +if(WITH_BLOSC) + find_package(Blosc) + + if(NOT BLOSC_FOUND) + set(WITH_BLOSC OFF) + endif() +endif() + +# todo +if(WITH_VIEWER) + set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_PATH}) + set(GLFW_LIBRARY_DIRS ${GLFW_LIBRARY_PATH}) +endif() + +if(WITH_LOGC4PLUS) + find_package(LogC4Plus) + + if(NOT LOGC4PLUS_FOUND) + set(WITH_LOGC4PLUS OFF) + endif() +endif() + +# todo +if(WITH_PYTHON) + set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH}) + set(PYTHON_LIBRARY_DIRS ${PYTHON_LIBRARY_PATH}) +endif() + +if(WITH_UNITTEST) + find_package(CppUnit) + + if(NOT CPPUNIT_FOUND) + set(WITH_UNITTEST OFF) + endif() +endif() + +# -------------------------------------------------------------------------------- + +message (STATUS "BOOST_ROOT ${BOOST_ROOT}") +message (STATUS "Boost found ${Boost_FOUND} ") +message (STATUS "Boost version ${Boost_VERSION}") +message (STATUS "Boost include dirs ${Boost_INCLUDE_DIRS}") +message (STATUS "Boost library dirs ${Boost_LIBRARY_DIRS}") +message (STATUS "Boost libraries ${Boost_LIBRARIES}") + +message (STATUS "ILMBase found ${ILMBASE_FOUND} ") +message (STATUS "ILMBase include dir ${ILMBASE_INCLUDE_DIR}") +message (STATUS "ILMBase libraries ${ILMBASE_LIBRARIES}") + +message (STATUS "TBB found ${TBB_FOUND} ") +message (STATUS "TBB include dir ${TBB_INCLUDE_DIR}") +message (STATUS "TBB libraries ${TBB_LIBRARIES}") + +if(MSVC) + set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" ) + set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj" ) +endif() + +set(OPENVDB_LIBRARIES ${BLOSC_LIBRARIES} ${BOOST_LIBRARIES} ${OPENEXR_LIBRARIES} ${ILMBASE_LIBRARIES} ${TBB_LIBRARIES} ${ZLIB_LIBRARY} ) + +include_directories(. ${CMAKE_CURRENT_SOURCE_DIR}/../ ${Boost_INCLUDE_DIRS} ${ILMBASE_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR} ${TBB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) +link_directories(${Boost_LIBRARY_DIRS} ${OPENEXR_LIBRARY_DIRS} ${TBB_INCLUDE_DIRS}) +add_definitions(-DNOMINMAX -D__TBB_NO_IMPLICIT_LINKAGE -DOPENVDB_STATICLIB -DOPENVDB_OPENEXR_STATICLIB) + +if(WITH_BLOSC) + add_definitions(-DOPENVDB_USE_BLOSC) + include_directories(${BLOSC_INCLUDE_DIRS}) + link_directories(${BLOSC_LIBRARY_DIRS}) +endif() + +if(WITH_LOGC4PLUS) + add_definitions(-DOPENVDB_USE_LOG4CPLUS) + include_directories(${LOG4CPLUS_INCLUDE_DIRS}) + link_directories(${LOG4CPLUS_LIBRARY_DIRS}) +endif() + +if(WITH_OPENVDB_2_ABI) + add_definitions(-DOPENVDB_2_ABI_COMPATIBLE) +endif() + +# todo +if(WITH_OPENVDB_USE_GLFW_3) + add_definitions(-DOPENVDB_USE_GLFW_3) +endif() + +if(WITH_UNITTEST) + include_directories(${CPPUNIT_INCLUDE_DIRS}) + link_directories(${CPPUNIT_LIBRARY_DIRS}) +endif() + +# -------------------------------------------------------------------------------- + +set(SRC_FILES + openvdb/openvdb.cc + openvdb/io/Compression.cc + openvdb/io/File.cc + openvdb/io/Queue.cc + openvdb/io/Stream.cc + openvdb/io/TempFile.cc + openvdb/io/GridDescriptor.cc + openvdb/io/Archive.cc + openvdb/metadata/MetaMap.cc + openvdb/metadata/Metadata.cc + openvdb/math/Maps.cc + openvdb/math/Transform.cc + openvdb/math/QuantizedUnitVec.cc + openvdb/math/Proximity.cc + openvdb/Grid.cc + openvdb/util/Formats.cc + openvdb/util/Util.cc +) + +set(HEADER_FILES + openvdb/openvdb.h + openvdb/version.h + openvdb/PlatformConfig.h + openvdb/Metadata.h + openvdb/Exceptions.h + openvdb/Grid.h + openvdb/Types.h + openvdb/Platform.h + openvdb/tree/ValueAccessor.h + openvdb/tree/NodeUnion.h + openvdb/tree/Tree.h + openvdb/tree/Iterator.h + openvdb/tree/LeafNodeBool.h + openvdb/tree/TreeIterator.h + openvdb/tree/LeafNode.h + openvdb/tree/NodeManager.h + openvdb/tree/LeafManager.h + openvdb/tree/InternalNode.h + openvdb/tree/RootNode.h + openvdb/tools/PointScatter.h + openvdb/tools/VolumeAdvect.h + openvdb/tools/LevelSetTracker.h + openvdb/tools/Composite.h + openvdb/tools/Morphology.h + openvdb/tools/ValueTransformer.h + openvdb/tools/ChangeBackground.h + openvdb/tools/GridTransformer.h + openvdb/tools/Prune.h + openvdb/tools/LevelSetUtil.h + openvdb/tools/VolumeToSpheres.h + openvdb/tools/LevelSetAdvect.h + openvdb/tools/Statistics.h + openvdb/tools/LevelSetMeasure.h + openvdb/tools/VectorTransformer.h + openvdb/tools/RayIntersector.h + openvdb/tools/PointPartitioner.h + openvdb/tools/Interpolation.h + openvdb/tools/VelocityFields.h + openvdb/tools/PointIndexGrid.h + openvdb/tools/LevelSetRebuild.h + openvdb/tools/Clip.h + openvdb/tools/SignedFloodFill.h + openvdb/tools/MeshToVolume.h + openvdb/tools/Dense.h + openvdb/tools/Filter.h + openvdb/tools/RayTracer.h + openvdb/tools/Diagnostics.h + openvdb/tools/VolumeToMesh.h + openvdb/tools/PoissonSolver.h + openvdb/tools/LevelSetFracture.h + openvdb/tools/GridOperators.h + openvdb/tools/DenseSparseTools.h + openvdb/tools/ParticlesToLevelSet.h + openvdb/tools/LevelSetSphere.h + openvdb/tools/LevelSetMorph.h + openvdb/tools/LevelSetFilter.h + openvdb/tools/PointAdvect.h + openvdb/io/Queue.h + openvdb/io/TempFile.h + openvdb/io/Stream.h + openvdb/io/GridDescriptor.h + openvdb/io/Archive.h + openvdb/io/io.h + openvdb/io/Compression.h + openvdb/io/File.h + openvdb/metadata/StringMetadata.h + openvdb/metadata/MetaMap.h + openvdb/metadata/Metadata.h + openvdb/math/DDA.h + openvdb/math/Vec2.h + openvdb/math/FiniteDifference.h + openvdb/math/Stencils.h + openvdb/math/BBox.h + openvdb/math/Mat3.h + openvdb/math/Mat.h + openvdb/math/Proximity.h + openvdb/math/Ray.h + openvdb/math/ConjGradient.h + openvdb/math/Quat.h + openvdb/math/Vec3.h + openvdb/math/Vec4.h + openvdb/math/QuantizedUnitVec.h + openvdb/math/Coord.h + openvdb/math/Operators.h + openvdb/math/Stats.h + openvdb/math/Math.h + openvdb/math/Tuple.h + openvdb/math/LegacyFrustum.h + openvdb/math/Mat4.h + openvdb/math/Maps.h + openvdb/math/Transform.h + openvdb/util/PagedArray.h + openvdb/util/CpuTimer.h + openvdb/util/Formats.h + openvdb/util/NullInterrupter.h + openvdb/util/Util.h + openvdb/util/Name.h + openvdb/util/MapsUtil.h + openvdb/util/NodeMasks.h + openvdb/util/logging.h +) + +add_library(openvdb STATIC ${SRC_FILES} ${HEADER_FILES}) + +# -------------------------------------------------------------------------------- + +target_link_libraries(openvdb ${OPENVDB_LIBRARIES}) + +set(OPENVDB_VERSION_MAJOR 3) +set(OPENVDB_VERSION_MINOR 1) +set(OPENVDB_VERSION_PATCH 0) +set(OPENVDB_VERSION_STRING ${OPENVDB_VERSION_MAJOR}.${OPENVDB_VERSION_MINOR}.${OPENVDB_VERSION_PATCH}) + +set_target_properties(openvdb PROPERTIES VERSION ${OPENVDB_VERSION_STRING} SOVERSION ${OPENVDB_VERSION_MAJOR}) + +install(TARGETS openvdb DESTINATION lib) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include COMPONENT Development FILES_MATCHING PATTERN "*.h" + PATTERN ".git" EXCLUDE PATTERN "build" EXCLUDE PATTERN "cmake" EXCLUDE) + +# -------------------------------------------------------------------------------- + +if(WITH_PRINTER) + set(PRINT_SRC + openvdb/cmd/openvdb_print/main.cc + ) + + add_executable(vdb_print ${PRINT_SRC}) + target_link_libraries(vdb_print openvdb) + install(TARGETS vdb_print RUNTIME DESTINATION bin) +endif() + +if(WITH_RENDER) + set(RENDER_SRC + openvdb/cmd/openvdb_render/main.cc + ) + + add_executable(vdb_render ${RENDER_SRC}) + target_link_libraries(vdb_render openvdb) + install(TARGETS vdb_render RUNTIME DESTINATION bin) +endif() + +# todo +if(WITH_VIEWER) + set(VIEWER_SRC + openvdb/viewer/Camera.cc + openvdb/viewer/ClipBox.cc + openvdb/viewer/Font.cc + openvdb/viewer/RenderModules.cc + openvdb/viewer/Viewer.cc + + openvdb/viewer/Camera.h + openvdb/viewer/ClipBox.h + openvdb/viewer/Font.h + openvdb/viewer/RenderModules.h + openvdb/viewer/Viewer.h + openvdb/cmd/openvdb_viewer/main.cc + ) + + include_directories(${GLFW_INCLUDE_DIRS}) + link_directories(${GLFW_LIBRARY_DIRS}) + + add_executable(vdb_viewer ${VIEWER_SRC}) + target_link_libraries(vdb_viewer openvdb) + install(TARGETS vdb_viewer RUNTIME DESTINATION bin) +endif() + +# todo +if(WITH_PYTHON) +# add_library(pyopenvdb SHARED ) +endif() + +set(UNITTEST_SRC + openvdb/unittest/main.cc + openvdb/unittest/TestBBox.cc + openvdb/unittest/TestConjGradient.cc + openvdb/unittest/TestCoord.cc + openvdb/unittest/TestCpt.cc + openvdb/unittest/TestCurl.cc + openvdb/unittest/TestDense.cc + openvdb/unittest/TestDenseSparseTools.cc + openvdb/unittest/TestDiagnostics.cc + openvdb/unittest/TestDivergence.cc + openvdb/unittest/TestDoubleMetadata.cc + openvdb/unittest/TestExceptions.cc + openvdb/unittest/TestFile.cc + openvdb/unittest/TestFloatMetadata.cc + openvdb/unittest/TestGradient.cc + openvdb/unittest/TestGrid.cc + openvdb/unittest/TestGridBbox.cc + openvdb/unittest/TestGridDescriptor.cc + openvdb/unittest/TestGridIO.cc + openvdb/unittest/TestGridTransformer.cc + openvdb/unittest/TestInit.cc + openvdb/unittest/TestInt32Metadata.cc + openvdb/unittest/TestInt64Metadata.cc + openvdb/unittest/TestInternalOrigin.cc + openvdb/unittest/TestLaplacian.cc + openvdb/unittest/TestLeaf.cc + openvdb/unittest/TestLeafBool.cc + openvdb/unittest/TestLeafIO.cc + openvdb/unittest/TestLeafOrigin.cc + openvdb/unittest/TestLevelSetRayIntersector.cc + openvdb/unittest/TestLevelSetUtil.cc + openvdb/unittest/TestLinearInterp.cc + openvdb/unittest/TestMaps.cc + openvdb/unittest/TestMat4Metadata.cc + openvdb/unittest/TestMath.cc + openvdb/unittest/TestMeanCurvature.cc + openvdb/unittest/TestMeshToVolume.cc + openvdb/unittest/TestMetadata.cc + openvdb/unittest/TestMetadataIO.cc + openvdb/unittest/TestMetaMap.cc + openvdb/unittest/TestName.cc + openvdb/unittest/TestNodeIterator.cc + openvdb/unittest/TestNodeMask.cc + openvdb/unittest/TestParticlesToLevelSet.cc + openvdb/unittest/TestPointIndexGrid.cc + openvdb/unittest/TestPointPartitioner.cc + openvdb/unittest/TestPoissonSolver.cc + openvdb/unittest/TestPrePostAPI.cc + openvdb/unittest/TestQuadraticInterp.cc + openvdb/unittest/TestQuantizedUnitVec.cc + openvdb/unittest/TestQuat.cc + openvdb/unittest/TestRay.cc + openvdb/unittest/TestStats.cc + openvdb/unittest/TestStream.cc + openvdb/unittest/TestStringMetadata.cc + openvdb/unittest/TestTools.cc + openvdb/unittest/TestTransform.cc + openvdb/unittest/TestTree.cc + openvdb/unittest/TestTreeCombine.cc + openvdb/unittest/TestTreeGetSetValues.cc + openvdb/unittest/TestTreeIterators.cc + openvdb/unittest/TestTreeVisitor.cc + openvdb/unittest/TestUtil.cc + openvdb/unittest/TestValueAccessor.cc + openvdb/unittest/TestVec2Metadata.cc + openvdb/unittest/TestVec3Metadata.cc + openvdb/unittest/TestVolumeRayIntersector.cc + openvdb/unittest/TestVolumeToMesh.cc +) + +# todo +if(WITH_UNITTEST) + add_executable(test ${UNITTEST_SRC} ${HEADER_FILES}) + target_link_libraries(test openvdb ${CPPUNIT_LIBRARIES}) +endif() diff --git a/build_files/build_environment/patches/cmakelists_tbb.txt b/build_files/build_environment/patches/cmakelists_tbb.txt new file mode 100644 index 00000000000..1be9ca25f6a --- /dev/null +++ b/build_files/build_environment/patches/cmakelists_tbb.txt @@ -0,0 +1,196 @@ +cmake_minimum_required (VERSION 2.8) +project(tbb CXX) + +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" + "MinSizeRel" "RelWithDebInfo") +endif() + +include_directories(include src src/rml/include ) + +option(TBB_BUILD_SHARED "Build TBB shared library" ON) +option(TBB_BUILD_STATIC "Build TBB static library" ON) +option(TBB_BUILD_TBBMALLOC "Build TBB malloc library" ON) +option(TBB_BUILD_TBBMALLOC_PROXY "Build TBB malloc proxy library" ON) + +if(APPLE) + set(CMAKE_MACOSX_RPATH ON) +endif() + +file(GLOB tbb_src "${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/old/*.cpp") +list(APPEND tbb_src ${CMAKE_CURRENT_SOURCE_DIR}/src/rml/client/rml_tbb.cpp) +file(GLOB to_remove "${CMAKE_CURRENT_SOURCE_DIR}/src/old/test*.cpp") +list(REMOVE_ITEM tbb_src ${to_remove}) + +set(tbbmalloc_static_src + src/tbbmalloc/backend.cpp + src/tbbmalloc/large_objects.cpp + src/tbbmalloc/backref.cpp + src/tbbmalloc/tbbmalloc.cpp + src/tbbmalloc/frontend.cpp + src/tbb/itt_notify.cpp) + +set(tbbmalloc_src ${tbbmalloc_static_src}) + +set(tbbmalloc_proxy_src + src/tbbmalloc/proxy.cpp + src/tbbmalloc/tbb_function_replacement.cpp) + +if (NOT APPLE) + add_definitions(-DDO_ITT_NOTIFY) +else() + # Disable annoying "has no symbols" warnings + set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>") + set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>") +endif() + +if (UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DUSE_PTHREAD") + if(NOT CMAKE_CXX_FLAGS MATCHES "-mno-rtm") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mrtm") + endif() + if (APPLE) + set(ARCH_PREFIX "mac") + else() + set(ARCH_PREFIX "lin") + endif() + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ARCH_PREFIX "${ARCH_PREFIX}64") + else() + set(ARCH_PREFIX "${ARCH_PREFIX}32") + endif() + set(ENABLE_RTTI "-frtti -fexceptions ") + set(DISABLE_RTTI "-fno-rtti -fno-exceptions ") +elseif(WIN32) + cmake_minimum_required (VERSION 3.1) + enable_language(ASM_MASM) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS- /Zc:wchar_t /Zc:forScope /DUSE_WINTHREAD") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /D_WIN32_WINNT=0x0600 /volatile:iso") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4800 /wd4146 /wd4244 /wd4018") + + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND tbb_src src/tbb/intel64-masm/atomic_support.asm + src/tbb/intel64-masm/itsx.asm src/tbb/intel64-masm/intel64_misc.asm) + list(APPEND tbbmalloc_src src/tbb/intel64-masm/atomic_support.asm) + set(CMAKE_ASM_MASM_FLAGS "/DEM64T=1") + set(ARCH_PREFIX "win64") + else() + list(APPEND tbb_src src/tbb/ia32-masm/atomic_support.asm + src/tbb/ia32-masm/itsx.asm src/tbb/ia32-masm/lock_byte.asm) + list(APPEND tbbmalloc_src src/tbb/ia32-masm/atomic_support.asm) + set(ARCH_PREFIX "win32") + endif() + set(ENABLE_RTTI "/EHsc /GR ") + set(DISABLE_RTTI "/EHs- /GR- ") +endif() + +# Linker export definitions +if (WIN32) + add_custom_command(OUTPUT tbb.def + COMMAND ${CMAKE_CXX_COMPILER} /TC /EP ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include > tbb.def + MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def + COMMENT "Preprocessing tbb.def" + ) + + add_custom_command(OUTPUT tbbmalloc.def + COMMAND ${CMAKE_CXX_COMPILER} /TC /EP ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include > tbbmalloc.def + MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def + COMMENT "Preprocessing tbbmalloc.def" + ) +else() + add_custom_command(OUTPUT tbb.def + COMMAND ${CMAKE_CXX_COMPILER} -xc++ -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbb.def + MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def + COMMENT "Preprocessing tbb.def" + ) + + add_custom_command(OUTPUT tbbmalloc.def + COMMAND ${CMAKE_CXX_COMPILER} -xc++ -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbbmalloc.def + MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def + COMMENT "Preprocessing tbbmalloc.def" + ) +endif() + +add_custom_target(tbb_def_files DEPENDS tbb.def tbbmalloc.def) + +# TBB library +if (TBB_BUILD_STATIC) + add_library(tbb_static STATIC ${tbb_src}) + set_property(TARGET tbb_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBB_BUILD=1") + set_property(TARGET tbb_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBB_SOURCE_DIRECTLY_INCLUDED=1") + set_property(TARGET tbb_static APPEND_STRING PROPERTY COMPILE_FLAGS ${ENABLE_RTTI}) + install(TARGETS tbb_static ARCHIVE DESTINATION lib) +endif() + +if (TBB_BUILD_SHARED) + add_library(tbb SHARED ${tbb_src}) + set_property(TARGET tbb APPEND PROPERTY COMPILE_DEFINITIONS "__TBB_BUILD=1") + set_property(TARGET tbb APPEND_STRING PROPERTY COMPILE_FLAGS ${ENABLE_RTTI}) + add_dependencies(tbb tbb_def_files) + if (APPLE) + set_property(TARGET tbb APPEND PROPERTY LINK_FLAGS "-Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/tbb.def") + elseif(UNIX) + set_property(TARGET tbb APPEND PROPERTY LINK_FLAGS "-Wl,-version-script,${CMAKE_CURRENT_BINARY_DIR}/tbb.def") + elseif(WIN32) + set_property(TARGET tbb APPEND PROPERTY LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/tbb.def") + endif() + install(TARGETS tbb DESTINATION lib) +endif() + +if(CMAKE_COMPILER_IS_GNUCC) + # Quench a warning on GCC + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/governor.cpp COMPILE_FLAGS "-Wno-missing-field-initializers ") +elseif(MSVC) + # Quench a warning on MSVC + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/scheduler.cpp COMPILE_FLAGS "/wd4458 ") +endif() + +if(TBB_BUILD_TBBMALLOC) + # TBB malloc library + if (TBB_BUILD_STATIC) + add_library(tbbmalloc_static STATIC ${tbbmalloc_static_src}) + set_property(TARGET tbbmalloc_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1") + set_property(TARGET tbbmalloc_static APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI}) + install(TARGETS tbbmalloc_static ARCHIVE DESTINATION lib) + endif() + + if (TBB_BUILD_SHARED) + add_library(tbbmalloc SHARED ${tbbmalloc_src}) + set_property(TARGET tbbmalloc APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1") + set_property(TARGET tbbmalloc APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI}) + add_dependencies(tbbmalloc tbb_def_files) + if (APPLE) + set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "-Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def") + elseif(UNIX) + set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "-Wl,-version-script,${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def") + elseif(WIN32) + set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "/DEF:${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def") + endif() + install(TARGETS tbbmalloc DESTINATION lib) + endif() +endif() + +if(TBB_BUILD_TBBMALLOC_PROXY) + # TBB malloc proxy library + if (TBB_BUILD_STATIC) + add_library(tbbmalloc_proxy_static STATIC ${tbbmalloc_proxy_src}) + set_property(TARGET tbbmalloc_proxy_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1") + set_property(TARGET tbbmalloc_proxy_static APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI}) + link_libraries(tbbmalloc_proxy_static tbbmalloc) + install(TARGETS tbbmalloc_proxy_static ARCHIVE DESTINATION lib) + endif() + + if (TBB_BUILD_SHARED) + add_library(tbbmalloc_proxy SHARED ${tbbmalloc_proxy_src}) + set_property(TARGET tbbmalloc_proxy APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1") + set_property(TARGET tbbmalloc_proxy APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI}) + link_libraries(tbbmalloc_proxy tbbmalloc) + install(TARGETS tbbmalloc_proxy DESTINATION lib) + endif() +endif() + +install(DIRECTORY include/tbb DESTINATION include) diff --git a/build_files/build_environment/patches/cuew.diff b/build_files/build_environment/patches/cuew.diff new file mode 100644 index 00000000000..0363034cd93 --- /dev/null +++ b/build_files/build_environment/patches/cuew.diff @@ -0,0 +1,26 @@ +--- CmakeLists.txt.orig 2015-12-31 03:46:41 -0700 ++++ CMakeLists.txt 2016-04-01 13:28:33 -0600 +@@ -22,3 +22,10 @@ + + add_executable(testcuew cuewTest/cuewTest.c include/cuew.h) + target_link_libraries(testcuew cuew ${CMAKE_DL_LIBS}) ++ ++install(TARGETS cuew ++ LIBRARY DESTINATION lib COMPONENT libraries ++ ARCHIVE DESTINATION lib/static COMPONENT libraries) ++ ++INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/cuew.h ++ DESTINATION include/) +\ No newline at end of file +--- src/cuew.c 2016-04-01 13:41:43 -0600 ++++ src/cuew.c 2016-04-01 13:41:11 -0600 +@@ -15,7 +15,9 @@ + */ + + #ifdef _MSC_VER ++#if _MSC_VER < 1900 + # define snprintf _snprintf ++#endif + # define popen _popen + # define pclose _pclose + # define _CRT_SECURE_NO_WARNINGS diff --git a/build_files/build_environment/patches/distutildebugflags.diff b/build_files/build_environment/patches/distutildebugflags.diff new file mode 100644 index 00000000000..3d6b688bc53 --- /dev/null +++ b/build_files/build_environment/patches/distutildebugflags.diff @@ -0,0 +1,11 @@ +--- _msvccompiler.py.orig 2017-01-17 00:57:48 -0700 ++++ _msvccompiler.py 2017-05-20 09:47:26 -0600 +@@ -237,7 +237,7 @@ + ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib')) + + ldflags_debug = [ +- '/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL' ++ '/nologo', '/INCREMENTAL:NO', '/LTCG' + ] + + self.ldflags_exe = [*ldflags, '/MANIFEST:EMBED,ID=1'] diff --git a/build_files/build_environment/patches/ffmpeg.diff b/build_files/build_environment/patches/ffmpeg.diff new file mode 100644 index 00000000000..75fc6490031 --- /dev/null +++ b/build_files/build_environment/patches/ffmpeg.diff @@ -0,0 +1,32 @@ +--- libavutil/common.h 2016-02-14 19:29:42 -0700 ++++ libavutil/common.h 2016-03-30 09:50:29 -0600 +@@ -99,6 +99,11 @@ + #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) + #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) + ++//msvc helper ++#ifdef _MSC_VER ++#define inline __inline ++#endif ++ + /* misc math functions */ + + #ifdef HAVE_AV_CONFIG_H +--- configure 2016-11-26 03:12:05.000000000 +0100 ++++ configure 2017-04-05 03:24:35.000000000 +0200 +@@ -1899,7 +1899,6 @@ + access + aligned_malloc + arc4random +- clock_gettime + closesocket + CommandLineToArgvW + CoTaskMemFree +@@ -5494,7 +5493,6 @@ + + check_func access + check_func_headers stdlib.h arc4random +-check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; } + check_func fcntl + check_func fork + check_func gethrtime diff --git a/build_files/build_environment/patches/fftw3.diff b/build_files/build_environment/patches/fftw3.diff new file mode 100644 index 00000000000..48d88414045 --- /dev/null +++ b/build_files/build_environment/patches/fftw3.diff @@ -0,0 +1,25 @@ +--- config.h.in 2014-03-04 11:44:58 -0700 ++++ config.h.in 2016-03-30 11:42:49 -0600 +@@ -142,9 +142,6 @@ + /* Define to 1 if you have the `gethrtime' function. */ + #undef HAVE_GETHRTIME + +-/* Define to 1 if you have the `gettimeofday' function. */ +-#undef HAVE_GETTIMEOFDAY +- + /* Define to 1 if hrtime_t is defined in <sys/time.h> */ + #undef HAVE_HRTIME_T + +--- kernel/assert.c 2014-03-04 11:41:03 -0700 ++++ kernel/assert.c 2016-04-01 09:41:05 -0600 +@@ -24,8 +24,10 @@ + + void X(assertion_failed)(const char *s, int line, const char *file) + { ++#if 0 + fflush(stdout); + fprintf(stderr, "fftw: %s:%d: assertion failed: %s\n", file, line, s); ++#endif + #ifdef HAVE_ABORT + abort(); + #else diff --git a/build_files/build_environment/patches/hdf5.diff b/build_files/build_environment/patches/hdf5.diff new file mode 100644 index 00000000000..cb84625810d --- /dev/null +++ b/build_files/build_environment/patches/hdf5.diff @@ -0,0 +1,11 @@ +--- UserMacros.cmake ++++ UserMacros.cmake +@@ -16,6 +16,8 @@ + if (BUILD_USER_DEFINED_LIBS) + MACRO_USER_DEFINED_LIBS () + endif (BUILD_USER_DEFINED_LIBS) ++ ++include(Config/cmake/usermacros/windows_mt.cmake) + #----------------------------------------------------------------------------- + #------------------- E X A M P L E E N D ----------------------------------- + #----------------------------------------------------------------------------- diff --git a/build_files/build_environment/patches/hidapi.diff b/build_files/build_environment/patches/hidapi.diff new file mode 100644 index 00000000000..720a8ae5ae9 --- /dev/null +++ b/build_files/build_environment/patches/hidapi.diff @@ -0,0 +1,15 @@ +--- hidapi/hidapi.h 2011-10-25 20:58:16 -0600 ++++ hidapi/hidapi.h 2016-11-01 12:05:58 -0600 +@@ -30,7 +30,11 @@ + #include <wchar.h> + + #ifdef _WIN32 +- #define HID_API_EXPORT __declspec(dllexport) ++ #ifdef HID_API_STATIC ++ #define HID_API_EXPORT ++ #else ++ #define HID_API_EXPORT __declspec(dllexport) ++ #endif + #define HID_API_CALL + #else + #define HID_API_EXPORT /**< API export macro */ diff --git a/build_files/build_environment/install_deps_patches/llvm.patch b/build_files/build_environment/patches/install_deps_llvm.diff index 968f011e57c..968f011e57c 100644 --- a/build_files/build_environment/install_deps_patches/llvm.patch +++ b/build_files/build_environment/patches/install_deps_llvm.diff diff --git a/build_files/build_environment/install_deps_patches/osl.patch b/build_files/build_environment/patches/install_deps_osl.diff index 3b52403f740..3b52403f740 100644 --- a/build_files/build_environment/install_deps_patches/osl.patch +++ b/build_files/build_environment/patches/install_deps_osl.diff diff --git a/build_files/build_environment/patches/libfaad.diff b/build_files/build_environment/patches/libfaad.diff new file mode 100644 index 00000000000..37605b29cd9 --- /dev/null +++ b/build_files/build_environment/patches/libfaad.diff @@ -0,0 +1,10 @@ +--- frontend/main.c 2008-09-22 11:55:09 -0600 ++++ frontend/main.c 2016-04-06 15:20:36 -0600 +@@ -31,7 +31,6 @@ + #ifdef _WIN32 + #define WIN32_LEAN_AND_MEAN + #include <windows.h> +-#define off_t __int64 + #else + #include <time.h> + #endif diff --git a/build_files/build_environment/patches/llvm-alloca-fix.diff b/build_files/build_environment/patches/llvm-alloca-fix.diff new file mode 100644 index 00000000000..5394a472167 --- /dev/null +++ b/build_files/build_environment/patches/llvm-alloca-fix.diff @@ -0,0 +1,111 @@ +Index: lib/Target/X86/X86ISelLowering.cpp +=================================================================== +--- lib/Target/X86/X86ISelLowering.cpp 2014-04-11 23:04:44.000000000 +0200 ++++ lib/Target/X86/X86ISelLowering.cpp (working copy) +@@ -15493,12 +15493,36 @@ + // non-trivial part is impdef of ESP. + + if (Subtarget->isTargetWin64()) { ++ const char *StackProbeSymbol = ++ Subtarget->isTargetCygMing() ? "___chkstk" : "__chkstk"; ++ ++ MachineInstrBuilder MIB; ++ ++ if (getTargetMachine().getCodeModel() == CodeModel::Large) { ++ // For large code model we need to do indirect call to __chkstk. ++ ++ // R11 will be used to contain the address of __chkstk. ++ // R11 is a volotiale register and assumed to be destoyed by the callee, ++ // so there is no need to save and restore it. ++ BuildMI(*BB, MI, DL, TII->get(X86::MOV64ri), X86::R11) ++ .addExternalSymbol(StackProbeSymbol); ++ // Create a call to __chkstk function which address contained in R11. ++ MIB = BuildMI(*BB, MI, DL, TII->get(X86::CALL64r)) ++ .addReg(X86::R11, RegState::Kill); ++ ++ } else { ++ ++ // For non-large code model we can do direct call to __chkstk. ++ ++ MIB = BuildMI(*BB, MI, DL, TII->get(X86::W64ALLOCA)) ++ .addExternalSymbol(StackProbeSymbol); ++ } ++ + if (Subtarget->isTargetCygMing()) { + // ___chkstk(Mingw64): + // Clobbers R10, R11, RAX and EFLAGS. + // Updates RSP. +- BuildMI(*BB, MI, DL, TII->get(X86::W64ALLOCA)) +- .addExternalSymbol("___chkstk") ++ MIB + .addReg(X86::RAX, RegState::Implicit) + .addReg(X86::RSP, RegState::Implicit) + .addReg(X86::RAX, RegState::Define | RegState::Implicit) +@@ -15507,8 +15531,7 @@ + } else { + // __chkstk(MSVCRT): does not update stack pointer. + // Clobbers R10, R11 and EFLAGS. +- BuildMI(*BB, MI, DL, TII->get(X86::W64ALLOCA)) +- .addExternalSymbol("__chkstk") ++ MIB + .addReg(X86::RAX, RegState::Implicit) + .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit); + // RAX has the offset to be subtracted from RSP. +Index: lib/Target/X86/X86FrameLowering.cpp +=================================================================== +--- lib/Target/X86/X86FrameLowering.cpp 2013-10-24 01:37:01.000000000 +0200 ++++ lib/Target/X86/X86FrameLowering.cpp (working copy) +@@ -635,25 +635,49 @@ + .addReg(X86::EAX, RegState::Kill) + .setMIFlag(MachineInstr::FrameSetup); + } ++ ++ MachineInstrBuilder MIB; + + if (Is64Bit) { ++ + // Handle the 64-bit Windows ABI case where we need to call __chkstk. + // Function prologue is responsible for adjusting the stack pointer. + BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64ri), X86::RAX) + .addImm(NumBytes) + .setMIFlag(MachineInstr::FrameSetup); ++ ++ if (TM.getCodeModel() == CodeModel::Large) { ++ // For large code model we need to do indirect call to __chkstk. ++ ++ ++ // R11 will be used to contain the address of __chkstk. ++ // R11 is a volotiale register and assumed to be destoyed by the callee, ++ // so there is no need to save and restore it. ++ BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64ri), X86::R11) ++ .addExternalSymbol(StackProbeSymbol); ++ // Create a call to __chkstk function which address contained in R11. ++ MIB = BuildMI(MBB, MBBI, DL, TII.get(X86::CALL64r)) ++ .addReg(X86::R11, RegState::Kill); ++ } else { ++ ++ // For non-large code model we can do direct call to __chkstk. ++ ++ MIB = BuildMI(MBB, MBBI, DL, TII.get(X86::W64ALLOCA)) ++ .addExternalSymbol(StackProbeSymbol); ++ } + } else { + // Allocate NumBytes-4 bytes on stack in case of isEAXAlive. + // We'll also use 4 already allocated bytes for EAX. + BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), X86::EAX) + .addImm(isEAXAlive ? NumBytes - 4 : NumBytes) + .setMIFlag(MachineInstr::FrameSetup); ++ ++ MIB = BuildMI(MBB, MBBI, DL, TII.get(X86::CALLpcrel32)) ++ .addExternalSymbol(StackProbeSymbol); + } + +- BuildMI(MBB, MBBI, DL, +- TII.get(Is64Bit ? X86::W64ALLOCA : X86::CALLpcrel32)) +- .addExternalSymbol(StackProbeSymbol) +- .addReg(StackPtr, RegState::Define | RegState::Implicit) ++ ++ MIB.addReg(StackPtr, RegState::Define | RegState::Implicit) + .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit) + .setMIFlag(MachineInstr::FrameSetup); + diff --git a/build_files/build_environment/patches/ming32sh.cmd b/build_files/build_environment/patches/ming32sh.cmd new file mode 100644 index 00000000000..3259d9d3714 --- /dev/null +++ b/build_files/build_environment/patches/ming32sh.cmd @@ -0,0 +1,7 @@ +@title MinGW-w64 32-bit GCC build environment + +@echo Setting up environment for MinGW-w64 GCC 32-bit... + +@set PATH=%CD%\bin;%CD%\msys\1.0\bin;%cd%\..\..\perl32\site\bin;%cd%\..\..\perl32\bin;%cd%\..\..\c\bin;%PATH% + + diff --git a/build_files/build_environment/patches/ming64sh.cmd b/build_files/build_environment/patches/ming64sh.cmd new file mode 100644 index 00000000000..18fea3829f3 --- /dev/null +++ b/build_files/build_environment/patches/ming64sh.cmd @@ -0,0 +1,7 @@ +@title MinGW-w64 64-bit GCC build environment + +@echo Setting up environment for MinGW-w64 GCC 64-bit... + +@set PATH=%CD%\bin;%CD%\msys\1.0\bin;%cd%\..\..\perl\site\bin;%cd%\..\..\perl\bin;%cd%\..\..\c\bin;%PATH% + + diff --git a/build_files/build_environment/patches/numpy.diff b/build_files/build_environment/patches/numpy.diff new file mode 100644 index 00000000000..c4c57222838 --- /dev/null +++ b/build_files/build_environment/patches/numpy.diff @@ -0,0 +1,23 @@ +diff -Naur numpy-1.11.1/numpy/distutils/ccompiler.py numpy-1.11.1/numpy/distutils/ccompiler.py +--- numpy-1.11.1/numpy/distutils/ccompiler.py 2016-06-25 08:38:34 -0600 ++++ numpy-1.11.1/numpy/distutils/ccompiler.py 2016-08-04 12:33:43 -0600 +@@ -29,6 +29,7 @@ + + # Using customized CCompiler.spawn. + def CCompiler_spawn(self, cmd, display=None): ++ cmd = quote_args(cmd) + """ + Execute a command in a sub-process. + +diff -Naur numpy-1.11.1/numpy/distutils/misc_util.py numpy-1.11.1/numpy/distutils/misc_util.py +--- numpy-1.11.1/numpy/distutils/misc_util.py 2016-06-25 08:38:34 -0600 ++++ numpy-1.11.1/numpy/distutils/misc_util.py 2016-08-04 12:34:56 -0600 +@@ -116,7 +116,7 @@ + args = list(args) + for i in range(len(args)): + a = args[i] +- if ' ' in a and a[0] not in '"\'': ++ if ' ' in a and a[0] not in '"\'' and a[len(a)-1] not in '"\'': + args[i] = '"%s"' % (a) + return args + diff --git a/build_files/build_environment/patches/opencollada.diff b/build_files/build_environment/patches/opencollada.diff new file mode 100644 index 00000000000..0c91b4151fe --- /dev/null +++ b/build_files/build_environment/patches/opencollada.diff @@ -0,0 +1,32 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3fc9be5..5112ce6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -254,11 +254,11 @@ + endif()
+
+ #adding PCRE
+-find_package(PCRE)
++#find_package(PCRE)
+ if (PCRE_FOUND)
+ message(STATUS "SUCCESSFUL: PCRE found")
+ else () # if pcre not found building its local copy from ./Externals
+- if (WIN32 OR APPLE)
++ if (1)
+ message("WARNING: Native PCRE not found, taking PCRE from ./Externals")
+ add_definitions(-DPCRE_STATIC)
+ add_subdirectory(${EXTERNAL_LIBRARIES}/pcre)
+diff --git a/DAEValidator/library/include/no_warning_begin.orig b/DAEValidator/library/include/no_warning_begin +index 3fc9be5..5112ce6 100644 +--- a/DAEValidator/library/include/no_warning_begin.orig 2017-05-31 16:56:39 -0600 ++++ b/DAEValidator/library/include/no_warning_begin 2017-06-07 10:18:45 -0600 +@@ -2,6 +2,9 @@ + #if defined(_WIN32) + # pragma warning(push) + # pragma warning(disable:4668) ++# if _MSC_VER >=1900 ++# pragma warning(disable:5031) ++# endif + # if defined(_MSC_VER) && defined(_DEBUG) + # pragma warning(disable:4548) + # endif diff --git a/build_files/build_environment/patches/opencolorio.diff b/build_files/build_environment/patches/opencolorio.diff new file mode 100644 index 00000000000..4e947d89097 --- /dev/null +++ b/build_files/build_environment/patches/opencolorio.diff @@ -0,0 +1,21 @@ +diff -ru ./CMakeLists.txt ./CMakeLists.txt +--- ./CMakeLists.txt 2014-09-11 21:08:18.000000000 +0200 ++++ ./CMakeLists.txt 2016-05-15 17:17:01.000000000 +0200 +@@ -186,7 +186,7 @@ + PATCH_COMMAND patch -f -p1 < ${CMAKE_SOURCE_DIR}/ext/tinyxml_${TINYXML_VERSION}.patch + BINARY_DIR ext/build/tinyxml + INSTALL_DIR ext/dist +- CMAKE_ARGS ${TINYXML_CMAKE_ARGS} ++ CMAKE_ARGS ${TINYXML_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} + ) + if(WIN32) + set(TINYXML_STATIC_LIBRARIES ${PROJECT_BINARY_DIR}/ext/dist/lib/tinyxml.lib) +@@ -254,7 +254,7 @@ + BINARY_DIR ext/build/yaml-cpp + PATCH_COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/ext/yaml-cpp-${YAML_CPP_VERSION}.patch + INSTALL_DIR ext/dist +- CMAKE_ARGS ${YAML_CPP_CMAKE_ARGS} ++ CMAKE_ARGS ${YAML_CPP_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT} -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} + ) + set(YAML_CPP_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ext/dist/include) + set(YAML_CPP_LIBRARY_DIRS ${PROJECT_BINARY_DIR}/ext/dist/lib) diff --git a/build_files/build_environment/patches/openexr.diff b/build_files/build_environment/patches/openexr.diff new file mode 100644 index 00000000000..ec18751fe74 --- /dev/null +++ b/build_files/build_environment/patches/openexr.diff @@ -0,0 +1,33 @@ +--- IlmImf/CMakeLists.txt 2014-08-10 06:23:56.000000000 +0200 ++++ IlmImf/CMakeLists.txt 2017-01-08 04:06:04.931723800 +0100 +@@ -8,8 +8,8 @@ + + TARGET_LINK_LIBRARIES ( b44ExpLogTable + Half +- Iex${ILMBASE_LIBSUFFIX} + IlmThread${ILMBASE_LIBSUFFIX} ++ Iex${ILMBASE_LIBSUFFIX} + ${PTHREAD_LIB} + ) + +@@ -25,8 +25,8 @@ + + TARGET_LINK_LIBRARIES ( dwaLookups + Half +- Iex${ILMBASE_LIBSUFFIX} + IlmThread${ILMBASE_LIBSUFFIX} ++ Iex${ILMBASE_LIBSUFFIX} + ${PTHREAD_LIB} + ) + +@@ -138,9 +138,9 @@ + + TARGET_LINK_LIBRARIES ( IlmImf + Half +- Iex${ILMBASE_LIBSUFFIX} + Imath${ILMBASE_LIBSUFFIX} + IlmThread${ILMBASE_LIBSUFFIX} ++ Iex${ILMBASE_LIBSUFFIX} + ${PTHREAD_LIB} ${ZLIB_LIBRARIES} + ) + diff --git a/build_files/build_environment/patches/openimageio_gdi.diff b/build_files/build_environment/patches/openimageio_gdi.diff new file mode 100644 index 00000000000..af0c90638de --- /dev/null +++ b/build_files/build_environment/patches/openimageio_gdi.diff @@ -0,0 +1,26 @@ +Index: OpenImageIO/osdep.h +=================================================================== +--- OpenImageIO/osdep.h (revision 61595) ++++ OpenImageIO/osdep.h (working copy) +@@ -34,6 +34,7 @@ + # define WIN32_LEAN_AND_MEAN + # define VC_EXTRALEAN + # define NOMINMAX ++# define NOGDI + # include <windows.h> + #endif + +Index: OpenImageIO/platform.h +=================================================================== +--- OpenImageIO/platform.h (revision 61595) ++++ OpenImageIO/platform.h (working copy) +@@ -77,6 +77,9 @@ + # ifndef NOMINMAX + # define NOMINMAX + # endif ++# ifndef NOGDI ++# define NOGDI ++# endif + # include <windows.h> + #endif + diff --git a/build_files/build_environment/patches/openimageio_idiff.diff b/build_files/build_environment/patches/openimageio_idiff.diff new file mode 100644 index 00000000000..ae1884f76b5 --- /dev/null +++ b/build_files/build_environment/patches/openimageio_idiff.diff @@ -0,0 +1,13 @@ +--- idiff.cpp 2016-11-18 11:42:01 -0700 ++++ idiff.cpp 2016-11-18 11:41:25 -0700 +@@ -308,8 +308,10 @@ + // printed with three digit exponent. We change this behaviour to fit + // Linux way + #ifdef _MSC_VER ++#if _MSC_VER < 1900 + _set_output_format(_TWO_DIGIT_EXPONENT); + #endif ++#endif + std::streamsize precis = std::cout.precision(); + std::cout << " " << cr.nwarn << " pixels (" + << std::setprecision(3) << (100.0*cr.nwarn / npels) diff --git a/build_files/build_environment/patches/openimageio_staticexr.diff b/build_files/build_environment/patches/openimageio_staticexr.diff new file mode 100644 index 00000000000..7e4eee04548 --- /dev/null +++ b/build_files/build_environment/patches/openimageio_staticexr.diff @@ -0,0 +1,10 @@ +--- CMakeLists.txt 2016-11-01 01:03:44 -0600 ++++ CMakeLists.txt 2016-12-01 09:20:12 -0700 +@@ -454,7 +454,6 @@ + add_definitions (-D_CRT_NONSTDC_NO_WARNINGS) + add_definitions (-D_SCL_SECURE_NO_WARNINGS) + add_definitions (-DJAS_WIN_MSVC_BUILD) +- add_definitions (-DOPENEXR_DLL) + if (LINKSTATIC) + add_definitions (-DBoost_USE_STATIC_LIBS=1) + else () diff --git a/build_files/build_environment/patches/opensubdiv.diff b/build_files/build_environment/patches/opensubdiv.diff new file mode 100644 index 00000000000..9e9cf7ad554 --- /dev/null +++ b/build_files/build_environment/patches/opensubdiv.diff @@ -0,0 +1,16 @@ + opensubdiv/osd/d3d11VertexBuffer.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/opensubdiv/osd/d3d11VertexBuffer.cpp b/opensubdiv/osd/d3d11VertexBuffer.cpp +index 603cbf4..07e7e0a 100644 +--- a/opensubdiv/osd/d3d11VertexBuffer.cpp ++++ b/opensubdiv/osd/d3d11VertexBuffer.cpp +@@ -81,7 +81,7 @@ D3D11VertexBuffer::UpdateData(const float *src, int startVertex, int numVertices + + deviceContext->Unmap(_uploadBuffer, 0); + +- D3D11_BOX srcBox = { 0, 0, 0, size, 1, 1 }; ++ D3D11_BOX srcBox = { 0, 0, 0, (UINT) size, 1, 1 }; + deviceContext->CopySubresourceRegion(_buffer, 0, 0, 0, 0, + _uploadBuffer, 0, &srcBox); + } diff --git a/build_files/build_environment/patches/openvdb.diff b/build_files/build_environment/patches/openvdb.diff new file mode 100644 index 00000000000..f3afa13ea17 --- /dev/null +++ b/build_files/build_environment/patches/openvdb.diff @@ -0,0 +1,11 @@ +diff -Naur k:\BlenderDev\lib\win64_vc12_Harvest\openVDB\/include/openvdb/math/Coord.h .\openVDB/include/openvdb/math/Coord.h +--- k:\BlenderDev\lib\win64_vc12_Harvest\openVDB\/include/openvdb/math/Coord.h 2016-03-30 15:09:49 -0600 ++++ .\openVDB/include/openvdb/math/Coord.h 2016-04-01 06:53:47 -0600 +@@ -34,6 +34,7 @@ + #include <openvdb/Platform.h> + #include "Math.h" + #include "Vec3.h" ++#define NOMINMAX + + namespace tbb { class split; } // forward declaration + diff --git a/build_files/build_environment/patches/openvdb_vc2013.diff b/build_files/build_environment/patches/openvdb_vc2013.diff new file mode 100644 index 00000000000..7dc3e476297 --- /dev/null +++ b/build_files/build_environment/patches/openvdb_vc2013.diff @@ -0,0 +1,35 @@ +--- openvdb/tree/LeafNode.h 2015-10-01 15:55:33 -0600 ++++ openvdb/tree/LeafNode.h 2016-03-26 13:12:22 -0600 +@@ -70,13 +70,14 @@ + typedef boost::shared_ptr<LeafNode> Ptr; + typedef util::NodeMask<Log2Dim> NodeMaskType; + +- static const Index +- LOG2DIM = Log2Dim, // needed by parent nodes +- TOTAL = Log2Dim, // needed by parent nodes +- DIM = 1 << TOTAL, // dimension along one coordinate direction +- NUM_VALUES = 1 << 3 * Log2Dim, +- NUM_VOXELS = NUM_VALUES, // total number of voxels represented by this node +- SIZE = NUM_VALUES, ++ static const Index ++ LOG2DIM = Log2Dim, // needed by parent nodes ++ TOTAL = Log2Dim, // needed by parent nodes ++ DIM = 1 << TOTAL, // dimension along one coordinate direction ++ NUM_VALUES = 1 << 3 * Log2Dim, ++ NUM_VOXELS = NUM_VALUES; // total number of voxels represented by this node ++ static const Index ++ SIZE = NUM_VALUES, + LEVEL = 0; // level 0 = leaf + + /// @brief ValueConverter<T>::Type is the type of a LeafNode having the same +--- openvdb/PlatformConfig.h 2016-03-30 15:09:49 -0600 ++++ openvdb/PlatformConfig.h 2016-04-01 07:00:38 -0600 +@@ -47,7 +47,7 @@ + #if !defined(OPENVDB_OPENEXR_STATICLIB) && !defined(OPENEXR_DLL) + #define OPENEXR_DLL + #endif +- ++ #define NOMINMAX + #endif // _WIN32 + + #endif // OPENVDB_PLATFORMCONFIG_HAS_BEEN_INCLUDED diff --git a/build_files/build_environment/patches/osl.diff b/build_files/build_environment/patches/osl.diff new file mode 100644 index 00000000000..fcb5ec4165f --- /dev/null +++ b/build_files/build_environment/patches/osl.diff @@ -0,0 +1,12 @@ +diff -Naur osl/src/external_osl/src/cmake/flexbison.cmake osl_bak/src/external_osl/src/cmake/flexbison.cmake +--- osl/src/external_osl//src/cmake/flexbison.cmake 2016-01-29 11:15:22 -0700 ++++ osl_bak/src/external_osl/src/cmake/flexbison.cmake 2016-02-29 21:26:26 -0700 +@@ -77,7 +77,7 @@ + DEPENDS ${${compiler_headers}} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) + ADD_CUSTOM_COMMAND ( OUTPUT ${flexoutputcxx} +- COMMAND ${FLEX_EXECUTABLE} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}" ++ COMMAND ${FLEX_EXECUTABLE} ${FLEX_EXTRA_OPTIONS} -o ${flexoutputcxx} "${CMAKE_CURRENT_SOURCE_DIR}/${flexsrc}" + MAIN_DEPENDENCY ${flexsrc} + DEPENDS ${${compiler_headers}} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/build_files/build_environment/patches/osl_simd_oiio.diff b/build_files/build_environment/patches/osl_simd_oiio.diff new file mode 100644 index 00000000000..5062a597167 --- /dev/null +++ b/build_files/build_environment/patches/osl_simd_oiio.diff @@ -0,0 +1,14 @@ +--- CMakeLists.txt 2016-10-31 16:48:19 -0600 ++++ CMakeLists.txt 2017-04-10 10:38:48 -0600 +@@ -269,6 +269,11 @@ + add_definitions ("-DOIIO_STATIC_BUILD=1") + endif () + ++set (OIIO_NOSIMD OFF CACHE BOOL "Disable simd support in oiio") ++if (OIIO_NOSIMD) ++ add_definitions ("-DOIIO_NO_SSE=1") ++endif () ++ + if (OSL_NO_DEFAULT_TEXTURESYSTEM) + add_definitions ("-DOSL_NO_DEFAULT_TEXTURESYSTEM=1") + endif () diff --git a/build_files/build_environment/patches/pthreads.diff b/build_files/build_environment/patches/pthreads.diff new file mode 100644 index 00000000000..bbabfdc8925 --- /dev/null +++ b/build_files/build_environment/patches/pthreads.diff @@ -0,0 +1,13 @@ +--- pthread.h.orig 2012-05-26 22:16:45 -0600 ++++ pthread.h 2016-04-01 09:20:36 -0600 +@@ -109,6 +109,10 @@ + /* Include everything */ + #endif + ++#if _MSC_VER >= 1900 ++# define HAVE_STRUCT_TIMESPEC 1 ++#endif ++ + #if defined(_UWIN) + # define HAVE_STRUCT_TIMESPEC 1 + # define HAVE_SIGNAL_H 1 diff --git a/build_files/build_environment/patches/pyshell.diff b/build_files/build_environment/patches/pyshell.diff new file mode 100644 index 00000000000..7ccffe4c040 --- /dev/null +++ b/build_files/build_environment/patches/pyshell.diff @@ -0,0 +1,12 @@ +--- pyshellext.cpp.orig 2017-01-17 00:57:53 -0700 ++++ pyshellext.cpp 2017-05-20 15:21:51 -0600 +@@ -13,6 +13,9 @@ + #include <strsafe.h> + + #include "pyshellext_h.h" ++#if _MSC_VER < 1900 ++#include "pyshellext_i.c" ++#endif + + #define DDWM_UPDATEWINDOW (WM_USER+3) + diff --git a/build_files/build_environment/patches/python.diff b/build_files/build_environment/patches/python.diff new file mode 100644 index 00000000000..749a51d6972 --- /dev/null +++ b/build_files/build_environment/patches/python.diff @@ -0,0 +1,40 @@ +--- pcbuild/build.bat 2016-05-21 09:53:55 -0600 ++++ pcbuild/build.bat 2016-05-21 09:56:16 -0600 +@@ -59,6 +59,7 @@ + if "%~1"=="-h" goto Usage + if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts + if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts ++if "%~1"=="-k" (set vs_toolset=%2) & shift & shift & goto CheckOpts + if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts + if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts + if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts +@@ -126,7 +126,7 @@ + + :Kill + echo on +-msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^ ++msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose% /p:PlatformToolset=%vs_toolset%^ + /p:Configuration=%conf% /p:Platform=%platf%^ + /p:KillPython=true + +@@ -95,7 +96,7 @@ + rem batch is, shall we say, "lackluster" + echo on + msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^ +- /p:Configuration=%conf% /p:Platform=%platf%^ ++ /p:Configuration=%conf% /p:Platform=%platf% /p:PlatformToolset=%vs_toolset%^ + /p:IncludeExternals=%IncludeExternals%^ + /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^ + /p:UseTestMarker=%UseTestMarker%^ + +--- pcbuild/sqlite3.vcxproj 2015-12-06 18:39:10 -0700 ++++ pcbuild/sqlite3.vcxproj 2016-11-02 09:25:56 -0600 +@@ -43,7 +43,7 @@ + <Import Project="python.props" /> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Label="Configuration"> +- <ConfigurationType>DynamicLibrary</ConfigurationType> ++ <ConfigurationType>StaticLibrary</ConfigurationType> + <CharacterSet>NotSet</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> diff --git a/build_files/build_environment/patches/python_apple.diff b/build_files/build_environment/patches/python_apple.diff new file mode 100644 index 00000000000..0ca7a8d8f04 --- /dev/null +++ b/build_files/build_environment/patches/python_apple.diff @@ -0,0 +1,48 @@ +--- Modules/expat/expat_external.h 2016-12-17 06:51:30 -0500 ++++ Modules/expat/expat_external.h 2016-12-17 06:55:29 -0500 +@@ -7,9 +7,17 @@ + + /* External API definitions */ + +-/* Namespace external symbols to allow multiple libexpat version to +- co-exist. */ +-#include "pyexpatns.h" ++/* ++ ++ HACK: Fix build breakage on MacOS: ++ *** WARNING: renaming "pyexpat" since importing it failed: dlopen(build/lib.macosx-10.6-i386-3.3/pyexpat.so, 2): Symbol not found: _XML_ErrorString ++ This reverts c242a8f30806 from the python hg repo: ++ restore namespacing of pyexpat symbols (closes #19186) ++ See http://bugs.python.org/issue19186#msg214069 ++ The recommendation to include Modules/inc at first broke the Linux build... ++ So do it this way, as it was before. Needs some realignment later. ++ ++*/ + + #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) + #define XML_USE_MSC_EXTENSIONS 1 +--- pyconfig.h.in 2017-04-05 02:47:52.000000000 +0200 ++++ pyconfig.h.in 2017-04-05 02:51:33.000000000 +0200 +@@ -119,12 +119,6 @@ + /* Define to 1 if you have the `clock' function. */ + #undef HAVE_CLOCK + +-/* Define to 1 if you have the `clock_getres' function. */ +-#undef HAVE_CLOCK_GETRES +- +-/* Define to 1 if you have the `clock_gettime' function. */ +-#undef HAVE_CLOCK_GETTIME +- + /* Define if the C compiler supports computed gotos. */ + #undef HAVE_COMPUTED_GOTOS + +@@ -338,9 +332,6 @@ + /* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ + #undef HAVE_GETC_UNLOCKED + +-/* Define to 1 if you have the `getentropy' function. */ +-#undef HAVE_GETENTROPY +- + /* Define to 1 if you have the `getgrouplist' function. */ + #undef HAVE_GETGROUPLIST + diff --git a/build_files/build_environment/patches/python_runtime_vc2013.diff b/build_files/build_environment/patches/python_runtime_vc2013.diff new file mode 100644 index 00000000000..8177f735c92 --- /dev/null +++ b/build_files/build_environment/patches/python_runtime_vc2013.diff @@ -0,0 +1,13 @@ +--- _msvccompiler.py 2016-08-12 10:44:32 -0600 ++++ _msvccompiler.py 2016-08-12 10:47:29 -0600 +@@ -246,8 +246,8 @@ + ldflags = [ + '/nologo', '/INCREMENTAL:NO', '/LTCG' + ] +- if not self._vcruntime_redist: +- ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib')) ++ #if not self._vcruntime_redist: ++ # ldflags.extend(('/nodefaultlib:libucrt.lib', 'ucrt.lib')) + + ldflags_debug = [ + '/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL' diff --git a/build_files/build_environment/patches/schroedinger.diff b/build_files/build_environment/patches/schroedinger.diff new file mode 100644 index 00000000000..6acb35f2a7b --- /dev/null +++ b/build_files/build_environment/patches/schroedinger.diff @@ -0,0 +1,54 @@ +--- configure.orig 2012-01-22 19:06:43 -0700 ++++ configure 2016-04-06 20:00:50 -0600 +@@ -16492,10 +16492,10 @@ + HAVE_ORC=yes + fi + if test "x${HAVE_ORC}" != xyes ; then +- as_fn_error $? "orc-0.4 >= $ORC_VER is required" "$LINENO" 5 ++ $as_echo "orc-0.4 >= $ORC_VER is required" + fi + SCHRO_PKG_DEPS="$SCHRO_PKG_DEPS orc-0.4 >= $ORC_VER" +-ORCC=`$PKG_CONFIG --variable=orcc orc-0.4` ++#ORCC=`$PKG_CONFIG --variable=orcc orc-0.4` + + if test "x$cross_compiling" != xyes; then + HAVE_ORCC_TRUE= +--- Makefile.in 2012-01-22 18:06:42 -0700 ++++ Makefile.in 2016-04-06 20:30:09 -0600 +@@ -291,7 +291,7 @@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + AUTOMAKE_OPTIONS = foreign +-SUBDIRS = schroedinger doc tools testsuite ++SUBDIRS = schroedinger doc tools + DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc + DIST_SUBDIRS = schroedinger doc tools testsuite + EXTRA_DIST = COPYING COPYING.GPL COPYING.LGPL COPYING.MIT COPYING.MPL \ + +--- schroedinger.pc.in 2011-03-21 17:08:39 -0600 ++++ schroedinger.pc.in 2016-04-08 13:30:42 -0600 +@@ -7,9 +7,9 @@ + + Name: schroedinger-@SCHRO_MAJORMINOR@ + Description: Dirac codec library +-Requires.private: @SCHRO_PKG_DEPS@ ++Requires: @SCHRO_PKG_DEPS@ + Version: @VERSION@ +-Libs: -L${libdir} -lschroedinger-@SCHRO_MAJORMINOR@ ++Libs: -L${libdir} -lschroedinger-@SCHRO_MAJORMINOR@ -lorc-0.4 + Libs.private: @PTHREAD_LIBS@ @LIBM@ + Cflags: -I${includedir} + +--- ./schroedinger/schrodecoder.c 2012-01-23 00:38:57.000000000 +0100 ++++ ./schroedinger/schrodecoder.c 2016-05-15 06:07:24.000000000 +0200 +@@ -70,8 +70,8 @@ + }; + + +-int _schro_decode_prediction_only; +-int _schro_telemetry; ++int _schro_decode_prediction_only = 0; ++int _schro_telemetry = 0; + + static void schro_decoder_x_decode_motion (SchroAsyncStage * stage); + static void schro_decoder_x_render_motion (SchroAsyncStage * stage); diff --git a/build_files/build_environment/patches/sdl.diff b/build_files/build_environment/patches/sdl.diff new file mode 100644 index 00000000000..b309d0230f3 --- /dev/null +++ b/build_files/build_environment/patches/sdl.diff @@ -0,0 +1,50 @@ +diff -ru /Users/brecht/dev/lib/deps/Downloads/SDL2-2.0.4/src/video/SDL_video.c ./src/video/SDL_video.c +--- /Users/brecht/dev/lib/deps/Downloads/SDL2-2.0.4/src/video/SDL_video.c 2016-01-02 20:56:31.000000000 +0100 ++++ ./src/video/SDL_video.c 2016-05-15 02:58:27.000000000 +0200 +@@ -137,7 +137,7 @@ + + #define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN) + +-#ifdef __MACOSX__ ++#if SDL_VIDEO_DRIVER_COCOA + /* Support for Mac OS X fullscreen spaces */ + extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window); + extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state); +@@ -1141,7 +1141,7 @@ + if ( window->is_hiding && fullscreen ) + return 0; + +-#ifdef __MACOSX__ ++#if SDL_VIDEO_DRIVER_COCOA + /* if the window is going away and no resolution change is necessary, + do nothing, or else we may trigger an ugly double-transition + */ +@@ -2365,7 +2365,7 @@ + return SDL_FALSE; + } + +-#ifdef __MACOSX__ ++#if SDL_VIDEO_DRIVER_COCOA + if (Cocoa_IsWindowInFullscreenSpace(window)) { + return SDL_FALSE; + } +--- CMakeLists.txt.old 2016-01-02 12:56:31 -0700 ++++ CMakeLists.txt 2016-10-03 11:24:24 -0600 +@@ -609,7 +609,7 @@ + list(APPEND EXTRA_LIBS m) + endif() + +- check_library_exists(iconv iconv_open "" HAVE_LIBICONV) ++ #check_library_exists(iconv iconv_open "" HAVE_LIBICONV) + if(HAVE_LIBICONV) + list(APPEND EXTRA_LIBS iconv) + set(HAVE_ICONV 1) +@@ -1455,7 +1455,7 @@ + set(_INSTALL_LIBS "SDL2main") + + if(SDL_SHARED) +- add_library(SDL2 SHARED ${SOURCE_FILES}) ++ add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES}) + if(UNIX) + set_target_properties(SDL2 PROPERTIES + VERSION ${LT_VERSION} diff --git a/build_files/build_environment/patches/semi.txt b/build_files/build_environment/patches/semi.txt new file mode 100644 index 00000000000..092bc2b0412 --- /dev/null +++ b/build_files/build_environment/patches/semi.txt @@ -0,0 +1 @@ +; diff --git a/build_files/build_environment/windows/build_deps.cmd b/build_files/build_environment/windows/build_deps.cmd new file mode 100644 index 00000000000..3e458816a5a --- /dev/null +++ b/build_files/build_environment/windows/build_deps.cmd @@ -0,0 +1,122 @@ +@echo off +if NOT "%1" == "" ( + if "%1" == "2013" ( + echo "Building for VS2013" + set VSVER=12.0 + set VSVER_SHORT=12 + set BuildDir=VS12 + goto par2 + ) + if "%1" == "2015" ( + echo "Building for VS2015" + set VSVER=14.0 + set VSVER_SHORT=14 + set BuildDir=VS14 + goto par2 + ) +) +:usage + +Echo Usage build_deps 2013/2015 x64/x86 +goto exit +:par2 +if NOT "%2" == "" ( + if "%2" == "x86" ( + echo "Building for x86" + set HARVESTROOT=Windows_vc + set ARCH=86 + if "%1" == "2013" ( + set CMAKE_BUILDER=Visual Studio 12 2013 + ) + if "%1" == "2015" ( + set CMAKE_BUILDER=Visual Studio 14 2015 + ) + goto start + ) + if "%2" == "x64" ( + echo "Building for x64" + set HARVESTROOT=Win64_vc + set ARCH=64 + if "%1" == "2013" ( + set CMAKE_BUILDER=Visual Studio 12 2013 Win64 + ) + if "%1" == "2015" ( + set CMAKE_BUILDER=Visual Studio 14 2015 Win64 + ) + goto start + ) +) +goto usage + +:start +setlocal ENABLEEXTENSIONS +set CMAKE_DEBUG_OPTIONS=-DWITH_OPTIMIZED_DEBUG=On +if "%3" == "debug" set CMAKE_DEBUG_OPTIONS=-DWITH_OPTIMIZED_DEBUG=Off + +set SOURCE_DIR=%~dp0\.. +set BUILD_DIR=%~dp0\..\..\..\..\build_windows\deps +set HARVEST_DIR=%BUILD_DIR%\output +set STAGING=%BUILD_DIR%\S + +rem for python module build +set MSSdk=1 +set DISTUTILS_USE_SDK=1 +rem for python externals source to be shared between the various archs and compilers +mkdir %SOURCE_DIR%\downloads\externals + +REM Detect MSVC Installation +if DEFINED VisualStudioVersion goto msvc_detect_finally +set VALUE_NAME=ProductDir +REM Check 64 bits +set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%VSVER%\Setup\VC" +for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C +if DEFINED MSVC_VC_DIR goto msvc_detect_finally +REM Check 32 bits +set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\%VSVER%\Setup\VC" +for /F "usebackq skip=2 tokens=1-2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO set MSVC_VC_DIR=%%C +if DEFINED MSVC_VC_DIR goto msvc_detect_finally +:msvc_detect_finally +if DEFINED MSVC_VC_DIR call "%MSVC_VC_DIR%\vcvarsall.bat" +echo on + +REM Sanity Checks +where /Q msbuild +if %ERRORLEVEL% NEQ 0 ( + echo Error: "MSBuild" command not in the PATH. + echo You must have MSVC installed and run this from the "Developer Command Prompt" + echo ^(available from Visual Studio's Start menu entry^), aborting! + goto EOF +) +where /Q cmake +if %ERRORLEVEL% NEQ 0 ( + echo Error: "CMake" command not in the PATH. + echo You must have CMake installed and added to your PATH, aborting! + goto EOF +) + +set StatusFile=%BUILD_DIR%\%1_%2.log +set path=%SOURCE_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%SOURCE_DIR%\downloads\nasm-2.12.01\;%path% +mkdir %STAGING%\%BuildDir%%ARCH%R +cd %Staging%\%BuildDir%%ARCH%R +echo %DATE% %TIME% : Start > %StatusFile% +cmake -G "%CMAKE_BUILDER%" %SOURCE_DIR% -DBUILD_MODE=Release -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/ +echo %DATE% %TIME% : Release Configuration done >> %StatusFile% +msbuild /m "ll.vcxproj" /p:Configuration=Release /fl /flp:logfile=BlenderDeps_llvm.log +msbuild /m "BlenderDependencies.sln" /p:Configuration=Release /fl /flp:logfile=BlenderDeps.log +echo %DATE% %TIME% : Release Build done >> %StatusFile% +cmake --build . --target Harvest_Release_Results > Harvest_Release.txt +echo %DATE% %TIME% : Release Harvest done >> %StatusFile% +cd %BUILD_DIR% +mkdir %STAGING%\%BuildDir%%ARCH%D +cd %Staging%\%BuildDir%%ARCH%D +cmake -G "%CMAKE_BUILDER%" %SOURCE_DIR% -DCMAKE_BUILD_TYPE=Debug -DBUILD_MODE=Debug -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/ %CMAKE_DEBUG_OPTIONS% +echo %DATE% %TIME% : Debug Configuration done >> %StatusFile% +msbuild /m "ll.vcxproj" /p:Configuration=Debug /fl /flp:logfile=BlenderDeps_llvm.log +msbuild /m "BlenderDependencies.sln" /p:Configuration=Debug /fl /flp:logfile=BlenderDeps.log +echo %DATE% %TIME% : Debug Build done >> %StatusFile% +cmake --build . --target Harvest_Debug_Results> Harvest_Debug.txt +echo %DATE% %TIME% : Debug Harvest done >> %StatusFile% +cd %BUILD_DIR% + +:exit +Echo . diff --git a/build_files/build_environment/windows/buildall.cmd b/build_files/build_environment/windows/buildall.cmd new file mode 100644 index 00000000000..480be8cde44 --- /dev/null +++ b/build_files/build_environment/windows/buildall.cmd @@ -0,0 +1,10 @@ +title building 1_4 - x86_2013 +call build_deps 2013 x86 +title building 2_4 - x86_2015 +call build_deps 2015 x86 +title building 3_4 - x64_2013 +call build_deps 2013 x64 +title building 4_4 - x64_2015 +call build_deps 2015 x64 +title done! +echo done!
\ No newline at end of file diff --git a/build_files/build_environment/windows/nuke.cmd b/build_files/build_environment/windows/nuke.cmd new file mode 100644 index 00000000000..68dbc8d1487 --- /dev/null +++ b/build_files/build_environment/windows/nuke.cmd @@ -0,0 +1,52 @@ +@echo off +if "%1"=="" goto EOF: +set ROOT=%~dp0\..\..\..\..\build_windows\deps + +set CurPath=%ROOT%\s\vs1264D\debug\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1264D\build\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1264R\release\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1264R\build\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\output\win64_vc12\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) + +set CurPath=%ROOT%\s\vs1464D\debug\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1464D\build\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1464R\release\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1464R\build\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\output\win64_vc14\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) + +set CurPath=%ROOT%\s\vs1286D\debug\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1286D\build\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1286R\release\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1286R\build\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\output\windows_vc12\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) + +set CurPath=%ROOT%\s\vs1486D\debug\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1486D\build\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1486R\release\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\s\vs1486R\build\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) +set CurPath=%ROOT%\output\windows_vc14\%1\ +if EXIST %CurPath%\nul ( echo removing "%CurPath%" && rd /s /q "%CurPath%" ) + + +:EOF + + diff --git a/extern/cuew/README.blender b/extern/cuew/README.blender index 7b77935d750..a53a927c25f 100644 --- a/extern/cuew/README.blender +++ b/extern/cuew/README.blender @@ -1,5 +1,5 @@ Project: Cuda Wrangler URL: https://github.com/CudaWrangler/cuew License: Apache 2.0 -Upstream version: 63d2a0f +Upstream version: cbf465b Local modifications: None diff --git a/extern/cuew/include/cuew.h b/extern/cuew/include/cuew.h index 4cce29d38ab..0eace96bc3f 100644 --- a/extern/cuew/include/cuew.h +++ b/extern/cuew/include/cuew.h @@ -27,7 +27,7 @@ extern "C" { #define CUEW_VERSION_MAJOR 1 #define CUEW_VERSION_MINOR 2 -#define CUDA_VERSION 7050 +#define CUDA_VERSION 8000 #define CU_IPC_HANDLE_SIZE 64 #define CU_STREAM_LEGACY ((CUstream)0x1) #define CU_STREAM_PER_THREAD ((CUstream)0x2) @@ -51,6 +51,8 @@ extern "C" { #define CU_LAUNCH_PARAM_BUFFER_POINTER ((void*)0x01) #define CU_LAUNCH_PARAM_BUFFER_SIZE ((void*)0x02) #define CU_PARAM_TR_DEFAULT -1 +#define CU_DEVICE_CPU ((CUdevice)-1) +#define CU_DEVICE_INVALID ((CUdevice)-2) /* Functions which changed 3.1 -> 3.2 for 64 bit stuff, * the cuda library has both the old ones for compatibility and new @@ -114,12 +116,30 @@ extern "C" { #define cuGLGetDevices cuGLGetDevices_v2 /* Types. */ +#ifdef _MSC_VER +typedef unsigned __int32 cuuint32_t; +typedef unsigned __int64 cuuint64_t; +#else +#include <stdint.h> +typedef uint32_t cuuint32_t; +typedef uint64_t cuuint64_t; +#endif + #if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) || defined (__aarch64__) typedef unsigned long long CUdeviceptr; #else typedef unsigned int CUdeviceptr; #endif + +#ifdef _WIN32 +# define CUDAAPI __stdcall +# define CUDA_CB __stdcall +#else +# define CUDAAPI +# define CUDA_CB +#endif + typedef int CUdevice; typedef struct CUctx_st* CUcontext; typedef struct CUmod_st* CUmodule; @@ -180,6 +200,53 @@ typedef enum CUevent_flags_enum { CU_EVENT_INTERPROCESS = 0x4, } CUevent_flags; +typedef enum CUstreamWaitValue_flags_enum { + CU_STREAM_WAIT_VALUE_GEQ = 0x0, + CU_STREAM_WAIT_VALUE_EQ = 0x1, + CU_STREAM_WAIT_VALUE_AND = 0x2, + CU_STREAM_WAIT_VALUE_FLUSH = (1 << 30), +} CUstreamWaitValue_flags; + +typedef enum CUstreamWriteValue_flags_enum { + CU_STREAM_WRITE_VALUE_DEFAULT = 0x0, + CU_STREAM_WRITE_VALUE_NO_MEMORY_BARRIER = 0x1, +} CUstreamWriteValue_flags; + +typedef enum CUstreamBatchMemOpType_enum { + CU_STREAM_MEM_OP_WAIT_VALUE_32 = 1, + CU_STREAM_MEM_OP_WRITE_VALUE_32 = 2, + CU_STREAM_MEM_OP_FLUSH_REMOTE_WRITES = 3, +} CUstreamBatchMemOpType; + +typedef union CUstreamBatchMemOpParams_union { + CUstreamBatchMemOpType operation; + struct CUstreamMemOpWaitValueParams_st { + CUstreamBatchMemOpType operation; + CUdeviceptr address; + union { + cuuint32_t value; + cuuint64_t pad; + }; + unsigned int flags; + CUdeviceptr alias; + } waitValue; + struct CUstreamMemOpWriteValueParams_st { + CUstreamBatchMemOpType operation; + CUdeviceptr address; + union { + cuuint32_t value; + cuuint64_t pad; + }; + unsigned int flags; + CUdeviceptr alias; + } writeValue; + struct CUstreamMemOpFlushRemoteWritesParams_st { + CUstreamBatchMemOpType operation; + unsigned int flags; + } flushRemoteWrites; + cuuint64_t pad[6]; +} CUstreamBatchMemOpParams; + typedef enum CUoccupancy_flags_enum { CU_OCCUPANCY_DEFAULT = 0x0, CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE = 0x1, @@ -299,6 +366,12 @@ typedef enum CUdevice_attribute_enum { CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY = 83, CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD = 84, CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID = 85, + CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED = 86, + CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO = 87, + CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS = 88, + CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS = 89, + CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED = 90, + CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM = 91, CU_DEVICE_ATTRIBUTE_MAX, } CUdevice_attribute; @@ -360,11 +433,26 @@ typedef enum CUmemorytype_enum { typedef enum CUcomputemode_enum { CU_COMPUTEMODE_DEFAULT = 0, - CU_COMPUTEMODE_EXCLUSIVE = 1, CU_COMPUTEMODE_PROHIBITED = 2, CU_COMPUTEMODE_EXCLUSIVE_PROCESS = 3, } CUcomputemode; +typedef enum CUmem_advise_enum { + CU_MEM_ADVISE_SET_READ_MOSTLY = 1, + CU_MEM_ADVISE_UNSET_READ_MOSTLY = 2, + CU_MEM_ADVISE_SET_PREFERRED_LOCATION = 3, + CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION = 4, + CU_MEM_ADVISE_SET_ACCESSED_BY = 5, + CU_MEM_ADVISE_UNSET_ACCESSED_BY = 6, +} CUmem_advise; + +typedef enum CUmem_range_attribute_enum { + CU_MEM_RANGE_ATTRIBUTE_READ_MOSTLY = 1, + CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION = 2, + CU_MEM_RANGE_ATTRIBUTE_ACCESSED_BY = 3, + CU_MEM_RANGE_ATTRIBUTE_LAST_PREFETCH_LOCATION = 4, +} CUmem_range_attribute; + typedef enum CUjit_option_enum { CU_JIT_MAX_REGISTERS = 0, CU_JIT_THREADS_PER_BLOCK, @@ -381,6 +469,8 @@ typedef enum CUjit_option_enum { CU_JIT_LOG_VERBOSE, CU_JIT_GENERATE_LINE_INFO, CU_JIT_CACHE_MODE, + CU_JIT_NEW_SM3X_OPT, + CU_JIT_FAST_COMPILE, CU_JIT_NUM_OPTIONS, } CUjit_option; @@ -397,6 +487,10 @@ typedef enum CUjit_target_enum { CU_TARGET_COMPUTE_37 = 37, CU_TARGET_COMPUTE_50 = 50, CU_TARGET_COMPUTE_52 = 52, + CU_TARGET_COMPUTE_53 = 53, + CU_TARGET_COMPUTE_60 = 60, + CU_TARGET_COMPUTE_61 = 61, + CU_TARGET_COMPUTE_62 = 62, } CUjit_target; typedef enum CUjit_fallback_enum { @@ -490,6 +584,7 @@ typedef enum cudaError_enum { CUDA_ERROR_PEER_ACCESS_UNSUPPORTED = 217, CUDA_ERROR_INVALID_PTX = 218, CUDA_ERROR_INVALID_GRAPHICS_CONTEXT = 219, + CUDA_ERROR_NVLINK_UNCORRECTABLE = 220, CUDA_ERROR_INVALID_SOURCE = 300, CUDA_ERROR_FILE_NOT_FOUND = 301, CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = 302, @@ -521,8 +616,14 @@ typedef enum cudaError_enum { CUDA_ERROR_UNKNOWN = 999, } CUresult; -typedef void* CUstreamCallback; -typedef size_t* CUoccupancyB2DSize; +typedef enum CUdevice_P2PAttribute_enum { + CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK = 0x01, + CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED = 0x02, + CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED = 0x03, +} CUdevice_P2PAttribute; + +typedef void (CUDA_CB *CUstreamCallback)(CUstream hStream, CUresult status, void* userData); +typedef size_t (CUDA_CB *CUoccupancyB2DSize)(int blockSize); typedef struct CUDA_MEMCPY2D_st { size_t srcXInBytes; @@ -654,7 +755,8 @@ typedef struct CUDA_TEXTURE_DESC_st { float mipmapLevelBias; float minMipmapLevelClamp; float maxMipmapLevelClamp; - int reserved[16]; + float borderColor[4]; + int reserved[12]; } CUDA_TEXTURE_DESC; typedef enum CUresourceViewFormat_enum { @@ -736,21 +838,16 @@ typedef enum { NVRTC_ERROR_INVALID_OPTION = 5, NVRTC_ERROR_COMPILATION = 6, NVRTC_ERROR_BUILTIN_OPERATION_FAILURE = 7, + NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION = 8, + NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION = 9, + NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID = 10, + NVRTC_ERROR_INTERNAL_ERROR = 11, } nvrtcResult; typedef struct _nvrtcProgram* nvrtcProgram; - -#ifdef _WIN32 -# define CUDAAPI __stdcall -# define CUDA_CB __stdcall -#else -# define CUDAAPI -# define CUDA_CB -#endif - /* Function types. */ -typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char* pStr); -typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char* pStr); +typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pStr); +typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pStr); typedef CUresult CUDAAPI tcuInit(unsigned int Flags); typedef CUresult CUDAAPI tcuDriverGetVersion(int* driverVersion); typedef CUresult CUDAAPI tcuDeviceGet(CUdevice* device, int ordinal); @@ -786,26 +883,26 @@ typedef CUresult CUDAAPI tcuCtxAttach(CUcontext* pctx, unsigned int flags); typedef CUresult CUDAAPI tcuCtxDetach(CUcontext ctx); typedef CUresult CUDAAPI tcuModuleLoad(CUmodule* module, const char* fname); typedef CUresult CUDAAPI tcuModuleLoadData(CUmodule* module, const void* image); -typedef CUresult CUDAAPI tcuModuleLoadDataEx(CUmodule* module, const void* image, unsigned int numOptions, CUjit_option* options, void* optionValues); +typedef CUresult CUDAAPI tcuModuleLoadDataEx(CUmodule* module, const void* image, unsigned int numOptions, CUjit_option* options, void** optionValues); typedef CUresult CUDAAPI tcuModuleLoadFatBinary(CUmodule* module, const void* fatCubin); typedef CUresult CUDAAPI tcuModuleUnload(CUmodule hmod); typedef CUresult CUDAAPI tcuModuleGetFunction(CUfunction* hfunc, CUmodule hmod, const char* name); typedef CUresult CUDAAPI tcuModuleGetGlobal_v2(CUdeviceptr* dptr, size_t* bytes, CUmodule hmod, const char* name); typedef CUresult CUDAAPI tcuModuleGetTexRef(CUtexref* pTexRef, CUmodule hmod, const char* name); typedef CUresult CUDAAPI tcuModuleGetSurfRef(CUsurfref* pSurfRef, CUmodule hmod, const char* name); -typedef CUresult CUDAAPI tcuLinkCreate_v2(unsigned int numOptions, CUjit_option* options, void* optionValues, CUlinkState* stateOut); -typedef CUresult CUDAAPI tcuLinkAddData_v2(CUlinkState state, CUjitInputType type, void* data, size_t size, const char* name, unsigned int numOptions, CUjit_option* options, void* optionValues); -typedef CUresult CUDAAPI tcuLinkAddFile_v2(CUlinkState state, CUjitInputType type, const char* path, unsigned int numOptions, CUjit_option* options, void* optionValues); -typedef CUresult CUDAAPI tcuLinkComplete(CUlinkState state, void* cubinOut, size_t* sizeOut); +typedef CUresult CUDAAPI tcuLinkCreate_v2(unsigned int numOptions, CUjit_option* options, void** optionValues, CUlinkState* stateOut); +typedef CUresult CUDAAPI tcuLinkAddData_v2(CUlinkState state, CUjitInputType type, void* data, size_t size, const char* name, unsigned int numOptions, CUjit_option* options, void** optionValues); +typedef CUresult CUDAAPI tcuLinkAddFile_v2(CUlinkState state, CUjitInputType type, const char* path, unsigned int numOptions, CUjit_option* options, void** optionValues); +typedef CUresult CUDAAPI tcuLinkComplete(CUlinkState state, void** cubinOut, size_t* sizeOut); typedef CUresult CUDAAPI tcuLinkDestroy(CUlinkState state); typedef CUresult CUDAAPI tcuMemGetInfo_v2(size_t* free, size_t* total); typedef CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr* dptr, size_t bytesize); typedef CUresult CUDAAPI tcuMemAllocPitch_v2(CUdeviceptr* dptr, size_t* pPitch, size_t WidthInBytes, size_t Height, unsigned int ElementSizeBytes); typedef CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr); typedef CUresult CUDAAPI tcuMemGetAddressRange_v2(CUdeviceptr* pbase, size_t* psize, CUdeviceptr dptr); -typedef CUresult CUDAAPI tcuMemAllocHost_v2(void* pp, size_t bytesize); +typedef CUresult CUDAAPI tcuMemAllocHost_v2(void** pp, size_t bytesize); typedef CUresult CUDAAPI tcuMemFreeHost(void* p); -typedef CUresult CUDAAPI tcuMemHostAlloc(void* pp, size_t bytesize, unsigned int Flags); +typedef CUresult CUDAAPI tcuMemHostAlloc(void** pp, size_t bytesize, unsigned int Flags); typedef CUresult CUDAAPI tcuMemHostGetDevicePointer_v2(CUdeviceptr* pdptr, void* p, unsigned int Flags); typedef CUresult CUDAAPI tcuMemHostGetFlags(unsigned int* pFlags, void* p); typedef CUresult CUDAAPI tcuMemAllocManaged(CUdeviceptr* dptr, size_t bytesize, unsigned int flags); @@ -863,8 +960,12 @@ typedef CUresult CUDAAPI tcuMipmappedArrayCreate(CUmipmappedArray* pHandle, cons typedef CUresult CUDAAPI tcuMipmappedArrayGetLevel(CUarray* pLevelArray, CUmipmappedArray hMipmappedArray, unsigned int level); typedef CUresult CUDAAPI tcuMipmappedArrayDestroy(CUmipmappedArray hMipmappedArray); typedef CUresult CUDAAPI tcuPointerGetAttribute(void* data, CUpointer_attribute attribute, CUdeviceptr ptr); +typedef CUresult CUDAAPI tcuMemPrefetchAsync(CUdeviceptr devPtr, size_t count, CUdevice dstDevice, CUstream hStream); +typedef CUresult CUDAAPI tcuMemAdvise(CUdeviceptr devPtr, size_t count, CUmem_advise advice, CUdevice device); +typedef CUresult CUDAAPI tcuMemRangeGetAttribute(void* data, size_t dataSize, CUmem_range_attribute attribute, CUdeviceptr devPtr, size_t count); +typedef CUresult CUDAAPI tcuMemRangeGetAttributes(void** data, size_t* dataSizes, CUmem_range_attribute* attributes, size_t numAttributes, CUdeviceptr devPtr, size_t count); typedef CUresult CUDAAPI tcuPointerSetAttribute(const void* value, CUpointer_attribute attribute, CUdeviceptr ptr); -typedef CUresult CUDAAPI tcuPointerGetAttributes(unsigned int numAttributes, CUpointer_attribute* attributes, void* data, CUdeviceptr ptr); +typedef CUresult CUDAAPI tcuPointerGetAttributes(unsigned int numAttributes, CUpointer_attribute* attributes, void** data, CUdeviceptr ptr); typedef CUresult CUDAAPI tcuStreamCreate(CUstream* phStream, unsigned int Flags); typedef CUresult CUDAAPI tcuStreamCreateWithPriority(CUstream* phStream, unsigned int flags, int priority); typedef CUresult CUDAAPI tcuStreamGetPriority(CUstream hStream, int* priority); @@ -881,10 +982,13 @@ typedef CUresult CUDAAPI tcuEventQuery(CUevent hEvent); typedef CUresult CUDAAPI tcuEventSynchronize(CUevent hEvent); typedef CUresult CUDAAPI tcuEventDestroy_v2(CUevent hEvent); typedef CUresult CUDAAPI tcuEventElapsedTime(float* pMilliseconds, CUevent hStart, CUevent hEnd); +typedef CUresult CUDAAPI tcuStreamWaitValue32(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags); +typedef CUresult CUDAAPI tcuStreamWriteValue32(CUstream stream, CUdeviceptr addr, cuuint32_t value, unsigned int flags); +typedef CUresult CUDAAPI tcuStreamBatchMemOp(CUstream stream, unsigned int count, CUstreamBatchMemOpParams* paramArray, unsigned int flags); typedef CUresult CUDAAPI tcuFuncGetAttribute(int* pi, CUfunction_attribute attrib, CUfunction hfunc); typedef CUresult CUDAAPI tcuFuncSetCacheConfig(CUfunction hfunc, CUfunc_cache config); typedef CUresult CUDAAPI tcuFuncSetSharedMemConfig(CUfunction hfunc, CUsharedconfig config); -typedef CUresult CUDAAPI tcuLaunchKernel(CUfunction f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, CUstream hStream, void* kernelParams, void* extra); +typedef CUresult CUDAAPI tcuLaunchKernel(CUfunction f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, CUstream hStream, void** kernelParams, void** extra); typedef CUresult CUDAAPI tcuFuncSetBlockShape(CUfunction hfunc, int x, int y, int z); typedef CUresult CUDAAPI tcuFuncSetSharedSize(CUfunction hfunc, unsigned int bytes); typedef CUresult CUDAAPI tcuParamSetSize(CUfunction hfunc, unsigned int numbytes); @@ -910,6 +1014,7 @@ typedef CUresult CUDAAPI tcuTexRefSetMipmapFilterMode(CUtexref hTexRef, CUfilter typedef CUresult CUDAAPI tcuTexRefSetMipmapLevelBias(CUtexref hTexRef, float bias); typedef CUresult CUDAAPI tcuTexRefSetMipmapLevelClamp(CUtexref hTexRef, float minMipmapLevelClamp, float maxMipmapLevelClamp); typedef CUresult CUDAAPI tcuTexRefSetMaxAnisotropy(CUtexref hTexRef, unsigned int maxAniso); +typedef CUresult CUDAAPI tcuTexRefSetBorderColor(CUtexref hTexRef, float* pBorderColor); typedef CUresult CUDAAPI tcuTexRefSetFlags(CUtexref hTexRef, unsigned int Flags); typedef CUresult CUDAAPI tcuTexRefGetAddress_v2(CUdeviceptr* pdptr, CUtexref hTexRef); typedef CUresult CUDAAPI tcuTexRefGetArray(CUarray* phArray, CUtexref hTexRef); @@ -921,6 +1026,7 @@ typedef CUresult CUDAAPI tcuTexRefGetMipmapFilterMode(CUfilter_mode* pfm, CUtexr typedef CUresult CUDAAPI tcuTexRefGetMipmapLevelBias(float* pbias, CUtexref hTexRef); typedef CUresult CUDAAPI tcuTexRefGetMipmapLevelClamp(float* pminMipmapLevelClamp, float* pmaxMipmapLevelClamp, CUtexref hTexRef); typedef CUresult CUDAAPI tcuTexRefGetMaxAnisotropy(int* pmaxAniso, CUtexref hTexRef); +typedef CUresult CUDAAPI tcuTexRefGetBorderColor(float* pBorderColor, CUtexref hTexRef); typedef CUresult CUDAAPI tcuTexRefGetFlags(unsigned int* pFlags, CUtexref hTexRef); typedef CUresult CUDAAPI tcuTexRefCreate(CUtexref* pTexRef); typedef CUresult CUDAAPI tcuTexRefDestroy(CUtexref hTexRef); @@ -935,6 +1041,7 @@ typedef CUresult CUDAAPI tcuSurfObjectCreate(CUsurfObject* pSurfObject, const CU typedef CUresult CUDAAPI tcuSurfObjectDestroy(CUsurfObject surfObject); typedef CUresult CUDAAPI tcuSurfObjectGetResourceDesc(CUDA_RESOURCE_DESC* pResDesc, CUsurfObject surfObject); typedef CUresult CUDAAPI tcuDeviceCanAccessPeer(int* canAccessPeer, CUdevice dev, CUdevice peerDev); +typedef CUresult CUDAAPI tcuDeviceGetP2PAttribute(int* value, CUdevice_P2PAttribute attrib, CUdevice srcDevice, CUdevice dstDevice); typedef CUresult CUDAAPI tcuCtxEnablePeerAccess(CUcontext peerContext, unsigned int Flags); typedef CUresult CUDAAPI tcuCtxDisablePeerAccess(CUcontext peerContext); typedef CUresult CUDAAPI tcuGraphicsUnregisterResource(CUgraphicsResource resource); @@ -944,7 +1051,7 @@ typedef CUresult CUDAAPI tcuGraphicsResourceGetMappedPointer_v2(CUdeviceptr* pDe typedef CUresult CUDAAPI tcuGraphicsResourceSetMapFlags_v2(CUgraphicsResource resource, unsigned int flags); typedef CUresult CUDAAPI tcuGraphicsMapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream); typedef CUresult CUDAAPI tcuGraphicsUnmapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream); -typedef CUresult CUDAAPI tcuGetExportTable(const void* ppExportTable, const CUuuid* pExportTableId); +typedef CUresult CUDAAPI tcuGetExportTable(const void** ppExportTable, const CUuuid* pExportTableId); typedef CUresult CUDAAPI tcuGraphicsGLRegisterBuffer(CUgraphicsResource* pCudaResource, GLuint buffer, unsigned int Flags); typedef CUresult CUDAAPI tcuGraphicsGLRegisterImage(CUgraphicsResource* pCudaResource, GLuint image, GLenum target, unsigned int Flags); @@ -961,13 +1068,15 @@ typedef CUresult CUDAAPI tcuGLUnmapBufferObjectAsync(GLuint buffer, CUstream hSt typedef const char* CUDAAPI tnvrtcGetErrorString(nvrtcResult result); typedef nvrtcResult CUDAAPI tnvrtcVersion(int* major, int* minor); -typedef nvrtcResult CUDAAPI tnvrtcCreateProgram(nvrtcProgram* prog, const char* src, const char* name, int numHeaders, const char* headers, const char* includeNames); +typedef nvrtcResult CUDAAPI tnvrtcCreateProgram(nvrtcProgram* prog, const char* src, const char* name, int numHeaders, const char** headers, const char** includeNames); typedef nvrtcResult CUDAAPI tnvrtcDestroyProgram(nvrtcProgram* prog); -typedef nvrtcResult CUDAAPI tnvrtcCompileProgram(nvrtcProgram prog, int numOptions, const char* options); +typedef nvrtcResult CUDAAPI tnvrtcCompileProgram(nvrtcProgram prog, int numOptions, const char** options); typedef nvrtcResult CUDAAPI tnvrtcGetPTXSize(nvrtcProgram prog, size_t* ptxSizeRet); typedef nvrtcResult CUDAAPI tnvrtcGetPTX(nvrtcProgram prog, char* ptx); typedef nvrtcResult CUDAAPI tnvrtcGetProgramLogSize(nvrtcProgram prog, size_t* logSizeRet); typedef nvrtcResult CUDAAPI tnvrtcGetProgramLog(nvrtcProgram prog, char* log); +typedef nvrtcResult CUDAAPI tnvrtcAddNameExpression(nvrtcProgram prog, const char* name_expression); +typedef nvrtcResult CUDAAPI tnvrtcGetLoweredName(nvrtcProgram prog, const char* name_expression, const char** lowered_name); /* Function declarations. */ @@ -1085,6 +1194,10 @@ extern tcuMipmappedArrayCreate *cuMipmappedArrayCreate; extern tcuMipmappedArrayGetLevel *cuMipmappedArrayGetLevel; extern tcuMipmappedArrayDestroy *cuMipmappedArrayDestroy; extern tcuPointerGetAttribute *cuPointerGetAttribute; +extern tcuMemPrefetchAsync *cuMemPrefetchAsync; +extern tcuMemAdvise *cuMemAdvise; +extern tcuMemRangeGetAttribute *cuMemRangeGetAttribute; +extern tcuMemRangeGetAttributes *cuMemRangeGetAttributes; extern tcuPointerSetAttribute *cuPointerSetAttribute; extern tcuPointerGetAttributes *cuPointerGetAttributes; extern tcuStreamCreate *cuStreamCreate; @@ -1103,6 +1216,9 @@ extern tcuEventQuery *cuEventQuery; extern tcuEventSynchronize *cuEventSynchronize; extern tcuEventDestroy_v2 *cuEventDestroy_v2; extern tcuEventElapsedTime *cuEventElapsedTime; +extern tcuStreamWaitValue32 *cuStreamWaitValue32; +extern tcuStreamWriteValue32 *cuStreamWriteValue32; +extern tcuStreamBatchMemOp *cuStreamBatchMemOp; extern tcuFuncGetAttribute *cuFuncGetAttribute; extern tcuFuncSetCacheConfig *cuFuncSetCacheConfig; extern tcuFuncSetSharedMemConfig *cuFuncSetSharedMemConfig; @@ -1132,6 +1248,7 @@ extern tcuTexRefSetMipmapFilterMode *cuTexRefSetMipmapFilterMode; extern tcuTexRefSetMipmapLevelBias *cuTexRefSetMipmapLevelBias; extern tcuTexRefSetMipmapLevelClamp *cuTexRefSetMipmapLevelClamp; extern tcuTexRefSetMaxAnisotropy *cuTexRefSetMaxAnisotropy; +extern tcuTexRefSetBorderColor *cuTexRefSetBorderColor; extern tcuTexRefSetFlags *cuTexRefSetFlags; extern tcuTexRefGetAddress_v2 *cuTexRefGetAddress_v2; extern tcuTexRefGetArray *cuTexRefGetArray; @@ -1143,6 +1260,7 @@ extern tcuTexRefGetMipmapFilterMode *cuTexRefGetMipmapFilterMode; extern tcuTexRefGetMipmapLevelBias *cuTexRefGetMipmapLevelBias; extern tcuTexRefGetMipmapLevelClamp *cuTexRefGetMipmapLevelClamp; extern tcuTexRefGetMaxAnisotropy *cuTexRefGetMaxAnisotropy; +extern tcuTexRefGetBorderColor *cuTexRefGetBorderColor; extern tcuTexRefGetFlags *cuTexRefGetFlags; extern tcuTexRefCreate *cuTexRefCreate; extern tcuTexRefDestroy *cuTexRefDestroy; @@ -1157,6 +1275,7 @@ extern tcuSurfObjectCreate *cuSurfObjectCreate; extern tcuSurfObjectDestroy *cuSurfObjectDestroy; extern tcuSurfObjectGetResourceDesc *cuSurfObjectGetResourceDesc; extern tcuDeviceCanAccessPeer *cuDeviceCanAccessPeer; +extern tcuDeviceGetP2PAttribute *cuDeviceGetP2PAttribute; extern tcuCtxEnablePeerAccess *cuCtxEnablePeerAccess; extern tcuCtxDisablePeerAccess *cuCtxDisablePeerAccess; extern tcuGraphicsUnregisterResource *cuGraphicsUnregisterResource; @@ -1190,6 +1309,8 @@ extern tnvrtcGetPTXSize *nvrtcGetPTXSize; extern tnvrtcGetPTX *nvrtcGetPTX; extern tnvrtcGetProgramLogSize *nvrtcGetProgramLogSize; extern tnvrtcGetProgramLog *nvrtcGetProgramLog; +extern tnvrtcAddNameExpression *nvrtcAddNameExpression; +extern tnvrtcGetLoweredName *nvrtcGetLoweredName; enum { diff --git a/extern/cuew/src/cuew.c b/extern/cuew/src/cuew.c index c96ea2c1959..962059bfcce 100644 --- a/extern/cuew/src/cuew.c +++ b/extern/cuew/src/cuew.c @@ -184,6 +184,10 @@ tcuMipmappedArrayCreate *cuMipmappedArrayCreate; tcuMipmappedArrayGetLevel *cuMipmappedArrayGetLevel; tcuMipmappedArrayDestroy *cuMipmappedArrayDestroy; tcuPointerGetAttribute *cuPointerGetAttribute; +tcuMemPrefetchAsync *cuMemPrefetchAsync; +tcuMemAdvise *cuMemAdvise; +tcuMemRangeGetAttribute *cuMemRangeGetAttribute; +tcuMemRangeGetAttributes *cuMemRangeGetAttributes; tcuPointerSetAttribute *cuPointerSetAttribute; tcuPointerGetAttributes *cuPointerGetAttributes; tcuStreamCreate *cuStreamCreate; @@ -202,6 +206,9 @@ tcuEventQuery *cuEventQuery; tcuEventSynchronize *cuEventSynchronize; tcuEventDestroy_v2 *cuEventDestroy_v2; tcuEventElapsedTime *cuEventElapsedTime; +tcuStreamWaitValue32 *cuStreamWaitValue32; +tcuStreamWriteValue32 *cuStreamWriteValue32; +tcuStreamBatchMemOp *cuStreamBatchMemOp; tcuFuncGetAttribute *cuFuncGetAttribute; tcuFuncSetCacheConfig *cuFuncSetCacheConfig; tcuFuncSetSharedMemConfig *cuFuncSetSharedMemConfig; @@ -231,6 +238,7 @@ tcuTexRefSetMipmapFilterMode *cuTexRefSetMipmapFilterMode; tcuTexRefSetMipmapLevelBias *cuTexRefSetMipmapLevelBias; tcuTexRefSetMipmapLevelClamp *cuTexRefSetMipmapLevelClamp; tcuTexRefSetMaxAnisotropy *cuTexRefSetMaxAnisotropy; +tcuTexRefSetBorderColor *cuTexRefSetBorderColor; tcuTexRefSetFlags *cuTexRefSetFlags; tcuTexRefGetAddress_v2 *cuTexRefGetAddress_v2; tcuTexRefGetArray *cuTexRefGetArray; @@ -242,6 +250,7 @@ tcuTexRefGetMipmapFilterMode *cuTexRefGetMipmapFilterMode; tcuTexRefGetMipmapLevelBias *cuTexRefGetMipmapLevelBias; tcuTexRefGetMipmapLevelClamp *cuTexRefGetMipmapLevelClamp; tcuTexRefGetMaxAnisotropy *cuTexRefGetMaxAnisotropy; +tcuTexRefGetBorderColor *cuTexRefGetBorderColor; tcuTexRefGetFlags *cuTexRefGetFlags; tcuTexRefCreate *cuTexRefCreate; tcuTexRefDestroy *cuTexRefDestroy; @@ -256,6 +265,7 @@ tcuSurfObjectCreate *cuSurfObjectCreate; tcuSurfObjectDestroy *cuSurfObjectDestroy; tcuSurfObjectGetResourceDesc *cuSurfObjectGetResourceDesc; tcuDeviceCanAccessPeer *cuDeviceCanAccessPeer; +tcuDeviceGetP2PAttribute *cuDeviceGetP2PAttribute; tcuCtxEnablePeerAccess *cuCtxEnablePeerAccess; tcuCtxDisablePeerAccess *cuCtxDisablePeerAccess; tcuGraphicsUnregisterResource *cuGraphicsUnregisterResource; @@ -289,6 +299,8 @@ tnvrtcGetPTXSize *nvrtcGetPTXSize; tnvrtcGetPTX *nvrtcGetPTX; tnvrtcGetProgramLogSize *nvrtcGetProgramLogSize; tnvrtcGetProgramLog *nvrtcGetProgramLog; +tnvrtcAddNameExpression *nvrtcAddNameExpression; +tnvrtcGetLoweredName *nvrtcGetLoweredName; static DynamicLibrary dynamic_library_open_find(const char **paths) { @@ -486,6 +498,10 @@ int cuewInit(void) { CUDA_LIBRARY_FIND(cuMipmappedArrayGetLevel); CUDA_LIBRARY_FIND(cuMipmappedArrayDestroy); CUDA_LIBRARY_FIND(cuPointerGetAttribute); + CUDA_LIBRARY_FIND(cuMemPrefetchAsync); + CUDA_LIBRARY_FIND(cuMemAdvise); + CUDA_LIBRARY_FIND(cuMemRangeGetAttribute); + CUDA_LIBRARY_FIND(cuMemRangeGetAttributes); CUDA_LIBRARY_FIND(cuPointerSetAttribute); CUDA_LIBRARY_FIND(cuPointerGetAttributes); CUDA_LIBRARY_FIND(cuStreamCreate); @@ -504,6 +520,9 @@ int cuewInit(void) { CUDA_LIBRARY_FIND(cuEventSynchronize); CUDA_LIBRARY_FIND(cuEventDestroy_v2); CUDA_LIBRARY_FIND(cuEventElapsedTime); + CUDA_LIBRARY_FIND(cuStreamWaitValue32); + CUDA_LIBRARY_FIND(cuStreamWriteValue32); + CUDA_LIBRARY_FIND(cuStreamBatchMemOp); CUDA_LIBRARY_FIND(cuFuncGetAttribute); CUDA_LIBRARY_FIND(cuFuncSetCacheConfig); CUDA_LIBRARY_FIND(cuFuncSetSharedMemConfig); @@ -533,6 +552,7 @@ int cuewInit(void) { CUDA_LIBRARY_FIND(cuTexRefSetMipmapLevelBias); CUDA_LIBRARY_FIND(cuTexRefSetMipmapLevelClamp); CUDA_LIBRARY_FIND(cuTexRefSetMaxAnisotropy); + CUDA_LIBRARY_FIND(cuTexRefSetBorderColor); CUDA_LIBRARY_FIND(cuTexRefSetFlags); CUDA_LIBRARY_FIND(cuTexRefGetAddress_v2); CUDA_LIBRARY_FIND(cuTexRefGetArray); @@ -544,6 +564,7 @@ int cuewInit(void) { CUDA_LIBRARY_FIND(cuTexRefGetMipmapLevelBias); CUDA_LIBRARY_FIND(cuTexRefGetMipmapLevelClamp); CUDA_LIBRARY_FIND(cuTexRefGetMaxAnisotropy); + CUDA_LIBRARY_FIND(cuTexRefGetBorderColor); CUDA_LIBRARY_FIND(cuTexRefGetFlags); CUDA_LIBRARY_FIND(cuTexRefCreate); CUDA_LIBRARY_FIND(cuTexRefDestroy); @@ -558,6 +579,7 @@ int cuewInit(void) { CUDA_LIBRARY_FIND(cuSurfObjectDestroy); CUDA_LIBRARY_FIND(cuSurfObjectGetResourceDesc); CUDA_LIBRARY_FIND(cuDeviceCanAccessPeer); + CUDA_LIBRARY_FIND(cuDeviceGetP2PAttribute); CUDA_LIBRARY_FIND(cuCtxEnablePeerAccess); CUDA_LIBRARY_FIND(cuCtxDisablePeerAccess); CUDA_LIBRARY_FIND(cuGraphicsUnregisterResource); @@ -593,6 +615,8 @@ int cuewInit(void) { NVRTC_LIBRARY_FIND(nvrtcGetPTX); NVRTC_LIBRARY_FIND(nvrtcGetProgramLogSize); NVRTC_LIBRARY_FIND(nvrtcGetProgramLog); + NVRTC_LIBRARY_FIND(nvrtcAddNameExpression); + NVRTC_LIBRARY_FIND(nvrtcGetLoweredName); } result = CUEW_SUCCESS; @@ -630,6 +654,7 @@ const char *cuewErrorString(CUresult result) { case CUDA_ERROR_PEER_ACCESS_UNSUPPORTED: return "Peer access unsupported"; case CUDA_ERROR_INVALID_PTX: return "Invalid ptx"; case CUDA_ERROR_INVALID_GRAPHICS_CONTEXT: return "Invalid graphics context"; + case CUDA_ERROR_NVLINK_UNCORRECTABLE: return "Nvlink uncorrectable"; case CUDA_ERROR_INVALID_SOURCE: return "Invalid source"; case CUDA_ERROR_FILE_NOT_FOUND: return "File not found"; case CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND: return "Link to a shared object failed to resolve"; diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 33143e2d8aa..0ad3c8a7429 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -153,7 +153,6 @@ void BVH::pack_primitives() if(pack.prim_index[i] != -1) { int tob = pack.prim_object[i]; Object *ob = objects[tob]; - if((pack.prim_type[i] & PRIMITIVE_ALL_TRIANGLE) != 0) { pack_triangle(i, (float4*)&pack.prim_tri_verts[3 * prim_triangle_index]); pack.prim_tri_index[i] = 3 * prim_triangle_index; @@ -162,11 +161,10 @@ void BVH::pack_primitives() else { pack.prim_tri_index[i] = -1; } - - pack.prim_visibility[i] = ob->visibility; - - if(pack.prim_type[i] & PRIMITIVE_ALL_CURVE) + pack.prim_visibility[i] = ob->visibility_for_tracing(); + if(pack.prim_type[i] & PRIMITIVE_ALL_CURVE) { pack.prim_visibility[i] |= PATH_RAY_CURVE; + } } else { pack.prim_tri_index[i] = -1; diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp index 340ba7dcf53..9aa8e71dfd0 100644 --- a/intern/cycles/bvh/bvh2.cpp +++ b/intern/cycles/bvh/bvh2.cpp @@ -312,10 +312,8 @@ void BVH2::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility) } } } - - visibility |= ob->visibility; + visibility |= ob->visibility_for_tracing(); } - /* TODO(sergey): De-duplicate with pack_leaf(). */ float4 leaf_data[BVH_NODE_LEAF_SIZE]; leaf_data[0].x = __int_as_float(c0); diff --git a/intern/cycles/bvh/bvh4.cpp b/intern/cycles/bvh/bvh4.cpp index 5034ab811d5..aeedd802f49 100644 --- a/intern/cycles/bvh/bvh4.cpp +++ b/intern/cycles/bvh/bvh4.cpp @@ -438,10 +438,8 @@ void BVH4::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility) } } } - - visibility |= ob->visibility; + visibility |= ob->visibility_for_tracing(); } - /* TODO(sergey): This is actually a copy of pack_leaf(), * but this chunk of code only knows actual data and has * no idea about BVHNode. diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp index 1880964355c..933e98fea01 100644 --- a/intern/cycles/bvh/bvh_build.cpp +++ b/intern/cycles/bvh/bvh_build.cpp @@ -865,7 +865,7 @@ BVHNode *BVHBuild::create_object_leaf_nodes(const BVHReference *ref, int start, prim_time[start] = make_float2(ref->time_from(), ref->time_to()); } - uint visibility = objects[ref->prim_object()]->visibility; + const uint visibility = objects[ref->prim_object()]->visibility_for_tracing(); BVHNode *leaf_node = new LeafNode(ref->bounds(), visibility, start, start+1); leaf_node->time_from = ref->time_from(); leaf_node->time_to = ref->time_to(); @@ -939,7 +939,7 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range, ref.time_to())); bounds[type_index].grow(ref.bounds()); - visibility[type_index] |= objects[ref.prim_object()]->visibility; + visibility[type_index] |= objects[ref.prim_object()]->visibility_for_tracing(); if(ref.prim_type() & PRIMITIVE_ALL_CURVE) { visibility[type_index] |= PATH_RAY_CURVE; } diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt index 74ec57ddf74..3c632160fbd 100644 --- a/intern/cycles/device/CMakeLists.txt +++ b/intern/cycles/device/CMakeLists.txt @@ -34,11 +34,13 @@ set(SRC set(SRC_OPENCL opencl/opencl.h + opencl/memory_manager.h opencl/opencl_base.cpp opencl/opencl_mega.cpp opencl/opencl_split.cpp opencl/opencl_util.cpp + opencl/memory_manager.cpp ) if(WITH_CYCLES_NETWORK) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index a54bb77f9f3..f64436aec7b 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -379,11 +379,9 @@ DeviceInfo Device::get_multi_device(vector<DeviceInfo> subdevices) info.num = 0; info.has_bindless_textures = true; - info.pack_images = false; foreach(DeviceInfo &device, subdevices) { assert(device.type == info.multi_devices[0].type); - info.pack_images |= device.pack_images; info.has_bindless_textures &= device.has_bindless_textures; } diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index b3b693c630c..26d6d380a10 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -53,7 +53,6 @@ public: int num; bool display_device; bool advanced_shading; - bool pack_images; bool has_bindless_textures; /* flag for GPU and Multi device */ bool use_split_kernel; /* Denotes if the device is going to run cycles using split-kernel */ vector<DeviceInfo> multi_devices; @@ -65,7 +64,6 @@ public: num = 0; display_device = false; advanced_shading = true; - pack_images = false; has_bindless_textures = false; use_split_kernel = false; } diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index a00be3eeaab..6e09c5f88c2 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -977,7 +977,6 @@ void device_cpu_info(vector<DeviceInfo>& devices) info.id = "CPU"; info.num = 0; info.advanced_shading = true; - info.pack_images = false; devices.insert(devices.begin(), info); } diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index dbf636e1405..6769ed0229e 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -2164,7 +2164,6 @@ void device_cuda_info(vector<DeviceInfo>& devices) info.advanced_shading = (major >= 2); info.has_bindless_textures = (major >= 3); - info.pack_images = false; int pci_location[3] = {0, 0, 0}; cuDeviceGetAttribute(&pci_location[0], CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, num); diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index 681b8214b03..aa380ec4b94 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -95,7 +95,6 @@ void device_opencl_info(vector<DeviceInfo>& devices) /* We don't know if it's used for display, but assume it is. */ info.display_device = true; info.advanced_shading = OpenCLInfo::kernel_use_advanced_shading(platform_name); - info.pack_images = true; info.use_split_kernel = OpenCLInfo::kernel_use_split(platform_name, device_type); info.id = string("OPENCL_") + platform_name + "_" + device_name + "_" + hardware_id; diff --git a/intern/cycles/device/opencl/memory_manager.cpp b/intern/cycles/device/opencl/memory_manager.cpp new file mode 100644 index 00000000000..b67dfef88aa --- /dev/null +++ b/intern/cycles/device/opencl/memory_manager.cpp @@ -0,0 +1,253 @@ +/* + * Copyright 2011-2017 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef WITH_OPENCL + +#include "util/util_foreach.h" + +#include "device/opencl/opencl.h" +#include "device/opencl/memory_manager.h" + +CCL_NAMESPACE_BEGIN + +void MemoryManager::DeviceBuffer::add_allocation(Allocation& allocation) +{ + allocations.push_back(&allocation); +} + +void MemoryManager::DeviceBuffer::update_device_memory(OpenCLDeviceBase *device) +{ + bool need_realloc = false; + + /* Calculate total size and remove any freed. */ + size_t total_size = 0; + + for(int i = allocations.size()-1; i >= 0; i--) { + Allocation* allocation = allocations[i]; + + /* Remove allocations that have been freed. */ + if(!allocation->mem || allocation->mem->memory_size() == 0) { + allocation->device_buffer = NULL; + allocation->size = 0; + + allocations.erase(allocations.begin()+i); + + need_realloc = true; + + continue; + } + + /* Get actual size for allocation. */ + size_t alloc_size = align_up(allocation->mem->memory_size(), 16); + + if(allocation->size != alloc_size) { + /* Allocation is either new or resized. */ + allocation->size = alloc_size; + allocation->needs_copy_to_device = true; + + need_realloc = true; + } + + total_size += alloc_size; + } + + if(need_realloc) { + cl_ulong max_buffer_size; + clGetDeviceInfo(device->cdDevice, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_buffer_size, NULL); + + if(total_size > max_buffer_size) { + device->set_error("Scene too complex to fit in available memory."); + return; + } + + device_memory *new_buffer = new device_memory; + + new_buffer->resize(total_size); + device->mem_alloc(string_printf("buffer_%p", this).data(), *new_buffer, MEM_READ_ONLY); + + size_t offset = 0; + + foreach(Allocation* allocation, allocations) { + if(allocation->needs_copy_to_device) { + /* Copy from host to device. */ + opencl_device_assert(device, clEnqueueWriteBuffer(device->cqCommandQueue, + CL_MEM_PTR(new_buffer->device_pointer), + CL_FALSE, + offset, + allocation->mem->memory_size(), + (void*)allocation->mem->data_pointer, + 0, NULL, NULL + )); + + allocation->needs_copy_to_device = false; + } + else { + /* Fast copy from memory already on device. */ + opencl_device_assert(device, clEnqueueCopyBuffer(device->cqCommandQueue, + CL_MEM_PTR(buffer->device_pointer), + CL_MEM_PTR(new_buffer->device_pointer), + allocation->desc.offset, + offset, + allocation->mem->memory_size(), + 0, NULL, NULL + )); + } + + allocation->desc.offset = offset; + offset += allocation->size; + } + + device->mem_free(*buffer); + delete buffer; + + buffer = new_buffer; + } + else { + assert(total_size == buffer->data_size); + + size_t offset = 0; + + foreach(Allocation* allocation, allocations) { + if(allocation->needs_copy_to_device) { + /* Copy from host to device. */ + opencl_device_assert(device, clEnqueueWriteBuffer(device->cqCommandQueue, + CL_MEM_PTR(buffer->device_pointer), + CL_FALSE, + offset, + allocation->mem->memory_size(), + (void*)allocation->mem->data_pointer, + 0, NULL, NULL + )); + + allocation->needs_copy_to_device = false; + } + + offset += allocation->size; + } + } + + /* Not really necessary, but seems to improve responsiveness for some reason. */ + clFinish(device->cqCommandQueue); +} + +void MemoryManager::DeviceBuffer::free(OpenCLDeviceBase *device) +{ + device->mem_free(*buffer); +} + +MemoryManager::DeviceBuffer* MemoryManager::smallest_device_buffer() +{ + DeviceBuffer* smallest = device_buffers; + + foreach(DeviceBuffer& device_buffer, device_buffers) { + if(device_buffer.size < smallest->size) { + smallest = &device_buffer; + } + } + + return smallest; +} + +MemoryManager::MemoryManager(OpenCLDeviceBase *device) : device(device), need_update(false) +{ +} + +void MemoryManager::free() +{ + foreach(DeviceBuffer& device_buffer, device_buffers) { + device_buffer.free(device); + } +} + +void MemoryManager::alloc(const char *name, device_memory& mem) +{ + Allocation& allocation = allocations[name]; + + allocation.mem = &mem; + allocation.needs_copy_to_device = true; + + if(!allocation.device_buffer) { + DeviceBuffer* device_buffer = smallest_device_buffer(); + allocation.device_buffer = device_buffer; + + allocation.desc.device_buffer = device_buffer - device_buffers; + + device_buffer->add_allocation(allocation); + + device_buffer->size += mem.memory_size(); + } + + need_update = true; +} + +bool MemoryManager::free(device_memory& mem) +{ + foreach(AllocationsMap::value_type& value, allocations) { + Allocation& allocation = value.second; + if(allocation.mem == &mem) { + + allocation.device_buffer->size -= mem.memory_size(); + + allocation.mem = NULL; + allocation.needs_copy_to_device = false; + + need_update = true; + return true; + } + } + + return false; +} + +MemoryManager::BufferDescriptor MemoryManager::get_descriptor(string name) +{ + update_device_memory(); + + Allocation& allocation = allocations[name]; + return allocation.desc; +} + +void MemoryManager::update_device_memory() +{ + if(!need_update) { + return; + } + + need_update = false; + + foreach(DeviceBuffer& device_buffer, device_buffers) { + device_buffer.update_device_memory(device); + } +} + +void MemoryManager::set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg) +{ + update_device_memory(); + + foreach(DeviceBuffer& device_buffer, device_buffers) { + if(device_buffer.buffer->device_pointer) { + device->kernel_set_args(kernel, (*narg)++, *device_buffer.buffer); + } + else { + device->kernel_set_args(kernel, (*narg)++, device->null_mem); + } + } +} + +CCL_NAMESPACE_END + +#endif /* WITH_OPENCL */ + diff --git a/intern/cycles/device/opencl/memory_manager.h b/intern/cycles/device/opencl/memory_manager.h new file mode 100644 index 00000000000..3714405d026 --- /dev/null +++ b/intern/cycles/device/opencl/memory_manager.h @@ -0,0 +1,105 @@ +/* + * Copyright 2011-2017 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "device/device.h" + +#include "util/util_map.h" +#include "util/util_vector.h" +#include "util/util_string.h" + +#include "clew.h" + +CCL_NAMESPACE_BEGIN + +class OpenCLDeviceBase; + +class MemoryManager { +public: + static const int NUM_DEVICE_BUFFERS = 8; + + struct BufferDescriptor { + uint device_buffer; + cl_ulong offset; + }; + +private: + struct DeviceBuffer; + + struct Allocation { + device_memory *mem; + + DeviceBuffer *device_buffer; + size_t size; /* Size of actual allocation, may be larger than requested. */ + + BufferDescriptor desc; + + bool needs_copy_to_device; + + Allocation() : mem(NULL), device_buffer(NULL), size(0), needs_copy_to_device(false) + { + } + }; + + struct DeviceBuffer { + device_memory *buffer; + vector<Allocation*> allocations; + size_t size; /* Size of all allocations. */ + + DeviceBuffer() : buffer(new device_memory), size(0) + { + } + + ~DeviceBuffer() { + delete buffer; + buffer = NULL; + } + + void add_allocation(Allocation& allocation); + + void update_device_memory(OpenCLDeviceBase *device); + + void free(OpenCLDeviceBase *device); + }; + + OpenCLDeviceBase *device; + + DeviceBuffer device_buffers[NUM_DEVICE_BUFFERS]; + + typedef unordered_map<string, Allocation> AllocationsMap; + AllocationsMap allocations; + + bool need_update; + + DeviceBuffer* smallest_device_buffer(); + +public: + MemoryManager(OpenCLDeviceBase *device); + + void free(); /* Free all memory. */ + + void alloc(const char *name, device_memory& mem); + bool free(device_memory& mem); + + BufferDescriptor get_descriptor(string name); + + void update_device_memory(); + void set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg); +}; + +CCL_NAMESPACE_END + diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h index 78ca377d933..71483ca9159 100644 --- a/intern/cycles/device/opencl/opencl.h +++ b/intern/cycles/device/opencl/opencl.h @@ -25,6 +25,8 @@ #include "clew.h" +#include "device/opencl/memory_manager.h" + CCL_NAMESPACE_BEGIN /* Disable workarounds, seems to be working fine on latest drivers. */ @@ -224,6 +226,18 @@ public: static string get_kernel_md5(); }; +#define opencl_device_assert(device, stmt) \ + { \ + cl_int err = stmt; \ + \ + if(err != CL_SUCCESS) { \ + string message = string_printf("OpenCL error: %s in %s (%s:%d)", clewErrorString(err), #stmt, __FILE__, __LINE__); \ + if((device)->error_message() == "") \ + (device)->set_error(message); \ + fprintf(stderr, "%s\n", message.c_str()); \ + } \ + } (void)0 + #define opencl_assert(stmt) \ { \ cl_int err = stmt; \ @@ -344,6 +358,7 @@ public: size_t global_size_round_up(int group_size, int global_size); void enqueue_kernel(cl_kernel kernel, size_t w, size_t h, size_t max_workgroup_size = -1); void set_kernel_arg_mem(cl_kernel kernel, cl_uint *narg, const char *name); + void set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg); void film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half); void shader(DeviceTask& task); @@ -525,6 +540,42 @@ protected: virtual string build_options_for_base_program( const DeviceRequestedFeatures& /*requested_features*/); + +private: + MemoryManager memory_manager; + friend MemoryManager; + + struct tex_info_t { + uint buffer, padding; + cl_ulong offset; + uint width, height, depth, options; + }; + static_assert_align(tex_info_t, 16); + + vector<tex_info_t> texture_descriptors; + device_memory texture_descriptors_buffer; + + struct Texture { + Texture() {} + Texture(device_memory* mem, + InterpolationType interpolation, + ExtensionType extension) + : mem(mem), + interpolation(interpolation), + extension(extension) { + } + device_memory* mem; + InterpolationType interpolation; + ExtensionType extension; + }; + + typedef map<string, Texture> TexturesMap; + TexturesMap textures; + + bool textures_need_update; + +protected: + void flush_texture_buffers(); }; Device *opencl_create_mega_device(DeviceInfo& info, Stats& stats, bool background); diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index 509da7a0a84..7bdf81462b8 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -29,6 +29,15 @@ CCL_NAMESPACE_BEGIN +struct texture_slot_t { + texture_slot_t(const string& name, int slot) + : name(name), + slot(slot) { + } + string name; + int slot; +}; + bool OpenCLDeviceBase::opencl_error(cl_int err) { if(err != CL_SUCCESS) { @@ -63,7 +72,7 @@ void OpenCLDeviceBase::opencl_assert_err(cl_int err, const char* where) } OpenCLDeviceBase::OpenCLDeviceBase(DeviceInfo& info, Stats &stats, bool background_) -: Device(info, stats, background_) +: Device(info, stats, background_), memory_manager(this) { cpPlatform = NULL; cdDevice = NULL; @@ -71,6 +80,7 @@ OpenCLDeviceBase::OpenCLDeviceBase(DeviceInfo& info, Stats &stats, bool backgrou cqCommandQueue = NULL; null_mem = 0; device_initialized = false; + textures_need_update = true; vector<OpenCLPlatformDevice> usable_devices; OpenCLInfo::get_usable_devices(&usable_devices); @@ -126,6 +136,12 @@ OpenCLDeviceBase::OpenCLDeviceBase(DeviceInfo& info, Stats &stats, bool backgrou return; } + /* Allocate this right away so that texture_descriptors_buffer is placed at offset 0 in the device memory buffers */ + texture_descriptors.resize(1); + texture_descriptors_buffer.resize(1); + texture_descriptors_buffer.data_pointer = (device_ptr)&texture_descriptors[0]; + memory_manager.alloc("texture_descriptors", texture_descriptors_buffer); + fprintf(stderr, "Device init success\n"); device_initialized = true; } @@ -134,6 +150,8 @@ OpenCLDeviceBase::~OpenCLDeviceBase() { task_pool.stop(); + memory_manager.free(); + if(null_mem) clReleaseMemObject(CL_MEM_PTR(null_mem)); @@ -493,29 +511,35 @@ void OpenCLDeviceBase::const_copy_to(const char *name, void *host, size_t size) void OpenCLDeviceBase::tex_alloc(const char *name, device_memory& mem, - InterpolationType /*interpolation*/, - ExtensionType /*extension*/) + InterpolationType interpolation, + ExtensionType extension) { VLOG(1) << "Texture allocate: " << name << ", " << string_human_readable_number(mem.memory_size()) << " bytes. (" << string_human_readable_size(mem.memory_size()) << ")"; - mem_alloc(NULL, mem, MEM_READ_ONLY); - mem_copy_to(mem); - assert(mem_map.find(name) == mem_map.end()); - mem_map.insert(MemMap::value_type(name, mem.device_pointer)); + + memory_manager.alloc(name, mem); + /* Set the pointer to non-null to keep code that inspects its value from thinking its unallocated. */ + mem.device_pointer = 1; + textures[name] = Texture(&mem, interpolation, extension); + textures_need_update = true; } void OpenCLDeviceBase::tex_free(device_memory& mem) { if(mem.device_pointer) { - foreach(const MemMap::value_type& value, mem_map) { - if(value.second == mem.device_pointer) { - mem_map.erase(value.first); + mem.device_pointer = 0; + + if(memory_manager.free(mem)) { + textures_need_update = true; + } + + foreach(TexturesMap::value_type& value, textures) { + if(value.second.mem == &mem) { + textures.erase(value.first); break; } } - - mem_free(mem); } } @@ -581,6 +605,98 @@ void OpenCLDeviceBase::set_kernel_arg_mem(cl_kernel kernel, cl_uint *narg, const opencl_assert(clSetKernelArg(kernel, (*narg)++, sizeof(ptr), (void*)&ptr)); } +void OpenCLDeviceBase::set_kernel_arg_buffers(cl_kernel kernel, cl_uint *narg) +{ + flush_texture_buffers(); + + memory_manager.set_kernel_arg_buffers(kernel, narg); +} + +void OpenCLDeviceBase::flush_texture_buffers() +{ + if(!textures_need_update) { + return; + } + textures_need_update = false; + + /* Setup slots for textures. */ + int num_slots = 0; + + vector<texture_slot_t> texture_slots; + +#define KERNEL_TEX(type, ttype, name) \ + if(textures.find(#name) != textures.end()) { \ + texture_slots.push_back(texture_slot_t(#name, num_slots)); \ + } \ + num_slots++; +#include "kernel/kernel_textures.h" + + int num_data_slots = num_slots; + + foreach(TexturesMap::value_type& tex, textures) { + string name = tex.first; + + if(string_startswith(name, "__tex_image")) { + int pos = name.rfind("_"); + int id = atoi(name.data() + pos + 1); + texture_slots.push_back(texture_slot_t(name, + num_data_slots + id)); + num_slots = max(num_slots, num_data_slots + id + 1); + } + } + + /* Realloc texture descriptors buffer. */ + memory_manager.free(texture_descriptors_buffer); + + texture_descriptors.resize(num_slots); + texture_descriptors_buffer.resize(num_slots * sizeof(tex_info_t)); + texture_descriptors_buffer.data_pointer = (device_ptr)&texture_descriptors[0]; + + memory_manager.alloc("texture_descriptors", texture_descriptors_buffer); + + /* Fill in descriptors */ + foreach(texture_slot_t& slot, texture_slots) { + Texture& tex = textures[slot.name]; + + tex_info_t& info = texture_descriptors[slot.slot]; + + MemoryManager::BufferDescriptor desc = memory_manager.get_descriptor(slot.name); + + info.offset = desc.offset; + info.buffer = desc.device_buffer; + + if(string_startswith(slot.name, "__tex_image")) { + info.width = tex.mem->data_width; + info.height = tex.mem->data_height; + info.depth = tex.mem->data_depth; + + info.options = 0; + + if(tex.interpolation == INTERPOLATION_CLOSEST) { + info.options |= (1 << 0); + } + + switch(tex.extension) { + case EXTENSION_REPEAT: + info.options |= (1 << 1); + break; + case EXTENSION_EXTEND: + info.options |= (1 << 2); + break; + case EXTENSION_CLIP: + info.options |= (1 << 3); + break; + default: + break; + } + } + } + + /* Force write of descriptors. */ + memory_manager.free(texture_descriptors_buffer); + memory_manager.alloc("texture_descriptors", texture_descriptors_buffer); +} + void OpenCLDeviceBase::film_convert(DeviceTask& task, device_ptr buffer, device_ptr rgba_byte, device_ptr rgba_half) { /* cast arguments to cl types */ @@ -605,10 +721,7 @@ void OpenCLDeviceBase::film_convert(DeviceTask& task, device_ptr buffer, device_ d_rgba, d_buffer); -#define KERNEL_TEX(type, ttype, name) \ -set_kernel_arg_mem(ckFilmConvertKernel, &start_arg_index, #name); -#include "kernel/kernel_textures.h" -#undef KERNEL_TEX + set_kernel_arg_buffers(ckFilmConvertKernel, &start_arg_index); start_arg_index += kernel_set_args(ckFilmConvertKernel, start_arg_index, @@ -1030,10 +1143,7 @@ void OpenCLDeviceBase::shader(DeviceTask& task) d_output_luma); } -#define KERNEL_TEX(type, ttype, name) \ - set_kernel_arg_mem(kernel, &start_arg_index, #name); -#include "kernel/kernel_textures.h" -#undef KERNEL_TEX + set_kernel_arg_buffers(kernel, &start_arg_index); start_arg_index += kernel_set_args(kernel, start_arg_index, diff --git a/intern/cycles/device/opencl/opencl_mega.cpp b/intern/cycles/device/opencl/opencl_mega.cpp index 06c15bcf401..ec47fdafa3d 100644 --- a/intern/cycles/device/opencl/opencl_mega.cpp +++ b/intern/cycles/device/opencl/opencl_mega.cpp @@ -82,10 +82,7 @@ public: d_buffer, d_rng_state); -#define KERNEL_TEX(type, ttype, name) \ - set_kernel_arg_mem(ckPathTraceKernel, &start_arg_index, #name); -#include "kernel/kernel_textures.h" -#undef KERNEL_TEX + set_kernel_arg_buffers(ckPathTraceKernel, &start_arg_index); start_arg_index += kernel_set_args(ckPathTraceKernel, start_arg_index, diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp index 76d9983e9a2..16a96213100 100644 --- a/intern/cycles/device/opencl/opencl_split.cpp +++ b/intern/cycles/device/opencl/opencl_split.cpp @@ -99,6 +99,8 @@ public: void thread_run(DeviceTask *task) { + flush_texture_buffers(); + if(task->type == DeviceTask::FILM_CONVERT) { film_convert(*task, task->buffer, task->rgba_byte, task->rgba_half); } @@ -113,10 +115,19 @@ public: */ typedef struct KernelGlobals { ccl_constant KernelData *data; + ccl_global char *buffers[8]; + + typedef struct _tex_info_t { + uint buffer, padding; + uint64_t offset; + uint width, height, depth, options; + } _tex_info_t; + #define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name; + _tex_info_t name; #include "kernel/kernel_textures.h" #undef KERNEL_TEX + SplitData split_data; SplitParams split_param_data; } KernelGlobals; @@ -217,11 +228,7 @@ public: *cached_memory.ray_state, *cached_memory.rng_state); -/* TODO(sergey): Avoid map lookup here. */ -#define KERNEL_TEX(type, ttype, name) \ - device->set_kernel_arg_mem(program(), &start_arg_index, #name); -#include "kernel/kernel_textures.h" -#undef KERNEL_TEX + device->set_kernel_arg_buffers(program(), &start_arg_index); start_arg_index += device->kernel_set_args(program(), @@ -352,11 +359,7 @@ public: ray_state, rtile.rng_state); -/* TODO(sergey): Avoid map lookup here. */ -#define KERNEL_TEX(type, ttype, name) \ - device->set_kernel_arg_mem(device->program_data_init(), &start_arg_index, #name); -#include "kernel/kernel_textures.h" -#undef KERNEL_TEX + device->set_kernel_arg_buffers(device->program_data_init(), &start_arg_index); start_arg_index += device->kernel_set_args(device->program_data_init(), diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 88c4c4e3282..9fe61515570 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -202,6 +202,7 @@ set(SRC_GEOM_HEADERS geom/geom.h geom/geom_attribute.h geom/geom_curve.h + geom/geom_curve_intersect.h geom/geom_motion_curve.h geom/geom_motion_triangle.h geom/geom_motion_triangle_intersect.h diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h index 85741016b25..cf0c8542d69 100644 --- a/intern/cycles/kernel/bvh/bvh.h +++ b/intern/cycles/kernel/bvh/bvh.h @@ -233,7 +233,7 @@ ccl_device_intersect void scene_intersect_subsurface(KernelGlobals *kg, ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg, const Ray *ray, Intersection *isect, - int skip_object, + uint visibility, uint max_hits, uint *num_hits) { @@ -244,7 +244,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg, return bvh_intersect_shadow_all_hair_motion(kg, ray, isect, - skip_object, + visibility, max_hits, num_hits); } @@ -253,7 +253,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg, return bvh_intersect_shadow_all_motion(kg, ray, isect, - skip_object, + visibility, max_hits, num_hits); } @@ -264,7 +264,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg, return bvh_intersect_shadow_all_hair(kg, ray, isect, - skip_object, + visibility, max_hits, num_hits); } @@ -275,7 +275,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg, return bvh_intersect_shadow_all_instancing(kg, ray, isect, - skip_object, + visibility, max_hits, num_hits); } @@ -284,7 +284,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals *kg, return bvh_intersect_shadow_all(kg, ray, isect, - skip_object, + visibility, max_hits, num_hits); } diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h b/intern/cycles/kernel/bvh/bvh_shadow_all.h index 267e098f912..a6a4353562c 100644 --- a/intern/cycles/kernel/bvh/bvh_shadow_all.h +++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h @@ -45,7 +45,7 @@ ccl_device_inline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, const Ray *ray, Intersection *isect_array, - const int skip_object, + const uint visibility, const uint max_hits, uint *num_hits) { @@ -119,7 +119,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, idir, isect_t, node_addr, - PATH_RAY_SHADOW, + visibility, dist); #else // __KERNEL_SSE2__ traverse_mask = NODE_INTERSECT(kg, @@ -134,7 +134,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, idirsplat, shufflexyz, node_addr, - PATH_RAY_SHADOW, + visibility, dist); #endif // __KERNEL_SSE2__ @@ -186,17 +186,6 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, /* primitive intersection */ while(prim_addr < prim_addr2) { kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type); - -#ifdef __SHADOW_TRICKS__ - uint tri_object = (object == OBJECT_NONE) - ? kernel_tex_fetch(__prim_object, prim_addr) - : object; - if(tri_object == skip_object) { - ++prim_addr; - continue; - } -#endif - bool hit; /* todo: specialized intersect functions which don't fill in @@ -209,7 +198,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, isect_array, P, dir, - PATH_RAY_SHADOW, + visibility, object, prim_addr); break; @@ -221,7 +210,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, P, dir, ray->time, - PATH_RAY_SHADOW, + visibility, object, prim_addr); break; @@ -232,30 +221,30 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, case PRIMITIVE_MOTION_CURVE: { const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr); if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { - hit = bvh_cardinal_curve_intersect(kg, - isect_array, - P, - dir, - PATH_RAY_SHADOW, - object, - prim_addr, - ray->time, - curve_type, - NULL, - 0, 0); + hit = cardinal_curve_intersect(kg, + isect_array, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + NULL, + 0, 0); } else { - hit = bvh_curve_intersect(kg, - isect_array, - P, - dir, - PATH_RAY_SHADOW, - object, - prim_addr, - ray->time, - curve_type, - NULL, - 0, 0); + hit = curve_intersect(kg, + isect_array, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + NULL, + 0, 0); } break; } @@ -402,7 +391,7 @@ bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersection *isect_array, - const int skip_object, + const uint visibility, const uint max_hits, uint *num_hits) { @@ -411,7 +400,7 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg, return BVH_FUNCTION_FULL_NAME(QBVH)(kg, ray, isect_array, - skip_object, + visibility, max_hits, num_hits); } @@ -422,7 +411,7 @@ ccl_device_inline bool BVH_FUNCTION_NAME(KernelGlobals *kg, return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect_array, - skip_object, + visibility, max_hits, num_hits); } diff --git a/intern/cycles/kernel/bvh/bvh_traversal.h b/intern/cycles/kernel/bvh/bvh_traversal.h index c58d3b0316c..ae8f54821f2 100644 --- a/intern/cycles/kernel/bvh/bvh_traversal.h +++ b/intern/cycles/kernel/bvh/bvh_traversal.h @@ -244,14 +244,14 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, { /* shadow ray early termination */ #if defined(__KERNEL_SSE2__) - if(visibility == PATH_RAY_SHADOW_OPAQUE) + if(visibility & PATH_RAY_SHADOW_OPAQUE) return true; tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t); # if BVH_FEATURE(BVH_HAIR) tfar = ssef(isect->t); # endif #else - if(visibility == PATH_RAY_SHADOW_OPAQUE) + if(visibility & PATH_RAY_SHADOW_OPAQUE) return true; #endif } @@ -274,14 +274,14 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, { /* shadow ray early termination */ # if defined(__KERNEL_SSE2__) - if(visibility == PATH_RAY_SHADOW_OPAQUE) + if(visibility & PATH_RAY_SHADOW_OPAQUE) return true; tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t); # if BVH_FEATURE(BVH_HAIR) tfar = ssef(isect->t); # endif # else - if(visibility == PATH_RAY_SHADOW_OPAQUE) + if(visibility & PATH_RAY_SHADOW_OPAQUE) return true; # endif } @@ -298,44 +298,44 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL)); bool hit; if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { - hit = bvh_cardinal_curve_intersect(kg, - isect, - P, - dir, - visibility, - object, - prim_addr, - ray->time, - curve_type, - lcg_state, - difl, - extmax); + hit = cardinal_curve_intersect(kg, + isect, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + lcg_state, + difl, + extmax); } else { - hit = bvh_curve_intersect(kg, - isect, - P, - dir, - visibility, - object, - prim_addr, - ray->time, - curve_type, - lcg_state, - difl, - extmax); + hit = curve_intersect(kg, + isect, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + lcg_state, + difl, + extmax); } if(hit) { /* shadow ray early termination */ # if defined(__KERNEL_SSE2__) - if(visibility == PATH_RAY_SHADOW_OPAQUE) + if(visibility & PATH_RAY_SHADOW_OPAQUE) return true; tsplat = ssef(0.0f, 0.0f, -isect->t, -isect->t); # if BVH_FEATURE(BVH_HAIR) tfar = ssef(isect->t); # endif # else - if(visibility == PATH_RAY_SHADOW_OPAQUE) + if(visibility & PATH_RAY_SHADOW_OPAQUE) return true; # endif } diff --git a/intern/cycles/kernel/bvh/qbvh_shadow_all.h b/intern/cycles/kernel/bvh/qbvh_shadow_all.h index ce474438f2c..522213f30ca 100644 --- a/intern/cycles/kernel/bvh/qbvh_shadow_all.h +++ b/intern/cycles/kernel/bvh/qbvh_shadow_all.h @@ -33,7 +33,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, const Ray *ray, Intersection *isect_array, - const int skip_object, + const uint visibility, const uint max_hits, uint *num_hits) { @@ -107,7 +107,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, if(false #ifdef __VISIBILITY_FLAG__ - || ((__float_as_uint(inodes.x) & PATH_RAY_SHADOW) == 0) + || ((__float_as_uint(inodes.x) & visibility) == 0) #endif #if BVH_FEATURE(BVH_MOTION) || UNLIKELY(ray->time < inodes.y) @@ -244,7 +244,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, if(node_addr < 0) { float4 leaf = kernel_tex_fetch(__bvh_leaf_nodes, (-node_addr-1)); #ifdef __VISIBILITY_FLAG__ - if((__float_as_uint(leaf.z) & PATH_RAY_SHADOW) == 0) { + if((__float_as_uint(leaf.z) & visibility) == 0) { /* Pop. */ node_addr = traversal_stack[stack_ptr].addr; --stack_ptr; @@ -268,17 +268,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, /* Primitive intersection. */ while(prim_addr < prim_addr2) { kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == p_type); - -#ifdef __SHADOW_TRICKS__ - uint tri_object = (object == OBJECT_NONE) - ? kernel_tex_fetch(__prim_object, prim_addr) - : object; - if(tri_object == skip_object) { - ++prim_addr; - continue; - } -#endif - bool hit; /* todo: specialized intersect functions which don't fill in @@ -291,7 +280,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, isect_array, P, dir, - PATH_RAY_SHADOW, + visibility, object, prim_addr); break; @@ -303,7 +292,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, P, dir, ray->time, - PATH_RAY_SHADOW, + visibility, object, prim_addr); break; @@ -314,30 +303,30 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, case PRIMITIVE_MOTION_CURVE: { const uint curve_type = kernel_tex_fetch(__prim_type, prim_addr); if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { - hit = bvh_cardinal_curve_intersect(kg, - isect_array, - P, - dir, - PATH_RAY_SHADOW, - object, - prim_addr, - ray->time, - curve_type, - NULL, - 0, 0); + hit = cardinal_curve_intersect(kg, + isect_array, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + NULL, + 0, 0); } else { - hit = bvh_curve_intersect(kg, - isect_array, - P, - dir, - PATH_RAY_SHADOW, - object, - prim_addr, - ray->time, - curve_type, - NULL, - 0, 0); + hit = curve_intersect(kg, + isect_array, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + NULL, + 0, 0); } break; } diff --git a/intern/cycles/kernel/bvh/qbvh_traversal.h b/intern/cycles/kernel/bvh/qbvh_traversal.h index fca75a1d416..335a4afd47a 100644 --- a/intern/cycles/kernel/bvh/qbvh_traversal.h +++ b/intern/cycles/kernel/bvh/qbvh_traversal.h @@ -340,7 +340,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, prim_addr)) { tfar = ssef(isect->t); /* Shadow ray early termination. */ - if(visibility == PATH_RAY_SHADOW_OPAQUE) { + if(visibility & PATH_RAY_SHADOW_OPAQUE) { return true; } } @@ -362,7 +362,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, prim_addr)) { tfar = ssef(isect->t); /* Shadow ray early termination. */ - if(visibility == PATH_RAY_SHADOW_OPAQUE) { + if(visibility & PATH_RAY_SHADOW_OPAQUE) { return true; } } @@ -379,37 +379,37 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, kernel_assert((curve_type & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL)); bool hit; if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) { - hit = bvh_cardinal_curve_intersect(kg, - isect, - P, - dir, - visibility, - object, - prim_addr, - ray->time, - curve_type, - lcg_state, - difl, - extmax); + hit = cardinal_curve_intersect(kg, + isect, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + lcg_state, + difl, + extmax); } else { - hit = bvh_curve_intersect(kg, - isect, - P, - dir, - visibility, - object, - prim_addr, - ray->time, - curve_type, - lcg_state, - difl, - extmax); + hit = curve_intersect(kg, + isect, + P, + dir, + visibility, + object, + prim_addr, + ray->time, + curve_type, + lcg_state, + difl, + extmax); } if(hit) { tfar = ssef(isect->t); /* Shadow ray early termination. */ - if(visibility == PATH_RAY_SHADOW_OPAQUE) { + if(visibility & PATH_RAY_SHADOW_OPAQUE) { return true; } } diff --git a/intern/cycles/kernel/geom/geom.h b/intern/cycles/kernel/geom/geom.h index c623e3490fd..f34b77ebc07 100644 --- a/intern/cycles/kernel/geom/geom.h +++ b/intern/cycles/kernel/geom/geom.h @@ -27,6 +27,7 @@ #include "kernel/geom/geom_motion_triangle_shader.h" #include "kernel/geom/geom_motion_curve.h" #include "kernel/geom/geom_curve.h" +#include "kernel/geom/geom_curve_intersect.h" #include "kernel/geom/geom_volume.h" #include "kernel/geom/geom_primitive.h" diff --git a/intern/cycles/kernel/geom/geom_curve.h b/intern/cycles/kernel/geom/geom_curve.h index 5c3b0ee3c15..e35267f02bf 100644 --- a/intern/cycles/kernel/geom/geom_curve.h +++ b/intern/cycles/kernel/geom/geom_curve.h @@ -16,18 +16,13 @@ CCL_NAMESPACE_BEGIN /* Curve Primitive * - * Curve primitive for rendering hair and fur. These can be render as flat ribbons - * or curves with actual thickness. The curve can also be rendered as line segments - * rather than curves for better performance */ + * Curve primitive for rendering hair and fur. These can be render as flat + * ribbons or curves with actual thickness. The curve can also be rendered as + * line segments rather than curves for better performance. + */ #ifdef __HAIR__ -#if defined(__KERNEL_CUDA__) && (__CUDA_ARCH__ < 300) -# define ccl_device_curveintersect ccl_device -#else -# define ccl_device_curveintersect ccl_device_forceinline -#endif - /* Reading attributes on various curve elements */ ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy) @@ -151,7 +146,7 @@ ccl_device float3 curve_motion_center_location(KernelGlobals *kg, ShaderData *sd /* Curve tangent normal */ ccl_device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd) -{ +{ float3 tgN = make_float3(0.0f,0.0f,0.0f); if(sd->type & PRIMITIVE_ALL_CURVE) { @@ -219,893 +214,6 @@ ccl_device_inline void curvebounds(float *lower, float *upper, float *extremta, } } -#ifdef __KERNEL_SSE2__ -ccl_device_inline ssef transform_point_T3(const ssef t[3], const ssef &a) -{ - return madd(shuffle<0>(a), t[0], madd(shuffle<1>(a), t[1], shuffle<2>(a) * t[2])); -} -#endif - -#ifdef __KERNEL_SSE2__ -/* Pass P and dir by reference to aligned vector */ -ccl_device_curveintersect bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect, - const float3 &P, const float3 &dir, uint visibility, int object, int curveAddr, float time, int type, uint *lcg_state, float difl, float extmax) -#else -ccl_device_curveintersect bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect, - float3 P, float3 dir, uint visibility, int object, int curveAddr, float time,int type, uint *lcg_state, float difl, float extmax) -#endif -{ - const bool is_curve_primitive = (type & PRIMITIVE_CURVE); - - if(!is_curve_primitive && kernel_data.bvh.use_bvh_steps) { - const float2 prim_time = kernel_tex_fetch(__prim_time, curveAddr); - if(time < prim_time.x || time > prim_time.y) { - return false; - } - } - - int segment = PRIMITIVE_UNPACK_SEGMENT(type); - float epsilon = 0.0f; - float r_st, r_en; - - int depth = kernel_data.curve.subdivisions; - int flags = kernel_data.curve.curveflags; - int prim = kernel_tex_fetch(__prim_index, curveAddr); - -#ifdef __KERNEL_SSE2__ - ssef vdir = load4f(dir); - ssef vcurve_coef[4]; - const float3 *curve_coef = (float3 *)vcurve_coef; - - { - ssef dtmp = vdir * vdir; - ssef d_ss = mm_sqrt(dtmp + shuffle<2>(dtmp)); - ssef rd_ss = load1f_first(1.0f) / d_ss; - - ssei v00vec = load4i((ssei *)&kg->__curves.data[prim]); - int2 &v00 = (int2 &)v00vec; - - int k0 = v00.x + segment; - int k1 = k0 + 1; - int ka = max(k0 - 1, v00.x); - int kb = min(k1 + 1, v00.x + v00.y - 1); - -#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && (!defined(_MSC_VER) || _MSC_VER > 1800) - avxf P_curve_0_1, P_curve_2_3; - if(is_curve_primitive) { - P_curve_0_1 = _mm256_loadu2_m128(&kg->__curve_keys.data[k0].x, &kg->__curve_keys.data[ka].x); - P_curve_2_3 = _mm256_loadu2_m128(&kg->__curve_keys.data[kb].x, &kg->__curve_keys.data[k1].x); - } - else { - int fobject = (object == OBJECT_NONE) ? kernel_tex_fetch(__prim_object, curveAddr) : object; - motion_cardinal_curve_keys_avx(kg, fobject, prim, time, ka, k0, k1, kb, &P_curve_0_1,&P_curve_2_3); - } -#else /* __KERNEL_AVX2__ */ - ssef P_curve[4]; - - if(is_curve_primitive) { - P_curve[0] = load4f(&kg->__curve_keys.data[ka].x); - P_curve[1] = load4f(&kg->__curve_keys.data[k0].x); - P_curve[2] = load4f(&kg->__curve_keys.data[k1].x); - P_curve[3] = load4f(&kg->__curve_keys.data[kb].x); - } - else { - int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object; - motion_cardinal_curve_keys(kg, fobject, prim, time, ka, k0, k1, kb, (float4*)&P_curve); - } -#endif /* __KERNEL_AVX2__ */ - - ssef rd_sgn = set_sign_bit<0, 1, 1, 1>(shuffle<0>(rd_ss)); - ssef mul_zxxy = shuffle<2, 0, 0, 1>(vdir) * rd_sgn; - ssef mul_yz = shuffle<1, 2, 1, 2>(vdir) * mul_zxxy; - ssef mul_shuf = shuffle<0, 1, 2, 3>(mul_zxxy, mul_yz); - ssef vdir0 = vdir & cast(ssei(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0)); - - ssef htfm0 = shuffle<0, 2, 0, 3>(mul_shuf, vdir0); - ssef htfm1 = shuffle<1, 0, 1, 3>(load1f_first(extract<0>(d_ss)), vdir0); - ssef htfm2 = shuffle<1, 3, 2, 3>(mul_shuf, vdir0); - -#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && (!defined(_MSC_VER) || _MSC_VER > 1800) - const avxf vPP = _mm256_broadcast_ps(&P.m128); - const avxf htfm00 = avxf(htfm0.m128, htfm0.m128); - const avxf htfm11 = avxf(htfm1.m128, htfm1.m128); - const avxf htfm22 = avxf(htfm2.m128, htfm2.m128); - - const avxf p01 = madd(shuffle<0>(P_curve_0_1 - vPP), - htfm00, - madd(shuffle<1>(P_curve_0_1 - vPP), - htfm11, - shuffle<2>(P_curve_0_1 - vPP) * htfm22)); - const avxf p23 = madd(shuffle<0>(P_curve_2_3 - vPP), - htfm00, - madd(shuffle<1>(P_curve_2_3 - vPP), - htfm11, - shuffle<2>(P_curve_2_3 - vPP)*htfm22)); - - const ssef p0 = _mm256_castps256_ps128(p01); - const ssef p1 = _mm256_extractf128_ps(p01, 1); - const ssef p2 = _mm256_castps256_ps128(p23); - const ssef p3 = _mm256_extractf128_ps(p23, 1); - - const ssef P_curve_1 = _mm256_extractf128_ps(P_curve_0_1, 1); - r_st = ((float4 &)P_curve_1).w; - const ssef P_curve_2 = _mm256_castps256_ps128(P_curve_2_3); - r_en = ((float4 &)P_curve_2).w; -#else /* __KERNEL_AVX2__ */ - ssef htfm[] = { htfm0, htfm1, htfm2 }; - ssef vP = load4f(P); - ssef p0 = transform_point_T3(htfm, P_curve[0] - vP); - ssef p1 = transform_point_T3(htfm, P_curve[1] - vP); - ssef p2 = transform_point_T3(htfm, P_curve[2] - vP); - ssef p3 = transform_point_T3(htfm, P_curve[3] - vP); - - r_st = ((float4 &)P_curve[1]).w; - r_en = ((float4 &)P_curve[2]).w; -#endif /* __KERNEL_AVX2__ */ - - float fc = 0.71f; - ssef vfc = ssef(fc); - ssef vfcxp3 = vfc * p3; - - vcurve_coef[0] = p1; - vcurve_coef[1] = vfc * (p2 - p0); - vcurve_coef[2] = madd(ssef(fc * 2.0f), p0, madd(ssef(fc - 3.0f), p1, msub(ssef(3.0f - 2.0f * fc), p2, vfcxp3))); - vcurve_coef[3] = msub(ssef(fc - 2.0f), p2 - p1, msub(vfc, p0, vfcxp3)); - - } -#else - float3 curve_coef[4]; - - /* curve Intersection check */ - /* obtain curve parameters */ - { - /* ray transform created - this should be created at beginning of intersection loop */ - Transform htfm; - float d = sqrtf(dir.x * dir.x + dir.z * dir.z); - htfm = make_transform( - dir.z / d, 0, -dir.x /d, 0, - -dir.x * dir.y /d, d, -dir.y * dir.z /d, 0, - dir.x, dir.y, dir.z, 0, - 0, 0, 0, 1); - - float4 v00 = kernel_tex_fetch(__curves, prim); - - int k0 = __float_as_int(v00.x) + segment; - int k1 = k0 + 1; - - int ka = max(k0 - 1,__float_as_int(v00.x)); - int kb = min(k1 + 1,__float_as_int(v00.x) + __float_as_int(v00.y) - 1); - - float4 P_curve[4]; - - if(is_curve_primitive) { - P_curve[0] = kernel_tex_fetch(__curve_keys, ka); - P_curve[1] = kernel_tex_fetch(__curve_keys, k0); - P_curve[2] = kernel_tex_fetch(__curve_keys, k1); - P_curve[3] = kernel_tex_fetch(__curve_keys, kb); - } - else { - int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object; - motion_cardinal_curve_keys(kg, fobject, prim, time, ka, k0, k1, kb, P_curve); - } - - float3 p0 = transform_point(&htfm, float4_to_float3(P_curve[0]) - P); - float3 p1 = transform_point(&htfm, float4_to_float3(P_curve[1]) - P); - float3 p2 = transform_point(&htfm, float4_to_float3(P_curve[2]) - P); - float3 p3 = transform_point(&htfm, float4_to_float3(P_curve[3]) - P); - - float fc = 0.71f; - curve_coef[0] = p1; - curve_coef[1] = -fc*p0 + fc*p2; - curve_coef[2] = 2.0f * fc * p0 + (fc - 3.0f) * p1 + (3.0f - 2.0f * fc) * p2 - fc * p3; - curve_coef[3] = -fc * p0 + (2.0f - fc) * p1 + (fc - 2.0f) * p2 + fc * p3; - r_st = P_curve[1].w; - r_en = P_curve[2].w; - } -#endif - - float r_curr = max(r_st, r_en); - - if((flags & CURVE_KN_RIBBONS) || !(flags & CURVE_KN_BACKFACING)) - epsilon = 2 * r_curr; - - /* find bounds - this is slow for cubic curves */ - float upper, lower; - - float zextrem[4]; - curvebounds(&lower, &upper, &zextrem[0], &zextrem[1], &zextrem[2], &zextrem[3], curve_coef[0].z, curve_coef[1].z, curve_coef[2].z, curve_coef[3].z); - if(lower - r_curr > isect->t || upper + r_curr < epsilon) - return false; - - /* minimum width extension */ - float mw_extension = min(difl * fabsf(upper), extmax); - float r_ext = mw_extension + r_curr; - - float xextrem[4]; - curvebounds(&lower, &upper, &xextrem[0], &xextrem[1], &xextrem[2], &xextrem[3], curve_coef[0].x, curve_coef[1].x, curve_coef[2].x, curve_coef[3].x); - if(lower > r_ext || upper < -r_ext) - return false; - - float yextrem[4]; - curvebounds(&lower, &upper, &yextrem[0], &yextrem[1], &yextrem[2], &yextrem[3], curve_coef[0].y, curve_coef[1].y, curve_coef[2].y, curve_coef[3].y); - if(lower > r_ext || upper < -r_ext) - return false; - - /* setup recurrent loop */ - int level = 1 << depth; - int tree = 0; - float resol = 1.0f / (float)level; - bool hit = false; - - /* begin loop */ - while(!(tree >> (depth))) { - const float i_st = tree * resol; - const float i_en = i_st + (level * resol); - -#ifdef __KERNEL_SSE2__ - ssef vi_st = ssef(i_st), vi_en = ssef(i_en); - ssef vp_st = madd(madd(madd(vcurve_coef[3], vi_st, vcurve_coef[2]), vi_st, vcurve_coef[1]), vi_st, vcurve_coef[0]); - ssef vp_en = madd(madd(madd(vcurve_coef[3], vi_en, vcurve_coef[2]), vi_en, vcurve_coef[1]), vi_en, vcurve_coef[0]); - - ssef vbmin = min(vp_st, vp_en); - ssef vbmax = max(vp_st, vp_en); - - float3 &bmin = (float3 &)vbmin, &bmax = (float3 &)vbmax; - float &bminx = bmin.x, &bminy = bmin.y, &bminz = bmin.z; - float &bmaxx = bmax.x, &bmaxy = bmax.y, &bmaxz = bmax.z; - float3 &p_st = (float3 &)vp_st, &p_en = (float3 &)vp_en; -#else - float3 p_st = ((curve_coef[3] * i_st + curve_coef[2]) * i_st + curve_coef[1]) * i_st + curve_coef[0]; - float3 p_en = ((curve_coef[3] * i_en + curve_coef[2]) * i_en + curve_coef[1]) * i_en + curve_coef[0]; - - float bminx = min(p_st.x, p_en.x); - float bmaxx = max(p_st.x, p_en.x); - float bminy = min(p_st.y, p_en.y); - float bmaxy = max(p_st.y, p_en.y); - float bminz = min(p_st.z, p_en.z); - float bmaxz = max(p_st.z, p_en.z); -#endif - - if(xextrem[0] >= i_st && xextrem[0] <= i_en) { - bminx = min(bminx,xextrem[1]); - bmaxx = max(bmaxx,xextrem[1]); - } - if(xextrem[2] >= i_st && xextrem[2] <= i_en) { - bminx = min(bminx,xextrem[3]); - bmaxx = max(bmaxx,xextrem[3]); - } - if(yextrem[0] >= i_st && yextrem[0] <= i_en) { - bminy = min(bminy,yextrem[1]); - bmaxy = max(bmaxy,yextrem[1]); - } - if(yextrem[2] >= i_st && yextrem[2] <= i_en) { - bminy = min(bminy,yextrem[3]); - bmaxy = max(bmaxy,yextrem[3]); - } - if(zextrem[0] >= i_st && zextrem[0] <= i_en) { - bminz = min(bminz,zextrem[1]); - bmaxz = max(bmaxz,zextrem[1]); - } - if(zextrem[2] >= i_st && zextrem[2] <= i_en) { - bminz = min(bminz,zextrem[3]); - bmaxz = max(bmaxz,zextrem[3]); - } - - float r1 = r_st + (r_en - r_st) * i_st; - float r2 = r_st + (r_en - r_st) * i_en; - r_curr = max(r1, r2); - - mw_extension = min(difl * fabsf(bmaxz), extmax); - float r_ext = mw_extension + r_curr; - float coverage = 1.0f; - - if(bminz - r_curr > isect->t || bmaxz + r_curr < epsilon || bminx > r_ext|| bmaxx < -r_ext|| bminy > r_ext|| bmaxy < -r_ext) { - /* the bounding box does not overlap the square centered at O */ - tree += level; - level = tree & -tree; - } - else if(level == 1) { - - /* the maximum recursion depth is reached. - * check if dP0.(Q-P0)>=0 and dPn.(Pn-Q)>=0. - * dP* is reversed if necessary.*/ - float t = isect->t; - float u = 0.0f; - float gd = 0.0f; - - if(flags & CURVE_KN_RIBBONS) { - float3 tg = (p_en - p_st); -#ifdef __KERNEL_SSE__ - const float3 tg_sq = tg * tg; - float w = tg_sq.x + tg_sq.y; -#else - float w = tg.x * tg.x + tg.y * tg.y; -#endif - if(w == 0) { - tree++; - level = tree & -tree; - continue; - } -#ifdef __KERNEL_SSE__ - const float3 p_sttg = p_st * tg; - w = -(p_sttg.x + p_sttg.y) / w; -#else - w = -(p_st.x * tg.x + p_st.y * tg.y) / w; -#endif - w = saturate(w); - - /* compute u on the curve segment */ - u = i_st * (1 - w) + i_en * w; - r_curr = r_st + (r_en - r_st) * u; - /* compare x-y distances */ - float3 p_curr = ((curve_coef[3] * u + curve_coef[2]) * u + curve_coef[1]) * u + curve_coef[0]; - - float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1]; - if(dot(tg, dp_st)< 0) - dp_st *= -1; - if(dot(dp_st, -p_st) + p_curr.z * dp_st.z < 0) { - tree++; - level = tree & -tree; - continue; - } - float3 dp_en = (3 * curve_coef[3] * i_en + 2 * curve_coef[2]) * i_en + curve_coef[1]; - if(dot(tg, dp_en) < 0) - dp_en *= -1; - if(dot(dp_en, p_en) - p_curr.z * dp_en.z < 0) { - tree++; - level = tree & -tree; - continue; - } - - /* compute coverage */ - float r_ext = r_curr; - coverage = 1.0f; - if(difl != 0.0f) { - mw_extension = min(difl * fabsf(bmaxz), extmax); - r_ext = mw_extension + r_curr; -#ifdef __KERNEL_SSE__ - const float3 p_curr_sq = p_curr * p_curr; - const float3 dxxx(_mm_sqrt_ss(_mm_hadd_ps(p_curr_sq.m128, p_curr_sq.m128))); - float d = dxxx.x; -#else - float d = sqrtf(p_curr.x * p_curr.x + p_curr.y * p_curr.y); -#endif - float d0 = d - r_curr; - float d1 = d + r_curr; - float inv_mw_extension = 1.0f/mw_extension; - if(d0 >= 0) - coverage = (min(d1 * inv_mw_extension, 1.0f) - min(d0 * inv_mw_extension, 1.0f)) * 0.5f; - else // inside - coverage = (min(d1 * inv_mw_extension, 1.0f) + min(-d0 * inv_mw_extension, 1.0f)) * 0.5f; - } - - if(p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon || isect->t < p_curr.z) { - tree++; - level = tree & -tree; - continue; - } - - t = p_curr.z; - - /* stochastic fade from minimum width */ - if(difl != 0.0f && lcg_state) { - if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage)) - return hit; - } - } - else { - float l = len(p_en - p_st); - /* minimum width extension */ - float or1 = r1; - float or2 = r2; - - if(difl != 0.0f) { - mw_extension = min(len(p_st - P) * difl, extmax); - or1 = r1 < mw_extension ? mw_extension : r1; - mw_extension = min(len(p_en - P) * difl, extmax); - or2 = r2 < mw_extension ? mw_extension : r2; - } - /* --- */ - float invl = 1.0f/l; - float3 tg = (p_en - p_st) * invl; - gd = (or2 - or1) * invl; - float difz = -dot(p_st,tg); - float cyla = 1.0f - (tg.z * tg.z * (1 + gd*gd)); - float invcyla = 1.0f/cyla; - float halfb = (-p_st.z - tg.z*(difz + gd*(difz*gd + or1))); - float tcentre = -halfb*invcyla; - float zcentre = difz + (tg.z * tcentre); - float3 tdif = - p_st; - tdif.z += tcentre; - float tdifz = dot(tdif,tg); - float tb = 2*(tdif.z - tg.z*(tdifz + gd*(tdifz*gd + or1))); - float tc = dot(tdif,tdif) - tdifz * tdifz * (1 + gd*gd) - or1*or1 - 2*or1*tdifz*gd; - float td = tb*tb - 4*cyla*tc; - if(td < 0.0f) { - tree++; - level = tree & -tree; - continue; - } - - float rootd = sqrtf(td); - float correction = (-tb - rootd) * 0.5f * invcyla; - t = tcentre + correction; - - float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1]; - if(dot(tg, dp_st)< 0) - dp_st *= -1; - float3 dp_en = (3 * curve_coef[3] * i_en + 2 * curve_coef[2]) * i_en + curve_coef[1]; - if(dot(tg, dp_en) < 0) - dp_en *= -1; - - if(flags & CURVE_KN_BACKFACING && (dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f)) { - correction = (-tb + rootd) * 0.5f * invcyla; - t = tcentre + correction; - } - - if(dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f) { - tree++; - level = tree & -tree; - continue; - } - - float w = (zcentre + (tg.z * correction)) * invl; - w = saturate(w); - /* compute u on the curve segment */ - u = i_st * (1 - w) + i_en * w; - - /* stochastic fade from minimum width */ - if(difl != 0.0f && lcg_state) { - r_curr = r1 + (r2 - r1) * w; - r_ext = or1 + (or2 - or1) * w; - coverage = r_curr/r_ext; - - if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage)) - return hit; - } - } - /* we found a new intersection */ - -#ifdef __VISIBILITY_FLAG__ - /* visibility flag test. we do it here under the assumption - * that most triangles are culled by node flags */ - if(kernel_tex_fetch(__prim_visibility, curveAddr) & visibility) -#endif - { - /* record intersection */ - isect->t = t; - isect->u = u; - isect->v = gd; - isect->prim = curveAddr; - isect->object = object; - isect->type = type; - hit = true; - } - - tree++; - level = tree & -tree; - } - else { - /* split the curve into two curves and process */ - level = level >> 1; - } - } - - return hit; -} - -ccl_device_curveintersect bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect, - float3 P, float3 direction, uint visibility, int object, int curveAddr, float time, int type, uint *lcg_state, float difl, float extmax) -{ - /* define few macros to minimize code duplication for SSE */ -#ifndef __KERNEL_SSE2__ -# define len3_squared(x) len_squared(x) -# define len3(x) len(x) -# define dot3(x, y) dot(x, y) -#endif - - const bool is_curve_primitive = (type & PRIMITIVE_CURVE); - - if(!is_curve_primitive && kernel_data.bvh.use_bvh_steps) { - const float2 prim_time = kernel_tex_fetch(__prim_time, curveAddr); - if(time < prim_time.x || time > prim_time.y) { - return false; - } - } - - int segment = PRIMITIVE_UNPACK_SEGMENT(type); - /* curve Intersection check */ - int flags = kernel_data.curve.curveflags; - - int prim = kernel_tex_fetch(__prim_index, curveAddr); - float4 v00 = kernel_tex_fetch(__curves, prim); - - int cnum = __float_as_int(v00.x); - int k0 = cnum + segment; - int k1 = k0 + 1; - -#ifndef __KERNEL_SSE2__ - float4 P_curve[2]; - - if(is_curve_primitive) { - P_curve[0] = kernel_tex_fetch(__curve_keys, k0); - P_curve[1] = kernel_tex_fetch(__curve_keys, k1); - } - else { - int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object; - motion_curve_keys(kg, fobject, prim, time, k0, k1, P_curve); - } - - float or1 = P_curve[0].w; - float or2 = P_curve[1].w; - float3 p1 = float4_to_float3(P_curve[0]); - float3 p2 = float4_to_float3(P_curve[1]); - - /* minimum width extension */ - float r1 = or1; - float r2 = or2; - float3 dif = P - p1; - float3 dif_second = P - p2; - if(difl != 0.0f) { - float pixelsize = min(len3(dif) * difl, extmax); - r1 = or1 < pixelsize ? pixelsize : or1; - pixelsize = min(len3(dif_second) * difl, extmax); - r2 = or2 < pixelsize ? pixelsize : or2; - } - /* --- */ - - float3 p21_diff = p2 - p1; - float3 sphere_dif1 = (dif + dif_second) * 0.5f; - float3 dir = direction; - float sphere_b_tmp = dot3(dir, sphere_dif1); - float3 sphere_dif2 = sphere_dif1 - sphere_b_tmp * dir; -#else - ssef P_curve[2]; - - if(is_curve_primitive) { - P_curve[0] = load4f(&kg->__curve_keys.data[k0].x); - P_curve[1] = load4f(&kg->__curve_keys.data[k1].x); - } - else { - int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object; - motion_curve_keys(kg, fobject, prim, time, k0, k1, (float4*)&P_curve); - } - - const ssef or12 = shuffle<3, 3, 3, 3>(P_curve[0], P_curve[1]); - - ssef r12 = or12; - const ssef vP = load4f(P); - const ssef dif = vP - P_curve[0]; - const ssef dif_second = vP - P_curve[1]; - if(difl != 0.0f) { - const ssef len1_sq = len3_squared_splat(dif); - const ssef len2_sq = len3_squared_splat(dif_second); - const ssef len12 = mm_sqrt(shuffle<0, 0, 0, 0>(len1_sq, len2_sq)); - const ssef pixelsize12 = min(len12 * difl, ssef(extmax)); - r12 = max(or12, pixelsize12); - } - float or1 = extract<0>(or12), or2 = extract<0>(shuffle<2>(or12)); - float r1 = extract<0>(r12), r2 = extract<0>(shuffle<2>(r12)); - - const ssef p21_diff = P_curve[1] - P_curve[0]; - const ssef sphere_dif1 = (dif + dif_second) * 0.5f; - const ssef dir = load4f(direction); - const ssef sphere_b_tmp = dot3_splat(dir, sphere_dif1); - const ssef sphere_dif2 = nmadd(sphere_b_tmp, dir, sphere_dif1); -#endif - - float mr = max(r1, r2); - float l = len3(p21_diff); - float invl = 1.0f / l; - float sp_r = mr + 0.5f * l; - - float sphere_b = dot3(dir, sphere_dif2); - float sdisc = sphere_b * sphere_b - len3_squared(sphere_dif2) + sp_r * sp_r; - - if(sdisc < 0.0f) - return false; - - /* obtain parameters and test midpoint distance for suitable modes */ -#ifndef __KERNEL_SSE2__ - float3 tg = p21_diff * invl; -#else - const ssef tg = p21_diff * invl; -#endif - float gd = (r2 - r1) * invl; - - float dirz = dot3(dir, tg); - float difz = dot3(dif, tg); - - float a = 1.0f - (dirz*dirz*(1 + gd*gd)); - - float halfb = dot3(dir, dif) - dirz*(difz + gd*(difz*gd + r1)); - - float tcentre = -halfb/a; - float zcentre = difz + (dirz * tcentre); - - if((tcentre > isect->t) && !(flags & CURVE_KN_ACCURATE)) - return false; - if((zcentre < 0 || zcentre > l) && !(flags & CURVE_KN_ACCURATE) && !(flags & CURVE_KN_INTERSECTCORRECTION)) - return false; - - /* test minimum separation */ -#ifndef __KERNEL_SSE2__ - float3 cprod = cross(tg, dir); - float cprod2sq = len3_squared(cross(tg, dif)); -#else - const ssef cprod = cross(tg, dir); - float cprod2sq = len3_squared(cross_zxy(tg, dif)); -#endif - float cprodsq = len3_squared(cprod); - float distscaled = dot3(cprod, dif); - - if(cprodsq == 0) - distscaled = cprod2sq; - else - distscaled = (distscaled*distscaled)/cprodsq; - - if(distscaled > mr*mr) - return false; - - /* calculate true intersection */ -#ifndef __KERNEL_SSE2__ - float3 tdif = dif + tcentre * dir; -#else - const ssef tdif = madd(ssef(tcentre), dir, dif); -#endif - float tdifz = dot3(tdif, tg); - float tdifma = tdifz*gd + r1; - float tb = 2*(dot3(dir, tdif) - dirz*(tdifz + gd*tdifma)); - float tc = dot3(tdif, tdif) - tdifz*tdifz - tdifma*tdifma; - float td = tb*tb - 4*a*tc; - - if(td < 0.0f) - return false; - - float rootd = 0.0f; - float correction = 0.0f; - if(flags & CURVE_KN_ACCURATE) { - rootd = sqrtf(td); - correction = ((-tb - rootd)/(2*a)); - } - - float t = tcentre + correction; - - if(t < isect->t) { - - if(flags & CURVE_KN_INTERSECTCORRECTION) { - rootd = sqrtf(td); - correction = ((-tb - rootd)/(2*a)); - t = tcentre + correction; - } - - float z = zcentre + (dirz * correction); - // bool backface = false; - - if(flags & CURVE_KN_BACKFACING && (t < 0.0f || z < 0 || z > l)) { - // backface = true; - correction = ((-tb + rootd)/(2*a)); - t = tcentre + correction; - z = zcentre + (dirz * correction); - } - - /* stochastic fade from minimum width */ - float adjradius = or1 + z * (or2 - or1) * invl; - adjradius = adjradius / (r1 + z * gd); - if(lcg_state && adjradius != 1.0f) { - if(lcg_step_float(lcg_state) > adjradius) - return false; - } - /* --- */ - - if(t > 0.0f && t < isect->t && z >= 0 && z <= l) { - - if(flags & CURVE_KN_ENCLOSEFILTER) { - float enc_ratio = 1.01f; - if((difz > -r1 * enc_ratio) && (dot3(dif_second, tg) < r2 * enc_ratio)) { - float a2 = 1.0f - (dirz*dirz*(1 + gd*gd*enc_ratio*enc_ratio)); - float c2 = dot3(dif, dif) - difz * difz * (1 + gd*gd*enc_ratio*enc_ratio) - r1*r1*enc_ratio*enc_ratio - 2*r1*difz*gd*enc_ratio; - if(a2*c2 < 0.0f) - return false; - } - } - -#ifdef __VISIBILITY_FLAG__ - /* visibility flag test. we do it here under the assumption - * that most triangles are culled by node flags */ - if(kernel_tex_fetch(__prim_visibility, curveAddr) & visibility) -#endif - { - /* record intersection */ - isect->t = t; - isect->u = z*invl; - isect->v = gd; - isect->prim = curveAddr; - isect->object = object; - isect->type = type; - - return true; - } - } - } - - return false; - -#ifndef __KERNEL_SSE2__ -# undef len3_squared -# undef len3 -# undef dot3 -#endif -} - -ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3) -{ - float fc = 0.71f; - float data[4]; - float t2 = t * t; - data[0] = -3.0f * fc * t2 + 4.0f * fc * t - fc; - data[1] = 3.0f * (2.0f - fc) * t2 + 2.0f * (fc - 3.0f) * t; - data[2] = 3.0f * (fc - 2.0f) * t2 + 2.0f * (3.0f - 2.0f * fc) * t + fc; - data[3] = 3.0f * fc * t2 - 2.0f * fc * t; - return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; -} - -ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3) -{ - float data[4]; - float fc = 0.71f; - float t2 = t * t; - float t3 = t2 * t; - data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t; - data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f; - data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t; - data[3] = fc * t3 - fc * t2; - return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; -} - -ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray) -{ - int flag = kernel_data.curve.curveflags; - float t = isect->t; - float3 P = ray->P; - float3 D = ray->D; - - if(isect->object != OBJECT_NONE) { -#ifdef __OBJECT_MOTION__ - Transform tfm = sd->ob_itfm; -#else - Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM); -#endif - - P = transform_point(&tfm, P); - D = transform_direction(&tfm, D*t); - D = normalize_len(D, &t); - } - - int prim = kernel_tex_fetch(__prim_index, isect->prim); - float4 v00 = kernel_tex_fetch(__curves, prim); - - int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type); - int k1 = k0 + 1; - - float3 tg; - - if(flag & CURVE_KN_INTERPOLATE) { - int ka = max(k0 - 1,__float_as_int(v00.x)); - int kb = min(k1 + 1,__float_as_int(v00.x) + __float_as_int(v00.y) - 1); - - float4 P_curve[4]; - - if(sd->type & PRIMITIVE_CURVE) { - P_curve[0] = kernel_tex_fetch(__curve_keys, ka); - P_curve[1] = kernel_tex_fetch(__curve_keys, k0); - P_curve[2] = kernel_tex_fetch(__curve_keys, k1); - P_curve[3] = kernel_tex_fetch(__curve_keys, kb); - } - else { - motion_cardinal_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve); - } - - float3 p[4]; - p[0] = float4_to_float3(P_curve[0]); - p[1] = float4_to_float3(P_curve[1]); - p[2] = float4_to_float3(P_curve[2]); - p[3] = float4_to_float3(P_curve[3]); - - P = P + D*t; - -#ifdef __UV__ - sd->u = isect->u; - sd->v = 0.0f; -#endif - - tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3])); - - if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) { - sd->Ng = normalize(-(D - tg * (dot(tg, D)))); - } - else { - /* direction from inside to surface of curve */ - float3 p_curr = curvepoint(isect->u, p[0], p[1], p[2], p[3]); - sd->Ng = normalize(P - p_curr); - - /* adjustment for changing radius */ - float gd = isect->v; - - if(gd != 0.0f) { - sd->Ng = sd->Ng - gd * tg; - sd->Ng = normalize(sd->Ng); - } - } - - /* todo: sometimes the normal is still so that this is detected as - * backfacing even if cull backfaces is enabled */ - - sd->N = sd->Ng; - } - else { - float4 P_curve[2]; - - if(sd->type & PRIMITIVE_CURVE) { - P_curve[0]= kernel_tex_fetch(__curve_keys, k0); - P_curve[1]= kernel_tex_fetch(__curve_keys, k1); - } - else { - motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve); - } - - float l = 1.0f; - tg = normalize_len(float4_to_float3(P_curve[1] - P_curve[0]), &l); - - P = P + D*t; - - float3 dif = P - float4_to_float3(P_curve[0]); - -#ifdef __UV__ - sd->u = dot(dif,tg)/l; - sd->v = 0.0f; -#endif - - if(flag & CURVE_KN_TRUETANGENTGNORMAL) { - sd->Ng = -(D - tg * dot(tg, D)); - sd->Ng = normalize(sd->Ng); - } - else { - float gd = isect->v; - - /* direction from inside to surface of curve */ - sd->Ng = (dif - tg * sd->u * l) / (P_curve[0].w + sd->u * l * gd); - - /* adjustment for changing radius */ - if(gd != 0.0f) { - sd->Ng = sd->Ng - gd * tg; - sd->Ng = normalize(sd->Ng); - } - } - - sd->N = sd->Ng; - } - -#ifdef __DPDU__ - /* dPdu/dPdv */ - sd->dPdu = tg; - sd->dPdv = cross(tg, sd->Ng); -#endif - - if(isect->object != OBJECT_NONE) { -#ifdef __OBJECT_MOTION__ - Transform tfm = sd->ob_tfm; -#else - Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM); -#endif - - P = transform_point(&tfm, P); - } - - return P; -} - -#endif +#endif /* __HAIR__ */ CCL_NAMESPACE_END - diff --git a/intern/cycles/kernel/geom/geom_curve_intersect.h b/intern/cycles/kernel/geom/geom_curve_intersect.h new file mode 100644 index 00000000000..e9a149ea1ab --- /dev/null +++ b/intern/cycles/kernel/geom/geom_curve_intersect.h @@ -0,0 +1,934 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +CCL_NAMESPACE_BEGIN + +/* Curve primitive intersection functions. */ + +#ifdef __HAIR__ + +#if defined(__KERNEL_CUDA__) && (__CUDA_ARCH__ < 300) +# define ccl_device_curveintersect ccl_device +#else +# define ccl_device_curveintersect ccl_device_forceinline +#endif + +#ifdef __KERNEL_SSE2__ +ccl_device_inline ssef transform_point_T3(const ssef t[3], const ssef &a) +{ + return madd(shuffle<0>(a), t[0], madd(shuffle<1>(a), t[1], shuffle<2>(a) * t[2])); +} +#endif + +/* On CPU pass P and dir by reference to aligned vector. */ +ccl_device_curveintersect bool cardinal_curve_intersect( + KernelGlobals *kg, + Intersection *isect, + const float3 ccl_ref P, + const float3 ccl_ref dir, + uint visibility, + int object, + int curveAddr, + float time, + int type, + uint *lcg_state, + float difl, + float extmax) +{ + const bool is_curve_primitive = (type & PRIMITIVE_CURVE); + + if(!is_curve_primitive && kernel_data.bvh.use_bvh_steps) { + const float2 prim_time = kernel_tex_fetch(__prim_time, curveAddr); + if(time < prim_time.x || time > prim_time.y) { + return false; + } + } + + int segment = PRIMITIVE_UNPACK_SEGMENT(type); + float epsilon = 0.0f; + float r_st, r_en; + + int depth = kernel_data.curve.subdivisions; + int flags = kernel_data.curve.curveflags; + int prim = kernel_tex_fetch(__prim_index, curveAddr); + +#ifdef __KERNEL_SSE2__ + ssef vdir = load4f(dir); + ssef vcurve_coef[4]; + const float3 *curve_coef = (float3 *)vcurve_coef; + + { + ssef dtmp = vdir * vdir; + ssef d_ss = mm_sqrt(dtmp + shuffle<2>(dtmp)); + ssef rd_ss = load1f_first(1.0f) / d_ss; + + ssei v00vec = load4i((ssei *)&kg->__curves.data[prim]); + int2 &v00 = (int2 &)v00vec; + + int k0 = v00.x + segment; + int k1 = k0 + 1; + int ka = max(k0 - 1, v00.x); + int kb = min(k1 + 1, v00.x + v00.y - 1); + +#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && (!defined(_MSC_VER) || _MSC_VER > 1800) + avxf P_curve_0_1, P_curve_2_3; + if(is_curve_primitive) { + P_curve_0_1 = _mm256_loadu2_m128(&kg->__curve_keys.data[k0].x, &kg->__curve_keys.data[ka].x); + P_curve_2_3 = _mm256_loadu2_m128(&kg->__curve_keys.data[kb].x, &kg->__curve_keys.data[k1].x); + } + else { + int fobject = (object == OBJECT_NONE) ? kernel_tex_fetch(__prim_object, curveAddr) : object; + motion_cardinal_curve_keys_avx(kg, fobject, prim, time, ka, k0, k1, kb, &P_curve_0_1,&P_curve_2_3); + } +#else /* __KERNEL_AVX2__ */ + ssef P_curve[4]; + + if(is_curve_primitive) { + P_curve[0] = load4f(&kg->__curve_keys.data[ka].x); + P_curve[1] = load4f(&kg->__curve_keys.data[k0].x); + P_curve[2] = load4f(&kg->__curve_keys.data[k1].x); + P_curve[3] = load4f(&kg->__curve_keys.data[kb].x); + } + else { + int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object; + motion_cardinal_curve_keys(kg, fobject, prim, time, ka, k0, k1, kb, (float4*)&P_curve); + } +#endif /* __KERNEL_AVX2__ */ + + ssef rd_sgn = set_sign_bit<0, 1, 1, 1>(shuffle<0>(rd_ss)); + ssef mul_zxxy = shuffle<2, 0, 0, 1>(vdir) * rd_sgn; + ssef mul_yz = shuffle<1, 2, 1, 2>(vdir) * mul_zxxy; + ssef mul_shuf = shuffle<0, 1, 2, 3>(mul_zxxy, mul_yz); + ssef vdir0 = vdir & cast(ssei(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0)); + + ssef htfm0 = shuffle<0, 2, 0, 3>(mul_shuf, vdir0); + ssef htfm1 = shuffle<1, 0, 1, 3>(load1f_first(extract<0>(d_ss)), vdir0); + ssef htfm2 = shuffle<1, 3, 2, 3>(mul_shuf, vdir0); + +#if defined(__KERNEL_AVX2__) && defined(__KERNEL_SSE__) && (!defined(_MSC_VER) || _MSC_VER > 1800) + const avxf vPP = _mm256_broadcast_ps(&P.m128); + const avxf htfm00 = avxf(htfm0.m128, htfm0.m128); + const avxf htfm11 = avxf(htfm1.m128, htfm1.m128); + const avxf htfm22 = avxf(htfm2.m128, htfm2.m128); + + const avxf p01 = madd(shuffle<0>(P_curve_0_1 - vPP), + htfm00, + madd(shuffle<1>(P_curve_0_1 - vPP), + htfm11, + shuffle<2>(P_curve_0_1 - vPP) * htfm22)); + const avxf p23 = madd(shuffle<0>(P_curve_2_3 - vPP), + htfm00, + madd(shuffle<1>(P_curve_2_3 - vPP), + htfm11, + shuffle<2>(P_curve_2_3 - vPP)*htfm22)); + + const ssef p0 = _mm256_castps256_ps128(p01); + const ssef p1 = _mm256_extractf128_ps(p01, 1); + const ssef p2 = _mm256_castps256_ps128(p23); + const ssef p3 = _mm256_extractf128_ps(p23, 1); + + const ssef P_curve_1 = _mm256_extractf128_ps(P_curve_0_1, 1); + r_st = ((float4 &)P_curve_1).w; + const ssef P_curve_2 = _mm256_castps256_ps128(P_curve_2_3); + r_en = ((float4 &)P_curve_2).w; +#else /* __KERNEL_AVX2__ */ + ssef htfm[] = { htfm0, htfm1, htfm2 }; + ssef vP = load4f(P); + ssef p0 = transform_point_T3(htfm, P_curve[0] - vP); + ssef p1 = transform_point_T3(htfm, P_curve[1] - vP); + ssef p2 = transform_point_T3(htfm, P_curve[2] - vP); + ssef p3 = transform_point_T3(htfm, P_curve[3] - vP); + + r_st = ((float4 &)P_curve[1]).w; + r_en = ((float4 &)P_curve[2]).w; +#endif /* __KERNEL_AVX2__ */ + + float fc = 0.71f; + ssef vfc = ssef(fc); + ssef vfcxp3 = vfc * p3; + + vcurve_coef[0] = p1; + vcurve_coef[1] = vfc * (p2 - p0); + vcurve_coef[2] = madd(ssef(fc * 2.0f), p0, madd(ssef(fc - 3.0f), p1, msub(ssef(3.0f - 2.0f * fc), p2, vfcxp3))); + vcurve_coef[3] = msub(ssef(fc - 2.0f), p2 - p1, msub(vfc, p0, vfcxp3)); + + } +#else + float3 curve_coef[4]; + + /* curve Intersection check */ + /* obtain curve parameters */ + { + /* ray transform created - this should be created at beginning of intersection loop */ + Transform htfm; + float d = sqrtf(dir.x * dir.x + dir.z * dir.z); + htfm = make_transform( + dir.z / d, 0, -dir.x /d, 0, + -dir.x * dir.y /d, d, -dir.y * dir.z /d, 0, + dir.x, dir.y, dir.z, 0, + 0, 0, 0, 1); + + float4 v00 = kernel_tex_fetch(__curves, prim); + + int k0 = __float_as_int(v00.x) + segment; + int k1 = k0 + 1; + + int ka = max(k0 - 1,__float_as_int(v00.x)); + int kb = min(k1 + 1,__float_as_int(v00.x) + __float_as_int(v00.y) - 1); + + float4 P_curve[4]; + + if(is_curve_primitive) { + P_curve[0] = kernel_tex_fetch(__curve_keys, ka); + P_curve[1] = kernel_tex_fetch(__curve_keys, k0); + P_curve[2] = kernel_tex_fetch(__curve_keys, k1); + P_curve[3] = kernel_tex_fetch(__curve_keys, kb); + } + else { + int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object; + motion_cardinal_curve_keys(kg, fobject, prim, time, ka, k0, k1, kb, P_curve); + } + + float3 p0 = transform_point(&htfm, float4_to_float3(P_curve[0]) - P); + float3 p1 = transform_point(&htfm, float4_to_float3(P_curve[1]) - P); + float3 p2 = transform_point(&htfm, float4_to_float3(P_curve[2]) - P); + float3 p3 = transform_point(&htfm, float4_to_float3(P_curve[3]) - P); + + float fc = 0.71f; + curve_coef[0] = p1; + curve_coef[1] = -fc*p0 + fc*p2; + curve_coef[2] = 2.0f * fc * p0 + (fc - 3.0f) * p1 + (3.0f - 2.0f * fc) * p2 - fc * p3; + curve_coef[3] = -fc * p0 + (2.0f - fc) * p1 + (fc - 2.0f) * p2 + fc * p3; + r_st = P_curve[1].w; + r_en = P_curve[2].w; + } +#endif + + float r_curr = max(r_st, r_en); + + if((flags & CURVE_KN_RIBBONS) || !(flags & CURVE_KN_BACKFACING)) + epsilon = 2 * r_curr; + + /* find bounds - this is slow for cubic curves */ + float upper, lower; + + float zextrem[4]; + curvebounds(&lower, &upper, &zextrem[0], &zextrem[1], &zextrem[2], &zextrem[3], curve_coef[0].z, curve_coef[1].z, curve_coef[2].z, curve_coef[3].z); + if(lower - r_curr > isect->t || upper + r_curr < epsilon) + return false; + + /* minimum width extension */ + float mw_extension = min(difl * fabsf(upper), extmax); + float r_ext = mw_extension + r_curr; + + float xextrem[4]; + curvebounds(&lower, &upper, &xextrem[0], &xextrem[1], &xextrem[2], &xextrem[3], curve_coef[0].x, curve_coef[1].x, curve_coef[2].x, curve_coef[3].x); + if(lower > r_ext || upper < -r_ext) + return false; + + float yextrem[4]; + curvebounds(&lower, &upper, &yextrem[0], &yextrem[1], &yextrem[2], &yextrem[3], curve_coef[0].y, curve_coef[1].y, curve_coef[2].y, curve_coef[3].y); + if(lower > r_ext || upper < -r_ext) + return false; + + /* setup recurrent loop */ + int level = 1 << depth; + int tree = 0; + float resol = 1.0f / (float)level; + bool hit = false; + + /* begin loop */ + while(!(tree >> (depth))) { + const float i_st = tree * resol; + const float i_en = i_st + (level * resol); + +#ifdef __KERNEL_SSE2__ + ssef vi_st = ssef(i_st), vi_en = ssef(i_en); + ssef vp_st = madd(madd(madd(vcurve_coef[3], vi_st, vcurve_coef[2]), vi_st, vcurve_coef[1]), vi_st, vcurve_coef[0]); + ssef vp_en = madd(madd(madd(vcurve_coef[3], vi_en, vcurve_coef[2]), vi_en, vcurve_coef[1]), vi_en, vcurve_coef[0]); + + ssef vbmin = min(vp_st, vp_en); + ssef vbmax = max(vp_st, vp_en); + + float3 &bmin = (float3 &)vbmin, &bmax = (float3 &)vbmax; + float &bminx = bmin.x, &bminy = bmin.y, &bminz = bmin.z; + float &bmaxx = bmax.x, &bmaxy = bmax.y, &bmaxz = bmax.z; + float3 &p_st = (float3 &)vp_st, &p_en = (float3 &)vp_en; +#else + float3 p_st = ((curve_coef[3] * i_st + curve_coef[2]) * i_st + curve_coef[1]) * i_st + curve_coef[0]; + float3 p_en = ((curve_coef[3] * i_en + curve_coef[2]) * i_en + curve_coef[1]) * i_en + curve_coef[0]; + + float bminx = min(p_st.x, p_en.x); + float bmaxx = max(p_st.x, p_en.x); + float bminy = min(p_st.y, p_en.y); + float bmaxy = max(p_st.y, p_en.y); + float bminz = min(p_st.z, p_en.z); + float bmaxz = max(p_st.z, p_en.z); +#endif + + if(xextrem[0] >= i_st && xextrem[0] <= i_en) { + bminx = min(bminx,xextrem[1]); + bmaxx = max(bmaxx,xextrem[1]); + } + if(xextrem[2] >= i_st && xextrem[2] <= i_en) { + bminx = min(bminx,xextrem[3]); + bmaxx = max(bmaxx,xextrem[3]); + } + if(yextrem[0] >= i_st && yextrem[0] <= i_en) { + bminy = min(bminy,yextrem[1]); + bmaxy = max(bmaxy,yextrem[1]); + } + if(yextrem[2] >= i_st && yextrem[2] <= i_en) { + bminy = min(bminy,yextrem[3]); + bmaxy = max(bmaxy,yextrem[3]); + } + if(zextrem[0] >= i_st && zextrem[0] <= i_en) { + bminz = min(bminz,zextrem[1]); + bmaxz = max(bmaxz,zextrem[1]); + } + if(zextrem[2] >= i_st && zextrem[2] <= i_en) { + bminz = min(bminz,zextrem[3]); + bmaxz = max(bmaxz,zextrem[3]); + } + + float r1 = r_st + (r_en - r_st) * i_st; + float r2 = r_st + (r_en - r_st) * i_en; + r_curr = max(r1, r2); + + mw_extension = min(difl * fabsf(bmaxz), extmax); + float r_ext = mw_extension + r_curr; + float coverage = 1.0f; + + if(bminz - r_curr > isect->t || bmaxz + r_curr < epsilon || bminx > r_ext|| bmaxx < -r_ext|| bminy > r_ext|| bmaxy < -r_ext) { + /* the bounding box does not overlap the square centered at O */ + tree += level; + level = tree & -tree; + } + else if(level == 1) { + + /* the maximum recursion depth is reached. + * check if dP0.(Q-P0)>=0 and dPn.(Pn-Q)>=0. + * dP* is reversed if necessary.*/ + float t = isect->t; + float u = 0.0f; + float gd = 0.0f; + + if(flags & CURVE_KN_RIBBONS) { + float3 tg = (p_en - p_st); +#ifdef __KERNEL_SSE__ + const float3 tg_sq = tg * tg; + float w = tg_sq.x + tg_sq.y; +#else + float w = tg.x * tg.x + tg.y * tg.y; +#endif + if(w == 0) { + tree++; + level = tree & -tree; + continue; + } +#ifdef __KERNEL_SSE__ + const float3 p_sttg = p_st * tg; + w = -(p_sttg.x + p_sttg.y) / w; +#else + w = -(p_st.x * tg.x + p_st.y * tg.y) / w; +#endif + w = saturate(w); + + /* compute u on the curve segment */ + u = i_st * (1 - w) + i_en * w; + r_curr = r_st + (r_en - r_st) * u; + /* compare x-y distances */ + float3 p_curr = ((curve_coef[3] * u + curve_coef[2]) * u + curve_coef[1]) * u + curve_coef[0]; + + float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1]; + if(dot(tg, dp_st)< 0) + dp_st *= -1; + if(dot(dp_st, -p_st) + p_curr.z * dp_st.z < 0) { + tree++; + level = tree & -tree; + continue; + } + float3 dp_en = (3 * curve_coef[3] * i_en + 2 * curve_coef[2]) * i_en + curve_coef[1]; + if(dot(tg, dp_en) < 0) + dp_en *= -1; + if(dot(dp_en, p_en) - p_curr.z * dp_en.z < 0) { + tree++; + level = tree & -tree; + continue; + } + + /* compute coverage */ + float r_ext = r_curr; + coverage = 1.0f; + if(difl != 0.0f) { + mw_extension = min(difl * fabsf(bmaxz), extmax); + r_ext = mw_extension + r_curr; +#ifdef __KERNEL_SSE__ + const float3 p_curr_sq = p_curr * p_curr; + const float3 dxxx(_mm_sqrt_ss(_mm_hadd_ps(p_curr_sq.m128, p_curr_sq.m128))); + float d = dxxx.x; +#else + float d = sqrtf(p_curr.x * p_curr.x + p_curr.y * p_curr.y); +#endif + float d0 = d - r_curr; + float d1 = d + r_curr; + float inv_mw_extension = 1.0f/mw_extension; + if(d0 >= 0) + coverage = (min(d1 * inv_mw_extension, 1.0f) - min(d0 * inv_mw_extension, 1.0f)) * 0.5f; + else // inside + coverage = (min(d1 * inv_mw_extension, 1.0f) + min(-d0 * inv_mw_extension, 1.0f)) * 0.5f; + } + + if(p_curr.x * p_curr.x + p_curr.y * p_curr.y >= r_ext * r_ext || p_curr.z <= epsilon || isect->t < p_curr.z) { + tree++; + level = tree & -tree; + continue; + } + + t = p_curr.z; + + /* stochastic fade from minimum width */ + if(difl != 0.0f && lcg_state) { + if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage)) + return hit; + } + } + else { + float l = len(p_en - p_st); + /* minimum width extension */ + float or1 = r1; + float or2 = r2; + + if(difl != 0.0f) { + mw_extension = min(len(p_st - P) * difl, extmax); + or1 = r1 < mw_extension ? mw_extension : r1; + mw_extension = min(len(p_en - P) * difl, extmax); + or2 = r2 < mw_extension ? mw_extension : r2; + } + /* --- */ + float invl = 1.0f/l; + float3 tg = (p_en - p_st) * invl; + gd = (or2 - or1) * invl; + float difz = -dot(p_st,tg); + float cyla = 1.0f - (tg.z * tg.z * (1 + gd*gd)); + float invcyla = 1.0f/cyla; + float halfb = (-p_st.z - tg.z*(difz + gd*(difz*gd + or1))); + float tcentre = -halfb*invcyla; + float zcentre = difz + (tg.z * tcentre); + float3 tdif = - p_st; + tdif.z += tcentre; + float tdifz = dot(tdif,tg); + float tb = 2*(tdif.z - tg.z*(tdifz + gd*(tdifz*gd + or1))); + float tc = dot(tdif,tdif) - tdifz * tdifz * (1 + gd*gd) - or1*or1 - 2*or1*tdifz*gd; + float td = tb*tb - 4*cyla*tc; + if(td < 0.0f) { + tree++; + level = tree & -tree; + continue; + } + + float rootd = sqrtf(td); + float correction = (-tb - rootd) * 0.5f * invcyla; + t = tcentre + correction; + + float3 dp_st = (3 * curve_coef[3] * i_st + 2 * curve_coef[2]) * i_st + curve_coef[1]; + if(dot(tg, dp_st)< 0) + dp_st *= -1; + float3 dp_en = (3 * curve_coef[3] * i_en + 2 * curve_coef[2]) * i_en + curve_coef[1]; + if(dot(tg, dp_en) < 0) + dp_en *= -1; + + if(flags & CURVE_KN_BACKFACING && (dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f)) { + correction = (-tb + rootd) * 0.5f * invcyla; + t = tcentre + correction; + } + + if(dot(dp_st, -p_st) + t * dp_st.z < 0 || dot(dp_en, p_en) - t * dp_en.z < 0 || isect->t < t || t <= 0.0f) { + tree++; + level = tree & -tree; + continue; + } + + float w = (zcentre + (tg.z * correction)) * invl; + w = saturate(w); + /* compute u on the curve segment */ + u = i_st * (1 - w) + i_en * w; + + /* stochastic fade from minimum width */ + if(difl != 0.0f && lcg_state) { + r_curr = r1 + (r2 - r1) * w; + r_ext = or1 + (or2 - or1) * w; + coverage = r_curr/r_ext; + + if(coverage != 1.0f && (lcg_step_float(lcg_state) > coverage)) + return hit; + } + } + /* we found a new intersection */ + +#ifdef __VISIBILITY_FLAG__ + /* visibility flag test. we do it here under the assumption + * that most triangles are culled by node flags */ + if(kernel_tex_fetch(__prim_visibility, curveAddr) & visibility) +#endif + { + /* record intersection */ + isect->t = t; + isect->u = u; + isect->v = gd; + isect->prim = curveAddr; + isect->object = object; + isect->type = type; + hit = true; + } + + tree++; + level = tree & -tree; + } + else { + /* split the curve into two curves and process */ + level = level >> 1; + } + } + + return hit; +} + +ccl_device_curveintersect bool curve_intersect(KernelGlobals *kg, + Intersection *isect, + float3 P, + float3 direction, + uint visibility, + int object, + int curveAddr, + float time, + int type, + uint *lcg_state, + float difl, + float extmax) +{ + /* define few macros to minimize code duplication for SSE */ +#ifndef __KERNEL_SSE2__ +# define len3_squared(x) len_squared(x) +# define len3(x) len(x) +# define dot3(x, y) dot(x, y) +#endif + + const bool is_curve_primitive = (type & PRIMITIVE_CURVE); + + if(!is_curve_primitive && kernel_data.bvh.use_bvh_steps) { + const float2 prim_time = kernel_tex_fetch(__prim_time, curveAddr); + if(time < prim_time.x || time > prim_time.y) { + return false; + } + } + + int segment = PRIMITIVE_UNPACK_SEGMENT(type); + /* curve Intersection check */ + int flags = kernel_data.curve.curveflags; + + int prim = kernel_tex_fetch(__prim_index, curveAddr); + float4 v00 = kernel_tex_fetch(__curves, prim); + + int cnum = __float_as_int(v00.x); + int k0 = cnum + segment; + int k1 = k0 + 1; + +#ifndef __KERNEL_SSE2__ + float4 P_curve[2]; + + if(is_curve_primitive) { + P_curve[0] = kernel_tex_fetch(__curve_keys, k0); + P_curve[1] = kernel_tex_fetch(__curve_keys, k1); + } + else { + int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object; + motion_curve_keys(kg, fobject, prim, time, k0, k1, P_curve); + } + + float or1 = P_curve[0].w; + float or2 = P_curve[1].w; + float3 p1 = float4_to_float3(P_curve[0]); + float3 p2 = float4_to_float3(P_curve[1]); + + /* minimum width extension */ + float r1 = or1; + float r2 = or2; + float3 dif = P - p1; + float3 dif_second = P - p2; + if(difl != 0.0f) { + float pixelsize = min(len3(dif) * difl, extmax); + r1 = or1 < pixelsize ? pixelsize : or1; + pixelsize = min(len3(dif_second) * difl, extmax); + r2 = or2 < pixelsize ? pixelsize : or2; + } + /* --- */ + + float3 p21_diff = p2 - p1; + float3 sphere_dif1 = (dif + dif_second) * 0.5f; + float3 dir = direction; + float sphere_b_tmp = dot3(dir, sphere_dif1); + float3 sphere_dif2 = sphere_dif1 - sphere_b_tmp * dir; +#else + ssef P_curve[2]; + + if(is_curve_primitive) { + P_curve[0] = load4f(&kg->__curve_keys.data[k0].x); + P_curve[1] = load4f(&kg->__curve_keys.data[k1].x); + } + else { + int fobject = (object == OBJECT_NONE)? kernel_tex_fetch(__prim_object, curveAddr): object; + motion_curve_keys(kg, fobject, prim, time, k0, k1, (float4*)&P_curve); + } + + const ssef or12 = shuffle<3, 3, 3, 3>(P_curve[0], P_curve[1]); + + ssef r12 = or12; + const ssef vP = load4f(P); + const ssef dif = vP - P_curve[0]; + const ssef dif_second = vP - P_curve[1]; + if(difl != 0.0f) { + const ssef len1_sq = len3_squared_splat(dif); + const ssef len2_sq = len3_squared_splat(dif_second); + const ssef len12 = mm_sqrt(shuffle<0, 0, 0, 0>(len1_sq, len2_sq)); + const ssef pixelsize12 = min(len12 * difl, ssef(extmax)); + r12 = max(or12, pixelsize12); + } + float or1 = extract<0>(or12), or2 = extract<0>(shuffle<2>(or12)); + float r1 = extract<0>(r12), r2 = extract<0>(shuffle<2>(r12)); + + const ssef p21_diff = P_curve[1] - P_curve[0]; + const ssef sphere_dif1 = (dif + dif_second) * 0.5f; + const ssef dir = load4f(direction); + const ssef sphere_b_tmp = dot3_splat(dir, sphere_dif1); + const ssef sphere_dif2 = nmadd(sphere_b_tmp, dir, sphere_dif1); +#endif + + float mr = max(r1, r2); + float l = len3(p21_diff); + float invl = 1.0f / l; + float sp_r = mr + 0.5f * l; + + float sphere_b = dot3(dir, sphere_dif2); + float sdisc = sphere_b * sphere_b - len3_squared(sphere_dif2) + sp_r * sp_r; + + if(sdisc < 0.0f) + return false; + + /* obtain parameters and test midpoint distance for suitable modes */ +#ifndef __KERNEL_SSE2__ + float3 tg = p21_diff * invl; +#else + const ssef tg = p21_diff * invl; +#endif + float gd = (r2 - r1) * invl; + + float dirz = dot3(dir, tg); + float difz = dot3(dif, tg); + + float a = 1.0f - (dirz*dirz*(1 + gd*gd)); + + float halfb = dot3(dir, dif) - dirz*(difz + gd*(difz*gd + r1)); + + float tcentre = -halfb/a; + float zcentre = difz + (dirz * tcentre); + + if((tcentre > isect->t) && !(flags & CURVE_KN_ACCURATE)) + return false; + if((zcentre < 0 || zcentre > l) && !(flags & CURVE_KN_ACCURATE) && !(flags & CURVE_KN_INTERSECTCORRECTION)) + return false; + + /* test minimum separation */ +#ifndef __KERNEL_SSE2__ + float3 cprod = cross(tg, dir); + float cprod2sq = len3_squared(cross(tg, dif)); +#else + const ssef cprod = cross(tg, dir); + float cprod2sq = len3_squared(cross_zxy(tg, dif)); +#endif + float cprodsq = len3_squared(cprod); + float distscaled = dot3(cprod, dif); + + if(cprodsq == 0) + distscaled = cprod2sq; + else + distscaled = (distscaled*distscaled)/cprodsq; + + if(distscaled > mr*mr) + return false; + + /* calculate true intersection */ +#ifndef __KERNEL_SSE2__ + float3 tdif = dif + tcentre * dir; +#else + const ssef tdif = madd(ssef(tcentre), dir, dif); +#endif + float tdifz = dot3(tdif, tg); + float tdifma = tdifz*gd + r1; + float tb = 2*(dot3(dir, tdif) - dirz*(tdifz + gd*tdifma)); + float tc = dot3(tdif, tdif) - tdifz*tdifz - tdifma*tdifma; + float td = tb*tb - 4*a*tc; + + if(td < 0.0f) + return false; + + float rootd = 0.0f; + float correction = 0.0f; + if(flags & CURVE_KN_ACCURATE) { + rootd = sqrtf(td); + correction = ((-tb - rootd)/(2*a)); + } + + float t = tcentre + correction; + + if(t < isect->t) { + + if(flags & CURVE_KN_INTERSECTCORRECTION) { + rootd = sqrtf(td); + correction = ((-tb - rootd)/(2*a)); + t = tcentre + correction; + } + + float z = zcentre + (dirz * correction); + // bool backface = false; + + if(flags & CURVE_KN_BACKFACING && (t < 0.0f || z < 0 || z > l)) { + // backface = true; + correction = ((-tb + rootd)/(2*a)); + t = tcentre + correction; + z = zcentre + (dirz * correction); + } + + /* stochastic fade from minimum width */ + float adjradius = or1 + z * (or2 - or1) * invl; + adjradius = adjradius / (r1 + z * gd); + if(lcg_state && adjradius != 1.0f) { + if(lcg_step_float(lcg_state) > adjradius) + return false; + } + /* --- */ + + if(t > 0.0f && t < isect->t && z >= 0 && z <= l) { + + if(flags & CURVE_KN_ENCLOSEFILTER) { + float enc_ratio = 1.01f; + if((difz > -r1 * enc_ratio) && (dot3(dif_second, tg) < r2 * enc_ratio)) { + float a2 = 1.0f - (dirz*dirz*(1 + gd*gd*enc_ratio*enc_ratio)); + float c2 = dot3(dif, dif) - difz * difz * (1 + gd*gd*enc_ratio*enc_ratio) - r1*r1*enc_ratio*enc_ratio - 2*r1*difz*gd*enc_ratio; + if(a2*c2 < 0.0f) + return false; + } + } + +#ifdef __VISIBILITY_FLAG__ + /* visibility flag test. we do it here under the assumption + * that most triangles are culled by node flags */ + if(kernel_tex_fetch(__prim_visibility, curveAddr) & visibility) +#endif + { + /* record intersection */ + isect->t = t; + isect->u = z*invl; + isect->v = gd; + isect->prim = curveAddr; + isect->object = object; + isect->type = type; + + return true; + } + } + } + + return false; + +#ifndef __KERNEL_SSE2__ +# undef len3_squared +# undef len3 +# undef dot3 +#endif +} + +ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3) +{ + float fc = 0.71f; + float data[4]; + float t2 = t * t; + data[0] = -3.0f * fc * t2 + 4.0f * fc * t - fc; + data[1] = 3.0f * (2.0f - fc) * t2 + 2.0f * (fc - 3.0f) * t; + data[2] = 3.0f * (fc - 2.0f) * t2 + 2.0f * (3.0f - 2.0f * fc) * t + fc; + data[3] = 3.0f * fc * t2 - 2.0f * fc * t; + return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; +} + +ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3) +{ + float data[4]; + float fc = 0.71f; + float t2 = t * t; + float t3 = t2 * t; + data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t; + data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f; + data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t; + data[3] = fc * t3 - fc * t2; + return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; +} + +ccl_device_inline float3 curve_refine(KernelGlobals *kg, + ShaderData *sd, + const Intersection *isect, + const Ray *ray) +{ + int flag = kernel_data.curve.curveflags; + float t = isect->t; + float3 P = ray->P; + float3 D = ray->D; + + if(isect->object != OBJECT_NONE) { +#ifdef __OBJECT_MOTION__ + Transform tfm = sd->ob_itfm; +#else + Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM); +#endif + + P = transform_point(&tfm, P); + D = transform_direction(&tfm, D*t); + D = normalize_len(D, &t); + } + + int prim = kernel_tex_fetch(__prim_index, isect->prim); + float4 v00 = kernel_tex_fetch(__curves, prim); + + int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type); + int k1 = k0 + 1; + + float3 tg; + + if(flag & CURVE_KN_INTERPOLATE) { + int ka = max(k0 - 1,__float_as_int(v00.x)); + int kb = min(k1 + 1,__float_as_int(v00.x) + __float_as_int(v00.y) - 1); + + float4 P_curve[4]; + + if(sd->type & PRIMITIVE_CURVE) { + P_curve[0] = kernel_tex_fetch(__curve_keys, ka); + P_curve[1] = kernel_tex_fetch(__curve_keys, k0); + P_curve[2] = kernel_tex_fetch(__curve_keys, k1); + P_curve[3] = kernel_tex_fetch(__curve_keys, kb); + } + else { + motion_cardinal_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve); + } + + float3 p[4]; + p[0] = float4_to_float3(P_curve[0]); + p[1] = float4_to_float3(P_curve[1]); + p[2] = float4_to_float3(P_curve[2]); + p[3] = float4_to_float3(P_curve[3]); + + P = P + D*t; + +#ifdef __UV__ + sd->u = isect->u; + sd->v = 0.0f; +#endif + + tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3])); + + if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) { + sd->Ng = normalize(-(D - tg * (dot(tg, D)))); + } + else { + /* direction from inside to surface of curve */ + float3 p_curr = curvepoint(isect->u, p[0], p[1], p[2], p[3]); + sd->Ng = normalize(P - p_curr); + + /* adjustment for changing radius */ + float gd = isect->v; + + if(gd != 0.0f) { + sd->Ng = sd->Ng - gd * tg; + sd->Ng = normalize(sd->Ng); + } + } + + /* todo: sometimes the normal is still so that this is detected as + * backfacing even if cull backfaces is enabled */ + + sd->N = sd->Ng; + } + else { + float4 P_curve[2]; + + if(sd->type & PRIMITIVE_CURVE) { + P_curve[0]= kernel_tex_fetch(__curve_keys, k0); + P_curve[1]= kernel_tex_fetch(__curve_keys, k1); + } + else { + motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve); + } + + float l = 1.0f; + tg = normalize_len(float4_to_float3(P_curve[1] - P_curve[0]), &l); + + P = P + D*t; + + float3 dif = P - float4_to_float3(P_curve[0]); + +#ifdef __UV__ + sd->u = dot(dif,tg)/l; + sd->v = 0.0f; +#endif + + if(flag & CURVE_KN_TRUETANGENTGNORMAL) { + sd->Ng = -(D - tg * dot(tg, D)); + sd->Ng = normalize(sd->Ng); + } + else { + float gd = isect->v; + + /* direction from inside to surface of curve */ + sd->Ng = (dif - tg * sd->u * l) / (P_curve[0].w + sd->u * l * gd); + + /* adjustment for changing radius */ + if(gd != 0.0f) { + sd->Ng = sd->Ng - gd * tg; + sd->Ng = normalize(sd->Ng); + } + } + + sd->N = sd->Ng; + } + +#ifdef __DPDU__ + /* dPdu/dPdv */ + sd->dPdu = tg; + sd->dPdv = cross(tg, sd->Ng); +#endif + + if(isect->object != OBJECT_NONE) { +#ifdef __OBJECT_MOTION__ + Transform tfm = sd->ob_tfm; +#else + Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM); +#endif + + P = transform_point(&tfm, P); + } + + return P; +} + +#endif + +CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h index 38708f7ff0b..6d1cf055f2c 100644 --- a/intern/cycles/kernel/kernel_compat_cuda.h +++ b/intern/cycles/kernel/kernel_compat_cuda.h @@ -53,6 +53,10 @@ #define ccl_may_alias #define ccl_addr_space #define ccl_restrict __restrict__ +/* TODO(sergey): In theory we might use references with CUDA, however + * performance impact yet to be investigated. + */ +#define ccl_ref #define ccl_align(n) __align__(n) #define ATTR_FALLTHROUGH diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h index 4836c290312..36d6031d042 100644 --- a/intern/cycles/kernel/kernel_compat_opencl.h +++ b/intern/cycles/kernel/kernel_compat_opencl.h @@ -42,6 +42,7 @@ #define ccl_local_param __local #define ccl_private __private #define ccl_restrict restrict +#define ccl_ref #define ccl_align(n) __attribute__((aligned(n))) #ifdef __SPLIT_KERNEL__ @@ -129,6 +130,7 @@ # define expf(x) native_exp(((float)(x))) # define sqrtf(x) native_sqrt(((float)(x))) # define logf(x) native_log(((float)(x))) +# define rcp(x) native_recip(x) #else # define sinf(x) sin(((float)(x))) # define cosf(x) cos(((float)(x))) @@ -136,11 +138,12 @@ # define expf(x) exp(((float)(x))) # define sqrtf(x) sqrt(((float)(x))) # define logf(x) log(((float)(x))) +# define rcp(x) recip(x)) #endif /* data lookup defines */ #define kernel_data (*kg->data) -#define kernel_tex_fetch(t, index) kg->t[index] +#define kernel_tex_fetch(tex, index) ((ccl_global tex##_t*)(kg->buffers[kg->tex.buffer] + kg->tex.offset))[(index)] /* define NULL */ #define NULL 0 diff --git a/intern/cycles/kernel/kernel_globals.h b/intern/cycles/kernel/kernel_globals.h index f95f0d98c52..9d55183d94b 100644 --- a/intern/cycles/kernel/kernel_globals.h +++ b/intern/cycles/kernel/kernel_globals.h @@ -23,6 +23,10 @@ # include "util/util_vector.h" #endif +#ifdef __KERNEL_OPENCL__ +# include "util/util_atomic.h" +#endif + CCL_NAMESPACE_BEGIN /* On the CPU, we pass along the struct KernelGlobals to nearly everywhere in @@ -109,11 +113,22 @@ typedef struct KernelGlobals { #ifdef __KERNEL_OPENCL__ +# define KERNEL_TEX(type, ttype, name) \ +typedef type name##_t; +# include "kernel/kernel_textures.h" + +typedef struct tex_info_t { + uint buffer, padding; + uint64_t offset; + uint width, height, depth, options; +} tex_info_t; + typedef ccl_addr_space struct KernelGlobals { ccl_constant KernelData *data; + ccl_global char *buffers[8]; # define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name; + tex_info_t name; # include "kernel/kernel_textures.h" # ifdef __SPLIT_KERNEL__ @@ -122,6 +137,57 @@ typedef ccl_addr_space struct KernelGlobals { # endif } KernelGlobals; +#define KERNEL_BUFFER_PARAMS \ + ccl_global char *buffer0, \ + ccl_global char *buffer1, \ + ccl_global char *buffer2, \ + ccl_global char *buffer3, \ + ccl_global char *buffer4, \ + ccl_global char *buffer5, \ + ccl_global char *buffer6, \ + ccl_global char *buffer7 + +#define KERNEL_BUFFER_ARGS buffer0, buffer1, buffer2, buffer3, buffer4, buffer5, buffer6, buffer7 + +ccl_device_inline void kernel_set_buffer_pointers(KernelGlobals *kg, KERNEL_BUFFER_PARAMS) +{ +#ifdef __SPLIT_KERNEL__ + if(ccl_local_id(0) + ccl_local_id(1) == 0) +#endif + { + kg->buffers[0] = buffer0; + kg->buffers[1] = buffer1; + kg->buffers[2] = buffer2; + kg->buffers[3] = buffer3; + kg->buffers[4] = buffer4; + kg->buffers[5] = buffer5; + kg->buffers[6] = buffer6; + kg->buffers[7] = buffer7; + } + +# ifdef __SPLIT_KERNEL__ + ccl_barrier(CCL_LOCAL_MEM_FENCE); +# endif +} + +ccl_device_inline void kernel_set_buffer_info(KernelGlobals *kg) +{ +# ifdef __SPLIT_KERNEL__ + if(ccl_local_id(0) + ccl_local_id(1) == 0) +# endif + { + ccl_global tex_info_t *info = (ccl_global tex_info_t*)kg->buffers[0]; + +# define KERNEL_TEX(type, ttype, name) \ + kg->name = *(info++); +# include "kernel/kernel_textures.h" + } + +# ifdef __SPLIT_KERNEL__ + ccl_barrier(CCL_LOCAL_MEM_FENCE); +# endif +} + #endif /* __KERNEL_OPENCL__ */ /* Interpolated lookup table access */ diff --git a/intern/cycles/kernel/kernel_image_opencl.h b/intern/cycles/kernel/kernel_image_opencl.h index 90747e09357..9e3373432ec 100644 --- a/intern/cycles/kernel/kernel_image_opencl.h +++ b/intern/cycles/kernel/kernel_image_opencl.h @@ -15,30 +15,42 @@ */ -/* For OpenCL all images are packed in a single array, and we do manual lookup - * and interpolation. */ +/* For OpenCL we do manual lookup and interpolation. */ + +ccl_device_inline ccl_global tex_info_t* kernel_tex_info(KernelGlobals *kg, uint id) { + const uint tex_offset = id +#define KERNEL_TEX(type, ttype, name) + 1 +#include "kernel/kernel_textures.h" + ; + + return &((ccl_global tex_info_t*)kg->buffers[0])[tex_offset]; +} + +#define tex_fetch(type, info, index) ((ccl_global type*)(kg->buffers[info->buffer] + info->offset))[(index)] ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int id, int offset) { + const ccl_global tex_info_t *info = kernel_tex_info(kg, id); const int texture_type = kernel_tex_type(id); + /* Float4 */ if(texture_type == IMAGE_DATA_TYPE_FLOAT4) { - return kernel_tex_fetch(__tex_image_float4_packed, offset); + return tex_fetch(float4, info, offset); } /* Byte4 */ else if(texture_type == IMAGE_DATA_TYPE_BYTE4) { - uchar4 r = kernel_tex_fetch(__tex_image_byte4_packed, offset); + uchar4 r = tex_fetch(uchar4, info, offset); float f = 1.0f/255.0f; return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); } /* Float */ else if(texture_type == IMAGE_DATA_TYPE_FLOAT) { - float f = kernel_tex_fetch(__tex_image_float_packed, offset); + float f = tex_fetch(float, info, offset); return make_float4(f, f, f, 1.0f); } /* Byte */ else { - uchar r = kernel_tex_fetch(__tex_image_byte_packed, offset); + uchar r = tex_fetch(uchar, info, offset); float f = r * (1.0f/255.0f); return make_float4(f, f, f, 1.0f); } @@ -64,17 +76,17 @@ ccl_device_inline float svm_image_texture_frac(float x, int *ix) return x - (float)i; } -ccl_device_inline uint kernel_decode_image_interpolation(uint4 info) +ccl_device_inline uint kernel_decode_image_interpolation(uint info) { - return (info.w & (1 << 0)) ? INTERPOLATION_CLOSEST : INTERPOLATION_LINEAR; + return (info & (1 << 0)) ? INTERPOLATION_CLOSEST : INTERPOLATION_LINEAR; } -ccl_device_inline uint kernel_decode_image_extension(uint4 info) +ccl_device_inline uint kernel_decode_image_extension(uint info) { - if(info.w & (1 << 1)) { + if(info & (1 << 1)) { return EXTENSION_REPEAT; } - else if(info.w & (1 << 2)) { + else if(info & (1 << 2)) { return EXTENSION_EXTEND; } else { @@ -84,13 +96,16 @@ ccl_device_inline uint kernel_decode_image_extension(uint4 info) ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, float y) { - uint4 info = kernel_tex_fetch(__tex_image_packed_info, id*2); - uint width = info.x; - uint height = info.y; - uint offset = info.z; + const ccl_global tex_info_t *info = kernel_tex_info(kg, id); + + uint width = info->width; + uint height = info->height; + uint offset = 0; + /* Decode image options. */ - uint interpolation = kernel_decode_image_interpolation(info); - uint extension = kernel_decode_image_extension(info); + uint interpolation = kernel_decode_image_interpolation(info->options); + uint extension = kernel_decode_image_extension(info->options); + /* Actual sampling. */ float4 r; int ix, iy, nix, niy; @@ -150,14 +165,17 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x, float y, float z) { - uint4 info = kernel_tex_fetch(__tex_image_packed_info, id*2); - uint width = info.x; - uint height = info.y; - uint offset = info.z; - uint depth = kernel_tex_fetch(__tex_image_packed_info, id*2+1).x; + const ccl_global tex_info_t *info = kernel_tex_info(kg, id); + + uint width = info->width; + uint height = info->height; + uint offset = 0; + uint depth = info->depth; + /* Decode image options. */ - uint interpolation = kernel_decode_image_interpolation(info); - uint extension = kernel_decode_image_extension(info); + uint interpolation = kernel_decode_image_interpolation(info->options); + uint extension = kernel_decode_image_extension(info->options); + /* Actual sampling. */ float4 r; int ix, iy, iz, nix, niy, niz; diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 8f6c2b07381..21564e81b7a 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -649,7 +649,6 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg, state.flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_SHADOW_CATCHER_ONLY | PATH_RAY_STORE_SHADOW_INFO); - state.catcher_object = sd.object; if(!kernel_data.background.transparent) { L->shadow_background_color = indirect_background(kg, &emission_sd, &state, &ray); @@ -783,7 +782,7 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg, #endif /* __SUBSURFACE__ */ #ifdef __SHADOW_TRICKS__ - *is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER); + *is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER) != 0; #endif /* __SHADOW_TRICKS__ */ #ifdef __KERNEL_DEBUG__ diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h index 77d4f1df447..4ec37d225f7 100644 --- a/intern/cycles/kernel/kernel_path_branched.h +++ b/intern/cycles/kernel/kernel_path_branched.h @@ -502,7 +502,6 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg, state.flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_SHADOW_CATCHER_ONLY | PATH_RAY_STORE_SHADOW_INFO); - state.catcher_object = sd.object; if(!kernel_data.background.transparent) { L->shadow_background_color = indirect_background(kg, &emission_sd, &state, &ray); @@ -628,7 +627,7 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg, } #ifdef __SHADOW_TRICKS__ - *is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER); + *is_shadow_catcher = (state.flag & PATH_RAY_SHADOW_CATCHER) != 0; #endif /* __SHADOW_TRICKS__ */ #ifdef __KERNEL_DEBUG__ diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h index 3ce183bf67a..0102de183f3 100644 --- a/intern/cycles/kernel/kernel_path_state.h +++ b/intern/cycles/kernel/kernel_path_state.h @@ -64,10 +64,6 @@ ccl_device_inline void path_state_init(KernelGlobals *kg, state->volume_stack[0].shader = SHADER_NONE; } #endif - -#ifdef __SHADOW_TRICKS__ - state->catcher_object = OBJECT_NONE; -#endif } ccl_device_inline void path_state_next(KernelGlobals *kg, ccl_addr_space PathState *state, int label) diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index c66f52255f0..90b936d83c9 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -83,7 +83,7 @@ ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg, float4 curvedata = kernel_tex_fetch(__curves, sd->prim); sd->shader = __float_as_int(curvedata.z); - sd->P = bvh_curve_refine(kg, sd, isect, ray); + sd->P = curve_refine(kg, sd, isect, ray); } else #endif diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h index fab5946970d..10e9083551e 100644 --- a/intern/cycles/kernel/kernel_shadow.h +++ b/intern/cycles/kernel/kernel_shadow.h @@ -72,13 +72,14 @@ ccl_device_forceinline bool shadow_handle_transparent_isect( ccl_device bool shadow_blocked_opaque(KernelGlobals *kg, ShaderData *shadow_sd, ccl_addr_space PathState *state, + const uint visibility, Ray *ray, Intersection *isect, float3 *shadow) { const bool blocked = scene_intersect(kg, *ray, - PATH_RAY_SHADOW_OPAQUE, + visibility & PATH_RAY_SHADOW_OPAQUE, isect, NULL, 0.0f, 0.0f); @@ -128,7 +129,7 @@ ccl_device bool shadow_blocked_opaque(KernelGlobals *kg, ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg, ShaderData *shadow_sd, ccl_addr_space PathState *state, - const int skip_object, + const uint visibility, Ray *ray, Intersection *hits, uint max_hits, @@ -141,7 +142,7 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg, const bool blocked = scene_intersect_shadow_all(kg, ray, hits, - skip_object, + visibility, max_hits, &num_hits); /* If no opaque surface found but we did find transparent hits, @@ -218,7 +219,7 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg, ccl_device bool shadow_blocked_transparent_all(KernelGlobals *kg, ShaderData *shadow_sd, ccl_addr_space PathState *state, - const int skip_object, + const uint visibility, Ray *ray, uint max_hits, float3 *shadow) @@ -253,7 +254,7 @@ ccl_device bool shadow_blocked_transparent_all(KernelGlobals *kg, return shadow_blocked_transparent_all_loop(kg, shadow_sd, state, - skip_object, + visibility, ray, hits, max_hits, @@ -278,14 +279,14 @@ ccl_device bool shadow_blocked_transparent_stepped_loop( KernelGlobals *kg, ShaderData *shadow_sd, ccl_addr_space PathState *state, - const int skip_object, + const uint visibility, Ray *ray, Intersection *isect, const bool blocked, const bool is_transparent_isect, float3 *shadow) { - if((blocked && is_transparent_isect) || skip_object != OBJECT_NONE) { + if(blocked && is_transparent_isect) { float3 throughput = make_float3(1.0f, 1.0f, 1.0f); float3 Pend = ray->P + ray->D*ray->t; int bounce = state->transparent_bounce; @@ -304,30 +305,13 @@ ccl_device bool shadow_blocked_transparent_stepped_loop( } if(!scene_intersect(kg, *ray, - PATH_RAY_SHADOW_TRANSPARENT, + visibility & PATH_RAY_SHADOW_TRANSPARENT, isect, NULL, 0.0f, 0.0f)) { break; } -#ifdef __SHADOW_TRICKS__ - if(skip_object != OBJECT_NONE) { - const int isect_object = (isect->object == PRIM_NONE) - ? kernel_tex_fetch(__prim_object, isect->prim) - : isect->object; - if(isect_object == skip_object) { - shader_setup_from_ray(kg, shadow_sd, isect, ray); - /* Move ray forward. */ - ray->P = ray_offset(shadow_sd->P, -shadow_sd->Ng); - if(ray->t != FLT_MAX) { - ray->D = normalize_len(Pend - ray->P, &ray->t); - } - bounce++; - continue; - } - } -#endif if(!shader_transparent_shadow(kg, isect)) { return true; } @@ -373,31 +357,24 @@ ccl_device bool shadow_blocked_transparent_stepped( KernelGlobals *kg, ShaderData *shadow_sd, ccl_addr_space PathState *state, - const int skip_object, + const uint visibility, Ray *ray, Intersection *isect, float3 *shadow) { - bool blocked, is_transparent_isect; - if(skip_object == OBJECT_NONE) { - blocked = scene_intersect(kg, - *ray, - PATH_RAY_SHADOW_OPAQUE, - isect, - NULL, - 0.0f, 0.0f); - is_transparent_isect = blocked - ? shader_transparent_shadow(kg, isect) - : false; - } - else { - blocked = false; - is_transparent_isect = false; - } + bool blocked = scene_intersect(kg, + *ray, + visibility & PATH_RAY_SHADOW_OPAQUE, + isect, + NULL, + 0.0f, 0.0f); + bool is_transparent_isect = blocked + ? shader_transparent_shadow(kg, isect) + : false; return shadow_blocked_transparent_stepped_loop(kg, shadow_sd, state, - skip_object, + visibility, ray, isect, blocked, @@ -422,25 +399,24 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, return false; } #ifdef __SHADOW_TRICKS__ - const int skip_object = state->catcher_object; + const uint visibility = (state->flag & PATH_RAY_SHADOW_CATCHER) + ? PATH_RAY_SHADOW_NON_CATCHER + : PATH_RAY_SHADOW; #else - const int skip_object = OBJECT_NONE; + const uint visibility = PATH_RAY_SHADOW; #endif /* Do actual shadow shading. */ /* First of all, we check if integrator requires transparent shadows. * if not, we use simplest and fastest ever way to calculate occlusion. - * - * NOTE: We can't do quick opaque test here if we are on shadow-catcher - * path because we don't want catcher object to be casting shadow here. */ #ifdef __TRANSPARENT_SHADOWS__ - if(!kernel_data.integrator.transparent_shadows && - skip_object == OBJECT_NONE) + if(!kernel_data.integrator.transparent_shadows) #endif { return shadow_blocked_opaque(kg, shadow_sd, state, + visibility, ray, &isect, shadow); @@ -467,7 +443,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, */ const bool blocked = scene_intersect(kg, *ray, - PATH_RAY_SHADOW_OPAQUE, + visibility & PATH_RAY_SHADOW_OPAQUE, &isect, NULL, 0.0f, 0.0f); @@ -480,7 +456,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, return shadow_blocked_transparent_stepped_loop(kg, shadow_sd, state, - skip_object, + visibility, ray, &isect, blocked, @@ -491,7 +467,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, return shadow_blocked_transparent_all(kg, shadow_sd, state, - skip_object, + visibility, ray, max_hits, shadow); @@ -500,7 +476,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, return shadow_blocked_transparent_stepped(kg, shadow_sd, state, - skip_object, + visibility, ray, &isect, shadow); diff --git a/intern/cycles/kernel/kernel_textures.h b/intern/cycles/kernel/kernel_textures.h index aa5b32803a5..dc6bbbb9924 100644 --- a/intern/cycles/kernel/kernel_textures.h +++ b/intern/cycles/kernel/kernel_textures.h @@ -184,15 +184,8 @@ KERNEL_IMAGE_TEX(uchar4, texture_image_uchar4, __tex_image_byte4_665) # else /* bindless textures */ KERNEL_TEX(uint, texture_uint, __bindless_mapping) -# endif -#endif - -/* packed image (opencl) */ -KERNEL_TEX(uchar4, texture_uchar4, __tex_image_byte4_packed) -KERNEL_TEX(float4, texture_float4, __tex_image_float4_packed) -KERNEL_TEX(uchar, texture_uchar, __tex_image_byte_packed) -KERNEL_TEX(float, texture_float, __tex_image_float_packed) -KERNEL_TEX(uint4, texture_uint4, __tex_image_packed_info) +# endif /* __CUDA_ARCH__ */ +#endif /* __KERNEL_CUDA__ */ #undef KERNEL_TEX #undef KERNEL_IMAGE_TEX diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 557ce5804f8..90a3c818214 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -330,24 +330,29 @@ enum PathRayFlag { PATH_RAY_SINGULAR = (1 << 5), PATH_RAY_TRANSPARENT = (1 << 6), - PATH_RAY_SHADOW_OPAQUE = (1 << 7), - PATH_RAY_SHADOW_TRANSPARENT = (1 << 8), - PATH_RAY_SHADOW = (PATH_RAY_SHADOW_OPAQUE|PATH_RAY_SHADOW_TRANSPARENT), - - PATH_RAY_CURVE = (1 << 9), /* visibility flag to define curve segments */ - PATH_RAY_VOLUME_SCATTER = (1 << 10), /* volume scattering */ + PATH_RAY_SHADOW_OPAQUE_NON_CATCHER = (1 << 7), + PATH_RAY_SHADOW_OPAQUE_CATCHER = (1 << 8), + PATH_RAY_SHADOW_OPAQUE = (PATH_RAY_SHADOW_OPAQUE_NON_CATCHER|PATH_RAY_SHADOW_OPAQUE_CATCHER), + PATH_RAY_SHADOW_TRANSPARENT_NON_CATCHER = (1 << 9), + PATH_RAY_SHADOW_TRANSPARENT_CATCHER = (1 << 10), + PATH_RAY_SHADOW_TRANSPARENT = (PATH_RAY_SHADOW_TRANSPARENT_NON_CATCHER|PATH_RAY_SHADOW_TRANSPARENT_CATCHER), + PATH_RAY_SHADOW_NON_CATCHER = (PATH_RAY_SHADOW_OPAQUE_NON_CATCHER|PATH_RAY_SHADOW_TRANSPARENT_NON_CATCHER), + PATH_RAY_SHADOW = (PATH_RAY_SHADOW_OPAQUE|PATH_RAY_SHADOW_TRANSPARENT), + + PATH_RAY_CURVE = (1 << 11), /* visibility flag to define curve segments */ + PATH_RAY_VOLUME_SCATTER = (1 << 12), /* volume scattering */ /* Special flag to tag unaligned BVH nodes. */ - PATH_RAY_NODE_UNALIGNED = (1 << 11), + PATH_RAY_NODE_UNALIGNED = (1 << 13), - PATH_RAY_ALL_VISIBILITY = ((1 << 12)-1), + PATH_RAY_ALL_VISIBILITY = ((1 << 14)-1), - PATH_RAY_MIS_SKIP = (1 << 12), - PATH_RAY_DIFFUSE_ANCESTOR = (1 << 13), - PATH_RAY_SINGLE_PASS_DONE = (1 << 14), - PATH_RAY_SHADOW_CATCHER = (1 << 15), - PATH_RAY_SHADOW_CATCHER_ONLY = (1 << 16), - PATH_RAY_STORE_SHADOW_INFO = (1 << 17), + PATH_RAY_MIS_SKIP = (1 << 15), + PATH_RAY_DIFFUSE_ANCESTOR = (1 << 16), + PATH_RAY_SINGLE_PASS_DONE = (1 << 17), + PATH_RAY_SHADOW_CATCHER = (1 << 18), + PATH_RAY_SHADOW_CATCHER_ONLY = (1 << 19), + PATH_RAY_STORE_SHADOW_INFO = (1 << 20), }; /* Closure Label */ @@ -1027,10 +1032,6 @@ typedef struct PathState { RNG rng_congruential; VolumeStack volume_stack[VOLUME_STACK_SIZE]; #endif - -#ifdef __SHADOW_TRICKS__ - int catcher_object; -#endif } PathState; /* Subsurface */ diff --git a/intern/cycles/kernel/kernels/cpu/filter_sse2.cpp b/intern/cycles/kernel/kernels/cpu/filter_sse2.cpp index a13fb5cd4fb..f7c9935f1d0 100644 --- a/intern/cycles/kernel/kernels/cpu/filter_sse2.cpp +++ b/intern/cycles/kernel/kernels/cpu/filter_sse2.cpp @@ -25,7 +25,6 @@ #else /* SSE optimization disabled for now on 32 bit, see bug #36316 */ # if !(defined(__GNUC__) && (defined(i386) || defined(_M_IX86))) -# define __KERNEL_SSE__ # define __KERNEL_SSE2__ # endif #endif /* WITH_CYCLES_OPTIMIZED_KERNEL_SSE2 */ diff --git a/intern/cycles/kernel/kernels/cpu/filter_sse3.cpp b/intern/cycles/kernel/kernels/cpu/filter_sse3.cpp index 6b690adf0f5..070b95a3505 100644 --- a/intern/cycles/kernel/kernels/cpu/filter_sse3.cpp +++ b/intern/cycles/kernel/kernels/cpu/filter_sse3.cpp @@ -25,7 +25,6 @@ #else /* SSE optimization disabled for now on 32 bit, see bug #36316 */ # if !(defined(__GNUC__) && (defined(i386) || defined(_M_IX86))) -# define __KERNEL_SSE__ # define __KERNEL_SSE2__ # define __KERNEL_SSE3__ # define __KERNEL_SSSE3__ diff --git a/intern/cycles/kernel/kernels/opencl/kernel.cl b/intern/cycles/kernel/kernels/opencl/kernel.cl index 078acc1631e..b7108f3d0f8 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel.cl @@ -52,9 +52,7 @@ __kernel void kernel_ocl_path_trace( ccl_global float *buffer, ccl_global uint *rng_state, -#define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name, -#include "kernel/kernel_textures.h" + KERNEL_BUFFER_PARAMS, int sample, int sx, int sy, int sw, int sh, int offset, int stride) @@ -63,9 +61,8 @@ __kernel void kernel_ocl_path_trace( kg->data = data; -#define KERNEL_TEX(type, ttype, name) \ - kg->name = name; -#include "kernel/kernel_textures.h" + kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS); + kernel_set_buffer_info(kg); int x = sx + ccl_global_id(0); int y = sy + ccl_global_id(1); @@ -82,9 +79,7 @@ __kernel void kernel_ocl_shader( ccl_global float4 *output, ccl_global float *output_luma, -#define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name, -#include "kernel/kernel_textures.h" + KERNEL_BUFFER_PARAMS, int type, int sx, int sw, int offset, int sample) { @@ -92,9 +87,8 @@ __kernel void kernel_ocl_shader( kg->data = data; -#define KERNEL_TEX(type, ttype, name) \ - kg->name = name; -#include "kernel/kernel_textures.h" + kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS); + kernel_set_buffer_info(kg); int x = sx + ccl_global_id(0); @@ -114,9 +108,7 @@ __kernel void kernel_ocl_bake( ccl_global uint4 *input, ccl_global float4 *output, -#define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name, -#include "kernel/kernel_textures.h" + KERNEL_BUFFER_PARAMS, int type, int filter, int sx, int sw, int offset, int sample) { @@ -124,9 +116,8 @@ __kernel void kernel_ocl_bake( kg->data = data; -#define KERNEL_TEX(type, ttype, name) \ - kg->name = name; -#include "kernel/kernel_textures.h" + kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS); + kernel_set_buffer_info(kg); int x = sx + ccl_global_id(0); @@ -144,9 +135,7 @@ __kernel void kernel_ocl_convert_to_byte( ccl_global uchar4 *rgba, ccl_global float *buffer, -#define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name, -#include "kernel/kernel_textures.h" + KERNEL_BUFFER_PARAMS, float sample_scale, int sx, int sy, int sw, int sh, int offset, int stride) @@ -155,9 +144,8 @@ __kernel void kernel_ocl_convert_to_byte( kg->data = data; -#define KERNEL_TEX(type, ttype, name) \ - kg->name = name; -#include "kernel/kernel_textures.h" + kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS); + kernel_set_buffer_info(kg); int x = sx + ccl_global_id(0); int y = sy + ccl_global_id(1); @@ -171,9 +159,7 @@ __kernel void kernel_ocl_convert_to_half_float( ccl_global uchar4 *rgba, ccl_global float *buffer, -#define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name, -#include "kernel/kernel_textures.h" + KERNEL_BUFFER_PARAMS, float sample_scale, int sx, int sy, int sw, int sh, int offset, int stride) @@ -182,9 +168,8 @@ __kernel void kernel_ocl_convert_to_half_float( kg->data = data; -#define KERNEL_TEX(type, ttype, name) \ - kg->name = name; -#include "kernel/kernel_textures.h" + kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS); + kernel_set_buffer_info(kg); int x = sx + ccl_global_id(0); int y = sy + ccl_global_id(1); @@ -193,7 +178,7 @@ __kernel void kernel_ocl_convert_to_half_float( kernel_film_convert_to_half_float(kg, rgba, buffer, sample_scale, x, y, offset, stride); } -__kernel void kernel_ocl_zero_buffer(ccl_global float4 *buffer, ulong size, ulong offset) +__kernel void kernel_ocl_zero_buffer(ccl_global float4 *buffer, uint64_t size, uint64_t offset) { size_t i = ccl_global_id(0) + ccl_global_id(1) * ccl_global_size(0); diff --git a/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl b/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl index 8b85d362f8a..95b35e40a45 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl @@ -25,11 +25,7 @@ __kernel void kernel_ocl_path_trace_data_init( int num_elements, ccl_global char *ray_state, ccl_global uint *rng_state, - -#define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name, -#include "kernel/kernel_textures.h" - + KERNEL_BUFFER_PARAMS, int start_sample, int end_sample, int sx, int sy, int sw, int sh, int offset, int stride, @@ -46,10 +42,7 @@ __kernel void kernel_ocl_path_trace_data_init( num_elements, ray_state, rng_state, - -#define KERNEL_TEX(type, ttype, name) name, -#include "kernel/kernel_textures.h" - + KERNEL_BUFFER_ARGS, start_sample, end_sample, sx, sy, sw, sh, offset, stride, diff --git a/intern/cycles/kernel/kernels/opencl/kernel_split_function.h b/intern/cycles/kernel/kernels/opencl/kernel_split_function.h index f1e914a70d4..591c3846ef2 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_split_function.h +++ b/intern/cycles/kernel/kernels/opencl/kernel_split_function.h @@ -25,9 +25,7 @@ __kernel void KERNEL_NAME_EVAL(kernel_ocl_path_trace, KERNEL_NAME)( ccl_global char *ray_state, ccl_global uint *rng_state, -#define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name, -#include "kernel/kernel_textures.h" + KERNEL_BUFFER_PARAMS, ccl_global int *queue_index, ccl_global char *use_queues_flag, @@ -52,12 +50,9 @@ __kernel void KERNEL_NAME_EVAL(kernel_ocl_path_trace, KERNEL_NAME)( split_data_init(kg, &kernel_split_state, ccl_global_size(0)*ccl_global_size(1), split_data_buffer, ray_state); -#define KERNEL_TEX(type, ttype, name) \ - kg->name = name; -#include "kernel/kernel_textures.h" } - ccl_barrier(CCL_LOCAL_MEM_FENCE); + kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS); KERNEL_NAME_EVAL(kernel, KERNEL_NAME)( kg diff --git a/intern/cycles/kernel/split/kernel_data_init.h b/intern/cycles/kernel/split/kernel_data_init.h index e4545d66eff..6f3297de342 100644 --- a/intern/cycles/kernel/split/kernel_data_init.h +++ b/intern/cycles/kernel/split/kernel_data_init.h @@ -52,9 +52,7 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)( ccl_global uint *rng_state, #ifdef __KERNEL_OPENCL__ -#define KERNEL_TEX(type, ttype, name) \ - ccl_global type *name, -#include "kernel/kernel_textures.h" + KERNEL_BUFFER_PARAMS, #endif int start_sample, @@ -100,9 +98,8 @@ void KERNEL_FUNCTION_FULL_NAME(data_init)( split_data_init(kg, &kernel_split_state, num_elements, split_data_buffer, ray_state); #ifdef __KERNEL_OPENCL__ -#define KERNEL_TEX(type, ttype, name) \ - kg->name = name; -#include "kernel/kernel_textures.h" + kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS); + kernel_set_buffer_info(kg); #endif int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0); diff --git a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h index fec671be016..916b81faf4e 100644 --- a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h +++ b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h @@ -129,7 +129,6 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao( state->flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_SHADOW_CATCHER_ONLY | PATH_RAY_STORE_SHADOW_INFO); - state->catcher_object = sd->object; if(!kernel_data.background.transparent) { ccl_global Ray *ray = &kernel_split_state.ray[ray_index]; L->shadow_background_color = indirect_background( diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index a490f10aee4..80ec77f8b4a 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -43,7 +43,6 @@ static bool isfinite(half /*value*/) ImageManager::ImageManager(const DeviceInfo& info) { need_update = true; - pack_images = false; osl_texture_system = NULL; animation_frame = 0; @@ -87,11 +86,6 @@ ImageManager::~ImageManager() } } -void ImageManager::set_pack_images(bool pack_images_) -{ - pack_images = pack_images_; -} - void ImageManager::set_osl_texture_system(void *texture_system) { osl_texture_system = texture_system; @@ -742,7 +736,7 @@ void ImageManager::device_load_image(Device *device, pixels[3] = TEX_IMAGE_MISSING_A; } - if(!pack_images) { + { thread_scoped_lock device_lock(device_mutex); device->tex_alloc(name.c_str(), tex_img, @@ -771,7 +765,7 @@ void ImageManager::device_load_image(Device *device, pixels[0] = TEX_IMAGE_MISSING_R; } - if(!pack_images) { + { thread_scoped_lock device_lock(device_mutex); device->tex_alloc(name.c_str(), tex_img, @@ -803,7 +797,7 @@ void ImageManager::device_load_image(Device *device, pixels[3] = (TEX_IMAGE_MISSING_A * 255); } - if(!pack_images) { + { thread_scoped_lock device_lock(device_mutex); device->tex_alloc(name.c_str(), tex_img, @@ -831,7 +825,7 @@ void ImageManager::device_load_image(Device *device, pixels[0] = (TEX_IMAGE_MISSING_R * 255); } - if(!pack_images) { + { thread_scoped_lock device_lock(device_mutex); device->tex_alloc(name.c_str(), tex_img, @@ -862,7 +856,7 @@ void ImageManager::device_load_image(Device *device, pixels[3] = TEX_IMAGE_MISSING_A; } - if(!pack_images) { + { thread_scoped_lock device_lock(device_mutex); device->tex_alloc(name.c_str(), tex_img, @@ -890,7 +884,7 @@ void ImageManager::device_load_image(Device *device, pixels[0] = TEX_IMAGE_MISSING_R; } - if(!pack_images) { + { thread_scoped_lock device_lock(device_mutex); device->tex_alloc(name.c_str(), tex_img, @@ -1047,9 +1041,6 @@ void ImageManager::device_update(Device *device, pool.wait_work(); - if(pack_images) - device_pack_images(device, dscene, progress); - need_update = false; } @@ -1079,141 +1070,6 @@ void ImageManager::device_update_slot(Device *device, } } -uint8_t ImageManager::pack_image_options(ImageDataType type, size_t slot) -{ - uint8_t options = 0; - /* Image Options are packed into one uint: - * bit 0 -> Interpolation - * bit 1 + 2 + 3 -> Extension - */ - if(images[type][slot]->interpolation == INTERPOLATION_CLOSEST) { - options |= (1 << 0); - } - if(images[type][slot]->extension == EXTENSION_REPEAT) { - options |= (1 << 1); - } - else if(images[type][slot]->extension == EXTENSION_EXTEND) { - options |= (1 << 2); - } - else /* EXTENSION_CLIP */ { - options |= (1 << 3); - } - return options; -} - -template<typename T> -void ImageManager::device_pack_images_type( - ImageDataType type, - const vector<device_vector<T>*>& cpu_textures, - device_vector<T> *device_image, - uint4 *info) -{ - size_t size = 0, offset = 0; - /* First step is to calculate size of the texture we need. */ - for(size_t slot = 0; slot < images[type].size(); slot++) { - if(images[type][slot] == NULL) { - continue; - } - device_vector<T>& tex_img = *cpu_textures[slot]; - size += tex_img.size(); - } - /* Now we know how much memory we need, so we can allocate and fill. */ - T *pixels = device_image->resize(size); - for(size_t slot = 0; slot < images[type].size(); slot++) { - if(images[type][slot] == NULL) { - continue; - } - device_vector<T>& tex_img = *cpu_textures[slot]; - uint8_t options = pack_image_options(type, slot); - const int index = type_index_to_flattened_slot(slot, type) * 2; - info[index] = make_uint4(tex_img.data_width, - tex_img.data_height, - offset, - options); - info[index+1] = make_uint4(tex_img.data_depth, 0, 0, 0); - memcpy(pixels + offset, - (void*)tex_img.data_pointer, - tex_img.memory_size()); - offset += tex_img.size(); - } -} - -void ImageManager::device_pack_images(Device *device, - DeviceScene *dscene, - Progress& /*progess*/) -{ - /* For OpenCL, we pack all image textures into a single large texture, and - * do our own interpolation in the kernel. - */ - - /* TODO(sergey): This will over-allocate a bit, but this is constant memory - * so should be fine for a short term. - */ - const size_t info_size = max4(max_flattened_slot(IMAGE_DATA_TYPE_FLOAT4), - max_flattened_slot(IMAGE_DATA_TYPE_BYTE4), - max_flattened_slot(IMAGE_DATA_TYPE_FLOAT), - max_flattened_slot(IMAGE_DATA_TYPE_BYTE)); - uint4 *info = dscene->tex_image_packed_info.resize(info_size*2); - - /* Pack byte4 textures. */ - device_pack_images_type(IMAGE_DATA_TYPE_BYTE4, - dscene->tex_byte4_image, - &dscene->tex_image_byte4_packed, - info); - /* Pack float4 textures. */ - device_pack_images_type(IMAGE_DATA_TYPE_FLOAT4, - dscene->tex_float4_image, - &dscene->tex_image_float4_packed, - info); - /* Pack byte textures. */ - device_pack_images_type(IMAGE_DATA_TYPE_BYTE, - dscene->tex_byte_image, - &dscene->tex_image_byte_packed, - info); - /* Pack float textures. */ - device_pack_images_type(IMAGE_DATA_TYPE_FLOAT, - dscene->tex_float_image, - &dscene->tex_image_float_packed, - info); - - /* Push textures to the device. */ - if(dscene->tex_image_byte4_packed.size()) { - if(dscene->tex_image_byte4_packed.device_pointer) { - thread_scoped_lock device_lock(device_mutex); - device->tex_free(dscene->tex_image_byte4_packed); - } - device->tex_alloc("__tex_image_byte4_packed", dscene->tex_image_byte4_packed); - } - if(dscene->tex_image_float4_packed.size()) { - if(dscene->tex_image_float4_packed.device_pointer) { - thread_scoped_lock device_lock(device_mutex); - device->tex_free(dscene->tex_image_float4_packed); - } - device->tex_alloc("__tex_image_float4_packed", dscene->tex_image_float4_packed); - } - if(dscene->tex_image_byte_packed.size()) { - if(dscene->tex_image_byte_packed.device_pointer) { - thread_scoped_lock device_lock(device_mutex); - device->tex_free(dscene->tex_image_byte_packed); - } - device->tex_alloc("__tex_image_byte_packed", dscene->tex_image_byte_packed); - } - if(dscene->tex_image_float_packed.size()) { - if(dscene->tex_image_float_packed.device_pointer) { - thread_scoped_lock device_lock(device_mutex); - device->tex_free(dscene->tex_image_float_packed); - } - device->tex_alloc("__tex_image_float_packed", dscene->tex_image_float_packed); - } - if(dscene->tex_image_packed_info.size()) { - if(dscene->tex_image_packed_info.device_pointer) { - thread_scoped_lock device_lock(device_mutex); - device->tex_free(dscene->tex_image_packed_info); - } - device->tex_alloc("__tex_image_packed_info", dscene->tex_image_packed_info); - } -} - void ImageManager::device_free_builtin(Device *device, DeviceScene *dscene) { for(int type = 0; type < IMAGE_DATA_NUM_TYPES; type++) { @@ -1239,18 +1095,6 @@ void ImageManager::device_free(Device *device, DeviceScene *dscene) dscene->tex_float_image.clear(); dscene->tex_byte_image.clear(); dscene->tex_half_image.clear(); - - device->tex_free(dscene->tex_image_float4_packed); - device->tex_free(dscene->tex_image_byte4_packed); - device->tex_free(dscene->tex_image_float_packed); - device->tex_free(dscene->tex_image_byte_packed); - device->tex_free(dscene->tex_image_packed_info); - - dscene->tex_image_float4_packed.clear(); - dscene->tex_image_byte4_packed.clear(); - dscene->tex_image_float_packed.clear(); - dscene->tex_image_byte_packed.clear(); - dscene->tex_image_packed_info.clear(); } CCL_NAMESPACE_END diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index db7e28a5e44..c86d1cbedbf 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -76,7 +76,6 @@ public: void device_free_builtin(Device *device, DeviceScene *dscene); void set_osl_texture_system(void *texture_system); - void set_pack_images(bool pack_images_); bool set_animation_frame_update(int frame); bool need_update; @@ -130,7 +129,6 @@ private: vector<Image*> images[IMAGE_DATA_NUM_TYPES]; void *osl_texture_system; - bool pack_images; bool file_load_image_generic(Image *img, ImageInput **in, @@ -152,8 +150,6 @@ private: int flattened_slot_to_type_index(int flat_slot, ImageDataType *type); string name_from_type(int type); - uint8_t pack_image_options(ImageDataType type, size_t slot); - void device_load_image(Device *device, DeviceScene *dscene, Scene *scene, @@ -164,17 +160,6 @@ private: DeviceScene *dscene, ImageDataType type, int slot); - - template<typename T> - void device_pack_images_type( - ImageDataType type, - const vector<device_vector<T>*>& cpu_textures, - device_vector<T> *device_image, - uint4 *info); - - void device_pack_images(Device *device, - DeviceScene *dscene, - Progress& progess); }; CCL_NAMESPACE_END diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 03825f780e0..84537bf5993 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -1925,16 +1925,7 @@ void MeshManager::device_update_displacement_images(Device *device, if(node->special_type != SHADER_SPECIAL_TYPE_IMAGE_SLOT) { continue; } - if(device->info.pack_images) { - /* If device requires packed images we need to update all - * images now, even if they're not used for displacement. - */ - image_manager->device_update(device, - dscene, - scene, - progress); - return; - } + ImageSlotTextureNode *image_node = static_cast<ImageSlotTextureNode*>(node); int slot = image_node->slot; if(slot != -1) { diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 375abfeb27a..b00e5624266 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -262,6 +262,17 @@ bool Object::is_traceable() return true; } +uint Object::visibility_for_tracing() const { + uint trace_visibility = visibility; + if (is_shadow_catcher) { + trace_visibility &= ~PATH_RAY_SHADOW_NON_CATCHER; + } + else { + trace_visibility &= ~PATH_RAY_SHADOW_CATCHER; + } + return trace_visibility; +} + /* Object Manager */ ObjectManager::ObjectManager() diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h index 12d7b2c81cf..6927bbfe4c7 100644 --- a/intern/cycles/render/object.h +++ b/intern/cycles/render/object.h @@ -60,7 +60,7 @@ public: ParticleSystem *particle_system; int particle_index; - + Object(); ~Object(); @@ -75,6 +75,11 @@ public: * kernel scene. */ bool is_traceable(); + + /* Combine object's visibility with all possible internal run-time + * determined flags which denotes trace-time visibility. + */ + uint visibility_for_tracing() const; }; /* Object Manager */ diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index a794f233718..c337079b09f 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -233,8 +233,10 @@ void OSLShaderManager::shading_system_init() "glossy", /* PATH_RAY_GLOSSY */ "singular", /* PATH_RAY_SINGULAR */ "transparent", /* PATH_RAY_TRANSPARENT */ - "shadow", /* PATH_RAY_SHADOW_OPAQUE */ - "shadow", /* PATH_RAY_SHADOW_TRANSPARENT */ + "shadow", /* PATH_RAY_SHADOW_OPAQUE_NON_CATCHER */ + "shadow", /* PATH_RAY_SHADOW_OPAQUE_CATCHER */ + "shadow", /* PATH_RAY_SHADOW_TRANSPARENT_NON_CATCHER */ + "shadow", /* PATH_RAY_SHADOW_TRANSPARENT_CATCHER */ "__unused__", "__unused__", diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index 4db20338744..c59a5d97df5 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -148,8 +148,6 @@ void Scene::device_update(Device *device_, Progress& progress) * - Film needs light manager to run for use_light_visibility * - Lookup tables are done a second time to handle film tables */ - - image_manager->set_pack_images(device->info.pack_images); progress.set_status("Updating Shaders"); shader_manager->device_update(device, &dscene, this, progress); diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h index 4c2c4f5fcc3..0194327f567 100644 --- a/intern/cycles/render/scene.h +++ b/intern/cycles/render/scene.h @@ -121,13 +121,6 @@ public: vector<device_vector<uchar>* > tex_byte_image; vector<device_vector<half>* > tex_half_image; - /* opencl images */ - device_vector<float4> tex_image_float4_packed; - device_vector<uchar4> tex_image_byte4_packed; - device_vector<float> tex_image_float_packed; - device_vector<uchar> tex_image_byte_packed; - device_vector<uint4> tex_image_packed_info; - KernelData data; }; diff --git a/intern/cycles/util/util_defines.h b/intern/cycles/util/util_defines.h index d0d87e74332..ae654092c87 100644 --- a/intern/cycles/util/util_defines.h +++ b/intern/cycles/util/util_defines.h @@ -35,6 +35,7 @@ # define ccl_local_param # define ccl_private # define ccl_restrict __restrict +# define ccl_ref & # define __KERNEL_WITH_SSE_ALIGN__ # if defined(_WIN32) && !defined(FREE_WINDOWS) diff --git a/intern/cycles/util/util_math_float4.h b/intern/cycles/util/util_math_float4.h index adb9a76a434..57befea66c4 100644 --- a/intern/cycles/util/util_math_float4.h +++ b/intern/cycles/util/util_math_float4.h @@ -286,13 +286,14 @@ ccl_device_inline float4 reduce_add(const float4& a) return shuffle<2,3,0,1>(h) + h; # endif #else - return make_float4(((a.x + a.y) + (a.z + a.w))); + float sum = (a.x + a.y) + (a.z + a.w); + return make_float4(sum, sum, sum, sum); #endif } ccl_device_inline float average(const float4& a) { - return reduce_add(a)[0] * 0.25f; + return reduce_add(a).x * 0.25f; } ccl_device_inline float len(const float4& a) diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h index a2b3247b207..1a26ca697dd 100644 --- a/intern/cycles/util/util_simd.h +++ b/intern/cycles/util/util_simd.h @@ -358,33 +358,45 @@ __forceinline size_t __bscf(size_t& v) #define _MM_FROUND_CUR_DIRECTION 0x04 #undef _mm_blendv_ps -__forceinline __m128 _mm_blendv_ps( __m128 value, __m128 input, __m128 mask ) { +#define _mm_blendv_ps _mm_blendv_ps_emu +__forceinline __m128 _mm_blendv_ps_emu( __m128 value, __m128 input, __m128 mask) +{ return _mm_or_ps(_mm_and_ps(mask, input), _mm_andnot_ps(mask, value)); } #undef _mm_blend_ps -__forceinline __m128 _mm_blend_ps( __m128 value, __m128 input, const int mask ) { +#define _mm_blend_ps _mm_blend_ps_emu +__forceinline __m128 _mm_blend_ps_emu( __m128 value, __m128 input, const int mask) +{ assert(mask < 0x10); return _mm_blendv_ps(value, input, _mm_lookupmask_ps[mask]); } #undef _mm_blendv_epi8 -__forceinline __m128i _mm_blendv_epi8( __m128i value, __m128i input, __m128i mask ) { +#define _mm_blendv_epi8 _mm_blendv_epi8_emu +__forceinline __m128i _mm_blendv_epi8_emu( __m128i value, __m128i input, __m128i mask) +{ return _mm_or_si128(_mm_and_si128(mask, input), _mm_andnot_si128(mask, value)); } #undef _mm_min_epi32 -__forceinline __m128i _mm_min_epi32( __m128i value, __m128i input ) { +#define _mm_min_epi32 _mm_min_epi32_emu +__forceinline __m128i _mm_min_epi32_emu( __m128i value, __m128i input) +{ return _mm_blendv_epi8(input, value, _mm_cmplt_epi32(value, input)); } #undef _mm_max_epi32 -__forceinline __m128i _mm_max_epi32( __m128i value, __m128i input ) { +#define _mm_max_epi32 _mm_max_epi32_emu +__forceinline __m128i _mm_max_epi32_emu( __m128i value, __m128i input) +{ return _mm_blendv_epi8(value, input, _mm_cmplt_epi32(value, input)); } #undef _mm_extract_epi32 -__forceinline int _mm_extract_epi32( __m128i input, const int index ) { - switch ( index ) { +#define _mm_extract_epi32 _mm_extract_epi32_emu +__forceinline int _mm_extract_epi32_emu( __m128i input, const int index) +{ + switch(index) { case 0: return _mm_cvtsi128_si32(input); case 1: return _mm_cvtsi128_si32(_mm_shuffle_epi32(input, _MM_SHUFFLE(1, 1, 1, 1))); case 2: return _mm_cvtsi128_si32(_mm_shuffle_epi32(input, _MM_SHUFFLE(2, 2, 2, 2))); @@ -394,18 +406,26 @@ __forceinline int _mm_extract_epi32( __m128i input, const int index ) { } #undef _mm_insert_epi32 -__forceinline __m128i _mm_insert_epi32( __m128i value, int input, const int index ) { +#define _mm_insert_epi32 _mm_insert_epi32_emu +__forceinline __m128i _mm_insert_epi32_emu( __m128i value, int input, const int index) +{ assert(index >= 0 && index < 4); ((int*)&value)[index] = input; return value; } #undef _mm_insert_ps -__forceinline __m128 _mm_insert_ps( __m128 value, __m128 input, const int index ) -{ assert(index < 0x100); ((float*)&value)[(index >> 4)&0x3] = ((float*)&input)[index >> 6]; return _mm_andnot_ps(_mm_lookupmask_ps[index&0xf], value); } +#define _mm_insert_ps _mm_insert_ps_emu +__forceinline __m128 _mm_insert_ps_emu( __m128 value, __m128 input, const int index) +{ + assert(index < 0x100); + ((float*)&value)[(index >> 4)&0x3] = ((float*)&input)[index >> 6]; + return _mm_andnot_ps(_mm_lookupmask_ps[index&0xf], value); +} #undef _mm_round_ps -__forceinline __m128 _mm_round_ps( __m128 value, const int flags ) +#define _mm_round_ps _mm_round_ps_emu +__forceinline __m128 _mm_round_ps_emu( __m128 value, const int flags) { - switch ( flags ) + switch(flags) { case _MM_FROUND_TO_NEAREST_INT: return _mm_cvtepi32_ps(_mm_cvtps_epi32(value)); case _MM_FROUND_TO_NEG_INF : return _mm_cvtepi32_ps(_mm_cvtps_epi32(_mm_add_ps(value, _mm_set1_ps(-0.5f)))); diff --git a/release/windows/blendthumb/CMakeLists.txt b/release/windows/blendthumb/CMakeLists.txt new file mode 100644 index 00000000000..1e5f5131a36 --- /dev/null +++ b/release/windows/blendthumb/CMakeLists.txt @@ -0,0 +1,42 @@ +# ***** 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. +# +# The Original Code is Copyright (C) 2006, Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): Jacques Beaurain. +# +# ***** END GPL LICENSE BLOCK ***** + +#----------------------------------------------------------------------------- +cmake_minimum_required(VERSION 2.8) +project(BlendThumb) + +#Bring the headers, such as Student.h into the project +include_directories(${ZLIB_INCLUDE}) + +#Can manually add the sources using the set command as follows: +set(SOURCES src/BlenderThumb.cpp + src/BlendThumb.def + src/BlendThumb.rc + src/Dll.cpp +) + +add_library(BlendThumb SHARED ${SOURCES}) +target_link_libraries(BlendThumb ${ZLIB_LIBS}) +install (TARGETS BlendThumb DESTINATION bin) diff --git a/release/windows/blendthumb/src/BlendThumb.def b/release/windows/blendthumb/src/BlendThumb.def new file mode 100644 index 00000000000..71f9236735f --- /dev/null +++ b/release/windows/blendthumb/src/BlendThumb.def @@ -0,0 +1,5 @@ +EXPORTS + DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE
\ No newline at end of file diff --git a/release/windows/blendthumb/src/BlendThumb.rc b/release/windows/blendthumb/src/BlendThumb.rc new file mode 100644 index 00000000000..5dfd416b0c5 --- /dev/null +++ b/release/windows/blendthumb/src/BlendThumb.rc @@ -0,0 +1,26 @@ +#define IDR_VERSION1 1 + +IDR_VERSION1 VERSIONINFO +FILEVERSION 1,4,0,0 +PRODUCTVERSION 2,78,0,0 +FILEOS 0x00000004 +FILETYPE 0x00000002 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "FFFF04B0" + BEGIN + VALUE "FileVersion", "1.4\0" + VALUE "ProductVersion", "2.78\0" + VALUE "FileDescription", "Blender Thumbnail Handler\0" + VALUE "OriginalFilename", "BlendThumb.dll\0" + VALUE "ProductName", "Blender\0" + VALUE "LegalCopyright", "GPL2, 2016\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04B0 + END +END + diff --git a/release/windows/blendthumb/src/BlenderThumb.cpp b/release/windows/blendthumb/src/BlenderThumb.cpp new file mode 100644 index 00000000000..508b9f74852 --- /dev/null +++ b/release/windows/blendthumb/src/BlenderThumb.cpp @@ -0,0 +1,324 @@ +/* + * ***** 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 ***** + */ + +#include <shlwapi.h> +#include <thumbcache.h> // For IThumbnailProvider. +#include <new> + +#pragma comment(lib, "shlwapi.lib") + +// this thumbnail provider implements IInitializeWithStream to enable being hosted +// in an isolated process for robustness + +class CBlendThumb : public IInitializeWithStream, public IThumbnailProvider +{ +public: + CBlendThumb() : _cRef(1), _pStream(NULL) {} + + virtual ~CBlendThumb() + { + if (_pStream) + { + _pStream->Release(); + } + } + + // IUnknown + IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + static const QITAB qit[] = + { + QITABENT(CBlendThumb, IInitializeWithStream), + QITABENT(CBlendThumb, IThumbnailProvider), + { 0 }, + }; + return QISearch(this, qit, riid, ppv); + } + + IFACEMETHODIMP_(ULONG) AddRef() + { + return InterlockedIncrement(&_cRef); + } + + IFACEMETHODIMP_(ULONG) Release() + { + ULONG cRef = InterlockedDecrement(&_cRef); + if (!cRef) + { + delete this; + } + return cRef; + } + + // IInitializeWithStream + IFACEMETHODIMP Initialize(IStream *pStream, DWORD grfMode); + + // IThumbnailProvider + IFACEMETHODIMP GetThumbnail(UINT cx, HBITMAP *phbmp, WTS_ALPHATYPE *pdwAlpha); + +private: + long _cRef; + IStream *_pStream; // provided during initialization. +}; + +HRESULT CBlendThumb_CreateInstance(REFIID riid, void **ppv) +{ + CBlendThumb *pNew = new (std::nothrow) CBlendThumb(); + HRESULT hr = pNew ? S_OK : E_OUTOFMEMORY; + if (SUCCEEDED(hr)) + { + hr = pNew->QueryInterface(riid, ppv); + pNew->Release(); + } + return hr; +} + +// IInitializeWithStream +IFACEMETHODIMP CBlendThumb::Initialize(IStream *pStream, DWORD) +{ + HRESULT hr = E_UNEXPECTED; // can only be inited once + if (_pStream == NULL) + { + // take a reference to the stream if we have not been inited yet + hr = pStream->QueryInterface(&_pStream); + } + return hr; +} + +#include <math.h> +#include <zlib.h> +#include "Wincodec.h" +const unsigned char gzip_magic[3] = { 0x1f, 0x8b, 0x08 }; + +// IThumbnailProvider +IFACEMETHODIMP CBlendThumb::GetThumbnail(UINT cx, HBITMAP *phbmp, WTS_ALPHATYPE *pdwAlpha) +{ + ULONG BytesRead; + HRESULT hr = S_FALSE; + LARGE_INTEGER SeekPos; + + // Compressed? + unsigned char in_magic[3]; + _pStream->Read(&in_magic,3,&BytesRead); + bool gzipped = true; + for ( int i=0; i < 3; i++ ) + if ( in_magic[i] != gzip_magic[i] ) + { + gzipped = false; + break; + } + + if (gzipped) + { + // Zlib inflate + z_stream stream; + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; + stream.opaque = Z_NULL; + + // Get compressed file length + SeekPos.QuadPart = 0; + _pStream->Seek(SeekPos,STREAM_SEEK_END,NULL); + + // Get compressed and uncompressed size + uLong source_size; + uLongf dest_size; + //SeekPos.QuadPart = -4; // last 4 bytes define size of uncompressed file + //ULARGE_INTEGER Tell; + //_pStream->Seek(SeekPos,STREAM_SEEK_END,&Tell); + //source_size = (uLong)Tell.QuadPart + 4; // src + //_pStream->Read(&dest_size,4,&BytesRead); // dest + dest_size = 1024*70; // thumbnail is currently always inside the first 65KB...if it moves or enlargens this line will have to change or go! + source_size = (uLong)max(SeekPos.QuadPart,dest_size); // for safety, assume no compression + + // Input + Bytef* src = new Bytef[source_size]; + stream.next_in = (Bytef*)src; + stream.avail_in = (uInt)source_size; + + // Output + Bytef* dest = new Bytef[dest_size]; + stream.next_out = (Bytef*)dest; + stream.avail_out = dest_size; + + // IStream to src + SeekPos.QuadPart = 0; + _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL); + _pStream->Read(src,source_size,&BytesRead); + + // Do the inflation + int err; + err = inflateInit2(&stream,16); // 16 means "gzip"...nice! + err = inflate(&stream, Z_FINISH); + err = inflateEnd(&stream); + + // Replace the IStream, which is read-only + _pStream->Release(); + _pStream = SHCreateMemStream(dest,dest_size); + + delete[] src; + delete[] dest; + } + + // Blender version, early out if sub 2.5 + SeekPos.QuadPart = 9; + _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL); + char version[4]; + version[3] = '\0'; + _pStream->Read(&version,3,&BytesRead); + if ( BytesRead != 3) + return E_UNEXPECTED; + int iVersion = atoi(version); + if ( iVersion < 250 ) + return S_FALSE; + + // 32 or 64 bit blend? + SeekPos.QuadPart = 7; + _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL); + + char _PointerSize; + _pStream->Read(&_PointerSize,1,&BytesRead); + + int PointerSize = _PointerSize == '_' ? 4 : 8; + int HeaderSize = 16 + PointerSize; + + // Find and read thumbnail ("TEST") block + SeekPos.QuadPart = 12; + _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL); + int BlockOffset = 12; + while ( _pStream ) + { + // Scan current block + char BlockName[5]; + BlockName[4] = '\0'; + int BlockSize = 0; + + if (_pStream->Read(BlockName,4,&BytesRead) == S_OK && _pStream->Read((void*)&BlockSize,4,&BytesRead) == S_OK) + { + if ( strcmp (BlockName,"TEST") != 0 ) + { + SeekPos.QuadPart = BlockOffset += HeaderSize + BlockSize; + _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL); + continue; + } + } + else break; // eof + + // Found the block + SeekPos.QuadPart = BlockOffset + HeaderSize; + _pStream->Seek(SeekPos,STREAM_SEEK_SET,NULL); + + int width, height; + _pStream->Read((char*)&width,4,&BytesRead); + _pStream->Read((char*)&height,4,&BytesRead); + BlockSize -= 8; + + // Isolate RGBA data + char* pRGBA = new char[BlockSize]; + _pStream->Read(pRGBA,BlockSize,&BytesRead); + + if (BytesRead != (ULONG)BlockSize) + return E_UNEXPECTED; + + // Convert to BGRA for Windows + for (int i=0; i < BlockSize; i+=4 ) + { + #define RED_BYTE pRGBA[i] + #define BLUE_BYTE pRGBA[i+2] + + char red = RED_BYTE; + RED_BYTE = BLUE_BYTE; + BLUE_BYTE = red; + } + + // Flip vertically (Blender stores it upside-down) + unsigned int LineSize = width*4; + char* FlippedImage = new char[BlockSize]; + for (int i=0; i<height; i++) + { + if ( 0 != memcpy_s(&FlippedImage[ (height - i - 1)*LineSize ],LineSize,&pRGBA[ i*LineSize ],LineSize)) + return E_UNEXPECTED; + } + delete[] pRGBA; + pRGBA = FlippedImage; + + // Create image + *phbmp = CreateBitmap(width,height,1,32,pRGBA); + if (!*phbmp) + return E_FAIL; + *pdwAlpha = WTSAT_ARGB; // it's actually BGRA, not sure why this works + + // Scale down if required + if ( (unsigned)width > cx || (unsigned)height > cx ) + { + float scale = 1.0f / (max(width,height) / (float)cx); + LONG NewWidth = (LONG)(width *scale); + LONG NewHeight = (LONG)(height *scale); + +#ifdef _DEBUG +#if 1 + MessageBox(0,L"Attach now",L"Debugging",MB_OK); +#endif +#endif + IWICImagingFactory *pImgFac; + hr = CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pImgFac)); + + IWICBitmap* WICBmp; + hr = pImgFac->CreateBitmapFromHBITMAP(*phbmp,0,WICBitmapUseAlpha,&WICBmp); + + BITMAPINFO bmi = {}; + bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); + bmi.bmiHeader.biWidth = NewWidth; + bmi.bmiHeader.biHeight = -NewHeight; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = 32; + bmi.bmiHeader.biCompression = BI_RGB; + + BYTE *pBits; + HBITMAP ResizedHBmp = CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, (void**)&pBits, NULL, 0); + hr = ResizedHBmp ? S_OK : E_OUTOFMEMORY; + if (SUCCEEDED(hr)) + { + IWICBitmapScaler* pIScaler; + hr = pImgFac->CreateBitmapScaler(&pIScaler); + hr = pIScaler->Initialize(WICBmp,NewWidth,NewHeight,WICBitmapInterpolationModeFant); + + WICRect rect = {0, 0, NewWidth, NewHeight}; + hr = pIScaler->CopyPixels(&rect, NewWidth * 4, NewWidth * NewHeight * 4, pBits); + + if (SUCCEEDED(hr)) + { + DeleteObject(*phbmp); + *phbmp = ResizedHBmp; + } + else + DeleteObject(ResizedHBmp); + + pIScaler->Release(); + } + WICBmp->Release(); + pImgFac->Release(); + } + else + hr = S_OK; + break; + } + return hr; +} diff --git a/release/windows/blendthumb/src/Dll.cpp b/release/windows/blendthumb/src/Dll.cpp new file mode 100644 index 00000000000..09ccd34ff8e --- /dev/null +++ b/release/windows/blendthumb/src/Dll.cpp @@ -0,0 +1,277 @@ +/* + * ***** 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 ***** + */ + +#include <objbase.h> +#include <shlwapi.h> +#include <thumbcache.h> // For IThumbnailProvider. +#include <shlobj.h> // For SHChangeNotify +#include <new> + +extern HRESULT CBlendThumb_CreateInstance(REFIID riid, void **ppv); + +#define SZ_CLSID_BLENDTHUMBHANDLER L"{D45F043D-F17F-4e8a-8435-70971D9FA46D}" +#define SZ_BLENDTHUMBHANDLER L"Blender Thumbnail Handler" +const CLSID CLSID_BlendThumbHandler = { 0xd45f043d, 0xf17f, 0x4e8a, { 0x84, 0x35, 0x70, 0x97, 0x1d, 0x9f, 0xa4, 0x6d } }; + +typedef HRESULT (*PFNCREATEINSTANCE)(REFIID riid, void **ppvObject); +struct CLASS_OBJECT_INIT +{ + const CLSID *pClsid; + PFNCREATEINSTANCE pfnCreate; +}; + +// add classes supported by this module here +const CLASS_OBJECT_INIT c_rgClassObjectInit[] = +{ + { &CLSID_BlendThumbHandler, CBlendThumb_CreateInstance } +}; + + +long g_cRefModule = 0; + +// Handle the the DLL's module +HINSTANCE g_hInst = NULL; + +// Standard DLL functions +STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, void *) +{ + if (dwReason == DLL_PROCESS_ATTACH) + { + g_hInst = hInstance; + DisableThreadLibraryCalls(hInstance); + } + return TRUE; +} + +STDAPI DllCanUnloadNow() +{ + // Only allow the DLL to be unloaded after all outstanding references have been released + return (g_cRefModule == 0) ? S_OK : S_FALSE; +} + +void DllAddRef() +{ + InterlockedIncrement(&g_cRefModule); +} + +void DllRelease() +{ + InterlockedDecrement(&g_cRefModule); +} + +class CClassFactory : public IClassFactory +{ +public: + static HRESULT CreateInstance(REFCLSID clsid, const CLASS_OBJECT_INIT *pClassObjectInits, size_t cClassObjectInits, REFIID riid, void **ppv) + { + *ppv = NULL; + HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; + for (size_t i = 0; i < cClassObjectInits; i++) + { + if (clsid == *pClassObjectInits[i].pClsid) + { + IClassFactory *pClassFactory = new (std::nothrow) CClassFactory(pClassObjectInits[i].pfnCreate); + hr = pClassFactory ? S_OK : E_OUTOFMEMORY; + if (SUCCEEDED(hr)) + { + hr = pClassFactory->QueryInterface(riid, ppv); + pClassFactory->Release(); + } + break; // match found + } + } + return hr; + } + + CClassFactory(PFNCREATEINSTANCE pfnCreate) : _cRef(1), _pfnCreate(pfnCreate) + { + DllAddRef(); + } + + // IUnknown + IFACEMETHODIMP QueryInterface(REFIID riid, void ** ppv) + { + static const QITAB qit[] = + { + QITABENT(CClassFactory, IClassFactory), + { 0 } + }; + return QISearch(this, qit, riid, ppv); + } + + IFACEMETHODIMP_(ULONG) AddRef() + { + return InterlockedIncrement(&_cRef); + } + + IFACEMETHODIMP_(ULONG) Release() + { + long cRef = InterlockedDecrement(&_cRef); + if (cRef == 0) + { + delete this; + } + return cRef; + } + + // IClassFactory + IFACEMETHODIMP CreateInstance(IUnknown *punkOuter, REFIID riid, void **ppv) + { + return punkOuter ? CLASS_E_NOAGGREGATION : _pfnCreate(riid, ppv); + } + + IFACEMETHODIMP LockServer(BOOL fLock) + { + if (fLock) + { + DllAddRef(); + } + else + { + DllRelease(); + } + return S_OK; + } + +private: + ~CClassFactory() + { + DllRelease(); + } + + long _cRef; + PFNCREATEINSTANCE _pfnCreate; +}; + +STDAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **ppv) +{ + return CClassFactory::CreateInstance(clsid, c_rgClassObjectInit, ARRAYSIZE(c_rgClassObjectInit), riid, ppv); +} + +// A struct to hold the information required for a registry entry + +struct REGISTRY_ENTRY +{ + HKEY hkeyRoot; + PCWSTR pszKeyName; + PCWSTR pszValueName; + DWORD dwValueType; + PCWSTR pszData; +}; + +// Creates a registry key (if needed) and sets the default value of the key + +HRESULT CreateRegKeyAndSetValue(const REGISTRY_ENTRY *pRegistryEntry) +{ + HKEY hKey; + HRESULT hr = HRESULT_FROM_WIN32(RegCreateKeyExW(pRegistryEntry->hkeyRoot, pRegistryEntry->pszKeyName, + 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL)); + if (SUCCEEDED(hr)) + { + // All this just to support REG_DWORD... + DWORD size; + DWORD data; + BYTE* lpData = (LPBYTE) pRegistryEntry->pszData; + switch (pRegistryEntry->dwValueType) + { + case REG_SZ: + size = ((DWORD) wcslen(pRegistryEntry->pszData) + 1) * sizeof(WCHAR); + break; + case REG_DWORD: + size = sizeof(DWORD); + data = (DWORD)pRegistryEntry->pszData; + lpData = (BYTE*)&data; + break; + default: + return E_INVALIDARG; + } + + hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, pRegistryEntry->pszValueName, 0, pRegistryEntry->dwValueType, + lpData, size )); + RegCloseKey(hKey); + } + return hr; +} + +// +// Registers this COM server +// +STDAPI DllRegisterServer() +{ + HRESULT hr; + + WCHAR szModuleName[MAX_PATH]; + + if (!GetModuleFileNameW(g_hInst, szModuleName, ARRAYSIZE(szModuleName))) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + } + else + { + const REGISTRY_ENTRY rgRegistryEntries[] = + { + // RootKey KeyName ValueName ValueType Data + {HKEY_CURRENT_USER, L"Software\\Classes\\CLSID\\" SZ_CLSID_BLENDTHUMBHANDLER, NULL, REG_SZ, SZ_BLENDTHUMBHANDLER}, + {HKEY_CURRENT_USER, L"Software\\Classes\\CLSID\\" SZ_CLSID_BLENDTHUMBHANDLER L"\\InProcServer32", NULL, REG_SZ, szModuleName}, + {HKEY_CURRENT_USER, L"Software\\Classes\\CLSID\\" SZ_CLSID_BLENDTHUMBHANDLER L"\\InProcServer32", L"ThreadingModel", REG_SZ, L"Apartment"}, + {HKEY_CURRENT_USER, L"Software\\Classes\\.blend\\", L"Treatment", REG_DWORD, 0}, // doesn't appear to do anything... + {HKEY_CURRENT_USER, L"Software\\Classes\\.blend\\ShellEx\\{e357fccd-a995-4576-b01f-234630154e96}", NULL, REG_SZ, SZ_CLSID_BLENDTHUMBHANDLER}, + }; + + hr = S_OK; + for (int i = 0; i < ARRAYSIZE(rgRegistryEntries) && SUCCEEDED(hr); i++) + { + hr = CreateRegKeyAndSetValue(&rgRegistryEntries[i]); + } + } + if (SUCCEEDED(hr)) + { + // This tells the shell to invalidate the thumbnail cache. This is important because any .blend files + // viewed before registering this handler would otherwise show cached blank thumbnails. + SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); + } + return hr; +} + +// +// Unregisters this COM server +// +STDAPI DllUnregisterServer() +{ + HRESULT hr = S_OK; + + const PCWSTR rgpszKeys[] = + { + L"Software\\Classes\\CLSID\\" SZ_CLSID_BLENDTHUMBHANDLER, + L"Software\\Classes\\.blend\\ShellEx\\{e357fccd-a995-4576-b01f-234630154e96}" + }; + + // Delete the registry entries + for (int i = 0; i < ARRAYSIZE(rgpszKeys) && SUCCEEDED(hr); i++) + { + hr = HRESULT_FROM_WIN32(RegDeleteTreeW(HKEY_CURRENT_USER, rgpszKeys[i])); + if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) + { + // If the registry entry has already been deleted, say S_OK. + hr = S_OK; + } + } + return hr; +} diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index 9a4ca6f99a8..456d16b3e0d 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -681,17 +681,17 @@ static void assign_materials(Main *bmain, Object *ob, const std::map<std::string std::string mat_name = it->first; mat_iter = mat_map.find(mat_name.c_str()); - Material *assigned_name; + Material *assigned_mat; if (mat_iter == mat_map.end()) { - assigned_name = BKE_material_add(bmain, mat_name.c_str()); - mat_map[mat_name] = assigned_name; + assigned_mat = BKE_material_add(bmain, mat_name.c_str()); + mat_map[mat_name] = assigned_mat; } else { - assigned_name = mat_iter->second; + assigned_mat = mat_iter->second; } - assign_material(ob, assigned_name, it->second, BKE_MAT_ASSIGN_OBDATA); + assign_material(ob, assigned_mat, it->second, BKE_MAT_ASSIGN_OBDATA); } } } @@ -983,8 +983,6 @@ static void read_mesh_sample(ImportSettings *settings, if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) { read_custom_data(schema.getArbGeomParams(), config, selector); } - - /* TODO: face sets */ } CDStreamConfig get_config(DerivedMesh *dm) @@ -1123,6 +1121,16 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm, CDDM_calc_normals(new_dm); CDDM_calc_edges(new_dm); + /* Here we assume that the number of materials doesn't change, i.e. that + * the material slots that were created when the object was loaded from + * Alembic are still valid now. */ + size_t num_polys = new_dm->getNumPolys(new_dm); + if (num_polys > 0) { + MPoly *dmpolies = new_dm->getPolyArray(new_dm); + std::map<std::string, int> mat_map; + assign_facesets_to_mpoly(sample_sel, 0, dmpolies, num_polys, mat_map); + } + return new_dm; } @@ -1133,8 +1141,11 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm, return dm; } -void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start, - const ISampleSelector &sample_sel) +void AbcMeshReader::assign_facesets_to_mpoly( + const ISampleSelector &sample_sel, + size_t poly_start, + MPoly *mpoly, int totpoly, + std::map<std::string, int> & r_mat_map) { std::vector<std::string> face_sets; m_schema.getFaceSetNames(face_sets); @@ -1143,21 +1154,21 @@ void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_star return; } - std::map<std::string, int> mat_map; int current_mat = 0; for (int i = 0; i < face_sets.size(); ++i) { const std::string &grp_name = face_sets[i]; - if (mat_map.find(grp_name) == mat_map.end()) { - mat_map[grp_name] = 1 + current_mat++; + if (r_mat_map.find(grp_name) == r_mat_map.end()) { + r_mat_map[grp_name] = 1 + current_mat++; } - const int assigned_mat = mat_map[grp_name]; + const int assigned_mat = r_mat_map[grp_name]; const IFaceSet faceset = m_schema.getFaceSet(grp_name); if (!faceset.valid()) { + std::cerr << " Face set " << grp_name << " invalid for " << m_object_name << "\n"; continue; } @@ -1169,16 +1180,25 @@ void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_star for (size_t l = 0; l < num_group_faces; l++) { size_t pos = (*group_faces)[l] + poly_start; - if (pos >= mesh->totpoly) { + if (pos >= totpoly) { std::cerr << "Faceset overflow on " << faceset.getName() << '\n'; break; } - MPoly &poly = mesh->mpoly[pos]; + MPoly &poly = mpoly[pos]; poly.mat_nr = assigned_mat - 1; } } +} + +void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start, + const ISampleSelector &sample_sel) +{ + std::map<std::string, int> mat_map; + assign_facesets_to_mpoly(sample_sel, + poly_start, mesh->mpoly, mesh->totpoly, + mat_map); utils::assign_materials(bmain, m_object, mat_map); } @@ -1234,8 +1254,6 @@ static void read_subd_sample(ImportSettings *settings, if ((settings->read_flag & (MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)) != 0) { read_custom_data(schema.getArbGeomParams(), config, selector); } - - /* TODO: face sets */ } /* ************************************************************************** */ diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h index 6bf1dde3d1d..5c1eb01d8e0 100644 --- a/source/blender/alembic/intern/abc_mesh.h +++ b/source/blender/alembic/intern/abc_mesh.h @@ -112,6 +112,11 @@ public: private: void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start, const Alembic::AbcGeom::ISampleSelector &sample_sel); + + void assign_facesets_to_mpoly(const Alembic::Abc::ISampleSelector &sample_sel, + size_t poly_start, + MPoly *mpoly, int totpoly, + std::map<std::string, int> & r_mat_map); }; /* ************************************************************************** */ diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 87d63b7d6f6..657e99f05d1 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -335,7 +335,8 @@ bool BKE_sequence_base_shuffle( bool BKE_sequence_base_shuffle_time(ListBase *seqbasep, struct Scene *evil_scene); bool BKE_sequence_base_isolated_sel_check(struct ListBase *seqbase); void BKE_sequencer_free_imbuf(struct Scene *scene, struct ListBase *seqbasep, bool for_render); -struct Sequence *BKE_sequence_dupli_recursive(struct Scene *scene, struct Scene *scene_to, struct Sequence *seq, int dupe_flag); +struct Sequence *BKE_sequence_dupli_recursive( + const struct Scene *scene_src, struct Scene *scene_dst, struct Sequence *seq, int dupe_flag); int BKE_sequence_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str); bool BKE_sequence_check_depend(struct Sequence *seq, struct Sequence *cur); @@ -352,7 +353,7 @@ void BKE_sequencer_refresh_sound_length(struct Scene *scene); void BKE_sequence_base_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq); void BKE_sequence_base_dupli_recursive( - const struct Scene *scene, struct Scene *scene_to, struct ListBase *nseqbase, const struct ListBase *seqbase, + const struct Scene *scene_src, struct Scene *scene_dst, struct ListBase *nseqbase, const struct ListBase *seqbase, int dupe_flag, const int flag); bool BKE_sequence_is_valid_check(struct Sequence *seq); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 18e4f332dc2..a1bd410d390 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1099,23 +1099,21 @@ void *BKE_libblock_alloc_notest(short type) */ void *BKE_libblock_alloc(Main *bmain, short type, const char *name, const int flag) { - ID *id = NULL; - BLI_assert((flag & LIB_ID_CREATE_NO_ALLOCATE) == 0); - - id = BKE_libblock_alloc_notest(type); - if ((flag & LIB_ID_CREATE_NO_MAIN) != 0) { - id->tag |= LIB_TAG_NO_MAIN; - } - if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0) { - id->tag |= LIB_TAG_NO_USER_REFCOUNT; - } + ID *id = BKE_libblock_alloc_notest(type); if (id) { + if ((flag & LIB_ID_CREATE_NO_MAIN) != 0) { + id->tag |= LIB_TAG_NO_MAIN; + } + if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0) { + id->tag |= LIB_TAG_NO_USER_REFCOUNT; + } + id->icon_id = 0; - *( (short *)id->name) = type; - if ((flag & LIB_ID_FREE_NO_USER_REFCOUNT) == 0) { + *((short *)id->name) = type; + if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { id->us = 1; } if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) { @@ -1132,6 +1130,9 @@ void *BKE_libblock_alloc(Main *bmain, short type, const char *name, const int fl DAG_id_type_tag(bmain, type); } } + else { + BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2); + } } return id; diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index ed9063e7640..1794d745767 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -241,7 +241,7 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id return IDWALK_RET_NOP; } -/* Some reamapping unfortunately require extra and/or specific handling, tackle those here. */ +/* Some remapping unfortunately require extra and/or specific handling, tackle those here. */ static void libblock_remap_data_preprocess_scene_base_unlink( IDRemap *r_id_remap_data, Scene *sce, Base *base, const bool skip_indirect, const bool is_indirect) { @@ -318,7 +318,7 @@ static void libblock_remap_data_preprocess(IDRemap *r_id_remap_data) } } -static void libblock_remap_data_postprocess_object_fromgroup_update(Main *bmain, Object *old_ob, Object *new_ob) +static void libblock_remap_data_postprocess_object_update(Main *bmain, Object *old_ob, Object *new_ob) { if (old_ob->flag & OB_FROMGROUP) { /* Note that for Scene's BaseObject->flag, either we: @@ -337,6 +337,13 @@ static void libblock_remap_data_postprocess_object_fromgroup_update(Main *bmain, new_ob->flag |= OB_FROMGROUP; } } + if (old_ob->type == OB_MBALL) { + for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { + if (ob->type == OB_MBALL && BKE_mball_is_basis_for(ob, old_ob)) { + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + } + } } static void libblock_remap_data_postprocess_group_scene_unlink(Main *UNUSED(bmain), Scene *sce, ID *old_id) @@ -547,7 +554,7 @@ void BKE_libblock_remap_locked( */ switch (GS(old_id->name)) { case ID_OB: - libblock_remap_data_postprocess_object_fromgroup_update(bmain, (Object *)old_id, (Object *)new_id); + libblock_remap_data_postprocess_object_update(bmain, (Object *)old_id, (Object *)new_id); break; case ID_GR: if (!new_id) { /* Only affects us in case group was unlinked. */ @@ -657,8 +664,7 @@ void BKE_libblock_relink_ex( switch (GS(old_id->name)) { case ID_OB: { - libblock_remap_data_postprocess_object_fromgroup_update( - bmain, (Object *)old_id, (Object *)new_id); + libblock_remap_data_postprocess_object_update(bmain, (Object *)old_id, (Object *)new_id); break; } case ID_GR: @@ -673,7 +679,7 @@ void BKE_libblock_relink_ex( else { /* No choice but to check whole objects/groups. */ for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { - libblock_remap_data_postprocess_object_fromgroup_update(bmain, ob, NULL); + libblock_remap_data_postprocess_object_update(bmain, ob, NULL); } for (Group *grp = bmain->group.first; grp; grp = grp->id.next) { libblock_remap_data_postprocess_group_scene_unlink(bmain, sce, NULL); diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 5a925af456c..8bfc1e81c73 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1660,13 +1660,13 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime) # pragma GCC diagnostic ignored "-Wunused-parameter" #endif -struct RigidBodyOb *BKE_rigidbody_copy_object(const Object *ob) { return NULL; } -struct RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob) { return NULL; } +struct RigidBodyOb *BKE_rigidbody_copy_object(const Object *ob, const int flag) { return NULL; } +struct RigidBodyCon *BKE_rigidbody_copy_constraint(const Object *ob, const int flag) { return NULL; } void BKE_rigidbody_validate_sim_world(Scene *scene, RigidBodyWorld *rbw, bool rebuild) {} void BKE_rigidbody_calc_volume(Object *ob, float *r_vol) { if (r_vol) *r_vol = 0.0f; } void BKE_rigidbody_calc_center_of_mass(Object *ob, float r_center[3]) { zero_v3(r_center); } struct RigidBodyWorld *BKE_rigidbody_create_world(Scene *scene) { return NULL; } -struct RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw) { return NULL; } +struct RigidBodyWorld *BKE_rigidbody_world_copy(RigidBodyWorld *rbw, const int flag) { return NULL; } void BKE_rigidbody_world_groups_relink(struct RigidBodyWorld *rbw) {} void BKE_rigidbody_world_id_loop(struct RigidBodyWorld *rbw, RigidbodyWorldIDFunc func, void *userdata) {} struct RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type) { return NULL; } diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 857bd5447c8..df47b89fadc 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -181,6 +181,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar) BLI_listbase_clear(&newar->ui_lists); newar->swinid = 0; newar->regiontimer = NULL; + newar->headerstr = NULL; /* use optional regiondata callback */ if (ar->regiondata) { diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index a7991139b3f..b09b3ecda07 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -5371,9 +5371,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad return seq; } -static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dupe_flag, const int flag) +static Sequence *seq_dupli(const Scene *scene_src, Scene *scene_dst, Sequence *seq, int dupe_flag, const int flag) { - Scene *sce_audio = scene_to ? scene_to : scene; Sequence *seqn = MEM_dupallocN(seq); seq->tmp = seqn; @@ -5416,7 +5415,7 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup else if (seq->type == SEQ_TYPE_SCENE) { seqn->strip->stripdata = NULL; if (seq->scene_sound) - seqn->scene_sound = BKE_sound_scene_add_scene_sound_defaults(sce_audio, seqn); + seqn->scene_sound = BKE_sound_scene_add_scene_sound_defaults(scene_dst, seqn); } else if (seq->type == SEQ_TYPE_MOVIECLIP) { /* avoid assert */ @@ -5433,7 +5432,7 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); if (seq->scene_sound) - seqn->scene_sound = BKE_sound_add_scene_sound_defaults(sce_audio, seqn); + seqn->scene_sound = BKE_sound_add_scene_sound_defaults(scene_dst, seqn); if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { id_us_plus((ID *)seqn->sound); @@ -5457,11 +5456,15 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup BLI_assert(0); } - if (dupe_flag & SEQ_DUPE_UNIQUE_NAME) - BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seqn); + if (scene_src == scene_dst) { + if (dupe_flag & SEQ_DUPE_UNIQUE_NAME) { + BKE_sequence_base_unique_name_recursive(&scene_dst->ed->seqbase, seqn); + } - if (dupe_flag & SEQ_DUPE_ANIM) - BKE_sequencer_dupe_animdata(scene, seq->name + 2, seqn->name + 2); + if (dupe_flag & SEQ_DUPE_ANIM) { + BKE_sequencer_dupe_animdata(scene_dst, seq->name + 2, seqn->name + 2); + } + } return seqn; } @@ -5488,16 +5491,16 @@ static void seq_new_fix_links_recursive(Sequence *seq) } } -Sequence *BKE_sequence_dupli_recursive(Scene *scene, Scene *scene_to, Sequence *seq, int dupe_flag) +Sequence *BKE_sequence_dupli_recursive(const Scene *scene_src, Scene *scene_dst, Sequence *seq, int dupe_flag) { Sequence *seqn; seq->tmp = NULL; - seqn = seq_dupli(scene, scene_to, seq, dupe_flag, 0); + seqn = seq_dupli(scene_src, scene_dst, seq, dupe_flag, 0); if (seq->type == SEQ_TYPE_META) { Sequence *s; for (s = seq->seqbase.first; s; s = s->next) { - Sequence *n = BKE_sequence_dupli_recursive(scene, scene_to, s, dupe_flag); + Sequence *n = BKE_sequence_dupli_recursive(scene_src, scene_dst, s, dupe_flag); if (n) { BLI_addtail(&seqn->seqbase, n); } @@ -5510,19 +5513,19 @@ Sequence *BKE_sequence_dupli_recursive(Scene *scene, Scene *scene_to, Sequence * } void BKE_sequence_base_dupli_recursive( - const Scene *scene, Scene *scene_to, ListBase *nseqbase, const ListBase *seqbase, + const Scene *scene_src, Scene *scene_dst, ListBase *nseqbase, const ListBase *seqbase, int dupe_flag, const int flag) { Sequence *seq; Sequence *seqn = NULL; - Sequence *last_seq = BKE_sequencer_active_get((Scene *)scene); + Sequence *last_seq = BKE_sequencer_active_get((Scene *)scene_src); /* always include meta's strips */ int dupe_flag_recursive = dupe_flag | SEQ_DUPE_ALL; for (seq = seqbase->first; seq; seq = seq->next) { seq->tmp = NULL; if ((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) { - seqn = seq_dupli((Scene *)scene, scene_to, seq, dupe_flag, flag); + seqn = seq_dupli(scene_src, scene_dst, seq, dupe_flag, flag); if (seqn) { /*should never fail */ if (dupe_flag & SEQ_DUPE_CONTEXT) { seq->flag &= ~SEQ_ALLSEL; @@ -5532,13 +5535,13 @@ void BKE_sequence_base_dupli_recursive( BLI_addtail(nseqbase, seqn); if (seq->type == SEQ_TYPE_META) { BKE_sequence_base_dupli_recursive( - scene, scene_to, &seqn->seqbase, &seq->seqbase, + scene_src, scene_dst, &seqn->seqbase, &seq->seqbase, dupe_flag_recursive, flag); } if (dupe_flag & SEQ_DUPE_CONTEXT) { if (seq == last_seq) { - BKE_sequencer_active_set(scene_to, seqn); + BKE_sequencer_active_set(scene_dst, seqn); } } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index a1abcb96411..bb8e2a710ef 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -927,16 +927,20 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) const char *rna_path = fcu->rna_path ? fcu->rna_path : ""; - /* create dependency between driver and data affected by it */ + /* Create dependency between driver and data affected by it. */ /* - direct property relationship... */ //RNAPathKey affected_key(id, fcu->rna_path); //add_relation(driver_key, affected_key, "[Driver -> Data] DepsRel"); - /* driver -> data components (for interleaved evaluation - bones/constraints/modifiers) */ - // XXX: this probably should probably be moved out into a separate function + /* Driver -> data components (for interleaved evaluation + * bones/constraints/modifiers). + */ + // XXX: this probably should probably be moved out into a separate function. if (strstr(rna_path, "pose.bones[") != NULL) { /* interleaved drivers during bone eval */ - // TODO: ideally, if this is for a constraint, it goes to said constraint + /* TODO: ideally, if this is for a constraint, it goes to said + * constraint. + */ Object *ob = (Object *)id; char *bone_name; @@ -949,7 +953,10 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) } if (pchan) { - OperationKey bone_key(id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL); + OperationKey bone_key(id, + DEG_NODE_TYPE_BONE, + pchan->name, + DEG_OPCODE_BONE_LOCAL); add_relation(driver_key, bone_key, "[Driver -> Bone]"); } else { @@ -959,30 +966,36 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) } } else if (GS(id->name) == ID_AR && strstr(rna_path, "bones[")) { - /* drivers on armature-level bone settings (i.e. bbone stuff), - * which will affect the evaluation of corresponding pose bones + /* Drivers on armature-level bone settings (i.e. bbone stuff), + * which will affect the evaluation of corresponding pose bones. */ IDDepsNode *arm_node = m_graph->find_id_node(id); char *bone_name = BLI_str_quoted_substrN(rna_path, "bones["); if (arm_node && bone_name) { - /* find objects which use this, and make their eval callbacks depend on this */ + /* Find objects which use this, and make their eval callbacks + * depend on this. + */ foreach (DepsRelation *rel, arm_node->outlinks) { IDDepsNode *to_node = (IDDepsNode *)rel->to; - - /* we only care about objects with pose data which use this... */ + /* We only care about objects with pose data which use this. */ if (GS(to_node->id->name) == ID_OB) { Object *ob = (Object *)to_node->id; - bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name); // NOTE: ob->pose may be NULL - - if (pchan) { - OperationKey bone_key(&ob->id, DEG_NODE_TYPE_BONE, pchan->name, DEG_OPCODE_BONE_LOCAL); - add_relation(driver_key, bone_key, "[Arm Bone -> Driver -> Bone]"); + /* NOTE: ob->pose may be NULL. */ + bPoseChannel *pchan = BKE_pose_channel_find_name( + ob->pose, bone_name); + if (pchan != NULL) { + OperationKey bone_key(&ob->id, + DEG_NODE_TYPE_BONE, + pchan->name, + DEG_OPCODE_BONE_LOCAL); + add_relation(driver_key, + bone_key, + "[Arm Bone -> Driver -> Bone]"); } } } - - /* free temp data */ + /* Free temp data. */ MEM_freeN(bone_name); bone_name = NULL; } @@ -993,7 +1006,9 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) } } else if (GS(id->name) == ID_OB && strstr(rna_path, "modifiers[")) { - OperationKey modifier_key(id, DEG_NODE_TYPE_GEOMETRY, DEG_OPCODE_GEOMETRY_UBEREVAL); + OperationKey modifier_key(id, + DEG_NODE_TYPE_GEOMETRY, + DEG_OPCODE_GEOMETRY_UBEREVAL); if (has_node(modifier_key)) { add_relation(driver_key, modifier_key, "[Driver -> Modifier]"); } @@ -1002,7 +1017,7 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) } } else if (GS(id->name) == ID_KE && strstr(rna_path, "key_blocks[")) { - /* shape key driver - hook into the base geometry operation */ + /* Shape key driver - hook into the base geometry operation. */ // XXX: double check where this points Key *shape_key = (Key *)id; @@ -1016,33 +1031,44 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) else { if (GS(id->name) == ID_OB) { /* assume that driver affects a transform... */ - OperationKey local_transform_key(id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_LOCAL); - add_relation(driver_key, local_transform_key, "[Driver -> Transform]"); + OperationKey local_transform_key(id, + DEG_NODE_TYPE_TRANSFORM, + DEG_OPCODE_TRANSFORM_LOCAL); + add_relation(driver_key, + local_transform_key, + "[Driver -> Transform]"); } else if (GS(id->name) == ID_KE) { ComponentKey geometry_key(id, DEG_NODE_TYPE_GEOMETRY); - add_relation(driver_key, geometry_key, "[Driver -> Shapekey Geometry]"); + add_relation(driver_key, + geometry_key, + "[Driver -> Shapekey Geometry]"); } } - - /* ensure that affected prop's update callbacks will be triggered once done */ - // TODO: implement this once the functionality to add these links exists in RNA - // XXX: the data itself could also set this, if it were to be truly initialised later? - - /* loop over variables to get the target relationships */ + /* Ensure that affected prop's update callbacks will be triggered once + * done. + */ + /* TODO: Implement this once the functionality to add these links exists + * RNA. + */ + /* XXX: the data itself could also set this, if it were to be truly + * initialised later? + */ + /* Loop over variables to get the target relationships. */ LINKLIST_FOREACH (DriverVar *, dvar, &driver->variables) { - /* only used targets */ + /* Only used targets. */ DRIVER_TARGETS_USED_LOOPER(dvar) { - if (dtar->id == NULL) + if (dtar->id == NULL) { continue; - - /* special handling for directly-named bones */ + } + /* Special handling for directly-named bones. */ if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) { Object *ob = (Object *)dtar->id; - bPoseChannel *target_pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); + bPoseChannel *target_pchan = + BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); if (target_pchan != NULL) { - /* get node associated with bone */ + /* Get node associated with bone. */ // XXX: watch the space! /* Some cases can't use final bone transform, for example: * - Driving the bone with itself (addressed here) @@ -1054,55 +1080,75 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu) { continue; } - OperationKey target_key(dtar->id, DEG_NODE_TYPE_BONE, target_pchan->name, DEG_OPCODE_BONE_DONE); - add_relation(target_key, driver_key, "[Bone Target -> Driver]"); + OperationKey target_key(dtar->id, + DEG_NODE_TYPE_BONE, + target_pchan->name, + DEG_OPCODE_BONE_DONE); + add_relation(target_key, + driver_key, + "[Bone Target -> Driver]"); } } else if (dtar->flag & DTAR_FLAG_STRUCT_REF) { - /* get node associated with the object's transforms */ - OperationKey target_key(dtar->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_FINAL); + /* Get node associated with the object's transforms. */ + if (dtar->id == id) { + /* Ignore input dependency if we're driving properties of + * the same ID, otherwise we'll be ending up in a cyclic + * dependency here. + */ + continue; + } + OperationKey target_key(dtar->id, + DEG_NODE_TYPE_TRANSFORM, + DEG_OPCODE_TRANSFORM_FINAL); add_relation(target_key, driver_key, "[Target -> Driver]"); } else if (dtar->rna_path && strstr(dtar->rna_path, "pose.bones[")) { - /* workaround for ensuring that local bone transforms don't end up - * having to wait for pose eval to finish (to prevent cycles) + /* Workaround for ensuring that local bone transforms don't end + * up having to wait for pose eval to finish (to prevent cycles). */ Object *ob = (Object *)dtar->id; - char *bone_name = BLI_str_quoted_substrN(dtar->rna_path, "pose.bones["); - bPoseChannel *target_pchan = BKE_pose_channel_find_name(ob->pose, bone_name); - if (bone_name) { + char *bone_name = BLI_str_quoted_substrN(dtar->rna_path, + "pose.bones["); + bPoseChannel *target_pchan = + BKE_pose_channel_find_name(ob->pose, bone_name); + if (bone_name != NULL) { MEM_freeN(bone_name); bone_name = NULL; } - if (target_pchan) { + if (target_pchan != NULL) { if (dtar->id == id && pchan != NULL && STREQ(pchan->name, target_pchan->name)) { continue; } - OperationKey bone_key(dtar->id, DEG_NODE_TYPE_BONE, target_pchan->name, DEG_OPCODE_BONE_LOCAL); + OperationKey bone_key(dtar->id, + DEG_NODE_TYPE_BONE, + target_pchan->name, + DEG_OPCODE_BONE_LOCAL); add_relation(bone_key, driver_key, "[RNA Bone -> Driver]"); } } else { if (dtar->id == id) { - /* Ignore input dependency if we're driving properties of the same ID, - * otherwise we'll be ending up in a cyclic dependency here. + /* Ignore input dependency if we're driving properties of + * the same ID, otherwise we'll be ending up in a cyclic + * dependency here. */ continue; } - /* resolve path to get node */ - RNAPathKey target_key(dtar->id, dtar->rna_path ? dtar->rna_path : ""); + /* Resolve path to get node. */ + RNAPathKey target_key(dtar->id, + dtar->rna_path ? dtar->rna_path : ""); add_relation(target_key, driver_key, "[RNA Target -> Driver]"); } } DRIVER_TARGETS_LOOPER_END } - - /* It's quite tricky to detect if the driver actually depends on time or not, - * so for now we'll be quite conservative here about optimization and consider - * all python drivers to be depending on time. + /* It's quite tricky to detect if the driver actually depends on time or + * not, so for now we'll be quite conservative here about optimization and + * consider all python drivers to be depending on time. */ if ((driver->type == DRIVER_TYPE_PYTHON) && python_driver_depends_on_time(driver)) diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index f8a5f30a596..a0efd586af5 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -303,7 +303,6 @@ enum { TH_EDGE_BEVEL, TH_VERTEX_BEVEL }; -/* XXX WARNING: previous is saved in file, so do not change order! */ /* specific defines per space should have higher define values */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index c57faf97188..804ffec7997 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2465,7 +2465,6 @@ static void ui_litem_estimate_box(uiLayout *litem) uiStyle *style = litem->root->style; ui_litem_estimate_column(litem, true); - litem->item.flag &= ~UI_ITEM_MIN; litem->w += 2 * style->boxspace; litem->h += 2 * style->boxspace; } @@ -3137,8 +3136,11 @@ static void ui_item_estimate(uiItem *item) for (subitem = litem->items.first; subitem; subitem = subitem->next) ui_item_estimate(subitem); - if (BLI_listbase_is_empty(&litem->items)) + if (BLI_listbase_is_empty(&litem->items)) { + litem->w = 0; + litem->h = 0; return; + } if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f) ui_item_scale(litem, litem->scale); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 4ed1e85fb48..e4f6d0da38f 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1344,89 +1344,87 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, const bool use_hierarchy) { Main *bmain = CTX_data_main(C); - ListBase *lb; + ListBase *lb_duplis; DupliObject *dob; - GHash *dupli_gh = NULL, *parent_gh = NULL; - Object *object; + GHash *dupli_gh, *parent_gh = NULL; - if (!(base->object->transflag & OB_DUPLI)) + if (!(base->object->transflag & OB_DUPLI)) { return; + } - lb = object_duplilist(bmain->eval_ctx, scene, base->object); + lb_duplis = object_duplilist(bmain->eval_ctx, scene, base->object); - if (use_hierarchy || use_base_parent) { - dupli_gh = BLI_ghash_ptr_new(__func__); - if (use_hierarchy) { - if (base->object->transflag & OB_DUPLIGROUP) { - parent_gh = BLI_ghash_new(dupliobject_group_hash, dupliobject_group_cmp, __func__); - } - else { - parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__); - } + dupli_gh = BLI_ghash_ptr_new(__func__); + if (use_hierarchy) { + if (base->object->transflag & OB_DUPLIGROUP) { + parent_gh = BLI_ghash_new(dupliobject_group_hash, dupliobject_group_cmp, __func__); + } + else { + parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__); } } - for (dob = lb->first; dob; dob = dob->next) { - Base *basen; - Object *ob = ID_NEW_SET(dob->ob, BKE_object_copy(bmain, dob->ob)); + for (dob = lb_duplis->first; dob; dob = dob->next) { + Object *ob_src = dob->ob; + Object *ob_dst = ID_NEW_SET(dob->ob, BKE_object_copy(bmain, ob_src)); + Base *base_dst; /* font duplis can have a totcol without material, we get them from parent * should be implemented better... */ - if (ob->mat == NULL) ob->totcol = 0; + if (ob_dst->mat == NULL) { + ob_dst->totcol = 0; + } - basen = MEM_dupallocN(base); - basen->flag &= ~(OB_FROMDUPLI | OB_FROMGROUP); - ob->flag = basen->flag; - basen->lay = base->lay; - BLI_addhead(&scene->base, basen); /* addhead: othwise eternal loop */ - basen->object = ob; + base_dst = MEM_dupallocN(base); + base_dst->flag &= ~(OB_FROMDUPLI | OB_FROMGROUP); + ob_dst->flag = base_dst->flag; + base_dst->lay = base->lay; + BLI_addhead(&scene->base, base_dst); /* addhead: othwise eternal loop */ + base_dst->object = ob_dst; /* make sure apply works */ - BKE_animdata_free(&ob->id, true); - ob->adt = NULL; + BKE_animdata_free(&ob_dst->id, true); + ob_dst->adt = NULL; /* Proxies are not to be copied. */ - ob->proxy_from = NULL; - ob->proxy_group = NULL; - ob->proxy = NULL; + ob_dst->proxy_from = NULL; + ob_dst->proxy_group = NULL; + ob_dst->proxy = NULL; - ob->parent = NULL; - BKE_constraints_free(&ob->constraints); - ob->curve_cache = NULL; - ob->transflag &= ~OB_DUPLI; - ob->lay = base->lay; + ob_dst->parent = NULL; + BKE_constraints_free(&ob_dst->constraints); + ob_dst->curve_cache = NULL; + ob_dst->transflag &= ~OB_DUPLI; + ob_dst->lay = base->lay; - copy_m4_m4(ob->obmat, dob->mat); - BKE_object_apply_mat4(ob, ob->obmat, false, false); + copy_m4_m4(ob_dst->obmat, dob->mat); + BKE_object_apply_mat4(ob_dst, ob_dst->obmat, false, false); - if (dupli_gh) { - BLI_ghash_insert(dupli_gh, dob, ob); - } + BLI_ghash_insert(dupli_gh, dob, ob_dst); if (parent_gh) { void **val; /* Due to nature of hash/comparison of this ghash, a lot of duplis may be considered as 'the same', * this avoids trying to insert same key several time and raise asserts in debug builds... */ if (!BLI_ghash_ensure_p(parent_gh, dob, &val)) { - *val = ob; + *val = ob_dst; } } + } + + for (dob = lb_duplis->first; dob; dob = dob->next) { + Object *ob_src = dob->ob; + Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob); /* Remap new object to itself, and clear again newid pointer of orig object. */ - BKE_libblock_relink_to_newid(&ob->id); - set_sca_new_poins_ob(ob); - BKE_id_clear_newpoin(&dob->ob->id); + BKE_libblock_relink_to_newid(&ob_dst->id); + set_sca_new_poins_ob(ob_dst); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - } + DAG_id_tag_update(&ob_dst->id, OB_RECALC_DATA); - if (use_hierarchy) { - for (dob = lb->first; dob; dob = dob->next) { + if (use_hierarchy) { /* original parents */ - Object *ob_src = dob->ob; Object *ob_src_par = ob_src->parent; - - Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob); Object *ob_dst_par = NULL; /* find parent that was also made real */ @@ -1437,8 +1435,8 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, dob_key.ob = ob_src_par; if (base->object->transflag & OB_DUPLIGROUP) { memcpy(&dob_key.persistent_id[1], - &dob->persistent_id[1], - sizeof(dob->persistent_id[1]) * (MAX_DUPLI_RECUR - 1)); + &dob->persistent_id[1], + sizeof(dob->persistent_id[1]) * (MAX_DUPLI_RECUR - 1)); } else { dob_key.persistent_id[0] = dob->persistent_id[0]; @@ -1462,49 +1460,42 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, ob_dst->parent = base->object; ob_dst->partype = PAROBJECT; } - - if (ob_dst->parent) { - /* note, this may be the parent of other objects, but it should - * still work out ok */ - BKE_object_apply_mat4(ob_dst, dob->mat, false, true); - - /* to set ob_dst->orig and in case theres any other discrepicies */ - DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); - } } - } - else if (use_base_parent) { - /* since we are ignoring the internal hierarchy - parent all to the - * base object */ - for (dob = lb->first; dob; dob = dob->next) { - /* original parents */ - Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob); - + else if (use_base_parent) { + /* since we are ignoring the internal hierarchy - parent all to the + * base object */ ob_dst->parent = base->object; ob_dst->partype = PAROBJECT; + } - /* similer to the code above, see comments */ + if (ob_dst->parent) { + /* note, this may be the parent of other objects, but it should + * still work out ok */ BKE_object_apply_mat4(ob_dst, dob->mat, false, true); + + /* to set ob_dst->orig and in case theres any other discrepicies */ DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); } } if (base->object->transflag & OB_DUPLIGROUP && base->object->dup_group) { - for (object = bmain->object.first; object; object = object->id.next) { - if (object->proxy_group == base->object) { - object->proxy = NULL; - object->proxy_from = NULL; - DAG_id_tag_update(&object->id, OB_RECALC_OB); + for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { + if (ob->proxy_group == base->object) { + ob->proxy = NULL; + ob->proxy_from = NULL; + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } } - if (dupli_gh) - BLI_ghash_free(dupli_gh, NULL, NULL); - if (parent_gh) + BLI_ghash_free(dupli_gh, NULL, NULL); + if (parent_gh) { BLI_ghash_free(parent_gh, NULL, NULL); + } + + free_object_duplilist(lb_duplis); - free_object_duplilist(lb); + BKE_main_id_clear_newpoins(bmain); base->object->transflag &= ~OB_DUPLI; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 5b6fe96861d..d5b516257a1 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2137,7 +2137,9 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo IDP_RelinkProperty(scene->gpd->id.properties); } - IDP_RelinkProperty(scene->world->id.properties); + if (scene->world) { + IDP_RelinkProperty(scene->world->id.properties); + } if (scene->clip) { IDP_RelinkProperty(scene->clip->id.properties); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 1ace61481a6..b22a158e151 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -727,7 +727,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe) if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); + seqn = BKE_sequence_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); } if (seqn) { @@ -820,7 +820,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe) if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); + seqn = BKE_sequence_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); } if (seqn) { @@ -2162,7 +2162,7 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) if (ed == NULL) return OPERATOR_CANCELLED; - BKE_sequence_base_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0); + BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0); if (nseqbase.first) { Sequence *seq = nseqbase.first; @@ -3200,7 +3200,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BKE_sequence_base_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME, 0); + BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME, 0); /* To make sure the copied strips have unique names between each other add * them temporarily to the end of the original seqbase. (bug 25932) @@ -3267,7 +3267,7 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) ED_sequencer_deselect_all(scene); ofs = scene->r.cfra - seqbase_clipboard_frame; - BKE_sequence_base_dupli_recursive(scene, NULL, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME, 0); + BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME, 0); /* transform pasted strips before adding */ if (ofs) { diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c index 0d19c503798..1ef3322711c 100644 --- a/source/blender/editors/space_text/text_format_pov.c +++ b/source/blender/editors/space_text/text_format_pov.c @@ -49,36 +49,38 @@ static int txtfmt_pov_find_keyword(const char *string) { int i, len; /* Language Directives */ - if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len; + if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "persistent", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "patch", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "range", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "render", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "undef", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "write", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len; else i = 0; /* If next source char is an identifier (eg. 'i' in "definate") no match */ @@ -92,221 +94,275 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) * list is from... * http://www.povray.org/documentation/view/3.7.0/212/ */ + + /* Float Functions */ + if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "bitwise_or", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "bitwise_xor", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "file_exists", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "precompute", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "dimensions", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clipped_by", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "shadowless", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "turb_depth", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "reciprocal", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "quaternion", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "phong_size", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tesselate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "save_file", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "load_file", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "transform", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "translate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "direction", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "roughness", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "metallic", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "gts_load", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "gts_save", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "location", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "altitude", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "function", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "evaluate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "inverse", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "collect", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "target", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "albedo", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "rotate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "jitter", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "angle", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "right", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "scale", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "child", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "crand", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "blink", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "defined", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "degrees", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "inside", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "radians", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vlength", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "select", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "floor", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "strcmp", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "strlen", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tessel", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sturm", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "abs", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "acosh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "prod", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "with", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "acos", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "asc", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "asinh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "asin", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "atan2", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "atand", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "atanh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "atan", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ceil", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "warp", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cosh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "log", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "min", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "mod", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pow", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "rand", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "seed", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "form", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sinh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sqrt", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tanh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vdot", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sin", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sum", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pwr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tan", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "val", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cos", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "div", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "exp", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "int", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sky", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "up", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ln", len)) i = len; + /* Color Identifiers */ + else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "filter", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "srgbft", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "srgbt", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "rgbft", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "gamma", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "green", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "blue", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "gray", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "srgb", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sRGB", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "SRGB", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "rgbt", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "red", len)) i = len; + /* Color Spaces */ + else if (STR_LITERAL_STARTSWITH(string, "pov", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "hsl", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "hsv", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "xyl", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "xyv", len)) i = len; + /* Vector Functions */ + else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "trace", len)) i = len; + /* String Functions */ + else if (STR_LITERAL_STARTSWITH(string, "file_time", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "concat", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "substr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "chr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "str", len)) i = len; + else i = 0; + + /* If next source char is an identifier (eg. 'i' in "definate") no match */ + return (i == 0 || text_check_identifier(string[i])) ? -1 : i; +} + + +static int txtfmt_pov_find_reserved_builtins(const char *string) +{ + int i, len; + + /* POV-Ray Built-in Variables + * list is from... + * http://www.povray.org/documentation/view/3.7.0/212/ + */ /* Language Keywords */ - if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) i = len; + if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "smooth_triangle", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "lommel_seeliger", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "falloff_angle", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "aa_threshold", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "hypercomplex", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "major_radius", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_distance", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_iteration", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "colour_space", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "color_space", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "iridescence", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "subsurface", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "scattering", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "absorption", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "adc_bailout", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "albedo", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "translucency", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "all", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "alpha", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "altitude", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "always_sample", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ambient_light", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "angle", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "aperture", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "water_level", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "oren_nayar", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "refraction", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "hierarchy", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "radiosity", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tolerance", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "interior", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "toroidal", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "emission", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "material", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "internal", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "photons", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "arc_angle", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "minnaert", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "texture", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "array", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "assumed_gamma", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "black_hole", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "blur_samples", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "brightness", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "brilliance", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "charset", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "collect", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "component", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "composite", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "confidence", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "contained_by", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "coords", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "count", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "crand", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "cube", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "diffuse", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "direction", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "dist_exp", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "distance", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "eccentricity", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "emission", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "error_bound", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "evaluate", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "expand_thresholds", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "exponent", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "exterior", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "extinction", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "face_indices", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "falloff_angle", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "file_gamma", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "flatness", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "planet", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "screw", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "keep", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "flip", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "focal_point", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "fog_alt", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "fog_offset", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "fog_type", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "form", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "fresnel", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "function", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "gamma", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "gather", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "gray_threshold", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "hf_gray_16", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "hierarchy", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "hypercomplex", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "importance", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "inside_vector", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "internal", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "intervals", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ior", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "irid_wavelength", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "irid", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "load_file", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "location", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "move", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "roll", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "low_error_factor", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "major_radius", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max_distance", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max_gradient", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max_iteration", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max_sample", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max_trace_level", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "maximum_reuse", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "metallic", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "method", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "metric", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "minimum_reuse", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "nearest_count", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "normal_indices", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "normal_vectors", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "now", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "number_of_waves", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "offset", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "open", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "orientation", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pass_through", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "pattern", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "phong_size", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "phong", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pot", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "precision", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "precompute", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pretrace_end", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pretrace_start", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "prod", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pwr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "quaternion", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "radiosity", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "radius", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "reciprocal", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "recursion_limit", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "refraction", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "width", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "right", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "roughness", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "samples", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "save_file", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "scattering", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "bend", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "size", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sky", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "alpha", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "slice", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "smooth", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "solid", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "spacing", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "specular", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "split_union", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "spotlight", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "strength", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sturm", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sum", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "target", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "texture_list", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "thickness", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "threshold", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "tightness", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "tolerance", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "toroidal", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ttf", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "turb_depth", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "all", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "now", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pot", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "type", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "u_steps", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "up", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "use_alpha", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "uv_indices", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "uv_vectors", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "v_steps", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "variance", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vertex_vectors", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "water_level", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "width", len)) i = len; - - else i = 0; - - /* If next source char is an identifier (eg. 'i' in "definate") no match */ - return (i == 0 || text_check_identifier(string[i])) ? -1 : i; -} - - -static int txtfmt_pov_find_reserved_builtins(const char *string) -{ - int i, len; - - /* POV-Ray Built-in Variables - * list is from... - * http://www.povray.org/documentation/view/3.7.0/212/ - */ - if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len; + /* Animation Options */ + else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len; - /* Color Identifiers */ - else if (STR_LITERAL_STARTSWITH(string, "blue", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "filter", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "gray", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "green", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "red", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "rgbft", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "rgbt", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "srgb", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sRGB", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "SRGB", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "srgbft", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "srgbt", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; + /* Spline Identifiers */ + else if (STR_LITERAL_STARTSWITH(string, "extended_x_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "general_x_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "quadratic_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "basic_x_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "natural_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "linear_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "bezier_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "akima_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sor_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tcb_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) i = len; /* Patterns */ - else if (STR_LITERAL_STARTSWITH(string, "agate", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "density_file", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cylindrical", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "proportion", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "triangular", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "image_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "proximity", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "spherical", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "bump_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "wrinkles", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "average", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "voronoi", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "masonry", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "binary", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "boxed", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "bozo", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "brick", len)) i = len; @@ -315,14 +371,11 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) else if (STR_LITERAL_STARTSWITH(string, "checker", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "crackle", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cylindrical", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "density_file", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "dents", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "facets", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "gradient", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "granite", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "hexagon", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "julia", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "leopard", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "magnet", len)) i = len; @@ -330,13 +383,11 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) else if (STR_LITERAL_STARTSWITH(string, "marble", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "onion", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "pavement", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "planar", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "quilted", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "radial", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ripples", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "slope", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "spherical", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "spiral1", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "spiral2", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "spotted", len)) i = len; @@ -344,97 +395,68 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) else if (STR_LITERAL_STARTSWITH(string, "tile2", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "tiling", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "tiles", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "triangular", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "waves", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "wood", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "wrinkles", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "agate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) i = len; /* Objects */ - else if (STR_LITERAL_STARTSWITH(string, "background", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "bicubic_patch", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "blob", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "box", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "camera", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cone", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "julia_fractal", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "height_field", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sphere_sweep", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "light_group", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "light_source", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "intersection", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "isosurface", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "background", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sky_sphere", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "cylinder", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "difference", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "brilliance", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "parametric", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "interunion", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "intermerge", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "polynomial", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "displace", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "specular", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "diffuse", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "polygon", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "quadric", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "quartic", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "rainbow", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "spline", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "prism", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "camera", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "galley", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "phong", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cone", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "blob", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "box", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "disc", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fog", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "height_field", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "intersection", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "isosurface", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "julia_fractal", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "lathe", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "light_group", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "light_source", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "merge", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "mesh2", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "mesh", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "object", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ovus", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "lemon", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "parametric", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "plane", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "poly", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "polygon", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "polynomial", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "prism", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "quadric", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "quartic", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "rainbow", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sky_sphere", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "smooth_triangle", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sphere_sweep", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "spline", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "irid", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "sor", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "text", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "torus", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "triangle", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "union", len)) i = len; - /* Filetypes */ - else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "gif", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "iff", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "png", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sys", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "tga", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) i = len; - /* Spline Identifiers */ - else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "bezier_spline", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "linear_spline", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "natural_spline", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "quadratic_spline", len)) i = len; - /* Encodings */ - else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) i = len; - /* Camera Types */ - else if (STR_LITERAL_STARTSWITH(string, "fisheye", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "mesh_camera", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "omnimax", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "orthographic", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "panoramic", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "perspective", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ultra_wide_angle", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "colour", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "media", len)) i = len; /* Built-in Vectors */ else if (STR_LITERAL_STARTSWITH(string, "t", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "u", len)) i = len; @@ -442,7 +464,6 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) else if (STR_LITERAL_STARTSWITH(string, "x", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "y", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "z", len)) i = len; - else i = 0; /* If next source char is an identifier (eg. 'i' in "definate") no match */ @@ -465,156 +486,201 @@ static int txtfmt_pov_find_specialvar(const char *string) { int i, len; /* Modifiers */ - if (STR_LITERAL_STARTSWITH(string, "interior_texture", len)) i = len; + if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "double_illuminate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "expand_thresholds", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "media_interaction", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "media_attenuation", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "low_error_factor", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "recursion_limit", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "interior_texture", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_trace_level", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "gray_threshold", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pretrace_start", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "normal_indices", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "normal_vectors", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vertex_vectors", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "noise_generator", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "irid_wavelength", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "number_of_waves", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ambient_light", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "inside_vector", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "face_indices", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "texture_list", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_gradient", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "uv_indices", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "uv_vectors", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fade_distance", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "global_lights", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "no_bump_scale", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pretrace_end", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "no_radiosity", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "no_reflection", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "assumed_gamma", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "scallop_wave", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "triangle_wave", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "nearest_count", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "maximum_reuse", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "minimum_reuse", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "always_sample", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "translucency", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "eccentricity", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "contained_by", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "inside_point", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "adc_bailout", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "density_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "split_union", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "mm_per_unit", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "agate_turb", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "bounded_by", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "brick_size", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "bump_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "bump_size", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "circular", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clipped_by", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "hf_gray_16", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "extinction", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "thickness", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "color_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "colour_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "colour", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "control0", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "control1", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "cubic_wave", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "density_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "density", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "fade_color", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fade_colour", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "fade_distance", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "global_lights", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "hollow", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "image_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "adaptive", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "interior", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "interpolate", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "inverse", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "jitter", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "map_type", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "material_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "material", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "media", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "mm_per_unit", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "mortar", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "no_bump_scale", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "no_image", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "no_radiosity", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "no_reflection", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "no_shadow", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fade_color", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "normal_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "omega", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "once", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "orient", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "parallel", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "phase", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "photons", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "pigment_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "finish", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "poly_wave", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "quick_color", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "quick_colour", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ramp_wave", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "rotate", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "scale", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "scallop_wave", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "shadowless", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sine_wave", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "slope_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "subsurface", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "material_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pass_through", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "interpolate", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "texture_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "texture", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "transform", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "translate", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "triangle_wave", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "turbulence", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "error_bound", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "brightness", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "use_color", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "use_alpha", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "use_colour", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "use_index", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "uv_mapping", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "warp", len)) i = len; - - /* Vector Functions */ - else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "trace", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) i = len; - /* String Functions */ - else if (STR_LITERAL_STARTSWITH(string, "chr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "concat", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "str", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "substr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) i = len; - /* Float Functions */ - else if (STR_LITERAL_STARTSWITH(string, "abs", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "acosh", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "acos", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "asc", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "asinh", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "asin", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "atan2", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "atand", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "atanh", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "atan", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "bitwise_or", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "bitwise_xor", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ceil", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cosh", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cos", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "defined", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "degrees", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "dimensions", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "div", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "exp", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "file_exists", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "floor", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "inside", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "int", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ln", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "log", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "min", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "mod", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pow", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "radians", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "rand", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "seed", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "select", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sinh", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sin", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sqrt", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "strcmp", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "strlen", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "tanh", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "tan", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "val", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vdot", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vlength", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "importance", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_sample", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "intervals", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sine_wave", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "slope_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "poly_wave", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "no_shadow", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ramp_wave", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "precision", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "original", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "map_type", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "no_image", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "distance", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fog_offset", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "modulation", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "outbound", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "no_cache", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "charset", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "inbound", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "outside", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "inner", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "turbulence", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "threshold", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "polarity", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "bump_size", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "circular", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "control0", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "control1", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "maximal", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "minimal", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fog_type", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fog_alt", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "samples", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "origin", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "amount", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "adaptive", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "exponent", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "strength", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "density", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fresnel", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "albinos", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "finish", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "method", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "omega", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fixed", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "spacing", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "u_steps", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "v_steps", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "offset", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "hollow", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "gather", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "mortar", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "count", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "once", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "orient", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "phase", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "open", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ior", len)) i = len; + /* Light Types and options*/ + else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tightness", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "spotlight", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "parallel", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "radius", len)) i = len; + /* Camera Types and options*/ + else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "miller_cylindrical", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "lambert_azimuthal", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ultra_wide_angle", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "camera_direction", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "camera_location ", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "van_der_grinten", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "aitoff_hammer", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "smyth_craster", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "orthographic", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "camera_right", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "blur_samples", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "plate_carree", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "camera_type", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "perspective", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "mesh_camera", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "focal_point", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "balthasart", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "confidence", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "parallaxe", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "hobo_dyer", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "camera_up", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "panoramic", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "eckert_vi", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "eckert_iv", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "mollweide", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "aperture", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "behrmann", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "variance", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "stereo", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "icosa", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tetra", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "octa", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "mercator", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "omnimax", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fisheye", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "edwards", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "peters", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "gall", len)) i = len; else i = 0; /* If next source char is an identifier (eg. 'i' in "definate") no match */ @@ -625,15 +691,43 @@ static int txtfmt_pov_find_bool(const char *string) { int i, len; /*Built-in Constants*/ - if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len; - else i = 0; + if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len; + /* Encodings */ + else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "bt2020", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "bt709", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) i = len; + /* Filetypes */ + else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "gif", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "iff", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "png", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sys", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tga", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ttf", len)) i = len; + else i = 0; /* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */ return (i == 0 || text_check_identifier(string[i])) ? -1 : i; @@ -645,7 +739,7 @@ static char txtfmt_pov_format_identifier(const char *str) if ((txtfmt_pov_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL; else if ((txtfmt_pov_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD; else if ((txtfmt_pov_find_reserved_keywords(str)) != -1) fmt = FMT_TYPE_RESERVED; - else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) fmt = FMT_TYPE_RESERVED; + else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) fmt = FMT_TYPE_DIRECTIVE; else fmt = FMT_TYPE_DEFAULT; return fmt; } @@ -770,7 +864,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_ if ((i = txtfmt_pov_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL; else if ((i = txtfmt_pov_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD; else if ((i = txtfmt_pov_find_reserved_keywords(str)) != -1) prev = FMT_TYPE_RESERVED; - else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) prev = FMT_TYPE_RESERVED; + else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) prev = FMT_TYPE_DIRECTIVE; if (i > 0) { text_format_fill_ascii(&str, &fmt, prev, i); diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c index 719f4e3c036..453dd1d748c 100644 --- a/source/blender/editors/space_text/text_format_pov_ini.c +++ b/source/blender/editors/space_text/text_format_pov_ini.c @@ -49,36 +49,36 @@ static int txtfmt_ini_find_keyword(const char *string) { int i, len; /* Language Directives */ - if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len; + if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "range", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "render", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "undef", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "write", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "I", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "S", len)) i = len; @@ -104,29 +104,54 @@ static int txtfmt_ini_find_reserved(const char *string) * list is from... * http://www.povray.org/documentation/view/3.7.0/212/ */ - if (STR_LITERAL_STARTSWITH(string, "Antialias_Threshold", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) i = len; + if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "HideWhenMainMinimized", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Antialias_Confidence", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSound", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSound", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSound", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "UseExtensions", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ReadWriteSourceDir", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "NormalPositionLeft", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "NormalPositionTop", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "NormalPositionRight", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "NormalPositionBottom", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Command", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Command", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Command", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Command", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Command", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Command", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "NormalPositionX", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "NormalPositionY", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Return", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Return", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Return", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Return", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Return", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Return", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Antialias_Threshold", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Antialias_Gamma", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Subset_Start_Frame", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Subset_End_Frame", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "UseToolbar", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "UseTooltips", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Frame_Step", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Cyclic_Animation", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Field_Render", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Odd_Field", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Height", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Width", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Start_Column", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Start_Row", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "End_Column", len)) i = len; @@ -134,7 +159,7 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "Test_Abort_Count", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Test_Abort", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Continue_Trace", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Display", len)) i = len; @@ -151,19 +176,6 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "Bits_Per_Color", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Compression", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Dither_Method", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Command", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Command", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Command", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Command", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Command", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Command", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Return", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Return", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Return", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Return", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Return", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Return", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Include_Header", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Library_Path", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Debug_Console", len)) i = len; @@ -187,7 +199,9 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "Remove_Bounds", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Split_Unions", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Antialias", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Glare_Desaturation", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Sampling_Method", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Stochastic_Seed", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Jitter_Amount", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Jitter", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) i = len; @@ -221,25 +235,14 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "Band3Width", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Band4Width", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ShowCmd", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "NormalPositionLeft", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "NormalPositionTop", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "NormalPositionRight", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "NormalPositionBottom", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "UseToolbar", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "UseTooltips", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "NormalPositionX", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "NormalPositionY", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Transparency", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Use8BitMode", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "MakeActive", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "KeepAboveMain", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "HideWhenMainMinimized", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "AutoClose", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "PreserveBitmap", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "FontSize", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "FontWeight", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Font", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "KeepMessages", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "AlertSound", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Completion", len)) i = len; @@ -250,14 +253,6 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "PreventSleep", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "NoShelloutWait", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "SystemNoActive", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSound", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSound", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSound", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "UseExtensions", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ReadWriteSourceDir", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "NoShellOuts", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "VideoSource", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "SceneFile", len)) i = len; @@ -269,6 +264,14 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "RenderwinClose", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Append_File", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Warning Level", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Height", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Width", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Font", len)) i = len; /* Filetypes */ else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len; diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c index f0edcc31a10..5b059ef89d2 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.c +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c @@ -25,12 +25,14 @@ */ #include "DNA_cachefile_types.h" +#include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BKE_cachefile.h" #include "BKE_DerivedMesh.h" +#include "BKE_cdderivedmesh.h" #include "BKE_global.h" #include "BKE_library.h" #include "BKE_library_query.h" @@ -95,11 +97,15 @@ static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, - ModifierApplyFlag flag) + ModifierApplyFlag UNUSED(flag)) { #ifdef WITH_ALEMBIC MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *) md; + /* Only used to check whether we are operating on org data or not... */ + Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL; + DerivedMesh *org_dm = dm; + Scene *scene = md->scene; const float frame = BKE_scene_frame_get(scene); const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS); @@ -121,6 +127,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } } + if (me != NULL) { + MVert *mvert = dm->getVertArray(dm); + MEdge *medge = dm->getEdgeArray(dm); + MPoly *mpoly = dm->getPolyArray(dm); + if ((me->mvert == mvert) || (me->medge == medge) || (me->mpoly == mpoly)) { + /* We need to duplicate data here, otherwise we'll modify org mesh, see T51701. */ + dm = CDDM_copy(dm); + } + } + DerivedMesh *result = ABC_read_mesh(mcmd->reader, ob, dm, @@ -132,11 +148,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, modifier_setError(md, "%s", err_str); } + if (!ELEM(result, NULL, dm) && (dm != org_dm)) { + dm->release(dm); + dm = org_dm; + } + return result ? result : dm; - UNUSED_VARS(flag); #else return dm; - UNUSED_VARS(md, ob, flag); + UNUSED_VARS(md, ob); #endif } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 8139e29bade..a95c3233132 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -178,6 +178,9 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node, LinkNod cmp_node_image_add_pass_output(ntree, node, "Alpha", RE_PASSNAME_COMBINED, -1, SOCK_FLOAT, false, available_sockets, &prev_index); if (ima) { + if (!ima->rr) { + cmp_node_image_add_pass_output(ntree, node, RE_PASSNAME_Z, RE_PASSNAME_Z, -1, SOCK_FLOAT, false, available_sockets, &prev_index); + } BKE_image_release_ibuf(ima, ibuf, NULL); } } diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index fdc2371c259..90aa22de5bf 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -59,8 +59,12 @@ static PyStructSequence_Field app_cb_info_fields[] = { {(char *)"load_post", (char *)"on loading a new blend file (after)"}, {(char *)"save_pre", (char *)"on saving a blend file (before)"}, {(char *)"save_post", (char *)"on saving a blend file (after)"}, - {(char *)"scene_update_pre", (char *)"on updating the scenes data (before)"}, - {(char *)"scene_update_post", (char *)"on updating the scenes data (after)"}, + {(char *)"scene_update_pre", (char *)"on every scene data update. Does not imply that anything changed in the " + "scene, just that the dependency graph is about to be reevaluated, and the " + "scene is about to be updated by Blender's animation system."}, + {(char *)"scene_update_post", (char *)"on every scene data update. Does not imply that anything changed in the " + "scene, just that the dependency graph was reevaluated, and the scene was " + "possibly updated by Blender's animation system."}, {(char *)"game_pre", (char *)"on starting the game engine"}, {(char *)"game_post", (char *)"on ending the game engine"}, {(char *)"version_update", (char *)"on ending the versioning code"}, diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fa0b86a2637..64326f34377 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,8 @@ # Python CTests -add_subdirectory(python) +if(WITH_BLENDER) + add_subdirectory(python) +endif() # GTest add_subdirectory(gtests) - diff --git a/tests/python/bl_alembic_import_test.py b/tests/python/bl_alembic_import_test.py index f45748f86e7..c3a4af26e11 100644 --- a/tests/python/bl_alembic_import_test.py +++ b/tests/python/bl_alembic_import_test.py @@ -179,22 +179,24 @@ class SimpleImportTest(AbstractAlembicTest): res = bpy.ops.wm.alembic_import(filepath=str(abc), as_background_job=False) self.assertEqual({'FINISHED'}, res) - cube = bpy.context.active_object + plane = bpy.context.active_object # Check that the file loaded ok. bpy.context.scene.frame_set(6) - self.assertAlmostEqual(-1, cube.data.vertices[0].co.x) - self.assertAlmostEqual(-1, cube.data.vertices[0].co.y) - self.assertAlmostEqual(0.5905638933181763, cube.data.vertices[0].co.z) + mesh = plane.to_mesh(bpy.context.scene, True, 'RENDER') + self.assertAlmostEqual(-1, mesh.vertices[0].co.x) + self.assertAlmostEqual(-1, mesh.vertices[0].co.y) + self.assertAlmostEqual(0.5905638933181763, mesh.vertices[0].co.z) # Change path from absolute to relative. This should not break the animation. bpy.context.scene.frame_set(1) bpy.data.cache_files[fname].filepath = relpath bpy.context.scene.frame_set(6) - self.assertAlmostEqual(1, cube.data.vertices[3].co.x) - self.assertAlmostEqual(1, cube.data.vertices[3].co.y) - self.assertAlmostEqual(0.5905638933181763, cube.data.vertices[3].co.z) + mesh = plane.to_mesh(bpy.context.scene, True, 'RENDER') + self.assertAlmostEqual(1, mesh.vertices[3].co.x) + self.assertAlmostEqual(1, mesh.vertices[3].co.y) + self.assertAlmostEqual(0.5905638933181763, mesh.vertices[3].co.z) def test_import_long_names(self): # This file contains very long names. The longest name is 4047 chars. diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py index 7ffececd1d9..2d8a908406f 100644 --- a/tests/python/bl_load_py_modules.py +++ b/tests/python/bl_load_py_modules.py @@ -123,6 +123,8 @@ def load_addons(): def load_modules(): + VERBOSE = os.environ.get("BLENDER_VERBOSE") is not None + modules = [] module_paths = [] @@ -162,6 +164,14 @@ def load_modules(): del module_names # + # test we tested all files except for presets and templates + ignore_paths = [ + os.sep + "presets" + os.sep, + os.sep + "templates" + os.sep, + ] + ([(os.sep + f + os.sep) for f in BLACKLIST] + + [(os.sep + f + ".py") for f in BLACKLIST]) + + # # now submodules for m in modules: filepath = m.__file__ @@ -199,7 +209,14 @@ def load_modules(): # import failure. # - We want to catch all failures of this script instead of stopping on # a first big failure. - traceback.print_exc() + do_print = True + if not VERBOSE: + for ignore in ignore_paths: + if ignore in submod_full: + do_print = False + break + if do_print: + traceback.print_exc() # # check which filepaths we didn't load @@ -218,14 +235,6 @@ def load_modules(): for f in loaded_files: source_files.remove(f) - # - # test we tested all files except for presets and templates - ignore_paths = [ - os.sep + "presets" + os.sep, - os.sep + "templates" + os.sep, - ] + ([(os.sep + f + os.sep) for f in BLACKLIST] + - [(os.sep + f + ".py") for f in BLACKLIST]) - for f in source_files: for ignore in ignore_paths: if ignore in f: |