Merge main: one linux-dmabuf, imported on the GPU or mapped without one
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
d478f58d9b
54 files changed
+1110
-376
No files matched your search
@@ -210,7 +210,7 @@ WASI-style, deny-by-default:
|
||||
| Option | What it is | Time-to-pixels | Fits the "everything is a component" goal | Main risks |
|
||||
|---|---|---|---|---|
|
||||
| **(a) Browser/Node host with jco** | components transpiled to JS+core wasm; host in JS; Canvas2D now, WebGPU later | **hours — done in M0** | components yes; host = JS runtime (large TCB: browser) | no real windows/devices; JS can't pre-empt a looping component; browser is not a desktop session |
|
||||
| **(b) Native host embedding wasmtime** | Rust host using `wasmtime::component` + `bindgen!`; software/GPU rendering into a window (winit/SDL) or DRM | days–weeks | best: small native TCB, fuel/epoch limits, real FS/net/devices | host is Rust, not MoonBit; wasmtime's C API cannot instantiate components with host imports as conveniently, so a MoonBit-native host via FFI is **unverified** and probably not worth it |
|
||||
| **(b) Native host embedding wasmtime** | MoonBit host (`wasmhost/`) linking the prebuilt wasmtime C API; software rendering into a window or DRM | days–weeks | best: small native TCB, fuel/epoch limits, real FS/net/devices | the C API has no bindgen: imports are hand-written handlers over dynamic values (done; a first Rust host on the wasmtime crate was dropped as slow to build and heavy on CPU) |
|
||||
| **(c) Nested compositor in an existing session** | (b) running as a window/Wayland client first, later a real compositor (smithay) hosting foreign Wayland apps | weeks–months | needed to run real apps | scope; Wayland/EGL/input details |
|
||||
|
||||
**Recommendation:** (a) for M0–M2 (done: it is the fastest way to prove the WIT
|
||||
@@ -265,7 +265,7 @@ Designed next (no WIT yet): `window-registry`/`wm-policy`/`decoration`, `search-
|
||||
| **M0** | Toolchain proof, WIT v0.1 (`widget`/`panel`/`shell`), host (Node+browser), 4 components, tests, CI, swap/theme/permission demos | **done (this PR)** |
|
||||
| M1 | `config-store` + `theme-provider` component; persisted settings; hot reload of `.wasm` on change; `text` interface (measure/fonts) and icon theme | next |
|
||||
| M2 | Move input routing + focus policy into the shell/WM component; more widgets (task manager stub, system tray, notifications toasts); `search-provider` + KRunner component | |
|
||||
| M3 | Native reference host: Rust + wasmtime (`bindgen!`), software rasteriser into a winit window, fuel/epoch limits, restart supervision; CI runs the *same* integration tests against both hosts | |
|
||||
| M3 | Native reference host: MoonBit + the wasmtime C API (`wasmhost/`), software rasteriser into a window, fuel/epoch limits, restart supervision; CI runs the *same* integration tests against both hosts | |
|
||||
| M4 | Window-manager world with synthetic windows (no real apps yet): stacking/tiling policies as swappable components, decorations, virtual desktops, activities | |
|
||||
| M5 | Nested compositor (smithay) hosting real Wayland clients; `buffer-surface` resource; GPU rasteriser | |
|
||||
| M6 | Settings (KCM-style) framework, notifications daemon bridge (D-Bus portal), tray (SNI bridge), clipboard, power/session | |
|
||||
@@ -274,7 +274,7 @@ Designed next (no WIT yet): `window-registry`/`wm-policy`/`decoration`, `search-
|
||||
|
||||
## 12. Open design questions (with recommendations)
|
||||
|
||||
1. **Host language/long-term host** — Rust+wasmtime native host vs trying to keep even the host in MoonBit. *Recommend Rust+wasmtime for M3; revisit MoonBit-native host only if wasmtime's C API gains full component embedding.* Resolved: the host is MoonBit (`wasmhost/`) on the wasmtime C API, whose component model support turned out to be enough; the Rust host was removed on 2026-11-26.
|
||||
1. **Host language/long-term host** — *Decided: MoonBit (`wasmhost/`) on the wasmtime C API, which does embed components. No Rust in the tree.*
|
||||
2. **Render-list vs textures** — *Recommend render-list as the default, `buffer-surface` resource only for non-vector content (§4).*
|
||||
3. **UI toolkit inside components** — adopt `moon-gpui` or a tiny immediate-mode helper (`lib/ui`)? *Recommend `lib/ui` until moon-gpui has a stable scene package and a flatten-to-draw-op adapter, then migrate widget internals; keep the WIT draw-op vocabulary as the stable boundary.*
|
||||
4. **Text and fonts** — host-provided shaping (`text` interface) vs components bundling a shaper. *Recommend host-provided: layout needs metrics from the same engine that rasterises.*
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ and `wasm-tools` wraps it into a component.
|
||||
| `wasm-tools component embed/new` (1.263.0) | works | `--encoding utf16` (MoonBit strings are UTF-16). |
|
||||
| `wasm-tools component targets` | works | Used as a **WIT conformance test**: asserts each component implements its declared world. |
|
||||
| `jco transpile` (1.42.0) | works | Component → JS + core wasm. Used for the M0 host. `--instantiation async` lets the host pass a *per-instance* import object, which is how capability grants work. |
|
||||
| `wasmtime` (51.0.0) | validates/compiles | `wasmtime compile` accepts every component. We do **not** run them under wasmtime yet: a component with host imports needs an embedder (Rust/C-API) to supply them — `wasmtime run` cannot. That is M4. |
|
||||
| `wasmtime` (51.0.0) | validates/compiles | `wasmtime compile` accepts every component. We do **not** run them under wasmtime yet: a component with host imports needs an embedder (now `wasmhost/`, MoonBit on the C API) to supply them — `wasmtime run` cannot. |
|
||||
| mooncakes packages | see below | Nothing needed at M0. |
|
||||
|
||||
### Pipeline
|
||||
|
||||
@@ -107,7 +107,7 @@ capability's `desktops`, `current-desktop` and `set-desktop` (`wit/capabilities.
|
||||
|
||||
`compositor/host/desktop_test.mbt`: choosing and listing, input routing (windows and the panel
|
||||
win, drags stay with the module), the right-click menu, resize, idle and animation pacing,
|
||||
reload, and screenshots (`_build/desktop_*.png`). Run with:
|
||||
and reload. Run with:
|
||||
|
||||
```
|
||||
scripts/test-native.py -p compositor/host desktop
|
||||
|
||||
+6
-5
@@ -21,7 +21,8 @@ At start the host looks for a GPU and logs it (or why there is none):
|
||||
part that changed is read back when one of them asks.
|
||||
- **Apps** (`compositor/wayland/dmabuf.mbt`): `zwp_linux_dmabuf_v1` version 4. Without it Mesa's EGL and
|
||||
Vulkan draw on the CPU whatever GPU there is. A committed buffer is copied on the GPU and
|
||||
released at once. Formats: 8-bit RGB with or without alpha, in every layout the driver samples.
|
||||
released at once. Formats: 8-bit RGB with or without alpha, in every layout the driver samples. A host that draws
|
||||
on the CPU takes only linear buffers, which it maps and copies.
|
||||
|
||||
Which GPU: the first render node whose driver is a real one (the list below), or the one
|
||||
`CHANDRA_RENDER_NODE` names. `CHANDRA_GPU=0`, `CHANDRA_RENDER=software` and `LIBGL_ALWAYS_SOFTWARE=1`
|
||||
@@ -38,10 +39,10 @@ when nested, recovering from a GPU reset, OpenGL ES 2 only GPUs (they use the CP
|
||||
`scripts/test-gpu.sh` (`just test-gpu`) compares both rasterisers on this machine's GPU and draws
|
||||
through real display buffers, without needing a free display.
|
||||
|
||||
On an HD 4600 (Haswell), 1920x1080, median time to rasterise a frame, CPU then GPU: the overview
|
||||
gliding with four windows 8 ms, 1 ms; a full-screen terminal scrolling 8 ms, 3 ms. alacritty (OpenGL)
|
||||
scrolling: 7 frames a second drawing in software, 42 on the GPU. vkcube (Vulkan) showed
|
||||
no frames at all without dmabufs, and 57 a second with them.
|
||||
On an HD 4600 (Haswell), 1920x1080: the overview gliding with four windows rasterises in 8 ms a frame
|
||||
on the CPU and 1 ms on the GPU (medians); a full-screen terminal scrolling in 5 ms and 2.5 ms. With
|
||||
a full-screen app drawing on the GPU at about 55 frames a second in both, the host's CPU use goes
|
||||
from 69 % to 42 % (vkcube) and from 75 % to 54 % (alacritty), PNG writes of the headless run included.
|
||||
|
||||
## Software or hardware mode
|
||||
|
||||
|
||||
@@ -76,7 +76,3 @@ overlay, rather than being a separate component window:
|
||||
52% for the same app on the desktop.
|
||||
- A picture saved unchanged is encoded by the host (`snapshot-png`), as before. An edited one is
|
||||
encoded with `@renderer.encode_png_compressed`.
|
||||
|
||||
Headless pictures of the editor: run the host tests with `CHANDRA_EDITOR_SHOTS=<folder>` set,
|
||||
and the test "editor: headless screenshots" writes `screenshot-editor.png` (the editor) and
|
||||
`screenshot-editor-saved.png` (what it would save) there.
|
||||
Reference in new issue
Block a user