Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ViewID] build viewid mask for primitive output #6886

Merged
merged 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions lib/HLSL/ComputeViewIdStateBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ class DxilViewIdStateBuilder {
// Contributing instructions per output.
std::unordered_map<unsigned, InstructionSetType>
ContributingInstructions[kNumStreams];

bool IsForPatchConstantOrPrimitive;
damyanp marked this conversation as resolved.
Show resolved Hide resolved
EntryInfo(bool ForPC) : IsForPatchConstantOrPrimitive(ForPC) {}
void Clear();
};

EntryInfo m_Entry;
EntryInfo m_PCEntry;
EntryInfo m_Entry = EntryInfo{false};
EntryInfo m_PCEntry = EntryInfo{true};

// Information per function.
using FunctionReturnSet = std::unordered_set<llvm::ReturnInst *>;
Expand Down Expand Up @@ -190,9 +191,12 @@ void DxilViewIdStateBuilder::Compute() {
CallGraph CG = CGA.run(m_pModule->GetModule());
m_Entry.pEntryFunc = m_pModule->GetEntryFunction();
m_PCEntry.pEntryFunc = m_pModule->GetPatchConstantFunction();
// For MS, use main entry as PC entry to collect primitive outputs.
if (pSM->IsMS())
m_PCEntry.pEntryFunc = m_pModule->GetEntryFunction();
ComputeReachableFunctionsRec(CG, CG[m_Entry.pEntryFunc], m_Entry.Functions);
if (m_PCEntry.pEntryFunc) {
DXASSERT_NOMSG(pSM->IsHS());
DXASSERT_NOMSG(pSM->IsHS() || pSM->IsMS());
ComputeReachableFunctionsRec(CG, CG[m_PCEntry.pEntryFunc],
m_PCEntry.Functions);
}
Expand Down Expand Up @@ -461,6 +465,7 @@ void DxilViewIdStateBuilder::CollectValuesContributingToOutputs(
unsigned id = (unsigned)-1;
int startRow = Semantic::kUndefinedRow, endRow = Semantic::kUndefinedRow;
unsigned col = (unsigned)-1;
bool IsForPatchConstantOrPrimitive = false;
if (DxilInst_StoreOutput SO = DxilInst_StoreOutput(CI)) {
pDxilSig = &m_pModule->GetOutputSignature();
pContributingValue = SO.get_value();
Expand All @@ -481,17 +486,23 @@ void DxilViewIdStateBuilder::CollectValuesContributingToOutputs(
GetUnsignedVal(SPO.get_outputSigId(), &id);
GetUnsignedVal(SPO.get_colIndex(), &col);
GetUnsignedVal(SPO.get_rowIndex(), (uint32_t *)&startRow);
IsForPatchConstantOrPrimitive = true;
} else if (DxilInst_StorePatchConstant SPC =
DxilInst_StorePatchConstant(CI)) {
pDxilSig = &m_pModule->GetPatchConstOrPrimSignature();
pContributingValue = SPC.get_value();
GetUnsignedVal(SPC.get_outputSigID(), &id);
GetUnsignedVal(SPC.get_row(), (uint32_t *)&startRow);
GetUnsignedVal(SPC.get_col(), &col);
IsForPatchConstantOrPrimitive = true;
} else {
IFT(DXC_E_GENERAL_INTERNAL_ERROR);
}

// Skip vertex outputs for MS when check primitive outputs.
damyanp marked this conversation as resolved.
Show resolved Hide resolved
if (IsForPatchConstantOrPrimitive != Entry.IsForPatchConstantOrPrimitive)
continue;

DxilSignatureElement &SigElem = pDxilSig->GetElement(id);
if (!SigElem.IsAllocated())
continue;
Expand Down
4 changes: 2 additions & 2 deletions tools/clang/test/DXC/dumpPSV_MS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
// CHECK-NEXT: Outputs affected by ViewID as a bitmask for stream 0:
// CHECK-NEXT: ViewID influencing Outputs[0] : 0 1 2 3 4 8 12 16
// CHECK-NEXT: PCOutputs affected by ViewID as a bitmask:
// CHECK-NEXT: ViewID influencing PCOutputs : None
// CHECK-NEXT: ViewID influencing PCOutputs : 3
// CHECK-NEXT: Outputs affected by inputs as a table of bitmasks for stream 0:
// CHECK-NEXT: Inputs contributing to computation of Outputs[0]: None

Expand Down Expand Up @@ -189,7 +189,7 @@ void main(
op.normal = mpl.normal;
op.malnor = gsMem[tig / 3 + 1];
op.alnorm = mpl.alnorm;
op.ormaln = mpl.ormaln;
op.ormaln = mpl.ormaln + vid;
damyanp marked this conversation as resolved.
Show resolved Hide resolved
op.layer[0] = mpl.layer[0];
op.layer[1] = mpl.layer[1];
op.layer[2] = mpl.layer[2];
Expand Down
Loading