From 8eab7d7a7d69f72767a59d50bf23e4fc1a914a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 23 Nov 2023 13:19:09 +0100 Subject: [PATCH] GL: pack the Mesh members better. Saves 8 bytes (104 -> 96 bytes), which were before wasted on 4 byte padding before the 8-byte _indexBufferOffset member and 4 bytes after the _indexBuffer, which is new there due to the Buffer being 8 instead of 12 bytes now. On ES2 there's three 32-bit members less, which means this change only moved the 4-byte after _indexBuffer to after _indexType, i.e. 88 bytes before and 88 now as well. --- src/Magnum/GL/Mesh.cpp | 4 ++-- src/Magnum/GL/Mesh.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Magnum/GL/Mesh.cpp b/src/Magnum/GL/Mesh.cpp index ada0c3e2a..ea674111a 100644 --- a/src/Magnum/GL/Mesh.cpp +++ b/src/Magnum/GL/Mesh.cpp @@ -344,7 +344,7 @@ Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), #ifndef MAGNUM_TARGET_GLES2 _indexStart(other._indexStart), _indexEnd(other._indexEnd), #endif - _indexBufferOffset(other._indexBufferOffset), _indexOffset(other._indexOffset), _indexType(other._indexType), _indexBuffer{Utility::move(other._indexBuffer)} + _indexType(other._indexType), _indexBufferOffset(other._indexBufferOffset), _indexOffset(other._indexOffset), _indexBuffer{Utility::move(other._indexBuffer)} { if(_constructed || other._constructed) Context::current().state().mesh.moveConstructImplementation(*this, Utility::move(other)); @@ -368,8 +368,8 @@ Mesh& Mesh::operator=(Mesh&& other) noexcept { swap(_indexEnd, other._indexEnd); #endif swap(_indexBufferOffset, other._indexBufferOffset); - swap(_indexOffset, other._indexOffset); swap(_indexType, other._indexType); + swap(_indexOffset, other._indexOffset); swap(_indexBuffer, other._indexBuffer); if(_constructed || other._constructed) diff --git a/src/Magnum/GL/Mesh.h b/src/Magnum/GL/Mesh.h index 43d897a16..0dc2a884a 100644 --- a/src/Magnum/GL/Mesh.h +++ b/src/Magnum/GL/Mesh.h @@ -1432,8 +1432,9 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject { UnsignedInt _baseInstance{}; UnsignedInt _indexStart{}, _indexEnd{}; #endif - GLintptr _indexBufferOffset{}, _indexOffset{}; MeshIndexType _indexType{}; + /* 4 bytes free on ES2 */ + GLintptr _indexBufferOffset{}, _indexOffset{}; Buffer _indexBuffer{NoCreate}; /* Storage for either std::vector (in case of no VAOs)