#shader #pipeline #hlsl #intellisense #dxc


HLSL compiler library, this crate provides an FFI layer and idiomatic rust wrappers for the new DXC HLSL compiler and validator

23 releases

0.11.0 Nov 1, 2023
0.10.0 Jan 28, 2023
0.9.0 Mar 24, 2022
0.5.4 Oct 18, 2021
0.1.6 Dec 15, 2018

#13 in Graphics APIs

Download history 18071/week @ 2023-08-09 14715/week @ 2023-08-16 13128/week @ 2023-08-23 12616/week @ 2023-08-30 19050/week @ 2023-09-06 18087/week @ 2023-09-13 14335/week @ 2023-09-20 14928/week @ 2023-09-27 15190/week @ 2023-10-04 14659/week @ 2023-10-11 15210/week @ 2023-10-18 16786/week @ 2023-10-25 17335/week @ 2023-11-01 17489/week @ 2023-11-08 25970/week @ 2023-11-15 16546/week @ 2023-11-22

79,743 downloads per month
Used in 606 crates (3 directly)

MIT license

2.5K SLoC

🌤 hassle-rs

Actions Status Latest version Documentation Lines of code MIT Contributor Covenant


This crate provides an FFI layer and idiomatic rust wrappers for the new DirectXShaderCompiler library.


Add this to your Cargo.toml:

hassle-rs = "0.11.0"

Then acquire dxcompiler.dll on Windows or libdxcompiler.so on Linux directly from AppVeyor, or compile it from source according to the instructions in the DirectXShaderCompiler GitHub repository and make sure it's in the executable environment. See our support table below for specific compatibility notes on non-Windows OSes.

DxcValidator also requires dxil.dll which can be grabbed from any recent DXC release: https://github.com/microsoft/DirectXShaderCompiler/releases/latest More info: https://www.wihlidal.com/blog/pipeline/2018-09-16-dxil-signing-post-compile/

Supported DXC versions on non-Windows

Outside of Windows (e.g. Unix) the emulated COM API needed its fair share of fixes to match the layout on Windows. This results in repetitive API breakage that is hard to detect from within hassle-rs: be sure to math the hassle-rs release below to a minimum DXC commit to prevent runtime failures outside of Windows!

Since hassle-rs DXC release Git commit
0.10.0 v1.7.2212 https://github.com/microsoft/DirectXShaderCompiler/commit/47f31378a9b51894b0465b33ac1d10ce6349a468
0.5.1 (if using intellisense) release-1.6.2012 https://github.com/microsoft/DirectXShaderCompiler/commit/2ade6f84d6b95bfd96eec1d6d15e3aa3b519d180

When compiling on MacOS with clang, or Linux with gcc, be sure to have at least https://github.com/microsoft/DirectXShaderCompiler/commit/af14220b45d3ce46e0bad51ce79655e41d07c478 (also included in release-1.6.2012).

Interesting DXC commits pertaining Unix support

These patches have had an effect on hassle-rs compatibility over time:

Usage examples

Compile HLSL into SPIR-V

let spirv = compile_hlsl(
        ("MY_DEFINE", Some("Value")),
        ("OTHER_DEFINE", None)

Compile HLSL into DXIL and validate it

let dxil = compile_hlsl("test.cs.hlsl", test_cs, "main", "cs_6_5", args, &[]).unwrap();
let result = validate_dxil(&dxil); // Only a Windows machine in Developer Mode can run non-validated DXIL

if let Some(err) = result.err() {
    println!("validation failed: {}", err);


Licensed under MIT license (LICENSE or http://opensource.org/licenses/MIT)


  • Graham Wihlidal
  • Tiago Carvalho
  • Marijn Suijten
  • Tomasz Stachowiak
  • Manon Oomen


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, shall be licensed as above, without any additional terms or conditions.

Contributions are always welcome; please look at the issue tracker to see what known improvements are documented.


~86K SLoC