Skip to content

Conversation

@JoeCitizen
Copy link

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
Contributor

github-actions bot commented Dec 2, 2025

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

@github-actions
Copy link
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
Member

damyanp commented Dec 2, 2025

Could you add something to ReleaseNotes.md please?

Copy link
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?

Copy link
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
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.

elif i.name.startswith("GetGroupWave"):
i.category = "Group Wave Ops"
i.shader_model = 6, 10
i.shader_stages = ("compute", "mesh", "amplification", "library")
Copy link
Contributor

Choose a reason for hiding this comment

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

You can back these changes out when you rebase on top of main with merged #7995.

counters=("floats",),
)

# Group Wave Operations
Copy link
Contributor

Choose a reason for hiding this comment

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

You can back these changes out when you rebase on top of main with merged #7995.

assert op_count == 312, (
"312 is expected next operation index but encountered %d and thus opcodes are broken"
assert op_count == 314, (
"314 is expected next operation index but encountered %d and thus opcodes are broken"
Copy link
Contributor

Choose a reason for hiding this comment

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

We definitely do not want this change.

"IOP_isnormal": 394
"IOP_isnormal": 394,
"IOP_GetGroupWaveCount": 395,
"IOP_GetGroupWaveIndex": 396
Copy link
Contributor

Choose a reason for hiding this comment

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

You can back these changes out when you rebase on top of main with merged #7995.

bool [[]] QuadAny(in bool cond);
bool [[]] QuadAll(in bool cond);
uint [[rn]] GetGroupWaveIndex();
uint [[rn]] GetGroupWaveCount();
Copy link
Contributor

Choose a reason for hiding this comment

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

You can back these changes out when you rebase on top of main with merged #7995.

@tex3d
Copy link
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.

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

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants