GPUCompilationMessage: lineNum 属性
注意:此功能在 Web Workers 中可用。
GPUCompilationMessage 接口的只读属性 lineNum 是一个数字,表示消息对应的着色器代码中的行号。
值
一个数字。
请注意:
- 如果消息对应的是一个子字符串,
lineNum将指向该子字符串开始的行号。 - 如果消息不对应具体的代码行(可能指整个着色器代码),
lineNum将为 0。 - 值是从 1 开始计数的——值为 1 表示代码的第一行。
- 行由换行符分隔。在 WGSL 中,特定字符列表 被定义为换行符。
示例
js
const shaderModule = device.createShaderModule({
code: shaders,
});
const shaderInfo = await shaderModule.getCompilationInfo();
const firstMessage = shaderInfo.messages[0];
console.log(firstMessage.lineNum);
有关更详细的示例,请参阅主要的 GPUCompilationInfo 页面。
规范
| 规范 |
|---|
| WebGPU # dom-gpucompilationmessage-linenum |
浏览器兼容性
加载中…