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.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Perf moonshots for 0.11.0-beta.1: merge main, Fast Upload toggle, Live Move preview in UI tests, note fragment
islandmed5213523eff1f
diff --cc changes/perf-moonshots.mdindex 00000000,00000000..70dcb1benew file mode 100644--- /dev/null+++ b/changes/perf-moonshots.md@@@ -1,0 -1,0 +1,38 @@@++---++highlight: Experimental: Live Move and Background Preview for very dense meshes++whats_new: **Live Move (experimental)**: **Preferences > Performance > Live Move**. The graphics card draws the++ Move brush's drag from where the surface started, so it keeps up with the pen on any mesh size, and the move is++ applied once, exactly, when you lift the pen ([Performance](performance.md)).++whats_new: **Background Preview (experimental)**: **Preferences > Performance > Background Preview**. On dense++ meshes, the dabs a big brush is still working out show as a preview under the pen, so the stroke no longer trails++ behind it. The finished sculpt is the same either way.++whats_new: **Fast Upload (experimental)**: **Preferences > Performance > Fast Upload**. Sculpted changes reach the++ graphics card through shared memory and a copy on the card, instead of a copy by the driver during the frame.++added: Experimental toggles in Preferences > Performance, all off by default. **Live Move**: the GPU draws a++ Move drag from the grab's start positions and the whole move is applied once at pen lift (one grab, equal to the++ per-frame grabs to 1e-6). It falls back to the normal Move with masks, hidden faces, sculpt layers, micro levels,++ Connected Only or View falloff (`SF_LIVE_MOVE=0/1`). **Background Preview**: the predictive preview is drawn for++ background dabs (meshes of 2M+ vertices), and the frame no longer waits for a batch; the solver's dabs are++ unchanged (`SF_BG_GHOST=0/1`). **Fast Upload**: stroke uploads are packed into persistently mapped staging++ buffers (GL_ARB_buffer_storage) and copied on the GPU (`SF_PERSISTENT_UPLOAD=0/1`). The research behind them,++ including a design for focus detail on billion-polygon assets, is in docs/design/perf-moonshots.md.++testers:++ - Any OS, Live Move: Preferences > Performance > Live Move (Experimental) on. Open Help > Benchmark's dense++ head, or any model over 10M triangles. Drag the Move brush big and fast. Good: the bulge follows the pen++ smoothly with no stutter, and when you lift the pen the shape stays exactly where the preview left it (no jump++ or flicker). Then Ctrl+Z / Ctrl+Shift+Z restores and redoes it in one step.++ - Any OS, Live Move with X symmetry on: both sides move in the preview and stay the same after the pen lifts.++ With a mask, a hidden part, a sculpt layer or a micro level, Move works exactly as it does with the toggle off.++ - Windows (tablet): Live Move with pen pressure and a fast flick. Good: no lag behind the pen, and no gap or++ dent where the drag ended.++ - Any OS, Background Preview: Preferences > Performance > Background Preview (Experimental) on. Use Clay or++ Standard at 200-300 px on a model of 15M+ triangles. Good: the stroke stays under the pen instead of trailing,++ lifting the pen is instant, and the result looks the same as the same stroke with the toggle off.++ - Any OS, Fast Upload: Preferences > Performance > Fast Upload (Experimental) on, then sculpt on a dense model.++ Good: nothing looks different (no flicker, holes, stale patches or black triangles), and strokes feel as fast++ or faster. macOS and older Intel drivers may lack the OpenGL feature; there it simply does nothing. Report your++ GPU and driver either way.++---++Research prototypes from docs/design/perf-moonshots.md (ideas 1-8). All three toggles are off by default; the++strokes they commit match the toggles-off result (tests/ui/live_move.sfui, ui_stroke_background_preview,++ui_stroke_persistent_upload with SF_MEASURE_VERIFY).diff --cc docs/design/perf-moonshots.mdindex 922277fb,00000000..3cec8bb8mode 100644,000000..100644--- a/docs/design/perf-moonshots.md+++ b/docs/design/perf-moonshots.md@@@ -1,192 -1,0 +1,212 @@@+# Performance moonshots: sculpting that costs pixels, not polygons++Research branch `research/perf-moonshots` (2026-11-01). Goal: the cost of a stroke grows with the pixels on screen+and the brush footprint, never with the total polygon count. This note surveys recent work, rates eight ideas,+reports three prototypes measured with `--benchmark standard-33m`, and recommends what to ship.++Starting point (Tony's clean 33M run, M1 Pro, Asahi, Mesa GL 4.6, unified memory): orbit 89 fps; Clay small p99+38 ms; Clay large p99 119 ms; 240 px brush p99 338 ms; Move 18 fps. The branch is built on `perf/bigbrush-p99`+(dabs of meshes from 2M vertices go to the solver thread without the preview), which already takes the stroke+p99s to about 30 ms; what it leaves is the surface trailing the pen (each 240 px dab at 33M still costs+100-200 ms of CPU) and Move, which never used the solver path.++## 1. What SculptForge already does (so the ideas below are measured against the right thing)++| Piece | Where | State |+|---|---|---|+| Solver thread for dabs, two-part upload (pack on the thread, `glBufferSubData` on the GL thread) | `app/AsyncStroke.cpp`, `Renderer::prepareStrokeUpload` | on (bigbrush: from 2M vertices) |+| GPU preview of the dabs not solved yet ("ghost"), analytic per brush kernel in the vertex shader, normals by forward differentiation | `render/Ghost.h`, `kMeshVS` GHOST | only with Predictive Strokes, which is **off** by default |+| Pen prediction: alpha-beta-gamma filter, 25 ms ahead | `core/PenPredictor.h` | with the ghost |+| Draft strokes: positions only, normals at pen lift | `Sculptor::draftStrokes` | off; measured no gain on M1 |+| Cluster culling + motion proxy | `render/Clusters.h` | on |+| Micro levels: 16-bit scalar height per point above the top level, evaluated in the vertex shader; stride-sampled brushes | `core/Micro.h`, `render/MicroRenderer.h` | on; 1.02B triangles in 1.7 GB RSS |+| Kelvinlet brushes (grab, twist, scale, snake) | `core/Kelvinlet.h` | on |++So "GPU preview from a dab list" (idea 1) and "quantized scalar displacement" (idea 6) exist already; the+question for them is where they are not used yet.++## 2. Research (2022-2026, plus the classics they build on)++**Micro-meshes and displacement micro-maps.** NVIDIA's micro-mesh primitive is a base mesh plus a compressed,+UV-free displacement per base face (11-bit scalars, four watertight levels), with hardware support on recent GPUs+for ray tracing [1]. Maggiordomo, Moreton and Tarini, *Micro-Mesh Construction* (SIGGRAPH 2023 / TOG 42(4)) build+them automatically from dense meshes with a base simplification tuned for tessellation and displacement sampling,+with an open reference implementation [2]. Our micro levels are the same idea (16-bit heights, barycentric grid+per base triangle) for editing rather than for ray tracing; [2]'s base-mesh simplification is relevant to+"Divide to micro" on scanned meshes.++**Cluster LOD / virtual geometry.** Nanite (Karis, Stubbe, Wihlidal, SIGGRAPH 2021 Advances [3]): ~128-triangle+clusters, a DAG of cluster groups simplified with locked group borders, LOD chosen per group by projected error,+visibility buffer and a software rasterizer for small triangles, streaming of pages. The 2021 design assumed rigid+meshes; UE 5.4 added tessellation with programmable displacement and UE 5.5 skinned Nanite meshes (deformed on+the GPU before culling) [4] (secondary sources; Epic's own notes should be checked before quoting).+NVIDIA's RTX Mega Geometry (2025) builds cluster acceleration structures, *cluster templates* (topology reused,+only vertices new), per-frame cluster tessellation of subdivision surfaces at about one triangle per pixel, and a+continuous cluster-LOD library [5]. The common lesson for an editor: keep topology-derived data (clusters, LOD+DAG, templates) fixed while vertices change, and rebuild only the cluster groups an edit touched.++**Sculpting engines.** Blender 4.3's sculpt refactor (2024) reports brushes about 8x faster and 30% less memory+on a 16M-face mesh, from data-oriented attribute arrays, a face (not triangle) BVH, removing per-element call+layers and writing deformation directly per symmetry pass [6]. That is the "make the CPU kernel lean" path; we+are already there in structure (flat arrays, parallel kernels); our remaining dab cost is proportional to the+vertices under the brush, which is the term this note attacks.++**Analytic deformers.** Regularized Kelvinlets (de Goes and James, SIGGRAPH 2017) give closed-form, volume-aware+grab/twist/scale/pinch brushes from regularized fundamental solutions of linear elasticity [7]; Dynamic+Kelvinlets (2018) and Sharp Kelvinlets (DigiPro 2019, multi-scale cusps) extend them [7]. Blender's Elastic Deform+and Unreal's modeling tools ship them. Key property for us: a closed-form displacement of the *start* position+is exactly what a vertex shader can evaluate; so are our Move and Standard kernels.++**Progressive refinement.** Hoppe's progressive meshes (SIGGRAPH 1996) and their GPU successors (cluster DAGs+above) refine coarse-to-fine by screen error. For editing, the exact final geometry is the constraint: coarse+first is useful as a *display* order, not as a different result.++**Zero-copy buffers.** `GL_ARB_buffer_storage` (core in 4.4) allows immutable storage that stays mapped while the+GPU uses it (`MAP_PERSISTENT`), with writes visible without flushes (`MAP_COHERENT`); it is the core of the+"Approaching Zero Driver Overhead" techniques (Everitt, McDonald et al., GDC 2014 [8]). It does not remove+synchronisation: the application must fence what the GPU may still read [8].++**Pen-latency prediction.** Henze et al. (MobileHCI 2016/2017) extrapolate touch with small neural networks;+predicting 33 ms ahead improved task performance, beyond that it did not [9]. A GRU-CNN stylus predictor+(Samsung Research, HCII 2020) reports 0.07/0.24/0.47 mm error at ~16/33/50 ms, several times below LSTM+baselines [10]. TurboTouch (UIST 2018) uses finite-time derivative estimation and predicts 2-3x further with few+side effects [11]. Our alpha-beta-gamma filter is the classical baseline these improve on.++**What the Asahi driver offers (checked on this machine).** Mesa 26.1.8 reports OpenGL 4.6 core with+`GL_ARB_buffer_storage`, `GL_ARB_compute_shader`, `GL_ARB_shader_storage_buffer_object`,+`GL_ARB_multi_draw_indirect`, `GL_ARB_indirect_parameters` and `GL_ARB_shader_draw_parameters` (glxinfo). The+Asahi drivers are conformant for OpenGL 4.6, OpenGL ES 3.2, OpenCL 3.0 and Vulkan 1.4 (Honeykrisp, in Mesa since+24.3); the hardware has no geometry or tessellation shaders, which the driver emulates with compute [12]+(so our texture-painting geometry shader is a compute pass on this GPU). No source says Honeykrisp exposes+`VK_EXT_mesh_shader`, and `vulkaninfo` is not installed here; treat mesh shaders as unavailable. GPU-driven+culling therefore means compute + multi-draw-indirect, which the driver has.++## 3. How ZBrush does it (publicly documented approaches only)++From Maxon's documentation and public material only (no binaries inspected):+(a) **2.5D pixol canvas**: ZBrush has "a 2.5D canvas document", not a 3D scene; a pixol is a pixel with depth,+orientation and material [13]. The heritage is a CPU renderer whose cost follows pixels.+(b) **Subdivision levels**: the classic multires stack (ours: subdivision levels).+(c) **HD Geometry**: DivideHD adds levels beyond the highest SDiv; Sculpt HD (the A hotkey) "selects an area of+your model around the current mouse position for high-definition sculpting", circular or square [14]; only that+region is at HD resolution while the rest stays at the regular top level.+(d) **Per-mesh caps**: Preferences > Mem > MaxPolyPerMesh limits polygons per mesh (in millions), with a separate+HD preview cap [15]; dense work is split into many objects, hidden ones costing little.++What it implies: their interactivity comes from bounding the *active* point count (cap per object, a local HD+region) on a CPU renderer. Our equivalents must bound the same thing with our own design: micro levels (bounded+bytes per triangle), a focus region (idea 8) and GPU drawing whose cost follows the screen.++## 4. Ideas, rated++Gain is for the 33M standard scene unless said; effort in agent-days; fit = how well it suits our engine.++| # | Idea | Expected gain | Risk | Effort | Fit |+|---|---|---|---|---|---|+| 1 | GPU stroke preview from the dab list, async commit | surface under the pen within a few px at any brush size (measured below); Move frame cost independent of the region | low: preview only, the solver's mesh is unchanged | 1-2 (exists; extend) | **high** |+| 2 | Coarse-first progressive dab application | none on the final mesh (same work); as a display order (visible clusters packed first) maybe 30-50% sooner visible surface on big symmetric brushes | medium: order changes must stay bit-identical | 2-3 | low once (1) is on: the preview already shows the result |+| 3 | Strokes as data (analytic fields, replay, re-tune, cheap undo) | undo of a 240 px stroke at 33M: tens of MB of positions -> ~10 KB of dabs; re-tune strength after the fact | high: Clay, Smooth, Flatten read the surface, so replay is sequential and as costly as the stroke; determinism across versions | 10+ | medium (Sculpt Timeline is the natural home) |+| 4 | Zero-copy persistent mapped buffers on unified memory | the GL thread's commit (2-10 ms per batch) -> a GPU copy command; measured below | low-medium: fences; not on macOS GL 4.1 (fallback kept) | 1 (prototyped) | medium |+| 5 | Cluster LOD with a per-cluster pixel budget (Nanite-style DAG on an editable mesh) | orbit cost bounded by screen (as micro levels already are: 3-4M triangles drawn at 299M, 8-9 ms); 33M orbit 89 -> ~110+ fps | high: cracks at group borders, rebuild the edited groups after each stroke | 10-15 | medium (compute + MDI available, no mesh shaders) |+| 6 | Quantized scalar displacement + GPU normals | memory 90 -> 1.25 B per triangle above the top level (micro levels, measured in docs/performance.md) | low (exists) | 2-3 to make it automatic ("Divide" past ~8M goes to a micro level) | **high** |+| 7 | Learned pen prediction | at most 1-3 px of the 1-4 px preview lag left; literature: no gain beyond 33 ms ahead [9] | medium: training data, per-device tuning | 3-5 | low |+| 8 | **Focus Detail** (below) | billion-triangle assets in a few GB of RAM and ~0.3-0.5 GB of GPU, editable locally at the speed of a 30-60M mesh | medium-high: streaming latency, seams between levels | 8-12 (data side started on `research/focus-detail`) | **high** |++### Idea 8: Focus Detail (our design)++The region under and near the brush is promoted to full micro resolution; everything else stays at a coarse+micro level (or compressed on disk), and the GPU draws each tile at its own level.++- **Data** (`core/FocusDetail`, branch `research/focus-detail`, in progress): micro tiles (one per base+ triangle) stored zstd-compressed in a tile file; a focus region (brush footprint plus a margin, plus what the+ view needs at one micro triangle per pixel) is decompressed to full level; tiles outside hold an upsampled coarse+ grid (level 3) so the MicroRenderer works unchanged today. Promotion and demotion `markDirty(tri)`; budget the+ promoted tiles by bytes (e.g. 512 MB) and demote least recently used.+- **GPU** (follow-up here): per-tile resident level. Coarse tiles keep 45 points (level 3) instead of 8385+ (level 7), drawn with the same vertex-shader evaluation at that level; the data side exposes+ `FocusDetail::tileLevel(tri)`. Edge stitching between a level-3 and a level-7 tile: snap the fine tile's edge+ points to the coarse edge (as micro levels already stitch shared edges).+- **What it enables, estimated** for 1.0B triangles (micro level 7 on 61K base triangles; 8385 points a tile):+ all tiles at full level are 511M points: 1.0 GB of heights on the CPU, ~3 GB on the GPU (2 B height + 4 B+ shading per point). With Focus Detail: coarse everywhere 2.7M points (16 MB GPU); a focus of ~2% of the tiles+ (a 240 px brush plus margin on a full figure) 1.2K tiles x 8385 points = 10M points (60 MB GPU, 20 MB CPU);+ compressed tile file perhaps 0.4-0.6 GB on disk (16-bit heights of sculpted detail compress 2-3x; to be+ measured). Dab cost depends on the points under the brush at full level, the same as on a 30-60M mesh today+ (docs/performance.md: Standard 64 px on 1.02B Micro 5 is 39 ms a step, 300 px 283 ms); drawing stays bounded+ by the screen. **A billion-triangle asset, editable locally at interactive rates on a 16 GB laptop**, is the+ claim to test; nothing here is measured yet, so no public claim until it is.+- **Measured on the data side** (`research/focus-detail` @ 6184559, docs/design/focus-detail.md §5.1; 1B+ triangles, shared machine, load ~4): promoting one tile 0.041 ms p50 / 0.051 ms p99, 65.5K tiles/s in parallel;+ RSS 1147 MB with the focus on against 1526 MB with every tile at full level; GPU memory (estimated) 3130 MB with+ today's renderer against 597 MB with per-tile resident levels (`FocusDetail::tileLevel(tri)` is in). So+ promotion is far below a frame (a few hundred tiles a frame while orbiting is ~10 ms on one thread, ~5 ms spread+ over the pool); the GPU side (per-tile levels in the MicroRenderer) is what turns the estimate into the 5x saving.+- **Difference from (c)**: the focus follows the brush automatically (no mode to enter), the coarse remainder is+ the same surface at a lower micro level (not a separate HD layer), and GPU memory follows focus + screen.++## 5. Prototypes (feature flags, off by default)+- All three are environment flags so they cost nothing when off. None changes what a stroke leaves on the mesh++All three are Experimental toggles in Preferences > Performance (Live Move, Background Preview, Fast Upload), off++by default, with environment overrides (`=0` / `=1`) for benchmarks; they cost nothing when off. None changes what a stroke leaves on the mesh+except Live Move's commit (one grab with the summed move instead of one per frame; tested equal to 1e-6).++1. **Background preview** (`SF_BG_GHOST=1`, idea 1): the ghost (already written for predictive strokes) also+ draws the dabs of bigbrush's background path, and the frame no longer waits 12.5 ms for a batch. The solver's+ dabs are unchanged (same dabs, same order), so the final mesh is identical by construction.+2. **Live Move** (`SF_LIVE_MOVE=1`, ideas 1 and 3): a Move drag is not applied frame by frame. The GPU draws it+ from the grab's start positions (`GhostKind::Move`: x0 + d w(|x0 - c|), normals by the rank-one inverse+ transpose), per symmetry mirror, and one `Sculptor::grab` with the whole move is applied when the stroke ends.+ Falls back to the old path with masks, hidden faces, sculpt layers, micro levels, connected-only or view+ falloff. Test `live_move_matches_the_grab`: the preview matches the grab to 1e-5, one grab matches the+ per-frame grabs to 1e-6 (X symmetry, focal shift).- 3. **Persistent upload** (`SF_PERSISTENT_UPLOAD=1`, idea 4): two persistently mapped, coherent staging buffers++3. **Persistent upload** (Fast Upload, `SF_PERSISTENT_UPLOAD=1`, idea 4): two persistently mapped, coherent staging buffers+ (48 MB each, `glBufferStorage`); the solver thread packs straight into one, the GL thread issues+ `glCopyBufferSubData` for each range and a fence; a buffer is reused only after its fence. Batches larger than+ 4M vertices pack into the old vector as before.++### Measurements+- MEASUREMENTS++Correctness (all in ctest): `live_move_matches_the_grab` (preview vs grab 1e-5, one grab vs per-frame grabs++1e-6); `ui_live_move` (the same drag with Live Move on and off moves the mesh by the same sum and maximum to 0.1%;++mid-drag the mesh is untouched and the GPU draws the move: screenshot `live_move_dragging` matches the committed++`live_move`; undo/redo); `ui_stroke_background_preview` and `ui_stroke_persistent_upload` (`SF_MEASURE_VERIFY=1`:++the background path's mesh is bit-identical to the plain path's with the preview and the persistent upload on).++++Speed: **not measured yet.** The before/after runs need the shared machine at load < 2 (`--benchmark standard`,++33M scene, toggles off vs each on vs all on, interleaved), and the load stayed between 7 and 20 through every++session of this work. Expected from the design, to be checked by those runs: Live Move's frame cost no longer++depends on the region moved (today Move at 33M is 18 fps); Background Preview takes the 12.5 ms batch wait out of++the frame; Fast Upload moves the GL thread's 2-10 ms commit copy to a GPU copy. No public numbers until measured.++## 6. Recommendation+- RECOMMENDATION++- **Ship now, Experimental, off by default (0.11.0-beta.1):** Live Move, Background Preview, Fast Upload. They are++ tested equal to the plain path, so the beta risk is in drawing (driver differences), which is what the++ #testers checklist asks about. Promote one to on-by-default only with the 33M numbers above and clean tester++ reports on Windows, Linux and macOS.++- **Build next:** Focus Detail's GPU side (per-tile resident levels in the MicroRenderer, idea 8): the data side's++ measurements (promotion 0.05 ms a tile, GPU 3130 -> 597 MB at 1B) make it the biggest lever toward++ billion-triangle assets. Then idea 6 made automatic (Divide past ~8M goes to a micro level).++- **Later or not at all:** cluster LOD (5) only if orbit at 33M+ stays below target after Focus Detail; strokes as++ data (3) belongs with the Sculpt Timeline; coarse-first (2) and learned prediction (7) don't pay once the++ preview is on.++## References++1. NVIDIA Research, *Micro-Mesh Construction* project page and micro-mesh format: https://research.nvidia.com/publication/2023-08_micro-mesh-construction+2. A. Maggiordomo, H. Moreton, M. Tarini, *Micro-Mesh Construction*, ACM TOG 42(4), SIGGRAPH 2023: https://micromesh.di.unimi.it/+3. B. Karis, R. Stubbe, G. Wihlidal, *Nanite: A Deep Dive*, SIGGRAPH 2021 Advances: https://advances.realtimerendering.com/s2021/Karis_Nanite_SIGGRAPH_Advances_2021_final.pdf+4. UE 5.4 Nanite tessellation (Puget Systems): https://www.pugetsystems.com/blog/2024/04/16/exploring-unreal-engine-5-4-whats-new-and-whats-next/ ; UE 5.5 skinned Nanite (secondary): https://wnhub.io/news/engines/item-45659+5. NVIDIA, *Fast Ray Tracing of Dynamic Scenes Using OptiX 9 and RTX Mega Geometry*: https://developer.nvidia.com/blog/fast-ray-tracing-of-dynamic-scenes-using-nvidia-optix-9-and-nvidia-rtx-mega-geometry ; Vulkan samples: https://developer.nvidia.com/blog/nvidia-rtx-mega-geometry-now-available-with-new-vulkan-samples+6. Blender developers, *This Summer's Sculpt Mode Refactor* (2024): https://code.blender.org/2024/11/this-summers-sculpt-mode-refactor/+7. F. de Goes, D. L. James, *Regularized Kelvinlets* (SIGGRAPH 2017): https://graphics.pixar.com/library/Kelvinlets ; *Sharp Kelvinlets* (DigiPro 2019): https://graphics.pixar.com/library/SharpKelvinlets+8. `ARB_buffer_storage` specification: https://developer.download.nvidia.com/opengl/specs/GL_ARB_buffer_storage.txt ; C. Everitt, J. McDonald, *Beyond Porting* (AZDO): https://www.ozone3d.net/dl/201401/NVIDIA_OpenGL_beyond_porting.pdf ; persistent mapping notes: https://cppstories.com/2015/01/persistent-mapped-buffers-in-opengl+9. N. Henze, H. V. Le, S. Mayer, V. Schwind, *Improving Software-Reduced Touchscreen Latency*, MobileHCI 2017: https://www.medien.informatik.uni-muenchen.de/pubdb/publications/pub/henze2017improving/henze2017improving.pdf+10. Samsung Research, *Active Stylus Input Latency Compensation on Touch Screen Mobile Devices* (HCII 2020): https://research.samsung.com/research-papers/Active-Stylus-Input-Latency-Compensation-on-Touch-Screen-Mobile-Devices+11. TurboTouch predictor (UIST 2018): https://github.com/LokiResearch/TurboTouchPredictor ; https://hal.archives-ouvertes.fr/hal-01893310+12. A. Rosenzweig, Asahi GPU driver status (OpenGL 4.6, Vulkan 1.4, geometry/tessellation emulation): https://rosenzweig.io/blog/asahi-gpu-part-n.html ; Honeykrisp in Mesa 24.3: https://www.phoronix.com/news/Apple-Vulkan-Driver-Mesa-24.3+13. Maxon ZBrush docs, *The Canvas Document* and *The Pixol*: https://help.maxon.net/zbr/en-us/Content/html/getting-started/basic-concepts/the-canvas-document/the-canvas-document.html ; https://help.maxon.net/zbr/en-us/Content/html/getting-started/basic-concepts/the-pixol/the-pixol.html+14. Maxon ZBrush docs, *Geometry HD*: https://help.maxon.net/zbr/en-us/Content/html/reference-guide/tool/polymesh/geometry-hd/geometry-hd.html+15. Maxon ZBrush docs, *Preferences > Mem*: https://help.maxon.net/zbr/en-us/Content/html/reference-guide/preferences/mem/mem.html++ZBrush is a trademark of Maxon; SculptForge is not affiliated with or endorsed by Maxon.diff --cc docs/guide/performance.mdindex fe4a5a4c,1bcb1e1f..030e785f--- a/docs/guide/performance.md+++ b/docs/guide/performance.md@@@ -40,8 -41,6 +41,9 @@@ Open **Preferences** and click **Perfor| **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 || **Predictive Strokes** | The brush is worked out on its own thread while the view keeps drawing at full speed. The dabs it hasn't finished show at once as a preview on the surface, and the brush cursor and the stroke's head are drawn where the pen is about to be, so on a heavy mesh the surface moves under the pen straight away and lifting the pen never waits. The finished sculpt is exactly the same as with it off. On by default (painting, masking, dynamic topology, Move, Tendril and the drag strokes work as before) || **Draft Strokes** | With Predictive Strokes: while you sculpt, the brush only moves the surface, the moved part is shaded from its facets, and the smooth shading, the cavities and the rest are worked out once when you lift the pen. Lighter on laptops and on battery. Inflate and the plane brushes use the surface's direction from the stroke's start, so the result can differ slightly from a full stroke. Off by default |+| **Live Move** (experimental) | The Move brush's drag is drawn by the graphics card from where the surface started, so it follows the pen at the view's frame rate on any mesh size; the move is applied once, exactly, when you lift the pen. Not with masks, hidden parts, sculpt layers, micro levels, Connected Only or View falloff (Move works as before there). Off by default |+| **Background Preview** (experimental) | On meshes of 2 million vertices or more a big brush is worked out on its own thread; with this on, the dabs still being worked out show as a preview under the pen. The finished sculpt is exactly the same either way. Off by default |++| **Fast Upload** (experimental) | While you sculpt, the changed part of the mesh goes to the graphics card through memory both can see and the card copies it into place, instead of the driver copying it during the frame. The sculpt and the view are exactly the same either way. Needs OpenGL 4.4 buffer storage (otherwise it does nothing). Off 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 |diff --cc src/app/App.cppindex 3aaf0c87,8176a49f..cb485f16--- a/src/app/App.cpp+++ b/src/app/App.cpp@@@ -458,6 -375,6 +375,7 @@@ int App::runUiTest(int w, int h, int fpImGui::LogFinish();ImGui::Render();updateMouseCursor();++ buildGhost(); // (the stroke preview, as run() draws it)prewarmTexturePaint(); // dense textured meshes: ready the area under the hovering Paint brush (PanelPbr.cpp)const auto syncStart = std::chrono::steady_clock::now();@@@ -1710,12 -1851,8 +1853,13 @@@ void App::beginStroke(float x, float yp.focal = focalShift_;p.connectedOnly = uiPrefs_.connectedOnly;p.viewFalloff = uiPrefs_.viewFalloff;+ grabPending_ = false;doc_.sculptor.beginGrab(doc_.mesh, doc_.bvh, p, symmetry_);+ liveMove_ = {};+ if (liveMoveEnabled() && !p.connectedOnly && !p.viewFalloff && !doc_.mesh.micro && !doc_.mesh.hasMask() &&+ !doc_.mesh.hasHidden() && doc_.mesh.layers.empty() && !doc_.sculptor.dyntopo.enabled &&+ &displayedMesh() == &doc_.mesh)+ liveMove_ = {true, p.center, glm::vec3(0.0f), p.radius, std::clamp(p.strength * 2.0f, 0.0f, 1.0f)};grabPlanePoint_ = grabLast_ = hit.position;beginAlongNormal(hit, p.radius);return;@@@ -1764,8 -1907,7 +1914,8 @@@ void App::strokeTo(float x, float y)const BrushRecipe* recipe = strokeRecipe();if (strokeBrush_ == BrushType::Move && !recipe && strokeSculpt_ && strokeAlongNormal_) {const glm::vec3 p = alongNormalTarget(x, y);- queueGrab(p - grabLast_);+ if (liveMove_.active) liveMove_.delta += p - grabLast_;- else doc_.sculptor.grab(doc_.mesh, doc_.bvh, p - grabLast_);++ else queueGrab(p - grabLast_);grabLast_ = p;return;}@@@ -1777,8 -1919,7 +1927,8 @@@if (std::abs(denom) < 1e-6f) return;float t = glm::dot(grabPlanePoint_ - origin, n) / denom;glm::vec3 p = origin + dir * t;- queueGrab(p - grabLast_);+ if (liveMove_.active) liveMove_.delta += p - grabLast_;- else doc_.sculptor.grab(doc_.mesh, doc_.bvh, p - grabLast_);++ else queueGrab(p - grabLast_);grabLast_ = p;return;}diff --cc src/app/App.hindex f18d62e5,a4a5ed30..13e4f4b4--- a/src/app/App.h+++ b/src/app/App.h@@@ -349,16 -370,9 +371,19 @@@ privateBrushType strokeBrush_ = BrushType::Standard;bool strokeInvert_ = false;glm::vec3 grabPlanePoint_{0.0f}, grabLast_{0.0f};+ // Live Move (Preferences > Performance, experimental; docs/design/perf-moonshots.md): a Move drag on a plain mesh+ // isn't applied frame by frame; the GPU draws it (render/Ghost.h, GhostKind::Move) from the grab's start, and+ // the whole move is applied once when the stroke ends (finishStrokeNow): one grab instead of one a frame.+ struct LiveMove {+ bool active = false;+ glm::vec3 center{0.0f}, delta{0.0f};+ float radius = 0.0f, scale = 0.0f;+ } liveMove_;+ bool liveMoveEnabled() const; // the Live Move preference (and SF_LIVE_MOVE)+ void commitLiveMove();+ bool grabPending_ = false; // Move: positions moved, normals and BVH not yet (queueGrab / flushGrab, once a frame)+ void queueGrab(const glm::vec3& delta);+ void flushGrab();// Along the normal (from the discussions): Move, Tendril, Elastic Tendril and KelvinGrab strokes that began with// the invert key held (Preferences > Input > Along the normal) slide along the average normal under the brush// at the press instead of the view plane. alongNormalTarget: where the cursor puts the grabbed point.diff --cc src/app/AsyncStroke.cppindex 36089b01,9d4c027c..0f117024--- a/src/app/AsyncStroke.cpp+++ b/src/app/AsyncStroke.cpp@@@ -272,7 -261,7 +272,8 @@@ void App::pumpStroke()s.view.radiusProbe = nullptr;s.view.settings = dabSettings();s.uploadId = doc_.activeSubtoolInfo().id;-- renderer_.bindStrokeUpload(s.uploadId, s.upload); // (the slot, found here: the thread doesn't walk the renderer's list)++ renderer_.setPersistentUpload(uiPrefs_.fastUpload);++ renderer_.bindStrokeUpload(s.uploadId, s.upload); // (the slot, found here: the thread doesn't walk the renderer's list)s.prepare = &displayedMesh() == &doc_.mesh;s.start();return;@@@ -300,6 -289,6 +301,7 @@@s.view.radiusProbe = strokeProbe_ ? &s.radiusProbe : nullptr;s.view.settings = dabSettings();s.uploadId = doc_.activeSubtoolInfo().id;++ renderer_.setPersistentUpload(uiPrefs_.fastUpload);renderer_.bindStrokeUpload(s.uploadId, s.upload); // (the slot, found here: the thread doesn't walk the renderer's list)s.prepare = &displayedMesh() == &doc_.mesh; // (a previewed LOD shows instead: nothing to pack)renderer_.setDraftNormals(doc_.sculptor.draftActive() ? s.uploadId : 0);diff --cc src/app/Config.cppindex 92ca2523,9a886dc6..93b08003--- a/src/app/Config.cpp+++ b/src/app/Config.cpp@@@ -100,8 -113,6 +113,9 @@@ Json toJson(const UiPrefs& p)j.set("multithreading", p.multithreading);j.set("predictiveStrokes", p.predictiveStrokes);j.set("draftStrokes", p.draftStrokes);+ j.set("liveMove", p.liveMove);+ j.set("backgroundPreview", p.backgroundPreview);++ j.set("fastUpload", p.fastUpload);j.set("dyntopoConstantDetail", p.dyntopoConstantDetail);j.set("flatShading", p.flatShading);j.set("viewportCursor", double(p.viewportCursor));@@@ -164,8 -191,6 +194,9 @@@ void fromJson(const Json& j, UiPrefs& pp.multithreading = j["multithreading"].asBool(p.multithreading);p.predictiveStrokes = j["predictiveStrokes"].asBool(p.predictiveStrokes);p.draftStrokes = j["draftStrokes"].asBool(p.draftStrokes);+ p.liveMove = j["liveMove"].asBool(p.liveMove);+ p.backgroundPreview = j["backgroundPreview"].asBool(p.backgroundPreview);++ p.fastUpload = j["fastUpload"].asBool(p.fastUpload);p.dyntopoConstantDetail = j["dyntopoConstantDetail"].asBool(p.dyntopoConstantDetail);p.flatShading = j["flatShading"].asBool(p.flatShading);p.viewportCursor = std::clamp(int(j["viewportCursor"].asNumber(p.viewportCursor)), 0, 1);diff --cc src/app/Config.hindex 7c473018,b3f2d1cb..cf4782bc--- a/src/app/Config.h+++ b/src/app/Config.h@@@ -85,11 -100,6 +100,13 @@@ struct UiPrefs// bounds of what they touched are worked out once, when the pen lifts (Sculptor::draftStrokes). Off by// default; meant for laptops and battery (a hardware tier will turn it on).bool draftStrokes = false;+ // Experimental (docs/design/perf-moonshots.md), off by default. Live Move: the GPU draws a Move drag and the+ // move is applied once when the pen lifts (SF_LIVE_MOVE=0 / 1 overrides). Background Preview: heavy meshes'- // background dabs draw the predictive preview too (SF_BG_GHOST=0 / 1 overrides).++ // background dabs draw the predictive preview too (SF_BG_GHOST=0 / 1 overrides). Fast Upload: stroke uploads++ // go through persistently mapped staging buffers and a GPU copy (SF_PERSISTENT_UPLOAD=0 / 1 overrides).+ bool liveMove = false;+ bool backgroundPreview = false;++ bool fastUpload = false;// Dynamic topology (Draw palette): false = the detail follows the brush size on screen (Sculptris Pro);// true = one detail size for the whole mesh.bool dyntopoConstantDetail = false;diff --cc src/app/I18nSpanish.cppindex 04041969,40feb506..8ed6fed2--- a/src/app/I18nSpanish.cpp+++ b/src/app/I18nSpanish.cpp@@@ -637,8 -665,6 +665,9 @@@ constexpr Entry kSpanish[] ={"Multithreading", "Multihilo"},{"Predictive Strokes", "Trazos predictivos"},{"Draft Strokes", "Trazos de borrador"},+ {"Live Move (Experimental)", "Mover en vivo (experimental)"},+ {"Background Preview (Experimental)", "Vista previa en segundo plano (experimental)"},++ {"Fast Upload (Experimental)", "Subida rápida (experimental)"},{"%d threads", "%d hilos"},{"Memory", "Memoria"},{"Hardware profile", "Perfil de hardware"},diff --cc src/app/PanelKelvinlet.cppindex 3fab2ad8,9aa1c1bc..7197808b--- a/src/app/PanelKelvinlet.cpp+++ b/src/app/PanelKelvinlet.cpp@@@ -141,6 -141,6 +141,7 @@@ bool App::kelvinPump()s.view.radiusProbe = nullptr;s.view.settings = dabSettings();s.uploadId = doc_.activeSubtoolInfo().id;++ renderer_.setPersistentUpload(uiPrefs_.fastUpload);renderer_.bindStrokeUpload(s.uploadId, s.upload);s.prepare = &displayedMesh() == &doc_.mesh;renderer_.setDraftNormals(doc_.sculptor.draftActive() ? s.uploadId : 0);diff --cc src/app/PanelPerformance.cppindex 42ef8edc,22c8fbc5..9de442a3--- a/src/app/PanelPerformance.cpp+++ b/src/app/PanelPerformance.cpp@@@ -99,25 -99,6 +99,34 @@@ void App::registerPerformanceUiActions("the dabs still being worked out as a preview on the surface, with the cursor and the stroke's head drawn ""where the pen is about to be. On a heavy mesh the surface moves under the pen at once and lifting the pen ""is instant. The finished sculpt is exactly the same either way.");+ add("perf.live_move", "Live Move (Experimental)",+ [this] {+ uiPrefs_.liveMove = !uiPrefs_.liveMove;+ status_ = uiPrefs_.liveMove ? "Live Move on" : "Live Move off";+ },+ [this] { return uiPrefs_.liveMove; },+ "Experimental. The Move brush's drag is drawn by the graphics card from where the surface started, so it "+ "follows the pen at the view's frame rate whatever the mesh size; the move itself is applied once, exactly, "+ "when you lift the pen. Not with masks, hidden parts, sculpt layers, micro levels, Connected Only or View "+ "falloff (Move works as before there).");+ add("perf.background_preview", "Background Preview (Experimental)",+ [this] {+ uiPrefs_.backgroundPreview = !uiPrefs_.backgroundPreview;+ status_ = uiPrefs_.backgroundPreview ? "Background preview on" : "Background preview off";+ },+ [this] { return uiPrefs_.backgroundPreview; },+ "Experimental. On meshes of 2 million vertices or more, big brushes are worked out on their own thread; "+ "with this on, the dabs still being worked out are shown as a preview on the surface (as Predictive "+ "Strokes does), so the stroke stays under the pen. The finished sculpt is exactly the same either way.");++ add("perf.fast_upload", "Fast Upload (Experimental)",++ [this] {++ uiPrefs_.fastUpload = !uiPrefs_.fastUpload;++ status_ = uiPrefs_.fastUpload ? "Fast upload on" : "Fast upload off";++ },++ [this] { return uiPrefs_.fastUpload; },++ "Experimental. While you sculpt, the changed part of the mesh goes to the graphics card through memory both "++ "can see, and the card copies it into place itself, instead of the driver copying it during the frame. The "++ "sculpt and the view are exactly the same either way; needs a driver with buffer storage (OpenGL 4.4).");add("perf.draft_strokes", "Draft Strokes",[this] {uiPrefs_.draftStrokes = !uiPrefs_.draftStrokes;@@@ -190,12 -177,6 +205,15 @@@ void App::drawPerformanceSection()bool draft = uiPrefs_.draftStrokes;if (ImGui::Checkbox(tr("Draft Strokes"), &draft)) actions_.find("perf.draft_strokes")->run();ui::HelpAction(*this, "perf.draft_strokes");+ bool liveMove = uiPrefs_.liveMove;+ if (ImGui::Checkbox(tr("Live Move (Experimental)"), &liveMove)) actions_.find("perf.live_move")->run();+ ui::HelpAction(*this, "perf.live_move");+ bool bgPreview = uiPrefs_.backgroundPreview;+ if (ImGui::Checkbox(tr("Background Preview (Experimental)"), &bgPreview)) actions_.find("perf.background_preview")->run();+ ui::HelpAction(*this, "perf.background_preview");++ bool fastUpload = uiPrefs_.fastUpload;++ if (ImGui::Checkbox(tr("Fast Upload (Experimental)"), &fastUpload)) actions_.find("perf.fast_upload")->run();++ ui::HelpAction(*this, "perf.fast_upload");// --- Threads ---bool threads = !ThreadPool::shared().serial();diff --cc src/app/UiTest.cppindex 6bf96c25,53005264..915d01b3--- a/src/app/UiTest.cpp+++ b/src/app/UiTest.cpp@@@ -390,8 -436,6 +436,10 @@@ double Demo::query(const std::string& nif (name == "view_samples") return double(app_.perf_.samplesWanted);if (name == "multithreading") return ThreadPool::shared().serial() ? 0.0 : 1.0;if (name == "predictive_strokes") return app_.predictiveStrokes() ? 1.0 : 0.0;+ if (name == "live_move") return app_.liveMoveEnabled() ? 1.0 : 0.0;+ if (name == "background_preview") return app_.uiPrefs_.backgroundPreview ? 1.0 : 0.0;++ if (name == "fast_upload") return app_.uiPrefs_.fastUpload ? 1.0 : 0.0;++ if (name == "live_move_active") return app_.liveMove_.active ? 1.0 : 0.0; // (a Move drag drawn by the GPU)if (name == "last_stroke_dabs") return double(app_.perf_.lastStroke.dabs);if (name == "texture_size") return hasTexture(m) ? double(m.texture->width) : 0.0;if (name == "paint_texture") return paintsTexture(m) ? 1.0 : 0.0;diff --cc src/render/Renderer.cppindex 7d90befc,2a4ed610..96a5c1a8--- a/src/render/Renderer.cpp+++ b/src/render/Renderer.cpp@@@ -3346,14 -3460,6 +3487,14 @@@ void Renderer::commitStrokeUpload(Strokvoid Renderer::setDraftNormals(uint32_t id) { draftId_ = id; }- bool Renderer::persistentUpload() {- static const bool on = [] {++bool Renderer::persistentUpload() const {++ static const int env = [] {+ const char* v = std::getenv("SF_PERSISTENT_UPLOAD");- return v && *v == '1' && gl::BufferStorage != nullptr;++ return v && *v ? (*v == '0' ? 0 : 1) : -1;+ }();- return on;++ return (env >= 0 ? env == 1 : persistentUpload_) && gl::BufferStorage != nullptr;+}+void Renderer::bindStrokeUpload(uint32_t id, StrokeUpload& up) {up.slot = nullptr;for (MeshSlot& s : slots_)diff --cc src/render/Renderer.hindex 422bce0c,e69ec29f..8ef00aa0--- a/src/render/Renderer.h+++ b/src/render/Renderer.h@@@ -201,6 -211,6 +220,7 @@@ public// GL thread, before handing `up` to another thread: finds SubTool id's slot (slots come and go on the GL// thread, e.g. thumbnails; the other thread uses this one, which stays put in the list).void bindStrokeUpload(uint32_t id, StrokeUpload& up);++ void setPersistentUpload(bool on) { persistentUpload_ = on; } // Fast Upload (Preferences > Performance, experimental)void commitStrokeUpload(StrokeUpload& up);// The stroke uploads gave the clusters they moved quick culling bounds (around their vertices' boxes, which// packing finds anyway, without the normal cone, so they are never culled as facing away); at the stroke's@@@ -256,14 -268,6 +278,15 @@@ privateGLuint viewFbo_ = 0, viewResolveFbo_ = 0, viewRb_[3] = {};int viewW_ = 0, viewH_ = 0, viewSamples_ = 0, viewFailed_ = 0;bool directView_ = false;+ struct Staging { // the persistent upload's buffers (StrokeUpload::stagingPtr), used in turn+ GLuint buffer = 0;+ void* ptr = nullptr;+ size_t cap = 0; // vertices+ GLsync fence = nullptr;+ } persist_[2];+ int stagingNext_ = 0;- static bool persistentUpload();++ bool persistentUpload_ = false; // setPersistentUpload++ bool persistentUpload() const; // the preference, SF_PERSISTENT_UPLOAD=0 / 1 overrides; needs GL_ARB_buffer_storageint captureW_ = 0, captureH_ = 0;GLuint emptyVao_ = 0;bool thumbnailPass_ = false; // draw(): transparent background, no gradient (renderMeshThumbnail)diff --cc tests/ui/live_move.sfuiindex 1b8eb2ba,00000000..58bb71b6mode 100644,000000..100644--- a/tests/ui/live_move.sfui+++ b/tests/ui/live_move.sfui@@@ -1,73 -1,0 +1,80 @@@+# Live Move (Preferences > Performance, experimental): the graphics card draws a Move drag and the move is applied+# once when the pen lifts. The same drag leaves the same surface as plain Move (one grab with the whole move is the+# sum of the per-frame grabs) and undo puts it back.+run ui_look look=classic layout=zbrush # written for the Classic look and the ZBrush-style palette bar and shelves+run new_sphere subdivisions=5+camera 0 0+click "Move##brush.move"+expect_value live_move == 0++# Plain Move.+snapshot+stroke 0.86 0.5 0.98 0.38+remember moved_sum plain+remember moved_max plainMax+expect_value moved_sum > 0+key ctrl+z+expect_value moved == 0++# Live Move on (Ctrl-hover help first).+click "Preferences##palette.preferences"+click "Performance##preferences.performance"+hold ctrl+hover "Live Move (Experimental)"+expect_help "lift the pen"+hover "Background Preview (Experimental)"+expect_help "exactly the same"+hold none+click "Live Move (Experimental)"+expect_value live_move == 1+expect_status "Live Move on"+click "Preferences##palette.preferences"++# The same drag: the same surface.+snapshot+stroke 0.86 0.5 0.98 0.38+expect_value moved_sum > $plain*0.999+expect_value moved_sum < $plain*1.001+expect_value moved_max > $plainMax*0.999+expect_value moved_max < $plainMax*1.001+shot live_move+key ctrl+z+expect_value moved == 0++# Mid-drag: the graphics card draws the move, the mesh itself hasn't moved yet; letting go applies it.+snapshot+stroke 0.86 0.5 0.98 0.38 0.6 hold+wait 0.3+expect_value moved == 0++expect_value live_move_active == 1+shot live_move_dragging+release+expect_value moved_sum > $plain*0.999+expect_value moved_sum < $plain*1.001+key ctrl+z+expect_value moved == 0++# Twice in a row, then both undone.+stroke 0.86 0.5 0.98 0.38+stroke 0.80 0.6 0.90 0.7+expect_value moved > 0+key ctrl+z+key ctrl+z+expect_value moved == 0+- # Background Preview: on and off again; Live Move off again.++# Background Preview and Fast Upload: on and off again; Live Move off again.+click "Preferences##palette.preferences" # (Performance stays open from before)+expect_value background_preview == 0+click "Background Preview (Experimental)"+expect_value background_preview == 1+click "Background Preview (Experimental)"+expect_value background_preview == 0++expect_value fast_upload == 0++click "Fast Upload (Experimental)"++expect_value fast_upload == 1++shot experimental_toggles++click "Fast Upload (Experimental)"++expect_value fast_upload == 0+click "Live Move (Experimental)"+expect_value live_move == 0+click "Preferences##palette.preferences"