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