From 5ec4de64c8859e5aacd1ddbb8d9e5da91d0be98e Mon Sep 17 00:00:00 2001 From: Doris Wu Date: Mon, 23 Dec 2024 19:22:28 +0800 Subject: [PATCH 1/9] Introduce FrameGraphInfo class --- libs/fgviewer/CMakeLists.txt | 2 + libs/fgviewer/include/fgviewer/DebugServer.h | 21 +++--- .../include/fgviewer/FrameGraphInfo.h | 66 +++++++++++++++++++ libs/fgviewer/src/DebugServer.cpp | 27 ++++---- libs/fgviewer/src/FrameGraphInfo.cpp | 48 ++++++++++++++ 5 files changed, 136 insertions(+), 28 deletions(-) create mode 100644 libs/fgviewer/include/fgviewer/FrameGraphInfo.h create mode 100644 libs/fgviewer/src/FrameGraphInfo.cpp diff --git a/libs/fgviewer/CMakeLists.txt b/libs/fgviewer/CMakeLists.txt index cf6bdb526df..892232f433a 100644 --- a/libs/fgviewer/CMakeLists.txt +++ b/libs/fgviewer/CMakeLists.txt @@ -15,12 +15,14 @@ endif() set(PUBLIC_HDRS include/fgviewer/DebugServer.h include/fgviewer/JsonWriter.h + include/fgviewer/FrameGraphInfo.h ) set(SRCS src/ApiHandler.cpp src/ApiHandler.h src/DebugServer.cpp + src/FrameGraphInfo.cpp ) # ================================================================================================== diff --git a/libs/fgviewer/include/fgviewer/DebugServer.h b/libs/fgviewer/include/fgviewer/DebugServer.h index ef054483334..887dcccbd30 100644 --- a/libs/fgviewer/include/fgviewer/DebugServer.h +++ b/libs/fgviewer/include/fgviewer/DebugServer.h @@ -17,6 +17,8 @@ #ifndef FGVIEWER_DEBUGSERVER_H #define FGVIEWER_DEBUGSERVER_H +#include + #include #include @@ -27,17 +29,9 @@ class CivetServer; namespace filament::fgviewer { -using FrameGraphInfoKey = uint32_t; +using ViewHandle = uint32_t; -struct FrameGraphPassInfo { - utils::CString pass_name; - // TODO: Add struct detail properties -}; -struct FrameGraphInfo { - utils::CString view_name; - std::vector passes; -}; /** * Server-side frame graph debugger. @@ -56,24 +50,25 @@ class DebugServer { /** * Notifies the debugger that a new view has been added. */ - void addView(const utils::CString& name, FrameGraphInfo info); + ViewHandle createView(utils::CString name); /** * Notifies the debugger that the given view has been deleted. */ - void removeView(const utils::CString& name); + void destroyView(ViewHandle h); /** * Updates the information for a given view. */ - void updateView(const utils::CString& name, FrameGraphInfo info); + void update(ViewHandle h, FrameGraphInfo info); bool isReady() const { return mServer; } private: CivetServer* mServer; - std::unordered_map mViews; + std::unordered_map mViews; + uint32_t viewCounter = 0; mutable utils::Mutex mViewsMutex; class FileRequestHandler* mFileHandler = nullptr; diff --git a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h new file mode 100644 index 00000000000..c99f43feac4 --- /dev/null +++ b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h @@ -0,0 +1,66 @@ +/* +* Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FGVIEWER_FRAMEGRAPHINFO_H +#define FGVIEWER_FRAMEGRAPHINFO_H + +#include + +#include +#include +#include +#include + +namespace filament::fgviewer { + +class FrameGraphInfo { +public: + using ResourceId = uint32_t; + + explicit FrameGraphInfo(utils::CString viewName); + ~FrameGraphInfo(); + FrameGraphInfo(FrameGraphInfo&& rhs); + FrameGraphInfo(FrameGraphInfo const&) = delete; + + struct Pass { + utils::CString name; + std::vector reads; + std::vector writes; + }; + + struct Resource { + ResourceId id; + utils::CString name; + // We use a vector of string pair here to store the resource properties, so different kinds of resources could choose different types of properties to send + // ex. + // Texture2D --> { {"name","XXX"}, {"sizeX", "1024"}, {"sizeY", "768"} } + // Buffer1D --> { {"name", "XXX"}, {"size", "512"} } + std::vector> resourceProperties; + }; + + // Resources and passes will be stored inside the impl class. + void setResources(std::unordered_map resources); + // The incoming passes should be sorted by the execution order. + void setPasses(std::vector passes); + +private: + class FrameGraphInfoImpl; + std::unique_ptr pImpl; +}; + +} // namespace filament::fgviewer + +#endif //FGVIEWER_FRAMEGRAPHINFO_H diff --git a/libs/fgviewer/src/DebugServer.cpp b/libs/fgviewer/src/DebugServer.cpp index ce1ccaa36b2..8d3ffb0edb9 100644 --- a/libs/fgviewer/src/DebugServer.cpp +++ b/libs/fgviewer/src/DebugServer.cpp @@ -15,6 +15,7 @@ */ #include +#include #include "ApiHandler.h" @@ -31,12 +32,6 @@ namespace filament::fgviewer { namespace { std::string const BASE_URL = "libs/fgviewer/web"; - -FrameGraphInfoKey getKeybyString(const utils::CString &input, - uint32_t seed) { - return utils::hash::murmurSlow(reinterpret_cast( - input.c_str()), input.size(), 0); -} } // anonymous using namespace utils; @@ -49,6 +44,7 @@ std::string_view const DebugServer::kErrorHeader = "HTTP/1.1 404 Not Found\r\nContent-Type: %s\r\n" "Connection: close\r\n\r\n"; + class FileRequestHandler : public CivetHandler { public: FileRequestHandler(DebugServer* server) : mServer(server) {} @@ -110,22 +106,23 @@ DebugServer::~DebugServer() { delete mServer; } -void DebugServer::addView(const utils::CString &name, FrameGraphInfo info) { +ViewHandle DebugServer::createView(utils::CString name) { std::unique_lock lock(mViewsMutex); - const FrameGraphInfoKey key = getKeybyString(name, 0); - mViews.insert({key, info}); + ViewHandle handle = viewCounter++; + mViews.emplace(handle, FrameGraphInfo(std::move(name))); + + return handle; } -void DebugServer::removeView(const utils::CString& name) { +void DebugServer::destroyView(ViewHandle h) { std::unique_lock lock(mViewsMutex); - const FrameGraphInfoKey key = getKeybyString(name, 0); - mViews.erase(key); + mViews.erase(h); } -void DebugServer::updateView(const utils::CString& name, FrameGraphInfo info) { +void DebugServer::update(ViewHandle h, FrameGraphInfo info) { std::unique_lock lock(mViewsMutex); - const FrameGraphInfoKey key = getKeybyString(name, 0); - mViews[key] = info; + mViews.erase(h); + mViews.emplace(h, std::move(info)); } } // namespace filament::fgviewer diff --git a/libs/fgviewer/src/FrameGraphInfo.cpp b/libs/fgviewer/src/FrameGraphInfo.cpp new file mode 100644 index 00000000000..9d39ad83a46 --- /dev/null +++ b/libs/fgviewer/src/FrameGraphInfo.cpp @@ -0,0 +1,48 @@ +/* +* Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +namespace filament::fgviewer { + +class FrameGraphInfo::FrameGraphInfoImpl { +public: + utils::CString viewName; + // The order of the passes in the vector indicates the execution + // order of the passes. + std::vector passes; + std::unordered_map resources; +}; + + +FrameGraphInfo::FrameGraphInfo(utils::CString viewName) + : pImpl(std::make_unique()) { + pImpl->viewName = std::move(viewName); +} + +FrameGraphInfo::~FrameGraphInfo() = default; + +FrameGraphInfo::FrameGraphInfo(FrameGraphInfo&& rhs) = default; + +void FrameGraphInfo::setResources( + std::unordered_map resources) { + pImpl->resources = std::move(resources); +} + +void FrameGraphInfo::setPasses(std::vector passes) { + pImpl->passes = std::move(passes); +} +} // namespace filament::fgviewer From 6eb7196ae6a3490bb2e966eba0cabe6e1e1d2966 Mon Sep 17 00:00:00 2001 From: Doris Wu Date: Mon, 23 Dec 2024 19:46:09 +0800 Subject: [PATCH 2/9] Move the assignment into pimpl --- .../include/fgviewer/FrameGraphInfo.h | 2 +- libs/fgviewer/src/FrameGraphInfo.cpp | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h index c99f43feac4..0127fb5e250 100644 --- a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h +++ b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h @@ -54,7 +54,7 @@ class FrameGraphInfo { // Resources and passes will be stored inside the impl class. void setResources(std::unordered_map resources); // The incoming passes should be sorted by the execution order. - void setPasses(std::vector passes); + void setPasses(std::vector sortedPasses); private: class FrameGraphInfoImpl; diff --git a/libs/fgviewer/src/FrameGraphInfo.cpp b/libs/fgviewer/src/FrameGraphInfo.cpp index 9d39ad83a46..ad5094d5db4 100644 --- a/libs/fgviewer/src/FrameGraphInfo.cpp +++ b/libs/fgviewer/src/FrameGraphInfo.cpp @@ -20,6 +20,19 @@ namespace filament::fgviewer { class FrameGraphInfo::FrameGraphInfoImpl { public: + void setViewName(utils::CString name) { + viewName = std::move(name); + } + + void setPasses(std::vector sortedPasses) { + passes = std::move(sortedPasses); + } + + void setResources(std::unordered_map resourceMap) { + resources = std::move(resourceMap); + } + +private: utils::CString viewName; // The order of the passes in the vector indicates the execution // order of the passes. @@ -30,7 +43,7 @@ class FrameGraphInfo::FrameGraphInfoImpl { FrameGraphInfo::FrameGraphInfo(utils::CString viewName) : pImpl(std::make_unique()) { - pImpl->viewName = std::move(viewName); + pImpl->setViewName(std::move(viewName)); } FrameGraphInfo::~FrameGraphInfo() = default; @@ -39,10 +52,10 @@ FrameGraphInfo::FrameGraphInfo(FrameGraphInfo&& rhs) = default; void FrameGraphInfo::setResources( std::unordered_map resources) { - pImpl->resources = std::move(resources); + pImpl->setResources(std::move(resources)); } -void FrameGraphInfo::setPasses(std::vector passes) { - pImpl->passes = std::move(passes); +void FrameGraphInfo::setPasses(std::vector sortedPasses) { + pImpl->setPasses(std::move(sortedPasses)); } } // namespace filament::fgviewer From 04afaa9b56309a95786f5b14836ea4ff2e94e1ea Mon Sep 17 00:00:00 2001 From: Doris Wu Date: Wed, 1 Jan 2025 15:04:33 +0800 Subject: [PATCH 3/9] Make ctors explicit --- libs/fgviewer/include/fgviewer/DebugServer.h | 2 +- libs/fgviewer/include/fgviewer/FrameGraphInfo.h | 6 ++++-- libs/fgviewer/src/FrameGraphInfo.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/fgviewer/include/fgviewer/DebugServer.h b/libs/fgviewer/include/fgviewer/DebugServer.h index 887dcccbd30..1a01a880f97 100644 --- a/libs/fgviewer/include/fgviewer/DebugServer.h +++ b/libs/fgviewer/include/fgviewer/DebugServer.h @@ -44,7 +44,7 @@ class DebugServer { static std::string_view const kSuccessHeader; static std::string_view const kErrorHeader; - DebugServer(int port); + explicit DebugServer(int port); ~DebugServer(); /** diff --git a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h index 0127fb5e250..2d5ea0702ef 100644 --- a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h +++ b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h @@ -32,7 +32,7 @@ class FrameGraphInfo { explicit FrameGraphInfo(utils::CString viewName); ~FrameGraphInfo(); - FrameGraphInfo(FrameGraphInfo&& rhs); + FrameGraphInfo(FrameGraphInfo&& rhs) noexcept; FrameGraphInfo(FrameGraphInfo const&) = delete; struct Pass { @@ -44,7 +44,9 @@ class FrameGraphInfo { struct Resource { ResourceId id; utils::CString name; - // We use a vector of string pair here to store the resource properties, so different kinds of resources could choose different types of properties to send + // We use a vector of string pair here to store the resource properties, + // so different kinds of resources could choose different types of + // properties to record. // ex. // Texture2D --> { {"name","XXX"}, {"sizeX", "1024"}, {"sizeY", "768"} } // Buffer1D --> { {"name", "XXX"}, {"size", "512"} } diff --git a/libs/fgviewer/src/FrameGraphInfo.cpp b/libs/fgviewer/src/FrameGraphInfo.cpp index ad5094d5db4..aa06cb9c3e4 100644 --- a/libs/fgviewer/src/FrameGraphInfo.cpp +++ b/libs/fgviewer/src/FrameGraphInfo.cpp @@ -48,7 +48,7 @@ FrameGraphInfo::FrameGraphInfo(utils::CString viewName) FrameGraphInfo::~FrameGraphInfo() = default; -FrameGraphInfo::FrameGraphInfo(FrameGraphInfo&& rhs) = default; +FrameGraphInfo::FrameGraphInfo(FrameGraphInfo&& rhs) noexcept = default; void FrameGraphInfo::setResources( std::unordered_map resources) { From 1cd1d70aba28014bccf315f42a5a78a44677797b Mon Sep 17 00:00:00 2001 From: Doris Wu Date: Wed, 1 Jan 2025 17:06:32 +0800 Subject: [PATCH 4/9] Add ctors to fg info structs --- .../include/fgviewer/FrameGraphInfo.h | 81 +++++++++++-------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h index 2d5ea0702ef..57d46af3d75 100644 --- a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h +++ b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef FGVIEWER_FRAMEGRAPHINFO_H -#define FGVIEWER_FRAMEGRAPHINFO_H +#ifndef FGVIEWER_FRAME_GRAPH_INFO_H +#define FGVIEWER_FRAME_GRAPH_INFO_H #include @@ -25,44 +25,57 @@ #include namespace filament::fgviewer { - -class FrameGraphInfo { -public: using ResourceId = uint32_t; - explicit FrameGraphInfo(utils::CString viewName); - ~FrameGraphInfo(); - FrameGraphInfo(FrameGraphInfo&& rhs) noexcept; - FrameGraphInfo(FrameGraphInfo const&) = delete; + class FrameGraphInfo { + public: + explicit FrameGraphInfo(utils::CString viewName); - struct Pass { - utils::CString name; - std::vector reads; - std::vector writes; - }; + ~FrameGraphInfo(); - struct Resource { - ResourceId id; - utils::CString name; - // We use a vector of string pair here to store the resource properties, - // so different kinds of resources could choose different types of - // properties to record. - // ex. - // Texture2D --> { {"name","XXX"}, {"sizeX", "1024"}, {"sizeY", "768"} } - // Buffer1D --> { {"name", "XXX"}, {"size", "512"} } - std::vector> resourceProperties; - }; + FrameGraphInfo(FrameGraphInfo &&rhs) noexcept; + + FrameGraphInfo(FrameGraphInfo const &) = delete; + + struct Pass { + Pass(utils::CString name, std::vector reads, + std::vector writes): name(std::move(name)), reads(std::move(reads)), + writes(std::move(writes)) { + } - // Resources and passes will be stored inside the impl class. - void setResources(std::unordered_map resources); - // The incoming passes should be sorted by the execution order. - void setPasses(std::vector sortedPasses); + utils::CString name; + std::vector reads; + std::vector writes; + }; -private: - class FrameGraphInfoImpl; - std::unique_ptr pImpl; -}; + struct Resource { + Resource(ResourceId id, utils::CString name, + std::vector > properties): id(id), + name(std::move(name)), + resourceProperties(std::move(properties)) { + } + ResourceId id; + utils::CString name; + // We use a vector of string pair here to store the resource properties, + // so different kinds of resources could choose different types of + // properties to record. + // ex. + // Texture2D --> { {"name","XXX"}, {"sizeX", "1024"}, {"sizeY", "768"} } + // Buffer1D --> { {"name", "XXX"}, {"size", "512"} } + std::vector > resourceProperties; + }; + + // Resources and passes will be stored inside the impl class. + void setResources(std::unordered_map resources); + + // The incoming passes should be sorted by the execution order. + void setPasses(std::vector sortedPasses); + + private: + class FrameGraphInfoImpl; + std::unique_ptr pImpl; + }; } // namespace filament::fgviewer -#endif //FGVIEWER_FRAMEGRAPHINFO_H +#endif //FGVIEWER_FRAME_GRAPH_INFO_H From e59b1118c52b65cdb5286c21a36694c069dc03f2 Mon Sep 17 00:00:00 2001 From: Doris Wu Date: Wed, 1 Jan 2025 17:09:47 +0800 Subject: [PATCH 5/9] Revert the macro change to align with existing --- libs/fgviewer/include/fgviewer/FrameGraphInfo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h index 57d46af3d75..8e28ccc9e7e 100644 --- a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h +++ b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef FGVIEWER_FRAME_GRAPH_INFO_H -#define FGVIEWER_FRAME_GRAPH_INFO_H +#ifndef FGVIEWER_FRAMEGRAPHINFO_H +#define FGVIEWER_FRAMEGRAPHINFO_H #include @@ -78,4 +78,4 @@ namespace filament::fgviewer { }; } // namespace filament::fgviewer -#endif //FGVIEWER_FRAME_GRAPH_INFO_H +#endif //FGVIEWER_FRAMEGRAPHINFO_H From c02d23143a3da790375cdc77cbe27a573418505e Mon Sep 17 00:00:00 2001 From: Doris Wu Date: Wed, 8 Jan 2025 10:50:39 +0800 Subject: [PATCH 6/9] Address the comments --- libs/fgviewer/include/fgviewer/DebugServer.h | 2 +- .../include/fgviewer/FrameGraphInfo.h | 100 +++++++++--------- libs/fgviewer/src/DebugServer.cpp | 2 +- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/libs/fgviewer/include/fgviewer/DebugServer.h b/libs/fgviewer/include/fgviewer/DebugServer.h index 1a01a880f97..d56addf9097 100644 --- a/libs/fgviewer/include/fgviewer/DebugServer.h +++ b/libs/fgviewer/include/fgviewer/DebugServer.h @@ -68,7 +68,7 @@ class DebugServer { CivetServer* mServer; std::unordered_map mViews; - uint32_t viewCounter = 0; + uint32_t mViewCounter = 0; mutable utils::Mutex mViewsMutex; class FileRequestHandler* mFileHandler = nullptr; diff --git a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h index 8e28ccc9e7e..9b5df97eff3 100644 --- a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h +++ b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h @@ -25,57 +25,57 @@ #include namespace filament::fgviewer { - using ResourceId = uint32_t; - - class FrameGraphInfo { - public: - explicit FrameGraphInfo(utils::CString viewName); - - ~FrameGraphInfo(); - - FrameGraphInfo(FrameGraphInfo &&rhs) noexcept; - - FrameGraphInfo(FrameGraphInfo const &) = delete; - - struct Pass { - Pass(utils::CString name, std::vector reads, - std::vector writes): name(std::move(name)), reads(std::move(reads)), - writes(std::move(writes)) { - } - - utils::CString name; - std::vector reads; - std::vector writes; - }; - - struct Resource { - Resource(ResourceId id, utils::CString name, - std::vector > properties): id(id), - name(std::move(name)), - resourceProperties(std::move(properties)) { - } - - ResourceId id; - utils::CString name; - // We use a vector of string pair here to store the resource properties, - // so different kinds of resources could choose different types of - // properties to record. - // ex. - // Texture2D --> { {"name","XXX"}, {"sizeX", "1024"}, {"sizeY", "768"} } - // Buffer1D --> { {"name", "XXX"}, {"size", "512"} } - std::vector > resourceProperties; - }; - - // Resources and passes will be stored inside the impl class. - void setResources(std::unordered_map resources); - - // The incoming passes should be sorted by the execution order. - void setPasses(std::vector sortedPasses); - - private: - class FrameGraphInfoImpl; - std::unique_ptr pImpl; +using ResourceId = uint32_t; + +class FrameGraphInfo { +public: + explicit FrameGraphInfo(utils::CString viewName); + + ~FrameGraphInfo(); + + FrameGraphInfo(FrameGraphInfo &&rhs) noexcept; + + FrameGraphInfo(FrameGraphInfo const &) = delete; + + struct Pass { + Pass(utils::CString name, std::vector reads, + std::vector writes): name(std::move(name)), reads(std::move(reads)), + writes(std::move(writes)) { + } + + utils::CString name; + std::vector reads; + std::vector writes; }; + + struct Resource { + Resource(ResourceId id, utils::CString name, + std::vector > properties): id(id), + name(std::move(name)), + properties(std::move(properties)) { + } + + ResourceId id; + utils::CString name; + // We use a vector of string pair here to store the resource properties, + // so different kinds of resources could choose different types of + // properties to record. + // ex. + // Texture2D --> { {"name","XXX"}, {"sizeX", "1024"}, {"sizeY", "768"} } + // Buffer1D --> { {"name", "XXX"}, {"size", "512"} } + std::vector > properties; + }; + + // Resources and passes will be stored inside the impl class. + void setResources(std::unordered_map resources); + + // The incoming passes should be sorted by the execution order. + void setPasses(std::vector sortedPasses); + +private: + class FrameGraphInfoImpl; + std::unique_ptr pImpl; +}; } // namespace filament::fgviewer #endif //FGVIEWER_FRAMEGRAPHINFO_H diff --git a/libs/fgviewer/src/DebugServer.cpp b/libs/fgviewer/src/DebugServer.cpp index 8d3ffb0edb9..70d2af08947 100644 --- a/libs/fgviewer/src/DebugServer.cpp +++ b/libs/fgviewer/src/DebugServer.cpp @@ -108,7 +108,7 @@ DebugServer::~DebugServer() { ViewHandle DebugServer::createView(utils::CString name) { std::unique_lock lock(mViewsMutex); - ViewHandle handle = viewCounter++; + ViewHandle handle = mViewCounter++; mViews.emplace(handle, FrameGraphInfo(std::move(name))); return handle; From e6a3af6b60f7cf7c5307530b99f04e72eb26962a Mon Sep 17 00:00:00 2001 From: Doris Wu Date: Sat, 18 Jan 2025 00:08:53 +0800 Subject: [PATCH 7/9] Remove pimpl and move func def to .cc --- .../include/fgviewer/FrameGraphInfo.h | 18 +++----- libs/fgviewer/src/FrameGraphInfo.cpp | 43 ++++++------------- 2 files changed, 21 insertions(+), 40 deletions(-) diff --git a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h index 9b5df97eff3..07832147d0e 100644 --- a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h +++ b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -39,9 +38,7 @@ class FrameGraphInfo { struct Pass { Pass(utils::CString name, std::vector reads, - std::vector writes): name(std::move(name)), reads(std::move(reads)), - writes(std::move(writes)) { - } + std::vector writes); utils::CString name; std::vector reads; @@ -50,10 +47,7 @@ class FrameGraphInfo { struct Resource { Resource(ResourceId id, utils::CString name, - std::vector > properties): id(id), - name(std::move(name)), - properties(std::move(properties)) { - } + std::vector > properties); ResourceId id; utils::CString name; @@ -66,15 +60,17 @@ class FrameGraphInfo { std::vector > properties; }; - // Resources and passes will be stored inside the impl class. void setResources(std::unordered_map resources); // The incoming passes should be sorted by the execution order. void setPasses(std::vector sortedPasses); private: - class FrameGraphInfoImpl; - std::unique_ptr pImpl; + utils::CString viewName; + // The order of the passes in the vector indicates the execution + // order of the passes. + std::vector passes; + std::unordered_map resources; }; } // namespace filament::fgviewer diff --git a/libs/fgviewer/src/FrameGraphInfo.cpp b/libs/fgviewer/src/FrameGraphInfo.cpp index aa06cb9c3e4..87b8bc64fbd 100644 --- a/libs/fgviewer/src/FrameGraphInfo.cpp +++ b/libs/fgviewer/src/FrameGraphInfo.cpp @@ -18,44 +18,29 @@ namespace filament::fgviewer { -class FrameGraphInfo::FrameGraphInfoImpl { -public: - void setViewName(utils::CString name) { - viewName = std::move(name); - } - - void setPasses(std::vector sortedPasses) { - passes = std::move(sortedPasses); - } - - void setResources(std::unordered_map resourceMap) { - resources = std::move(resourceMap); - } - -private: - utils::CString viewName; - // The order of the passes in the vector indicates the execution - // order of the passes. - std::vector passes; - std::unordered_map resources; -}; - - -FrameGraphInfo::FrameGraphInfo(utils::CString viewName) - : pImpl(std::make_unique()) { - pImpl->setViewName(std::move(viewName)); -} +FrameGraphInfo::FrameGraphInfo(utils::CString viewName): + viewName(std::move(viewName)), passes({}), resources({}) {} FrameGraphInfo::~FrameGraphInfo() = default; FrameGraphInfo::FrameGraphInfo(FrameGraphInfo&& rhs) noexcept = default; +FrameGraphInfo::Pass::Pass(utils::CString name, std::vector reads, + std::vector writes): name(std::move(name)), + reads(std::move(reads)), + writes(std::move(writes)) {} + +FrameGraphInfo::Resource::Resource(ResourceId id, utils::CString name, + std::vector > properties): id(id), + name(std::move(name)), properties(std::move(properties)) {} + void FrameGraphInfo::setResources( std::unordered_map resources) { - pImpl->setResources(std::move(resources)); + resources = std::move(resources); } void FrameGraphInfo::setPasses(std::vector sortedPasses) { - pImpl->setPasses(std::move(sortedPasses)); + passes = std::move(sortedPasses); } + } // namespace filament::fgviewer From a7f8176dcf1f9b16aa1574c8d3491dd656da0c8d Mon Sep 17 00:00:00 2001 From: Doris Wu Date: Sat, 18 Jan 2025 00:37:45 +0800 Subject: [PATCH 8/9] Fix --- libs/fgviewer/src/FrameGraphInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/fgviewer/src/FrameGraphInfo.cpp b/libs/fgviewer/src/FrameGraphInfo.cpp index 87b8bc64fbd..963aa843051 100644 --- a/libs/fgviewer/src/FrameGraphInfo.cpp +++ b/libs/fgviewer/src/FrameGraphInfo.cpp @@ -36,7 +36,7 @@ FrameGraphInfo::Resource::Resource(ResourceId id, utils::CString name, void FrameGraphInfo::setResources( std::unordered_map resources) { - resources = std::move(resources); + this->resources = std::move(resources); } void FrameGraphInfo::setPasses(std::vector sortedPasses) { From 63cd78f9c544c15f02751ccee8f6ab7b9a2e67c6 Mon Sep 17 00:00:00 2001 From: Doris Wu Date: Sat, 18 Jan 2025 10:10:26 +0800 Subject: [PATCH 9/9] Address the comment --- libs/fgviewer/include/fgviewer/FrameGraphInfo.h | 11 ++++++++--- libs/fgviewer/src/FrameGraphInfo.cpp | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h index 07832147d0e..7de8dd02def 100644 --- a/libs/fgviewer/include/fgviewer/FrameGraphInfo.h +++ b/libs/fgviewer/include/fgviewer/FrameGraphInfo.h @@ -46,18 +46,23 @@ class FrameGraphInfo { }; struct Resource { + struct Property { + utils::CString name; + utils::CString value; + }; + Resource(ResourceId id, utils::CString name, - std::vector > properties); + std::vector properties); ResourceId id; utils::CString name; - // We use a vector of string pair here to store the resource properties, + // We use a vector of Property here to store the resource properties, // so different kinds of resources could choose different types of // properties to record. // ex. // Texture2D --> { {"name","XXX"}, {"sizeX", "1024"}, {"sizeY", "768"} } // Buffer1D --> { {"name", "XXX"}, {"size", "512"} } - std::vector > properties; + std::vector properties; }; void setResources(std::unordered_map resources); diff --git a/libs/fgviewer/src/FrameGraphInfo.cpp b/libs/fgviewer/src/FrameGraphInfo.cpp index 963aa843051..59fcaea489b 100644 --- a/libs/fgviewer/src/FrameGraphInfo.cpp +++ b/libs/fgviewer/src/FrameGraphInfo.cpp @@ -31,7 +31,7 @@ FrameGraphInfo::Pass::Pass(utils::CString name, std::vector reads, writes(std::move(writes)) {} FrameGraphInfo::Resource::Resource(ResourceId id, utils::CString name, - std::vector > properties): id(id), + std::vector properties): id(id), name(std::move(name)), properties(std::move(properties)) {} void FrameGraphInfo::setResources(