Collabora develops an add-on for running OpenCL and OpenGL on top of DirectX

Company Collabora presented a new Gallium driver for Mesa that implements a layer for organizing the work of the OpenCL 1.2 and OpenGL 3.3 APIs on top of DirectX 12 (D3D12)-enabled drivers. Code published under the MIT license.

The proposed driver allows Mesa to be used on devices that do not natively support OpenCL and OpenGL, and also as a starting point for porting OpenGL/OpenCL applications to run on top of D3D12. For GPU manufacturers, the subsystem makes it possible to provide support for OpenCL and OpenGL, if drivers are available that only support D3D12.

From the nearest plans, achievement of full passing of tests for compatibility of OpenCL 1.2 and OpenGL 3.3, verification of compatibility with applications and inclusion of developments in the main structure of Mesa is noted. Development is carried out jointly with Microsoft engineers developing open tools D3D11On12 to transfer games from D3D11 to D3D12 and the library D3D12TranslationLayer, which implements typical graphical primitives on top of D3D12.

The implementation includes a Gallium driver, an OpenCL compiler, an OpenCL runtime, and a NIR-to-DXIL shader compiler that converts Mesa's NIR shader intermediate representation to DirectX 12's DXIL (DirectX Intermediate Language) binary format, based on the LLVM 3.7 bitcode (DirectX Shader Compiler from Microsoft is essentially an extended fork of LLVM 3.7). The OpenCL compiler is prepared based on the developments of the LLVM project and tools SPIRV-LLVM.

Sources with OpenCL extensions are compiled using clang into LLVM intermediate pseudocode (LLVM IR), which is then converted to an intermediate representation of OpenCL kernels in SPIR-V format. Cores in SPIR-V representation are passed to Mesa, translated to NIR format, optimized and passed to NIR-to-DXIL to generate compute shaders in DXIL format suitable for GPU execution using DirectX 12 based runtime.
Instead of Mesa's Clover implementation of OpenCL, a new OpenCL runtime has been proposed that allows more direct conversions to the DirectX 12 API.

Collabora develops an add-on for running OpenCL and OpenGL on top of DirectX

OpenCL and OpenGL drivers are prepared using the Gallium interface provided in Mesa, which allows you not to delve into OpenGL-specific details when creating drivers and translate OpenGL calls into entities that are closer to the graphical primitives that modern GPUs operate on. Gallium driver, accepts OpenGL commands and when using the NIR-to-DXIL translator
generates command buffers that are executed on the GPU using the D3D12 driver.

Source: opennet.ru

Add a comment