[D3D12] HLSL 6?
By reading old messages: https://github.com/halide/Halide/issues/7072#issue-1400197951 And this message:
So, this seems to be a bug in the "old" HLSL compiler (FXC, `d3dcompiler_47.dll`, produces DXBC).
The bug does not happen in the "new" compiler (DXC, `dxcmpiler.dll`, produces DXIL).
Since FXC is being deprecated, it's unlikely we'll get enough traction to push for a fix.
Moving our d3d12 runtime to the new compiler is the best choice, but there are caveats:
- need to modify the HLSL code-gen: kernel arguments need to be relocated t global scope; since Halide packs multiple kernels into the same file, argument conflicts are prone to happen.
- need to have access to the new DXC compiler, which does not ship with the Microsoft D3D12 runtime yet
- need to jump to Shader Model 6, which could break some hardware compatibility (or maybe I'm too paranoid here)
- RenderDoc can't seem to be able to step-debug through DXIL; ~maybe PIX can do it?~, but PIX can.
Originally posted by @slomp in https://github.com/halide/Halide/issues/7072#issuecomment-1275354915
Do we have a plan? How can I help?. I think we need to give more love of D3D12.
- dxc is distributed with Windows SDK.
- And the gap is pretty closed with LLVM.
- Having HLSL 6 will allow us to have Atomic for 64 bits integers without that, multiple most of histogram test fail on D3D12 due to the lack of those atomic.
References: https://github.com/microsoft/DirectXShaderCompiler/wiki/FAQ#how-does-the-new-compiler-integrate-into-the-windows-sdk https://discourse.llvm.org/t/rfc-adding-hlsl-and-directx-support-to-clang-llvm/60783 https://github.com/microsoft/DirectXShaderCompiler/wiki/SPIR%E2%80%90V-CodeGen https://github.com/Microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_Int64_and_Float_Atomics.html#integer-64-bit-capabilities
Hi @soufianekhiat,
For SM 6 support, I think we'll have to introduce a companion feature flag to Direct3D 12 (say, d3d12compute-sm6), and then extend the current HLSL code generator with SM 6 (when the feature flag is set).
As for the runtime module, we'd have to also adjust it for the feature flag, load the proper dxcompiler.lib, and implement an equivalent D3DCompile() function on top of the DXC API (I actually have code for that, and I can ask for a code release, if necessary).
I'm still working on it. Do we need a process to create a branch? Halide_sk_d3d12_hlsl_6.patch Let me know if you have any comment. [WIP]
I'm still working on it. Do we need a process to create a branch? Halide_sk_d3d12_hlsl_6.patch Let me know if you have any comment. [WIP]
Just follow standard GitHub practice: fork the project on your own repo, create a branch there, and submit a pull request. Also, please run all the correctness tests locally if possible.
Thanks, I'll share a part 1 of the changes here: https://github.com/soufianekhiat/Halide/tree/sk/d3d12_hlsl_6
@soufianekhiat Please open a PR from your repo branch to merge into Halide main. It will make it easier for us to review, provide feedback, and even run the build/test bots.
@slomp sure:
https://github.com/halide/Halide/pull/8207
Far from being ready. I keep having:
Error: Debug info not available: no device.
I wasn't able to debug the runtime (yet):
https://github.com/halide/Halide/issues/8203
Still having conflict with symbol, clang constrain etc.