text reimpl
This commit is contained in:
parent
fe45ea77bc
commit
ee1f720fa1
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 <nmmintrin.h> /* 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"
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) })
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 */
|
||||
|
||||
@ -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 */
|
||||
|
||||
@ -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);
|
||||
|
||||
119
src/font/font.c
119
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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ DirectX12 libs
|
||||
|
||||
#include <d3d12.h>
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Win32 libs
|
||||
|
||||
#pragma comment(lib, "kernel32")
|
||||
#pragma comment(lib, "user32")
|
||||
|
||||
////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Win32 helpers
|
||||
|
||||
String W32_StringFromError(Arena *arena, DWORD err);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Decode
|
||||
|
||||
MP3_Result MP3_Decode(Arena *arena, String encoded, u32 sample_rate, MP3_DecodeFlag flags)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Windows headers
|
||||
|
||||
#pragma warning(push, 0)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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. */
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
38
src/pp/pp.c
38
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)
|
||||
|
||||
30
src/pp/pp.h
30
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);
|
||||
|
||||
@ -5,7 +5,7 @@ ConstantBuffer<UiBlitSig> ui_blit_sig : register (b0);
|
||||
ConstantBuffer<UiRectSig> ui_rect_sig : register (b0);
|
||||
ConstantBuffer<UiShapeSig> 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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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. */
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Startup
|
||||
|
||||
void RT_Startup(void)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Startup
|
||||
|
||||
void RT_Startup(void);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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; });
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -5,3 +5,6 @@
|
||||
|
||||
//- DirectWrite impl
|
||||
@DefaultWindowsImpl ttf_dwrite
|
||||
|
||||
//- Startup
|
||||
@Startup TTF_Startup
|
||||
|
||||
@ -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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user