SH-2789 WIP - add asserts to check object address alignment where needed
parent
dbc91a7fac
commit
e68d5e248f
|
|
@ -512,4 +512,13 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr)
|
|||
|
||||
// LLSingleton moved to llsingleton.h
|
||||
|
||||
#define CHECK_ALIGNMENT
|
||||
|
||||
#ifdef CHECK_ALIGNMENT
|
||||
#define ll_assert_aligned(ptr,alignment) llassert((reinterpret_cast<uintptr_t>(ptr))%(alignment) == 0)
|
||||
#else
|
||||
#define ll_assert_aligned(ptr,alignment)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -67,11 +67,10 @@ template <typename T> T* LL_NEXT_ALIGNED_ADDRESS_64(T* address)
|
|||
|
||||
#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16)
|
||||
|
||||
|
||||
|
||||
#include <xmmintrin.h>
|
||||
#include <emmintrin.h>
|
||||
|
||||
#include "llmemory.h"
|
||||
#include "llsimdtypes.h"
|
||||
#include "llsimdtypes.inl"
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,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 };
|
||||
ll_assert_aligned(signMask,16);
|
||||
return _mm_xor_ps(*reinterpret_cast<const LLQuad*>(signMask), a);
|
||||
}
|
||||
|
||||
|
|
@ -146,6 +147,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 };
|
||||
ll_assert_aligned(F_ABS_MASK_4A,16);
|
||||
return _mm_and_ps( mQ, *reinterpret_cast<const LLQuad*>(F_ABS_MASK_4A));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "llmemory.h"
|
||||
#include "llmath.h"
|
||||
#include "llquantize.h"
|
||||
|
||||
|
|
@ -189,6 +190,8 @@ void LLVector4a::quantize16( const LLVector4a& low, const LLVector4a& high )
|
|||
LLVector4a oneOverDelta;
|
||||
{
|
||||
static LL_ALIGN_16( 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 );
|
||||
|
||||
// Here we use _mm_rcp_ps plus one round of newton-raphson
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class LLRotation;
|
|||
|
||||
#include <assert.h>
|
||||
#include "llpreprocessor.h"
|
||||
#include "llmemory.h"
|
||||
|
||||
///////////////////////////////////
|
||||
// FIRST TIME USERS PLEASE READ
|
||||
|
|
@ -90,6 +91,7 @@ public:
|
|||
|
||||
LLVector4a()
|
||||
{ //DO NOT INITIALIZE -- The overhead is completely unnecessary
|
||||
ll_assert_aligned(this,16);
|
||||
}
|
||||
|
||||
LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f)
|
||||
|
|
|
|||
|
|
@ -475,6 +475,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 };
|
||||
ll_assert_aligned(nanOrInfMask,16);
|
||||
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 ));
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#ifndef LL_VECTOR4LOGICAL_H
|
||||
#define LL_VECTOR4LOGICAL_H
|
||||
|
||||
#include "llmemory.h"
|
||||
|
||||
////////////////////////////
|
||||
// LLVector4Logical
|
||||
|
|
@ -77,6 +78,7 @@ public:
|
|||
inline LLVector4Logical& invert()
|
||||
{
|
||||
static const LL_ALIGN_16(U32 allOnes[4]) = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
|
||||
ll_assert_aligned(allOnes,16);
|
||||
mQ = _mm_andnot_ps( mQ, *(LLQuad*)(allOnes) );
|
||||
return *this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,17 +95,6 @@ const S32 SCULPT_MIN_AREA_DETAIL = 1;
|
|||
|
||||
extern BOOL gDebugGL;
|
||||
|
||||
void assert_aligned(void* ptr, uintptr_t alignment)
|
||||
{
|
||||
#if 0
|
||||
uintptr_t t = (uintptr_t) ptr;
|
||||
if (t%alignment != 0)
|
||||
{
|
||||
llerrs << "Alignment check failed." << llendl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
|
||||
{
|
||||
LLVector3 test = (pt2-pt1)%(pt3-pt2);
|
||||
|
|
@ -6894,14 +6883,14 @@ void LLVolumeFace::resizeVertices(S32 num_verts)
|
|||
if (num_verts)
|
||||
{
|
||||
mPositions = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts);
|
||||
assert_aligned(mPositions, 16);
|
||||
ll_assert_aligned(mPositions, 16);
|
||||
mNormals = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts);
|
||||
assert_aligned(mNormals, 16);
|
||||
ll_assert_aligned(mNormals, 16);
|
||||
|
||||
//pad texture coordinate block end to allow for QWORD reads
|
||||
S32 size = ((num_verts*sizeof(LLVector2)) + 0xF) & ~0xF;
|
||||
mTexCoords = (LLVector2*) ll_aligned_malloc_16(size);
|
||||
assert_aligned(mTexCoords, 16);
|
||||
ll_assert_aligned(mTexCoords, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -7027,11 +7016,11 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
|
|||
|
||||
//allocate new buffer space
|
||||
mPositions = (LLVector4a*) realloc(mPositions, new_count*sizeof(LLVector4a));
|
||||
assert_aligned(mPositions, 16);
|
||||
ll_assert_aligned(mPositions, 16);
|
||||
mNormals = (LLVector4a*) realloc(mNormals, new_count*sizeof(LLVector4a));
|
||||
assert_aligned(mNormals, 16);
|
||||
ll_assert_aligned(mNormals, 16);
|
||||
mTexCoords = (LLVector2*) realloc(mTexCoords, (new_count*sizeof(LLVector2)+0xF) & ~0xF);
|
||||
assert_aligned(mTexCoords, 16);
|
||||
ll_assert_aligned(mTexCoords, 16);
|
||||
|
||||
mNumVertices = new_count;
|
||||
|
||||
|
|
|
|||
|
|
@ -546,6 +546,7 @@ void LLSpatialGroup::setVisible()
|
|||
|
||||
void LLSpatialGroup::validate()
|
||||
{
|
||||
ll_assert_aligned(this,64);
|
||||
#if LL_OCTREE_PARANOIA_CHECK
|
||||
|
||||
sg_assert(!isState(DIRTY));
|
||||
|
|
@ -1195,6 +1196,8 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
|
|||
mCurUpdatingSlotp(NULL),
|
||||
mCurUpdatingTexture (NULL)
|
||||
{
|
||||
ll_assert_aligned(this,64);
|
||||
|
||||
sNodeCount++;
|
||||
LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue