#if defined(IsProfilingEnabled) && IsProfilingEnabled == 1 //////////////////////////////////////////////////////////// //~ Profiling enabled #ifndef __clang__ # error Only clang is supported when compiling with IsProfilingEnabled=1 (cleanup attributes are required for profiling markup) #endif #define ProfilingSystemTrace 0 #define ProfilingCaptureFrame 0 #define ProfilingLocks 0 #define ProfilingGpu 1 #define ProfilingGpuStablePowerState 1 //#define ProfilerThreadAffinityMask 0x000000000000F000ull #define ProfilerThreadAffinityMask 0 #define ProfilerThreadPrefixWstr L"Tracy" #define ProfilingOutFileWstr L".tracy" #define ProfilingCmdWstr L"cmd /C start \"\" /wait tracy-capture.exe -o .tracy -a 127.0.0.1 && start \"\" tracy-profiler.exe .tracy" //#define ProfilingCmdWstr L"tracy-profiler.exe -a 127.0.0.1" /* Tracy defines */ #define TRACY_ENABLE #define TRACY_FIBERS #if !ProfilingSystemTrace # define TRACY_NO_CALLSTACK # define TRACY_NO_SYSTEM_TRACING #endif /* Include tracy client */ #pragma clang diagnostic ignored "-Wshadow" #pragma clang diagnostic ignored "-Wextra-semi" #pragma clang diagnostic ignored "-Wextra-semi-stmt" #pragma clang diagnostic ignored "-Wpointer-sign" #pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers" #include TracyClientHeaderPath inline void __prof_zone_cleanup_func(TracyCZoneCtx *ctx) { TracyCZoneEnd(*ctx) } #define __profnc(name, color) static const struct ___tracy_source_location_data Cat(__tracy_source_location,__LINE__) = { (name), __func__, __FILE__, (uint32_t)__LINE__, Bgr32(color) }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &Cat(__tracy_source_location,__LINE__), 1 ) #define __profn(name) __profnc(name, 0) #define __prof __profnc(0, 0) #define __profvalue(v) TracyCZoneValue(__tracy_zone_ctx, (v)) #define __profalloc(ptr, size) TracyCAlloc((ptr), (size)) #define __proffree(ptr) TracyCFree((ptr)) #define __profmsg(txt, len, col) TracyCMessageC((txt), (len), Bgr32(col)) #define __profframe(name) TracyCFrameMarkNamed((name)) #define __profthread(name, group_hint) TracyCSetThreadNameWithHint((name), (group_hint)) enum __prof_plot_type { __prof_plot_type_number = TracyPlotFormatNumber, __prof_plot_type_memory = TracyPlotFormatMemory, __prof_plot_type_percentage = TracyPlotFormatPercentage, __prof_plot_type_watt = TracyPlotFormatWatt }; #define __prof_plot_init(name, type, step, fill, color) TracyCPlotConfig(name, type, step, fill, Bgr32(color)) #define __prof_plot(name, val) TracyCPlot(name, val) #define __prof_plot_i(name, val) TracyCPlotI(name, val) #define __prof_is_connected() ___tracy_connected() #else //////////////////////////////////////////////////////////// //~ Profiling disabled #define ProfilingCaptureFrame 0 #define ProfilingLocks 0 #define ProfilingGpu 0 #define __profnc(name, color) #define __profn(name) #define __prof #define __profvalue(v) #define __profalloc(ptr, size) #define __proffree(ptr) #define __profmsg(txt, len, col) #define __profframe(name) #define __profthread(name, group_hint) #define __prof_plot_init(name, type, step, fill, color) #define __prof_plot(name, val) #define __prof_plot_i(name, val) #define __prof_is_connected() 0 #endif /* IsProfilingEnabled */ #if ProfilingLocks # define __proflock_ctx(name) struct TracyCSharedLockCtx *name # define __proflock_acquire(ctx) TracyCSharedLockAnnounce((ctx)) # define __proflock_release(ctx) TracyCSharedLockTerminate((ctx)) # define __proflock_before_exclusive_lock(ctx) TracyCSharedLockBeforeExclusiveLock((ctx)) # define __proflock_after_exclusive_lock(ctx) TracyCSharedLockAfterExclusiveLock((ctx)) # define __proflock_after_exclusive_unlock(ctx) TracyCSharedLockAfterExclusiveUnlock((ctx)) # define __proflock_after_try_exclusive_lock(ctx, acquired) TracyCSharedLockAfterTryExclusiveLock((ctx), (acquired)) # define __proflock_before_shared_lock(ctx) TracyCSharedLockBeforeSharedLock((ctx)) # define __proflock_after_shared_lock(ctx) TracyCSharedLockAfterSharedLock((ctx)) # define __proflock_after_shared_unlock(ctx) TracyCSharedLockAfterSharedUnlock((ctx)) # define __proflock_after_try_shared_lock(ctx, acquired) TracyCSharedLockAfterTrySharedLock((ctx), (acquired)) # define __proflock_mark(ctx) TracyCSharedLockMark((ctx)) # define __proflock_custom_name(ctx, name, len) TracyCSharedLockCustomName((ctx), (name), (len)) #else # define __proflock_acquire(ctx) # define __proflock_release(ctx) # define __proflock_before_exclusive_lock(ctx) # define __proflock_after_exclusive_lock(ctx) # define __proflock_after_exclusive_unlock(ctx) # define __proflock_after_try_exclusive_lock(ctx, acquired) # define __proflock_before_shared_lock(ctx) # define __proflock_after_shared_lock(ctx) # define __proflock_after_shared_unlock(ctx) # define __proflock_after_try_shared_lock(ctx, acquired) # define __proflock_mark(ctx) # define __proflock_custom_name(ctx, name, len) #endif /* IsProfilingEnabled && ProfilingLocks */ #if ProfilingGpu /* Dx11 */ inline void __prof_dx11_zone_cleanup_func(TracyCD3D11ZoneCtx *ctx) { ___tracy_d3d11_emit_zone_end(*ctx); } # define __profnc_dx11(dx11_ctx, name, color) static const struct ___tracy_source_location_data Cat(__tracy_gpu_d3d11_source_location,__LINE__) = { name, __func__, __FILE__, (uint32_t)__LINE__, Bgr32(color) }; __attribute((cleanup(__prof_dx11_zone_cleanup_func))) TracyCD3D11ZoneCtx __tracy_d3d11_zone_ctx; ___tracy_d3d11_emit_zone_begin( dx11_ctx, &__tracy_d3d11_zone_ctx, &Cat(__tracy_gpu_d3d11_source_location,__LINE__), 1) # define __prof_dx11_ctx(name) struct TracyCD3D11Ctx *name # define __prof_dx11_ctx_acquire(ctx, device, device_ctx, name, name_len) ctx = ___tracy_d3d11_context_announce(device, device_ctx, name, name_len) # define __prof_dx11_ctx_release(ctx) ___tracy_d3d11_context_terminate(ctx) # define __prof_dx11_collect(ctx) ___tracy_d3d11_context_collect(ctx) /* Dx12 */ inline void __prof_dx12_zone_cleanup_func(TracyCD3D12ZoneCtx *ctx) { ___tracy_d3d12_emit_zone_end(*ctx); } # define __profnc_dx12(dx12_ctx, cmd_list, name, color) static const struct ___tracy_source_location_data Cat(__tracy_gpu_d3d12_source_location,__LINE__) = { name, __func__, __FILE__, (uint32_t)__LINE__, Bgr32(color) }; __attribute((cleanup(__prof_dx12_zone_cleanup_func))) TracyCD3D12ZoneCtx __tracy_d3d12_zone_ctx; ___tracy_d3d12_emit_zone_begin( dx12_ctx, cmd_list, &__tracy_d3d12_zone_ctx, &Cat(__tracy_gpu_d3d12_source_location,__LINE__), 1) # define __prof_dx12_ctx(name) struct TracyCD3D12Ctx *name # define __prof_dx12_ctx_acquire(ctx, device, queue, name, name_len) ctx = ___tracy_d3d12_context_announce(device, queue, name, name_len) # define __prof_dx12_ctx_release(ctx) ___tracy_d3d12_context_terminate(ctx) # define __prof_dx12_new_frame(ctx) ___tracy_d3d12_context_new_frame(ctx) # define __prof_dx12_collect(ctx) ___tracy_d3d12_context_collect(ctx) #else # define __profnc_dx11(dx11_ctx, name, color) # define __prof_dx11_ctx_acquire(ctx, device, device_ctx, name, name_len) # define __prof_dx11_ctx_release(ctx) # define __prof_dx11_collect(ctx) # define __profnc_dx12(dx11_ctx, queue, name, color) # define __prof_dx12_ctx_acquire(ctx, device, queue, name, name_len) # define __prof_dx12_ctx_release(ctx) # define __prof_dx12_new_frame(ctx) # define __prof_dx12_collect(ctx) #endif /* ProfilingGpu */ #if ProfilingCaptureFrame # define __profframeimage(image, width, height, offset, flipped) TracyCFrameImage((image), (width), (height), (offset), (flipped)) #else # define __profframeimage(image, width, height, offset, flipped) #endif /* ProfilingCaptureFrame */ #ifdef TRACY_FIBERS /* Tracy fiber methods are wrapped in ForceNoInline because otherwise issues can arise * accross fiber context boundaries during optimization */ __attribute__((noinline)) inline void __prof_fiber_enter(char *fiber_name, int profiler_group) { TracyCFiberEnterWithHint(fiber_name, profiler_group); } __attribute__((noinline)) inline void __prof_fiber_leave(void) { TracyCFiberLeave; } #else # define __prof_fiber_enter(fiber_name, profiler_group) # define __prof_fiber_leave() #endif