base_memory refactor
This commit is contained in:
parent
6776a15141
commit
d2e1be0df9
@ -18,7 +18,7 @@ internal u32 peek_bits(struct huff_bb *bb, u32 nbits)
|
||||
u64 nbytes = (nbits + bit_index + 7) >> 3;
|
||||
|
||||
u64 val64 = 0;
|
||||
MEMCPY(&val64, &bb->data[cur_byte], nbytes);
|
||||
CopyBytes(&val64, &bb->data[cur_byte], nbytes);
|
||||
u32 val32 = (u32)(val64 >> bit_index);
|
||||
val32 &= U32Max >> (32 - nbits);
|
||||
|
||||
@ -179,7 +179,7 @@ internal struct huffman huffman_init(Arena *arena, u32 max_code_bits, u32 *bl_co
|
||||
struct huffman res = ZI;
|
||||
res.max_code_bits = max_code_bits;
|
||||
res.entries_count = (1 << max_code_bits);
|
||||
res.entries = PushArrayNoZero(arena, struct huffman_entry, res.entries_count);
|
||||
res.entries = PushStructsNoZero(arena, struct huffman_entry, res.entries_count);
|
||||
|
||||
u32 code_length_hist[HUFFMAN_BIT_COUNT] = ZI;
|
||||
for (u32 i = 0; i < bl_counts_count; ++i) {
|
||||
@ -581,7 +581,7 @@ Ase_DecodedImage ase_decode_image(Arena *arena, String encoded)
|
||||
res.width = image_width;
|
||||
res.height = image_height;
|
||||
/* TODO: Optimize this. Naive memset(0) is bloating the decode time for large images. */
|
||||
res.pixels = PushArray(arena, u32, image_width * image_height);
|
||||
res.pixels = PushStructs(arena, u32, image_width * image_height);
|
||||
|
||||
u32 num_layers = 0;
|
||||
struct layer *layer_head = 0;
|
||||
@ -641,7 +641,7 @@ Ase_DecodedImage ase_decode_image(Arena *arena, String encoded)
|
||||
BB_SeekBytes(&br, sizeof(u8) * 3);
|
||||
|
||||
u16 str_len = BB_ReadUBits(&br, 16);
|
||||
layer->name = (String) { str_len, PushArrayNoZero(scratch.arena, u8, str_len) };
|
||||
layer->name = (String) { str_len, PushStructsNoZero(scratch.arena, u8, str_len) };
|
||||
BB_ReadBytes(&br, layer->name);
|
||||
|
||||
if (layer->type == 2) {
|
||||
@ -685,7 +685,7 @@ Ase_DecodedImage ase_decode_image(Arena *arena, String encoded)
|
||||
cel->width = BB_ReadUBits(&br, 16);
|
||||
cel->height = BB_ReadUBits(&br, 16);
|
||||
|
||||
cel->pixels = PushArrayNoZero(scratch.arena, u32, cel->width * cel->height);
|
||||
cel->pixels = PushStructsNoZero(scratch.arena, u32, cel->width * cel->height);
|
||||
u8 *huffman_encoded = BB_ReadBytesRaw(&br, chunk_end_pos - BB_GetCurrentReaderByte(&br));
|
||||
if (huffman_encoded) {
|
||||
inflate((u8 *)cel->pixels, huffman_encoded);
|
||||
@ -709,13 +709,13 @@ Ase_DecodedImage ase_decode_image(Arena *arena, String encoded)
|
||||
}
|
||||
|
||||
/* Create ordered layers array */
|
||||
struct layer **layers_ordered = PushArrayNoZero(scratch.arena, struct layer *, num_layers);
|
||||
struct layer **layers_ordered = PushStructsNoZero(scratch.arena, struct layer *, num_layers);
|
||||
for (struct layer *layer = layer_head; layer; layer = layer->next) {
|
||||
layers_ordered[layer->index] = layer;
|
||||
}
|
||||
|
||||
/* Link cels */
|
||||
struct cel **cels_ordered = PushArrayNoZero(scratch.arena, struct cel *, num_frames * num_layers);
|
||||
struct cel **cels_ordered = PushStructsNoZero(scratch.arena, struct cel *, num_frames * num_layers);
|
||||
for (struct cel *cel = cel_head; cel; cel = cel->next) {
|
||||
cels_ordered[(cel->frame_index * num_layers) + cel->layer_index] = cel;
|
||||
if (cel->type == CEL_TYPE_LINKED) {
|
||||
@ -894,7 +894,7 @@ Ase_DecodedSheet ase_decode_sheet(Arena *arena, String encoded)
|
||||
BB_SeekBytes(&br, 13);
|
||||
|
||||
u16 str_len = BB_ReadUBits(&br, 16);
|
||||
span->name = (String) { str_len, PushArrayNoZero(arena, u8, str_len) };
|
||||
span->name = (String) { str_len, PushStructsNoZero(arena, u8, str_len) };
|
||||
BB_ReadBytes(&br, span->name);
|
||||
|
||||
++num_spans;
|
||||
@ -914,7 +914,7 @@ Ase_DecodedSheet ase_decode_sheet(Arena *arena, String encoded)
|
||||
BB_SeekBytes(&br, 4);
|
||||
|
||||
u16 str_len = BB_ReadUBits(&br, 16);
|
||||
slice_key->name = (String) { str_len, PushArrayNoZero(arena, u8, str_len) };
|
||||
slice_key->name = (String) { str_len, PushStructsNoZero(arena, u8, str_len) };
|
||||
BB_ReadBytes(&br, slice_key->name);
|
||||
|
||||
for (u32 k = 0; k < num_slices; ++k) {
|
||||
|
||||
@ -41,7 +41,7 @@ internal void refresh_dbg_table(void)
|
||||
{
|
||||
#if RtcIsEnabled
|
||||
P_Lock lock = P_LockE(&G.dbg_table_mutex);
|
||||
MEMZERO_ARRAY(G.dbg_table);
|
||||
ZeroArray(G.dbg_table);
|
||||
G.dbg_table_count = 0;
|
||||
for (u64 i = 0; i < countof(G.lookup); ++i) {
|
||||
AC_Asset *asset = &G.lookup[i];
|
||||
@ -123,7 +123,7 @@ AC_Asset *asset_cache_touch(String key, u64 hash, b32 *is_first_touch)
|
||||
}
|
||||
String key_stored = ZI;
|
||||
{
|
||||
/* Copy key to store */
|
||||
/* CopyStruct key to store */
|
||||
AC_Store store = asset_cache_store_open();
|
||||
key_stored = string_copy(store.arena, key);
|
||||
asset_cache_store_close(&store);
|
||||
|
||||
@ -13,7 +13,7 @@ Arena *AllocArena(u64 reserve)
|
||||
reserve += ArenaBlockSize - block_remainder;
|
||||
}
|
||||
|
||||
u8 *base = memory_reserve(reserve);
|
||||
u8 *base = ReserveMemory(reserve);
|
||||
if (!base)
|
||||
{
|
||||
/* Hard fail on memory reserve failure for now */
|
||||
@ -25,7 +25,7 @@ Arena *AllocArena(u64 reserve)
|
||||
AddGstat(GSTAT_MEMORY_RESERVED, reserve);
|
||||
|
||||
/* Commit initial block */
|
||||
base = memory_commit(base, ArenaBlockSize);
|
||||
base = CommitMemory(base, ArenaBlockSize);
|
||||
if (!base)
|
||||
{
|
||||
/* Hard fail on commit failure */
|
||||
@ -45,7 +45,7 @@ Arena *AllocArena(u64 reserve)
|
||||
|
||||
/* Create & return arena header at beginning of block */
|
||||
Arena *arena = (Arena *)base;
|
||||
MEMZERO_STRUCT(arena);
|
||||
ZeroStruct(arena);
|
||||
arena->committed = ArenaBlockSize - ArenaHeaderSize;
|
||||
arena->reserved = reserved;
|
||||
return arena;
|
||||
@ -59,7 +59,7 @@ void ReleaseArena(Arena *arena)
|
||||
AddGstat(GSTAT_MEMORY_COMMITTED, -(i64)(arena->committed - ArenaHeaderSize));
|
||||
AddGstat(GSTAT_MEMORY_RESERVED, -(i64)(arena->reserved));
|
||||
AddGstat(GSTAT_NUM_ARENAS, -1);
|
||||
memory_release(arena);
|
||||
ReleaseMemory(arena);
|
||||
}
|
||||
|
||||
/* NOTE: Application will exit if arena fails to commit memory */
|
||||
@ -93,7 +93,7 @@ void *PushBytesNoZero(Arena *arena, u64 size, u64 align)
|
||||
(*(volatile int *)0) = 0;
|
||||
}
|
||||
void *commit_address = base + arena->committed;
|
||||
if (!memory_commit(commit_address, commit_bytes))
|
||||
if (!CommitMemory(commit_address, commit_bytes))
|
||||
{
|
||||
/* Hard fail on memory allocation failure for now */
|
||||
/* FIXME: Enable this */
|
||||
@ -127,7 +127,7 @@ void CopyArena(Arena *dst, Arena *src)
|
||||
u64 data_size = src->pos;
|
||||
u8 *data_src = ArenaBase(src);
|
||||
u8 *data_dst = PushBytesNoZero(dst, data_size, 1);
|
||||
MEMCPY(data_dst, data_src, data_size);
|
||||
CopyBytes(data_dst, data_src, data_size);
|
||||
}
|
||||
|
||||
void ShrinkArena(Arena *arena)
|
||||
@ -142,12 +142,12 @@ void SetArenaReadonly(Arena *arena)
|
||||
#if RtcIsEnabled
|
||||
arena->readonly = 1;
|
||||
#endif
|
||||
memory_set_committed_readonly(arena, arena->committed + ArenaHeaderSize);
|
||||
SetMemoryReadonly(arena, arena->committed + ArenaHeaderSize);
|
||||
}
|
||||
|
||||
void SetArenaReadWrite(Arena *arena)
|
||||
{
|
||||
memory_set_committed_readwrite(arena, arena->committed + ArenaHeaderSize);
|
||||
SetMemoryReadWrite(arena, arena->committed + ArenaHeaderSize);
|
||||
#if RtcIsEnabled
|
||||
arena->readonly = 0;
|
||||
#endif
|
||||
|
||||
@ -49,11 +49,11 @@ extern SharedScratchCtx shared_scratch_ctx;
|
||||
#define PushStruct(a, type) ((type *)PushBytes((a), sizeof(type), alignof(type)))
|
||||
#define PushStructNoZero(a, type) ((type *)PushBytesNoZero((a), sizeof(type), alignof(type)))
|
||||
|
||||
#define PushArray(a, type, n) ((type *)PushBytes((a), (sizeof(type) * (n)), alignof(type)))
|
||||
#define PushArrayNoZero(a, type, n) ((type *)PushBytesNoZero((a), (sizeof(type) * (n)), alignof(type)))
|
||||
#define PushStructs(a, type, n) ((type *)PushBytes((a), (sizeof(type) * (n)), alignof(type)))
|
||||
#define PushStructsNoZero(a, type, n) ((type *)PushBytesNoZero((a), (sizeof(type) * (n)), alignof(type)))
|
||||
|
||||
#define PopStruct(a, type, dst) PopBytes((a), sizeof(type), dst)
|
||||
#define PopArray(a, type, n, dst) PopBytes((a), sizeof(type) * (n), dst)
|
||||
#define PopStructs(a, type, n, dst) PopBytes((a), sizeof(type) * (n), dst)
|
||||
|
||||
/* Returns a pointer to where the next allocation would be (at alignment of type).
|
||||
* Equivalent to PushStruct but without actually allocating anything or modifying the arena. */
|
||||
@ -64,7 +64,7 @@ void *PushBytesNoZero(Arena *arena, u64 size, u64 align);
|
||||
Inline void *PushBytes(Arena *arena, u64 size, u64 align)
|
||||
{
|
||||
void *p = PushBytesNoZero(arena, size, align);
|
||||
MEMZERO(p, size);
|
||||
ZeroBytes(p, size);
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ Inline void PopBytes(Arena *arena, u64 size, void *copy_dst)
|
||||
|
||||
u64 new_pos = arena->pos - size;
|
||||
void *src = (void *)(ArenaBase(arena) + new_pos);
|
||||
MEMCPY(copy_dst, src, size);
|
||||
CopyBytes(copy_dst, src, size);
|
||||
|
||||
AsanPoison(ArenaBase(arena) + new_pos, arena->pos - new_pos);
|
||||
arena->pos = new_pos;
|
||||
@ -122,7 +122,7 @@ Inline void *AlignArena(Arena *arena, u64 align)
|
||||
aligned_start_pos -= aligned_start_pos % align;
|
||||
u64 align_bytes = aligned_start_pos - (u64)arena->pos;
|
||||
if (align_bytes > 0) {
|
||||
return (void *)PushArrayNoZero(arena, u8, align_bytes);
|
||||
return (void *)PushStructsNoZero(arena, u8, align_bytes);
|
||||
} else {
|
||||
return (void *)(ArenaBase(arena) + arena->pos);
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ BuddyCtx *AllocBuddyCtx(u64 reserve)
|
||||
ctx->data_arena = AllocArena(reserve);
|
||||
|
||||
/* TODO: Minimum block size */
|
||||
ctx->levels = PushArray(ctx->meta_arena, BuddyLevel, 64);
|
||||
ctx->levels = PushStructs(ctx->meta_arena, BuddyLevel, 64);
|
||||
for (u64 i = 0; i < 64; ++i)
|
||||
{
|
||||
BuddyLevel *level = &ctx->levels[i];
|
||||
@ -100,7 +100,7 @@ BuddyBlock *PushBuddyBlock(BuddyCtx *ctx)
|
||||
{
|
||||
block = PushStructNoZero(ctx->meta_arena, BuddyBlock);
|
||||
}
|
||||
MEMZERO_STRUCT(block);
|
||||
ZeroStruct(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ BuddyBlock *GetUnusedBuddyBlock(BuddyCtx *ctx, BuddyLevel *level)
|
||||
i64 level_commit_diff = (level->size * 2) - arena->pos;
|
||||
if (level_commit_diff > 0)
|
||||
{
|
||||
PushArrayNoZero(arena, u8, level_commit_diff);
|
||||
PushStructsNoZero(arena, u8, level_commit_diff);
|
||||
Assert(arena->pos == (level->size * 2));
|
||||
}
|
||||
|
||||
|
||||
@ -155,7 +155,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
||||
# define CppCompatInitListType(type) (type)
|
||||
#endif
|
||||
|
||||
//- Zero initialization macro
|
||||
//- ZeroStruct initialization macro
|
||||
#if LanguageIsC
|
||||
# define ZI { 0 }
|
||||
#else
|
||||
@ -280,6 +280,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
||||
//- countof
|
||||
#define countof(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
//- IsArray
|
||||
#define IsIndexable(a) (sizeof(a[0]))
|
||||
#define IsArray(a) (IsIndexable(a) && (((void *)&a) == ((void *)a)))
|
||||
|
||||
|
||||
@ -1,9 +1,60 @@
|
||||
/* ========================== *
|
||||
* Memory operations
|
||||
* ========================== */
|
||||
|
||||
////////////////////////////////
|
||||
//~ Memory allocation
|
||||
|
||||
#if PlatformIsWindows
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define UNICODE
|
||||
#include <Windows.h>
|
||||
|
||||
//- Reserve
|
||||
void *ReserveMemory(u64 size)
|
||||
{
|
||||
void *ptr = VirtualAlloc(0, size, MEM_RESERVE, PAGE_NOACCESS);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void ReleaseMemory(void *address)
|
||||
{
|
||||
VirtualFree(address, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
//- Commit
|
||||
void *CommitMemory(void *address, u64 size)
|
||||
{
|
||||
void *ptr = VirtualAlloc(address, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void DecommitMemory(void *address, u64 size)
|
||||
{
|
||||
VirtualFree(address, size, MEM_DECOMMIT);
|
||||
}
|
||||
|
||||
//- Protect
|
||||
void SetMemoryReadonly(void *address, u64 size)
|
||||
{
|
||||
DWORD old;
|
||||
VirtualProtect(address, size, PAGE_READONLY, &old);
|
||||
}
|
||||
|
||||
void SetMemoryReadWrite(void *address, u64 size)
|
||||
{
|
||||
DWORD old;
|
||||
VirtualProtect(address, size, PAGE_READWRITE, &old);
|
||||
}
|
||||
|
||||
#else
|
||||
# error Memory allocation not implemented for this platform
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ Crtlib memory.h stubs
|
||||
|
||||
#if !CrtlibIsEnabled
|
||||
|
||||
//- memcpy
|
||||
__attribute((section(".text.memcpy")))
|
||||
void *memcpy(void *__restrict dst, const void *__restrict src, u64 n)
|
||||
{
|
||||
@ -13,6 +64,7 @@ void *memcpy(void *__restrict dst, const void *__restrict src, u64 n)
|
||||
return dst;
|
||||
}
|
||||
|
||||
//- memset
|
||||
__attribute((section(".text.memset")))
|
||||
void *memset(void *dst, i32 c, u64 n)
|
||||
{
|
||||
@ -22,6 +74,7 @@ void *memset(void *dst, i32 c, u64 n)
|
||||
return dst;
|
||||
}
|
||||
|
||||
//- memcmp
|
||||
__attribute((section(".text.memcmp")))
|
||||
i32 memcmp(const void *p1, const void *p2, u64 n)
|
||||
{
|
||||
@ -36,51 +89,3 @@ i32 memcmp(const void *p1, const void *p2, u64 n)
|
||||
}
|
||||
|
||||
#endif /* !CrtlibIsEnabled */
|
||||
|
||||
/* ========================== *
|
||||
* Memory allocation
|
||||
* ========================== */
|
||||
|
||||
#if PlatformIsWindows
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define UNICODE
|
||||
#include <Windows.h>
|
||||
|
||||
void *memory_reserve(u64 size)
|
||||
{
|
||||
void *ptr = VirtualAlloc(0, size, MEM_RESERVE, PAGE_NOACCESS);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void memory_release(void *address)
|
||||
{
|
||||
VirtualFree(address, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
void *memory_commit(void *address, u64 size)
|
||||
{
|
||||
void *ptr = VirtualAlloc(address, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void memory_decommit(void *address, u64 size)
|
||||
{
|
||||
VirtualFree(address, size, MEM_DECOMMIT);
|
||||
}
|
||||
|
||||
void memory_set_committed_readonly(void *address, u64 size)
|
||||
{
|
||||
DWORD old;
|
||||
VirtualProtect(address, size, PAGE_READONLY, &old);
|
||||
}
|
||||
|
||||
void memory_set_committed_readwrite(void *address, u64 size)
|
||||
{
|
||||
DWORD old;
|
||||
VirtualProtect(address, size, PAGE_READWRITE, &old);
|
||||
}
|
||||
|
||||
#else
|
||||
# error Memory allocation not implemented for this platform
|
||||
#endif
|
||||
|
||||
@ -1,21 +1,36 @@
|
||||
/* ========================== *
|
||||
* Memory operations
|
||||
* ========================== */
|
||||
////////////////////////////////
|
||||
//~ Memory allocation
|
||||
|
||||
#define MEMZERO_STRUCT(ptr) MEMZERO((ptr), sizeof(*(ptr)))
|
||||
#define MEMZERO_ARRAY(a) MEMZERO((a), sizeof((a)))
|
||||
#define MEMZERO(ptr, count) MEMSET((ptr), 0, (count))
|
||||
//- Reserve
|
||||
void *ReserveMemory(u64 size);
|
||||
void ReleaseMemory(void *address);
|
||||
|
||||
#define MEMCPY_STRUCT(ptr_dst, ptr_src) MEMCPY((ptr_dst), (ptr_src), sizeof(*(ptr_dst)))
|
||||
#define MEMCPY(dst, src, count) memcpy((dst), (src), (count))
|
||||
//- Commit
|
||||
void *CommitMemory(void *address, u64 size);
|
||||
void DecommitMemory(void *address, u64 size);
|
||||
|
||||
#define MEMEQ_STRUCT(p1, p2) MEMEQ((p1), (p2), sizeof(*p1))
|
||||
#define MEMEQ(p1, p2, n) (MEMCMP((p1), (p2), (n)) == 0)
|
||||
//- Protect
|
||||
void SetMemoryReadonly(void *address, u64 size);
|
||||
void SetMemoryReadWrite(void *address, u64 size);
|
||||
|
||||
#define MEMCMP(p1, p2, n) memcmp((p1), (p2), (n))
|
||||
////////////////////////////////
|
||||
//~ Memory operations
|
||||
|
||||
#define MEMSET(ptr, val, count) memset((ptr), (val), (count))
|
||||
#define ZeroStruct(ptr) ZeroBytes((ptr), sizeof(*(ptr)))
|
||||
#define ZeroArray(a) Assert(IsArray(a)); ZeroBytes((a), sizeof((a)))
|
||||
#define ZeroBytes(ptr, count) SetBytes((ptr), 0, (count))
|
||||
|
||||
#define CopyStruct(ptr_dst, ptr_src) CopyBytes((ptr_dst), (ptr_src), sizeof(*(ptr_dst)))
|
||||
#define CopyBytes(dst, src, count) memcpy((dst), (src), (count))
|
||||
|
||||
#define EqStruct(p1, p2) EqBytes((p1), (p2), sizeof(*p1))
|
||||
#define EqBytes(p1, p2, n) (CmpBytes((p1), (p2), (n)) == 0)
|
||||
|
||||
#define CmpBytes(p1, p2, n) memcmp((p1), (p2), (n))
|
||||
|
||||
#define SetBytes(ptr, val, count) memset((ptr), (val), (count))
|
||||
|
||||
//- Crtlib stubs
|
||||
#if CrtlibIsEnabled
|
||||
# include <memory.h>
|
||||
#else
|
||||
@ -23,14 +38,3 @@ void *memcpy(void *__restrict dst, const void *__restrict src, u64 n);
|
||||
void *memset(void *dst, i32 c, u64 n);
|
||||
i32 memcmp(const void *p1, const void *p2, u64 n);
|
||||
#endif
|
||||
|
||||
/* ========================== *
|
||||
* Memory allocation
|
||||
* ========================== */
|
||||
|
||||
void *memory_reserve(u64 size);
|
||||
void memory_release(void *address);
|
||||
void *memory_commit(void *address, u64 size);
|
||||
void memory_decommit(void *address, u64 size);
|
||||
void memory_set_committed_readonly(void *address, u64 size);
|
||||
void memory_set_committed_readwrite(void *address, u64 size);
|
||||
|
||||
@ -48,7 +48,7 @@ String string_from_uint(Arena *arena, u64 n, u64 base, u64 zfill)
|
||||
}
|
||||
|
||||
/* Reverse text into final string */
|
||||
u8 *final_text = PushArrayNoZero(arena, u8, len);
|
||||
u8 *final_text = PushStructsNoZero(arena, u8, len);
|
||||
for (u64 i = 0; i < len; ++i) {
|
||||
final_text[i] = backwards_text[len - i - 1];
|
||||
}
|
||||
@ -127,7 +127,7 @@ String string_from_float(Arena *arena, f64 f, u32 precision)
|
||||
} while (part_whole > 0);
|
||||
|
||||
/* Reverse text into final string */
|
||||
PushArrayNoZero(arena, u8, backwards_text_len);
|
||||
PushStructsNoZero(arena, u8, backwards_text_len);
|
||||
for (u64 i = backwards_text_len; i-- > 0;) {
|
||||
final_text[final_len++] = backwards_text[i];
|
||||
}
|
||||
@ -181,9 +181,9 @@ String string_copy(Arena *arena, String src)
|
||||
{
|
||||
String str = {
|
||||
.len = src.len,
|
||||
.text = PushArrayNoZero(arena, u8, src.len)
|
||||
.text = PushStructsNoZero(arena, u8, src.len)
|
||||
};
|
||||
MEMCPY(str.text, src.text, src.len);
|
||||
CopyBytes(str.text, src.text, src.len);
|
||||
return str;
|
||||
}
|
||||
|
||||
@ -192,16 +192,16 @@ String string_copy_to_string(String dst, String src)
|
||||
String res = ZI;
|
||||
res.len = MinU64(dst.len, src.len);
|
||||
res.text = dst.text;
|
||||
MEMCPY(res.text, src.text, res.len);
|
||||
CopyBytes(res.text, src.text, res.len);
|
||||
return res;
|
||||
}
|
||||
|
||||
String string_repeat(Arena *arena, String src, u64 count)
|
||||
{
|
||||
u64 final_len = src.len * count;
|
||||
u8 *final_text = PushArrayNoZero(arena, u8, final_len);
|
||||
u8 *final_text = PushStructsNoZero(arena, u8, final_len);
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
MEMCPY(final_text + (src.len * i), src.text, src.len);
|
||||
CopyBytes(final_text + (src.len * i), src.text, src.len);
|
||||
}
|
||||
return (String) {
|
||||
.text = final_text,
|
||||
@ -213,9 +213,9 @@ String string_cat(Arena *arena, String str1, String str2)
|
||||
{
|
||||
String new_str = ZI;
|
||||
new_str.len = str1.len + str2.len;
|
||||
new_str.text = PushArrayNoZero(arena, u8, new_str.len);
|
||||
MEMCPY(new_str.text, str1.text, str1.len);
|
||||
MEMCPY(new_str.text + str1.len, str2.text, str2.len);
|
||||
new_str.text = PushStructsNoZero(arena, u8, new_str.len);
|
||||
CopyBytes(new_str.text, str1.text, str1.len);
|
||||
CopyBytes(new_str.text + str1.len, str2.text, str2.len);
|
||||
return new_str;
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ String string_indent(Arena *arena, String str, u32 indent)
|
||||
String string_lower(Arena *arena, String str)
|
||||
{
|
||||
String res = ZI;
|
||||
res.text = PushArrayNoZero(arena, u8, str.len);
|
||||
res.text = PushStructsNoZero(arena, u8, str.len);
|
||||
res.len = str.len;
|
||||
|
||||
for (u64 i = 0; i < str.len; ++i) {
|
||||
@ -576,8 +576,8 @@ String string_from_string16(Arena *arena, String16 str16)
|
||||
Utf16DecodeResult decoded = uni_decode_utf16(str16_remaining);
|
||||
Utf8EncodeResult encoded = uni_encode_utf8(decoded.codepoint);
|
||||
|
||||
u8 *dst = PushArrayNoZero(arena, u8, encoded.count8);
|
||||
MEMCPY(dst, encoded.chars8, encoded.count8);
|
||||
u8 *dst = PushStructsNoZero(arena, u8, encoded.count8);
|
||||
CopyBytes(dst, encoded.chars8, encoded.count8);
|
||||
|
||||
pos16 += decoded.advance16;
|
||||
res.len += encoded.count8;
|
||||
@ -600,8 +600,8 @@ String string_from_string32(Arena *arena, String32 str32)
|
||||
Utf32DecodeResult decoded = uni_decode_utf32(str32_remaining);
|
||||
Utf8EncodeResult encoded = uni_encode_utf8(decoded.codepoint);
|
||||
|
||||
u8 *dst = PushArrayNoZero(arena, u8, encoded.count8);
|
||||
MEMCPY(dst, &encoded.chars8, encoded.count8);
|
||||
u8 *dst = PushStructsNoZero(arena, u8, encoded.count8);
|
||||
CopyBytes(dst, &encoded.chars8, encoded.count8);
|
||||
|
||||
pos32 += 1;
|
||||
res.len += encoded.count8;
|
||||
@ -624,8 +624,8 @@ String16 string16_from_string(Arena *arena, String str8)
|
||||
Utf8DecodeResult decoded = uni_decode_utf8(str8_remaining);
|
||||
Utf16EncodeResult encoded = uni_encode_utf16(decoded.codepoint);
|
||||
|
||||
u16 *dst = PushArrayNoZero(arena, u16, encoded.count16);
|
||||
MEMCPY(dst, encoded.chars16, (encoded.count16 << 1));
|
||||
u16 *dst = PushStructsNoZero(arena, u16, encoded.count16);
|
||||
CopyBytes(dst, encoded.chars16, (encoded.count16 << 1));
|
||||
|
||||
pos8 += decoded.advance8;
|
||||
res.len += encoded.count16;
|
||||
@ -690,8 +690,8 @@ u64 cstr_len(char *cstr, u64 limit)
|
||||
|
||||
char *cstr_from_string(Arena *arena, String src)
|
||||
{
|
||||
u8 *text = PushArrayNoZero(arena, u8, src.len + 1);
|
||||
MEMCPY(text, src.text, src.len);
|
||||
u8 *text = PushStructsNoZero(arena, u8, src.len + 1);
|
||||
CopyBytes(text, src.text, src.len);
|
||||
text[src.len] = 0;
|
||||
return (char *)text;
|
||||
}
|
||||
@ -700,7 +700,7 @@ char *cstr_buff_from_string(String dst_buff, String src)
|
||||
{
|
||||
if (dst_buff.len > 0) {
|
||||
u64 len = MinU64(src.len, dst_buff.len - 1);
|
||||
MEMCPY(dst_buff.text, src.text, len);
|
||||
CopyBytes(dst_buff.text, src.text, len);
|
||||
dst_buff.text[len] = 0;
|
||||
}
|
||||
return (char *)dst_buff.text;
|
||||
@ -763,7 +763,7 @@ wchar_t *wstr_from_string(Arena *arena, String src)
|
||||
|
||||
wchar_t *wstr_from_string16(Arena *arena, String16 src)
|
||||
{
|
||||
u16 *text = PushArrayNoZero(arena, u16, src.len + 1);
|
||||
u16 *text = PushStructsNoZero(arena, u16, src.len + 1);
|
||||
text[src.len] = 0;
|
||||
return (wchar_t *)text;
|
||||
}
|
||||
|
||||
@ -43,26 +43,26 @@ Inline void merge_sort_internal(u8 *left, u8 *right, u8 *items, u64 left_count,
|
||||
u8 *right_item = right + (r * item_size);
|
||||
++i;
|
||||
if (callback(left_item, right_item, udata) > 0) {
|
||||
MEMCPY(dst, left_item, item_size);
|
||||
CopyBytes(dst, left_item, item_size);
|
||||
++l;
|
||||
} else {
|
||||
MEMCPY(dst, right_item, item_size);
|
||||
CopyBytes(dst, right_item, item_size);
|
||||
++r;
|
||||
}
|
||||
}
|
||||
/* Copy remaining */
|
||||
/* CopyStruct remaining */
|
||||
if (l != left_count) {
|
||||
u64 remaining_count = left_count - l;
|
||||
u64 remaining_bytes = remaining_count * item_size;
|
||||
u8 *dst = items + (i * item_size);
|
||||
u8 *src = left + (l * item_size);
|
||||
MEMCPY(dst, src, remaining_bytes);
|
||||
CopyBytes(dst, src, remaining_bytes);
|
||||
} else if (r != right_count) {
|
||||
u64 remaining_count = right_count - r;
|
||||
u64 remaining_bytes = remaining_count * item_size;
|
||||
u8 *dst = items + (i * item_size);
|
||||
u8 *src = right + (r * item_size);
|
||||
MEMCPY(dst, src, remaining_bytes);
|
||||
CopyBytes(dst, src, remaining_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,10 +76,10 @@ Inline void merge_sort(void *items, u64 item_count, u64 item_size, sort_compare_
|
||||
u64 left_size = left_count * item_size;
|
||||
u64 right_size = right_count * item_size;
|
||||
|
||||
u8 *left = PushArrayNoZero(scratch.arena, u8, left_size);
|
||||
u8 *right = PushArrayNoZero(scratch.arena, u8, right_size);
|
||||
MEMCPY(left, items, left_size);
|
||||
MEMCPY(right, (u8 *)items + left_size, right_size);
|
||||
u8 *left = PushStructsNoZero(scratch.arena, u8, left_size);
|
||||
u8 *right = PushStructsNoZero(scratch.arena, u8, right_size);
|
||||
CopyBytes(left, items, left_size);
|
||||
CopyBytes(right, (u8 *)items + left_size, right_size);
|
||||
|
||||
merge_sort(left, left_count, item_size, callback, udata);
|
||||
merge_sort(right, right_count, item_size, callback, udata);
|
||||
@ -121,13 +121,13 @@ Inline Dict *dict_init(Arena *arena, u64 bins_count)
|
||||
__prof;
|
||||
Dict *dict = PushStruct(arena, Dict);
|
||||
dict->bins_count = MaxU64(bins_count, 1); /* Ensure at least 1 bin */
|
||||
dict->bins = PushArray(arena, DictBin, dict->bins_count);
|
||||
dict->bins = PushStructs(arena, DictBin, dict->bins_count);
|
||||
return dict;
|
||||
}
|
||||
|
||||
Inline void dict_reset(Dict *dict)
|
||||
{
|
||||
MEMZERO(dict->bins, sizeof(*dict->bins) * dict->bins_count);
|
||||
ZeroBytes(dict->bins, sizeof(*dict->bins) * dict->bins_count);
|
||||
if (dict->first) {
|
||||
dict->last->next = dict->first_free;
|
||||
dict->first_free = dict->first;
|
||||
@ -156,7 +156,7 @@ Inline DictEntry *dict_ensure_entry(Arena *arena, Dict *dict, u64 hash)
|
||||
} else {
|
||||
entry = PushStructNoZero(arena, DictEntry);
|
||||
}
|
||||
MEMZERO_STRUCT(entry);
|
||||
ZeroStruct(entry);
|
||||
entry->hash = hash;
|
||||
if (bin->last) {
|
||||
bin->last->next_in_bin = entry;
|
||||
|
||||
@ -76,8 +76,8 @@ String BB_GetWritten(Arena *arena, BB_Writer *bw)
|
||||
{
|
||||
String res = ZI;
|
||||
res.len = (bw->cur_bit + 7) >> 3;
|
||||
res.text = PushArrayNoZero(arena, u8, res.len);
|
||||
MEMCPY(res.text, bw->base, res.len);
|
||||
res.text = PushStructsNoZero(arena, u8, res.len);
|
||||
CopyBytes(res.text, bw->base, res.len);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ b32 BB_CheckWriterOverflowBits(BB_Writer *bw, u64 num_bits)
|
||||
{
|
||||
/* Grow arena */
|
||||
u64 push_size = (((bytes_needed - arena->pos) / BB_WriterOverflowArenaPushSize) + 1) * BB_WriterOverflowArenaPushSize;
|
||||
PushArrayNoZero(arena, u8, push_size);
|
||||
PushStructsNoZero(arena, u8, push_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -167,7 +167,7 @@ void BB_WriteUBitsNoMagic(BB_Writer *bw, u64 value, u8 num_bits)
|
||||
/* cur_bit is now aligned to byte */
|
||||
u8 *at = bw->base + (bw->cur_bit >> 3);
|
||||
u8 num_bytes = (num_bits + 7) >> 3;
|
||||
MEMCPY(at, &value, num_bytes);
|
||||
CopyBytes(at, &value, num_bytes);
|
||||
bw->cur_bit += num_bits;
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ void BB_WriteBytes(BB_Writer *bw, String bytes)
|
||||
}
|
||||
|
||||
u8 *at = bw->base + (bw->cur_bit >> 3);
|
||||
MEMCPY(at, bytes.text, bytes.len);
|
||||
CopyBytes(at, bytes.text, bytes.len);
|
||||
bw->cur_bit += num_bits;
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ u64 BB_ReadUBitsNoMagic(BB_Reader *br, u8 num_bits)
|
||||
u8 *at = br->base + (br->cur_bit >> 3);
|
||||
u8 num_bytes = (num_bits + 7) >> 3;
|
||||
u64 tmp = 0;
|
||||
MEMCPY(&tmp, at, num_bytes);
|
||||
CopyBytes(&tmp, at, num_bytes);
|
||||
u64 mask = U64Max;
|
||||
if (num_bits < 64)
|
||||
{
|
||||
@ -606,8 +606,8 @@ String BB_ReadString(Arena *arena, BB_Reader *br)
|
||||
if (src != 0)
|
||||
{
|
||||
res.len = len;
|
||||
res.text = PushArrayNoZero(arena, u8, len);
|
||||
MEMCPY(res.text, src, len);
|
||||
res.text = PushStructsNoZero(arena, u8, len);
|
||||
CopyBytes(res.text, src, len);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -618,11 +618,11 @@ void BB_ReadBytes(BB_Reader *br, String out)
|
||||
u8 *src = BB_ReadBytesRaw(br, out.len);
|
||||
if (src)
|
||||
{
|
||||
MEMCPY(out.text, src, out.len);
|
||||
CopyBytes(out.text, src, out.len);
|
||||
}
|
||||
else
|
||||
{
|
||||
MEMZERO(out.text, out.len);
|
||||
ZeroBytes(out.text, out.len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -340,7 +340,7 @@ internal struct epa_result epa_get_normal_from_gjk(CLD_Shape *shape0, CLD_Shape
|
||||
proto = PushDry(scratch.arena, CLD_MenkowskiPoint);
|
||||
{
|
||||
Assert(s.len == 3);
|
||||
CLD_MenkowskiPoint *tmp = PushArrayNoZero(scratch.arena, CLD_MenkowskiPoint, 3);
|
||||
CLD_MenkowskiPoint *tmp = PushStructsNoZero(scratch.arena, CLD_MenkowskiPoint, 3);
|
||||
tmp[0] = s.a;
|
||||
tmp[1] = s.b;
|
||||
tmp[2] = s.c;
|
||||
@ -766,7 +766,7 @@ CLD_CollisionResult collider_collision_points(CLD_Shape *shape0, CLD_Shape *shap
|
||||
abort:
|
||||
res.simplex = gjk_res.simplex;
|
||||
res.prototype.len = epa_res.prototype.len;
|
||||
MEMCPY(res.prototype.points, epa_res.prototype.points, sizeof(res.prototype.points[0]) * res.prototype.len);
|
||||
CopyBytes(res.prototype.points, epa_res.prototype.points, sizeof(res.prototype.points[0]) * res.prototype.len);
|
||||
#endif
|
||||
res.normal = normal;
|
||||
res.points[0] = points[0];
|
||||
@ -854,7 +854,7 @@ CLD_ClosestResult collider_closest_points(CLD_Shape *shape0, CLD_Shape *shape1,
|
||||
abort:
|
||||
res.simplex = gjk_res.simplex;
|
||||
res.prototype.len = epa_res.prototype.len;
|
||||
MEMCPY(res.prototype.points, epa_res.prototype.points, sizeof(res.prototype.points[0]) *res.prototype.len);
|
||||
CopyBytes(res.prototype.points, epa_res.prototype.points, sizeof(res.prototype.points[0]) *res.prototype.len);
|
||||
res.simplex = gjk_res.simplex;
|
||||
#endif
|
||||
res.p0 = p0;
|
||||
|
||||
@ -58,7 +58,7 @@ void draw_poly(G_RenderSig *sig, V2Array vertices, u32 color)
|
||||
/* Generate indices in a fan pattern */
|
||||
G_Indices indices = {
|
||||
.count = num_indices,
|
||||
.indices = PushArrayNoZero(scratch.arena, u32, num_indices)
|
||||
.indices = PushStructsNoZero(scratch.arena, u32, num_indices)
|
||||
};
|
||||
for (u32 i = 0; i < num_tris; ++i) {
|
||||
u32 tri_offset = i * 3;
|
||||
@ -77,7 +77,7 @@ void draw_circle(G_RenderSig *sig, Vec2 pos, f32 radius, u32 color, u32 detail)
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
|
||||
Vec2 *points = PushArrayNoZero(scratch.arena, Vec2, detail);
|
||||
Vec2 *points = PushStructsNoZero(scratch.arena, Vec2, detail);
|
||||
for (u32 i = 0; i < detail; ++i) {
|
||||
f32 angle = ((f32)i / (f32)detail) * Tau;
|
||||
Vec2 p = VEC2(
|
||||
@ -158,7 +158,7 @@ void draw_circle_line(G_RenderSig *sig, Vec2 pos, f32 radius, f32 thickness, u32
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
|
||||
Vec2 *points = PushArrayNoZero(scratch.arena, Vec2, detail);
|
||||
Vec2 *points = PushStructsNoZero(scratch.arena, Vec2, detail);
|
||||
for (u32 i = 0; i < detail; ++i) {
|
||||
f32 angle = ((f32)i / (f32)detail) * Tau;
|
||||
Vec2 p = VEC2(
|
||||
@ -226,14 +226,14 @@ void draw_collider_line(G_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 t
|
||||
V2Array poly = ZI;
|
||||
if (shape.radius == 0) {
|
||||
poly.count = shape.count;
|
||||
poly.points = PushArrayNoZero(scratch.arena, Vec2, shape.count);
|
||||
poly.points = PushStructsNoZero(scratch.arena, Vec2, shape.count);
|
||||
for (u32 i = 0; i < shape.count; ++i) {
|
||||
Vec2 p = MulXformV2(shape_xf, shape.points[i]);
|
||||
poly.points[i] = p;
|
||||
}
|
||||
} else {
|
||||
poly.count = detail;
|
||||
poly.points = PushArrayNoZero(scratch.arena, Vec2, detail);
|
||||
poly.points = PushStructsNoZero(scratch.arena, Vec2, detail);
|
||||
for (u32 i = 0; i < detail; ++i) {
|
||||
f32 angle = ((f32)i / (f32)detail) * Tau;
|
||||
Vec2 dir = VEC2(CosF32(angle), SinF32(angle));
|
||||
|
||||
@ -35,7 +35,7 @@ DXC_Result dxc_compile(Arena *arena, String shader_source, i32 num_args, String
|
||||
TempArena scratch = BeginScratch(arena);
|
||||
DXC_Result res = ZI;
|
||||
|
||||
wchar_t **wstr_args = PushArray(scratch.arena, wchar_t *, num_args);
|
||||
wchar_t **wstr_args = PushStructs(scratch.arena, wchar_t *, num_args);
|
||||
for (i32 i = 0; i < num_args; ++i) {
|
||||
wstr_args[i] = wstr_from_string(scratch.arena, args[i]);
|
||||
}
|
||||
@ -57,7 +57,7 @@ DXC_Result dxc_compile(Arena *arena, String shader_source, i32 num_args, String
|
||||
CComPtr<IDxcResult> compile_results = 0;
|
||||
dxc_compiler->Compile(&dxc_src_buffer, (LPCWSTR *)wstr_args, (u32)num_args, dxc_include_handler, IID_PPV_ARGS(&compile_results));
|
||||
|
||||
/* Copy errors */
|
||||
/* CopyStruct errors */
|
||||
CComPtr<IDxcBlobUtf8> dxc_errors = 0;
|
||||
compile_results->GetOutput(DXC_OUT_ERRORS, IID_PPV_ARGS(&dxc_errors), 0);
|
||||
if (dxc_errors != 0) {
|
||||
@ -72,7 +72,7 @@ DXC_Result dxc_compile(Arena *arena, String shader_source, i32 num_args, String
|
||||
compile_results->GetStatus(&dxc_hr);
|
||||
res.success = SUCCEEDED(dxc_hr);
|
||||
|
||||
/* Copy shader output */
|
||||
/* CopyStruct shader output */
|
||||
if (res.success) {
|
||||
CComPtr<IDxcBlob> dxc_shader = 0;
|
||||
compile_results->GetOutput(DXC_OUT_OBJECT, IID_PPV_ARGS(&dxc_shader), 0);
|
||||
|
||||
@ -107,8 +107,8 @@ internal P_JobDef(font_load_asset_job, job)
|
||||
{
|
||||
AC_Store store = asset_cache_store_open();
|
||||
font = PushStruct(store.arena, F_Font);
|
||||
font->glyphs = PushArrayNoZero(store.arena, F_Glyph, result.glyphs_count);
|
||||
font->lookup = PushArray(store.arena, u16, LOOKUP_TABLE_SIZE);
|
||||
font->glyphs = PushStructsNoZero(store.arena, F_Glyph, result.glyphs_count);
|
||||
font->lookup = PushStructs(store.arena, u16, LOOKUP_TABLE_SIZE);
|
||||
asset_cache_store_close(&store);
|
||||
}
|
||||
|
||||
@ -126,9 +126,9 @@ internal P_JobDef(font_load_asset_job, job)
|
||||
FMT_STR(path)));
|
||||
}
|
||||
|
||||
/* Copy glyphs from decode result */
|
||||
/* CopyStruct glyphs from decode result */
|
||||
StaticAssert(sizeof(*font->glyphs) == sizeof(*result.glyphs)); /* Font glyph size must match TTF glyph size for memcpy */
|
||||
MEMCPY(font->glyphs, result.glyphs, sizeof(*font->glyphs) * result.glyphs_count);
|
||||
CopyBytes(font->glyphs, result.glyphs, sizeof(*font->glyphs) * result.glyphs_count);
|
||||
|
||||
/* Build lookup table */
|
||||
for (u64 i = 0; i < countof(g_font_codes); ++i) {
|
||||
|
||||
@ -651,7 +651,7 @@ internal void dx12_init_objects(void)
|
||||
struct command_queue_desc params[] = {
|
||||
{.type = D3D12_COMMAND_LIST_TYPE_DIRECT, .priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL, .dbg_name = LIT("Direct queue") },
|
||||
{.type = D3D12_COMMAND_LIST_TYPE_COMPUTE, .priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL, .dbg_name = LIT("Compute queue") },
|
||||
{.type = D3D12_COMMAND_LIST_TYPE_COPY, .priority = D3D12_COMMAND_QUEUE_PRIORITY_HIGH, .dbg_name = LIT("Copy queue") },
|
||||
{.type = D3D12_COMMAND_LIST_TYPE_COPY, .priority = D3D12_COMMAND_QUEUE_PRIORITY_HIGH, .dbg_name = LIT("CopyStruct queue") },
|
||||
{.type = D3D12_COMMAND_LIST_TYPE_COPY, .priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL, .dbg_name = LIT("Background copy queue") }
|
||||
};
|
||||
struct command_queue_alloc_job_sig sig = ZI;
|
||||
@ -746,7 +746,7 @@ internal void dx12_init_pipelines(void)
|
||||
*PushStruct(scratch.arena, struct pipeline_desc) = *desc;
|
||||
++num_pipelines;
|
||||
}
|
||||
struct pipeline **pipelines = PushArray(scratch.arena, struct pipeline *, num_pipelines);
|
||||
struct pipeline **pipelines = PushStructs(scratch.arena, struct pipeline *, num_pipelines);
|
||||
{
|
||||
__profn("Allocate pipelines");
|
||||
struct pipeline_alloc_job_sig sig = ZI;
|
||||
@ -892,7 +892,7 @@ internal P_JobDef(shader_compile_job, job)
|
||||
LIT("-T"), desc->target,
|
||||
};
|
||||
u32 num_args = countof(shader_args) + dxc_args_array.count;
|
||||
String *args = PushArray(scratch.arena, String, num_args);
|
||||
String *args = PushStructs(scratch.arena, String, num_args);
|
||||
for (u32 i = 0; i < countof(shader_args); ++i) {
|
||||
args[i] = shader_args[i];
|
||||
}
|
||||
@ -934,7 +934,7 @@ internal P_JobDef(pipeline_alloc_job, job)
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(pipeline);
|
||||
ZeroStruct(pipeline);
|
||||
pipelines_out[job.id] = pipeline;
|
||||
pipeline->desc = *desc;
|
||||
pipeline->name = desc->name;
|
||||
@ -976,7 +976,7 @@ internal P_JobDef(pipeline_alloc_job, job)
|
||||
if (success && vs_dxc.len > 0) {
|
||||
hr = D3DCreateBlob(vs_dxc.len, &vs_blob);
|
||||
if (SUCCEEDED(hr)) {
|
||||
MEMCPY(ID3D10Blob_GetBufferPointer(vs_blob), vs_dxc.text, vs_dxc.len);
|
||||
CopyBytes(ID3D10Blob_GetBufferPointer(vs_blob), vs_dxc.text, vs_dxc.len);
|
||||
} else {
|
||||
error_str = LIT("Failed to create vertex shader blob");
|
||||
success = 0;
|
||||
@ -985,7 +985,7 @@ internal P_JobDef(pipeline_alloc_job, job)
|
||||
if (success && ps_dxc.len > 0) {
|
||||
hr = D3DCreateBlob(ps_dxc.len, &ps_blob);
|
||||
if (SUCCEEDED(hr)) {
|
||||
MEMCPY(ID3D10Blob_GetBufferPointer(ps_blob), ps_dxc.text, ps_dxc.len);
|
||||
CopyBytes(ID3D10Blob_GetBufferPointer(ps_blob), ps_dxc.text, ps_dxc.len);
|
||||
} else {
|
||||
error_str = LIT("Failed to create pixel shader blob");
|
||||
success = 0;
|
||||
@ -994,7 +994,7 @@ internal P_JobDef(pipeline_alloc_job, job)
|
||||
if (success && cs_dxc.len > 0) {
|
||||
hr = D3DCreateBlob(cs_dxc.len, &cs_blob);
|
||||
if (SUCCEEDED(hr)) {
|
||||
MEMCPY(ID3D10Blob_GetBufferPointer(cs_blob), cs_dxc.text, cs_dxc.len);
|
||||
CopyBytes(ID3D10Blob_GetBufferPointer(cs_blob), cs_dxc.text, cs_dxc.len);
|
||||
} else {
|
||||
error_str = LIT("Failed to create compute shader blob");
|
||||
success = 0;
|
||||
@ -1044,7 +1044,7 @@ internal P_JobDef(pipeline_alloc_job, job)
|
||||
} else if (ps_rootsig_data_len == 0) {
|
||||
success = 0;
|
||||
error_str = LIT("Pixel shader is missing root signature");
|
||||
} else if (vs_rootsig_data_len != ps_rootsig_data_len || !MEMEQ(vs_rootsig_data, ps_rootsig_data, vs_rootsig_data_len)) {
|
||||
} else if (vs_rootsig_data_len != ps_rootsig_data_len || !EqBytes(vs_rootsig_data, ps_rootsig_data, vs_rootsig_data_len)) {
|
||||
success = 0;
|
||||
error_str = LIT("Root signature mismatch between vertex and pixel shader");
|
||||
} else {
|
||||
@ -1347,8 +1347,8 @@ internal WATCH_CALLBACK_FUNC_DEF(pipeline_watch_callback, name)
|
||||
sig.arena = scratch.arena;
|
||||
if (is_rs) {
|
||||
num_shaders = 2;
|
||||
shader_descs = PushArray(scratch.arena, struct shader_compile_desc, num_shaders);
|
||||
shader_results = PushArray(scratch.arena, struct shader_compile_result, num_shaders);
|
||||
shader_descs = PushStructs(scratch.arena, struct shader_compile_desc, num_shaders);
|
||||
shader_results = PushStructs(scratch.arena, struct shader_compile_result, num_shaders);
|
||||
sig.descs = shader_descs;
|
||||
sig.results = shader_results;
|
||||
sig.descs[0].src = data;
|
||||
@ -1361,8 +1361,8 @@ internal WATCH_CALLBACK_FUNC_DEF(pipeline_watch_callback, name)
|
||||
sig.descs[1].target = LIT("ps_6_6");
|
||||
} else if (is_cs) {
|
||||
num_shaders = 1;
|
||||
shader_descs = PushArray(scratch.arena, struct shader_compile_desc, num_shaders);
|
||||
shader_results = PushArray(scratch.arena, struct shader_compile_result, num_shaders);
|
||||
shader_descs = PushStructs(scratch.arena, struct shader_compile_desc, num_shaders);
|
||||
shader_results = PushStructs(scratch.arena, struct shader_compile_result, num_shaders);
|
||||
sig.descs = shader_descs;
|
||||
sig.results = shader_results;
|
||||
sig.descs[0].src = data;
|
||||
@ -1418,7 +1418,7 @@ internal WATCH_CALLBACK_FUNC_DEF(pipeline_watch_callback, name)
|
||||
/* Recompile dirty pipelines */
|
||||
if (num_pipelines > 0) {
|
||||
__profn("Compile dirty pipelines");
|
||||
struct pipeline **pipelines = PushArray(scratch.arena, struct pipeline *, num_pipelines);
|
||||
struct pipeline **pipelines = PushStructs(scratch.arena, struct pipeline *, num_pipelines);
|
||||
{
|
||||
struct pipeline_alloc_job_sig sig = ZI;
|
||||
sig.descs_in = pipeline_descs;
|
||||
@ -1490,7 +1490,7 @@ internal struct descriptor *descriptor_alloc(struct cpu_descriptor_heap *dh)
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(d);
|
||||
ZeroStruct(d);
|
||||
d->heap = dh;
|
||||
d->handle = handle;
|
||||
d->index = index;
|
||||
@ -1581,7 +1581,7 @@ internal void fenced_release(void *data, enum fenced_release_kind kind)
|
||||
P_Lock lock = P_LockE(&G.fenced_releases_mutex);
|
||||
{
|
||||
*PushStruct(G.fenced_releases_arena, struct fenced_release_data) = fr;
|
||||
MEMCPY(G.fenced_release_targets, fr_targets, sizeof(fr_targets));
|
||||
CopyBytes(G.fenced_release_targets, fr_targets, sizeof(fr_targets));
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
@ -1615,7 +1615,7 @@ internal struct dx12_resource *dx12_resource_alloc(D3D12_HEAP_PROPERTIES heap_pr
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(r);
|
||||
ZeroStruct(r);
|
||||
|
||||
D3D12_CLEAR_VALUE clear_value = { .Format = desc.Format, .Color = { 0 } };
|
||||
D3D12_CLEAR_VALUE *clear_value_ptr = desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET ? &clear_value : 0;
|
||||
@ -1685,7 +1685,7 @@ internal void dx12_resource_barriers(ID3D12GraphicsCommandList *cl, i32 num_desc
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
|
||||
i32 num_rbs = 0;
|
||||
struct D3D12_RESOURCE_BARRIER *rbs = PushArrayNoZero(scratch.arena, struct D3D12_RESOURCE_BARRIER, num_descs);
|
||||
struct D3D12_RESOURCE_BARRIER *rbs = PushStructsNoZero(scratch.arena, struct D3D12_RESOURCE_BARRIER, num_descs);
|
||||
for (i32 i = 0; i < num_descs; ++i) {
|
||||
struct dx12_resource_barrier_desc *desc = &descs[i];
|
||||
struct dx12_resource *resource = desc->resource;
|
||||
@ -1695,7 +1695,7 @@ internal void dx12_resource_barriers(ID3D12GraphicsCommandList *cl, i32 num_desc
|
||||
enum D3D12_RESOURCE_STATES new_state = desc->new_state;
|
||||
if (new_state != old_state) {
|
||||
struct D3D12_RESOURCE_BARRIER *rb = &rbs[num_rbs++];
|
||||
MEMZERO_STRUCT(rb);
|
||||
ZeroStruct(rb);
|
||||
rb->Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||
rb->Flags = 0;
|
||||
rb->Transition.pResource = resource->resource;
|
||||
@ -1706,7 +1706,7 @@ internal void dx12_resource_barriers(ID3D12GraphicsCommandList *cl, i32 num_desc
|
||||
}
|
||||
} else if (type == D3D12_RESOURCE_BARRIER_TYPE_UAV) {
|
||||
struct D3D12_RESOURCE_BARRIER *rb = &rbs[num_rbs++];
|
||||
MEMZERO_STRUCT(rb);
|
||||
ZeroStruct(rb);
|
||||
rb->Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
|
||||
rb->Flags = 0;
|
||||
rb->UAV.pResource = resource->resource;
|
||||
@ -1826,7 +1826,7 @@ internal struct command_list *command_list_open(struct command_list_pool *pool)
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(cl);
|
||||
ZeroStruct(cl);
|
||||
cl->cq = cq;
|
||||
cl->pool = pool;
|
||||
cl->global_record_lock = P_LockS(&G.global_command_list_record_mutex);
|
||||
@ -1996,7 +1996,7 @@ internal struct command_descriptor_heap *command_list_push_descriptor_heap(struc
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(cdh);
|
||||
ZeroStruct(cdh);
|
||||
|
||||
if (old_heap) {
|
||||
cdh->heap = old_heap;
|
||||
@ -2015,7 +2015,7 @@ internal struct command_descriptor_heap *command_list_push_descriptor_heap(struc
|
||||
ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(cdh->heap, &cdh->start_gpu_handle);
|
||||
}
|
||||
|
||||
/* Copy CPU heap */
|
||||
/* CopyStruct CPU heap */
|
||||
{
|
||||
P_Lock lock = P_LockS(&dh_cpu->mutex);
|
||||
ID3D12Device_CopyDescriptorsSimple(G.device, dh_cpu->num_descriptors_reserved, cdh->start_cpu_handle, dh_cpu->handle, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||
@ -2113,7 +2113,7 @@ internal struct command_buffer *_command_list_push_buffer(struct command_list *c
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(cb);
|
||||
ZeroStruct(cb);
|
||||
cb->group = cb_group;
|
||||
cb->size = data_len;
|
||||
|
||||
@ -2165,7 +2165,7 @@ internal struct command_buffer *_command_list_push_buffer(struct command_list *c
|
||||
/* TODO: Don't panic */
|
||||
P_Panic(LIT("Failed to map command buffer resource"));
|
||||
}
|
||||
MEMCPY(dst, data, data_len);
|
||||
CopyBytes(dst, data, data_len);
|
||||
ID3D12Resource_Unmap(cb->resource->resource, 0, 0);
|
||||
}
|
||||
|
||||
@ -2328,7 +2328,7 @@ internal P_JobDef(dx12_upload_job, job)
|
||||
struct command_queue *cq = G.command_queues[DX12_QUEUE_COPY_BACKGROUND];
|
||||
struct command_list *cl = command_list_open(cq->cl_pool);
|
||||
{
|
||||
/* Copy to upload heap */
|
||||
/* CopyStruct to upload heap */
|
||||
{
|
||||
D3D12_RANGE read_range = ZI;
|
||||
void *mapped = 0;
|
||||
@ -2345,13 +2345,13 @@ internal P_JobDef(dx12_upload_job, job)
|
||||
for (u32 z = 0; z < desc.DepthOrArraySize; ++z) {
|
||||
u32 z_offset = z * z_size;
|
||||
for (u32 y = 0; y < upload_num_rows; ++y) {
|
||||
MEMCPY(dst + y * footprint.RowPitch + z_offset, src + y * upload_row_size + z_offset, upload_row_size);
|
||||
CopyBytes(dst + y * footprint.RowPitch + z_offset, src + y * upload_row_size + z_offset, upload_row_size);
|
||||
}
|
||||
}
|
||||
ID3D12Resource_Unmap(upload->resource, 0, 0);
|
||||
}
|
||||
|
||||
/* Copy from upload heap to texture */
|
||||
/* CopyStruct from upload heap to texture */
|
||||
{
|
||||
__profnc_dx12(cl->cq->prof, cl->cl, "Upload texture", Rgb32F(0.2, 0.5, 0.2));
|
||||
D3D12_TEXTURE_COPY_LOCATION dst_loc = {
|
||||
@ -2409,7 +2409,7 @@ internal void command_list_set_sig(struct command_list *cl, void *src, u32 size)
|
||||
b32 is_gfx = cl->cur_pipeline->is_gfx;
|
||||
for (u32 i = 0; i < num32bit; ++i) {
|
||||
u32 val = 0;
|
||||
MEMCPY(&val, (((u32 *)src) + i), 4);
|
||||
CopyBytes(&val, (((u32 *)src) + i), 4);
|
||||
if (is_gfx) {
|
||||
ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstant(cl->cl, 0, val, i);
|
||||
} else {
|
||||
@ -2653,8 +2653,8 @@ u32 gp_push_render_cmd(G_RenderSig *render_sig, G_RenderCmdDesc *cmd_desc)
|
||||
case GP_RENDER_CMD_KIND_DRAW_UI_SHAPE:
|
||||
{
|
||||
u32 color = cmd_desc->ui_shape.color;
|
||||
struct k_shape_vert *verts = PushArrayNoZero(sig->ui_shape_verts_arena, struct k_shape_vert, cmd_desc->ui_shape.vertices.count);
|
||||
u32 *indices = PushArrayNoZero(sig->ui_shape_indices_arena, u32, cmd_desc->ui_shape.indices.count);
|
||||
struct k_shape_vert *verts = PushStructsNoZero(sig->ui_shape_verts_arena, struct k_shape_vert, cmd_desc->ui_shape.vertices.count);
|
||||
u32 *indices = PushStructsNoZero(sig->ui_shape_indices_arena, u32, cmd_desc->ui_shape.indices.count);
|
||||
for (u32 i = 0; i < cmd_desc->ui_shape.vertices.count; ++i) {
|
||||
struct k_shape_vert *v = &verts[i];
|
||||
v->pos = K_Float2FromV2(cmd_desc->ui_shape.vertices.points[i]);
|
||||
@ -2764,9 +2764,9 @@ G_Resource *gp_run_render(G_RenderSig *gp_render_sig, G_RenderParams params)
|
||||
struct command_buffer *quad_index_buffer = command_list_push_buffer(cl, countof(quad_indices), quad_indices);
|
||||
|
||||
/* Process sig data into uploadable data */
|
||||
struct k_material_instance *material_instances = PushArrayNoZero(scratch.arena, struct k_material_instance, rsig->num_material_instance_descs);
|
||||
struct k_ui_instance *ui_rect_instances = PushArrayNoZero(scratch.arena, struct k_ui_instance, rsig->num_ui_rect_instance_descs);
|
||||
struct k_material_grid *grids = PushArrayNoZero(scratch.arena, struct k_material_grid, rsig->num_material_grid_descs);
|
||||
struct k_material_instance *material_instances = PushStructsNoZero(scratch.arena, struct k_material_instance, rsig->num_material_instance_descs);
|
||||
struct k_ui_instance *ui_rect_instances = PushStructsNoZero(scratch.arena, struct k_ui_instance, rsig->num_ui_rect_instance_descs);
|
||||
struct k_material_grid *grids = PushStructsNoZero(scratch.arena, struct k_material_grid, rsig->num_material_grid_descs);
|
||||
{
|
||||
__profn("Process sig data");
|
||||
|
||||
@ -3192,7 +3192,7 @@ internal void swapchain_init_resources(struct swapchain *swapchain)
|
||||
P_Panic(LIT("Failed to get swapchain buffer"));
|
||||
}
|
||||
struct swapchain_buffer *sb = &swapchain->buffers[i];
|
||||
MEMZERO_STRUCT(sb);
|
||||
ZeroStruct(sb);
|
||||
sb->swapchain = swapchain;
|
||||
sb->resource = resource;
|
||||
sb->rtv_descriptor = descriptor_alloc(G.rtv_heap);
|
||||
@ -3500,17 +3500,17 @@ internal P_JobDef(dx12_evictor_job, _)
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
u64 targets[countof(completed_targets)] = ZI;
|
||||
|
||||
/* Copy queued data */
|
||||
/* CopyStruct queued data */
|
||||
u32 num_fenced_releases = 0;
|
||||
struct fenced_release_data *fenced_releases = 0;
|
||||
{
|
||||
__profn("Copy queued releases");
|
||||
__profn("CopyStruct queued releases");
|
||||
P_Lock lock = P_LockE(&G.fenced_releases_mutex);
|
||||
num_fenced_releases = G.fenced_releases_arena->pos / sizeof(struct fenced_release_data);
|
||||
fenced_releases = PushArrayNoZero(scratch.arena, struct fenced_release_data, num_fenced_releases);
|
||||
MEMCPY(fenced_releases, ArenaBase(G.fenced_releases_arena), G.fenced_releases_arena->pos);
|
||||
fenced_releases = PushStructsNoZero(scratch.arena, struct fenced_release_data, num_fenced_releases);
|
||||
CopyBytes(fenced_releases, ArenaBase(G.fenced_releases_arena), G.fenced_releases_arena->pos);
|
||||
ResetArena(G.fenced_releases_arena);
|
||||
MEMCPY(targets, G.fenced_release_targets, sizeof(targets));
|
||||
CopyBytes(targets, G.fenced_release_targets, sizeof(targets));
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ Inline struct K_float4x4 K_Float4x4FromMat4x4(Mat4x4 v)
|
||||
{
|
||||
struct K_float4x4 res;
|
||||
StaticAssert(sizeof(res) == sizeof(v));
|
||||
MEMCPY(&res, v.e, sizeof(res));
|
||||
CopyBytes(&res, v.e, sizeof(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ Inline struct K_float2x3 K_Float2x3FromXform(Xform v)
|
||||
{
|
||||
struct K_float2x3 res;
|
||||
StaticAssert(sizeof(res) == sizeof(v));
|
||||
MEMCPY(&res, &v, sizeof(res));
|
||||
CopyBytes(&res, &v, sizeof(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -265,7 +265,7 @@ M_PcmF32 mixer_update(Arena *arena, u64 frame_count)
|
||||
|
||||
M_PcmF32 res = ZI;
|
||||
res.count = frame_count * 2;
|
||||
res.samples = PushArray(arena, f32, res.count);
|
||||
res.samples = PushStructs(arena, f32, res.count);
|
||||
|
||||
Vec2 listener_pos = VEC2(0, 0);
|
||||
Vec2 listener_dir = VEC2(0, 0);
|
||||
@ -281,7 +281,7 @@ M_PcmF32 mixer_update(Arena *arena, u64 frame_count)
|
||||
listener_dir = G.listener_dir;
|
||||
|
||||
/* Update & read mixes */
|
||||
mixes = PushArrayNoZero(scratch.arena, struct mix *, G.track_playing_count);
|
||||
mixes = PushStructsNoZero(scratch.arena, struct mix *, G.track_playing_count);
|
||||
for (struct track *track = G.track_first_playing; track; track = track->next) {
|
||||
__profn("Prepare track");
|
||||
struct mix *mix = &track->mix;
|
||||
@ -337,7 +337,7 @@ M_PcmF32 mixer_update(Arena *arena, u64 frame_count)
|
||||
|
||||
M_PcmF32 mix_pcm = {
|
||||
.count = res.count,
|
||||
.samples = PushArray(scratch.arena, f32, res.count)
|
||||
.samples = PushStructs(scratch.arena, f32, res.count)
|
||||
};
|
||||
|
||||
/* ========================== *
|
||||
|
||||
@ -109,8 +109,8 @@ MP3_Result mp3_decode(Arena *arena, String encoded, u32 sample_rate, u32 flags)
|
||||
DWORD size_bytes;
|
||||
IMFMediaBuffer_Lock(buffer, &src, 0, &size_bytes);
|
||||
{
|
||||
i16 *dst = PushArrayNoZero(arena, i16, (size_bytes + 1) >> 1);
|
||||
MEMCPY(dst, src, size_bytes);
|
||||
i16 *dst = PushStructsNoZero(arena, i16, (size_bytes + 1) >> 1);
|
||||
CopyBytes(dst, src, size_bytes);
|
||||
sample_bytes_read += size_bytes;
|
||||
}
|
||||
IMFMediaBuffer_Unlock(buffer);
|
||||
|
||||
@ -154,10 +154,10 @@ N_Host *host_alloc(u16 listen_port)
|
||||
host->channels = PushDry(host->channel_arena, struct host_channel);
|
||||
|
||||
host->num_channel_lookup_bins = N_NumChannelLookupBins;
|
||||
host->channel_lookup_bins = PushArray(host->arena, N_ChannelLookupBin, host->num_channel_lookup_bins);
|
||||
host->channel_lookup_bins = PushStructs(host->arena, N_ChannelLookupBin, host->num_channel_lookup_bins);
|
||||
|
||||
host->num_msg_assembler_lookup_bins = N_NumMsgAssemblerLookupBins;
|
||||
host->msg_assembler_lookup_bins = PushArray(host->arena, struct host_msg_assembler_lookup_bin, host->num_msg_assembler_lookup_bins);
|
||||
host->msg_assembler_lookup_bins = PushStructs(host->arena, struct host_msg_assembler_lookup_bin, host->num_msg_assembler_lookup_bins);
|
||||
|
||||
host->sock = P_AllocSock(listen_port, Mebi(2), Mebi(2));
|
||||
|
||||
@ -253,7 +253,7 @@ internal struct host_channel *host_channel_alloc(N_Host *host, P_Address address
|
||||
id.idx = host->num_channels_reserved;
|
||||
++host->num_channels_reserved;
|
||||
}
|
||||
MEMZERO_STRUCT(channel);
|
||||
ZeroStruct(channel);
|
||||
channel->valid = 1;
|
||||
channel->id = id;
|
||||
channel->host = host;
|
||||
@ -352,7 +352,7 @@ internal struct host_msg_assembler *host_msg_assembler_alloc(struct host_channel
|
||||
} else {
|
||||
ma = PushStructNoZero(host->arena, struct host_msg_assembler);
|
||||
}
|
||||
MEMZERO_STRUCT(ma);
|
||||
ZeroStruct(ma);
|
||||
ma->channel = channel;
|
||||
ma->msg_id = msg_id;
|
||||
|
||||
@ -370,7 +370,7 @@ internal struct host_msg_assembler *host_msg_assembler_alloc(struct host_channel
|
||||
* access as packets are received */
|
||||
ma->buddy_block = AllocBuddyBlock(host->buddy, chunk_bitmap_size + chunk_data_size);
|
||||
ma->chunk_bitmap = ma->buddy_block->memory;
|
||||
MEMZERO(ma->chunk_bitmap, chunk_bitmap_size);
|
||||
ZeroBytes(ma->chunk_bitmap, chunk_bitmap_size);
|
||||
ma->chunk_data = ma->chunk_bitmap + chunk_bitmap_size;
|
||||
|
||||
/* FIXME: Ensure chunk_count > 0 */
|
||||
@ -507,7 +507,7 @@ internal N_SndPacket *host_channel_snd_packet_alloc(struct host_channel *channel
|
||||
} else {
|
||||
packet = PushStructNoZero(host->arena, N_SndPacket);
|
||||
}
|
||||
MEMZERO_STRUCT(packet);
|
||||
ZeroStruct(packet);
|
||||
|
||||
if (is_reliable) {
|
||||
if (channel->last_reliable_packet) {
|
||||
@ -744,7 +744,7 @@ N_EventList host_update_begin(Arena *arena, N_Host *host)
|
||||
u8 *src = BB_ReadBytesRaw(&br, chunk_len);
|
||||
if (src) {
|
||||
u8 *dst = &ma->chunk_data[chunk_id * N_MaxPacketChunkLen];
|
||||
MEMCPY(dst, src, chunk_len);
|
||||
CopyBytes(dst, src, chunk_len);
|
||||
if (is_last_chunk) {
|
||||
ma->last_chunk_len = chunk_len;
|
||||
}
|
||||
@ -757,8 +757,8 @@ N_EventList host_update_begin(Arena *arena, N_Host *host)
|
||||
N_Event *event = push_event(arena, &events);
|
||||
String data = ZI;
|
||||
data.len = ((chunk_count - 1) * N_MaxPacketChunkLen) + ma->last_chunk_len;
|
||||
data.text = PushArrayNoZero(arena, u8, data.len);
|
||||
MEMCPY(data.text, ma->chunk_data, data.len);
|
||||
data.text = PushStructsNoZero(arena, u8, data.len);
|
||||
CopyBytes(data.text, ma->chunk_data, data.len);
|
||||
event->kind = HOST_EVENT_KIND_MSG;
|
||||
event->msg = data;
|
||||
event->channel_id = channel->id;
|
||||
|
||||
@ -132,7 +132,7 @@ void P_Unlock(P_Lock *l)
|
||||
Atomic32FetchAdd(&m->v, -1);
|
||||
}
|
||||
P_Wake(&m->v, I32Max);
|
||||
MEMZERO_STRUCT(l);
|
||||
ZeroStruct(l);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@ -83,7 +83,7 @@ P_W32_Thread *P_W32_AllocThread(P_W32_ThreadFunc *entry_point, void *thread_data
|
||||
{
|
||||
t = PushStructNoZero(g->threads_arena, P_W32_Thread);
|
||||
}
|
||||
MEMZERO_STRUCT(t);
|
||||
ZeroStruct(t);
|
||||
if (g->last_thread)
|
||||
{
|
||||
g->last_thread->next = t;
|
||||
@ -102,16 +102,16 @@ P_W32_Thread *P_W32_AllocThread(P_W32_ThreadFunc *entry_point, void *thread_data
|
||||
t->thread_data = thread_data;
|
||||
t->profiler_group = profiler_group;
|
||||
|
||||
/* Copy thread name to params */
|
||||
/* CopyStruct thread name to params */
|
||||
{
|
||||
u64 cstr_len = MinU64((countof(t->thread_name_cstr) - 1), thread_name.len);
|
||||
MEMCPY(t->thread_name_cstr, thread_name.text, cstr_len * sizeof(*t->thread_name_cstr));
|
||||
CopyBytes(t->thread_name_cstr, thread_name.text, cstr_len * sizeof(*t->thread_name_cstr));
|
||||
t->thread_name_cstr[cstr_len] = 0;
|
||||
}
|
||||
{
|
||||
String16 thread_name16 = string16_from_string(scratch.arena, thread_name);
|
||||
u64 wstr_len = MinU64((countof(t->thread_name_wstr) - 1), thread_name16.len);
|
||||
MEMCPY(t->thread_name_wstr, thread_name16.text, wstr_len * sizeof(*t->thread_name_wstr));
|
||||
CopyBytes(t->thread_name_wstr, thread_name16.text, wstr_len * sizeof(*t->thread_name_wstr));
|
||||
t->thread_name_wstr[wstr_len] = 0;
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ void P_W32_WakeLockedFibers(i32 num_fibers, P_W32_Fiber **fibers)
|
||||
{
|
||||
info = PushStructNoZero(queue->arena, P_W32_JobInfo);
|
||||
}
|
||||
MEMZERO_STRUCT(info);
|
||||
ZeroStruct(info);
|
||||
info->count = 1;
|
||||
info->num_dispatched = fiber->job_id;
|
||||
info->func = fiber->job_func;
|
||||
@ -447,7 +447,7 @@ void P_W32_WakeByAddress(void *addr, i32 count)
|
||||
/* Lock fibers & build array */
|
||||
if (wait_addr_list)
|
||||
{
|
||||
fibers = PushArrayNoZero(scratch.arena, P_W32_Fiber *, wait_addr_list->num_waiters);
|
||||
fibers = PushStructsNoZero(scratch.arena, P_W32_Fiber *, wait_addr_list->num_waiters);
|
||||
for (P_W32_Fiber *fiber = P_W32_FiberFromId(wait_addr_list->first_waiter); fiber && num_fibers < count; fiber = P_W32_FiberFromId(fiber->next_addr_waiter))
|
||||
{
|
||||
if (Atomic32FetchTestSet(&fiber->wake_lock, 0, 1) == 0)
|
||||
@ -509,7 +509,7 @@ void P_W32_WakeByTime(u64 time)
|
||||
if (wait_time_list)
|
||||
{
|
||||
/* Set waiter wake status & build fibers list */
|
||||
fibers = PushArrayNoZero(scratch.arena, P_W32_Fiber *, wait_time_list->num_waiters);
|
||||
fibers = PushStructsNoZero(scratch.arena, P_W32_Fiber *, wait_time_list->num_waiters);
|
||||
for (P_W32_Fiber *fiber = P_W32_FiberFromId(wait_time_list->first_waiter); fiber; fiber = P_W32_FiberFromId(fiber->next_time_waiter))
|
||||
{
|
||||
if (Atomic32FetchTestSet(&fiber->wake_lock, 0, 1) == 0)
|
||||
@ -562,7 +562,7 @@ P_W32_Fiber *P_W32_AllocFiber(P_W32_JobPool *pool)
|
||||
P_Panic(LIT("Max fibers reached"));
|
||||
}
|
||||
fiber = &g->fibers[fiber_id];
|
||||
new_name_cstr = PushArray(g->fiber_names_arena, char, P_W32_FiberNameMaxSize);
|
||||
new_name_cstr = PushStructs(g->fiber_names_arena, char, P_W32_FiberNameMaxSize);
|
||||
}
|
||||
}
|
||||
P_W32_UnlockTicketMutex(&g->fibers_lock);
|
||||
@ -599,11 +599,11 @@ P_W32_Fiber *P_W32_AllocFiber(P_W32_JobPool *pool)
|
||||
/* Concat fiber name */
|
||||
i32 name_size = 1;
|
||||
Assert(sizeof(sizeof(P_W32_FiberNamePrefixCstr)) <= P_W32_FiberNameMaxSize);
|
||||
MEMCPY(new_name_cstr, P_W32_FiberNamePrefixCstr, sizeof(P_W32_FiberNamePrefixCstr));
|
||||
CopyBytes(new_name_cstr, P_W32_FiberNamePrefixCstr, sizeof(P_W32_FiberNamePrefixCstr));
|
||||
name_size += sizeof(P_W32_FiberNamePrefixCstr) - 2;
|
||||
MEMCPY(new_name_cstr + name_size, id_chars, id_chars_len);
|
||||
CopyBytes(new_name_cstr + name_size, id_chars, id_chars_len);
|
||||
name_size += id_chars_len;
|
||||
MEMCPY(new_name_cstr + name_size, P_W32_FiberNameSuffixCstr, sizeof(P_W32_FiberNameSuffixCstr));
|
||||
CopyBytes(new_name_cstr + name_size, P_W32_FiberNameSuffixCstr, sizeof(P_W32_FiberNameSuffixCstr));
|
||||
name_size += sizeof(P_W32_FiberNameSuffixCstr) - 2;
|
||||
|
||||
fiber->name_cstr = new_name_cstr;
|
||||
@ -964,7 +964,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
|
||||
}
|
||||
P_W32_UnlockTicketMutex(&g->wait_lists_arena_lock);
|
||||
}
|
||||
MEMZERO_STRUCT(wait_addr_list);
|
||||
ZeroStruct(wait_addr_list);
|
||||
wait_addr_list->value = (u64)wait_addr;
|
||||
if (wait_addr_bin->last_wait_list)
|
||||
{
|
||||
@ -1018,7 +1018,7 @@ P_W32_ThreadDef(P_W32_JobWorkerEntryFunc, worker_ctx_arg)
|
||||
}
|
||||
P_W32_UnlockTicketMutex(&g->wait_lists_arena_lock);
|
||||
}
|
||||
MEMZERO_STRUCT(wait_time_list);
|
||||
ZeroStruct(wait_time_list);
|
||||
wait_time_list->value = wait_time;
|
||||
if (wait_time_bin->last_wait_list)
|
||||
{
|
||||
@ -1205,7 +1205,7 @@ String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src)
|
||||
String16 decode_str = { .len = *(src + 1) ? 2 : 1, .text = src };
|
||||
Utf16DecodeResult decoded = uni_decode_utf16(decode_str);
|
||||
Utf8EncodeResult encoded = uni_encode_utf8(decoded.codepoint);
|
||||
u8 *dest = PushArrayNoZero(arena, u8, encoded.count8);
|
||||
u8 *dest = PushStructsNoZero(arena, u8, encoded.count8);
|
||||
for (u32 i = 0; i < encoded.count8; ++i)
|
||||
{
|
||||
u8 byte = encoded.chars8[i];
|
||||
@ -1242,7 +1242,7 @@ P_W32_Window *P_W32_AllocWindow(void)
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(window);
|
||||
ZeroStruct(window);
|
||||
|
||||
window->event_arenas[0] = AllocArena(Gibi(64));
|
||||
window->event_arenas[1] = AllocArena(Gibi(64));
|
||||
@ -1802,14 +1802,14 @@ LRESULT CALLBACK P_W32_Win32WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
|
||||
/* Read raw input buffer */
|
||||
UINT buff_size;
|
||||
GetRawInputData((HRAWINPUT)lparam, RID_INPUT, 0, &buff_size, sizeof(RAWINPUTHEADER));
|
||||
u8 *buff = PushArray(scratch.arena, u8, buff_size);
|
||||
u8 *buff = PushStructs(scratch.arena, u8, buff_size);
|
||||
if (GetRawInputData((HRAWINPUT)lparam, RID_INPUT, buff, &buff_size, sizeof(RAWINPUTHEADER)) != buff_size)
|
||||
{
|
||||
P_LogErrorF("GetRawInputData did not return correct size");
|
||||
break;
|
||||
}
|
||||
RAWINPUT raw = ZI;
|
||||
MEMCPY(&raw, buff, sizeof(RAWINPUT));
|
||||
CopyBytes(&raw, buff, sizeof(RAWINPUT));
|
||||
|
||||
if (raw.header.dwType == RIM_TYPEMOUSE)
|
||||
{
|
||||
@ -1859,7 +1859,7 @@ P_W32_Address P_W32_Win32AddressFromPlatformAddress(P_Address addr)
|
||||
res.size = sizeof(struct sockaddr_in);
|
||||
res.sin.sin_port = addr.portnb;
|
||||
res.sin.sin_family = res.family;
|
||||
MEMCPY(&res.sin.sin_addr, addr.ipnb, 4);
|
||||
CopyBytes(&res.sin.sin_addr, addr.ipnb, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1867,7 +1867,7 @@ P_W32_Address P_W32_Win32AddressFromPlatformAddress(P_Address addr)
|
||||
res.sin6.sin6_port = addr.portnb;
|
||||
res.sin6.sin6_family = res.family;
|
||||
res.size = sizeof(struct sockaddr_in6);
|
||||
MEMCPY(&res.sin6.sin6_addr.s6_addr, addr.ipnb, 16);
|
||||
CopyBytes(&res.sin6.sin6_addr.s6_addr, addr.ipnb, 16);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -1920,14 +1920,14 @@ P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr)
|
||||
{
|
||||
res.family = P_AddressFamily_Ipv4;
|
||||
res.portnb = ws_addr.sin.sin_port;
|
||||
MEMCPY(res.ipnb, &ws_addr.sin.sin_addr, 4);
|
||||
CopyBytes(res.ipnb, &ws_addr.sin.sin_addr, 4);
|
||||
res.valid = 1;
|
||||
}
|
||||
else if (ws_addr.family == AF_INET6)
|
||||
{
|
||||
res.family = P_AddressFamily_Ipv6;
|
||||
res.portnb = ws_addr.sin6.sin6_port;
|
||||
MEMCPY(res.ipnb, &ws_addr.sin6.sin6_addr.s6_addr, 16);
|
||||
CopyBytes(res.ipnb, &ws_addr.sin6.sin6_addr.s6_addr, 16);
|
||||
res.valid = 1;
|
||||
}
|
||||
return res;
|
||||
@ -2014,7 +2014,7 @@ void P_Run(i32 count, P_JobFunc *func, void *sig, P_Pool pool_kind, P_Priority p
|
||||
{
|
||||
info = PushStructNoZero(queue->arena, P_W32_JobInfo);
|
||||
}
|
||||
MEMZERO_STRUCT(info);
|
||||
ZeroStruct(info);
|
||||
info->count = count;
|
||||
info->func = func;
|
||||
info->sig = sig;
|
||||
@ -2281,7 +2281,7 @@ String P_ReadFile(Arena *arena, P_File file)
|
||||
/* ReadFile returns non-zero on success */
|
||||
/* TODO: error checking */
|
||||
AlignArena(arena, 16);
|
||||
s.text = PushArrayNoZero(arena, u8, size);
|
||||
s.text = PushStructsNoZero(arena, u8, size);
|
||||
(UNUSED)ReadFile(
|
||||
(HANDLE)file.handle,
|
||||
s.text,
|
||||
@ -2454,7 +2454,7 @@ P_Watch *P_AllocWatch(String dir_path)
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(w32_watch);
|
||||
ZeroStruct(w32_watch);
|
||||
|
||||
wchar_t *dir_path_wstr = wstr_from_string(scratch.arena, dir_path);
|
||||
w32_watch->dir_handle = CreateFileW(
|
||||
@ -2651,8 +2651,8 @@ P_WindowEventArray P_PopWindowEvents(Arena *arena, P_Window *p_window)
|
||||
Arena *events_arena = window->event_arenas[event_arena_index];
|
||||
P_WindowEventArray events = ZI;
|
||||
events.count = events_arena->pos / sizeof(P_WindowEvent);
|
||||
events.events = PushArrayNoZero(arena, P_WindowEvent, events.count);
|
||||
MEMCPY(events.events, ArenaBase(events_arena), events_arena->pos);
|
||||
events.events = PushStructsNoZero(arena, P_WindowEvent, events.count);
|
||||
CopyBytes(events.events, ArenaBase(events_arena), events_arena->pos);
|
||||
ResetArena(events_arena);
|
||||
return events;
|
||||
}
|
||||
@ -2788,7 +2788,7 @@ P_Address P_AddressFromIpPortCstr(char *ip_cstr, char *port_cstr)
|
||||
res.family = P_AddressFamily_Ipv4;
|
||||
res.portnb = sockaddr->sin_port;
|
||||
StaticAssert(sizeof(sockaddr->sin_addr) == 4);
|
||||
MEMCPY(res.ipnb, (void *)&sockaddr->sin_addr, 4);
|
||||
CopyBytes(res.ipnb, (void *)&sockaddr->sin_addr, 4);
|
||||
break;
|
||||
}
|
||||
else if (ai_res->ai_family == AF_INET6)
|
||||
@ -2800,7 +2800,7 @@ P_Address P_AddressFromIpPortCstr(char *ip_cstr, char *port_cstr)
|
||||
res.family = P_AddressFamily_Ipv6;
|
||||
res.portnb = sockaddr->sin6_port;
|
||||
StaticAssert(sizeof(sockaddr->sin6_addr) == 16);
|
||||
MEMCPY(res.ipnb, (void *)&sockaddr->sin6_addr, 16);
|
||||
CopyBytes(res.ipnb, (void *)&sockaddr->sin6_addr, 16);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
@ -2886,9 +2886,9 @@ P_Address P_AddressFromString(String str)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Copy address without port */
|
||||
/* CopyStruct address without port */
|
||||
ip_len = MinU64(str.len, countof(ip_buff) - 1);
|
||||
MEMCPY(ip_buff, str.text, ip_len);
|
||||
CopyBytes(ip_buff, str.text, ip_len);
|
||||
}
|
||||
if (ip_len > 0)
|
||||
{
|
||||
@ -2962,7 +2962,7 @@ String P_StringFromAddress(Arena *arena, P_Address address)
|
||||
|
||||
b32 P_AddressIsEqual(P_Address a, P_Address b)
|
||||
{
|
||||
return MEMEQ_STRUCT(&a, &b);
|
||||
return EqStruct(&a, &b);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@ -2985,7 +2985,7 @@ P_Sock *P_AllocSock(u16 listen_port, u64 sndbuf_size, u64 rcvbuf_size)
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(ws);
|
||||
ZeroStruct(ws);
|
||||
|
||||
P_Address addr = P_AddressFromPort(listen_port);
|
||||
P_W32_Address bind_address = P_W32_Win32AddressFromPlatformAddress(addr);
|
||||
@ -3023,7 +3023,7 @@ P_SockReadResult P_ReadSock(Arena *arena, P_Sock *sock)
|
||||
u64 read_buff_size = Kibi(64);
|
||||
String read_buff = ZI;
|
||||
read_buff.len = read_buff_size;
|
||||
read_buff.text = PushArrayNoZero(arena, u8, read_buff_size);
|
||||
read_buff.text = PushStructsNoZero(arena, u8, read_buff_size);
|
||||
|
||||
P_SockReadResult res = ZI;
|
||||
|
||||
@ -3132,7 +3132,7 @@ void P_SetClipboardText(String str)
|
||||
if (handle)
|
||||
{
|
||||
u16 *dest_wstr = (u16 *)GlobalLock(handle);
|
||||
MEMCPY(dest_wstr, str16.text, str16_size_bytes);
|
||||
CopyBytes(dest_wstr, str16.text, str16_size_bytes);
|
||||
dest_wstr[str16.len] = 0;
|
||||
GlobalUnlock(handle);
|
||||
SetClipboardData(CF_UNICODETEXT, handle);
|
||||
@ -3253,7 +3253,7 @@ void P_Panic(String msg)
|
||||
u64 wstr_len = 0;
|
||||
|
||||
wchar_t prefix[] = L"A fatal error has occured and the application needs to exit:\n\n";
|
||||
MEMCPY(wstr, prefix, MinU64(countof(g->panic_wstr), (countof(prefix) << 1)));
|
||||
CopyBytes(wstr, prefix, MinU64(countof(g->panic_wstr), (countof(prefix) << 1)));
|
||||
wstr_len += countof(prefix) - 1;
|
||||
|
||||
/* Perform manual string encode to avoid any implicit memory
|
||||
@ -3269,7 +3269,7 @@ void P_Panic(String msg)
|
||||
if (wstr_new_len < (countof(g->panic_wstr) - 1))
|
||||
{
|
||||
u16 *dest = wstr + wstr_len;
|
||||
MEMCPY(dest, encoded.chars16, (encoded.count16 << 1));
|
||||
CopyBytes(dest, encoded.chars16, (encoded.count16 << 1));
|
||||
wstr_len = wstr_new_len;
|
||||
pos8 += decoded.advance8;
|
||||
}
|
||||
@ -3302,7 +3302,7 @@ void P_Panic(String msg)
|
||||
void P_W32_InitBtnTable(void)
|
||||
{
|
||||
P_W32_SharedCtx *g = &P_W32_shared_ctx;
|
||||
MEMZERO_ARRAY(g->vk_btn_table);
|
||||
ZeroArray(g->vk_btn_table);
|
||||
|
||||
for (u32 i = 'A', j = P_Btn_A; i <= 'Z'; ++i, ++j)
|
||||
{
|
||||
@ -3392,7 +3392,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
||||
si.cb = sizeof(si);
|
||||
PROCESS_INFORMATION pi = ZI;
|
||||
wchar_t cmd[sizeof(ProfilingIsEnabled_CMD_WSTR)] = ZI;
|
||||
MEMCPY(cmd, ProfilingIsEnabled_CMD_WSTR, sizeof(ProfilingIsEnabled_CMD_WSTR));
|
||||
CopyBytes(cmd, ProfilingIsEnabled_CMD_WSTR, sizeof(ProfilingIsEnabled_CMD_WSTR));
|
||||
DeleteFileW(ProfilingIsEnabled_FILE_WSTR);
|
||||
b32 success = CreateProcessW(0, cmd, 0, 0, 0, DETACHED_PROCESS, 0, 0, &si, &pi);
|
||||
if (!success)
|
||||
@ -3428,7 +3428,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
u64 thread_name_len = wstr_len_no_limit(thread_name_wstr);
|
||||
if (thread_name_len >= prefix_name_wstr_len && MEMEQ(thread_name_wstr, prefix_name_wstr, prefix_name_wstr_len))
|
||||
if (thread_name_len >= prefix_name_wstr_len && EqBytes(thread_name_wstr, prefix_name_wstr, prefix_name_wstr_len))
|
||||
{
|
||||
__profn("Set profiler thread affinity");
|
||||
b32 success = SetThreadAffinityMask(thread, PROFILER_THREAD_AFFINITY_MASK) != 0;
|
||||
@ -3500,7 +3500,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
||||
}
|
||||
|
||||
u64 cmdline_len = wstr_len(cmdline_wstr, countof(g->cmdline_args_wstr) - 1);
|
||||
MEMCPY(g->cmdline_args_wstr, cmdline_wstr, cmdline_len * sizeof(*cmdline_wstr));
|
||||
CopyBytes(g->cmdline_args_wstr, cmdline_wstr, cmdline_len * sizeof(*cmdline_wstr));
|
||||
g->cmdline_args_wstr[cmdline_len] = 0;
|
||||
|
||||
g->main_thread_id = GetCurrentThreadId();
|
||||
@ -3619,8 +3619,8 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
||||
} break;
|
||||
}
|
||||
pool->worker_threads_arena = AllocArena(Gibi(64));
|
||||
pool->worker_threads = PushArray(pool->worker_threads_arena, P_W32_Thread *, pool->num_worker_threads);
|
||||
pool->worker_contexts = PushArray(pool->worker_threads_arena, P_W32_WorkerCtx, pool->num_worker_threads);
|
||||
pool->worker_threads = PushStructs(pool->worker_threads_arena, P_W32_Thread *, pool->num_worker_threads);
|
||||
pool->worker_contexts = PushStructs(pool->worker_threads_arena, P_W32_WorkerCtx, pool->num_worker_threads);
|
||||
for (i32 i = 0; i < pool->num_worker_threads; ++i)
|
||||
{
|
||||
P_W32_WorkerCtx *ctx = &pool->worker_contexts[i];
|
||||
|
||||
@ -189,10 +189,10 @@ internal void wasapi_update_end(struct wasapi_buffer *wspbuf, M_PcmF32 src)
|
||||
|
||||
u32 flags = 0;
|
||||
if (frames_in_source == frames_in_output) {
|
||||
/* Copy bytes to output */
|
||||
/* CopyStruct bytes to output */
|
||||
u32 bytes_per_sample = G.buffer_format->nBlockAlign / G.buffer_format->nChannels;
|
||||
u32 write_size = frames_in_source * 2 * bytes_per_sample;
|
||||
MEMCPY(wspbuf->frames, src.samples, write_size);
|
||||
CopyBytes(wspbuf->frames, src.samples, write_size);
|
||||
} else {
|
||||
/* Submit silence if not enough samples */
|
||||
flags = AUDCLNT_BUFFERFLAGS_SILENT;
|
||||
|
||||
@ -62,7 +62,7 @@ R_Resource resource_open(String name)
|
||||
path_text[2] = 's';
|
||||
path_text[3] = '/';
|
||||
u64 path_text_len = 4;
|
||||
MEMCPY(path_text + path_text_len, name.text, name.len);
|
||||
CopyBytes(path_text + path_text_len, name.text, name.len);
|
||||
path_text_len += name.len;
|
||||
path = STRING(path_text_len, path_text);
|
||||
}
|
||||
@ -86,7 +86,7 @@ R_Resource resource_open(String name)
|
||||
res._file = file;
|
||||
res._file_map = file_map;
|
||||
res._name_len = name.len;
|
||||
MEMCPY(res._name_text, name.text, name.len);
|
||||
CopyBytes(res._name_text, name.text, name.len);
|
||||
} else {
|
||||
Assert(0);
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ ClientStore *sim_client_store_alloc(void)
|
||||
}
|
||||
store->valid = 1;
|
||||
store->num_client_lookup_bins = CLIENT_LOOKUP_BINS;
|
||||
store->client_lookup_bins = PushArray(store->arena, ClientLookupBin, store->num_client_lookup_bins);
|
||||
store->client_lookup_bins = PushStructs(store->arena, ClientLookupBin, store->num_client_lookup_bins);
|
||||
store->clients_arena = AllocArena(Gibi(64));
|
||||
store->clients = PushDry(store->clients_arena, Client);
|
||||
return store;
|
||||
@ -151,7 +151,7 @@ Client *sim_client_alloc(ClientStore *store)
|
||||
|
||||
client->snapshots_arena = AllocArena(Gibi(8));
|
||||
client->num_snapshot_lookup_bins = TICK_LOOKUP_BINS;
|
||||
client->snapshot_lookup_bins = PushArray(client->snapshots_arena, SnapshotLookupBin, client->num_snapshot_lookup_bins);
|
||||
client->snapshot_lookup_bins = PushStructs(client->snapshots_arena, SnapshotLookupBin, client->num_snapshot_lookup_bins);
|
||||
|
||||
return client;
|
||||
}
|
||||
@ -303,29 +303,29 @@ Snapshot *sim_snapshot_alloc(Client *client, Snapshot *src, u64 tick)
|
||||
ss->client = client;
|
||||
++client->num_ticks;
|
||||
|
||||
/* Copy src info */
|
||||
/* CopyStruct src info */
|
||||
ss->sim_dt_ns = src->sim_dt_ns;
|
||||
ss->sim_time_ns = src->sim_time_ns;
|
||||
ss->continuity_gen = src->continuity_gen;
|
||||
ss->local_player = src->local_player;
|
||||
ss->phys_iteration = src->phys_iteration;
|
||||
|
||||
/* Copy id lookup bins */
|
||||
/* CopyStruct id lookup bins */
|
||||
ss->num_id_bins = src->num_id_bins > 0 ? src->num_id_bins : ID_LOOKUP_BINS;
|
||||
ss->id_bins = PushArrayNoZero(ss->arena, EntBin, ss->num_id_bins);
|
||||
ss->id_bins = PushStructsNoZero(ss->arena, EntBin, ss->num_id_bins);
|
||||
if (src->num_id_bins > 0) {
|
||||
for (u64 i = 0; i < src->num_id_bins; ++i) {
|
||||
ss->id_bins[i] = src->id_bins[i];
|
||||
}
|
||||
} else {
|
||||
MEMZERO(ss->id_bins, sizeof(*ss->id_bins) * ss->num_id_bins);
|
||||
ZeroBytes(ss->id_bins, sizeof(*ss->id_bins) * ss->num_id_bins);
|
||||
}
|
||||
|
||||
/* Copy entities */
|
||||
/* CopyStruct entities */
|
||||
ss->first_free_ent = src->first_free_ent;
|
||||
ss->num_ents_allocated = src->num_ents_allocated;
|
||||
ss->num_ents_reserved = src->num_ents_reserved;
|
||||
ss->ents = PushArrayNoZero(ss->ents_arena, Ent, ss->num_ents_reserved);
|
||||
ss->ents = PushStructsNoZero(ss->ents_arena, Ent, ss->num_ents_reserved);
|
||||
if (ss->num_ents_reserved == 0) {
|
||||
/* Copying from nil snapshot, need to create blank & root entity */
|
||||
|
||||
@ -689,7 +689,7 @@ void sim_snapshot_sync_ents(Snapshot *local_ss, Snapshot *remote_ss, EntId remot
|
||||
if (should_sync) {
|
||||
Ent *remote_ent = sim_ent_from_id(remote_ss, local_ent->id);
|
||||
if (remote_ent->valid) {
|
||||
/* Copy all ent data from remote */
|
||||
/* CopyStruct all ent data from remote */
|
||||
sim_ent_sync(local_ent, remote_ent);
|
||||
} else {
|
||||
/* Remote ent is no longer valid / networked, release it */
|
||||
@ -838,7 +838,7 @@ void sim_snapshot_decode(BB_Reader *br, Snapshot *ss)
|
||||
ss->num_ents_reserved = BB_ReadUV(br);
|
||||
i64 reserve_diff = (i64)ss->num_ents_reserved - (i64)old_num_ents_reserved;
|
||||
if (reserve_diff > 0) {
|
||||
PushArrayNoZero(ss->ents_arena, Ent, reserve_diff);
|
||||
PushStructsNoZero(ss->ents_arena, Ent, reserve_diff);
|
||||
for (u64 i = old_num_ents_reserved; i < ss->num_ents_reserved; ++i) {
|
||||
Ent *e = &ss->ents[i];
|
||||
*e = *sim_ent_nil();
|
||||
@ -959,7 +959,7 @@ void sim_snapshot_decode(BB_Reader *br, Snapshot *ss)
|
||||
ss->num_ents_reserved = BB_ReadUV(br);
|
||||
i64 reserve_diff = (i64)ss->num_ents_reserved - (i64)old_num_ents_reserved;
|
||||
if (reserve_diff > 0) {
|
||||
PushArrayNoZero(ss->ents_arena, Ent, reserve_diff);
|
||||
PushStructsNoZero(ss->ents_arena, Ent, reserve_diff);
|
||||
for (u64 i = old_num_ents_reserved; i < ss->num_ents_reserved; ++i) {
|
||||
Ent *e = &ss->ents[i];
|
||||
*e = *sim_ent_nil();
|
||||
@ -1056,7 +1056,7 @@ void sim_snapshot_decode(BB_Reader *br, Snapshot *ss)
|
||||
ss->num_ents_reserved = BB_ReadUV(br);
|
||||
i64 reserve_diff = (i64)ss->num_ents_reserved - (i64)old_num_ents_reserved;
|
||||
if (reserve_diff > 0) {
|
||||
PushArrayNoZero(ss->ents_arena, Ent, reserve_diff);
|
||||
PushStructsNoZero(ss->ents_arena, Ent, reserve_diff);
|
||||
for (u64 i = old_num_ents_reserved; i < ss->num_ents_reserved; ++i) {
|
||||
Ent *e = &ss->ents[i];
|
||||
*e = *sim_ent_nil();
|
||||
|
||||
@ -646,7 +646,7 @@ void sim_ent_sync_alloc_tree(Ent *local_parent, Ent *remote, EntId remote_player
|
||||
void sim_ent_sync(Ent *local, Ent *remote)
|
||||
{
|
||||
Ent old = *local;
|
||||
MEMCPY_STRUCT(local, remote);
|
||||
CopyStruct(local, remote);
|
||||
|
||||
/* Why would 2 ents w/ different uids ever be synced? */
|
||||
Assert(sim_ent_id_eq(local->id, old.id));
|
||||
@ -700,9 +700,9 @@ void sim_ent_encode(BB_Writer *bw, Ent *e0, Ent *e1)
|
||||
u64 chunk_size = MinU64(pos + 8, sizeof(*e1)) - pos;
|
||||
u8 *chunk0 = (u8 *)e0 + pos;
|
||||
u8 *chunk1 = (u8 *)e1 + pos;
|
||||
if (BB_WriteBit(bw, !MEMEQ(chunk0, chunk1, chunk_size))) {
|
||||
if (BB_WriteBit(bw, !EqBytes(chunk0, chunk1, chunk_size))) {
|
||||
u64 bits = 0;
|
||||
MEMCPY(&bits, chunk1, chunk_size);
|
||||
CopyBytes(&bits, chunk1, chunk_size);
|
||||
BB_WriteUBits(bw, bits, 64);
|
||||
}
|
||||
pos += 8;
|
||||
@ -724,7 +724,7 @@ void sim_ent_decode(BB_Reader *br, Ent *e)
|
||||
if (BB_ReadBit(br)) {
|
||||
u64 chunk_size = MinU64(pos + 8, sizeof(*e)) - pos;
|
||||
u64 bits = BB_ReadUBits(br, 64);
|
||||
MEMCPY(chunk, &bits, chunk_size);
|
||||
CopyBytes(chunk, &bits, chunk_size);
|
||||
}
|
||||
pos += 8;
|
||||
}
|
||||
@ -755,12 +755,12 @@ void sim_ent_encode(BB_Writer *bw, Ent *e0, Ent *e1)
|
||||
u64 chunk_size = MinU64(pos + 8, sizeof(*e1)) - pos;
|
||||
u8 *chunk0 = (u8 *)e0 + pos;
|
||||
u8 *chunk1 = (u8 *)e1 + pos;
|
||||
if (MEMEQ(chunk0, chunk1, chunk_size)) {
|
||||
if (EqBytes(chunk0, chunk1, chunk_size)) {
|
||||
BB_WriteBit(bw, 0);
|
||||
} else {
|
||||
BB_WriteBit(bw, 1);
|
||||
u64 bits = 0;
|
||||
MEMCPY(&bits, chunk1, chunk_size);
|
||||
CopyBytes(&bits, chunk1, chunk_size);
|
||||
BB_WriteUBits(bw, bits, 64);
|
||||
}
|
||||
pos += 8;
|
||||
@ -782,7 +782,7 @@ void sim_ent_decode(BB_Reader *br, Ent *e)
|
||||
if (BB_ReadBit(br)) {
|
||||
u64 chunk_size = MinU64(pos + 8, sizeof(decoded)) - pos;
|
||||
u64 bits = BB_ReadUBits(br, 64);
|
||||
MEMCPY(chunk, &bits, chunk_size);
|
||||
CopyBytes(chunk, &bits, chunk_size);
|
||||
}
|
||||
pos += 8;
|
||||
}
|
||||
@ -791,7 +791,7 @@ void sim_ent_decode(BB_Reader *br, Ent *e)
|
||||
|
||||
EntId old_id = e->id;
|
||||
EntId new_id = decoded.id;
|
||||
MEMCPY_STRUCT(e, &decoded);
|
||||
CopyStruct(e, &decoded);
|
||||
e->id = old_id;
|
||||
if (!sim_ent_id_eq(old_id, new_id)) {
|
||||
sim_ent_set_id(e, new_id);
|
||||
|
||||
@ -145,7 +145,7 @@ void phys_create_and_update_contacts(PhysStepCtx *ctx, f32 elapsed_dt, u64 phys_
|
||||
if (!contact) {
|
||||
/* Insert */
|
||||
contact = &constraint->points[constraint->num_points++];
|
||||
MEMZERO_STRUCT(contact);
|
||||
ZeroStruct(contact);
|
||||
contact->id = id;
|
||||
constraint->pushout_velocity = 3.0f;
|
||||
}
|
||||
@ -243,7 +243,7 @@ void phys_create_and_update_contacts(PhysStepCtx *ctx, f32 elapsed_dt, u64 phys_
|
||||
dbg->res = collider_res;
|
||||
|
||||
if (constraint) {
|
||||
MEMCPY(dbg->points, constraint->points, sizeof(dbg->points));
|
||||
CopyBytes(dbg->points, constraint->points, sizeof(dbg->points));
|
||||
dbg->num_points = constraint->num_points;
|
||||
} else {
|
||||
dbg->num_points = 0;
|
||||
|
||||
@ -31,7 +31,7 @@ Space *space_alloc(f32 cell_size, u32 num_bins_sqrt)
|
||||
space->cell_size = cell_size;
|
||||
space->num_bins = num_bins_sqrt * num_bins_sqrt;
|
||||
space->num_bins_sqrt = num_bins_sqrt;
|
||||
space->bins = PushArray(space->cell_arena, SpaceCellBin, space->num_bins);
|
||||
space->bins = PushStructs(space->cell_arena, SpaceCellBin, space->num_bins);
|
||||
|
||||
return space;
|
||||
}
|
||||
@ -46,7 +46,7 @@ void space_reset(Space *space)
|
||||
{
|
||||
PopTo(space->entry_arena, (u64)space->entries - (u64)ArenaBase(space->entry_arena));
|
||||
ResetArena(space->cell_arena);
|
||||
space->bins = PushArray(space->cell_arena, SpaceCellBin, space->num_bins);
|
||||
space->bins = PushStructs(space->cell_arena, SpaceCellBin, space->num_bins);
|
||||
space->num_entries_reserved = 0;
|
||||
space->first_free_cell = 0;
|
||||
space->first_free_cell_node = 0;
|
||||
@ -137,7 +137,7 @@ internal void space_cell_node_alloc(Vec2I32 cell_pos, SpaceEntry *entry)
|
||||
} else {
|
||||
cell = PushStructNoZero(space->cell_arena, SpaceCell);
|
||||
}
|
||||
MEMZERO_STRUCT(cell);
|
||||
ZeroStruct(cell);
|
||||
if (bin->last_cell) {
|
||||
bin->last_cell->next_in_bin = cell;
|
||||
cell->prev_in_bin = bin->last_cell;
|
||||
@ -159,7 +159,7 @@ internal void space_cell_node_alloc(Vec2I32 cell_pos, SpaceEntry *entry)
|
||||
} else {
|
||||
node = PushStructNoZero(space->cell_arena, SpaceCellNode);
|
||||
}
|
||||
MEMZERO_STRUCT(node);
|
||||
ZeroStruct(node);
|
||||
}
|
||||
|
||||
/* Insert into cell list */
|
||||
@ -281,7 +281,7 @@ SpaceEntry *space_entry_alloc(Space *space, EntId ent)
|
||||
handle.gen = 1;
|
||||
++space->num_entries_reserved;
|
||||
}
|
||||
MEMZERO_STRUCT(entry);
|
||||
ZeroStruct(entry);
|
||||
entry->valid = 1;
|
||||
entry->handle = handle;
|
||||
entry->ent = ent;
|
||||
|
||||
@ -22,7 +22,7 @@ void sim_accel_reset(Snapshot *ss, SimAccel *accel)
|
||||
for (u64 sim_ent_index = 0; sim_ent_index < ss->num_ents_reserved; ++sim_ent_index) {
|
||||
Ent *ent = &ss->ents[sim_ent_index];
|
||||
if (ent->valid) {
|
||||
MEMZERO_STRUCT(&ent->space_handle);
|
||||
ZeroStruct(&ent->space_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -457,8 +457,8 @@ internal void test_generate_walls(Snapshot *world)
|
||||
sim_ent_enable_prop(ent, SEPROP_RELEASE);
|
||||
}
|
||||
}
|
||||
y_sorted_tile_chunks = PushArrayNoZero(scratch.arena, Ent *, sorted_tile_chunks_count);
|
||||
MEMCPY(y_sorted_tile_chunks, x_sorted_tile_chunks, sizeof(*x_sorted_tile_chunks) * sorted_tile_chunks_count);
|
||||
y_sorted_tile_chunks = PushStructsNoZero(scratch.arena, Ent *, sorted_tile_chunks_count);
|
||||
CopyBytes(y_sorted_tile_chunks, x_sorted_tile_chunks, sizeof(*x_sorted_tile_chunks) * sorted_tile_chunks_count);
|
||||
|
||||
/* NOTE: We sort x & y separately because it's possible that a wall
|
||||
* should merge with another wall that was generated from a diagonal chunk. */
|
||||
|
||||
@ -110,16 +110,16 @@ internal P_JobDef(sound_load_asset_job, job)
|
||||
{
|
||||
AC_Store store = asset_cache_store_open();
|
||||
sound = PushStructNoZero(store.arena, SND_Sound);
|
||||
samples = PushArrayNoZero(store.arena, i16, samples_count);
|
||||
samples = PushStructsNoZero(store.arena, i16, samples_count);
|
||||
asset_cache_store_close(&store);
|
||||
}
|
||||
|
||||
/* Initialize */
|
||||
MEMZERO_STRUCT(sound);
|
||||
ZeroStruct(sound);
|
||||
sound->flags = flags;
|
||||
sound->samples_count = samples_count;
|
||||
sound->samples = samples;
|
||||
MEMCPY(sound->samples, decoded.samples, decoded.samples_count * sizeof(*decoded.samples));
|
||||
CopyBytes(sound->samples, decoded.samples, decoded.samples_count * sizeof(*decoded.samples));
|
||||
|
||||
P_LogSuccessF("Loaded sound \"%F\" in %F seconds", FMT_STR(path), FMT_FLOAT(SecondsFromNs(P_TimeNs() - start_ns)));
|
||||
asset_cache_mark_ready(asset, sound);
|
||||
|
||||
@ -150,7 +150,7 @@ Global struct {
|
||||
|
||||
internal u32 *generate_purple_black_image(Arena *arena, u32 width, u32 height)
|
||||
{
|
||||
u32 *pixels = PushArrayNoZero(arena, u32, width * height);
|
||||
u32 *pixels = PushStructsNoZero(arena, u32, width * height);
|
||||
|
||||
/* Create texture containing alternating blocks of purple and black */
|
||||
u32 color_size = 4;
|
||||
@ -224,7 +224,7 @@ S_StartupReceipt sprite_startup(void)
|
||||
SetArenaReadonly(G.perm_arena);
|
||||
|
||||
G.cache.arena = AllocArena(Gibi(64));
|
||||
G.cache.bins = PushArray(G.cache.arena, struct cache_bin, CACHE_BINS_COUNT);
|
||||
G.cache.bins = PushStructs(G.cache.arena, struct cache_bin, CACHE_BINS_COUNT);
|
||||
|
||||
G.load_cmds_arena = AllocArena(Gibi(64));
|
||||
|
||||
@ -297,7 +297,7 @@ internal void push_load_job(struct cache_ref ref, S_Tag tag)
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(cmd);
|
||||
ZeroStruct(cmd);
|
||||
|
||||
/* Initialize cmd */
|
||||
cmd->scope = sprite_scope_begin();
|
||||
@ -306,7 +306,7 @@ internal void push_load_job(struct cache_ref ref, S_Tag tag)
|
||||
{
|
||||
u64 copy_len = MinU64(tag.path.len, countof(cmd->tag_path_buff));
|
||||
cmd->tag.path.text = cmd->tag_path_buff;
|
||||
MEMCPY(cmd->tag.path.text, tag.path.text, copy_len);
|
||||
CopyBytes(cmd->tag.path.text, tag.path.text, copy_len);
|
||||
}
|
||||
|
||||
/* PushStruct work */
|
||||
@ -405,7 +405,7 @@ internal S_Sheet init_sheet_from_ase_result(Arena *arena, Ase_DecodedSheet ase)
|
||||
__profn("Init frames");
|
||||
sheet.image_size = ase.image_size;
|
||||
sheet.frame_size = ase.frame_size;
|
||||
sheet.frames = PushArray(arena, S_SheetFrame, ase.num_frames);
|
||||
sheet.frames = PushStructs(arena, S_SheetFrame, ase.num_frames);
|
||||
sheet.frames_count = ase.num_frames;
|
||||
for (Ase_Frame *ase_frame = ase.frame_head; ase_frame; ase_frame = ase_frame->next) {
|
||||
u32 index = ase_frame->index;
|
||||
@ -425,7 +425,7 @@ internal S_Sheet init_sheet_from_ase_result(Arena *arena, Ase_DecodedSheet ase)
|
||||
sheet.spans_count = ase.num_spans;
|
||||
if (ase.num_spans > 0) {
|
||||
__profn("Init spans");
|
||||
sheet.spans = PushArray(arena, S_SheetSpan, sheet.spans_count);
|
||||
sheet.spans = PushStructs(arena, S_SheetSpan, sheet.spans_count);
|
||||
sheet.spans_dict = dict_init(arena, (u64)(ase.num_spans * SHEET_SPAN_LOOKUP_TABLE_BIN_RATIO));
|
||||
u64 index = 0;
|
||||
for (Ase_Span *ase_span = ase.span_head; ase_span; ase_span = ase_span->next) {
|
||||
@ -494,7 +494,7 @@ internal S_Sheet init_sheet_from_ase_result(Arena *arena, Ase_DecodedSheet ase)
|
||||
|
||||
/* Allocate slice groups & fill originals in 2d array */
|
||||
sheet.slice_groups_count = num_temp_slice_group_nodes;
|
||||
sheet.slice_groups = PushArray(arena, S_SheetSliceGroup, sheet.slice_groups_count);
|
||||
sheet.slice_groups = PushStructs(arena, S_SheetSliceGroup, sheet.slice_groups_count);
|
||||
sheet.slice_groups_dict = dict_init(arena, (u64)(num_temp_slice_group_nodes * SHEET_SLICE_LOOKUP_TABLE_BIN_RATIO));
|
||||
|
||||
u64 index = 0;
|
||||
@ -503,7 +503,7 @@ internal S_Sheet init_sheet_from_ase_result(Arena *arena, Ase_DecodedSheet ase)
|
||||
slice_group->name = string_copy(arena, temp_slice_group_node->name);
|
||||
slice_group->per_frame_count = temp_slice_group_node->per_frame_count;
|
||||
|
||||
slice_group->frame_slices = PushArray(arena, S_SheetSlice, ase.num_frames * slice_group->per_frame_count);
|
||||
slice_group->frame_slices = PushStructs(arena, S_SheetSlice, ase.num_frames * slice_group->per_frame_count);
|
||||
|
||||
u64 index_in_frame = 0;
|
||||
for (struct temp_ase_slice_key_node *node = temp_slice_group_node->temp_ase_slice_key_head; node; node = node->next) {
|
||||
@ -757,7 +757,7 @@ internal struct sprite_scope_cache_ref *scope_ensure_ref_unsafe(S_Scope *scope,
|
||||
|
||||
/* Grab node from pool */
|
||||
struct sprite_scope_cache_ref *scope_ref = &scope->ref_node_pool[scope->num_references++];
|
||||
MEMZERO_STRUCT(scope_ref);
|
||||
ZeroStruct(scope_ref);
|
||||
scope_ref->ref.e = e;
|
||||
|
||||
*slot = scope_ref;
|
||||
@ -795,14 +795,14 @@ S_Scope *sprite_scope_begin(void)
|
||||
pool = res->ref_node_pool;
|
||||
} else {
|
||||
res = PushStructNoZero(G.scopes_arena, S_Scope);
|
||||
bins = PushArrayNoZero(G.scopes_arena, struct sprite_scope_cache_ref *, CACHE_BINS_COUNT);
|
||||
pool = PushArrayNoZero(G.scopes_arena, struct sprite_scope_cache_ref, MAX_SCOPE_REFERENCES);
|
||||
bins = PushStructsNoZero(G.scopes_arena, struct sprite_scope_cache_ref *, CACHE_BINS_COUNT);
|
||||
pool = PushStructsNoZero(G.scopes_arena, struct sprite_scope_cache_ref, MAX_SCOPE_REFERENCES);
|
||||
}
|
||||
}
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
MEMZERO_STRUCT(res);
|
||||
MEMZERO(bins, sizeof(*bins) * CACHE_BINS_COUNT);
|
||||
ZeroStruct(res);
|
||||
ZeroBytes(bins, sizeof(*bins) * CACHE_BINS_COUNT);
|
||||
res->ref_node_bins = bins;
|
||||
res->ref_node_pool = pool;
|
||||
return res;
|
||||
@ -919,7 +919,7 @@ internal struct sprite_scope_cache_ref *cache_entry_from_tag(S_Scope *scope, S_T
|
||||
}
|
||||
P_Unlock(&pool_lock);
|
||||
}
|
||||
MEMZERO_STRUCT(entry);
|
||||
ZeroStruct(entry);
|
||||
|
||||
/* Init entry and add to bin */
|
||||
{
|
||||
|
||||
@ -152,7 +152,7 @@ TTF_Result ttf_decode(Arena *arena, String encoded, f32 point_size, u32 *cache_c
|
||||
}
|
||||
|
||||
/* Allocate font memory */
|
||||
TTF_Glyph *glyphs = (TTF_Glyph *)PushArray(arena, TTF_Glyph, glyph_count);
|
||||
TTF_Glyph *glyphs = (TTF_Glyph *)PushStructs(arena, TTF_Glyph, glyph_count);
|
||||
|
||||
/* Allocate (starting) atlas memory
|
||||
* NOTE: This is unecessary since atlas memory will grow anyway. Could
|
||||
@ -160,7 +160,7 @@ TTF_Result ttf_decode(Arena *arena, String encoded, f32 point_size, u32 *cache_c
|
||||
*/
|
||||
u64 atlas_w = 1024;
|
||||
u64 atlas_h = 1;
|
||||
u32 *atlas_memory = PushArray(arena, u32, atlas_w * atlas_h);
|
||||
u32 *atlas_memory = PushStructs(arena, u32, atlas_w * atlas_h);
|
||||
|
||||
/* Fill CPU side atlas & metric data */
|
||||
u32 out_offset_x = 0;
|
||||
@ -229,7 +229,7 @@ TTF_Result ttf_decode(Arena *arena, String encoded, f32 point_size, u32 *cache_c
|
||||
u64 diff = (out_offset_y + tex_h) - atlas_h;
|
||||
/* NOTE: This allocation must be contiguous with the initial atlas
|
||||
* allocation (IE: No non-atlas arena PUSHes) */
|
||||
PushArray(arena, u32, diff * atlas_w);
|
||||
PushStructs(arena, u32, diff * atlas_w);
|
||||
atlas_h += diff;
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ TTF_Result ttf_decode(Arena *arena, String encoded, f32 point_size, u32 *cache_c
|
||||
/* Construct indices array */
|
||||
u16 *cache_indices = 0;
|
||||
if (cache_codes_count > 0) {
|
||||
cache_indices = PushArray(arena, u16, cache_codes_count);
|
||||
cache_indices = PushStructs(arena, u16, cache_codes_count);
|
||||
font_face->GetGlyphIndices(cache_codes, cache_codes_count, cache_indices);
|
||||
}
|
||||
|
||||
|
||||
@ -423,7 +423,7 @@ internal void draw_debug_console(i32 level, b32 minimized)
|
||||
f32 bg_margin = 5;
|
||||
|
||||
LocalPersist u32 colors[P_LogLevel_Count][2] = ZI;
|
||||
MEMSET(colors, 0xFF, sizeof(colors));
|
||||
SetBytes(colors, 0xFF, sizeof(colors));
|
||||
#if 1
|
||||
colors[P_LogLevel_Debug][0] = Rgb32F(0.4, 0.1, 0.4); colors[P_LogLevel_Debug][1] = Rgb32F(0.5, 0.2, 0.5);
|
||||
colors[P_LogLevel_Info][0] = Rgb32F(0.4, 0.4, 0.4); colors[P_LogLevel_Info][1] = Rgb32F(0.5, 0.5, 0.5);
|
||||
@ -1137,7 +1137,7 @@ internal void user_update(P_Window *window)
|
||||
Ent **sorted = PushDry(scratch.arena, Ent *);
|
||||
u64 sorted_count = 0;
|
||||
{
|
||||
/* Copy valid entities */
|
||||
/* CopyStruct valid entities */
|
||||
{
|
||||
__profn("Build ents list for sorting");
|
||||
for (u64 ent_index = 0; ent_index < G.ss_blended->num_ents_reserved; ++ent_index) {
|
||||
@ -2745,7 +2745,7 @@ internal P_JobDef(local_sim_job, _)
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy local snapshot to user client */
|
||||
/* CopyStruct local snapshot to user client */
|
||||
{
|
||||
Snapshot *local_ss = sim_snapshot_from_tick(local_client, local_client->last_tick);
|
||||
if (local_ss->valid) {
|
||||
|
||||
@ -180,7 +180,7 @@ internal P_JobDef(watch_dispatcher_job, _)
|
||||
P_Lock callbacks_lock = P_LockS(&G.watch_callbacks_mutex);
|
||||
{
|
||||
num_callbacks = G.num_watch_callbacks;
|
||||
callbacks = PushArrayNoZero(scratch.arena, watch_callback *, num_callbacks);
|
||||
callbacks = PushStructsNoZero(scratch.arena, watch_callback *, num_callbacks);
|
||||
for (u64 i = 0; i < num_callbacks; ++i) {
|
||||
callbacks[i] = G.watch_callbacks[i];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user