()
| 32 | } |
| 33 | |
| 34 | async init() { |
| 35 | const shaderModule = await this.loadShader("hello_triangle"); |
| 36 | |
| 37 | this.vertexBuffer = this.createBuffer({ |
| 38 | label: "Vertex Buffer", |
| 39 | data: this.vertices, |
| 40 | usage: GPUBufferUsage.VERTEX, |
| 41 | }); |
| 42 | |
| 43 | this.indexBuffer = this.createBuffer({ |
| 44 | label: "Index Buffer", |
| 45 | data: this.indices, |
| 46 | usage: GPUBufferUsage.INDEX, |
| 47 | }); |
| 48 | |
| 49 | this.renderPipeline = this.device.createRenderPipeline({ |
| 50 | vertex: { |
| 51 | module: shaderModule, |
| 52 | entryPoint: "vs_main", |
| 53 | buffers: [ |
| 54 | { |
| 55 | arrayStride: 4 * 3 + 4 * 4, |
| 56 | stepMode: "vertex", |
| 57 | attributes: [ |
| 58 | { |
| 59 | offset: 0, |
| 60 | shaderLocation: 0, |
| 61 | format: "float32x3", |
| 62 | }, |
| 63 | { |
| 64 | offset: 4 * 3, |
| 65 | shaderLocation: 1, |
| 66 | format: "float32x4", |
| 67 | }, |
| 68 | ], |
| 69 | }, |
| 70 | ], |
| 71 | }, |
| 72 | fragment: { |
| 73 | module: shaderModule, |
| 74 | entryPoint: "fs_main", |
| 75 | targets: [ |
| 76 | { |
| 77 | format: this.format, |
| 78 | }, |
| 79 | ], |
| 80 | }, |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | render(encoder, view) { |
| 85 | const renderPass = encoder.beginRenderPass({ |
nothing calls this directly
no test coverage detected