static #uboView: DataView
static #resultView: DataView
static #bindGroupLayout: GPUBindGroupLayout
+ static #bindGroup: GPUBindGroup
static #searchPipeline: GPUComputePipeline
static #validatePipeline: GPUComputePipeline
module: shaderModule
}
})
+ // Bind UBO read and GPU write buffers
+ this.#bindGroup = this.#device.createBindGroup({
+ layout: this.#bindGroupLayout,
+ entries: [
+ {
+ binding: 0,
+ resource: {
+ buffer: this.#uboBuffer
+ },
+ },
+ {
+ binding: 1,
+ resource: {
+ buffer: this.#gpuBuffer
+ },
+ },
+ ],
+ })
// Create pipeline to connect compute shader to binding layout
this.#validatePipeline = this.#device.createComputePipeline({
layout: this.#device.createPipelineLayout({
this.#device.queue.writeBuffer(this.#gpuBuffer, 0, this.#bufferReset)
this.#device.queue.writeBuffer(this.#cpuBuffer, 0, this.#bufferReset)
- // Bind UBO read and GPU write buffers
- const bindGroup = this.#device.createBindGroup({
- layout: this.#bindGroupLayout,
- entries: [
- {
- binding: 0,
- resource: {
- buffer: this.#uboBuffer
- },
- },
- {
- binding: 1,
- resource: {
- buffer: this.#gpuBuffer
- },
- },
- ],
- })
-
// Create command encoder to issue commands to GPU and initiate computation
const commandEncoder = this.#device.createCommandEncoder()
const passEncoder = commandEncoder.beginComputePass()
// Issue commands and end compute pass structure
passEncoder.setPipeline(pipeline)
- passEncoder.setBindGroup(0, bindGroup)
+ passEncoder.setBindGroup(0, this.#bindGroup)
passEncoder.dispatchWorkgroups(passes, passes)
passEncoder.end()