DirectX Shader Compiler is a software tool designed to compile High-Level Shader Language (HLSL) programs into DirectX Intermediate Language (DXIL) representation. This compiler enables developers to create shader programs compatible with DirectX graphics APIs for applications in gaming, visualization, and computation.
Key Features:
Command-line compilation: The dxc.exe tool allows developers to compile HLSL shaders directly from the command line.
Componentized architecture: The dxcompiler.dll provides modular access to compiler, assembler, disassembler, and validator functionalities.
DXIL support up to version 1.5: Enables shader development for DirectXShaderModel 6.6 and beyond, supporting advanced GPU capabilities.
LLVM/Clang integration: Built on the LLVM infrastructure, enabling extensibility and compatibility with a wide range of tools and languages.
Cross-platform compatibility: Works across various Windows 10 versions, ensuring broad support for shader development.
Audience & Benefit:
Ideal for graphics developers creating DirectX-based applications, this compiler provides the necessary tools to optimize performance and leverage cutting-edge GPU features. By supporting the latest DirectX shader models and DXIL formats, it ensures compatibility with modern hardware while enabling efficient development workflows.
The DirectX Shader Compiler can be installed via winget, making it accessible for integration into development environments.
README
DirectX Shader Compiler
The DirectX Shader Compiler project includes a compiler and related tools used to compile High-Level Shader Language (HLSL) programs into DirectX Intermediate Language (DXIL) for DirectX and the Standard Portable Intermediate Representation (SPIR-V) for Vulkan.
Applications that make use of DirectX or Vulkan for graphics, games, and computation can use it to generate shader program binaries.
The starting point of the project is a fork of the LLVM and Clang projects, modified to accept HLSL and emit a validated shader binary that can be consumed by GPU drivers.
At the moment, the DirectX Shader Compiler releases provide the following components:
dxc.exe, a command-line tool that can compile HLSL programs for shader model 6.0 or higher
dxcompiler.[dll|so], a DLL providing a componentized compiler, assembler, disassembler, and validator
dxil.[dll|so], a DLL providing the DXIL validation and hashing support
dxv.exe, a command-line tool that validates DXIL IR (compiled HLSL programs)
A collection of C++ headers for working with the contained dynamic libraries
A collection of HLSL headers exposing useful high level abstractions
The Microsoft Windows SDK releases include a supported version of the compiler and validator.
The goal of the project is to allow the broader community of shader developers to contribute to the language and representation of shader programs, maintaining the principles of compatibility and supportability for the platform. It's currently in active development across two axes: language evolution (with no impact to DXIL representation), and surfacing hardware capabilities (with impact to DXIL, and thus requiring coordination with GPU implementations).
Development kits containing only the dxc.exe driver app, the dxcompiler.dll, and the dxil.dll signing binary are available here, or in the releases tab.
SPIR-V CodeGen
As an example of community contribution, this project can also target the SPIR-V intermediate representation. Please see the doc for how HLSL features are mapped to SPIR-V, and the wiki page for how to build, use, and contribute to the SPIR-V CodeGen.
Metal CodeGen
When built from source DXC can utilize the Metal Shader
Converter if it is
available during build and configuration time. This allows DXC to generate Metal
shader libraries directly using the -metal flag.
Note: DXC cannot currently disassemble Metal shaders so the -Fc flag cannot be
used in conjunction with the -Fo flag.
To run shaders compiled as DXIL, you will need support from the operating system as well as from the driver for your graphics adapter. Windows 10 Creators Update is the first version to support DXIL shaders. See the Wiki for information on using experimental support or the software adapter.
Hardware Support
Hardware GPU support for DXIL is provided by the following vendors:
NVIDIA
NVIDIA's r396 drivers (r397.64 and later) provide release mode support for DXIL
1.1 and Shader Model 6.1 on Win10 1709 and later, and experimental mode support
for DXIL 1.2 and Shader Model 6.2 on Win10 1803 and later. These drivers also
support DXR in experimental mode.
AMD’s driver (Radeon Software Adrenalin Edition 18.4.1 or later) provides release mode support for DXIL 1.1 and Shader Model 6.1. Drivers can be downloaded from AMD's download site.
Intel
Intel's 15.60 drivers (15.60.0.4849 and later) support release mode for DXIL 1.0 and Shader Model 6.0 as well as
release mode for DXIL 1.1 and Shader Model 6.1 (View Instancing support only).
To make contributions, see the CONTRIBUTING.md file in this project.
Documentation
You can find documentation for this project in the docs directory. These contain the original LLVM documentation files, as well as two new files worth nothing:
HLSLChanges.rst: this is the starting point for how this fork diverges from the original llvm/clang sources
DXIL.rst: this file contains the specification for the DXIL format