capabilityMatrix
On this page

capabilityMatrix()

Function in Backends

Report which backend can spell which capability, as one row per capability with a support class per backend.

import { capabilityMatrix } from 'typeshade'

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

Syntax

function capabilityMatrix(backends: readonly Backend[]): readonly CapabilityRow[]

Parameters

backends readonly Backend[]

the backends to compare, in the column order you want.

Return value

readonly CapabilityRow[]

one row per capability, in the canonical capability order.

Exceptions

UnsupportedFeatureError

Emit throws UnsupportedFeatureError with SD0030 naming the capability, and no source the driver would reject is produced. declarable is false for the nine capabilities derived from a module’s shape, which enables cannot name: storageBuffer, compute, msaaTextureLoad, storageTexture, texture1d, textureCubeArray, textureGather, bgra8unormStorage and packed4x8Dot.

SD0030

Emit throws UnsupportedFeatureError with SD0030 naming the capability, and no source the driver would reject is produced. declarable is false for the nine capabilities derived from a module’s shape, which enables cannot name: storageBuffer, compute, msaaTextureLoad, storageTexture, texture1d, textureCubeArray, textureGather, bgra8unormStorage and packed4x8Dot.

Description

The support classes are read from each backend’s own capProfile table, so the matrix cannot go stale against the thing it describes. A row reads 'native' when the target needs nothing, 'directive' when the backend emits a source line for it, 'host-feature' when the host activates it before pipeline creation, and 'unsupported' when that target has no row at all. A capability may need both halves, a directive and a host feature, and the class names the one that decides the row.

Support is not reachability. A capability can have a profile row and no way to author it: a row says the backend would emit the directive, and whether the DSL has a construct that needs it is a separate question. Read a row as a fact about the emit, and check the authoring surface separately.

A missing row is a hard stop by design, and it is no hint to work around. Emit throws UnsupportedFeatureError with SD0030 naming the capability, and no source the driver would reject is produced.

declarable is false for the nine capabilities derived from a module’s shape, which enables cannot name: storageBuffer, compute, msaaTextureLoad, storageTexture, texture1d, textureCubeArray, textureGather, bgra8unormStorage and packed4x8Dot. It reads the same list DeclarableCapability is defined against.

Examples

Example

import { capabilityMatrix, wgslBackend, glslEs300Backend } from 'typeshade'
capabilityMatrix([wgslBackend, glslEs300Backend])
// [{ capability: 'storageBuffer',
// support: { wgsl: 'native', 'glsl-es300': 'unsupported' }, declarable: false },
// …,
// { capability: 'f16',
// support: { wgsl: 'directive', 'glsl-es300': 'unsupported' }, declarable: true }]

In the guide

See also

Source

src/core/backend.ts, line 452, at commit 26de7be8

Edit this page Report a problem