Novità di WebGPU (Chrome 119)

François Beaufort
François Beaufort

Texture floating a 32 bit filtrabili

Le texture in virgola mobile a 32 bit vengono utilizzate per archiviare dati ad alta precisione, come immagini HDR e mappe di profondità. Sono particolarmente importanti per le GPU utilizzate in applicazioni professionali e di gioco di fascia alta.

Il supporto delle texture in virgola mobile a 32 bit filtrabile descrive la capacità di una GPU di filtrare le texture in virgola mobile a 32 bit. Ciò significa che la GPU può rendere più uniformi i bordi delle texture in virgola mobile, rendendoli meno frastagliati. È simile a "OES_texture_float_linear" in WebGL.

Non tutte le GPU supportano texture in virgola mobile a 32 bit filtrabili. Quando la funzionalità "float32-filterable" è disponibile in un GPUAdapter, ora puoi richiedere un GPUDevice con questa funzionalità e filtrare le texture con "r32float", "rg32float" e "Iniziativa" formati. Vedi l'esempio seguente e 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....

formato vertice unorm10-10-10-2

Un nuovo formato vertice chiamato "unorm10-10-10-2" noto anche come "Googlebot10a2" è stata aggiunta alla specifica WebGPU. È costituito da un valore a 32 bit compresso con quattro valori interi senza segno normalizzati, disposti come 10 bit, 10 bit, 10 bit e 2 bit. Vedi l'esempio seguente e 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.

Formato texture rgb10a2uint

Un nuovo formato di texture chiamato "JavaScript10a2uint" è stata aggiunta alla specifica WebGPU. È costituito da un formato pixel a 32 bit con quattro componenti interi senza segno: rosso a 10 bit, verde a 10 bit, blu a 10 bit e alfa a 2 bit. Vedi l'esempio seguente e 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....

Aggiornamenti all'alba

Le query con timestamp consentono alle applicazioni WebGPU di misurare con precisione (fino al nanosecondo) il tempo necessario per l'esecuzione dei loro comandi GPU. La forma dell'API per acquisire le query sui timestamp all'inizio e alla fine delle tessere è stata aggiornata in modo da corrispondere alla specifica WebGPU. Vedi l'esempio seguente e 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);

Descrive solo alcuni dei punti salienti. Consulta l'elenco completo dei commit.

Novità di WebGPU

Un elenco di tutti gli argomenti trattati nella serie Novità di 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