Resident
On this page

Resident

Interface in Runtime

A value that stays on the device across calls, made by resident: one buffer of both layers.

import type { Resident } from 'typeshade'
import type { Resident } from 'typeshade/runtime'

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

Syntax

interface Resident<T = ResidentValue> {
read(): Promise<T>;
write(value: T): void;
destroy(): void;
readonly [residentBrand]: T;
}

Description

Pass it where a kernel function takes an array, as an entry’s storage array with no size (surface §67), or as any buffer binding of a program runtime’s draw or dispatch (surface §69): the first use on WebGPU uploads it, the uses after bind it as it is, and nothing is read back until Resident.read. A call whose written arrays are all resident, and that returns nothing, only queues.

Instance methods

read (): Promise<T>

Wait for every kernel call made before this one, and return a new array holding what the handle holds.

write (value: T): void

Replace what the handle holds with value, after every call made before this one; with none waiting, at once. The next use uploads it.

destroy (): void

Release the device buffer, after every call made before this one. A use after it throws.

See also

Source

src/core/resident.ts, line 46, at commit 26de7be8

Edit this page Report a problem