v148 · WebGPU

Compatibility Rendering

A shader designed to run identically in both core and compatibility mode. It deliberately avoids fine derivatives, storage buffers in the vertex stage, and per-attachment blend states — the features removed in compat.

Feature detection: checking…
The WGSL shader below uses only features present in both core and compatibility mode: dpdx/dpdy (coarse, not fine), uniform blend state, no vertex storage buffers. The result is a shader that runs everywhere WebGPU runs — including older devices where only the compat adapter is available.
Detecting adapter…
// WGSL — compatible with both core and compat mode
// Avoids: dpdxFine, dpdyFine, storage buffers in vertex stage,
//         linear interpolation, cube array textures

@vertex fn vs(@builtin(vertex_index) vi: u32) -> VSOut {
  // Full-screen triangle — no vertex buffer needed
  var p = array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));
  var out: VSOut;
  out.pos = vec4f(p[vi], 0, 1);
  out.uv  = (p[vi] + vec2f(1)) * 0.5;
  return out;
}

@fragment fn fs(in: VSOut) -> @location(0) vec4f {
  let uv = in.uv;
  // dpdx/dpdy (coarse) — OK in compat; dpdxFine is NOT
  let edge = abs(dpdx(uv.x)) + abs(dpdy(uv.y));
  let grid = step(0.02, fract(uv * 8.0));
  return vec4f(grid.x * grid.y * 0.8, uv.x * 0.5, uv.y * 0.7, 1);
}

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