r/webgpu • • 19d ago

PeerBrush: partial texture updates for a desktop paint canvas with Rust and wgpu

Post image

PeerBrush is a GPLv3 desktop painting app built in Rust with egui and wgpu. One detail that may be useful if you’re building an interactive raster canvas: when a brush preview returns a dirty rectangle, the UI copies just those RGBA rows into a tightly packed buffer and calls TextureHandle::set_partial at the rectangle’s origin. If the canvas size changes or there’s no usable rectangle, it falls back to a full texture update.

The upload optimization sits on the display side. The editor still keeps the current preview pixels, and it commits the brush gesture to undo history when the gesture ends. The demo shows the result in the actual editor, including the optional MCP workflow.

I’d be interested in how other wgpu editors handle this tradeoff for sparse strokes: a single dirty rectangle, a set of smaller tiles, or something else?

Source: https://github.com/Deftr0y/PeerBrush

63-second demo: https://peerbrush.com/assets/peerbrush-trailer-v2.1.mp4

Disclosure: posted on behalf of PeerBrush. The project and this write-up used AI assistance.

Workspace screenshot: https://peerbrush.com/assets/showcase/workspace-golden-hour.webp

0 Upvotes

0 comments sorted by