fix asm instruction, make scratch allocator able to work per frame
This commit is contained in:
parent
ff94c5cb5e
commit
8d651ab1fc
30
alloc.d
30
alloc.d
@ -15,8 +15,9 @@ const DEFAULT_ALIGNMENT = (void *).sizeof * 2;
|
|||||||
|
|
||||||
struct Scratch
|
struct Scratch
|
||||||
{
|
{
|
||||||
Arena arena;
|
Arena[] arenas;
|
||||||
bool init;
|
u64 index;
|
||||||
|
bool init;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ArenaPool
|
struct ArenaPool
|
||||||
@ -188,25 +189,34 @@ Free(T)(T* ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ResetScratch(u64 size)
|
ResetScratch(u64 size, u64 count)
|
||||||
{
|
{
|
||||||
if(!g_scratch.init)
|
with(g_scratch)
|
||||||
{
|
{
|
||||||
g_scratch.arena = CreateArena(size);
|
if(!init)
|
||||||
g_scratch.init = true;
|
{
|
||||||
}
|
arenas = AllocArray!(Arena)(count);
|
||||||
|
for(u64 i = 0; i < count; i += 1)
|
||||||
|
{
|
||||||
|
arenas[i] = CreateArena(size);
|
||||||
|
}
|
||||||
|
|
||||||
Reset(&g_scratch.arena);
|
g_scratch.init = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = index % count;
|
||||||
|
Reset(&arenas[index]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
T*
|
T*
|
||||||
ScratchAlloc(T)()
|
ScratchAlloc(T)()
|
||||||
{
|
{
|
||||||
return Alloc!(T)(&g_scratch.arena);
|
return Alloc!(T)(&g_scratch.arenas[g_scratch.index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
T[]
|
T[]
|
||||||
ScratchAlloc(T)(u64 count)
|
ScratchAlloc(T)(u64 count)
|
||||||
{
|
{
|
||||||
return AllocArray!(T)(&g_scratch.arena, count);
|
return AllocArray!(T)(&g_scratch.arenas[g_scratch.index], count);
|
||||||
}
|
}
|
||||||
|
|||||||
2
util.d
2
util.d
@ -836,7 +836,7 @@ MemCpy(void* dst_p, void* src_p, u64 length)
|
|||||||
movdqu XMM3, [R8+48];
|
movdqu XMM3, [R8+48];
|
||||||
|
|
||||||
add R9, i;
|
add R9, i;
|
||||||
movdqu [R9+00], XMM0;
|
movups [R9+00], XMM0;
|
||||||
movups [R9+16], XMM1;
|
movups [R9+16], XMM1;
|
||||||
movups [R9+32], XMM2;
|
movups [R9+32], XMM2;
|
||||||
movups [R9+48], XMM3;
|
movups [R9+48], XMM3;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user