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

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 CLI • Give Feedback 💬

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();
Copilot AI review requested due to automatic review settings September 29, 2026 04:46

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.

Copilot review overview

🟡 Changes recommended

The mesh pass still applies a locally derived fallback layout when the coordinator omits the amplification-shader layout.

Review effort: Balanced
Findings: 1 Medium severity · 3 Low severity

Open (4)

Comment on lines +110 to +111
auto const *expandedLayout = M.getDataLayout().getStructLayout(
cast<StructType>(expanded.ExpandedPayloadStructType));
uint32_t ExpandedSizeInBytes, uint32_t AppendedFieldsOffsetInBytes,
unsigned *AppendedFieldsElementIndex) {
ExpandedStruct ret = {};
auto *OriginalStructType = dyn_cast<StructType>(OriginalPayloadStructType);
Comment on lines +1628 to +1629
auto as = Compile(m_dllSupport, hlsl, L"as_6_6", {}, L"ASMain");
auto asOutput = RunDxilPIXAddTidToAmplificationShaderPayloadPass(as);
Copilot AI review requested due to automatic review settings September 29, 2026 16:36

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.

Copilot review overview

🟡 Changes recommended

The mesh pass still applies a locally derived payload layout when no amplification layout is forwarded.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity · 3 Low severity

Open (5)

Comment on lines +457 to +458
} else {
expanded = ExpandStructType(Ctx, OriginalPayloadStructType);
Copilot AI balanced review requested due to automatic review settings September 29, 2026 19:02

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.

Copilot review overview

🔵 Needs a closer look

Mesh payloads are still locally expanded when the coordinator omits the amplification-shader layout, contrary to the stated contract.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity · 3 Low severity

Open (5)

Copilot AI balanced review requested due to automatic review settings September 29, 2026 21:26

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.

Comment on lines +280 to +283
ExpandedSizeInBytes % sizeof(uint32_t) == 0 &&
ExpandedSizeInBytes >=
AppendedFieldsOffsetInBytes + AppendedFieldsSizeInBytes &&
ExpandedSizeInBytes <= DXIL::kMaxMSASPayloadBytes;
Copilot AI balanced review requested due to automatic review settings September 29, 2026 23:53

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.

constexpr uint32_t AppendedFieldsSizeInBytes = 3 * sizeof(uint32_t);
const DataLayout &DL = M.getDataLayout();
const StructLayout *OriginalLayout = DL.getStructLayout(OriginalStructType);
auto *Int32Type = Type::getInt32Ty(Ctx);
Copilot AI balanced review requested due to automatic review settings September 30, 2026 00:14

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.

auto asOutput = RunDxilPIXAddTidToAmplificationShaderPayloadPass(as);
auto lines = Tokenize(Disassemble(asOutput), "\n");
bool foundAlloca = false;
for (auto const &line : lines) {
Reconstruct the mesh shader payload from the amplification shader's reported expanded layout instead of a locally derived one, instrument mesh shaders whose payload is unread, sign-extend signed 16-bit outputs, remove unused EmitIndices declarations, and fix the reservation assertion.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40dc9de3-617e-4caf-ab0d-fba0a033ed93

This branch has not been deployed

No deployments
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