diff options
| author | Rye <rye@alchemyviewer.org> | 2025-10-27 02:55:56 -0400 |
|---|---|---|
| committer | Rye <rye@alchemyviewer.org> | 2025-10-27 04:59:16 -0400 |
| commit | e803bbc0db695abe73de9797510ba22646528e23 (patch) | |
| tree | a3aa818fa4768b40df9223fb5922aa27ac2a21a7 | |
| parent | b1a96885492b65fe0636bf1184f5a8fbfe7b3930 (diff) | |
Modernize viewer alignment macros to use alignas and fix misaligned class issues reported by ubsan/asan
Signed-off-by: Rye <rye@alchemyviewer.org>
41 files changed, 114 insertions, 143 deletions
diff --git a/indra/llappearance/llavatarjoint.h b/indra/llappearance/llavatarjoint.h index 13f025fd5f..71fe4b61b6 100644 --- a/indra/llappearance/llavatarjoint.h +++ b/indra/llappearance/llavatarjoint.h @@ -41,9 +41,10 @@ extern const F32 DEFAULT_AVATAR_JOINT_LOD; //----------------------------------------------------------------------------- // class LLViewerJoint //----------------------------------------------------------------------------- -class LLAvatarJoint : +class alignas(16) LLAvatarJoint : public LLJoint { + LL_ALIGN_NEW public: LLAvatarJoint(); LLAvatarJoint(S32 joint_num); @@ -121,8 +122,9 @@ protected: S32 mMeshID; }; -class LLAvatarJointCollisionVolume : public LLAvatarJoint +class alignas(16) LLAvatarJointCollisionVolume : public LLAvatarJoint { + LL_ALIGN_NEW public: LLAvatarJointCollisionVolume(); virtual ~LLAvatarJointCollisionVolume() {}; diff --git a/indra/llappearance/llavatarjointmesh.h b/indra/llappearance/llavatarjointmesh.h index 33f50fce00..153a2b88fe 100644 --- a/indra/llappearance/llavatarjointmesh.h +++ b/indra/llappearance/llavatarjointmesh.h @@ -59,8 +59,9 @@ public: //----------------------------------------------------------------------------- // class LLViewerJointMesh //----------------------------------------------------------------------------- -class LLAvatarJointMesh : public virtual LLAvatarJoint +class alignas(16) LLAvatarJointMesh : public virtual LLAvatarJoint { + LL_ALIGN_NEW protected: LLColor4 mColor; // color value // LLColor4 mSpecular; // specular color (always white for now) diff --git a/indra/llappearance/lldriverparam.h b/indra/llappearance/lldriverparam.h index 59092988dd..df8733dde7 100644 --- a/indra/llappearance/lldriverparam.h +++ b/indra/llappearance/lldriverparam.h @@ -128,7 +128,7 @@ protected: void setDrivenWeight(LLDrivenEntry* driven, F32 driven_weight); - LL_ALIGN_16(LLVector4a mDefaultVec); // temp holder + LLVector4a mDefaultVec; // temp holder entry_list_t mDriven; LLViewerVisualParam* mCurrentDistortionParam{ nullptr }; // Backlink only; don't make this an LLPointer. diff --git a/indra/llappearance/llpolymorph.h b/indra/llappearance/llpolymorph.h index 8c76689f2c..64434bd5d9 100644 --- a/indra/llappearance/llpolymorph.h +++ b/indra/llappearance/llpolymorph.h @@ -71,7 +71,7 @@ public: private: void freeData(); -} LL_ALIGN_POSTFIX(16); +}; //----------------------------------------------------------------------------- diff --git a/indra/llappearance/llpolyskeletaldistortion.h b/indra/llappearance/llpolyskeletaldistortion.h index 9ba4cf66e9..37f35d50ba 100644 --- a/indra/llappearance/llpolyskeletaldistortion.h +++ b/indra/llappearance/llpolyskeletaldistortion.h @@ -111,13 +111,13 @@ public: protected: LLPolySkeletalDistortion(const LLPolySkeletalDistortion& pOther); - LL_ALIGN_16(LLVector4a mDefaultVec); + LLVector4a mDefaultVec; typedef std::map<LLJoint*, LLVector3> joint_vec_map_t; joint_vec_map_t mJointScales; joint_vec_map_t mJointOffsets; // Backlink only; don't make this an LLPointer. LLAvatarAppearance *mAvatar; -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLPOLYSKELETALDISTORTION_H diff --git a/indra/llappearance/lltexlayerparams.h b/indra/llappearance/lltexlayerparams.h index 116eb3bee0..2c243d0e9b 100644 --- a/indra/llappearance/lltexlayerparams.h +++ b/indra/llappearance/lltexlayerparams.h @@ -63,7 +63,6 @@ protected: // LLTexLayerParamAlpha // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -LL_ALIGN_PREFIX(16) class alignas(16) LLTexLayerParamAlpha : public LLTexLayerParam { LL_ALIGN_NEW @@ -103,7 +102,7 @@ private: LLPointer<LLImageRaw> mStaticImageRaw; std::atomic<bool> mNeedsCreateTexture; bool mStaticImageInvalid; - LL_ALIGN_16(LLVector4a mAvgDistortionVec); + LLVector4a mAvgDistortionVec; F32 mCachedEffectiveWeight; public: @@ -113,7 +112,7 @@ public: typedef std::list< LLTexLayerParamAlpha* > param_alpha_ptr_list_t; static param_alpha_ptr_list_t sInstances; -} LL_ALIGN_POSTFIX(16); +}; class LLTexLayerParamAlphaInfo : public LLViewerVisualParamInfo { friend class LLTexLayerParamAlpha; diff --git a/indra/llappearance/llviewervisualparam.h b/indra/llappearance/llviewervisualparam.h index b79983df8e..37771cc8d3 100644 --- a/indra/llappearance/llviewervisualparam.h +++ b/indra/llappearance/llviewervisualparam.h @@ -65,8 +65,7 @@ protected: // VIRTUAL CLASS // a viewer side interface class for a generalized parametric modification of the avatar mesh //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLViewerVisualParam : public LLVisualParam +class alignas(16) LLViewerVisualParam : public LLVisualParam { public: LLViewerVisualParam(); @@ -107,6 +106,6 @@ public: protected: LLViewerVisualParam(const LLViewerVisualParam& pOther); -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLViewerVisualParam_H diff --git a/indra/llappearanceutility/llbakingavatar.h b/indra/llappearanceutility/llbakingavatar.h index 8261dfc814..b4cf99cbfb 100644 --- a/indra/llappearanceutility/llbakingavatar.h +++ b/indra/llappearanceutility/llbakingavatar.h @@ -38,15 +38,7 @@ class LLBakingAvatar : public LLAvatarAppearance ** INITIALIZATION **/ public: - void* operator new(size_t size) - { - return ll_aligned_malloc_16(size); - } - - void operator delete(void* ptr) - { - ll_aligned_free_16(ptr); - } + LL_ALIGN_NEW LLBakingAvatar(LLWearableData* wearable_data, S32 bakeTextureSize = 512); virtual ~LLBakingAvatar(); diff --git a/indra/llappearanceutility/llbakingjoint.h b/indra/llappearanceutility/llbakingjoint.h index 07e15a1d04..10201cc7b8 100644 --- a/indra/llappearanceutility/llbakingjoint.h +++ b/indra/llappearanceutility/llbakingjoint.h @@ -29,8 +29,9 @@ #include "llavatarjoint.h" -class LLBakingJoint : public virtual LLAvatarJoint +class alignas(16) LLBakingJoint : public virtual LLAvatarJoint { + LL_ALIGN_NEW public: LLBakingJoint(); LLBakingJoint(S32 joint_num); diff --git a/indra/llappearanceutility/llbakingjointmesh.h b/indra/llappearanceutility/llbakingjointmesh.h index a66bf3f61b..9c7b276bd8 100644 --- a/indra/llappearanceutility/llbakingjointmesh.h +++ b/indra/llappearanceutility/llbakingjointmesh.h @@ -30,8 +30,9 @@ #include "llavatarjointmesh.h" #include "llbakingjoint.h" -class LLBakingJointMesh : public LLAvatarJointMesh, public LLBakingJoint +class alignas(16) LLBakingJointMesh : public LLAvatarJointMesh, public LLBakingJoint { + LL_ALIGN_NEW public: LLBakingJointMesh(); LLBakingJointMesh(S32 joint_num); diff --git a/indra/llcharacter/lleditingmotion.h b/indra/llcharacter/lleditingmotion.h index f94756d43d..a3c0ee94b7 100644 --- a/indra/llcharacter/lleditingmotion.h +++ b/indra/llcharacter/lleditingmotion.h @@ -42,8 +42,7 @@ //----------------------------------------------------------------------------- // class LLEditingMotion //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLEditingMotion : +class alignas(16) LLEditingMotion : public LLMotion { LL_ALIGN_NEW @@ -110,11 +109,11 @@ public: //------------------------------------------------------------------------- // joint states to be animated //------------------------------------------------------------------------- - LL_ALIGN_16(LLJoint mParentJoint); - LL_ALIGN_16(LLJoint mShoulderJoint); - LL_ALIGN_16(LLJoint mElbowJoint); - LL_ALIGN_16(LLJoint mWristJoint); - LL_ALIGN_16(LLJoint mTarget); + LLJoint mParentJoint; + LLJoint mShoulderJoint; + LLJoint mElbowJoint; + LLJoint mWristJoint; + LLJoint mTarget; LLJointSolverRP3 mIKSolver; LLCharacter *mCharacter; @@ -129,7 +128,7 @@ public: static S32 sHandPose; static S32 sHandPosePriority; LLVector3 mLastSelectPt; -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLKEYFRAMEMOTION_H diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index b58dc797f8..481fb0a1bb 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -86,8 +86,7 @@ inline bool operator!=(const LLVector3OverrideMap& a, const LLVector3OverrideMap //----------------------------------------------------------------------------- // class LLJoint //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLJoint +class alignas(16) LLJoint { LL_ALIGN_NEW public: @@ -118,7 +117,7 @@ public: }; protected: // explicit transformation members - LL_ALIGN_16(LLMatrix4a mWorldMatrix); + LLMatrix4a mWorldMatrix; LLXformMatrix mXform; std::string mName; @@ -302,6 +301,6 @@ public: // These are used in checks of whether a pos/scale override is considered significant. bool aboveJointPosThreshold(const LLVector3& pos) const; bool aboveJointScaleThreshold(const LLVector3& scale) const; -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLJOINT_H diff --git a/indra/llcharacter/llkeyframestandmotion.h b/indra/llcharacter/llkeyframestandmotion.h index df458c7a0c..7d1acb7c5a 100644 --- a/indra/llcharacter/llkeyframestandmotion.h +++ b/indra/llcharacter/llkeyframestandmotion.h @@ -37,8 +37,7 @@ //----------------------------------------------------------------------------- // class LLKeyframeStandMotion //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLKeyframeStandMotion : +class alignas(16) LLKeyframeStandMotion : public LLKeyframeMotion { LL_ALIGN_NEW @@ -112,7 +111,7 @@ public: bool mTrackAnkles; S32 mFrameNum; -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLKEYFRAMESTANDMOTION_H diff --git a/indra/llcharacter/llpose.h b/indra/llcharacter/llpose.h index f2032220e0..fbcd482211 100644 --- a/indra/llcharacter/llpose.h +++ b/indra/llcharacter/llpose.h @@ -80,8 +80,7 @@ public: const S32 JSB_NUM_JOINT_STATES = 6; -LL_ALIGN_PREFIX(16) -class LLJointStateBlender +class alignas(16) LLJointStateBlender { LL_ALIGN_NEW protected: @@ -98,8 +97,8 @@ public: void resetCachedJoint(); public: - LL_ALIGN_16(LLJoint mJointCache); -} LL_ALIGN_POSTFIX(16); + LLJoint mJointCache; +}; class LLMotion; diff --git a/indra/llcharacter/llvisualparam.h b/indra/llcharacter/llvisualparam.h index 3caddb9c62..c99577ed80 100644 --- a/indra/llcharacter/llvisualparam.h +++ b/indra/llcharacter/llvisualparam.h @@ -100,8 +100,7 @@ protected: // An interface class for a generalized parametric modification of the avatar mesh // Contains data that is specific to each Avatar //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLVisualParam +class alignas(16) LLVisualParam { public: typedef boost::function<LLVisualParam*(S32)> visual_param_mapper; @@ -180,6 +179,6 @@ protected: S32 mID; // id for storing weight/morphtarget compares compactly LLVisualParamInfo *mInfo; EParamLocation mParamLocation; // where does this visual param live? -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLVisualParam_H diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index b47138b0eb..a25387d321 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -92,22 +92,6 @@ template <typename T> T* LL_NEXT_ALIGNED_ADDRESS_64(T* address) (uintptr_t(address) + 0x3F) & ~0x3F); } -#if LL_LINUX || LL_DARWIN - -#define LL_ALIGN_PREFIX(x) -#define LL_ALIGN_POSTFIX(x) __attribute__((aligned(x))) - -#elif LL_WINDOWS - -#define LL_ALIGN_PREFIX(x) __declspec(align(x)) -#define LL_ALIGN_POSTFIX(x) - -#else -#error "LL_ALIGN_PREFIX and LL_ALIGN_POSTFIX undefined" -#endif - -#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16) - #define LL_ALIGN_NEW \ public: \ void* operator new(size_t size) \ diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h index 6201761c46..3863588407 100644 --- a/indra/llmath/llcamera.h +++ b/indra/llmath/llcamera.h @@ -60,10 +60,10 @@ constexpr F32 MAX_FIELD_OF_VIEW = 175.f * DEG_TO_RAD; // roll(), pitch(), yaw() // etc... -LL_ALIGN_PREFIX(16) -class LLCamera +class alignas(16) LLCamera : public LLCoordFrame { + LL_ALIGN_NEW public: LLCamera(const LLCamera& rhs) { @@ -120,9 +120,9 @@ public: }; private: - LL_ALIGN_16(LLPlane mAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]); //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP - LL_ALIGN_16(LLPlane mRegionPlanes[AGENT_PLANE_USER_CLIP_NUM]); //frustum planes in a local region space, derived from mAgentPlanes - LL_ALIGN_16(LLPlane mLastAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]); + LLPlane mAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]; //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP + LLPlane mRegionPlanes[AGENT_PLANE_USER_CLIP_NUM]; //frustum planes in a local region space, derived from mAgentPlanes + LLPlane mLastAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]; U8 mPlaneMask[PLANE_MASK_NUM]; // 8 for alignment F32 mView; // angle between top and bottom frustum planes in radians. @@ -218,7 +218,7 @@ protected: void calculateFrustumPlanes(); void calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom); void calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2); -} LL_ALIGN_POSTFIX(16); +}; #endif diff --git a/indra/llmath/llmatrix3a.cpp b/indra/llmath/llmatrix3a.cpp index c0b00201cf..904c9de2a1 100644 --- a/indra/llmath/llmatrix3a.cpp +++ b/indra/llmath/llmatrix3a.cpp @@ -28,7 +28,7 @@ #include "llmath.h" -static LL_ALIGN_16(const F32 M_IDENT_3A[12]) = +alignas(16) static const F32 M_IDENT_3A[12] = { 1.f, 0.f, 0.f, 0.f, // Column 1 0.f, 1.f, 0.f, 0.f, // Column 2 0.f, 0.f, 1.f, 0.f }; // Column 3 diff --git a/indra/llmath/llmatrix3a.h b/indra/llmath/llmatrix3a.h index 9b173c22ed..742a2488fd 100644 --- a/indra/llmath/llmatrix3a.h +++ b/indra/llmath/llmatrix3a.h @@ -40,8 +40,9 @@ // LLMatrix3a is the base class for LLRotation, which should be used instead any time you're dealing with a // rotation matrix. -class LLMatrix3a +class alignas(16) LLMatrix3a { + LL_ALIGN_NEW public: // Utility function for quickly transforming an array of LLVector4a's @@ -111,7 +112,7 @@ public: protected: - LL_ALIGN_16(LLVector4a mColumns[3]); + LLVector4a mColumns[3]; }; diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h index 377203098e..2967949993 100644 --- a/indra/llmath/llmatrix4a.h +++ b/indra/llmath/llmatrix4a.h @@ -31,10 +31,11 @@ #include "m4math.h" #include "m3math.h" -class LLMatrix4a +class alignas(16) LLMatrix4a { + LL_ALIGN_NEW public: - LL_ALIGN_16(LLVector4a mMatrix[4]); + LLVector4a mMatrix[4]; LLMatrix4a() = default; diff --git a/indra/llmath/llplane.h b/indra/llmath/llplane.h index 832004bb64..822e6a7b6f 100644 --- a/indra/llmath/llplane.h +++ b/indra/llmath/llplane.h @@ -36,10 +36,9 @@ // The plane normal = [A, B, C] // The closest approach = D / sqrt(A*A + B*B + C*C) - -LL_ALIGN_PREFIX(16) -class LLPlane +class alignas(16) LLPlane { + LL_ALIGN_NEW public: // Constructors @@ -102,7 +101,7 @@ public: private: LLVector4a mV; -} LL_ALIGN_POSTFIX(16); +}; static_assert(std::is_trivial<LLPlane>::value, "LLPlane must be a trivial type"); diff --git a/indra/llmath/llquantize.h b/indra/llmath/llquantize.h index e8d880122e..2a53fdbf84 100644 --- a/indra/llmath/llquantize.h +++ b/indra/llmath/llquantize.h @@ -29,16 +29,16 @@ #define LL_LLQUANTIZE_H const U16 U16MAX = 65535; -LL_ALIGN_16( const F32 F_U16MAX_4A[4] ) = { 65535.f, 65535.f, 65535.f, 65535.f }; +alignas(16) const F32 F_U16MAX_4A[4] = { 65535.f, 65535.f, 65535.f, 65535.f }; const F32 OOU16MAX = 1.f/(F32)(U16MAX); -LL_ALIGN_16( const F32 F_OOU16MAX_4A[4] ) = { OOU16MAX, OOU16MAX, OOU16MAX, OOU16MAX }; +alignas(16) const F32 F_OOU16MAX_4A[4] = { OOU16MAX, OOU16MAX, OOU16MAX, OOU16MAX }; const U8 U8MAX = 255; -LL_ALIGN_16( const F32 F_U8MAX_4A[4] ) = { 255.f, 255.f, 255.f, 255.f }; +alignas(16) const F32 F_U8MAX_4A[4] = { 255.f, 255.f, 255.f, 255.f }; const F32 OOU8MAX = 1.f/(F32)(U8MAX); -LL_ALIGN_16( const F32 F_OOU8MAX_4A[4] ) = { OOU8MAX, OOU8MAX, OOU8MAX, OOU8MAX }; +alignas(16) const F32 F_OOU8MAX_4A[4] = { OOU8MAX, OOU8MAX, OOU8MAX, OOU8MAX }; const U8 FIRSTVALIDCHAR = 54; const U8 MAXSTRINGVAL = U8MAX - FIRSTVALIDCHAR; //we don't allow newline or null diff --git a/indra/llmath/llquaternion2.h b/indra/llmath/llquaternion2.h index c9dcc4573f..d73e1a0ca2 100644 --- a/indra/llmath/llquaternion2.h +++ b/indra/llmath/llquaternion2.h @@ -40,8 +40,9 @@ ///////////////////////////// #include "llquaternion.h" -class LLQuaternion2 +class alignas(16) LLQuaternion2 { + LL_ALIGN_NEW public: ////////////////////////// diff --git a/indra/llmath/llquaternion2.inl b/indra/llmath/llquaternion2.inl index ce5ed73926..2ebc8e0bfb 100644 --- a/indra/llmath/llquaternion2.inl +++ b/indra/llmath/llquaternion2.inl @@ -57,7 +57,7 @@ inline LLVector4a& LLQuaternion2::getVector4aRw() // Set this quaternion to the conjugate of src inline void LLQuaternion2::setConjugate(const LLQuaternion2& src) { - static LL_ALIGN_16( const U32 F_QUAT_INV_MASK_4A[4] ) = { 0x80000000, 0x80000000, 0x80000000, 0x00000000 }; + alignas(16) static const U32 F_QUAT_INV_MASK_4A[4] = { 0x80000000, 0x80000000, 0x80000000, 0x00000000 }; mQ = _mm_xor_ps(src.mQ, *reinterpret_cast<const LLQuad*>(&F_QUAT_INV_MASK_4A)); } diff --git a/indra/llmath/llsimdtypes.inl b/indra/llmath/llsimdtypes.inl index 125f4b9df5..20ea7640b6 100644 --- a/indra/llmath/llsimdtypes.inl +++ b/indra/llmath/llsimdtypes.inl @@ -61,7 +61,7 @@ inline LLSimdScalar operator/(const LLSimdScalar& a, const LLSimdScalar& b) inline LLSimdScalar operator-(const LLSimdScalar& a) { - static LL_ALIGN_16(const U32 signMask[4]) = {0x80000000, 0x80000000, 0x80000000, 0x80000000 }; + alignas(16) static const U32 signMask[4] = {0x80000000, 0x80000000, 0x80000000, 0x80000000 }; ll_assert_aligned(signMask,16); return _mm_xor_ps(*reinterpret_cast<const LLQuad*>(signMask), a); } @@ -146,7 +146,7 @@ inline LLSimdScalar& LLSimdScalar::operator/=(const LLSimdScalar& rhs) inline LLSimdScalar LLSimdScalar::getAbs() const { - static const LL_ALIGN_16(U32 F_ABS_MASK_4A[4]) = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; + alignas(16) static const U32 F_ABS_MASK_4A[4] = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; ll_assert_aligned(F_ABS_MASK_4A,16); return _mm_and_ps( mQ, *reinterpret_cast<const LLQuad*>(F_ABS_MASK_4A)); } diff --git a/indra/llmath/llvector4a.cpp b/indra/llmath/llvector4a.cpp index b81d50f0f9..6bdc97e420 100644 --- a/indra/llmath/llvector4a.cpp +++ b/indra/llmath/llvector4a.cpp @@ -101,7 +101,7 @@ void LLVector4a::quantize8( const LLVector4a& low, const LLVector4a& high ) // 8-bit quantization means we can do with just 12 bits of reciprocal accuracy const LLVector4a oneOverDelta = _mm_rcp_ps(delta.mQ); // { -// static LL_ALIGN_16( const F32 F_TWO_4A[4] ) = { 2.f, 2.f, 2.f, 2.f }; +// alignas(16) static const F32 F_TWO_4A[4] = { 2.f, 2.f, 2.f, 2.f }; // LLVector4a two; two.load4a( F_TWO_4A ); // // // Here we use _mm_rcp_ps plus one round of newton-raphson @@ -146,7 +146,7 @@ void LLVector4a::quantize16( const LLVector4a& low, const LLVector4a& high ) // 16-bit quantization means we need a round of Newton-Raphson LLVector4a oneOverDelta; { - static LL_ALIGN_16( const F32 F_TWO_4A[4] ) = { 2.f, 2.f, 2.f, 2.f }; + alignas(16) static const F32 F_TWO_4A[4] = { 2.f, 2.f, 2.f, 2.f }; ll_assert_aligned(F_TWO_4A,16); LLVector4a two; two.load4a( F_TWO_4A ); diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 443a46c317..b6e2a4fce5 100644 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -196,7 +196,7 @@ inline void LLVector4a::setDiv(const LLVector4a& a, const LLVector4a& b) // Set this to the element-wise absolute value of src inline void LLVector4a::setAbs(const LLVector4a& src) { - static const LL_ALIGN_16(U32 F_ABS_MASK_4A[4]) = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; + alignas(16) static const U32 F_ABS_MASK_4A[4] = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; mQ = _mm_and_ps(src.mQ, *reinterpret_cast<const LLQuad*>(F_ABS_MASK_4A)); } @@ -448,7 +448,7 @@ inline void LLVector4a::normalize3fast_checked(LLVector4a* d) // Return true if this vector is normalized with respect to x,y,z up to tolerance inline LLBool32 LLVector4a::isNormalized3( F32 tolerance ) const { - static LL_ALIGN_16(const U32 ones[4]) = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 }; + alignas(16) static const U32 ones[4] = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 }; LLSimdScalar tol = _mm_load_ss( &tolerance ); tol = _mm_mul_ss( tol, tol ); LLVector4a lenSquared; lenSquared.setAllDot3( *this, *this ); @@ -460,7 +460,7 @@ inline LLBool32 LLVector4a::isNormalized3( F32 tolerance ) const // Return true if this vector is normalized with respect to all components up to tolerance inline LLBool32 LLVector4a::isNormalized4( F32 tolerance ) const { - static LL_ALIGN_16(const U32 ones[4]) = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 }; + alignas(16) static const U32 ones[4] = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 }; LLSimdScalar tol = _mm_load_ss( &tolerance ); tol = _mm_mul_ss( tol, tol ); LLVector4a lenSquared; lenSquared.setAllDot4( *this, *this ); @@ -507,7 +507,7 @@ inline void LLVector4a::setLerp(const LLVector4a& lhs, const LLVector4a& rhs, F3 inline LLBool32 LLVector4a::isFinite3() const { - static LL_ALIGN_16(const U32 nanOrInfMask[4]) = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 }; + alignas(16) static const U32 nanOrInfMask[4] = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 }; ll_assert_aligned(nanOrInfMask,16); const __m128i nanOrInfMaskV = *reinterpret_cast<const __m128i*> (nanOrInfMask); const __m128i maskResult = _mm_and_si128( _mm_castps_si128(mQ), nanOrInfMaskV ); @@ -517,7 +517,7 @@ inline LLBool32 LLVector4a::isFinite3() const inline LLBool32 LLVector4a::isFinite4() const { - static LL_ALIGN_16(const U32 nanOrInfMask[4]) = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 }; + alignas(16) static const U32 nanOrInfMask[4] = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 }; const __m128i nanOrInfMaskV = *reinterpret_cast<const __m128i*> (nanOrInfMask); const __m128i maskResult = _mm_and_si128( _mm_castps_si128(mQ), nanOrInfMaskV ); const LLVector4Logical equalityCheck = _mm_castsi128_ps(_mm_cmpeq_epi32( maskResult, nanOrInfMaskV )); diff --git a/indra/llmath/llvector4logical.h b/indra/llmath/llvector4logical.h index 77cb5862e5..411971c42d 100644 --- a/indra/llmath/llvector4logical.h +++ b/indra/llmath/llvector4logical.h @@ -39,7 +39,7 @@ // contact someone with SSE experience (Falcon, Richard, Davep, e.g.) //////////////////////////// -static LL_ALIGN_16(const U32 S_V4LOGICAL_MASK_TABLE[4*4]) = +alignas(16) static const U32 S_V4LOGICAL_MASK_TABLE[4*4] = { 0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0x00000000, 0x00000000, @@ -77,7 +77,7 @@ public: // Invert this mask inline LLVector4Logical& invert() { - static const LL_ALIGN_16(U32 allOnes[4]) = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; + alignas(16) static const U32 allOnes[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; ll_assert_aligned(allOnes,16); mQ = _mm_andnot_ps( mQ, *(LLQuad*)(allOnes) ); return *this; diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h index 1d74644715..4200e0d5a1 100644 --- a/indra/llmath/llvolumeoctree.h +++ b/indra/llmath/llvolumeoctree.h @@ -53,7 +53,7 @@ public: } - LL_ALIGN_16(LLVector4a mPositionGroup); + LLVector4a mPositionGroup; const LLVector4a* mV[3]; U32 mIndex[3]; @@ -99,8 +99,8 @@ public: public: - 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 + 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 }; class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle, LLVolumeTriangle*> diff --git a/indra/llmath/tests/alignment_test.cpp b/indra/llmath/tests/alignment_test.cpp index eb6fa4a3b8..f41ebe82aa 100644 --- a/indra/llmath/tests/alignment_test.cpp +++ b/indra/llmath/tests/alignment_test.cpp @@ -46,8 +46,7 @@ typedef test_group<alignment_test> alignment_test_t; typedef alignment_test_t::object alignment_test_object_t; tut::alignment_test_t tut_alignment_test("LLAlignment"); -LL_ALIGN_PREFIX(16) -class MyVector4a +class alignas(16) MyVector4a { public: void* operator new(size_t size) @@ -71,7 +70,7 @@ public: } LLQuad mQ; -} LL_ALIGN_POSTFIX(16); +}; // Verify that aligned allocators perform as advertised. diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index ac88af18f0..26448069c6 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -40,8 +40,7 @@ class domMesh; #define MAX_MODEL_FACES 8 -LL_ALIGN_PREFIX(16) -class LLMeshSkinInfo : public LLRefCount +class alignas(16) LLMeshSkinInfo : public LLRefCount { LL_ALIGN_NEW public: @@ -65,17 +64,16 @@ public: // cached multiply of mBindShapeMatrix and mInvBindMatrix matrix_list_t mBindPoseMatrix; - LL_ALIGN_16(LLMatrix4a mBindShapeMatrix); + LLMatrix4a mBindShapeMatrix; float mPelvisOffset; bool mLockScaleIfJointPosition; bool mInvalidJointsScrubbed; bool mJointNumsInitialized; U64 mHash = 0; -} LL_ALIGN_POSTFIX(16); +}; -LL_ALIGN_PREFIX(16) -class LLModel : public LLVolume +class alignas(16) LLModel : public LLVolume { LL_ALIGN_NEW public: @@ -323,7 +321,7 @@ public: // A model/object can only have 8 faces, spillover faces will // be moved to new model/object and assigned a submodel id. int mSubmodelID; -} LL_ALIGN_POSTFIX(16); +}; typedef std::vector<LLPointer<LLModel> > model_list; typedef std::queue<LLPointer<LLModel> > model_queue; diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index a7ac9da618..d05cd0ee2b 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -59,8 +59,7 @@ class LLViewerTexture; const U32 SILHOUETTE_HIGHLIGHT = 0; // All data for new renderer goes into this class. -LL_ALIGN_PREFIX(16) -class LLDrawable +class alignas(16) LLDrawable : public LLViewerOctreeEntryData { LL_ALIGN_NEW; @@ -313,7 +312,7 @@ private: static U32 sNumZombieDrawables; static std::vector<LLPointer<LLDrawable> > sDeadList; -} LL_ALIGN_POSTFIX(16); +}; inline LLFace* LLDrawable::getFace(const S32 i) const diff --git a/indra/newview/lldynamictexture.h b/indra/newview/lldynamictexture.h index 375828fefa..cc5e39c5fb 100644 --- a/indra/newview/lldynamictexture.h +++ b/indra/newview/lldynamictexture.h @@ -33,7 +33,7 @@ #include "llviewertexture.h" #include "llcamera.h" -class LLViewerDynamicTexture : public LLViewerTexture +class alignas(16) LLViewerDynamicTexture : public LLViewerTexture { LL_ALIGN_NEW public: @@ -90,7 +90,7 @@ protected: protected: bool mClamp; LLCoordGL mOrigin; - LL_ALIGN_16(LLCamera mCamera); + LLCamera mCamera; LLRenderTarget* mBoundTarget; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index f3cfbd9565..4ba47aa4da 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3625,12 +3625,11 @@ bool LLSpatialPartition::isVisible(const LLVector3& v) return true; } -LL_ALIGN_PREFIX(16) -class LLOctreeIntersect : public LLOctreeTraveler<LLViewerOctreeEntry, LLPointer<LLViewerOctreeEntry>> +class alignas(16) LLOctreeIntersect : public LLOctreeTraveler<LLViewerOctreeEntry, LLPointer<LLViewerOctreeEntry>> { public: - LL_ALIGN_16(LLVector4a mStart); - LL_ALIGN_16(LLVector4a mEnd); + LLVector4a mStart; + LLVector4a mEnd; S32 *mFaceHit; LLVector4a *mIntersection; @@ -3780,7 +3779,7 @@ public: return false; } -} LL_ALIGN_POSTFIX(16); +}; LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, bool pick_transparent, diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 3aaa3d60e8..4ca1ef7c7a 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -64,7 +64,7 @@ void pushVerts(LLFace* face); Make every effort to keep size minimal. Member ordering is important for cache coherency */ -class LLDrawInfo final : public LLRefCount +class alignas(16) LLDrawInfo final : public LLRefCount { LL_ALIGN_NEW; protected: @@ -198,12 +198,13 @@ public: }; }; -LL_ALIGN_PREFIX(16) -class LLSpatialGroup : public LLOcclusionCullingGroup +class alignas(16) LLSpatialGroup : public LLOcclusionCullingGroup { using super = LLOcclusionCullingGroup; friend class LLSpatialPartition; friend class LLOctreeStateCheck; + + LL_ALIGN_NEW public: LLSpatialGroup(const LLSpatialGroup& rhs) : LLOcclusionCullingGroup(rhs) @@ -338,8 +339,8 @@ public: virtual void rebound(); public: - LL_ALIGN_16(LLVector4a mViewAngle); - LL_ALIGN_16(LLVector4a mLastUpdateViewAngle); + LLVector4a mViewAngle; + LLVector4a mLastUpdateViewAngle; protected: virtual ~LLSpatialGroup(); @@ -369,7 +370,7 @@ public: U32 mRenderOrder = 0; // Reflection Probe associated with this node (if any) LLPointer<LLReflectionMap> mReflectionProbe = nullptr; -} LL_ALIGN_POSTFIX(16); +}; class LLGeometryManager { diff --git a/indra/newview/llviewerjoint.h b/indra/newview/llviewerjoint.h index 7f52ca9623..57959ec2fc 100644 --- a/indra/newview/llviewerjoint.h +++ b/indra/newview/llviewerjoint.h @@ -39,9 +39,10 @@ class LLViewerJointMesh; //----------------------------------------------------------------------------- // class LLViewerJoint //----------------------------------------------------------------------------- -class LLViewerJoint : +class alignas(16) LLViewerJoint : public virtual LLAvatarJoint { + LL_ALIGN_NEW public: LLViewerJoint(); LLViewerJoint(S32 joint_num); diff --git a/indra/newview/llviewerjointattachment.h b/indra/newview/llviewerjointattachment.h index fe66949f73..12075177b3 100644 --- a/indra/newview/llviewerjointattachment.h +++ b/indra/newview/llviewerjointattachment.h @@ -40,9 +40,10 @@ class LLViewerObject; //----------------------------------------------------------------------------- // class LLViewerJointAttachment //----------------------------------------------------------------------------- -class LLViewerJointAttachment : +class alignas(16) LLViewerJointAttachment : public LLViewerJoint { + LL_ALIGN_NEW public: LLViewerJointAttachment(); virtual ~LLViewerJointAttachment(); diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h index cfe8ecdb67..a3afd84d06 100644 --- a/indra/newview/llviewerjointmesh.h +++ b/indra/newview/llviewerjointmesh.h @@ -41,8 +41,9 @@ class LLViewerTexLayerSet; //----------------------------------------------------------------------------- // class LLViewerJointMesh //----------------------------------------------------------------------------- -class LLViewerJointMesh : public LLAvatarJointMesh, public LLViewerJoint +class alignas(16) LLViewerJointMesh : public LLAvatarJointMesh, public LLViewerJoint { + LL_ALIGN_NEW public: // Constructor LLViewerJointMesh(); diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index 60e17a6f58..83b8aa8d03 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -70,8 +70,7 @@ S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVect S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared); //defines data needed for octree of an entry -//LL_ALIGN_PREFIX(16) -class LLViewerOctreeEntry : public LLRefCount +class alignas(16) LLViewerOctreeEntry : public LLRefCount { LL_ALIGN_NEW friend class LLViewerOctreeEntryData; @@ -115,16 +114,15 @@ private: LLViewerOctreeGroup* mGroup; //aligned members - LL_ALIGN_16(LLVector4a mExtents[2]); - LL_ALIGN_16(LLVector4a mPositionGroup); + LLVector4a mExtents[2]; + LLVector4a mPositionGroup; F32 mBinRadius; mutable S32 mBinIndex; mutable U32 mVisible; -} ;//LL_ALIGN_POSTFIX(16); +}; //defines an abstract class for entry data -//LL_ALIGN_PREFIX(16) class LLViewerOctreeEntryData : public LLRefCount { protected: @@ -173,11 +171,10 @@ protected: LLPointer<LLViewerOctreeEntry> mEntry; LLViewerOctreeEntry::eEntryDataType_t mDataType; static U32 sCurVisible; // Counter for what value of mVisible means currently visible -};//LL_ALIGN_POSTFIX(16); +}; //defines an octree group for an octree node, which contains multiple entries. -//LL_ALIGN_PREFIX(16) class LLViewerOctreeGroup : public OctreeListener { @@ -259,18 +256,17 @@ protected: U32 mState; OctreeNode* mOctreeNode; - 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 mObjectBounds[2]); // bounding box (center, size) of objects in this node - 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 + LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects) + LLVector4a mObjectBounds[2]; // bounding box (center, size) of objects in this node + LLVector4a mExtents[2]; // extents (min, max) of this node and all its children + LLVector4a mObjectExtents[2]; // extents (min, max) of objects in this node S32 mAnyVisible; //latest visible to any camera S32 mVisible[LLViewerCamera::NUM_CAMERAS]; -};//LL_ALIGN_POSTFIX(16); +}; //octree group which has capability to support occlusion culling -//LL_ALIGN_PREFIX(16) class LLOcclusionCullingGroup : public LLViewerOctreeGroup { public: @@ -340,7 +336,7 @@ protected: public: static std::set<U32> sPendingQueries; -};//LL_ALIGN_POSTFIX(16); +}; class LLViewerOctreePartition { diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index c6a7a59034..25b7c58733 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3074,7 +3074,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update) if (isImpostor() && !mNeedsImpostorUpdate) { - LL_ALIGN_16(LLVector4a ext[2]); + LLVector4a ext[2]; F32 distance; LLVector3 angle; diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 5c062870a0..a1675e8a02 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -264,7 +264,7 @@ public: private: //aligned members - LL_ALIGN_16(LLVector4a mImpostorExtents[2]); + LLVector4a mImpostorExtents[2]; //-------------------------------------------------------------------- // Updates |
