Migrate ui scale/translation transform matrix stacks to LLAlignedArray.

This commit is contained in:
Shyotl
2013-10-26 16:29:38 -05:00
parent 8441bc80a4
commit f4863527aa
4 changed files with 20 additions and 32 deletions

View File

@@ -41,7 +41,11 @@ public:
~LLAlignedArray(); ~LLAlignedArray();
void push_back(const T& elem); void push_back(const T& elem);
U32 size() const { return mElementCount; } void pop_back() { if(!!mElementCount) --mElementCount; }
bool empty() const { return !mElementCount; }
T& front() { return operator[](0); }
T& back() { return operator[](mElementCount-1); }
U32 size() const { return mElementCount; }
void resize(U32 size); void resize(U32 size);
T* append(S32 N); T* append(S32 N);
T& operator[](int idx); T& operator[](int idx);

View File

@@ -663,14 +663,6 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr)
#endif #endif
#endif #endif
LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);
#ifdef SHOW_ASSERT
#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast<uintptr_t>(ptr),((U32)alignment))
#else
#define ll_assert_aligned(ptr,alignment)
#endif
//EVENTUALLY REMOVE THESE: //EVENTUALLY REMOVE THESE:
#include "llpointer.h" #include "llpointer.h"
#include "llsingleton.h" #include "llsingleton.h"

View File

@@ -1496,7 +1496,7 @@ void LLRender::translateUI(F32 x, F32 y, F32 z)
} }
LLVector4a add(x,y,z); LLVector4a add(x,y,z);
mUIOffset.back()->add(add); mUIOffset.back().add(add);
} }
void LLRender::scaleUI(F32 x, F32 y, F32 z) void LLRender::scaleUI(F32 x, F32 y, F32 z)
@@ -1507,33 +1507,27 @@ void LLRender::scaleUI(F32 x, F32 y, F32 z)
} }
LLVector4a scale(x,y,z); LLVector4a scale(x,y,z);
mUIScale.back()->mul(scale); mUIScale.back().mul(scale);
} }
void LLRender::pushUIMatrix() void LLRender::pushUIMatrix()
{ {
if (mUIOffset.empty()) if (mUIOffset.empty())
{ {
mUIOffset.push_back(static_cast<LLVector4a*>(ll_aligned_malloc_16(sizeof(LLVector4a)))); mUIOffset.push_back(LLVector4a(0.f));
mUIOffset.back()->splat(0.f);
} }
else else
{ {
const LLVector4a* last_entry = mUIOffset.back(); mUIOffset.push_back(mUIOffset.back());
mUIOffset.push_back(static_cast<LLVector4a*>(ll_aligned_malloc_16(sizeof(LLVector4a))));
*mUIOffset.back() = *last_entry;
} }
if (mUIScale.empty()) if (mUIScale.empty())
{ {
mUIScale.push_back(static_cast<LLVector4a*>(ll_aligned_malloc_16(sizeof(LLVector4a)))); mUIScale.push_back(LLVector4a(1.f));
mUIScale.back()->splat(1.f);
} }
else else
{ {
const LLVector4a* last_entry = mUIScale.back(); mUIScale.push_back(mUIScale.back());
mUIScale.push_back(static_cast<LLVector4a*>(ll_aligned_malloc_16(sizeof(LLVector4a))));
*mUIScale.back() = *last_entry;
} }
} }
@@ -1543,9 +1537,7 @@ void LLRender::popUIMatrix()
{ {
llerrs << "UI offset stack blown." << llendl; llerrs << "UI offset stack blown." << llendl;
} }
ll_aligned_free_16(mUIOffset.back());
mUIOffset.pop_back(); mUIOffset.pop_back();
ll_aligned_free_16(mUIScale.back());
mUIScale.pop_back(); mUIScale.pop_back();
} }
@@ -1555,7 +1547,7 @@ LLVector3 LLRender::getUITranslation()
{ {
return LLVector3(0,0,0); return LLVector3(0,0,0);
} }
return LLVector3(mUIOffset.back()->getF32ptr()); return LLVector3(mUIOffset.back().getF32ptr());
} }
LLVector3 LLRender::getUIScale() LLVector3 LLRender::getUIScale()
@@ -1564,7 +1556,7 @@ LLVector3 LLRender::getUIScale()
{ {
return LLVector3(1,1,1); return LLVector3(1,1,1);
} }
return LLVector3(mUIScale.back()->getF32ptr()); return LLVector3(mUIScale.back().getF32ptr());
} }
@@ -1574,8 +1566,8 @@ void LLRender::loadUIIdentity()
{ {
llerrs << "Need to push UI translation frame before clearing offset." << llendl; llerrs << "Need to push UI translation frame before clearing offset." << llendl;
} }
mUIOffset.back()->splat(0.f); mUIOffset.back().splat(0.f);
mUIScale.back()->splat(1.f); mUIScale.back().splat(1.f);
} }
void LLRender::setColorMask(bool writeColor, bool writeAlpha) void LLRender::setColorMask(bool writeColor, bool writeAlpha)
@@ -1977,8 +1969,8 @@ void LLRender::vertex4a(const LLVector4a& vertex)
else else
{ {
//LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back()); //LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back());
mVerticesp[mCount].setAdd(vertex,*mUIOffset.back()); mVerticesp[mCount].setAdd(vertex,mUIOffset.back());
mVerticesp[mCount].mul(*mUIScale.back()); mVerticesp[mCount].mul(mUIScale.back());
} }
if (mMode == LLRender::QUADS && LLRender::sGLCoreProfile) if (mMode == LLRender::QUADS && LLRender::sGLCoreProfile)

View File

@@ -38,6 +38,7 @@
#include "v3math.h" #include "v3math.h"
#include "v4coloru.h" #include "v4coloru.h"
#include "v4math.h" #include "v4math.h"
#include "llalignedarray.h"
#include "llstrider.h" #include "llstrider.h"
#include "llpointer.h" #include "llpointer.h"
#include "llglheaders.h" #include "llglheaders.h"
@@ -466,9 +467,8 @@ private:
F32 mMaxAnisotropy; F32 mMaxAnisotropy;
std::vector<LLVector4a*> mUIOffset; LLAlignedArray<LLVector4a, 64> mUIOffset;
std::vector<LLVector4a*> mUIScale; LLAlignedArray<LLVector4a, 64> mUIScale;
}; };
extern F32 gGLModelView[16]; extern F32 gGLModelView[16];