Browse Source

Added Tracy profiler

The module is still WIP. Some build system changes are necessary to
make it sufficiently convenient
pitch-detection
Macoy Madson 2 years ago
parent
commit
0bded8b046
  1. 3
      .gitmodules
  2. 4
      BuildTools.sh
  3. 1
      Build_Debug.sh
  4. 1
      Dependencies/tracy
  5. 3
      RunProfiler.sh
  6. 48
      src/Tracy.cake

3
.gitmodules

@ -7,3 +7,6 @@
[submodule "Dependencies/ogre-next-deps"]
path = Dependencies/ogre-next-deps
url = https://github.com/OGRECave/ogre-next-deps
[submodule "Dependencies/tracy"]
path = Dependencies/tracy
url = https://github.com/wolfpld/tracy

4
BuildTools.sh

@ -0,0 +1,4 @@
#!/bin/sh
# These are things not required to build, but are useful for debugging/profiling etc.
cd Dependencies/tracy/profiler/build/unix && make -j4

1
Build_Debug.sh

@ -7,3 +7,4 @@
# ./Dependencies/cakelisp/bin/cakelisp --verbose-processes src/SDL.cake
./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects test/SDLOgreApp.cake \
&& echo "\n\nRUNTIME\n" && cd test && ./SDLOgreApp
# ./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects src/Tracy.cake

1
Dependencies/tracy

@ -0,0 +1 @@
Subproject commit e580dfeed3f44911cf0a5ce0f584603aafa9ecde

3
RunProfiler.sh

@ -0,0 +1,3 @@
#!/bin/sh
cd Dependencies/tracy/profiler/build/unix && ./Tracy-release

48
src/Tracy.cake

@ -0,0 +1,48 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(import &comptime-only "Macros.cake")
(c-import "Tracy.hpp")
;; TODO: Linux only
(c-import "unistd.h")
(defun test-tracy-main (&return int)
(ZoneScopedN "main")
(while (not (on-call (call (in tracy GetProfiler)) IsConnected))
(ZoneScopedN "wait for profiler")
(sleep 1))
(var i int 0)
(while (< i 100000)
(ZoneScopedN "hot loop")
(sleep 1)
(incr i))
(return 0))
;; TODO: Any file which includes Tracy needs these
;; For now, an easy way to build files which include necessary headers
(defmacro module-use-tracy-build-options ()
(tokenize-push output
(set-module-option build-time-compiler "/usr/bin/clang++")
;; Include cakelisp source for DynamicLoader.hpp
(set-module-option build-time-compile-arguments
"-Werror" "-Wall" "-Wextra" "-Wno-unused-parameter" "-Wno-unused-variable"
"-c" 'source-input "-o" 'object-output "-fPIC"
"-DTRACY_ENABLE" "-IDependencies/tracy"))
(return true))
(module-use-tracy-build-options)
(add-cpp-build-dependency "../Dependencies/tracy/TracyClient.cpp")
(defun-comptime tracy-link-hook (manager (& ModuleManager)
linkCommand (& ProcessCommand)
linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int
&return bool)
(command-add-string-argument "-lpthread")
(command-add-string-argument "-ldl")
(return true))
(add-compile-time-hook pre-link tracy-link-hook)
Loading…
Cancel
Save