WebGPU の新機能(Chrome 153 ~ 154)

François Beaufort
François Beaufort

公開日: 2026 年 9 月 15 日

WGSL buffer_view 拡張機能

WGSL 言語拡張機能 buffer_view を使用すると、uniform、storage、workgroup 変数のデータを複数の異なる型として解釈できます。これは、従来の型パニングの使用から、変数を複数の論理変数に分割するまで、幅広い用途があります。

安全性と実装の簡素化のため、再解釈された型には次の組み込み関数を使用してのみアクセスできます。

  • bufferView<T>() は、特定のバイト オフセットのメモリを型 T へのポインタとして解釈します。
  • bufferArrayView<T>() は、明示的な要素数で境界付き配列ポインタを作成します。
  • bufferLength() は、バッファのバイトサイズを返します。

この言語拡張機能は、navigator.gpu.wgslLanguageFeatures を使用して JavaScript で機能検出できます。WGSL シェーダー コードの先頭で、requires-directive を使用して requires buffer_view での移植性の可能性を通知することをおすすめします。次の WGSL の例と出荷の意向をご覧ください。

requires buffer_view;

//  +-------------------+-----------------------------+----------------------------+
//  | Byte 0 .. 3       | Byte 4 .. (4 + N - 1)       | Byte (4 + N) .. End        |
//  +-------------------+-----------------------------+----------------------------+
//  | indices_size (u32)| indices (array<u32, count>) | vertices (array<f32>)      |
//  +-------------------+-----------------------------+----------------------------+
@group(0) @binding(0) var<storage> indices_and_vertices : buffer;

fn unpack_and_process_geometry() {
  let indices_size = *bufferView<u32>(&indices_and_vertices, 0);

  let indices = bufferArrayView<array<u32>>(&indices_and_vertices, 4, indices_size);
  let vertices = bufferView<array<f32>>(&indices_and_vertices, indices_size + 4);
  ...
}

詳細については、バッファビューの提案をご覧ください。また、ワイヤーフレーム WebGPU サンプルを試すこともできます。

WGSL swizzle_assignment 拡張機能

要望が最も多かったコミュニティ機能の 1 つに対応して、WGSL 拡張機能 swizzle_assignment を使用すると、ベクトル スウィズルに直接書き込むことができるため、1 つのステートメントで複数のコンポーネントを更新できます。ボイラープレートを大幅に削減し、シェーダーの可読性を向上させながら、WGSL を他のシェーディング言語と一致させます。

この言語拡張機能は、navigator.gpu.wgslLanguageFeatures を使用して JavaScript で機能検出できます。WGSL シェーダー コードの先頭で、requires-directive を使用して requires swizzle_assignment での移植性の可能性を通知することをおすすめします。次の WGSL の例と出荷の意向をご覧ください。

if (!navigator.gpu.wgslLanguageFeatures.has("swizzle_assignment")) {
  throw new Error(`WGSL swizzle assignment is not available`);
}

const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();

const shaderModule = device.createShaderModule({ code: `
  requires swizzle_assignment;

  @vertex
  fn main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4f {
    var position = vec4f(0.0, 0.0, 0.0, 1.0);
    position.xy = vec2f(10.0, 20.0); // Swizzle assignment

    return position;
  }`,
});

WGSL 拡張機能の更新

texture-formats-tier1 言語拡張機能は WGSL コードでサポートされていますが、以前は JavaScript で navigator.gpu.wgslLanguageFeaturestexture_formats_tier1)に正しくマッピングされていませんでした。このマッピングの問題は解決されました。Chromium CL 8159562 をご覧ください。

WGSL で subgroup_size_control が有効になっている場合、subgroups 言語拡張機能が自動的に有効になるようになりました。問題 dawn:545285663 をご覧ください。

Dawn のアップデート

新しい wgpu::FeatureName::BufferMapWriteExtendedUsages 試験運用版機能を使用すると、wgpu::BufferUsage::MapWritewgpu::BufferUsage::MapRead 以外の wgpu::BufferUsage を組み合わせてバッファを作成し、GPU でも使用可能なマッピング可能なバッファに直接書き込むことができます。これにより、Vulkan と D3D12 バックエンドのステージング バッファと追加のコピーが不要になります。詳しくは、Buffer Map Write Extended Usages と問題 dawn:386255678 をご覧ください。

新しい webgpu_upstream_cpp_headers を使用することで、Dawn のフレーバーに縛られることなく、任意の webgpu.h 実装の上に webgpu_cpp.h バインディングを使用できるようになりました。webgpu-headers の問題 #596 をご覧ください。

Dawn を利用するには macOS 13.0 以降が必要になりました。Dawn CL 334415 を参照してください。

ここでは、主なハイライトの一部のみを取り上げます。詳しくは、コミットの完全なリストをご覧ください。

WebGPU の新機能

WebGPU の新機能シリーズで取り上げたすべての内容のリスト。

Chrome 153-154

Chrome 151-152

Chrome 149-150

Chrome 147-148

Chrome 146

Chrome 145

Chrome 144

Chrome 143

Chrome 142

Chrome 141

Chrome 140

Chrome 139

Chrome 138

Chrome 137

Chrome 136

Chrome 135

Chrome 134

Chrome 133

Chrome 132

Chrome 131

Chrome 130

Chrome 129

Chrome 128

Chrome 127

Chrome 126

Chrome 125

Chrome 124

Chrome 123

Chrome 122

Chrome 121

Chrome 120

Chrome 119

Chrome 118

Chrome 117

Chrome 116

Chrome 115

Chrome 114

Chrome 113