Skip to content

[PIX] Fix shared instrumentation resource handling - #8842

Open
Damyan Pepper (damyanp) wants to merge 4 commits into
users/damyanp/pix-fixes-01from
users/damyanp/pix-fixes-02
Open

[PIX] Fix shared instrumentation resource handling#8842
Damyan Pepper (damyanp) wants to merge 4 commits into
users/damyanp/pix-fixes-01from
users/damyanp/pix-fixes-02

Conversation

@damyanp

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

Copy link
Copy Markdown
Member

Part 2 of 14 in the PIX instrumentation stack. It targets users/damyanp/pix-fixes-01, which supplies the validation helpers. Eleven later layers use the helpers this layer changes, so please review it with care.

More than one PIX pass can run on the same module. Each pass adds its own tools UAV, so a pipeline with two passes makes two resources at the same register and space.

The code that adds this UAV to a root signature has three unsafe paths. Root signature serialization can fail and give a null blob, which the code then reads. An empty result can replace a correct root signature. Only the first global root-signature subobject gets the new parameter, so a state object that declares more than one is left in a mixed state.

The tools UAV is a raw buffer, so it changes the shader flags of the module. The code does not compute the flags again. Some passes make a dx.op overload declaration and then find no callers for it. They leave the declaration in the module, and the validator refuses a module that has an unused declaration.

When serialization fails, the helpers keep the original root signature. A valid signature is better than an empty one.

Assisted-by: Copilot

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


Stack created with GitHub Stacks CLIGive Feedback 💬

More than one PIX pass can run on the same module. Each pass adds its own tools UAV, so a pipeline with two passes makes two resources at the same register and space.

The code that adds this UAV to a root signature has three unsafe paths. Root signature serialization can fail and give a null blob, which the code then reads. An empty result can replace a correct root signature. Only the first global root-signature subobject gets the new parameter, so a state object that declares more than one is left in a mixed state.

The tools UAV is a raw buffer, so it changes the shader flags of the module. The code does not compute the flags again. Some passes make a dx.op overload declaration and then find no callers for it. They leave the declaration in the module, and the validator refuses a module that has an unused declaration.

When serialization fails, the helpers keep the original root signature. A valid signature is better than an empty one.

Assisted-by: Copilot

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

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@damyanp
Damyan Pepper (damyanp) marked this pull request as ready for review August 27, 2026 23:31
Copilot AI balanced review requested due to automatic review settings August 27, 2026 23:31

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 instrumentation resource reuse, root-signature handling, shader flags, and unused DXIL operation declarations.

Changes:

  • Reuses tools UAVs and safely updates all global root signatures.
  • Recomputes shader flags and centralizes unused declaration cleanup.
  • Adds regression and validation coverage for affected PIX passes.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/clang/unittests/HLSL/PixTest.cpp Adds PIX resource, root-signature, flags, cleanup, and validation tests.
tools/clang/test/HLSLFileCheck/pix/pixelCounterEarlyZ.hlsl Updates expected raw-buffer shader flags.
lib/DxilPIXPasses/PixPassHelpers.h Exposes the operation cleanup helper.
lib/DxilPIXPasses/PixPassHelpers.cpp Implements UAV reuse, root-signature updates, flags, and cleanup.
lib/DxilPIXPasses/DxilRemoveDiscards.cpp Removes unused discard declarations.
lib/DxilPIXPasses/DxilPIXMeshShaderOutputInstrumentation.cpp Cleans obsolete mesh operation overloads.
lib/DxilPIXPasses/DxilPIXAddTidToAmplificationShaderPayload.cpp Cleans the replaced dispatch declaration.
lib/DxilPIXPasses/DxilOutputColorBecomesConstant.cpp Cleans unused output overloads.
lib/DxilPIXPasses/DxilNonUniformResourceIndexInstrumentation.cpp Cleans unused instrumentation operations.
lib/DxilPIXPasses/DxilDebugInstrumentation.cpp Removes obsolete UAV-selection logic.
lib/DxilPIXPasses/DxilDebugBreakInstrumentation.cpp Uses centralized operation cleanup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/DxilPIXPasses/PixPassHelpers.cpp Outdated
Comment on lines 246 to 249
ExtendRootSig<DxilRootSignatureDesc1, DxilRootParameter1>(rs->Desc_1_1,
toolsUAVRegister);
rs->Desc_1_1.pParameters[rs->Desc_1_1.NumParameters - 1].Descriptor.Flags =
hlsl::DxilRootDescriptorFlags::None;
Bring the final approved L1 tip, including its formatting follow-up, into this layer while preserving the original L2 commit as the first parent.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ExtendRootSig returns early, without appending a parameter, when a
version 1.1 root signature already holds the requested tools UAV. The
caller still unconditionally cleared Descriptor.Flags on the last
parameter in that case, which may be an unrelated, pre-existing
parameter whose flags the caller must not disturb.

Have ExtendRootSig report whether it actually appended a parameter, and
only clear flags on that path.

Add a regression test: a v1.1 root signature with the tools UAV already
present as parameter 0 and an unrelated root descriptor as parameter 1
with DataVolatile flags. Re-requesting the same register leaves
parameter 1's flags untouched; appending a genuinely new register still
leaves parameter 1 untouched and gives the new parameter None flags.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the stable, nameable auto-deduced types introduced by L2. Retain only the two DxilSubobjects MapVector ranges whose underlying pair type is implementation-dependent and obscures the loop.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 3, 2026 02:13

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.

🟡 Changes recommended

Declaration cleanup mutations must be reflected in pass modification results.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

tools/clang/unittests/HLSL/PixTest.cpp:4243

  • Use the explicit CComPtr<IDxcBlob> type here. Compile results use that type throughout these new tests (for example, line 4224 immediately above), matching the repository's almost-never-auto convention.
  auto compiled = Compile(m_dllSupport, source, L"cs_6_10", {});
  • Files reviewed: 11/11 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +389 to +393
void EraseIfUnused(hlsl::DxilModule &DM, llvm::Function *OpFunction) {
if (OpFunction != nullptr && OpFunction->user_empty()) {
DM.GetOP()->RemoveFunction(OpFunction);
OpFunction->eraseFromParent();
}
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