# How to read the docs

> `@typegpu/kit` 0.1.0. If it is installed, read `node_modules/@typegpu/kit/docs/` instead.

The four kinds of page, the parts of a module page, and what the marks on a module's card state.

The label above a page's title says which kind of page it is.

| Kind     | Read it to                                                    | It assumes                                          |
| -------- | ------------------------------------------------------------- | --------------------------------------------------- |
| Tutorial | build one example from an empty canvas, step by step          | nothing: no shaders and no TypeGPU                  |
| Concept  | learn how the kit works and why modules share one shape       | the frame from [Getting started](getting-started.md) |
| Recipe   | combine several modules for one job, in code you can copy     | the modules it names                                |
| Module   | use one module: what it solves, how to call it, what it costs | TypeGPU basics                                      |

If you are new to the kit, read [Getting started](getting-started.md), then [How the kit works](concepts/how-the-kit-works.md). Every module page builds on those two.

A page that builds on another names it under its title, after **Read first**. A module page names the concept behind it beside its label. Every page ends with the next page of its group.

## A module page

Every module page has its parts in the same order. It opens with one sentence on what the module does, a strip with its import and main call, and the problem it solves. Any figure and the module in use come next, then sections in the order you meet them. The reference card comes last.

A page that covers several modules gives each one a strip in its own section and gathers their cards under Reference.

## The card

A card is generated from the module's source, so it always matches the installed code. It lists every call with what each argument is, every option with its default, every member of what a call returns, and the module's facts.

A fact is listed only where the module differs from a plain one. A plain module records into what you hand it, never submits, creates no GPU objects in a steady frame and needs no device feature. A card with few facts describes a module with few surprises.

Coral marks an exception to a rule every other module keeps: it submits on its own, it allocates after setup, or its API may still change. An exception is valid behaviour you design around, and its row says when it happens.

An option marked `'use gpu'` on the card takes a function that runs in a shader, so pass it a `'use gpu'` function. Any other function option runs on the CPU.

A name in a call opens its definition: the result opens its members, `options` its fields, an option its row, a module its page. A method named in a fact opens its member. Point at a label or a kind for its meaning.

## Figures and code

- In a figure, blue marks what is live, selected or new. The caption says what to try.
- A number in code with a dotted underline can be dragged, and the figure follows it.
- Every code block is typechecked against the kit. Point at a name to see its type.
- Lines a block needs to compile but that are not its subject are hidden. A tutorial shows every line you write.

## Words

A word with a dotted underline is one the docs use in a sense of their own, marked where a page first uses it. Point at it or tap it for its meaning and the section that teaches it.

