GPUTextureView: label 屬性
注意:此功能在 Web Workers 中可用。
GPUTextureView 介面的 label 屬性提供了一個可用於標識物件的標籤,例如在 GPUError 訊息或控制檯警告中。
這可以透過在傳遞給原始 GPUTexture.createView() 呼叫的描述符物件中提供 label 屬性來設定,或者您可以直接在 GPUTextureView 物件上獲取和設定它。
值
一個字串。如果之前未按上述方式設定,則為空字串。
示例
透過 GPUTextureView.label 設定和獲取標籤
js
// …
const depthTexture = device.createTexture({
size: [canvas.width, canvas.height],
format: "depth24plus",
usage: GPUTextureUsage.RENDER_ATTACHMENT,
});
const view = depthTexture.createView();
view.label = "my_view";
console.log(view.label); // "my_view"
透過原始 GPUTexture.createView() 呼叫設定標籤,然後透過 GPUTextureView.label 獲取
js
// …
const depthTexture = device.createTexture({
size: [canvas.width, canvas.height],
format: "depth24plus",
usage: GPUTextureUsage.RENDER_ATTACHMENT,
});
const view = depthTexture.createView({
label: "my_view",
});
console.log(view.label); // "my_view"
規範
| 規範 |
|---|
| WebGPU # dom-gpuobjectbase-label |
瀏覽器相容性
載入中…