From 718c0de889c59b109ab4f1c89cfcfbe80669da58 Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 3 Dec 2025 20:41:03 -0600 Subject: [PATCH] remove profiler markup --- src/ase/ase.c | 8 - src/asset_cache/asset_cache.c | 1 - src/base/base.h | 4 - src/base/base_arena.c | 8 - src/base/base_log.h | 2 +- src/base/base_string.c | 2 - src/base/base_util.h | 6 - src/base/base_win32/base_win32.c | 75 --------- src/base/base_win32/base_win32_job.c | 23 +-- src/base/base_win32/base_win32_job.h | 3 +- src/base/base_win32/base_win32_log.c | 3 - src/config.h | 5 - src/draw/draw.c | 1 - src/font/font.c | 4 - src/gpu/gpu_core.h | 8 +- src/gpu/gpu_dx12/gpu_dx12.c | 20 +-- src/meta/meta.c | 11 -- src/mixer/mixer.c | 8 - src/net/net.c | 8 - src/platform/platform_win32/platform_win32.c | 19 --- .../playback_wasapi/playback_wasapi.c | 8 - src/pp/pp_vis/pp_vis_widgets.c | 1 - src/prof/prof_inc.h | 1 - src/prof/prof_tracy.cpp | 9 - src/prof/prof_tracy.h | 158 ------------------ src/settings/settings.c | 3 - src/sound/sound.c | 4 - src/tar/tar.c | 2 - src/ttf/ttf_dwrite/ttf_dwrite.c | 3 - src/ui/ui_core.c | 6 - src/window/window_win32/window_win32.c | 1 - 31 files changed, 7 insertions(+), 408 deletions(-) delete mode 100644 src/prof/prof_inc.h delete mode 100644 src/prof/prof_tracy.cpp delete mode 100644 src/prof/prof_tracy.h diff --git a/src/ase/ase.c b/src/ase/ase.c index 1cbc0838..602a8769 100644 --- a/src/ase/ase.c +++ b/src/ase/ase.c @@ -159,8 +159,6 @@ u32 ASE_ReverseBits(u32 v, u32 bit_count) ASE_HuffDict ASE_InitHuffDict(Arena *arena, u32 max_code_bits, u32 *bl_counts, u32 bl_counts_count) { - __prof; - ASE_HuffDict result = ZI; result.max_code_bits = max_code_bits; result.entries_count = (1 << max_code_bits); @@ -222,7 +220,6 @@ void ASE_Inflate(u8 *dst, u8 *encoded) { TempArena scratch = BeginScratchNoConflict(); - __prof; ASE_Bitbuff bb = { .data = encoded }; /* ZLIB header */ @@ -484,8 +481,6 @@ void ASE_MakeDimensionsSquareish(ASE_Header *header, u32 *frames_x, u32 *frames_ ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded) { - __prof; - TempArena scratch = BeginScratch(arena); ASE_DecodedImage result = ZI; @@ -692,7 +687,6 @@ ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded) //- Assemble image from cels { - __profn("Build image from cels"); for (Ace_Cel *cel = cel_head; cel; cel = cel->next) { ASE_Layer *layer = layers_ordered[cel->layer_index]; @@ -779,8 +773,6 @@ abort: ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded) { - __prof; - ASE_DecodedSheet result = ZI; BB_Buff bb = BB_BuffFromString(encoded); diff --git a/src/asset_cache/asset_cache.c b/src/asset_cache/asset_cache.c index 5f670584..40a01521 100644 --- a/src/asset_cache/asset_cache.c +++ b/src/asset_cache/asset_cache.c @@ -7,7 +7,6 @@ AC_SharedState AC_shared_state = ZI; void AC_Startup(void) { - __prof; AC_SharedState *g = &AC_shared_state; g->store_arena = AcquireArena(Gibi(64)); } diff --git a/src/base/base.h b/src/base/base.h index 3ea85d4b..8b2558db 100644 --- a/src/base/base.h +++ b/src/base/base.h @@ -25,10 +25,6 @@ #error Missing compile time definition for 'IsDeveloperModeEnabled' #endif -#ifndef IsProfilingEnabled - #error Missing compile time definition for 'IsProfilingEnabled' -#endif - #ifndef IsUnoptimized #error Missing compile time definition for 'IsUnoptimized' #endif diff --git a/src/base/base_arena.c b/src/base/base_arena.c index e15a9d65..83801983 100644 --- a/src/base/base_arena.c +++ b/src/base/base_arena.c @@ -5,7 +5,6 @@ SharedArenaCtx shared_arena_ctx = ZI; Arena *AcquireArena(u64 reserve) { - __prof; reserve += ArenaHeaderSize; /* Round up to nearest block size */ @@ -36,7 +35,6 @@ Arena *AcquireArena(u64 reserve) StaticAssert(ArenaHeaderSize <= ArenaBlockSize); /* Header must fit in first block */ StaticAssert(sizeof(Arena) <= ArenaHeaderSize); /* Arena struct must fit in header */ - __profalloc(base, ArenaBlockSize); AsanPoison(base + sizeof(Arena), ArenaBlockSize - sizeof(Arena)); AddGstat(GSTAT_MEMORY_COMMITTED, ArenaBlockSize); AddGstat(GSTAT_NUM_ARENAS, 1); @@ -52,8 +50,6 @@ Arena *AcquireArena(u64 reserve) void ReleaseArena(Arena *arena) { AsanUnpoison(arena, arena->committed + ArenaHeaderSize); - __prof; - __proffree(arena); AddGstat(GSTAT_MEMORY_COMMITTED, -(i64)(arena->committed - ArenaHeaderSize)); AddGstat(GSTAT_MEMORY_RESERVED, -(i64)(arena->reserved)); AddGstat(GSTAT_NUM_ARENAS, -1); @@ -112,7 +108,6 @@ void *PushBytesNoZero(Arena *arena, u64 size, u64 align) u64 new_pos = aligned_start_pos + size; if (new_pos > arena->committed) { - __profn("Arena commit"); /* Commit new block(s) */ u64 blocks_needed = (new_pos - arena->committed + ArenaBlockSize - 1) / ArenaBlockSize; u64 commit_bytes = blocks_needed * ArenaBlockSize; @@ -130,8 +125,6 @@ void *PushBytesNoZero(Arena *arena, u64 size, u64 align) } arena->committed += commit_bytes; AddGstat(GSTAT_MEMORY_COMMITTED, commit_bytes); - __proffree(arena); - __profalloc(arena, arena->committed + ArenaHeaderSize); AsanPoison(commit_address, commit_bytes); } @@ -244,7 +237,6 @@ FiberArenaCtx *FiberArenaCtxFromId(i16 fiber_id) FiberArenaCtx *ctx = &g->arena_contexts[fiber_id]; if (!ctx->perm_arena) { - __profn("Initialize fiber arena ctx"); ctx->perm_arena = AcquireArena(Gibi(64)); for (i32 i = 0; i < (i32)countof(ctx->scratch_arenas); ++i) { diff --git a/src/base/base_log.h b/src/base/base_log.h index de37874c..4cd8ec0b 100644 --- a/src/base/base_log.h +++ b/src/base/base_log.h @@ -29,7 +29,7 @@ Struct(LogEventsArray) /* Log level configuration */ #ifndef LogLevel_CompTime -# if IsRtcEnabled || IsProfilingEnabled +# if IsRtcEnabled # define LogLevel_CompTime LogLevel_Debug # else # define LogLevel_CompTime LogLevel_Info diff --git a/src/base/base_string.c b/src/base/base_string.c index 54603234..5ccc2b13 100644 --- a/src/base/base_string.c +++ b/src/base/base_string.c @@ -540,8 +540,6 @@ String TrimWhitespace(String s) */ String FormatStringV(Arena *arena, String fmt, va_list args) { - __prof; - u64 final_len = 0; u8 *final_text = ArenaNext(arena, u8); diff --git a/src/base/base_util.h b/src/base/base_util.h index 0750ab46..64ca8782 100644 --- a/src/base/base_util.h +++ b/src/base/base_util.h @@ -150,7 +150,6 @@ Inline void Mergesort(void *items, u64 item_count, u64 item_size, MergesortCompa Inline Dict *InitDict(Arena *arena, u64 bins_count) { - __prof; Dict *dict = PushStruct(arena, Dict); dict->bins_count = MaxU64(bins_count, 1); /* Ensure at least 1 bin */ dict->bins = PushStructs(arena, DictBin, dict->bins_count); @@ -171,7 +170,6 @@ Inline void ResetDict(Dict *dict) Inline DictEntry *EnsureDictEntry(Arena *arena, Dict *dict, u64 hash) { - __prof; DictBin *bin = &dict->bins[hash % dict->bins_count]; DictEntry *entry = bin->first; @@ -226,7 +224,6 @@ Inline DictEntry *EnsureDictEntry(Arena *arena, Dict *dict, u64 hash) Inline void SetDictValue(Arena *arena, Dict *dict, u64 hash, u64 value) { - __prof; DictEntry *entry = EnsureDictEntry(arena, dict, hash); entry->value = value; } @@ -289,7 +286,6 @@ Inline void RemoveDictEntry(Dict *dict, DictEntry *entry) Inline DictEntry *DictEntryFromHash(Dict *dict, u64 hash) { - __prof; DictEntry *result = 0; DictBin *bin = &dict->bins[hash % dict->bins_count]; for (DictEntry *entry = bin->first; entry; entry = entry->next_in_bin) @@ -306,14 +302,12 @@ Inline DictEntry *DictEntryFromHash(Dict *dict, u64 hash) Inline u64 DictValueFromHash(Dict *dict, u64 hash) { - __prof; DictEntry *entry = DictEntryFromHash(dict, hash); return entry ? entry->value : 0; } Inline u64 DictValueOrNilFromHash(Dict *dict, u64 hash, u64 nil) { - __prof; DictEntry *entry = DictEntryFromHash(dict, hash); return entry ? entry->value : nil; } diff --git a/src/base/base_win32/base_win32.c b/src/base/base_win32/base_win32.c index 6d541ab1..132f6c57 100644 --- a/src/base/base_win32/base_win32.c +++ b/src/base/base_win32/base_win32.c @@ -212,7 +212,6 @@ JobImpl(W32_StartupLayers, sig, id) JobImpl(W32_ShutdownLayers, sig, id) { - __prof; W32_SharedState *g = &W32_shared_state; i32 num_funcs = Atomic32Fetch(&g->num_exit_funcs); for (i32 i = num_funcs - 1; i >= 0; --i) @@ -228,82 +227,8 @@ JobImpl(W32_ShutdownLayers, sig, id) i32 W32_Main(void) { - __profthread("Main thread", PROF_THREAD_GROUP_MAIN); W32_SharedState *g = &W32_shared_state; -#if IsProfilingEnabled - /* Start profiler */ - { - __profn("Launch profiler"); - STARTUPINFO si = ZI; - si.cb = sizeof(si); - PROCESS_INFORMATION pi = ZI; - wchar_t cmd[sizeof(ProfilingCmdWstr)] = ZI; - CopyBytes(cmd, ProfilingCmdWstr, sizeof(ProfilingCmdWstr)); - DeleteFileW(ProfilingOutFileWstr); - b32 ok = CreateProcessW(0, cmd, 0, 0, 0, DETACHED_PROCESS, 0, 0, &si, &pi); - if (!ok) - { - MessageBoxExW(0, L"Failed to launch profiler using command '" ProfilingCmdWstr L"'.", L"Error", MB_ICONSTOP | MB_SETFOREGROUND | MB_TOPMOST, 0); - } - } - /* Set internal profiler thread affinities */ - { - __profn("Set profiler thread affinities"); - wchar_t *prefix_name_wstr = ProfilerThreadPrefixWstr; - u64 prefix_name_wstr_len = ((i32)sizeof(ProfilerThreadPrefixWstr) >> 1) - 1; - if (prefix_name_wstr_len > 0 && ProfilerThreadAffinityMask != 0) - { - DWORD proc_id = GetCurrentProcessId(); - HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); - if (snapshot != INVALID_HANDLE_VALUE) - { - THREADENTRY32 te = ZI; - te.dwSize = sizeof(THREADENTRY32); - if (Thread32First(snapshot, &te)) - { - do - { - if (te.th32OwnerProcessID == proc_id) - { - i32 thread_id = te.th32ThreadID; - HANDLE thread = OpenThread(THREAD_ALL_ACCESS, FALSE, thread_id); - if (thread) - { - wchar_t *thread_name_wstr = 0; - HRESULT hr = GetThreadDescription(thread, &thread_name_wstr); - if (SUCCEEDED(hr)) - { - u64 thread_name_len = WstrLenNoLimit(thread_name_wstr); - if (thread_name_len >= prefix_name_wstr_len && MatchBytes(thread_name_wstr, prefix_name_wstr, prefix_name_wstr_len)) - { - __profn("Set profiler thread affinity"); - b32 ok = SetThreadAffinityMask(thread, ProfilerThreadAffinityMask) != 0; - { - /* Retry until external tools can set correct process affinity */ - i32 delay_ms = 16; - while (!ok && delay_ms <= 1024) - { - __profn("Profiler thread affinity retry"); - Sleep(delay_ms); - ok = SetThreadAffinityMask(thread, ProfilerThreadAffinityMask) != 0; - delay_ms *= 2; - } - } - Assert(ok); - } - } - CloseHandle(thread); - } - } - } while (Thread32Next(snapshot, &te)); - } - } - CloseHandle(snapshot); - } - } -#endif - /* Init time */ { LARGE_INTEGER qpf; diff --git a/src/base/base_win32/base_win32_job.c b/src/base/base_win32/base_win32_job.c index 7e947d62..d1a960c7 100644 --- a/src/base/base_win32/base_win32_job.c +++ b/src/base/base_win32/base_win32_job.c @@ -39,8 +39,6 @@ DWORD WINAPI W32_Win32ThreadProc(LPVOID vt) char *thread_name_desc_cstr = CstrFromString(perm, thread_name_desc); wchar_t *thread_name_desc_wstr = WstrFromString(perm, thread_name_desc); - __profthread(thread_name_dsec_cstr, t->profiler_group); - /* Initialize COM */ CoInitializeEx(0, COINIT_MULTITHREADED); @@ -58,9 +56,8 @@ DWORD WINAPI W32_Win32ThreadProc(LPVOID vt) return 0; } -W32_Thread *W32_StartThread(W32_ThreadFunc *entry_point, void *thread_udata, String thread_name, i32 profiler_group) +W32_Thread *W32_StartThread(W32_ThreadFunc *entry_point, void *thread_udata, String thread_name) { - __prof; W32_SharedJobState *g = &W32_shared_job_state; TempArena scratch = BeginScratchNoConflict(); Arena *perm = PermArena(); @@ -71,7 +68,6 @@ W32_Thread *W32_StartThread(W32_ThreadFunc *entry_point, void *thread_udata, Str t->thread_name = PushString(perm, thread_name); t->entry_point = entry_point; t->thread_udata = thread_udata; - t->profiler_group = profiler_group; t->handle = CreateThread(0, W32_FiberStackSize, W32_Win32ThreadProc, t, 0, 0); if (!t->handle) @@ -86,7 +82,6 @@ W32_Thread *W32_StartThread(W32_ThreadFunc *entry_point, void *thread_udata, Str /* Returns 0 if the thread could not release in specified timeout (e.g. because it is still running) */ b32 W32_TryEndThread(W32_Thread *thread, f32 timeout_seconds) { - __prof; W32_SharedJobState *g = &W32_shared_job_state; b32 ok = 0; W32_Thread *t = (W32_Thread *)thread; @@ -108,7 +103,6 @@ b32 W32_TryEndThread(W32_Thread *thread, f32 timeout_seconds) void W32_WaitEndThread(W32_Thread *thread) { - __prof; b32 ok = W32_TryEndThread(thread, F32Infinity); Assert(ok); } @@ -160,7 +154,6 @@ W32_Fiber *W32_AcquireFiber(W32_JobPool *pool) } if (new_name_cstr != 0) { - __profn("Initialize fiber"); fiber->id = fiber_id; /* Id to ASCII */ @@ -200,7 +193,6 @@ W32_Fiber *W32_AcquireFiber(W32_JobPool *pool) /* Init win32 fiber */ if (pool != 0) { - __profn("CreateFiber"); fiber->pool = pool->id; #if VIRTUAL_FIBERS fiber->addr = CreateThread(0, W32_FiberStackSize, W32_VirtualFiberEntryPoint, (void *)(i64)fiber_id, 0, 0); @@ -211,7 +203,6 @@ W32_Fiber *W32_AcquireFiber(W32_JobPool *pool) else { /* Fiber is not a part of a job pool, convert thread to fiber */ - __profn("ConvertThreadToFiber"); fiber->addr = ConvertThreadToFiber((void *)(i64)fiber_id); #if VIRTUAL_FIBERS fiber->addr = GetCurrentThread(); @@ -275,7 +266,6 @@ void W32_FiberEntryPoint(void *_) W32_JobPool *pool = &W32_shared_job_state.job_pools[fiber->pool]; JobPoolId pool_id = fiber->pool; char *fiber_name_cstr = fiber->name_cstr; - __prof_fiber_enter(fiber_name_cstr, PROF_THREAD_GROUP_FIBERS - Mebi(pool_id) + Kibi(1) + fiber->id); for (;;) { W32_Task *task = fiber->task; @@ -311,7 +301,6 @@ void W32_FiberEntryPoint(void *_) /* Yield to worker */ { - __prof_fiber_leave(); W32_Fiber *parent_fiber = W32_FiberFromId(fiber->return_id); W32_SwitchToFiber(parent_fiber); } @@ -377,7 +366,6 @@ W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg) case JobPoolPriority_Audio: { /* https://learn.microsoft.com/en-us/windows/win32/procthread/multimedia-class-scheduler-service#registry-settings */ - __profn("Set mm thread characteristics"); DWORD task = 0; AvSetMmThreadCharacteristics(L"Pro Audio", &task); SetThreadPriority(thread_handle, THREAD_PRIORITY_TIME_CRITICAL); @@ -460,22 +448,18 @@ W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg) void SuspendFiber(void) { - __prof; i16 fiber_id = FiberId(); W32_Fiber *fiber = W32_FiberFromId(FiberId()); - __prof_fiber_leave(); { Atomic8Set(&fiber->status, W32_FiberStatus_Suspending); W32_Fiber *parent_fiber = W32_FiberFromId(fiber->return_id); W32_SwitchToFiber(parent_fiber); } - __prof_fiber_enter(fiber->name_cstr, PROF_THREAD_GROUP_FIBERS - Mebi(fiber->pool) + Kibi(1) + fiber->id); } /* NOTE: Must only be called on fibers suspended via SuspendFiber */ void ResumeFibers(i16 fiber_ids_count, i16 *fiber_ids) { - __prof; TempArena scratch = BeginScratchNoConflict(); W32_SharedJobState *g = &W32_shared_job_state; i32 num_pools = Atomic32Fetch(&g->num_pools); @@ -568,9 +552,6 @@ JobPoolId InitJobPool(u32 thread_count, String name, JobPoolPriority priority) pool->name = name; pool->priority = priority; - /* TODO: Real profiler group */ - i32 profiler_group = 0; - Arena *perm = PermArena(); pool->worker_threads = PushStructs(perm, W32_Thread *, pool->num_worker_threads); pool->worker_contexts = PushStructs(perm, W32_WorkerCtx, pool->num_worker_threads); @@ -580,7 +561,7 @@ JobPoolId InitJobPool(u32 thread_count, String name, JobPoolPriority priority) ctx->pool_id = pool_id; ctx->id = i; String worker_name = StringF(perm, "%F [%F]", FmtString(name), FmtSint(i)); - pool->worker_threads[i] = W32_StartThread(W32_JobWorkerEntryPoint, ctx, worker_name, profiler_group + i); + pool->worker_threads[i] = W32_StartThread(W32_JobWorkerEntryPoint, ctx, worker_name); } return pool_id; } diff --git a/src/base/base_win32/base_win32_job.h b/src/base/base_win32/base_win32_job.h index 9a3cf23c..75a73174 100644 --- a/src/base/base_win32/base_win32_job.h +++ b/src/base/base_win32/base_win32_job.h @@ -34,7 +34,6 @@ Struct(W32_Thread) String thread_name; W32_ThreadFunc *entry_point; void *thread_udata; - i32 profiler_group; HANDLE handle; }; @@ -180,7 +179,7 @@ void StartupJobs(void); //~ Thread operations DWORD WINAPI W32_Win32ThreadProc(LPVOID vt); -W32_Thread *W32_StartThread(W32_ThreadFunc *entry_point, void *thread_udata, String thread_name, i32 profiler_group); +W32_Thread *W32_StartThread(W32_ThreadFunc *entry_point, void *thread_udata, String thread_name); b32 W32_TryEndThread(W32_Thread *thread, f32 timeout_seconds); void W32_WaitEndThread(W32_Thread *thread); JobDecl(W32_DummyJob, EmptySig); diff --git a/src/base/base_win32/base_win32_log.c b/src/base/base_win32/base_win32_log.c index 37bd5507..320f123c 100644 --- a/src/base/base_win32/base_win32_log.c +++ b/src/base/base_win32/base_win32_log.c @@ -5,7 +5,6 @@ W32_SharedLogState W32_shared_log_state = ZI; void InitLogSystem(String logfile_path) { - __prof; W32_SharedLogState *g = &W32_shared_log_state; g->logs_arena = AcquireArena(Gibi(64)); g->log_msgs_arena = AcquireArena(Gibi(64)); @@ -33,7 +32,6 @@ void InitLogSystem(String logfile_path) void W32_Log(i32 level, String msg) { - __prof; W32_SharedLogState *g = &W32_shared_log_state; TempArena scratch = BeginScratchNoConflict(); if (Atomic32Fetch(&g->initialized)) @@ -43,7 +41,6 @@ void W32_Log(i32 level, String msg) { Panic(Lit("Invalid log level")); } - __profmsg((char *)msg.text, msg.len, settings.color); DateTime datetime = LocalDateTime(); i64 now_ns = TimeNs(); diff --git a/src/config.h b/src/config.h index 8a224e25..d9997ccf 100644 --- a/src/config.h +++ b/src/config.h @@ -85,11 +85,6 @@ /* If enabled, things like network writes & memory allocations will be tracked in a global statistics struct */ #define GstatIsEnabled 1 -#define PROF_THREAD_GROUP_FIBERS -(i64)Gibi(1) -#define PROF_THREAD_GROUP_SCHEDULER -(i64)Mebi(3) -#define PROF_THREAD_GROUP_WINDOW -(i64)Mebi(2) -#define PROF_THREAD_GROUP_MAIN -(i64)Mebi(1) - //////////////////////////////////////////////////////////// //~ Settings diff --git a/src/draw/draw.c b/src/draw/draw.c index 9ea6b50a..65a7cac7 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -5,7 +5,6 @@ D_SharedState D_shared_state = ZI; void D_Startup(void) { - __prof; D_SharedState *g = &D_shared_state; u32 pixel_white = 0xFFFFFFFF; g->solid_white_texture = GPU_AcquireTexture(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, VEC2I32(1, 1), &pixel_white); diff --git a/src/font/font.c b/src/font/font.c index b3ec35fa..210e691a 100644 --- a/src/font/font.c +++ b/src/font/font.c @@ -3,7 +3,6 @@ JobImpl(F_Load, sig, _) { - __prof; TempArena scratch = BeginScratchNoConflict(); PERSIST Readonly u32 font_codes[] = { @@ -135,7 +134,6 @@ JobImpl(F_Load, sig, _) /* Returns the asset from the asset cache */ AC_Asset *F_LoadAsset(ResourceKey resource, f32 size, b32 wait) { - __prof; TempArena scratch = BeginScratchNoConflict(); String name = NameFromResource(resource); @@ -172,7 +170,6 @@ AC_Asset *F_LoadAsset(ResourceKey resource, f32 size, b32 wait) F_Font *F_LoadFontAsync(ResourceKey resource, f32 point_size) { - __prof; AC_Asset *asset = F_LoadAsset(resource, point_size, 0); F_Font *f = (F_Font *)AC_DataFromStore(asset); return f; @@ -180,7 +177,6 @@ F_Font *F_LoadFontAsync(ResourceKey resource, f32 point_size) F_Font *F_LoadFontWait(ResourceKey resource, f32 point_size) { - __prof; AC_Asset *asset = F_LoadAsset(resource, point_size, 1); AC_YieldOnAssetReady(asset); F_Font *f = (F_Font *)AC_DataFromStore(asset); diff --git a/src/gpu/gpu_core.h b/src/gpu/gpu_core.h index 68726951..3a1a7047 100644 --- a/src/gpu/gpu_core.h +++ b/src/gpu/gpu_core.h @@ -12,11 +12,11 @@ Struct(GPU_SwapchainHandle) { u64 v; }; //////////////////////////////////////////////////////////// //~ Queue types -#define GPU_MultiQueueIsEnabled (!IsProfilingEnabled) +#define GPU_IsMultiQueueEnabled 1 Enum(GPU_QueueKind) { -#if GPU_MultiQueueIsEnabled +#if GPU_IsMultiQueueEnabled GPU_QueueKind_Direct = 0, GPU_QueueKind_AsyncCompute = 1, GPU_QueueKind_AsyncCopy = 2, @@ -681,10 +681,6 @@ void GPU_RasterizeEx(GPU_CommandListHandle cl, void GPU_ClearRenderTarget(GPU_CommandListHandle cl, GPU_ResourceHandle render_target, Vec4 color); -//- Profile - -void GPU_ProfN(GPU_CommandListHandle cl, String name); - //////////////////////////////////////////////////////////// //~ @hookdecl Synchronization diff --git a/src/gpu/gpu_dx12/gpu_dx12.c b/src/gpu/gpu_dx12/gpu_dx12.c index 15cddb21..187915cd 100644 --- a/src/gpu/gpu_dx12/gpu_dx12.c +++ b/src/gpu/gpu_dx12/gpu_dx12.c @@ -19,7 +19,6 @@ void GPU_Startup(void) u32 dxgi_factory_flags = 0; #if GPU_DEBUG { - __profn("Enable debug layer"); ID3D12Debug *debug_controller0 = 0; { hr = D3D12GetDebugInterface(&IID_ID3D12Debug, (void **)&debug_controller0); @@ -50,7 +49,6 @@ void GPU_Startup(void) /* Create factory */ { - __profn("Create factory"); hr = CreateDXGIFactory2(dxgi_factory_flags, &IID_IDXGIFactory6, (void **)&g->factory); if (FAILED(hr)) { @@ -60,7 +58,6 @@ void GPU_Startup(void) /* Create device */ { - __profn("Create device"); IDXGIAdapter3 *adapter = 0; ID3D12Device10 *device = 0; String error = Lit("Could not initialize GPU device."); @@ -123,7 +120,6 @@ void GPU_Startup(void) #if GPU_DEBUG /* Enable D3D12 Debug break */ { - __profn("Enable d3d12 debug break"); ID3D12InfoQueue *info = 0; hr = ID3D12Device_QueryInterface(g->device, &IID_ID3D12InfoQueue, (void **)&info); if (FAILED(hr)) @@ -136,7 +132,6 @@ void GPU_Startup(void) } /* Enable DXGI Debug break */ { - __profn("Enable dxgi debug break"); IDXGIInfoQueue *dxgi_info = 0; hr = DXGIGetDebugInterface1(0, &IID_IDXGIInfoQueue, (void **)&dxgi_info); if (FAILED(hr)) @@ -252,8 +247,6 @@ void GPU_Startup(void) ID3D10Blob *blob = 0; if (SUCCEEDED(hr)) { - __profn("Serialize root signature"); - D3D12_ROOT_PARAMETER params[MaxShaderConstants] = ZI; for (i32 slot = 0; slot < MaxShaderConstants; ++slot) { @@ -279,7 +272,6 @@ void GPU_Startup(void) ID3D12RootSignature *rootsig = 0; if (SUCCEEDED(hr)) { - __profn("Create root signature"); hr = ID3D12Device_CreateRootSignature(g->device, 0, ID3D10Blob_GetBufferPointer(blob), ID3D10Blob_GetBufferSize(blob), &IID_ID3D12RootSignature, (void **)&rootsig); } g->bindless_rootsig = rootsig; @@ -675,7 +667,6 @@ void GPU_D12_CommitRawCommandList(GPU_D12_RawCommandList *cl) /* Close */ { - __profn("Close DX12 command list"); HRESULT hr = ID3D12GraphicsCommandList_Close(cl->d3d_cl); if (FAILED(hr)) { @@ -686,7 +677,6 @@ void GPU_D12_CommitRawCommandList(GPU_D12_RawCommandList *cl) /* Commit */ { - __profn("Commit"); Lock lock = LockE(&queue->commit_mutex); { u64 target = ++queue->commit_fence_target; @@ -2377,13 +2367,6 @@ void GPU_ClearRenderTarget(GPU_CommandListHandle cl_handle, GPU_ResourceHandle r cmd->clear_rtv.color = color; } -//- Profile - -void GPU_ProfN(GPU_CommandListHandle cl, String name) -{ - /* TODO */ -} - //////////////////////////////////////////////////////////// //~ @hookimpl Synchronization @@ -2409,7 +2392,7 @@ void GPU_SyncQueue(GPU_QueueKind completion_queue_kind, GPU_QueueKind waiter_que void GPU_SyncAllQueues(GPU_QueueKind completion_queue_kind) { - if (GPU_MultiQueueIsEnabled) + if (GPU_IsMultiQueueEnabled) { GPU_D12_Queue *completion_queue = GPU_D12_QueueFromKind(completion_queue_kind); ID3D12Fence *d3d_fence = completion_queue->commit_fence; @@ -2714,7 +2697,6 @@ void GPU_CommitBackbuffer(GPU_ResourceHandle backbuffer_handle, i32 vsync) /* Present */ { - __profn("Present"); HRESULT hr = IDXGISwapChain3_Present(swapchain->d3d_swapchain, vsync, present_flags); if (!SUCCEEDED(hr)) { diff --git a/src/meta/meta.c b/src/meta/meta.c index b682e1c7..a799613d 100644 --- a/src/meta/meta.c +++ b/src/meta/meta.c @@ -33,10 +33,6 @@ # define IsDeveloperModeEnabled 1 #endif -#ifndef IsProfilingEnabled -# define IsProfilingEnabled 0 -#endif - #ifndef IsUnoptimized # define IsUnoptimized 1 #endif @@ -53,7 +49,6 @@ //~ Includes //- Header files -#include "../prof/prof_inc.h" #include "../base/base_inc.h" #include "meta_os/meta_os_inc.h" #include "meta_file/meta_file_inc.h" @@ -332,11 +327,9 @@ JobImpl(Step, sig, id) PushStringToList(arena, &c_out_lines, Lit("// Auto generated file")); /* Include base layer */ { - String prof_inc_path = F_GetFull(arena, Lit("../src/prof/prof_inc.h")); String base_inc_path = F_GetFull(arena, Lit("../src/base/base_inc.h")); PushStringToList(arena, &c_out_lines, Lit("")); PushStringToList(arena, &c_out_lines, Lit("//- Base layer includes")); - PushStringToList(arena, &c_out_lines, StringF(arena, "#include \"%F\"", FmtString(prof_inc_path))); PushStringToList(arena, &c_out_lines, StringF(arena, "#include \"%F\"", FmtString(base_inc_path))); } /* Define resource stores */ @@ -507,11 +500,9 @@ JobImpl(Step, sig, id) PushStringToList(arena, &gpu_out_lines, Lit("// Auto generated file")); /* Include base layer */ { - String prof_inc_path = F_GetFull(arena, Lit("../src/prof/prof_inc.h")); String base_inc_path = F_GetFull(arena, Lit("../src/base/base_inc.h")); PushStringToList(arena, &gpu_out_lines, Lit("")); PushStringToList(arena, &gpu_out_lines, Lit("//- Base layer includes")); - PushStringToList(arena, &gpu_out_lines, StringF(arena, "#include \"%F\"", FmtString(prof_inc_path))); PushStringToList(arena, &gpu_out_lines, StringF(arena, "#include \"%F\"", FmtString(base_inc_path))); } /* Include dependency layers */ @@ -860,7 +851,6 @@ JobImpl(Build, _, __) u64 new_metahash = 0; { StringList check_files = ZI; - F_FilesFromDir(arena, &check_files, Lit("../src/prof"), F_IterFlag_Recurse); F_FilesFromDir(arena, &check_files, Lit("../src/base"), F_IterFlag_Recurse); F_FilesFromDir(arena, &check_files, Lit("../src/meta"), F_IterFlag_Recurse); PushStringToList(arena, &check_files, Lit("../src/config.h")); @@ -921,7 +911,6 @@ JobImpl(Build, _, __) PushStringToList(arena, &cp.defs, Lit("-DIsCrtlibEnabled=1")); PushStringToList(arena, &cp.defs, Lit("-DIsDebinfoEnabled=1")); PushStringToList(arena, &cp.defs, Lit("-DIsDeveloperModeEnabled=1")); - PushStringToList(arena, &cp.defs, Lit("-DIsProfilingEnabled=0")); PushStringToList(arena, &cp.defs, Lit("-DIsUnoptimized=1")); PushStringToList(arena, &cp.defs, Lit("-DIsTestingEnabled=0")); PushStringToList(arena, &cp.defs, Lit("-DIsHotSwappingEnabled=1")); diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c index c7fe7cb3..9066437e 100644 --- a/src/mixer/mixer.c +++ b/src/mixer/mixer.c @@ -21,7 +21,6 @@ MIX_SharedState M_shared_state = ZI; void MIX_Startup(void) { - __prof; MIX_SharedState *g = &M_shared_state; g->track_arena = AcquireArena(Gibi(64)); g->listener_pos = VEC2(0, 0); @@ -241,7 +240,6 @@ i16 MIX_SampleSound(SND_Sound *sound, u64 sample_pos, b32 wrap) /* To be called once per audio playback interval */ MIX_PcmF32 MIX_MixAllTracks(Arena *arena, u64 frame_count) { - __prof; TempArena scratch = BeginScratch(arena); MIX_SharedState *g = &M_shared_state; @@ -267,7 +265,6 @@ MIX_PcmF32 MIX_MixAllTracks(Arena *arena, u64 frame_count) mixes = PushStructsNoZero(scratch.arena, MIX_MixData *, g->track_playing_count); for (MIX_Track *track = g->track_first_playing; track; track = track->next) { - __profn("Prepare track"); MIX_MixData *mix = &track->mix; mix->desc = track->desc; mixes[mixes_count++] = mix; @@ -280,7 +277,6 @@ MIX_PcmF32 MIX_MixAllTracks(Arena *arena, u64 frame_count) for (u64 mix_index = 0; mix_index < mixes_count; ++mix_index) { - __profn("Mix track"); MIX_MixData *mix = mixes[mix_index]; if (mix->source->samples_count <= 0) @@ -338,7 +334,6 @@ MIX_PcmF32 MIX_MixAllTracks(Arena *arena, u64 frame_count) //- Resample /* Transform 16 bit source -> 32 bit stereo at output duration */ { - __profn("Resample"); f32 *out_samples = mix_pcm.samples; u64 out_frames_count = mix_pcm.count / 2; @@ -395,8 +390,6 @@ MIX_PcmF32 MIX_MixAllTracks(Arena *arena, u64 frame_count) //- Spatialize if (desc.flags & MIX_TrackFlag_Spatialize) { - __profn("Spatialize"); - /* Algorithm constants */ const f32 rolloff_height = 1.2f; const f32 rolloff_scale = 6.0f; @@ -457,7 +450,6 @@ MIX_PcmF32 MIX_MixAllTracks(Arena *arena, u64 frame_count) //- Update track effect data { - __profn("Update track effect data"); Lock lock = LockE(&g->mutex); for (u64 i = 0; i < mixes_count; ++i) { diff --git a/src/net/net.c b/src/net/net.c index 7a005b63..2a9c4978 100644 --- a/src/net/net.c +++ b/src/net/net.c @@ -544,13 +544,10 @@ N_EventList N_BeginUpdate(Arena *arena, N_Host *host) N_EventList events = ZI; i64 now_ns = TimeNs(); { - __profn("Read packets"); - //- Read socket N_RcvPacket *first_packet = 0; N_RcvPacket *last_packet = 0; { - __profn("Read socket"); P_Sock *sock = host->sock; P_SockReadResult result = ZI; while ((result = P_ReadSock(scratch.arena, sock)).valid) @@ -577,7 +574,6 @@ N_EventList N_BeginUpdate(Arena *arena, N_Host *host) //- Read incoming packets { - __profn("Process host packets"); for (N_RcvPacket *packet = first_packet; packet; packet = packet->next) { //struct sock *sock = packet->sock; @@ -766,7 +762,6 @@ N_EventList N_BeginUpdate(Arena *arena, N_Host *host) //- Update channels { - __profn("Update host channels"); for (u64 i = 0; i < host->num_channels_reserved; ++i) { N_Channel *channel = &host->channels[i]; @@ -850,13 +845,11 @@ N_EventList N_BeginUpdate(Arena *arena, N_Host *host) /* Process host cmds & send outgoing packets */ void N_EndUpdate(N_Host *host) { - __prof; TempArena scratch = BeginScratchNoConflict(); /* Process cmds into sendable packets */ /* TODO: Unreliable packets don't need to be allocated into unreliable packet queue, should just send them and forget */ { - __profn("Process host cmds"); for (N_Cmd *cmd = host->first_cmd; cmd; cmd = cmd->next) { N_CmdKind kind = cmd->kind; @@ -981,7 +974,6 @@ void N_EndUpdate(N_Host *host) //- Send packets /* TODO: Aggregate small packets */ { - __profn("Send host packets"); for (u64 i = 0; i < host->num_channels_reserved; ++i) { P_Sock *sock = host->sock; diff --git a/src/platform/platform_win32/platform_win32.c b/src/platform/platform_win32/platform_win32.c index 4051c0af..af31da58 100644 --- a/src/platform/platform_win32/platform_win32.c +++ b/src/platform/platform_win32/platform_win32.c @@ -181,10 +181,8 @@ JobImpl(P_W32_StartTimerSync, _, __) /* FIXME: shutdown */ for (;;) { - __profn("Job scheduler cycle"); { /* TODO: Minimum timer frequency in case timers ever become ultra precise in the future */ - __profn("Job scheduler wait"); LARGE_INTEGER due = ZI; due.QuadPart = -1; //due.QuadPart = -10000; @@ -244,7 +242,6 @@ String P_GetWritePath(Arena *arena) b32 P_IsFile(String path) { - __prof; TempArena scratch = BeginScratchNoConflict(); wchar_t *path_wstr = WstrFromString(scratch.arena, path); DWORD attributes = GetFileAttributesW(path_wstr); @@ -263,7 +260,6 @@ b32 P_IsDir(String path) void P_MkDir(String path) { - __prof; TempArena scratch = BeginScratchNoConflict(); wchar_t *path_wstr = WstrFromString(scratch.arena, path); int err_code = SHCreateDirectory(0, path_wstr); @@ -306,7 +302,6 @@ void P_MkDir(String path) //- File creation P_File P_OpenFileRead(String path) { - __prof; TempArena scratch = BeginScratchNoConflict(); P_File file = ZI; @@ -329,7 +324,6 @@ P_File P_OpenFileRead(String path) P_File P_OpenFileReadWait(String path) { - __prof; TempArena scratch = BeginScratchNoConflict(); P_File file = ZI; @@ -340,7 +334,6 @@ P_File P_OpenFileReadWait(String path) { if (GetLastError() == ERROR_SHARING_VIOLATION) { - __profn("File share conflict delay"); Sleep(delay_ms); if (delay_ms < 1024) { @@ -361,7 +354,6 @@ P_File P_OpenFileReadWait(String path) P_File P_OpenFileWrite(String path) { - __prof; TempArena scratch = BeginScratchNoConflict(); P_File file = ZI; @@ -384,7 +376,6 @@ P_File P_OpenFileWrite(String path) P_File P_OpenFileAppend(String path) { - __prof; TempArena scratch = BeginScratchNoConflict(); P_File file = ZI; @@ -407,7 +398,6 @@ P_File P_OpenFileAppend(String path) void P_CloseFile(P_File file) { - __prof; if (file.handle) { CloseHandle((HANDLE)file.handle); @@ -417,7 +407,6 @@ void P_CloseFile(P_File file) //- File data manipulation String P_ReadFile(Arena *arena, P_File file) { - __prof; i64 size = 0; GetFileSizeEx((HANDLE)file.handle, (PLARGE_INTEGER)&size); @@ -446,7 +435,6 @@ String P_ReadFile(Arena *arena, P_File file) void P_WriteFile(P_File file, String data) { - __prof; /* TODO: Check what the real data limit is and chunk sequentially based on * that (rather than failing) */ if (data.len >= 0x7FFF) @@ -478,8 +466,6 @@ u64 P_GetFileSize(P_File file) P_FileTime P_GetFileTime(P_File file) { - __prof; - /* Get file times */ FILETIME ft_created; FILETIME ft_accessed; @@ -518,7 +504,6 @@ P_FileTime P_GetFileTime(P_File file) P_FileMap P_OpenFileMap(P_File file) { - __prof; P_FileMap map = ZI; u64 size = P_GetFileSize(file); @@ -996,14 +981,11 @@ i64 P_GetCurrentTimerPeriodNs(void) void P_SleepPrecise(i64 sleep_time_ns) { - __prof; - i64 now_ns = TimeNs(); i64 target_ns = now_ns + sleep_time_ns; /* Sleep on timer to conserve power */ { - __profn("Sleep timer"); Fence *timer_fence = P_GetTimerFence(); i64 timer_period_ns = P_GetCurrentTimerPeriodNs(); i64 timer_tolerance_ns = timer_period_ns * 0.5; @@ -1015,7 +997,6 @@ void P_SleepPrecise(i64 sleep_time_ns) now_ns = TimeNs(); while (now_ns < target_ns) { - __profn("Sleep spin"); _mm_pause(); now_ns = TimeNs(); } diff --git a/src/playback/playback_wasapi/playback_wasapi.c b/src/playback/playback_wasapi/playback_wasapi.c index 99960b65..54883387 100644 --- a/src/playback/playback_wasapi/playback_wasapi.c +++ b/src/playback/playback_wasapi/playback_wasapi.c @@ -11,7 +11,6 @@ PB_WSP_SharedState PB_WSP_shared_state = ZI; void PB_Startup(void) { - __prof; PB_WSP_SharedState *g = &PB_WSP_shared_state; PB_WSP_InitializeWasapi(); /* Start playback job */ @@ -22,7 +21,6 @@ void PB_Startup(void) ExitFuncDef(PB_WSP_Shutdown) { - __prof; PB_WSP_SharedState *g = &PB_WSP_shared_state; Atomic32Set(&g->shutdown, 1); YieldOnFence(&g->shutdown_jobs_fence, g->shutdown_jobs_count); @@ -126,7 +124,6 @@ void PB_WSP_InitializeWasapi(void) PB_WSP_Buff PB_WSP_BeginUpdate(void) { - __prof; PB_WSP_SharedState *g = &PB_WSP_shared_state; PB_WSP_Buff wspbuf = ZI; @@ -147,7 +144,6 @@ PB_WSP_Buff PB_WSP_BeginUpdate(void) void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src) { - __prof; PB_WSP_SharedState *g = &PB_WSP_shared_state; u32 frames_in_source = src.count / 2; u32 frames_in_output = wspbuf->frames_count; @@ -176,7 +172,6 @@ void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src) /* Submit output buffer to WASAPI */ IAudioRenderClient_ReleaseBuffer(g->playback, frames_in_source, flags); - __profframe("Audio"); } //////////////////////////////////////////////////////////// @@ -184,7 +179,6 @@ void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src) JobImpl(PB_WSP_Playback, sig, id) { - __prof; PB_WSP_SharedState *g = &PB_WSP_shared_state; /* FIXME: If playback fails at any point and mixer stops advancing, we @@ -194,11 +188,9 @@ JobImpl(PB_WSP_Playback, sig, id) { TempArena scratch = BeginScratchNoConflict(); { - __profn("Wasapi wait"); WaitForSingleObject(g->event, INFINITE); } { - __profn("Fill sample buffer"); PB_WSP_Buff wspbuf = PB_WSP_BeginUpdate(); MIX_PcmF32 pcm = MIX_MixAllTracks(scratch.arena, wspbuf.frames_count); PB_WSP_EndUpdate(&wspbuf, pcm); diff --git a/src/pp/pp_vis/pp_vis_widgets.c b/src/pp/pp_vis/pp_vis_widgets.c index 6c6bf04d..98e9e311 100644 --- a/src/pp/pp_vis/pp_vis_widgets.c +++ b/src/pp/pp_vis/pp_vis_widgets.c @@ -281,7 +281,6 @@ void V_EndCommandsWidget(V_CommandsWidget *widget) UI_Key V_BuildConsoleWidget(b32 minimized) { /* TODO: Remove this whole thing */ - __prof; TempArena scratch = BeginScratchNoConflict(); // i32 console_level = minimized ? LogLevel_Success : LogLevel_Debug; diff --git a/src/prof/prof_inc.h b/src/prof/prof_inc.h deleted file mode 100644 index 5d9e5381..00000000 --- a/src/prof/prof_inc.h +++ /dev/null @@ -1 +0,0 @@ -#include "prof_tracy.h" diff --git a/src/prof/prof_tracy.cpp b/src/prof/prof_tracy.cpp deleted file mode 100644 index 7a3b35ab..00000000 --- a/src/prof/prof_tracy.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#if defined(IsProfilingEnabled) && IsProfilingEnabled == 1 - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Weverything" -#define TRACY_FIBERS -# include TracyClientSrcPath -#pragma clang diagnostic pop - -#endif diff --git a/src/prof/prof_tracy.h b/src/prof/prof_tracy.h deleted file mode 100644 index 2ddc5481..00000000 --- a/src/prof/prof_tracy.h +++ /dev/null @@ -1,158 +0,0 @@ -#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 diff --git a/src/settings/settings.c b/src/settings/settings.c index c1994a01..6dd1332e 100644 --- a/src/settings/settings.c +++ b/src/settings/settings.c @@ -3,8 +3,6 @@ String SETTINGS_StringFromWindowSettings(Arena *arena, const P_WindowSettings *settings) { - __prof; - String minimized = settings->flags & P_WindowSettingsFlag_Minimized ? Lit("true") : Lit("false"); String maximized = settings->flags & P_WindowSettingsFlag_Maximized ? Lit("true") : Lit("false"); String fullscreen = settings->flags & P_WindowSettingsFlag_Fullscreen ? Lit("true") : Lit("false"); @@ -45,7 +43,6 @@ String SETTINGS_StringFromWindowSettings(Arena *arena, const P_WindowSettings *s P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, String *error_out) { - __prof; TempArena scratch = BeginScratch(arena); String error = ZI; diff --git a/src/sound/sound.c b/src/sound/sound.c index dd11a0a6..8787cb43 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -3,7 +3,6 @@ JobImpl(SND_Load, sig, id) { - __prof; TempArena scratch = BeginScratchNoConflict(); ResourceKey resource = sig->resource; String name = NameFromResource(resource); @@ -82,7 +81,6 @@ JobImpl(SND_Load, sig, id) AC_Asset *SND_LoadAsset(ResourceKey resource, SND_SoundFlag flags, b32 wait) { - __prof; TempArena scratch = BeginScratchNoConflict(); /* Generate and append sound flags to name key */ @@ -119,7 +117,6 @@ AC_Asset *SND_LoadAsset(ResourceKey resource, SND_SoundFlag flags, b32 wait) SND_Sound *SND_LoadSoundAsync(ResourceKey resource, SND_SoundFlag flags) { - __prof; AC_Asset *asset = SND_LoadAsset(resource, flags, 0); SND_Sound *sound = (SND_Sound *)AC_DataFromStore(asset); return sound; @@ -127,7 +124,6 @@ SND_Sound *SND_LoadSoundAsync(ResourceKey resource, SND_SoundFlag flags) SND_Sound *SND_LoadSoundWait(ResourceKey resource, SND_SoundFlag flags) { - __prof; AC_Asset *asset = SND_LoadAsset(resource, flags, 1); AC_YieldOnAssetReady(asset); SND_Sound *sound = (SND_Sound *)AC_DataFromStore(asset); diff --git a/src/tar/tar.c b/src/tar/tar.c index 41ea3832..eb6ffb2f 100644 --- a/src/tar/tar.c +++ b/src/tar/tar.c @@ -18,8 +18,6 @@ u64 TAR_U64FromOctString(String str) */ TAR_Archive TAR_ArchiveFromString(Arena *arena, String data, String prefix) { - __prof; - TAR_Archive archive = ZI; BB_Buff bb = BitbuffFromString(data); BB_Reader br = BB_ReaderFromBuffNoDebug(&bb); diff --git a/src/ttf/ttf_dwrite/ttf_dwrite.c b/src/ttf/ttf_dwrite/ttf_dwrite.c index 72d22358..a8e3af1d 100644 --- a/src/ttf/ttf_dwrite/ttf_dwrite.c +++ b/src/ttf/ttf_dwrite/ttf_dwrite.c @@ -9,7 +9,6 @@ TTF_DW_SharedState TTF_DW_shared_state = ZI; /* Call this during font system startup */ void TTF_Startup(void) { - __prof; TTF_DW_SharedState *g = &TTF_DW_shared_state; Assert(!g->factory); /* FIXME: I think IDWriteFactory5 only exists on later updates of windows @@ -40,7 +39,6 @@ void TTF_Startup(void) TTF_Decoded TTF_Decode(Arena *arena, String encoded, f32 em_size, u32 *cache_codes, u32 cache_codes_count) { - __prof; TTF_DW_SharedState *g = &TTF_DW_shared_state; COLORREF bg_color = 0xFF000000; COLORREF fg_color = 0xFFFFFFFF; @@ -143,7 +141,6 @@ TTF_Decoded TTF_Decode(Arena *arena, String encoded, f32 em_size, u32 *cache_cod u32 out_offset_y = 0; u32 row_height = 0; { - __profn("Build atlas"); for (u16 i = 0; i < glyph_count; ++i) { //- Render glyph to render target diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index bbb34ff4..afc78f27 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -1245,7 +1245,6 @@ i64 UI_EndFrame(UI_Frame frame) } if (!g->eframe.draw_target) { - __profn("Acquire ui render target"); GPU_ResourceDesc desc = ZI; desc.kind = GPU_ResourceKind_Texture2D; desc.flags = GPU_ResourceFlag_Renderable | GPU_ResourceFlag_Writable; @@ -1429,8 +1428,6 @@ i64 UI_EndFrame(UI_Frame frame) { //- Prep rect pass { - __profn("Clear target"); - GPU_ProfN(cl, Lit("Clear target")); GPU_TransitionToRenderable(cl, g->eframe.draw_target, 0); GPU_ClearRenderable(cl, g->eframe.draw_target); } @@ -1438,9 +1435,6 @@ i64 UI_EndFrame(UI_Frame frame) //- Rect pass if (draw_rects_count > 0) { - __profn("UI rect pass"); - GPU_ProfN(cl, Lit("UI rect pass")); - GPU_Viewport viewport = GPU_ViewportFromRect(draw_viewport); GPU_Scissor scissor = GPU_ScissorFromRect(draw_viewport); diff --git a/src/window/window_win32/window_win32.c b/src/window/window_win32/window_win32.c index c5961c09..1c5211e2 100644 --- a/src/window/window_win32/window_win32.c +++ b/src/window/window_win32/window_win32.c @@ -154,7 +154,6 @@ JobImpl(WND_W32_ProcessMessagesForever, sig, id) MSG msg = ZI; GetMessageW(&msg, 0, 0, 0); { - __profn("Process window message"); TranslateMessage(&msg); DispatchMessageW(&msg); }