GPUCommandEncoder:label 属性
注意:此功能在 Web Workers 中可用。
label 是 GPUCommandEncoder 接口的只读属性,它是一个字符串,用于标识该对象,例如在 GPUError 消息或控制台警告中。
可以通过在传递给源 GPUDevice.createCommandEncoder() 调用的描述符对象中提供 label 属性来设置此值,也可以直接在 GPUCommandEncoder 对象上进行获取和设置。
值
一个字符串。如果之前没有设置标签值,则获取标签会返回一个空字符串。
示例
通过 GPUCommandEncoder.label 设置和获取标签
js
const commandEncoder = device.createCommandEncoder();
commandEncoder.label = "my_command_encoder";
console.log(commandEncoder.label); // "my_command_encoder"
通过源 GPUDevice.createCommandEncoder() 调用设置标签,然后通过 GPUCommandEncoder.label 获取标签
js
const commandEncoder = device.createCommandEncoder({
label: "my_command_encoder",
});
console.log(commandEncoder.label); // "my_command_encoder"
规范
| 规范 |
|---|
| WebGPU # dom-gpuobjectbase-label |
浏览器兼容性
加载中…