Microsoft Wants To Add DirectX + HLSL Support To The Upstream LLVM/Clang Compiler

Written by Michael Larabel in Microsoft on 9 March 2022 at 08:00 AM EST. 16 Comments
MICROSOFT
Microsoft has laid out a proposal whereby they are hoping to contribute support for DirectX, the HLSL shading language, and Vulkan graphics support to the upstream LLVM/Clang compiler.

Back in 2017 Microsoft announced an open-source DirectX Shader Compiler. That current DirectX Shader Compiler "DXC" is based on an old LLVM Clang 3.7 fork and showing its age while Microsoft is hoping to create a modern re-implementation of that for upstream LLVM/Clang to in turn also enjoy modern C++ language features, tooling improvements around HLSL shaders, and other features.

With their new DirectX compiler implementation they are looking to initially support the DirectX Intermediate Language (DXIL) and SPIR-V as the common IR used by the Khronos APIs. Microsoft in the future may add support for DirectX Bytecode (DXBC) as used by DirectX 9 through DirectX 11.


Microsoft is looking to move to upstream LLVM/Clang for its future DirectX shader compiler.


Microsoft does somewhat surprisingly acknowledge the importance of Khronos' SPIR-V. "There have been many discussions of SPIR-V in the LLVM community. SPIR-V is a virtual ISA used for GPU programming. Since SPIR-V code generation is widely used by developers writing HLSL, this is a critically important feature for us too. There are several possible ways we could support SPIR-V, and we are looking forward to actively engaging with the community to solve this problem."

Due to LLVM/Clang 3.7 being seven years old, Microsoft isn't looking to simply upstream it's old DXC compiler code but rather re-implementing it within the modern LLVM code-base piece-by-piece. This process would involve introducing HLSL-specific options to the Clang front-end, DirectX target support for both LLVM and Clang, and more. There still are some open design elements around how the code generation would be handled and is to be sorted out between Microsoft and the upstream LLVM developers. In turn this may also end up jiving with the work being pursued for the SPIR-V back-end for LLVM.

The RFC proposal ends with, "Microsoft is making a commitment to bring Clang up to feature parity with DXC, but the HLSL community is supporting this effort and we expect to fully shift development over to LLVM/main after HLSL support becomes feature complete."
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week