Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Webgpu Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-webgpu-knowledge-patch)
---
name: webgpu-knowledge-patch
description: WebGPU / WGSL
version: "Chrome 150"
license: MIT
metadata:
author: Nevaberry
---
# WebGPU / WGSL compatibility guidance
Load this skill when updating WebGPU or WGSL code, checking feature support,
or migrating native Dawn and Emdawnwebgpu applications. Use the quick reference
for API migrations and feature requirements; open the topic references for
complete guidance, examples, and release-specific behavior.
## Reference index
| Reference | Topics |
| --- | --- |
| [Adapters and compatibility](references/adapters-and-compatibility.md) | Device requests, compatibility selection, core capabilities, limits, adapter information |
| [Native Dawn and Emdawnwebgpu](references/native-dawn-and-emscripten.md) | Native API migrations, headers, builds, platform requirements, callbacks, diagnostics, browser bindings |
| [Platforms and integration](references/platforms-and-integration.md) | Linux, Android bindings, WebXR, canvas export, HTML-in-Canvas, linear color spaces |
| [Resources and rendering](references/resources-and-rendering.md) | Validation, bindings, copies, compression, texture formats, transient attachments, vertex formats, worker mapping |
| [WGSL and shaders](references/wgsl-and-shaders.md) | Subgroups, memory layouts, buffer views, immediates, shader inputs and outputs, texture operations |
## Breaking changes and deprecations
### Device requests and adapter information
After `GPUAdapter.requestDevice()` succeeds, later calls on that adapter reject
their promises. Call `navigator.gpu.requestAdapter()` again before requesting
another device.
`GPUAdapter.isFallbackAdapter` has been removed. Read
`adapter.info.isFallbackAdapter` or `device.adapterInfo.isFallbackAdapter`.
The reference preserves the release-specific restriction on the reported value.
`maxInterStageShaderComponents` has been removed. Use
`maxInterStageShaderVariables` and count inter-stage variables when checking
shader interfaces against the device limit.
### Buffer, shader, and texture validation
`GPUDevice.createBuffer()` throws a synchronous `RangeError` when
`mappedAtCreation` is `true` and `size` is not a multiple of four bytes. Handle
the exception at the call site if code previously relied on a GPU validation
error scope.
WGSL rejects an explicit `@align(n)` smaller than a struct member's required
alignment. For a `vec4f` member, `@align(16)` satisfies the requirement.
`"float32-filterable"` no longer makes 32-bit float render targets blendable.
Enable `"float32-blendable"` on the device before creating a pipeline that blends
into those targets.
Read-only storage bindings using `"bgra8unorm"` fail validation. Use write-only
storage access with this format.
Dawn rejects filtering samplers used to sample depth textures. Use a
non-filtering sampler for ordinary sampling or a comparison sampler for depth
comparisons.
### Native API migrations
| Previous API | Migration |
| --- | --- |
| `WGPUProgrammableStageDescriptor` | Use `WGPUComputeState` for a compute pipeline's compute state. |
| `wgpu::VertexStepMode::VertexBufferNotUsed` | Use `wgpu::VertexStepMode::Undefined` with `attributeCount` zero for an unused layout. |
| `WGPURequiredLimits`, `WGPUSupportedLimits` | Use `WGPULimits`; limit fields are directly on it. |
| `WGPUImageCopyBuffer` | Use `WGPUTexelCopyBufferInfo`. |
| `WGPUImageCopyTexture` | Use `WGPUTexelCopyTextureInfo`. |
| `WGPUTextureDataLayout` | Use `WGPUTexelCopyBufferLayout`. |
| `EnumerateWGSLLanguageFeatures()` | Call `instance.GetWGSLLanguageFeatures()` on a `wgpu::Instance`. |
| `InstanceDropped` | Use `CallbackCancelled`; associated work can continue after callback cancellation. |
| `wgpu::PopErrorScopeStatus::EmptyStack` | Use `wgpu::PopErrorScopeStatus::Error`; the callback includes an error message. |
| `wgpu::FeatureName::R8UnormStorage`, `wgpu::FeatureName::Snorm16TextureFormats` | Request `wgpu::FeatureName::TextureFormatsTier1`; tier 1 omits resolve support for 16-bit signed normalized formats. |
`wgpuInstanceGetWGSLLanguageFeatures()` returns `void`; remove checks of its
former `WGPUStatus` return value. Update `WGPUQueueWorkDoneCallback`
implementations to accept the new `message` argument alongside the status.
### Emscripten migration
Migrate browser WebAssembly builds using `webgpu.h` from Emscripten's unmaintained
`USE_WEBGPU` bindings to `emdawnwebgpu`. Replace `-sUSE_WEBGPU` with
`--use-port=emdawnwebgpu`; Emscripten 4.0.10 or later includes a snapshot.
```sh
emcc --use-port=emdawnwebgpu app.c -o app.html
```
## Compatibility selection and limits
`requestAdapter()` uses `featureLevel: "compatibility"` in place of
`compatibilityMode`; the supported levels are `"core"` (the default) and
`"compatibility"`. The experimental `GPUAdapter.featureLevel` and
`GPUAdapter.isCompatibilityMode` properties were removed.
With Unsafe WebGPU Support enabled, `"core-features-and-limits"` on a device
lifts compatibility-mode feature and limit restrictions. A compatibility request can return a core-defaulting
adapter, which enables the feature on every device. A compatibility-defaulting
adapter can enable it on request if it advertises support. Check the resulting
device's features to determine which validation rules apply. See the adapter
reference for flag requirements and changes in default availability.
Applications that stay within the compatibility subset run unchanged in
browsers implementing only core WebGPU. Run tests that expect
compatibility-specific validation errors on a device with those restrictions
active.
`maxStorageBuffersInVertexStage` can be zero on compatibility devices. Check
the device's limit before selecting a shader variant using vertex storage-buffer
bindings. Unknown `requiredLimits` keys with value `undefined` are ignored by
`requestDevice()`, allowing an adapter limit that may be absent to pass through.
## Subgroups and WGSL feature checks
Request `"subgroups"`; `"chromium-experimental-subgroups"` and
`"chromium-experimental-subgroup-uniform-control-flow"` were removed, and
`"subgroups-f16"` was deprecated. For `f16` subgroup operations, request both
`"subgroups"` and `"shader-f16"` in `requiredFeatures`.
Subgroups are stable. In compute and fragment shaders, `enable subgroups;`
makes collective operations and `subgroup_invocation_id` and `subgroup_size`
available. Read adapter size bounds from `adapter.info.subgroupMinSize` and
`adapter.info.subgroupMaxSize` when the adapter exposes `"subgroups"`.
Check `navigator.gpu?.wgslLanguageFeatures.has("subgroup_id")` and use
`requires subgroup_id;` for compute `subgroup_id` and `num_subgroups` inputs.
For fixed-width subgroup slots, use
`subgroup_id * subgroup_size + subgroup_invocation_id`, allowing gaps when a
subgroup is partially filled.
Check `navigator.gpu.wgslLanguageFeatures.has("subgroup_uniformity")` before
using subgroup-uniform conditions to guard subgroup or quad built-ins.
`enable subgroup_size_control;` also enables `subgroups`.
| Language feature check in `navigator.gpu.wgslLanguageFeatures` | Guidance |
| --- | --- |
| `"uniform_buffer_standard_layout"` | Declare `requires uniform_buffer_standard_layout;` for uniform buffers with the same layout constraints as storage buffers, including natural array strides and nested-struct offsets. |
| `"buffer_view"` | Declare `requires buffer_view;`; `bufferView<T>()` returns a typed pointer at a byte offset, `bufferArrayView<array<T>>()` bounds an array view by an element count, and `bufferLength()` returns bytes. |
| `"linear_indexing"` | Declare `requires linear_indexing;` for `u32` compute inputs `global_invocation_index` and `workgroup_index`, flattening the dispatch grid with X varying fastest. |
| `"swizzle_assignment"` | Declare `requires swizzle_assignment;` to assign several components of a mutable vector in one statement. |
| `"texture_and_sampler_let"` | Allows function-local `let` bindings for textures and samplers. |
| `"texture_formats_tier1"` | Use the underscore spelling to detect the WGSL extension. |
| `"fragment_depth"` | Declare `requires fragment_depth;`; `@builtin(frag_depth, less)` or `@builtin(frag_depth, greater)` constrains output relative to interpolated depth and allows early depth testing. |
## Immediate data
Check `navigator.gpu.wgslLanguageFeatures` for `"immediate_address_space"` and
declare `requires immediate_address_space;`. Use `var<immediate>` and
`pass.setImmediates()` to pass small values directly to a shader before drawing.
A pipeline with `layout: "auto"` infers the required `immediateSize`.
Declare immediate variables at module scope, read-only and without initializers.
Types must be concrete, constructible, and host-shareable, with no arrays even
in nested members. Each entry point can statically use at most one immediate
variable, including references through called functions.
For explicit layouts, set `immediateSize` to cover the full WGSL size, including
padding. It defaults to zero and is capped by `device.limits.maxImmediateSize`,
whose default is 64 bytes. All shader stages share one byte range; size it for
the largest immediate declaration used by the pipeline.
The destination offset and bytes copied by `setImmediates()` must be multiples
of four. Source offset and size count elements for a `TypedArray`, bytes for
other buffer sources. Before drawing or dispatching, set every four-byte slot
used by any shader stage; padding-only slots may remain unset. Pipelines with
the same `immediateSize` can reuse values already set.
Each encoder starts with every slot unset, and each render bundle starts
execution with all slots unset. Supply a bundle's own values on its encoder;
this can precede `setPipeline()`. Pass and bundle encoders copy supplied bytes
at encoding time. `executeBundles()` clears the render pass's slots, so set
required values again before the next direct draw.
## Transient render attachments
For contents needed only within one render pass, combine
`GPUTextureUsage.TRANSIENT_ATTACHMENT` with `GPUTextureUsage.RENDER_ATTACHMENT`.
Clear at the start and discard at the end, including each depth or stencil
aspect present in a transient attachment.
A transient texture must be 2D with one mip level and one array layer. Both the
texture and its views must use exactly
`GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TRANSIENT_ATTACHMENT`.
Omit `viewFormats` or use `viewFormats: []`; a nonempty list fails validation.
A multisample `resolveTarget` must use a texture created without the transient
usage bit. Passing `TRANSIENT_ATTACHMENT` in `GPUCanvasContext.configure()`
usage throws a `TypeError`.
## Resource shortcuts and texture capabilities
A bind group entry can take a `GPUBuffer` directly with offset zero and full
buffer size; use `GPUBufferBinding` for an explicit offset or size. A
`GPUTexture` directly supplies its default view in bind group resources, color
attachment `view` and `resolveTarget`, and depth/stencil attachment `view`.
For equal-sized buffers, `encoder.copyBufferToBuffer(source, destination)`
copies the whole buffer with both offsets defaulting to zero.
Request `"texture-component-swizzle"` before passing `swizzle` to
`GPUTexture.createView()`. Its four characters select output red, green, blue,
and alpha from `r`, `g`, `b`, `a`, `0`, or `1`.
Request a sliced-3D compression feature together with its matching BC or ASTC
base feature. Request `"texture-compression-unaligned"` alongside the chosen
compression-family feature for dimensions not divisible by the block dimensions.
`"texture-formats-tier2"` enables tier 1 as well; the resource reference details
the formats and access modes each tier adds.
## Experimental buffer mapping
Launch with `--enable-features=WebGPUMapSyncOnWorkers` to try
`GPUBuffer.mapSync()` in a worker. It blocks until the buffer is mapped; use
`mapAsync()` as a fallback when the method is unavailable.
In Dawn, the experimental `wgpu::FeatureName::BufferMapWriteExtendedUsages`
device feature allows `wgpu::BufferUsage::MapWrite` with any usage except
`MapRead`. On Vulkan and D3D12, this permits direct writes into GPU-usable
buffers such as storage buffers.