From a8499e89eb6bd338f7d9cc062d8936cb4466cb1d Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Sun, 25 Jan 2015 15:38:51 +0000 Subject: [PATCH] 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. --- source/renderer/PatchRData.h | 16 +++++++++++----- source/renderer/WaterManager.cpp | 5 ++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/source/renderer/PatchRData.h b/source/renderer/PatchRData.h index 88075f23de..4908782483 100644 --- a/source/renderer/PatchRData.h +++ b/source/renderer/PatchRData.h @@ -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(); diff --git a/source/renderer/WaterManager.cpp b/source/renderer/WaterManager.cpp index 2e48d34cd7..c0a472087e 100644 --- a/source/renderer/WaterManager.cpp +++ b/source/renderer/WaterManager.cpp @@ -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 {