Explicit enforcement of alignment for all aligned types, including structures with aligned members. (Compiler handholding)

This commit is contained in:
Shyotl
2014-06-22 03:39:33 -05:00
parent 061178ad82
commit 7c073c1db7
18 changed files with 140 additions and 32 deletions

View File

@@ -231,9 +231,9 @@ BOOL LLPolyMeshSharedData::allocateVertexData( U32 numVertices )
mBaseCoords = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a)); mBaseCoords = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
mBaseNormals = (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)); mBaseBinormals = (LLVector4a*) ll_aligned_malloc_16(numVertices*sizeof(LLVector4a));
mTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2)); mTexCoords = (LLVector2*) ll_aligned_malloc_16((numVertices+numVertices%2)*sizeof(LLVector2));
mDetailTexCoords = (LLVector2*) ll_aligned_malloc_16(numVertices*sizeof(LLVector2)); mDetailTexCoords = (LLVector2*) ll_aligned_malloc_16((numVertices+numVertices%2)*sizeof(LLVector2));
mWeights = (F32*) ll_aligned_malloc_16(numVertices*sizeof(F32)); mWeights = (F32*) ll_aligned_malloc_16(((numVertices)*sizeof(F32)+0xF) & ~0xF);
for (i = 0; i < numVertices; i++) for (i = 0; i < numVertices; i++)
{ {
mBaseCoords[i].clear(); mBaseCoords[i].clear();

View File

@@ -68,7 +68,16 @@ class LLPolySkeletalDistortionInfo : public LLViewerVisualParamInfo
{ {
friend class LLPolySkeletalDistortion; friend class LLPolySkeletalDistortion;
public: public:
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
LLPolySkeletalDistortionInfo(); LLPolySkeletalDistortionInfo();
/*virtual*/ ~LLPolySkeletalDistortionInfo() {}; /*virtual*/ ~LLPolySkeletalDistortionInfo() {};
@@ -77,12 +86,12 @@ public:
protected: protected:
typedef std::vector<LLPolySkeletalBoneInfo> bone_info_list_t; typedef std::vector<LLPolySkeletalBoneInfo> bone_info_list_t;
bone_info_list_t mBoneInfoList; bone_info_list_t mBoneInfoList;
}; } LL_ALIGN_POSTFIX(16);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// LLPolySkeletalDeformation // LLPolySkeletalDeformation
// A set of joint scale data for deforming the avatar mesh // A set of joint scale data for deforming the avatar mesh
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
LL_ALIGN_PREFIX(16)
class LLPolySkeletalDistortion : public LLViewerVisualParam class LLPolySkeletalDistortion : public LLViewerVisualParam
{ {
public: public:

View File

@@ -40,6 +40,7 @@
// LLMatrix3a is the base class for LLRotation, which should be used instead any time you're dealing with a // LLMatrix3a is the base class for LLRotation, which should be used instead any time you're dealing with a
// rotation matrix. // rotation matrix.
LL_ALIGN_PREFIX(16)
class LLMatrix3a class LLMatrix3a
{ {
public: public:
@@ -113,8 +114,9 @@ protected:
LL_ALIGN_16(LLVector4a mColumns[3]); LL_ALIGN_16(LLVector4a mColumns[3]);
}; } LL_ALIGN_POSTFIX(16);
LL_ALIGN_PREFIX(16)
class LLRotation : public LLMatrix3a class LLRotation : public LLMatrix3a
{ {
public: public:
@@ -123,6 +125,6 @@ public:
// Returns true if this rotation is orthonormal with det ~= 1 // Returns true if this rotation is orthonormal with det ~= 1
inline bool isOkRotation() const; inline bool isOkRotation() const;
}; } LL_ALIGN_POSTFIX(16);
#endif #endif

View File

@@ -932,10 +932,10 @@ protected:
MIN = 3 MIN = 3
} eDName; } eDName;
LLVector4a mCenter; LL_ALIGN_16(LLVector4a mCenter);
LLVector4a mSize; LL_ALIGN_16(LLVector4a mSize);
LLVector4a mMax; LL_ALIGN_16(LLVector4a mMax);
LLVector4a mMin; LL_ALIGN_16(LLVector4a mMin);
oct_node* mParent; oct_node* mParent;
U8 mOctant; U8 mOctant;
@@ -964,6 +964,26 @@ public:
: BaseType(center, size, parent) : BaseType(center, size, parent)
{ {
} }
#ifdef LL_OCTREE_POOLS
void* operator new(size_t size)
{
return getPool(size).malloc();
}
void operator delete(void* ptr)
{
getPool(sizeof(LLOctreeNode<T>)).free(ptr);
}
#else
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
#endif
bool balance() bool balance()
{ {

View File

@@ -101,7 +101,7 @@ public:
} }
private: private:
LLVector4a mV; LL_ALIGN_16(LLVector4a mV);
} LL_ALIGN_POSTFIX(16); } LL_ALIGN_POSTFIX(16);

