Draw in the host: the wasm compositor sends draw ops, the host rasterises natively
CI / test (push) Failing after 29s
CI / test (push) Failing after 29s
The wasm software renderer cost ~10-20 ns/pixel, so any changed frame took ~100+ ms at 1080p and the desktop swung between idle and very slow. The compositor still builds the scene (windows, decorations, panel, wallpaper) but a new moonplasma:host/raster interface turns it into pixels in the host: - host-wasm/src/raster.rs: a port of compositor/renderer (same blend arithmetic: fills, strokes, lines, circles, text, clips, shadows, surface blits), a wallpaper+desktop-card cache, and captured client surfaces (copied out of the shared memory once at commit, converted to RGBA, solid ones blit as row copies). 9 unit tests; a full frame matches the native software renderer except for text antialiasing (0.3% of pixels). - compositor/raster sends a SceneGraph as ops; compositor.compose_scene() returns it only when something changed. The login session shows the host framebuffer directly (display.present-frame), the nested window gets it as a memfd (raster.export-memfd), --gfx-out reads it (read-frame). - Client buffers never enter wasm: snapshot_shm_buffer captures in the host and keeps an id. - Loop pacing sleeps the rest of the frame budget instead of a fixed 16/8 ms. Full-screen terminal flooding output at 1080p: ~2 fps / 94% CPU -> ~57 fps; idle ~9%. The native build keeps the software renderer. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
66bf293085
commit
c6e31b4a8f
38 files changed
+2141
-220
No files matched your search
@@ -0,0 +1,62 @@
|
||||
package moonplasma:host@0.1.0;
|
||||
|
||||
/// Drawing done by the host. The compositor component decides what the screen shows (windows,
|
||||
/// panel, wallpaper, decorations) and sends it as a list of draw operations; the host keeps the
|
||||
/// framebuffer and does the pixel work natively, so no pixels cross the component boundary. Client
|
||||
/// window buffers are captured here too (a native copy out of the client's shared memory), and the
|
||||
/// component only holds their ids.
|
||||
interface raster {
|
||||
record rect { x: s32, y: s32, w: s32, h: s32 }
|
||||
record color { r: u8, g: u8, b: u8, a: u8 }
|
||||
record fill { area: rect, color: color, radius: s32 }
|
||||
record stroke { area: rect, color: color, width: s32, radius: s32 }
|
||||
record segment { x0: s32, y0: s32, x1: s32, y1: s32, color: color, width: s32 }
|
||||
record disc { cx: s32, cy: s32, radius: s32, color: color, filled: bool }
|
||||
/// `align`: 0 left, 1 centre, 2 right of `x`; `y` is the text's vertical centre.
|
||||
record label { x: s32, y: s32, text: string, size: s32, color: color, align: u8, bold: bool, mono: bool }
|
||||
variant op {
|
||||
fill-rect(fill),
|
||||
stroke-rect(stroke),
|
||||
draw-line(segment),
|
||||
draw-circle(disc),
|
||||
draw-text(label),
|
||||
push-clip(rect),
|
||||
pop-clip,
|
||||
}
|
||||
|
||||
/// A toplevel: its decoration (drawn at `geometry` minus the insets), then its client surface.
|
||||
record window {
|
||||
geometry: rect,
|
||||
inset-top: s32,
|
||||
inset-right: s32,
|
||||
inset-bottom: s32,
|
||||
inset-left: s32,
|
||||
deco: list<op>,
|
||||
fullscreen: bool,
|
||||
/// A surface id from `capture`; 0 when the client has not committed a buffer.
|
||||
surface: u32,
|
||||
}
|
||||
record popup { area: rect, surface: u32 }
|
||||
record frame {
|
||||
width: s32,
|
||||
height: s32,
|
||||
/// The static backdrop (wallpaper and desktop card); none means "unchanged since the last submit" (the host keeps its pixels).
|
||||
wallpaper: option<list<op>>,
|
||||
background: list<op>,
|
||||
windows: list<window>,
|
||||
panel: list<op>,
|
||||
popups: list<popup>,
|
||||
}
|
||||
|
||||
/// Copy a client buffer (`stride * height` bytes at `offset` of the file behind `fd`) into a
|
||||
/// host surface. `format` is the wl_shm format (0 ARGB8888, 1 XRGB8888). 0 on failure.
|
||||
capture: func(fd: s32, offset: s32, stride: s32, width: s32, height: s32, format: s32) -> u32;
|
||||
release: func(id: u32);
|
||||
/// Draw a frame into the host framebuffer.
|
||||
submit: func(f: frame);
|
||||
/// The framebuffer as RGBA8888 (for screenshots and tests; the display path never needs it).
|
||||
read-frame: func() -> list<u8>;
|
||||
/// A new memfd holding the framebuffer as little-endian ARGB8888, ready to hand to a Wayland
|
||||
/// compositor as a wl_shm pool. The caller closes it. -1 on failure.
|
||||
export-memfd: func() -> s32;
|
||||
}
|
||||
Reference in new issue
Block a user