Neu bei WebGPU (Chrome 119)

François Beaufort
François Beaufort

Filterbare 32-Bit-Gleitkomma-Texturen

32‑Bit-Gleitkomma-Texturen werden zum Speichern von hochpräzisen Daten wie HDR-Bildern und Tiefenkarten verwendet. Sie sind besonders wichtig für GPUs, die in High-End-Gaming- und professionellen Anwendungen verwendet werden.

Die Unterstützung für filterbare 32-Bit-Gleitkomma-Texturen beschreibt die Fähigkeit einer GPU, 32-Bit-Gleitkomma-Texturen zu filtern. Das bedeutet, dass die GPU die Kanten von Gleitkomma-Texturen glätten kann, sodass sie weniger gezackt erscheinen. Sie ähnelt der Erweiterung „OES_texture_float_linear“ in WebGL.

Nicht alle GPUs unterstützen filterbare 32-Bit-Gleitkomma-Texturen. Wenn die Funktion "float32-filterable" in einem GPUAdapter verfügbar ist, können Sie jetzt ein GPUDevice mit dieser Funktion anfordern und Texturen mit den Formaten „r32float“, „rg32float“ und „rgba32float“ filtern. Sehen Sie sich das folgende Beispiel und Problem dawn:1664 an.

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....

Vertex-Format „unorm10-10-10-2“

Der WebGPU-Spezifikation wurde ein neues Vertex-Format namens „unorm10-10-10-2“ (auch „rgb10a2“) hinzugefügt. Sie besteht aus einem gepackten 32-Bit-Wert mit vier normalisierten vorzeichenlosen Ganzzahlwerten, die als 10 Bit, 10 Bit, 10 Bit und 2 Bit angeordnet sind. Sehen Sie sich das folgende Beispiel und Problem dawn:2044 an.

// 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.

Texturformat „rgb10a2uint“

Der WebGPU-Spezifikation wurde ein neues Texturformat namens „rgb10a2uint“ hinzugefügt. Es besteht aus einem gepackten 32-Bit-Pixelformat mit vier vorzeichenlosen Ganzzahlkomponenten: 10-Bit-Rot, 10-Bit-Grün, 10-Bit-Blau und 2-Bit-Alpha. Sehen Sie sich das folgende Beispiel und Problem dawn:1936 an.

// 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....

Änderungen bei Dawn

Mit Zeitstempelabfragen können WebGPU-Anwendungen genau (bis auf die Nanosekunde) messen, wie viel Zeit für die Ausführung ihrer GPU-Befehle benötigt wird. Die API-Form für Zeitstempelabfragen am Anfang und Ende von Durchgängen wurde aktualisiert, um der WebGPU-Spezifikation zu entsprechen. Sehen Sie sich das folgende Beispiel und issue dawn:1800 an.

// 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);

Dies sind nur einige der wichtigsten Highlights. Vollständige Liste der Commits

Neu bei WebGPU

Eine Liste aller Themen, die in der Reihe Neu in WebGPU behandelt wurden.

Chrome 155–156

Chrome 153–154

Chrome 151–152

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