split meta.c types into meta.h
This commit is contained in:
parent
905cb50e33
commit
74413ca702
@ -6,6 +6,7 @@
|
|||||||
AlignedStruct(WaveCtx, CachelineSize)
|
AlignedStruct(WaveCtx, CachelineSize)
|
||||||
{
|
{
|
||||||
i32 lanes_count;
|
i32 lanes_count;
|
||||||
|
void *udata;
|
||||||
|
|
||||||
/* Sync barrier */
|
/* Sync barrier */
|
||||||
Atomic32Padded sync_count;
|
Atomic32Padded sync_count;
|
||||||
@ -26,7 +27,7 @@ AlignedStruct(WaveLaneCtx, CachelineSize)
|
|||||||
i64 seen_broadcast_gen;
|
i64 seen_broadcast_gen;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void WaveLaneEntryFunc(WaveLaneCtx *lane, void *udata);
|
typedef void WaveLaneEntryFunc(WaveLaneCtx *lane);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Wave sync ops
|
//~ Wave sync ops
|
||||||
|
|||||||
@ -27,7 +27,7 @@ DWORD WINAPI W32_ThreadProc(LPVOID thread_args_vp)
|
|||||||
W32_ThreadArgs *thread_args = (W32_ThreadArgs *)thread_args_vp;
|
W32_ThreadArgs *thread_args = (W32_ThreadArgs *)thread_args_vp;
|
||||||
W32_InitCurrentThread(thread_args->name);
|
W32_InitCurrentThread(thread_args->name);
|
||||||
LogInfoF("New thread \"%F\" created with ID %F", FmtString(thread_args->name), FmtUint(ThreadId()));
|
LogInfoF("New thread \"%F\" created with ID %F", FmtString(thread_args->name), FmtUint(ThreadId()));
|
||||||
thread_args->entry(thread_args->lane, thread_args->udata);
|
thread_args->entry(thread_args->lane);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +40,7 @@ void DispatchWave(String name, u32 num_lanes, WaveLaneEntryFunc *entry, void *ud
|
|||||||
|
|
||||||
WaveCtx *wave_ctx = PushStruct(perm, WaveCtx);
|
WaveCtx *wave_ctx = PushStruct(perm, WaveCtx);
|
||||||
wave_ctx->lanes_count = num_lanes;
|
wave_ctx->lanes_count = num_lanes;
|
||||||
|
wave_ctx->udata = udata;
|
||||||
|
|
||||||
for (u32 lane_idx = 0; lane_idx < num_lanes; ++lane_idx)
|
for (u32 lane_idx = 0; lane_idx < num_lanes; ++lane_idx)
|
||||||
{
|
{
|
||||||
|
|||||||
359
src/meta/meta.c
359
src/meta/meta.c
@ -1,65 +1,7 @@
|
|||||||
/* TODO: Move decls to meta.h */
|
|
||||||
|
|
||||||
#define MetaRebuildCode 1317212284
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
//~ Default base layer compiler definitions
|
|
||||||
|
|
||||||
#ifndef IsConsoleApp
|
|
||||||
# define IsConsoleApp 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IsRtcEnabled
|
|
||||||
# define IsRtcEnabled 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IsUnoptimized
|
|
||||||
# define IsUnoptimized 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IsAsanEnabled
|
|
||||||
# define IsAsanEnabled 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IsCrtlibEnabled
|
|
||||||
# define IsCrtlibEnabled 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IsDebinfoEnabled
|
|
||||||
# define IsDebinfoEnabled 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IsDeveloperModeEnabled
|
|
||||||
# define IsDeveloperModeEnabled 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IsUnoptimized
|
|
||||||
# define IsUnoptimized 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IsTestingEnabled
|
|
||||||
# define IsTestingEnabled 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IsHotSwappingEnabled
|
|
||||||
# define IsHotSwappingEnabled 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
//~ Includes
|
|
||||||
|
|
||||||
//- Header files
|
|
||||||
#include "../base/base_inc.h"
|
|
||||||
#include "meta_os/meta_os_inc.h"
|
|
||||||
#include "meta_file/meta_file_inc.h"
|
|
||||||
#include "meta_lay.h"
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
//- Source files
|
|
||||||
#include "meta_lay.c"
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Util
|
//~ Helpers
|
||||||
|
|
||||||
void EchoLine(String msg)
|
void EchoLine(String msg)
|
||||||
{
|
{
|
||||||
@ -80,12 +22,6 @@ void EchoLineOrNothing(String msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Struct(LineCol)
|
|
||||||
{
|
|
||||||
i64 line;
|
|
||||||
i64 col;
|
|
||||||
};
|
|
||||||
|
|
||||||
LineCol LineColFromPos(String data, i64 pos)
|
LineCol LineColFromPos(String data, i64 pos)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
@ -147,9 +83,9 @@ String StringFromMetaErrors(Arena *arena, M_ErrorList errors)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Build
|
||||||
|
|
||||||
void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
void BuildEntryPoint(WaveLaneCtx *lane)
|
||||||
{
|
{
|
||||||
Arena *perm = PermArena();
|
Arena *perm = PermArena();
|
||||||
|
|
||||||
@ -230,26 +166,7 @@ void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Generate compiler params
|
//- Generate compiler params
|
||||||
|
|
||||||
Struct(CompilerParams)
|
|
||||||
{
|
|
||||||
StringList defs;
|
|
||||||
|
|
||||||
StringList warnings_msvc;
|
|
||||||
StringList warnings_clang;
|
|
||||||
StringList warnings_dxc;
|
|
||||||
|
|
||||||
StringList flags_msvc;
|
|
||||||
StringList flags_clang;
|
|
||||||
StringList flags_dxc;
|
|
||||||
|
|
||||||
StringList compiler_only_flags_msvc;
|
|
||||||
StringList compiler_only_flags_clang;
|
|
||||||
|
|
||||||
StringList linker_only_flags_msvc;
|
|
||||||
StringList linker_only_flags_clang;
|
|
||||||
};
|
|
||||||
CompilerParams cp = ZI;
|
CompilerParams cp = ZI;
|
||||||
|
|
||||||
{
|
{
|
||||||
//- Common
|
//- Common
|
||||||
{
|
{
|
||||||
@ -345,41 +262,6 @@ void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
|||||||
String c_out_file = F_GetFull(perm, StringF(perm, "%F_gen_c.c", FmtString(cmdline.leaf_layer_name)));
|
String c_out_file = F_GetFull(perm, StringF(perm, "%F_gen_c.c", FmtString(cmdline.leaf_layer_name)));
|
||||||
String gpu_out_file = F_GetFull(perm, StringF(perm, "%F_gen_gpu.hlsl", FmtString(cmdline.leaf_layer_name)));
|
String gpu_out_file = F_GetFull(perm, StringF(perm, "%F_gen_gpu.hlsl", FmtString(cmdline.leaf_layer_name)));
|
||||||
|
|
||||||
Enum(ShaderEntryKind)
|
|
||||||
{
|
|
||||||
ShaderEntryKind_VS,
|
|
||||||
ShaderEntryKind_PS,
|
|
||||||
ShaderEntryKind_CS,
|
|
||||||
};
|
|
||||||
|
|
||||||
Struct(ShaderEntry)
|
|
||||||
{
|
|
||||||
ShaderEntry *next;
|
|
||||||
ShaderEntryKind kind;
|
|
||||||
String name;
|
|
||||||
};
|
|
||||||
|
|
||||||
Struct(ArcInfoEntry)
|
|
||||||
{
|
|
||||||
ArcInfoEntry *next;
|
|
||||||
String dir_path;
|
|
||||||
String store_name;
|
|
||||||
String out_path;
|
|
||||||
};
|
|
||||||
|
|
||||||
Struct(GpuComp)
|
|
||||||
{
|
|
||||||
String output;
|
|
||||||
i32 return_code;
|
|
||||||
};
|
|
||||||
|
|
||||||
Struct(ResComp)
|
|
||||||
{
|
|
||||||
String obj_file;
|
|
||||||
String output;
|
|
||||||
i32 return_code;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ## Phase 1
|
* ## Phase 1
|
||||||
*
|
*
|
||||||
@ -409,57 +291,6 @@ void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
|||||||
|
|
||||||
/* TODO: Dispatch OS Cmds asynchronously rather than synchronously waiting on each lane */
|
/* TODO: Dispatch OS Cmds asynchronously rather than synchronously waiting on each lane */
|
||||||
|
|
||||||
Struct(BuildData)
|
|
||||||
{
|
|
||||||
M_Layer flattened;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
M_ErrorList errors;
|
|
||||||
} cgen;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
M_ErrorList errors;
|
|
||||||
ShaderEntry *first_shader_entry;
|
|
||||||
ShaderEntry *last_shader_entry;
|
|
||||||
u64 shader_entries_count;
|
|
||||||
} gpugen;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
String obj_file;
|
|
||||||
String output;
|
|
||||||
i32 return_code;
|
|
||||||
} ccomp;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
GpuComp *array;
|
|
||||||
u32 count;
|
|
||||||
} gpucomps;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
M_ErrorList errors;
|
|
||||||
ArcInfoEntry *first_arc_entry;
|
|
||||||
ArcInfoEntry *last_arc_entry;
|
|
||||||
u64 arc_entries_count;
|
|
||||||
} arcinfogen;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
ResComp *array;
|
|
||||||
u32 count;
|
|
||||||
} rescomps;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
String output;
|
|
||||||
i32 return_code;
|
|
||||||
} link;
|
|
||||||
};
|
|
||||||
|
|
||||||
BuildData *build = 0;
|
BuildData *build = 0;
|
||||||
if (lane->idx == 0)
|
if (lane->idx == 0)
|
||||||
{
|
{
|
||||||
@ -470,41 +301,27 @@ void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
|||||||
i32 ret = 0;
|
i32 ret = 0;
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Parse meta layers
|
//- Parse layers, generate final C file, generate final HLSL file, and gather resource archive info
|
||||||
|
|
||||||
if (lane->idx == 0 && !ret)
|
if (lane->idx == 0 && !ret)
|
||||||
{
|
{
|
||||||
//- Lex layers
|
//- Parse layers
|
||||||
M_TokenFileList lexed = ZI;
|
|
||||||
{
|
{
|
||||||
|
/* Lex */
|
||||||
StringList src_dirs = ZI;
|
StringList src_dirs = ZI;
|
||||||
PushStringToList(perm, &src_dirs, Lit("../src"));
|
PushStringToList(perm, &src_dirs, Lit("../src"));
|
||||||
lexed = M_TokensFromSrcDirs(perm, src_dirs);
|
M_TokenFileList lexed = M_TokensFromSrcDirs(perm, src_dirs);
|
||||||
}
|
|
||||||
|
|
||||||
//- Parse layers
|
/* Parse */
|
||||||
M_LayerList parsed = ZI;
|
M_LayerList parsed = M_LayersFromTokenFiles(perm, lexed);;
|
||||||
{
|
|
||||||
parsed = M_LayersFromTokenFiles(perm, lexed);
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Flatten layers
|
/* Flatten */
|
||||||
{
|
|
||||||
StringList starting_layer_names = ZI;
|
StringList starting_layer_names = ZI;
|
||||||
PushStringToList(perm, &starting_layer_names, cmdline.leaf_layer_name);
|
PushStringToList(perm, &starting_layer_names, cmdline.leaf_layer_name);
|
||||||
build->flattened = M_GetFlattenedEntries(perm, parsed, starting_layer_names);
|
build->flattened = M_GetFlattenedEntries(perm, parsed, starting_layer_names);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
WaveSync(lane);
|
//- Generate C file
|
||||||
if (!ret) ret = build->flattened.errors.count > 0;
|
|
||||||
|
|
||||||
//////////////////////////////
|
|
||||||
//- Generate C & HLSL files
|
|
||||||
|
|
||||||
if (lane->idx == 0 && !ret)
|
|
||||||
{
|
|
||||||
/* Generate C file */
|
|
||||||
{
|
{
|
||||||
String c_out_file = F_GetFull(perm, StringF(perm, "%F_gen_c.c", FmtString(cmdline.leaf_layer_name)));
|
String c_out_file = F_GetFull(perm, StringF(perm, "%F_gen_c.c", FmtString(cmdline.leaf_layer_name)));
|
||||||
StringList c_store_lines = ZI;
|
StringList c_store_lines = ZI;
|
||||||
@ -667,7 +484,7 @@ void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate HLSL file */
|
//- Generate HLSL file
|
||||||
{
|
{
|
||||||
/* Clear shader store */
|
/* Clear shader store */
|
||||||
OS_Mkdir(shader_store_name);
|
OS_Mkdir(shader_store_name);
|
||||||
@ -780,86 +597,12 @@ void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
|||||||
F_ClearWrite(gpu_out_file, c_out);
|
F_ClearWrite(gpu_out_file, c_out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
build->gpucomps.count = build->gpugen.shader_entries_count;
|
build->gpucomps.count = build->gpugen.shader_entries_count;
|
||||||
build->gpucomps.array = PushStructs(perm, GpuComp, build->gpucomps.count);
|
build->gpucomps.array = PushStructs(perm, GpuComp, build->gpucomps.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveSync(lane);
|
//- Generate archive info
|
||||||
if (!ret) ret = build->cgen.errors.count > 0;
|
|
||||||
if (!ret) ret = build->gpugen.errors.count > 0;
|
|
||||||
|
|
||||||
//////////////////////////////
|
|
||||||
//- Compile C & Shaders
|
|
||||||
|
|
||||||
if (!ret)
|
|
||||||
{
|
|
||||||
/* Compile C */
|
|
||||||
u64 ccomp_task_idx = 0;
|
|
||||||
if (lane->idx == WaveLaneIdxFromTaskIdx(lane, ccomp_task_idx))
|
|
||||||
{
|
|
||||||
build->ccomp.obj_file = StringF(perm, "%F_gen_c.obj", FmtString(cmdline.leaf_layer_name));
|
|
||||||
String cmd = StringF(perm,
|
|
||||||
"cl.exe /c %F -Fo:%F %F %F %F %F",
|
|
||||||
FmtString(c_out_file),
|
|
||||||
FmtString(build->ccomp.obj_file),
|
|
||||||
FmtString(StringFromList(perm, cp.flags_msvc, Lit(" "))),
|
|
||||||
FmtString(StringFromList(perm, cp.compiler_only_flags_msvc, Lit(" "))),
|
|
||||||
FmtString(StringFromList(perm, cp.warnings_msvc, Lit(" "))),
|
|
||||||
FmtString(StringFromList(perm, cp.defs, Lit(" "))));
|
|
||||||
OS_CommandResult cmd_result = OS_RunCommand(perm, cmd);
|
|
||||||
String cmd_output = TrimWhitespace(cmd_result.output);
|
|
||||||
build->ccomp.output = cmd_output;
|
|
||||||
build->ccomp.return_code = cmd_result.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compile shaders */
|
|
||||||
u32 gpucomp_idx = 0;
|
|
||||||
for (ShaderEntry *e = build->gpugen.first_shader_entry; e; e = e->next)
|
|
||||||
{
|
|
||||||
/* NOTE: Using gpucomp_idx + 1 as task index for parralelism w/ C compilation */
|
|
||||||
u64 gpucomp_task_idx = gpucomp_idx + 1;
|
|
||||||
if (lane->idx == WaveLaneIdxFromTaskIdx(lane, gpucomp_task_idx))
|
|
||||||
{
|
|
||||||
GpuComp *gpucomp = &build->gpucomps.array[gpucomp_idx];
|
|
||||||
String out_file = StringF(perm, "%F/%F", FmtString(shader_store_name), FmtString(e->name));
|
|
||||||
String target = e->kind == ShaderEntryKind_VS ? Lit("vs_6_6")
|
|
||||||
: e->kind == ShaderEntryKind_PS ? Lit("ps_6_6")
|
|
||||||
: e->kind == ShaderEntryKind_CS ? Lit("cs_6_6")
|
|
||||||
: Lit("vs_6_6");
|
|
||||||
String compile_cmd = StringF(perm,
|
|
||||||
"dxc.exe -T %F -E %F -Fo %F %F %F %F",
|
|
||||||
FmtString(target),
|
|
||||||
FmtString(e->name),
|
|
||||||
FmtString(out_file),
|
|
||||||
FmtString(gpu_out_file),
|
|
||||||
FmtString(StringFromList(perm, cp.defs, Lit(" "))),
|
|
||||||
FmtString(StringFromList(perm, cp.flags_dxc, Lit(" "))));
|
|
||||||
|
|
||||||
OS_CommandResult cmd_result = OS_RunCommand(perm, compile_cmd);
|
|
||||||
|
|
||||||
if (cmd_result.code == 0)
|
|
||||||
{
|
|
||||||
gpucomp->output = cmd_result.output;
|
|
||||||
gpucomp->return_code = cmd_result.code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++gpucomp_idx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WaveSync(lane);
|
|
||||||
if (!ret) ret = build->ccomp.return_code;
|
|
||||||
for (u32 i = 0; i < build->gpucomps.count; ++i)
|
|
||||||
{
|
|
||||||
if (!ret) ret = build->gpucomps.array[i].return_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////
|
|
||||||
//- Gather resource archive info
|
|
||||||
|
|
||||||
if (lane->idx == 0 && !ret)
|
|
||||||
{
|
{
|
||||||
/* Gather archives from embedded dirs */
|
/* Gather archives from embedded dirs */
|
||||||
for (M_Entry *entry = build->flattened.first; entry->valid; entry = entry->next)
|
for (M_Entry *entry = build->flattened.first; entry->valid; entry = entry->next)
|
||||||
@ -915,9 +658,82 @@ void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
|||||||
build->rescomps.count = build->arcinfogen.arc_entries_count;
|
build->rescomps.count = build->arcinfogen.arc_entries_count;
|
||||||
build->rescomps.array = PushStructs(perm, ResComp, build->rescomps.count);
|
build->rescomps.array = PushStructs(perm, ResComp, build->rescomps.count);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WaveSync(lane);
|
WaveSync(lane);
|
||||||
|
if (!ret) ret = build->cgen.errors.count > 0;
|
||||||
|
if (!ret) ret = build->gpugen.errors.count > 0;
|
||||||
if (!ret) ret = build->arcinfogen.errors.count > 0;
|
if (!ret) ret = build->arcinfogen.errors.count > 0;
|
||||||
|
if (!ret) ret = build->flattened.errors.count > 0;
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- Compile C & Shaders
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
u64 task_idx = 0;
|
||||||
|
|
||||||
|
//- Compile C
|
||||||
|
{
|
||||||
|
if (lane->idx == WaveLaneIdxFromTaskIdx(lane, task_idx++))
|
||||||
|
{
|
||||||
|
build->ccomp.obj_file = StringF(perm, "%F_gen_c.obj", FmtString(cmdline.leaf_layer_name));
|
||||||
|
String cmd = StringF(perm,
|
||||||
|
"cl.exe /c %F -Fo:%F %F %F %F %F",
|
||||||
|
FmtString(c_out_file),
|
||||||
|
FmtString(build->ccomp.obj_file),
|
||||||
|
FmtString(StringFromList(perm, cp.flags_msvc, Lit(" "))),
|
||||||
|
FmtString(StringFromList(perm, cp.compiler_only_flags_msvc, Lit(" "))),
|
||||||
|
FmtString(StringFromList(perm, cp.warnings_msvc, Lit(" "))),
|
||||||
|
FmtString(StringFromList(perm, cp.defs, Lit(" "))));
|
||||||
|
OS_CommandResult cmd_result = OS_RunCommand(perm, cmd);
|
||||||
|
String cmd_output = TrimWhitespace(cmd_result.output);
|
||||||
|
build->ccomp.output = cmd_output;
|
||||||
|
build->ccomp.return_code = cmd_result.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Compile shaders
|
||||||
|
{
|
||||||
|
u32 gpucomp_idx = 0;
|
||||||
|
for (ShaderEntry *e = build->gpugen.first_shader_entry; e; e = e->next)
|
||||||
|
{
|
||||||
|
if (lane->idx == WaveLaneIdxFromTaskIdx(lane, task_idx++))
|
||||||
|
{
|
||||||
|
GpuComp *gpucomp = &build->gpucomps.array[gpucomp_idx];
|
||||||
|
String out_file = StringF(perm, "%F/%F", FmtString(shader_store_name), FmtString(e->name));
|
||||||
|
String target = e->kind == ShaderEntryKind_VS ? Lit("vs_6_6")
|
||||||
|
: e->kind == ShaderEntryKind_PS ? Lit("ps_6_6")
|
||||||
|
: e->kind == ShaderEntryKind_CS ? Lit("cs_6_6")
|
||||||
|
: Lit("vs_6_6");
|
||||||
|
String compile_cmd = StringF(perm,
|
||||||
|
"dxc.exe -T %F -E %F -Fo %F %F %F %F",
|
||||||
|
FmtString(target),
|
||||||
|
FmtString(e->name),
|
||||||
|
FmtString(out_file),
|
||||||
|
FmtString(gpu_out_file),
|
||||||
|
FmtString(StringFromList(perm, cp.defs, Lit(" "))),
|
||||||
|
FmtString(StringFromList(perm, cp.flags_dxc, Lit(" "))));
|
||||||
|
|
||||||
|
OS_CommandResult cmd_result = OS_RunCommand(perm, compile_cmd);
|
||||||
|
|
||||||
|
if (cmd_result.code == 0)
|
||||||
|
{
|
||||||
|
gpucomp->output = cmd_result.output;
|
||||||
|
gpucomp->return_code = cmd_result.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++gpucomp_idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WaveSync(lane);
|
||||||
|
if (!ret) ret = build->ccomp.return_code;
|
||||||
|
for (u32 i = 0; i < build->gpucomps.count; ++i)
|
||||||
|
{
|
||||||
|
if (!ret) ret = build->gpucomps.array[i].return_code;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Generate resource archives
|
//- Generate resource archives
|
||||||
@ -927,7 +743,7 @@ void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
|||||||
u32 task_idx = 0;
|
u32 task_idx = 0;
|
||||||
for (ArcInfoEntry *entry = build->arcinfogen.first_arc_entry; entry; entry = entry->next)
|
for (ArcInfoEntry *entry = build->arcinfogen.first_arc_entry; entry; entry = entry->next)
|
||||||
{
|
{
|
||||||
if (lane->idx == WaveLaneIdxFromTaskIdx(lane, task_idx))
|
if (lane->idx == WaveLaneIdxFromTaskIdx(lane, task_idx++))
|
||||||
{
|
{
|
||||||
String dir_path = entry->dir_path;
|
String dir_path = entry->dir_path;
|
||||||
String store_name = entry->store_name;
|
String store_name = entry->store_name;
|
||||||
@ -1031,7 +847,6 @@ void BuildEntryPoint(WaveLaneCtx *lane, void *udata)
|
|||||||
F_ClearWrite(arc_path, arc_contents);
|
F_ClearWrite(arc_path, arc_contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++task_idx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveSync(lane);
|
WaveSync(lane);
|
||||||
|
|||||||
186
src/meta/meta.h
186
src/meta/meta.h
@ -0,0 +1,186 @@
|
|||||||
|
#define MetaRebuildCode 1317212284
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Base layer definitions
|
||||||
|
|
||||||
|
#ifndef IsConsoleApp
|
||||||
|
# define IsConsoleApp 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IsRtcEnabled
|
||||||
|
# define IsRtcEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IsUnoptimized
|
||||||
|
# define IsUnoptimized 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IsAsanEnabled
|
||||||
|
# define IsAsanEnabled 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IsCrtlibEnabled
|
||||||
|
# define IsCrtlibEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IsDebinfoEnabled
|
||||||
|
# define IsDebinfoEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IsDeveloperModeEnabled
|
||||||
|
# define IsDeveloperModeEnabled 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IsUnoptimized
|
||||||
|
# define IsUnoptimized 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IsTestingEnabled
|
||||||
|
# define IsTestingEnabled 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IsHotSwappingEnabled
|
||||||
|
# define IsHotSwappingEnabled 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Includes
|
||||||
|
|
||||||
|
//- Header files
|
||||||
|
#include "../base/base_inc.h"
|
||||||
|
#include "meta_os/meta_os_inc.h"
|
||||||
|
#include "meta_file/meta_file_inc.h"
|
||||||
|
#include "meta_lay.h"
|
||||||
|
|
||||||
|
//- Source files
|
||||||
|
#include "meta_lay.c"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Build types
|
||||||
|
|
||||||
|
Struct(CompilerParams)
|
||||||
|
{
|
||||||
|
StringList defs;
|
||||||
|
|
||||||
|
StringList warnings_msvc;
|
||||||
|
StringList warnings_clang;
|
||||||
|
StringList warnings_dxc;
|
||||||
|
|
||||||
|
StringList flags_msvc;
|
||||||
|
StringList flags_clang;
|
||||||
|
StringList flags_dxc;
|
||||||
|
|
||||||
|
StringList compiler_only_flags_msvc;
|
||||||
|
StringList compiler_only_flags_clang;
|
||||||
|
|
||||||
|
StringList linker_only_flags_msvc;
|
||||||
|
StringList linker_only_flags_clang;
|
||||||
|
};
|
||||||
|
|
||||||
|
Enum(ShaderEntryKind)
|
||||||
|
{
|
||||||
|
ShaderEntryKind_VS,
|
||||||
|
ShaderEntryKind_PS,
|
||||||
|
ShaderEntryKind_CS,
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(ShaderEntry)
|
||||||
|
{
|
||||||
|
ShaderEntry *next;
|
||||||
|
ShaderEntryKind kind;
|
||||||
|
String name;
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(ArcInfoEntry)
|
||||||
|
{
|
||||||
|
ArcInfoEntry *next;
|
||||||
|
String dir_path;
|
||||||
|
String store_name;
|
||||||
|
String out_path;
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(GpuComp)
|
||||||
|
{
|
||||||
|
String output;
|
||||||
|
i32 return_code;
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(ResComp)
|
||||||
|
{
|
||||||
|
String obj_file;
|
||||||
|
String output;
|
||||||
|
i32 return_code;
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(BuildData)
|
||||||
|
{
|
||||||
|
M_Layer flattened;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
M_ErrorList errors;
|
||||||
|
} cgen;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
M_ErrorList errors;
|
||||||
|
ShaderEntry *first_shader_entry;
|
||||||
|
ShaderEntry *last_shader_entry;
|
||||||
|
u64 shader_entries_count;
|
||||||
|
} gpugen;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
String obj_file;
|
||||||
|
String output;
|
||||||
|
i32 return_code;
|
||||||
|
} ccomp;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
GpuComp *array;
|
||||||
|
u32 count;
|
||||||
|
} gpucomps;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
M_ErrorList errors;
|
||||||
|
ArcInfoEntry *first_arc_entry;
|
||||||
|
ArcInfoEntry *last_arc_entry;
|
||||||
|
u64 arc_entries_count;
|
||||||
|
} arcinfogen;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ResComp *array;
|
||||||
|
u32 count;
|
||||||
|
} rescomps;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
String output;
|
||||||
|
i32 return_code;
|
||||||
|
} link;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Helper types
|
||||||
|
|
||||||
|
Struct(LineCol)
|
||||||
|
{
|
||||||
|
i64 line;
|
||||||
|
i64 col;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Helpers
|
||||||
|
|
||||||
|
void EchoLine(String msg);
|
||||||
|
void EchoLineOrNothing(String msg);
|
||||||
|
LineCol LineColFromPos(String data, i64 pos);
|
||||||
|
String StringFromMetaErrors(Arena *arena, M_ErrorList errors);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Build
|
||||||
|
|
||||||
|
void BuildEntryPoint(WaveLaneCtx *lane);
|
||||||
@ -157,7 +157,7 @@ P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Timer job
|
//~ Timer job
|
||||||
|
|
||||||
void P_W32_SyncTimerForever(WaveLaneCtx *lane, void *udata)
|
void P_W32_SyncTimerForever(WaveLaneCtx *lane)
|
||||||
{
|
{
|
||||||
P_W32_SharedState *g = &P_W32_shared_state;
|
P_W32_SharedState *g = &P_W32_shared_state;
|
||||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
|
||||||
|
|||||||
@ -103,4 +103,4 @@ P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Timer job
|
//~ Timer job
|
||||||
|
|
||||||
void P_W32_SyncTimerForever(WaveLaneCtx *lane, void *udata);
|
void P_W32_SyncTimerForever(WaveLaneCtx *lane);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
void PT_RunForever(WaveLaneCtx *lane, void *udata)
|
void PT_RunForever(WaveLaneCtx *lane)
|
||||||
{
|
{
|
||||||
GPU_ArenaHandle gpu_frame_arena = GPU_AcquireArena();
|
GPU_ArenaHandle gpu_frame_arena = GPU_AcquireArena();
|
||||||
|
|
||||||
|
|||||||
@ -101,7 +101,7 @@ WND_W32_Window *WND_W32_WindowFromHandle(WND_Handle handle)
|
|||||||
//~ Initialization
|
//~ Initialization
|
||||||
|
|
||||||
/* Win32 limitation: Window must be initialized on same thread that processes events */
|
/* Win32 limitation: Window must be initialized on same thread that processes events */
|
||||||
void WND_W32_ProcessMessagesForever(WaveLaneCtx *lane, void *udata)
|
void WND_W32_ProcessMessagesForever(WaveLaneCtx *lane)
|
||||||
{
|
{
|
||||||
WND_W32_SharedState *g = &WND_W32_shared_state;
|
WND_W32_SharedState *g = &WND_W32_shared_state;
|
||||||
WND_W32_Window *window = &g->window;
|
WND_W32_Window *window = &g->window;
|
||||||
|
|||||||
@ -77,7 +77,7 @@ WND_W32_Window *WND_W32_WindowFromHandle(WND_Handle handle);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Initialization
|
//~ Initialization
|
||||||
|
|
||||||
void WND_W32_ProcessMessagesForever(WaveLaneCtx *lane, void *udata);
|
void WND_W32_ProcessMessagesForever(WaveLaneCtx *lane);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Message processing
|
//~ Message processing
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user