From ee1f720fa16837d605d3d4dc6cd72d43a4abbcc7 Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 22 Oct 2025 03:22:23 -0500 Subject: [PATCH] text reimpl --- src/app/app.c | 8 +- src/app/app.h | 6 +- src/ase/ase.c | 14 +- src/ase/ase.h | 22 +-- src/asset_cache/asset_cache.c | 10 +- src/asset_cache/asset_cache.h | 16 +-- src/base/base.h | 38 ++--- src/base/base_arena.h | 14 +- src/base/base_bitbuff.c | 38 ++--- src/base/base_bitbuff.h | 22 +-- src/base/base_buddy.c | 8 +- src/base/base_buddy.h | 6 +- src/base/base_entry.h | 6 +- src/base/base_futex.c | 8 +- src/base/base_futex.h | 12 +- src/base/base_intrinsics.h | 10 +- src/base/base_job.h | 14 +- src/base/base_math.c | 40 +++--- src/base/base_math.h | 48 +++---- src/base/base_math_gpu.h | 10 +- src/base/base_memory.c | 4 +- src/base/base_memory.h | 6 +- src/base/base_rand.c | 4 +- src/base/base_rand.h | 4 +- src/base/base_resource.c | 8 +- src/base/base_resource.h | 12 +- src/base/base_snc.c | 6 +- src/base/base_snc.h | 12 +- src/base/base_string.c | 24 ++-- src/base/base_string.h | 23 ++-- src/base/base_uid.h | 4 +- src/base/base_uni.c | 6 +- src/base/base_uni.h | 12 +- src/base/base_util.h | 12 +- src/base/base_win32/base_win32.c | 12 +- src/base/base_win32/base_win32.h | 12 +- src/base/base_win32/base_win32_job.c | 14 +- src/base/base_win32/base_win32_job.h | 20 +-- src/collider/collider.c | 24 ++-- src/collider/collider.h | 36 ++--- src/config.h | 2 +- src/draw/draw.c | 14 +- src/draw/draw.h | 22 +-- src/font/font.c | 119 ++++++++++++---- src/font/font.h | 19 ++- src/gpu/gpu.h | 40 +++--- src/gpu/gpu_dx12/gpu_dx12.c | 44 +++--- src/gpu/gpu_dx12/gpu_dx12.h | 38 ++--- src/gpu/gpu_extra.c | 6 +- src/gpu/gpu_extra.h | 10 +- src/json/json.c | 6 +- src/json/json.h | 12 +- src/meta/meta.c | 52 +++---- src/meta/meta_file/meta_file.c | 10 +- src/meta/meta_file/meta_file.h | 12 +- src/meta/meta_lay.c | 8 +- src/meta/meta_lay.h | 16 +-- src/meta/meta_os/meta_os.h | 12 +- .../meta_os/meta_os_win32/meta_os_win32.c | 10 +- .../meta_os/meta_os_win32/meta_os_win32.h | 4 +- src/mixer/mixer.c | 8 +- src/mixer/mixer.h | 14 +- src/mp3/mp3.h | 4 +- src/mp3/mp3_mmf/mp3_mmf.c | 2 +- src/mp3/mp3_mmf/mp3_mmf.h | 2 +- src/net/net.c | 18 +-- src/net/net.h | 30 ++-- src/platform/platform.h | 36 ++--- src/platform/platform_log.c | 14 +- src/platform/platform_log.h | 16 +-- src/platform/platform_win32/platform_win32.c | 34 ++--- src/platform/platform_win32/platform_win32.h | 26 ++-- .../playback_wasapi/playback_wasapi.c | 6 +- .../playback_wasapi/playback_wasapi.h | 12 +- src/pp/pp.c | 38 ++--- src/pp/pp.h | 30 ++-- src/pp/pp_draw.gpu | 12 +- src/pp/pp_draw.h | 12 +- src/pp/pp_ent.c | 30 ++-- src/pp/pp_ent.h | 36 ++--- src/pp/pp_phys.c | 16 +-- src/pp/pp_phys.h | 28 ++-- src/pp/pp_sim.c | 26 ++-- src/pp/pp_sim.h | 38 ++--- src/pp/pp_space.c | 8 +- src/pp/pp_space.h | 18 +-- src/pp/pp_step.c | 10 +- src/pp/pp_step.h | 14 +- src/prof/prof_tracy.h | 4 +- src/rendertest/rendertest.c | 2 +- src/rendertest/rendertest.h | 2 +- src/settings/settings.c | 4 +- src/sound/sound.c | 5 +- src/sound/sound.h | 4 +- src/sprite/sprite.c | 8 +- src/sprite/sprite.h | 16 +-- src/tar/tar.h | 6 +- src/ttf/ttf.h | 4 +- src/ttf/ttf.lay | 3 + src/ttf/ttf_dwrite/ttf_dwrite.c | 8 +- src/ttf/ttf_dwrite/ttf_dwrite.h | 6 +- src/ui/ui.c | 130 +++++++++++++----- src/ui/ui.h | 64 ++++++--- src/ui/ui.lay | 9 +- src/ui/ui_draw.gpu | 26 ++-- src/ui/ui_draw.h | 17 ++- src/ui/ui_extra.c | 6 +- src/ui/ui_extra.h | 4 +- src/ui/ui_flags.h | 8 -- .../ui_res/font/default.ttf} | 0 110 files changed, 1056 insertions(+), 879 deletions(-) rename src/{pp/pp_res/font/fixedsys.ttf => ui/ui_res/font/default.ttf} (100%) diff --git a/src/app/app.c b/src/app/app.c index 8ca02540..727bc1fa 100644 --- a/src/app/app.c +++ b/src/app/app.c @@ -1,6 +1,6 @@ SharedAppState shared_app_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Write directory String InitializeAppWriteDirectory(Arena *arena, String write_dir) @@ -35,7 +35,7 @@ String CatAppWritePath(Arena *arena, String filename) return CatString(arena, g->write_path, filename); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Default settings P_WindowSettings GetDefaultAppWindowSettings(P_Window *window) @@ -59,7 +59,7 @@ P_WindowSettings GetDefaultAppWindowSettings(P_Window *window) }; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Args /* TODO: Remove this and do real argument parsing */ @@ -140,7 +140,7 @@ AppArgList ParseAppArgs(Arena *arena, String args_str) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Entry point void Startup(void) diff --git a/src/app/app.h b/src/app/app.h index 3ca1fc54..40bec06f 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ App arg types Struct(AppArg) @@ -15,7 +15,7 @@ Struct(AppArgList) u64 count; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types Struct(SharedAppState) @@ -24,7 +24,7 @@ Struct(SharedAppState) String write_path; } extern shared_app_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ App functions //- Write path diff --git a/src/ase/ase.c b/src/ase/ase.c index d461c8b6..23545927 100644 --- a/src/ase/ase.c +++ b/src/ase/ase.c @@ -3,7 +3,7 @@ * DEFLATE decoder based on Handmade Hero's png parser */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Shared constants Global Readonly u32 ASE_huff_hclen_order[] = { @@ -83,7 +83,7 @@ Global Readonly u32 ASE_huff_bl_counts[][2] = { {319, 5}, }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ase bitbuff u32 ASE_PeekBits(ASE_Bitbuff *bb, u32 nbits) @@ -114,7 +114,7 @@ void ASE_SkipBits(ASE_Bitbuff *bb, u32 nbits) bb->cur_bit += nbits; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Inflate u32 ASE_ReverseBits(u32 v, u32 bit_count) @@ -401,7 +401,7 @@ void ASE_Inflate(u8 *dst, u8 *encoded) EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Error helpers void ASE_PushError(Arena *arena, ASE_ErrorList *list, String msg_src) @@ -420,7 +420,7 @@ void ASE_PushError(Arena *arena, ASE_ErrorList *list, String msg_src) ++list->count; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode helpers u32 ASE_BlendMulU8(u32 a, u32 b) @@ -482,7 +482,7 @@ void ASE_MakeDimensionsSquareish(ASE_Header *header, u32 *frames_x, u32 *frames_ } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode image ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded) @@ -777,7 +777,7 @@ abort: return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode sheet ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded) diff --git a/src/ase/ase.h b/src/ase/ase.h index 031d1c36..490204ac 100644 --- a/src/ase/ase.h +++ b/src/ase/ase.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sheet types Struct(ASE_Slice) @@ -38,7 +38,7 @@ Struct(ASE_SliceKey) ASE_SliceKey *next; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decoder result types Struct(ASE_Error) @@ -77,7 +77,7 @@ Struct(ASE_DecodedSheet) b32 ok; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Inflator types #define ASE_HuffBitCount 16 @@ -109,7 +109,7 @@ Struct(ASE_HuffDict) ASE_HuffEntry *entries; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Header types Packed(Struct(ASE_Header) @@ -146,7 +146,7 @@ Packed(Struct(ASE_FrameHeader) u32 chunks_new; }); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Image decoder types Enum(ASE_ChunkKind) @@ -210,14 +210,14 @@ Struct(Ace_Cel) Ace_Cel *next; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ase bitbuff operations u32 ASE_PeekBits(ASE_Bitbuff *bb, u32 nbits); u32 ASE_ConsumeBits(ASE_Bitbuff *bb, u32 nbits); void ASE_SkipBits(ASE_Bitbuff *bb, u32 nbits); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Inflate operations u32 ASE_ReverseBits(u32 v, u32 bit_count); @@ -225,24 +225,24 @@ ASE_HuffDict ASE_InitHuffDict(Arena *arena, u32 max_code_bits, u32 *bl_counts, u u16 ASE_DecodeHuffDict(ASE_HuffDict *huffman, ASE_Bitbuff *bb); void ASE_Inflate(u8 *dst, u8 *encoded); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Error helpers void ASE_PushError(Arena *arena, ASE_ErrorList *list, String msg_src); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode helpers u32 ASE_BlendMulU8(u32 a, u32 b); u32 ASE_Blend(u32 src, u32 dst, u8 opacity); void ASE_MakeDimensionsSquareish(ASE_Header *header, u32 *frames_x, u32 *frames_y, u64 *image_width, u64 *image_height); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode image ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode sheet ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded); diff --git a/src/asset_cache/asset_cache.c b/src/asset_cache/asset_cache.c index 903225a9..453769a5 100644 --- a/src/asset_cache/asset_cache.c +++ b/src/asset_cache/asset_cache.c @@ -2,7 +2,7 @@ AC_SharedState AC_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void AC_Startup(void) @@ -12,7 +12,7 @@ void AC_Startup(void) g->store_arena = AcquireArena(Gibi(64)); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Hash u64 AC_HashFromKey(String key) @@ -21,7 +21,7 @@ u64 AC_HashFromKey(String key) return HashFnv64(Fnv64Basis, key); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Cache void AC_RefreshDebugTable(void) @@ -150,7 +150,7 @@ AC_Asset *AC_TouchCache(String key, u64 hash, b32 *is_first_touch) return asset; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Status /* Call this once asset job has been created */ @@ -172,7 +172,7 @@ void AC_YieldOnAssetReady(AC_Asset *asset) YieldOnFence(&asset->ready_fence, 1); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Store void *AC_DataFromStore(AC_Asset *asset) diff --git a/src/asset_cache/asset_cache.h b/src/asset_cache/asset_cache.h index f8f92456..2e30de54 100644 --- a/src/asset_cache/asset_cache.h +++ b/src/asset_cache/asset_cache.h @@ -1,6 +1,6 @@ /* TODO: Remove this entire layer */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Asset types Enum(AC_Status) @@ -27,7 +27,7 @@ Struct(AC_Asset) void *store_data; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Asset store types Struct(AC_Store) @@ -38,7 +38,7 @@ Struct(AC_Store) Lock lock; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define AC_MaxAssets 1024 @@ -61,31 +61,31 @@ Struct(AC_SharedState) #endif } extern AC_shared_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void AC_Startup(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Hash u64 AC_HashFromKey(String key); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Cache operations void AC_RefreshDebugTable(void); AC_Asset *AC_GetAssetCacheSlotLocked(Lock *lock, String key, u64 hash); AC_Asset *AC_TouchCache(String key, u64 hash, b32 *is_first_touch); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Status operations void AC_MarkLoading(AC_Asset *asset); void AC_MarkReady(AC_Asset *asset, void *store_data); void AC_YieldOnAssetReady(AC_Asset *asset); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Store operations void *AC_DataFromStore(AC_Asset *asset); diff --git a/src/base/base.h b/src/base/base.h index bb2e685d..dd93e873 100644 --- a/src/base/base.h +++ b/src/base/base.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Compiler flag checks #ifndef IsConsoleApp @@ -37,7 +37,7 @@ # error Missing compile time definition for 'TestsAreEnabled' #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Machine context //- Compiler @@ -111,7 +111,7 @@ #endif #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Platform headers //- Windows headers @@ -131,7 +131,7 @@ # pragma warning(pop) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Debug //- Static assert @@ -185,7 +185,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t); # define AsanUnpoison(addr, size) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Common utility macros //- ZeroStruct initialization macro @@ -278,7 +278,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t); #define NsFromSeconds(s) ((i64)((s) * 1000000000.0)) #define SecondsFromNs(ns) ((f64)(ns) / 1000000000.0) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Linked list helper macros /* Taken from the rad debugger @@ -344,7 +344,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t); #define DllPushFront(f,l,n) DllPushFrontNPZ(0,f,l,n,next,prev) #define DllRemove(f,l,n) DllRemoveNPZ(0,f,l,n,next,prev) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Color helper macros //- Rgba 32 bit helpers @@ -369,7 +369,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t); #define Color_Orange Rgb32(0xFF, 0xA5, 0x00) #define Color_Purple Rgb32(0xFF, 0x00, 0XFF) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Intrinsic headers #if LanguageIsC @@ -389,7 +389,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t); #include /* SSE4.2 */ #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Type helper macros //- Struct @@ -449,7 +449,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t); #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Scalar types #if LanguageIsC @@ -517,7 +517,7 @@ Global const f64 *_f64_nan = (f64 *)&_f64_nan_u64; #define IsF64Nan(x) (x != x) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Atomics #if LanguageIsC @@ -576,7 +576,7 @@ ForceInline i64 Atomic64FetchAdd (Atomic64 *x, i64 a) { return #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ticket mutex #if LanguageIsC @@ -602,7 +602,7 @@ ForceInline void UnlockTicketMutex(TicketMutex *tm) } #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ String types #if LanguageIsC @@ -661,7 +661,7 @@ Struct(StringList) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource types #if LanguageIsC @@ -680,7 +680,7 @@ Struct(Resource) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Shader types #if LanguageIsC @@ -738,7 +738,7 @@ typedef uint SamplerStateRid; #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fibers # define MaxFibers 4096 @@ -752,7 +752,7 @@ StaticAssert(MaxFibers < I16Max); /* MaxFibers should fit in FiberId */ # endif #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Exit callback types #if LanguageIsC @@ -760,7 +760,7 @@ StaticAssert(MaxFibers < I16Max); /* MaxFibers should fit in FiberId */ typedef ExitFuncDef(ExitFunc); #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Api hooks #if LanguageIsC @@ -782,7 +782,7 @@ void StartupLayers(void); #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Config #include "../config.h" diff --git a/src/base/base_arena.h b/src/base/base_arena.h index 855e5f6b..036e87f2 100644 --- a/src/base/base_arena.h +++ b/src/base/base_arena.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Arena types #define ArenaHeaderSize CachelineSize @@ -24,7 +24,7 @@ Struct(TempArena) #endif }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define ScratchArenasPerCtx 2 @@ -40,7 +40,7 @@ Struct(SharedArenaCtx) FiberArenaCtx arena_contexts[MaxFibers]; } extern shared_arena_ctx; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Arena push/pop #define PushStruct(a, type) ((type *)PushBytes((a), sizeof(type), alignof(type))) @@ -110,7 +110,7 @@ Inline void *_PushDry(Arena *arena, u64 align) return ptr; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Arena management Arena *AcquireArena(u64 reserve); @@ -152,7 +152,7 @@ Inline void *ResetArena(Arena *arena) return (void *)ArenaBase(arena); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Temp arena operations Inline TempArena BeginTempArena(Arena *arena) @@ -168,7 +168,7 @@ Inline void EndTempArena(TempArena temp) PopTo(temp.arena, temp.start_pos); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fiber arena ctx operations Inline FiberArenaCtx *FiberArenaCtxFromId(i16 fiber_id) @@ -189,7 +189,7 @@ Inline FiberArenaCtx *FiberArenaCtxFromId(i16 fiber_id) #define PermArena() (FiberArenaCtxFromId(FiberId())->perm_arena) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Scratch helpers /* Any parameterized arenas in the caller's scope should be passed into this diff --git a/src/base/base_bitbuff.c b/src/base/base_bitbuff.c index 526cb8ba..e71a556f 100644 --- a/src/base/base_bitbuff.c +++ b/src/base/base_bitbuff.c @@ -1,6 +1,6 @@ /* TODO: Safety check that functions taking byte length can't overflow bit conversion (log2(num_bytes) > 61) */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Buff management BB_Buff BB_AcquireBuff(u64 arena_reserve) @@ -27,7 +27,7 @@ BB_Buff BB_BuffFromString(String s) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Writer management BB_Writer BB_WriterFromBuff(BB_Buff *bb) @@ -125,7 +125,7 @@ b32 BB_CheckWriterOverflowBits(BB_Writer *bw, u64 num_bits) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Align writer /* Align the pos to the next byte */ @@ -157,7 +157,7 @@ void BB_WriteAlignBytes(BB_Writer *bw, u64 align) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Write bits void BB_WriteUBitsNoMagic(BB_Writer *bw, u64 value, u8 num_bits) @@ -216,7 +216,7 @@ b32 BB_WriteBit(BB_Writer *bw, u8 value) return value; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Write variable length integers /* Writes a variable length unsigned integer. @@ -280,7 +280,7 @@ void BB_WriteIV(BB_Writer *bw, i64 value) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Write floating point void BB_WriteF32(BB_Writer *bw, f32 value) @@ -295,7 +295,7 @@ void BB_WriteF64(BB_Writer *bw, f64 value) BB_WriteUBits(bw, *(u64 *)&value, 64); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Write Uid void BB_WriteUid(BB_Writer *bw, Uid value) @@ -305,7 +305,7 @@ void BB_WriteUid(BB_Writer *bw, Uid value) BB_WriteUBits(bw, value.lo, 64); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Write raw data void BB_WriteString(BB_Writer *bw, String s) @@ -344,7 +344,7 @@ void BB_WriteSeekBytes(BB_Writer *bw, u64 num_bytes) bw->cur_bit += num_bits; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Writer debug #if BITBUFF_DEBUG @@ -371,7 +371,7 @@ void BB_WriteDebugMagic(BB_Writer *bw, BB_DebugMagicKind magic, u8 num_bits) } #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Reader management BB_Reader BB_ReaderFromBuff(BB_Buff *bb) @@ -456,7 +456,7 @@ b32 BB_CheckReaderOverflowBits(BB_Reader *br, u64 num_bits) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Align reader /* Align the pos to the next byte */ @@ -488,7 +488,7 @@ void BB_ReadAlignBytes(BB_Reader *br, u64 align) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Read bits u64 BB_ReadUBitsNoMagic(BB_Reader *br, u8 num_bits) @@ -549,7 +549,7 @@ u8 BB_ReadBit(BB_Reader *br) return BB_ReadUBits(br, 1); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Read variable length integer /* Read a variable length unsigned integer. @@ -613,7 +613,7 @@ i64 BB_ReadIV(BB_Reader *br) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Read floating point f32 BB_ReadF32(BB_Reader *br) @@ -630,7 +630,7 @@ f64 BB_ReadF64(BB_Reader *br) return *(f64 *)&ubits; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Read Uid Uid BB_ReadUid(BB_Reader *br) @@ -641,7 +641,7 @@ Uid BB_ReadUid(BB_Reader *br) return UID(hi, lo); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Read raw data String BB_ReadString(Arena *arena, BB_Reader *br) @@ -719,7 +719,7 @@ void BB_ReadSeekToByte(BB_Reader *br, u64 pos) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Reader debug #if BITBUFF_DEBUG @@ -757,7 +757,7 @@ void BB_ReadDebugMarker(BB_Reader *br, String name) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utils u64 BB_TwosComplimentFromUint(u64 value, u8 num_bits) @@ -780,7 +780,7 @@ i64 BB_IntFromTwosCompliment(u64 tc, u8 num_bits) return value; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Test #if BITBUFF_TEST diff --git a/src/base/base_bitbuff.h b/src/base/base_bitbuff.h index 4a310dc7..0ddb01af 100644 --- a/src/base/base_bitbuff.h +++ b/src/base/base_bitbuff.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Bitbuff types //- Buff @@ -39,7 +39,7 @@ Struct(BB_Reader) #endif }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Debug types #if BITBUFF_DEBUG @@ -61,7 +61,7 @@ Enum(BB_DebugMagicKind) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Buff management //- Growable-arena backed bitbuff @@ -71,7 +71,7 @@ void BB_ReleaseBuff(BB_Buff *bitbuff); //- Fixed-buffer backed bitbuff BB_Buff BB_BuffFromString(String s); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Writer management BB_Writer BB_WriterFromBuff(BB_Buff *bb); @@ -85,7 +85,7 @@ u8 *BB_GetWrittenRaw(BB_Writer *bw); b32 BB_CheckWriterOverflowBits(BB_Writer *bw, u64 num_bits); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Writer ops //- Align @@ -114,7 +114,7 @@ void BB_WriteString(BB_Writer *bw, String s); void BB_WriteBytes(BB_Writer *bw, String bytes); void BB_WriteSeekBytes(BB_Writer *bw, u64 num_bytes); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Writer debug #if BITBUFF_DEBUG @@ -125,7 +125,7 @@ void BB_WriteDebugMarker(BB_Writer *bw, String name); #define BB_WriteDebugMarker(bw, name) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Reader management BB_Reader BB_ReaderFromBuff(BB_Buff *bb); @@ -139,7 +139,7 @@ u64 BB_NumBytesRemaining(BB_Reader *br); b32 BB_CheckReaderOverflowBits(BB_Reader *br, u64 num_bits); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Reader ops //- Align @@ -170,7 +170,7 @@ u8 *BB_ReadBytesRaw(BB_Reader *br, u64 num_bytes); void BB_ReadSeekBytes(BB_Reader *br, u64 num_bytes); void BB_ReadSeekToByte(BB_Reader *br, u64 pos); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Reader debug #if BITBUFF_DEBUG @@ -181,13 +181,13 @@ void BB_ReadDebugMarker(BB_Reader *br, String name); #define BB_ReadDebugMarker(br, name) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utils u64 BB_TwosComplimentFromUint(u64 value, u8 num_bits); i64 BB_IntFromTwosCompliment(u64 tc, u8 num_bits); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Test #if BITBUFF_TEST diff --git a/src/base/base_buddy.c b/src/base/base_buddy.c index 1308a036..5fe2f91d 100644 --- a/src/base/base_buddy.c +++ b/src/base/base_buddy.c @@ -1,6 +1,6 @@ /* TODO: Elminiate meta arena. Just store levels in first 4096 bytes of buddy arena, and then zone header data at the beginning of each allocation. */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Buddy ctx BuddyCtx *AcquireBuddyCtx(u64 reserve) @@ -30,7 +30,7 @@ void ReleaseBuddyCtx(BuddyCtx *ctx) ReleaseArena(ctx->meta_arena); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Block acquire / release BuddyBlock *AcquireBuddyBlock(BuddyCtx *ctx, u64 size) @@ -84,7 +84,7 @@ void ReleaseBuddyBlock(BuddyBlock *block) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Block push / pop //- Push @@ -128,7 +128,7 @@ void PopBuddyBlock(BuddyCtx *ctx, BuddyLevel *level, BuddyBlock *block) ctx->first_free_block = block; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Get unused block BuddyBlock *GetUnusedBuddyBlock(BuddyCtx *ctx, BuddyLevel *level) diff --git a/src/base/base_buddy.h b/src/base/base_buddy.h index 891f7d5e..af2dc3ca 100644 --- a/src/base/base_buddy.h +++ b/src/base/base_buddy.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Buddy types //- Block @@ -35,13 +35,13 @@ Struct(BuddyCtx) BuddyBlock *first_free_block; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Buddy context operations BuddyCtx *AcquireBuddyCtx(u64 reserve); void ReleaseBuddyCtx(BuddyCtx *ctx); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Buddy block operations //- Acquire / release diff --git a/src/base/base_entry.h b/src/base/base_entry.h index 7cab32e5..d25118c2 100644 --- a/src/base/base_entry.h +++ b/src/base/base_entry.h @@ -1,17 +1,17 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Exit callback types #define ExitFuncDef(name) void name(void) typedef ExitFuncDef(ExitFunc); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Exit operations void OnExit(ExitFunc *func); void SignalExit(i32 code); void ExitNow(i32 code); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Application defined hooks void Startup(void); diff --git a/src/base/base_futex.c b/src/base/base_futex.c index e1412a96..d6e2ab31 100644 --- a/src/base/base_futex.c +++ b/src/base/base_futex.c @@ -1,6 +1,6 @@ SharedFutexState shared_futex_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void InitFutexSystem(void) @@ -8,7 +8,7 @@ void InitFutexSystem(void) SharedFutexState *g = &shared_futex_state; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State helpers FiberNeqFutexState *FiberNeqFutexStateFromId(i16 fiber_id) @@ -16,7 +16,7 @@ FiberNeqFutexState *FiberNeqFutexStateFromId(i16 fiber_id) return &shared_futex_state.fiber_neq_states[fiber_id]; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Not-equal futex operations void FutexYieldNeq(volatile void *addr, void *cmp, u8 cmp_size) @@ -171,7 +171,7 @@ void FutexWakeNeq(void *addr) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Greater-than-or-equal futex operations void FutexYieldGte(volatile void *addr, void *cmp, u8 cmp_size) diff --git a/src/base/base_futex.h b/src/base/base_futex.h index 8aa0729c..89f5f68a 100644 --- a/src/base/base_futex.h +++ b/src/base/base_futex.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Neq futex types Struct(FutexNeqList) @@ -16,7 +16,7 @@ Struct(FutexNeqListBin) FutexNeqList *first_free; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define FutexNeqBinsCount 16384 @@ -33,17 +33,17 @@ Struct(SharedFutexState) FutexNeqListBin neq_bins[FutexNeqBinsCount]; } extern shared_futex_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void InitFutexSystem(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State helpers FiberNeqFutexState *FiberNeqFutexStateFromId(i16 fiber_id); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Not-equal futex operations /* Similar to Win32 WaitOnAddress & WakeByAddressAll @@ -52,7 +52,7 @@ FiberNeqFutexState *FiberNeqFutexStateFromId(i16 fiber_id); void FutexYieldNeq(volatile void *addr, void *cmp, u8 cmp_size); void FutexWakeNeq(void *addr); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Greater-than-or-equal futex operations /* Similar to Win32 WaitOnAddress & WakeByAddressAll diff --git a/src/base/base_intrinsics.h b/src/base/base_intrinsics.h index eb0f3213..563af523 100644 --- a/src/base/base_intrinsics.h +++ b/src/base/base_intrinsics.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sqrt intrinsics Inline f32 IxSqrtF32(f32 f) @@ -22,7 +22,7 @@ Inline f32 IxRsqrtF32(f32 f) return _mm_cvtss_f32(n); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Round intrinsics Inline i32 IxRoundF32ToI32(f32 f) @@ -45,7 +45,7 @@ Inline f64 IxRoundF64ToF64(f64 f) return _mm_cvtsd_f64(_mm_round_sd(_mm_setzero_pd(), _mm_set_sd(f), _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Floor intrinsics Inline i32 IxFloorF32ToI32(f32 f) @@ -68,7 +68,7 @@ Inline f64 IxFloorF64ToF64(f64 f) return _mm_cvtsd_f64(_mm_floor_sd(_mm_setzero_pd(), _mm_set_sd(f))); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ceil intrinsics Inline i32 IxCeilF32ToI32(f32 f) @@ -91,7 +91,7 @@ Inline f64 IxCeilF64ToF64(f64 f) return _mm_cvtsd_f64(_mm_ceil_sd(_mm_setzero_pd(), _mm_set_sd(f))); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Truncate intrinsics Inline f32 IxTruncF32ToF32(f32 f) diff --git a/src/base/base_job.h b/src/base/base_job.h index 0e1b15e2..e5af11f5 100644 --- a/src/base/base_job.h +++ b/src/base/base_job.h @@ -1,9 +1,9 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Opaque types Struct(Job); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Job pool types /* Job pools contain worker threads with their own thread priorities @@ -32,7 +32,7 @@ Enum(JobPool) JobPool_Count }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Job types typedef void JobFunc(void *, i32); @@ -78,18 +78,18 @@ Struct(Job) void *sig; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Init void InitJobSystem(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Fiber suspend/resume operations void SuspendFiber(void); void ResumeFibers(i16 fiber_ids_count, i16 *fiber_ids); /* NOTE: Must only be called on fibers suspended via SuspendFiber */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Job declaration operations #define EmptySig { i32 _; } @@ -102,7 +102,7 @@ void ResumeFibers(i16 fiber_ids_count, i16 *fiber_ids); /* NOTE: Must only be c #define JobDef(job, sig_arg, id_arg) void job(job##_Sig *sig_arg, i32 id_arg) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Job dispatch operations /* RunJob example usage: diff --git a/src/base/base_math.c b/src/base/base_math.c index 993c983d..338c0f73 100644 --- a/src/base/base_math.c +++ b/src/base/base_math.c @@ -1,6 +1,6 @@ /* Math functions are default 32 bit (f32, i32, etc) unless specified */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Min / max //- Min @@ -31,7 +31,7 @@ u64 ClampU64(u64 v, u64 min, u64 max) { return v < min ? min : v > max ? max : v i64 ClampI64(i64 v, i64 min, i64 max) { return v < min ? min : v > max ? max : v; } f64 ClampF64(f64 v, f64 min, f64 max) { return v < min ? min : v > max ? max : v; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Rounding ops //- Round @@ -108,7 +108,7 @@ f64 TruncF64(f64 f) return IxTruncF64ToF64(f); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fmod f32 ModF32(f32 x, f32 m) @@ -121,7 +121,7 @@ f64 ModF64(f64 x, f64 m) return x - m * TruncF64(x / m); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Floating point sign f32 AbsF32(f32 f) @@ -158,7 +158,7 @@ i64 SignF64(f64 f) return 1 + -((i64)(sign_bit << 1)); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ U64 pow /* Taken from https://gist.github.com/orlp/3551590 */ @@ -254,7 +254,7 @@ u64 PowU64(u64 base, u8 exp) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Align up u64 AlignU64Pow2(u64 x) @@ -274,7 +274,7 @@ u64 AlignU64Pow2(u64 x) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Logn /* Based on FreeBSD's implementation @@ -369,7 +369,7 @@ f32 LnF32(f32 x) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Exp /* Based on FreeBSD's implementation @@ -481,7 +481,7 @@ f32 ExpF32(f32 x) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Pow f32 PowF32(f32 a, f32 b) @@ -499,7 +499,7 @@ f32 PowF32(f32 a, f32 b) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sqrt f32 SqrtF32(f32 x) @@ -517,7 +517,7 @@ f32 RSqrtF32(f32 x) return IxRsqrtF32(x); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Trig /* Functions based on Cephes implementation (https://www.netlib.org/cephes/): @@ -745,7 +745,7 @@ f32 ArcCosF32(f32 x) return (Pi / 2.0f) - ArcTan2F32(x, SqrtF32(1.0f - (x * x))); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Angle unwind /* Returns angle in range [-Pi, Pi] */ @@ -755,7 +755,7 @@ f32 UnwindAngleF32(f32 a) return ModF32(2.0f * d, Tau) - d; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Float lerp f32 LerpF32(f32 val0, f32 val1, f32 t) @@ -774,7 +774,7 @@ f32 LerpAngleF32(f32 a, f32 b, f32 t) return a + diff * t; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Int lerp i32 LerpI32(i32 val0, i32 val1, f32 t) @@ -789,7 +789,7 @@ i64 LerpI64(i64 val0, i64 val1, f64 t) return val0 + RoundF64ToI64(((f64)(val1 - val0) * t)); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Vec2 operations b32 IsVec2Zero(Vec2 a) @@ -1010,7 +1010,7 @@ Vec2 SlerpVec2(Vec2 val0, Vec2 val1, f32 t) return MulVec2(Vec2FromAngle(rot), len); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Vec2I32 Operations b32 EqVec2I32(Vec2I32 a, Vec2I32 b) @@ -1033,7 +1033,7 @@ Vec2I32 SubVec2I32(Vec2I32 a, Vec2I32 b) return VEC2I32(a.x - b.x, a.y - b.y); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Xform operations b32 EqXform(Xform xf1, Xform xf2) @@ -1270,7 +1270,7 @@ Vec2 ScaleFromXform(Xform xf) return VEC2(Vec2Len(xf.bx), det_sign * Vec2Len(xf.by)); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Quad operations Quad QuadFromRect(Rect rect) @@ -1346,7 +1346,7 @@ Quad FloorQuad(Quad quad) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Spring operations /* https://box2d.org/files/ErinCatto_SoftConstraints_GDC2011.pdf */ @@ -1372,7 +1372,7 @@ SoftSpring MakeSpring(f32 hertz, f32 damping_ratio, f32 dt) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mat4x4 operations Mat4x4 Mat4x4FromXform(Xform xf) diff --git a/src/base/base_math.h b/src/base/base_math.h index 57d03e2e..a8d837db 100644 --- a/src/base/base_math.h +++ b/src/base/base_math.h @@ -4,7 +4,7 @@ #define Tau ((f32)6.28318530717958647693) #define GoldenRatio ((f32)1.61803398874989484820) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Axis types Enum(Axis) @@ -17,7 +17,7 @@ Enum(Axis) Axis_CountXYZ = 3, }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Vector types #define VEC2(x, y) (Vec2) { (x), (y) } @@ -62,7 +62,7 @@ Struct(Vec4Array) u64 count; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Xform types Struct(Xform) @@ -80,7 +80,7 @@ Struct(Trs) f32 r; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Rect types Struct(Rect) { @@ -98,14 +98,14 @@ Struct(ClipRect) Vec2 p0, p1; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Axis aligned bounding box types Struct(Aabb) { Vec2 p0, p1; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Quad types Struct(Quad) { @@ -116,7 +116,7 @@ Struct(Quad) { }; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Spring types Struct(SoftSpring) @@ -126,7 +126,7 @@ Struct(SoftSpring) f32 impulse_scale; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mat4x4 types Struct(Mat4x4) @@ -138,7 +138,7 @@ Struct(Mat4x4) }; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Min / max //- Min @@ -169,7 +169,7 @@ u64 ClampU64(u64 v, u64 min, u64 max); i64 ClampI64(i64 v, i64 min, i64 max); f64 ClampF64(f64 v, f64 min, f64 max); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Rounding ops //- Round @@ -194,13 +194,13 @@ i64 CeilF64ToI64(f64 f); f32 TruncF32(f32 f); f64 TruncF64(f64 f); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fmod f32 ModF32(f32 x, f32 m); f64 ModF64(f64 x, f64 m); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Abs f32 AbsF32(f32 f); @@ -210,7 +210,7 @@ u64 AbsI64(i64 v); i32 SignF32(f32 f); i64 SignF64(f64 f); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Exponential ops u64 PowU64(u64 base, u8 exp); @@ -222,7 +222,7 @@ f32 SqrtF32(f32 x); f64 SqrtF64(f64 x); f32 RSqrtF32(f32 x); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Trig f32 ReduceToPio4(f32 x, i32 *octant_out); @@ -235,26 +235,26 @@ f32 ArcTan2F32(f32 y, f32 x); f32 ArcSinF32(f32 x); f32 ArcCosF32(f32 x); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Angle unwind /* Returns angle in range [-Pi, Pi] */ f32 UnwindAngleF32(f32 a); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Float lerp f32 LerpF32(f32 val0, f32 val1, f32 t); f64 LerpF64(f64 val0, f64 val1, f64 t); f32 LerpAngleF32(f32 a, f32 b, f32 t); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Int lerp i32 LerpI32(i32 val0, i32 val1, f32 t); i64 LerpI64(i64 val0, i64 val1, f64 t); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Vec2 operations #define Vec2FromVec2I32(v) VEC2((v).x, (v).y) @@ -311,7 +311,7 @@ Vec2 ClosestPointFromRay(Vec2 ray_pos, Vec2 ray_dir_norm, Vec2 p); Vec2 LerpVec2(Vec2 val0, Vec2 val1, f32 t); Vec2 SlerpVec2(Vec2 val0, Vec2 val1, f32 t); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Vec2I32 Operations b32 EqVec2I32(Vec2I32 a, Vec2I32 b); @@ -319,7 +319,7 @@ Vec2I32 NegVec2I32(Vec2I32 a); Vec2I32 AddVec2I32(Vec2I32 a, Vec2I32 b); Vec2I32 SubVec2I32(Vec2I32 a, Vec2I32 b); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Xform operations b32 EqXform(Xform xf1, Xform xf2); @@ -374,14 +374,14 @@ Vec2 ScaleFromXform(Xform xf); //- Trs #define TRS(...) ((Trs) { .t = VEC2(0,0), .s = VEC2(1, 1), .r = 0, __VA_ARGS__ }) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Rect operations #define RectFromScalar(_x, _y, _width, _height) (Rect) { .x = (_x), .y = (_y), .width = (_width), .height = (_height) } #define RectFromVec2(_pos, _size) (Rect) { .pos = (_pos), .size = (_size) } #define AllClipped ((ClipRect) { { 0.0f, 0.0f }, { 1.0f, 1.0f } }) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Quad operations #define UnitSquareQuad (Quad) { .p0 = VEC2(0, 0), .p1 = VEC2(0, 1), .p2 = VEC2(1, 1), .p3 = VEC2(1, 0) } @@ -395,12 +395,12 @@ Quad ScaleQuad(Quad q, f32 s); Quad RoundQuad(Quad quad); Quad FloorQuad(Quad quad); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Spring operations SoftSpring MakeSpring(f32 hertz, f32 damping_ratio, f32 dt); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mat4x4 operations Mat4x4 Mat4x4FromXform(Xform xf); diff --git a/src/base/base_math_gpu.h b/src/base/base_math_gpu.h index 16dd8ae7..2c80bd5d 100644 --- a/src/base/base_math_gpu.h +++ b/src/base/base_math_gpu.h @@ -1,11 +1,11 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Gpu math constants #define Pi ((f32)3.14159265358979323846) #define Tau ((f32)6.28318530717958647693) #define GoldenRatio ((f32)1.61803398874989484820) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Gpu math types typedef float2 Vec2; @@ -24,7 +24,7 @@ typedef float4 Aabb; typedef float4 Quad; typedef float4x4 Mat4x4; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Integer -> float Vec4 Vec4NormFromU32(u32 v) @@ -37,7 +37,7 @@ Vec4 Vec4NormFromU32(u32 v) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Srgb -> linear /* Linear color from normalized sRGB */ @@ -52,7 +52,7 @@ Vec4 LinearFromSrgbU32(u32 srgb32) return LinearFromSrgbVec4(Vec4NormFromU32(srgb32)); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ndc helpers Vec2 NdcFromViewport(Vec2 viewport_size, Vec2 viewport_coords) diff --git a/src/base/base_memory.c b/src/base/base_memory.c index 17236419..1f2d9d46 100644 --- a/src/base/base_memory.c +++ b/src/base/base_memory.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 memory allocation #if PlatformIsWindows @@ -44,7 +44,7 @@ void SetMemoryReadWrite(void *address, u64 size) # error Memory allocation not implemented for this platform #endif /* PlatformIsWindows */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Crtlib mem op stubs #if !CrtlibIsEnabled diff --git a/src/base/base_memory.h b/src/base/base_memory.h index d77a6958..f1ad9f94 100644 --- a/src/base/base_memory.h +++ b/src/base/base_memory.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Memory allocation //- Reserve @@ -13,7 +13,7 @@ void DecommitMemory(void *address, u64 size); void SetMemoryReadonly(void *address, u64 size); void SetMemoryReadWrite(void *address, u64 size); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Memory operations //- Wrappers @@ -28,7 +28,7 @@ void SetMemoryReadWrite(void *address, u64 size); #define SetBytes(dst, c, count) memset(dst, c, count) #define CmpBytes(p1, p2, count) memcmp(p1, p2, count) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Crtlib stubs #if CrtlibIsEnabled diff --git a/src/base/base_rand.c b/src/base/base_rand.c index 05c6fb13..db708a7b 100644 --- a/src/base/base_rand.c +++ b/src/base/base_rand.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Stateful randomness u64 RandU64FromState(RandState *state) @@ -17,7 +17,7 @@ f64 RandF64FromState(RandState *state, f64 range_start, f64 range_end) return range_start + (range_end - range_start) * ((f64)(RandU64FromState(state) % RandMaxF64) / (f64)RandMaxF64); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Seeded randomness /* Based on Jon Maiga's "mx3" diff --git a/src/base/base_rand.h b/src/base/base_rand.h index c2c79cb8..35c585b9 100644 --- a/src/base/base_rand.h +++ b/src/base/base_rand.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Rand types Struct(RandState) @@ -10,7 +10,7 @@ Struct(RandState) /* TODO: Use a value that gives good precision when dividing into range 0 -> 1 */ #define RandMaxF64 U64Max -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Rand operations //- Stateful randomness diff --git a/src/base/base_resource.c b/src/base/base_resource.c index d22e6a60..67ed10b3 100644 --- a/src/base/base_resource.c +++ b/src/base/base_resource.c @@ -1,6 +1,6 @@ SharedResourceState shared_resource_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void InitResourceSystem(u64 archive_strings_count, String *archive_strings) @@ -41,7 +41,7 @@ void InitResourceSystem(u64 archive_strings_count, String *archive_strings) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource helpers b32 IsResourceNil(Resource resource) @@ -56,7 +56,7 @@ Resource ResourceFromStore(ResourceStore *store, String name) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource cache operations ResourceEntry *ResourceEntryFromHash(u64 hash) @@ -75,7 +75,7 @@ ResourceEntry *ResourceEntryFromHash(u64 hash) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource operations String DataFromResource(Resource resource) diff --git a/src/base/base_resource.h b/src/base/base_resource.h index 71ae39db..0c859331 100644 --- a/src/base/base_resource.h +++ b/src/base/base_resource.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource cache types Struct(ResourceEntry) @@ -17,7 +17,7 @@ Struct(ResourceEntryBin) ResourceEntry *last; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define NumResourceEntryBins 4096 @@ -30,23 +30,23 @@ Struct(SharedResourceState) ResourceEntryBin bins[NumResourceEntryBins]; } extern shared_resource_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void InitResourceSystem(u64 archive_strings_count, String *archive_strings); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource operations b32 IsResourceNil(Resource resource); Resource ResourceFromStore(ResourceStore *store, String name); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource cache operations ResourceEntry *ResourceEntryFromHash(u64 hash); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource data operations String DataFromResource(Resource resource); diff --git a/src/base/base_snc.c b/src/base/base_snc.c index f0a03b29..26a4450d 100644 --- a/src/base/base_snc.c +++ b/src/base/base_snc.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mutex //- Exclusive mutex lock @@ -135,7 +135,7 @@ void Unlock(Lock *l) ZeroStruct(l); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Condition variable void YieldOnCv(Cv *cv, Lock *l) @@ -165,7 +165,7 @@ void SignalCv(Cv *cv) FutexWakeNeq(&cv->wake_gen); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fence i64 FetchFence(Fence *fence) diff --git a/src/base/base_snc.h b/src/base/base_snc.h index fe3ceb43..12ad09ec 100644 --- a/src/base/base_snc.h +++ b/src/base/base_snc.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mutex types #define DefaultMutexSpin 4000 @@ -23,7 +23,7 @@ Struct(Lock) b32 exclusive; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Condition variable types AlignedStruct(Cv, CachelineSize) @@ -32,7 +32,7 @@ AlignedStruct(Cv, CachelineSize) }; StaticAssert(alignof(Cv) == CachelineSize && sizeof(Cv) % CachelineSize == 0); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fence types Struct(Fence) @@ -40,7 +40,7 @@ Struct(Fence) Atomic64Padded v; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mutex operations Lock LockSpinE(Mutex *m, i32 spin); @@ -60,13 +60,13 @@ void Unlock(Lock *lock); # define AssertLockedES(l, m) LAX l #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Condition variable operations void YieldOnCv(Cv *cv, Lock *lock); void SignalCv(Cv *cv); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fence operations i64 FetchFence(Fence *fence); diff --git a/src/base/base_string.c b/src/base/base_string.c index 5cf9d7d6..bc3200c3 100644 --- a/src/base/base_string.c +++ b/src/base/base_string.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Conversion helpers //- Char conversion @@ -182,7 +182,7 @@ String StringFromUid(Arena *arena, Uid uid) } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ String helpers //- Copy @@ -419,7 +419,7 @@ b32 StringEndsWith(String str, String substring) return 0; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ String list helpers StringListNode *PushStringToList(Arena *arena, StringList *l, String s) @@ -458,7 +458,7 @@ String StringFromList(Arena *arena, StringList l, String separator) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Trimming helpers String TrimLeft(String s, String pattern) @@ -509,7 +509,7 @@ String TrimWhitespace(String s) return s; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Formatting /* String formatting only has one format specifier: "%F". All specifier info is @@ -665,12 +665,12 @@ String FormatString_(Arena *arena, String fmt, ...) return new_str; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Unicode //- Codepoint iteration -CodepointIter BeginCodepointIter(String str) +CodepointIter InitCodepointIter(String str) { return (CodepointIter) { @@ -679,7 +679,7 @@ CodepointIter BeginCodepointIter(String str) } /* Returns 0 if done iterating */ -b32 AdvanceCodepointIter(CodepointIter *iter) +b32 NextCodepoint(CodepointIter *iter) { if (iter->pos < iter->src.len) { @@ -695,12 +695,6 @@ b32 AdvanceCodepointIter(CodepointIter *iter) } } -void EndCodepointIter(CodepointIter *iter) -{ - /* Do nothing */ - LAX iter; -} - //- String decode /* utf8 <- utf16 */ @@ -805,7 +799,7 @@ String32 String32FromString(Arena *arena, String str8) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Legacy null-terminated C string operations //- Narrow C strings diff --git a/src/base/base_string.h b/src/base/base_string.h index 57ef5b70..ee0d2eb7 100644 --- a/src/base/base_string.h +++ b/src/base/base_string.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Formatting types #define DefaultFmtPrecision 3 @@ -43,7 +43,7 @@ Struct(FmtArg) } value; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Unicode types Struct(CodepointIter) @@ -55,7 +55,7 @@ Struct(CodepointIter) u64 pos; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Conversion helpers String StringFromChar(Arena *arena, char c); @@ -66,7 +66,7 @@ String StringFromF64(Arena *arena, f64 f, u32 precision); String StringFromhandle(Arena *arena, u64 v0, u64 v1); String StringFromUid(Arena *arena, Uid uid); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ String helpers String PushString(Arena *arena, String src); @@ -81,7 +81,7 @@ b32 StringContains(String str, String substring); b32 StringStartsWith(String str, String substring); b32 StringEndsWith(String str, String substring); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Trimming helpers String TrimLeft(String s, String pattern); @@ -89,13 +89,13 @@ String TrimRight(String s, String pattern); String Trim(String s, String pattern); String TrimWhitespace(String s); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ String list helpers StringListNode *PushStringToList(Arena *arena, StringList *l, String s); String StringFromList(Arena *arena, StringList l, String separator); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Formatting //- Format arg helpers @@ -118,13 +118,12 @@ String StringFromList(Arena *arena, StringList l, String separator); String FormatString_(Arena *arena, String fmt, ...); String FormatStringV(Arena *arena, String fmt, va_list args); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Unicode operations //- Iter -CodepointIter BeginCodepointIter(String str); -b32 AdvanceCodepointIter(CodepointIter *iter); -void EndCodepointIter(CodepointIter *iter); +CodepointIter InitCodepointIter(String str); +b32 NextCodepoint(CodepointIter *iter); //- Decode string String StringFromString16(Arena *arena, String16 str16); @@ -134,7 +133,7 @@ String StringFromString32(Arena *arena, String32 str32); String16 String16FromString(Arena *arena, String str8); String32 String32FromString(Arena *arena, String str8); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Legacy null-terminated C string operations //- Narrow strings diff --git a/src/base/base_uid.h b/src/base/base_uid.h index 25f462af..59e54247 100644 --- a/src/base/base_uid.h +++ b/src/base/base_uid.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Uid types Struct(Uid) @@ -7,7 +7,7 @@ Struct(Uid) u64 lo; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Uid operations #define UID(hi64, lo64) ((Uid) { .hi = (hi64), .lo = (lo64) }) diff --git a/src/base/base_uni.c b/src/base/base_uni.c index 7fe84a9f..6496cca1 100644 --- a/src/base/base_uni.c +++ b/src/base/base_uni.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utf8 //- Decode @@ -127,7 +127,7 @@ Utf8EncodeResult EncodeUtf8(u32 codepoint) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utf16 //- Decode @@ -199,7 +199,7 @@ b32 IsUtf16LowSurrogate(u16 c) return 0xDC00 <= c && c < 0xE000; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utf32 //- Decode diff --git a/src/base/base_uni.h b/src/base/base_uni.h index f542a12e..7bb24567 100644 --- a/src/base/base_uni.h +++ b/src/base/base_uni.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utf8 types Struct(Utf8DecodeResult) @@ -13,7 +13,7 @@ Struct(Utf8EncodeResult) u8 chars8[4]; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utf16 types Struct(Utf16DecodeResult) @@ -28,7 +28,7 @@ Struct(Utf16EncodeResult) u16 chars16[2]; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utf32 types Struct(Utf32DecodeResult) @@ -42,13 +42,13 @@ Struct(Utf32EncodeResult) u32 chars32; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utf8 operations Utf8DecodeResult DecodeUtf8(String str); Utf8EncodeResult EncodeUtf8(u32 codepoint); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utf16 operations Utf16DecodeResult DecodeUtf16(String16 str); @@ -57,7 +57,7 @@ Utf16EncodeResult EncodeUtf16(u32 codepoint); b32 IsUtf16HighSurrogate(u16 c); b32 IsUtf16LowSurrogate(u16 c); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Utf32 operations Utf32DecodeResult DecodeUtf32(String32 str); diff --git a/src/base/base_util.h b/src/base/base_util.h index cffa444d..e8fa3c53 100644 --- a/src/base/base_util.h +++ b/src/base/base_util.h @@ -1,9 +1,9 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Hash types #define Fnv64Basis 0xCBF29CE484222325 -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mergesort types /* Compare functions should @@ -14,7 +14,7 @@ #define MergesortCompareFuncDef(name, arg_a, arg_b, arg_udata) i32 name(void *arg_a, void *arg_b, void *arg_udata) typedef MergesortCompareFuncDef(MergesortCompareFunc, a, b, udata); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Dict types Struct(DictEntry) @@ -42,7 +42,7 @@ Struct(Dict) DictEntry *last; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Hash utils /* FNV-1a parameters for different hash sizes: @@ -59,7 +59,7 @@ Inline u64 HashFnv64(u64 seed, String s) return hash; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mergesort utils Inline void MergesortInternal(u8 *left, u8 *right, u8 *items, u64 left_count, u64 right_count, u64 item_size, MergesortCompareFunc *callback, void *udata) @@ -127,7 +127,7 @@ Inline void Mergesort(void *items, u64 item_count, u64 item_size, MergesortCompa } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Dict utils //- Dict init diff --git a/src/base/base_win32/base_win32.c b/src/base/base_win32/base_win32.c index 67dc513b..b43cfd90 100644 --- a/src/base/base_win32/base_win32.c +++ b/src/base/base_win32/base_win32.c @@ -1,6 +1,6 @@ W32_SharedState W32_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 embedded data BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name, LONG_PTR udata) @@ -35,7 +35,7 @@ BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name return 1; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Core hooks StringList GetCommandLineArgs(void) @@ -132,7 +132,7 @@ void ExitNow(i32 code) ExitProcess(code); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup / shutdown jobs JobDef(W32_StartupLayers, UNUSED sig, UNUSED id) @@ -159,7 +159,7 @@ JobDef(W32_ShutdownLayers, UNUSED sig, UNUSED id) SetEvent(g->exit_end_event); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Main i32 W32_Main(void) @@ -334,7 +334,7 @@ i32 W32_Main(void) return Atomic32Fetch(&g->exit_code); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Crt main #if CrtlibIsEnabled @@ -351,7 +351,7 @@ int CALLBACK wWinMain(UNUSED _In_ HINSTANCE instance, UNUSED _In_opt_ HINSTANCE # endif /* IsConsoleApp */ #endif /* CrtlibIsEnabled */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Crt stub #if !CrtlibIsEnabled diff --git a/src/base/base_win32/base_win32.h b/src/base/base_win32/base_win32.h index 33015617..0a613856 100644 --- a/src/base/base_win32/base_win32.h +++ b/src/base/base_win32/base_win32.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 libs #ifndef BCRYPT_RNG_ALG_HANDLE @@ -10,7 +10,7 @@ u32 BCryptGenRandom(void *algorithm, u8 *buffer, u32 buffer_size, u32 flags); #pragma comment(lib, "user32") #pragma comment(lib, "bcrypt") -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Embedded data iter types Struct(W32_FindEmbeddedDataCtx) @@ -19,7 +19,7 @@ Struct(W32_FindEmbeddedDataCtx) String embedded_strings[64]; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define W32_MaxOnExitFuncs 4096 @@ -47,19 +47,19 @@ Struct(W32_SharedState) ExitFunc *exit_funcs[W32_MaxOnExitFuncs]; } extern W32_shared_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Embedded data initialization #define W32_EmbeddedDataPrefix EMBEDDED_RESOURCE_DATA__ BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name, LONG_PTR udata); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup / shutdown jobs JobDecl(W32_StartupLayers, EmptySig); JobDecl(W32_ShutdownLayers, EmptySig); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Main i32 W32_Main(void); diff --git a/src/base/base_win32/base_win32_job.c b/src/base/base_win32/base_win32_job.c index dcc7ebaa..9c018160 100644 --- a/src/base/base_win32/base_win32_job.c +++ b/src/base/base_win32/base_win32_job.c @@ -1,6 +1,6 @@ W32_SharedJobState W32_shared_job_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Startup void InitJobSystem(void) @@ -85,7 +85,7 @@ void InitJobSystem(void) //OnExit(ShutdownJobs); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 thread JobDef(W32_DummyJob, sig, id) @@ -178,7 +178,7 @@ void W32_WaitEndThread(W32_Thread *thread) Assert(ok); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 fiber //- Acquire fiber @@ -330,7 +330,7 @@ void W32_SwitchToFiber(W32_Fiber *target) #endif } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 fiber entry void W32_FiberEntryPoint(void *_) @@ -398,7 +398,7 @@ DWORD WINAPI W32_VirtualFiberEntryPoint(LPVOID arg) return 0; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 job worker entry W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg) @@ -525,7 +525,7 @@ W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Fiber suspend/resume operations void SuspendFiber(void) @@ -619,7 +619,7 @@ void ResumeFibers(i16 fiber_ids_count, i16 *fiber_ids) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hoodef Job operations Job *OpenJob(JobFunc *func, JobPool pool_kind) diff --git a/src/base/base_win32/base_win32_job.h b/src/base/base_win32/base_win32_job.h index e7d6a78e..7f253c9b 100644 --- a/src/base/base_win32/base_win32_job.h +++ b/src/base/base_win32/base_win32_job.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 libs #pragma warning(push, 0) @@ -23,7 +23,7 @@ #pragma comment(lib, "avrt") #pragma comment(lib, "ws2_32.lib") -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Thread types #define W32_ThreadDef(name, arg_name) void name(void *arg_name) @@ -39,7 +39,7 @@ Struct(W32_Thread) HANDLE handle; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fiber types #define W32_FiberStackSize Mebi(1) @@ -72,7 +72,7 @@ AlignedStruct(W32_Fiber, CachelineSize) }; StaticAssert(alignof(W32_Fiber) == CachelineSize && sizeof(W32_Fiber) % CachelineSize == 0); /* False sharing validation */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Job pool types //- Worker ctx @@ -142,7 +142,7 @@ AlignedStruct(W32_JobPool, CachelineSize) }; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types /* Arbitrary threshold for determining when to use a looped WakeByAddressSingle vs a WakeByAddressAll to wake parked workers */ @@ -166,12 +166,12 @@ Struct(W32_SharedJobState) }; } extern W32_shared_job_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void StartupJobs(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Thread operations DWORD WINAPI W32_Win32ThreadProc(LPVOID vt); @@ -180,7 +180,7 @@ b32 W32_TryEndThread(W32_Thread *thread, f32 timeout_seconds); void W32_WaitEndThread(W32_Thread *thread); JobDecl(W32_DummyJob, EmptySig); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fiber operations W32_Fiber *W32_AcquireFiber(W32_JobPool *pool); @@ -189,13 +189,13 @@ ForceInline W32_Fiber *W32_FiberFromId(i16 id); void W32_SwitchToFiber(W32_Fiber *target); void W32_YieldFiber(W32_Fiber *fiber, W32_Fiber *parent_fiber); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Fiber entry void W32_FiberEntryPoint(void *wi32_fiber_data); DWORD WINAPI W32_VirtualFiberEntryPoint(LPVOID arg); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Job worker entry W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg); diff --git a/src/collider/collider.c b/src/collider/collider.c index dc588466..0d894ce9 100644 --- a/src/collider/collider.c +++ b/src/collider/collider.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Debug #if COLLIDER_DEBUG @@ -10,7 +10,7 @@ void CLD_DebugBreakable(void) } #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Shape CLD_Shape CLD_ShapeFromQuad(Quad quad) @@ -25,7 +25,7 @@ CLD_Shape CLD_ShapeFromQuad(Quad quad) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Menkowski support point CLD_SupportPoint CLD_SupportPointFromDirEx(CLD_Shape *shape, Xform xf, Vec2 dir, i32 ignore) @@ -91,7 +91,7 @@ CLD_MenkowskiPoint CLD_MenkowskiPointFromDir(CLD_Shape *shape0, CLD_Shape *shape return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Aabb Aabb CLD_AabbFromShape(CLD_Shape *shape, Xform xf) @@ -128,7 +128,7 @@ b32 CLD_TestAabb(Aabb box0, Aabb box1) ((b0_y0 >= b1_y0 && b0_y0 <= b1_y1) || (b0_y1 >= b1_y0 && b0_y1 <= b1_y1) || (b1_y0 >= b0_y0 && b1_y0 <= b0_y1) || (b1_y1 >= b0_y0 && b1_y1 <= b0_y1)); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Gjk /* @@ -308,7 +308,7 @@ CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Epa /* Expands upon result of GJK calculation to determine collision normal & @@ -477,7 +477,7 @@ CLD_EpaData CLD_EpaDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Clipping CLD_ClippedLine CLD_ClipLineToLine(Vec2 a0, Vec2 b0, Vec2 a1, Vec2 b1, Vec2 normal) @@ -533,7 +533,7 @@ Vec2 CLD_ClipPointToLine(Vec2 a, Vec2 b, Vec2 p, Vec2 normal) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Collision points CLD_CollisionData CLD_CollisionDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1) @@ -814,7 +814,7 @@ abort: return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Closest points /* TODO: De-duplicate code between CLD_ClosestPointDataFromShapes & CLD_CollisionDataFromShapes */ @@ -901,7 +901,7 @@ abort: return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Time of impact /* Takes 2 shapes and their xforms at t=0 and t=1. @@ -984,7 +984,7 @@ f32 CLD_TimeOfImpact(CLD_Shape *c0, CLD_Shape *c1, Xform xf0_t0, Xform xf1_t0, X return t; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Point cloud debugging /* TODO: Remove this (debugging) */ @@ -1027,7 +1027,7 @@ Vec2Array CLD_PointCloud(Arena *arena, CLD_Shape *shape0, CLD_Shape *shape1, Xfo return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Boolean GJK (unused) #if 0 diff --git a/src/collider/collider.h b/src/collider/collider.h index 4eb76f6b..eff009d6 100644 --- a/src/collider/collider.h +++ b/src/collider/collider.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tweakable defines /* How close can non-overlapping shapes be before collision is considered */ @@ -10,7 +10,7 @@ /* To prevent extremely large prototypes when origin is in exact center of rounded feature */ #define CLD_MaxEpaIterations 64 -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Shape types Struct(CLD_Shape) @@ -20,7 +20,7 @@ Struct(CLD_Shape) f32 radius; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Menkowski types Struct(CLD_SupportPoint) @@ -48,7 +48,7 @@ Struct(CLD_MenkowskiFeature) CLD_MenkowskiPoint a, b; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Collision types Struct(CLD_CollisionPoint) @@ -91,7 +91,7 @@ Struct(CLD_ClosestPointData) CLD_Prototype prototype; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Clipping types Struct(CLD_ClippedLine) @@ -100,7 +100,7 @@ Struct(CLD_ClippedLine) Vec2 a1_clipped, b1_clipped; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Gjk types Struct(CLD_GjkData) @@ -118,7 +118,7 @@ Struct(CLD_GjkData) #endif }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Epa types Struct(CLD_EpaData) @@ -132,7 +132,7 @@ Struct(CLD_EpaData) #endif }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Debug helpers #if COLLIDER_DEBUG @@ -152,26 +152,26 @@ void CLD_DebugBreakable(void); #define CLD_DBGSTEP #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Shape operations CLD_Shape CLD_ShapeFromQuad(Quad quad); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Menkowski operations CLD_SupportPoint CLD_SupportPointFromDirEx(CLD_Shape *shape, Xform xf, Vec2 dir, i32 ignore); CLD_SupportPoint CLD_SupportPointFromDir(CLD_Shape *shape, Xform xf, Vec2 dir); CLD_MenkowskiPoint CLD_MenkowskiPointFromDir(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1, Vec2 dir); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Aabb operations Aabb CLD_AabbFromShape(CLD_Shape *shape, Xform xf); Aabb CLD_CombineAabb(Aabb b0, Aabb b1); b32 CLD_TestAabb(Aabb box0, Aabb box1); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Gjk operations #if COLLIDER_DEBUG @@ -180,7 +180,7 @@ CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1, f32 min_unique_pt_dist_sq); #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Epa operations #if COLLIDER_DEBUG @@ -189,28 +189,28 @@ CLD_EpaData CLD_EpaDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf CLD_EpaData CLD_EpaDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1, CLD_GjkData gjk_result, f32 min_unique_pt_dist_sq, u32 max_iterations); #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Clipping operations CLD_ClippedLine CLD_ClipLineToLine(Vec2 a0, Vec2 b0, Vec2 a1, Vec2 b1, Vec2 normal); Vec2 CLD_ClipPointToLine(Vec2 a, Vec2 b, Vec2 p, Vec2 normal); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Collision point operations CLD_CollisionData CLD_CollisionDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Closest point operations CLD_ClosestPointData CLD_ClosestPointDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Time of impact operations f32 CLD_TimeOfImpact(CLD_Shape *c0, CLD_Shape *c1, Xform xf0_t0, Xform xf1_t0, Xform xf0_t1, Xform xf1_t1, f32 tolerance, u32 max_iterations); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Point cloud debugging operations Vec2Array CLD_Menkowski(Arena *arena, CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1, u32 detail); diff --git a/src/config.h b/src/config.h index b663b6cb..29f64ab0 100644 --- a/src/config.h +++ b/src/config.h @@ -89,7 +89,7 @@ #define PROF_THREAD_GROUP_WINDOW -(i64)Mebi(2) #define PROF_THREAD_GROUP_MAIN -(i64)Mebi(1) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Settings /* TODO: Move these to user-configurable settings */ diff --git a/src/draw/draw.c b/src/draw/draw.c index db90831f..d63743d2 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -1,6 +1,6 @@ D_SharedState D_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void D_Startup(void) @@ -11,7 +11,7 @@ void D_Startup(void) g->solid_white_texture = GPU_AcquireTexture(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, VEC2I32(1, 1), &pixel_white); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Material void D_DrawMaterial(GPU_RenderSig *sig, D_MaterialParams params) @@ -27,7 +27,7 @@ void D_DrawMaterial(GPU_RenderSig *sig, D_MaterialParams params) GPU_PushRenderCmd(sig, &cmd); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Solid shapes void D_DrawPolyEx(GPU_RenderSig *sig, Vec2Array vertices, GPU_Indices indices, u32 color) @@ -103,7 +103,7 @@ void D_DrawQuad(GPU_RenderSig *sig, Quad quad, u32 color) D_DrawPolyEx(sig, vertices, indices, color); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Line shapes void D_DrawLineGradient(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 start_color, u32 end_color) @@ -250,7 +250,7 @@ void D_DrawColliderLine(GPU_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Grid void D_DrawGrid(GPU_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 line_color, u32 x_color, u32 y_color, f32 thickness, f32 spacing, Vec2 offset) @@ -278,7 +278,7 @@ void D_DrawGrid(GPU_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 GPU_PushRenderCmd(sig, &cmd); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ui void D_DrawUiRect(GPU_RenderSig *sig, D_UiRectParams params) @@ -292,7 +292,7 @@ void D_DrawUiRect(GPU_RenderSig *sig, D_UiRectParams params) GPU_PushRenderCmd(sig, &cmd); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Text /* Returns the rect of the text area */ diff --git a/src/draw/draw.h b/src/draw/draw.h index 061dd969..131d7614 100644 --- a/src/draw/draw.h +++ b/src/draw/draw.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Material types Struct(D_MaterialParams) @@ -16,7 +16,7 @@ Struct(D_MaterialParams) __VA_ARGS__ \ }) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ui types Struct(D_UiRectParams) @@ -32,7 +32,7 @@ Struct(D_UiRectParams) __VA_ARGS__ \ }) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Text types /* How is text aligned within its area */ @@ -98,7 +98,7 @@ Struct(D_TextParams) __VA_ARGS__ \ }) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types Struct(D_SharedState) @@ -106,17 +106,17 @@ Struct(D_SharedState) GPU_Resource *solid_white_texture; } extern D_shared_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void D_Startup(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Material operations void D_DrawMaterial(GPU_RenderSig *sig, D_MaterialParams params); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Solid shape operations void D_DrawPolyEx(GPU_RenderSig *sig, Vec2Array vertices, GPU_Indices indices, u32 color); @@ -124,7 +124,7 @@ void D_DrawPoly(GPU_RenderSig *sig, Vec2Array points, u32 color); void D_DrawCircle(GPU_RenderSig *sig, Vec2 pos, f32 radius, u32 color, u32 detail); void D_DrawQuad(GPU_RenderSig *sig, Quad quad, u32 color); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Line shape operations void D_DrawLineGradient(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 start_color, u32 end_color); @@ -137,17 +137,17 @@ void D_DrawArrowLine(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, f3 void D_DrawArrowRay(GPU_RenderSig *sig, Vec2 pos, Vec2 rel, f32 thickness, f32 arrowhead_height, u32 color); void D_DrawColliderLine(GPU_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 thickness, u32 color, u32 detail); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Grid operations void D_DrawGrid(GPU_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 line_color, u32 x_color, u32 y_color, f32 thickness, f32 spacing, Vec2 offset); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ui operations void D_DrawUiRect(GPU_RenderSig *sig, D_UiRectParams params); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Text operations Rect draw_text(GPU_RenderSig *sig, D_TextParams params); diff --git a/src/font/font.c b/src/font/font.c index 70bca28b..263b06af 100644 --- a/src/font/font.c +++ b/src/font/font.c @@ -1,5 +1,5 @@ -//////////////////////////////// -//~ Load job +//////////////////////////////////////////////////////////// +//~ Font load job JobDef(F_Load, sig, _) { @@ -45,20 +45,73 @@ JobDef(F_Load, sig, _) "Font \"%F\" not found", FmtString(name))); } - TTF_Result result = TTF_Decode(scratch.arena, resource_data, point_size, font_codes, countof(font_codes)); + TTF_Decoded decoded = TTF_Decode(scratch.arena, resource_data, point_size, font_codes, countof(font_codes)); /* Send texture to GPU */ GPU_Resource *texture = 0; { GPU_ResourceDesc desc = ZI; desc.kind = GPU_ResourceKind_Texture2D; + desc.flags = GPU_ResourceFlag_None; desc.texture.format = GPU_Format_R8G8B8A8_Unorm; - desc.texture.size = VEC3I32(64, 64, 1); + desc.texture.size = VEC3I32(decoded.image_width, decoded.image_height, 1); texture = GPU_AcquireResource(desc); - /* FIXME: Copy to GPU resource here */ - //GPU_Mapped mapped = GPU_Map(texture); - //GPU_CopyToMapped(&mapped, STRING(desc.texture.size.x * desc.texture.size.y * 4, (u8 *)result.image_pixels)); - //GPU_Unmap(&mapped); + + /* Fill upload buffer */ + GPU_ResourceDesc upload_desc = ZI; + upload_desc.kind = GPU_ResourceKind_Buffer; + upload_desc.buffer.heap_kind = GPU_HeapKind_Upload; + upload_desc.buffer.count = GPU_GetFootprintSize(texture); + GPU_Resource *upload = GPU_AcquireResource(upload_desc); + { + GPU_Mapped mapped = GPU_Map(upload); + GPU_CopyBytesToFootprint(mapped.mem, (u8 *)decoded.image_pixels, texture); + GPU_Unmap(mapped); + } + + GPU_QueueKind copy_queue = GPU_QueueKind_BackgroundCopy; + GPU_QueueKind direct_queue = GPU_QueueKind_Direct; + Fence *direct_queue_fence = GPU_FenceFromQueue(direct_queue); + i64 direct_queue_fence_target = 0; + if (copy_queue == direct_queue) + { + /* Copy & transition GPU resource on direct queue*/ + { + GPU_CommandList *cl = GPU_BeginCommandList(direct_queue); + { + GPU_TransitionToCopyDst(cl, texture); + GPU_CopyResource(cl, texture, upload); + GPU_TransitionToReadable(cl, texture); + } + direct_queue_fence_target = GPU_EndCommandList(cl); + } + } + else + { + /* Copy to GPU resource on background copy queue*/ + i64 copy_queue_fence_target = 0; + { + GPU_CommandList *cl = GPU_BeginCommandList(copy_queue); + { + GPU_TransitionToCopyDst(cl, texture); + GPU_CopyResource(cl, texture, upload); + } + copy_queue_fence_target = GPU_EndCommandList(cl); + } + /* Once copy finishes, transition resource to readable on direct queue */ + { + GPU_QueueWait(direct_queue, copy_queue, copy_queue_fence_target); + GPU_CommandList *cl = GPU_BeginCommandList(direct_queue); + { + GPU_TransitionToReadable(cl, texture); + } + direct_queue_fence_target = GPU_EndCommandList(cl); + } + } + + /* Release upload buffer once transition finishes */ + YieldOnFence(direct_queue_fence, direct_queue_fence_target); + GPU_ReleaseResource(upload, GPU_ReleaseFlag_None); } /* Acquire store memory */ @@ -66,16 +119,16 @@ JobDef(F_Load, sig, _) { AC_Store store = AC_OpenStore(); font = PushStruct(store.arena, F_Font); - font->glyphs = PushStructsNoZero(store.arena, F_Glyph, result.glyphs_count); + font->glyphs = PushStructsNoZero(store.arena, F_Glyph, decoded.glyphs_count); font->lookup = PushStructs(store.arena, u16, F_LookupTableSize); AC_CloseStore(&store); } /* Set font data */ font->texture = texture; - font->image_width = result.image_width; - font->image_height = result.image_height; - font->glyphs_count = result.glyphs_count; + font->image_width = decoded.image_width; + font->image_height = decoded.image_height; + font->glyphs_count = decoded.glyphs_count; font->point_size = point_size; /* FIXME: Load baked font instead of panicking */ @@ -86,15 +139,15 @@ JobDef(F_Load, sig, _) FmtString(name))); } - /* Copy glyphs from decode result */ - StaticAssert(sizeof(*font->glyphs) == sizeof(*result.glyphs)); /* Font glyph size must match TTF glyph size for memcpy */ - CopyBytes(font->glyphs, result.glyphs, sizeof(*font->glyphs) * result.glyphs_count); + /* Copy glyphs from decode decoded */ + StaticAssert(sizeof(*font->glyphs) == sizeof(*decoded.glyphs)); /* Font glyph size must match TTF glyph size for memcpy */ + CopyBytes(font->glyphs, decoded.glyphs, sizeof(*font->glyphs) * decoded.glyphs_count); /* Build lookup table */ for (u64 i = 0; i < countof(font_codes); ++i) { u32 codepoint = font_codes[i]; - font->lookup[codepoint] = result.cache_indices[i]; + font->lookup[codepoint] = decoded.cache_indices[i]; } P_LogSuccessF("Loaded font \"%F\" (point size %F) in %F seconds", FmtString(name), FmtFloat((f64)point_size), FmtFloat(SecondsFromNs(TimeNs() - start_ns))); @@ -103,8 +156,8 @@ JobDef(F_Load, sig, _) EndScratch(scratch); } -//////////////////////////////// -//~ Load +//////////////////////////////////////////////////////////// +//~ Font load operations /* Returns the asset from the asset cache */ AC_Asset *F_LoadAsset(Resource resource, f32 point_size, b32 wait) @@ -128,6 +181,7 @@ AC_Asset *F_LoadAsset(Resource resource, f32 point_size, b32 wait) { Job *job = OpenJob(F_Load, JobPool_Background); F_Load_Sig *sig = PushStruct(job->arena, F_Load_Sig); + job->sig = sig; sig->asset = asset; sig->resource = resource; sig->point_size = point_size; @@ -160,25 +214,42 @@ F_Font *F_LoadFontWait(Resource resource, f32 point_size) return f; } -//////////////////////////////// -//~ Get glyph +//////////////////////////////////////////////////////////// +//~ Font data operations -F_Glyph *F_GetGlyph(F_Font *font, u32 codepoint) +F_Glyph F_GlyphFromCodepoint(F_Font *font, u32 codepoint) { if (codepoint < F_LookupTableSize) { u16 index = font->lookup[codepoint]; if (index < font->glyphs_count) { - return &font->glyphs[index]; + return font->glyphs[index]; } } if (codepoint == '?') { - return &font->glyphs[font->lookup[0]]; + return font->glyphs[font->lookup[0]]; } else { - return &font->glyphs[font->lookup['?']]; + return font->glyphs[font->lookup['?']]; } } + +F_GlyphRun F_GlyphRunFromString(Arena *arena, F_Font *font, String str) +{ + F_GlyphRun result = ZI; + result.glyphs = PushDry(arena, F_Glyph); + for (CodepointIter it = InitCodepointIter(str); NextCodepoint(&it);) + { + u32 codepoint = it.codepoint; + u16 index = font->lookup[codepoint]; + F_Glyph glyph = font->glyphs[index]; + *PushStructNoZero(arena, F_Glyph) = glyph; + ++result.count; + result.width += glyph.advance; + result.height = MaxF32(result.height, glyph.height); + } + return result; +} diff --git a/src/font/font.h b/src/font/font.h index 47582ba4..3d178ef4 100644 --- a/src/font/font.h +++ b/src/font/font.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Font types #define F_LookupTableSize (256) @@ -13,6 +13,14 @@ Struct(F_Glyph) Rect atlas_rect; }; +Struct(F_GlyphRun) +{ + f32 width; + f32 height; + u64 count; + F_Glyph *glyphs; +}; + Struct(F_Font) { GPU_Resource *texture; @@ -24,19 +32,20 @@ Struct(F_Font) u16 *lookup; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Font load job JobDecl(F_Load, { AC_Asset *asset; f32 point_size; Resource resource; }); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Font load operations AC_Asset *F_LoadAsset(Resource resource, f32 point_size, b32 wait); F_Font *F_LoadFontAsync(Resource resource, f32 point_size); F_Font *F_LoadFontWait(Resource resource, f32 point_size); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Font data operations -F_Glyph *F_GetGlyph(F_Font *font, u32 codepoint); +F_Glyph F_GlyphFromCodepoint(F_Font *font, u32 codepoint); +F_GlyphRun F_GlyphRunFromString(Arena *arena, F_Font *font, String str); diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h index 237984dc..8a2aa83f 100644 --- a/src/gpu/gpu.h +++ b/src/gpu/gpu.h @@ -1,11 +1,11 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Opaque types Struct(GPU_Resource); Struct(GPU_CommandList); Struct(GPU_Swapchain); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Queue types #define GPU_MultiQueueEnabled !ProfilingIsEnabled @@ -26,7 +26,7 @@ Enum(GPU_QueueKind) #endif }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Format types /* NOTE: Matches DirectX DXGI_FORMAT */ @@ -157,7 +157,7 @@ Enum(GPU_Format) GPU_Format_Count = 192 }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Filter types /* NOTE: Matches DirectX D3D12_FILTER */ @@ -236,7 +236,7 @@ Enum(GPU_ComparisonFunc) GPU_ComparisonFunc_Always = 8 }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource types #define GPU_MaxRenderTargets 8 @@ -317,7 +317,7 @@ Struct(GPU_Mapped) void *mem; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Rasterizer types Enum(GPU_RasterizeMode) @@ -348,7 +348,7 @@ Struct(GPU_Scissor) f32 bottom; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Memory info types Struct(GPU_MemoryInfo) @@ -357,24 +357,24 @@ Struct(GPU_MemoryInfo) u64 non_local_used; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Startup void GPU_Startup(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Fence operations Fence *GPU_FenceFromQueue(GPU_QueueKind queue); void GPU_QueueWait(GPU_QueueKind a, GPU_QueueKind b, i64 b_target_fence_value); /* Tells queue A Forces `waiting_queue` to wait until `target_queue`'s fence reaches the specified value */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Rasterizer helpers GPU_Viewport GPU_ViewportFromRect(Rect rect); GPU_Scissor GPU_ScissorFromRect(Rect rect); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Resource operations GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc); @@ -386,7 +386,7 @@ u64 GPU_GetFootprintSize(GPU_Resource *resource); u64 GPU_GetBufferCount(GPU_Resource *gpu_resource); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Resource index operations StructuredBufferRid GPU_StructuredBufferRidFromResource(GPU_Resource *resource); @@ -399,18 +399,18 @@ RWTexture2DRid GPU_RWTexture2DRidFromResource(GPU_Resource *resource); RWTexture3DRid GPU_RWTexture3DRidFromResource(GPU_Resource *resource); SamplerStateRid GPU_SamplerStateRidFromResource(GPU_Resource *resource); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Command list operations GPU_CommandList *GPU_BeginCommandList(GPU_QueueKind queue); i64 GPU_EndCommandList(GPU_CommandList *cl); /* Returns the value that the queue's fence will be set to once the command is completed */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Profiling helpers void GPU_ProfN(GPU_CommandList *cl, String name); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Barrier operations void GPU_TransitionToReadable(GPU_CommandList *cl, GPU_Resource *resource); /* Allows the resource to be read via read-only types in shaders */ @@ -422,7 +422,7 @@ void GPU_TransitionToCopyDst(GPU_CommandList *cl, GPU_Resource *resource); /* A void GPU_FlushWritable(GPU_CommandList *cl, GPU_Resource *resource); /* Waits until writes to a shader writable resource have completed */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Dispatch operations void GPU_ClearRenderable(GPU_CommandList *cl, GPU_Resource *resource); @@ -452,12 +452,12 @@ void GPU_Compute_(GPU_CommandList *cl, u32 num_threads_y, u32 num_threads_z); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Resource copy operations void GPU_CopyResource(GPU_CommandList *cl, GPU_Resource *dst, GPU_Resource *src); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Map operations GPU_Mapped GPU_Map(GPU_Resource *r); @@ -465,12 +465,12 @@ void GPU_Unmap(GPU_Mapped mapped); void GPU_CopyBytesToFootprint(void *dst, void *src, GPU_Resource *footprint_reference); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Memory info operations GPU_MemoryInfo GPU_QueryMemoryInfo(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Swapchain operations GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, GPU_Format format, Vec2I32 size); diff --git a/src/gpu/gpu_dx12/gpu_dx12.c b/src/gpu/gpu_dx12/gpu_dx12.c index 2ce46274..3591081a 100644 --- a/src/gpu/gpu_dx12/gpu_dx12.c +++ b/src/gpu/gpu_dx12/gpu_dx12.c @@ -1,6 +1,6 @@ GPU_D12_SharedState GPU_D12_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Helpers GPU_D12_FiberState *GPU_D12_FiberStateFromId(i16 fiber_id) @@ -68,7 +68,7 @@ u64 GPU_D12_ReuseHashFromResourceDesc(GPU_ResourceDesc desc, u64 buffer_size) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void GPU_D12_Startup(void) @@ -114,7 +114,7 @@ void GPU_D12_Startup(void) RunJob(GPU_D12_StartQueueSync, .pool = JobPool_Hyper, .flags = JobFlag_Dedicated); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Initialization //- Device initialization @@ -378,7 +378,7 @@ void GPU_D12_InitRootsig(void) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Pipeline operations JobDef(GPU_D12_LoadPipeline, sig, _) @@ -529,7 +529,7 @@ GPU_D12_Pipeline *GPU_D12_PipelineFromDesc(GPU_D12_PipelineDesc desc) return pipeline; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Queue operations GPU_D12_Queue *GPU_D12_QueueFromKind(GPU_QueueKind kind) @@ -538,7 +538,7 @@ GPU_D12_Queue *GPU_D12_QueueFromKind(GPU_QueueKind kind) return g->queues[kind]; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Descriptor operations GPU_D12_Descriptor *GPU_D12_AcquireDescriptor(GPU_D12_DescriptorHeap *heap) @@ -586,7 +586,7 @@ void GPU_D12_ReleaseDescriptor(GPU_D12_Descriptor *descriptor) Unlock(&lock); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Raw command list GPU_D12_RawCommandList *GPU_D12_BeginRawCommandList(GPU_QueueKind queue_kind) @@ -696,7 +696,7 @@ u64 GPU_D12_EndRawCommandList(GPU_D12_RawCommandList *cl) return target; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Swapchain helpers void GPU_D12_InitSwapchainResources(GPU_D12_Swapchain *swapchain) @@ -915,7 +915,7 @@ i64 GPU_D12_BlitToSwapchain(GPU_D12_SwapchainBuffer *dst, GPU_D12_Resource *text return fence_target; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Queue sync job JobDef(GPU_D12_StartQueueSync, _, __) @@ -946,7 +946,7 @@ JobDef(GPU_D12_StartQueueSync, _, __) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Startup hook void GPU_Startup(void) @@ -954,7 +954,7 @@ void GPU_Startup(void) GPU_D12_Startup(); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Fence hooks Fence *GPU_FenceFromQueue(GPU_QueueKind queue_kind) @@ -971,7 +971,7 @@ void GPU_QueueWait(GPU_QueueKind a, GPU_QueueKind b, i64 b_target_fence_value) ID3D12CommandQueue_Wait(queue_a->d3d_queue, b_fence, b_target_fence_value); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Rasterizer helper hooks GPU_Viewport GPU_ViewportFromRect(Rect rect) @@ -996,7 +996,7 @@ GPU_Scissor GPU_ScissorFromRect(Rect rect) return scissor; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Resource hooks GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc) @@ -1357,7 +1357,7 @@ u64 GPU_GetBufferCount(GPU_Resource *gpu_resource) return resource->desc.buffer.count; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Resource index hooks StructuredBufferRid GPU_StructuredBufferRidFromResource(GPU_Resource *resource) { return (StructuredBufferRid) { ((GPU_D12_Resource *)resource)->srv_descriptor->index }; } @@ -1370,7 +1370,7 @@ RWTexture2DRid GPU_RWTexture2DRidFromResource(GPU_Resource *resource) RWTexture3DRid GPU_RWTexture3DRidFromResource(GPU_Resource *resource) { return (RWTexture3DRid) { ((GPU_D12_Resource *)resource)->uav_descriptor->index }; } SamplerStateRid GPU_SamplerStateRidFromResource(GPU_Resource *resource) { return (SamplerStateRid) { ((GPU_D12_Resource *)resource)->sampler_descriptor->index }; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Command list hooks GPU_CommandList *GPU_BeginCommandList(GPU_QueueKind queue_kind) @@ -1838,7 +1838,7 @@ i64 GPU_EndCommandList(GPU_CommandList *gpu_cl) return fence_target; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Profiling helper hooks void GPU_ProfN(GPU_CommandList *cl, String name) @@ -1846,7 +1846,7 @@ void GPU_ProfN(GPU_CommandList *cl, String name) /* TODO */ } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Barrier hooks void GPU_TransitionToReadable(GPU_CommandList *cl, GPU_Resource *resource) @@ -1892,7 +1892,7 @@ void GPU_FlushWritable(GPU_CommandList *cl, GPU_Resource *resource) cmd->barrier.resource = (GPU_D12_Resource *)resource; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Dispatch hooks void GPU_ClearRenderable(GPU_CommandList *gpu_cl, GPU_Resource *resource) @@ -1952,7 +1952,7 @@ void GPU_Compute_(GPU_CommandList *gpu_cl, cmd->compute.num_threads_z = num_threads_z; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Copy hooks void GPU_CopyResource(GPU_CommandList *gpu_cl, GPU_Resource *gpu_dst, GPU_Resource *gpu_src) @@ -1966,7 +1966,7 @@ void GPU_CopyResource(GPU_CommandList *gpu_cl, GPU_Resource *gpu_dst, GPU_Resour cmd->copy.src = src; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Map hooks GPU_Mapped GPU_Map(GPU_Resource *gpu_r) @@ -2025,7 +2025,7 @@ void GPU_CopyBytesToFootprint(void *dst, void *src, GPU_Resource *footprint_refe } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Memory info hooks GPU_MemoryInfo GPU_QueryMemoryInfo(void) @@ -2034,7 +2034,7 @@ GPU_MemoryInfo GPU_QueryMemoryInfo(void) return (GPU_MemoryInfo) ZI; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Swapchain hooks GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, GPU_Format format, Vec2I32 size) diff --git a/src/gpu/gpu_dx12/gpu_dx12.h b/src/gpu/gpu_dx12/gpu_dx12.h index 80f25d56..b1574b84 100644 --- a/src/gpu/gpu_dx12/gpu_dx12.h +++ b/src/gpu/gpu_dx12/gpu_dx12.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ DirectX12 libs #include @@ -8,7 +8,7 @@ #pragma comment(lib, "d3d12") #pragma comment(lib, "dxgi") -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tweakable defines #define GPU_D12_TearingIsAllowed 1 @@ -22,7 +22,7 @@ #define GPU_D12_MaxSamplerDescriptors (1024 * 1) #define GPU_D12_MaxRtvDescriptors (1024 * 1) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Pipeline types Struct(GPU_D12_PipelineDesc) @@ -53,7 +53,7 @@ Struct(GPU_D12_PipelineBin) GPU_D12_Pipeline *first; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Descriptor types Struct(GPU_D12_Descriptor) @@ -83,7 +83,7 @@ Struct(GPU_D12_DescriptorHeap) u32 max_count; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Resource types Struct(GPU_D12_Resource) @@ -124,7 +124,7 @@ Struct(GPU_D12_ResourceReuseListBin) GPU_D12_ResourceReuseList *first_free; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Queue types Struct(GPU_D12_QueueDesc) @@ -149,7 +149,7 @@ Struct(GPU_D12_Queue) Fence sync_fence; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Raw command list types Struct(GPU_D12_RawCommandList) @@ -163,7 +163,7 @@ Struct(GPU_D12_RawCommandList) ID3D12GraphicsCommandList *cl; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Command list types Enum(GPU_D12_CommandKind) @@ -247,7 +247,7 @@ Struct(GPU_D12_CommandList) GPU_QueueKind queue_kind; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Swapchain types Struct(GPU_D12_SwapchainBuffer) @@ -271,7 +271,7 @@ Struct(GPU_D12_Swapchain) GPU_D12_SwapchainBuffer buffers[GPU_D12_SwapchainBufferCount]; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define GPU_D12_NumResourceReuseBins 1024 @@ -317,7 +317,7 @@ Struct(GPU_D12_SharedState) ID3D12Device *device; } extern GPU_D12_shared_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Helpers GPU_D12_FiberState *GPU_D12_FiberStateFromId(i16 fiber_id); @@ -325,12 +325,12 @@ DXGI_FORMAT GPU_D12_DxgiFormatFromGpuFormat(GPU_Format format); GPU_D12_Command *GPU_D12_PushCmd(GPU_D12_CommandList *cl); u64 GPU_D12_ReuseHashFromResourceDesc(GPU_ResourceDesc desc, u64 buffer_size); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void GPU_D12_Startup(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Initialization //- Device initialization @@ -345,37 +345,37 @@ GPU_D12_DescriptorHeap *GPU_D12_InitDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE ty //- Rootsig initialization void GPU_D12_InitRootsig(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Pipeline operations JobDecl(GPU_D12_LoadPipeline, { GPU_D12_Pipeline *pipeline; }); GPU_D12_Pipeline *GPU_D12_PipelineFromDesc(GPU_D12_PipelineDesc desc); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Queue operations GPU_D12_Queue *GPU_D12_QueueFromKind(GPU_QueueKind kind); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Descriptor operations GPU_D12_Descriptor *GPU_D12_AcquireDescriptor(GPU_D12_DescriptorHeap *heap); void GPU_D12_ReleaseDescriptor(GPU_D12_Descriptor *descriptor); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Raw command list operations GPU_D12_RawCommandList *GPU_D12_BeginRawCommandList(GPU_QueueKind queue_kind); u64 GPU_D12_EndRawCommandList(GPU_D12_RawCommandList *cl); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Swapchain helpers void GPU_D12_InitSwapchainResources(GPU_D12_Swapchain *swapchain); GPU_D12_SwapchainBuffer *GPU_D12_UpdateSwapchain(GPU_D12_Swapchain *swapchain, Vec2I32 resolution); i64 GPU_D12_BlitToSwapchain(GPU_D12_SwapchainBuffer *swapchain_buffer, GPU_D12_Resource *texture, Vec2I32 dst_pos); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sync job JobDecl(GPU_D12_StartQueueSync, EmptySig); diff --git a/src/gpu/gpu_extra.c b/src/gpu/gpu_extra.c index 2f4d554a..daf13efa 100644 --- a/src/gpu/gpu_extra.c +++ b/src/gpu/gpu_extra.c @@ -1,6 +1,6 @@ GPU_SharedUtilState GPU_shared_util_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void GPU_StartupUtils(void) @@ -85,7 +85,7 @@ void GPU_StartupUtils(void) g->quad_indices = quad; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Common resource helpers GPU_Resource *GPU_GetCommonPointSampler(void) @@ -103,7 +103,7 @@ GPU_Resource *GPU_GetCommonNoise(void) return GPU_shared_util_state.noise; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Transient buffer operations GPU_TransientBuffer GPU_AcquireTransientBuffer(GPU_QueueKind queue_kind, u32 element_size) diff --git a/src/gpu/gpu_extra.h b/src/gpu/gpu_extra.h index cbb971ce..65870ab1 100644 --- a/src/gpu/gpu_extra.h +++ b/src/gpu/gpu_extra.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Transient buffer types Struct(GPU_SubmittedResourceNode) @@ -24,7 +24,7 @@ Struct(GPU_TransientBuffer) }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types Struct(GPU_SharedUtilState) @@ -39,19 +39,19 @@ Struct(GPU_SharedUtilState) GPU_SubmittedResourceNode *first_free_submitted_transient_buffer; } extern GPU_shared_util_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void GPU_StartupUtils(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Common resource helpers GPU_Resource *GPU_GetCommonPointSampler(void); GPU_Resource *GPU_GetCommonQuadIndices(void); GPU_Resource *GPU_GetCommonNoise(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Transient buffer operations GPU_TransientBuffer GPU_AcquireTransientBuffer(GPU_QueueKind queue_kind, u32 element_size); diff --git a/src/json/json.c b/src/json/json.c index a6965f44..50dcd4c5 100644 --- a/src/json/json.c +++ b/src/json/json.c @@ -3,7 +3,7 @@ * - Don't allow leading 0s in numbers */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Lex JSON_Token *JSON_PushToken(Arena *arena, JSON_TokenList *list) @@ -351,7 +351,7 @@ JSON_TokenList JSON_TokensFromString(Arena *arena, String src) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Interpret f64 interpret_number(String src) @@ -683,7 +683,7 @@ String interpret_string(Arena *arena, String src, String *error) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Parse void JSON_PushError(Arena *arena, JSON_Parser *p, JSON_Token *t, String msg) diff --git a/src/json/json.h b/src/json/json.h index f9158193..5f8fd27c 100644 --- a/src/json/json.h +++ b/src/json/json.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Blob types Enum(JSON_Type) @@ -50,7 +50,7 @@ Struct(JSON_Result) JSON_ErrorList errors; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Lexer types #define JSON_Case_Newline \ @@ -125,7 +125,7 @@ Global Readonly JSON_TokenKind JSON_keyword_types[] = { ['n'] = JSON_TokenKind_KeywordNull }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Parser types Struct(JSON_Parser) @@ -139,19 +139,19 @@ Struct(JSON_Parser) JSON_ErrorList errors; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Lex JSON_Token *JSON_PushToken(Arena *arena, JSON_TokenList *list); JSON_TokenList JSON_TokensFromString(Arena *arena, String src); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Interpret f64 interpret_number(String src); String interpret_string(Arena *arena, String src, String *error); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Parse void JSON_PushError(Arena *arena, JSON_Parser *p, JSON_Token *t, String msg); diff --git a/src/meta/meta.c b/src/meta/meta.c index e7037697..9e7ef1b5 100644 --- a/src/meta/meta.c +++ b/src/meta/meta.c @@ -2,7 +2,7 @@ #define MetaRebuildCode 1317212284 -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Default base layer compiler definitions #ifndef IsConsoleApp @@ -45,7 +45,7 @@ # define TestsAreEnabled 0 #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Includes //- Header files @@ -59,7 +59,7 @@ //- Source files #include "meta_lay.c" -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Util void EchoLine(String msg) @@ -96,7 +96,7 @@ LineCol LineColFromPos(String data, i64 pos) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ OS command job Struct(RunCommandResult) @@ -116,7 +116,7 @@ JobDef(RunCommand, sig, id) result->elapsed_ns = TimeNs() - start_ns; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Compiler params Struct(CompilerParams) @@ -139,7 +139,7 @@ Struct(CompilerParams) }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Build step job Enum(StepParamsFlag) @@ -207,8 +207,8 @@ JobDef(Step, sig, id) String shader_store_name = Lit("ShadersStore"); - //////////////////////////////// - //~ Build C + ////////////////////////////// + //- Build C if (flags & StepParamsFlag_CompileProgram) { @@ -400,8 +400,8 @@ JobDef(Step, sig, id) } } - //////////////////////////////// - //~ Build shaders + ////////////////////////////// + //- Build shaders if (flags & StepParamsFlag_CompileShaders) { @@ -589,8 +589,8 @@ JobDef(Step, sig, id) } } - //////////////////////////////// - //~ Build embedded dirs + ////////////////////////////// + //- Build embedded dirs if (flags & StepParamsFlag_CompileEmbeddedDirs) { @@ -670,8 +670,8 @@ JobDef(Step, sig, id) } } - //////////////////////////////// - //~ Build arc file + ////////////////////////////// + //- Build arc file if (flags & StepParamsFlag_CompileArc) { @@ -818,7 +818,7 @@ JobDef(Step, sig, id) result->elapsed_ns = TimeNs() - start_ns; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup JobDecl(Build, EmptySig); @@ -828,8 +828,8 @@ JobDef(Build, _, __) M_ErrorList errors = ZI; i32 ret = 0; - //////////////////////////////// - //~ Dirty check + ////////////////////////////// + //- Dirty check //- Return rebuild code if metaprogram is dirty { @@ -872,8 +872,8 @@ JobDef(Build, _, __) } } - //////////////////////////////// - //~ Args + ////////////////////////////// + //- Args //- Unpack args StringList args = GetCommandLineArgs(); @@ -962,8 +962,8 @@ JobDef(Build, _, __) } } - //////////////////////////////// - //~ Parse + ////////////////////////////// + //- Parse //- Lex layers M_TokenFileList lexed = ZI; @@ -989,8 +989,8 @@ JobDef(Build, _, __) M_AppendErrors(arena, &errors, flattened.errors); ret = errors.count > 0; - //////////////////////////////// - //~ Compile & link + ////////////////////////////// + //- Compile & link if (errors.count == 0) { @@ -1083,8 +1083,8 @@ JobDef(Build, _, __) } - //////////////////////////////// - //~ Echo errors + ////////////////////////////// + //- Echo errors for (M_Error *e = errors.first; e; e = e->next) { @@ -1125,7 +1125,7 @@ JobDef(Build, _, __) ExitNow(ret); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Startup void StartupLayers(void) diff --git a/src/meta/meta_file/meta_file.c b/src/meta/meta_file/meta_file.c index aa371624..76df6ade 100644 --- a/src/meta/meta_file/meta_file.c +++ b/src/meta/meta_file/meta_file.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Path helpers String F_GetFull(Arena *arena, String path) @@ -81,7 +81,7 @@ String F_ExtensionFromFile(String path) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File read operations String F_DataFromFile(Arena *arena, String path) @@ -93,7 +93,7 @@ String F_DataFromFile(Arena *arena, String path) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File write operations void F_ClearWrite(String path, String data) @@ -103,7 +103,7 @@ void F_ClearWrite(String path, String data) OS_CloseFile(file); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File attribute helpers b32 F_IsFile(String path) @@ -116,7 +116,7 @@ b32 F_IsDir(String path) return OS_DirExists(path); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File iter operations void F_FilesFromDir(Arena *arena, StringList *list, String dir, F_IterFlag flags) diff --git a/src/meta/meta_file/meta_file.h b/src/meta/meta_file/meta_file.h index a80f5120..49d0bf12 100644 --- a/src/meta/meta_file/meta_file.h +++ b/src/meta/meta_file/meta_file.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File iter types Enum(F_IterFlag) @@ -7,7 +7,7 @@ Enum(F_IterFlag) F_IterFlag_Recurse = (1 << 0) }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Path helpers String F_GetFull(Arena *arena, String path); @@ -16,23 +16,23 @@ String F_GetFileName(String path); String F_GetParentDir(String path); String F_ExtensionFromFile(String path); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File read operations String F_DataFromFile(Arena *arena, String path); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File write operations void F_ClearWrite(String path, String data); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File attribute helpers b32 F_IsFile(String path); b32 F_IsDir(String path); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File iter operations void F_FilesFromDir(Arena *arena, StringList *list, String dir, F_IterFlag flags); diff --git a/src/meta/meta_lay.c b/src/meta/meta_lay.c index c6a7a98f..e1bbc945 100644 --- a/src/meta/meta_lay.c +++ b/src/meta/meta_lay.c @@ -24,7 +24,7 @@ Readonly M_Layer M_NilLayer = { .last = &M_NilEntry, }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Error helpers M_Error *M_PushError(Arena *arena, M_ErrorList *l, M_Token *token, String msg) @@ -45,7 +45,7 @@ void M_AppendErrors(Arena *arena, M_ErrorList *dst, M_ErrorList src) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Lexer operations M_TokenFile *M_PushTokenFile(Arena *arena, M_TokenFileList *l, String name, String data) @@ -199,7 +199,7 @@ M_TokenFileList M_TokensFromSrcDirs(Arena *arena, StringList src_dirs) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Parser operations M_Layer *M_PushLayer(Arena *arena, M_LayerList *list, M_TokenFile *file) @@ -324,7 +324,7 @@ M_LayerList M_LayersFromTokenFiles(Arena *arena, M_TokenFileList lexed) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Flatten operations M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList starting_layer_names) diff --git a/src/meta/meta_lay.h b/src/meta/meta_lay.h index 5f5fedcf..e46bcbba 100644 --- a/src/meta/meta_lay.h +++ b/src/meta/meta_lay.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Error types Struct(M_Error) @@ -15,7 +15,7 @@ Struct(M_ErrorList) u64 count; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File types Struct(M_File) @@ -24,7 +24,7 @@ Struct(M_File) String data; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Token types Enum(M_TokenKind) @@ -66,7 +66,7 @@ Struct(M_TokenFileList) u64 count; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Entry types Enum(M_EntryKind) @@ -129,26 +129,26 @@ Struct(M_LayerList) u64 count; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Error helpers M_Error *M_PushError(Arena *arena, M_ErrorList *l, M_Token *token, String msg); void M_AppendErrors(Arena *arena, M_ErrorList *dst, M_ErrorList src); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Lexer operations M_Token *M_PushToken(Arena *arena, M_TokenFile *file, String s, M_TokenKind kind); M_TokenFileList M_TokensFromSrcDirs(Arena *arena, StringList src_dirs); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Parser operations M_Layer *M_PushLayer(Arena *arena, M_LayerList *list, M_TokenFile *file); M_Entry *M_PushEntry(Arena *arena, M_Layer *l, M_EntryKind kind, M_Token *entry_token, u64 args_count, M_Token **args); M_LayerList M_LayersFromTokenFiles(Arena *arena, M_TokenFileList token_files); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Flatten operations M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList starting_layer_names); diff --git a/src/meta/meta_os/meta_os.h b/src/meta/meta_os/meta_os.h index 85f632f6..e67d2f38 100644 --- a/src/meta/meta_os/meta_os.h +++ b/src/meta/meta_os/meta_os.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File types Enum(OS_FileFlag) @@ -15,7 +15,7 @@ Struct(OS_File) u64 handle; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Command types Struct(OS_CommandResult) @@ -24,12 +24,12 @@ Struct(OS_CommandResult) String output; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Startup hooks void OS_Startup(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl File system operations OS_File OS_OpenFile(String path, OS_FileFlag flags); @@ -40,7 +40,7 @@ void OS_DirContentsFromFullPath(Arena *arena, StringList *list, String path); String OS_GetFullPath(Arena *arena, String path); u64 OS_LastWriteTimestampFromPath(String path); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Directory helpers b32 OS_FileOrDirExists(String path); @@ -49,7 +49,7 @@ b32 OS_DirExists(String path); void OS_Mkdir(String path); void OS_Rm(String path); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Shell operations OS_CommandResult OS_RunCommand(Arena *arena, String cmd); diff --git a/src/meta/meta_os/meta_os_win32/meta_os_win32.c b/src/meta/meta_os/meta_os_win32/meta_os_win32.c index 31bec3a3..ed76dbad 100644 --- a/src/meta/meta_os/meta_os_win32/meta_os_win32.c +++ b/src/meta/meta_os/meta_os_win32/meta_os_win32.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 helpers String W32_StringFromError(Arena *arena, DWORD err) @@ -25,14 +25,14 @@ String W32_StringFromError(Arena *arena, DWORD err) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Startup hook void OS_Startup(void) { } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef File system hooks OS_File OS_OpenFile(String path, OS_FileFlag flags) @@ -151,7 +151,7 @@ u64 OS_LastWriteTimestampFromPath(String path) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Directory helper hooks b32 OS_FileOrDirExists(String path) @@ -197,7 +197,7 @@ void OS_Rm(String path) EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Shell hooks OS_CommandResult OS_RunCommand(Arena *arena, String cmd) diff --git a/src/meta/meta_os/meta_os_win32/meta_os_win32.h b/src/meta/meta_os/meta_os_win32/meta_os_win32.h index b66fd51f..13f6a19d 100644 --- a/src/meta/meta_os/meta_os_win32/meta_os_win32.h +++ b/src/meta/meta_os/meta_os_win32/meta_os_win32.h @@ -1,10 +1,10 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 libs #pragma comment(lib, "kernel32") #pragma comment(lib, "user32") -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 helpers String W32_StringFromError(Arena *arena, DWORD err); diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c index 3b587cfc..b8a4758d 100644 --- a/src/mixer/mixer.c +++ b/src/mixer/mixer.c @@ -16,7 +16,7 @@ MIX_SharedState M_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void MIX_Startup(void) @@ -28,7 +28,7 @@ void MIX_Startup(void) g->listener_dir = VEC2(0, -1); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Track MIX_Handle MIX_HandleFromTrack(MIX_Track *track) @@ -139,7 +139,7 @@ void MIX_ReleaseTrackLocked(Lock *lock, MIX_Track *track) g->track_first_free = track; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mixer control /* TODO: Rework interface to be command based instead of directly modifying tracks. */ @@ -221,7 +221,7 @@ void MIX_UpdateListener(Vec2 pos, Vec2 dir) Unlock(&lock); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mix i16 MIX_SampleSound(SND_Sound *sound, u64 sample_pos, b32 wrap) diff --git a/src/mixer/mixer.h b/src/mixer/mixer.h index b899a99f..f813e8c7 100644 --- a/src/mixer/mixer.h +++ b/src/mixer/mixer.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Track types Enum(MIX_TrackFlag) @@ -32,7 +32,7 @@ Struct(MIX_TrackDesc) __VA_ARGS__ \ }) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mix types /* Stereo mix of 32 bit float samples */ @@ -74,7 +74,7 @@ Struct(MIX_Track){ MIX_Track *prev; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types Struct(MIX_SharedState) @@ -93,12 +93,12 @@ Struct(MIX_SharedState) MIX_Track *track_first_free; } extern M_shared_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void MIX_Startup(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Track operations MIX_Handle MIX_HandleFromTrack(MIX_Track *track); @@ -106,7 +106,7 @@ MIX_Track *MIX_TrackFromHandle(MIX_Handle handle); MIX_Track *MIX_AcquireTrackLocked(Lock *lock, SND_Sound *sound); void MIX_ReleaseTrackLocked(Lock *lock, MIX_Track *track); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mixer state operations MIX_Handle MIX_PlaySound(SND_Sound *sound); @@ -115,7 +115,7 @@ MIX_TrackDesc MIX_TrackDescFromHandle(MIX_Handle handle); void MIX_UpdateTrack(MIX_Handle handle, MIX_TrackDesc desc); void MIX_UpdateListener(Vec2 pos, Vec2 dir); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mixer update i16 MIX_SampleSound(SND_Sound *sound, u64 sample_pos, b32 wrap); diff --git a/src/mp3/mp3.h b/src/mp3/mp3.h index 15d6961c..33ae1b03 100644 --- a/src/mp3/mp3.h +++ b/src/mp3/mp3.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mp3 types Enum(MP3_DecodeFlag) @@ -14,7 +14,7 @@ Struct(MP3_Result) b32 ok; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mp3 operations MP3_Result MP3_Decode(Arena *arena, String encoded, u32 sample_rate, MP3_DecodeFlag flags); diff --git a/src/mp3/mp3_mmf/mp3_mmf.c b/src/mp3/mp3_mmf/mp3_mmf.c index 139ac864..fcade995 100644 --- a/src/mp3/mp3_mmf/mp3_mmf.c +++ b/src/mp3/mp3_mmf/mp3_mmf.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode MP3_Result MP3_Decode(Arena *arena, String encoded, u32 sample_rate, MP3_DecodeFlag flags) diff --git a/src/mp3/mp3_mmf/mp3_mmf.h b/src/mp3/mp3_mmf/mp3_mmf.h index 9bbeaea7..a3a00f37 100644 --- a/src/mp3/mp3_mmf/mp3_mmf.h +++ b/src/mp3/mp3_mmf/mp3_mmf.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Windows headers #pragma warning(push, 0) diff --git a/src/net/net.c b/src/net/net.c index 6d925ab9..b6239bd7 100644 --- a/src/net/net.c +++ b/src/net/net.c @@ -12,7 +12,7 @@ * Challenges to verify receiving address. */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Host N_Host *N_AcquireHost(u16 listen_port) @@ -54,7 +54,7 @@ void N_ReleaseHost(N_Host *host) ReleaseArena(host->arena); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Channel u64 N_HashFromAddress(P_Address address) @@ -223,7 +223,7 @@ void N_ReleaseChannel(N_Channel *channel) host->first_free_channel = channel; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Message assembler u64 N_HashFromMsg(N_ChannelId channel_id, u64 msg_id) @@ -433,7 +433,7 @@ void N_MarkChunkReceived(N_MsgAssembler *ma, u64 chunk_id) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Packet N_SndPacket *N_PushSndPacket(N_Channel *channel, b32 is_reliable) @@ -481,7 +481,7 @@ N_SndPacket *N_PushSndPacket(N_Channel *channel, b32 is_reliable) return packet; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Host commands N_Cmd *N_PushCmd(N_Host *host) @@ -524,7 +524,7 @@ void N_Write(N_Host *host, N_ChannelId channel_id, String msg, N_WriteFlag flags cmd->write_reliable = flags & N_WriteFlag_Reliable; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Channel info i64 N_GetChannelLastRttNs(N_Host *host, N_ChannelId channel_id) @@ -533,7 +533,7 @@ i64 N_GetChannelLastRttNs(N_Host *host, N_ChannelId channel_id) return channel->last_heartbeat_rtt_ns; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Update begin /* Read incoming packets, update channels, and return events */ @@ -844,7 +844,7 @@ N_EventList N_BeginUpdate(Arena *arena, N_Host *host) return events; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Update end /* Process host cmds & send outgoing packets */ @@ -1025,7 +1025,7 @@ void N_EndUpdate(N_Host *host) EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ PushEvent N_Event *N_PushEvent(Arena *arena, N_EventList *list) diff --git a/src/net/net.h b/src/net/net.h index f107bd51..abfa976b 100644 --- a/src/net/net.h +++ b/src/net/net.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Channel ID Struct(N_ChannelId) @@ -7,7 +7,7 @@ Struct(N_ChannelId) u32 idx; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Host command types Enum(N_CmdKind) @@ -40,7 +40,7 @@ Struct(N_Cmd) N_Cmd *next; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Event types Enum(N_EventKind) @@ -72,7 +72,7 @@ Struct(N_ChannelLookupBin) struct N_Channel *last; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Packet types #define N_PacketMagic 0xd9e3b8b6 @@ -119,7 +119,7 @@ Struct(N_RcvBuffer) N_RcvPacket *last_packet; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Channel types Struct(N_Channel) @@ -173,7 +173,7 @@ Struct(N_ChannelList) N_ChannelNode *last; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Message asssembler types Struct(N_MsgAssembler) @@ -212,7 +212,7 @@ Struct(N_MsgAssemblerLookupBin) N_MsgAssembler *last; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Host types #define N_NumChannelLookupBins 512 @@ -254,18 +254,18 @@ Struct(N_Host) u64 bytes_sent; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Nil constants Readonly Global N_Channel N_nil_channel = { .valid = 0 }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Host initialization N_Host *N_AcquireHost(u16 listen_port); void N_ReleaseHost(N_Host *host); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Channel operations #define N_NilChannelId (N_ChannelId) { .gen = 0, .idx = 0 } @@ -281,7 +281,7 @@ N_ChannelList N_ChannelsFromId(Arena *arena, N_Host *host, N_ChannelId channel_i N_Channel *N_AcquireChannel(N_Host *host, P_Address address); void N_ReleaseChannel(N_Channel *channel); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Message assembler operations u64 N_HashFromMsg(N_ChannelId channel_id, u64 msg_id); @@ -292,12 +292,12 @@ void N_TouchMessageAssembler(N_MsgAssembler *ma, i64 now_ns); b32 N_IsChunkFilled(N_MsgAssembler *ma, u64 chunk_id); void N_MarkChunkReceived(N_MsgAssembler *ma, u64 chunk_id); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Packet operations N_SndPacket *N_PushSndPacket(N_Channel *channel, b32 is_reliable); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Host command operations N_Cmd *N_PushCmd(N_Host *host); @@ -305,12 +305,12 @@ void N_Connect(N_Host *host, P_Address connect_address); void N_Disconnect(N_Host *host, N_ChannelId channel_id); void N_Write(N_Host *host, N_ChannelId channel_id, String msg, N_WriteFlag flags); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Channel info operations i64 N_GetChannelLastRttNs(N_Host *host, N_ChannelId channel_id); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Update N_Event *N_PushEvent(Arena *arena, N_EventList *list); diff --git a/src/platform/platform.h b/src/platform/platform.h index 140c8501..accc3a32 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -1,11 +1,11 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Opaque types Struct(P_Watch); Struct(P_Window); Struct(P_Sock); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Time types Struct(P_DateTime) @@ -20,7 +20,7 @@ Struct(P_DateTime) u32 milliseconds; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File system types Struct(P_File) @@ -43,7 +43,7 @@ Struct(P_FileMap) b32 valid; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Window event types //- Button @@ -192,7 +192,7 @@ Struct(P_WindowEventArray) P_WindowEvent *events; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Window setting types /* NOTE: @@ -234,7 +234,7 @@ Struct(P_WindowSettings) i32 floating_height; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Address types Enum(P_AddressFamily) @@ -252,7 +252,7 @@ Struct(P_Address) u16 portnb; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sock types Struct(P_SockReadResult) @@ -262,7 +262,7 @@ Struct(P_SockReadResult) String data; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Message box types Enum(P_MessageBoxKind) @@ -273,17 +273,17 @@ Enum(P_MessageBoxKind) P_MessageBoxKind_Fatal }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Startup void P_Startup(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Time helper hooks P_DateTime P_LocalTime(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl File system hooks /* NOTE: File paths use forward slash '/' as delimiter */ @@ -309,14 +309,14 @@ void P_WriteFile(P_File file, String data); u64 P_GetFileSize(P_File file); P_FileTime P_GetFileTime(P_File file); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl File map hooks P_FileMap P_OpenFileMap(P_File file); void P_CloseFileMap(P_FileMap map); String P_GetFileMapData(P_FileMap map); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Window hooks P_Window *P_AcquireWindow(void); @@ -341,7 +341,7 @@ Vec2I32 P_GetWindowSize(P_Window *window); Vec2I32 P_GetWindowMonitorSize(P_Window *window); u64 P_GetInternalWindowHandle(P_Window *window); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Address helper hooks P_Address P_AddressFromString(String str); @@ -350,7 +350,7 @@ P_Address P_AddressFromPort(u16 port); String P_StringFromAddress(Arena *arena, P_Address address); b32 P_AddressIsEqual(P_Address a, P_Address b); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Sock hooks P_Sock *P_AcquireSock(u16 listen_port, u64 sndbuf_size, u64 rcvbuf_size); @@ -358,20 +358,20 @@ void P_ReleaseSock(P_Sock *sock); P_SockReadResult P_ReadSock(Arena *arena, P_Sock *sock); void P_WriteSock(P_Sock *sock, P_Address address, String data); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Util hooks void P_MessageBox(P_MessageBoxKind kind, String message); void P_SetClipboardText(String str); String P_GetClipboardText(Arena *arena); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Timer hooks Fence *P_GetTimerFence(); i64 P_GetCurrentTimerPeriodNs(); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdecl Sleep hooks void P_SleepPrecise(i64 sleep_time_ns); diff --git a/src/platform/platform_log.c b/src/platform/platform_log.c index 930faed3..9ed7b525 100644 --- a/src/platform/platform_log.c +++ b/src/platform/platform_log.c @@ -1,6 +1,6 @@ P_SharedLogState P_shared_log_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void P_StartupLog(void) @@ -24,7 +24,7 @@ void P_StartupLog(void) Atomic32Set(&ctx->initialized, 1); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Callback registration void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level) @@ -49,7 +49,7 @@ void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level) Unlock(&lock); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Append void P_LogAppend_(String msg) @@ -67,7 +67,7 @@ void P_LogAppend_(String msg) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Panic /* Panic log function is separate to enforce zero side effects other than @@ -85,7 +85,7 @@ void P_LogPanic_(String msg) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Logfv #if P_IncludeLogSourceLocation @@ -106,7 +106,7 @@ void P_LogFV_(i32 level, String fmt, va_list args) EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Logf #if P_IncludeLogSourceLocation @@ -127,7 +127,7 @@ void P_LogF_(i32 level, String fmt, ...) va_end(args); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Log #if P_IncludeLogSourceLocation diff --git a/src/platform/platform_log.h b/src/platform/platform_log.h index 4a10d981..0aa5de90 100644 --- a/src/platform/platform_log.h +++ b/src/platform/platform_log.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Log event types //- Event @@ -27,7 +27,7 @@ Struct(LogEventCallback) i32 level; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Logging levels #define P_LogLevel(l) (l <= P_LogLevel_CompTime) @@ -55,7 +55,7 @@ Struct(LogEventCallback) #define P_LogLevel_Debug 5 #define P_LogLevel_Count 6 -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types Struct(P_SharedLogState) @@ -71,7 +71,7 @@ Struct(P_SharedLogState) b32 file_valid; } P_shared_log_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Log level types Struct(P_LogLevelSettings) @@ -112,12 +112,12 @@ Global Readonly P_LogLevelSettings P_log_settings[P_LogLevel_Count] = { } }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void P_StartupLog(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Logging macros #if P_LogLevel(P_LogLevel_Critical) @@ -198,12 +198,12 @@ void P_StartupLog(void); # define P_LogDebugF(...) #endif -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Callback registration void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Raw log operations /* NOTE: Calling these functions rather than using the logging macros may result in logs that are compiled regardless of log level. */ diff --git a/src/platform/platform_win32/platform_win32.c b/src/platform/platform_win32/platform_win32.c index c648f515..6723e387 100644 --- a/src/platform/platform_win32/platform_win32.c +++ b/src/platform/platform_win32/platform_win32.c @@ -1,6 +1,6 @@ P_W32_SharedState P_W32_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Startup void P_Startup(void) @@ -104,7 +104,7 @@ void P_Startup(void) RunJob(P_W32_StartTimerSync, .pool = JobPool_Hyper, .flags = JobFlag_Dedicated); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 time P_DateTime P_W32_DateTimeFromWin32SystemTime(SYSTEMTIME st) @@ -122,7 +122,7 @@ P_DateTime P_W32_DateTimeFromWin32SystemTime(SYSTEMTIME st) }; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 file system String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src) @@ -154,7 +154,7 @@ String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 window P_W32_Window *P_W32_AcquireWindow(void) @@ -244,7 +244,7 @@ HWND P_W32_InitWindow(P_W32_Window *window) return hwnd; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 window settings void P_W32_UpdateWindowFromSystem(P_W32_Window *window) @@ -388,7 +388,7 @@ void P_W32_UpdateWindowFromSettings(P_W32_Window *window, P_WindowSettings *sett } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 window message processing JobDef(P_W32_StartWindowMsgProcessing, sig, id) @@ -775,7 +775,7 @@ LRESULT CALLBACK P_W32_Win32WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARA return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 Address P_W32_Address P_W32_Win32AddressFromPlatformAddress(P_Address addr) @@ -861,7 +861,7 @@ P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Timer job JobDef(P_W32_StartTimerSync, _, __) @@ -925,7 +925,7 @@ JobDef(P_W32_StartTimerSync, _, __) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Time hooks P_DateTime P_LocalTime(void) @@ -935,7 +935,7 @@ P_DateTime P_LocalTime(void) return P_W32_DateTimeFromWin32SystemTime(lt); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef File system hooks //- FIle system helpers @@ -1229,7 +1229,7 @@ P_FileTime P_GetFileTime(P_File file) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef File map hooks P_FileMap P_OpenFileMap(P_File file) @@ -1297,7 +1297,7 @@ String P_GetFileMapData(P_FileMap map) return map.mapped_memory; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Window hooks P_Window *P_AcquireWindow(void) @@ -1441,7 +1441,7 @@ u64 P_GetInternalWindowHandle(P_Window *p_window) return (u64)window->hwnd; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Address helper hooks P_Address P_AddressFromIpPortCstr(char *ip_cstr, char *port_cstr) @@ -1643,7 +1643,7 @@ b32 P_AddressIsEqual(P_Address a, P_Address b) return EqStruct(&a, &b); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Sock hooks P_Sock *P_AcquireSock(u16 listen_port, u64 sndbuf_size, u64 rcvbuf_size) @@ -1755,7 +1755,7 @@ void P_WriteSock(P_Sock *sock, P_Address address, String data) #endif } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Utility hooks void P_MessageBox(P_MessageBoxKind kind, String message) @@ -1837,7 +1837,7 @@ String P_GetClipboardText(Arena *arena) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Timer hooks Fence *P_GetTimerFence() @@ -1852,7 +1852,7 @@ i64 P_GetCurrentTimerPeriodNs() return Atomic64Fetch(&g->average_timer_period_ns.v); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Sleep hooks void P_SleepPrecise(i64 sleep_time_ns) diff --git a/src/platform/platform_win32/platform_win32.h b/src/platform/platform_win32/platform_win32.h index f43a9d85..2c4b67df 100644 --- a/src/platform/platform_win32/platform_win32.h +++ b/src/platform/platform_win32/platform_win32.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 libs #pragma warning(push, 0) @@ -23,7 +23,7 @@ #pragma comment(lib, "avrt") #pragma comment(lib, "ws2_32.lib") -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Window types Enum(P_W32_CursorFlag) @@ -72,7 +72,7 @@ Struct(P_W32_Window) P_W32_Window *next_free; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Watch types Struct(P_W32_Watch) @@ -83,7 +83,7 @@ Struct(P_W32_Watch) u8 results_buff[Kibi(64)]; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Address types Struct(P_W32_Address) @@ -99,7 +99,7 @@ Struct(P_W32_Address) }; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sock types Struct(P_W32_Sock) @@ -108,7 +108,7 @@ Struct(P_W32_Sock) P_W32_Sock *next_free; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define P_W32_WindowClassName L"power_play_window_class" @@ -142,30 +142,30 @@ Struct(P_W32_SharedState) Atomic64Padded average_timer_period_ns; } extern P_W32_shared_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Time operations P_DateTime P_W32_DateTimeFromWin32SystemTime(SYSTEMTIME st); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ File system operations String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Window operations P_W32_Window *P_W32_AcquireWindow(void); void P_W32_ReleaseWindow(P_W32_Window *window); HWND P_W32_InitWindow(P_W32_Window *window); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Window settings void P_W32_UpdateWindowFromSystem(P_W32_Window *window); void P_W32_UpdateWindowFromSettings(P_W32_Window *window, P_WindowSettings *settings); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Window message processing JobDecl(P_W32_StartWindowMsgProcessing, { P_W32_Window *window; }); @@ -173,14 +173,14 @@ void P_W32_ProcessWindowEvent(P_W32_Window *window, P_WindowEvent event); void P_W32_WakeWindow(P_W32_Window *window); LRESULT CALLBACK P_W32_Win32WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Address operations P_W32_Address P_W32_Win32AddressFromPlatformAddress(P_Address addr); P_W32_Address P_W32_ConvertAnyaddrToLocalhost(P_W32_Address addr); P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Timer job JobDecl(P_W32_StartTimerSync, EmptySig); diff --git a/src/playback/playback_wasapi/playback_wasapi.c b/src/playback/playback_wasapi/playback_wasapi.c index 8ee38515..a34a1b6e 100644 --- a/src/playback/playback_wasapi/playback_wasapi.c +++ b/src/playback/playback_wasapi/playback_wasapi.c @@ -6,7 +6,7 @@ PB_WSP_SharedState PB_WSP_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void PB_Startup(void) @@ -120,7 +120,7 @@ void PB_WSP_InitializeWasapi(void) IAudioClient_GetBufferSize(g->client, &g->buffer_frames); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Wasapi update PB_WSP_Buff PB_WSP_BeginUpdate(void) @@ -178,7 +178,7 @@ void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src) __profframe("Audio"); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Playback job JobDef(PB_WSP_Playback, UNUSED sig, UNUSED id) diff --git a/src/playback/playback_wasapi/playback_wasapi.h b/src/playback/playback_wasapi/playback_wasapi.h index e5a8d02f..75ceb450 100644 --- a/src/playback/playback_wasapi/playback_wasapi.h +++ b/src/playback/playback_wasapi/playback_wasapi.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 libs #pragma warning(push, 0) @@ -12,7 +12,7 @@ DEFINE_GUID(IID_IAudioClient, 0x1cb9ad4c, 0xdbfa, 0x4c32, 0xb1, 0x78, 0x DEFINE_GUID(IID_IAudioClient3, 0x7ed4ee07, 0x8e67, 0x4cd4, 0x8c, 0x1a, 0x2b, 0x7a, 0x59, 0x87, 0xad, 0x42); DEFINE_GUID(IID_IAudioRenderClient, 0xf294acfc, 0x3146, 0x4483, 0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Wasapi buffer types Struct(PB_WSP_Buff) @@ -21,7 +21,7 @@ Struct(PB_WSP_Buff) u8 *frames; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types Struct(PB_WSP_SharedState) @@ -36,19 +36,19 @@ Struct(PB_WSP_SharedState) u32 shutdown_jobs_count; } extern PB_WSP_shared_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Wasapi startup void PB_WSP_InitializeWasapi(void); ExitFuncDef(PB_WSP_Shutdown); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Playback update PB_WSP_Buff PB_WSP_BeginUpdate(void); void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Playback job JobDecl(PB_WSP_Playback, EmptySig); diff --git a/src/pp/pp.c b/src/pp/pp.c index 2f82c001..f28a914a 100644 --- a/src/pp/pp.c +++ b/src/pp/pp.c @@ -1,6 +1,6 @@ SharedUserState shared_user_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void StartupUser(void) @@ -46,7 +46,7 @@ void StartupUser(void) OnExit(&ShutdownUser); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Shutdown ExitFuncDef(ShutdownUser) @@ -58,7 +58,7 @@ ExitFuncDef(ShutdownUser) P_ReleaseWindow(g->window); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Debug draw //- Draw xform @@ -232,7 +232,7 @@ String DebugStringFromEntity(Arena *arena, Entity *ent) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Console //- Console log callback @@ -377,7 +377,7 @@ void DrawDebugConsole(i32 level, b32 minimized) #endif } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Render buffers //- Gbuffer @@ -393,7 +393,7 @@ GPU_Resource *AcquireGbuffer(GPU_Format format, Vec2I32 size) return GPU_AcquireResource(desc); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sort entities MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _) @@ -435,7 +435,7 @@ MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ User update void UpdateUser(P_Window *window) @@ -451,7 +451,7 @@ void UpdateUser(P_Window *window) //- Begin UI UI_BeginBuild(); - UI_Box *pp_root_box = UI_BuildBox(UI_Flag_DrawImage, UI_NilKey); + UI_Box *pp_root_box = UI_BuildBox(UI_BoxFlag_DrawImage, UI_NilKey); UI_Push(Parent, pp_root_box); //- Init render data buffers @@ -1996,7 +1996,10 @@ void UpdateUser(P_Window *window) GPU_MemoryInfo vram = GPU_QueryMemoryInfo(); - //////////////////////////////// + ////////////////////////////// + //- Debug draw + + //~ Draw global debug info /* FIXME: Enable this */ #if 1 @@ -2012,7 +2015,7 @@ void UpdateUser(P_Window *window) UI_Push(Parent, dbg_box); UI_Push(Width, UI_TextSize(0)); UI_Push(Height, UI_TextSize(0)); - UI_Push(BackgroundColor, Color_White); + UI_Push(BackgroundColor, Rgba32F(0.3, 0.3, 0.3, 1)); UI_BuildLabelF("blended world entities: %F/%F", FmtUint(g->ss_blended->num_ents_allocated), FmtUint(g->ss_blended->num_ents_reserved)); UI_BuildSeparator(); @@ -2238,8 +2241,9 @@ void UpdateUser(P_Window *window) #endif } - //////////////////////////////// - //~ Render + ////////////////////////////// + //- Render + Rect ui_viewport = RectFromVec2(VEC2(0, 0), VEC2(g->ui_size.x, g->ui_size.y)); Rect render_viewport = RectFromVec2(VEC2(0, 0), VEC2(g->render_size.x, g->render_size.y)); GPU_QueueKind gpu_render_queue = GPU_QueueKind_Direct; @@ -2550,8 +2554,8 @@ void UpdateUser(P_Window *window) UI_SetDisplayImage(pp_root_box, g->ui_target); GPU_Resource *ui_render = UI_EndBuild(ui_viewport); - //////////////////////////////// - //~ Present + ////////////////////////////// + //- Present Vec2 backbuffer_dst_f = MulXformV2(g->ui_to_screen_xf, VEC2(0, 0)); Vec2I32 backbuffer_dst = VEC2I32(RoundF32ToI32(backbuffer_dst_f.x), RoundF32ToI32(backbuffer_dst_f.y)); @@ -2561,7 +2565,7 @@ void UpdateUser(P_Window *window) EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ User update job JobDef(UpdateUserOrSleep, UNUSED sig, UNUSED id) @@ -2589,7 +2593,7 @@ JobDef(UpdateUserOrSleep, UNUSED sig, UNUSED id) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Generate user input cmds void GenerateuserInputCmds(Client *user_input_client, u64 tick) @@ -2629,7 +2633,7 @@ void GenerateuserInputCmds(Client *user_input_client, u64 tick) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sim update JobDef(UpdateSim, UNUSED sig, UNUSED id) diff --git a/src/pp/pp.h b/src/pp/pp.h index 262cf6ba..fc517e12 100644 --- a/src/pp/pp.h +++ b/src/pp/pp.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Binds //- Bind kinds @@ -95,7 +95,7 @@ Global Readonly BindKind g_binds[P_Btn_Count] = { #endif }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Stats Struct(SecondsStat) @@ -105,7 +105,7 @@ Struct(SecondsStat) u64 last_second; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Console log Struct(ConsoleLog) @@ -120,7 +120,7 @@ Struct(ConsoleLog) ConsoleLog *next; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sim decode queue Struct(DecodeQueueNode) @@ -138,7 +138,7 @@ Struct(DecodeQueue) DecodeQueueNode *last; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types Struct(BindState) @@ -271,55 +271,55 @@ Struct(SharedUserState) Vec2 focus_send; } extern shared_user_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void StartupUser(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Shutdown ExitFuncDef(ShutdownUser); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Debug draw operations void DrawDebugXform(Xform xf, u32 color_x, u32 color_y); void DrawDebugMovement(Entity *ent); String DebugStringFromEntity(Arena *arena, Entity *ent); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Console draw operations P_LogEventCallbackFuncDef(ConsoleLogCallback, log); void DrawDebugConsole(i32 level, b32 minimized); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Gpu buffer helpers GPU_Resource *AcquireGbuffer(GPU_Format format, Vec2I32 size); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Entity sorting MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ User update void UpdateUser(P_Window *window); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ User update job JobDecl(UpdateUserOrSleep, EmptySig); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ User input cmds void GenerateuserInputCmds(Client *user_input_client, u64 tick); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sim update job JobDecl(UpdateSim, EmptySig); diff --git a/src/pp/pp_draw.gpu b/src/pp/pp_draw.gpu index 576d2282..32cb8769 100644 --- a/src/pp/pp_draw.gpu +++ b/src/pp/pp_draw.gpu @@ -5,7 +5,7 @@ ConstantBuffer ui_blit_sig : register (b0); ConstantBuffer ui_rect_sig : register (b0); ConstantBuffer ui_shape_sig : register (b0); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Material Struct(MaterialPS_Input) @@ -122,7 +122,7 @@ MaterialPS_Output PSDef(MaterialPS, MaterialPS_Input input) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Flood //- Compute shader @@ -187,7 +187,7 @@ void CSDef(FloodCS, Semantic(Vec3U32, sv_dispatchthreadid)) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Shade #define LightSamples 16 @@ -294,7 +294,7 @@ void CSDef(ShadeCS, Semantic(Vec3U32, sv_dispatchthreadid)) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ui Blit Struct(UiBlitPS_Input) @@ -365,7 +365,7 @@ UiBlitPS_Output PSDef(UiBlitPS, UiBlitPS_Input input) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ui rect Struct(UiRectPS_Input) @@ -426,7 +426,7 @@ UiRectPS_Output PSDef(UiRectPS, UiRectPS_Input input) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ui shape Struct(UiShapePS_Input) diff --git a/src/pp/pp_draw.h b/src/pp/pp_draw.h index 8af27767..22854b4b 100644 --- a/src/pp/pp_draw.h +++ b/src/pp/pp_draw.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Material types Struct(MaterialSig) @@ -51,7 +51,7 @@ Struct(MaterialGrid) .bg0_srgb = Color_White \ } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Flood types Struct(FloodSig) @@ -70,7 +70,7 @@ Struct(FloodSig) }; AssertRootConst(FloodSig, 8); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Shade types #define ShadeFlag_None (0 << 0) @@ -103,7 +103,7 @@ Struct(ShadeSig) }; AssertRootConst(ShadeSig, 20); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ui blit types #define UiBlitFlag_None (0) @@ -129,7 +129,7 @@ Struct(UiBlitSig) AssertRootConst(UiBlitSig, 24); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ui rect types Struct(UiRectSig) @@ -154,7 +154,7 @@ Struct(UiRectInstance) u32 tint_srgb; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Ui shape types Struct(UiShapeSig) diff --git a/src/pp/pp_ent.c b/src/pp/pp_ent.c index 336bde5f..d5ed3e3e 100644 --- a/src/pp/pp_ent.c +++ b/src/pp/pp_ent.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Acquire Entity *AcquireRaw(Snapshot *ss, Entity *parent, EntityId id) @@ -78,7 +78,7 @@ Entity *AcquireSyncDst(Entity *parent, EntityId ent_id, EntityId owner_id) return e; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Release void ReleaseRaw(Entity *ent) @@ -145,7 +145,7 @@ void ReleaseAllWithProp(Snapshot *ss, Prop prop) EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Activate void Activate(Entity *ent, u64 current_tick) @@ -155,7 +155,7 @@ void Activate(Entity *ent, u64 current_tick) ++ent->continuity_gen; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Entity id u32 IndexFromEntity(Snapshot *ss, Entity *ent) @@ -321,7 +321,7 @@ EntityId TileChunkIdFromIndex(Vec2I32 chunk_index) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Query Entity *FirstWithProp(Snapshot *ss, Prop prop) @@ -366,7 +366,7 @@ Entity *FirstWithAllProps(Snapshot *ss, PropArray props) return NilEntity(); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tree void Link(Entity *ent, Entity *parent) @@ -438,7 +438,7 @@ void Unlink(Entity *ent) ent->next = NilEntityId; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Xform void MarkChildXformsDirty(Snapshot *ss, Entity *ent) @@ -549,7 +549,7 @@ void SetLocalXform(Entity *ent, Xform xf) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Movement void SetLinearVelocity(Entity *ent, Vec2 velocity) @@ -623,7 +623,7 @@ void ApplyTorque(Entity *ent, f32 torque) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tile Entity *TileChunkFromChunkIndex(Snapshot *ss, Vec2I32 chunk_index) @@ -646,7 +646,7 @@ TileKind TileKindFromChunk(Entity *chunk_ent, Vec2I32 local_tile_index) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Lerp void LerpEntity(Entity *e, Entity *e0, Entity *e1, f64 blend) @@ -687,7 +687,7 @@ void LerpEntity(Entity *e, Entity *e0, Entity *e1, f64 blend) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sync /* Walks a local & remote ent tree and allocates any missing net dst ents from remote src ents */ @@ -744,7 +744,7 @@ void SyncEntity(Entity *local, Entity *remote) #if 1 -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Encode void EncodeEntity(BB_Writer *bw, Entity *e0, Entity *e1) @@ -772,7 +772,7 @@ void EncodeEntity(BB_Writer *bw, Entity *e0, Entity *e1) e1->ss = ss; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode void DecodeEntity(BB_Reader *br, Entity *e) @@ -798,7 +798,7 @@ void DecodeEntity(BB_Reader *br, Entity *e) #else -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Encode void EncodeEntity(BB_Writer *bw, Entity *e0, Entity *e1) @@ -834,7 +834,7 @@ void EncodeEntity(BB_Writer *bw, Entity *e0, Entity *e1) e1->ss = ss; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode void DecodeEntity(BB_Reader *br, Entity *e) diff --git a/src/pp/pp_ent.h b/src/pp/pp_ent.h index bd18f2a8..0dd27a84 100644 --- a/src/pp/pp_ent.h +++ b/src/pp/pp_ent.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Entity props Enum(Prop) @@ -61,7 +61,7 @@ Enum(Prop) Prop_Count }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Entity Struct(Entity) @@ -393,7 +393,7 @@ Inline Entity *NilEntity(void) return *_g_sim_ent_nil; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Id types #define NilEntityId ((EntityId) { UID(0, 0) }) @@ -404,7 +404,7 @@ Inline Entity *NilEntity(void) #define ContactBasisUid (UID(0x6a2a5d2dbecf534f, 0x0a8ca7c372a015af)) #define CollisionDebugBasisUid (UID(0x302c01182013bb02, 0x570bd270399d11a5)) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Id helpers Inline b32 EqId(EntityId a, EntityId b) @@ -417,7 +417,7 @@ Inline b32 IsNilId(EntityId id) return EqUid(id.uid, NilEntityId.uid); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Property helpers Inline void EnableProp(Entity *ent, Prop prop) @@ -471,7 +471,7 @@ Inline b32 ShouldSimulate(Entity *ent) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Acquire operations Entity *AcquireRaw(Snapshot *ss, Entity *parent, EntityId id); @@ -481,19 +481,19 @@ Entity *AcquireSyncSrc(Entity *parent); Entity *AcquireSyncSrcWithId(Entity *parent, EntityId id); Entity *AcquireSyncDst(Entity *parent, EntityId ent_id, EntityId owner_id); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Release operations void ReleaseRaw(Entity *ent); void Release(Entity *ent); void ReleaseAllWithProp(Snapshot *ss, Prop prop); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Activate operations void Activate(Entity *ent, u64 current_tick); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Id operations u32 IndexFromEntity(Snapshot *ss, Entity *ent); @@ -506,19 +506,19 @@ EntityId ContactConstraintIdFromContactingIds(EntityId player_id, EntityId id0, EntityId CollisionDebugIdFromIds(EntityId player_id, EntityId id0, EntityId id1); EntityId TileChunkIdFromIndex(Vec2I32 chunk_start); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Query operations Entity *FirstWithProp(Snapshot *ss, Prop prop); Entity *FirstWithAllProps(Snapshot *ss, PropArray props); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tree operations void Link(Entity *parent, Entity *child); void Unlink(Entity *ent); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Xform operations void MarkChildXformsDirty(Snapshot *ss, Entity *ent); @@ -528,7 +528,7 @@ Xform LocalXformFromEntity(Entity *ent); void SetXform(Entity *ent, Xform xf); void SetLocalXform(Entity *ent, Xform xf); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Movement operations void SetLinearVelocity(Entity *ent, Vec2 velocity); @@ -539,30 +539,30 @@ void ApplyForceToCenter(Entity *ent, Vec2 force); void ApplyAngularImpulse(Entity *ent, f32 impulse); void ApplyTorque(Entity *ent, f32 torque); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tile operations Entity *TileChunkFromChunkIndex(Snapshot *ss, Vec2I32 chunk_index); Entity *TileChunkFromWorldTileIndex(Snapshot *ss, Vec2I32 world_tile_index); TileKind TileKindFromChunk(Entity *chunk_ent, Vec2I32 local_tile_index); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Lerp operations void LerpEntity(Entity *e, Entity *e0, Entity *e1, f64 blend); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sync operations void CreateMissingEntitiesFromSnapshots(Entity *local_parent, Entity *remote, EntityId remote_player); void SyncEntity(Entity *local, Entity *remote); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Encode void EncodeEntity(BB_Writer *bw, Entity *e0, Entity *e1); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Decode void DecodeEntity(BB_Reader *br, Entity *e); diff --git a/src/pp/pp_phys.c b/src/pp/pp_phys.c index 65b206a4..c6311353 100644 --- a/src/pp/pp_phys.c +++ b/src/pp/pp_phys.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Contact b32 CanEntitiesContact(Entity *e0, Entity *e1) @@ -589,7 +589,7 @@ void SolveContacts(PhysStepCtx *ctx, f32 dt, b32 apply_bias) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Motor joint MotorJointDesc CreateMotorJointDef(void) @@ -788,7 +788,7 @@ void SolveMotorJoints(PhysStepCtx *ctx, f32 dt) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mouse joint MouseJointDesc CreateMouseJointDef(void) @@ -962,7 +962,7 @@ void SolveMouseJoints(PhysStepCtx *ctx, f32 dt) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Weld joint WeldJointDesc CreateWeldJointDef(void) @@ -1147,7 +1147,7 @@ void SolveWeldJoints(PhysStepCtx *ctx, f32 dt) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Integration Xform GetDerivedEntityXform(Entity *ent, f32 dt) @@ -1222,7 +1222,7 @@ void IntegrateVelocities(PhysStepCtx *ctx, f32 dt) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Earliest time of impact f32 DetermineEarliestToi(PhysStepCtx *ctx, f32 step_dt, f32 tolerance, u32 max_iterations) @@ -1275,7 +1275,7 @@ f32 DetermineEarliestToi(PhysStepCtx *ctx, f32 step_dt, f32 tolerance, u32 max_i return smallest_t; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Spatial void UpdateAabbs(PhysStepCtx *ctx) @@ -1302,7 +1302,7 @@ void UpdateAabbs(PhysStepCtx *ctx) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Step /* Returns phys iteration to be fed into next step. Supplied iteration must be > 0. */ diff --git a/src/pp/pp_phys.h b/src/pp/pp_phys.h index 68f77812..6b5dbe4c 100644 --- a/src/pp/pp_phys.h +++ b/src/pp/pp_phys.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Collision data types #define ContactSpringHz 25 @@ -20,7 +20,7 @@ struct SimStepCtx; #define CollisionCallbackFuncDef(name, arg_collision_data, arg_sim_step_ctx) b32 name(CollisionData *arg_collision_data, struct SimStepCtx *arg_sim_step_ctx) typedef CollisionCallbackFuncDef(CollisionCallbackFunc, collision_data, ctx); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Step ctx /* Structure containing data used for a single physics step */ @@ -30,7 +30,7 @@ Struct(PhysStepCtx) CollisionCallbackFunc *collision_callback; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Contact types Struct(ContactPoint) @@ -97,7 +97,7 @@ Struct(ContactDebugData) Xform xf1; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Motor joint types Struct(MotorJointDesc) @@ -132,7 +132,7 @@ Struct(MotorJoint) f32 angular_mass; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mouse joint types Struct(MouseJointDesc) @@ -167,7 +167,7 @@ Struct(MouseJoint) Xform linear_mass_xf; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Weld joint types Struct(WeldJointDesc) @@ -207,7 +207,7 @@ Struct(WeldJoint) f32 angular_impulse1; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Contact operations b32 CanEntitiesContact(struct Entity *e0, struct Entity *e1); @@ -216,7 +216,7 @@ void PrepareContacts(PhysStepCtx *ctx, u64 phys_iteration); void WarmStartContacts(PhysStepCtx *ctx); void SolveContacts(PhysStepCtx *ctx, f32 dt, b32 apply_bias); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Motor joint operations MotorJointDesc CreateMotorJointDef(void); @@ -225,7 +225,7 @@ void PrepareMotorJoints(PhysStepCtx *ctx); void WarmStartMotorJoints(PhysStepCtx *ctx); void SolveMotorJoints(PhysStepCtx *ctx, f32 dt); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Mouse joint operations MouseJointDesc CreateMouseJointDef(void); @@ -234,7 +234,7 @@ void PrepareMouseJoints(PhysStepCtx *ctx); void WarmStartMouseJoints(PhysStepCtx *ctx); void SolveMouseJoints(PhysStepCtx *ctx, f32 dt); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Weld joint operations WeldJointDesc CreateWeldJointDef(void); @@ -243,7 +243,7 @@ void PrepareWeldJoints(PhysStepCtx *ctx); void WarmStartWeldJoints(PhysStepCtx *ctx); void SolveWeldJoints(PhysStepCtx *ctx, f32 dt); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Integration operations struct Entity; @@ -251,17 +251,17 @@ Xform GetDerivedEntityXform(struct Entity *ent, f32 dt); void IntegrateForces(PhysStepCtx *ctx, f32 dt); void IntegrateVelocities(PhysStepCtx *ctx, f32 dt); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Time of impact operations f32 DetermineEarliestToi(PhysStepCtx *ctx, f32 step_dt, f32 tolerance, u32 max_iterations); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Spatial operations void UpdateAabbs(PhysStepCtx *ctx); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Step void StepPhys(PhysStepCtx *ctx, f32 timestep); diff --git a/src/pp/pp_sim.c b/src/pp/pp_sim.c index 08621c2c..51ccde0b 100644 --- a/src/pp/pp_sim.c +++ b/src/pp/pp_sim.c @@ -24,7 +24,7 @@ * is used when working in contexts where id is irrelevant. */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup SharedSimCtx shared_sim_ctx = ZI; @@ -71,7 +71,7 @@ void StartupSim(void) SetArenaReadonly(g->nil_arena); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Acquire client store ClientStore *AcquireClientStore(void) @@ -106,7 +106,7 @@ void ReleaseClientStore(ClientStore *store) ReleaseArena(store->arena); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Acquire client Client *AcquireClient(ClientStore *store) @@ -169,7 +169,7 @@ void ReleaseClient(Client *client) ReleaseArena(client->snapshots_arena); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Client lookup u64 ClientChannelHashFromChannelId(N_ChannelId channel_id) @@ -262,7 +262,7 @@ Client *ClientFromHandle(ClientStore *store, ClientHandle handle) return NilClient(); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Acquire snapshot /* Produces a new snapshot at `tick` with data copied from `src` snapshot. */ @@ -526,7 +526,7 @@ void ReleaseSnapshotsInRange(Client *client, u64 start, u64 end) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot lookup Snapshot *SnapshotFromTick(Client *client, u64 tick) @@ -588,7 +588,7 @@ Snapshot *SnapshotFromClosestTickGte(Client *client, u64 tick) return ss; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tile Vec2I32 WorldTileIndexFromPos(Vec2 pos) @@ -658,7 +658,7 @@ void SetSnapshotTile(Snapshot *ss, Vec2I32 world_tile_index, TileKind tile_kind) chunk_ent->tile_chunk_tiles[local_index.x + (local_index.y * SIM_TILES_PER_CHUNK_SQRT)] = tile_kind; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot lerp Snapshot *AcquireSnapshotFromLerp(Client *client, Snapshot *ss0, Snapshot *ss1, f64 blend) @@ -715,7 +715,7 @@ Snapshot *AcquireSnapshotFromLerp(Client *client, Snapshot *ss0, Snapshot *ss1, return ss; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot sync /* Syncs entity data between snapshots */ @@ -782,7 +782,7 @@ void SyncSnapshotEntities(Snapshot *local_ss, Snapshot *remote_ss, EntityId remo #if 1 -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot encode void EncodeSnapshot(BB_Writer *bw, Client *receiver, Snapshot *ss0, Snapshot *ss1) @@ -859,7 +859,7 @@ void EncodeSnapshot(BB_Writer *bw, Client *receiver, Snapshot *ss0, Snapshot *ss BB_WriteDebugMarker(bw, Lit("SNAPSHOT END")); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot decode void DecodeSnapshot(BB_Reader *br, Snapshot *ss) @@ -951,7 +951,7 @@ void DecodeSnapshot(BB_Reader *br, Snapshot *ss) #else -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot encode void EncodeSnapshot(BB_Writer *bw, Client *receiver, Snapshot *ss0, Snapshot *ss1) @@ -1021,7 +1021,7 @@ void EncodeSnapshot(BB_Writer *bw, Client *receiver, Snapshot *ss0, Snapshot *ss } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot decode struct sim_ent_decode_node diff --git a/src/pp/pp_sim.h b/src/pp/pp_sim.h index dce320af..8d17249c 100644 --- a/src/pp/pp_sim.h +++ b/src/pp/pp_sim.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Id types Struct(EntityId) @@ -15,7 +15,7 @@ Struct(ClientHandle) #define NilClientHandle ((ClientHandle) { .gen = 0, .idx = 0 }) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Client store types Struct(ClientLookupBin) @@ -47,7 +47,7 @@ Inline ClientStore *sim_client_store_nil(void) return *_g_sim_client_store_nil; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Client types Struct(SnapshotLookupBin) @@ -110,7 +110,7 @@ Inline b32 EqClientHandle(ClientHandle a, ClientHandle b) return a.gen == b.gen && a.idx == b.idx; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Layer types /* Absolute layers */ @@ -124,7 +124,7 @@ Inline b32 EqClientHandle(ClientHandle a, ClientHandle b) #define Layer_DefaultRelative (0) #define Layer_RelativeWeapon (1) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Control types Enum(ControlFlag) @@ -162,7 +162,7 @@ Enum(CmdKind) CmdKind_Chat }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tile types Enum(TileKind) @@ -174,7 +174,7 @@ Enum(TileKind) }; StaticAssert(TileKind_Count < 256); /* Tile kind must fit in 8 bits */ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot types Enum(SyncFlag) @@ -226,7 +226,7 @@ Inline Snapshot *NilSnapshot(void) return *_g_sim_snapshot_nil; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define ClientLookupBinsCount 127 @@ -254,24 +254,24 @@ extern Readonly Client **_g_sim_client_nil; extern Readonly Snapshot **_g_sim_snapshot_nil; extern Readonly struct Entity **_g_sim_ent_nil; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void StartupSim(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Client store acquire operations ClientStore *AcquireClientStore(void); void ReleaseClientStore(ClientStore *store); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Client acquire operations Client *AcquireClient(ClientStore *store); void ReleaseClient(Client *client); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Client lookup operations u64 ClientChannelHashFromChannelId(N_ChannelId channel_id); @@ -279,21 +279,21 @@ void SetClientChannelId(Client *client, N_ChannelId channel_id); Client *ClientFromChannelId(ClientStore *store, N_ChannelId channel_id); Client *ClientFromHandle(ClientStore *store, ClientHandle handle); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot acquire operations Snapshot *AcquireSnapshot(Client *client, Snapshot *src, u64 tick); void ReleaseSnapshot(Snapshot *ss); void ReleaseSnapshotsInRange(Client *client, u64 start, u64 end); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot lookup operations Snapshot *SnapshotFromTick(Client *client, u64 tick); Snapshot *SnapshotFromClosestTickLte(Client *client, u64 tick); Snapshot *SnapshotFromClosestTickGte(Client *client, u64 tick); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tile operations Vec2I32 WorldTileIndexFromPos(Vec2 pos); @@ -303,22 +303,22 @@ Vec2I32 WorldTileIndexFromLocalTileIndex(Vec2I32 tile_chunk_index, Vec2I32 local Vec2I32 TileChunkIndexFromWorldTileIndex(Vec2I32 world_tile_index); void SetSnapshotTile(Snapshot *ss, Vec2I32 world_tile_index, TileKind tile_kind); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot lerp operations Snapshot *AcquireSnapshotFromLerp(Client *client, Snapshot *ss0, Snapshot *ss1, f64 blend); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot sync operations void SyncSnapshotEntities(Snapshot *local_ss, Snapshot *remote_ss, EntityId remote_player, u32 sync_flags); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot encode operations void EncodeSnapshot(BB_Writer *bw, Client *receiver, Snapshot *ss0, Snapshot *ss1); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Snapshot decode operations void DecodeSnapshot(BB_Reader *br, Snapshot *ss); diff --git a/src/pp/pp_space.c b/src/pp/pp_space.c index c98f5865..e21b487b 100644 --- a/src/pp/pp_space.c +++ b/src/pp/pp_space.c @@ -4,7 +4,7 @@ Readonly SpaceEntry _g_space_entry_nil = ZI; Readonly SpaceCell _g_space_cell_nil = ZI; Readonly Space _g_space_nil = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Space /* NOTE: @@ -63,7 +63,7 @@ Space *SpaceFromEntry(SpaceEntry *entry) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Cell Vec2I32 SpaceCellCoordsFromWorldCoords(f32 cell_size, Vec2 world_pos) @@ -285,7 +285,7 @@ void ReleaseSpaceCellNode(SpaceCellNode *n) space->first_free_cell_node = n; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Entry SpaceEntry *SpaceEntryFromHandle(Space *space, SpaceEntryHandle handle) @@ -399,7 +399,7 @@ void UpdateSpaceEntryAabb(SpaceEntry *entry, Aabb new_aabb) entry->aabb = new_aabb; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Iter SpaceIter BeginSpaceIterAabb(Space *space, Aabb aabb) diff --git a/src/pp/pp_space.h b/src/pp/pp_space.h index bc936adf..15f64258 100644 --- a/src/pp/pp_space.h +++ b/src/pp/pp_space.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Space entry types Struct(SpaceEntryHandle) @@ -21,7 +21,7 @@ Struct(SpaceEntry) SpaceEntry *next_free; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Space cell types /* Links a cell to a entry. @@ -63,7 +63,7 @@ Struct(SpaceCellBin) SpaceCell *last_cell; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Space types Struct(Space) @@ -94,7 +94,7 @@ Struct(SpaceIter) SpaceCellNode *prev; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Nil types /* Offset in bytes from start of space struct to start of entry array (assume adjacently allocated) */ @@ -105,7 +105,7 @@ extern Readonly SpaceEntry _g_space_entry_nil; extern Readonly SpaceCell _g_space_cell_nil; extern Readonly Space _g_space_nil; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Nil helpers Inline SpaceEntry *NilSpaceEntry(void) @@ -126,7 +126,7 @@ Inline Space *NilSpace(void) return &_g_space_nil; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Space Space *AcquireSpace(f32 cell_size, u32 num_bins_sqrt); @@ -134,7 +134,7 @@ void ReleaseSpace(Space *space); void ResetSpace(Space *space); Space *SpaceFromEntry(SpaceEntry *entry); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Cell Vec2I32 SpaceCellCoordsFromWorldCoords(f32 cell_size, Vec2 world_pos); @@ -143,7 +143,7 @@ SpaceCell *SpaceCellFromCellPos(Space *space, Vec2I32 cell_pos); void AcquireSpaceCellNode(Vec2I32 cell_pos, SpaceEntry *entry); void ReleaseSpaceCellNode(SpaceCellNode *n); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Entry SpaceEntry *SpaceEntryFromHandle(Space *space, SpaceEntryHandle handle); @@ -151,7 +151,7 @@ SpaceEntry *AcquireSpaceEntry(Space *space, EntityId ent); void ReleaseSpaceEntry(SpaceEntry *entry); void UpdateSpaceEntryAabb(SpaceEntry *entry, Aabb new_aabb); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Iter SpaceIter BeginSpaceIterAabb(Space *space, Aabb aabb); diff --git a/src/pp/pp_step.c b/src/pp/pp_step.c index 8ef1f31d..14d35070 100644 --- a/src/pp/pp_step.c +++ b/src/pp/pp_step.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sim accel SimAccel AcquireSimAccel(void) @@ -28,7 +28,7 @@ void ResetSimAccel(Snapshot *ss, SimAccel *accel) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Spawn test operations /* TODO: Remove this */ @@ -408,7 +408,7 @@ void ClearLevelTest(SimStepCtx *ctx) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tile test operations MergesortCompareFuncDef(SortTileXCmp, arg_a, arg_b, _) @@ -736,7 +736,7 @@ void GenerateTestWalls(Snapshot *world) EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ On collision CollisionCallbackFuncDef(OnEntityCollision, data, step_ctx) @@ -872,7 +872,7 @@ CollisionCallbackFuncDef(OnEntityCollision, data, step_ctx) return skip_solve; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Step void StepSim(SimStepCtx *ctx) diff --git a/src/pp/pp_step.h b/src/pp/pp_step.h index 16f451f9..2bee3943 100644 --- a/src/pp/pp_step.h +++ b/src/pp/pp_step.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Acceleration structure types /* Structure used to accelerate up entity lookup (rebuilt every step) */ @@ -9,7 +9,7 @@ Struct(SimAccel) Space *space; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Step ctx Struct(SimStepCtx) @@ -26,14 +26,14 @@ Struct(SimStepCtx) Client *publish_client; /* The publish client to write syncable state to (nil if skipping publish) */ }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Accel operations SimAccel AcquireSimAccel(void); void ReleaseSimAccel(SimAccel *accel); void ResetSimAccel(Snapshot *ss, SimAccel *accel); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Spawn test operations Entity *SpawnTestSmg(Entity *parent); @@ -50,19 +50,19 @@ void SpawnTestEntities4(Entity *parent, Vec2 pos); void SpawnTestTile(Snapshot *world, Vec2 world_pos); void ClearLevelTest(SimStepCtx *ctx); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Tile test operations MergesortCompareFuncDef(SortTileXCmp, arg_a, arg_b, _); MergesortCompareFuncDef(SortTileYCmp, arg_a, arg_b, _); void GenerateTestWalls(Snapshot *world); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Collision response CollisionCallbackFuncDef(OnEntityCollision, data, step_ctx); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Step void StepSim(SimStepCtx *ctx); diff --git a/src/prof/prof_tracy.h b/src/prof/prof_tracy.h index 248ba608..1b399f82 100644 --- a/src/prof/prof_tracy.h +++ b/src/prof/prof_tracy.h @@ -1,6 +1,6 @@ #if defined(ProfilingIsEnabled) && ProfilingIsEnabled == 1 -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Profiling enabled #ifndef __clang__ @@ -60,7 +60,7 @@ enum __prof_plot_type { #else -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Profiling disabled #define ProfilingCaptureFrame 0 diff --git a/src/rendertest/rendertest.c b/src/rendertest/rendertest.c index 2ace1547..14a60187 100644 --- a/src/rendertest/rendertest.c +++ b/src/rendertest/rendertest.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void RT_Startup(void) diff --git a/src/rendertest/rendertest.h b/src/rendertest/rendertest.h index dbcf0806..d69fc0a0 100644 --- a/src/rendertest/rendertest.h +++ b/src/rendertest/rendertest.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Startup void RT_Startup(void); diff --git a/src/settings/settings.c b/src/settings/settings.c index 560eea20..743c54bd 100644 --- a/src/settings/settings.c +++ b/src/settings/settings.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Serialize String SETTINGS_StringFromWindowSettings(Arena *arena, const P_WindowSettings *settings) @@ -40,7 +40,7 @@ String SETTINGS_StringFromWindowSettings(Arena *arena, const P_WindowSettings *s return formatted; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Deserialize P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, String *error_out) diff --git a/src/sound/sound.c b/src/sound/sound.c index af3dccb0..fd554890 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Load job JobDef(SND_Load, sig, UNUSED id) @@ -77,7 +77,7 @@ JobDef(SND_Load, sig, UNUSED id) EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Load sound AC_Asset *SND_LoadAsset(Resource resource, SND_SoundFlag flags, b32 wait) @@ -101,6 +101,7 @@ AC_Asset *SND_LoadAsset(Resource resource, SND_SoundFlag flags, b32 wait) { Job *job = OpenJob(SND_Load, JobPool_Background); SND_Load_Sig *sig = PushStruct(job->arena, SND_Load_Sig); + job->sig = sig; sig->resource = resource; sig->asset = asset; sig->flags = flags; diff --git a/src/sound/sound.h b/src/sound/sound.h index 5080c206..f5ba104f 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sound types #define SND_SampleRate 48000 @@ -16,7 +16,7 @@ Struct(SND_Sound) i16 *samples; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sound load operations JobDecl(SND_Load, { SND_SoundFlag flags; AC_Asset *asset; Resource resource; }); diff --git a/src/sprite/sprite.c b/src/sprite/sprite.c index 9cf59cef..49dde4ab 100644 --- a/src/sprite/sprite.c +++ b/src/sprite/sprite.c @@ -2,7 +2,7 @@ Readonly S_Texture S_NilTexture = ZI; Readonly S_Sheet S_NilSheet = ZI; S_SharedState S_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Load jobs JobDef(S_LoadTexture, sig, _) @@ -279,7 +279,7 @@ JobDef(S_LoadSheet, sig, _) EndScratch(scratch); } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Cache /* TODO: Per-fiber L1 cache */ @@ -346,7 +346,7 @@ S_Entry *S_FetchEntry(Resource resource, JobPool pool, S_FetchFlag flags) return entry; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sprite data retrieval operations S_Texture *S_TextureFromResource(Resource resource) @@ -385,7 +385,7 @@ S_Sheet *S_SheetFromResourceAsync(Resource resource) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sheet access operations S_Span S_SpanFromName(S_Sheet *sheet, String name) diff --git a/src/sprite/sprite.h b/src/sprite/sprite.h index 7e690e86..6bfaea8f 100644 --- a/src/sprite/sprite.h +++ b/src/sprite/sprite.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Texture types Struct(S_Texture) @@ -12,7 +12,7 @@ Struct(S_Texture) extern Readonly S_Texture S_NilTexture; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sheet types Struct(S_Frame) @@ -95,7 +95,7 @@ Struct(S_Sheet) extern Readonly S_Sheet S_NilSheet; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Cache types Struct(S_Entry) @@ -120,7 +120,7 @@ Struct(S_EntryBin) Mutex mutex; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define S_EntryBinsCount 1024 @@ -130,13 +130,13 @@ Struct(S_SharedState) S_EntryBin entry_bins[S_EntryBinsCount]; } extern S_shared_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Load jobs JobDecl(S_LoadTexture, { S_Entry *entry; }); JobDecl(S_LoadSheet, { S_Entry *entry; }); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Cache operations Enum(S_FetchFlag) @@ -148,7 +148,7 @@ Enum(S_FetchFlag) S_Entry *S_FetchEntry(Resource resource, JobPool pool, S_FetchFlag flags); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sprite data retrieval operations S_Texture *S_TextureFromResource(Resource resource); @@ -157,7 +157,7 @@ S_Texture *S_TextureFromResourceAsync(Resource resource); S_Sheet *S_SheetFromResource(Resource resource); S_Sheet *S_SheetFromResourceAsync(Resource resource); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Sheet access operations S_Span S_SpanFromName(S_Sheet *sheet, String name); diff --git a/src/tar/tar.h b/src/tar/tar.h index 4fc8138f..6b85c7e1 100644 --- a/src/tar/tar.h +++ b/src/tar/tar.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Archive types #define TAR_ArchiveLookupTableCapacityFactor 2.0 @@ -20,7 +20,7 @@ Struct(TAR_Archive) TAR_Entry *head; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Header types Enum(TAR_FileKind) @@ -63,7 +63,7 @@ Packed(Struct(TAR_Header) u8 padding[12]; }); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Archive operations u64 TAR_U64FromOctString(String str); diff --git a/src/ttf/ttf.h b/src/ttf/ttf.h index 232a0dfb..69de1d6f 100644 --- a/src/ttf/ttf.h +++ b/src/ttf/ttf.h @@ -8,7 +8,7 @@ Struct(TTF_Glyph) Rect atlas_rect; }; -Struct(TTF_Result) +Struct(TTF_Decoded) { TTF_Glyph *glyphs; u16 glyphs_count; @@ -20,4 +20,4 @@ Struct(TTF_Result) void TTF_Startup(void); -TTF_Result TTF_Decode(Arena *arena, String encoded, f32 point_size, u32 *cache_codes, u32 cache_codes_count); +TTF_Decoded TTF_Decode(Arena *arena, String encoded, f32 point_size, u32 *cache_codes, u32 cache_codes_count); diff --git a/src/ttf/ttf.lay b/src/ttf/ttf.lay index 239fb4ea..233f82bb 100644 --- a/src/ttf/ttf.lay +++ b/src/ttf/ttf.lay @@ -5,3 +5,6 @@ //- DirectWrite impl @DefaultWindowsImpl ttf_dwrite + +//- Startup +@Startup TTF_Startup diff --git a/src/ttf/ttf_dwrite/ttf_dwrite.c b/src/ttf/ttf_dwrite/ttf_dwrite.c index 3bbd8650..cd09aa4b 100644 --- a/src/ttf/ttf_dwrite/ttf_dwrite.c +++ b/src/ttf/ttf_dwrite/ttf_dwrite.c @@ -3,7 +3,7 @@ TTF_DW_SharedState TTF_DW_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Startup /* Call this during font system startup */ @@ -35,10 +35,10 @@ void TTF_Startup(void) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ @hookdef Decode -TTF_Result TTF_Decode(Arena *arena, String encoded, f32 point_size, u32 *cache_codes, u32 cache_codes_count) +TTF_Decoded TTF_Decode(Arena *arena, String encoded, f32 point_size, u32 *cache_codes, u32 cache_codes_count) { __prof; TTF_DW_SharedState *g = &TTF_DW_shared_state; @@ -274,7 +274,7 @@ TTF_Result TTF_Decode(Arena *arena, String encoded, f32 point_size, u32 *cache_c IDWriteFactory5_Release(factory); /* Return */ - TTF_Result result = ZI; + TTF_Decoded result = ZI; result.glyphs = glyphs; result.glyphs_count = glyph_count; result.cache_indices = cache_indices; diff --git a/src/ttf/ttf_dwrite/ttf_dwrite.h b/src/ttf/ttf_dwrite/ttf_dwrite.h index 7462fb60..dcad9522 100644 --- a/src/ttf/ttf_dwrite/ttf_dwrite.h +++ b/src/ttf/ttf_dwrite/ttf_dwrite.h @@ -1,10 +1,10 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Win32 libs #pragma comment(lib, "dwrite") #pragma comment(lib, "gdi32") -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ DirectWrite types /* DirectWrite C API stubs are taken from Mārtiņš Možeiko's c_d2d_dwrite @@ -139,7 +139,7 @@ static inline UINT32 IDWriteGdiInterop_Release //- Functions EXTERN_C HRESULT DECLSPEC_IMPORT WINAPI DWriteCreateFactory (DWRITE_FACTORY_TYPE factoryType, const GUID* iid, void** factory) WIN_NOEXCEPT; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types /* TODO: Determine font dpi dynamically */ diff --git a/src/ui/ui.c b/src/ui/ui.c index cdc91e71..dc763503 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -1,6 +1,16 @@ UI_SharedState UI_shared_state = ZI; -//////////////////////////////// +//////////////////////////////////////////////////////////// +//~ Startup + +void UI_Startup(void) +{ + /* Prefetch default font */ + Resource default_font = ResourceFromStore(&UI_Resources, Lit("font/default.ttf")); + F_LoadFontAsync(default_font, 12); +} + +//////////////////////////////////////////////////////////// //~ Key helpers u64 UI_HashFromTop(void) @@ -26,7 +36,7 @@ UI_Key UI_KeyFromString(u64 seed, String str) return result; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Checkpoint helpers void UI_PushCheckpoint(void) @@ -67,7 +77,7 @@ void UI_PopCheckpoint(void) g->first_free_checkpoint = cp; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Style stack helpers UI_StyleNode *UI_PushStyleNode(UI_StyleKind kind, b32 pop_when_used, UI_Style desc) @@ -123,10 +133,10 @@ UI_Style UI_StyleFromTopNode(UI_StyleKind kind, b32 use) return style; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Box helpers -UI_Box *UI_BuildBox(UI_Flag flags, UI_Key key) +UI_Box *UI_BuildBox(UI_BoxFlag flags, UI_Key key) { UI_SharedState *g = &UI_shared_state; UI_BoxBin *bin = &g->box_bins[key.hash % UI_NumBoxLookupBins]; @@ -178,6 +188,14 @@ UI_Box *UI_BuildBox(UI_Flag flags, UI_Key key) box->pref_size[Axis_Y] = UI_UseTop(Height); box->layout_axis = UI_UseTop(LayoutAxis); box->background_color = UI_UseTop(BackgroundColor); + box->font_resource = UI_UseTop(Font); + box->font_size = UI_UseTop(FontSize); + + /* Prefetch font */ + if (box->flags & UI_BoxFlag_DrawText) + { + box->font = F_LoadFontAsync(box->font_resource, box->font_size); + } DllPushBack(box->parent->first, box->parent->last, box); ++box->parent->count; @@ -197,7 +215,7 @@ void UI_SetDisplayImage(UI_Box *box, GPU_Resource *img) box->display_image = img; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Begin build void UI_BeginBuild(void) @@ -246,10 +264,12 @@ void UI_BeginBuild(void) style->kind = kind; g->style_tops[kind] = n; } - g->style_tops[UI_StyleKind_Tag]->style.Tag = HashFnv64(Fnv64Basis, Lit("root")); - g->style_tops[UI_StyleKind_Parent]->style.Parent = g->root_box; - g->style_tops[UI_StyleKind_Width]->style.Width = UI_RatioSize(1, 0); - g->style_tops[UI_StyleKind_Height]->style.Height = UI_RatioSize(1, 0); + g->style_tops[UI_StyleKind_Tag]->style.Tag = HashFnv64(Fnv64Basis, Lit("root")); + g->style_tops[UI_StyleKind_Parent]->style.Parent = g->root_box; + g->style_tops[UI_StyleKind_Width]->style.Width = UI_RatioSize(1, 0); + g->style_tops[UI_StyleKind_Height]->style.Height = UI_RatioSize(1, 0); + g->style_tops[UI_StyleKind_Font]->style.Font = ResourceFromStore(&UI_Resources, Lit("font/default.ttf")); + g->style_tops[UI_StyleKind_FontSize]->style.FontSize = 12.0f; } if (!g->back_build_arena) @@ -259,7 +279,7 @@ void UI_BeginBuild(void) } } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ End build GPU_Resource *UI_EndBuild(Rect render_viewport) @@ -269,7 +289,7 @@ GPU_Resource *UI_EndBuild(Rect render_viewport) /* TODO: Ensure root is parent */ - //////////////////////////////// + ////////////////////////////// //- Layout /* Init root size */ @@ -319,9 +339,9 @@ GPU_Resource *UI_EndBuild(Rect render_viewport) } /* Calculate independent sizes */ - for (u64 box_index = 0; box_index < boxes_count; ++box_index) + for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index) { - UI_Box *box = boxes_pre[box_index]; + UI_Box *box = boxes_pre[pre_index]; for (Axis axis = 0; axis < Axis_CountXY; ++axis) { UI_Size pref_size = box->pref_size[axis]; @@ -331,17 +351,25 @@ GPU_Resource *UI_EndBuild(Rect render_viewport) } else if (pref_size.kind == UI_SizeKind_Text) { - /* FIXME: Calculate actual text size here */ - f32 text_size = 10; + f32 text_size = 0; + if (box->display_text.len > 0 && box->font) + { + if (box->glyph_run.count == 0) + { + box->glyph_run = F_GlyphRunFromString(g->build_arena, box->font, box->display_text); + } + text_size += box->glyph_run.width * (axis == Axis_X); + text_size += box->glyph_run.height * (axis == Axis_Y); + } box->solved_dims[axis] = text_size; } } } /* Calculate upwards-dependent sizes */ - for (u64 box_index = 0; box_index < boxes_count; ++box_index) + for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index) { - UI_Box *box = boxes_pre[box_index]; + UI_Box *box = boxes_pre[pre_index]; for (Axis axis = 0; axis < Axis_CountXY; ++axis) { UI_Size pref_size = box->pref_size[axis]; @@ -364,9 +392,9 @@ GPU_Resource *UI_EndBuild(Rect render_viewport) } /* Calculate final positions */ - for (u64 box_index = 0; box_index < boxes_count; ++box_index) + for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index) { - UI_Box *box = boxes_pre[box_index]; + UI_Box *box = boxes_pre[pre_index]; UI_Box *parent = box->parent; Vec2 final_size = VEC2(box->solved_dims[0], box->solved_dims[1]); if (parent) @@ -423,7 +451,7 @@ GPU_Resource *UI_EndBuild(Rect render_viewport) } #endif - //////////////////////////////// + ////////////////////////////// //- Build render data /* Init transient buffers */ @@ -437,23 +465,59 @@ GPU_Resource *UI_EndBuild(Rect render_viewport) Fence *render_fence = GPU_FenceFromQueue(render_queue); /* Build rect instance data */ - for (u64 box_index = 0; box_index < boxes_count; ++box_index) + for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index) { - UI_Box *box = boxes_pre[box_index]; - UI_RectInstance *rect = PushStruct(g->draw_rects_arena, UI_RectInstance); - - rect->flags = box->flags; - rect->p0 = box->p0; - rect->p1 = box->p1; - rect->background_srgb = box->background_color; - - if (box->flags & UI_Flag_DrawImage, box->display_image) + UI_Box *box = boxes_pre[pre_index]; + /* Push box rect */ { - rect->image_tex = GPU_Texture2DRidFromResource(box->display_image); + UI_RectInstance *rect = PushStruct(g->draw_rects_arena, UI_RectInstance); + rect->flags |= UI_RectFlag_DrawTexture * !!(box->flags & UI_BoxFlag_DrawImage); + rect->p0 = box->p0; + rect->p1 = box->p1; + rect->tex_uv0 = VEC2(0, 0); + rect->tex_uv1 = VEC2(1, 1); + rect->background_srgb = box->background_color; + + /* FIXME: Remove this */ + u64 test_idx = rect - ((UI_RectInstance *)ArenaBase(g->draw_rects_arena)); + if (test_idx == 931) + { + DEBUGBREAKABLE; + } + + + if ((box->flags & UI_BoxFlag_DrawImage) && box->display_image) + { + rect->tex = GPU_Texture2DRidFromResource(box->display_image); + } + } + /* Push text rects */ + if ((box->flags & UI_BoxFlag_DrawText) && box->glyph_run.count > 0 && box->font) + { + Texture2DRid tex_rid = GPU_Texture2DRidFromResource(box->font->texture); + f32 inv_font_image_width = 1.0f / (f32)box->font->image_width; + f32 inv_font_image_height = 1.0f / (f32)box->font->image_height; + + String text = box->display_text; + F_GlyphRun run = box->glyph_run; + f32 offset = 0; + for (u64 i = 0; i < run.count; ++i) + { + F_Glyph glyph = run.glyphs[i]; + Rect atlas_rect = glyph.atlas_rect; + UI_RectInstance *rect = PushStruct(g->draw_rects_arena, UI_RectInstance); + rect->flags |= UI_RectFlag_DrawTexture; + rect->p0 = AddVec2(box->p0, VEC2(offset, 0)); + rect->p1 = AddVec2(rect->p0, VEC2(glyph.width, glyph.height)); + rect->tex_uv0 = VEC2(atlas_rect.x * inv_font_image_width, atlas_rect.y * inv_font_image_height); + rect->tex_uv1 = VEC2((atlas_rect.x + atlas_rect.width) * inv_font_image_width, (atlas_rect.y + atlas_rect.height) * inv_font_image_height); + rect->tex = tex_rid; + offset += glyph.advance; + } } } - //////////////////////////////// + ////////////////////////////// //- Render /* Init render target */ diff --git a/src/ui/ui.h b/src/ui/ui.h index 8ff07c68..7f0dd981 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Key types #define UI_NilKey ((UI_Key) { 0 }) @@ -9,7 +9,7 @@ Struct(UI_Key) u64 hash; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Size types Enum(UI_SizeKind) @@ -27,9 +27,18 @@ Struct(UI_Size) f32 strictness; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Box types +/* NOTE: UI flags are located here since they are shared between application & shader code */ + +Enum(UI_BoxFlag) +{ + UI_BoxFlag_None = 0, + UI_BoxFlag_DrawText = (1 << 0), + UI_BoxFlag_DrawImage = (1 << 1), +}; + Struct(UI_Box) { //- Hash list @@ -48,14 +57,22 @@ Struct(UI_Box) UI_Key key; //- Per-build data - UI_Flag flags; + UI_BoxFlag flags; + String display_text; GPU_Resource *display_image; - UI_Size pref_size[Axis_CountXY]; + Axis layout_axis; + + UI_Size pref_size[Axis_CountXY]; u32 background_color; + Resource font_resource; + f32 font_size; + //- Layout data + F_GlyphRun glyph_run; + F_Font *font; f32 solved_dims[Axis_CountXY]; f32 layout_cursor; @@ -63,14 +80,13 @@ Struct(UI_Box) Vec2 p0; Vec2 p1; }; - Struct(UI_BoxBin) { UI_Box *first; UI_Box *last; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Style types #define UI_StyleKindsXMacro(x) \ @@ -79,7 +95,10 @@ Struct(UI_BoxBin) x(LayoutAxis, Axis) \ x(Width, UI_Size) \ x(Height, UI_Size) \ - x(BackgroundColor, u32) + x(BackgroundColor, u32) \ + x(Font, Resource) \ + x(FontSize, u32) \ +/* ----------------------------------- */ Enum(UI_StyleKind) { @@ -110,7 +129,7 @@ Struct(UI_StyleNode) UI_Style style; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Checkpoint types Struct(UI_Checkpoint) @@ -119,7 +138,7 @@ Struct(UI_Checkpoint) u64 v; }; -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ State types #define UI_NumBoxLookupBins 16384 @@ -154,20 +173,25 @@ Struct(UI_SharedState) } extern UI_shared_state; -//////////////////////////////// +//////////////////////////////////////////////////////////// +//~ Startup + +void UI_Startup(void); + +//////////////////////////////////////////////////////////// //~ Key helpers u64 UI_HashFromTop(void); u64 UI_HashFromString(u64 seed, String str); UI_Key UI_KeyFromString(u64 seed, String str); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Checkpoint helpers void UI_PushCheckpoint(void); void UI_PopCheckpoint(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Style stack helpers UI_StyleNode *UI_PushStyleNode(UI_StyleKind kind, b32 pop_when_used, UI_Style desc); @@ -178,10 +202,10 @@ UI_Style UI_StyleFromTopNode(UI_StyleKind kind, b32 use); #define UI_SetNext(name, v) UI_PushStyleNode(UI_StyleKind_##name, 1, (UI_Style) { .name = v }) #define UI_Push(name, v) UI_PushStyleNode(UI_StyleKind_##name, 0, (UI_Style) { .name = v }) #define UI_Pop(name, v) UI_PopStyleNode(UI_StyleKind_##name).name -#define UI_UseTop(name) UI_StyleFromTopNode(UI_StyleKind_##name, 1).name +#define UI_UseTop(name) UI_StyleFromTopNode(UI_StyleKind_##name, 1).name #define UI_PeekTop(name) UI_StyleFromTopNode(UI_StyleKind_##name, 0).name -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Size helpers #define UI_ChildrenSize(_strictness) ((UI_Size) { .kind = UI_SizeKind_Children, .strictness = strictness_ }) @@ -189,25 +213,25 @@ UI_Style UI_StyleFromTopNode(UI_StyleKind kind, b32 use); #define UI_PixelSize(_pixels, _strictness) ((UI_Size) { .kind = UI_SizeKind_Pixel, .v = _pixels, .strictness = _strictness }) #define UI_TextSize(_strictness) ((UI_Size) { .kind = UI_SizeKind_Text, .strictness = _strictness }) -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Box -UI_Box *UI_BuildBox(UI_Flag flags, UI_Key key); +UI_Box *UI_BuildBox(UI_BoxFlag flags, UI_Key key); void UI_SetDisplayText(UI_Box *box, String str); void UI_SetDisplayImage(UI_Box *box, GPU_Resource *img); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Image void UI_SetDisplayImage(UI_Box *box, GPU_Resource *img); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Begin build void UI_BeginBuild(void); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ End build GPU_Resource *UI_EndBuild(Rect render_viewport); diff --git a/src/ui/ui.lay b/src/ui/ui.lay index eff8d335..5494a069 100644 --- a/src/ui/ui.lay +++ b/src/ui/ui.lay @@ -2,13 +2,12 @@ //- Dependencies @Dep gpu +@Dep font //- Api -@IncludeC ui_flags.h @IncludeC ui.h @IncludeC ui_extra.h @IncludeC ui_draw.h -@IncludeGpu ui_flags.h @IncludeGpu ui_draw.h //- Impl @@ -19,3 +18,9 @@ //- Shaders @VertexShader UI_RectVS @PixelShader UI_RectPS + +//- Embeds +@EmbedDir UI_Resources ui_res + +//- Startup +@Startup UI_Startup diff --git a/src/ui/ui_draw.gpu b/src/ui/ui_draw.gpu index 3a980a66..2cb29b28 100644 --- a/src/ui/ui_draw.gpu +++ b/src/ui/ui_draw.gpu @@ -1,6 +1,6 @@ ConstantBuffer UI_rect_sig : register (b0); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Rect Struct(UI_RectPS_Input) @@ -8,7 +8,7 @@ Struct(UI_RectPS_Input) Semantic(Vec4, sv_position); Semantic(Vec4, background_lin); - Semantic(Vec2, uv); + Semantic(Vec2, tex_uv); Semantic(nointerpolation u32, instance_idx); }; @@ -31,15 +31,17 @@ UI_RectPS_Input VSDef(UI_RectVS, Semantic(u32, sv_instanceid), Semantic(u32, sv_ StructuredBuffer instances = UniformResourceFromRid(sig.instances); UI_RectInstance instance = instances[sv_instanceid]; + Vec2 uv = uvs[sv_vertexid]; - Vec2 vert = instance.p0 + (uv * instance.p1); - Vec2 ndc = NdcFromViewport(sig.viewport_size, vert); + Vec2 tex_uv = lerp(instance.tex_uv0, instance.tex_uv1, uv); + Vec2 screen_vert = lerp(instance.p0, instance.p1, uv); + Vec2 ndc = NdcFromViewport(sig.viewport_size, screen_vert); UI_RectPS_Input result; result.sv_position = Vec4(ndc.xy, 0, 1); result.background_lin = LinearFromSrgbU32(instance.background_srgb); result.instance_idx = sv_instanceid; - result.uv = uv; + result.tex_uv = tex_uv; return result; } @@ -51,14 +53,18 @@ UI_RectPS_Output PSDef(UI_RectPS, UI_RectPS_Input input) ConstantBuffer sig = UI_rect_sig; StructuredBuffer instances = UniformResourceFromRid(sig.instances); UI_RectInstance instance = instances[input.instance_idx]; + Vec4 color; - Vec4 color = input.background_lin; - - if (instance.flags & UI_Flag_DrawImage) + /* Background */ + if (instance.flags & UI_RectFlag_DrawTexture) { SamplerState sampler = UniformSamplerFromRid(sig.sampler); - Texture2D tex = NonUniformResourceFromRid(instance.image_tex); - color = tex.Sample(sampler, input.uv); + Texture2D tex = NonUniformResourceFromRid(instance.tex); + color = tex.Sample(sampler, input.tex_uv); + } + else + { + color = input.background_lin; } UI_RectPS_Output result; diff --git a/src/ui/ui_draw.h b/src/ui/ui_draw.h index aed9016a..cb9c7c2a 100644 --- a/src/ui/ui_draw.h +++ b/src/ui/ui_draw.h @@ -1,4 +1,4 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Rect types Struct(UI_RectSig) @@ -11,14 +11,19 @@ Struct(UI_RectSig) }; AssertRootConst(UI_RectSig, 4); +Enum(UI_RectFlag) +{ + UI_RectFlag_None = 0, + UI_RectFlag_DrawTexture = (1 << 0), +}; + Struct(UI_RectInstance) { - u32 flags; + UI_RectFlag flags; Vec2 p0; Vec2 p1; u32 background_srgb; - Texture2DRid image_tex; + Vec2 tex_uv0; + Vec2 tex_uv1; + Texture2DRid tex; }; -#define UI_DefaultRectInstance (UI_RectInstance) { \ - 0 \ -} diff --git a/src/ui/ui_extra.c b/src/ui/ui_extra.c index 1a258521..6baf686c 100644 --- a/src/ui/ui_extra.c +++ b/src/ui/ui_extra.c @@ -1,10 +1,10 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Label widget UI_Box *UI_BuildLabel(String text) { UI_Key key = UI_KeyFromString(0, text); - UI_Box *box = UI_BuildBox(UI_Flag_DrawText, UI_NilKey); + UI_Box *box = UI_BuildBox(UI_BoxFlag_DrawText, UI_NilKey); UI_SetDisplayText(box, text); return box; } @@ -24,7 +24,7 @@ UI_Box *UI_BuildLabelF_(char *fmt_cstr, ...) return box; } -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Separator widget UI_Box *UI_BuildSeparator(void) diff --git a/src/ui/ui_extra.h b/src/ui/ui_extra.h index b6f2e75d..62bc2749 100644 --- a/src/ui/ui_extra.h +++ b/src/ui/ui_extra.h @@ -1,11 +1,11 @@ -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Label widget UI_Box *UI_BuildLabel(String text); #define UI_BuildLabelF(fmt_cstr, ...) UI_BuildLabelF_(fmt_cstr, __VA_ARGS__, FmtEnd) UI_Box *UI_BuildLabelF_(char *fmt_cstr, ...); -//////////////////////////////// +//////////////////////////////////////////////////////////// //~ Separator widget UI_Box *UI_BuildSeparator(void); diff --git a/src/ui/ui_flags.h b/src/ui/ui_flags.h index d4a855f8..e69de29b 100644 --- a/src/ui/ui_flags.h +++ b/src/ui/ui_flags.h @@ -1,8 +0,0 @@ -/* NOTE: UI flags are located here since they are shared between application & shader code */ - -Enum(UI_Flag) -{ - UI_Flag_None = 0, - UI_Flag_DrawText = (1 << 0), - UI_Flag_DrawImage = (1 << 1), -}; diff --git a/src/pp/pp_res/font/fixedsys.ttf b/src/ui/ui_res/font/default.ttf similarity index 100% rename from src/pp/pp_res/font/fixedsys.ttf rename to src/ui/ui_res/font/default.ttf