Skip to content
heff

browser.gpu.canvas

A <canvas> of the page shown a GPU buffer’s pixels: where the DOM’s effect and the GPU’s meet. The canvas is an element browser.dom found or made, the host’s own, given by value; the device and the buffer are held by browser.gpu’s withs; all three are in scope inside the same withs, and the operation here takes them together. Import it by a name, import browser.gpu.canvas as Canvas.

Its provider is WebGPU’s, a page’s: the canvas is configured for the device, and the buffer copied into the canvas’s current texture.

CanvasF

data CanvasF (m : Type -> Type) x
= Present GPU.Device Element GPU.Buffer Int Int (Either GPU.GpuError Unit
-> x)

canvas

canvas : HFunctor

For a GPU buffer shown on a <canvas>, a frame at a time.

present

present : {e : HFunctor}
-> {s t : Type}
-> {{ev : canvas <: e}}
-> With s GPU.Device
-> Element
-> With t GPU.Buffer
-> Int
-> Int
-> Co e (Either GPU.GpuError Unit)

The buffer’s bytes shown on the canvas as its pixels, w wide and h high, RGBA, a byte each (a UInt32 an invocation stores is one pixel: red its lowest byte, alpha its highest); w a multiple of 64, as the host copies rows of 256 bytes. The canvas is sized to fit. Done when the GPU is.