Skip to content

Commit

Permalink
Call updateFrameGraph in appropriate locations
Browse files Browse the repository at this point in the history
  • Loading branch information
show50726 committed Feb 3, 2025
1 parent 57502a4 commit 0e4cfc2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion libs/fgviewer/src/ApiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ bool ApiHandler::handleGet(CivetServer* server, struct mg_connection* conn) {
return error(__LINE__, uri);
}

void ApiHandler::addFrameGraph(ViewHandle view_handle) {
void ApiHandler::updateFrameGraph(ViewHandle view_handle) {
std::unique_lock const lock(mStatusMutex);
snprintf(statusFrameGraphId, sizeof(statusFrameGraphId), "%8.8x", view_handle);
mCurrentStatus++;
mStatusCondition.notify_all();
}

Expand Down
4 changes: 2 additions & 2 deletions libs/fgviewer/src/ApiHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ApiHandler : public CivetHandler {

bool handleGet(CivetServer* server, struct mg_connection* conn);

void addFrameGraph(ViewHandle view_handle);
void updateFrameGraph(ViewHandle view_handle);

private:
const FrameGraphInfo* getFrameGraphInfo(struct mg_connection* conn,
Expand All @@ -58,7 +58,7 @@ class ApiHandler : public CivetHandler {
// This variable is to implement a *hanging* effect for /api/status. The call to /api/status
// will always block until statusMaterialId is updated again. The client is expected to keep
// calling /api/status (a constant "pull" to simulate a push).
std::atomic<uint64_t> mCurrentStatus = 0;
uint64_t mCurrentStatus = 0;
};

} // filament::fgviewer
Expand Down
12 changes: 12 additions & 0 deletions libs/fgviewer/src/DebugServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ViewHandle DebugServer::createView(utils::CString name) {
std::unique_lock<utils::Mutex> lock(mViewsMutex);
ViewHandle handle = mViewCounter++;
mViews.emplace(handle, FrameGraphInfo(std::move(name)));
mApiHandler->updateFrameGraph(handle);

return handle;
}
Expand All @@ -121,8 +122,19 @@ void DebugServer::destroyView(ViewHandle h) {

void DebugServer::update(ViewHandle h, FrameGraphInfo info) {
std::unique_lock<utils::Mutex> lock(mViewsMutex);
const auto it = mViews.find(h);
if (it == mViews.end()) {
slog.w << "[fgviewer] Received update for unknown handle " << h;
return;
}

bool has_changed = !(it->second == info);
if (!has_changed)
return;

mViews.erase(h);
mViews.emplace(h, std::move(info));
mApiHandler->updateFrameGraph(h);
}

} // namespace filament::fgviewer

0 comments on commit 0e4cfc2

Please sign in to comment.