setLabel method

  1. @override
void setLabel(
  1. Object resource,
  2. String label
)

Passes the label to the browser, which names the object in its own validation errors and in a frame capture, and keeps it for labelOf.

Implementation

@override
void setLabel(Object resource, String label) {
  super.setLabel(resource, label);
  final backend = switch (resource) {
    TextureHandle(:final backend) => backend,
    StorageBuffer(:final backend) => backend,
    QuerySet(:final backend) => backend,
    ComputePipelineHandle(:final backend) => backend,
    _ => null,
  };
  switch (backend) {
    case WebGpuTexture(:final texture):
      texture.label = label;
    case WebGpuStorage(:final buffer):
      buffer.label = label;
    case GPUQuerySet():
      backend.label = label;
    case WebGpuComputePipeline(:final pipeline):
      pipeline.label = label;
  }
}