GPUPipelineError

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.

Giao diện GPUPipelineError của WebGPU API mô tả lỗi pipeline. Đây là giá trị nhận được khi Promise được trả về bởi lệnh gọi GPUDevice.createComputePipelineAsync() hoặc GPUDevice.createRenderPipelineAsync() bị từ chối.

DOMException GPUPipelineError

Hàm khởi tạo

GPUPipelineError()

Tạo phiên bản đối tượng GPUPipelineError mới.

Thuộc tính phiên bản

Kế thừa các thuộc tính từ cha, DOMException.

reason Read only

Giá trị được liệt kê xác định lý do tạo pipeline thất bại theo cách máy có thể đọc được.

Ví dụ

Trong đoạn code sau, chúng ta đang cố gắng tạo GPUComputePipeline bằng GPUDevice.createComputePipelineAsync(). Tuy nhiên, chúng ta đã viết sai entryPoint của pipeline tính toán là "maijn" (lẽ ra phải là "main"), do đó việc tạo pipeline thất bại và khối catch in lý do và thông báo lỗi kết quả ra console.

js
// …

let computePipeline;

try {
  computePipeline = await device.createComputePipelineAsync({
    layout: device.createPipelineLayout({
      bindGroupLayouts: [bindGroupLayout],
    }),
    compute: {
      module: shaderModule,
      entryPoint: "maijn",
    },
  });
} catch (error) {
  // error is a GPUPipelineError object instance
  console.error(error.reason);
  console.error(`Pipeline creation failed: ${error.message}`);
}

// …

Trong trường hợp này, reason"Validation"message"Entry point "maijn" doesn't exist in the shader module [ShaderModule].".

Thông số kỹ thuật

Thông số kỹ thuật
WebGPU
# gpupipelineerror

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

Xem thêm