wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

Pipeline validation errors are not very clear

Open jimblandy opened this issue 2 years ago • 0 comments

The error messages produced when the WGSL bindings and pipeline IO don't match the layouts presented to the WebGPU API are not as clear as they could be. It would be nice if we could help people debug their pipelines more quickly.

This is probably not a super-high priority, but it would make the API easier to work with.

For example, I got the following message:

error: error matching VERTEX shader requirements against the pipeline, caused by: location[1] Float32x2 interpolated as Some(Perspective) with sampling Some(Center) is not provided by the previous stage outputs, caused by: input is not provided by the earlier stage in the pipeline

This was because I had the following vertex shader:

@vertex
fn vertex_shader(@location(0) center: vec2<f32>,
                 @location(1) corner: vec2<f32>)
                 -> @builtin(position) vec4<f32>
{
    ...
}

and the following vertex state:

        { // GPUVertexState
            module,
            entryPoint: 'vertex_shader',
            buffers: [
                { // GPUVertexBufferLayout
                    arrayStride: 8,
                    attributes: [
                        { // GPUVertexAttribute
                            format: 'float32x2',
                            offset: 0,
                            shaderLocation: 0,
                        },
                    ]
                }
            ]
        },

Obviously, vertex_shader is expecting two arguments and I'm only providing one.

Possible improvements:

  • Make it clearer that it's the vertex shader inputs that are the problem. The inclusion of interpolation information, which is irrelevant for vertex shader inputs, threw me off.
  • Refer to things by name (corner) not by index (location[1]).
  • Name the vertex shader.
  • Provide WGSL source locations.

jimblandy avatar Apr 20 '22 00:04 jimblandy