From bf3e71c859f7e02b1535a0e26826f44bcee3c1b8 Mon Sep 17 00:00:00 2001 From: jacob Date: Sat, 12 Jul 2025 00:02:07 -0500 Subject: [PATCH] enable average sim dt calculation --- src/gp_dx12.c | 1 - src/prof_tracy.h | 2 +- src/sys_win32.c | 10 ++++++++-- src/user.c | 10 +++------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gp_dx12.c b/src/gp_dx12.c index 83c9b3da..a96cac55 100644 --- a/src/gp_dx12.c +++ b/src/gp_dx12.c @@ -2913,7 +2913,6 @@ void gp_present(struct gp_swapchain *gp_swapchain, struct v2i32 backbuffer_resol INTERNAL SYS_JOB_DEF(dx12_evictor_job, _) { - __prof; (UNUSED)_; u64 completed_targets[DX12_NUM_QUEUES] = ZI; diff --git a/src/prof_tracy.h b/src/prof_tracy.h index 3828abea..5320e40b 100644 --- a/src/prof_tracy.h +++ b/src/prof_tracy.h @@ -7,7 +7,7 @@ #if PROFILING -#define PROFILING_SYSTEM_TRACE 0 +#define PROFILING_SYSTEM_TRACE 1 #define PROFILING_CAPTURE_FRAME_IMAGE 0 #define PROFILING_LOCKS 0 #define PROFILING_D3D 1 diff --git a/src/sys_win32.c b/src/sys_win32.c index 2c1fd7e1..57a380d1 100644 --- a/src/sys_win32.c +++ b/src/sys_win32.c @@ -45,7 +45,7 @@ #define FIBER_NAME_SUFFIX_CSTR "]" #define FIBER_NAME_MAX_SIZE 64 -#define NUM_WAIT_ADDR_BINS 65536 +#define NUM_WAIT_ADDR_BINS 16384 #define NUM_WAIT_TIME_BINS 1024 #define MAX_EXIT_FUNCS 1024 @@ -471,7 +471,6 @@ void sys_wait(void *addr, void *cmp, u32 size, i64 timeout_ns) /* REQUIRED: Caller must have acquired `wake_lock` for each fiber in array */ INTERNAL void wake_fibers_locked(i32 num_fibers, struct fiber **fibers) { - __prof; /* Update wait lists */ for (i32 i = 0; i < num_fibers; ++i) { struct fiber *fiber = fibers[i]; @@ -992,11 +991,13 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) (UNUSED)success; } +#if 0 if (pool->thread_affinity_mask) { b32 success = SetThreadAffinityMask(thread_handle, pool->thread_affinity_mask) != 0; ASSERT(success); (UNUSED)success; } +#endif if (pool->thread_mm_characteristics) { /* https://learn.microsoft.com/en-us/windows/win32/procthread/multimedia-class-scheduler-service#registry-settings */ @@ -1264,6 +1265,11 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) } snc_unlock(&wake_lock); } + + /* Worker shutdown */ + if (job_fiber) { + fiber_release(pool, job_fiber); + } } /* ========================== * diff --git a/src/user.c b/src/user.c index ffe8d322..383e6676 100644 --- a/src/user.c +++ b/src/user.c @@ -594,15 +594,8 @@ INTERNAL void user_update(struct sys_window *window) struct sim_snapshot *src = sim_snapshot_from_tick(G.local_to_user_client, last_tick); sim_snapshot_alloc(G.user_unblended_client, src, src->tick); G.last_local_to_user_snapshot_published_at_ns = G.local_to_user_client_publish_time_ns; - - /* FIXME: Enable this */ -#if 0 G.average_local_to_user_snapshot_publish_dt_ns -= G.average_local_to_user_snapshot_publish_dt_ns / 50; G.average_local_to_user_snapshot_publish_dt_ns += G.local_to_user_client_publish_dt_ns / 50; -#else - G.average_local_to_user_snapshot_publish_dt_ns -= G.average_local_to_user_snapshot_publish_dt_ns / 1; - G.average_local_to_user_snapshot_publish_dt_ns += G.local_to_user_client_publish_dt_ns / 1; -#endif } snc_unlock(&lock); } @@ -2731,6 +2724,9 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) struct snc_lock lock = snc_lock_e(&G.local_to_user_client_mutex); sim_snapshot_alloc(G.local_to_user_client, local_ss, local_ss->tick); i64 publish_ns = sys_time_ns(); + if (last_publish_to_user_ns == 0) { + last_publish_to_user_ns = publish_ns - G.average_local_to_user_snapshot_publish_dt_ns; + } G.local_to_user_client_publish_dt_ns = publish_ns - last_publish_to_user_ns; G.local_to_user_client_publish_time_ns = publish_ns; last_publish_to_user_ns = publish_ns;