WebGPU (Chrome 119) में नया क्या है

François Beaufort
François Beaufort

फ़िल्टर की जा सकने वाली 32-बिट फ़्लोट टेक्सचर

32-बिट फ़्लोटिंग-पॉइंट टेक्सचर का इस्तेमाल, हाई सटीक डेटा को स्टोर करने के लिए किया जाता है. जैसे, एचडीआर इमेज और डेप्थ मैप. ये खास तौर पर, महंगे गेमिंग और प्रोफ़ेशनल ऐप्लिकेशन में इस्तेमाल किए जाने वाले जीपीयू के लिए ज़रूरी हैं.

फ़िल्टर किया जा सकने वाला 32-बिट फ़्लोट टेक्सचर्स सपोर्ट, 32-बिट फ़्लोटिंग-पॉइंट टेक्सचर को फ़िल्टर करने में जीपीयू की क्षमता के बारे में बताता है. इसका मतलब है कि जीपीयू फ़्लोटिंग-पॉइंट टेक्सचर के किनारों को एक जैसा कर सकता है, जिससे वे कम टेढ़े-मेढ़े दिखते हैं. यह WebGL में "OES_texture_float_linear" एक्सटेंशन की तरह है.

सभी जीपीयू, फ़िल्टर की जा सकने वाली 32-बिट फ़्लोट टेक्सचर के साथ काम नहीं करते. जब GPUAdapter में "float32-filterable" सुविधा उपलब्ध होती है, तो अब आप इस सुविधा वाले GPUDevice का अनुरोध कर सकते हैं और "r32float", "rg32 फंस के", और "?" नीचे दिया गया उदाहरण देखें और समस्या का सुबह: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 वर्टेक्स फ़ॉर्मैट

WebGPU स्पेसिफ़िकेशन में, "unorm10-10-10-2" यानी "?" इसमें एक पैक की गई 32-बिट वैल्यू होती है, जिसमें चार नॉर्मलाइज़्ड, बिना साइन वाले पूर्णांक वैल्यू होती हैं. इन्हें 10 बिट, 10 बिट, 10 बिट, और 2 बिट के तौर पर व्यवस्थित किया जाता है. नीचे दिया गया उदाहरण देखें और टिकट जारी करें: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.

RGB10a2uint टेक्स्चर फ़ॉर्मैट

WebGPU की खास जानकारी में, "?" समूह 10a2uint" नाम का एक नया टेक्सचर फ़ॉर्मैट जोड़ा गया है. इसमें 32-बिट पैक किया गया पिक्सल फ़ॉर्मैट होता है, जिसमें चार बिना साइन वाले पूर्णांक कॉम्पोनेंट होते हैं: 10-बिट लाल, 10-बिट हरा, 10-बिट नीला, और 2-बिट ऐल्फ़ा. नीचे दिया गया उदाहरण देखें और जारी करने का समय: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....

Dawn के अपडेट

टाइमस्टैंप क्वेरी से WebGPU ऐप्लिकेशन, सटीक तौर पर (नैनोसेकंड तक) यह माप सकता है कि उनके जीपीयू कमांड को एक्ज़ीक्यूट होने में कितना समय लगता है. पास की शुरुआत और आखिर में टाइमस्टैंप क्वेरी को कैप्चर करने के लिए, एपीआई के आकार को अपडेट किया गया है. ऐसा WebGPU की खास बातों के हिसाब से किया गया है. नीचे दिया गया उदाहरण देखें और जारी करने का समय: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);

इसमें सिर्फ़ कुछ खास बातों के बारे में बताया गया है. कमियों की पूरी सूची देखें.

WebGPU में नया क्या है

WebGPU में नया क्या है सीरीज़ में शामिल सभी चीज़ों की सूची.

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