summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender')
-rwxr-xr-xindra/llrender/llgl.cpp40
-rwxr-xr-xindra/llrender/llglslshader.cpp17
-rwxr-xr-xindra/llrender/llrender.cpp28
-rwxr-xr-xindra/llrender/llrendertarget.cpp6
-rwxr-xr-xindra/llrender/llrendertarget.h2
-rwxr-xr-xindra/llrender/llshadermgr.cpp5
-rwxr-xr-xindra/llrender/llshadermgr.h6
-rwxr-xr-xindra/llrender/llvertexbuffer.cpp136
-rwxr-xr-xindra/llrender/llvertexbuffer.h3
9 files changed, 142 insertions, 101 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 00de61a8cc..acfb3c085a 100755
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -73,7 +73,6 @@ std::ofstream gFailLog;
#define APIENTRY
#endif
-
void APIENTRY gl_debug_callback(GLenum source,
GLenum type,
GLuint id,
@@ -84,24 +83,24 @@ void APIENTRY gl_debug_callback(GLenum source,
{
if (gGLDebugLoggingEnabled)
{
- if (severity == GL_DEBUG_SEVERITY_HIGH_ARB)
- {
- llwarns << "----- GL ERROR --------" << llendl;
- }
- else
- {
- llwarns << "----- GL WARNING -------" << llendl;
- }
- llwarns << "Type: " << std::hex << type << llendl;
- llwarns << "ID: " << std::hex << id << llendl;
- llwarns << "Severity: " << std::hex << severity << llendl;
- llwarns << "Message: " << message << llendl;
- llwarns << "-----------------------" << llendl;
- if (severity == GL_DEBUG_SEVERITY_HIGH_ARB)
- {
- llerrs << "Halting on GL Error" << llendl;
- }
+ if (severity == GL_DEBUG_SEVERITY_HIGH_ARB)
+ {
+ llwarns << "----- GL ERROR --------" << llendl;
+ }
+ else
+ {
+ llwarns << "----- GL WARNING -------" << llendl;
}
+ llwarns << "Type: " << std::hex << type << llendl;
+ llwarns << "ID: " << std::hex << id << llendl;
+ llwarns << "Severity: " << std::hex << severity << llendl;
+ llwarns << "Message: " << message << llendl;
+ llwarns << "-----------------------" << llendl;
+ if (severity == GL_DEBUG_SEVERITY_HIGH_ARB)
+ {
+ llerrs << "Halting on GL Error" << llendl;
+ }
+}
}
#endif
@@ -653,7 +652,8 @@ bool LLGLManager::initGL()
}
#if LL_DARWIN
else if ((mGLRenderer.find("9400M") != std::string::npos)
- || (mGLRenderer.find("9600M") != std::string::npos))
+ || (mGLRenderer.find("9600M") != std::string::npos)
+ || (mGLRenderer.find("9800M") != std::string::npos))
{
mIsMobileGF = TRUE;
}
@@ -751,7 +751,7 @@ bool LLGLManager::initGL()
#if LL_WINDOWS
if (mHasDebugOutput && gDebugGL)
{ //setup debug output callback
- glDebugMessageControlARB(GL_DONT_CARE, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, GL_TRUE);
+ //glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, GL_TRUE);
glDebugMessageCallbackARB((GLDEBUGPROCARB) gl_debug_callback, NULL);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
}
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index dfb73de6f3..35620bb656 100755
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -375,6 +375,11 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
// Create program
mProgramObject = glCreateProgramObjectARB();
+#if LL_DARWIN
+ // work-around missing mix(vec3,vec3,bvec3)
+ mDefines["OLD_SELECT"] = "1";
+#endif
+
//compile new source
vector< pair<string,GLenum> >::iterator fileIter = mShaderFiles.begin();
for ( ; fileIter != mShaderFiles.end(); fileIter++ )
@@ -1190,7 +1195,7 @@ GLint LLGLSLShader::getAttribLocation(U32 attrib)
void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v)
{
GLint location = getUniformLocation(uniform);
-
+
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
@@ -1223,7 +1228,7 @@ void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint
void LLGLSLShader::uniform1f(const LLStaticHashedString& uniform, GLfloat v)
{
GLint location = getUniformLocation(uniform);
-
+
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
@@ -1239,7 +1244,7 @@ void LLGLSLShader::uniform1f(const LLStaticHashedString& uniform, GLfloat v)
void LLGLSLShader::uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y)
{
GLint location = getUniformLocation(uniform);
-
+
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
@@ -1256,7 +1261,7 @@ void LLGLSLShader::uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLf
void LLGLSLShader::uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z)
{
GLint location = getUniformLocation(uniform);
-
+
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
@@ -1288,7 +1293,7 @@ void LLGLSLShader::uniform1fv(const LLStaticHashedString& uniform, U32 count, co
void LLGLSLShader::uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
-
+
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
@@ -1304,7 +1309,7 @@ void LLGLSLShader::uniform2fv(const LLStaticHashedString& uniform, U32 count, co
void LLGLSLShader::uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
-
+
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 3393d352de..aa94110f4d 100755
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1872,33 +1872,33 @@ 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 (mCount%4 != 0)
+ if (mMode == LLRender::QUADS && !sGLCoreProfile)
{
+ if (mCount%4 != 0)
+ {
count -= (mCount % 4);
llwarns << "Incomplete quad requested." << llendl;
+ }
}
- }
-
- if (mMode == LLRender::TRIANGLES)
- {
- if (mCount%3 != 0)
+
+ if (mMode == LLRender::TRIANGLES)
{
+ if (mCount%3 != 0)
+ {
count -= (mCount % 3);
llwarns << "Incomplete triangle requested." << llendl;
+ }
}
- }
-
- if (mMode == LLRender::LINES)
- {
- if (mCount%2 != 0)
+
+ if (mMode == LLRender::LINES)
{
+ if (mCount%2 != 0)
+ {
count -= (mCount % 2);
llwarns << "Incomplete line requested." << llendl;
}
}
-
+
mCount = 0;
if (mBuffer->useVBOs() && !mBuffer->isLocked())
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 33a852bedf..d7f141bd92 100755
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -79,7 +79,7 @@ LLRenderTarget::~LLRenderTarget()
release();
}
-void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt)
+void LLRenderTarget::resize(U32 resx, U32 resy)
{
//for accounting, get the number of pixels added/subtracted
S32 pix_diff = (resx*resy)-(mResX*mResY);
@@ -87,10 +87,12 @@ void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt)
mResX = resx;
mResY = resy;
+ llassert(mInternalFormat.size() == mTex.size());
+
for (U32 i = 0; i < mTex.size(); ++i)
{ //resize color attachments
gGL.getTexUnit(0)->bindManual(mUsage, mTex[i]);
- LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false);
+ LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, mInternalFormat[i], mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false);
sBytesAllocated += pix_diff*4;
}
diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h
index 740e25d40d..6dc84d978d 100755
--- a/indra/llrender/llrendertarget.h
+++ b/indra/llrender/llrendertarget.h
@@ -79,7 +79,7 @@ public:
// CAUTION: if the GL runs out of memory attempting to resize, this render target will be undefined
// DO NOT use for screen space buffers or for scratch space for an image that might be uploaded
// DO use for render targets that resize often and aren't likely to ruin someone's day if they break
- void resize(U32 resx, U32 resy, U32 color_fmt);
+ void resize(U32 resx, U32 resy);
//add color buffer attachment
//limit of 4 color attachments per render target
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index d1afd2ed28..d230574752 100755
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -1137,7 +1137,8 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("lightMap");
mReservedUniforms.push_back("bloomMap");
mReservedUniforms.push_back("projectionMap");
-
+ mReservedUniforms.push_back("norm_mat");
+
mReservedUniforms.push_back("global_gamma");
mReservedUniforms.push_back("texture_gamma");
@@ -1183,7 +1184,7 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("alpha_ramp");
mReservedUniforms.push_back("origin");
-
+ mReservedUniforms.push_back("display_gamma");
llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS);
std::set<std::string> dupe_check;
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h
index ba781036eb..51c27fc8b6 100755
--- a/indra/llrender/llshadermgr.h
+++ b/indra/llrender/llshadermgr.h
@@ -167,7 +167,8 @@ public:
DEFERRED_LIGHT,
DEFERRED_BLOOM,
DEFERRED_PROJECTION,
-
+ DEFERRED_NORM_MATRIX,
+
GLOBAL_GAMMA,
TEXTURE_GAMMA,
@@ -213,9 +214,8 @@ public:
TERRAIN_ALPHARAMP,
SHINY_ORIGIN,
-
+DISPLAY_GAMMA,
END_RESERVED_UNIFORMS
-
} eGLSLReservedUniforms;
// singleton pattern implementation
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 83ea6fabbb..f168b3af14 100755
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -954,15 +954,15 @@ S32 LLVertexBuffer::determineUsage(S32 usage)
{ //only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default
if (ret_usage != GL_DYNAMIC_COPY_ARB)
{
- if (sDisableVBOMapping)
- { //always use stream draw if VBO mapping is disabled
- ret_usage = GL_STREAM_DRAW_ARB;
- }
- else
- {
- ret_usage = GL_DYNAMIC_DRAW_ARB;
- }
+ if (sDisableVBOMapping)
+ { //always use stream draw if VBO mapping is disabled
+ ret_usage = GL_STREAM_DRAW_ARB;
}
+ else
+ {
+ ret_usage = GL_DYNAMIC_DRAW_ARB;
+ }
+ }
}
return ret_usage;
@@ -1119,7 +1119,7 @@ void LLVertexBuffer::genBuffer(U32 size)
{
mMappedData = sDynamicCopyVBOPool.allocate(mGLBuffer, mSize);
}
-
+
sGLCount++;
}
@@ -1333,7 +1333,7 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
//actually allocate space for the vertex buffer if using VBO mapping
flush();
- if (gGLManager.mHasVertexArrayObject && useVBOs() && (sUseVAO))
+ if (gGLManager.mHasVertexArrayObject && useVBOs() && (LLRender::sGLCoreProfile || sUseVAO))
{
#if GL_ARB_vertex_array_object
mGLArray = getVAOName();
@@ -1489,18 +1489,21 @@ bool LLVertexBuffer::useVBOs() const
//----------------------------------------------------------------------------
-bool expand_region(LLVertexBuffer::MappedRegion& region, S32 start, S32 end)
+bool expand_region(LLVertexBuffer::MappedRegion& region, S32 index, S32 count)
{
+ S32 end = index+count;
+ S32 region_end = region.mIndex+region.mCount;
+
if (end < region.mIndex ||
- start > region.mEnd)
+ index > region_end)
{ //gap exists, do not merge
return false;
}
- region.mEnd = llmax(end, region.mEnd);
- region.mIndex = llmin(start, region.mIndex);
- region.mCount = region.mEnd-region.mIndex;
-
+ S32 new_end = llmax(end, region_end);
+ S32 new_index = llmin(index, region.mIndex);
+ region.mIndex = new_index;
+ region.mCount = new_end-new_index;
return true;
}
@@ -1510,6 +1513,7 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER("VBO Map");
// Map for data access
volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range)
{
+ bindGLBuffer(true);
if (mFinal)
{
llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl;
@@ -1530,23 +1534,23 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo
bool mapped = false;
//see if range is already mapped
- S32 start_index = mOffsets[type]+index*sTypeSize[type];
- S32 end_index = start_index+count*sTypeSize[type];
-
- for (std::vector<MappedRegion>::iterator iter = mMappedVertexRegions.begin(), end = mMappedVertexRegions.end(); iter != end; ++iter)
+ for (U32 i = 0; i < mMappedVertexRegions.size(); ++i)
{
- MappedRegion& region = *iter;
- if (expand_region(region, index, end_index))
+ MappedRegion& region = mMappedVertexRegions[i];
+ if (region.mType == type)
{
- mapped = true;
- break;
+ if (expand_region(region, index, count))
+ {
+ mapped = true;
+ break;
+ }
}
}
if (!mapped)
{
//not already mapped, map new region
- MappedRegion region(mMappable && map_range ? -1 : start_index, end_index-start_index);
+ MappedRegion region(type, mMappable && map_range ? -1 : index, count);
mMappedVertexRegions.push_back(region);
}
}
@@ -1570,7 +1574,6 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo
{
volatile U8* src = NULL;
waitFence();
- bindGLBuffer();
if (gGLManager.mHasMapBufferRange)
{
if (map_range)
@@ -1691,6 +1694,7 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_INDEX("IBO Map");
volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range)
{
+ bindGLIndices(true);
if (mFinal)
{
llerrs << "LLVertexBuffer::mapIndexBuffer() called on a finalized buffer." << llendl;
@@ -1709,14 +1713,12 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range
count = mNumIndices-index;
}
- S32 end = index+count;
-
bool mapped = false;
//see if range is already mapped
for (U32 i = 0; i < mMappedIndexRegions.size(); ++i)
{
MappedRegion& region = mMappedIndexRegions[i];
- if (expand_region(region, index, end))
+ if (expand_region(region, index, count))
{
mapped = true;
break;
@@ -1726,7 +1728,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range
if (!mapped)
{
//not already mapped, map new region
- MappedRegion region(mMappable && map_range ? -1 : index, count);
+ MappedRegion region(TYPE_INDEX, mMappable && map_range ? -1 : index, count);
mMappedIndexRegions.push_back(region);
}
}
@@ -1742,23 +1744,23 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range
sMappedCount++;
stop_glerror();
+ if (gDebugGL && useVBOs())
+ {
+ GLint elem = 0;
+ glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &elem);
+
+ if (elem != mGLIndices)
+ {
+ llerrs << "Wrong index buffer bound!" << llendl;
+ }
+ }
+
if(!mMappable)
{
map_range = false;
}
else
{
- bindGLIndices();
- if (gDebugGL && useVBOs())
- {
- GLint elem = 0;
- glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &elem);
-
- if (elem != mGLIndices)
- {
- llerrs << "Wrong index buffer bound!" << llendl;
- }
- }
volatile U8* src = NULL;
waitFence();
if (gGLManager.mHasMapBufferRange)
@@ -1871,10 +1873,8 @@ void LLVertexBuffer::unmapBuffer()
if (mMappedData && mVertexLocked)
{
- llassert(mUsage != GL_DYNAMIC_COPY_ARB);
-
LLFastTimer t(FTM_VBO_UNMAP);
- bindGLBuffer();
+ bindGLBuffer(true);
updated_all = mIndexLocked; //both vertex and index buffers done updating
if(!mMappable)
@@ -1885,8 +1885,8 @@ void LLVertexBuffer::unmapBuffer()
for (U32 i = 0; i < mMappedVertexRegions.size(); ++i)
{
const MappedRegion& region = mMappedVertexRegions[i];
- S32 offset = region.mIndex;
- S32 length = region.mCount;
+ S32 offset = region.mIndex >= 0 ? mOffsets[region.mType]+sTypeSize[region.mType]*region.mIndex : 0;
+ S32 length = sTypeSize[region.mType]*region.mCount;
glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, (U8*) mMappedData+offset);
stop_glerror();
}
@@ -1910,8 +1910,8 @@ void LLVertexBuffer::unmapBuffer()
for (U32 i = 0; i < mMappedVertexRegions.size(); ++i)
{
const MappedRegion& region = mMappedVertexRegions[i];
- S32 offset = region.mIndex;
- S32 length = region.mCount;
+ S32 offset = region.mIndex >= 0 ? mOffsets[region.mType]+sTypeSize[region.mType]*region.mIndex : 0;
+ S32 length = sTypeSize[region.mType]*region.mCount;
if (gGLManager.mHasMapBufferRange)
{
LLFastTimer t(FTM_VBO_FLUSH_RANGE);
@@ -2131,6 +2131,7 @@ bool LLVertexBuffer::bindGLArray()
if (mGLArray && sGLRenderArray != mGLArray)
{
{
+ LLFastTimer t(FTM_BIND_GL_ARRAY);
#if GL_ARB_vertex_array_object
glBindVertexArray(mGLArray);
#endif
@@ -2165,7 +2166,7 @@ bool LLVertexBuffer::bindGLBuffer(bool force_bind)
sVBOActive = true;
llassert(!mGLArray || sGLRenderArray == mGLArray);
-
+
ret = true;
}
@@ -2245,7 +2246,38 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
if ((data_mask & required_mask) != required_mask)
{
- llwarns << "Shader consumption mismatches data provision." << llendl;
+
+ U32 unsatisfied_mask = (required_mask & ~data_mask);
+ U32 i = 0;
+
+ while (i < TYPE_MAX)
+ {
+ U32 unsatisfied_flag = unsatisfied_mask & (1 << i);
+ switch (unsatisfied_flag)
+ {
+ case MAP_VERTEX: llinfos << "Missing vert pos" << llendl; break;
+ case MAP_NORMAL: llinfos << "Missing normals" << llendl; break;
+ case MAP_TEXCOORD0: llinfos << "Missing TC 0" << llendl; break;
+ case MAP_TEXCOORD1: llinfos << "Missing TC 1" << llendl; break;
+ case MAP_TEXCOORD2: llinfos << "Missing TC 2" << llendl; break;
+ case MAP_TEXCOORD3: llinfos << "Missing TC 3" << llendl; break;
+ case MAP_COLOR: llinfos << "Missing vert color" << llendl; break;
+ case MAP_EMISSIVE: llinfos << "Missing emissive" << llendl; break;
+ case MAP_TANGENT: llinfos << "Missing tangent" << llendl; break;
+ case MAP_WEIGHT: llinfos << "Missing weight" << llendl; break;
+ case MAP_WEIGHT4: llinfos << "Missing weightx4" << llendl; break;
+ case MAP_CLOTHWEIGHT: llinfos << "Missing clothweight" << llendl; break;
+ case MAP_TEXTURE_INDEX: llinfos << "Missing tex index" << llendl; break;
+ default: llinfos << "Missing who effin knows: " << unsatisfied_flag << llendl;
+ }
+ }
+
+ if (unsatisfied_mask & (1 << TYPE_INDEX))
+ {
+ llinfos << "Missing indices" << llendl;
+ }
+
+ llerrs << "Shader consumption mismatches data provision." << llendl;
}
}
}
@@ -2512,8 +2544,8 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
llglassertok();
}
-LLVertexBuffer::MappedRegion::MappedRegion(S32 index, S32 count)
-: mIndex(index), mCount(count)
+LLVertexBuffer::MappedRegion::MappedRegion(S32 type, S32 index, S32 count)
+: mType(type), mIndex(index), mCount(count)
{
mEnd = mIndex+mCount;
}
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index b7597cf60e..de58207c23 100755
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -104,11 +104,12 @@ public:
class MappedRegion
{
public:
+ S32 mType;
S32 mIndex;
S32 mCount;
S32 mEnd;
- MappedRegion(S32 index, S32 count);
+ MappedRegion(S32 type, S32 index, S32 count);
};
LLVertexBuffer(const LLVertexBuffer& rhs)