From b3b90796dc0f2ee2f7c479bf302b53d8f350aa7a Mon Sep 17 00:00:00 2001 From: Learath2 Date: Tue, 13 Oct 2020 17:30:30 +0200 Subject: [PATCH] Don't waste bytes when we are already aligned --- src/engine/client/graphics_threaded.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index b9315c27c..66a0b2c73 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -41,7 +41,10 @@ class CCommandBuffer void *Alloc(unsigned Requested, unsigned Alignment = alignof(std::max_align_t)) { - size_t Offset = Alignment - (reinterpret_cast(m_pData + m_Used) % Alignment); + size_t Offset = reinterpret_cast(m_pData + m_Used) % Alignment; + if(Offset) + Offset = Alignment - Offset; + if(Requested + Offset + m_Used > m_Size) return 0;