WebGPU'daki Yenilikler (Chrome 119)

François Beaufort
François Beaufort

Filtrelenebilir 32 bit kayan dokular

HDR resimler ve derinlik haritaları gibi yüksek hassasiyetli verileri depolamak için 32 bit kayan nokta dokuları kullanılır. Özellikle ileri teknoloji oyunlarda ve profesyonel uygulamalarda kullanılan GPU'lar için önemlidir.

Filtrelenebilir 32 bit kayan doku desteği, bir GPU'nun 32 bit kayan nokta dokularını filtreleme yeteneğini ifade eder. Bu, GPU'nun kayan nokta dokularının kenarlarını yumuşatabileceği ve böylece, daha az pürüzlü görünmelerini sağladığı anlamına gelir. WebGL'deki "OES_texture_float_linear" uzantısına benzer.

Tüm GPU'lar filtrelenebilir 32 bit kayan dokuları desteklemez. "float32-filterable" özelliği GPUAdapter öğesinde mevcut olduğunda artık bu özelliği kullanarak GPUDevice isteğinde bulunabilir ve "r32float", "rg32float" ve "rgba32float" biçimlerindeki dokuları filtreleyebilirsiniz. Aşağıdaki örneği inceleyin ve issue dawn:1664'ü inceleyin.

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 köşe biçimi

WebGPU spesifikasyonuna "unorm10-10-10-2" veya "rgb10a2" adında yeni bir köşe biçimi eklendi. 10 bit, 10 bit, 10 bit ve 2 bit şeklinde düzenlenmiş dört normalleştirilmiş imzasız tam sayı değeriyle paketlenmiş bir 32 bit değerden oluşur. Aşağıdaki örneği inceleyin ve issue dawn:2044'ü inceleyin.

// 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 doku biçimi

WebGPU spesifikasyonuna "rgb10a2uint" adlı yeni bir doku biçimi eklendi. Dört imzasız tam sayı bileşeni içeren 32 bit paketlenmiş bir piksel biçiminden oluşur: 10 bit kırmızı, 10 bit yeşil, 10 bit mavi ve 2 bit alfa. Aşağıdaki örneği inceleyin ve issue dawn:1936'yı inceleyin.

// 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 ile ilgili güncellemeler

Zaman damgası sorguları, WebGPU uygulamalarının GPU komutlarının yürütülmesi için geçen süreyi hassas bir şekilde (nanosaniyeye kadar) ölçmesine olanak tanır. Kartların başındaki ve sonundaki zaman damgası sorgularını yakalamak için kullanılan API şekli, WebGPU spesifikasyonuyla eşleşecek şekilde güncellendi. Aşağıdaki örneği inceleyin ve issue dawn:1800'ü inceleyin.

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

Burada, öne çıkan özelliklerin yalnızca bir kısmı ele alınıyor. Kayıtların kapsamlı listesine göz atın.

WebGPU'daki Yenilikler

WebGPU'daki Yenilikler serisinde ele alınan her şeyin listesi.

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