Yang Baru di WebGPU (Chrome 119)

François Beaufort
François Beaufort

Tekstur mengambang 32-bit yang dapat difilter

Tekstur floating point 32-bit digunakan untuk menyimpan data presisi tinggi, seperti gambar HDR dan peta kedalaman. Chip ini sangat penting untuk GPU yang digunakan dalam aplikasi profesional dan game kelas atas.

Dukungan tekstur float 32-bit yang dapat difilter menjelaskan kemampuan GPU untuk memfilter tekstur floating point 32-bit. Artinya, GPU dapat menghaluskan tepi tekstur floating point, sehingga membuatnya tidak terlihat bergerigi. Hal ini mirip dengan "OES_texture_float_linear" ekstensi di WebGL.

Tidak semua GPU mendukung tekstur float 32-bit yang dapat difilter. Jika fitur "float32-filterable" tersedia di GPUAdapter, Anda kini dapat meminta GPUDevice dengan fitur ini dan memfilter tekstur dengan "r32float", "rg32float", dan " rgba32float" format font. Lihat contoh berikut dan issue 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 format verteks

Format verteks baru yang disebut "unorm10-10-10-2" alias "RGB10a2" telah ditambahkan ke spesifikasi WebGPU. Ini terdiri dari satu nilai 32-bit yang dikemas dengan empat nilai integer tanpa tanda tangan yang dinormalisasi, disusun sebagai 10 bit, 10 bit, 10 bit, dan 2 bit. Lihat contoh berikut dan issue 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.

format tekstur rgb10a2uint

Format tekstur baru bernama "RGB10a2uint" telah ditambahkan ke spesifikasi WebGPU. Ini terdiri dari format piksel dikemas 32-bit dengan empat komponen bilangan bulat tanpa label: 10-bit merah, 10-bit hijau, 10-bit biru, dan 2-bit alpha. Lihat contoh berikut dan 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....

Update fajar

Kueri stempel waktu memungkinkan aplikasi WebGPU mengukur secara tepat (hingga nanodetik) berapa banyak waktu yang diperlukan untuk mengeksekusi perintah GPU. Bentuk API untuk menangkap kueri stempel waktu di awal dan akhir kartu telah diupdate agar sesuai dengan spesifikasi WebGPU. Lihat contoh berikut dan issue 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);

Artikel ini hanya mencakup beberapa sorotan utama. Lihat daftar commit selengkapnya.

Yang Baru di WebGPU

Daftar semua hal yang telah dibahas dalam seri 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