Fixed numerous bugs.
This commit is contained in:
@@ -59,9 +59,7 @@ static const U32 LL_NUM_LIGHT_UNITS = 8;
|
||||
static const GLenum sGLTextureType[] =
|
||||
{
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE_RECTANGLE_ARB,
|
||||
GL_TEXTURE_CUBE_MAP_ARB
|
||||
//,GL_TEXTURE_2D_MULTISAMPLE Don't use.
|
||||
};
|
||||
|
||||
static const GLint sGLAddressMode[] =
|
||||
@@ -171,7 +169,7 @@ void LLTexUnit::activate(void)
|
||||
|
||||
if ((S32)gGL.mCurrTextureUnitIndex != mIndex || gGL.mDirty)
|
||||
{
|
||||
gGL.flush();
|
||||
//gGL.flush();
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + mIndex);
|
||||
gGL.mCurrTextureUnitIndex = mIndex;
|
||||
}
|
||||
@@ -230,7 +228,7 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind)
|
||||
stop_glerror();
|
||||
if (mIndex >= 0)
|
||||
{
|
||||
gGL.flush();
|
||||
//gGL.flush();
|
||||
|
||||
LLImageGL* gl_tex = NULL ;
|
||||
|
||||
@@ -344,8 +342,6 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap)
|
||||
{
|
||||
if (mIndex < 0) return false;
|
||||
|
||||
gGL.flush();
|
||||
|
||||
if (cubeMap == NULL)
|
||||
{
|
||||
LL_WARNS() << "NULL LLTexUnit::bind cubemap" << LL_ENDL;
|
||||
@@ -361,6 +357,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap)
|
||||
{
|
||||
if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)
|
||||
{
|
||||
gGL.flush();
|
||||
activate();
|
||||
enable(LLTexUnit::TT_CUBE_MAP);
|
||||
mCurrTexture = cubeMap->mImages[0]->getTexName();
|
||||
@@ -390,7 +387,7 @@ bool LLTexUnit::bind(LLRenderTarget* renderTarget, bool bindDepth)
|
||||
{
|
||||
if (mIndex < 0) return false;
|
||||
|
||||
gGL.flush();
|
||||
//gGL.flush();
|
||||
|
||||
if (bindDepth)
|
||||
{
|
||||
@@ -438,12 +435,16 @@ void LLTexUnit::unbind(eTextureType type)
|
||||
|
||||
//always flush and activate for consistency
|
||||
// some code paths assume unbind always flushes and sets the active texture
|
||||
gGL.flush();
|
||||
activate();
|
||||
if (gGL.mCurrTextureUnitIndex != mIndex || gGL.mDirty)
|
||||
{
|
||||
gGL.flush();
|
||||
activate();
|
||||
}
|
||||
|
||||
// Disabled caching of binding state.
|
||||
if (mCurrTexType == type)
|
||||
if (mCurrTexType == type && mCurrTexture != 0)
|
||||
{
|
||||
gGL.flush();
|
||||
mCurrTexture = 0;
|
||||
if (LLGLSLShader::sNoFixedFunction && type == LLTexUnit::TT_TEXTURE)
|
||||
{
|
||||
@@ -1044,6 +1045,7 @@ LLRender::LLRender()
|
||||
mMode(LLRender::TRIANGLES),
|
||||
mCurrTextureUnitIndex(0),
|
||||
mMaxAnisotropy(0.f),
|
||||
mLineWidth(1.f),
|
||||
mPrimitiveReset(false)
|
||||
{
|
||||
mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS);
|
||||
@@ -1663,8 +1665,6 @@ bool LLRender::unprojectf(const LLVector3& windowCoordinate, const LLMatrix4a& m
|
||||
|
||||
void LLRender::pushMatrix()
|
||||
{
|
||||
flush();
|
||||
|
||||
{
|
||||
if (mMatIdx[mMatrixMode] < LL_MATRIX_STACK_DEPTH-1)
|
||||
{
|
||||
@@ -1680,15 +1680,19 @@ void LLRender::pushMatrix()
|
||||
|
||||
void LLRender::popMatrix()
|
||||
{
|
||||
flush();
|
||||
{
|
||||
if (mMatIdx[mMatrixMode] > 0)
|
||||
{
|
||||
if ( memcmp(mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].getF32ptr(), mMatrix[mMatrixMode][mMatIdx[mMatrixMode] - 1].getF32ptr(), sizeof(LLMatrix4a)) )
|
||||
{
|
||||
flush();
|
||||
}
|
||||
--mMatIdx[mMatrixMode];
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
flush();
|
||||
LL_WARNS() << "Matrix stack underflow." << LL_ENDL;
|
||||
}
|
||||
}
|
||||
@@ -1697,6 +1701,7 @@ void LLRender::popMatrix()
|
||||
void LLRender::loadMatrix(const LLMatrix4a& mat)
|
||||
{
|
||||
flush();
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] = mat;
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
@@ -1772,6 +1777,18 @@ void LLRender::scaleUI(F32 x, F32 y, F32 z)
|
||||
mUIScale.back().mul(scale);
|
||||
}
|
||||
|
||||
void LLRender::rotateUI(LLQuaternion& rot)
|
||||
{
|
||||
if (mUIRotation.empty())
|
||||
{
|
||||
mUIRotation.push_back(rot);
|
||||
}
|
||||
else
|
||||
{
|
||||
mUIRotation.push_back(mUIRotation.back()*rot);
|
||||
}
|
||||
}
|
||||
|
||||
void LLRender::pushUIMatrix()
|
||||
{
|
||||
if (mUIOffset.empty())
|
||||
@@ -1791,6 +1808,10 @@ void LLRender::pushUIMatrix()
|
||||
{
|
||||
mUIScale.push_back(mUIScale.back());
|
||||
}
|
||||
if (!mUIRotation.empty())
|
||||
{
|
||||
mUIRotation.push_back(mUIRotation.back());
|
||||
}
|
||||
}
|
||||
|
||||
void LLRender::popUIMatrix()
|
||||
@@ -1801,6 +1822,10 @@ void LLRender::popUIMatrix()
|
||||
}
|
||||
mUIOffset.pop_back();
|
||||
mUIScale.pop_back();
|
||||
if (!mUIRotation.empty())
|
||||
{
|
||||
mUIRotation.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
LLVector3 LLRender::getUITranslation()
|
||||
@@ -1830,6 +1855,8 @@ void LLRender::loadUIIdentity()
|
||||
}
|
||||
mUIOffset.back().splat(0.f);
|
||||
mUIScale.back().splat(1.f);
|
||||
if (!mUIRotation.empty())
|
||||
mUIRotation.push_back(LLQuaternion());
|
||||
}
|
||||
|
||||
void LLRender::setColorMask(bool writeColor, bool writeAlpha)
|
||||
@@ -1839,8 +1866,6 @@ void LLRender::setColorMask(bool writeColor, bool writeAlpha)
|
||||
|
||||
void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB, bool writeAlpha)
|
||||
{
|
||||
flush();
|
||||
|
||||
if (mCurrColorMask[0] != writeColorR ||
|
||||
mCurrColorMask[1] != writeColorG ||
|
||||
mCurrColorMask[2] != writeColorB ||
|
||||
@@ -1851,6 +1876,7 @@ void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB
|
||||
mCurrColorMask[2] = writeColorB;
|
||||
mCurrColorMask[3] = writeAlpha;
|
||||
|
||||
flush();
|
||||
glColorMask(writeColorR ? GL_TRUE : GL_FALSE,
|
||||
writeColorG ? GL_TRUE : GL_FALSE,
|
||||
writeColorB ? GL_TRUE : GL_FALSE,
|
||||
@@ -1891,8 +1917,6 @@ void LLRender::setSceneBlendType(eBlendType type)
|
||||
|
||||
void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
|
||||
{
|
||||
flush();
|
||||
|
||||
if (LLGLSLShader::sNoFixedFunction)
|
||||
{ //glAlphaFunc is deprecated in OpenGL 3.3
|
||||
return;
|
||||
@@ -1901,6 +1925,7 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
|
||||
if (mCurrAlphaFunc != func ||
|
||||
mCurrAlphaFuncVal != value || mDirty)
|
||||
{
|
||||
flush();
|
||||
mCurrAlphaFunc = func;
|
||||
mCurrAlphaFuncVal = value;
|
||||
if (func == CF_DEFAULT)
|
||||
@@ -2030,6 +2055,23 @@ void LLRender::setAmbientLightColor(const LLColor4& color)
|
||||
}
|
||||
}
|
||||
|
||||
void LLRender::setLineWidth(F32 line_width)
|
||||
{
|
||||
if (LLRender::sGLCoreProfile)
|
||||
{
|
||||
line_width = 1.f;
|
||||
}
|
||||
if (mLineWidth != line_width)
|
||||
{
|
||||
if (mMode == LLRender::LINES || LLRender::LINE_STRIP)
|
||||
{
|
||||
flush();
|
||||
}
|
||||
mLineWidth = line_width;
|
||||
glLineWidth(line_width);
|
||||
}
|
||||
}
|
||||
|
||||
bool LLRender::verifyTexUnitActive(U32 unitToVerify)
|
||||
{
|
||||
if (mCurrTextureUnitIndex == unitToVerify)
|
||||
@@ -2092,8 +2134,13 @@ void LLRender::end()
|
||||
mPrimitiveReset = true;
|
||||
}
|
||||
}
|
||||
|
||||
extern bool countFlushes;
|
||||
extern unsigned int flushCount;
|
||||
|
||||
void LLRender::flush()
|
||||
{
|
||||
if (countFlushes) ++flushCount;
|
||||
if (mCount > 0)
|
||||
{
|
||||
#if 0
|
||||
@@ -2236,13 +2283,33 @@ void LLRender::vertex4a(const LLVector4a& vertex)
|
||||
|
||||
if (mUIOffset.empty())
|
||||
{
|
||||
mVerticesp[mCount]=vertex;
|
||||
if (!mUIRotation.empty() && mUIRotation.back().isNotIdentity())
|
||||
{
|
||||
LLVector4 vert(vertex.getF32ptr());
|
||||
mVerticesp[mCount].loadua((vert*mUIRotation.back()).mV);
|
||||
}
|
||||
else
|
||||
{
|
||||
mVerticesp[mCount] = vertex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back());
|
||||
mVerticesp[mCount].setAdd(vertex,mUIOffset.back());
|
||||
mVerticesp[mCount].mul(mUIScale.back());
|
||||
if (!mUIRotation.empty() && mUIRotation.back().isNotIdentity())
|
||||
{
|
||||
LLVector4 vert(vertex.getF32ptr());
|
||||
vert = vert * mUIRotation.back();
|
||||
LLVector4a postrot_vert;
|
||||
postrot_vert.loadua(vert.mV);
|
||||
mVerticesp[mCount].setAdd(postrot_vert, mUIOffset.back());
|
||||
mVerticesp[mCount].mul(mUIScale.back());
|
||||
}
|
||||
else
|
||||
{
|
||||
//LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back());
|
||||
mVerticesp[mCount].setAdd(vertex, mUIOffset.back());
|
||||
mVerticesp[mCount].mul(mUIScale.back());
|
||||
}
|
||||
}
|
||||
|
||||
mCount++;
|
||||
|
||||
Reference in New Issue
Block a user