Build: Library updates for 4.1

Update libraries to match VFX platform 2024, and a few other upgrades to
latest versions.

boost 1.82.0
deflate 1.18 (new)
ffi 3.4.4
freeglut (deleted)
ispc 1.12.1
llvm 17.0.6
materialx 1.38.8
mesa 23.3.0
numpy 1.24.3
opencolorio 2.3.0
openexr 3.2.1
openimageio 2.5.6.0
opensubdiv 3.6.0
openvdb 11.0.0
osl 1.13.5.0 (now dynamic)
python 3.11.6
sqlite 3.42.0
sse2neon 0d6e9b3dd4
usd 23.11
vulkan 1.3.270
xm2 2.12.3

This only updates the build scripts, the precompiled libraries for each
platform will land over the coming weeks.

Ref #113157

Co-authored-by: Ray Molenkamp <github@lazydodo.com>
Co-authored-by: Campbell Barton <campbell@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/116420
This commit is contained in:
Brecht Van Lommel
2023-12-21 19:16:11 +01:00
committed by Brecht Van Lommel
parent e8c5f8dddf
commit 802ac5ba5a
52 changed files with 780 additions and 1754 deletions

View File

@@ -54,12 +54,12 @@ include(cmake/png.cmake)
include(cmake/jpeg.cmake)
include(cmake/blosc.cmake)
include(cmake/pthreads.cmake)
include(cmake/deflate.cmake)
include(cmake/imath.cmake)
include(cmake/openexr.cmake)
include(cmake/brotli.cmake)
include(cmake/freetype.cmake)
include(cmake/epoxy.cmake)
include(cmake/freeglut.cmake)
include(cmake/alembic.cmake)
include(cmake/opensubdiv.cmake)
include(cmake/sdl.cmake)

View File

