มีอะไรใหม่ใน WebGPU (Chrome 147-148)

François Beaufort
François Beaufort

เผยแพร่: 22 เมษายน 2026

ส่วนขยาย linear_indexing ของ WGSL

ส่วนขยายภาษา WGSL linear_indexing ช่วยให้คุณใช้ค่าในตัวต่อไปนี้ในเวิร์กกรุ๊ปได้

  • global_invocation_index: ตำแหน่งเชิงเส้นของการเรียกใช้ปัจจุบันภายในตาราง Compute Shader ทั้งหมด u32 ค่าอินพุตที่คำนวณตาม global_invocation_id, workgroup_size และ num_workgroups

  • workgroup_index: ตำแหน่งเชิงเส้นของเวิร์กกรุ๊ปปัจจุบันภายในตารางการประมวลผล Shader โดยรวม u32 ค่าอินพุตที่การเรียกใช้ทั้งหมดภายในเวิร์กกรุ๊ปเดียวกันแชร์ดัชนีเดียวกัน

ส่วนขยายนี้จะจัดการการคำนวณดัชนีด้วยตนเองจากพิกัด 3 มิติ ซึ่งเป็นกระบวนการที่ต้องทำซ้ำและอาจเกิดข้อผิดพลาดได้ การย้ายตรรกะนี้ไปยังภาษา WGSL เองจะช่วยปรับปรุงความสามารถในการอ่านโค้ดและขจัดการคำนวณที่ซ้ำซ้อนทั่วไป

ส่วนขยายภาษาดังกล่าวสามารถตรวจหาฟีเจอร์ได้โดยใช้ navigator.gpu.wgslLanguageFeatures ดูตัวอย่างต่อไปนี้และความตั้งใจที่จะจัดส่ง

if (!navigator.gpu.wgslLanguageFeatures.has("linear_indexing")) {
  throw new Error(`WGSL global_invocation_index and workgroup_index built-in values are not available`);
}

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

const shaderModule = device.createShaderModule({ code: `
  requires linear_indexing;

  override x : u32;
  override y : u32;
  override z : u32;

  @compute @workgroup_size(x, y, z)
  fn main(@builtin(workgroup_index) wg_index : u32,
          @builtin(global_invocation_index) g_index : u32) {

  // The workgroup_index built-in value is equivalent to:
  // (@builtin(workgroup_id).x +
  // (@builtin(workgroup_id).y * @builtin(num_workgroups).x) +
  // (@builtin(workgroup_id).z * @builtin(num_workgroups).x * @builtin(num_workgroups).y))

  // The global_invocation_index built-in value is equivalent to:
  // (@builtin(global_invocation_id).x +
  // (@builtin(global_invocation_id).y * x * @builtin(num_workgroups).x) +
  // (@builtin(global_invocation_id).z * x * @builtin(num_workgroups).x * y * @builtin(num_workgroups).y))
  }`,
});

WebGPU ใน Linux NVIDIA

หลังจากเปิดตัว WebGPU บน Linux ก่อนหน้านี้ ตอนนี้เราได้ขยายการรองรับให้รวมถึงไดรเวอร์ NVIDIA รุ่นใหม่ (2024-05) บน Wayland แล้ว โปรดดูปัญหา 442791440

ข้อมูลอัปเดตเกี่ยวกับ Dawn

wgpu::FeatureName::AdapterPropertiesDRM ซึ่งใช้ได้ใน Vulkan เท่านั้น ช่วยให้คุณค้นหาข้อมูล DRM ของ Linux เกี่ยวกับอะแดปเตอร์ได้ ดูCL 299575 ของ Dawn

นี่เป็นเพียงไฮไลต์สำคัญบางส่วนเท่านั้น ดูรายการคอมมิตทั้งหมด

มีอะไรใหม่ใน WebGPU

รายการทุกอย่างที่ครอบคลุมในซีรีส์มีอะไรใหม่ใน WebGPU

Chrome 149-150

Chrome 147-148

Chrome 146

Chrome 145

Chrome 144

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