Compare commits
9 Commits
ma/descrip
...
fr/fgdbgap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e72e67bce | ||
|
|
a0c486f608 | ||
|
|
eb7447fd17 | ||
|
|
a870d01475 | ||
|
|
83e747b732 | ||
|
|
ca5cc32dc1 | ||
|
|
5c03e290c2 | ||
|
|
e4953ada3f | ||
|
|
10022f983b |
@@ -459,6 +459,13 @@ else()
|
||||
option(FILAMENT_ENABLE_MATDBG "Enable the material debugger" OFF)
|
||||
endif()
|
||||
|
||||
# By default, link in fgdbg for Desktop + Debug
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND IS_HOST_PLATFORM)
|
||||
option(FILAMENT_ENABLE_FGDBG "Enable the framegraph debugger" ON)
|
||||
else()
|
||||
option(FILAMENT_ENABLE_FGDBG "Enable the framegraph debugger" OFF)
|
||||
endif()
|
||||
|
||||
# Only optimize materials in Release mode (so error message lines match the source code)
|
||||
if (CMAKE_BUILD_TYPE MATCHES Release)
|
||||
option(FILAMENT_DISABLE_MATOPT "Disable material optimizations" OFF)
|
||||
@@ -685,6 +692,10 @@ if (FILAMENT_BUILD_FILAMAT OR IS_HOST_PLATFORM)
|
||||
if (FILAMENT_ENABLE_MATDBG OR IS_HOST_PLATFORM)
|
||||
add_subdirectory(${LIBRARIES}/matdbg)
|
||||
endif()
|
||||
|
||||
if (FILAMENT_ENABLE_FGDBG OR IS_HOST_PLATFORM)
|
||||
add_subdirectory(${LIBRARIES}/fgdbg)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN)
|
||||
|
||||
@@ -313,6 +313,7 @@ and tools.
|
||||
- `bluegl`: OpenGL bindings for macOS, Linux and Windows
|
||||
- `bluevk`: Vulkan bindings for macOS, Linux, Windows and Android
|
||||
- `camutils`: Camera manipulation utilities
|
||||
- `fgdbg`: Frame Graph inspector and debugger (debug builds only)
|
||||
- `filabridge`: Library shared by the Filament engine and host tools
|
||||
- `filaflat`: Serialization/deserialization library used for materials
|
||||
- `filagui`: Helper library for [Dear ImGui](https://github.com/ocornut/imgui)
|
||||
|
||||
6
build.sh
6
build.sh
@@ -162,6 +162,8 @@ EGL_ON_LINUX_OPTION="-DFILAMENT_SUPPORTS_EGL_ON_LINUX=OFF"
|
||||
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=OFF"
|
||||
MATDBG_GRADLE_OPTION=""
|
||||
|
||||
FGDBG_OPTION="-DFILAMENT_ENABLE_FGDBG=OFF"
|
||||
|
||||
IOS_BUILD_SIMULATOR=false
|
||||
BUILD_UNIVERSAL_LIBRARIES=false
|
||||
|
||||
@@ -221,6 +223,7 @@ function build_desktop_target {
|
||||
${SWIFTSHADER_OPTION} \
|
||||
${EGL_ON_LINUX_OPTION} \
|
||||
${MATDBG_OPTION} \
|
||||
${FGDBG_OPTION} \
|
||||
${deployment_target} \
|
||||
${architectures} \
|
||||
../..
|
||||
@@ -347,6 +350,7 @@ function build_android_target {
|
||||
-DCMAKE_INSTALL_PREFIX="../android-${lc_target}/filament" \
|
||||
-DCMAKE_TOOLCHAIN_FILE="../../build/toolchain-${arch}-linux-android.cmake" \
|
||||
${MATDBG_OPTION} \
|
||||
${FGDBG_OPTION} \
|
||||
${VULKAN_ANDROID_OPTION} \
|
||||
../..
|
||||
fi
|
||||
@@ -576,6 +580,7 @@ function build_ios_target {
|
||||
-DIOS=1 \
|
||||
-DCMAKE_TOOLCHAIN_FILE=../../third_party/clang/iOS.cmake \
|
||||
${MATDBG_OPTION} \
|
||||
${FGDBG_OPTION} \
|
||||
../..
|
||||
fi
|
||||
|
||||
@@ -760,6 +765,7 @@ while getopts ":hacCfijmp:q:uvslwtedk:" opt; do
|
||||
PRINT_MATDBG_HELP=true
|
||||
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=ON, -DFILAMENT_DISABLE_MATOPT=ON, -DFILAMENT_BUILD_FILAMAT=ON"
|
||||
MATDBG_GRADLE_OPTION="-Pcom.google.android.filament.matdbg"
|
||||
FGDBG_OPTION="-DFILAMENT_ENABLE_FGDBG=ON"
|
||||
;;
|
||||
f)
|
||||
ISSUE_CMAKE_ALWAYS=true
|
||||
|
||||
@@ -537,6 +537,13 @@ target_link_libraries(${TARGET} PUBLIC filaflat)
|
||||
target_link_libraries(${TARGET} PUBLIC filabridge)
|
||||
target_link_libraries(${TARGET} PUBLIC ibl-lite)
|
||||
|
||||
if (FILAMENT_ENABLE_FGDBG)
|
||||
target_link_libraries(${TARGET} PUBLIC fgdbg)
|
||||
add_definitions(-DFILAMENT_ENABLE_FGDBG=1)
|
||||
else()
|
||||
add_definitions(-DFILAMENT_ENABLE_FGDBG=0)
|
||||
endif()
|
||||
|
||||
if (FILAMENT_ENABLE_MATDBG)
|
||||
target_link_libraries(${TARGET} PUBLIC matdbg)
|
||||
add_definitions(-DFILAMENT_ENABLE_MATDBG=1)
|
||||
|
||||
@@ -258,6 +258,12 @@ uint32_t FEngine::getJobSystemThreadPoolSize() noexcept {
|
||||
void FEngine::init() {
|
||||
SYSTRACE_CALL();
|
||||
|
||||
#if FILAMENT_ENABLE_FGDBG
|
||||
if (!debug.fgdbg) {
|
||||
debug.fgdbg = std::make_unique<fgdbg::DebugServer>();
|
||||
}
|
||||
#endif
|
||||
|
||||
// this must be first.
|
||||
assert_invariant( intptr_t(&mDriverApiStorage) % alignof(DriverApi) == 0 );
|
||||
::new(&mDriverApiStorage) DriverApi(*mDriver, mCommandBufferQueue.getCircularBuffer());
|
||||
@@ -606,16 +612,16 @@ int FEngine::loop() {
|
||||
#endif
|
||||
if (portString != nullptr) {
|
||||
const int port = atoi(portString);
|
||||
debug.server = new matdbg::DebugServer(mBackend, port);
|
||||
debug.matdbg = std::make_unique<matdbg::DebugServer>(mBackend, port);
|
||||
|
||||
// Sometimes the server can fail to spin up (e.g. if the above port is already in use).
|
||||
// When this occurs, carry onward, developers can look at civetweb.txt for details.
|
||||
if (!debug.server->isReady()) {
|
||||
delete debug.server;
|
||||
debug.server = nullptr;
|
||||
if (!debug.matdbg->isReady()) {
|
||||
delete debug.matdbg.get();
|
||||
debug.matdbg = nullptr;
|
||||
} else {
|
||||
debug.server->setEditCallback(FMaterial::onEditCallback);
|
||||
debug.server->setQueryCallback(FMaterial::onQueryCallback);
|
||||
debug.matdbg->setEditCallback(FMaterial::onEditCallback);
|
||||
debug.matdbg->setQueryCallback(FMaterial::onQueryCallback);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -640,6 +646,16 @@ int FEngine::loop() {
|
||||
uint32_t id = std::thread::hardware_concurrency() - 1;
|
||||
|
||||
while (true) {
|
||||
#if FILAMENT_ENABLE_FGDBG
|
||||
// TODO (@feresr): Only for testing purposes, remove
|
||||
if (debug.fgdbg) {
|
||||
static int fgdbgMessage = 0;
|
||||
fgdbgMessage++;
|
||||
if (fgdbgMessage % 100 == 0) {
|
||||
debug.fgdbg->sendMessage(fgdbgMessage/100);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// looks like thread affinity needs to be reset regularly (on Android)
|
||||
JobSystem::setThreadAffinityById(id);
|
||||
if (!execute()) {
|
||||
|
||||
@@ -57,6 +57,14 @@
|
||||
#include <filament/Texture.h>
|
||||
#include <filament/VertexBuffer.h>
|
||||
|
||||
#if FILAMENT_ENABLE_FGDBG
|
||||
#include <fgdbg/DebugServer.h>
|
||||
#else
|
||||
namespace filament::fgdbg {
|
||||
class DebugServer;
|
||||
} // namespace filament::fgdbg
|
||||
#endif
|
||||
|
||||
#if FILAMENT_ENABLE_MATDBG
|
||||
#include <matdbg/DebugServer.h>
|
||||
#else
|
||||
@@ -519,7 +527,8 @@ public:
|
||||
// capture to file. At the moment, only supported by the Metal backend.
|
||||
bool doFrameCapture = false;
|
||||
} renderer;
|
||||
matdbg::DebugServer* server = nullptr;
|
||||
std::unique_ptr<matdbg::DebugServer> matdbg = nullptr;
|
||||
std::unique_ptr<fgdbg::DebugServer> fgdbg = nullptr;
|
||||
} debug;
|
||||
};
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ FMaterial::FMaterial(FEngine& engine, const Material::Builder& builder)
|
||||
|
||||
#if FILAMENT_ENABLE_MATDBG
|
||||
// Register the material with matdbg.
|
||||
matdbg::DebugServer* server = downcast(engine).debug.server;
|
||||
matdbg::DebugServer* server = downcast(engine).debug.matdbg.get();
|
||||
if (UTILS_UNLIKELY(server)) {
|
||||
auto details = builder.mImpl;
|
||||
mDebuggerId = server->addMaterial(mName, details->mPayload, details->mSize, this);
|
||||
@@ -319,7 +319,7 @@ void FMaterial::terminate(FEngine& engine) {
|
||||
|
||||
#if FILAMENT_ENABLE_MATDBG
|
||||
// Unregister the material with matdbg.
|
||||
matdbg::DebugServer* server = downcast(mEngine).debug.server;
|
||||
matdbg::DebugServer* server = downcast(mEngine).debug.matdbg.get();
|
||||
if (UTILS_UNLIKELY(server)) {
|
||||
server->removeMaterial(mDebuggerId);
|
||||
}
|
||||
|
||||
22
libs/fgdbg/CMakeLists.txt
Normal file
22
libs/fgdbg/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
project(fgdbg)
|
||||
|
||||
set(TARGET fgdbg)
|
||||
set(PUBLIC_HDR_DIR include)
|
||||
|
||||
# ==================================================================================================
|
||||
# Sources and headers
|
||||
# ==================================================================================================
|
||||
|
||||
set(PUBLIC_HDRS include/fgdbg/DebugServer.h include/fgdbg/Session.h)
|
||||
|
||||
set(SRCS src/DebugServer.cpp src/Session.cpp)
|
||||
|
||||
# ==================================================================================================
|
||||
# Include and target definitions
|
||||
# ==================================================================================================
|
||||
|
||||
add_library(${TARGET} STATIC ${PUBLIC_HDRS} ${SRCS})
|
||||
target_link_libraries(${TARGET} PUBLIC civetweb utils)
|
||||
target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR})
|
||||
include_directories(${PUBLIC_HDR_DIR})
|
||||
1
libs/fgdbg/README.md
Normal file
1
libs/fgdbg/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# FrameGraph Debugger (WIP)
|
||||
9
libs/fgdbg/client/.gitignore
vendored
Normal file
9
libs/fgdbg/client/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
/.idea/caches
|
||||
/.idea/gradle.xml
|
||||
.DS_Store
|
||||
/build
|
||||
46
libs/fgdbg/client/build.gradle.kts
Normal file
46
libs/fgdbg/client/build.gradle.kts
Normal file
@@ -0,0 +1,46 @@
|
||||
import org.jetbrains.compose.compose
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.6.10"
|
||||
id("org.jetbrains.compose") version "1.1.1"
|
||||
}
|
||||
|
||||
group = "com.google.filament"
|
||||
version = "1.0"
|
||||
val ktorVersion: String by project
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
|
||||
maven {
|
||||
url = uri("https://maven.pkg.jetbrains.space/public/p/ktor/eap")
|
||||
name = "ktor-eap"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(compose.desktop.currentOs)
|
||||
dependencies {
|
||||
implementation("io.ktor:ktor-client-core:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-cio:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-websockets:$ktorVersion")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "11"
|
||||
}
|
||||
|
||||
compose.desktop {
|
||||
application {
|
||||
mainClass = "MainKt"
|
||||
nativeDistributions {
|
||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
||||
packageName = "fgdbg"
|
||||
packageVersion = "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
2
libs/fgdbg/client/gradle.properties
Normal file
2
libs/fgdbg/client/gradle.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
kotlin.code.style=official
|
||||
ktorVersion=2.1.2
|
||||
BIN
libs/fgdbg/client/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
libs/fgdbg/client/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
libs/fgdbg/client/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
libs/fgdbg/client/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
234
libs/fgdbg/client/gradlew
vendored
Executable file
234
libs/fgdbg/client/gradlew
vendored
Executable file
@@ -0,0 +1,234 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# https://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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
libs/fgdbg/client/gradlew.bat
vendored
Normal file
89
libs/fgdbg/client/gradlew.bat
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
9
libs/fgdbg/client/settings.gradle.kts
Normal file
9
libs/fgdbg/client/settings.gradle.kts
Normal file
@@ -0,0 +1,9 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google()
|
||||
gradlePluginPortal()
|
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
|
||||
}
|
||||
|
||||
}
|
||||
rootProject.name = "fgdbg"
|
||||
104
libs/fgdbg/client/src/main/kotlin/Main.kt
Normal file
104
libs/fgdbg/client/src/main/kotlin/Main.kt
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.desktop.ui.tooling.preview.Preview
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.application
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.plugins.websocket.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.websocket.Frame
|
||||
import io.ktor.websocket.readText
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
private enum class ConnectionState { UNKNOWN, CONNECTED, CONNECTING, ERROR }
|
||||
|
||||
private data class Connection(
|
||||
val host: String = "localhost",
|
||||
val port: Int = 8082,
|
||||
val path: String = "/",
|
||||
val state: MutableState<ConnectionState> = mutableStateOf(ConnectionState.UNKNOWN),
|
||||
val reconnectDelay: Int = 5,
|
||||
)
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
fun App() {
|
||||
val connection = remember { Connection() }
|
||||
val client = remember { HttpClient { install(WebSockets) } }
|
||||
var message by remember { mutableStateOf("") }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
while (true) {
|
||||
connection.state.value = ConnectionState.CONNECTING
|
||||
try {
|
||||
client.webSocket(HttpMethod.Get,
|
||||
connection.host,
|
||||
connection.port,
|
||||
connection.path) {
|
||||
message = "Connected!"
|
||||
connection.state.value = ConnectionState.CONNECTED
|
||||
while (true) {
|
||||
val frame = incoming.receive() as? Frame.Text ?: continue
|
||||
message = frame.readText()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
connection.state.value = ConnectionState.ERROR
|
||||
repeat(connection.reconnectDelay) {
|
||||
val remaining = connection.reconnectDelay - it
|
||||
message = "Connection interrupted, will re-connect in $remaining seconds..."
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DisposableEffect(Unit) { onDispose { client.close() } }
|
||||
|
||||
MaterialTheme {
|
||||
when (connection.state.value) {
|
||||
ConnectionState.CONNECTED -> {
|
||||
Row(Modifier.height(40.dp)) {
|
||||
Text(modifier = Modifier.align(Alignment.CenterVertically),
|
||||
text = "Listening on ${connection.host}:${connection.port} ")
|
||||
Button(onClick = {}) { Text(message) }
|
||||
}
|
||||
}
|
||||
ConnectionState.ERROR -> Text(text = message, color = Color.Red)
|
||||
else -> Text(connection.state.value.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main() = application { Window(onCloseRequest = ::exitApplication) { App() } }
|
||||
2
libs/fgdbg/client/src/main/kotlin/NavRestore.kt
Normal file
2
libs/fgdbg/client/src/main/kotlin/NavRestore.kt
Normal file
@@ -0,0 +1,2 @@
|
||||
class NavRestore {
|
||||
}
|
||||
42
libs/fgdbg/include/fgdbg/DebugServer.h
Normal file
42
libs/fgdbg/include/fgdbg/DebugServer.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 FGDBG_DEBUGSERVER_H
|
||||
#define FGDBG_DEBUGSERVER_H
|
||||
|
||||
class CivetServer;
|
||||
|
||||
namespace filament::fgdbg {
|
||||
|
||||
class DebugServer {
|
||||
public:
|
||||
DebugServer();
|
||||
~DebugServer();
|
||||
|
||||
void sendMessage(int number);
|
||||
|
||||
private:
|
||||
CivetServer* mServer;
|
||||
|
||||
class RestRequestHandler *mRestRequestHandler = nullptr;
|
||||
class WebSocketHandler* mWebSocketHandler = nullptr;
|
||||
|
||||
friend class RestRequestHandler;
|
||||
friend class WebSocketHandler;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // FGDBG_DEBUGSERVER_H
|
||||
34
libs/fgdbg/include/fgdbg/Pass.h
Normal file
34
libs/fgdbg/include/fgdbg/Pass.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 FGDBG_PASS_H
|
||||
#define FGDBG_PASS_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace filament::fgdbg {
|
||||
using ResourceId = int;
|
||||
|
||||
struct Pass {
|
||||
std::string name;
|
||||
int id;
|
||||
std::vector<ResourceId> reads;
|
||||
std::vector<ResourceId> writes;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //FGDBG_PASS_H
|
||||
30
libs/fgdbg/include/fgdbg/Resource.h
Normal file
30
libs/fgdbg/include/fgdbg/Resource.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 FGDBG_RESOURCE_H
|
||||
#define FGDBG_RESOURCE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace filament::fgdbg {
|
||||
struct Resource {
|
||||
std::string name;
|
||||
int id;
|
||||
int size;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //FGDBG_RESOURCE_H
|
||||
28
libs/fgdbg/include/fgdbg/Session.h
Normal file
28
libs/fgdbg/include/fgdbg/Session.h
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by Fernando Raviola on 4/11/2022.
|
||||
//
|
||||
|
||||
#ifndef FGDBG_SESSION_H
|
||||
#define FGDBG_SESSION_H
|
||||
|
||||
#include "DebugServer.h"
|
||||
#include "Resource.h"
|
||||
#include "Pass.h"
|
||||
#include <memory>
|
||||
|
||||
namespace filament::fgdbg {
|
||||
class Session {
|
||||
|
||||
public:
|
||||
Session(std::shared_ptr<DebugServer> server) : server{ server } {}
|
||||
|
||||
void addPasses(std::vector<Pass> passes);
|
||||
void addResources(std::vector<Resource> resources);
|
||||
void update();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DebugServer> server;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //FGDBG_SESSION_H
|
||||
110
libs/fgdbg/src/DebugServer.cpp
Normal file
110
libs/fgdbg/src/DebugServer.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 "fgdbg/DebugServer.h"
|
||||
#include <CivetServer.h>
|
||||
#include <utils/Log.h>
|
||||
#include <tsl/robin_set.h>
|
||||
|
||||
namespace filament::fgdbg {
|
||||
|
||||
using namespace utils;
|
||||
|
||||
static const std::string_view kSuccessHeader =
|
||||
"HTTP/1.1 200 OK\r\nContent-Type: %s\r\n"
|
||||
"Connection: close\r\n\r\n";
|
||||
|
||||
class RestRequestHandler : public CivetHandler {
|
||||
|
||||
public:
|
||||
RestRequestHandler() = default;
|
||||
|
||||
bool handleGet(CivetServer *server, struct mg_connection *conn) override {
|
||||
mg_printf(conn, kSuccessHeader.data(), "application/json");
|
||||
mg_printf(conn, "{ RestRequestHandler is working! }");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class WebSocketHandler : public CivetWebSocketHandler {
|
||||
|
||||
public:
|
||||
WebSocketHandler() = default;
|
||||
|
||||
bool handleConnection(CivetServer *server, const struct mg_connection *conn) override {
|
||||
return true;
|
||||
}
|
||||
|
||||
void handleReadyState(CivetServer *server, struct mg_connection *conn) override {
|
||||
mConnections.insert(conn);
|
||||
}
|
||||
|
||||
void handleClose(CivetServer *server, const struct mg_connection *conn) override {
|
||||
auto *key = const_cast<struct mg_connection *>(conn);
|
||||
mConnections.erase(key);
|
||||
}
|
||||
|
||||
void send(int number) {
|
||||
auto string = std::to_string(number);
|
||||
for (auto connection : mConnections) {
|
||||
mg_websocket_write(connection,
|
||||
MG_WEBSOCKET_OPCODE_TEXT,
|
||||
string.c_str(),
|
||||
string.length());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
tsl::robin_set<struct mg_connection*> mConnections;
|
||||
};
|
||||
|
||||
DebugServer::DebugServer() {
|
||||
slog.d << "FrameGraph debug server created" << io::endl;
|
||||
|
||||
//TODO (@feresr): Make port param customizable
|
||||
const char* kServerOptions[] = {
|
||||
"listening_ports", "8082",
|
||||
"num_threads", "10",
|
||||
"error_log_file", "civetweb.txt",
|
||||
nullptr
|
||||
};
|
||||
|
||||
mServer = new CivetServer(kServerOptions);
|
||||
if (!mServer->getContext()) {
|
||||
delete mServer;
|
||||
mServer = nullptr;
|
||||
slog.e << "Unable to start fgdbg DebugServer, see civetweb.txt for details." << io::endl;
|
||||
return;
|
||||
}
|
||||
slog.i << "Server started successfully" << io::endl;
|
||||
|
||||
mRestRequestHandler = new RestRequestHandler();
|
||||
mWebSocketHandler = new WebSocketHandler();
|
||||
|
||||
mServer->addHandler("", mRestRequestHandler);
|
||||
mServer->addWebSocketHandler("", mWebSocketHandler);
|
||||
}
|
||||
|
||||
void DebugServer::sendMessage(int number) {
|
||||
mWebSocketHandler->send(number);
|
||||
}
|
||||
|
||||
DebugServer::~DebugServer() {
|
||||
slog.d << "FrameGraph debug server destroyed" << io::endl;
|
||||
delete mRestRequestHandler;
|
||||
delete mWebSocketHandler;
|
||||
}
|
||||
}
|
||||
25
libs/fgdbg/src/Session.cpp
Normal file
25
libs/fgdbg/src/Session.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 "Session.h"
|
||||
|
||||
namespace filament::fgdbg {
|
||||
|
||||
void Session::addPasses(std::vector <Pass> passes);
|
||||
void Session::addResources(std::vector <Resource> resources);
|
||||
void Session::update();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user