מה חדש ב-WebGPU (Chrome 119)

François Beaufort
François Beaufort

מרקמים מסוג float ב-32 ביט שאפשר לסנן

מרקמים של נקודה צפה (floating-point) ב-32 ביט משמשים לאחסון נתונים ברמת דיוק גבוהה, כמו תמונות HDR ומפות עומק. הן חשובות במיוחד למעבדי GPU שמשמשים למשחקים מתקדמים ולאפליקציות מקצועיות.

תמיכה בטקסטורות מסוג נקודה צפה (floating-point) ב-32 ביט שניתנות לסינון מתארת את היכולת של מעבד גרפי (GPU) לסנן טקסטורות מסוג נקודה צפה (floating-point) ב-32 ביט. המשמעות היא שה-GPU יכול להחליק את הקצוות של טקסטורות בנקודה צפה, כך שהן ייראו פחות משוננות. היא דומה לתוסף 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 ביט. מקרה לדוגמה: 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.

פורמט טקסטורה rgb10a2uint

הוספנו פורמט טקסטורה חדש בשם rgb10a2uint למפרט WebGPU. הוא מורכב מפורמט פיקסל דחוס של 32 ביט עם ארבעה רכיבי מספרים שלמים לא חתומים: אדום של 10 ביט, ירוק של 10 ביט, כחול של 10 ביט ואלפא של 2 ביט. לדוגמה, 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....

עדכונים של Dawn

שאילתות של חותמות זמן מאפשרות לאפליקציות WebGPU למדוד בדיוק (עד לרמת הננו-שנייה) כמה זמן לוקח לפקודות ה-GPU שלהן להתבצע. הצורה של ה-API לתיעוד שאילתות של חותמות זמן בתחילת המעברים ובסופם עודכנה בהתאם למפרט WebGPU. לדוגמה: 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);

המידע הזה כולל רק נקודות עיקריות. רשימה מלאה של קומיטים

מה חדש ב-WebGPU

רשימה של כל הנושאים שמופיעים בסדרה What's New in WebGPU.

‫Chrome 147-148

Chrome 146

Chrome 145

Chrome 144

Chrome 143

Chrome 142

Chrome 141

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