Compare commits

..

9 Commits

Author SHA1 Message Date
925166bed6 continue with derived node tree 2020-05-05 15:13:02 +02:00
dd1a90353b rename 2020-05-05 14:35:27 +02:00
04c05a028c DerivedNodeTree data structure 2020-05-05 14:31:43 +02:00
22d68d0f26 fix memory leak 2020-05-04 17:41:29 +02:00
220bcdaa15 Add dot exporter 2020-05-04 17:35:26 +02:00
a9051f4106 initial NodeTreeRef generation 2020-05-04 17:15:20 +02:00
a600e76a58 Merge branch 'master' into node-tree-ref 2020-05-04 17:13:12 +02:00
723b12bbca add inline functions 2020-05-04 16:03:00 +02:00
7ca85442ad initial node tree ref declarations 2020-04-28 15:03:44 +02:00
1093 changed files with 16611 additions and 16446 deletions

View File

@@ -256,7 +256,6 @@ ForEachMacros:
- SEQ_BEGIN
- SURFACE_QUAD_ITER_BEGIN
- foreach
- ED_screen_areas_iter
# Use once we bump the minimum version to version 8.
# # Without this string literals that in-line 'STRINGIFY' behave strangely (a bug?).

View File

@@ -281,7 +281,7 @@ option(WITH_ALEMBIC "Enable Alembic Support" ON)
option(WITH_ALEMBIC_HDF5 "Enable Legacy Alembic Support (not officially supported)" OFF)
# Universal Scene Description support
option(WITH_USD "Enable Universal Scene Description (USD) Support" ON)
option(WITH_USD "Enable Universal Scene Description (USD) Support" OFF)
# 3D format support
# Disable opencollada when we don't have precompiled libs
@@ -628,6 +628,12 @@ if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
endif()
# may as well build python module without a UI
if(WITH_PYTHON_MODULE)
set(WITH_HEADLESS ON)
endif()
if(NOT WITH_PYTHON)
set(WITH_CYCLES OFF)
set(WITH_DRACO OFF)
@@ -1733,7 +1739,6 @@ if(FIRST_RUN)
info_cfg_option(WITH_ALEMBIC)
info_cfg_option(WITH_QUADRIFLOW)
info_cfg_option(WITH_USD)
info_cfg_option(WITH_TBB)
info_cfg_text("Compiler Options:")
info_cfg_option(WITH_BUILDINFO)

View File

@@ -130,6 +130,7 @@ if(NOT WIN32 OR ENABLE_MINGW64)
include(cmake/vpx.cmake)
include(cmake/x264.cmake)
include(cmake/xvidcore.cmake)
include(cmake/faad.cmake)
include(cmake/ffmpeg.cmake)
include(cmake/fftw.cmake)
include(cmake/sndfile.cmake)

View File

