{"record":{"id":"7398c1e7c9c8847f","repo":"BabylonJS/Babylon.js","slug":"invalid-format-vertexbuffer-getkind-type","errorCode":null,"errorMessage":"Invalid Format '${vertexBuffer.getKind()}' - type=${type}, normalized=${normalized}, size=${size}","messagePattern":"Invalid Format '(.+?)' - type=(.+?), normalized=(.+?), size=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/WebGPU/webgpuCacheRenderPipeline.ts","lineNumber":757,"sourceCode":"                    case 4:\r\n                        return WebGPUConstants.VertexFormat.Uint32x4;\r\n                }\r\n                break;\r\n            case VertexBuffer.FLOAT:\r\n                switch (size) {\r\n                    case 1:\r\n                        return WebGPUConstants.VertexFormat.Float32;\r\n                    case 2:\r\n                        return WebGPUConstants.VertexFormat.Float32x2;\r\n                    case 3:\r\n                        return WebGPUConstants.VertexFormat.Float32x3;\r\n                    case 4:\r\n                        return WebGPUConstants.VertexFormat.Float32x4;\r\n                }\r\n                break;\r\n        }\r\n\r\n        throw new Error(`Invalid Format '${vertexBuffer.getKind()}' - type=${type}, normalized=${normalized}, size=${size}`);\r\n    }\r\n\r\n    private _getAphaBlendState(targetIndex: number): Nullable<GPUBlendComponent> {\r\n        if (!this._alphaBlendEnabled[targetIndex]) {\r\n            return null;\r\n        }\r\n\r\n        return {\r\n            srcFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[targetIndex * 4 + 2]),\r\n            dstFactor: WebGPUCacheRenderPipeline._GetAphaBlendFactor(this._alphaBlendFuncParams[targetIndex * 4 + 3]),\r\n            operation: WebGPUCacheRenderPipeline._GetAphaBlendOperation(this._alphaBlendEqParams[targetIndex * 2 + 1]),\r\n        };\r\n    }\r\n\r\n    private _getColorBlendState(targetIndex: number): Nullable<GPUBlendComponent> {\r\n        if (!this._alphaBlendEnabled) {\r\n            return null;\r\n        }\r","sourceCodeStart":739,"sourceCodeEnd":775,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/WebGPU/webgpuCacheRenderPipeline.ts#L739-L775","documentation":"When building the WebGPU vertex buffer layout, this helper maps (type, normalized, size) tuples of a vertex buffer to a GPUVertexFormat. If the combination has no matching WebGPU vertex format (unsupported component type, size, or normalization flag), it throws with the buffer kind and offending values.","triggerScenarios":"Attaching a VertexBuffer whose component type/size/normalized combo has no WebGPU equivalent, e.g. a 3-component normalized unsigned-short attribute, or an unusual custom kind with type/size outside the supported set.","commonSituations":"Custom vertex kinds with hand-built buffers of unusual stride/size; importing meshes with exotic attribute layouts (e.g. byte-based normals at size 3 normalized); passing a wrong 'size' (e.g. 5) or an unnormalized integer type WebGPU cannot consume.","solutions":["Convert the attribute data to a supported layout, e.g. Float32Array with size 1-4.","Adjust the normalized flag: use normalized:false with float data or a supported normalized integer format.","Inspect the error's type/normalized/size values and match them to a documented WebGPU GPUVertexFormat before creating the buffer."],"exampleFix":"// before\nnew VertexBuffer(engine, new Uint16Array([...]), \"normal\", false, 64, 0, 3); // u16 x3 unnormalized\n// after\nnew VertexBuffer(engine, new Float32Array([...]), \"normal\", false, 64, 0, 3); // float32 x3","handlingStrategy":"validation","validationCode":"// Supported combos: float 1-4, uint16/uint8 etc. per WebGPU spec\nfunction hasSupportedVertexLayout(type: number, normalized: boolean, size: number): boolean {\n  if (type === BABYLON.VertexBuffer.FLOAT) return size >= 1 && size <= 4;\n  if (type === BABYLON.VertexBuffer.UNSIGNED_SHORT) return size === 2 || size === 4; // u16x3 unnormalized is invalid\n  if (type === BABYLON.VertexBuffer.UNSIGNED_BYTE) return size === 2 || size === 4;\n  return false;\n}\nif (!hasSupportedVertexLayout(type, normalized, size)) convertBufferToFloat32();","typeGuard":"function hasWebGPUVertexFormat(type: number, normalized: boolean, size: number): boolean {\n  const V = BABYLON.VertexBuffer;\n  if (type === V.FLOAT) return size >= 1 && size <= 4;\n  if (type === V.UNSIGNED_SHORT) return [2, 4].includes(size);\n  if (type === V.UNSIGNED_BYTE) return [2, 4].includes(size);\n  return false;\n}","tryCatchPattern":"try {\n  mesh.setVerticesBuffer(kind, buffer);\n} catch (e) {\n  if (String(e.message).startsWith('Invalid Format')) {\n    console.warn(`Rebuilding ${kind} as float32x4`, e.message);\n    mesh.setVerticesBuffer(kind, rebuildAsFloat32(buffer));\n  } else throw e;\n}","preventionTips":["Prefer Float32Array vertex data with sizes 1-4 for custom attributes.","Avoid odd sizes (3, 5) on 8/16-bit integer attributes; pad to 4 components.","Check the WebGPU GPUVertexFormat table before introducing a new vertex kind."],"tags":["babylonjs","webgpu","vertex-format","vertex-buffer"],"backgroundTag":"unsupported-vertex-attribute-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}