RenderState
On this page

RenderState

Interface in Runtime

The fixed-function state of a render pipeline, which the host writes: the compiler knows its entries' inputs and outputs, and the runtime fills and checks those.

import type { RenderState } from 'typeshade/runtime'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

interface RenderState {
readonly vertex?: string;
readonly fragment?: string | null;
readonly targets?: readonly TargetState[];
readonly depth?: { readonly format: string; readonly compare?: string; readonly write?: boolean; };
readonly primitive?: { readonly topology?: string; readonly cullMode?: 'none' | 'front' | 'back'; readonly frontFace?: 'ccw' | 'cw'; };
readonly multisample?: { readonly count?: number };
readonly constants?: Constants;
}

Instance properties

vertexoptionalread only string

The vertex entry; the program’s only one when omitted.

fragmentoptionalread only string | null

The fragment entry; the program’s only one when omitted, none for a depth-only pass.

targetsoptionalread only readonly TargetState[]

One per colour output, by location. Omitted: rgba8unorm for each.

depthoptionalread only { readonly format: string; readonly compare?: string; readonly write?: boolean; }

The depth attachment’s format, and how the pipeline tests and writes it: compare defaults to 'less' and write to true. A reversed projection compares 'greater', and a pass drawn behind everything else (a sky) compares 'always' and does not write. Omitted: no depth test, for a pass with no depth attachment.

primitiveoptionalread only { readonly topology?: string; readonly cullMode?: 'none' | 'front' | 'back'; readonly frontFace?: 'ccw' | 'cw'; }

What the vertices make: topology defaults to 'triangle-list', cullMode to 'none' and frontFace to 'ccw'.

multisampleoptionalread only { readonly count?: number }

The sample count of the targets it draws into: 1 when omitted, 4 for a multisampled target.

constantsoptionalread only Constants

The values of the program’s overrides (surface §15), by the names the source declares: { quality: 3 }. The vertex and the fragment stage are each created with them, as WebGPU’s constants. An override the record leaves out takes the default its declaration states, so omitted, every override does. An f32 takes a finite number no larger than 3.4028234663852886e38 in magnitude, an i32 or a u32 a whole number in its range, and a bool a boolean or a number, where 0 is false. A name the program does not declare is a TypeError that names the program’s overrides, and a value its type cannot hold one that says what the type takes. Two states that differ in an override are two pipelines, and the same values give the same pipeline back.

Source

src/runtime/program.ts, line 64, at commit 26de7be8

Edit this page Report a problem