Skip to content

Commit

Permalink
Improve AccelStruct building matching
Browse files Browse the repository at this point in the history
  • Loading branch information
nyorain committed Aug 27, 2023
1 parent 9dea742 commit f7ca613
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/command/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,43 @@ MatchVal match(MatchType mt, const BeginRenderingCmd& a, const BeginRenderingCmd
return m;
}

MatchVal matchAccelStructBuild(
MatchType mt,
// a
const VkAccelerationStructureBuildGeometryInfoKHR& geomsA,
span<const VkAccelerationStructureBuildRangeInfoKHR> rangesA,
const AccelStruct* srcA,
const AccelStruct* dstA,
// b
const VkAccelerationStructureBuildGeometryInfoKHR& geomsB,
span<const VkAccelerationStructureBuildRangeInfoKHR> rangesB,
const AccelStruct* srcB,
const AccelStruct* dstB) {
if(geomsA.type != geomsB.type || geomsA.mode != geomsB.mode) {
return MatchVal::noMatch();
}

// TODO: consider other parameters
(void) rangesA;
(void) srcA;
(void) rangesB;
(void) srcB;

return match(mt, dstA, dstB);
}

MatchVal match(MatchType mt, const BuildAccelStructsCmd& a, const BuildAccelStructsCmd& b) {
auto cbBuild = [&](auto ia, auto ib) {
return matchAccelStructBuild(mt,
a.buildInfos[ia], a.buildRangeInfos[ia], a.srcs[ia], a.dsts[ia],
b.buildInfos[ib], b.buildRangeInfos[ib], b.srcs[ib], b.dsts[ib]);
};

MatchVal ret;
addSpanOrderedStrict(ret, a.buildInfos.size(), b.buildInfos.size(), cbBuild);
return ret;
}

// dummy for validExpression below
template<typename Cmd> using HasStaticType = decltype(Cmd::staticType());
template<typename Cmd> using HasMatch = decltype(match(MatchType::deep,
Expand Down

0 comments on commit f7ca613

Please sign in to comment.