Capability
타입, IR 분류
A GPU or language feature a target backend may or may not support.
import type { Capability } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
type Capability = | 'storageBuffer' | 'compute' | 'msaaTextureLoad' | 'storageTexture' | 'texture1d' | 'textureCubeArray' | 'textureGather' | 'f16' | 'subgroups' | 'clipDistances' | 'primitiveIndex' | 'dualSourceBlending' | 'floatRenderTarget' | 'float32Blend' | 'float32Filterable' | 'multiview' | 'bgra8unormStorage' | 'packed4x8Dot';설명
Emitting a module
that needs an unsupported feature throws 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,msaaTextureLoadandstorageTexture, are inferred from a module’s shape (a storage binding, a@computeentry, a multisampled texture load, a storage-texture binding) and never declared. - Opt-in language capabilities,
f16,subgroups,clipDistancesandprimitiveIndex, are declared inModuleDecl.enables, or — for the two that a@builtin(...)id names outright — derived from that use byrequiredCaps, the wayenable clip_distances;is what WGSL asks for before@builtin(clip_distances)is spelled. Each is a WGSLenabledirective 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(WebGL2EXT_color_buffer_float, WebGPU core),float32Blend(EXT_float_blend, WebGPU'float32-blendable') andfloat32Filterable(OES_texture_float_linear, WebGPU'float32-filterable') are host-side: on WebGL2 the host activates them withgl.getExtensionbefore creating the pipeline, and they have no shader-source token, so declaring one leaves the emitted source unchanged on both targets.multiviewis the one source-directive capability: GLSL ES 3.00 needs#extension GL_OVR_multiview2 : requirein the shader itself. It is absent from the WGSL profile, since WebGPU has no equivalent, so a multiview module fails closed there. Note thatmultiviewbuys the directive only: a module declaring it emits the#extensionline and still renders single-view, because the DSL cannot spelllayout(num_views = N) in;or readgl_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.
함께 보기
소스
src/core/ir/nodes.ts, 724행, 커밋 c66579bf 기준