{"record":{"id":"2cdd7a2384f426cf","repo":"BabylonJS/Babylon.js","slug":"webgpucomputecontext-getbindgroups-bindingsmappin","errorCode":null,"errorMessage":"WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!","messagePattern":"WebGPUComputeContext\\.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/WebGPU/webgpuComputeContext.ts","lineNumber":28,"sourceCode":"import * as WebGPUConstants from \"./webgpuConstants\";\r\nimport { type WebGPUHardwareTexture } from \"./webgpuHardwareTexture\";\r\nimport { type ExternalTexture } from \"core/Materials/Textures/externalTexture\";\r\nimport { type InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\n\r\n/** @internal */\r\nexport class WebGPUComputeContext implements IComputeContext {\r\n    private static _Counter = 0;\r\n\r\n    public readonly uniqueId: number;\r\n\r\n    private _device: GPUDevice;\r\n    private _cacheSampler: WebGPUCacheSampler;\r\n    private _bindGroups: GPUBindGroup[];\r\n    private _bindGroupEntries: GPUBindGroupEntry[][];\r\n\r\n    public getBindGroups(bindings: ComputeBindingList, computePipeline: GPUComputePipeline, bindingsMapping?: ComputeBindingMapping): GPUBindGroup[] {\r\n        if (!bindingsMapping) {\r\n            throw new Error(\"WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!\");\r\n        }\r\n        if (this._bindGroups.length === 0) {\r\n            const bindGroupEntriesExist = this._bindGroupEntries.length > 0;\r\n            for (const key in bindings) {\r\n                const binding = bindings[key],\r\n                    location = bindingsMapping[key],\r\n                    group = location.group,\r\n                    index = location.binding,\r\n                    type = binding.type,\r\n                    object = binding.object;\r\n                let indexInGroupEntries = binding.indexInGroupEntries;\r\n\r\n                let entries = this._bindGroupEntries[group];\r\n                if (!entries) {\r\n                    entries = this._bindGroupEntries[group] = [];\r\n                }\r\n\r\n                switch (type) {\r","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/WebGPU/webgpuComputeContext.ts#L10-L46","documentation":"WebGPUComputeContext.getBindGroups needs a bindingsMapping (shader location map) because browsers do not yet expose reflection for WGSL shaders, so the engine cannot infer binding locations itself. Calling getBindGroups without bindingsMapping throws immediately.","triggerScenarios":"Invoking getBindGroups (or dispatching compute work through a code path that bypasses the engine's shader processor) without supplying the bindingsMapping argument, e.g. calling low-level WebGPU compute APIs directly or with a custom pipeline whose bindings were never processed by the engine's WGSL shader processor.","commonSituations":"Custom compute integrations calling WebGPUComputeContext directly; skipping the engine's shader processing step that normally produces the binding map; older code written before bindingsMapping became mandatory.","solutions":["Let the engine process the WGSL shader (use engine.createComputePipelineEffect / the standard compute dispatch path) so bindingsMapping is generated and passed.","Build and pass a bindingsMapping object ({ [bindingNameOrId]: { group, binding } }) yourself when calling getBindGroups directly.","Update Babylon.js, as newer versions construct the mapping automatically for standard compute effects."],"exampleFix":"// before\ncontext.getBindGroups(bindings, computePipeline); // missing mapping\n// after\ncontext.getBindGroups(bindings, computePipeline, { uniforms: { group: 0, binding: 0 }, textures: { group: 0, binding: 1 } });","handlingStrategy":"validation","validationCode":"if (!bindingsMapping) {\n  throw new Error('getBindGroups requires a bindingsMapping produced by the WGSL shader processor; use the engine compute dispatch path');\n}\ncontext.getBindGroups(bindings, computePipeline, bindingsMapping);","typeGuard":"function hasBindingsMapping(m: unknown): m is NonNullable<Parameters<BABYLON.WebGPUComputeContext['getBindGroups']>[2]> {\n  return !!m && typeof m === 'object' && Object.keys(m as object).length > 0;\n}","tryCatchPattern":"try {\n  groups = context.getBindGroups(bindings, computePipeline, bindingsMapping);\n} catch (e) {\n  if (String(e.message).includes('bindingsMapping is required')) {\n    bindingsMapping = buildBindingsMappingFromShaderProcessor(computeEffect);\n    groups = context.getBindGroups(bindings, computePipeline, bindingsMapping);\n  } else throw e;\n}","preventionTips":["Dispatch compute work through the engine's standard compute effect APIs so bindingsMapping is auto-generated.","Never call WebGPUComputeContext.getBindGroups directly without a mapping from the shader processor.","Keep Babylon.js updated; newer versions improve automatic WGSL binding resolution."],"tags":["babylonjs","webgpu","compute-shader","api-misuse"],"backgroundTag":"missing-bindings-mapping","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}