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));
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));
mTexCoords = (LLVector2*) ll_aligned_malloc_16((numVertices+numVertices%2)*sizeof(LLVector2));
mDetailTexCoords = (LLVector2*) ll_aligned_malloc_16((numVertices+numVertices%2)*sizeof(LLVector2));
mWeights = (F32*) ll_aligned_malloc_16(((numVertices)*sizeof(F32)+0xF) & ~0xF);
for (i = 0; i < numVertices; i++)
{
mBaseCoords[i].clear();

View File

@@ -68,7 +68,16 @@ class LLPolySkeletalDistortionInfo : public LLViewerVisualParamInfo
{
friend class LLPolySkeletalDistortion;
public:
void* operator new(size_t size)
{
return ll_aligned_malloc_16(size);
}
void operator delete(void* ptr)
{
ll_aligned_free_16(ptr);
}
LLPolySkeletalDistortionInfo();
/*virtual*/ ~LLPolySkeletalDistortionInfo() {};
@@ -77,12 +86,12 @@ public:
protected:
typedef std::vector<LLPolySkeletalBoneInfo> bone_info_list_t;
bone_info_list_t mBoneInfoList;
};
} LL_ALIGN_POSTFIX(16);
//-----------------------------------------------------------------------------
// LLPolySkeletalDeformation
// A set of joint scale data for deforming the avatar mesh
//-----------------------------------------------------------------------------
LL_ALIGN_PREFIX(16)
class LLPolySkeletalDistortion : public LLViewerVisualParam
{
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
// rotation matrix.
LL_ALIGN_PREFIX(16)
class LLMatrix3a
{
public:
@@ -113,8 +114,9 @@ protected:
LL_ALIGN_16(LLVector4a mColumns[3]);
};
} LL_ALIGN_POSTFIX(16);
LL_ALIGN_PREFIX(16)
class LLRotation : public LLMatrix3a
{
public:
@@ -123,6 +125,6 @@ public:
// Returns true if this rotation is orthonormal with det ~= 1
inline bool isOkRotation() const;
};
} LL_ALIGN_POSTFIX(16);
#endif

View File

@@ -932,10 +932,10 @@ protected:
MIN = 3
} eDName;
LLVector4a mCenter;
LLVector4a mSize;
LLVector4a mMax;
LLVector4a mMin;
LL_ALIGN_16(LLVector4a mCenter);
LL_ALIGN_16(LLVector4a mSize);
LL_ALIGN_16(LLVector4a mMax);
LL_ALIGN_16(LLVector4a mMin);
oct_node* mParent;
U8 mOctant;
@@ -964,6 +964,26 @@ public:
: 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()
{

View File

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

View File

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

View File

@@ -750,10 +750,10 @@ public:
class PathPt
{
public:
LLMatrix4a mRot;
LLVector4a mPos;
LL_ALIGN_16(LLMatrix4a mRot);
LL_ALIGN_16(LLVector4a mPos);
LLVector4a mScale;
LL_ALIGN_16(LLVector4a mScale);
F32 mTexT;
F32 pad[3]; //for alignment
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_PREFIX(16)
class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle>
{
public:
const LLVolumeFace* mFace;
LLVector4a mStart;
LLVector4a mDir;
LLVector4a mEnd;
LL_ALIGN_16(LLVector4a mStart);
LL_ALIGN_16(LLVector4a mDir);
LL_ALIGN_16(LLVector4a mEnd);
LLVector4a* mIntersection;
LLVector2* mTexCoord;
LLVector4a* mNormal;
@@ -148,7 +149,7 @@ public:
void traverse(const LLOctreeNode<LLVolumeTriangle>* node);
virtual void visit(const LLOctreeNode<LLVolumeTriangle>* node);
};
} LL_ALIGN_POSTFIX(16);
class LLVolumeOctreeValidate : public LLOctreeTraveler<LLVolumeTriangle>
{

View File

@@ -322,6 +322,7 @@ public:
Does not stack.
Caches inverse of projection matrix used in gGLObliqueProjectionInverse
*/
LL_ALIGN_PREFIX(16)
class LLGLUserClipPlane
{
public:
@@ -332,11 +333,12 @@ public:
void setPlane(F32 a, F32 b, F32 c, F32 d);
private:
bool mApply;
LLMatrix4a mProjection;
LLMatrix4a mModelview;
};
LL_ALIGN_16(LLMatrix4a mProjection);
LL_ALIGN_16(LLMatrix4a mModelview);
bool mApply;
} LL_ALIGN_POSTFIX(16);
/*
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);
public: //aligned members
LLVector4a mExtents[2];
LL_ALIGN_16(LLVector4a mExtents[2]);
private:
F32 adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius );

View File

@@ -40,13 +40,24 @@
class LLVOAvatar;
class LLViewerJointMesh;
LL_ALIGN_PREFIX(16)
class LLPreviewAnimation : public LLViewerDynamicTexture
{
public:
virtual ~LLPreviewAnimation();
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 ;
@@ -69,7 +80,7 @@ protected:
LLVector3 mCameraOffset;
LLVector3 mCameraRelPos;
LLPointer<LLVOAvatar> mDummyAvatar;
};
} LL_ALIGN_POSTFIX(16);
class LLFloaterBvhPreview : public LLFloaterNameDesc
{

View File

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

View File

@@ -52,6 +52,16 @@ protected:
public:
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 ;
void setPreviewTarget(LLImageRaw *imagep, F32 distance);
@@ -85,6 +95,16 @@ protected:
public:
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 ;
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);
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 setPreviewTarget(F32 distance);
void setTexture(U32 name) { mTextureName = name; }

View File

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

View File

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

View File

@@ -65,6 +65,16 @@ public:
LLWearable *wearable,
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 ;
BOOL needsRender();
@@ -110,6 +120,17 @@ protected:
/*virtual */ ~LLVisualParamReset(){}
public:
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*/ S8 getType() const ;

View File

@@ -79,6 +79,16 @@ public:
LLViewerTexLayerSetBuffer(LLTexLayerSet* const owner, S32 width, S32 height);
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:
/*virtual*/ S8 getType() const;
BOOL isInitialized(void) const;