มีอะไรใหม่ใน WebGPU (Chrome 119)

François Beaufort
François Beaufort

พื้นผิวแบบลอย 32 บิตที่กรองได้

พื้นผิวของจุดลอยตัว 32 บิตใช้ในการจัดเก็บข้อมูลที่มีความแม่นยำสูง เช่น รูปภาพ HDR และแผนที่ความลึก ซึ่งสำคัญมากสำหรับ GPU ที่ใช้ในเกมระดับไฮเอนด์และแอปพลิเคชันระดับมืออาชีพ

การรองรับพื้นผิวลอยตัว 32 บิตที่กรองได้อธิบายความสามารถของ GPU ในการกรองพื้นผิวจุดลอยตัว 32 บิต ซึ่งหมายความว่า GPU สามารถทำให้ขอบของพื้นผิวจุดลอยตัวเรียบเนียน ทำให้ดูหยักศกน้อยลง โดยมีลักษณะคล้ายกับ "OES_texture_Flo_Linear" ใน WebGL

GPU บางรุ่นไม่รองรับพื้นผิวลอยตัว 32 บิตที่กรองได้ เมื่อฟีเจอร์ "float32-filterable" พร้อมใช้งานใน GPUAdapter ตอนนี้คุณขอ GPUDevice ด้วยฟีเจอร์นี้และกรองพื้นผิวด้วย "r32Flo", "rg32Flo" และ "rgba32Flo" ได้เลย รูปแบบ ดูตัวอย่างและปัญหา dawn:1664

const adapter = await navigator.gpu.requestAdapter();
if (!adapter.features.has("float32-filterable")) {
  throw new Error("Filterable 32-bit float textures support is not available");
}
// Explicitly request filterable 32-bit float textures support.
const device = await adapter.requestDevice({
  requiredFeatures: ["float32-filterable"],
});

// Create a sampler with linear filtering.
const sampler = device.createSampler({
  magFilter: "linear",
});

// Create a texture with rgba32float format.
const texture = device.createTexture({
  size: [100, 100],
  format: "rgba32float",
  usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
});

// Write data to texture, create a bindgroup with sampler and texture and
// send the appropriate commands to the GPU....

รูปแบบ Vertex10-10-10-2

จุดยอดมุมรูปแบบใหม่ชื่อ "unorm10-10-10-2" หรือ "rgb10a2" ในข้อกำหนด WebGPU แล้ว ซึ่งประกอบด้วยค่า 32 บิต 1 ค่า พร้อมค่าจำนวนเต็มที่ไม่มีเครื่องหมายมาตรฐาน 4 รายการ ซึ่งจัดเรียงเป็น 10 บิต, 10 บิต, 10 บิต และ 2 บิต ดูตัวอย่างและปัญหา dawn:2044

// Define the layout of vertex attribute data with unorm10-10-10-2 format.
const buffers = [
  {
    arrayStride: 0,
    attributes: [
      { format: "unorm10-10-10-2", offset: 0, shaderLocation: 0 },
    ],
  },
];

// Describe the vertex shader entry point and its input buffer layouts.
const vertex = {
  module: myVertexShaderModule,
  entryPoint: "main",
  buffers,
};

// Pass vertex to device.createRenderPipeline() and
// use vec4<f32> type in WGSL shader code to manipulate data.

รูปแบบพื้นผิว RGB10a2uint

รูปแบบพื้นผิวใหม่ชื่อ "rgb10a2uint" ในข้อกำหนด WebGPU แล้ว ซึ่งประกอบด้วยรูปแบบพิกเซลที่อัดแน่นไปด้วยขนาด 32 บิตพร้อมด้วยส่วนประกอบจำนวนเต็มที่ไม่มีเครื่องหมาย 4 แบบ ได้แก่ สีแดง 10 บิต สีเขียว 10 บิต สีน้ำเงิน 10 บิต และอัลฟ่า 2 บิต ดูตัวอย่างและปัญหา dawn:1936

// Create a texture with rgb10a2uint format.
const texture = device.createTexture({
  size: [100, 100],
  format: "rgb10a2uint",
  usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
});

// Write data to texture, create a bindgroup with texture and
// send the appropriate commands to the GPU....

ข้อมูลอัปเดตรุ่งเช้า

การค้นหาการประทับเวลาช่วยให้แอปพลิเคชัน WebGPU วัดระยะเวลาที่ใช้ในการดำเนินการตามคำสั่ง GPU ได้อย่างแม่นยำ (จนถึงระดับนาโนวินาที) รูปร่าง API สำหรับบันทึกการค้นหาการประทับเวลาที่จุดเริ่มต้นและจุดสิ้นสุดของบัตรได้รับการอัปเดตให้ตรงกับข้อกำหนดของ WebGPU แล้ว ดูตัวอย่างและปัญหา dawn:1800

// Create a timestamp query set that will store the timestamp values.
wgpu::QuerySetDescriptor querySetDescriptor = {
    .count = 2,
    .type = wgpu::QueryType::Timestamp};
wgpu::QuerySet querySet = device.CreateQuerySet(&querySetDescriptor);

wgpu::RenderPassTimestampWrites timestampWrites = {
    .querySet = querySet,
    .beginningOfPassWriteIndex = 0,
    .endOfPassWriteIndex = 1};
wgpu::ComputePassDescriptor pass{.timestampWrites = &timestampWrites};

// Write the queue timestamp into beginningOfPassWriteIndex and
// endOfPassWriteIndex of myQuerySet respectively before and after the pass
// commands execute.
myEncoder.BeginComputePass(&pass);

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

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

รายการทั้งหมดที่กล่าวถึงในซีรีส์ What's New in 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