@@ -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(FAAD_EXTRA_ARGS)
if(WIN32)
set(FAAD_EXTRA_CONFIGURE "utils\\win32\\ac2ver.exe" "faad2" "configure.ac" > libfaad\\win32_ver.h)
else()
set(FAAD_EXTRA_CONFIGURE echo .)
endif()
ExternalProject_Add(external_faad
URL ${FAAD_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${FAAD_HASH}
PREFIX ${BUILD_DIR}/faad
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/faad/src/external_faad/ && ${FAAD_EXTRA_CONFIGURE} && ${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()

View File

@@ -127,6 +127,7 @@ endif()
add_dependencies(
external_ffmpeg
external_zlib
external_faad
external_openjpeg
external_xvidcore
external_x264

View File

@@ -19,12 +19,8 @@
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)
set(FFTW_EXTRA_ARGS --disable-static --enable-shared)
set(FFTW_INSTALL install-strip)
else()
set(FFTW_EXTRA_ARGS --enable-static)
set(FFTW_INSTALL install)
endif()
ExternalProject_Add(external_fftw3
@@ -32,10 +28,10 @@ ExternalProject_Add(external_fftw3
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${FFTW_HASH}
PREFIX ${BUILD_DIR}/fftw3
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && ${CONFIGURE_COMMAND} ${FFTW_EXTRA_ARGS} --prefix=${mingw_LIBDIR}/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 ${FFTW_INSTALL}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3/ && make install
INSTALL_DIR ${LIBDIR}/fftw3
)
@@ -43,8 +39,7 @@ if(MSVC)
set_target_properties(external_fftw3 PROPERTIES FOLDER Mingw)
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_fftw3 after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/lib/libfftw3.dll.a ${HARVEST_TARGET}/fftw3/lib/libfftw.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/bin/libfftw3-3.dll ${HARVEST_TARGET}/fftw3/lib/libfftw3-3.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/lib/libfftw3.a ${HARVEST_TARGET}/fftw3/lib/libfftw.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/include/fftw3.h ${HARVEST_TARGET}/fftw3/include/fftw3.h
DEPENDEES install
)

View File

@@ -44,6 +44,10 @@ if(BUILD_MODE STREQUAL Release)
# 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/ &&

View File

@@ -18,7 +18,7 @@
if(WIN32)
# cmake for windows
set(JPEG_EXTRA_ARGS -DNASM=${NASM_PATH} -DWITH_JPEG8=ON -DCMAKE_DEBUG_POSTFIX=d -DWITH_CRT_DLL=On)
set(JPEG_EXTRA_ARGS -DNASM=${NASM_PATH} -DWITH_JPEG8=ON -DCMAKE_DEBUG_POSTFIX=d)
ExternalProject_Add(external_jpeg
URL ${JPEG_URI}

View File

@@ -52,6 +52,7 @@ if(BUILD_MODE STREQUAL Release)
PREFIX ${BUILD_DIR}/openal
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openal ${DEFAULT_CMAKE_FLAGS} ${OPENAL_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/openal
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openal/src/external_openal < ${PATCH_DIR}/openal.diff
)
if(WIN32)

View File

@@ -67,7 +67,7 @@ endif()
ExternalProject_Add(external_opensubdiv
URL ${OPENSUBDIV_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${OPENSUBDIV_HASH}
URL_HASH MD5=${OPENSUBDIV_Hash}
PREFIX ${BUILD_DIR}/opensubdiv
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opensubdiv -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${OPENSUBDIV_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/opensubdiv

View File

@@ -24,7 +24,7 @@ if(WIN32)
set(PTHREAD_CPPFLAGS "/I. /DHAVE_CONFIG_H ")
endif()
set(PTHREADS_BUILD cd ${BUILD_DIR}/pthreads/src/external_pthreads/ && cd && nmake VC-static /e CPPFLAGS=${PTHREAD_CPPFLAGS})
set(PTHREADS_BUILD cd ${BUILD_DIR}/pthreads/src/external_pthreads/ && cd && nmake VC-static /e CPPFLAGS=${PTHREAD_CPPFLAGS} /e XLIBS=/NODEFAULTLIB:msvcr)
ExternalProject_Add(external_pthreads
URL ${PTHREADS_URI}
@@ -32,7 +32,6 @@ if(WIN32)
URL_HASH MD5=${PTHREADS_HASH}
PREFIX ${BUILD_DIR}/pthreads
CONFIGURE_COMMAND echo .
PATCH_COMMAND COMMAND ${PATCH_CMD} -p 1 -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/libpthreadVC3${LIBEXT} ${LIBDIR}/pthreads/lib/pthreadVC3${LIBEXT} &&

View File

@@ -60,14 +60,3 @@ if(UNIX)
external_flac
)
endif()
if(BUILD_MODE STREQUAL Release AND WIN32)
ExternalProject_Add_Step(external_sndfile after_install
COMMAND lib /def:${BUILD_DIR}/sndfile/src/external_sndfile/src/libsndfile-1.def /machine:x64 /out:${BUILD_DIR}/sndfile/src/external_sndfile/src/libsndfile-1.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/bin/libsndfile-1.dll ${HARVEST_TARGET}/sndfile/lib/libsndfile-1.dll
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/sndfile/src/external_sndfile/src/libsndfile-1.lib ${HARVEST_TARGET}/sndfile/lib/libsndfile-1.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/include/sndfile.h ${HARVEST_TARGET}/sndfile/include/sndfile.h
DEPENDEES install
)
endif()

View File

@@ -20,9 +20,9 @@ set(ZLIB_VERSION 1.2.11)
set(ZLIB_URI https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz)
set(ZLIB_HASH 1c9f62f0778697a09d36121ead88e08e)
set(OPENAL_VERSION 1.20.1)
set(OPENAL_VERSION 1.18.2)
set(OPENAL_URI http://openal-soft.org/openal-releases/openal-soft-${OPENAL_VERSION}.tar.bz2)
set(OPENAL_HASH 556695068ce8375b89986083d810fd35)
set(OPENAL_HASH d4eeb0889812e2fdeaa1843523d76190)
set(PNG_VERSION 1.6.35)
set(PNG_URI http://prdownloads.sourceforge.net/libpng/libpng-${PNG_VERSION}.tar.xz)
@@ -66,9 +66,9 @@ else()
set(OPENEXR_VERSION_POSTFIX)
endif()
set(FREETYPE_VERSION 2.10.2)
set(FREETYPE_VERSION 2.10.1)
set(FREETYPE_URI http://prdownloads.sourceforge.net/freetype/freetype-${FREETYPE_VERSION}.tar.gz)
set(FREETYPE_HASH b1cb620e4c875cd4d1bfa04945400945)
set(FREETYPE_HASH c50a3c9e5e62bdc938a6e1598a782947)
set(GLEW_VERSION 1.13.0)
set(GLEW_URI http://prdownloads.sourceforge.net/glew/glew/${GLEW_VERSION}/glew-${GLEW_VERSION}.tgz)
@@ -101,13 +101,13 @@ 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_4_3)
set(OPENSUBDIV_VERSION v3_4_0_RC2)
set(OPENSUBDIV_Hash f6a10ba9efaa82fde86fe65aad346319)
set(OPENSUBDIV_URI https://github.com/PixarAnimationStudios/OpenSubdiv/archive/${OPENSUBDIV_VERSION}.tar.gz)
set(OPENSUBDIV_HASH 7bbfa275d021fb829e521df749160edb)
set(SDL_VERSION 2.0.12)
set(SDL_VERSION 2.0.8)
set(SDL_URI https://www.libsdl.org/release/SDL2-${SDL_VERSION}.tar.gz)
set(SDL_HASH 783b6f2df8ff02b19bb5ce492b99c8ff)
set(SDL_HASH 3800d705cef742c6a634f202c37f263f)
set(OPENCOLLADA_VERSION v1.6.68)
set(OPENCOLLADA_URI https://github.com/KhronosGroup/OpenCOLLADA/archive/${OPENCOLLADA_VERSION}.tar.gz)
@@ -168,9 +168,9 @@ set(LAME_VERSION 3.100)
set(LAME_URI http://downloads.sourceforge.net/project/lame/lame/3.100/lame-${LAME_VERSION}.tar.gz)
set(LAME_HASH 83e260acbe4389b54fe08e0bdbf7cddb)
set(OGG_VERSION 1.3.4)
set(OGG_VERSION 1.3.3)
set(OGG_URI http://downloads.xiph.org/releases/ogg/libogg-${OGG_VERSION}.tar.gz)
set(OGG_HASH fe5670640bd49e828d64d2879c31cb4dde9758681bb664f9bdbf159a01b0c76e)
set(OGG_HASH c2e8a485110b97550f453226ec644ebac6cb29d1caef2902c007edab4308d985)
set(VORBIS_VERSION 1.3.6)
set(VORBIS_URI http://downloads.xiph.org/releases/vorbis/libvorbis-${VORBIS_VERSION}.tar.gz)
@@ -180,24 +180,24 @@ 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.3)
set(FLAC_VERSION 1.3.2)
set(FLAC_URI http://downloads.xiph.org/releases/flac/flac-${FLAC_VERSION}.tar.xz)
set(FLAC_HASH 213e82bd716c9de6db2f98bcadbc4c24c7e2efe8c75939a1a84e28539c4e1748)
set(FLAC_HASH 91cfc3ed61dc40f47f050a109b08610667d73477af6ef36dcad31c31a4a8d53f)
set(VPX_VERSION 1.8.2)
set(VPX_VERSION 1.7.0)
set(VPX_URI https://github.com/webmproject/libvpx/archive/v${VPX_VERSION}/libvpx-v${VPX_VERSION}.tar.gz)
set(VPX_HASH 8735d9fcd1a781ae6917f28f239a8aa358ce4864ba113ea18af4bb2dc8b474ac)
set(VPX_HASH 1fec931eb5c94279ad219a5b6e0202358e94a93a90cfb1603578c326abfc1238)
set(OPUS_VERSION 1.3.1)
set(OPUS_URI https://archive.mozilla.org/pub/opus/opus-${OPUS_VERSION}.tar.gz)
set(OPUS_HASH 65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d)
set(X264_URI https://code.videolan.org/videolan/x264/-/archive/master/x264-33f9e1474613f59392be5ab6a7e7abf60fa63622.tar.gz)
set(X264_HASH 300dfb5b6c35722516f168868ce9419252a9e9eb77a05d82c9cede925b691bd6)
set(X264_URI http://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20180811-2245-stable.tar.bz2)
set(X264_HASH ae8a868a0e236a348b35d79f3ee80294b169d1195408b689f9851383661ed7aa)
set(XVIDCORE_VERSION 1.3.7)
set(XVIDCORE_URI https://downloads.xvid.com/downloads/xvidcore-${XVIDCORE_VERSION}.tar.gz)
set(XVIDCORE_HASH abbdcbd39555691dd1c9b4d08f0a031376a3b211652c0d8b3b8aa9be1303ce2d)
set(XVIDCORE_VERSION 1.3.5)
set(XVIDCORE_URI http://downloads.xvid.org/downloads/xvidcore-${XVIDCORE_VERSION}.tar.gz)
set(XVIDCORE_HASH 165ba6a2a447a8375f7b06db5a3c91810181f2898166e7c8137401d7fc894cf0)
# This has to be in sync with the version in blenders /extern folder.
set(OPENJPEG_VERSION 2.3.0)
@@ -206,9 +206,13 @@ set(OPENJPEG_SHORT_VERSION 2.3)
set(OPENJPEG_URI https://github.com/uclouvain/openjpeg/archive/66297f07a43.zip)
set(OPENJPEG_HASH 8242b18d908c7c42174e4231a741cfa7ce7c26b6ed5c9644feb9df7b3054310b)
set(FFMPEG_VERSION 4.2.3)
set(FAAD_VERSION 2-2.8.8)
set(FAAD_URI http://downloads.sourceforge.net/faac/faad${FAAD_VERSION}.tar.gz)
set(FAAD_HASH 28f6116efdbe9378269f8a6221767d1f)
set(FFMPEG_VERSION 4.0.2)
set(FFMPEG_URI http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2)
set(FFMPEG_HASH 695fad11f3baf27784e24cb0e977b65a)
set(FFMPEG_HASH 5576e8a22f80b6a336db39808f427cfb)
set(FFTW_VERSION 3.3.8)
set(FFTW_URI http://www.fftw.org/fftw-${FFTW_VERSION}.tar.gz)
@@ -315,6 +319,6 @@ set(MESA_VERSION 18.3.1)
set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa//mesa-${MESA_VERSION}.tar.xz)
set(MESA_HASH d60828056d77bfdbae0970f9b15fb1be)
set(XR_OPENXR_SDK_VERSION 1.0.8)
set(XR_OPENXR_SDK_VERSION 1.0.6)
set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
set(XR_OPENXR_SDK_HASH c6de63d2e0f9029aa58dfa97cad8ce07)
set(XR_OPENXR_SDK_HASH 21daea7c3bfec365298d779a0e19caa1)

View File

@@ -18,6 +18,9 @@
if(WIN32)
set(X264_EXTRA_ARGS --enable-win32thread --cross-prefix=${MINGW_HOST}- --host=${MINGW_HOST})
set(X264_PATCH_CMD ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/x264/src/external_x264 < ${PATCH_DIR}/x264.diff)
else()
set(X264_PATCH_CMD echo .)
endif()
@@ -26,6 +29,7 @@ ExternalProject_Add(external_x264
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA256=${X264_HASH}
PREFIX ${BUILD_DIR}/x264
PATCH_COMMAND ${X264_PATCH_CMD}
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264
--enable-static
--enable-pic

View File

@@ -53,15 +53,15 @@ getopt \
--long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,\
with-all,with-opencollada,with-jack,with-embree,with-oidn,\
ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,ver-xr-openxr:,\
force-all,force-python,force-numpy,force-boost,force-tbb,\
force-all,force-python,force-numpy,force-boost,\
force-ocio,force-openexr,force-oiio,force-llvm,force-osl,force-osd,force-openvdb,\
force-ffmpeg,force-opencollada,force-alembic,force-embree,force-oidn,force-usd,\
force-xr-openxr,\
build-all,build-python,build-numpy,build-boost,build-tbb,\
build-all,build-python,build-numpy,build-boost,\
build-ocio,build-openexr,build-oiio,build-llvm,build-osl,build-osd,build-openvdb,\
build-ffmpeg,build-opencollada,build-alembic,build-embree,build-oidn,build-usd,\
build-xr-openxr,\
skip-python,skip-numpy,skip-boost,skip-tbb,\
skip-python,skip-numpy,skip-boost,\
skip-ocio,skip-openexr,skip-oiio,skip-llvm,skip-osl,skip-osd,skip-openvdb,\
skip-ffmpeg,skip-opencollada,skip-alembic,skip-embree,skip-oidn,skip-usd,\
skip-xr-openxr \
@@ -191,9 +191,6 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--build-boost
Force the build of Boost.
--build-tbb
Force the build of TBB.
--build-ocio
Force the build of OpenColorIO.
@@ -258,9 +255,6 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--force-boost
Force the rebuild of Boost.
--force-tbb
Force the rebuild of TBB.
--force-ocio
Force the rebuild of OpenColorIO.
@@ -318,9 +312,6 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--skip-boost
Unconditionally skip Boost installation/building.
--skip-tbb
Unconditionally skip TBB installation/building.
--skip-ocio
Unconditionally skip OpenColorIO installation/building.
@@ -394,13 +385,6 @@ BOOST_FORCE_BUILD=false
BOOST_FORCE_REBUILD=false
BOOST_SKIP=false
TBB_VERSION="2019"
TBB_VERSION_UPDATE="_U9" # Used for source packages...
TBB_VERSION_MIN="2018"
TBB_FORCE_BUILD=false
TBB_FORCE_REBUILD=false
TBB_SKIP=false
OCIO_VERSION="1.1.0"
OCIO_VERSION_MIN="1.0"
OCIO_FORCE_BUILD=false
@@ -669,7 +653,6 @@ while true; do
PYTHON_FORCE_BUILD=true
NUMPY_FORCE_BUILD=true
BOOST_FORCE_BUILD=true
TBB_FORCE_BUILD=true
OCIO_FORCE_BUILD=true
OPENEXR_FORCE_BUILD=true
OIIO_FORCE_BUILD=true
@@ -699,9 +682,6 @@ while true; do
--build-boost)
BOOST_FORCE_BUILD=true; shift; continue
;;
--build-tbb)
TBB_FORCE_BUILD=true; shift; continue
;;
--build-ocio)
OCIO_FORCE_BUILD=true; shift; continue
;;
@@ -748,7 +728,6 @@ while true; do
PYTHON_FORCE_REBUILD=true
NUMPY_FORCE_REBUILD=true
BOOST_FORCE_REBUILD=true
TBB_FORCE_REBUILD=true
OCIO_FORCE_REBUILD=true
OPENEXR_FORCE_REBUILD=true
OIIO_FORCE_REBUILD=true
@@ -776,9 +755,6 @@ while true; do
--force-boost)
BOOST_FORCE_REBUILD=true; shift; continue
;;
--force-tbb)
TBB_FORCE_REBUILD=true; shift; continue
;;
--force-ocio)
OCIO_FORCE_REBUILD=true; shift; continue
;;
@@ -830,9 +806,6 @@ while true; do
--skip-boost)
BOOST_SKIP=true; shift; continue
;;
--skip-tbb)
TBB_SKIP=true; shift; continue
;;
--skip-ocio)
OCIO_SKIP=true; shift; continue
;;
@@ -925,12 +898,9 @@ PYTHON_SOURCE=( "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHO
NUMPY_SOURCE=( "https://github.com/numpy/numpy/releases/download/v$NUMPY_VERSION/numpy-$NUMPY_VERSION.tar.gz" )
_boost_version_nodots=`echo "$BOOST_VERSION" | sed -r 's/\./_/g'`
BOOST_SOURCE=( "https://dl.bintray.com/boostorg/release/$BOOST_VERSION/source/boost_$_boost_version_nodots.tar.bz2" )
BOOST_SOURCE=( "http://sourceforge.net/projects/boost/files/boost/$BOOST_VERSION/boost_$_boost_version_nodots.tar.bz2/download" )
BOOST_BUILD_MODULES="--with-system --with-filesystem --with-thread --with-regex --with-locale --with-date_time --with-wave --with-iostreams --with-python --with-program_options"
TBB_SOURCE=( "https://github.com/oneapi-src/oneTBB/archive/$TBB_VERSION$TBB_VERSION_UPDATE.tar.gz" )
TBB_SOURCE_CMAKE=( "https://raw.githubusercontent.com/wjakob/tbb/master/CMakeLists.txt" )
OCIO_USE_REPO=false
OCIO_SOURCE=( "https://github.com/AcademySoftwareFoundation/OpenColorIO/archive/v$OCIO_VERSION.tar.gz")
#~ OCIO_SOURCE_REPO=( "https://github.com/imageworks/OpenColorIO.git" )
@@ -1041,7 +1011,6 @@ You may also want to build them yourself (optional ones are [between brackets]):
* Python $PYTHON_VERSION_MIN (from $PYTHON_SOURCE).
* [NumPy $NUMPY_VERSION_MIN] (from $NUMPY_SOURCE).
* Boost $BOOST_VERSION_MIN (from $BOOST_SOURCE, modules: $BOOST_BUILD_MODULES).
* TBB $TBB_VERSION_MIN (from $TBB_SOURCE).
* [FFMpeg $FFMPEG_VERSION_MIN (needs libvorbis, libogg, libtheora, libx264, libmp3lame, libxvidcore, libvpx, ...)] (from $FFMPEG_SOURCE).
* [OpenColorIO $OCIO_VERSION_MIN] (from $OCIO_SOURCE).
* ILMBase $OPENEXR_VERSION_MIN (from $OPENEXR_SOURCE).
@@ -1279,10 +1248,8 @@ _update_deps_python() {
clean_Python() {
clean_Numpy
_init_python
if [ -d $_inst ]; then
_update_deps_python
fi
_clean
_update_deps_python
}
compile_Python() {
@@ -1365,10 +1332,8 @@ _update_deps_numpy() {
clean_Numpy() {
_init_numpy
if [ -d $_inst ]; then
_update_deps_numpy
fi
_clean
_update_deps_numpy
}
compile_Numpy() {
@@ -1453,10 +1418,8 @@ _update_deps_boost() {
clean_Boost() {
_init_boost
if [ -d $_inst ]; then
_update_deps_boost
fi
_clean
_update_deps_boost
}
compile_Boost() {
@@ -1521,128 +1484,6 @@ compile_Boost() {
run_ldconfig "boost"
}
# ----------------------------------------------------------------------------
# Build TBB
_init_tbb() {
_src=$SRC/TBB-$TBB_VERSION
_git=false
_inst=$INST/tbb-$TBB_VERSION
_inst_shortcut=$INST/tbb
}
_update_deps_tbb() {
OSD_FORCE_REBUILD=true
OPENVDB_FORCE_REBUILD=true
USD_FORCE_REBUILD=true
OIDN_FORCE_REBUILD=true
if [ "$_is_building" = true ]; then
OSD_FORCE_BUILD=true
OPENVDB_FORCE_BUILD=true
USD_FORCE_BUILD=true
OIDN_FORCE_BUILD=true
fi
}
clean_TBB() {
_init_tbb
if [ -d $_inst ]; then
_update_deps_tbb
fi
_clean
}
compile_TBB() {
if [ "$NO_BUILD" = true ]; then
WARNING "--no-build enabled, TBB will not be compiled!"
return
fi
# To be changed each time we make edits that would modify the compiled result!
tbb_magic=0
_init_tbb
# Clean install if needed!
magic_compile_check tbb-$TBB_VERSION $tbb_magic
if [ $? -eq 1 -o "$TBB_FORCE_REBUILD" = true ]; then
clean_TBB
fi
if [ ! -d $_inst ]; then
INFO "Building TBB-$TBB_VERSION$TBB_VERSION_UPDATE"
_is_building=true
# Rebuild dependencies as well!
_update_deps_tbb
prepare_opt
if [ ! -d $_src ]; then
INFO "Downloading TBB-$TBB_VERSION$TBB_VERSION_UPDATE"
mkdir -p $SRC
download TBB_SOURCE[@] $_src.tar.gz
INFO "Unpacking TBB-$TBB_VERSION$TBB_VERSION_UPDATE"
tar -C $SRC --transform "s,(.*/?)oneTBB[^/]*(.*),\1TBB-$TBB_VERSION\2,x" \
-xf $_src.tar.gz
INFO
# Super-hack: Add some cmake builder to tbb... since they don't even have an install target by default, sic.
download TBB_SOURCE_CMAKE[@] $_src/CMakeLists.txt
cp $_src/build/vs2013/version_string.ver $_src/build/version_string.ver.in
fi
cd $_src
# Always refresh the whole build!
if [ -d cmake_build ]; then
rm -rf cmake_build
fi
mkdir cmake_build
cd cmake_build
cmake_d="-D CMAKE_BUILD_TYPE=Release"
cmake_d="$cmake_d -D CMAKE_PREFIX_PATH=$_inst"
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
cmake_d="$cmake_d -D TBB_BUILD_SHARED=ON"
cmake_d="$cmake_d -D TBB_BUILD_STATIC=OFF"
cmake_d="$cmake_d -D TBB_BUILD_TBBMALLOC=ON"
cmake_d="$cmake_d -D TBB_BUILD_TBBMALLOC_PROXY=OFF"
cmake_d="$cmake_d -D TBB_BUILD_TESTS=OFF"
if file /bin/cp | grep -q '32-bit'; then
cflags="-fPIC -m32 -march=i686"
else
cflags="-fPIC"
fi
cmake $cmake_d -D CMAKE_CXX_FLAGS="$cflags" -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" ..
make -j$THREADS && make install
make clean
if [ -d $_inst ]; then
_create_inst_shortcut
else
ERROR "TBB-$TBB_VERSION$TBB_VERSION_UPDATE failed to compile, exiting"
exit 1
fi
magic_compile_set tbb-$TBB_VERSION $tbb_magic
cd $CWD
INFO "Done compiling TBB-$TBB_VERSION$TBB_VERSION_UPDATE!"
_is_building=false
else
INFO "Own TBB-$TBB_VERSION$TBB_VERSION_UPDATE is up to date, nothing to do!"
INFO "If you want to force rebuild of this lib, use the --force-tbb option."
fi
run_ldconfig "tbb"
}
# ----------------------------------------------------------------------------
# Build OCIO
@@ -1663,10 +1504,8 @@ _update_deps_ocio() {
clean_OCIO() {
_init_ocio
if [ -d $_inst ]; then
_update_deps_ocio
fi
_clean
_update_deps_ocio
}
compile_OCIO() {
@@ -1778,7 +1617,7 @@ compile_OCIO() {
_init_openexr() {
_src=$SRC/OpenEXR-$OPENEXR_VERSION
_git=false
_inst=$INST/openexr-$OPENEXR_VERSION
_inst=$_openexr_inst
_inst_shortcut=$INST/openexr
}
@@ -1793,10 +1632,8 @@ _update_deps_openexr() {
clean_OPENEXR() {
_init_openexr
if [ -d $_inst ]; then
_update_deps_openexr
fi
_clean
_update_deps_openexr
}
compile_OPENEXR() {
@@ -1814,6 +1651,7 @@ compile_OPENEXR() {
clean_OPENEXR
fi
_openexr_inst=$INST/openexr-$OPENEXR_VERSION
PRINT ""
_init_openexr
@@ -1859,7 +1697,7 @@ compile_OPENEXR() {
mkdir build
cd build
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_openexr_inst"
cmake_d="$cmake_d -D CMAKE_INSTALL_DOCDIR=/dev/null" # Hack, there is no option to disable that currently...
cmake_d="$cmake_d -D BUILD_SHARED_LIBS=ON"
cmake_d="$cmake_d -D BUILD_TESTING=OFF"
@@ -1921,10 +1759,8 @@ _update_deps_oiio() {
clean_OIIO() {
_init_oiio
if [ -d $_inst ]; then
_update_deps_oiio
fi
_clean
_update_deps_oiio
}
compile_OIIO() {
@@ -2076,10 +1912,8 @@ _update_deps_llvm() {
clean_LLVM() {
_init_llvm
if [ -d $_inst ]; then
_update_deps_llvm
fi
_clean
_update_deps_llvm
}
compile_LLVM() {
@@ -2185,10 +2019,8 @@ _update_deps_osl() {
clean_OSL() {
_init_osl
if [ -d $_inst ]; then
_update_deps_osl
fi
_clean
_update_deps_osl
}
compile_OSL() {
@@ -2330,10 +2162,8 @@ _update_deps_osd() {
clean_OSD() {
_init_osd
if [ -d $_inst ]; then
_update_deps_osd
fi
_clean
_update_deps_osd
}
compile_OSD() {
@@ -2392,9 +2222,6 @@ compile_OSD() {
mkdir build
cd build
if [ -d $INST/tbb ]; then
cmake_d="$cmake_d $cmake_d -D TBB_LOCATION=$INST/tbb"
fi
cmake_d="-D CMAKE_BUILD_TYPE=Release"
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
# ptex is only needed when nicholas bishop is ready
@@ -2447,10 +2274,8 @@ _update_deps_blosc() {
clean_BLOSC() {
_init_blosc
if [ -d $_inst ]; then
_update_deps_blosc
fi
_clean
_update_deps_blosc
}
compile_BLOSC() {
@@ -2544,10 +2369,8 @@ _update_deps_openvdb() {
clean_OPENVDB() {
_init_openvdb
if [ -d $_inst ]; then
_update_deps_openvdb
fi
_clean
_update_deps_openvdb
}
compile_OPENVDB() {
@@ -2606,9 +2429,6 @@ compile_OPENVDB() {
if [ -d $INST/boost ]; then
make_d="$make_d BOOST_INCL_DIR=$INST/boost/include BOOST_LIB_DIR=$INST/boost/lib"
fi
if [ -d $INST/tbb ]; then
make_d="$make_d TBB_ROOT=$INST/tbb TBB_USE_STATIC_LIBS=OFF"
fi
if [ "$_with_built_openexr" = true ]; then
make_d="$make_d ILMBASE_INCL_DIR=$INST/openexr/include ILMBASE_LIB_DIR=$INST/openexr/lib"
@@ -2662,10 +2482,8 @@ _update_deps_alembic() {
clean_ALEMBIC() {
_init_alembic
if [ -d $_inst ]; then
_update_deps_alembic
fi
_clean
_update_deps_alembic
}
compile_ALEMBIC() {
@@ -2767,10 +2585,8 @@ _update_deps_usd() {
clean_USD() {
_init_usd
if [ -d $_inst ]; then
_update_deps_usd
fi
_clean
_update_deps_usd
}
compile_USD() {
@@ -2814,10 +2630,6 @@ compile_USD() {
if [ -d $INST/boost ]; then
cmake_d="$cmake_d $cmake_d -D BOOST_ROOT=$INST/boost"
fi
if [ -d $INST/tbb ]; then
cmake_d="$cmake_d $cmake_d -D TBB_ROOT_DIR=$INST/tbb"
fi
cmake_d="$cmake_d -DPXR_SET_INTERNAL_NAMESPACE=usdBlender"
cmake_d="$cmake_d -DPXR_ENABLE_PYTHON_SUPPORT=OFF"
cmake_d="$cmake_d -DPXR_BUILD_IMAGING=OFF"
@@ -2866,10 +2678,8 @@ _update_deps_collada() {
clean_OpenCOLLADA() {
_init_opencollada
if [ -d $_inst ]; then
_update_deps_collada
fi
_clean
_update_deps_collada
}
compile_OpenCOLLADA() {
@@ -2972,10 +2782,8 @@ _update_deps_embree() {
clean_Embree() {
_init_embree
if [ -d $_inst ]; then
_update_deps_embree
fi
_clean
_update_deps_embree
}
compile_Embree() {
@@ -3081,10 +2889,8 @@ _update_deps_oidn() {
clean_oidn() {
_init_oidn
if [ -d $_inst ]; then
_update_deps_oidn
fi
_clean
_update_deps_oidn
}
compile_OIDN() {
@@ -3146,10 +2952,6 @@ compile_OIDN() {
cmake_d="$cmake_d -D WITH_TEST=OFF"
cmake_d="$cmake_d -D OIDN_STATIC_LIB=ON"
if [ -d $INST/tbb ]; then
make_d="$make_d TBB_ROOT=$INST/tbb"
fi
cmake $cmake_d ../
make -j$THREADS && make install
@@ -3190,10 +2992,8 @@ _update_deps_ffmpeg() {
clean_FFmpeg() {
_init_ffmpeg
if [ -d $_inst ]; then
_update_deps_ffmpeg
fi
_clean
_update_deps_ffmpeg
}
compile_FFmpeg() {
@@ -3319,10 +3119,8 @@ _update_deps_xr_openxr_sdk() {
clean_XR_OpenXR_SDK() {
_init_xr_openxr_sdk
if [ -d $_inst ]; then
_update_deps_xr_openxr_sdk
fi
_clean
_update_deps_xr_openxr_sdk
}
compile_XR_OpenXR_SDK() {
@@ -3336,7 +3134,7 @@ compile_XR_OpenXR_SDK() {
_init_xr_openxr_sdk
# Clean install if needed!
magic_compile_check xr-openxr-$XR_OPENXR_VERSION $xr_openxr_magic
magic_compile_check xr-openxr-$OPENXR_VERSION $xr_openxr_magic
if [ $? -eq 1 -o "$XR_OPENXR_FORCE_REBUILD" = true ]; then
clean_XR_OpenXR_SDK
fi
@@ -3513,7 +3311,7 @@ install_DEB() {
THEORA_DEV="libtheora-dev"
_packages="gawk cmake cmake-curses-gui build-essential libjpeg-dev libpng-dev libtiff-dev \
git libfreetype6-dev libx11-dev flex bison libxxf86vm-dev \
git libfreetype6-dev libx11-dev flex bison libtbb-dev libxxf86vm-dev \
libxcursor-dev libxi-dev wget libsqlite3-dev libxrandr-dev libxinerama-dev \
libbz2-dev libncurses5-dev libssl-dev liblzma-dev libreadline-dev \
libopenal-dev libglew-dev yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV \
@@ -3722,23 +3520,6 @@ install_DEB() {
fi
PRINT ""
if [ "$TBB_SKIP" = true ]; then
WARNING "Skipping TBB installation, as requested..."
elif [ "$TBB_FORCE_BUILD" = true ]; then
INFO "Forced TBB building, as requested..."
compile_TBB
else
check_package_version_ge_DEB libtbb-dev $TBB_VERSION_MIN
if [ $? -eq 0 ]; then
install_packages_DEB libtbb-dev
clean_TBB
else
compile_TBB
fi
fi
PRINT ""
if [ "$OCIO_SKIP" = true ]; then
WARNING "Skipping OpenColorIO installation, as requested..."
@@ -4175,7 +3956,7 @@ install_RPM() {
THEORA_USE=true
if [ "$RPM" = "FEDORA" -o "$RPM" = "RHEL" ]; then
_packages="$_packages freetype-devel"
_packages="$_packages freetype-devel tbb-devel"
if [ "$WITH_JACK" = true ]; then
_packages="$_packages jack-audio-connection-kit-devel"
@@ -4216,6 +3997,17 @@ install_RPM() {
PRINT ""
install_packages_RPM $_packages
PRINT ""
# Install TBB on openSUSE, from temporary repo
check_package_RPM tbb-devel
if [ $? -eq 0 ]; then
install_packages_RPM tbb-devel
else
$SUDO zypper ar -f http://download.opensuse.org/repositories/devel:/libraries:/c_c++/openSUSE_$_suse_rel/devel:libraries:c_c++.repo
$SUDO zypper -n --gpg-auto-import-keys install tbb-devel
$SUDO zypper rr devel_libraries_c_c++
fi
PRINT ""
X264_DEV="libx264-devel"
check_package_version_ge_RPM $X264_DEV $X264_VERSION_MIN
@@ -4351,23 +4143,6 @@ install_RPM() {
fi
PRINT ""
if [ "$TBB_SKIP" = true ]; then
WARNING "Skipping TBB installation, as requested..."
elif [ "$TBB_FORCE_BUILD" = true ]; then
INFO "Forced TBB building, as requested..."
compile_TBB
else
check_package_version_ge_RPM tbb-devel $TBB_VERSION_MIN
if [ $? -eq 0 ]; then
install_packages_RPM tbb-devel
clean_TBB
else
compile_TBB
fi
fi
PRINT ""
if [ "$OCIO_SKIP" = true ]; then
WARNING "Skipping OpenColorIO installation, as requested..."
@@ -4724,7 +4499,7 @@ install_ARCH() {
_packages="$BASE_DEVEL git cmake \
libxi libxcursor libxrandr libxinerama glew libpng libtiff wget openal \
$OPENJPEG_DEV $VORBIS_DEV $OGG_DEV $THEORA_DEV yasm sdl fftw \
$OPENJPEG_DEV $VORBIS_DEV $OGG_DEV $THEORA_DEV yasm sdl fftw intel-tbb \
libxml2 yaml-cpp tinyxml python-requests jemalloc"
OPENJPEG_USE=true
@@ -4863,23 +4638,6 @@ install_ARCH() {
fi
PRINT ""
if [ "$TBB_SKIP" = true ]; then
WARNING "Skipping TBB installation, as requested..."
elif [ "$TBB_FORCE_BUILD" = true ]; then
INFO "Forced TBB building, as requested..."
compile_TBB
else
check_package_version_ge_ARCH intel-tbb $TBB_VERSION_MIN
if [ $? -eq 0 ]; then
install_packages_ARCH intel-tbb
clean_TBB
else
compile_TBB
fi
fi
PRINT ""
if [ "$OCIO_SKIP" = true ]; then
WARNING "Skipping OpenColorIO installation, as requested..."
@@ -5174,10 +4932,15 @@ install_OTHER() {
fi
PRINT ""
_do_compile_python=false
if [ "$PYTHON_SKIP" = true ]; then
WARNING "Skipping Python/NumPy installation, as requested..."
elif [ "$PYTHON_FORCE_BUILD" = true ]; then
INFO "Forced Python/NumPy building, as requested..."
_do_compile_python=true
fi
if [ "$_do_compile_python" = true ]; then
compile_Python
PRINT ""
if [ "$NUMPY_SKIP" = true ]; then
@@ -5197,15 +4960,6 @@ install_OTHER() {
fi
PRINT ""
if [ "$TBB_SKIP" = true ]; then
WARNING "Skipping TBB installation, as requested..."
elif [ "$TBB_FORCE_BUILD" = true ]; then
INFO "Forced TBB building, as requested..."
compile_TBB
fi
PRINT ""
if [ "$OCIO_SKIP" = true ]; then
WARNING "Skipping OpenColorIO installation, as requested..."
@@ -5235,10 +4989,16 @@ install_OTHER() {
PRINT ""
have_llvm=false
_do_compile_llvm=false
if [ "$LLVM_SKIP" = true ]; then
WARNING "Skipping LLVM installation, as requested (this also implies skipping OSL!)..."
elif [ "$LLVM_FORCE_BUILD" = true ]; then
INFO "Forced LLVM building, as requested..."
_do_compile_llvm=true
fi
if [ "$_do_compile_llvm" = true ]; then
PRINT ""
compile_LLVM
have_llvm=true
LLVM_VERSION_FOUND=$LLVM_VERSION
@@ -5246,10 +5006,15 @@ install_OTHER() {
PRINT ""
_do_compile_osl=false
if [ "$OSL_SKIP" = true ]; then
WARNING "Skipping OpenShadingLanguage installation, as requested..."
elif [ "$OSL_FORCE_BUILD" = true ]; then
INFO "Forced OpenShadingLanguage building, as requested..."
_do_compile_osl=true
fi
if [ "$_do_compile_osl" = true ]; then
if [ "$have_llvm" = true ]; then
PRINT ""
compile_OSL
@@ -5260,40 +5025,66 @@ install_OTHER() {
PRINT ""
_do_compile_osd=false
if [ "$OSD_SKIP" = true ]; then
WARNING "Skipping OpenSubdiv installation, as requested..."
elif [ "$OSD_FORCE_BUILD" = true ]; then
INFO "Forced OpenSubdiv building, as requested..."
_do_compile_osd=true
fi
if [ "$_do_compile_osd" = true ]; then
PRINT ""
compile_OSD
fi
if [ "$WITH_OPENCOLLADA" = true ]; then
_do_compile_collada=false
PRINT ""
if [ "$OPENCOLLADA_SKIP" = true ]; then
WARNING "Skipping OpenCOLLADA installation, as requested..."
elif [ "$OPENCOLLADA_FORCE_BUILD" = true ]; then
INFO "Forced OpenCollada building, as requested..."
_do_compile_collada=true
fi
if [ "$_do_compile_collada" = true ]; then
PRINT ""
compile_OpenCOLLADA
fi
fi
if [ "$WITH_EMBREE" = true ]; then
_do_compile_embree=false
PRINT ""
if [ "$EMBREE_SKIP" = true ]; then
WARNING "Skipping Embree installation, as requested..."
elif [ "$EMBREE_FORCE_BUILD" = true ]; then
INFO "Forced Embree building, as requested..."
_do_compile_embree=true
fi
if [ "$_do_compile_embree" = true ]; then
PRINT ""
compile_Embree
fi
fi
if [ "$WITH_OIDN" = true ]; then
_do_compile_oidn=false
PRINT ""
if [ "$OIDN_SKIP" = true ]; then
WARNING "Skipping OpenImgeDenoise installation, as requested..."
elif [ "$OIDN_FORCE_BUILD" = true ]; then
INFO "Forced OpenImageDenoise building, as requested..."
_do_compile_oidn=true
else
# No package currently!
_do_compile_oidn=true
fi
if [ "$_do_compile_oidn" = true ]; then
compile_OIDN
fi
fi
@@ -5312,6 +5103,9 @@ install_OTHER() {
elif [ "$XR_OPENXR_FORCE_BUILD" = true ]; then
INFO "Forced OpenXR-SDK building, as requested..."
compile_XR_OpenXR_SDK
else
# No package currently!
compile_XR_OpenXR_SDK
fi
}
@@ -5397,7 +5191,7 @@ print_info() {
PRINT ""
PRINT "If you're using CMake add this to your configuration flags:"
_buildargs="-U *SNDFILE* -U PYTHON* -U *BOOST* -U *Boost* -U *TBB*"
_buildargs="-U *SNDFILE* -U PYTHON* -U *BOOST* -U *Boost*"
_buildargs="$_buildargs -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES*"
_buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -U *USD*"
@@ -5422,12 +5216,6 @@ print_info() {
_buildargs="$_buildargs $_1 $_2"
fi
if [ -d $INST/tbb ]; then
_1="-D TBB_ROOT_DIR=$INST/tbb"
PRINT " $_1"
_buildargs="$_buildargs $_1"
fi
if [ "$OCIO_SKIP" = false ]; then
_1="-D WITH_OPENCOLORIO=ON"
PRINT " $_1"

View File

@@ -0,0 +1,13 @@
diff -Naur external_openal_original/CMakeLists.txt external_openal/CMakeLists.txt
--- external_openal_original/CMakeLists.txt 2016-01-24 20:12:39 -0700
+++ external_openal/CMakeLists.txt 2018-06-02 12:16:52 -0600
@@ -885,7 +885,8 @@
OPTION(ALSOFT_REQUIRE_MMDEVAPI "Require MMDevApi backend" OFF)
IF(HAVE_WINDOWS_H)
# Check MMSystem backend
- CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0502)
+ set(CMAKE_REQUIRED_FLAGS "-D_WIN32_WINNT=0x0502")
+ CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H)
IF(HAVE_MMSYSTEM_H)
CHECK_SHARED_FUNCTION_EXISTS(waveOutOpen "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM)
IF(HAVE_LIBWINMM)

View File

@@ -1,12 +1,13 @@
diff -Naur orig/Makefile external_pthreads/Makefile
--- orig/Makefile 2018-08-08 04:47:40 -0600
+++ external_pthreads/Makefile 2020-05-09 11:20:28 -0600
@@ -185,7 +185,7 @@
@ $(MAKE) /E /nologo XCFLAGS="/MTd" EHFLAGS="$(VSEFLAGSD) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_SEH pthreadVSE$(PTW32_VER_DEBUG).inlined_static_stamp
--- 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
VC-static:
- @ $(MAKE) /E /nologo XCFLAGS="/MT" EHFLAGS="$(VCFLAGS) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER).inlined_static_stamp
+ @ $(MAKE) /E /nologo XCFLAGS="/MD" EHFLAGS="$(VCFLAGS) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER).inlined_static_stamp
VC-static-debug:
@ $(MAKE) /E /nologo XCFLAGS="/MTd" EHFLAGS="$(VCFLAGSD) /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED" CLEANUP=__PTW32_CLEANUP_C pthreadVC$(PTW32_VER_DEBUG).inlined_static_stamp
+#if _MSC_VER >= 1900
+# define HAVE_STRUCT_TIMESPEC 1
+#endif
+
#if defined(_UWIN)
# define HAVE_STRUCT_TIMESPEC 1
# define HAVE_SIGNAL_H 1

View File

@@ -0,0 +1,22 @@
--- x264-snapshot-20180811-2245-stable\configure 2018-08-11 14:45:05 -0600
+++ external_x264\configure 2018-08-11 23:51:35 -0600
@@ -396,7 +396,7 @@
# list of all preprocessor HAVE values we can define
CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F SWSCALE \
LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH X86_INLINE_ASM AS_FUNC INTEL_DISPATCHER \
- MSA MMAP WINRT VSX ARM_INLINE_ASM STRTOK_R BITDEPTH8 BITDEPTH10"
+ MSA MMAP WINRT VSX ARM_INLINE_ASM BITDEPTH8 BITDEPTH10"
# parse options
@@ -1071,10 +1071,6 @@
define HAVE_LOG2F
fi
-if cc_check 'string.h' '' 'strtok_r(0, 0, 0);' ; then
- define HAVE_STRTOK_R
-fi
-
if [ "$SYS" != "WINDOWS" ] && cpp_check "sys/mman.h unistd.h" "" "defined(MAP_PRIVATE)"; then
define HAVE_MMAP
fi

View File

@@ -104,7 +104,6 @@ FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}-${_openexr_libs_ver} ${COMPONENT}
NAMES_PER_DIR
HINTS
${_openexr_SEARCH_DIRS}
PATH_SUFFIXES

View File

@@ -43,7 +43,6 @@ FIND_PATH(USD_INCLUDE_DIR
FIND_LIBRARY(USD_LIBRARY
NAMES
usd_m usd_ms
NAMES_PER_DIR
HINTS
${_usd_SEARCH_DIRS}
PATH_SUFFIXES

View File

@@ -52,7 +52,6 @@ set(WITH_OPENVDB OFF CACHE BOOL "" FORCE)
set(WITH_QUADRIFLOW OFF CACHE BOOL "" FORCE)
set(WITH_SDL OFF CACHE BOOL "" FORCE)
set(WITH_TBB OFF CACHE BOOL "" FORCE)
set(WITH_USD OFF CACHE BOOL "" FORCE)
if(UNIX AND NOT APPLE)
set(WITH_GHOST_XDND OFF CACHE BOOL "" FORCE)

View File

@@ -57,7 +57,6 @@ if(EXISTS ${LIBDIR})
set(BOOST_ROOT ${LIBDIR}/boost)
set(BOOST_LIBRARYDIR ${LIBDIR}/boost/lib)
set(Boost_NO_SYSTEM_PATHS ON)
set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
endif()
if(WITH_STATIC_LIBS)

View File

@@ -190,7 +190,7 @@ if(MSVC_VERSION GREATER 1914 AND NOT MSVC_CLANG)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /JMC")
endif()
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /SUBSYSTEM:CONSOLE /STACK:2097152")
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ")
set(PLATFORM_LINKFLAGS_RELEASE "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib")
set(PLATFORM_LINKFLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG} /IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib")

View File

@@ -51,7 +51,7 @@ PROJECT_BRIEF =
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory.
PROJECT_LOGO = ../../release/freedesktop/icons/scalable/apps/blender.svg
PROJECT_LOGO = ../../release/freedesktop/icons/48x48/apps/blender.png
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is
@@ -1720,7 +1720,7 @@ COMPACT_LATEX = NO
# The default value is: a4.
# This tag requires that the tag GENERATE_LATEX is set to YES.
PAPER_TYPE = a4
PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
# that should be included in the LaTeX output. The package can be specified just

View File

@@ -1,2 +1,2 @@
Sphinx==3.0.3
sphinx_rtd_theme==0.5.0rc1
Sphinx==1.8.5
sphinx_rtd_theme==0.4.3

View File

@@ -253,13 +253,7 @@ Registering a class with Blender results in the class definition being loaded in
where it becomes available alongside existing functionality.
Once this class is loaded you can access it from :mod:`bpy.types`,
using the ``bl_idname`` rather than the classes original name.
.. note::
There are some exceptions to this for class names which aren't guarantee to be unique.
In this case use: :func:`bpy.types.Struct.bl_rna_get_subclass`.
using the bl_idname rather than the classes original name.
When loading a class, Blender performs sanity checks making sure all required properties and functions are found,
that properties have the correct type, and that functions have the right number of arguments.

View File

@@ -492,11 +492,6 @@ if _BPY_PROP_COLLECTION_FAKE:
else:
_BPY_PROP_COLLECTION_ID = "collection"
if _BPY_STRUCT_FAKE:
bpy_struct = bpy.types.bpy_struct
else:
bpy_struct = None
def escape_rst(text):
""" Escape plain text which may contain characters used by RST.
@@ -517,7 +512,7 @@ def is_struct_seq(value):
def undocumented_message(module_name, type_name, identifier):
return "Undocumented, consider `contributing <https://developer.blender.org/T51061>`__."
return "Undocumented `contribute <https://developer.blender.org/T51061>`"
def range_str(val):
@@ -1448,7 +1443,7 @@ def pyrna2sphinx(basepath):
if _BPY_STRUCT_FAKE:
descr_items = [
(key, descr) for key, descr in sorted(bpy_struct.__dict__.items())
(key, descr) for key, descr in sorted(bpy.types.Struct.__bases__[0].__dict__.items())
if not key.startswith("__")
]
@@ -1464,6 +1459,9 @@ def pyrna2sphinx(basepath):
for identifier, py_prop in base.get_py_properties():
lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier))
for identifier, py_prop in base.get_py_properties():
lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier))
if lines:
fw(".. rubric:: Inherited Properties\n\n")
@@ -1487,8 +1485,6 @@ def pyrna2sphinx(basepath):
lines.append(" * :class:`%s.%s`\n" % (base.identifier, func.identifier))
for identifier, py_func in base.get_py_functions():
lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier))
for identifier, py_func in base.get_py_c_functions():
lines.append(" * :class:`%s.%s`\n" % (base.identifier, identifier))
if lines:
fw(".. rubric:: Inherited Functions\n\n")
@@ -1576,7 +1572,7 @@ def pyrna2sphinx(basepath):
# write fake classes
if _BPY_STRUCT_FAKE:
class_value = bpy_struct
class_value = bpy.types.Struct.__bases__[0]
fake_bpy_type(
"bpy.types", class_value, _BPY_STRUCT_FAKE,
"built-in base class for all classes in bpy.types.", use_subclasses=True,
@@ -1716,7 +1712,7 @@ class PatchedPythonDomain(PythonDomain):
fw("def setup(app):\n")
fw(" app.add_stylesheet('css/theme_overrides.css')\n")
fw(" app.add_domain(PatchedPythonDomain, override=True)\n\n")
fw(" app.override_domain(PatchedPythonDomain)\n\n")
file.close()

View File

@@ -1,3 +1,3 @@
#define MANTA_GIT_VERSION "commit b61bf9efa7a1d8ca98635076a7e9f2c4dacb2914"
#define MANTA_GIT_VERSION "commit b4a2742bd743e2913fba94dd35846042e2650212"

View File

@@ -469,7 +469,6 @@ template<class S> class ParticleSystem : public ParticleBase {
const int integrationMode,
const bool deleteInObstacle = true,
const bool stopInObstacle = true,
const bool skipNew = false,
const ParticleDataImpl<int> *ptype = NULL,
const int exclude = 0);
static PyObject *_W_9(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
@@ -487,20 +486,13 @@ template<class S> class ParticleSystem : public ParticleBase {
const int integrationMode = _args.get<int>("integrationMode", 2, &_lock);
const bool deleteInObstacle = _args.getOpt<bool>("deleteInObstacle", 3, true, &_lock);
const bool stopInObstacle = _args.getOpt<bool>("stopInObstacle", 4, true, &_lock);
const bool skipNew = _args.getOpt<bool>("skipNew", 5, false, &_lock);
const ParticleDataImpl<int> *ptype = _args.getPtrOpt<ParticleDataImpl<int>>(
"ptype", 6, NULL, &_lock);
const int exclude = _args.getOpt<int>("exclude", 7, 0, &_lock);
"ptype", 5, NULL, &_lock);
const int exclude = _args.getOpt<int>("exclude", 6, 0, &_lock);
pbo->_args.copy(_args);
_retval = getPyNone();
pbo->advectInGrid(flags,
vel,
integrationMode,
deleteInObstacle,
stopInObstacle,
skipNew,
ptype,
exclude);
pbo->advectInGrid(
flags, vel, integrationMode, deleteInObstacle, stopInObstacle, ptype, exclude);
pbo->_args.check();
}
pbFinalizePlugin(pbo->getParent(), "ParticleSystem::advectInGrid", !noTiming);
@@ -1871,7 +1863,6 @@ template<class S> struct _GridAdvectKernel : public KernelBase {
const Real dt,
const bool deleteInObstacle,
const bool stopInObstacle,
const bool skipNew,
const ParticleDataImpl<int> *ptype,
const int exclude,
std::vector<Vec3> &u)
@@ -1882,7 +1873,6 @@ template<class S> struct _GridAdvectKernel : public KernelBase {
dt(dt),
deleteInObstacle(deleteInObstacle),
stopInObstacle(stopInObstacle),
skipNew(skipNew),
ptype(ptype),
exclude(exclude),
u(u)
@@ -1895,13 +1885,11 @@ template<class S> struct _GridAdvectKernel : public KernelBase {
const Real dt,
const bool deleteInObstacle,
const bool stopInObstacle,
const bool skipNew,
const ParticleDataImpl<int> *ptype,
const int exclude,
std::vector<Vec3> &u) const
{
if ((p[idx].flag & ParticleBase::PDELETE) || (ptype && ((*ptype)[idx] & exclude)) ||
(skipNew && (p[idx].flag & ParticleBase::PNEW))) {
if ((p[idx].flag & ParticleBase::PDELETE) || (ptype && ((*ptype)[idx] & exclude))) {
u[idx] = 0.;
return;
}
@@ -1922,7 +1910,7 @@ template<class S> struct _GridAdvectKernel : public KernelBase {
void operator()(const tbb::blocked_range<IndexInt> &__r) const
{
for (IndexInt idx = __r.begin(); idx != (IndexInt)__r.end(); idx++)
op(idx, p, vel, flags, dt, deleteInObstacle, stopInObstacle, skipNew, ptype, exclude, u);
op(idx, p, vel, flags, dt, deleteInObstacle, stopInObstacle, ptype, exclude, u);
}
void run()
{
@@ -1934,7 +1922,6 @@ template<class S> struct _GridAdvectKernel : public KernelBase {
const Real dt;
const bool deleteInObstacle;
const bool stopInObstacle;
const bool skipNew;
const ParticleDataImpl<int> *ptype;
const int exclude;
std::vector<Vec3> &u;
@@ -1946,7 +1933,6 @@ template<class S> struct GridAdvectKernel : public KernelBase {
const Real dt,
const bool deleteInObstacle,
const bool stopInObstacle,
const bool skipNew,
const ParticleDataImpl<int> *ptype,
const int exclude)
: KernelBase(p.size()),
@@ -1957,7 +1943,6 @@ template<class S> struct GridAdvectKernel : public KernelBase {
dt,
deleteInObstacle,
stopInObstacle,
skipNew,
ptype,
exclude,
u),
@@ -1967,7 +1952,6 @@ template<class S> struct GridAdvectKernel : public KernelBase {
dt(dt),
deleteInObstacle(deleteInObstacle),
stopInObstacle(stopInObstacle),
skipNew(skipNew),
ptype(ptype),
exclude(exclude),
u((size))
@@ -2017,21 +2001,16 @@ template<class S> struct GridAdvectKernel : public KernelBase {
return stopInObstacle;
}
typedef bool type5;
inline const bool &getArg6()
{
return skipNew;
}
typedef bool type6;
inline const ParticleDataImpl<int> *getArg7()
inline const ParticleDataImpl<int> *getArg6()
{
return ptype;
}
typedef ParticleDataImpl<int> type7;
inline const int &getArg8()
typedef ParticleDataImpl<int> type6;
inline const int &getArg7()
{
return exclude;
}
typedef int type8;
typedef int type7;
void runMessage()
{
debMsg("Executing kernel GridAdvectKernel ", 3);
@@ -2046,7 +2025,6 @@ template<class S> struct GridAdvectKernel : public KernelBase {
const Real dt;
const bool deleteInObstacle;
const bool stopInObstacle;
const bool skipNew;
const ParticleDataImpl<int> *ptype;
const int exclude;
std::vector<Vec3> u;
@@ -2217,7 +2195,6 @@ void ParticleSystem<S>::advectInGrid(const FlagGrid &flags,
const int integrationMode,
const bool deleteInObstacle,
const bool stopInObstacle,
const bool skipNew,
const ParticleDataImpl<int> *ptype,
const int exclude)
{
@@ -2231,15 +2208,8 @@ void ParticleSystem<S>::advectInGrid(const FlagGrid &flags,
}
// update positions
GridAdvectKernel<S> kernel(mData,
vel,
flags,
getParent()->getDt(),
deleteInObstacle,
stopInObstacle,
skipNew,
ptype,
exclude);
GridAdvectKernel<S> kernel(
mData, vel, flags, getParent()->getDt(), deleteInObstacle, stopInObstacle, ptype, exclude);
integratePointSet(kernel, integrationMode);
if (!deleteInObstacle) {
@@ -2468,15 +2438,15 @@ template<class S> void ParticleSystem<S>::compress()
//! insert buffered positions as new particles, update additional particle data
template<class S> void ParticleSystem<S>::insertBufferedParticles()
{
// clear new flag everywhere
for (IndexInt i = 0; i < (IndexInt)mData.size(); ++i)
mData[i].flag &= ~PNEW;
if (mNewBufferPos.size() == 0)
return;
IndexInt newCnt = mData.size();
resizeAll(newCnt + mNewBufferPos.size());
// clear new flag everywhere
for (IndexInt i = 0; i < (IndexInt)mData.size(); ++i)
mData[i].flag &= ~PNEW;
for (IndexInt i = 0; i < (IndexInt)mNewBufferPos.size(); ++i) {
int flag = (mNewBufferFlag.size() > 0) ? mNewBufferFlag[i] : 0;
// note, other fields are not initialized here...

View File

@@ -982,14 +982,9 @@ void flipSampleSecondaryParticles(const std::string mode,
const Real c_b,
const Real k_ta,
const Real k_wc,
const Real dt = 0,
const Real dt,
const int itype = FlagGrid::TypeFluid)
{
float timestep = dt;
if (dt <= 0)
timestep = flags.getParent()->getDt();
if (mode == "single") {
knFlipSampleSecondaryParticles(flags,
v,
@@ -1006,7 +1001,7 @@ void flipSampleSecondaryParticles(const std::string mode,
c_b,
k_ta,
k_wc,
timestep,
dt,
itype);
}
else if (mode == "multiple") {
@@ -1025,7 +1020,7 @@ void flipSampleSecondaryParticles(const std::string mode,
c_b,
k_ta,
k_wc,
timestep,
dt,
itype);
}
else {
@@ -1058,7 +1053,7 @@ static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
const Real c_b = _args.get<Real>("c_b", 13, &_lock);
const Real k_ta = _args.get<Real>("k_ta", 14, &_lock);
const Real k_wc = _args.get<Real>("k_wc", 15, &_lock);
const Real dt = _args.getOpt<Real>("dt", 16, 0, &_lock);
const Real dt = _args.get<Real>("dt", 16, &_lock);
const int itype = _args.getOpt<int>("itype", 17, FlagGrid::TypeFluid, &_lock);
_retval = getPyNone();
flipSampleSecondaryParticles(mode,
@@ -1696,20 +1691,13 @@ void flipUpdateSecondaryParticles(const std::string mode,
const Real k_d,
const Real c_s,
const Real c_b,
const Real dt = 0,
bool scale = true,
const Real dt,
const int exclude = ParticleBase::PTRACER,
const int antitunneling = 0,
const int itype = FlagGrid::TypeFluid)
{
float gridScale = (scale) ? flags.getParent()->getDx() : 1;
Vec3 g = gravity / gridScale;
float timestep = dt;
if (dt <= 0)
timestep = flags.getParent()->getDt();
Vec3 g = gravity / flags.getDx();
if (mode == "linear") {
knFlipUpdateSecondaryParticlesLinear(pts_sec,
v_sec,
@@ -1723,7 +1711,7 @@ void flipUpdateSecondaryParticles(const std::string mode,
k_d,
c_s,
c_b,
timestep,
dt,
exclude,
antitunneling);
}
@@ -1741,7 +1729,7 @@ void flipUpdateSecondaryParticles(const std::string mode,
k_d,
c_s,
c_b,
timestep,
dt,
exclude,
antitunneling,
itype);
@@ -1776,11 +1764,10 @@ static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
const Real k_d = _args.get<Real>("k_d", 11, &_lock);
const Real c_s = _args.get<Real>("c_s", 12, &_lock);
const Real c_b = _args.get<Real>("c_b", 13, &_lock);
const Real dt = _args.getOpt<Real>("dt", 14, 0, &_lock);
bool scale = _args.getOpt<bool>("scale", 15, true, &_lock);
const int exclude = _args.getOpt<int>("exclude", 16, ParticleBase::PTRACER, &_lock);
const int antitunneling = _args.getOpt<int>("antitunneling", 17, 0, &_lock);
const int itype = _args.getOpt<int>("itype", 18, FlagGrid::TypeFluid, &_lock);
const Real dt = _args.get<Real>("dt", 14, &_lock);
const int exclude = _args.getOpt<int>("exclude", 15, ParticleBase::PTRACER, &_lock);
const int antitunneling = _args.getOpt<int>("antitunneling", 16, 0, &_lock);
const int itype = _args.getOpt<int>("itype", 17, FlagGrid::TypeFluid, &_lock);
_retval = getPyNone();
flipUpdateSecondaryParticles(mode,
pts_sec,
@@ -1797,7 +1784,6 @@ static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
c_s,
c_b,
dt,
scale,
exclude,
antitunneling,
itype);

View File

@@ -21,7 +21,7 @@
#define __WCWIDTH_H__
#ifndef __cplusplus
# if defined(__APPLE__) || defined(__NetBSD__)
# if defined(__APPLE__)
/* The <uchar.h> standard header is missing on macOS. */
#include <stddef.h>
typedef unsigned int char32_t;

View File

@@ -82,8 +82,8 @@ class CyclesRender(bpy.types.RenderEngine):
def render(self, depsgraph):
engine.render(self, depsgraph)
def bake(self, depsgraph, obj, pass_type, pass_filter, width, height):
engine.bake(self, depsgraph, obj, pass_type, pass_filter, width, height)
def bake(self, depsgraph, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result):
engine.bake(self, depsgraph, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result)
# viewport render
def view_update(self, context, depsgraph):

View File

@@ -168,11 +168,11 @@ def render(engine, depsgraph):
_cycles.render(engine.session, depsgraph.as_pointer())
def bake(engine, depsgraph, obj, pass_type, pass_filter, width, height):
def bake(engine, depsgraph, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result):
import _cycles
session = getattr(engine, "session", None)
if session is not None:
_cycles.bake(engine.session, depsgraph.as_pointer(), obj.as_pointer(), pass_type, pass_filter, width, height)
_cycles.bake(engine.session, depsgraph.as_pointer(), obj.as_pointer(), pass_type, pass_filter, object_id, pixel_array.as_pointer(), num_pixels, depth, result.as_pointer())
def reset(engine, data, depsgraph):

View File

@@ -1907,15 +1907,10 @@ class CYCLES_RENDER_PT_bake_selected_to_active(CyclesButtonsPanel, Panel):
col.prop(cbk, "use_cage", text="Cage")
if cbk.use_cage:
col.prop(cbk, "cage_object")
col = layout.column()
col.prop(cbk, "cage_extrusion")
col.active = cbk.cage_object is None
else:
col.prop(cbk, "cage_extrusion", text="Extrusion")
col = layout.column()
col.prop(cbk, "max_ray_distance")
col.prop(cbk, "cage_object", text="Cage Object")
else:
col.prop(cbk, "cage_extrusion", text="Ray Distance")
class CYCLES_RENDER_PT_bake_output(CyclesButtonsPanel, Panel):

View File

@@ -460,12 +460,9 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
sync_objects(b_depsgraph, b_v3d, 0.0f);
}
/* Insert motion times from camera. Motion times from other objects
* have already been added in a sync_objects call. */
uint camera_motion_steps = object_motion_steps(b_cam, b_cam);
for (size_t step = 0; step < camera_motion_steps; step++) {
motion_times.insert(scene->camera->motion_time(step));
}
/* always sample these times for camera motion */
motion_times.insert(-1.0f);
motion_times.insert(1.0f);
/* note iteration over motion_times set happens in sorted order */
foreach (float relative_time, motion_times) {
@@ -490,8 +487,10 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
b_engine.frame_set(frame, subframe);
python_thread_state_save(python_thread_state);
/* Syncs camera motion if relative_time is one of the camera's motion times. */
sync_camera_motion(b_render, b_cam, width, height, relative_time);
/* sync camera, only supports two times at the moment */
if (relative_time == -1.0f || relative_time == 1.0f) {
sync_camera_motion(b_render, b_cam, width, height, relative_time);
}
/* sync object */
sync_objects(b_depsgraph, b_v3d, relative_time);

View File

@@ -60,12 +60,6 @@ void *pylong_as_voidptr_typesafe(PyObject *object)
return PyLong_AsVoidPtr(object);
}
PyObject *pyunicode_from_string(const char *str)
{
/* Ignore errors if device API returns invalid UTF-8 strings. */
return PyUnicode_DecodeUTF8(str, strlen(str), "ignore");
}
/* Synchronize debug flags from a given Blender scene.
* Return truth when device list needs invalidation.
*/
@@ -298,18 +292,22 @@ static PyObject *render_func(PyObject * /*self*/, PyObject *args)
static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
{
PyObject *pysession, *pydepsgraph, *pyobject;
PyObject *pypixel_array, *pyresult;
const char *pass_type;
int pass_filter, width, height;
int num_pixels, depth, object_id, pass_filter;
if (!PyArg_ParseTuple(args,
"OOOsiii",
"OOOsiiOiiO",
&pysession,
&pydepsgraph,
&pyobject,
&pass_type,
&pass_filter,
&width,
&height))
&object_id,
&pypixel_array,
&num_pixels,
&depth,
&pyresult))
return NULL;
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
@@ -322,9 +320,23 @@ static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
RNA_id_pointer_create((ID *)PyLong_AsVoidPtr(pyobject), &objectptr);
BL::Object b_object(objectptr);
void *b_result = PyLong_AsVoidPtr(pyresult);
PointerRNA bakepixelptr;
RNA_pointer_create(NULL, &RNA_BakePixel, PyLong_AsVoidPtr(pypixel_array), &bakepixelptr);
BL::BakePixel b_bake_pixel(bakepixelptr);
python_thread_state_save(&session->python_thread_state);
session->bake(b_depsgraph, b_object, pass_type, pass_filter, width, height);
session->bake(b_depsgraph,
b_object,
pass_type,
pass_filter,
object_id,
b_bake_pixel,
(size_t)num_pixels,
depth,
(float *)b_result);
python_thread_state_restore(&session->python_thread_state);
@@ -417,9 +429,9 @@ static PyObject *available_devices_func(PyObject * /*self*/, PyObject *args)
DeviceInfo &device = devices[i];
string type_name = Device::string_from_type(device.type);
PyObject *device_tuple = PyTuple_New(3);
PyTuple_SET_ITEM(device_tuple, 0, pyunicode_from_string(device.description.c_str()));
PyTuple_SET_ITEM(device_tuple, 1, pyunicode_from_string(type_name.c_str()));
PyTuple_SET_ITEM(device_tuple, 2, pyunicode_from_string(device.id.c_str()));
PyTuple_SET_ITEM(device_tuple, 0, PyUnicode_FromString(device.description.c_str()));
PyTuple_SET_ITEM(device_tuple, 1, PyUnicode_FromString(type_name.c_str()));
PyTuple_SET_ITEM(device_tuple, 2, PyUnicode_FromString(device.id.c_str()));
PyTuple_SET_ITEM(ret, i, device_tuple);
}
@@ -630,7 +642,7 @@ static PyObject *osl_compile_func(PyObject * /*self*/, PyObject *args)
static PyObject *system_info_func(PyObject * /*self*/, PyObject * /*value*/)
{
string system_info = Device::device_capabilities();
return pyunicode_from_string(system_info.c_str());
return PyUnicode_FromString(system_info.c_str());
}
#ifdef WITH_OPENCL

View File

@@ -247,7 +247,9 @@ void BlenderSession::reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsg
void BlenderSession::free_session()
{
delete sync;
if (sync)
delete sync;
delete session;
}
@@ -315,7 +317,6 @@ static void end_render_result(BL::RenderEngine &b_engine,
void BlenderSession::do_write_update_render_tile(RenderTile &rtile,
bool do_update_only,
bool do_read_only,
bool highlight)
{
int x = rtile.x - session->tile_manager.params.full_x;
@@ -341,23 +342,7 @@ void BlenderSession::do_write_update_render_tile(RenderTile &rtile,
BL::RenderLayer b_rlay = *b_single_rlay;
if (do_read_only) {
/* copy each pass */
BL::RenderLayer::passes_iterator b_iter;
for (b_rlay.passes.begin(b_iter); b_iter != b_rlay.passes.end(); ++b_iter) {
BL::RenderPass b_pass(*b_iter);
/* find matching pass type */
PassType pass_type = BlenderSync::get_pass_type(b_pass);
int components = b_pass.channels();
rtile.buffers->set_pass_rect(pass_type, components, (float *)b_pass.rect());
}
end_render_result(b_engine, b_rr, false, false, false);
}
else if (do_update_only) {
if (do_update_only) {
/* Sample would be zero at initial tile update, which is only needed
* to tag tile form blender side as IN PROGRESS for proper highlight
* no buffers should be sent to blender yet. For denoise we also
@@ -377,14 +362,9 @@ void BlenderSession::do_write_update_render_tile(RenderTile &rtile,
}
}
void BlenderSession::read_render_tile(RenderTile &rtile)
{
do_write_update_render_tile(rtile, false, true, false);
}
void BlenderSession::write_render_tile(RenderTile &rtile)
{
do_write_update_render_tile(rtile, false, false, false);
do_write_update_render_tile(rtile, false, false);
}
void BlenderSession::update_render_tile(RenderTile &rtile, bool highlight)
@@ -394,9 +374,9 @@ void BlenderSession::update_render_tile(RenderTile &rtile, bool highlight)
* would need to be investigated a bit further, but for now shall be fine
*/
if (!b_engine.is_preview())
do_write_update_render_tile(rtile, true, false, highlight);
do_write_update_render_tile(rtile, true, highlight);
else
do_write_update_render_tile(rtile, false, false, false);
do_write_update_render_tile(rtile, false, false);
}
static void add_cryptomatte_layer(BL::RenderResult &b_rr, string name, string manifest)
@@ -613,6 +593,25 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_)
#endif
}
static void populate_bake_data(BakeData *data,
const int object_id,
BL::BakePixel &pixel_array,
const int num_pixels)
{
BL::BakePixel bp = pixel_array;
int i;
for (i = 0; i < num_pixels; i++) {
if (bp.object_id() == object_id) {
data->set(i, bp.primitive_id(), bp.uv(), bp.du_dx(), bp.du_dy(), bp.dv_dx(), bp.dv_dy());
}
else {
data->set_null(i);
}
bp = bp.next();
}
}
static int bake_pass_filter_get(const int pass_filter)
{
int flag = BAKE_FILTER_NONE;
@@ -643,26 +642,43 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
BL::Object &b_object,
const string &pass_type,
const int pass_filter,
const int bake_width,
const int bake_height)
const int object_id,
BL::BakePixel &pixel_array,
const size_t num_pixels,
const int /*depth*/,
float result[])
{
b_depsgraph = b_depsgraph_;
ShaderEvalType shader_type = get_shader_type(pass_type);
/* Set baking flag in advance, so kernel loading can check if we need
* any baking capabilities.
*/
scene->bake_manager->set_baking(true);
/* ensure kernels are loaded before we do any scene updates */
session->load_kernels();
if (shader_type == SHADER_EVAL_UV) {
/* force UV to be available */
Pass::add(PASS_UV, scene->film->passes);
}
int bake_pass_filter = bake_pass_filter_get(pass_filter);
bake_pass_filter = BakeManager::shader_type_to_pass_filter(shader_type, bake_pass_filter);
/* Initialize bake manager, before we load the baking kernels. */
scene->bake_manager->set(scene, b_object.name(), shader_type, bake_pass_filter);
/* force use_light_pass to be true if we bake more than just colors */
if (bake_pass_filter & ~BAKE_FILTER_COLOR) {
Pass::add(PASS_LIGHT, scene->film->passes);
}
/* Passes are identified by name, so in order to return the combined pass we need to set the
* name. */
Pass::add(PASS_COMBINED, scene->film->passes, "Combined");
session->read_bake_tile_cb = function_bind(&BlenderSession::read_render_tile, this, _1);
session->write_render_tile_cb = function_bind(&BlenderSession::write_render_tile, this, _1);
/* create device and update scene */
scene->film->tag_update(scene);
scene->integrator->tag_update(scene);
if (!session->progress.get_cancel()) {
/* Sync scene. */
/* update scene */
BL::Object b_camera_override(b_engine.camera_override());
sync->sync_camera(b_render, b_camera_override, width, height, "");
sync->sync_data(
@@ -670,43 +686,75 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
builtin_images_load();
}
/* Object might have been disabled for rendering or excluded in some
* other way, in that case Blender will report a warning afterwards. */
bool object_found = false;
foreach (Object *ob, scene->objects) {
if (ob->name == b_object.name()) {
object_found = true;
break;
}
}
BakeData *bake_data = NULL;
if (object_found && !session->progress.get_cancel()) {
/* Get session and buffer parameters. */
if (!session->progress.get_cancel()) {
/* get buffer parameters */
SessionParams session_params = BlenderSync::get_session_params(
b_engine, b_userpref, b_scene, background);
session_params.progressive_refine = false;
BufferParams buffer_params = BlenderSync::get_buffer_params(
b_scene, b_render, b_v3d, b_rv3d, scene->camera, width, height);
BufferParams buffer_params;
buffer_params.width = bake_width;
buffer_params.height = bake_height;
buffer_params.passes = scene->film->passes;
scene->bake_manager->set_shader_limit((size_t)b_engine.tile_x(), (size_t)b_engine.tile_y());
/* Update session. */
/* set number of samples */
session->tile_manager.set_samples(session_params.samples);
session->reset(buffer_params, session_params.samples);
session->update_scene();
/* find object index. todo: is arbitrary - copied from mesh_displace.cpp */
size_t object_index = OBJECT_NONE;
int tri_offset = 0;
for (size_t i = 0; i < scene->objects.size(); i++) {
const Object *object = scene->objects[i];
const Geometry *geom = object->geometry;
if (object->name == b_object.name() && geom->type == Geometry::MESH) {
const Mesh *mesh = static_cast<const Mesh *>(geom);
object_index = i;
tri_offset = mesh->prim_offset;
break;
}
}
/* Object might have been disabled for rendering or excluded in some
* other way, in that case Blender will report a warning afterwards. */
if (object_index != OBJECT_NONE) {
int object = object_index;
bake_data = scene->bake_manager->init(object, tri_offset, num_pixels);
populate_bake_data(bake_data, object_id, pixel_array, num_pixels);
}
/* set number of samples */
session->tile_manager.set_samples(session_params.samples);
session->reset(buffer_params, session_params.samples);
session->update_scene();
session->progress.set_update_callback(
function_bind(&BlenderSession::update_bake_progress, this));
}
/* Perform bake. Check cancel to avoid crash with incomplete scene data. */
if (object_found && !session->progress.get_cancel()) {
session->start();
session->wait();
if (!session->progress.get_cancel() && bake_data) {
scene->bake_manager->bake(scene->device,
&scene->dscene,
scene,
session->progress,
shader_type,
bake_pass_filter,
bake_data,
result);
}
session->read_bake_tile_cb = function_null;
session->write_render_tile_cb = function_null;
/* free all memory used (host and device), so we wouldn't leave render
* engine with extra memory allocated
*/
session->device_free();
delete sync;
sync = NULL;
}
void BlenderSession::do_write_update_render_result(BL::RenderLayer &b_rlay,

View File

@@ -66,12 +66,14 @@ class BlenderSession {
BL::Object &b_object,
const string &pass_type,
const int custom_flag,
const int bake_width,
const int bake_height);
const int object_id,
BL::BakePixel &pixel_array,
const size_t num_pixels,
const int depth,
float pixels[]);
void write_render_result(BL::RenderLayer &b_rlay, RenderTile &rtile);
void write_render_tile(RenderTile &rtile);
void read_render_tile(RenderTile &rtile);
/* update functions are used to update display buffer only after sample was rendered
* only needed for better visual feedback */
@@ -153,10 +155,7 @@ class BlenderSession {
void do_write_update_render_result(BL::RenderLayer &b_rlay,
RenderTile &rtile,
bool do_update_only);
void do_write_update_render_tile(RenderTile &rtile,
bool do_update_only,
bool do_read_only,
bool highlight);
void do_write_update_render_tile(RenderTile &rtile, bool do_update_only, bool highlight);
void builtin_images_load();

View File

@@ -384,16 +384,16 @@ static ShaderNode *add_node(Scene *scene,
switch (b_aniso_node.distribution()) {
case BL::ShaderNodeBsdfAnisotropic::distribution_BECKMANN:
aniso->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_ID;
aniso->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID;
break;
case BL::ShaderNodeBsdfAnisotropic::distribution_GGX:
aniso->distribution = CLOSURE_BSDF_MICROFACET_GGX_ID;
aniso->distribution = CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID;
break;
case BL::ShaderNodeBsdfAnisotropic::distribution_MULTI_GGX:
aniso->distribution = CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID;
aniso->distribution = CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_ID;
break;
case BL::ShaderNodeBsdfAnisotropic::distribution_ASHIKHMIN_SHIRLEY:
aniso->distribution = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID;
aniso->distribution = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID;
break;
}
@@ -1231,11 +1231,12 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
Shader *shader;
/* test if we need to sync */
if (shader_map.add_or_update(&shader, b_mat) || update_all) {
if (shader_map.add_or_update(&shader, b_mat) || shader->need_sync_object || update_all) {
ShaderGraph *graph = new ShaderGraph();
shader->name = b_mat.name().c_str();
shader->pass_id = b_mat.pass_index();
shader->need_sync_object = false;
/* create nodes */
if (b_mat.use_nodes() && b_mat.node_tree()) {

View File

@@ -85,6 +85,8 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
/* Sync recalc flags from blender to cycles. Actual update is done separate,
* so we can do it later on if doing it immediate is not suitable. */
bool has_updated_objects = b_depsgraph.id_type_updated(BL::DriverTarget::id_type_OBJECT);
if (experimental) {
/* Mark all meshes as needing to be exported again if dicing changed. */
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
@@ -187,6 +189,19 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
if (viewport_parameters.modified(new_viewport_parameters)) {
world_recalc = true;
}
/* Updates shader with object dependency if objects changed. */
if (has_updated_objects) {
if (scene->default_background->has_object_dependency) {
world_recalc = true;
}
foreach (Shader *shader, scene->shaders) {
if (shader->has_object_dependency) {
shader->need_sync_object = true;
}
}
}
}
void BlenderSync::sync_data(BL::RenderSettings &b_render,
@@ -481,9 +496,6 @@ PassType BlenderSync::get_pass_type(BL::RenderPass &b_pass)
MAP_PASS("AO", PASS_AO);
MAP_PASS("Shadow", PASS_SHADOW);
MAP_PASS("BakePrimitive", PASS_BAKE_PRIMITIVE);
MAP_PASS("BakeDifferential", PASS_BAKE_DIFFERENTIAL);
#ifdef __KERNEL_DEBUG__
MAP_PASS("Debug BVH Traversed Nodes", PASS_BVH_TRAVERSED_NODES);
MAP_PASS("Debug BVH Traversed Instances", PASS_BVH_TRAVERSED_INSTANCES);

View File

@@ -34,13 +34,15 @@ CCL_NAMESPACE_BEGIN
/* TODO: verify this is not loading unnecessary attributes. */
class BlenderSmokeLoader : public ImageLoader {
public:
BlenderSmokeLoader(BL::Object &b_ob, AttributeStandard attribute)
: b_domain(object_fluid_gas_domain_find(b_ob)), b_mesh(b_ob.data()), attribute(attribute)
BlenderSmokeLoader(const BL::Object &b_ob, AttributeStandard attribute)
: b_ob(b_ob), attribute(attribute)
{
}
bool load_metadata(ImageMetaData &metadata) override
{
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
if (!b_domain) {
return false;
}
@@ -77,6 +79,7 @@ class BlenderSmokeLoader : public ImageLoader {
/* Create a matrix to transform from object space to mesh texture space.
* This does not work with deformations but that can probably only be done
* well with a volume grid mapping of coordinates. */
BL::Mesh b_mesh(b_ob.data());
float3 loc, size;
mesh_texture_space(b_mesh, loc, size);
metadata.transform_3d = transform_translate(-loc) * transform_scale(size);
@@ -87,6 +90,9 @@ class BlenderSmokeLoader : public ImageLoader {
bool load_pixels(const ImageMetaData &, void *pixels, const size_t, const bool) override
{
/* smoke volume data */
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
if (!b_domain) {
return false;
}
@@ -173,11 +179,10 @@ class BlenderSmokeLoader : public ImageLoader {
bool equals(const ImageLoader &other) const override
{
const BlenderSmokeLoader &other_loader = (const BlenderSmokeLoader &)other;
return b_domain == other_loader.b_domain && attribute == other_loader.attribute;
return b_ob == other_loader.b_ob && attribute == other_loader.attribute;
}
BL::FluidDomainSettings b_domain;
BL::Mesh b_mesh;
BL::Object b_ob;
AttributeStandard attribute;
};

View File

@@ -223,7 +223,7 @@ class CUDADevice : public Device {
CUdeviceptr d_wtile,
CUstream stream = 0);
void render(DeviceTask &task, RenderTile &rtile, device_vector<WorkTile> &work_tiles);
void path_trace(DeviceTask &task, RenderTile &rtile, device_vector<WorkTile> &work_tiles);
void film_convert(DeviceTask &task,
device_ptr buffer,

View File

@@ -421,10 +421,10 @@ string CUDADevice::compile_kernel(const DeviceRequestedFeatures &requested_featu
nvcc_cuda_version % 10);
return string();
}
else if (!(nvcc_cuda_version == 101 || nvcc_cuda_version == 102)) {
else if (nvcc_cuda_version != 101) {
printf(
"CUDA version %d.%d detected, build may succeed but only "
"CUDA 10.1 and 10.2 are officially supported.\n",
"CUDA 10.1 is officially supported.\n",
nvcc_cuda_version / 10,
nvcc_cuda_version % 10);
}
@@ -586,23 +586,20 @@ void CUDADevice::reserve_local_memory(const DeviceRequestedFeatures &requested_f
cuMemGetInfo(&free_before, &total);
/* Get kernel function. */
CUfunction cuRender;
CUfunction cuPathTrace;
if (requested_features.use_baking) {
cuda_assert(cuModuleGetFunction(&cuRender, cuModule, "kernel_cuda_bake"));
}
else if (requested_features.use_integrator_branched) {
cuda_assert(cuModuleGetFunction(&cuRender, cuModule, "kernel_cuda_branched_path_trace"));
if (requested_features.use_integrator_branched) {
cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_branched_path_trace"));
}
else {
cuda_assert(cuModuleGetFunction(&cuRender, cuModule, "kernel_cuda_path_trace"));
cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_path_trace"));
}
cuda_assert(cuFuncSetCacheConfig(cuRender, CU_FUNC_CACHE_PREFER_L1));
cuda_assert(cuFuncSetCacheConfig(cuPathTrace, CU_FUNC_CACHE_PREFER_L1));
int min_blocks, num_threads_per_block;
cuda_assert(
cuOccupancyMaxPotentialBlockSize(&min_blocks, &num_threads_per_block, cuRender, NULL, 0, 0));
cuda_assert(cuOccupancyMaxPotentialBlockSize(
&min_blocks, &num_threads_per_block, cuPathTrace, NULL, 0, 0));
/* Launch kernel, using just 1 block appears sufficient to reserve
* memory for all multiprocessors. It would be good to do this in
@@ -612,7 +609,7 @@ void CUDADevice::reserve_local_memory(const DeviceRequestedFeatures &requested_f
void *args[] = {&d_work_tiles, &total_work_size};
cuda_assert(cuLaunchKernel(cuRender, 1, 1, 1, num_threads_per_block, 1, 1, 0, 0, args, 0));
cuda_assert(cuLaunchKernel(cuPathTrace, 1, 1, 1, num_threads_per_block, 1, 1, 0, 0, args, 0));
cuda_assert(cuCtxSynchronize());
@@ -1783,7 +1780,9 @@ void CUDADevice::adaptive_sampling_post(RenderTile &rtile,
0));
}
void CUDADevice::render(DeviceTask &task, RenderTile &rtile, device_vector<WorkTile> &work_tiles)
void CUDADevice::path_trace(DeviceTask &task,
RenderTile &rtile,
device_vector<WorkTile> &work_tiles)
{
scoped_timer timer(&rtile.buffers->render_time);
@@ -1791,24 +1790,21 @@ void CUDADevice::render(DeviceTask &task, RenderTile &rtile, device_vector<WorkT
return;
CUDAContextScope scope(this);
CUfunction cuRender;
CUfunction cuPathTrace;
/* Get kernel function. */
if (rtile.task == RenderTile::BAKE) {
cuda_assert(cuModuleGetFunction(&cuRender, cuModule, "kernel_cuda_bake"));
}
else if (task.integrator_branched) {
cuda_assert(cuModuleGetFunction(&cuRender, cuModule, "kernel_cuda_branched_path_trace"));
if (task.integrator_branched) {
cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_branched_path_trace"));
}
else {
cuda_assert(cuModuleGetFunction(&cuRender, cuModule, "kernel_cuda_path_trace"));
cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_path_trace"));
}
if (have_error()) {
return;
}
cuda_assert(cuFuncSetCacheConfig(cuRender, CU_FUNC_CACHE_PREFER_L1));
cuda_assert(cuFuncSetCacheConfig(cuPathTrace, CU_FUNC_CACHE_PREFER_L1));
/* Allocate work tile. */
work_tiles.alloc(1);
@@ -1826,8 +1822,8 @@ void CUDADevice::render(DeviceTask &task, RenderTile &rtile, device_vector<WorkT
* remain conservative for GPUs connected to a display to avoid driver
* timeouts and display freezing. */
int min_blocks, num_threads_per_block;
cuda_assert(
cuOccupancyMaxPotentialBlockSize(&min_blocks, &num_threads_per_block, cuRender, NULL, 0, 0));
cuda_assert(cuOccupancyMaxPotentialBlockSize(
&min_blocks, &num_threads_per_block, cuPathTrace, NULL, 0, 0));
if (!info.display_device) {
min_blocks *= 8;
}
@@ -1855,7 +1851,7 @@ void CUDADevice::render(DeviceTask &task, RenderTile &rtile, device_vector<WorkT
void *args[] = {&d_work_tiles, &total_work_size};
cuda_assert(
cuLaunchKernel(cuRender, num_blocks, 1, 1, num_threads_per_block, 1, 1, 0, 0, args, 0));
cuLaunchKernel(cuPathTrace, num_blocks, 1, 1, num_threads_per_block, 1, 1, 0, 0, args, 0));
/* Run the adaptive sampling kernels at selected samples aligned to step samples. */
uint filter_sample = sample + wtile->num_samples - 1;
@@ -1961,7 +1957,10 @@ void CUDADevice::shader(DeviceTask &task)
CUdeviceptr d_output = (CUdeviceptr)task.shader_output;
/* get kernel function */
if (task.shader_eval_type == SHADER_EVAL_DISPLACE) {
if (task.shader_eval_type >= SHADER_EVAL_BAKE) {
cuda_assert(cuModuleGetFunction(&cuShader, cuModule, "kernel_cuda_bake"));
}
else if (task.shader_eval_type == SHADER_EVAL_DISPLACE) {
cuda_assert(cuModuleGetFunction(&cuShader, cuModule, "kernel_cuda_displace"));
}
else {
@@ -2298,12 +2297,9 @@ void CUDADevice::thread_run(DeviceTask *task)
split_kernel->path_trace(task, tile, void_buffer, void_buffer);
}
else {
render(*task, tile, work_tiles);
path_trace(*task, tile, work_tiles);
}
}
else if (tile.task == RenderTile::BAKE) {
render(*task, tile, work_tiles);
}
else if (tile.task == RenderTile::DENOISE) {
tile.sample = tile.start_sample + tile.num_samples;

View File

@@ -494,18 +494,16 @@ vector<DeviceInfo> Device::available_devices(uint mask)
}
#endif
#if defined(WITH_CUDA) || defined(WITH_OPTIX)
if (mask & (DEVICE_MASK_CUDA | DEVICE_MASK_OPTIX)) {
#ifdef WITH_CUDA
if (mask & DEVICE_MASK_CUDA) {
if (!(devices_initialized_mask & DEVICE_MASK_CUDA)) {
if (device_cuda_init()) {
device_cuda_info(cuda_devices);
}
devices_initialized_mask |= DEVICE_MASK_CUDA;
}
if (mask & DEVICE_MASK_CUDA) {
foreach (DeviceInfo &info, cuda_devices) {
devices.push_back(info);
}
foreach (DeviceInfo &info, cuda_devices) {
devices.push_back(info);
}
}
#endif
@@ -514,7 +512,7 @@ vector<DeviceInfo> Device::available_devices(uint mask)
if (mask & DEVICE_MASK_OPTIX) {
if (!(devices_initialized_mask & DEVICE_MASK_OPTIX)) {
if (device_optix_init()) {
device_optix_info(cuda_devices, optix_devices);
device_optix_info(optix_devices);
}
devices_initialized_mask |= DEVICE_MASK_OPTIX;
}

View File

@@ -188,7 +188,6 @@ class CPUDevice : public Device {
convert_to_byte_kernel;
KernelFunctions<void (*)(KernelGlobals *, uint4 *, float4 *, int, int, int, int, int)>
shader_kernel;
KernelFunctions<void (*)(KernelGlobals *, float *, int, int, int, int, int)> bake_kernel;
KernelFunctions<void (*)(
int, TileInfo *, int, int, float *, float *, float *, float *, float *, int *, int, int)>
@@ -271,7 +270,6 @@ class CPUDevice : public Device {
REGISTER_KERNEL(convert_to_half_float),
REGISTER_KERNEL(convert_to_byte),
REGISTER_KERNEL(shader),
REGISTER_KERNEL(bake),
REGISTER_KERNEL(filter_divide_shadow),
REGISTER_KERNEL(filter_get_feature),
REGISTER_KERNEL(filter_write_feature),
@@ -897,7 +895,7 @@ class CPUDevice : public Device {
}
}
void render(DeviceTask &task, RenderTile &tile, KernelGlobals *kg)
void path_trace(DeviceTask &task, RenderTile &tile, KernelGlobals *kg)
{
const bool use_coverage = kernel_data.film.cryptomatte_passes & CRYPT_ACCURATE;
@@ -921,21 +919,12 @@ class CPUDevice : public Device {
break;
}
if (tile.task == RenderTile::PATH_TRACE) {
for (int y = tile.y; y < tile.y + tile.h; y++) {
for (int x = tile.x; x < tile.x + tile.w; x++) {
if (use_coverage) {
coverage.init_pixel(x, y);
}
path_trace_kernel()(kg, render_buffer, sample, x, y, tile.offset, tile.stride);
}
}
}
else {
for (int y = tile.y; y < tile.y + tile.h; y++) {
for (int x = tile.x; x < tile.x + tile.w; x++) {
bake_kernel()(kg, render_buffer, sample, x, y, tile.offset, tile.stride);
for (int y = tile.y; y < tile.y + tile.h; y++) {
for (int x = tile.x; x < tile.x + tile.w; x++) {
if (use_coverage) {
coverage.init_pixel(x, y);
}
path_trace_kernel()(kg, render_buffer, sample, x, y, tile.offset, tile.stride);
}
}
tile.sample = sample + 1;
@@ -1030,12 +1019,9 @@ class CPUDevice : public Device {
split_kernel->path_trace(&task, tile, kgbuffer, void_buffer);
}
else {
render(task, tile, kg);
path_trace(task, tile, kg);
}
}
else if (tile.task == RenderTile::BAKE) {
render(task, tile, kg);
}
else if (tile.task == RenderTile::DENOISE) {
denoise(denoising, tile);
task.update_progress(&tile, tile.w * tile.h);

View File

@@ -45,7 +45,7 @@ Device *device_multi_create(DeviceInfo &info, Stats &stats, Profiler &profiler,
void device_cpu_info(vector<DeviceInfo> &devices);
void device_opencl_info(vector<DeviceInfo> &devices);
void device_cuda_info(vector<DeviceInfo> &devices);
void device_optix_info(const vector<DeviceInfo> &cuda_devices, vector<DeviceInfo> &devices);
void device_optix_info(vector<DeviceInfo> &devices);
void device_network_info(vector<DeviceInfo> &devices);
string device_cpu_capabilities();

View File

@@ -1534,11 +1534,14 @@ bool device_optix_init()
return true;
}
void device_optix_info(const vector<DeviceInfo> &cuda_devices, vector<DeviceInfo> &devices)
void device_optix_info(vector<DeviceInfo> &devices)
{
// Simply add all supported CUDA devices as OptiX devices again
for (const DeviceInfo &cuda_info : cuda_devices) {
DeviceInfo info = cuda_info;
vector<DeviceInfo> cuda_devices;
device_cuda_info(cuda_devices);
for (auto it = cuda_devices.begin(); it != cuda_devices.end();) {
DeviceInfo &info = *it;
assert(info.type == DEVICE_CUDA);
info.type = DEVICE_OPTIX;
info.id += "_OptiX";
@@ -1561,10 +1564,13 @@ void device_optix_info(const vector<DeviceInfo> &cuda_devices, vector<DeviceInfo
}
// Only add devices with RTX support
if (rtcore_version != 0 || getenv("CYCLES_OPTIX_TEST")) {
devices.push_back(info);
}
if (rtcore_version == 0 && !getenv("CYCLES_OPTIX_TEST"))
it = cuda_devices.erase(it);
else
++it;
}
devices.insert(devices.end(), cuda_devices.begin(), cuda_devices.end());
}
Device *device_optix_create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background)

View File

@@ -451,7 +451,6 @@ class OpenCLDevice : public Device {
device_ptr rgba_half);
void shader(DeviceTask &task);
void update_adaptive(DeviceTask &task, RenderTile &tile, int sample);
void bake(DeviceTask &task, RenderTile &tile);
void denoise(RenderTile &tile, DenoisingTask &denoising);

View File

@@ -1367,9 +1367,6 @@ void OpenCLDevice::thread_run(DeviceTask *task)
*/
clFinish(cqCommandQueue);
}
else if (tile.task == RenderTile::BAKE) {
bake(*task, tile);
}
else if (tile.task == RenderTile::DENOISE) {
tile.sample = tile.start_sample + tile.num_samples;
denoise(tile, denoising);
@@ -1861,7 +1858,10 @@ void OpenCLDevice::shader(DeviceTask &task)
cl_int d_offset = task.offset;
OpenCLDevice::OpenCLProgram *program = &background_program;
if (task.shader_eval_type == SHADER_EVAL_DISPLACE) {
if (task.shader_eval_type >= SHADER_EVAL_BAKE) {
program = &bake_program;
}
else if (task.shader_eval_type == SHADER_EVAL_DISPLACE) {
program = &displace_program;
}
program->wait_for_availability();
@@ -1892,51 +1892,6 @@ void OpenCLDevice::shader(DeviceTask &task)
}
}
void OpenCLDevice::bake(DeviceTask &task, RenderTile &rtile)
{
scoped_timer timer(&rtile.buffers->render_time);
/* Cast arguments to cl types. */
cl_mem d_data = CL_MEM_PTR(const_mem_map["__data"]->device_pointer);
cl_mem d_buffer = CL_MEM_PTR(rtile.buffer);
cl_int d_x = rtile.x;
cl_int d_y = rtile.y;
cl_int d_w = rtile.w;
cl_int d_h = rtile.h;
cl_int d_offset = rtile.offset;
cl_int d_stride = rtile.stride;
bake_program.wait_for_availability();
cl_kernel kernel = bake_program();
cl_uint start_arg_index = kernel_set_args(kernel, 0, d_data, d_buffer);
set_kernel_arg_buffers(kernel, &start_arg_index);
start_arg_index += kernel_set_args(
kernel, start_arg_index, d_x, d_y, d_w, d_h, d_offset, d_stride);
int start_sample = rtile.start_sample;
int end_sample = rtile.start_sample + rtile.num_samples;
for (int sample = start_sample; sample < end_sample; sample++) {
if (task.get_cancel()) {
if (task.need_finish_queue == false)
break;
}
kernel_set_args(kernel, start_arg_index, sample);
enqueue_kernel(kernel, d_w, d_h);
rtile.sample = sample + 1;
task.update_progress(&rtile, rtile.w * rtile.h);
}
clFinish(cqCommandQueue);
}
string OpenCLDevice::kernel_build_options(const string *debug_src)
{
string build_options = "-cl-no-signed-zeros -cl-mad-enable ";

View File

@@ -133,7 +133,7 @@ void Node::set(const SocketType &input, const Transform &value)
void Node::set(const SocketType &input, Node *value)
{
assert(input.type == SocketType::NODE);
assert(input.type == SocketType::TRANSFORM);
get_socket_value<Node *>(this, input) = value;
}
@@ -213,7 +213,7 @@ float Node::get_float(const SocketType &input) const
float2 Node::get_float2(const SocketType &input) const
{
assert(input.type == SocketType::POINT2);
assert(input.type == SocketType::FLOAT);
return get_socket_value<float2>(this, input);
}
@@ -272,7 +272,7 @@ const array<float> &Node::get_float_array(const SocketType &input) const
const array<float2> &Node::get_float2_array(const SocketType &input) const
{
assert(input.type == SocketType::POINT2_ARRAY);
assert(input.type == SocketType::FLOAT_ARRAY);
return get_socket_value<array<float2>>(this, input);
}

View File

@@ -375,11 +375,11 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(CUDA_VERSION "${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}")
# warn for other versions
if((CUDA_VERSION MATCHES "101") OR (CUDA_VERSION MATCHES "102"))
if(CUDA_VERSION MATCHES "101")
else()
message(WARNING
"CUDA version ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} detected, "
"build may succeed but only CUDA 10.1 and 10.2 are officially supported")
"build may succeed but only CUDA 10.1 is officially supported")
endif()
# build for each arch

View File

@@ -229,6 +229,8 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
case CLOSURE_BSDF_MICROFACET_GGX_ID:
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
label = bsdf_microfacet_ggx_sample(kg,
sc,
@@ -279,6 +281,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
&sd->lcg_state);
break;
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
label = bsdf_microfacet_beckmann_sample(kg,
sc,
@@ -295,6 +298,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
pdf);
break;
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
label = bsdf_ashikhmin_shirley_sample(sc,
sd->Ng,
sd->I,
@@ -500,6 +504,8 @@ ccl_device_inline
case CLOSURE_BSDF_MICROFACET_GGX_ID:
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
eval = bsdf_microfacet_ggx_eval_reflect(sc, sd->I, omega_in, pdf);
break;
@@ -513,10 +519,12 @@ ccl_device_inline
sc, sd->I, omega_in, pdf, &sd->lcg_state);
break;
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
eval = bsdf_microfacet_beckmann_eval_reflect(sc, sd->I, omega_in, pdf);
break;
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
eval = bsdf_ashikhmin_shirley_eval_reflect(sc, sd->I, omega_in, pdf);
break;
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
@@ -587,6 +595,8 @@ ccl_device_inline
case CLOSURE_BSDF_MICROFACET_GGX_ID:
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
eval = bsdf_microfacet_ggx_eval_transmit(sc, sd->I, omega_in, pdf);
break;
@@ -600,10 +610,12 @@ ccl_device_inline
sc, sd->I, omega_in, pdf, &sd->lcg_state);
break;
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
eval = bsdf_microfacet_beckmann_eval_transmit(sc, sd->I, omega_in, pdf);
break;
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
eval = bsdf_ashikhmin_shirley_eval_transmit(sc, sd->I, omega_in, pdf);
break;
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
@@ -667,14 +679,18 @@ ccl_device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness)
case CLOSURE_BSDF_MICROFACET_GGX_ID:
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
bsdf_microfacet_ggx_blur(sc, roughness);
break;
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
bsdf_microfacet_beckmann_blur(sc, roughness);
break;
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
bsdf_ashikhmin_shirley_blur(sc, roughness);
break;
case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
@@ -703,14 +719,18 @@ ccl_device bool bsdf_merge(ShaderClosure *a, ShaderClosure *b)
case CLOSURE_BSDF_MICROFACET_GGX_ID:
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
return bsdf_microfacet_merge(a, b);
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
return bsdf_ashikhmin_velvet_merge(a, b);

View File

@@ -34,12 +34,21 @@ CCL_NAMESPACE_BEGIN
ccl_device int bsdf_ashikhmin_shirley_setup(MicrofacetBsdf *bsdf)
{
bsdf->alpha_x = clamp(bsdf->alpha_x, 1e-4f, 1.0f);
bsdf->alpha_y = clamp(bsdf->alpha_y, 1e-4f, 1.0f);
bsdf->alpha_y = bsdf->alpha_x;
bsdf->type = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
ccl_device int bsdf_ashikhmin_shirley_aniso_setup(MicrofacetBsdf *bsdf)
{
bsdf->alpha_x = clamp(bsdf->alpha_x, 1e-4f, 1.0f);
bsdf->alpha_y = clamp(bsdf->alpha_y, 1e-4f, 1.0f);
bsdf->type = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
ccl_device void bsdf_ashikhmin_shirley_blur(ShaderClosure *sc, float roughness)
{
MicrofacetBsdf *bsdf = (MicrofacetBsdf *)sc;

View File

@@ -256,7 +256,9 @@ ccl_device_forceinline float3 reflection_color(const MicrofacetBsdf *bsdf, float
{
float3 F = make_float3(1.0f, 1.0f, 1.0f);
bool use_fresnel = (bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID ||
bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID);
bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID ||
bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID);
if (use_fresnel) {
float F0 = fresnel_dielectric_cos(1.0f, bsdf->ior);
@@ -309,27 +311,19 @@ ccl_device int bsdf_microfacet_ggx_setup(MicrofacetBsdf *bsdf)
bsdf->extra = NULL;
bsdf->alpha_x = saturate(bsdf->alpha_x);
bsdf->alpha_y = saturate(bsdf->alpha_y);
bsdf->alpha_y = bsdf->alpha_x;
bsdf->type = CLOSURE_BSDF_MICROFACET_GGX_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
/* Required to maintain OSL interface. */
ccl_device int bsdf_microfacet_ggx_isotropic_setup(MicrofacetBsdf *bsdf)
{
bsdf->alpha_y = bsdf->alpha_x;
return bsdf_microfacet_ggx_setup(bsdf);
}
ccl_device int bsdf_microfacet_ggx_fresnel_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
{
bsdf->extra->cspec0 = saturate3(bsdf->extra->cspec0);
bsdf->alpha_x = saturate(bsdf->alpha_x);
bsdf->alpha_y = saturate(bsdf->alpha_y);
bsdf->alpha_y = bsdf->alpha_x;
bsdf->type = CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID;
@@ -367,6 +361,32 @@ ccl_device bool bsdf_microfacet_merge(const ShaderClosure *a, const ShaderClosur
(bsdf_a->extra->clearcoat == bsdf_b->extra->clearcoat)));
}
ccl_device int bsdf_microfacet_ggx_aniso_setup(MicrofacetBsdf *bsdf)
{
bsdf->extra = NULL;
bsdf->alpha_x = saturate(bsdf->alpha_x);
bsdf->alpha_y = saturate(bsdf->alpha_y);
bsdf->type = CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
ccl_device int bsdf_microfacet_ggx_aniso_fresnel_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
{
bsdf->extra->cspec0 = saturate3(bsdf->extra->cspec0);
bsdf->alpha_x = saturate(bsdf->alpha_x);
bsdf->alpha_y = saturate(bsdf->alpha_y);
bsdf->type = CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID;
bsdf_microfacet_fresnel_color(sd, bsdf);
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
ccl_device int bsdf_microfacet_ggx_refraction_setup(MicrofacetBsdf *bsdf)
{
bsdf->extra = NULL;
@@ -616,7 +636,8 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg,
*eval = make_float3(1e6f, 1e6f, 1e6f);
bool use_fresnel = (bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID ||
bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID);
bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID ||
bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID);
/* if fresnel is used, calculate the color with reflection_color(...) */
if (use_fresnel) {
@@ -790,18 +811,19 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg,
ccl_device int bsdf_microfacet_beckmann_setup(MicrofacetBsdf *bsdf)
{
bsdf->alpha_x = saturate(bsdf->alpha_x);
bsdf->alpha_y = saturate(bsdf->alpha_y);
bsdf->alpha_y = bsdf->alpha_x;
bsdf->type = CLOSURE_BSDF_MICROFACET_BECKMANN_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
/* Required to maintain OSL interface. */
ccl_device int bsdf_microfacet_beckmann_isotropic_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_beckmann_aniso_setup(MicrofacetBsdf *bsdf)
{
bsdf->alpha_y = bsdf->alpha_x;
bsdf->alpha_x = saturate(bsdf->alpha_x);
bsdf->alpha_y = saturate(bsdf->alpha_y);
return bsdf_microfacet_beckmann_setup(bsdf);
bsdf->type = CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
ccl_device int bsdf_microfacet_beckmann_refraction_setup(MicrofacetBsdf *bsdf)

View File

@@ -384,7 +384,7 @@ ccl_device int bsdf_microfacet_multi_ggx_common_setup(MicrofacetBsdf *bsdf)
return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_NEEDS_LCG;
}
ccl_device int bsdf_microfacet_multi_ggx_setup(MicrofacetBsdf *bsdf)
ccl_device int bsdf_microfacet_multi_ggx_aniso_setup(MicrofacetBsdf *bsdf)
{
if (is_zero(bsdf->T))
bsdf->T = make_float3(1.0f, 0.0f, 0.0f);
@@ -394,7 +394,8 @@ ccl_device int bsdf_microfacet_multi_ggx_setup(MicrofacetBsdf *bsdf)
return bsdf_microfacet_multi_ggx_common_setup(bsdf);
}
ccl_device int bsdf_microfacet_multi_ggx_fresnel_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
ccl_device int bsdf_microfacet_multi_ggx_aniso_fresnel_setup(MicrofacetBsdf *bsdf,
const ShaderData *sd)
{
if (is_zero(bsdf->T))
bsdf->T = make_float3(1.0f, 0.0f, 0.0f);
@@ -406,6 +407,26 @@ ccl_device int bsdf_microfacet_multi_ggx_fresnel_setup(MicrofacetBsdf *bsdf, con
return bsdf_microfacet_multi_ggx_common_setup(bsdf);
}
ccl_device int bsdf_microfacet_multi_ggx_setup(MicrofacetBsdf *bsdf)
{
bsdf->alpha_y = bsdf->alpha_x;
bsdf->type = CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID;
return bsdf_microfacet_multi_ggx_common_setup(bsdf);
}
ccl_device int bsdf_microfacet_multi_ggx_fresnel_setup(MicrofacetBsdf *bsdf, const ShaderData *sd)
{
bsdf->alpha_y = bsdf->alpha_x;
bsdf->type = CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID;
bsdf_microfacet_fresnel_color(sd, bsdf);
return bsdf_microfacet_multi_ggx_common_setup(bsdf);
}
ccl_device int bsdf_microfacet_multi_ggx_refraction_setup(MicrofacetBsdf *bsdf)
{
bsdf->alpha_y = bsdf->alpha_x;

View File

@@ -18,33 +18,19 @@ CCL_NAMESPACE_BEGIN
#ifdef __BAKING__
ccl_device_noinline void compute_light_pass(
ccl_device_inline void compute_light_pass(
KernelGlobals *kg, ShaderData *sd, PathRadiance *L, uint rng_hash, int pass_filter, int sample)
{
kernel_assert(kernel_data.film.use_light_pass);
PathRadiance L_sample;
PathState state;
Ray ray;
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
/* Emission and indirect shader data memory used by various functions. */
ShaderDataTinyStorage emission_sd_storage;
ShaderData *emission_sd = AS_SHADER_DATA(&emission_sd_storage);
ShaderData indirect_sd;
/* emission and indirect shader data memory used by various functions */
ShaderData emission_sd, indirect_sd;
/* Init radiance. */
path_radiance_init(kg, L);
/* Init path state. */
PathState state;
path_state_init(kg, emission_sd, &state, rng_hash, sample, NULL);
/* Evaluate surface shader. */
shader_eval_surface(kg, sd, &state, NULL, state.flag);
/* TODO, disable more closures we don't need besides transparent */
shader_bsdf_disable_transparency(kg, sd);
/* Init ray. */
Ray ray;
ray.P = sd->P + sd->Ng;
ray.D = -sd->Ng;
ray.t = FLT_MAX;
@@ -52,6 +38,18 @@ ccl_device_noinline void compute_light_pass(
ray.time = 0.5f;
# endif
/* init radiance */
path_radiance_init(kg, &L_sample);
/* init path state */
path_state_init(kg, &emission_sd, &state, rng_hash, sample, NULL);
/* evaluate surface shader */
shader_eval_surface(kg, sd, &state, NULL, state.flag);
/* TODO, disable more closures we don't need besides transparent */
shader_bsdf_disable_transparency(kg, sd);
# ifdef __BRANCHED_PATH__
if (!kernel_data.integrator.branched) {
/* regular path tracer */
@@ -59,13 +57,14 @@ ccl_device_noinline void compute_light_pass(
/* sample ambient occlusion */
if (pass_filter & BAKE_FILTER_AO) {
kernel_path_ao(kg, sd, emission_sd, L, &state, throughput, shader_bsdf_alpha(kg, sd));
kernel_path_ao(
kg, sd, &emission_sd, &L_sample, &state, throughput, shader_bsdf_alpha(kg, sd));
}
/* sample emission */
if ((pass_filter & BAKE_FILTER_EMISSION) && (sd->flag & SD_EMISSION)) {
float3 emission = indirect_primitive_emission(kg, sd, 0.0f, state.flag, state.ray_pdf);
path_radiance_accum_emission(kg, L, &state, throughput, emission);
path_radiance_accum_emission(kg, &L_sample, &state, throughput, emission);
}
bool is_sss_sample = false;
@@ -78,10 +77,12 @@ ccl_device_noinline void compute_light_pass(
SubsurfaceIndirectRays ss_indirect;
kernel_path_subsurface_init_indirect(&ss_indirect);
if (kernel_path_subsurface_scatter(
kg, sd, emission_sd, L, &state, &ray, &throughput, &ss_indirect)) {
kg, sd, &emission_sd, &L_sample, &state, &ray, &throughput, &ss_indirect)) {
while (ss_indirect.num_rays) {
kernel_path_subsurface_setup_indirect(kg, &ss_indirect, &state, &ray, L, &throughput);
kernel_path_indirect(kg, &indirect_sd, emission_sd, &ray, throughput, &state, L);
kernel_path_subsurface_setup_indirect(
kg, &ss_indirect, &state, &ray, &L_sample, &throughput);
kernel_path_indirect(
kg, &indirect_sd, &emission_sd, &ray, throughput, &state, &L_sample);
}
is_sss_sample = true;
}
@@ -90,18 +91,18 @@ ccl_device_noinline void compute_light_pass(
/* sample light and BSDF */
if (!is_sss_sample && (pass_filter & (BAKE_FILTER_DIRECT | BAKE_FILTER_INDIRECT))) {
kernel_path_surface_connect_light(kg, sd, emission_sd, throughput, &state, L);
kernel_path_surface_connect_light(kg, sd, &emission_sd, throughput, &state, &L_sample);
if (kernel_path_surface_bounce(kg, sd, &throughput, &state, &L->state, &ray)) {
if (kernel_path_surface_bounce(kg, sd, &throughput, &state, &L_sample.state, &ray)) {
# ifdef __LAMP_MIS__
state.ray_t = 0.0f;
# endif
/* compute indirect light */
kernel_path_indirect(kg, &indirect_sd, emission_sd, &ray, throughput, &state, L);
kernel_path_indirect(kg, &indirect_sd, &emission_sd, &ray, throughput, &state, &L_sample);
/* sum and reset indirect light pass variables for the next samples */
path_radiance_sum_indirect(L);
path_radiance_reset_indirect(L);
path_radiance_sum_indirect(&L_sample);
path_radiance_reset_indirect(&L_sample);
}
}
# ifdef __BRANCHED_PATH__
@@ -111,13 +112,13 @@ ccl_device_noinline void compute_light_pass(
/* sample ambient occlusion */
if (pass_filter & BAKE_FILTER_AO) {
kernel_branched_path_ao(kg, sd, emission_sd, L, &state, throughput);
kernel_branched_path_ao(kg, sd, &emission_sd, &L_sample, &state, throughput);
}
/* sample emission */
if ((pass_filter & BAKE_FILTER_EMISSION) && (sd->flag & SD_EMISSION)) {
float3 emission = indirect_primitive_emission(kg, sd, 0.0f, state.flag, state.ray_pdf);
path_radiance_accum_emission(kg, L, &state, throughput, emission);
path_radiance_accum_emission(kg, &L_sample, &state, throughput, emission);
}
# ifdef __SUBSURFACE__
@@ -126,7 +127,7 @@ ccl_device_noinline void compute_light_pass(
/* When mixing BSSRDF and BSDF closures we should skip BSDF lighting
* if scattering was successful. */
kernel_branched_path_subsurface_scatter(
kg, sd, &indirect_sd, emission_sd, L, &state, &ray, throughput);
kg, sd, &indirect_sd, &emission_sd, &L_sample, &state, &ray, throughput);
}
# endif
@@ -137,16 +138,19 @@ ccl_device_noinline void compute_light_pass(
if (kernel_data.integrator.use_direct_light) {
int all = kernel_data.integrator.sample_all_lights_direct;
kernel_branched_path_surface_connect_light(
kg, sd, emission_sd, &state, throughput, 1.0f, L, all);
kg, sd, &emission_sd, &state, throughput, 1.0f, &L_sample, all);
}
# endif
/* indirect light */
kernel_branched_path_surface_indirect_light(
kg, sd, &indirect_sd, emission_sd, throughput, 1.0f, &state, L);
kg, sd, &indirect_sd, &emission_sd, throughput, 1.0f, &state, &L_sample);
}
}
# endif
/* accumulate into master L */
path_radiance_accum_sample(L, &L_sample);
}
/* this helps with AA but it's not the real solution as it does not AA the geometry
@@ -221,28 +225,41 @@ ccl_device float3 kernel_bake_evaluate_direct_indirect(KernelGlobals *kg,
return out;
}
ccl_device void kernel_bake_evaluate(
KernelGlobals *kg, ccl_global float *buffer, int sample, int x, int y, int offset, int stride)
ccl_device void kernel_bake_evaluate(KernelGlobals *kg,
ccl_global uint4 *input,
ccl_global float4 *output,
ShaderEvalType type,
int pass_filter,
int i,
int offset,
int sample)
{
/* Setup render buffers. */
const int index = offset + x + y * stride;
const int pass_stride = kernel_data.film.pass_stride;
buffer += index * pass_stride;
ShaderData sd;
PathState state = {0};
uint4 in = input[i * 2];
uint4 diff = input[i * 2 + 1];
ccl_global float *primitive = buffer + kernel_data.film.pass_bake_primitive;
ccl_global float *differential = buffer + kernel_data.film.pass_bake_differential;
ccl_global float *output = buffer + kernel_data.film.pass_combined;
float3 out = make_float3(0.0f, 0.0f, 0.0f);
int object = in.x;
int prim = in.y;
int prim = __float_as_uint(primitive[1]);
if (prim == -1)
return;
prim += kernel_data.bake.tri_offset;
float u = __uint_as_float(in.z);
float v = __uint_as_float(in.w);
float dudx = __uint_as_float(diff.x);
float dudy = __uint_as_float(diff.y);
float dvdx = __uint_as_float(diff.z);
float dvdy = __uint_as_float(diff.w);
/* Random number generator. */
uint rng_hash = hash_uint2(x, y) ^ kernel_data.integrator.seed;
int num_samples = kernel_data.integrator.aa_samples;
/* random number generator */
uint rng_hash = cmj_hash(offset + i, kernel_data.integrator.seed);
float filter_x, filter_y;
if (sample == 0) {
filter_x = filter_y = 0.5f;
@@ -251,29 +268,23 @@ ccl_device void kernel_bake_evaluate(
path_rng_2D(kg, rng_hash, sample, num_samples, PRNG_FILTER_U, &filter_x, &filter_y);
}
/* Barycentric UV with subpixel offset. */
float u = primitive[2];
float v = primitive[3];
float dudx = differential[0];
float dudy = differential[1];
float dvdx = differential[2];
float dvdy = differential[3];
/* subpixel u/v offset */
if (sample > 0) {
u = bake_clamp_mirror_repeat(u + dudx * (filter_x - 0.5f) + dudy * (filter_y - 0.5f), 1.0f);
v = bake_clamp_mirror_repeat(v + dvdx * (filter_x - 0.5f) + dvdy * (filter_y - 0.5f),
1.0f - u);
}
/* Shader data setup. */
int object = kernel_data.bake.object_index;
/* triangle */
int shader;
float3 P, Ng;
triangle_point_normal(kg, object, prim, u, v, &P, &Ng, &shader);
ShaderData sd;
/* light passes */
PathRadiance L;
path_radiance_init(kg, &L);
shader_setup_from_sample(
kg,
&sd,
@@ -291,7 +302,7 @@ ccl_device void kernel_bake_evaluate(
LAMP_NONE);
sd.I = sd.N;
/* Setup differentials. */
/* update differentials */
sd.dP.dx = sd.dPdu * dudx + sd.dPdv * dvdx;
sd.dP.dy = sd.dPdu * dudy + sd.dPdv * dvdy;
sd.du.dx = dudx;
@@ -299,24 +310,17 @@ ccl_device void kernel_bake_evaluate(
sd.dv.dx = dvdx;
sd.dv.dy = dvdy;
/* Set RNG state for shaders that use sampling. */
PathState state = {0};
/* set RNG state for shaders that use sampling */
state.rng_hash = rng_hash;
state.rng_offset = 0;
state.sample = sample;
state.num_samples = num_samples;
state.min_ray_pdf = FLT_MAX;
/* Light passes if we need more than color. */
PathRadiance L;
int pass_filter = kernel_data.bake.pass_filter;
if (kernel_data.bake.pass_filter & ~BAKE_FILTER_COLOR)
/* light passes if we need more than color */
if (pass_filter & ~BAKE_FILTER_COLOR)
compute_light_pass(kg, &sd, &L, rng_hash, pass_filter, sample);
float3 out = make_float3(0.0f, 0.0f, 0.0f);
ShaderEvalType type = (ShaderEvalType)kernel_data.bake.type;
switch (type) {
/* data passes */
case SHADER_EVAL_NORMAL:
@@ -437,8 +441,10 @@ ccl_device void kernel_bake_evaluate(
}
/* write output */
const float4 result = make_float4(out.x, out.y, out.z, 1.0f);
kernel_write_pass_float4(output, result);
const float output_fac = 1.0f / num_samples;
const float4 scaled_result = make_float4(out.x, out.y, out.z, 1.0f) * output_fac;
output[i] = (sample == 0) ? scaled_result : output[i] + scaled_result;
}
#endif /* __BAKING__ */

View File

@@ -43,17 +43,12 @@
#define ccl_local __local
#define ccl_local_param __local
#define ccl_private __private
#define ccl_loop_no_unroll __attribute__((opencl_unroll_hint(1)))
#define ccl_restrict restrict
#define ccl_ref
#define ccl_align(n) __attribute__((aligned(n)))
#define ccl_optional_struct_init
#if __OPENCL_VERSION__ >= 200
# define ccl_loop_no_unroll __attribute__((opencl_unroll_hint(1)))
#else
# define ccl_loop_no_unroll
#endif
#ifdef __SPLIT_KERNEL__
# define ccl_addr_space __global
#else

View File

@@ -28,13 +28,13 @@ ccl_device float4 film_get_pass_result(KernelGlobals *kg,
int display_pass_components = kernel_data.film.display_pass_components;
if (display_pass_components == 4) {
float4 in = *(ccl_global float4 *)(buffer + display_pass_stride +
index * kernel_data.film.pass_stride);
ccl_global float4 *in = (ccl_global float4 *)(buffer + display_pass_stride +
index * kernel_data.film.pass_stride);
float alpha = use_display_sample_scale ?
(kernel_data.film.use_display_pass_alpha ? in.w : 1.0f / sample_scale) :
(kernel_data.film.use_display_pass_alpha ? in->w : 1.0f / sample_scale) :
1.0f;
pass_result = make_float4(in.x, in.y, in.z, alpha);
pass_result = make_float4(in->x, in->y, in->z, alpha);
int display_divide_pass_stride = kernel_data.film.display_divide_pass_stride;
if (display_divide_pass_stride != -1) {

View File

@@ -1041,19 +1041,11 @@ ccl_device_forceinline void triangle_light_sample(KernelGlobals *kg,
}
}
else {
/* compute random point in triangle. From Eric Heitz's "A Low-Distortion Map Between Triangle
* and Square" */
float u = randu;
float v = randv;
if (v > u) {
u *= 0.5f;
v -= u;
}
else {
v *= 0.5f;
u -= v;
}
/* compute random point in triangle */
randu = sqrtf(randu);
const float u = 1.0f - randu;
const float v = randv * randu;
const float t = 1.0f - u - v;
ls->P = u * V[0] + v * V[1] + t * V[2];
/* compute incoming direction, distance and pdf */

View File

@@ -395,10 +395,6 @@ typedef enum PassType {
PASS_VOLUME_INDIRECT,
/* No Scatter color since it's tricky to define what it would even mean. */
PASS_CATEGORY_LIGHT_END = 63,
PASS_BAKE_PRIMITIVE,
PASS_BAKE_DIFFERENTIAL,
PASS_CATEGORY_BAKE_END = 95
} PassType;
#define PASS_ANY (~0)
@@ -1252,10 +1248,6 @@ typedef struct KernelFilm {
float4 xyz_to_b;
float4 rgb_to_y;
int pass_bake_primitive;
int pass_bake_differential;
int pad;
#ifdef __KERNEL_DEBUG__
int pass_bvh_traversed_nodes;
int pass_bvh_traversed_instances;
@@ -1435,14 +1427,6 @@ typedef struct KernelTables {
} KernelTables;
static_assert_align(KernelTables, 16);
typedef struct KernelBake {
int object_index;
int tri_offset;
int type;
int pass_filter;
} KernelBake;
static_assert_align(KernelBake, 16);
typedef struct KernelData {
KernelCamera cam;
KernelFilm film;
@@ -1451,7 +1435,6 @@ typedef struct KernelData {
KernelBVH bvh;
KernelCurves curve;
KernelTables tables;
KernelBake bake;
} KernelData;
static_assert_align(KernelData, 16);

View File

@@ -46,9 +46,6 @@ void KERNEL_FUNCTION_FULL_NAME(shader)(KernelGlobals *kg,
int offset,
int sample);
void KERNEL_FUNCTION_FULL_NAME(bake)(
KernelGlobals *kg, float *buffer, int sample, int x, int y, int offset, int stride);
/* Split kernels */
void KERNEL_FUNCTION_FULL_NAME(data_init)(KernelGlobals *kg,

View File

@@ -132,18 +132,6 @@ void KERNEL_FUNCTION_FULL_NAME(convert_to_half_float)(KernelGlobals *kg,
# endif /* KERNEL_STUB */
}
/* Bake */
void KERNEL_FUNCTION_FULL_NAME(bake)(
KernelGlobals *kg, float *buffer, int sample, int x, int y, int offset, int stride)
{
# ifdef KERNEL_STUB
STUB_ASSERT(KERNEL_ARCH, bake);
# else
kernel_bake_evaluate(kg, buffer, sample, x, y, offset, stride);
# endif /* KERNEL_STUB */
}
/* Shader Evaluate */
void KERNEL_FUNCTION_FULL_NAME(shader)(KernelGlobals *kg,
@@ -158,7 +146,12 @@ void KERNEL_FUNCTION_FULL_NAME(shader)(KernelGlobals *kg,
# ifdef KERNEL_STUB
STUB_ASSERT(KERNEL_ARCH, shader);
# else
if (type == SHADER_EVAL_DISPLACE) {
if (type >= SHADER_EVAL_BAKE) {
# ifdef __BAKING__
kernel_bake_evaluate(kg, input, output, (ShaderEvalType)type, filter, i, offset, sample);
# endif
}
else if (type == SHADER_EVAL_DISPLACE) {
kernel_displace_evaluate(kg, input, output, i);
}
else {

View File

@@ -214,16 +214,13 @@ kernel_cuda_background(uint4 *input,
#ifdef __BAKING__
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
kernel_cuda_bake(WorkTile *tile, uint total_work_size)
kernel_cuda_bake(uint4 *input, float4 *output, int type, int filter, int sx, int sw, int offset, int sample)
{
int work_index = ccl_global_id(0);
if(work_index < total_work_size) {
uint x, y, sample;
get_work_pixel(tile, work_index, &x, &y, &sample);
int x = sx + blockDim.x*blockIdx.x + threadIdx.x;
if(x < sx + sw) {
KernelGlobals kg;
kernel_bake_evaluate(&kg, tile->buffer, sample, x, y, tile->offset, tile->stride);
kernel_bake_evaluate(&kg, input, output, (ShaderEvalType)type, filter, x, offset, sample);
}
}
#endif

View File

@@ -100,14 +100,14 @@ CLOSURE_FLOAT3_PARAM(DiffuseClosure, params.N),
BSDF_CLOSURE_CLASS_END(AshikhminVelvet, ashikhmin_velvet)
BSDF_CLOSURE_CLASS_BEGIN(AshikhminShirley,
ashikhmin_shirley,
ashikhmin_shirley_aniso,
MicrofacetBsdf,
LABEL_GLOSSY | LABEL_REFLECT)
CLOSURE_FLOAT3_PARAM(AshikhminShirleyClosure, params.N),
CLOSURE_FLOAT3_PARAM(AshikhminShirleyClosure, params.T),
CLOSURE_FLOAT_PARAM(AshikhminShirleyClosure, params.alpha_x),
CLOSURE_FLOAT_PARAM(AshikhminShirleyClosure, params.alpha_y),
BSDF_CLOSURE_CLASS_END(AshikhminShirley, ashikhmin_shirley)
BSDF_CLOSURE_CLASS_END(AshikhminShirley, ashikhmin_shirley_aniso)
BSDF_CLOSURE_CLASS_BEGIN(DiffuseToon, diffuse_toon, ToonBsdf, LABEL_DIFFUSE)
CLOSURE_FLOAT3_PARAM(DiffuseToonClosure, params.N),
@@ -121,42 +121,42 @@ CLOSURE_FLOAT3_PARAM(DiffuseClosure, params.N),
CLOSURE_FLOAT_PARAM(GlossyToonClosure, params.smooth),
BSDF_CLOSURE_CLASS_END(GlossyToon, glossy_toon)
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetGGXIsotropic,
microfacet_ggx_isotropic,
MicrofacetBsdf,
LABEL_GLOSSY | LABEL_REFLECT)
CLOSURE_FLOAT3_PARAM(MicrofacetGGXIsotropicClosure, params.N),
CLOSURE_FLOAT_PARAM(MicrofacetGGXIsotropicClosure, params.alpha_x),
BSDF_CLOSURE_CLASS_END(MicrofacetGGXIsotropic, microfacet_ggx_isotropic)
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetGGX,
microfacet_ggx,
MicrofacetBsdf,
LABEL_GLOSSY | LABEL_REFLECT)
CLOSURE_FLOAT3_PARAM(MicrofacetGGXClosure, params.N),
CLOSURE_FLOAT3_PARAM(MicrofacetGGXClosure, params.T),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure, params.alpha_x),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure, params.alpha_y),
BSDF_CLOSURE_CLASS_END(MicrofacetGGX, microfacet_ggx)
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetBeckmannIsotropic,
microfacet_beckmann_isotropic,
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetGGXAniso,
microfacet_ggx_aniso,
MicrofacetBsdf,
LABEL_GLOSSY | LABEL_REFLECT)
CLOSURE_FLOAT3_PARAM(MicrofacetBeckmannIsotropicClosure, params.N),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannIsotropicClosure, params.alpha_x),
BSDF_CLOSURE_CLASS_END(MicrofacetBeckmannIsotropic, microfacet_beckmann_isotropic)
CLOSURE_FLOAT3_PARAM(MicrofacetGGXAnisoClosure, params.N),
CLOSURE_FLOAT3_PARAM(MicrofacetGGXAnisoClosure, params.T),
CLOSURE_FLOAT_PARAM(MicrofacetGGXAnisoClosure, params.alpha_x),
CLOSURE_FLOAT_PARAM(MicrofacetGGXAnisoClosure, params.alpha_y),
BSDF_CLOSURE_CLASS_END(MicrofacetGGXAniso, microfacet_ggx_aniso)
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetBeckmann,
microfacet_beckmann,
MicrofacetBsdf,
LABEL_GLOSSY | LABEL_REFLECT)
CLOSURE_FLOAT3_PARAM(MicrofacetBeckmannClosure, params.N),
CLOSURE_FLOAT3_PARAM(MicrofacetBeckmannClosure, params.T),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure, params.alpha_x),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure, params.alpha_y),
BSDF_CLOSURE_CLASS_END(MicrofacetBeckmann, microfacet_beckmann)
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetBeckmannAniso,
microfacet_beckmann_aniso,
MicrofacetBsdf,
LABEL_GLOSSY | LABEL_REFLECT)
CLOSURE_FLOAT3_PARAM(MicrofacetBeckmannAnisoClosure, params.N),
CLOSURE_FLOAT3_PARAM(MicrofacetBeckmannAnisoClosure, params.T),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannAnisoClosure, params.alpha_x),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannAnisoClosure, params.alpha_y),
BSDF_CLOSURE_CLASS_END(MicrofacetBeckmannAniso, microfacet_beckmann_aniso)
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetGGXRefraction,
microfacet_ggx_refraction,
MicrofacetBsdf,
@@ -362,13 +362,13 @@ void OSLShader::register_closures(OSLShadingSystem *ss_)
id++,
closure_bsdf_transparent_params(),
closure_bsdf_transparent_prepare);
register_closure(ss,
"microfacet_ggx",
id++,
bsdf_microfacet_ggx_isotropic_params(),
bsdf_microfacet_ggx_isotropic_prepare);
register_closure(
ss, "microfacet_ggx_aniso", id++, bsdf_microfacet_ggx_params(), bsdf_microfacet_ggx_prepare);
ss, "microfacet_ggx", id++, bsdf_microfacet_ggx_params(), bsdf_microfacet_ggx_prepare);
register_closure(ss,
"microfacet_ggx_aniso",
id++,
bsdf_microfacet_ggx_aniso_params(),
bsdf_microfacet_ggx_aniso_prepare);
register_closure(ss,
"microfacet_ggx_refraction",
id++,
@@ -417,13 +417,13 @@ void OSLShader::register_closures(OSLShadingSystem *ss_)
register_closure(ss,
"microfacet_beckmann",
id++,
bsdf_microfacet_beckmann_isotropic_params(),
bsdf_microfacet_beckmann_isotropic_prepare);
bsdf_microfacet_beckmann_params(),
bsdf_microfacet_beckmann_prepare);
register_closure(ss,
"microfacet_beckmann_aniso",
id++,
bsdf_microfacet_beckmann_params(),
bsdf_microfacet_beckmann_prepare);
bsdf_microfacet_beckmann_aniso_params(),
bsdf_microfacet_beckmann_aniso_prepare);
register_closure(ss,
"microfacet_beckmann_refraction",
id++,
@@ -432,8 +432,8 @@ void OSLShader::register_closures(OSLShadingSystem *ss_)
register_closure(ss,
"ashikhmin_shirley",
id++,
bsdf_ashikhmin_shirley_params(),
bsdf_ashikhmin_shirley_prepare);
bsdf_ashikhmin_shirley_aniso_params(),
bsdf_ashikhmin_shirley_aniso_prepare);
register_closure(
ss, "ashikhmin_velvet", id++, bsdf_ashikhmin_velvet_params(), bsdf_ashikhmin_velvet_prepare);
register_closure(
@@ -582,7 +582,7 @@ class MicrofacetGGXAnisoFresnelClosure : public MicrofacetFresnelClosure {
return;
}
sd->flag |= bsdf_microfacet_ggx_fresnel_setup(bsdf, sd);
sd->flag |= bsdf_microfacet_ggx_aniso_fresnel_setup(bsdf, sd);
}
};
@@ -676,7 +676,7 @@ class MicrofacetMultiGGXAnisoClosure : public MicrofacetMultiClosure {
}
bsdf->ior = 0.0f;
sd->flag |= bsdf_microfacet_multi_ggx_setup(bsdf);
sd->flag |= bsdf_microfacet_multi_ggx_aniso_setup(bsdf);
}
};
@@ -801,7 +801,7 @@ class MicrofacetMultiGGXAnisoFresnelClosure : public MicrofacetMultiFresnelClosu
return;
}
sd->flag |= bsdf_microfacet_multi_ggx_fresnel_setup(bsdf, sd);
sd->flag |= bsdf_microfacet_multi_ggx_aniso_fresnel_setup(bsdf, sd);
}
};

View File

@@ -320,9 +320,9 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg,
/* setup bsdf */
if (distribution == CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID ||
roughness <= 0.075f) /* use single-scatter GGX */
sd->flag |= bsdf_microfacet_ggx_fresnel_setup(bsdf, sd);
sd->flag |= bsdf_microfacet_ggx_aniso_fresnel_setup(bsdf, sd);
else /* use multi-scatter GGX */
sd->flag |= bsdf_microfacet_multi_ggx_fresnel_setup(bsdf, sd);
sd->flag |= bsdf_microfacet_multi_ggx_aniso_fresnel_setup(bsdf, sd);
}
}
# ifdef __CAUSTICS_TRICKS__
@@ -515,34 +515,12 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg,
float roughness = sqr(param1);
bsdf->N = N;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->alpha_x = roughness;
bsdf->alpha_y = roughness;
bsdf->ior = 0.0f;
bsdf->extra = NULL;
if (data_node.y == SVM_STACK_INVALID) {
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->alpha_x = roughness;
bsdf->alpha_y = roughness;
}
else {
bsdf->T = stack_load_float3(stack, data_node.y);
/* rotate tangent */
float rotation = stack_load_float(stack, data_node.z);
if (rotation != 0.0f)
bsdf->T = rotate_around_axis(bsdf->T, bsdf->N, rotation * M_2PI_F);
/* compute roughness */
float anisotropy = clamp(param2, -0.99f, 0.99f);
if (anisotropy < 0.0f) {
bsdf->alpha_x = roughness / (1.0f + anisotropy);
bsdf->alpha_y = roughness * (1.0f + anisotropy);
}
else {
bsdf->alpha_x = roughness * (1.0f - anisotropy);
bsdf->alpha_y = roughness / (1.0f - anisotropy);
}
}
/* setup bsdf */
if (type == CLOSURE_BSDF_REFLECTION_ID)
sd->flag |= bsdf_reflection_setup(bsdf);
@@ -551,10 +529,10 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg,
else if (type == CLOSURE_BSDF_MICROFACET_GGX_ID)
sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
else if (type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID) {
kernel_assert(stack_valid(data_node.w));
kernel_assert(stack_valid(data_node.z));
bsdf->extra = (MicrofacetExtra *)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
if (bsdf->extra) {
bsdf->extra->color = stack_load_float3(stack, data_node.w);
bsdf->extra->color = stack_load_float3(stack, data_node.z);
bsdf->extra->cspec0 = make_float3(0.0f, 0.0f, 0.0f);
bsdf->extra->clearcoat = 0.0f;
sd->flag |= bsdf_microfacet_multi_ggx_setup(bsdf);
@@ -697,6 +675,64 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg,
sd->flag |= bsdf_microfacet_multi_ggx_glass_setup(bsdf);
break;
}
case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_ID:
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID: {
#ifdef __CAUSTICS_TRICKS__
if (!kernel_data.integrator.caustics_reflective && (path_flag & PATH_RAY_DIFFUSE))
break;
#endif
float3 weight = sd->svm_closure_weight * mix_weight;
MicrofacetBsdf *bsdf = (MicrofacetBsdf *)bsdf_alloc(sd, sizeof(MicrofacetBsdf), weight);
if (bsdf) {
bsdf->N = N;
bsdf->extra = NULL;
bsdf->T = stack_load_float3(stack, data_node.y);
/* rotate tangent */
float rotation = stack_load_float(stack, data_node.z);
if (rotation != 0.0f)
bsdf->T = rotate_around_axis(bsdf->T, bsdf->N, rotation * M_2PI_F);
/* compute roughness */
float roughness = sqr(param1);
float anisotropy = clamp(param2, -0.99f, 0.99f);
if (anisotropy < 0.0f) {
bsdf->alpha_x = roughness / (1.0f + anisotropy);
bsdf->alpha_y = roughness * (1.0f + anisotropy);
}
else {
bsdf->alpha_x = roughness * (1.0f - anisotropy);
bsdf->alpha_y = roughness / (1.0f - anisotropy);
}
bsdf->ior = 0.0f;
if (type == CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID) {
sd->flag |= bsdf_microfacet_beckmann_aniso_setup(bsdf);
}
else if (type == CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID) {
sd->flag |= bsdf_microfacet_ggx_aniso_setup(bsdf);
}
else if (type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_ID) {
kernel_assert(stack_valid(data_node.w));
bsdf->extra = (MicrofacetExtra *)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
if (bsdf->extra) {
bsdf->extra->color = stack_load_float3(stack, data_node.w);
bsdf->extra->cspec0 = make_float3(0.0f, 0.0f, 0.0f);
bsdf->extra->clearcoat = 0.0f;
sd->flag |= bsdf_microfacet_multi_ggx_aniso_setup(bsdf);
}
}
else
sd->flag |= bsdf_ashikhmin_shirley_aniso_setup(bsdf);
}
break;
}
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID: {
float3 weight = sd->svm_closure_weight * mix_weight;
VelvetBsdf *bsdf = (VelvetBsdf *)bsdf_alloc(sd, sizeof(VelvetBsdf), weight);

View File

@@ -539,6 +539,12 @@ typedef enum ClosureType {
CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID,
CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID,
CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID,
CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID,
CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID,
CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_ID,
CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_FRESNEL_ID,
CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID,
CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID,
CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
CLOSURE_BSDF_PHONG_RAMP_ID,
CLOSURE_BSDF_GLOSSY_TOON_ID,
@@ -599,9 +605,10 @@ typedef enum ClosureType {
#define CLOSURE_IS_BSDF_TRANSPARENT(type) (type == CLOSURE_BSDF_TRANSPARENT_ID)
#define CLOSURE_IS_BSDF_MULTISCATTER(type) \
(type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID || \
type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_ID || \
type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID)
#define CLOSURE_IS_BSDF_MICROFACET(type) \
((type >= CLOSURE_BSDF_MICROFACET_GGX_ID && type <= CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID) || \
((type >= CLOSURE_BSDF_MICROFACET_GGX_ID && type <= CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID) || \
(type >= CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID && \
type <= CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID) || \
(type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID))
@@ -609,7 +616,8 @@ typedef enum ClosureType {
(type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID || \
type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID || \
type == CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID || \
type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID)
type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID || \
type == CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID)
#define CLOSURE_IS_BSDF_OR_BSSRDF(type) (type <= CLOSURE_BSSRDF_PRINCIPLED_RANDOM_WALK_ID)
#define CLOSURE_IS_BSSRDF(type) \
(type >= CLOSURE_BSSRDF_CUBIC_ID && type <= CLOSURE_BSSRDF_PRINCIPLED_RANDOM_WALK_ID)

View File

@@ -15,7 +15,6 @@
*/
#include "render/bake.h"
#include "render/buffers.h"
#include "render/integrator.h"
#include "render/mesh.h"
#include "render/object.h"
@@ -25,13 +24,235 @@
CCL_NAMESPACE_BEGIN
static int aa_samples(Scene *scene, Object *object, ShaderEvalType type)
BakeData::BakeData(const int object, const size_t tri_offset, const size_t num_pixels)
: m_object(object), m_tri_offset(tri_offset), m_num_pixels(num_pixels)
{
m_primitive.resize(num_pixels);
m_u.resize(num_pixels);
m_v.resize(num_pixels);
m_dudx.resize(num_pixels);
m_dudy.resize(num_pixels);
m_dvdx.resize(num_pixels);
m_dvdy.resize(num_pixels);
}
BakeData::~BakeData()
{
m_primitive.clear();
m_u.clear();
m_v.clear();
m_dudx.clear();
m_dudy.clear();
m_dvdx.clear();
m_dvdy.clear();
}
void BakeData::set(int i, int prim, float uv[2], float dudx, float dudy, float dvdx, float dvdy)
{
m_primitive[i] = (prim == -1 ? -1 : m_tri_offset + prim);
m_u[i] = uv[0];
m_v[i] = uv[1];
m_dudx[i] = dudx;
m_dudy[i] = dudy;
m_dvdx[i] = dvdx;
m_dvdy[i] = dvdy;
}
void BakeData::set_null(int i)
{
m_primitive[i] = -1;
}
int BakeData::object()
{
return m_object;
}
size_t BakeData::size()
{
return m_num_pixels;
}
bool BakeData::is_valid(int i)
{
return m_primitive[i] != -1;
}
uint4 BakeData::data(int i)
{
return make_uint4(m_object, m_primitive[i], __float_as_int(m_u[i]), __float_as_int(m_v[i]));
}
uint4 BakeData::differentials(int i)
{
return make_uint4(__float_as_int(m_dudx[i]),
__float_as_int(m_dudy[i]),
__float_as_int(m_dvdx[i]),
__float_as_int(m_dvdy[i]));
}
BakeManager::BakeManager()
{
m_bake_data = NULL;
m_is_baking = false;
need_update = true;
m_shader_limit = 512 * 512;
}
BakeManager::~BakeManager()
{
if (m_bake_data)
delete m_bake_data;
}
bool BakeManager::get_baking()
{
return m_is_baking;
}
void BakeManager::set_baking(const bool value)
{
m_is_baking = value;
}
BakeData *BakeManager::init(const int object, const size_t tri_offset, const size_t num_pixels)
{
m_bake_data = new BakeData(object, tri_offset, num_pixels);
return m_bake_data;
}
void BakeManager::set_shader_limit(const size_t x, const size_t y)
{
m_shader_limit = x * y;
m_shader_limit = (size_t)pow(2, std::ceil(log(m_shader_limit) / log(2)));
}
bool BakeManager::bake(Device *device,
DeviceScene *dscene,
Scene *scene,
Progress &progress,
ShaderEvalType shader_type,
const int pass_filter,
BakeData *bake_data,
float result[])
{
size_t num_pixels = bake_data->size();
int num_samples = aa_samples(scene, bake_data, shader_type);
/* calculate the total pixel samples for the progress bar */
total_pixel_samples = 0;
for (size_t shader_offset = 0; shader_offset < num_pixels; shader_offset += m_shader_limit) {
size_t shader_size = (size_t)fminf(num_pixels - shader_offset, m_shader_limit);
total_pixel_samples += shader_size * num_samples;
}
progress.reset_sample();
progress.set_total_pixel_samples(total_pixel_samples);
/* needs to be up to date for baking specific AA samples */
dscene->data.integrator.aa_samples = num_samples;
device->const_copy_to("__data", &dscene->data, sizeof(dscene->data));
for (size_t shader_offset = 0; shader_offset < num_pixels; shader_offset += m_shader_limit) {
size_t shader_size = (size_t)fminf(num_pixels - shader_offset, m_shader_limit);
/* setup input for device task */
device_vector<uint4> d_input(device, "bake_input", MEM_READ_ONLY);
uint4 *d_input_data = d_input.alloc(shader_size * 2);
size_t d_input_size = 0;
for (size_t i = shader_offset; i < (shader_offset + shader_size); i++) {
d_input_data[d_input_size++] = bake_data->data(i);
d_input_data[d_input_size++] = bake_data->differentials(i);
}
if (d_input_size == 0) {
m_is_baking = false;
return false;
}
/* run device task */
device_vector<float4> d_output(device, "bake_output", MEM_READ_WRITE);
d_output.alloc(shader_size);
d_output.zero_to_device();
d_input.copy_to_device();
DeviceTask task(DeviceTask::SHADER);
task.shader_input = d_input.device_pointer;
task.shader_output = d_output.device_pointer;
task.shader_eval_type = shader_type;
task.shader_filter = pass_filter;
task.shader_x = 0;
task.offset = shader_offset;
task.shader_w = d_output.size();
task.num_samples = num_samples;
task.get_cancel = function_bind(&Progress::get_cancel, &progress);
task.update_progress_sample = function_bind(&Progress::add_samples_update, &progress, _1, _2);
device->task_add(task);
device->task_wait();
if (progress.get_cancel()) {
d_input.free();
d_output.free();
m_is_baking = false;
return false;
}
d_output.copy_from_device(0, 1, d_output.size());
d_input.free();
/* read result */
int k = 0;
float4 *offset = d_output.data();
size_t depth = 4;
for (size_t i = shader_offset; i < (shader_offset + shader_size); i++) {
size_t index = i * depth;
float4 out = offset[k++];
if (bake_data->is_valid(i)) {
for (size_t j = 0; j < 4; j++) {
result[index + j] = out[j];
}
}
}
d_output.free();
}
m_is_baking = false;
return true;
}
void BakeManager::device_update(Device * /*device*/,
DeviceScene * /*dscene*/,
Scene * /*scene*/,
Progress &progress)
{
if (!need_update)
return;
if (progress.get_cancel())
return;
need_update = false;
}
void BakeManager::device_free(Device * /*device*/, DeviceScene * /*dscene*/)
{
}
int BakeManager::aa_samples(Scene *scene, BakeData *bake_data, ShaderEvalType type)
{
if (type == SHADER_EVAL_UV || type == SHADER_EVAL_ROUGHNESS) {
return 1;
}
else if (type == SHADER_EVAL_NORMAL) {
/* Only antialias normal if mesh has bump mapping. */
Object *object = scene->objects[bake_data->object()];
if (object->geometry) {
foreach (Shader *shader, object->geometry->used_shaders) {
if (shader->has_bump) {
@@ -48,7 +269,7 @@ static int aa_samples(Scene *scene, Object *object, ShaderEvalType type)
}
/* Keep it synced with kernel_bake.h logic */
static int shader_type_to_pass_filter(ShaderEvalType type, int pass_filter)
int BakeManager::shader_type_to_pass_filter(ShaderEvalType type, const int pass_filter)
{
const int component_flags = pass_filter &
(BAKE_FILTER_DIRECT | BAKE_FILTER_INDIRECT | BAKE_FILTER_COLOR);
@@ -71,84 +292,4 @@ static int shader_type_to_pass_filter(ShaderEvalType type, int pass_filter)
}
}
BakeManager::BakeManager()
{
type = SHADER_EVAL_BAKE;
pass_filter = 0;
need_update = true;
}
BakeManager::~BakeManager()
{
}
bool BakeManager::get_baking()
{
return !object_name.empty();
}
void BakeManager::set(Scene *scene,
const std::string &object_name_,
ShaderEvalType type_,
int pass_filter_)
{
object_name = object_name_;
type = type_;
pass_filter = shader_type_to_pass_filter(type_, pass_filter_);
Pass::add(PASS_BAKE_PRIMITIVE, scene->film->passes);
Pass::add(PASS_BAKE_DIFFERENTIAL, scene->film->passes);
if (type == SHADER_EVAL_UV) {
/* force UV to be available */
Pass::add(PASS_UV, scene->film->passes);
}
/* force use_light_pass to be true if we bake more than just colors */
if (pass_filter & ~BAKE_FILTER_COLOR) {
Pass::add(PASS_LIGHT, scene->film->passes);
}
/* create device and update scene */
scene->film->tag_update(scene);
scene->integrator->tag_update(scene);
need_update = true;
}
void BakeManager::device_update(Device * /*device*/,
DeviceScene *dscene,
Scene *scene,
Progress & /* progress */)
{
if (!need_update)
return;
KernelIntegrator *kintegrator = &dscene->data.integrator;
KernelBake *kbake = &dscene->data.bake;
kbake->type = type;
kbake->pass_filter = pass_filter;
int object_index = 0;
foreach (Object *object, scene->objects) {
const Geometry *geom = object->geometry;
if (object->name == object_name && geom->type == Geometry::MESH) {
kbake->object_index = object_index;
kbake->tri_offset = geom->prim_offset;
kintegrator->aa_samples = aa_samples(scene, object, type);
break;
}
object_index++;
}
need_update = false;
}
void BakeManager::device_free(Device * /*device*/, DeviceScene * /*dscene*/)
{
}
CCL_NAMESPACE_END

View File

@@ -25,23 +25,67 @@
CCL_NAMESPACE_BEGIN
class BakeData {
public:
BakeData(const int object, const size_t tri_offset, const size_t num_pixels);
~BakeData();
void set(int i, int prim, float uv[2], float dudx, float dudy, float dvdx, float dvdy);
void set_null(int i);
int object();
size_t size();
uint4 data(int i);
uint4 differentials(int i);
bool is_valid(int i);
private:
int m_object;
size_t m_tri_offset;
size_t m_num_pixels;
vector<int> m_primitive;
vector<float> m_u;
vector<float> m_v;
vector<float> m_dudx;
vector<float> m_dudy;
vector<float> m_dvdx;
vector<float> m_dvdy;
};
class BakeManager {
public:
BakeManager();
~BakeManager();
void set(Scene *scene, const std::string &object_name, ShaderEvalType type, int pass_filter);
bool get_baking();
void set_baking(const bool value);
BakeData *init(const int object, const size_t tri_offset, const size_t num_pixels);
void set_shader_limit(const size_t x, const size_t y);
bool bake(Device *device,
DeviceScene *dscene,
Scene *scene,
Progress &progress,
ShaderEvalType shader_type,
const int pass_filter,
BakeData *bake_data,
float result[]);
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
void device_free(Device *device, DeviceScene *dscene);
static int shader_type_to_pass_filter(ShaderEvalType type, const int pass_filter);
static int aa_samples(Scene *scene, BakeData *bake_data, ShaderEvalType type);
bool need_update;
size_t total_pixel_samples;
private:
ShaderEvalType type;
int pass_filter;
std::string object_name;
BakeData *m_bake_data;
bool m_is_baking;
size_t m_shader_limit;
};
CCL_NAMESPACE_END

View File

@@ -459,40 +459,6 @@ bool RenderBuffers::get_pass_rect(
return false;
}
bool RenderBuffers::set_pass_rect(PassType type, int components, float *pixels)
{
if (buffer.data() == NULL) {
return false;
}
int pass_offset = 0;
for (size_t j = 0; j < params.passes.size(); j++) {
Pass &pass = params.passes[j];
if (pass.type != type) {
pass_offset += pass.components;
continue;
}
float *out = buffer.data() + pass_offset;
int pass_stride = params.get_passes_size();
int size = params.width * params.height;
assert(pass.components == components);
for (int i = 0; i < size; i++, out += pass_stride, pixels += components) {
for (int j = 0; j < components; j++) {
out[j] = pixels[j];
}
}
return true;
}
return false;
}
/* Display Buffer */
DisplayBuffer::DisplayBuffer(Device *device, bool linear)

View File

@@ -92,7 +92,6 @@ class RenderBuffers {
const string &name, float exposure, int sample, int components, float *pixels);
bool get_denoising_pass_rect(
int offset, float exposure, int sample, int components, float *pixels);
bool set_pass_rect(PassType type, int components, float *pixels);
};
/* Display Buffer
@@ -131,7 +130,7 @@ class DisplayBuffer {
class RenderTile {
public:
typedef enum { PATH_TRACE = (1 << 0), BAKE = (1 << 1), DENOISE = (1 << 2) } Task;
typedef enum { PATH_TRACE = (1 << 0), DENOISE = (1 << 1) } Task;
Task task;
int x, y, w, h;

View File

@@ -196,10 +196,6 @@ void Pass::add(PassType type, vector<Pass> &passes, const char *name)
case PASS_AOV_VALUE:
pass.components = 1;
break;
case PASS_BAKE_PRIMITIVE:
case PASS_BAKE_DIFFERENTIAL:
pass.components = 4;
break;
default:
assert(false);
break;
@@ -390,13 +386,11 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
if (pass.type <= PASS_CATEGORY_MAIN_END) {
kfilm->pass_flag |= pass_flag;
}
else if (pass.type <= PASS_CATEGORY_LIGHT_END) {
else {
assert(pass.type <= PASS_CATEGORY_LIGHT_END);
kfilm->use_light_pass = 1;
kfilm->light_pass_flag |= pass_flag;
}
else {
assert(pass.type <= PASS_CATEGORY_BAKE_END);
}
switch (pass.type) {
case PASS_COMBINED:
@@ -477,13 +471,6 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
kfilm->pass_volume_direct = kfilm->pass_stride;
break;
case PASS_BAKE_PRIMITIVE:
kfilm->pass_bake_primitive = kfilm->pass_stride;
break;
case PASS_BAKE_DIFFERENTIAL:
kfilm->pass_bake_differential = kfilm->pass_stride;
break;
#ifdef WITH_CYCLES_DEBUG
case PASS_BVH_TRAVERSED_NODES:
kfilm->pass_bvh_traversed_nodes = kfilm->pass_stride;

View File

@@ -204,6 +204,10 @@ class ShaderNode : public Node {
{
return false;
}
virtual bool has_object_dependency()
{
return false;
}
virtual bool has_attribute_dependency()
{
return false;

View File

@@ -181,7 +181,6 @@ bool Light::has_contribution(Scene *scene)
LightManager::LightManager()
{
need_update = true;
need_update_background = true;
use_light_visibility = false;
}
@@ -902,7 +901,7 @@ void LightManager::device_update(Device *device,
VLOG(1) << "Total " << scene->lights.size() << " lights.";
device_free(device, dscene, need_update_background);
device_free(device, dscene);
use_light_visibility = false;
@@ -916,11 +915,9 @@ void LightManager::device_update(Device *device,
if (progress.get_cancel())
return;
if (need_update_background) {
device_update_background(device, dscene, scene, progress);
if (progress.get_cancel())
return;
}
device_update_background(device, dscene, scene, progress);
if (progress.get_cancel())
return;
device_update_ies(dscene);
if (progress.get_cancel())
@@ -932,17 +929,14 @@ void LightManager::device_update(Device *device,
}
need_update = false;
need_update_background = false;
}
void LightManager::device_free(Device *, DeviceScene *dscene, const bool free_background)
void LightManager::device_free(Device *, DeviceScene *dscene)
{
dscene->light_distribution.free();
dscene->lights.free();
if (free_background) {
dscene->light_background_marginal_cdf.free();
dscene->light_background_conditional_cdf.free();
}
dscene->light_background_marginal_cdf.free();
dscene->light_background_conditional_cdf.free();
dscene->ies_lights.free();
}
@@ -995,7 +989,6 @@ int LightManager::add_ies(const string &content)
ies_slots[slot]->hash = hash;
need_update = true;
need_update_background = true;
return slot;
}
@@ -1014,7 +1007,6 @@ void LightManager::remove_ies(int slot)
/* If the slot has no more users, update the device to remove it. */
need_update |= (ies_slots[slot]->users == 0);
need_update_background |= need_update;
}
void LightManager::device_update_ies(DeviceScene *dscene)

View File

@@ -88,9 +88,6 @@ class LightManager {
bool use_light_visibility;
bool need_update;
/* Need to update background (including multiple importance map) */
bool need_update_background;
LightManager();
~LightManager();
@@ -100,7 +97,7 @@ class LightManager {
void remove_ies(int slot);
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
void device_free(Device *device, DeviceScene *dscene, const bool free_background = true);
void device_free(Device *device, DeviceScene *dscene);
void tag_update(Scene *scene);

View File

@@ -2166,11 +2166,12 @@ NODE_DEFINE(AnisotropicBsdfNode)
SOCKET_IN_FLOAT(surface_mix_weight, "SurfaceMixWeight", 0.0f, SocketType::SVM_INTERNAL);
static NodeEnum distribution_enum;
distribution_enum.insert("beckmann", CLOSURE_BSDF_MICROFACET_BECKMANN_ID);
distribution_enum.insert("GGX", CLOSURE_BSDF_MICROFACET_GGX_ID);
distribution_enum.insert("Multiscatter GGX", CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID);
distribution_enum.insert("ashikhmin_shirley", CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID);
SOCKET_ENUM(distribution, "Distribution", distribution_enum, CLOSURE_BSDF_MICROFACET_GGX_ID);
distribution_enum.insert("beckmann", CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID);
distribution_enum.insert("GGX", CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID);
distribution_enum.insert("Multiscatter GGX", CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_ID);
distribution_enum.insert("ashikhmin_shirley", CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID);
SOCKET_ENUM(
distribution, "Distribution", distribution_enum, CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID);
SOCKET_IN_VECTOR(tangent, "Tangent", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TANGENT);
@@ -2185,7 +2186,7 @@ NODE_DEFINE(AnisotropicBsdfNode)
AnisotropicBsdfNode::AnisotropicBsdfNode() : BsdfNode(node_type)
{
closure = CLOSURE_BSDF_MICROFACET_GGX_ID;
closure = CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID;
}
void AnisotropicBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes)
@@ -2204,7 +2205,7 @@ void AnisotropicBsdfNode::compile(SVMCompiler &compiler)
{
closure = distribution;
if (closure == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID)
if (closure == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_ID)
BsdfNode::compile(
compiler, input("Roughness"), input("Anisotropy"), input("Rotation"), input("Color"));
else
@@ -2298,7 +2299,7 @@ void GlossyBsdfNode::compile(SVMCompiler &compiler)
if (closure == CLOSURE_BSDF_REFLECTION_ID)
BsdfNode::compile(compiler, NULL, NULL);
else if (closure == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID)
BsdfNode::compile(compiler, input("Roughness"), NULL, NULL, input("Color"));
BsdfNode::compile(compiler, input("Roughness"), NULL, input("Color"));
else
BsdfNode::compile(compiler, input("Roughness"), NULL);
}

View File

@@ -359,6 +359,10 @@ class PointDensityTextureNode : public ShaderNode {
{
return true;
}
bool has_object_dependency()
{
return true;
}
/* Parameters. */
ustring filename;
@@ -892,6 +896,10 @@ class TextureCoordinateNode : public ShaderNode {
{
return true;
}
bool has_object_dependency()
{
return use_transform;
}
float3 normal_osl;
bool from_dupli;

View File

@@ -764,6 +764,10 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
current_shader->has_volume_attribute_dependency = true;
}
if (node->has_object_dependency()) {
current_shader->has_object_dependency = true;
}
if (node->has_integrator_dependency()) {
current_shader->has_integrator_dependency = true;
}
@@ -1138,6 +1142,7 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
shader->has_surface_spatial_varying = false;
shader->has_volume_spatial_varying = false;
shader->has_volume_attribute_dependency = false;
shader->has_object_dependency = false;
shader->has_integrator_dependency = false;
/* generate surface shader */

View File

@@ -410,16 +410,7 @@ bool Session::acquire_tile(RenderTile &rtile, Device *tile_device, uint tile_typ
rtile.num_samples = tile_manager.state.num_samples;
rtile.resolution = tile_manager.state.resolution_divider;
rtile.tile_index = tile->index;
if (tile->state == Tile::DENOISE) {
rtile.task = RenderTile::DENOISE;
}
else if (read_bake_tile_cb) {
rtile.task = RenderTile::BAKE;
}
else {
rtile.task = RenderTile::PATH_TRACE;
}
rtile.task = tile->state == Tile::DENOISE ? RenderTile::DENOISE : RenderTile::PATH_TRACE;
tile_lock.unlock();
@@ -460,20 +451,11 @@ bool Session::acquire_tile(RenderTile &rtile, Device *tile_device, uint tile_typ
rtile.buffers = tile->buffers;
rtile.sample = tile_manager.state.sample;
if (read_bake_tile_cb) {
/* This will read any passes needed as input for baking. */
{
thread_scoped_lock tile_lock(tile_mutex);
read_bake_tile_cb(rtile);
}
rtile.buffers->buffer.copy_to_device();
}
else {
/* This will tag tile as IN PROGRESS in blender-side render pipeline,
* which is needed to highlight currently rendering tile before first
* sample was processed for it. */
update_tile_sample(rtile);
}
/* this will tag tile as IN PROGRESS in blender-side render pipeline,
* which is needed to highlight currently rendering tile before first
* sample was processed for it
*/
update_tile_sample(rtile);
return true;
}
@@ -502,7 +484,6 @@ void Session::release_tile(RenderTile &rtile, const bool need_denoise)
bool delete_tile;
if (tile_manager.finish_tile(rtile.tile_index, need_denoise, delete_tile)) {
/* Finished tile pixels write. */
if (write_render_tile_cb && params.progressive_refine == false) {
write_render_tile_cb(rtile);
}
@@ -513,7 +494,6 @@ void Session::release_tile(RenderTile &rtile, const bool need_denoise)
}
}
else {
/* In progress tile pixels update. */
if (update_render_tile_cb && params.progressive_refine == false) {
update_render_tile_cb(rtile, false);
}

View File

@@ -148,7 +148,6 @@ class Session {
function<void(RenderTile &)> write_render_tile_cb;
function<void(RenderTile &, bool)> update_render_tile_cb;
function<void(RenderTile &)> read_bake_tile_cb;
explicit Session(const SessionParams &params);
~Session();

View File

@@ -206,6 +206,7 @@ Shader::Shader() : Node(node_type)
has_surface_spatial_varying = false;
has_volume_spatial_varying = false;
has_volume_attribute_dependency = false;
has_object_dependency = false;
has_integrator_dependency = false;
has_volume_connected = false;
prev_volume_step_rate = 0.0f;
@@ -217,6 +218,7 @@ Shader::Shader() : Node(node_type)
need_update = true;
need_update_geometry = true;
need_sync_object = false;
}
Shader::~Shader()
@@ -318,11 +320,9 @@ void Shader::tag_update(Scene *scene)
* has use_mis set to false. We are quite close to release now, so
* better to be safe.
*/
if (this == scene->background->get_shader(scene)) {
scene->light_manager->need_update_background = true;
if (scene->light_manager->has_background_light(scene)) {
scene->light_manager->need_update = true;
}
if (this == scene->background->get_shader(scene) &&
scene->light_manager->has_background_light(scene)) {
scene->light_manager->need_update = true;
}
/* quick detection of which kind of shaders we have to avoid loading

View File

@@ -98,6 +98,7 @@ class Shader : public Node {
/* synchronization */
bool need_update;
bool need_update_geometry;
bool need_sync_object;
/* If the shader has only volume components, the surface is assumed to
* be transparent.
@@ -120,6 +121,7 @@ class Shader : public Node {
bool has_surface_spatial_varying;
bool has_volume_spatial_varying;
bool has_volume_attribute_dependency;
bool has_object_dependency;
bool has_integrator_dependency;
/* displacement */

View File

@@ -448,6 +448,10 @@ void SVMCompiler::generate_node(ShaderNode *node, ShaderNodeSet &done)
current_shader->has_volume_attribute_dependency = true;
}
if (node->has_object_dependency()) {
current_shader->has_object_dependency = true;
}
if (node->has_integrator_dependency()) {
current_shader->has_integrator_dependency = true;
}
@@ -859,6 +863,7 @@ void SVMCompiler::compile(Shader *shader, array<int4> &svm_nodes, int index, Sum
shader->has_surface_spatial_varying = false;
shader->has_volume_spatial_varying = false;
shader->has_volume_attribute_dependency = false;
shader->has_object_dependency = false;
shader->has_integrator_dependency = false;
/* generate bump shader */

View File

@@ -57,7 +57,7 @@ struct avxb {
: m256(_mm256_insertf128_ps(_mm256_castps128_ps256(a), b, 1))
{
}
__forceinline operator const __m256 &(void)const
__forceinline operator const __m256 &(void) const
{
return m256;
}

View File

@@ -54,7 +54,7 @@ struct avxi {
__forceinline avxi(const __m256i a) : m256(a)
{
}
__forceinline operator const __m256i &(void)const
__forceinline operator const __m256i &(void) const
{
return m256;
}

View File

@@ -57,7 +57,7 @@ struct sseb {
__forceinline sseb(const __m128 input) : m128(input)
{
}
__forceinline operator const __m128 &(void)const
__forceinline operator const __m128 &(void) const
{
return m128;
}

View File

@@ -57,7 +57,7 @@ struct ssei {
__forceinline ssei(const __m128i a) : m128(a)
{
}
__forceinline operator const __m128i &(void)const
__forceinline operator const __m128i &(void) const
{
return m128;
}

View File

@@ -23,8 +23,8 @@
#include "GHOST_System.h"
#include <chrono>
#include <stdio.h> /* just for printf */
#include <time.h>
#include "GHOST_DisplayManager.h"
#include "GHOST_EventManager.h"
@@ -58,9 +58,12 @@ GHOST_System::~GHOST_System()
GHOST_TUns64 GHOST_System::getMilliSeconds() const
{
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch())
.count();
GHOST_TUns64 millis = ::clock();
if (CLOCKS_PER_SEC != 1000) {
millis *= 1000;
millis /= CLOCKS_PER_SEC;
}
return millis;
}
GHOST_ITimerTask *GHOST_System::installTimer(GHOST_TUns64 delay,

View File

@@ -1063,7 +1063,14 @@ GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType,
}
switch (eventType) {
case GHOST_kEventWindowClose:
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window));
// check for index of mainwindow as it would quit blender without dialog and discard
if ([windowsList count] > 1 &&
window->getCocoaWindow() != [windowsList objectAtIndex:[windowsList count] - 1]) {
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window));
}
else {
handleQuitRequest(); // -> quit dialog
}
break;
case GHOST_kEventWindowActivate:
m_windowManager->setActiveWindow(window);

View File

@@ -25,7 +25,6 @@
#include "GHOST_EventDragnDrop.h"
#include "GHOST_EventKey.h"
#include "GHOST_EventWheel.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
#include "GHOST_ContextEGL.h"
@@ -35,7 +34,7 @@
#include <algorithm>
#include <atomic>
#include <stdexcept>
#include <exception>
#include <thread>
#include <unordered_map>
#include <unordered_set>
@@ -92,13 +91,6 @@ struct data_source_t {
char *buffer_out;
};
struct key_repeat_payload_t {
GHOST_SystemWayland *system;
GHOST_IWindow *window;
GHOST_TKey key;
GHOST_TEventKeyData key_data;
};
struct input_t {
GHOST_SystemWayland *system;
@@ -117,17 +109,6 @@ struct input_t {
struct xkb_context *xkb_context;
struct xkb_state *xkb_state;
struct {
/* Key repetition in character per second. */
int32_t rate;
/* Time (milliseconds) after which to start repeating keys. */
int32_t delay;
/* Timer for key repeats. */
GHOST_ITimerTask *timer = nullptr;
} key_repeat;
struct wl_surface *focus_pointer = nullptr;
struct wl_surface *focus_keyboard = nullptr;
struct wl_data_device *data_device = nullptr;
struct data_offer_t *data_offer_dnd; /* Drag & Drop. */
@@ -140,6 +121,7 @@ struct display_t {
GHOST_SystemWayland *system;
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor = nullptr;
struct xdg_wm_base *xdg_shell = nullptr;
struct wl_shm *shm = nullptr;
@@ -193,11 +175,6 @@ static void display_destroy(display_t *d)
}
}
if (input->keyboard) {
if (input->key_repeat.timer) {
delete static_cast<key_repeat_payload_t *>(input->key_repeat.timer->getUserData());
input->system->removeTimer(input->key_repeat.timer);
input->key_repeat.timer = nullptr;
}
wl_keyboard_destroy(input->keyboard);
}
if (input->xkb_state) {
@@ -288,7 +265,6 @@ static GHOST_TKey xkb_map_gkey(const xkb_keysym_t &sym)
GXMAP(gkey, XKB_KEY_Escape, GHOST_kKeyEsc);
GXMAP(gkey, XKB_KEY_space, GHOST_kKeySpace);
GXMAP(gkey, XKB_KEY_apostrophe, GHOST_kKeyQuote);
GXMAP(gkey, XKB_KEY_comma, GHOST_kKeyComma);
GXMAP(gkey, XKB_KEY_minus, GHOST_kKeyMinus);
GXMAP(gkey, XKB_KEY_plus, GHOST_kKeyPlus);
@@ -318,19 +294,29 @@ static GHOST_TKey xkb_map_gkey(const xkb_keysym_t &sym)
GXMAP(gkey, XKB_KEY_Scroll_Lock, GHOST_kKeyScrollLock);
GXMAP(gkey, XKB_KEY_Left, GHOST_kKeyLeftArrow);
GXMAP(gkey, XKB_KEY_KP_Left, GHOST_kKeyLeftArrow);
GXMAP(gkey, XKB_KEY_Right, GHOST_kKeyRightArrow);
GXMAP(gkey, XKB_KEY_KP_Right, GHOST_kKeyRightArrow);
GXMAP(gkey, XKB_KEY_Up, GHOST_kKeyUpArrow);
GXMAP(gkey, XKB_KEY_KP_Up, GHOST_kKeyUpArrow);
GXMAP(gkey, XKB_KEY_Down, GHOST_kKeyDownArrow);
GXMAP(gkey, XKB_KEY_KP_Down, GHOST_kKeyDownArrow);
GXMAP(gkey, XKB_KEY_Print, GHOST_kKeyPrintScreen);
GXMAP(gkey, XKB_KEY_Pause, GHOST_kKeyPause);
GXMAP(gkey, XKB_KEY_Insert, GHOST_kKeyInsert);
GXMAP(gkey, XKB_KEY_KP_Insert, GHOST_kKeyInsert);
GXMAP(gkey, XKB_KEY_Delete, GHOST_kKeyDelete);
GXMAP(gkey, XKB_KEY_KP_Delete, GHOST_kKeyDelete);
GXMAP(gkey, XKB_KEY_Home, GHOST_kKeyHome);
GXMAP(gkey, XKB_KEY_KP_Home, GHOST_kKeyHome);
GXMAP(gkey, XKB_KEY_End, GHOST_kKeyEnd);
GXMAP(gkey, XKB_KEY_KP_End, GHOST_kKeyEnd);
GXMAP(gkey, XKB_KEY_Page_Up, GHOST_kKeyUpPage);
GXMAP(gkey, XKB_KEY_KP_Page_Up, GHOST_kKeyUpPage);
GXMAP(gkey, XKB_KEY_Page_Down, GHOST_kKeyDownPage);
GXMAP(gkey, XKB_KEY_KP_Page_Down, GHOST_kKeyDownPage);
GXMAP(gkey, XKB_KEY_KP_Decimal, GHOST_kKeyNumpadPeriod);
GXMAP(gkey, XKB_KEY_KP_Enter, GHOST_kKeyNumpadEnter);
@@ -344,8 +330,7 @@ static GHOST_TKey xkb_map_gkey(const xkb_keysym_t &sym)
GXMAP(gkey, XKB_KEY_XF86AudioPrev, GHOST_kKeyMediaFirst);
GXMAP(gkey, XKB_KEY_XF86AudioNext, GHOST_kKeyMediaLast);
default:
GHOST_PRINT("unhandled key: " << std::hex << std::showbase << sym << std::dec << " ("
<< sym << ")" << std::endl);
GHOST_PRINT("unhandled key: " << sym << std::endl);
gkey = GHOST_kKeyUnknown;
}
#undef GXMAP
@@ -444,26 +429,22 @@ static void relative_pointer_relative_motion(
input->x += wl_fixed_to_int(dx);
input->y += wl_fixed_to_int(dy);
GHOST_IWindow *win = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_pointer));
input->system->pushEvent(new GHOST_EventCursor(input->system->getMilliSeconds(),
GHOST_kEventCursorMove,
win,
input->x,
input->y,
GHOST_TABLET_DATA_NONE));
input->system->pushEvent(
new GHOST_EventCursor(input->system->getMilliSeconds(),
GHOST_kEventCursorMove,
input->system->getWindowManager()->getActiveWindow(),
input->x,
input->y,
GHOST_TABLET_DATA_NONE));
}
static const zwp_relative_pointer_v1_listener relative_pointer_listener = {
relative_pointer_relative_motion,
};
relative_pointer_relative_motion};
static void dnd_events(const input_t *const input, const GHOST_TEventType event)
{
const GHOST_TUns64 time = input->system->getMilliSeconds();
GHOST_IWindow *const window = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_pointer));
GHOST_IWindow *const window = input->system->getWindowManager()->getActiveWindow();
for (const std::string &type : mime_preference_order) {
input->system->pushEvent(new GHOST_EventDragnDrop(time,
event,
@@ -669,7 +650,7 @@ static void data_device_drop(void *data, struct wl_data_device * /*wl_data_devic
data_offer->types.begin(),
data_offer->types.end());
auto read_uris = [](input_t *const input,
auto read_uris = [](GHOST_SystemWayland *const system,
data_offer_t *data_offer,
const std::string mime_receive) {
const int x = data_offer->dnd.x;
@@ -683,8 +664,6 @@ static void data_device_drop(void *data, struct wl_data_device * /*wl_data_devic
delete data_offer;
data_offer = nullptr;
GHOST_SystemWayland *const system = input->system;
if (mime_receive == mime_text_uri) {
static constexpr const char *file_proto = "file://";
static constexpr const char *crlf = "\r\n";
@@ -713,12 +692,10 @@ static void data_device_drop(void *data, struct wl_data_device * /*wl_data_devic
malloc((uris[i].size() + 1) * sizeof(GHOST_TUns8)));
memcpy(flist->strings[i], uris[i].data(), uris[i].size() + 1);
}
GHOST_IWindow *win = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_pointer));
system->pushEvent(new GHOST_EventDragnDrop(system->getMilliSeconds(),
GHOST_kEventDraggingDropDone,
GHOST_kDragnDropTypeFilenames,
win,
system->getWindowManager()->getActiveWindow(),
x,
y,
flist));
@@ -730,7 +707,7 @@ static void data_device_drop(void *data, struct wl_data_device * /*wl_data_devic
wl_display_roundtrip(system->display());
};
std::thread read_thread(read_uris, input, data_offer, mime_receive);
std::thread read_thread(read_uris, input->system, data_offer, mime_receive);
read_thread.detach();
}
@@ -784,16 +761,13 @@ static const struct wl_data_device_listener data_device_listener = {
data_device_selection,
};
static void cursor_buffer_release(void *data, struct wl_buffer *wl_buffer)
static void buffer_release(void * /*data*/, struct wl_buffer *wl_buffer)
{
cursor_t *cursor = static_cast<cursor_t *>(data);
wl_buffer_destroy(wl_buffer);
cursor->buffer = nullptr;
}
const struct wl_buffer_listener cursor_buffer_listener = {
cursor_buffer_release,
const struct wl_buffer_listener buffer_listener = {
buffer_release,
};
static void pointer_enter(void *data,
@@ -810,24 +784,17 @@ static void pointer_enter(void *data,
input->pointer_serial = serial;
input->x = wl_fixed_to_int(surface_x);
input->y = wl_fixed_to_int(surface_y);
input->focus_pointer = surface;
input->system->pushEvent(
new GHOST_EventCursor(input->system->getMilliSeconds(),
GHOST_kEventCursorMove,
static_cast<GHOST_WindowWayland *>(wl_surface_get_user_data(surface)),
input->x,
input->y,
GHOST_TABLET_DATA_NONE));
static_cast<GHOST_WindowWayland *>(wl_surface_get_user_data(surface))->activate();
}
static void pointer_leave(void *data,
static void pointer_leave(void * /*data*/,
struct wl_pointer * /*wl_pointer*/,
uint32_t /*serial*/,
struct wl_surface *surface)
{
if (surface != nullptr) {
static_cast<input_t *>(data)->focus_pointer = nullptr;
static_cast<GHOST_WindowWayland *>(wl_surface_get_user_data(surface))->deactivate();
}
}
@@ -839,22 +806,16 @@ static void pointer_motion(void *data,
{
input_t *input = static_cast<input_t *>(data);
GHOST_IWindow *win = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_pointer));
if (!win) {
return;
}
input->x = wl_fixed_to_int(surface_x);
input->y = wl_fixed_to_int(surface_y);
input->system->pushEvent(new GHOST_EventCursor(input->system->getMilliSeconds(),
GHOST_kEventCursorMove,
win,
wl_fixed_to_int(surface_x),
wl_fixed_to_int(surface_y),
GHOST_TABLET_DATA_NONE));
input->system->pushEvent(
new GHOST_EventCursor(input->system->getMilliSeconds(),
GHOST_kEventCursorMove,
input->system->getWindowManager()->getActiveWindow(),
wl_fixed_to_int(surface_x),
wl_fixed_to_int(surface_y),
GHOST_TABLET_DATA_NONE));
}
static void pointer_button(void *data,
@@ -888,12 +849,14 @@ static void pointer_button(void *data,
}
input_t *input = static_cast<input_t *>(data);
GHOST_IWindow *win = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_pointer));
input->data_source->source_serial = serial;
input->buttons.set(ebutton, state == WL_POINTER_BUTTON_STATE_PRESSED);
input->system->pushEvent(new GHOST_EventButton(
input->system->getMilliSeconds(), etype, win, ebutton, GHOST_TABLET_DATA_NONE));
input->system->pushEvent(
new GHOST_EventButton(input->system->getMilliSeconds(),
etype,
input->system->getWindowManager()->getActiveWindow(),
ebutton,
GHOST_TABLET_DATA_NONE));
}
static void pointer_axis(void *data,
@@ -906,10 +869,10 @@ static void pointer_axis(void *data,
return;
}
input_t *input = static_cast<input_t *>(data);
GHOST_IWindow *win = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_pointer));
input->system->pushEvent(
new GHOST_EventWheel(input->system->getMilliSeconds(), win, std::signbit(value) ? +1 : -1));
new GHOST_EventWheel(input->system->getMilliSeconds(),
input->system->getWindowManager()->getActiveWindow(),
std::signbit(value) ? +1 : -1));
}
static const struct wl_pointer_listener pointer_listener = {
@@ -956,15 +919,13 @@ static void keyboard_keymap(
* Notification that this seat's keyboard focus is on a certain
* surface.
*/
static void keyboard_enter(void *data,
static void keyboard_enter(void * /*data*/,
struct wl_keyboard * /*wl_keyboard*/,
uint32_t /*serial*/,
struct wl_surface *surface,
struct wl_surface * /*surface*/,
struct wl_array * /*keys*/)
{
if (surface != nullptr) {
static_cast<input_t *>(data)->focus_keyboard = surface;
}
/* pass */
}
/**
@@ -973,40 +934,12 @@ static void keyboard_enter(void *data,
* Notification that this seat's keyboard focus is no longer on a
* certain surface.
*/
static void keyboard_leave(void *data,
static void keyboard_leave(void * /*data*/,
struct wl_keyboard * /*wl_keyboard*/,
uint32_t /*serial*/,
struct wl_surface *surface)
struct wl_surface * /*surface*/)
{
if (surface != nullptr) {
static_cast<input_t *>(data)->focus_keyboard = nullptr;
}
}
/**
* A version of #xkb_state_key_get_one_sym which returns the key without any modifiers pressed.
* Needed because #GHOST_TKey uses these values as key-codes.
*/
static xkb_keysym_t xkb_state_key_get_one_sym_without_modifiers(struct xkb_state *xkb_state,
xkb_keycode_t key)
{
/* Use an empty keyboard state to access key symbol without modifiers. */
xkb_state_get_keymap(xkb_state);
struct xkb_keymap *keymap = xkb_state_get_keymap(xkb_state);
struct xkb_state *xkb_state_empty = xkb_state_new(keymap);
/* Enable number-lock. */
{
const xkb_mod_index_t mod2 = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_NUM);
const xkb_mod_index_t num = xkb_keymap_mod_get_index(keymap, "NumLock");
if (num != XKB_MOD_INVALID && mod2 != XKB_MOD_INVALID) {
xkb_state_update_mask(xkb_state_empty, (1 << mod2), 0, (1 << num), 0, 0, 0);
}
}
const xkb_keysym_t sym = xkb_state_key_get_one_sym(xkb_state_empty, key);
xkb_state_unref(xkb_state_empty);
return sym;
/* pass */
}
static void keyboard_key(void *data,
@@ -1028,21 +961,12 @@ static void keyboard_key(void *data,
break;
}
const xkb_keysym_t sym = xkb_state_key_get_one_sym_without_modifiers(input->xkb_state, key + 8);
const xkb_keysym_t sym = xkb_state_key_get_one_sym(input->xkb_state, key + 8);
if (sym == XKB_KEY_NoSymbol) {
return;
}
const GHOST_TKey gkey = xkb_map_gkey(sym);
/* Delete previous timer. */
if (xkb_keymap_key_repeats(xkb_state_get_keymap(input->xkb_state), key + 8) &&
input->key_repeat.timer) {
delete static_cast<key_repeat_payload_t *>(input->key_repeat.timer->getUserData());
input->system->removeTimer(input->key_repeat.timer);
input->key_repeat.timer = nullptr;
}
GHOST_TEventKeyData key_data;
if (etype == GHOST_kEventKeyDown) {
@@ -1054,38 +978,13 @@ static void keyboard_key(void *data,
}
input->data_source->source_serial = serial;
GHOST_IWindow *win = static_cast<GHOST_WindowWayland *>(
wl_surface_get_user_data(input->focus_keyboard));
input->system->pushEvent(new GHOST_EventKey(
input->system->getMilliSeconds(), etype, win, gkey, '\0', key_data.utf8_buf, false));
/* Start timer for repeating key, if applicable. */
if (input->key_repeat.rate > 0 &&
xkb_keymap_key_repeats(xkb_state_get_keymap(input->xkb_state), key + 8) &&
etype == GHOST_kEventKeyDown) {
key_repeat_payload_t *payload = new key_repeat_payload_t({
.system = input->system,
.window = win,
.key = gkey,
.key_data = key_data,
});
auto cb = [](GHOST_ITimerTask *task, GHOST_TUns64 /*time*/) {
struct key_repeat_payload_t *payload = static_cast<key_repeat_payload_t *>(
task->getUserData());
payload->system->pushEvent(new GHOST_EventKey(payload->system->getMilliSeconds(),
GHOST_kEventKeyDown,
payload->window,
payload->key,
'\0',
payload->key_data.utf8_buf,
true));
};
input->key_repeat.timer = input->system->installTimer(
input->key_repeat.delay, 1000 / input->key_repeat.rate, cb, payload);
}
input->system->pushEvent(new GHOST_EventKey(input->system->getMilliSeconds(),
etype,
input->system->getWindowManager()->getActiveWindow(),
gkey,
'\0',
key_data.utf8_buf,
false));
}
static void keyboard_modifiers(void *data,
@@ -1105,24 +1004,12 @@ static void keyboard_modifiers(void *data,
group);
}
static void keyboard_repeat_info(void *data,
struct wl_keyboard * /*wl_keyboard*/,
int32_t rate,
int32_t delay)
{
input_t *input = static_cast<input_t *>(data);
input->key_repeat.rate = rate;
input->key_repeat.delay = delay;
}
static const struct wl_keyboard_listener keyboard_listener = {
keyboard_keymap,
keyboard_enter,
keyboard_leave,
keyboard_key,
keyboard_modifiers,
keyboard_repeat_info,
};
static void seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t capabilities)
@@ -1255,7 +1142,7 @@ static void global_add(void *data,
input->relative_pointer = nullptr;
input->locked_pointer = nullptr;
input->seat = static_cast<wl_seat *>(
wl_registry_bind(wl_registry, name, &wl_seat_interface, 4));
wl_registry_bind(wl_registry, name, &wl_seat_interface, 2));
display->inputs.push_back(input);
wl_seat_add_listener(input->seat, &seat_listener, input);
}
@@ -1352,18 +1239,10 @@ GHOST_SystemWayland::~GHOST_SystemWayland()
display_destroy(d);
}
bool GHOST_SystemWayland::processEvents(bool waitForEvent)
bool GHOST_SystemWayland::processEvents(bool /*waitForEvent*/)
{
const bool fired = getTimerManager()->fireTimers(getMilliSeconds());
if (waitForEvent) {
wl_display_dispatch(d->display);
}
else {
wl_display_roundtrip(d->display);
}
return fired || (getEventManager()->getNumEvents() > 0);
wl_display_dispatch(d->display);
return true;
}
int GHOST_SystemWayland::toggleConsole(int /*action*/)
@@ -1452,7 +1331,7 @@ GHOST_TUns8 GHOST_SystemWayland::getNumDisplays() const
GHOST_TSuccess GHOST_SystemWayland::getCursorPosition(GHOST_TInt32 &x, GHOST_TInt32 &y) const
{
if (!d->inputs.empty() && (d->inputs[0]->focus_pointer != nullptr)) {
if (getWindowManager()->getActiveWindow() != nullptr && !d->inputs.empty()) {
x = d->inputs[0]->x;
y = d->inputs[0]->y;
return GHOST_kSuccess;
@@ -1665,7 +1544,7 @@ GHOST_TSuccess GHOST_SystemWayland::setCustomCursorShape(GHOST_TUns8 *bitmap,
wl_shm_pool_destroy(pool);
close(fd);
wl_buffer_add_listener(buffer, &cursor_buffer_listener, cursor);
wl_buffer_add_listener(buffer, &buffer_listener, nullptr);
static constexpr uint32_t black = 0xFF000000;
static constexpr uint32_t white = 0xFFFFFFFF;
@@ -1714,17 +1593,15 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorVisibility(bool visible)
return GHOST_kFailure;
}
input_t *input = d->inputs[0];
cursor_t *cursor = &input->cursor;
cursor_t *cursor = &d->inputs[0]->cursor;
if (visible) {
if (!cursor->visible) {
set_cursor_buffer(input, cursor->buffer);
set_cursor_buffer(d->inputs[0], d->inputs[0]->cursor.buffer);
}
}
else {
if (cursor->visible) {
set_cursor_buffer(input, nullptr);
set_cursor_buffer(d->inputs[0], nullptr);
}
}

View File

@@ -2172,24 +2172,14 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
else if (owner == None)
return (NULL);
/* Restore events so copy doesn't swallow other event types (keyboard/mouse). */
vector<XEvent> restore_events;
while (1) {
/* only get an event if xcout() is doing something */
bool restore_this_event = false;
if (context != XCLIB_XCOUT_NONE) {
if (context != XCLIB_XCOUT_NONE)
XNextEvent(m_display, &evt);
restore_this_event = (evt.type != SelectionNotify);
}
/* fetch the selection, or part of it */
getClipboard_xcout(&evt, sseln, target, &sel_buf, &sel_len, &context);
if (restore_this_event) {
restore_events.push_back(evt);
}
/* fallback is needed. set XA_STRING to target and restart the loop. */
if (context == XCLIB_XCOUT_FALLBACK) {
context = XCLIB_XCOUT_NONE;
@@ -2218,11 +2208,6 @@ GHOST_TUns8 *GHOST_SystemX11::getClipboard(bool selection) const
break;
}
while (!restore_events.empty()) {
XPutBackEvent(m_display, &restore_events.back());
restore_events.pop_back();
}
if (sel_len) {
/* only print the buffer out, and free it, if it's not
* empty

View File

@@ -465,14 +465,7 @@ void GHOST_XrContext::startSession(const GHOST_XrSessionBeginInfo *begin_info)
void GHOST_XrContext::endSession()
{
if (m_session) {
if (m_session->isRunning()) {
m_session->requestEnd();
}
else {
m_session = nullptr;
}
}
m_session->requestEnd();
}
bool GHOST_XrContext::isSessionRunning() const

View File

@@ -203,17 +203,13 @@ void GHOST_XrSession::requestEnd()
xrRequestExitSession(m_oxr->session);
}
void GHOST_XrSession::beginSession()
{
XrSessionBeginInfo begin_info = {XR_TYPE_SESSION_BEGIN_INFO};
begin_info.primaryViewConfigurationType = m_oxr->view_type;
CHECK_XR(xrBeginSession(m_oxr->session, &begin_info), "Failed to cleanly begin the VR session.");
}
void GHOST_XrSession::endSession()
void GHOST_XrSession::end()
{
assert(m_oxr->session != XR_NULL_HANDLE);
CHECK_XR(xrEndSession(m_oxr->session), "Failed to cleanly end the VR session.");
unbindGraphicsContext();
m_draw_info = nullptr;
}
GHOST_XrSession::LifeExpectancy GHOST_XrSession::handleStateChangeEvent(
@@ -226,11 +222,16 @@ GHOST_XrSession::LifeExpectancy GHOST_XrSession::handleStateChangeEvent(
switch (lifecycle->state) {
case XR_SESSION_STATE_READY: {
beginSession();
XrSessionBeginInfo begin_info = {XR_TYPE_SESSION_BEGIN_INFO};
begin_info.primaryViewConfigurationType = m_oxr->view_type;
CHECK_XR(xrBeginSession(m_oxr->session, &begin_info),
"Failed to cleanly begin the VR session.");
break;
}
case XR_SESSION_STATE_STOPPING:
endSession();
/* Runtime will change state to STATE_EXITING, don't destruct session yet. */
end();
break;
case XR_SESSION_STATE_EXITING:
case XR_SESSION_STATE_LOSS_PENDING:

View File

@@ -68,8 +68,7 @@ class GHOST_XrSession {
std::unique_ptr<GHOST_XrDrawInfo> m_draw_info;
void initSystem();
void beginSession();
void endSession();
void end();
void bindGraphicsContext();

View File

@@ -53,14 +53,6 @@ if(WIN32 AND NOT UNIX)
mmap_win.h
)
list(APPEND INC_SYS
${PTHREADS_INC}
)
list(APPEND LIB
${PTHREADS_LIBRARIES}
)
endif()
# Jemalloc 5.0.0+ needs extra configuration.

View File

@@ -145,6 +145,14 @@ extern void *(*MEM_mallocN_aligned)(size_t len,
const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(3);
/**
* Same as callocN, clears memory and uses mmap (disk cached) if supported.
* Can be free'd with MEM_freeN as usual.
* */
extern void *(*MEM_mapallocN)(size_t len,
const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);
/** Print a list of the names and sizes of all allocated memory
* blocks. as a python dict for easy investigation */
extern void (*MEM_printmemlist_pydict)(void);
@@ -168,11 +176,20 @@ extern void (*MEM_set_error_callback)(void (*func)(const char *));
* @retval true for correct memory, false for corrupted memory. */
extern bool (*MEM_consistency_check)(void);
/** Set thread locking functions for safe memory allocation from multiple
* threads, pass NULL pointers to disable thread locking again. */
extern void (*MEM_set_lock_callback)(void (*lock)(void), void (*unlock)(void));
/** Attempt to enforce OSX (or other OS's) to have malloc and stack nonzero */
extern void (*MEM_set_memory_debug)(void);
/** Memory usage stats. */
/**
* Memory usage stats
* - MEM_get_memory_in_use is all memory
* - MEM_get_mapped_memory_in_use is a subset of all memory */
extern size_t (*MEM_get_memory_in_use)(void);
/** Get mapped memory usage. */
extern size_t (*MEM_get_mapped_memory_in_use)(void);
/** Get amount of memory blocks in use. */
extern unsigned int (*MEM_get_memory_blocks_in_use)(void);

View File

@@ -21,24 +21,24 @@
#include "../MEM_guardedalloc.h"
#include <new>
void *operator new(size_t size, const char *str);
void *operator new[](size_t size, const char *str);
void *operator new(size_t size, const char *str) throw(std::bad_alloc);
void *operator new[](size_t size, const char *str) throw(std::bad_alloc);
/* not default but can be used when needing to set a string */
void *operator new(size_t size, const char *str)
void *operator new(size_t size, const char *str) throw(std::bad_alloc)
{
return MEM_mallocN(size, str);
}
void *operator new[](size_t size, const char *str)
void *operator new[](size_t size, const char *str) throw(std::bad_alloc)
{
return MEM_mallocN(size, str);
}
void *operator new(size_t size)
void *operator new(size_t size) throw(std::bad_alloc)
{
return MEM_mallocN(size, "C++/anonymous");
}
void *operator new[](size_t size)
void *operator new[](size_t size) throw(std::bad_alloc)
{
return MEM_mallocN(size, "C++/anonymous[]");
}

View File

@@ -48,14 +48,18 @@ void *(*MEM_malloc_arrayN)(size_t len, size_t size, const char *str) = MEM_lockf
void *(*MEM_mallocN_aligned)(size_t len,
size_t alignment,
const char *str) = MEM_lockfree_mallocN_aligned;
void *(*MEM_mapallocN)(size_t len, const char *str) = MEM_lockfree_mapallocN;
void (*MEM_printmemlist_pydict)(void) = MEM_lockfree_printmemlist_pydict;
void (*MEM_printmemlist)(void) = MEM_lockfree_printmemlist;
void (*MEM_callbackmemlist)(void (*func)(void *)) = MEM_lockfree_callbackmemlist;
void (*MEM_printmemlist_stats)(void) = MEM_lockfree_printmemlist_stats;
void (*MEM_set_error_callback)(void (*func)(const char *)) = MEM_lockfree_set_error_callback;
bool (*MEM_consistency_check)(void) = MEM_lockfree_consistency_check;
void (*MEM_set_lock_callback)(void (*lock)(void),
void (*unlock)(void)) = MEM_lockfree_set_lock_callback;
void (*MEM_set_memory_debug)(void) = MEM_lockfree_set_memory_debug;
size_t (*MEM_get_memory_in_use)(void) = MEM_lockfree_get_memory_in_use;
size_t (*MEM_get_mapped_memory_in_use)(void) = MEM_lockfree_get_mapped_memory_in_use;
unsigned int (*MEM_get_memory_blocks_in_use)(void) = MEM_lockfree_get_memory_blocks_in_use;
void (*MEM_reset_peak_memory)(void) = MEM_lockfree_reset_peak_memory;
size_t (*MEM_get_peak_memory)(void) = MEM_lockfree_get_peak_memory;
@@ -107,14 +111,17 @@ void MEM_use_guarded_allocator(void)
MEM_mallocN = MEM_guarded_mallocN;
MEM_malloc_arrayN = MEM_guarded_malloc_arrayN;
MEM_mallocN_aligned = MEM_guarded_mallocN_aligned;
MEM_mapallocN = MEM_guarded_mapallocN;
MEM_printmemlist_pydict = MEM_guarded_printmemlist_pydict;
MEM_printmemlist = MEM_guarded_printmemlist;
MEM_callbackmemlist = MEM_guarded_callbackmemlist;
MEM_printmemlist_stats = MEM_guarded_printmemlist_stats;
MEM_set_error_callback = MEM_guarded_set_error_callback;
MEM_consistency_check = MEM_guarded_consistency_check;
MEM_set_lock_callback = MEM_guarded_set_lock_callback;
MEM_set_memory_debug = MEM_guarded_set_memory_debug;
MEM_get_memory_in_use = MEM_guarded_get_memory_in_use;
MEM_get_mapped_memory_in_use = MEM_guarded_get_mapped_memory_in_use;
MEM_get_memory_blocks_in_use = MEM_guarded_get_memory_blocks_in_use;
MEM_reset_peak_memory = MEM_guarded_reset_peak_memory;
MEM_get_peak_memory = MEM_guarded_get_peak_memory;

View File

@@ -28,8 +28,6 @@
#include <string.h> /* memcpy */
#include <sys/types.h>
#include <pthread.h>
#include "MEM_guardedalloc.h"
/* to ensure strict conversions */
@@ -52,6 +50,17 @@
//#define DEBUG_MEMCOUNTER
/* Only for debugging:
* defining DEBUG_THREADS will enable check whether memory manager
* is locked with a mutex when allocation is called from non-main
* thread.
*
* This helps troubleshooting memory issues caused by the fact
* guarded allocator is not thread-safe, however this check will
* fail to check allocations from openmp threads.
*/
//#define DEBUG_THREADS
/* Only for debugging:
* Defining DEBUG_BACKTRACE will store a backtrace from where
* memory block was allocated and print this trace for all
@@ -95,7 +104,7 @@ typedef struct MemHead {
const char *name;
const char *nextname;
int tag2;
short pad1;
short mmap; /* if true, memory was mmapped */
short alignment; /* if non-zero aligned alloc was used
* and alignment is stored here.
*/
@@ -115,6 +124,24 @@ typedef struct MemHead {
typedef MemHead MemHeadAligned;
/* for openmp threading asserts, saves time troubleshooting
* we may need to extend this if blender code starts using MEM_
* functions inside OpenMP correctly with omp_set_lock() */
#if 0 /* disable for now, only use to debug openmp code which doesn lock threads for malloc */
# if defined(_OPENMP) && defined(DEBUG)
# include <assert.h>
# include <omp.h>
# define DEBUG_OMP_MALLOC
# endif
#endif
#ifdef DEBUG_THREADS
# include <assert.h>
# include <pthread.h>
static pthread_t mainid;
#endif
#ifdef DEBUG_BACKTRACE
# if defined(__linux__) || defined(__APPLE__)
# include <execinfo.h>
@@ -160,11 +187,13 @@ static const char *check_memlist(MemHead *memh);
/* --------------------------------------------------------------------- */
static unsigned int totblock = 0;
static size_t mem_in_use = 0, peak_mem = 0;
static size_t mem_in_use = 0, mmap_in_use = 0, peak_mem = 0;
static volatile struct localListBase _membase;
static volatile struct localListBase *membase = &_membase;
static void (*error_callback)(const char *) = NULL;
static void (*thread_lock_callback)(void) = NULL;
static void (*thread_unlock_callback)(void) = NULL;
static bool malloc_debug_memset = false;
@@ -204,16 +233,40 @@ print_error(const char *str, ...)
fputs(buf, stderr);
}
static pthread_mutex_t thread_lock = PTHREAD_MUTEX_INITIALIZER;
static void mem_lock_thread(void)
{
pthread_mutex_lock(&thread_lock);
#ifdef DEBUG_THREADS
static int initialized = 0;
if (initialized == 0) {
/* assume first allocation happens from main thread */
mainid = pthread_self();
initialized = 1;
}
if (!pthread_equal(pthread_self(), mainid) && thread_lock_callback == NULL) {
assert(!"Memory function is called from non-main thread without lock");
}
#endif
#ifdef DEBUG_OMP_MALLOC
assert(omp_in_parallel() == 0);
#endif
if (thread_lock_callback)
thread_lock_callback();
}
static void mem_unlock_thread(void)
{
pthread_mutex_unlock(&thread_lock);
#ifdef DEBUG_THREADS
if (!pthread_equal(pthread_self(), mainid) && thread_lock_callback == NULL) {
assert(!"Thread lock was removed while allocation from thread is in progress");
}
#endif
if (thread_unlock_callback)
thread_unlock_callback();
}
bool MEM_guarded_consistency_check(void)
@@ -234,6 +287,12 @@ void MEM_guarded_set_error_callback(void (*func)(const char *))
error_callback = func;
}
void MEM_guarded_set_lock_callback(void (*lock)(void), void (*unlock)(void))
{
thread_lock_callback = lock;
thread_unlock_callback = unlock;
}
void MEM_guarded_set_memory_debug(void)
{
malloc_debug_memset = true;
@@ -261,8 +320,10 @@ void *MEM_guarded_dupallocN(const void *vmemh)
memh--;
#ifndef DEBUG_MEMDUPLINAME
if (LIKELY(memh->alignment == 0))
newp = MEM_guarded_mallocN(memh->len, "dupli_alloc");
if (UNLIKELY(memh->mmap))
newp = MEM_guarded_mapallocN(memh->len, "dupli_mapalloc");
else if (LIKELY(memh->alignment == 0))
newp = MEM_guarded_mapallocN(memh->len, "dupli_mapalloc");
else
newp = MEM_guarded_mallocN_aligned(memh->len, (size_t)memh->alignment, "dupli_alloc");
@@ -273,7 +334,11 @@ void *MEM_guarded_dupallocN(const void *vmemh)
MemHead *nmemh;
char *name = malloc(strlen(memh->name) + 24);
if (LIKELY(memh->alignment == 0)) {
if (UNLIKELY(memh->mmap)) {
sprintf(name, "%s %s", "dupli_mapalloc", memh->name);
newp = MEM_guarded_mapallocN(memh->len, name);
}
else if (LIKELY(memh->alignment == 0)) {
sprintf(name, "%s %s", "dupli_alloc", memh->name);
newp = MEM_guarded_mallocN(memh->len, name);
}
@@ -413,7 +478,7 @@ static void make_memhead_header(MemHead *memh, size_t len, const char *str)
memh->name = str;
memh->nextname = NULL;
memh->len = len;
memh->pad1 = 0;
memh->mmap = 0;
memh->alignment = 0;
memh->tag2 = MEMTAG2;
@@ -581,6 +646,58 @@ void *MEM_guarded_calloc_arrayN(size_t len, size_t size, const char *str)
return MEM_guarded_callocN(total_size, str);
}
/* note; mmap returns zero'd memory */
void *MEM_guarded_mapallocN(size_t len, const char *str)
{
MemHead *memh;
/* on 64 bit, simply use calloc instead, as mmap does not support
* allocating > 4 GB on Windows. the only reason mapalloc exists
* is to get around address space limitations in 32 bit OSes. */
if (sizeof(void *) >= 8)
return MEM_guarded_callocN(len, str);
len = SIZET_ALIGN_4(len);
#if defined(WIN32)
/* our windows mmap implementation is not thread safe */
mem_lock_thread();
#endif
memh = mmap(NULL,
len + sizeof(MemHead) + sizeof(MemTail),
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANON,
-1,
0);
#if defined(WIN32)
mem_unlock_thread();
#endif
if (memh != (MemHead *)-1) {
make_memhead_header(memh, len, str);
memh->mmap = 1;
atomic_add_and_fetch_z(&mmap_in_use, len);
mem_lock_thread();
peak_mem = mmap_in_use > peak_mem ? mmap_in_use : peak_mem;
mem_unlock_thread();
#ifdef DEBUG_MEMCOUNTER
if (_mallocn_count == DEBUG_MEMCOUNTER_ERROR_VAL)
memcount_raise(__func__);
memh->_count = _mallocn_count++;
#endif
return (++memh);
}
else {
print_error(
"Mapalloc returns null, fallback to regular malloc: "
"len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
(unsigned int)mmap_in_use);
return MEM_guarded_callocN(len, str);
}
}
/* Memory statistics print */
typedef struct MemPrintBlock {
const char *name;
@@ -648,7 +765,7 @@ void MEM_guarded_printmemlist_stats(void)
pb++;
#ifdef USE_MALLOC_USABLE_SIZE
if (membl->alignment == 0) {
if (!membl->mmap && membl->alignment == 0) {
mem_in_use_slop += (sizeof(MemHead) + sizeof(MemTail) + malloc_usable_size((void *)membl)) -
membl->len;
}
@@ -981,13 +1098,27 @@ static void rem_memblock(MemHead *memh)
free((char *)memh->name);
#endif
if (UNLIKELY(malloc_debug_memset && memh->len))
memset(memh + 1, 255, memh->len);
if (LIKELY(memh->alignment == 0)) {
free(memh);
if (memh->mmap) {
atomic_sub_and_fetch_z(&mmap_in_use, memh->len);
#if defined(WIN32)
/* our windows mmap implementation is not thread safe */
mem_lock_thread();
#endif
if (munmap(memh, memh->len + sizeof(MemHead) + sizeof(MemTail)))
printf("Couldn't unmap memory %s\n", memh->name);
#if defined(WIN32)
mem_unlock_thread();
#endif
}
else {
aligned_free(MEMHEAD_REAL_PTR(memh));
if (UNLIKELY(malloc_debug_memset && memh->len))
memset(memh + 1, 255, memh->len);
if (LIKELY(memh->alignment == 0)) {
free(memh);
}
else {
aligned_free(MEMHEAD_REAL_PTR(memh));
}
}
}
@@ -1139,6 +1270,17 @@ size_t MEM_guarded_get_memory_in_use(void)
return _mem_in_use;
}
size_t MEM_guarded_get_mapped_memory_in_use(void)
{
size_t _mmap_in_use;
mem_lock_thread();
_mmap_in_use = mmap_in_use;
mem_unlock_thread();
return _mmap_in_use;
}
unsigned int MEM_guarded_get_memory_blocks_in_use(void)
{
unsigned int _totblock;

View File

@@ -24,6 +24,13 @@
#ifndef __MALLOCN_INTERN_H__
#define __MALLOCN_INTERN_H__
/* mmap exception */
#if defined(WIN32)
# include "mmap_win.h"
#else
# include <sys/mman.h>
#endif
#ifdef __GNUC__
# define UNUSED(x) UNUSED_##x __attribute__((__unused__))
#else
@@ -133,14 +140,19 @@ void *MEM_lockfree_mallocN_aligned(size_t len,
size_t alignment,
const char *UNUSED(str)) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(3);
void *MEM_lockfree_mapallocN(size_t len,
const char *UNUSED(str)) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);
void MEM_lockfree_printmemlist_pydict(void);
void MEM_lockfree_printmemlist(void);
void MEM_lockfree_callbackmemlist(void (*func)(void *));
void MEM_lockfree_printmemlist_stats(void);
void MEM_lockfree_set_error_callback(void (*func)(const char *));
bool MEM_lockfree_consistency_check(void);
void MEM_lockfree_set_lock_callback(void (*lock)(void), void (*unlock)(void));
void MEM_lockfree_set_memory_debug(void);
size_t MEM_lockfree_get_memory_in_use(void);
size_t MEM_lockfree_get_mapped_memory_in_use(void);
unsigned int MEM_lockfree_get_memory_blocks_in_use(void);
void MEM_lockfree_reset_peak_memory(void);
size_t MEM_lockfree_get_peak_memory(void) ATTR_WARN_UNUSED_RESULT;
@@ -176,14 +188,19 @@ void *MEM_guarded_mallocN_aligned(size_t len,
size_t alignment,
const char *UNUSED(str)) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(3);
void *MEM_guarded_mapallocN(size_t len,
const char *UNUSED(str)) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);
void MEM_guarded_printmemlist_pydict(void);
void MEM_guarded_printmemlist(void);
void MEM_guarded_callbackmemlist(void (*func)(void *));
void MEM_guarded_printmemlist_stats(void);
void MEM_guarded_set_error_callback(void (*func)(const char *));
bool MEM_guarded_consistency_check(void);
void MEM_guarded_set_lock_callback(void (*lock)(void), void (*unlock)(void));
void MEM_guarded_set_memory_debug(void);
size_t MEM_guarded_get_memory_in_use(void);
size_t MEM_guarded_get_mapped_memory_in_use(void);
unsigned int MEM_guarded_get_memory_blocks_in_use(void);
void MEM_guarded_reset_peak_memory(void);
size_t MEM_guarded_get_peak_memory(void) ATTR_WARN_UNUSED_RESULT;

View File

@@ -44,18 +44,22 @@ typedef struct MemHeadAligned {
} MemHeadAligned;
static unsigned int totblock = 0;
static size_t mem_in_use = 0, peak_mem = 0;
static size_t mem_in_use = 0, mmap_in_use = 0, peak_mem = 0;
static bool malloc_debug_memset = false;
static void (*error_callback)(const char *) = NULL;
static void (*thread_lock_callback)(void) = NULL;
static void (*thread_unlock_callback)(void) = NULL;
enum {
MEMHEAD_ALIGN_FLAG = 1,
MEMHEAD_MMAP_FLAG = 1,
MEMHEAD_ALIGN_FLAG = 2,
};
#define MEMHEAD_FROM_PTR(ptr) (((MemHead *)ptr) - 1)
#define PTR_FROM_MEMHEAD(memhead) (memhead + 1)
#define MEMHEAD_ALIGNED_FROM_PTR(ptr) (((MemHeadAligned *)ptr) - 1)
#define MEMHEAD_IS_MMAP(memhead) ((memhead)->len & (size_t)MEMHEAD_MMAP_FLAG)
#define MEMHEAD_IS_ALIGNED(memhead) ((memhead)->len & (size_t)MEMHEAD_ALIGN_FLAG)
/* Uncomment this to have proper peak counter. */
@@ -89,10 +93,24 @@ print_error(const char *str, ...)
}
}
#if defined(WIN32)
static void mem_lock_thread(void)
{
if (thread_lock_callback)
thread_lock_callback();
}
static void mem_unlock_thread(void)
{
if (thread_unlock_callback)
thread_unlock_callback();
}
#endif
size_t MEM_lockfree_allocN_len(const void *vmemh)
{
if (vmemh) {
return MEMHEAD_FROM_PTR(vmemh)->len & ~((size_t)(MEMHEAD_ALIGN_FLAG));
return MEMHEAD_FROM_PTR(vmemh)->len & ~((size_t)(MEMHEAD_MMAP_FLAG | MEMHEAD_ALIGN_FLAG));
}
else {
return 0;
@@ -115,15 +133,29 @@ void MEM_lockfree_freeN(void *vmemh)
atomic_sub_and_fetch_u(&totblock, 1);
atomic_sub_and_fetch_z(&mem_in_use, len);
if (UNLIKELY(malloc_debug_memset && len)) {
memset(memh + 1, 255, len);
}
if (UNLIKELY(MEMHEAD_IS_ALIGNED(memh))) {
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
aligned_free(MEMHEAD_REAL_PTR(memh_aligned));
if (MEMHEAD_IS_MMAP(memh)) {
atomic_sub_and_fetch_z(&mmap_in_use, len);
#if defined(WIN32)
/* our windows mmap implementation is not thread safe */
mem_lock_thread();
#endif
if (munmap(memh, len + sizeof(MemHead)))
printf("Couldn't unmap memory\n");
#if defined(WIN32)
mem_unlock_thread();
#endif
}
else {
free(memh);
if (UNLIKELY(malloc_debug_memset && len)) {
memset(memh + 1, 255, len);
}
if (UNLIKELY(MEMHEAD_IS_ALIGNED(memh))) {
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
aligned_free(MEMHEAD_REAL_PTR(memh_aligned));
}
else {
free(memh);
}
}
}
@@ -133,7 +165,10 @@ void *MEM_lockfree_dupallocN(const void *vmemh)
if (vmemh) {
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
const size_t prev_size = MEM_lockfree_allocN_len(vmemh);
if (UNLIKELY(MEMHEAD_IS_ALIGNED(memh))) {
if (UNLIKELY(MEMHEAD_IS_MMAP(memh))) {
newp = MEM_lockfree_mapallocN(prev_size, "dupli_mapalloc");
}
else if (UNLIKELY(MEMHEAD_IS_ALIGNED(memh))) {
MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh);
newp = MEM_lockfree_mallocN_aligned(
prev_size, (size_t)memh_aligned->alignment, "dupli_malloc");
@@ -362,6 +397,47 @@ void *MEM_lockfree_mallocN_aligned(size_t len, size_t alignment, const char *str
return NULL;
}
void *MEM_lockfree_mapallocN(size_t len, const char *str)
{
MemHead *memh;
/* on 64 bit, simply use calloc instead, as mmap does not support
* allocating > 4 GB on Windows. the only reason mapalloc exists
* is to get around address space limitations in 32 bit OSes. */
if (sizeof(void *) >= 8)
return MEM_lockfree_callocN(len, str);
len = SIZET_ALIGN_4(len);
#if defined(WIN32)
/* our windows mmap implementation is not thread safe */
mem_lock_thread();
#endif
memh = mmap(NULL, len + sizeof(MemHead), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
#if defined(WIN32)
mem_unlock_thread();
#endif
if (memh != (MemHead *)-1) {
memh->len = len | (size_t)MEMHEAD_MMAP_FLAG;
atomic_add_and_fetch_u(&totblock, 1);
atomic_add_and_fetch_z(&mem_in_use, len);
atomic_add_and_fetch_z(&mmap_in_use, len);
update_maximum(&peak_mem, mem_in_use);
update_maximum(&peak_mem, mmap_in_use);
return PTR_FROM_MEMHEAD(memh);
}
print_error(
"Mapalloc returns null, fallback to regular malloc: "
"len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
(unsigned int)mmap_in_use);
return MEM_lockfree_callocN(len, str);
}
void MEM_lockfree_printmemlist_pydict(void)
{
}
@@ -400,6 +476,12 @@ bool MEM_lockfree_consistency_check(void)
return true;
}
void MEM_lockfree_set_lock_callback(void (*lock)(void), void (*unlock)(void))
{
thread_lock_callback = lock;
thread_unlock_callback = unlock;
}
void MEM_lockfree_set_memory_debug(void)
{
malloc_debug_memset = true;
@@ -410,6 +492,11 @@ size_t MEM_lockfree_get_memory_in_use(void)
return mem_in_use;
}
size_t MEM_lockfree_get_mapped_memory_in_use(void)
{
return mmap_in_use;
}
unsigned int MEM_lockfree_get_memory_blocks_in_use(void)
{
return totblock;

Some files were not shown because too many files have changed in this diff Show More