Skip to content

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

Merged
alexreinking merged 56 commits into
halide:mainfrom
soufianekhiat:sk/hlsl_6
May 19, 2026
Merged

HLSL 6.0 ... 6.9 and GPUTexture for d3d12#9077
alexreinking merged 56 commits into
halide:mainfrom
soufianekhiat:sk/hlsl_6

Conversation

@soufianekhiat
Copy link
Copy Markdown
Contributor

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

Comment thread src/CodeGen_D3D12Compute_Dev.cpp Outdated
Comment thread src/CodeGen_D3D12Compute_Dev.cpp Outdated
@soufianekhiat
Copy link
Copy Markdown
Contributor 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

Comment thread src/CodeGen_D3D12Compute_Dev.cpp Outdated
@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
Contributor Author

Thanks

Comment thread src/runtime/d3d12compute.cpp
@soufianekhiat
Copy link
Copy Markdown
Contributor Author

@alexreinking @shoaibkamil @slomp Let me know if that changes fits.

Comment thread src/runtime/d3d12compute.cpp
Comment thread src/runtime/d3d12compute.cpp
Upload,
ReadBack
ReadBack,
Texture
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think retrofitting textures into the buffer interface will lead to trouble eventually.
Technically, things like Upload/Readback and ReadOnly/ReadWrite are properties of the buffer that are also applicable (with their own quirks) to textures.
Is this how the other Halide back-ends implement textures (by just piggy-backing on the buffer interface)?

Comment thread src/runtime/d3d12compute.cpp Outdated
Comment thread src/runtime/d3d12compute.cpp Outdated
Comment thread src/runtime/d3d12compute.cpp Outdated
Comment thread src/runtime/d3d12compute.cpp Outdated
Comment thread src/runtime/d3d12compute.cpp
Comment thread src/runtime/d3d12compute.cpp Outdated
Comment thread src/runtime/d3d12compute.cpp Outdated
Comment thread src/runtime/d3d12compute.cpp Outdated
@slomp
Copy link
Copy Markdown
Contributor

slomp commented Apr 30, 2026

I'll give you and the other reviewers some time to discuss/address my points above, and once that's resolved, I'll give the runtime code another look.

I think the kernel argument packing logic which I wrote originally has some fundamental flaws that I want to explore, and adding/mixing 64bits to it has raised some concerns I need to verify in the meanwhile.

@soufianekhiat
Copy link
Copy Markdown
Contributor Author

@alexreinking could you help for the current state of build machines?

Comment thread src/runtime/d3d12compute.cpp Outdated
Comment thread src/runtime/d3d12compute.cpp Outdated
@slomp
Copy link
Copy Markdown
Contributor

slomp commented May 4, 2026

I had some worries about the byte straddling rules for cbuffer storage with the addition of 64-bit types, but I think it's all good. We don't use/mix HLSL vector types in the kernel arguments, so we should be good, as far as I can tell.

(If someone else would like to double-check and verify the argument packing rules, now would be a good time!)

@alexreinking
Copy link
Copy Markdown
Member

@soufianekhiat - how is this going? Seems @slomp had a few more comments

@soufianekhiat
Copy link
Copy Markdown
Contributor Author

@alexreinking still on it. Need more time, I really want to land this one.
Some question are really design question, and subjective question. Like I put Texture with HLSL 6 on the same PR.
Having a define or a comment, which to me is just a taste version particulary if we don't use it at all in code, I think I'll change it to a define.

So ti answer: WIP

@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

❌ Patch coverage is 13.49325% with 577 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@833447a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/CodeGen_D3D12Compute_Dev.cpp 5.50% 549 Missing ⚠️
src/Target.cpp 70.73% 9 Missing and 15 partials ⚠️
src/DeviceInterface.cpp 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9077   +/-   ##
=======================================
  Coverage        ?   69.40%           
=======================================
  Files           ?      255           
  Lines           ?    78139           
  Branches        ?    18694           
=======================================
  Hits            ?    54229           
  Misses          ?    18468           
  Partials        ?     5442           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

I don't have anything else to request or suggest, LGTM.
Thanks for the contribution!!

@alexreinking alexreinking merged commit 3bb5d0c into halide:main May 19, 2026
27 checks passed
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.

4 participants