From e4a1b12e7a9c4bb8cbc2a1e41fddb8cec5a1b1e0 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Thu, 15 Dec 2011 12:48:07 -0500
Subject: [PATCH] SH-2789 WIP - build without tcmalloc, force alignment in
 various places

---
 indra/cmake/FindGooglePerfTools.cmake |  2 ++
 indra/cmake/GooglePerfTools.cmake     |  2 +-
 indra/llmath/llcamera.h               | 12 ++++++------
 indra/llmath/llmatrix3a.h             |  2 +-
 indra/llmath/llmatrix4a.h             |  2 +-
 indra/llmath/llplane.h                |  4 +++-
 indra/llmath/llvector4a.h             |  3 ++-
 indra/newview/CMakeLists.txt          |  5 +++--
 indra/newview/lldrawable.h            |  7 ++++---
 indra/newview/llspatialpartition.h    | 12 ++++++------
 indra/newview/llviewercamera.h        |  4 +++-
 indra/newview/llvoavatar.cpp          |  2 +-
 indra/newview/llvoavatar.h            |  2 +-
 13 files changed, 34 insertions(+), 25 deletions(-)
 mode change 100644 => 100755 indra/cmake/FindGooglePerfTools.cmake
 mode change 100644 => 100755 indra/cmake/GooglePerfTools.cmake
 mode change 100644 => 100755 indra/llmath/llcamera.h
 mode change 100644 => 100755 indra/llmath/llmatrix4a.h
 mode change 100644 => 100755 indra/llmath/llplane.h
 mode change 100644 => 100755 indra/llmath/llvector4a.h
 mode change 100644 => 100755 indra/newview/CMakeLists.txt
 mode change 100644 => 100755 indra/newview/lldrawable.h
 mode change 100644 => 100755 indra/newview/llspatialpartition.h
 mode change 100644 => 100755 indra/newview/llviewercamera.h
 mode change 100644 => 100755 indra/newview/llvoavatar.cpp
 mode change 100644 => 100755 indra/newview/llvoavatar.h

diff --git a/indra/cmake/FindGooglePerfTools.cmake b/indra/cmake/FindGooglePerfTools.cmake
old mode 100644
new mode 100755
index bb125d538e0..1c785d34614
--- a/indra/cmake/FindGooglePerfTools.cmake
+++ b/indra/cmake/FindGooglePerfTools.cmake
@@ -64,3 +64,5 @@ MARK_AS_ADVANCED(
   PROFILER_LIBRARY
   GOOGLE_PERFTOOLS_INCLUDE_DIR
   )
+
+SET(GOOGLE_PERFTOOLS_FOUND "NO")
diff --git a/indra/cmake/GooglePerfTools.cmake b/indra/cmake/GooglePerfTools.cmake
old mode 100644
new mode 100755
index d9f91193be1..2e96912769f
--- a/indra/cmake/GooglePerfTools.cmake
+++ b/indra/cmake/GooglePerfTools.cmake
@@ -29,7 +29,7 @@ if (GOOGLE_PERFTOOLS_FOUND)
 endif (GOOGLE_PERFTOOLS_FOUND)
 
 if (WINDOWS)
-    set(USE_GOOGLE_PERFTOOLS ON)
+   set(USE_GOOGLE_PERFTOOLS OFF)
 endif (WINDOWS)
 
 if (USE_GOOGLE_PERFTOOLS)
diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h
old mode 100644
new mode 100755
index ec67b91d05f..0b591be622e
--- a/indra/llmath/llcamera.h
+++ b/indra/llmath/llcamera.h
@@ -60,7 +60,7 @@ static const F32 MAX_FIELD_OF_VIEW = 175.f * DEG_TO_RAD;
 // roll(), pitch(), yaw()
 // etc...
 
-
+LL_ALIGN_PREFIX(16)
 class LLCamera
 : 	public LLCoordFrame
 {
@@ -108,7 +108,7 @@ class LLCamera
 	};
 
 private:
-	LLPlane mAgentPlanes[7];  //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
+	LL_ALIGN_16(LLPlane mAgentPlanes[7]);  //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
 	U8 mPlaneMask[8];         // 8 for alignment	
 	
 	F32 mView;					// angle between top and bottom frustum planes in radians.
@@ -116,13 +116,13 @@ class LLCamera
 	S32 mViewHeightInPixels;	// for ViewHeightInPixels() only
 	F32 mNearPlane;
 	F32 mFarPlane;
-	LLPlane mLocalPlanes[4];
+	LL_ALIGN_16(LLPlane mLocalPlanes[4]);
 	F32 mFixedDistance;			// Always return this distance, unless < 0
 	LLVector3 mFrustCenter;		// center of frustum and radius squared for ultra-quick exclusion test
 	F32 mFrustRadiusSquared;
 	
-	LLPlane mWorldPlanes[PLANE_NUM];
-	LLPlane mHorizPlanes[HORIZ_PLANE_NUM];
+	LL_ALIGN_16(LLPlane mWorldPlanes[PLANE_NUM]);
+	LL_ALIGN_16(LLPlane mHorizPlanes[HORIZ_PLANE_NUM]);
 
 	U32 mPlaneCount;  //defaults to 6, if setUserClipPlane is called, uses user supplied clip plane in
 
@@ -208,7 +208,7 @@ class LLCamera
 	void calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom);
 	void calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2);
 	void calculateWorldFrustumPlanes();
-};
+} LL_ALIGN_POSTFIX(16);
 
 
 #endif
