Skip to content

PIX: Correct the disambiguation of AS+MS threads for mesh shader output#6592

Merged
jeffnn merged 4 commits intomicrosoft:mainfrom
jeffnn:PIX_ASThreadIdTake2
May 13, 2024
Merged

PIX: Correct the disambiguation of AS+MS threads for mesh shader output#6592
jeffnn merged 4 commits intomicrosoft:mainfrom
jeffnn:PIX_ASThreadIdTake2

Conversation

@jeffnn
Copy link
Copy Markdown
Collaborator

@jeffnn jeffnn commented May 6, 2024

PIX requires that all vertex information generated by these passes be uniquely identified by vertex id and MS thread id.
This change fixes the MS thread id part in two places: the amplification shader and the mesh shader.
To be unique across an entire DispatchMesh call, we must uniquify the AS thread group, the AS thread, the MS thread group and the MS thread. This is a lot of multiplying and adding, and there wasn't quite enough math going on here before.
In the AS case, we now generate a unique "flat" thread id from the flat-thread-id-in-group (the already-available system value) and the "flat group id", which we synthesize by multiplying together the group id components with the DispatchMesh API's thread group counts, and then multiplying that by the number of threads each AS group launches, then add the flat-thread-id-in-group. (This flat id then goes into an expanded version of the AS->MS payload, the code for which was pre-existing.)
The MS will either treat the incoming AS thread id as its unique thread-group-within-the-whole-dispatch id.
If the AS is not active, the instrumentation herein will synthesize a flat id in the same way as the AS did before it passed that id through the payload, again from the DispatchMesh parameters (newly-added params to that pass) and the flat-thread-in-group.

In addition to the new filecheck tests for this, there is also a new filecheck test to cover coercion of non-i32 types to i32 before being written to PIX's output UAV, which I happened to notice wasn't adequately tested.

@jeffnn jeffnn self-assigned this May 6, 2024
@jeffnn jeffnn requested a review from a team as a code owner May 6, 2024 21:55
@damyanp damyanp added this to the May 2024 Release milestone May 8, 2024
Comment thread lib/DxilPIXPasses/DxilPIXAddTidToAmplificationShaderPayload.cpp
Copy link
Copy Markdown
Collaborator

@coopp coopp 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 to me. Glad to see the tests too!

@jeffnn jeffnn merged commit f9389db into microsoft:main May 13, 2024
SjMxr233 pushed a commit to ShaderHelper/DirectXShaderCompiler that referenced this pull request Jul 24, 2025
…ut (microsoft#6592)

PIX requires that all vertex information generated by these passes be
uniquely identified by vertex id and MS thread id.
This change fixes the MS thread id part in two places: the amplification
shader and the mesh shader.
To be unique across an entire DispatchMesh call, we must uniquify the AS
thread group, the AS thread, the MS thread group and the MS thread. This
is a lot of multiplying and adding, and there wasn't quite enough math
going on here before.
In the AS case, we now generate a unique "flat" thread id from the
flat-thread-id-in-group (the already-available system value) and the
"flat group id", which we synthesize by multiplying together the group
id components with the DispatchMesh API's thread group counts, and then
multiplying that by the number of threads each AS group launches, then
add the flat-thread-id-in-group. (This flat id then goes into an
expanded version of the AS->MS payload, the code for which was
pre-existing.)
The MS will either treat the incoming AS thread id as its unique
thread-group-within-the-whole-dispatch id.
If the AS is not active, the instrumentation herein will synthesize a
flat id in the same way as the AS did before it passed that id through
the payload, again from the DispatchMesh parameters (newly-added params
to that pass) and the flat-thread-in-group.

In addition to the new filecheck tests for this, there is also a new
filecheck test to cover coercion of non-i32 types to i32 before being
written to PIX's output UAV, which I happened to notice wasn't
adequately tested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project
Status: Triaged

Development

Successfully merging this pull request may close these issues.

4 participants