| 355 | } |
| 356 | |
| 357 | fn blit_into_atlas( |
| 358 | enc: &mut wgpu::CommandEncoder, |
| 359 | cell: &wgpu::Texture, |
| 360 | atlas: &wgpu::Texture, |
| 361 | i: u32, |
| 362 | j: u32, |
| 363 | cell_px: u32, |
| 364 | ) { |
| 365 | enc.copy_texture_to_texture( |
| 366 | wgpu::TexelCopyTextureInfo { |
| 367 | texture: cell, |
| 368 | mip_level: 0, |
| 369 | origin: wgpu::Origin3d::ZERO, |
| 370 | aspect: wgpu::TextureAspect::All, |
| 371 | }, |
| 372 | wgpu::TexelCopyTextureInfo { |
| 373 | texture: atlas, |
| 374 | mip_level: 0, |
| 375 | origin: wgpu::Origin3d { x: i * cell_px, y: j * cell_px, z: 0 }, |
| 376 | aspect: wgpu::TextureAspect::All, |
| 377 | }, |
| 378 | wgpu::Extent3d { width: cell_px, height: cell_px, depth_or_array_layers: 1 }, |
| 379 | ); |
| 380 | } |
| 381 | |
| 382 | /// Copy texture to a CPU-mappable buffer, handling wgpu's 256-byte |
| 383 | /// row-pitch alignment, and return the unpadded pixel bytes. |