├── python ├── .gitignore ├── tracy_client │ ├── py.typed │ ├── __init__.py │ └── tracy.py ├── pyproject.toml ├── CMakeLists.txt └── bindings │ └── NameBuffer.hpp ├── .github ├── FUNDING.yml ├── sponsor.png └── workflows │ ├── latex.yml │ └── emscripten.yml ├── examples ├── ToyPathTracer │ ├── .gitignore │ ├── README │ ├── Windows │ │ ├── VertexShader.hlsl │ │ ├── PixelShader.hlsl │ │ ├── TestCpu.sln │ │ └── TestCpu.vcxproj.filters │ ├── Source │ │ ├── Test.h │ │ └── Config.h │ └── license.md ├── OpenCLVectorAdd │ └── CMakeLists.txt └── fibers.cpp ├── icon ├── icon.ico ├── icon.pdf ├── icon.png ├── application-tracy.copying ├── icon.svg └── application-tracy.svg ├── test ├── image.jpg └── CMakeLists.txt ├── doc ├── profiler.png ├── profiler2.png └── profiler3.png ├── extra ├── zigzag01.png ├── zigzag02.png ├── zigzag04.png ├── zigzag08.png ├── zigzag16.png ├── zigzag32.png ├── version.cpp ├── desktop │ ├── tracy.desktop │ └── application-tracy.xml ├── dxt1divtable.c ├── update-meson-version.sh ├── rdotbl.c ├── dxt1table.c ├── uarch │ └── TracyMicroArchitecture.hpp ├── x11_colors.c ├── make-build.sh ├── identify.cpp ├── color-hot.cpp ├── color.cpp └── zigzag.svg ├── manual ├── icons │ ├── lmb.pdf │ ├── mmb.pdf │ ├── rmb.pdf │ └── scroll.pdf ├── images │ ├── ryzen.png │ ├── screenshot-hi.png │ └── screenshot-lo.png ├── filter.lua ├── latex2md.sh └── tracy.bib ├── profiler ├── win32 │ ├── Tracy.rc │ └── Tracy.manifest ├── src │ ├── font │ │ ├── Roboto-Bold.ttf │ │ ├── FiraCode-Retina.ttf │ │ ├── Roboto-Italic.ttf │ │ ├── Roboto-Regular.ttf │ │ ├── Roboto-BoldItalic.ttf │ │ └── Font Awesome 6 Free-Solid-900.otf │ ├── IsElevated.hpp │ ├── profiler │ │ ├── TracyWeb.hpp │ │ ├── TracyEventDebug.hpp │ │ ├── TracyProtoHistory.hpp │ │ ├── TracyStorage.hpp │ │ ├── TracyEmbed.cpp │ │ ├── TracyMarkdown.hpp │ │ ├── TracyTimelineContext.hpp │ │ ├── TracyFileselector.hpp │ │ ├── TracyFilesystem.hpp │ │ ├── TracyMouse.hpp │ │ ├── TracyEmbed.hpp │ │ ├── TracyFilesystem.cpp │ │ ├── TracyTexture.hpp │ │ ├── TracyLockHelpers.hpp │ │ ├── TracyWeb.cpp │ │ ├── TracyBadVersion.hpp │ │ ├── TracyBuzzAnim.hpp │ │ ├── TracyMicroArchitecture.hpp │ │ ├── TracyLlmEmbeddings.hpp │ │ ├── TracyManualData.hpp │ │ ├── TracyColor.cpp │ │ ├── TracyDecayValue.hpp │ │ ├── TracyUtility.hpp │ │ ├── TracyProtoHistory.cpp │ │ ├── TracyTimelineItemGpu.hpp │ │ ├── TracyLlmChat.hpp │ │ ├── TracySourceContents.hpp │ │ ├── TracyTimelineItemPlot.hpp │ │ ├── TracyUserData.hpp │ │ ├── TracyConfig.hpp │ │ ├── TracyTimelineItemCpuData.hpp │ │ ├── TracyLlmApi.hpp │ │ ├── TracySourceTokenizer.hpp │ │ ├── TracyAchievements.hpp │ │ ├── TracyColor.hpp │ │ ├── TracyTimelineController.hpp │ │ ├── TracyTimelineDraw.hpp │ │ ├── TracyViewData.hpp │ │ ├── TracyTimelineItem.hpp │ │ ├── TracyLlmTools.hpp │ │ ├── TracyLlm.hpp │ │ ├── TracyMouse.cpp │ │ └── TracyTimelineItemThread.hpp │ ├── HttpRequest.hpp │ ├── llm │ │ └── system.reminder.md │ ├── ImGuiContext.hpp │ ├── WindowPosition.hpp │ ├── winmainArchDiscovery.cpp │ ├── Fonts.hpp │ ├── RunQueue.hpp │ ├── Filters.hpp │ ├── zigzag01.hpp │ ├── zigzag02.hpp │ ├── ImGuiContext.cpp │ ├── zigzag04.hpp │ ├── ini.h │ ├── RunQueue.cpp │ ├── IsElevated.cpp │ ├── Backend.hpp │ ├── zigzag08.hpp │ ├── ConnectionHistory.hpp │ ├── ResolvService.hpp │ ├── zigzag16.hpp │ ├── zigzag32.hpp │ ├── WindowPosition.cpp │ ├── ResolvService.cpp │ ├── winmain.cpp │ ├── Filters.cpp │ └── ConnectionHistory.cpp ├── helpers │ ├── CMakeLists.txt │ └── embed.cpp └── wasm │ └── httpd.py ├── .mailmap ├── server ├── TracyMemory.cpp ├── TracySort.hpp ├── TracySysUtil.hpp ├── TracyMemory.hpp ├── TracyFileMeta.hpp ├── TracyMmap.hpp ├── TracyFileHeader.hpp ├── TracyTaskDispatch.hpp ├── TracySysUtil.cpp ├── TracyMmap.cpp ├── TracyPopcnt.hpp ├── TracyCharUtil.hpp ├── TracyThreadCompress.hpp ├── TracyThreadCompress.cpp ├── TracyTextureCompression.hpp ├── TracyTaskDispatch.cpp ├── TracyShortPtr.hpp ├── TracyStringDiscovery.hpp └── TracyVarArray.hpp ├── Config.cmake.in ├── .vscode ├── extensions.json ├── launch.json └── settings.json ├── public ├── client │ ├── TracyDxt1.hpp │ ├── TracyDebug.hpp │ ├── TracyCpuid.hpp │ ├── TracySysTime.hpp │ ├── TracyKCore.hpp │ ├── TracyOverride.cpp │ ├── TracySysTrace.hpp │ ├── TracySysPower.hpp │ ├── TracyStringHelpers.hpp │ ├── TracyCallstack.h │ ├── TracyAlloc.cpp │ └── TracyThread.hpp ├── common │ ├── TracyVersion.hpp │ ├── TracyMutex.hpp │ ├── TracyApi.h │ ├── TracyStackFrames.hpp │ ├── TracyWinFamily.hpp │ ├── TracyAlign.hpp │ ├── TracyForceInline.hpp │ ├── TracyYield.hpp │ ├── TracySystem.hpp │ └── TracyAlloc.hpp ├── libbacktrace │ ├── config.h │ ├── LICENSE │ ├── filenames.hpp │ └── state.cpp └── TracyClient.cpp ├── cmake ├── gl3w-extra-symbols.patch ├── ppqsort-nodebug.patch ├── imgui-emscripten.patch ├── version.cmake ├── server.cmake ├── tidy-cmake.patch └── config.cmake ├── .gitignore ├── csvexport └── CMakeLists.txt ├── capture └── CMakeLists.txt ├── update ├── CMakeLists.txt └── src │ └── OfflineSymbolResolver.h ├── import └── CMakeLists.txt ├── .clang-format ├── LICENSE ├── dtl ├── dtl.hpp ├── Lcs.hpp └── Sequence.hpp ├── README.md └── getopt └── getopt.h /python/.gitignore: -------------------------------------------------------------------------------- 1 | *.whl 2 | -------------------------------------------------------------------------------- /python/tracy_client/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: wolfpld 2 | -------------------------------------------------------------------------------- /examples/ToyPathTracer/.gitignore: -------------------------------------------------------------------------------- 1 | Windows/Compiled*Shader.h 2 | -------------------------------------------------------------------------------- /icon/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/icon/icon.ico -------------------------------------------------------------------------------- /icon/icon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/icon/icon.pdf -------------------------------------------------------------------------------- /icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/icon/icon.png -------------------------------------------------------------------------------- /test/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/test/image.jpg -------------------------------------------------------------------------------- /doc/profiler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/doc/profiler.png -------------------------------------------------------------------------------- /doc/profiler2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/doc/profiler2.png -------------------------------------------------------------------------------- /doc/profiler3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/doc/profiler3.png -------------------------------------------------------------------------------- /.github/sponsor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/.github/sponsor.png -------------------------------------------------------------------------------- /extra/zigzag01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/extra/zigzag01.png -------------------------------------------------------------------------------- /extra/zigzag02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/extra/zigzag02.png -------------------------------------------------------------------------------- /extra/zigzag04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/extra/zigzag04.png -------------------------------------------------------------------------------- /extra/zigzag08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/extra/zigzag08.png -------------------------------------------------------------------------------- /extra/zigzag16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/extra/zigzag16.png -------------------------------------------------------------------------------- /extra/zigzag32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/extra/zigzag32.png -------------------------------------------------------------------------------- /manual/icons/lmb.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/manual/icons/lmb.pdf -------------------------------------------------------------------------------- /manual/icons/mmb.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/manual/icons/mmb.pdf -------------------------------------------------------------------------------- /manual/icons/rmb.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/manual/icons/rmb.pdf -------------------------------------------------------------------------------- /manual/icons/scroll.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/manual/icons/scroll.pdf -------------------------------------------------------------------------------- /manual/images/ryzen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/manual/images/ryzen.png -------------------------------------------------------------------------------- /profiler/win32/Tracy.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON "../../icon/icon.ico" 2 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /python/tracy_client/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from tracy_client.tracy import * 4 | -------------------------------------------------------------------------------- /manual/images/screenshot-hi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/manual/images/screenshot-hi.png -------------------------------------------------------------------------------- /manual/images/screenshot-lo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/manual/images/screenshot-lo.png -------------------------------------------------------------------------------- /profiler/src/font/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/profiler/src/font/Roboto-Bold.ttf -------------------------------------------------------------------------------- /profiler/src/font/FiraCode-Retina.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/profiler/src/font/FiraCode-Retina.ttf -------------------------------------------------------------------------------- /profiler/src/font/Roboto-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/profiler/src/font/Roboto-Italic.ttf -------------------------------------------------------------------------------- /profiler/src/font/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/profiler/src/font/Roboto-Regular.ttf -------------------------------------------------------------------------------- /profiler/src/font/Roboto-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/profiler/src/font/Roboto-BoldItalic.ttf -------------------------------------------------------------------------------- /profiler/src/IsElevated.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __ISELEVATED_HPP__ 2 | #define __ISELEVATED_HPP__ 3 | 4 | bool IsElevated(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /server/TracyMemory.cpp: -------------------------------------------------------------------------------- 1 | #include "TracyMemory.hpp" 2 | 3 | namespace tracy 4 | { 5 | 6 | std::atomic memUsage( 0 ); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /manual/filter.lua: -------------------------------------------------------------------------------- 1 | function Link(el) 2 | el.attributes['reference-type'] = nil 3 | el.attributes['reference'] = nil 4 | return el 5 | end 6 | -------------------------------------------------------------------------------- /profiler/src/font/Font Awesome 6 Free-Solid-900.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfpld/tracy/HEAD/profiler/src/font/Font Awesome 6 Free-Solid-900.otf -------------------------------------------------------------------------------- /Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | find_dependency(Threads REQUIRED) 5 | 6 | include("${CMAKE_CURRENT_LIST_DIR}/TracyTargets.cmake") -------------------------------------------------------------------------------- /examples/ToyPathTracer/README: -------------------------------------------------------------------------------- 1 | https://github.com/aras-p/ToyPathTracer 2 | 3 | Modified to render only 10 frames. Client part requires 12 GB, server part 4 | requires 6.4 GB. 5 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "llvm-vs-code-extensions.vscode-clangd", 4 | "vadimcn.vscode-lldb", 5 | "ms-vscode.cmake-tools" 6 | ] 7 | } -------------------------------------------------------------------------------- /profiler/src/profiler/TracyWeb.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYWEB_HPP__ 2 | #define __TRACYWEB_HPP__ 3 | 4 | namespace tracy 5 | { 6 | 7 | void OpenWebpage( const char* url ); 8 | 9 | } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /server/TracySort.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSORT_HPP__ 2 | #define __TRACYSORT_HPP__ 3 | 4 | #ifdef __EMSCRIPTEN__ 5 | # include "tracy_pdqsort.h" 6 | #else 7 | # include 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /server/TracySysUtil.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSYSUTIL_HPP__ 2 | #define __TRACYSYSUTIL_HPP__ 3 | 4 | #include 5 | 6 | namespace tracy 7 | { 8 | 9 | size_t GetPhysicalMemorySize(); 10 | 11 | } 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /public/client/TracyDxt1.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYDXT1_HPP__ 2 | #define __TRACYDXT1_HPP__ 3 | 4 | namespace tracy 5 | { 6 | 7 | void CompressImageDxt1( const char* src, char* dst, int w, int h ); 8 | 9 | } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyEventDebug.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYEVENTDEBUG_HPP__ 2 | #define __TRACYEVENTDEBUG_HPP__ 3 | 4 | namespace tracy 5 | { 6 | struct QueueItem; 7 | void EventDebug( const QueueItem& ev ); 8 | } 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /server/TracyMemory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYMEMORY_HPP__ 2 | #define __TRACYMEMORY_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | namespace tracy 8 | { 9 | 10 | extern std::atomic memUsage; 11 | 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /profiler/src/HttpRequest.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __HTTPREQUEST_HPP__ 2 | #define __HTTPREQUEST_HPP__ 3 | 4 | #include 5 | 6 | void HttpRequest( const char* server, const char* resource, int port, const std::function& cb ); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /public/common/TracyVersion.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYVERSION_HPP__ 2 | #define __TRACYVERSION_HPP__ 3 | 4 | namespace tracy 5 | { 6 | namespace Version 7 | { 8 | enum { Major = 0 }; 9 | enum { Minor = 13 }; 10 | enum { Patch = 1 }; 11 | } 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /profiler/src/llm/system.reminder.md: -------------------------------------------------------------------------------- 1 | Remember your core principles: 2 | 1. Protect user's privacy. 3 | 2. Always prioritize tools for factual information. 4 | 3. Your internal knowledge is strictly secondary and a last resort. 5 | 4. Respond strictly in the user's language. 6 | -------------------------------------------------------------------------------- /public/client/TracyDebug.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYPRINT_HPP__ 2 | #define __TRACYPRINT_HPP__ 3 | 4 | #ifdef TRACY_VERBOSE 5 | # include 6 | # define TracyDebug(...) fprintf( stderr, __VA_ARGS__ ); 7 | #else 8 | # define TracyDebug(...) 9 | #endif 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /profiler/src/ImGuiContext.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __IMGUICONTEXT_HPP__ 2 | #define __IMGUICONTEXT_HPP__ 3 | 4 | #include 5 | 6 | class ImGuiTracyContext 7 | { 8 | public: 9 | ImGuiTracyContext(); 10 | ~ImGuiTracyContext(); 11 | 12 | private: 13 | std::string m_iniFilename; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /profiler/helpers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | set(CMAKE_CXX_STANDARD 20) 4 | 5 | project(helpers LANGUAGES CXX) 6 | 7 | add_executable(embed 8 | ../../public/common/tracy_lz4.cpp 9 | ../../public/common/tracy_lz4hc.cpp 10 | embed.cpp 11 | ) 12 | 13 | install(TARGETS embed DESTINATION .) -------------------------------------------------------------------------------- /cmake/gl3w-extra-symbols.patch: -------------------------------------------------------------------------------- 1 | diff --git a/extra_symbols.txt b/extra_symbols.txt 2 | index b95bb58..6b8f616 100644 3 | --- a/extra_symbols.txt 4 | +++ b/extra_symbols.txt 5 | @@ -1,3 +1,7 @@ 6 | +glCompressedTexImage2D 7 | +GL_LINEAR_MIPMAP_LINEAR 8 | +GL_TEXTURE_WRAP_S 9 | +GL_TEXTURE_WRAP_T 10 | glReadPixels 11 | glClearColor 12 | glClear 13 | -------------------------------------------------------------------------------- /examples/ToyPathTracer/Windows/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | struct vs2ps 2 | { 3 | float2 uv : TEXCOORD0; 4 | float4 pos : SV_Position; 5 | }; 6 | 7 | vs2ps main(uint vid : SV_VertexID) 8 | { 9 | vs2ps o; 10 | o.uv = float2((vid << 1) & 2, vid & 2); 11 | o.pos = float4(o.uv * float2(2, 2) + float2(-1, -1), 0, 1); 12 | return o; 13 | } 14 | -------------------------------------------------------------------------------- /extra/version.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../server/TracyFileHeader.hpp" 5 | #include "../public/common/TracyVersion.hpp" 6 | 7 | int main() 8 | { 9 | const auto ver = uint32_t( tracy::FileVersion( tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch ) ); 10 | fwrite( &ver, 1, 4, stdout ); 11 | } 12 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch", 6 | "type": "lldb", 7 | "request": "launch", 8 | "program": "${command:cmake.launchTargetPath}", 9 | "args": [], 10 | "cwd": "${workspaceFolder}" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /profiler/src/WindowPosition.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __WINDOWPOSITION_HPP__ 2 | #define __WINDOWPOSITION_HPP__ 3 | 4 | #include 5 | 6 | class WindowPosition 7 | { 8 | public: 9 | WindowPosition(); 10 | ~WindowPosition(); 11 | 12 | int x, y, w, h, maximize; 13 | 14 | private: 15 | void Defaults(); 16 | 17 | std::string m_fn; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /profiler/win32/Tracy.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UTF-8 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /profiler/src/winmainArchDiscovery.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _WIN32 2 | namespace tracy 3 | { 4 | bool DiscoveryAVX() 5 | { 6 | #ifdef __AVX__ 7 | return true; 8 | #else 9 | return false; 10 | #endif 11 | } 12 | 13 | bool DiscoveryAVX2() 14 | { 15 | #ifdef __AVX2__ 16 | return true; 17 | #else 18 | return false; 19 | #endif 20 | } 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /public/common/TracyMutex.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYMUTEX_HPP__ 2 | #define __TRACYMUTEX_HPP__ 3 | 4 | #if defined _MSC_VER 5 | 6 | # include 7 | 8 | namespace tracy 9 | { 10 | using TracyMutex = std::shared_mutex; 11 | } 12 | 13 | #else 14 | 15 | #include 16 | 17 | namespace tracy 18 | { 19 | using TracyMutex = std::mutex; 20 | } 21 | 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyProtoHistory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYPROTOHISTORY_HPP__ 2 | #define __TRACYPROTOHISTORY_HPP__ 3 | 4 | #include 5 | 6 | namespace tracy 7 | { 8 | 9 | struct ProtocolHistory_t 10 | { 11 | uint32_t protocol; 12 | uint32_t minVer; 13 | uint32_t maxVer; 14 | }; 15 | 16 | extern const ProtocolHistory_t* ProtocolHistory; 17 | 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /profiler/src/Fonts.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __FONTS_HPP__ 2 | #define __FONTS_HPP__ 3 | 4 | struct ImFont; 5 | 6 | struct FontData 7 | { 8 | ImFont* normal; 9 | ImFont* mono; 10 | ImFont* bold; 11 | ImFont* boldItalic; 12 | ImFont* italic; 13 | }; 14 | 15 | extern FontData g_fonts; 16 | extern float FontNormal, FontSmall, FontBig; 17 | 18 | void LoadFonts( float scale ); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyStorage.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSTORAGE_HPP__ 2 | #define __TRACYSTORAGE_HPP__ 3 | 4 | #include 5 | 6 | namespace tracy 7 | { 8 | 9 | const char* GetSavePath( const char* file ); 10 | const char* GetSavePath( const char* program, uint64_t time, const char* file, bool create ); 11 | 12 | const char* GetCachePath( const char* file ); 13 | 14 | } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /extra/desktop/tracy.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Tracy Profiler 5 | GenericName=Code profiler 6 | GenericName[pl]=Profiler kodu 7 | Comment=Examine code to see where it is slow 8 | Comment[pl]=Znajdowanie wolno wykonującego się kodu 9 | Exec=/usr/bin/tracy %f 10 | Icon=tracy 11 | Terminal=false 12 | Categories=Development;Profiling; 13 | MimeType=application/tracy; 14 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyEmbed.cpp: -------------------------------------------------------------------------------- 1 | #include "TracyEmbed.hpp" 2 | #include "../public/common/tracy_lz4.hpp" 3 | 4 | EmbedData::EmbedData( size_t size, size_t lz4Size, const uint8_t* data ) 5 | : m_data( new char[size] ) 6 | , m_size( size ) 7 | { 8 | tracy::LZ4_decompress_safe( (const char*)data, m_data, lz4Size, size ); 9 | } 10 | 11 | EmbedData::~EmbedData() 12 | { 13 | delete[] m_data; 14 | } 15 | -------------------------------------------------------------------------------- /cmake/ppqsort-nodebug.patch: -------------------------------------------------------------------------------- 1 | diff --git i/include/ppqsort/parameters.h w/include/ppqsort/parameters.h 2 | index 115c3a1..3f4b669 100644 3 | --- i/include/ppqsort/parameters.h 4 | +++ w/include/ppqsort/parameters.h 5 | @@ -3,7 +3,8 @@ 6 | #include 7 | #include 8 | 9 | -#ifndef NDEBUG 10 | +//#ifndef NDEBUG 11 | +#if 0 12 | #include 13 | #include 14 | #include 15 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyMarkdown.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYMARKDOWN_HPP__ 2 | #define __TRACYMARKDOWN_HPP__ 3 | 4 | #include 5 | 6 | struct MD_PARSER; 7 | 8 | namespace tracy 9 | { 10 | 11 | class Markdown 12 | { 13 | public: 14 | Markdown(); 15 | ~Markdown(); 16 | 17 | void Print( const char* str, size_t size ); 18 | 19 | private: 20 | MD_PARSER* m_parser; 21 | }; 22 | 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /public/common/TracyApi.h: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYAPI_H__ 2 | #define __TRACYAPI_H__ 3 | 4 | #if defined _WIN32 5 | # if defined TRACY_EXPORTS 6 | # define TRACY_API __declspec(dllexport) 7 | # elif defined TRACY_IMPORTS 8 | # define TRACY_API __declspec(dllimport) 9 | # else 10 | # define TRACY_API 11 | # endif 12 | #else 13 | # define TRACY_API __attribute__((visibility("default"))) 14 | #endif 15 | 16 | #endif // __TRACYAPI_H__ 17 | -------------------------------------------------------------------------------- /public/common/TracyStackFrames.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSTACKFRAMES_HPP__ 2 | #define __TRACYSTACKFRAMES_HPP__ 3 | 4 | #include 5 | 6 | namespace tracy 7 | { 8 | 9 | struct StringMatch 10 | { 11 | const char* str; 12 | size_t len; 13 | }; 14 | 15 | extern const char** s_tracyStackFrames; 16 | extern const StringMatch* s_tracySkipSubframes; 17 | 18 | static constexpr int s_tracySkipSubframesMinLen = 7; 19 | 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /server/TracyFileMeta.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYFILEMETA_HPP__ 2 | #define __TRACYFILEMETA_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../public/common/tracy_lz4.hpp" 9 | 10 | namespace tracy 11 | { 12 | 13 | constexpr size_t FileBufSize = 64 * 1024; 14 | constexpr size_t FileBoundSize = std::max( LZ4_COMPRESSBOUND( FileBufSize ), ZSTD_COMPRESSBOUND( FileBufSize ) ); 15 | 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /examples/ToyPathTracer/Windows/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | float3 LinearToSRGB(float3 rgb) 2 | { 3 | rgb = max(rgb, float3(0, 0, 0)); 4 | return max(1.055 * pow(rgb, 0.416666667) - 0.055, 0.0); 5 | } 6 | 7 | Texture2D tex : register(t0); 8 | SamplerState smp : register(s0); 9 | 10 | float4 main(float2 uv : TEXCOORD0) : SV_Target 11 | { 12 | float3 col = tex.Sample(smp, uv).rgb; 13 | col = LinearToSRGB(col); 14 | return float4(col, 1.0f); 15 | } 16 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyTimelineContext.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTIMELINECONTEXT_HPP__ 2 | #define __TRACYTIMELINECONTEXT_HPP__ 3 | 4 | #include 5 | 6 | #include "imgui.h" 7 | 8 | namespace tracy 9 | { 10 | 11 | struct TimelineContext 12 | { 13 | float w, ty, sty, scale; 14 | float yMin, yMax; 15 | double pxns, nspx; 16 | int64_t vStart, vEnd; 17 | ImVec2 wpos; 18 | bool hover; 19 | }; 20 | 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /server/TracyMmap.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYMMAP_HPP__ 2 | #define __TRACYMMAP_HPP__ 3 | 4 | #if !defined _WIN32 5 | # include 6 | #else 7 | # include 8 | # include 9 | 10 | # define PROT_READ 1 11 | # define PROT_WRITE 2 12 | # define MAP_SHARED 0 13 | 14 | void* mmap( void* addr, size_t length, int prot, int flags, int fd, off_t offset ); 15 | int munmap( void* addr, size_t length ); 16 | 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /public/common/TracyWinFamily.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYWINFAMILY_HPP__ 2 | #define __TRACYWINFAMILY_HPP__ 3 | 4 | #ifdef _WIN32 5 | # include 6 | # if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 7 | # define TRACY_WIN32_NO_DESKTOP 8 | # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES) 9 | # define TRACY_GDK 10 | # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 11 | # define TRACY_UWP 12 | # endif 13 | # endif 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyFileselector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYFILESELECTOR_HPP__ 2 | #define __TRACYFILESELECTOR_HPP__ 3 | 4 | #include 5 | 6 | namespace tracy::Fileselector 7 | { 8 | 9 | void Init(); 10 | void Shutdown(); 11 | bool HasFailed(); 12 | 13 | void OpenFile( const char* ext, const char* desc, const std::function& callback ); 14 | void SaveFile( const char* ext, const char* desc, const std::function& callback ); 15 | 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /profiler/src/RunQueue.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __RUNQUEUE_HPP__ 2 | #define __RUNQUEUE_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class RunQueue 10 | { 11 | public: 12 | RunQueue(); 13 | 14 | void Queue( const std::function& cb, bool forceDelay = false ); 15 | void Run(); 16 | 17 | private: 18 | std::vector> m_queue; 19 | std::mutex m_lock; 20 | std::thread::id m_mainThread; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /public/client/TracyCpuid.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYCPUID_HPP__ 2 | #define __TRACYCPUID_HPP__ 3 | 4 | // Prior to GCC 11 the cpuid.h header did not have any include guards and thus 5 | // including it more than once would cause a compiler error due to symbol 6 | // redefinitions. In order to support older GCC versions, we have to wrap this 7 | // include between custom include guards to prevent this issue. 8 | // See also https://github.com/wolfpld/tracy/issues/452 9 | 10 | #include 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /public/common/TracyAlign.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYALIGN_HPP__ 2 | #define __TRACYALIGN_HPP__ 3 | 4 | #include 5 | 6 | #include "TracyForceInline.hpp" 7 | 8 | namespace tracy 9 | { 10 | 11 | template 12 | tracy_force_inline T MemRead( const void* ptr ) 13 | { 14 | T val; 15 | memcpy( &val, ptr, sizeof( T ) ); 16 | return val; 17 | } 18 | 19 | template 20 | tracy_force_inline void MemWrite( void* ptr, T val ) 21 | { 22 | memcpy( ptr, &val, sizeof( T ) ); 23 | } 24 | 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyFilesystem.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYFILESYSTEM_HPP__ 2 | #define __TRACYFILESYSTEM_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | namespace tracy 8 | { 9 | 10 | class View; 11 | class Worker; 12 | 13 | static inline bool FileExists( const char* fn ) 14 | { 15 | struct stat buf; 16 | return stat( fn, &buf ) == 0 && ( buf.st_mode & S_IFREG ) != 0; 17 | } 18 | 19 | bool SourceFileValid( const char* fn, uint64_t olderThan, const View& view, const Worker& worker ); 20 | 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /.github/workflows/latex.yml: -------------------------------------------------------------------------------- 1 | name: Manual 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Compile LaTeX 17 | uses: xu-cheng/latex-action@v3 18 | with: 19 | working_directory: manual 20 | root_file: tracy.tex 21 | - uses: actions/upload-artifact@v4 22 | with: 23 | name: manual 24 | path: manual/tracy.pdf 25 | -------------------------------------------------------------------------------- /extra/dxt1divtable.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | for( int i=0; i<255*3+1; i++ ) 7 | { 8 | // replace 4 with 2 for ARM NEON table 9 | uint32_t range = ( 4 << 16 ) / ( 1+i ); 10 | if( range > 0xFFFF ) range = 0xFFFF; 11 | if( i % 16 == 15 ) 12 | { 13 | printf( "0x%04x,\n", range ); 14 | } 15 | else 16 | { 17 | printf( "0x%04x, ", range ); 18 | } 19 | } 20 | printf( "\n" ); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyMouse.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYMOUSE_HPP__ 2 | #define __TRACYMOUSE_HPP__ 3 | 4 | #include "imgui.h" 5 | 6 | namespace tracy 7 | { 8 | 9 | void MouseFrame(); 10 | 11 | bool IsMouseDown( ImGuiMouseButton button ); 12 | bool IsMouseClicked( ImGuiMouseButton button ); 13 | bool IsMouseDragging( ImGuiMouseButton button ); 14 | ImVec2 GetMouseDragDelta( ImGuiMouseButton button ); 15 | 16 | void ConsumeMouseEvents( ImGuiMouseButton button ); 17 | bool IsMouseClickReleased( ImGuiMouseButton button ); 18 | 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /profiler/src/Filters.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __FILTERS_HPP__ 2 | #define __FILTERS_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | class Filters 8 | { 9 | public: 10 | Filters(); 11 | ~Filters(); 12 | 13 | void Clear(); 14 | void Draw( float w ); 15 | 16 | bool IsActive() const; 17 | 18 | bool FailAddr( const char* addr ); 19 | bool FailPort( uint16_t port ); 20 | bool FailProg( const char* prog ); 21 | 22 | private: 23 | std::string m_fn; 24 | 25 | ImGuiTextFilter m_addrFilter, m_portFilter, m_progFilter; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /public/common/TracyForceInline.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYFORCEINLINE_HPP__ 2 | #define __TRACYFORCEINLINE_HPP__ 3 | 4 | #if defined(__GNUC__) 5 | # define tracy_force_inline __attribute__((always_inline)) inline 6 | #elif defined(_MSC_VER) 7 | # define tracy_force_inline __forceinline 8 | #else 9 | # define tracy_force_inline inline 10 | #endif 11 | 12 | #if defined(__GNUC__) 13 | # define tracy_no_inline __attribute__((noinline)) 14 | #elif defined(_MSC_VER) 15 | # define tracy_no_inline __declspec(noinline) 16 | #else 17 | # define tracy_no_inline 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /extra/update-meson-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | version_header="../public/common/TracyVersion.hpp" 4 | 5 | major=$(grep -o -E 'Major = [0-9]+' "$version_header" | awk -F '= ' '{print $2}') 6 | minor=$(grep -o -E 'Minor = [0-9]+' "$version_header" | awk -F '= ' '{print $2}') 7 | patch=$(grep -o -E 'Patch = [0-9]+' "$version_header" | awk -F '= ' '{print $2}') 8 | 9 | version="${major}.${minor}.${patch}" 10 | 11 | # the extension is required for macOS's outdated sed 12 | sed -i.bak "s/version: '[0-9]*\.[0-9]*\.[0-9]*'/version: '$version'/g" ../meson.build 13 | rm ../meson.build.bak 14 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyEmbed.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #define Unembed( name ) std::make_shared( Embed::name##Size, Embed::name##Lz4Size, Embed::name##Data ) 8 | 9 | class EmbedData 10 | { 11 | public: 12 | EmbedData( size_t size, size_t lz4Size, const uint8_t* data ); 13 | ~EmbedData(); 14 | 15 | [[nodiscard]] const char* data() const { return m_data; } 16 | [[nodiscard]] size_t size() const { return m_size; } 17 | 18 | private: 19 | char* m_data; 20 | size_t m_size; 21 | }; 22 | -------------------------------------------------------------------------------- /server/TracyFileHeader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYFILEHEADER_HPP__ 2 | #define __TRACYFILEHEADER_HPP__ 3 | 4 | #include 5 | 6 | #include "../public/common/TracyForceInline.hpp" 7 | 8 | namespace tracy 9 | { 10 | 11 | static const uint8_t TracyHeader[4] = { 't', 'r', 253, 'P' }; 12 | static const uint8_t Lz4Header[4] = { 't', 'l', 'Z', 4 }; 13 | static const uint8_t ZstdHeader[4] = { 't', 'Z', 's', 't' }; 14 | 15 | static constexpr tracy_force_inline int FileVersion( uint8_t h5, uint8_t h6, uint8_t h7 ) 16 | { 17 | return ( h5 << 16 ) | ( h6 << 8 ) | h7; 18 | } 19 | 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyFilesystem.cpp: -------------------------------------------------------------------------------- 1 | #include "TracyFilesystem.hpp" 2 | #include "TracyView.hpp" 3 | 4 | namespace tracy 5 | { 6 | 7 | bool SourceFileValid( const char* fn, uint64_t olderThan, const View& view, const Worker& worker ) 8 | { 9 | if( worker.GetSourceFileFromCache( fn ).data != nullptr ) return true; 10 | struct stat buf; 11 | if( stat( view.SourceSubstitution( fn ), &buf ) == 0 && ( buf.st_mode & S_IFREG ) != 0 ) 12 | { 13 | if(!view.ValidateSourceAge()) return true; 14 | return (uint64_t)buf.st_mtime < olderThan; 15 | } 16 | return false; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /public/client/TracySysTime.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSYSTIME_HPP__ 2 | #define __TRACYSYSTIME_HPP__ 3 | 4 | #if defined _WIN32 || defined __linux__ || defined __APPLE__ 5 | # define TRACY_HAS_SYSTIME 6 | #else 7 | # include 8 | #endif 9 | 10 | #ifdef BSD 11 | # define TRACY_HAS_SYSTIME 12 | #endif 13 | 14 | #ifdef TRACY_HAS_SYSTIME 15 | 16 | #include 17 | 18 | namespace tracy 19 | { 20 | 21 | class SysTime 22 | { 23 | public: 24 | SysTime(); 25 | float Get(); 26 | 27 | void ReadTimes(); 28 | 29 | private: 30 | uint64_t idle, used; 31 | }; 32 | 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /public/client/TracyKCore.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYKCORE_HPP__ 2 | #define __TRACYKCORE_HPP__ 3 | 4 | #ifdef __linux__ 5 | 6 | #include 7 | 8 | #include "TracyFastVector.hpp" 9 | 10 | namespace tracy 11 | { 12 | 13 | class KCore 14 | { 15 | struct Offset 16 | { 17 | uint64_t start; 18 | uint64_t size; 19 | uint64_t offset; 20 | }; 21 | 22 | public: 23 | KCore(); 24 | ~KCore(); 25 | 26 | void* Retrieve( uint64_t addr, uint64_t size ) const; 27 | 28 | private: 29 | int m_fd; 30 | FastVector m_offsets; 31 | }; 32 | 33 | } 34 | 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /profiler/src/zigzag01.hpp: -------------------------------------------------------------------------------- 1 | // File: 'zigzag01.png' (126 bytes) 2 | // Exported using binary_to_compressed_c.cpp 3 | static const unsigned int ZigZag01_size = 126; 4 | static const unsigned int ZigZag01_data[128/4] = 5 | { 6 | 0x474e5089, 0x0a1a0a0d, 0x0d000000, 0x52444849, 0x01000000, 0x01000000, 0x00000408, 0x0c1cb500, 0x00000002, 0x58457419, 0x666f5374, 0x72617774, 7 | 0x77770065, 0x6e692e77, 0x6163736b, 0x6f2e6570, 0xee9b6772, 0x00001a3c, 0x48700900, 0x00007359, 0x00007600, 0x4e017600, 0x0008267b, 0x490b0000, 8 | 0x78544144, 0xbff963da, 0xb802001a, 0x77afaf01, 0x0000dbd6, 0x45490000, 0x42ae444e, 0x00008260, 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyTexture.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTEXTURE_HPP__ 2 | #define __TRACYTEXTURE_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | namespace tracy 8 | { 9 | 10 | void InitTexture(); 11 | ImTextureID MakeTexture( bool zigzag = false ); 12 | void FreeTexture( ImTextureID tex, void(*runOnMainThread)(const std::function&, bool) ); 13 | void UpdateTexture( ImTextureID tex, const char* data, int w, int h ); 14 | void UpdateTextureRGBA( ImTextureID tex, void* data, int w, int h ); 15 | void UpdateTextureRGBAMips( ImTextureID tex, void** data, int* w, int* h, size_t mips ); 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /cmake/imgui-emscripten.patch: -------------------------------------------------------------------------------- 1 | diff '--color=auto' -ruN 72d8f61727dc878102157113d1998f86b852d20e/imconfig.h new/imconfig.h 2 | --- 72d8f61727dc878102157113d1998f86b852d20e/imconfig.h 2024-09-27 14:28:05.568760349 +0200 3 | +++ new/imconfig.h 2024-09-27 14:29:47.310243707 +0200 4 | @@ -113,6 +113,10 @@ 5 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 6 | //#define ImDrawIdx unsigned int 7 | 8 | +#ifdef __EMSCRIPTEN__ 9 | +#define ImDrawIdx unsigned int 10 | +#endif 11 | + 12 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 13 | //struct ImDrawList; 14 | //struct ImDrawCmd; 15 | -------------------------------------------------------------------------------- /extra/rdotbl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | //int a = 16, b = 44, s = 4; 6 | //int av = 12, bv = 6, cv = 3; 7 | 8 | //int a = 32, b = 48, s = 16; 9 | //int av = 12, bv = 6, cv = 3; 10 | 11 | int a = 48, b = 64, s = 16; 12 | int av = 48, bv = 32, cv = 24; 13 | 14 | printf( "int TrTbl[] = { " ); 15 | int first = 1; 16 | for( int i=0; i<256; i+=s ) 17 | { 18 | if( first ) first = 0; else printf( ", " ); 19 | if( i < a ) printf( "%i", av ); 20 | else if( i < b ) printf( "%i", bv ); 21 | else printf( "%i", cv ); 22 | } 23 | printf( " };\n" ); 24 | } 25 | -------------------------------------------------------------------------------- /public/client/TracyOverride.cpp: -------------------------------------------------------------------------------- 1 | #ifdef TRACY_ENABLE 2 | # ifdef __linux__ 3 | # include "TracyDebug.hpp" 4 | # ifdef TRACY_VERBOSE 5 | # include 6 | # include 7 | # endif 8 | 9 | extern "C" int dlclose( void* hnd ) 10 | { 11 | #ifdef TRACY_VERBOSE 12 | struct link_map* lm; 13 | if( dlinfo( hnd, RTLD_DI_LINKMAP, &lm ) == 0 ) 14 | { 15 | TracyDebug( "Overriding dlclose for %s\n", lm->l_name ); 16 | } 17 | else 18 | { 19 | TracyDebug( "Overriding dlclose for unknown object (%s)\n", dlerror() ); 20 | } 21 | #endif 22 | return 0; 23 | } 24 | 25 | # endif 26 | #endif 27 | -------------------------------------------------------------------------------- /profiler/src/zigzag02.hpp: -------------------------------------------------------------------------------- 1 | // File: 'zigzag02.png' (133 bytes) 2 | // Exported using binary_to_compressed_c.cpp 3 | static const unsigned int ZigZag02_size = 133; 4 | static const unsigned int ZigZag02_data[136/4] = 5 | { 6 | 0x474e5089, 0x0a1a0a0d, 0x0d000000, 0x52444849, 0x02000000, 0x02000000, 0x00000408, 0xc5bfd800, 0x000000af, 0x58457419, 0x666f5374, 0x72617774, 7 | 0x77770065, 0x6e692e77, 0x6163736b, 0x6f2e6570, 0xee9b6772, 0x00001a3c, 0x48700900, 0x00007359, 0x0000ec00, 0x7901ec00, 0x00bd7128, 0x49120000, 8 | 0x78544144, 0xfffc63da, 0xf19fa18c, 0x0143297f, 0x04651900, 0x4bae135b, 0x000000a6, 0x4e454900, 0x6042ae44, 0x00000082, 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /public/common/TracyYield.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYYIELD_HPP__ 2 | #define __TRACYYIELD_HPP__ 3 | 4 | #if defined __SSE2__ || defined _M_AMD64 || (defined _M_IX86_FP && _M_IX86_FP == 2) 5 | # include 6 | #else 7 | # include 8 | #endif 9 | 10 | #include "TracyForceInline.hpp" 11 | 12 | namespace tracy 13 | { 14 | 15 | static tracy_force_inline void YieldThread() 16 | { 17 | #if defined __SSE2__ || defined _M_AMD64 || (defined _M_IX86_FP && _M_IX86_FP == 2) 18 | _mm_pause(); 19 | #elif defined __aarch64__ 20 | asm volatile( "isb" : : ); 21 | #else 22 | std::this_thread::yield(); 23 | #endif 24 | } 25 | 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /extra/desktop/application-tracy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tracy Profiler trace file 5 | Zrzut sesji profilera Tracy 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /profiler/src/ImGuiContext.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "profiler/TracyStorage.hpp" 3 | #include "ImGuiContext.hpp" 4 | 5 | ImGuiTracyContext::ImGuiTracyContext() 6 | : m_iniFilename( tracy::GetSavePath( "imgui.ini" ) ) 7 | { 8 | IMGUI_CHECKVERSION(); 9 | ImGui::CreateContext(); 10 | ImGuiIO& io = ImGui::GetIO(); 11 | io.IniFilename = m_iniFilename.c_str(); 12 | io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard | ImGuiConfigFlags_DockingEnable; 13 | io.ConfigInputTextCursorBlink = false; 14 | io.ConfigScrollbarScrollByPage = false; 15 | } 16 | 17 | ImGuiTracyContext::~ImGuiTracyContext() 18 | { 19 | ImGui::DestroyContext(); 20 | } 21 | -------------------------------------------------------------------------------- /examples/OpenCLVectorAdd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(OpenCLVectorAdd) 4 | 5 | set(THREADS_PREFER_PTHREAD_FLAG ON) 6 | find_package(Threads REQUIRED) 7 | 8 | find_package(OpenCL REQUIRED) 9 | 10 | add_executable(OpenCLVectorAdd OpenCLVectorAdd.cpp) 11 | 12 | add_library(TracyClient STATIC ../../public/TracyClient.cpp 13 | ../../public/tracy/TracyOpenCL.hpp) 14 | target_include_directories(TracyClient PUBLIC ../../public/tracy) 15 | target_compile_definitions(TracyClient PUBLIC TRACY_ENABLE=1) 16 | 17 | target_link_libraries(OpenCLVectorAdd PUBLIC OpenCL::OpenCL TracyClient ${CMAKE_DL_LIBS} Threads::Threads) 18 | -------------------------------------------------------------------------------- /icon/application-tracy.copying: -------------------------------------------------------------------------------- 1 | application-tracy.svg (and no other file) is based on icons retrieved from 2 | https://gitlab.gnome.org/GNOME/adwaita-icon-theme.git 3 | 4 | ---------------------------------------------------------------------------- 5 | 6 | This work is licenced under the Creative Commons Attribution-Share Alike 3.0 7 | United States License. To view a copy of this licence, visit 8 | http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative 9 | Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. 10 | 11 | When attributing the artwork, using "GNOME Project" is enough. 12 | Please link to http://www.gnome.org where available. 13 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyLockHelpers.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYLOCKHELPERS_HPP__ 2 | #define __TRACYLOCKHELPERS_HPP__ 3 | 4 | #include 5 | 6 | #include "../public/common/TracyForceInline.hpp" 7 | 8 | namespace tracy 9 | { 10 | 11 | static tracy_force_inline uint64_t GetThreadBit( uint8_t thread ) 12 | { 13 | return uint64_t( 1 ) << thread; 14 | } 15 | 16 | static tracy_force_inline bool IsThreadWaiting( uint64_t bitlist, uint64_t threadBit ) 17 | { 18 | return ( bitlist & threadBit ) != 0; 19 | } 20 | 21 | static tracy_force_inline bool AreOtherWaiting( uint64_t bitlist, uint64_t threadBit ) 22 | { 23 | return ( bitlist & ~threadBit ) != 0; 24 | } 25 | 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /examples/ToyPathTracer/Source/Test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | enum TestFlags 5 | { 6 | kFlagAnimate = (1 << 0), 7 | kFlagProgressive = (1 << 1), 8 | }; 9 | 10 | void InitializeTest(); 11 | void ShutdownTest(); 12 | 13 | void UpdateTest(float time, int frameCount, int screenWidth, int screenHeight, unsigned testFlags); 14 | void DrawTest(float time, int frameCount, int screenWidth, int screenHeight, float* backbuffer, int& outRayCount, unsigned testFlags); 15 | 16 | void GetObjectCount(int& outCount, int& outObjectSize, int& outMaterialSize, int& outCamSize); 17 | void GetSceneDesc(void* outObjects, void* outMaterials, void* outCam, void* outEmissives, int* outEmissiveCount); 18 | -------------------------------------------------------------------------------- /profiler/wasm/httpd.py: -------------------------------------------------------------------------------- 1 | from http import server 2 | 3 | class MyHTTPRequestHandler(server.SimpleHTTPRequestHandler): 4 | def end_headers(self): 5 | self.send_my_headers() 6 | server.SimpleHTTPRequestHandler.end_headers(self) 7 | 8 | def send_my_headers(self): 9 | self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") 10 | self.send_header("Pragma", "no-cache") 11 | self.send_header("Expires", "0") 12 | self.send_header("Cross-Origin-Embedder-Policy", "require-corp"); 13 | self.send_header("Cross-Origin-Opener-Policy", "same-origin"); 14 | 15 | 16 | if __name__ == '__main__': 17 | server.test(HandlerClass=MyHTTPRequestHandler) 18 | -------------------------------------------------------------------------------- /public/client/TracySysTrace.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSYSTRACE_HPP__ 2 | #define __TRACYSYSTRACE_HPP__ 3 | 4 | #if !defined TRACY_NO_SYSTEM_TRACING && ( defined _WIN32 || defined __linux__ ) 5 | # include "../common/TracyWinFamily.hpp" 6 | # if !defined TRACY_WIN32_NO_DESKTOP 7 | # define TRACY_HAS_SYSTEM_TRACING 8 | # endif 9 | #endif 10 | 11 | #ifdef TRACY_HAS_SYSTEM_TRACING 12 | 13 | #include 14 | 15 | namespace tracy 16 | { 17 | 18 | bool SysTraceStart( int64_t& samplingPeriod ); 19 | void SysTraceStop(); 20 | void SysTraceWorker( void* ptr ); 21 | 22 | void SysTraceGetExternalName( uint64_t thread, const char*& threadName, const char*& name ); 23 | 24 | } 25 | 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /profiler/src/zigzag04.hpp: -------------------------------------------------------------------------------- 1 | // File: 'zigzag04.png' (151 bytes) 2 | // Exported using binary_to_compressed_c.cpp 3 | static const unsigned int ZigZag04_size = 151; 4 | static const unsigned int ZigZag04_data[152/4] = 5 | { 6 | 0x474e5089, 0x0a1a0a0d, 0x0d000000, 0x52444849, 0x04000000, 0x04000000, 0x00000408, 0x56f80300, 0x000000f5, 0x58457419, 0x666f5374, 0x72617774, 7 | 0x77770065, 0x6e692e77, 0x6163736b, 0x6f2e6570, 0xee9b6772, 0x00001a3c, 0x48700900, 0x00007359, 0x0000d801, 0xfa01d801, 0x0072a65c, 0x49240000, 8 | 0x78544144, 0x6ff863da, 0x8022dff1, 0xe1818021, 0x74202bff, 0x00c0eff8, 0x061c4022, 0xf37ff090, 0x5500e6ff, 0x70bb123d, 0x0058f936, 0x49000000, 9 | 0xae444e45, 0x00826042, 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /public/libbacktrace/config.h: -------------------------------------------------------------------------------- 1 | #include 2 | #if defined(__linux__) && !defined(__GLIBC__) && !defined(__WORDSIZE) 3 | // include __WORDSIZE headers for musl 4 | # include 5 | #endif 6 | #if __WORDSIZE == 64 7 | # define BACKTRACE_ELF_SIZE 64 8 | #else 9 | # define BACKTRACE_ELF_SIZE 32 10 | #endif 11 | 12 | #define HAVE_DLFCN_H 1 13 | #define HAVE_FCNTL 1 14 | #define HAVE_INTTYPES_H 1 15 | #define HAVE_LSTAT 1 16 | #define HAVE_READLINK 1 17 | #define HAVE_DL_ITERATE_PHDR 1 18 | #define HAVE_ATOMIC_FUNCTIONS 1 19 | #define HAVE_DECL_STRNLEN 1 20 | 21 | #ifdef __APPLE__ 22 | # define HAVE_MACH_O_DYLD_H 1 23 | #elif defined BSD 24 | # define HAVE_KERN_PROC 1 25 | # define HAVE_KERN_PROC_ARGS 1 26 | #endif 27 | -------------------------------------------------------------------------------- /examples/fibers.cpp: -------------------------------------------------------------------------------- 1 | // g++ fibers.cpp ../public/TracyClient.cpp -I../public/tracy -DTRACY_ENABLE -DTRACY_FIBERS -lpthread -ldl 2 | 3 | #include 4 | #include 5 | 6 | #include "Tracy.hpp" 7 | #include "TracyC.h" 8 | 9 | const char* fiber = "job1"; 10 | TracyCZoneCtx zone; 11 | 12 | int main() 13 | { 14 | std::thread t1( [] { 15 | TracyFiberEnter( fiber ); 16 | TracyCZone( ctx, 1 ); 17 | zone = ctx; 18 | sleep( 1 ); 19 | TracyFiberLeave; 20 | }); 21 | t1.join(); 22 | 23 | std::thread t2( [] { 24 | TracyFiberEnter( fiber ); 25 | sleep( 1 ); 26 | TracyCZoneEnd( zone ); 27 | TracyFiberLeave; 28 | }); 29 | t2.join(); 30 | } 31 | -------------------------------------------------------------------------------- /profiler/src/ini.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 rxi 3 | * 4 | * This library is free software; you can redistribute it and/or modify it 5 | * under the terms of the MIT license. See `ini.c` for details. 6 | */ 7 | 8 | #ifndef INI_H 9 | #define INI_H 10 | 11 | #define INI_VERSION "0.1.1" 12 | 13 | #if defined(__cplusplus) 14 | extern "C" { 15 | #endif 16 | 17 | typedef struct ini_t ini_t; 18 | 19 | ini_t* ini_load(const char *filename); 20 | void ini_free(ini_t *ini); 21 | const char* ini_get(ini_t *ini, const char *section, const char *key); 22 | int ini_sget(ini_t *ini, const char *section, const char *key, const char *scanfmt, void *dst); 23 | 24 | #if defined(__cplusplus) 25 | } 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /profiler/src/RunQueue.cpp: -------------------------------------------------------------------------------- 1 | #include "RunQueue.hpp" 2 | 3 | RunQueue::RunQueue() 4 | : m_mainThread( std::this_thread::get_id() ) 5 | { 6 | } 7 | 8 | void RunQueue::Queue( const std::function& cb, bool forceDelay ) 9 | { 10 | if( !forceDelay && std::this_thread::get_id() == m_mainThread ) 11 | { 12 | cb(); 13 | } 14 | else 15 | { 16 | std::lock_guard lock( m_lock ); 17 | m_queue.emplace_back( cb ); 18 | } 19 | } 20 | 21 | void RunQueue::Run() 22 | { 23 | std::unique_lock lock( m_lock ); 24 | if( !m_queue.empty() ) 25 | { 26 | std::vector> tmp; 27 | std::swap( tmp, m_queue ); 28 | lock.unlock(); 29 | for( auto& cb : tmp ) cb(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyWeb.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _WIN32 2 | # include 3 | # include 4 | #elif defined __EMSCRIPTEN__ 5 | # include 6 | #else 7 | # include 8 | # include 9 | #endif 10 | 11 | #include "TracyWeb.hpp" 12 | 13 | namespace tracy 14 | { 15 | 16 | void OpenWebpage( const char* url ) 17 | { 18 | #ifdef _WIN32 19 | ShellExecuteA( nullptr, nullptr, url, nullptr, nullptr, 0 ); 20 | #elif defined __APPLE__ 21 | char buf[1024]; 22 | sprintf( buf, "open %s", url ); 23 | system( buf ); 24 | #elif defined __EMSCRIPTEN__ 25 | EM_ASM( { window.open( UTF8ToString( $0 ), '_blank' ) }, url ); 26 | #else 27 | char buf[1024]; 28 | sprintf( buf, "xdg-open %s", url ); 29 | system( buf ); 30 | #endif 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | _build 3 | _compiler 4 | tools/* 5 | *.d 6 | *.o 7 | *.so 8 | *.swp 9 | *.obj 10 | imgui.ini 11 | test/tracy_test 12 | test/tracy_test.exe 13 | */build/unix/*-* 14 | manual/t*.aux 15 | manual/t*.log 16 | manual/t*.out 17 | manual/t*.pdf 18 | manual/t*.synctex.gz 19 | manual/t*.toc 20 | manual/t*.bbl 21 | manual/t*.blg 22 | manual/t*.fdb_latexmk 23 | manual/t*.fls 24 | profiler/build/win32/packages 25 | profiler/build/win32/Tracy.aps 26 | .deps/ 27 | .dirstamp 28 | /_*/** 29 | /**/__pycache__/** 30 | extra/vswhere.exe 31 | extra/tracy-build 32 | .cache 33 | compile_commands.json 34 | profiler/build/wasm/Tracy-release.* 35 | profiler/build/wasm/Tracy-debug.* 36 | profiler/build/wasm/embed.tracy 37 | examples/ToyPathTracer/Windows/TestCpu 38 | examples/ToyPathTracer/Windows/x64 39 | *.user 40 | -------------------------------------------------------------------------------- /profiler/src/IsElevated.cpp: -------------------------------------------------------------------------------- 1 | #include "IsElevated.hpp" 2 | 3 | #ifdef _WIN32 4 | 5 | #include 6 | 7 | bool IsElevated() 8 | { 9 | HANDLE token; 10 | if( OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &token ) == 0 ) return false; 11 | 12 | TOKEN_ELEVATION te; 13 | DWORD sz; 14 | if( GetTokenInformation( token, TokenElevation, &te, sizeof( te ), &sz ) == 0 ) 15 | { 16 | CloseHandle( token ); 17 | return false; 18 | } 19 | 20 | bool ret = te.TokenIsElevated; 21 | CloseHandle( token ); 22 | return ret; 23 | } 24 | 25 | #elif defined __EMSCRIPTEN__ 26 | 27 | bool IsElevated() 28 | { 29 | return false; 30 | } 31 | 32 | #else 33 | 34 | #include 35 | 36 | bool IsElevated() 37 | { 38 | return getuid() == 0; 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyBadVersion.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYBADVERSION_HPP__ 2 | #define __TRACYBADVERSION_HPP__ 3 | 4 | #include 5 | 6 | #include "../public/common/TracyForceInline.hpp" 7 | 8 | namespace tracy 9 | { 10 | 11 | struct BadVersionState 12 | { 13 | enum State 14 | { 15 | Ok, 16 | BadFile, 17 | ReadError, 18 | UnsupportedVersion, 19 | LegacyVersion, 20 | LoadFailure 21 | }; 22 | 23 | State state = Ok; 24 | int version = 0; 25 | std::string msg; 26 | }; 27 | 28 | namespace detail 29 | { 30 | void BadVersionImpl( BadVersionState& badVer ); 31 | } 32 | 33 | tracy_force_inline void BadVersion( BadVersionState& badVer ) { if( badVer.state != BadVersionState::Ok ) detail::BadVersionImpl( badVer ); } 34 | 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /public/client/TracySysPower.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSYSPOWER_HPP__ 2 | #define __TRACYSYSPOWER_HPP__ 3 | 4 | #if defined __linux__ 5 | # define TRACY_HAS_SYSPOWER 6 | #endif 7 | 8 | #ifdef TRACY_HAS_SYSPOWER 9 | 10 | #include 11 | #include 12 | 13 | #include "TracyFastVector.hpp" 14 | 15 | namespace tracy 16 | { 17 | 18 | class SysPower 19 | { 20 | struct Domain 21 | { 22 | uint64_t value; 23 | uint64_t overflow; 24 | FILE* handle; 25 | const char* name; 26 | }; 27 | 28 | public: 29 | SysPower(); 30 | ~SysPower(); 31 | 32 | void Tick(); 33 | 34 | private: 35 | void ScanDirectory( const char* path, int parent ); 36 | 37 | FastVector m_domains; 38 | uint64_t m_lastTime; 39 | }; 40 | 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /profiler/src/Backend.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __BACKEND_HPP__ 2 | #define __BACKEND_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | #include "WindowPosition.hpp" 8 | 9 | class RunQueue; 10 | 11 | class Backend 12 | { 13 | public: 14 | Backend( const char* title, const std::function& redraw, const std::function& scaleChanged, const std::function& isBusy, RunQueue* mainThreadTasks ); 15 | ~Backend(); 16 | 17 | void Show(); 18 | void Run(); 19 | void Attention(); 20 | 21 | void NewFrame( int& w, int& h ); 22 | void EndFrame(); 23 | 24 | void SetIcon( uint8_t* data, int w, int h ); 25 | void SetTitle( const char* title ); 26 | 27 | float GetDpiScale(); 28 | 29 | private: 30 | WindowPosition m_winPos; 31 | int m_w, m_h; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /profiler/src/zigzag08.hpp: -------------------------------------------------------------------------------- 1 | // File: 'zigzag08.png' (191 bytes) 2 | // Exported using binary_to_compressed_c.cpp 3 | static const unsigned int ZigZag08_size = 191; 4 | static const unsigned int ZigZag08_data[192/4] = 5 | { 6 | 0x474e5089, 0x0a1a0a0d, 0x0d000000, 0x52444849, 0x08000000, 0x08000000, 0x00000304, 0xa3213600, 0x000000b8, 0x58457419, 0x666f5374, 0x72617774, 7 | 0x77770065, 0x6e692e77, 0x6163736b, 0x6f2e6570, 0xee9b6772, 0x00001a3c, 0x48700900, 0x00007359, 0x0000b003, 0x2701b003, 0x00ad0fc4, 0x500f0000, 8 | 0x5045544c, 0xffff5050, 0xffffffff, 0xffffffff, 0x5a2fffff, 0x0000b6c6, 0x52740500, 0x3700534e, 0x35ea4038, 0x00e23649, 0x49200000, 0x78544144, 9 | 0x030063da, 0x61200526, 0x9c240ce2, 0x19980c4d, 0x4d9d980c, 0x028c0260, 0x32001560, 0x4e760248, 0x00382c13, 0x49000000, 0xae444e45, 0x00826042, 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /extra/dxt1table.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static const uint8_t IndexTable[4] = { 1, 3, 2, 0 }; 5 | 6 | int convert( int v ) 7 | { 8 | int v0 = v & 0x3; 9 | int v1 = ( v >> 2 ) & 0x3; 10 | int v2 = ( v >> 4 ) & 0x3; 11 | int v3 = ( v >> 6 ); 12 | 13 | int t0 = IndexTable[v0]; 14 | int t1 = IndexTable[v1]; 15 | int t2 = IndexTable[v2]; 16 | int t3 = IndexTable[v3]; 17 | 18 | return t0 | ( t1 << 2 ) | ( t2 << 4 ) | ( t3 << 6 ); 19 | } 20 | 21 | int main() 22 | { 23 | for( int i=0; i<256; i++ ) 24 | { 25 | if( i % 16 == 15 ) 26 | { 27 | printf( "%i,\n", convert( i ) ); 28 | } 29 | else 30 | { 31 | printf( "%i,\t", convert( i ) ); 32 | } 33 | } 34 | printf( "\n" ); 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cmake.configureOnOpen": true, 3 | "cmake.sourceDirectory": [ 4 | "${workspaceFolder}/profiler", 5 | "${workspaceFolder}/capture", 6 | "${workspaceFolder}/csvexport", 7 | "${workspaceFolder}/import", 8 | "${workspaceFolder}/update", 9 | "${workspaceFolder}/test", 10 | "${workspaceFolder}", 11 | ], 12 | "cmake.buildDirectory": "${sourceDirectory}/build", 13 | "cmake.autoSelectActiveFolder": false, 14 | "cmake.options.advanced": { 15 | "folder": { "statusBarVisibility": "visible" }, 16 | "variant": { "statusBarVisibility": "compact" } 17 | }, 18 | "cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json", 19 | "lldb.launch.initCommands": ["command script import ${workspaceRoot}/extra/natvis.py"], 20 | } 21 | -------------------------------------------------------------------------------- /python/tracy_client/tracy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from typing import Optional, Union 4 | 5 | from tracy_client.TracyClientBindings import ( 6 | is_enabled, 7 | program_name, 8 | thread_name, 9 | app_info, 10 | ColorType, 11 | PlotFormatType, 12 | frame_mark, 13 | frame_mark_start, 14 | frame_mark_end, 15 | frame_image, 16 | alloc, 17 | free, 18 | message, 19 | plot, 20 | _plot_config, 21 | ) 22 | from tracy_client.scoped import ( 23 | Color, 24 | ScopedZone, 25 | ScopedFrame, 26 | ScopedZoneDecorator, 27 | ScopedFrameDecorator, 28 | ) 29 | 30 | PlotType = Union[int, PlotFormatType] 31 | 32 | 33 | def plot_config( 34 | name: str, type: PlotType, step: bool = False, flip: bool = False, color: Color = 0 35 | ) -> Optional[int]: 36 | return _plot_config(name, int(type), step, flip, int(color)) 37 | -------------------------------------------------------------------------------- /profiler/src/ConnectionHistory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __CONNECTIONHISTORY_HPP__ 2 | #define __CONNECTIONHISTORY_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class ConnectionHistory 10 | { 11 | public: 12 | ConnectionHistory(); 13 | ~ConnectionHistory(); 14 | 15 | const std::string& Name( size_t idx ) const { return m_connHistVec[idx]->first; } 16 | 17 | void Count( const std::string& name ); 18 | void Erase( size_t idx ); 19 | 20 | bool empty() const { return m_connHistVec.empty(); } 21 | size_t size() const { return m_connHistVec.size(); } 22 | 23 | private: 24 | void Rebuild(); 25 | 26 | std::string m_fn; 27 | 28 | std::unordered_map m_connHistMap; 29 | std::vector::const_iterator> m_connHistVec; 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /profiler/src/ResolvService.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __RESOLVSERVICE_HPP__ 2 | #define __RESOLVSERVICE_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class ResolvService 14 | { 15 | struct QueueItem 16 | { 17 | uint32_t ip; 18 | std::function callback; 19 | }; 20 | 21 | public: 22 | ResolvService( uint16_t port ); 23 | ~ResolvService(); 24 | 25 | void Query( uint32_t ip, const std::function& callback ); 26 | 27 | private: 28 | void Worker(); 29 | 30 | std::atomic m_exit; 31 | std::mutex m_lock; 32 | std::condition_variable m_cv; 33 | std::vector m_queue; 34 | uint16_t m_port; 35 | std::thread m_thread; 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /python/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["scikit-build-core>=0.11"] 3 | build-backend = "scikit_build_core.build" 4 | 5 | [project] 6 | name = "tracy_client" 7 | version = "0.13.1" 8 | description = "A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications." 9 | authors = [ 10 | { name = "Bartosz Taudul", email = "wolf@nereid.pl" }, 11 | ] 12 | requires-python = ">=3.10" 13 | 14 | [project.urls] 15 | homepage = "https://github.com/wolfpld/tracy" 16 | source = "https://github.com/wolfpld/tracy" 17 | 18 | [tool.scikit-build] 19 | cmake.version = ">=3.15.0" 20 | ninja.version = ">=1.11" 21 | cmake.source-dir = ".." 22 | cmake.build-type = "Release" 23 | wheel.install-dir = "tracy_client" 24 | wheel.packages = ["tracy_client"] 25 | 26 | [tool.scikit-build.cmake.define] 27 | TRACY_CLIENT_PYTHON = "ON" 28 | TRACY_STATIC = "OFF" 29 | CMAKE_INSTALL_BINDIR = "" 30 | -------------------------------------------------------------------------------- /server/TracyTaskDispatch.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTASKDISPATCH_HPP__ 2 | #define __TRACYTASKDISPATCH_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace tracy 12 | { 13 | 14 | class TaskDispatch 15 | { 16 | public: 17 | TaskDispatch( size_t workers, const char* name ); 18 | ~TaskDispatch(); 19 | 20 | void Queue( const std::function& f ); 21 | void Queue( std::function&& f ); 22 | 23 | void Sync(); 24 | 25 | private: 26 | void Worker(); 27 | void SetName( const char* name, size_t num ); 28 | 29 | std::vector> m_queue; 30 | std::mutex m_queueLock; 31 | std::condition_variable m_cvWork, m_cvJobs; 32 | std::atomic m_exit; 33 | size_t m_jobs; 34 | 35 | std::vector m_workers; 36 | }; 37 | 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /extra/uarch/TracyMicroArchitecture.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace tracy 4 | { 5 | 6 | struct AsmDesc 7 | { 8 | uint8_t type; 9 | uint16_t width; 10 | }; 11 | 12 | struct AsmVar 13 | { 14 | int descNum; 15 | AsmDesc desc[5]; 16 | int isaSet; 17 | float tp; 18 | int port, uops, minlat, maxlat; 19 | bool minbound, maxbound; 20 | }; 21 | 22 | struct AsmOp 23 | { 24 | int id; 25 | int descId; 26 | int numVariants; 27 | const AsmVar*const* variant; 28 | }; 29 | 30 | struct MicroArchitecture 31 | { 32 | int numOps; 33 | const AsmOp*const* ops; 34 | }; 35 | 36 | extern const char* MicroArchitectureList[]; 37 | extern const char* PortList[]; 38 | extern const char* OpsList[]; 39 | extern const char* OpDescList[]; 40 | extern const char* IsaList[]; 41 | extern const MicroArchitecture* const MicroArchitectureData[]; 42 | 43 | extern int OpsNum; 44 | extern int MicroArchitectureNum; 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /cmake/version.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | message("Parsing public/common/TracyVersion.hpp file") 4 | 5 | file(READ "${CMAKE_CURRENT_LIST_DIR}/../public/common/TracyVersion.hpp" version) 6 | 7 | # Note: This looks for a specific pattern in TracyVersion.hpp, if it changes 8 | # this needs updating. 9 | string(REGEX MATCH "Major = ([0-9]+)" _ ${version}) 10 | 11 | # This works do to the above () subexpression selection. See 12 | # https://cmake.org/cmake/help/latest/command/string.html#regex-match for more 13 | # details 14 | set(TRACY_VERSION_MAJOR ${CMAKE_MATCH_1}) 15 | 16 | string(REGEX MATCH "Minor = ([0-9]+)" _ ${version}) 17 | set(TRACY_VERSION_MINOR ${CMAKE_MATCH_1}) 18 | 19 | string(REGEX MATCH "Patch = ([0-9]+)" _ ${version}) 20 | set(TRACY_VERSION_PATCH ${CMAKE_MATCH_1}) 21 | 22 | set(TRACY_VERSION_STRING "${TRACY_VERSION_MAJOR}.${TRACY_VERSION_MINOR}.${TRACY_VERSION_PATCH}") 23 | 24 | message("VERSION ${TRACY_VERSION_STRING}") 25 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyBuzzAnim.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYBUZZANIM_HPP__ 2 | #define __TRACYBUZZANIM_HPP__ 3 | 4 | #include 5 | 6 | namespace tracy 7 | { 8 | 9 | template 10 | class BuzzAnim 11 | { 12 | public: 13 | bool Match( const T& comp ) const 14 | { 15 | return active && comp == id; 16 | } 17 | 18 | float Time() const 19 | { 20 | assert( active ); 21 | return time; 22 | } 23 | 24 | void Enable( const T& val, float len ) 25 | { 26 | active = true; 27 | time = len; 28 | id = val; 29 | } 30 | 31 | bool Update( float dt ) 32 | { 33 | if( active ) 34 | { 35 | time -= dt; 36 | if( time <= 0 ) active = false; 37 | return true; 38 | } 39 | return false; 40 | } 41 | 42 | private: 43 | bool active = false; 44 | float time; 45 | T id; 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyMicroArchitecture.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace tracy 4 | { 5 | 6 | struct AsmDesc 7 | { 8 | uint8_t type; 9 | uint16_t width; 10 | }; 11 | 12 | struct AsmVar 13 | { 14 | int descNum; 15 | AsmDesc desc[5]; 16 | int isaSet; 17 | float tp; 18 | int port, uops, minlat, maxlat; 19 | bool minbound, maxbound; 20 | }; 21 | 22 | struct AsmOp 23 | { 24 | int id; 25 | int descId; 26 | int numVariants; 27 | const AsmVar*const* variant; 28 | }; 29 | 30 | struct MicroArchitecture 31 | { 32 | int numOps; 33 | const AsmOp*const* ops; 34 | }; 35 | 36 | extern const char* MicroArchitectureList[]; 37 | extern const char* PortList[]; 38 | extern const char* OpsList[]; 39 | extern const char* OpDescList[]; 40 | extern const char* IsaList[]; 41 | extern const MicroArchitecture* const MicroArchitectureData[]; 42 | 43 | extern int OpsNum; 44 | extern int MicroArchitectureNum; 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /profiler/src/zigzag16.hpp: -------------------------------------------------------------------------------- 1 | // File: 'zigzag16.png' (234 bytes) 2 | // Exported using binary_to_compressed_c.cpp 3 | static const unsigned int ZigZag16_size = 234; 4 | static const unsigned int ZigZag16_data[236/4] = 5 | { 6 | 0x474e5089, 0x0a1a0a0d, 0x0d000000, 0x52444849, 0x10000000, 0x10000000, 0x00000304, 0xe2dded00, 0x00000052, 0x58457419, 0x666f5374, 0x72617774, 7 | 0x77770065, 0x6e692e77, 0x6163736b, 0x6f2e6570, 0xee9b6772, 0x00001a3c, 0x48700900, 0x00007359, 0x00006107, 0x95016107, 0x00b6b8c3, 0x501b0000, 8 | 0x5045544c, 0xffff5050, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x289affff, 0x00004ebe, 0x52740900, 0x3700534e, 0x403d3c38, 9 | 0x6aeae942, 0x0041d380, 0x493b0000, 0x78544144, 0x07c063da, 0x8ca01498, 0xcd085688, 0x009e6652, 0x3027b866, 0xad198197, 0x0600c940, 0x10065606, 10 | 0x4580e201, 0x205813cd, 0xee65ccd2, 0x3046a809, 0xb3e00a30, 0x4f750012, 0x7fcbb408, 0x000025f6, 0x45490000, 0x42ae444e, 0x00008260, 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /public/common/TracySystem.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSYSTEM_HPP__ 2 | #define __TRACYSYSTEM_HPP__ 3 | 4 | #include 5 | 6 | #include "TracyApi.h" 7 | 8 | namespace tracy 9 | { 10 | 11 | namespace detail 12 | { 13 | TRACY_API uint32_t GetThreadHandleImpl(); 14 | } 15 | 16 | #ifdef TRACY_ENABLE 17 | struct ThreadNameData 18 | { 19 | uint32_t id; 20 | int32_t groupHint; 21 | const char* name; 22 | ThreadNameData* next; 23 | }; 24 | 25 | ThreadNameData* GetThreadNameData( uint32_t id ); 26 | 27 | TRACY_API uint32_t GetThreadHandle(); 28 | #else 29 | static inline uint32_t GetThreadHandle() 30 | { 31 | return detail::GetThreadHandleImpl(); 32 | } 33 | #endif 34 | 35 | TRACY_API void SetThreadName( const char* name ); 36 | TRACY_API void SetThreadNameWithHint( const char* name, int32_t groupHint ); 37 | TRACY_API const char* GetThreadName( uint32_t id ); 38 | 39 | TRACY_API const char* GetEnvVar( const char* name ); 40 | 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /examples/ToyPathTracer/Source/Config.h: -------------------------------------------------------------------------------- 1 | 2 | #if defined(__APPLE__) && !defined(__METAL_VERSION__) 3 | #include 4 | #endif 5 | 6 | #define kBackbufferWidth 1280 7 | #define kBackbufferHeight 720 8 | 9 | #if defined(__EMSCRIPTEN__) 10 | #define CPU_CAN_DO_SIMD 0 11 | #define CPU_CAN_DO_THREADS 0 12 | #else 13 | #define CPU_CAN_DO_SIMD 1 14 | #define CPU_CAN_DO_THREADS 1 15 | #endif 16 | 17 | 18 | #define DO_SAMPLES_PER_PIXEL 4 19 | #define DO_ANIMATE_SMOOTHING 0.9f 20 | #define DO_LIGHT_SAMPLING 1 21 | #define DO_MITSUBA_COMPARE 0 22 | 23 | // Should path tracing be done on the GPU with a compute shader? 24 | #define DO_COMPUTE_GPU 0 25 | #define kCSGroupSizeX 8 26 | #define kCSGroupSizeY 8 27 | #define kCSMaxObjects 64 28 | 29 | // Should float3 struct use SSE/NEON? 30 | #define DO_FLOAT3_WITH_SIMD (!(DO_COMPUTE_GPU) && CPU_CAN_DO_SIMD && 1) 31 | 32 | // Should HitSpheres function use SSE/NEON? 33 | #define DO_HIT_SPHERES_SIMD (CPU_CAN_DO_SIMD && 1) 34 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyLlmEmbeddings.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYLLMEMBEDDINGS_HPP__ 2 | #define __TRACYLLMEMBEDDINGS_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace tracy 9 | { 10 | 11 | class TracyLlmEmbeddings 12 | { 13 | public: 14 | struct Result 15 | { 16 | size_t idx; 17 | float distance; 18 | }; 19 | 20 | explicit TracyLlmEmbeddings( size_t length, size_t reserve = 0 ); 21 | explicit TracyLlmEmbeddings( const char* file, uint64_t hash ); 22 | 23 | void Add( uint32_t idx, const std::vector& embedding ); 24 | [[nodiscard]] std::vector Search( const std::vector& embedding, size_t k ) const; 25 | [[nodiscard]] uint32_t Get( size_t idx ) const { return m_data[idx]; } 26 | 27 | bool Save( const char* file, uint64_t hash ) const; 28 | 29 | private: 30 | unum::usearch::index_dense_t m_index; 31 | std::vector m_data; 32 | }; 33 | 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /csvexport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) 4 | 5 | set(NO_STATISTICS OFF) 6 | 7 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) 8 | 9 | set(CMAKE_CXX_STANDARD 20) 10 | 11 | project( 12 | tracy-csvexport 13 | LANGUAGES C CXX 14 | VERSION ${TRACY_VERSION_STRING} 15 | ) 16 | 17 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/config.cmake) 18 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/vendor.cmake) 19 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/server.cmake) 20 | 21 | set(PROGRAM_FILES 22 | src/csvexport.cpp 23 | ) 24 | 25 | add_executable(${PROJECT_NAME} ${PROGRAM_FILES} ${COMMON_FILES} ${SERVER_FILES}) 26 | target_link_libraries(${PROJECT_NAME} PRIVATE TracyServer TracyGetOpt) 27 | set_property(DIRECTORY ${CMAKE_CURRENT_LIST_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) 28 | 29 | install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) -------------------------------------------------------------------------------- /profiler/src/profiler/TracyManualData.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYMANUALDATA_HPP__ 2 | #define __TRACYMANUALDATA_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace tracy 10 | { 11 | 12 | class TracyManualData 13 | { 14 | public: 15 | struct ManualChunk 16 | { 17 | std::string text; 18 | std::string section; 19 | std::string title; 20 | std::string parents; 21 | std::string link; 22 | int level; 23 | }; 24 | 25 | TracyManualData(); 26 | 27 | [[nodiscard]] const std::vector& GetChunks() const { return m_manualChunks; } 28 | [[nodiscard]] uint64_t GetHash() const { return m_hash; } 29 | 30 | private: 31 | void AddManualChunk( const std::string_view& manual, int manualChunkPos, int pos, const std::vector& levels, const std::vector& chapterNames ); 32 | 33 | std::vector m_manualChunks; 34 | uint64_t m_hash; 35 | }; 36 | 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /capture/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) 4 | option(NO_STATISTICS "Disable calculation of statistics" ON) 5 | 6 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) 7 | 8 | set(CMAKE_CXX_STANDARD 20) 9 | 10 | project( 11 | tracy-capture 12 | LANGUAGES C CXX 13 | VERSION ${TRACY_VERSION_STRING} 14 | ) 15 | 16 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/config.cmake) 17 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/vendor.cmake) 18 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/server.cmake) 19 | 20 | set(PROGRAM_FILES 21 | src/capture.cpp 22 | ) 23 | 24 | add_executable(${PROJECT_NAME} ${PROGRAM_FILES} ${COMMON_FILES} ${SERVER_FILES}) 25 | target_link_libraries(${PROJECT_NAME} PRIVATE TracyServer TracyGetOpt) 26 | set_property(DIRECTORY ${CMAKE_CURRENT_LIST_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) 27 | 28 | install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) -------------------------------------------------------------------------------- /public/client/TracyStringHelpers.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSTRINGHELPERS_HPP__ 2 | #define __TRACYSTRINGHELPERS_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | #include "../common/TracyAlloc.hpp" 8 | #include "../common/TracyForceInline.hpp" 9 | 10 | namespace tracy 11 | { 12 | 13 | static tracy_force_inline char* CopyString( const char* src, size_t sz ) 14 | { 15 | auto dst = (char*)tracy_malloc( sz + 1 ); 16 | memcpy( dst, src, sz ); 17 | dst[sz] = '\0'; 18 | return dst; 19 | } 20 | 21 | static tracy_force_inline char* CopyString( const char* src ) 22 | { 23 | return CopyString( src, strlen( src ) ); 24 | } 25 | 26 | static tracy_force_inline char* CopyStringFast( const char* src, size_t sz ) 27 | { 28 | auto dst = (char*)tracy_malloc_fast( sz + 1 ); 29 | memcpy( dst, src, sz ); 30 | dst[sz] = '\0'; 31 | return dst; 32 | } 33 | 34 | static tracy_force_inline char* CopyStringFast( const char* src ) 35 | { 36 | return CopyStringFast( src, strlen( src ) ); 37 | } 38 | 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /update/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) 4 | 5 | set(NO_STATISTICS ON) 6 | 7 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) 8 | 9 | set(CMAKE_CXX_STANDARD 20) 10 | 11 | project( 12 | tracy-update 13 | LANGUAGES C CXX 14 | VERSION ${TRACY_VERSION_STRING} 15 | ) 16 | 17 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/config.cmake) 18 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/vendor.cmake) 19 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/server.cmake) 20 | 21 | set(PROGRAM_FILES 22 | src/OfflineSymbolResolver.cpp 23 | src/OfflineSymbolResolverAddr2Line.cpp 24 | src/OfflineSymbolResolverDbgHelper.cpp 25 | src/update.cpp 26 | ) 27 | 28 | add_executable(${PROJECT_NAME} ${PROGRAM_FILES} ${COMMON_FILES} ${SERVER_FILES}) 29 | target_link_libraries(${PROJECT_NAME} PRIVATE TracyServer TracyGetOpt) 30 | set_property(DIRECTORY ${CMAKE_CURRENT_LIST_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) -------------------------------------------------------------------------------- /profiler/src/zigzag32.hpp: -------------------------------------------------------------------------------- 1 | // File: 'zigzag32.png' (263 bytes) 2 | // Exported using binary_to_compressed_c.cpp 3 | static const unsigned int ZigZag32_size = 263; 4 | static const unsigned int ZigZag32_data[264/4] = 5 | { 6 | 0x474e5089, 0x0a1a0a0d, 0x0d000000, 0x52444849, 0x20000000, 0x20000000, 0x00000304, 0x67548100, 0x000000c7, 0x58457419, 0x666f5374, 0x72617774, 7 | 0x77770065, 0x6e692e77, 0x6163736b, 0x6f2e6570, 0xee9b6772, 0x00001a3c, 0x48700900, 0x00007359, 0x0000c30e, 0xc701c30e, 0x0064a86f, 0x50180000, 8 | 0x5045544c, 0xffff5050, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x1dffffff, 0x002deec8, 0x74070000, 0x00534e52, 0x877e7d01, 0xbd7e8f88, 9 | 0x0000db4b, 0x44495d00, 0xda785441, 0xc0381863, 0x902680a4, 0x67ca865e, 0x404f4b2b, 0x604f0811, 0xe2401329, 0xb83502b3, 0x002b2227, 0x412887aa, 10 | 0x02514028, 0x610d9031, 0x50859811, 0x5600cac2, 0x1c253080, 0x928456bb, 0xcc30b070, 0x08959814, 0x08055025, 0x08057025, 0x060fe24f, 0x81836606, 11 | 0x3c00248b, 0x79101397, 0x00b45f6d, 0x49000000, 0xae444e45, 0x00826042, 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /import/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) 4 | option(NO_STATISTICS "Disable calculation of statistics" ON) 5 | 6 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) 7 | 8 | set(CMAKE_CXX_STANDARD 20) 9 | 10 | project( 11 | tracy-import 12 | LANGUAGES C CXX 13 | VERSION ${TRACY_VERSION_STRING} 14 | ) 15 | 16 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/config.cmake) 17 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/vendor.cmake) 18 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/server.cmake) 19 | 20 | add_executable(tracy-import-chrome 21 | src/import-chrome.cpp 22 | ) 23 | target_link_libraries(tracy-import-chrome PRIVATE TracyServer nlohmann_json::nlohmann_json) 24 | 25 | add_executable(tracy-import-fuchsia 26 | src/import-fuchsia.cpp 27 | ) 28 | target_link_libraries(tracy-import-fuchsia PRIVATE TracyServer) 29 | 30 | set_property(DIRECTORY ${CMAKE_CURRENT_LIST_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) 31 | -------------------------------------------------------------------------------- /server/TracySysUtil.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "TracySysUtil.hpp" 4 | 5 | #ifdef _WIN32 6 | # include 7 | #elif defined __linux__ 8 | # include 9 | #elif defined __APPLE__ || defined BSD 10 | # include 11 | # include 12 | #endif 13 | 14 | namespace tracy 15 | { 16 | 17 | size_t GetPhysicalMemorySize() 18 | { 19 | #ifdef _WIN32 20 | MEMORYSTATUSEX statex; 21 | statex.dwLength = sizeof( statex ); 22 | GlobalMemoryStatusEx( &statex ); 23 | return statex.ullTotalPhys; 24 | #elif defined __linux__ 25 | struct sysinfo sysInfo; 26 | sysinfo( &sysInfo ); 27 | return sysInfo.totalram; 28 | #elif defined __APPLE__ 29 | size_t memSize; 30 | size_t sz = sizeof( memSize ); 31 | sysctlbyname( "hw.memsize", &memSize, &sz, nullptr, 0 ); 32 | return memSize; 33 | #elif defined BSD 34 | size_t memSize; 35 | size_t sz = sizeof( memSize ); 36 | sysctlbyname( "hw.physmem", &memSize, &sz, nullptr, 0 ); 37 | return memSize; 38 | #else 39 | return 0; 40 | #endif 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyColor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "TracyColor.hpp" 4 | 5 | namespace tracy 6 | { 7 | 8 | uint32_t GetHsvColor( uint64_t hue, int value ) 9 | { 10 | const uint8_t h = ( hue * 11400714819323198485ull ) & 0xFF; 11 | const uint8_t s = 108; 12 | const uint8_t v = std::max( 96, 170 - value * 8 ); 13 | 14 | const uint8_t reg = h / 43; 15 | const uint8_t rem = ( h - ( reg * 43 ) ) * 6; 16 | 17 | const uint8_t p = ( v * ( 255 - s ) ) >> 8; 18 | const uint8_t q = ( v * ( 255 - ( ( s * rem ) >> 8 ) ) ) >> 8; 19 | const uint8_t t = ( v * ( 255 - ( ( s * ( 255 - rem ) ) >> 8 ) ) ) >> 8; 20 | 21 | uint8_t r, g, b; 22 | 23 | switch( reg ) 24 | { 25 | case 0: r = v; g = t; b = p; break; 26 | case 1: r = q; g = v; b = p; break; 27 | case 2: r = p; g = v; b = t; break; 28 | case 3: r = p; g = q; b = v; break; 29 | case 4: r = t; g = p; b = v; break; 30 | default: r = v; g = p; b = q; break; 31 | } 32 | 33 | return 0xFF000000 | ( r << 16 ) | ( g << 8 ) | b; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /extra/x11_colors.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | FILE* f = fopen( "rgb.txt", "rb" ); 7 | 8 | char buf[1024]; 9 | int off = 0; 10 | for(;;) 11 | { 12 | int sz = fread( buf+off, 1, 1, f ); 13 | if( buf[off] == '\r' || buf[off] == '\n' || sz == 0 ) 14 | { 15 | if( off == 0 ) 16 | { 17 | if( sz == 0 ) break; 18 | continue; 19 | } 20 | int ok = 1; 21 | for( int i=13; i 10 | class DecayValue 11 | { 12 | public: 13 | DecayValue( const T& init, bool active = false ) 14 | : m_value( init ) 15 | , m_active( active ) 16 | { 17 | } 18 | 19 | tracy_force_inline operator const T& () const { return m_value; } 20 | tracy_force_inline T operator->() const { return m_value; } 21 | 22 | tracy_force_inline DecayValue& operator=( const T& value ) 23 | { 24 | m_value = value; 25 | m_active = true; 26 | return *this; 27 | } 28 | 29 | tracy_force_inline void Decay( const T& value ) 30 | { 31 | if( m_active ) 32 | { 33 | m_active = false; 34 | } 35 | else 36 | { 37 | m_value = value; 38 | } 39 | } 40 | 41 | private: 42 | T m_value; 43 | bool m_active; 44 | }; 45 | 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /public/client/TracyCallstack.h: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYCALLSTACK_H__ 2 | #define __TRACYCALLSTACK_H__ 3 | 4 | #ifndef TRACY_NO_CALLSTACK 5 | 6 | # if !defined _WIN32 7 | # include 8 | # endif 9 | 10 | # if defined _WIN32 11 | # include "../common/TracyWinFamily.hpp" 12 | # if !defined TRACY_WIN32_NO_DESKTOP 13 | # define TRACY_HAS_CALLSTACK 1 14 | # endif 15 | # elif defined __ANDROID__ 16 | # if !defined __arm__ || __ANDROID_API__ >= 21 17 | # define TRACY_HAS_CALLSTACK 2 18 | # else 19 | # define TRACY_HAS_CALLSTACK 5 20 | # endif 21 | # elif defined __linux 22 | # if defined _GNU_SOURCE && defined __GLIBC__ 23 | # define TRACY_HAS_CALLSTACK 3 24 | # else 25 | # define TRACY_HAS_CALLSTACK 2 26 | # endif 27 | # elif defined __APPLE__ 28 | # define TRACY_HAS_CALLSTACK 4 29 | # elif defined BSD 30 | # define TRACY_HAS_CALLSTACK 6 31 | # endif 32 | 33 | #if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6 34 | #define TRACY_USE_LIBBACKTRACE 35 | #endif 36 | 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /server/TracyMmap.cpp: -------------------------------------------------------------------------------- 1 | #include "TracyMmap.hpp" 2 | 3 | #if defined _WIN32 4 | # include 5 | # include 6 | 7 | void* mmap( void* addr, size_t length, int prot, int flags, int fd, off_t offset ) 8 | { 9 | HANDLE hnd; 10 | void* map = nullptr; 11 | 12 | switch( prot ) 13 | { 14 | case PROT_READ: 15 | if( hnd = CreateFileMapping( HANDLE( _get_osfhandle( fd ) ), nullptr, PAGE_READONLY, 0, 0, nullptr ) ) 16 | { 17 | map = MapViewOfFile( hnd, FILE_MAP_READ, 0, 0, length ); 18 | CloseHandle( hnd ); 19 | } 20 | break; 21 | case PROT_WRITE: 22 | if( hnd = CreateFileMapping( HANDLE( _get_osfhandle( fd ) ), nullptr, PAGE_READWRITE, 0, 0, nullptr ) ) 23 | { 24 | map = MapViewOfFile( hnd, FILE_MAP_WRITE, 0, 0, length ); 25 | CloseHandle( hnd ); 26 | } 27 | break; 28 | } 29 | 30 | return map ? (char*)map + offset : (void*)-1; 31 | } 32 | 33 | int munmap( void* addr, size_t length ) 34 | { 35 | return UnmapViewOfFile( addr ) != 0 ? 0 : -1; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyUtility.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYUTILITY_HPP__ 2 | #define __TRACYUTILITY_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "imgui.h" 9 | #include "../server/TracyEvent.hpp" 10 | 11 | namespace tracy 12 | { 13 | 14 | class Worker; 15 | 16 | enum class ShortenName : uint8_t 17 | { 18 | Never, 19 | Always, 20 | OnlyNormalize, 21 | NoSpace, 22 | NoSpaceAndNormalize, 23 | }; 24 | 25 | const char* ShortenZoneName( ShortenName type, const char* name, ImVec2& tsz, float zsz ); 26 | void TooltipNormalizedName( const char* name, const char* normalized ); 27 | 28 | static inline const char* ShortenZoneName( ShortenName type, const char* name ) { ImVec2 tsz = {}; return ShortenZoneName( type, name, tsz, 0 ); } 29 | 30 | uint32_t GetThreadColor( uint64_t thread, int depth, bool dynamic ); 31 | uint32_t GetPlotColor( const PlotData& plot, const Worker& worker ); 32 | const char* FormatPlotValue( double val, PlotValueFormatting format ); 33 | 34 | std::vector SplitLines( const char* data, size_t sz ); 35 | 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /server/TracyPopcnt.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYPOPCNT_HPP__ 2 | #define __TRACYPOPCNT_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | #if defined __GNUC__ || defined __clang__ 8 | static inline uint64_t TracyCountBits( uint64_t i ) 9 | { 10 | return uint64_t( __builtin_popcountll( i ) ); 11 | } 12 | static inline uint64_t TracyLzcnt( uint64_t i ) 13 | { 14 | return uint64_t( __builtin_clzll( i ) ); 15 | } 16 | #elif defined _WIN64 17 | # include 18 | # define TracyCountBits __popcnt64 19 | # define TracyLzcnt __lzcnt64 20 | #else 21 | static inline uint64_t TracyCountBits( uint64_t i ) 22 | { 23 | i = i - ( (i >> 1) & 0x5555555555555555 ); 24 | i = ( i & 0x3333333333333333 ) + ( (i >> 2) & 0x3333333333333333 ); 25 | i = ( (i + (i >> 4) ) & 0x0F0F0F0F0F0F0F0F ); 26 | return ( i * (0x0101010101010101) ) >> 56; 27 | } 28 | static inline uint64_t TracyLzcnt( uint64_t i ) 29 | { 30 | i |= i >> 1; 31 | i |= i >> 2; 32 | i |= i >> 4; 33 | i |= i >> 8; 34 | i |= i >> 16; 35 | i |= i >> 32; 36 | return 64 - TracyCountBits( i ); 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /cmake/server.cmake: -------------------------------------------------------------------------------- 1 | set(TRACY_COMMON_DIR ${CMAKE_CURRENT_LIST_DIR}/../public/common) 2 | 3 | set(TRACY_COMMON_SOURCES 4 | tracy_lz4.cpp 5 | tracy_lz4hc.cpp 6 | TracySocket.cpp 7 | TracyStackFrames.cpp 8 | TracySystem.cpp 9 | ) 10 | 11 | list(TRANSFORM TRACY_COMMON_SOURCES PREPEND "${TRACY_COMMON_DIR}/") 12 | 13 | 14 | set(TRACY_SERVER_DIR ${CMAKE_CURRENT_LIST_DIR}/../server) 15 | 16 | set(TRACY_SERVER_SOURCES 17 | TracyMemory.cpp 18 | TracyMmap.cpp 19 | TracyPrint.cpp 20 | TracySysUtil.cpp 21 | TracyTaskDispatch.cpp 22 | TracyTextureCompression.cpp 23 | TracyThreadCompress.cpp 24 | TracyWorker.cpp 25 | ) 26 | 27 | list(TRANSFORM TRACY_SERVER_SOURCES PREPEND "${TRACY_SERVER_DIR}/") 28 | 29 | 30 | add_library(TracyServer STATIC EXCLUDE_FROM_ALL ${TRACY_COMMON_SOURCES} ${TRACY_SERVER_SOURCES}) 31 | target_include_directories(TracyServer PUBLIC ${TRACY_COMMON_DIR} ${TRACY_SERVER_DIR}) 32 | target_link_libraries(TracyServer PUBLIC TracyCapstone libzstd PPQSort::PPQSort) 33 | if(NO_STATISTICS) 34 | target_compile_definitions(TracyServer PUBLIC TRACY_NO_STATISTICS) 35 | endif() 36 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) 4 | 5 | # we target C++11 for the client part 6 | set(CMAKE_CXX_STANDARD 11) 7 | 8 | project( 9 | tracy-test 10 | LANGUAGES C CXX 11 | VERSION ${TRACY_VERSION_STRING}) 12 | 13 | file(GENERATE OUTPUT .gitignore CONTENT "*") 14 | 15 | # a bit weird but works: include the client cmake config coming from top-level 16 | # cmake needs us to specify the build subfolder -> client/ this way we can 17 | # simply link the test executable against TracyClient 18 | add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/.. client/) 19 | 20 | add_executable(tracy-test test.cpp) 21 | target_link_options(tracy-test PRIVATE -rdynamic) 22 | target_link_libraries(tracy-test TracyClient) 23 | 24 | # OS-specific options 25 | 26 | if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") 27 | target_link_libraries(tracy-test "execinfo") 28 | endif() 29 | 30 | # copy image file in build folder 31 | configure_file(${CMAKE_CURRENT_LIST_DIR}/image.jpg image.jpg COPYONLY) 32 | 33 | set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT tracy-test) 34 | -------------------------------------------------------------------------------- /extra/make-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf tracy-build 4 | mkdir tracy-build 5 | 6 | ./update-meson-version.sh 7 | 8 | if [ ! -f vswhere.exe ]; then 9 | wget https://github.com/microsoft/vswhere/releases/download/2.8.4/vswhere.exe 10 | fi 11 | 12 | MSVC=`./vswhere.exe -property installationPath -version '[17.0,17.999]' | head -n 1` 13 | MSVC=`wslpath "$MSVC" | tr -d '\r'` 14 | MSBUILD=$MSVC/MSBuild/Current/Bin/MSBuild.exe 15 | 16 | for i in capture csvexport import-chrome update; do 17 | echo $i... 18 | "$MSBUILD" ../$i/build/win32/$i.sln /t:Clean /p:Configuration=Release /p:Platform=x64 /noconsolelogger /nologo -m 19 | "$MSBUILD" ../$i/build/win32/$i.sln /t:Build /p:Configuration=Release /p:Platform=x64 /noconsolelogger /nologo -m 20 | cp ../$i/build/win32/x64/Release/$i.exe tracy-build/ 21 | done 22 | 23 | echo profiler... 24 | "$MSBUILD" ../profiler/build/win32/Tracy.sln /t:Clean /p:Configuration=Release /p:Platform=x64 /noconsolelogger /nologo -m 25 | "$MSBUILD" ../profiler/build/win32/Tracy.sln /t:Build /p:Configuration=Release /p:Platform=x64 /noconsolelogger /nologo -m 26 | cp ../profiler/build/win32/x64/Release/Tracy.exe tracy-build/ 27 | -------------------------------------------------------------------------------- /update/src/OfflineSymbolResolver.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYMBOLRESOLVER_HPP__ 2 | #define __SYMBOLRESOLVER_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace tracy 10 | { 11 | struct CallstackFrame; 12 | class Worker; 13 | } 14 | 15 | struct FrameEntry 16 | { 17 | tracy::CallstackFrame* frame = nullptr; 18 | uint64_t symbolOffset = 0; 19 | }; 20 | 21 | using FrameEntryList = std::vector; 22 | 23 | struct SymbolEntry 24 | { 25 | std::string name; 26 | std::string file; 27 | int line = 0; 28 | }; 29 | 30 | using SymbolEntryList = std::vector; 31 | 32 | bool ResolveSymbols( const std::string& imagePath, const FrameEntryList& inputEntryList, 33 | SymbolEntryList& resolvedEntries ); 34 | 35 | void PatchSymbols( tracy::Worker& worker, const std::vector& pathSubstitutionsStrings, bool verbose = false ); 36 | 37 | using PathSubstitutionList = std::vector >; 38 | bool PatchSymbolsWithRegex( tracy::Worker& worker, const PathSubstitutionList& pathSubstituionlist, bool verbose = false ); 39 | 40 | #endif // __SYMBOLRESOLVER_HPP__ -------------------------------------------------------------------------------- /profiler/src/WindowPosition.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "WindowPosition.hpp" 5 | 6 | #include "profiler/TracyStorage.hpp" 7 | 8 | 9 | WindowPosition::WindowPosition() 10 | : m_fn( tracy::GetSavePath( "window.position" ) ) 11 | { 12 | Defaults(); 13 | 14 | FILE* f = fopen( m_fn.c_str(), "rb" ); 15 | if( f ) 16 | { 17 | uint32_t data[5]; 18 | if( fread( data, 1, sizeof( data ), f ) == sizeof( data ) ) 19 | { 20 | x = data[0]; 21 | y = data[1]; 22 | w = data[2]; 23 | h = data[3]; 24 | maximize = data[4]; 25 | } 26 | fclose( f ); 27 | 28 | if( w <= 0 || h <= 0 ) Defaults(); 29 | } 30 | } 31 | 32 | WindowPosition::~WindowPosition() 33 | { 34 | FILE* f = fopen( m_fn.c_str(), "wb" ); 35 | if( !f ) return; 36 | uint32_t data[5] = { uint32_t( x ), uint32_t( y ), uint32_t( w ), uint32_t( h ), uint32_t( maximize ) }; 37 | fwrite( data, 1, sizeof( data ), f ); 38 | fclose( f ); 39 | } 40 | 41 | void WindowPosition::Defaults() 42 | { 43 | x = 200; 44 | y = 200; 45 | w = 1650; 46 | h = 960; 47 | maximize = 0; 48 | } 49 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyProtoHistory.cpp: -------------------------------------------------------------------------------- 1 | #include "TracyFileHeader.hpp" 2 | #include "TracyProtoHistory.hpp" 3 | 4 | namespace tracy 5 | { 6 | 7 | constexpr ProtocolHistory_t ProtocolHistoryArr[] = { 8 | { 76, FileVersion( 0, 13, 0 ) }, 9 | { 74, FileVersion( 0, 12, 0 ), FileVersion( 0, 12, 2 ) }, 10 | { 69, FileVersion( 0, 11, 1 ) }, 11 | { 66, FileVersion( 0, 11, 0 ) }, 12 | { 64, FileVersion( 0, 10, 0 ) }, 13 | { 63, FileVersion( 0, 9, 0 ), FileVersion( 0, 9, 1 ) }, 14 | { 57, FileVersion( 0, 8, 2 ) }, 15 | { 56, FileVersion( 0, 8, 1 ) }, 16 | { 55, FileVersion( 0, 8, 0 ) }, 17 | { 46, FileVersion( 0, 7, 6 ), FileVersion( 0, 7, 8 ) }, 18 | { 44, FileVersion( 0, 7, 5 ) }, 19 | { 42, FileVersion( 0, 7, 3 ), FileVersion( 0, 7, 4 ) }, 20 | { 40, FileVersion( 0, 7, 1 ), FileVersion( 0, 7, 2 ) }, 21 | { 35, FileVersion( 0, 7, 0 ) }, 22 | { 25, FileVersion( 0, 6, 2 ), FileVersion( 0, 6, 3 ) }, 23 | { 24, FileVersion( 0, 6, 1 ) }, 24 | { 23, FileVersion( 0, 6, 0 ) }, 25 | { 14, FileVersion( 0, 5, 0 ) }, 26 | { 1, FileVersion( 0, 4, 1 ) }, 27 | {} 28 | }; 29 | 30 | const ProtocolHistory_t* ProtocolHistory = ProtocolHistoryArr; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyTimelineItemGpu.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTIMELINEITEMGPU_HPP__ 2 | #define __TRACYTIMELINEITEMGPU_HPP__ 3 | 4 | #include "TracyEvent.hpp" 5 | #include "TracyTimelineItem.hpp" 6 | 7 | namespace tracy 8 | { 9 | 10 | class TimelineItemGpu final : public TimelineItem 11 | { 12 | public: 13 | TimelineItemGpu( View& view, Worker& worker, GpuCtxData* gpu ); 14 | 15 | int GetIdx() const { return m_idx; } 16 | 17 | protected: 18 | uint32_t HeaderColor() const override { return 0xFFFFAAAA; } 19 | uint32_t HeaderColorInactive() const override { return 0xFF886666; } 20 | uint32_t HeaderLineColor() const override { return 0x33FFFFFF; } 21 | const char* HeaderLabel() const override; 22 | 23 | int64_t RangeBegin() const override; 24 | int64_t RangeEnd() const override; 25 | 26 | void HeaderTooltip( const char* label ) const override; 27 | void HeaderExtraContents( const TimelineContext& ctx, int offset, float labelWidth ) override; 28 | 29 | bool DrawContents( const TimelineContext& ctx, int& offset ) override; 30 | 31 | bool IsEmpty() const override; 32 | 33 | private: 34 | GpuCtxData* m_gpu; 35 | int m_idx; 36 | }; 37 | 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /public/TracyClient.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Tracy profiler 3 | // ---------------- 4 | // 5 | // For fast integration, compile and 6 | // link with this source file (and none 7 | // other) in your executable (or in the 8 | // main DLL / shared object on multi-DLL 9 | // projects). 10 | // 11 | 12 | // Define TRACY_ENABLE to enable profiler. 13 | 14 | #include "common/TracySystem.cpp" 15 | 16 | #ifdef TRACY_ENABLE 17 | 18 | #ifdef _MSC_VER 19 | # pragma warning(push, 0) 20 | #endif 21 | 22 | #include "common/tracy_lz4.cpp" 23 | #include "client/TracyProfiler.cpp" 24 | #include "client/TracyCallstack.cpp" 25 | #include "client/TracySysPower.cpp" 26 | #include "client/TracySysTime.cpp" 27 | #include "client/TracySysTrace.cpp" 28 | #include "common/TracySocket.cpp" 29 | #include "client/tracy_rpmalloc.cpp" 30 | #include "client/TracyDxt1.cpp" 31 | #include "client/TracyAlloc.cpp" 32 | #include "client/TracyOverride.cpp" 33 | #include "client/TracyKCore.cpp" 34 | 35 | #ifdef TRACY_ROCPROF 36 | # include "client/TracyRocprof.cpp" 37 | #endif 38 | #ifdef _MSC_VER 39 | # pragma comment(lib, "ws2_32.lib") 40 | # pragma comment(lib, "advapi32.lib") 41 | # pragma comment(lib, "user32.lib") 42 | # pragma warning(pop) 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /manual/latex2md.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cp -f tracy.tex _tmp.tex 4 | sed -i -e 's@\\menu\[,\]@@g' _tmp.tex 5 | sed -i -e 's@\\keys@@g' _tmp.tex 6 | sed -i -e 's@\\ctrl@Ctrl@g' _tmp.tex 7 | sed -i -e 's@\\shift@Shift@g' _tmp.tex 8 | sed -i -e 's@\\Alt@Alt@g' _tmp.tex 9 | sed -i -e 's@\\del@Delete@g' _tmp.tex 10 | sed -i -e 's@\\fa\([a-zA-Z]*\)@(\1~icon)@g' _tmp.tex 11 | sed -i -e 's@\\LMB{}~@@g' _tmp.tex 12 | sed -i -e 's@\\MMB{}~@@g' _tmp.tex 13 | sed -i -e 's@\\RMB{}~@@g' _tmp.tex 14 | sed -i -e 's@\\Scroll{}~@@g' _tmp.tex 15 | 16 | sed -i -e 's@\\nameref{quicklook}@A quick look at Tracy Profiler@g' _tmp.tex 17 | sed -i -e 's@\\nameref{firststeps}@First steps@g' _tmp.tex 18 | sed -i -e 's@\\nameref{client}@Client markup@g' _tmp.tex 19 | sed -i -e 's@\\nameref{capturing}@Capturing the data@g' _tmp.tex 20 | sed -i -e 's@\\nameref{analyzingdata}@Analyzing captured data@g' _tmp.tex 21 | sed -i -e 's@\\nameref{csvexport}@Exporting zone statistics to CSV@g' _tmp.tex 22 | sed -i -e 's@\\nameref{importingdata}@Importing external profiling data@g' _tmp.tex 23 | sed -i -e 's@\\nameref{configurationfiles}@Configuration files@g' _tmp.tex 24 | 25 | pandoc --wrap=none --reference-location=block --number-sections -L filter.lua -s _tmp.tex -o tracy.md 26 | rm -f _tmp.tex 27 | -------------------------------------------------------------------------------- /public/client/TracyAlloc.cpp: -------------------------------------------------------------------------------- 1 | #include "../common/TracyAlloc.hpp" 2 | 3 | #ifdef TRACY_USE_RPMALLOC 4 | 5 | #include 6 | 7 | #include "../common/TracyForceInline.hpp" 8 | #include "../common/TracyYield.hpp" 9 | 10 | namespace tracy 11 | { 12 | 13 | extern thread_local bool RpThreadInitDone; 14 | extern std::atomic RpInitDone; 15 | extern std::atomic RpInitLock; 16 | 17 | tracy_no_inline static void InitRpmallocPlumbing() 18 | { 19 | const auto done = RpInitDone.load( std::memory_order_acquire ); 20 | if( !done ) 21 | { 22 | int expected = 0; 23 | while( !RpInitLock.compare_exchange_weak( expected, 1, std::memory_order_release, std::memory_order_relaxed ) ) { expected = 0; YieldThread(); } 24 | const auto done = RpInitDone.load( std::memory_order_acquire ); 25 | if( !done ) 26 | { 27 | rpmalloc_initialize(); 28 | RpInitDone.store( 1, std::memory_order_release ); 29 | } 30 | RpInitLock.store( 0, std::memory_order_release ); 31 | } 32 | rpmalloc_thread_initialize(); 33 | RpThreadInitDone = true; 34 | } 35 | 36 | TRACY_API void InitRpmalloc() 37 | { 38 | if( !RpThreadInitDone ) InitRpmallocPlumbing(); 39 | } 40 | 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_STANDARD 20) 2 | 3 | option(EXTERNAL_PYBIND11 "Whether to download pybind11" ON) 4 | 5 | if(EXTERNAL_PYBIND11) 6 | find_package(Python 3.6 COMPONENTS Interpreter Development REQUIRED) 7 | 8 | include(FetchContent) 9 | 10 | FetchContent_Declare(pybind11 GIT_REPOSITORY "https://github.com/pybind/pybind11.git" GIT_TAG "v2.13.6" GIT_SHALLOW ON) 11 | FetchContent_MakeAvailable(pybind11) 12 | endif() 13 | 14 | set(BUFFER_SIZE 128 CACHE STRING "The size of the pointer buffer") 15 | set(NAME_LENGTH 128 CACHE STRING "The length of a name in the buffer") 16 | 17 | pybind11_add_module(TracyClientBindings SHARED bindings/Module.cpp) 18 | target_link_libraries(TracyClientBindings PUBLIC TracyClient) 19 | target_link_libraries(TracyClientBindings PUBLIC ${Python_LIBRARIES}) 20 | target_compile_definitions(TracyClientBindings PUBLIC BUFFER_SIZE=${BUFFER_SIZE}) 21 | target_compile_definitions(TracyClientBindings PUBLIC NAME_LENGTH=${NAME_LENGTH}) 22 | 23 | if (UNIX) 24 | set_target_properties(TracyClientBindings PROPERTIES 25 | BUILD_RPATH_USE_ORIGIN TRUE 26 | INSTALL_RPATH "\$ORIGIN/lib") 27 | endif () 28 | 29 | install(TARGETS TracyClientBindings 30 | RUNTIME DESTINATION . 31 | LIBRARY DESTINATION . 32 | ) 33 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyLlmChat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYLLMCHAT_HPP__ 2 | #define __TRACYLLMCHAT_HPP__ 3 | 4 | #include 5 | 6 | #include "TracyMarkdown.hpp" 7 | 8 | namespace tracy 9 | { 10 | 11 | class TracyLlmChat 12 | { 13 | public: 14 | static constexpr const char* ForgetMsg = "\n..."; 15 | 16 | enum class TurnRole 17 | { 18 | User, 19 | UserDebug, 20 | Attachment, 21 | Assistant, 22 | AssistantDebug, 23 | Error, 24 | // virtual roles below 25 | Trash, 26 | Regenerate, 27 | None, 28 | }; 29 | 30 | TracyLlmChat(); 31 | ~TracyLlmChat(); 32 | 33 | void Begin(); 34 | void End(); 35 | 36 | bool Turn( TurnRole role, const std::string& content ); 37 | 38 | private: 39 | void NormalScope(); 40 | void ThinkScope(); 41 | 42 | void PrintThink( const char* str, size_t size ); 43 | void PrintToolCall( const char* str, size_t size ); 44 | 45 | float* m_width; 46 | float m_maxWidth; 47 | 48 | TurnRole m_role; 49 | bool m_thinkActive; 50 | bool m_thinkOpen; 51 | int m_thinkIdx; 52 | int m_subIdx; 53 | int m_roleIdx; 54 | 55 | Markdown m_markdown; 56 | }; 57 | 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /examples/ToyPathTracer/license.md: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracySourceContents.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSOURCECONTENTS_HPP__ 2 | #define __TRACYSOURCECONTENTS_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "TracySourceTokenizer.hpp" 9 | 10 | namespace tracy 11 | { 12 | 13 | class View; 14 | class Worker; 15 | 16 | class SourceContents 17 | { 18 | public: 19 | SourceContents(); 20 | ~SourceContents(); 21 | 22 | void Parse( const char* fileName, const Worker& worker, const View& view ); 23 | void Parse( const char* source ); 24 | void Parse( const char* source, size_t len ); 25 | 26 | const std::vector& get() const { return m_lines; } 27 | bool empty() const { return m_lines.empty(); } 28 | 29 | const char* filename() const { return m_file; } 30 | uint32_t idx() const { return m_fileStringIdx; } 31 | bool is_cached() const { return m_data != m_dataBuf; } 32 | const char* data() const { return m_data; } 33 | size_t data_size() const { return m_dataSize; } 34 | 35 | private: 36 | void Tokenize( const char* txt, size_t sz ); 37 | 38 | const char* m_file; 39 | uint32_t m_fileStringIdx; 40 | 41 | const char* m_data; 42 | size_t m_dataSize; 43 | 44 | char* m_dataBuf; 45 | size_t m_dataBufSize; 46 | 47 | std::vector m_lines; 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyTimelineItemPlot.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTIMELINEITEMPLOT_HPP__ 2 | #define __TRACYTIMELINEITEMPLOT_HPP__ 3 | 4 | #include "TracyEvent.hpp" 5 | #include "TracyTimelineDraw.hpp" 6 | #include "TracyTimelineItem.hpp" 7 | 8 | namespace tracy 9 | { 10 | 11 | class TimelineItemPlot final : public TimelineItem 12 | { 13 | public: 14 | TimelineItemPlot( View& view, Worker& worker, PlotData* plot ); 15 | 16 | protected: 17 | uint32_t HeaderColor() const override { return 0xFF44DDDD; } 18 | uint32_t HeaderColorInactive() const override { return 0xFF226E6E; } 19 | uint32_t HeaderLineColor() const override { return 0x8844DDDD; } 20 | const char* HeaderLabel() const override; 21 | 22 | int64_t RangeBegin() const override; 23 | int64_t RangeEnd() const override; 24 | 25 | void HeaderTooltip( const char* label ) const override; 26 | void HeaderExtraContents( const TimelineContext& ctx, int offset, float labelWidth ) override; 27 | 28 | bool DrawContents( const TimelineContext& ctx, int& offset ) override; 29 | void DrawFinished() override; 30 | 31 | bool IsEmpty() const override; 32 | 33 | void Preprocess( const TimelineContext& ctx, TaskDispatch& td, bool visible, int yPos ) override; 34 | 35 | private: 36 | PlotData* m_plot; 37 | 38 | std::vector m_draw; 39 | bool m_rightEnd; 40 | }; 41 | 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyUserData.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYUSERDATA_HPP__ 2 | #define __TRACYUSERDATA_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace tracy 11 | { 12 | 13 | struct Annotation; 14 | struct SourceRegex; 15 | struct ViewData; 16 | 17 | class UserData 18 | { 19 | public: 20 | UserData(); 21 | UserData( const char* program, uint64_t time ); 22 | 23 | bool Valid() const { return !m_program.empty(); } 24 | void Init( const char* program, uint64_t time ); 25 | 26 | const std::string& GetDescription() const { return m_description; } 27 | bool SetDescription( const char* description ); 28 | 29 | void LoadState( ViewData& data ); 30 | void SaveState( const ViewData& data ); 31 | void StateShouldBePreserved(); 32 | 33 | void LoadAnnotations( std::vector>& data ); 34 | void SaveAnnotations( const std::vector>& data ); 35 | 36 | bool LoadSourceSubstitutions( std::vector& data ); 37 | void SaveSourceSubstitutions( const std::vector& data ); 38 | 39 | const char* GetConfigLocation() const; 40 | 41 | private: 42 | FILE* OpenFile( const char* filename, bool write ); 43 | void Remove( const char* filename ); 44 | 45 | std::string m_program; 46 | uint64_t m_time; 47 | 48 | std::string m_description; 49 | 50 | bool m_preserveState; 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /public/common/TracyAlloc.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYALLOC_HPP__ 2 | #define __TRACYALLOC_HPP__ 3 | 4 | #include 5 | 6 | #if defined TRACY_ENABLE && !defined __EMSCRIPTEN__ 7 | # include "TracyApi.h" 8 | # include "TracyForceInline.hpp" 9 | # include "../client/tracy_rpmalloc.hpp" 10 | # define TRACY_USE_RPMALLOC 11 | #endif 12 | 13 | namespace tracy 14 | { 15 | 16 | #ifdef TRACY_USE_RPMALLOC 17 | TRACY_API void InitRpmalloc(); 18 | #else 19 | static inline void InitRpmalloc() {} 20 | #endif 21 | 22 | static inline void* tracy_malloc( size_t size ) 23 | { 24 | #ifdef TRACY_USE_RPMALLOC 25 | InitRpmalloc(); 26 | return rpmalloc( size ); 27 | #else 28 | return malloc( size ); 29 | #endif 30 | } 31 | 32 | static inline void* tracy_malloc_fast( size_t size ) 33 | { 34 | #ifdef TRACY_USE_RPMALLOC 35 | return rpmalloc( size ); 36 | #else 37 | return malloc( size ); 38 | #endif 39 | } 40 | 41 | static inline void tracy_free( void* ptr ) 42 | { 43 | #ifdef TRACY_USE_RPMALLOC 44 | InitRpmalloc(); 45 | rpfree( ptr ); 46 | #else 47 | free( ptr ); 48 | #endif 49 | } 50 | 51 | static inline void tracy_free_fast( void* ptr ) 52 | { 53 | #ifdef TRACY_USE_RPMALLOC 54 | rpfree( ptr ); 55 | #else 56 | free( ptr ); 57 | #endif 58 | } 59 | 60 | static inline void* tracy_realloc( void* ptr, size_t size ) 61 | { 62 | #ifdef TRACY_USE_RPMALLOC 63 | InitRpmalloc(); 64 | return rprealloc( ptr, size ); 65 | #else 66 | return realloc( ptr, size ); 67 | #endif 68 | } 69 | 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /manual/tracy.bib: -------------------------------------------------------------------------------- 1 | @inproceedings{Abel19a, 2 | title = {uops.info: Characterizing Latency, Throughput, and Port Usage of Instructions on Intel Microarchitectures}, 3 | acmid = {3304062}, 4 | address = {New York, NY, USA}, 5 | author = {Abel, Andreas and Reineke, Jan}, 6 | booktitle = {ASPLOS}, 7 | doi = {10.1145/3297858.3304062}, 8 | isbn = {978-1-4503-6240-5}, 9 | location = {Providence, RI, USA}, 10 | numpages = {14}, 11 | pages = {673--686}, 12 | publisher = {ACM}, 13 | series = {ASPLOS '19}, 14 | year = {2019}, 15 | url = {http://doi.acm.org/10.1145/3297858.3304062} 16 | }, 17 | @book{ISO:2012:III, 18 | added-at = {2012-10-08T01:13:47.000+0200}, 19 | address = {Geneva, Switzerland}, 20 | author = {{ISO}}, 21 | bibdate = {Mon Dec 19 11:12:12 2011}, 22 | bibsource = {http://www.math.utah.edu/pub/tex/bib/isostd.bib}, 23 | biburl = {https://www.bibsonomy.org/bibtex/24b660c16d9a5ab0ad595b1555402c797/gron}, 24 | day = 28, 25 | interhash = {ff5df6d7fa67f89d7d5ea964dab3e3c9}, 26 | intrahash = {4b660c16d9a5ab0ad595b1555402c797}, 27 | keywords = {C++ Specification Standard}, 28 | month = feb, 29 | pages = {1338 (est.)}, 30 | publisher = {International Organization for Standardization}, 31 | remark = {Revises ISO/IEC 14882:2003.}, 32 | timestamp = {2012-10-08T01:13:47.000+0200}, 33 | title = {{ISO/IEC 14882:2011 Information technology --- Programming languages --- C++}}, 34 | url = {http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372}, 35 | year = 2012 36 | } 37 | -------------------------------------------------------------------------------- /examples/ToyPathTracer/Windows/TestCpu.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30907.101 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpu", "TestCpu.vcxproj", "{4F84B756-87F5-4B92-827B-DA087DAE1900}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|x64.ActiveCfg = Debug|x64 17 | {4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|x64.Build.0 = Debug|x64 18 | {4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|x86.ActiveCfg = Debug|Win32 19 | {4F84B756-87F5-4B92-827B-DA087DAE1900}.Debug|x86.Build.0 = Debug|Win32 20 | {4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|x64.ActiveCfg = Release|x64 21 | {4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|x64.Build.0 = Release|x64 22 | {4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|x86.ActiveCfg = Release|Win32 23 | {4F84B756-87F5-4B92-827B-DA087DAE1900}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {067FB780-37B8-465E-AD7E-E7B238B9C04F} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyConfig.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYCONFIG_HPP__ 2 | #define __TRACYCONFIG_HPP__ 3 | 4 | #include 5 | 6 | #include "TracyUtility.hpp" 7 | 8 | namespace tracy 9 | { 10 | 11 | struct Config 12 | { 13 | bool threadedRendering = true; 14 | bool focusLostLimit = true; 15 | int targetFps = 60; 16 | bool drawFrameTargets = false; 17 | double horizontalScrollMultiplier = 1.0; 18 | double verticalScrollMultiplier = 1.0; 19 | bool memoryLimit = false; 20 | int memoryLimitPercent = 80; 21 | bool achievements = false; 22 | bool achievementsAsked = false; 23 | int dynamicColors = 1; 24 | bool forceColors = false; 25 | bool ghostZones = true; 26 | int shortenName = (int)ShortenName::NoSpaceAndNormalize; 27 | bool drawSamples = true; 28 | bool drawContextSwitches = true; 29 | int plotHeight = 100; 30 | bool saveUserScale = false; 31 | float userScale = 1.0f; 32 | 33 | // LLM assistant settings 34 | #ifdef __EMSCRIPTEN__ 35 | bool llm = false; 36 | #else 37 | bool llm = true; 38 | #endif 39 | std::string llmAddress = "http://localhost:11434"; 40 | std::string llmModel; 41 | std::string llmEmbeddingsModel; 42 | std::string llmUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36"; 43 | std::string llmSearchIdentifier; 44 | std::string llmSearchApiKey; 45 | }; 46 | 47 | extern Config s_config; 48 | 49 | void LoadConfig(); 50 | bool SaveConfig(); 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyTimelineItemCpuData.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTIMELINEITEMCPUDATA_HPP__ 2 | #define __TRACYTIMELINEITEMCPUDATA_HPP__ 3 | 4 | #include "TracyEvent.hpp" 5 | #include "TracyTimelineItem.hpp" 6 | #include "TracyTimelineDraw.hpp" 7 | 8 | namespace tracy 9 | { 10 | 11 | class TimelineItemCpuData final : public TimelineItem 12 | { 13 | public: 14 | TimelineItemCpuData( View& view, Worker& worker, void* key ); 15 | 16 | void SetVisible( bool visible ) override; 17 | bool IsVisible() const override; 18 | 19 | protected: 20 | uint32_t HeaderColor() const override { return 0xFFDD88DD; } 21 | uint32_t HeaderColorInactive() const override { return 0xFF6E446E; } 22 | uint32_t HeaderLineColor() const override { return 0x66DD88DD; } 23 | const char* HeaderLabel() const override { return "CPU data"; } 24 | 25 | int64_t RangeBegin() const override; 26 | int64_t RangeEnd() const override; 27 | 28 | bool DrawContents( const TimelineContext& ctx, int& offset ) override; 29 | void DrawFinished() override; 30 | 31 | bool IsEmpty() const override; 32 | 33 | void Preprocess( const TimelineContext& ctx, TaskDispatch& td, bool visible, int yPos ) override; 34 | 35 | private: 36 | void PreprocessCpuUsage( const TimelineContext& ctx ); 37 | void PreprocessCpuCtxSwitches( const TimelineContext& ctx, const Vector& cs, std::vector& out ); 38 | 39 | std::vector m_cpuDraw; 40 | std::vector> m_ctxDraw; 41 | 42 | bool m_hasCpuData; 43 | }; 44 | 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /public/libbacktrace/LICENSE: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012-2016 Free Software Foundation, Inc. 2 | 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are 5 | # met: 6 | 7 | # (1) Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | 10 | # (2) Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in 12 | # the documentation and/or other materials provided with the 13 | # distribution. 14 | 15 | # (3) The name of the author may not be used to 16 | # endorse or promote products derived from this software without 17 | # specific prior written permission. 18 | 19 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 23 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 28 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | # POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /server/TracyCharUtil.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACY__CHARUTIL_HPP__ 2 | #define __TRACY__CHARUTIL_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define XXH_INLINE_ALL 9 | #include "tracy_xxhash.h" 10 | 11 | namespace tracy 12 | { 13 | namespace charutil 14 | { 15 | 16 | static inline size_t hash( const char* str ) 17 | { 18 | const auto sz = strlen( str ); 19 | return XXH3_64bits( str, sz ); 20 | } 21 | 22 | static inline size_t hash( const char* str, size_t sz ) 23 | { 24 | return XXH3_64bits( str, sz ); 25 | } 26 | 27 | struct Hasher 28 | { 29 | size_t operator()( const char* key ) const 30 | { 31 | return hash( key ); 32 | } 33 | }; 34 | 35 | struct Comparator 36 | { 37 | bool operator()( const char* lhs, const char* rhs ) const 38 | { 39 | return strcmp( lhs, rhs ) == 0; 40 | } 41 | }; 42 | 43 | struct LessComparator 44 | { 45 | bool operator()( const char* lhs, const char* rhs ) const 46 | { 47 | return strcmp( lhs, rhs ) < 0; 48 | } 49 | }; 50 | 51 | struct StringKey 52 | { 53 | const char* ptr; 54 | size_t sz; 55 | 56 | struct Hasher 57 | { 58 | size_t operator()( const StringKey& key ) const 59 | { 60 | return hash( key.ptr, key.sz ); 61 | } 62 | }; 63 | 64 | struct Comparator 65 | { 66 | bool operator()( const StringKey& lhs, const StringKey& rhs ) const 67 | { 68 | return lhs.sz == rhs.sz && memcmp( lhs.ptr, rhs.ptr, lhs.sz ) == 0; 69 | } 70 | }; 71 | }; 72 | 73 | } 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /cmake/tidy-cmake.patch: -------------------------------------------------------------------------------- 1 | diff --git i/CMakeLists.txt w/CMakeLists.txt 2 | index 8efec25..c1d101e 100644 3 | --- i/CMakeLists.txt 4 | +++ w/CMakeLists.txt 5 | @@ -17,7 +17,7 @@ 6 | # @date Consult git log. 7 | ############################################################################## 8 | 9 | -cmake_minimum_required (VERSION 2.8.12) 10 | +cmake_minimum_required (VERSION 3.10) 11 | 12 | set(LIB_NAME tidy) 13 | set(LIBTIDY_DESCRIPTION "${LIB_NAME} - HTML syntax checker") 14 | @@ -528,6 +528,7 @@ if (UNIX AND SUPPORT_CONSOLE_APP) 15 | 16 | # Run the built EXE to generate xml output . 17 | add_custom_command( 18 | + POST_BUILD 19 | TARGET man 20 | COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME} -xml-help > ${TIDYHELP} 21 | COMMENT "Generate ${TIDYHELP}" 22 | @@ -536,6 +537,7 @@ if (UNIX AND SUPPORT_CONSOLE_APP) 23 | 24 | # Run the built EXE to generate more xml output. 25 | add_custom_command( 26 | + POST_BUILD 27 | TARGET man 28 | COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME} -xml-config > ${TIDYCONFIG} 29 | COMMENT "Generate ${TIDYCONFIG}" 30 | @@ -544,8 +546,8 @@ if (UNIX AND SUPPORT_CONSOLE_APP) 31 | 32 | # Run xsltproc to generate the install files. 33 | add_custom_command( 34 | + POST_BUILD 35 | TARGET man 36 | - DEPENDS ${TIDYHELP} 37 | COMMAND xsltproc ARGS ${TIDY1XSL} ${TIDYHELP} > ${CMAKE_CURRENT_BINARY_DIR}/${TIDY_MANFILE} 38 | COMMENT "Generate ${TIDY_MANFILE}" 39 | VERBATIM 40 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyLlmApi.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYLLMAPI_HPP__ 2 | #define __TRACYLLMAPI_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace tracy 11 | { 12 | 13 | struct LlmModel 14 | { 15 | std::string name; 16 | std::string quant; 17 | int contextSize = -1; 18 | bool embeddings = false; 19 | }; 20 | 21 | class TracyLlmApi 22 | { 23 | enum class Type 24 | { 25 | Unknown, 26 | Ollama, 27 | LmStudio, 28 | LlamaSwap, 29 | Other 30 | }; 31 | 32 | public: 33 | ~TracyLlmApi(); 34 | 35 | bool Connect( const char* url ); 36 | bool ChatCompletion( const nlohmann::json& req, const std::function& callback, int modelIdx ); 37 | bool Embeddings( const nlohmann::json& req, nlohmann::json& response, bool separateConnection = false ); 38 | [[nodiscard]] int Tokenize( const std::string& text, int modelIdx ); 39 | 40 | [[nodiscard]] bool IsConnected() const { return m_curl != nullptr; } 41 | [[nodiscard]] const std::vector& GetModels() const { return m_models; } 42 | 43 | private: 44 | void SetupCurl( void* curl ); 45 | 46 | int64_t GetRequest( const std::string& url, std::string& response ); 47 | int64_t PostRequest( const std::string& url, const std::string& data, std::string& response, bool separateConnection = false ); 48 | 49 | void* m_curl = nullptr; 50 | std::string m_url; 51 | Type m_type; 52 | 53 | std::vector m_models; 54 | }; 55 | 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /extra/identify.cpp: -------------------------------------------------------------------------------- 1 | // g++ identify.cpp -lpthread ../public/common/tracy_lz4.cpp ../zstd/common/*.c ../zstd/decompress/*.c ../zstd/decompress/huf_decompress_amd64.S 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../server/TracyFileRead.hpp" 8 | #include "../public/common/TracyVersion.hpp" 9 | 10 | static const uint8_t FileHeader[8] { 't', 'r', 'a', 'c', 'y', tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch }; 11 | enum { FileHeaderMagic = 5 }; 12 | 13 | int main( int argc, char** argv ) 14 | { 15 | if( argc != 2 ) 16 | { 17 | fprintf( stderr, "Usage: %s trace\n", argv[0] ); 18 | return -1; 19 | } 20 | 21 | try 22 | { 23 | std::unique_ptr f( tracy::FileRead::Open( argv[1] ) ); 24 | if( !f ) 25 | { 26 | fprintf( stderr, "%s: Cannot open!\n", argv[1] ); 27 | return -2; 28 | } 29 | 30 | uint8_t hdr[8]; 31 | f->Read( hdr, sizeof( hdr ) ); 32 | if( memcmp( FileHeader, hdr, FileHeaderMagic ) != 0 ) 33 | { 34 | fprintf( stderr, "%s: Bad header!\n", argv[1] ); 35 | return -3; 36 | } 37 | 38 | printf( "%s: %i.%i.%i\n", argv[1], hdr[FileHeaderMagic], hdr[FileHeaderMagic+1], hdr[FileHeaderMagic+2] ); 39 | } 40 | catch( const tracy::NotTracyDump& ) 41 | { 42 | fprintf( stderr, "%s: Not a tracy dump!\n", argv[1] ); 43 | return -4; 44 | } 45 | catch( const tracy::FileReadError& ) 46 | { 47 | fprintf( stderr, "%s: File read error!\n", argv[1] ); 48 | return -5; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /python/bindings/NameBuffer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef BUFFER_SIZE 9 | #define BUFFER_SIZE = 128 10 | #endif 11 | 12 | #ifndef NAME_LENGTH 13 | #define NAME_LENGTH = 128 14 | #endif 15 | 16 | using OptionalNumber = std::optional; 17 | using BufferEntry = std::pair; 18 | 19 | class NameBuffer { 20 | public: 21 | static inline BufferEntry Add(const std::string& name) { 22 | return getBuffer().add(name); 23 | } 24 | 25 | static inline const char* Get(std::size_t index) { 26 | return getBuffer().get(index); 27 | } 28 | 29 | private: 30 | NameBuffer() : m_buffer(BUFFER_SIZE, nullptr), m_index(0ul) { 31 | for (std::size_t index = 0ul, end = m_buffer.size(); index < end; ++index) 32 | m_buffer[index] = new char[NAME_LENGTH]; 33 | } 34 | 35 | std::mutex m_mutex; 36 | std::vector m_buffer; 37 | std::size_t m_index; 38 | 39 | static inline NameBuffer& getBuffer() { 40 | static NameBuffer buffer; 41 | return buffer; 42 | } 43 | 44 | BufferEntry add(const std::string& name) { 45 | std::lock_guard lock(m_mutex); 46 | if (m_index >= BUFFER_SIZE || name.size() > NAME_LENGTH) 47 | return std::make_pair(std::nullopt, nullptr); 48 | 49 | auto index = m_index++; 50 | name.copy(m_buffer[index], name.size()); 51 | return std::make_pair(index, m_buffer[index]); 52 | } 53 | 54 | const char* get(std::size_t index) { 55 | std::lock_guard lock(m_mutex); 56 | if (index >= BUFFER_SIZE) return nullptr; 57 | return m_buffer[index]; 58 | } 59 | }; 60 | -------------------------------------------------------------------------------- /server/TracyThreadCompress.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACY__THREADCOMPRESS_HPP__ 2 | #define __TRACY__THREADCOMPRESS_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | #include "../public/common/TracyForceInline.hpp" 8 | #include "tracy_robin_hood.h" 9 | #include "TracyVector.hpp" 10 | 11 | namespace tracy 12 | { 13 | 14 | class FileRead; 15 | class FileWrite; 16 | 17 | class ThreadCompress 18 | { 19 | public: 20 | ThreadCompress(); 21 | 22 | void InitZero(); 23 | void Load( FileRead& f ); 24 | void Save( FileWrite& f ) const; 25 | 26 | tracy_force_inline uint16_t CompressThread( uint64_t thread ) 27 | { 28 | if( m_threadLast.first == thread ) return m_threadLast.second; 29 | return CompressThreadReal( thread ); 30 | } 31 | 32 | tracy_force_inline uint64_t DecompressThread( uint16_t thread ) const 33 | { 34 | assert( thread < m_threadExpand.size() ); 35 | return m_threadExpand[thread]; 36 | } 37 | 38 | tracy_force_inline uint16_t DecompressMustRaw( uint64_t thread ) const 39 | { 40 | auto it = m_threadMap.find( thread ); 41 | assert( it != m_threadMap.end() ); 42 | return it->second; 43 | } 44 | 45 | tracy_force_inline bool Exists( uint64_t thread ) const 46 | { 47 | return m_threadMap.find( thread ) != m_threadMap.end(); 48 | } 49 | 50 | private: 51 | uint16_t CompressThreadReal( uint64_t thread ); 52 | uint16_t CompressThreadNew( uint64_t thread ); 53 | 54 | unordered_flat_map m_threadMap; 55 | Vector m_threadExpand; 56 | std::pair m_threadLast; 57 | }; 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # Empirical format config, based on observed style guide 2 | # Use this only as an help to fit the surrounding code style - don't reformat whole files at once 3 | --- 4 | BasedOnStyle: Microsoft 5 | AllowShortIfStatementsOnASingleLine: AllIfsAndElse 6 | AllowShortLoopsOnASingleLine: true 7 | AllowShortCaseLabelsOnASingleLine: true 8 | AllowShortFunctionsOnASingleLine: All 9 | # AllowShortEnumsOnASingleLine: true # Broken for some reason, even in last versions of clang-format... So don't use it or it may change formating in the future. 10 | AllowShortLambdasOnASingleLine: All 11 | BreakConstructorInitializers: BeforeComma 12 | BreakStringLiterals: false 13 | SpaceAfterTemplateKeyword: false 14 | AlwaysBreakTemplateDeclarations: Yes 15 | # Allman seems to break lambda formatting for some reason with `ColumnLimit: 0`. See https://github.com/llvm/llvm-project/issues/50275 16 | # Even though it is supposed to have been fixed, issue still remains in 20.1.8. (and is very much present in 18.x which is the one shipped by VS2022 and VSCord clangd as of 2025-07-27) 17 | # Things work fine with `BasedOnStyle: Microsoft` so use that instead 18 | #BreakBeforeBraces: Allman 19 | ColumnLimit: 0 20 | # We'd like to use LeftWithLastLine but it's only available in >=19.x 21 | #AlignEscapedNewlines: LeftWithLastLine 22 | AlignEscapedNewlines: Left 23 | FixNamespaceComments: false 24 | IndentPPDirectives: AfterHash 25 | IndentAccessModifiers: false 26 | AccessModifierOffset: -4 27 | LambdaBodyIndentation: OuterScope 28 | PPIndentWidth: 2 29 | IndentWidth: 4 30 | PointerAlignment: Left 31 | SpaceBeforeParens: Never 32 | SpacesInParentheses: true 33 | TabWidth: 4 34 | AlignTrailingComments: 35 | Kind: Leave 36 | -------------------------------------------------------------------------------- /icon/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | image/svg+xml 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Tracy Profiler (https://github.com/wolfpld/tracy) is licensed under the 2 | 3-clause BSD license. 3 | 4 | Copyright (c) 2017-2025, Bartosz Taudul 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the nor the 15 | names of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracySourceTokenizer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSOURCETOKENIZER_HPP__ 2 | #define __TRACYSOURCETOKENIZER_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | namespace tracy 8 | { 9 | 10 | class Tokenizer 11 | { 12 | public: 13 | enum class TokenColor : uint8_t 14 | { 15 | Default, 16 | Comment, 17 | Preprocessor, 18 | String, 19 | CharacterLiteral, 20 | Keyword, 21 | Number, 22 | Punctuation, 23 | Type, 24 | Special 25 | }; 26 | 27 | struct Token 28 | { 29 | const char* begin; 30 | const char* end; 31 | TokenColor color; 32 | }; 33 | 34 | struct Line 35 | { 36 | const char* begin; 37 | const char* end; 38 | std::vector tokens; 39 | }; 40 | 41 | enum class AsmTokenColor : uint8_t 42 | { 43 | Label, // no-op, padding 44 | Default, // '+', '[', '*', etc 45 | SizeDirective, // byte, word, dword, etc 46 | Register, // rax, rip, etc 47 | Literal, // 0x04, etc 48 | }; 49 | 50 | struct AsmToken 51 | { 52 | const char* begin; 53 | const char* end; 54 | AsmTokenColor color; 55 | }; 56 | 57 | Tokenizer(); 58 | 59 | std::vector Tokenize( const char* begin, const char* end ); 60 | std::vector TokenizeAsm( const char* begin, const char* end ); 61 | 62 | private: 63 | TokenColor IdentifyToken( const char*& begin, const char* end ); 64 | AsmTokenColor IdentifyAsmToken( const char*& begin, const char* end ); 65 | 66 | bool m_isInComment; 67 | bool m_isInPreprocessor; 68 | }; 69 | 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyAchievements.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYACHIEVEMENTS_HPP__ 2 | #define __TRACYACHIEVEMENTS_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "imgui.h" 9 | 10 | #include "TracyCharUtil.hpp" 11 | #include "tracy_robin_hood.h" 12 | 13 | namespace tracy 14 | { 15 | 16 | namespace data 17 | { 18 | 19 | struct AchievementItem 20 | { 21 | const char* id; 22 | const char* name; 23 | void(*description)(); 24 | AchievementItem** items; 25 | AchievementItem** unlocks; 26 | bool keepOpen; 27 | uint64_t unlockTime; 28 | uint64_t doneTime; 29 | bool hideCompleted; 30 | bool hideNew; 31 | }; 32 | 33 | struct AchievementCategory 34 | { 35 | const char* id; 36 | const char* name; 37 | AchievementItem** items; 38 | uint64_t unlockTime; 39 | }; 40 | 41 | } 42 | 43 | class AchievementsMgr 44 | { 45 | struct AchievementPair 46 | { 47 | data::AchievementItem* item; 48 | data::AchievementCategory* category; 49 | }; 50 | 51 | public: 52 | AchievementsMgr(); 53 | ~AchievementsMgr(); 54 | 55 | void Achieve( const char* id ); 56 | data::AchievementCategory** GetCategories() const; 57 | data::AchievementCategory* GetCategoryForAchievement( const char* id ) const; 58 | 59 | data::AchievementItem* GetNextQueue(); 60 | void PopQueue(); 61 | 62 | bool NeedsAttention() const; 63 | bool CategoryNeedsAttention( const char* id ) const; 64 | 65 | private: 66 | void FillMap( data::AchievementItem** items, data::AchievementCategory* category ); 67 | void Save(); 68 | 69 | std::vector m_queue; 70 | tracy::unordered_flat_map m_map; 71 | }; 72 | 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /profiler/src/ResolvService.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _WIN32 2 | # include 3 | #else 4 | # ifdef __FreeBSD__ 5 | # include 6 | # endif 7 | # include 8 | # include 9 | # include 10 | #endif 11 | 12 | #include "ResolvService.hpp" 13 | 14 | ResolvService::ResolvService( uint16_t port ) 15 | : m_exit( false ) 16 | , m_port( port ) 17 | #ifndef __EMSCRIPTEN__ 18 | , m_thread( [this] { Worker(); } ) 19 | #endif 20 | { 21 | } 22 | 23 | ResolvService::~ResolvService() 24 | { 25 | #ifndef __EMSCRIPTEN__ 26 | m_exit.store( true, std::memory_order_relaxed ); 27 | m_cv.notify_one(); 28 | m_thread.join(); 29 | #endif 30 | } 31 | 32 | void ResolvService::Query( uint32_t ip, const std::function& callback ) 33 | { 34 | #ifndef __EMSCRIPTEN__ 35 | std::lock_guard lock( m_lock ); 36 | m_queue.emplace_back( QueueItem { ip, callback } ); 37 | m_cv.notify_one(); 38 | #endif 39 | } 40 | 41 | void ResolvService::Worker() 42 | { 43 | struct sockaddr_in addr = {}; 44 | addr.sin_family = AF_INET; 45 | addr.sin_port = htons( m_port ); 46 | 47 | char buf[128]; 48 | 49 | for(;;) 50 | { 51 | std::unique_lock lock( m_lock ); 52 | m_cv.wait( lock, [this] { return !m_queue.empty() || m_exit.load( std::memory_order_relaxed ); } ); 53 | if( m_exit.load( std::memory_order_relaxed ) ) return; 54 | auto query = m_queue.back(); 55 | m_queue.pop_back(); 56 | lock.unlock(); 57 | 58 | addr.sin_addr.s_addr = query.ip; 59 | if( getnameinfo( (const struct sockaddr*)&addr, sizeof( sockaddr_in ), buf, 128, nullptr, 0, NI_NOFQDN ) != 0 ) 60 | { 61 | inet_ntop( AF_INET, &query.ip, buf, 17 ); 62 | } 63 | query.callback( buf ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /server/TracyThreadCompress.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "TracyFileRead.hpp" 4 | #include "TracyFileWrite.hpp" 5 | #include "TracyThreadCompress.hpp" 6 | 7 | namespace tracy 8 | { 9 | 10 | ThreadCompress::ThreadCompress() 11 | : m_threadLast( std::numeric_limits::max(), 0 ) 12 | { 13 | } 14 | 15 | void ThreadCompress::InitZero() 16 | { 17 | assert( m_threadExpand.empty() ); 18 | m_threadExpand.push_back( 0 ); 19 | } 20 | 21 | void ThreadCompress::Load( FileRead& f ) 22 | { 23 | assert( m_threadExpand.empty() ); 24 | assert( m_threadMap.empty() ); 25 | 26 | uint64_t sz; 27 | f.Read( sz ); 28 | if( sz != 0 ) 29 | { 30 | m_threadExpand.reserve_and_use( sz ); 31 | f.Read( m_threadExpand.data(), sizeof( uint64_t ) * sz ); 32 | m_threadMap.reserve( sz ); 33 | for( size_t i=0; isecond; 54 | return it->second; 55 | } 56 | else 57 | { 58 | return CompressThreadNew( thread ); 59 | } 60 | } 61 | 62 | uint16_t ThreadCompress::CompressThreadNew( uint64_t thread ) 63 | { 64 | auto sz = m_threadExpand.size(); 65 | m_threadExpand.push_back( thread ); 66 | m_threadMap.emplace( thread, sz ); 67 | m_threadLast.first = thread; 68 | m_threadLast.second = sz; 69 | return sz; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /profiler/src/winmain.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _WIN32 2 | # include 3 | # include 4 | # include 5 | # include 6 | 7 | namespace tracy 8 | { 9 | bool DiscoveryAVX(); 10 | bool DiscoveryAVX2(); 11 | } 12 | 13 | int main( int argc, char** argv ); 14 | 15 | int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd, int nCmd ) 16 | { 17 | { 18 | uint32_t regs[4]; 19 | __cpuidex( (int*)regs, 0, 0 ); 20 | const uint32_t maxLeaf = regs[0]; 21 | bool cpuHasAVX = false; 22 | bool cpuHasAVX2 = false; 23 | if( maxLeaf >= 1 ) 24 | { 25 | __cpuidex( (int*)regs, 1, 0 ); 26 | cpuHasAVX = ( regs[2] & 0x10000000 ) != 0; 27 | } 28 | if( maxLeaf >= 7 ) 29 | { 30 | __cpuidex( (int*)regs, 7, 0 ); 31 | cpuHasAVX2 = ( regs[1] & 0x00000020 ) != 0; 32 | } 33 | 34 | if( tracy::DiscoveryAVX2() && !cpuHasAVX2 ) 35 | { 36 | MessageBoxA( nullptr, "This program is compiled with AVX2 instruction set, but your CPU doesn't support it. You must recompile with lower instruction set.\n\nIn Visual Studio go to Project properties -> C/C++ -> Code Generation -> Enable Enhanced Instruction Set and select appropriate value for your CPU.", "Wrong CPU architecture", MB_ICONERROR ); 37 | return 0; 38 | } 39 | if( tracy::DiscoveryAVX() && !cpuHasAVX ) 40 | { 41 | MessageBoxA( nullptr, "This program is compiled with AVX instruction set, but your CPU doesn't support it. You must recompile with lower instruction set.\n\nIn Visual Studio go to Project properties -> C/C++ -> Code Generation -> Enable Enhanced Instruction Set and select appropriate value for your CPU.", "Wrong CPU architecture", MB_ICONERROR ); 42 | return 0; 43 | } 44 | } 45 | 46 | return main( __argc, __argv ); 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /extra/color-hot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | inline float linear2sRGB( float v ) 8 | { 9 | float s1 = sqrt( v ); 10 | float s2 = sqrt( s1 ); 11 | float s3 = sqrt( s2 ); 12 | return 0.585122381f * s1 + 0.783140355f * s2 - 0.368262736f * s3; 13 | } 14 | 15 | float lerp( float v0, float v1, float t ) 16 | { 17 | return ( 1-t ) * v0 + t * v1; 18 | } 19 | 20 | inline float sRGB2linear( float v ) 21 | { 22 | return v * ( v * ( v * 0.305306011f + 0.682171111f ) + 0.012522878f ); 23 | } 24 | 25 | int main() 26 | { 27 | int c0 = 0x3333FF; 28 | int c1 = 0x33FF33; 29 | 30 | uint32_t t[256] = {}; 31 | 32 | float r0 = ( c0 & 0xFF ) / 255.f; 33 | float r1 = ( c1 & 0xFF ) / 255.f; 34 | float g0 = ( ( c0 >> 8 ) & 0xFF ) / 255.f; 35 | float g1 = ( ( c1 >> 8 ) & 0xFF ) / 255.f; 36 | float b0 = ( ( c0 >> 16 ) & 0xFF ) / 255.f; 37 | float b1 = ( ( c1 >> 16 ) & 0xFF ) / 255.f; 38 | 39 | for( int i=0; i<256; i++ ) 40 | { 41 | float m = i / 255.f; 42 | float rf = linear2sRGB( lerp( sRGB2linear( r0 ), sRGB2linear( r1 ), m ) ); 43 | float gf = linear2sRGB( lerp( sRGB2linear( g0 ), sRGB2linear( g1 ), m ) ); 44 | float bf = linear2sRGB( lerp( sRGB2linear( b0 ), sRGB2linear( b1 ), m ) ); 45 | 46 | int r = (int)std::clamp( rf * 255.f, 0.f, 255.f ); 47 | int g = (int)std::clamp( gf * 255.f, 0.f, 255.f ); 48 | int b = (int)std::clamp( bf * 255.f, 0.f, 255.f ); 49 | 50 | t[i] = 0xFF000000 | ( b << 16 ) | ( g << 8 ) | r; 51 | } 52 | 53 | printf( "uint32_t GoodnessColor[256] = {\n" ); 54 | for( int i=0; i<256; i += 8 ) 55 | { 56 | printf( " " ); 57 | for( int j=i; j 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "TracySlab.hpp" 11 | 12 | struct ZSTD_CCtx_s; 13 | struct ZSTD_DCtx_s; 14 | struct ZSTD_CDict_s; 15 | struct ZSTD_DDict_s; 16 | 17 | namespace tracy 18 | { 19 | 20 | struct FrameImage; 21 | 22 | class TextureCompression 23 | { 24 | public: 25 | TextureCompression(); 26 | ~TextureCompression(); 27 | 28 | void SetDict( struct ZSTD_DDict_s* dict ) { m_dict = dict; } 29 | 30 | uint32_t Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes ); 31 | uint32_t Pack( struct ZSTD_CCtx_s* ctx, const struct ZSTD_CDict_s* dict, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes ); 32 | 33 | template 34 | const char* Pack( const char* image, uint32_t inBytes, uint32_t& csz, Slab& slab ) 35 | { 36 | const auto outsz = Pack( m_cctx, m_buf, m_bufSize, image, inBytes ); 37 | auto ptr = (char*)slab.AllocBig( outsz ); 38 | memcpy( ptr, m_buf, outsz ); 39 | csz = outsz; 40 | return ptr; 41 | } 42 | 43 | const char* Unpack( const FrameImage& image ); 44 | 45 | void Rdo( char* data, size_t blocks ); 46 | void FixOrder( char* data, size_t blocks ); 47 | 48 | uint64_t GetInputBytesCount() const { return m_inputBytes.load( std::memory_order_relaxed ); } 49 | uint64_t GetOutputBytesCount() const { return m_outputBytes.load( std::memory_order_relaxed ); } 50 | 51 | private: 52 | char* m_buf; 53 | size_t m_bufSize; 54 | struct ZSTD_CCtx_s* m_cctx; 55 | struct ZSTD_DCtx_s* m_dctx; 56 | struct ZSTD_DDict_s* m_dict; 57 | 58 | std::atomic m_inputBytes { 0 }; 59 | std::atomic m_outputBytes { 0 }; 60 | }; 61 | 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /public/client/TracyThread.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTHREAD_HPP__ 2 | #define __TRACYTHREAD_HPP__ 3 | 4 | #if defined _WIN32 5 | # include 6 | #else 7 | # include 8 | #endif 9 | 10 | #ifdef TRACY_MANUAL_LIFETIME 11 | # include "tracy_rpmalloc.hpp" 12 | #endif 13 | 14 | namespace tracy 15 | { 16 | 17 | #ifdef TRACY_MANUAL_LIFETIME 18 | extern thread_local bool RpThreadInitDone; 19 | #endif 20 | 21 | class ThreadExitHandler 22 | { 23 | public: 24 | ~ThreadExitHandler() 25 | { 26 | #ifdef TRACY_MANUAL_LIFETIME 27 | rpmalloc_thread_finalize( 1 ); 28 | RpThreadInitDone = false; 29 | #endif 30 | } 31 | }; 32 | 33 | #if defined _WIN32 34 | 35 | class Thread 36 | { 37 | public: 38 | Thread( void(*func)( void* ptr ), void* ptr ) 39 | : m_func( func ) 40 | , m_ptr( ptr ) 41 | , m_hnd( CreateThread( nullptr, 0, Launch, this, 0, nullptr ) ) 42 | {} 43 | 44 | ~Thread() 45 | { 46 | WaitForSingleObject( m_hnd, INFINITE ); 47 | CloseHandle( m_hnd ); 48 | } 49 | 50 | HANDLE Handle() const { return m_hnd; } 51 | 52 | private: 53 | static DWORD WINAPI Launch( void* ptr ) { ((Thread*)ptr)->m_func( ((Thread*)ptr)->m_ptr ); return 0; } 54 | 55 | void(*m_func)( void* ptr ); 56 | void* m_ptr; 57 | HANDLE m_hnd; 58 | }; 59 | 60 | #else 61 | 62 | class Thread 63 | { 64 | public: 65 | Thread( void(*func)( void* ptr ), void* ptr ) 66 | : m_func( func ) 67 | , m_ptr( ptr ) 68 | { 69 | pthread_create( &m_thread, nullptr, Launch, this ); 70 | } 71 | 72 | ~Thread() 73 | { 74 | pthread_join( m_thread, nullptr ); 75 | } 76 | 77 | pthread_t Handle() const { return m_thread; } 78 | 79 | private: 80 | static void* Launch( void* ptr ) { ((Thread*)ptr)->m_func( ((Thread*)ptr)->m_ptr ); return nullptr; } 81 | void(*m_func)( void* ptr ); 82 | void* m_ptr; 83 | pthread_t m_thread; 84 | }; 85 | 86 | #endif 87 | 88 | } 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyColor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYCOLOR_HPP__ 2 | #define __TRACYCOLOR_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | #include "../public/common/TracyForceInline.hpp" 8 | 9 | namespace tracy 10 | { 11 | 12 | uint32_t GetHsvColor( uint64_t hue, int value ); 13 | 14 | template 15 | static tracy_force_inline uint32_t HighlightColor( uint32_t color ) 16 | { 17 | return 0xFF000000 | 18 | ( std::min( 0xFF, ( ( ( color & 0x00FF0000 ) >> 16 ) + V ) ) << 16 ) | 19 | ( std::min( 0xFF, ( ( ( color & 0x0000FF00 ) >> 8 ) + V ) ) << 8 ) | 20 | ( std::min( 0xFF, ( ( ( color & 0x000000FF ) ) + V ) ) ); 21 | } 22 | 23 | static tracy_force_inline uint32_t DarkenColorSlightly( uint32_t color ) 24 | { 25 | return 0xFF000000 | 26 | ( ( ( ( color & 0x00FF0000 ) >> 16 ) * 4 / 5 ) << 16 ) | 27 | ( ( ( ( color & 0x0000FF00 ) >> 8 ) * 4 / 5 ) << 8 ) | 28 | ( ( ( ( color & 0x000000FF ) ) * 4 / 5 ) ); 29 | } 30 | 31 | static tracy_force_inline uint32_t DarkenColor( uint32_t color ) 32 | { 33 | return 0xFF000000 | 34 | ( ( ( ( color & 0x00FF0000 ) >> 16 ) * 2 / 3 ) << 16 ) | 35 | ( ( ( ( color & 0x0000FF00 ) >> 8 ) * 2 / 3 ) << 8 ) | 36 | ( ( ( ( color & 0x000000FF ) ) * 2 / 3 ) ); 37 | } 38 | 39 | static tracy_force_inline uint32_t DarkenColorHalf( uint32_t color ) 40 | { 41 | return 0xFF000000 | 42 | ( ( ( ( color & 0x00FF0000 ) >> 16 ) / 2 ) << 16 ) | 43 | ( ( ( ( color & 0x0000FF00 ) >> 8 ) / 2 ) << 8 ) | 44 | ( ( ( ( color & 0x000000FF ) ) / 2 ) ); 45 | } 46 | 47 | static tracy_force_inline uint32_t DarkenColorMore( uint32_t color ) 48 | { 49 | return 0xFF000000 | 50 | ( ( ( ( color & 0x00FF0000 ) >> 16 ) * 1 / 4 ) << 16 ) | 51 | ( ( ( ( color & 0x0000FF00 ) >> 8 ) * 1 / 4 ) << 8 ) | 52 | ( ( ( ( color & 0x000000FF ) ) * 1 / 4 ) ); 53 | } 54 | 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyTimelineController.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTIMELINECONTROLLER_HPP__ 2 | #define __TRACYTIMELINECONTROLLER_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "TracyImGui.hpp" 9 | #include "../server/TracyTaskDispatch.hpp" 10 | #include "../server/tracy_robin_hood.h" 11 | #include "../public/common/TracyForceInline.hpp" 12 | 13 | namespace tracy 14 | { 15 | 16 | class TimelineItem; 17 | class View; 18 | class Worker; 19 | 20 | class TimelineController 21 | { 22 | public: 23 | TimelineController( View& view, Worker& worker, bool threading ); 24 | ~TimelineController(); 25 | 26 | void FirstFrameExpired(); 27 | void Begin(); 28 | void End( double pxns, const ImVec2& wpos, bool hover, bool vcenter, float yMin, float yMax ); 29 | 30 | template 31 | void AddItem( U* data ) 32 | { 33 | auto it = m_itemMap.find( data ); 34 | if( it == m_itemMap.end() ) it = m_itemMap.emplace( data, std::make_unique( m_view, m_worker, data ) ).first; 35 | m_items.emplace_back( it->second.get() ); 36 | } 37 | 38 | float GetHeight() const { return m_height; } 39 | const unordered_flat_map>& GetItemMap() const { return m_itemMap; } 40 | 41 | tracy_force_inline TimelineItem& GetItem( const void* data ) 42 | { 43 | auto it = m_itemMap.find( data ); 44 | assert( it != m_itemMap.end() ); 45 | return *it->second; 46 | } 47 | 48 | private: 49 | void UpdateCenterItem(); 50 | std::optional CalculateScrollPosition() const; 51 | 52 | std::vector m_items; 53 | unordered_flat_map> m_itemMap; 54 | 55 | float m_height; 56 | float m_scroll; 57 | 58 | const void* m_centerItemkey; 59 | int m_centerItemOffsetY; 60 | 61 | bool m_firstFrame; 62 | 63 | View& m_view; 64 | Worker& m_worker; 65 | 66 | TaskDispatch m_td; 67 | }; 68 | 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyTimelineDraw.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTIMELINEDRAW_HPP__ 2 | #define __TRACYTIMELINEDRAW_HPP__ 3 | 4 | #include 5 | 6 | #include "TracyEvent.hpp" 7 | #include "TracyShortPtr.hpp" 8 | 9 | namespace tracy 10 | { 11 | 12 | enum class TimelineDrawType : uint8_t 13 | { 14 | Folded, 15 | Zone, 16 | GhostFolded, 17 | Ghost 18 | }; 19 | 20 | struct TimelineDraw 21 | { 22 | TimelineDrawType type; 23 | uint16_t depth; 24 | short_ptr ev; 25 | Int48 rend; 26 | uint32_t num; 27 | uint32_t inheritedColor; 28 | }; 29 | 30 | 31 | enum class ContextSwitchDrawType : uint8_t 32 | { 33 | Waiting, 34 | Folded, 35 | Running 36 | }; 37 | 38 | struct ContextSwitchDraw 39 | { 40 | ContextSwitchDrawType type; 41 | uint32_t idx; 42 | uint32_t data; // Folded: number of items -OR- Waiting: wait stack 43 | }; 44 | 45 | 46 | struct SamplesDraw 47 | { 48 | uint32_t num; 49 | uint32_t idx; 50 | }; 51 | 52 | 53 | struct MessagesDraw 54 | { 55 | short_ptr msg; 56 | bool highlight; 57 | uint32_t num; 58 | }; 59 | 60 | 61 | struct CpuUsageDraw 62 | { 63 | int own; 64 | int other; 65 | }; 66 | 67 | 68 | struct CpuCtxDraw 69 | { 70 | uint32_t idx; 71 | uint32_t num; 72 | }; 73 | 74 | 75 | 76 | struct LockState 77 | { 78 | enum Type : uint8_t 79 | { 80 | Nothing = 1 << 0, 81 | HasLock = 1 << 1, // green 82 | HasBlockingLock = 1 << 2, // yellow 83 | WaitLock = 1 << 3 // red 84 | }; 85 | }; 86 | 87 | struct LockDrawItem 88 | { 89 | Int48 t1; 90 | LockState::Type state; 91 | uint32_t condensed; 92 | short_ptr ptr, next; 93 | }; 94 | 95 | struct LockDraw 96 | { 97 | uint32_t id; 98 | bool forceDraw; 99 | uint8_t thread; 100 | std::vector data; 101 | }; 102 | 103 | } 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /dtl/dtl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | dtl -- Diff Template Library 3 | 4 | In short, Diff Template Library is distributed under so called "BSD license", 5 | 6 | Copyright (c) 2015 Tatsuhiko Kubo 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without modification, 10 | are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, 13 | this list of conditions and the following disclaimer. 14 | 15 | * Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | 19 | * Neither the name of the authors nor the names of its contributors 20 | may be used to endorse or promote products derived from this software 21 | without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #ifndef DTL_H 37 | #define DTL_H 38 | 39 | #include "variables.hpp" 40 | #include "functors.hpp" 41 | #include "Sequence.hpp" 42 | #include "Lcs.hpp" 43 | #include "Ses.hpp" 44 | #include "Diff.hpp" 45 | #include "Diff3.hpp" 46 | 47 | #endif // DTL_H 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tracy Profiler 2 | 3 | [![Sponsor](.github/sponsor.png)](https://github.com/sponsors/wolfpld/) 4 | 5 | ### A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications. 6 | 7 | Tracy supports profiling CPU (Direct support is provided for C, C++, Lua, Python and Fortran integration. At the same time, third-party bindings to many other languages exist on the internet, such as [Rust](https://github.com/nagisa/rust_tracy_client), [Zig](https://github.com/tealsnow/zig-tracy), [C#](https://github.com/clibequilibrium/Tracy-CSharp), [OCaml](https://github.com/imandra-ai/ocaml-tracy), [Odin](https://github.com/oskarnp/odin-tracy), etc.), GPU (All major graphic APIs: OpenGL, Vulkan, Direct3D 11/12, Metal, OpenCL, CUDA.), memory allocations, locks, context switches, automatically attribute screenshots to captured frames, and much more. 8 | 9 | - [Documentation](https://github.com/wolfpld/tracy/releases/latest/download/tracy.pdf) for usage and build process instructions 10 | - [Releases](https://github.com/wolfpld/tracy/releases) containing the documentation (`tracy.pdf`) and compiled Windows x64 binaries (`Tracy-.7z`) as assets 11 | - [Changelog](NEWS) 12 | - [Interactive demo](https://tracy.nereid.pl/) 13 | 14 | ![](doc/profiler.png) 15 | 16 | ![](doc/profiler2.png) 17 | 18 | ![](doc/profiler3.png) 19 | 20 | [An Introduction to Tracy Profiler in C++ - Marcos Slomp - CppCon 2023](https://youtu.be/ghXk3Bk5F2U?t=37) 21 | 22 | [Introduction to Tracy Profiler v0.2](https://www.youtube.com/watch?v=fB5B46lbapc) 23 | [New features in Tracy Profiler v0.3](https://www.youtube.com/watch?v=3SXpDpDh2Uo) 24 | [New features in Tracy Profiler v0.4](https://www.youtube.com/watch?v=eAkgkaO8B9o) 25 | [New features in Tracy Profiler v0.5](https://www.youtube.com/watch?v=P6E7qLMmzTQ) 26 | [New features in Tracy Profiler v0.6](https://www.youtube.com/watch?v=uJkrFgriuOo) 27 | [New features in Tracy Profiler v0.7](https://www.youtube.com/watch?v=_hU7vw00MZ4) 28 | [New features in Tracy Profiler v0.8](https://www.youtube.com/watch?v=30wpRpHTTag) 29 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyViewData.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYVIEWDATA_HPP__ 2 | #define __TRACYVIEWDATA_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | #include "TracyUtility.hpp" 8 | 9 | namespace tracy 10 | { 11 | 12 | struct Range 13 | { 14 | void StartFrame() { hiMin = hiMax = false; } 15 | 16 | int64_t min = 0; 17 | int64_t max = 0; 18 | bool active = false; 19 | bool hiMin = false; 20 | bool hiMax = false; 21 | bool modMin = false; 22 | bool modMax = false; 23 | }; 24 | 25 | struct RangeSlim 26 | { 27 | bool operator==( const Range& other ) const { return other.active == active && other.min == min && other.max == max; } 28 | bool operator!=( const Range& other ) const { return !(*this == other); } 29 | void operator=( const Range& other ) { active = other.active; min = other.min; max = other.max; } 30 | 31 | int64_t min, max; 32 | bool active = false; 33 | }; 34 | 35 | 36 | struct ViewData 37 | { 38 | int64_t zvStart = 0; 39 | int64_t zvEnd = 0; 40 | int32_t frameScale = 0; 41 | int32_t frameStart = 0; 42 | 43 | uint8_t drawGpuZones = true; 44 | uint8_t drawZones = true; 45 | uint8_t drawLocks = true; 46 | uint8_t drawPlots = true; 47 | uint8_t onlyContendedLocks = true; 48 | uint8_t drawEmptyLabels = false; 49 | uint8_t drawFrameTargets = false; 50 | uint8_t drawContextSwitches = true; 51 | uint8_t darkenContextSwitches = true; 52 | uint8_t drawCpuData = true; 53 | uint8_t drawCpuUsageGraph = true; 54 | uint8_t drawSamples = true; 55 | uint8_t dynamicColors = 1; 56 | uint8_t inheritParentColors = true; 57 | uint8_t forceColors = false; 58 | uint8_t ghostZones = true; 59 | ShortenName shortenName = ShortenName::NoSpaceAndNormalize; 60 | 61 | uint32_t frameTarget = 60; 62 | 63 | uint32_t plotHeight = 100; 64 | }; 65 | 66 | struct Annotation 67 | { 68 | std::string text; 69 | Range range; 70 | uint32_t color; 71 | }; 72 | 73 | struct SourceRegex 74 | { 75 | std::string pattern; 76 | std::string target; 77 | std::regex regex; 78 | }; 79 | 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /extra/color.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | inline float sqrtfast( float v ) 8 | { 9 | union 10 | { 11 | int i; 12 | float f; 13 | } u; 14 | 15 | u.f = v; 16 | u.i -= 1 << 23; 17 | u.i >>= 1; 18 | u.i += 1 << 29; 19 | return u.f; 20 | } 21 | 22 | inline float linear2sRGB( float v ) 23 | { 24 | float s1 = sqrtfast( v ); 25 | float s2 = sqrtfast( s1 ); 26 | float s3 = sqrtfast( s2 ); 27 | return 0.585122381f * s1 + 0.783140355f * s2 - 0.368262736f * s3; 28 | } 29 | 30 | int lerp( int v0, int v1, float t ) 31 | { 32 | return int( ( 1-t ) * v0 + t * v1 ); 33 | } 34 | 35 | inline float sRGB2linear( float v ) 36 | { 37 | return v * ( v * ( v * 0.305306011f + 0.682171111f ) + 0.012522878f ); 38 | } 39 | 40 | int main() 41 | { 42 | int c0 = std::min( 255, int( sRGB2linear( 1.f ) * 255 ) ); 43 | int c1 = std::min( 255, int( sRGB2linear( 0x44 / 255.f ) * 255 ) ); 44 | 45 | int s0 = std::min( 255, int( sRGB2linear( 1.f ) * 255 * 0.5 ) ); 46 | int s1 = std::min( 255, int( sRGB2linear( 0x44 / 255.f ) * 255 * 0.5 ) ); 47 | 48 | float target = 80.f; 49 | 50 | uint32_t t[256]; 51 | memset( t, 0, sizeof( uint32_t ) * 256 ); 52 | 53 | for( int i=1; i<128; i++ ) 54 | { 55 | float m = (i-1) / target; 56 | int l0 = std::min( 255, lerp( s0, c0, m ) ); 57 | int l1 = std::min( 255, lerp( s1, c1, m ) ); 58 | int g0 = std::min( 255, int( linear2sRGB( l0/255.f ) * 255 ) ); 59 | int g1 = std::min( 255, int( linear2sRGB( l1/255.f ) * 255 ) ); 60 | g0 = l0; 61 | g1 = l1; 62 | t[i] = 0xFF000000 | ( g1 << 16 ) | ( g0 << 8 ) | g1; 63 | t[uint8_t(-i)] = 0xFF000000 | ( g1 << 16 ) | ( g1 << 8 ) | g0; 64 | } 65 | 66 | printf( "uint32_t MemDecayColor[256] = {\n" ); 67 | for( int i=0; i<256; i += 8 ) 68 | { 69 | printf( " " ); 70 | for( int j=i; j 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without modification, 10 | are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, 13 | this list of conditions and the following disclaimer. 14 | 15 | * Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | 19 | * Neither the name of the authors nor the names of its contributors 20 | may be used to endorse or promote products derived from this software 21 | without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | /* If you use this library, you must include dtl.hpp only. */ 37 | 38 | #ifndef DTL_LCS_H 39 | #define DTL_LCS_H 40 | 41 | namespace dtl { 42 | 43 | /** 44 | * Longest Common Subsequence template class 45 | */ 46 | template 47 | class Lcs : public Sequence< elem > 48 | { 49 | public : 50 | Lcs () {} 51 | ~Lcs () {} 52 | }; 53 | } 54 | 55 | #endif // DTL_LCS_H 56 | -------------------------------------------------------------------------------- /extra/zigzag.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 40 | 45 | 50 | 55 | 56 | 58 | 62 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /public/libbacktrace/filenames.hpp: -------------------------------------------------------------------------------- 1 | /* btest.c -- Filename header for libbacktrace library 2 | Copyright (C) 2012-2018 Free Software Foundation, Inc. 3 | Written by Ian Lance Taylor, Google. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | (1) Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | (2) Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in 14 | the documentation and/or other materials provided with the 15 | distribution. 16 | 17 | (3) The name of the author may not be used to 18 | endorse or promote products derived from this software without 19 | specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. */ 32 | 33 | #ifndef GCC_VERSION 34 | # define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) 35 | #endif 36 | 37 | #if (GCC_VERSION < 2007) 38 | # define __attribute__(x) 39 | #endif 40 | 41 | #ifndef ATTRIBUTE_UNUSED 42 | # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 43 | #endif 44 | 45 | #if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__) 46 | # define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\') 47 | # define HAS_DRIVE_SPEC(f) ((f)[0] != '\0' && (f)[1] == ':') 48 | # define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || HAS_DRIVE_SPEC(f)) 49 | #else 50 | # define IS_DIR_SEPARATOR(c) ((c) == '/') 51 | # define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0])) 52 | #endif 53 | -------------------------------------------------------------------------------- /.github/workflows/emscripten.yml: -------------------------------------------------------------------------------- 1 | name: emscripten 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm-cache 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | container: archlinux:base-devel 16 | steps: 17 | - name: Install dependencies 18 | run: pacman -Syu --noconfirm && pacman -S --noconfirm --needed cmake git unzip python ninja zstd 19 | - name: Setup emscripten 20 | uses: mymindstorm/setup-emsdk@v14 21 | with: 22 | version: 4.0.10 23 | - name: Trust git repo 24 | run: git config --global --add safe.directory '*' 25 | - uses: actions/checkout@v4 26 | - name: Profiler GUI 27 | run: | 28 | cmake -G Ninja -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=MinSizeRel -DGIT_REV=${{ github.sha }} -DCMAKE_TOOLCHAIN_FILE=${{env.EMSDK}}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake 29 | cmake --build profiler/build --parallel 30 | - name: Compress artifacts 31 | run: | 32 | zstd -18 profiler/build/tracy-profiler.js profiler/build/tracy-profiler.wasm 33 | gzip -9 profiler/build/tracy-profiler.js profiler/build/tracy-profiler.wasm 34 | - name: Find Artifacts 35 | id: find_artifacts 36 | run: | 37 | mkdir -p bin 38 | cp profiler/build/index.html bin 39 | cp profiler/build/favicon.svg bin 40 | cp profiler/build/tracy-profiler.data bin 41 | cp profiler/build/tracy-profiler.js.gz bin 42 | cp profiler/build/tracy-profiler.js.zst bin 43 | cp profiler/build/tracy-profiler.wasm.gz bin 44 | cp profiler/build/tracy-profiler.wasm.zst bin 45 | - uses: actions/upload-artifact@v4 46 | with: 47 | name: emscripten 48 | path: bin 49 | deploy: 50 | runs-on: ubuntu-latest 51 | needs: build 52 | if: github.ref == 'refs/heads/master' 53 | steps: 54 | - uses: actions/download-artifact@v4 55 | - uses: wlixcc/SFTP-Deploy-Action@v1.2.4 56 | with: 57 | username: ${{ secrets.USERNAME }} 58 | server: ${{ secrets.SERVER }} 59 | port: ${{ secrets.PORT }} 60 | ssh_private_key: ${{ secrets.PRIVATE_KEY }} 61 | local_path: './emscripten/*' 62 | remote_path: ${{ secrets.REMOTE_PATH }} 63 | sftp_only: true -------------------------------------------------------------------------------- /profiler/src/Filters.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "Filters.hpp" 6 | 7 | #include "profiler/TracyStorage.hpp" 8 | 9 | 10 | Filters::Filters() 11 | : m_fn( tracy::GetSavePath( "client.filters" ) ) 12 | { 13 | FILE* f = fopen( m_fn.c_str(), "rb" ); 14 | if( !f ) return; 15 | 16 | uint8_t sz; 17 | fread( &sz, 1, sizeof( sz ), f ); 18 | fread( m_addrFilter.InputBuf, 1, sz, f ); 19 | m_addrFilter.Build(); 20 | 21 | fread( &sz, 1, sizeof( sz ), f ); 22 | fread( m_portFilter.InputBuf, 1, sz, f ); 23 | m_portFilter.Build(); 24 | 25 | fread( &sz, 1, sizeof( sz ), f ); 26 | fread( m_progFilter.InputBuf, 1, sz, f ); 27 | m_progFilter.Build(); 28 | 29 | fclose( f ); 30 | } 31 | 32 | Filters::~Filters() 33 | { 34 | FILE* f = fopen( m_fn.c_str(), "wb" ); 35 | if( !f ) return; 36 | 37 | uint8_t sz = (uint8_t)strlen( m_addrFilter.InputBuf ); 38 | fwrite( &sz, 1, sizeof( sz ), f ); 39 | fwrite( m_addrFilter.InputBuf, 1, sz, f ); 40 | 41 | sz = (uint8_t)strlen( m_portFilter.InputBuf ); 42 | fwrite( &sz, 1, sizeof( sz ), f ); 43 | fwrite( m_portFilter.InputBuf, 1, sz, f ); 44 | 45 | sz = (uint8_t)strlen( m_progFilter.InputBuf ); 46 | fwrite( &sz, 1, sizeof( sz ), f ); 47 | fwrite( m_progFilter.InputBuf, 1, sz, f ); 48 | 49 | fclose( f ); 50 | } 51 | 52 | void Filters::Clear() 53 | { 54 | m_addrFilter.Clear(); 55 | m_portFilter.Clear(); 56 | m_progFilter.Clear(); 57 | } 58 | 59 | void Filters::Draw( float w ) 60 | { 61 | m_addrFilter.Draw( "Address filter", w ); 62 | m_portFilter.Draw( "Port filter", w ); 63 | m_progFilter.Draw( "Program filter", w ); 64 | } 65 | 66 | bool Filters::IsActive() const 67 | { 68 | return m_addrFilter.IsActive() || m_portFilter.IsActive() || m_progFilter.IsActive(); 69 | } 70 | 71 | bool Filters::FailAddr( const char* addr ) 72 | { 73 | return m_addrFilter.IsActive() && !m_addrFilter.PassFilter( addr ); 74 | } 75 | 76 | bool Filters::FailPort( uint16_t port ) 77 | { 78 | if( !m_portFilter.IsActive() ) return false; 79 | char buf[32]; 80 | sprintf( buf, "%" PRIu16, port ); 81 | return !m_portFilter.PassFilter( buf ); 82 | } 83 | 84 | bool Filters::FailProg( const char* prog ) 85 | { 86 | return m_progFilter.IsActive() && !m_progFilter.PassFilter( prog ); 87 | } 88 | -------------------------------------------------------------------------------- /server/TracyTaskDispatch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../public/common/TracySystem.hpp" 5 | #include "TracyTaskDispatch.hpp" 6 | 7 | namespace tracy 8 | { 9 | 10 | TaskDispatch::TaskDispatch( size_t workers, const char* name ) 11 | : m_exit( false ) 12 | , m_jobs( 0 ) 13 | { 14 | m_workers.reserve( workers ); 15 | for( size_t i=0; i& f ) 35 | { 36 | std::lock_guard lock( m_queueLock ); 37 | m_queue.emplace_back( f ); 38 | m_cvWork.notify_one(); 39 | } 40 | 41 | void TaskDispatch::Queue( std::function&& f ) 42 | { 43 | std::lock_guard lock( m_queueLock ); 44 | m_queue.emplace_back( std::move( f ) ); 45 | m_cvWork.notify_one(); 46 | } 47 | 48 | void TaskDispatch::Sync() 49 | { 50 | std::unique_lock lock( m_queueLock ); 51 | while( !m_queue.empty() ) 52 | { 53 | auto f = m_queue.back(); 54 | m_queue.pop_back(); 55 | lock.unlock(); 56 | f(); 57 | lock.lock(); 58 | } 59 | m_cvJobs.wait( lock, [this]{ return m_jobs == 0; } ); 60 | } 61 | 62 | void TaskDispatch::Worker() 63 | { 64 | for(;;) 65 | { 66 | std::unique_lock lock( m_queueLock ); 67 | m_cvWork.wait( lock, [this]{ return !m_queue.empty() || m_exit.load( std::memory_order_acquire ); } ); 68 | if( m_exit.load( std::memory_order_acquire ) ) return; 69 | auto f = m_queue.back(); 70 | m_queue.pop_back(); 71 | m_jobs++; 72 | lock.unlock(); 73 | f(); 74 | lock.lock(); 75 | m_jobs--; 76 | if( m_jobs == 0 && m_queue.empty() ) m_cvJobs.notify_one(); 77 | lock.unlock(); 78 | } 79 | } 80 | 81 | void TaskDispatch::SetName( const char* name, size_t num ) 82 | { 83 | char tmp[128]; 84 | snprintf( tmp, sizeof( tmp ), "%s #%zu", name, num ); 85 | SetThreadName( tmp ); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyTimelineItem.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYTIMELINEITEM_HPP__ 2 | #define __TRACYTIMELINEITEM_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | #include "imgui.h" 8 | 9 | namespace tracy 10 | { 11 | 12 | struct TimelineContext; 13 | class TaskDispatch; 14 | class View; 15 | class Worker; 16 | 17 | class TimelineItem 18 | { 19 | public: 20 | TimelineItem( View& view, Worker& worker, const void* key, bool wantPreprocess ); 21 | virtual ~TimelineItem() = default; 22 | 23 | // draws the timeline item and also updates the next frame height value 24 | void Draw( bool firstFrame, const TimelineContext& ctx, int yOffset ); 25 | 26 | bool WantPreprocess() const { return m_wantPreprocess; } 27 | virtual void Preprocess( const TimelineContext& ctx, TaskDispatch& td, bool visible, int yPos ) { assert( false ); } 28 | 29 | void VisibilityCheckbox(); 30 | virtual void SetVisible( bool visible ) { m_visible = visible; } 31 | virtual bool IsVisible() const { return m_visible; } 32 | 33 | void SetShowFull( bool showFull ) { m_showFull = showFull; } 34 | 35 | // returns 0 instead of the correct value for the first frame 36 | int GetHeight() const { return m_height; } 37 | 38 | const void* GetKey() const { return m_key; } 39 | 40 | protected: 41 | virtual uint32_t HeaderColor() const = 0; 42 | virtual uint32_t HeaderColorInactive() const = 0; 43 | virtual uint32_t HeaderLineColor() const = 0; 44 | virtual const char* HeaderLabel() const = 0; 45 | 46 | virtual void HeaderTooltip( const char* label ) const {}; 47 | virtual void HeaderExtraContents( const TimelineContext& ctx, int offset, float labelWidth ) {}; 48 | 49 | virtual int64_t RangeBegin() const = 0; 50 | virtual int64_t RangeEnd() const = 0; 51 | 52 | virtual bool DrawContents( const TimelineContext& ctx, int& offset ) = 0; 53 | virtual void DrawOverlay( const ImVec2& ul, const ImVec2& dr ) {} 54 | virtual void DrawExtraPopupItems() {} 55 | virtual void DrawFinished() {} 56 | 57 | virtual bool IsEmpty() const { return false; } 58 | 59 | bool m_visible; 60 | bool m_showFull; 61 | 62 | private: 63 | void AdjustThreadHeight( bool firstFrame, int yBegin, int yEnd ); 64 | 65 | int m_height; 66 | bool m_wantPreprocess; 67 | 68 | const void* m_key; 69 | 70 | protected: 71 | View& m_view; 72 | Worker& m_worker; 73 | }; 74 | 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /getopt/getopt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2012-2023, Kim Grasman 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Kim Grasman nor the 13 | * names of contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRASMAN BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ******************************************************************************/ 28 | 29 | #ifndef INCLUDED_GETOPT_PORT_H 30 | #define INCLUDED_GETOPT_PORT_H 31 | 32 | #if defined(__cplusplus) 33 | extern "C" { 34 | #endif 35 | 36 | #define no_argument 1 37 | #define required_argument 2 38 | #define optional_argument 3 39 | 40 | extern char* optarg; 41 | extern int optind, opterr, optopt; 42 | 43 | struct option { 44 | const char* name; 45 | int has_arg; 46 | int* flag; 47 | int val; 48 | }; 49 | 50 | int getopt(int argc, char* const argv[], const char* optstring); 51 | 52 | int getopt_long(int argc, char* const argv[], 53 | const char* optstring, const struct option* longopts, int* longindex); 54 | 55 | #if defined(__cplusplus) 56 | } 57 | #endif 58 | 59 | #endif // INCLUDED_GETOPT_PORT_H 60 | -------------------------------------------------------------------------------- /dtl/Sequence.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | dtl -- Diff Template Library 3 | 4 | In short, Diff Template Library is distributed under so called "BSD license", 5 | 6 | Copyright (c) 2015 Tatsuhiko Kubo 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without modification, 10 | are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, 13 | this list of conditions and the following disclaimer. 14 | 15 | * Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | 19 | * Neither the name of the authors nor the names of its contributors 20 | may be used to endorse or promote products derived from this software 21 | without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | /* If you use this library, you must include dtl.hpp only. */ 37 | 38 | #ifndef DTL_SEQUENCE_H 39 | #define DTL_SEQUENCE_H 40 | 41 | namespace dtl { 42 | 43 | /** 44 | * sequence class template 45 | */ 46 | template 47 | class Sequence 48 | { 49 | public : 50 | typedef vector< elem > elemVec; 51 | Sequence () {} 52 | virtual ~Sequence () {} 53 | 54 | elemVec getSequence () const { 55 | return sequence; 56 | } 57 | void addSequence (elem e) { 58 | sequence.push_back(e); 59 | } 60 | protected : 61 | elemVec sequence; 62 | }; 63 | } 64 | 65 | #endif // DTL_SEQUENCE_H 66 | -------------------------------------------------------------------------------- /examples/ToyPathTracer/Windows/TestCpu.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Source 7 | 8 | 9 | Source\enkiTS 10 | 11 | 12 | Source\enkiTS 13 | 14 | 15 | Source 16 | 17 | 18 | 19 | 20 | 21 | {5f19f217-c1c7-4eeb-be61-8b986fee9375} 22 | 23 | 24 | {38c448a8-1dcc-4116-9410-a9f8d068caff} 25 | 26 | 27 | 28 | 29 | Source 30 | 31 | 32 | Source 33 | 34 | 35 | Source\enkiTS 36 | 37 | 38 | Source\enkiTS 39 | 40 | 41 | Source\enkiTS 42 | 43 | 44 | Source\enkiTS 45 | 46 | 47 | Source\enkiTS 48 | 49 | 50 | Source 51 | 52 | 53 | Source 54 | 55 | 56 | Source 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /server/TracyShortPtr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSHORTPTR_HPP__ 2 | #define __TRACYSHORTPTR_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../public/common/TracyForceInline.hpp" 9 | 10 | namespace tracy 11 | { 12 | 13 | #if UINTPTR_MAX == 0xFFFFFFFFFFFFFFFF 14 | template 15 | class short_ptr 16 | { 17 | public: 18 | tracy_force_inline short_ptr() {} 19 | tracy_force_inline short_ptr( const T* ptr ) { set( ptr ); } 20 | 21 | tracy_force_inline operator T*() { return get(); } 22 | tracy_force_inline operator const T*() const { return get(); } 23 | tracy_force_inline T& operator*() { return *get(); } 24 | tracy_force_inline const T& operator*() const { return *get(); } 25 | tracy_force_inline T* operator->() { return get(); } 26 | tracy_force_inline const T* operator->() const { return get(); } 27 | 28 | tracy_force_inline void set( const T* ptr ) 29 | { 30 | assert( ( uint64_t( ptr ) & 0xFFFF000000000000 ) == 0 ); 31 | memcpy( m_ptr, &ptr, 4 ); 32 | memcpy( m_ptr+4, ((char*)&ptr)+4, 2 ); 33 | } 34 | 35 | tracy_force_inline T* get() 36 | { 37 | uint32_t lo; 38 | uint16_t hi; 39 | memcpy( &lo, m_ptr, 4 ); 40 | memcpy( &hi, m_ptr+4, 2 ); 41 | return (T*)( uint64_t( lo ) | ( ( uint64_t( hi ) << 32 ) ) ); 42 | } 43 | 44 | tracy_force_inline const T* get() const 45 | { 46 | uint32_t lo; 47 | uint16_t hi; 48 | memcpy( &lo, m_ptr, 4 ); 49 | memcpy( &hi, m_ptr+4, 2 ); 50 | return (T*)( uint64_t( lo ) | ( ( uint64_t( hi ) << 32 ) ) ); 51 | } 52 | 53 | private: 54 | uint8_t m_ptr[6]; 55 | }; 56 | #else 57 | template 58 | class short_ptr 59 | { 60 | public: 61 | tracy_force_inline short_ptr() {} 62 | tracy_force_inline short_ptr( const T* ptr ) { memcpy( &m_ptr, &ptr, sizeof( T* ) ); } 63 | 64 | tracy_force_inline operator T*() { return m_ptr; } 65 | tracy_force_inline operator const T*() const { return m_ptr; } 66 | tracy_force_inline T& operator*() { return *m_ptr; } 67 | tracy_force_inline const T& operator*() const { return *m_ptr; } 68 | tracy_force_inline T* operator->() { return m_ptr; } 69 | tracy_force_inline const T* operator->() const { return m_ptr; } 70 | 71 | tracy_force_inline void set( const T* ptr ) { m_ptr = ptr; } 72 | tracy_force_inline T* get() { return m_ptr; } 73 | tracy_force_inline const T* get() const { return m_ptr; } 74 | 75 | private: 76 | T* m_ptr; 77 | }; 78 | #endif 79 | 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /cmake/config.cmake: -------------------------------------------------------------------------------- 1 | if (NOT NO_ISA_EXTENSIONS) 2 | include(CheckCXXCompilerFlag) 3 | if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") 4 | CHECK_CXX_COMPILER_FLAG("-mcpu=native" COMPILER_SUPPORTS_MCPU_NATIVE) 5 | if(COMPILER_SUPPORTS_MARCH_NATIVE) 6 | add_compile_options(-mcpu=native) 7 | endif() 8 | else() 9 | CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE) 10 | if(COMPILER_SUPPORTS_MARCH_NATIVE) 11 | add_compile_options(-march=native) 12 | endif() 13 | endif() 14 | if(WIN32) 15 | add_compile_options(/arch:AVX2) 16 | endif() 17 | endif() 18 | 19 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT LEGACY) 20 | set(USE_WAYLAND ON) 21 | else() 22 | set(USE_WAYLAND OFF) 23 | endif() 24 | 25 | if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") 26 | if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") 27 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "15") 28 | message(FATAL_ERROR "Apple Clang 15 or newer is required.") 29 | elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16") 30 | # AppleClang 15 has issues with to_chars in if target is too old 31 | add_compile_options($<$:-mmacosx-version-min=13.3>) 32 | endif() 33 | add_compile_options($<$:-fexperimental-library>) 34 | endif() 35 | endif() 36 | 37 | if(WIN32) 38 | add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) 39 | # /MP is MSVC-specific for multi-processor compilation 40 | if(MSVC) 41 | add_compile_options(/MP) 42 | endif() 43 | endif() 44 | 45 | if(EMSCRIPTEN) 46 | add_compile_options(-pthread -DIMGUI_IMPL_OPENGL_ES2) 47 | endif() 48 | 49 | if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT EMSCRIPTEN) 50 | set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) 51 | endif() 52 | 53 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") 54 | find_program(MOLD_LINKER mold) 55 | if(MOLD_LINKER) 56 | set(CMAKE_LINKER_TYPE "MOLD") 57 | endif() 58 | if (CMAKE_BUILD_TYPE STREQUAL "Debug") 59 | add_compile_options(-fno-eliminate-unused-debug-types) 60 | endif() 61 | endif() 62 | 63 | find_program(CCACHE ccache) 64 | if(CCACHE) 65 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) 66 | set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) 67 | endif() 68 | 69 | file(GENERATE OUTPUT .gitignore CONTENT "*") 70 | 71 | set(CMAKE_COLOR_DIAGNOSTICS ON) 72 | -------------------------------------------------------------------------------- /profiler/src/ConnectionHistory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "ConnectionHistory.hpp" 6 | 7 | #include "../../server/tracy_pdqsort.h" 8 | #include "profiler/TracyStorage.hpp" 9 | 10 | 11 | ConnectionHistory::ConnectionHistory() 12 | : m_fn( tracy::GetSavePath( "connection.history" ) ) 13 | { 14 | FILE* f = fopen( m_fn.c_str(), "rb" ); 15 | if( !f ) return; 16 | 17 | uint64_t sz; 18 | if( fread( &sz, 1, sizeof( sz ), f ) != sizeof( sz ) ) goto err; 19 | for( uint64_t i=0; i= 1024 ) goto err; 24 | char tmp[1024]; 25 | if( fread( tmp, 1, ssz, f ) != ssz ) goto err; 26 | if( fread( &cnt, 1, sizeof( cnt ), f ) != sizeof( cnt ) ) goto err; 27 | m_connHistMap.emplace( std::string( tmp, tmp+ssz ), cnt ); 28 | } 29 | fclose( f ); 30 | 31 | Rebuild(); 32 | return; 33 | 34 | err: 35 | fclose( f ); 36 | m_connHistMap.clear(); 37 | } 38 | 39 | ConnectionHistory::~ConnectionHistory() 40 | { 41 | FILE* f = fopen( m_fn.c_str(), "wb" ); 42 | if( !f ) return; 43 | 44 | uint64_t sz = uint64_t( m_connHistMap.size() ); 45 | fwrite( &sz, 1, sizeof( uint64_t ), f ); 46 | for( auto& v : m_connHistMap ) 47 | { 48 | sz = uint64_t( v.first.size() ); 49 | fwrite( &sz, 1, sizeof( uint64_t ), f ); 50 | fwrite( v.first.c_str(), 1, sz, f ); 51 | fwrite( &v.second, 1, sizeof( v.second ), f ); 52 | } 53 | fclose( f ); 54 | } 55 | 56 | void ConnectionHistory::Rebuild() 57 | { 58 | std::vector::const_iterator> vec; 59 | vec.reserve( m_connHistMap.size() ); 60 | for( auto it = m_connHistMap.begin(); it != m_connHistMap.end(); ++it ) 61 | { 62 | vec.emplace_back( it ); 63 | } 64 | tracy::pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second > rhs->second; } ); 65 | std::swap( m_connHistVec, vec ); 66 | } 67 | 68 | void ConnectionHistory::Count( const std::string& name ) 69 | { 70 | auto it = m_connHistMap.find( name ); 71 | if( it != m_connHistMap.end() ) 72 | { 73 | it->second++; 74 | } 75 | else 76 | { 77 | m_connHistMap.emplace( name, 1 ); 78 | } 79 | Rebuild(); 80 | } 81 | 82 | void ConnectionHistory::Erase( size_t idx ) 83 | { 84 | assert( idx < m_connHistVec.size() ); 85 | m_connHistMap.erase( m_connHistVec[idx] ); 86 | Rebuild(); 87 | } 88 | -------------------------------------------------------------------------------- /profiler/helpers/embed.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../../public/common/tracy_lz4hc.hpp" 6 | 7 | static void Usage() 8 | { 9 | fprintf( stderr, "Usage: embed \n" ); 10 | fprintf( stderr, " destination should be without extension, will create cpp, hpp pair\n" ); 11 | } 12 | 13 | int main( int argc, char** argv ) 14 | { 15 | if( argc < 4 ) 16 | { 17 | Usage(); 18 | return 1; 19 | } 20 | 21 | const char* objectName = argv[1]; 22 | const char* source = argv[2]; 23 | const char* destination = argv[3]; 24 | 25 | FILE* src = fopen( source, "rb" ); 26 | if( !src ) 27 | { 28 | fprintf( stderr, "Failed to open source file %s\n", source ); 29 | return 1; 30 | } 31 | 32 | size_t sz; 33 | fseek( src, 0, SEEK_END ); 34 | sz = ftell( src ); 35 | fseek( src, 0, SEEK_SET ); 36 | 37 | auto data = new uint8_t[sz]; 38 | fread( data, 1, sz, src ); 39 | fclose( src ); 40 | 41 | const auto lz4szMax = tracy::LZ4_compressBound( sz ); 42 | auto lz4data = new uint8_t[lz4szMax]; 43 | const auto lz4sz = tracy::LZ4_compress_HC( (const char*)data, (char*)lz4data, sz, lz4szMax, 6 ); 44 | delete[] data; 45 | 46 | FILE* hdr = fopen( ( std::string(destination) + ".hpp" ).c_str(), "wb" ); 47 | fprintf( hdr, "// This file is generated by embed tool, do not modify\n" ); 48 | fprintf( hdr, "// Source: %s\n\n", source ); 49 | fprintf( hdr, "#pragma once\n\n" ); 50 | fprintf( hdr, "#include \n" ); 51 | fprintf( hdr, "#include \n\n" ); 52 | fprintf( hdr, "namespace Embed\n{\n" ); 53 | fprintf( hdr, "constexpr size_t %sSize = %zu;\n", objectName, sz ); 54 | fprintf( hdr, "constexpr size_t %sLz4Size = %i;\n", objectName, lz4sz ); 55 | fprintf( hdr, "extern const uint8_t %sData[];\n", objectName ); 56 | fprintf( hdr, "}\n" ); 57 | fclose( hdr ); 58 | 59 | FILE* cpp = fopen( ( std::string(destination) + ".cpp" ).c_str(), "wb" ); 60 | fprintf( cpp, "// This file is generated by embed tool, do not modify\n" ); 61 | fprintf( cpp, "// Source: %s\n\n", source ); 62 | fprintf( cpp, "#include \"%s.hpp\"\n\n", destination ); 63 | fprintf( cpp, "namespace Embed\n{\n" ); 64 | fprintf( cpp, "const uint8_t %sData[] =\n", objectName ); 65 | fprintf( cpp, "{\n" ); 66 | for( size_t i=0; i 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "TracyLlmEmbeddings.hpp" 12 | #include "tracy_robin_hood.h" 13 | 14 | class EmbedData; 15 | 16 | namespace tracy 17 | { 18 | 19 | class TracyLlmApi; 20 | class TracyManualData; 21 | class Worker; 22 | 23 | class TracyLlmTools 24 | { 25 | public: 26 | struct ToolReply 27 | { 28 | std::string reply; 29 | std::string image; 30 | }; 31 | 32 | struct EmbeddingState 33 | { 34 | std::string model; 35 | bool done = false; 36 | bool inProgress = false; 37 | float progress = 0; 38 | }; 39 | 40 | TracyLlmTools( Worker& worker, const TracyManualData& manual ); 41 | ~TracyLlmTools(); 42 | 43 | ToolReply HandleToolCalls( const nlohmann::json& json, TracyLlmApi& api, int contextSize, bool hasEmbeddingsModel ); 44 | std::string GetCurrentTime() const; 45 | 46 | [[nodiscard]] EmbeddingState GetManualEmbeddingsState() const; 47 | void SelectManualEmbeddings( const std::string& model ); 48 | void BuildManualEmbeddings( const std::string& model, TracyLlmApi& api ); 49 | void CancelManualEmbeddings(); 50 | 51 | bool m_netAccess = true; 52 | 53 | private: 54 | [[nodiscard]] int CalcMaxSize() const; 55 | [[nodiscard]] std::string TrimString( std::string&& str ) const; 56 | 57 | std::string FetchWebPage( const std::string& url, bool cache = true ); 58 | ToolReply SearchWikipedia( std::string query, const std::string& lang ); 59 | std::string GetWikipedia( std::string page, const std::string& lang ); 60 | std::string GetDictionary( std::string word, const std::string& lang ); 61 | std::string SearchWeb( std::string query ); 62 | std::string GetWebpage( const std::string& url ); 63 | std::string SearchManual( const std::string& query, TracyLlmApi& api, bool hasEmbeddingsModel ); 64 | std::string SourceFile( const std::string& file, uint32_t line ) const; 65 | 66 | void ManualEmbeddingsWorker( TracyLlmApi& api ); 67 | 68 | unordered_flat_map m_webCache; 69 | 70 | int m_ctxSize; 71 | 72 | mutable std::mutex m_lock; 73 | std::thread m_thread; 74 | bool m_cancel = false; 75 | EmbeddingState m_manualEmbeddingState; 76 | std::unique_ptr m_manualEmbeddings; 77 | 78 | std::vector> m_chunkData; 79 | 80 | Worker& m_worker; 81 | const TracyManualData& m_manual; 82 | }; 83 | 84 | } 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /server/TracyStringDiscovery.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYSTRINGDISCOVERY_HPP__ 2 | #define __TRACYSTRINGDISCOVERY_HPP__ 3 | 4 | #include "../public/common/TracyForceInline.hpp" 5 | #include "tracy_robin_hood.h" 6 | #include "TracyCharUtil.hpp" 7 | #include "TracyEvent.hpp" 8 | #include "TracyVector.hpp" 9 | 10 | namespace tracy 11 | { 12 | 13 | template 14 | class StringDiscovery 15 | { 16 | public: 17 | tracy_force_inline Vector& Data() { return m_data; } 18 | tracy_force_inline const Vector& Data() const { return m_data; } 19 | 20 | tracy_force_inline bool IsPending() const { return !m_pending.empty(); } 21 | 22 | // Merge( destination, postponed ) 23 | template 24 | tracy_force_inline void StringDiscovered( uint64_t name, const StringLocation& sl, U& stringMap, std::function Merge ) 25 | { 26 | auto pit = m_pending.find( name ); 27 | assert( pit != m_pending.end() ); 28 | 29 | auto it = m_rev.find( sl.ptr ); 30 | if( it == m_rev.end() ) 31 | { 32 | m_map.emplace( name, pit->second ); 33 | m_rev.emplace( sl.ptr, pit->second ); 34 | m_data.push_back( pit->second ); 35 | stringMap.emplace( name, sl.ptr ); 36 | } 37 | else 38 | { 39 | auto item = it->second; 40 | m_map.emplace( name, item ); 41 | Merge( item, pit->second ); 42 | } 43 | 44 | m_pending.erase( pit ); 45 | } 46 | 47 | tracy_force_inline T Retrieve( uint64_t name, const std::function& Create, const std::function& Query ) 48 | { 49 | auto it = m_map.find( name ); 50 | if( it == m_map.end() ) 51 | { 52 | auto pit = m_pending.find( name ); 53 | if( pit == m_pending.end() ) 54 | { 55 | T item = Create( name ); 56 | if( item ) 57 | { 58 | m_pending.emplace( name, item ); 59 | Query( name ); 60 | } 61 | return item; 62 | } 63 | else 64 | { 65 | return pit->second; 66 | } 67 | } 68 | else 69 | { 70 | return it->second; 71 | } 72 | } 73 | 74 | tracy_force_inline void AddExternal( const T& val ) 75 | { 76 | m_data.push_back( val ); 77 | } 78 | 79 | private: 80 | Vector m_data; 81 | unordered_flat_map m_pending; 82 | unordered_flat_map m_map; 83 | unordered_flat_map m_rev; 84 | }; 85 | 86 | } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /server/TracyVarArray.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYVARARRAY_HPP__ 2 | #define __TRACYVARARRAY_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | #define XXH_INLINE_ALL 8 | #include "tracy_xxhash.h" 9 | 10 | #include "../public/common/TracyForceInline.hpp" 11 | #include "TracyCharUtil.hpp" 12 | #include "TracyEvent.hpp" 13 | #include "TracyMemory.hpp" 14 | #include "TracyShortPtr.hpp" 15 | 16 | namespace tracy 17 | { 18 | 19 | #pragma pack( push, 1 ) 20 | template 21 | class VarArray 22 | { 23 | public: 24 | VarArray( uint16_t size, const T* data ) 25 | : m_size( size ) 26 | , m_ptr( data ) 27 | { 28 | CalcHash(); 29 | } 30 | 31 | VarArray( const VarArray& ) = delete; 32 | VarArray( VarArray&& ) = delete; 33 | 34 | VarArray& operator=( const VarArray& ) = delete; 35 | VarArray& operator=( VarArray&& ) = delete; 36 | 37 | tracy_force_inline uint32_t get_hash() const { return m_hash; } 38 | 39 | tracy_force_inline bool empty() const { return m_size == 0; } 40 | tracy_force_inline uint16_t size() const { return m_size; } 41 | 42 | tracy_force_inline const T* data() const { return m_ptr; }; 43 | 44 | tracy_force_inline const T* begin() const { return m_ptr; } 45 | tracy_force_inline const T* end() const { return m_ptr + m_size; } 46 | 47 | tracy_force_inline const T& front() const { assert( m_size > 0 ); return m_ptr[0]; } 48 | tracy_force_inline const T& back() const { assert( m_size > 0 ); return m_ptr[m_size - 1]; } 49 | 50 | tracy_force_inline const T& operator[]( size_t idx ) const { return m_ptr[idx]; } 51 | 52 | private: 53 | tracy_force_inline void CalcHash(); 54 | 55 | uint16_t m_size; 56 | uint32_t m_hash; 57 | const short_ptr m_ptr; 58 | }; 59 | #pragma pack( pop ) 60 | 61 | enum { VarArraySize = sizeof( VarArray ) }; 62 | 63 | 64 | template 65 | inline void VarArray::CalcHash() 66 | { 67 | m_hash = uint32_t( XXH3_64bits( m_ptr.get(), m_size * sizeof( T ) ) ); 68 | } 69 | 70 | template 71 | static inline bool Compare( const VarArray& lhs, const VarArray& rhs ) 72 | { 73 | if( lhs.size() != rhs.size() || lhs.get_hash() != rhs.get_hash() ) return false; 74 | return memcmp( lhs.data(), rhs.data(), lhs.size() * sizeof( T ) ) == 0; 75 | } 76 | 77 | template 78 | struct VarArrayHasher 79 | { 80 | size_t operator()( const VarArray* arr ) const 81 | { 82 | return arr->get_hash(); 83 | } 84 | }; 85 | 86 | template 87 | struct VarArrayComparator 88 | { 89 | bool operator()( const VarArray* lhs, const VarArray* rhs ) const 90 | { 91 | return Compare( *lhs, *rhs ); 92 | } 93 | }; 94 | 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /public/libbacktrace/state.cpp: -------------------------------------------------------------------------------- 1 | /* state.c -- Create the backtrace state. 2 | Copyright (C) 2012-2021 Free Software Foundation, Inc. 3 | Written by Ian Lance Taylor, Google. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | (1) Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | (2) Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in 14 | the documentation and/or other materials provided with the 15 | distribution. 16 | 17 | (3) The name of the author may not be used to 18 | endorse or promote products derived from this software without 19 | specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. */ 32 | 33 | #include "config.h" 34 | 35 | #include 36 | #include 37 | 38 | #include "backtrace.hpp" 39 | #include "internal.hpp" 40 | 41 | namespace tracy 42 | { 43 | 44 | /* Create the backtrace state. This will then be passed to all the 45 | other routines. */ 46 | 47 | struct backtrace_state * 48 | backtrace_create_state (const char *filename, int threaded, 49 | backtrace_error_callback error_callback, 50 | void *data) 51 | { 52 | struct backtrace_state init_state; 53 | struct backtrace_state *state; 54 | 55 | #ifndef HAVE_SYNC_FUNCTIONS 56 | if (threaded) 57 | { 58 | error_callback (data, "backtrace library does not support threads", 0); 59 | return NULL; 60 | } 61 | #endif 62 | 63 | memset (&init_state, 0, sizeof init_state); 64 | init_state.filename = filename; 65 | init_state.threaded = threaded; 66 | 67 | state = ((struct backtrace_state *) 68 | backtrace_alloc (&init_state, sizeof *state, error_callback, data)); 69 | if (state == NULL) 70 | return NULL; 71 | *state = init_state; 72 | 73 | return state; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyLlm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TRACYLLM_HPP__ 2 | #define __TRACYLLM_HPP__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "TracyEmbed.hpp" 15 | 16 | namespace tracy 17 | { 18 | 19 | class TracyLlmApi; 20 | class TracyLlmChat; 21 | class TracyLlmTools; 22 | class TracyManualData; 23 | class Worker; 24 | 25 | class TracyLlm 26 | { 27 | enum class Task 28 | { 29 | Connect, 30 | SendMessage, 31 | Tokenize 32 | }; 33 | 34 | struct WorkItem 35 | { 36 | Task task; 37 | std::function callback; 38 | std::function callback2; 39 | std::string param; 40 | bool stop; 41 | }; 42 | 43 | public: 44 | TracyLlm( Worker& worker, const TracyManualData& manual ); 45 | ~TracyLlm(); 46 | 47 | [[nodiscard]] bool IsBusy() const { std::lock_guard lock( m_lock ); return m_busy; } 48 | 49 | void Draw(); 50 | void AddAttachment( std::string&& str, const char* role ); 51 | void AddMessage( std::string&& str, const char* role ); 52 | bool QueueSendMessage(); 53 | 54 | bool m_show = false; 55 | 56 | private: 57 | void WorkerThread(); 58 | 59 | void UpdateModels(); 60 | void ResetChat(); 61 | 62 | void QueueConnect(); 63 | 64 | void AddMessageBlocking( std::string&& str, const char* role, std::unique_lock& lock ); 65 | 66 | void ManageContext( std::unique_lock& lock ); 67 | void SendMessage( std::unique_lock& lock ); 68 | bool OnResponse( const nlohmann::json& json ); 69 | 70 | std::unique_ptr m_api; 71 | std::unique_ptr m_chatUi; 72 | std::unique_ptr m_tools; 73 | 74 | int m_modelIdx; 75 | int m_embedIdx; 76 | 77 | std::atomic m_exit; 78 | std::condition_variable m_cv; 79 | std::thread m_thread; 80 | 81 | mutable std::mutex m_lock; 82 | std::vector> m_jobs; 83 | std::shared_ptr m_currentJob; 84 | 85 | bool m_busy = false; 86 | bool m_focusInput = false; 87 | int m_chatId = 0; 88 | int m_usedCtx = 0; 89 | float m_temperature = 1.0f; 90 | bool m_setTemperature = false; 91 | 92 | char* m_input; 93 | char* m_apiInput; 94 | std::vector m_chat; 95 | 96 | std::shared_ptr m_systemPrompt; 97 | std::shared_ptr m_systemReminder; 98 | }; 99 | 100 | } 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /profiler/src/profiler/TracyMouse.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "TracyMouse.hpp" 4 | 5 | #include "imgui_internal.h" 6 | 7 | namespace tracy 8 | { 9 | 10 | static constexpr int MouseButtons = IM_ARRAYSIZE( ImGuiContext::IO.MouseDown ); 11 | static constexpr float MouseDragThreshold = 2; 12 | 13 | struct Mouse 14 | { 15 | bool mouseDown[MouseButtons]; 16 | bool mouseClicked[MouseButtons]; 17 | bool mouseReleased[MouseButtons]; 18 | bool mouseDragging[MouseButtons]; 19 | ImVec2 mouseDragDelta[MouseButtons]; 20 | bool mousePotentialClickRelease[MouseButtons]; 21 | }; 22 | 23 | static Mouse s_mouse = {}; 24 | 25 | void MouseFrame() 26 | { 27 | for( int i=0; i& vec, int depth, bool visible ); 40 | #endif 41 | int PreprocessZoneLevel( const TimelineContext& ctx, const Vector>& vec, int depth, bool visible, const uint32_t inheritedColor ); 42 | 43 | template 44 | int PreprocessZoneLevel( const TimelineContext& ctx, const V& vec, int depth, bool visible, const uint32_t inheritedColor ); 45 | 46 | void PreprocessContextSwitches( const TimelineContext& ctx, const ContextSwitch& ctxSwitch, bool visible ); 47 | void PreprocessSamples( const TimelineContext& ctx, const Vector& vec, bool visible, int yPos ); 48 | void PreprocessMessages( const TimelineContext& ctx, const Vector>& vec, uint64_t tid, bool visible, int yPos ); 49 | void PreprocessLocks( const TimelineContext& ctx, const unordered_flat_map& locks, uint32_t tid, TaskDispatch& td, bool visible ); 50 | 51 | const ThreadData* m_thread; 52 | bool m_ghost; 53 | 54 | std::vector m_samplesDraw; 55 | std::vector m_ctxDraw; 56 | std::vector m_draw; 57 | std::vector m_msgDraw; 58 | std::vector> m_lockDraw; 59 | int m_depth; 60 | bool m_hasCtxSwitch; 61 | bool m_hasSamples; 62 | bool m_hasMessages; 63 | }; 64 | 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /icon/application-tracy.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | text-x-preview 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | --------------------------------------------------------------------------------