[PIX] Fix DXR invocation log bounds - #8845
Open
Damyan Pepper (damyanp) wants to merge 1 commit into
Open
Conversation
Each DXR invocation takes one slot in the log with an atomic increment on the counter UAV. If the slot number is too large, the pass limits it to the last slot. Every invocation that overflows therefore writes over the last correct record. PIX sees a full log with a plausible final entry and cannot detect the truncation. A capacity of zero makes that clamp wrap to a very large value, so a log with no slots accepts writes. An out-of-range slot must produce no write. The correct records then stay unchanged, and the overflow stays visible, because the claimed count is larger than the capacity. An invocation that overflows contributes no record. A tool that treats a full log as a complete log must compare the claimed count with the capacity. Assisted-by: Copilot Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 40dc9de3-617e-4caf-ab0d-fba0a033ed93
Damyan Pepper (damyanp)
requested a review
from Austin Kinross (austinkinross)
August 27, 2026 23:33
Damyan Pepper (damyanp)
marked this pull request as ready for review
August 27, 2026 23:35
Austin Kinross (austinkinross)
approved these changes
Aug 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes PIX DXR invocation logging so out-of-capacity entries do not overwrite valid records.
Changes:
- Replaces index clamping with a guarded write path.
- Disables instrumentation for zero-capacity logs.
- Adds overflow, boundary, and validation tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
lib/DxilPIXPasses/DxilPIXDXRInvocationsLog.cpp |
Adds bounds-checked record writes. |
tools/clang/unittests/HLSL/PixTest.cpp |
Adds capacity and validation tests. |
tools/clang/test/HLSLFileCheck/pix/InvocationsLog_OverflowIsNotClamped.hlsl |
Verifies overflow is guarded rather than clamped. |
tools/clang/test/HLSLFileCheck/pix/InvocationsLog_ClosestHit.hlsl |
Updates checks to reflect removal of clamping. |
Suppressed comments (3)
tools/clang/unittests/HLSL/PixTest.cpp:3671
- These declarations infer straightforward
CComPtr<IDxcBlob>andstd::vector<std::string>types. Please spell them explicitly per the repository's almost-never-auto convention (PixTest.cpp:1814-1815andPixTest.cpp:3724show the established forms).
auto compiledLib =
Compile(m_dllSupport, kSingleMissInvocationLogShader, L"lib_6_6", {});
auto output = RunDxilPIXDXRInvocationsLog(compiledLib, 1);
auto lines = Tokenize(Disassemble(output), "\n");
tools/clang/unittests/HLSL/PixTest.cpp:3680
- These declarations infer straightforward
CComPtr<IDxcBlob>andstd::vector<std::string>types. Please spell them explicitly per the repository's almost-never-auto convention (PixTest.cpp:1814-1815andPixTest.cpp:3724show the established forms).
auto compiledLib =
Compile(m_dllSupport, kSingleMissInvocationLogShader, L"lib_6_6", {});
auto output = RunDxilPIXDXRInvocationsLog(compiledLib, 24);
auto lines = Tokenize(Disassemble(output), "\n");
tools/clang/unittests/HLSL/PixTest.cpp:3688
- These declarations infer the short
CComPtr<IDxcBlob>type. Please spell it explicitly per the repository's almost-never-auto convention; the same test file uses this explicit form atPixTest.cpp:1814-1815.
auto compiledLib =
Compile(m_dllSupport, kSingleMissInvocationLogShader, L"lib_6_6", {});
auto output = RunDxilPIXDXRInvocationsLog(compiledLib, 1);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+207
to
+208
| auto *EntryIndexIsInRange = Builder.CreateICmpULT( | ||
| EntryIndex, MaxEntryCountAsConstant, "EntryIndexIsInRange"); |
Comment on lines
+3655
to
+3663
| auto compiledLib = | ||
| Compile(m_dllSupport, kSingleMissInvocationLogShader, L"lib_6_6", {}); | ||
|
|
||
| auto oneEntryOutput = RunDxilPIXDXRInvocationsLog(compiledLib, 1); | ||
| auto oneEntryLines = Tokenize(Disassemble(oneEntryOutput), "\n"); | ||
| VERIFY_ARE_EQUAL(2, CountToolsUAVRecords(oneEntryLines)); | ||
|
|
||
| auto zeroEntryOutput = RunDxilPIXDXRInvocationsLog(compiledLib, 0); | ||
| auto zeroEntryLines = Tokenize(Disassemble(zeroEntryOutput), "\n"); |
Comment on lines
+687
to
+693
| const std::string expectedSuffix = ", " + std::to_string(expectedEntryCount); | ||
| for (auto const &line : lines) { | ||
| if (line.find("icmp ult i32 %EntryIndexResult") != std::string::npos && | ||
| line.find(expectedSuffix) != std::string::npos) { | ||
| return true; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each DXR invocation takes one slot in the log with an atomic increment on the counter UAV. If the slot number is too large, the pass limits it to the last slot. Every invocation that overflows therefore writes over the last correct record. PIX sees a full log with a plausible final entry and cannot detect the truncation.
A capacity of zero makes that clamp wrap to a very large value, so a log with no slots accepts writes.
An out-of-range slot must produce no write. The correct records then stay unchanged, and the overflow stays visible, because the claimed count is larger than the capacity.
An invocation that overflows contributes no record. A tool that treats a full log as a complete log must compare the claimed count with the capacity.
Assisted-by: Copilot
Stack created with GitHub Stacks CLI • Give Feedback 💬