From c23f22dd5b96e2143de1b3ec5b15e6f9af629fa1 Mon Sep 17 00:00:00 2001 From: Luna Nova Date: Sat, 3 Jan 2026 11:04:41 -0800 Subject: [PATCH] blender-hip: manual backport of hiprt 3 support Minimal backport that applies on current blender of https://projects.blender.org/blender/blender/pulls/144889 --- pkgs/by-name/bl/blender/hiprt-3-compat.patch | 72 ++++++++++++++++++++ pkgs/by-name/bl/blender/package.nix | 3 + 2 files changed, 75 insertions(+) create mode 100644 pkgs/by-name/bl/blender/hiprt-3-compat.patch diff --git a/pkgs/by-name/bl/blender/hiprt-3-compat.patch b/pkgs/by-name/bl/blender/hiprt-3-compat.patch new file mode 100644 index 000000000000..b3f410128507 --- /dev/null +++ b/pkgs/by-name/bl/blender/hiprt-3-compat.patch @@ -0,0 +1,72 @@ +diff --git a/extern/hipew/include/hiprtew.h b/extern/hipew/include/hiprtew.h +index d245cb76..952ed805 100644 +--- a/extern/hipew/include/hiprtew.h ++++ b/extern/hipew/include/hiprtew.h +@@ -157,7 +157,7 @@ typedef hiprtError (thiprtDestroyGlobalStackBuffer)( hiprtContext context, hiprt + + typedef hiprtError(thiprtDestroyFuncTable)(hiprtContext context, + hiprtFuncTable funcTable); +-typedef void(thiprtSetLogLevel)( hiprtLogLevel level ); ++typedef hiprtError(thiprtSetLogLevel)( hiprtContext context, hiprtLogLevel level ); + + /* Function declarations. */ + extern thiprtCreateContext *hiprtCreateContext; +diff --git a/extern/hipew/src/hipew.c b/extern/hipew/src/hipew.c +index e72ccde6..138e1efc 100644 +--- a/extern/hipew/src/hipew.c ++++ b/extern/hipew/src/hipew.c +@@ -241,13 +241,13 @@ static int hipewHipInit(void) { + /* ROCm 6 changes paths from /opt/rocm/hip/lib to /opt/rocm/lib, so + * search for libraries there. */ + +- const char* hip_paths[] = { "libamdhip64.so", ++ const char* hip_paths[] = { "libamdhip64.so.7", ++ "/opt/rocm/lib/libamdhip64.so.7", ++ "/opt/rocm/hip/lib/libamdhip64.so.7", + "libamdhip64.so.6", + "/opt/rocm/lib/libamdhip64.so.6", + "/opt/rocm/hip/lib/libamdhip64.so.6", +- "libamdhip64.so.7", +- "/opt/rocm/lib/libamdhip64.so.7", +- "/opt/rocm/hip/lib/libamdhip64.so.7", ++ "libamdhip64.so", + NULL }; + #endif + static int initialized = 0; +diff --git a/intern/cycles/device/hiprt/device_impl.cpp b/intern/cycles/device/hiprt/device_impl.cpp +index c251a8d0..b54bc36c 100644 +--- a/intern/cycles/device/hiprt/device_impl.cpp ++++ b/intern/cycles/device/hiprt/device_impl.cpp +@@ -104,10 +104,10 @@ HIPRTDevice::HIPRTDevice(const DeviceInfo &info, + } + + if (LOG_IS_ON(LOG_LEVEL_TRACE)) { +- hiprtSetLogLevel(hiprtLogLevelInfo | hiprtLogLevelWarn | hiprtLogLevelError); ++ hiprtSetLogLevel(hiprt_context, hiprtLogLevelInfo | hiprtLogLevelWarn | hiprtLogLevelError); + } + else { +- hiprtSetLogLevel(hiprtLogLevelNone); ++ hiprtSetLogLevel(hiprt_context, hiprtLogLevelNone); + } + } + +diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt +index bcaf4e16..aa6a3d17 100644 +--- a/intern/cycles/kernel/CMakeLists.txt ++++ b/intern/cycles/kernel/CMakeLists.txt +@@ -93,13 +93,13 @@ set(SRC_KERNEL_DEVICE_HIPRT_HEADERS + set(SRC_KERNEL_DEVICE_HIPRT_SDK + hiprt/impl/Aabb.h + hiprt/impl/BvhNode.h +- hiprt/impl/Geometry.h ++ hiprt/impl/Header.h + hiprt/impl/hiprt_device_impl.h + hiprt/impl/hiprt_kernels_bitcode.h + hiprt/impl/Instance.h ++ hiprt/impl/Obb.h + hiprt/impl/QrDecomposition.h + hiprt/impl/Quaternion.h +- hiprt/impl/Scene.h + hiprt/impl/Transform.h + hiprt/impl/Triangle.h + ) diff --git a/pkgs/by-name/bl/blender/package.nix b/pkgs/by-name/bl/blender/package.nix index f4cec841f317..33630f2a2b26 100644 --- a/pkgs/by-name/bl/blender/package.nix +++ b/pkgs/by-name/bl/blender/package.nix @@ -126,6 +126,9 @@ stdenv'.mkDerivation (finalAttrs: { hash = "sha256-fNnQRfGfNc7rbk8npkcYtoAqRjJc6MaV4mqtSJxd0EM="; }; + # Minimal backport of hiprt 3.x support from https://projects.blender.org/blender/blender/pulls/144889 + patches = lib.optional rocmSupport ./hiprt-3-compat.patch; + postPatch = (lib.optionalString stdenv.hostPlatform.isDarwin '' : > build_files/cmake/platform/platform_apple_xcode.cmake