Dragged in a bunch of alignment fixes from LL. Should allow disabling of tcmalloc on windows/linux32 if such is ever implemented.

This commit is contained in:
Shyotl
2012-10-16 02:33:05 -05:00
parent e8ec81bf04
commit 1b89e5c973
32 changed files with 381 additions and 136 deletions

View File

@@ -65,6 +65,7 @@ class LLViewerTexture;
const U32 SILHOUETTE_HIGHLIGHT = 0;
// All data for new renderer goes into this class.
LL_ALIGN_PREFIX(16)
class LLDrawable : public LLRefCount
{
public:
@@ -81,6 +82,16 @@ public:
static void initClass();
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
LLDrawable() { init(); }
MEM_TYPE_NEW(LLMemType::MTYPE_DRAWABLE);
@@ -290,8 +301,8 @@ public:
} EDrawableFlags;
private: //aligned members
LLVector4a mExtents[2];
LLVector4a mPositionGroup;
LL_ALIGN_16(LLVector4a mExtents[2]);
LL_ALIGN_16(LLVector4a mPositionGroup);
public:
LLXformMatrix mXform;
@@ -333,7 +344,7 @@ private:
static U32 sNumZombieDrawables;
static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList;
};
} LL_ALIGN_POSTFIX(16);
inline LLFace* LLDrawable::getFace(const S32 i) const

View File

@@ -83,6 +83,16 @@ public:
LLDriverParam(LLWearable *wearablep);
~LLDriverParam();
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
// Special: These functions are overridden by child classes
LLDriverParamInfo* getInfo() const { return (LLDriverParamInfo*)mInfo; }
// This sets mInfo and calls initialization functions

View File

