-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add skeleton code of fgviewer (#8303)
* Skeleton of fgviewer debug server * Update the map for fg info * Add ApiHandler skeleton class * Format the files Format the file * Prevent fgviewer being built before ready Add comment to fgviewer related lines Fix cmake commands * Update the copyright * Address the comments Address the comments * Address the comments * Specify the debug server * Fix build options
- Loading branch information
Showing
11 changed files
with
528 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
cmake_minimum_required(VERSION 3.19) | ||
project(fgviewer C ASM) | ||
|
||
set(TARGET fgviewer) | ||
set(PUBLIC_HDR_DIR include) | ||
|
||
if (CMAKE_CROSSCOMPILING) | ||
include(${IMPORT_EXECUTABLES}) | ||
endif() | ||
|
||
# ================================================================================================== | ||
# Sources and headers | ||
# ================================================================================================== | ||
|
||
set(PUBLIC_HDRS | ||
include/fgviewer/DebugServer.h | ||
include/fgviewer/JsonWriter.h | ||
) | ||
|
||
set(SRCS | ||
src/ApiHandler.cpp | ||
src/ApiHandler.h | ||
src/DebugServer.cpp | ||
) | ||
|
||
# ================================================================================================== | ||
# Include and target definitions | ||
# ================================================================================================== | ||
|
||
include_directories(${PUBLIC_HDR_DIR}) | ||
|
||
add_library(${TARGET} STATIC ${PUBLIC_HDRS} ${SRCS}) | ||
|
||
target_link_libraries(${TARGET} PUBLIC | ||
civetweb | ||
utils | ||
) | ||
|
||
target_include_directories(${TARGET} PRIVATE ${filamat_SOURCE_DIR}/src) | ||
|
||
target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR}) | ||
set_target_properties(${TARGET} PROPERTIES FOLDER Libs) | ||
|
||
# ================================================================================================== | ||
# Compiler flags | ||
# ================================================================================================== | ||
|
||
if (MSVC) | ||
else() | ||
target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register) | ||
endif() | ||
|
||
# ================================================================================================== | ||
# Installation | ||
# ================================================================================================== | ||
|
||
# matdbg has dependencies on non-installed libraries. Here we bundle them all together into a single | ||
# library that gets copied into the installation folder so users are only required to link against | ||
# matdbg. | ||
set(FGVIEWER_DEPS | ||
fgviewer | ||
civetweb | ||
) | ||
|
||
set(FGVIEWER_COMBINED_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libfgviewer_combined.a") | ||
combine_static_libs(fgviewer "${FGVIEWER_COMBINED_OUTPUT}" "${FGVIEWER_DEPS}") | ||
|
||
set(FGVIEWER_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}fgviewer${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
install(FILES "${FGVIEWER_COMBINED_OUTPUT}" DESTINATION lib/${DIST_DIR} RENAME ${FGVIEWER_LIB_NAME}) | ||
# We do not need fgviewer headers in the install directory | ||
# install(DIRECTORY ${PUBLIC_HDR_DIR}/fgviewer DESTINATION include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* 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_DEBUGSERVER_H | ||
#define FGVIEWER_DEBUGSERVER_H | ||
|
||
#include <utils/CString.h> | ||
#include <utils/Mutex.h> | ||
|
||
#include <unordered_map> | ||
#include <vector> | ||
|
||
class CivetServer; | ||
|
||
namespace filament::fgviewer { | ||
|
||
using FrameGraphInfoKey = uint32_t; | ||
|
||
struct FrameGraphPassInfo { | ||
utils::CString pass_name; | ||
// TODO: Add struct detail properties | ||
}; | ||
|
||
struct FrameGraphInfo { | ||
utils::CString view_name; | ||
std::vector<FrameGraphPassInfo> passes; | ||
}; | ||
|
||
/** | ||
* Server-side frame graph debugger. | ||
* | ||
* This class manages an HTTP server. It receives frame graph packages from the Filament C++ engine or | ||
* from a standalone tool such as fginfo. | ||
*/ | ||
class DebugServer { | ||
public: | ||
static std::string_view const kSuccessHeader; | ||
static std::string_view const kErrorHeader; | ||
|
||
DebugServer(int port); | ||
~DebugServer(); | ||
|
||
/** | ||
* Notifies the debugger that a new view has been added. | ||
*/ | ||
void addView(const utils::CString& name, FrameGraphInfo info); | ||
|
||
/** | ||
* Notifies the debugger that the given view has been deleted. | ||
*/ | ||
void removeView(const utils::CString& name); | ||
|
||
/** | ||
* Updates the information for a given view. | ||
*/ | ||
void updateView(const utils::CString& name, FrameGraphInfo info); | ||
|
||
bool isReady() const { return mServer; } | ||
|
||
private: | ||
CivetServer* mServer; | ||
|
||
std::unordered_map<FrameGraphInfoKey, FrameGraphInfo> mViews; | ||
mutable utils::Mutex mViewsMutex; | ||
|
||
class FileRequestHandler* mFileHandler = nullptr; | ||
class ApiHandler* mApiHandler = nullptr; | ||
|
||
friend class FileRequestHandler; | ||
friend class ApiHandler; | ||
}; | ||
|
||
} // namespace filament::fgviewer | ||
|
||
#endif // FGVIEWER_DEBUGSERVER_H |
Oops, something went wrong.