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

François Beaufort
François Beaufort

พื้นผิวแบบกรองได้ที่เป็นจำนวนลอยตัว 32 บิต

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

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

GPU บางรุ่นไม่รองรับพื้นผิวแบบกรองได้ที่เป็นจำนวนลอยตัว 32 บิต เมื่อฟีเจอร์ "float32-filterable" พร้อมใช้งานใน GPUAdapter คุณสามารถขอ GPUDevice ที่มีฟีเจอร์นี้และกรองพื้นผิวด้วยรูปแบบ "r32float", "rg32float" และ "rgba32float" ได้แล้ว ดูตัวอย่างต่อไปนี้และ ปัญหา 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....

รูปแบบจุดยอด unorm10-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....

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

การค้นหาการประทับเวลาช่วยให้แอปพลิเคชัน 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

รายการทุกอย่างที่กล่าวถึงในซีรีส์มีอะไรใหม่ใน 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