textures almost work?

This commit is contained in:
Asuro
2025-02-15 04:13:03 +01:00
parent ab326d3624
commit f93c40f3b6
19 changed files with 643 additions and 456 deletions

View File

@@ -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