| 316 | } |
| 317 | |
| 318 | clear() { |
| 319 | const commandEncoder = this.device.createCommandEncoder(); |
| 320 | const passEncoder = commandEncoder.beginRenderPass({ |
| 321 | colorAttachments: [ |
| 322 | { |
| 323 | view: this.canvasContext.getCurrentTexture().createView(), |
| 324 | clearValue: { r: 0.0, g: 0.0, b: 0.0, a: 1.0 }, |
| 325 | loadOp: "clear", |
| 326 | storeOp: "store", |
| 327 | }, |
| 328 | ], |
| 329 | }); |
| 330 | passEncoder.setPipeline(this.clearPipeline); |
| 331 | const renderBindingGroup = this.device.createBindGroup({ |
| 332 | layout: this.renderPipeline.getBindGroupLayout(0), |
| 333 | entries: [ |
| 334 | { binding: 0, resource: this.renderSampler }, |
| 335 | { binding: 1, resource: this.stagingTexture.createView() }, |
| 336 | ], |
| 337 | }); |
| 338 | passEncoder.setBindGroup(0, renderBindingGroup); |
| 339 | passEncoder.draw(6, 1, 0, 0); |
| 340 | passEncoder.end(); |
| 341 | this.device.queue.submit([commandEncoder.finish()]); |
| 342 | } |
| 343 | |
| 344 | draw(buffer: GPUBuffer, height: number, width: number) { |
| 345 | // resize the staging texture |