Types
On this page

Types

The scalar and vector names are WGSL's, since one source has to serve both targets, and the GLSL writer spells each one in this target's terms. A declaration therefore says f32 where the emitted shader says float.

Scalars

GLSL ES 3.00TypeShade
float
f32
int
i32
uint
u32
bool
bool

Vectors

GLSL ES 3.00TypeShade
vec3
vec3
ivec3
vec3i
uvec3
vec3u
bvec3
vec3b

vec2 and vec4 read the same way, and so do the integer, unsigned and boolean forms of each. A vector of doubles has no form on either target and is rewritten into f32 lanes before the writer runs.

Matrices and arrays

GLSL ES 3.00TypeShade
mat4
mat4
mat3
mat3
mat2x3
mat2x3

A square matrix keeps the short name every driver's error messages use, and the other six shapes are written matCxR, columns then rows, the same way this target writes them.

GLSL ES 3.00TypeShade
float[4]
array<f32, 4>
float[2]
[f32, f32]

A tuple is a list of a length the type fixes, so [f32, f32] and array<f32, 2> reach the same type. An array whose length is not known until the program runs is a storage buffer, which this target has no form for, so a module with one is rewritten to read from a data texture instead.

Samplers

This target fuses the texture and the sampler into one combined sampler, and WebGPU keeps them apart. A TypeShade file declares the two the WebGPU way and the GLSL writer fuses them, so the sampler argument disappears from every read and the binding it stood in is dropped from the layout the host binds.

GLSL ES 3.00TypeShade
sampler2D
texture_2d<f32>
usampler2D
texture_2d<u32>
isampler2D
texture_2d<i32>
sampler2DArray
texture_2d_array<f32>
samplerCube
texture_cube<f32>
sampler3D
texture_3d<f32>
sampler2DShadow
texture_depth_2d

standalone sampler — fused into the combined sampler2D

sampler

standalone comparison sampler — fused into the combined sampler2DShadow

sampler_comparison

A depth texture is the exception that proves the fusing: its combined type depends on how the module reads it, so the binding emit decides it. Every read of one this surface admits is a comparison, which makes it the shadow form.

Types with no GLSL form

Each of these is refused by the writer, and the cell beside it is the sentence the writer throws. A module carrying one still emits its WGSL, so these are the lines that make a shader WebGPU only.

TypeShadeWhat the compiler says
texture_1d<f32>

texture_1d<f32> has no GLSL ES 3.00 spelling (no 1d or cube-array samplers)

texture_cube_array<f32>

texture_cube_array<f32> has no GLSL ES 3.00 spelling (no 1d or cube-array samplers)

texture_multisampled_2d<f32>

multisampled texture load — sampler2DMS is ES 3.10 (msaaTextureLoad fails the module closed first)

texture_storage_2d<"rgba8unorm", "write">

texture_storage_2d<rgba8unorm, write> has no GLSL ES 3.00 spelling (image load/store is ES 3.10)

atomic<u32>

atomic<u32> has no GLSL ES 3.00 spelling (no storage buffers, no atomics)

Edit this page Report a problem