summarylogtreecommitdiffstats
path: root/blender.patch
blob: fe767829a70ae4775fe6726f6832be18964a9d7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
diff -x .git -ur usd.orig/cmake/defaults/Packages.cmake external_usd/cmake/defaults/Packages.cmake
--- usd.orig/cmake/defaults/Packages.cmake	2019-10-24 22:39:53.000000000 +0200
+++ external_usd/cmake/defaults/Packages.cmake	2019-11-28 13:00:33.185957483 +0100
@@ -64,7 +64,7 @@
 endif()
 
 # --TBB
-find_package(TBB REQUIRED COMPONENTS tbb)
+find_package(TBB)
 add_definitions(${TBB_DEFINITIONS})
 
 # --math
diff -x .git -ur usd.orig/pxr/base/plug/initConfig.cpp external_usd/pxr/base/plug/initConfig.cpp
--- usd.orig/pxr/base/plug/initConfig.cpp.orig	2020-06-12 17:20:07.478199779 +0200
+++ external_usd/pxr/base/plug/initConfig.cpp	2020-06-12 17:25:28.648588552 +0200
@@ -69,10 +69,40 @@

 ARCH_CONSTRUCTOR(Plug_InitConfig, 2, void)
 {
+    /* The contents of this constructor have been moved to usd_initialise_plugin_path(...) */
+}
+
+}; // end of anonymous namespace
+
+/**
+ * The contents of this function used to be in the static constructor Plug_InitConfig.
+ * This static constructor made it impossible for Blender to pass a path to the USD
+ * library at runtime, as the constructor would run before Blender's main() function.
+ *
+ * This function is wrapped in a C function of the same name (defined below),
+ * so that it can be called from Blender's main() function.
+ *
+ * The datafiles_usd_path path is used to point to the USD plugin path when Blender
+ * has been installed. The fallback_usd_path path should point to the build-time
+ * location of the USD plugin files so that Blender can be run on a development machine
+ * without requiring an installation step.
+ */
+void
+usd_initialise_plugin_path(const char *datafiles_usd_path)
+{
     std::vector<std::string> result;

     std::vector<std::string> debugMessages;

+    // Add Blender-specific paths. They MUST end in a slash, or symlinks will not be treated as directory.
+    if (datafiles_usd_path != NULL && datafiles_usd_path[0] != '\0') {
+        std::string datafiles_usd_path_str(datafiles_usd_path);
+        if (datafiles_usd_path_str.back() != '/') {
+            datafiles_usd_path_str += "/";
+        }
+        result.push_back(datafiles_usd_path_str);
+    }
+
     // Determine the absolute path to the Plug shared library.  Any relative
     // paths specified in the plugin search path will be anchored to this
     // directory, to allow for relocatability.  Note that this can fail when pxr
@@ -114,9 +144,24 @@
     _AppendPathList(&result, installLocation, binaryPath);
 #endif // PXR_INSTALL_LOCATION

-    Plug_SetPaths(result, debugMessages);
-}
+    if (!TfGetenv("PXR_PATH_DEBUG").empty()) {
+        printf("USD Plugin paths: (%zu in total):\n", result.size());
+        for(const std::string &path : result) {
+            printf("    %s\n", path.c_str());
+        }
+    }

+    Plug_SetPaths(result, debugMessages);
 }

 PXR_NAMESPACE_CLOSE_SCOPE
+
+/* Workaround to make it possible to pass a path at runtime to USD. */
+extern "C" {
+void
+usd_initialise_plugin_path(
+    const char *datafiles_usd_path)
+{
+    PXR_NS::usd_initialise_plugin_path(datafiles_usd_path);
+}
+}
diff -Naur external_usd_base/cmake/macros/Public.cmake external_usd/cmake/macros/Public.cmake
--- external_usd_base/cmake/macros/Public.cmake	2019-10-24 14:39:53 -0600
+++ external_usd/cmake/macros/Public.cmake	2020-01-11 13:33:29 -0700
@@ -996,6 +996,12 @@
     foreach(lib ${PXR_OBJECT_LIBS})
         string(TOUPPER ${lib} uppercaseName)
         list(APPEND exports "${uppercaseName}_EXPORTS=1")
+        # When building for blender, we do NOT want to export all symbols on windows.
+        # This is a dirty hack, but USD makes it impossible to do the right thing
+        # with the default options exposed.
+        if (WIN32)
+            list(APPEND exports "PXR_STATIC=1")
+        endif()
     endforeach()
     foreach(lib ${PXR_OBJECT_LIBS})
         set(objects "${objects};\$<TARGET_OBJECTS:${lib}>")

diff --git a/pxr/base/arch/align.h b/pxr/base/arch/align.h
index f3cabf4..ebc8a69 100644
--- a/pxr/base/arch/align.h
+++ b/pxr/base/arch/align.h
@@ -77,7 +77,11 @@ ArchAlignMemory(void *base)
 /// The size of a CPU cache line on the current processor architecture in bytes.
 ///
 /// \hideinitializer
+#if defined(ARCH_OS_DARWIN) && defined(ARCH_CPU_ARM)
+#define ARCH_CACHE_LINE_SIZE 128
+#else
 #define ARCH_CACHE_LINE_SIZE 64
+#endif
 
 ///@}
 
diff --git a/pxr/base/arch/math.h b/pxr/base/arch/math.h
index 3e66c37..64a052c 100644
--- a/pxr/base/arch/math.h
+++ b/pxr/base/arch/math.h
@@ -42,7 +42,7 @@ PXR_NAMESPACE_OPEN_SCOPE
 /// \addtogroup group_arch_Math
 ///@{
 
-#if defined (ARCH_CPU_INTEL) || defined(doxygen)
+#if defined (ARCH_CPU_INTEL) || defined(ARCH_CPU_ARM) || defined(doxygen)
 
 /// This is the smallest value e such that 1+e^2 == 1, using floats.
 /// True for all IEEE754 chipsets.