From 6eb70e4aaf51d1cb1a61b1245f4573756bb4f4d6 Mon Sep 17 00:00:00 2001 From: Christoph Willing Date: Sun, 8 Feb 2026 11:12:35 +1100 Subject: [PATCH] graphics/Blender: Enable Nvidia & AMD GPU render support Signed-off-by: Christoph Willing --- graphics/Blender/01_FindEmbree_so.diff | 75 -------------------------- graphics/Blender/Blender.SlackBuild | 19 +++++-- graphics/Blender/Blender.info | 6 +-- graphics/Blender/README | 29 +++++++--- graphics/Blender/README.Slackware | 33 ------------ graphics/Blender/README.libs | 18 +++++-- graphics/Blender/blender-libs.defs | 1 + graphics/Blender/blender-libs.sh | 41 ++++++++++---- 8 files changed, 86 insertions(+), 136 deletions(-) delete mode 100644 graphics/Blender/01_FindEmbree_so.diff delete mode 100644 graphics/Blender/README.Slackware diff --git a/graphics/Blender/01_FindEmbree_so.diff b/graphics/Blender/01_FindEmbree_so.diff deleted file mode 100644 index 6739f6852a8..00000000000 --- a/graphics/Blender/01_FindEmbree_so.diff +++ /dev/null @@ -1,75 +0,0 @@ ---- build_files/cmake/Modules/FindEmbree.cmake.orig 2020-10-21 18:59:19.000000000 +1000 -+++ build_files/cmake/Modules/FindEmbree.cmake 2021-01-16 01:26:51.000000000 +1000 -@@ -7,19 +7,12 @@ - # EMBREE_ROOT_DIR, The base directory to search for Embree. - # This can also be an environment variable. - # EMBREEFOUND, If false, do not try to use Embree. --# --# also defined, but not for general use are --# EMBREE_LIBRARY, where to find the Embree library. - - #============================================================================= - # Copyright 2018 Blender Foundation. - # --# Distributed under the OSI-approved BSD License (the "License"); --# see accompanying file Copyright.txt for details. --# --# This software is distributed WITHOUT ANY WARRANTY; without even the --# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --# See the License for more information. -+# Distributed under the OSI-approved BSD 3-Clause License, -+# see accompanying file BSD-3-Clause-license.txt for details. - #============================================================================= - - # If EMBREE_ROOT_DIR was defined in the environment, use it. -@@ -44,9 +37,9 @@ - - SET(_embree_FIND_COMPONENTS - embree3 -+ embree_sse42 - embree_avx - embree_avx2 -- embree_sse42 - lexers - math - simd -@@ -66,29 +59,28 @@ - PATH_SUFFIXES - lib64 lib - ) -+ IF (NOT EMBREE_${UPPERCOMPONENT}_LIBRARY) -+ IF (EMBREE_EMBREE3_LIBRARY) -+ # If we can't find all the static libraries, try to fall back to the shared library if found. -+ # This allows building with a shared embree library -+ SET(_embree_LIBRARIES ${EMBREE_EMBREE3_LIBRARY}) -+ BREAK() -+ ENDIF () -+ ENDIF () - LIST(APPEND _embree_LIBRARIES "${EMBREE_${UPPERCOMPONENT}_LIBRARY}") - ENDFOREACH() - - --FIND_LIBRARY(EMBREE_LIBRARY -- NAMES -- libembree3 -- HINTS -- ${_embree_SEARCH_DIRS} -- PATH_SUFFIXES -- lib64 lib --) -- - # handle the QUIETLY and REQUIRED arguments and set EMBREE_FOUND to TRUE if - # all listed variables are TRUE - INCLUDE(FindPackageHandleStandardArgs) --FIND_PACKAGE_HANDLE_STANDARD_ARGS(EMBREE DEFAULT_MSG -+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Embree DEFAULT_MSG - _embree_LIBRARIES EMBREE_INCLUDE_DIR) - - IF(EMBREE_FOUND) - SET(EMBREE_LIBRARIES ${_embree_LIBRARIES}) - SET(EMBREE_INCLUDE_DIRS ${EMBREE_INCLUDE_DIR}) --ENDIF(EMBREE_FOUND) -+ENDIF() - - MARK_AS_ADVANCED( - EMBREE_INCLUDE_DIR diff --git a/graphics/Blender/Blender.SlackBuild b/graphics/Blender/Blender.SlackBuild index cbd70176439..e7296f9668e 100644 --- a/graphics/Blender/Blender.SlackBuild +++ b/graphics/Blender/Blender.SlackBuild @@ -26,8 +26,8 @@ cd $(dirname $0) ; CWD=$(pwd) PRGNAM=Blender VERSION=${VERSION:-5.0.1} -BUILD=${BUILD:-3} -LIBS_BUILD=${LIBS_BUILD:-1} +BUILD=${BUILD:-4} +LIBS_BUILD=${LIBS_BUILD:-2} TAG=${TAG:-_SBo} PKGTYPE=${PKGTYPE:-tgz} @@ -67,6 +67,15 @@ with_cuda="" . /etc/profile.d/cuda-12.*.sh with_cuda="-DWITH_CYCLES_DEVICE_CUDA=ON -DWITH_CYCLES_CUDA_BINARIES=ON " } +with_rocm="" +[ -x /etc/profile.d/rocmtoolkit_6.sh ] && { + . /etc/profile.d/rocmtoolkit_6.sh + with_rocm="-DWITH_CYCLES_DEVICE_HIP=ON -DWITH_CYCLES_HIP_BINARIES=ON -DWITH_CYCLES_DEVICE_HIPRT=ON " +} +with_optix="" +[ -d /usr/include/optix ] && { + with_optix="-DOPTIX_INCLUDE_DIR=/usr/include/optix -DWITH_CYCLES_DEVICE_OPTIX=ON " +} set -e @@ -106,7 +115,7 @@ find -L . \ mkdir -p build cd build cmake .. \ - -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \ + -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS $(pkg-config --libs numa)" \ -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \ -DCMAKE_BUILD_TYPE=Release \ -DLIBDIR:PATH=$(pwd)/../lib/linux_x64 \ @@ -114,7 +123,9 @@ cd build -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH \ -DWITH_INSTALL_PORTABLE:BOOL=ON \ -DWITH_BUILDINFO:BOOL=ON \ - $with_cuda \ + $with_cuda \ + $with_rocm \ + $with_optix \ # From https://projects.blender.org/blender (Release: Bump to 5.0.1) COMMIT_HASH="a3db93c5b2" diff --git a/graphics/Blender/Blender.info b/graphics/Blender/Blender.info index 3abb801787d..6b5b9e2d0f0 100644 --- a/graphics/Blender/Blender.info +++ b/graphics/Blender/Blender.info @@ -4,9 +4,9 @@ HOMEPAGE="https://blender.org" DOWNLOAD="UNSUPPORTED" MD5SUM="" DOWNLOAD_x86_64="https://download.blender.org/source/blender-5.0.1.tar.xz \ - https://sourceforge.net/projects/slackbuildsdirectlinks/files/Blender/blender-libs-5.0.1.1.tar.lz" + https://sourceforge.net/projects/slackbuildsdirectlinks/files/Blender/blender-libs-5.0.1.2.tar.lz" MD5SUM_x86_64="b7b865015cd203c53f8b5369899fb503 \ - 8c30f0f900f2f1ea0009a1ab2d6734ed" -REQUIRES="" + 4a7c19c8c491a2686fb01929a0dc1c07" +REQUIRES="numactl" MAINTAINER="Christoph Willing" EMAIL="chris.willing@linux.com" diff --git a/graphics/Blender/README b/graphics/Blender/README index 6ddf75016b0..3d210186fe2 100644 --- a/graphics/Blender/README +++ b/graphics/Blender/README @@ -7,19 +7,34 @@ range of essential tools for the creation of 3D content, including modeling, uv-mapping, texturing, particle and other simulation, scripting, rendering, compositing, post-production and game creation. + This SlackBuild builds Blender from source code using prepackaged support libraries which don't provide libraries for i*86, therefore 32bit builds are no longer supported. -The prepackaged libraries can themselves be built from source code. -See README.libs +The prepackaged libraries can themselves be built from source code if +desired and provided sufficient resources (disk space, cpu, time) are +available. See the README.libs file. + +If targeting hardware rendering with Nvidia GPU, it is necessary to +first install the cudatoolkit_12 package, in which case additional +dedicated rendering binaries will be generated during the Blender +build. In this case, it is also recommended to install the +OptiX-Headers SlackBuild; this enables optix render kernels to be +built into Blender. + +For a comparison of bare CUDA and OptiX (which requires CUDA anyway) +see: + https://yelzkizi.org/optix-vs-cuda/ -When targeting Nvidia GPU, it is recommended to first install the -cudatoolkit_12 package, in which case additional dedicated rendering -binaries will be generated during the Blender build. +If targeting hardware rendering with AMD GPU, it is necessary to +first install the rocmtoolkit_6 package, in which case additional +dedicated rendering binaries will be generated during the Blender +build. -After installing the built package, log out and back in again to the -initiate ability to launch from the desktop menu (at Graphics/Blender). +After installing the built package, log out and back in again to +initiate the ability to launch from the desktop menu +(at Graphics/Blender). See also: graphics/blender (note, lowercase b), which repackages the official Blender x86_64 release binary. diff --git a/graphics/Blender/README.Slackware b/graphics/Blender/README.Slackware deleted file mode 100644 index ae3123fd946..00000000000 --- a/graphics/Blender/README.Slackware +++ /dev/null @@ -1,33 +0,0 @@ -This script builds Blender from its source code, rather than repackaging -an existing binary version. The process is therefore more complex and -time consuming but allows finer tuning of capabilities of the resulting -package. Working through the prerequisite packages from the REQUIRES field -of Blender.info results in the following basic build order: - libraries/libaec - graphics/opencollada - libraries/yaml-cpp - libraries/ptex - graphics/potrace - libraries/tbb - libraries/dcmtk - development/valgrind - python/python3-flit_core - libraries/robin-map - python/python3-installer - libraries/freealut - libraries/hdf5 - graphics/OpenSubdiv - python/python3-wheel - python/python3-pyproject-hooks - libraries/pugixml - python/python3-build - python/python3-pyproject-metadata - python/python3-meson-opt - python/python3-packaging-opt - python/pybind11 - python/python3-mesonpy - audio/jack - graphics/opencolorio - development/python3-numpy - graphics/openimageio - graphics/Blender diff --git a/graphics/Blender/README.libs b/graphics/Blender/README.libs index 4b83b3bdcf3..59a3b4a2736 100644 --- a/graphics/Blender/README.libs +++ b/graphics/Blender/README.libs @@ -6,7 +6,7 @@ Since blender-5.0.1, this SlackBuild uses a set of precompiled libraries which are required to build Blender from source code. They are downloaded as a tarball and unpacked as required. -Initially this tarball of precompiled libraries was created by +Historically, this tarball of precompiled libraries was created by downloading them from blender.org using the 'make update' command, along the lines of: @@ -73,13 +73,25 @@ specified with the SOURCES_CACHE environment variable when running the script e.g. SOURCES_CACHE=/var/cache/blender-sources bash blender-libs.sh +While not mandatory, AMD graphics hardware support depends on prior +installation of the rocmtoolkit_6 package. + +## NOTE ## +Even if not targeting the Nvidia GPU, the cudatoolkit_12 package is +still mandatory. + ################################################## Resources for source build of precompiled libraries ################################################## - library source tarballs: 2 GB -- time to download source tarballs: depends on internet connection (downloading 2GB) +- time to download source tarballs: depends on internet connection + (downloading 2GB) +- time to build & install cudatoolkit_12 and rocmtoolkit_6 + (both very large) - time to build library tarball: 2 hours -- disk space to build: 46 GB +- disk space to build: 70 GB (over and above full + Slackware installation) + diff --git a/graphics/Blender/blender-libs.defs b/graphics/Blender/blender-libs.defs index e8b8a729bbc..e8ce12e5291 100644 --- a/graphics/Blender/blender-libs.defs +++ b/graphics/Blender/blender-libs.defs @@ -32,6 +32,7 @@ DOWNLOAD_x86_64="https://download.blender.org/source/blender-5.0.1.tar.xz \ http://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.gz \ http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.7.tar.gz \ http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2 \ + http://downloads.xiph.org/releases/flac/flac-1.4.2.tar.xz \ https://github.com/webmproject/libvpx/archive/v1.15.2/libvpx-v1.15.2.tar.gz \ https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz \ https://code.videolan.org/videolan/x264/-/archive/35fe20d1ba49918ec739a5b068c208ca82f977f7/x264-35fe20d1ba49918ec739a5b068c208ca82f977f7.tar.gz \ diff --git a/graphics/Blender/blender-libs.sh b/graphics/Blender/blender-libs.sh index 0619cb1361c..b646f3e2297 100644 --- a/graphics/Blender/blender-libs.sh +++ b/graphics/Blender/blender-libs.sh @@ -22,12 +22,16 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# BUILD = 1: Enable building of openimagedenoise +# by disabling OIDN_DEVICE_HIP in its CMakeLists.txt +# BUILD = 2: rocm-6.4.4 available (like cudatoolkit for AMD) + cd $(dirname $0) ; CWD=$(pwd) PRGNAM=blender-libs SRCNAM=blender VERSION=${VERSION:-5.0.1} -BUILD=${BUILD:-1} +BUILD=${BUILD:-2} TAG=${TAG:-_SBo} PKGTYPE=${PKGTYPE:-tgz} @@ -47,6 +51,22 @@ fi TMP=${TMP:-/tmp/SBo} OUTPUT=${OUTPUT:-/tmp} +CUDAToolkit_ROOT=${CUDAToolkit_ROOT:-/opt/cuda-12.9} +ROCM_PATH=${ROCM_PATH:-/opt/rocm-6.4.4} + +# cudatoolkit is mandatory, rocmtoolkit is optional (although recommended) +[ -d "$CUDAToolkit_ROOT" -a -x "$CUDAToolkit_ROOT"/bin/nvcc ] || { + echo "Can't proceed without cudatoolkit being installed." + echo "Please install the cudatoolkit_12 SlackBuild from SBo." + exit 1 +} + +export CUDAToolkit_ROOT +export ROCM_PATH +echo "CUDAToolkit_ROOT set to $CUDAToolkit_ROOT, ROCM_PATH set to $ROCM_PATH" +export PATH=${CUDAToolkit_ROOT}/bin:${ROCM_PATH}/bin:${PATH} +echo "PATH = $PATH" + # Ensure updated versions of some system packages are installed # Slackware 15.0 stock cmake version is 3.21.4 (NOT usable) # Slackware 15.0 also has version 3.31.8 in testing (usable) @@ -59,13 +79,14 @@ REQUIRED_CMAKE_VERSION=3.30.5 [ -x /opt/cmake-opt/bin/cmake ] && \ export PATH="/opt/cmake-opt/bin:${PATH}" - installed_cmake_version=$(cmake --version | head -1 |cut -d' ' -f3) if [ ! "$REQUIRED_CMAKE_VERSION" = "$installed_cmake_version" ]; then echo "Wrong cmake version ($installed_cmake_version) detected." - exit 1 + echo "For Slackware 15.0, install the cmake-opt SlackBuild from SBo." + exit 2 fi + # Obtain sources # The user should set SOURCES_CACHE in the environment # or change the definition here @@ -76,6 +97,7 @@ for f in $DOWNLOAD_x86_64 ; do echo "Source file: $(basename $f)" cp -u $SOURCES_CACHE/$(basename $f) . || \ wget $f +# md5sum $(basename $f) |cut -f1 -d' ' done # rename some source files (those listed in .defs file): @@ -98,12 +120,6 @@ cp 3cf6c1e53037eb9e198860365712e1bafb22f7c6.tar.gz x265-3cf6c1e53037eb9e1988603 set -e -CUDAToolkit_ROOT=${CUDAToolkit_ROOT:-/opt/cuda-12.9} -export CUDAToolkit_ROOT -echo "CUDAToolkit_ROOT set to $CUDAToolkit_ROOT" -export PATH=${PATH}:${CUDAToolkit_ROOT}/bin -echo "PATH = $PATH" - mkdir -p $TMP $OUTPUT cd $TMP rm -rf $SRCNAM-$VERSION @@ -118,9 +134,12 @@ find -L . \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; -# For now, don't try building openimagedenoise for HIP device (not avaiable) +# Disable building openimagedenoise if hipcc not available # -sed -i -e 's/DOIDN_DEVICE_HIP=ON/DOIDN_DEVICE_HIP=OFF/' build_files/build_environment/cmake/openimagedenoise.cmake +[ -x "$ROCM_PATH"/bin/hipcc ] || \ + sed -i -e 's/DOIDN_DEVICE_HIP=ON/DOIDN_DEVICE_HIP=OFF/' \ + build_files/build_environment/cmake/openimagedenoise.cmake + # Copy source files to where blender expects them # (where make deps would download them to)