copyExternalImageToTexture() での HTMLImageElement と ImageData のサポート
GPUQueue
の copyExternalImageToTexture()
メソッドを使用すると、ソース画像、動画、キャンバスから取得したスナップショットを特定の GPUTexture
にコピーできます。HTMLImageElement
オブジェクトと ImageData
オブジェクトをソースとして渡せるようになりました。以下の例と Chromium:1471372 の問題をご覧ください。
// Fetch and decode image.
const source = document.createElement("img");
source.src = "my-image.png";
await source.decode();
// Create destination texture.
const size = [source.width, source.height];
const texture = myDevice.createTexture({
size,
format: "rgba8unorm",
usage:
GPUTextureUsage.COPY_DST |
GPUTextureUsage.RENDER_ATTACHMENT |
GPUTextureUsage.TEXTURE_BINDING,
});
// Copies a snapshot taken from the source image into a texture.
myDevice.queue.copyExternalImageToTexture({ source }, { texture }, size);
読み取り / 書き込みと読み取り専用のストレージ テクスチャの試験運用版のサポート
ストレージ テクスチャのバインディング タイプを使用すると、サンプリングなしでテクスチャを読み取り、シェーダーの任意の位置に保存できます。GPUAdapter
で "chromium-experimental-read-write-storage-texture"
機能が利用できる場合、この機能を使用して GPUDevice
をリクエストし、バインド グループ レイアウトの作成時に GPUStorageTexture
アクセスを "read-write"
または "read-only"
に設定できるようになりました。これまでは "write-only"
に制限されていました。
これを利用するには、WGSL のコードで enable chromium_experimental_read_write_storage_texture
を使用して、この拡張機能を明示的に有効にする必要があります。有効にすると、ストレージ テクスチャに read_write
および read
アクセス修飾子を使用でき、textureLoad()
および textureStore()
組み込み関数がそれに応じて動作し、新しい textureBarrier()
組み込み関数を使用してワークグループ内のテクスチャ メモリアクセスを同期できるようになります。次の例と issue dawn:1972 をご覧ください。
この機能はまだ試験運用版であり、変更される可能性があります。標準化が完了するまでに、--enable-dawn-features=allow_unsafe_apis
フラグを指定して Chrome を実行し、利用可能にします。
const feature = "chromium-experimental-read-write-storage-texture";
const adapter = await navigator.gpu.requestAdapter();
if (!adapter.features.has(feature)) {
throw new Error("Read-write storage texture support is not available");
}
// Explicitly request read-write storage texture support.
const device = await adapter.requestDevice({
requiredFeatures: [feature],
});
const bindGroupLayout = device.createBindGroupLayout({
entries: [{
binding: 0,
visibility: GPUShaderStage.COMPUTE,
storageTexture: {
access: "read-write", // <-- New!
format: "r32uint",
},
}],
});
const shaderModule = device.createShaderModule({ code: `
enable chromium_experimental_read_write_storage_texture;
@group(0) @binding(0) var tex : texture_storage_2d<r32uint, read_write>;
@compute @workgroup_size(1, 1)
fn main(@builtin(local_invocation_id) local_id: vec3u) {
var data = textureLoad(tex, vec2i(local_id.xy));
data.x *= 2;
textureStore(tex, vec2i(local_id.xy), data);
}`,
});
// You can now create a compute pipeline with this shader module and
// send the appropriate commands to the GPU.
夜明けの更新情報
webgpu.h C API では、一貫性を保つためにフィールド requiredFeaturesCount
から requiredFeatureCount
、pipelineStatisticsCount
から pipelineStatisticCount
、colorFormatsCount
から colorFormatCount
の名前が変更されました。Issue dawn:146040 をご覧ください。
新しい DawnInfo
プログラム(vulkaninfo に類似)を使用すると、切り替え、アダプター、アダプターの機能、アダプターの制限を一覧表示できます。夜明け samples
の建築時に利用できます。簡略化のために、以下の出力は一部省略しています。change dawn:149020 をご覧ください。
./out/Debug/DawnInfo
Toggles
=======
Name: allow_unsafe_apis
Suppresses validation errors on API entry points or parameter combinations
that aren't considered secure yet.
http://crbug.com/1138528
[…]
Adapter
=======
VendorID: 0x106B
Vendor: apple
Architecture: common-3
DeviceID: 0x0000
Name: Apple M1 Pro
Driver description: Metal driver on macOS Version 13.5.1 (Build 22G90)
Adapter Type: discrete GPU
Backend Type: Metal
Power: <undefined>
Features
========
* depth_clip_control
Disable depth clipping of primitives to the clip volume
https://bugs.chromium.org/p/dawn/issues/detail?id=1178
[…]
Adapter Limits
==============
maxTextureDimension1D: 16,384
maxTextureDimension2D: 16,384
[…]
ここでは、重要なハイライトの一部についてのみ説明します。commit の完全なリストを確認する。
WebGPU の新機能
WebGPU の新機能シリーズで取り上げたすべての内容のリストです。
Chrome 125
Chrome 124
Chrome 123
- WGSL での DP4a 組み込み関数のサポート
- WGSL の無制限のポインタ パラメータ
- WGSL で複合体を逆参照するためのシンタックス シュガー
- ステンシルと奥行きの側面の読み取り専用状態を分離
- 夜明けの更新情報
Chrome 122
Chrome 121
- Android で WebGPU をサポートする
- Windows でのシェーダー コンパイルに FXC ではなく DXC を使用する
- コンピューティング パスとレンダリング パスのタイムスタンプ クエリ
- シェーダー モジュールへのデフォルトのエントリ ポイント
- GPUExternalTexture 色空間として display-p3 をサポート
- メモリヒープ情報
- 夜明けの更新情報
Chrome 120
Chrome 119
Chrome 118
copyExternalImageToTexture()
での HTMLImageElement と ImageData のサポート- 読み取り / 書き込みと読み取り専用のストレージ テクスチャの試験運用版のサポート
- 夜明けの更新情報
Chrome 117
- 頂点バッファの設定解除
- バインド グループの設定を解除
- デバイスを紛失した場合に非同期パイプライン作成によるエラーをミュート
- SPIR-V シェーダー モジュール作成の更新
- デベロッパー エクスペリエンスの向上
- 自動生成されたレイアウトを使用したキャッシュ パイプラインのキャッシュ
- 夜明けの更新情報
Chrome 116
- WebCodecs の統合
- GPUAdapter
requestDevice()
から返却された紛失のデバイス importExternalTexture()
が呼び出された場合に動画のスムーズな再生を維持する- 仕様の遵守
- デベロッパー エクスペリエンスの向上
- 夜明けの更新情報
Chrome 115
- サポートされている WGSL 言語拡張機能
- Direct3D 11 の試験運用版のサポート
- AC 電源でデフォルトでディスクリート GPU を使用
- デベロッパー エクスペリエンスの向上
- 夜明けの更新情報