formatting

This commit is contained in:
jacob 2025-08-01 21:15:00 -05:00
parent d2ef6273c9
commit 59e724f57a
9 changed files with 93 additions and 112 deletions

47
.natvis
View File

@ -1,33 +1,33 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name = "v2"> <Type Name = "Vec2">
<DisplayString>({x}, {y})</DisplayString> <DisplayString>({x}, {y})</DisplayString>
</Type> </Type>
<Type Name = "string"> <Type Name = "String">
<DisplayString>({len}) {text, [len] s}</DisplayString> <DisplayString>({len}) {text, [len] s}</DisplayString>
<StringView>text, [len] s</StringView> <StringView>text, [len] s</StringView>
</Type> </Type>
<Type Name = "string16"> <Type Name = "String16">
<DisplayString>({len}) {text, [len] su}</DisplayString> <DisplayString>({len}) {text, [len] su}</DisplayString>
<StringView>text, [len] su</StringView> <StringView>text, [len] su</StringView>
</Type> </Type>
<Type Name = "arena"> <Type Name = "Arena">
<DisplayString>pos: {pos}, committed: [{committed} / {reserved}]</DisplayString> <DisplayString>pos: {pos}, committed: [{committed} / {reserved}]</DisplayString>
<Expand> <Expand>
<Item Name="Data">base, [pos] s</Item> <Item Name="Data">(((u8 *)this) + 64), [pos] s</Item>
<Item Name="Data (Extended)">base, [pos+100] s</Item> <Item Name="Data (Extended)">(((u8 *)this) + 64), [pos+100] s</Item>
</Expand> </Expand>
</Type> </Type>
<Type Name = "arena_temp"> <Type Name = "TempArena">
<DisplayString>start: {start_pos}, arena: {{{*arena}}}</DisplayString> <DisplayString>start: {start_pos}, arena: {{{*arena}}}</DisplayString>
<Expand> <Expand>
<Item Name="Data">(arena->base + start_pos), [arena->pos - start_pos] s</Item> <Item Name="Data">(((u8 *)arena) + start_pos + 64), [arena->pos - start_pos]</Item>
<Item Name="Data (Extended)">(arena->base + start_pos), [arena->pos - start_pos + 100] s</Item> <Item Name="Data (Extended)">(((u8 *)arena) + start_pos + 64), [arena->pos - start_pos + 100]</Item>
<Item Name="Size">arena->pos - start_pos</Item> <Item Name="Size">arena->pos - start_pos</Item>
</Expand> </Expand>
</Type> </Type>
@ -42,7 +42,7 @@
</Expand> </Expand>
</Type> </Type>
<Type Name = "uid"> <Type Name = "UID">
<DisplayString>[{(u32)(hi >> 32), xb}]{((u32)(hi &amp; 0xFFFFFFFF)), xb}{lo, xb}</DisplayString> <DisplayString>[{(u32)(hi >> 32), xb}]{((u32)(hi &amp; 0xFFFFFFFF)), xb}{lo, xb}</DisplayString>
<Expand> <Expand>
<Item Name="hi">hi, x</Item> <Item Name="hi">hi, x</Item>
@ -50,40 +50,17 @@
</Expand> </Expand>
</Type> </Type>
<Type Name = "sim_ent_id"> <Type Name = "EntityId">
<DisplayString Condition="uid.hi == 0 &amp;&amp; uid.lo == 0">[NIL]</DisplayString> <DisplayString Condition="uid.hi == 0 &amp;&amp; uid.lo == 0">[NIL]</DisplayString>
<DisplayString Condition="uid.hi == 0x66a36cc2bcc752da &amp;&amp; uid.lo == 0x6c286c09b366eae6">[ROOT]</DisplayString> <DisplayString Condition="uid.hi == 0x66a36cc2bcc752da &amp;&amp; uid.lo == 0x6c286c09b366eae6">[ROOT]</DisplayString>
<DisplayString>[{(u32)(uid.hi >> 32), xb}]</DisplayString> <DisplayString>[{(u32)(uid.hi >> 32), xb}]</DisplayString>
</Type> </Type>
<Type Name = "sim_ent"> <Type Name = "Entity">
<DisplayString Condition="(valid == 0 || (id.uid.hi == 0 &amp;&amp; id.uid.lo == 0)) &amp;&amp; this != *_g_sim_ent_nil">~~~MISMATCH~~~ {id} &lt;{this - this->ss->ents}&gt;</DisplayString> <DisplayString Condition="(valid == 0 || (id.uid.hi == 0 &amp;&amp; id.uid.lo == 0)) &amp;&amp; this != *_g_sim_ent_nil">~~~MISMATCH~~~ {id} &lt;{this - this->ss->ents}&gt;</DisplayString>
<DisplayString Condition="valid == 1 &amp;&amp; (id.uid.hi == 0 || id.uid.lo == 0)">~~~MISMATCH~~~ {id} &lt;{this - this->ss->ents}&gt;</DisplayString> <DisplayString Condition="valid == 1 &amp;&amp; (id.uid.hi == 0 || id.uid.lo == 0)">~~~MISMATCH~~~ {id} &lt;{this - this->ss->ents}&gt;</DisplayString>
<DisplayString Condition="this == *_g_sim_ent_nil">{id}</DisplayString> <DisplayString Condition="this == *_g_sim_ent_nil">{id}</DisplayString>
<DisplayString>{id} &lt;{this - this->ss->ents}&gt;</DisplayString> <DisplayString>{id} &lt;{this - this->ss->ents}&gt;</DisplayString>
</Type> </Type>
<Type Name = "String">
<DisplayString>({len}) {text, [len] s}</DisplayString>
<StringView>text, [len]</StringView>
</Type>
<Type Name = "Arena">
<DisplayString>pos: {pos}, committed: [{committed} / {reserved}]</DisplayString>
<Expand>
<Item Name="Data">base, [pos] s</Item>
<Item Name="Data (Extended)">base, [pos+100] s</Item>
</Expand>
</Type>
<Type Name = "TempArena">
<DisplayString>start: {start_pos}, arena: {{{*arena}}}</DisplayString>
<Expand>
<Item Name="Data">(arena->base + start_pos), [arena->pos - start_pos] s</Item>
<Item Name="Data (Extended)">(arena->base + start_pos), [arena->pos - start_pos + 100] s</Item>
<Item Name="Size">arena->pos - start_pos</Item>
</Expand>
</Type>
</AutoVisualizer> </AutoVisualizer>

