الميزات الجديدة في WebGPU (Chrome 119)

François Beaufort
François Beaufort

الصور النسيجية العائمة التي يمكن فلترتها والمكوّنة من 32 بت

يتم استخدام مواد عرض نقطة عائمة 32 بت لتخزين بيانات عالية الدقة، مثل صور النطاق العالي الديناميكية وخرائط العمق. وهي مهمة بشكل خاص لوحدات معالجة الرسومات المستخدَمة في الألعاب المتطورة والتطبيقات الاحترافية.

يشير توافق وحدة معالجة الرسومات مع إمكانية فلترة مواد العرض ذات الفاصلة العائمة 32 بت إلى قدرة وحدة معالجة الرسومات على فلترة مواد العرض ذات الفاصلة العائمة 32 بت. وهذا يعني أنّ وحدة معالجة الرسومات يمكنها تنعيم حواف الأنسجة ذات الفاصلة العائمة، ما يجعلها تبدو أقل خشونة. وهي تشبه الإضافة "OES_texture_float_linear" في WebGL.

لا تتوافق بعض وحدات معالجة الرسومات مع مواد العرض العائمة ذات 32 بت القابلة للتصفية. عندما تتوفّر ميزة "float32-filterable" في GPUAdapter، يمكنك الآن طلب GPUDevice باستخدام هذه الميزة وفلترة المواد باستخدام التنسيقات "r32float" و"rg32float" و "rgba32float". راجِع المثال التالي والمشكلة 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" أو "rgb10a2" إلى مواصفات WebGPU. تتألف من قيمة واحدة مضغوطة ذات 32 بت مع أربع قيم أعداد صحيحة غير سالبة عادية، مرتبة على النحو التالي: 10 بت و10 بت و10 بت و2 بت. اطّلِع على المثال التالي والمشكلة 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.

تنسيق بنية rgb10a2uint

تمت إضافة تنسيق جديد للنسيج يُسمى "rgb10a2uint" إلى مواصفات WebGPU. يتألف من تنسيق بكسل مضغوط 32 بت مع أربعة مكونات عدد صحيح غير موقّع: 10 بت أحمر و10 بت أخضر و10 بت أزرق و2 بت ألفا. اطّلِع على المثال التالي والمشكلة 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....

إشعارات الفجر

تسمح طلبات البحث عن الطوابع الزمنية لتطبيقات WebGPU بقياس الوقت الذي تستغرقه أوامر وحدة معالجة الرسومات بدقة (حتى جزء من مليار من الثانية). تم تعديل شكل واجهة برمجة التطبيقات لتسجيل طلبات البحث عن الطوابع الزمنية في بداية عمليات النقل ونهايتها لتتطابق مع مواصفات WebGPU. اطّلِع على المثال التالي وأرسِل طلبًا إلى 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);

هذا يشمل بعض النقاط الرئيسية فقط. اطّلِع على القائمة الشاملة لعمليات الإيداع.

الميزات الجديدة في WebGPU

قائمة بكل ما تم تناوله في سلسلة الميزات الجديدة في WebGPU

Chrome 140

‫Chrome 139

‫Chrome 138

‫Chrome 137

Chrome 136

Chrome 135

Chrome 134

Chrome 133

‫Chrome 132

Chrome 131

Chrome 130

Chrome 129

Chrome 128

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