1
0
forked from 0ad/0ad

Pad vertex data to power-of-two sizes.

This reduces the total number of different vertex sizes in the system,
allowing more data to share a single CVertexBuffer, therefore reducing
the amount of wasted space in each CVertexBuffer and reducing VRAM
usage.

This was SVN commit r16230.
This commit is contained in:
Ykkrosh 2015-01-25 15:38:51 +00:00
parent 0423f6cc29
commit a8499e89eb
2 changed files with 15 additions and 6 deletions

View File

@ -80,14 +80,16 @@ private:
// diffuse color from sunlight
SColor4ub m_DiffuseColor;
CVector3D m_Normal;
// pad to a power of two
u8 m_Padding[4];
};
cassert(sizeof(SBaseVertex) == 28);
cassert(sizeof(SBaseVertex) == 32);
struct SSideVertex {
// vertex position
CVector3D m_Position;
// add some padding
u32 m_Padding[1];
// pad to a power of two
u8 m_Padding[4];
};
cassert(sizeof(SSideVertex) == 16);
@ -99,16 +101,20 @@ private:
// vertex uvs for alpha texture
float m_AlphaUVs[2];
CVector3D m_Normal;
// pad to a power of two
u8 m_Padding[28];
};
cassert(sizeof(SBlendVertex) == 36);
cassert(sizeof(SBlendVertex) == 64);
// Mixed Fancy/Simple water vertex description data structure
struct SWaterVertex {
// vertex position
CVector3D m_Position;
CVector2D m_WaterData;
// pad to a power of two
u8 m_Padding[12];
};
cassert(sizeof(SWaterVertex) == 20);
cassert(sizeof(SWaterVertex) == 32);
// build this renderdata object
void Build();

View File

@ -65,8 +65,11 @@ struct SWavesVertex {
CVector2D m_PerpVect;
u8 m_UV[3];
// pad to a power of two
u8 m_Padding[5];
};
cassert(sizeof(SWavesVertex) == 60);
cassert(sizeof(SWavesVertex) == 64);
struct WaveObject
{