GPUComputePipeline

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 GPUComputePipeline của WebGPU API đại diện cho pipeline kiểm soát giai đoạn compute shader và có thể được sử dụng trong GPUComputePassEncoder.

Phiên bản đối tượng GPUComputePipeline có thể được tạo bằng phương thức GPUDevice.createComputePipeline() hoặc GPUDevice.createComputePipelineAsync().

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

label

Một chuỗi 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.

Phương thức phiên bản

getBindGroupLayout()

Trả về đối tượng GPUBindGroupLayout của pipeline với chỉ mục cho trước (tức là được bao gồm trong bố cục pipeline của lệnh gọi GPUDevice.createComputePipeline() hoặc GPUDevice.createComputePipelineAsync() gốc).

Ví dụ

Note: Mẫu WebGPU có nhiều ví dụ hơn.

Ví dụ cơ bản

Demo tính toán cơ bản của chúng ta hiển thị quá trình:

js
// …

const bindGroupLayout = device.createBindGroupLayout({
  entries: [
    {
      binding: 0,
      visibility: GPUShaderStage.COMPUTE,
      buffer: {
        type: "storage",
      },
    },
  ],
});

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

// …

Thông số kỹ thuật

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

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

Xem thêm