提高 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。](https://developer.chrome.google.cn/static/blog/new-in-webgpu-126/image/render-pipeline-creation-diagram.jpg?authuser=0&hl=zh-tw)
上述改善項目目前已在 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
- 在 Android 上支援 WebGPU
- 在 Windows 上使用 DXC (而非 FXC) 編譯著色器
- 在運算和算繪票證中為查詢加上時間戳記
- 著色器模組的預設進入點
- 支援 display-p3 做為 GPUExternalTexture 色彩空間
- 記憶體堆積資訊
- Dawn 更新
Chrome 120
Chrome 119
Chrome 118
Chrome 117
Chrome 116
- WebCodecs 整合
- GPUAdapter 傳回遺失的裝置
requestDevice()
- 如果呼叫
importExternalTexture()
,讓影片播放順暢 - 規格符合性
- 改善開發人員體驗
- Dawn 更新