diff options
-rw-r--r-- | indra/llcommon/llmemory.h | 30 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 8 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 16 | ||||
-rw-r--r-- | indra/newview/lldrawable.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llface.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llspatialpartition.cpp | 14 |
6 files changed, 49 insertions, 27 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 93dd7a7fe3..1c8c91f57e 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -43,13 +43,9 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi #else void *rtn; if (LL_LIKELY(0 == posix_memalign(&rtn, 16, size))) - { return rtn; - } else // bad alignment requested, or out of memory - { return NULL; - } #endif } @@ -64,6 +60,32 @@ inline void ll_aligned_free_16(void *p) #endif } +inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed with ll_aligned_free_32(). +{ +#if defined(LL_WINDOWS) + return _mm_malloc(size, 32); +#elif defined(LL_DARWIN) +# error implement me. +#else + void *rtn; + if (LL_LIKELY(0 == posix_memalign(&rtn, 32, size))) + return rtn; + else // bad alignment requested, or out of memory + return NULL; +#endif +} + +inline void ll_aligned_free_32(void *p) +{ +#if defined(LL_WINDOWS) + _mm_free(p); +#elif defined(LL_DARWIN) +# error implement me. +#else + free(p); // posix_memalign() is compatible with heap deallocator +#endif +} + class LL_COMMON_API LLMemory { public: diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 3f70ccacb1..70601663e6 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -777,8 +777,8 @@ LLRender::LLRender() mTexcoordsp = tc.get(); mColorsp = color.get(); - mUIOffset = (LLVector4a*) _mm_malloc(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a), 16); - mUIScale = (LLVector4a*) _mm_malloc(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a), 16); + mUIOffset = (LLVector4a*) ll_aligned_malloc_16(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a)); + mUIScale = (LLVector4a*) ll_aligned_malloc_16(LL_MAX_UI_STACK_DEPTH*sizeof(LLVector4a)); mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS); for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++) @@ -816,9 +816,9 @@ void LLRender::shutdown() delete mDummyTexUnit; mDummyTexUnit = NULL; - _mm_free(mUIOffset); + ll_aligned_free_16(mUIOffset); mUIOffset = NULL; - _mm_free(mUIScale); + ll_aligned_free_16(mUIScale); mUIScale = NULL; } diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 4f2dae0cdf..ff966f1e95 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -627,7 +627,7 @@ void LLVertexBuffer::createGLBuffer() { static int gl_buffer_idx = 0; mGLBuffer = ++gl_buffer_idx; - mMappedData = (U8*) _mm_malloc(size, 16); + mMappedData = (U8*) ll_aligned_malloc_16(size); memset(mMappedData, 0, size); } } @@ -662,7 +662,7 @@ void LLVertexBuffer::createGLIndices() } else { - mMappedIndexData = (U8*) _mm_malloc(size, 16); + mMappedIndexData = (U8*) ll_aligned_malloc_16(size); static int gl_buffer_idx = 0; mGLIndices = ++gl_buffer_idx; } @@ -683,7 +683,7 @@ void LLVertexBuffer::destroyGLBuffer() } else { - _mm_free(mMappedData); + ll_aligned_free_16(mMappedData); mMappedData = NULL; mEmpty = TRUE; } @@ -710,7 +710,7 @@ void LLVertexBuffer::destroyGLIndices() } else { - _mm_free(mMappedIndexData); + ll_aligned_free_16(mMappedIndexData); mMappedIndexData = NULL; mEmpty = TRUE; } @@ -846,8 +846,8 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) { if (!useVBOs()) { - _mm_free(mMappedData); - mMappedData = (U8*) _mm_malloc(newsize, 16); + ll_aligned_free_16(mMappedData); + mMappedData = (U8*) ll_aligned_malloc_16(newsize); } mResized = TRUE; } @@ -867,8 +867,8 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) { if (!useVBOs()) { - _mm_free(mMappedIndexData); - mMappedIndexData = (U8*) _mm_malloc(new_index_size, 16); + ll_aligned_free_16(mMappedIndexData); + mMappedIndexData = (U8*) ll_aligned_malloc_16(new_index_size); } mResized = TRUE; } diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 04e433dcfd..96ec51300f 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -95,7 +95,7 @@ void LLDrawable::incrementVisible() void LLDrawable::init() { - mExtents = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*3, 32); + mExtents = (LLVector4a*) ll_aligned_malloc_32(sizeof(LLVector4a)*3, 32); mPositionGroup = mExtents + 2; // mXform @@ -150,7 +150,7 @@ void LLDrawable::destroy() llinfos << "- Zombie drawables: " << sNumZombieDrawables << llendl; }*/ - _mm_free(mExtents); + ll_aligned_free_32(mExtents); mExtents = mPositionGroup = NULL; } diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 0b5cf78261..9b5a1eb07c 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -152,7 +152,7 @@ void cylindricalProjection(LLVector2 &tc, const LLVector4a& normal, const LLVect void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) { - mExtents = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*2, 16); + mExtents = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*2); mLastUpdateTime = gFrameTimeSeconds; mLastMoveTime = 0.f; @@ -269,7 +269,7 @@ void LLFace::destroy() mVObjp = NULL; } - _mm_free(mExtents); + ll_aligned_free_16(mExtents); mExtents = NULL; } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 05e7bbb6cd..e5d0e064c6 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -239,7 +239,7 @@ void LLSpatialGroup::buildOcclusion() { if (!mOcclusionVerts) { - mOcclusionVerts = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*8, 16); + mOcclusionVerts = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*8); } LLVector4a fudge; @@ -342,13 +342,13 @@ LLSpatialGroup::~LLSpatialGroup() sQueryPool.release(mOcclusionQuery[LLViewerCamera::sCurCameraID]); } - _mm_free(mOcclusionVerts); + ll_aligned_free_16(mOcclusionVerts); LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); clearDrawMap(); clearAtlasList() ; - _mm_free(mBounds); + ll_aligned_free_16(mBounds); } BOOL LLSpatialGroup::hasAtlas(LLTextureAtlas* atlasp) @@ -1163,7 +1163,7 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : sNodeCount++; LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - mBounds = (LLVector4a*) _mm_malloc(sizeof(LLVector4a) * V4_COUNT, 16); + mBounds = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a) * V4_COUNT); mExtents = mBounds + EXTENTS; mObjectBounds = mBounds + OBJECT_BOUNDS; mObjectExtents = mBounds + OBJECT_EXTENTS; @@ -1434,7 +1434,7 @@ void LLSpatialGroup::destroyGL() } } - _mm_free(mOcclusionVerts); + ll_aligned_free_16(mOcclusionVerts); mOcclusionVerts = NULL; for (LLSpatialGroup::element_iter i = getData().begin(); i != getData().end(); ++i) @@ -3502,7 +3502,7 @@ LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, mDrawMode(LLRender::TRIANGLES) { mVertexBuffer->validateRange(mStart, mEnd, mCount, mOffset); - mExtents = (LLVector4a*) _mm_malloc(sizeof(LLVector4a)*2, 16); + mExtents = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*2); mDebugColor = (rand() << 16) + rand(); } @@ -3524,7 +3524,7 @@ LLDrawInfo::~LLDrawInfo() gPipeline.checkReferences(this); } - _mm_free(mExtents); + ll_aligned_free_16(mExtents); } void LLDrawInfo::validate() |