WebGPU 新功能 (Chrome 135)

François Beaufort
François Beaufort

發布日期:2025 年 3 月 26 日

允許使用空值繫結群組版面配置建立管道版面配置

先前建立空白繫結群組版面配置時,必須新增零繫結的繫結群組,相當不便。現在已允許使用空值繫結群組版面配置,且建立管道版面配置時會忽略這類版面配置,因此不再需要這麼做。這應該能簡化開發作業。

舉例來說,您可能只想建立使用繫結群組版面配置 0 和 2 的管道。您可以將繫結群組版面配置 1 指派給片段資料,並將繫結群組版面配置 2 指派給頂點資料,然後在沒有片段著色器的情況下進行算繪。請參閱問題 377836524

const bgl0 = myDevice.createBindGroupLayout({ entries: myGlobalEntries });
const bgl1 = myDevice.createBindGroupLayout({ entries: myFragmentEntries });
const bgl2 = myDevice.createBindGroupLayout({ entries: myVertexEntries });

// Create a pipeline layout that will be used to render without a fragment shader.
const myPipelineLayout = myDevice.createPipelineLayout({
  bindGroupLayouts: [bgl0, null, bgl2],
});

允許可視埠超出算繪目標的邊界

我們放寬了對可視區域驗證的要求,允許可視區域超出算繪目標的邊界。這項功能特別適合繪製 2D 元素,例如可能超出目前可視區域的 UI。請參閱問題 390162929

const passEncoder = myCommandEncoder.beginRenderPass({
  colorAttachments: [
    {
      view: myColorTexture.createView(),
      loadOp: "clear",
      storeOp: "store",
    },
  ],
});

// Set a viewport that extends past the render target's bounds by 8 pixels
// in all directions.
passEncoder.setViewport(
  /*x=*/ -8,
  /*y=*/ -8,
  /*width=*/ myColorTexture.width + 16,
  /*height=*/ myColorTexture.height + 16,
  /*minDepth=*/ 0,
  /*maxDepth=*/ 1,
);

// Draw geometry and complete the render pass as usual.

在 Android 上更輕鬆存取實驗性相容模式

現在只要使用 chrome://flags/#enable-unsafe-webgpu 標記,即可在 Android 上啟用實驗性 WebGPU 相容模式所需的所有功能。因此,您可以使用 featureLevel: "compatibility" 選項,在相容性模式中要求 GPUAdapter,甚至在不支援 Vulkan 的裝置上存取 OpenGL ES 後端。請參閱以下範例和問題 dawn:389876644

// Request a GPUAdapter in compatibility mode.
const adapter = await navigator.gpu.requestAdapter({ featureLevel: "compatibility" });
WebGPU 報告頁面顯示 Android 裝置上處於相容模式的 GPUAdapter。
webgpureport.org 中的相容性模式轉接器資訊。

移除 maxInterStageShaderComponents 限制

先前公告所述,由於多種因素,maxInterStageShaderComponents 限制已移除:

  • maxInterStageShaderVariables 的冗餘:這個限制已達到類似目的,可控制著色器階段之間傳遞的資料量。
  • 微小差異:雖然這兩種限制的計算方式略有不同,但差異不大,可在 maxInterStageShaderVariables 限制內有效管理。
  • 簡化:移除 maxInterStageShaderComponents 可簡化著色器介面,降低開發人員的複雜度。不必再管理兩個有細微差異的獨立限制,而是專注於名稱更適當且更全面的 maxInterStageShaderVariables

請參閱預計移除問題 364338810

黎明更新

您無法再使用篩選取樣器對深度紋理取樣。提醒您,深度紋理只能搭配非篩選或比較取樣器使用。請參閱問題 379788112

WGPURequiredLimitsWGPUSupportedLimits 結構體已扁平化為 WGPULimits。請參閱問題 374263404

下列結構體已重新命名。請參閱問題 42240793

  • WGPUImageCopyBuffer 現在是 WGPUTexelCopyBufferInfo
  • WGPUImageCopyTexture 現在是 WGPUTexelCopyTextureInfo
  • WGPUTextureDataLayout 現在是 WGPUTexelCopyBufferLayout

subgroupMinSizesubgroupMaxSize 成員已新增至 WGPUAdapterInfo 結構體。請參閱 webgpu-headers PR

現在使用 DAWN_TRACE_FILE_BASE 環境變數執行程式時,即可追蹤 Metal 中的 Dawn API 用量,該變數會儲存 .gputrace 檔案,稍後可載入 XCode 的 Metal Debugger。請參閱「偵錯 Dawn」說明文件。

這僅涵蓋部分重點。請參閱完整的提交清單

WebGPU 最新消息

WebGPU 最新消息」系列涵蓋的所有主題清單。

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