blender patches

This commit is contained in:
2025-07-12 14:38:47 +03:00
parent 792e1b937a
commit 19984c4b4f
10 changed files with 428 additions and 0 deletions

4
.gitmodules vendored
View File

@@ -102,3 +102,7 @@
path = oneTBB path = oneTBB
url = https://github.com/uxlfoundation/oneTBB url = https://github.com/uxlfoundation/oneTBB
branch = master branch = master
[submodule "pugixml"]
path = pugixml
url = https://github.com/zeux/pugixml
branch = master

View File

@@ -0,0 +1,25 @@
From: "Matteo F. Vescovi" <mfv@debian.org>
Date: Sun, 28 Jul 2019 14:54:30 +0200
Subject: install_in_usr_share
* Arch-specific files go to /usr/share
* Make blender look for systemdir into /usr/share
---
source/creator/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 816d3a6..ed03aac 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -383,8 +383,8 @@ if(WITH_PYTHON)
endif()
install(
- DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
- DESTINATION ${TARGETDIR_VER}
+ DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts/
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/blender/scripts/
PATTERN ".git" EXCLUDE
PATTERN ".gitignore" EXCLUDE
PATTERN ".arcconfig" EXCLUDE

View File

@@ -0,0 +1,42 @@
From: "Matteo F. Vescovi" <mfv@debian.org>
Date: Tue, 18 Jan 2022 23:50:42 +0100
Subject: do_not_use_version_number_in_system_path
Global installation expects system path to be
something like /usr/share/blender/scripts/
without version numbers.
Contributions by:
Antonio Ospite <ospite@studenti.unina.it>
---
intern/ghost/intern/GHOST_SystemPathsUnix.cpp | 3 +++
source/creator/CMakeLists.txt | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/intern/ghost/intern/GHOST_SystemPathsUnix.cpp b/intern/ghost/intern/GHOST_SystemPathsUnix.cpp
index 7239678..174696e 100644
--- a/intern/ghost/intern/GHOST_SystemPathsUnix.cpp
+++ b/intern/ghost/intern/GHOST_SystemPathsUnix.cpp
@@ -57,6 +57,9 @@ GHOST_SystemPathsUnix::~GHOST_SystemPathsUnix()
const char *GHOST_SystemPathsUnix::getSystemDir(int, const char *versionstr) const
{
+ /* XXX On Debian ignore versionstr when building the system path */
+ versionstr = "";
+
/* no prefix assumes a portable build which only uses bundled scripts */
if (static_path) {
static string system_path = string(static_path) + "/blender/" + versionstr;
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index ed03aac..83779a8 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -328,7 +328,7 @@ if(UNIX AND NOT APPLE)
if(WITH_INSTALL_PORTABLE)
set(TARGETDIR_VER ${BLENDER_VERSION})
else()
- set(TARGETDIR_VER share/blender/${BLENDER_VERSION})
+ set(TARGETDIR_VER share/blender)
endif()
endif()

View File

@@ -0,0 +1,98 @@
From: "Matteo F. Vescovi" <mfv@debian.org>
Date: Thu, 5 Aug 2021 22:53:36 +0200
Subject: locales_directory_install
Change where locales are installed.
Contributions by:
Antonio Ospite <ao2@ao2.it>
Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
---
source/blender/blenkernel/BKE_appdir.h | 1 +
source/blender/blenkernel/intern/appdir.c | 3 +++
source/blender/blentranslation/intern/blt_lang.c | 10 +++++-----
source/creator/CMakeLists.txt | 2 +-
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/source/blender/blenkernel/BKE_appdir.h b/source/blender/blenkernel/BKE_appdir.h
index 6548505..69e4b5c 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -94,6 +94,7 @@ enum {
BLENDER_SYSTEM_DATAFILES = 52,
BLENDER_SYSTEM_SCRIPTS = 53,
BLENDER_SYSTEM_PYTHON = 54,
+ BLENDER_SYSTEM_LOCALE = 55,
};
/* for BKE_appdir_folder_id_version only */
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 08a3b7d..a9b7d38 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -721,6 +721,9 @@ bool BKE_appdir_folder_id_ex(const int folder_id,
}
return false;
+ case BLENDER_SYSTEM_LOCALE:
+ BLI_strncpy(path, "/usr/share/locale", FILE_MAX); break;
+
default:
BLI_assert_unreachable();
break;
diff --git a/source/blender/blentranslation/intern/blt_lang.c b/source/blender/blentranslation/intern/blt_lang.c
index 91e8a81..6574810 100644
--- a/source/blender/blentranslation/intern/blt_lang.c
+++ b/source/blender/blentranslation/intern/blt_lang.c
@@ -78,9 +78,9 @@ static void free_locales(void)
num_locales = num_locales_menu = 0;
}
-static void fill_locales(void)
+static void fill_locales(char *locale_path)
{
- const char *const languages_path = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale");
+ const char * const languages_path = locale_path;
char languages[FILE_MAX];
LinkNode *lines = NULL, *line;
char *str;
@@ -88,7 +88,7 @@ static void fill_locales(void)
free_locales();
- BLI_join_dirfile(languages, FILE_MAX, languages_path, "languages");
+ BLI_join_dirfile(languages, FILE_MAX, locale_path, "languages");
line = lines = BLI_file_read_as_lines(languages);
/* This whole "parsing" code is a bit weak, in that it expects strictly formatted input file...
@@ -195,7 +195,7 @@ EnumPropertyItem *BLT_lang_RNA_enum_properties(void)
void BLT_lang_init(void)
{
#ifdef WITH_INTERNATIONAL
- const char *const messagepath = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale");
+ const char * const messagepath = BKE_appdir_folder_id(BLENDER_SYSTEM_LOCALE, NULL);
#endif
/* Make sure LANG is correct and wouldn't cause #std::runtime_error. */
@@ -228,7 +228,7 @@ void BLT_lang_init(void)
#ifdef WITH_INTERNATIONAL
if (messagepath) {
bl_locale_init(messagepath, TEXT_DOMAIN_NAME);
- fill_locales();
+ fill_locales(messagepath);
}
else {
printf("%s: 'locale' data path for translations not found, continuing\n", __func__);
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 83779a8..9836c8f 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -407,7 +407,7 @@ install(
# localization
if(WITH_INTERNATIONAL)
set(_locale_dir "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
- set(_locale_target_dir ${TARGETDIR_VER}/datafiles/locale)
+ set(_locale_target_dir ${CMAKE_INSTALL_PREFIX}/share/locale)
file(GLOB _po_files "${_locale_dir}/po/*.po")
foreach(_po_file ${_po_files})

View File

@@ -0,0 +1,27 @@
From: Aurelien Jarno <aurelien@aurel32.net>
Date: Mon, 18 Oct 2021 23:02:51 +0200
Subject: fix_linking_with_WITH_X11_XF86VMODE_and_bfd
Fix typos in the variables of the Xxf86vm libray to fix link failure
with bfd. These variables are defined in platform_unix.cmake.
---
intern/ghost/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 4164231..84f1569 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -245,10 +245,10 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
if(WITH_X11_XF86VMODE)
add_definitions(-DWITH_X11_XF86VMODE)
list(APPEND INC_SYS
- ${X11_xf86vmode_INCLUDE_PATH}
+ ${X11_Xxf86vmode_INCLUDE_PATH}
)
list(APPEND LIB
- ${X11_Xf86vmode_LIB}
+ ${X11_Xxf86vmode_LIB}
)
endif()

View File

@@ -0,0 +1,120 @@
From: Sergey Sharybin <sergey@blender.org>
Date: Wed, 2 Feb 2022 11:17:13 +0100
Subject: fix_round_trip_in_Cycles
There are two things achieved by this change:
- No possible downcast of size_t to int when calculating motion steps.
- Disambiguate call to min() which was for some reason considered
ambiguous on 32bit platforms `min(int, unsigned int)`.
Differential Revision: https://developer.blender.org/D13992
---
intern/cycles/bvh/embree.cpp | 6 +++---
intern/cycles/scene/hair.cpp | 8 ++++----
intern/cycles/scene/mesh.cpp | 2 +-
intern/cycles/util/math.h | 7 ++++++-
4 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/intern/cycles/bvh/embree.cpp b/intern/cycles/bvh/embree.cpp
index 944a84c..386c6f4 100644
--- a/intern/cycles/bvh/embree.cpp
+++ b/intern/cycles/bvh/embree.cpp
@@ -418,7 +418,7 @@ void BVHEmbree::add_instance(Object *ob, int i)
assert(instance_bvh != NULL);
const size_t num_object_motion_steps = ob->use_motion() ? ob->get_motion().size() : 1;
- const size_t num_motion_steps = min(num_object_motion_steps, RTC_MAX_TIME_STEP_COUNT);
+ const size_t num_motion_steps = min(num_object_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT);
assert(num_object_motion_steps <= RTC_MAX_TIME_STEP_COUNT);
RTCGeometry geom_id = rtcNewGeometry(rtc_device, RTC_GEOMETRY_TYPE_INSTANCE);
@@ -469,7 +469,7 @@ void BVHEmbree::add_triangles(const Object *ob, const Mesh *mesh, int i)
}
assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT);
- num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT);
+ num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT);
const size_t num_triangles = mesh->num_triangles();
@@ -638,7 +638,7 @@ void BVHEmbree::add_curves(const Object *ob, const Hair *hair, int i)
}
assert(num_motion_steps <= RTC_MAX_TIME_STEP_COUNT);
- num_motion_steps = min(num_motion_steps, RTC_MAX_TIME_STEP_COUNT);
+ num_motion_steps = min(num_motion_steps, (size_t)RTC_MAX_TIME_STEP_COUNT);
const size_t num_curves = hair->num_curves();
size_t num_segments = 0;
diff --git a/intern/cycles/scene/hair.cpp b/intern/cycles/scene/hair.cpp
index 2951a60..0fd9c70 100644
--- a/intern/cycles/scene/hair.cpp
+++ b/intern/cycles/scene/hair.cpp
@@ -119,7 +119,7 @@ void Hair::Curve::motion_keys(const float3 *curve_keys,
{
/* Figure out which steps we need to fetch and their interpolation factor. */
const size_t max_step = num_steps - 1;
- const size_t step = min((int)(time * max_step), max_step - 1);
+ const size_t step = std::min((size_t)(time * max_step), max_step - 1);
const float t = time * max_step - step;
/* Fetch vertex coordinates. */
float4 curr_keys[2];
@@ -147,7 +147,7 @@ void Hair::Curve::cardinal_motion_keys(const float3 *curve_keys,
{
/* Figure out which steps we need to fetch and their interpolation factor. */
const size_t max_step = num_steps - 1;
- const size_t step = min((int)(time * max_step), max_step - 1);
+ const size_t step = min((size_t)(time * max_step), max_step - 1);
const float t = time * max_step - step;
/* Fetch vertex coordinates. */
float4 curr_keys[4];
@@ -192,7 +192,7 @@ void Hair::Curve::keys_for_step(const float3 *curve_keys,
float4 r_keys[2]) const
{
k0 = max(k0, 0);
- k1 = min(k1, num_keys - 1);
+ k1 = min(k1, (size_t)(num_keys - 1));
const size_t center_step = ((num_steps - 1) / 2);
if (step == center_step) {
/* Center step: regular key location. */
@@ -238,7 +238,7 @@ void Hair::Curve::cardinal_keys_for_step(const float3 *curve_keys,
float4 r_keys[4]) const
{
k0 = max(k0, 0);
- k3 = min(k3, num_keys - 1);
+ k3 = min(k3, (size_t)(num_keys - 1));
const size_t center_step = ((num_steps - 1) / 2);
if (step == center_step) {
/* Center step: regular key location. */
diff --git a/intern/cycles/scene/mesh.cpp b/intern/cycles/scene/mesh.cpp
index f47dab3..e6c8d9b 100644
--- a/intern/cycles/scene/mesh.cpp
+++ b/intern/cycles/scene/mesh.cpp
@@ -53,7 +53,7 @@ void Mesh::Triangle::motion_verts(const float3 *verts,
{
/* Figure out which steps we need to fetch and their interpolation factor. */
const size_t max_step = num_steps - 1;
- const size_t step = min((int)(time * max_step), max_step - 1);
+ const size_t step = min((size_t)(time * max_step), max_step - 1);
const float t = time * max_step - step;
/* Fetch vertex coordinates. */
float3 curr_verts[3];
diff --git a/intern/cycles/util/math.h b/intern/cycles/util/math.h
index e4c7df6..4e0e97f 100644
--- a/intern/cycles/util/math.h
+++ b/intern/cycles/util/math.h
@@ -122,7 +122,12 @@ ccl_device_inline int min(int a, int b)
return (a < b) ? a : b;
}
-ccl_device_inline uint min(uint a, uint b)
+ccl_device_inline uint32_t min(uint32_t a, uint32_t b)
+{
+ return (a < b) ? a : b;
+}
+
+ccl_device_inline uint64_t min(uint64_t a, uint64_t b)
{
return (a < b) ? a : b;
}

View File

@@ -0,0 +1,40 @@
From: Sergey Sharybin <sergey@blender.org>
Date: Wed, 9 Feb 2022 23:15:50 +0100
Subject: fix_Cycles_compilation_on_ARM
The rbit instruction is only available starting with ARMv6T2 and
the register prefix is different from what AARCH64 uses.
Separate the 32 and 64 bit ARM branches, add missing ISA checks.
Made sure the code works as intended on macMini with Apple silicon,
and on Raspberry Pi 4 B running 32bit Raspbian OS.
Differential Revision: https://developer.blender.org/D14056
Signed-off-by: Matteo F. Vescovi <mfv@debian.org>
---
intern/cycles/util/math.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/intern/cycles/util/math.h b/intern/cycles/util/math.h
index 4e0e97f..7fc829f 100644
--- a/intern/cycles/util/math.h
+++ b/intern/cycles/util/math.h
@@ -849,9 +849,15 @@ ccl_device_inline uint prev_power_of_two(uint x)
ccl_device_inline uint32_t reverse_integer_bits(uint32_t x)
{
/* Use a native instruction if it exists. */
-#if defined(__arm__) || defined(__aarch64__)
+#if defined(__aarch64__) || defined(_M_ARM64)
+ /* Assume the rbit is always available on 64bit ARM architecture. */
__asm__("rbit %w0, %w1" : "=r"(x) : "r"(x));
return x;
+#elif defined(__arm__) && ((__ARM_ARCH > 7) || __ARM_ARCH == 6 && __ARM_ARCH_ISA_THUMB >= 2)
+ /* This ARM instruction is available in ARMv6T2 and above.
+ * This 32-bit Thumb instruction is available in ARMv6T2 and above. */
+ __asm__("rbit %0, %1" : "=r"(x) : "r"(x));
+ return x;
#elif defined(__KERNEL_CUDA__)
return __brev(x);
#elif __has_builtin(__builtin_bitreverse32)

View File

@@ -0,0 +1,64 @@
From: Sergey Sharybin <sergey@blender.org>
Date: Fri, 11 Feb 2022 11:10:53 +0100
Subject: fix_compilation_on_certain_platforms
Atomic operations performed by the C++ standard library might require
libatomic on platforms which do not have hardware support for those
operations.
This change makes it that such configurations are automatically detected
and -latomic is added when needed.
---
build_files/cmake/platform/platform_unix.cmake | 42 ++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index fc0c37e..e7c6509 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -741,3 +741,45 @@ if(WITH_COMPILER_CCACHE)
set(WITH_COMPILER_CCACHE OFF)
endif()
endif()
+
+# On some platforms certain atomic operations are not possible with assembly and/or intrinsics and
+# they are emulated in software with locks. For example, on armel there is no intrinsics to grant
+# 64 bit atomic operations and STL library uses libatomic to offload software emulation of atomics
+# to.
+# This function will check whether libatomic is required and if so will configure linker flags.
+# If atomic operations are possible without libatomic then linker flags are left as-is.
+function(CONFIGURE_ATOMIC_LIB_IF_NEEDED)
+ # Source which is used to enforce situation when software emulation of atomics is required.
+ # Assume that using 64bit integer gives a definitive asnwer (as in, if 64bit atomic operations
+ # are possible using assembly/intrinsics 8, 16, and 32 bit operations will also be possible.
+ set(_source
+ "#include <atomic>
+ #include <cstdint>
+ int main(int argc, char **argv) {
+ std::atomic<uint64_t> uint64; uint64++;
+ return 0;
+ }")
+
+ include(CheckCXXSourceCompiles)
+ check_cxx_source_compiles("${_source}" ATOMIC_OPS_WITHOUT_LIBATOMIC)
+
+ if(NOT ATOMIC_OPS_WITHOUT_LIBATOMIC)
+ # Compilation of the test program has failed.
+ # Try it again with -latomic to see if this is what is needed, or whether something else is
+ # going on.
+
+ set(CMAKE_REQUIRED_LIBRARIES atomic)
+ check_cxx_source_compiles("${_source}" ATOMIC_OPS_WITH_LIBATOMIC)
+
+ if(ATOMIC_OPS_WITH_LIBATOMIC)
+ set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -latomic" PARENT_SCOPE)
+ else()
+ # Atomic operations are required part of Blender and it is not possible to process forward.
+ # We expect that either standard library or libatomic will make atomics to work. If both
+ # cases has failed something fishy o na bigger scope is going on.
+ message(FATAL_ERROR "Failed to detect required configuration for atomic operations")
+ endif()
+ endif()
+endfunction()
+
+CONFIGURE_ATOMIC_LIB_IF_NEEDED()

7
blender-patches/series Normal file
View File

@@ -0,0 +1,7 @@
0001-install_in_usr_share.patch
0002-do_not_use_version_number_in_system_path.patch
0003-locales_directory_install.patch
0004-fix_linking_with_WITH_X11_XF86VMODE_and_bfd.patch
0005-fix_round_trip_in_Cycles.patch
0006-fix_Cycles_compilation_on_ARM.patch
0007-fix_compilation_on_certain_platforms.patch

1
pugixml Submodule

Submodule pugixml added at 5a1892b321