<< All versions

Skill v1.0.0

currentLLM-judged scan95/100
leahycc/claude-skills/webgpu
──Details
PublishedOctober 23, 2026 at 07:02 PM
Content Hashsha256:9bd7a54af6870e68...
Git SHAcfa9cd1f33ff
──Files
Files (1 file, 6.7 KB)
SKILL.md6.7 KBactive
SKILL.md · 97 lines · 6.7 KB

version: "1.0.0" name: webgpu description: > Writes, reviews, and debugs WebGPU and WGSL code: adapter and device setup, feature detection and WebGL2 fallback, buffers and struct alignment, textures, bind groups, pipelines, depth, MSAA, compute shaders, the canvas frame loop, React integration, device loss, error scopes, GPU timing, and testing. Use when code touches navigator.gpu, GPUDevice, a .wgsl file, a WebGPU black canvas or validation error, or a WebGL port to WebGPU. Not for deciding whether WebGPU will make a page faster (spa-performance).


WebGPU

Writing WebGPU that works on the browsers you ship to, and does not fail silently when it does not. Whether WebGPU is the right fix for a slow page belongs to the spa-performance skill.

WebGPU almost never throws. A bad call returns an invalid object and reports the error later, and a lost device turns every call into a no-op. Wire up error reporting and device loss before anything else, or a black canvas is all you get.

If an engine owns the device, use the engine. In three.js, Babylon.js, or a library like TypeGPU, follow that library's API and its docs. Do not mix raw WebGPU calls into its frame unless it documents a way to. This skill is for code that owns its own device.

Source checks and dates: SOURCES.md.

Procedure

  1. Read setup.md. Detect, request only the features and limits the adapter has, and decide the fallback.
  2. Add the uncapturederror listener and device.lost handler from errors-and-device-loss.md. Label every object.
  3. For multi-pass or compute work, write down each pass first: what it reads, what it writes, and which buffer holds the current data afterwards.
  4. Read the resource for the thing you are building.
  5. For any struct shared with the CPU, run node scripts/wgsl-layout.mjs <file.wgsl> and use the offsets it prints. Add --uniform for uniform buffers.
  6. Check the resource's checklist, then report how far the code was checked, using the levels in debugging-and-testing.md.
navigator.gpu? -> adapter? -> device? --any no--> fallback, log why
|
error listener + device.lost
|
+------------------------+------------------------+
| | |
draw to canvas compute only both
canvas.md compute.md all three
render-basics.md |
| |
+--- buffers-and-textures.md, wgsl.md, pipelines.md ---+
|
check it: debugging-and-testing.md slow? profiling.md

Where to read

TaskResource
Support, detection, adapter, device, limits, fallback, old tutorialssetup.md
Error scopes, labels, device loss and recoveryerrors-and-device-loss.md
Usage flags, alignment, uploads, readback, textures, mipmapsbuffers-and-textures.md
Struct layout, the vec3 trap, uniformity, overrides, extensions, untrusted shaderswgsl.md
Async pipelines, explicit layouts, bind group frequency, instancingpipelines.md
Vertex layouts, depth, culling, blending, MSAA, video, porting from WebGLrender-basics.md
Configure, frame loop, resize, React, workerscanvas.md
Workgroups, dispatch, bounds, barriers, atomicscompute.md
GPU time with timestamp queriesprofiling.md
chrome://gpu, capture tools, offline WGSL checks, tests in Node and headless Chromedebugging-and-testing.md

The traps that cost the most time

SymptomUsual causeRead
Black canvas, no exceptionAn invalid object upstream. Read the first error, not the last.errors-and-device-loss.md
Values shifted or garbled in the shadervec3 is 16-byte aligned. The CPU packed it at 12. Run the layout script.wgsl.md
Works in dev, black after a while in productionDevice lost and never recoverederrors-and-device-loss.md
Bind group rejected by a second pipelineBoth used layout: 'auto'pipelines.md
Near objects vanish after a WebGL portProjection maps depth to -1..1. WebGPU clips at 0..1.render-basics.md
Far objects draw over near onesNo depth texture or depthStencil staterender-basics.md
Blurry or stretched outputCanvas size in CSS pixels, not device pixelscanvas.md
Device creation fails on some machinesA feature or limit requested that the adapter lackssetup.md
Big buffer binding rejected though the GPU is largeThe device got the default limit. Request it in requiredLimits.setup.md
Last elements never computedDispatch count truncated, not rounded upcompute.md
textureSample compile error inside an ifUniformity analysiswgsl.md
Video frame bind group errors after the first frameExternal textures expire. Import and bind each frame.render-basics.md
Two devices in development, one leakedReact Strict Mode cleanup ran during the async setupcanvas.md
GPU timer always reads zeroThe pass is shorter than the browser's timer quantumprofiling.md

Review checklist

  • [ ] Every way setup can fail reaches a fallback, and the reason is logged
  • [ ] An uncapturederror listener and a device.lost handler exist, and recovery starts from a new adapter
  • [ ] Every descriptor has a label
  • [ ] Features and limits are requested only when the adapter has them
  • [ ] Every CPU-shared struct has offsets from the layout script, not from hand counting
  • [ ] Pipelines are created async, outside the frame loop
  • [ ] getCurrentTexture() is called each frame, and the canvas is sized in device pixels
  • [ ] The projection maps depth to 0..1
  • [ ] Compute dispatches round up, and shaders bounds-check
  • [ ] Readback never makes a frame wait
  • [ ] Buffers, textures, and the device are destroyed on teardown
  • [ ] The report says how far the code was checked: types, WGSL, a real device, a browser
All versions