(
texture: BrowserGpuTexture,
pixels: Uint8Array
)
| 347 | }; |
| 348 | |
| 349 | const uploadTexture = ( |
| 350 | texture: BrowserGpuTexture, |
| 351 | pixels: Uint8Array |
| 352 | ) => { |
| 353 | const bytesPerRow = Math.ceil((width * 4) / 256) * 256; |
| 354 | const upload = new Uint8Array(bytesPerRow * height); |
| 355 | for (let y = 0; y < height; y++) { |
| 356 | upload.set( |
| 357 | pixels.subarray(y * width * 4, (y + 1) * width * 4), |
| 358 | y * bytesPerRow |
| 359 | ); |
| 360 | } |
| 361 | device!.queue.writeTexture( |
| 362 | { texture }, |
| 363 | upload, |
| 364 | { bytesPerRow, rowsPerImage: height }, |
| 365 | { width, height } |
| 366 | ); |
| 367 | }; |
| 368 | |
| 369 | const createAndWriteUniformBuffer = (data: Uint32Array): BrowserGpuBuffer => { |
| 370 | const buffer = device!.createBuffer({ |
no test coverage detected