Mach v0.3 has been released! For all the details check out the announcement

mach-dxcompiler

The DirectX shader compiler, built better.

GitHub repository | Issue tracker

See ‘Building the DirectX shader compiler better than Microsoft?’ for details/background information.

Features

  • Statically linked dxcompiler library and dxc executables.
  • Zero dependency on proprietary dxil.dll code-signing blob (see: Mach Siegbert Vogt DXCSA)
  • Built using build.zig instead of 10k+ LOC CMake build system.
  • Prebuilt binaries provided for many OS/arch.
  • Binaries for macOS and aarch64 Linux (first ever in history), among others.
  • Simple C API bundled into library as an alternative to the traditional COM API.

Building from source

Specify the -Dfrom_source build option to produce a build from source (the default is to fetch a prebuilt binary produced from our CI pipelines):

zig build -Dfrom_source -Doptimize=ReleaseFast -Dtarget=aarch64-macos
zig build -Dfrom_source -Doptimize=ReleaseFast -Dtarget=x86_64-windows-gnu -Dcpu=x86_64_v2
zig build -Dfrom_source -Doptimize=ReleaseFast -Dtarget=x86_64-linux-gnu -Dcpu=x86_64_v2

Getting started (Zig package)

First zig init to create a new Zig project. Then add the dependency (change LATEST_COMMIT to the actual latest commit hash from the repository):

zig fetch --save https://pkg.machengine.org/mach-dxcompiler/LATEST_COMMIT.tar.gz

Then in your build.zig file make the module importable in your code using e.g.:

    const dxcompiler_dep = b.dependency("mach_dxcompiler", .{
        .target = target,
        .optimize = ReleaseFast, // use an optimized compiler
        .from_source = false, // use a prebuilt binary
    });
    exe.root_module.addImport("mach-dxcompiler", dxcompiler_dep.module("mach-dxcompiler"));

For usage, see src/main.zig tests in the repository.

Ran into trouble?

Feel free to join the Mach Discord community for help.