Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Build on macOS (no std::atomic_ref in Apple libc++) and cap CI build jobs at 4 (unbounded make -j ran runners out of memory)

islandmed371110bf4b79
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1790daed..cdd25aab 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -40,7 +40,7 @@ jobs:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSCULPTFORGE_USE_SYSTEM_SDL=OFF
-DSCULPTFORGE_BUILD_PYTHON=ON -DPython_EXECUTABLE="${{ env.pythonLocation }}/${{ runner.os == 'Windows' && 'python.exe' || 'bin/python3' }}"
- name: Build
- run: cmake --build build --config Release --parallel
+ run: cmake --build build --config Release --parallel 4
- name: Test (C++ and Python API)
run: ctest --test-dir build -C Release --output-on-failure -LE ui
- name: UI tests (real app, Xvfb + Mesa)
@@ -99,7 +99,7 @@ jobs:
gcc --version | head -1
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSCULPTFORGE_USE_SYSTEM_SDL=OFF \
-DSCULPTFORGE_BUILD_PYTHON=ON -DPython_EXECUTABLE="$PYTHON313"
- cmake --build build --parallel
+ cmake --build build --parallel 4
ctest --test-dir build --output-on-failure -LE ui
- name: Check binary compatibility (glibc <= ${{ matrix.glibc }})
run: |
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6a380123..f2777bb4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -32,7 +32,7 @@ jobs:
- name: Build and test
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DSCULPTFORGE_USE_SYSTEM_SDL=OFF
- cmake --build build --parallel
+ cmake --build build --parallel 4
ctest --test-dir build --output-on-failure -LE ui
- name: UI tests (real app, Xvfb + Mesa)
run: |
@@ -88,7 +88,7 @@ jobs:
source /opt/rh/gcc-toolset-14/enable
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DSCULPTFORGE_USE_SYSTEM_SDL=OFF \
-DSCULPTFORGE_BUILD_PYTHON=ON -DPython_EXECUTABLE="$PYTHON313" -DSCULPTFORGE_PYTHON_INSTALL_DIR=lib/sculptforge/python
- cmake --build build --parallel
+ cmake --build build --parallel 4
# UI tests need a display; they run under Xvfb in the Linux jobs above and in CI.
ctest --test-dir build --output-on-failure -LE ui
cd build
@@ -111,7 +111,7 @@ jobs:
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSCULPTFORGE_USE_SYSTEM_SDL=OFF \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
- cmake --build build --parallel
+ cmake --build build --parallel 4
# UI tests need a display; they run under Xvfb in the Linux jobs above and in CI.
ctest --test-dir build --output-on-failure -LE ui
- name: Package (signed ad-hoc inside CPack, see cmake/MacSign.cmake)
@@ -130,7 +130,7 @@ jobs:
- name: Build and test
run: |
cmake -S . -B build -DSCULPTFORGE_USE_SYSTEM_SDL=OFF
- cmake --build build --config Release --parallel
+ cmake --build build --config Release --parallel 4
# UI tests need a display; they run under Xvfb in the Linux jobs above and in CI.
ctest --test-dir build -C Release --output-on-failure -LE ui
- name: Package
diff --git a/packaging/rez/build.sh b/packaging/rez/build.sh
index ef826aee..c4ddcf2d 100755
--- a/packaging/rez/build.sh
+++ b/packaging/rez/build.sh
@@ -9,7 +9,7 @@ if [ -n "$python" ]; then
fi
cmake -S "$source_dir" -B . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$REZ_BUILD_INSTALL_PATH" \
-DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_LIBDIR=lib "${python_args[@]}"
-cmake --build . --parallel
+cmake --build . --parallel "${REZ_BUILD_THREAD_COUNT:-4}"
ctest --output-on-failure
if [ "${1:-}" = "install" ]; then
cmake --install .
diff --git a/src/core/AtomicRef.h b/src/core/AtomicRef.h
new file mode 100644
index 00000000..7845ea07
--- /dev/null
+++ b/src/core/AtomicRef.h
@@ -0,0 +1,32 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// AtomicRef<T>: atomic operations on a plain integer in a vector, for the parallel brush passes that mark
+// vertices and BVH leaves. std::atomic_ref where the standard library has it; Apple's libc++ doesn't yet,
+// so there the GCC/Clang __atomic builtins do the same (relaxed order only, all these passes need).
+#pragma once
+
+#include <atomic>
+
+namespace sf {
+
+#if defined(__cpp_lib_atomic_ref)
+template <typename T> using AtomicRef = std::atomic_ref<T>;
+#else
+template <typename T> class AtomicRef {
+public:
+ explicit AtomicRef(T& v) : p_(&v) {}
+ T load(std::memory_order) const { return __atomic_load_n(p_, __ATOMIC_RELAXED); }
+ void store(T v, std::memory_order) const { __atomic_store_n(p_, v, __ATOMIC_RELAXED); }
+ T exchange(T v, std::memory_order) const { return __atomic_exchange_n(p_, v, __ATOMIC_RELAXED); }
+ T fetch_or(T v, std::memory_order) const { return __atomic_fetch_or(p_, v, __ATOMIC_RELAXED); }
+ bool compare_exchange_weak(T& expected, T desired, std::memory_order) const {
+ return __atomic_compare_exchange_n(p_, &expected, desired, true, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
+ }
+
+private:
+ T* p_;
+};
+#endif
+
+} // namespace sf
diff --git a/src/core/BVH.cpp b/src/core/BVH.cpp
index 3a357a7d..43aee3d1 100644
--- a/src/core/BVH.cpp
+++ b/src/core/BVH.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "core/BVH.h"
+#include "core/AtomicRef.h"
#include "core/ThreadPool.h"
#include <algorithm>
@@ -323,7 +324,7 @@ void BVH::queryVertices(const Mesh& mesh, const glm::vec3& center, float radius,
std::vector<uint32_t>& found = queryParts_[k];
found.clear();
walk(tasks[k], nodeStack, [&](uint32_t v) {
- std::atomic_ref<uint32_t> owner(vertStamp_[v]);
+ AtomicRef<uint32_t> owner(vertStamp_[v]);
if (owner.load(std::memory_order_relaxed) == mine || !inside(v)) return;
found.push_back(v);
for (uint32_t cur = owner.load(std::memory_order_relaxed);
@@ -338,7 +339,7 @@ void BVH::queryVertices(const Mesh& mesh, const glm::vec3& center, float radius,
std::vector<uint32_t>& found = queryParts_[k];
size_t kept = 0;
for (uint32_t v : found) {
- std::atomic_ref<uint32_t> owner(vertStamp_[v]);
+ AtomicRef<uint32_t> owner(vertStamp_[v]);
if (owner.load(std::memory_order_relaxed) != mine) continue;
owner.store(done, std::memory_order_relaxed);
found[kept++] = v;
@@ -374,7 +375,7 @@ void BVH::refit(const Mesh& mesh, std::span<const uint32_t> movedVerts) {
for (size_t i = b; i < e; ++i)
for (uint32_t ti : mesh.vertexTriangles(movedVerts[i])) {
const uint32_t leaf = triLeaf_[ti];
- if (std::atomic_ref<uint32_t>(leafStamp_[leaf]).exchange(s, std::memory_order_relaxed) != s)
+ if (AtomicRef<uint32_t>(leafStamp_[leaf]).exchange(s, std::memory_order_relaxed) != s)
out.push_back(leaf);
}
}, kBlock);
diff --git a/src/core/Mesh.cpp b/src/core/Mesh.cpp
index 1d1de78a..7e654d68 100644
--- a/src/core/Mesh.cpp
+++ b/src/core/Mesh.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "core/Mesh.h"
#include "core/Multires.h"
+#include "core/AtomicRef.h"
#include "core/ThreadPool.h"
#include <algorithm>
@@ -277,7 +278,7 @@ void Mesh::updateNormals(std::span<const uint32_t> verts) {
std::vector<uint32_t>& out = scratchParts_[b / kBlock];
out.clear();
for (size_t i = b; i < e; ++i)
- if (std::atomic_ref<uint32_t>(vertStamp_[verts[i]]).exchange(own, std::memory_order_relaxed) != own)
+ if (AtomicRef<uint32_t>(vertStamp_[verts[i]]).exchange(own, std::memory_order_relaxed) != own)
out.push_back(verts[i]);
}, kBlock);
poolFor(verts.size(), [&](size_t b, size_t e) {
@@ -285,7 +286,7 @@ void Mesh::updateNormals(std::span<const uint32_t> verts) {
out.clear();
for (size_t i = b; i < e; ++i)
for (uint32_t u : neighbors(verts[i])) {
- std::atomic_ref<uint32_t> stamp(vertStamp_[u]);
+ AtomicRef<uint32_t> stamp(vertStamp_[u]);
const uint32_t seen = stamp.load(std::memory_order_relaxed);
if (seen == own || seen == ring) continue;
if (stamp.exchange(ring, std::memory_order_relaxed) != ring) out.push_back(u);
@@ -306,8 +307,8 @@ void Mesh::updateNormals(std::span<const uint32_t> verts) {
if (len > 1e-20f) normals[v] = sum / len;
lo = std::min(lo, v);
hi = std::max(hi, v);
- std::atomic_ref<uint8_t>(dirtyBlocks[v >> kDirtyBlockShift]).store(1, std::memory_order_relaxed);
- std::atomic_ref<uint64_t>(dirtyBits[v >> 6]).fetch_or(uint64_t(1) << (v & 63), std::memory_order_relaxed);
+ AtomicRef<uint8_t>(dirtyBlocks[v >> kDirtyBlockShift]).store(1, std::memory_order_relaxed);
+ AtomicRef<uint64_t>(dirtyBits[v >> 6]).fetch_or(uint64_t(1) << (v & 63), std::memory_order_relaxed);
}
bounds[b / kBlock] = {lo, hi + 1};
}, kBlock);