textures almost work?
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#include "../engine/Shared.h"
|
||||
#include "Global.h"
|
||||
#include "Instance.h"
|
||||
#include "bx/bx.h"
|
||||
#include "bx/math.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -105,4 +108,15 @@ namespace Game
|
||||
{
|
||||
GameInst = &instance;
|
||||
}
|
||||
|
||||
void* AllocateScratch(size_t byteCount, size_t align = 16)
|
||||
{
|
||||
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;
|
||||
if (newOffset > GetShared().Game.TransientStorageSize) return nullptr;
|
||||
return reinterpret_cast<void*>(ptrAligned);
|
||||
}
|
||||
} // namespace Game
|
||||
|
||||
Reference in New Issue
Block a user