'ZI' -> 'Zi'
This commit is contained in:
parent
af3687f3e5
commit
1de54d60ba
@ -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 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.max_code_bits = max_code_bits;
|
||||||
result.entries_count = (1 << max_code_bits);
|
result.entries_count = (1 << max_code_bits);
|
||||||
result.entries = PushStructsNoZero(arena, ASE_HuffEntry, result.entries_count);
|
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)
|
for (u32 i = 0; i < bl_counts_count; ++i)
|
||||||
{
|
{
|
||||||
u32 count = bl_counts[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];
|
++code_length_hist[count];
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 next_code[ASE_HuffBitCount] = ZI;
|
u32 next_code[ASE_HuffBitCount] = Zi;
|
||||||
next_code[0] = 0;
|
next_code[0] = 0;
|
||||||
code_length_hist[0] = 0;
|
code_length_hist[0] = 0;
|
||||||
for (u32 i = 1; i < countof(next_code); ++i)
|
for (u32 i = 1; i < countof(next_code); ++i)
|
||||||
@ -260,7 +260,7 @@ void ASE_Inflate(u8 *dst, u8 *encoded)
|
|||||||
case ASE_BlockType_CompressedDynamic:
|
case ASE_BlockType_CompressedDynamic:
|
||||||
{
|
{
|
||||||
TempArena temp = BeginTempArena(scratch.arena);
|
TempArena temp = BeginTempArena(scratch.arena);
|
||||||
u32 lit_len_dist_table[512] = ZI;
|
u32 lit_len_dist_table[512] = Zi;
|
||||||
u32 hlit;
|
u32 hlit;
|
||||||
u32 hdist;
|
u32 hdist;
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ void ASE_Inflate(u8 *dst, u8 *encoded)
|
|||||||
u32 hclen = ASE_ConsumeBits(&bb, 4) + 4;
|
u32 hclen = ASE_ConsumeBits(&bb, 4) + 4;
|
||||||
|
|
||||||
/* Init dict huffman (hclen) */
|
/* Init dict huffman (hclen) */
|
||||||
u32 hclen_bl_counts[19] = ZI;
|
u32 hclen_bl_counts[19] = Zi;
|
||||||
for (u32 i = 0; i < hclen; ++i)
|
for (u32 i = 0; i < hclen; ++i)
|
||||||
{
|
{
|
||||||
u32 code = ASE_huff_hclen_order[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)
|
ASE_DecodedImage ASE_DecodeImage(Arena *arena, String encoded)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
ASE_DecodedImage result = ZI;
|
ASE_DecodedImage result = Zi;
|
||||||
|
|
||||||
BB_Buff bb = BB_BuffFromString(encoded);
|
BB_Buff bb = BB_BuffFromString(encoded);
|
||||||
BB_Reader br = BB_ReaderFromBuffNoDebug(&bb);
|
BB_Reader br = BB_ReaderFromBuffNoDebug(&bb);
|
||||||
@ -773,7 +773,7 @@ abort:
|
|||||||
|
|
||||||
ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded)
|
ASE_DecodedSheet ASE_DecodeSheet(Arena *arena, String encoded)
|
||||||
{
|
{
|
||||||
ASE_DecodedSheet result = ZI;
|
ASE_DecodedSheet result = Zi;
|
||||||
|
|
||||||
BB_Buff bb = BB_BuffFromString(encoded);
|
BB_Buff bb = BB_BuffFromString(encoded);
|
||||||
BB_Reader br = BB_ReaderFromBuffNoDebug(&bb);
|
BB_Reader br = BB_ReaderFromBuffNoDebug(&bb);
|
||||||
|
|||||||
@ -155,11 +155,11 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Common utility macros
|
//~ Common utility macros
|
||||||
|
|
||||||
//- ZeroStruct initialization macro
|
//- Zero initialization
|
||||||
#if IsLanguageC
|
#if IsLanguageC
|
||||||
#define ZI { 0 }
|
#define Zi { 0 }
|
||||||
#else
|
#else
|
||||||
#define ZI { }
|
#define Zi { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- Inline
|
//- Inline
|
||||||
|
|||||||
@ -180,7 +180,7 @@ void *ArenaNext_(Arena *arena, u64 align)
|
|||||||
|
|
||||||
TempArena BeginTempArena(Arena *arena)
|
TempArena BeginTempArena(Arena *arena)
|
||||||
{
|
{
|
||||||
TempArena t = ZI;
|
TempArena t = Zi;
|
||||||
t.arena = arena;
|
t.arena = arena;
|
||||||
t.start_pos = arena->pos;
|
t.start_pos = arena->pos;
|
||||||
return t;
|
return t;
|
||||||
|
|||||||
@ -36,7 +36,7 @@ void SignalAsyncTick(void)
|
|||||||
|
|
||||||
void AsyncWorkerEntryPoint(WaveLaneCtx *lane)
|
void AsyncWorkerEntryPoint(WaveLaneCtx *lane)
|
||||||
{
|
{
|
||||||
AsyncTickCtx tick = ZI;
|
AsyncTickCtx tick = Zi;
|
||||||
tick.arena = AcquireArena(Gibi(64));
|
tick.arena = AcquireArena(Gibi(64));
|
||||||
|
|
||||||
/* Tick forever */
|
/* Tick forever */
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
BB_Buff BB_AcquireBuff(u64 arena_reserve)
|
BB_Buff BB_AcquireBuff(u64 arena_reserve)
|
||||||
{
|
{
|
||||||
BB_Buff result = ZI;
|
BB_Buff result = Zi;
|
||||||
result.arena = AcquireArena(arena_reserve);
|
result.arena = AcquireArena(arena_reserve);
|
||||||
result.is_backed_by_arena = 1;
|
result.is_backed_by_arena = 1;
|
||||||
return result;
|
return result;
|
||||||
@ -22,7 +22,7 @@ void BB_ReleaseBuff(BB_Buff *bb)
|
|||||||
|
|
||||||
BB_Buff BB_BuffFromString(String s)
|
BB_Buff BB_BuffFromString(String s)
|
||||||
{
|
{
|
||||||
BB_Buff result = ZI;
|
BB_Buff result = Zi;
|
||||||
result.fixed_buffer = s;
|
result.fixed_buffer = s;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ BB_Buff BB_BuffFromString(String s)
|
|||||||
|
|
||||||
BB_Writer BB_WriterFromBuff(BB_Buff *bb)
|
BB_Writer BB_WriterFromBuff(BB_Buff *bb)
|
||||||
{
|
{
|
||||||
BB_Writer result = ZI;
|
BB_Writer result = Zi;
|
||||||
result.bb = bb;
|
result.bb = bb;
|
||||||
if (bb->is_backed_by_arena)
|
if (bb->is_backed_by_arena)
|
||||||
{
|
{
|
||||||
@ -74,7 +74,7 @@ u64 BB_GetNumBytesWritten(BB_Writer *bw)
|
|||||||
/* FIXME: Handle overflowed bw */
|
/* FIXME: Handle overflowed bw */
|
||||||
String BB_GetWritten(Arena *arena, BB_Writer *bw)
|
String BB_GetWritten(Arena *arena, BB_Writer *bw)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.len = (bw->cur_bit + 7) >> 3;
|
result.len = (bw->cur_bit + 7) >> 3;
|
||||||
result.text = PushStructsNoZero(arena, u8, result.len);
|
result.text = PushStructsNoZero(arena, u8, result.len);
|
||||||
CopyBytes(result.text, bw->base, 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 BB_ReaderFromBuff(BB_Buff *bb)
|
||||||
{
|
{
|
||||||
BB_Reader result = ZI;
|
BB_Reader result = Zi;
|
||||||
if (!bb->is_backed_by_arena)
|
if (!bb->is_backed_by_arena)
|
||||||
{
|
{
|
||||||
result.base = bb->fixed_buffer.text;
|
result.base = bb->fixed_buffer.text;
|
||||||
@ -651,7 +651,7 @@ Uid BB_ReadUid(BB_Reader *br)
|
|||||||
String BB_ReadString(Arena *arena, BB_Reader *br)
|
String BB_ReadString(Arena *arena, BB_Reader *br)
|
||||||
{
|
{
|
||||||
BB_ReadDebugMagic(br, BB_DebugMagicKind_String, 0);
|
BB_ReadDebugMagic(br, BB_DebugMagicKind_String, 0);
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
u64 len = BB_ReadUV(br);
|
u64 len = BB_ReadUV(br);
|
||||||
u8 *src = BB_ReadBytesRaw(br, len);
|
u8 *src = BB_ReadBytesRaw(br, len);
|
||||||
if (src != 0)
|
if (src != 0)
|
||||||
@ -857,7 +857,7 @@ void BB_Test(void)
|
|||||||
{ kind_string, .s = { Lit("Alriiiiiiiiiiiiiiiiiiighty then") } },
|
{ kind_string, .s = { Lit("Alriiiiiiiiiiiiiiiiiiighty then") } },
|
||||||
};
|
};
|
||||||
|
|
||||||
String encoded = ZI;
|
String encoded = Zi;
|
||||||
{
|
{
|
||||||
BB_Buff bb = BB_AcquireBuff(Gibi(64));
|
BB_Buff bb = BB_AcquireBuff(Gibi(64));
|
||||||
BB_Writer bw = BB_WriterFromBuff(&bb);
|
BB_Writer bw = BB_WriterFromBuff(&bb);
|
||||||
|
|||||||
@ -12,7 +12,7 @@ void BootstrapCmdline(void)
|
|||||||
CommandlineArg *tmp_args = PushStructs(scratch.arena, CommandlineArg, raw.count);
|
CommandlineArg *tmp_args = PushStructs(scratch.arena, CommandlineArg, raw.count);
|
||||||
String *tmp_positionals = PushStructs(scratch.arena, String, 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)
|
for (StringListNode *n = raw.first; n; n = n->next)
|
||||||
{
|
{
|
||||||
String s = n->s;
|
String s = n->s;
|
||||||
@ -74,7 +74,7 @@ void BootstrapCmdline(void)
|
|||||||
|
|
||||||
String StringFromCommandlineIdx(i32 idx)
|
String StringFromCommandlineIdx(i32 idx)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
if (idx < Base.cmdline.positional_args_count)
|
if (idx < Base.cmdline.positional_args_count)
|
||||||
{
|
{
|
||||||
result = Base.cmdline.positional_args[idx];
|
result = Base.cmdline.positional_args[idx];
|
||||||
@ -84,7 +84,7 @@ String StringFromCommandlineIdx(i32 idx)
|
|||||||
|
|
||||||
CommandlineArg CommandlineArgFromName(String name)
|
CommandlineArg CommandlineArgFromName(String name)
|
||||||
{
|
{
|
||||||
CommandlineArg result = ZI;
|
CommandlineArg result = Zi;
|
||||||
u64 hash = HashFnv64(Fnv64Basis, name);
|
u64 hash = HashFnv64(Fnv64Basis, name);
|
||||||
for (CommandlineArgNode *n = Base.cmdline.arg_bins[hash % countof(Base.cmdline.arg_bins)]; n; n = n->next)
|
for (CommandlineArgNode *n = Base.cmdline.arg_bins[hash % countof(Base.cmdline.arg_bins)]; n; n = n->next)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -836,7 +836,7 @@ f32 LinearFromSrgbF32(f32 srgb)
|
|||||||
|
|
||||||
Vec4 LinearFromSrgb(Vec4 srgb)
|
Vec4 LinearFromSrgb(Vec4 srgb)
|
||||||
{
|
{
|
||||||
Vec4 result = ZI;
|
Vec4 result = Zi;
|
||||||
result.x = LinearFromSrgbF32(srgb.x);
|
result.x = LinearFromSrgbF32(srgb.x);
|
||||||
result.y = LinearFromSrgbF32(srgb.y);
|
result.y = LinearFromSrgbF32(srgb.y);
|
||||||
result.z = LinearFromSrgbF32(srgb.z);
|
result.z = LinearFromSrgbF32(srgb.z);
|
||||||
@ -846,7 +846,7 @@ Vec4 LinearFromSrgb(Vec4 srgb)
|
|||||||
|
|
||||||
Vec4 SrgbFromLinear(Vec4 lin)
|
Vec4 SrgbFromLinear(Vec4 lin)
|
||||||
{
|
{
|
||||||
Vec4 result = ZI;
|
Vec4 result = Zi;
|
||||||
result.x = SrgbFromLinearF32(lin.x);
|
result.x = SrgbFromLinearF32(lin.x);
|
||||||
result.y = SrgbFromLinearF32(lin.y);
|
result.y = SrgbFromLinearF32(lin.y);
|
||||||
result.z = SrgbFromLinearF32(lin.z);
|
result.z = SrgbFromLinearF32(lin.z);
|
||||||
@ -865,7 +865,7 @@ Vec4 BlendSrgb(Vec4 v0, Vec4 v1, f32 t)
|
|||||||
{
|
{
|
||||||
Vec4 v0_l = LinearFromSrgb(v0);
|
Vec4 v0_l = LinearFromSrgb(v0);
|
||||||
Vec4 v1_l = LinearFromSrgb(v1);
|
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.x = LerpF32(v0_l.x, v1_l.x, t);
|
||||||
blend_l.y = LerpF32(v0_l.y, v1_l.y, 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 Vec4FromU32(u32 v)
|
||||||
{
|
{
|
||||||
Vec4 result = ZI;
|
Vec4 result = Zi;
|
||||||
result.x = ((v >> 0) & 0xFF) / 255.0;
|
result.x = ((v >> 0) & 0xFF) / 255.0;
|
||||||
result.y = ((v >> 8) & 0xFF) / 255.0;
|
result.y = ((v >> 8) & 0xFF) / 255.0;
|
||||||
result.z = ((v >> 16) & 0xFF) / 255.0;
|
result.z = ((v >> 16) & 0xFF) / 255.0;
|
||||||
@ -1175,7 +1175,7 @@ u32 U32FromVec4(Vec4 v)
|
|||||||
|
|
||||||
Vec2 DimsFromRng2(Rng2 r)
|
Vec2 DimsFromRng2(Rng2 r)
|
||||||
{
|
{
|
||||||
Vec2 result = ZI;
|
Vec2 result = Zi;
|
||||||
result.x = r.p1.x - r.p0.x;
|
result.x = r.p1.x - r.p0.x;
|
||||||
result.y = r.p1.y - r.p0.y;
|
result.y = r.p1.y - r.p0.y;
|
||||||
return result;
|
return result;
|
||||||
@ -1183,7 +1183,7 @@ Vec2 DimsFromRng2(Rng2 r)
|
|||||||
|
|
||||||
Rng2 UnionRng2(Rng2 a, Rng2 b)
|
Rng2 UnionRng2(Rng2 a, Rng2 b)
|
||||||
{
|
{
|
||||||
Rng2 result = ZI;
|
Rng2 result = Zi;
|
||||||
result.p0.x = MinF32(a.p0.x, b.p0.x);
|
result.p0.x = MinF32(a.p0.x, b.p0.x);
|
||||||
result.p0.y = MinF32(a.p0.y, b.p0.y);
|
result.p0.y = MinF32(a.p0.y, b.p0.y);
|
||||||
result.p1.x = MaxF32(a.p1.x, b.p1.x);
|
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 AddRng2Vec2(Rng2 r, Vec2 v)
|
||||||
{
|
{
|
||||||
Rng2 result = ZI;
|
Rng2 result = Zi;
|
||||||
result.p0 = AddVec2(r.p0, v);
|
result.p0 = AddVec2(r.p0, v);
|
||||||
result.p1 = AddVec2(r.p1, v);
|
result.p1 = AddVec2(r.p1, v);
|
||||||
return result;
|
return result;
|
||||||
@ -1201,7 +1201,7 @@ Rng2 AddRng2Vec2(Rng2 r, Vec2 v)
|
|||||||
|
|
||||||
Rng2 MulRng2Vec2(Rng2 r, Vec2 v)
|
Rng2 MulRng2Vec2(Rng2 r, Vec2 v)
|
||||||
{
|
{
|
||||||
Rng2 result = ZI;
|
Rng2 result = Zi;
|
||||||
result.p0 = MulVec2Vec2(r.p0, v);
|
result.p0 = MulVec2Vec2(r.p0, v);
|
||||||
result.p1 = MulVec2Vec2(r.p1, v);
|
result.p1 = MulVec2Vec2(r.p1, v);
|
||||||
return result;
|
return result;
|
||||||
@ -1209,7 +1209,7 @@ Rng2 MulRng2Vec2(Rng2 r, Vec2 v)
|
|||||||
|
|
||||||
Rng2 DivRng2Vec2(Rng2 r, Vec2 v)
|
Rng2 DivRng2Vec2(Rng2 r, Vec2 v)
|
||||||
{
|
{
|
||||||
Rng2 result = ZI;
|
Rng2 result = Zi;
|
||||||
result.p0 = DivVec2Vec2(r.p0, v);
|
result.p0 = DivVec2Vec2(r.p0, v);
|
||||||
result.p1 = DivVec2Vec2(r.p1, v);
|
result.p1 = DivVec2Vec2(r.p1, v);
|
||||||
return result;
|
return result;
|
||||||
@ -1219,7 +1219,7 @@ Rng2 DivRng2Vec2(Rng2 r, Vec2 v)
|
|||||||
|
|
||||||
Vec2I32 DimsFromRng2I32(Rng2I32 r)
|
Vec2I32 DimsFromRng2I32(Rng2I32 r)
|
||||||
{
|
{
|
||||||
Vec2I32 result = ZI;
|
Vec2I32 result = Zi;
|
||||||
result.x = r.p1.x - r.p0.x;
|
result.x = r.p1.x - r.p0.x;
|
||||||
result.y = r.p1.y - r.p0.y;
|
result.y = r.p1.y - r.p0.y;
|
||||||
return result;
|
return result;
|
||||||
@ -1227,7 +1227,7 @@ Vec2I32 DimsFromRng2I32(Rng2I32 r)
|
|||||||
|
|
||||||
Rng2I32 UnionRng2I32(Rng2I32 a, Rng2I32 b)
|
Rng2I32 UnionRng2I32(Rng2I32 a, Rng2I32 b)
|
||||||
{
|
{
|
||||||
Rng2I32 result = ZI;
|
Rng2I32 result = Zi;
|
||||||
result.p0.x = MinF32(a.p0.x, b.p0.x);
|
result.p0.x = MinF32(a.p0.x, b.p0.x);
|
||||||
result.p0.y = MinF32(a.p0.y, b.p0.y);
|
result.p0.y = MinF32(a.p0.y, b.p0.y);
|
||||||
result.p1.x = MaxF32(a.p1.x, b.p1.x);
|
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 AddRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
|
||||||
{
|
{
|
||||||
Rng2I32 result = ZI;
|
Rng2I32 result = Zi;
|
||||||
result.p0 = AddVec2I32(r.p0, v);
|
result.p0 = AddVec2I32(r.p0, v);
|
||||||
result.p1 = AddVec2I32(r.p1, v);
|
result.p1 = AddVec2I32(r.p1, v);
|
||||||
return result;
|
return result;
|
||||||
@ -1245,7 +1245,7 @@ Rng2I32 AddRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
|
|||||||
|
|
||||||
Rng2I32 MulRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
|
Rng2I32 MulRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
|
||||||
{
|
{
|
||||||
Rng2I32 result = ZI;
|
Rng2I32 result = Zi;
|
||||||
result.p0 = MulVec2I32Vec2I32(r.p0, v);
|
result.p0 = MulVec2I32Vec2I32(r.p0, v);
|
||||||
result.p1 = MulVec2I32Vec2I32(r.p1, v);
|
result.p1 = MulVec2I32Vec2I32(r.p1, v);
|
||||||
return result;
|
return result;
|
||||||
@ -1253,7 +1253,7 @@ Rng2I32 MulRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
|
|||||||
|
|
||||||
Rng2I32 DivRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
|
Rng2I32 DivRng2I32Vec2I32(Rng2I32 r, Vec2I32 v)
|
||||||
{
|
{
|
||||||
Rng2I32 result = ZI;
|
Rng2I32 result = Zi;
|
||||||
result.p0 = DivVec2I32Vec2I32(r.p0, v);
|
result.p0 = DivVec2I32Vec2I32(r.p0, v);
|
||||||
result.p1 = DivVec2I32Vec2I32(r.p1, v);
|
result.p1 = DivVec2I32Vec2I32(r.p1, v);
|
||||||
return result;
|
return result;
|
||||||
@ -1434,7 +1434,7 @@ Vec2 InvertXformMulV2(Xform xf, Vec2 v)
|
|||||||
//- Helpers
|
//- Helpers
|
||||||
Xform BasisFromXform(Xform xf)
|
Xform BasisFromXform(Xform xf)
|
||||||
{
|
{
|
||||||
Xform result = ZI;
|
Xform result = Zi;
|
||||||
result.bx = xf.bx;
|
result.bx = xf.bx;
|
||||||
result.by = xf.by;
|
result.by = xf.by;
|
||||||
return result;
|
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 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 rl = 1.0f / (right - left);
|
||||||
f32 tb = 1.0f / (top - bottom);
|
f32 tb = 1.0f / (top - bottom);
|
||||||
|
|||||||
@ -49,7 +49,7 @@ b32 IsResourceNil(ResourceKey resource)
|
|||||||
|
|
||||||
ResourceKey ResourceKeyFromStore(ResourceStore *store, String name)
|
ResourceKey ResourceKeyFromStore(ResourceStore *store, String name)
|
||||||
{
|
{
|
||||||
ResourceKey result = ZI;
|
ResourceKey result = Zi;
|
||||||
result.v = HashFnv64(store->v, name);
|
result.v = HashFnv64(store->v, name);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ ResourceEntry *ResourceEntryFromHash(u64 hash)
|
|||||||
|
|
||||||
String DataFromResource(ResourceKey resource)
|
String DataFromResource(ResourceKey resource)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
ResourceEntry *entry = ResourceEntryFromHash(resource.v);
|
ResourceEntry *entry = ResourceEntryFromHash(resource.v);
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
@ -82,7 +82,7 @@ String DataFromResource(ResourceKey resource)
|
|||||||
|
|
||||||
String NameFromResource(ResourceKey resource)
|
String NameFromResource(ResourceKey resource)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
ResourceEntry *entry = ResourceEntryFromHash(resource.v);
|
ResourceEntry *entry = ResourceEntryFromHash(resource.v);
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
BaseCtx Base = ZI;
|
BaseCtx Base = Zi;
|
||||||
ThreadLocal BaseThreadLocalCtx Base_tl = ZI;
|
ThreadLocal BaseThreadLocalCtx Base_tl = Zi;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ String StringFromUint(Arena *arena, u64 n, u64 base, u64 zfill)
|
|||||||
{
|
{
|
||||||
/* Base too large */
|
/* Base too large */
|
||||||
Assert(base <= (countof(IntChars) - 1));
|
Assert(base <= (countof(IntChars) - 1));
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
{
|
{
|
||||||
/* Build backwards text starting from least significant digit */
|
/* 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 StringFromUints(Arena *arena, u64 uints_count, u64 *uints, u64 base, u64 zfill)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
result.len += StringFromChar(arena, '(').len;
|
result.len += StringFromChar(arena, '(').len;
|
||||||
for (u64 uint_idx = 0; uint_idx < uints_count; ++uint_idx)
|
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 StringFromSint(Arena *arena, i64 n, u64 base, u64 zfill)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
if (n < 0)
|
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 StringFromSints(Arena *arena, u64 sints_count, i64 *sints, u64 base, u64 zfill)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
result.len += StringFromChar(arena, '(').len;
|
result.len += StringFromChar(arena, '(').len;
|
||||||
for (u64 sint_idx = 0; sint_idx < sints_count; ++sint_idx)
|
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 StringFromFloat(Arena *arena, f64 f, u32 precision)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
TempArena scratch = BeginScratch(arena);
|
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 StringFromFloats(Arena *arena, u64 floats_count, f64 *floats, u32 precision)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
result.len += StringFromChar(arena, '(').len;
|
result.len += StringFromChar(arena, '(').len;
|
||||||
for (u64 float_idx = 0; float_idx < floats_count; ++float_idx)
|
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 StringFromhandle(Arena *arena, u64 v0, u64 v1)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
result.len += PushString(arena, Lit("h")).len;
|
result.len += PushString(arena, Lit("h")).len;
|
||||||
result.len += StringFromUint(arena, v0, 16, 0).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 StringFromUid(Arena *arena, Uid uid)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
result.len += StringFromUint(arena, (uid.hi >> 32), 16, 8).len;
|
result.len += StringFromUint(arena, (uid.hi >> 32), 16, 8).len;
|
||||||
return result;
|
return result;
|
||||||
@ -235,7 +235,7 @@ String StringFromUid(Arena *arena, Uid uid)
|
|||||||
|
|
||||||
String PushString(Arena *arena, String src)
|
String PushString(Arena *arena, String src)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.len = src.len;
|
result.len = src.len;
|
||||||
result.text = PushStructsNoZero(arena, u8, src.len);
|
result.text = PushStructsNoZero(arena, u8, src.len);
|
||||||
CopyBytes(result.text, src.text, 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 CopyString(String dst, String src)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.len = MinU64(dst.len, src.len);
|
result.len = MinU64(dst.len, src.len);
|
||||||
result.text = dst.text;
|
result.text = dst.text;
|
||||||
CopyBytes(result.text, src.text, result.len);
|
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 CatString(Arena *arena, String str1, String str2)
|
||||||
{
|
{
|
||||||
String new_str = ZI;
|
String new_str = Zi;
|
||||||
new_str.len = str1.len + str2.len;
|
new_str.len = str1.len + str2.len;
|
||||||
new_str.text = PushStructsNoZero(arena, u8, new_str.len);
|
new_str.text = PushStructsNoZero(arena, u8, new_str.len);
|
||||||
CopyBytes(new_str.text, str1.text, str1.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. */
|
* into the existing string and do not allocate any new text. */
|
||||||
StringArray SplitString(Arena *arena, String str, String delim)
|
StringArray SplitString(Arena *arena, String str, String delim)
|
||||||
{
|
{
|
||||||
StringArray pieces = ZI;
|
StringArray pieces = Zi;
|
||||||
pieces.strings = ArenaNext(arena, String);
|
pieces.strings = ArenaNext(arena, String);
|
||||||
i64 piece_start = 0;
|
i64 piece_start = 0;
|
||||||
for (i64 i = 0; i < (i64)str.len - (i64)delim.len;)
|
for (i64 i = 0; i < (i64)str.len - (i64)delim.len;)
|
||||||
{
|
{
|
||||||
String cmp = ZI;
|
String cmp = Zi;
|
||||||
cmp.text = &str.text[i];
|
cmp.text = &str.text[i];
|
||||||
cmp.len = MinI64(str.len - i, delim.len);
|
cmp.len = MinI64(str.len - i, delim.len);
|
||||||
|
|
||||||
if (MatchString(cmp, delim))
|
if (MatchString(cmp, delim))
|
||||||
{
|
{
|
||||||
String piece = ZI;
|
String piece = Zi;
|
||||||
piece.text = &str.text[piece_start];
|
piece.text = &str.text[piece_start];
|
||||||
piece.len = i - piece_start;
|
piece.len = i - piece_start;
|
||||||
*PushStructNoZero(arena, String) = piece;
|
*PushStructNoZero(arena, String) = piece;
|
||||||
@ -312,7 +312,7 @@ StringArray SplitString(Arena *arena, String str, String delim)
|
|||||||
}
|
}
|
||||||
if (piece_start < (i64)str.len)
|
if (piece_start < (i64)str.len)
|
||||||
{
|
{
|
||||||
String piece = ZI;
|
String piece = Zi;
|
||||||
piece.text = &str.text[piece_start];
|
piece.text = &str.text[piece_start];
|
||||||
piece.len = str.len - piece_start;
|
piece.len = str.len - piece_start;
|
||||||
*PushStructNoZero(arena, String) = piece;
|
*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 ReplaceString(Arena *arena, String str, String old_pattern, String new_pattern)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
i64 piece_start = 0;
|
i64 piece_start = 0;
|
||||||
for (i64 i = 0; i < (i64)str.len - (i64)old_pattern.len;)
|
for (i64 i = 0; i < (i64)str.len - (i64)old_pattern.len;)
|
||||||
{
|
{
|
||||||
String cmp = ZI;
|
String cmp = Zi;
|
||||||
cmp.text = &str.text[i];
|
cmp.text = &str.text[i];
|
||||||
cmp.len = MinI64(str.len - i, old_pattern.len);
|
cmp.len = MinI64(str.len - i, old_pattern.len);
|
||||||
if (MatchString(cmp, old_pattern))
|
if (MatchString(cmp, old_pattern))
|
||||||
{
|
{
|
||||||
String piece = ZI;
|
String piece = Zi;
|
||||||
piece.text = &str.text[piece_start];
|
piece.text = &str.text[piece_start];
|
||||||
piece.len = i - piece_start;
|
piece.len = i - piece_start;
|
||||||
if (piece.len > 0)
|
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)
|
if (piece_start < (i64)str.len)
|
||||||
{
|
{
|
||||||
String piece = ZI;
|
String piece = Zi;
|
||||||
piece.text = &str.text[piece_start];
|
piece.text = &str.text[piece_start];
|
||||||
piece.len = str.len - piece_start;
|
piece.len = str.len - piece_start;
|
||||||
result.len += PushString(arena, piece).len;
|
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 LowerString(Arena *arena, String str)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = PushStructsNoZero(arena, u8, str.len);
|
result.text = PushStructsNoZero(arena, u8, str.len);
|
||||||
result.len = str.len;
|
result.len = str.len;
|
||||||
|
|
||||||
@ -504,7 +504,7 @@ b32 StringEndsWith(String str, String substring)
|
|||||||
|
|
||||||
String StringFromArray(Arena *arena, StringArray a)
|
String StringFromArray(Arena *arena, StringArray a)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
for (u64 string_idx = 0; string_idx < a.count; ++string_idx)
|
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 StringFromList(Arena *arena, StringList l, String separator)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
for (StringListNode *n = l.first; n; n = n->next)
|
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 FormatString(Arena *arena, String fmt, FmtArgArray args)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = ArenaNext(arena, u8);
|
result.text = ArenaNext(arena, u8);
|
||||||
|
|
||||||
u8 *end = fmt.text + fmt.len;
|
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')
|
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)
|
if (arg_idx < args.count)
|
||||||
{
|
{
|
||||||
arg = args.args[arg_idx];
|
arg = args.args[arg_idx];
|
||||||
@ -786,7 +786,7 @@ String FormatString(Arena *arena, String fmt, FmtArgArray args)
|
|||||||
#if IsRtcEnabled
|
#if IsRtcEnabled
|
||||||
if (!no_more_valid_args)
|
if (!no_more_valid_args)
|
||||||
{
|
{
|
||||||
FmtArg last_arg = ZI;
|
FmtArg last_arg = Zi;
|
||||||
if (arg_idx < args.count)
|
if (arg_idx < args.count)
|
||||||
{
|
{
|
||||||
last_arg = args.args[arg_idx];
|
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 StringF_(Arena *arena, String fmt, ...)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -815,7 +815,7 @@ String StringF_(Arena *arena, String fmt, ...)
|
|||||||
|
|
||||||
FmtArgArray FmtArgsFromVaList(Arena *arena, va_list args)
|
FmtArgArray FmtArgsFromVaList(Arena *arena, va_list args)
|
||||||
{
|
{
|
||||||
FmtArgArray result = ZI;
|
FmtArgArray result = Zi;
|
||||||
result.args = ArenaNext(arena, FmtArg);
|
result.args = ArenaNext(arena, FmtArg);
|
||||||
{
|
{
|
||||||
b32 done = 0;
|
b32 done = 0;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ Lock LockSpinE(Mutex *m, i32 spin)
|
|||||||
Atomic32Set(&m->exclusive_thread_id, ThreadId());
|
Atomic32Set(&m->exclusive_thread_id, ThreadId());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Lock lock = ZI;
|
Lock lock = Zi;
|
||||||
lock.exclusive = 1;
|
lock.exclusive = 1;
|
||||||
lock.mutex = m;
|
lock.mutex = m;
|
||||||
return lock;
|
return lock;
|
||||||
@ -101,7 +101,7 @@ Lock LockSpinS(Mutex *m, i32 spin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Lock lock = ZI;
|
Lock lock = Zi;
|
||||||
lock.mutex = m;
|
lock.mutex = m;
|
||||||
return lock;
|
return lock;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/* Returns a uid generated from the system's random number generator */
|
/* Returns a uid generated from the system's random number generator */
|
||||||
Uid UidFromTrueRand(void)
|
Uid UidFromTrueRand(void)
|
||||||
{
|
{
|
||||||
Uid result = ZI;
|
Uid result = Zi;
|
||||||
TrueRand(StringFromStruct(&result));
|
TrueRand(StringFromStruct(&result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
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 codepoint = U32Max;
|
||||||
u32 advance = 0;
|
u32 advance = 0;
|
||||||
if (str.len > 0)
|
if (str.len > 0)
|
||||||
@ -89,7 +89,7 @@ Utf8DecodeResult DecodeUtf8(String str)
|
|||||||
|
|
||||||
Utf8EncodeResult EncodeUtf8(u32 codepoint)
|
Utf8EncodeResult EncodeUtf8(u32 codepoint)
|
||||||
{
|
{
|
||||||
Utf8EncodeResult result = ZI;
|
Utf8EncodeResult result = Zi;
|
||||||
|
|
||||||
if (codepoint <= 0x7F)
|
if (codepoint <= 0x7F)
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ Utf8EncodeResult EncodeUtf8(u32 codepoint)
|
|||||||
|
|
||||||
Utf16DecodeResult DecodeUtf16(String16 str)
|
Utf16DecodeResult DecodeUtf16(String16 str)
|
||||||
{
|
{
|
||||||
Utf16DecodeResult result = ZI;
|
Utf16DecodeResult result = Zi;
|
||||||
u32 codepoint = U32Max;
|
u32 codepoint = U32Max;
|
||||||
u32 advance = 0;
|
u32 advance = 0;
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ Utf16DecodeResult DecodeUtf16(String16 str)
|
|||||||
|
|
||||||
Utf16EncodeResult EncodeUtf16(u32 codepoint)
|
Utf16EncodeResult EncodeUtf16(u32 codepoint)
|
||||||
{
|
{
|
||||||
Utf16EncodeResult result = ZI;
|
Utf16EncodeResult result = Zi;
|
||||||
|
|
||||||
if (codepoint <= 0xFFFF)
|
if (codepoint <= 0xFFFF)
|
||||||
{
|
{
|
||||||
@ -206,7 +206,7 @@ b32 IsUtf16LowSurrogate(u16 c)
|
|||||||
|
|
||||||
Utf32DecodeResult DecodeUtf32(String32 str)
|
Utf32DecodeResult DecodeUtf32(String32 str)
|
||||||
{
|
{
|
||||||
Utf32DecodeResult result = ZI;
|
Utf32DecodeResult result = Zi;
|
||||||
u32 codepoint = U32Max;
|
u32 codepoint = U32Max;
|
||||||
u32 advance = 0;
|
u32 advance = 0;
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ Utf32DecodeResult DecodeUtf32(String32 str)
|
|||||||
|
|
||||||
Utf32EncodeResult EncodeUtf32(u32 codepoint)
|
Utf32EncodeResult EncodeUtf32(u32 codepoint)
|
||||||
{
|
{
|
||||||
Utf32EncodeResult result = ZI;
|
Utf32EncodeResult result = Zi;
|
||||||
|
|
||||||
if (codepoint <= 0x10FFFF)
|
if (codepoint <= 0x10FFFF)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
W32_Ctx W32 = ZI;
|
W32_Ctx W32 = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Win32 embedded data
|
//~ 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))
|
if (ctx->embedded_strings_count < countof(ctx->embedded_strings))
|
||||||
{
|
{
|
||||||
String embedded = ZI;
|
String embedded = Zi;
|
||||||
embedded.len = SizeofResource(module, hres);
|
embedded.len = SizeofResource(module, hres);
|
||||||
embedded.text = LockResource(hg);
|
embedded.text = LockResource(hg);
|
||||||
ctx->embedded_strings[ctx->embedded_strings_count++] = embedded;
|
ctx->embedded_strings[ctx->embedded_strings_count++] = embedded;
|
||||||
@ -106,7 +106,7 @@ void TrueRand(String buffer)
|
|||||||
CpuTopologyInfo GetCpuTopologyInfo(void)
|
CpuTopologyInfo GetCpuTopologyInfo(void)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
CpuTopologyInfo res = ZI;
|
CpuTopologyInfo res = Zi;
|
||||||
{
|
{
|
||||||
DWORD infos_buff_size = 0;
|
DWORD infos_buff_size = 0;
|
||||||
u8 *infos_buff = 0;
|
u8 *infos_buff = 0;
|
||||||
@ -193,7 +193,7 @@ b32 IsSwappingOut(void)
|
|||||||
String SwappedStateFromName(Arena *arena, String name)
|
String SwappedStateFromName(Arena *arena, String name)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
String path = StringF(scratch.arena, "ppswap/%F.swp", FmtString(name));
|
String path = StringF(scratch.arena, "ppswap/%F.swp", FmtString(name));
|
||||||
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
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);
|
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();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
/* TODO: Use directory non-relative to executable */
|
/* TODO: Use directory non-relative to executable */
|
||||||
CreateDirectoryW(L"ppswap", 0);
|
CreateDirectoryW(L"ppswap", 0);
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
String path = StringF(scratch.arena, "ppswap/%F.swp", FmtString(name));
|
String path = StringF(scratch.arena, "ppswap/%F.swp", FmtString(name));
|
||||||
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
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);
|
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 GetLogEvents(void)
|
||||||
{
|
{
|
||||||
LogEventsArray result = ZI;
|
LogEventsArray result = Zi;
|
||||||
result.count = Atomic64Fetch(&W32.readable_logs_count);
|
result.count = Atomic64Fetch(&W32.readable_logs_count);
|
||||||
if (result.count > 0)
|
if (result.count > 0)
|
||||||
{
|
{
|
||||||
@ -431,7 +431,7 @@ i32 W32_Main(void)
|
|||||||
/* Get raw args from command line */
|
/* Get raw args from command line */
|
||||||
{
|
{
|
||||||
Arena *perm = PermArena();
|
Arena *perm = PermArena();
|
||||||
StringList args_list = ZI;
|
StringList args_list = Zi;
|
||||||
{
|
{
|
||||||
LPCWSTR cmdline_wstr = GetCommandLineW();
|
LPCWSTR cmdline_wstr = GetCommandLineW();
|
||||||
i32 argc = 0;
|
i32 argc = 0;
|
||||||
@ -459,7 +459,7 @@ i32 W32_Main(void)
|
|||||||
|
|
||||||
/* Bootstrap resource system */
|
/* Bootstrap resource system */
|
||||||
{
|
{
|
||||||
W32_FindEmbeddedDataCtx ctx = ZI;
|
W32_FindEmbeddedDataCtx ctx = Zi;
|
||||||
EnumResourceNamesW(0, RT_RCDATA, &W32_FindEmbeddedRcData, (LONG_PTR)&ctx);
|
EnumResourceNamesW(0, RT_RCDATA, &W32_FindEmbeddedRcData, (LONG_PTR)&ctx);
|
||||||
BootstrapResources(ctx.embedded_strings_count, ctx.embedded_strings);
|
BootstrapResources(ctx.embedded_strings_count, ctx.embedded_strings);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
DateTime LocalDateTime(void)
|
DateTime LocalDateTime(void)
|
||||||
{
|
{
|
||||||
DateTime result = ZI;
|
DateTime result = Zi;
|
||||||
{
|
{
|
||||||
SYSTEMTIME lt;
|
SYSTEMTIME lt;
|
||||||
GetLocalTime(<);
|
GetLocalTime(<);
|
||||||
|
|||||||
@ -36,7 +36,7 @@ DWORD WINAPI W32_ThreadProc(LPVOID thread_args_vp)
|
|||||||
void DispatchWave(String name, u32 num_lanes, WaveLaneEntryFunc *entry, void *udata)
|
void DispatchWave(String name, u32 num_lanes, WaveLaneEntryFunc *entry, void *udata)
|
||||||
{
|
{
|
||||||
Arena *perm = PermArena();
|
Arena *perm = PermArena();
|
||||||
PERSIST Atomic64 num_threads_allocated = ZI;
|
PERSIST Atomic64 num_threads_allocated = Zi;
|
||||||
|
|
||||||
/* Catch high lane count to prevent OS crash */
|
/* Catch high lane count to prevent OS crash */
|
||||||
i64 old_num_threads_allocated = Atomic64FetchAdd(&num_threads_allocated, num_lanes);
|
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->wave = wave_ctx;
|
||||||
lane_ctx->default_spin_count = DefaultWaveLaneSpinCount;
|
lane_ctx->default_spin_count = DefaultWaveLaneSpinCount;
|
||||||
|
|
||||||
String thread_name = ZI;
|
String thread_name = Zi;
|
||||||
if (num_lanes > 1)
|
if (num_lanes > 1)
|
||||||
{
|
{
|
||||||
thread_name = StringF(perm, "%F:%F", FmtString(name), FmtUint(lane_idx));
|
thread_name = StringF(perm, "%F:%F", FmtString(name), FmtUint(lane_idx));
|
||||||
|
|||||||
@ -43,7 +43,7 @@ CLD_SupportPoint CLD_SupportPointFromDirEx(CLD_Shape *shape, Xform xf, Vec2 dir,
|
|||||||
ignore = -1;
|
ignore = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 furthest = ZI;
|
Vec2 furthest = Zi;
|
||||||
u32 furthest_index = 0;
|
u32 furthest_index = 0;
|
||||||
f32 furthest_dot = -F32Infinity;
|
f32 furthest_dot = -F32Infinity;
|
||||||
|
|
||||||
@ -144,9 +144,9 @@ CLD_GjkData CLD_GjkDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
b32 overlapping = 0;
|
b32 overlapping = 0;
|
||||||
CLD_MenkowskiSimplex s = ZI;
|
CLD_MenkowskiSimplex s = Zi;
|
||||||
Vec2 dir = ZI;
|
Vec2 dir = Zi;
|
||||||
CLD_MenkowskiPoint m = ZI;
|
CLD_MenkowskiPoint m = Zi;
|
||||||
|
|
||||||
/* First point is support point in shape's general directions to eachother */
|
/* First point is support point in shape's general directions to eachother */
|
||||||
dir = SubVec2(xf1.og, xf0.og);
|
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.a = CLD_MenkowskiPointFromDir(shape0, shape1, xf0, xf1, dir);
|
||||||
s.len = 1;
|
s.len = 1;
|
||||||
|
|
||||||
Vec2 removed_a = ZI;
|
Vec2 removed_a = Zi;
|
||||||
Vec2 removed_b = ZI;
|
Vec2 removed_b = Zi;
|
||||||
u32 num_removed = 0;
|
u32 num_removed = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -323,8 +323,8 @@ CLD_EpaData CLD_EpaDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf
|
|||||||
{
|
{
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
|
|
||||||
CLD_MenkowskiFeature closest_feature = ZI;
|
CLD_MenkowskiFeature closest_feature = Zi;
|
||||||
Vec2 normal = ZI;
|
Vec2 normal = Zi;
|
||||||
|
|
||||||
CLD_MenkowskiPoint *proto = 0;
|
CLD_MenkowskiPoint *proto = 0;
|
||||||
u32 proto_count = 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 */
|
/* Find dir from origin to closest edge */
|
||||||
/* FIXME: Winding order of ps & pe index */
|
/* FIXME: Winding order of ps & pe index */
|
||||||
f32 closest_len_sq = F32Infinity;
|
f32 closest_len_sq = F32Infinity;
|
||||||
CLD_MenkowskiPoint closest_a = ZI;
|
CLD_MenkowskiPoint closest_a = Zi;
|
||||||
CLD_MenkowskiPoint closest_b = ZI;
|
CLD_MenkowskiPoint closest_b = Zi;
|
||||||
u32 closest_b_index = 0;
|
u32 closest_b_index = 0;
|
||||||
for (u32 i = 0; i < proto_count; ++i)
|
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 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 tolerance = CLD_CollisionTolerance;
|
||||||
const f32 min_unique_pt_dist_sq = CLD_MinUniquePtDistSq;
|
const f32 min_unique_pt_dist_sq = CLD_MinUniquePtDistSq;
|
||||||
const u32 max_epa_iterations = CLD_MaxEpaIterations;
|
const u32 max_epa_iterations = CLD_MaxEpaIterations;
|
||||||
|
|
||||||
CLD_CollisionPoint points[2] = ZI;
|
CLD_CollisionPoint points[2] = Zi;
|
||||||
u32 num_points = 0;
|
u32 num_points = 0;
|
||||||
b32 colliding = 0;
|
b32 colliding = 0;
|
||||||
Vec2 normal = ZI;
|
Vec2 normal = Zi;
|
||||||
|
|
||||||
#if COLLIDER_DEBUG
|
#if COLLIDER_DEBUG
|
||||||
u32 dbg_step = 0;
|
u32 dbg_step = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CLD_GjkData gjk_result = ZI;
|
CLD_GjkData gjk_result = Zi;
|
||||||
CLD_EpaData epa_result = ZI;
|
CLD_EpaData epa_result = Zi;
|
||||||
|
|
||||||
/* Run GJK */
|
/* Run GJK */
|
||||||
#if COLLIDER_DEBUG
|
#if COLLIDER_DEBUG
|
||||||
@ -713,8 +713,8 @@ CLD_CollisionData CLD_CollisionDataFromShapes(CLD_Shape *shape0, CLD_Shape *shap
|
|||||||
|
|
||||||
f32 a_sep = F32Infinity;
|
f32 a_sep = F32Infinity;
|
||||||
f32 b_sep = F32Infinity;
|
f32 b_sep = F32Infinity;
|
||||||
Vec2 a_midpoint = ZI;
|
Vec2 a_midpoint = Zi;
|
||||||
Vec2 b_midpoint = ZI;
|
Vec2 b_midpoint = Zi;
|
||||||
b32 ignore_a = 1;
|
b32 ignore_a = 1;
|
||||||
b32 ignore_b = 1;
|
b32 ignore_b = 1;
|
||||||
if (!collapse0 && !collapse1)
|
if (!collapse0 && !collapse1)
|
||||||
@ -821,22 +821,22 @@ abort:
|
|||||||
|
|
||||||
CLD_ClosestPointData CLD_ClosestPointDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1)
|
CLD_ClosestPointData CLD_ClosestPointDataFromShapes(CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0, Xform xf1)
|
||||||
{
|
{
|
||||||
CLD_ClosestPointData result = ZI;
|
CLD_ClosestPointData result = Zi;
|
||||||
|
|
||||||
const f32 tolerance = CLD_CollisionTolerance;
|
const f32 tolerance = CLD_CollisionTolerance;
|
||||||
const f32 min_unique_pt_dist_sq = CLD_MinUniquePtDistSq;
|
const f32 min_unique_pt_dist_sq = CLD_MinUniquePtDistSq;
|
||||||
const u32 max_epa_iterations = CLD_MaxEpaIterations;
|
const u32 max_epa_iterations = CLD_MaxEpaIterations;
|
||||||
|
|
||||||
Vec2 p0 = ZI;
|
Vec2 p0 = Zi;
|
||||||
Vec2 p1 = ZI;
|
Vec2 p1 = Zi;
|
||||||
b32 colliding = 0;
|
b32 colliding = 0;
|
||||||
|
|
||||||
#if COLLIDER_DEBUG
|
#if COLLIDER_DEBUG
|
||||||
u32 dbg_step = 0;
|
u32 dbg_step = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CLD_GjkData gjk_result = ZI;
|
CLD_GjkData gjk_result = Zi;
|
||||||
CLD_EpaData epa_result = ZI;
|
CLD_EpaData epa_result = Zi;
|
||||||
|
|
||||||
//- Run GJK
|
//- Run GJK
|
||||||
#if COLLIDER_DEBUG
|
#if COLLIDER_DEBUG
|
||||||
@ -1033,7 +1033,7 @@ Vec2Array CLD_PointCloud(Arena *arena, CLD_Shape *shape0, CLD_Shape *shape1, Xfo
|
|||||||
#if 0
|
#if 0
|
||||||
b32 CLD_GjkBoolean(CLD_Shape *shape0, CLD_Shape *shape1)
|
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? */
|
/* FIXME: Infinite loop when shapes exactly overlap same space? */
|
||||||
Vec2 dir, p;
|
Vec2 dir, p;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
GC_Ctx GC = ZI;
|
GC_Ctx GC = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Bootstrap
|
//~ Bootstrap
|
||||||
@ -13,7 +13,7 @@ void GC_Bootstrap(void)
|
|||||||
|
|
||||||
GC_FontKey GC_FontKeyFromResource(ResourceKey resource)
|
GC_FontKey GC_FontKeyFromResource(ResourceKey resource)
|
||||||
{
|
{
|
||||||
GC_FontKey result = ZI;
|
GC_FontKey result = Zi;
|
||||||
result.r = resource;
|
result.r = resource;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ u64 GC_HashFromGlyphDesc(GC_GlyphDesc desc)
|
|||||||
/* TODO: Thread-local cache */
|
/* TODO: Thread-local cache */
|
||||||
GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size)
|
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);
|
TempArena scratch = BeginScratch(arena);
|
||||||
Arena *perm = PermArena();
|
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];
|
u32 codepoint = codepoints[codepoint_idx];
|
||||||
|
|
||||||
GC_GlyphDesc desc = ZI;
|
GC_GlyphDesc desc = Zi;
|
||||||
desc.font = font;
|
desc.font = font;
|
||||||
desc.font_size = font_size;
|
desc.font_size = font_size;
|
||||||
desc.codepoint = codepoint;
|
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)
|
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 = font;
|
||||||
desc.font_size = font_size;
|
desc.font_size = font_size;
|
||||||
desc.codepoint = uncached_codepoints[uncached_codepoint_idx];
|
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 `*/
|
/* TODO: Use a more efficient atlas packing algorithm for less wasted space `*/
|
||||||
GC_Atlas *atlas = GC.first_atlas;
|
GC_Atlas *atlas = GC.first_atlas;
|
||||||
b32 can_use_atlas = 0;
|
b32 can_use_atlas = 0;
|
||||||
Vec2I32 pos_in_atlas = ZI;
|
Vec2I32 pos_in_atlas = Zi;
|
||||||
while (can_use_atlas == 0)
|
while (can_use_atlas == 0)
|
||||||
{
|
{
|
||||||
/* Create atlas */
|
/* Create atlas */
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
G_SharedUtilState G_shared_util_state = ZI;
|
G_SharedUtilState G_shared_util_state = Zi;
|
||||||
ThreadLocal G_ArenaHandle G_t_perm_arena = ZI;
|
ThreadLocal G_ArenaHandle G_t_perm_arena = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Bootstrap
|
//~ Bootstrap
|
||||||
@ -14,7 +14,7 @@ void G_BootstrapCommon(void)
|
|||||||
{
|
{
|
||||||
/* Init quad index buffer */
|
/* Init quad index buffer */
|
||||||
{
|
{
|
||||||
G_ResourceHandle quad_indices = ZI;
|
G_ResourceHandle quad_indices = Zi;
|
||||||
u16 quad_data[6] = { 0, 1, 2, 0, 2, 3 };
|
u16 quad_data[6] = { 0, 1, 2, 0, 2, 3 };
|
||||||
quad_indices = G_PushBuffer(gpu_perm, u16, countof(quad_data));
|
quad_indices = G_PushBuffer(gpu_perm, u16, countof(quad_data));
|
||||||
G_CopyCpuToBuffer(cl, quad_indices, 0, quad_data, RNGU64(0, sizeof(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 */
|
/* 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")));
|
String noise_data = DataFromResource(ResourceKeyFromStore(&G_Resources, Lit("noise_128x128x64_16.dat")));
|
||||||
Vec3I32 noise_dims = VEC3I32(128, 128, 64);
|
Vec3I32 noise_dims = VEC3I32(128, 128, 64);
|
||||||
if (noise_data.len != noise_dims.x * noise_dims.y * noise_dims.z * 2)
|
if (noise_data.len != noise_dims.x * noise_dims.y * noise_dims.z * 2)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
G_D12_SharedState G_D12_shared_state = ZI;
|
G_D12_SharedState G_D12_shared_state = Zi;
|
||||||
ThreadLocal G_D12_ThreadLocalState G_D12_tl = ZI;
|
ThreadLocal G_D12_ThreadLocalState G_D12_tl = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookimpl Bootstrap
|
//~ @hookimpl Bootstrap
|
||||||
@ -62,7 +62,7 @@ void G_Bootstrap(void)
|
|||||||
IDXGIAdapter3 *adapter = 0;
|
IDXGIAdapter3 *adapter = 0;
|
||||||
ID3D12Device10 *device = 0;
|
ID3D12Device10 *device = 0;
|
||||||
String error = Lit("Could not initialize GPU device.");
|
String error = Lit("Could not initialize GPU device.");
|
||||||
String first_gpu_name = ZI;
|
String first_gpu_name = Zi;
|
||||||
u32 adapter_index = 0;
|
u32 adapter_index = 0;
|
||||||
b32 skip = 0; /* For iGPU testing */
|
b32 skip = 0; /* For iGPU testing */
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -207,7 +207,7 @@ void G_Bootstrap(void)
|
|||||||
heap->max_count = desc.max;
|
heap->max_count = desc.max;
|
||||||
heap->descriptor_size = ID3D12Device_GetDescriptorHandleIncrementSize(g->device, desc.type);
|
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.Type = desc.type;
|
||||||
d3d_desc.Flags = desc.flags;
|
d3d_desc.Flags = desc.flags;
|
||||||
d3d_desc.NumDescriptors = desc.max;
|
d3d_desc.NumDescriptors = desc.max;
|
||||||
@ -249,7 +249,7 @@ void G_Bootstrap(void)
|
|||||||
ID3D10Blob *blob = 0;
|
ID3D10Blob *blob = 0;
|
||||||
if (SUCCEEDED(hr))
|
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)
|
for (i32 slot = 0; slot < G_NumConstants; ++slot)
|
||||||
{
|
{
|
||||||
D3D12_ROOT_PARAMETER *param = ¶ms[slot];
|
D3D12_ROOT_PARAMETER *param = ¶ms[slot];
|
||||||
@ -260,7 +260,7 @@ void G_Bootstrap(void)
|
|||||||
param->Constants.Num32BitValues = 1;
|
param->Constants.Num32BitValues = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_ROOT_SIGNATURE_DESC desc = ZI;
|
D3D12_ROOT_SIGNATURE_DESC desc = Zi;
|
||||||
desc.NumParameters = countof(params);
|
desc.NumParameters = countof(params);
|
||||||
desc.pParameters = params;
|
desc.pParameters = params;
|
||||||
desc.NumStaticSamplers = 0;
|
desc.NumStaticSamplers = 0;
|
||||||
@ -326,7 +326,7 @@ void G_Bootstrap(void)
|
|||||||
|
|
||||||
// for (G_QueueKind kind = 0; kind < G_NumQueues; ++kind)
|
// 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_Direct) name = Lit("Gpu direct queue worker");
|
||||||
// if (kind == G_QueueKind_AsyncCompute) name = Lit("Gpu compute queue worker");
|
// if (kind == G_QueueKind_AsyncCompute) name = Lit("Gpu compute queue worker");
|
||||||
// if (kind == G_QueueKind_AsyncCopy) name = Lit("Gpu copy 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;
|
HRESULT hr = 0;
|
||||||
b32 ok = 1;
|
b32 ok = 1;
|
||||||
String error_str = ZI;
|
String error_str = Zi;
|
||||||
|
|
||||||
/* Create PSO */
|
/* Create PSO */
|
||||||
ID3D12PipelineState *pso = 0;
|
ID3D12PipelineState *pso = 0;
|
||||||
if (ok && (!IsResourceNil(desc.vs.resource) || !IsResourceNil(desc.ps.resource)))
|
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)
|
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;
|
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.AlphaToCoverageEnable = 0;
|
||||||
blend_desc.IndependentBlendEnable = 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;
|
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.DepthEnable = 0;
|
||||||
ds_desc.StencilEnable = 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 vs = DataFromResource(desc.vs.resource);
|
||||||
String ps = DataFromResource(desc.ps.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.pRootSignature = g->bindless_rootsig;
|
||||||
pso_desc.VS.pShaderBytecode = vs.text;
|
pso_desc.VS.pShaderBytecode = vs.text;
|
||||||
@ -576,7 +576,7 @@ G_D12_Pipeline *G_D12_PipelineFromDesc(G_D12_PipelineDesc desc)
|
|||||||
else if (ok)
|
else if (ok)
|
||||||
{
|
{
|
||||||
String cs = DataFromResource(desc.cs.resource);
|
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.pRootSignature = g->bindless_rootsig;
|
||||||
pso_desc.CS.pShaderBytecode = cs.text;
|
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);
|
G_D12_Queue *queue = G_D12_QueueFromKind(queue_kind);
|
||||||
|
|
||||||
/* Try to pull first completed command list from queue */
|
/* 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);
|
Lock lock = LockE(&queue->commit_mutex);
|
||||||
{
|
{
|
||||||
@ -888,7 +888,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_ResourceDesc desc)
|
|||||||
{
|
{
|
||||||
/* Create d3d heap */
|
/* Create d3d heap */
|
||||||
{
|
{
|
||||||
D3D12_HEAP_DESC d3d_desc = ZI;
|
D3D12_HEAP_DESC d3d_desc = Zi;
|
||||||
d3d_desc.SizeInBytes = Mebi(512);
|
d3d_desc.SizeInBytes = Mebi(512);
|
||||||
if (heap_kind == G_D12_ResourceHeapKind_Cpu)
|
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))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
D3D12_RESOURCE_DESC1 d3d_desc = ZI;
|
D3D12_RESOURCE_DESC1 d3d_desc = Zi;
|
||||||
d3d_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
d3d_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||||
d3d_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
d3d_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||||
d3d_desc.Format = DXGI_FORMAT_UNKNOWN;
|
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_size = 0;
|
||||||
u64 alloc_align = 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);
|
ID3D12Device_GetResourceAllocationInfo(g->device, &alloc_info, 0, 1, (D3D12_RESOURCE_DESC *)&d3d_desc);
|
||||||
alloc_size = alloc_info.SizeInBytes;
|
alloc_size = alloc_info.SizeInBytes;
|
||||||
alloc_align = alloc_info.Alignment;
|
alloc_align = alloc_info.Alignment;
|
||||||
@ -968,7 +968,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_ResourceDesc desc)
|
|||||||
}
|
}
|
||||||
if (SUCCEEDED(hr))
|
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);
|
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
|
//- Initialize d3d resource desc
|
||||||
|
|
||||||
D3D12_BARRIER_LAYOUT initial_layout = D3D12_BARRIER_LAYOUT_UNDEFINED;
|
D3D12_BARRIER_LAYOUT initial_layout = D3D12_BARRIER_LAYOUT_UNDEFINED;
|
||||||
D3D12_CLEAR_VALUE clear_value = ZI;
|
D3D12_CLEAR_VALUE clear_value = Zi;
|
||||||
D3D12_RESOURCE_DESC1 d3d_desc = ZI;
|
D3D12_RESOURCE_DESC1 d3d_desc = Zi;
|
||||||
{
|
{
|
||||||
if (is_buffer)
|
if (is_buffer)
|
||||||
{
|
{
|
||||||
@ -1031,7 +1031,7 @@ G_ResourceHandle G_PushResource(G_ArenaHandle arena_handle, G_ResourceDesc desc)
|
|||||||
u64 align_in_heap = 0;
|
u64 align_in_heap = 0;
|
||||||
u64 size_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);
|
ID3D12Device_GetResourceAllocationInfo(g->device, &alloc_info, 0, 1, (D3D12_RESOURCE_DESC *)&d3d_desc);
|
||||||
align_in_heap = alloc_info.Alignment;
|
align_in_heap = alloc_info.Alignment;
|
||||||
size_in_heap = alloc_info.SizeInBytes;
|
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)
|
if (is_uav)
|
||||||
{
|
{
|
||||||
D3D12_UNORDERED_ACCESS_VIEW_DESC desc = ZI;
|
D3D12_UNORDERED_ACCESS_VIEW_DESC desc = Zi;
|
||||||
{
|
{
|
||||||
desc.Format = DXGI_FORMAT_UNKNOWN;
|
desc.Format = DXGI_FORMAT_UNKNOWN;
|
||||||
desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
|
desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
|
||||||
@ -1303,7 +1303,7 @@ u32 G_PushRef(G_ArenaHandle arena_handle, G_ResourceHandle resource_handle, G_Re
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
D3D12_SHADER_RESOURCE_VIEW_DESC desc = ZI;
|
D3D12_SHADER_RESOURCE_VIEW_DESC desc = Zi;
|
||||||
{
|
{
|
||||||
desc.Format = DXGI_FORMAT_UNKNOWN;
|
desc.Format = DXGI_FORMAT_UNKNOWN;
|
||||||
desc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
|
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);
|
descriptor = G_D12_PushDescriptor(gpu_arena, G_D12_DescriptorHeapKind_Sampler);
|
||||||
G_SamplerDesc sampler_desc = resource->sampler_desc;
|
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.Filter = (D3D12_FILTER)sampler_desc.filter;
|
||||||
d3d_desc.AddressU = (D3D12_TEXTURE_ADDRESS_MODE)sampler_desc.x;
|
d3d_desc.AddressU = (D3D12_TEXTURE_ADDRESS_MODE)sampler_desc.x;
|
||||||
@ -1741,11 +1741,11 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Rasterizer state */
|
/* Rasterizer state */
|
||||||
D3D12_VIEWPORT bound_viewport = ZI;
|
D3D12_VIEWPORT bound_viewport = Zi;
|
||||||
D3D12_RECT bound_scissor = ZI;
|
D3D12_RECT bound_scissor = Zi;
|
||||||
D3D_PRIMITIVE_TOPOLOGY bound_primitive_topology = -1;
|
D3D_PRIMITIVE_TOPOLOGY bound_primitive_topology = -1;
|
||||||
D3D12_INDEX_BUFFER_VIEW bound_ibv = ZI;
|
D3D12_INDEX_BUFFER_VIEW bound_ibv = Zi;
|
||||||
u64 bound_render_target_uids[G_MaxRenderTargets] = ZI;
|
u64 bound_render_target_uids[G_MaxRenderTargets] = Zi;
|
||||||
u64 bound_render_clear_target_uid = 0;
|
u64 bound_render_clear_target_uid = 0;
|
||||||
|
|
||||||
/* Flatten command chunks */
|
/* Flatten command chunks */
|
||||||
@ -1935,7 +1935,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
|
|||||||
/* Dispatch barriers */
|
/* Dispatch barriers */
|
||||||
{
|
{
|
||||||
u32 barrier_groups_count = 0;
|
u32 barrier_groups_count = 0;
|
||||||
D3D12_BARRIER_GROUP barrier_groups[3] = ZI;
|
D3D12_BARRIER_GROUP barrier_groups[3] = Zi;
|
||||||
if (buffer_barriers_count > 0)
|
if (buffer_barriers_count > 0)
|
||||||
{
|
{
|
||||||
D3D12_BARRIER_GROUP *group = &barrier_groups[barrier_groups_count++];
|
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;
|
Vec3I32 dst_offset = cmd->copy_texels.dst_texture_offset;
|
||||||
Rng3I32 src_range = cmd->copy_texels.src_texture_range;
|
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;
|
D3D12_BOX *src_box_ptr = 0;
|
||||||
{
|
{
|
||||||
src_box.left = src_range.p0.x;
|
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_Pipeline *pipeline = 0;
|
||||||
{
|
{
|
||||||
G_D12_PipelineDesc pipeline_desc = ZI;
|
G_D12_PipelineDesc pipeline_desc = Zi;
|
||||||
pipeline_desc.cs = cmd->compute.cs;
|
pipeline_desc.cs = cmd->compute.cs;
|
||||||
pipeline = G_D12_PipelineFromDesc(pipeline_desc);
|
pipeline = G_D12_PipelineFromDesc(pipeline_desc);
|
||||||
}
|
}
|
||||||
@ -2088,7 +2088,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
|
|||||||
{
|
{
|
||||||
G_D12_Pipeline *pipeline = 0;
|
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.vs = cmd->rasterize.vs;
|
||||||
pipeline_desc.ps = cmd->rasterize.ps;
|
pipeline_desc.ps = cmd->rasterize.ps;
|
||||||
{
|
{
|
||||||
@ -2126,7 +2126,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
|
|||||||
|
|
||||||
/* Create ibv */
|
/* Create ibv */
|
||||||
u32 indices_count = 0;
|
u32 indices_count = 0;
|
||||||
D3D12_INDEX_BUFFER_VIEW ibv = ZI;
|
D3D12_INDEX_BUFFER_VIEW ibv = Zi;
|
||||||
{
|
{
|
||||||
G_IndexBufferDesc desc = cmd->rasterize.index_buffer_desc;
|
G_IndexBufferDesc desc = cmd->rasterize.index_buffer_desc;
|
||||||
if (desc.index_count > 0)
|
if (desc.index_count > 0)
|
||||||
@ -2191,7 +2191,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
|
|||||||
|
|
||||||
/* Set viewport */
|
/* Set viewport */
|
||||||
{
|
{
|
||||||
D3D12_VIEWPORT viewport = ZI;
|
D3D12_VIEWPORT viewport = Zi;
|
||||||
{
|
{
|
||||||
Rng3 range = cmd->rasterize.viewport;
|
Rng3 range = cmd->rasterize.viewport;
|
||||||
viewport.TopLeftX = range.p0.x;
|
viewport.TopLeftX = range.p0.x;
|
||||||
@ -2210,7 +2210,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
|
|||||||
|
|
||||||
/* Set scissor */
|
/* Set scissor */
|
||||||
{
|
{
|
||||||
D3D12_RECT scissor = ZI;
|
D3D12_RECT scissor = Zi;
|
||||||
{
|
{
|
||||||
Rng2 range = cmd->rasterize.scissor;
|
Rng2 range = cmd->rasterize.scissor;
|
||||||
scissor.left = range.p0.x;
|
scissor.left = range.p0.x;
|
||||||
@ -2277,7 +2277,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
|
|||||||
}
|
}
|
||||||
if (om_dirty)
|
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)
|
for (u32 i = 0; i < rtvs_count; ++i)
|
||||||
{
|
{
|
||||||
rtv_handles[i] = rcl->rtv_descriptors[i]->handle;
|
rtv_handles[i] = rcl->rtv_descriptors[i]->handle;
|
||||||
@ -2298,7 +2298,7 @@ i64 G_CommitCommandList(G_CommandListHandle cl_handle)
|
|||||||
case G_D12_CmdKind_ClearRtv:
|
case G_D12_CmdKind_ClearRtv:
|
||||||
{
|
{
|
||||||
G_D12_Resource *rt = cmd->clear_rtv.render_target;
|
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[0] = cmd->clear_rtv.color.x;
|
||||||
clear_color[1] = cmd->clear_rtv.color.y;
|
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)
|
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.x = src_copy_range.p1.x - src_copy_range.p0.x;
|
||||||
staged_dims.y = src_copy_range.p1.y - src_copy_range.p0.y;
|
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_rows_count = 0;
|
||||||
u64 footprint_row_size = 0;
|
u64 footprint_row_size = 0;
|
||||||
u64 footprint_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);
|
ID3D12Resource_GetDesc(dst->d3d_resource, &src_desc);
|
||||||
src_desc.Width = staged_dims.x;
|
src_desc.Width = staged_dims.x;
|
||||||
@ -2435,7 +2435,7 @@ void G_CopyCpuToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_hand
|
|||||||
|
|
||||||
/* Fill staging buffer */
|
/* Fill staging buffer */
|
||||||
{
|
{
|
||||||
D3D12_RANGE read_range = ZI;
|
D3D12_RANGE read_range = Zi;
|
||||||
u8 *src_base = src;
|
u8 *src_base = src;
|
||||||
u8 *dst_base = (u8 *)staging_region->ring->base + footprint.Offset;
|
u8 *dst_base = (u8 *)staging_region->ring->base + footprint.Offset;
|
||||||
u32 z_size = footprint_row_size * footprint_rows_count;
|
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.p0 = dst_offset;
|
||||||
dst_copy_range.p1.x = dst_copy_range.p0.x + staged_dims.x;
|
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;
|
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)
|
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.x = dst_copy_range.p1.x - dst_copy_range.p0.x;
|
||||||
src_dims.y = dst_copy_range.p1.y - dst_copy_range.p0.y;
|
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);
|
Assert(dst->is_texture);
|
||||||
|
|
||||||
/* Grab footprint info */
|
/* 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);
|
ID3D12Resource_GetDesc(dst->d3d_resource, &src_desc);
|
||||||
src_desc.Width = src_dims.x;
|
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;
|
src_footprint.Offset = src_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_TEXTURE_COPY_LOCATION src_loc = ZI;
|
D3D12_TEXTURE_COPY_LOCATION src_loc = Zi;
|
||||||
D3D12_TEXTURE_COPY_LOCATION dst_loc = ZI;
|
D3D12_TEXTURE_COPY_LOCATION dst_loc = Zi;
|
||||||
{
|
{
|
||||||
src_loc.pResource = src->d3d_resource;
|
src_loc.pResource = src->d3d_resource;
|
||||||
src_loc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
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(src->is_texture);
|
||||||
Assert(dst->is_texture);
|
Assert(dst->is_texture);
|
||||||
|
|
||||||
D3D12_TEXTURE_COPY_LOCATION src_loc = ZI;
|
D3D12_TEXTURE_COPY_LOCATION src_loc = Zi;
|
||||||
D3D12_TEXTURE_COPY_LOCATION dst_loc = ZI;
|
D3D12_TEXTURE_COPY_LOCATION dst_loc = Zi;
|
||||||
{
|
{
|
||||||
src_loc.pResource = dst->d3d_resource;
|
src_loc.pResource = dst->d3d_resource;
|
||||||
src_loc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
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 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)
|
for (G_QueueKind queue_kind = 0; queue_kind < G_NumQueues; ++queue_kind)
|
||||||
{
|
{
|
||||||
if (queue_mask & (1 << 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 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)
|
for (G_QueueKind queue_kind = 0; queue_kind < G_NumQueues; ++queue_kind)
|
||||||
{
|
{
|
||||||
if (queue_mask & (1 << 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;
|
G_D12_SharedState *g = &G_D12_shared_state;
|
||||||
|
|
||||||
u64 fences_count = 0;
|
u64 fences_count = 0;
|
||||||
ID3D12Fence *fences[G_NumQueues] = ZI;
|
ID3D12Fence *fences[G_NumQueues] = Zi;
|
||||||
i64 fence_targets[G_NumQueues] = ZI;
|
i64 fence_targets[G_NumQueues] = Zi;
|
||||||
|
|
||||||
/* Grab fences */
|
/* Grab fences */
|
||||||
for (G_QueueKind completion_queue_kind = 0; completion_queue_kind < G_NumQueues; ++ completion_queue_kind)
|
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_Stats G_QueryStats(void)
|
||||||
{
|
{
|
||||||
G_D12_SharedState *g = &G_D12_shared_state;
|
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);
|
IDXGIAdapter3_QueryVideoMemoryInfo(g->adapter, 0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info);
|
||||||
result.local_committed = info.CurrentUsage;
|
result.local_committed = info.CurrentUsage;
|
||||||
result.local_budget = info.Budget;
|
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);
|
IDXGIAdapter3_QueryVideoMemoryInfo(g->adapter, 0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &info);
|
||||||
result.non_local_budget = info.Budget;
|
result.non_local_budget = info.Budget;
|
||||||
result.non_local_committed = info.CurrentUsage;
|
result.non_local_committed = info.CurrentUsage;
|
||||||
@ -2817,7 +2817,7 @@ G_ResourceHandle G_PrepareBackbuffer(G_SwapchainHandle swapchain_handle, G_Forma
|
|||||||
IDXGISwapChain1 *swapchain1 = 0;
|
IDXGISwapChain1 *swapchain1 = 0;
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
DXGI_SWAP_CHAIN_DESC1 desc = ZI;
|
DXGI_SWAP_CHAIN_DESC1 desc = Zi;
|
||||||
desc.Format = G_D12_DxgiFormatFromGpuFormat(format);
|
desc.Format = G_D12_DxgiFormatFromGpuFormat(format);
|
||||||
desc.Width = size.x;
|
desc.Width = size.x;
|
||||||
desc.Height = size.y;
|
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_CopyRead,
|
||||||
G_Stage_Copy, G_Access_CopyWrite
|
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_CopyCpuToBuffer(cl, queue->print_buffer, 0, zero, RNGU64(0, sizeof(zero)));
|
||||||
}
|
}
|
||||||
G_CommitCommandList(cl);
|
G_CommitCommandList(cl);
|
||||||
@ -3076,14 +3076,14 @@ void G_D12_CollectionWorkerEntryPoint(WaveLaneCtx *lane)
|
|||||||
at += 4;
|
at += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
String fmt = ZI;
|
String fmt = Zi;
|
||||||
{
|
{
|
||||||
fmt.len = chars_count;
|
fmt.len = chars_count;
|
||||||
fmt.text = at;
|
fmt.text = at;
|
||||||
at += chars_count;
|
at += chars_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
FmtArgArray args = ZI;
|
FmtArgArray args = Zi;
|
||||||
args.count = args_count;
|
args.count = args_count;
|
||||||
{
|
{
|
||||||
if (args_count > 0)
|
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)
|
if (internal_overflow)
|
||||||
{
|
{
|
||||||
final_str = Lit("[Shader PrintF is too large]");
|
final_str = Lit("[Shader PrintF is too large]");
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
BuildCtx Build = ZI;
|
BuildCtx Build = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Helpers
|
//~ Helpers
|
||||||
@ -37,7 +37,7 @@ void EchoLineOrNothing(String msg)
|
|||||||
LineCol LineColFromPos(String data, i64 pos)
|
LineCol LineColFromPos(String data, i64 pos)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
LineCol result = ZI;
|
LineCol result = Zi;
|
||||||
for (u64 cur = 0; cur < data.len && cur <= (u64)pos; ++cur)
|
for (u64 cur = 0; cur < data.len && cur <= (u64)pos; ++cur)
|
||||||
{
|
{
|
||||||
u8 c = data.text[cur];
|
u8 c = data.text[cur];
|
||||||
@ -60,7 +60,7 @@ String StringFromMetaErrors(Arena *arena, M_ErrorList errors)
|
|||||||
{
|
{
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
|
|
||||||
StringList error_strings = ZI;
|
StringList error_strings = Zi;
|
||||||
for (M_Error *e = errors.first; e; e = e->next)
|
for (M_Error *e = errors.first; e; e = e->next)
|
||||||
{
|
{
|
||||||
M_Token *token = e->token;
|
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;
|
token_pos = token->s.text - token_file_data.text;
|
||||||
}
|
}
|
||||||
LineCol line_col = ZI;
|
LineCol line_col = Zi;
|
||||||
if (token_pos >= 0)
|
if (token_pos >= 0)
|
||||||
{
|
{
|
||||||
line_col = LineColFromPos(token_file_data, token_pos);
|
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)
|
EmbedObj Embed(String store_name, String dir_path)
|
||||||
{
|
{
|
||||||
Arena *perm = PermArena();
|
Arena *perm = PermArena();
|
||||||
EmbedObj result = ZI;
|
EmbedObj result = Zi;
|
||||||
|
|
||||||
/* Generate resource archive contents */
|
/* 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);
|
F_FilesFromDir(perm, &files, dir_path, F_IterFlag_Recurse);
|
||||||
|
|
||||||
Struct(EntryNode)
|
Struct(EntryNode)
|
||||||
@ -210,8 +210,8 @@ EmbedObj Embed(String store_name, String dir_path)
|
|||||||
/* Generate RC file */
|
/* Generate RC file */
|
||||||
String rc_out_file = StringF(perm, "%F.rc", FmtString(store_name));
|
String rc_out_file = StringF(perm, "%F.rc", FmtString(store_name));
|
||||||
{
|
{
|
||||||
RandState rs = ZI;
|
RandState rs = Zi;
|
||||||
StringList rc_out_lines = ZI;
|
StringList rc_out_lines = Zi;
|
||||||
String arc_file_cp = F_GetFullCrossPlatform(perm, arc_path);
|
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));
|
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);
|
PushStringToList(perm, &rc_out_lines, line);
|
||||||
@ -270,7 +270,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
|
|||||||
/* Compute new metahash */
|
/* Compute new metahash */
|
||||||
u64 new_metahash = 0;
|
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/base"), F_IterFlag_Recurse);
|
||||||
F_FilesFromDir(perm, &check_files, Lit("../src/meta"), F_IterFlag_Recurse);
|
F_FilesFromDir(perm, &check_files, Lit("../src/meta"), F_IterFlag_Recurse);
|
||||||
PushStringToList(perm, &check_files, Lit("../src/config.h"));
|
PushStringToList(perm, &check_files, Lit("../src/config.h"));
|
||||||
@ -300,10 +300,10 @@ void BuildEntryPoint(WaveLaneCtx *lane)
|
|||||||
{
|
{
|
||||||
String leaf_layer_name;
|
String leaf_layer_name;
|
||||||
};
|
};
|
||||||
CmdLineArgs cmdline = ZI;
|
CmdLineArgs cmdline = Zi;
|
||||||
{
|
{
|
||||||
CommandlineArg layer_arg = CommandlineArgFromName(Lit("layer"));
|
CommandlineArg layer_arg = CommandlineArgFromName(Lit("layer"));
|
||||||
String layer_name = ZI;
|
String layer_name = Zi;
|
||||||
if (layer_arg.name.len != 0)
|
if (layer_arg.name.len != 0)
|
||||||
{
|
{
|
||||||
layer_name = layer_arg.value;
|
layer_name = layer_arg.value;
|
||||||
@ -331,7 +331,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Generate compiler params
|
//- Generate compiler params
|
||||||
|
|
||||||
CompilerParams cp = ZI;
|
CompilerParams cp = Zi;
|
||||||
{
|
{
|
||||||
//- Common
|
//- Common
|
||||||
{
|
{
|
||||||
@ -452,7 +452,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
|
|||||||
//- Parse layers
|
//- Parse layers
|
||||||
{
|
{
|
||||||
/* Lex */
|
/* Lex */
|
||||||
StringList src_dirs = ZI;
|
StringList src_dirs = Zi;
|
||||||
PushStringToList(perm, &src_dirs, Lit("../src"));
|
PushStringToList(perm, &src_dirs, Lit("../src"));
|
||||||
M_TokenFileList lexed = M_TokensFromSrcDirs(perm, src_dirs);
|
M_TokenFileList lexed = M_TokensFromSrcDirs(perm, src_dirs);
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
|
|||||||
M_LayerList parsed = M_LayersFromTokenFiles(perm, lexed);;
|
M_LayerList parsed = M_LayersFromTokenFiles(perm, lexed);;
|
||||||
|
|
||||||
/* Flatten */
|
/* Flatten */
|
||||||
StringList starting_layer_names = ZI;
|
StringList starting_layer_names = Zi;
|
||||||
PushStringToList(perm, &starting_layer_names, cmdline.leaf_layer_name);
|
PushStringToList(perm, &starting_layer_names, cmdline.leaf_layer_name);
|
||||||
Build.layers_parse = M_FlattenEntries(perm, parsed, starting_layer_names);
|
Build.layers_parse = M_FlattenEntries(perm, parsed, starting_layer_names);
|
||||||
|
|
||||||
@ -469,10 +469,10 @@ void BuildEntryPoint(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
//- Generate C file
|
//- Generate C file
|
||||||
{
|
{
|
||||||
StringList c_store_lines = ZI;
|
StringList c_store_lines = Zi;
|
||||||
StringList c_shader_lines = ZI;
|
StringList c_shader_lines = Zi;
|
||||||
StringList c_include_lines = ZI;
|
StringList c_include_lines = Zi;
|
||||||
StringList c_bootstrap_lines = ZI;
|
StringList c_bootstrap_lines = Zi;
|
||||||
{
|
{
|
||||||
for (M_Entry *entry = Build.layers_parse.first; entry->valid; entry = entry->next)
|
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)
|
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"));
|
PushStringToList(perm, &c_out_lines, Lit("// Auto generated file"));
|
||||||
/* Include base layer */
|
/* Include base layer */
|
||||||
{
|
{
|
||||||
@ -638,7 +638,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
|
|||||||
OS_Mkdir(shader_store_name);
|
OS_Mkdir(shader_store_name);
|
||||||
{
|
{
|
||||||
/* Remove all old shaders */
|
/* Remove all old shaders */
|
||||||
StringList files = ZI;
|
StringList files = Zi;
|
||||||
F_FilesFromDir(perm, &files, shader_store_name, F_IterFlag_None);
|
F_FilesFromDir(perm, &files, shader_store_name, F_IterFlag_None);
|
||||||
for (StringListNode *n = files.first; n; n = n->next)
|
for (StringListNode *n = files.first; n; n = n->next)
|
||||||
{
|
{
|
||||||
@ -658,7 +658,7 @@ void BuildEntryPoint(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
/* Generate GPU file & shader entries */
|
/* 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)
|
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)
|
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"));
|
PushStringToList(perm, &gpu_out_lines, Lit("// Auto generated file"));
|
||||||
/* Include base layer */
|
/* Include base layer */
|
||||||
{
|
{
|
||||||
@ -925,9 +925,9 @@ void BuildEntryPoint(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
i64 start_ns = TimeNs();
|
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);
|
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)
|
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)
|
if (lane->idx == 0)
|
||||||
{
|
{
|
||||||
String gpu_obj_output = ZI;
|
String gpu_obj_output = Zi;
|
||||||
{
|
{
|
||||||
GpuObj *disp_obj = 0;
|
GpuObj *disp_obj = 0;
|
||||||
for (u32 gpu_obj_idx = 0; gpu_obj_idx < Build.gpu_objs.count; ++gpu_obj_idx)
|
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);
|
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)
|
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];
|
EmbedObj *embed_obj = &Build.embed_objs.array[embed_obj_idx];
|
||||||
|
|||||||
@ -42,7 +42,7 @@ String F_GetFileName(String path)
|
|||||||
|
|
||||||
String F_GetParentDir(String path)
|
String F_GetParentDir(String path)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
result.text = path.text;
|
result.text = path.text;
|
||||||
u64 end = path.len;
|
u64 end = path.len;
|
||||||
for (u64 i = path.len; i-- > 0;)
|
for (u64 i = path.len; i-- > 0;)
|
||||||
@ -62,7 +62,7 @@ String F_GetParentDir(String path)
|
|||||||
|
|
||||||
String F_ExtensionFromFile(String path)
|
String F_ExtensionFromFile(String path)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
u64 start = path.len;
|
u64 start = path.len;
|
||||||
for (u64 i = path.len; i-- > 0;)
|
for (u64 i = path.len; i-- > 0;)
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ String F_ExtensionFromFile(String path)
|
|||||||
|
|
||||||
String F_DataFromFile(Arena *arena, 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);
|
OS_File file = OS_OpenFile(path, OS_FileFlag_Read, I64Max);
|
||||||
result = OS_ReadEntireFile(arena, file);
|
result = OS_ReadEntireFile(arena, file);
|
||||||
OS_CloseFile(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)
|
void F_FilesFromDir(Arena *arena, StringList *list, String dir, F_IterFlag flags)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
StringList tmp = ZI;
|
StringList tmp = Zi;
|
||||||
String dir_full_path = F_GetFull(scratch.arena, dir);
|
String dir_full_path = F_GetFull(scratch.arena, dir);
|
||||||
OS_DirContentsFromFullPath(scratch.arena, &tmp, dir_full_path);
|
OS_DirContentsFromFullPath(scratch.arena, &tmp, dir_full_path);
|
||||||
for (StringListNode *n = tmp.first; n; n = n->next)
|
for (StringListNode *n = tmp.first; n; n = n->next)
|
||||||
|
|||||||
@ -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 M_TokensFromSrcDirs(Arena *arena, StringList src_dirs)
|
||||||
{
|
{
|
||||||
M_TokenFileList result = ZI;
|
M_TokenFileList result = Zi;
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
result.first = &M_NilTokenFile;
|
result.first = &M_NilTokenFile;
|
||||||
result.last = &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)
|
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;
|
String dir_name = dir_name_node->s;
|
||||||
StringList files = ZI;
|
StringList files = Zi;
|
||||||
F_FilesFromDir(arena, &files, dir_name, F_IterFlag_Recurse);
|
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)
|
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)
|
M_LayerList M_LayersFromTokenFiles(Arena *arena, M_TokenFileList lexed)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
M_LayerList result = ZI;
|
M_LayerList result = Zi;
|
||||||
result.first = &M_NilLayer;
|
result.first = &M_NilLayer;
|
||||||
result.last = &M_NilLayer;
|
result.last = &M_NilLayer;
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
String W32_StringFromError(Arena *arena, DWORD err)
|
String W32_StringFromError(Arena *arena, DWORD err)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
char *msg_cstr = 0;
|
char *msg_cstr = 0;
|
||||||
i64 len = FormatMessageA(
|
i64 len = FormatMessageA(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
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)
|
OS_File OS_OpenFile(String path, OS_FileFlag flags, i64 timeout_ns)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
OS_File result = ZI;
|
OS_File result = Zi;
|
||||||
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
||||||
u32 share_mode = FILE_SHARE_READ;
|
u32 share_mode = FILE_SHARE_READ;
|
||||||
u32 create_mode = OPEN_EXISTING;
|
u32 create_mode = OPEN_EXISTING;
|
||||||
@ -77,7 +77,7 @@ void OS_CloseFile(OS_File file)
|
|||||||
|
|
||||||
String OS_ReadEntireFile(Arena *arena, OS_File file)
|
String OS_ReadEntireFile(Arena *arena, OS_File file)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
HANDLE handle = (HANDLE)file.handle;
|
HANDLE handle = (HANDLE)file.handle;
|
||||||
u32 chunk_size = Kibi(64);
|
u32 chunk_size = Kibi(64);
|
||||||
result.text = ArenaNext(arena, u8);
|
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)
|
void OS_DirContentsFromFullPath(Arena *arena, StringList *list, String path)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
WIN32_FIND_DATAW find_data = ZI;
|
WIN32_FIND_DATAW find_data = Zi;
|
||||||
String filter = StringF(scratch.arena, "%F\\*", FmtString(path));
|
String filter = StringF(scratch.arena, "%F\\*", FmtString(path));
|
||||||
wchar_t *filter_wstr = WstrFromString(scratch.arena, filter);
|
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);
|
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();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
u64 result = 0;
|
u64 result = 0;
|
||||||
WIN32_FILE_ATTRIBUTE_DATA a = ZI;
|
WIN32_FILE_ATTRIBUTE_DATA a = Zi;
|
||||||
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
||||||
if (GetFileAttributesExW(path_wstr, GetFileExInfoStandard, &a))
|
if (GetFileAttributesExW(path_wstr, GetFileExInfoStandard, &a))
|
||||||
{
|
{
|
||||||
@ -202,12 +202,12 @@ void OS_Rm(String path)
|
|||||||
OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
|
OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
OS_CommandResult result = ZI;
|
OS_CommandResult result = Zi;
|
||||||
b32 ok = 1;
|
b32 ok = 1;
|
||||||
|
|
||||||
wchar_t *cmd_wstr = WstrFromString(scratch.arena, cmd);
|
wchar_t *cmd_wstr = WstrFromString(scratch.arena, cmd);
|
||||||
|
|
||||||
SECURITY_ATTRIBUTES sa = ZI;
|
SECURITY_ATTRIBUTES sa = Zi;
|
||||||
sa.nLength = sizeof(sa);
|
sa.nLength = sizeof(sa);
|
||||||
sa.bInheritHandle = 0;
|
sa.bInheritHandle = 0;
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize attrs list */
|
/* Initialize attrs list */
|
||||||
LPPROC_THREAD_ATTRIBUTE_LIST attrs = ZI;
|
LPPROC_THREAD_ATTRIBUTE_LIST attrs = Zi;
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
u64 attrs_size = 0;
|
u64 attrs_size = 0;
|
||||||
@ -271,8 +271,8 @@ OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
|
|||||||
HANDLE process_thread = 0;
|
HANDLE process_thread = 0;
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
PROCESS_INFORMATION pi = ZI;
|
PROCESS_INFORMATION pi = Zi;
|
||||||
STARTUPINFOEXW si = ZI;
|
STARTUPINFOEXW si = Zi;
|
||||||
si.StartupInfo.cb = sizeof(si);
|
si.StartupInfo.cb = sizeof(si);
|
||||||
si.StartupInfo.dwFlags = STARTF_USESTDHANDLES;
|
si.StartupInfo.dwFlags = STARTF_USESTDHANDLES;
|
||||||
si.StartupInfo.hStdOutput = child_pipe_write;
|
si.StartupInfo.hStdOutput = child_pipe_write;
|
||||||
@ -306,7 +306,7 @@ OS_CommandResult OS_RunCommand(Arena *arena, String cmd)
|
|||||||
b32 stdout_finished = 0;
|
b32 stdout_finished = 0;
|
||||||
while (!stdout_finished)
|
while (!stdout_finished)
|
||||||
{
|
{
|
||||||
u8 buff[4096] = ZI;
|
u8 buff[4096] = Zi;
|
||||||
DWORD bytes_read = 0;
|
DWORD bytes_read = 0;
|
||||||
if (!ReadFile(pipe_read, buff, countof(buff), &bytes_read, 0))
|
if (!ReadFile(pipe_read, buff, countof(buff), &bytes_read, 0))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
P_W32_SharedState P_W32_shared_state = ZI;
|
P_W32_SharedState P_W32_shared_state = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookimpl Bootstrap
|
//~ @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 P_W32_Win32AddressFromPlatformAddress(P_Address addr)
|
||||||
{
|
{
|
||||||
P_W32_Address result = ZI;
|
P_W32_Address result = Zi;
|
||||||
if (addr.family == P_AddressFamily_Ipv4)
|
if (addr.family == P_AddressFamily_Ipv4)
|
||||||
{
|
{
|
||||||
result.family = AF_INET;
|
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 P_W32_PlatformAddressFromWin32Address(P_W32_Address ws_addr)
|
||||||
{
|
{
|
||||||
P_Address result = ZI;
|
P_Address result = Zi;
|
||||||
if (ws_addr.family == AF_INET)
|
if (ws_addr.family == AF_INET)
|
||||||
{
|
{
|
||||||
result.family = P_AddressFamily_Ipv4;
|
result.family = P_AddressFamily_Ipv4;
|
||||||
@ -170,7 +170,7 @@ void P_W32_SyncTimerForever(WaveLaneCtx *lane)
|
|||||||
}
|
}
|
||||||
|
|
||||||
i32 periods_index = 0;
|
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)
|
for (i32 i = 0; i < (i32)countof(periods); ++i)
|
||||||
{
|
{
|
||||||
periods[i] = P_W32_DefaultTimerPeriodNs;
|
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 */
|
/* 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 = -1;
|
||||||
//due.QuadPart = -10000;
|
//due.QuadPart = -10000;
|
||||||
//due.QuadPart = -32000;
|
//due.QuadPart = -32000;
|
||||||
@ -230,7 +230,7 @@ String P_GetWritePath(Arena *arena)
|
|||||||
0,
|
0,
|
||||||
&p
|
&p
|
||||||
);
|
);
|
||||||
String path = ZI;
|
String path = Zi;
|
||||||
if (result == S_OK)
|
if (result == S_OK)
|
||||||
{
|
{
|
||||||
path = P_W32_StringFromWin32Path(arena, p);
|
path = P_W32_StringFromWin32Path(arena, p);
|
||||||
@ -262,7 +262,7 @@ void P_MkDir(String path)
|
|||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
||||||
int err_code = SHCreateDirectory(0, path_wstr);
|
int err_code = SHCreateDirectory(0, path_wstr);
|
||||||
String err = ZI;
|
String err = Zi;
|
||||||
switch (err_code)
|
switch (err_code)
|
||||||
{
|
{
|
||||||
default: break;
|
default: break;
|
||||||
@ -302,7 +302,7 @@ void P_MkDir(String path)
|
|||||||
P_File P_OpenFileRead(String path)
|
P_File P_OpenFileRead(String path)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
P_File file = ZI;
|
P_File file = Zi;
|
||||||
|
|
||||||
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
||||||
HANDLE handle = CreateFileW(
|
HANDLE handle = CreateFileW(
|
||||||
@ -324,7 +324,7 @@ P_File P_OpenFileRead(String path)
|
|||||||
P_File P_OpenFileReadWait(String path)
|
P_File P_OpenFileReadWait(String path)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
P_File file = ZI;
|
P_File file = Zi;
|
||||||
|
|
||||||
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
||||||
i32 delay_ms = 1;
|
i32 delay_ms = 1;
|
||||||
@ -354,7 +354,7 @@ P_File P_OpenFileReadWait(String path)
|
|||||||
P_File P_OpenFileWrite(String path)
|
P_File P_OpenFileWrite(String path)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
P_File file = ZI;
|
P_File file = Zi;
|
||||||
|
|
||||||
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
||||||
HANDLE handle = CreateFileW(
|
HANDLE handle = CreateFileW(
|
||||||
@ -376,7 +376,7 @@ P_File P_OpenFileWrite(String path)
|
|||||||
P_File P_OpenFileAppend(String path)
|
P_File P_OpenFileAppend(String path)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
P_File file = ZI;
|
P_File file = Zi;
|
||||||
|
|
||||||
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
wchar_t *path_wstr = WstrFromString(scratch.arena, path);
|
||||||
HANDLE handle = CreateFileW(
|
HANDLE handle = CreateFileW(
|
||||||
@ -503,7 +503,7 @@ P_FileTime P_GetFileTime(P_File file)
|
|||||||
|
|
||||||
P_FileMap P_OpenFileMap(P_File file)
|
P_FileMap P_OpenFileMap(P_File file)
|
||||||
{
|
{
|
||||||
P_FileMap map = ZI;
|
P_FileMap map = Zi;
|
||||||
|
|
||||||
u64 size = P_GetFileSize(file);
|
u64 size = P_GetFileSize(file);
|
||||||
u8 *base_ptr = 0;
|
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 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_family = AF_UNSPEC;
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
hints.ai_flags = AI_PASSIVE;
|
hints.ai_flags = AI_PASSIVE;
|
||||||
@ -742,7 +742,7 @@ P_Address P_AddressFromPort(u16 port)
|
|||||||
|
|
||||||
String P_StringFromAddress(Arena *arena, P_Address address)
|
String P_StringFromAddress(Arena *arena, P_Address address)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
|
|
||||||
if (address.family == P_AddressFamily_Ipv6)
|
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;
|
P_W32_Sock *ws = (P_W32_Sock *)sock;
|
||||||
|
|
||||||
u64 read_buff_size = Kibi(64);
|
u64 read_buff_size = Kibi(64);
|
||||||
String read_buff = ZI;
|
String read_buff = Zi;
|
||||||
read_buff.len = read_buff_size;
|
read_buff.len = read_buff_size;
|
||||||
read_buff.text = PushStructsNoZero(arena, u8, 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);
|
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);
|
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 P_GetClipboardText(Arena *arena)
|
||||||
{
|
{
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(0))
|
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(0))
|
||||||
{
|
{
|
||||||
HANDLE handle = GetClipboardData(CF_UNICODETEXT);
|
HANDLE handle = GetClipboardData(CF_UNICODETEXT);
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
S_SharedState S_shared_state = ZI;
|
S_Ctx S = Zi;
|
||||||
|
|
||||||
Readonly S_Ent S_nil_ent = {
|
Readonly S_ReadonlyCtx S_ro = {
|
||||||
.xf = CompXformIdentity
|
.nil_ent = {
|
||||||
|
.xf = CompXformIdentity
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -9,17 +11,15 @@ Readonly S_Ent S_nil_ent = {
|
|||||||
|
|
||||||
void S_Bootstrap(void)
|
void S_Bootstrap(void)
|
||||||
{
|
{
|
||||||
S_SharedState *shared = &S_shared_state;
|
|
||||||
|
|
||||||
/* Initialize 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));
|
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));
|
output->arena = AcquireArena(Gibi(64));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,9 +29,8 @@ void S_Bootstrap(void)
|
|||||||
|
|
||||||
void S_Shutdown(void)
|
void S_Shutdown(void)
|
||||||
{
|
{
|
||||||
S_SharedState *shared = &S_shared_state;
|
Atomic32Set(&S.shutdown, 1);
|
||||||
Atomic32Set(&shared->shutdown, 1);
|
YieldOnFence(&S.worker_completion_fence, S.workers_count);
|
||||||
YieldOnFence(&shared->worker_completion_fence, shared->workers_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -44,7 +43,7 @@ b32 S_IsKeyNil(S_Key key)
|
|||||||
|
|
||||||
b32 S_IsEntNil(S_Ent *ent)
|
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)
|
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)
|
S_Key S_RandKey(void)
|
||||||
{
|
{
|
||||||
/* TODO: Don't use true randomness for entity keys. It's overkill & non-deterministic. */
|
/* 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));
|
TrueRand(StringFromStruct(&result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -69,11 +68,11 @@ S_Key S_RandKey(void)
|
|||||||
S_Shape S_ShapeFromDescEx(S_ShapeDesc desc)
|
S_Shape S_ShapeFromDescEx(S_ShapeDesc desc)
|
||||||
{
|
{
|
||||||
desc.count = MaxI32(desc.count, 1);
|
desc.count = MaxI32(desc.count, 1);
|
||||||
S_Shape result = ZI;
|
S_Shape result = Zi;
|
||||||
{
|
{
|
||||||
result.points_count = desc.count;
|
result.points_count = desc.count;
|
||||||
CopyStructs(result.points, desc.points, result.points_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)
|
for (i32 p_idx = 0; p_idx < result.points_count; ++p_idx)
|
||||||
{
|
{
|
||||||
accum = AddVec2(accum, result.points[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 S_SupportPointFromShape(S_Shape shape, Vec2 dir)
|
||||||
{
|
{
|
||||||
Vec2 result = ZI;
|
Vec2 result = Zi;
|
||||||
f32 max_dot = -F32Infinity;
|
f32 max_dot = -F32Infinity;
|
||||||
for (i32 i = 0; i < shape.points_count; ++i)
|
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 S_LookupFromWorld(Arena *arena, S_World *world)
|
||||||
{
|
{
|
||||||
S_Lookup lookup = ZI;
|
S_Lookup lookup = Zi;
|
||||||
|
|
||||||
lookup.bins_count = 4096;
|
lookup.bins_count = 4096;
|
||||||
lookup.bins = PushStructs(arena, S_LookupEntNode *, lookup.bins_count);
|
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 *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))
|
if (!S_IsKeyNil(key))
|
||||||
{
|
{
|
||||||
i64 bins_count = lookup->bins_count;
|
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_Ent *S_NextEnt(S_Iter *iter)
|
||||||
{
|
{
|
||||||
S_World *world = iter->world;
|
S_World *world = iter->world;
|
||||||
S_Ent *result = &S_nil_ent;
|
S_Ent *result = &S_ro.nil_ent;
|
||||||
|
|
||||||
i64 ent_idx = iter->cur_idx;
|
i64 ent_idx = iter->cur_idx;
|
||||||
for (; ent_idx < world->ents_count; ++ent_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)
|
void S_TickForever(WaveLaneCtx *lane)
|
||||||
{
|
{
|
||||||
S_SharedState *shared = &S_shared_state;
|
|
||||||
Arena *frame_arena = AcquireArena(Gibi(64));
|
Arena *frame_arena = AcquireArena(Gibi(64));
|
||||||
Arena *perm = PermArena();
|
Arena *perm = PermArena();
|
||||||
|
|
||||||
@ -253,8 +251,8 @@ void S_TickForever(WaveLaneCtx *lane)
|
|||||||
while (!shutdown)
|
while (!shutdown)
|
||||||
{
|
{
|
||||||
ResetArena(frame_arena);
|
ResetArena(frame_arena);
|
||||||
S_Iter iter = ZI;
|
S_Iter iter = Zi;
|
||||||
S_Lookup lookup = ZI;
|
S_Lookup lookup = Zi;
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Begin sim frame
|
//- Begin sim frame
|
||||||
@ -270,16 +268,16 @@ void S_TickForever(WaveLaneCtx *lane)
|
|||||||
//- Pop sim commands
|
//- Pop sim commands
|
||||||
|
|
||||||
S_InputState *input = 0;
|
S_InputState *input = 0;
|
||||||
LockTicketMutex(&shared->input_back_tm);
|
LockTicketMutex(&S.input_back_tm);
|
||||||
{
|
{
|
||||||
input = &shared->input_states[shared->input_back_idx];
|
input = &S.input_states[S.input_back_idx];
|
||||||
++shared->input_back_idx;
|
++S.input_back_idx;
|
||||||
if (shared->input_back_idx >= countof(shared->input_states))
|
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
|
//- Spawn entities
|
||||||
@ -307,7 +305,7 @@ void S_TickForever(WaveLaneCtx *lane)
|
|||||||
{
|
{
|
||||||
dst = PushStructNoZero(ents_arena, S_Ent);
|
dst = PushStructNoZero(ents_arena, S_Ent);
|
||||||
}
|
}
|
||||||
*dst = S_nil_ent;
|
*dst = S_ro.nil_ent;
|
||||||
dst->key = key;
|
dst->key = key;
|
||||||
++world->ents_count;
|
++world->ents_count;
|
||||||
}
|
}
|
||||||
@ -367,7 +365,7 @@ void S_TickForever(WaveLaneCtx *lane)
|
|||||||
if (follow->active)
|
if (follow->active)
|
||||||
{
|
{
|
||||||
f32 follow_speed = 20 * sim_dt;
|
f32 follow_speed = 20 * sim_dt;
|
||||||
Vec2 look_ratio = ZI;
|
Vec2 look_ratio = Zi;
|
||||||
look_ratio.y = 0.25;
|
look_ratio.y = 0.25;
|
||||||
look_ratio.x = look_ratio.y / (16.0 / 9.0);
|
look_ratio.x = look_ratio.y / (16.0 / 9.0);
|
||||||
|
|
||||||
@ -384,9 +382,9 @@ void S_TickForever(WaveLaneCtx *lane)
|
|||||||
//- Publish sim state
|
//- Publish sim state
|
||||||
|
|
||||||
/* TODO: Only copy active entities */
|
/* 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);
|
ResetArena(output->arena);
|
||||||
S_SnapshotNode *snapshot_node = PushStruct(output->arena, S_SnapshotNode);
|
S_SnapshotNode *snapshot_node = PushStruct(output->arena, S_SnapshotNode);
|
||||||
S_Snapshot *snapshot = &snapshot_node->snapshot;
|
S_Snapshot *snapshot = &snapshot_node->snapshot;
|
||||||
@ -402,7 +400,7 @@ void S_TickForever(WaveLaneCtx *lane)
|
|||||||
*dst = *src;
|
*dst = *src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UnlockTicketMutex(&shared->output_back_tm);
|
UnlockTicketMutex(&S.output_back_tm);
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- End sim frame
|
//- End sim frame
|
||||||
@ -422,11 +420,11 @@ void S_TickForever(WaveLaneCtx *lane)
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Sleep
|
//- Sleep
|
||||||
|
|
||||||
if (!Atomic32Fetch(&shared->shutdown))
|
if (!Atomic32Fetch(&S.shutdown))
|
||||||
{
|
{
|
||||||
i64 step_dt_ns = NsFromSeconds(1) / SIM_TICKS_PER_SECOND;
|
i64 step_dt_ns = NsFromSeconds(1) / SIM_TICKS_PER_SECOND;
|
||||||
P_SleepFrame(frame_begin_ns, step_dt_ns);
|
P_SleepFrame(frame_begin_ns, step_dt_ns);
|
||||||
}
|
}
|
||||||
shutdown = Atomic32Fetch(&shared->shutdown);
|
shutdown = Atomic32Fetch(&S.shutdown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ Struct(S_Ent)
|
|||||||
|
|
||||||
i64 next_free_ent_num;
|
i64 next_free_ent_num;
|
||||||
|
|
||||||
} extern Readonly S_nil_ent;
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Ent container types
|
//~ Ent container types
|
||||||
@ -165,7 +165,7 @@ Struct(S_CmdNode)
|
|||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ Context types
|
||||||
|
|
||||||
#define S_InputStatesCount 2
|
#define S_InputStatesCount 2
|
||||||
#define S_OutputStatesCount 2
|
#define S_OutputStatesCount 2
|
||||||
@ -186,7 +186,7 @@ Struct(S_OutputState)
|
|||||||
u64 snapshots_count;
|
u64 snapshots_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
Struct(S_SharedState)
|
Struct(S_Ctx)
|
||||||
{
|
{
|
||||||
Atomic32 shutdown;
|
Atomic32 shutdown;
|
||||||
Fence worker_completion_fence;
|
Fence worker_completion_fence;
|
||||||
@ -202,7 +202,15 @@ Struct(S_SharedState)
|
|||||||
i32 output_back_idx;
|
i32 output_back_idx;
|
||||||
S_OutputState output_states[S_OutputStatesCount];
|
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
|
//~ Bootstrap
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
V_State V = ZI;
|
V_Ctx V = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Bootstrap
|
//~ Bootstrap
|
||||||
@ -20,7 +20,6 @@ void V_Shutdown(void)
|
|||||||
void V_TickForever(WaveLaneCtx *lane)
|
void V_TickForever(WaveLaneCtx *lane)
|
||||||
{
|
{
|
||||||
Arena *perm = PermArena();
|
Arena *perm = PermArena();
|
||||||
S_SharedState *sim_shared = &S_shared_state;
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Init vis state
|
//- Init vis state
|
||||||
@ -48,10 +47,10 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
b32 show_command_palette;
|
b32 show_command_palette;
|
||||||
b32 show_console;
|
b32 show_console;
|
||||||
};
|
};
|
||||||
Persist persist = ZI;
|
Persist persist = Zi;
|
||||||
String window_restore = ZI;
|
String window_restore = Zi;
|
||||||
|
|
||||||
Button held_buttons[Button_Count] = ZI;
|
Button held_buttons[Button_Count] = Zi;
|
||||||
|
|
||||||
/* Init shortcuts */
|
/* Init shortcuts */
|
||||||
u64 shortcut_bins_count = 1024;
|
u64 shortcut_bins_count = 1024;
|
||||||
@ -141,8 +140,8 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
frame->time_ns = TimeNs();
|
frame->time_ns = TimeNs();
|
||||||
frame->tick = last_frame->tick + 1;
|
frame->tick = last_frame->tick + 1;
|
||||||
|
|
||||||
S_Iter iter = ZI;
|
S_Iter iter = Zi;
|
||||||
S_EntList spawn_ents = ZI;
|
S_EntList spawn_ents = Zi;
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Spawn test ents
|
//- Spawn test ents
|
||||||
@ -159,7 +158,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
SllQueuePush(spawn_ents.first, spawn_ents.last, n);
|
SllQueuePush(spawn_ents.first, spawn_ents.last, n);
|
||||||
++spawn_ents.count;
|
++spawn_ents.count;
|
||||||
S_Ent *ent = &n->ent;
|
S_Ent *ent = &n->ent;
|
||||||
*ent = S_nil_ent;
|
*ent = S_ro.nil_ent;
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
/* Test player */
|
/* Test player */
|
||||||
@ -224,7 +223,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
UI_Key vis_box = UI_KeyF("vis box");
|
UI_Key vis_box = UI_KeyF("vis box");
|
||||||
UI_Push(Parent, UI_BuildColumnEx(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 */
|
/* 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);
|
UI_Report vis_rep = UI_ReportFromKey(vis_box);
|
||||||
@ -237,16 +236,16 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
//- Pop sim output
|
//- Pop sim output
|
||||||
|
|
||||||
S_OutputState *sim_output = 0;
|
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_output = &S.output_states[S.output_back_idx];
|
||||||
++sim_shared->output_back_idx;
|
++S.output_back_idx;
|
||||||
if (sim_shared->output_back_idx >= countof(sim_shared->output_states))
|
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)
|
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;
|
f32 meters_per_draw_width = 20;
|
||||||
|
|
||||||
Vec2 camera_pos = ZI;
|
Vec2 camera_pos = Zi;
|
||||||
f32 camera_zoom = 1;
|
f32 camera_zoom = 1;
|
||||||
{
|
{
|
||||||
S_Ent *player = S_EntFromKey(&V.lookup, V.player_key);
|
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 world_to_draw_xf = XformIdentity;
|
||||||
Xform draw_to_world_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.x = (f32)draw_size.x / meters_per_draw_width;
|
||||||
scale.y = scale.x;
|
scale.y = scale.x;
|
||||||
world_to_draw_xf = XformFromScale(scale);
|
world_to_draw_xf = XformFromScale(scale);
|
||||||
@ -322,7 +321,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
b32 up = cev.kind == ControllerEventKind_ButtonUp;
|
b32 up = cev.kind == ControllerEventKind_ButtonUp;
|
||||||
if (down || up)
|
if (down || up)
|
||||||
{
|
{
|
||||||
V_Hotkey hotkey = ZI;
|
V_Hotkey hotkey = Zi;
|
||||||
hotkey.button = cev.button;
|
hotkey.button = cev.button;
|
||||||
hotkey.ctrl = held_buttons[Button_Ctrl];
|
hotkey.ctrl = held_buttons[Button_Ctrl];
|
||||||
hotkey.shift = held_buttons[Button_Shift];
|
hotkey.shift = held_buttons[Button_Shift];
|
||||||
@ -362,7 +361,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
V_CmdDesc desc = V_cmd_descs[i];
|
V_CmdDesc desc = V_cmd_descs[i];
|
||||||
if (!desc.flags & V_CmdDescFlag_HideFromPalette)
|
if (!desc.flags & V_CmdDescFlag_HideFromPalette)
|
||||||
{
|
{
|
||||||
V_CommandsWidgetItemDesc item_desc = ZI;
|
V_CommandsWidgetItemDesc item_desc = Zi;
|
||||||
item_desc.display_name = desc.display_name;
|
item_desc.display_name = desc.display_name;
|
||||||
/* FIXME: Attach active shortcuts instead of default hotkeys */
|
/* FIXME: Attach active shortcuts instead of default hotkeys */
|
||||||
CopyStructs(item_desc.hotkeys, desc.default_hotkeys, MinU32(countof(item_desc.hotkeys), countof(desc.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
|
//- 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 */
|
/* Submit control cmd */
|
||||||
{
|
{
|
||||||
@ -500,14 +499,14 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
cmd = &cmd_node->cmd;
|
cmd = &cmd_node->cmd;
|
||||||
}
|
}
|
||||||
cmd->kind = S_CmdKind_Control;
|
cmd->kind = S_CmdKind_Control;
|
||||||
Vec2 move = ZI;
|
Vec2 move = Zi;
|
||||||
{
|
{
|
||||||
if (held_buttons[Button_A]) move.x -= 1;
|
if (held_buttons[Button_A]) move.x -= 1;
|
||||||
if (held_buttons[Button_D]) move.x += 1;
|
if (held_buttons[Button_D]) move.x += 1;
|
||||||
if (held_buttons[Button_W]) move.y -= 1;
|
if (held_buttons[Button_W]) move.y -= 1;
|
||||||
if (held_buttons[Button_S]) 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);
|
S_Ent *player = S_EntFromKey(&V.lookup, V.player_key);
|
||||||
Vec2 center = MulXformV2(player->xf, player->local_shape.centroid);
|
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
|
//- Render
|
||||||
@ -608,7 +607,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
G_IndexBufferDesc dvert_idxs_ib = G_IdxBuff32(dvert_idxs_buff);
|
G_IndexBufferDesc dvert_idxs_ib = G_IdxBuff32(dvert_idxs_buff);
|
||||||
|
|
||||||
/* Params */
|
/* Params */
|
||||||
V_DParams params = ZI;
|
V_DParams params = Zi;
|
||||||
{
|
{
|
||||||
params.target_size = draw_size;
|
params.target_size = draw_size;
|
||||||
params.target_ro = draw_target_ro;
|
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);
|
G_DumbMemoryLayoutSync(frame->cl, draw_target, G_Layout_DirectQueue_ShaderRead);
|
||||||
{
|
{
|
||||||
Rng2 uv = ZI;
|
Rng2 uv = Zi;
|
||||||
uv.p0 = Vec2FromVec(viewport.p0);
|
uv.p0 = Vec2FromVec(viewport.p0);
|
||||||
uv.p1 = Vec2FromVec(viewport.p1);
|
uv.p1 = Vec2FromVec(viewport.p1);
|
||||||
uv = DivRng2Vec2(uv, Vec2FromVec(draw_size));
|
uv = DivRng2Vec2(uv, Vec2FromVec(draw_size));
|
||||||
|
|||||||
@ -71,7 +71,7 @@ Global Readonly V_CmdDesc V_cmd_descs[V_CmdKind_Count] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State types
|
//~ Context types
|
||||||
|
|
||||||
Struct(V_Frame)
|
Struct(V_Frame)
|
||||||
{
|
{
|
||||||
@ -85,7 +85,7 @@ Struct(V_Frame)
|
|||||||
G_CommandListHandle cl;
|
G_CommandListHandle cl;
|
||||||
};
|
};
|
||||||
|
|
||||||
Struct(V_State)
|
Struct(V_Ctx)
|
||||||
{
|
{
|
||||||
Arena *world_arena;
|
Arena *world_arena;
|
||||||
S_World *world;
|
S_World *world;
|
||||||
@ -97,7 +97,9 @@ Struct(V_State)
|
|||||||
|
|
||||||
u64 current_frame_idx;
|
u64 current_frame_idx;
|
||||||
V_Frame frames[2];
|
V_Frame frames[2];
|
||||||
} extern V;
|
};
|
||||||
|
|
||||||
|
extern V_Ctx V;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Bootstrap
|
//~ Bootstrap
|
||||||
|
|||||||
@ -97,7 +97,7 @@ void V_DrawShape(Arena *verts_arena, Arena *idxs_arena, S_Shape shape, Vec4 colo
|
|||||||
{
|
{
|
||||||
if (shape.radius == 0)
|
if (shape.radius == 0)
|
||||||
{
|
{
|
||||||
Vec2Array draw_points = ZI;
|
Vec2Array draw_points = Zi;
|
||||||
draw_points.points = shape.points;
|
draw_points.points = shape.points;
|
||||||
draw_points.count = shape.points_count;
|
draw_points.count = shape.points_count;
|
||||||
V_DrawPoly(verts_arena, idxs_arena, draw_points, color_lin, flags);
|
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();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
{
|
{
|
||||||
Vec2Array draw_points = ZI;
|
Vec2Array draw_points = Zi;
|
||||||
draw_points.points = PushStructsNoZero(scratch.arena, Vec2, detail);
|
draw_points.points = PushStructsNoZero(scratch.arena, Vec2, detail);
|
||||||
draw_points.count = detail;
|
draw_points.count = detail;
|
||||||
for (i32 i = 0; i < detail; ++i)
|
for (i32 i = 0; i < detail; ++i)
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
V_WidgetTheme V_GetWidgetTheme(void)
|
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 = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/fixedsys.ttf")));
|
||||||
theme.font_size = 16;
|
theme.font_size = 16;
|
||||||
@ -40,7 +40,7 @@ void V_PushWidgetThemeStyles(V_WidgetTheme theme)
|
|||||||
String V_StringFromHotkey(Arena *arena, V_Hotkey hotkey)
|
String V_StringFromHotkey(Arena *arena, V_Hotkey hotkey)
|
||||||
{
|
{
|
||||||
TempArena scratch = BeginScratch(arena);
|
TempArena scratch = BeginScratch(arena);
|
||||||
StringList parts = ZI;
|
StringList parts = Zi;
|
||||||
if (hotkey.ctrl)
|
if (hotkey.ctrl)
|
||||||
{
|
{
|
||||||
PushStringToList(scratch.arena, &parts, Lit("Ctrl"));
|
PushStringToList(scratch.arena, &parts, Lit("Ctrl"));
|
||||||
@ -81,7 +81,7 @@ V_CommandsWidgetItemReport V_PushCommandsWidgetItem(V_CommandsWidget *widget, V_
|
|||||||
++widget->build.num_items;
|
++widget->build.num_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
V_CommandsWidgetItemReport result = ZI;
|
V_CommandsWidgetItemReport result = Zi;
|
||||||
UI_Report rep = UI_ReportFromKey(key);
|
UI_Report rep = UI_ReportFromKey(key);
|
||||||
result.ui_report = rep;
|
result.ui_report = rep;
|
||||||
result.pressed = rep.m1_presses > 0;
|
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_background_color = theme.window_background_color;
|
||||||
Vec4 window_border_color = theme.window_border_color;
|
Vec4 window_border_color = theme.window_border_color;
|
||||||
Vec4 titlebar_color = ZI;
|
Vec4 titlebar_color = Zi;
|
||||||
Vec4 titlebar_border_color = ZI;
|
Vec4 titlebar_border_color = Zi;
|
||||||
Vec4 divider_color = theme.divider_color;
|
Vec4 divider_color = theme.divider_color;
|
||||||
{
|
{
|
||||||
UI_Report rep = UI_ReportFromKey(titlebar_key);
|
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);
|
UI_Report btn_rep = UI_ReportFromKey(btn_key);
|
||||||
|
|
||||||
Vec4 btn_color = theme.window_background_color;
|
Vec4 btn_color = theme.window_background_color;
|
||||||
Vec4 btn_border_color = ZI;
|
Vec4 btn_border_color = Zi;
|
||||||
{
|
{
|
||||||
Vec4 hovered_color = Rgb32(0x103c4c);
|
Vec4 hovered_color = Rgb32(0x103c4c);
|
||||||
Vec4 pressed_color = hovered_color;
|
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_Key hotkey_key = UI_KeyF("hotkey%F", FmtUint(i));
|
||||||
UI_Report hotkey_rep = UI_ReportFromKey(hotkey_key);
|
UI_Report hotkey_rep = UI_ReportFromKey(hotkey_key);
|
||||||
|
|
||||||
Vec4 hotkey_color = ZI;
|
Vec4 hotkey_color = Zi;
|
||||||
Vec4 hotkey_border_color = ZI;
|
Vec4 hotkey_border_color = Zi;
|
||||||
{
|
{
|
||||||
Vec4 hovered_color = Rgb32(0x103c4c);
|
Vec4 hovered_color = Rgb32(0x103c4c);
|
||||||
Vec4 pressed_color = hovered_color;
|
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 = minimized ? LogLevel_Success : LogLevel_Debug;
|
||||||
i32 console_level = LogLevel_Debug;
|
i32 console_level = LogLevel_Debug;
|
||||||
|
|
||||||
Vec4 colors[LogLevel_Count][2] = ZI;
|
Vec4 colors[LogLevel_Count][2] = Zi;
|
||||||
SetBytes(colors, 0xFF, sizeof(colors));
|
SetBytes(colors, 0xFF, sizeof(colors));
|
||||||
/* Debug colors */
|
/* Debug colors */
|
||||||
colors[LogLevel_Debug][0] = Rgb(0.4, 0.1, 0.4);
|
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;
|
f32 fade_curve = 0.5;
|
||||||
|
|
||||||
i64 now_ns = TimeNs();
|
i64 now_ns = TimeNs();
|
||||||
UI_Key console_box = ZI;
|
UI_Key console_box = Zi;
|
||||||
{
|
{
|
||||||
UI_SetNext(Border, 0);
|
UI_SetNext(Border, 0);
|
||||||
if (minimized)
|
if (minimized)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/* Based on Allen Webster's dwrite rasterizer example -
|
/* Based on Allen Webster's dwrite rasterizer example -
|
||||||
* https://github.com/4th-dimention/examps */
|
* https://github.com/4th-dimention/examps */
|
||||||
|
|
||||||
extern TTF_DW_Ctx TTF_DW = ZI;
|
extern TTF_DW_Ctx TTF_DW = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookimpl Bootstrap
|
//~ @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_descent = font->design_metrics.descent * pixels_per_design_unit;
|
||||||
f32 font_cap = font->design_metrics.capHeight * 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))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
@ -199,7 +199,7 @@ TTF_GlyphResult TTF_RasterizeGlyphFromCodepoint(Arena *arena, u32 codepoint, Res
|
|||||||
rt = PushStruct(perm, TTF_DW_RenderTarget);
|
rt = PushStruct(perm, TTF_DW_RenderTarget);
|
||||||
IDWriteBitmapRenderTarget *dw_rt = 0;
|
IDWriteBitmapRenderTarget *dw_rt = 0;
|
||||||
HDC dc = 0;
|
HDC dc = 0;
|
||||||
DIBSECTION dib = ZI;
|
DIBSECTION dib = Zi;
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = IDWriteGdiInterop_CreateBitmapRenderTarget(TTF_DW.gdi_interop, 0, (UINT32)rt_dims.x, (UINT32)rt_dims.y, &dw_rt);
|
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 */
|
/* Glyph metrics */
|
||||||
DWRITE_GLYPH_METRICS m = ZI;
|
DWRITE_GLYPH_METRICS m = Zi;
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = IDWriteFontFace_GetDesignGlyphMetrics(font->face, &glyph_idx, 1, &m, 0);
|
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;
|
f32 advance = (f32)m.advanceWidth * pixels_per_design_unit;
|
||||||
|
|
||||||
/* Best-guess a position in the middle of the render target based on metrics */
|
/* 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.x = (rt_dims.x / 2) - (advance / 2);
|
||||||
rt_baseline.y = (rt_dims.y / 2) + (font_cap / 2);
|
rt_baseline.y = (rt_dims.y / 2) + (font_cap / 2);
|
||||||
|
|
||||||
/* Render */
|
/* Render */
|
||||||
Rng2I32 rt_slice = ZI;
|
Rng2I32 rt_slice = Zi;
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
/* Clear target */
|
/* Clear target */
|
||||||
@ -263,14 +263,14 @@ TTF_GlyphResult TTF_RasterizeGlyphFromCodepoint(Arena *arena, u32 codepoint, Res
|
|||||||
}
|
}
|
||||||
/* Draw glyph */
|
/* Draw glyph */
|
||||||
{
|
{
|
||||||
DWRITE_GLYPH_RUN glyph_run = ZI;
|
DWRITE_GLYPH_RUN glyph_run = Zi;
|
||||||
{
|
{
|
||||||
glyph_run.fontFace = font->face;
|
glyph_run.fontFace = font->face;
|
||||||
glyph_run.fontEmSize = pixels_per_em;
|
glyph_run.fontEmSize = pixels_per_em;
|
||||||
glyph_run.glyphCount = 1;
|
glyph_run.glyphCount = 1;
|
||||||
glyph_run.glyphIndices = &glyph_idx;
|
glyph_run.glyphIndices = &glyph_idx;
|
||||||
}
|
}
|
||||||
RECT bounding_box = ZI;
|
RECT bounding_box = Zi;
|
||||||
hr = IDWriteBitmapRenderTarget_DrawGlyphRun(
|
hr = IDWriteBitmapRenderTarget_DrawGlyphRun(
|
||||||
rt->dw_rt,
|
rt->dw_rt,
|
||||||
rt_baseline.x,
|
rt_baseline.x,
|
||||||
@ -296,7 +296,7 @@ TTF_GlyphResult TTF_RasterizeGlyphFromCodepoint(Arena *arena, u32 codepoint, Res
|
|||||||
//- Copy result
|
//- Copy result
|
||||||
|
|
||||||
/* Copy from target to result */
|
/* Copy from target to result */
|
||||||
Vec2I32 dst_dims = ZI;
|
Vec2I32 dst_dims = Zi;
|
||||||
u32 *dst_pixels = 0;
|
u32 *dst_pixels = 0;
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
UI_State UI_state = ZI;
|
UI_State UI_state = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Bootstrap
|
//~ Bootstrap
|
||||||
@ -21,14 +21,14 @@ GC_FontKey UI_GetDefaultFont(void)
|
|||||||
UI_Key UI_KeyFromString(String str)
|
UI_Key UI_KeyFromString(String str)
|
||||||
{
|
{
|
||||||
u64 top_tag = UI_UseTop(Tag);
|
u64 top_tag = UI_UseTop(Tag);
|
||||||
UI_Key key = ZI;
|
UI_Key key = Zi;
|
||||||
key.hash = HashFnv64(top_tag, str);
|
key.hash = HashFnv64(top_tag, str);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
UI_Key UI_KeyF_(String fmt, ...)
|
UI_Key UI_KeyF_(String fmt, ...)
|
||||||
{
|
{
|
||||||
UI_Key key = ZI;
|
UI_Key key = Zi;
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -45,7 +45,7 @@ UI_Key UI_TransKey(void)
|
|||||||
{
|
{
|
||||||
UI_Frame *frame = UI_CurrentFrame();
|
UI_Frame *frame = UI_CurrentFrame();
|
||||||
u64 seed = ++frame->transient_key_seed;
|
u64 seed = ++frame->transient_key_seed;
|
||||||
UI_Key key = ZI;
|
UI_Key key = Zi;
|
||||||
key.hash = RandU64FromSeed(seed);
|
key.hash = RandU64FromSeed(seed);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ UI_Box *UI_BoxFromKey(UI_Key key)
|
|||||||
String UI_StringF_(String fmt, ...)
|
String UI_StringF_(String fmt, ...)
|
||||||
{
|
{
|
||||||
UI_Frame *frame = UI_CurrentFrame();
|
UI_Frame *frame = UI_CurrentFrame();
|
||||||
String result = ZI;
|
String result = Zi;
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -139,7 +139,7 @@ void UI_PushDefaults(void)
|
|||||||
{
|
{
|
||||||
for (UI_StyleKind kind = UI_StyleKind_None; kind < UI_StyleKind_Count; ++kind)
|
for (UI_StyleKind kind = UI_StyleKind_None; kind < UI_StyleKind_Count; ++kind)
|
||||||
{
|
{
|
||||||
UI_StyleDesc desc = ZI;
|
UI_StyleDesc desc = Zi;
|
||||||
desc.style.kind = kind;
|
desc.style.kind = kind;
|
||||||
switch (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_Height: { desc.style.Height = UI_GROW(1, 0); }
|
||||||
case UI_StyleKind_Font: { desc.style.Font = UI_GetDefaultFont(); } break;
|
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)
|
for (u64 idx = 0; idx < countof(prefetch); ++idx)
|
||||||
{
|
{
|
||||||
prefetch[idx] = idx;
|
prefetch[idx] = idx;
|
||||||
@ -299,7 +299,7 @@ UI_Style UI_PopStyle(UI_StyleDesc desc)
|
|||||||
{
|
{
|
||||||
UI_Frame *frame = UI_CurrentFrame();
|
UI_Frame *frame = UI_CurrentFrame();
|
||||||
UI_Stack *stack = frame->top_stack;
|
UI_Stack *stack = frame->top_stack;
|
||||||
UI_Style result = ZI;
|
UI_Style result = Zi;
|
||||||
UI_StyleKind kind = desc.style.kind;
|
UI_StyleKind kind = desc.style.kind;
|
||||||
result.kind = kind;
|
result.kind = kind;
|
||||||
if (kind >= UI_StyleKind_BeginVirtualStyles_)
|
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_Report UI_ReportFromKey(UI_Key key)
|
||||||
{
|
{
|
||||||
UI_State *g = &UI_state;
|
UI_State *g = &UI_state;
|
||||||
UI_Report result = ZI;
|
UI_Report result = Zi;
|
||||||
|
|
||||||
UI_Box *box = UI_BoxFromKey(key);
|
UI_Box *box = UI_BoxFromKey(key);
|
||||||
if (box)
|
if (box)
|
||||||
@ -1095,7 +1095,7 @@ void UI_EndFrame(UI_Frame *frame)
|
|||||||
{
|
{
|
||||||
f32 *dims_arr = box->solved_dims;
|
f32 *dims_arr = box->solved_dims;
|
||||||
Vec2 dims_vec = VEC2(dims_arr[0], dims_arr[1]);
|
Vec2 dims_vec = VEC2(dims_arr[0], dims_arr[1]);
|
||||||
Vec2 final_pos = ZI;
|
Vec2 final_pos = Zi;
|
||||||
|
|
||||||
/* Floating box position */
|
/* Floating box position */
|
||||||
if (AnyBit(box->desc.flags, UI_BoxFlag_Floating))
|
if (AnyBit(box->desc.flags, UI_BoxFlag_Floating))
|
||||||
@ -1118,7 +1118,7 @@ void UI_EndFrame(UI_Frame *frame)
|
|||||||
else if (parent)
|
else if (parent)
|
||||||
{
|
{
|
||||||
f32 layout_cursor = parent->layout_cursor;
|
f32 layout_cursor = parent->layout_cursor;
|
||||||
f32 offset[2] = ZI;
|
f32 offset[2] = Zi;
|
||||||
/* Compute offset in layout direction */
|
/* Compute offset in layout direction */
|
||||||
{
|
{
|
||||||
Axis axis = parent->desc.child_layout_axis;
|
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_width = raw_run.baseline_length;
|
||||||
f32 baseline_height = ascent + font_descent;
|
f32 baseline_height = ascent + font_descent;
|
||||||
Vec2 box_dims = DimsFromRng2(box->rect);
|
Vec2 box_dims = DimsFromRng2(box->rect);
|
||||||
Vec2 baseline = ZI;
|
Vec2 baseline = Zi;
|
||||||
switch (x_alignment)
|
switch (x_alignment)
|
||||||
{
|
{
|
||||||
case UI_AxisAlignment_Start:
|
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);
|
G_StructuredBufferRef rects_ro = G_PushStructuredBufferRef(frame->gpu_arena, rects_buff, UI_DRect);
|
||||||
|
|
||||||
/* Params */
|
/* Params */
|
||||||
UI_DParams params = ZI;
|
UI_DParams params = Zi;
|
||||||
{
|
{
|
||||||
params.target_size = draw_size;
|
params.target_size = draw_size;
|
||||||
params.target_ro = draw_target_ro;
|
params.target_ro = draw_target_ro;
|
||||||
|
|||||||
@ -9,7 +9,7 @@ UI_Key UI_BuildLabel(String text)
|
|||||||
Vec4 tint = UI_UseTop(Tint);
|
Vec4 tint = UI_UseTop(Tint);
|
||||||
UI_Alignment alignment = UI_UseTop(ChildAlignment);
|
UI_Alignment alignment = UI_UseTop(ChildAlignment);
|
||||||
|
|
||||||
UI_Key key = ZI;
|
UI_Key key = Zi;
|
||||||
UI_PushCP(UI_NilKey);
|
UI_PushCP(UI_NilKey);
|
||||||
{
|
{
|
||||||
UI_PushDefaults();
|
UI_PushDefaults();
|
||||||
@ -30,7 +30,7 @@ UI_Key UI_BuildLabel(String text)
|
|||||||
|
|
||||||
UI_Key UI_BuildLabelF_(String fmt, ...)
|
UI_Key UI_BuildLabelF_(String fmt, ...)
|
||||||
{
|
{
|
||||||
UI_Key key = ZI;
|
UI_Key key = Zi;
|
||||||
TempArena scratch = BeginScratchNoConflict();
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
@ -49,7 +49,7 @@ UI_Key UI_BuildLabelF_(String fmt, ...)
|
|||||||
UI_Key UI_BuildSpacer(UI_Size size, Axis axis)
|
UI_Key UI_BuildSpacer(UI_Size size, Axis axis)
|
||||||
{
|
{
|
||||||
UI_Key parent = UI_UseTop(Parent);
|
UI_Key parent = UI_UseTop(Parent);
|
||||||
UI_Key key = ZI;
|
UI_Key key = Zi;
|
||||||
UI_PushCP(UI_NilKey);
|
UI_PushCP(UI_NilKey);
|
||||||
{
|
{
|
||||||
UI_PushDefaults();
|
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 UI_BuildDivider(UI_Size size, Vec4 color, Axis axis)
|
||||||
{
|
{
|
||||||
UI_Key key = ZI;
|
UI_Key key = Zi;
|
||||||
UI_Key parent = UI_UseTop(Parent);
|
UI_Key parent = UI_UseTop(Parent);
|
||||||
Vec4 tint = UI_UseTop(Tint);
|
Vec4 tint = UI_UseTop(Tint);
|
||||||
UI_PushCP(UI_NilKey);
|
UI_PushCP(UI_NilKey);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
WND_W32_SharedState WND_W32_shared_state = ZI;
|
WND_W32_SharedState WND_W32_shared_state = Zi;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ @hookimpl Bootstrap
|
//~ @hookimpl Bootstrap
|
||||||
@ -67,7 +67,7 @@ void WND_Bootstrap(void)
|
|||||||
wc->hInstance = instance;
|
wc->hInstance = instance;
|
||||||
|
|
||||||
/* Use first icon resource as window icon (same as explorer) */
|
/* 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));
|
GetModuleFileNameW(instance, path, countof(path));
|
||||||
ExtractIconExW(path, 0, &wc->hIcon, &wc->hIconSm, 1);
|
ExtractIconExW(path, 0, &wc->hIcon, &wc->hIconSm, 1);
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ void WND_Bootstrap(void)
|
|||||||
|
|
||||||
//- Register raw mouse input
|
//- Register raw mouse input
|
||||||
{
|
{
|
||||||
RAWINPUTDEVICE rid = ZI;
|
RAWINPUTDEVICE rid = Zi;
|
||||||
rid.usUsagePage = 0x01; /* HID_USAGE_PAGE_GENERIC */
|
rid.usUsagePage = 0x01; /* HID_USAGE_PAGE_GENERIC */
|
||||||
rid.usUsage = 0x02; /* HID_USAGE_GENERIC_MOUSE */
|
rid.usUsage = 0x02; /* HID_USAGE_GENERIC_MOUSE */
|
||||||
RegisterRawInputDevices(&rid, 1, sizeof(rid));
|
RegisterRawInputDevices(&rid, 1, sizeof(rid));
|
||||||
@ -153,7 +153,7 @@ void WND_W32_ProcessMessagesForever(WaveLaneCtx *lane)
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
// SetFocus(window->hwnd);
|
// SetFocus(window->hwnd);
|
||||||
MSG msg = ZI;
|
MSG msg = Zi;
|
||||||
GetMessageW(&msg, 0, 0, 0);
|
GetMessageW(&msg, 0, 0, 0);
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
@ -207,7 +207,7 @@ LRESULT CALLBACK WND_W32_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
|
|||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
{
|
{
|
||||||
WORD vk_code = LOWORD(wparam);
|
WORD vk_code = LOWORD(wparam);
|
||||||
ControllerEvent event = ZI;
|
ControllerEvent event = Zi;
|
||||||
if (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN)
|
if (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN)
|
||||||
{
|
{
|
||||||
event.kind = ControllerEventKind_ButtonDown;
|
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')
|
if ((codepoint >= 32 && codepoint != 127) || codepoint == '\t' || codepoint == '\n')
|
||||||
{
|
{
|
||||||
ControllerEvent event = ZI;
|
ControllerEvent event = Zi;
|
||||||
event.kind = ControllerEventKind_Text;
|
event.kind = ControllerEventKind_Text;
|
||||||
event.text_codepoint = codepoint;
|
event.text_codepoint = codepoint;
|
||||||
WND_W32_PushEvent(window, event);
|
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_RBUTTONDOWN:
|
||||||
case WM_XBUTTONDOWN:
|
case WM_XBUTTONDOWN:
|
||||||
{
|
{
|
||||||
ControllerEvent event = ZI;
|
ControllerEvent event = Zi;
|
||||||
b32 is_down = msg == WM_LBUTTONDOWN ||
|
b32 is_down = msg == WM_LBUTTONDOWN ||
|
||||||
msg == WM_MBUTTONDOWN ||
|
msg == WM_MBUTTONDOWN ||
|
||||||
msg == WM_RBUTTONDOWN ||
|
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 x = GET_X_LPARAM(lparam);
|
||||||
i32 y = GET_Y_LPARAM(lparam);
|
i32 y = GET_Y_LPARAM(lparam);
|
||||||
ControllerEvent event = ZI;
|
ControllerEvent event = Zi;
|
||||||
event.kind = ControllerEventKind_CursorMove;
|
event.kind = ControllerEventKind_CursorMove;
|
||||||
event.cursor_pos = VEC2I32(x, y);
|
event.cursor_pos = VEC2I32(x, y);
|
||||||
WND_W32_PushEvent(window, event);
|
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");
|
LogErrorF("GetRawInputData did not return correct size");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
RAWINPUT raw = ZI;
|
RAWINPUT raw = Zi;
|
||||||
CopyBytes(&raw, buff, sizeof(RAWINPUT));
|
CopyBytes(&raw, buff, sizeof(RAWINPUT));
|
||||||
|
|
||||||
if (raw.header.dwType == RIM_TYPEMOUSE)
|
if (raw.header.dwType == RIM_TYPEMOUSE)
|
||||||
{
|
{
|
||||||
i32 x = raw.data.mouse.lLastX;
|
i32 x = raw.data.mouse.lLastX;
|
||||||
i32 y = raw.data.mouse.lLastY;
|
i32 y = raw.data.mouse.lLastY;
|
||||||
ControllerEvent event = ZI;
|
ControllerEvent event = Zi;
|
||||||
event.kind = ControllerEventKind_MouseMove;
|
event.kind = ControllerEventKind_MouseMove;
|
||||||
event.mouse_delta = VEC2I32(x, y);
|
event.mouse_delta = VEC2I32(x, y);
|
||||||
WND_W32_PushEvent(window, event);
|
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_SharedState *g = &WND_W32_shared_state;
|
||||||
WND_W32_Window *window = &g->window;
|
WND_W32_Window *window = &g->window;
|
||||||
WND_Frame result = ZI;
|
WND_Frame result = Zi;
|
||||||
|
|
||||||
while (!Atomic32Fetch(&window->is_ready))
|
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;
|
result.window.v = (u64)window;
|
||||||
|
|
||||||
/* Grab monitor info */
|
/* Grab monitor info */
|
||||||
RECT monitor_rect = ZI;
|
RECT monitor_rect = Zi;
|
||||||
{
|
{
|
||||||
MONITORINFO monitor_info = { .cbSize = sizeof(monitor_info) };
|
MONITORINFO monitor_info = { .cbSize = sizeof(monitor_info) };
|
||||||
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &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);
|
result.monitor_size.y = MaxI32(result.monitor_size.y, 1);
|
||||||
|
|
||||||
/* Client rect */
|
/* Client rect */
|
||||||
RECT client_rect = ZI;
|
RECT client_rect = Zi;
|
||||||
GetClientRect(hwnd, (LPRECT)&client_rect);
|
GetClientRect(hwnd, (LPRECT)&client_rect);
|
||||||
|
|
||||||
/* Screen 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);
|
result.draw_size.y = MaxI32(result.draw_size.y, 1);
|
||||||
|
|
||||||
/* Prepare backbuffer */
|
/* Prepare backbuffer */
|
||||||
Vec2I32 backbuffer_size = ZI;
|
Vec2I32 backbuffer_size = Zi;
|
||||||
if (backbuffer_size_mode == WND_BackbufferSizeMode_MatchWindow)
|
if (backbuffer_size_mode == WND_BackbufferSizeMode_MatchWindow)
|
||||||
{
|
{
|
||||||
backbuffer_size = result.draw_size;
|
backbuffer_size = result.draw_size;
|
||||||
@ -502,7 +502,7 @@ WND_Frame WND_BeginFrame(G_Format backbuffer_format, WND_BackbufferSizeMode back
|
|||||||
|
|
||||||
/* Generate restore data */
|
/* Generate restore data */
|
||||||
{
|
{
|
||||||
WND_W32_RestorableData restore = ZI;
|
WND_W32_RestorableData restore = Zi;
|
||||||
{
|
{
|
||||||
restore.magic = WND_W32_RestoreMagic;
|
restore.magic = WND_W32_RestoreMagic;
|
||||||
restore.placement = placement;
|
restore.placement = placement;
|
||||||
@ -558,14 +558,14 @@ void WND_EndFrame(WND_Frame frame, i32 vsync)
|
|||||||
if (cmd.v != window->is_fullscreen)
|
if (cmd.v != window->is_fullscreen)
|
||||||
{
|
{
|
||||||
DWORD old_style = (DWORD)GetWindowLongPtr(hwnd, GWL_STYLE);
|
DWORD old_style = (DWORD)GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||||
RECT old_rect = ZI;
|
RECT old_rect = Zi;
|
||||||
{
|
{
|
||||||
GetClientRect(hwnd, (LPRECT)&old_rect);
|
GetClientRect(hwnd, (LPRECT)&old_rect);
|
||||||
ClientToScreen(hwnd, (LPPOINT)&old_rect.left);
|
ClientToScreen(hwnd, (LPPOINT)&old_rect.left);
|
||||||
ClientToScreen(hwnd, (LPPOINT)&old_rect.right);
|
ClientToScreen(hwnd, (LPPOINT)&old_rect.right);
|
||||||
AdjustWindowRect(&old_rect, old_style, 0);
|
AdjustWindowRect(&old_rect, old_style, 0);
|
||||||
}
|
}
|
||||||
RECT new_rect = ZI;
|
RECT new_rect = Zi;
|
||||||
HWND new_hwnd = 0;
|
HWND new_hwnd = 0;
|
||||||
DWORD new_style = old_style;
|
DWORD new_style = old_style;
|
||||||
if (cmd.v)
|
if (cmd.v)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user