WebGPU support added to Firefox nightly builds

Π’ nightly builds of Firefox appeared specification support WebGPU, which provides a programming interface for processing 3D graphics and calculations on the GPU side, conceptually similar to the API Vulkan, Metal ΠΈ Direct3D 12. The specification is being developed by Mozilla, Google, Apple, Microsoft and community representatives in working groupcreated by the W3C.

A key goal of the WebGPU is to provide a secure, user-friendly, portable, and high-performance API for using the Web Platform's 3D graphics technologies and capabilities provided by modern system graphics APIs such as Direct3D 12 on Windows, Metal on macOS, and Vulkan on Linux. Conceptually, WebGPU differs from WebGL in much the same way that Vulkan differs from OpenGL, and at the same time is not based on a specific graphics API, but is a universal layer that generally uses the same low-level primitives that are found in Vulkan, Metal and Direct3D.

WebGPU provides JavaScript applications with the means for lower-level control over the organization, processing and transmission of commands to the GPU, managing associated resources, memory, buffers, texture objects, and compiled graphics shaders. This approach allows you to achieve higher performance graphics applications by reducing overhead and increasing the efficiency of the GPU.

WebGPU makes it possible to create full-fledged complex 3D projects for the Web that work no worse than stand-alone programs that directly access Vulkan, Metal or Direct3D, but are not tied to specific platforms. The WebGPU also provides additional opportunities for porting native graphics programs to a web-based form through the use of WebAssembly technology. In addition to 3D graphics, WebGPU also covers the possibilities associated with the removal of calculations to the GPU side and support for the development of shaders. Shaders can be created in the WebGPU Shading Language or specified in the intermediate SPIR-V format, and then translated into the shader languages ​​supported by the current drivers.

WebGPU uses separate management of resources, preparatory work and transmission of commands to the GPU (in WebGL, one object was responsible for everything at once). Three separate contexts are provided:
GPUDevice for creating resources like textures and buffers; GPUCommandEncoder for encoding individual commands, including the rendering and calculation stages; GPUCommandBuffer to pass to the GPU run queue. The result can be rendered in an area associated with one or more canvas elements, or processed without output (for example, when running computational tasks). The separation of stages makes it easier to separate resource creation and provisioning operations into different handlers that can run on different threads.

The second difference between WebGPU and WebGL is a different approach to handling states. WebGPU provides two objects - GPURenderPipeline and GPUComputePipeline, which allow you to combine different states predefined by the developer, which makes it possible for the browser to not waste resources on additional work, such as recompiling shaders. Supported states include: shaders, vertex buffer and attribute layouts, sticky group layouts, blending, depth and patterns, post-render output formats.

The third feature of WebGPU is called the binding model, in many ways
reminiscent of Vulkan's resource grouping tools.
To group resources into groups, the WebGPU provides a GPUBindGroup object, which, at the time of writing commands, can be associated with other similar objects for use in shaders. Creating such groups allows the driver to perform the necessary preparatory actions in advance, and allows the browser to change resource bindings between draw calls much faster. The layout of resource bindings can be predefined using the GPUBindGroupLayout object.

WebGPU support added to Firefox nightly builds

In Firefox, to enable WebGPU in about:config, the setting "dom.webgpu.enabled" is provided. Rendering the CanvasContext also requires the compositing system to be enabled. WebRender ("gfx.webrender.all" in about:config), written in Rust and outsourcing page content rendering operations to the GPU side. WebGPU implementation based on project code
wgpu, written in Rust and capable of running on top of the DX12, Vulkan, and Metal APIs on Linux, Android, Windows, and macOS (support for DX11 and OpenGL ES 3.0 is also in development). In parallel, Google is developing another implementation, which is available in canary-branch Chromium and is enabled using the "chrome://flags/#enable-unsafe-webgpu" flag, but so far only works on macOS and Windows.

Source: opennet.ru

Add a comment