From 28c294881d91aa8133dae975778ab86bfdeee720 Mon Sep 17 00:00:00 2001 From: Wouter Wijsman Date: Tue, 3 Dec 2024 09:48:46 +0100 Subject: [PATCH] Align memory to 16 when giving out vram for textures and buffers --- src/gu/vram.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gu/vram.c b/src/gu/vram.c index b8b9af4a..467466e3 100644 --- a/src/gu/vram.c +++ b/src/gu/vram.c @@ -10,6 +10,7 @@ #include static unsigned int staticOffset = 0; +static const unsigned int alignment = 16; static unsigned int getMemorySize(unsigned int width, unsigned int height, unsigned int psm) { @@ -39,6 +40,7 @@ static unsigned int getMemorySize(unsigned int width, unsigned int height, unsig void* guGetStaticVramBuffer(unsigned int width, unsigned int height, unsigned int psm) { unsigned int memSize = getMemorySize(width,height,psm); + staticOffset = (staticOffset + (alignment-1)) &~ (alignment-1); void* result = (void*)staticOffset; staticOffset += memSize;