@@ -36,6 +36,16 @@
class LLViewerDynamicTexture : public LLViewerTexture
{
public:
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
enum
{
LL_VIEWER_DYNAMIC_TEXTURE = LLViewerTexture::DYNAMIC_TEXTURE,
@@ -85,7 +95,7 @@ protected:
protected:
BOOL mClamp;
LLCoordGL mOrigin;
LLCamera mCamera;
LL_ALIGN_16(LLCamera mCamera);
typedef std::set<LLViewerDynamicTexture*> instance_list_t;
static instance_list_t sInstances[ LLViewerDynamicTexture::ORDER_COUNT ];

View File

@@ -64,6 +64,17 @@ class LLFace
{
public:
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
LLFace(const LLFace& rhs)
{
*this = rhs;

View File

@@ -125,28 +125,28 @@ void LLPolyMeshSharedData::setupLOD(LLPolyMeshSharedData* reference_data)
//-----------------------------------------------------------------------------
void LLPolyMeshSharedData::freeMeshData()
{
if (!mReferenceData)
{
mNumVertices = 0;
if (!mReferenceData)
{
mNumVertices = 0;
delete [] mBaseCoords;
mBaseCoords = NULL;
ll_aligned_free_16(mBaseCoords);
mBaseCoords = NULL;
delete [] mBaseNormals;
mBaseNormals = NULL;
ll_aligned_free_16(mBaseNormals);
mBaseNormals = NULL;
delete [] mBaseBinormals;
mBaseBinormals = NULL;
ll_aligned_free_16(mBaseBinormals);
mBaseBinormals = NULL;
delete [] mTexCoords;
mTexCoords = NULL;
ll_aligned_free_16(mTexCoords);
mTexCoords = NULL;
delete [] mDetailTexCoords;
mDetailTexCoords = NULL;
ll_aligned_free_16(mDetailTexCoords);
mDetailTexCoords = NULL;
delete [] mWeights;
mWeights = NULL;
}
ll_aligned_free_16(mWeights);
mWeights = NULL;
}
mNumFaces = 0;
delete [] mFaces;
@@ -228,14 +228,14 @@ U32 LLPolyMeshSharedData::getNumKB()
//-----------------------------------------------------------------------------
BOOL LLPolyMeshSharedData::allocateVertexData( U32 numVertices )
{
U32 i;
mBaseCoords = new LLVector4a[ numVertices ];
mBaseNormals = new LLVector4a[ numVertices ];
mBaseBinormals = new LLVector4a[ numVertices ];
mTexCoords = new LLVector2[ numVertices ];
mDetailTexCoords = new LLVector2[ numVertices ];
mWeights = new F32[ numVertices ];
for (i = 0; i < numVertices; i++)
U32 i;
mBaseCoords = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
mBaseNormals = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
mBaseBinormals = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
mTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
mDetailTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2));
mWeights = (F32*) ll_aligned_malloc_16(numVertices*sizeof(F32));
for (i = 0; i < numVertices; i++)
{
mBaseCoords[i].clear();
mBaseNormals[i].clear();

View File

@@ -428,6 +428,16 @@ public:
LLPolySkeletalDistortion(LLVOAvatar *avatarp);
~LLPolySkeletalDistortion();
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
// Special: These functions are overridden by child classes
LLPolySkeletalDistortionInfo* getInfo() const { return (LLPolySkeletalDistortionInfo*)mInfo; }
// This sets mInfo and calls initialization functions

View File

@@ -74,9 +74,9 @@ LLPolyMorphData::LLPolyMorphData(const LLPolyMorphData &rhs) :
{
const S32 numVertices = mNumIndices;
mCoords = new LLVector4a[numVertices];
mNormals = new LLVector4a[numVertices];
mBinormals = new LLVector4a[numVertices];
mCoords = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
mNormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
mBinormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
mTexCoords = new LLVector2[numVertices];
mVertexIndices = new U32[numVertices];
@@ -90,17 +90,12 @@ LLPolyMorphData::LLPolyMorphData(const LLPolyMorphData &rhs) :
}
}
//-----------------------------------------------------------------------------
// ~LLPolyMorphData()
//-----------------------------------------------------------------------------
LLPolyMorphData::~LLPolyMorphData()
{
delete [] mVertexIndices;
delete [] mCoords;
delete [] mNormals;
delete [] mBinormals;
delete [] mTexCoords;
freeData();
}
//-----------------------------------------------------------------------------
@@ -119,12 +114,17 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
return FALSE;
}
//-------------------------------------------------------------------------
// free any existing data
//-------------------------------------------------------------------------
freeData();
//-------------------------------------------------------------------------
// allocate vertices
//-------------------------------------------------------------------------
mCoords = new LLVector4a[numVertices];
mNormals = new LLVector4a[numVertices];
mBinormals = new LLVector4a[numVertices];
mCoords = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
mNormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
mBinormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
mTexCoords = new LLVector2[numVertices];
// Actually, we are allocating more space than we need for the skiplist
mVertexIndices = new U32[numVertices];
@@ -207,6 +207,42 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh)
return TRUE;
}
//-----------------------------------------------------------------------------
// freeData()
//-----------------------------------------------------------------------------
void LLPolyMorphData::freeData()
{
if (mCoords != NULL)
{
ll_aligned_free_16(mCoords);
mCoords = NULL;
}
if (mNormals != NULL)
{
ll_aligned_free_16(mNormals);
mNormals = NULL;
}
if (mBinormals != NULL)
{
ll_aligned_free_16(mBinormals);
mBinormals = NULL;
}
if (mTexCoords != NULL)
{
delete [] mTexCoords;
mTexCoords = NULL;
}
if (mVertexIndices != NULL)
{
delete [] mVertexIndices;
mVertexIndices = NULL;
}
}
//-----------------------------------------------------------------------------
// LLPolyMesh::saveLLM()
//-----------------------------------------------------------------------------
@@ -354,9 +390,9 @@ BOOL LLPolyMorphData::setMorphFromMesh(LLPolyMesh *morph)
if (num_significant == 0)
nindices = 1;
LLVector4a* new_coords = new LLVector4a[nindices];
LLVector4a* new_normals = new LLVector4a[nindices];
LLVector4a* new_binormals = new LLVector4a[nindices];
LLVector4a* new_coords = static_cast<LLVector4a*>(ll_aligned_malloc_16(nindices * sizeof(LLVector4a)));
LLVector4a* new_normals = static_cast<LLVector4a*>(ll_aligned_malloc_16(nindices * sizeof(LLVector4a)));
LLVector4a* new_binormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(nindices * sizeof(LLVector4a)));
LLVector2* new_tex_coords = new LLVector2[nindices];
U32* new_vertex_indices = new U32[nindices];
@@ -490,11 +526,7 @@ BOOL LLPolyMorphData::setMorphFromMesh(LLPolyMesh *morph)
//-------------------------------------------------------------------------
// reallocate vertices
//-------------------------------------------------------------------------
delete [] mVertexIndices;
delete [] mCoords;
delete [] mNormals;
delete [] mBinormals;
delete [] mTexCoords;
freeData();
mVertexIndices = new_vertex_indices;
mCoords = new_coords;

View File

@@ -54,6 +54,16 @@ public:
~LLPolyMorphData();
LLPolyMorphData(const LLPolyMorphData &rhs);
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
BOOL loadBinary(LLFILE* fp, LLPolyMeshSharedData *mesh);
const std::string& getName() { return mName; }
@@ -77,6 +87,9 @@ public:
F32 mMaxDistortion; // maximum single vertex distortion in a given morph
LLVector4a mAvgDistortion; // average vertex distortion, to infer directionality of the morph
LLPolyMeshSharedData* mMesh;
private:
void freeData();
};
//-----------------------------------------------------------------------------

