diff --git a/filament/src/fg/FrameGraph.cpp b/filament/src/fg/FrameGraph.cpp index 0bf10f75e0..afa2a37b06 100644 --- a/filament/src/fg/FrameGraph.cpp +++ b/filament/src/fg/FrameGraph.cpp @@ -43,13 +43,6 @@ #include -namespace utils{ -template<> -CString to_string(uint32_t value) noexcept { - return utils::CString(std::to_string(value).data()); -} -} // namespace utils - namespace filament { inline FrameGraph::Builder::Builder(FrameGraph& fg, PassNode* passNode) noexcept @@ -496,7 +489,7 @@ fgviewer::FrameGraphInfo FrameGraph::getFrameGraphInfo(const char *viewName) con const auto activePassNodesEnd = mActivePassNodesEnd; while (first != activePassNodesEnd) { PassNode *const pass = *first; - first++; + ++first; assert_invariant(!pass->isCulled()); std::vector reads; @@ -504,7 +497,12 @@ fgviewer::FrameGraphInfo FrameGraph::getFrameGraphInfo(const char *viewName) con for (auto const &edge: readEdges) { // all incoming edges should be valid by construction assert_invariant(mGraph.isEdgeValid(edge)); - reads.push_back(edge->from); + auto resourceNode = static_cast(mGraph.getNode(edge->from)); + assert_invariant(resourceNode); + if (resourceNode->getRefCount() == 0) + continue; + + reads.push_back(resourceNode->resourceHandle.index); } std::vector writes; @@ -515,7 +513,11 @@ fgviewer::FrameGraphInfo FrameGraph::getFrameGraphInfo(const char *viewName) con if (!mGraph.isEdgeValid(edge)) { continue; } - writes.push_back(edge->to); + auto resourceNode = static_cast(mGraph.getNode(edge->to)); + assert_invariant(resourceNode); + if (resourceNode->getRefCount() == 0) + continue; + writes.push_back(resourceNode->resourceHandle.index); } passes.emplace_back(utils::CString(pass->getName()), std::move(reads), std::move(writes)); @@ -523,20 +525,23 @@ fgviewer::FrameGraphInfo FrameGraph::getFrameGraphInfo(const char *viewName) con std::unordered_map resources; for (const auto &resourceNode: mResourceNodes) { + const FrameGraphHandle resourceHandle = resourceNode->resourceHandle; + if (resources.find(resourceHandle.index) != resources.end()) + continue; + std::vector resourceProps; - // TODO: Fill in resource properties - fgviewer::ResourceId id = resourceNode->getId(); - auto resource = getResource(resourceNode->resourceHandle); - if (resource->refcount == 0) + if (resourceNode->getRefCount() == 0) continue; if (resourceNode->getParentNode() != nullptr) { resourceProps.emplace_back(fgviewer::FrameGraphInfo::Resource::Property { .name = "is_subresource", - .value = utils::to_string(resourceNode->getParentNode()->getId()) + .value = utils::CString(std::to_string( + resourceNode->getParentHandle().index).data()) }); } - resources.emplace(id, fgviewer::FrameGraphInfo::Resource( - id, utils::CString(resourceNode->getName()), + resources.emplace(resourceHandle.index, fgviewer::FrameGraphInfo::Resource( + resourceHandle.index, + utils::CString(resourceNode->getName()), std::move(resourceProps)) ); } diff --git a/libs/fgviewer/web/app.js b/libs/fgviewer/web/app.js index 41458f918d..44eff1b108 100644 --- a/libs/fgviewer/web/app.js +++ b/libs/fgviewer/web/app.js @@ -356,14 +356,11 @@ class FrameGraphTable extends LitElement { } _getRowHtml(allPasses, resourceId, defaultColor) { - return allPasses.map((passName, index) => { - const passData = this.frameGraphData.passes.find(pass => pass.name === passName); + return allPasses.map((passData, index) => { const isRead = passData?.reads.includes(resourceId); const isWrite = passData?.writes.includes(resourceId); let type = null; - const getPassData = (name) => this.frameGraphData.passes.find(pass => pass.name === name); - const hasUsed = (name) => { - const passData = getPassData(name); + const hasUsed = (passData) => { return passData?.reads.includes(resourceId) || passData?.writes.includes(resourceId); }; const hasBeenUsedBefore = allPasses.slice(0, index).some(hasUsed); @@ -388,7 +385,7 @@ class FrameGraphTable extends LitElement { render() { if (!this.frameGraphData || !this.frameGraphData.passes || !this.frameGraphData.resources) return nothing; - const allPasses = this.frameGraphData.passes.map(pass => pass.name); + const allPasses = this.frameGraphData.passes; const resources = Object.values(this.frameGraphData.resources); return html`
@@ -397,7 +394,7 @@ class FrameGraphTable extends LitElement { Resources/Passes ${allPasses.map(pass => html` - ${pass}`)} + ${pass.name}`)}