text reimpl
This commit is contained in:
parent
fe45ea77bc
commit
ee1f720fa1
@ -1,6 +1,6 @@
|
|||||||
SharedAppState shared_app_state = ZI;
|
SharedAppState shared_app_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Write directory
|
//~ Write directory
|
||||||
|
|
||||||
String InitializeAppWriteDirectory(Arena *arena, String write_dir)
|
String InitializeAppWriteDirectory(Arena *arena, String write_dir)
|
||||||
@ -35,7 +35,7 @@ String CatAppWritePath(Arena *arena, String filename)
|
|||||||
return CatString(arena, g->write_path, filename);
|
return CatString(arena, g->write_path, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Default settings
|
//~ Default settings
|
||||||
|
|
||||||
P_WindowSettings GetDefaultAppWindowSettings(P_Window *window)
|
P_WindowSettings GetDefaultAppWindowSettings(P_Window *window)
|
||||||
@ -59,7 +59,7 @@ P_WindowSettings GetDefaultAppWindowSettings(P_Window *window)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Args
|
//~ Args
|
||||||
|
|
||||||
/* TODO: Remove this and do real argument parsing */
|
/* TODO: Remove this and do real argument parsing */
|
||||||
@ -140,7 +140,7 @@ AppArgList ParseAppArgs(Arena *arena, String args_str)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Entry point
|
//~ @hookdef Entry point
|
||||||
|
|
||||||
void Startup(void)
|
void Startup(void)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ App arg types
|
//~ App arg types
|
||||||
|
|
||||||
Struct(AppArg)
|
Struct(AppArg)
|
||||||
@ -15,7 +15,7 @@ Struct(AppArgList)
|
|||||||
u64 count;
|
u64 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
Struct(SharedAppState)
|
Struct(SharedAppState)
|
||||||
@ -24,7 +24,7 @@ Struct(SharedAppState)
|
|||||||
String write_path;
|
String write_path;
|
||||||
} extern shared_app_state;
|
} extern shared_app_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ App functions
|
//~ App functions
|
||||||
|
|
||||||
//- Write path
|
//- Write path
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* DEFLATE decoder based on Handmade Hero's png parser
|
* DEFLATE decoder based on Handmade Hero's png parser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shared constants
|
//~ Shared constants
|
||||||
|
|
||||||
Global Readonly u32 ASE_huff_hclen_order[] = {
|
Global Readonly u32 ASE_huff_hclen_order[] = {
|
||||||
@ -83,7 +83,7 @@ Global Readonly u32 ASE_huff_bl_counts[][2] = {
|
|||||||
{319, 5},
|
{319, 5},
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ase bitbuff
|
//~ Ase bitbuff
|
||||||
|
|
||||||
u32 ASE_PeekBits(ASE_Bitbuff *bb, u32 nbits)
|
u32 ASE_PeekBits(ASE_Bitbuff *bb, u32 nbits)
|
||||||
@ -114,7 +114,7 @@ void ASE_SkipBits(ASE_Bitbuff *bb, u32 nbits)
|
|||||||
bb->cur_bit += nbits;
|
bb->cur_bit += nbits;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Inflate
|
//~ Inflate
|
||||||
|
|
||||||
u32 ASE_ReverseBits(u32 v, u32 bit_count)
|
u32 ASE_ReverseBits(u32 v, u32 bit_count)
|
||||||
@ -401,7 +401,7 @@ void ASE_Inflate(u8 *dst, u8 *encoded)
|
|||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Error helpers
|
//~ Error helpers
|
||||||
|
|
||||||
void ASE_PushError(Arena *arena, ASE_ErrorList *list, String msg_src)
|
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;
|
++list->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode helpers
|
//~ Decode helpers
|
||||||
|
|
||||||
u32 ASE_BlendMulU8(u32 a, u32 b)
|
u32 ASE_BlendMulU8(u32 a, u32 b)
|
||||||
@ -482,7 +482,7 @@ void ASE_MakeDimensionsSquareish(ASE_Header *header, u32 *frames_x, u32 *frames_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode image
|
//~ Decode image
|
||||||
|
|
||||||
ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded)
|
ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded)
|
||||||
@ -777,7 +777,7 @@ abort:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode sheet
|
//~ Decode sheet
|
||||||
|
|
||||||
ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded)
|
ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sheet types
|
//~ Sheet types
|
||||||
|
|
||||||
Struct(ASE_Slice)
|
Struct(ASE_Slice)
|
||||||
@ -38,7 +38,7 @@ Struct(ASE_SliceKey)
|
|||||||
ASE_SliceKey *next;
|
ASE_SliceKey *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decoder result types
|
//~ Decoder result types
|
||||||
|
|
||||||
Struct(ASE_Error)
|
Struct(ASE_Error)
|
||||||
@ -77,7 +77,7 @@ Struct(ASE_DecodedSheet)
|
|||||||
b32 ok;
|
b32 ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Inflator types
|
//~ Inflator types
|
||||||
|
|
||||||
#define ASE_HuffBitCount 16
|
#define ASE_HuffBitCount 16
|
||||||
@ -109,7 +109,7 @@ Struct(ASE_HuffDict)
|
|||||||
ASE_HuffEntry *entries;
|
ASE_HuffEntry *entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Header types
|
//~ Header types
|
||||||
|
|
||||||
Packed(Struct(ASE_Header)
|
Packed(Struct(ASE_Header)
|
||||||
@ -146,7 +146,7 @@ Packed(Struct(ASE_FrameHeader)
|
|||||||
u32 chunks_new;
|
u32 chunks_new;
|
||||||
});
|
});
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Image decoder types
|
//~ Image decoder types
|
||||||
|
|
||||||
Enum(ASE_ChunkKind)
|
Enum(ASE_ChunkKind)
|
||||||
@ -210,14 +210,14 @@ Struct(Ace_Cel)
|
|||||||
Ace_Cel *next;
|
Ace_Cel *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ase bitbuff operations
|
//~ Ase bitbuff operations
|
||||||
|
|
||||||
u32 ASE_PeekBits(ASE_Bitbuff *bb, u32 nbits);
|
u32 ASE_PeekBits(ASE_Bitbuff *bb, u32 nbits);
|
||||||
u32 ASE_ConsumeBits(ASE_Bitbuff *bb, u32 nbits);
|
u32 ASE_ConsumeBits(ASE_Bitbuff *bb, u32 nbits);
|
||||||
void ASE_SkipBits(ASE_Bitbuff *bb, u32 nbits);
|
void ASE_SkipBits(ASE_Bitbuff *bb, u32 nbits);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Inflate operations
|
//~ Inflate operations
|
||||||
|
|
||||||
u32 ASE_ReverseBits(u32 v, u32 bit_count);
|
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);
|
u16 ASE_DecodeHuffDict(ASE_HuffDict *huffman, ASE_Bitbuff *bb);
|
||||||
void ASE_Inflate(u8 *dst, u8 *encoded);
|
void ASE_Inflate(u8 *dst, u8 *encoded);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Error helpers
|
//~ Error helpers
|
||||||
|
|
||||||
void ASE_PushError(Arena *arena, ASE_ErrorList *list, String msg_src);
|
void ASE_PushError(Arena *arena, ASE_ErrorList *list, String msg_src);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode helpers
|
//~ Decode helpers
|
||||||
|
|
||||||
u32 ASE_BlendMulU8(u32 a, u32 b);
|
u32 ASE_BlendMulU8(u32 a, u32 b);
|
||||||
u32 ASE_Blend(u32 src, u32 dst, u8 opacity);
|
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);
|
void ASE_MakeDimensionsSquareish(ASE_Header *header, u32 *frames_x, u32 *frames_y, u64 *image_width, u64 *image_height);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode image
|
//~ Decode image
|
||||||
|
|
||||||
ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded);
|
ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode sheet
|
//~ Decode sheet
|
||||||
|
|
||||||
ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded);
|
ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
AC_SharedState AC_shared_state = ZI;
|
AC_SharedState AC_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void AC_Startup(void)
|
void AC_Startup(void)
|
||||||
@ -12,7 +12,7 @@ void AC_Startup(void)
|
|||||||
g->store_arena = AcquireArena(Gibi(64));
|
g->store_arena = AcquireArena(Gibi(64));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Hash
|
//~ Hash
|
||||||
|
|
||||||
u64 AC_HashFromKey(String key)
|
u64 AC_HashFromKey(String key)
|
||||||
@ -21,7 +21,7 @@ u64 AC_HashFromKey(String key)
|
|||||||
return HashFnv64(Fnv64Basis, key);
|
return HashFnv64(Fnv64Basis, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Cache
|
//~ Cache
|
||||||
|
|
||||||
void AC_RefreshDebugTable(void)
|
void AC_RefreshDebugTable(void)
|
||||||
@ -150,7 +150,7 @@ AC_Asset *AC_TouchCache(String key, u64 hash, b32 *is_first_touch)
|
|||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Status
|
//~ Status
|
||||||
|
|
||||||
/* Call this once asset job has been created */
|
/* Call this once asset job has been created */
|
||||||
@ -172,7 +172,7 @@ void AC_YieldOnAssetReady(AC_Asset *asset)
|
|||||||
YieldOnFence(&asset->ready_fence, 1);
|
YieldOnFence(&asset->ready_fence, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Store
|
//~ Store
|
||||||
|
|
||||||
void *AC_DataFromStore(AC_Asset *asset)
|
void *AC_DataFromStore(AC_Asset *asset)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* TODO: Remove this entire layer */
|
/* TODO: Remove this entire layer */
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Asset types
|
//~ Asset types
|
||||||
|
|
||||||
Enum(AC_Status)
|
Enum(AC_Status)
|
||||||
@ -27,7 +27,7 @@ Struct(AC_Asset)
|
|||||||
void *store_data;
|
void *store_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Asset store types
|
//~ Asset store types
|
||||||
|
|
||||||
Struct(AC_Store)
|
Struct(AC_Store)
|
||||||
@ -38,7 +38,7 @@ Struct(AC_Store)
|
|||||||
Lock lock;
|
Lock lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
#define AC_MaxAssets 1024
|
#define AC_MaxAssets 1024
|
||||||
@ -61,31 +61,31 @@ Struct(AC_SharedState)
|
|||||||
#endif
|
#endif
|
||||||
} extern AC_shared_state;
|
} extern AC_shared_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void AC_Startup(void);
|
void AC_Startup(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Hash
|
//~ Hash
|
||||||
|
|
||||||
u64 AC_HashFromKey(String key);
|
u64 AC_HashFromKey(String key);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Cache operations
|
//~ Cache operations
|
||||||
|
|
||||||
void AC_RefreshDebugTable(void);
|
void AC_RefreshDebugTable(void);
|
||||||
AC_Asset *AC_GetAssetCacheSlotLocked(Lock *lock, String key, u64 hash);
|
AC_Asset *AC_GetAssetCacheSlotLocked(Lock *lock, String key, u64 hash);
|
||||||
AC_Asset *AC_TouchCache(String key, u64 hash, b32 *is_first_touch);
|
AC_Asset *AC_TouchCache(String key, u64 hash, b32 *is_first_touch);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Status operations
|
//~ Status operations
|
||||||
|
|
||||||
void AC_MarkLoading(AC_Asset *asset);
|
void AC_MarkLoading(AC_Asset *asset);
|
||||||
void AC_MarkReady(AC_Asset *asset, void *store_data);
|
void AC_MarkReady(AC_Asset *asset, void *store_data);
|
||||||
void AC_YieldOnAssetReady(AC_Asset *asset);
|
void AC_YieldOnAssetReady(AC_Asset *asset);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Store operations
|
//~ Store operations
|
||||||
|
|
||||||
void *AC_DataFromStore(AC_Asset *asset);
|
void *AC_DataFromStore(AC_Asset *asset);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Compiler flag checks
|
//~ Compiler flag checks
|
||||||
|
|
||||||
#ifndef IsConsoleApp
|
#ifndef IsConsoleApp
|
||||||
@ -37,7 +37,7 @@
|
|||||||
# error Missing compile time definition for 'TestsAreEnabled'
|
# error Missing compile time definition for 'TestsAreEnabled'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Machine context
|
//~ Machine context
|
||||||
|
|
||||||
//- Compiler
|
//- Compiler
|
||||||
@ -111,7 +111,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Platform headers
|
//~ Platform headers
|
||||||
|
|
||||||
//- Windows headers
|
//- Windows headers
|
||||||
@ -131,7 +131,7 @@
|
|||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Debug
|
//~ Debug
|
||||||
|
|
||||||
//- Static assert
|
//- Static assert
|
||||||
@ -185,7 +185,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
|||||||
# define AsanUnpoison(addr, size)
|
# define AsanUnpoison(addr, size)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Common utility macros
|
//~ Common utility macros
|
||||||
|
|
||||||
//- ZeroStruct initialization macro
|
//- 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 NsFromSeconds(s) ((i64)((s) * 1000000000.0))
|
||||||
#define SecondsFromNs(ns) ((f64)(ns) / 1000000000.0)
|
#define SecondsFromNs(ns) ((f64)(ns) / 1000000000.0)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Linked list helper macros
|
//~ Linked list helper macros
|
||||||
|
|
||||||
/* Taken from the rad debugger
|
/* 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 DllPushFront(f,l,n) DllPushFrontNPZ(0,f,l,n,next,prev)
|
||||||
#define DllRemove(f,l,n) DllRemoveNPZ(0,f,l,n,next,prev)
|
#define DllRemove(f,l,n) DllRemoveNPZ(0,f,l,n,next,prev)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Color helper macros
|
//~ Color helper macros
|
||||||
|
|
||||||
//- Rgba 32 bit helpers
|
//- 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_Orange Rgb32(0xFF, 0xA5, 0x00)
|
||||||
#define Color_Purple Rgb32(0xFF, 0x00, 0XFF)
|
#define Color_Purple Rgb32(0xFF, 0x00, 0XFF)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Intrinsic headers
|
//~ Intrinsic headers
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
@ -389,7 +389,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
|||||||
#include <nmmintrin.h> /* SSE4.2 */
|
#include <nmmintrin.h> /* SSE4.2 */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Type helper macros
|
//~ Type helper macros
|
||||||
|
|
||||||
//- Struct
|
//- Struct
|
||||||
@ -449,7 +449,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Scalar types
|
//~ Scalar types
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
@ -517,7 +517,7 @@ Global const f64 *_f64_nan = (f64 *)&_f64_nan_u64;
|
|||||||
#define IsF64Nan(x) (x != x)
|
#define IsF64Nan(x) (x != x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Atomics
|
//~ Atomics
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
@ -576,7 +576,7 @@ ForceInline i64 Atomic64FetchAdd (Atomic64 *x, i64 a) { return
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ticket mutex
|
//~ Ticket mutex
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
@ -602,7 +602,7 @@ ForceInline void UnlockTicketMutex(TicketMutex *tm)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ String types
|
//~ String types
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
@ -661,7 +661,7 @@ Struct(StringList)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource types
|
//~ Resource types
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
@ -680,7 +680,7 @@ Struct(Resource)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shader types
|
//~ Shader types
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
@ -738,7 +738,7 @@ typedef uint SamplerStateRid;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fibers
|
//~ Fibers
|
||||||
|
|
||||||
# define MaxFibers 4096
|
# define MaxFibers 4096
|
||||||
@ -752,7 +752,7 @@ StaticAssert(MaxFibers < I16Max); /* MaxFibers should fit in FiberId */
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Exit callback types
|
//~ Exit callback types
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
@ -760,7 +760,7 @@ StaticAssert(MaxFibers < I16Max); /* MaxFibers should fit in FiberId */
|
|||||||
typedef ExitFuncDef(ExitFunc);
|
typedef ExitFuncDef(ExitFunc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Api hooks
|
//~ @hookdecl Api hooks
|
||||||
|
|
||||||
#if LanguageIsC
|
#if LanguageIsC
|
||||||
@ -782,7 +782,7 @@ void StartupLayers(void);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Config
|
//~ Config
|
||||||
|
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Arena types
|
//~ Arena types
|
||||||
|
|
||||||
#define ArenaHeaderSize CachelineSize
|
#define ArenaHeaderSize CachelineSize
|
||||||
@ -24,7 +24,7 @@ Struct(TempArena)
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
#define ScratchArenasPerCtx 2
|
#define ScratchArenasPerCtx 2
|
||||||
@ -40,7 +40,7 @@ Struct(SharedArenaCtx)
|
|||||||
FiberArenaCtx arena_contexts[MaxFibers];
|
FiberArenaCtx arena_contexts[MaxFibers];
|
||||||
} extern shared_arena_ctx;
|
} extern shared_arena_ctx;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Arena push/pop
|
//~ Arena push/pop
|
||||||
|
|
||||||
#define PushStruct(a, type) ((type *)PushBytes((a), sizeof(type), alignof(type)))
|
#define PushStruct(a, type) ((type *)PushBytes((a), sizeof(type), alignof(type)))
|
||||||
@ -110,7 +110,7 @@ Inline void *_PushDry(Arena *arena, u64 align)
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Arena management
|
//~ Arena management
|
||||||
|
|
||||||
Arena *AcquireArena(u64 reserve);
|
Arena *AcquireArena(u64 reserve);
|
||||||
@ -152,7 +152,7 @@ Inline void *ResetArena(Arena *arena)
|
|||||||
return (void *)ArenaBase(arena);
|
return (void *)ArenaBase(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Temp arena operations
|
//~ Temp arena operations
|
||||||
|
|
||||||
Inline TempArena BeginTempArena(Arena *arena)
|
Inline TempArena BeginTempArena(Arena *arena)
|
||||||
@ -168,7 +168,7 @@ Inline void EndTempArena(TempArena temp)
|
|||||||
PopTo(temp.arena, temp.start_pos);
|
PopTo(temp.arena, temp.start_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fiber arena ctx operations
|
//~ Fiber arena ctx operations
|
||||||
|
|
||||||
Inline FiberArenaCtx *FiberArenaCtxFromId(i16 fiber_id)
|
Inline FiberArenaCtx *FiberArenaCtxFromId(i16 fiber_id)
|
||||||
@ -189,7 +189,7 @@ Inline FiberArenaCtx *FiberArenaCtxFromId(i16 fiber_id)
|
|||||||
|
|
||||||
#define PermArena() (FiberArenaCtxFromId(FiberId())->perm_arena)
|
#define PermArena() (FiberArenaCtxFromId(FiberId())->perm_arena)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Scratch helpers
|
//~ Scratch helpers
|
||||||
|
|
||||||
/* Any parameterized arenas in the caller's scope should be passed into this
|
/* 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) */
|
/* TODO: Safety check that functions taking byte length can't overflow bit conversion (log2(num_bytes) > 61) */
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Buff management
|
//~ Buff management
|
||||||
|
|
||||||
BB_Buff BB_AcquireBuff(u64 arena_reserve)
|
BB_Buff BB_AcquireBuff(u64 arena_reserve)
|
||||||
@ -27,7 +27,7 @@ BB_Buff BB_BuffFromString(String s)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Writer management
|
//~ Writer management
|
||||||
|
|
||||||
BB_Writer BB_WriterFromBuff(BB_Buff *bb)
|
BB_Writer BB_WriterFromBuff(BB_Buff *bb)
|
||||||
@ -125,7 +125,7 @@ b32 BB_CheckWriterOverflowBits(BB_Writer *bw, u64 num_bits)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Align writer
|
//~ Align writer
|
||||||
|
|
||||||
/* Align the pos to the next byte */
|
/* Align the pos to the next byte */
|
||||||
@ -157,7 +157,7 @@ void BB_WriteAlignBytes(BB_Writer *bw, u64 align)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Write bits
|
//~ Write bits
|
||||||
|
|
||||||
void BB_WriteUBitsNoMagic(BB_Writer *bw, u64 value, u8 num_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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Write variable length integers
|
//~ Write variable length integers
|
||||||
|
|
||||||
/* Writes a variable length unsigned integer.
|
/* Writes a variable length unsigned integer.
|
||||||
@ -280,7 +280,7 @@ void BB_WriteIV(BB_Writer *bw, i64 value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Write floating point
|
//~ Write floating point
|
||||||
|
|
||||||
void BB_WriteF32(BB_Writer *bw, f32 value)
|
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);
|
BB_WriteUBits(bw, *(u64 *)&value, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Write Uid
|
//~ Write Uid
|
||||||
|
|
||||||
void BB_WriteUid(BB_Writer *bw, Uid value)
|
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);
|
BB_WriteUBits(bw, value.lo, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Write raw data
|
//~ Write raw data
|
||||||
|
|
||||||
void BB_WriteString(BB_Writer *bw, String s)
|
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;
|
bw->cur_bit += num_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Writer debug
|
//~ Writer debug
|
||||||
|
|
||||||
#if BITBUFF_DEBUG
|
#if BITBUFF_DEBUG
|
||||||
@ -371,7 +371,7 @@ void BB_WriteDebugMagic(BB_Writer *bw, BB_DebugMagicKind magic, u8 num_bits)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Reader management
|
//~ Reader management
|
||||||
|
|
||||||
BB_Reader BB_ReaderFromBuff(BB_Buff *bb)
|
BB_Reader BB_ReaderFromBuff(BB_Buff *bb)
|
||||||
@ -456,7 +456,7 @@ b32 BB_CheckReaderOverflowBits(BB_Reader *br, u64 num_bits)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Align reader
|
//~ Align reader
|
||||||
|
|
||||||
/* Align the pos to the next byte */
|
/* Align the pos to the next byte */
|
||||||
@ -488,7 +488,7 @@ void BB_ReadAlignBytes(BB_Reader *br, u64 align)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Read bits
|
//~ Read bits
|
||||||
|
|
||||||
u64 BB_ReadUBitsNoMagic(BB_Reader *br, u8 num_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);
|
return BB_ReadUBits(br, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Read variable length integer
|
//~ Read variable length integer
|
||||||
|
|
||||||
/* Read a variable length unsigned integer.
|
/* Read a variable length unsigned integer.
|
||||||
@ -613,7 +613,7 @@ i64 BB_ReadIV(BB_Reader *br)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Read floating point
|
//~ Read floating point
|
||||||
|
|
||||||
f32 BB_ReadF32(BB_Reader *br)
|
f32 BB_ReadF32(BB_Reader *br)
|
||||||
@ -630,7 +630,7 @@ f64 BB_ReadF64(BB_Reader *br)
|
|||||||
return *(f64 *)&ubits;
|
return *(f64 *)&ubits;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Read Uid
|
//~ Read Uid
|
||||||
|
|
||||||
Uid BB_ReadUid(BB_Reader *br)
|
Uid BB_ReadUid(BB_Reader *br)
|
||||||
@ -641,7 +641,7 @@ Uid BB_ReadUid(BB_Reader *br)
|
|||||||
return UID(hi, lo);
|
return UID(hi, lo);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Read raw data
|
//~ Read raw data
|
||||||
|
|
||||||
String BB_ReadString(Arena *arena, BB_Reader *br)
|
String BB_ReadString(Arena *arena, BB_Reader *br)
|
||||||
@ -719,7 +719,7 @@ void BB_ReadSeekToByte(BB_Reader *br, u64 pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Reader debug
|
//~ Reader debug
|
||||||
|
|
||||||
#if BITBUFF_DEBUG
|
#if BITBUFF_DEBUG
|
||||||
@ -757,7 +757,7 @@ void BB_ReadDebugMarker(BB_Reader *br, String name)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utils
|
//~ Utils
|
||||||
|
|
||||||
u64 BB_TwosComplimentFromUint(u64 value, u8 num_bits)
|
u64 BB_TwosComplimentFromUint(u64 value, u8 num_bits)
|
||||||
@ -780,7 +780,7 @@ i64 BB_IntFromTwosCompliment(u64 tc, u8 num_bits)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Test
|
//~ Test
|
||||||
|
|
||||||
#if BITBUFF_TEST
|
#if BITBUFF_TEST
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Bitbuff types
|
//~ Bitbuff types
|
||||||
|
|
||||||
//- Buff
|
//- Buff
|
||||||
@ -39,7 +39,7 @@ Struct(BB_Reader)
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Debug types
|
//~ Debug types
|
||||||
|
|
||||||
#if BITBUFF_DEBUG
|
#if BITBUFF_DEBUG
|
||||||
@ -61,7 +61,7 @@ Enum(BB_DebugMagicKind)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Buff management
|
//~ Buff management
|
||||||
|
|
||||||
//- Growable-arena backed bitbuff
|
//- Growable-arena backed bitbuff
|
||||||
@ -71,7 +71,7 @@ void BB_ReleaseBuff(BB_Buff *bitbuff);
|
|||||||
//- Fixed-buffer backed bitbuff
|
//- Fixed-buffer backed bitbuff
|
||||||
BB_Buff BB_BuffFromString(String s);
|
BB_Buff BB_BuffFromString(String s);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Writer management
|
//~ Writer management
|
||||||
|
|
||||||
BB_Writer BB_WriterFromBuff(BB_Buff *bb);
|
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);
|
b32 BB_CheckWriterOverflowBits(BB_Writer *bw, u64 num_bits);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Writer ops
|
//~ Writer ops
|
||||||
|
|
||||||
//- Align
|
//- Align
|
||||||
@ -114,7 +114,7 @@ void BB_WriteString(BB_Writer *bw, String s);
|
|||||||
void BB_WriteBytes(BB_Writer *bw, String bytes);
|
void BB_WriteBytes(BB_Writer *bw, String bytes);
|
||||||
void BB_WriteSeekBytes(BB_Writer *bw, u64 num_bytes);
|
void BB_WriteSeekBytes(BB_Writer *bw, u64 num_bytes);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Writer debug
|
//~ Writer debug
|
||||||
|
|
||||||
#if BITBUFF_DEBUG
|
#if BITBUFF_DEBUG
|
||||||
@ -125,7 +125,7 @@ void BB_WriteDebugMarker(BB_Writer *bw, String name);
|
|||||||
#define BB_WriteDebugMarker(bw, name)
|
#define BB_WriteDebugMarker(bw, name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Reader management
|
//~ Reader management
|
||||||
|
|
||||||
BB_Reader BB_ReaderFromBuff(BB_Buff *bb);
|
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);
|
b32 BB_CheckReaderOverflowBits(BB_Reader *br, u64 num_bits);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Reader ops
|
//~ Reader ops
|
||||||
|
|
||||||
//- Align
|
//- 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_ReadSeekBytes(BB_Reader *br, u64 num_bytes);
|
||||||
void BB_ReadSeekToByte(BB_Reader *br, u64 pos);
|
void BB_ReadSeekToByte(BB_Reader *br, u64 pos);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Reader debug
|
//~ Reader debug
|
||||||
|
|
||||||
#if BITBUFF_DEBUG
|
#if BITBUFF_DEBUG
|
||||||
@ -181,13 +181,13 @@ void BB_ReadDebugMarker(BB_Reader *br, String name);
|
|||||||
#define BB_ReadDebugMarker(br, name)
|
#define BB_ReadDebugMarker(br, name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utils
|
//~ Utils
|
||||||
|
|
||||||
u64 BB_TwosComplimentFromUint(u64 value, u8 num_bits);
|
u64 BB_TwosComplimentFromUint(u64 value, u8 num_bits);
|
||||||
i64 BB_IntFromTwosCompliment(u64 tc, u8 num_bits);
|
i64 BB_IntFromTwosCompliment(u64 tc, u8 num_bits);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Test
|
//~ Test
|
||||||
|
|
||||||
#if BITBUFF_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. */
|
/* 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
|
//~ Buddy ctx
|
||||||
|
|
||||||
BuddyCtx *AcquireBuddyCtx(u64 reserve)
|
BuddyCtx *AcquireBuddyCtx(u64 reserve)
|
||||||
@ -30,7 +30,7 @@ void ReleaseBuddyCtx(BuddyCtx *ctx)
|
|||||||
ReleaseArena(ctx->meta_arena);
|
ReleaseArena(ctx->meta_arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Block acquire / release
|
//~ Block acquire / release
|
||||||
|
|
||||||
BuddyBlock *AcquireBuddyBlock(BuddyCtx *ctx, u64 size)
|
BuddyBlock *AcquireBuddyBlock(BuddyCtx *ctx, u64 size)
|
||||||
@ -84,7 +84,7 @@ void ReleaseBuddyBlock(BuddyBlock *block)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Block push / pop
|
//~ Block push / pop
|
||||||
|
|
||||||
//- Push
|
//- Push
|
||||||
@ -128,7 +128,7 @@ void PopBuddyBlock(BuddyCtx *ctx, BuddyLevel *level, BuddyBlock *block)
|
|||||||
ctx->first_free_block = block;
|
ctx->first_free_block = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Get unused block
|
//~ Get unused block
|
||||||
|
|
||||||
BuddyBlock *GetUnusedBuddyBlock(BuddyCtx *ctx, BuddyLevel *level)
|
BuddyBlock *GetUnusedBuddyBlock(BuddyCtx *ctx, BuddyLevel *level)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Buddy types
|
//~ Buddy types
|
||||||
|
|
||||||
//- Block
|
//- Block
|
||||||
@ -35,13 +35,13 @@ Struct(BuddyCtx)
|
|||||||
BuddyBlock *first_free_block;
|
BuddyBlock *first_free_block;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Buddy context operations
|
//~ Buddy context operations
|
||||||
|
|
||||||
BuddyCtx *AcquireBuddyCtx(u64 reserve);
|
BuddyCtx *AcquireBuddyCtx(u64 reserve);
|
||||||
void ReleaseBuddyCtx(BuddyCtx *ctx);
|
void ReleaseBuddyCtx(BuddyCtx *ctx);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Buddy block operations
|
//~ Buddy block operations
|
||||||
|
|
||||||
//- Acquire / release
|
//- Acquire / release
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Exit callback types
|
//~ Exit callback types
|
||||||
|
|
||||||
#define ExitFuncDef(name) void name(void)
|
#define ExitFuncDef(name) void name(void)
|
||||||
typedef ExitFuncDef(ExitFunc);
|
typedef ExitFuncDef(ExitFunc);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Exit operations
|
//~ @hookdecl Exit operations
|
||||||
|
|
||||||
void OnExit(ExitFunc *func);
|
void OnExit(ExitFunc *func);
|
||||||
void SignalExit(i32 code);
|
void SignalExit(i32 code);
|
||||||
void ExitNow(i32 code);
|
void ExitNow(i32 code);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Application defined hooks
|
//~ @hookdecl Application defined hooks
|
||||||
|
|
||||||
void Startup(void);
|
void Startup(void);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
SharedFutexState shared_futex_state = ZI;
|
SharedFutexState shared_futex_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void InitFutexSystem(void)
|
void InitFutexSystem(void)
|
||||||
@ -8,7 +8,7 @@ void InitFutexSystem(void)
|
|||||||
SharedFutexState *g = &shared_futex_state;
|
SharedFutexState *g = &shared_futex_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State helpers
|
//~ State helpers
|
||||||
|
|
||||||
FiberNeqFutexState *FiberNeqFutexStateFromId(i16 fiber_id)
|
FiberNeqFutexState *FiberNeqFutexStateFromId(i16 fiber_id)
|
||||||
@ -16,7 +16,7 @@ FiberNeqFutexState *FiberNeqFutexStateFromId(i16 fiber_id)
|
|||||||
return &shared_futex_state.fiber_neq_states[fiber_id];
|
return &shared_futex_state.fiber_neq_states[fiber_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Not-equal futex operations
|
//~ Not-equal futex operations
|
||||||
|
|
||||||
void FutexYieldNeq(volatile void *addr, void *cmp, u8 cmp_size)
|
void FutexYieldNeq(volatile void *addr, void *cmp, u8 cmp_size)
|
||||||
@ -171,7 +171,7 @@ void FutexWakeNeq(void *addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Greater-than-or-equal futex operations
|
//~ Greater-than-or-equal futex operations
|
||||||
|
|
||||||
void FutexYieldGte(volatile void *addr, void *cmp, u8 cmp_size)
|
void FutexYieldGte(volatile void *addr, void *cmp, u8 cmp_size)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Neq futex types
|
//~ Neq futex types
|
||||||
|
|
||||||
Struct(FutexNeqList)
|
Struct(FutexNeqList)
|
||||||
@ -16,7 +16,7 @@ Struct(FutexNeqListBin)
|
|||||||
FutexNeqList *first_free;
|
FutexNeqList *first_free;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
#define FutexNeqBinsCount 16384
|
#define FutexNeqBinsCount 16384
|
||||||
@ -33,17 +33,17 @@ Struct(SharedFutexState)
|
|||||||
FutexNeqListBin neq_bins[FutexNeqBinsCount];
|
FutexNeqListBin neq_bins[FutexNeqBinsCount];
|
||||||
} extern shared_futex_state;
|
} extern shared_futex_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void InitFutexSystem(void);
|
void InitFutexSystem(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State helpers
|
//~ State helpers
|
||||||
|
|
||||||
FiberNeqFutexState *FiberNeqFutexStateFromId(i16 fiber_id);
|
FiberNeqFutexState *FiberNeqFutexStateFromId(i16 fiber_id);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Not-equal futex operations
|
//~ Not-equal futex operations
|
||||||
|
|
||||||
/* Similar to Win32 WaitOnAddress & WakeByAddressAll
|
/* 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 FutexYieldNeq(volatile void *addr, void *cmp, u8 cmp_size);
|
||||||
void FutexWakeNeq(void *addr);
|
void FutexWakeNeq(void *addr);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Greater-than-or-equal futex operations
|
//~ Greater-than-or-equal futex operations
|
||||||
|
|
||||||
/* Similar to Win32 WaitOnAddress & WakeByAddressAll
|
/* Similar to Win32 WaitOnAddress & WakeByAddressAll
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sqrt intrinsics
|
//~ Sqrt intrinsics
|
||||||
|
|
||||||
Inline f32 IxSqrtF32(f32 f)
|
Inline f32 IxSqrtF32(f32 f)
|
||||||
@ -22,7 +22,7 @@ Inline f32 IxRsqrtF32(f32 f)
|
|||||||
return _mm_cvtss_f32(n);
|
return _mm_cvtss_f32(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Round intrinsics
|
//~ Round intrinsics
|
||||||
|
|
||||||
Inline i32 IxRoundF32ToI32(f32 f)
|
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));
|
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
|
//~ Floor intrinsics
|
||||||
|
|
||||||
Inline i32 IxFloorF32ToI32(f32 f)
|
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)));
|
return _mm_cvtsd_f64(_mm_floor_sd(_mm_setzero_pd(), _mm_set_sd(f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ceil intrinsics
|
//~ Ceil intrinsics
|
||||||
|
|
||||||
Inline i32 IxCeilF32ToI32(f32 f)
|
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)));
|
return _mm_cvtsd_f64(_mm_ceil_sd(_mm_setzero_pd(), _mm_set_sd(f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Truncate intrinsics
|
//~ Truncate intrinsics
|
||||||
|
|
||||||
Inline f32 IxTruncF32ToF32(f32 f)
|
Inline f32 IxTruncF32ToF32(f32 f)
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Opaque types
|
//~ Opaque types
|
||||||
|
|
||||||
Struct(Job);
|
Struct(Job);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Job pool types
|
//~ Job pool types
|
||||||
|
|
||||||
/* Job pools contain worker threads with their own thread priorities
|
/* Job pools contain worker threads with their own thread priorities
|
||||||
@ -32,7 +32,7 @@ Enum(JobPool)
|
|||||||
JobPool_Count
|
JobPool_Count
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Job types
|
//~ Job types
|
||||||
|
|
||||||
typedef void JobFunc(void *, i32);
|
typedef void JobFunc(void *, i32);
|
||||||
@ -78,18 +78,18 @@ Struct(Job)
|
|||||||
void *sig;
|
void *sig;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Init
|
//~ @hookdecl Init
|
||||||
|
|
||||||
void InitJobSystem(void);
|
void InitJobSystem(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Fiber suspend/resume operations
|
//~ @hookdecl Fiber suspend/resume operations
|
||||||
|
|
||||||
void SuspendFiber(void);
|
void SuspendFiber(void);
|
||||||
void ResumeFibers(i16 fiber_ids_count, i16 *fiber_ids); /* NOTE: Must only be called on fibers suspended via SuspendFiber */
|
void ResumeFibers(i16 fiber_ids_count, i16 *fiber_ids); /* NOTE: Must only be called on fibers suspended via SuspendFiber */
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Job declaration operations
|
//~ @hookdecl Job declaration operations
|
||||||
|
|
||||||
#define EmptySig { i32 _; }
|
#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)
|
#define JobDef(job, sig_arg, id_arg) void job(job##_Sig *sig_arg, i32 id_arg)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Job dispatch operations
|
//~ @hookdecl Job dispatch operations
|
||||||
|
|
||||||
/* RunJob example usage:
|
/* RunJob example usage:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* Math functions are default 32 bit (f32, i32, etc) unless specified */
|
/* Math functions are default 32 bit (f32, i32, etc) unless specified */
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Min / max
|
//~ Min / max
|
||||||
|
|
||||||
//- Min
|
//- 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; }
|
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; }
|
f64 ClampF64(f64 v, f64 min, f64 max) { return v < min ? min : v > max ? max : v; }
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Rounding ops
|
//~ Rounding ops
|
||||||
|
|
||||||
//- Round
|
//- Round
|
||||||
@ -108,7 +108,7 @@ f64 TruncF64(f64 f)
|
|||||||
return IxTruncF64ToF64(f);
|
return IxTruncF64ToF64(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fmod
|
//~ Fmod
|
||||||
|
|
||||||
f32 ModF32(f32 x, f32 m)
|
f32 ModF32(f32 x, f32 m)
|
||||||
@ -121,7 +121,7 @@ f64 ModF64(f64 x, f64 m)
|
|||||||
return x - m * TruncF64(x / m);
|
return x - m * TruncF64(x / m);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Floating point sign
|
//~ Floating point sign
|
||||||
|
|
||||||
f32 AbsF32(f32 f)
|
f32 AbsF32(f32 f)
|
||||||
@ -158,7 +158,7 @@ i64 SignF64(f64 f)
|
|||||||
return 1 + -((i64)(sign_bit << 1));
|
return 1 + -((i64)(sign_bit << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ U64 pow
|
//~ U64 pow
|
||||||
|
|
||||||
/* Taken from https://gist.github.com/orlp/3551590 */
|
/* Taken from https://gist.github.com/orlp/3551590 */
|
||||||
@ -254,7 +254,7 @@ u64 PowU64(u64 base, u8 exp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Align up
|
//~ Align up
|
||||||
|
|
||||||
u64 AlignU64Pow2(u64 x)
|
u64 AlignU64Pow2(u64 x)
|
||||||
@ -274,7 +274,7 @@ u64 AlignU64Pow2(u64 x)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Logn
|
//~ Logn
|
||||||
|
|
||||||
/* Based on FreeBSD's implementation
|
/* Based on FreeBSD's implementation
|
||||||
@ -369,7 +369,7 @@ f32 LnF32(f32 x)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Exp
|
//~ Exp
|
||||||
|
|
||||||
/* Based on FreeBSD's implementation
|
/* Based on FreeBSD's implementation
|
||||||
@ -481,7 +481,7 @@ f32 ExpF32(f32 x)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Pow
|
//~ Pow
|
||||||
|
|
||||||
f32 PowF32(f32 a, f32 b)
|
f32 PowF32(f32 a, f32 b)
|
||||||
@ -499,7 +499,7 @@ f32 PowF32(f32 a, f32 b)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sqrt
|
//~ Sqrt
|
||||||
|
|
||||||
f32 SqrtF32(f32 x)
|
f32 SqrtF32(f32 x)
|
||||||
@ -517,7 +517,7 @@ f32 RSqrtF32(f32 x)
|
|||||||
return IxRsqrtF32(x);
|
return IxRsqrtF32(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Trig
|
//~ Trig
|
||||||
|
|
||||||
/* Functions based on Cephes implementation (https://www.netlib.org/cephes/):
|
/* 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)));
|
return (Pi / 2.0f) - ArcTan2F32(x, SqrtF32(1.0f - (x * x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Angle unwind
|
//~ Angle unwind
|
||||||
|
|
||||||
/* Returns angle in range [-Pi, Pi] */
|
/* Returns angle in range [-Pi, Pi] */
|
||||||
@ -755,7 +755,7 @@ f32 UnwindAngleF32(f32 a)
|
|||||||
return ModF32(2.0f * d, Tau) - d;
|
return ModF32(2.0f * d, Tau) - d;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Float lerp
|
//~ Float lerp
|
||||||
|
|
||||||
f32 LerpF32(f32 val0, f32 val1, f32 t)
|
f32 LerpF32(f32 val0, f32 val1, f32 t)
|
||||||
@ -774,7 +774,7 @@ f32 LerpAngleF32(f32 a, f32 b, f32 t)
|
|||||||
return a + diff * t;
|
return a + diff * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Int lerp
|
//~ Int lerp
|
||||||
|
|
||||||
i32 LerpI32(i32 val0, i32 val1, f32 t)
|
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));
|
return val0 + RoundF64ToI64(((f64)(val1 - val0) * t));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Vec2 operations
|
//~ Vec2 operations
|
||||||
|
|
||||||
b32 IsVec2Zero(Vec2 a)
|
b32 IsVec2Zero(Vec2 a)
|
||||||
@ -1010,7 +1010,7 @@ Vec2 SlerpVec2(Vec2 val0, Vec2 val1, f32 t)
|
|||||||
return MulVec2(Vec2FromAngle(rot), len);
|
return MulVec2(Vec2FromAngle(rot), len);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Vec2I32 Operations
|
//~ Vec2I32 Operations
|
||||||
|
|
||||||
b32 EqVec2I32(Vec2I32 a, Vec2I32 b)
|
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);
|
return VEC2I32(a.x - b.x, a.y - b.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Xform operations
|
//~ Xform operations
|
||||||
|
|
||||||
b32 EqXform(Xform xf1, Xform xf2)
|
b32 EqXform(Xform xf1, Xform xf2)
|
||||||
@ -1270,7 +1270,7 @@ Vec2 ScaleFromXform(Xform xf)
|
|||||||
return VEC2(Vec2Len(xf.bx), det_sign * Vec2Len(xf.by));
|
return VEC2(Vec2Len(xf.bx), det_sign * Vec2Len(xf.by));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Quad operations
|
//~ Quad operations
|
||||||
|
|
||||||
Quad QuadFromRect(Rect rect)
|
Quad QuadFromRect(Rect rect)
|
||||||
@ -1346,7 +1346,7 @@ Quad FloorQuad(Quad quad)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Spring operations
|
//~ Spring operations
|
||||||
|
|
||||||
/* https://box2d.org/files/ErinCatto_SoftConstraints_GDC2011.pdf */
|
/* https://box2d.org/files/ErinCatto_SoftConstraints_GDC2011.pdf */
|
||||||
@ -1372,7 +1372,7 @@ SoftSpring MakeSpring(f32 hertz, f32 damping_ratio, f32 dt)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mat4x4 operations
|
//~ Mat4x4 operations
|
||||||
|
|
||||||
Mat4x4 Mat4x4FromXform(Xform xf)
|
Mat4x4 Mat4x4FromXform(Xform xf)
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
#define Tau ((f32)6.28318530717958647693)
|
#define Tau ((f32)6.28318530717958647693)
|
||||||
#define GoldenRatio ((f32)1.61803398874989484820)
|
#define GoldenRatio ((f32)1.61803398874989484820)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Axis types
|
//~ Axis types
|
||||||
|
|
||||||
Enum(Axis)
|
Enum(Axis)
|
||||||
@ -17,7 +17,7 @@ Enum(Axis)
|
|||||||
Axis_CountXYZ = 3,
|
Axis_CountXYZ = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Vector types
|
//~ Vector types
|
||||||
|
|
||||||
#define VEC2(x, y) (Vec2) { (x), (y) }
|
#define VEC2(x, y) (Vec2) { (x), (y) }
|
||||||
@ -62,7 +62,7 @@ Struct(Vec4Array)
|
|||||||
u64 count;
|
u64 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Xform types
|
//~ Xform types
|
||||||
|
|
||||||
Struct(Xform)
|
Struct(Xform)
|
||||||
@ -80,7 +80,7 @@ Struct(Trs)
|
|||||||
f32 r;
|
f32 r;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Rect types
|
//~ Rect types
|
||||||
|
|
||||||
Struct(Rect) {
|
Struct(Rect) {
|
||||||
@ -98,14 +98,14 @@ Struct(ClipRect)
|
|||||||
Vec2 p0, p1;
|
Vec2 p0, p1;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Axis aligned bounding box types
|
//~ Axis aligned bounding box types
|
||||||
|
|
||||||
Struct(Aabb) {
|
Struct(Aabb) {
|
||||||
Vec2 p0, p1;
|
Vec2 p0, p1;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Quad types
|
//~ Quad types
|
||||||
|
|
||||||
Struct(Quad) {
|
Struct(Quad) {
|
||||||
@ -116,7 +116,7 @@ Struct(Quad) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Spring types
|
//~ Spring types
|
||||||
|
|
||||||
Struct(SoftSpring)
|
Struct(SoftSpring)
|
||||||
@ -126,7 +126,7 @@ Struct(SoftSpring)
|
|||||||
f32 impulse_scale;
|
f32 impulse_scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mat4x4 types
|
//~ Mat4x4 types
|
||||||
|
|
||||||
Struct(Mat4x4)
|
Struct(Mat4x4)
|
||||||
@ -138,7 +138,7 @@ Struct(Mat4x4)
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Min / max
|
//~ Min / max
|
||||||
|
|
||||||
//- Min
|
//- Min
|
||||||
@ -169,7 +169,7 @@ u64 ClampU64(u64 v, u64 min, u64 max);
|
|||||||
i64 ClampI64(i64 v, i64 min, i64 max);
|
i64 ClampI64(i64 v, i64 min, i64 max);
|
||||||
f64 ClampF64(f64 v, f64 min, f64 max);
|
f64 ClampF64(f64 v, f64 min, f64 max);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Rounding ops
|
//~ Rounding ops
|
||||||
|
|
||||||
//- Round
|
//- Round
|
||||||
@ -194,13 +194,13 @@ i64 CeilF64ToI64(f64 f);
|
|||||||
f32 TruncF32(f32 f);
|
f32 TruncF32(f32 f);
|
||||||
f64 TruncF64(f64 f);
|
f64 TruncF64(f64 f);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fmod
|
//~ Fmod
|
||||||
|
|
||||||
f32 ModF32(f32 x, f32 m);
|
f32 ModF32(f32 x, f32 m);
|
||||||
f64 ModF64(f64 x, f64 m);
|
f64 ModF64(f64 x, f64 m);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Abs
|
//~ Abs
|
||||||
|
|
||||||
f32 AbsF32(f32 f);
|
f32 AbsF32(f32 f);
|
||||||
@ -210,7 +210,7 @@ u64 AbsI64(i64 v);
|
|||||||
i32 SignF32(f32 f);
|
i32 SignF32(f32 f);
|
||||||
i64 SignF64(f64 f);
|
i64 SignF64(f64 f);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Exponential ops
|
//~ Exponential ops
|
||||||
|
|
||||||
u64 PowU64(u64 base, u8 exp);
|
u64 PowU64(u64 base, u8 exp);
|
||||||
@ -222,7 +222,7 @@ f32 SqrtF32(f32 x);
|
|||||||
f64 SqrtF64(f64 x);
|
f64 SqrtF64(f64 x);
|
||||||
f32 RSqrtF32(f32 x);
|
f32 RSqrtF32(f32 x);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Trig
|
//~ Trig
|
||||||
|
|
||||||
f32 ReduceToPio4(f32 x, i32 *octant_out);
|
f32 ReduceToPio4(f32 x, i32 *octant_out);
|
||||||
@ -235,26 +235,26 @@ f32 ArcTan2F32(f32 y, f32 x);
|
|||||||
f32 ArcSinF32(f32 x);
|
f32 ArcSinF32(f32 x);
|
||||||
f32 ArcCosF32(f32 x);
|
f32 ArcCosF32(f32 x);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Angle unwind
|
//~ Angle unwind
|
||||||
|
|
||||||
/* Returns angle in range [-Pi, Pi] */
|
/* Returns angle in range [-Pi, Pi] */
|
||||||
f32 UnwindAngleF32(f32 a);
|
f32 UnwindAngleF32(f32 a);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Float lerp
|
//~ Float lerp
|
||||||
|
|
||||||
f32 LerpF32(f32 val0, f32 val1, f32 t);
|
f32 LerpF32(f32 val0, f32 val1, f32 t);
|
||||||
f64 LerpF64(f64 val0, f64 val1, f64 t);
|
f64 LerpF64(f64 val0, f64 val1, f64 t);
|
||||||
f32 LerpAngleF32(f32 a, f32 b, f32 t);
|
f32 LerpAngleF32(f32 a, f32 b, f32 t);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Int lerp
|
//~ Int lerp
|
||||||
|
|
||||||
i32 LerpI32(i32 val0, i32 val1, f32 t);
|
i32 LerpI32(i32 val0, i32 val1, f32 t);
|
||||||
i64 LerpI64(i64 val0, i64 val1, f64 t);
|
i64 LerpI64(i64 val0, i64 val1, f64 t);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Vec2 operations
|
//~ Vec2 operations
|
||||||
|
|
||||||
#define Vec2FromVec2I32(v) VEC2((v).x, (v).y)
|
#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 LerpVec2(Vec2 val0, Vec2 val1, f32 t);
|
||||||
Vec2 SlerpVec2(Vec2 val0, Vec2 val1, f32 t);
|
Vec2 SlerpVec2(Vec2 val0, Vec2 val1, f32 t);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Vec2I32 Operations
|
//~ Vec2I32 Operations
|
||||||
|
|
||||||
b32 EqVec2I32(Vec2I32 a, Vec2I32 b);
|
b32 EqVec2I32(Vec2I32 a, Vec2I32 b);
|
||||||
@ -319,7 +319,7 @@ Vec2I32 NegVec2I32(Vec2I32 a);
|
|||||||
Vec2I32 AddVec2I32(Vec2I32 a, Vec2I32 b);
|
Vec2I32 AddVec2I32(Vec2I32 a, Vec2I32 b);
|
||||||
Vec2I32 SubVec2I32(Vec2I32 a, Vec2I32 b);
|
Vec2I32 SubVec2I32(Vec2I32 a, Vec2I32 b);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Xform operations
|
//~ Xform operations
|
||||||
|
|
||||||
b32 EqXform(Xform xf1, Xform xf2);
|
b32 EqXform(Xform xf1, Xform xf2);
|
||||||
@ -374,14 +374,14 @@ Vec2 ScaleFromXform(Xform xf);
|
|||||||
//- Trs
|
//- Trs
|
||||||
#define TRS(...) ((Trs) { .t = VEC2(0,0), .s = VEC2(1, 1), .r = 0, __VA_ARGS__ })
|
#define TRS(...) ((Trs) { .t = VEC2(0,0), .s = VEC2(1, 1), .r = 0, __VA_ARGS__ })
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Rect operations
|
//~ Rect operations
|
||||||
|
|
||||||
#define RectFromScalar(_x, _y, _width, _height) (Rect) { .x = (_x), .y = (_y), .width = (_width), .height = (_height) }
|
#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 RectFromVec2(_pos, _size) (Rect) { .pos = (_pos), .size = (_size) }
|
||||||
#define AllClipped ((ClipRect) { { 0.0f, 0.0f }, { 1.0f, 1.0f } })
|
#define AllClipped ((ClipRect) { { 0.0f, 0.0f }, { 1.0f, 1.0f } })
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Quad operations
|
//~ Quad operations
|
||||||
|
|
||||||
#define UnitSquareQuad (Quad) { .p0 = VEC2(0, 0), .p1 = VEC2(0, 1), .p2 = VEC2(1, 1), .p3 = VEC2(1, 0) }
|
#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 RoundQuad(Quad quad);
|
||||||
Quad FloorQuad(Quad quad);
|
Quad FloorQuad(Quad quad);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Spring operations
|
//~ Spring operations
|
||||||
|
|
||||||
SoftSpring MakeSpring(f32 hertz, f32 damping_ratio, f32 dt);
|
SoftSpring MakeSpring(f32 hertz, f32 damping_ratio, f32 dt);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mat4x4 operations
|
//~ Mat4x4 operations
|
||||||
|
|
||||||
Mat4x4 Mat4x4FromXform(Xform xf);
|
Mat4x4 Mat4x4FromXform(Xform xf);
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Gpu math constants
|
//~ Gpu math constants
|
||||||
|
|
||||||
#define Pi ((f32)3.14159265358979323846)
|
#define Pi ((f32)3.14159265358979323846)
|
||||||
#define Tau ((f32)6.28318530717958647693)
|
#define Tau ((f32)6.28318530717958647693)
|
||||||
#define GoldenRatio ((f32)1.61803398874989484820)
|
#define GoldenRatio ((f32)1.61803398874989484820)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Gpu math types
|
//~ Gpu math types
|
||||||
|
|
||||||
typedef float2 Vec2;
|
typedef float2 Vec2;
|
||||||
@ -24,7 +24,7 @@ typedef float4 Aabb;
|
|||||||
typedef float4 Quad;
|
typedef float4 Quad;
|
||||||
typedef float4x4 Mat4x4;
|
typedef float4x4 Mat4x4;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Integer -> float
|
//~ Integer -> float
|
||||||
|
|
||||||
Vec4 Vec4NormFromU32(u32 v)
|
Vec4 Vec4NormFromU32(u32 v)
|
||||||
@ -37,7 +37,7 @@ Vec4 Vec4NormFromU32(u32 v)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Srgb -> linear
|
//~ Srgb -> linear
|
||||||
|
|
||||||
/* Linear color from normalized sRGB */
|
/* Linear color from normalized sRGB */
|
||||||
@ -52,7 +52,7 @@ Vec4 LinearFromSrgbU32(u32 srgb32)
|
|||||||
return LinearFromSrgbVec4(Vec4NormFromU32(srgb32));
|
return LinearFromSrgbVec4(Vec4NormFromU32(srgb32));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ndc helpers
|
//~ Ndc helpers
|
||||||
|
|
||||||
Vec2 NdcFromViewport(Vec2 viewport_size, Vec2 viewport_coords)
|
Vec2 NdcFromViewport(Vec2 viewport_size, Vec2 viewport_coords)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 memory allocation
|
//~ Win32 memory allocation
|
||||||
|
|
||||||
#if PlatformIsWindows
|
#if PlatformIsWindows
|
||||||
@ -44,7 +44,7 @@ void SetMemoryReadWrite(void *address, u64 size)
|
|||||||
# error Memory allocation not implemented for this platform
|
# error Memory allocation not implemented for this platform
|
||||||
#endif /* PlatformIsWindows */
|
#endif /* PlatformIsWindows */
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Crtlib mem op stubs
|
//~ Crtlib mem op stubs
|
||||||
|
|
||||||
#if !CrtlibIsEnabled
|
#if !CrtlibIsEnabled
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Memory allocation
|
//~ Memory allocation
|
||||||
|
|
||||||
//- Reserve
|
//- Reserve
|
||||||
@ -13,7 +13,7 @@ void DecommitMemory(void *address, u64 size);
|
|||||||
void SetMemoryReadonly(void *address, u64 size);
|
void SetMemoryReadonly(void *address, u64 size);
|
||||||
void SetMemoryReadWrite(void *address, u64 size);
|
void SetMemoryReadWrite(void *address, u64 size);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Memory operations
|
//~ Memory operations
|
||||||
|
|
||||||
//- Wrappers
|
//- Wrappers
|
||||||
@ -28,7 +28,7 @@ void SetMemoryReadWrite(void *address, u64 size);
|
|||||||
#define SetBytes(dst, c, count) memset(dst, c, count)
|
#define SetBytes(dst, c, count) memset(dst, c, count)
|
||||||
#define CmpBytes(p1, p2, count) memcmp(p1, p2, count)
|
#define CmpBytes(p1, p2, count) memcmp(p1, p2, count)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Crtlib stubs
|
//~ Crtlib stubs
|
||||||
|
|
||||||
#if CrtlibIsEnabled
|
#if CrtlibIsEnabled
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Stateful randomness
|
//~ Stateful randomness
|
||||||
|
|
||||||
u64 RandU64FromState(RandState *state)
|
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);
|
return range_start + (range_end - range_start) * ((f64)(RandU64FromState(state) % RandMaxF64) / (f64)RandMaxF64);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Seeded randomness
|
//~ Seeded randomness
|
||||||
|
|
||||||
/* Based on Jon Maiga's "mx3"
|
/* Based on Jon Maiga's "mx3"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Rand types
|
//~ Rand types
|
||||||
|
|
||||||
Struct(RandState)
|
Struct(RandState)
|
||||||
@ -10,7 +10,7 @@ Struct(RandState)
|
|||||||
/* TODO: Use a value that gives good precision when dividing into range 0 -> 1 */
|
/* TODO: Use a value that gives good precision when dividing into range 0 -> 1 */
|
||||||
#define RandMaxF64 U64Max
|
#define RandMaxF64 U64Max
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Rand operations
|
//~ Rand operations
|
||||||
|
|
||||||
//- Stateful randomness
|
//- Stateful randomness
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
SharedResourceState shared_resource_state = ZI;
|
SharedResourceState shared_resource_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void InitResourceSystem(u64 archive_strings_count, String *archive_strings)
|
void InitResourceSystem(u64 archive_strings_count, String *archive_strings)
|
||||||
@ -41,7 +41,7 @@ void InitResourceSystem(u64 archive_strings_count, String *archive_strings)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource helpers
|
//~ Resource helpers
|
||||||
|
|
||||||
b32 IsResourceNil(Resource resource)
|
b32 IsResourceNil(Resource resource)
|
||||||
@ -56,7 +56,7 @@ Resource ResourceFromStore(ResourceStore *store, String name)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource cache operations
|
//~ Resource cache operations
|
||||||
|
|
||||||
ResourceEntry *ResourceEntryFromHash(u64 hash)
|
ResourceEntry *ResourceEntryFromHash(u64 hash)
|
||||||
@ -75,7 +75,7 @@ ResourceEntry *ResourceEntryFromHash(u64 hash)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource operations
|
//~ Resource operations
|
||||||
|
|
||||||
String DataFromResource(Resource resource)
|
String DataFromResource(Resource resource)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource cache types
|
//~ Resource cache types
|
||||||
|
|
||||||
Struct(ResourceEntry)
|
Struct(ResourceEntry)
|
||||||
@ -17,7 +17,7 @@ Struct(ResourceEntryBin)
|
|||||||
ResourceEntry *last;
|
ResourceEntry *last;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
#define NumResourceEntryBins 4096
|
#define NumResourceEntryBins 4096
|
||||||
@ -30,23 +30,23 @@ Struct(SharedResourceState)
|
|||||||
ResourceEntryBin bins[NumResourceEntryBins];
|
ResourceEntryBin bins[NumResourceEntryBins];
|
||||||
} extern shared_resource_state;
|
} extern shared_resource_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void InitResourceSystem(u64 archive_strings_count, String *archive_strings);
|
void InitResourceSystem(u64 archive_strings_count, String *archive_strings);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource operations
|
//~ Resource operations
|
||||||
|
|
||||||
b32 IsResourceNil(Resource resource);
|
b32 IsResourceNil(Resource resource);
|
||||||
Resource ResourceFromStore(ResourceStore *store, String name);
|
Resource ResourceFromStore(ResourceStore *store, String name);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource cache operations
|
//~ Resource cache operations
|
||||||
|
|
||||||
ResourceEntry *ResourceEntryFromHash(u64 hash);
|
ResourceEntry *ResourceEntryFromHash(u64 hash);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource data operations
|
//~ Resource data operations
|
||||||
|
|
||||||
String DataFromResource(Resource resource);
|
String DataFromResource(Resource resource);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mutex
|
//~ Mutex
|
||||||
|
|
||||||
//- Exclusive mutex lock
|
//- Exclusive mutex lock
|
||||||
@ -135,7 +135,7 @@ void Unlock(Lock *l)
|
|||||||
ZeroStruct(l);
|
ZeroStruct(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Condition variable
|
//~ Condition variable
|
||||||
|
|
||||||
void YieldOnCv(Cv *cv, Lock *l)
|
void YieldOnCv(Cv *cv, Lock *l)
|
||||||
@ -165,7 +165,7 @@ void SignalCv(Cv *cv)
|
|||||||
FutexWakeNeq(&cv->wake_gen);
|
FutexWakeNeq(&cv->wake_gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fence
|
//~ Fence
|
||||||
|
|
||||||
i64 FetchFence(Fence *fence)
|
i64 FetchFence(Fence *fence)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mutex types
|
//~ Mutex types
|
||||||
|
|
||||||
#define DefaultMutexSpin 4000
|
#define DefaultMutexSpin 4000
|
||||||
@ -23,7 +23,7 @@ Struct(Lock)
|
|||||||
b32 exclusive;
|
b32 exclusive;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Condition variable types
|
//~ Condition variable types
|
||||||
|
|
||||||
AlignedStruct(Cv, CachelineSize)
|
AlignedStruct(Cv, CachelineSize)
|
||||||
@ -32,7 +32,7 @@ AlignedStruct(Cv, CachelineSize)
|
|||||||
};
|
};
|
||||||
StaticAssert(alignof(Cv) == CachelineSize && sizeof(Cv) % CachelineSize == 0);
|
StaticAssert(alignof(Cv) == CachelineSize && sizeof(Cv) % CachelineSize == 0);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fence types
|
//~ Fence types
|
||||||
|
|
||||||
Struct(Fence)
|
Struct(Fence)
|
||||||
@ -40,7 +40,7 @@ Struct(Fence)
|
|||||||
Atomic64Padded v;
|
Atomic64Padded v;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mutex operations
|
//~ Mutex operations
|
||||||
|
|
||||||
Lock LockSpinE(Mutex *m, i32 spin);
|
Lock LockSpinE(Mutex *m, i32 spin);
|
||||||
@ -60,13 +60,13 @@ void Unlock(Lock *lock);
|
|||||||
# define AssertLockedES(l, m) LAX l
|
# define AssertLockedES(l, m) LAX l
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Condition variable operations
|
//~ Condition variable operations
|
||||||
|
|
||||||
void YieldOnCv(Cv *cv, Lock *lock);
|
void YieldOnCv(Cv *cv, Lock *lock);
|
||||||
void SignalCv(Cv *cv);
|
void SignalCv(Cv *cv);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fence operations
|
//~ Fence operations
|
||||||
|
|
||||||
i64 FetchFence(Fence *fence);
|
i64 FetchFence(Fence *fence);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Conversion helpers
|
//~ Conversion helpers
|
||||||
|
|
||||||
//- Char conversion
|
//- Char conversion
|
||||||
@ -182,7 +182,7 @@ String StringFromUid(Arena *arena, Uid uid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ String helpers
|
//~ String helpers
|
||||||
|
|
||||||
//- Copy
|
//- Copy
|
||||||
@ -419,7 +419,7 @@ b32 StringEndsWith(String str, String substring)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ String list helpers
|
//~ String list helpers
|
||||||
|
|
||||||
StringListNode *PushStringToList(Arena *arena, StringList *l, String s)
|
StringListNode *PushStringToList(Arena *arena, StringList *l, String s)
|
||||||
@ -458,7 +458,7 @@ String StringFromList(Arena *arena, StringList l, String separator)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Trimming helpers
|
//~ Trimming helpers
|
||||||
|
|
||||||
String TrimLeft(String s, String pattern)
|
String TrimLeft(String s, String pattern)
|
||||||
@ -509,7 +509,7 @@ String TrimWhitespace(String s)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Formatting
|
//~ Formatting
|
||||||
|
|
||||||
/* String formatting only has one format specifier: "%F". All specifier info is
|
/* 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;
|
return new_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Unicode
|
//~ Unicode
|
||||||
|
|
||||||
//- Codepoint iteration
|
//- Codepoint iteration
|
||||||
|
|
||||||
CodepointIter BeginCodepointIter(String str)
|
CodepointIter InitCodepointIter(String str)
|
||||||
{
|
{
|
||||||
return (CodepointIter)
|
return (CodepointIter)
|
||||||
{
|
{
|
||||||
@ -679,7 +679,7 @@ CodepointIter BeginCodepointIter(String str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Returns 0 if done iterating */
|
/* Returns 0 if done iterating */
|
||||||
b32 AdvanceCodepointIter(CodepointIter *iter)
|
b32 NextCodepoint(CodepointIter *iter)
|
||||||
{
|
{
|
||||||
if (iter->pos < iter->src.len)
|
if (iter->pos < iter->src.len)
|
||||||
{
|
{
|
||||||
@ -695,12 +695,6 @@ b32 AdvanceCodepointIter(CodepointIter *iter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndCodepointIter(CodepointIter *iter)
|
|
||||||
{
|
|
||||||
/* Do nothing */
|
|
||||||
LAX iter;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- String decode
|
//- String decode
|
||||||
|
|
||||||
/* utf8 <- utf16 */
|
/* utf8 <- utf16 */
|
||||||
@ -805,7 +799,7 @@ String32 String32FromString(Arena *arena, String str8)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Legacy null-terminated C string operations
|
//~ Legacy null-terminated C string operations
|
||||||
|
|
||||||
//- Narrow C strings
|
//- Narrow C strings
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Formatting types
|
//~ Formatting types
|
||||||
|
|
||||||
#define DefaultFmtPrecision 3
|
#define DefaultFmtPrecision 3
|
||||||
@ -43,7 +43,7 @@ Struct(FmtArg)
|
|||||||
} value;
|
} value;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Unicode types
|
//~ Unicode types
|
||||||
|
|
||||||
Struct(CodepointIter)
|
Struct(CodepointIter)
|
||||||
@ -55,7 +55,7 @@ Struct(CodepointIter)
|
|||||||
u64 pos;
|
u64 pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Conversion helpers
|
//~ Conversion helpers
|
||||||
|
|
||||||
String StringFromChar(Arena *arena, char c);
|
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 StringFromhandle(Arena *arena, u64 v0, u64 v1);
|
||||||
String StringFromUid(Arena *arena, Uid uid);
|
String StringFromUid(Arena *arena, Uid uid);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ String helpers
|
//~ String helpers
|
||||||
|
|
||||||
String PushString(Arena *arena, String src);
|
String PushString(Arena *arena, String src);
|
||||||
@ -81,7 +81,7 @@ b32 StringContains(String str, String substring);
|
|||||||
b32 StringStartsWith(String str, String substring);
|
b32 StringStartsWith(String str, String substring);
|
||||||
b32 StringEndsWith(String str, String substring);
|
b32 StringEndsWith(String str, String substring);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Trimming helpers
|
//~ Trimming helpers
|
||||||
|
|
||||||
String TrimLeft(String s, String pattern);
|
String TrimLeft(String s, String pattern);
|
||||||
@ -89,13 +89,13 @@ String TrimRight(String s, String pattern);
|
|||||||
String Trim(String s, String pattern);
|
String Trim(String s, String pattern);
|
||||||
String TrimWhitespace(String s);
|
String TrimWhitespace(String s);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ String list helpers
|
//~ String list helpers
|
||||||
|
|
||||||
StringListNode *PushStringToList(Arena *arena, StringList *l, String s);
|
StringListNode *PushStringToList(Arena *arena, StringList *l, String s);
|
||||||
String StringFromList(Arena *arena, StringList l, String separator);
|
String StringFromList(Arena *arena, StringList l, String separator);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Formatting
|
//~ Formatting
|
||||||
|
|
||||||
//- Format arg helpers
|
//- Format arg helpers
|
||||||
@ -118,13 +118,12 @@ String StringFromList(Arena *arena, StringList l, String separator);
|
|||||||
String FormatString_(Arena *arena, String fmt, ...);
|
String FormatString_(Arena *arena, String fmt, ...);
|
||||||
String FormatStringV(Arena *arena, String fmt, va_list args);
|
String FormatStringV(Arena *arena, String fmt, va_list args);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Unicode operations
|
//~ Unicode operations
|
||||||
|
|
||||||
//- Iter
|
//- Iter
|
||||||
CodepointIter BeginCodepointIter(String str);
|
CodepointIter InitCodepointIter(String str);
|
||||||
b32 AdvanceCodepointIter(CodepointIter *iter);
|
b32 NextCodepoint(CodepointIter *iter);
|
||||||
void EndCodepointIter(CodepointIter *iter);
|
|
||||||
|
|
||||||
//- Decode string
|
//- Decode string
|
||||||
String StringFromString16(Arena *arena, String16 str16);
|
String StringFromString16(Arena *arena, String16 str16);
|
||||||
@ -134,7 +133,7 @@ String StringFromString32(Arena *arena, String32 str32);
|
|||||||
String16 String16FromString(Arena *arena, String str8);
|
String16 String16FromString(Arena *arena, String str8);
|
||||||
String32 String32FromString(Arena *arena, String str8);
|
String32 String32FromString(Arena *arena, String str8);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Legacy null-terminated C string operations
|
//~ Legacy null-terminated C string operations
|
||||||
|
|
||||||
//- Narrow strings
|
//- Narrow strings
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Uid types
|
//~ Uid types
|
||||||
|
|
||||||
Struct(Uid)
|
Struct(Uid)
|
||||||
@ -7,7 +7,7 @@ Struct(Uid)
|
|||||||
u64 lo;
|
u64 lo;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Uid operations
|
//~ Uid operations
|
||||||
|
|
||||||
#define UID(hi64, lo64) ((Uid) { .hi = (hi64), .lo = (lo64) })
|
#define UID(hi64, lo64) ((Uid) { .hi = (hi64), .lo = (lo64) })
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utf8
|
//~ Utf8
|
||||||
|
|
||||||
//- Decode
|
//- Decode
|
||||||
@ -127,7 +127,7 @@ Utf8EncodeResult EncodeUtf8(u32 codepoint)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utf16
|
//~ Utf16
|
||||||
|
|
||||||
//- Decode
|
//- Decode
|
||||||
@ -199,7 +199,7 @@ b32 IsUtf16LowSurrogate(u16 c)
|
|||||||
return 0xDC00 <= c && c < 0xE000;
|
return 0xDC00 <= c && c < 0xE000;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utf32
|
//~ Utf32
|
||||||
|
|
||||||
//- Decode
|
//- Decode
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utf8 types
|
//~ Utf8 types
|
||||||
|
|
||||||
Struct(Utf8DecodeResult)
|
Struct(Utf8DecodeResult)
|
||||||
@ -13,7 +13,7 @@ Struct(Utf8EncodeResult)
|
|||||||
u8 chars8[4];
|
u8 chars8[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utf16 types
|
//~ Utf16 types
|
||||||
|
|
||||||
Struct(Utf16DecodeResult)
|
Struct(Utf16DecodeResult)
|
||||||
@ -28,7 +28,7 @@ Struct(Utf16EncodeResult)
|
|||||||
u16 chars16[2];
|
u16 chars16[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utf32 types
|
//~ Utf32 types
|
||||||
|
|
||||||
Struct(Utf32DecodeResult)
|
Struct(Utf32DecodeResult)
|
||||||
@ -42,13 +42,13 @@ Struct(Utf32EncodeResult)
|
|||||||
u32 chars32;
|
u32 chars32;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utf8 operations
|
//~ Utf8 operations
|
||||||
|
|
||||||
Utf8DecodeResult DecodeUtf8(String str);
|
Utf8DecodeResult DecodeUtf8(String str);
|
||||||
Utf8EncodeResult EncodeUtf8(u32 codepoint);
|
Utf8EncodeResult EncodeUtf8(u32 codepoint);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utf16 operations
|
//~ Utf16 operations
|
||||||
|
|
||||||
Utf16DecodeResult DecodeUtf16(String16 str);
|
Utf16DecodeResult DecodeUtf16(String16 str);
|
||||||
@ -57,7 +57,7 @@ Utf16EncodeResult EncodeUtf16(u32 codepoint);
|
|||||||
b32 IsUtf16HighSurrogate(u16 c);
|
b32 IsUtf16HighSurrogate(u16 c);
|
||||||
b32 IsUtf16LowSurrogate(u16 c);
|
b32 IsUtf16LowSurrogate(u16 c);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Utf32 operations
|
//~ Utf32 operations
|
||||||
|
|
||||||
Utf32DecodeResult DecodeUtf32(String32 str);
|
Utf32DecodeResult DecodeUtf32(String32 str);
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Hash types
|
//~ Hash types
|
||||||
|
|
||||||
#define Fnv64Basis 0xCBF29CE484222325
|
#define Fnv64Basis 0xCBF29CE484222325
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mergesort types
|
//~ Mergesort types
|
||||||
|
|
||||||
/* Compare functions should
|
/* 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)
|
#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);
|
typedef MergesortCompareFuncDef(MergesortCompareFunc, a, b, udata);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Dict types
|
//~ Dict types
|
||||||
|
|
||||||
Struct(DictEntry)
|
Struct(DictEntry)
|
||||||
@ -42,7 +42,7 @@ Struct(Dict)
|
|||||||
DictEntry *last;
|
DictEntry *last;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Hash utils
|
//~ Hash utils
|
||||||
|
|
||||||
/* FNV-1a parameters for different hash sizes:
|
/* FNV-1a parameters for different hash sizes:
|
||||||
@ -59,7 +59,7 @@ Inline u64 HashFnv64(u64 seed, String s)
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mergesort utils
|
//~ Mergesort utils
|
||||||
|
|
||||||
Inline void MergesortInternal(u8 *left, u8 *right, u8 *items, u64 left_count, u64 right_count, u64 item_size, MergesortCompareFunc *callback, void *udata)
|
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 utils
|
||||||
|
|
||||||
//- Dict init
|
//- Dict init
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
W32_SharedState W32_shared_state = ZI;
|
W32_SharedState W32_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 embedded data
|
//~ Win32 embedded data
|
||||||
|
|
||||||
BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name, LONG_PTR udata)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Core hooks
|
//~ @hookdef Core hooks
|
||||||
|
|
||||||
StringList GetCommandLineArgs(void)
|
StringList GetCommandLineArgs(void)
|
||||||
@ -132,7 +132,7 @@ void ExitNow(i32 code)
|
|||||||
ExitProcess(code);
|
ExitProcess(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup / shutdown jobs
|
//~ Startup / shutdown jobs
|
||||||
|
|
||||||
JobDef(W32_StartupLayers, UNUSED sig, UNUSED id)
|
JobDef(W32_StartupLayers, UNUSED sig, UNUSED id)
|
||||||
@ -159,7 +159,7 @@ JobDef(W32_ShutdownLayers, UNUSED sig, UNUSED id)
|
|||||||
SetEvent(g->exit_end_event);
|
SetEvent(g->exit_end_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Main
|
//~ Main
|
||||||
|
|
||||||
i32 W32_Main(void)
|
i32 W32_Main(void)
|
||||||
@ -334,7 +334,7 @@ i32 W32_Main(void)
|
|||||||
return Atomic32Fetch(&g->exit_code);
|
return Atomic32Fetch(&g->exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Crt main
|
//~ Crt main
|
||||||
|
|
||||||
#if CrtlibIsEnabled
|
#if CrtlibIsEnabled
|
||||||
@ -351,7 +351,7 @@ int CALLBACK wWinMain(UNUSED _In_ HINSTANCE instance, UNUSED _In_opt_ HINSTANCE
|
|||||||
# endif /* IsConsoleApp */
|
# endif /* IsConsoleApp */
|
||||||
#endif /* CrtlibIsEnabled */
|
#endif /* CrtlibIsEnabled */
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Crt stub
|
//~ Crt stub
|
||||||
|
|
||||||
#if !CrtlibIsEnabled
|
#if !CrtlibIsEnabled
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 libs
|
//~ Win32 libs
|
||||||
|
|
||||||
#ifndef BCRYPT_RNG_ALG_HANDLE
|
#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, "user32")
|
||||||
#pragma comment(lib, "bcrypt")
|
#pragma comment(lib, "bcrypt")
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Embedded data iter types
|
//~ Embedded data iter types
|
||||||
|
|
||||||
Struct(W32_FindEmbeddedDataCtx)
|
Struct(W32_FindEmbeddedDataCtx)
|
||||||
@ -19,7 +19,7 @@ Struct(W32_FindEmbeddedDataCtx)
|
|||||||
String embedded_strings[64];
|
String embedded_strings[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
#define W32_MaxOnExitFuncs 4096
|
#define W32_MaxOnExitFuncs 4096
|
||||||
@ -47,19 +47,19 @@ Struct(W32_SharedState)
|
|||||||
ExitFunc *exit_funcs[W32_MaxOnExitFuncs];
|
ExitFunc *exit_funcs[W32_MaxOnExitFuncs];
|
||||||
} extern W32_shared_state;
|
} extern W32_shared_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Embedded data initialization
|
//~ Embedded data initialization
|
||||||
|
|
||||||
#define W32_EmbeddedDataPrefix EMBEDDED_RESOURCE_DATA__
|
#define W32_EmbeddedDataPrefix EMBEDDED_RESOURCE_DATA__
|
||||||
BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name, LONG_PTR udata);
|
BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name, LONG_PTR udata);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup / shutdown jobs
|
//~ Startup / shutdown jobs
|
||||||
|
|
||||||
JobDecl(W32_StartupLayers, EmptySig);
|
JobDecl(W32_StartupLayers, EmptySig);
|
||||||
JobDecl(W32_ShutdownLayers, EmptySig);
|
JobDecl(W32_ShutdownLayers, EmptySig);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Main
|
//~ Main
|
||||||
|
|
||||||
i32 W32_Main(void);
|
i32 W32_Main(void);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
W32_SharedJobState W32_shared_job_state = ZI;
|
W32_SharedJobState W32_shared_job_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Startup
|
//~ @hookdef Startup
|
||||||
|
|
||||||
void InitJobSystem(void)
|
void InitJobSystem(void)
|
||||||
@ -85,7 +85,7 @@ void InitJobSystem(void)
|
|||||||
//OnExit(ShutdownJobs);
|
//OnExit(ShutdownJobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 thread
|
//~ Win32 thread
|
||||||
|
|
||||||
JobDef(W32_DummyJob, sig, id)
|
JobDef(W32_DummyJob, sig, id)
|
||||||
@ -178,7 +178,7 @@ void W32_WaitEndThread(W32_Thread *thread)
|
|||||||
Assert(ok);
|
Assert(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 fiber
|
//~ Win32 fiber
|
||||||
|
|
||||||
//- Acquire fiber
|
//- Acquire fiber
|
||||||
@ -330,7 +330,7 @@ void W32_SwitchToFiber(W32_Fiber *target)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 fiber entry
|
//~ Win32 fiber entry
|
||||||
|
|
||||||
void W32_FiberEntryPoint(void *_)
|
void W32_FiberEntryPoint(void *_)
|
||||||
@ -398,7 +398,7 @@ DWORD WINAPI W32_VirtualFiberEntryPoint(LPVOID arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 job worker entry
|
//~ Win32 job worker entry
|
||||||
|
|
||||||
W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg)
|
W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg)
|
||||||
@ -525,7 +525,7 @@ W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Fiber suspend/resume operations
|
//~ @hookdef Fiber suspend/resume operations
|
||||||
|
|
||||||
void SuspendFiber(void)
|
void SuspendFiber(void)
|
||||||
@ -619,7 +619,7 @@ void ResumeFibers(i16 fiber_ids_count, i16 *fiber_ids)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hoodef Job operations
|
//~ @hoodef Job operations
|
||||||
|
|
||||||
Job *OpenJob(JobFunc *func, JobPool pool_kind)
|
Job *OpenJob(JobFunc *func, JobPool pool_kind)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 libs
|
//~ Win32 libs
|
||||||
|
|
||||||
#pragma warning(push, 0)
|
#pragma warning(push, 0)
|
||||||
@ -23,7 +23,7 @@
|
|||||||
#pragma comment(lib, "avrt")
|
#pragma comment(lib, "avrt")
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Thread types
|
//~ Thread types
|
||||||
|
|
||||||
#define W32_ThreadDef(name, arg_name) void name(void *arg_name)
|
#define W32_ThreadDef(name, arg_name) void name(void *arg_name)
|
||||||
@ -39,7 +39,7 @@ Struct(W32_Thread)
|
|||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fiber types
|
//~ Fiber types
|
||||||
|
|
||||||
#define W32_FiberStackSize Mebi(1)
|
#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 */
|
StaticAssert(alignof(W32_Fiber) == CachelineSize && sizeof(W32_Fiber) % CachelineSize == 0); /* False sharing validation */
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Job pool types
|
//~ Job pool types
|
||||||
|
|
||||||
//- Worker ctx
|
//- Worker ctx
|
||||||
@ -142,7 +142,7 @@ AlignedStruct(W32_JobPool, CachelineSize)
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
/* Arbitrary threshold for determining when to use a looped WakeByAddressSingle vs a WakeByAddressAll to wake parked workers */
|
/* 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;
|
} extern W32_shared_job_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void StartupJobs(void);
|
void StartupJobs(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Thread operations
|
//~ Thread operations
|
||||||
|
|
||||||
DWORD WINAPI W32_Win32ThreadProc(LPVOID vt);
|
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);
|
void W32_WaitEndThread(W32_Thread *thread);
|
||||||
JobDecl(W32_DummyJob, EmptySig);
|
JobDecl(W32_DummyJob, EmptySig);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fiber operations
|
//~ Fiber operations
|
||||||
|
|
||||||
W32_Fiber *W32_AcquireFiber(W32_JobPool *pool);
|
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_SwitchToFiber(W32_Fiber *target);
|
||||||
void W32_YieldFiber(W32_Fiber *fiber, W32_Fiber *parent_fiber);
|
void W32_YieldFiber(W32_Fiber *fiber, W32_Fiber *parent_fiber);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Fiber entry
|
//~ Fiber entry
|
||||||
|
|
||||||
void W32_FiberEntryPoint(void *wi32_fiber_data);
|
void W32_FiberEntryPoint(void *wi32_fiber_data);
|
||||||
DWORD WINAPI W32_VirtualFiberEntryPoint(LPVOID arg);
|
DWORD WINAPI W32_VirtualFiberEntryPoint(LPVOID arg);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Job worker entry
|
//~ Job worker entry
|
||||||
|
|
||||||
W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg);
|
W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Debug
|
//~ Debug
|
||||||
|
|
||||||
#if COLLIDER_DEBUG
|
#if COLLIDER_DEBUG
|
||||||
@ -10,7 +10,7 @@ void CLD_DebugBreakable(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shape
|
//~ Shape
|
||||||
|
|
||||||
CLD_Shape CLD_ShapeFromQuad(Quad quad)
|
CLD_Shape CLD_ShapeFromQuad(Quad quad)
|
||||||
@ -25,7 +25,7 @@ CLD_Shape CLD_ShapeFromQuad(Quad quad)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Menkowski support point
|
//~ Menkowski support point
|
||||||
|
|
||||||
CLD_SupportPoint CLD_SupportPointFromDirEx(CLD_Shape *shape, Xform xf, Vec2 dir, i32 ignore)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Aabb
|
//~ Aabb
|
||||||
|
|
||||||
Aabb CLD_AabbFromShape(CLD_Shape *shape, Xform xf)
|
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));
|
((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
|
//~ Gjk
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -308,7 +308,7 @@ CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Epa
|
//~ Epa
|
||||||
|
|
||||||
/* Expands upon result of GJK calculation to determine collision normal &
|
/* 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Clipping
|
//~ Clipping
|
||||||
|
|
||||||
CLD_ClippedLine CLD_ClipLineToLine(Vec2 a0, Vec2 b0, Vec2 a1, Vec2 b1, Vec2 normal)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Collision points
|
//~ Collision points
|
||||||
|
|
||||||
CLD_CollisionData CLD_CollisionDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1)
|
CLD_CollisionData CLD_CollisionDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1)
|
||||||
@ -814,7 +814,7 @@ abort:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Closest points
|
//~ Closest points
|
||||||
|
|
||||||
/* TODO: De-duplicate code between CLD_ClosestPointDataFromShapes & CLD_CollisionDataFromShapes */
|
/* TODO: De-duplicate code between CLD_ClosestPointDataFromShapes & CLD_CollisionDataFromShapes */
|
||||||
@ -901,7 +901,7 @@ abort:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Time of impact
|
//~ Time of impact
|
||||||
|
|
||||||
/* Takes 2 shapes and their xforms at t=0 and t=1.
|
/* 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;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Point cloud debugging
|
//~ Point cloud debugging
|
||||||
|
|
||||||
/* TODO: Remove this (debugging) */
|
/* TODO: Remove this (debugging) */
|
||||||
@ -1027,7 +1027,7 @@ Vec2Array CLD_PointCloud(Arena *arena, CLD_Shape *shape0, CLD_Shape *shape1, Xfo
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Boolean GJK (unused)
|
//~ Boolean GJK (unused)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tweakable defines
|
//~ Tweakable defines
|
||||||
|
|
||||||
/* How close can non-overlapping shapes be before collision is considered */
|
/* 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 */
|
/* To prevent extremely large prototypes when origin is in exact center of rounded feature */
|
||||||
#define CLD_MaxEpaIterations 64
|
#define CLD_MaxEpaIterations 64
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shape types
|
//~ Shape types
|
||||||
|
|
||||||
Struct(CLD_Shape)
|
Struct(CLD_Shape)
|
||||||
@ -20,7 +20,7 @@ Struct(CLD_Shape)
|
|||||||
f32 radius;
|
f32 radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Menkowski types
|
//~ Menkowski types
|
||||||
|
|
||||||
Struct(CLD_SupportPoint)
|
Struct(CLD_SupportPoint)
|
||||||
@ -48,7 +48,7 @@ Struct(CLD_MenkowskiFeature)
|
|||||||
CLD_MenkowskiPoint a, b;
|
CLD_MenkowskiPoint a, b;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Collision types
|
//~ Collision types
|
||||||
|
|
||||||
Struct(CLD_CollisionPoint)
|
Struct(CLD_CollisionPoint)
|
||||||
@ -91,7 +91,7 @@ Struct(CLD_ClosestPointData)
|
|||||||
CLD_Prototype prototype;
|
CLD_Prototype prototype;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Clipping types
|
//~ Clipping types
|
||||||
|
|
||||||
Struct(CLD_ClippedLine)
|
Struct(CLD_ClippedLine)
|
||||||
@ -100,7 +100,7 @@ Struct(CLD_ClippedLine)
|
|||||||
Vec2 a1_clipped, b1_clipped;
|
Vec2 a1_clipped, b1_clipped;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Gjk types
|
//~ Gjk types
|
||||||
|
|
||||||
Struct(CLD_GjkData)
|
Struct(CLD_GjkData)
|
||||||
@ -118,7 +118,7 @@ Struct(CLD_GjkData)
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Epa types
|
//~ Epa types
|
||||||
|
|
||||||
Struct(CLD_EpaData)
|
Struct(CLD_EpaData)
|
||||||
@ -132,7 +132,7 @@ Struct(CLD_EpaData)
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Debug helpers
|
//~ Debug helpers
|
||||||
|
|
||||||
#if COLLIDER_DEBUG
|
#if COLLIDER_DEBUG
|
||||||
@ -152,26 +152,26 @@ void CLD_DebugBreakable(void);
|
|||||||
#define CLD_DBGSTEP
|
#define CLD_DBGSTEP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shape operations
|
//~ Shape operations
|
||||||
|
|
||||||
CLD_Shape CLD_ShapeFromQuad(Quad quad);
|
CLD_Shape CLD_ShapeFromQuad(Quad quad);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Menkowski operations
|
//~ Menkowski operations
|
||||||
|
|
||||||
CLD_SupportPoint CLD_SupportPointFromDirEx(CLD_Shape *shape, Xform xf, Vec2 dir, i32 ignore);
|
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_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);
|
CLD_MenkowskiPoint CLD_MenkowskiPointFromDir(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1, Vec2 dir);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Aabb operations
|
//~ Aabb operations
|
||||||
|
|
||||||
Aabb CLD_AabbFromShape(CLD_Shape *shape, Xform xf);
|
Aabb CLD_AabbFromShape(CLD_Shape *shape, Xform xf);
|
||||||
Aabb CLD_CombineAabb(Aabb b0, Aabb b1);
|
Aabb CLD_CombineAabb(Aabb b0, Aabb b1);
|
||||||
b32 CLD_TestAabb(Aabb box0, Aabb box1);
|
b32 CLD_TestAabb(Aabb box0, Aabb box1);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Gjk operations
|
//~ Gjk operations
|
||||||
|
|
||||||
#if COLLIDER_DEBUG
|
#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);
|
CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1, f32 min_unique_pt_dist_sq);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Epa operations
|
//~ Epa operations
|
||||||
|
|
||||||
#if COLLIDER_DEBUG
|
#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);
|
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
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Clipping operations
|
//~ Clipping operations
|
||||||
|
|
||||||
CLD_ClippedLine CLD_ClipLineToLine(Vec2 a0, Vec2 b0, Vec2 a1, Vec2 b1, Vec2 normal);
|
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);
|
Vec2 CLD_ClipPointToLine(Vec2 a, Vec2 b, Vec2 p, Vec2 normal);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Collision point operations
|
//~ Collision point operations
|
||||||
|
|
||||||
CLD_CollisionData CLD_CollisionDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1);
|
CLD_CollisionData CLD_CollisionDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Closest point operations
|
//~ Closest point operations
|
||||||
|
|
||||||
CLD_ClosestPointData CLD_ClosestPointDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1);
|
CLD_ClosestPointData CLD_ClosestPointDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Time of impact operations
|
//~ 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);
|
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
|
//~ Point cloud debugging operations
|
||||||
|
|
||||||
Vec2Array CLD_Menkowski(Arena *arena, CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1, u32 detail);
|
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_WINDOW -(i64)Mebi(2)
|
||||||
#define PROF_THREAD_GROUP_MAIN -(i64)Mebi(1)
|
#define PROF_THREAD_GROUP_MAIN -(i64)Mebi(1)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Settings
|
//~ Settings
|
||||||
|
|
||||||
/* TODO: Move these to user-configurable settings */
|
/* TODO: Move these to user-configurable settings */
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
D_SharedState D_shared_state = ZI;
|
D_SharedState D_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void D_Startup(void)
|
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);
|
g->solid_white_texture = GPU_AcquireTexture(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, VEC2I32(1, 1), &pixel_white);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Material
|
//~ Material
|
||||||
|
|
||||||
void D_DrawMaterial(GPU_RenderSig *sig, D_MaterialParams params)
|
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);
|
GPU_PushRenderCmd(sig, &cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Solid shapes
|
//~ Solid shapes
|
||||||
|
|
||||||
void D_DrawPolyEx(GPU_RenderSig *sig, Vec2Array vertices, GPU_Indices indices, u32 color)
|
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);
|
D_DrawPolyEx(sig, vertices, indices, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Line shapes
|
//~ Line shapes
|
||||||
|
|
||||||
void D_DrawLineGradient(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 start_color, u32 end_color)
|
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);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Grid
|
//~ 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)
|
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);
|
GPU_PushRenderCmd(sig, &cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ui
|
//~ Ui
|
||||||
|
|
||||||
void D_DrawUiRect(GPU_RenderSig *sig, D_UiRectParams params)
|
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);
|
GPU_PushRenderCmd(sig, &cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Text
|
//~ Text
|
||||||
|
|
||||||
/* Returns the rect of the text area */
|
/* Returns the rect of the text area */
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Material types
|
//~ Material types
|
||||||
|
|
||||||
Struct(D_MaterialParams)
|
Struct(D_MaterialParams)
|
||||||
@ -16,7 +16,7 @@ Struct(D_MaterialParams)
|
|||||||
__VA_ARGS__ \
|
__VA_ARGS__ \
|
||||||
})
|
})
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ui types
|
//~ Ui types
|
||||||
|
|
||||||
Struct(D_UiRectParams)
|
Struct(D_UiRectParams)
|
||||||
@ -32,7 +32,7 @@ Struct(D_UiRectParams)
|
|||||||
__VA_ARGS__ \
|
__VA_ARGS__ \
|
||||||
})
|
})
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Text types
|
//~ Text types
|
||||||
|
|
||||||
/* How is text aligned within its area */
|
/* How is text aligned within its area */
|
||||||
@ -98,7 +98,7 @@ Struct(D_TextParams)
|
|||||||
__VA_ARGS__ \
|
__VA_ARGS__ \
|
||||||
})
|
})
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
Struct(D_SharedState)
|
Struct(D_SharedState)
|
||||||
@ -106,17 +106,17 @@ Struct(D_SharedState)
|
|||||||
GPU_Resource *solid_white_texture;
|
GPU_Resource *solid_white_texture;
|
||||||
} extern D_shared_state;
|
} extern D_shared_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void D_Startup(void);
|
void D_Startup(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Material operations
|
//~ Material operations
|
||||||
|
|
||||||
void D_DrawMaterial(GPU_RenderSig *sig, D_MaterialParams params);
|
void D_DrawMaterial(GPU_RenderSig *sig, D_MaterialParams params);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Solid shape operations
|
//~ Solid shape operations
|
||||||
|
|
||||||
void D_DrawPolyEx(GPU_RenderSig *sig, Vec2Array vertices, GPU_Indices indices, u32 color);
|
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_DrawCircle(GPU_RenderSig *sig, Vec2 pos, f32 radius, u32 color, u32 detail);
|
||||||
void D_DrawQuad(GPU_RenderSig *sig, Quad quad, u32 color);
|
void D_DrawQuad(GPU_RenderSig *sig, Quad quad, u32 color);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Line shape operations
|
//~ Line shape operations
|
||||||
|
|
||||||
void D_DrawLineGradient(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 start_color, u32 end_color);
|
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_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);
|
void D_DrawColliderLine(GPU_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 thickness, u32 color, u32 detail);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Grid operations
|
//~ 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);
|
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
|
//~ Ui operations
|
||||||
|
|
||||||
void D_DrawUiRect(GPU_RenderSig *sig, D_UiRectParams params);
|
void D_DrawUiRect(GPU_RenderSig *sig, D_UiRectParams params);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Text operations
|
//~ Text operations
|
||||||
|
|
||||||
Rect draw_text(GPU_RenderSig *sig, D_TextParams params);
|
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, _)
|
JobDef(F_Load, sig, _)
|
||||||
{
|
{
|
||||||
@ -45,20 +45,73 @@ JobDef(F_Load, sig, _)
|
|||||||
"Font \"%F\" not found",
|
"Font \"%F\" not found",
|
||||||
FmtString(name)));
|
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 */
|
/* Send texture to GPU */
|
||||||
GPU_Resource *texture = 0;
|
GPU_Resource *texture = 0;
|
||||||
{
|
{
|
||||||
GPU_ResourceDesc desc = ZI;
|
GPU_ResourceDesc desc = ZI;
|
||||||
desc.kind = GPU_ResourceKind_Texture2D;
|
desc.kind = GPU_ResourceKind_Texture2D;
|
||||||
|
desc.flags = GPU_ResourceFlag_None;
|
||||||
desc.texture.format = GPU_Format_R8G8B8A8_Unorm;
|
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);
|
texture = GPU_AcquireResource(desc);
|
||||||
/* FIXME: Copy to GPU resource here */
|
|
||||||
//GPU_Mapped mapped = GPU_Map(texture);
|
/* Fill upload buffer */
|
||||||
//GPU_CopyToMapped(&mapped, STRING(desc.texture.size.x * desc.texture.size.y * 4, (u8 *)result.image_pixels));
|
GPU_ResourceDesc upload_desc = ZI;
|
||||||
//GPU_Unmap(&mapped);
|
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 */
|
/* Acquire store memory */
|
||||||
@ -66,16 +119,16 @@ JobDef(F_Load, sig, _)
|
|||||||
{
|
{
|
||||||
AC_Store store = AC_OpenStore();
|
AC_Store store = AC_OpenStore();
|
||||||
font = PushStruct(store.arena, F_Font);
|
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);
|
font->lookup = PushStructs(store.arena, u16, F_LookupTableSize);
|
||||||
AC_CloseStore(&store);
|
AC_CloseStore(&store);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set font data */
|
/* Set font data */
|
||||||
font->texture = texture;
|
font->texture = texture;
|
||||||
font->image_width = result.image_width;
|
font->image_width = decoded.image_width;
|
||||||
font->image_height = result.image_height;
|
font->image_height = decoded.image_height;
|
||||||
font->glyphs_count = result.glyphs_count;
|
font->glyphs_count = decoded.glyphs_count;
|
||||||
font->point_size = point_size;
|
font->point_size = point_size;
|
||||||
|
|
||||||
/* FIXME: Load baked font instead of panicking */
|
/* FIXME: Load baked font instead of panicking */
|
||||||
@ -86,15 +139,15 @@ JobDef(F_Load, sig, _)
|
|||||||
FmtString(name)));
|
FmtString(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy glyphs from decode result */
|
/* Copy glyphs from decode decoded */
|
||||||
StaticAssert(sizeof(*font->glyphs) == sizeof(*result.glyphs)); /* Font glyph size must match TTF glyph size for memcpy */
|
StaticAssert(sizeof(*font->glyphs) == sizeof(*decoded.glyphs)); /* Font glyph size must match TTF glyph size for memcpy */
|
||||||
CopyBytes(font->glyphs, result.glyphs, sizeof(*font->glyphs) * result.glyphs_count);
|
CopyBytes(font->glyphs, decoded.glyphs, sizeof(*font->glyphs) * decoded.glyphs_count);
|
||||||
|
|
||||||
/* Build lookup table */
|
/* Build lookup table */
|
||||||
for (u64 i = 0; i < countof(font_codes); ++i)
|
for (u64 i = 0; i < countof(font_codes); ++i)
|
||||||
{
|
{
|
||||||
u32 codepoint = 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)));
|
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);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Load
|
//~ Font load operations
|
||||||
|
|
||||||
/* Returns the asset from the asset cache */
|
/* Returns the asset from the asset cache */
|
||||||
AC_Asset *F_LoadAsset(Resource resource, f32 point_size, b32 wait)
|
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);
|
Job *job = OpenJob(F_Load, JobPool_Background);
|
||||||
F_Load_Sig *sig = PushStruct(job->arena, F_Load_Sig);
|
F_Load_Sig *sig = PushStruct(job->arena, F_Load_Sig);
|
||||||
|
job->sig = sig;
|
||||||
sig->asset = asset;
|
sig->asset = asset;
|
||||||
sig->resource = resource;
|
sig->resource = resource;
|
||||||
sig->point_size = point_size;
|
sig->point_size = point_size;
|
||||||
@ -160,25 +214,42 @@ F_Font *F_LoadFontWait(Resource resource, f32 point_size)
|
|||||||
return f;
|
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)
|
if (codepoint < F_LookupTableSize)
|
||||||
{
|
{
|
||||||
u16 index = font->lookup[codepoint];
|
u16 index = font->lookup[codepoint];
|
||||||
if (index < font->glyphs_count)
|
if (index < font->glyphs_count)
|
||||||
{
|
{
|
||||||
return &font->glyphs[index];
|
return font->glyphs[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (codepoint == '?')
|
if (codepoint == '?')
|
||||||
{
|
{
|
||||||
return &font->glyphs[font->lookup[0]];
|
return font->glyphs[font->lookup[0]];
|
||||||
}
|
}
|
||||||
else
|
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
|
//~ Font types
|
||||||
|
|
||||||
#define F_LookupTableSize (256)
|
#define F_LookupTableSize (256)
|
||||||
@ -13,6 +13,14 @@ Struct(F_Glyph)
|
|||||||
Rect atlas_rect;
|
Rect atlas_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Struct(F_GlyphRun)
|
||||||
|
{
|
||||||
|
f32 width;
|
||||||
|
f32 height;
|
||||||
|
u64 count;
|
||||||
|
F_Glyph *glyphs;
|
||||||
|
};
|
||||||
|
|
||||||
Struct(F_Font)
|
Struct(F_Font)
|
||||||
{
|
{
|
||||||
GPU_Resource *texture;
|
GPU_Resource *texture;
|
||||||
@ -24,19 +32,20 @@ Struct(F_Font)
|
|||||||
u16 *lookup;
|
u16 *lookup;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Font load job
|
//~ Font load job
|
||||||
|
|
||||||
JobDecl(F_Load, { AC_Asset *asset; f32 point_size; Resource resource; });
|
JobDecl(F_Load, { AC_Asset *asset; f32 point_size; Resource resource; });
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Font load operations
|
//~ Font load operations
|
||||||
|
|
||||||
AC_Asset *F_LoadAsset(Resource resource, f32 point_size, b32 wait);
|
AC_Asset *F_LoadAsset(Resource resource, f32 point_size, b32 wait);
|
||||||
F_Font *F_LoadFontAsync(Resource resource, f32 point_size);
|
F_Font *F_LoadFontAsync(Resource resource, f32 point_size);
|
||||||
F_Font *F_LoadFontWait(Resource resource, f32 point_size);
|
F_Font *F_LoadFontWait(Resource resource, f32 point_size);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Font data operations
|
//~ 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
|
//~ Opaque types
|
||||||
|
|
||||||
Struct(GPU_Resource);
|
Struct(GPU_Resource);
|
||||||
Struct(GPU_CommandList);
|
Struct(GPU_CommandList);
|
||||||
Struct(GPU_Swapchain);
|
Struct(GPU_Swapchain);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Queue types
|
//~ Queue types
|
||||||
|
|
||||||
#define GPU_MultiQueueEnabled !ProfilingIsEnabled
|
#define GPU_MultiQueueEnabled !ProfilingIsEnabled
|
||||||
@ -26,7 +26,7 @@ Enum(GPU_QueueKind)
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Format types
|
//~ Format types
|
||||||
|
|
||||||
/* NOTE: Matches DirectX DXGI_FORMAT */
|
/* NOTE: Matches DirectX DXGI_FORMAT */
|
||||||
@ -157,7 +157,7 @@ Enum(GPU_Format)
|
|||||||
GPU_Format_Count = 192
|
GPU_Format_Count = 192
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Filter types
|
//~ Filter types
|
||||||
|
|
||||||
/* NOTE: Matches DirectX D3D12_FILTER */
|
/* NOTE: Matches DirectX D3D12_FILTER */
|
||||||
@ -236,7 +236,7 @@ Enum(GPU_ComparisonFunc)
|
|||||||
GPU_ComparisonFunc_Always = 8
|
GPU_ComparisonFunc_Always = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource types
|
//~ Resource types
|
||||||
|
|
||||||
#define GPU_MaxRenderTargets 8
|
#define GPU_MaxRenderTargets 8
|
||||||
@ -317,7 +317,7 @@ Struct(GPU_Mapped)
|
|||||||
void *mem;
|
void *mem;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Rasterizer types
|
//~ Rasterizer types
|
||||||
|
|
||||||
Enum(GPU_RasterizeMode)
|
Enum(GPU_RasterizeMode)
|
||||||
@ -348,7 +348,7 @@ Struct(GPU_Scissor)
|
|||||||
f32 bottom;
|
f32 bottom;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Memory info types
|
//~ Memory info types
|
||||||
|
|
||||||
Struct(GPU_MemoryInfo)
|
Struct(GPU_MemoryInfo)
|
||||||
@ -357,24 +357,24 @@ Struct(GPU_MemoryInfo)
|
|||||||
u64 non_local_used;
|
u64 non_local_used;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Startup
|
//~ @hookdecl Startup
|
||||||
|
|
||||||
void GPU_Startup(void);
|
void GPU_Startup(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Fence operations
|
//~ @hookdecl Fence operations
|
||||||
|
|
||||||
Fence *GPU_FenceFromQueue(GPU_QueueKind queue);
|
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 */
|
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
|
//~ @hookdecl Rasterizer helpers
|
||||||
|
|
||||||
GPU_Viewport GPU_ViewportFromRect(Rect rect);
|
GPU_Viewport GPU_ViewportFromRect(Rect rect);
|
||||||
GPU_Scissor GPU_ScissorFromRect(Rect rect);
|
GPU_Scissor GPU_ScissorFromRect(Rect rect);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Resource operations
|
//~ @hookdecl Resource operations
|
||||||
|
|
||||||
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc);
|
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc);
|
||||||
@ -386,7 +386,7 @@ u64 GPU_GetFootprintSize(GPU_Resource *resource);
|
|||||||
|
|
||||||
u64 GPU_GetBufferCount(GPU_Resource *gpu_resource);
|
u64 GPU_GetBufferCount(GPU_Resource *gpu_resource);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Resource index operations
|
//~ @hookdecl Resource index operations
|
||||||
|
|
||||||
StructuredBufferRid GPU_StructuredBufferRidFromResource(GPU_Resource *resource);
|
StructuredBufferRid GPU_StructuredBufferRidFromResource(GPU_Resource *resource);
|
||||||
@ -399,18 +399,18 @@ RWTexture2DRid GPU_RWTexture2DRidFromResource(GPU_Resource *resource);
|
|||||||
RWTexture3DRid GPU_RWTexture3DRidFromResource(GPU_Resource *resource);
|
RWTexture3DRid GPU_RWTexture3DRidFromResource(GPU_Resource *resource);
|
||||||
SamplerStateRid GPU_SamplerStateRidFromResource(GPU_Resource *resource);
|
SamplerStateRid GPU_SamplerStateRidFromResource(GPU_Resource *resource);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Command list operations
|
//~ @hookdecl Command list operations
|
||||||
|
|
||||||
GPU_CommandList *GPU_BeginCommandList(GPU_QueueKind queue);
|
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 */
|
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
|
//~ @hookdecl Profiling helpers
|
||||||
|
|
||||||
void GPU_ProfN(GPU_CommandList *cl, String name);
|
void GPU_ProfN(GPU_CommandList *cl, String name);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Barrier operations
|
//~ @hookdecl Barrier operations
|
||||||
|
|
||||||
void GPU_TransitionToReadable(GPU_CommandList *cl, GPU_Resource *resource); /* Allows the resource to be read via read-only types in shaders */
|
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 */
|
void GPU_FlushWritable(GPU_CommandList *cl, GPU_Resource *resource); /* Waits until writes to a shader writable resource have completed */
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Dispatch operations
|
//~ @hookdecl Dispatch operations
|
||||||
|
|
||||||
void GPU_ClearRenderable(GPU_CommandList *cl, GPU_Resource *resource);
|
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_y,
|
||||||
u32 num_threads_z);
|
u32 num_threads_z);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Resource copy operations
|
//~ @hookdecl Resource copy operations
|
||||||
|
|
||||||
void GPU_CopyResource(GPU_CommandList *cl, GPU_Resource *dst, GPU_Resource *src);
|
void GPU_CopyResource(GPU_CommandList *cl, GPU_Resource *dst, GPU_Resource *src);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Map operations
|
//~ @hookdecl Map operations
|
||||||
|
|
||||||
GPU_Mapped GPU_Map(GPU_Resource *r);
|
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);
|
void GPU_CopyBytesToFootprint(void *dst, void *src, GPU_Resource *footprint_reference);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Memory info operations
|
//~ @hookdecl Memory info operations
|
||||||
|
|
||||||
GPU_MemoryInfo GPU_QueryMemoryInfo(void);
|
GPU_MemoryInfo GPU_QueryMemoryInfo(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Swapchain operations
|
//~ @hookdecl Swapchain operations
|
||||||
|
|
||||||
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, GPU_Format format, Vec2I32 size);
|
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, GPU_Format format, Vec2I32 size);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
GPU_D12_SharedState GPU_D12_shared_state = ZI;
|
GPU_D12_SharedState GPU_D12_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Helpers
|
//~ Helpers
|
||||||
|
|
||||||
GPU_D12_FiberState *GPU_D12_FiberStateFromId(i16 fiber_id)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void GPU_D12_Startup(void)
|
void GPU_D12_Startup(void)
|
||||||
@ -114,7 +114,7 @@ void GPU_D12_Startup(void)
|
|||||||
RunJob(GPU_D12_StartQueueSync, .pool = JobPool_Hyper, .flags = JobFlag_Dedicated);
|
RunJob(GPU_D12_StartQueueSync, .pool = JobPool_Hyper, .flags = JobFlag_Dedicated);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Initialization
|
//~ Initialization
|
||||||
|
|
||||||
//- Device initialization
|
//- Device initialization
|
||||||
@ -378,7 +378,7 @@ void GPU_D12_InitRootsig(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Pipeline operations
|
//~ Pipeline operations
|
||||||
|
|
||||||
JobDef(GPU_D12_LoadPipeline, sig, _)
|
JobDef(GPU_D12_LoadPipeline, sig, _)
|
||||||
@ -529,7 +529,7 @@ GPU_D12_Pipeline *GPU_D12_PipelineFromDesc(GPU_D12_PipelineDesc desc)
|
|||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Queue operations
|
//~ Queue operations
|
||||||
|
|
||||||
GPU_D12_Queue *GPU_D12_QueueFromKind(GPU_QueueKind kind)
|
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];
|
return g->queues[kind];
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Descriptor operations
|
//~ Descriptor operations
|
||||||
|
|
||||||
GPU_D12_Descriptor *GPU_D12_AcquireDescriptor(GPU_D12_DescriptorHeap *heap)
|
GPU_D12_Descriptor *GPU_D12_AcquireDescriptor(GPU_D12_DescriptorHeap *heap)
|
||||||
@ -586,7 +586,7 @@ void GPU_D12_ReleaseDescriptor(GPU_D12_Descriptor *descriptor)
|
|||||||
Unlock(&lock);
|
Unlock(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Raw command list
|
//~ Raw command list
|
||||||
|
|
||||||
GPU_D12_RawCommandList *GPU_D12_BeginRawCommandList(GPU_QueueKind queue_kind)
|
GPU_D12_RawCommandList *GPU_D12_BeginRawCommandList(GPU_QueueKind queue_kind)
|
||||||
@ -696,7 +696,7 @@ u64 GPU_D12_EndRawCommandList(GPU_D12_RawCommandList *cl)
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Swapchain helpers
|
//~ Swapchain helpers
|
||||||
|
|
||||||
void GPU_D12_InitSwapchainResources(GPU_D12_Swapchain *swapchain)
|
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;
|
return fence_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Queue sync job
|
//~ Queue sync job
|
||||||
|
|
||||||
JobDef(GPU_D12_StartQueueSync, _, __)
|
JobDef(GPU_D12_StartQueueSync, _, __)
|
||||||
@ -946,7 +946,7 @@ JobDef(GPU_D12_StartQueueSync, _, __)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Startup hook
|
//~ @hookdef Startup hook
|
||||||
|
|
||||||
void GPU_Startup(void)
|
void GPU_Startup(void)
|
||||||
@ -954,7 +954,7 @@ void GPU_Startup(void)
|
|||||||
GPU_D12_Startup();
|
GPU_D12_Startup();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Fence hooks
|
//~ @hookdef Fence hooks
|
||||||
|
|
||||||
Fence *GPU_FenceFromQueue(GPU_QueueKind queue_kind)
|
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);
|
ID3D12CommandQueue_Wait(queue_a->d3d_queue, b_fence, b_target_fence_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Rasterizer helper hooks
|
//~ @hookdef Rasterizer helper hooks
|
||||||
|
|
||||||
GPU_Viewport GPU_ViewportFromRect(Rect rect)
|
GPU_Viewport GPU_ViewportFromRect(Rect rect)
|
||||||
@ -996,7 +996,7 @@ GPU_Scissor GPU_ScissorFromRect(Rect rect)
|
|||||||
return scissor;
|
return scissor;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Resource hooks
|
//~ @hookdef Resource hooks
|
||||||
|
|
||||||
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc)
|
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc)
|
||||||
@ -1357,7 +1357,7 @@ u64 GPU_GetBufferCount(GPU_Resource *gpu_resource)
|
|||||||
return resource->desc.buffer.count;
|
return resource->desc.buffer.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Resource index hooks
|
//~ @hookdef Resource index hooks
|
||||||
|
|
||||||
StructuredBufferRid GPU_StructuredBufferRidFromResource(GPU_Resource *resource) { return (StructuredBufferRid) { ((GPU_D12_Resource *)resource)->srv_descriptor->index }; }
|
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 }; }
|
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 }; }
|
SamplerStateRid GPU_SamplerStateRidFromResource(GPU_Resource *resource) { return (SamplerStateRid) { ((GPU_D12_Resource *)resource)->sampler_descriptor->index }; }
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Command list hooks
|
//~ @hookdef Command list hooks
|
||||||
|
|
||||||
GPU_CommandList *GPU_BeginCommandList(GPU_QueueKind queue_kind)
|
GPU_CommandList *GPU_BeginCommandList(GPU_QueueKind queue_kind)
|
||||||
@ -1838,7 +1838,7 @@ i64 GPU_EndCommandList(GPU_CommandList *gpu_cl)
|
|||||||
return fence_target;
|
return fence_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Profiling helper hooks
|
//~ @hookdef Profiling helper hooks
|
||||||
|
|
||||||
void GPU_ProfN(GPU_CommandList *cl, String name)
|
void GPU_ProfN(GPU_CommandList *cl, String name)
|
||||||
@ -1846,7 +1846,7 @@ void GPU_ProfN(GPU_CommandList *cl, String name)
|
|||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Barrier hooks
|
//~ @hookdef Barrier hooks
|
||||||
|
|
||||||
void GPU_TransitionToReadable(GPU_CommandList *cl, GPU_Resource *resource)
|
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;
|
cmd->barrier.resource = (GPU_D12_Resource *)resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Dispatch hooks
|
//~ @hookdef Dispatch hooks
|
||||||
|
|
||||||
void GPU_ClearRenderable(GPU_CommandList *gpu_cl, GPU_Resource *resource)
|
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;
|
cmd->compute.num_threads_z = num_threads_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Copy hooks
|
//~ @hookdef Copy hooks
|
||||||
|
|
||||||
void GPU_CopyResource(GPU_CommandList *gpu_cl, GPU_Resource *gpu_dst, GPU_Resource *gpu_src)
|
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;
|
cmd->copy.src = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Map hooks
|
//~ @hookdef Map hooks
|
||||||
|
|
||||||
GPU_Mapped GPU_Map(GPU_Resource *gpu_r)
|
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
|
//~ @hookdef Memory info hooks
|
||||||
|
|
||||||
GPU_MemoryInfo GPU_QueryMemoryInfo(void)
|
GPU_MemoryInfo GPU_QueryMemoryInfo(void)
|
||||||
@ -2034,7 +2034,7 @@ GPU_MemoryInfo GPU_QueryMemoryInfo(void)
|
|||||||
return (GPU_MemoryInfo) ZI;
|
return (GPU_MemoryInfo) ZI;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Swapchain hooks
|
//~ @hookdef Swapchain hooks
|
||||||
|
|
||||||
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, GPU_Format format, Vec2I32 size)
|
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, GPU_Format format, Vec2I32 size)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ DirectX12 libs
|
//~ DirectX12 libs
|
||||||
|
|
||||||
#include <d3d12.h>
|
#include <d3d12.h>
|
||||||
@ -8,7 +8,7 @@
|
|||||||
#pragma comment(lib, "d3d12")
|
#pragma comment(lib, "d3d12")
|
||||||
#pragma comment(lib, "dxgi")
|
#pragma comment(lib, "dxgi")
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tweakable defines
|
//~ Tweakable defines
|
||||||
|
|
||||||
#define GPU_D12_TearingIsAllowed 1
|
#define GPU_D12_TearingIsAllowed 1
|
||||||
@ -22,7 +22,7 @@
|
|||||||
#define GPU_D12_MaxSamplerDescriptors (1024 * 1)
|
#define GPU_D12_MaxSamplerDescriptors (1024 * 1)
|
||||||
#define GPU_D12_MaxRtvDescriptors (1024 * 1)
|
#define GPU_D12_MaxRtvDescriptors (1024 * 1)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Pipeline types
|
//~ Pipeline types
|
||||||
|
|
||||||
Struct(GPU_D12_PipelineDesc)
|
Struct(GPU_D12_PipelineDesc)
|
||||||
@ -53,7 +53,7 @@ Struct(GPU_D12_PipelineBin)
|
|||||||
GPU_D12_Pipeline *first;
|
GPU_D12_Pipeline *first;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Descriptor types
|
//~ Descriptor types
|
||||||
|
|
||||||
Struct(GPU_D12_Descriptor)
|
Struct(GPU_D12_Descriptor)
|
||||||
@ -83,7 +83,7 @@ Struct(GPU_D12_DescriptorHeap)
|
|||||||
u32 max_count;
|
u32 max_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource types
|
//~ Resource types
|
||||||
|
|
||||||
Struct(GPU_D12_Resource)
|
Struct(GPU_D12_Resource)
|
||||||
@ -124,7 +124,7 @@ Struct(GPU_D12_ResourceReuseListBin)
|
|||||||
GPU_D12_ResourceReuseList *first_free;
|
GPU_D12_ResourceReuseList *first_free;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Queue types
|
//~ Queue types
|
||||||
|
|
||||||
Struct(GPU_D12_QueueDesc)
|
Struct(GPU_D12_QueueDesc)
|
||||||
@ -149,7 +149,7 @@ Struct(GPU_D12_Queue)
|
|||||||
Fence sync_fence;
|
Fence sync_fence;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Raw command list types
|
//~ Raw command list types
|
||||||
|
|
||||||
Struct(GPU_D12_RawCommandList)
|
Struct(GPU_D12_RawCommandList)
|
||||||
@ -163,7 +163,7 @@ Struct(GPU_D12_RawCommandList)
|
|||||||
ID3D12GraphicsCommandList *cl;
|
ID3D12GraphicsCommandList *cl;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Command list types
|
//~ Command list types
|
||||||
|
|
||||||
Enum(GPU_D12_CommandKind)
|
Enum(GPU_D12_CommandKind)
|
||||||
@ -247,7 +247,7 @@ Struct(GPU_D12_CommandList)
|
|||||||
GPU_QueueKind queue_kind;
|
GPU_QueueKind queue_kind;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Swapchain types
|
//~ Swapchain types
|
||||||
|
|
||||||
Struct(GPU_D12_SwapchainBuffer)
|
Struct(GPU_D12_SwapchainBuffer)
|
||||||
@ -271,7 +271,7 @@ Struct(GPU_D12_Swapchain)
|
|||||||
GPU_D12_SwapchainBuffer buffers[GPU_D12_SwapchainBufferCount];
|
GPU_D12_SwapchainBuffer buffers[GPU_D12_SwapchainBufferCount];
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
#define GPU_D12_NumResourceReuseBins 1024
|
#define GPU_D12_NumResourceReuseBins 1024
|
||||||
@ -317,7 +317,7 @@ Struct(GPU_D12_SharedState)
|
|||||||
ID3D12Device *device;
|
ID3D12Device *device;
|
||||||
} extern GPU_D12_shared_state;
|
} extern GPU_D12_shared_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Helpers
|
//~ Helpers
|
||||||
|
|
||||||
GPU_D12_FiberState *GPU_D12_FiberStateFromId(i16 fiber_id);
|
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);
|
GPU_D12_Command *GPU_D12_PushCmd(GPU_D12_CommandList *cl);
|
||||||
u64 GPU_D12_ReuseHashFromResourceDesc(GPU_ResourceDesc desc, u64 buffer_size);
|
u64 GPU_D12_ReuseHashFromResourceDesc(GPU_ResourceDesc desc, u64 buffer_size);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void GPU_D12_Startup(void);
|
void GPU_D12_Startup(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Initialization
|
//~ Initialization
|
||||||
|
|
||||||
//- Device initialization
|
//- Device initialization
|
||||||
@ -345,37 +345,37 @@ GPU_D12_DescriptorHeap *GPU_D12_InitDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE ty
|
|||||||
//- Rootsig initialization
|
//- Rootsig initialization
|
||||||
void GPU_D12_InitRootsig(void);
|
void GPU_D12_InitRootsig(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Pipeline operations
|
//~ Pipeline operations
|
||||||
|
|
||||||
JobDecl(GPU_D12_LoadPipeline, { GPU_D12_Pipeline *pipeline; });
|
JobDecl(GPU_D12_LoadPipeline, { GPU_D12_Pipeline *pipeline; });
|
||||||
GPU_D12_Pipeline *GPU_D12_PipelineFromDesc(GPU_D12_PipelineDesc desc);
|
GPU_D12_Pipeline *GPU_D12_PipelineFromDesc(GPU_D12_PipelineDesc desc);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Queue operations
|
//~ Queue operations
|
||||||
|
|
||||||
GPU_D12_Queue *GPU_D12_QueueFromKind(GPU_QueueKind kind);
|
GPU_D12_Queue *GPU_D12_QueueFromKind(GPU_QueueKind kind);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Descriptor operations
|
//~ Descriptor operations
|
||||||
|
|
||||||
GPU_D12_Descriptor *GPU_D12_AcquireDescriptor(GPU_D12_DescriptorHeap *heap);
|
GPU_D12_Descriptor *GPU_D12_AcquireDescriptor(GPU_D12_DescriptorHeap *heap);
|
||||||
void GPU_D12_ReleaseDescriptor(GPU_D12_Descriptor *descriptor);
|
void GPU_D12_ReleaseDescriptor(GPU_D12_Descriptor *descriptor);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Raw command list operations
|
//~ Raw command list operations
|
||||||
|
|
||||||
GPU_D12_RawCommandList *GPU_D12_BeginRawCommandList(GPU_QueueKind queue_kind);
|
GPU_D12_RawCommandList *GPU_D12_BeginRawCommandList(GPU_QueueKind queue_kind);
|
||||||
u64 GPU_D12_EndRawCommandList(GPU_D12_RawCommandList *cl);
|
u64 GPU_D12_EndRawCommandList(GPU_D12_RawCommandList *cl);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Swapchain helpers
|
//~ Swapchain helpers
|
||||||
|
|
||||||
void GPU_D12_InitSwapchainResources(GPU_D12_Swapchain *swapchain);
|
void GPU_D12_InitSwapchainResources(GPU_D12_Swapchain *swapchain);
|
||||||
GPU_D12_SwapchainBuffer *GPU_D12_UpdateSwapchain(GPU_D12_Swapchain *swapchain, Vec2I32 resolution);
|
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);
|
i64 GPU_D12_BlitToSwapchain(GPU_D12_SwapchainBuffer *swapchain_buffer, GPU_D12_Resource *texture, Vec2I32 dst_pos);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sync job
|
//~ Sync job
|
||||||
|
|
||||||
JobDecl(GPU_D12_StartQueueSync, EmptySig);
|
JobDecl(GPU_D12_StartQueueSync, EmptySig);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
GPU_SharedUtilState GPU_shared_util_state = ZI;
|
GPU_SharedUtilState GPU_shared_util_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void GPU_StartupUtils(void)
|
void GPU_StartupUtils(void)
|
||||||
@ -85,7 +85,7 @@ void GPU_StartupUtils(void)
|
|||||||
g->quad_indices = quad;
|
g->quad_indices = quad;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Common resource helpers
|
//~ Common resource helpers
|
||||||
|
|
||||||
GPU_Resource *GPU_GetCommonPointSampler(void)
|
GPU_Resource *GPU_GetCommonPointSampler(void)
|
||||||
@ -103,7 +103,7 @@ GPU_Resource *GPU_GetCommonNoise(void)
|
|||||||
return GPU_shared_util_state.noise;
|
return GPU_shared_util_state.noise;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Transient buffer operations
|
//~ Transient buffer operations
|
||||||
|
|
||||||
GPU_TransientBuffer GPU_AcquireTransientBuffer(GPU_QueueKind queue_kind, u32 element_size)
|
GPU_TransientBuffer GPU_AcquireTransientBuffer(GPU_QueueKind queue_kind, u32 element_size)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Transient buffer types
|
//~ Transient buffer types
|
||||||
|
|
||||||
Struct(GPU_SubmittedResourceNode)
|
Struct(GPU_SubmittedResourceNode)
|
||||||
@ -24,7 +24,7 @@ Struct(GPU_TransientBuffer)
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
Struct(GPU_SharedUtilState)
|
Struct(GPU_SharedUtilState)
|
||||||
@ -39,19 +39,19 @@ Struct(GPU_SharedUtilState)
|
|||||||
GPU_SubmittedResourceNode *first_free_submitted_transient_buffer;
|
GPU_SubmittedResourceNode *first_free_submitted_transient_buffer;
|
||||||
} extern GPU_shared_util_state;
|
} extern GPU_shared_util_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void GPU_StartupUtils(void);
|
void GPU_StartupUtils(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Common resource helpers
|
//~ Common resource helpers
|
||||||
|
|
||||||
GPU_Resource *GPU_GetCommonPointSampler(void);
|
GPU_Resource *GPU_GetCommonPointSampler(void);
|
||||||
GPU_Resource *GPU_GetCommonQuadIndices(void);
|
GPU_Resource *GPU_GetCommonQuadIndices(void);
|
||||||
GPU_Resource *GPU_GetCommonNoise(void);
|
GPU_Resource *GPU_GetCommonNoise(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Transient buffer operations
|
//~ Transient buffer operations
|
||||||
|
|
||||||
GPU_TransientBuffer GPU_AcquireTransientBuffer(GPU_QueueKind queue_kind, u32 element_size);
|
GPU_TransientBuffer GPU_AcquireTransientBuffer(GPU_QueueKind queue_kind, u32 element_size);
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* - Don't allow leading 0s in numbers
|
* - Don't allow leading 0s in numbers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Lex
|
//~ Lex
|
||||||
|
|
||||||
JSON_Token *JSON_PushToken(Arena *arena, JSON_TokenList *list)
|
JSON_Token *JSON_PushToken(Arena *arena, JSON_TokenList *list)
|
||||||
@ -351,7 +351,7 @@ JSON_TokenList JSON_TokensFromString(Arena *arena, String src)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Interpret
|
//~ Interpret
|
||||||
|
|
||||||
f64 interpret_number(String src)
|
f64 interpret_number(String src)
|
||||||
@ -683,7 +683,7 @@ String interpret_string(Arena *arena, String src, String *error)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Parse
|
//~ Parse
|
||||||
|
|
||||||
void JSON_PushError(Arena *arena, JSON_Parser *p, JSON_Token *t, String msg)
|
void JSON_PushError(Arena *arena, JSON_Parser *p, JSON_Token *t, String msg)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Blob types
|
//~ Blob types
|
||||||
|
|
||||||
Enum(JSON_Type)
|
Enum(JSON_Type)
|
||||||
@ -50,7 +50,7 @@ Struct(JSON_Result)
|
|||||||
JSON_ErrorList errors;
|
JSON_ErrorList errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Lexer types
|
//~ Lexer types
|
||||||
|
|
||||||
#define JSON_Case_Newline \
|
#define JSON_Case_Newline \
|
||||||
@ -125,7 +125,7 @@ Global Readonly JSON_TokenKind JSON_keyword_types[] = {
|
|||||||
['n'] = JSON_TokenKind_KeywordNull
|
['n'] = JSON_TokenKind_KeywordNull
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Parser types
|
//~ Parser types
|
||||||
|
|
||||||
Struct(JSON_Parser)
|
Struct(JSON_Parser)
|
||||||
@ -139,19 +139,19 @@ Struct(JSON_Parser)
|
|||||||
JSON_ErrorList errors;
|
JSON_ErrorList errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Lex
|
//~ Lex
|
||||||
|
|
||||||
JSON_Token *JSON_PushToken(Arena *arena, JSON_TokenList *list);
|
JSON_Token *JSON_PushToken(Arena *arena, JSON_TokenList *list);
|
||||||
JSON_TokenList JSON_TokensFromString(Arena *arena, String src);
|
JSON_TokenList JSON_TokensFromString(Arena *arena, String src);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Interpret
|
//~ Interpret
|
||||||
|
|
||||||
f64 interpret_number(String src);
|
f64 interpret_number(String src);
|
||||||
String interpret_string(Arena *arena, String src, String *error);
|
String interpret_string(Arena *arena, String src, String *error);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Parse
|
//~ Parse
|
||||||
|
|
||||||
void JSON_PushError(Arena *arena, JSON_Parser *p, JSON_Token *t, String msg);
|
void JSON_PushError(Arena *arena, JSON_Parser *p, JSON_Token *t, String msg);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#define MetaRebuildCode 1317212284
|
#define MetaRebuildCode 1317212284
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Default base layer compiler definitions
|
//~ Default base layer compiler definitions
|
||||||
|
|
||||||
#ifndef IsConsoleApp
|
#ifndef IsConsoleApp
|
||||||
@ -45,7 +45,7 @@
|
|||||||
# define TestsAreEnabled 0
|
# define TestsAreEnabled 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Includes
|
//~ Includes
|
||||||
|
|
||||||
//- Header files
|
//- Header files
|
||||||
@ -59,7 +59,7 @@
|
|||||||
//- Source files
|
//- Source files
|
||||||
#include "meta_lay.c"
|
#include "meta_lay.c"
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Util
|
//~ Util
|
||||||
|
|
||||||
void EchoLine(String msg)
|
void EchoLine(String msg)
|
||||||
@ -96,7 +96,7 @@ LineCol LineColFromPos(String data, i64 pos)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ OS command job
|
//~ OS command job
|
||||||
|
|
||||||
Struct(RunCommandResult)
|
Struct(RunCommandResult)
|
||||||
@ -116,7 +116,7 @@ JobDef(RunCommand, sig, id)
|
|||||||
result->elapsed_ns = TimeNs() - start_ns;
|
result->elapsed_ns = TimeNs() - start_ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Compiler params
|
//~ Compiler params
|
||||||
|
|
||||||
Struct(CompilerParams)
|
Struct(CompilerParams)
|
||||||
@ -139,7 +139,7 @@ Struct(CompilerParams)
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Build step job
|
//~ Build step job
|
||||||
|
|
||||||
Enum(StepParamsFlag)
|
Enum(StepParamsFlag)
|
||||||
@ -207,8 +207,8 @@ JobDef(Step, sig, id)
|
|||||||
|
|
||||||
String shader_store_name = Lit("ShadersStore");
|
String shader_store_name = Lit("ShadersStore");
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Build C
|
//- Build C
|
||||||
|
|
||||||
if (flags & StepParamsFlag_CompileProgram)
|
if (flags & StepParamsFlag_CompileProgram)
|
||||||
{
|
{
|
||||||
@ -400,8 +400,8 @@ JobDef(Step, sig, id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Build shaders
|
//- Build shaders
|
||||||
|
|
||||||
if (flags & StepParamsFlag_CompileShaders)
|
if (flags & StepParamsFlag_CompileShaders)
|
||||||
{
|
{
|
||||||
@ -589,8 +589,8 @@ JobDef(Step, sig, id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Build embedded dirs
|
//- Build embedded dirs
|
||||||
|
|
||||||
if (flags & StepParamsFlag_CompileEmbeddedDirs)
|
if (flags & StepParamsFlag_CompileEmbeddedDirs)
|
||||||
{
|
{
|
||||||
@ -670,8 +670,8 @@ JobDef(Step, sig, id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Build arc file
|
//- Build arc file
|
||||||
|
|
||||||
if (flags & StepParamsFlag_CompileArc)
|
if (flags & StepParamsFlag_CompileArc)
|
||||||
{
|
{
|
||||||
@ -818,7 +818,7 @@ JobDef(Step, sig, id)
|
|||||||
result->elapsed_ns = TimeNs() - start_ns;
|
result->elapsed_ns = TimeNs() - start_ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
JobDecl(Build, EmptySig);
|
JobDecl(Build, EmptySig);
|
||||||
@ -828,8 +828,8 @@ JobDef(Build, _, __)
|
|||||||
M_ErrorList errors = ZI;
|
M_ErrorList errors = ZI;
|
||||||
i32 ret = 0;
|
i32 ret = 0;
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Dirty check
|
//- Dirty check
|
||||||
|
|
||||||
//- Return rebuild code if metaprogram is dirty
|
//- Return rebuild code if metaprogram is dirty
|
||||||
{
|
{
|
||||||
@ -872,8 +872,8 @@ JobDef(Build, _, __)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Args
|
//- Args
|
||||||
|
|
||||||
//- Unpack args
|
//- Unpack args
|
||||||
StringList args = GetCommandLineArgs();
|
StringList args = GetCommandLineArgs();
|
||||||
@ -962,8 +962,8 @@ JobDef(Build, _, __)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Parse
|
//- Parse
|
||||||
|
|
||||||
//- Lex layers
|
//- Lex layers
|
||||||
M_TokenFileList lexed = ZI;
|
M_TokenFileList lexed = ZI;
|
||||||
@ -989,8 +989,8 @@ JobDef(Build, _, __)
|
|||||||
M_AppendErrors(arena, &errors, flattened.errors);
|
M_AppendErrors(arena, &errors, flattened.errors);
|
||||||
ret = errors.count > 0;
|
ret = errors.count > 0;
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Compile & link
|
//- Compile & link
|
||||||
|
|
||||||
if (errors.count == 0)
|
if (errors.count == 0)
|
||||||
{
|
{
|
||||||
@ -1083,8 +1083,8 @@ JobDef(Build, _, __)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Echo errors
|
//- Echo errors
|
||||||
|
|
||||||
for (M_Error *e = errors.first; e; e = e->next)
|
for (M_Error *e = errors.first; e; e = e->next)
|
||||||
{
|
{
|
||||||
@ -1125,7 +1125,7 @@ JobDef(Build, _, __)
|
|||||||
ExitNow(ret);
|
ExitNow(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Startup
|
//~ @hookdef Startup
|
||||||
|
|
||||||
void StartupLayers(void)
|
void StartupLayers(void)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Path helpers
|
//~ Path helpers
|
||||||
|
|
||||||
String F_GetFull(Arena *arena, String path)
|
String F_GetFull(Arena *arena, String path)
|
||||||
@ -81,7 +81,7 @@ String F_ExtensionFromFile(String path)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File read operations
|
//~ File read operations
|
||||||
|
|
||||||
String F_DataFromFile(Arena *arena, String path)
|
String F_DataFromFile(Arena *arena, String path)
|
||||||
@ -93,7 +93,7 @@ String F_DataFromFile(Arena *arena, String path)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File write operations
|
//~ File write operations
|
||||||
|
|
||||||
void F_ClearWrite(String path, String data)
|
void F_ClearWrite(String path, String data)
|
||||||
@ -103,7 +103,7 @@ void F_ClearWrite(String path, String data)
|
|||||||
OS_CloseFile(file);
|
OS_CloseFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File attribute helpers
|
//~ File attribute helpers
|
||||||
|
|
||||||
b32 F_IsFile(String path)
|
b32 F_IsFile(String path)
|
||||||
@ -116,7 +116,7 @@ b32 F_IsDir(String path)
|
|||||||
return OS_DirExists(path);
|
return OS_DirExists(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File iter operations
|
//~ File iter operations
|
||||||
|
|
||||||
void F_FilesFromDir(Arena *arena, StringList *list, String dir, F_IterFlag flags)
|
void F_FilesFromDir(Arena *arena, StringList *list, String dir, F_IterFlag flags)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File iter types
|
//~ File iter types
|
||||||
|
|
||||||
Enum(F_IterFlag)
|
Enum(F_IterFlag)
|
||||||
@ -7,7 +7,7 @@ Enum(F_IterFlag)
|
|||||||
F_IterFlag_Recurse = (1 << 0)
|
F_IterFlag_Recurse = (1 << 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Path helpers
|
//~ Path helpers
|
||||||
|
|
||||||
String F_GetFull(Arena *arena, String path);
|
String F_GetFull(Arena *arena, String path);
|
||||||
@ -16,23 +16,23 @@ String F_GetFileName(String path);
|
|||||||
String F_GetParentDir(String path);
|
String F_GetParentDir(String path);
|
||||||
String F_ExtensionFromFile(String path);
|
String F_ExtensionFromFile(String path);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File read operations
|
//~ File read operations
|
||||||
|
|
||||||
String F_DataFromFile(Arena *arena, String path);
|
String F_DataFromFile(Arena *arena, String path);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File write operations
|
//~ File write operations
|
||||||
|
|
||||||
void F_ClearWrite(String path, String data);
|
void F_ClearWrite(String path, String data);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File attribute helpers
|
//~ File attribute helpers
|
||||||
|
|
||||||
b32 F_IsFile(String path);
|
b32 F_IsFile(String path);
|
||||||
b32 F_IsDir(String path);
|
b32 F_IsDir(String path);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File iter operations
|
//~ File iter operations
|
||||||
|
|
||||||
void F_FilesFromDir(Arena *arena, StringList *list, String dir, F_IterFlag flags);
|
void F_FilesFromDir(Arena *arena, StringList *list, String dir, F_IterFlag flags);
|
||||||
|
|||||||
@ -24,7 +24,7 @@ Readonly M_Layer M_NilLayer = {
|
|||||||
.last = &M_NilEntry,
|
.last = &M_NilEntry,
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Error helpers
|
//~ Error helpers
|
||||||
|
|
||||||
M_Error *M_PushError(Arena *arena, M_ErrorList *l, M_Token *token, String msg)
|
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
|
//~ Lexer operations
|
||||||
|
|
||||||
M_TokenFile *M_PushTokenFile(Arena *arena, M_TokenFileList *l, String name, String data)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Parser operations
|
//~ Parser operations
|
||||||
|
|
||||||
M_Layer *M_PushLayer(Arena *arena, M_LayerList *list, M_TokenFile *file)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Flatten operations
|
//~ Flatten operations
|
||||||
|
|
||||||
M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList starting_layer_names)
|
M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList starting_layer_names)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Error types
|
//~ Error types
|
||||||
|
|
||||||
Struct(M_Error)
|
Struct(M_Error)
|
||||||
@ -15,7 +15,7 @@ Struct(M_ErrorList)
|
|||||||
u64 count;
|
u64 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File types
|
//~ File types
|
||||||
|
|
||||||
Struct(M_File)
|
Struct(M_File)
|
||||||
@ -24,7 +24,7 @@ Struct(M_File)
|
|||||||
String data;
|
String data;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Token types
|
//~ Token types
|
||||||
|
|
||||||
Enum(M_TokenKind)
|
Enum(M_TokenKind)
|
||||||
@ -66,7 +66,7 @@ Struct(M_TokenFileList)
|
|||||||
u64 count;
|
u64 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Entry types
|
//~ Entry types
|
||||||
|
|
||||||
Enum(M_EntryKind)
|
Enum(M_EntryKind)
|
||||||
@ -129,26 +129,26 @@ Struct(M_LayerList)
|
|||||||
u64 count;
|
u64 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Error helpers
|
//~ Error helpers
|
||||||
|
|
||||||
M_Error *M_PushError(Arena *arena, M_ErrorList *l, M_Token *token, String msg);
|
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);
|
void M_AppendErrors(Arena *arena, M_ErrorList *dst, M_ErrorList src);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Lexer operations
|
//~ Lexer operations
|
||||||
|
|
||||||
M_Token *M_PushToken(Arena *arena, M_TokenFile *file, String s, M_TokenKind kind);
|
M_Token *M_PushToken(Arena *arena, M_TokenFile *file, String s, M_TokenKind kind);
|
||||||
M_TokenFileList M_TokensFromSrcDirs(Arena *arena, StringList src_dirs);
|
M_TokenFileList M_TokensFromSrcDirs(Arena *arena, StringList src_dirs);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Parser operations
|
//~ Parser operations
|
||||||
|
|
||||||
M_Layer *M_PushLayer(Arena *arena, M_LayerList *list, M_TokenFile *file);
|
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_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);
|
M_LayerList M_LayersFromTokenFiles(Arena *arena, M_TokenFileList token_files);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Flatten operations
|
//~ Flatten operations
|
||||||
|
|
||||||
M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList starting_layer_names);
|
M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList starting_layer_names);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File types
|
//~ File types
|
||||||
|
|
||||||
Enum(OS_FileFlag)
|
Enum(OS_FileFlag)
|
||||||
@ -15,7 +15,7 @@ Struct(OS_File)
|
|||||||
u64 handle;
|
u64 handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Command types
|
//~ Command types
|
||||||
|
|
||||||
Struct(OS_CommandResult)
|
Struct(OS_CommandResult)
|
||||||
@ -24,12 +24,12 @@ Struct(OS_CommandResult)
|
|||||||
String output;
|
String output;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Startup hooks
|
//~ @hookdecl Startup hooks
|
||||||
|
|
||||||
void OS_Startup(void);
|
void OS_Startup(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl File system operations
|
//~ @hookdecl File system operations
|
||||||
|
|
||||||
OS_File OS_OpenFile(String path, OS_FileFlag flags);
|
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);
|
String OS_GetFullPath(Arena *arena, String path);
|
||||||
u64 OS_LastWriteTimestampFromPath(String path);
|
u64 OS_LastWriteTimestampFromPath(String path);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Directory helpers
|
//~ @hookdecl Directory helpers
|
||||||
|
|
||||||
b32 OS_FileOrDirExists(String path);
|
b32 OS_FileOrDirExists(String path);
|
||||||
@ -49,7 +49,7 @@ b32 OS_DirExists(String path);
|
|||||||
void OS_Mkdir(String path);
|
void OS_Mkdir(String path);
|
||||||
void OS_Rm(String path);
|
void OS_Rm(String path);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Shell operations
|
//~ @hookdecl Shell operations
|
||||||
|
|
||||||
OS_CommandResult OS_RunCommand(Arena *arena, String cmd);
|
OS_CommandResult OS_RunCommand(Arena *arena, String cmd);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 helpers
|
//~ Win32 helpers
|
||||||
|
|
||||||
String W32_StringFromError(Arena *arena, DWORD err)
|
String W32_StringFromError(Arena *arena, DWORD err)
|
||||||
@ -25,14 +25,14 @@ String W32_StringFromError(Arena *arena, DWORD err)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Startup hook
|
//~ @hookdef Startup hook
|
||||||
|
|
||||||
void OS_Startup(void)
|
void OS_Startup(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef File system hooks
|
//~ @hookdef File system hooks
|
||||||
|
|
||||||
OS_File OS_OpenFile(String path, OS_FileFlag flags)
|
OS_File OS_OpenFile(String path, OS_FileFlag flags)
|
||||||
@ -151,7 +151,7 @@ u64 OS_LastWriteTimestampFromPath(String path)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Directory helper hooks
|
//~ @hookdef Directory helper hooks
|
||||||
|
|
||||||
b32 OS_FileOrDirExists(String path)
|
b32 OS_FileOrDirExists(String path)
|
||||||
@ -197,7 +197,7 @@ void OS_Rm(String path)
|
|||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Shell hooks
|
//~ @hookdef Shell hooks
|
||||||
|
|
||||||
OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
|
OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 libs
|
//~ Win32 libs
|
||||||
|
|
||||||
#pragma comment(lib, "kernel32")
|
#pragma comment(lib, "kernel32")
|
||||||
#pragma comment(lib, "user32")
|
#pragma comment(lib, "user32")
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 helpers
|
//~ Win32 helpers
|
||||||
|
|
||||||
String W32_StringFromError(Arena *arena, DWORD err);
|
String W32_StringFromError(Arena *arena, DWORD err);
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
MIX_SharedState M_shared_state = ZI;
|
MIX_SharedState M_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void MIX_Startup(void)
|
void MIX_Startup(void)
|
||||||
@ -28,7 +28,7 @@ void MIX_Startup(void)
|
|||||||
g->listener_dir = VEC2(0, -1);
|
g->listener_dir = VEC2(0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Track
|
//~ Track
|
||||||
|
|
||||||
MIX_Handle MIX_HandleFromTrack(MIX_Track *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;
|
g->track_first_free = track;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mixer control
|
//~ Mixer control
|
||||||
|
|
||||||
/* TODO: Rework interface to be command based instead of directly modifying tracks. */
|
/* 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);
|
Unlock(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mix
|
//~ Mix
|
||||||
|
|
||||||
i16 MIX_SampleSound(SND_Sound *sound, u64 sample_pos, b32 wrap)
|
i16 MIX_SampleSound(SND_Sound *sound, u64 sample_pos, b32 wrap)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Track types
|
//~ Track types
|
||||||
|
|
||||||
Enum(MIX_TrackFlag)
|
Enum(MIX_TrackFlag)
|
||||||
@ -32,7 +32,7 @@ Struct(MIX_TrackDesc)
|
|||||||
__VA_ARGS__ \
|
__VA_ARGS__ \
|
||||||
})
|
})
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mix types
|
//~ Mix types
|
||||||
|
|
||||||
/* Stereo mix of 32 bit float samples */
|
/* Stereo mix of 32 bit float samples */
|
||||||
@ -74,7 +74,7 @@ Struct(MIX_Track){
|
|||||||
MIX_Track *prev;
|
MIX_Track *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
Struct(MIX_SharedState)
|
Struct(MIX_SharedState)
|
||||||
@ -93,12 +93,12 @@ Struct(MIX_SharedState)
|
|||||||
MIX_Track *track_first_free;
|
MIX_Track *track_first_free;
|
||||||
} extern M_shared_state;
|
} extern M_shared_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void MIX_Startup(void);
|
void MIX_Startup(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Track operations
|
//~ Track operations
|
||||||
|
|
||||||
MIX_Handle MIX_HandleFromTrack(MIX_Track *track);
|
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);
|
MIX_Track *MIX_AcquireTrackLocked(Lock *lock, SND_Sound *sound);
|
||||||
void MIX_ReleaseTrackLocked(Lock *lock, MIX_Track *track);
|
void MIX_ReleaseTrackLocked(Lock *lock, MIX_Track *track);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mixer state operations
|
//~ Mixer state operations
|
||||||
|
|
||||||
MIX_Handle MIX_PlaySound(SND_Sound *sound);
|
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_UpdateTrack(MIX_Handle handle, MIX_TrackDesc desc);
|
||||||
void MIX_UpdateListener(Vec2 pos, Vec2 dir);
|
void MIX_UpdateListener(Vec2 pos, Vec2 dir);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mixer update
|
//~ Mixer update
|
||||||
|
|
||||||
i16 MIX_SampleSound(SND_Sound *sound, u64 sample_pos, b32 wrap);
|
i16 MIX_SampleSound(SND_Sound *sound, u64 sample_pos, b32 wrap);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mp3 types
|
//~ Mp3 types
|
||||||
|
|
||||||
Enum(MP3_DecodeFlag)
|
Enum(MP3_DecodeFlag)
|
||||||
@ -14,7 +14,7 @@ Struct(MP3_Result)
|
|||||||
b32 ok;
|
b32 ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mp3 operations
|
//~ Mp3 operations
|
||||||
|
|
||||||
MP3_Result MP3_Decode(Arena *arena, String encoded, u32 sample_rate, MP3_DecodeFlag flags);
|
MP3_Result MP3_Decode(Arena *arena, String encoded, u32 sample_rate, MP3_DecodeFlag flags);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode
|
//~ Decode
|
||||||
|
|
||||||
MP3_Result MP3_Decode(Arena *arena, String encoded, u32 sample_rate, MP3_DecodeFlag flags)
|
MP3_Result MP3_Decode(Arena *arena, String encoded, u32 sample_rate, MP3_DecodeFlag flags)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Windows headers
|
//~ Windows headers
|
||||||
|
|
||||||
#pragma warning(push, 0)
|
#pragma warning(push, 0)
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
* Challenges to verify receiving address.
|
* Challenges to verify receiving address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Host
|
//~ Host
|
||||||
|
|
||||||
N_Host *N_AcquireHost(u16 listen_port)
|
N_Host *N_AcquireHost(u16 listen_port)
|
||||||
@ -54,7 +54,7 @@ void N_ReleaseHost(N_Host *host)
|
|||||||
ReleaseArena(host->arena);
|
ReleaseArena(host->arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Channel
|
//~ Channel
|
||||||
|
|
||||||
u64 N_HashFromAddress(P_Address address)
|
u64 N_HashFromAddress(P_Address address)
|
||||||
@ -223,7 +223,7 @@ void N_ReleaseChannel(N_Channel *channel)
|
|||||||
host->first_free_channel = channel;
|
host->first_free_channel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Message assembler
|
//~ Message assembler
|
||||||
|
|
||||||
u64 N_HashFromMsg(N_ChannelId channel_id, u64 msg_id)
|
u64 N_HashFromMsg(N_ChannelId channel_id, u64 msg_id)
|
||||||
@ -433,7 +433,7 @@ void N_MarkChunkReceived(N_MsgAssembler *ma, u64 chunk_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Packet
|
//~ Packet
|
||||||
|
|
||||||
N_SndPacket *N_PushSndPacket(N_Channel *channel, b32 is_reliable)
|
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;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Host commands
|
//~ Host commands
|
||||||
|
|
||||||
N_Cmd *N_PushCmd(N_Host *host)
|
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;
|
cmd->write_reliable = flags & N_WriteFlag_Reliable;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Channel info
|
//~ Channel info
|
||||||
|
|
||||||
i64 N_GetChannelLastRttNs(N_Host *host, N_ChannelId channel_id)
|
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;
|
return channel->last_heartbeat_rtt_ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Update begin
|
//~ Update begin
|
||||||
|
|
||||||
/* Read incoming packets, update channels, and return events */
|
/* Read incoming packets, update channels, and return events */
|
||||||
@ -844,7 +844,7 @@ N_EventList N_BeginUpdate(Arena *arena, N_Host *host)
|
|||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Update end
|
//~ Update end
|
||||||
|
|
||||||
/* Process host cmds & send outgoing packets */
|
/* Process host cmds & send outgoing packets */
|
||||||
@ -1025,7 +1025,7 @@ void N_EndUpdate(N_Host *host)
|
|||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ PushEvent
|
//~ PushEvent
|
||||||
|
|
||||||
N_Event *N_PushEvent(Arena *arena, N_EventList *list)
|
N_Event *N_PushEvent(Arena *arena, N_EventList *list)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Channel ID
|
//~ Channel ID
|
||||||
|
|
||||||
Struct(N_ChannelId)
|
Struct(N_ChannelId)
|
||||||
@ -7,7 +7,7 @@ Struct(N_ChannelId)
|
|||||||
u32 idx;
|
u32 idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Host command types
|
//~ Host command types
|
||||||
|
|
||||||
Enum(N_CmdKind)
|
Enum(N_CmdKind)
|
||||||
@ -40,7 +40,7 @@ Struct(N_Cmd)
|
|||||||
N_Cmd *next;
|
N_Cmd *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Event types
|
//~ Event types
|
||||||
|
|
||||||
Enum(N_EventKind)
|
Enum(N_EventKind)
|
||||||
@ -72,7 +72,7 @@ Struct(N_ChannelLookupBin)
|
|||||||
struct N_Channel *last;
|
struct N_Channel *last;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Packet types
|
//~ Packet types
|
||||||
|
|
||||||
#define N_PacketMagic 0xd9e3b8b6
|
#define N_PacketMagic 0xd9e3b8b6
|
||||||
@ -119,7 +119,7 @@ Struct(N_RcvBuffer)
|
|||||||
N_RcvPacket *last_packet;
|
N_RcvPacket *last_packet;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Channel types
|
//~ Channel types
|
||||||
|
|
||||||
Struct(N_Channel)
|
Struct(N_Channel)
|
||||||
@ -173,7 +173,7 @@ Struct(N_ChannelList)
|
|||||||
N_ChannelNode *last;
|
N_ChannelNode *last;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Message asssembler types
|
//~ Message asssembler types
|
||||||
|
|
||||||
Struct(N_MsgAssembler)
|
Struct(N_MsgAssembler)
|
||||||
@ -212,7 +212,7 @@ Struct(N_MsgAssemblerLookupBin)
|
|||||||
N_MsgAssembler *last;
|
N_MsgAssembler *last;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Host types
|
//~ Host types
|
||||||
|
|
||||||
#define N_NumChannelLookupBins 512
|
#define N_NumChannelLookupBins 512
|
||||||
@ -254,18 +254,18 @@ Struct(N_Host)
|
|||||||
u64 bytes_sent;
|
u64 bytes_sent;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Nil constants
|
//~ Nil constants
|
||||||
|
|
||||||
Readonly Global N_Channel N_nil_channel = { .valid = 0 };
|
Readonly Global N_Channel N_nil_channel = { .valid = 0 };
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Host initialization
|
//~ Host initialization
|
||||||
|
|
||||||
N_Host *N_AcquireHost(u16 listen_port);
|
N_Host *N_AcquireHost(u16 listen_port);
|
||||||
void N_ReleaseHost(N_Host *host);
|
void N_ReleaseHost(N_Host *host);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Channel operations
|
//~ Channel operations
|
||||||
|
|
||||||
#define N_NilChannelId (N_ChannelId) { .gen = 0, .idx = 0 }
|
#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);
|
N_Channel *N_AcquireChannel(N_Host *host, P_Address address);
|
||||||
void N_ReleaseChannel(N_Channel *channel);
|
void N_ReleaseChannel(N_Channel *channel);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Message assembler operations
|
//~ Message assembler operations
|
||||||
|
|
||||||
u64 N_HashFromMsg(N_ChannelId channel_id, u64 msg_id);
|
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);
|
b32 N_IsChunkFilled(N_MsgAssembler *ma, u64 chunk_id);
|
||||||
void N_MarkChunkReceived(N_MsgAssembler *ma, u64 chunk_id);
|
void N_MarkChunkReceived(N_MsgAssembler *ma, u64 chunk_id);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Packet operations
|
//~ Packet operations
|
||||||
|
|
||||||
N_SndPacket *N_PushSndPacket(N_Channel *channel, b32 is_reliable);
|
N_SndPacket *N_PushSndPacket(N_Channel *channel, b32 is_reliable);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Host command operations
|
//~ Host command operations
|
||||||
|
|
||||||
N_Cmd *N_PushCmd(N_Host *host);
|
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_Disconnect(N_Host *host, N_ChannelId channel_id);
|
||||||
void N_Write(N_Host *host, N_ChannelId channel_id, String msg, N_WriteFlag flags);
|
void N_Write(N_Host *host, N_ChannelId channel_id, String msg, N_WriteFlag flags);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Channel info operations
|
//~ Channel info operations
|
||||||
|
|
||||||
i64 N_GetChannelLastRttNs(N_Host *host, N_ChannelId channel_id);
|
i64 N_GetChannelLastRttNs(N_Host *host, N_ChannelId channel_id);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Update
|
//~ Update
|
||||||
|
|
||||||
N_Event *N_PushEvent(Arena *arena, N_EventList *list);
|
N_Event *N_PushEvent(Arena *arena, N_EventList *list);
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Opaque types
|
//~ Opaque types
|
||||||
|
|
||||||
Struct(P_Watch);
|
Struct(P_Watch);
|
||||||
Struct(P_Window);
|
Struct(P_Window);
|
||||||
Struct(P_Sock);
|
Struct(P_Sock);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Time types
|
//~ Time types
|
||||||
|
|
||||||
Struct(P_DateTime)
|
Struct(P_DateTime)
|
||||||
@ -20,7 +20,7 @@ Struct(P_DateTime)
|
|||||||
u32 milliseconds;
|
u32 milliseconds;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File system types
|
//~ File system types
|
||||||
|
|
||||||
Struct(P_File)
|
Struct(P_File)
|
||||||
@ -43,7 +43,7 @@ Struct(P_FileMap)
|
|||||||
b32 valid;
|
b32 valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Window event types
|
//~ Window event types
|
||||||
|
|
||||||
//- Button
|
//- Button
|
||||||
@ -192,7 +192,7 @@ Struct(P_WindowEventArray)
|
|||||||
P_WindowEvent *events;
|
P_WindowEvent *events;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Window setting types
|
//~ Window setting types
|
||||||
|
|
||||||
/* NOTE:
|
/* NOTE:
|
||||||
@ -234,7 +234,7 @@ Struct(P_WindowSettings)
|
|||||||
i32 floating_height;
|
i32 floating_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Address types
|
//~ Address types
|
||||||
|
|
||||||
Enum(P_AddressFamily)
|
Enum(P_AddressFamily)
|
||||||
@ -252,7 +252,7 @@ Struct(P_Address)
|
|||||||
u16 portnb;
|
u16 portnb;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sock types
|
//~ Sock types
|
||||||
|
|
||||||
Struct(P_SockReadResult)
|
Struct(P_SockReadResult)
|
||||||
@ -262,7 +262,7 @@ Struct(P_SockReadResult)
|
|||||||
String data;
|
String data;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Message box types
|
//~ Message box types
|
||||||
|
|
||||||
Enum(P_MessageBoxKind)
|
Enum(P_MessageBoxKind)
|
||||||
@ -273,17 +273,17 @@ Enum(P_MessageBoxKind)
|
|||||||
P_MessageBoxKind_Fatal
|
P_MessageBoxKind_Fatal
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Startup
|
//~ @hookdecl Startup
|
||||||
|
|
||||||
void P_Startup(void);
|
void P_Startup(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Time helper hooks
|
//~ @hookdecl Time helper hooks
|
||||||
|
|
||||||
P_DateTime P_LocalTime(void);
|
P_DateTime P_LocalTime(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl File system hooks
|
//~ @hookdecl File system hooks
|
||||||
|
|
||||||
/* NOTE: File paths use forward slash '/' as delimiter */
|
/* 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);
|
u64 P_GetFileSize(P_File file);
|
||||||
P_FileTime P_GetFileTime(P_File file);
|
P_FileTime P_GetFileTime(P_File file);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl File map hooks
|
//~ @hookdecl File map hooks
|
||||||
|
|
||||||
P_FileMap P_OpenFileMap(P_File file);
|
P_FileMap P_OpenFileMap(P_File file);
|
||||||
void P_CloseFileMap(P_FileMap map);
|
void P_CloseFileMap(P_FileMap map);
|
||||||
String P_GetFileMapData(P_FileMap map);
|
String P_GetFileMapData(P_FileMap map);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Window hooks
|
//~ @hookdecl Window hooks
|
||||||
|
|
||||||
P_Window *P_AcquireWindow(void);
|
P_Window *P_AcquireWindow(void);
|
||||||
@ -341,7 +341,7 @@ Vec2I32 P_GetWindowSize(P_Window *window);
|
|||||||
Vec2I32 P_GetWindowMonitorSize(P_Window *window);
|
Vec2I32 P_GetWindowMonitorSize(P_Window *window);
|
||||||
u64 P_GetInternalWindowHandle(P_Window *window);
|
u64 P_GetInternalWindowHandle(P_Window *window);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Address helper hooks
|
//~ @hookdecl Address helper hooks
|
||||||
|
|
||||||
P_Address P_AddressFromString(String str);
|
P_Address P_AddressFromString(String str);
|
||||||
@ -350,7 +350,7 @@ P_Address P_AddressFromPort(u16 port);
|
|||||||
String P_StringFromAddress(Arena *arena, P_Address address);
|
String P_StringFromAddress(Arena *arena, P_Address address);
|
||||||
b32 P_AddressIsEqual(P_Address a, P_Address b);
|
b32 P_AddressIsEqual(P_Address a, P_Address b);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Sock hooks
|
//~ @hookdecl Sock hooks
|
||||||
|
|
||||||
P_Sock *P_AcquireSock(u16 listen_port, u64 sndbuf_size, u64 rcvbuf_size);
|
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);
|
P_SockReadResult P_ReadSock(Arena *arena, P_Sock *sock);
|
||||||
void P_WriteSock(P_Sock *sock, P_Address address, String data);
|
void P_WriteSock(P_Sock *sock, P_Address address, String data);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Util hooks
|
//~ @hookdecl Util hooks
|
||||||
|
|
||||||
void P_MessageBox(P_MessageBoxKind kind, String message);
|
void P_MessageBox(P_MessageBoxKind kind, String message);
|
||||||
void P_SetClipboardText(String str);
|
void P_SetClipboardText(String str);
|
||||||
String P_GetClipboardText(Arena *arena);
|
String P_GetClipboardText(Arena *arena);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Timer hooks
|
//~ @hookdecl Timer hooks
|
||||||
|
|
||||||
Fence *P_GetTimerFence();
|
Fence *P_GetTimerFence();
|
||||||
i64 P_GetCurrentTimerPeriodNs();
|
i64 P_GetCurrentTimerPeriodNs();
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdecl Sleep hooks
|
//~ @hookdecl Sleep hooks
|
||||||
|
|
||||||
void P_SleepPrecise(i64 sleep_time_ns);
|
void P_SleepPrecise(i64 sleep_time_ns);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
P_SharedLogState P_shared_log_state = ZI;
|
P_SharedLogState P_shared_log_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void P_StartupLog(void)
|
void P_StartupLog(void)
|
||||||
@ -24,7 +24,7 @@ void P_StartupLog(void)
|
|||||||
Atomic32Set(&ctx->initialized, 1);
|
Atomic32Set(&ctx->initialized, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Callback registration
|
//~ Callback registration
|
||||||
|
|
||||||
void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level)
|
void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level)
|
||||||
@ -49,7 +49,7 @@ void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level)
|
|||||||
Unlock(&lock);
|
Unlock(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Append
|
//~ Append
|
||||||
|
|
||||||
void P_LogAppend_(String msg)
|
void P_LogAppend_(String msg)
|
||||||
@ -67,7 +67,7 @@ void P_LogAppend_(String msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Panic
|
//~ Panic
|
||||||
|
|
||||||
/* Panic log function is separate to enforce zero side effects other than
|
/* Panic log function is separate to enforce zero side effects other than
|
||||||
@ -85,7 +85,7 @@ void P_LogPanic_(String msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Logfv
|
//~ Logfv
|
||||||
|
|
||||||
#if P_IncludeLogSourceLocation
|
#if P_IncludeLogSourceLocation
|
||||||
@ -106,7 +106,7 @@ void P_LogFV_(i32 level, String fmt, va_list args)
|
|||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Logf
|
//~ Logf
|
||||||
|
|
||||||
#if P_IncludeLogSourceLocation
|
#if P_IncludeLogSourceLocation
|
||||||
@ -127,7 +127,7 @@ void P_LogF_(i32 level, String fmt, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Log
|
//~ Log
|
||||||
|
|
||||||
#if P_IncludeLogSourceLocation
|
#if P_IncludeLogSourceLocation
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Log event types
|
//~ Log event types
|
||||||
|
|
||||||
//- Event
|
//- Event
|
||||||
@ -27,7 +27,7 @@ Struct(LogEventCallback)
|
|||||||
i32 level;
|
i32 level;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Logging levels
|
//~ Logging levels
|
||||||
|
|
||||||
#define P_LogLevel(l) (l <= P_LogLevel_CompTime)
|
#define P_LogLevel(l) (l <= P_LogLevel_CompTime)
|
||||||
@ -55,7 +55,7 @@ Struct(LogEventCallback)
|
|||||||
#define P_LogLevel_Debug 5
|
#define P_LogLevel_Debug 5
|
||||||
#define P_LogLevel_Count 6
|
#define P_LogLevel_Count 6
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
Struct(P_SharedLogState)
|
Struct(P_SharedLogState)
|
||||||
@ -71,7 +71,7 @@ Struct(P_SharedLogState)
|
|||||||
b32 file_valid;
|
b32 file_valid;
|
||||||
} P_shared_log_state;
|
} P_shared_log_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Log level types
|
//~ Log level types
|
||||||
|
|
||||||
Struct(P_LogLevelSettings)
|
Struct(P_LogLevelSettings)
|
||||||
@ -112,12 +112,12 @@ Global Readonly P_LogLevelSettings P_log_settings[P_LogLevel_Count] = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void P_StartupLog(void);
|
void P_StartupLog(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Logging macros
|
//~ Logging macros
|
||||||
|
|
||||||
#if P_LogLevel(P_LogLevel_Critical)
|
#if P_LogLevel(P_LogLevel_Critical)
|
||||||
@ -198,12 +198,12 @@ void P_StartupLog(void);
|
|||||||
# define P_LogDebugF(...)
|
# define P_LogDebugF(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Callback registration
|
//~ Callback registration
|
||||||
|
|
||||||
void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level);
|
void P_RegisterLogCallback(P_LogEventCallbackFunc *func, i32 level);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Raw log operations
|
//~ Raw log operations
|
||||||
|
|
||||||
/* NOTE: Calling these functions rather than using the logging macros may result in logs that are compiled regardless of log level. */
|
/* 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;
|
P_W32_SharedState P_W32_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Startup
|
//~ @hookdef Startup
|
||||||
|
|
||||||
void P_Startup(void)
|
void P_Startup(void)
|
||||||
@ -104,7 +104,7 @@ void P_Startup(void)
|
|||||||
RunJob(P_W32_StartTimerSync, .pool = JobPool_Hyper, .flags = JobFlag_Dedicated);
|
RunJob(P_W32_StartTimerSync, .pool = JobPool_Hyper, .flags = JobFlag_Dedicated);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 time
|
//~ Win32 time
|
||||||
|
|
||||||
P_DateTime P_W32_DateTimeFromWin32SystemTime(SYSTEMTIME st)
|
P_DateTime P_W32_DateTimeFromWin32SystemTime(SYSTEMTIME st)
|
||||||
@ -122,7 +122,7 @@ P_DateTime P_W32_DateTimeFromWin32SystemTime(SYSTEMTIME st)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 file system
|
//~ Win32 file system
|
||||||
|
|
||||||
String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src)
|
String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src)
|
||||||
@ -154,7 +154,7 @@ String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 window
|
//~ Win32 window
|
||||||
|
|
||||||
P_W32_Window *P_W32_AcquireWindow(void)
|
P_W32_Window *P_W32_AcquireWindow(void)
|
||||||
@ -244,7 +244,7 @@ HWND P_W32_InitWindow(P_W32_Window *window)
|
|||||||
return hwnd;
|
return hwnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 window settings
|
//~ Win32 window settings
|
||||||
|
|
||||||
void P_W32_UpdateWindowFromSystem(P_W32_Window *window)
|
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
|
//~ Win32 window message processing
|
||||||
|
|
||||||
JobDef(P_W32_StartWindowMsgProcessing, sig, id)
|
JobDef(P_W32_StartWindowMsgProcessing, sig, id)
|
||||||
@ -775,7 +775,7 @@ LRESULT CALLBACK P_W32_Win32WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 Address
|
//~ Win32 Address
|
||||||
|
|
||||||
P_W32_Address P_W32_Win32AddressFromPlatformAddress(P_Address addr)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Timer job
|
//~ Timer job
|
||||||
|
|
||||||
JobDef(P_W32_StartTimerSync, _, __)
|
JobDef(P_W32_StartTimerSync, _, __)
|
||||||
@ -925,7 +925,7 @@ JobDef(P_W32_StartTimerSync, _, __)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Time hooks
|
//~ @hookdef Time hooks
|
||||||
|
|
||||||
P_DateTime P_LocalTime(void)
|
P_DateTime P_LocalTime(void)
|
||||||
@ -935,7 +935,7 @@ P_DateTime P_LocalTime(void)
|
|||||||
return P_W32_DateTimeFromWin32SystemTime(lt);
|
return P_W32_DateTimeFromWin32SystemTime(lt);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef File system hooks
|
//~ @hookdef File system hooks
|
||||||
|
|
||||||
//- FIle system helpers
|
//- FIle system helpers
|
||||||
@ -1229,7 +1229,7 @@ P_FileTime P_GetFileTime(P_File file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef File map hooks
|
//~ @hookdef File map hooks
|
||||||
|
|
||||||
P_FileMap P_OpenFileMap(P_File file)
|
P_FileMap P_OpenFileMap(P_File file)
|
||||||
@ -1297,7 +1297,7 @@ String P_GetFileMapData(P_FileMap map)
|
|||||||
return map.mapped_memory;
|
return map.mapped_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Window hooks
|
//~ @hookdef Window hooks
|
||||||
|
|
||||||
P_Window *P_AcquireWindow(void)
|
P_Window *P_AcquireWindow(void)
|
||||||
@ -1441,7 +1441,7 @@ u64 P_GetInternalWindowHandle(P_Window *p_window)
|
|||||||
return (u64)window->hwnd;
|
return (u64)window->hwnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Address helper hooks
|
//~ @hookdef Address helper hooks
|
||||||
|
|
||||||
P_Address P_AddressFromIpPortCstr(char *ip_cstr, char *port_cstr)
|
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);
|
return EqStruct(&a, &b);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Sock hooks
|
//~ @hookdef Sock hooks
|
||||||
|
|
||||||
P_Sock *P_AcquireSock(u16 listen_port, u64 sndbuf_size, u64 rcvbuf_size)
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Utility hooks
|
//~ @hookdef Utility hooks
|
||||||
|
|
||||||
void P_MessageBox(P_MessageBoxKind kind, String message)
|
void P_MessageBox(P_MessageBoxKind kind, String message)
|
||||||
@ -1837,7 +1837,7 @@ String P_GetClipboardText(Arena *arena)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Timer hooks
|
//~ @hookdef Timer hooks
|
||||||
|
|
||||||
Fence *P_GetTimerFence()
|
Fence *P_GetTimerFence()
|
||||||
@ -1852,7 +1852,7 @@ i64 P_GetCurrentTimerPeriodNs()
|
|||||||
return Atomic64Fetch(&g->average_timer_period_ns.v);
|
return Atomic64Fetch(&g->average_timer_period_ns.v);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Sleep hooks
|
//~ @hookdef Sleep hooks
|
||||||
|
|
||||||
void P_SleepPrecise(i64 sleep_time_ns)
|
void P_SleepPrecise(i64 sleep_time_ns)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 libs
|
//~ Win32 libs
|
||||||
|
|
||||||
#pragma warning(push, 0)
|
#pragma warning(push, 0)
|
||||||
@ -23,7 +23,7 @@
|
|||||||
#pragma comment(lib, "avrt")
|
#pragma comment(lib, "avrt")
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Window types
|
//~ Window types
|
||||||
|
|
||||||
Enum(P_W32_CursorFlag)
|
Enum(P_W32_CursorFlag)
|
||||||
@ -72,7 +72,7 @@ Struct(P_W32_Window)
|
|||||||
P_W32_Window *next_free;
|
P_W32_Window *next_free;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Watch types
|
//~ Watch types
|
||||||
|
|
||||||
Struct(P_W32_Watch)
|
Struct(P_W32_Watch)
|
||||||
@ -83,7 +83,7 @@ Struct(P_W32_Watch)
|
|||||||
u8 results_buff[Kibi(64)];
|
u8 results_buff[Kibi(64)];
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Address types
|
//~ Address types
|
||||||
|
|
||||||
Struct(P_W32_Address)
|
Struct(P_W32_Address)
|
||||||
@ -99,7 +99,7 @@ Struct(P_W32_Address)
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sock types
|
//~ Sock types
|
||||||
|
|
||||||
Struct(P_W32_Sock)
|
Struct(P_W32_Sock)
|
||||||
@ -108,7 +108,7 @@ Struct(P_W32_Sock)
|
|||||||
P_W32_Sock *next_free;
|
P_W32_Sock *next_free;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
#define P_W32_WindowClassName L"power_play_window_class"
|
#define P_W32_WindowClassName L"power_play_window_class"
|
||||||
@ -142,30 +142,30 @@ Struct(P_W32_SharedState)
|
|||||||
Atomic64Padded average_timer_period_ns;
|
Atomic64Padded average_timer_period_ns;
|
||||||
} extern P_W32_shared_state;
|
} extern P_W32_shared_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Time operations
|
//~ Time operations
|
||||||
|
|
||||||
P_DateTime P_W32_DateTimeFromWin32SystemTime(SYSTEMTIME st);
|
P_DateTime P_W32_DateTimeFromWin32SystemTime(SYSTEMTIME st);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ File system operations
|
//~ File system operations
|
||||||
|
|
||||||
String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src);
|
String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Window operations
|
//~ Window operations
|
||||||
|
|
||||||
P_W32_Window *P_W32_AcquireWindow(void);
|
P_W32_Window *P_W32_AcquireWindow(void);
|
||||||
void P_W32_ReleaseWindow(P_W32_Window *window);
|
void P_W32_ReleaseWindow(P_W32_Window *window);
|
||||||
HWND P_W32_InitWindow(P_W32_Window *window);
|
HWND P_W32_InitWindow(P_W32_Window *window);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Window settings
|
//~ Window settings
|
||||||
|
|
||||||
void P_W32_UpdateWindowFromSystem(P_W32_Window *window);
|
void P_W32_UpdateWindowFromSystem(P_W32_Window *window);
|
||||||
void P_W32_UpdateWindowFromSettings(P_W32_Window *window, P_WindowSettings *settings);
|
void P_W32_UpdateWindowFromSettings(P_W32_Window *window, P_WindowSettings *settings);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Window message processing
|
//~ Window message processing
|
||||||
|
|
||||||
JobDecl(P_W32_StartWindowMsgProcessing, { P_W32_Window *window; });
|
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);
|
void P_W32_WakeWindow(P_W32_Window *window);
|
||||||
LRESULT CALLBACK P_W32_Win32WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
LRESULT CALLBACK P_W32_Win32WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Address operations
|
//~ Address operations
|
||||||
|
|
||||||
P_W32_Address P_W32_Win32AddressFromPlatformAddress(P_Address addr);
|
P_W32_Address P_W32_Win32AddressFromPlatformAddress(P_Address addr);
|
||||||
P_W32_Address P_W32_ConvertAnyaddrToLocalhost(P_W32_Address addr);
|
P_W32_Address P_W32_ConvertAnyaddrToLocalhost(P_W32_Address addr);
|
||||||
P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr);
|
P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Timer job
|
//~ Timer job
|
||||||
|
|
||||||
JobDecl(P_W32_StartTimerSync, EmptySig);
|
JobDecl(P_W32_StartTimerSync, EmptySig);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
PB_WSP_SharedState PB_WSP_shared_state = ZI;
|
PB_WSP_SharedState PB_WSP_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void PB_Startup(void)
|
void PB_Startup(void)
|
||||||
@ -120,7 +120,7 @@ void PB_WSP_InitializeWasapi(void)
|
|||||||
IAudioClient_GetBufferSize(g->client, &g->buffer_frames);
|
IAudioClient_GetBufferSize(g->client, &g->buffer_frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Wasapi update
|
//~ Wasapi update
|
||||||
|
|
||||||
PB_WSP_Buff PB_WSP_BeginUpdate(void)
|
PB_WSP_Buff PB_WSP_BeginUpdate(void)
|
||||||
@ -178,7 +178,7 @@ void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src)
|
|||||||
__profframe("Audio");
|
__profframe("Audio");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Playback job
|
//~ Playback job
|
||||||
|
|
||||||
JobDef(PB_WSP_Playback, UNUSED sig, UNUSED id)
|
JobDef(PB_WSP_Playback, UNUSED sig, UNUSED id)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 libs
|
//~ Win32 libs
|
||||||
|
|
||||||
#pragma warning(push, 0)
|
#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_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);
|
DEFINE_GUID(IID_IAudioRenderClient, 0xf294acfc, 0x3146, 0x4483, 0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Wasapi buffer types
|
//~ Wasapi buffer types
|
||||||
|
|
||||||
Struct(PB_WSP_Buff)
|
Struct(PB_WSP_Buff)
|
||||||
@ -21,7 +21,7 @@ Struct(PB_WSP_Buff)
|
|||||||
u8 *frames;
|
u8 *frames;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
Struct(PB_WSP_SharedState)
|
Struct(PB_WSP_SharedState)
|
||||||
@ -36,19 +36,19 @@ Struct(PB_WSP_SharedState)
|
|||||||
u32 shutdown_jobs_count;
|
u32 shutdown_jobs_count;
|
||||||
} extern PB_WSP_shared_state;
|
} extern PB_WSP_shared_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Wasapi startup
|
//~ Wasapi startup
|
||||||
|
|
||||||
void PB_WSP_InitializeWasapi(void);
|
void PB_WSP_InitializeWasapi(void);
|
||||||
ExitFuncDef(PB_WSP_Shutdown);
|
ExitFuncDef(PB_WSP_Shutdown);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Playback update
|
//~ Playback update
|
||||||
|
|
||||||
PB_WSP_Buff PB_WSP_BeginUpdate(void);
|
PB_WSP_Buff PB_WSP_BeginUpdate(void);
|
||||||
void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src);
|
void PB_WSP_EndUpdate(PB_WSP_Buff *wspbuf, MIX_PcmF32 src);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Playback job
|
//~ Playback job
|
||||||
|
|
||||||
JobDecl(PB_WSP_Playback, EmptySig);
|
JobDecl(PB_WSP_Playback, EmptySig);
|
||||||
|
|||||||
38
src/pp/pp.c
38
src/pp/pp.c
@ -1,6 +1,6 @@
|
|||||||
SharedUserState shared_user_state = ZI;
|
SharedUserState shared_user_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void StartupUser(void)
|
void StartupUser(void)
|
||||||
@ -46,7 +46,7 @@ void StartupUser(void)
|
|||||||
OnExit(&ShutdownUser);
|
OnExit(&ShutdownUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shutdown
|
//~ Shutdown
|
||||||
|
|
||||||
ExitFuncDef(ShutdownUser)
|
ExitFuncDef(ShutdownUser)
|
||||||
@ -58,7 +58,7 @@ ExitFuncDef(ShutdownUser)
|
|||||||
P_ReleaseWindow(g->window);
|
P_ReleaseWindow(g->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Debug draw
|
//~ Debug draw
|
||||||
|
|
||||||
//- Draw xform
|
//- Draw xform
|
||||||
@ -232,7 +232,7 @@ String DebugStringFromEntity(Arena *arena, Entity *ent)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Console
|
//~ Console
|
||||||
|
|
||||||
//- Console log callback
|
//- Console log callback
|
||||||
@ -377,7 +377,7 @@ void DrawDebugConsole(i32 level, b32 minimized)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Render buffers
|
//~ Render buffers
|
||||||
|
|
||||||
//- Gbuffer
|
//- Gbuffer
|
||||||
@ -393,7 +393,7 @@ GPU_Resource *AcquireGbuffer(GPU_Format format, Vec2I32 size)
|
|||||||
return GPU_AcquireResource(desc);
|
return GPU_AcquireResource(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sort entities
|
//~ Sort entities
|
||||||
|
|
||||||
MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _)
|
MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _)
|
||||||
@ -435,7 +435,7 @@ MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ User update
|
//~ User update
|
||||||
|
|
||||||
void UpdateUser(P_Window *window)
|
void UpdateUser(P_Window *window)
|
||||||
@ -451,7 +451,7 @@ void UpdateUser(P_Window *window)
|
|||||||
|
|
||||||
//- Begin UI
|
//- Begin UI
|
||||||
UI_BeginBuild();
|
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);
|
UI_Push(Parent, pp_root_box);
|
||||||
|
|
||||||
//- Init render data buffers
|
//- Init render data buffers
|
||||||
@ -1996,7 +1996,10 @@ void UpdateUser(P_Window *window)
|
|||||||
|
|
||||||
GPU_MemoryInfo vram = GPU_QueryMemoryInfo();
|
GPU_MemoryInfo vram = GPU_QueryMemoryInfo();
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
|
//- Debug draw
|
||||||
|
|
||||||
|
|
||||||
//~ Draw global debug info
|
//~ Draw global debug info
|
||||||
/* FIXME: Enable this */
|
/* FIXME: Enable this */
|
||||||
#if 1
|
#if 1
|
||||||
@ -2012,7 +2015,7 @@ void UpdateUser(P_Window *window)
|
|||||||
UI_Push(Parent, dbg_box);
|
UI_Push(Parent, dbg_box);
|
||||||
UI_Push(Width, UI_TextSize(0));
|
UI_Push(Width, UI_TextSize(0));
|
||||||
UI_Push(Height, 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_BuildLabelF("blended world entities: %F/%F", FmtUint(g->ss_blended->num_ents_allocated), FmtUint(g->ss_blended->num_ents_reserved));
|
||||||
UI_BuildSeparator();
|
UI_BuildSeparator();
|
||||||
@ -2238,8 +2241,9 @@ void UpdateUser(P_Window *window)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Render
|
//- Render
|
||||||
|
|
||||||
Rect ui_viewport = RectFromVec2(VEC2(0, 0), VEC2(g->ui_size.x, g->ui_size.y));
|
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));
|
Rect render_viewport = RectFromVec2(VEC2(0, 0), VEC2(g->render_size.x, g->render_size.y));
|
||||||
GPU_QueueKind gpu_render_queue = GPU_QueueKind_Direct;
|
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);
|
UI_SetDisplayImage(pp_root_box, g->ui_target);
|
||||||
GPU_Resource *ui_render = UI_EndBuild(ui_viewport);
|
GPU_Resource *ui_render = UI_EndBuild(ui_viewport);
|
||||||
|
|
||||||
////////////////////////////////
|
//////////////////////////////
|
||||||
//~ Present
|
//- Present
|
||||||
|
|
||||||
Vec2 backbuffer_dst_f = MulXformV2(g->ui_to_screen_xf, VEC2(0, 0));
|
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));
|
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);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ User update job
|
//~ User update job
|
||||||
|
|
||||||
JobDef(UpdateUserOrSleep, UNUSED sig, UNUSED id)
|
JobDef(UpdateUserOrSleep, UNUSED sig, UNUSED id)
|
||||||
@ -2589,7 +2593,7 @@ JobDef(UpdateUserOrSleep, UNUSED sig, UNUSED id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Generate user input cmds
|
//~ Generate user input cmds
|
||||||
|
|
||||||
void GenerateuserInputCmds(Client *user_input_client, u64 tick)
|
void GenerateuserInputCmds(Client *user_input_client, u64 tick)
|
||||||
@ -2629,7 +2633,7 @@ void GenerateuserInputCmds(Client *user_input_client, u64 tick)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sim update
|
//~ Sim update
|
||||||
|
|
||||||
JobDef(UpdateSim, UNUSED sig, UNUSED id)
|
JobDef(UpdateSim, UNUSED sig, UNUSED id)
|
||||||
|
|||||||
30
src/pp/pp.h
30
src/pp/pp.h
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Binds
|
//~ Binds
|
||||||
|
|
||||||
//- Bind kinds
|
//- Bind kinds
|
||||||
@ -95,7 +95,7 @@ Global Readonly BindKind g_binds[P_Btn_Count] = {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Stats
|
//~ Stats
|
||||||
|
|
||||||
Struct(SecondsStat)
|
Struct(SecondsStat)
|
||||||
@ -105,7 +105,7 @@ Struct(SecondsStat)
|
|||||||
u64 last_second;
|
u64 last_second;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Console log
|
//~ Console log
|
||||||
|
|
||||||
Struct(ConsoleLog)
|
Struct(ConsoleLog)
|
||||||
@ -120,7 +120,7 @@ Struct(ConsoleLog)
|
|||||||
ConsoleLog *next;
|
ConsoleLog *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sim decode queue
|
//~ Sim decode queue
|
||||||
|
|
||||||
Struct(DecodeQueueNode)
|
Struct(DecodeQueueNode)
|
||||||
@ -138,7 +138,7 @@ Struct(DecodeQueue)
|
|||||||
DecodeQueueNode *last;
|
DecodeQueueNode *last;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
Struct(BindState)
|
Struct(BindState)
|
||||||
@ -271,55 +271,55 @@ Struct(SharedUserState)
|
|||||||
Vec2 focus_send;
|
Vec2 focus_send;
|
||||||
} extern shared_user_state;
|
} extern shared_user_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void StartupUser(void);
|
void StartupUser(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shutdown
|
//~ Shutdown
|
||||||
|
|
||||||
ExitFuncDef(ShutdownUser);
|
ExitFuncDef(ShutdownUser);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Debug draw operations
|
//~ Debug draw operations
|
||||||
|
|
||||||
void DrawDebugXform(Xform xf, u32 color_x, u32 color_y);
|
void DrawDebugXform(Xform xf, u32 color_x, u32 color_y);
|
||||||
void DrawDebugMovement(Entity *ent);
|
void DrawDebugMovement(Entity *ent);
|
||||||
String DebugStringFromEntity(Arena *arena, Entity *ent);
|
String DebugStringFromEntity(Arena *arena, Entity *ent);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Console draw operations
|
//~ Console draw operations
|
||||||
|
|
||||||
P_LogEventCallbackFuncDef(ConsoleLogCallback, log);
|
P_LogEventCallbackFuncDef(ConsoleLogCallback, log);
|
||||||
void DrawDebugConsole(i32 level, b32 minimized);
|
void DrawDebugConsole(i32 level, b32 minimized);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Gpu buffer helpers
|
//~ Gpu buffer helpers
|
||||||
|
|
||||||
GPU_Resource *AcquireGbuffer(GPU_Format format, Vec2I32 size);
|
GPU_Resource *AcquireGbuffer(GPU_Format format, Vec2I32 size);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Entity sorting
|
//~ Entity sorting
|
||||||
|
|
||||||
MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _);
|
MergesortCompareFuncDef(EntitySortCmp, arg_a, arg_b, _);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ User update
|
//~ User update
|
||||||
|
|
||||||
void UpdateUser(P_Window *window);
|
void UpdateUser(P_Window *window);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ User update job
|
//~ User update job
|
||||||
|
|
||||||
JobDecl(UpdateUserOrSleep, EmptySig);
|
JobDecl(UpdateUserOrSleep, EmptySig);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ User input cmds
|
//~ User input cmds
|
||||||
|
|
||||||
void GenerateuserInputCmds(Client *user_input_client, u64 tick);
|
void GenerateuserInputCmds(Client *user_input_client, u64 tick);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sim update job
|
//~ Sim update job
|
||||||
|
|
||||||
JobDecl(UpdateSim, EmptySig);
|
JobDecl(UpdateSim, EmptySig);
|
||||||
|
|||||||
@ -5,7 +5,7 @@ ConstantBuffer<UiBlitSig> ui_blit_sig : register (b0);
|
|||||||
ConstantBuffer<UiRectSig> ui_rect_sig : register (b0);
|
ConstantBuffer<UiRectSig> ui_rect_sig : register (b0);
|
||||||
ConstantBuffer<UiShapeSig> ui_shape_sig : register (b0);
|
ConstantBuffer<UiShapeSig> ui_shape_sig : register (b0);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Material
|
//~ Material
|
||||||
|
|
||||||
Struct(MaterialPS_Input)
|
Struct(MaterialPS_Input)
|
||||||
@ -122,7 +122,7 @@ MaterialPS_Output PSDef(MaterialPS, MaterialPS_Input input)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Flood
|
//~ Flood
|
||||||
|
|
||||||
//- Compute shader
|
//- Compute shader
|
||||||
@ -187,7 +187,7 @@ void CSDef(FloodCS, Semantic(Vec3U32, sv_dispatchthreadid))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shade
|
//~ Shade
|
||||||
|
|
||||||
#define LightSamples 16
|
#define LightSamples 16
|
||||||
@ -294,7 +294,7 @@ void CSDef(ShadeCS, Semantic(Vec3U32, sv_dispatchthreadid))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ui Blit
|
//~ Ui Blit
|
||||||
|
|
||||||
Struct(UiBlitPS_Input)
|
Struct(UiBlitPS_Input)
|
||||||
@ -365,7 +365,7 @@ UiBlitPS_Output PSDef(UiBlitPS, UiBlitPS_Input input)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ui rect
|
//~ Ui rect
|
||||||
|
|
||||||
Struct(UiRectPS_Input)
|
Struct(UiRectPS_Input)
|
||||||
@ -426,7 +426,7 @@ UiRectPS_Output PSDef(UiRectPS, UiRectPS_Input input)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ui shape
|
//~ Ui shape
|
||||||
|
|
||||||
Struct(UiShapePS_Input)
|
Struct(UiShapePS_Input)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Material types
|
//~ Material types
|
||||||
|
|
||||||
Struct(MaterialSig)
|
Struct(MaterialSig)
|
||||||
@ -51,7 +51,7 @@ Struct(MaterialGrid)
|
|||||||
.bg0_srgb = Color_White \
|
.bg0_srgb = Color_White \
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Flood types
|
//~ Flood types
|
||||||
|
|
||||||
Struct(FloodSig)
|
Struct(FloodSig)
|
||||||
@ -70,7 +70,7 @@ Struct(FloodSig)
|
|||||||
};
|
};
|
||||||
AssertRootConst(FloodSig, 8);
|
AssertRootConst(FloodSig, 8);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Shade types
|
//~ Shade types
|
||||||
|
|
||||||
#define ShadeFlag_None (0 << 0)
|
#define ShadeFlag_None (0 << 0)
|
||||||
@ -103,7 +103,7 @@ Struct(ShadeSig)
|
|||||||
};
|
};
|
||||||
AssertRootConst(ShadeSig, 20);
|
AssertRootConst(ShadeSig, 20);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ui blit types
|
//~ Ui blit types
|
||||||
|
|
||||||
#define UiBlitFlag_None (0)
|
#define UiBlitFlag_None (0)
|
||||||
@ -129,7 +129,7 @@ Struct(UiBlitSig)
|
|||||||
AssertRootConst(UiBlitSig, 24);
|
AssertRootConst(UiBlitSig, 24);
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ui rect types
|
//~ Ui rect types
|
||||||
|
|
||||||
Struct(UiRectSig)
|
Struct(UiRectSig)
|
||||||
@ -154,7 +154,7 @@ Struct(UiRectInstance)
|
|||||||
u32 tint_srgb;
|
u32 tint_srgb;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ui shape types
|
//~ Ui shape types
|
||||||
|
|
||||||
Struct(UiShapeSig)
|
Struct(UiShapeSig)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Acquire
|
//~ Acquire
|
||||||
|
|
||||||
Entity *AcquireRaw(Snapshot *ss, Entity *parent, EntityId id)
|
Entity *AcquireRaw(Snapshot *ss, Entity *parent, EntityId id)
|
||||||
@ -78,7 +78,7 @@ Entity *AcquireSyncDst(Entity *parent, EntityId ent_id, EntityId owner_id)
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Release
|
//~ Release
|
||||||
|
|
||||||
void ReleaseRaw(Entity *ent)
|
void ReleaseRaw(Entity *ent)
|
||||||
@ -145,7 +145,7 @@ void ReleaseAllWithProp(Snapshot *ss, Prop prop)
|
|||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Activate
|
//~ Activate
|
||||||
|
|
||||||
void Activate(Entity *ent, u64 current_tick)
|
void Activate(Entity *ent, u64 current_tick)
|
||||||
@ -155,7 +155,7 @@ void Activate(Entity *ent, u64 current_tick)
|
|||||||
++ent->continuity_gen;
|
++ent->continuity_gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Entity id
|
//~ Entity id
|
||||||
|
|
||||||
u32 IndexFromEntity(Snapshot *ss, Entity *ent)
|
u32 IndexFromEntity(Snapshot *ss, Entity *ent)
|
||||||
@ -321,7 +321,7 @@ EntityId TileChunkIdFromIndex(Vec2I32 chunk_index)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Query
|
//~ Query
|
||||||
|
|
||||||
Entity *FirstWithProp(Snapshot *ss, Prop prop)
|
Entity *FirstWithProp(Snapshot *ss, Prop prop)
|
||||||
@ -366,7 +366,7 @@ Entity *FirstWithAllProps(Snapshot *ss, PropArray props)
|
|||||||
return NilEntity();
|
return NilEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tree
|
//~ Tree
|
||||||
|
|
||||||
void Link(Entity *ent, Entity *parent)
|
void Link(Entity *ent, Entity *parent)
|
||||||
@ -438,7 +438,7 @@ void Unlink(Entity *ent)
|
|||||||
ent->next = NilEntityId;
|
ent->next = NilEntityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Xform
|
//~ Xform
|
||||||
|
|
||||||
void MarkChildXformsDirty(Snapshot *ss, Entity *ent)
|
void MarkChildXformsDirty(Snapshot *ss, Entity *ent)
|
||||||
@ -549,7 +549,7 @@ void SetLocalXform(Entity *ent, Xform xf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Movement
|
//~ Movement
|
||||||
|
|
||||||
void SetLinearVelocity(Entity *ent, Vec2 velocity)
|
void SetLinearVelocity(Entity *ent, Vec2 velocity)
|
||||||
@ -623,7 +623,7 @@ void ApplyTorque(Entity *ent, f32 torque)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tile
|
//~ Tile
|
||||||
|
|
||||||
Entity *TileChunkFromChunkIndex(Snapshot *ss, Vec2I32 chunk_index)
|
Entity *TileChunkFromChunkIndex(Snapshot *ss, Vec2I32 chunk_index)
|
||||||
@ -646,7 +646,7 @@ TileKind TileKindFromChunk(Entity *chunk_ent, Vec2I32 local_tile_index)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Lerp
|
//~ Lerp
|
||||||
|
|
||||||
void LerpEntity(Entity *e, Entity *e0, Entity *e1, f64 blend)
|
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
|
//~ Sync
|
||||||
|
|
||||||
/* Walks a local & remote ent tree and allocates any missing net dst ents from remote src ents */
|
/* 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
|
#if 1
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Encode
|
//~ Encode
|
||||||
|
|
||||||
void EncodeEntity(BB_Writer *bw, Entity *e0, Entity *e1)
|
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;
|
e1->ss = ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode
|
//~ Decode
|
||||||
|
|
||||||
void DecodeEntity(BB_Reader *br, Entity *e)
|
void DecodeEntity(BB_Reader *br, Entity *e)
|
||||||
@ -798,7 +798,7 @@ void DecodeEntity(BB_Reader *br, Entity *e)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Encode
|
//~ Encode
|
||||||
|
|
||||||
void EncodeEntity(BB_Writer *bw, Entity *e0, Entity *e1)
|
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;
|
e1->ss = ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode
|
//~ Decode
|
||||||
|
|
||||||
void DecodeEntity(BB_Reader *br, Entity *e)
|
void DecodeEntity(BB_Reader *br, Entity *e)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Entity props
|
//~ Entity props
|
||||||
|
|
||||||
Enum(Prop)
|
Enum(Prop)
|
||||||
@ -61,7 +61,7 @@ Enum(Prop)
|
|||||||
Prop_Count
|
Prop_Count
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Entity
|
//~ Entity
|
||||||
|
|
||||||
Struct(Entity)
|
Struct(Entity)
|
||||||
@ -393,7 +393,7 @@ Inline Entity *NilEntity(void)
|
|||||||
return *_g_sim_ent_nil;
|
return *_g_sim_ent_nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Id types
|
//~ Id types
|
||||||
|
|
||||||
#define NilEntityId ((EntityId) { UID(0, 0) })
|
#define NilEntityId ((EntityId) { UID(0, 0) })
|
||||||
@ -404,7 +404,7 @@ Inline Entity *NilEntity(void)
|
|||||||
#define ContactBasisUid (UID(0x6a2a5d2dbecf534f, 0x0a8ca7c372a015af))
|
#define ContactBasisUid (UID(0x6a2a5d2dbecf534f, 0x0a8ca7c372a015af))
|
||||||
#define CollisionDebugBasisUid (UID(0x302c01182013bb02, 0x570bd270399d11a5))
|
#define CollisionDebugBasisUid (UID(0x302c01182013bb02, 0x570bd270399d11a5))
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Id helpers
|
//~ Id helpers
|
||||||
|
|
||||||
Inline b32 EqId(EntityId a, EntityId b)
|
Inline b32 EqId(EntityId a, EntityId b)
|
||||||
@ -417,7 +417,7 @@ Inline b32 IsNilId(EntityId id)
|
|||||||
return EqUid(id.uid, NilEntityId.uid);
|
return EqUid(id.uid, NilEntityId.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Property helpers
|
//~ Property helpers
|
||||||
|
|
||||||
Inline void EnableProp(Entity *ent, Prop prop)
|
Inline void EnableProp(Entity *ent, Prop prop)
|
||||||
@ -471,7 +471,7 @@ Inline b32 ShouldSimulate(Entity *ent)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Acquire operations
|
//~ Acquire operations
|
||||||
|
|
||||||
Entity *AcquireRaw(Snapshot *ss, Entity *parent, EntityId id);
|
Entity *AcquireRaw(Snapshot *ss, Entity *parent, EntityId id);
|
||||||
@ -481,19 +481,19 @@ Entity *AcquireSyncSrc(Entity *parent);
|
|||||||
Entity *AcquireSyncSrcWithId(Entity *parent, EntityId id);
|
Entity *AcquireSyncSrcWithId(Entity *parent, EntityId id);
|
||||||
Entity *AcquireSyncDst(Entity *parent, EntityId ent_id, EntityId owner_id);
|
Entity *AcquireSyncDst(Entity *parent, EntityId ent_id, EntityId owner_id);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Release operations
|
//~ Release operations
|
||||||
|
|
||||||
void ReleaseRaw(Entity *ent);
|
void ReleaseRaw(Entity *ent);
|
||||||
void Release(Entity *ent);
|
void Release(Entity *ent);
|
||||||
void ReleaseAllWithProp(Snapshot *ss, Prop prop);
|
void ReleaseAllWithProp(Snapshot *ss, Prop prop);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Activate operations
|
//~ Activate operations
|
||||||
|
|
||||||
void Activate(Entity *ent, u64 current_tick);
|
void Activate(Entity *ent, u64 current_tick);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Id operations
|
//~ Id operations
|
||||||
|
|
||||||
u32 IndexFromEntity(Snapshot *ss, Entity *ent);
|
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 CollisionDebugIdFromIds(EntityId player_id, EntityId id0, EntityId id1);
|
||||||
EntityId TileChunkIdFromIndex(Vec2I32 chunk_start);
|
EntityId TileChunkIdFromIndex(Vec2I32 chunk_start);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Query operations
|
//~ Query operations
|
||||||
|
|
||||||
Entity *FirstWithProp(Snapshot *ss, Prop prop);
|
Entity *FirstWithProp(Snapshot *ss, Prop prop);
|
||||||
Entity *FirstWithAllProps(Snapshot *ss, PropArray props);
|
Entity *FirstWithAllProps(Snapshot *ss, PropArray props);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tree operations
|
//~ Tree operations
|
||||||
|
|
||||||
void Link(Entity *parent, Entity *child);
|
void Link(Entity *parent, Entity *child);
|
||||||
void Unlink(Entity *ent);
|
void Unlink(Entity *ent);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Xform operations
|
//~ Xform operations
|
||||||
|
|
||||||
void MarkChildXformsDirty(Snapshot *ss, Entity *ent);
|
void MarkChildXformsDirty(Snapshot *ss, Entity *ent);
|
||||||
@ -528,7 +528,7 @@ Xform LocalXformFromEntity(Entity *ent);
|
|||||||
void SetXform(Entity *ent, Xform xf);
|
void SetXform(Entity *ent, Xform xf);
|
||||||
void SetLocalXform(Entity *ent, Xform xf);
|
void SetLocalXform(Entity *ent, Xform xf);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Movement operations
|
//~ Movement operations
|
||||||
|
|
||||||
void SetLinearVelocity(Entity *ent, Vec2 velocity);
|
void SetLinearVelocity(Entity *ent, Vec2 velocity);
|
||||||
@ -539,30 +539,30 @@ void ApplyForceToCenter(Entity *ent, Vec2 force);
|
|||||||
void ApplyAngularImpulse(Entity *ent, f32 impulse);
|
void ApplyAngularImpulse(Entity *ent, f32 impulse);
|
||||||
void ApplyTorque(Entity *ent, f32 torque);
|
void ApplyTorque(Entity *ent, f32 torque);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tile operations
|
//~ Tile operations
|
||||||
|
|
||||||
Entity *TileChunkFromChunkIndex(Snapshot *ss, Vec2I32 chunk_index);
|
Entity *TileChunkFromChunkIndex(Snapshot *ss, Vec2I32 chunk_index);
|
||||||
Entity *TileChunkFromWorldTileIndex(Snapshot *ss, Vec2I32 world_tile_index);
|
Entity *TileChunkFromWorldTileIndex(Snapshot *ss, Vec2I32 world_tile_index);
|
||||||
TileKind TileKindFromChunk(Entity *chunk_ent, Vec2I32 local_tile_index);
|
TileKind TileKindFromChunk(Entity *chunk_ent, Vec2I32 local_tile_index);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Lerp operations
|
//~ Lerp operations
|
||||||
|
|
||||||
void LerpEntity(Entity *e, Entity *e0, Entity *e1, f64 blend);
|
void LerpEntity(Entity *e, Entity *e0, Entity *e1, f64 blend);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sync operations
|
//~ Sync operations
|
||||||
|
|
||||||
void CreateMissingEntitiesFromSnapshots(Entity *local_parent, Entity *remote, EntityId remote_player);
|
void CreateMissingEntitiesFromSnapshots(Entity *local_parent, Entity *remote, EntityId remote_player);
|
||||||
void SyncEntity(Entity *local, Entity *remote);
|
void SyncEntity(Entity *local, Entity *remote);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Encode
|
//~ Encode
|
||||||
|
|
||||||
void EncodeEntity(BB_Writer *bw, Entity *e0, Entity *e1);
|
void EncodeEntity(BB_Writer *bw, Entity *e0, Entity *e1);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Decode
|
//~ Decode
|
||||||
|
|
||||||
void DecodeEntity(BB_Reader *br, Entity *e);
|
void DecodeEntity(BB_Reader *br, Entity *e);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Contact
|
//~ Contact
|
||||||
|
|
||||||
b32 CanEntitiesContact(Entity *e0, Entity *e1)
|
b32 CanEntitiesContact(Entity *e0, Entity *e1)
|
||||||
@ -589,7 +589,7 @@ void SolveContacts(PhysStepCtx *ctx, f32 dt, b32 apply_bias)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Motor joint
|
//~ Motor joint
|
||||||
|
|
||||||
MotorJointDesc CreateMotorJointDef(void)
|
MotorJointDesc CreateMotorJointDef(void)
|
||||||
@ -788,7 +788,7 @@ void SolveMotorJoints(PhysStepCtx *ctx, f32 dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mouse joint
|
//~ Mouse joint
|
||||||
|
|
||||||
MouseJointDesc CreateMouseJointDef(void)
|
MouseJointDesc CreateMouseJointDef(void)
|
||||||
@ -962,7 +962,7 @@ void SolveMouseJoints(PhysStepCtx *ctx, f32 dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Weld joint
|
//~ Weld joint
|
||||||
|
|
||||||
WeldJointDesc CreateWeldJointDef(void)
|
WeldJointDesc CreateWeldJointDef(void)
|
||||||
@ -1147,7 +1147,7 @@ void SolveWeldJoints(PhysStepCtx *ctx, f32 dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Integration
|
//~ Integration
|
||||||
|
|
||||||
Xform GetDerivedEntityXform(Entity *ent, f32 dt)
|
Xform GetDerivedEntityXform(Entity *ent, f32 dt)
|
||||||
@ -1222,7 +1222,7 @@ void IntegrateVelocities(PhysStepCtx *ctx, f32 dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Earliest time of impact
|
//~ Earliest time of impact
|
||||||
|
|
||||||
f32 DetermineEarliestToi(PhysStepCtx *ctx, f32 step_dt, f32 tolerance, u32 max_iterations)
|
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;
|
return smallest_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Spatial
|
//~ Spatial
|
||||||
|
|
||||||
void UpdateAabbs(PhysStepCtx *ctx)
|
void UpdateAabbs(PhysStepCtx *ctx)
|
||||||
@ -1302,7 +1302,7 @@ void UpdateAabbs(PhysStepCtx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Step
|
//~ Step
|
||||||
|
|
||||||
/* Returns phys iteration to be fed into next step. Supplied iteration must be > 0. */
|
/* Returns phys iteration to be fed into next step. Supplied iteration must be > 0. */
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Collision data types
|
//~ Collision data types
|
||||||
|
|
||||||
#define ContactSpringHz 25
|
#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)
|
#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);
|
typedef CollisionCallbackFuncDef(CollisionCallbackFunc, collision_data, ctx);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Step ctx
|
//~ Step ctx
|
||||||
|
|
||||||
/* Structure containing data used for a single physics step */
|
/* Structure containing data used for a single physics step */
|
||||||
@ -30,7 +30,7 @@ Struct(PhysStepCtx)
|
|||||||
CollisionCallbackFunc *collision_callback;
|
CollisionCallbackFunc *collision_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Contact types
|
//~ Contact types
|
||||||
|
|
||||||
Struct(ContactPoint)
|
Struct(ContactPoint)
|
||||||
@ -97,7 +97,7 @@ Struct(ContactDebugData)
|
|||||||
Xform xf1;
|
Xform xf1;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Motor joint types
|
//~ Motor joint types
|
||||||
|
|
||||||
Struct(MotorJointDesc)
|
Struct(MotorJointDesc)
|
||||||
@ -132,7 +132,7 @@ Struct(MotorJoint)
|
|||||||
f32 angular_mass;
|
f32 angular_mass;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mouse joint types
|
//~ Mouse joint types
|
||||||
|
|
||||||
Struct(MouseJointDesc)
|
Struct(MouseJointDesc)
|
||||||
@ -167,7 +167,7 @@ Struct(MouseJoint)
|
|||||||
Xform linear_mass_xf;
|
Xform linear_mass_xf;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Weld joint types
|
//~ Weld joint types
|
||||||
|
|
||||||
Struct(WeldJointDesc)
|
Struct(WeldJointDesc)
|
||||||
@ -207,7 +207,7 @@ Struct(WeldJoint)
|
|||||||
f32 angular_impulse1;
|
f32 angular_impulse1;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Contact operations
|
//~ Contact operations
|
||||||
|
|
||||||
b32 CanEntitiesContact(struct Entity *e0, struct Entity *e1);
|
b32 CanEntitiesContact(struct Entity *e0, struct Entity *e1);
|
||||||
@ -216,7 +216,7 @@ void PrepareContacts(PhysStepCtx *ctx, u64 phys_iteration);
|
|||||||
void WarmStartContacts(PhysStepCtx *ctx);
|
void WarmStartContacts(PhysStepCtx *ctx);
|
||||||
void SolveContacts(PhysStepCtx *ctx, f32 dt, b32 apply_bias);
|
void SolveContacts(PhysStepCtx *ctx, f32 dt, b32 apply_bias);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Motor joint operations
|
//~ Motor joint operations
|
||||||
|
|
||||||
MotorJointDesc CreateMotorJointDef(void);
|
MotorJointDesc CreateMotorJointDef(void);
|
||||||
@ -225,7 +225,7 @@ void PrepareMotorJoints(PhysStepCtx *ctx);
|
|||||||
void WarmStartMotorJoints(PhysStepCtx *ctx);
|
void WarmStartMotorJoints(PhysStepCtx *ctx);
|
||||||
void SolveMotorJoints(PhysStepCtx *ctx, f32 dt);
|
void SolveMotorJoints(PhysStepCtx *ctx, f32 dt);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Mouse joint operations
|
//~ Mouse joint operations
|
||||||
|
|
||||||
MouseJointDesc CreateMouseJointDef(void);
|
MouseJointDesc CreateMouseJointDef(void);
|
||||||
@ -234,7 +234,7 @@ void PrepareMouseJoints(PhysStepCtx *ctx);
|
|||||||
void WarmStartMouseJoints(PhysStepCtx *ctx);
|
void WarmStartMouseJoints(PhysStepCtx *ctx);
|
||||||
void SolveMouseJoints(PhysStepCtx *ctx, f32 dt);
|
void SolveMouseJoints(PhysStepCtx *ctx, f32 dt);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Weld joint operations
|
//~ Weld joint operations
|
||||||
|
|
||||||
WeldJointDesc CreateWeldJointDef(void);
|
WeldJointDesc CreateWeldJointDef(void);
|
||||||
@ -243,7 +243,7 @@ void PrepareWeldJoints(PhysStepCtx *ctx);
|
|||||||
void WarmStartWeldJoints(PhysStepCtx *ctx);
|
void WarmStartWeldJoints(PhysStepCtx *ctx);
|
||||||
void SolveWeldJoints(PhysStepCtx *ctx, f32 dt);
|
void SolveWeldJoints(PhysStepCtx *ctx, f32 dt);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Integration operations
|
//~ Integration operations
|
||||||
|
|
||||||
struct Entity;
|
struct Entity;
|
||||||
@ -251,17 +251,17 @@ Xform GetDerivedEntityXform(struct Entity *ent, f32 dt);
|
|||||||
void IntegrateForces(PhysStepCtx *ctx, f32 dt);
|
void IntegrateForces(PhysStepCtx *ctx, f32 dt);
|
||||||
void IntegrateVelocities(PhysStepCtx *ctx, f32 dt);
|
void IntegrateVelocities(PhysStepCtx *ctx, f32 dt);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Time of impact operations
|
//~ Time of impact operations
|
||||||
|
|
||||||
f32 DetermineEarliestToi(PhysStepCtx *ctx, f32 step_dt, f32 tolerance, u32 max_iterations);
|
f32 DetermineEarliestToi(PhysStepCtx *ctx, f32 step_dt, f32 tolerance, u32 max_iterations);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Spatial operations
|
//~ Spatial operations
|
||||||
|
|
||||||
void UpdateAabbs(PhysStepCtx *ctx);
|
void UpdateAabbs(PhysStepCtx *ctx);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Step
|
//~ Step
|
||||||
|
|
||||||
void StepPhys(PhysStepCtx *ctx, f32 timestep);
|
void StepPhys(PhysStepCtx *ctx, f32 timestep);
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
* is used when working in contexts where id is irrelevant.
|
* is used when working in contexts where id is irrelevant.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
SharedSimCtx shared_sim_ctx = ZI;
|
SharedSimCtx shared_sim_ctx = ZI;
|
||||||
@ -71,7 +71,7 @@ void StartupSim(void)
|
|||||||
SetArenaReadonly(g->nil_arena);
|
SetArenaReadonly(g->nil_arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Acquire client store
|
//~ Acquire client store
|
||||||
|
|
||||||
ClientStore *AcquireClientStore(void)
|
ClientStore *AcquireClientStore(void)
|
||||||
@ -106,7 +106,7 @@ void ReleaseClientStore(ClientStore *store)
|
|||||||
ReleaseArena(store->arena);
|
ReleaseArena(store->arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Acquire client
|
//~ Acquire client
|
||||||
|
|
||||||
Client *AcquireClient(ClientStore *store)
|
Client *AcquireClient(ClientStore *store)
|
||||||
@ -169,7 +169,7 @@ void ReleaseClient(Client *client)
|
|||||||
ReleaseArena(client->snapshots_arena);
|
ReleaseArena(client->snapshots_arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Client lookup
|
//~ Client lookup
|
||||||
|
|
||||||
u64 ClientChannelHashFromChannelId(N_ChannelId channel_id)
|
u64 ClientChannelHashFromChannelId(N_ChannelId channel_id)
|
||||||
@ -262,7 +262,7 @@ Client *ClientFromHandle(ClientStore *store, ClientHandle handle)
|
|||||||
return NilClient();
|
return NilClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Acquire snapshot
|
//~ Acquire snapshot
|
||||||
|
|
||||||
/* Produces a new snapshot at `tick` with data copied from `src` 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 lookup
|
||||||
|
|
||||||
Snapshot *SnapshotFromTick(Client *client, u64 tick)
|
Snapshot *SnapshotFromTick(Client *client, u64 tick)
|
||||||
@ -588,7 +588,7 @@ Snapshot *SnapshotFromClosestTickGte(Client *client, u64 tick)
|
|||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tile
|
//~ Tile
|
||||||
|
|
||||||
Vec2I32 WorldTileIndexFromPos(Vec2 pos)
|
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;
|
chunk_ent->tile_chunk_tiles[local_index.x + (local_index.y * SIM_TILES_PER_CHUNK_SQRT)] = tile_kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot lerp
|
//~ Snapshot lerp
|
||||||
|
|
||||||
Snapshot *AcquireSnapshotFromLerp(Client *client, Snapshot *ss0, Snapshot *ss1, f64 blend)
|
Snapshot *AcquireSnapshotFromLerp(Client *client, Snapshot *ss0, Snapshot *ss1, f64 blend)
|
||||||
@ -715,7 +715,7 @@ Snapshot *AcquireSnapshotFromLerp(Client *client, Snapshot *ss0, Snapshot *ss1,
|
|||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot sync
|
//~ Snapshot sync
|
||||||
|
|
||||||
/* Syncs entity data between snapshots */
|
/* Syncs entity data between snapshots */
|
||||||
@ -782,7 +782,7 @@ void SyncSnapshotEntities(Snapshot *local_ss, Snapshot *remote_ss, EntityId remo
|
|||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot encode
|
//~ Snapshot encode
|
||||||
|
|
||||||
void EncodeSnapshot(BB_Writer *bw, Client *receiver, Snapshot *ss0, Snapshot *ss1)
|
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"));
|
BB_WriteDebugMarker(bw, Lit("SNAPSHOT END"));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot decode
|
//~ Snapshot decode
|
||||||
|
|
||||||
void DecodeSnapshot(BB_Reader *br, Snapshot *ss)
|
void DecodeSnapshot(BB_Reader *br, Snapshot *ss)
|
||||||
@ -951,7 +951,7 @@ void DecodeSnapshot(BB_Reader *br, Snapshot *ss)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot encode
|
//~ Snapshot encode
|
||||||
|
|
||||||
void EncodeSnapshot(BB_Writer *bw, Client *receiver, Snapshot *ss0, Snapshot *ss1)
|
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
|
//~ Snapshot decode
|
||||||
|
|
||||||
struct sim_ent_decode_node
|
struct sim_ent_decode_node
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Id types
|
//~ Id types
|
||||||
|
|
||||||
Struct(EntityId)
|
Struct(EntityId)
|
||||||
@ -15,7 +15,7 @@ Struct(ClientHandle)
|
|||||||
#define NilClientHandle ((ClientHandle) { .gen = 0, .idx = 0 })
|
#define NilClientHandle ((ClientHandle) { .gen = 0, .idx = 0 })
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Client store types
|
//~ Client store types
|
||||||
|
|
||||||
Struct(ClientLookupBin)
|
Struct(ClientLookupBin)
|
||||||
@ -47,7 +47,7 @@ Inline ClientStore *sim_client_store_nil(void)
|
|||||||
return *_g_sim_client_store_nil;
|
return *_g_sim_client_store_nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Client types
|
//~ Client types
|
||||||
|
|
||||||
Struct(SnapshotLookupBin)
|
Struct(SnapshotLookupBin)
|
||||||
@ -110,7 +110,7 @@ Inline b32 EqClientHandle(ClientHandle a, ClientHandle b)
|
|||||||
return a.gen == b.gen && a.idx == b.idx;
|
return a.gen == b.gen && a.idx == b.idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Layer types
|
//~ Layer types
|
||||||
|
|
||||||
/* Absolute layers */
|
/* Absolute layers */
|
||||||
@ -124,7 +124,7 @@ Inline b32 EqClientHandle(ClientHandle a, ClientHandle b)
|
|||||||
#define Layer_DefaultRelative (0)
|
#define Layer_DefaultRelative (0)
|
||||||
#define Layer_RelativeWeapon (1)
|
#define Layer_RelativeWeapon (1)
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Control types
|
//~ Control types
|
||||||
|
|
||||||
Enum(ControlFlag)
|
Enum(ControlFlag)
|
||||||
@ -162,7 +162,7 @@ Enum(CmdKind)
|
|||||||
CmdKind_Chat
|
CmdKind_Chat
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tile types
|
//~ Tile types
|
||||||
|
|
||||||
Enum(TileKind)
|
Enum(TileKind)
|
||||||
@ -174,7 +174,7 @@ Enum(TileKind)
|
|||||||
};
|
};
|
||||||
StaticAssert(TileKind_Count < 256); /* Tile kind must fit in 8 bits */
|
StaticAssert(TileKind_Count < 256); /* Tile kind must fit in 8 bits */
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot types
|
//~ Snapshot types
|
||||||
|
|
||||||
Enum(SyncFlag)
|
Enum(SyncFlag)
|
||||||
@ -226,7 +226,7 @@ Inline Snapshot *NilSnapshot(void)
|
|||||||
return *_g_sim_snapshot_nil;
|
return *_g_sim_snapshot_nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
#define ClientLookupBinsCount 127
|
#define ClientLookupBinsCount 127
|
||||||
@ -254,24 +254,24 @@ extern Readonly Client **_g_sim_client_nil;
|
|||||||
extern Readonly Snapshot **_g_sim_snapshot_nil;
|
extern Readonly Snapshot **_g_sim_snapshot_nil;
|
||||||
extern Readonly struct Entity **_g_sim_ent_nil;
|
extern Readonly struct Entity **_g_sim_ent_nil;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void StartupSim(void);
|
void StartupSim(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Client store acquire operations
|
//~ Client store acquire operations
|
||||||
|
|
||||||
ClientStore *AcquireClientStore(void);
|
ClientStore *AcquireClientStore(void);
|
||||||
void ReleaseClientStore(ClientStore *store);
|
void ReleaseClientStore(ClientStore *store);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Client acquire operations
|
//~ Client acquire operations
|
||||||
|
|
||||||
Client *AcquireClient(ClientStore *store);
|
Client *AcquireClient(ClientStore *store);
|
||||||
void ReleaseClient(Client *client);
|
void ReleaseClient(Client *client);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Client lookup operations
|
//~ Client lookup operations
|
||||||
|
|
||||||
u64 ClientChannelHashFromChannelId(N_ChannelId channel_id);
|
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 *ClientFromChannelId(ClientStore *store, N_ChannelId channel_id);
|
||||||
Client *ClientFromHandle(ClientStore *store, ClientHandle handle);
|
Client *ClientFromHandle(ClientStore *store, ClientHandle handle);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot acquire operations
|
//~ Snapshot acquire operations
|
||||||
|
|
||||||
Snapshot *AcquireSnapshot(Client *client, Snapshot *src, u64 tick);
|
Snapshot *AcquireSnapshot(Client *client, Snapshot *src, u64 tick);
|
||||||
void ReleaseSnapshot(Snapshot *ss);
|
void ReleaseSnapshot(Snapshot *ss);
|
||||||
void ReleaseSnapshotsInRange(Client *client, u64 start, u64 end);
|
void ReleaseSnapshotsInRange(Client *client, u64 start, u64 end);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot lookup operations
|
//~ Snapshot lookup operations
|
||||||
|
|
||||||
Snapshot *SnapshotFromTick(Client *client, u64 tick);
|
Snapshot *SnapshotFromTick(Client *client, u64 tick);
|
||||||
Snapshot *SnapshotFromClosestTickLte(Client *client, u64 tick);
|
Snapshot *SnapshotFromClosestTickLte(Client *client, u64 tick);
|
||||||
Snapshot *SnapshotFromClosestTickGte(Client *client, u64 tick);
|
Snapshot *SnapshotFromClosestTickGte(Client *client, u64 tick);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tile operations
|
//~ Tile operations
|
||||||
|
|
||||||
Vec2I32 WorldTileIndexFromPos(Vec2 pos);
|
Vec2I32 WorldTileIndexFromPos(Vec2 pos);
|
||||||
@ -303,22 +303,22 @@ Vec2I32 WorldTileIndexFromLocalTileIndex(Vec2I32 tile_chunk_index, Vec2I32 local
|
|||||||
Vec2I32 TileChunkIndexFromWorldTileIndex(Vec2I32 world_tile_index);
|
Vec2I32 TileChunkIndexFromWorldTileIndex(Vec2I32 world_tile_index);
|
||||||
void SetSnapshotTile(Snapshot *ss, Vec2I32 world_tile_index, TileKind tile_kind);
|
void SetSnapshotTile(Snapshot *ss, Vec2I32 world_tile_index, TileKind tile_kind);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot lerp operations
|
//~ Snapshot lerp operations
|
||||||
|
|
||||||
Snapshot *AcquireSnapshotFromLerp(Client *client, Snapshot *ss0, Snapshot *ss1, f64 blend);
|
Snapshot *AcquireSnapshotFromLerp(Client *client, Snapshot *ss0, Snapshot *ss1, f64 blend);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot sync operations
|
//~ Snapshot sync operations
|
||||||
|
|
||||||
void SyncSnapshotEntities(Snapshot *local_ss, Snapshot *remote_ss, EntityId remote_player, u32 sync_flags);
|
void SyncSnapshotEntities(Snapshot *local_ss, Snapshot *remote_ss, EntityId remote_player, u32 sync_flags);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot encode operations
|
//~ Snapshot encode operations
|
||||||
|
|
||||||
void EncodeSnapshot(BB_Writer *bw, Client *receiver, Snapshot *ss0, Snapshot *ss1);
|
void EncodeSnapshot(BB_Writer *bw, Client *receiver, Snapshot *ss0, Snapshot *ss1);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Snapshot decode operations
|
//~ Snapshot decode operations
|
||||||
|
|
||||||
void DecodeSnapshot(BB_Reader *br, Snapshot *ss);
|
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 SpaceCell _g_space_cell_nil = ZI;
|
||||||
Readonly Space _g_space_nil = ZI;
|
Readonly Space _g_space_nil = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Space
|
//~ Space
|
||||||
|
|
||||||
/* NOTE:
|
/* NOTE:
|
||||||
@ -63,7 +63,7 @@ Space *SpaceFromEntry(SpaceEntry *entry)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Cell
|
//~ Cell
|
||||||
|
|
||||||
Vec2I32 SpaceCellCoordsFromWorldCoords(f32 cell_size, Vec2 world_pos)
|
Vec2I32 SpaceCellCoordsFromWorldCoords(f32 cell_size, Vec2 world_pos)
|
||||||
@ -285,7 +285,7 @@ void ReleaseSpaceCellNode(SpaceCellNode *n)
|
|||||||
space->first_free_cell_node = n;
|
space->first_free_cell_node = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Entry
|
//~ Entry
|
||||||
|
|
||||||
SpaceEntry *SpaceEntryFromHandle(Space *space, SpaceEntryHandle handle)
|
SpaceEntry *SpaceEntryFromHandle(Space *space, SpaceEntryHandle handle)
|
||||||
@ -399,7 +399,7 @@ void UpdateSpaceEntryAabb(SpaceEntry *entry, Aabb new_aabb)
|
|||||||
entry->aabb = new_aabb;
|
entry->aabb = new_aabb;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Iter
|
//~ Iter
|
||||||
|
|
||||||
SpaceIter BeginSpaceIterAabb(Space *space, Aabb aabb)
|
SpaceIter BeginSpaceIterAabb(Space *space, Aabb aabb)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Space entry types
|
//~ Space entry types
|
||||||
|
|
||||||
Struct(SpaceEntryHandle)
|
Struct(SpaceEntryHandle)
|
||||||
@ -21,7 +21,7 @@ Struct(SpaceEntry)
|
|||||||
SpaceEntry *next_free;
|
SpaceEntry *next_free;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Space cell types
|
//~ Space cell types
|
||||||
|
|
||||||
/* Links a cell to a entry.
|
/* Links a cell to a entry.
|
||||||
@ -63,7 +63,7 @@ Struct(SpaceCellBin)
|
|||||||
SpaceCell *last_cell;
|
SpaceCell *last_cell;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Space types
|
//~ Space types
|
||||||
|
|
||||||
Struct(Space)
|
Struct(Space)
|
||||||
@ -94,7 +94,7 @@ Struct(SpaceIter)
|
|||||||
SpaceCellNode *prev;
|
SpaceCellNode *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Nil types
|
//~ Nil types
|
||||||
|
|
||||||
/* Offset in bytes from start of space struct to start of entry array (assume adjacently allocated) */
|
/* 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 SpaceCell _g_space_cell_nil;
|
||||||
extern Readonly Space _g_space_nil;
|
extern Readonly Space _g_space_nil;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Nil helpers
|
//~ Nil helpers
|
||||||
|
|
||||||
Inline SpaceEntry *NilSpaceEntry(void)
|
Inline SpaceEntry *NilSpaceEntry(void)
|
||||||
@ -126,7 +126,7 @@ Inline Space *NilSpace(void)
|
|||||||
return &_g_space_nil;
|
return &_g_space_nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Space
|
//~ Space
|
||||||
|
|
||||||
Space *AcquireSpace(f32 cell_size, u32 num_bins_sqrt);
|
Space *AcquireSpace(f32 cell_size, u32 num_bins_sqrt);
|
||||||
@ -134,7 +134,7 @@ void ReleaseSpace(Space *space);
|
|||||||
void ResetSpace(Space *space);
|
void ResetSpace(Space *space);
|
||||||
Space *SpaceFromEntry(SpaceEntry *entry);
|
Space *SpaceFromEntry(SpaceEntry *entry);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Cell
|
//~ Cell
|
||||||
|
|
||||||
Vec2I32 SpaceCellCoordsFromWorldCoords(f32 cell_size, Vec2 world_pos);
|
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 AcquireSpaceCellNode(Vec2I32 cell_pos, SpaceEntry *entry);
|
||||||
void ReleaseSpaceCellNode(SpaceCellNode *n);
|
void ReleaseSpaceCellNode(SpaceCellNode *n);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Entry
|
//~ Entry
|
||||||
|
|
||||||
SpaceEntry *SpaceEntryFromHandle(Space *space, SpaceEntryHandle handle);
|
SpaceEntry *SpaceEntryFromHandle(Space *space, SpaceEntryHandle handle);
|
||||||
@ -151,7 +151,7 @@ SpaceEntry *AcquireSpaceEntry(Space *space, EntityId ent);
|
|||||||
void ReleaseSpaceEntry(SpaceEntry *entry);
|
void ReleaseSpaceEntry(SpaceEntry *entry);
|
||||||
void UpdateSpaceEntryAabb(SpaceEntry *entry, Aabb new_aabb);
|
void UpdateSpaceEntryAabb(SpaceEntry *entry, Aabb new_aabb);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Iter
|
//~ Iter
|
||||||
|
|
||||||
SpaceIter BeginSpaceIterAabb(Space *space, Aabb aabb);
|
SpaceIter BeginSpaceIterAabb(Space *space, Aabb aabb);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sim accel
|
//~ Sim accel
|
||||||
|
|
||||||
SimAccel AcquireSimAccel(void)
|
SimAccel AcquireSimAccel(void)
|
||||||
@ -28,7 +28,7 @@ void ResetSimAccel(Snapshot *ss, SimAccel *accel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Spawn test operations
|
//~ Spawn test operations
|
||||||
|
|
||||||
/* TODO: Remove this */
|
/* TODO: Remove this */
|
||||||
@ -408,7 +408,7 @@ void ClearLevelTest(SimStepCtx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tile test operations
|
//~ Tile test operations
|
||||||
|
|
||||||
MergesortCompareFuncDef(SortTileXCmp, arg_a, arg_b, _)
|
MergesortCompareFuncDef(SortTileXCmp, arg_a, arg_b, _)
|
||||||
@ -736,7 +736,7 @@ void GenerateTestWalls(Snapshot *world)
|
|||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ On collision
|
//~ On collision
|
||||||
|
|
||||||
CollisionCallbackFuncDef(OnEntityCollision, data, step_ctx)
|
CollisionCallbackFuncDef(OnEntityCollision, data, step_ctx)
|
||||||
@ -872,7 +872,7 @@ CollisionCallbackFuncDef(OnEntityCollision, data, step_ctx)
|
|||||||
return skip_solve;
|
return skip_solve;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Step
|
//~ Step
|
||||||
|
|
||||||
void StepSim(SimStepCtx *ctx)
|
void StepSim(SimStepCtx *ctx)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Acceleration structure types
|
//~ Acceleration structure types
|
||||||
|
|
||||||
/* Structure used to accelerate up entity lookup (rebuilt every step) */
|
/* Structure used to accelerate up entity lookup (rebuilt every step) */
|
||||||
@ -9,7 +9,7 @@ Struct(SimAccel)
|
|||||||
Space *space;
|
Space *space;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Step ctx
|
//~ Step ctx
|
||||||
|
|
||||||
Struct(SimStepCtx)
|
Struct(SimStepCtx)
|
||||||
@ -26,14 +26,14 @@ Struct(SimStepCtx)
|
|||||||
Client *publish_client; /* The publish client to write syncable state to (nil if skipping publish) */
|
Client *publish_client; /* The publish client to write syncable state to (nil if skipping publish) */
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Accel operations
|
//~ Accel operations
|
||||||
|
|
||||||
SimAccel AcquireSimAccel(void);
|
SimAccel AcquireSimAccel(void);
|
||||||
void ReleaseSimAccel(SimAccel *accel);
|
void ReleaseSimAccel(SimAccel *accel);
|
||||||
void ResetSimAccel(Snapshot *ss, SimAccel *accel);
|
void ResetSimAccel(Snapshot *ss, SimAccel *accel);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Spawn test operations
|
//~ Spawn test operations
|
||||||
|
|
||||||
Entity *SpawnTestSmg(Entity *parent);
|
Entity *SpawnTestSmg(Entity *parent);
|
||||||
@ -50,19 +50,19 @@ void SpawnTestEntities4(Entity *parent, Vec2 pos);
|
|||||||
void SpawnTestTile(Snapshot *world, Vec2 world_pos);
|
void SpawnTestTile(Snapshot *world, Vec2 world_pos);
|
||||||
void ClearLevelTest(SimStepCtx *ctx);
|
void ClearLevelTest(SimStepCtx *ctx);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Tile test operations
|
//~ Tile test operations
|
||||||
|
|
||||||
MergesortCompareFuncDef(SortTileXCmp, arg_a, arg_b, _);
|
MergesortCompareFuncDef(SortTileXCmp, arg_a, arg_b, _);
|
||||||
MergesortCompareFuncDef(SortTileYCmp, arg_a, arg_b, _);
|
MergesortCompareFuncDef(SortTileYCmp, arg_a, arg_b, _);
|
||||||
void GenerateTestWalls(Snapshot *world);
|
void GenerateTestWalls(Snapshot *world);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Collision response
|
//~ Collision response
|
||||||
|
|
||||||
CollisionCallbackFuncDef(OnEntityCollision, data, step_ctx);
|
CollisionCallbackFuncDef(OnEntityCollision, data, step_ctx);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Step
|
//~ Step
|
||||||
|
|
||||||
void StepSim(SimStepCtx *ctx);
|
void StepSim(SimStepCtx *ctx);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#if defined(ProfilingIsEnabled) && ProfilingIsEnabled == 1
|
#if defined(ProfilingIsEnabled) && ProfilingIsEnabled == 1
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Profiling enabled
|
//~ Profiling enabled
|
||||||
|
|
||||||
#ifndef __clang__
|
#ifndef __clang__
|
||||||
@ -60,7 +60,7 @@ enum __prof_plot_type {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Profiling disabled
|
//~ Profiling disabled
|
||||||
|
|
||||||
#define ProfilingCaptureFrame 0
|
#define ProfilingCaptureFrame 0
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void RT_Startup(void)
|
void RT_Startup(void)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Startup
|
//~ Startup
|
||||||
|
|
||||||
void RT_Startup(void);
|
void RT_Startup(void);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Serialize
|
//~ Serialize
|
||||||
|
|
||||||
String SETTINGS_StringFromWindowSettings(Arena *arena, const P_WindowSettings *settings)
|
String SETTINGS_StringFromWindowSettings(Arena *arena, const P_WindowSettings *settings)
|
||||||
@ -40,7 +40,7 @@ String SETTINGS_StringFromWindowSettings(Arena *arena, const P_WindowSettings *s
|
|||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Deserialize
|
//~ Deserialize
|
||||||
|
|
||||||
P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, String *error_out)
|
P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, String *error_out)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Load job
|
//~ Load job
|
||||||
|
|
||||||
JobDef(SND_Load, sig, UNUSED id)
|
JobDef(SND_Load, sig, UNUSED id)
|
||||||
@ -77,7 +77,7 @@ JobDef(SND_Load, sig, UNUSED id)
|
|||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Load sound
|
//~ Load sound
|
||||||
|
|
||||||
AC_Asset *SND_LoadAsset(Resource resource, SND_SoundFlag flags, b32 wait)
|
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);
|
Job *job = OpenJob(SND_Load, JobPool_Background);
|
||||||
SND_Load_Sig *sig = PushStruct(job->arena, SND_Load_Sig);
|
SND_Load_Sig *sig = PushStruct(job->arena, SND_Load_Sig);
|
||||||
|
job->sig = sig;
|
||||||
sig->resource = resource;
|
sig->resource = resource;
|
||||||
sig->asset = asset;
|
sig->asset = asset;
|
||||||
sig->flags = flags;
|
sig->flags = flags;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sound types
|
//~ Sound types
|
||||||
|
|
||||||
#define SND_SampleRate 48000
|
#define SND_SampleRate 48000
|
||||||
@ -16,7 +16,7 @@ Struct(SND_Sound)
|
|||||||
i16 *samples;
|
i16 *samples;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sound load operations
|
//~ Sound load operations
|
||||||
|
|
||||||
JobDecl(SND_Load, { SND_SoundFlag flags; AC_Asset *asset; Resource resource; });
|
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;
|
Readonly S_Sheet S_NilSheet = ZI;
|
||||||
S_SharedState S_shared_state = ZI;
|
S_SharedState S_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Load jobs
|
//~ Load jobs
|
||||||
|
|
||||||
JobDef(S_LoadTexture, sig, _)
|
JobDef(S_LoadTexture, sig, _)
|
||||||
@ -279,7 +279,7 @@ JobDef(S_LoadSheet, sig, _)
|
|||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Cache
|
//~ Cache
|
||||||
|
|
||||||
/* TODO: Per-fiber L1 cache */
|
/* TODO: Per-fiber L1 cache */
|
||||||
@ -346,7 +346,7 @@ S_Entry *S_FetchEntry(Resource resource, JobPool pool, S_FetchFlag flags)
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sprite data retrieval operations
|
//~ Sprite data retrieval operations
|
||||||
|
|
||||||
S_Texture *S_TextureFromResource(Resource resource)
|
S_Texture *S_TextureFromResource(Resource resource)
|
||||||
@ -385,7 +385,7 @@ S_Sheet *S_SheetFromResourceAsync(Resource resource)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sheet access operations
|
//~ Sheet access operations
|
||||||
|
|
||||||
S_Span S_SpanFromName(S_Sheet *sheet, String name)
|
S_Span S_SpanFromName(S_Sheet *sheet, String name)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Texture types
|
//~ Texture types
|
||||||
|
|
||||||
Struct(S_Texture)
|
Struct(S_Texture)
|
||||||
@ -12,7 +12,7 @@ Struct(S_Texture)
|
|||||||
|
|
||||||
extern Readonly S_Texture S_NilTexture;
|
extern Readonly S_Texture S_NilTexture;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sheet types
|
//~ Sheet types
|
||||||
|
|
||||||
Struct(S_Frame)
|
Struct(S_Frame)
|
||||||
@ -95,7 +95,7 @@ Struct(S_Sheet)
|
|||||||
|
|
||||||
extern Readonly S_Sheet S_NilSheet;
|
extern Readonly S_Sheet S_NilSheet;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Cache types
|
//~ Cache types
|
||||||
|
|
||||||
Struct(S_Entry)
|
Struct(S_Entry)
|
||||||
@ -120,7 +120,7 @@ Struct(S_EntryBin)
|
|||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ State types
|
||||||
|
|
||||||
#define S_EntryBinsCount 1024
|
#define S_EntryBinsCount 1024
|
||||||
@ -130,13 +130,13 @@ Struct(S_SharedState)
|
|||||||
S_EntryBin entry_bins[S_EntryBinsCount];
|
S_EntryBin entry_bins[S_EntryBinsCount];
|
||||||
} extern S_shared_state;
|
} extern S_shared_state;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Load jobs
|
//~ Load jobs
|
||||||
|
|
||||||
JobDecl(S_LoadTexture, { S_Entry *entry; });
|
JobDecl(S_LoadTexture, { S_Entry *entry; });
|
||||||
JobDecl(S_LoadSheet, { S_Entry *entry; });
|
JobDecl(S_LoadSheet, { S_Entry *entry; });
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Cache operations
|
//~ Cache operations
|
||||||
|
|
||||||
Enum(S_FetchFlag)
|
Enum(S_FetchFlag)
|
||||||
@ -148,7 +148,7 @@ Enum(S_FetchFlag)
|
|||||||
|
|
||||||
S_Entry *S_FetchEntry(Resource resource, JobPool pool, S_FetchFlag flags);
|
S_Entry *S_FetchEntry(Resource resource, JobPool pool, S_FetchFlag flags);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sprite data retrieval operations
|
//~ Sprite data retrieval operations
|
||||||
|
|
||||||
S_Texture *S_TextureFromResource(Resource resource);
|
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_SheetFromResource(Resource resource);
|
||||||
S_Sheet *S_SheetFromResourceAsync(Resource resource);
|
S_Sheet *S_SheetFromResourceAsync(Resource resource);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Sheet access operations
|
//~ Sheet access operations
|
||||||
|
|
||||||
S_Span S_SpanFromName(S_Sheet *sheet, String name);
|
S_Span S_SpanFromName(S_Sheet *sheet, String name);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Archive types
|
//~ Archive types
|
||||||
|
|
||||||
#define TAR_ArchiveLookupTableCapacityFactor 2.0
|
#define TAR_ArchiveLookupTableCapacityFactor 2.0
|
||||||
@ -20,7 +20,7 @@ Struct(TAR_Archive)
|
|||||||
TAR_Entry *head;
|
TAR_Entry *head;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Header types
|
//~ Header types
|
||||||
|
|
||||||
Enum(TAR_FileKind)
|
Enum(TAR_FileKind)
|
||||||
@ -63,7 +63,7 @@ Packed(Struct(TAR_Header)
|
|||||||
u8 padding[12];
|
u8 padding[12];
|
||||||
});
|
});
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Archive operations
|
//~ Archive operations
|
||||||
|
|
||||||
u64 TAR_U64FromOctString(String str);
|
u64 TAR_U64FromOctString(String str);
|
||||||
|
|||||||
@ -8,7 +8,7 @@ Struct(TTF_Glyph)
|
|||||||
Rect atlas_rect;
|
Rect atlas_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
Struct(TTF_Result)
|
Struct(TTF_Decoded)
|
||||||
{
|
{
|
||||||
TTF_Glyph *glyphs;
|
TTF_Glyph *glyphs;
|
||||||
u16 glyphs_count;
|
u16 glyphs_count;
|
||||||
@ -20,4 +20,4 @@ Struct(TTF_Result)
|
|||||||
|
|
||||||
void TTF_Startup(void);
|
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
|
//- DirectWrite impl
|
||||||
@DefaultWindowsImpl ttf_dwrite
|
@DefaultWindowsImpl ttf_dwrite
|
||||||
|
|
||||||
|
//- Startup
|
||||||
|
@Startup TTF_Startup
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
TTF_DW_SharedState TTF_DW_shared_state = ZI;
|
TTF_DW_SharedState TTF_DW_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Startup
|
//~ @hookdef Startup
|
||||||
|
|
||||||
/* Call this during font system startup */
|
/* Call this during font system startup */
|
||||||
@ -35,10 +35,10 @@ void TTF_Startup(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookdef Decode
|
//~ @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;
|
__prof;
|
||||||
TTF_DW_SharedState *g = &TTF_DW_shared_state;
|
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);
|
IDWriteFactory5_Release(factory);
|
||||||
|
|
||||||
/* Return */
|
/* Return */
|
||||||
TTF_Result result = ZI;
|
TTF_Decoded result = ZI;
|
||||||
result.glyphs = glyphs;
|
result.glyphs = glyphs;
|
||||||
result.glyphs_count = glyph_count;
|
result.glyphs_count = glyph_count;
|
||||||
result.cache_indices = cache_indices;
|
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