webgpu-impl-buffer-upload
Installation
SKILL.md
WebGPU Buffer Upload and Readback
Moving data CPU to GPU (upload) and GPU to CPU (readback) in WebGPU 1.0-stable (Chrome 113+, Safari 26+, Firefox 141+), with the alignment rules that cause the most validation errors.
Quick Reference
| Upload path | When to use | Needs COPY_DST | API |
|---|---|---|---|
queue.writeBuffer |
Safe default for any CPU to GPU upload | yes | device.queue.writeBuffer(buf, offset, data) |
mappedAtCreation: true |
Initial vertex/index/uniform data, set once | no | createBuffer({ mappedAtCreation: true }) |
| Staging-buffer ring (2-3 buffers) | Large uploads issued every frame | yes (on destination) | mapAsync + copyBufferToBuffer |
| Readback path | When to use | API |
|---|---|---|
| Buffer readback | Read a storage/compute-written buffer | copyBufferToBuffer into a COPY_DST | MAP_READ buffer |
| Texture readback | Read pixels / download a texture | copyTextureToBuffer with 256-byte bytesPerRow padding |