View File

@@ -40,6 +40,7 @@
///////////////////////////// /////////////////////////////
#include "llquaternion.h" #include "llquaternion.h"
LL_ALIGN_PREFIX(16)
class LLQuaternion2 class LLQuaternion2
{ {
public: public:
@@ -100,8 +101,8 @@ public:
protected: protected:
LLVector4a mQ; LL_ALIGN_16(LLVector4a mQ);
}; } LL_ALIGN_POSTFIX(16);
#endif #endif

View File

@@ -750,10 +750,10 @@ public:
class PathPt class PathPt
{ {
public: public:
LLMatrix4a mRot; LL_ALIGN_16(LLMatrix4a mRot);
LLVector4a mPos; LL_ALIGN_16(LLVector4a mPos);
LLVector4a mScale; LL_ALIGN_16(LLVector4a mScale);
F32 mTexT; F32 mTexT;
F32 pad[3]; //for alignment F32 pad[3]; //for alignment
PathPt() PathPt()

View File

@@ -127,13 +127,14 @@ public:
LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
}; };
LL_ALIGN_PREFIX(16)
class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle> class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle>
{ {
public: public:
const LLVolumeFace* mFace; const LLVolumeFace* mFace;
LLVector4a mStart; LL_ALIGN_16(LLVector4a mStart);
LLVector4a mDir; LL_ALIGN_16(LLVector4a mDir);
LLVector4a mEnd; LL_ALIGN_16(LLVector4a mEnd);
LLVector4a* mIntersection; LLVector4a* mIntersection;
LLVector2* mTexCoord; LLVector2* mTexCoord;
LLVector4a* mNormal; LLVector4a* mNormal;
@@ -148,7 +149,7 @@ public:
void traverse(const LLOctreeNode<LLVolumeTriangle>* node); void traverse(const LLOctreeNode<LLVolumeTriangle>* node);
virtual void visit(const LLOctreeNode<LLVolumeTriangle>* node); virtual void visit(const LLOctreeNode<LLVolumeTriangle>* node);
}; } LL_ALIGN_POSTFIX(16);
class LLVolumeOctreeValidate : public LLOctreeTraveler<LLVolumeTriangle> class LLVolumeOctreeValidate : public LLOctreeTraveler<LLVolumeTriangle>
{ {

View File

@@ -322,6 +322,7 @@ public:
Does not stack. Does not stack.
Caches inverse of projection matrix used in gGLObliqueProjectionInverse Caches inverse of projection matrix used in gGLObliqueProjectionInverse
*/ */
LL_ALIGN_PREFIX(16)
class LLGLUserClipPlane class LLGLUserClipPlane
{ {
public: public:
@@ -332,11 +333,12 @@ public:
void setPlane(F32 a, F32 b, F32 c, F32 d); void setPlane(F32 a, F32 b, F32 c, F32 d);
private: private:
bool mApply;
LLMatrix4a mProjection; LL_ALIGN_16(LLMatrix4a mProjection);
LLMatrix4a mModelview; LL_ALIGN_16(LLMatrix4a mModelview);
};
bool mApply;
} LL_ALIGN_POSTFIX(16);
/* /*
Modify and load projection matrix to push depth values to far clip plane. Modify and load projection matrix to push depth values to far clip plane.

View File

@@ -239,7 +239,7 @@ public:
static U32 getRiggedDataMask(U32 type); static U32 getRiggedDataMask(U32 type);
public: //aligned members public: //aligned members
LLVector4a mExtents[2]; LL_ALIGN_16(LLVector4a mExtents[2]);
private: private:
F32 adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius ); F32 adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius );

View File

@@ -40,13 +40,24 @@
class LLVOAvatar; class LLVOAvatar;
class LLViewerJointMesh; class LLViewerJointMesh;
LL_ALIGN_PREFIX(16)
class LLPreviewAnimation : public LLViewerDynamicTexture class LLPreviewAnimation : public LLViewerDynamicTexture
{ {
public: public:
virtual ~LLPreviewAnimation(); virtual ~LLPreviewAnimation();
public: public:
LLPreviewAnimation(S32 width, S32 height); LLPreviewAnimation(S32 width, S32 height);
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
/*virtual*/ S8 getType() const ; /*virtual*/ S8 getType() const ;
@@ -69,7 +80,7 @@ protected:
LLVector3 mCameraOffset; LLVector3 mCameraOffset;
LLVector3 mCameraRelPos; LLVector3 mCameraRelPos;
LLPointer<LLVOAvatar> mDummyAvatar; LLPointer<LLVOAvatar> mDummyAvatar;
}; } LL_ALIGN_POSTFIX(16);
class LLFloaterBvhPreview : public LLFloaterNameDesc class LLFloaterBvhPreview : public LLFloaterNameDesc
{ {

View File

@@ -49,7 +49,7 @@ private:
protected: protected:
void draw(); void draw();
LLPreviewAnimation mAnimPreview; LL_ALIGN_16(LLPreviewAnimation mAnimPreview);
LLRect mPreviewRect; LLRect mPreviewRect;
S32 mLastMouseX; S32 mLastMouseX;
S32 mLastMouseY; S32 mLastMouseY;

View File

@@ -52,6 +52,16 @@ protected:
public: public:
LLImagePreviewSculpted(S32 width, S32 height); LLImagePreviewSculpted(S32 width, S32 height);
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
/*virtual*/ S8 getType() const ; /*virtual*/ S8 getType() const ;
void setPreviewTarget(LLImageRaw *imagep, F32 distance); void setPreviewTarget(LLImageRaw *imagep, F32 distance);
@@ -85,6 +95,16 @@ protected:
public: public:
LLImagePreviewAvatar(S32 width, S32 height); LLImagePreviewAvatar(S32 width, S32 height);
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
/*virtual*/ S8 getType() const ; /*virtual*/ S8 getType() const ;
void setPreviewTarget(const std::string& joint_name, const std::string& mesh_name, LLImageRaw* imagep, F32 distance, BOOL male); void setPreviewTarget(const std::string& joint_name, const std::string& mesh_name, LLImageRaw* imagep, F32 distance, BOOL male);

View File

@@ -302,6 +302,16 @@ public:
LLModelPreview(S32 width, S32 height, LLFloater* fmp); LLModelPreview(S32 width, S32 height, LLFloater* fmp);
virtual ~LLModelPreview(); virtual ~LLModelPreview();
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
void resetPreviewTarget(); void resetPreviewTarget();
void setPreviewTarget(F32 distance); void setPreviewTarget(F32 distance);
void setTexture(U32 name) { mTextureName = name; } void setTexture(U32 name) { mTextureName = name; }

View File

@@ -3576,6 +3576,7 @@ void renderLights(LLDrawable* drawablep)
} }
} }
LL_ALIGN_PREFIX(16)
class LLRenderOctreeRaycast : public LLOctreeTriangleRayIntersect class LLRenderOctreeRaycast : public LLOctreeTriangleRayIntersect
{ {
public: public:
@@ -3648,7 +3649,7 @@ public:
} }
} }
} }
}; } LL_ALIGN_POSTFIX(16);
void renderRaycast(LLDrawable* drawablep) void renderRaycast(LLDrawable* drawablep)
{ {

View File

@@ -102,7 +102,7 @@ public:
void validate(); void validate();
LLVector4a mExtents[2]; LL_ALIGN_16(LLVector4a mExtents[2]);
LLPointer<LLVertexBuffer> mVertexBuffer; LLPointer<LLVertexBuffer> mVertexBuffer;
LLPointer<LLViewerTexture> mTexture; LLPointer<LLViewerTexture> mTexture;

View File

@@ -65,6 +65,16 @@ public:
LLWearable *wearable, LLWearable *wearable,
F32 param_weight); F32 param_weight);
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
/*virtual*/ S8 getType() const ; /*virtual*/ S8 getType() const ;
BOOL needsRender(); BOOL needsRender();
@@ -110,6 +120,17 @@ protected:
/*virtual */ ~LLVisualParamReset(){} /*virtual */ ~LLVisualParamReset(){}
public: public:
LLVisualParamReset(); LLVisualParamReset();
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
/*virtual */ BOOL render(); /*virtual */ BOOL render();
/*virtual*/ S8 getType() const ; /*virtual*/ S8 getType() const ;

View File

@@ -79,6 +79,16 @@ public:
LLViewerTexLayerSetBuffer(LLTexLayerSet* const owner, S32 width, S32 height); LLViewerTexLayerSetBuffer(LLTexLayerSet* const owner, S32 width, S32 height);
virtual ~LLViewerTexLayerSetBuffer(); virtual ~LLViewerTexLayerSetBuffer();
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
public: public:
/*virtual*/ S8 getType() const; /*virtual*/ S8 getType() const;
BOOL isInitialized(void) const; BOOL isInitialized(void) const;