GPUCompilationMessage: type 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

安全上下文: 此功能仅在安全上下文(HTTPS)中可用,且支持此功能的浏览器数量有限。

注意:此功能在 Web Workers 中可用。

GPUCompilationMessage 接口的只读属性 type 是一个枚举值,表示消息的类型。每种类型代表不同的严重级别。

一个枚举值。可能的值是:

"error"

着色器创建错误,会导致编译失败。

"info"

纯粹的信息性消息,严重程度低。

"warning"

有关不会阻止成功编译但值得开发者关注的问题的警告。例如,使用了已弃用的函数或语法。

示例

js
const shaderModule = device.createShaderModule({
  code: shaders,
});

const shaderInfo = await shaderModule.getCompilationInfo();
const firstMessage = shaderInfo.messages[0];
console.log(firstMessage.type);

有关更详细的示例,请参阅主要的 GPUCompilationInfo 页面

规范

规范
WebGPU
# dom-gpucompilationmessage-type

浏览器兼容性

另见