fix fence signedness
This commit is contained in:
parent
1abf58d45b
commit
64dad2457c
@ -196,14 +196,14 @@ void YieldOnCounter(Counter *counter)
|
||||
////////////////////////////////
|
||||
//~ Fence
|
||||
|
||||
u64 FetchFence(Fence *fence)
|
||||
i64 FetchFence(Fence *fence)
|
||||
{
|
||||
return Atomic64Fetch(&fence->v.v);
|
||||
}
|
||||
|
||||
u64 FetchSetFence(Fence *fence, u64 x)
|
||||
i64 FetchSetFence(Fence *fence, i64 x)
|
||||
{
|
||||
u64 fetch = Atomic64FetchSet(&fence->v.v, x);
|
||||
i64 fetch = Atomic64FetchSet(&fence->v.v, x);
|
||||
if (x > fetch)
|
||||
{
|
||||
FutexWakeGte(&fence->v.v);
|
||||
@ -211,16 +211,16 @@ u64 FetchSetFence(Fence *fence, u64 x)
|
||||
return fetch;
|
||||
}
|
||||
|
||||
u64 FetchAddFence(Fence *fence, u64 x)
|
||||
i64 FetchAddFence(Fence *fence, i64 x)
|
||||
{
|
||||
u64 fetch = Atomic64FetchAdd(&fence->v.v, x);
|
||||
i64 fetch = Atomic64FetchAdd(&fence->v.v, x);
|
||||
FutexWakeGte(&fence->v.v);
|
||||
return fetch;
|
||||
}
|
||||
|
||||
void YieldOnFence(Fence *fence, u64 target)
|
||||
void YieldOnFence(Fence *fence, i64 target)
|
||||
{
|
||||
u64 v = Atomic64Fetch(&fence->v.v);
|
||||
i64 v = Atomic64Fetch(&fence->v.v);
|
||||
while (v < target)
|
||||
{
|
||||
FutexYieldGte(&fence->v.v, &v, sizeof(v));
|
||||
|
||||
@ -85,8 +85,8 @@ void YieldOnCounter(Counter *counter);
|
||||
////////////////////////////////
|
||||
//~ Fence operations
|
||||
|
||||
u64 FetchFence(Fence *fence);
|
||||
u64 FetchSetFence(Fence *fence, u64 x);
|
||||
u64 FetchAddFence(Fence *fence, u64 x);
|
||||
i64 FetchFence(Fence *fence);
|
||||
i64 FetchSetFence(Fence *fence, i64 x);
|
||||
i64 FetchAddFence(Fence *fence, i64 x);
|
||||
|
||||
void YieldOnFence(Fence *fence, u64 target);
|
||||
void YieldOnFence(Fence *fence, i64 target);
|
||||
|
||||
@ -47,10 +47,18 @@ StringList GetCommandLineArgs(void)
|
||||
void Echo(String msg)
|
||||
{
|
||||
HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (console_handle != INVALID_HANDLE_VALUE)
|
||||
if (console_handle && console_handle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
WriteFile(console_handle, msg.text, msg.len, 0, 0);
|
||||
}
|
||||
else if (IsRunningInDebugger())
|
||||
{
|
||||
char msg_cstr[16384];
|
||||
u64 len = MinU64(countof(msg_cstr) - 1, msg.len);
|
||||
CopyBytes(msg_cstr, msg.text, len);
|
||||
msg_cstr[len] = 0;
|
||||
OutputDebugStringA(msg_cstr);
|
||||
}
|
||||
}
|
||||
|
||||
b32 Panic(String msg)
|
||||
@ -127,7 +135,7 @@ void ExitNow(i32 code)
|
||||
////////////////////////////////
|
||||
//~ Startup / shutdown jobs
|
||||
|
||||
JobDef(W32_StartupLayersJob, UNUSED sig, UNUSED id)
|
||||
JobDef(W32_StartupLayers, UNUSED sig, UNUSED id)
|
||||
{
|
||||
W32_SharedState *g = &W32_shared_state;
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
@ -138,7 +146,7 @@ JobDef(W32_StartupLayersJob, UNUSED sig, UNUSED id)
|
||||
EndScratch(scratch);
|
||||
}
|
||||
|
||||
JobDef(W32_ShutdownLayersJob, UNUSED sig, UNUSED id)
|
||||
JobDef(W32_ShutdownLayers, UNUSED sig, UNUSED id)
|
||||
{
|
||||
__prof;
|
||||
W32_SharedState *g = &W32_shared_state;
|
||||
@ -275,7 +283,7 @@ i32 W32_Main(void)
|
||||
/* Startup layers */
|
||||
if (!Atomic32Fetch(&g->panicking))
|
||||
{
|
||||
RunJob(W32_StartupLayersJob);
|
||||
RunJob(W32_StartupLayers);
|
||||
}
|
||||
|
||||
/* Wait for startup end or panic */
|
||||
@ -303,7 +311,7 @@ i32 W32_Main(void)
|
||||
/* Run exit callbacks job */
|
||||
if (!Atomic32Fetch(&g->panicking))
|
||||
{
|
||||
RunJob(W32_ShutdownLayersJob);
|
||||
RunJob(W32_ShutdownLayers);
|
||||
}
|
||||
|
||||
/* Wait for exit end or panic */
|
||||
|
||||
@ -56,8 +56,8 @@ BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name
|
||||
////////////////////////////////
|
||||
//~ Startup / shutdown jobs
|
||||
|
||||
JobDecl(W32_StartupLayersJob, EmptySig);
|
||||
JobDecl(W32_ShutdownLayersJob, EmptySig);
|
||||
JobDecl(W32_StartupLayers, EmptySig);
|
||||
JobDecl(W32_ShutdownLayers, EmptySig);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Main
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
////////////////////////////////
|
||||
//~ Load job
|
||||
|
||||
JobDef(F_LoadJob, sig, _)
|
||||
JobDef(F_Load, sig, _)
|
||||
{
|
||||
__prof;
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
@ -123,8 +123,8 @@ AC_Asset *F_LoadAsset(Resource resource, f32 point_size, b32 wait)
|
||||
{
|
||||
AC_MarkLoading(asset);
|
||||
{
|
||||
Job *job = OpenJob(F_LoadJob, JobPool_Background);
|
||||
F_LoadJob_Sig *sig = PushStruct(job->arena, F_LoadJob_Sig);
|
||||
Job *job = OpenJob(F_Load, JobPool_Background);
|
||||
F_Load_Sig *sig = PushStruct(job->arena, F_Load_Sig);
|
||||
sig->asset = asset;
|
||||
sig->resource = resource;
|
||||
sig->point_size = point_size;
|
||||
|
||||
@ -27,7 +27,7 @@ Struct(F_Font)
|
||||
////////////////////////////////
|
||||
//~ Font load job
|
||||
|
||||
JobDecl(F_LoadJob, { AC_Asset *asset; f32 point_size; Resource resource; });
|
||||
JobDecl(F_Load, { AC_Asset *asset; f32 point_size; Resource resource; });
|
||||
|
||||
////////////////////////////////
|
||||
//~ Font load operations
|
||||
|
||||
@ -105,8 +105,8 @@ Struct(RunCommandResult)
|
||||
i64 elapsed_ns;
|
||||
};
|
||||
|
||||
JobDecl(RunCommandJob, { String *cmds; RunCommandResult *results; });
|
||||
JobDef(RunCommandJob, sig, id)
|
||||
JobDecl(RunCommand, { String *cmds; RunCommandResult *results; });
|
||||
JobDef(RunCommand, sig, id)
|
||||
{
|
||||
i64 start_ns = TimeNs();
|
||||
Arena *arena = PermArena();
|
||||
@ -192,8 +192,8 @@ void InheritStepResults(Arena *arena, StepResult *dst, u64 srcs_count, StepResul
|
||||
}
|
||||
}
|
||||
|
||||
JobDecl(StepJob, { StepParams *params; StepResult *results; });
|
||||
JobDef(StepJob, sig, id)
|
||||
JobDecl(Step, { StepParams *params; StepResult *results; });
|
||||
JobDef(Step, sig, id)
|
||||
{
|
||||
StepParams *params = &sig->params[id];
|
||||
StepParamsFlag flags = params->flags;
|
||||
@ -530,7 +530,7 @@ JobDef(StepJob, sig, id)
|
||||
}
|
||||
}
|
||||
JobCounter counter = ZI;
|
||||
RunJob(RunCommandJob,
|
||||
RunJob(RunCommand,
|
||||
.count = shader_entries_count,
|
||||
.counter = &counter,
|
||||
.sig = { .cmds = compile_cmds, .results = compile_results });
|
||||
@ -567,7 +567,7 @@ JobDef(StepJob, sig, id)
|
||||
arc_params.arc_dir = shader_store_name;
|
||||
|
||||
JobCounter counter = ZI;
|
||||
RunJob(StepJob, .counter = &counter, .sig.params = &arc_params, .sig.results = &arc_results);
|
||||
RunJob(Step, .counter = &counter, .sig.params = &arc_params, .sig.results = &arc_results);
|
||||
YieldOnJobs(&counter);
|
||||
InheritStepResults(arena, result, 1, &arc_results);
|
||||
}
|
||||
@ -643,7 +643,7 @@ JobDef(StepJob, sig, id)
|
||||
}
|
||||
}
|
||||
JobCounter counter = ZI;
|
||||
RunJob(StepJob,
|
||||
RunJob(Step,
|
||||
.counter = &counter,
|
||||
.count = dir_embeds_count,
|
||||
.sig.params = arc_params_array,
|
||||
@ -805,8 +805,8 @@ JobDef(StepJob, sig, id)
|
||||
////////////////////////////////
|
||||
//~ Startup
|
||||
|
||||
JobDecl(BuildJob, EmptySig);
|
||||
JobDef(BuildJob, _, __)
|
||||
JobDecl(Build, EmptySig);
|
||||
JobDef(Build, _, __)
|
||||
{
|
||||
Arena *arena = PermArena();
|
||||
M_ErrorList errors = ZI;
|
||||
@ -994,7 +994,7 @@ JobDef(BuildJob, _, __)
|
||||
resource_params->flattened = flattened;
|
||||
|
||||
JobCounter step_counter = ZI;
|
||||
RunJob(StepJob, .count = countof(params_array), .counter = &step_counter, .sig.params = params_array, .sig.results = results_array);
|
||||
RunJob(Step, .count = countof(params_array), .counter = &step_counter, .sig.params = params_array, .sig.results = results_array);
|
||||
YieldOnJobs(&step_counter);
|
||||
|
||||
////////////////////////////////
|
||||
@ -1108,5 +1108,5 @@ JobDef(BuildJob, _, __)
|
||||
void StartupLayers(void)
|
||||
{
|
||||
OS_Startup();
|
||||
RunJob(BuildJob, .pool = JobPool_Hyper);
|
||||
RunJob(Build, .pool = JobPool_Hyper);
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ void P_Startup(void)
|
||||
g->socks_arena = AcquireArena(Gibi(64));
|
||||
|
||||
//- Init timer
|
||||
RunJob(P_W32_TimerJob);
|
||||
RunJob(P_W32_UpdateTimer);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@ -868,7 +868,7 @@ P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr)
|
||||
////////////////////////////////
|
||||
//~ Timer job
|
||||
|
||||
JobDef(P_W32_TimerJob, _, __)
|
||||
JobDef(P_W32_UpdateTimer, _, __)
|
||||
{
|
||||
P_W32_SharedState *g = &P_W32_shared_state;
|
||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
|
||||
@ -887,6 +887,8 @@ JobDef(P_W32_TimerJob, _, __)
|
||||
periods[i] = P_W32_DefaultTimerPeriodNs;
|
||||
}
|
||||
|
||||
Echo(Lit("Starting timer\n"));
|
||||
|
||||
i64 last_cycle_ns = 0;
|
||||
/* FIXME: shutdown */
|
||||
for (;;)
|
||||
|
||||
@ -180,4 +180,4 @@ P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr);
|
||||
////////////////////////////////
|
||||
//~ Timer job
|
||||
|
||||
JobDecl(P_W32_TimerJob, EmptySig);
|
||||
JobDecl(P_W32_UpdateTimer, EmptySig);
|
||||
|
||||
@ -15,7 +15,7 @@ void PB_Startup(void)
|
||||
PB_WSP_SharedState *g = &PB_WSP_shared_state;
|
||||
PB_WSP_InitializeWasapi();
|
||||
/* Start playback job */
|
||||
RunJob(PB_WSP_PlaybackJob, .pool = JobPool_Audio, .counter = &g->shutdown_job_counter);
|
||||
RunJob(PB_WSP_Playback, .pool = JobPool_Audio, .counter = &g->shutdown_job_counter);
|
||||
OnExit(&PB_WSP_Shutdown);
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src)
|
||||
////////////////////////////////
|
||||
//~ Playback job
|
||||
|
||||
JobDef(PB_WSP_PlaybackJob, UNUSED sig, UNUSED id)
|
||||
JobDef(PB_WSP_Playback, UNUSED sig, UNUSED id)
|
||||
{
|
||||
__prof;
|
||||
PB_WSP_SharedState *g = &PB_WSP_shared_state;
|
||||
|
||||
@ -50,4 +50,4 @@ void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src);
|
||||
////////////////////////////////
|
||||
//~ Playback job
|
||||
|
||||
JobDecl(PB_WSP_PlaybackJob, EmptySig);
|
||||
JobDecl(PB_WSP_Playback, EmptySig);
|
||||
|
||||
10
src/pp/pp.c
10
src/pp/pp.c
@ -48,8 +48,8 @@ void StartupUser(void)
|
||||
P_ShowWindow(g->window);
|
||||
|
||||
/* Start jobs */
|
||||
RunJob(UpdateUserJob, .pool = JobPool_User, .counter = &g->shutdown_job_counter);
|
||||
RunJob(SimJob, .pool = JobPool_Sim, .counter = &g->shutdown_job_counter);
|
||||
RunJob(UpdateUserOrSleep, .pool = JobPool_User, .counter = &g->shutdown_job_counter);
|
||||
RunJob(UpdateSim, .pool = JobPool_Sim, .counter = &g->shutdown_job_counter);
|
||||
OnExit(&ShutdownUser);
|
||||
}
|
||||
|
||||
@ -2445,7 +2445,7 @@ void UpdateUser(P_Window *window)
|
||||
////////////////////////////////
|
||||
//~ User update job
|
||||
|
||||
JobDef(UpdateUserJob, UNUSED sig, UNUSED id)
|
||||
JobDef(UpdateUserOrSleep, UNUSED sig, UNUSED id)
|
||||
{
|
||||
SharedUserState *g = &shared_user_state;
|
||||
i64 time_ns = TimeNs();
|
||||
@ -2459,7 +2459,7 @@ JobDef(UpdateUserJob, UNUSED sig, UNUSED id)
|
||||
GPU_WaitOnSwapchain(g->swapchain);
|
||||
}
|
||||
{
|
||||
__profn("Frame limiter wait");
|
||||
__profn("Frame limiter wait");;
|
||||
P_SleepFrame(time_ns, 1000000000 / FPS_LIMIT);
|
||||
time_ns = TimeNs();
|
||||
}
|
||||
@ -2511,7 +2511,7 @@ void GenerateuserInputCmds(Client *user_input_client, u64 tick)
|
||||
////////////////////////////////
|
||||
//~ Sim update
|
||||
|
||||
JobDef(SimJob, UNUSED sig, UNUSED id)
|
||||
JobDef(UpdateSim, UNUSED sig, UNUSED id)
|
||||
{
|
||||
SharedUserState *g = &shared_user_state;
|
||||
#if 0
|
||||
|
||||
@ -311,7 +311,7 @@ void UpdateUser(P_Window *window);
|
||||
////////////////////////////////
|
||||
//~ User update job
|
||||
|
||||
JobDecl(UpdateUserJob, EmptySig);
|
||||
JobDecl(UpdateUserOrSleep, EmptySig);
|
||||
|
||||
////////////////////////////////
|
||||
//~ User input cmds
|
||||
@ -319,6 +319,6 @@ JobDecl(UpdateUserJob, EmptySig);
|
||||
void GenerateuserInputCmds(Client *user_input_client, u64 tick);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Sim update
|
||||
//~ Sim update job
|
||||
|
||||
JobDecl(SimJob, EmptySig);
|
||||
JobDecl(UpdateSim, EmptySig);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
////////////////////////////////
|
||||
//~ Load job
|
||||
|
||||
JobDef(SND_LoadJob, sig, UNUSED id)
|
||||
JobDef(SND_Load, sig, UNUSED id)
|
||||
{
|
||||
__prof;
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
@ -99,8 +99,8 @@ AC_Asset *SND_LoadAsset(Resource resource, SND_SoundFlag flags, b32 wait)
|
||||
{
|
||||
AC_MarkLoading(asset);
|
||||
{
|
||||
Job *job = OpenJob(SND_LoadJob, JobPool_Background);
|
||||
SND_LoadJob_Sig *sig = PushStruct(job->arena, SND_LoadJob_Sig);
|
||||
Job *job = OpenJob(SND_Load, JobPool_Background);
|
||||
SND_Load_Sig *sig = PushStruct(job->arena, SND_Load_Sig);
|
||||
sig->resource = resource;
|
||||
sig->asset = asset;
|
||||
sig->flags = flags;
|
||||
|
||||
@ -19,7 +19,7 @@ Struct(SND_Sound)
|
||||
////////////////////////////////
|
||||
//~ Sound load operations
|
||||
|
||||
JobDecl(SND_LoadJob, { SND_SoundFlag flags; AC_Asset *asset; Resource resource; });
|
||||
JobDecl(SND_Load, { SND_SoundFlag flags; AC_Asset *asset; Resource resource; });
|
||||
AC_Asset *SND_LoadAsset(Resource resource, SND_SoundFlag flags, b32 wait);
|
||||
SND_Sound *SND_LoadSoundAsync(Resource resource, SND_SoundFlag flags);
|
||||
SND_Sound *SND_LoadSoundWait(Resource resource, SND_SoundFlag flags);
|
||||
|
||||
@ -5,7 +5,7 @@ S_SharedState S_shared_state = ZI;
|
||||
////////////////////////////////
|
||||
//~ Load jobs
|
||||
|
||||
JobDef(S_LoadTextureJob, sig, _)
|
||||
JobDef(S_LoadTexture, sig, _)
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
S_Entry *entry = sig->entry;
|
||||
@ -40,7 +40,7 @@ JobDef(S_LoadTextureJob, sig, _)
|
||||
EndScratch(scratch);
|
||||
}
|
||||
|
||||
JobDef(S_LoadSheetJob, sig, _)
|
||||
JobDef(S_LoadSheet, sig, _)
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
Arena *perm = PermArena();
|
||||
@ -286,13 +286,13 @@ S_Entry *S_FetchEntry(Resource resource, JobPool pool, S_FetchFlag flags)
|
||||
&& !Atomic32Fetch(&entry->texture_touched)
|
||||
&& !Atomic32FetchTestSet(&entry->texture_touched, 0, 1))
|
||||
{
|
||||
RunJob(S_LoadTextureJob, .pool = pool, .sig.entry = entry);
|
||||
RunJob(S_LoadTexture, .pool = pool, .sig.entry = entry);
|
||||
}
|
||||
if ((flags & S_FetchFlag_Sheet)
|
||||
&& !Atomic32Fetch(&entry->sheet_touched)
|
||||
&& !Atomic32FetchTestSet(&entry->sheet_touched, 0, 1))
|
||||
{
|
||||
RunJob(S_LoadSheetJob, .pool = pool, .sig.entry = entry);
|
||||
RunJob(S_LoadSheet, .pool = pool, .sig.entry = entry);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -133,8 +133,8 @@ Struct(S_SharedState)
|
||||
////////////////////////////////
|
||||
//~ Load jobs
|
||||
|
||||
JobDecl(S_LoadTextureJob, { S_Entry *entry; });
|
||||
JobDecl(S_LoadSheetJob, { S_Entry *entry; });
|
||||
JobDecl(S_LoadTexture, { S_Entry *entry; });
|
||||
JobDecl(S_LoadSheet, { S_Entry *entry; });
|
||||
|
||||
////////////////////////////////
|
||||
//~ Cache operations
|
||||
|
||||
Loading…
Reference in New Issue
Block a user