Browse Source

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.
pull/168/head
Vladimír Vondruš 2 years ago
parent
commit
8eab7d7a7d
  1. 4
      src/Magnum/GL/Mesh.cpp
  2. 3
      src/Magnum/GL/Mesh.h

4
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)

3
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<AttributeLayout> (in case of no VAOs)

Loading…
Cancel
Save