summaryrefslogtreecommitdiff
path: root/indra/llrender/llrender.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2010-06-03 12:53:11 -0500
committerDave Parks <davep@lindenlab.com>2010-06-03 12:53:11 -0500
commit64d51dbc4482c12bc1ae56598b924cfe6f0ff0e9 (patch)
tree482cc191426a9332d3b900b7f8136f6a340ddb64 /indra/llrender/llrender.cpp
parent8b16faec3096e32b76b227efcb67fd33e7254f40 (diff)
parent26ba00b5554d20ee958693ced87b36fa7f6e3d99 (diff)
merge
Diffstat (limited to 'indra/llrender/llrender.cpp')
-rw-r--r--indra/llrender/llrender.cpp97
1 files changed, 57 insertions, 40 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 2472339ec4..3f70ccacb1 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -39,6 +39,7 @@
#include "llimagegl.h"
#include "llrendertarget.h"
#include "lltexture.h"
+#include "llvector4a.h"
LLRender gGL;
@@ -53,6 +54,7 @@ U32 LLRender::sUICalls = 0;
U32 LLRender::sUIVerts = 0;
static const U32 LL_NUM_TEXTURE_LAYERS = 16;
+static const U32 LL_MAX_UI_STACK_DEPTH = 32;
static GLenum sGLTextureType[] =
{
@@ -757,14 +759,27 @@ LLRender::LLRender()
mCount(0),
mMode(LLRender::TRIANGLES),
mCurrTextureUnitIndex(0),
- mMaxAnisotropy(0.f)
+ mMaxAnisotropy(0.f),
+ mUIStackDepth(0)
{
mBuffer = new LLVertexBuffer(immediate_mask, 0);
mBuffer->allocateBuffer(4096, 0, TRUE);
- mBuffer->getVertexStrider(mVerticesp);
- mBuffer->getTexCoord0Strider(mTexcoordsp);
- mBuffer->getColorStrider(mColorsp);
-
+
+ LLStrider<LLVector3> vert;
+ LLStrider<LLVector2> tc;
+ LLStrider<LLColor4U> color;
+
+ mBuffer->getVertexStrider(vert);
+ mBuffer->getTexCoord0Strider(tc);
+ mBuffer->getColorStrider(color);
+
+ mVerticesp = (LLVector4a*) vert.get();
+ 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);
+
mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS);
for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++)
{
@@ -800,6 +815,11 @@ void LLRender::shutdown()
mTexUnits.clear();
delete mDummyTexUnit;
mDummyTexUnit = NULL;
+
+ _mm_free(mUIOffset);
+ mUIOffset = NULL;
+ _mm_free(mUIScale);
+ mUIScale = NULL;
}
void LLRender::refreshState(void)
@@ -848,84 +868,83 @@ void LLRender::popMatrix()
void LLRender::translateUI(F32 x, F32 y, F32 z)
{
- if (mUIOffset.empty())
+ if (mUIStackDepth == 0)
{
llerrs << "Need to push a UI translation frame before offsetting" << llendl;
}
- mUIOffset.front().mV[0] += x;
- mUIOffset.front().mV[1] += y;
- mUIOffset.front().mV[2] += z;
+ LLVector4a trans(x,y,z);
+ mUIOffset[mUIStackDepth-1].add(trans);
}
void LLRender::scaleUI(F32 x, F32 y, F32 z)
{
- if (mUIScale.empty())
+ if (mUIStackDepth == 0)
{
llerrs << "Need to push a UI transformation frame before scaling." << llendl;
}
- mUIScale.front().scaleVec(LLVector3(x,y,z));
+ LLVector4a scale(x,y,z);
+ mUIScale[mUIStackDepth-1].mul(scale);
}
void LLRender::pushUIMatrix()
{
- if (mUIOffset.empty())
+ if (mUIStackDepth == 0)
{
- mUIOffset.push_front(LLVector3(0,0,0));
+ mUIOffset[0].clear();
+ mUIScale[0].splat(1.f);
}
- else
+ else if (mUIStackDepth < LL_MAX_UI_STACK_DEPTH)
{
- mUIOffset.push_front(mUIOffset.front());
- }
-
- if (mUIScale.empty())
- {
- mUIScale.push_front(LLVector3(1,1,1));
+ mUIOffset[mUIStackDepth] = mUIOffset[mUIStackDepth-1];
+ mUIScale[mUIStackDepth] = mUIScale[mUIStackDepth-1];
}
else
{
- mUIScale.push_front(mUIScale.front());
+ llerrs << "Blown UI matrix stack." << llendl;
}
+
+ ++mUIStackDepth;
+
}
void LLRender::popUIMatrix()
{
- if (mUIOffset.empty())
+ if (mUIStackDepth == 0)
{
llerrs << "UI offset stack blown." << llendl;
}
- mUIOffset.pop_front();
- mUIScale.pop_front();
+ --mUIStackDepth;
}
LLVector3 LLRender::getUITranslation()
{
- if (mUIOffset.empty())
+ if (mUIStackDepth == 0)
{
llerrs << "UI offset stack empty." << llendl;
}
- return mUIOffset.front();
+ return LLVector3(mUIOffset[mUIStackDepth-1].getF32());
}
LLVector3 LLRender::getUIScale()
{
- if (mUIScale.empty())
+ if (mUIStackDepth == 0)
{
llerrs << "UI scale stack empty." << llendl;
}
- return mUIScale.front();
+ return LLVector3(mUIScale[mUIStackDepth-1].getF32());
}
void LLRender::loadUIIdentity()
{
- if (mUIOffset.empty())
+ if (mUIStackDepth == 0)
{
llerrs << "Need to push UI translation frame before clearing offset." << llendl;
}
- mUIOffset.front().setVec(0,0,0);
- mUIScale.front().setVec(1,1,1);
+ mUIOffset[mUIStackDepth-1].clear();
+ mUIScale[mUIStackDepth-1].splat(1.f);
}
void LLRender::setColorMask(bool writeColor, bool writeAlpha)
@@ -1154,7 +1173,7 @@ void LLRender::flush()
}
#endif
- if (!mUIOffset.empty())
+ if (mUIStackDepth > 0)
{
sUICalls++;
sUIVerts += mCount;
@@ -1206,24 +1225,22 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
return;
}
- if (mUIOffset.empty())
+ LLVector3& v = reinterpret_cast<LLVector3&>(mVerticesp[mCount]);
+ v.set(x,y,z);
+ if (mUIStackDepth != 0)
{
- mVerticesp[mCount] = LLVector3(x,y,z);
- }
- else
- {
- LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.front()).scaledVec(mUIScale.front());
- mVerticesp[mCount] = vert;
+ v += reinterpret_cast<LLVector3&>(mUIOffset[mUIStackDepth-1]);
+ v.scaleVec(reinterpret_cast<LLVector3&>(mUIScale[mUIStackDepth-1]));
}
mCount++;
if (mCount < 4096)
{
- mVerticesp[mCount] = mVerticesp[mCount-1];
mColorsp[mCount] = mColorsp[mCount-1];
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
}
}
+
void LLRender::vertex2i(const GLint& x, const GLint& y)
{
vertex3f((GLfloat) x, (GLfloat) y, 0);