meta layer progress

This commit is contained in:
jacob 2025-08-24 20:08:49 -05:00
parent 20a21d31d4
commit 93e340853c
8 changed files with 70 additions and 38 deletions

View File

@ -109,15 +109,11 @@
//~ Debug
//- Static assert
#if CompilerIsMsvc || (LanguageIsC && __STDC_VERSION__ < 202311L) || LanguageIsGpu
# if CompilerIsMsvc
#if LanguageIsC
# define StaticAssert2(cond, line, counter) struct STATIC_ASSERT_____##line##counter {int foo[(cond) ? 1 : -1];}
# define StaticAssert1(cond, line, counter) StaticAssert2(cond, line, counter)
# define StaticAssert(cond) StaticAssert1(cond, __LINE__, __COUNTER__)
#else
# define StaticAssert(cond) _Static_assert(cond, "")
# endif
#else
# define StaticAssert(cond) static_assert(cond, "")
#endif
@ -622,7 +618,7 @@ Struct(String32)
# if PlatformIsWindows
ForceInline i16 FiberId(void)
{
i16 *v = (void *)__readgsqword(32);
i16 *v = (void *)(u64)__readgsqword(32);
return *v;
}
# else

View File

@ -1,10 +1,10 @@
#if CompilerIsMsvc
#if PlatformIsWindows
////////////////////////////////
//~ Incbin
/* Find first resource with `type` and return the data in `udata`. */
b32 CALLBACK IncbinEnumerateResourceNamesFunc(HMODULE module, LPCWSTR type, LPCWSTR wstr_entry_name, LONG_PTR udata)
BOOL IncbinEnumerateResourceNamesFunc(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name, LONG_PTR udata)
{
TempArena scratch = BeginScratchNoConflict();
IncbinRcSearchParams *params = (IncbinRcSearchParams *)udata;
@ -75,4 +75,4 @@ String StringFromIncbinRcResource(IncbinRcResource *inc)
return inc->data;
}
#endif /* CompilerIsMsvc */
#endif /* PlatformIsWindows */

View File

@ -1,7 +1,7 @@
#if CompilerIsMsvc
#if PlatformIsWindows
////////////////////////////////
//~ Msvc incbin types
//~ Windows incbin types
Struct(IncbinRcSearchParams)
{
@ -29,7 +29,7 @@ Struct(IncbinRcResource)
////////////////////////////////
//~ Msvc incbin operations
b32 IncbinEnumerateResourceNamesFunc(void *module, const wchar_t *type, const wchar_t *wstr_entry_name, i64 udata);
BOOL IncbinEnumerateResourceNamesFunc(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name, LONG_PTR udata);
String StringFromIncbinRcResource(IncbinRcResource *inc);
/* NOTE: Msvc doesn't have an Inline assembler that can include binary data.
@ -43,7 +43,7 @@ String StringFromIncbinRcResource(IncbinRcResource *inc);
String StringFromIncbinRcResource(struct IncbinRcResource *inc);
#else /* CompilerIsMsvc */
#else /* PlatformIsWindows */
////////////////////////////////
//~ Clang incbin operations

View File

@ -39,8 +39,8 @@ typedef i32 FmtKind; enum
FmtKind_Hex = 0x0a3d0792,
FmtKind_Ptr = 0x0c4519e4,
FmtKind_Float = 0x04814143,
FmtKind_Uid = 0x9d1cd407,
FmtKind_Handle = 0xfead3bec,
FmtKind_Uid = 0x3d1cd407,
FmtKind_Handle = 0x6ead3bec,
FmtKind_End = 0x0ecbc5ae
};

View File

