Neu bei WebGPU (Chrome 119)

François Beaufort
François Beaufort

Filterbare 32-Bit-Float-Texturen

32-Bit-Gleitkommatexturen werden verwendet, um Daten mit hoher Genauigkeit wie HDR-Bilder und Tiefenkarten zu speichern. 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-Gleitkommatexturen beschreibt die Fähigkeit einer GPU, 32-Bit-Gleitkommatexturen zu filtern. Das bedeutet, dass die GPU die Ränder der Gleitkommatexturen glätten kann, sodass sie weniger zerklüftet erscheinen. Er ähnelt der Methode „OES_texture_float_linear“ in WebGL.

Nicht alle GPUs unterstützen filterbare 32-Bit-Float-Texturen. Wenn die Funktion „"float32-filterable"“ in einem GPUAdapter verfügbar ist, können Sie jetzt damit eine GPUDevice anfordern und Texturen mit „r32float“, „rg32float“ und „rgba32float“ filtern. Formaten. Sehen Sie sich das folgende Beispiel und issue 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....

Unorm10-10-10-2-Vertexformat

Ein neues Vertex-Format namens „unorm10-10-10-2“ (auch bekannt als „rgb10a2“) wurde der WebGPU-Spezifikation 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 issue 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.

rgb10a2uint-Texturformat

Das neue Texturformat „rgb10a2uint“ wurde der WebGPU-Spezifikation hinzugefügt. Es besteht aus einem 32-Bit-Pixelformat mit vier ganzzahligen Komponenten ohne Vorzeichen: 10-Bit-Rot, 10-Bit-Grün, 10-Bit-Blau und 2-Bit-Alpha. Sieh dir das folgende Beispiel und issue 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....

Updates zur Morgendämmerung

Mithilfe von Zeitstempelabfragen können WebGPU-Anwendungen bis auf die Nanosekunde genau messen, wie viel Zeit ihre GPU-Befehle für die Ausführung ihrer GPU-Befehle benötigen. Die API-Form zum Erfassen von Zeitstempelabfragen am Anfang und am Ende von Karten/Tickets wurde aktualisiert, um der WebGPU-Spezifikation zu entsprechen. Sieh dir 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);

Hier werden nur einige der wichtigsten Vorteile behandelt. Vollständige Liste der Commits

Das ist neu bei WebGPU

Eine Liste aller behandelten Themen der Reihe 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