WebGPU 新功能' (Chrome<版本>126)

François Beaufort
François Beaufort

提高 maxTextureArrayLayers 限制

根據預設,2D 紋理的深度或圖層數量上限為 256。現在可以使用 maxTextureArrayLayers 限制 (如果支援的話) 來要求最多 2048 個。請參閱以下範例和問題 42241514

const adapter = await navigator.gpu.requestAdapter();
if (adapter.limits.maxTextureArrayLayers < 30) {
  // When the desired limit isn't supported, take action to either fall back to
  // a code path that does not require the higher limit or notify the user that
  // their device does not meet minimum requirements.
}

// Request highest limit of max texture array layers attributes.
const device = await adapter.requestDevice({
  requiredLimits: { maxTextureArrayLayers: 2048 }
});

Vulkan 後端的緩衝區上傳最佳化

針對 Vulkan 後端 GPUQueue 的 writeBuffer() 方法呼叫時,現在可以使用快速路徑。您現在可以將資料直接寫入目的地緩衝區,省下額外的複製與同步處理作業。這項最佳化功能可減少將資料上傳至 GPU 所需的記憶體流量。

如要進行快速路徑最佳化,緩衝區的記憶體必須處於主機可見,且不含任何待處理的 GPU 作業。請參閱問題 42242084

改善著色器編譯時間

Chrome 團隊正在提升 Tint (WebGPU 著色器語言的編譯器) 的效率。Tint 目前會多次修改著色器程式碼的抽象語法樹狀結構 (AST),才能產生機器程式碼。這項程序在某些平台上已耗用大量資源。為達到最佳效果,我們推出了新的中繼表示法 (IR),以及重新設計使用該表示法的後端。這項變更旨在加快著色器編譯速度。

建立算繪管道的程序包括使用 Tint 編譯器將 WGSL 轉換為 SPIR-V,然後再透過驅動程式編譯器將 WGSL 轉換為 ISA。
在 ChromeOS 中建立轉譯管道。

這些改善項目目前已在 Android 裝置上提供,並逐步擴大適用可支援 WebGPU 與 Vulkan 後端的 ChromeOS 裝置。請參閱問題 42250751

提交的指令緩衝區不得重複

使用 submit() 方法提交至 GPUQueue 的每個 GPUCommandBuffer 都不得重複,否則會產生驗證錯誤。這是規格錯誤。請參閱問題 42241492

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

const commandEncoder = device.createCommandEncoder();
const commandBuffer = commandEncoder.finish();

device.queue.submit([commandBuffer, commandBuffer]);
// ⚠️ Validation fails because command buffers are not unique.

黎明更新

C++ 包裝函式 webgpu_cpp.h 目前只具備標頭,可簡化其使用方式,並方便與替代 C++ 包裝函式整合。請參閱問題 40195122

webgpu.h C API 不會再揭露交換鏈物件的概念。此變更是配合 JavaScript API 調整。內部設定現在是透過新 wgpu::Surface 物件的 Configure() 方法完成,因此日後可能會有所修改。查看「使用 WebGPU 建構應用程式」說明文件中的範例。請參閱問題 42241264

查看完整的修訂版本清單

WebGPU 的新功能

WebGPU 新功能」系列中已說明的所有功能清單。

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