impr: Simplify tracy integration
This commit is contained in:
parent
3e0bb6d8be
commit
92b5fd84c2
@ -543,13 +543,9 @@ macro(setupDebugCompressionFlag)
|
|||||||
|
|
||||||
if (NOT DEBUG_COMPRESSION_FLAG) # Cache variable
|
if (NOT DEBUG_COMPRESSION_FLAG) # Cache variable
|
||||||
if (ZSTD_AVAILABLE_COMPILER AND ZSTD_AVAILABLE_LINKER)
|
if (ZSTD_AVAILABLE_COMPILER AND ZSTD_AVAILABLE_LINKER)
|
||||||
message("Using Zstd compression for debug info because both compiler and linker support it")
|
|
||||||
set(DEBUG_COMPRESSION_FLAG "-gz=zstd" CACHE STRING "Cache to use for debug info compression")
|
set(DEBUG_COMPRESSION_FLAG "-gz=zstd" CACHE STRING "Cache to use for debug info compression")
|
||||||
elseif (COMPRESS_AVAILABLE_COMPILER AND COMPRESS_AVAILABLE_LINKER)
|
elseif (COMPRESS_AVAILABLE_COMPILER AND COMPRESS_AVAILABLE_LINKER)
|
||||||
message("Using default compression for debug info because both compiler and linker support it")
|
|
||||||
set(DEBUG_COMPRESSION_FLAG "-gz" CACHE STRING "Cache to use for debug info compression")
|
set(DEBUG_COMPRESSION_FLAG "-gz" CACHE STRING "Cache to use for debug info compression")
|
||||||
else()
|
|
||||||
message("No compression available for debug info")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ macro(add_imhex_plugin)
|
|||||||
# Add include directories and link libraries
|
# Add include directories and link libraries
|
||||||
target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
|
target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
|
||||||
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_LIBRARIES})
|
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_LIBRARIES})
|
||||||
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} imgui_all_includes libwolv)
|
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} imgui_all_includes libwolv tracing)
|
||||||
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl)
|
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl)
|
||||||
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl-gen)
|
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl-gen)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
project(tracing)
|
project(tracing)
|
||||||
|
|
||||||
option(IMHEX_TRACE_EXCEPTIONS "Hook thrown exceptions to display a stack trace when possible" ON)
|
option(IMHEX_TRACE_EXCEPTIONS "Hook thrown exceptions to display a stack trace when possible" ON)
|
||||||
option(IMHEX_INSTRUMENT_FUNCTIONS "Hook all function entries and exits to profile things in Tracy" OFF)
|
option(IMHEX_INSTRUMENT_FUNCTIONS "Hook all function entries and exits to profile things in Tracy" ON)
|
||||||
|
|
||||||
add_library(tracing OBJECT
|
add_library(tracing OBJECT
|
||||||
source/stacktrace.cpp
|
source/stacktrace.cpp
|
||||||
@ -42,20 +42,23 @@ endif()
|
|||||||
|
|
||||||
if (IMHEX_INSTRUMENT_FUNCTIONS)
|
if (IMHEX_INSTRUMENT_FUNCTIONS)
|
||||||
target_sources(tracing PUBLIC
|
target_sources(tracing PUBLIC
|
||||||
source/instr_entry.cpp
|
|
||||||
source/instrumentation.cpp
|
source/instrumentation.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(TRACY_ON_DEMAND ON CACHE INTERNAL "TRACY_ON_DEMAND")
|
||||||
|
set(TRACY_DELAYED_INIT ON CACHE INTERNAL "TRACY_DELAYED_INIT")
|
||||||
|
set(TRACY_ONLY_LOCALHOST ON CACHE INTERNAL "TRACY_ONLY_LOCALHOST")
|
||||||
|
set(TRACY_NO_FRAME_IMAGE ON CACHE INTERNAL "TRACY_NO_FRAME_IMAGE")
|
||||||
|
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "BUILD_SHARED_LIBS")
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
tracy
|
tracy
|
||||||
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
|
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
|
||||||
GIT_TAG v0.10
|
GIT_TAG master
|
||||||
GIT_SHALLOW TRUE
|
GIT_SHALLOW TRUE
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(tracy)
|
FetchContent_MakeAvailable(tracy)
|
||||||
target_compile_options(TracyClient PRIVATE "-Wno-error")
|
target_compile_options(TracyClient PRIVATE "-Wno-error")
|
||||||
|
target_link_libraries(tracing PUBLIC TracyClient)
|
||||||
target_compile_options(tracing PUBLIC "-finstrument-functions")
|
target_compile_definitions(tracing PUBLIC IMHEX_USE_INSTRUMENTATION=1)
|
||||||
target_link_libraries(tracing PRIVATE TracyClient)
|
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#if defined(IMHEX_USE_INSTRUMENTATION)
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
#include <tracy/Tracy.hpp>
|
||||||
|
|
||||||
|
#define IMHEX_TRACE_SCOPE ZoneScoped
|
||||||
|
#define IMHEX_TRACE_SCOPE_NAME(name) ZoneScoped; ZoneName(name, strlen(name))
|
||||||
|
#define IMHEX_START_FRAME_MARK FrameMarkStart("Frame")
|
||||||
|
#define IMHEX_END_FRAME_MARK FrameMarkEnd("Frame")
|
||||||
|
#define IMHEX_TRACE_MESSAGE(message) TracyMessage(message, strlen(message))
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define IMHEX_TRACE_SCOPE_NAME(name)
|
||||||
|
#define IMHEX_END_FRAME_MARK
|
||||||
|
|
||||||
|
#endif
|
@ -1,28 +0,0 @@
|
|||||||
#include <mutex>
|
|
||||||
|
|
||||||
namespace hex {
|
|
||||||
|
|
||||||
void functionEntry(void *);
|
|
||||||
void functionExit(void *);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
static std::mutex s_mutex;
|
|
||||||
|
|
||||||
[[gnu::no_instrument_function]]
|
|
||||||
void __cyg_profile_func_enter(void *functionAddress, void *) {
|
|
||||||
std::scoped_lock lock(s_mutex);
|
|
||||||
|
|
||||||
hex::functionEntry(functionAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[gnu::no_instrument_function]]
|
|
||||||
void __cyg_profile_func_exit(void *functionAddress, void *) {
|
|
||||||
std::scoped_lock lock(s_mutex);
|
|
||||||
|
|
||||||
hex::functionExit(functionAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +1 @@
|
|||||||
#include <hex/trace/instrumentation.hpp>
|
#include <hex/trace/instrumentation.hpp>
|
||||||
|
|
||||||
namespace hex {
|
|
||||||
|
|
||||||
void functionEntry([[maybe_unused]] void *functionAddress) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void functionExit([[maybe_unused]] void *functionAddress) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -57,7 +57,7 @@ set_target_properties(main PROPERTIES
|
|||||||
|
|
||||||
target_compile_definitions(main PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
target_compile_definitions(main PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
||||||
|
|
||||||
target_link_libraries(main PRIVATE libromfs-imhex libimhex libwolv ${LIBBACKTRACE_LIBRARIES} LLVMDemangle)
|
target_link_libraries(main PRIVATE libromfs-imhex libimhex libwolv ${LIBBACKTRACE_LIBRARIES} LLVMDemangle tracing)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(main PRIVATE usp10 wsock32 ws2_32 Dwmapi.lib)
|
target_link_libraries(main PRIVATE usp10 wsock32 ws2_32 Dwmapi.lib)
|
||||||
else ()
|
else ()
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include <hex/ui/view.hpp>
|
#include <hex/ui/view.hpp>
|
||||||
#include <hex/ui/popup.hpp>
|
#include <hex/ui/popup.hpp>
|
||||||
|
|
||||||
|
#include <hex/trace/instrumentation.hpp>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
@ -236,7 +238,9 @@ namespace hex {
|
|||||||
glfwSetWindowSizeLimits(m_window, lastWindowSize.x, lastWindowSize.y, lastWindowSize.x, lastWindowSize.y);
|
glfwSetWindowSizeLimits(m_window, lastWindowSize.x, lastWindowSize.y, lastWindowSize.x, lastWindowSize.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMHEX_START_FRAME_MARK;
|
||||||
this->fullFrame();
|
this->fullFrame();
|
||||||
|
IMHEX_END_FRAME_MARK;
|
||||||
|
|
||||||
ImHexApi::System::impl::setLastFrameTime(glfwGetTime() - m_lastStartFrameTime);
|
ImHexApi::System::impl::setLastFrameTime(glfwGetTime() - m_lastStartFrameTime);
|
||||||
|
|
||||||
@ -288,6 +292,8 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window::frameBegin() {
|
void Window::frameBegin() {
|
||||||
|
IMHEX_TRACE_SCOPE;
|
||||||
|
|
||||||
// Start new ImGui Frame
|
// Start new ImGui Frame
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
@ -547,6 +553,8 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window::drawView(const std::string &name, const std::unique_ptr<View> &view) {
|
void Window::drawView(const std::string &name, const std::unique_ptr<View> &view) {
|
||||||
|
IMHEX_TRACE_SCOPE_NAME(name.c_str());
|
||||||
|
|
||||||
// Draw always visible views
|
// Draw always visible views
|
||||||
view->drawAlwaysVisibleContent();
|
view->drawAlwaysVisibleContent();
|
||||||
|
|
||||||
@ -607,6 +615,8 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window::frame() {
|
void Window::frame() {
|
||||||
|
IMHEX_TRACE_SCOPE;
|
||||||
|
|
||||||
// Loop through all views and draw them
|
// Loop through all views and draw them
|
||||||
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
|
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||||
ImGui::GetCurrentContext()->NextWindowData.ClearFlags();
|
ImGui::GetCurrentContext()->NextWindowData.ClearFlags();
|
||||||
@ -624,6 +634,8 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window::frameEnd() {
|
void Window::frameEnd() {
|
||||||
|
IMHEX_TRACE_SCOPE;
|
||||||
|
|
||||||
EventFrameEnd::post();
|
EventFrameEnd::post();
|
||||||
|
|
||||||
TutorialManager::drawTutorial();
|
TutorialManager::drawTutorial();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user