View File

@ -1,7 +1,7 @@
//////////////////////////////// ////////////////////////////////
//~ Arena types //~ Arena types
#define ArenaHeaderSize 256 #define ArenaHeaderSize 64
#define ArenaBlockSize 16384 #define ArenaBlockSize 16384
Struct(Arena) Struct(Arena)
@ -202,13 +202,13 @@ Inline TempArena _BeginScratch(Arena *potential_conflict)
* exists in the caller's scope (`BeginScratch(arena)` should be called * exists in the caller's scope (`BeginScratch(arena)` should be called
* instead). */ * instead). */
#define BeginScratchNoConflict() \ #define BeginScratchNoConflict() \
_BeginScratchNoConflict(); \ BeginScratchNoConflict_(); \
do { \ do { \
u8 arena = 0; \ u8 arena = 0; \
LAX arena; \ LAX arena; \
} while (0) } while (0)
Inline TempArena _BeginScratchNoConflict(void) Inline TempArena BeginScratchNoConflict_(void)
{ {
ScratchCtx *ctx = ScratchCtxFromFiberId(FiberId()); ScratchCtx *ctx = ScratchCtxFromFiberId(FiberId());
Arena *scratch_arena = ctx->arenas[0]; Arena *scratch_arena = ctx->arenas[0];

View File

@ -143,7 +143,6 @@ extern "C" {
((sizeof(s) / 4) == n) && /* Root constant struct size should match the specified 32-bit-constant count */ \ ((sizeof(s) / 4) == n) && /* Root constant struct size should match the specified 32-bit-constant count */ \
(sizeof(s) <= 256)) /* Root constant struct can only fit 64 DWORDS */ (sizeof(s) <= 256)) /* Root constant struct can only fit 64 DWORDS */
//- Debug alias //- Debug alias
/* TODO: Remove this */ /* TODO: Remove this */
#if CompilerIsMsvc #if CompilerIsMsvc

View File

@ -1,7 +1,8 @@
//////////////////////////////// ////////////////////////////////
//~ Font types //~ Font types
Struct(F_Glyph) { Struct(F_Glyph)
{
f32 off_x; f32 off_x;
f32 off_y; f32 off_y;
f32 width; f32 width;
@ -10,7 +11,8 @@ Struct(F_Glyph) {
Rect atlas_rect; Rect atlas_rect;
}; };
Struct(F_Font) { Struct(F_Font)
{
GPU_Resource *texture; GPU_Resource *texture;
u32 image_width; u32 image_width;
u32 image_height; u32 image_height;

View File

@ -53,7 +53,7 @@ void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level)
//////////////////////////////// ////////////////////////////////
//~ Append //~ Append
void P__LogAppend(String msg) void P_LogAppend_(String msg)
{ {
__prof; __prof;
P_SharedLogCtx *ctx = &P_shared_log_ctx; P_SharedLogCtx *ctx = &P_shared_log_ctx;
@ -73,7 +73,7 @@ void P__LogAppend(String msg)
/* Panic log function is separate to enforce zero side effects other than /* Panic log function is separate to enforce zero side effects other than
* writing to log file. */ * writing to log file. */
void P__LogPanic(String msg) void P_LogPanic_(String msg)
{ {
P_SharedLogCtx *ctx = &P_shared_log_ctx; P_SharedLogCtx *ctx = &P_shared_log_ctx;
if (!Atomic32Fetch(&ctx->initialized)) { return; } if (!Atomic32Fetch(&ctx->initialized)) { return; }
@ -90,9 +90,9 @@ void P__LogPanic(String msg)
//~ Logfv //~ Logfv
#if P_IncludeLogSourceLocation #if P_IncludeLogSourceLocation
void P__LogFV(i32 level, String file, u32 line, String fmt, va_list args) void P_LogFV_(i32 level, String file, u32 line, String fmt, va_list args)
#else #else
void P__LogFV(i32 level, String fmt, va_list args) void P_LogFV_(i32 level, String fmt, va_list args)
#endif #endif
{ {
P_SharedLogCtx *ctx = &P_shared_log_ctx; P_SharedLogCtx *ctx = &P_shared_log_ctx;
@ -100,9 +100,9 @@ void P__LogFV(i32 level, String fmt, va_list args)
TempArena scratch = BeginScratchNoConflict(); TempArena scratch = BeginScratchNoConflict();
String msg = StringFormatV(scratch.arena, fmt, args); String msg = StringFormatV(scratch.arena, fmt, args);
#if P_IncludeLogSourceLocation #if P_IncludeLogSourceLocation
P__log(level, file, line, msg); P_Log_(level, file, line, msg);
#else #else
P__log(level, msg); P_Log_(level, msg);
#endif #endif
EndScratch(scratch); EndScratch(scratch);
} }
@ -111,9 +111,9 @@ void P__LogFV(i32 level, String fmt, va_list args)
//~ Logf //~ Logf
#if P_IncludeLogSourceLocation #if P_IncludeLogSourceLocation
void P__LogF(i32 level, String file, u32 line, String fmt, ...) void P_LogF_(i32 level, String file, u32 line, String fmt, ...)
#else #else
void P__LogF(i32 level, String fmt, ...) void P_LogF_(i32 level, String fmt, ...)
#endif #endif
{ {
P_SharedLogCtx *ctx = &P_shared_log_ctx; P_SharedLogCtx *ctx = &P_shared_log_ctx;
@ -121,9 +121,9 @@ void P__LogF(i32 level, String fmt, ...)
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
#if P_IncludeLogSourceLocation #if P_IncludeLogSourceLocation
P__LogFV(level, file, line, fmt, args); P_LogFV_(level, file, line, fmt, args);
#else #else
P__LogFV(level, fmt, args); P_LogFV_(level, fmt, args);
#endif #endif
va_end(args); va_end(args);
} }
@ -132,9 +132,9 @@ void P__LogF(i32 level, String fmt, ...)
//~ Log //~ Log
#if P_IncludeLogSourceLocation #if P_IncludeLogSourceLocation
void P__log(i32 level, String file, u32 line, String msg) void P_Log_(i32 level, String file, u32 line, String msg)
#else #else
void P__log(i32 level, String msg) void P_Log_(i32 level, String msg)
#endif #endif
{ {
__prof; __prof;
@ -204,7 +204,7 @@ void P__log(i32 level, String msg)
#endif #endif
__profmsg((char *)msg.text, msg.len, settings.color); __profmsg((char *)msg.text, msg.len, settings.color);
P__LogAppend(msg_formatted); P_LogAppend_(msg_formatted);
//- Run callbacks //- Run callbacks
P_LogEvent event = ZI; P_LogEvent event = ZI;

View File

@ -122,15 +122,15 @@ void P_LogStartup(String logfile_path);
//////////////////////////////// ////////////////////////////////
//~ Logging macros //~ Logging macros
#define log_panic(msg) P__LogPanic(msg) #define log_panic(msg) P_LogPanic_(msg)
#if P_LogLevel(P_LogLevel_Critical) #if P_LogLevel(P_LogLevel_Critical)
# if P_IncludeLogSourceLocation # if P_IncludeLogSourceLocation
# define P_LogCritical(msg) P__log(P_LogLevel_Critical, Lit(__FILE__), __LINE__, msg) # define P_LogCritical(msg) P_Log_(P_LogLevel_Critical, Lit(__FILE__), __LINE__, msg)
# define P_LogCriticalF(fmt_lit, ...) P__LogF(P_LogLevel_Critical, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogCriticalF(fmt_lit, ...) P_LogF_(P_LogLevel_Critical, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# else # else
# define P_LogCritical(msg) P__log(P_LogLevel_Critical, msg) # define P_LogCritical(msg) P_Log_(P_LogLevel_Critical, msg)
# define P_LogCriticalF(fmt_lit, ...) P__LogF(P_LogLevel_Critical, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogCriticalF(fmt_lit, ...) P_LogF_(P_LogLevel_Critical, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# endif # endif
#else #else
# define P_LogCritical(msg) # define P_LogCritical(msg)
@ -139,11 +139,11 @@ void P_LogStartup(String logfile_path);
#if P_LogLevel(P_LogLevel_Error) #if P_LogLevel(P_LogLevel_Error)
# if P_IncludeLogSourceLocation # if P_IncludeLogSourceLocation
# define P_LogError(msg) P__log(P_LogLevel_Error, Lit(__FILE__), __LINE__, msg) # define P_LogError(msg) P_Log_(P_LogLevel_Error, Lit(__FILE__), __LINE__, msg)
# define P_LogErrorF(fmt_lit, ...) P__LogF(P_LogLevel_Error, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogErrorF(fmt_lit, ...) P_LogF_(P_LogLevel_Error, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# else # else
# define P_LogError(msg) P__log(P_LogLevel_Error, msg) # define P_LogError(msg) P_Log_(P_LogLevel_Error, msg)
# define P_LogErrorF(fmt_lit, ...) P__LogF(P_LogLevel_Error, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogErrorF(fmt_lit, ...) P_LogF_(P_LogLevel_Error, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# endif # endif
#else #else
# define P_LogError(msg) # define P_LogError(msg)
@ -152,11 +152,11 @@ void P_LogStartup(String logfile_path);
#if P_LogLevel(P_LogLevel_Warning) #if P_LogLevel(P_LogLevel_Warning)
# if P_IncludeLogSourceLocation # if P_IncludeLogSourceLocation
# define P_LogWarning(msg) P__log(P_LogLevel_Warning, Lit(__FILE__), __LINE__, msg) # define P_LogWarning(msg) P_Log_(P_LogLevel_Warning, Lit(__FILE__), __LINE__, msg)
# define P_LogWarningF(fmt_lit, ...) P__LogF(P_LogLevel_Warning, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogWarningF(fmt_lit, ...) P_LogF_(P_LogLevel_Warning, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# else # else
# define P_LogWarning(msg) P__log(P_LogLevel_Warning, msg) # define P_LogWarning(msg) P_Log_(P_LogLevel_Warning, msg)
# define P_LogWarningF(fmt_lit, ...) P__LogF(P_LogLevel_Warning, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogWarningF(fmt_lit, ...) P_LogF_(P_LogLevel_Warning, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# endif # endif
#else #else
# define P_LogWarning(msg) # define P_LogWarning(msg)
@ -165,11 +165,11 @@ void P_LogStartup(String logfile_path);
#if P_LogLevel(P_LogLevel_Success) #if P_LogLevel(P_LogLevel_Success)
# if P_IncludeLogSourceLocation # if P_IncludeLogSourceLocation
# define P_LogSuccess(msg) P__log(P_LogLevel_Success, Lit(__FILE__), __LINE__, msg) # define P_LogSuccess(msg) P_Log_(P_LogLevel_Success, Lit(__FILE__), __LINE__, msg)
# define P_LogSuccessF(fmt_lit, ...) P__LogF(P_LogLevel_Success, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogSuccessF(fmt_lit, ...) P_LogF_(P_LogLevel_Success, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# else # else
# define P_LogSuccess(msg) P__log(P_LogLevel_Success, msg) # define P_LogSuccess(msg) P_Log_(P_LogLevel_Success, msg)
# define P_LogSuccessF(fmt_lit, ...) P__LogF(P_LogLevel_Success, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogSuccessF(fmt_lit, ...) P_LogF_(P_LogLevel_Success, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# endif # endif
#else #else
# define P_LogSuccess(msg) # define P_LogSuccess(msg)
@ -178,11 +178,11 @@ void P_LogStartup(String logfile_path);
#if P_LogLevel(P_LogLevel_Info) #if P_LogLevel(P_LogLevel_Info)
# if P_IncludeLogSourceLocation # if P_IncludeLogSourceLocation
# define P_LogInfo(msg) P__log(P_LogLevel_Info, Lit(__FILE__), __LINE__, msg) # define P_LogInfo(msg) P_Log_(P_LogLevel_Info, Lit(__FILE__), __LINE__, msg)
# define P_LogInfoF(fmt_lit, ...) P__LogF(P_LogLevel_Info, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogInfoF(fmt_lit, ...) P_LogF_(P_LogLevel_Info, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# else # else
# define P_LogInfo(msg) P__log(P_LogLevel_Info, msg) # define P_LogInfo(msg) P_Log_(P_LogLevel_Info, msg)
# define P_LogInfoF(fmt_lit, ...) P__LogF(P_LogLevel_Info, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogInfoF(fmt_lit, ...) P_LogF_(P_LogLevel_Info, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# endif # endif
#else #else
# define P_LogInfo(msg) # define P_LogInfo(msg)
@ -191,11 +191,11 @@ void P_LogStartup(String logfile_path);
#if P_LogLevel(P_LogLevel_Debug) #if P_LogLevel(P_LogLevel_Debug)
# if P_IncludeLogSourceLocation # if P_IncludeLogSourceLocation
# define P_LogDebug(msg) P__log(P_LogLevel_Debug, Lit(__FILE__), __LINE__, msg) # define P_LogDebug(msg) P_Log_(P_LogLevel_Debug, Lit(__FILE__), __LINE__, msg)
# define P_LogDebugF(fmt_lit, ...) P__LogF(P_LogLevel_Debug, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogDebugF(fmt_lit, ...) P_LogF_(P_LogLevel_Debug, Lit(__FILE__), __LINE__, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# else # else
# define P_LogDebug(msg) P__log(P_LogLevel_Debug, msg) # define P_LogDebug(msg) P_Log_(P_LogLevel_Debug, msg)
# define P_LogDebugF(fmt_lit, ...) P__LogF(P_LogLevel_Debug, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd) # define P_LogDebugF(fmt_lit, ...) P_LogF_(P_LogLevel_Debug, Lit(fmt_lit) , ## __VA_ARGS__, FmtEnd)
# endif # endif
#else #else
# define P_LogDebug(msg) # define P_LogDebug(msg)
@ -212,23 +212,23 @@ void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level);
/* NOTE: Calling these functions rather than using the logging macros may result in logs that are compiled regardless of log level. */ /* NOTE: Calling these functions rather than using the logging macros may result in logs that are compiled regardless of log level. */
void P__LogAppend(String msg); void P_LogAppend_(String msg);
void P__LogPanic(String msg); void P_LogPanic_(String msg);
#if P_IncludeLogSourceLocation #if P_IncludeLogSourceLocation
void P__LogFV(i32 level, String file, u32 line, String fmt, va_list args); void P_LogFV_(i32 level, String file, u32 line, String fmt, va_list args);
#else #else
void P__LogFV(i32 level, String fmt, va_list args); void P_LogFV_(i32 level, String fmt, va_list args);
#endif #endif
#if P_IncludeLogSourceLocation #if P_IncludeLogSourceLocation
void P__LogF(i32 level, String file, u32 line, String fmt, ...); void P_LogF_(i32 level, String file, u32 line, String fmt, ...);
#else #else
void P__LogF(i32 level, String fmt, ...); void P_LogF_(i32 level, String fmt, ...);
#endif #endif
#if P_IncludeLogSourceLocation #if P_IncludeLogSourceLocation
void P__log(i32 level, String file, u32 line, String msg); void P_Log_(i32 level, String file, u32 line, String msg);
#else #else
void P__log(i32 level, String msg); void P_Log_(i32 level, String msg);
#endif #endif

View File

@ -782,7 +782,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
b32 shutdown = 0; b32 shutdown = 0;
while (!shutdown) while (!shutdown)
{ {
/* Pull job from queue */ //- Pull job from queue
P_Priority job_priority = 0; P_Priority job_priority = 0;
i16 job_fiber_id = 0; i16 job_fiber_id = 0;
i32 job_id = 0; i32 job_id = 0;
@ -851,7 +851,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
} }
} }
/* Use resumed fiber if present */ //- Release old fiber if resuming a yielded fiber
if (job_fiber_id > 0) if (job_fiber_id > 0)
{ {
if (job_fiber) if (job_fiber)
@ -861,7 +861,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
job_fiber = P_W32_FiberFromId(job_fiber_id); job_fiber = P_W32_FiberFromId(job_fiber_id);
} }
/* Run fiber */ //- Run fiber
if (job_func) if (job_func)
{ {
if (!job_fiber) if (!job_fiber)
@ -895,6 +895,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
EndScratch(scratch); EndScratch(scratch);
} break; } break;
//- Fiber is waiting
case P_W32_YieldKind_Wait: case P_W32_YieldKind_Wait:
{ {
__profn("Process fiber wait"); __profn("Process fiber wait");
@ -919,6 +920,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
{ {
if (wait_time != 0) P_W32_LockTicketMutex(&wait_time_bin->lock); if (wait_time != 0) P_W32_LockTicketMutex(&wait_time_bin->lock);
{ {
//- Load and compare value at address now that wait bins are locked
b32 cancel_wait = wait_addr == 0 && wait_time == 0; b32 cancel_wait = wait_addr == 0 && wait_time == 0;
if (wait_addr != 0) if (wait_addr != 0)
{ {
@ -939,7 +941,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
{ {
if (wait_addr != 0) if (wait_addr != 0)
{ {
/* Search for wait addr list in bin */ //- Search for wait addr list in bin
P_W32_WaitList *wait_addr_list = 0; P_W32_WaitList *wait_addr_list = 0;
for (P_W32_WaitList *tmp = wait_addr_bin->first_wait_list; tmp && !wait_addr_list; tmp = tmp->next_in_bin) for (P_W32_WaitList *tmp = wait_addr_bin->first_wait_list; tmp && !wait_addr_list; tmp = tmp->next_in_bin)
{ {
@ -948,7 +950,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
wait_addr_list = tmp; wait_addr_list = tmp;
} }
} }
/* Allocate new wait addr list */ //- Allocate new wait addr list
if (!wait_addr_list) if (!wait_addr_list)
{ {
if (wait_addr_bin->first_free_wait_list) if (wait_addr_bin->first_free_wait_list)
@ -977,7 +979,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
} }
wait_addr_bin->last_wait_list = wait_addr_list; wait_addr_bin->last_wait_list = wait_addr_list;
} }
/* Insert fiber into wait addr list */ //- Insert fiber into wait addr list
job_fiber->wait_addr = (u64)wait_addr; job_fiber->wait_addr = (u64)wait_addr;
if (wait_addr_list->last_waiter) if (wait_addr_list->last_waiter)
{ {
@ -993,7 +995,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
} }
if (wait_time != 0) if (wait_time != 0)
{ {
/* Search for wait time list in bin */ //- Search for wait time list in bin
P_W32_WaitList *wait_time_list = 0; P_W32_WaitList *wait_time_list = 0;
for (P_W32_WaitList *tmp = wait_time_bin->first_wait_list; tmp && !wait_time_list; tmp = tmp->next_in_bin) for (P_W32_WaitList *tmp = wait_time_bin->first_wait_list; tmp && !wait_time_list; tmp = tmp->next_in_bin)
{ {
@ -1002,7 +1004,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
wait_time_list = tmp; wait_time_list = tmp;
} }
} }
/* Allocate new wait time list */ //- Allocate new wait time list
if (!wait_time_list) if (!wait_time_list)
{ {
if (wait_time_bin->first_free_wait_list) if (wait_time_bin->first_free_wait_list)
@ -1031,7 +1033,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
} }
wait_time_bin->last_wait_list = wait_time_list; wait_time_bin->last_wait_list = wait_time_list;
} }
/* Insert fiber into wait time list */ //- Insert fiber into wait time list
job_fiber->wait_time = wait_time; job_fiber->wait_time = wait_time;
if (wait_time_list->last_waiter) if (wait_time_list->last_waiter)
{ {
@ -1046,7 +1048,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
++wait_time_list->num_waiters; ++wait_time_list->num_waiters;
} }
/* PopStruct worker's job fiber */ //- PopStruct worker's job fiber
job_fiber = 0; job_fiber = 0;
done = 1; done = 1;
} }
@ -1056,6 +1058,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
if (wait_addr != 0) P_W32_UnlockTicketMutex(&wait_addr_bin->lock); if (wait_addr != 0) P_W32_UnlockTicketMutex(&wait_addr_bin->lock);
} break; } break;
//- Fiber is finished
case P_W32_YieldKind_Done: case P_W32_YieldKind_Done:
{ {
done = 1; done = 1;
@ -1065,7 +1068,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
} }
} }
/* Wait for job */ //- Wait for job
i64 num_jobs_in_queue = Atomic64Fetch(&pool->num_jobs_in_queue.v); i64 num_jobs_in_queue = Atomic64Fetch(&pool->num_jobs_in_queue.v);
shutdown = Atomic32Fetch(&pool->workers_shutdown.v); shutdown = Atomic32Fetch(&pool->workers_shutdown.v);
if (num_jobs_in_queue <= 0 && !shutdown) if (num_jobs_in_queue <= 0 && !shutdown)
@ -1090,7 +1093,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
} }
} }
/* Worker shutdown */ //- Worker shutdown
if (job_fiber) if (job_fiber)
{ {
P_W32_ReleaseFiber(pool, job_fiber); P_W32_ReleaseFiber(pool, job_fiber);

View File

@ -80,7 +80,7 @@ P_ExitFuncDef(ShutdownUser)
//~ Debug draw //~ Debug draw
//- Draw xform //- Draw xform
void DebugDrawXform(Xform xf, u32 color_x, u32 color_y) void DrawDebugXform(Xform xf, u32 color_x, u32 color_y)
{ {
SharedUserState *g = &shared_user_state; SharedUserState *g = &shared_user_state;
f32 thickness = 2.f; f32 thickness = 2.f;
@ -104,7 +104,7 @@ void DebugDrawXform(Xform xf, u32 color_x, u32 color_y)
} }
//- Draw movement //- Draw movement
void DebugDrawMovement(Entity *ent) void DrawDebugMovement(Entity *ent)
{ {
SharedUserState *g = &shared_user_state; SharedUserState *g = &shared_user_state;
f32 thickness = 2.f; f32 thickness = 2.f;
@ -135,7 +135,7 @@ String DebugStringFromEntity(Arena *arena, Entity *ent)
String result = ZI; String result = ZI;
result.text = PushDry(arena, u8); result.text = PushDry(arena, u8);
result.len += StringFormat(arena, Lit("[%F]"), FmtUid(ent->id.uid)).len; //result.len += StringFormat(arena, Lit("[%F]"), FmtUid(ent->id.uid)).len;
{ {
b32 transmitting = sim_ent_has_prop(ent, SEPROP_SYNC_SRC); b32 transmitting = sim_ent_has_prop(ent, SEPROP_SYNC_SRC);
b32 receiving = sim_ent_has_prop(ent, SEPROP_SYNC_DST); b32 receiving = sim_ent_has_prop(ent, SEPROP_SYNC_DST);
@ -263,7 +263,7 @@ P_LogEventCallbackFuncDef(ConsoleLogCallback, log)
} }
//- Draw console //- Draw console
void DebugDrawConsole(i32 level, b32 minimized) void DrawDebugConsole(i32 level, b32 minimized)
{ {
__prof; __prof;
SharedUserState *g = &shared_user_state; SharedUserState *g = &shared_user_state;
@ -1204,7 +1204,7 @@ void UpdateUser(P_Window *window)
if (sim_ent_has_prop(ent, SEPROP_KINEMATIC) || sim_ent_has_prop(ent, SEPROP_DYNAMIC)) if (sim_ent_has_prop(ent, SEPROP_KINEMATIC) || sim_ent_has_prop(ent, SEPROP_DYNAMIC))
{ {
DebugDrawMovement(ent); DrawDebugMovement(ent);
} }
/* Draw xform */ /* Draw xform */
@ -1212,7 +1212,7 @@ void UpdateUser(P_Window *window)
{ {
u32 color_x = Rgba32F(1, 0, 0, 0.5); u32 color_x = Rgba32F(1, 0, 0, 0.5);
u32 color_y = Rgba32F(0, 1, 0, 0.5); u32 color_y = Rgba32F(0, 1, 0, 0.5);
DebugDrawXform(xf, color_x, color_y); DrawDebugXform(xf, color_x, color_y);
} }
/* Draw AABB */ /* Draw AABB */
@ -2026,11 +2026,11 @@ void UpdateUser(P_Window *window)
#if DeveloperIsEnabled #if DeveloperIsEnabled
b32 console_minimized = !g->debug_console; b32 console_minimized = !g->debug_console;
i32 console_level = console_minimized ? P_LogLevel_Success : P_LogLevel_Debug; i32 console_level = console_minimized ? P_LogLevel_Success : P_LogLevel_Debug;
DebugDrawConsole(console_level, console_minimized); DrawDebugConsole(console_level, console_minimized);
#else #else
if (g->debug_draw) if (g->debug_draw)
{ {
DebugDrawConsole(P_LogLevel_Info, 0); DrawDebugConsole(P_LogLevel_Info, 0);
} }
#endif #endif
} }

View File

@ -270,18 +270,18 @@ P_ExitFuncDef(ShutdownUser);
//////////////////////////////// ////////////////////////////////
//~ Debug draw operations //~ Debug draw operations
void DebugDrawXform(Xform xf, u32 color_x, u32 color_y); void DrawDebugXform(Xform xf, u32 color_x, u32 color_y);
void DebugDrawMovement(Entity *ent); void DrawDebugMovement(Entity *ent);
String DebugStringFromEntity(Arena *arena, Entity *ent); String DebugStringFromEntity(Arena *arena, Entity *ent);
//////////////////////////////// ////////////////////////////////
//~ Console draw operations //~ Console draw operations
P_LogEventCallbackFuncDef(ConsoleLogCallback, log); P_LogEventCallbackFuncDef(ConsoleLogCallback, log);
void DebugDrawConsole(i32 level, b32 minimized); void DrawDebugConsole(i32 level, b32 minimized);
//////////////////////////////// ////////////////////////////////
//~ Entity sortign //~ Entity sorting
MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _); MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _);