Skip to content

WIP: microsoft/compiler: Add a DXBC (shader model 4.x / 5.x) backend

Jesse Natalie requested to merge jenatali/mesa:dxbc into main

In the D3D ecosystem, there's two IRs used:

  • DXIL, shader model 6.x, an LLVM IR, supported by D3D12 only, and only by "newer" drivers and OSes - original Win10 or 1st generation D3D12 GPUs/drivers may not support it. Prior to the DXIL backend in Mesa, this could only be emitted by Microsoft's DXC shader compiler.
  • DXBC, shader models prior to 6. These can be broken down further:
    • Shader model 5.1, supported by D3D12 only, but supported by all D3D12 runtimes/drivers.
    • Shader model 5.0, supported by D3D11 and D3D12.
    • Shader model 4.1, supported by D3D10.1 and up.
    • Shader model 4.0, supported by D3D10.0 and up.
    • Older shader models are not supported by modern D3D, and use a different bytecode format - still called DXBC, but not the same.

DXBC can only be emitted by FXC today (except for a SM1-3 -> SM4 upconverter in the D3D9On12 project). FXC is no longer under active development, or really even getting bugfixes. So, in order to emit DXBC today, you need to have HLSL (see tools like spirv-cross) and then make sure it doesn't hit any pathological cases in FXC, of which there are many. Some can take >1 minute to compile shaders that are relatively straightforward. This is a proposal for an alternate way to emit DXBC from SPIR-V without having to go all the way to HLSL first. It could also theoretically extend GLOn12's support to include pre-DXIL GPUs.

This DXBC backend targets SM5.1 mostly, but I was able to run some stuff targeting SM5.0. Haven't tried targeting 4.x, but should be simple, just a matter of not using opcodes/operands prefixed with D3D11_ (or D3D10_1_ for 4.0).

This is WIP because it needs a massive history cleanup/squash. This is the result of a couple of hackathon-type projects. It's able to run wglgears with GL-style NIR, but my main focus was the Dawn (Chromium WebGPU implementation) end2end test suite, which passes 100% on top of this.

Merge request reports