WebGPU 新功能 (Chrome 143)

François Beaufort
François Beaufort

發布日期:2025 年 11 月 19 日

紋理元件重組

現在透過著色器存取時,可以重新排列或取代紋理的紅色、綠色、藍色和 Alpha 通道的顏色元件。

如果 GPUAdapter 提供 "texture-component-swizzle" 功能,請要求使用這項功能的 GPUDevice,然後呼叫 createView() 並提供新的 swizzle 選項,藉此建立 GPUTextureView。這個值是長度為 4 的字串,每個字元分別對應檢視區塊的紅色、綠色、藍色和 Alpha 元件。每個字元可以是:

  • "r":從紋理的紅色管道取得值。
  • "g":從紋理的綠色通道取得值。
  • "b":從紋理的藍色管道取得值。
  • "a":從紋理的 Alpha 色板取得值。
  • "0":強制將值設為 0。
  • "1":強制將值設為 1。

請參閱下列程式碼片段和 chromestatus 項目

const adapter = await navigator.gpu.requestAdapter();
if (!adapter.features.has("texture-component-swizzle")) {
  throw new Error("Texture component swizzle support is not available");
}
// Explicitly request texture component swizzle support.
const device = await adapter.requestDevice({
  requiredFeatures: ["texture-component-swizzle"],
});

// ... Assuming myTexture is a GPUTexture with a single red channel.

// Map the view's red, green, blue components to myTexture's red channel
// and force the view's alpha component to 1 so that the shader sees it as
// a grayscale image.
const view = myTexture.createView({ swizzle: "rrr1" });

// Send the appropriate commands to the GPU...

移除 bgra8unorm 唯讀儲存空間紋理用量

如先前公告所述,我們已移除搭配唯讀儲存空間紋理使用的 "bgra8unorm" 格式。WebGPU 規格明確禁止此行為,而 Chrome 先前允許此行為是錯誤,因為這個格式僅供寫入存取,且無法移植。請參閱問題 427681156

黎明更新

修正了在 Vulkan 中清除 3D 紋理時引發的驗證錯誤。請參閱問題 443950688

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

WebGPU 最新消息

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

Chrome 143

Chrome 142

Chrome 141

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