GPUComputePipeline
注意:此功能在 Web Workers 中可用。
GPUComputePipeline 介面是 WebGPU API 的一部分,它表示一個控制計算著色器階段的管道,並可用於 GPUComputePassEncoder。
GPUComputePipeline 物件例項可以透過 GPUDevice.createComputePipeline() 或 GPUDevice.createComputePipelineAsync() 方法建立。
例項屬性
例項方法
getBindGroupLayout()-
返回給定索引的管道的
GPUBindGroupLayout物件(即,包含在原始的GPUDevice.createComputePipeline()或GPUDevice.createComputePipelineAsync()呼叫中的管道佈局)。
示例
注意:WebGPU 示例 提供了更多示例。
基本示例
我們的 基本計算演示 展示了一個流程:
- 使用
GPUDevice.createBindGroupLayout()建立繫結組佈局。 - 將
bindGroupLayout輸入到GPUDevice.createPipelineLayout()中以建立GPUPipelineLayout。 - 立即在
createComputePipeline()呼叫中使用該值來建立GPUComputePipeline。
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",
},
});
// …
規範
| 規範 |
|---|
| WebGPU # gpucomputepipeline |
瀏覽器相容性
載入中…