[PIX] Fix mesh shader instrumentation - #8855
Open
Damyan Pepper (damyanp) wants to merge 1 commit into
Open
Conversation
PIX instruments an amplification shader by expanding its payload to carry a group identifier. The mesh shader must agree on the resulting layout. When the two cannot be reconciled, the pass applies a locally derived layout that is known to disagree. The instrumented pair then disagrees about where each payload field lives. A mesh shader whose payload is never read is skipped, so its output cannot be instrumented at all. A signed 16-bit output is zero-extended instead of sign-extended. Unused EmitIndices declarations stay in the module, and the validator refuses it. The reservation assertion checks a value that is already zero, so it does not catch a caller that asks for enough space to overwrite the offset counter. The amplification shader reports the size and offset of the expanded payload through the expanded-payload-size and expanded-payload-offset options. The mesh shader reconstructs its payload type from that report. When reconstruction fails, the pass reports the failure and leaves the mesh payload unchanged. A mismatched pair produces records PIX cannot interpret, so there is no fallback layout. The pass does not expand a payload that is already near the size limit. If the PIX coordinator does not forward the layout of the amplification shader, the mesh shader leaves its payload unchanged. That is an integration item for PIX. Assisted-by: Copilot Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 886bcfe8-1fdc-4b99-ac8f-2947a66178f4
Damyan Pepper (damyanp)
requested a review
from Austin Kinross (austinkinross)
August 28, 2026 04:01
Damyan Pepper (damyanp)
marked this pull request as ready for review
August 28, 2026 04:02
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes PIX mesh-shader instrumentation so amplification and mesh shaders can share an expanded payload layout.
Changes:
- Reports and consumes expanded payload size and offset.
- Adds payload limits, alignment fixes, signed 16-bit handling, and declaration cleanup.
- Adds regression and validation coverage.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
utils/hct/hctdb.py |
Registers payload-layout pass options. |
tools/clang/unittests/HLSL/PixTest.cpp |
Adds PIX instrumentation regression tests. |
tools/clang/test/HLSLFileCheck/pix/SynthesizedPayloadTypeShapes.hlsl |
Tests synthesized payload layouts. |
tools/clang/test/HLSLFileCheck/pix/SynthesizedPayloadTypeRejectsUnusableLayout.hlsl |
Tests invalid-layout rejection. |
tools/clang/test/HLSLFileCheck/pix/MeshShaderWithoutEmitIndicesLeavesNoDeadDeclaration.hlsl |
Verifies declaration cleanup. |
tools/clang/test/HLSLFileCheck/pix/MeshPayloadExpansionAgreesWithAmplificationShader.hlsl |
Verifies AS/MS layout agreement. |
tools/clang/test/HLSLFileCheck/pix/MeshOutputSignedInt16IsSignExtended.hlsl |
Verifies signed 16-bit extension. |
tools/clang/test/HLSLFileCheck/pix/AddThreadIdWhenMSPayloadIsUnused.hlsl |
Updates unused-payload expectations. |
lib/DxilPIXPasses/DxilPIXMeshShaderOutputInstrumentation.cpp |
Reconstructs payload layouts and fixes output instrumentation. |
lib/DxilPIXPasses/DxilPIXAddTidToAmplificationShaderPayload.cpp |
Reports layout and enforces payload constraints. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+457
to
+460
| } else { | ||
| expanded = ExpandStructType(Ctx, OriginalPayloadStructType); | ||
| AppendedFieldsElementIndex = | ||
| OriginalPayloadStructType->getStructNumElements(); |
Austin Kinross (austinkinross)
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PIX instruments an amplification shader by expanding its payload to carry a group identifier. The mesh shader must agree on the resulting layout. When the two cannot be reconciled, the pass applies a locally derived layout that is known to disagree. The instrumented pair then disagrees about where each payload field lives.
A mesh shader whose payload is never read is skipped, so its output cannot be instrumented at all. A signed 16-bit output is zero-extended instead of sign-extended. Unused EmitIndices declarations stay in the module, and the validator refuses it. The reservation assertion checks a value that is already zero, so it does not catch a caller that asks for enough space to overwrite the offset counter.
The amplification shader reports the size and offset of the expanded payload through the expanded-payload-size and expanded-payload-offset options. The mesh shader reconstructs its payload type from that report. When reconstruction fails, the pass reports the failure and leaves the mesh payload unchanged. A mismatched pair produces records PIX cannot interpret, so there is no fallback layout.
The pass does not expand a payload that is already near the size limit.
If the PIX coordinator does not forward the layout of the amplification shader, the mesh shader leaves its payload unchanged. That is an integration item for PIX.
Assisted-by: Copilot
Stack created with GitHub Stacks CLI • Give Feedback 💬