GPUSampler: label property
注意:此功能在 Web Workers 中可用。
GPUSampler 接口的 label 属性提供了一个标签,可用于标识对象,例如在 GPUError 消息或控制台警告中。
这可以通过在传入原始的 GPUDevice.createSampler() 调用的描述符对象中提供 label 属性来设置,也可以直接在 GPUSampler 对象上获取和设置。
值
一个字符串。如果之前未按上述方式设置,则为空字符串。
示例
通过 GPUSampler.label 设置和获取标签
js
// …
const sampler = device.createSampler({
compare: "less",
});
sampler.label = "my_sampler";
console.log(sampler.label); // "my_sampler"
通过原始的 GPUDevice.createSampler() 调用设置标签,然后通过 GPUSampler.label 获取它
js
// …
const sampler = device.createSampler({
compare: "less",
label: "my_sampler",
});
console.log(sampler.label); // "my_sampler"
规范
| 规范 |
|---|
| WebGPU # dom-gpuobjectbase-label |
浏览器兼容性
加载中…