Jump to content

Microsoft and Collabora Announce Project to Map OpenGL and OpenCL Over DirectX 12


Guest_Jim_*

Recommended Posts

For playing games on Linux that were not necessarily meant for it, a valuable piece of software is DXVK. This software serves as a translation layer that can intercept DirectX calls and translate them into Vulkan calls, so the multi-platform graphics API can be used to render games that normally only uses the Windows-only API. The current version of DXVK is able to work with DirectX 9, DirectX 10, and DirectX 11, and I have heard of it improving performance in some games, and have personally seen it successfully work around a game engine-driver issue.

Today it was announced by Microsoft and Collabora that they are working on a translation layer that will map OpenCL and OpenGL to DirectX 12. The current target is to support OpenCL 1.2 and OpenGL 3.3, but hopefully it will come to cover OpenGL 2.x and OpenGL 4.x. The purpose for this software is to provide a means to get these older APIs supported on modern devices that may not have proper or complete support for them, but do support the D3D12 API. This mapping layer would also be able to serve as a starting point for those porting older OpenCL and OpenGL applications to DX12.

Actually getting this to work is a bit involved, as the Collabora blog post explains. The project will start with Mesa 3D, an open source implementation of many graphics technologies. Its support for OpenGL is already robust and is used for several "industry-strength" OpenGL drivers. The Gallium interface for Mesa 3D will also be used, which will help as it is able to translate OpenGL calls into something more similar to modern GPU primitives, and it can hade various legacy OpenGL details.

Making the work complicated is differences between shaders between Mesa 3D and DirectX 12. While Mesa 3D uses NIR to internally represent GPU shaders while DirectX 12 uses DXIL. When Microsoft created DXIL it based it on LLVM 3.7 bitcode with some additional metadata and validation, which was a sensible decision as every major driver vendor used LLVM in its compiler toolchain. Unfortunately, because of how LLVM has developed since, the DirectX Shader Compiler cannot be used as a back-end component. As LLVM continued to develop, with Collabora's compiler using a LLVM 10.0 front-end, it maintained backwards compatibility for the bitcode, LLVM itself is not forward compatible. This means that while LLVM could use bitcode from older versions, the new versions of LLVM cannot produce bitcode an older version would understand. This project's solution is to use a new DXIL emitter, which presents its own problems too as LLVM bitcode tries to be very dense, which will make interpreting it more difficult.

The last bit to this puzzle is the D3D12 Gallium driver that will take the OpenGL commands and along with the NIR to DXIL translator, create the D3D12 command-buffers for a DX12 supporting GPU to execute.

The work on Mesa 3D to make this possible will be contributed back to the open source project as the intent is to upstream the work to the main Mesa repository. Microsoft hopes it and the larger graphics development community will benefit from this work, but as it is still somewhat early, it may be a while before we see how the contributions are received. I know I am personally curious in seeing how this project goes. Though it is not directly related to DXVK, these projects are still interesting to me as a way to bring up support for older games and software, and as a way to sometimes side-step issues that appear. Hopefully more than just OpenGL 3.3 and OpenCL 1.2 will be supported, but it may take a while to get support for those two APIs nailed down. Proving the work as it currently is though, Collabora has shared a Windows version of glxgears.

Source: Collabora, Microsoft, and Phoronix




Back to original news post

Share this post


Link to post
Share on other sites

×
×
  • Create New...