← 03 实验索引

阶段间变量:改一项看报错

顶点着色器输出、片段着色器接收,靠的是 @location 的数字,不是变量名。把两边改得对不上,看浏览器报什么错——错误原文原样打在下面,不做任何改写。

顶点输出片段输入 @location 类型 @interpolate

      
正在启动 WebGPU…

画得出来才说明这三项都对上了。报错时画布保持上一次的内容。

规范怎么说

WebGPU 规范校验渲染管线时的原文(spec/index.bs):

For each user-defined input of descriptor.fragment there
must be a user-defined output of descriptor.vertex that
matches the location, type, and interpolation of the input.

三项都要对上:location、类型、插值。另外 WGSL 规范要求阶段间传整数 (i32 / u32)必须写 flat,这条在着色器编译阶段就会被拦下, 比管线校验更早报错。