The developers of the GTK library have announced the readiness of two new rendering engines — "ngl" and "vulkan", utilizing the graphic APIs OpenGL (GL 3.3+ and GLES 3.0+) and Vulkan. The new engines are included in the experimental release of GTK 4.13.6. In the experimental branch of GTK, the ngl engine is now used by default, but in case of significant issues in the next stable branch 4.14, the old rendering engine "gl" will be returned.
The new engines are positioned as unified and built from a single codebase. The essence of the unification is that the Vulkan API is used as the foundation, on top of which a separate abstraction layer for OpenGL has been created, taking into account the differences between OpenGL and Vulkan. This approach has allowed both engines to utilize a shared infrastructure for handling the scene graph, transformations, texture caching, and glyphs. Unification has also significantly simplified the maintenance of the codebase of both engines and their upkeep in an up-to-date and synchronized state.
Unlike the old "gl" engine, which used a separate simple shader for each type of rendering node (rendernode) and performed periodic data re-sorting during offscreen rendering, the new engines use a complex shader (ubershader) instead of offscreen rendering, interpreting data from the buffer. In its current form, the new implementation still lags behind the old in terms of optimizations, as the main focus at this stage is on correctness and ease of maintenance.
New capabilities that are absent in the old "gl" engine:
- Anti-aliasing — allows for preserving fine details and achieving smoother outlines.

- Formation of arbitrary gradients, which can use any number of colors and anti-aliasing (the "gl" engine only supported linear, radial, and conic gradients with 6 color stops).

- Fractional scaling, allowing for non-integer scale values — for example, when using a 125% scale for a 1200×800 window, a buffer of 1500×1000 will be allocated instead of 2400×1600 as in the old engine.
- Support for DMA-BUF technology for using multiple GPUs and offloading separate operations to another GPU.
- Many rendering nodes that had issues in the old implementation are now handled correctly.
The limitations of the new engines include the lack of support for positioning with fractional values and glshader nodes, which were heavily tied to the features of the old engine and are no longer necessary after the addition of support for nodes with masks and textures with transparency. Also mentioned is the potential for issues with graphic drivers due to changes in the way drivers are handled.
In the future, based on the new unified model, there may be rendering engines that use Metal on macOS and DirectX on Windows, but creating such engines is complicated by the use of different languages for shaders (the 'ngl' and 'vulkan' engines utilize GLSL, so for Metal and Direct, shaders will either need to be duplicated or a layer based on SPIRV-Cross tooling will need to be used).
Future plans include ensuring support for HDR and tools for accurate color management, GPU-based path rendering, glyph rendering, rendering outside the main thread, and performance optimization for older and lower-powered devices. Currently, the performance of the 'vulkan' engine is close to that of the old 'gl' engine. The 'ngl' engine lags behind the performance of the old 'gl' engine, but the existing metrics are sufficient for rendering at 60 or 144 FPS. It is anticipated that the situation will improve after optimization.
Source: opennet.ru

