specify platform name as argument for default downstream layer declarations

This commit is contained in:
jacob 2025-12-09 14:14:33 -06:00
parent a54b9c62c8
commit 7c1602e463
64 changed files with 423 additions and 249 deletions

View File

@ -1,7 +1,11 @@
@Layer ase @Layer ase
//////////////////////////////
//- Api //- Api
@IncludeC ase.h @IncludeC ase.h
//////////////////////////////
//- Impl //- Impl
@IncludeC ase.c @IncludeC ase.c

View File

@ -666,6 +666,24 @@
}; };
#endif #endif
////////////////////////////////////////////////////////////
//~ Arena types
#if IsLanguageC
Struct(Arena)
{
u64 pos;
u64 committed;
u64 reserved;
};
Struct(TempArena)
{
Arena *arena;
u64 start_pos;
};
#endif
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Resource types //~ Resource types
@ -775,25 +793,43 @@ Struct(SamplerStateHandle) { u32 v; };
#endif #endif
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookdecl Core api hooks //~ @hookdecl Core api
#if IsLanguageC #if IsLanguageC
//- Core hooks
StringList GetRawCommandline(void); StringList GetRawCommandline(void);
void Echo(String msg); void Echo(String msg);
b32 Panic(String msg); b32 Panic(String msg);
b32 IsRunningInDebugger(void); b32 IsRunningInDebugger(void);
i64 TimeNs(void); i64 TimeNs(void);
u32 GetNumHardwareThreads(void);
void TrueRand(String buffer); void TrueRand(String buffer);
CpuTopologyInfo GetCpuTopologyInfo(void);
#endif
////////////////////////////////////////////////////////////
//~ @hookdecl Swap
#if IsLanguageC
b32 IsSwappedIn(void);
b32 IsSwappingOut(void);
String SwappedStateFromName(Arena *arena, String name);
void WriteSwappedState(String name, String data);
#endif
////////////////////////////////////////////////////////////
//~ @hookdecl Exit
#if IsLanguageC
void OnExit(ExitFunc *func); void OnExit(ExitFunc *func);
void SignalExit(i32 code); void SignalExit(i32 code);
void ExitNow(i32 code); void ExitNow(i32 code);
#endif
////////////////////////////////////////////////////////////
//~ @hookdecl Bootstrap layers
//- Meta hooks #if IsLanguageC
void StartupLayers(void); void BootstrapLayers(void);
#endif #endif
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -4,19 +4,6 @@
#define ArenaHeaderSize 256 #define ArenaHeaderSize 256
#define ArenaBlockSize 16384 #define ArenaBlockSize 16384
Struct(Arena)
{
u64 pos;
u64 committed;
u64 reserved;
};
Struct(TempArena)
{
Arena *arena;
u64 start_pos;
};
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ State types //~ State types

View File

@ -1,20 +0,0 @@
////////////////////////////////////////////////////////////
//~ @hookdecl Swap hooks
b32 IsSwappedIn(void);
b32 IsSwappingOut(void);
String SwappedStateFromName(Arena *arena, String name);
void WriteSwappedState(String name, String data);
////////////////////////////////////////////////////////////
//~ @hookdecl Exit hooks
void OnExit(ExitFunc *func);
void SignalExit(i32 code);
void ExitNow(i32 code);
////////////////////////////////////////////////////////////
//~ @hookdecl Application defined hooks
void Startup(void);

View File

@ -22,7 +22,6 @@
# include "base_math.h" # include "base_math.h"
# include "base_rand.h" # include "base_rand.h"
# include "base_util.h" # include "base_util.h"
# include "base_entry.h"
# include "base_bitbuff.h" # include "base_bitbuff.h"
# include "base_resource.h" # include "base_resource.h"
# include "base_controller.h" # include "base_controller.h"

View File

@ -1,7 +1,7 @@
SharedResourceState shared_resource_state = ZI; SharedResourceState shared_resource_state = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void InitResourceSystem(u64 archive_strings_count, String *archive_strings) void InitResourceSystem(u64 archive_strings_count, String *archive_strings)
{ {

View File

@ -31,7 +31,7 @@ Struct(SharedResourceState)
} extern shared_resource_state; } extern shared_resource_state;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void InitResourceSystem(u64 archive_strings_count, String *archive_strings); void InitResourceSystem(u64 archive_strings_count, String *archive_strings);

View File

