1# llimphi-surface
2
3External surfaces inside the Elm loop.
4
5An `ExternalSurface` is an RGBA8 texture living on the GPU, painted over a rect
6of the Llimphi frame every time the app exposes it through
7`View::gpu_paint_with`. The byte source runs outside the Elm loop: a video
8decoder, a camera capture, a PDF raster, a raw texture produced by another engine
9— any producer generating RGBA can push frames with `ExternalSurface::upload` and
10see the result on the next raster pass.
11
12The crate provides:
13
14- `ExternalSurface`: owner of the texture + render pipeline + bind group.
15 `upload(rgba, w, h)` uploads bytes and recreates the texture if `w`/`h` changed.
16- `ExternalSurface::view`: a helper that builds a `View` with `gpu_paint_with`
17 already wired. The app only chooses the node's `Style` (which portion of the
18 layout it occupies).
19
20## Design
21
22The pipeline is a classic textured quad: two triangles cover the destination
23rect, and the fragment shader samples the external texture with a bilinear
24sampler. The quad's NDC coordinates are computed on the GPU from
25`(rect, viewport)` travelling through a uniform — which is why the callback needs
26the `viewport` that `llimphi-ui` began propagating in `GpuPaintFn`.
27
28The intermediate texture Llimphi paints vello into is `Rgba8Unorm` (see
29`llimphi-hal::INTERMEDIATE_FORMAT`). The pipeline emits `Rgba8Unorm` too — the
30render pass target is that same intermediate with `LoadOp::Load`, so the vello
31background is preserved.
32
33---
34
35Part of **llimphi** — see [llimphi](../README.md).
README.md
llimphi-surface
External surfaces inside the Elm loop.
An ExternalSurface is an RGBA8 texture living on the GPU, painted over a rect
of the Llimphi frame every time the app exposes it through
View::gpu_paint_with. The byte source runs outside the Elm loop: a video
decoder, a camera capture, a PDF raster, a raw texture produced by another engine
— any producer generating RGBA can push frames with ExternalSurface::upload and
see the result on the next raster pass.
The crate provides:
ExternalSurface: owner of the texture + render pipeline + bind group.
upload(rgba, w, h) uploads bytes and recreates the texture if w/h changed.
ExternalSurface::view: a helper that builds a View with gpu_paint_with
already wired. The app only chooses the node's Style (which portion of the
layout it occupies).
Design
The pipeline is a classic textured quad: two triangles cover the destination
rect, and the fragment shader samples the external texture with a bilinear
sampler. The quad's NDC coordinates are computed on the GPU from
(rect, viewport) travelling through a uniform — which is why the callback needs
the viewport that llimphi-ui began propagating in GpuPaintFn.
The intermediate texture Llimphi paints vello into is Rgba8Unorm (see
llimphi-hal::INTERMEDIATE_FORMAT). The pipeline emits Rgba8Unorm too — the
render pass target is that same intermediate with LoadOp::Load, so the vello
background is preserved.
Part of llimphi — see llimphi.