//////////////////////////////////////////////////////////// //~ Binds //- Bind kinds Enum(PP_BindKind) { PP_BindKind_None, PP_BindKind_MoveUp, PP_BindKind_MoveDown, PP_BindKind_MoveLeft, PP_BindKind_MoveRight, PP_BindKind_Walk, PP_BindKind_Fire, PP_BindKind_AltFire, PP_BindKind_TestTile, PP_BindKind_DebugClear, PP_BindKind_DebugSpawn1, PP_BindKind_DebugSpawn2, PP_BindKind_DebugSpawn3, PP_BindKind_DebugSpawn4, PP_BindKind_DebugWalls, PP_BindKind_DebugFollow, PP_BindKind_DebugDraw, PP_BindKind_DebugConsole, PP_BindKind_DebugCamera, PP_BindKind_DebugLister, PP_BindKind_DebugPause, PP_BindKind_DebugStep, PP_BindKind_DebugDrag, PP_BindKind_DebugDelete, PP_BindKind_DebugTeleport, PP_BindKind_DebugExplode, PP_BindKind_DebugToggleTopmost, PP_BindKind_DebugUi, PP_BindKind_FullscreenMod, PP_BindKind_Fullscreen, PP_BindKind_ZoomIn, PP_BindKind_ZoomOut, PP_BindKind_Pan, #if IsRtcEnabled /* Debug */ PP_BindKind_ResetDebugSteps, PP_BindKind_IncrementDebugSteps, PP_BindKind_DecrementDebugSteps, #endif PP_BindKind_COUNT }; //- Test bindings /* TODO: Remove this */ Global Readonly PP_BindKind g_binds[Btn_COUNT] = { [Btn_W] = PP_BindKind_MoveUp, [Btn_S] = PP_BindKind_MoveDown, [Btn_A] = PP_BindKind_MoveLeft, [Btn_D] = PP_BindKind_MoveRight, [Btn_M1] = PP_BindKind_Fire, [Btn_M2] = PP_BindKind_AltFire, #if 0 [Btn_Alt] = PP_BindKind_Walk, #endif /* Testing */ [Btn_Z] = PP_BindKind_TestTile, [Btn_M5] = PP_BindKind_DebugDrag, [Btn_M4] = PP_BindKind_DebugDelete, [Btn_F] = PP_BindKind_DebugExplode, [Btn_T] = PP_BindKind_DebugTeleport, [Btn_C] = PP_BindKind_DebugClear, [Btn_1] = PP_BindKind_DebugSpawn1, [Btn_2] = PP_BindKind_DebugSpawn2, [Btn_3] = PP_BindKind_DebugSpawn3, [Btn_4] = PP_BindKind_DebugSpawn4, [Btn_G] = PP_BindKind_DebugWalls, [Btn_N] = PP_BindKind_DebugStep, [Btn_Q] = PP_BindKind_DebugFollow, [Btn_F1] = PP_BindKind_DebugPause, [Btn_F2] = PP_BindKind_DebugCamera, [Btn_F3] = PP_BindKind_DebugDraw, [Btn_Tab] = PP_BindKind_DebugLister, [Btn_F4] = PP_BindKind_DebugToggleTopmost, [Btn_F5] = PP_BindKind_DebugUi, [Btn_GraveAccent] = PP_BindKind_DebugConsole, [Btn_Alt] = PP_BindKind_FullscreenMod, [Btn_Enter] = PP_BindKind_Fullscreen, [Btn_MWheelUp] = PP_BindKind_ZoomIn, [Btn_MWheelDown] = PP_BindKind_ZoomOut, [Btn_M3] = PP_BindKind_Pan, #if IsRtcEnabled [Btn_ForwardSlash] = PP_BindKind_ResetDebugSteps, [Btn_Comma] = PP_BindKind_DecrementDebugSteps, [Btn_Period] = PP_BindKind_IncrementDebugSteps #endif }; //////////////////////////////////////////////////////////// //~ Stats Struct(PP_SecondsStat) { u64 last_second_start; u64 last_second_end; u64 last_second; }; //////////////////////////////////////////////////////////// //~ Console log Struct(PP_ConsoleLog) { String msg; i32 level; i32 color_index; DateTime datetime; PP_ConsoleLog *prev; PP_ConsoleLog *next; }; //////////////////////////////////////////////////////////// //~ Sim decode queue Struct(PP_DecodeQueueNode) { PP_Client *client; u64 tick; u64 base_tick; String tmp_encoded; PP_DecodeQueueNode *next; }; Struct(PP_DecodeQueue) { PP_DecodeQueueNode *first; PP_DecodeQueueNode *last; }; //////////////////////////////////////////////////////////// //~ State types Struct(PP_BindState) { b32 is_held; /* Is this bind held down this frame */ u32 num_presses; /* How many times was this bind's pressed since last frame */ u32 num_repeats; /* How many times was this bind's key repeated since last frame */ u32 num_presses_and_repeats; /* Same as `num_presses` but includes key repeats as well */ u32 num_releases; /* How many times was this bind released since last frame */ }; Struct(PP_SharedUserState) { Atomic32 shutdown; Fence shutdown_jobs_fence; u64 shutdown_jobs_count; Arena *arena; String connect_address_str; PP_ClientStore *user_client_store; PP_Client *user_unblended_client; /* Contains snapshots received from local sim */ PP_Client *user_blended_client; /* Contains single snapshot from result of blending local sim snapshots */ PP_Snapshot *ss_blended; /* Points to blended snapshot contained in blended client */ u64 user_tick; u64 window_os_gen; //- Usage stats i64 last_second_reset_ns; PP_SecondsStat net_bytes_read; PP_SecondsStat net_bytes_sent; //- Renderer gbuffers GPU_Resource *albedo; GPU_Resource *emittance; GPU_Resource *emittance_flood_read; GPU_Resource *emittance_flood_target; GPU_Resource *shade_read; GPU_Resource *shade_target; //- Renderer transient buffers GPU_TransientBuffer material_instances_tbuff; GPU_TransientBuffer grids_tbuff; Arena *material_instances_arena; Arena *grids_arena; //- Renderer state RandState frame_rand; u64 frame_index; i64 gpu_submit_fence_target; //- Bind state PP_BindState bind_states[PP_BindKind_COUNT]; //- Window -> user Mutex sys_window_events_mutex; Arena *sys_window_events_arena; //- User -> sim Mutex user_sim_cmd_mutex; PP_ControlData user_sim_cmd_control; PP_EntKey user_hovered_ent; u64 last_user_sim_cmd_gen; u64 user_sim_cmd_gen; Atomic32 user_paused; Atomic32 user_paused_steps; //- Sim -> user Mutex local_to_user_client_mutex; PP_ClientStore *local_to_user_client_store; PP_Client *local_to_user_client; i64 local_to_user_client_publish_dt_ns; i64 local_to_user_client_publish_time_ns; //- Local sim -> user rolling window of publish time deltas i64 last_local_to_user_snapshot_published_at_ns; i64 average_local_to_user_snapshot_publish_dt_ns; i64 local_sim_predicted_time_ns; /* Calculated from +