webgpu-impl-webgl-migration
Installation
SKILL.md
WebGL to WebGPU Migration
Map every WebGL concept to its WebGPU equivalent and avoid the two ports that silently break: clip-space Z range and the removed automatic mipmap generation. Targets WebGPU 1.0-stable (Chrome 113+, Safari 26+, Firefox 141+).
Quick Reference
| WebGL concept | WebGPU equivalent |
|---|---|
Immediate-mode gl.draw* against global state |
Record commands into a GPUCommandEncoder, submit a GPUCommandBuffer via queue.submit |
Global state machine (gl.enable, gl.bindBuffer, gl.blendFunc) |
Immutable GPURenderPipeline capturing blend, topology, depth, cull state |
| GLSL shaders | WGSL shaders |
Uniforms set by name (gl.getUniformLocation) |
GPUBindGroup + GPUBindGroupLayout, positional @group(g) @binding(b) |
| Framebuffer objects (FBOs) | Render pass colorAttachments / depthStencilAttachment |
gl.getError() synchronous |
Asynchronous pushErrorScope / popErrorScope + uncapturederror event |
gl.generateMipmap() |
Manual mipmap generation (render-pass downsample chain or compute pass) |
| Resizable buffers/textures via re-upload | Immutable size/format; destroy and recreate the resource to resize |
Uniform buffer 64 KB limit (maxUniformBufferBindingSize 65536) |
Storage buffers (maxStorageBufferBindingSize 134217728, 128 MiB+) |
gl.viewport / clip Z [-1, 1] |
Clip Z [0, 1]; rebuild the projection matrix |
gl.texImage2D upload |
queue.writeTexture or copyExternalImageToTexture |