summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender')
-rwxr-xr-xindra/llrender/llglslshader.cpp65
-rwxr-xr-xindra/llrender/llglslshader.h7
-rwxr-xr-xindra/llrender/llrendertarget.cpp36
-rwxr-xr-xindra/llrender/llrendertarget.h6
4 files changed, 111 insertions, 3 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 62191b4c1a..ac16e30796 100755
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -149,6 +149,9 @@ void LLGLSLShader::clearStats()
mTimeElapsed = 0;
mSamplesDrawn = 0;
mDrawCalls = 0;
+ mTextureStateFetched = false;
+ mTextureMagFilter.clear();
+ mTextureMinFilter.clear();
}
void LLGLSLShader::dumpStats()
@@ -161,6 +164,16 @@ void LLGLSLShader::dumpStats()
{
llinfos << mShaderFiles[i].first << llendl;
}
+ for (U32 i = 0; i < mTexture.size(); ++i)
+ {
+ GLint idx = mTexture[i];
+
+ if (idx >= 0)
+ {
+ GLint uniform_idx = getUniformLocation(i);
+ llinfos << mUniformNameMap[uniform_idx] << " - " << std::hex << mTextureMagFilter[i] << "/" << mTextureMinFilter[i] << std::dec << llendl;
+ }
+ }
llinfos << "=============================================" << llendl;
F32 ms = mTimeElapsed/1000000.f;
@@ -211,6 +224,39 @@ void LLGLSLShader::placeProfileQuery()
glGenQueriesARB(1, &mTimerQuery);
}
+ if (!mTextureStateFetched)
+ {
+ mTextureStateFetched = true;
+ mTextureMagFilter.resize(mTexture.size());
+ mTextureMinFilter.resize(mTexture.size());
+
+ U32 cur_active = gGL.getCurrentTexUnitIndex();
+
+ for (U32 i = 0; i < mTexture.size(); ++i)
+ {
+ GLint idx = mTexture[i];
+
+ if (idx >= 0)
+ {
+ gGL.getTexUnit(idx)->activate();
+
+ U32 mag = 0xFFFFFFFF;
+ U32 min = 0xFFFFFFFF;
+
+ U32 type = LLTexUnit::getInternalType(gGL.getTexUnit(idx)->getCurrType());
+
+ glGetTexParameteriv(type, GL_TEXTURE_MAG_FILTER, (GLint*) &mag);
+ glGetTexParameteriv(type, GL_TEXTURE_MIN_FILTER, (GLint*) &min);
+
+ mTextureMagFilter[i] = mag;
+ mTextureMinFilter[i] = min;
+ }
+ }
+
+ gGL.getTexUnit(cur_active)->activate();
+ }
+
+
glBeginQueryARB(GL_SAMPLES_PASSED, 1);
glBeginQueryARB(GL_TIME_ELAPSED, mTimerQuery);
#endif
@@ -573,6 +619,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
}
mUniformMap[name] = location;
+ mUniformNameMap[location] = name;
LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL;
//find the index of this uniform
@@ -635,6 +682,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<string> * uniforms)
mActiveTextureChannels = 0;
mUniform.clear();
mUniformMap.clear();
+ mUniformNameMap.clear();
mTexture.clear();
mValue.clear();
//initialize arrays
@@ -1152,6 +1200,23 @@ void LLGLSLShader::uniform1i(const string& uniform, GLint v)
}
}
+void LLGLSLShader::uniform2i(const string& uniform, GLint i, GLint j)
+{
+ GLint location = getUniformLocation(uniform);
+
+ if (location >= 0)
+ {
+ std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+ LLVector4 vec(i,j,0.f,0.f);
+ if (iter == mValue.end() || shouldChange(iter->second,vec))
+ {
+ glUniform2iARB(location, i, j);
+ mValue[location] = vec;
+ }
+ }
+}
+
+
void LLGLSLShader::uniform1f(const string& uniform, GLfloat v)
{
GLint location = getUniformLocation(uniform);
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 3c775cde27..eabdb9fc92 100755
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -111,6 +111,7 @@ public:
void uniform3fv(U32 index, U32 count, const GLfloat* v);
void uniform4fv(U32 index, U32 count, const GLfloat* v);
void uniform1i(const std::string& uniform, GLint i);
+ void uniform2i(const std::string& uniform, GLint i, GLint j);
void uniform1f(const std::string& uniform, GLfloat v);
void uniform2f(const std::string& uniform, GLfloat x, GLfloat y);
void uniform3f(const std::string& uniform, GLfloat x, GLfloat y, GLfloat z);
@@ -170,6 +171,7 @@ public:
U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask())
std::vector<GLint> mUniform; //lookup table of uniform enum to uniform location
std::map<std::string, GLint> mUniformMap; //lookup map of uniform name to uniform location
+ std::map<GLint, std::string> mUniformNameMap; //lookup map of uniform location to uniform name
std::map<GLint, LLVector4> mValue; //lookup map of uniform location to last known value
std::vector<GLint> mTexture;
S32 mTotalUniformSize;
@@ -192,6 +194,11 @@ public:
static U64 sTotalSamplesDrawn;
U32 mDrawCalls;
static U32 sTotalDrawCalls;
+
+ bool mTextureStateFetched;
+ std::vector<U32> mTextureMagFilter;
+ std::vector<U32> mTextureMinFilter;
+
};
//UI shader (declared here so llui_libtest will link properly)
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 5fb4fc8e52..752486fdde 100755
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -53,11 +53,23 @@ void check_framebuffer_status()
bool LLRenderTarget::sUseFBO = false;
U32 LLRenderTarget::sCurFBO = 0;
+
+extern S32 gGLViewport[4];
+
+//HEY DAVE HOOK THESE UP
+U32 LLRenderTarget::sCurResX = 0;
+U32 LLRenderTarget::sCurResY = 0;
+
+
+/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
LLRenderTarget::LLRenderTarget() :
mResX(0),
mResY(0),
mFBO(0),
mPreviousFBO(0),
+ mPreviousResX(0),
+ mPreviousResY(0),
mDepth(0),
mStencil(0),
mUseDepth(false),
@@ -390,13 +402,12 @@ void LLRenderTarget::bindTarget()
{
if (mFBO)
{
- mPreviousFBO = sCurFBO;
-
stop_glerror();
+ mPreviousFBO = sCurFBO;
glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
sCurFBO = mFBO;
-
+
stop_glerror();
if (gGLManager.mHasDrawBuffers)
{ //setup multiple render targets
@@ -418,7 +429,12 @@ void LLRenderTarget::bindTarget()
stop_glerror();
}
+ mPreviousResX = sCurResX;
+ mPreviousResY = sCurResY;
glViewport(0, 0, mResX, mResY);
+ sCurResX = mResX;
+ sCurResY = mResY;
+
sBoundTarget = this;
}
@@ -489,6 +505,20 @@ void LLRenderTarget::flush(bool fetch_depth)
stop_glerror();
glBindFramebuffer(GL_FRAMEBUFFER, mPreviousFBO);
sCurFBO = mPreviousFBO;
+
+ if (mPreviousFBO)
+ {
+ glViewport(0, 0, mPreviousResX, mPreviousResY);
+ sCurResX = mPreviousResX;
+ sCurResY = mPreviousResY;
+ }
+ else
+ {
+ glViewport(gGLViewport[0],gGLViewport[1],gGLViewport[2],gGLViewport[3]);
+ sCurResX = gGLViewport[2];
+ sCurResY = gGLViewport[3];
+ }
+
stop_glerror();
}
}
diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h
index 765a727b5b..66a9874a6b 100755
--- a/indra/llrender/llrendertarget.h
+++ b/indra/llrender/llrendertarget.h
@@ -63,6 +63,9 @@ public:
static bool sUseFBO;
static U32 sBytesAllocated;
static U32 sCurFBO;
+ static U32 sCurResX;
+ static U32 sCurResY;
+
LLRenderTarget();
~LLRenderTarget();
@@ -146,6 +149,9 @@ protected:
std::vector<U32> mInternalFormat;
U32 mFBO;
U32 mPreviousFBO;
+ U32 mPreviousResX;
+ U32 mPreviousResY;
+
U32 mDepth;
bool mStencil;
bool mUseDepth;