fixed texture loading
This commit is contained in:
@@ -109,14 +109,16 @@ namespace Game
|
||||
GameInst = &instance;
|
||||
}
|
||||
|
||||
void* AllocateScratch(size_t byteCount, size_t align = 16)
|
||||
void* AllocateScratch(size_t byteCount, size_t align)
|
||||
{
|
||||
size_t offset = GetInstance().UsedScratchAmount;
|
||||
uint8_t* base = static_cast<uint8_t*>(GetShared().Game.TransientStorage);
|
||||
uint8_t* current = base + offset;
|
||||
uintptr_t ptrAligned = ((reinterpret_cast<uintptr_t>(current) + align - 1) / align) * align;
|
||||
uintptr_t newOffset = ptrAligned - reinterpret_cast<uintptr_t>(base) + byteCount;
|
||||
size_t offsetAligned = ((offset + align - 1) / align) * align;
|
||||
uint8_t* ptrAligned = base + offsetAligned;
|
||||
size_t newOffset = offsetAligned + byteCount;
|
||||
if (newOffset > GetShared().Game.TransientStorageSize) return nullptr;
|
||||
GetInstance().UsedScratchAmount = newOffset;
|
||||
return reinterpret_cast<void*>(ptrAligned);
|
||||
}
|
||||
} // namespace Game
|
||||
|
||||
Reference in New Issue
Block a user