TextureElem
Type in Types
The element type of a sampled texture: WGSL's texture_2d<T> type parameter, or GLSL ES 3.00's sampler prefix.
import type { TextureElem } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
type TextureElem = 'f32' | 'u32' | 'i32';Description
All three are core in both targets.
An integer texture is unfilterable: interpolating integer texels is undefined, and WGSL
rejects textureSample on a texture_2d<u32>. GLSL would accept texture(usampler2D, …)
with nearest filtering, but a construct that compiles on WebGL2 and cannot be expressed on
WebGPU is what authoring once for both targets is meant to rule out. Read an integer
texture with textureLoad, textureDimensions and textureNumLayers;
textureSample and textureSampleLevel on an integer key are tsc errors.
See also
Source
src/core/ir/types.ts, line 33, at commit 26de7be8