มีอะไรใหม่ใน 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 บิต ดูตัวอย่างต่อไปนี้และissue 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 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