@@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: 2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(DEFLATE_EXTRA_ARGS
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
)
ExternalProject_Add(external_deflate
URL file://${PACKAGE_DIR}/${DEFLATE_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${DEFLATE_HASH_TYPE}=${DEFLATE_HASH}
PREFIX ${BUILD_DIR}/deflate
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/deflate ${DEFAULT_CMAKE_FLAGS} ${DEFLATE_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/deflate
)

View File

@@ -84,7 +84,6 @@ download_source(PTHREADS)
download_source(OPENEXR)
download_source(FREETYPE)
download_source(EPOXY)
download_source(FREEGLUT)
download_source(ALEMBIC)
download_source(OPENSUBDIV)
download_source(SDL)
@@ -178,3 +177,4 @@ download_source(SHADERC_GLSLANG)
download_source(VULKAN_HEADERS)
download_source(VULKAN_LOADER)
download_source(PYBIND11)
download_source(DEFLATE)

View File

@@ -1,21 +0,0 @@
# SPDX-FileCopyrightText: 2012-2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
if(WIN32)
if(BUILD_MODE STREQUAL Release)
set(FREEGLUT_EXTRA_ARGS
-DFREEGLUT_BUILD_SHARED_LIBS=Off
-DFREEGLUT_BUILD_STATIC_LIBS=On
)
ExternalProject_Add(external_freeglut
URL file://${PACKAGE_DIR}/${FREEGLUT_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${FREEGLUT_HASH_TYPE}=${FREEGLUT_HASH}
PREFIX ${BUILD_DIR}/freeglut
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/freeglut ${DEFAULT_C_FLAGS} ${DEFAULT_CXX_FLAGS} ${FREEGLUT_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/freeglut
)
endif()
endif()

View File

@@ -21,10 +21,6 @@ if(WIN32)
# PNG.
${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_static.lib ${HARVEST_TARGET}/png/lib/libpng.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/png/include/ ${HARVEST_TARGET}/png/include/ &&
# FREEGLUT -> OPENGL.
${CMAKE_COMMAND} -E copy ${LIBDIR}/freeglut/lib/freeglut_static.lib ${HARVEST_TARGET}/opengl/lib/freeglut_static.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freeglut/include/ ${HARVEST_TARGET}/opengl/include/ &&
DEPENDS
)
endif()
@@ -249,7 +245,7 @@ else()
harvest(xr_openxr_sdk/lib xr_openxr_sdk/lib "*.a")
harvest_rpath_bin(osl/bin osl/bin "oslc")
harvest(osl/include osl/include "*.h")
harvest(osl/lib osl/lib "*.a")
harvest_rpath_lib(osl/lib osl/lib "*${SHAREDLIBEXT}*")
harvest(osl/share/OSL/shaders osl/share/OSL/shaders "*.h")
harvest(png/include png/include "*.h")
harvest(png/lib png/lib "*.a")
@@ -277,6 +273,7 @@ else()
harvest(webp/lib webp/lib "*.a")
harvest(webp/include webp/include "*.h")
harvest(usd/include usd/include "*.h")
harvest(usd/include usd/include "*.hpp")
harvest_rpath_lib(usd/lib usd/lib "libusd_ms${SHAREDLIBEXT}")
harvest(usd/lib/usd usd/lib/usd "*")
harvest_rpath_python(

View File

@@ -15,6 +15,7 @@ ExternalProject_Add(external_imath
PREFIX ${BUILD_DIR}/imath
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/imath ${DEFAULT_CMAKE_FLAGS} ${IMATH_EXTRA_ARGS}
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/imath/src/external_imath < ${PATCH_DIR}/imath_358.diff
INSTALL_DIR ${LIBDIR}/imath
)

View File

@@ -39,7 +39,9 @@ set(ISPC_EXTRA_ARGS
-DISPC_NO_DUMPS=On
-DISPC_INCLUDE_EXAMPLES=Off
-DISPC_INCLUDE_TESTS=Off
-DLLVM_ROOT=${LIBDIR}/llvm/lib/cmake/llvm
-DISPC_INCLUDE_RT=Off
-DLLVM_CONFIG_EXECUTABLE=${LIBDIR}/llvm/bin/llvm-config
-DLLVM_DIR=${LIBDIR}/llvm/lib/cmake/llvm/
-DLLVM_LIBRARY_DIR=${LIBDIR}/llvm/lib
-DCLANG_EXECUTABLE=${LIBDIR}/llvm/bin/clang
-DCLANGPP_EXECUTABLE=${LIBDIR}/llvm/bin/clang++

View File

@@ -29,6 +29,8 @@ set(LLVM_EXTRA_ARGS
-DLLVM_ENABLE_TERMINFO=OFF
-DLLVM_BUILD_LLVM_C_DYLIB=OFF
-DLLVM_ENABLE_UNWIND_TABLES=OFF
-DLLVM_ENABLE_ZSTD=OFF
-DLLVM_ENABLE_ZLIB=OFF
-DLLVM_ENABLE_PROJECTS=clang${LLVM_BUILD_CLANG_TOOLS_EXTRA}
-DPython3_ROOT_DIR=${LIBDIR}/python/
-DPython3_EXECUTABLE=${PYTHON_BINARY}

View File

@@ -11,17 +11,22 @@ set(MATERIALX_EXTRA_ARGS
-DMATERIALX_BUILD_SHARED_LIBS=ON
-DMATERIALX_BUILD_TESTS=OFF
-DCMAKE_DEBUG_POSTFIX=_d
# This policy makes pybind11_ROOT work.
-DCMAKE_POLICY_DEFAULT_CMP0074=NEW
-Dpybind11_ROOT=${LIBDIR}/pybind11
-DPython_EXECUTABLE=${PYTHON_BINARY}
)
if(WIN32)
LIST(APPEND MATERIALX_EXTRA_ARGS -DPYTHON_LIBRARIES=${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib)
endif()
ExternalProject_Add(external_materialx
URL file://${PACKAGE_DIR}/${MATERIALX_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${MATERIALX_HASH_TYPE}=${MATERIALX_HASH}
PREFIX ${BUILD_DIR}/materialx
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/materialx/src/external_materialx < ${PATCH_DIR}/materialx.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/materialx ${DEFAULT_CMAKE_FLAGS} ${MATERIALX_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/materialx
)

View File

@@ -22,14 +22,14 @@ set(MESA_EXTRA_FLAGS
-Dcpp_args=${MESA_CXXFLAGS}
-Dc_link_args=${MESA_LDFLAGS}
-Dcpp_link_args=${MESA_LDFLAGS}
-Dglx=gallium-xlib
-Dglx=xlib
-Dgallium-drivers=swrast
-Ddri-drivers=
-Dvulkan-drivers=
-Dgbm=disabled
-Degl=disabled
-Dgles1=disabled
-Dgles2=disabled
-Dcpp_rtti=false
-Dshared-llvm=disabled
# Without this, the build fails when: `wayland-scanner` is not found.
# At some point we will likely want to support Wayland.

View File

@@ -3,6 +3,8 @@
# SPDX-License-Identifier: GPL-2.0-or-later
set(MINIZIPNG_EXTRA_ARGS
# Disable most compression methods like OpenColorIO does, enabling
# more is not needed and will give link errors.
-DMZ_FETCH_LIBS=OFF
-DMZ_LIBCOMP=OFF
-DMZ_PKCRYPT=OFF
@@ -11,10 +13,11 @@ set(MINIZIPNG_EXTRA_ARGS
-DMZ_SIGNING=OFF
-DMZ_LZMA=OFF
-DMZ_ZSTD=OFF
-DMZ_BZIP2=OFF
-DMZ_ICONV=OFF
-DMZ_ZLIB=ON
-DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
-DBZIP2_LIBRARY=${LIBDIR}/bzip2/lib/${LIBPREFIX}bz2${LIBEXT}
-DBZIP2_INCLUDE_DIR=${LIBDIR}/bzip2/include/
# Because OCIO hardcodes a non standard include path
-DCMAKE_INSTALL_INCLUDEDIR=${LIBDIR}/minizipng/include/minizip-ng
)

View File

@@ -11,7 +11,7 @@ set(OPENCOLORIO_EXTRA_ARGS
-DOCIO_BUILD_DOCS=OFF
-DOCIO_BUILD_TESTS=OFF
-DOCIO_BUILD_GPU_TESTS=OFF
-DOCIO_USE_SSE=ON
-DOCIO_USE_SIMD=ON
-DOCIO_INSTALL_EXT_PACKAGES=NONE
@@ -21,7 +21,7 @@ set(OPENCOLORIO_EXTRA_ARGS
-Dpystring_ROOT=${LIBDIR}/pystring
-DImath_ROOT=${LIBDIR}/imath
-Dminizip-ng_ROOT=${LIBDIR}/minizipng
-Dminizip-ng_INCLUDE_DIR=${LIBDIR}/minizipng/include
-Dminizip-ng_INCLUDE_DIR=${LIBDIR}/minizipng/include/minizip-ng
-Dminizip-ng_LIBRARY=${LIBDIR}/minizipng/lib/libminizip${LIBEXT}
-DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
@@ -30,14 +30,10 @@ set(OPENCOLORIO_EXTRA_ARGS
)
if(APPLE)
# Work around issue where minizip-ng_LIBRARY assumes -ng in file name.
set(OPENCOLORIO_EXTRA_ARGS
${OPENCOLORIO_EXTRA_ARGS}
"-DCMAKE_SHARED_LINKER_FLAGS=-liconv ${LIBDIR}/bzip2/lib/${LIBPREFIX}bz2${LIBEXT}"
)
elseif(UNIX)
set(OPENCOLORIO_EXTRA_ARGS
${OPENCOLORIO_EXTRA_ARGS}
"-DCMAKE_SHARED_LINKER_FLAGS=${LIBDIR}/bzip2/lib/${LIBPREFIX}bz2${LIBEXT}"
-Dminizip_LIBRARY=${LIBDIR}/minizipng/lib/libminizip${LIBEXT}
)
endif()
@@ -72,7 +68,6 @@ ExternalProject_Add(external_opencolorio
URL_HASH ${OPENCOLORIO_HASH_TYPE}=${OPENCOLORIO_HASH}
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PREFIX ${BUILD_DIR}/opencolorio
PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/opencolorio/src/external_opencolorio < ${PATCH_DIR}/opencolorio.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencolorio ${DEFAULT_CMAKE_FLAGS} ${OPENCOLORIO_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/opencolorio
)
@@ -93,14 +88,14 @@ if(WIN32)
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_opencolorio after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/include ${HARVEST_TARGET}/opencolorio/include
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/bin/OpenColorIO_2_2.dll ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_2_2.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/bin/OpenColorIO_2_3.dll ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_2_3.dll
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/lib ${HARVEST_TARGET}/opencolorio/lib
DEPENDEES install
)
endif()
if(BUILD_MODE STREQUAL Debug)
ExternalProject_Add_Step(external_opencolorio after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/bin/OpenColorIO_d_2_2.dll ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_d_2_2.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/bin/OpenColorIO_d_2_3.dll ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_d_2_3.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/lib/Opencolorio_d.lib ${HARVEST_TARGET}/opencolorio/lib/OpenColorIO_d.lib
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/lib/site-packages ${HARVEST_TARGET}/opencolorio/lib/site-packages-debug
DEPENDEES install

View File

@@ -14,8 +14,6 @@ endif()
set(OPENEXR_EXTRA_ARGS
${OPENEXR_EXTRA_ARGS}
-DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
-DBUILD_TESTING=OFF
-DOPENEXR_BUILD_BOTH_STATIC_SHARED=OFF
-DBUILD_SHARED_LIBS=ON
@@ -23,13 +21,14 @@ set(OPENEXR_EXTRA_ARGS
-DOPENEXR_INSTALL_EXAMPLES=OFF
-DImath_DIR=${LIBDIR}/imath/lib/cmake/Imath
-DOPENEXR_LIB_SUFFIX=${OPENEXR_VERSION_BUILD_POSTFIX}
-Dlibdeflate_DIR=${LIBDIR}/deflate/lib/cmake/libdeflate
)
ExternalProject_Add(external_openexr
URL file://${PACKAGE_DIR}/${OPENEXR_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${OPENEXR_HASH_TYPE}=${OPENEXR_HASH}
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openexr/src/external_openexr < ${PATCH_DIR}/openexr_b18905772e.diff
PATCH_COMMAND ${PATCH_CMD} -p 2 -d ${BUILD_DIR}/openexr/src/external_openexr < ${PATCH_DIR}/openexr_deflate_1588.diff
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PREFIX ${BUILD_DIR}/openexr
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openexr ${DEFAULT_CMAKE_FLAGS} ${OPENEXR_EXTRA_ARGS}
@@ -51,6 +50,6 @@ endif()
add_dependencies(
external_openexr
external_zlib
external_imath
external_deflate
)

View File

@@ -64,6 +64,14 @@ add_dependencies(
external_python
)
if(UNIX AND NOT APPLE)
add_dependencies(
external_openimagedenoise
external_dpcpp
external_ocloc
)
endif()
if(BUILD_MODE STREQUAL Release AND WIN32)
ExternalProject_Add_Step(external_openimagedenoise after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openimagedenoise/bin ${HARVEST_TARGET}/openimagedenoise/bin

View File

@@ -109,9 +109,8 @@ ExternalProject_Add(external_openimageio
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PREFIX ${BUILD_DIR}/openimageio
PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/openimageio.diff &&
${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_deadlock.diff &&
${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_3984.diff &&
${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_webp.diff
${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_webp.diff &&
${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_4044.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimageio ${DEFAULT_CMAKE_FLAGS} ${OPENIMAGEIO_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/openimageio
)

View File

@@ -22,26 +22,15 @@ set(OPENSUBDIV_EXTRA_ARGS
-DNO_GLEW=ON
-DNO_GLFW=ON
-DNO_GLFW_X11=ON
-DTBB_DIR=${LIBDIR}/tbb/lib/cmake/tbb
)
if(WIN32)
set(OPENSUBDIV_EXTRA_ARGS
${OPENSUBDIV_EXTRA_ARGS}
-DTBB_INCLUDE_DIR=${LIBDIR}/tbb/include
-DTBB_LIBRARIES=${LIBDIR}/tbb/lib/tbb.lib
)
else()
set(OPENSUBDIV_EXTRA_ARGS
${OPENSUBDIV_EXTRA_ARGS}
-DTBB_LOCATION=${LIBDIR}/tbb
)
endif()
ExternalProject_Add(external_opensubdiv
URL file://${PACKAGE_DIR}/${OPENSUBDIV_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${OPENSUBDIV_HASH_TYPE}=${OPENSUBDIV_HASH}
PREFIX ${BUILD_DIR}/opensubdiv
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opensubdiv -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${OPENSUBDIV_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/opensubdiv
)

View File

@@ -37,6 +37,7 @@ set(OPENVDB_EXTRA_ARGS
-DOPENVDB_PYTHON_WRAP_ALL_GRID_TYPES=ON
-DUSE_NUMPY=ON
-DPython_EXECUTABLE=${PYTHON_BINARY}
-Dpybind11_DIR=${LIBDIR}/pybind11/share/cmake/pybind11
# OPENVDB_AX Disabled for now as it adds ~25MB distribution wise
# with no blender code depending on it, seems wasteful.
@@ -46,7 +47,11 @@ set(OPENVDB_EXTRA_ARGS
# -DLLVM_DIR=${LIBDIR}/llvm/lib/cmake/llvm
)
set(OPENVDB_PATCH ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb.diff)
set(OPENVDB_PATCH
${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb.diff &&
${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb_1706.diff &&
${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb_1733.diff
)
ExternalProject_Add(openvdb
URL file://${PACKAGE_DIR}/${OPENVDB_FILE}
@@ -67,6 +72,7 @@ add_dependencies(
external_blosc
external_python
external_numpy
external_pybind11
)
if(WIN32)
@@ -75,7 +81,7 @@ if(WIN32)
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openvdb/include ${HARVEST_TARGET}/openvdb/include
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/bin/openvdb.dll ${HARVEST_TARGET}/openvdb/bin/openvdb.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb.pyd ${HARVEST_TARGET}openvdb/python/pyopenvdb.pyd
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd ${HARVEST_TARGET}openvdb/python/pyopenvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd
DEPENDEES install
)
endif()
@@ -83,7 +89,7 @@ if(WIN32)
ExternalProject_Add_Step(openvdb after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb_d.lib ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/bin/openvdb_d.dll ${HARVEST_TARGET}/openvdb/bin/openvdb_d.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb_d.pyd ${HARVEST_TARGET}openvdb/python/pyopenvdb_d.pyd
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd ${HARVEST_TARGET}openvdb/python/pyopenvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd
DEPENDEES install
)
endif()

View File

@@ -22,7 +22,7 @@ set(OSL_EXTRA_ARGS
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
${OSL_FLEX_BISON}
-DCMAKE_CXX_STANDARD_LIBRARIES=${OSL_CMAKE_CXX_STANDARD_LIBRARIES}
-DBUILD_SHARED_LIBS=OFF
-DBUILD_SHARED_LIBS=ON
-DLINKSTATIC=OFF
-DOSL_BUILD_PLUGINS=OFF
-DSTOP_ON_WARNING=OFF
@@ -38,7 +38,9 @@ set(OSL_EXTRA_ARGS
-DJPEG_ROOT=${LIBDIR}/jpeg
-DUSE_PYTHON=OFF
-DImath_ROOT=${LIBDIR}/imath
-DUSE_OIIO_STATIC=OFF
-DCMAKE_DEBUG_POSTFIX=_d
-DPython_ROOT=${LIBDIR}/python
-DPython_EXECUTABLE=${PYTHON_BINARY}
)
ExternalProject_Add(external_osl
@@ -83,10 +85,14 @@ if(WIN32)
endif()
if(BUILD_MODE STREQUAL Debug)
ExternalProject_Add_Step(external_osl after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslcomp.lib ${HARVEST_TARGET}/osl/lib/oslcomp_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslexec.lib ${HARVEST_TARGET}/osl/lib/oslexec_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslquery.lib ${HARVEST_TARGET}/osl/lib/oslquery_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslnoise.lib ${HARVEST_TARGET}/osl/lib/oslnoise_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslcomp_d.lib ${HARVEST_TARGET}/osl/lib/oslcomp_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslexec_d.lib ${HARVEST_TARGET}/osl/lib/oslexec_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslquery_d.lib ${HARVEST_TARGET}/osl/lib/oslquery_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslnoise_d.lib ${HARVEST_TARGET}/osl/lib/oslnoise_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/bin/oslcomp_d.dll ${HARVEST_TARGET}/osl/bin/oslcomp_d.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/bin/oslexec_d.dll ${HARVEST_TARGET}/osl/bin/oslexec_d.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/bin/oslquery_d.dll ${HARVEST_TARGET}/osl/bin/oslquery_d.dll
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/bin/oslnoise_d.dll ${HARVEST_TARGET}/osl/bin/oslnoise_d.dll
DEPENDEES install
)
endif()

View File

@@ -13,6 +13,7 @@ ExternalProject_Add(external_pybind11
URL_HASH ${PYBIND11_HASH_TYPE}=${PYBIND11_HASH}
PREFIX ${BUILD_DIR}/pybind11
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/pybind11/src/external_pybind11 < ${PATCH_DIR}/pybind11_4761.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/pybind11 ${DEFAULT_CMAKE_FLAGS} ${PYBIND11_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/pybind11
)

View File

@@ -37,7 +37,7 @@ if(WIN32)
# regardless of the version actually in there.
PATCH_COMMAND mkdir ${PYTHON_EXTERNALS_FOLDER_DOS} &&
mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\zlib-1.2.13 ${ZLIB_SOURCE_FOLDER_DOS} &&
mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\openssl-1.1.1u ${SSL_SOURCE_FOLDER_DOS} &&
mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\openssl-3.0.11 ${SSL_SOURCE_FOLDER_DOS} &&
${CMAKE_COMMAND} -E copy ${ZLIB_SOURCE_FOLDER}/../external_zlib-build/zconf.h ${PYTHON_EXTERNALS_FOLDER}/zlib-1.2.13/zconf.h &&
${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_windows.diff
CONFIGURE_COMMAND echo "."
@@ -79,16 +79,36 @@ else()
set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV})
endif()
set(PYTHON_BINARY ${LIBDIR}/python/bin/python${PYTHON_SHORT_VERSION})
# Link against zlib statically (Unix). Avoid rpath issues (macOS).
set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_unix.diff)
set(PYTHON_CONFIGURE_EXTRA_ARGS "")
set(PYTHON_CFLAGS "-I${LIBDIR}/sqlite/include -I${LIBDIR}/bzip2/include -I${LIBDIR}/lzma/include -I${LIBDIR}/zlib/include ${PLATFORM_CFLAGS}")
set(PYTHON_LDFLAGS "-L${LIBDIR}/ffi/lib -L${LIBDIR}/sqlite/lib -L${LIBDIR}/bzip2/lib -L${LIBDIR}/lzma/lib -L${LIBDIR}/zlib/lib ${PLATFORM_LDFLAGS}")
# Various flags to convince Python to use our own versions of ffi, sqlite, ssl, bzip2, lzma and zlib.
# Using pkg-config is only supported for some, and even then we need to work around issues.
set(PYTHON_CONFIGURE_EXTRA_ARGS --with-openssl=${LIBDIR}/ssl)
set(PYTHON_CFLAGS "${PLATFORM_CFLAGS} ")
# Manually specify some library paths. For ffi there is no other way, for sqlite is needed because
# LIBSQLITE3_LIBS does not work, and ssl because it uses the wrong ssl/lib dir instead of ssl/lib64.
set(PYTHON_LDFLAGS "-L${LIBDIR}/ffi/lib -L${LIBDIR}/sqlite/lib -L${LIBDIR}/ssl/lib -L${LIBDIR}/ssl/lib64 ${PLATFORM_LDFLAGS} ")
set(PYTHON_CONFIGURE_EXTRA_ENV
export CFLAGS=${PYTHON_CFLAGS} &&
export CPPFLAGS=${PYTHON_CFLAGS} &&
export LDFLAGS=${PYTHON_LDFLAGS} &&
export PKG_CONFIG_PATH=${LIBDIR}/ffi/lib/pkgconfig:${LIBDIR}/ssl/lib/pkgconfig:${LIBDIR}/ssl/lib64/pkgconfig)
# Use pkg-config for libraries that support it.
export PKG_CONFIG_PATH=${LIBDIR}/ffi/lib/pkgconfig:${LIBDIR}/sqlite/lib/pkgconfig:${LIBDIR}/ssl/lib/pkgconfig:${LIBDIR}/ssl/lib64/pkgconfig
# Use flags documented by ./configure for other libs.
export BZIP2_CFLAGS=-I${LIBDIR}/bzip2/include
export BZIP2_LIBS=${LIBDIR}/bzip2/lib/${LIBPREFIX}bz2${LIBEXT}
export LIBLZMA_CFLAGS=-I${LIBDIR}/lzma/include
export LIBLZMA_LIBS=${LIBDIR}/lzma/lib/${LIBPREFIX}lzma${LIBEXT}
export ZLIB_CFLAGS=-I${LIBDIR}/zlib/include
export ZLIB_LIBS=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
)
# This patch indludes changes to fix missing -lm for sqlite and and fix the order of
# -ldl flags for ssl to avoid link errors.
if(APPLE)
set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_apple.diff)
else()
set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_unix.diff)
endif()
# NOTE: untested on APPLE so far.
if(NOT APPLE)

View File

@@ -111,12 +111,7 @@ ExternalProject_Add(external_usd
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PREFIX ${BUILD_DIR}/usd
LIST_SEPARATOR ^^
# usd_pull_1965.diff https://github.com/PixarAnimationStudios/USD/pull/1965
# usd_hydra.diff - https://github.com/bnagirniak/RPRHydraRenderBlenderAddon/blob/master/usd.diff
# usd_hydra.diff also included the blender changes and usd_pull_1965 and has been edited to remove those sections.
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd.diff &&
${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd_pull_1965.diff &&
${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd_hydra.diff &&
${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd_core_profile.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/usd -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${USD_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/usd

View File

@@ -40,12 +40,12 @@ set(JPEG_HASH_TYPE MD5)
set(JPEG_FILE libjpeg-turbo-${JPEG_VERSION}.tar.gz)
set(JPEG_CPE "cpe:2.3:a:d.r.commander:libjpeg-turbo:${JPEG_VERSION}:*:*:*:*:*:*:*")
set(BOOST_VERSION 1.80.0)
set(BOOST_VERSION_SHORT 1.80)
set(BOOST_VERSION_NODOTS 1_80_0)
set(BOOST_VERSION_NODOTS_SHORT 1_80)
set(BOOST_VERSION 1.82.0)
set(BOOST_VERSION_SHORT 1.82)
set(BOOST_VERSION_NODOTS 1_82_0)
set(BOOST_VERSION_NODOTS_SHORT 1_82)
set(BOOST_URI https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_NODOTS}.tar.gz)
set(BOOST_HASH 077f074743ea7b0cb49c6ed43953ae95)
set(BOOST_HASH f7050f554a65f6a42ece221eaeec1660)
set(BOOST_HASH_TYPE MD5)
set(BOOST_FILE boost_${BOOST_VERSION_NODOTS}.tar.gz)
set(BOOST_CPE "cpe:2.3:a:boost:boost:${BOOST_VERSION}:*:*:*:*:*:*:*")
@@ -65,15 +65,21 @@ set(PTHREADS_HASH_TYPE MD5)
set(PTHREADS_FILE pthreads4w-code-${PTHREADS_VERSION}.zip)
set(PTHREADS_HOMEPAGE https://github.com/fwbuilder/pthreads4w)
set(OPENEXR_VERSION 3.1.7)
set(DEFLATE_VERSION 1.18)
set(DEFLATE_URI https://github.com/ebiggers/libdeflate/archive/refs/tags/v${DEFLATE_VERSION}.tar.gz)
set(DEFLATE_HASH a29d9dd653cbe03f2d5cd83972063f9e)
set(DEFLATE_HASH_TYPE MD5)
set(DEFLATE_FILE libdeflate-v${DEFLATE_VERSION}.tar.gz)
set(OPENEXR_VERSION 3.2.1)
set(OPENEXR_URI https://github.com/AcademySoftwareFoundation/openexr/archive/v${OPENEXR_VERSION}.tar.gz)
set(OPENEXR_HASH ae68f0cb8b30a49c961fa87d31c60394)
set(OPENEXR_HASH 1d5bb07433ec641cf3bb1b519a27ea6f)
set(OPENEXR_HASH_TYPE MD5)
set(OPENEXR_FILE openexr-${OPENEXR_VERSION}.tar.gz)
set(OPENEXR_CPE "cpe:2.3:a:openexr:openexr:${OPENEXR_VERSION}:*:*:*:*:*:*:*")
set(IMATH_VERSION 3.1.7)
set(IMATH_URI https://github.com/AcademySoftwareFoundation/Imath/archive/v${OPENEXR_VERSION}.tar.gz)
set(IMATH_URI https://github.com/AcademySoftwareFoundation/Imath/archive/v${IMATH_VERSION}.tar.gz)
set(IMATH_HASH 5cedab446ab296c080957c3037c6d097)
set(IMATH_HASH_TYPE MD5)
set(IMATH_FILE imath-${IMATH_VERSION}.tar.gz)
@@ -109,22 +115,15 @@ set(EPOXY_HASH f0730aad115c952e77591fcc805b1dc1)
set(EPOXY_HASH_TYPE MD5)
set(EPOXY_FILE libepoxy-${EPOXY_VERSION}.tar.gz)
set(FREEGLUT_VERSION 3.0.0)
set(FREEGLUT_URI http://prdownloads.sourceforge.net/freeglut/freeglut/${FREEGLUT_VERSION}/freeglut-${FREEGLUT_VERSION}.tar.gz)
set(FREEGLUT_HASH 90c3ca4dd9d51cf32276bc5344ec9754)
set(FREEGLUT_HASH_TYPE MD5)
set(FREEGLUT_FILE freeglut-${FREEGLUT_VERSION}.tar.gz)
set(FREEGLUT_HOMEPAGE https://freeglut.sourceforge.net/)
set(ALEMBIC_VERSION 1.8.3)
set(ALEMBIC_URI https://github.com/alembic/alembic/archive/${ALEMBIC_VERSION}.tar.gz)
set(ALEMBIC_HASH 2cd8d6e5a3ac4a014e24a4b04f4fadf9)
set(ALEMBIC_HASH_TYPE MD5)
set(ALEMBIC_FILE alembic-${ALEMBIC_VERSION}.tar.gz)
set(OPENSUBDIV_VERSION v3_5_0)
set(OPENSUBDIV_VERSION v3_6_0)
set(OPENSUBDIV_URI https://github.com/PixarAnimationStudios/OpenSubdiv/archive/${OPENSUBDIV_VERSION}.tar.gz)
set(OPENSUBDIV_HASH 230f5cd2911d6240e58a3773b9c6e5e4)
set(OPENSUBDIV_HASH cd03aaf8890bc0b8550eef62029cabe7)
set(OPENSUBDIV_HASH_TYPE MD5)
set(OPENSUBDIV_FILE opensubdiv-${OPENSUBDIV_VERSION}.tar.gz)
@@ -142,9 +141,9 @@ set(OPENCOLLADA_HASH ee7dae874019fea7be11613d07567493)
set(OPENCOLLADA_HASH_TYPE MD5)
set(OPENCOLLADA_FILE opencollada-${OPENCOLLADA_VERSION}.tar.gz)
set(OPENCOLORIO_VERSION 2.2.0)
set(OPENCOLORIO_VERSION 2.3.0)
set(OPENCOLORIO_URI https://github.com/AcademySoftwareFoundation/OpenColorIO/archive/v${OPENCOLORIO_VERSION}.tar.gz)
set(OPENCOLORIO_HASH d58a5980adba2d89a363100a09daa5f3)
set(OPENCOLORIO_HASH c05f24a516fe82d381c4b0d471e12ad5)
set(OPENCOLORIO_HASH_TYPE MD5)
set(OPENCOLORIO_FILE OpenColorIO-${OPENCOLORIO_VERSION}.tar.gz)
@@ -154,9 +153,9 @@ set(MINIZIPNG_HASH 09dcc8a9def348e1be9659e384c2cd55)
set(MINIZIPNG_HASH_TYPE MD5)
set(MINIZIPNG_FILE minizip-ng-${MINIZIPNG_VERSION}.tar.gz)
set(LLVM_VERSION 12.0.0)
set(LLVM_VERSION 17.0.6)
set(LLVM_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/llvm-project-${LLVM_VERSION}.src.tar.xz)
set(LLVM_HASH 5a4fab4d7fc84aefffb118ac2c8a4fc0)
set(LLVM_HASH 62a09d65240a5133f001ace48269dbfc)
set(LLVM_HASH_TYPE MD5)
set(LLVM_FILE llvm-project-${LLVM_VERSION}.src.tar.xz)
set(LLVM_CPE "cpe:2.3:a:llvm:compiler:${LLVM_VERSION}:*:*:*:*:*:*:*")
@@ -168,15 +167,15 @@ if(APPLE)
set(OPENMP_HASH 6eade16057edbdecb3c4eef9daa2bfcf)
else()
set(OPENMP_VERSION ${LLVM_VERSION})
set(OPENMP_HASH ac48ce3e4582ccb82f81ab59eb3fc9dc)
set(OPENMP_HASH 5cc01d151821c546bb4ec6fb03d86c29)
endif()
set(OPENMP_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${OPENMP_VERSION}/openmp-${OPENMP_VERSION}.src.tar.xz)
set(OPENMP_HASH_TYPE MD5)
set(OPENMP_FILE openmp-${OPENMP_VERSION}.src.tar.xz)
set(OPENIMAGEIO_VERSION v2.4.15.0)
set(OPENIMAGEIO_VERSION v2.5.6.0)
set(OPENIMAGEIO_URI https://github.com/AcademySoftwareFoundation/OpenImageIO/archive/refs/tags/${OPENIMAGEIO_VERSION}.tar.gz)
set(OPENIMAGEIO_HASH 784391406ee309075a3f82e60a42f023)
set(OPENIMAGEIO_HASH d02db17716a20a71a446bdc6de57bd9c)
set(OPENIMAGEIO_HASH_TYPE MD5)
set(OPENIMAGEIO_FILE OpenImageIO-${OPENIMAGEIO_VERSION}.tar.gz)
@@ -205,12 +204,12 @@ set(TIFF_FILE tiff-${TIFF_VERSION}.tar.gz)
set(TIFF_CPE "cpe:2.3:a:libtiff:libtiff:${TIFF_VERSION}:*:*:*:*:*:*:*")
set(TIFF_HOMEPAGE http://www.simplesystems.org/libtiff/)
# Recent commit from 1.13.0.2 under development, which includes string table
# Recent commit from 1.13.5.0 under development, which includes string table
# changes that make the Cycles OptiX implementation work. Official 1.12 OSL
# releases should also build but without OptiX support.
set(OSL_VERSION 1a7670600c8b08c2443a78d03c8c27e9a1149140)
set(OSL_VERSION 3d52f3906b12d38ad0f4b991a8f9ea678171bd28)
set(OSL_URI https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/archive/${OSL_VERSION}.tar.gz)
set(OSL_HASH 7b6d6716b05d1addb92a8f47280bf77f)
set(OSL_HASH dfe5d69f48930badc1ad39a4e11e2e98)
set(OSL_HASH_TYPE MD5)
set(OSL_FILE OpenShadingLanguage-${OSL_VERSION}.tar.gz)
@@ -219,11 +218,11 @@ set(OSL_FILE OpenShadingLanguage-${OSL_VERSION}.tar.gz)
# BZIP2, FFI, SQLITE and change the versions in this file as well. For compliance
# reasons there can be no exceptions to this.
set(PYTHON_VERSION 3.10.13)
set(PYTHON_SHORT_VERSION 3.10)
set(PYTHON_SHORT_VERSION_NO_DOTS 310)
set(PYTHON_VERSION 3.11.6)
set(PYTHON_SHORT_VERSION 3.11)
set(PYTHON_SHORT_VERSION_NO_DOTS 311)
set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
set(PYTHON_HASH 8847dc6458d1431d0ae0f55942deeb89)
set(PYTHON_HASH d0c5a1a31efe879723e51addf56dd206)
set(PYTHON_HASH_TYPE MD5)
set(PYTHON_FILE Python-${PYTHON_VERSION}.tar.xz)
set(PYTHON_CPE "cpe:2.3:a:python:python:${PYTHON_VERSION}:-:*:*:*:*:*:*")
@@ -237,9 +236,9 @@ set(TBB_HASH_TYPE MD5)
set(TBB_FILE oneTBB-${TBB_VERSION}.tar.gz)
set(TBB_CPE "cpe:2.3:a:intel:threading_building_blocks:${TBB_YEAR}:*:*:*:*:*:*:*")
set(OPENVDB_VERSION 10.0.0)
set(OPENVDB_VERSION 11.0.0)
set(OPENVDB_URI https://github.com/AcademySoftwareFoundation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz)
set(OPENVDB_HASH 64301c737e16b26c8f3085a31e6397e9)
set(OPENVDB_HASH 025f4fc4db58419341a4991f1a16174a)
set(OPENVDB_HASH_TYPE MD5)
set(OPENVDB_FILE openvdb-${OPENVDB_VERSION}.tar.gz)
@@ -273,10 +272,10 @@ set(TOML_VERSION 0.10.2)
# Build system for other packages (not used by Blender at run-time).
set(MESON_VERSION 0.63.0)
set(NUMPY_VERSION 1.23.5)
set(NUMPY_SHORT_VERSION 1.23)
set(NUMPY_VERSION 1.24.3)
set(NUMPY_SHORT_VERSION 1.24)
set(NUMPY_URI https://github.com/numpy/numpy/releases/download/v${NUMPY_VERSION}/numpy-${NUMPY_VERSION}.tar.gz)
set(NUMPY_HASH 8b2692a511a3795f3af8af2cd7566a15)
set(NUMPY_HASH 89e5e2e78407032290ae6acf6dcaea46)
set(NUMPY_HASH_TYPE MD5)
set(NUMPY_FILE numpy-${NUMPY_VERSION}.tar.gz)
set(NUMPY_CPE "cpe:2.3:a:numpy:numpy:${NUMPY_VERSION}:*:*:*:*:*:*:*")
@@ -397,9 +396,9 @@ set(JEMALLOC_HASH 3d41fbf006e6ebffd489bdb304d009ae)
set(JEMALLOC_HASH_TYPE MD5)
set(JEMALLOC_FILE jemalloc-${JEMALLOC_VERSION}.tar.bz2)
set(XML2_VERSION 2.10.4)
set(XML2_URI https://download.gnome.org/sources/libxml2/2.10/libxml2-${XML2_VERSION}.tar.xz)
set(XML2_HASH 76808c467a58c31e2dbd511e71d5fd13)
set(XML2_VERSION 2.12.3)
set(XML2_URI https://download.gnome.org/sources/libxml2/2.12/libxml2-${XML2_VERSION}.tar.xz)
set(XML2_HASH 13871e7cf2137b4b9b9da753ffef538c)
set(XML2_HASH_TYPE MD5)
set(XML2_FILE libxml2-${XML2_VERSION}.tar.xz)
set(XML2_CPE "cpe:2.3:a:xmlsoft:libxml2:${XML2_VERSION}:*:*:*:*:*:*:*")
@@ -465,13 +464,12 @@ set(BZIP2_HOMEPAGE https://sourceware.org/bzip2/)
# NOTE: This will *HAVE* to match the version python ships on windows which
# is hardcoded in pythons PCbuild/get_externals.bat. For compliance reasons there
# can be no exceptions to this.
set(FFI_VERSION 3.3)
set(FFI_URI https://sourceware.org/pub/libffi/libffi-${FFI_VERSION}.tar.gz)
set(FFI_HASH 72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056)
set(FFI_VERSION 3.4.4)
set(FFI_URI https://github.com/libffi/libffi/releases/download/v${FFI_VERSION}/libffi-${FFI_VERSION}.tar.gz)
set(FFI_HASH d66c56ad259a82cf2a9dfc408b32bf5da52371500b84745f7fb8b645712df676)
set(FFI_HASH_TYPE SHA256)
set(FFI_FILE libffi-${FFI_VERSION}.tar.gz)
set(FFI_CPE "cpe:2.3:a:libffi_project:libffi:${FFI_VERSION}:*:*:*:*:*:*:*")
set(FFI_HOMEPAGE https://sourceware.org/libffi/)
set(LZMA_VERSION 5.2.5)
set(LZMA_URI https://tukaani.org/xz/xz-${LZMA_VERSION}.tar.bz2)
@@ -492,10 +490,10 @@ set(SSL_HOMEPAGE https://www.openssl.org)
# Note: This will *HAVE* to match the version python ships on windows which
# is hardcoded in pythons PCbuild/get_externals.bat for compliance reasons there
# can be no exceptions to this.
set(SQLITE_VERSION 3.40.1)
set(SQLLITE_LONG_VERSION 3400100)
set(SQLITE_URI https://www.sqlite.org/2022/sqlite-autoconf-${SQLLITE_LONG_VERSION}.tar.gz)
set(SQLITE_HASH b8c2d4bc0094f5c0ce985dc0e237dfcbaa1f6275)
set(SQLITE_VERSION 3.42.0)
set(SQLLITE_LONG_VERSION 3420000)
set(SQLITE_URI https://www.sqlite.org/2023/sqlite-autoconf-${SQLLITE_LONG_VERSION}.tar.gz)
set(SQLITE_HASH 036575929b174c1b829769255491ba2b32bda9ee)
set(SQLITE_HASH_TYPE SHA1)
set(SQLITE_FILE sqlite-autoconf-${SQLLITE_LONG_VERSION}.tar.gz)
set(SQLITE_CPE "cpe:2.3:a:sqlite:sqlite:${SQLITE_VERSION}:*:*:*:*:*:*:*")
@@ -507,15 +505,15 @@ set(EMBREE_HASH 4b525955b08e1249a700dea5b5ffc8b2)
set(EMBREE_HASH_TYPE MD5)
set(EMBREE_FILE embree-v${EMBREE_VERSION}.zip)
set(USD_VERSION 23.05)
set(USD_VERSION 23.11)
set(USD_URI https://github.com/PixarAnimationStudios/OpenUSD/archive/v${USD_VERSION}.tar.gz)
set(USD_HASH d4d92ff112bc82a1718bcd129b853a54)
set(USD_HASH 77358a244f50fc607e8b40764ea4f6c6)
set(USD_HASH_TYPE MD5)
set(USD_FILE usd-v${USD_VERSION}.tar.gz)
set(MATERIALX_VERSION 1.38.6)
set(MATERIALX_VERSION 1.38.8)
set(MATERIALX_URI https://github.com/AcademySoftwareFoundation/MaterialX/archive/refs/tags/v${MATERIALX_VERSION}.tar.gz)
set(MATERIALX_HASH d49c9fdef34b5702fc60058d3e1864f2)
set(MATERIALX_HASH fad8f4e19305fb2ee920cbff638f3560)
set(MATERIALX_HASH_TYPE MD5)
set(MATERIALX_FILE materialx-v${MATERIALX_VERSION}.tar.gz)
@@ -532,9 +530,9 @@ set(LIBGLU_HASH_TYPE MD5)
set(LIBGLU_FILE glu-${LIBGLU_VERSION}.tar.xz)
set(LIBGLU_HOMEPAGE https://gitlab.freedesktop.org/mesa/glu)
set(MESA_VERSION 21.1.5)
set(MESA_VERSION 23.3.0)
set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa/mesa-${MESA_VERSION}.tar.xz)
set(MESA_HASH 022c7293074aeeced2278c872db4fa693147c70f8595b076cf3f1ef81520766d)
set(MESA_HASH 50f729dd60ed6335b989095baad81ef5edf7cfdd4b4b48b9b955917cb07d69c5)
set(MESA_HASH_TYPE SHA256)
set(MESA_FILE mesa-${MESA_VERSION}.tar.xz)
set(MESA_CPE "cpe:2.3:a:mesa3d:mesa:${MESA_VERSION}:*:*:*:*:*:*:*")
@@ -581,9 +579,9 @@ set(WAYLAND_WESTON_HASH 44542b60bf9b9fe3add904af11bbad98)
set(WAYLAND_WESTON_HASH_TYPE MD5)
set(WAYLAND_WESTON_HOMEPAGE https://wayland.freedesktop.org)
set(ISPC_VERSION v1.17.0)
set(ISPC_VERSION v1.21.1)
set(ISPC_URI https://github.com/ispc/ispc/archive/${ISPC_VERSION}.tar.gz)
set(ISPC_HASH 4f476a3109332a77fe839a9014c60ca9)
set(ISPC_HASH edd16b016aabc07819d14fd86a1fb5d0)
set(ISPC_HASH_TYPE MD5)
set(ISPC_FILE ispc-${ISPC_VERSION}.tar.gz)
@@ -616,9 +614,9 @@ set(ZSTD_HASH_TYPE SHA256)
set(ZSTD_FILE zstd-${ZSTD_VERSION}.tar.gz)
set(ZSTD_CPE "cpe:2.3:a:facebook:zstandard:${ZSTD_VERSION}:*:*:*:*:*:*:*")
set(SSE2NEON_VERSION v1.6.0)
set(SSE2NEON_VERSION 0d6e9b3dd4687a0b98c0645e001f96659aae5854)
set(SSE2NEON_URI https://github.com/DLTcollab/sse2neon/archive/${SSE2NEON_VERSION}.tar.gz)
set(SSE2NEON_HASH 06f4693219deccb91b457135d836fc514a1c0a57e9fa66b143982901d2d19677)
set(SSE2NEON_HASH 68cf4dfe6d0667ae3e3850233227c4c4937b7b83de01845d356b68d313f25e32)
set(SSE2NEON_HASH_TYPE SHA256)
set(SSE2NEON_FILE sse2neon-${SSE2NEON_VERSION}.tar.gz)
@@ -826,17 +824,17 @@ set(SHADERC_GLSLANG_HASH 3b3c79ad8e9132ffcb8b63cc29c532e2)
set(SHADERC_GLSLANG_HASH_TYPE MD5)
set(SHADERC_GLSLANG_FILE glslang-${SHADERC_GLSLANG_VERSION}.tar.gz)
set(VULKAN_VERSION v1.2.198)
set(VULKAN_VERSION v1.3.270)
set(VULKAN_HEADERS_VERSION ${VULKAN_VERSION})
set(VULKAN_HEADERS_URI https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/${VULKAN_HEADERS_VERSION}.tar.gz)
set(VULKAN_HEADERS_HASH 64fe73e887c963ad546bfc7f9505fa1d)
set(VULKAN_HEADERS_HASH 805bde4c23197b86334cee5c2cf69d8e)
set(VULKAN_HEADERS_HASH_TYPE MD5)
set(VULKAN_HEADERS_FILE Vulkan-Headers-${VULKAN_HEADERS_VERSION}.tar.gz)
set(VULKAN_LOADER_VERSION ${VULKAN_VERSION})
set(VULKAN_LOADER_URI https://github.com/KhronosGroup/Vulkan-Loader/archive/refs/tags/${VULKAN_LOADER_VERSION}.tar.gz)
set(VULKAN_LOADER_HASH 015170a74f648fd2b41e209b6bf1ebc4)
set(VULKAN_LOADER_HASH 6903f9d285afcd1a167ec7c46cbabd49)
set(VULKAN_LOADER_HASH_TYPE MD5)
set(VULKAN_LOADER_FILE Vulkan-Loader-${VULKAN_LOADER_VERSION}.tar.gz)

View File

@@ -2,44 +2,23 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
if(WIN32)
set(XML2_EXTRA_ARGS
-DLIBXML2_WITH_ZLIB=OFF
-DLIBXML2_WITH_LZMA=OFF
-DLIBXML2_WITH_PYTHON=OFF
-DLIBXML2_WITH_ICONV=OFF
-DLIBXML2_WITH_TESTS=OFF
-DLIBXML2_WITH_PROGRAMS=OFF
-DBUILD_SHARED_LIBS=OFF
)
ExternalProject_Add(external_xml2
URL file://${PACKAGE_DIR}/${XML2_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${XML2_HASH_TYPE}=${XML2_HASH}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/xml2 ${DEFAULT_CMAKE_FLAGS} ${XML2_EXTRA_ARGS}
PREFIX ${BUILD_DIR}/xml2
INSTALL_DIR ${LIBDIR}/xml2
)
else()
ExternalProject_Add(external_xml2
URL file://${PACKAGE_DIR}/${XML2_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${XML2_HASH_TYPE}=${XML2_HASH}
PREFIX ${BUILD_DIR}/xml2
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xml2/src/external_xml2/ && ${CONFIGURE_COMMAND}
--prefix=${LIBDIR}/xml2
--disable-shared
--enable-static
--with-pic
--with-python=no
--with-lzma=no
--with-zlib=no
--with-iconv=no
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xml2/src/external_xml2/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/xml2/src/external_xml2/ && make install
INSTALL_DIR ${LIBDIR}/xml2
)
endif()
set(XML2_EXTRA_ARGS
-DLIBXML2_WITH_ZLIB=OFF
-DLIBXML2_WITH_LZMA=OFF
-DLIBXML2_WITH_PYTHON=OFF
-DLIBXML2_WITH_ICONV=OFF
-DLIBXML2_WITH_TESTS=OFF
-DLIBXML2_WITH_PROGRAMS=OFF
-DBUILD_SHARED_LIBS=OFF
)
ExternalProject_Add(external_xml2
URL file://${PACKAGE_DIR}/${XML2_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${XML2_HASH_TYPE}=${XML2_HASH}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/xml2 ${DEFAULT_CMAKE_FLAGS} ${XML2_EXTRA_ARGS}
PREFIX ${BUILD_DIR}/xml2
INSTALL_DIR ${LIBDIR}/xml2
)
if(WIN32 AND BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_xml2 after_install

View File

@@ -96,6 +96,10 @@ PACKAGES_FOR_LIBS=(
# Required by: `external_mesa`.
expat-devel
# Required by: `external_mesa`.
libxshmfence
libxshmfence-devel
# Required by: `external_igc` & `external_osl` as a build-time dependency.
bison
# Required by: `external_osl` as a build-time dependency.

View File

@@ -0,0 +1,21 @@
diff --git a/src/Imath/half.h b/src/Imath/half.h
index 84b349ab..828e0d82 100644
--- a/src/Imath/half.h
+++ b/src/Imath/half.h
@@ -328,8 +328,14 @@ imath_half_to_float (imath_half_bits_t h)
// other compilers may provide count-leading-zeros primitives,
// but we need the community to inform us of the variants
uint32_t lc;
-# if defined(_MSC_VER) && (_M_IX86 || _M_X64)
- lc = __lzcnt (hexpmant);
+# if defined(_MSC_VER)
+ // The direct intrinsic for this is __lznct, but that is not supported
+ // on older x86_64 hardware or ARM. Instead uses the bsr instruction
+ // and one additional subtraction. This assumes hexpmant != 0, for 0
+ // bsr and lznct would behave differently.
+ unsigned long bsr;
+ _BitScanReverse (&bsr, hexpmant);
+ lc = (31 - bsr);
# elif defined(__GNUC__) || defined(__clang__)
lc = (uint32_t) __builtin_clz (hexpmant);
# else

View File

@@ -1,21 +1,6 @@
diff -Naur ispc-1.17.0.org/CMakeLists.txt ispc-1.17.0/CMakeLists.txt
--- ispc-1.17.0.org/CMakeLists.txt 2022-01-15 01:35:15 -0700
+++ ispc-1.17.0/CMakeLists.txt 2022-02-12 12:44:24 -0700
@@ -36,8 +36,12 @@
cmake_minimum_required(VERSION 3.13)
if (UNIX)
- set(CMAKE_C_COMPILER "clang")
- set(CMAKE_CXX_COMPILER "clang++")
+ if (NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER "clang")
+ endif()
+ if (NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER "clang++")
+ endif()
endif()
set(PROJECT_NAME ispc)
@@ -443,7 +447,7 @@
# Include directories
@@ -25,15 +10,15 @@ diff -Naur ispc-1.17.0.org/CMakeLists.txt ispc-1.17.0/CMakeLists.txt
${XE_DEPS_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
@@ -507,7 +511,7 @@
# Link against Clang libraries
foreach(clangLib ${CLANG_LIBRARY_LIST})
- find_library(${clangLib}Path NAMES ${clangLib} HINTS ${LLVM_LIBRARY_DIRS})
+ find_library(${clangLib}Path NAMES ${clangLib} HINTS ${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIR})
list(APPEND CLANG_LIBRARY_FULL_PATH_LIST ${${clangLib}Path})
endforeach()
target_link_libraries(${PROJECT_NAME} ${CLANG_LIBRARY_FULL_PATH_LIST})
@@ -607,7 +607,7 @@
NAMES
"${CMAKE_STATIC_LIBRARY_PREFIX}${clangLib}${CMAKE_STATIC_LIBRARY_SUFFIX}"
clang-cpp
- HINTS ${LLVM_LIBRARY_DIRS})
+ HINTS ${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIR})
if (NOT ${${clangLib}Path} IN_LIST CLANG_LIBRARY_FULL_PATH_LIST)
list(APPEND CLANG_LIBRARY_FULL_PATH_LIST ${${clangLib}Path})
endif()
@@ -546,6 +550,29 @@
endif()
endif()

View File

@@ -1,13 +1,14 @@
--- a/llvm/lib/Support/Unix/Path.inc 2020-02-17 09:24:26.000000000 +0100
+++ b/llvm/lib/Support/Unix/Path.inc 2020-02-17 09:26:25.000000000 +0100
@@ -1200,7 +1200,9 @@
/// implementation.
diff -Naur ll.org/llvm/lib/Support/Unix/Path.inc ll/llvm/lib/Support/Unix/Path.inc
--- ll.org/llvm/lib/Support/Unix/Path.inc 2023-08-01 06:41:14.360891600 -0600
+++ ll/llvm/lib/Support/Unix/Path.inc 2023-08-01 07:20:02.063130200 -0600
@@ -1476,7 +1476,9 @@
std::error_code copy_file(const Twine &From, const Twine &To) {
uint32_t Flag = COPYFILE_DATA;
-#if __has_builtin(__builtin_available) && defined(COPYFILE_CLONE)
std::string FromS = From.str();
std::string ToS = To.str();
-#if __has_builtin(__builtin_available)
+ // BLENDER: This optimization makes LLVM not build on older Xcode versions,
+ // just disable until everyone has new enough Xcode versions.
+#if 0
if (__builtin_available(macos 10.12, *)) {
bool IsSymlink;
if (std::error_code Error = is_symlink_file(From, IsSymlink))
// Optimistically try to use clonefile() and handle errors, rather than
// calling stat() to see if it'll work.

View File

@@ -1,13 +0,0 @@
diff -Naur orig/source/PyMaterialX/PyBind11/tools/FindPythonLibsNew.cmake external_materialx/source/PyMaterialX/PyBind11/tools/FindPythonLibsNew.cmake
--- orig/source/PyMaterialX/PyBind11/tools/FindPythonLibsNew.cmake 2022-11-04 14:23:29 -0600
+++ external_materialx/source/PyMaterialX/PyBind11/tools/FindPythonLibsNew.cmake 2022-11-08 11:58:45 -0700
@@ -181,6 +181,9 @@
string(REGEX REPLACE "\\\\" "/" PYTHON_SITE_PACKAGES "${PYTHON_SITE_PACKAGES}")
if(CMAKE_HOST_WIN32)
+ if(PYTHON_EXECUTABLE MATCHES "_d.exe$")
+ set(PYTHON_LIBRARY_SUFFIX ${PYTHON_LIBRARY_SUFFIX}_d)
+ endif()
set(PYTHON_LIBRARY "${PYTHON_PREFIX}/libs/python${PYTHON_LIBRARY_SUFFIX}.lib")
# when run in a venv, PYTHON_PREFIX points to it. But the libraries remain in the

View File

@@ -1,13 +0,0 @@
diff --git a/src/libOpenImageIO/exif.cpp b/src/libOpenImageIO/exif.cpp
index 90eaaec6e9..1fbf04140e 100644
--- a/src/libOpenImageIO/exif.cpp
+++ b/src/libOpenImageIO/exif.cpp
@@ -1302,6 +1302,8 @@ encode_exif(const ImageSpec& spec, std::vector<char>& blob,
TIFFHeader head;
head.tiff_magic = (endianreq == endian::little) ? 0x4949 : 0x4d4d;
head.tiff_version = 42;
+ if (endianreq != endian::native)
+ swap_endian(&head.tiff_version);
// N.B. need to swap_endian head.tiff_diroff below, once we know the sizes
append(blob, head);

View File

@@ -0,0 +1,13 @@
diff --git a/src/png.imageio/pngoutput.cpp b/src/png.imageio/pngoutput.cpp
index cc694f5a..f752ab7d 100644
--- a/src/png.imageio/pngoutput.cpp
+++ b/src/png.imageio/pngoutput.cpp
@@ -385,7 +385,7 @@ PNGOutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format,
unassoc_scratch.reset(new float[nvals]);
float* floatvals = unassoc_scratch.get();
// Contiguize and convert to float
- OIIO::convert_image(m_spec.nchannels, m_spec.width, m_spec.height, 1,
+ OIIO::convert_image(m_spec.nchannels, m_spec.width, yend - ybegin, 1,
data, format, xstride, ystride, AutoStride,
floatvals, TypeFloat, AutoStride, AutoStride,
AutoStride);

View File

@@ -1,62 +0,0 @@
diff -Naur orig/src/idiff/idiff.cpp external_openimageio/src/idiff/idiff.cpp
--- orig/src/idiff/idiff.cpp 2023-06-07 07:47:42 -0600
+++ external_openimageio/src/idiff/idiff.cpp 2023-06-07 09:46:47 -0600
@@ -399,5 +399,6 @@
imagecache->invalidate_all(true);
ImageCache::destroy(imagecache);
+ default_thread_pool()->resize(0);
return ret;
}
diff -Naur orig/src/libutil/thread.cpp external_openimageio/src/libutil/thread.cpp
--- orig/src/libutil/thread.cpp 2023-06-07 07:47:42 -0600
+++ external_openimageio/src/libutil/thread.cpp 2023-06-07 09:45:39 -0600
@@ -151,9 +151,10 @@
this->set_thread(i);
}
} else { // the number of threads is decreased
+ std::vector<std::unique_ptr<std::thread>> terminating_threads;
for (int i = oldNThreads - 1; i >= nThreads; --i) {
*this->flags[i] = true; // this thread will finish
- this->terminating_threads.push_back(
+ terminating_threads.push_back(
std::move(this->threads[i]));
this->threads.erase(this->threads.begin() + i);
}
@@ -162,6 +163,11 @@
std::unique_lock<std::mutex> lock(this->mutex);
this->cv.notify_all();
}
+ // wait for the terminated threads to finish
+ for (auto& thread : terminating_threads) {
+ if (thread->joinable())
+ thread->join();
+ }
this->threads.resize(
nThreads); // safe to delete because the threads are detached
this->flags.resize(
@@ -238,16 +244,10 @@
if (thread->joinable())
thread->join();
}
- // wait for the terminated threads to finish
- for (auto& thread : this->terminating_threads) {
- if (thread->joinable())
- thread->join();
- }
// if there were no threads in the pool but some functors in the queue, the functors are not deleted by the threads
// therefore delete them here
this->clear_queue();
this->threads.clear();
- this->terminating_threads.clear();
this->flags.clear();
}
@@ -349,7 +349,6 @@
}
std::vector<std::unique_ptr<std::thread>> threads;
- std::vector<std::unique_ptr<std::thread>> terminating_threads;
std::vector<std::shared_ptr<std::atomic<bool>>> flags;
mutable pvt::ThreadsafeQueue<std::function<void(int id)>*> q;
std::atomic<bool> isDone;

View File

@@ -1,28 +0,0 @@
diff --git a/share/cmake/modules/Findpystring.cmake b/share/cmake/modules/Findpystring.cmake
index 7b894a45..92618215 100644
--- a/share/cmake/modules/Findpystring.cmake
+++ b/share/cmake/modules/Findpystring.cmake
@@ -113,6 +113,11 @@ if(NOT pystring_FOUND)
-DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE}
-DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT}
-DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX}
+ -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
+ -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
+ -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
+ -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
+ -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
)
if(CMAKE_TOOLCHAIN_FILE)
set(pystring_CMAKE_ARGS
--- a/src/OpenColorIO/FileRules.cpp
+++ b/src/OpenColorIO/FileRules.cpp
@@ -7,6 +7,9 @@
#include <regex>
#include <sstream>
+/* NOTE: this has been applied up-stream, this edit can be removed after upgrading OpenColorIO. */
+#include <cstring>
+
#include <OpenColorIO/OpenColorIO.h>
#include "CustomKeys.h"

View File

@@ -1,1023 +0,0 @@
From b18905772e9dd98658f8a37d16c6e53c7c17adaa Mon Sep 17 00:00:00 2001
From: Kimball Thurston <kdt3rd@gmail.com>
Date: Sat, 22 Apr 2023 15:58:43 +1200
Subject: [PATCH] Change setNumThreads to wait for thread start (#1291)
Fix Issue #890, issue with windows shutdown when exiting quickly prior to
threads actually starting. We do this by having a data block that is passed
by shared_ptr to the thread to avoid dereferencing a deleted object.
Further, greatly simplify the ThreadPool code by using atomic shared_ptr
functions instead of trying to manually implement something similar and
otherwise modernizing the thread code.
Fix a few potential null dereference locations and also fix an issue when
systems are overloaded enabling the TaskGroup destructor to destroy
the semaphore while code is still using it, causing undefined memory
corruption if some other thread immediately allocates that same block
Originally based on a proposed patch by Dieter De Baets @debaetsd
Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
---
src/lib/IlmThread/IlmThreadPool.cpp | 740 ++++++++++---------------
src/lib/IlmThread/IlmThreadSemaphore.h | 8 +-
2 files changed, 303 insertions(+), 445 deletions(-)
diff --git a/src/lib/IlmThread/IlmThreadPool.cpp b/src/lib/IlmThread/IlmThreadPool.cpp
index 0ddcf8d52..f4578a510 100644
--- a/src/lib/IlmThread/IlmThreadPool.cpp
+++ b/src/lib/IlmThread/IlmThreadPool.cpp
@@ -15,12 +15,17 @@
#include "Iex.h"
#include <atomic>
+#include <limits>
#include <memory>
#include <mutex>
#include <vector>
#include <thread>
-using namespace std;
+#if (defined(_WIN32) || defined(_WIN64))
+# include <windows.h>
+#else
+# include <unistd.h>
+#endif
ILMTHREAD_INTERNAL_NAMESPACE_SOURCE_ENTER
@@ -28,380 +33,301 @@ ILMTHREAD_INTERNAL_NAMESPACE_SOURCE_ENTER
# define ENABLE_THREADING
#endif
-#if defined(__GNU_LIBRARY__) && ( __GLIBC__ < 2 || ( __GLIBC__ == 2 && __GLIBC_MINOR__ < 21 ) )
-# define ENABLE_SEM_DTOR_WORKAROUND
-#endif
-
-#ifdef ENABLE_THREADING
-
-struct TaskGroup::Data
+namespace
{
- Data ();
- ~Data ();
-
- void addTask () ;
- void removeTask ();
- std::atomic<int> numPending;
- Semaphore isEmpty; // used to signal that the taskgroup is empty
-#if defined(ENABLE_SEM_DTOR_WORKAROUND)
- // this mutex is also used to lock numPending in the legacy c++ mode...
- std::mutex dtorMutex; // used to work around the glibc bug:
- // http://sources.redhat.com/bugzilla/show_bug.cgi?id=12674
-#endif
-};
-
-struct ThreadPool::Data
+static inline void
+handleProcessTask (Task* task)
{
- typedef ThreadPoolProvider *TPPointer;
-
- Data ();
- ~Data();
- Data (const Data&) = delete;
- Data &operator= (const Data&) = delete;
- Data (Data&&) = delete;
- Data &operator= (Data&&) = delete;
-
- struct SafeProvider
+ if (task)
{
- SafeProvider (Data *d, ThreadPoolProvider *p) : _data( d ), _ptr( p )
- {
- }
-
- ~SafeProvider()
- {
- if ( _data )
- _data->coalesceProviderUse();
- }
- SafeProvider (const SafeProvider &o)
- : _data( o._data ), _ptr( o._ptr )
- {
- if ( _data )
- _data->bumpProviderUse();
- }
- SafeProvider &operator= (const SafeProvider &o)
- {
- if ( this != &o )
- {
- if ( o._data )
- o._data->bumpProviderUse();
- if ( _data )
- _data->coalesceProviderUse();
- _data = o._data;
- _ptr = o._ptr;
- }
- return *this;
- }
- SafeProvider( SafeProvider &&o )
- : _data( o._data ), _ptr( o._ptr )
- {
- o._data = nullptr;
- }
- SafeProvider &operator=( SafeProvider &&o )
- {
- std::swap( _data, o._data );
- std::swap( _ptr, o._ptr );
- return *this;
- }
-
- inline ThreadPoolProvider *get () const
- {
- return _ptr;
- }
- ThreadPoolProvider *operator-> () const
- {
- return get();
- }
-
- Data *_data;
- ThreadPoolProvider *_ptr;
- };
-
- // NB: In C++20, there is full support for atomic shared_ptr, but that is not
- // yet in use or finalized. Once stabilized, add appropriate usage here
- inline SafeProvider getProvider ();
- inline void coalesceProviderUse ();
- inline void bumpProviderUse ();
- inline void setProvider (ThreadPoolProvider *p);
-
- std::atomic<int> provUsers;
- std::atomic<ThreadPoolProvider *> provider;
-};
-
+ TaskGroup* taskGroup = task->group ();
+ task->execute ();
-namespace {
+ // kill the task prior to notifying the group
+ // such that any internal reference-based
+ // semantics will be handled prior to
+ // the task group destructor letting it out
+ // of the scope of those references
+ delete task;
-class DefaultWorkerThread;
+ if (taskGroup) taskGroup->finishOneTask ();
+ }
+}
-struct DefaultWorkData
+#ifdef ENABLE_THREADING
+struct DefaultThreadPoolData
{
- Semaphore taskSemaphore; // threads wait on this for ready tasks
- mutable std::mutex taskMutex; // mutual exclusion for the tasks list
- vector<Task*> tasks; // the list of tasks to execute
+ Semaphore _taskSemaphore; // threads wait on this for ready tasks
+ mutable std::mutex _taskMutex; // mutual exclusion for the tasks list
+ std::vector<Task*> _tasks; // the list of tasks to execute
- Semaphore threadSemaphore; // signaled when a thread starts executing
- mutable std::mutex threadMutex; // mutual exclusion for threads list
- vector<DefaultWorkerThread*> threads; // the list of all threads
-
- std::atomic<bool> hasThreads;
- std::atomic<bool> stopping;
+ mutable std::mutex _threadMutex; // mutual exclusion for threads list
+ std::vector<std::thread> _threads; // the list of all threads
+
+ std::atomic<int> _threadCount;
+ std::atomic<bool> _stopping;
inline bool stopped () const
{
- return stopping.load( std::memory_order_relaxed );
+ return _stopping.load (std::memory_order_relaxed);
}
- inline void stop ()
+ inline void stop () { _stopping = true; }
+
+ inline void resetAtomics ()
{
- stopping = true;
+ _threadCount = 0;
+ _stopping = false;
}
};
+#endif
-//
-// class WorkerThread
-//
-class DefaultWorkerThread: public Thread
+} // namespace
+
+#ifdef ENABLE_THREADING
+
+struct TaskGroup::Data
{
- public:
+ Data ();
+ ~Data ();
+ Data (const Data&) = delete;
+ Data& operator= (const Data&) = delete;
+ Data (Data&&) = delete;
+ Data& operator= (Data&&) = delete;
- DefaultWorkerThread (DefaultWorkData* data);
+ void addTask ();
+ void removeTask ();
- virtual void run ();
-
- private:
+ void waitForEmpty ();
- DefaultWorkData * _data;
+ std::atomic<int> numPending;
+ std::atomic<int> inFlight;
+ Semaphore isEmpty; // used to signal that the taskgroup is empty
};
-DefaultWorkerThread::DefaultWorkerThread (DefaultWorkData* data):
- _data (data)
+struct ThreadPool::Data
{
- start();
-}
-
+ using ProviderPtr = std::shared_ptr<ThreadPoolProvider>;
-void
-DefaultWorkerThread::run ()
-{
- //
- // Signal that the thread has started executing
- //
+ Data ();
+ ~Data ();
+ Data (const Data&) = delete;
+ Data& operator= (const Data&) = delete;
+ Data (Data&&) = delete;
+ Data& operator= (Data&&) = delete;
- _data->threadSemaphore.post();
+ ProviderPtr getProvider () const { return std::atomic_load (&_provider); }
- while (true)
+ void setProvider (ProviderPtr provider)
{
- //
- // Wait for a task to become available
- //
-
- _data->taskSemaphore.wait();
-
- {
- std::unique_lock<std::mutex> taskLock (_data->taskMutex);
-
- //
- // If there is a task pending, pop off the next task in the FIFO
- //
+ ProviderPtr curp = std::atomic_exchange (&_provider, provider);
+ if (curp && curp != provider) curp->finish ();
+ }
- if (!_data->tasks.empty())
- {
- Task* task = _data->tasks.back();
- _data->tasks.pop_back();
- // release the mutex while we process
- taskLock.unlock();
+ std::shared_ptr<ThreadPoolProvider> _provider;
+};
- TaskGroup* taskGroup = task->group();
- task->execute();
- delete task;
-
- taskGroup->_data->removeTask ();
- }
- else if (_data->stopped())
- {
- break;
- }
- }
- }
-}
+namespace {
//
// class DefaultThreadPoolProvider
//
class DefaultThreadPoolProvider : public ThreadPoolProvider
{
- public:
- DefaultThreadPoolProvider(int count);
- virtual ~DefaultThreadPoolProvider();
+public:
+ DefaultThreadPoolProvider (int count);
+ DefaultThreadPoolProvider (const DefaultThreadPoolProvider&) = delete;
+ DefaultThreadPoolProvider&
+ operator= (const DefaultThreadPoolProvider&) = delete;
+ DefaultThreadPoolProvider (DefaultThreadPoolProvider&&) = delete;
+ DefaultThreadPoolProvider& operator= (DefaultThreadPoolProvider&&) = delete;
+ ~DefaultThreadPoolProvider () override;
+
+ int numThreads () const override;
+ void setNumThreads (int count) override;
+ void addTask (Task* task) override;
- virtual int numThreads() const;
- virtual void setNumThreads(int count);
- virtual void addTask(Task *task);
+ void finish () override;
- virtual void finish();
+private:
+ void lockedFinish ();
+ void threadLoop (std::shared_ptr<DefaultThreadPoolData> d);
- private:
- DefaultWorkData _data;
+ std::shared_ptr<DefaultThreadPoolData> _data;
};
DefaultThreadPoolProvider::DefaultThreadPoolProvider (int count)
+ : _data (std::make_shared<DefaultThreadPoolData> ())
{
- setNumThreads(count);
+ _data->resetAtomics ();
+ setNumThreads (count);
}
DefaultThreadPoolProvider::~DefaultThreadPoolProvider ()
-{
- finish();
-}
+{}
int
DefaultThreadPoolProvider::numThreads () const
{
- std::lock_guard<std::mutex> lock (_data.threadMutex);
- return static_cast<int> (_data.threads.size());
+ return _data->_threadCount.load ();
}
void
DefaultThreadPoolProvider::setNumThreads (int count)
{
- //
- // Lock access to thread list and size
- //
+ // since we're a private class, the thread pool won't call us if
+ // we aren't changing size so no need to check that...
- std::lock_guard<std::mutex> lock (_data.threadMutex);
+ std::lock_guard<std::mutex> lock (_data->_threadMutex);
- size_t desired = static_cast<size_t>(count);
- if (desired > _data.threads.size())
- {
- //
- // Add more threads
- //
+ size_t curThreads = _data->_threads.size ();
+ size_t nToAdd = static_cast<size_t> (count);
- while (_data.threads.size() < desired)
- _data.threads.push_back (new DefaultWorkerThread (&_data));
- }
- else if ((size_t)count < _data.threads.size())
+ if (nToAdd < curThreads)
{
- //
- // Wait until all existing threads are finished processing,
- // then delete all threads.
- //
- finish ();
-
- //
- // Add in new threads
- //
-
- while (_data.threads.size() < desired)
- _data.threads.push_back (new DefaultWorkerThread (&_data));
+ // no easy way to only shutdown the n threads at the end of
+ // the vector (well, really, guaranteeing they are the ones to
+ // be woken up), so just kill all of the threads
+ lockedFinish ();
+ curThreads = 0;
}
- _data.hasThreads = !(_data.threads.empty());
+ _data->_threads.resize (nToAdd);
+ for (size_t i = curThreads; i < nToAdd; ++i)
+ {
+ _data->_threads[i] =
+ std::thread (&DefaultThreadPoolProvider::threadLoop, this, _data);
+ }
+ _data->_threadCount = static_cast<int> (_data->_threads.size ());
}
void
DefaultThreadPoolProvider::addTask (Task *task)
{
- //
- // Lock the threads, needed to access numThreads
- //
- bool doPush = _data.hasThreads.load( std::memory_order_relaxed );
-
- if ( doPush )
+ // the thread pool will kill us and switch to a null provider
+ // if the thread count is set to 0, so we can always
+ // go ahead and lock and assume we have a thread to do the
+ // processing
{
- //
- // Get exclusive access to the tasks queue
- //
+ std::lock_guard<std::mutex> taskLock (_data->_taskMutex);
- {
- std::lock_guard<std::mutex> taskLock (_data.taskMutex);
-
- //
- // Push the new task into the FIFO
- //
- _data.tasks.push_back (task);
- }
-
//
- // Signal that we have a new task to process
+ // Push the new task into the FIFO
//
- _data.taskSemaphore.post ();
- }
- else
- {
- // this path shouldn't normally happen since we have the
- // NullThreadPoolProvider, but just in case...
- task->execute ();
- task->group()->_data->removeTask ();
- delete task;
+ _data->_tasks.push_back (task);
}
+
+ //
+ // Signal that we have a new task to process
+ //
+ _data->_taskSemaphore.post ();
}
void
DefaultThreadPoolProvider::finish ()
{
- _data.stop();
+ std::lock_guard<std::mutex> lock (_data->_threadMutex);
+
+ lockedFinish ();
+}
+
+void
+DefaultThreadPoolProvider::lockedFinish ()
+{
+ _data->stop ();
//
// Signal enough times to allow all threads to stop.
//
- // Wait until all threads have started their run functions.
- // If we do not wait before we destroy the threads then it's
- // possible that the threads have not yet called their run
- // functions.
- // If this happens then the run function will be called off
- // of an invalid object and we will crash, most likely with
- // an error like: "pure virtual method called"
+ // NB: we must do this as many times as we have threads.
//
-
- size_t curT = _data.threads.size();
+ // If there is still work in the queue, or this call happens "too
+ // quickly", threads will not be waiting on the semaphore, so we
+ // need to ensure the semaphore is at a count equal to the amount
+ // of work left plus the number of threads to ensure exit of a
+ // thread. There can be threads in a few states:
+ // - still starting up (successive calls to setNumThreads)
+ // - in the middle of processing a task / looping
+ // - waiting in the semaphore
+ size_t curT = _data->_threads.size ();
for (size_t i = 0; i != curT; ++i)
- {
- if (_data.threads[i]->joinable())
- {
- _data.taskSemaphore.post();
- _data.threadSemaphore.wait();
- }
- }
+ _data->_taskSemaphore.post ();
//
- // Join all the threads
+ // We should not need to check joinability, they should all, by
+ // definition, be joinable (assuming normal start)
//
for (size_t i = 0; i != curT; ++i)
{
- if (_data.threads[i]->joinable())
- _data.threads[i]->join();
- delete _data.threads[i];
+ // This isn't quite right in that the thread may have actually
+ // be in an exited / signalled state (needing the
+ // WaitForSingleObject call), and so already have an exit code
+ // (I think, but the docs are vague), but if we don't do the
+ // join, the stl thread seems to then throw an exception. The
+ // join should just return invalid handle and continue, and is
+ // more of a windows bug... except maybe someone needs to work
+ // around it...
+ //# ifdef TEST_FOR_WIN_THREAD_STATUS
+ //
+ // // per OIIO issue #2038, on exit / dll unload, windows may
+ // // kill the thread, double check that it is still active prior
+ // // to joining.
+ // DWORD tstatus;
+ // if (GetExitCodeThread (_threads[i].native_handle (), &tstatus))
+ // {
+ // if (tstatus != STILL_ACTIVE) { continue; }
+ // }
+ //# endif
+
+ _data->_threads[i].join ();
}
- std::lock_guard<std::mutex> lk( _data.taskMutex );
-
- _data.threads.clear();
- _data.tasks.clear();
+ _data->_threads.clear ();
- _data.stopping = false;
+ _data->resetAtomics ();
}
-
-class NullThreadPoolProvider : public ThreadPoolProvider
+void
+DefaultThreadPoolProvider::threadLoop (
+ std::shared_ptr<DefaultThreadPoolData> data)
{
- virtual ~NullThreadPoolProvider() {}
- virtual int numThreads () const { return 0; }
- virtual void setNumThreads (int count)
- {
- }
- virtual void addTask (Task *t)
+ while (true)
{
- t->execute ();
- t->group()->_data->removeTask ();
- delete t;
+ //
+ // Wait for a task to become available
+ //
+
+ data->_taskSemaphore.wait ();
+
+ {
+ std::unique_lock<std::mutex> taskLock (data->_taskMutex);
+
+ //
+ // If there is a task pending, pop off the next task in the FIFO
+ //
+
+ if (!data->_tasks.empty ())
+ {
+ Task* task = data->_tasks.back ();
+ data->_tasks.pop_back ();
+
+ // release the mutex while we process
+ taskLock.unlock ();
+
+ handleProcessTask (task);
+
+ // do not need to reacquire the lock at all since we
+ // will just loop around, pull any other task
+ }
+ else if (data->stopped ()) { break; }
+ }
}
- virtual void finish () {}
-};
+}
} //namespace
@@ -409,81 +335,69 @@ class NullThreadPoolProvider : public ThreadPoolProvider
// struct TaskGroup::Data
//
-TaskGroup::Data::Data () : numPending (0), isEmpty (1)
-{
- // empty
-}
+TaskGroup::Data::Data () : numPending (0), inFlight (0), isEmpty (1)
+{}
TaskGroup::Data::~Data ()
+{}
+
+void
+TaskGroup::Data::waitForEmpty ()
{
//
// A TaskGroup acts like an "inverted" semaphore: if the count
- // is above 0 then waiting on the taskgroup will block. This
+ // is above 0 then waiting on the taskgroup will block. The
// destructor waits until the taskgroup is empty before returning.
//
isEmpty.wait ();
-#ifdef ENABLE_SEM_DTOR_WORKAROUND
- // Update: this was fixed in v. 2.2.21, so this ifdef checks for that
- //
- // Alas, given the current bug in glibc we need a secondary
- // syncronisation primitive here to account for the fact that
- // destructing the isEmpty Semaphore in this thread can cause
- // an error for a separate thread that is issuing the post() call.
- // We are entitled to destruct the semaphore at this point, however,
- // that post() call attempts to access data out of the associated
- // memory *after* it has woken the waiting threads, including this one,
- // potentially leading to invalid memory reads.
- // http://sources.redhat.com/bugzilla/show_bug.cgi?id=12674
-
- std::lock_guard<std::mutex> lock (dtorMutex);
-#endif
+ // pseudo spin to wait for the notifying thread to finish the post
+ // to avoid a premature deletion of the semaphore
+ int count = 0;
+ while (inFlight.load () > 0)
+ {
+ ++count;
+ if (count > 100)
+ {
+ std::this_thread::yield ();
+ count = 0;
+ }
+ }
}
void
TaskGroup::Data::addTask ()
{
- //
- // in c++11, we use an atomic to protect numPending to avoid the
- // extra lock but for c++98, to add the ability for custom thread
- // pool we add the lock here
- //
- if (numPending++ == 0)
- isEmpty.wait ();
+ inFlight.fetch_add (1);
+
+ // if we are the first task off the rank, clear the
+ // isEmpty semaphore such that the group will actually pause
+ // until the task finishes
+ if (numPending.fetch_add (1) == 0) { isEmpty.wait (); }
}
void
TaskGroup::Data::removeTask ()
{
- // Alas, given the current bug in glibc we need a secondary
- // syncronisation primitive here to account for the fact that
- // destructing the isEmpty Semaphore in a separate thread can
- // cause an error. Issuing the post call here the current libc
- // implementation attempts to access memory *after* it has woken
- // waiting threads.
- // Since other threads are entitled to delete the semaphore the
- // access to the memory location can be invalid.
- // http://sources.redhat.com/bugzilla/show_bug.cgi?id=12674
- // Update: this bug has been fixed, but how do we know which
- // glibc version we're in?
-
- // Further update:
+ // if we are the last task, notify the group we're done
+ if (numPending.fetch_sub (1) == 1) { isEmpty.post (); }
+
+ // in theory, a background thread could actually finish a task
+ // prior to the next task being added. The fetch_add / fetch_sub
+ // logic between addTask and removeTask are fine to keep the
+ // inverted semaphore straight. All addTask must happen prior to
+ // the TaskGroup destructor.
//
- // we could remove this if it is a new enough glibc, however
- // we've changed the API to enable a custom override of a
- // thread pool. In order to provide safe access to the numPending,
- // we need the lock anyway, except for c++11 or newer
- if (--numPending == 0)
- {
-#ifdef ENABLE_SEM_DTOR_WORKAROUND
- std::lock_guard<std::mutex> lk (dtorMutex);
-#endif
- isEmpty.post ();
- }
+ // But to let the taskgroup thread waiting know we're actually
+ // finished with the last one and finished posting (the semaphore
+ // might wake up the other thread while in the middle of post) so
+ // we don't destroy the semaphore while posting to it, keep a
+ // separate counter that is modified pre / post semaphore
+ inFlight.fetch_sub (1);
}
@@ -491,8 +405,7 @@ TaskGroup::Data::removeTask ()
// struct ThreadPool::Data
//
-ThreadPool::Data::Data ():
- provUsers (0), provider (NULL)
+ThreadPool::Data::Data ()
{
// empty
}
@@ -500,82 +413,7 @@ ThreadPool::Data::Data ():
ThreadPool::Data::~Data()
{
- ThreadPoolProvider *p = provider.load( std::memory_order_relaxed );
- p->finish();
- delete p;
-}
-
-inline ThreadPool::Data::SafeProvider
-ThreadPool::Data::getProvider ()
-{
- provUsers.fetch_add( 1, std::memory_order_relaxed );
- return SafeProvider( this, provider.load( std::memory_order_relaxed ) );
-}
-
-
-inline void
-ThreadPool::Data::coalesceProviderUse ()
-{
- int ov = provUsers.fetch_sub( 1, std::memory_order_relaxed );
- // ov is the previous value, so one means that now it might be 0
- if ( ov == 1 )
- {
- // do we have anything to do here?
- }
-}
-
-
-inline void
-ThreadPool::Data::bumpProviderUse ()
-{
- provUsers.fetch_add( 1, std::memory_order_relaxed );
-}
-
-
-inline void
-ThreadPool::Data::setProvider (ThreadPoolProvider *p)
-{
- ThreadPoolProvider *old = provider.load( std::memory_order_relaxed );
- // work around older gcc bug just in case
- do
- {
- if ( ! provider.compare_exchange_weak( old, p, std::memory_order_release, std::memory_order_relaxed ) )
- continue;
- } while (false); // NOSONAR - suppress SonarCloud bug report.
-
- // wait for any other users to finish prior to deleting, given
- // that these are just mostly to query the thread count or push a
- // task to the queue (so fast), just spin...
- //
- // (well, and normally, people don't do this mid stream anyway, so
- // this will be 0 99.999% of the time, but just to be safe)
- //
- while ( provUsers.load( std::memory_order_relaxed ) > 0 )
- std::this_thread::yield();
-
- if ( old )
- {
- old->finish();
- delete old;
- }
-
- // NB: the shared_ptr mechanism is safer and means we don't have
- // to have the provUsers counter since the shared_ptr keeps that
- // for us. However, gcc 4.8/9 compilers which many people are
- // still using even though it is 2018 forgot to add the shared_ptr
- // functions... once that compiler is fully deprecated, switch to
- // using the below, change provider to a std::shared_ptr and remove
- // provUsers...
- //
-// std::shared_ptr<ThreadPoolProvider> newp( p );
-// std::shared_ptr<ThreadPoolProvider> curp = std::atomic_load_explicit( &provider, std::memory_order_relaxed );
-// do
-// {
-// if ( ! std::atomic_compare_exchange_weak_explicit( &provider, &curp, newp, std::memory_order_release, std::memory_order_relaxed ) )
-// continue;
-// } while ( false );
-// if ( curp )
-// curp->finish();
+ setProvider (nullptr);
}
#endif // ENABLE_THREADING
@@ -608,7 +446,7 @@ Task::group ()
TaskGroup::TaskGroup ():
#ifdef ENABLE_THREADING
- _data (new Data())
+ _data (new Data)
#else
_data (nullptr)
#endif
@@ -620,6 +458,7 @@ TaskGroup::TaskGroup ():
TaskGroup::~TaskGroup ()
{
#ifdef ENABLE_THREADING
+ _data->waitForEmpty ();
delete _data;
#endif
}
@@ -660,10 +499,7 @@ ThreadPool::ThreadPool (unsigned nthreads):
#endif
{
#ifdef ENABLE_THREADING
- if ( nthreads == 0 )
- _data->setProvider( new NullThreadPoolProvider );
- else
- _data->setProvider( new DefaultThreadPoolProvider( int(nthreads) ) );
+ setNumThreads (static_cast<int> (nthreads));
#endif
}
@@ -671,6 +507,8 @@ ThreadPool::ThreadPool (unsigned nthreads):
ThreadPool::~ThreadPool ()
{
#ifdef ENABLE_THREADING
+ // ensures any jobs / threads are finished & shutdown
+ _data->setProvider (nullptr);
delete _data;
#endif
}
@@ -680,7 +518,8 @@ int
ThreadPool::numThreads () const
{
#ifdef ENABLE_THREADING
- return _data->getProvider ()->numThreads ();
+ Data::ProviderPtr sp = _data->getProvider ();
+ return (sp) ? sp->numThreads () : 0;
#else
return 0;
#endif
@@ -695,36 +534,30 @@ ThreadPool::setNumThreads (int count)
throw IEX_INTERNAL_NAMESPACE::ArgExc ("Attempt to set the number of threads "
"in a thread pool to a negative value.");
- bool doReset = false;
{
- Data::SafeProvider sp = _data->getProvider ();
- int curT = sp->numThreads ();
- if ( curT == count )
- return;
-
- if ( curT == 0 )
+ Data::ProviderPtr sp = _data->getProvider ();
+ if (sp)
{
- NullThreadPoolProvider *npp = dynamic_cast<NullThreadPoolProvider *>( sp.get() );
- if ( npp )
- doReset = true;
- }
- else if ( count == 0 )
- {
- DefaultThreadPoolProvider *dpp = dynamic_cast<DefaultThreadPoolProvider *>( sp.get() );
- if ( dpp )
- doReset = true;
+ bool doReset = false;
+ int curT = sp->numThreads ();
+ if (curT == count) return;
+
+ if (count != 0)
+ {
+ sp->setNumThreads (count);
+ return;
+ }
}
- if ( ! doReset )
- sp->setNumThreads( count );
}
- if ( doReset )
- {
- if ( count == 0 )
- _data->setProvider( new NullThreadPoolProvider );
- else
- _data->setProvider( new DefaultThreadPoolProvider( count ) );
- }
+ // either a null provider or a case where we should switch from
+ // a default provider to a null one or vice-versa
+ if (count == 0)
+ _data->setProvider (nullptr);
+ else
+ _data->setProvider (
+ std::make_shared<DefaultThreadPoolProvider> (count));
+
#else
// just blindly ignore
(void)count;
@@ -736,7 +569,8 @@ void
ThreadPool::setThreadProvider (ThreadPoolProvider *provider)
{
#ifdef ENABLE_THREADING
- _data->setProvider (provider);
+ // contract is we take ownership and will free the provider
+ _data->setProvider (Data::ProviderPtr (provider));
#else
throw IEX_INTERNAL_NAMESPACE::ArgExc (
"Attempt to set a thread provider on a system with threads"
@@ -748,12 +582,19 @@ ThreadPool::setThreadProvider (ThreadPoolProvider *provider)
void
ThreadPool::addTask (Task* task)
{
+ if (task)
+ {
#ifdef ENABLE_THREADING
- _data->getProvider ()->addTask (task);
-#else
- task->execute ();
- delete task;
+ Data::ProviderPtr p = _data->getProvider ();
+ if (p)
+ {
+ p->addTask (task);
+ return;
+ }
#endif
+
+ handleProcessTask (task);
+ }
}
@@ -780,7 +621,24 @@ unsigned
ThreadPool::estimateThreadCountForFileIO ()
{
#ifdef ENABLE_THREADING
- return std::thread::hardware_concurrency ();
+ unsigned rv = std::thread::hardware_concurrency ();
+ // hardware concurrency is not required to work
+ if (rv == 0 ||
+ rv > static_cast<unsigned> (std::numeric_limits<int>::max ()))
+ {
+ rv = 1;
+# if (defined(_WIN32) || defined(_WIN64))
+ SYSTEM_INFO si;
+ GetNativeSystemInfo (&si);
+
+ rv = si.dwNumberOfProcessors;
+# else
+ // linux, bsd, and mac are fine with this
+ // other *nix should be too, right?
+ rv = sysconf (_SC_NPROCESSORS_ONLN);
+# endif
+ }
+ return rv;
#else
return 0;
#endif
diff --git a/src/lib/IlmThread/IlmThreadSemaphore.h b/src/lib/IlmThread/IlmThreadSemaphore.h
index f26e48a09..576968aa6 100644
--- a/src/lib/IlmThread/IlmThreadSemaphore.h
+++ b/src/lib/IlmThread/IlmThreadSemaphore.h
@@ -64,10 +64,10 @@ class ILMTHREAD_EXPORT_TYPE Semaphore
mutable HANDLE _semaphore;
#elif ILMTHREAD_THREADING_ENABLED
- //
- // If the platform has threads but no semapohores,
- // then we implement them ourselves using condition variables
- //
+ //
+ // If the platform has threads but no semaphores,
+ // then we implement them ourselves using condition variables
+ //
struct sema_t
{

View File

@@ -0,0 +1,140 @@
diff --git a/openexr_original/cmake/OpenEXRSetup.cmake b/openexr/cmake/OpenEXRSetup.cmake
index 425992d..fa80886 100644
--- a/openexr_original/cmake/OpenEXRSetup.cmake
+++ b/openexr/cmake/OpenEXRSetup.cmake
@@ -160,71 +160,79 @@ set(OPENEXR_DEFLATE_TAG "v1.18" CACHE STRING "Tag to use for libdeflate source r
if(NOT OPENEXR_FORCE_INTERNAL_DEFLATE)
#TODO: ^^ Release should not clone from main, this is a place holder
set(CMAKE_IGNORE_PATH "${CMAKE_CURRENT_BINARY_DIR}/_deps/deflate-src/config;${CMAKE_CURRENT_BINARY_DIR}/_deps/deflate-build/config")
- include(FindPkgConfig)
- pkg_check_modules(deflate IMPORTED_TARGET GLOBAL libdeflate)
- set(CMAKE_IGNORE_PATH)
- if (deflate_FOUND)
- message(STATUS "Using libdeflate from ${deflate_LINK_LIBRARIES}")
+ find_package(libdeflate CONFIG)
+ if(libdeflate_FOUND)
+ message(STATUS "Using libdeflate from ${libdeflate_DIR}")
+ else()
+ include(FindPkgConfig)
+ pkg_check_modules(deflate IMPORTED_TARGET GLOBAL libdeflate)
+ set(CMAKE_IGNORE_PATH)
+ if (deflate_FOUND)
+ message(STATUS "Using libdeflate from ${deflate_LINK_LIBRARIES}")
+ endif()
endif()
endif()
-if(NOT TARGET PkgConfig::deflate AND NOT deflate_FOUND)
- if(OPENEXR_FORCE_INTERNAL_DEFLATE)
- message(STATUS "libdeflate forced internal, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
- else()
- message(STATUS "libdeflate was not found, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
- endif()
- include(FetchContent)
- FetchContent_Declare(Deflate
- GIT_REPOSITORY "${OPENEXR_DEFLATE_REPO}"
- GIT_TAG "${OPENEXR_DEFLATE_TAG}"
- GIT_SHALLOW ON
- )
+if(libdeflate_FOUND)
+ set(EXR_DEFLATE_LIB libdeflate::libdeflate_static)
+else()
+ if(NOT TARGET PkgConfig::deflate AND NOT deflate_FOUND)
+ if(OPENEXR_FORCE_INTERNAL_DEFLATE)
+ message(STATUS "libdeflate forced internal, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
+ else()
+ message(STATUS "libdeflate was not found, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
+ endif()
+ include(FetchContent)
+ FetchContent_Declare(Deflate
+ GIT_REPOSITORY "${OPENEXR_DEFLATE_REPO}"
+ GIT_TAG "${OPENEXR_DEFLATE_TAG}"
+ GIT_SHALLOW ON
+ )
- FetchContent_GetProperties(Deflate)
- if(NOT Deflate_POPULATED)
- FetchContent_Populate(Deflate)
- endif()
+ FetchContent_GetProperties(Deflate)
+ if(NOT Deflate_POPULATED)
+ FetchContent_Populate(Deflate)
+ endif()
- # Rather than actually compile something, just embed the sources
- # into exrcore. This could in theory cause issues when compiling as
- # a static library into another application which also uses
- # libdeflate but we switch the export symbol to hidden which should
- # hide the symbols when linking...
- set(EXR_DEFLATE_SOURCES
- lib/arm/cpu_features.c
- lib/x86/cpu_features.c
- lib/utils.c
- lib/deflate_compress.c
- lib/deflate_decompress.c
- lib/adler32.c
- lib/zlib_compress.c
- lib/zlib_decompress.c)
- # don't need these
- # lib/crc32.c
- # lib/gzip_compress.c
- # lib/gzip_decompress.c
- file(READ ${deflate_SOURCE_DIR}/lib/lib_common.h DEFLATE_HIDE)
- string(REPLACE "visibility(\"default\")" "visibility(\"hidden\")" DEFLATE_HIDE "${DEFLATE_HIDE}")
- string(REPLACE "__declspec(dllexport)" "/**/" DEFLATE_HIDE "${DEFLATE_HIDE}")
- file(WRITE ${deflate_SOURCE_DIR}/lib/lib_common.h "${DEFLATE_HIDE}")
+ # Rather than actually compile something, just embed the sources
+ # into exrcore. This could in theory cause issues when compiling as
+ # a static library into another application which also uses
+ # libdeflate but we switch the export symbol to hidden which should
+ # hide the symbols when linking...
+ set(EXR_DEFLATE_SOURCES
+ lib/arm/cpu_features.c
+ lib/x86/cpu_features.c
+ lib/utils.c
+ lib/deflate_compress.c
+ lib/deflate_decompress.c
+ lib/adler32.c
+ lib/zlib_compress.c
+ lib/zlib_decompress.c)
+ # don't need these
+ # lib/crc32.c
+ # lib/gzip_compress.c
+ # lib/gzip_decompress.c
+ file(READ ${deflate_SOURCE_DIR}/lib/lib_common.h DEFLATE_HIDE)
+ string(REPLACE "visibility(\"default\")" "visibility(\"hidden\")" DEFLATE_HIDE "${DEFLATE_HIDE}")
+ string(REPLACE "__declspec(dllexport)" "/**/" DEFLATE_HIDE "${DEFLATE_HIDE}")
+ file(WRITE ${deflate_SOURCE_DIR}/lib/lib_common.h "${DEFLATE_HIDE}")
- # cmake makes fetch content name lowercase for the properties (to deflate)
- list(TRANSFORM EXR_DEFLATE_SOURCES PREPEND ${deflate_SOURCE_DIR}/)
- set(EXR_DEFLATE_INCLUDE_DIR ${deflate_SOURCE_DIR})
- set(EXR_DEFLATE_LIB)
-else()
- set(EXR_DEFLATE_INCLUDE_DIR)
- set(EXR_DEFLATE_LIB ${deflate_LIBRARIES})
- # set EXR_DEFATE_LDFLAGS for OpenEXR.pc.in for static build
- if (BUILD_SHARED_LIBS)
- set(EXR_DEFLATE_LDFLAGS "")
+ # cmake makes fetch content name lowercase for the properties (to deflate)
+ list(TRANSFORM EXR_DEFLATE_SOURCES PREPEND ${deflate_SOURCE_DIR}/)
+ set(EXR_DEFLATE_INCLUDE_DIR ${deflate_SOURCE_DIR})
+ set(EXR_DEFLATE_LIB)
else()
- set(EXR_DEFLATE_LDFLAGS "-l${deflate_LIBRARIES}")
+ set(EXR_DEFLATE_INCLUDE_DIR)
+ set(EXR_DEFLATE_LIB ${deflate_LIBRARIES})
+ # set EXR_DEFATE_LDFLAGS for OpenEXR.pc.in for static build
+ if (BUILD_SHARED_LIBS)
+ set(EXR_DEFLATE_LDFLAGS "")
+ else()
+ set(EXR_DEFLATE_LDFLAGS "-l${deflate_LIBRARIES}")
+ endif()
+ set(EXR_DEFLATE_SOURCES)
endif()
- set(EXR_DEFLATE_SOURCES)
endif()
-
#######################################
# Find or install Imath
#######################################

View File

@@ -1,7 +1,7 @@
diff -Naur orig/CMakeLists.txt external_openimageio/CMakeLists.txt
--- orig/CMakeLists.txt 2020-05-10 21:43:52 -0600
+++ external_openimageio/CMakeLists.txt 2020-05-13 17:03:35 -0600
@@ -170,7 +170,7 @@
@@ -237,7 +237,7 @@
add_subdirectory (src/iinfo)
add_subdirectory (src/maketx)
add_subdirectory (src/oiiotool)
@@ -13,7 +13,7 @@ diff -Naur orig/CMakeLists.txt external_openimageio/CMakeLists.txt
diff -Naur orig/src/cmake/compiler.cmake external_openimageio/src/cmake/compiler.cmake
--- orig/src/cmake/compiler.cmake 2020-05-10 21:43:52 -0600
+++ external_openimageio/src/cmake/compiler.cmake 2020-05-13 17:02:54 -0600
@@ -172,6 +172,7 @@
@@ -188,6 +189,7 @@
add_definitions (-D_CRT_NONSTDC_NO_WARNINGS)
add_definitions (-D_SCL_SECURE_NO_WARNINGS)
add_definitions (-DJAS_WIN_MSVC_BUILD)

View File

@@ -75,40 +75,3 @@ diff -Naur openvdb-8.0.0/openvdb/openvdb/version.rc.in openvdb/openvdb/openvdb/v
+
+ END
+END
diff -Naur orig/openvdb/openvdb/tree/ValueAccessor.h openvdb/openvdb/openvdb/tree/ValueAccessor.h
--- orig/openvdb/openvdb/tree/ValueAccessor.h 2022-11-02 13:58:26 -0600
+++ openvdb/openvdb/openvdb/tree/ValueAccessor.h 2022-11-02 18:55:09 -0600
@@ -872,7 +872,10 @@
using LeafNodeType = typename NodeType::LeafNodeType;
using CoordLimits = std::numeric_limits<Int32>;
- static_assert(std::is_same<NodeType, LeafNodeType>::value);
+ // Blender: Technically not an issue in OpenVDB, but USD 21.11 still builds
+ // as C++14 which does not support terse asserts yet. Add a message to
+ // explicitly select the C++14 supported static assert.
+ static_assert(std::is_same<NodeType, LeafNodeType>::value, "cache item node type is not leaf node type");
CacheItem(TreeCacheT& parent)
: mParent(&parent)
diff --git a/nanovdb/nanovdb/NanoVDB.h b/nanovdb/nanovdb/NanoVDB.h
index f7fc304..fde5c47 100644
--- a/nanovdb/nanovdb/NanoVDB.h
+++ b/nanovdb/nanovdb/NanoVDB.h
@@ -1877,7 +1877,7 @@ __hostdev__ static inline uint32_t FindLowestOn(uint64_t v)
{
NANOVDB_ASSERT(v);
#if (defined(__CUDA_ARCH__) || defined(__HIP__)) && defined(NANOVDB_USE_INTRINSICS)
- return __ffsll(v);
+ return __ffsll(static_cast<unsigned long long int>(v));
#elif defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS)
unsigned long index;
_BitScanForward64(&index, v);
@@ -2592,7 +2592,7 @@ public:
///
/// @note This method is only defined for IndexGrid = NanoGrid<ValueIndex>
template <typename T = BuildType>
- __hostdev__ typename enable_if<is_same<T, ValueIndex>::value, uint64_t>::type valueCount() const {return DataType::mData1;}
+ __hostdev__ typename enable_if<is_same<T, ValueIndex>::value, const uint64_t&>::type valueCount() const {return DataType::mData1;}
/// @brief Return a const reference to the tree
__hostdev__ const TreeT& tree() const { return *reinterpret_cast<const TreeT*>(this->treePtr()); }

View File

@@ -0,0 +1,81 @@
diff --git a/openvdb/openvdb/python/pyGrid.h b/openvdb/openvdb/python/pyGrid.h
index 9249eaf6d..f4c859110 100644
--- a/openvdb/openvdb/python/pyGrid.h
+++ b/openvdb/openvdb/python/pyGrid.h
@@ -322,7 +322,7 @@ copyToArray(GridType&, const py::object&, py::object)
#else // if defined(PY_OPENVDB_USE_NUMPY)
-using ArrayDimVec = std::vector<ssize_t>;
+using ArrayDimVec = std::vector<Py_ssize_t>;
// ID numbers for supported value types
enum class DtId { NONE, FLOAT, DOUBLE, BOOL, INT16, INT32, INT64, UINT32, UINT64/*, HALF*/ };
@@ -768,12 +768,12 @@ template<typename GridType>
inline typename GridType::Ptr
meshToLevelSet(py::array_t<float> pointsObj, py::array_t<Index32> trianglesObj, py::array_t<Index32> quadsObj, math::Transform::Ptr xform, float halfWidth)
{
- auto validate2DArray = [](py::array array, ssize_t N) {
+ auto validate2DArray = [](py::array array, Py_ssize_t N) {
if (array.ndim() != 2 || array.shape(1) != N) {
std::ostringstream os;
os << "Expected a 2-dimensional numpy.ndarray with shape(1) = "<< N;
os << ", found " << array.ndim() << "-dimensional array with shape = (";
- for (ssize_t i = 0; i < array.ndim(); ++i) {
+ for (Py_ssize_t i = 0; i < array.ndim(); ++i) {
os << array.shape(i);
if (i != array.ndim() - 1)
os << ", ";
@@ -826,12 +826,12 @@ volumeToQuadMesh(const GridType& grid, double isovalue)
std::vector<Vec4I> quads;
tools::volumeToMesh(grid, points, quads, isovalue);
- std::vector<ssize_t> shape = { static_cast<ssize_t>(points.size()), 3 };
- std::vector<ssize_t> strides = { 3 * static_cast<ssize_t>(sizeof(float)), static_cast<ssize_t>(sizeof(float))};
+ std::vector<Py_ssize_t> shape = { static_cast<Py_ssize_t>(points.size()), 3 };
+ std::vector<Py_ssize_t> strides = { 3 * static_cast<Py_ssize_t>(sizeof(float)), static_cast<Py_ssize_t>(sizeof(float))};
py::array_t<float> pointArrayObj(py::buffer_info(points.data(), sizeof(float), py::format_descriptor<float>::format(), 2, shape, strides));
- shape = { static_cast<ssize_t>(quads.size()), 4 };
- strides = { 4 * static_cast<ssize_t>(sizeof(Index32)), static_cast<ssize_t>(sizeof(Index32))};
+ shape = { static_cast<Py_ssize_t>(quads.size()), 4 };
+ strides = { 4 * static_cast<Py_ssize_t>(sizeof(Index32)), static_cast<Py_ssize_t>(sizeof(Index32))};
py::array_t<Index32> quadArrayObj(py::buffer_info(quads.data(), sizeof(Index32), py::format_descriptor<Index32>::format(), 2, shape, strides));
return std::make_tuple(pointArrayObj, quadArrayObj);
@@ -857,18 +857,18 @@ volumeToMesh(const GridType& grid, double isovalue, double adaptivity)
// Create a deep copy of the array (because the point vector will be destroyed
// when this function returns).
- std::vector<ssize_t> shape = { static_cast<ssize_t>(points.size()), 3 };
- std::vector<ssize_t> strides = { 3 * static_cast<ssize_t>(sizeof(float)), static_cast<ssize_t>(sizeof(float))};
+ std::vector<Py_ssize_t> shape = { static_cast<Py_ssize_t>(points.size()), 3 };
+ std::vector<Py_ssize_t> strides = { 3 * static_cast<Py_ssize_t>(sizeof(float)), static_cast<Py_ssize_t>(sizeof(float))};
py::buffer_info pointInfo(points.data(), sizeof(float), py::format_descriptor<float>::format(), 2, shape, strides);
py::array_t<float> pointArray(pointInfo);
- shape = { static_cast<ssize_t>(triangles.size()), 3 };
- strides = { 3 * static_cast<ssize_t>(sizeof(Index32)), static_cast<ssize_t>(sizeof(Index32))};
+ shape = { static_cast<Py_ssize_t>(triangles.size()), 3 };
+ strides = { 3 * static_cast<Py_ssize_t>(sizeof(Index32)), static_cast<Py_ssize_t>(sizeof(Index32))};
py::buffer_info triangleInfo(triangles.data(), sizeof(Index32), py::format_descriptor<Index32>::format(), 2, shape, strides);
py::array_t<Index32> triangleArray(triangleInfo);
- shape = { static_cast<ssize_t>(quads.size()), 4 };
- strides = { 4 * static_cast<ssize_t>(sizeof(Index32)), static_cast<ssize_t>(sizeof(Index32))};
+ shape = { static_cast<Py_ssize_t>(quads.size()), 4 };
+ strides = { 4 * static_cast<Py_ssize_t>(sizeof(Index32)), static_cast<Py_ssize_t>(sizeof(Index32))};
py::buffer_info quadInfo(quads.data(), sizeof(Index32), py::format_descriptor<Index32>::format(), 2, shape, strides);
py::array_t<Index32> quadArray(quadInfo);
@@ -1590,8 +1590,8 @@ exportGrid(py::module_ m)
&pyGrid::meshToLevelSet<GridType>,
py::arg("points"),
#ifdef PY_OPENVDB_USE_NUMPY
- py::arg("triangles")=py::array_t<Index32>({ 0, 3 }, { 3 * static_cast<ssize_t>(sizeof(Index32)), static_cast<ssize_t>(sizeof(Index32))} ),
- py::arg("quads")=py::array_t<Index32>({ 0, 4 }, { 4 * static_cast<ssize_t>(sizeof(Index32)), static_cast<ssize_t>(sizeof(Index32))} ),
+ py::arg("triangles")=py::array_t<Index32>({ 0, 3 }, { 3 * static_cast<Py_ssize_t>(sizeof(Index32)), static_cast<Py_ssize_t>(sizeof(Index32))} ),
+ py::arg("quads")=py::array_t<Index32>({ 0, 4 }, { 4 * static_cast<Py_ssize_t>(sizeof(Index32)), static_cast<Py_ssize_t>(sizeof(Index32))} ),
#else
py::arg("triangles")=std::vector<Index32>(),
py::arg("quads")=std::vector<Index32>(),

View File

@@ -0,0 +1,21 @@
diff --git a/openvdb/openvdb/math/Half.h b/openvdb/openvdb/math/Half.h
index b8045ba441..ba72b0e6df 100644
--- a/openvdb/openvdb/math/Half.h
+++ b/openvdb/openvdb/math/Half.h
@@ -342,8 +342,14 @@ imath_half_to_float (imath_half_bits_t h)
// other compilers may provide count-leading-zeros primitives,
// but we need the community to inform us of the variants
uint32_t lc;
-# if defined(_MSC_VER) && (_M_IX86 || _M_X64)
- lc = __lzcnt (hexpmant);
+# if defined(_MSC_VER)
+ // The direct intrinsic for this is __lznct, but that is not supported
+ // on older x86_64 hardware or ARM. Instead uses the bsr instruction
+ // and one additional subtraction. This assumes hexpmant != 0, for 0
+ // bsr and lznct would behave differently.
+ unsigned long bsr;
+ _BitScanReverse (&bsr, hexpmant);
+ lc = (31 - bsr);
# elif defined(__GNUC__) || defined(__clang__)
lc = (uint32_t) __builtin_clz (hexpmant);
# else

View File

@@ -1,31 +1,3 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d527232..5ad6eaa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,6 +99,11 @@ set (OSL_PTX_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/ptx"
CACHE STRING "Directory where OptiX PTX files will be installed")
set (CMAKE_DEBUG_POSTFIX "" CACHE STRING "Library naming postfix for Debug builds (e.g., '_debug')")
+set (USE_OIIO_STATIC ON CACHE BOOL "If OIIO is built static")
+if (USE_OIIO_STATIC)
+ add_definitions ("-DOIIO_STATIC_BUILD=1")
+ add_definitions ("-DOIIO_STATIC_DEFINE=1")
+endif ()
set (OSL_NO_DEFAULT_TEXTURESYSTEM OFF CACHE BOOL "Do not use create a raw OIIO::TextureSystem")
if (OSL_NO_DEFAULT_TEXTURESYSTEM)
diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake
index a7e098b..dad11d0 100644
--- a/src/cmake/externalpackages.cmake
+++ b/src/cmake/externalpackages.cmake
@@ -77,6 +77,7 @@ link_directories ("${Boost_LIBRARY_DIRS}")
checked_find_package (ZLIB REQUIRED) # Needed by several packages
+checked_find_package (PNG REQUIRED) # Needed since OIIO needs it
# IlmBase & OpenEXR
checked_find_package (OpenEXR REQUIRED
diff --git a/src/liboslcomp/oslcomp.cpp b/src/liboslcomp/oslcomp.cpp
index 8c2e77b..211b8a7 100644
--- a/src/liboslcomp/oslcomp.cpp
@@ -44,70 +16,3 @@ index 8c2e77b..211b8a7 100644
#include <clang/Basic/TargetInfo.h>
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/TextDiagnosticPrinter.h>
diff --git a/src/liboslexec/llvm_instance.cpp b/src/liboslexec/llvm_instance.cpp
index 8f52546..8c2d0c7 100644
--- a/src/liboslexec/llvm_instance.cpp
+++ b/src/liboslexec/llvm_instance.cpp
@@ -1363,6 +1363,10 @@ BackendLLVM::run()
#ifdef OSL_LLVM_NO_BITCODE
OSL_ASSERT(!use_rs_bitcode());
ll.module(ll.new_module("llvm_ops"));
+ if (use_optix()) {
+ ll.module()->setDataLayout("e-i64:64-i128:128-v16:16-v32:32-n16:32:64");
+ ll.module()->setTargetTriple("nvptx64-nvidia-cuda");
+ }
#else
if (!use_optix()) {
if (use_rs_bitcode()) {
diff --git a/src/liboslexec/shadingsys.cpp b/src/liboslexec/shadingsys.cpp
index 46e4529..8e86486 100644
--- a/src/liboslexec/shadingsys.cpp
+++ b/src/liboslexec/shadingsys.cpp
@@ -2121,6 +2121,11 @@ ShadingSystemImpl::getattribute(ShaderGroup* group, string_view name,
return true;
}
+ if (name == "groupdata_size" && type == TypeDesc::TypeInt) {
+ *(int*)val = (int)group->m_llvm_groupdata_size;
+ return true;
+ }
+
return false;
}
diff --git a/src/liboslexec/CMakeLists.txt b/src/liboslexec/CMakeLists.txt
index 6bb0d175..19f13513 100644
--- a/src/liboslexec/CMakeLists.txt
+++ b/src/liboslexec/CMakeLists.txt
@@ -148,7 +148,9 @@ file (GLOB exec_headers "*.h")
file (GLOB compiler_headers "../liboslcomp/*.h")
FLEX_BISON ( osolex.l osogram.y oso lib_src exec_headers )
-FLEX_BISON ( ../liboslcomp/osllex.l ../liboslcomp/oslgram.y osl lib_src compiler_headers )
+if (BUILD_SHARED_LIBS)
+ FLEX_BISON ( ../liboslcomp/osllex.l ../liboslcomp/oslgram.y osl lib_src compiler_headers )
+endif()
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS" )
diff --git a/src/include/OSL/mask.h b/src/include/OSL/mask.h
index 24197af..b9275f6 100644
--- a/src/include/OSL/mask.h
+++ b/src/include/OSL/mask.h
@@ -4,7 +4,6 @@
#pragma once
-#include <immintrin.h>
#include <type_traits>
#include <OSL/oslconfig.h>
@@ -23,6 +22,8 @@ using std::countr_zero;
#elif OSL_INTEL_CLASSIC_COMPILER_VERSION
+#include <immintrin.h>
+
OSL_FORCEINLINE int popcount(uint32_t x) noexcept { return _mm_popcnt_u32(x);}
OSL_FORCEINLINE int popcount(uint64_t x) noexcept { return _mm_popcnt_u64(x); }
OSL_FORCEINLINE int countr_zero(uint32_t x) noexcept { return _bit_scan_forward(x); }

View File

@@ -0,0 +1,113 @@
diff --git a/tools/FindPythonLibsNew.cmake b/tools/FindPythonLibsNew.cmake
index ce558d4ece..104448597f 100644
--- a/tools/FindPythonLibsNew.cmake
+++ b/tools/FindPythonLibsNew.cmake
@@ -172,13 +172,20 @@ _pybind11_get_if_undef(_PYTHON_VALUES 0 _PYTHON_VERSION_LIST)
_pybind11_get_if_undef(_PYTHON_VALUES 1 PYTHON_PREFIX)
_pybind11_get_if_undef(_PYTHON_VALUES 2 PYTHON_INCLUDE_DIR)
_pybind11_get_if_undef(_PYTHON_VALUES 3 PYTHON_SITE_PACKAGES)
-_pybind11_get_if_undef(_PYTHON_VALUES 4 PYTHON_MODULE_EXTENSION)
_pybind11_get_if_undef(_PYTHON_VALUES 5 PYTHON_IS_DEBUG)
_pybind11_get_if_undef(_PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P)
_pybind11_get_if_undef(_PYTHON_VALUES 7 PYTHON_LIBRARY_SUFFIX)
_pybind11_get_if_undef(_PYTHON_VALUES 8 PYTHON_LIBDIR)
_pybind11_get_if_undef(_PYTHON_VALUES 9 PYTHON_MULTIARCH)
+list(GET _PYTHON_VALUES 4 _PYTHON_MODULE_EXT_SUFFIX)
+if(PYBIND11_PYTHONLIBS_OVERWRITE OR NOT DEFINED PYTHON_MODULE_DEBUG_POSTFIX)
+ get_filename_component(PYTHON_MODULE_DEBUG_POSTFIX "${_PYTHON_MODULE_EXT_SUFFIX}" NAME_WE)
+endif()
+if(PYBIND11_PYTHONLIBS_OVERWRITE OR NOT DEFINED PYTHON_MODULE_EXTENSION)
+ get_filename_component(PYTHON_MODULE_EXTENSION "${_PYTHON_MODULE_EXT_SUFFIX}" EXT)
+endif()
+
# Make sure the Python has the same pointer-size as the chosen compiler
# Skip if CMAKE_SIZEOF_VOID_P is not defined
# This should be skipped for (non-Apple) cross-compiles (like EMSCRIPTEN)
diff --git a/tools/pybind11NewTools.cmake b/tools/pybind11NewTools.cmake
index 7d7424a790..07bd2f90eb 100644
--- a/tools/pybind11NewTools.cmake
+++ b/tools/pybind11NewTools.cmake
@@ -95,25 +95,36 @@ endif()
# Get the suffix - SO is deprecated, should use EXT_SUFFIX, but this is
# required for PyPy3 (as of 7.3.1)
-if(NOT DEFINED PYTHON_MODULE_EXTENSION)
+if(NOT DEFINED PYTHON_MODULE_EXTENSION OR NOT DEFINED PYTHON_MODULE_DEBUG_POSTFIX)
execute_process(
COMMAND
"${${_Python}_EXECUTABLE}" "-c"
"import sys, importlib; s = importlib.import_module('distutils.sysconfig' if sys.version_info < (3, 10) else 'sysconfig'); print(s.get_config_var('EXT_SUFFIX') or s.get_config_var('SO'))"
- OUTPUT_VARIABLE _PYTHON_MODULE_EXTENSION
- ERROR_VARIABLE _PYTHON_MODULE_EXTENSION_ERR
+ OUTPUT_VARIABLE _PYTHON_MODULE_EXT_SUFFIX
+ ERROR_VARIABLE _PYTHON_MODULE_EXT_SUFFIX_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE)
- if(_PYTHON_MODULE_EXTENSION STREQUAL "")
+ if(_PYTHON_MODULE_EXT_SUFFIX STREQUAL "")
message(
FATAL_ERROR "pybind11 could not query the module file extension, likely the 'distutils'"
- "package is not installed. Full error message:\n${_PYTHON_MODULE_EXTENSION_ERR}")
+ "package is not installed. Full error message:\n${_PYTHON_MODULE_EXT_SUFFIX_ERR}"
+ )
endif()
# This needs to be available for the pybind11_extension function
- set(PYTHON_MODULE_EXTENSION
- "${_PYTHON_MODULE_EXTENSION}"
- CACHE INTERNAL "")
+ if(NOT DEFINED PYTHON_MODULE_DEBUG_POSTFIX)
+ get_filename_component(_PYTHON_MODULE_DEBUG_POSTFIX "${_PYTHON_MODULE_EXT_SUFFIX}" NAME_WE)
+ set(PYTHON_MODULE_DEBUG_POSTFIX
+ "${_PYTHON_MODULE_DEBUG_POSTFIX}"
+ CACHE INTERNAL "")
+ endif()
+
+ if(NOT DEFINED PYTHON_MODULE_EXTENSION)
+ get_filename_component(_PYTHON_MODULE_EXTENSION "${_PYTHON_MODULE_EXT_SUFFIX}" EXT)
+ set(PYTHON_MODULE_EXTENSION
+ "${_PYTHON_MODULE_EXTENSION}"
+ CACHE INTERNAL "")
+ endif()
endif()
# Python debug libraries expose slightly different objects before 3.8
@@ -251,6 +262,9 @@ endfunction()
function(pybind11_extension name)
# The extension is precomputed
- set_target_properties(${name} PROPERTIES PREFIX "" SUFFIX "${PYTHON_MODULE_EXTENSION}")
-
+ set_target_properties(
+ ${name}
+ PROPERTIES PREFIX ""
+ DEBUG_POSTFIX "${PYTHON_MODULE_DEBUG_POSTFIX}"
+ SUFFIX "${PYTHON_MODULE_EXTENSION}")
endfunction()
diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake
index 66ad00a478..874fc39ebb 100644
--- a/tools/pybind11Tools.cmake
+++ b/tools/pybind11Tools.cmake
@@ -65,6 +65,7 @@ _pybind11_promote_to_cache(PYTHON_INCLUDE_DIRS)
_pybind11_promote_to_cache(PYTHON_LIBRARIES)
_pybind11_promote_to_cache(PYTHON_MODULE_PREFIX)
_pybind11_promote_to_cache(PYTHON_MODULE_EXTENSION)
+_pybind11_promote_to_cache(PYTHON_MODULE_DEBUG_POSTFIX)
_pybind11_promote_to_cache(PYTHON_VERSION_MAJOR)
_pybind11_promote_to_cache(PYTHON_VERSION_MINOR)
_pybind11_promote_to_cache(PYTHON_VERSION)
@@ -148,8 +149,11 @@ endif()
function(pybind11_extension name)
# The prefix and extension are provided by FindPythonLibsNew.cmake
- set_target_properties(${name} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
- SUFFIX "${PYTHON_MODULE_EXTENSION}")
+ set_target_properties(
+ ${name}
+ PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
+ DEBUG_POSTFIX "${PYTHON_MODULE_DEBUG_POSTFIX}"
+ SUFFIX "${PYTHON_MODULE_EXTENSION}")
endfunction()
# Build a Python extension module:

View File

@@ -0,0 +1,49 @@
diff --git a/setup.py.orig b/setup.py
index a97a755..07ce853 100644
--- a/setup.py.orig
+++ b/setup.py
@@ -2168,7 +2168,7 @@
ffi_inc = None
print('Header file {} does not exist'.format(ffi_h))
if ffi_lib is None and ffi_inc:
- for lib_name in ('ffi', 'ffi_pic'):
+ for lib_name in ('ffi_pic', ):
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
ffi_lib = lib_name
break
--- a/Modules/posixmodule.c 2022-12-09 21:44:03
+++ b/Modules/posixmodule.c 2022-12-09 21:39:46
@@ -10564,10 +10564,15 @@
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_MKFIFOAT
if (dir_fd != DEFAULT_DIR_FD) {
+// BLENDER: disable also at compile time for compatibility when linking with older Xcode.
+// https://github.com/python/cpython/issues/97897
+#ifndef __APPLE__
if (HAVE_MKFIFOAT_RUNTIME) {
result = mkfifoat(dir_fd, path->narrow, mode);
+ } else
+#endif
+ {
- } else {
mkfifoat_unavailable = 1;
result = 0;
}
@@ -10638,10 +10633,15 @@
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_MKNODAT
if (dir_fd != DEFAULT_DIR_FD) {
+// BLENDER: disable also at compile time for compatibility when linking with older Xcode.
+// https://github.com/python/cpython/issues/97897
+#ifndef __APPLE__
if (HAVE_MKNODAT_RUNTIME) {
result = mknodat(dir_fd, path->narrow, mode, device);
+ } else
+#endif
+ {
- } else {
mknodat_unavailable = 1;
result = 0;
}

View File

@@ -2,31 +2,6 @@ diff --git a/setup.py.orig b/setup.py
index a97a755..07ce853 100644
--- a/setup.py.orig
+++ b/setup.py
@@ -1603,13 +1603,13 @@
version = line.split()[2]
break
if version >= version_req:
- if (self.compiler.find_library_file(self.lib_dirs, 'z')):
+ if (self.compiler.find_library_file(self.lib_dirs, 'z_pic')):
if MACOS:
zlib_extra_link_args = ('-Wl,-search_paths_first',)
else:
zlib_extra_link_args = ()
self.add(Extension('zlib', ['zlibmodule.c'],
- libraries=['z'],
+ libraries=['z_pic'],
extra_link_args=zlib_extra_link_args))
have_zlib = True
else:
@@ -1623,7 +1623,7 @@
# crc32 if we have it. Otherwise binascii uses its own.
if have_zlib:
extra_compile_args = ['-DUSE_ZLIB_CRC32']
- libraries = ['z']
+ libraries = ['z_pic']
extra_link_args = zlib_extra_link_args
else:
extra_compile_args = []
@@ -2168,7 +2168,7 @@
ffi_inc = None
print('Header file {} does not exist'.format(ffi_h))
@@ -36,39 +11,32 @@ index a97a755..07ce853 100644
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):
ffi_lib = lib_name
break
--- a/Modules/posixmodule.c 2022-12-09 21:44:03
+++ b/Modules/posixmodule.c 2022-12-09 21:39:46
@@ -10564,10 +10564,15 @@
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_MKFIFOAT
if (dir_fd != DEFAULT_DIR_FD) {
+// BLENDER: disable also at compile time for compatibility when linking with older Xcode.
+// https://github.com/python/cpython/issues/97897
+#ifndef __APPLE__
if (HAVE_MKFIFOAT_RUNTIME) {
result = mkfifoat(dir_fd, path->narrow, mode);
--- a/configure 2023-12-10 05:22:18.130767840 +0100
+++ b/configure 2023-12-10 05:22:05.210521365 +0100
@@ -11258,7 +11258,7 @@
#define HAVE_LIBDL 1
_ACEOF
+ } else
+#endif
+ {
- } else {
mkfifoat_unavailable = 1;
result = 0;
}
@@ -10638,10 +10633,15 @@
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_MKNODAT
if (dir_fd != DEFAULT_DIR_FD) {
+// BLENDER: disable also at compile time for compatibility when linking with older Xcode.
+// https://github.com/python/cpython/issues/97897
+#ifndef __APPLE__
if (HAVE_MKNODAT_RUNTIME) {
result = mknodat(dir_fd, path->narrow, mode, device);
- LIBS="-ldl $LIBS"
+ LIBS="-ldl -lm $LIBS"
fi
# Dynamic linking for SunOS/Solaris and SYSV
@@ -23231,7 +23231,7 @@
save_LIBS=$LIBS
- LIBS="$LIBS $OPENSSL_LIBS"
+ LIBS="$OPENSSL_LIBS $LIBS"
CFLAGS="$CFLAGS $OPENSSL_INCLUDES"
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH"
@@ -23292,7 +23292,7 @@
save_LIBS=$LIBS
- LIBS="$LIBS $LIBCRYPTO_LIBS"
+ LIBS="$LIBCRYPTO_LIBS $LIBS"
CFLAGS="$CFLAGS $OPENSSL_INCLUDES"
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH"
+ } else
+#endif
+ {
- } else {
mknodat_unavailable = 1;
result = 0;
}

View File

@@ -20,18 +20,6 @@
+REM %MSBUILD% "%PCBUILD%\openssl.vcxproj" /p:Configuration=Release /p:Platform=ARM64
+REM if errorlevel 1 exit /b
diff -aurw Python-3.10.12/PCbuild/openssl.props external_python/PCbuild/openssl.props
--- Python-3.10.12/PCbuild/openssl.props 2023-06-06 16:30:33 -0600
+++ external_python/PCbuild/openssl.props 2023-06-20 09:58:57 -0600
@@ -10,7 +10,7 @@
</Link>
</ItemDefinitionGroup>
<PropertyGroup>
- <_DLLSuffix>-1_1</_DLLSuffix>
+ <_DLLSuffix>-3</_DLLSuffix>
<_DLLSuffix Condition="$(Platform) == 'ARM'">$(_DLLSuffix)-arm</_DLLSuffix>
<_DLLSuffix Condition="$(Platform) == 'ARM64'">$(_DLLSuffix)-arm64</_DLLSuffix>
</PropertyGroup>
diff -aurw Python-3.10.12/PCbuild/openssl.vcxproj external_python/PCbuild/openssl.vcxproj
--- Python-3.10.12/PCbuild/openssl.vcxproj 2023-06-06 16:30:33 -0600
+++ external_python/PCbuild/openssl.vcxproj 2023-06-20 08:50:43 -0600
@@ -44,16 +32,3 @@ diff -aurw Python-3.10.12/PCbuild/openssl.vcxproj external_python/PCbuild/openss
<_Built Include="$(IntDir)\libcrypto.lib;$(IntDir)\libcrypto-*.dll;$(IntDir)\libcrypto-*.pdb" />
<_Built Include="$(IntDir)\libssl.lib;$(IntDir)\libssl-*.dll;$(IntDir)\libssl-*.pdb" />
<_AppLink Include="$(opensslDir)\ms\applink.c" />
diff -aurw Python-3.10.12/PCbuild/regen.targets external_python/PCbuild/regen.targets
--- Python-3.10.12/PCbuild/regen.targets 2023-06-06 16:30:33 -0600
+++ external_python/PCbuild/regen.targets 2023-06-20 09:37:17 -0600
@@ -89,7 +89,7 @@
<_LicenseSources Include="$(PySourcePath)LICENSE;
$(PySourcePath)PC\crtlicense.txt;
$(bz2Dir)LICENSE;
- $(opensslOutDir)LICENSE;
+ $(opensslOutDir)LICENSE.txt;
$(libffiDir)LICENSE;" />
<_LicenseSources Include="$(tcltkDir)tcllicense.terms;
$(tcltkDir)tklicense.terms;

View File

@@ -99,18 +99,3 @@ diff -Naur orig/pxr/usdImaging/CMakeLists.txt external_usd/pxr/usdImaging/CMakeL
plugin
)
diff -Naur orig/cmake/macros/Private.cmake external_usd/cmake/macros/Private.cmake
--- orig/cmake/macros/Private.cmake 2022-02-18 14:49:09 -0700
+++ external_usd/cmake/macros/Private.cmake 2022-08-05 10:42:03 -0600
@@ -900,8 +900,10 @@
return()
endif()
- if (WIN32 AND PXR_USE_DEBUG_PYTHON)
+ if (WIN32 AND PXR_USE_DEBUG_PYTHON AND NOT CMAKE_DEBUG_POSTFIX)
# On Windows when compiling with debug python the library must be named with _d.
+ # Blender: but this can be skipped if CMAKE_DEBUG_POSTFIX is set, it knows
+ # what it is doing and we don't want libraries ending in _d_d.pyd
set(LIBRARY_NAME "_${NAME}_d")
else()
set(LIBRARY_NAME "_${NAME}")

View File

@@ -1,37 +0,0 @@
diff --git a/pxr/usd/usdMtlx/reader.cpp b/pxr/usd/usdMtlx/reader.cpp
index 29e901816..e6fc68b20 100644
--- a/pxr/usd/usdMtlx/reader.cpp
+++ b/pxr/usd/usdMtlx/reader.cpp
@@ -797,6 +797,15 @@ _NodeGraphBuilder::_CreateInterfaceInputs(
// We deliberately ignore tokens here.
}
+mx::StringSet _GetStdlibIncludes() {
+ mx::StringSet stdlibIncludes = UsdMtlxGetDocument("")->getReferencedSourceUris();
+ mx::StringSet normStdlibIncludes;
+ for (std::string const& entry : stdlibIncludes) {
+ normStdlibIncludes.insert(TfNormPath(entry));
+ }
+ return normStdlibIncludes;
+}
+
// Returns True if the mtlxNodeDef corresponds to a locally defined custom node
// with an associated nodegraph.
// XXX Locally defined custom nodes without nodegraphs are not supported
@@ -818,13 +827,14 @@ _NodeGraphBuilder::_IsLocalCustomNode(const mx::ConstNodeDefPtr &mtlxNodeDef)
}
// Combine with the nodeDef relative path
nodeDefUri = TfNormPath(fullMtlxPath + nodeDefUri);
+ } else {
+ nodeDefUri = TfNormPath(nodeDefUri);
}
// This is a locally defined custom node if the absolute path to the
// nodedef is not included in the stdlibDoc.
static mx::StringSet customNodeDefNames;
- static const mx::StringSet stdlibIncludes =
- UsdMtlxGetDocument("")->getReferencedSourceUris();
+ static const mx::StringSet stdlibIncludes = _GetStdlibIncludes();
if (stdlibIncludes.find(nodeDefUri) == stdlibIncludes.end()) {
// Check if we already used this custom node
if (std::find(customNodeDefNames.begin(), customNodeDefNames.end(),

View File

@@ -1,106 +0,0 @@
diff --git a/build_scripts/build_usd.py b/build_scripts/build_usd.py
index cfe243effb..a4bb94eee1 100644
--- a/build_scripts/build_usd.py
+++ b/build_scripts/build_usd.py
@@ -1415,7 +1415,7 @@ def InstallDraco(context, force, buildArgs):
############################################################
# MaterialX
-MATERIALX_URL = "https://github.com/materialx/MaterialX/archive/v1.38.4.zip"
+MATERIALX_URL = "https://github.com/materialx/MaterialX/archive/v1.38.5.zip"
def InstallMaterialX(context, force, buildArgs):
with CurrentWorkingDirectory(DownloadURL(MATERIALX_URL, context, force)):
diff --git a/pxr/imaging/hdSt/materialXShaderGen.cpp b/pxr/imaging/hdSt/materialXShaderGen.cpp
index df80ff119f..e4b5f04a73 100644
--- a/pxr/imaging/hdSt/materialXShaderGen.cpp
+++ b/pxr/imaging/hdSt/materialXShaderGen.cpp
@@ -136,8 +136,7 @@ HdStMaterialXShaderGen::HdStMaterialXShaderGen(
"st" : mxHdInfo.defaultTexcoordName;
// Register the customized version of the Surface node generator
- registerImplementation("IM_surface_" + GlslShaderGenerator::TARGET,
- HdStMaterialXSurfaceNodeGen::create);
+ registerImplementation("IM_surface_genglsl", HdStMaterialXSurfaceNodeGen::create);
}
// Based on GlslShaderGenerator::generate()
@@ -273,8 +272,7 @@ HdStMaterialXShaderGen::_EmitMxFunctions(
mx::ShaderStage& mxStage) const
{
// Add global constants and type definitions
- emitLibraryInclude("stdlib/" + mx::GlslShaderGenerator::TARGET
- + "/lib/mx_math.glsl", mxContext, mxStage);
+ emitLibraryInclude("stdlib/genglsl/lib/mx_math.glsl", mxContext, mxStage);
emitLine("#if NUM_LIGHTS > 0", mxStage, false);
emitLine("#define MAX_LIGHT_SOURCES NUM_LIGHTS", mxStage, false);
emitLine("#else", mxStage, false);
@@ -394,16 +392,24 @@ HdStMaterialXShaderGen::_EmitMxFunctions(
emitSpecularEnvironment(mxContext, mxStage);
}
if (shadowing) {
- emitLibraryInclude("pbrlib/" + mx::GlslShaderGenerator::TARGET
- + "/lib/mx_shadow.glsl", mxContext, mxStage);
+ emitLibraryInclude("pbrlib/genglsl/lib/mx_shadow.glsl", mxContext, mxStage);
}
+#if MATERIALX_MAJOR_VERSION > 1 || \
+ (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION > 38) || \
+ (MATERIALX_MAJOR_VERSION == 1 && MATERIALX_MINOR_VERSION == 38 && MATERIALX_BUILD_VERSION > 4)
+ // MaterialX 1.38.5 changes the default transmission method to "refraction".
+ mxContext.getOptions().hwTransmissionRenderMethod = mx::TRANSMISSION_OPACITY;
+
+ // Emit transmission code
+ emitTransmissionRender(mxContext, mxStage);
+#endif
+
// Emit directional albedo table code.
if (mxContext.getOptions().hwDirectionalAlbedoMethod ==
mx::HwDirectionalAlbedoMethod::DIRECTIONAL_ALBEDO_TABLE ||
mxContext.getOptions().hwWriteAlbedoTable) {
- emitLibraryInclude("pbrlib/" + mx::GlslShaderGenerator::TARGET
- + "/lib/mx_table.glsl", mxContext, mxStage);
+ emitLibraryInclude("pbrlib/genglsl/lib/mx_table.glsl", mxContext, mxStage);
emitLineBreak(mxStage);
}
@@ -421,7 +427,7 @@ HdStMaterialXShaderGen::_EmitMxFunctions(
// Emit uv transform code globally if needed.
if (mxContext.getOptions().hwAmbientOcclusion) {
emitLibraryInclude(
- "stdlib/" + mx::GlslShaderGenerator::TARGET + "/lib/" +
+ "stdlib/genglsl/lib/" +
_tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV],
mxContext, mxStage);
}
@@ -490,10 +496,30 @@ HdStMaterialXShaderGen::_EmitMxSurfaceShader(
// closure/shader nodes and need to be emitted first.
emitFunctionCalls(mxGraph, mxContext, mxStage, mx::ShaderNode::Classification::TEXTURE);
+#if MATERIALX_MAJOR_VERSION == 1 && \
+ MATERIALX_MINOR_VERSION == 38 && \
+ MATERIALX_BUILD_VERSION <= 4
// Emit function calls for all surface shader nodes.
// These will internally emit their closure function calls.
emitFunctionCalls(mxGraph, mxContext, mxStage, mx::ShaderNode::Classification::SHADER |
mx::ShaderNode::Classification::SURFACE);
+#else
+ // Emit function calls for "root" closure/shader nodes.
+ // These will internally emit function calls for any dependent closure nodes upstream.
+ for (mx::ShaderGraphOutputSocket* socket : mxGraph.getOutputSockets())
+ {
+ if (socket->getConnection())
+ {
+ const mx::ShaderNode* upstream = socket->getConnection()->getNode();
+ if (upstream->getParent() == &mxGraph &&
+ (upstream->hasClassification(mx::ShaderNode::Classification::CLOSURE) ||
+ upstream->hasClassification(mx::ShaderNode::Classification::SHADER)))
+ {
+ emitFunctionCall(*upstream, mxContext, mxStage);
+ }
+ }
+ }
+#endif
}
else
{

View File

@@ -329,6 +329,7 @@ endif()
if(WITH_CYCLES AND WITH_CYCLES_OSL)
find_package(OSL REQUIRED)
endif()
add_bundled_libraries(osl/lib)
if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
find_package(Embree 3.8.0 REQUIRED)

View File

@@ -105,7 +105,7 @@ if(UNIX AND (NOT APPLE) AND LIBDIR AND (EXISTS ${LIBDIR}))
unset(_libdir_stale)
endif()
# Detect update in 4.1 to shared library OpenImageDenoise.
# Detect update in 4.1 to shared library OpenImageDenoise and OSL.
if(UNIX AND
DEFINED OPENIMAGEDENOISE_LIBRARY AND
OPENIMAGEDENOISE_LIBRARY MATCHES "libOpenImageDenoise.a$" AND
@@ -114,3 +114,12 @@ if(UNIX AND
message(STATUS "Auto updating CMake configuration for dynamic OpenImageDenoise")
unset_cache_variables("^OPENIMAGEDENOISE")
endif()
if(UNIX AND
DEFINED OSL_OSLCOMP_LIBRARY AND
OSL_OSLCOMP_LIBRARY MATCHES "liboslcomp.a$" AND
(EXISTS ${LIBDIR}/osl/lib/liboslcomp.so OR
EXISTS ${LIBDIR}/osl/lib/liboslcomp.dylib))
message(STATUS "Auto updating CMake configuration for dynamic OpenShadingLanguage")
unset_cache_variables("^OSL_")
endif()

View File

@@ -355,6 +355,7 @@ if(WITH_CYCLES AND WITH_CYCLES_OSL)
endif()
endif()
endif()
add_bundled_libraries(osl/lib)
if(WITH_CYCLES AND WITH_CYCLES_DEVICE_ONEAPI)
set(CYCLES_LEVEL_ZERO ${LIBDIR}/level-zero CACHE PATH "Path to Level Zero installation")

View File

@@ -553,8 +553,16 @@ if(WITH_JACK)
set(JACK_LIBRARIES optimized ${LIBDIR}/jack/lib/libjack.lib debug ${LIBDIR}/jack/lib/libjack_d.lib)
endif()
set(_PYTHON_VERSION "3.10")
set(_PYTHON_VERSION "3.11")
string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${_PYTHON_VERSION})
if(NOT EXISTS ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS})
set(_PYTHON_VERSION "3.10")
string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${_PYTHON_VERSION})
if(NOT EXISTS ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS})
message(FATAL_ERROR "Missing python libraries! Neither 3.11 nor 3.10 are found in ${LIBDIR}/python")
endif()
endif()
# Python executable is needed as part of the build-process,
# note that building without Python is quite unusual.
set(PYTHON_EXECUTABLE ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python$<$<CONFIG:Debug>:_d>.exe)
@@ -574,8 +582,6 @@ if(WITH_PYTHON)
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_LIBRARIES debug "${PYTHON_LIBRARY_DEBUG}" optimized "${PYTHON_LIBRARY}" )
endif()
unset(_PYTHON_VERSION)
unset(_PYTHON_VERSION_NO_DOTS)
if(NOT WITH_WINDOWS_FIND_MODULES)
# even if boost is off, we still need to install the dlls when we use our lib folder since
@@ -615,7 +621,7 @@ if(WITH_BOOST)
if(NOT Boost_FOUND)
warn_hardcoded_paths(BOOST)
# This is file new in 3.4 if it does not exist, assume we are building against 3.3 libs
set(BOOST_34_TRIGGER_FILE ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python310-${BOOST_DEBUG_POSTFIX}.lib)
set(BOOST_34_TRIGGER_FILE ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python${_PYTHON_VERSION_NO_DOTS}-${BOOST_DEBUG_POSTFIX}.lib)
if(NOT EXISTS ${BOOST_34_TRIGGER_FILE})
set(BOOST_DEBUG_POSTFIX "vc142-mt-gd-x64-${BOOST_VERSION}")
set(BOOST_PREFIX "lib")
@@ -637,8 +643,8 @@ if(WITH_BOOST)
if(EXISTS ${BOOST_34_TRIGGER_FILE})
if(WITH_USD)
set(BOOST_PYTHON_LIBRARIES
debug ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python310-${BOOST_DEBUG_POSTFIX}.lib
optimized ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python310-${BOOST_POSTFIX}.lib
debug ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python${_PYTHON_VERSION_NO_DOTS}-${BOOST_DEBUG_POSTFIX}.lib
optimized ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python${_PYTHON_VERSION_NO_DOTS}-${BOOST_POSTFIX}.lib
)
endif()
endif()
@@ -662,6 +668,8 @@ if(WITH_BOOST)
set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
endif()
unset(_PYTHON_VERSION)
unset(_PYTHON_VERSION_NO_DOTS)
windows_find_package(OpenImageIO)
if(NOT OpenImageIO_FOUND)

View File

@@ -15,6 +15,7 @@ set(INC
set(INC_SYS
${JPEG_INCLUDE_DIR}
${ZLIB_INCLUDE_DIRS}
${IMATH_INCLUDE_DIRS}
${OPENIMAGEIO_INCLUDE_DIRS}
)

View File

@@ -527,6 +527,22 @@ if(WITH_OPENCOLORIO)
)
endif()
if(WIN32)
if(EXISTS ${LIBDIR}/osl/bin/oslquery.dll) # 4.1+
windows_install_shared_manifest(
FILES ${LIBDIR}/osl/bin/oslquery.dll
${LIBDIR}/osl/bin/oslcomp.dll
${LIBDIR}/osl/bin/oslexec.dll
${LIBDIR}/osl/bin/oslnoise.dll
RELEASE
)
windows_install_shared_manifest(
FILES ${LIBDIR}/osl/bin/oslquery_d.dll
${LIBDIR}/osl/bin/oslcomp_d.dll
${LIBDIR}/osl/bin/oslexec_d.dll
${LIBDIR}/osl/bin/oslnoise_d.dll
DEBUG
)
endif()
if(EXISTS ${LIBDIR}/opencolorio/bin/opencolorio_2_2.dll) # 3.5
windows_install_shared_manifest(
FILES ${LIBDIR}/opencolorio/bin/opencolorio_2_2.dll
@@ -547,6 +563,26 @@ if(WIN32)
CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
)
endif()
if(EXISTS ${LIBDIR}/opencolorio/bin/opencolorio_2_3.dll) # 4.1
windows_install_shared_manifest(
FILES ${LIBDIR}/opencolorio/bin/opencolorio_2_3.dll
RELEASE
)
windows_install_shared_manifest(
FILES ${LIBDIR}/opencolorio/bin/opencolorio_d_2_3.dll
DEBUG
)
install(
DIRECTORY ${LIBDIR}/opencolorio/lib/site-packages-debug/PyOpenColorIO
DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
CONFIGURATIONS Debug
)
install(
DIRECTORY ${LIBDIR}/opencolorio/lib/site-packages/PyOpenColorIO
DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
)
endif()
if(EXISTS ${LIBDIR}/OpenImageDenoise/bin/openimagedenoise.dll) # 4.0
windows_install_shared_manifest(
FILES
@@ -1061,22 +1097,6 @@ elseif(WIN32)
DEBUG
)
# This will not exist for 3.4 and earlier lib folders
# to ease the transition, support both 3.4 and 3.5 lib
# folders.
if(EXISTS ${LIBDIR}/openvdb/python/pyopenvdb_d.pyd)
install(
FILES ${LIBDIR}/openvdb/python/pyopenvdb_d.pyd
DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
CONFIGURATIONS Debug
)
install(
FILES ${LIBDIR}/openvdb/python/pyopenvdb.pyd
DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
)
endif()
windows_install_shared_manifest(
FILES
${LIBDIR}/materialx/bin/MaterialXCore.dll
@@ -1105,6 +1125,18 @@ elseif(WIN32)
DEBUG
)
endif()
if(EXISTS ${LIBDIR}/materialx/bin/MaterialXGenMsl.dll) # 4.1+
windows_install_shared_manifest(
FILES
${LIBDIR}/materialx/bin/MaterialXGenMsl.dll
RELEASE
)
windows_install_shared_manifest(
FILES
${LIBDIR}/materialx/bin/MaterialXGenMsl_d.dll
DEBUG
)
endif()
windows_install_shared_manifest(
FILES
${LIBDIR}/materialx/bin/MaterialXCore_d.dll
@@ -1245,6 +1277,36 @@ elseif(WIN32)
)
endif()
# This will not exist for 3.4 and earlier lib folders
# to ease the transition, support both 3.4 and 3.5 lib
# folders.
if(EXISTS ${LIBDIR}/openvdb/python/pyopenvdb_d.pyd)
install(
FILES ${LIBDIR}/openvdb/python/pyopenvdb_d.pyd
DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
CONFIGURATIONS Debug
)
install(
FILES ${LIBDIR}/openvdb/python/pyopenvdb.pyd
DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
)
endif()
# this will exist for 4.1 lib folders
if(EXISTS ${LIBDIR}/openvdb/python/pyopenvdb_d.cp${_PYTHON_VERSION_NO_DOTS}-win_amd64.pyd)
install(
FILES ${LIBDIR}/openvdb/python/pyopenvdb_d.cp${_PYTHON_VERSION_NO_DOTS}-win_amd64.pyd
DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
CONFIGURATIONS Debug
)
install(
FILES ${LIBDIR}/openvdb/python/pyopenvdb.cp${_PYTHON_VERSION_NO_DOTS}-win_amd64.pyd
DESTINATION ${TARGETDIR_VER}/python/lib/site-packages
CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
)
endif()
# MaterialX python bindings
install(
DIRECTORY ${LIBDIR}/materialx/python/Release/MaterialX