Skip to content

HLSL 6.0 ... 6.9 and GPUTexture for d3d12#9077

Draft
soufianekhiat wants to merge 25 commits intohalide:mainfrom
soufianekhiat:sk/hlsl_6
Draft

HLSL 6.0 ... 6.9 and GPUTexture for d3d12#9077
soufianekhiat wants to merge 25 commits intohalide:mainfrom
soufianekhiat:sk/hlsl_6

Conversation

@soufianekhiat
Copy link
Copy Markdown

@soufianekhiat soufianekhiat commented Mar 25, 2026

Breaking changes

  • Add support for HLSL 6.0 ... 6.9
  • Add support for GPU Texture on d3d12compute

Details:

  • Emit "//HALIDE_D3D12_SM XX" on HLSL version and being parsed to avoid complex infrastructure just to get that version KISS.
  • Co-authored-by: Claude (all code formating, comments and mini_dxc.cpp was 100% written by Claude Opus 4.6)

Checklist

  • Tests added or updated (not required for docs, CI config, or typo fixes)
  • Documentation updated (if public API changed)
  • Python bindings updated (if public API changed)
  • Benchmarks are included here if the change is intended to affect performance.
  • Commits include AI attribution where applicable (see Code of Conduct)

@soufianekhiat
Copy link
Copy Markdown
Author

Is that possible to have a maintainer trigger the CI for this one please?

@alexreinking
Copy link
Copy Markdown
Member

We don't seem to have any d3d12compute coverage on the buildbots. I'll need to add that prior to reviewing/merging this.

@soufianekhiat
Copy link
Copy Markdown
Author

We don't seem to have any d3d12compute coverage on the buildbots. I'll need to add that prior to reviewing/merging this.

Added this to tests HLSL 6.x features:
test/correctness/cross_compilation.cpp
https://github.com/halide/Halide/pull/9077/changes#diff-8155bdbbeeb25a66365bbd00273602683aa90a2f220c98dbaa8e15f6f988403e

@alexreinking alexreinking added the dev_meeting Topic to be discussed at the next dev meeting label Mar 26, 2026
alexreinking added a commit to halide/build_bot that referenced this pull request Mar 27, 2026
@alexreinking
Copy link
Copy Markdown
Member

I've modified the buildbots to test d3d12compute_sm65, which is the highest version both Windows bots support. We'll see how this goes! I notice that several features here are gated behind higher versions than that. I've tagged this dev_meeting so we can discuss a testing plan.

@alexreinking
Copy link
Copy Markdown
Member

Many tests require strict_float... it seemed easy enough to implement following the precise hint and copying the Vulkan backend's approach to lowering. The only tricky business is that we need a different key than the given expression (or we'd need to implement a bunch of strict_OP intrinsics with precise arguments).

@soufianekhiat soufianekhiat changed the title HLSL 6.0 ... 6.9 HLSL 6.0 ... 6.9 and GPUTexture for d3d12 Mar 27, 2026
@alexreinking
Copy link
Copy Markdown
Member

@soufianekhiat -- can you look at the codegen failures here? There seem to be two classes of bug:

  1. Globals have clashing names. I'm not sure what the best resolution here is.
  2. "as" casts are misspelled, e.g. asfloat32_t instead of asfloat

@soufianekhiat
Copy link
Copy Markdown
Author

@soufianekhiat -- can you look at the codegen failures here? There seem to be two classes of bug:

  1. Globals have clashing names. I'm not sure what the best resolution here is.
  2. "as" casts are misspelled, e.g. asfloat32_t instead of asfloat

Do we have tests for codegen? I just run locally the one I think are relevant.

@alexreinking
Copy link
Copy Markdown
Member

Do we have tests for codegen? I just run locally the one I think are relevant.

We don't have (many) compile-only tests... I'm just looking at the buildbot failures here; the issues are with invalid code being generated which is why I called them "codegen failures".

Also, I'm noticing that there's some signed/unsigned mismatch happening somewhere.

https://buildbot.halide-lang.org/master/#/builders/391/builds/385

@alexreinking alexreinking mentioned this pull request Mar 28, 2026
5 tasks
@alexreinking
Copy link
Copy Markdown
Member

@soufianekhiat - I've opened #9080 to test patches that are generally needed to fix the D3D12 backend, even for HLSL <6.0. That should provide a more stable foundation for this PR, which should be scoped to extending support to 6.0-6.9, rather than also including fundamental bug-fixes.

@alexreinking
Copy link
Copy Markdown
Member

@soufianekhiat - the HLSL 5.1 fixes are in, so please rebase/merge with main.

@soufianekhiat
Copy link
Copy Markdown
Author

Thanks

alexreinking and others added 3 commits March 28, 2026 23:06
- Remove dead duplicate strict_float handler (bad merge artifact); the
  ScopedValue<emit_precise> approach is the correct implementation
- Fix strict_fma to emit mad() for float/float16 (HLSL fma() is
  double-only; mad() is the correct float FMA intrinsic)
- Add hlsl_reinterpret_name() helper so 'as' casts always emit the
  correct HLSL name (asfloat/asint/asuint/asfloat16) regardless of SM
  level; fixes asfloat32_t -> asfloat regression at SM >= 6.2
- Fix DXC global name clashes: prefix all arg names with the kernel
  name via RenameKernelArgs IRMutator; rename cbuffer per-kernel to
  avoid redeclaration errors in multi-kernel pipelines
@soufianekhiat soufianekhiat force-pushed the sk/hlsl_6 branch 2 times, most recently from 8872efc to 58223e6 Compare March 28, 2026 22:19
@alexreinking alexreinking requested review from slomp and removed request for derek-gerstmann March 31, 2026 23:41
Copy link
Copy Markdown
Contributor

@slomp slomp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few observations and suggestions to get started.
(I will try to carve some time to review the runtime and code-gen properly, and to run everything locally).

@soufianekhiat soufianekhiat requested a review from slomp April 1, 2026 09:53
@soufianekhiat
Copy link
Copy Markdown
Author

@slomp here my systematic generation code:
https://gist.github.com/soufianekhiat/e3fa5aea28d14ed85722b6756e61af8d

@alexreinking
Copy link
Copy Markdown
Member

alexreinking commented Apr 1, 2026

@soufianekhiat -- looks like you forgot to update Target.h/.cpp while changing the naming scheme to hlsl_smXY. I just updated the buildbots to use that scheme going forward.

@alexreinking
Copy link
Copy Markdown
Member

Just FYI, the buildbot changes I made affect all PRs, so I can't keep them indefinitely. After this week, I'm going to need to revert them if this isn't merged, so you'll need a way to test this locally rather than relying on CI for iteration.

If there's something missing in your local setup that's making that hard, let me know and maybe I can help. I do want to see this land, I just need to keep the shared buildbot usage manageable.

@soufianekhiat
Copy link
Copy Markdown
Author

Make the tests skip 64 bits for skip correctness_{gpu_mixed_shared_mem_types, math, newtons_method}, unsupported on dx12 (DXGI_FORMAT).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev_meeting Topic to be discussed at the next dev meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants