Skip to content

[PIX] Fix mesh shader instrumentation - #8855

Open
Damyan Pepper (damyanp) wants to merge 1 commit into
users/damyanp/pix-fixes-13from
users/damyanp/pix-fixes-14
Open

[PIX] Fix mesh shader instrumentation#8855
Damyan Pepper (damyanp) wants to merge 1 commit into
users/damyanp/pix-fixes-13from
users/damyanp/pix-fixes-14

Conversation

@damyanp

@damyanp Damyan Pepper (damyanp) commented Aug 28, 2026

Copy link
Copy Markdown
Member

Part 14 of 14 in the PIX instrumentation stack. It targets users/damyanp/pix-fixes-13. Its content depends on PR 2 for the declaration cleanup and the shared UAV behavior.

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

This changes only the PIX instrumentation, so it needs no release note.


Stack created with GitHub Stacks CLIGive Feedback 💬

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

Copilot AI left a comment

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.

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();
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