RuntimeOptions
On this page

RuntimeOptions

Interface in Runtime

How createRuntime() makes a runtime.

import type { RuntimeOptions } from 'typeshade/runtime'

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

Syntax

interface RuntimeOptions<D extends object = object> {
readonly device?: D;
readonly prefer?: readonly RuntimeTier[];
readonly programs?: readonly Pack[];
readonly limits?: Readonly<Record<string, number>>;
readonly console?: 'print' | ConsoleSink;
readonly consoleBytes?: number;
readonly emit?: (manifest: Pack, options: { readonly console?: boolean }) => Pack;
}

Instance properties

deviceoptionalread only D

The host’s GPUDevice or WebGL2RenderingContext, which the runtime uses and never destroys; the runtime’s tier is the one it belongs to (change 0054). Omitted: the runtime tries the tiers of prefer in order, requesting a device with the features programs need, or making a WebGL2 context of its own. Escape hatch (Rule 11.17): the host’s own device or context, which it keeps and calls beside the runtime.

preferoptionalread only readonly RuntimeTier[]

The tiers createRuntime tries when it is given no device, in order: ['webgpu', 'webgl2'] by default. A list of one tier makes it required. On WebGL2 the runtime runs compute entries and draws from the GLSL programs the manifest carries (change 0054).

programsoptionalread only readonly Pack[]

The programs the requested device must be able to run.

limitsoptionalread only Readonly<Record<string, number>>

WebGPU limits the device must have, by their names in GPUSupportedLimits (change 0051): { maxStorageBufferBindingSize: 1 << 30 }. Without device, the runtime requests each, with the limits programs need, and the larger of the two where both name one. A binding size named here raises maxBufferSize with it, up to the adapter’s. With device, the runtime checks the device against each. A WebGL2 device has no WebGPU limits, so it refuses this option. Omitted: none.

consoleoptionalread only 'print' | ConsoleSink

Where the events of an entry’s console.* calls go: printed to the host’s console, with a warning for the calls that did not fit the buffer ('print', the default), or handed to a sink, which takes the lines and the count and prints nothing. The count of each buffer’s lines and dropped calls is what submit() resolves to, either way.

consoleBytesoptionalread only number

The console buffer’s size for each dispatch and draw that records, in bytes. 1 MiB. A call the buffer has no room for is dropped whole, and counted in the dropped of submit()’s row for that dispatch or draw.

emitoptionalread only (manifest: Pack, options: { readonly console?: boolean }) => Pack

The load-time emitter, repack from typeshade/emit, which emits a manifest again from the portable IR it carries when a load asks for a variant the build did not write (load(m, { console: true })), under the options the manifest was packed under (packModule(m, { emit })). The runtime never imports it itself, so a host that does not pass it ships no emitter. Normal builds need none for console variants.

Source

src/runtime/runtime.ts, line 45, at commit af54ddad5

Edit this page Report a problem