GPUComputePipeline: label property

Khả dụng hạn chế

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 GPUComputePipeline cung cấp nhãn có thể được sử dụng để xác định đối tượng, ví dụ trong các thông báo GPUError hoặc cảnh báo console.

Điều này 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 GPUDevice.createComputePipeline() hoặc GPUDevice.createComputePipelineAsync() gốc, hoặc bạn có thể lấy và đặt trực tiếp trên đối tượng GPUComputePipeline.

Giá trị

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

Ví dụ

Đặt và lấy nhãn qua GPUComputePipeline.label:

js
// …

const computePipeline = device.createComputePipeline({
  layout: device.createPipelineLayout({
    bindGroupLayouts: [bindGroupLayout],
  }),
  compute: {
    module: shaderModule,
    entryPoint: "main",
  },
});

computePipeline.label = "my_compute_pipeline";

console.log(computePipeline.label); // "my_compute_pipeline"

Đặt nhãn qua lệnh gọi GPUDevice.createComputePipeline(), sau đó lấy qua GPUComputePipeline.label:

js
// …

const computePipeline = device.createComputePipeline({
  layout: device.createPipelineLayout({
    bindGroupLayouts: [bindGroupLayout],
  }),
  compute: {
    module: shaderModule,
    entryPoint: "main",
  },
  label: "my_compute_pipeline",
});

console.log(computePipeline.label); // "my_compute_pipeline"

Thông số kỹ thuật

Thông số kỹ thuật
WebGPU
# dom-gpuobjectbase-label

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

Xem thêm