Repository navigation
[PIX] Fix render-state visualization passes - #8850
Damyan Pepper (damyanp) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes PIX render-state visualization for 16-bit outputs, valid constant-buffer metadata, and modern MSAA handles.
Changes:
- Supports all legal
storeOutputoverloads and 16-bit narrowing. - Adds valid constant-buffer layout annotations.
- Handles SM 6.6 annotated resources and f16 MSAA loads.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/DxilPIXPasses/DxilOutputColorBecomesConstant.cpp |
Adds 16-bit output support and valid buffer metadata. |
lib/DxilPIXPasses/DxilReduceMSAAToSingleSample.cpp |
Recognizes annotated handles and all load overloads. |
tools/clang/unittests/HLSL/PixTest.cpp |
Adds validation and MSAA regression tests. |
tools/clang/test/HLSLFileCheck/pix/constantcolorminprecisionMRT.hlsl |
Tests min-precision MRT output. |
tools/clang/test/HLSLFileCheck/pix/constantcolorminprecisionint.hlsl |
Tests min-precision integer output. |
tools/clang/test/HLSLFileCheck/pix/constantcolorminprecisionFromCB.hlsl |
Tests min-precision buffer narrowing. |
tools/clang/test/HLSLFileCheck/pix/constantcolorminprecision.hlsl |
Tests min-precision float literals. |
tools/clang/test/HLSLFileCheck/pix/constantcolorint16.hlsl |
Tests native 16-bit integer output. |
tools/clang/test/HLSLFileCheck/pix/constantcolorhalfMRTOnRTV1.hlsl |
Tests half output on RTV1. |
tools/clang/test/HLSLFileCheck/pix/constantcolorhalfMRT.hlsl |
Tests half output on RTV0. |
tools/clang/test/HLSLFileCheck/pix/constantcolorhalfFromCB.hlsl |
Tests native-half buffer narrowing. |
tools/clang/test/HLSLFileCheck/pix/constantcolorhalf.hlsl |
Tests native-half literal replacement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| : Builder.CreateTrunc(ReplacementColors[ChannelIndex], | ||
| OutputValueType, | ||
| NarrowedNames[ChannelIndex]); |
|
|
||
| unsigned RangeId = | ||
| cast<ConstantInt>(CreateHandle.get_rangeId())->getLimitedValue(); | ||
| auto Resource = DM.GetSRV(RangeId); |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Cleanup does not report all module mutations, and the integer constant-buffer narrowing branch lacks regression coverage.
Review effort: Balanced
Findings: 2
Open (7)
Propagate cleanup modifications in pass result · New The new integer narrowing branch is not exercised. The added FromCB tests cover f16… Use explicit annotation pointer type · New Use explicit pointer type · New Use explicit return types · New Use explicit vector and element types · NewGetSRVreturns a reference, so plainautocopies the entire resource and also conflicts with…
| std::array<Function *, 4> &OutputFunctions; | ||
| ~EraseUnusedOutputFunctionsOnExit() { | ||
| for (Function *OutputFunction : OutputFunctions) { | ||
| PIXPassHelpers::eraseIfUnused(DM, OutputFunction); |
| pCBuf->SetSize(4); | ||
| pCBuf->SetSize(ConstantColorCBufferSizeInBytes); | ||
|
|
||
| auto *StructAnnotation = DM.GetTypeSystem().GetStructAnnotation(CBStructTy); |
| bool DxilReduceMSAAToSingleSample::runOnModule(Module &M) { | ||
| DxilModule &DM = M.GetOrCreateDxilModule(); | ||
| static bool IsMultisampledSRVHandle(Value *TextureHandle, DxilModule &DM) { | ||
| auto *TextureHandleInst = dyn_cast<CallInst>(TextureHandle); |
| auto compiled = Compile(m_dllSupport, source, L"ps_6_0", {L"-Od"}); | ||
| auto output = runSinglePass(compiled, L"-hlsl-dxil-constantColor,mod-mode=1"); |
| auto lines = Tokenize(Disassemble(pNewContainer).c_str(), "\n"); | ||
| bool foundConstantColorCBuffer = false; | ||
| for (auto const &line : lines) { |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The newly introduced 16-bit integer constant-buffer truncation branch lacks direct regression coverage.
Review effort: Balanced
Findings: 2
Open (7)
Propagate cleanup modifications in pass result The new integer narrowing branch is not exercised. The added FromCB tests cover f16… Use explicit vector and element types Use explicit return types Use explicit pointer type Use explicit annotation pointer typeGetSRVreturns a reference, so plainautocopies the entire resource and also conflicts with…
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new i16 constant-buffer truncation path lacks coverage, and several additions violate the explicit-type convention.
Review effort: Balanced
Findings: 2
Open (10)
Propagate cleanup modifications in pass result The new integer narrowing branch is not exercised. The added FromCB tests cover f16… Use explicit field-annotation reference type · New Use explicit types for short inferred locals · New Use explicit const string reference element type · New Use explicit vector and element types Use explicit return types Use explicit pointer type Use explicit annotation pointer typeGetSRVreturns a reference, so plainautocopies the entire resource and also conflicts with…
| auto &FieldAnnotation = | ||
| StructAnnotation->GetFieldAnnotation(ComponentIndex); |
| auto &FunctionUse = *FI++; | ||
| auto FunctionUser = FunctionUse.getUser(); | ||
| auto instruction = cast<Instruction>(FunctionUser); | ||
| DxilInst_TextureLoad LoadInstruction(instruction); | ||
| auto TextureHandle = LoadInstruction.get_srv(); | ||
| auto TextureHandleInst = cast<CallInst>(TextureHandle); | ||
| DxilInst_CreateHandle createHandle(TextureHandleInst); | ||
| // Dynamic rangeId is not supported | ||
| if (isa<ConstantInt>(createHandle.get_rangeId())) { | ||
| unsigned rangeId = | ||
| cast<ConstantInt>(createHandle.get_rangeId())->getLimitedValue(); | ||
| if (static_cast<DXIL::ResourceClass>( | ||
| createHandle.get_resourceClass_val()) == | ||
| DXIL::ResourceClass::SRV) { | ||
| auto Resource = DM.GetSRV(rangeId); | ||
| if (Resource.GetKind() == DXIL::ResourceKind::Texture2DMS || | ||
| Resource.GetKind() == DXIL::ResourceKind::Texture2DMSArray) { | ||
| // "2" is the mip-level/sample-index operand index: | ||
| // https://github.com/Microsoft/DirectXShaderCompiler/blob/master/docs/DXIL.rst#textureload | ||
| instruction->setOperand(2, HlslOP->GetI32Const(0)); | ||
| Modified = true; | ||
| } | ||
| } | ||
| auto *InstructionUser = dyn_cast<Instruction>(FunctionUse.getUser()); |
| const char *textureLoadOverload, | ||
| const char *originalSampleIndex) { | ||
| bool foundTextureLoad = false; | ||
| for (auto const &line : lines) { |
95eca4e to
ddc1237
Compare
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The no-target path incorrectly reports no module mutation, and the new integer narrowing branch lacks coverage.
Review effort: Balanced
Findings: 2
Open (10)
Propagate cleanup modifications in pass result The new integer narrowing branch is not exercised. The added FromCB tests cover f16… Use explicit const string reference element type Use explicit types for short inferred locals Use explicit field-annotation reference type Use explicit vector and element types Use explicit return types Use explicit pointer type Use explicit annotation pointer typeGetSRVreturns a reference, so plainautocopies the entire resource and also conflicts with…
ddc1237 to
6c1b3a6
Compare
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Cleanup reports an incorrect modification result, and the new integer narrowing path lacks coverage.
Review effort: Balanced
Findings: 2
Open (10)
Propagate cleanup modifications in pass result The new integer narrowing branch is not exercised. The added FromCB tests cover f16… Use explicit const string reference element type Use explicit types for short inferred locals Use explicit field-annotation reference type Use explicit vector and element types Use explicit return types Use explicit pointer type Use explicit annotation pointer typeGetSRVreturns a reference, so plainautocopies the entire resource and also conflicts with…
6c1b3a6 to
2f1e63e
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The newly added integer 16-bit constant-buffer narrowing path lacks regression coverage, alongside several convention issues.
Review effort: Balanced
Findings: 2
Open (11)
Propagate cleanup modifications in pass result The new integer narrowing branch is not exercised. The added FromCB tests cover f16… Use explicit types for helper results · New Use explicit const string reference element type Use explicit types for short inferred locals Use explicit field-annotation reference type Use explicit vector and element types Use explicit return types Use explicit pointer type Use explicit annotation pointer typeGetSRVreturns a reference, so plainautocopies the entire resource and also conflicts with…
| auto compiled = Compile(m_dllSupport, source, L"ps_6_6", {L"-Od"}); | ||
| auto output = runSinglePass(compiled, L"-hlsl-dxil-reduce-msaa-to-single"); | ||
| auto lines = Tokenize(Disassemble(output.Module).c_str(), "\n"); |
2f1e63e to
5565bfb
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The no-target path mutates the module during scope cleanup while incorrectly reporting that no modification occurred.
12 open findings
Propagate cleanup modifications in pass result The new integer narrowing branch is not exercised. The added FromCB tests cover f16… Add release note for 16-bit instrumentation fix · New Use explicit types for helper results Use explicit const string reference element type Use explicit types for short inferred locals Use explicit field-annotation reference type Use explicit vector and element types Use explicit return types Use explicit pointer type Use explicit annotation pointer typeGetSRVreturns a reference, so plainautocopies the entire resource and also conflicts with…
🧠 Review effort: Balanced
| // dx.op.storeOutput has four legal overloads: f16, f32, i16 and i32. | ||
| // A min16float or min16int SV_Target lowers through the f16 or i16 form, | ||
| // as does a native half or int16_t target under -enable-16bit-types. |
DxilOutputColorBecomesConstant handles all storeOutput overloads (including 16-bit), gives its constant buffer a layout the validator accepts, and DxilReduceMSAAToSingleSample looks through annotateHandle and accepts 16-bit texture loads. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 40dc9de3-617e-4caf-ab0d-fba0a033ed93
5565bfb to
78d27d7
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The constant-color pass can remove declarations while incorrectly reporting that the module was unmodified.
12 open findings
Propagate cleanup modifications in pass result The new integer narrowing branch is not exercised. The added FromCB tests cover f16… Add release note for 16-bit instrumentation fix Use explicit types for helper results Use explicit const string reference element type Use explicit types for short inferred locals Use explicit field-annotation reference type Use explicit vector and element types Use explicit return types Use explicit pointer type Use explicit annotation pointer typeGetSRVreturns a reference, so plainautocopies the entire resource and also conflicts with…
🧠 Review effort: Balanced


dx.op.storeOutput has four legal overloads: f16, f32, i16, and i32. DxilOutputColorBecomesConstant looks only for f32 and i32. A shader that writes SV_Target0 as min16float, min16int, half, or int16_t gets no constant-color instrumentation. The pass then asserts that the outputs are not mixed, and that assertion cannot tell "both types present" from "neither type recognised".
The pass builds a constant buffer for the colour, but it does not give that buffer a layout ValidateCBuffer can reach. The validator therefore refuses the instrumented module.
DxilReduceMSAAToSingleSample does not look through annotateHandle, and it does not accept a 16-bit texture load.
Only one overload can write SV_Target0, so there is no mixed case to resolve. PIX always uploads four 32-bit components, so the shader narrows them when the output is 16 bits. The upload format does not change.
Assisted-by: Copilot
Stack created with GitHub Stacks CLI • Give Feedback 💬