View File

@@ -412,6 +412,7 @@ void LLSpatialGroup::setVisible()
void LLSpatialGroup::validate()
{
ll_assert_aligned(this,64);
#if LL_OCTREE_PARANOIA_CHECK
sg_assert(!isState(DIRTY));
@@ -1075,6 +1076,8 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
mLastUpdateDistance(-1.f),
mLastUpdateTime(gFrameTimeSeconds)
{
ll_assert_aligned(this,16);
sNodeCount++;
LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);

View File

@@ -73,6 +73,16 @@ protected:
~LLDrawInfo();
public:
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
LLDrawInfo(const LLDrawInfo& rhs)
{
@@ -111,7 +121,7 @@ public:
F32 mPartSize;
F32 mVSize;
LLSpatialGroup* mGroup;
LLFace* mFace; //associated face
LL_ALIGN_16(LLFace* mFace); //associated face
F32 mDistance;
U32 mDrawMode;
@@ -186,7 +196,7 @@ public:
};
};
LL_ALIGN_PREFIX(64)
LL_ALIGN_PREFIX(16)
class LLSpatialGroup : public LLOctreeListener<LLDrawable>
{
friend class LLSpatialPartition;
@@ -198,6 +208,16 @@ public:
*this = rhs;
}
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
const LLSpatialGroup& operator=(const LLSpatialGroup& rhs)
{
llerrs << "Illegal operation!" << llendl;
@@ -359,12 +379,12 @@ public:
V4_COUNT = 10
} eV4Index;
LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
LLVector4a mExtents[2]; // extents (min, max) of this node and all its children
LLVector4a mObjectExtents[2]; // extents (min, max) of objects in this node
LLVector4a mObjectBounds[2]; // bounding box (center, size) of objects in this node
LLVector4a mViewAngle;
LLVector4a mLastUpdateViewAngle;
LL_ALIGN_16(LLVector4a mBounds[2]); // bounding box (center, size) of this node and all its children (tight fit to objects)
LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node
LL_ALIGN_16(LLVector4a mObjectBounds[2]); // bounding box (center, size) of objects in this node
LL_ALIGN_16(LLVector4a mViewAngle);
LL_ALIGN_16(LLVector4a mLastUpdateViewAngle);
F32 mObjectBoxSize; //cached mObjectBounds[1].getLength3()

View File

@@ -67,6 +67,16 @@ public:
/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable = NULL) const;
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
// LLVisualParam Virtual functions
///*virtual*/ BOOL parseData(LLXmlTreeNode* node);
/*virtual*/ void apply( ESex avatar_sex ) {}
@@ -143,6 +153,16 @@ public:
LLTexLayerParamColor( LLVOAvatar* avatar );
/* virtual */ ~LLTexLayerParamColor();
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable = NULL) const;
// LLVisualParam Virtual functions

View File

@@ -52,9 +52,20 @@ const F32 OGL_TO_CFR_ROTATION[16] = { 0.f, 0.f, -1.f, 0.f, // -Z becomes X
const BOOL FOR_SELECTION = TRUE;
const BOOL NOT_FOR_SELECTION = FALSE;
LL_ALIGN_PREFIX(16)
class LLViewerCamera : public LLCamera, public LLSingleton<LLViewerCamera>
{
public:
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
typedef enum
{
@@ -138,6 +149,7 @@ protected:
S16 mZoomSubregion;
public:
};
} LL_ALIGN_POSTFIX(16);
#endif // LL_LLVIEWERCAMERA_H

View File

@@ -3139,7 +3139,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
if (isImpostor() && !mNeedsImpostorUpdate)
{
LLVector4a ext[2];
LL_ALIGN_16(LLVector4a ext[2]);
F32 distance;
LLVector3 angle;

View File

@@ -140,6 +140,16 @@ protected:
**/
public:
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
LLVOAvatar(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
virtual void markDead();
static void initClass(); // Initialize data that's only init'd once per class.
@@ -261,7 +271,7 @@ public:
bool isBuilt() const { return mIsBuilt; }
private: //aligned members
LLVector4a mImpostorExtents[2];
LL_ALIGN_16(LLVector4a mImpostorExtents[2]);
private:
BOOL mSupportsAlphaLayers; // For backwards compatibility, TRUE for 1.23+ clients

View File

@@ -49,6 +49,16 @@ class LLVOAvatarSelf :
**/
public:
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
LLVOAvatarSelf(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
virtual ~LLVOAvatarSelf();
virtual void markDead();