Skip to content

Commit

Permalink
Update per comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
python3kgae committed Sep 4, 2024
1 parent 57ad149 commit 5f2d2bc
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions lib/HLSL/ComputeViewIdStateBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,11 @@ class DxilViewIdStateBuilder {
// Contributing instructions per output.
std::unordered_map<unsigned, InstructionSetType>
ContributingInstructions[kNumStreams];
bool IsForPatchConstantOrPrimitive;
EntryInfo(bool ForPC) : IsForPatchConstantOrPrimitive(ForPC) {}
void Clear();
};

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

// Information per function.
using FunctionReturnSet = std::unordered_set<llvm::ReturnInst *>;
Expand All @@ -143,7 +141,7 @@ class DxilViewIdStateBuilder {
llvm::CallGraphNode *pNode,
FunctionSetType &FuncSet);
void AnalyzeFunctions(EntryInfo &Entry);
void CollectValuesContributingToOutputs(EntryInfo &Entry);
void CollectValuesContributingToOutputs(EntryInfo &Entry, bool IsForPatchConstant);
void CollectValuesContributingToOutputRec(
EntryInfo &Entry, llvm::Value *pContributingValue,
InstructionSetType &ContributingInstructions);
Expand Down Expand Up @@ -209,10 +207,11 @@ void DxilViewIdStateBuilder::Compute() {
}

// 4. Collect sets of values contributing to outputs.
CollectValuesContributingToOutputs(m_Entry);
if (m_PCEntry.pEntryFunc) {
CollectValuesContributingToOutputs(m_PCEntry);
}
CollectValuesContributingToOutputs(m_Entry,
/*IsForPatchConstantOrPrimitive*/ false);
if (m_PCEntry.pEntryFunc)
CollectValuesContributingToOutputs(m_PCEntry,
/*IsForPatchConstantOrPrimitive*/ true);

// 5. Construct dependency sets.
for (unsigned StreamId = 0; StreamId < (pSM->IsGS() ? kNumStreams : 1u);
Expand Down Expand Up @@ -458,29 +457,34 @@ void DxilViewIdStateBuilder::AnalyzeFunctions(EntryInfo &Entry) {
}

void DxilViewIdStateBuilder::CollectValuesContributingToOutputs(
EntryInfo &Entry) {
EntryInfo &Entry, bool IsForPatchConstantOrPrimitive) {
for (auto *CI : Entry.Outputs) { // CI = call instruction
DxilSignature *pDxilSig = nullptr;
Value *pContributingValue = nullptr;
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)) {
if (IsForPatchConstantOrPrimitive)
continue;
pDxilSig = &m_pModule->GetOutputSignature();
pContributingValue = SO.get_value();
GetUnsignedVal(SO.get_outputSigId(), &id);
GetUnsignedVal(SO.get_colIndex(), &col);
GetUnsignedVal(SO.get_rowIndex(), (uint32_t *)&startRow);
} else if (DxilInst_StoreVertexOutput SVO =
DxilInst_StoreVertexOutput(CI)) {
if (IsForPatchConstantOrPrimitive)
continue;
pDxilSig = &m_pModule->GetOutputSignature();
pContributingValue = SVO.get_value();
GetUnsignedVal(SVO.get_outputSigId(), &id);
GetUnsignedVal(SVO.get_colIndex(), &col);
GetUnsignedVal(SVO.get_rowIndex(), (uint32_t *)&startRow);
} else if (DxilInst_StorePrimitiveOutput SPO =
DxilInst_StorePrimitiveOutput(CI)) {
if (!IsForPatchConstantOrPrimitive)
continue;
pDxilSig = &m_pModule->GetPatchConstOrPrimSignature();
pContributingValue = SPO.get_value();
GetUnsignedVal(SPO.get_outputSigId(), &id);
Expand All @@ -489,20 +493,17 @@ void DxilViewIdStateBuilder::CollectValuesContributingToOutputs(
IsForPatchConstantOrPrimitive = true;
} else if (DxilInst_StorePatchConstant SPC =
DxilInst_StorePatchConstant(CI)) {
if (!IsForPatchConstantOrPrimitive)
continue;
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.
if (IsForPatchConstantOrPrimitive != Entry.IsForPatchConstantOrPrimitive)
continue;

DxilSignatureElement &SigElem = pDxilSig->GetElement(id);
if (!SigElem.IsAllocated())
continue;
Expand Down

0 comments on commit 5f2d2bc

Please sign in to comment.