pixijs/pixijs · error · Error
Unknown type ${uboElement.data.type}
Error message
Unknown type ${uboElement.data.type} What it means
Thrown by createUboElementsSTD40() when computing the STD40 packing layout for a uniform buffer object (UBO) and a uniform's WGSL type string is absent from the WGSL_TO_STD40_SIZE table. The table covers f32/i32/u32, their vec2-4 variants, and mat2x2/3x3/4x4. Any other type (e.g. a struct, an array type, a f16, or a custom/typo'd type string) yields size === undefined and is rejected.
Source
Thrown at src/rendering/renderers/gl/shader/utils/createUboElementsSTD40.ts:71
data,
offset: 0,
size: 0,
}));
const chunkSize = 16;
let size = 0;
let offset = 0;
for (let i = 0; i < uboElements.length; i++)
{
const uboElement = uboElements[i];
size = WGSL_TO_STD40_SIZE[uboElement.data.type];
if (!size)
{
throw new Error(`Unknown type ${uboElement.data.type}`);
}
if (uboElement.data.size > 1)
{
size = Math.max(size, chunkSize) * uboElement.data.size;
}
const boundary = size === 12 ? 16 : size;
uboElement.size = size;
const curOffset = offset % chunkSize;
if (curOffset > 0 && chunkSize - curOffset < boundary)
{
offset += (chunkSize - curOffset) % 16;
}
elseView on GitHub (pinned to 4b141e3ced)
Solutions
- Restrict UBO uniforms to the supported primitive/vector/matrix types (f32, i32, u32, vec2/3/4, mat2x2/3x3/4x4).
- Decompose unsupported types (structs/arrays) into individual supported uniforms.
- If you control the shader compiler, ensure the emitted uniform type string exactly matches a key in WGSL_TO_STD40_SIZE.
Example fix
// before (uniform metadata)
{ name: 'uLights', type: 'array<vec3<f32>, 8>' } // not in STD40 map
// after
// flatten to individual supported uniforms or use a fixed set of vec4 entries:
{ name: 'uLight0', type: 'vec4<f32>' },
{ name: 'uLight1', type: 'vec4<f32>' } /* ... */ Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_UBO_TYPES = new Set([
'f32','i32','u32',
'vec2<f32>','vec3<f32>','vec4<f32>',
'vec2<i32>','vec3<i32>','vec4<i32>',
'vec2<u32>','vec3<u32>','vec4<u32>',
'mat2x2<f32>','mat3x3<f32>','mat4x4<f32>',
]);
function assertUboTypesSupported(uniforms: {type:string}[]): void {
for (const u of uniforms) {
if (!SUPPORTED_UBO_TYPES.has(u.type)) {
throw new Error(`Uniform type '${u.type}' is not supported by the STD40 UBO packer.`);
}
}
} Type guard
function isStd40SupportedType(type: string): boolean {
return type in WGSL_TO_STD40_SIZE; // import the map or mirror it
} Prevention
- Restrict UBO uniforms to scalar/vector/matrix types the packer knows.
- Validate shader uniform metadata at load time, not at draw time.
- Keep your shader compiler's emitted types in sync with the STD40 size table.
When it happens
Trigger: Declaring a uniform in a shader whose type is not in the STD40 size map (e.g. arrays of structs, half-precision types, or a malformed type string). Fires when the renderer builds the UBO layout from the program's uniform metadata.
Common situations: Custom shaders introducing uniform types the STD40 packer doesn't support (arrays, nested structs, f16). Typos in WGSL type annotations inside uniform data. Library version mismatch where a new type was added to shaders but not to the packer table.
Related errors
- Invalid value of `0` passed to `checkMaxIfStatementsInShader
- shader and geometry incompatible, geometry missing the "${j}
- Current environment does not allow unsafe-eval, please use p
- [HTMLSource] WebGLRenderingContext.texElementImage2D is not
- This browser does not support WebGL. Try using the canvas re
AI-assisted analysis of pixijs/pixijs@4b141e3ced (2026-08-12).
Data as JSON: /api/errors/74f5d0493747d82b.
Report an issue: GitHub.