Skip to content

[PIX] Record only real resource accesses, including samplers - #8847

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

[PIX] Record only real resource accesses, including samplers#8847
Damyan Pepper (damyanp) wants to merge 1 commit into
users/damyanp/pix-fixes-05from
users/damyanp/pix-fixes-06

Conversation

@damyanp

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

Copy link
Copy Markdown
Member

Part 6 of 14 in the PIX instrumentation stack. It targets users/damyanp/pix-fixes-05. Its content depends on PR 2 for the shared helpers.

The shader access tracking pass records an access for each DXIL operation that takes a resource handle. Two of these operations are not accesses. annotateHandle attaches type information to a handle. barrierByMemoryHandle puts accesses in order. The pass therefore reports a read or a write at a point where the shader touches no memory.

The pass also matches a library handle against the UAVs, the SRVs, and the constant buffers, but not against the samplers. A sampler access in a library shader gets no record, so the sampler binding looks unused.

An access that consumes an annotated handle keeps its record. The pass still looks through the annotation to reach the resource.

PIX receives fewer incorrect records and more sampler records. A tool that counts records will see different totals.

Assisted-by: Copilot

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


Stack created with GitHub Stacks CLIGive Feedback 💬

The shader access tracking pass records an access for each DXIL operation that takes a resource handle. Two of these operations are not accesses. annotateHandle attaches type information to a handle. barrierByMemoryHandle puts accesses in order. The pass therefore reports a read or a write at a point where the shader touches no memory.

The pass also matches a library handle against the UAVs, the SRVs, and the constant buffers, but not against the samplers. A sampler access in a library shader gets no record, so the sampler binding looks unused.

An access that consumes an annotated handle keeps its record. The pass still looks through the annotation to reach the resource.

PIX receives fewer incorrect records and more sampler records. A tool that counts records will see different totals.

Assisted-by: Copilot

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

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

Corrects PIX shader access tracking to record genuine resource accesses, including library samplers, while excluding annotations and barriers.

Changes:

  • Adds sampler matching for library handles.
  • Excludes AnnotateHandle and resource barriers from access records.
  • Adds FileCheck and validation coverage.

Reviewed changes

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

Show a summary per file
File Description
lib/DxilPIXPasses/DxilShaderAccessTracking.cpp Updates resource matching and non-access exclusions.
tools/clang/unittests/HLSL/PixTest.cpp Extends pass configuration and validation tests.
tools/clang/test/HLSLFileCheck/pix/AccessTrackingLibAnnotateHandleIsNotAnAccess.hlsl Tests annotation exclusion.
tools/clang/test/HLSLFileCheck/pix/AccessTrackingLibAnnotatedHandleReadStillRecorded.hlsl Tests accesses through annotated handles.
tools/clang/test/HLSLFileCheck/pix/AccessTrackingBarrierIsNotAnAccess.hlsl Tests barrier exclusion.

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

Comment on lines +1299 to +1305
std::string needle = "i32 " + std::to_string(byteOffset);
for (auto const &line : lines) {
if (line.find("dx.op.bufferStore") != std::string::npos &&
line.find(needle) != std::string::npos) {
return true;
}
}
Comment on lines +1327 to +1330
auto compiled = Compile(m_dllSupport, hlsl, L"lib_6_6", {L"-Od"});
auto output = RunShaderAccessTrackingPass(
compiled, L"S0:0:4i0;M0:20:4i0;U0:40:4i0;.0;0;0.");
auto lines = Split(Disassemble(output.blob), '\n');
})x";

auto compiled = Compile(m_dllSupport, source, L"ps_6_0", {L"-Od"});
auto output = RunShaderAccessTrackingPass(compiled);
return textures[index].Sample(samp, pos.xy);
})x";

auto compiled = Compile(m_dllSupport, source, L"ps_6_0", {L"-Od"});
if (global == Sampler->GetGlobalSymbol()) {
binding =
hlsl::resource_helper::loadBindingFromResourceBase(Sampler.get());
ret.registerType = RegisterType::Sampler;
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