- **accessor** An accessor is a typed value that shader code reads and that each pipeline can fill with a different resource.
- **atlas** An atlas is one texture that holds many small pictures side by side, such as every glyph of a font or every view of a model.
- **bind group** A bind group is a set of buffers, textures and samplers that a pipeline reads, and a pipeline has room for four.
- **binding** A binding is one buffer, texture or sampler in a bind group, which a shader reads by its place there.
- **cadence** A cadence tells you on which frames work that runs less often than every frame is due.
- **capture** A capture copies a buffer at one point in the frame, so the CPU can read it after the submit.
- **compound** A compound is a drawing made of several pipelines, with resources of its own for each view it draws into.
- **definition** A definition names a table's fields before any table exists, so shader code written over it works with every table made from it.
- **dispatch** A dispatch runs a kernel once over a number of threads, inside a compute pass.
- **drawing** A drawing is what a renderer hands to a pass description: what each vertex carries to its pixels, what a pixel looks like and the draw call.
- **factory** A factory is the function that creates a module, which allocates what the module needs and returns its resources, functions and recording methods.
- **fill** A fill is the resource a pipeline binds for an accessor its shaders read.
- **fixed step** A fixed step advances a simulation by one set length of time, and each frame runs a whole number of them, so the result is the same at any frame rate.
- **flush** A flush uploads the rows the CPU changed since the last one.
- **frame** A frame is one turn of the loop, and the object your function gets for it, which holds the encoder, the time and the time since the last frame.
- **HDR** HDR, high dynamic range, is colour stored with more range than a screen shows, so a light can be brighter than white.
- **hook** A hook is a placeholder that each pipeline fills with its own choice, such as the camera it draws through.
- **host** A host runs a scene for you, which means it makes the device, the surface and the frame loop and frees them in order.
- **impostor** An impostor draws a distant model as one card that faces the camera, textured with pictures of the model taken in advance.
- **indirect draw** An indirect draw reads how much to draw from a buffer, so a kernel can decide the count and the CPU never reads it.
- **inject** A module's inject() returns the fills a pipeline needs before its shaders can read the module's placeholders.
- **instance** An instance is one copy of a mesh with its own position, rotation, scale and material, kept as a row of a table.
- **kernel** A kernel is a compute function that the GPU runs many times at once, each run on its own thread.
- **kind** A kind adds fields to the rows of a set of instances and replaces functions in the shaders that draw them.
- **linear light** Linear light is colour as amounts of light, the form in which lighting adds up correctly, before the final pass encodes it for the screen.
- **live list** A live list is a list of the live rows of one group, made on the GPU each frame so that a draw covers only them.
- **member** A member is a function or accessor on what a factory returns that reads that instance's own resources, so a pipeline that uses it needs no fill.
- **mesh pool** A mesh pool stores every mesh's vertices in shared buffers, so one pipeline can draw any mesh.
- **module** A module is one piece of GPU work, made by a factory that borrows your root and returns resources, shader functions and methods that record into your frame.
- **output** An output is a value every drawing writes at each pixel beside its colour, such as motion or an id.
- **part** A part is a set of resources that can be replaced, such as a texture that follows the screen size, which pipelines read through a layout they share.
- **pass description** A pass description says once which textures a pass draws into and what each holds, and builds the pipeline for every drawing added to it.
- **patch** A patch uploads only the fields you pass and leaves the others as they are.
- **placeholder** A placeholder is an accessor with no resource of its own, which each pipeline fills through the inject() of the module it reads.
- **readback** A readback copies a buffer during a frame and hands it to the CPU a frame or two later, without making the frame wait.
- **recorder** The recorder is the function you give the frame loop, which records one frame into the encoder it is handed.
- **recording method** A recording method records a module's work into the pass, the encoder or the frame you hand it, and never submits.
- **renderer** A renderer draws one sort of thing, such as instances or particles, by handing a pass description a drawing.
- **row** A row is one object's values in a buffer, such as one enemy, one particle or one light.
- **row id** A row id names one row of a table for as long as the row lives, and stops working once the row is removed.
- **runtime** A runtime is one JavaScript thread with its own memory, such as the page, a worker or a React Native worklet thread.
- **sampler** A sampler tells the GPU how to read a texture between its texels and past its edges, such as smoothly or in blocks.
- **scene** A scene is the function a scene file exports, which creates its modules and returns the function that records each frame.
- **slot** A slot is a row's place in its buffers, which a new row can take once the first is removed.
- **sRGB** sRGB is the encoding screens and most image files use for colour, which a shader turns into linear light before it does maths on it.
- **staging buffer** A staging buffer is a buffer the CPU can map, which a result is copied into so that it can be read after the frame.
- **steady frame** A steady frame is any frame after setup, in which a module only records and creates no GPU objects.
- **storage buffer** A storage buffer is GPU memory that shaders read by index and kernels can write, which is where the kit keeps rows.
- **surface** A surface is a canvas set up for your root, which keeps its drawing buffer the size the page shows it at.
- **table** A table is a buffer of rows with named fields, some written by the CPU and the others by kernels.
- **target** A target is a texture that a frame draws into.
- **texel** A texel is one cell of a texture, as a pixel is one cell of the screen.
- **thread** A thread is one run of a kernel, and the GPU starts many at once, each with its own number.
- **tone curve** A tone curve maps light of any brightness into the range a screen can show, keeping detail in the bright parts.
- **workgroup** A workgroup is a block of threads that the GPU starts together, and a dispatch runs as many workgroups as cover the work.
- **worklet** A worklet is a function that react-native-worklets can run on a thread other than the main JavaScript thread.

## For coding agents

Every page is also Markdown at its address with `.md` in place of the trailing slash, such as `/kit/frames.md`. `/llms.txt` lists them, and the kit ships the same pages in its package. [Getting started](getting-started.md#coding-agents) sets an agent up with them.
