'ZI' -> 'Zi'

This commit is contained in:
jacob 2025-12-16 16:46:25 -06:00
parent af3687f3e5
commit 1de54d60ba
35 changed files with 381 additions and 374 deletions

View File

@ -159,12 +159,12 @@ u32 ASE_ReverseBits(u32 v, u32 bit_count)
ASE_HuffDict ASE_InitHuffDict(Arena *arena, u32 max_code_bits, u32 *bl_counts, u32 bl_counts_count)
{
ASE_HuffDict result = ZI;
ASE_HuffDict result = Zi;
result.max_code_bits = max_code_bits;
result.entries_count = (1 << max_code_bits);
result.entries = PushStructsNoZero(arena, ASE_HuffEntry, result.entries_count);
u32 code_length_hist[ASE_HuffBitCount] = ZI;
u32 code_length_hist[ASE_HuffBitCount] = Zi;
for (u32 i = 0; i < bl_counts_count; ++i)
{
u32 count = bl_counts[i];
@ -172,7 +172,7 @@ ASE_HuffDict ASE_InitHuffDict(Arena *arena, u32 max_code_bits, u32 *bl_counts, u
++code_length_hist[count];
}
u32 next_code[ASE_HuffBitCount] = ZI;
u32 next_code[ASE_HuffBitCount] = Zi;
next_code[0] = 0;
code_length_hist[0] = 0;
for (u32 i = 1; i < countof(next_code); ++i)
@ -260,7 +260,7 @@ void ASE_Inflate(u8 *dst, u8 *encoded)
case ASE_BlockType_CompressedDynamic:
{
TempArena temp = BeginTempArena(scratch.arena);
u32 lit_len_dist_table[512] = ZI;
u32 lit_len_dist_table[512] = Zi;
u32 hlit;
u32 hdist;
@ -274,7 +274,7 @@ void ASE_Inflate(u8 *dst, u8 *encoded)
u32 hclen = ASE_ConsumeBits(&bb, 4) + 4;
/* Init dict huffman (hclen) */
u32 hclen_bl_counts[19] = ZI;
u32 hclen_bl_counts[19] = Zi;
for (u32 i = 0; i < hclen; ++i)
{
u32 code = ASE_huff_hclen_order[i];
@ -482,7 +482,7 @@ void ASE_MakeDimensionsSquareish(ASE_Header *header, u32 *frames_x, u32 *frames_
ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded)
{
TempArena scratch = BeginScratch(arena);
ASE_DecodedImage result = ZI;
ASE_DecodedImage result = Zi;
BB_Buff bb = BB_BuffFromString(encoded);
BB_Reader br = BB_ReaderFromBuffNoDebug(&bb);
@ -773,7 +773,7 @@ abort:
ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded)
{
ASE_DecodedSheet result = ZI;
ASE_DecodedSheet result = Zi;
BB_Buff bb = BB_BuffFromString(encoded);
BB_Reader br = BB_ReaderFromBuffNoDebug(&bb);

View File

@ -155,11 +155,11 @@
////////////////////////////////////////////////////////////
//~ Common utility macros
//- ZeroStruct initialization macro
//- Zero initialization
#if IsLanguageC
#define ZI { 0 }
#define Zi { 0 }
#else
#define ZI { }
#define Zi { }
#endif
//- Inline

View File

@ -180,7 +180,7 @@ void *ArenaNext_(Arena *arena, u64 align)
TempArena BeginTempArena(Arena *arena)
{
TempArena t = ZI;
TempArena t = Zi;
t.arena = arena;
t.start_pos = arena->pos;
return t;

View File

@ -36,7 +36,7 @@ void SignalAsyncTick(void)
void AsyncWorkerEntryPoint(WaveLaneCtx *lane)
{
AsyncTickCtx tick = ZI;
AsyncTickCtx tick = Zi;
tick.arena = AcquireArena(Gibi(64));
/* Tick forever */

View File

@ -5,7 +5,7 @@
BB_Buff BB_AcquireBuff(u64 arena_reserve)
{
BB_Buff result = ZI;
BB_Buff result = Zi;
result.arena = AcquireArena(arena_reserve);
result.is_backed_by_arena = 1;
return result;
@ -22,7 +22,7 @@ void BB_ReleaseBuff(BB_Buff *bb)
BB_Buff BB_BuffFromString(String s)
{
BB_Buff result = ZI;
BB_Buff result = Zi;
result.fixed_buffer = s;
return result;
}
@ -32,7 +32,7 @@ BB_Buff BB_BuffFromString(String s)
BB_Writer BB_WriterFromBuff(BB_Buff *bb)
{
BB_Writer result = ZI;
BB_Writer result = Zi;
result.bb = bb;
if (bb->is_backed_by_arena)
{
@ -74,7 +74,7 @@ u64 BB_GetNumBytesWritten(BB_Writer *bw)
/* FIXME: Handle overflowed bw */
String BB_GetWritten(Arena *arena, BB_Writer *bw)
{
String result = ZI;
String result = Zi;
result.len = (bw->cur_bit + 7) >> 3;
result.text = PushStructsNoZero(arena, u8, result.len);
CopyBytes(result.text, bw->base, result.len);
@ -378,7 +378,7 @@ void BB_WriteDebugMagic(BB_Writer *bw, BB_DebugMagicKind magic, u8 num_bits)
BB_Reader BB_ReaderFromBuff(BB_Buff *bb)
{
BB_Reader result = ZI;
BB_Reader result = Zi;
if (!bb->is_backed_by_arena)
{
result.base = bb->fixed_buffer.text;
@ -651,7 +651,7 @@ Uid BB_ReadUid(BB_Reader *br)
String BB_ReadString(Arena *arena, BB_Reader *br)
{
BB_ReadDebugMagic(br, BB_DebugMagicKind_String, 0);
String result = ZI;
String result = Zi;
u64 len = BB_ReadUV(br);
u8 *src = BB_ReadBytesRaw(br, len);
if (src != 0)
@ -857,7 +857,7 @@ void BB_Test(void)
{ kind_string, .s = { Lit("Alriiiiiiiiiiiiiiiiiiighty then") } },
};
String encoded = ZI;
String encoded = Zi;
{
BB_Buff bb = BB_AcquireBuff(Gibi(64));
BB_Writer bw = BB_WriterFromBuff(&bb);

View File

@ -12,7 +12,7 @@ void BootstrapCmdline(void)
CommandlineArg *tmp_args = PushStructs(scratch.arena, CommandlineArg, raw.count);
String *tmp_positionals = PushStructs(scratch.arena, String, raw.count);
{
String name = ZI;
String name = Zi;
for (StringListNode *n = raw.first; n; n = n->next)
{
String s = n->s;
@ -74,7 +74,7 @@ void BootstrapCmdline(void)
String StringFromCommandlineIdx(i32 idx)
{
String result = ZI;
String result = Zi;
if (idx < Base.cmdline.positional_args_count)
{
result = Base.cmdline.positional_args[idx];
@ -84,7 +84,7 @@ String StringFromCommandlineIdx(i32 idx)
CommandlineArg CommandlineArgFromName(String name)
{
CommandlineArg result = ZI;
CommandlineArg result = Zi;
u64 hash = HashFnv64(Fnv64Basis, name);
for (CommandlineArgNode *n = Base.cmdline.arg_bins[hash % countof(Base.cmdline.arg_bins)]; n; n = n->next)
{

View File

@ -836,7 +836,7 @@ f32 LinearFromSrgbF32(f32 srgb)
Vec4 LinearFromSrgb(Vec4 srgb)
{
Vec4 result = ZI;
Vec4 result = Zi;
result.x = LinearFromSrgbF32(srgb.x);
result.y = LinearFromSrgbF32(srgb.y);
result.z = LinearFromSrgbF32(srgb.z);
@ -846,7 +846,7 @@ Vec4 LinearFromSrgb(Vec4 srgb)
Vec4 SrgbFromLinear(Vec4 lin)
{
Vec4 result = ZI;
Vec4 result = Zi;
result.x = SrgbFromLinearF32(lin.x);
result.y = SrgbFromLinearF32(lin.y);
result.z = SrgbFromLinearF32(lin.z);
@ -865,7 +865,7 @@ Vec4 BlendSrgb(Vec4 v0, Vec4 v1, f32 t)
{
Vec4 v0_l = LinearFromSrgb(v0);
Vec4 v1_l = LinearFromSrgb(v1);
Vec4 blend_l = ZI;
Vec4 blend_l = Zi;
{
blend_l.x = LerpF32(v0_l.x, v1_l.x, t);
blend_l.y = LerpF32(v0_l.y, v1_l.y, t);
@ -1150,7 +1150,7 @@ Vec2I32 DivVec2I32Vec2I32(Vec2I32 a, Vec2I32 b)
Vec4 Vec4FromU32(u32 v)
{
Vec4 result = ZI;
Vec4 result = Zi;
result.x = ((v >> 0) & 0xFF) / 255.0;
result.y = ((v >> 8) & 0xFF) / 255.0;
result.z = ((v >> 16) & 0xFF) / 255.0;
@ -1175,7 +1175,7 @@ u32 U32FromVec4(Vec4 v)
Vec2 DimsFromRng2(Rng2 r)
{
Vec2 result = ZI;
Vec2 result = Zi;
result.x = r.p1.x - r.p0.x;
result.y = r.p1.y - r.p0.y;
return result;
@ -1183,7 +1183,7 @@ Vec2 DimsFromRng2(Rng2 r)
Rng2 UnionRng2(Rng2 a, Rng2 b)
{
Rng2 result = ZI;
Rng2 result = Zi;
result.p0.x = MinF32(a.p0.x, b.p0.x);
result.p0.y = MinF32(a.p0.y, b.p0.y);
result.p1.x = MaxF32(a.p1.x, b.p1.x);
@ -1193,7 +1193,7 @@ Rng2 UnionRng2(Rng2 a, Rng2 b)
Rng2 AddRng2Vec2(Rng2 r, Vec2 v)
{
Rng2 result = ZI;
Rng2 result = Zi;
result.p0 = AddVec2(r.p0, v);
result.p1 = AddVec2(r.p1, v);
return result;
@ -1201,7 +1201,7 @@ Rng2 AddRng2Vec2(Rng2 r, Vec2 v)
Rng2 MulRng2Vec2(Rng2 r, Vec2 v)
{
Rng2 result = ZI;
Rng2 result = Zi;
result.p0 = MulVec2Vec2(r.p0, v);
result.p1 = MulVec2Vec2(r.p1, v);
return result;
@ -1209,7 +1209,7 @@ Rng2 MulRng2Vec2(Rng2 r, Vec2 v)
Rng2 DivRng2Vec2(Rng2 r, Vec2 v)
{
Rng2 result = ZI;
Rng2 result = Zi;
result.p0 = DivVec2Vec2(r.p0, v);
result.p1 = DivVec2Vec2(r.p1, v);
return result;
@ -1219,7 +1219,7 @@ Rng2 DivRng2Vec2(Rng2 r, Vec2 v)
Vec2I32 DimsFromRng2I32(Rng2I32 r)
{
Vec2I32 result = ZI;
Vec2I32 result = Zi;
result.x = r.p1.x - r.p0.x;
result.y = r.p1.y - r.p0.y;
return result;
@ -1227,7 +1227,7 @@ Vec2I32 DimsFromRng2I32(Rng2I32 r)
Rng2I32 UnionRng2I32(Rng2I32 a, Rng2I32 b)
{
Rng2I32 result = ZI;
Rng2I32 result = Zi;
result.p0.x = MinF32(a.p0.x, b.p0.x);
result.p0.y = MinF32(a.p0.y, b.p0.y);
result.p1.x = MaxF32(a.p1.x, b.p1.x);
@ -1237,7 +1237,7 @@ Rng2I32 UnionRng2I32(Rng2I32 a, Rng2I32 b)
Rng2I32 AddRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
{
Rng2I32 result = ZI;
Rng2I32 result = Zi;
result.p0 = AddVec2I32(r.p0, v);
result.p1 = AddVec2I32(r.p1, v);
return result;
@ -1245,7 +1245,7 @@ Rng2I32 AddRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
Rng2I32 MulRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
{
Rng2I32 result = ZI;
Rng2I32 result = Zi;
result.p0 = MulVec2I32Vec2I32(r.p0, v);
result.p1 = MulVec2I32Vec2I32(r.p1, v);
return result;
@ -1253,7 +1253,7 @@ Rng2I32 MulRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
Rng2I32 DivRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
{
Rng2I32 result = ZI;
Rng2I32 result = Zi;
result.p0 = DivVec2I32Vec2I32(r.p0, v);
result.p1 = DivVec2I32Vec2I32(r.p1, v);
return result;
@ -1434,7 +1434,7 @@ Vec2 InvertXformMulV2(Xform xf, Vec2 v)
//- Helpers
Xform BasisFromXform(Xform xf)
{
Xform result = ZI;
Xform result = Zi;
result.bx = xf.bx;
result.by = xf.by;
return result;
@ -1520,7 +1520,7 @@ Mat4x4 Mat4x4FromXform(Xform xf)
Mat4x4 Mat4x4FromOrtho(f32 left, f32 right, f32 bottom, f32 top, f32 near_z, f32 far_z)
{
Mat4x4 m = ZI;
Mat4x4 m = Zi;
f32 rl = 1.0f / (right - left);
f32 tb = 1.0f / (top - bottom);

View File

@ -49,7 +49,7 @@ b32 IsResourceNil(ResourceKey resource)
ResourceKey ResourceKeyFromStore(ResourceStore *store, String name)
{
ResourceKey result = ZI;
ResourceKey result = Zi;
result.v = HashFnv64(store->v, name);
return result;
}
@ -71,7 +71,7 @@ ResourceEntry *ResourceEntryFromHash(u64 hash)
String DataFromResource(ResourceKey resource)
{
String result = ZI;
String result = Zi;
ResourceEntry *entry = ResourceEntryFromHash(resource.v);
if (entry)
{
@ -82,7 +82,7 @@ String DataFromResource(ResourceKey resource)
String NameFromResource(ResourceKey resource)
{
String result = ZI;
String result = Zi;
ResourceEntry *entry = ResourceEntryFromHash(resource.v);
if (entry)
{

View File

@ -1,2 +1,2 @@
BaseCtx Base = ZI;
ThreadLocal BaseThreadLocalCtx Base_tl = ZI;
BaseCtx Base = Zi;
ThreadLocal BaseThreadLocalCtx Base_tl = Zi;

View File

@ -20,7 +20,7 @@ String StringFromUint(Arena *arena, u64 n, u64 base, u64 zfill)
{
/* Base too large */
Assert(base <= (countof(IntChars) - 1));
String result = ZI;
String result = Zi;
TempArena scratch = BeginScratch(arena);
{
/* Build backwards text starting from least significant digit */
@ -52,7 +52,7 @@ String StringFromUint(Arena *arena, u64 n, u64 base, u64 zfill)
String StringFromUints(Arena *arena, u64 uints_count, u64 *uints, u64 base, u64 zfill)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
result.len += StringFromChar(arena, '(').len;
for (u64 uint_idx = 0; uint_idx < uints_count; ++uint_idx)
@ -71,7 +71,7 @@ String StringFromUints(Arena *arena, u64 uints_count, u64 *uints, u64 base, u64
String StringFromSint(Arena *arena, i64 n, u64 base, u64 zfill)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
if (n < 0)
{
@ -84,7 +84,7 @@ String StringFromSint(Arena *arena, i64 n, u64 base, u64 zfill)
String StringFromSints(Arena *arena, u64 sints_count, i64 *sints, u64 base, u64 zfill)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
result.len += StringFromChar(arena, '(').len;
for (u64 sint_idx = 0; sint_idx < sints_count; ++sint_idx)
@ -103,7 +103,7 @@ String StringFromSints(Arena *arena, u64 sints_count, i64 *sints, u64 base, u64
String StringFromFloat(Arena *arena, f64 f, u32 precision)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
TempArena scratch = BeginScratch(arena);
{
@ -176,7 +176,7 @@ String StringFromFloat(Arena *arena, f64 f, u32 precision)
String StringFromFloats(Arena *arena, u64 floats_count, f64 *floats, u32 precision)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
result.len += StringFromChar(arena, '(').len;
for (u64 float_idx = 0; float_idx < floats_count; ++float_idx)
@ -208,7 +208,7 @@ String StringFromPtr(Arena *arena, void *ptr)
String StringFromhandle(Arena *arena, u64 v0, u64 v1)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
result.len += PushString(arena, Lit("h")).len;
result.len += StringFromUint(arena, v0, 16, 0).len;
@ -221,7 +221,7 @@ String StringFromhandle(Arena *arena, u64 v0, u64 v1)
String StringFromUid(Arena *arena, Uid uid)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
result.len += StringFromUint(arena, (uid.hi >> 32), 16, 8).len;
return result;
@ -235,7 +235,7 @@ String StringFromUid(Arena *arena, Uid uid)
String PushString(Arena *arena, String src)
{
String result = ZI;
String result = Zi;
result.len = src.len;
result.text = PushStructsNoZero(arena, u8, src.len);
CopyBytes(result.text, src.text, src.len);
@ -244,7 +244,7 @@ String PushString(Arena *arena, String src)
String CopyString(String dst, String src)
{
String result = ZI;
String result = Zi;
result.len = MinU64(dst.len, src.len);
result.text = dst.text;
CopyBytes(result.text, src.text, result.len);
@ -272,7 +272,7 @@ String RepeatString(Arena *arena, String src, u64 count)
String CatString(Arena *arena, String str1, String str2)
{
String new_str = ZI;
String new_str = Zi;
new_str.len = str1.len + str2.len;
new_str.text = PushStructsNoZero(arena, u8, new_str.len);
CopyBytes(new_str.text, str1.text, str1.len);
@ -286,18 +286,18 @@ String CatString(Arena *arena, String str1, String str2)
* into the existing string and do not allocate any new text. */
StringArray SplitString(Arena *arena, String str, String delim)
{
StringArray pieces = ZI;
StringArray pieces = Zi;
pieces.strings = ArenaNext(arena, String);
i64 piece_start = 0;
for (i64 i = 0; i < (i64)str.len - (i64)delim.len;)
{
String cmp = ZI;
String cmp = Zi;
cmp.text = &str.text[i];
cmp.len = MinI64(str.len - i, delim.len);
if (MatchString(cmp, delim))
{
String piece = ZI;
String piece = Zi;
piece.text = &str.text[piece_start];
piece.len = i - piece_start;
*PushStructNoZero(arena, String) = piece;
@ -312,7 +312,7 @@ StringArray SplitString(Arena *arena, String str, String delim)
}
if (piece_start < (i64)str.len)
{
String piece = ZI;
String piece = Zi;
piece.text = &str.text[piece_start];
piece.len = str.len - piece_start;
*PushStructNoZero(arena, String) = piece;
@ -323,17 +323,17 @@ StringArray SplitString(Arena *arena, String str, String delim)
String ReplaceString(Arena *arena, String str, String old_pattern, String new_pattern)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
i64 piece_start = 0;
for (i64 i = 0; i < (i64)str.len - (i64)old_pattern.len;)
{
String cmp = ZI;
String cmp = Zi;
cmp.text = &str.text[i];
cmp.len = MinI64(str.len - i, old_pattern.len);
if (MatchString(cmp, old_pattern))
{
String piece = ZI;
String piece = Zi;
piece.text = &str.text[piece_start];
piece.len = i - piece_start;
if (piece.len > 0)
@ -351,7 +351,7 @@ String ReplaceString(Arena *arena, String str, String old_pattern, String new_pa
}
if (piece_start < (i64)str.len)
{
String piece = ZI;
String piece = Zi;
piece.text = &str.text[piece_start];
piece.len = str.len - piece_start;
result.len += PushString(arena, piece).len;
@ -400,7 +400,7 @@ String IndentString(Arena *arena, String str, u32 indent)
String LowerString(Arena *arena, String str)
{
String result = ZI;
String result = Zi;
result.text = PushStructsNoZero(arena, u8, str.len);
result.len = str.len;
@ -504,7 +504,7 @@ b32 StringEndsWith(String str, String substring)
String StringFromArray(Arena *arena, StringArray a)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
for (u64 string_idx = 0; string_idx < a.count; ++string_idx)
{
@ -536,7 +536,7 @@ StringListNode *PushStringToList(Arena *arena, StringList *l, String s)
String StringFromList(Arena *arena, StringList l, String separator)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
for (StringListNode *n = l.first; n; n = n->next)
{
@ -627,7 +627,7 @@ String TrimWhitespace(String s)
*/
String FormatString(Arena *arena, String fmt, FmtArgArray args)
{
String result = ZI;
String result = Zi;
result.text = ArenaNext(arena, u8);
u8 *end = fmt.text + fmt.len;
@ -647,9 +647,9 @@ String FormatString(Arena *arena, String fmt, FmtArgArray args)
if (!no_more_valid_args && !escape && *c == '%' && *next == 'F')
{
String parsed_arg = ZI;
String parsed_arg = Zi;
FmtArg arg = ZI;
FmtArg arg = Zi;
if (arg_idx < args.count)
{
arg = args.args[arg_idx];
@ -786,7 +786,7 @@ String FormatString(Arena *arena, String fmt, FmtArgArray args)
#if IsRtcEnabled
if (!no_more_valid_args)
{
FmtArg last_arg = ZI;
FmtArg last_arg = Zi;
if (arg_idx < args.count)
{
last_arg = args.args[arg_idx];
@ -801,7 +801,7 @@ String FormatString(Arena *arena, String fmt, FmtArgArray args)
String StringF_(Arena *arena, String fmt, ...)
{
String result = ZI;
String result = Zi;
TempArena scratch = BeginScratch(arena);
{
va_list args;
@ -815,7 +815,7 @@ String StringF_(Arena *arena, String fmt, ...)
FmtArgArray FmtArgsFromVaList(Arena *arena, va_list args)
{
FmtArgArray result = ZI;
FmtArgArray result = Zi;
result.args = ArenaNext(arena, FmtArg);
{
b32 done = 0;

View File

@ -59,7 +59,7 @@ Lock LockSpinE(Mutex *m, i32 spin)
Atomic32Set(&m->exclusive_thread_id, ThreadId());
#endif
Lock lock = ZI;
Lock lock = Zi;
lock.exclusive = 1;
lock.mutex = m;
return lock;
@ -101,7 +101,7 @@ Lock LockSpinS(Mutex *m, i32 spin)
}
}
}
Lock lock = ZI;
Lock lock = Zi;
lock.mutex = m;
return lock;
}

View File

@ -1,7 +1,7 @@
/* Returns a uid generated from the system's random number generator */
Uid UidFromTrueRand(void)
{
Uid result = ZI;
Uid result = Zi;
TrueRand(StringFromStruct(&result));
return result;
}

View File

@ -9,7 +9,7 @@ Utf8DecodeResult DecodeUtf8(String str)
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,3,3,4,5
};
Utf8DecodeResult result = ZI;
Utf8DecodeResult result = Zi;
u32 codepoint = U32Max;
u32 advance = 0;
if (str.len > 0)
@ -89,7 +89,7 @@ Utf8DecodeResult DecodeUtf8(String str)
Utf8EncodeResult EncodeUtf8(u32 codepoint)
{
Utf8EncodeResult result = ZI;
Utf8EncodeResult result = Zi;
if (codepoint <= 0x7F)
{
@ -134,7 +134,7 @@ Utf8EncodeResult EncodeUtf8(u32 codepoint)
Utf16DecodeResult DecodeUtf16(String16 str)
{
Utf16DecodeResult result = ZI;
Utf16DecodeResult result = Zi;
u32 codepoint = U32Max;
u32 advance = 0;
@ -164,7 +164,7 @@ Utf16DecodeResult DecodeUtf16(String16 str)
Utf16EncodeResult EncodeUtf16(u32 codepoint)
{
Utf16EncodeResult result = ZI;
Utf16EncodeResult result = Zi;
if (codepoint <= 0xFFFF)
{
@ -206,7 +206,7 @@ b32 IsUtf16LowSurrogate(u16 c)
Utf32DecodeResult DecodeUtf32(String32 str)
{
Utf32DecodeResult result = ZI;
Utf32DecodeResult result = Zi;
u32 codepoint = U32Max;
u32 advance = 0;
@ -229,7 +229,7 @@ Utf32DecodeResult DecodeUtf32(String32 str)
Utf32EncodeResult EncodeUtf32(u32 codepoint)
{
Utf32EncodeResult result = ZI;
Utf32EncodeResult result = Zi;
if (codepoint <= 0x10FFFF)
{

View File

@ -1,4 +1,4 @@
W32_Ctx W32 = ZI;
W32_Ctx W32 = Zi;
////////////////////////////////////////////////////////////
//~ Win32 embedded data
@ -19,7 +19,7 @@ BOOL W32_FindEmbeddedRcData(HMODULE module, LPCWSTR type, LPWSTR wstr_entry_name
{
if (ctx->embedded_strings_count < countof(ctx->embedded_strings))
{
String embedded = ZI;
String embedded = Zi;
embedded.len = SizeofResource(module, hres);
embedded.text = LockResource(hg);
ctx->embedded_strings[ctx->embedded_strings_count++] = embedded;
@ -106,7 +106,7 @@ void TrueRand(String buffer)
CpuTopologyInfo GetCpuTopologyInfo(void)
{
TempArena scratch = BeginScratchNoConflict();
CpuTopologyInfo res = ZI;
CpuTopologyInfo res = Zi;
{
DWORD infos_buff_size = 0;
u8 *infos_buff = 0;
@ -193,7 +193,7 @@ b32 IsSwappingOut(void)
String SwappedStateFromName(Arena *arena, String name)
{
TempArena scratch = BeginScratch(arena);
String result = ZI;
String result = Zi;
String path = StringF(scratch.arena, "ppswap/%F.swp", FmtString(name));
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
HANDLE handle = CreateFileW(path_wstr, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
@ -224,7 +224,7 @@ void WriteSwappedState(String name, String data)
TempArena scratch = BeginScratchNoConflict();
/* TODO: Use directory non-relative to executable */
CreateDirectoryW(L"ppswap", 0);
String result = ZI;
String result = Zi;
String path = StringF(scratch.arena, "ppswap/%F.swp", FmtString(name));
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
HANDLE handle = CreateFileW(path_wstr, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
@ -389,7 +389,7 @@ void LogF_(i32 level, String fmt, ...)
LogEventsArray GetLogEvents(void)
{
LogEventsArray result = ZI;
LogEventsArray result = Zi;
result.count = Atomic64Fetch(&W32.readable_logs_count);
if (result.count > 0)
{
@ -431,7 +431,7 @@ i32 W32_Main(void)
/* Get raw args from command line */
{
Arena *perm = PermArena();
StringList args_list = ZI;
StringList args_list = Zi;
{
LPCWSTR cmdline_wstr = GetCommandLineW();
i32 argc = 0;
@ -459,7 +459,7 @@ i32 W32_Main(void)
/* Bootstrap resource system */
{
W32_FindEmbeddedDataCtx ctx = ZI;
W32_FindEmbeddedDataCtx ctx = Zi;
EnumResourceNamesW(0, RT_RCDATA, &W32_FindEmbeddedRcData, (LONG_PTR)&ctx);
BootstrapResources(ctx.embedded_strings_count, ctx.embedded_strings);
}

View File

@ -3,7 +3,7 @@
DateTime LocalDateTime(void)
{
DateTime result = ZI;
DateTime result = Zi;
{
SYSTEMTIME lt;
GetLocalTime(&lt);

View File

@ -36,7 +36,7 @@ DWORD WINAPI W32_ThreadProc(LPVOID thread_args_vp)
void DispatchWave(String name, u32 num_lanes, WaveLaneEntryFunc *entry, void *udata)
{
Arena *perm = PermArena();
PERSIST Atomic64 num_threads_allocated = ZI;
PERSIST Atomic64 num_threads_allocated = Zi;
/* Catch high lane count to prevent OS crash */
i64 old_num_threads_allocated = Atomic64FetchAdd(&num_threads_allocated, num_lanes);
@ -65,7 +65,7 @@ void DispatchWave(String name, u32 num_lanes, WaveLaneEntryFunc *entry, void *ud
lane_ctx->wave = wave_ctx;
lane_ctx->default_spin_count = DefaultWaveLaneSpinCount;
String thread_name = ZI;
String thread_name = Zi;
if (num_lanes > 1)
{
thread_name = StringF(perm, "%F:%F", FmtString(name), FmtUint(lane_idx));

View File

@ -43,7 +43,7 @@ CLD_SupportPoint CLD_SupportPointFromDirEx(CLD_Shape *shape, Xform xf, Vec2 dir,
ignore = -1;
}
Vec2 furthest = ZI;
Vec2 furthest = Zi;
u32 furthest_index = 0;
f32 furthest_dot = -F32Infinity;
@ -144,9 +144,9 @@ CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf
#endif
{
b32 overlapping = 0;
CLD_MenkowskiSimplex s = ZI;
Vec2 dir = ZI;
CLD_MenkowskiPoint m = ZI;
CLD_MenkowskiSimplex s = Zi;
Vec2 dir = Zi;
CLD_MenkowskiPoint m = Zi;
/* First point is support point in shape's general directions to eachother */
dir = SubVec2(xf1.og, xf0.og);
@ -154,8 +154,8 @@ CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf
s.a = CLD_MenkowskiPointFromDir(shape0, shape1, xf0, xf1, dir);
s.len = 1;
Vec2 removed_a = ZI;
Vec2 removed_b = ZI;
Vec2 removed_a = Zi;
Vec2 removed_b = Zi;
u32 num_removed = 0;
for (;;)
{
@ -323,8 +323,8 @@ CLD_EpaData CLD_EpaDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf
{
TempArena scratch = BeginScratchNoConflict();
CLD_MenkowskiFeature closest_feature = ZI;
Vec2 normal = ZI;
CLD_MenkowskiFeature closest_feature = Zi;
Vec2 normal = Zi;
CLD_MenkowskiPoint *proto = 0;
u32 proto_count = 0;
@ -351,8 +351,8 @@ CLD_EpaData CLD_EpaDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf
/* Find dir from origin to closest edge */
/* FIXME: Winding order of ps & pe index */
f32 closest_len_sq = F32Infinity;
CLD_MenkowskiPoint closest_a = ZI;
CLD_MenkowskiPoint closest_b = ZI;
CLD_MenkowskiPoint closest_a = Zi;
CLD_MenkowskiPoint closest_b = Zi;
u32 closest_b_index = 0;
for (u32 i = 0; i < proto_count; ++i)
{
@ -538,23 +538,23 @@ Vec2 CLD_ClipPointToLine(Vec2 a, Vec2 b, Vec2 p, Vec2 normal)
CLD_CollisionData CLD_CollisionDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1)
{
CLD_CollisionData result = ZI;
CLD_CollisionData result = Zi;
const f32 tolerance = CLD_CollisionTolerance;
const f32 min_unique_pt_dist_sq = CLD_MinUniquePtDistSq;
const u32 max_epa_iterations = CLD_MaxEpaIterations;
CLD_CollisionPoint points[2] = ZI;
CLD_CollisionPoint points[2] = Zi;
u32 num_points = 0;
b32 colliding = 0;
Vec2 normal = ZI;
Vec2 normal = Zi;
#if COLLIDER_DEBUG
u32 dbg_step = 0;
#endif
CLD_GjkData gjk_result = ZI;
CLD_EpaData epa_result = ZI;
CLD_GjkData gjk_result = Zi;
CLD_EpaData epa_result = Zi;
/* Run GJK */
#if COLLIDER_DEBUG
@ -713,8 +713,8 @@ CLD_CollisionData CLD_CollisionDataFromShapes(CLD_Shape *shape0, CLD_Shape *shap
f32 a_sep = F32Infinity;
f32 b_sep = F32Infinity;
Vec2 a_midpoint = ZI;
Vec2 b_midpoint = ZI;
Vec2 a_midpoint = Zi;
Vec2 b_midpoint = Zi;
b32 ignore_a = 1;
b32 ignore_b = 1;
if (!collapse0 && !collapse1)
@ -821,22 +821,22 @@ abort:
CLD_ClosestPointData CLD_ClosestPointDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1)
{
CLD_ClosestPointData result = ZI;
CLD_ClosestPointData result = Zi;
const f32 tolerance = CLD_CollisionTolerance;
const f32 min_unique_pt_dist_sq = CLD_MinUniquePtDistSq;
const u32 max_epa_iterations = CLD_MaxEpaIterations;
Vec2 p0 = ZI;
Vec2 p1 = ZI;
Vec2 p0 = Zi;
Vec2 p1 = Zi;
b32 colliding = 0;
#if COLLIDER_DEBUG
u32 dbg_step = 0;
#endif
CLD_GjkData gjk_result = ZI;
CLD_EpaData epa_result = ZI;
CLD_GjkData gjk_result = Zi;
CLD_EpaData epa_result = Zi;
//- Run GJK
#if COLLIDER_DEBUG
@ -1033,7 +1033,7 @@ Vec2Array CLD_PointCloud(Arena *arena, CLD_Shape *shape0, CLD_Shape *shape1, Xfo
#if 0
b32 CLD_GjkBoolean(CLD_Shape *shape0, CLD_Shape *shape1)
{
struct { Vec2 a, b, c; } s = ZI;
struct { Vec2 a, b, c; } s = Zi;
/* FIXME: Infinite loop when shapes exactly overlap same space? */
Vec2 dir, p;

View File

@ -1,4 +1,4 @@
GC_Ctx GC = ZI;
GC_Ctx GC = Zi;
////////////////////////////////////////////////////////////
//~ Bootstrap
@ -13,7 +13,7 @@ void GC_Bootstrap(void)
GC_FontKey GC_FontKeyFromResource(ResourceKey resource)
{
GC_FontKey result = ZI;
GC_FontKey result = Zi;
result.r = resource;
return result;
}
@ -30,7 +30,7 @@ u64 GC_HashFromGlyphDesc(GC_GlyphDesc desc)
/* TODO: Thread-local cache */
GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size)
{
GC_Run result = ZI;
GC_Run result = Zi;
TempArena scratch = BeginScratch(arena);
Arena *perm = PermArena();
@ -63,7 +63,7 @@ GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size
{
u32 codepoint = codepoints[codepoint_idx];
GC_GlyphDesc desc = ZI;
GC_GlyphDesc desc = Zi;
desc.font = font;
desc.font_size = font_size;
desc.codepoint = codepoint;
@ -107,7 +107,7 @@ GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size
{
for (u64 uncached_codepoint_idx = 0; uncached_codepoint_idx < uncached_codepoints_count; ++uncached_codepoint_idx)
{
GC_GlyphDesc desc = ZI;
GC_GlyphDesc desc = Zi;
desc.font = font;
desc.font_size = font_size;
desc.codepoint = uncached_codepoints[uncached_codepoint_idx];
@ -298,7 +298,7 @@ void GC_TickAsync(WaveLaneCtx *lane, AsyncTickCtx *tick)
/* TODO: Use a more efficient atlas packing algorithm for less wasted space `*/
GC_Atlas *atlas = GC.first_atlas;
b32 can_use_atlas = 0;
Vec2I32 pos_in_atlas = ZI;
Vec2I32 pos_in_atlas = Zi;
while (can_use_atlas == 0)
{
/* Create atlas */

View File

@ -1,5 +1,5 @@
G_SharedUtilState G_shared_util_state = ZI;
ThreadLocal G_ArenaHandle G_t_perm_arena = ZI;
G_SharedUtilState G_shared_util_state = Zi;
ThreadLocal G_ArenaHandle G_t_perm_arena = Zi;
////////////////////////////////////////////////////////////
//~ Bootstrap
@ -14,7 +14,7 @@ void G_BootstrapCommon(void)
{
/* Init quad index buffer */
{
G_ResourceHandle quad_indices = ZI;
G_ResourceHandle quad_indices = Zi;
u16 quad_data[6] = { 0, 1, 2, 0, 2, 3 };
quad_indices = G_PushBuffer(gpu_perm, u16, countof(quad_data));
G_CopyCpuToBuffer(cl, quad_indices, 0, quad_data, RNGU64(0, sizeof(quad_data)));
@ -29,7 +29,7 @@ void G_BootstrapCommon(void)
/* Init noise texture */
{
G_ResourceHandle noise_tex = ZI;
G_ResourceHandle noise_tex = Zi;
String noise_data = DataFromResource(ResourceKeyFromStore(&G_Resources, Lit("noise_128x128x64_16.dat")));
Vec3I32 noise_dims = VEC3I32(128, 128, 64);
if (noise_data.len != noise_dims.x * noise_dims.y * noise_dims.z * 2)

View File

@ -1,5 +1,5 @@
G_D12_SharedState G_D12_shared_state = ZI;
ThreadLocal G_D12_ThreadLocalState G_D12_tl = ZI;
G_D12_SharedState G_D12_shared_state = Zi;
ThreadLocal G_D12_ThreadLocalState G_D12_tl = Zi;
////////////////////////////////////////////////////////////
//~ @hookimpl Bootstrap
@ -62,7 +62,7 @@ void G_Bootstrap(void)
IDXGIAdapter3 *adapter = 0;
ID3D12Device10 *device = 0;
String error = Lit("Could not initialize GPU device.");
String first_gpu_name = ZI;
String first_gpu_name = Zi;
u32 adapter_index = 0;
b32 skip = 0; /* For iGPU testing */
for (;;)
@ -207,7 +207,7 @@ void G_Bootstrap(void)
heap->max_count = desc.max;
heap->descriptor_size = ID3D12Device_GetDescriptorHandleIncrementSize(g->device, desc.type);
D3D12_DESCRIPTOR_HEAP_DESC d3d_desc = ZI;
D3D12_DESCRIPTOR_HEAP_DESC d3d_desc = Zi;
d3d_desc.Type = desc.type;
d3d_desc.Flags = desc.flags;
d3d_desc.NumDescriptors = desc.max;
@ -249,7 +249,7 @@ void G_Bootstrap(void)
ID3D10Blob *blob = 0;
if (SUCCEEDED(hr))
{
D3D12_ROOT_PARAMETER params[G_NumConstants] = ZI;
D3D12_ROOT_PARAMETER params[G_NumConstants] = Zi;
for (i32 slot = 0; slot < G_NumConstants; ++slot)
{
D3D12_ROOT_PARAMETER *param = &params[slot];
@ -260,7 +260,7 @@ void G_Bootstrap(void)
param->Constants.Num32BitValues = 1;
}
D3D12_ROOT_SIGNATURE_DESC desc = ZI;
D3D12_ROOT_SIGNATURE_DESC desc = Zi;
desc.NumParameters = countof(params);
desc.pParameters = params;
desc.NumStaticSamplers = 0;
@ -326,7 +326,7 @@ void G_Bootstrap(void)
// for (G_QueueKind kind = 0; kind < G_NumQueues; ++kind)
// {
// String name = ZI;
// String name = Zi;
// if (kind == G_QueueKind_Direct) name = Lit("Gpu direct queue worker");
// if (kind == G_QueueKind_AsyncCompute) name = Lit("Gpu compute queue worker");
// if (kind == G_QueueKind_AsyncCopy) name = Lit("Gpu copy queue worker");
@ -488,13 +488,13 @@ G_D12_Pipeline *G_D12_PipelineFromDesc(G_D12_PipelineDesc desc)
{
HRESULT hr = 0;
b32 ok = 1;
String error_str = ZI;
String error_str = Zi;
/* Create PSO */
ID3D12PipelineState *pso = 0;
if (ok && (!IsResourceNil(desc.vs.resource) || !IsResourceNil(desc.ps.resource)))
{
D3D12_RASTERIZER_DESC raster_desc = ZI;
D3D12_RASTERIZER_DESC raster_desc = Zi;
{
if (desc.is_wireframe)
{
@ -516,7 +516,7 @@ G_D12_Pipeline *G_D12_PipelineFromDesc(G_D12_PipelineDesc desc)
raster_desc.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF;
}
D3D12_BLEND_DESC blend_desc = ZI;
D3D12_BLEND_DESC blend_desc = Zi;
{
blend_desc.AlphaToCoverageEnable = 0;
blend_desc.IndependentBlendEnable = 0;
@ -530,7 +530,7 @@ G_D12_Pipeline *G_D12_PipelineFromDesc(G_D12_PipelineDesc desc)
blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL;
}
D3D12_DEPTH_STENCIL_DESC ds_desc = ZI;
D3D12_DEPTH_STENCIL_DESC ds_desc = Zi;
{
ds_desc.DepthEnable = 0;
ds_desc.StencilEnable = 0;
@ -538,7 +538,7 @@ G_D12_Pipeline *G_D12_PipelineFromDesc(G_D12_PipelineDesc desc)
String vs = DataFromResource(desc.vs.resource);
String ps = DataFromResource(desc.ps.resource);
D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc = ZI;
D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc = Zi;
{
pso_desc.pRootSignature = g->bindless_rootsig;
pso_desc.VS.pShaderBytecode = vs.text;
@ -576,7 +576,7 @@ G_D12_Pipeline *G_D12_PipelineFromDesc(G_D12_PipelineDesc desc)
else if (ok)
{
String cs = DataFromResource(desc.cs.resource);
D3D12_COMPUTE_PIPELINE_STATE_DESC pso_desc = ZI;
D3D12_COMPUTE_PIPELINE_STATE_DESC pso_desc = Zi;
{
pso_desc.pRootSignature = g->bindless_rootsig;
pso_desc.CS.pShaderBytecode = cs.text;
@ -622,7 +622,7 @@ G_D12_RawCommandList *G_D12_PrepareRawCommandList(G_QueueKind queue_kind)
G_D12_Queue *queue = G_D12_QueueFromKind(queue_kind);
/* Try to pull first completed command list from queue */
G_D12_RawCommandList *cl = ZI;
G_D12_RawCommandList *cl = Zi;
{
Lock lock = LockE(&queue->commit_mutex);
{
@ -888,7 +888,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_ResourceDesc desc)
{
/* Create d3d heap */
{
D3D12_HEAP_DESC d3d_desc = ZI;
D3D12_HEAP_DESC d3d_desc = Zi;
d3d_desc.SizeInBytes = Mebi(512);
if (heap_kind == G_D12_ResourceHeapKind_Cpu)
{
@ -927,7 +927,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_ResourceDesc desc)
{
if (SUCCEEDED(hr))
{
D3D12_RESOURCE_DESC1 d3d_desc = ZI;
D3D12_RESOURCE_DESC1 d3d_desc = Zi;
d3d_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
d3d_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
d3d_desc.Format = DXGI_FORMAT_UNKNOWN;
@ -942,7 +942,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_ResourceDesc desc)
u64 alloc_size = 0;
u64 alloc_align = 0;
{
D3D12_RESOURCE_ALLOCATION_INFO alloc_info = ZI;
D3D12_RESOURCE_ALLOCATION_INFO alloc_info = Zi;
ID3D12Device_GetResourceAllocationInfo(g->device, &alloc_info, 0, 1, (D3D12_RESOURCE_DESC *)&d3d_desc);
alloc_size = alloc_info.SizeInBytes;
alloc_align = alloc_info.Alignment;
@ -968,7 +968,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_ResourceDesc desc)
}
if (SUCCEEDED(hr))
{
D3D12_RANGE read_range = ZI;
D3D12_RANGE read_range = Zi;
hr = ID3D12Resource_Map(heap->d3d_mapped_resource, 0, &read_range, &heap->mapped);
}
}
@ -986,8 +986,8 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_ResourceDesc desc)
//- Initialize d3d resource desc
D3D12_BARRIER_LAYOUT initial_layout = D3D12_BARRIER_LAYOUT_UNDEFINED;
D3D12_CLEAR_VALUE clear_value = ZI;
D3D12_RESOURCE_DESC1 d3d_desc = ZI;
D3D12_CLEAR_VALUE clear_value = Zi;
D3D12_RESOURCE_DESC1 d3d_desc = Zi;
{
if (is_buffer)
{
@ -1031,7 +1031,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_ResourceDesc desc)
u64 align_in_heap = 0;
u64 size_in_heap = 0;
{
D3D12_RESOURCE_ALLOCATION_INFO alloc_info = ZI;
D3D12_RESOURCE_ALLOCATION_INFO alloc_info = Zi;
ID3D12Device_GetResourceAllocationInfo(g->device, &alloc_info, 0, 1, (D3D12_RESOURCE_DESC *)&d3d_desc);
align_in_heap = alloc_info.Alignment;
size_in_heap = alloc_info.SizeInBytes;
@ -1284,7 +1284,7 @@ u32 G_PushRef(G_ArenaHandle arena_handle, G_ResourceHandle resource_handle, G_Re
{
if (is_uav)
{
D3D12_UNORDERED_ACCESS_VIEW_DESC desc = ZI;
D3D12_UNORDERED_ACCESS_VIEW_DESC desc = Zi;
{
desc.Format = DXGI_FORMAT_UNKNOWN;
desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
@ -1303,7 +1303,7 @@ u32 G_PushRef(G_ArenaHandle arena_handle, G_ResourceHandle resource_handle, G_Re
}
else
{
D3D12_SHADER_RESOURCE_VIEW_DESC desc = ZI;
D3D12_SHADER_RESOURCE_VIEW_DESC desc = Zi;
{
desc.Format = DXGI_FORMAT_UNKNOWN;
desc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
@ -1339,7 +1339,7 @@ u32 G_PushRef(G_ArenaHandle arena_handle, G_ResourceHandle resource_handle, G_Re
{
descriptor = G_D12_PushDescriptor(gpu_arena, G_D12_DescriptorHeapKind_Sampler);
G_SamplerDesc sampler_desc = resource->sampler_desc;
D3D12_SAMPLER_DESC d3d_desc = ZI;
D3D12_SAMPLER_DESC d3d_desc = Zi;
{
d3d_desc.Filter = (D3D12_FILTER)sampler_desc.filter;
d3d_desc.AddressU = (D3D12_TEXTURE_ADDRESS_MODE)sampler_desc.x;
@ -1741,11 +1741,11 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
}
/* Rasterizer state */
D3D12_VIEWPORT bound_viewport = ZI;
D3D12_RECT bound_scissor = ZI;
D3D12_VIEWPORT bound_viewport = Zi;
D3D12_RECT bound_scissor = Zi;
D3D_PRIMITIVE_TOPOLOGY bound_primitive_topology = -1;
D3D12_INDEX_BUFFER_VIEW bound_ibv = ZI;
u64 bound_render_target_uids[G_MaxRenderTargets] = ZI;
D3D12_INDEX_BUFFER_VIEW bound_ibv = Zi;
u64 bound_render_target_uids[G_MaxRenderTargets] = Zi;
u64 bound_render_clear_target_uid = 0;
/* Flatten command chunks */
@ -1935,7 +1935,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
/* Dispatch barriers */
{
u32 barrier_groups_count = 0;
D3D12_BARRIER_GROUP barrier_groups[3] = ZI;
D3D12_BARRIER_GROUP barrier_groups[3] = Zi;
if (buffer_barriers_count > 0)
{
D3D12_BARRIER_GROUP *group = &barrier_groups[barrier_groups_count++];
@ -1997,7 +1997,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
Vec3I32 dst_offset = cmd->copy_texels.dst_texture_offset;
Rng3I32 src_range = cmd->copy_texels.src_texture_range;
D3D12_BOX src_box = ZI;
D3D12_BOX src_box = Zi;
D3D12_BOX *src_box_ptr = 0;
{
src_box.left = src_range.p0.x;
@ -2033,7 +2033,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
{
G_D12_Pipeline *pipeline = 0;
{
G_D12_PipelineDesc pipeline_desc = ZI;
G_D12_PipelineDesc pipeline_desc = Zi;
pipeline_desc.cs = cmd->compute.cs;
pipeline = G_D12_PipelineFromDesc(pipeline_desc);
}
@ -2088,7 +2088,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
{
G_D12_Pipeline *pipeline = 0;
{
G_D12_PipelineDesc pipeline_desc = ZI;
G_D12_PipelineDesc pipeline_desc = Zi;
pipeline_desc.vs = cmd->rasterize.vs;
pipeline_desc.ps = cmd->rasterize.ps;
{
@ -2126,7 +2126,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
/* Create ibv */
u32 indices_count = 0;
D3D12_INDEX_BUFFER_VIEW ibv = ZI;
D3D12_INDEX_BUFFER_VIEW ibv = Zi;
{
G_IndexBufferDesc desc = cmd->rasterize.index_buffer_desc;
if (desc.index_count > 0)
@ -2191,7 +2191,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
/* Set viewport */
{
D3D12_VIEWPORT viewport = ZI;
D3D12_VIEWPORT viewport = Zi;
{
Rng3 range = cmd->rasterize.viewport;
viewport.TopLeftX = range.p0.x;
@ -2210,7 +2210,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
/* Set scissor */
{
D3D12_RECT scissor = ZI;
D3D12_RECT scissor = Zi;
{
Rng2 range = cmd->rasterize.scissor;
scissor.left = range.p0.x;
@ -2277,7 +2277,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
}
if (om_dirty)
{
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handles[G_MaxRenderTargets] = ZI;
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handles[G_MaxRenderTargets] = Zi;
for (u32 i = 0; i < rtvs_count; ++i)
{
rtv_handles[i] = rcl->rtv_descriptors[i]->handle;
@ -2298,7 +2298,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
case G_D12_CmdKind_ClearRtv:
{
G_D12_Resource *rt = cmd->clear_rtv.render_target;
f32 clear_color[4] = ZI;
f32 clear_color[4] = Zi;
{
clear_color[0] = cmd->clear_rtv.color.x;
clear_color[1] = cmd->clear_rtv.color.y;
@ -2399,7 +2399,7 @@ void G_CopyCpuToBuffer(G_CommandListHandle cl_handle, G_ResourceHandle dst_handl
void G_CopyCpuToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_handle, Vec3I32 dst_offset, void *src, Vec3I32 src_dims, Rng3I32 src_copy_range)
{
Vec3I32 staged_dims = ZI;
Vec3I32 staged_dims = Zi;
{
staged_dims.x = src_copy_range.p1.x - src_copy_range.p0.x;
staged_dims.y = src_copy_range.p1.y - src_copy_range.p0.y;
@ -2416,9 +2416,9 @@ void G_CopyCpuToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_hand
u64 footprint_rows_count = 0;
u64 footprint_row_size = 0;
u64 footprint_size = 0;
D3D12_PLACED_SUBRESOURCE_FOOTPRINT footprint = ZI;
D3D12_PLACED_SUBRESOURCE_FOOTPRINT footprint = Zi;
{
D3D12_RESOURCE_DESC src_desc = ZI;
D3D12_RESOURCE_DESC src_desc = Zi;
{
ID3D12Resource_GetDesc(dst->d3d_resource, &src_desc);
src_desc.Width = staged_dims.x;
@ -2435,7 +2435,7 @@ void G_CopyCpuToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_hand
/* Fill staging buffer */
{
D3D12_RANGE read_range = ZI;
D3D12_RANGE read_range = Zi;
u8 *src_base = src;
u8 *dst_base = (u8 *)staging_region->ring->base + footprint.Offset;
u32 z_size = footprint_row_size * footprint_rows_count;
@ -2451,7 +2451,7 @@ void G_CopyCpuToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_hand
}
}
Rng3I32 dst_copy_range = ZI;
Rng3I32 dst_copy_range = Zi;
dst_copy_range.p0 = dst_offset;
dst_copy_range.p1.x = dst_copy_range.p0.x + staged_dims.x;
dst_copy_range.p1.y = dst_copy_range.p0.y + staged_dims.y;
@ -2482,7 +2482,7 @@ void G_CopyBufferToBuffer(G_CommandListHandle cl_handle, G_ResourceHandle dst_ha
void G_CopyBufferToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_handle, Rng3I32 dst_copy_range, G_ResourceHandle src_handle, u64 src_offset)
{
Vec3I32 src_dims = ZI;
Vec3I32 src_dims = Zi;
{
src_dims.x = dst_copy_range.p1.x - dst_copy_range.p0.x;
src_dims.y = dst_copy_range.p1.y - dst_copy_range.p0.y;
@ -2498,9 +2498,9 @@ void G_CopyBufferToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_h
Assert(dst->is_texture);
/* Grab footprint info */
D3D12_PLACED_SUBRESOURCE_FOOTPRINT src_footprint = ZI;
D3D12_PLACED_SUBRESOURCE_FOOTPRINT src_footprint = Zi;
{
D3D12_RESOURCE_DESC src_desc = ZI;
D3D12_RESOURCE_DESC src_desc = Zi;
{
ID3D12Resource_GetDesc(dst->d3d_resource, &src_desc);
src_desc.Width = src_dims.x;
@ -2511,8 +2511,8 @@ void G_CopyBufferToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_h
src_footprint.Offset = src_offset;
}
D3D12_TEXTURE_COPY_LOCATION src_loc = ZI;
D3D12_TEXTURE_COPY_LOCATION dst_loc = ZI;
D3D12_TEXTURE_COPY_LOCATION src_loc = Zi;
D3D12_TEXTURE_COPY_LOCATION dst_loc = Zi;
{
src_loc.pResource = src->d3d_resource;
src_loc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
@ -2547,8 +2547,8 @@ void G_CopyTextureToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_
Assert(src->is_texture);
Assert(dst->is_texture);
D3D12_TEXTURE_COPY_LOCATION src_loc = ZI;
D3D12_TEXTURE_COPY_LOCATION dst_loc = ZI;
D3D12_TEXTURE_COPY_LOCATION src_loc = Zi;
D3D12_TEXTURE_COPY_LOCATION dst_loc = Zi;
{
src_loc.pResource = dst->d3d_resource;
src_loc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
@ -2668,7 +2668,7 @@ i64 G_CompletionTargetFromQueue(G_QueueKind queue_kind)
G_QueueCompletions G_CompletionValuesFromQueues(G_QueueMask queue_mask)
{
G_QueueCompletions completions = ZI;
G_QueueCompletions completions = Zi;
for (G_QueueKind queue_kind = 0; queue_kind < G_NumQueues; ++queue_kind)
{
if (queue_mask & (1 << queue_kind))
@ -2681,7 +2681,7 @@ G_QueueCompletions G_CompletionValuesFromQueues(G_QueueMask queue_mask)
G_QueueCompletions G_CompletionTargetsFromQueues(G_QueueMask queue_mask)
{
G_QueueCompletions completions = ZI;
G_QueueCompletions completions = Zi;
for (G_QueueKind queue_kind = 0; queue_kind < G_NumQueues; ++queue_kind)
{
if (queue_mask & (1 << queue_kind))
@ -2697,8 +2697,8 @@ void G_SyncEx(G_QueueBarrierDesc desc)
G_D12_SharedState *g = &G_D12_shared_state;
u64 fences_count = 0;
ID3D12Fence *fences[G_NumQueues] = ZI;
i64 fence_targets[G_NumQueues] = ZI;
ID3D12Fence *fences[G_NumQueues] = Zi;
i64 fence_targets[G_NumQueues] = Zi;
/* Grab fences */
for (G_QueueKind completion_queue_kind = 0; completion_queue_kind < G_NumQueues; ++ completion_queue_kind)
@ -2760,15 +2760,15 @@ void G_SyncEx(G_QueueBarrierDesc desc)
G_Stats G_QueryStats(void)
{
G_D12_SharedState *g = &G_D12_shared_state;
G_Stats result = ZI;
G_Stats result = Zi;
{
DXGI_QUERY_VIDEO_MEMORY_INFO info = ZI;
DXGI_QUERY_VIDEO_MEMORY_INFO info = Zi;
IDXGIAdapter3_QueryVideoMemoryInfo(g->adapter, 0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info);
result.local_committed = info.CurrentUsage;
result.local_budget = info.Budget;
}
{
DXGI_QUERY_VIDEO_MEMORY_INFO info = ZI;
DXGI_QUERY_VIDEO_MEMORY_INFO info = Zi;
IDXGIAdapter3_QueryVideoMemoryInfo(g->adapter, 0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &info);
result.non_local_budget = info.Budget;
result.non_local_committed = info.CurrentUsage;
@ -2817,7 +2817,7 @@ G_ResourceHandle G_PrepareBackbuffer(G_SwapchainHandle swapchain_handle, G_Forma
IDXGISwapChain1 *swapchain1 = 0;
if (SUCCEEDED(hr))
{
DXGI_SWAP_CHAIN_DESC1 desc = ZI;
DXGI_SWAP_CHAIN_DESC1 desc = Zi;
desc.Format = G_D12_DxgiFormatFromGpuFormat(format);
desc.Width = size.x;
desc.Height = size.y;
@ -3026,7 +3026,7 @@ void G_D12_CollectionWorkerEntryPoint(WaveLaneCtx *lane)
G_Stage_Copy, G_Access_CopyRead,
G_Stage_Copy, G_Access_CopyWrite
);
u8 zero[12] = ZI;
u8 zero[12] = Zi;
G_CopyCpuToBuffer(cl, queue->print_buffer, 0, zero, RNGU64(0, sizeof(zero)));
}
G_CommitCommandList(cl);
@ -3076,14 +3076,14 @@ void G_D12_CollectionWorkerEntryPoint(WaveLaneCtx *lane)
at += 4;
}
String fmt = ZI;
String fmt = Zi;
{
fmt.len = chars_count;
fmt.text = at;
at += chars_count;
}
FmtArgArray args = ZI;
FmtArgArray args = Zi;
args.count = args_count;
{
if (args_count > 0)
@ -3180,7 +3180,7 @@ void G_D12_CollectionWorkerEntryPoint(WaveLaneCtx *lane)
}
}
String final_str = ZI;
String final_str = Zi;
if (internal_overflow)
{
final_str = Lit("[Shader PrintF is too large]");

View File

@ -1,6 +1,6 @@
#include "meta.h"
BuildCtx Build = ZI;
BuildCtx Build = Zi;
////////////////////////////////////////////////////////////
//~ Helpers
@ -37,7 +37,7 @@ void EchoLineOrNothing(String msg)
LineCol LineColFromPos(String data, i64 pos)
{
TempArena scratch = BeginScratchNoConflict();
LineCol result = ZI;
LineCol result = Zi;
for (u64 cur = 0; cur < data.len && cur <= (u64)pos; ++cur)
{
u8 c = data.text[cur];
@ -60,7 +60,7 @@ String StringFromMetaErrors(Arena *arena, M_ErrorList errors)
{
TempArena scratch = BeginScratch(arena);
StringList error_strings = ZI;
StringList error_strings = Zi;
for (M_Error *e = errors.first; e; e = e->next)
{
M_Token *token = e->token;
@ -76,7 +76,7 @@ String StringFromMetaErrors(Arena *arena, M_ErrorList errors)
{
token_pos = token->s.text - token_file_data.text;
}
LineCol line_col = ZI;
LineCol line_col = Zi;
if (token_pos >= 0)
{
line_col = LineColFromPos(token_file_data, token_pos);
@ -104,12 +104,12 @@ String StringFromMetaErrors(Arena *arena, M_ErrorList errors)
EmbedObj Embed(String store_name, String dir_path)
{
Arena *perm = PermArena();
EmbedObj result = ZI;
EmbedObj result = Zi;
/* Generate resource archive contents */
String arc_contents = ZI;
String arc_contents = Zi;
{
StringList files = ZI;
StringList files = Zi;
F_FilesFromDir(perm, &files, dir_path, F_IterFlag_Recurse);
Struct(EntryNode)
@ -210,8 +210,8 @@ EmbedObj Embed(String store_name, String dir_path)
/* Generate RC file */
String rc_out_file = StringF(perm, "%F.rc", FmtString(store_name));
{
RandState rs = ZI;
StringList rc_out_lines = ZI;
RandState rs = Zi;
StringList rc_out_lines = Zi;
String arc_file_cp = F_GetFullCrossPlatform(perm, arc_path);
String line = StringF(perm, "%F_%F RCDATA \"%F\"", FmtString(Lit(Stringize(W32_EmbeddedDataPrefix))), FmtHex(RandU64FromState(&rs)), FmtString(arc_file_cp));
PushStringToList(perm, &rc_out_lines, line);
@ -270,7 +270,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
/* Compute new metahash */
u64 new_metahash = 0;
{
StringList check_files = ZI;
StringList check_files = Zi;
F_FilesFromDir(perm, &check_files, Lit("../src/base"), F_IterFlag_Recurse);
F_FilesFromDir(perm, &check_files, Lit("../src/meta"), F_IterFlag_Recurse);
PushStringToList(perm, &check_files, Lit("../src/config.h"));
@ -300,10 +300,10 @@ void BuildEntryPoint(WaveLaneCtx *lane)
{
String leaf_layer_name;
};
CmdLineArgs cmdline = ZI;
CmdLineArgs cmdline = Zi;
{
CommandlineArg layer_arg = CommandlineArgFromName(Lit("layer"));
String layer_name = ZI;
String layer_name = Zi;
if (layer_arg.name.len != 0)
{
layer_name = layer_arg.value;
@ -331,7 +331,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
//////////////////////////////
//- Generate compiler params
CompilerParams cp = ZI;
CompilerParams cp = Zi;
{
//- Common
{
@ -452,7 +452,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
//- Parse layers
{
/* Lex */
StringList src_dirs = ZI;
StringList src_dirs = Zi;
PushStringToList(perm, &src_dirs, Lit("../src"));
M_TokenFileList lexed = M_TokensFromSrcDirs(perm, src_dirs);
@ -460,7 +460,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
M_LayerList parsed = M_LayersFromTokenFiles(perm, lexed);;
/* Flatten */
StringList starting_layer_names = ZI;
StringList starting_layer_names = Zi;
PushStringToList(perm, &starting_layer_names, cmdline.leaf_layer_name);
Build.layers_parse = M_FlattenEntries(perm, parsed, starting_layer_names);
@ -469,10 +469,10 @@ void BuildEntryPoint(WaveLaneCtx *lane)
//- Generate C file
{
StringList c_store_lines = ZI;
StringList c_shader_lines = ZI;
StringList c_include_lines = ZI;
StringList c_bootstrap_lines = ZI;
StringList c_store_lines = Zi;
StringList c_shader_lines = Zi;
StringList c_include_lines = Zi;
StringList c_bootstrap_lines = Zi;
{
for (M_Entry *entry = Build.layers_parse.first; entry->valid; entry = entry->next)
{
@ -571,7 +571,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
}
if (Build.c_parse.errors.count == 0)
{
StringList c_out_lines = ZI;
StringList c_out_lines = Zi;
PushStringToList(perm, &c_out_lines, Lit("// Auto generated file"));
/* Include base layer */
{
@ -638,7 +638,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
OS_Mkdir(shader_store_name);
{
/* Remove all old shaders */
StringList files = ZI;
StringList files = Zi;
F_FilesFromDir(perm, &files, shader_store_name, F_IterFlag_None);
for (StringListNode *n = files.first; n; n = n->next)
{
@ -658,7 +658,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
/* Generate GPU file & shader entries */
{
StringList gpu_include_lines = ZI;
StringList gpu_include_lines = Zi;
{
for (M_Entry *entry = Build.layers_parse.first; entry->valid; entry = entry->next)
{
@ -720,7 +720,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
}
if (Build.gpu_parse.errors.count == 0)
{
StringList gpu_out_lines = ZI;
StringList gpu_out_lines = Zi;
PushStringToList(perm, &gpu_out_lines, Lit("// Auto generated file"));
/* Include base layer */
{
@ -925,9 +925,9 @@ void BuildEntryPoint(WaveLaneCtx *lane)
i64 start_ns = TimeNs();
String obj_files_str = ZI;
String obj_files_str = Zi;
{
StringList obj_files = ZI;
StringList obj_files = Zi;
PushStringToList(perm, &obj_files, Build.c_obj.obj_file);
for (u64 embed_obj_idx = 0; embed_obj_idx < Build.embed_objs.count; ++embed_obj_idx)
{
@ -957,7 +957,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
if (lane->idx == 0)
{
String gpu_obj_output = ZI;
String gpu_obj_output = Zi;
{
GpuObj *disp_obj = 0;
for (u32 gpu_obj_idx = 0; gpu_obj_idx < Build.gpu_objs.count; ++gpu_obj_idx)
@ -973,9 +973,9 @@ void BuildEntryPoint(WaveLaneCtx *lane)
gpu_obj_output = TrimWhitespace(disp_obj->output);
}
}
String embed_obj_output = ZI;
String embed_obj_output = Zi;
{
StringList embed_obj_outputs = ZI;
StringList embed_obj_outputs = Zi;
for (u32 embed_obj_idx = 0; embed_obj_idx < Build.embed_objs.count; ++embed_obj_idx)
{
EmbedObj *embed_obj = &Build.embed_objs.array[embed_obj_idx];

View File

@ -42,7 +42,7 @@ String F_GetFileName(String path)
String F_GetParentDir(String path)
{
String result = ZI;
String result = Zi;
result.text = path.text;
u64 end = path.len;
for (u64 i = path.len; i-- > 0;)
@ -62,7 +62,7 @@ String F_GetParentDir(String path)
String F_ExtensionFromFile(String path)
{
String result = ZI;
String result = Zi;
u64 start = path.len;
for (u64 i = path.len; i-- > 0;)
{
@ -86,7 +86,7 @@ String F_ExtensionFromFile(String path)
String F_DataFromFile(Arena *arena, String path)
{
String result = ZI;
String result = Zi;
OS_File file = OS_OpenFile(path, OS_FileFlag_Read, I64Max);
result = OS_ReadEntireFile(arena, file);
OS_CloseFile(file);
@ -122,7 +122,7 @@ b32 F_IsDir(String path)
void F_FilesFromDir(Arena *arena, StringList *list, String dir, F_IterFlag flags)
{
TempArena scratch = BeginScratch(arena);
StringList tmp = ZI;
StringList tmp = Zi;
String dir_full_path = F_GetFull(scratch.arena, dir);
OS_DirContentsFromFullPath(scratch.arena, &tmp, dir_full_path);
for (StringListNode *n = tmp.first; n; n = n->next)

View File

@ -79,7 +79,7 @@ M_Token *M_PushToken(Arena *arena, M_TokenFile *file, String s, M_TokenKind kind
M_TokenFileList M_TokensFromSrcDirs(Arena *arena, StringList src_dirs)
{
M_TokenFileList result = ZI;
M_TokenFileList result = Zi;
TempArena scratch = BeginScratch(arena);
result.first = &M_NilTokenFile;
result.last = &M_NilTokenFile;
@ -89,7 +89,7 @@ M_TokenFileList M_TokensFromSrcDirs(Arena *arena, StringList src_dirs)
for (StringListNode *dir_name_node = src_dirs.first; dir_name_node; dir_name_node = dir_name_node->next)
{
String dir_name = dir_name_node->s;
StringList files = ZI;
StringList files = Zi;
F_FilesFromDir(arena, &files, dir_name, F_IterFlag_Recurse);
for (StringListNode *file_name_node = files.first; file_name_node; file_name_node = file_name_node->next)
{
@ -233,7 +233,7 @@ M_Entry *M_PushEntry(Arena *arena, M_Layer *l, M_EntryKind kind, M_Token *entry_
M_LayerList M_LayersFromTokenFiles(Arena *arena, M_TokenFileList lexed)
{
TempArena scratch = BeginScratch(arena);
M_LayerList result = ZI;
M_LayerList result = Zi;
result.first = &M_NilLayer;
result.last = &M_NilLayer;

View File

@ -3,7 +3,7 @@
String W32_StringFromError(Arena *arena, DWORD err)
{
String result = ZI;
String result = Zi;
char *msg_cstr = 0;
i64 len = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
@ -38,7 +38,7 @@ void OS_Bootstrap(void)
OS_File OS_OpenFile(String path, OS_FileFlag flags, i64 timeout_ns)
{
TempArena scratch = BeginScratchNoConflict();
OS_File result = ZI;
OS_File result = Zi;
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
u32 share_mode = FILE_SHARE_READ;
u32 create_mode = OPEN_EXISTING;
@ -77,7 +77,7 @@ void OS_CloseFile(OS_File file)
String OS_ReadEntireFile(Arena *arena, OS_File file)
{
String result = ZI;
String result = Zi;
HANDLE handle = (HANDLE)file.handle;
u32 chunk_size = Kibi(64);
result.text = ArenaNext(arena, u8);
@ -107,7 +107,7 @@ void OS_ClearWriteFile(OS_File file, String data)
void OS_DirContentsFromFullPath(Arena *arena, StringList *list, String path)
{
TempArena scratch = BeginScratch(arena);
WIN32_FIND_DATAW find_data = ZI;
WIN32_FIND_DATAW find_data = Zi;
String filter = StringF(scratch.arena, "%F\\*", FmtString(path));
wchar_t *filter_wstr = WstrFromString(scratch.arena, filter);
HANDLE find_handle = FindFirstFileExW(filter_wstr, FindExInfoStandard, &find_data, FindExSearchNameMatch, 0, FIND_FIRST_EX_CASE_SENSITIVE | FIND_FIRST_EX_LARGE_FETCH);
@ -139,7 +139,7 @@ u64 OS_LastWriteTimestampFromPath(String path)
{
TempArena scratch = BeginScratchNoConflict();
u64 result = 0;
WIN32_FILE_ATTRIBUTE_DATA a = ZI;
WIN32_FILE_ATTRIBUTE_DATA a = Zi;
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
if (GetFileAttributesExW(path_wstr, GetFileExInfoStandard, &a))
{
@ -202,12 +202,12 @@ void OS_Rm(String path)
OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
{
TempArena scratch = BeginScratch(arena);
OS_CommandResult result = ZI;
OS_CommandResult result = Zi;
b32 ok = 1;
wchar_t *cmd_wstr = WstrFromString(scratch.arena, cmd);
SECURITY_ATTRIBUTES sa = ZI;
SECURITY_ATTRIBUTES sa = Zi;
sa.nLength = sizeof(sa);
sa.bInheritHandle = 0;
@ -238,7 +238,7 @@ OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
}
/* Initialize attrs list */
LPPROC_THREAD_ATTRIBUTE_LIST attrs = ZI;
LPPROC_THREAD_ATTRIBUTE_LIST attrs = Zi;
if (ok)
{
u64 attrs_size = 0;
@ -271,8 +271,8 @@ OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
HANDLE process_thread = 0;
if (ok)
{
PROCESS_INFORMATION pi = ZI;
STARTUPINFOEXW si = ZI;
PROCESS_INFORMATION pi = Zi;
STARTUPINFOEXW si = Zi;
si.StartupInfo.cb = sizeof(si);
si.StartupInfo.dwFlags = STARTF_USESTDHANDLES;
si.StartupInfo.hStdOutput = child_pipe_write;
@ -306,7 +306,7 @@ OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
b32 stdout_finished = 0;
while (!stdout_finished)
{
u8 buff[4096] = ZI;
u8 buff[4096] = Zi;
DWORD bytes_read = 0;
if (!ReadFile(pipe_read, buff, countof(buff), &bytes_read, 0))
{

View File

@ -1,4 +1,4 @@
P_W32_SharedState P_W32_shared_state = ZI;
P_W32_SharedState P_W32_shared_state = Zi;
////////////////////////////////////////////////////////////
//~ @hookimpl Bootstrap
@ -73,7 +73,7 @@ String P_W32_StringFromWin32Path(Arena *arena, wchar_t *src)
P_W32_Address P_W32_Win32AddressFromPlatformAddress(P_Address addr)
{
P_W32_Address result = ZI;
P_W32_Address result = Zi;
if (addr.family == P_AddressFamily_Ipv4)
{
result.family = AF_INET;
@ -136,7 +136,7 @@ P_W32_Address P_W32_ConvertAnyaddrToLocalhost(P_W32_Address addr)
P_Address P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr)
{
P_Address result = ZI;
P_Address result = Zi;
if (ws_addr.family == AF_INET)
{
result.family = P_AddressFamily_Ipv4;
@ -170,7 +170,7 @@ void P_W32_SyncTimerForever(WaveLaneCtx *lane)
}
i32 periods_index = 0;
i64 periods[P_W32_NumRollingTimerPeriods] = ZI;
i64 periods[P_W32_NumRollingTimerPeriods] = Zi;
for (i32 i = 0; i < (i32)countof(periods); ++i)
{
periods[i] = P_W32_DefaultTimerPeriodNs;
@ -182,7 +182,7 @@ void P_W32_SyncTimerForever(WaveLaneCtx *lane)
{
{
/* TODO: Minimum timer frequency in case timers ever become ultra precise in the future */
LARGE_INTEGER due = ZI;
LARGE_INTEGER due = Zi;
due.QuadPart = -1;
//due.QuadPart = -10000;
//due.QuadPart = -32000;
@ -230,7 +230,7 @@ String P_GetWritePath(Arena *arena)
0,
&p
);
String path = ZI;
String path = Zi;
if (result == S_OK)
{
path = P_W32_StringFromWin32Path(arena, p);
@ -262,7 +262,7 @@ void P_MkDir(String path)
TempArena scratch = BeginScratchNoConflict();
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
int err_code = SHCreateDirectory(0, path_wstr);
String err = ZI;
String err = Zi;
switch (err_code)
{
default: break;
@ -302,7 +302,7 @@ void P_MkDir(String path)
P_File P_OpenFileRead(String path)
{
TempArena scratch = BeginScratchNoConflict();
P_File file = ZI;
P_File file = Zi;
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
HANDLE handle = CreateFileW(
@ -324,7 +324,7 @@ P_File P_OpenFileRead(String path)
P_File P_OpenFileReadWait(String path)
{
TempArena scratch = BeginScratchNoConflict();
P_File file = ZI;
P_File file = Zi;
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
i32 delay_ms = 1;
@ -354,7 +354,7 @@ P_File P_OpenFileReadWait(String path)
P_File P_OpenFileWrite(String path)
{
TempArena scratch = BeginScratchNoConflict();
P_File file = ZI;
P_File file = Zi;
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
HANDLE handle = CreateFileW(
@ -376,7 +376,7 @@ P_File P_OpenFileWrite(String path)
P_File P_OpenFileAppend(String path)
{
TempArena scratch = BeginScratchNoConflict();
P_File file = ZI;
P_File file = Zi;
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
HANDLE handle = CreateFileW(
@ -503,7 +503,7 @@ P_FileTime P_GetFileTime(P_File file)
P_FileMap P_OpenFileMap(P_File file)
{
P_FileMap map = ZI;
P_FileMap map = Zi;
u64 size = P_GetFileSize(file);
u8 *base_ptr = 0;
@ -570,9 +570,9 @@ String P_GetFileMapData(P_FileMap map)
P_Address P_AddressFromIpPortCstr(char *ip_cstr, char *port_cstr)
{
P_Address result = ZI;
P_Address result = Zi;
struct addrinfo hints = ZI;
struct addrinfo hints = Zi;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE;
@ -742,7 +742,7 @@ P_Address P_AddressFromPort(u16 port)
String P_StringFromAddress(Arena *arena, P_Address address)
{
String result = ZI;
String result = Zi;
if (address.family == P_AddressFamily_Ipv6)
{
@ -823,13 +823,13 @@ P_SockReadResult P_ReadSock(Arena *arena, P_Sock *sock)
P_W32_Sock *ws = (P_W32_Sock *)sock;
u64 read_buff_size = Kibi(64);
String read_buff = ZI;
String read_buff = Zi;
read_buff.len = read_buff_size;
read_buff.text = PushStructsNoZero(arena, u8, read_buff_size);
P_SockReadResult result = ZI;
P_SockReadResult result = Zi;
P_W32_Address ws_addr = ZI;
P_W32_Address ws_addr = Zi;
ws_addr.size = sizeof(ws_addr.sas);
i32 size = recvfrom(ws->sock, (char *)read_buff.text, read_buff.len, 0, &ws_addr.sa, &ws_addr.size);
@ -945,7 +945,7 @@ void P_SetClipboardText(String str)
String P_GetClipboardText(Arena *arena)
{
String result = ZI;
String result = Zi;
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(0))
{
HANDLE handle = GetClipboardData(CF_UNICODETEXT);

View File

@ -1,7 +1,9 @@
S_SharedState S_shared_state = ZI;
S_Ctx S = Zi;
Readonly S_Ent S_nil_ent = {
.xf = CompXformIdentity
Readonly S_ReadonlyCtx S_ro = {
.nil_ent = {
.xf = CompXformIdentity
}
};
////////////////////////////////////////////////////////////
@ -9,17 +11,15 @@ Readonly S_Ent S_nil_ent = {
void S_Bootstrap(void)
{
S_SharedState *shared = &S_shared_state;
/* Initialize shared state */
for (u64 i = 0; i < countof(shared->input_states); ++i)
for (u64 i = 0; i < countof(S.input_states); ++i)
{
S_InputState *input = &shared->input_states[i];
S_InputState *input = &S.input_states[i];
input->arena = AcquireArena(Gibi(64));
}
for (u64 i = 0; i < countof(shared->output_states); ++i)
for (u64 i = 0; i < countof(S.output_states); ++i)
{
S_OutputState *output = &shared->output_states[i];
S_OutputState *output = &S.output_states[i];
output->arena = AcquireArena(Gibi(64));
}
@ -29,9 +29,8 @@ void S_Bootstrap(void)
void S_Shutdown(void)
{
S_SharedState *shared = &S_shared_state;
Atomic32Set(&shared->shutdown, 1);
YieldOnFence(&shared->worker_completion_fence, shared->workers_count);
Atomic32Set(&S.shutdown, 1);
YieldOnFence(&S.worker_completion_fence, S.workers_count);
}
////////////////////////////////////////////////////////////
@ -44,7 +43,7 @@ b32 S_IsKeyNil(S_Key key)
b32 S_IsEntNil(S_Ent *ent)
{
return ent == 0 || ent == &S_nil_ent;
return ent == 0 || ent == &S_ro.nil_ent;
}
b32 S_MatchKey(S_Key a, S_Key b)
@ -58,7 +57,7 @@ b32 S_MatchKey(S_Key a, S_Key b)
S_Key S_RandKey(void)
{
/* TODO: Don't use true randomness for entity keys. It's overkill & non-deterministic. */
S_Key result = ZI;
S_Key result = Zi;
TrueRand(StringFromStruct(&result));
return result;
}
@ -69,11 +68,11 @@ S_Key S_RandKey(void)
S_Shape S_ShapeFromDescEx(S_ShapeDesc desc)
{
desc.count = MaxI32(desc.count, 1);
S_Shape result = ZI;
S_Shape result = Zi;
{
result.points_count = desc.count;
CopyStructs(result.points, desc.points, result.points_count);
Vec2 accum = ZI;
Vec2 accum = Zi;
for (i32 p_idx = 0; p_idx < result.points_count; ++p_idx)
{
accum = AddVec2(accum, result.points[p_idx]);
@ -100,7 +99,7 @@ S_Shape S_MulXformShape(Xform xf, S_Shape shape)
Vec2 S_SupportPointFromShape(S_Shape shape, Vec2 dir)
{
Vec2 result = ZI;
Vec2 result = Zi;
f32 max_dot = -F32Infinity;
for (i32 i = 0; i < shape.points_count; ++i)
{
@ -121,7 +120,7 @@ Vec2 S_SupportPointFromShape(S_Shape shape, Vec2 dir)
S_Lookup S_LookupFromWorld(Arena *arena, S_World *world)
{
S_Lookup lookup = ZI;
S_Lookup lookup = Zi;
lookup.bins_count = 4096;
lookup.bins = PushStructs(arena, S_LookupEntNode *, lookup.bins_count);
@ -143,7 +142,7 @@ S_Lookup S_LookupFromWorld(Arena *arena, S_World *world)
S_Ent *S_EntFromKey(S_Lookup *lookup, S_Key key)
{
S_Ent *result = &S_nil_ent;
S_Ent *result = &S_ro.nil_ent;
if (!S_IsKeyNil(key))
{
i64 bins_count = lookup->bins_count;
@ -176,7 +175,7 @@ S_Ent *S_FirstEnt(S_Iter *iter, S_World *world)
S_Ent *S_NextEnt(S_Iter *iter)
{
S_World *world = iter->world;
S_Ent *result = &S_nil_ent;
S_Ent *result = &S_ro.nil_ent;
i64 ent_idx = iter->cur_idx;
for (; ent_idx < world->ents_count; ++ent_idx)
@ -235,7 +234,6 @@ MergesortCompareFuncDef(S_SortEntsByKeyCmp, arg_a, arg_b, _)
void S_TickForever(WaveLaneCtx *lane)
{
S_SharedState *shared = &S_shared_state;
Arena *frame_arena = AcquireArena(Gibi(64));
Arena *perm = PermArena();
@ -253,8 +251,8 @@ void S_TickForever(WaveLaneCtx *lane)
while (!shutdown)
{
ResetArena(frame_arena);
S_Iter iter = ZI;
S_Lookup lookup = ZI;
S_Iter iter = Zi;
S_Lookup lookup = Zi;
//////////////////////////////
//- Begin sim frame
@ -270,16 +268,16 @@ void S_TickForever(WaveLaneCtx *lane)
//- Pop sim commands
S_InputState *input = 0;
LockTicketMutex(&shared->input_back_tm);
LockTicketMutex(&S.input_back_tm);
{
input = &shared->input_states[shared->input_back_idx];
++shared->input_back_idx;
if (shared->input_back_idx >= countof(shared->input_states))
input = &S.input_states[S.input_back_idx];
++S.input_back_idx;
if (S.input_back_idx >= countof(S.input_states))
{
shared->input_back_idx = 0;
S.input_back_idx = 0;
}
}
UnlockTicketMutex(&shared->input_back_tm);
UnlockTicketMutex(&S.input_back_tm);
//////////////////////////////
//- Spawn entities
@ -307,7 +305,7 @@ void S_TickForever(WaveLaneCtx *lane)
{
dst = PushStructNoZero(ents_arena, S_Ent);
}
*dst = S_nil_ent;
*dst = S_ro.nil_ent;
dst->key = key;
++world->ents_count;
}
@ -367,7 +365,7 @@ void S_TickForever(WaveLaneCtx *lane)
if (follow->active)
{
f32 follow_speed = 20 * sim_dt;
Vec2 look_ratio = ZI;
Vec2 look_ratio = Zi;
look_ratio.y = 0.25;
look_ratio.x = look_ratio.y / (16.0 / 9.0);
@ -384,9 +382,9 @@ void S_TickForever(WaveLaneCtx *lane)
//- Publish sim state
/* TODO: Only copy active entities */
LockTicketMutex(&shared->output_back_tm);
LockTicketMutex(&S.output_back_tm);
{
S_OutputState *output = &shared->output_states[shared->output_back_idx];
S_OutputState *output = &S.output_states[S.output_back_idx];
ResetArena(output->arena);
S_SnapshotNode *snapshot_node = PushStruct(output->arena, S_SnapshotNode);
S_Snapshot *snapshot = &snapshot_node->snapshot;
@ -402,7 +400,7 @@ void S_TickForever(WaveLaneCtx *lane)
*dst = *src;
}
}
UnlockTicketMutex(&shared->output_back_tm);
UnlockTicketMutex(&S.output_back_tm);
//////////////////////////////
//- End sim frame
@ -422,11 +420,11 @@ void S_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Sleep
if (!Atomic32Fetch(&shared->shutdown))
if (!Atomic32Fetch(&S.shutdown))
{
i64 step_dt_ns = NsFromSeconds(1) / SIM_TICKS_PER_SECOND;
P_SleepFrame(frame_begin_ns, step_dt_ns);
}
shutdown = Atomic32Fetch(&shared->shutdown);
shutdown = Atomic32Fetch(&S.shutdown);
}
}

View File

@ -64,7 +64,7 @@ Struct(S_Ent)
i64 next_free_ent_num;
} extern Readonly S_nil_ent;
};
////////////////////////////////////////////////////////////
//~ Ent container types
@ -165,7 +165,7 @@ Struct(S_CmdNode)
};
////////////////////////////////////////////////////////////
//~ State types
//~ Context types
#define S_InputStatesCount 2
#define S_OutputStatesCount 2
@ -186,7 +186,7 @@ Struct(S_OutputState)
u64 snapshots_count;
};
Struct(S_SharedState)
Struct(S_Ctx)
{
Atomic32 shutdown;
Fence worker_completion_fence;
@ -202,7 +202,15 @@ Struct(S_SharedState)
i32 output_back_idx;
S_OutputState output_states[S_OutputStatesCount];
} extern S_shared_state;
};
Struct(S_ReadonlyCtx)
{
S_Ent nil_ent;
};
extern S_Ctx S;
extern Readonly S_ReadonlyCtx S_ro;
////////////////////////////////////////////////////////////
//~ Bootstrap

View File

@ -1,4 +1,4 @@
V_State V = ZI;
V_Ctx V = Zi;
////////////////////////////////////////////////////////////
//~ Bootstrap
@ -20,7 +20,6 @@ void V_Shutdown(void)
void V_TickForever(WaveLaneCtx *lane)
{
Arena *perm = PermArena();
S_SharedState *sim_shared = &S_shared_state;
//////////////////////////////
//- Init vis state
@ -48,10 +47,10 @@ void V_TickForever(WaveLaneCtx *lane)
b32 show_command_palette;
b32 show_console;
};
Persist persist = ZI;
String window_restore = ZI;
Persist persist = Zi;
String window_restore = Zi;
Button held_buttons[Button_Count] = ZI;
Button held_buttons[Button_Count] = Zi;
/* Init shortcuts */
u64 shortcut_bins_count = 1024;
@ -141,8 +140,8 @@ void V_TickForever(WaveLaneCtx *lane)
frame->time_ns = TimeNs();
frame->tick = last_frame->tick + 1;
S_Iter iter = ZI;
S_EntList spawn_ents = ZI;
S_Iter iter = Zi;
S_EntList spawn_ents = Zi;
//////////////////////////////
//- Spawn test ents
@ -159,7 +158,7 @@ void V_TickForever(WaveLaneCtx *lane)
SllQueuePush(spawn_ents.first, spawn_ents.last, n);
++spawn_ents.count;
S_Ent *ent = &n->ent;
*ent = S_nil_ent;
*ent = S_ro.nil_ent;
switch (i)
{
/* Test player */
@ -224,7 +223,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_Key vis_box = UI_KeyF("vis box");
UI_Push(Parent, UI_BuildColumnEx(vis_box));
Vec2I32 draw_size = ZI;
Vec2I32 draw_size = Zi;
{
/* TODO: Don't rely on ui report for draw size since it introduces one frame of delay when resizing */
UI_Report vis_rep = UI_ReportFromKey(vis_box);
@ -237,16 +236,16 @@ void V_TickForever(WaveLaneCtx *lane)
//- Pop sim output
S_OutputState *sim_output = 0;
LockTicketMutex(&sim_shared->output_back_tm);
LockTicketMutex(&S.output_back_tm);
{
sim_output = &sim_shared->output_states[sim_shared->output_back_idx];
++sim_shared->output_back_idx;
if (sim_shared->output_back_idx >= countof(sim_shared->output_states))
sim_output = &S.output_states[S.output_back_idx];
++S.output_back_idx;
if (S.output_back_idx >= countof(S.output_states))
{
sim_shared->output_back_idx = 0;
S.output_back_idx = 0;
}
}
UnlockTicketMutex(&sim_shared->output_back_tm);
UnlockTicketMutex(&S.output_back_tm);
if (sim_output->last_snapshot_node && sim_output->last_snapshot_node->snapshot.tick > V.world->tick)
{
@ -260,7 +259,7 @@ void V_TickForever(WaveLaneCtx *lane)
f32 meters_per_draw_width = 20;
Vec2 camera_pos = ZI;
Vec2 camera_pos = Zi;
f32 camera_zoom = 1;
{
S_Ent *player = S_EntFromKey(&V.lookup, V.player_key);
@ -275,7 +274,7 @@ void V_TickForever(WaveLaneCtx *lane)
Xform world_to_draw_xf = XformIdentity;
Xform draw_to_world_xf = XformIdentity;
{
Vec2 scale = ZI;
Vec2 scale = Zi;
scale.x = (f32)draw_size.x / meters_per_draw_width;
scale.y = scale.x;
world_to_draw_xf = XformFromScale(scale);
@ -322,7 +321,7 @@ void V_TickForever(WaveLaneCtx *lane)
b32 up = cev.kind == ControllerEventKind_ButtonUp;
if (down || up)
{
V_Hotkey hotkey = ZI;
V_Hotkey hotkey = Zi;
hotkey.button = cev.button;
hotkey.ctrl = held_buttons[Button_Ctrl];
hotkey.shift = held_buttons[Button_Shift];
@ -362,7 +361,7 @@ void V_TickForever(WaveLaneCtx *lane)
V_CmdDesc desc = V_cmd_descs[i];
if (!desc.flags & V_CmdDescFlag_HideFromPalette)
{
V_CommandsWidgetItemDesc item_desc = ZI;
V_CommandsWidgetItemDesc item_desc = Zi;
item_desc.display_name = desc.display_name;
/* FIXME: Attach active shortcuts instead of default hotkeys */
CopyStructs(item_desc.hotkeys, desc.default_hotkeys, MinU32(countof(item_desc.hotkeys), countof(desc.default_hotkeys)));
@ -486,9 +485,9 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Submit sim commands
LockTicketMutex(&sim_shared->input_back_tm);
LockTicketMutex(&S.input_back_tm);
{
S_InputState *v2s = &sim_shared->input_states[sim_shared->input_back_idx];
S_InputState *v2s = &S.input_states[S.input_back_idx];
/* Submit control cmd */
{
@ -500,14 +499,14 @@ void V_TickForever(WaveLaneCtx *lane)
cmd = &cmd_node->cmd;
}
cmd->kind = S_CmdKind_Control;
Vec2 move = ZI;
Vec2 move = Zi;
{
if (held_buttons[Button_A]) move.x -= 1;
if (held_buttons[Button_D]) move.x += 1;
if (held_buttons[Button_W]) move.y -= 1;
if (held_buttons[Button_S]) move.y += 1;
}
Vec2 look = ZI;
Vec2 look = Zi;
{
S_Ent *player = S_EntFromKey(&V.lookup, V.player_key);
Vec2 center = MulXformV2(player->xf, player->local_shape.centroid);
@ -541,7 +540,7 @@ void V_TickForever(WaveLaneCtx *lane)
}
}
}
UnlockTicketMutex(&sim_shared->input_back_tm);
UnlockTicketMutex(&S.input_back_tm);
//////////////////////////////
//- Render
@ -608,7 +607,7 @@ void V_TickForever(WaveLaneCtx *lane)
G_IndexBufferDesc dvert_idxs_ib = G_IdxBuff32(dvert_idxs_buff);
/* Params */
V_DParams params = ZI;
V_DParams params = Zi;
{
params.target_size = draw_size;
params.target_ro = draw_target_ro;
@ -659,7 +658,7 @@ void V_TickForever(WaveLaneCtx *lane)
G_DumbMemoryLayoutSync(frame->cl, draw_target, G_Layout_DirectQueue_ShaderRead);
{
Rng2 uv = ZI;
Rng2 uv = Zi;
uv.p0 = Vec2FromVec(viewport.p0);
uv.p1 = Vec2FromVec(viewport.p1);
uv = DivRng2Vec2(uv, Vec2FromVec(draw_size));

View File

@ -71,7 +71,7 @@ Global Readonly V_CmdDesc V_cmd_descs[V_CmdKind_Count] = {
};
////////////////////////////////////////////////////////////
//~ State types
//~ Context types
Struct(V_Frame)
{
@ -85,7 +85,7 @@ Struct(V_Frame)
G_CommandListHandle cl;
};
Struct(V_State)
Struct(V_Ctx)
{
Arena *world_arena;
S_World *world;
@ -97,7 +97,9 @@ Struct(V_State)
u64 current_frame_idx;
V_Frame frames[2];
} extern V;
};
extern V_Ctx V;
////////////////////////////////////////////////////////////
//~ Bootstrap

View File

@ -97,7 +97,7 @@ void V_DrawShape(Arena *verts_arena, Arena *idxs_arena, S_Shape shape, Vec4 colo
{
if (shape.radius == 0)
{
Vec2Array draw_points = ZI;
Vec2Array draw_points = Zi;
draw_points.points = shape.points;
draw_points.count = shape.points_count;
V_DrawPoly(verts_arena, idxs_arena, draw_points, color_lin, flags);
@ -106,7 +106,7 @@ void V_DrawShape(Arena *verts_arena, Arena *idxs_arena, S_Shape shape, Vec4 colo
{
TempArena scratch = BeginScratchNoConflict();
{
Vec2Array draw_points = ZI;
Vec2Array draw_points = Zi;
draw_points.points = PushStructsNoZero(scratch.arena, Vec2, detail);
draw_points.count = detail;
for (i32 i = 0; i < detail; ++i)

View File

@ -3,7 +3,7 @@
V_WidgetTheme V_GetWidgetTheme(void)
{
V_WidgetTheme theme = ZI;
V_WidgetTheme theme = Zi;
theme.font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/fixedsys.ttf")));
theme.font_size = 16;
@ -40,7 +40,7 @@ void V_PushWidgetThemeStyles(V_WidgetTheme theme)
String V_StringFromHotkey(Arena *arena, V_Hotkey hotkey)
{
TempArena scratch = BeginScratch(arena);
StringList parts = ZI;
StringList parts = Zi;
if (hotkey.ctrl)
{
PushStringToList(scratch.arena, &parts, Lit("Ctrl"));
@ -81,7 +81,7 @@ V_CommandsWidgetItemReport V_PushCommandsWidgetItem(V_CommandsWidget *widget, V_
++widget->build.num_items;
}
V_CommandsWidgetItemReport result = ZI;
V_CommandsWidgetItemReport result = Zi;
UI_Report rep = UI_ReportFromKey(key);
result.ui_report = rep;
result.pressed = rep.m1_presses > 0;
@ -100,8 +100,8 @@ void V_EndCommandsWidget(V_CommandsWidget *widget)
Vec4 window_background_color = theme.window_background_color;
Vec4 window_border_color = theme.window_border_color;
Vec4 titlebar_color = ZI;
Vec4 titlebar_border_color = ZI;
Vec4 titlebar_color = Zi;
Vec4 titlebar_border_color = Zi;
Vec4 divider_color = theme.divider_color;
{
UI_Report rep = UI_ReportFromKey(titlebar_key);
@ -179,7 +179,7 @@ void V_EndCommandsWidget(V_CommandsWidget *widget)
UI_Report btn_rep = UI_ReportFromKey(btn_key);
Vec4 btn_color = theme.window_background_color;
Vec4 btn_border_color = ZI;
Vec4 btn_border_color = Zi;
{
Vec4 hovered_color = Rgb32(0x103c4c);
Vec4 pressed_color = hovered_color;
@ -223,8 +223,8 @@ void V_EndCommandsWidget(V_CommandsWidget *widget)
UI_Key hotkey_key = UI_KeyF("hotkey%F", FmtUint(i));
UI_Report hotkey_rep = UI_ReportFromKey(hotkey_key);
Vec4 hotkey_color = ZI;
Vec4 hotkey_border_color = ZI;
Vec4 hotkey_color = Zi;
Vec4 hotkey_border_color = Zi;
{
Vec4 hovered_color = Rgb32(0x103c4c);
Vec4 pressed_color = hovered_color;
@ -293,7 +293,7 @@ UI_Key V_BuildConsoleWidget(b32 minimized)
// i32 console_level = minimized ? LogLevel_Success : LogLevel_Debug;
i32 console_level = LogLevel_Debug;
Vec4 colors[LogLevel_Count][2] = ZI;
Vec4 colors[LogLevel_Count][2] = Zi;
SetBytes(colors, 0xFF, sizeof(colors));
/* Debug colors */
colors[LogLevel_Debug][0] = Rgb(0.4, 0.1, 0.4);
@ -321,7 +321,7 @@ UI_Key V_BuildConsoleWidget(b32 minimized)
f32 fade_curve = 0.5;
i64 now_ns = TimeNs();
UI_Key console_box = ZI;
UI_Key console_box = Zi;
{
UI_SetNext(Border, 0);
if (minimized)

View File

@ -1,7 +1,7 @@
/* Based on Allen Webster's dwrite rasterizer example -
* https://github.com/4th-dimention/examps */
extern TTF_DW_Ctx TTF_DW = ZI;
extern TTF_DW_Ctx TTF_DW = Zi;
////////////////////////////////////////////////////////////
//~ @hookimpl Bootstrap
@ -172,7 +172,7 @@ TTF_GlyphResult TTF_RasterizeGlyphFromCodepoint(Arena *arena, u32 codepoint, Res
f32 font_descent = font->design_metrics.descent * pixels_per_design_unit;
f32 font_cap = font->design_metrics.capHeight * pixels_per_design_unit;
TTF_GlyphResult result = ZI;
TTF_GlyphResult result = Zi;
{
if (SUCCEEDED(hr))
{
@ -199,7 +199,7 @@ TTF_GlyphResult TTF_RasterizeGlyphFromCodepoint(Arena *arena, u32 codepoint, Res
rt = PushStruct(perm, TTF_DW_RenderTarget);
IDWriteBitmapRenderTarget *dw_rt = 0;
HDC dc = 0;
DIBSECTION dib = ZI;
DIBSECTION dib = Zi;
if (SUCCEEDED(hr))
{
hr = IDWriteGdiInterop_CreateBitmapRenderTarget(TTF_DW.gdi_interop, 0, (UINT32)rt_dims.x, (UINT32)rt_dims.y, &dw_rt);
@ -234,7 +234,7 @@ TTF_GlyphResult TTF_RasterizeGlyphFromCodepoint(Arena *arena, u32 codepoint, Res
}
/* Glyph metrics */
DWRITE_GLYPH_METRICS m = ZI;
DWRITE_GLYPH_METRICS m = Zi;
if (SUCCEEDED(hr))
{
hr = IDWriteFontFace_GetDesignGlyphMetrics(font->face, &glyph_idx, 1, &m, 0);
@ -242,12 +242,12 @@ TTF_GlyphResult TTF_RasterizeGlyphFromCodepoint(Arena *arena, u32 codepoint, Res
f32 advance = (f32)m.advanceWidth * pixels_per_design_unit;
/* Best-guess a position in the middle of the render target based on metrics */
Vec2I32 rt_baseline = ZI;
Vec2I32 rt_baseline = Zi;
rt_baseline.x = (rt_dims.x / 2) - (advance / 2);
rt_baseline.y = (rt_dims.y / 2) + (font_cap / 2);
/* Render */
Rng2I32 rt_slice = ZI;
Rng2I32 rt_slice = Zi;
if (SUCCEEDED(hr))
{
/* Clear target */
@ -263,14 +263,14 @@ TTF_GlyphResult TTF_RasterizeGlyphFromCodepoint(Arena *arena, u32 codepoint, Res
}
/* Draw glyph */
{
DWRITE_GLYPH_RUN glyph_run = ZI;
DWRITE_GLYPH_RUN glyph_run = Zi;
{
glyph_run.fontFace = font->face;
glyph_run.fontEmSize = pixels_per_em;
glyph_run.glyphCount = 1;
glyph_run.glyphIndices = &glyph_idx;
}
RECT bounding_box = ZI;
RECT bounding_box = Zi;
hr = IDWriteBitmapRenderTarget_DrawGlyphRun(
rt->dw_rt,
rt_baseline.x,
@ -296,7 +296,7 @@ TTF_GlyphResult TTF_RasterizeGlyphFromCodepoint(Arena *arena, u32 codepoint, Res
//- Copy result
/* Copy from target to result */
Vec2I32 dst_dims = ZI;
Vec2I32 dst_dims = Zi;
u32 *dst_pixels = 0;
if (SUCCEEDED(hr))
{

View File

@ -1,4 +1,4 @@
UI_State UI_state = ZI;
UI_State UI_state = Zi;
////////////////////////////////////////////////////////////
//~ Bootstrap
@ -21,14 +21,14 @@ GC_FontKey UI_GetDefaultFont(void)
UI_Key UI_KeyFromString(String str)
{
u64 top_tag = UI_UseTop(Tag);
UI_Key key = ZI;
UI_Key key = Zi;
key.hash = HashFnv64(top_tag, str);
return key;
}
UI_Key UI_KeyF_(String fmt, ...)
{
UI_Key key = ZI;
UI_Key key = Zi;
TempArena scratch = BeginScratchNoConflict();
{
va_list args;
@ -45,7 +45,7 @@ UI_Key UI_TransKey(void)
{
UI_Frame *frame = UI_CurrentFrame();
u64 seed = ++frame->transient_key_seed;
UI_Key key = ZI;
UI_Key key = Zi;
key.hash = RandU64FromSeed(seed);
return key;
}
@ -75,7 +75,7 @@ UI_Box *UI_BoxFromKey(UI_Key key)
String UI_StringF_(String fmt, ...)
{
UI_Frame *frame = UI_CurrentFrame();
String result = ZI;
String result = Zi;
TempArena scratch = BeginScratchNoConflict();
{
va_list args;
@ -139,7 +139,7 @@ void UI_PushDefaults(void)
{
for (UI_StyleKind kind = UI_StyleKind_None; kind < UI_StyleKind_Count; ++kind)
{
UI_StyleDesc desc = ZI;
UI_StyleDesc desc = Zi;
desc.style.kind = kind;
switch (kind)
{
@ -149,7 +149,7 @@ void UI_PushDefaults(void)
case UI_StyleKind_Height: { desc.style.Height = UI_GROW(1, 0); }
case UI_StyleKind_Font: { desc.style.Font = UI_GetDefaultFont(); } break;
u8 prefetch[127] = ZI;
u8 prefetch[127] = Zi;
for (u64 idx = 0; idx < countof(prefetch); ++idx)
{
prefetch[idx] = idx;
@ -299,7 +299,7 @@ UI_Style UI_PopStyle(UI_StyleDesc desc)
{
UI_Frame *frame = UI_CurrentFrame();
UI_Stack *stack = frame->top_stack;
UI_Style result = ZI;
UI_Style result = Zi;
UI_StyleKind kind = desc.style.kind;
result.kind = kind;
if (kind >= UI_StyleKind_BeginVirtualStyles_)
@ -431,7 +431,7 @@ void UI_SetRawTexture(UI_Key key, G_Texture2DRef tex, Rng2 uv)
UI_Report UI_ReportFromKey(UI_Key key)
{
UI_State *g = &UI_state;
UI_Report result = ZI;
UI_Report result = Zi;
UI_Box *box = UI_BoxFromKey(key);
if (box)
@ -1095,7 +1095,7 @@ void UI_EndFrame(UI_Frame *frame)
{
f32 *dims_arr = box->solved_dims;
Vec2 dims_vec = VEC2(dims_arr[0], dims_arr[1]);
Vec2 final_pos = ZI;
Vec2 final_pos = Zi;
/* Floating box position */
if (AnyBit(box->desc.flags, UI_BoxFlag_Floating))
@ -1118,7 +1118,7 @@ void UI_EndFrame(UI_Frame *frame)
else if (parent)
{
f32 layout_cursor = parent->layout_cursor;
f32 offset[2] = ZI;
f32 offset[2] = Zi;
/* Compute offset in layout direction */
{
Axis axis = parent->desc.child_layout_axis;
@ -1302,7 +1302,7 @@ void UI_EndFrame(UI_Frame *frame)
f32 baseline_width = raw_run.baseline_length;
f32 baseline_height = ascent + font_descent;
Vec2 box_dims = DimsFromRng2(box->rect);
Vec2 baseline = ZI;
Vec2 baseline = Zi;
switch (x_alignment)
{
case UI_AxisAlignment_Start:
@ -1381,7 +1381,7 @@ void UI_EndFrame(UI_Frame *frame)
G_StructuredBufferRef rects_ro = G_PushStructuredBufferRef(frame->gpu_arena, rects_buff, UI_DRect);
/* Params */
UI_DParams params = ZI;
UI_DParams params = Zi;
{
params.target_size = draw_size;
params.target_ro = draw_target_ro;

View File

@ -9,7 +9,7 @@ UI_Key UI_BuildLabel(String text)
Vec4 tint = UI_UseTop(Tint);
UI_Alignment alignment = UI_UseTop(ChildAlignment);
UI_Key key = ZI;
UI_Key key = Zi;
UI_PushCP(UI_NilKey);
{
UI_PushDefaults();
@ -30,7 +30,7 @@ UI_Key UI_BuildLabel(String text)
UI_Key UI_BuildLabelF_(String fmt, ...)
{
UI_Key key = ZI;
UI_Key key = Zi;
TempArena scratch = BeginScratchNoConflict();
{
va_list va;
@ -49,7 +49,7 @@ UI_Key UI_BuildLabelF_(String fmt, ...)
UI_Key UI_BuildSpacer(UI_Size size, Axis axis)
{
UI_Key parent = UI_UseTop(Parent);
UI_Key key = ZI;
UI_Key key = Zi;
UI_PushCP(UI_NilKey);
{
UI_PushDefaults();
@ -65,7 +65,7 @@ UI_Key UI_BuildSpacer(UI_Size size, Axis axis)
UI_Key UI_BuildDivider(UI_Size size, Vec4 color, Axis axis)
{
UI_Key key = ZI;
UI_Key key = Zi;
UI_Key parent = UI_UseTop(Parent);
Vec4 tint = UI_UseTop(Tint);
UI_PushCP(UI_NilKey);

View File

@ -1,4 +1,4 @@
WND_W32_SharedState WND_W32_shared_state = ZI;
WND_W32_SharedState WND_W32_shared_state = Zi;
////////////////////////////////////////////////////////////
//~ @hookimpl Bootstrap
@ -67,7 +67,7 @@ void WND_Bootstrap(void)
wc->hInstance = instance;
/* Use first icon resource as window icon (same as explorer) */
wchar_t path[4096] = ZI;
wchar_t path[4096] = Zi;
GetModuleFileNameW(instance, path, countof(path));
ExtractIconExW(path, 0, &wc->hIcon, &wc->hIconSm, 1);
@ -79,7 +79,7 @@ void WND_Bootstrap(void)
//- Register raw mouse input
{
RAWINPUTDEVICE rid = ZI;
RAWINPUTDEVICE rid = Zi;
rid.usUsagePage = 0x01; /* HID_USAGE_PAGE_GENERIC */
rid.usUsage = 0x02; /* HID_USAGE_GENERIC_MOUSE */
RegisterRawInputDevices(&rid, 1, sizeof(rid));
@ -153,7 +153,7 @@ void WND_W32_ProcessMessagesForever(WaveLaneCtx *lane)
for (;;)
{
// SetFocus(window->hwnd);
MSG msg = ZI;
MSG msg = Zi;
GetMessageW(&msg, 0, 0, 0);
{
TranslateMessage(&msg);
@ -207,7 +207,7 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
case WM_KEYDOWN:
{
WORD vk_code = LOWORD(wparam);
ControllerEvent event = ZI;
ControllerEvent event = Zi;
if (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN)
{
event.kind = ControllerEventKind_ButtonDown;
@ -269,7 +269,7 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
}
if ((codepoint >= 32 && codepoint != 127) || codepoint == '\t' || codepoint == '\n')
{
ControllerEvent event = ZI;
ControllerEvent event = Zi;
event.kind = ControllerEventKind_Text;
event.text_codepoint = codepoint;
WND_W32_PushEvent(window, event);
@ -286,7 +286,7 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
case WM_RBUTTONDOWN:
case WM_XBUTTONDOWN:
{
ControllerEvent event = ZI;
ControllerEvent event = Zi;
b32 is_down = msg == WM_LBUTTONDOWN ||
msg == WM_MBUTTONDOWN ||
msg == WM_RBUTTONDOWN ||
@ -344,7 +344,7 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
{
i32 x = GET_X_LPARAM(lparam);
i32 y = GET_Y_LPARAM(lparam);
ControllerEvent event = ZI;
ControllerEvent event = Zi;
event.kind = ControllerEventKind_CursorMove;
event.cursor_pos = VEC2I32(x, y);
WND_W32_PushEvent(window, event);
@ -364,14 +364,14 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
LogErrorF("GetRawInputData did not return correct size");
break;
}
RAWINPUT raw = ZI;
RAWINPUT raw = Zi;
CopyBytes(&raw, buff, sizeof(RAWINPUT));
if (raw.header.dwType == RIM_TYPEMOUSE)
{
i32 x = raw.data.mouse.lLastX;
i32 y = raw.data.mouse.lLastY;
ControllerEvent event = ZI;
ControllerEvent event = Zi;
event.kind = ControllerEventKind_MouseMove;
event.mouse_delta = VEC2I32(x, y);
WND_W32_PushEvent(window, event);
@ -407,7 +407,7 @@ WND_Frame WND_BeginFrame(G_Format backbuffer_format, WND_BackbufferSizeMode back
{
WND_W32_SharedState *g = &WND_W32_shared_state;
WND_W32_Window *window = &g->window;
WND_Frame result = ZI;
WND_Frame result = Zi;
while (!Atomic32Fetch(&window->is_ready))
{
@ -417,7 +417,7 @@ WND_Frame WND_BeginFrame(G_Format backbuffer_format, WND_BackbufferSizeMode back
result.window.v = (u64)window;
/* Grab monitor info */
RECT monitor_rect = ZI;
RECT monitor_rect = Zi;
{
MONITORINFO monitor_info = { .cbSize = sizeof(monitor_info) };
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &monitor_info);
@ -428,7 +428,7 @@ WND_Frame WND_BeginFrame(G_Format backbuffer_format, WND_BackbufferSizeMode back
result.monitor_size.y = MaxI32(result.monitor_size.y, 1);
/* Client rect */
RECT client_rect = ZI;
RECT client_rect = Zi;
GetClientRect(hwnd, (LPRECT)&client_rect);
/* Screen rect */
@ -440,7 +440,7 @@ WND_Frame WND_BeginFrame(G_Format backbuffer_format, WND_BackbufferSizeMode back
result.draw_size.y = MaxI32(result.draw_size.y, 1);
/* Prepare backbuffer */
Vec2I32 backbuffer_size = ZI;
Vec2I32 backbuffer_size = Zi;
if (backbuffer_size_mode == WND_BackbufferSizeMode_MatchWindow)
{
backbuffer_size = result.draw_size;
@ -502,7 +502,7 @@ WND_Frame WND_BeginFrame(G_Format backbuffer_format, WND_BackbufferSizeMode back
/* Generate restore data */
{
WND_W32_RestorableData restore = ZI;
WND_W32_RestorableData restore = Zi;
{
restore.magic = WND_W32_RestoreMagic;
restore.placement = placement;
@ -558,14 +558,14 @@ void WND_EndFrame(WND_Frame frame, i32 vsync)
if (cmd.v != window->is_fullscreen)
{
DWORD old_style = (DWORD)GetWindowLongPtr(hwnd, GWL_STYLE);
RECT old_rect = ZI;
RECT old_rect = Zi;
{
GetClientRect(hwnd, (LPRECT)&old_rect);
ClientToScreen(hwnd, (LPPOINT)&old_rect.left);
ClientToScreen(hwnd, (LPPOINT)&old_rect.right);
AdjustWindowRect(&old_rect, old_style, 0);
}
RECT new_rect = ZI;
RECT new_rect = Zi;
HWND new_hwnd = 0;
DWORD new_style = old_style;
if (cmd.v)