mirror of
https://github.com/shadps4-emu/tracy.git
synced 2024-11-26 20:40:22 +00:00
Tracy Profiler 0.11.1
This commit is contained in:
parent
b8061982ca
commit
143a53d198
@ -38,7 +38,7 @@ target_link_libraries(
|
||||
)
|
||||
|
||||
# Public dependency on some libraries required when using Mingw
|
||||
if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
|
||||
if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU|Clang")
|
||||
target_link_libraries(TracyClient PUBLIC ws2_32 dbghelp)
|
||||
endif()
|
||||
|
||||
@ -47,6 +47,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
target_link_libraries(TracyClient PUBLIC ${EXECINFO_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(TRACY_LIBUNWIND_BACKTRACE)
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(unwind REQUIRED libunwind)
|
||||
target_include_directories(TracyClient INTERFACE ${unwind_INCLUDE_DIRS})
|
||||
target_link_libraries(TracyClient INTERFACE ${unwind_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
add_library(Tracy::TracyClient ALIAS TracyClient)
|
||||
|
||||
macro(set_option option help value)
|
||||
@ -86,6 +93,8 @@ set_option(TRACY_SYMBOL_OFFLINE_RESOLVE "Instead of full runtime symbol resoluti
|
||||
set_option(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT "Enable libbacktrace to support dynamically loaded elfs in symbol resolution resolution after the first symbol resolve operation" OFF)
|
||||
|
||||
# advanced
|
||||
set_option(TRACY_VERBOSE "[advanced] Verbose output from the profiler" OFF)
|
||||
mark_as_advanced(TRACY_VERBOSE)
|
||||
set_option(TRACY_DEMANGLE "[advanced] Don't use default demangling function - You'll need to provide your own" OFF)
|
||||
mark_as_advanced(TRACY_DEMANGLE)
|
||||
|
||||
@ -152,7 +161,12 @@ install(TARGETS TracyClient
|
||||
EXPORT TracyConfig
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT lib)
|
||||
# Export targets to build tree root
|
||||
export(TARGETS TracyClient
|
||||
NAMESPACE Tracy::
|
||||
FILE ${CMAKE_BINARY_DIR}/TracyTargets.cmake)
|
||||
install(FILES ${tracy_includes}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tracy)
|
||||
install(FILES ${client_includes}
|
||||
|
142
cmake/CPM.cmake
142
cmake/CPM.cmake
@ -42,7 +42,7 @@ if(NOT COMMAND cpm_message)
|
||||
endfunction()
|
||||
endif()
|
||||
|
||||
set(CURRENT_CPM_VERSION 0.38.7)
|
||||
set(CURRENT_CPM_VERSION 0.40.2)
|
||||
|
||||
get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
|
||||
if(CPM_DIRECTORY)
|
||||
@ -300,12 +300,6 @@ function(CPMFindPackage)
|
||||
return()
|
||||
endif()
|
||||
|
||||
cpm_check_if_package_already_added(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}")
|
||||
if(CPM_PACKAGE_ALREADY_ADDED)
|
||||
cpm_export_variables(${CPM_ARGS_NAME})
|
||||
return()
|
||||
endif()
|
||||
|
||||
cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS})
|
||||
|
||||
if(NOT CPM_PACKAGE_FOUND)
|
||||
@ -397,8 +391,8 @@ function(cpm_parse_add_package_single_arg arg outArgs)
|
||||
# We don't try to parse the version if it's not provided explicitly. cpm_get_version_from_url
|
||||
# should do this at a later point
|
||||
else()
|
||||
# We should never get here. This is an assertion and hitting it means there's a bug in the code
|
||||
# above. A packageType was set, but not handled by this if-else.
|
||||
# We should never get here. This is an assertion and hitting it means there's a problem with the
|
||||
# code above. A packageType was set, but not handled by this if-else.
|
||||
message(FATAL_ERROR "${CPM_INDENT} Unsupported package type '${packageType}' of '${arg}'")
|
||||
endif()
|
||||
|
||||
@ -470,6 +464,72 @@ function(cpm_check_git_working_dir_is_clean repoPath gitTag isClean)
|
||||
|
||||
endfunction()
|
||||
|
||||
# Add PATCH_COMMAND to CPM_ARGS_UNPARSED_ARGUMENTS. This method consumes a list of files in ARGN
|
||||
# then generates a `PATCH_COMMAND` appropriate for `ExternalProject_Add()`. This command is appended
|
||||
# to the parent scope's `CPM_ARGS_UNPARSED_ARGUMENTS`.
|
||||
function(cpm_add_patches)
|
||||
# Return if no patch files are supplied.
|
||||
if(NOT ARGN)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Find the patch program.
|
||||
find_program(PATCH_EXECUTABLE patch)
|
||||
if(WIN32 AND NOT PATCH_EXECUTABLE)
|
||||
# The Windows git executable is distributed with patch.exe. Find the path to the executable, if
|
||||
# it exists, then search `../usr/bin` and `../../usr/bin` for patch.exe.
|
||||
find_package(Git QUIET)
|
||||
if(GIT_EXECUTABLE)
|
||||
get_filename_component(extra_search_path ${GIT_EXECUTABLE} DIRECTORY)
|
||||
get_filename_component(extra_search_path_1up ${extra_search_path} DIRECTORY)
|
||||
get_filename_component(extra_search_path_2up ${extra_search_path_1up} DIRECTORY)
|
||||
find_program(
|
||||
PATCH_EXECUTABLE patch HINTS "${extra_search_path_1up}/usr/bin"
|
||||
"${extra_search_path_2up}/usr/bin"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT PATCH_EXECUTABLE)
|
||||
message(FATAL_ERROR "Couldn't find `patch` executable to use with PATCHES keyword.")
|
||||
endif()
|
||||
|
||||
# Create a temporary
|
||||
set(temp_list ${CPM_ARGS_UNPARSED_ARGUMENTS})
|
||||
|
||||
# Ensure each file exists (or error out) and add it to the list.
|
||||
set(first_item True)
|
||||
foreach(PATCH_FILE ${ARGN})
|
||||
# Make sure the patch file exists, if we can't find it, try again in the current directory.
|
||||
if(NOT EXISTS "${PATCH_FILE}")
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/${PATCH_FILE}")
|
||||
message(FATAL_ERROR "Couldn't find patch file: '${PATCH_FILE}'")
|
||||
endif()
|
||||
set(PATCH_FILE "${CMAKE_CURRENT_LIST_DIR}/${PATCH_FILE}")
|
||||
endif()
|
||||
|
||||
# Convert to absolute path for use with patch file command.
|
||||
get_filename_component(PATCH_FILE "${PATCH_FILE}" ABSOLUTE)
|
||||
|
||||
# The first patch entry must be preceded by "PATCH_COMMAND" while the following items are
|
||||
# preceded by "&&".
|
||||
if(first_item)
|
||||
set(first_item False)
|
||||
list(APPEND temp_list "PATCH_COMMAND")
|
||||
else()
|
||||
list(APPEND temp_list "&&")
|
||||
endif()
|
||||
# Add the patch command to the list
|
||||
list(APPEND temp_list "${PATCH_EXECUTABLE}" "-p1" "<" "${PATCH_FILE}")
|
||||
endforeach()
|
||||
|
||||
# Move temp out into parent scope.
|
||||
set(CPM_ARGS_UNPARSED_ARGUMENTS
|
||||
${temp_list}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
endfunction()
|
||||
|
||||
# method to overwrite internal FetchContent properties, to allow using CPM.cmake to overload
|
||||
# FetchContent calls. As these are internal cmake properties, this method should be used carefully
|
||||
# and may need modification in future CMake versions. Source:
|
||||
@ -540,9 +600,10 @@ function(CPMAddPackage)
|
||||
GIT_SHALLOW
|
||||
EXCLUDE_FROM_ALL
|
||||
SOURCE_SUBDIR
|
||||
CUSTOM_CACHE_KEY
|
||||
)
|
||||
|
||||
set(multiValueArgs URL OPTIONS DOWNLOAD_COMMAND)
|
||||
set(multiValueArgs URL OPTIONS DOWNLOAD_COMMAND PATCHES)
|
||||
|
||||
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
||||
|
||||
@ -633,6 +694,7 @@ function(CPMAddPackage)
|
||||
SOURCE_DIR "${PACKAGE_SOURCE}"
|
||||
EXCLUDE_FROM_ALL "${CPM_ARGS_EXCLUDE_FROM_ALL}"
|
||||
SYSTEM "${CPM_ARGS_SYSTEM}"
|
||||
PATCHES "${CPM_ARGS_PATCHES}"
|
||||
OPTIONS "${CPM_ARGS_OPTIONS}"
|
||||
SOURCE_SUBDIR "${CPM_ARGS_SOURCE_SUBDIR}"
|
||||
DOWNLOAD_ONLY "${DOWNLOAD_ONLY}"
|
||||
@ -688,6 +750,8 @@ function(CPMAddPackage)
|
||||
set(CPM_FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/_deps)
|
||||
endif()
|
||||
|
||||
cpm_add_patches(${CPM_ARGS_PATCHES})
|
||||
|
||||
if(DEFINED CPM_ARGS_DOWNLOAD_COMMAND)
|
||||
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS DOWNLOAD_COMMAND ${CPM_ARGS_DOWNLOAD_COMMAND})
|
||||
elseif(DEFINED CPM_ARGS_SOURCE_DIR)
|
||||
@ -710,7 +774,10 @@ function(CPMAddPackage)
|
||||
string(TOLOWER ${CPM_ARGS_NAME} lower_case_name)
|
||||
set(origin_parameters ${CPM_ARGS_UNPARSED_ARGUMENTS})
|
||||
list(SORT origin_parameters)
|
||||
if(CPM_USE_NAMED_CACHE_DIRECTORIES)
|
||||
if(CPM_ARGS_CUSTOM_CACHE_KEY)
|
||||
# Application set a custom unique directory name
|
||||
set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${CPM_ARGS_CUSTOM_CACHE_KEY})
|
||||
elseif(CPM_USE_NAMED_CACHE_DIRECTORIES)
|
||||
string(SHA1 origin_hash "${origin_parameters};NEW_CACHE_STRUCTURE_TAG")
|
||||
set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${origin_hash}/${CPM_ARGS_NAME})
|
||||
else()
|
||||
@ -798,14 +865,38 @@ function(CPMAddPackage)
|
||||
)
|
||||
|
||||
if(NOT CPM_SKIP_FETCH)
|
||||
# CMake 3.28 added EXCLUDE, SYSTEM (3.25), and SOURCE_SUBDIR (3.18) to FetchContent_Declare.
|
||||
# Calling FetchContent_MakeAvailable will then internally forward these options to
|
||||
# add_subdirectory. Up until these changes, we had to call FetchContent_Populate and
|
||||
# add_subdirectory separately, which is no longer necessary and has been deprecated as of 3.30.
|
||||
set(fetchContentDeclareExtraArgs "")
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.28.0")
|
||||
if(${CPM_ARGS_EXCLUDE_FROM_ALL})
|
||||
list(APPEND fetchContentDeclareExtraArgs EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
if(${CPM_ARGS_SYSTEM})
|
||||
list(APPEND fetchContentDeclareExtraArgs SYSTEM)
|
||||
endif()
|
||||
if(DEFINED CPM_ARGS_SOURCE_SUBDIR)
|
||||
list(APPEND fetchContentDeclareExtraArgs SOURCE_SUBDIR ${CPM_ARGS_SOURCE_SUBDIR})
|
||||
endif()
|
||||
# For CMake version <3.28 OPTIONS are parsed in cpm_add_subdirectory
|
||||
if(CPM_ARGS_OPTIONS AND NOT DOWNLOAD_ONLY)
|
||||
foreach(OPTION ${CPM_ARGS_OPTIONS})
|
||||
cpm_parse_option("${OPTION}")
|
||||
set(${OPTION_KEY} "${OPTION_VALUE}")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
cpm_declare_fetch(
|
||||
"${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}" "${PACKAGE_INFO}" "${CPM_ARGS_UNPARSED_ARGUMENTS}"
|
||||
"${CPM_ARGS_NAME}" ${fetchContentDeclareExtraArgs} "${CPM_ARGS_UNPARSED_ARGUMENTS}"
|
||||
)
|
||||
cpm_fetch_package("${CPM_ARGS_NAME}" populated)
|
||||
|
||||
cpm_fetch_package("${CPM_ARGS_NAME}" ${DOWNLOAD_ONLY} populated ${CPM_ARGS_UNPARSED_ARGUMENTS})
|
||||
if(CPM_SOURCE_CACHE AND download_directory)
|
||||
file(LOCK ${download_directory}/../cmake.lock RELEASE)
|
||||
endif()
|
||||
if(${populated})
|
||||
if(${populated} AND ${CMAKE_VERSION} VERSION_LESS "3.28.0")
|
||||
cpm_add_subdirectory(
|
||||
"${CPM_ARGS_NAME}"
|
||||
"${DOWNLOAD_ONLY}"
|
||||
@ -916,7 +1007,7 @@ function(CPMGetPackageVersion PACKAGE OUTPUT)
|
||||
endfunction()
|
||||
|
||||
# declares a package in FetchContent_Declare
|
||||
function(cpm_declare_fetch PACKAGE VERSION INFO)
|
||||
function(cpm_declare_fetch PACKAGE)
|
||||
if(${CPM_DRY_RUN})
|
||||
cpm_message(STATUS "${CPM_INDENT} Package not declared (dry run)")
|
||||
return()
|
||||
@ -992,7 +1083,7 @@ endfunction()
|
||||
|
||||
# downloads a previously declared package via FetchContent and exports the variables
|
||||
# `${PACKAGE}_SOURCE_DIR` and `${PACKAGE}_BINARY_DIR` to the parent scope
|
||||
function(cpm_fetch_package PACKAGE populated)
|
||||
function(cpm_fetch_package PACKAGE DOWNLOAD_ONLY populated)
|
||||
set(${populated}
|
||||
FALSE
|
||||
PARENT_SCOPE
|
||||
@ -1007,7 +1098,24 @@ function(cpm_fetch_package PACKAGE populated)
|
||||
string(TOLOWER "${PACKAGE}" lower_case_name)
|
||||
|
||||
if(NOT ${lower_case_name}_POPULATED)
|
||||
FetchContent_Populate(${PACKAGE})
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.28.0")
|
||||
if(DOWNLOAD_ONLY)
|
||||
# MakeAvailable will call add_subdirectory internally which is not what we want when
|
||||
# DOWNLOAD_ONLY is set. Populate will only download the dependency without adding it to the
|
||||
# build
|
||||
FetchContent_Populate(
|
||||
${PACKAGE}
|
||||
SOURCE_DIR "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-src"
|
||||
BINARY_DIR "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-build"
|
||||
SUBBUILD_DIR "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild"
|
||||
${ARGN}
|
||||
)
|
||||
else()
|
||||
FetchContent_MakeAvailable(${PACKAGE})
|
||||
endif()
|
||||
else()
|
||||
FetchContent_Populate(${PACKAGE})
|
||||
endif()
|
||||
set(${populated}
|
||||
TRUE
|
||||
PARENT_SCOPE
|
||||
|
@ -42,7 +42,7 @@ if(EMSCRIPTEN)
|
||||
add_link_options(-pthread)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT EMSCRIPTEN)
|
||||
find_program(MOLD_LINKER mold)
|
||||
if(MOLD_LINKER)
|
||||
set(CMAKE_LINKER_TYPE "MOLD")
|
||||
|
@ -24,7 +24,7 @@ else()
|
||||
CPMAddPackage(
|
||||
NAME capstone
|
||||
GITHUB_REPOSITORY capstone-engine/capstone
|
||||
GIT_TAG 5.0.1
|
||||
GIT_TAG 5.0.3
|
||||
)
|
||||
add_library(TracyCapstone INTERFACE)
|
||||
target_include_directories(TracyCapstone INTERFACE ${capstone_SOURCE_DIR}/include/capstone)
|
||||
|
@ -308,7 +308,7 @@ struct ThreadHandleWrapper
|
||||
static inline void CpuId( uint32_t* regs, uint32_t leaf )
|
||||
{
|
||||
memset(regs, 0, sizeof(uint32_t) * 4);
|
||||
#if defined _WIN32
|
||||
#if defined _MSC_VER
|
||||
__cpuidex( (int*)regs, leaf, 0 );
|
||||
#else
|
||||
__get_cpuid( leaf, regs, regs+1, regs+2, regs+3 );
|
||||
@ -3474,7 +3474,22 @@ bool Profiler::HandleServerQuery()
|
||||
}
|
||||
else
|
||||
{
|
||||
SendString( ptr, GetThreadName( (uint32_t)ptr ), QueueType::ThreadName );
|
||||
auto t = GetThreadNameData( (uint32_t)ptr );
|
||||
if( t )
|
||||
{
|
||||
SendString( ptr, t->name, QueueType::ThreadName );
|
||||
if( t->groupHint != 0 )
|
||||
{
|
||||
TracyLfqPrepare( QueueType::ThreadGroupHint );
|
||||
MemWrite( &item->threadGroupHint.thread, (uint32_t)ptr );
|
||||
MemWrite( &item->threadGroupHint.groupHint, t->groupHint );
|
||||
TracyLfqCommit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendString( ptr, GetThreadName( (uint32_t)ptr ), QueueType::ThreadName );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ServerQuerySourceLocation:
|
||||
@ -3712,6 +3727,7 @@ void Profiler::ReportTopology()
|
||||
struct CpuData
|
||||
{
|
||||
uint32_t package;
|
||||
uint32_t die;
|
||||
uint32_t core;
|
||||
uint32_t thread;
|
||||
};
|
||||
@ -3741,6 +3757,7 @@ void Profiler::ReportTopology()
|
||||
const uint32_t numcpus = sysinfo.dwNumberOfProcessors;
|
||||
|
||||
auto cpuData = (CpuData*)tracy_malloc( sizeof( CpuData ) * numcpus );
|
||||
memset( cpuData, 0, sizeof( CpuData ) * numcpus );
|
||||
for( uint32_t i=0; i<numcpus; i++ ) cpuData[i].thread = i;
|
||||
|
||||
int idx = 0;
|
||||
@ -3785,6 +3802,7 @@ void Profiler::ReportTopology()
|
||||
|
||||
TracyLfqPrepare( QueueType::CpuTopology );
|
||||
MemWrite( &item->cpuTopology.package, data.package );
|
||||
MemWrite( &item->cpuTopology.die, data.die );
|
||||
MemWrite( &item->cpuTopology.core, data.core );
|
||||
MemWrite( &item->cpuTopology.thread, data.thread );
|
||||
|
||||
@ -3834,6 +3852,7 @@ void Profiler::ReportTopology()
|
||||
|
||||
TracyLfqPrepare( QueueType::CpuTopology );
|
||||
MemWrite( &item->cpuTopology.package, data.package );
|
||||
MemWrite( &item->cpuTopology.die, data.die );
|
||||
MemWrite( &item->cpuTopology.core, data.core );
|
||||
MemWrite( &item->cpuTopology.thread, data.thread );
|
||||
|
||||
@ -4709,7 +4728,7 @@ TRACY_API int ___tracy_connected( void )
|
||||
}
|
||||
|
||||
#ifdef TRACY_FIBERS
|
||||
TRACY_API void ___tracy_fiber_enter( const char* fiber ){ tracy::Profiler::EnterFiber( fiber ); }
|
||||
TRACY_API void ___tracy_fiber_enter( const char* fiber ){ tracy::Profiler::EnterFiber( fiber, 0 ); }
|
||||
TRACY_API void ___tracy_fiber_leave( void ){ tracy::Profiler::LeaveFiber(); }
|
||||
#endif
|
||||
|
||||
|
@ -675,11 +675,12 @@ public:
|
||||
}
|
||||
|
||||
#ifdef TRACY_FIBERS
|
||||
static tracy_force_inline void EnterFiber( const char* fiber )
|
||||
static tracy_force_inline void EnterFiber( const char* fiber, int32_t groupHint )
|
||||
{
|
||||
TracyQueuePrepare( QueueType::FiberEnter );
|
||||
MemWrite( &item->fiberEnter.time, GetTime() );
|
||||
MemWrite( &item->fiberEnter.fiber, (uint64_t)fiber );
|
||||
MemWrite( &item->fiberEnter.groupHint, groupHint );
|
||||
TracyQueueCommit( fiberEnter );
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
TracyQueueCommit( zoneTextFatThread );
|
||||
}
|
||||
|
||||
tracy_force_inline void TextFmt( const char* fmt, ... )
|
||||
void TextFmt( const char* fmt, ... )
|
||||
{
|
||||
if( !m_active ) return;
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
@ -165,7 +165,7 @@ public:
|
||||
TracyQueueCommit( zoneTextFatThread );
|
||||
}
|
||||
|
||||
tracy_force_inline void NameFmt( const char* fmt, ... )
|
||||
void NameFmt( const char* fmt, ... )
|
||||
{
|
||||
if( !m_active ) return;
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
|
@ -16,16 +16,25 @@
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
static constexpr int GetSamplingFrequency()
|
||||
static int GetSamplingFrequency()
|
||||
{
|
||||
int samplingHz = TRACY_SAMPLING_HZ;
|
||||
|
||||
auto env = GetEnvVar( "TRACY_SAMPLING_HZ" );
|
||||
if( env )
|
||||
{
|
||||
int val = atoi( env );
|
||||
if( val > 0 ) samplingHz = val;
|
||||
}
|
||||
|
||||
#if defined _WIN32
|
||||
return TRACY_SAMPLING_HZ > 8000 ? 8000 : ( TRACY_SAMPLING_HZ < 1 ? 1 : TRACY_SAMPLING_HZ );
|
||||
return samplingHz > 8000 ? 8000 : ( samplingHz < 1 ? 1 : samplingHz );
|
||||
#else
|
||||
return TRACY_SAMPLING_HZ > 1000000 ? 1000000 : ( TRACY_SAMPLING_HZ < 1 ? 1 : TRACY_SAMPLING_HZ );
|
||||
return samplingHz > 1000000 ? 1000000 : ( samplingHz < 1 ? 1 : samplingHz );
|
||||
#endif
|
||||
}
|
||||
|
||||
static constexpr int GetSamplingPeriod()
|
||||
static int GetSamplingPeriod()
|
||||
{
|
||||
return 1000000000 / GetSamplingFrequency();
|
||||
}
|
||||
@ -321,7 +330,7 @@ static void SetupVsync()
|
||||
#endif
|
||||
}
|
||||
|
||||
static constexpr int GetSamplingInterval()
|
||||
static int GetSamplingInterval()
|
||||
{
|
||||
return GetSamplingPeriod() / 100;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace tracy
|
||||
|
||||
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
||||
|
||||
enum : uint32_t { ProtocolVersion = 66 };
|
||||
enum : uint32_t { ProtocolVersion = 69 };
|
||||
enum : uint16_t { BroadcastVersion = 3 };
|
||||
|
||||
using lz4sz_t = uint32_t;
|
||||
|
@ -108,6 +108,7 @@ enum class QueueType : uint8_t
|
||||
SingleStringData,
|
||||
SecondStringData,
|
||||
MemNamePayload,
|
||||
ThreadGroupHint,
|
||||
StringData,
|
||||
ThreadName,
|
||||
PlotName,
|
||||
@ -259,6 +260,7 @@ struct QueueFiberEnter
|
||||
int64_t time;
|
||||
uint64_t fiber; // ptr
|
||||
uint32_t thread;
|
||||
int32_t groupHint;
|
||||
};
|
||||
|
||||
struct QueueFiberLeave
|
||||
@ -477,6 +479,12 @@ struct QueueMemNamePayload
|
||||
uint64_t name;
|
||||
};
|
||||
|
||||
struct QueueThreadGroupHint
|
||||
{
|
||||
uint32_t thread;
|
||||
int32_t groupHint;
|
||||
};
|
||||
|
||||
struct QueueMemAlloc
|
||||
{
|
||||
int64_t time;
|
||||
@ -639,6 +647,7 @@ struct QueueSourceCodeNotAvailable
|
||||
struct QueueCpuTopology
|
||||
{
|
||||
uint32_t package;
|
||||
uint32_t die;
|
||||
uint32_t core;
|
||||
uint32_t thread;
|
||||
};
|
||||
@ -732,6 +741,7 @@ struct QueueItem
|
||||
QueueMemAlloc memAlloc;
|
||||
QueueMemFree memFree;
|
||||
QueueMemNamePayload memName;
|
||||
QueueThreadGroupHint threadGroupHint;
|
||||
QueueCallstackFat callstackFat;
|
||||
QueueCallstackFatThread callstackFatThread;
|
||||
QueueCallstackAllocFat callstackAllocFat;
|
||||
@ -868,6 +878,7 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ), // single string data
|
||||
sizeof( QueueHeader ), // second string data
|
||||
sizeof( QueueHeader ) + sizeof( QueueMemNamePayload ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueThreadGroupHint ),
|
||||
// keep all QueueStringTransfer below
|
||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // string data
|
||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // thread name
|
||||
|
@ -101,12 +101,6 @@ TRACY_API uint32_t GetThreadHandleImpl()
|
||||
}
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
struct ThreadNameData
|
||||
{
|
||||
uint32_t id;
|
||||
const char* name;
|
||||
ThreadNameData* next;
|
||||
};
|
||||
std::atomic<ThreadNameData*>& GetThreadNameData();
|
||||
#endif
|
||||
|
||||
@ -134,6 +128,11 @@ void ThreadNameMsvcMagic( const THREADNAME_INFO& info )
|
||||
#endif
|
||||
|
||||
TRACY_API void SetThreadName( const char* name )
|
||||
{
|
||||
SetThreadNameWithHint( name, 0 );
|
||||
}
|
||||
|
||||
TRACY_API void SetThreadNameWithHint( const char* name, int32_t groupHint )
|
||||
{
|
||||
#if defined _WIN32
|
||||
# ifdef TRACY_UWP
|
||||
@ -205,6 +204,7 @@ TRACY_API void SetThreadName( const char* name )
|
||||
buf[sz] = '\0';
|
||||
auto data = (ThreadNameData*)tracy_malloc_fast( sizeof( ThreadNameData ) );
|
||||
data->id = detail::GetThreadHandleImpl();
|
||||
data->groupHint = groupHint;
|
||||
data->name = buf;
|
||||
data->next = GetThreadNameData().load( std::memory_order_relaxed );
|
||||
while( !GetThreadNameData().compare_exchange_weak( data->next, data, std::memory_order_release, std::memory_order_relaxed ) ) {}
|
||||
@ -212,6 +212,22 @@ TRACY_API void SetThreadName( const char* name )
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
ThreadNameData* GetThreadNameData( uint32_t id )
|
||||
{
|
||||
auto ptr = GetThreadNameData().load( std::memory_order_relaxed );
|
||||
while( ptr )
|
||||
{
|
||||
if( ptr->id == id )
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
TRACY_API const char* GetThreadName( uint32_t id )
|
||||
{
|
||||
static char buf[256];
|
||||
|
@ -14,6 +14,16 @@ TRACY_API uint32_t GetThreadHandleImpl();
|
||||
}
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
struct ThreadNameData
|
||||
{
|
||||
uint32_t id;
|
||||
int32_t groupHint;
|
||||
const char* name;
|
||||
ThreadNameData* next;
|
||||
};
|
||||
|
||||
ThreadNameData* GetThreadNameData( uint32_t id );
|
||||
|
||||
TRACY_API uint32_t GetThreadHandle();
|
||||
#else
|
||||
static inline uint32_t GetThreadHandle()
|
||||
@ -23,6 +33,7 @@ static inline uint32_t GetThreadHandle()
|
||||
#endif
|
||||
|
||||
TRACY_API void SetThreadName( const char* name );
|
||||
TRACY_API void SetThreadNameWithHint( const char* name, int32_t groupHint );
|
||||
TRACY_API const char* GetThreadName( uint32_t id );
|
||||
|
||||
TRACY_API const char* GetEnvVar( const char* name );
|
||||
|
@ -7,7 +7,7 @@ namespace Version
|
||||
{
|
||||
enum { Major = 0 };
|
||||
enum { Minor = 11 };
|
||||
enum { Patch = 0 };
|
||||
enum { Patch = 1 };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@
|
||||
#define TracySetProgramName(x)
|
||||
|
||||
#define TracyFiberEnter(x)
|
||||
#define TracyFiberEnterHint(x,y)
|
||||
#define TracyFiberLeave
|
||||
|
||||
#else
|
||||
@ -139,6 +140,7 @@
|
||||
|
||||
# define ZoneTransient( varname, active ) tracy::ScopedZone varname( TracyLine, TracyFile, strlen( TracyFile ), TracyFunction, strlen( TracyFunction ), nullptr, 0, TRACY_CALLSTACK, active )
|
||||
# define ZoneTransientN( varname, name, active ) tracy::ScopedZone varname( TracyLine, TracyFile, strlen( TracyFile ), TracyFunction, strlen( TracyFunction ), name, strlen( name ), TRACY_CALLSTACK, active )
|
||||
# define ZoneTransientNC( varname, name, color, active ) tracy::ScopedZone varname( TracyLine, TracyFile, strlen( TracyFile ), TracyFunction, strlen( TracyFunction ), name, strlen( name ), color, TRACY_CALLSTACK, active )
|
||||
#else
|
||||
# define ZoneNamed( varname, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,TracyLine) { nullptr, TracyFunction, TracyFile, (uint32_t)TracyLine, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,TracyLine), active )
|
||||
# define ZoneNamedN( varname, name, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location,TracyLine) { name, TracyFunction, TracyFile, (uint32_t)TracyLine, 0 }; tracy::ScopedZone varname( &TracyConcat(__tracy_source_location,TracyLine), active )
|
||||
@ -147,6 +149,7 @@
|
||||
|
||||
# define ZoneTransient( varname, active ) tracy::ScopedZone varname( TracyLine, TracyFile, strlen( TracyFile ), TracyFunction, strlen( TracyFunction ), nullptr, 0, active )
|
||||
# define ZoneTransientN( varname, name, active ) tracy::ScopedZone varname( TracyLine, TracyFile, strlen( TracyFile ), TracyFunction, strlen( TracyFunction ), name, strlen( name ), active )
|
||||
# define ZoneTransientNC( varname, name, color, active ) tracy::ScopedZone varname( TracyLine, TracyFile, strlen( TracyFile ), TracyFunction, strlen( TracyFunction ), name, strlen( name ), color, active )
|
||||
#endif
|
||||
|
||||
#define ZoneScoped ZoneNamed( ___tracy_scoped_zone, true )
|
||||
@ -287,7 +290,8 @@
|
||||
#define TracySetProgramName( name ) tracy::GetProfiler().SetProgramName( name );
|
||||
|
||||
#ifdef TRACY_FIBERS
|
||||
# define TracyFiberEnter( fiber ) tracy::Profiler::EnterFiber( fiber )
|
||||
# define TracyFiberEnter( fiber ) tracy::Profiler::EnterFiber( fiber, 0 )
|
||||
# define TracyFiberEnterHint( fiber, groupHint ) tracy::Profiler::EnterFiber( fiber, groupHint )
|
||||
# define TracyFiberLeave tracy::Profiler::LeaveFiber()
|
||||
#endif
|
||||
|
||||
|
@ -188,6 +188,13 @@ static tracy_force_inline void SendLuaCallstack( lua_State* L, uint32_t depth )
|
||||
TracyQueueCommit( callstackAllocFatThread );
|
||||
}
|
||||
|
||||
static inline void LuaShortenSrc( char* dst, const char* src )
|
||||
{
|
||||
size_t l = std::min( (size_t)255, strlen( src ) );
|
||||
memcpy( dst, src, l );
|
||||
dst[l] = 0;
|
||||
}
|
||||
|
||||
static inline int LuaZoneBeginS( lua_State* L )
|
||||
{
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
@ -207,7 +214,9 @@ static inline int LuaZoneBeginS( lua_State* L )
|
||||
lua_Debug dbg;
|
||||
lua_getstack( L, 1, &dbg );
|
||||
lua_getinfo( L, "Snl", &dbg );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src );
|
||||
char src[256];
|
||||
LuaShortenSrc( src, dbg.source );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, src, dbg.name ? dbg.name : dbg.short_src );
|
||||
|
||||
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
@ -237,8 +246,10 @@ static inline int LuaZoneBeginNS( lua_State* L )
|
||||
lua_getstack( L, 1, &dbg );
|
||||
lua_getinfo( L, "Snl", &dbg );
|
||||
size_t nsz;
|
||||
char src[256];
|
||||
LuaShortenSrc( src, dbg.source );
|
||||
const auto name = lua_tolstring( L, 1, &nsz );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src, name, nsz );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, src, dbg.name ? dbg.name : dbg.short_src, name, nsz );
|
||||
|
||||
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
@ -264,7 +275,9 @@ static inline int LuaZoneBegin( lua_State* L )
|
||||
lua_Debug dbg;
|
||||
lua_getstack( L, 1, &dbg );
|
||||
lua_getinfo( L, "Snl", &dbg );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src );
|
||||
char src[256];
|
||||
LuaShortenSrc( src, dbg.source );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, src, dbg.name ? dbg.name : dbg.short_src );
|
||||
|
||||
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLoc );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
@ -290,8 +303,10 @@ static inline int LuaZoneBeginN( lua_State* L )
|
||||
lua_getstack( L, 1, &dbg );
|
||||
lua_getinfo( L, "Snl", &dbg );
|
||||
size_t nsz;
|
||||
char src[256];
|
||||
LuaShortenSrc( src, dbg.source );
|
||||
const auto name = lua_tolstring( L, 1, &nsz );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, dbg.source, dbg.name ? dbg.name : dbg.short_src, name, nsz );
|
||||
const auto srcloc = Profiler::AllocSourceLocation( dbg.currentline, src, dbg.name ? dbg.name : dbg.short_src, name, nsz );
|
||||
|
||||
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLoc );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
|
Loading…
Reference in New Issue
Block a user