Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[D3D12] HLSL 6? #8164

Open
soufianekhiat opened this issue Mar 27, 2024 · 6 comments
Open

[D3D12] HLSL 6? #8164

soufianekhiat opened this issue Mar 27, 2024 · 6 comments

Comments

@soufianekhiat
Copy link

By reading old messages:
#7072 (comment)
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 #7072 (comment)

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

@slomp
Copy link
Contributor

slomp commented Mar 28, 2024

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).

@soufianekhiat
Copy link
Author

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]

@slomp
Copy link
Contributor

slomp commented Apr 16, 2024

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.

@soufianekhiat
Copy link
Author

Thanks, I'll share a part 1 of the changes here:
https://github.com/soufianekhiat/Halide/tree/sk/d3d12_hlsl_6

@slomp
Copy link
Contributor

slomp commented Apr 24, 2024

@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.

@soufianekhiat
Copy link
Author

@slomp sure:
#8207
Far from being ready. I keep having:
Error: Debug info not available: no device.
I wasn't able to debug the runtime (yet):
#8203
Still having conflict with symbol, clang constrain etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants