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.

Docs and ctest for the hardware profile: performance guide chapter, docs/performance.md (probe, benchmarks, tiers, TierConfig, governor, how micromesh reads the budget, this machine's calibration), CHANGELOG, ui_calibrate_json

islandmed6f3172544b72
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 067543ea..8bfbabf2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,27 @@ All notable changes to SculptForge are listed here. The format follows
## [Unreleased]
+### Added
+- Automatic hardware detection and calibration. On first launch, and again when the graphics card, its driver or
+ the version changes, SculptForge spends about a second or two (under a small overlay; Esc skips) measuring
+ triangle throughput, upload bandwidth, brush speed and memory bandwidth, and probes the GPU (OpenGL strings,
+ video memory through GL_NVX_gpu_memory_info, GL_ATI_meminfo, GLX_MESA_query_renderer, amdgpu sysfs, DXGI or
+ CGL), RAM, threads, SIMD and OS. The result picks a profile: **Laptop / Budget**, **Workstation** (16 GB+
+ discrete GPU, 64 GB+ RAM) or a **Software** safe mode for llvmpipe, with a render triangle budget, motion proxy
+ threshold, GPU memory and upload budgets, texture, subdivision and micro-triangle limits and the thread count.
+ Cached in the settings folder; no network use. A one-line status bar message says what was found.
+- Preferences > Performance shows what was detected and measured ("Detected <GPU>, <memory> -> Workstation"),
+ the settings in effect, **Re-calibrate** and manual overrides (kept across re-calibrations).
+- An adaptive frame governor holds the view at 60 fps (120 / 144 on a fast display) while it moves, by switching
+ big scenes to their motion proxy sooner or later, with hysteresis; it changes only what is drawn, never the
+ model. Fast Navigation's 10 million triangle threshold now comes from the profile.
+- On battery (laptops), brushes switch to draft mode, uploads per frame halve and the target is 60 Hz.
+- `sculptforge --calibrate` prints the profile as JSON (schema sculptforge.calibration/1); commands
+ `performance_profile`, `calibrate` and `set_performance_override` for the console, scripts and MCP.
+- For developers: `core/TierConfig.h` (resident cache cap, active-triangle budget, upload budget, draft brush
+ mode, zero-copy UMA, target Hz) and `renderTriangleBudget()` for the renderer and micro-displacement
+ (docs/performance.md, "Hardware profile").
+
## [0.9.7] - 2026-10-31
Speed first: big brushes on dense meshes take a third less time per frame, trail the pen by half as far and no
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9a780894..4e60eb49 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -549,6 +549,9 @@ if(SCULPTFORGE_BUILD_TESTS)
# Idle, the app draws nothing (#14): --measure-idle fails when it keeps drawing frames.
add_test(NAME ui_idle_redraw COMMAND sculptforge --measure-idle 4)
set_tests_properties(ui_idle_redraw PROPERTIES LABELS ui TIMEOUT 60 ENVIRONMENT "SF_NO_UPDATE_CHECK=1")
+ # sculptforge --calibrate on this machine's GPU: the JSON it prints passes the schema check (it exits 1 if not).
+ add_test(NAME ui_calibrate_json COMMAND sculptforge --calibrate-quick --calibrate-no-save)
+ set_tests_properties(ui_calibrate_json PROPERTIES LABELS ui TIMEOUT 60)
# A fast stroke in the interactive loop (dabs queued, placed a few milliseconds a frame): every dab lands on the
# pointer's circle (#19).
add_test(NAME ui_stroke_path COMMAND sculptforge --run "new_sphere" --measure-stroke 1.5)
diff --git a/docs/guide/performance.md b/docs/guide/performance.md
index 64dd27f9..ec271751 100644
--- a/docs/guide/performance.md
+++ b/docs/guide/performance.md
@@ -37,11 +37,43 @@ Open **Preferences** and click **Performance**.
| Control | What it does |
|---|---|
| **Antialiasing** (Off, 2x, 4x, 8x) | How many samples per pixel the 3D view uses to smooth edges. 4x is the default. More samples look smoother and cost more on huge meshes. If the graphics card can't make room for them, the view quietly uses fewer and the panel says so |
-| **Fast Navigation** | While you rotate, pan or zoom a scene of 10 million triangles or more, draw it without antialiasing and draw big meshes as a lighter version with about a fifth of their triangles, so the view keeps up. The full mesh, smooth again, is back as soon as the view stops. On by default |
+| **Fast Navigation** | While you rotate, pan or zoom a scene bigger than the hardware profile's motion proxy threshold (see below), draw it without antialiasing and draw big meshes as a lighter version with about a fifth of their triangles, so the view keeps up. The full mesh, smooth again, is back as soon as the view stops. On by default |
| **Multithreading** | Run brushes, normal and picking updates and project saving on every core (the number of threads is shown beside it). The results are exactly the same with it off; turn it off only to compare speeds or rule it out when something goes wrong |
| **Last stroke** | What your last stroke cost per dab: **Brush** (finding and moving the vertices), **Normals** (shading), **BVH** (the structure that finds the surface under the cursor), and the **GPU upload** per frame |
| **Memory** | What the scene holds: the meshes, the BVHs, the subdivision levels kept for stepping between them, the undo history (up to 1 GB; the oldest steps are dropped beyond that) and, roughly, the graphics card's buffers |
+## The hardware profile
+
+The first time you start SculptForge, a small window says **Getting to know this computer** for a second or two:
+it checks how fast your graphics card draws and receives data, how fast a brush runs and how fast the memory is,
+and picks settings to match. It does this once, and again only when you change the graphics card, update its
+driver or install a new version. Press <kbd>Esc</kbd> or **Skip** to skip it; the settings then come from the
+type of graphics card and the memory sizes. Nothing is sent anywhere: the results stay in your settings folder.
+
+There are two main profiles and a safe mode:
+
+| Profile | For | What changes |
+|---|---|---|
+| **Laptop / Budget** | laptops and most desktops: 8-16 GB of memory, a 2-4 GB graphics card, Apple Silicon | a moderate number of triangles drawn while the view moves; brushes update shading when you lift the pen (draft brushes) |
+| **Workstation** | 64 GB of memory or more and a graphics card with 16 GB or more | more triangles drawn per frame, larger textures and subdivision limits, shading updated with every dab |
+| **Software** (safe mode) | no graphics driver, so the drawing happens on the processor (llvmpipe) | the lightest settings, no antialiasing |
+
+On a laptop running on battery, SculptForge switches to draft brushes, sends less data to the graphics card per
+frame and aims for 60 frames a second, and the status bar says so; plugged in again, it goes back.
+
+At the top of **Preferences > Performance**:
+
+| Control | What it does |
+|---|---|
+| **Detected ...** | the graphics card, its memory and the profile, and why |
+| Measured numbers | triangles drawn per second, upload speed, the cost of a brush dab, memory speed, the processor and the system |
+| Settings | how many triangles the view draws per frame, from what size big scenes use their lighter version while moving, memory and upload budgets, texture and subdivision limits, threads, the target frame rate (60, or 120 / 144 on a fast display) |
+| **Frame Governor** | while the view moves, watch how long frames take and draw big scenes' lighter version sooner or later to hold the target frame rate. It only changes what you see while moving, never the model. On by default |
+| **Re-calibrate** | measure again (your overrides are kept) |
+| **Manual overrides** | choose the profile yourself, or set any of the numbers (empty = automatic); **Back to automatic** clears them. Overrides are saved at once and kept when you re-calibrate |
+
+From a shell, `sculptforge --calibrate` measures and prints the result as JSON.
+
Like the other preferences, these last until you quit; **Preferences > Config > Store Config** keeps them. Every
setting is also in the <kbd>F3</kbd> command palette (type "antialiasing", "fast navigation" or
"multithreading").
diff --git a/docs/performance.md b/docs/performance.md
index 2856f75d..8ffd4f20 100644
--- a/docs/performance.md
+++ b/docs/performance.md
@@ -12,6 +12,145 @@ sculptforge-cli --bench ... # the same without the GPU (CI,
Machine for all figures: Apple M1 Pro (8 performance + 2 efficiency cores, 32 GB unified memory, 30 GB usable
under Asahi Linux), integrated GPU, Mesa 26.1 (OpenGL 4.6). How the benchmark works is described under v0.5 below.
+## Hardware profile, calibration and the frame governor (feat/hw-profile)
+
+SculptForge measures the computer it runs on and sets its budgets from what it measured. Code:
+`src/core/HardwareProfile.*` (probe types, mapping, cache, JSON, commands), `src/core/TierConfig.*` (the knobs other
+modules read), `src/core/FrameGovernor.*` (run-time adaptation), `src/app/Calibration.*` (OpenGL probe and GPU
+benchmarks, `--calibrate`), `src/app/PanelPerformanceProfile.cpp` (first-launch flow, Preferences > Performance).
+Nothing in it uses the network.
+
+### When it runs
+
+On first launch, and again when `GL_VENDOR`, `GL_RENDERER` or `GL_VERSION` (which carries the driver version)
+or the app version changes, or when the cache holds only a CPU calibration from `sculptforge-cli`. The result
+is cached in `<settings folder>/hardware_profile.json` (Linux `~/.local/share/SculptForge/SculptForge/`, macOS
+`~/Library/Application Support/SculptForge/SculptForge/`, Windows `%APPDATA%\SculptForge\SculptForge\`). In the
+app it runs over the first frames, one step per frame under a small overlay (Esc or Skip skips it; the profile
+then comes from the probe alone). UI tests, renders, recordings, demos and the `--measure-*` runs never
+calibrate and keep the fixed defaults (Fast Navigation at 10 million triangles), so their results don't depend
+on the machine. `SF_NO_CALIBRATION=1` skips it too.
+
+```
+sculptforge --calibrate [--calibrate-quick] [--calibrate-no-save] # prints JSON (schema sculptforge.calibration/1)
+sculptforge-cli -c 'calibrate' # CPU half only (no OpenGL); GPU numbers from the cache
+sculptforge-cli -c 'performance_profile' # the cached profile as JSON
+sculptforge-cli -c 'set_performance_override name=render_triangle_budget value=12000000' # value=auto clears
+```
+
+The same three commands are in the command registry, so the console, scripts and MCP clients have them; in the
+app `calibrate` measures the GPU too.
+
+### What it probes
+
+| | How |
+|---|---|
+| GPU | `GL_VENDOR`, `GL_RENDERER`, `GL_VERSION`, `GL_MAX_TEXTURE_SIZE`, timer queries (`GL_TIME_ELAPSED`) |
+| Memory type | Software (llvmpipe, softpipe, SwiftShader, GDI Generic, Microsoft Basic Render), unified (Apple GPUs on macOS and Asahi), integrated or discrete, from the renderer string, refined by `GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA` / `..._ACCELERATED_MESA` where available. Only the memory type comes from names; tiers come from measurements and memory sizes |
+| Video memory | the first that answers: `GL_NVX_gpu_memory_info` (NVIDIA; Mesa's radeonsi and asahi too), `GL_ATI_meminfo` (free memory only), `GLX_MESA_query_renderer` (Mesa on X11), amdgpu's `mem_info_vram_total` in sysfs (Linux, also on Wayland), DXGI (Windows), CGL (macOS). Unified memory counts at most two thirds of the RAM (Metal's working set), whatever the driver reports |
+| Machine | RAM, hardware threads, SIMD (SSE4.2 / AVX2 / AVX-512 on x86, NEON / SVE on ARM) and what the build uses, OS, CPU brand (x86 cpuid, macOS sysctl, the device tree on ARM Linux) |
+
+### What it measures (about 0.5-1.5 s of work; medians of 5 runs, 3 quick)
+
+| Measurement | Work |
+|---|---|
+| Triangle throughput | a 512 x 256 quad grid (262k triangles, about 4 pixels each, like a whole sculpt on screen) drawn instanced into a 1024 x 1024 offscreen target, every instance in front of the last; the instance count is chosen for about 25 ms a run; GL timer queries, else glFinish around the CPU clock |
+| Upload bandwidth | `glBufferSubData` of a 32 MB buffer, waited for (glFinish) |
+| Brush dab | 20 Standard dabs (X symmetry, radius 0.12) on a generated 1M-triangle sphere, undone between runs |
+| Memory bandwidth | `memcpy` of 64 MB |
+
+### Profiles
+
+Two main tiers and a safe mode:
+
+- **Workstation**: a discrete GPU with 16 GB or more (15 GB reported), 64 GB or more of RAM (60 GB reported),
+ at least 1000M triangles/s, dabs under 3 ms, memory over 4 GB/s.
+- **Laptop / Budget**: everything else, including Apple Silicon and other unified memory machines (8-16 GB RAM,
+ 2-4 GB GPUs, thermal and battery limits).
+- **Software** (safe mode): a software renderer, or under 60M triangles/s.
+
+A re-calibration of the same GPU keeps the previous tier while the new triangle throughput is within 15% of the
+boundary, so a busy machine doesn't flip between tiers. Settings, before overrides:
+
+| Setting | How |
+|---|---|
+| `render_triangle_budget` | half a 60 Hz frame of the measured throughput, clamped per tier (Software 0.25-4M, Laptop 2-40M, Workstation 8-600M) |
+| `motion_proxy_threshold` | the budget (at least 262k): scenes over it draw the motion proxy while the view moves |
+| `vram_budget_mb` | 80% of dedicated memory; unified: two thirds of RAM; integrated: half of RAM; software: a quarter |
+| `upload_budget_mb_per_frame` | a quarter of a 60 Hz frame at the measured upload bandwidth (4-1024 MB) |
+| `max_texture_size` | the GL limit, at most 4096 / 8192 / 16384 by tier, 8192 under 2 GB of GPU memory |
+| `max_subdivision_triangles` | the smaller of half the RAM at 100 bytes per triangle and the GPU budget at 16 bytes per triangle, capped by tier |
+| `micro_triangle_limit` | a quarter of the GPU budget at 8 bytes per micro-triangle, capped by tier |
+| `threads` | hardware threads (at most 16, the pool's limit); half in safe mode, where llvmpipe draws on the same cores. Applies at the next start |
+| `target_fps` | 60, 120 or 144 from the display (`TierConfig::targetHz`) |
+
+Every setting can be overridden by hand (Preferences > Performance > Manual overrides, or `set_performance_override`),
+and overrides survive re-calibration.
+
+### TierConfig (core/TierConfig.h)
+
+What feat/micromesh and feat/zero-latency read, through `currentTierConfig()` (thread-safe; `tierConfigRevision()`
+changes when it does):
+
+| Field | Software | Laptop / Budget | Workstation |
+|---|---|---|---|
+| `residentCacheCapMB` | RAM / 8, at most 1 GB | RAM / 4, at most 4 GB | RAM x 2/5, at most 64 GB |
+| `activeTriangleBudget` | 0.5M | 2M | 8M+ (half the render budget, at most 64M) |
+| `uploadBudgetMBPerFrame` | the profile's | the profile's | the profile's |
+| `draftBrushMode` (normals and cavity at pen release) | on | on | off (continuous) |
+| `zeroCopyUMA` | the GPU shares system memory: unified or integrated | | |
+| `targetHz` | 60 | 60 / 120 / 144 from the display | 60 / 120 / 144 from the display |
+
+The app reads the power source with `SDL_GetPowerInfo` at start and every 5 seconds. On battery: draft brushes,
+half the upload budget and 60 Hz (unless set by hand), and the status bar says so. The `draft_brush` override
+(on / off) wins over both. `draftBrushMode` is a flag for the brush engine; the brushes don't read it yet.
+
+### Render triangle budget and the frame governor
+
+`renderTriangleBudget()` (core/HardwareProfile.h) is the number of triangles the 3D view may draw per frame to
+hold the target frame rate; `motionProxyThreshold()` is where Fast Navigation switches big scenes to their
+motion proxy. The frame governor (core/FrameGovernor.h) adjusts both from real frames:
+
+- Inputs per drawn frame: CPU time from input to swap (without the vsync wait), GPU time from a `GL_TIME_ELAPSED`
+ query read up to 4 frames later (never waiting), triangles drawn, the scene's full triangle count, whether
+ the view is moving and whether the proxy was used. Only moving frames count: still frames draw everything in
+ full and the governor can't change them. Frames over 250 ms (dialogs, loading) are ignored.
+- Every 20 counted frames it takes the medians. Above the target frame time it lowers the budget (aiming at 80%
+ of the frame, at most halving it); under 60% it raises it (at most 1.25x) when the budget is what limits the
+ view. In between it holds (the dead band). After a change, 5 frames are ignored.
+- Raising the budget past the scene's size would switch the proxy off; it only does when the predicted full
+ frame stays under 90% of the target, so the view never flips between proxy and full detail.
+- Bounds: an eighth to four times the profile's budget. It changes only how much is drawn, never the mesh.
+
+Today's renderer uses the governed threshold for the motion proxy (Preferences > Performance > Fast Navigation;
+`SF_FAST_NAVIGATION_TRIANGLES` still overrides it for tests).
+
+**How micromesh consumes it:** read `renderTriangleBudget()` once per frame (an atomic load) and amplify
+micro-displacement only until the frame's drawn triangles reach it, finest where the screen-space error is
+largest; keep the generated micro-triangles under `currentPerformanceSettings().microTriangleLimit` and their
+pages under `currentTierConfig().residentCacheCapMB`. Report the triangles actually drawn through
+`Renderer::lastDrawnTriangles()` so the governor sees them; it then raises or lowers the budget continuously
+(continuous level of detail converges without the proxy's step, see the `governor_converges_*` tests).
+
+### This machine
+
+Apple M1 Pro under Asahi Linux, on battery, with about 35 other processes compiling (load average 35 on 10
+cores), so the CPU numbers here are low (memory bandwidth measured 23 GB/s on a quieter run, dabs 0.07 ms on a
+0.2M sphere):
+
+```
+"gl_renderer": "Apple M1 Pro (G13S C0)", "gl_version": "4.6 (Core Profile) Mesa 26.1.8", "gpu_kind": "unified",
+"vram_mb": 31667 (GL_NVX_gpu_memory_info: all of the RAM), "timer_query": true, "cpu_threads": 10, "simd": ["neon"]
+measurements: 1358M triangles/s (GPU timer), upload 12.8 GB/s, dab 0.37 ms (2.5k vertices), memory 5.9 GB/s, 607 ms
+profile: Laptop ("Detected Apple M1 Pro (G13S C0), 20.6 GB unified -> Laptop (1358M triangles/s, Laptop / Budget:
+ no discrete GPU (unified))")
+settings: render budget 11.3M, motion proxy from 11.3M, GPU memory 20.6 GB, uploads 50 MB/frame, textures 8192,
+ subdivision 120M, micro-triangles 256M, 10 threads, 60 fps
+tier_config: cache 4 GB, active 2M, uploads 25 MB/frame (battery), draft brushes, zero-copy UMA, 60 Hz, on battery
+```
+
+Across runs on the busy machine the triangle throughput ranged 913-1410M/s and upload 4.3-21 GB/s.
+
## Next version: big brushes on dense meshes (feat/perf-pass)
What a user feels on a heavy model is a large brush: how far it trails the pointer, how long a frame takes, and
diff --git a/src/app/PanelPerformance.cpp b/src/app/PanelPerformance.cpp
index 1f886414..828f22ad 100644
--- a/src/app/PanelPerformance.cpp
+++ b/src/app/PanelPerformance.cpp
@@ -75,8 +75,9 @@ void App::registerPerformanceUiActions() {
status_ = uiPrefs_.fastNavigation ? "Fast Navigation on" : "Fast Navigation off";
},
[this] { return uiPrefs_.fastNavigation; },
- "While you rotate, pan or zoom a scene of 10 million triangles or more, draw it without antialiasing, so the "
- "view keeps up; it is smooth again as soon as the view stops.");
+ "While you rotate, pan or zoom a big scene (over the hardware profile's motion proxy threshold, which the "
+ "frame governor adjusts; 10 million triangles without a profile), draw a lighter version without "
+ "antialiasing, so the view keeps up; it is full detail again as soon as the view stops.");
add("perf.multithreading", "Multithreading",
[this] {
uiPrefs_.multithreading = ThreadPool::shared().serial();