GPURenderPassEncoder: label property
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 insecure contexts (HTTPS), in some or allsupporting browsers.
Note: This feature is available inWeb Workers.
Thelabel read-only property of theGPURenderPassEncoder interface is a string providing a label that can be used to identify the object, for example inGPUError messages or console warnings.
This can be set by providing alabel property in the descriptor object passed into the originatingGPUCommandEncoder.beginRenderPass() call, or you can get and set it directly on theGPURenderPassEncoder object.
In this article
Value
A string. If no label value has previously been set, getting the label returns an empty string.
Examples
Setting and getting a label viaGPURenderPassEncoder.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"Setting a label via the originatingGPUCommandEncoder.beginRenderPass() call, and then getting it viaGPURenderPassEncoder.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"Specifications
| Specification |
|---|
| WebGPU> # dom-gpuobjectbase-label> |
Browser compatibility
See also
- TheWebGPU API