GPUExternalTexture: 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 in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

Thuộc tính label của giao diện GPUExternalTexture cung cấp nhãn có thể được sử dụng để nhận dạng đối tượng, ví dụ trong thông báo GPUError hoặc cảnh báo bảng điều khiển.

Thuộc tính này có thể được đặt bằng cách cung cấp thuộc tính label trong đối tượng descriptor truyền vào lệnh gọi GPUDevice.importExternalTexture() nguồn gốc, hoặc bạn có thể lấy và đặt trực tiếp trên đối tượng GPUExternalTexture.

Giá trị

Một chuỗi. Nếu chưa được đặt như mô tả ở trên, nó sẽ là một chuỗi rỗng.

Ví dụ

Đặt và lấy nhãn thông qua GPUExternalTexture.label:

js
// …

const externalTexture = device.importExternalTexture({
  source: video,
});

externalTexture.label = "my_ext_texture";

console.log(externalTexture.label); // "my_ext_texture"

Đặt nhãn thông qua lệnh gọi GPUDevice.importExternalTexture() nguồn gốc, sau đó lấy qua GPUExternalTexture.label:

js
// …

const externalTexture = device.importExternalTexture({
  source: video,
  label: "my_ext_texture",
});

console.log(externalTexture.label); //  "my_ext_texture"

Thông số kỹ thuật

Specification
WebGPU
# dom-gpuobjectbase-label

Tương thích trình duyệt

Xem thêm