summaryrefslogtreecommitdiff
path: root/indra/llrender/llrender.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llrender.cpp')
-rw-r--r--indra/llrender/llrender.cpp95
1 files changed, 71 insertions, 24 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 1dc87a66ce..332d15f76c 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -84,10 +84,16 @@ static thread_local std::list<LLVertexBufferData> *sBufferDataList = nullptr;
static const GLenum sGLTextureType[] =
{
GL_TEXTURE_2D,
+#if GL_VERSION_3_1
GL_TEXTURE_RECTANGLE,
+#endif
GL_TEXTURE_CUBE_MAP,
+#if GL_VERSION_4_0
GL_TEXTURE_CUBE_MAP_ARRAY,
+#endif
+#if GL_VERSION_3_2
GL_TEXTURE_2D_MULTISAMPLE,
+#endif
GL_TEXTURE_3D
};
@@ -197,6 +203,7 @@ void LLTexUnit::bindFast(LLTexture* texture)
glActiveTexture(GL_TEXTURE0 + mIndex);
gGL.mCurrTextureUnitIndex = mIndex;
mCurrTexture = gl_tex->getTexName();
+ mCurrTexType = gl_tex->getTarget();
if (!mCurrTexture)
{
LL_PROFILE_ZONE_NAMED("MISSING TEXTURE");
@@ -473,59 +480,70 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio
{
if (mIndex < 0 || mCurrTexture == 0 || mCurrTexType == LLTexUnit::TT_MULTISAMPLE_TEXTURE) return;
+ GLenum target = sGLTextureType[mCurrTexType];
+
+ if (mCurrTexType == LLTexUnit::TT_NONE)
+ {
+ LL_WARNS() << "setTextureFilteringOption() Error: mCurrTexType==TT_NONE texture: " << mCurrTexture << LL_ENDL;
+ gGL.debugTexUnits();
+ }
+
gGL.flush();
if (option == TFO_POINT)
{
- glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
else
{
- glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
if (option >= TFO_TRILINEAR && mHasMipMaps)
{
- glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
}
else if (option >= TFO_BILINEAR)
{
if (mHasMipMaps)
{
- glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
}
else
{
- glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
}
else
{
if (mHasMipMaps)
{
- glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
}
else
{
- glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
}
- if (gGLManager.mGLVersion >= 4.59f)
+ if (gGLManager.mHasAnisotropic)
{
if (LLImageGL::sGlobalUseAnisotropic && option == TFO_ANISOTROPIC)
{
- glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, gGLManager.mMaxAnisotropy);
+ //glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, gGLManager.mMaxAnisotropy);
+ //We plan to add a setting. For now we stick to a low value.
+ glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, 4.0);
}
else
{
- glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, 1.f);
+ glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f);
}
}
}
GLint LLTexUnit::getTextureSource(eTextureBlendSrc src)
{
+#if GL_VERSION_1_3
switch(src)
{
// All four cases should return the same value.
@@ -540,8 +558,10 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src)
case TBS_TEX_ALPHA:
case TBS_ONE_MINUS_TEX_COLOR:
case TBS_ONE_MINUS_TEX_ALPHA:
+#endif
return GL_TEXTURE;
+#if GL_VERSION_1_3
// All four cases should return the same value.
case TBS_VERT_COLOR:
case TBS_VERT_ALPHA:
@@ -560,6 +580,7 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src)
LL_WARNS() << "Unknown eTextureBlendSrc: " << src << ". Using Vertex Color instead." << LL_ENDL;
return GL_PRIMARY_COLOR;
}
+#endif
}
GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha)
@@ -606,7 +627,9 @@ void LLTexUnit::setColorScale(S32 scale)
{
mCurrColorScale = scale;
gGL.flush();
+#if GL_VERSION_1_1
glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE, scale );
+#endif
}
}
@@ -616,7 +639,9 @@ void LLTexUnit::setAlphaScale(S32 scale)
{
mCurrAlphaScale = scale;
gGL.flush();
+#if GL_VERSION_1_1
glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale );
+#endif
}
}
@@ -867,7 +892,9 @@ bool LLRender::init(bool needs_vertex_buffer)
glCullFace(GL_BACK);
// necessary for reflection maps
+#if GL_VERSION_3_2
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
+#endif
#if LL_WINDOWS
if (glGenVertexArrays == nullptr)
@@ -892,13 +919,12 @@ bool LLRender::init(bool needs_vertex_buffer)
void LLRender::initVertexBuffer()
{
llassert_always(mBuffer.isNull());
- stop_glerror();
mBuffer = new LLVertexBuffer(immediate_mask);
- mBuffer->allocateBuffer(4096, 0);
+ mBuffer->allocateBuffer(16384, 0);
mBuffer->getVertexStrider(mVerticesp);
mBuffer->getTexCoord0Strider(mTexcoordsp);
mBuffer->getColorStrider(mColorsp);
- stop_glerror();
+ LOG_GLERROR("LLRender::initVertexBuffer()");
}
void LLRender::resetVertexBuffer()
@@ -984,7 +1010,6 @@ void LLRender::syncLightState()
void LLRender::syncMatrices()
{
- STOP_GLERROR;
LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
static const U32 name[] =
@@ -1129,7 +1154,7 @@ void LLRender::syncMatrices()
syncLightState();
}
}
- STOP_GLERROR;
+ LOG_GLERROR("LLRender::syncMatrices()");
}
void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
@@ -1539,7 +1564,7 @@ void LLRender::begin(const GLuint& mode)
mMode == LLRender::TRIANGLES ||
mMode == LLRender::POINTS)
{
- flush();
+ flush("LLRender::begin");
}
else if (mCount != 0)
{
@@ -1550,7 +1575,7 @@ void LLRender::begin(const GLuint& mode)
}
}
-void LLRender::end()
+void LLRender::end(std::string comment_)
{
if (mCount == 0)
{
@@ -1563,13 +1588,12 @@ void LLRender::end()
mMode != LLRender::POINTS) ||
mCount > 2048)
{
- flush();
+ flush("from end " + comment_);
}
}
-void LLRender::flush()
+void LLRender::flush(std::string comment_)
{
- STOP_GLERROR;
if (mCount > 0)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
@@ -1638,9 +1662,16 @@ void LLRender::flush()
}
resetStriders(count);
+
+ LOG_GLERROR("LLRender::flush() end " + comment_);
}
}
+void LLRender::flush()
+{
+ flush("");
+}
+
LLVertexBuffer* LLRender::bufferfromCache(U32 attribute_mask, U32 count)
{
LLVertexBuffer *vb = nullptr;
@@ -1735,9 +1766,11 @@ LLVertexBuffer* LLRender::genBuffer(U32 attribute_mask, S32 count)
vb->setColorData(mColorsp.get());
}
-#if LL_DARWIN
+ if(gGLManager.mIsApple && LLVertexBuffer::getVertexBufferMode() == 0)
+ {
vb->unmapBuffer();
-#endif
+ }
+
vb->unbind();
return vb;
@@ -2010,7 +2043,8 @@ void LLRender::debugTexUnits(void)
std::string active_enabled = "false";
for (U32 i = 0; i < mTexUnits.size(); i++)
{
- if (getTexUnit(i)->mCurrTexType != LLTexUnit::TT_NONE)
+ //if (getTexUnit(i)->mCurrTexType != LLTexUnit::TT_NONE)
+ if(1)
{
if (i == mCurrTextureUnitIndex) active_enabled = "true";
LL_INFOS("TextureUnit") << "TexUnit: " << i << " Enabled" << LL_ENDL;
@@ -2020,14 +2054,27 @@ void LLRender::debugTexUnits(void)
case LLTexUnit::TT_TEXTURE:
LL_CONT << "Texture 2D";
break;
+#if GL_VERSION_3_1
case LLTexUnit::TT_RECT_TEXTURE:
LL_CONT << "Texture Rectangle";
break;
+#endif
case LLTexUnit::TT_CUBE_MAP:
LL_CONT << "Cube Map";
break;
+ case LLTexUnit::TT_CUBE_MAP_ARRAY:
+ LL_CONT << "Cube Map Array";
+ break;
+
+ case LLTexUnit::TT_MULTISAMPLE_TEXTURE:
+ LL_CONT << "Multisample Texture";
+ break;
+
+ case LLTexUnit::TT_TEXTURE_3D:
+ LL_CONT << "Texture 3D";
+ break;
default:
- LL_CONT << "ARGH!!! NONE!";
+ LL_CONT << "ARGH!!! NONE! -> type = " << getTexUnit(i)->mCurrTexType;
break;
}
LL_CONT << ", Texture Bound: " << getTexUnit(i)->mCurrTexture << LL_ENDL;