@ -36,7 +36,7 @@ BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookimpl Core api hooks //~ @hookimpl Core api
StringList GetRawCommandline(void) StringList GetRawCommandline(void)
{ {
@ -99,11 +99,6 @@ i64 TimeNs(void)
return result; return result;
} }
u32 GetNumHardwareThreads(void)
{
return GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
}
void TrueRand(String buffer) void TrueRand(String buffer)
{ {
BCryptGenRandom(BCRYPT_RNG_ALG_HANDLE, (u8 *)buffer.text, buffer.len, 0); BCryptGenRandom(BCRYPT_RNG_ALG_HANDLE, (u8 *)buffer.text, buffer.len, 0);
@ -171,7 +166,7 @@ CpuTopologyInfo GetCpuTopologyInfo(void)
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookimpl Swap hooks //~ @hookimpl Swap
b32 IsSwappedIn(void) b32 IsSwappedIn(void)
{ {
@ -232,7 +227,7 @@ void WriteSwappedState(String name, String data)
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookimpl Exit hooks //~ @hookimpl Exit
void OnExit(ExitFunc *func) void OnExit(ExitFunc *func)
{ {
@ -307,29 +302,33 @@ i32 W32_Main(void)
g->raw_command_line = args_list; g->raw_command_line = args_list;
} }
/* Init command line */ //////////////////////////////
//- Bootstrap
/* Bootstrap command line */
InitCmdline(); InitCmdline();
/* Init log system */ /* Bootstrap log system */
/* FIXME: Remove hardcoded log path */ /* FIXME: Remove hardcoded log path */
InitLogSystem(Lit("log.log")); InitLogSystem(Lit("log.log"));
LogInfoF("Main thread ID: %F", FmtUint(ThreadId())); LogInfoF("Main thread ID: %F", FmtUint(ThreadId()));
/* Init resources */ /* Bootstrap resource system */
{ {
W32_FindEmbeddedDataCtx ctx = ZI; W32_FindEmbeddedDataCtx ctx = ZI;
EnumResourceNamesW(0, RT_RCDATA, &W32_FindEmbeddedRcData, (LONG_PTR)&ctx); EnumResourceNamesW(0, RT_RCDATA, &W32_FindEmbeddedRcData, (LONG_PTR)&ctx);
InitResourceSystem(ctx.embedded_strings_count, ctx.embedded_strings); InitResourceSystem(ctx.embedded_strings_count, ctx.embedded_strings);
} }
//- App startup /* Bootstrap layers */
/* Startup layers */
if (!Atomic32Fetch(&g->panicking)) if (!Atomic32Fetch(&g->panicking))
{ {
StartupLayers(); BootstrapLayers();
} }
//////////////////////////////
//- Wait for exit signal
/* Wait for exit start or panic */ /* Wait for exit start or panic */
if (!Atomic32Fetch(&g->panicking)) if (!Atomic32Fetch(&g->panicking))
{ {
@ -340,7 +339,8 @@ i32 W32_Main(void)
DWORD wake = WaitForMultipleObjects(countof(handles), handles, 0, INFINITE); DWORD wake = WaitForMultipleObjects(countof(handles), handles, 0, INFINITE);
} }
//- App shutdown //////////////////////////////
//- Shutdown
/* Run exit callbacks */ /* Run exit callbacks */
if (!Atomic32Fetch(&g->panicking)) if (!Atomic32Fetch(&g->panicking))

View File

@ -1,7 +1,11 @@
@Layer collider @Layer collider
//////////////////////////////
//- Api //- Api
@IncludeC collider.h @IncludeC collider.h
//////////////////////////////
//- Impl //- Impl
@IncludeC collider.c @IncludeC collider.c

View File

@ -1,9 +1,9 @@
D_SharedState D_shared_state = ZI; D_SharedState D_shared_state = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void D_Startup(void) void D_Bootstrap(void)
{ {
D_SharedState *g = &D_shared_state; D_SharedState *g = &D_shared_state;
u32 pixel_white = 0xFFFFFFFF; u32 pixel_white = 0xFFFFFFFF;

View File

@ -107,9 +107,9 @@ Struct(D_SharedState)
} extern D_shared_state; } extern D_shared_state;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void D_Startup(void); void D_Bootstrap(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Material operations //~ Material operations

View File

@ -1,17 +1,22 @@
@Layer draw @Layer draw
//////////////////////////////
//- Dependencies //- Dependencies
@Dep base @Dep base
@Dep gpu @Dep gpu
@Dep sprite @Dep sprite
@Dep font @Dep font
@Dep collider @Dep collider
//////////////////////////////
//- Api //- Api
@IncludeC draw.h @IncludeC draw.h
//- Impl @Bootstrap D_Bootstrap
@IncludeC draw.c
//- Init //////////////////////////////
@Startup D_Startup //- Impl
@IncludeC draw.c

View File

@ -1,11 +1,17 @@
@Layer glyph_cache @Layer glyph_cache
//////////////////////////////
//- Dependencies //- Dependencies
@Dep ttf @Dep ttf
@Dep gpu @Dep gpu
//////////////////////////////
//- Api //- Api
@IncludeC glyph_cache.h @IncludeC glyph_cache.h
//////////////////////////////
//- Impl //- Impl
@IncludeC glyph_cache.c @IncludeC glyph_cache.c

View File

@ -1,24 +1,30 @@
@Layer gpu @Layer gpu
//////////////////////////////
//- Dependencies //- Dependencies
@Dep platform @Dep platform
//////////////////////////////
//- Resources
@EmbedDir GPU_Resources gpu_res
//////////////////////////////
//- Api //- Api
@IncludeC gpu_core.h @IncludeC gpu_core.h
@IncludeC gpu_shader_extras.cgh @IncludeC gpu_shader_extras.cgh
@IncludeC gpu_common.h @IncludeC gpu_common.h
@IncludeG gpu_shader_extras.cgh @IncludeG gpu_shader_extras.cgh
@IncludeG gpu_shader_extras.gh @IncludeG gpu_shader_extras.gh
@Bootstrap GPU_Bootstrap
@Bootstrap GPU_BootstrapExtra
//////////////////////////////
//- Impl //- Impl
@IncludeC gpu_common.c @IncludeC gpu_common.c
//- Dx12 impl @DefaultDownstream Win32 gpu_dx12
@DefaultWindowsImpl gpu_dx12
//- Embeds
@EmbedDir GPU_Resources gpu_res
//- Startup
@Startup GPU_Startup
@Startup GPU_StartupExtra

View File

@ -2,9 +2,9 @@ GPU_SharedUtilState GPU_shared_util_state = ZI;
ThreadLocal GPU_ArenaHandle GPU_t_perm_arena = ZI; ThreadLocal GPU_ArenaHandle GPU_t_perm_arena = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void GPU_StartupExtra(void) void GPU_BootstrapExtra(void)
{ {
GPU_SharedUtilState *g = &GPU_shared_util_state; GPU_SharedUtilState *g = &GPU_shared_util_state;

View File

@ -10,9 +10,9 @@ Struct(GPU_SharedUtilState)
extern ThreadLocal GPU_ArenaHandle GPU_t_perm_arena; extern ThreadLocal GPU_ArenaHandle GPU_t_perm_arena;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void GPU_StartupExtra(void); void GPU_BootstrapExtra(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Helpers //~ Helpers

View File

@ -502,9 +502,9 @@ Struct(GPU_Stats)
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookdecl Startup //~ @hookdecl Bootstrap
void GPU_Startup(void); void GPU_Bootstrap(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookdecl Arena //~ @hookdecl Arena

View File

@ -1,9 +1,9 @@
GPU_D12_SharedState GPU_D12_shared_state = ZI; GPU_D12_SharedState GPU_D12_shared_state = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookimpl Startup //~ @hookimpl Bootstrap
void GPU_Startup(void) void GPU_Bootstrap(void)
{ {
GPU_D12_SharedState *g = &GPU_D12_shared_state; GPU_D12_SharedState *g = &GPU_D12_shared_state;
TempArena scratch = BeginScratchNoConflict(); TempArena scratch = BeginScratchNoConflict();

View File

@ -1,7 +1,11 @@
@Layer gpu_dx12 @Layer gpu_dx12
//////////////////////////////
//- Api //- Api
@IncludeC gpu_dx12.h @IncludeC gpu_dx12.h
//////////////////////////////
//- Impl //- Impl
@IncludeC gpu_dx12.c @IncludeC gpu_dx12.c

View File

@ -1,10 +1,16 @@
@Layer json @Layer json
//////////////////////////////
//- Dependencies //- Dependencies
@Dep base @Dep base
//////////////////////////////
//- Api //- Api
@IncludeC json_core.h @IncludeC json_core.h
//////////////////////////////
//- Impl //- Impl
@IncludeC json_core.c @IncludeC json_core.c

View File

@ -58,7 +58,9 @@ LineCol LineColFromPos(String data, i64 pos)
String StringFromMetaErrors(Arena *arena, M_ErrorList errors) String StringFromMetaErrors(Arena *arena, M_ErrorList errors)
{ {
String result = ZI; TempArena scratch = BeginScratch(arena);
StringList error_strings = ZI;
for (M_Error *e = errors.first; e; e = e->next) for (M_Error *e = errors.first; e; e = e->next)
{ {
M_Token *token = e->token; M_Token *token = e->token;
@ -79,18 +81,23 @@ String StringFromMetaErrors(Arena *arena, M_ErrorList errors)
{ {
line_col = LineColFromPos(token_file_data, token_pos); line_col = LineColFromPos(token_file_data, token_pos);
} }
result = StringF(arena, String formatted = StringF(scratch.arena,
"%F:%F:%F: error: %F", "%F:%F:%F: error: %F",
FmtString(token_file), FmtString(token_file),
FmtSint(line_col.line), FmtSint(line_col.line),
FmtSint(line_col.col), FmtSint(line_col.col),
FmtString(e->msg)); FmtString(e->msg));
PushStringToList(scratch.arena, &error_strings, formatted);
} }
else else
{ {
result = StringF(arena, "error: %F", FmtString(e->msg)); PushStringToList(scratch.arena, &error_strings, StringF(scratch.arena, "error: %F", FmtString(e->msg)));
} }
} }
String result = StringFromList(arena, error_strings, Lit("\n"));
EndScratch(scratch);
return result; return result;
} }
@ -465,7 +472,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
StringList c_store_lines = ZI; StringList c_store_lines = ZI;
StringList c_shader_lines = ZI; StringList c_shader_lines = ZI;
StringList c_include_lines = ZI; StringList c_include_lines = ZI;
StringList c_startup_lines = ZI; StringList c_bootstrap_lines = ZI;
{ {
for (M_Entry *entry = build.layers_parse.first; entry->valid; entry = entry->next) for (M_Entry *entry = build.layers_parse.first; entry->valid; entry = entry->next)
{ {
@ -546,17 +553,17 @@ void BuildEntryPoint(WaveLaneCtx *lane)
M_PushError(perm, &build.c_parse.errors, entry_tok, Lit("Expected file name")); M_PushError(perm, &build.c_parse.errors, entry_tok, Lit("Expected file name"));
} }
} break; } break;
case M_EntryKind_Startup: case M_EntryKind_Bootstrap:
{ {
if (arg0_tok->valid) if (arg0_tok->valid)
{ {
String startup = arg0_tok->s; String bootstrap = arg0_tok->s;
String line = StringF(perm, " %F();", FmtString(startup)); String line = StringF(perm, " %F();", FmtString(bootstrap));
PushStringToList(perm, &c_startup_lines, line); PushStringToList(perm, &c_bootstrap_lines, line);
} }
else else
{ {
M_PushError(perm, &build.c_parse.errors, entry_tok, Lit("Expected startup function name")); M_PushError(perm, &build.c_parse.errors, entry_tok, Lit("Expected bootstrap function name"));
} }
} break; } break;
} }
@ -603,13 +610,13 @@ void BuildEntryPoint(WaveLaneCtx *lane)
PushStringToList(perm, &c_out_lines, n->s); PushStringToList(perm, &c_out_lines, n->s);
} }
} }
/* Define StartupLayers */ /* Define BootstrapLayers */
{ {
PushStringToList(perm, &c_out_lines, Lit("")); PushStringToList(perm, &c_out_lines, Lit(""));
PushStringToList(perm, &c_out_lines, Lit("//- Startup")); PushStringToList(perm, &c_out_lines, Lit("//- Bootstrap"));
PushStringToList(perm, &c_out_lines, Lit("void StartupLayers(void)")); PushStringToList(perm, &c_out_lines, Lit("void BootstrapLayers(void)"));
PushStringToList(perm, &c_out_lines, Lit("{")); PushStringToList(perm, &c_out_lines, Lit("{"));
for (StringListNode *n = c_startup_lines.first; n; n = n->next) for (StringListNode *n = c_bootstrap_lines.first; n; n = n->next)
{ {
PushStringToList(perm, &c_out_lines, n->s); PushStringToList(perm, &c_out_lines, n->s);
} }
@ -998,11 +1005,11 @@ void BuildEntryPoint(WaveLaneCtx *lane)
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookimpl Startup //~ @hookimpl Bootstrap layers
void StartupLayers(void) void BootstrapLayers(void)
{ {
OS_Startup(); OS_Bootstrap();
CpuTopologyInfo cpu_info = GetCpuTopologyInfo(); CpuTopologyInfo cpu_info = GetCpuTopologyInfo();
i32 meta_lanes_count = cpu_info.num_logical_cores - 1; i32 meta_lanes_count = cpu_info.num_logical_cores - 1;
DispatchWave(Lit("Meta"), MaxI32(meta_lanes_count, 1), BuildEntryPoint, 0); DispatchWave(Lit("Meta"), MaxI32(meta_lanes_count, 1), BuildEntryPoint, 0);

View File

@ -464,37 +464,61 @@ M_Layer M_FlattenEntries(Arena *arena, M_LayerList unflattened, StringList start
{ {
state->is_entered = 1; state->is_entered = 1;
/* Push downstream impl enters to stack */ /* Push downstream impl entries to stack */
for (M_Entry *entry = layer->first; entry->valid; entry = entry->next) for (M_Entry *entry = layer->first; entry->valid; entry = entry->next)
{ {
b32 include = (IsPlatformWindows && entry->kind == M_EntryKind_DefaultWindowsImpl); if (entry->kind == M_EntryKind_DefaultDownstream)
if (include)
{ {
M_Token *impl_token = entry->arg_tokens[0]; M_Token *platform_token = entry->arg_tokens[0];
if (impl_token->valid) M_Token *downstream_layer_token = entry->arg_tokens[1];
if (platform_token->valid && downstream_layer_token->valid)
{ {
String impl_name = impl_token->s; /* Determine platform match */
u64 hash = HashFnv64(Fnv64Basis, impl_name); b32 should_include = 0;
IterState *impl_layer_state = (IterState *)DictValueOrNilFromHash(layer_name_to_state, hash, (u64)&NilIterState);
M_Layer *impl_layer = impl_layer_state->layer;
if (impl_layer->valid)
{ {
if (!impl_layer_state->is_exited) String platform_name = platform_token->s;
if (MatchString(platform_name, Lit("Any")))
{
should_include = 1;
}
else if (MatchString(platform_name, Lit("Win32")))
{
should_include = IsPlatformWindows;
}
else
{
String err = StringF(arena, "Unknown platform \"%F\"", FmtString(platform_name));
M_PushError(arena, &result.errors, platform_token, err);
}
}
/* Include layer downstream */
if (should_include)
{
String downstream_layer_name = downstream_layer_token->s;
u64 hash = HashFnv64(Fnv64Basis, downstream_layer_name);
IterState *downstream_layer_state = (IterState *)DictValueOrNilFromHash(layer_name_to_state, hash, (u64)&NilIterState);
M_Layer *downstream_layer = downstream_layer_state->layer;
if (downstream_layer->valid)
{
if (!downstream_layer_state->is_exited)
{ {
StackNode *n = PushStruct(scratch.arena, StackNode); StackNode *n = PushStruct(scratch.arena, StackNode);
n->state = impl_layer_state; n->state = downstream_layer_state;
SllStackPush(stack, n); SllStackPush(stack, n);
} }
} }
else else
{ {
String err = StringF(arena, "Layer \"%F\" not found", FmtString(impl_name)); String err = StringF(arena, "Layer \"%F\" not found", FmtString(downstream_layer_name));
M_PushError(arena, &result.errors, impl_token, err); M_PushError(arena, &result.errors, downstream_layer_token, err);
}
} }
} }
else else
{ {
M_PushError(arena, &result.errors, entry->name_token, Lit("Expected layer argument")); M_PushError(arena, &result.errors, entry->name_token, Lit("Expected platform and layer arguments"));
} }
} }
} }
@ -505,7 +529,7 @@ M_Layer M_FlattenEntries(Arena *arena, M_LayerList unflattened, StringList start
SllStackPush(stack, stack_node); SllStackPush(stack, stack_node);
} }
/* Push upstream dep enters to stack */ /* Push upstream dep entries to stack */
for (M_Entry *entry = layer->first; entry->valid; entry = entry->next) for (M_Entry *entry = layer->first; entry->valid; entry = entry->next)
{ {
if (entry->kind == M_EntryKind_Dep) if (entry->kind == M_EntryKind_Dep)

View File

@ -76,21 +76,27 @@ Enum(M_EntryKind)
M_EntryKind_Dep, M_EntryKind_Dep,
M_EntryKind_IncludeC, M_EntryKind_IncludeC,
M_EntryKind_IncludeG, M_EntryKind_IncludeG,
M_EntryKind_DefaultWindowsImpl, M_EntryKind_DefaultDownstream,
M_EntryKind_Startup, M_EntryKind_Bootstrap,
M_EntryKind_VertexShader, M_EntryKind_VertexShader,
M_EntryKind_PixelShader, M_EntryKind_PixelShader,
M_EntryKind_ComputeShader, M_EntryKind_ComputeShader,
M_EntryKind_EmbedDir, M_EntryKind_EmbedDir,
}; };
Enum(M_PlatformKind)
{
M_PlatformKind_Any,
M_PlatformKind_Win32,
};
Global Readonly char *M_entry_kind_rules[] = { Global Readonly char *M_entry_kind_rules[] = {
[M_EntryKind_Layer] = "@Layer", [M_EntryKind_Layer] = "@Layer",
[M_EntryKind_Dep] = "@Dep", [M_EntryKind_Dep] = "@Dep",
[M_EntryKind_IncludeC] = "@IncludeC", [M_EntryKind_IncludeC] = "@IncludeC",
[M_EntryKind_IncludeG] = "@IncludeG", [M_EntryKind_IncludeG] = "@IncludeG",
[M_EntryKind_DefaultWindowsImpl] = "@DefaultWindowsImpl", [M_EntryKind_DefaultDownstream] = "@DefaultDownstream",
[M_EntryKind_Startup] = "@Startup", [M_EntryKind_Bootstrap] = "@Bootstrap",
[M_EntryKind_VertexShader] = "@VertexShader", [M_EntryKind_VertexShader] = "@VertexShader",
[M_EntryKind_PixelShader] = "@PixelShader", [M_EntryKind_PixelShader] = "@PixelShader",
[M_EntryKind_ComputeShader] = "@ComputeShader", [M_EntryKind_ComputeShader] = "@ComputeShader",

View File

@ -24,9 +24,9 @@ Struct(OS_CommandResult)
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookdecl Startup hooks //~ @hookdecl Bootstrap
void OS_Startup(void); void OS_Bootstrap(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookdecl File system operations //~ @hookdecl File system operations

View File

@ -26,9 +26,9 @@ String W32_StringFromError(Arena *arena, DWORD err)
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookimpl Startup hook //~ @hookimpl Bootstrap
void OS_Startup(void) void OS_Bootstrap(void)
{ {
} }

View File

@ -17,9 +17,9 @@
MIX_SharedState M_shared_state = ZI; MIX_SharedState M_shared_state = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void MIX_Startup(void) void MIX_Bootstrap(void)
{ {
MIX_SharedState *g = &M_shared_state; MIX_SharedState *g = &M_shared_state;
g->track_arena = AcquireArena(Gibi(64)); g->track_arena = AcquireArena(Gibi(64));

View File

@ -94,9 +94,9 @@ Struct(MIX_SharedState)
} extern M_shared_state; } extern M_shared_state;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void MIX_Startup(void); void MIX_Bootstrap(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Track operations //~ Track operations

View File

@ -1,14 +1,19 @@
@Layer mixer @Layer mixer
//////////////////////////////
//- Dependencies //- Dependencies
@Dep platform @Dep platform
@Dep sound @Dep sound
//////////////////////////////
//- Api //- Api
@IncludeC mixer.h @IncludeC mixer.h
//- Impl @Bootstrap MIX_Bootstrap
@IncludeC mixer.c
//- Startup //////////////////////////////
@Startup MIX_Startup //- Impl
@IncludeC mixer.c

View File

@ -1,7 +1,11 @@
@Layer mp3 @Layer mp3
//////////////////////////////
//- Api //- Api
@IncludeC mp3.h @IncludeC mp3.h
//- Mmf impl //////////////////////////////
@DefaultWindowsImpl mp3_mmf //- Impl
@DefaultDownstream mp3_mmf

View File

@ -1,7 +1,11 @@
@Layer mp3_mmf @Layer mp3_mmf
//////////////////////////////
//- Api //- Api
@IncludeC mp3_mmf.h @IncludeC mp3_mmf.h
//////////////////////////////
//- Impl //- Impl
@IncludeC mp3_mmf.c @IncludeC mp3_mmf.c

View File

@ -1,10 +1,16 @@
@Layer net @Layer net
//////////////////////////////
//- Dependencies //- Dependencies
@Dep platform @Dep platform
//////////////////////////////
//- Api //- Api
@IncludeC net.h @IncludeC net.h
//////////////////////////////
//- Impl //- Impl
@IncludeC net.c @IncludeC net.c

View File

@ -67,9 +67,9 @@ Enum(P_MessageBoxKind)
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookdecl Startup //~ @hookdecl Bootstrap
void P_Startup(void); void P_Bootstrap(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookdecl File system hooks //~ @hookdecl File system hooks

View File

@ -1,10 +1,13 @@
@Layer platform @Layer platform
//////////////////////////////
//- Api //- Api
@IncludeC platform.h @IncludeC platform.h
//- Win32 impl @Bootstrap P_Bootstrap
@DefaultWindowsImpl platform_win32
//- Startup //////////////////////////////
@Startup P_Startup //- Impl
@DefaultDownstream Win32 platform_win32

View File

@ -1,9 +1,9 @@
P_W32_SharedState P_W32_shared_state = ZI; P_W32_SharedState P_W32_shared_state = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookimpl Startup //~ @hookimpl Bootstrap
void P_Startup(void) void P_Bootstrap(void)
{ {
P_W32_SharedState *g = &P_W32_shared_state; P_W32_SharedState *g = &P_W32_shared_state;

View File

@ -1,7 +1,11 @@
@Layer platform_win32 @Layer platform_win32
//////////////////////////////
//- Api //- Api
@IncludeC platform_win32.h @IncludeC platform_win32.h
//////////////////////////////
//- Impl //- Impl
@IncludeC platform_win32.c @IncludeC platform_win32.c

View File

@ -1,3 +1,3 @@
#define PB_SampleRate 48000 #define PB_SampleRate 48000
void PB_Startup(void); void PB_Bootstrap(void);

View File

@ -1,14 +1,19 @@
@Layer playback @Layer playback
//////////////////////////////
//- Dependencies //- Dependencies
@Dep platform @Dep platform
@Dep mixer @Dep mixer
//////////////////////////////
//- Api //- Api
@IncludeC playback.h @IncludeC playback.h
//- Wasapi impl @Bootstrap PB_Bootstrap
@DefaultWindowsImpl playback_wasapi
//- Startup //////////////////////////////
@Startup PB_Startup //- Impl
@DefaultDownstream playback_wasapi

View File

@ -7,9 +7,9 @@
PB_WSP_SharedState PB_WSP_shared_state = ZI; PB_WSP_SharedState PB_WSP_shared_state = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void PB_Startup(void) void PB_Bootstrap(void)
{ {
PB_WSP_SharedState *g = &PB_WSP_shared_state; PB_WSP_SharedState *g = &PB_WSP_shared_state;
PB_WSP_InitializeWasapi(); PB_WSP_InitializeWasapi();

View File

@ -1,7 +1,11 @@
@Layer playback_wasapi @Layer playback_wasapi
//////////////////////////////
//- Api //- Api
@IncludeC playback_wasapi.h @IncludeC playback_wasapi.h
//////////////////////////////
//- Impl //- Impl
@IncludeC playback_wasapi.c @IncludeC playback_wasapi.c

View File

@ -1,4 +1,7 @@
@Layer pp @Layer pp
//////////////////////////////
//- Dependencies
@Dep pp_sim @Dep pp_sim
@Dep pp_vis @Dep pp_vis

View File

@ -1,13 +1,18 @@
@Layer pp_sim @Layer pp_sim
//////////////////////////////
//- Dependencies //- Dependencies
@Dep platform @Dep platform
//////////////////////////////
//- Api //- Api
@IncludeC pp_sim_core.h @IncludeC pp_sim_core.h
//- Impl @Bootstrap S_Bootstrap
@IncludeC pp_sim_core.c
//- Startup //////////////////////////////
@Startup S_Startup //- Impl
@IncludeC pp_sim_core.c

View File

@ -7,9 +7,9 @@ Readonly S_Ent S_nil_ent = {
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void S_Startup(void) void S_Bootstrap(void)
{ {
S_SharedState *shared = &S_shared_state; S_SharedState *shared = &S_shared_state;

View File

@ -242,9 +242,9 @@ Struct(S_SharedState)
} extern S_shared_state; } extern S_shared_state;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void S_Startup(void); void S_Bootstrap(void);
void S_Shutdown(void); void S_Shutdown(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -1,6 +1,8 @@
@Layer pp_vis @Layer pp_vis
//////////////////////////////
//- Dependencies //- Dependencies
@Dep gpu @Dep gpu
@Dep glyph_cache @Dep glyph_cache
@Dep platform @Dep platform
@ -8,28 +10,32 @@
@Dep ui @Dep ui
@Dep pp_sim @Dep pp_sim
//- Api //////////////////////////////
@IncludeC pp_vis_widgets.h //- Resources
@IncludeC pp_vis_shaders.cgh
@IncludeC pp_vis_draw.h
@IncludeC pp_vis_core.h
@IncludeG pp_vis_shaders.cgh
//- Impl
@IncludeC pp_vis_widgets.c
@IncludeC pp_vis_draw.c
@IncludeC pp_vis_core.c
@IncludeG pp_vis_shaders.g
//- Embeds
@EmbedDir V_Resources pp_vis_res @EmbedDir V_Resources pp_vis_res
//- Shaders
@ComputeShader V_BackdropCS @ComputeShader V_BackdropCS
@VertexShader V_DQuadVS @VertexShader V_DQuadVS
@PixelShader V_DQuadPS @PixelShader V_DQuadPS
@VertexShader V_DVertVS @VertexShader V_DVertVS
@PixelShader V_DVertPS @PixelShader V_DVertPS
//- Startup //////////////////////////////
@Startup V_Startup //- Api
@IncludeC pp_vis_widgets.h
@IncludeC pp_vis_shaders.cgh
@IncludeC pp_vis_draw.h
@IncludeC pp_vis_core.h
@IncludeG pp_vis_shaders.cgh
@Bootstrap V_Bootstrap
//////////////////////////////
//- Impl
@IncludeC pp_vis_widgets.c
@IncludeC pp_vis_draw.c
@IncludeC pp_vis_core.c
@IncludeG pp_vis_shaders.g

View File

@ -1,9 +1,9 @@
V_State V = ZI; V_State V = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void V_Startup(void) void V_Bootstrap(void)
{ {
DispatchWave(Lit("Vis"), 1, V_TickForever, 0); DispatchWave(Lit("Vis"), 1, V_TickForever, 0);
} }

View File

@ -100,9 +100,9 @@ Struct(V_State)
} extern V; } extern V;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void V_Startup(void); void V_Bootstrap(void);
void V_Shutdown(void); void V_Shutdown(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -1,6 +1,8 @@
@Layer pp_old @Layer pp_old
//////////////////////////////
//- Dependencies //- Dependencies
@Dep gpu @Dep gpu
@Dep sprite @Dep sprite
@Dep font @Dep font
@ -13,7 +15,19 @@
@Dep window @Dep window
@Dep ui @Dep ui
//////////////////////////////
//- Resources
@EmbedDir PP_Resources pp_res
@VertexShader PP_MaterialVS
@PixelShader PP_MaterialPS
@ComputeShader PP_FloodCS
@ComputeShader PP_ShadeCS
//////////////////////////////
//- Api //- Api
@IncludeC pp_sim.h @IncludeC pp_sim.h
@IncludeC pp_phys.h @IncludeC pp_phys.h
@IncludeC pp_space.h @IncludeC pp_space.h
@ -24,7 +38,12 @@
@IncludeG pp_draw.cgh @IncludeG pp_draw.cgh
@IncludeC pp.h @IncludeC pp.h
@Bootstrap PP_StartupSim
@Bootstrap PP_StartupUser
//////////////////////////////
//- Impl //- Impl
@IncludeC pp_sim.c @IncludeC pp_sim.c
@IncludeC pp_phys.c @IncludeC pp_phys.c
@IncludeC pp_space.c @IncludeC pp_space.c
@ -33,16 +52,3 @@
@IncludeC pp_widgets.c @IncludeC pp_widgets.c
@IncludeC pp.c @IncludeC pp.c
@IncludeG pp_draw.g @IncludeG pp_draw.g
//- Embeds
@EmbedDir PP_Resources pp_res
//- Shaders
@VertexShader PP_MaterialVS
@PixelShader PP_MaterialPS
@ComputeShader PP_FloodCS
@ComputeShader PP_ShadeCS
//- Startup
@Startup PP_StartupSim
@Startup PP_StartupUser

View File

@ -79,7 +79,7 @@ void PT_RunForever(WaveLaneCtx *lane)
} }
} }
void PT_Startup(void) void PT_Bootstrap(void)
{ {
DispatchWave(Lit("Proto"), 1, PT_RunForever, 0); DispatchWave(Lit("Proto"), 1, PT_RunForever, 0);
} }

View File

@ -1,22 +1,29 @@
@Layer proto @Layer proto
//////////////////////////////
//- Dependencies //- Dependencies
@Dep gpu @Dep gpu
@Dep window @Dep window
@Dep ui @Dep ui
//- Api //////////////////////////////
@IncludeC proto_shaders.h //- Resources
@IncludeG proto_shaders.h
//- Impl
@IncludeC proto.c
@IncludeG proto_shaders.g
//- Shaders
@ComputeShader PT_TestCS @ComputeShader PT_TestCS
@VertexShader PT_BlitVS @VertexShader PT_BlitVS
@PixelShader PT_BlitPS @PixelShader PT_BlitPS
//- Startup //////////////////////////////
@Startup PT_Startup //- Api
@IncludeC proto_shaders.h
@IncludeG proto_shaders.h
@Bootstrap PT_Bootstrap
//////////////////////////////
//- Impl
@IncludeC proto.c
@IncludeG proto_shaders.g

View File

@ -1,12 +1,18 @@
@Layer settings @Layer settings
//////////////////////////////
//- Dependencies //- Dependencies
@Dep base @Dep base
@Dep platform @Dep platform
@Dep json @Dep json
//////////////////////////////
//- Api //- Api
@IncludeC settings_core.h @IncludeC settings_core.h
//////////////////////////////
//- Impl //- Impl
@IncludeC settings_core.c @IncludeC settings_core.c

View File

@ -1,12 +1,18 @@
@Layer sound @Layer sound
//////////////////////////////
//- Dependencies //- Dependencies
@Dep platform @Dep platform
@Dep mp3 @Dep mp3
@Dep asset_cache @Dep asset_cache
//////////////////////////////
//- Api //- Api
@IncludeC sound.h @IncludeC sound.h
//////////////////////////////
//- Impl //- Impl
@IncludeC sound.c @IncludeC sound.c

View File

@ -1,11 +1,17 @@
@Layer sprite @Layer sprite
//////////////////////////////
//- Dependencies //- Dependencies
@Dep gpu @Dep gpu
@Dep ase @Dep ase
//////////////////////////////
//- Api //- Api
@IncludeC sprite.h @IncludeC sprite.h
//////////////////////////////
//- Impl //- Impl
@IncludeC sprite.c @IncludeC sprite.c

View File

@ -1,11 +1,17 @@
@Layer tar @Layer tar
//////////////////////////////
//- Dependencies //- Dependencies
@Dep platform @Dep platform
@Dep bitbuff @Dep bitbuff
//////////////////////////////
//- Api //- Api
@IncludeC tar.h @IncludeC tar.h
//////////////////////////////
//- Impl //- Impl
@IncludeC tar.c @IncludeC tar.c

View File

@ -22,6 +22,6 @@ Struct(TTF_Decoded)
}; };
void TTF_Startup(void); void TTF_Bootstrap(void);
TTF_Decoded TTF_Decode(Arena *arena, String encoded, f32 em_size, u32 *cache_codes, u32 cache_codes_count); TTF_Decoded TTF_Decode(Arena *arena, String encoded, f32 em_size, u32 *cache_codes, u32 cache_codes_count);

View File

@ -1,10 +1,13 @@
@Layer ttf @Layer ttf
//////////////////////////////
//- Api //- Api
@IncludeC ttf.h @IncludeC ttf.h
//- DirectWrite impl @Bootstrap TTF_Bootstrap
@DefaultWindowsImpl ttf_dwrite
//- Startup //////////////////////////////
@Startup TTF_Startup //- Impl
@DefaultDownstream Win32 ttf_dwrite

View File

@ -4,10 +4,9 @@
TTF_DW_SharedState TTF_DW_shared_state = ZI; TTF_DW_SharedState TTF_DW_shared_state = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookimpl Startup //~ @hookimpl Bootstrap
/* Call this during font system startup */ void TTF_Bootstrap(void)
void TTF_Startup(void)
{ {
TTF_DW_SharedState *g = &TTF_DW_shared_state; TTF_DW_SharedState *g = &TTF_DW_shared_state;
Assert(!g->factory); Assert(!g->factory);
@ -15,18 +14,11 @@ void TTF_Startup(void)
* 10? Need to verify. Maybe should just use a custom loader. (We're only * 10? Need to verify. Maybe should just use a custom loader. (We're only
* using a factory5 since I think WriteInMemoryFileLoader wasn't * using a factory5 since I think WriteInMemoryFileLoader wasn't
* implemented until then) */ * implemented until then) */
#if IsCompilerClang
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wlanguage-extension-token" /* for __uuidof */
#endif
HRESULT error = DWriteCreateFactory( HRESULT error = DWriteCreateFactory(
DWRITE_FACTORY_TYPE_SHARED, DWRITE_FACTORY_TYPE_SHARED,
&IID_IDWriteFactory5, &IID_IDWriteFactory5,
(void **)&g->factory (void **)&g->factory
); );
#if IsCompilerClang
# pragma clang diagnostic pop
#endif
if (error != S_OK) if (error != S_OK)
{ {
Panic(Lit("Error creating DWrite factory")); Panic(Lit("Error creating DWrite factory"));

View File

@ -1,7 +1,11 @@
@Layer ttf_dwrite @Layer ttf_dwrite
//////////////////////////////
//- Api //- Api
@IncludeC ttf_dwrite.h @IncludeC ttf_dwrite.h
//////////////////////////////
//- Impl //- Impl
@IncludeC ttf_dwrite.c @IncludeC ttf_dwrite.c

View File

@ -1,29 +1,35 @@
@Layer ui @Layer ui
//////////////////////////////
//- Dependencies //- Dependencies
@Dep gpu @Dep gpu
@Dep glyph_cache @Dep glyph_cache
@Dep window @Dep window
//- Api //////////////////////////////
@IncludeC ui_core.h //- Resources
@IncludeC ui_extras.h
@IncludeC ui_shaders.cgh
@IncludeG ui_shaders.cgh
//- Impl @EmbedDir UI_Resources ui_res
@IncludeC ui_core.c
@IncludeC ui_extras.c
@IncludeG ui_shaders.g
//- Shaders
@VertexShader UI_DRectVS @VertexShader UI_DRectVS
@PixelShader UI_DRectPS @PixelShader UI_DRectPS
@VertexShader UI_BlitVS @VertexShader UI_BlitVS
@PixelShader UI_BlitPS @PixelShader UI_BlitPS
//- Embeds //////////////////////////////
@EmbedDir UI_Resources ui_res //- Api
//- Startup @IncludeC ui_core.h
@Startup UI_Startup @IncludeC ui_extras.h
@IncludeC ui_shaders.cgh
@IncludeG ui_shaders.cgh
@Bootstrap UI_Bootstrap
//////////////////////////////
//- Impl
@IncludeC ui_core.c
@IncludeC ui_extras.c
@IncludeG ui_shaders.g

View File

@ -1,9 +1,9 @@
UI_State UI_state = ZI; UI_State UI_state = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void UI_Startup(void) void UI_Bootstrap(void)
{ {
} }

View File

@ -360,9 +360,9 @@ Struct(UI_State)
} extern UI_state; } extern UI_state;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Startup //~ Bootstrap
void UI_Startup(void); void UI_Bootstrap(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Font helpers //~ Font helpers

View File

@ -54,9 +54,9 @@ Struct(WND_Frame)
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookdecl Startup //~ @hookdecl Bootstrap
void WND_Startup(void); void WND_Bootstrap(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookdecl Command //~ @hookdecl Command

View File

@ -1,13 +1,18 @@
@Layer window @Layer window
//////////////////////////////
//- Dependencies //- Dependencies
@Dep gpu @Dep gpu
//////////////////////////////
//- Api //- Api
@IncludeC window.h @IncludeC window.h
//- Win32 impl @Bootstrap WND_Bootstrap
@DefaultWindowsImpl window_win32
//- Startup //////////////////////////////
@Startup WND_Startup //- Impl
@DefaultDownstream Win32 window_win32

View File

@ -1,9 +1,9 @@
WND_W32_SharedState WND_W32_shared_state = ZI; WND_W32_SharedState WND_W32_shared_state = ZI;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ @hookimpl Startup //~ @hookimpl Bootstrap
void WND_Startup(void) void WND_Bootstrap(void)
{ {
WND_W32_SharedState *g = &WND_W32_shared_state; WND_W32_SharedState *g = &WND_W32_shared_state;

View File

@ -1,7 +1,11 @@
@Layer window_win32 @Layer window_win32
//////////////////////////////
//- Api //- Api
@IncludeC window_win32.h @IncludeC window_win32.h
//////////////////////////////
//- Impl //- Impl
@IncludeC window_win32.c @IncludeC window_win32.c