Skip to content

[PIX] Attribute library accesses to reaching entry points - #8849

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

Damyan Pepper (damyanp) wants to merge 1 commit into
users/damyanp/pix-fixes-07from
users/damyanp/pix-fixes-08

Conversation

@damyanp

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

Copy link
Copy Markdown
Member

Part 8 of 14 in the PIX instrumentation stack. It targets users/damyanp/pix-fixes-07, which supplies the bind-point test support.

The pass either skips a helper function in a library or gives its access the Library shader kind. Library is the kind of the module. It does not identify the pipeline stage that reaches the access. PIX cannot tell whether a record comes from a ray generation, closest-hit, or miss shader.

The access record holds the instruction number in a field of 24 bits. A larger number overflows into the adjacent fields of the record.

PIX receives records for helper functions, and each record carries a pipeline stage. A tool that filtered out records with the Library kind will see more data.

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

Attributes PIX resource-access records in library helpers to their reaching shader entry-point kind and prevents instruction ordinals from corrupting adjacent record fields.

Changes:

  • Resolves shader kinds through the library call graph.
  • Masks instruction ordinals to 24 bits.
  • Adds library-helper and bindless-access tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/DxilPIXPasses/DxilShaderAccessTracking.cpp Adds shader-kind propagation and safe record encoding.
tools/clang/test/HLSLFileCheck/pix/AccessTrackingLibHelperShaderKind.hlsl Verifies ray-generation encoding in a helper.
tools/clang/unittests/HLSL/PixTest.cpp Adds instrumentation and validation tests.

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

Comment on lines +849 to +853
auto emplaced =
functionToShaderKind.emplace(reached, entryPointShaderKind);
if (!emplaced.second && emplaced.first->second != entryPointShaderKind) {
emplaced.first->second = ambiguousShaderKind;
}
Comment on lines +1335 to +1336
uint32_t value =
static_cast<uint32_t>(strtoul(line.c_str() + position, &end, 10));
Comment on lines +557 to +559
constexpr uint32_t InstructionOrdinalMask = 0x00FF'FFFF;
uint32_t EncodedInstructionNumber =
(InstructionNumber & InstructionOrdinalMask) |
Copilot AI review requested due to automatic review settings September 29, 2026 02:56

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 +551 to +553
auto *EncodedShaderKindConstant = cast<ConstantInt>(
m_FunctionToEncodedAccess.at(Builder.GetInsertBlock()->getParent())
.at(ResourceAccessStyle::None));
Copilot AI review requested due to automatic review settings September 29, 2026 16:29

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 +832 to +842
for (llvm::Function *entryPoint : entryPoints) {
if (entryPoint == nullptr || entryPoint->isDeclaration()) {
continue;
}

const DXIL::ShaderKind entryPointShaderKind =
PIXPassHelpers::GetFunctionShaderKind(DM, entryPoint);

std::vector<llvm::Function *> pending{entryPoint};
std::set<llvm::Function *> visited;
while (!pending.empty()) {

for (llvm::BasicBlock &block : reached->getBasicBlockList()) {
for (llvm::Instruction &instruction : block.getInstList()) {
auto *call = llvm::dyn_cast<llvm::CallInst>(&instruction);
static bool
HasBufferStoreValueMatchingMask(std::vector<std::string> const &lines,
uint32_t mask, uint32_t maskedValue) {
for (auto const &line : lines) {
Copilot AI balanced review requested due to automatic review settings September 30, 2026 00:06

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 910 to 911
auto instrumentableFunctions =
PIXPassHelpers::GetAllInstrumentableFunctions(DM);
Copilot AI balanced review requested due to automatic review settings October 1, 2026 22:00

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.

std::map<llvm::Function *, DXIL::ShaderKind> functionToShaderKind;

const DXIL::ShaderKind ambiguousShaderKind = DM.GetShaderModel()->GetKind();
auto entryPoints = DM.GetExportedFunctions();
Comment on lines +551 to +553
auto *EncodedShaderKindConstant = cast<ConstantInt>(
m_FunctionToEncodedAccess.at(Builder.GetInsertBlock()->getParent())
.at(ResourceAccessStyle::None));
Attribute accesses in library helper functions to the pipeline stage of the entry points that reach them instead of the Library kind, and keep instruction numbers from overflowing the 24-bit record field.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 40dc9de3-617e-4caf-ab0d-fba0a033ed93
Copilot AI balanced review requested due to automatic review settings October 1, 2026 23:11

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 instrumentableFunctions =
PIXPassHelpers::GetAllInstrumentableFunctions(DM);

auto functionToShaderKind = ResolveShaderKindByReachingEntryPoint(DM);
Comment on lines +1575 to +1577
auto compiled = Compile(m_dllSupport, hlsl, L"lib_6_6", {L"-Od"});
auto output = RunShaderAccessTrackingPass(compiled, L".0;0;0.");
auto lines = Split(Disassemble(output.blob), '\n');

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