Reference
API Reference
Browse generated API docs by topic. Every symbol comes from the docs manifest and deep-links to an anchor on its topic page.
Start with vgpu
initfunctionCreates the public `Gpu` context. `init()` creates the device only; canvas-backed rendering is explicit through `surface(gpu, canvas, opts)`.
import { init } from "vgpu";GpuclassThe main API (`vgpu`) context returned by `init()`. It owns device lifetime and the frame clock; every resource — canvas surfaces, offscreen targets, render, compute, storage, uniforms, samplers, and bundles — is created by a free function that takes the `Gpu` as its first argument.
import type { Gpu } from "vgpu";
import { init } from "vgpu/mock";EffecttypeFullscreen-fragment render unit created by `effect(gpu)`. Use it for post-processing, gradients, blurs, and screen/target copies; use `draw(gpu)` for meshes, vertex buffers, instancing, or explicit vertex counts.
import type { Effect, EffectOptions } from "vgpu";DrawtypeTarget-agnostic renderable shader unit created by `draw(gpu)`. It reflects WGSL bindings, caches pipelines per target format/depth/sample count, and supports geometries, explicit vertex counts, instancing, and raw group claims.
import type { DepthOptions, Draw, DrawOptions, DrawCallOptions, DrawLayoutOptions, GeometryLike, StencilFaceOptions, StencilOptions } from "vgpu";ComputetypeCompute pipeline created by `compute(gpu)`. It uses the same WGSL reflection and `set()` ownership rules as render draws, then `dispatch(x, y?, z?)` — or `dispatch({ indirect })` for GPU-driven counts — encodes and submits one compute pass.
import type { Compute, ComputeOptions, DispatchOptions, StorageAccess, StorageBuffer, StorageOptions } from "vgpu";Frametype`frame()` is both a callable one-frame submit helper and a `FrameRunner`. It creates one command encoder, lets you encode any number of explicit-target render passes, then submits once.
import type { Frame, FramePass, FramePassOptions, FrameLoopHandle, FrameRunner } from "vgpu";BundletypeMain API (`vgpu`) render bundle recorded by `bundle(gpu, { target }, cb)`. Bundles freeze commands, attachment formats, sample count, and bind-group identities for static work; `FramePass.bundles()` checks signature and resource staleness (`VGPU-R3-BUNDLE-STALE`) when replaying.
import type { Bundle, BundleOptions, BundleRecorder } from "vgpu";TargettypeOffscreen render target abstraction used by passes, draws, bundles, and ping-pong resources. Targets own size, color formats, optional depth, MSAA resolve textures, and readback. Canvas-backed targets are `Surface` instances created with `surface(gpu, canvas)`.
import type { Target, TargetOptions, TargetTextureOptions, PingPongTargets, PingPongStorage } from "vgpu";SharedUniformstypeValues-first shared uniform/storage object created by `uniforms(gpu, values)`. It adopts binary WGSL layout lazily from the first compatible shader binding and reuses one stable buffer across shaders.
import type { SharedUniforms } from "vgpu";PingPongStoragetypeOffscreen render target abstraction used by passes, draws, bundles, and ping-pong resources. Targets own size, color formats, optional depth, MSAA resolve textures, and readback. Canvas-backed targets are `Surface` instances created with `surface(gpu, canvas)`.
import type { Target, TargetOptions, TargetTextureOptions, PingPongTargets, PingPongStorage } from "vgpu";Packages
vgpu
Public API: init, Gpu, effect, draw, compute, frame, bundle, target, ping-pong, and uniforms.
vgpu/scene
Tree-shakeable geometry, camera, color, and orbit helpers without a retained scene graph.
@vgpu/wgsl
WGSL compile-time entry points, runtime resolution, reflection metadata, and bundler loaders.
@vgpu/wgsl-std
Standard WGSL modules for color, fullscreen triangles, hashes, and procedural noise.
vgpu/core
AdvancedAdvanced escape hatches for native WebGPU handles, buffers, textures, bind groups, and structured uniforms.
@vgpu/render
AdvancedAdvanced render tooling for inspection, performance measurement, utilities, and mesh editing.
@vgpu/adapter-node
Reference documentation for @vgpu/adapter-node.
vgpu/mock
Reference documentation for vgpu/mock.