diff --git a/blender/PKGBUILD b/blender/PKGBUILD index 36fc7aa87a..df3e69409f 100644 --- a/blender/PKGBUILD +++ b/blender/PKGBUILD @@ -10,7 +10,7 @@ pkgname=blender pkgver=4.0.2 -pkgrel=4 +pkgrel=15 epoch=17 pkgdesc="A fully integrated 3D graphics creation suite" arch=(x86_64 powerpc64le) @@ -19,12 +19,18 @@ url="https://www.blender.org" depends=('libpng' 'libtiff' 'openexr' 'python' 'desktop-file-utils' 'python-requests' 'potrace' 'shared-mime-info' 'hicolor-icon-theme' 'xdg-utils' 'glew' 'openjpeg2' 'python-numpy' 'freetype2' 'openal' 'ffmpeg' 'fftw' 'boost-libs' 'opencollada' 'alembic' 'openxr' - 'openimageio' 'libsndfile' 'jack' 'opencolorio' + 'openimageio' 'libsndfile' 'jack' 'opencolorio' 'materialx' 'jemalloc' 'libspnav' 'ptex' 'opensubdiv' 'openvdb' 'sdl2' 'libharu' 'draco' 'level-zero-loader' 'libxkbcommon' 'libepoxy' 'openshadinglanguage') +depends_x86_64=('openimagedenoise' 'intel-oneapi-compiler-shared-runtime-libs' + 'intel-oneapi-compiler-dpcpp-cpp-runtime-libs' 'embree' 'openpgl' 'usd') makedepends=('cmake' 'boost' 'mesa' 'git' 'subversion' 'llvm' 'ninja' 'wayland-protocols' 'libxkbcommon' - 'libdecor' 'hip-runtime-amd' 'level-zero-headers') + 'libdecor' 'hip-runtime-amd' 'level-zero-headers') +makedepends_x86_64=('cuda' 'intel-oneapi-compiler-shared-runtime' 'intel-compute-runtime' + 'intel-oneapi-dpcpp-cpp') optdepends=('libdecor: wayland support') +optdepends_x86_64=('cuda: Cycles renderer CUDA support' + 'intel-compute-runtime: Cycles renderer Intel OneAPI support') # We're using !buildflags here as otherwise we get stuff such as FS#77557 # It'd be better to figure out exactly which of the flags is the culprit which I attempted but without any success. options=('!buildflags') @@ -34,16 +40,20 @@ source=("git+https://projects.blender.org/blender/blender.git#tag=v$pkgver" "svn+https://svn.blender.org/svnroot/bf-blender/tags/blender-${pkgver%%.[^.]}-release/lib/assets" https://developer.download.nvidia.com/redist/optix/v7.7/OptiX-7.7-Include.zip https://projects.blender.org/blender/blender/commit/5486c70aae94196d715c07364292fc108ebf59a8.patch + blender-openpgl6.patch::https://projects.blender.org/blender/blender/pulls/118328.patch force-draco1.patch - force-draco2.patch) + force-draco2.patch + blender-rocm-6.patch) sha512sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' '55caea5beccdc0adebdba8a825f3cfee083015311de5602cfcf215139ccbf9fed62f10ee1dcdf7e31a3557aabbc1fa872eeed67bc46f59fb4e5abd18331c0aca' '375508d1d010b4b043b293cb0c192cb2096aef7ddb0dd1be4a738b20aa720523494cf3054161f1ad116fddc6a9ce03159d6da0a3b3fdb1b57002a477c7c5920a' + '5442a5b978cc00481f7b8678b5e03ff02701a10ea885f8cdc7ec410b4aa8f75054410fd28569309efa771f30149d7f8171af3935b22e2f95a0ef36512b179fe7' 'e239da4f3906f1b54265435181cf770bae3d269c8d915df9a73861e6ee71ec70bf2339426e7c81a91e5a567273b3b3742d7a99feefd3398d821b26e1ff3a56d0' - 'c162646eba42ea7112cfb615466c2cbaddac8d254d4a9e91cf887c5bffef1325a983701163223a1fdee091310ac5574a400347aab7f52321825b5fa3d5a9036f') + 'c162646eba42ea7112cfb615466c2cbaddac8d254d4a9e91cf887c5bffef1325a983701163223a1fdee091310ac5574a400347aab7f52321825b5fa3d5a9036f' + 'dc694c655690913701dba92281724671c14f7305cc8f4de6071056f4608837532194178fdddcbcf500d330a0b804d26cd9599b88ff71f9c799664e941809813a') prepare() { cd "$pkgname" @@ -59,6 +69,16 @@ prepare() { cp -r "$srcdir"/blender-addons scripts/addons cp -r "$srcdir"/blender-addons-contrib scripts/addons_contrib + # Disable openexr core + # https://projects.blender.org/blender/blender/issues/117145 + git cherry-pick -n eb99895c972b6c713294f68a34798aa51d36034a + + # Fix compatibility with OSL 1.13.5 + # https://projects.blender.org/blender/blender/issues/113157 + git cherry-pick -n 798a0b301e640e73ae12e6f8a36a66746893bff1 + + patch -Np1 -i "$srcdir"/blender-openpgl6.patch + # fix draco patch -p1 -i "$srcdir"/force-draco1.patch patch -p1 -d scripts/addons -i "$srcdir"/force-draco2.patch @@ -72,6 +92,8 @@ prepare() { # Revert https://projects.blender.org/blender/blender/commit/4b891b4af which causes all # CMake custom commands to be run in serial instead of in parallel. sed -i "s/USES_TERMINAL//g" intern/cycles/kernel/CMakeLists.txt + + patch -Np1 -i "$srcdir/blender-rocm-6.patch" } get_pyver() { @@ -87,8 +109,21 @@ build() { echo 'set(CYCLES_CUDA_BINARIES_ARCH sm_52 sm_53 sm_60 sm_61 sm_62 sm_70 sm_72 sm_75 sm_80 sm_86 sm_87 sm_89 compute_89 CACHE STRING "CUDA architectures to build binaries for" FORCE)' > precache echo 'mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)' >> precache - # Disable OSL until it's built with LLVM 16 otherwise we get stuff like - # https://gitlab.archlinux.org/archlinux/packaging/packages/blender/-/issues/2 + case "${CARCH}" in + x86_64) + CYCLES=ON + CYCLES_OSL=ON + CYCLES_EMBREE=ON + CYCLES_DEVICE_OPTIX=ON + ;; + *) + CYCLES=OFF + CYCLES_OSL=OFF + CYCLES_EMBREE=OFF + CYCLES_DEVICE_OPTIX=OFF + ;; + esac + cmake \ -Bbuild \ -GNinja \ @@ -100,16 +135,16 @@ build() { -DHIP_ROOT_DIR=/opt/rocm \ -DOPTIX_ROOT_DIR="$srcdir" \ -DCMAKE_INSTALL_PREFIX=/usr \ - -DWITH_CYCLES_OSL=OFF \ + -DWITH_CYCLES=${CYCLES} \ + -DWITH_CYCLES_EMBREE=${CYCLES_EMBREE} \ + -DWITH_CYCLES_DEVICE_OPTIX=${CYCLES_DEVICE_OPTIX} \ + -DWITH_CYCLES_OSL=${CYCLES_OSL} \ -DCMAKE_BUILD_TYPE=Release \ -DWITH_INSTALL_PORTABLE=OFF \ -DWITH_PYTHON_INSTALL=OFF \ -DOCLOC_INSTALL_DIR=/usr \ -DUSD_ROOT_DIR=/usr \ - -DSYCL_OFFLINE_COMPILER_PARALLEL_JOBS=8 \ - -DWITH_CYCLES=OFF \ - -DWITH_CYCLES_EMBREE=OFF \ - -DWITH_CYCLES_DEVICE_OPTIX=OFF + -DSYCL_OFFLINE_COMPILER_PARALLEL_JOBS=8 cmake --build build # For debug: # -DSYCL_CPP_FLAGS=--verbose @@ -132,4 +167,11 @@ package() { mkdir -p "${pkgdir}/usr/lib/python$(get_pyver)"/ mv "${pkgdir}"/usr/share/blender/4*/python/lib/* "${pkgdir}"/usr/lib/ rm -r "${pkgdir}"/usr/share/blender/4*/python + + case "${CARCH}" in + x86_64) + # Move OneAPI AOT lib to proper place + mv "${pkgdir}"/usr/share/blender/lib/libcycles_kernel_oneapi_aot.so "${pkgdir}"/usr/lib/ + ;; + esac } diff --git a/blender/blender-rocm-6.patch b/blender/blender-rocm-6.patch new file mode 100644 index 0000000000..b277975525 --- /dev/null +++ b/blender/blender-rocm-6.patch @@ -0,0 +1,210 @@ +From f753cf14fca2b97d4bbf48eccc1defcaa1d17daa Mon Sep 17 00:00:00 2001 +From: bsavery +Date: Wed, 3 Jan 2024 18:16:07 +0100 +Subject: [PATCH] Cycles: add ROCm 6 compatibility for HIP + +ROCm 6 brings some changes to the HIP API. This pull request is meant to be +backward and forward compatible. + +That is Blender could be compiled with either ROCM 6 or 5 and run on either. +The main change is the hipMemoryType enum, which we check based on the +runtime version to use the correct enum values. + +Without this, HIP will not work on Windows with upcoming 23.40 driver. + +Pull Request: https://projects.blender.org/blender/blender/pulls/116713 +--- + extern/hipew/include/hipew.h | 26 +++++++++++++++++++----- + extern/hipew/src/hipew.c | 23 +++++++++++++++++++++ + intern/cycles/device/hip/device_impl.cpp | 16 +++++++++++---- + intern/cycles/device/hip/device_impl.h | 2 ++ + 4 files changed, 58 insertions(+), 9 deletions(-) + +diff --git a/extern/hipew/include/hipew.h b/extern/hipew/include/hipew.h +index f82654ffe93..df7498aaeae 100644 +--- a/extern/hipew/include/hipew.h ++++ b/extern/hipew/include/hipew.h +@@ -185,13 +185,26 @@ typedef struct textureReference { + + typedef textureReference* hipTexRef; + ++/** ++ * ROCm 6 and ROCm 5 memory types are different. ++ * For now, we include both in the enum and then use the get_hip_memory_type ++ * Function to convert. When removing ROCm 5 compatibility this can be simplified. ++*/ + typedef enum hipMemoryType { +- hipMemoryTypeHost = 0x00, +- hipMemoryTypeDevice = 0x01, +- hipMemoryTypeArray = 0x02, +- hipMemoryTypeUnified = 0x03, ++ hipMemoryTypeHost_v5 = 0x00, ++ hipMemoryTypeDevice_v5 = 0x01, ++ hipMemoryTypeArray_v5 = 0x02, ++ hipMemoryTypeUnified_v5 = 0x03, ++ hipMemoryTypeUnregistered = 0, ++ hipMemoryTypeHost = 1, ++ hipMemoryTypeDevice = 2, ++ hipMemoryTypeManaged = 3, ++ hipMemoryTypeArray = 10, ++ hipMemoryTypeUnified = 11, + } hipMemoryType; + ++hipMemoryType get_hip_memory_type(hipMemoryType mem_type, int runtime_version); ++ + /** + * Pointer attributes + */ +@@ -316,7 +329,7 @@ typedef enum hipDeviceAttribute_t { + hipDeviceAttributeConcurrentManagedAccess, ///< Device can coherently access managed memory concurrently with the CPU + hipDeviceAttributeCooperativeLaunch, ///< Support cooperative launch + hipDeviceAttributeCooperativeMultiDeviceLaunch, ///< Support cooperative launch on multiple devices +- hipDeviceAttributeDeviceOverlap, ///< Cuda only. Device can concurrently copy memory and execute a kernel. ++ hipDeviceAttributeDeviceOverlap, ///< Cuda only. Device can concurrently copy memory and execute a kernel. + ///< Deprecated. Use instead asyncEngineCount. + hipDeviceAttributeDirectManagedMemAccessFromHost, ///< Host can directly access managed memory on + ///< the device without migration +@@ -420,6 +433,7 @@ typedef enum hipDeviceAttribute_t { + ///< hipStreamWaitValue64() , '0' otherwise. + hipDeviceAttributeAmdSpecificEnd = 19999, + hipDeviceAttributeVendorSpecificBegin = 20000, ++ hipDeviceAttribute + // Extended attributes for vendors + } hipDeviceAttribute_t; + +@@ -1160,6 +1174,7 @@ typedef const char* HIPAPI thipGetErrorString(hipError_t error); + typedef hipError_t HIPAPI thipGetLastError(hipError_t error); + typedef hipError_t HIPAPI thipInit(unsigned int Flags); + typedef hipError_t HIPAPI thipDriverGetVersion(int* driverVersion); ++typedef hipError_t HIPAPI thipRuntimeGetVersion(int* runtimeVersion); + typedef hipError_t HIPAPI thipGetDevice(int* device); + typedef hipError_t HIPAPI thipGetDeviceCount(int* count); + typedef hipError_t HIPAPI thipGetDeviceProperties(hipDeviceProp_t* props, int deviceId); +@@ -1310,6 +1325,7 @@ extern thipGetErrorString* hipGetErrorString; + extern thipGetLastError* hipGetLastError; + extern thipInit *hipInit; + extern thipDriverGetVersion *hipDriverGetVersion; ++extern thipRuntimeGetVersion *hipRuntimeGetVersion; + extern thipGetDevice *hipGetDevice; + extern thipGetDeviceCount *hipGetDeviceCount; + extern thipGetDeviceProperties *hipGetDeviceProperties; +diff --git a/extern/hipew/src/hipew.c b/extern/hipew/src/hipew.c +index 4927f86b804..74b2ef111d6 100644 +--- a/extern/hipew/src/hipew.c ++++ b/extern/hipew/src/hipew.c +@@ -35,6 +35,7 @@ thipGetErrorString *hipGetErrorString; + thipGetLastError *hipGetLastError; + thipInit *hipInit; + thipDriverGetVersion *hipDriverGetVersion; ++thipRuntimeGetVersion *hipRuntimeGetVersion; + thipGetDevice *hipGetDevice; + thipGetDeviceCount *hipGetDeviceCount; + thipGetDeviceProperties *hipGetDeviceProperties; +@@ -285,6 +286,7 @@ static int hipewHipInit(void) { + HIP_LIBRARY_FIND_CHECKED(hipGetLastError); + HIP_LIBRARY_FIND_CHECKED(hipInit); + HIP_LIBRARY_FIND_CHECKED(hipDriverGetVersion); ++ HIP_LIBRARY_FIND_CHECKED(hipRuntimeGetVersion); + HIP_LIBRARY_FIND_CHECKED(hipGetDevice); + HIP_LIBRARY_FIND_CHECKED(hipGetDeviceCount); + HIP_LIBRARY_FIND_CHECKED(hipGetDeviceProperties); +@@ -410,7 +412,28 @@ static int hipewHipInit(void) { + return result; + } + ++hipMemoryType get_hip_memory_type(hipMemoryType mem_type, int runtime_version) { ++ /** Convert hipMemoryType for backwards compatibility with rocm5/6. ++ * This can be removed when support for ROCm 5 is removed. */ + ++ /* If version is 5 we need to use the old enum vals (60000000 is start of ROCm 6) */ ++ if (runtime_version > 60000000) { ++ return mem_type; ++ } ++ ++ switch (mem_type) { ++ case hipMemoryTypeHost: ++ return hipMemoryTypeHost_v5; ++ case hipMemoryTypeDevice: ++ return hipMemoryTypeDevice_v5; ++ case hipMemoryTypeArray: ++ return hipMemoryTypeArray_v5; ++ case hipMemoryTypeUnified: ++ return hipMemoryTypeUnified_v5; ++ default: ++ return hipMemoryTypeUnregistered; /* This should not happen. */ ++ } ++} + + int hipewInit(hipuint32_t flags) { + int result = HIPEW_SUCCESS; +diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp +index 57d82b07631..9a3f6b95143 100644 +--- a/intern/cycles/device/hip/device_impl.cpp ++++ b/intern/cycles/device/hip/device_impl.cpp +@@ -116,6 +116,9 @@ HIPDevice::HIPDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler) + hipDeviceGetAttribute(&minor, hipDeviceAttributeComputeCapabilityMinor, hipDevId); + hipDevArchitecture = major * 100 + minor * 10; + ++ /* Get hip runtime Version needed for memory types. */ ++ hip_assert(hipRuntimeGetVersion(&hipRuntimeVersion)); ++ + /* Pop context set by hipCtxCreate. */ + hipCtxPopCurrent(NULL); + } +@@ -745,9 +748,9 @@ void HIPDevice::tex_alloc(device_texture &mem) + + HIP_MEMCPY3D param; + memset(¶m, 0, sizeof(HIP_MEMCPY3D)); +- param.dstMemoryType = hipMemoryTypeArray; ++ param.dstMemoryType = get_memory_type(hipMemoryTypeArray); + param.dstArray = array_3d; +- param.srcMemoryType = hipMemoryTypeHost; ++ param.srcMemoryType = get_memory_type(hipMemoryTypeHost); + param.srcHost = mem.host_pointer; + param.srcPitch = src_pitch; + param.WidthInBytes = param.srcPitch; +@@ -777,10 +780,10 @@ void HIPDevice::tex_alloc(device_texture &mem) + + hip_Memcpy2D param; + memset(¶m, 0, sizeof(param)); +- param.dstMemoryType = hipMemoryTypeDevice; ++ param.dstMemoryType = get_memory_type(hipMemoryTypeDevice); + param.dstDevice = mem.device_pointer; + param.dstPitch = dst_pitch; +- param.srcMemoryType = hipMemoryTypeHost; ++ param.srcMemoryType = get_memory_type(hipMemoryTypeHost); + param.srcHost = mem.host_pointer; + param.srcPitch = src_pitch; + param.WidthInBytes = param.srcPitch; +@@ -958,6 +961,11 @@ int HIPDevice::get_device_default_attribute(hipDeviceAttribute_t attribute, int + return value; + } + ++hipMemoryType HIPDevice::get_memory_type(hipMemoryType mem_type) ++{ ++ return get_hip_memory_type(mem_type, hipRuntimeVersion); ++} ++ + CCL_NAMESPACE_END + + #endif +diff --git a/intern/cycles/device/hip/device_impl.h b/intern/cycles/device/hip/device_impl.h +index bded023bd4a..fdbec2e3dbf 100644 +--- a/intern/cycles/device/hip/device_impl.h ++++ b/intern/cycles/device/hip/device_impl.h +@@ -32,6 +32,7 @@ class HIPDevice : public GPUDevice { + int pitch_alignment; + int hipDevId; + int hipDevArchitecture; ++ int hipRuntimeVersion; + bool first_error; + + HIPDeviceKernels kernels; +@@ -102,6 +103,7 @@ class HIPDevice : public GPUDevice { + protected: + bool get_device_attribute(hipDeviceAttribute_t attribute, int *value); + int get_device_default_attribute(hipDeviceAttribute_t attribute, int default_value); ++ hipMemoryType get_memory_type(hipMemoryType mem_type); + }; + + CCL_NAMESPACE_END