From 2904c247aa0c379798b8ea5d3ce9a18b1542af25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 23 Nov 2023 11:56:24 +0100 Subject: [PATCH] GL: make Buffer::TargetHint just 16-bit. Which, thanks to a 3-byte padding being now just 1 byte, makes the Buffer class 8 bytes large instead of 12. And in turn, the internal Mesh::AttributeLayout struct is now 40 bytes instead of 48 as there's no longer an extra 4 bytes of padding to satisfy 8-byte alignment of the offset member. Still can go lower than that. --- src/Magnum/GL/Buffer.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Magnum/GL/Buffer.h b/src/Magnum/GL/Buffer.h index c433232c8..4f85d91f4 100644 --- a/src/Magnum/GL/Buffer.h +++ b/src/Magnum/GL/Buffer.h @@ -256,7 +256,11 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject { * @see @ref Buffer(), @ref setTargetHint() * @m_enum_values_as_keywords */ - enum class TargetHint: GLenum { + /* The type is a (32bit) GLenum, but all values fit into 16 bits, I + suppose thanks to backwards compatibility with systems where int is + just 16 bit. Restricting the type size makes the class 8 instead of + 12 bytes. */ + enum class TargetHint: UnsignedShort { /** Used for storing vertex attributes. */ Array = GL_ARRAY_BUFFER,