Batch indexing/no-fixed-function WIP.

This commit is contained in:
Shyotl
2011-08-09 01:11:05 -05:00
parent 1e7415095c
commit 9bda97786f
225 changed files with 2120 additions and 729 deletions

View File

@@ -54,6 +54,7 @@ using std::pair;
using std::make_pair;
using std::string;
GLhandleARB LLGLSLShader::sCurBoundShader = 0;
BOOL shouldChange(const LLVector4& v1, const LLVector4& v2)
{
return v1 != v2;
@@ -63,6 +64,7 @@ LLShaderFeatures::LLShaderFeatures()
: calculatesLighting(false), isShiny(false), isFullbright(false), hasWaterFog(false),
hasTransport(false), hasSkinning(false), hasAtmospherics(false), isSpecular(false),
hasGamma(false), hasLighting(false), calculatesAtmospherics(false)
, mIndexedTextureChannels(0), disableTextureIndex(false)
#if MESH_ENABLED
, hasObjectSkinning(false)
#endif //MESH_ENABLED
@@ -119,6 +121,27 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
glDeleteObjectARB(mProgramObject);
// Create program
mProgramObject = glCreateProgramObjectARB();
if (gGLManager.mGLVersion < 3.1f)
{ //force indexed texture channels to 1 if GL version is old (performance improvement for drivers with poor branching shader model support)
mFeatures.mIndexedTextureChannels = llmin(mFeatures.mIndexedTextureChannels, 1);
}
//compile new source
vector< pair<string,GLenum> >::iterator fileIter = mShaderFiles.begin();
for ( ; fileIter != mShaderFiles.end(); fileIter++ )
{
GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, mFeatures.mIndexedTextureChannels);
LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL;
if (shaderhandle > 0)
{
attachObject(shaderhandle);
}
else
{
success = FALSE;
}
}
// Attach existing objects
if (!LLShaderMgr::instance()->attachShaderFeatures(this))
@@ -129,19 +152,9 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
return FALSE;
}
vector< pair<string,GLenum> >::iterator fileIter = mShaderFiles.begin();
for ( ; fileIter != mShaderFiles.end(); fileIter++ )
{
GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second);
LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL;
if (mShaderLevel > 0)
{
attachObject(shaderhandle);
}
else
{
success = FALSE;
}
if (gGLManager.mGLVersion < 3.1f)
{ //attachShaderFeatures may have set the number of indexed texture channels, so set to 1 again
mFeatures.mIndexedTextureChannels = llmin(mFeatures.mIndexedTextureChannels, 1);
}
// Map attributes and uniforms
@@ -169,6 +182,28 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
return createShader(attributes,uniforms);
}
}
else if (mFeatures.mIndexedTextureChannels > 0)
{ //override texture channels for indexed texture rendering
bind();
S32 channel_count = mFeatures.mIndexedTextureChannels;
for (S32 i = 0; i < channel_count; i++)
{
uniform1i(llformat("tex%d", i), i);
}
S32 cur_tex = channel_count; //adjust any texture channels that might have been overwritten
for (U32 i = 0; i < mTexture.size(); i++)
{
if (mTexture[i] > -1 && mTexture[i] < channel_count)
{
llassert(cur_tex < gGLManager.mNumTextureImageUnits);
uniform1i(i, cur_tex);
mTexture[i] = cur_tex++;
}
}
unbind();
}
return success;
}
@@ -363,7 +398,7 @@ void LLGLSLShader::bind()
if (gGLManager.mHasShaderObjects)
{
glUseProgramObjectARB(mProgramObject);
sCurBoundShader = mProgramObject;
if (mUniformsDirty)
{
LLShaderMgr::instance()->updateShaderUniforms(this);
@@ -386,6 +421,7 @@ void LLGLSLShader::unbind()
}
}
glUseProgramObjectARB(0);
sCurBoundShader = 0;
stop_glerror();
}
}
@@ -393,6 +429,7 @@ void LLGLSLShader::unbind()
void LLGLSLShader::bindNoShader(void)
{
glUseProgramObjectARB(0);
sCurBoundShader = 0;
}
S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)