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 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