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

François Beaufort
François Beaufort

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

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

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

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

Unorm10-10-10-2 वर्टेक्स फ़ॉर्मैट

"unorm10-10-10-2" नाम का एक नया वर्टेक्स फ़ॉर्मैट इसे "आरजीबी10a2" के नाम से भी जाना जाता है को WebGPU की खास बातों में जोड़ा गया है. इसमें एक पैक की गई 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.

आरजीबी10a2uint टेक्स्चर फ़ॉर्मैट

"आरजीबी10a2uint" नाम का एक नया टेक्स्चर फ़ॉर्मैट को WebGPU की खास बातों में जोड़ा गया है. इसमें 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....

डॉन से जुड़े अपडेट

टाइमस्टैंप क्वेरी से 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 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