diff --git a/log.txt b/log.txt new file mode 100644 index 00000000..89a4e0af --- /dev/null +++ b/log.txt @@ -0,0 +1,145 @@ +[11:51:18.682] |16888| [INFO] Loading pipeline "kernel_material" +[11:51:18.683] |05964| [INFO] Loading pipeline "kernel_shape" +[11:51:18.683] |29584| [INFO] Loading pipeline "kernel_shade" +[11:51:18.684] |25484| [INFO] Loading pipeline "kernel_ui" +[11:51:18.685] |23760| [INFO] Loading pipeline "kernel_flood" +[11:51:18.685] |26808| [INFO] Loading pipeline "kernel_blit" +[11:51:18.687] |29620| [SUCCESS] Successfully compiled pipeline "kernel_material" in 0.002 seconds +[11:51:18.687] |29620| [SUCCESS] Successfully compiled pipeline "kernel_flood" in 0.001 seconds +[11:51:18.687] |29620| [SUCCESS] Successfully compiled pipeline "kernel_shade" in 0.003 seconds +[11:51:18.687] |29620| [SUCCESS] Successfully compiled pipeline "kernel_shape" in 0.001 seconds +[11:51:18.687] |29620| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.001 seconds +[11:51:18.687] |29620| [SUCCESS] Successfully compiled pipeline "kernel_blit" in 0.001 seconds +[11:51:18.723] |29584| [INFO] Inserting asset cache entry for "font/fixedsys.ttf12.0_font" +[11:51:18.725] |26348| [INFO] Loading sprite texture [f6ddd0f8a4758bce] "sprite/crosshair.ase" +[11:51:18.727] |28868| [INFO] Loading font "font/fixedsys.ttf" (point size 12.000) +[11:51:18.730] |25484| [INFO] Created player with id 54446c99 for sim client h0x1. is_master: 1 +[11:51:18.733] |26348| [SUCCESS] Loaded sprite texture [f6ddd0f8a4758bce] "sprite/crosshair.ase" in 0.008 seconds (cache size: 20416 bytes). +[11:51:18.750] |25484| [INFO] Loading sprite sheet [d2db500e4a9e79a6] "sprite/tim.ase" +[11:51:18.751] |25484| [SUCCESS] Loaded sprite sheet [d2db500e4a9e79a6] "sprite/tim.ase" in 0.001 seconds (cache size: 16320 bytes). +[11:51:18.751] |25484| [INFO] Loading sprite sheet [b977d286fa3eb7c7] "sprite/gun.ase" +[11:51:18.751] |25484| [SUCCESS] Loaded sprite sheet [b977d286fa3eb7c7] "sprite/gun.ase" in 0.000 seconds (cache size: 16320 bytes). +[11:51:18.782] |26348| [INFO] Loading sprite texture [69e272c667301980] "sprite/tim.ase" +[11:51:18.783] |26348| [INFO] Loading sprite texture [acf325b34223e086] "sprite/gun.ase" +[11:51:18.787] |26348| [SUCCESS] Loaded sprite texture [69e272c667301980] "sprite/tim.ase" in 0.005 seconds (cache size: 32704 bytes). +[11:51:18.787] |26348| [SUCCESS] Loaded sprite texture [acf325b34223e086] "sprite/gun.ase" in 0.004 seconds (cache size: 35520 bytes). +[11:51:18.808] |28868| [SUCCESS] Loaded font "font/fixedsys.ttf" (point size 12.000) in 0.080 seconds +[11:51:19.391] |26808| [DEBUG] Spawn test 2 +[11:51:19.412] |26808| [INFO] Loading sprite sheet [c7595d812ab95147] "sprite/tile.ase" +[11:51:19.412] |26808| [SUCCESS] Loaded sprite sheet [c7595d812ab95147] "sprite/tile.ase" in 0.000 seconds (cache size: 16320 bytes). +[11:51:19.435] |26348| [INFO] Loading sprite texture [f85f052a30eff918] "sprite/tile.ase" +[11:51:19.436] |28868| [SUCCESS] Loaded sprite texture [f85f052a30eff918] "sprite/tile.ase" in 0.002 seconds (cache size: 20416 bytes). +[11:51:19.850] |25484| [DEBUG] Spawn test 2 +[11:51:20.109] |05964| [DEBUG] Spawn test 2 +[11:51:20.150] |16888| [DEBUG] Spawn test 2 +[11:51:20.170] |25484| [DEBUG] Spawn test 2 +[11:51:20.210] |23760| [DEBUG] Spawn test 2 +[11:51:20.249] |29620| [DEBUG] Spawn test 2 +[11:51:20.270] |29584| [DEBUG] Spawn test 2 +[11:51:20.310] |29584| [DEBUG] Spawn test 2 +[11:51:20.329] |05964| [DEBUG] Spawn test 2 +[11:51:20.370] |05964| [DEBUG] Spawn test 2 +[11:51:20.410] |29620| [DEBUG] Spawn test 2 +[11:51:20.450] |25484| [DEBUG] Spawn test 2 +[11:51:20.470] |26808| [DEBUG] Spawn test 2 +[11:51:20.509] |29584| [DEBUG] Spawn test 2 +[11:51:20.530] |29620| [DEBUG] Spawn test 2 +[11:51:20.570] |26808| [DEBUG] Spawn test 2 +[11:51:20.610] |26808| [DEBUG] Spawn test 2 +[11:51:20.649] |25484| [DEBUG] Spawn test 2 +[11:51:20.670] |05964| [DEBUG] Spawn test 2 +[11:51:20.710] |29620| [DEBUG] Spawn test 2 +[11:51:20.729] |29584| [DEBUG] Spawn test 2 +[11:51:20.769] |25484| [DEBUG] Spawn test 2 +[11:51:20.790] |29620| [DEBUG] Spawn test 2 +[11:51:20.850] |23760| [DEBUG] Spawn test 2 +[11:51:20.869] |29620| [DEBUG] Spawn test 2 +[11:51:20.910] |05964| [DEBUG] Spawn test 2 +[11:51:20.930] |26808| [DEBUG] Spawn test 2 +[11:51:20.970] |05964| [DEBUG] Spawn test 2 +[11:51:20.990] |23760| [DEBUG] Spawn test 2 +[11:51:21.030] |25484| [DEBUG] Spawn test 2 +[11:51:30.609] |26348| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:30.609] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:30.611] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:30.623] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.012 seconds +[11:51:30.623] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.012 seconds +[11:51:30.623] |28868| [INFO] Loading pipeline "kernel_ui" +[11:51:30.796] |26348| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.172 seconds +[11:51:31.010] |28868| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:31.010] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:31.010] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:31.016] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.007 seconds +[11:51:31.016] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.005 seconds +[11:51:31.016] |28868| [INFO] Loading pipeline "kernel_ui" +[11:51:31.016] |28868| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:31.226] |26348| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:31.226] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:31.227] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:31.234] |26348| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.008 seconds +[11:51:31.234] |26348| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.005 seconds +[11:51:31.234] |26348| [INFO] Loading pipeline "kernel_ui" +[11:51:31.234] |26348| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:31.395] |26348| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:31.395] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:31.395] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:31.402] |26348| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.007 seconds +[11:51:31.402] |26348| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.007 seconds +[11:51:31.402] |26348| [INFO] Loading pipeline "kernel_ui" +[11:51:31.402] |26348| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:31.589] |28868| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:31.589] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:31.589] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:31.596] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.007 seconds +[11:51:31.596] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.006 seconds +[11:51:31.596] |28868| [INFO] Loading pipeline "kernel_ui" +[11:51:31.596] |28868| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:31.781] |28868| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:31.781] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:31.781] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:31.789] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.008 seconds +[11:51:31.789] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.007 seconds +[11:51:31.789] |28868| [INFO] Loading pipeline "kernel_ui" +[11:51:31.789] |28868| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:31.952] |26348| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:31.952] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:31.953] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:31.959] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.006 seconds +[11:51:31.959] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.006 seconds +[11:51:31.959] |28868| [INFO] Loading pipeline "kernel_ui" +[11:51:31.959] |28868| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:32.122] |28868| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:32.122] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:32.122] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:32.130] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.008 seconds +[11:51:32.130] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.005 seconds +[11:51:32.130] |28868| [INFO] Loading pipeline "kernel_ui" +[11:51:32.130] |28868| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:32.328] |28868| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:32.328] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:32.328] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:32.335] |26348| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.007 seconds +[11:51:32.335] |26348| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.007 seconds +[11:51:32.335] |26348| [INFO] Loading pipeline "kernel_ui" +[11:51:32.335] |26348| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:32.486] |28868| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:32.486] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:32.486] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:32.492] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.006 seconds +[11:51:32.492] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.005 seconds +[11:51:32.492] |28868| [INFO] Loading pipeline "kernel_ui" +[11:51:32.492] |28868| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:32.688] |26348| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:32.688] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:32.690] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:32.701] |26348| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.013 seconds +[11:51:32.701] |26348| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.008 seconds +[11:51:32.701] |26348| [INFO] Loading pipeline "kernel_ui" +[11:51:32.701] |26348| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds +[11:51:32.871] |28868| [DEBUG] Change detected in shader source file "src/kernel/kernel_ui.rst", recompiling... +[11:51:32.871] |28868| [INFO] Compiling shader "src/kernel/kernel_ui.rst:vs" +[11:51:32.871] |26348| [INFO] Compiling shader "src/kernel/kernel_ui.rst:ps" +[11:51:32.878] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:vs" in 0.007 seconds +[11:51:32.878] |28868| [SUCCESS] Finished compiling shader "src/kernel/kernel_ui.rst:ps" in 0.006 seconds +[11:51:32.878] |28868| [INFO] Loading pipeline "kernel_ui" +[11:51:32.878] |28868| [SUCCESS] Successfully compiled pipeline "kernel_ui" in 0.000 seconds diff --git a/src/.vscode/settings.json b/src/.vscode/settings.json new file mode 100644 index 00000000..ddc6cda1 --- /dev/null +++ b/src/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "files.associations": { + "*.rst": "hlsl", + "*.knl": "hlsl", + "mp3.h": "c", + "resource.h": "c", + "watch.h": "c", + "base.h": "c", + "tar.h": "c" + } +} \ No newline at end of file diff --git a/src/app/app_core.c b/src/app/app_core.c index 90cd9d17..d8008633 100644 --- a/src/app/app_core.c +++ b/src/app/app_core.c @@ -171,6 +171,7 @@ void P_AppStartup(String args_str) g->write_path = InitializeAppWriteDirectory(g->arena, Lit(WRITE_DIR)); /* Startup logging */ +#if 0 { TempArena temp = BeginTempArena(scratch.arena); @@ -186,6 +187,7 @@ void P_AppStartup(String args_str) for (AppArg *arg = args.first; arg; arg = arg->next) { P_LogInfoF("Parsed arg: key = \"%F\", value = \"%F\"", FmtString(arg->key), FmtString(arg->value)); } +#endif #if 0 /* Read window settings from file */ @@ -230,6 +232,7 @@ void P_AppStartup(String args_str) } #endif +#if 0 /* Global systems */ RES_Startup(); W_Startup(); @@ -243,12 +246,11 @@ void P_AppStartup(String args_str) D_StartupReceipt draw_sr = D_Startup(); /* Interface systems */ - SimStartupReceipt sim_sr = SimStartup(); + SimStartupReceipt sim_sr = StartupSim(); PB_StartupReceipt playback_sr = PB_Startup(&mixer_sr); UserStartupReceipt user_sr = StartupUser(&sprite_sr, &draw_sr, &asset_cache_sr, &mixer_sr, &sim_sr, connect_address); - - LAX user_sr; - LAX playback_sr; +#endif + PpMain(); #if 0 /* Write window settings to file */ diff --git a/src/ase/ase.c b/src/ase/ase.c index 0cf764bc..f7efc70b 100644 --- a/src/ase/ase.c +++ b/src/ase/ase.c @@ -1,3 +1,8 @@ #include "ase.h" #include "ase_core.c" +void ASE_Main(void) +{ + RunOnce(); + ASE_StartupDeps(); +} diff --git a/src/ase/ase.h b/src/ase/ase.h index b72ed50c..39486065 100644 --- a/src/ase/ase.h +++ b/src/ase/ase.h @@ -3,7 +3,13 @@ #include "../base/base.h" #include "../bitbuff/bitbuff.h" +inline void ASE_StartupDeps(void) +{ + BaseMain(); + BB_Main(); +} #include "ase_core.h" +void ASE_Main(void); #endif diff --git a/src/asset_cache/asset_cache.c b/src/asset_cache/asset_cache.c index bbf567ec..b5fc6e65 100644 --- a/src/asset_cache/asset_cache.c +++ b/src/asset_cache/asset_cache.c @@ -1,3 +1,9 @@ #include "asset_cache.h" #include "asset_cache_core.c" +void AC_Main(void) +{ + RunOnce(); + AC_StartupDeps(); + AC_StartupCore(); +} diff --git a/src/asset_cache/asset_cache.h b/src/asset_cache/asset_cache.h index e56202bd..1e8a065d 100644 --- a/src/asset_cache/asset_cache.h +++ b/src/asset_cache/asset_cache.h @@ -3,6 +3,12 @@ #include "../base/base.h" #include "../platform/platform.h" +void AC_Main(void); +inline void AC_StartupDeps(void) +{ + BaseMain(); + P_Main(); +} #include "asset_cache_core.h" diff --git a/src/asset_cache/asset_cache_core.c b/src/asset_cache/asset_cache_core.c index 1243312e..7a0083e2 100644 --- a/src/asset_cache/asset_cache_core.c +++ b/src/asset_cache/asset_cache_core.c @@ -5,12 +5,11 @@ AC_SharedState AC_shared_state = ZI; //////////////////////////////// //~ Startup -AC_StartupReceipt AC_Startup(void) +void AC_StartupCore(void) { __prof; AC_SharedState *g = &AC_shared_state; g->store_arena = AllocArena(Gibi(64)); - return (AC_StartupReceipt) { 0 }; } //////////////////////////////// diff --git a/src/asset_cache/asset_cache_core.h b/src/asset_cache/asset_cache_core.h index f2c31109..0c040be7 100644 --- a/src/asset_cache/asset_cache_core.h +++ b/src/asset_cache/asset_cache_core.h @@ -65,8 +65,7 @@ extern AC_SharedState AC_shared_state; //////////////////////////////// //~ Startup -Struct(AC_StartupReceipt) { i32 _; }; -AC_StartupReceipt AC_Startup(void); +void AC_StartupCore(void); //////////////////////////////// //~ Hash diff --git a/src/base/base.c b/src/base/base.c index 93fe0db1..d61ea8b8 100644 --- a/src/base/base.c +++ b/src/base/base.c @@ -17,3 +17,10 @@ #else # error Base layer platform backend not implemented #endif + +void BaseMain(void) +{ + RunOnce(); + StartupBaseDeps(); + StartupBaseJobs(); +} diff --git a/src/base/base.h b/src/base/base.h index e88a6980..cbb2b1ed 100644 --- a/src/base/base.h +++ b/src/base/base.h @@ -1,6 +1,10 @@ #ifndef BASE_H #define BASE_H +inline void StartupBaseDeps(void) +{ +} + #include "base_core.h" #if LanguageIsC || LanguageIsCpp @@ -20,10 +24,10 @@ # include "base_rand.h" # include "base_util.h" # include "base_incbin.h" - #if PlatformIsWindows # include "win32/base_win32.h" #endif +void BaseMain(void); #elif LanguageIsGpu //- Base gpu includes diff --git a/src/base/base_core.h b/src/base/base_core.h index 71f77ab9..cc9e4465 100644 --- a/src/base/base_core.h +++ b/src/base/base_core.h @@ -554,16 +554,24 @@ ForceInline void UnlockTicketMutex(TicketMutex *tm) #define MaxFibers 4096 #if !LanguageIsGpu +# if PlatformIsWindows ForceInline i16 FiberId(void) { - /* FIXME */ - //return (i16)(i64)GetFiberData(); - Assert(0); - return 0; +#if LanguageIsCpp + i16 *v = reinterpret_cast((void *)__readgsqword(32)); +#else + i16 *v = (void *)__readgsqword(32); +#endif + return *v; } +# endif StaticAssert(MaxFibers < I16Max); /* Fiber id type should fit max fibers */ #endif +//////////////////////////////// +//~ Startup + +#define RunOnce() do { LocalPersist b32 r = 0; if (r) return; r = 1; } while (0) //////////////////////////////// //~ Config diff --git a/src/base/base_job.h b/src/base/base_job.h index fb1b1f83..7cea3d4d 100644 --- a/src/base/base_job.h +++ b/src/base/base_job.h @@ -32,6 +32,11 @@ typedef i32 PriorityKind; enum PriorityKind_Count }; +//////////////////////////////// +//~ @hookdecl Startup + +void StartupBaseJobs(void); + //////////////////////////////// //~ @hookdecl Futex @@ -67,17 +72,20 @@ Struct(JobDescParams) #define JobDecl(job, sigdef) \ typedef struct job##_Sig sigdef job##_Sig; \ - Struct(job##_Desc) { Arena *arena; job##_Sig *sig; GenericJobFunc *func; i32 count; PoolKind pool; PriorityKind priority; Counter *counter;}; \ - void job(job##_Sig *, i32) + Struct(job##_Desc) { Arena *arena; job##_Sig *sig; GenericJobFunc *func; i32 count; PoolKind pool; PriorityKind priority; Counter *counter; }; \ + void job(job##_Sig *, i32); \ + inline void job##_Generic(void *sig, i32 id) { job((job##_Sig *)sig, id); } \ + StaticAssert(1) -#define PushJobDesc(job, ...) (job##_Desc *)PushJobDesc_(sizeof(job##_Sig), alignof(job##_Sig), (GenericJobFunc *)(i64)job, (JobDescParams) { .count = 1, .pool = PoolKind_Inherit, .priority = PriorityKind_Inherit, .counter = 0, __VA_ARGS__ }) +#define PushJobDesc(job, ...) (job##_Desc *)PushJobDesc_(sizeof(job##_Sig), alignof(job##_Sig), job##_Generic, (JobDescParams) { .count = 1, .pool = PoolKind_Inherit, .priority = PriorityKind_Inherit, .counter = 0, __VA_ARGS__ }) GenericJobDesc *PushJobDesc_(u64 sig_size, u64 sig_align, GenericJobFunc *func, JobDescParams params); #define JobDef(job, sig_arg, id_arg) void job(job##_Sig *sig_arg, i32 id_arg) #define RunJob(_count, job, _pool, _priority, _counter, ...) do { \ - job##_Desc *__job_desc = (job##_Desc *)PushJobDesc_(sizeof(job##_Sig), alignof(job##_Sig), (GenericJobFunc *)(i64)job, (JobDescParams) { .count = _count, .pool = _pool, .priority = _priority, .counter = _counter,}); \ + job##_Desc *__job_desc = (job##_Desc *)PushJobDesc_(sizeof(job##_Sig), alignof(job##_Sig), job##_Generic, (JobDescParams) { .count = _count, .pool = _pool, .priority = _priority, .counter = _counter,}); \ *__job_desc->sig = (job##_Sig) { __VA_ARGS__ }; \ + RunJobEx((GenericJobDesc *)__job_desc); \ } while (0) void RunJobEx(GenericJobDesc *desc); diff --git a/src/base/win32/base_win32_job.c b/src/base/win32/base_win32_job.c index 43add503..5de59d42 100644 --- a/src/base/win32/base_win32_job.c +++ b/src/base/win32/base_win32_job.c @@ -17,9 +17,9 @@ W32_SharedCtx W32_shared_ctx = ZI; #pragma comment(lib, "ws2_32.lib") //////////////////////////////// -//~ Startup +//~ @hookdef Startup -void StartupJobs(void) +void StartupBaseJobs(void) { W32_SharedCtx *g = &W32_shared_ctx; @@ -40,6 +40,9 @@ void StartupJobs(void) g->num_fibers = 1; /* Fiber at index 0 always nil */ g->fiber_names_arena = AllocArena(Gibi(64)); + /* Convert main thread to fiber */ + W32_AllocFiber(0); + /* Init wait lists */ g->wait_lists_arena = AllocArena(Gibi(64)); diff --git a/src/bitbuff/bitbuff.c b/src/bitbuff/bitbuff.c index 4396f9db..b1a9256a 100644 --- a/src/bitbuff/bitbuff.c +++ b/src/bitbuff/bitbuff.c @@ -1,3 +1,8 @@ #include "bitbuff.h" #include "bitbuff_core.c" +void BB_Main(void) +{ + RunOnce(); + BB_StartupDeps(); +} diff --git a/src/bitbuff/bitbuff.h b/src/bitbuff/bitbuff.h index 525a1cad..3023897b 100644 --- a/src/bitbuff/bitbuff.h +++ b/src/bitbuff/bitbuff.h @@ -2,7 +2,12 @@ #define BITBUFF_H #include "../base/base.h" +inline void BB_StartupDeps(void) +{ + BaseMain(); +} #include "bitbuff_core.h" +void BB_Main(void); #endif diff --git a/src/collider/collider.c b/src/collider/collider.c index af2f721b..7479fdaf 100644 --- a/src/collider/collider.c +++ b/src/collider/collider.c @@ -1,3 +1,8 @@ #include "collider.h" #include "collider_core.c" +void CLD_Main(void) +{ + RunOnce(); + CLD_StartupDeps(); +} diff --git a/src/collider/collider.h b/src/collider/collider.h index 65fe51e5..aa3cb380 100644 --- a/src/collider/collider.h +++ b/src/collider/collider.h @@ -2,7 +2,12 @@ #define COLLIDER_H #include "../base/base.h" +inline void CLD_StartupDeps(void) +{ + BaseMain(); +} #include "collider_core.h" +void CLD_Main(void); #endif diff --git a/src/draw/draw.c b/src/draw/draw.c index 857dc99d..4c5ade94 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -1,3 +1,9 @@ #include "draw.h" #include "draw_core.c" +void D_Main(void) +{ + RunOnce(); + D_StartupDeps(); + D_StartupCore(); +} diff --git a/src/draw/draw.h b/src/draw/draw.h index 603bb412..1946f27d 100644 --- a/src/draw/draw.h +++ b/src/draw/draw.h @@ -6,7 +6,16 @@ #include "../sprite/sprite.h" #include "../font/font.h" #include "../collider/collider.h" +inline void D_StartupDeps(void) +{ + BaseMain(); + GPU_Main(); + S_Main(); + F_Main(); + CLD_Main(); +} #include "draw_core.h" +void D_Main(void); #endif diff --git a/src/draw/draw_core.c b/src/draw/draw_core.c index 33029789..43f72d4f 100644 --- a/src/draw/draw_core.c +++ b/src/draw/draw_core.c @@ -3,13 +3,12 @@ D_SharedState D_shared_state = ZI; //////////////////////////////// //~ Startup -D_StartupReceipt D_Startup(void) +void D_StartupCore(void) { __prof; D_SharedState *g = &D_shared_state; u32 pixel_white = 0xFFFFFFFF; g->solid_white_texture = GPU_AllocTexture(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, VEC2I32(1, 1), &pixel_white); - return (D_StartupReceipt) { 0 }; } //////////////////////////////// diff --git a/src/draw/draw_core.h b/src/draw/draw_core.h index cd09f8cb..804b338d 100644 --- a/src/draw/draw_core.h +++ b/src/draw/draw_core.h @@ -111,8 +111,7 @@ extern D_SharedState D_shared_state; //////////////////////////////// //~ Startup -Struct(D_StartupReceipt) { i32 _; }; -D_StartupReceipt D_Startup(void); +void D_StartupCore(void); //////////////////////////////// //~ Material operations diff --git a/src/dxc/dxc.cpp b/src/dxc/dxc.cpp index 0124a28a..31c48348 100644 --- a/src/dxc/dxc.cpp +++ b/src/dxc/dxc.cpp @@ -8,3 +8,8 @@ extern "C" #else # error Dxc core not implemented for this platform #endif +void DXC_Main(void) +{ + RunOnce(); + DXC_StartupDeps(); +} diff --git a/src/dxc/dxc.h b/src/dxc/dxc.h index 11eca208..bf9fc8c8 100644 --- a/src/dxc/dxc.h +++ b/src/dxc/dxc.h @@ -2,7 +2,12 @@ #define DXC_H #include "../base/base.h" +inline void DXC_StartupDeps(void) +{ + BaseMain(); +} #include "dxc_core.h" +void DXC_Main(void); #endif diff --git a/src/font/font.c b/src/font/font.c index 90ae31f5..d0ac6048 100644 --- a/src/font/font.c +++ b/src/font/font.c @@ -1,3 +1,8 @@ #include "font.h" #include "font_core.c" +void F_Main(void) +{ + RunOnce(); + F_StartupDeps(); +} diff --git a/src/font/font.h b/src/font/font.h index b5532931..7036c1f4 100644 --- a/src/font/font.h +++ b/src/font/font.h @@ -6,7 +6,16 @@ #include "../gpu/gpu.h" #include "../resource/resource.h" #include "../asset_cache/asset_cache.h" +inline void F_StartupDeps(void) +{ + BaseMain(); + TTF_Main(); + GPU_Main(); + RES_Main(); + AC_Main(); +} #include "font_core.h" +void F_Main(void); #endif diff --git a/src/gpu/gpu.c b/src/gpu/gpu.c index 271b0e7a..f5a905c0 100644 --- a/src/gpu/gpu.c +++ b/src/gpu/gpu.c @@ -7,3 +7,9 @@ #else # error Gpu layer not implemented for this platform #endif +void GPU_Main(void) +{ + RunOnce(); + GPU_StartupDeps(); + GPU_StartupCore(); +} diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h index 8d248362..9a21efa6 100644 --- a/src/gpu/gpu.h +++ b/src/gpu/gpu.h @@ -9,11 +9,22 @@ #include "../inc/inc.h" #include "../resource/resource.h" #include "../watch/watch.h" +inline void GPU_StartupDeps(void) +{ + BaseMain(); + P_Main(); + TAR_Main(); + ASE_Main(); + DXC_Main(); + INC_Main(); + RES_Main(); + W_Main(); +} #include "gpu_core.h" - #if PlatformIsWindows # include "gpu_dx12.h" #endif +void GPU_Main(void); #endif diff --git a/src/gpu/gpu_core.h b/src/gpu/gpu_core.h index b42bef61..6b84d75b 100644 --- a/src/gpu/gpu_core.h +++ b/src/gpu/gpu_core.h @@ -110,7 +110,7 @@ Struct(GPU_MemoryInfo) //////////////////////////////// //~ Startup -void GPU_Startup(void); +void GPU_StartupCore(void); //////////////////////////////// //~ Resource operations diff --git a/src/gpu/gpu_dx12.c b/src/gpu/gpu_dx12.c index fd0c2fb0..aea9cded 100644 --- a/src/gpu/gpu_dx12.c +++ b/src/gpu/gpu_dx12.c @@ -18,7 +18,7 @@ GPU_D12_SharedState GPU_D12_shared_state = ZI; * Startup * ========================== */ -void GPU_Startup(void) +void GPU_StartupCore(void) { __prof; GPU_D12_SharedState *g = &GPU_D12_shared_state; diff --git a/src/inc/inc.c b/src/inc/inc.c index a89d040a..e86c6f29 100644 --- a/src/inc/inc.c +++ b/src/inc/inc.c @@ -1,3 +1,8 @@ #include "inc.h" #include "inc_core.c" +void INC_Main(void) +{ + RunOnce(); + INC_StartupDeps(); +} diff --git a/src/inc/inc.h b/src/inc/inc.h index 5a032d4c..92ee615c 100644 --- a/src/inc/inc.h +++ b/src/inc/inc.h @@ -2,7 +2,12 @@ #define INC_H #include "../base/base.h" +inline void INC_StartupDeps(void) +{ + BaseMain(); +} #include "inc_core.h" +void INC_Main(void); #endif diff --git a/src/json/json.c b/src/json/json.c index 43d0bc92..01b61a5d 100644 --- a/src/json/json.c +++ b/src/json/json.c @@ -1,3 +1,8 @@ #include "json.h" #include "json_core.c" +void JSON_Main(void) +{ + RunOnce(); + JSON_StartupDeps(); +} diff --git a/src/json/json.h b/src/json/json.h index 27a9660e..5b2e91cb 100644 --- a/src/json/json.h +++ b/src/json/json.h @@ -2,7 +2,12 @@ #define JSON_H #include "../base/base.h" +inline void JSON_StartupDeps(void) +{ + BaseMain(); +} #include "json_core.h" +void JSON_Main(void); #endif diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c index 38b0235f..f5cc0d0e 100644 --- a/src/mixer/mixer.c +++ b/src/mixer/mixer.c @@ -1,3 +1,9 @@ #include "mixer.h" #include "mixer_core.c" +void MIX_Main(void) +{ + RunOnce(); + MIX_StartupDeps(); + MIX_StartupCore(); +} diff --git a/src/mixer/mixer.h b/src/mixer/mixer.h index 3d50fe05..a7570172 100644 --- a/src/mixer/mixer.h +++ b/src/mixer/mixer.h @@ -4,7 +4,14 @@ #include "../base/base.h" #include "../platform/platform.h" #include "../sound/sound.h" +inline void MIX_StartupDeps(void) +{ + BaseMain(); + P_Main(); + SND_Main(); +} #include "mixer_core.h" +void MIX_Main(void); #endif diff --git a/src/mixer/mixer_core.c b/src/mixer/mixer_core.c index 26468130..648a23ce 100644 --- a/src/mixer/mixer_core.c +++ b/src/mixer/mixer_core.c @@ -19,14 +19,13 @@ MIX_SharedState M_shared_state = ZI; //////////////////////////////// //~ Startup -MIX_StartupReceipt MIX_Startup(void) +void MIX_StartupCore(void) { __prof; MIX_SharedState *g = &M_shared_state; g->track_arena = AllocArena(Gibi(64)); g->listener_pos = VEC2(0, 0); g->listener_dir = VEC2(0, -1); - return (MIX_StartupReceipt) { 0 }; } //////////////////////////////// diff --git a/src/mixer/mixer_core.h b/src/mixer/mixer_core.h index 1f480f8e..64aafad6 100644 --- a/src/mixer/mixer_core.h +++ b/src/mixer/mixer_core.h @@ -98,8 +98,7 @@ extern MIX_SharedState M_shared_state; //////////////////////////////// //~ Startup -Struct(MIX_StartupReceipt) { i32 _; }; -MIX_StartupReceipt MIX_Startup(void); +void MIX_StartupCore(void); //////////////////////////////// //~ Track operations diff --git a/src/mp3/mp3.c b/src/mp3/mp3.c index 855b8c6b..71649eb2 100644 --- a/src/mp3/mp3.c +++ b/src/mp3/mp3.c @@ -5,3 +5,8 @@ #else # error Mp3 core not implemented for this platform #endif +void MP3_Main(void) +{ + RunOnce(); + MP3_StartupDeps(); +} diff --git a/src/mp3/mp3.h b/src/mp3/mp3.h index 6ae91e50..6cf153de 100644 --- a/src/mp3/mp3.h +++ b/src/mp3/mp3.h @@ -2,7 +2,12 @@ #define MP3_H #include "../base/base.h" +inline void MP3_StartupDeps(void) +{ + BaseMain(); +} #include "mp3_core.h" +void MP3_Main(void); #endif diff --git a/src/net/net.c b/src/net/net.c index c786b48c..8f0ab453 100644 --- a/src/net/net.c +++ b/src/net/net.c @@ -1,3 +1,8 @@ #include "net.h" #include "net_core.c" +void N_Main(void) +{ + RunOnce(); + N_StartupDeps(); +} diff --git a/src/net/net.h b/src/net/net.h index 63a9c05f..84893ca3 100644 --- a/src/net/net.h +++ b/src/net/net.h @@ -4,7 +4,14 @@ #include "../base/base.h" #include "../platform/platform.h" #include "../bitbuff/bitbuff.h" +inline void N_StartupDeps(void) +{ + BaseMain(); + P_Main(); + BB_Main(); +} #include "net_core.h" +void N_Main(void); #endif diff --git a/src/platform/platform.c b/src/platform/platform.c index 096ed58d..e4d1ab11 100644 --- a/src/platform/platform.c +++ b/src/platform/platform.c @@ -7,3 +7,10 @@ #else # error Platform core not implemented #endif +void P_Main(void) +{ + RunOnce(); + P_StartupDeps(); + /* FIXME: Logfile path */ + P_StartupLog(Lit("log.txt")); +} diff --git a/src/platform/platform.h b/src/platform/platform.h index 57722ec8..34ffe2ab 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -2,12 +2,16 @@ #define PLATFORM_H #include "../base/base.h" +inline void P_StartupDeps(void) +{ + BaseMain(); +} #include "platform_core.h" #include "platform_log.h" - #if PlatformIsWindows # include "platform_win32.h" #endif +void P_Main(void); #endif diff --git a/src/platform/platform_log.c b/src/platform/platform_log.c index fe349b70..ad671798 100644 --- a/src/platform/platform_log.c +++ b/src/platform/platform_log.c @@ -6,7 +6,7 @@ P_SharedLogState P_shared_log_state = ZI; //////////////////////////////// //~ Startup -void P_LogStartup(String logfile_path) +void P_StartupLog(String logfile_path) { __prof; P_SharedLogState *ctx = &P_shared_log_state; diff --git a/src/platform/platform_log.h b/src/platform/platform_log.h index 51fabc32..3cb6f5c5 100644 --- a/src/platform/platform_log.h +++ b/src/platform/platform_log.h @@ -117,7 +117,7 @@ Global Readonly P_LogLevelSettings P_log_settings[P_LogLevel_Count] = { //////////////////////////////// //~ Startup -void P_LogStartup(String logfile_path); +void P_StartupLog(String logfile_path); //////////////////////////////// //~ Logging macros diff --git a/src/platform/platform_win32.c b/src/platform/platform_win32.c index f5625120..10cb9607 100644 --- a/src/platform/platform_win32.c +++ b/src/platform/platform_win32.c @@ -2075,6 +2075,8 @@ JobDef(P_W32_AppShutdownJob, UNUSED sig, UNUSED id) int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, _In_ LPWSTR cmdline_wstr, _In_ int show_code) { + P_Main(); + LAX instance; LAX prev_instance; LAX cmdline_wstr; @@ -2163,9 +2165,6 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, g->exit_begin_event = CreateEventW(0, 1, 0, 0); g->exit_end_event = CreateEventW(0, 1, 0, 0); - /* Convert main thread to fiber */ - W32_AllocFiber(0); - u64 cmdline_len = WstrLen(cmdline_wstr, countof(g->cmdline_args_wstr) - 1); CopyBytes(g->cmdline_args_wstr, cmdline_wstr, cmdline_len * sizeof(*cmdline_wstr)); g->cmdline_args_wstr[cmdline_len] = 0; diff --git a/src/playback/playback.c b/src/playback/playback.c index 4a7f6ea2..70e0ffdc 100644 --- a/src/playback/playback.c +++ b/src/playback/playback.c @@ -5,3 +5,9 @@ #else # error Playback core not implemented for this platform #endif +void PB_Main(void) +{ + RunOnce(); + PB_StartupDeps(); + PB_StartupCore(); +} diff --git a/src/playback/playback.h b/src/playback/playback.h index 92189091..a834cb98 100644 --- a/src/playback/playback.h +++ b/src/playback/playback.h @@ -4,11 +4,17 @@ #include "../base/base.h" #include "../platform/platform.h" #include "../mixer/mixer.h" +inline void PB_StartupDeps(void) +{ + BaseMain(); + P_Main(); + MIX_Main(); +} #include "playback_core.h" - #if PlatformIsWindows # include "playback_win32.h" #endif +void PB_Main(void); #endif diff --git a/src/playback/playback_core.h b/src/playback/playback_core.h index 99586bbb..8690daea 100644 --- a/src/playback/playback_core.h +++ b/src/playback/playback_core.h @@ -1,4 +1,3 @@ #define PB_SampleRate 48000 -Struct(PB_StartupReceipt) { i32 _; }; -PB_StartupReceipt PB_Startup(MIX_StartupReceipt *mixer_sr); +void PB_StartupCore(void); diff --git a/src/playback/playback_win32.c b/src/playback/playback_win32.c index 97cdfd3e..2185c652 100644 --- a/src/playback/playback_win32.c +++ b/src/playback/playback_win32.c @@ -9,17 +9,14 @@ PB_WSP_SharedState PB_WSP_shared_state = ZI; //////////////////////////////// //~ Startup -PB_StartupReceipt PB_Startup(MIX_StartupReceipt *mixer_sr) +void PB_StartupCore(void) { __prof; PB_WSP_SharedState *g = &PB_WSP_shared_state; - LAX mixer_sr; PB_WSP_InitializeWasapi(); /* Start playback job */ RunJob(1, PB_WSP_PlaybackJob, 0, PoolKind_Audio, PriorityKind_High, &g->PB_WSP_PlaybackJob_counter); P_OnExit(&PB_WSP_Shutdown); - - return (PB_StartupReceipt) { 0 }; } P_ExitFuncDef(PB_WSP_Shutdown) diff --git a/src/pp/pp.c b/src/pp/pp.c index 2bbe132e..8e807f69 100644 --- a/src/pp/pp.c +++ b/src/pp/pp.c @@ -6,3 +6,10 @@ #include "pp_space.c" #include "pp_sim.c" #include "pp_core.c" +void PpMain(void) +{ + RunOnce(); + StartupPpDeps(); + StartupSim(); + StartupUser(); +} diff --git a/src/pp/pp.h b/src/pp/pp.h index 2cda782b..866edce6 100644 --- a/src/pp/pp.h +++ b/src/pp/pp.h @@ -10,6 +10,18 @@ #include "../net/net.h" #include "../mixer/mixer.h" #include "../bitbuff/bitbuff.h" +inline void StartupPpDeps(void) +{ + BaseMain(); + GPU_Main(); + S_Main(); + F_Main(); + CLD_Main(); + D_Main(); + N_Main(); + MIX_Main(); + BB_Main(); +} #include "pp_sim.h" #include "pp_phys.h" @@ -17,5 +29,6 @@ #include "pp_ent.h" #include "pp_step.h" #include "pp_core.h" +void PpMain(void); #endif diff --git a/src/pp/pp_core.c b/src/pp/pp_core.c index b9eabc31..3ad765db 100644 --- a/src/pp/pp_core.c +++ b/src/pp/pp_core.c @@ -3,19 +3,9 @@ SharedUserState shared_user_state = ZI; //////////////////////////////// //~ Startup -UserStartupReceipt StartupUser(S_StartupReceipt *sprite_sr, - D_StartupReceipt *draw_sr, - AC_StartupReceipt *asset_cache_sr, - MIX_StartupReceipt *mixer_sr, - SimStartupReceipt *sim_sr, - String connect_address_str) +void StartupUser(void) { __prof; - LAX sprite_sr; - LAX draw_sr; - LAX asset_cache_sr; - LAX mixer_sr; - LAX sim_sr; SharedUserState *g = &shared_user_state; SetGstat(GSTAT_DEBUG_STEPS, U64Max); @@ -24,6 +14,7 @@ UserStartupReceipt StartupUser(S_StartupReceipt *sprite_sr, g->real_time_ns = TimeNs(); /* TODO: Remove this */ + String connect_address_str = Lit(""); g->connect_address_str = PushString(g->arena, connect_address_str); /* Initialize average dt to a reasonable value */ @@ -56,8 +47,6 @@ UserStartupReceipt StartupUser(S_StartupReceipt *sprite_sr, RunJob(1, UpdateUserJob, 0, PoolKind_User, PriorityKind_High, &g->shutdown_job_counters); RunJob(1, SimJob, 0, PoolKind_Sim, PriorityKind_High, &g->shutdown_job_counters); P_OnExit(&ShutdownUser); - - return (UserStartupReceipt) { 0 }; } //////////////////////////////// diff --git a/src/pp/pp_core.h b/src/pp/pp_core.h index 6805d9aa..ea87c796 100644 --- a/src/pp/pp_core.h +++ b/src/pp/pp_core.h @@ -252,13 +252,7 @@ extern SharedUserState shared_user_state; //////////////////////////////// //~ Startup -Struct(UserStartupReceipt) { i32 _; }; -UserStartupReceipt StartupUser(S_StartupReceipt *sprite_sr, - D_StartupReceipt *draw_sr, - AC_StartupReceipt *asset_cache_sr, - MIX_StartupReceipt *mixer_sr, - SimStartupReceipt *sim_sr, - String connect_address_str); +void StartupUser(void); //////////////////////////////// //~ Shutdown diff --git a/src/pp/pp_sim.c b/src/pp/pp_sim.c index d8c77f5e..88d95f98 100644 --- a/src/pp/pp_sim.c +++ b/src/pp/pp_sim.c @@ -52,7 +52,7 @@ Readonly Snapshot **_g_sim_snapshot_nil = &G.nil_snapshot; /* Accessed via `sim_ent_nil()` */ Readonly Entity **_g_sim_ent_nil = &G.nil_ent; -SimStartupReceipt SimStartup(void) +void StartupSim(void) { __prof; G.nil_arena = AllocArena(Gibi(1)); @@ -87,7 +87,6 @@ SimStartupReceipt SimStartup(void) /* Lock nil arena */ SetArenaReadonly(G.nil_arena); - return (SimStartupReceipt) { 0 }; } /* ========================== * diff --git a/src/pp/pp_sim.h b/src/pp/pp_sim.h index b7b2a674..8a3b5848 100644 --- a/src/pp/pp_sim.h +++ b/src/pp/pp_sim.h @@ -24,8 +24,7 @@ Struct(ClientHandle) { * Startup * ========================== */ -Struct(SimStartupReceipt) { i32 _; }; -SimStartupReceipt SimStartup(void); +void StartupSim(void); /* ========================== * * Client store diff --git a/src/resource/resource.c b/src/resource/resource.c index 4e9714cb..89308560 100644 --- a/src/resource/resource.c +++ b/src/resource/resource.c @@ -1,3 +1,9 @@ #include "resource.h" #include "resource_core.c" +void RES_Main(void) +{ + RunOnce(); + RES_StartupDeps(); + RES_StartupCore(); +} diff --git a/src/resource/resource.h b/src/resource/resource.h index 31faea71..8ce87dcd 100644 --- a/src/resource/resource.h +++ b/src/resource/resource.h @@ -4,11 +4,20 @@ #include "../base/base.h" #include "../platform/platform.h" #include "../tar/tar.h" - #if RESOURCES_EMBEDDED # include "../inc/inc.h" #endif +inline void RES_StartupDeps(void) +{ + BaseMain(); + P_Main(); + TAR_Main(); +#if RESOURCES_EMBEDDED + INC_Main(); +#endif +} #include "resource_core.h" +void RES_Main(void); #endif diff --git a/src/resource/resource_core.c b/src/resource/resource_core.c index 4f820adb..859754f4 100644 --- a/src/resource/resource_core.c +++ b/src/resource/resource_core.c @@ -3,7 +3,7 @@ RES_SharedState RES_shared_state = ZI; //////////////////////////////// //~ Startup -RES_StartupReceipt RES_Startup(void) +void RES_StartupCore(void) { __prof; RES_SharedState *g = &RES_shared_state; @@ -23,8 +23,6 @@ RES_StartupReceipt RES_Startup(void) P_Panic(Lit("Resource directory \"res\" not found. Make sure the executable is being launched from the correct working directory.")); } #endif - - return (RES_StartupReceipt) { 0 }; } //////////////////////////////// diff --git a/src/resource/resource_core.h b/src/resource/resource_core.h index f9b28e46..bd8c9aab 100644 --- a/src/resource/resource_core.h +++ b/src/resource/resource_core.h @@ -33,8 +33,7 @@ extern RES_SharedState RES_shared_state; //////////////////////////////// //~ Startup -Struct(RES_StartupReceipt) { i32 _; }; -RES_StartupReceipt RES_Startup(void); +void RES_StartupCore(void); //////////////////////////////// //~ Open / close diff --git a/src/settings/settings.c b/src/settings/settings.c index 3e05f5c3..23aa4d85 100644 --- a/src/settings/settings.c +++ b/src/settings/settings.c @@ -1,3 +1,8 @@ #include "settings.h" #include "settings_core.c" +void SETTINGS_Main(void) +{ + RunOnce(); + SETTINGS_StartupDeps(); +} diff --git a/src/settings/settings.h b/src/settings/settings.h index 7c066ef6..5c0e2088 100644 --- a/src/settings/settings.h +++ b/src/settings/settings.h @@ -4,7 +4,14 @@ #include "../base/base.h" #include "../platform/platform.h" #include "../json/json.h" +inline void SETTINGS_StartupDeps(void) +{ + BaseMain(); + P_Main(); + JSON_Main(); +} #include "settings_core.h" +void SETTINGS_Main(void); #endif diff --git a/src/sound/sound.c b/src/sound/sound.c index aa22fe9e..2c7bec52 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -1,3 +1,8 @@ #include "sound.h" #include "sound_core.c" +void SND_Main(void) +{ + RunOnce(); + SND_StartupDeps(); +} diff --git a/src/sound/sound.h b/src/sound/sound.h index 38ce369e..692ca3ee 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -6,7 +6,16 @@ #include "../mp3/mp3.h" #include "../resource/resource.h" #include "../asset_cache/asset_cache.h" +inline void SND_StartupDeps(void) +{ + BaseMain(); + P_Main(); + MP3_Main(); + RES_Main(); + AC_Main(); +} #include "sound_core.h" +void SND_Main(void); #endif diff --git a/src/sprite/sprite.c b/src/sprite/sprite.c index c1dca241..139f8114 100644 --- a/src/sprite/sprite.c +++ b/src/sprite/sprite.c @@ -1,3 +1,9 @@ #include "sprite.h" #include "sprite_core.c" +void S_Main(void) +{ + RunOnce(); + S_StartupDeps(); + S_StartupCore(); +} diff --git a/src/sprite/sprite.h b/src/sprite/sprite.h index 586e027d..2312a8c2 100644 --- a/src/sprite/sprite.h +++ b/src/sprite/sprite.h @@ -7,7 +7,17 @@ #include "../ase/ase.h" #include "../resource/resource.h" #include "../watch/watch.h" +inline void S_StartupDeps(void) +{ + BaseMain(); + P_Main(); + GPU_Main(); + ASE_Main(); + RES_Main(); + W_Main(); +} #include "sprite_core.h" +void S_Main(void); #endif diff --git a/src/sprite/sprite_core.c b/src/sprite/sprite_core.c index 998351d1..c823a1f5 100644 --- a/src/sprite/sprite_core.c +++ b/src/sprite/sprite_core.c @@ -3,7 +3,7 @@ S_SharedState S_shared_state = ZI; //////////////////////////////// //~ Startup -S_StartupReceipt S_Startup(void) +void S_StartupCore(void) { __prof; S_SharedState *g = &S_shared_state; @@ -42,14 +42,12 @@ S_StartupReceipt S_Startup(void) g->scopes_arena = AllocArena(Gibi(64)); - RunJob(1, S_EvictorJob, 0, PoolKind_Background, PriorityKind_Low, &g->shutdown_counter); + RunJob(1, S_EvictorJob, PoolKind_Background, PriorityKind_Low, &g->shutdown_counter, 0); P_OnExit(&S_Shutdown); #if RESOURCE_RELOADING W_RegisterCallback(&S_WatchSpriteCallback); #endif - - return (S_StartupReceipt) { 0 }; } //////////////////////////////// diff --git a/src/sprite/sprite_core.h b/src/sprite/sprite_core.h index 2a9c4e52..c996e082 100644 --- a/src/sprite/sprite_core.h +++ b/src/sprite/sprite_core.h @@ -255,8 +255,7 @@ extern S_SharedState S_shared_state; //////////////////////////////// //~ Startup -Struct(S_StartupReceipt) { i32 _; }; -S_StartupReceipt S_Startup(void); +void S_StartupCore(void); //////////////////////////////// //~ Shutdown diff --git a/src/tar/tar.c b/src/tar/tar.c index 7badbbf0..d9a85d04 100644 --- a/src/tar/tar.c +++ b/src/tar/tar.c @@ -1,3 +1,8 @@ #include "tar.h" #include "tar_core.c" +void TAR_Main(void) +{ + RunOnce(); + TAR_StartupDeps(); +} diff --git a/src/tar/tar.h b/src/tar/tar.h index 6b39dd58..a8dd88d9 100644 --- a/src/tar/tar.h +++ b/src/tar/tar.h @@ -4,7 +4,14 @@ #include "../base/base.h" #include "../platform/platform.h" #include "../bitbuff/bitbuff.h" +inline void TAR_StartupDeps(void) +{ + BaseMain(); + P_Main(); + BB_Main(); +} #include "tar_core.h" +void TAR_Main(void); #endif diff --git a/src/ttf/ttf.cpp b/src/ttf/ttf.cpp index cad50f59..034c448e 100644 --- a/src/ttf/ttf.cpp +++ b/src/ttf/ttf.cpp @@ -8,3 +8,9 @@ extern "C" #else # error TTF not implemented for this platform #endif +void TTF_Main(void) +{ + RunOnce(); + TTF_StartupDeps(); + TTF_StartupCore(); +} diff --git a/src/ttf/ttf.h b/src/ttf/ttf.h index dbee8c4b..5ee38ed3 100644 --- a/src/ttf/ttf.h +++ b/src/ttf/ttf.h @@ -2,11 +2,15 @@ #define TTF_H #include "../base/base.h" +inline void TTF_StartupDeps(void) +{ + BaseMain(); +} #include "ttf_core.h" - #if PlatformIsWindows # include "ttf_dwrite.h" #endif +void TTF_Main(void); #endif diff --git a/src/ttf/ttf_core.h b/src/ttf/ttf_core.h index 1e240d8e..4a89d11c 100644 --- a/src/ttf/ttf_core.h +++ b/src/ttf/ttf_core.h @@ -18,7 +18,6 @@ Struct(TTF_Result) u32 *image_pixels; /* Array of [width * height] pixels */ }; -Struct(TTF_StartupReceipt) { i32 _; }; -TTF_StartupReceipt TTF_Startup(void); +void TTF_StartupCore(void); TTF_Result TTF_Decode(Arena *arena, String encoded, f32 point_size, u32 *cache_codes, u32 cache_codes_count); diff --git a/src/ttf/ttf_dwrite.cpp b/src/ttf/ttf_dwrite.cpp index 7cfa143a..07af9e36 100644 --- a/src/ttf/ttf_dwrite.cpp +++ b/src/ttf/ttf_dwrite.cpp @@ -21,7 +21,7 @@ extern TTF_DW_SharedState TTF_DW_shared_state = ZI; //~ Startup /* Call this during font system startup */ -TTF_StartupReceipt TTF_Startup(void) +void TTF_StartupCore(void) { __prof; TTF_DW_SharedState *g = &TTF_DW_shared_state; @@ -48,8 +48,6 @@ TTF_StartupReceipt TTF_Startup(void) //P_Panic(Lit("Error creating DWrite factory")); (*(volatile int *)0) = 0; } - - return { 0 }; } //////////////////////////////// diff --git a/src/watch/watch.c b/src/watch/watch.c index d97ac3cd..ac00f629 100644 --- a/src/watch/watch.c +++ b/src/watch/watch.c @@ -1,3 +1,9 @@ #include "watch.h" #include "watch_core.c" +void W_Main(void) +{ + RunOnce(); + W_StartupDeps(); + W_StartupCore(); +} diff --git a/src/watch/watch.h b/src/watch/watch.h index c18151e7..264919eb 100644 --- a/src/watch/watch.h +++ b/src/watch/watch.h @@ -3,7 +3,13 @@ #include "../base/base.h" #include "../platform/platform.h" +inline void W_StartupDeps(void) +{ + BaseMain(); + P_Main(); +} #include "watch_core.h" +void W_Main(void); #endif diff --git a/src/watch/watch_core.c b/src/watch/watch_core.c index 44236f29..325e1198 100644 --- a/src/watch/watch_core.c +++ b/src/watch/watch_core.c @@ -3,15 +3,15 @@ W_SharedState W_shared_state = ZI; //////////////////////////////// //~ Startup -void W_Startup(void) +void W_StartupCore(void) { W_SharedState *g = &W_shared_state; g->watch = P_AllocWatch(Lit("./")); g->watch_events_arena = AllocArena(Gibi(64)); - RunJob(1, W_MonitorJob, 0, PoolKind_Floating, PriorityKind_Low, &g->watch_jobs_counter); - RunJob(1, W_DispatcherJob, 0, PoolKind_Background, PriorityKind_Low, &g->watch_jobs_counter); + RunJob(1, W_MonitorJob, PoolKind_Floating, PriorityKind_Low, &g->watch_jobs_counter, 0); + RunJob(1, W_DispatcherJob, PoolKind_Background, PriorityKind_Low, &g->watch_jobs_counter, 0); P_OnExit(&W_Shutdown); } diff --git a/src/watch/watch_core.h b/src/watch/watch_core.h index f3ec6cc3..c77c3d75 100644 --- a/src/watch/watch_core.h +++ b/src/watch/watch_core.h @@ -41,7 +41,7 @@ extern W_SharedState W_shared_state; //////////////////////////////// //~ Startup -void W_Startup(void); +void W_StartupCore(void); P_ExitFuncDef(W_Shutdown); ////////////////////////////////