Skip to content

Commit

Permalink
Address the comments
Browse files Browse the repository at this point in the history
Address the comments
  • Loading branch information
show50726 committed Dec 12, 2024
1 parent 4312c88 commit 8e58dff
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 31 deletions.
35 changes: 33 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ function print_help {
echo " This is sometimes needed instead of -c (which still misses some clean steps)."
echo " -d"
echo " Enable matdbg."
echo " -t"
echo " Enable fgviewer."
echo " -f"
echo " Always invoke CMake before incremental builds."
echo " -g"
Expand Down Expand Up @@ -125,6 +127,27 @@ function print_matdbg_help {
echo ""
}

function print_fgviewer_help {
echo "fgviewer is enabled in the build, but some extra steps are needed."
echo ""
echo "FOR DESKTOP BUILDS:"
echo ""
echo "Please set the port environment variable before launching. e.g., on macOS do:"
echo " export FILAMENT_FGVIEWER_PORT=8085"
echo ""
echo "FOR ANDROID BUILDS:"
echo ""
echo "1) For Android Studio builds, make sure to set:"
echo " -Pcom.google.android.filament.fgviewer"
echo " option in Preferences > Build > Compiler > Command line options."
echo ""
echo "2) The port number is hardcoded to 8085 so you will need to do:"
echo " adb forward tcp:8085 tcp:8085"
echo ""
echo "3) Be sure to enable INTERNET permission in your app's manifest file."
echo ""
}

# Unless explicitly specified, NDK version will be selected as highest available version within same major release chain
FILAMENT_NDK_VERSION=${FILAMENT_NDK_VERSION:-$(cat `dirname $0`/build/android/ndk.version | cut -f 1 -d ".")}

Expand Down Expand Up @@ -824,11 +847,15 @@ while getopts ":hacCfgijmp:q:uvslwedk:bx:S:X:" opt; do
;;
d)
PRINT_MATDBG_HELP=true
# TODO: Uncomment below when fgviewer is ready
# FGVIEWER_OPTION="-DFILAMENT_ENABLE_FGVIEWER=ON"
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=ON, -DFILAMENT_BUILD_FILAMAT=ON"
MATDBG_GRADLE_OPTION="-Pcom.google.android.filament.matdbg"
;;
t)
# TODO: Uncomment below when fgviewer is ready
# PRINT_FGVIEWER_HELP=true
# FGVIEWER_OPTION="-DFILAMENT_ENABLE_FGVIEWER=ON"
#FGVIEWER_GRADLE_OPTION="-Pcom.google.android.filament.fgviewer"
;;
f)
ISSUE_CMAKE_ALWAYS=true
;;
Expand Down Expand Up @@ -1033,3 +1060,7 @@ fi
if [[ "${PRINT_MATDBG_HELP}" == "true" ]]; then
print_matdbg_help
fi

if [[ "${PRINT_FGVIEWER_HELP}" == "true" ]]; then
print_fgviewer_help
fi
10 changes: 4 additions & 6 deletions libs/fgviewer/include/fgviewer/DebugServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
#ifndef FGVIEWER_DEBUGSERVER_H
#define FGVIEWER_DEBUGSERVER_H

#include <utils/CString.h>
#include <unordered_map>
#include <vector>

#include <tsl/robin_map.h>
#include <utils/CString.h>
#include <utils/Mutex.h>

class CivetServer;
Expand Down Expand Up @@ -70,12 +71,9 @@ class DebugServer {
bool isReady() const { return mServer; }

private:
static FrameGraphInfoKey getKeybyString(const utils::CString &input,
uint32_t seed);

CivetServer* mServer;

tsl::robin_map<FrameGraphInfoKey, FrameGraphInfo> mViews;
std::unordered_map<FrameGraphInfoKey, FrameGraphInfo> mViews;
mutable utils::Mutex mViewsMutex;

class FileRequestHandler* mFileHandler = nullptr;
Expand Down
3 changes: 0 additions & 3 deletions libs/fgviewer/src/ApiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@

#include <CivetServer.h>

#include <sstream>
#include <chrono>

namespace filament::fgviewer {

using namespace std::chrono_literals;
Expand Down
4 changes: 0 additions & 4 deletions libs/fgviewer/src/ApiHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
#ifndef FGVIEWER_APIHANDLER_H
#define FGVIEWER_APIHANDLER_H

#include <mutex>
#include <condition_variable>
#include <atomic>

#include <CivetServer.h>

namespace filament::fgviewer {
Expand Down
29 changes: 13 additions & 16 deletions libs/fgviewer/src/DebugServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@
#include <utils/Hash.h>
#include <utils/Log.h>

#include <tsl/robin_set.h>

#include <sstream>
#include <string>
#include <string_view>

namespace filament::fgviewer {

namespace {
std::string const BASE_URL = "libs/matdbg/web";
} // anonymous
std::string const BASE_URL = "libs/fgviewer/web";

namespace filament::fgviewer {
FrameGraphInfoKey getKeybyString(const utils::CString &input,
uint32_t seed) {
return utils::hash::murmurSlow(reinterpret_cast<uint8_t const*>(
input.c_str()), input.size(), 0);
}
} // anonymous

using namespace utils;

Expand All @@ -61,7 +64,7 @@ class FileRequestHandler : public CivetHandler {
mg_send_file(conn, (BASE_URL + uri).c_str());
return true;
}
slog.e << "DebugServer: bad request at line " << __LINE__ << ": " << uri << io::endl;
slog.e << "fgviewer DebugServer: bad request at line " << __LINE__ << ": " << uri << io::endl;
return false;
}
private:
Expand All @@ -74,7 +77,7 @@ DebugServer::DebugServer(int port) {
/// establish multiple connections to load a single web page, including all linked documents
// (CSS, JavaScript, images, ...)." If this count is too small, the web app basically hangs.
const char* kServerOptions[] = {
"listening_ports", "8090",
"listening_ports", "8085",
"num_threads", "10",
"error_log_file", "civetweb.txt",
nullptr
Expand All @@ -86,7 +89,7 @@ DebugServer::DebugServer(int port) {
if (!mServer->getContext()) {
delete mServer;
mServer = nullptr;
slog.e << "Unable to start DebugServer, see civetweb.txt for details." << io::endl;
slog.e << "Unable to start fgviewer DebugServer, see civetweb.txt for details." << io::endl;
return;
}

Expand All @@ -96,7 +99,7 @@ DebugServer::DebugServer(int port) {
mServer->addHandler("/api", mApiHandler);
mServer->addHandler("", mFileHandler);

slog.i << "DebugServer listening at http://localhost:" << port << io::endl;
slog.i << "fgviewer DebugServer listening at http://localhost:" << port << io::endl;
}

DebugServer::~DebugServer() {
Expand All @@ -107,12 +110,6 @@ DebugServer::~DebugServer() {
delete mServer;
}

FrameGraphInfoKey DebugServer::getKeybyString(const utils::CString &input,
uint32_t seed) {
return utils::hash::murmurSlow(reinterpret_cast<uint8_t const*>(
input.c_str()), input.size(), 0);
}

void DebugServer::addView(const utils::CString &name, FrameGraphInfo info) {
std::unique_lock<utils::Mutex> lock(mViewsMutex);
const FrameGraphInfoKey key = getKeybyString(name, 0);
Expand Down

0 comments on commit 8e58dff

Please sign in to comment.