VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
vae_profiler.hpp
Go to the documentation of this file.
1#ifndef _VAE_PROFILER
2#define _VAE_PROFILER
3
4namespace vae { namespace core { namespace profiler {
5 const char* const audioFrame = "Audio Frame";
6 const char* const updateFrame = "Update Frame";
7 const char* const voiceCount = "Voices";
8 const char* const voiceFinishedCount = "Voices Finished Queue";
9 const char* const voiceVirtualCount = "Virtual voices";
10 const char* const starvedVoiceCount = "Starved voices";
11 const char* const stoppedVoiceOverflow = "Stopped voice overflow";
12 const char* const voiceHRTFCount = "HRTF voices";
13 const char* const emitters = "Emitters";
14 const char* const deviceUnderruns = "Device Underruns";
15 const char* const deviceOverruns = "Device Overruns";
16 const char* const engineUnderruns = "Engine Underruns";
17 const char* const engineOverruns = "Engine Overruns";
18 const char* const tklbAllocator = "tklb Allocator"; ///< Old tklb stuff, shouldn't be anything important in here
19 const char* const objAllocator = "new Allocator"; ///< Generic object heap like vae::core::Device
20 const char* const fsAllocator = "FS Allocator"; ///< Deals with everything deserialization
21 const char* const mainAllocator = "Main Allocator"; ///< Allocates all the bank, event emitter arrays
22 const char* const dspAllocator = "DSP allocator"; ///< Tracks DSP memory usage
23} } } // vae::core::profiler
24
25
26#ifdef VAE_USE_PROFILER
27 #define TRACY_ENABLE
28 #include "../../external/tracy/Tracy.hpp"
29 #define VAE_PROFILER_FRAME_MARK() FrameMark
30 #define VAE_PROFILER_FRAME_MARK_START(name) FrameMarkStart(name)
31 #define VAE_PROFILER_FRAME_MARK_END(name) FrameMarkEnd(name)
32 #define VAE_PROFILER_SCOPE() ZoneScoped
33 #define VAE_PROFILER_SCOPE_NAMED(name) ZoneScopedN(name)
34 #define VAE_PROFILER_PLOT(name, value) TracyPlot(name, value)
35 #define VEA_PROFILER_THREAD_NAME(name) tracy::SetThreadName(name);
36 #define VAE_PROFILER_MESSAGE_L(msg) TracyMessageL(msg)
37 #define VAE_PROFILER_MESSAGE(msg, size) TracyMessage(msg, size)
38 #define VAE_PROFILER_MALLOC(ptr, size) TracyAlloc(ptr, size);
39 #define VAE_PROFILER_FREE(ptr) TracyFree(ptr);
40 #define VAE_PROFILER_MALLOC_L(ptr, size, name) TracyAllocN(ptr, size, name);
41 #define VAE_PROFILER_FREE_L(ptr, name) TracyFreeN(ptr, name);
42 #define VAE_PROFILER_MUTEX(type, name, desc) TracyLockableN(type, name, desc)
43
44 // Add tracking to tklb which is mostly audiobuffers
45 #define TKLB_TRACK_ALLOCATE(ptr, size) VAE_PROFILER_MALLOC_L(ptr, size, vae::core::profiler::tklbAllocator)
46 #define TKLB_TRACK_FREE(ptr, size) VAE_PROFILER_FREE_L(ptr, vae::core::profiler::tklbAllocator)
47
48 #define VAE_PROFILER_OVERLOAD_NEW() \
49 void* operator new(std::size_t count) { \
50 auto ptr = std::malloc(count); \
51 VAE_PROFILER_MALLOC_L(ptr, count, \
52 vae::core::profiler::objAllocator \
53 ); \
54 return ptr; \
55 } \
56 void operator delete (void* ptr) noexcept { \
57 VAE_PROFILER_FREE_L(ptr, \
58 vae::core::profiler::objAllocator \
59 ); \
60 std::free(ptr); \
61 } \
62
63 namespace vae { namespace core {
64 using Mutex = std::mutex;
65 using Lock = std::lock_guard<LockableBase(Mutex)>;
66 } } // vae::core
67
68#else
69 #define VAE_PROFILER_FRAME_MARK() ///< Marks a frame to calculate FPS, not really needed for audio
70 #define VAE_PROFILER_FRAME_MARK_START(name) ///< Starts a named frame, uses const defined above to maintain the same pointer
71 #define VAE_PROFILER_FRAME_MARK_END(name) ///< Stops a named frame
72 #define VAE_PROFILER_SCOPE() ///< Profiles a scope
73 #define VAE_PROFILER_SCOPE_NAMED(name) ///< Profiles a scope and names it
74 #define VAE_PROFILER_PLOT(name, value) ///< Records a value
75 #define VEA_PROFILER_THREAD_NAME(name) ///< Sets name for current thread
76 #define VAE_PROFILER_MESSAGE_L(msg) ///< Send literal message to profiler
77 #define VAE_PROFILER_MESSAGE(msg, size) ///< Send dynamic string message
78 #define VAE_PROFILER_MALLOC(ptr, size) ///< Track allocation
79 #define VAE_PROFILER_FREE(ptr) ///< Track free
80 #define VAE_PROFILER_OVERLOAD_NEW() ///< Overloads new and delete of class to be tracked
81 #define VAE_PROFILER_MUTEX(type, name, desc) type name;
82 #define VAE_PROFILER_FREE_L(ptr, name) ///< Track named allocaions
83 #define VAE_PROFILER_MALLOC_L(ptr, size, name) ///< Track named allocaions
84#endif // VAE_USE_PROFILER
85
86#endif // _VAE_PROFILER
const char *const fsAllocator
Deals with everything deserialization.
const char *const deviceUnderruns
const char *const updateFrame
Definition: vae_profiler.hpp:6
const char *const dspAllocator
Tracks DSP memory usage.
const char *const tklbAllocator
Old tklb stuff, shouldn't be anything important in here.
const char *const deviceOverruns
const char *const voiceHRTFCount
const char *const audioFrame
Definition: vae_profiler.hpp:5
const char *const engineUnderruns
const char *const starvedVoiceCount
const char *const engineOverruns
const char *const mainAllocator
Allocates all the bank, event emitter arrays.
const char *const voiceCount
Definition: vae_profiler.hpp:7
const char *const voiceVirtualCount
Definition: vae_profiler.hpp:9
const char *const stoppedVoiceOverflow
const char *const emitters
const char *const objAllocator
Generic object heap like vae::core::Device.
const char *const voiceFinishedCount
Definition: vae_profiler.hpp:8
std::mutex Mutex
Definition: vae_types.hpp:52
std::unique_lock< Mutex > Lock
Definition: vae_types.hpp:53
Contains Typedefinitions and basic structures use by the public API and internally.
Definition: vae.hpp:31