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.cpp127
1 files changed, 64 insertions, 63 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index a0209fab43..633a453ab0 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -50,6 +50,8 @@ extern void APIENTRY gl_debug_callback(GLenum source,
thread_local LLRender gGL;
+const U32 BATCH_SIZE = 16334;
+
// Handy copies of last good GL matrices
F32 gGLModelView[16];
F32 gGLLastModelView[16];
@@ -66,7 +68,7 @@ S32 gGLViewport[4];
U32 LLRender::sUICalls = 0;
U32 LLRender::sUIVerts = 0;
U32 LLTexUnit::sWhiteTexture = 0;
-bool LLRender::sGLCoreProfile = false;
+bool LLRender::sGLCoreProfile = true;
bool LLRender::sNsightDebugSupport = false;
LLVector2 LLRender::sUIGLScaleFactor = LLVector2(1.f, 1.f);
@@ -81,10 +83,16 @@ static std::unordered_map<U64, LLVBCache> sVBCache;
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
};
@@ -522,17 +530,18 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio
{
if (LLImageGL::sGlobalUseAnisotropic && option == TFO_ANISOTROPIC)
{
- glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, gGLManager.mMaxAnisotropy);
+ glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY_EXT, gGLManager.mMaxAnisotropy);
}
else
{
- glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, 1.f);
+ glTexParameterf(sGLTextureType[mCurrTexType], 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.
@@ -547,8 +556,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:
@@ -567,6 +578,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)
@@ -613,7 +625,9 @@ void LLTexUnit::setColorScale(S32 scale)
{
mCurrColorScale = scale;
gGL.flush();
+#if GL_VERSION_1_1
glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE, scale );
+#endif
}
}
@@ -623,7 +637,9 @@ void LLTexUnit::setAlphaScale(S32 scale)
{
mCurrAlphaScale = scale;
gGL.flush();
+#if GL_VERSION_1_1
glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale );
+#endif
}
}
@@ -877,7 +893,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)
@@ -904,7 +922,7 @@ void LLRender::initVertexBuffer()
llassert_always(mBuffer.isNull());
stop_glerror();
mBuffer = new LLVertexBuffer(immediate_mask);
- mBuffer->allocateBuffer(4096, 0);
+ mBuffer->allocateBuffer(BATCH_SIZE, 0);
mBuffer->getVertexStrider(mVerticesp);
mBuffer->getTexCoord0Strider(mTexcoordsp);
mBuffer->getColorStrider(mColorsp);
@@ -1319,9 +1337,8 @@ void LLRender::translateUI(F32 x, F32 y, F32 z)
LL_ERRS() << "Need to push a UI translation frame before offsetting" << LL_ENDL;
}
- mUIOffset.back().mV[0] += x;
- mUIOffset.back().mV[1] += y;
- mUIOffset.back().mV[2] += z;
+ LLVector4a add(x,y,z);
+ mUIOffset.back().add(add);
}
void LLRender::scaleUI(F32 x, F32 y, F32 z)
@@ -1331,14 +1348,15 @@ void LLRender::scaleUI(F32 x, F32 y, F32 z)
LL_ERRS() << "Need to push a UI transformation frame before scaling." << LL_ENDL;
}
- mUIScale.back().scaleVec(LLVector3(x,y,z));
+ LLVector4a scale(x,y,z);
+ mUIScale.back().mul(scale);
}
void LLRender::pushUIMatrix()
{
if (mUIOffset.empty())
{
- mUIOffset.push_back(LLVector3(0,0,0));
+ mUIOffset.emplace_back(LLVector4a::getZero());
}
else
{
@@ -1347,7 +1365,7 @@ void LLRender::pushUIMatrix()
if (mUIScale.empty())
{
- mUIScale.push_back(LLVector3(1,1,1));
+ mUIScale.emplace_back(LLVector4a(1.f));
}
else
{
@@ -1371,7 +1389,7 @@ LLVector3 LLRender::getUITranslation()
{
return LLVector3(0,0,0);
}
- return mUIOffset.back();
+ return LLVector3(mUIOffset.back().getF32ptr());
}
LLVector3 LLRender::getUIScale()
@@ -1380,18 +1398,17 @@ LLVector3 LLRender::getUIScale()
{
return LLVector3(1,1,1);
}
- return mUIScale.back();
+ return LLVector3(mUIScale.back().getF32ptr());
}
-
void LLRender::loadUIIdentity()
{
if (mUIOffset.empty())
{
LL_ERRS() << "Need to push UI translation frame before clearing offset." << LL_ENDL;
}
- mUIOffset.back().setVec(0,0,0);
- mUIScale.back().setVec(1,1,1);
+ mUIOffset.back().splat(0.f);
+ mUIScale.back().splat(1.f);
}
void LLRender::setColorMask(bool writeColor, bool writeAlpha)
@@ -1580,7 +1597,7 @@ void LLRender::end()
mMode != LLRender::LINES &&
mMode != LLRender::TRIANGLES &&
mMode != LLRender::POINTS) ||
- mCount > 2048)
+ mCount > (BATCH_SIZE / 2))
{
flush();
}
@@ -1601,28 +1618,28 @@ void LLRender::flush()
//store mCount in a local variable to avoid re-entrance (drawArrays may call flush)
U32 count = mCount;
- if (mMode == LLRender::QUADS && !sGLCoreProfile)
+ if (mMode == LLRender::QUADS && !sGLCoreProfile)
+ {
+ if (mCount%4 != 0)
{
- if (mCount%4 != 0)
- {
count -= (mCount % 4);
LL_WARNS() << "Incomplete quad requested." << LL_ENDL;
- }
}
+ }
- if (mMode == LLRender::TRIANGLES)
+ if (mMode == LLRender::TRIANGLES)
+ {
+ if (mCount%3 != 0)
{
- if (mCount%3 != 0)
- {
count -= (mCount % 3);
LL_WARNS() << "Incomplete triangle requested." << LL_ENDL;
- }
}
+ }
- if (mMode == LLRender::LINES)
+ if (mMode == LLRender::LINES)
+ {
+ if (mCount%2 != 0)
{
- if (mCount%2 != 0)
- {
count -= (mCount % 2);
LL_WARNS() << "Incomplete line requested." << LL_ENDL;
}
@@ -1684,7 +1701,7 @@ void LLRender::flush()
vb->setBuffer();
- vb->setPositionData((LLVector4a*) mVerticesp.get());
+ vb->setPositionData(mVerticesp.get());
if (attribute_mask & LLVertexBuffer::MAP_TEXCOORD0)
{
@@ -1696,9 +1713,12 @@ void LLRender::flush()
vb->setColorData(mColorsp.get());
}
-#if LL_DARWIN
- vb->unmapBuffer();
-#endif
+ //LL_INFOS() << "LLVertexBuffer::sMappingMode " << LLVertexBuffer::sMappingMode << LL_ENDL;
+ if(LLVertexBuffer::sMappingMode == 3)
+ {
+ vb->unmapBuffer();
+ }
+
vb->unbind();
sVBCache[vhash] = { vb , std::chrono::steady_clock::now() };
@@ -1754,10 +1774,10 @@ void LLRender::flush()
}
}
-void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
+void LLRender::vertex4a(const LLVector4a& vertex)
{
//the range of mVerticesp, mColorsp and mTexcoordsp is [0, 4095]
- if (mCount > 2048)
+ if (mCount > BATCH_SIZE / 2)
{ //break when buffer gets reasonably full to keep GL command buffers happy and avoid overflow below
switch (mMode)
{
@@ -1768,20 +1788,20 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
}
}
- if (mCount > 4094)
+ if (mCount > BATCH_SIZE - 2)
{
- // LL_WARNS() << "GL immediate mode overflow. Some geometry not drawn." << LL_ENDL;
+ LL_WARNS() << "GL immediate mode overflow. Some geometry not drawn." << LL_ENDL;
return;
}
if (mUIOffset.empty())
{
- mVerticesp[mCount] = LLVector3(x,y,z);
+ mVerticesp[mCount] = vertex;
}
else
{
- LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back());
- mVerticesp[mCount] = vert;
+ mVerticesp[mCount].setAdd(vertex, mUIOffset.back());
+ mVerticesp[mCount].mul(mUIScale.back());
}
if (mMode == LLRender::QUADS && LLRender::sGLCoreProfile)
@@ -1809,9 +1829,9 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
}
-void LLRender::vertexBatchPreTransformed(LLVector3* verts, S32 vert_count)
+void LLRender::vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count)
{
- if (mCount + vert_count > 4094)
+ if (mCount + vert_count > BATCH_SIZE - 2)
{
// LL_WARNS() << "GL immediate mode overflow. Some geometry not drawn." << LL_ENDL;
return;
@@ -1867,9 +1887,9 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, S32 vert_count)
mVerticesp[mCount] = mVerticesp[mCount-1];
}
-void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count)
+void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 vert_count)
{
- if (mCount + vert_count > 4094)
+ if (mCount + vert_count > BATCH_SIZE - 2)
{
// LL_WARNS() << "GL immediate mode overflow. Some geometry not drawn." << LL_ENDL;
return;
@@ -1928,9 +1948,9 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 v
}
}
-void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLColor4U* colors, S32 vert_count)
+void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLColor4U* colors, S32 vert_count)
{
- if (mCount + vert_count > 4094)
+ if (mCount + vert_count > BATCH_SIZE - 2)
{
// LL_WARNS() << "GL immediate mode overflow. Some geometry not drawn." << LL_ENDL;
return;
@@ -1991,25 +2011,6 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLCol
}
}
-void LLRender::vertex2i(const GLint& x, const GLint& y)
-{
- vertex3f((GLfloat) x, (GLfloat) y, 0);
-}
-
-void LLRender::vertex2f(const GLfloat& x, const GLfloat& y)
-{
- vertex3f(x,y,0);
-}
-
-void LLRender::vertex2fv(const GLfloat* v)
-{
- vertex3f(v[0], v[1], 0);
-}
-
-void LLRender::vertex3fv(const GLfloat* v)
-{
- vertex3f(v[0], v[1], v[2]);
-}
void LLRender::texCoord2f(const GLfloat& x, const GLfloat& y)
{