diff --git a/indra/llmath/llmatrix3a.h b/indra/llmath/llmatrix3a.h
index adb7e3389d5..9916cfd2dab 100644
--- a/indra/llmath/llmatrix3a.h
+++ b/indra/llmath/llmatrix3a.h
@@ -111,7 +111,7 @@ class LLMatrix3a
 
 protected:
 
-	LLVector4a mColumns[3];
+	LL_ALIGN_16(LLVector4a mColumns[3]);
 
 };
 
diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h
old mode 100644
new mode 100755
index 27cf5b79f64..c4cefdb4fa7
--- a/indra/llmath/llmatrix4a.h
+++ b/indra/llmath/llmatrix4a.h
@@ -34,7 +34,7 @@
 class LLMatrix4a
 {
 public:
-	LLVector4a mMatrix[4];
+	LL_ALIGN_16(LLVector4a mMatrix[4]);
 
 	inline void clear()
 	{
diff --git a/indra/llmath/llplane.h b/indra/llmath/llplane.h
old mode 100644
new mode 100755
index a611894721c..3c32441b118
--- a/indra/llmath/llplane.h
+++ b/indra/llmath/llplane.h
@@ -36,6 +36,8 @@
 // The plane normal = [A, B, C]
 // The closest approach = D / sqrt(A*A + B*B + C*C)
 
+
+LL_ALIGN_PREFIX(16)
 class LLPlane
 {
 public:
@@ -94,7 +96,7 @@ class LLPlane
 		
 private:
 	LLVector4a mV;
-};
+} LL_ALIGN_POSTFIX(16);
 
 
 
diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h
old mode 100644
new mode 100755
index eada6ed1b76..9de0e667742
--- a/indra/llmath/llvector4a.h
+++ b/indra/llmath/llvector4a.h
@@ -47,6 +47,7 @@ class LLRotation;
 // LLVector3/LLVector4. 
 /////////////////////////////////
 
+LL_ALIGN_PREFIX(16)
 class LLVector4a
 {
 public:
@@ -315,7 +316,7 @@ class LLVector4a
 
 private:
 	LLQuad mQ;
-};
+} LL_ALIGN_POSTFIX(16);
 
 inline void update_min_max(LLVector4a& min, LLVector4a& max, const LLVector4a& p)
 {
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
old mode 100644
new mode 100755
index 6b2fe1e45ae..825cbbef8fb
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1509,7 +1509,8 @@ if (WINDOWS)
         PROPERTIES
         # *TODO -reenable this once we get server usage sorted out
         #LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS /INCLUDE:\"__tcmalloc\""
-        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS /INCLUDE:__tcmalloc"
+#        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS /INCLUDE:__tcmalloc"
+        LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS"
         LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\" /INCREMENTAL:NO"
         LINK_FLAGS_RELEASE ""
         )
@@ -1764,7 +1765,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
     ${CRYPTO_LIBRARIES}
     ${LLLOGIN_LIBRARIES}
     ${LLCONVEXDECOMP_LIBRARY}
-    ${TCMALLOC_LIBRARIES}
+#    ${TCMALLOC_LIBRARIES}
     )
 
 if (USE_KDU)
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
old mode 100644
new mode 100755
index e268640a21c..244b87b2e71
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -59,6 +59,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:
@@ -280,8 +281,8 @@ class LLDrawable : public LLRefCount
 	} EDrawableFlags;
 
 private: //aligned members
-	LLVector4a		mExtents[2];
-	LLVector4a		mPositionGroup;
+	LL_ALIGN_16(LLVector4a		mExtents[2]);
+	LL_ALIGN_16(LLVector4a		mPositionGroup);
 	
 public:
 	LLXformMatrix       mXform;
@@ -322,7 +323,7 @@ class LLDrawable : public LLRefCount
 
 	static U32 sNumZombieDrawables;
 	static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList;
-};
+} LL_ALIGN_POSTFIX(16);
 
 
 inline LLFace* LLDrawable::getFace(const S32 i) const
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
old mode 100644
new mode 100755
index f0c8a372ee3..cbd4507f842
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -372,12 +372,12 @@ class LLSpatialGroup : public LLOctreeListener<LLDrawable>
 		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);
 		
 private:
 	U32                     mCurUpdatingTime ;
diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h
old mode 100644
new mode 100755
index cc3395115ba..7257297cfde
--- a/indra/newview/llviewercamera.h
+++ b/indra/newview/llviewercamera.h
@@ -51,6 +51,7 @@ const BOOL NOT_FOR_SELECTION = FALSE;
 extern template class LLViewerCamera* LLSingleton<class LLViewerCamera>::getInstance();
 #endif
 
+LL_ALIGN_PREFIX(16)
 class LLViewerCamera : public LLCamera, public LLSingleton<LLViewerCamera>
 {
 public:
@@ -137,6 +138,7 @@ class LLViewerCamera : public LLCamera, public LLSingleton<LLViewerCamera>
 	S16					mZoomSubregion;
 
 public:
-};
+} LL_ALIGN_POSTFIX(16);
+
 
 #endif // LL_LLVIEWERCAMERA_H
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
old mode 100644
new mode 100755
index 4767ba2bedf..ad5ea15bbbb
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2595,7 +2595,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 
 	if (isImpostor() && !mNeedsImpostorUpdate)
 	{
-		LLVector4a ext[2];
+		LL_ALIGN_16(LLVector4a ext[2]);
 		F32 distance;
 		LLVector3 angle;
 
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
old mode 100644
new mode 100755
index 59796370ae6..82157436b9f
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -212,7 +212,7 @@ class LLVOAvatar :
 	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
-- 
GitLab