Simple list of common bugs and fixes which you might have come across while learning, experimenting, testing and updating your WebGPU demos.
Comment | |||
---|---|---|---|
BeN | Binding sizes are too small for bind group [BindGroup] at index 0 | Binding sizes are too small for bind group [BindGroup] at index 0 - While encoding [RenderPassEncoder].Draw(4, 1, 0, 0). // FIX ``` struct Uniforms2 { instancePos : array< vec4<f32>, 8>, }; ``` size in the shader didn't match the size in the group (i.e., should be size 8 not 64). | 2022-06-14 09:05:54 |
BeN | `mod` is a reserved keyword | 'mod' function wasn't available in earlier versions - simply remove the user defined version or rename it to another name (e.g., 'mymod') ``` Shader '' parsing error: name `mod` is a reserved keyword ┌─ wgsl │ │ fn mod( x: f32, y: f32 ) -> f32 │ ^^^ definition of `mod` ``` Fix //fn mod( x: f32, y: f32 ) -> f32 fn mymod( x: f32, y: f32 ) -> f32 | 2022-05-23 08:28:40 |
BeN | Shader '' parsing error: name `output` is a reserved keyword | Careful with naming variables ``` Shader '' parsing error: name `output` is a reserved keyword ┌─ wgsl │ │ var output : VertexOutput; │ ^^^^^^ definition of `output` , caused by: name `output` is a reserved keyword ``` Fix Rename var output to var vout | 2022-05-23 08:17:49 |
BeN | default GPUCanvasCompositingAlphaMode will change | The default GPUCanvasCompositingAlphaMode will change from "premultiplied" to "opaque". Please explicitly pass "premultiplied" if you would like to continue using that compositing mode. Not required but prevents the 'warning' message by explicitly stating the preferred format (the previous default has changed) "premultiplied" to "opaque" ``` // GPUCanvasConfiguration context.configure({ device: device, format: presentationFormat, // GPUCanvasCompositingAlphaMode compositingAlphaMode: "opaque" // <-- add this }); ``` | 2022-05-23 08:03:55 |
BeN | Setting an explicit size when calling configure() on a GPUCanvasContext has been deprecated | Setting an explicit size when calling configure() on a GPUCanvasContext has been deprecated, and will soon be removed. Please set the canvas width and height attributes instead. Note that after the initial call to configure() changes to the canvas width and height will now take effect without the need to call configure() again. Makes sense, as the canvas that the GPU graphical output is associated with already has its size set, not to mention, if the GPU isn't going to be used for graphical output (i.e., compute) - why would you need to set the size information. Fix ``` context.configure({ device: device, format: presentationFormat, // size : presentationSize <-- remove this }); ``` | 2022-05-23 07:59:32 |