demo · v132

WebGPU texture format capabilities

Every WebGPU texture format has rules: can it be sampled? Stored? Blended? Used as render target? Here's the matrix, with v132's row highlighted — r32float, rg32float, rgba32float now allow blending if the float32-blendable feature is enabled.

checking support…
formatsamplestoragerenderblend (default)blend (float32-blendable)
r8unormyesnoyesyesyes
rgba8unormyesyesyesyesyes
r16floatyesnoyesyesyes
rgba16floatyesyesyesyesyes
r32float (v132)yesyesyesnoyes
rg32float (v132)yesyesyesnoyes
rgba32float (v132)yesyesyesnoyes
depth24plusyes (depth)noyesnono

request the feature

const adapter = await navigator.gpu.requestAdapter();
if (!adapter.features.has("float32-blendable")) {
  console.log("device cannot blend 32-bit float textures");
}
const device = await adapter.requestDevice({
  requiredFeatures: ["float32-blendable"],
});

// now r32float / rg32float / rgba32float
// participate in fragment-stage alpha blending
const pipeline = device.createRenderPipeline({
  fragment: {
    targets: [{
      format: "rgba32float",
      blend: {
        color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha" },
        alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha" },
      }
    }]
  },
  // ...
});

see also