---
title: "Capability: type in IR, TypeShade API reference"
description: "Capability, a type in IR. A GPU or language feature a target backend may or may not support."
url: https://typeshade.dev/api/capability/
language: en
---

# `Capability`

Type in IR

A GPU or language feature a target backend may or may not support.

`import type { Capability } from 'typeshade'`
`import type { Capability } from 'typeshade/core/ir'`

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

## Syntax

```ts
type Capability =
  | 'storageBuffer'
  | 'compute'
  | 'msaaTextureLoad'
  | 'storageTexture'
  | 'texture1d'
  | 'textureCubeArray'
  | 'textureGather'
  | 'f16'
  | 'subgroups'
  | 'clipDistances'
  | 'primitiveIndex'
  | 'dualSourceBlending'
  | 'floatRenderTarget'
  | 'float32Blend'
  | 'float32Filterable'
  | 'multiview'
  | 'bgra8unormStorage'
  | 'packed4x8Dot';
```

## Description

Emitting a module that needs an unsupported feature throws [`UnsupportedFeatureError`](https://typeshade.dev/api/unsupportedfeatureerror/): a capability absent from the target’s `capProfile` fails closed, naming the capability.

Ids are neutral; a module never names a raw `EXT_*` or `OVR_*` string. Each backend’s `capProfile` row translates the id into that target’s `hostFeature` (what the host activates: `gl.getExtension(...)` on WebGL2, a `requiredFeatures` entry on WebGPU) and its `directive` (what the emitted source says), so the same module ports across targets whose extension names differ.

There are three classes:

- Derived resource capabilities, `storageBuffer`, `compute`, `msaaTextureLoad` and `storageTexture`, are inferred from a module’s shape (a storage binding, a `@compute` entry, a multisampled texture load, a storage-texture binding) and never declared.
- Opt-in language capabilities, `f16`, `subgroups`, `clipDistances` and `primitiveIndex`, are declared in `ModuleDecl.enables`, or — for the two that a `@builtin(...)` id names outright — derived from that use by `requiredCaps`, the way `enable clip_distances;` is what WGSL asks for before `@builtin(clip_distances)` is spelled. Each is a WGSL `enable` directive with no GLSL ES 3.00 counterpart, so a module using one fails closed on the GLSL backend.
- Opt-in device capabilities are also declared in `ModuleDecl.enables`. They change what the device can do and leave what the source may spell unchanged. `floatRenderTarget` (WebGL2 `EXT_color_buffer_float`, WebGPU core), `float32Blend` (`EXT_float_blend`, WebGPU `'float32-blendable'`) and `float32Filterable` (`OES_texture_float_linear`, WebGPU `'float32-filterable'`) are host-side: on WebGL2 the host activates them with `gl.getExtension` before creating the pipeline, and they have no shader-source token, so declaring one leaves the emitted source unchanged on both targets. `multiview` is the one source-directive capability: GLSL ES 3.00 needs `#extension GL_OVR_multiview2 : require` in the shader itself. It is absent from the WGSL profile, since WebGPU has no equivalent, so a multiview module fails closed there. Note that `multiview` buys the directive only: a module declaring it emits the `#extension` line and still renders single-view, because the DSL cannot spell `layout(num_views = N) in;` or read `gl_ViewID_OVR`.

A bit width appears in an id only where the feature is bit-width specific: `float32Blend` and `float32Filterable` carry the `32` because both underlying features are 32-bit-float only. `floatRenderTarget` carries none, because `EXT_color_buffer_float` makes both 16-bit and 32-bit float attachments renderable.

A host reads what to activate from `reflect().requiredFeatures`.

## See also

- [`UnsupportedFeatureError`](https://typeshade.dev/api/unsupportedfeatureerror/)

## Source

[`src/core/ir/nodes/capabilities.ts`, line 43](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/nodes/capabilities.ts#L43), at commit af54ddad5
