Skip to content

Implement GetGroupWaveIndex and GetGroupWaveCount#7959

Merged
JoeCitizen merged 16 commits intomicrosoft:mainfrom
JoeCitizen:Group-Wave-Intrinsics
Jan 12, 2026
Merged

Implement GetGroupWaveIndex and GetGroupWaveCount#7959
JoeCitizen merged 16 commits intomicrosoft:mainfrom
JoeCitizen:Group-Wave-Intrinsics

Conversation

@JoeCitizen
Copy link
Copy Markdown
Collaborator

Implement Group Wave Index and Group Wave Count as proposed by:
https://github.com/microsoft/hlsl-specs/blob/main/proposals/0048-group-wave-index.md

Added two new intrinsics:

  • GetGroupWaveIndex - returns the index of the wave in the thread group
  • GetGroupWaveCount - returns the number of waves in the thread group

Limited to Shader Model 6.10 and Compute, Mesh, Node and Amp. shaders.

Added basic test.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 2, 2025

✅ With the latest revision this PR passed the Python code formatter.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 2, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@JoeCitizen JoeCitizen marked this pull request as ready for review December 2, 2025 20:23
@damyanp
Copy link
Copy Markdown
Member

damyanp commented Dec 2, 2025

Could you add something to ReleaseNotes.md please?

Copy link
Copy Markdown
Member

@damyanp damyanp left a comment

Choose a reason for hiding this comment

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

Seems to LGTM, but I'm not an expert in this area.

@tex3d - do we need to wait for #7947 to land before merging this?

Comment thread docs/ReleaseNotes.md Outdated
Comment thread tools/clang/test/CodeGenSPIRV/sm6_10.group-wave-index.hlsl
Comment thread tools/clang/test/CodeGenSPIRV/sm6_10.group-wave-count.hlsl Outdated
Copy link
Copy Markdown
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

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

We have several SM 6.10 features staged in PRs now. In order to reduce conflicts, I'd like to suggest we make a separate PR reserving the HLSL Intrinsics and the experimental DXIL ops ahead of the rest of the changes.

This means a PR with just the additions to gen_intrin_main.txt, hctdb.py, nullptr , generated changes (hlsl_intrinsic_opcodes.json, DxilConstants.h, DXIL.rst, DxilInstructions.h, DxilOperations.cpp), and initial EmptyLower table entries for gLowerTable in HLOperationLower.cpp.

Of course, this will also depend on getting #7947 in first.

Copy link
Copy Markdown
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

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

I've put a PR up for reserving these operations here: #7995.

Once that's merged, this should be rebased onto main, but you won't want some of your changes here.

You don't need the changes in the generated files, or the addition of the HLSL instrinsics in gen_intrin_main.txt or DXIL ops in hctdb.py, or the HL op reservations in hlsl_intrinsic_opcodes.json.

You'll want to take what's in main for HLOperationLower.cpp's gLowerTable, then update the lowering function to TranslateWaveToVal.

Comment thread utils/hct/hctdb.py Outdated
Comment thread utils/hct/hctdb.py Outdated
Comment thread utils/hct/hctdb.py Outdated
Comment thread utils/hct/hlsl_intrinsic_opcodes.json Outdated
Comment thread utils/hct/gen_intrin_main.txt Outdated
@tex3d
Copy link
Copy Markdown
Contributor

tex3d commented Dec 11, 2025

I did a rebase and a test update, while catching a fault with the ordering of the lowering table entries in the opcode reservation change. Since it's not based on this branch (it's a rebase), I put the branch up here:
https://github.com/tex3d/DirectXShaderCompiler/tree/Group-Wave-Intrinsics

You can reset your branch to this and iterate from there to save a bunch of work.

@JoeCitizen JoeCitizen force-pushed the Group-Wave-Intrinsics branch from 84e7262 to 2388db2 Compare January 5, 2026 23:35
@damyanp damyanp linked an issue Jan 5, 2026 that may be closed by this pull request
@tex3d
Copy link
Copy Markdown
Contributor

tex3d commented Jan 6, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Collaborator

@s-perron s-perron left a comment

Choose a reason for hiding this comment

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

The SPIR-V changes look good. I did not review the rest.

Comment thread lib/DxilValidation/DxilValidation.cpp Outdated
@@ -0,0 +1,82 @@
; RUN: not %dxv %s 2>&1 | FileCheck %s

; CHECK: error: Function requires a visible group, but is called from a shader without one.
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.

Yeah, this mechanism is a bit of a backstop, and doesn't provide very clear diagnostic. I still think it would be beneficial to have a dedicated check and message for this case, especially since there is no front-end diagnostic that will catch it. But it's not critical that we add that at this time.

Copy link
Copy Markdown
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

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

Looks good. I had a minor comment about a dedicated diagnostic for thread-launch node shader, but it's not absolutely necessary to do that.

@V-FEXrt
Copy link
Copy Markdown
Collaborator

V-FEXrt commented Jan 12, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JoeCitizen JoeCitizen merged commit e5c51ea into microsoft:main Jan 12, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[SM 6.10] Group Wave Index preview

5 participants