enable average sim dt calculation

This commit is contained in:
jacob 2025-07-12 00:02:07 -05:00
parent 2f3c47697b
commit bf3e71c859
4 changed files with 12 additions and 11 deletions

View File

@ -2913,7 +2913,6 @@ void gp_present(struct gp_swapchain *gp_swapchain, struct v2i32 backbuffer_resol
INTERNAL SYS_JOB_DEF(dx12_evictor_job, _) INTERNAL SYS_JOB_DEF(dx12_evictor_job, _)
{ {
__prof;
(UNUSED)_; (UNUSED)_;
u64 completed_targets[DX12_NUM_QUEUES] = ZI; u64 completed_targets[DX12_NUM_QUEUES] = ZI;

View File

@ -7,7 +7,7 @@
#if PROFILING #if PROFILING
#define PROFILING_SYSTEM_TRACE 0 #define PROFILING_SYSTEM_TRACE 1
#define PROFILING_CAPTURE_FRAME_IMAGE 0 #define PROFILING_CAPTURE_FRAME_IMAGE 0
#define PROFILING_LOCKS 0 #define PROFILING_LOCKS 0
#define PROFILING_D3D 1 #define PROFILING_D3D 1

View File

@ -45,7 +45,7 @@
#define FIBER_NAME_SUFFIX_CSTR "]" #define FIBER_NAME_SUFFIX_CSTR "]"
#define FIBER_NAME_MAX_SIZE 64 #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 NUM_WAIT_TIME_BINS 1024
#define MAX_EXIT_FUNCS 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 */ /* REQUIRED: Caller must have acquired `wake_lock` for each fiber in array */
INTERNAL void wake_fibers_locked(i32 num_fibers, struct fiber **fibers) INTERNAL void wake_fibers_locked(i32 num_fibers, struct fiber **fibers)
{ {
__prof;
/* Update wait lists */ /* Update wait lists */
for (i32 i = 0; i < num_fibers; ++i) { for (i32 i = 0; i < num_fibers; ++i) {
struct fiber *fiber = fibers[i]; struct fiber *fiber = fibers[i];
@ -992,11 +991,13 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg)
(UNUSED)success; (UNUSED)success;
} }
#if 0
if (pool->thread_affinity_mask) { if (pool->thread_affinity_mask) {
b32 success = SetThreadAffinityMask(thread_handle, pool->thread_affinity_mask) != 0; b32 success = SetThreadAffinityMask(thread_handle, pool->thread_affinity_mask) != 0;
ASSERT(success); ASSERT(success);
(UNUSED)success; (UNUSED)success;
} }
#endif
if (pool->thread_mm_characteristics) { if (pool->thread_mm_characteristics) {
/* https://learn.microsoft.com/en-us/windows/win32/procthread/multimedia-class-scheduler-service#registry-settings */ /* 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); snc_unlock(&wake_lock);
} }
/* Worker shutdown */
if (job_fiber) {
fiber_release(pool, job_fiber);
}
} }
/* ========================== * /* ========================== *

View File

@ -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); 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); 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; 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.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; 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); 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); 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); sim_snapshot_alloc(G.local_to_user_client, local_ss, local_ss->tick);
i64 publish_ns = sys_time_ns(); 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_dt_ns = publish_ns - last_publish_to_user_ns;
G.local_to_user_client_publish_time_ns = publish_ns; G.local_to_user_client_publish_time_ns = publish_ns;
last_publish_to_user_ns = publish_ns; last_publish_to_user_ns = publish_ns;