Fixed numerous bugs.
This commit is contained in:
@@ -487,10 +487,20 @@ void LLFontFreetype::renderGlyph(const U32 glyph_index) const
|
||||
if (mFTFace == NULL)
|
||||
return;
|
||||
|
||||
llassert_always(! FT_Load_Glyph(mFTFace, glyph_index, FT_LOAD_DEFAULT));
|
||||
|
||||
llassert_always(! FT_Render_Glyph(mFTFace->glyph, gFontRenderMode) );
|
||||
|
||||
FT_Error error = FT_Load_Glyph(mFTFace, glyph_index, FT_LOAD_DEFAULT);
|
||||
#ifdef SHOW_ASSERT
|
||||
if (error)
|
||||
{
|
||||
LL_ERRS() << "FT_Load_Glyph returned " << error << LL_ENDL;
|
||||
}
|
||||
#endif
|
||||
error = FT_Render_Glyph(mFTFace->glyph, gFontRenderMode);
|
||||
#ifdef SHOW_ASSERT
|
||||
if (error)
|
||||
{
|
||||
LL_ERRS() << "FT_Render_Glyph returned " << error << LL_ENDL;
|
||||
}
|
||||
#endif
|
||||
mRenderGlyphCount++;
|
||||
}
|
||||
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -65,7 +65,6 @@ public:
|
||||
{
|
||||
TT_TEXTURE = 0, // Standard 2D Texture
|
||||
TT_CUBE_MAP, // 6-sided cube map texture
|
||||
//TT_MULTISAMPLE_TEXTURE, // see GL_ARB_texture_multisample Do not use
|
||||
TT_NONE // No texture type is currently enabled
|
||||
} eTextureType;
|
||||
|
||||
@@ -380,6 +379,8 @@ public:
|
||||
|
||||
void translateUI(F32 x, F32 y, F32 z);
|
||||
void scaleUI(F32 x, F32 y, F32 z);
|
||||
// Rotates vertices, pre-translation/scale
|
||||
void rotateUI(LLQuaternion& rot);
|
||||
void pushUIMatrix();
|
||||
void popUIMatrix();
|
||||
void loadUIIdentity();
|
||||
@@ -435,6 +436,8 @@ public:
|
||||
LLLightState* getLight(U32 index);
|
||||
void setAmbientLightColor(const LLColor4& color);
|
||||
|
||||
void setLineWidth(F32 line_width);
|
||||
|
||||
LLTexUnit* getTexUnit(U32 index);
|
||||
|
||||
U32 getCurrentTexUnitIndex(void) const { return mCurrTextureUnitIndex; }
|
||||
@@ -475,6 +478,7 @@ private:
|
||||
bool mCurrColorMask[4];
|
||||
eCompareFunc mCurrAlphaFunc;
|
||||
F32 mCurrAlphaFuncVal;
|
||||
F32 mLineWidth;
|
||||
|
||||
LLPointer<LLVertexBuffer> mBuffer;
|
||||
LLStrider<LLVector4a> mVerticesp;
|
||||
@@ -493,6 +497,7 @@ private:
|
||||
|
||||
std::vector<LLVector4a, boost::alignment::aligned_allocator<LLVector4a, 64> > mUIOffset;
|
||||
std::vector<LLVector4a, boost::alignment::aligned_allocator<LLVector4a, 64> > mUIScale;
|
||||
std::vector<LLQuaternion> mUIRotation;
|
||||
|
||||
bool mPrimitiveReset;
|
||||
} LL_ALIGN_POSTFIX(16);
|
||||
|
||||
@@ -490,7 +490,6 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
|
||||
gGL.getTexUnit(0)->bind(image, true);
|
||||
|
||||
gGL.color4fv(color.mV);
|
||||
gGL.diffuseColor4fv(color.mV); //workaround: Intel HD 4000
|
||||
|
||||
const S32 NUM_VERTICES = (2 + 2 * 3) * 3 + 4;
|
||||
LLVector2 uv[NUM_VERTICES];
|
||||
@@ -894,12 +893,11 @@ void gl_ring( F32 radius, F32 width, const LLColor4& center_color, const LLColor
|
||||
if( render_center )
|
||||
{
|
||||
gGL.color4fv(center_color.mV);
|
||||
gGL.diffuseColor4fv(center_color.mV);
|
||||
gl_deep_circle( radius, width, steps );
|
||||
}
|
||||
else
|
||||
{
|
||||
gGL.diffuseColor4fv(side_color.mV);
|
||||
gGL.color4fv(side_color.mV);
|
||||
gl_washer_2d(radius - width, radius, steps, side_color, side_color);
|
||||
gGL.translateUI(0.f, 0.f, width);
|
||||
gl_washer_2d(radius, radius - width, steps, side_color, side_color);
|
||||
@@ -1520,8 +1518,7 @@ void LLRender2D::setScaleFactor(const LLVector2 &scale_factor)
|
||||
//static
|
||||
void LLRender2D::setLineWidth(F32 width)
|
||||
{
|
||||
gGL.flush();
|
||||
glLineWidth(width * lerp(sGLScaleFactor.mV[VX], sGLScaleFactor.mV[VY], 0.5f));
|
||||
gGL.setLineWidth(width * lerp(sGLScaleFactor.mV[VX], sGLScaleFactor.mV[VY], 0.5f));
|
||||
}
|
||||
|
||||
//static
|
||||
|
||||
@@ -538,7 +538,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
range = mShaderObjects.equal_range(filename);
|
||||
for (std::multimap<std::string, CachedObjectInfo>::iterator it = range.first; it != range.second;++it)
|
||||
{
|
||||
if((*it).second.mLevel == shader_level && (*it).second.mType == type && (*it).second.mDefinitions == (defines ? *defines : std::map<std::string, std::string>()))
|
||||
if((*it).second.mLevel == shader_level && (*it).second.mType == type && (*it).second.mIndexChannels == texture_index_channels && (*it).second.mDefinitions == (defines ? *defines : std::map<std::string, std::string>()))
|
||||
{
|
||||
//LL_INFOS("ShaderLoading") << "Loading cached shader for " << filename << LL_ENDL;
|
||||
return (*it).second.mHandle;
|
||||
@@ -935,7 +935,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
if (ret)
|
||||
{
|
||||
// Add shader file to map
|
||||
mShaderObjects.insert(make_pair(filename,CachedObjectInfo(ret,try_gpu_class,type,defines)));
|
||||
mShaderObjects.insert(make_pair(filename,CachedObjectInfo(ret,try_gpu_class,type, texture_index_channels,defines)));
|
||||
shader_level = try_gpu_class;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -242,11 +242,12 @@ DISPLAY_GAMMA,
|
||||
public:
|
||||
struct CachedObjectInfo
|
||||
{
|
||||
CachedObjectInfo(GLhandleARB handle, U32 level, GLenum type, std::map<std::string,std::string> *definitions) :
|
||||
mHandle(handle), mLevel(level), mType(type), mDefinitions(definitions ? *definitions : std::map<std::string,std::string>()){}
|
||||
CachedObjectInfo(GLhandleARB handle, U32 level, GLenum type, U32 texture_index_channels, std::map<std::string,std::string> *definitions) :
|
||||
mHandle(handle), mLevel(level), mType(type), mIndexChannels(texture_index_channels), mDefinitions(definitions ? *definitions : std::map<std::string,std::string>()){}
|
||||
GLhandleARB mHandle; //Actual handle of the opengl shader object.
|
||||
U32 mLevel; //Level /might/ not be needed, but it's stored to ensure there's no change in behavior.
|
||||
GLenum mType; //GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB. Tracked because some utility shaders can be loaded as both types (carefully).
|
||||
U32 mIndexChannels; //LLShaderFeatures::mIndexedTextureChannels
|
||||
std::map<std::string,std::string> mDefinitions;
|
||||
};
|
||||
// Map of shader names to compiled
|
||||
|
||||
Reference in New Issue
Block a user