MCPcopy Create free account
hub / github.com/NVIDIA-RTX/NVRHI / buildTopLevelAccelStruct

Method buildTopLevelAccelStruct

src/validation/validation-commandlist.cpp:1717–1807  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1715
1716
1717 void CommandListWrapper::buildTopLevelAccelStruct(rt::IAccelStruct* as, const rt::InstanceDesc* pInstances, size_t numInstances, rt::AccelStructBuildFlags buildFlags)
1718 {
1719 if (!requireOpenState())
1720 return;
1721
1722 if (!requireType(CommandQueue::Compute, "buildTopLevelAccelStruct"))
1723 return;
1724
1725 if (!as)
1726 {
1727 error("buildTopLevelAccelStruct: 'as' is NULL");
1728 return;
1729 }
1730
1731 std::vector<rt::InstanceDesc> patchedInstances;
1732 patchedInstances.assign(pInstances, pInstances + numInstances);
1733
1734 for (auto& instance : patchedInstances)
1735 {
1736 instance.bottomLevelAS = checked_cast<rt::IAccelStruct*>(unwrapResource(instance.bottomLevelAS));
1737 }
1738
1739 rt::IAccelStruct* underlyingAS = as;
1740
1741 AccelStructWrapper* wrapper = dynamic_cast<AccelStructWrapper*>(as);
1742 if (wrapper)
1743 {
1744 underlyingAS = wrapper->getUnderlyingObject();
1745
1746 if (!validateBuildTopLevelAccelStruct(wrapper, numInstances, buildFlags))
1747 return;
1748
1749 const bool allowEmptyInstances = (buildFlags & rt::AccelStructBuildFlags::AllowEmptyInstances) != 0;
1750
1751 for (size_t i = 0; i < numInstances; i++)
1752 {
1753 const auto& instance = pInstances[i];
1754
1755 if (instance.bottomLevelAS == nullptr)
1756 {
1757 if (allowEmptyInstances)
1758 {
1759 continue;
1760 }
1761 else
1762 {
1763 std::stringstream ss;
1764 ss << "TLAS " << utils::DebugNameToString(as->getDesc().debugName) << " build instance " << i
1765 << " has a NULL bottomLevelAS";
1766 error(ss.str());
1767 return;
1768 }
1769 }
1770
1771 AccelStructWrapper* blasWrapper = dynamic_cast<AccelStructWrapper*>(instance.bottomLevelAS);
1772 if (blasWrapper)
1773 {
1774 if (blasWrapper->isTopLevel)

Callers

nothing calls this directly

Calls 5

unwrapResourceFunction · 0.85
DebugNameToStringFunction · 0.85
getUnderlyingObjectMethod · 0.80
sizeMethod · 0.80
getDescMethod · 0.45

Tested by

no test coverage detected