GPURenderPassEncoder: thuộc tính label
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
Thuộc tính chỉ đọc label của giao diện GPURenderPassEncoder là một chuỗi cung cấp nhãn có thể được dùng để nhận dạng đối tượng, ví dụ trong các thông báo GPUError hoặc cảnh báo console.
Nhãn có thể được đặt bằng cách cung cấp thuộc tính label trong đối tượng descriptor được truyền vào lệnh gọi GPUCommandEncoder.beginRenderPass() nguồn gốc, hoặc bạn có thể lấy và đặt nó trực tiếp trên đối tượng GPURenderPassEncoder.
Giá trị
Một chuỗi. Nếu không có giá trị nhãn nào được đặt trước đó, việc lấy nhãn sẽ trả về một chuỗi rỗng.
Ví dụ
Đặt và lấy nhãn thông qua GPURenderPassEncoder.label:
const commandEncoder = device.createCommandEncoder();
const renderPassDescriptor = {
colorAttachments: [
{
clearValue: clearColor,
loadOp: "clear",
storeOp: "store",
view: context.getCurrentTexture().createView(),
},
],
};
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
passEncoder.label = "my_render_pass_encoder";
console.log(passEncoder.label); // "my_render_pass_encoder"
Đặt nhãn thông qua lệnh gọi GPUCommandEncoder.beginRenderPass() nguồn gốc, sau đó lấy nó thông qua GPURenderPassEncoder.label:
const commandEncoder = device.createCommandEncoder();
const renderPassDescriptor = {
colorAttachments: [
{
clearValue: clearColor,
loadOp: "clear",
storeOp: "store",
view: context.getCurrentTexture().createView(),
},
],
label: "my_render_pass_encoder",
};
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
console.log(passEncoder.label); // "my_render_pass_encoder"
Thông số kỹ thuật
| Specification |
|---|
| WebGPU> # dom-gpuobjectbase-label> |