@ -30,8 +30,8 @@ b32 Panic(String msg)
u32 mb_flags = MB_SETFOREGROUND | MB_ICONERROR;
MessageBoxExA(0, msg_cstr, "Fatal error", mb_flags, 0);
}
printf(msg_cstr);
fflush(stdout);
HANDLE console_handle = GetStdHandle(STD_ERROR_HANDLE);
WriteConsoleA(console_handle, msg.text, msg.len, 0, 0);
if ((1)) /* Supress unreachable code warning */
{
ExitProcess(1);

View File

@ -876,41 +876,73 @@ i32 main(i32 argc, u8 **argv)
//- Generate compiler flags
StringList shared_compiler_flags = ZI;
StringList msvc_compiler_flags = ZI;
StringList clang_compiler_flags = ZI;
{
/* Definitions */
PushStringToList(arena, &shared_compiler_flags, Lit("DRtcIsEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("DAsanIsEnabled=0"));
PushStringToList(arena, &shared_compiler_flags, Lit("DCrtlibIsEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("DDebinfoEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("DDeveloperIsEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("DProfilingIsEnabled=0"));
PushStringToList(arena, &shared_compiler_flags, Lit("DUnoptimizedIsEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("DTestsAreEnabled=0"));
PushStringToList(arena, &shared_compiler_flags, Lit("DIncbinRawDir=\"bla\""));
//- Shared
PushStringToList(arena, &shared_compiler_flags, Lit("-DRtcIsEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("-DAsanIsEnabled=0"));
PushStringToList(arena, &shared_compiler_flags, Lit("-DCrtlibIsEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("-DDebinfoEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("-DDeveloperIsEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("-DProfilingIsEnabled=0"));
PushStringToList(arena, &shared_compiler_flags, Lit("-DUnoptimizedIsEnabled=1"));
PushStringToList(arena, &shared_compiler_flags, Lit("-DTestsAreEnabled=0"));
PushStringToList(arena, &shared_compiler_flags, Lit("-DIncbinRawDir=\"bla/\""));
/* Msvc flags */
PushStringToList(arena, &msvc_compiler_flags, Lit("Zi"));
PushStringToList(arena, &msvc_compiler_flags, Lit("DEBUG"));
PushStringToList(arena, &msvc_compiler_flags, Lit("Fo:gen.obj"));
PushStringToList(arena, &msvc_compiler_flags, Lit("Fe:pp.exe"));
PushStringToList(arena, &msvc_compiler_flags, Lit("nologo"));
//- Msvc
{
PushStringToList(arena, &msvc_compiler_flags, Lit("-Zi"));
PushStringToList(arena, &msvc_compiler_flags, Lit("-DEBUG"));
PushStringToList(arena, &msvc_compiler_flags, Lit("-Fo:gen.obj"));
PushStringToList(arena, &msvc_compiler_flags, Lit("-Fe:pp.exe"));
PushStringToList(arena, &msvc_compiler_flags, Lit("-nologo"));
}
//- Clang
{
PushStringToList(arena, &clang_compiler_flags, Lit("-std=c99"));
PushStringToList(arena, &clang_compiler_flags, Lit("-fno-finite-loops"));
PushStringToList(arena, &clang_compiler_flags, Lit("-g -gcodeview"));
PushStringToList(arena, &clang_compiler_flags, Lit("-O0"));
PushStringToList(arena, &clang_compiler_flags, Lit("-msse4.2"));
/* Warnings */
PushStringToList(arena, &clang_compiler_flags, Lit("-Wall"));
PushStringToList(arena, &clang_compiler_flags, Lit("-Wframe-larger-than=65536"));
PushStringToList(arena, &clang_compiler_flags, Lit("-Wmissing-prototypes"));
PushStringToList(arena, &clang_compiler_flags, Lit("-Wunused-variable"));
PushStringToList(arena, &clang_compiler_flags, Lit("-Wunused-but-set-variable"));
PushStringToList(arena, &clang_compiler_flags, Lit("-Wunused-parameter"));
PushStringToList(arena, &clang_compiler_flags, Lit("-Wno-initializer-overrides"));
}
}
//- Generate compiler cmds
String msvc_cmd_str = ZI;
String clang_cmd_str = ZI;
/* Msvc */
{
String flags_str = StringF(arena,
"/%F /%F",
FmtString(StringFromList(arena, shared_compiler_flags, Lit(" /"))),
FmtString(StringFromList(arena, msvc_compiler_flags, Lit(" /")))
"%F %F",
FmtString(StringFromList(arena, shared_compiler_flags, Lit(" "))),
FmtString(StringFromList(arena, msvc_compiler_flags, Lit(" ")))
);
msvc_cmd_str = StringF(arena, "\"cl\" gen.c %F", FmtString(flags_str));
}
/* Clang */
{
String flags_str = StringF(arena,
"%F %F",
FmtString(StringFromList(arena, shared_compiler_flags, Lit(" "))),
FmtString(StringFromList(arena, clang_compiler_flags, Lit(" ")))
);
clang_cmd_str = StringF(arena, "\"clang\" gen.c %F", FmtString(flags_str));
}
//- Compile C
if (ret == 0)
{
String cmd_str = msvc_cmd_str;
// String cmd_str = clang_cmd_str;
OS_CommandResult result = OS_RunCommand(arena, cmd_str);
ret = result.code;
String output = result.output;

View File

@ -1,7 +1,7 @@
/* Based on Allen Webster's dwrite rasterizer example -
* https://github.com/4th-dimention/examps */
extern TTF_DW_SharedState TTF_DW_shared_state = ZI;
TTF_DW_SharedState TTF_DW_shared_state = ZI;
////////////////////////////////
//~ Win32 libs
@ -29,7 +29,7 @@ void TTF_StartupCore(void)
HRESULT error = DWriteCreateFactory(
DWRITE_FACTORY_TYPE_SHARED,
&IID_IDWriteFactory5,
(IUnknown **)&g->factory
(void **)&g->factory
);
#if CompilerIsClang
# pragma clang diagnostic pop

View File

@ -9,6 +9,7 @@
#include <combaseapi.h>
#include <dcommon.h>
#include <initguid.h>
#include <unknwn.h>
//- GUIDs
DEFINE_GUID(IID_IDWriteFactory5, 0x958db99a, 0xbe2a, 0x4f09, 0xaf, 0x7d, 0x65, 0x18, 0x98, 0x03, 0xd1, 0xd3);
@ -135,6 +136,9 @@ static inline HRESULT IDWriteFontFace_GetDesignGlyphMe
static inline HRESULT IDWriteFontFace_GetGlyphIndices (IDWriteFontFace* this, const UINT32* codePoints, UINT32 codePointCount, UINT16* glyphIndices) { return ((HRESULT (WINAPI*)(IDWriteFontFace*, const UINT32*, UINT32, UINT16*))this->v->tbl[11])(this, codePoints, codePointCount, glyphIndices); }
static inline UINT32 IDWriteGdiInterop_Release (IDWriteGdiInterop* this) { return ((UINT32 (WINAPI*)(IDWriteGdiInterop*))this->v->tbl[2])(this); }
//- Functions
EXTERN_C HRESULT DECLSPEC_IMPORT WINAPI DWriteCreateFactory (DWRITE_FACTORY_TYPE factoryType, const GUID* iid, void** factory) WIN_NOEXCEPT;
////////////////////////////////
//~ Shared state