Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Tracy v0.11.0 #8

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

40 changes: 21 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
BSD 2-Clause License
Tracy Profiler (https://github.com/wolfpld/tracy) is licensed under the
3-clause BSD license.

Copyright (c) 2020, Oskar Nordquist
Copyright (c) 2017-2024, Bartosz Taudul <wolf@nereid.pl>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76 changes: 17 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,86 +15,44 @@ This assumes you are using the latest nightly build or GitHub master of the Odin

## 1. Cloning the sources
```console
git clone --recurse-submodules https://github.com/oskarnp/odin-tracy
```
Or if you already had this repo cloned:
```console
git submodule update --init
git clone https://github.com/oskarnp/odin-tracy
```

## 2. Building the Tracy profiler server

### Mac OS
#### Install dependencies
```console
brew install pkg-config glfw freetype capstone
```
#### Build profiler server
```console
cd tracy/profiler/build/unix
make release
```
#### Run profiler server
```console
./tracy/profiler/build/unix/Tracy-release
```
Tracy profiler server is built using CMake version 3.16 or later.

## Windows
#### Install dependencies
This will download and install external dependencies (glfw3, libcapstone, libfreetype) to vcpkg local directory. This writes files only to the vcpkg\vcpkg directory and makes no other changes on your machine.
```console
cd tracy\vcpkg
install_vcpkg_dependencies.bat
```
#### Build profiler server
This requires Visual Studio installed. Open "x64 Native Tools Command Prompt for VS 20XX" and run commands below.
```console
cd tracy\profiler\build\win32
msbuild Tracy.sln -t:Build -p:Configuration=Release
```
(or open solution with Visual Studio and build from there)
#### Run profiler server
```console
x64\Release\Tracy.exe
```
Example (using Clang compiler and Ninja build system):

## Linux

### Install dependencies
* pkg-config
* freetype2
* capstone
* glfw3 (glfw-x11)
* (Only required if using LEGACY=1 below, otherwise not required and
profiler server will use Wayland instead.)

#### Build profiler server
```console
cd tracy/profiler/build/unix
make release LEGACY=1
CXX=clang++ CC=clang cmake -G Ninja -S vendor/tracy/profiler -B build/tracy-profiler -D CMAKE_BUILD_TYPE=Release
cmake --build build/tracy-profiler
```

> [!NOTE]
> Remove LEGACY=1 above to use Wayland instead of GLFW.
> Add `-D LEGACY=ON` to first line to configure for X11 instead of Wayland if you are on Linux.

Refer to official manual for more details.

#### Run profiler server
```console
./tracy/profiler/build/unix/Tracy-release
```

## 3. Building the Tracy profiler client library

Tracy profiler library is _optionally_ built using CMake version 3.10 or later. See vendor/tracy/CMakeLists.txt for more information.

If you prefer to not use CMake you can build the client directly:

### Mac OS
```console
c++ -stdlib=libc++ -mmacosx-version-min=10.8 -std=c++11 -DTRACY_ENABLE -O2 -dynamiclib tracy/public/TracyClient.cpp -o tracy.dylib
c++ -stdlib=libc++ -mmacosx-version-min=10.8 -std=c++11 -DTRACY_ENABLE -O2 -dynamiclib vendor/tracy/public/TracyClient.cpp -o tracy.dylib
```
### Windows
```console
cl -MT -O2 -DTRACY_ENABLE -c tracy\public\TracyClient.cpp -Fotracy
cl -MT -O2 -DTRACY_ENABLE -c vendor\tracy\public\TracyClient.cpp -Fotracy
lib tracy.obj
```
### Linux
```console
c++ -std=c++11 -DTRACY_ENABLE -O2 tracy/public/TracyClient.cpp -shared -fPIC -o tracy.so
c++ -std=c++11 -DTRACY_ENABLE -O2 vendor/tracy/public/TracyClient.cpp -shared -fPIC -o tracy.so
```

## 4. (Optional) Run the demo application / profiler client
Expand All @@ -113,4 +71,4 @@ and then click Connect in Tracy profiler server.
---

> [!IMPORTANT]
> For more details on how to use Tracy, please refer to the [official manual](https://github.com/wolfpld/tracy/releases/download/v0.10/tracy.pdf).
> For more details on how to use Tracy, please refer to the [official manual](https://github.com/wolfpld/tracy/releases/download/v0.11.0/tracy.pdf).
56 changes: 40 additions & 16 deletions bindings.odin
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ when ODIN_OS == .Linux do foreign import tracy "tracy.so"

TracyPlotFormatEnum :: enum i32
{
TracyPlotFormatNumber,
TracyPlotFormatMemory,
TracyPlotFormatPercentage,
TracyPlotFormatWatt
TracyPlotFormatNumber,
TracyPlotFormatMemory,
TracyPlotFormatPercentage,
TracyPlotFormatWatt
}

___tracy_source_location_data :: struct {
Expand All @@ -30,61 +30,69 @@ ___tracy_c_zone_context :: struct {
___tracy_gpu_time_data :: struct {
gpuTime: i64,
queryId: u16,
_context: u8,
_context: u8, // NOTE(oskar): `context` is a reserved identifier in Odin.
}

___tracy_gpu_zone_begin_data :: struct {
srcloc: u64,
queryId: u16,
_context: u8,
_context: u8, // NOTE(oskar): `context` is a reserved identifier in Odin.
}

___tracy_gpu_zone_begin_callstack_data :: struct {
srcloc: u64,
depth: i32,
queryId: u16,
_context: u8,
_context: u8, // NOTE(oskar): `context` is a reserved identifier in Odin.
}

___tracy_gpu_zone_end_data :: struct {
queryId: u16,
_context: u8,
_context: u8, // NOTE(oskar): `context` is a reserved identifier in Odin.
}

___tracy_gpu_new_context_data :: struct {
gpuTime: i64,
period: f32,
_context: u8,
_context: u8, // NOTE(oskar): `context` is a reserved identifier in Odin.
flags: u8,
type: u8,
}

___tracy_gpu_context_name_data :: struct {
_context: u8,
_context: u8, // NOTE(oskar): `context` is a reserved identifier in Odin.
name: cstring,
len: u16,
}

___tracy_gpu_calibration_data :: struct {
gpuTime: i64,
cpuDelta: i64,
_context: u8,
_context: u8, // NOTE(oskar): `context` is a reserved identifier in Odin.
}

___tracy_gpu_time_sync_data :: struct {
gpuTime: i64,
_context: u8, // NOTE(oskar): `context` is a reserved identifier in Odin.
};

__tracy_lockable_context_data :: struct {} // NOTE(oskar): opaque

when #config(TRACY_MANUAL_LIFETIME, false) {
@(default_calling_convention="c")
foreign tracy {
___tracy_startup_profiler :: proc() ---
___tracy_shutdown_profiler :: proc() ---
___tracy_profiler_started :: proc() -> b32 ---
}
}

@(default_calling_convention="c")
foreign tracy {
___tracy_set_thread_name :: proc( name: cstring ) ---

___tracy_alloc_srcloc :: proc( line: u32, source: cstring, sourceSz: c.size_t, function: cstring, functionSz: c.size_t ) -> u64 ---
___tracy_alloc_srcloc_name :: proc( line: u32, source: cstring, sourceSz: c.size_t, function: cstring, functionSz: c.size_t, name: cstring, nameSz: c.size_t ) -> u64 ---
___tracy_alloc_srcloc :: proc( line: u32, source: cstring, sourceSz: c.size_t, function: cstring, functionSz: c.size_t, color: u32 = 0 ) -> u64 ---
___tracy_alloc_srcloc_name :: proc( line: u32, source: cstring, sourceSz: c.size_t, function: cstring, functionSz: c.size_t, name: cstring, nameSz: c.size_t, color: u32 = 0 ) -> u64 ---

___tracy_emit_zone_begin :: proc( srcloc: ^___tracy_source_location_data, active: b32 ) -> ___tracy_c_zone_context ---
___tracy_emit_zone_begin_callstack :: proc( srcloc: ^___tracy_source_location_data, depth: i32, active: b32 ) -> ___tracy_c_zone_context ---
Expand All @@ -105,6 +113,7 @@ foreign tracy {
___tracy_emit_gpu_new_context :: proc( ___tracy_gpu_new_context_data ) ---
___tracy_emit_gpu_context_name :: proc( ___tracy_gpu_context_name_data ) ---
___tracy_emit_gpu_calibration :: proc( ___tracy_gpu_calibration_data ) ---
___tracy_emit_gpu_time_sync :: proc( ___tracy_gpu_time_sync_data ) ---

___tracy_emit_gpu_zone_begin_serial :: proc( ___tracy_gpu_zone_begin_data ) ---
___tracy_emit_gpu_zone_begin_callstack_serial :: proc( ___tracy_gpu_zone_begin_callstack_data ) ---
Expand All @@ -115,6 +124,7 @@ foreign tracy {
___tracy_emit_gpu_new_context_serial :: proc( ___tracy_gpu_new_context_data ) ---
___tracy_emit_gpu_context_name_serial :: proc( ___tracy_gpu_context_name_data ) ---
___tracy_emit_gpu_calibration_serial :: proc( ___tracy_gpu_calibration_data ) ---
___tracy_emit_gpu_time_sync_serial :: proc( ___tracy_gpu_time_sync_data ) ---

___tracy_connected :: proc() -> b32 ---

Expand All @@ -135,14 +145,28 @@ foreign tracy {
___tracy_emit_frame_mark :: proc( name: cstring ) ---
___tracy_emit_frame_mark_start :: proc( name: cstring ) ---
___tracy_emit_frame_mark_end :: proc( name: cstring ) ---
___tracy_emit_frame_image :: proc( image: rawptr, w, h: u16, offset: u8, flip: i32 ) ---
___tracy_emit_frame_image :: proc( image: rawptr, w, h: u16, offset: u8, flip: b32 ) ---

___tracy_emit_plot :: proc( name: cstring, val: f64 ) ---
___tracy_emit_plot_float :: proc( name: cstring, val: f32 ) ---
___tracy_emit_plot_int :: proc( name: cstring, val: i64 ) ---
___tracy_emit_plot_config :: proc( name: cstring, type: TracyPlotFormatEnum, step, fill: b32, color: u32 ) ---
___tracy_emit_message_appinfo :: proc( txt: cstring, size: c.size_t ) ---

___tracy_fiber_enter :: proc( fiber: cstring ) ---
___tracy_fiber_leave :: proc() ---
___tracy_announce_lockable_ctx :: proc( srcloc: ^___tracy_source_location_data ) -> ^__tracy_lockable_context_data ---
___tracy_terminate_lockable_ctx :: proc( lockdata: ^__tracy_lockable_context_data ) ---
___tracy_before_lock_lockable_ctx :: proc( lockdata: ^__tracy_lockable_context_data ) -> b32 ---
___tracy_after_lock_lockable_ctx :: proc( lockdata: ^__tracy_lockable_context_data ) ---
___tracy_after_unlock_lockable_ctx :: proc( lockdata: ^__tracy_lockable_context_data ) ---
___tracy_after_try_lock_lockable_ctx :: proc( lockdata: ^__tracy_lockable_context_data, acquired: b32 ) ---
___tracy_mark_lockable_ctx :: proc( lockdata: ^__tracy_lockable_context_data, srcloc: ^___tracy_source_location_data ) ---
___tracy_custom_name_lockable_ctx :: proc( lockdata: ^__tracy_lockable_context_data, name: cstring, nameSz: c.size_t ) ---
}

when #config(TRACY_FIBERS, false) {
@(default_calling_convention="c")
foreign tracy {
___tracy_fiber_enter :: proc( fiber: cstring ) ---
___tracy_fiber_leave :: proc() ---
}
}
1 change: 0 additions & 1 deletion tracy
Submodule tracy deleted from 37aff7
62 changes: 62 additions & 0 deletions vendor/tracy/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
Checks:
'
clang-diagnostic-*,
clang-analyzer-*,
bugprone-*,
google-*,
misc-*,
modernize-*,
performance-*,
readability-*,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-narrowing-conversions,
-bugprone-reserved-identifier,
-google-readability-braces-around-statements,
-google-readability-casting,
-google-readability-function-size,
-google-readability-todo,
-google-readability-namespace-comments,
-misc-confusable-identifiers,
-misc-no-recursion,
-modernize-avoid-c-arrays,
-modernize-deprecated-headers,
-modernize-use-default-member-init,
-modernize-use-trailing-return-type,
-performance-no-int-to-ptr,
-readability-braces-around-statements,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-qualified-auto,
-readability-uppercase-literal-suffix
'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
llvm-else-after-return.WarnOnConditionVariables: 'false'
modernize-loop-convert.MinConfidence: reasonable
modernize-replace-auto-ptr.IncludeStyle: llvm
modernize-pass-by-value.IncludeStyle: llvm
google-readability-namespace-comments.ShortNamespaceLines: '10'
google-readability-namespace-comments.SpacesBeforeComments: '2'
cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true'
google-readability-braces-around-statements.ShortStatementLines: '1'
cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
modernize-loop-convert.MaxCopySize: '16'
cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false'
cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false'
modernize-use-nullptr.NullMacros: 'NULL'
llvm-qualified-auto.AddConstToQualified: 'false'
modernize-loop-convert.NamingStyle: CamelCase
llvm-else-after-return.WarnOnUnfixable: 'false'
google-readability-function-size.StatementThreshold: '800'
...

1 change: 1 addition & 0 deletions vendor/tracy/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: wolfpld
Binary file added vendor/tracy/.github/sponsor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading