A Firefox összeállításokban a specifikáció támogatása , amely egy programozási interfészt biztosít a 3D grafika és GPU oldali számítások feldolgozásához, fogalmilag hasonló az API-hoz , és . A specifikációt a Mozilla, a Google, az Apple, a Microsoft és a közösség képviselői fejlesztik , amelyet a W3C szervezett.
A WebGPU kulcsfeladata egy biztonságos, felhasználóbarát, hordozható és nagy teljesítményű programozási interfész létrehozása a Web Platform grafikai lehetőségeinek és technológiáinak használatára, amelyeket a modern rendszer grafikai API-k, mint például a Direct3D 12 Windows alatt, a Metal macOS-ban és a Vulkan Linux alatt nyújtanak. Fogalmilag a WebGPU a WebGL-től körülbelül úgy tér el, mint a Vulkan az OpenGL-től, és nem alapoz egy adott grafikai API-ra, hanem egy univerzális réteg, amely általánosan ugyanazokat az alacsony szintű primitívákat használja, mint amik a Vulkanban, Metalban és Direct3D-ben megtalálhatók.
A WebGPU lehetőséget biztosít a JavaScript alapú alkalmazások számára az alacsony szintű ellenőrzésre a feladatok szervezésében, feldolgozásában és a GPU-hoz való parancsok továbbításában, valamint az összes kapcsolódó erőforrás, memória, pufferek, textúra objektumok és a lefordított grafikai shader-ek kezelésére. Ez a megközelítés lehetővé teszi a grafikai alkalmazások magasabb teljesítményének elérését a költségek csökkentésével és a GPU-val való hatékonyabb munkavégzéssel.
A WebGPU lehetővé teszi a valódi összetett 3D projektek létrehozását a Weben, amelyek olyan jól működnek, mint a különálló programok, amelyek közvetlenül a Vulkanra, Metalra vagy Direct3D-re támaszkodnak, de nem kötődnek konkrét platformokhoz. A WebGPU emellett további lehetőségeket biztosít a natív grafikai programok webes technológiákra való portolásához a WebAssembly technológia alkalmazásának köszönhetően. A 3D grafikán kívül a WebGPU magában foglalja a GPU-ra való számítások kiszervezésével kapcsolatos lehetőségeket és a shader-fejlesztés támogatását. A shaderek a WebGPU Shading Language nyelven készülnek vagy egy köztes formátumban, SPIR-V-ben határozzák meg, majd lefordítják a jelenlegi meghajtók által támogatott shader nyelvekre.
A WebGPU különálló erőforrás-irányítást, előkészítési munkát és parancsok GPU-ra való továbbítását alkalmazza (a WebGL-ben egy objektum felelt mindenért egyszerre). Három különálló kontextust biztosít:
A GPUDevice for creating resources such as textures and buffers; a GPUCommandEncoder for encoding individual commands, including rendering and computation stages; a GPUCommandBuffer for queuing for execution on the GPU. The result can be rendered in an area associated with one or more canvas elements or processed without output (for example, when running computation tasks). The separation of stages simplifies the distribution of resource creation and preparation operations into different handlers that can run in different threads.
The second distinction of WebGPU from WebGL is its different approach to handling states. WebGPU proposes two objects — GPURenderPipeline and GPUComputePipeline, which allow combining various states pre-defined by the developer, enabling the browser to save resources on additional tasks, such as recompiling shaders. Among the supported states: shaders, vertex buffer layouts and attributes, attached group layouts, blending, depth, and output formats after rendering.
The third feature of WebGPU is called the binding model, which largely
resembles the resource grouping mechanisms present in Vulkan.
To group resources in WebGPU, a GPUBindGroup object is provided, which can be linked with other similar objects during command recording for use in shaders. Creating such groups allows the driver to perform necessary preparatory actions in advance and significantly speeds up the browser's ability to change resource bindings between render calls. The layout of resource bindings can be predefined using the GPUBindGroupLayout object.

In Firefox, to enable WebGPU in about:config, the setting "dom.webgpu.enabled" is provided. Enabling the compositing system is also required for CanvasContext rendering ("gfx.webrender.all" in about:config), written in Rust and offloading page content rendering operations to the GPU. The WebGPU implementation is based on the code from the
, written in Rust and capable of running on top of the DX12, Vulkan, and Metal APIs in Linux, Android, Windows, and macOS (support for DX11 and OpenGL ES 3.0 is also in development). Concurrently, Google is developing another implementation available in the A Chromium és a «chrome://flags/#enable-unsafe-webgpu» zászlóval aktiválható, de jelenleg csak macOS és Windows rendszeren működik.
Forrás: opennet.ru
