Merge branch 'master' of git://github.com/Shyotl/SingularityViewer

This commit is contained in:
Inusaito Sayori
2015-06-02 04:45:31 -04:00
21 changed files with 384 additions and 604 deletions

View File

@@ -113,8 +113,8 @@ void LLStat::addValue(const F32 value)
} }
// Increment the bin counters. // Increment the bin counters.
mCurBin = ++mCurBin % mNumBins; mCurBin = (mCurBin+1) % mNumBins;
mNextBin = ++mNextBin % mNumBins; mNextBin = (mNextBin+1) % mNumBins;
mBins[mCurBin].mValue = value; mBins[mCurBin].mValue = value;
if (mUseFrameTimer) if (mUseFrameTimer)

View File

@@ -35,15 +35,7 @@
class LLPerlinNoise class LLPerlinNoise
{ {
public: public:
template<typename T> static F32 noise(const F32& x, U32 wrap_at = 256)
static F32 noise(const T& x, U32 wrap_at);
template<typename T>
static F32 noise(const T& x)
{
return noise(x, 256);
}
template<>
static F32 noise(const F32& x, U32 wrap_at)
{ {
U8 b[1][2]; U8 b[1][2];
F32 r[1][2], s[1], u, v; F32 r[1][2], s[1], u, v;
@@ -55,8 +47,7 @@ public:
return lerp(u, v, s[VX]); return lerp(u, v, s[VX]);
} }
template <> static F32 noise(const LLVector2& vec, U32 wrap_at = 256)
static F32 noise(const LLVector2& vec, U32 wrap_at)
{ {
U8 b[2][2]; U8 b[2][2];
F32 r[2][2], s[2], u, v, A, B; F32 r[2][2], s[2], u, v, A, B;
@@ -73,8 +64,7 @@ public:
return lerp(A, B, s[VY]); return lerp(A, B, s[VY]);
} }
template <> static F32 noise(const LLVector3& vec, U32 wrap_at = 256)
static F32 noise(const LLVector3& vec, U32 wrap_at)
{ {
U8 b[3][2]; U8 b[3][2];
F32 r[3][2], s[3], u, v, A, B, C, D; F32 r[3][2], s[3], u, v, A, B, C, D;
@@ -101,7 +91,7 @@ public:
D = lerp(A, B, s[VY]); D = lerp(A, B, s[VY]);
return lerp(C, D, s[VZ]); return lerp(C, D, s[VZ]) * 0.77f;
} }
template <typename T> template <typename T>
static F32 turbulence(const T& vec, F32 freq, U32 wrap_at = 256) static F32 turbulence(const T& vec, F32 freq, U32 wrap_at = 256)
@@ -169,7 +159,7 @@ private:
const U32 limit = llclamp(wrap_at, U32(1), U32(256)); const U32 limit = llclamp(wrap_at, U32(1), U32(256));
for (U32 i = 0; i < N; ++i) for (U32 i = 0; i < N; ++i)
{ {
const S32 t_S32 = lltrunc(vec[i]); const S32 t_S32 = llfloor(vec[i]);
b[i][0] = (t_S32) % limit; b[i][0] = (t_S32) % limit;
b[i][1] = (t_S32 + 1) % limit; b[i][1] = (t_S32 + 1) % limit;
r[i][0] = vec[i] - F32(t_S32); r[i][0] = vec[i] - F32(t_S32);

View File

@@ -38,12 +38,6 @@
#include "OpenGL/OpenGL.h" #include "OpenGL/OpenGL.h"
#endif #endif
#ifdef LL_RELEASE_FOR_DOWNLOAD
#define UNIFORM_ERRS LL_WARNS_ONCE("Shader")
#else
#define UNIFORM_ERRS LL_ERRS("Shader")
#endif
// Lots of STL stuff in here, using namespace std to keep things more readable // Lots of STL stuff in here, using namespace std to keep things more readable
using std::vector; using std::vector;
using std::pair; using std::pair;
@@ -431,7 +425,6 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *
} }
LLStaticHashedString hashedName(name); LLStaticHashedString hashedName(name);
mUniformNameMap[location] = name;
mUniformMap[hashedName] = location; mUniformMap[hashedName] = location;
LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL; LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL;
@@ -496,9 +489,10 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
mActiveTextureChannels = 0; mActiveTextureChannels = 0;
mUniform.clear(); mUniform.clear();
mUniformMap.clear(); mUniformMap.clear();
mUniformNameMap.clear();
mTexture.clear(); mTexture.clear();
mValue.clear(); mValueVec4.clear();
mValueMat3.clear();
mValueMat4.clear();
//initialize arrays //initialize arrays
U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size(); U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size();
mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1); mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1);
@@ -671,326 +665,6 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)
return index; return index;
} }
void LLGLSLShader::uniform1i(U32 index, GLint x)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
if (iter == mValue.end() || iter->second.mV[0] != x)
{
glUniform1iARB(mUniform[index], x);
mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
}
}
}
}
void LLGLSLShader::uniform1f(U32 index, GLfloat x)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
if (iter == mValue.end() || iter->second.mV[0] != x)
{
glUniform1fARB(mUniform[index], x);
mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
}
}
}
}
void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
glUniform2fARB(mUniform[index], x, y);
mValue[mUniform[index]] = vec;
}
}
}
}
void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,z,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
glUniform3fARB(mUniform[index], x, y, z);
mValue[mUniform[index]] = vec;
}
}
}
}
void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(x,y,z,w);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
glUniform4fARB(mUniform[index], x, y, z, w);
mValue[mUniform[index]] = vec;
}
}
}
}
void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(v[0],0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
glUniform1ivARB(mUniform[index], count, v);
mValue[mUniform[index]] = vec;
}
}
}
}
void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(v[0],0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
glUniform1fvARB(mUniform[index], count, v);
mValue[mUniform[index]] = vec;
}
}
}
}
void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(v[0],v[1],0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
glUniform2fvARB(mUniform[index], count, v);
mValue[mUniform[index]] = vec;
}
}
}
}
void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(v[0],v[1],v[2],0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
glUniform3fvARB(mUniform[index], count, v);
mValue[mUniform[index]] = vec;
}
}
}
}
void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
LLVector4 vec(v[0],v[1],v[2],v[3]);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
glUniform4fvARB(mUniform[index], count, v);
mValue[mUniform[index]] = vec;
}
}
}
}
void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
glUniformMatrix2fvARB(mUniform[index], count, transpose, v);
}
}
}
void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
glUniformMatrix3fvARB(mUniform[index], count, transpose, v);
}
}
}
void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
glUniformMatrix3x4fv(mUniform[index], count, transpose, v);
}
}
}
void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
if (mProgramObject > 0)
{
if (mUniform.size() <= index)
{
UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
return;
}
if (mUniform[index] >= 0)
{
glUniformMatrix4fvARB(mUniform[index], count, transpose, v);
}
}
}
GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform)
{
GLint ret = -1;
if (mProgramObject > 0)
{
LLStaticStringTable<GLint>::iterator iter = mUniformMap.find(uniform);
if (iter != mUniformMap.end())
{
if (gDebugGL)
{
stop_glerror();
if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.String().c_str()))
{
llerrs << "Uniform does not match." << llendl;
}
stop_glerror();
}
ret = iter->second;
}
}
return ret;
}
GLint LLGLSLShader::getUniformLocation(U32 index) GLint LLGLSLShader::getUniformLocation(U32 index)
{ {
GLint ret = -1; GLint ret = -1;
@@ -1015,167 +689,6 @@ 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);
LLVector4 vec(v,0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
glUniform1iARB(location, v);
mValue[location] = vec;
}
}
}
void LLGLSLShader::uniform2i(const LLStaticHashedString& 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 LLStaticHashedString& uniform, GLfloat v)
{
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
LLVector4 vec(v,0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
glUniform1fARB(location, v);
mValue[location] = vec;
}
}
}
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);
LLVector4 vec(x,y,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
glUniform2fARB(location, x,y);
mValue[location] = vec;
}
}
}
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);
LLVector4 vec(x,y,z,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
glUniform3fARB(location, x,y,z);
mValue[location] = vec;
}
}
}
void LLGLSLShader::uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
LLVector4 vec(v[0],0.f,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
glUniform1fvARB(location, count, v);
mValue[location] = vec;
}
}
}
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);
LLVector4 vec(v[0],v[1],0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
glUniform2fvARB(location, count, v);
mValue[location] = vec;
}
}
}
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);
LLVector4 vec(v[0],v[1],v[2],0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
glUniform3fvARB(location, count, v);
mValue[location] = vec;
}
}
}
void LLGLSLShader::uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
LLVector4 vec(v);
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
{
stop_glerror();
glUniform4fvARB(location, count, v);
stop_glerror();
mValue[location] = vec;
}
}
}
void LLGLSLShader::uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
stop_glerror();
glUniformMatrix4fvARB(location, count, transpose, v);
stop_glerror();
}
}
void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{ {
if (mAttribute[index] > 0) if (mAttribute[index] > 0)
@@ -1184,14 +697,6 @@ void LLGLSLShader::vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GL
} }
} }
void LLGLSLShader::vertexAttrib4fv(U32 index, GLfloat* v)
{
if (mAttribute[index] > 0)
{
glVertexAttrib4fvARB(mAttribute[index], v);
}
}
void LLGLSLShader::setMinimumAlpha(F32 minimum) void LLGLSLShader::setMinimumAlpha(F32 minimum)
{ {
gGL.flush(); gGL.flush();

View File

@@ -30,6 +30,11 @@
#include "llgl.h" #include "llgl.h"
#include "llrender.h" #include "llrender.h"
#include "llstaticstringtable.h" #include "llstaticstringtable.h"
#ifdef LL_RELEASE_FOR_DOWNLOAD
#define UNIFORM_ERRS LL_WARNS_ONCE("Shader")
#else
#define UNIFORM_ERRS LL_ERRS("Shader")
#endif
class LLShaderFeatures class LLShaderFeatures
{ {
@@ -87,38 +92,256 @@ public:
BOOL mapAttributes(const std::vector<LLStaticHashedString> * attributes); BOOL mapAttributes(const std::vector<LLStaticHashedString> * attributes);
BOOL mapUniforms(const std::vector<LLStaticHashedString> *); BOOL mapUniforms(const std::vector<LLStaticHashedString> *);
void mapUniform(GLint index, const std::vector<LLStaticHashedString> *); void mapUniform(GLint index, const std::vector<LLStaticHashedString> *);
void uniform1i(U32 index, GLint i); S32 getUniformFromIndex(const U32 index)
void uniform1f(U32 index, GLfloat v); {
void uniform2f(U32 index, GLfloat x, GLfloat y); if (mUniform.size() <= index)
void uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z); {
void uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
void uniform1iv(U32 index, U32 count, const GLint* i); return -1;
void uniform1fv(U32 index, U32 count, const GLfloat* v); }
void uniform2fv(U32 index, U32 count, const GLfloat* v); return mUniform[index];
void uniform3fv(U32 index, U32 count, const GLfloat* v); }
void uniform4fv(U32 index, U32 count, const GLfloat* v); template <typename T, int N>
void uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j); S32 updateUniform(std::vector<std::pair<GLint, T> >& cache, S32 uniform, const F32* val)
void uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); {
void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); if (mProgramObject > 0)
void uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); {
void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); if (uniform >= 0)
void uniform1i(const LLStaticHashedString& uniform, GLint i); {
void uniform1f(const LLStaticHashedString& uniform, GLfloat v); std::vector<std::pair<GLint, T> >::iterator iter = std::find_if(cache.begin(), cache.end(), boost::bind(&std::pair<GLint, T>::first, _1) == uniform);
void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y); if (iter == cache.end())
void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z); {
void uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); T tmp;
void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); memcpy(&tmp, val, sizeof(F32)*N);
void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); cache.push_back(std::make_pair(uniform, tmp));
void uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v); return true;
void uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat *v); }
else if (memcmp(&iter->second, val, sizeof(F32)*N))
{
memcpy(&iter->second, val, sizeof(F32)*N);
return true;
}
}
}
return false;
}
void uniform1i(U32 index, GLint x)
{
F32 val = x;
if (updateUniform<LLVector4, 1>(mValueVec4, getUniformFromIndex(index), &val))
{
glUniform1iARB(mUniform[index], x);
}
}
void uniform1f(U32 index, GLfloat x)
{
if (updateUniform<LLVector4, 1>(mValueVec4, getUniformFromIndex(index), &x))
{
glUniform1fARB(mUniform[index], x);
}
}
void uniform2f(U32 index, GLfloat x, GLfloat y)
{
F32 val[] = { x, y };
if (updateUniform<LLVector4, 2>(mValueVec4, getUniformFromIndex(index), val))
{
glUniform2fARB(mUniform[index], x, y);
}
}
void uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z)
{
F32 val[] = { x, y, z };
if (updateUniform<LLVector4, 3>(mValueVec4, getUniformFromIndex(index), val))
{
glUniform3fARB(mUniform[index], x, y, z);
}
}
void uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
F32 val[] = { x, y, z, w };
if (updateUniform<LLVector4, 4>(mValueVec4, getUniformFromIndex(index), val))
{
glUniform4fARB(mUniform[index], x, y, z, w);
}
}
void uniform1iv(U32 index, U32 count, const GLint* v)
{
F32 val[] = { v[0] };
if (updateUniform<LLVector4, 1>(mValueVec4, getUniformFromIndex(index), val) || count > 1)
{
glUniform1ivARB(mUniform[index], count, v);
}
}
void uniform1fv(U32 index, U32 count, const GLfloat* v)
{
if (updateUniform<LLVector4, 1>(mValueVec4, getUniformFromIndex(index), v) || count > 1)
{
glUniform1fvARB(mUniform[index], count, v);
}
}
void uniform2fv(U32 index, U32 count, const GLfloat* v)
{
if (updateUniform<LLVector4, 2>(mValueVec4, getUniformFromIndex(index), v) || count > 1)
{
glUniform2fvARB(mUniform[index], count, v);
}
}
void uniform3fv(U32 index, U32 count, const GLfloat* v)
{
if (updateUniform<LLVector4, 3>(mValueVec4, getUniformFromIndex(index), v) || count > 1)
{
glUniform3fvARB(mUniform[index], count, v);
}
}
void uniform4fv(U32 index, U32 count, const GLfloat* v)
{
if (updateUniform<LLVector4, 4>(mValueVec4, getUniformFromIndex(index), v) || count > 1)
{
glUniform4fvARB(mUniform[index], count, v);
}
}
void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
if (updateUniform<LLMatrix3, 9>(mValueMat3, getUniformFromIndex(index), v) || count > 1)
{
glUniformMatrix3fvARB(mUniform[index], count, transpose, v);
}
}
void uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
if (updateUniform<LLMatrix4, 12>(mValueMat4, getUniformFromIndex(index), v) || count > 1)
{
glUniformMatrix3x4fv(mUniform[index], count, transpose, v);
}
}
void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v)
{
if (updateUniform<LLMatrix4, 16>(mValueMat4, getUniformFromIndex(index), v) || count > 1)
{
glUniformMatrix4fvARB(mUniform[index], count, transpose, v);
}
}
void uniform1i(const LLStaticHashedString& uniform, GLint i)
{
GLint location = getUniformLocation(uniform);
if (location < 0)
return;
F32 val = i;
if (updateUniform<LLVector4, 1>(mValueVec4, getUniformLocation(uniform), &val))
{
glUniform1iARB(location, i);
}
}
void uniform1f(const LLStaticHashedString& uniform, GLfloat v)
{
GLint location = getUniformLocation(uniform);
if (location < 0)
return;
if (updateUniform<LLVector4, 1>(mValueVec4, location, &v))
{
glUniform1fARB(location, v);
}
}
void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y)
{
GLint location = getUniformLocation(uniform);
if (location < 0)
return;
F32 val[] = { x, y };
if (updateUniform<LLVector4, 2>(mValueVec4, location, val))
{
glUniform2fARB(location, x, y);
}
}
void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z)
{
GLint location = getUniformLocation(uniform);
if (location < 0)
return;
F32 val[] = { x, y, z };
if (updateUniform<LLVector4, 3>(mValueVec4, location, val))
{
glUniform3fARB(location, x, y, z);
}
}
void uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
if (location < 0)
return;
if (updateUniform<LLVector4, 1>(mValueVec4, location, v))
{
glUniform1fvARB(location, count, v);
}
}
void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
if (location < 0)
return;
if (updateUniform<LLVector4, 2>(mValueVec4, location, v))
{
glUniform2fvARB(location, count, v);
}
}
void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
if (location < 0)
return;
if (updateUniform<LLVector4, 3>(mValueVec4, location, v))
{
glUniform3fvARB(location, count, v);
}
}
void uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
if (location < 0)
return;
if (updateUniform<LLVector4, 4>(mValueVec4, location, v))
{
glUniform4fvARB(location, count, v);
}
}
void uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat *v)
{
GLint location = getUniformLocation(uniform);
if (location < 0)
return;
if (updateUniform<LLMatrix4, 16>(mValueMat4, location, v))
{
glUniformMatrix4fvARB(location, count, transpose, v);
}
}
void setMinimumAlpha(F32 minimum); void setMinimumAlpha(F32 minimum);
void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void vertexAttrib4fv(U32 index, GLfloat* v);
//GLint getUniformLocation(const std::string& uniform); GLint getUniformLocation(const LLStaticHashedString& uniform)
GLint getUniformLocation(const LLStaticHashedString& uniform); {
GLint ret = -1;
if (mProgramObject > 0)
{
LLStaticStringTable<GLint>::iterator iter = mUniformMap.find(uniform);
if (iter != mUniformMap.end())
{
if (gDebugGL)
{
stop_glerror();
if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.String().c_str()))
{
llerrs << "Uniform does not match." << llendl;
}
stop_glerror();
}
ret = iter->second;
}
}
return ret;
}
GLint getUniformLocation(U32 index); GLint getUniformLocation(U32 index);
GLint getAttribLocation(U32 attrib); GLint getAttribLocation(U32 attrib);
@@ -156,9 +379,12 @@ public:
U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask()) 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::vector<GLint> mUniform; //lookup table of uniform enum to uniform location
LLStaticStringTable<GLint> mUniformMap; //lookup map of uniform name to uniform location LLStaticStringTable<GLint> mUniformMap; //lookup map of uniform name to uniform location
std::map<GLint, std::string> mUniformNameMap; //lookup map of uniform location to uniform name //There are less naive ways to do this than just having several vectors for the differing types, but this method is of least complexity and has some inherent type-safety.
std::map<GLint, LLVector4> mValue; //lookup map of uniform location to last known value std::vector<std::pair<GLint, LLVector4> > mValueVec4; //lookup map of uniform location to last known value
std::vector<GLint> mTexture; std::vector<std::pair<GLint, LLMatrix3> > mValueMat3; //lookup map of uniform location to last known value
std::vector<std::pair<GLint, LLMatrix4> > mValueMat4; //lookup map of uniform location to last known value
std::vector<GLint> mTexture; //lookup table of texture uniform enum to texture channel
S32 mTotalUniformSize; S32 mTotalUniformSize;
S32 mActiveTextureChannels; S32 mActiveTextureChannels;
S32 mShaderClass; S32 mShaderClass;

View File

@@ -333,8 +333,8 @@ void LLImageGL::destroyGL(BOOL save_state)
gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE);
} }
int stored_count = 0;
sAllowReadBackRaw = true ; sAllowReadBackRaw = true ;
std::set<LLImageGL*> stored_images;
for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); for (std::set<LLImageGL*>::iterator iter = sImageList.begin();
iter != sImageList.end(); iter++) iter != sImageList.end(); iter++)
{ {
@@ -346,20 +346,21 @@ void LLImageGL::destroyGL(BOOL save_state)
glimage->mSaveData = new LLImageRaw; glimage->mSaveData = new LLImageRaw;
if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) //necessary, keep it. if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) //necessary, keep it.
{ {
glimage->mSaveData = NULL ; delete glimage;
} }
else else
{ {
glimage->mSaveDiscardLevel = glimage->mCurrentDiscardLevel; glimage->mSaveDiscardLevel = glimage->mCurrentDiscardLevel;
stored_count++; stored_images.insert(glimage);
glimage->destroyGLTexture();
} }
} }
glimage->destroyGLTexture();
stop_glerror(); stop_glerror();
} }
} }
llinfos << "Storing " << stored_count << " images..." << llendl; sImageList = stored_images;
llinfos << "Storing " << stored_images.size() << " images..." << llendl;
sAllowReadBackRaw = false ; sAllowReadBackRaw = false ;
} }
@@ -367,7 +368,7 @@ void LLImageGL::destroyGL(BOOL save_state)
void LLImageGL::restoreGL() void LLImageGL::restoreGL()
{ {
int recovered_count = 0; std::set<LLImageGL*> restored_images;
for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); for (std::set<LLImageGL*>::iterator iter = sImageList.begin();
iter != sImageList.end(); iter++) iter != sImageList.end(); iter++)
{ {
@@ -376,19 +377,22 @@ void LLImageGL::restoreGL()
{ {
llerrs << "tex name is not 0." << llendl ; llerrs << "tex name is not 0." << llendl ;
} }
if (glimage->mSaveData.notNull()) if (glimage->mSaveData.notNull() && glimage->getComponents() &&
glimage->mSaveData->getComponents() &&
glimage->mSaveDiscardLevel >= 0 &&
glimage->createGLTexture(glimage->mSaveDiscardLevel, glimage->mSaveData, 0, TRUE, glimage->getCategory()))
{ {
if (glimage->getComponents() && glimage->mSaveData->getComponents() && glimage->mSaveDiscardLevel >= 0)
{
glimage->createGLTexture(glimage->mSaveDiscardLevel, glimage->mSaveData, 0, TRUE, glimage->getCategory());
stop_glerror(); stop_glerror();
recovered_count++; restored_images.insert(glimage);
} }
glimage->mSaveData = NULL; // deletes data else
glimage->mSaveDiscardLevel = -1; {
delete glimage;
} }
} }
llinfos << "Restored " << recovered_count << " images" << llendl;
restored_images = restored_images;
llinfos << "Restored " << restored_images.size() << " images" << llendl;
} }
//static //static

View File

@@ -1096,15 +1096,7 @@ void LLRender::init()
glBindVertexArray(ret); glBindVertexArray(ret);
#endif #endif
} }
restoreVertexBuffers();
llassert_always(mBuffer.isNull()) ;
stop_glerror();
mBuffer = new LLVertexBuffer(immediate_mask, 0);
mBuffer->allocateBuffer(4096, 0, TRUE);
mBuffer->getVertexStrider(mVerticesp);
mBuffer->getTexCoord0Strider(mTexcoordsp);
mBuffer->getColorStrider(mColorsp);
stop_glerror();
} }
void LLRender::shutdown() void LLRender::shutdown()
@@ -1148,6 +1140,23 @@ void LLRender::refreshState(void)
mDirty = false; mDirty = false;
} }
void LLRender::resetVertexBuffers()
{
mBuffer = NULL;
}
void LLRender::restoreVertexBuffers()
{
llassert_always(mBuffer.isNull());
stop_glerror();
mBuffer = new LLVertexBuffer(immediate_mask, 0);
mBuffer->allocateBuffer(4096, 0, TRUE);
mBuffer->getVertexStrider(mVerticesp);
mBuffer->getTexCoord0Strider(mTexcoordsp);
mBuffer->getColorStrider(mColorsp);
stop_glerror();
}
void LLRender::syncLightState() void LLRender::syncLightState()
{ {
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;

View File

@@ -346,6 +346,9 @@ public:
// Needed when the render context has changed and invalidated the current state // Needed when the render context has changed and invalidated the current state
void refreshState(void); void refreshState(void);
void resetVertexBuffers();
void restoreVertexBuffers();
LLMatrix4a genRot(const GLfloat& a, const LLVector4a& axis) const; LLMatrix4a genRot(const GLfloat& a, const LLVector4a& axis) const;
LLMatrix4a genRot(const GLfloat& a, const GLfloat& x, const GLfloat& y, const GLfloat& z) const { return genRot(a,LLVector4a(x,y,z)); } LLMatrix4a genRot(const GLfloat& a, const GLfloat& x, const GLfloat& y, const GLfloat& z) const { return genRot(a,LLVector4a(x,y,z)); }
LLMatrix4a genOrtho(const GLfloat& left, const GLfloat& right, const GLfloat& bottom, const GLfloat& top, const GLfloat& znear, const GLfloat& zfar) const; LLMatrix4a genOrtho(const GLfloat& left, const GLfloat& right, const GLfloat& bottom, const GLfloat& top, const GLfloat& znear, const GLfloat& zfar) const;

View File

@@ -1056,6 +1056,10 @@ LLSpatialPartition* LLDrawable::getSpatialPartition()
{ {
setSpatialBridge(new LLHUDBridge(this)); setSpatialBridge(new LLHUDBridge(this));
} }
else if (mVObjp->isAttachment())
{
setSpatialBridge(new LLAttachmentBridge(this));
}
else else
{ {
setSpatialBridge(new LLVolumeBridge(this)); setSpatialBridge(new LLVolumeBridge(this));
@@ -1663,12 +1667,18 @@ void LLDrawable::updateFaceSize(S32 idx)
LLBridgePartition::LLBridgePartition() LLBridgePartition::LLBridgePartition()
: LLSpatialPartition(0, FALSE, 0) : LLSpatialPartition(0, FALSE, 0)
{ {
mDrawableType = LLPipeline::RENDER_TYPE_AVATAR; mDrawableType = LLPipeline::RENDER_TYPE_VOLUME;
mPartitionType = LLViewerRegion::PARTITION_BRIDGE; mPartitionType = LLViewerRegion::PARTITION_BRIDGE;
mLODPeriod = 16; mLODPeriod = 16;
mSlopRatio = 0.25f; mSlopRatio = 0.25f;
} }
LLAttachmentPartition::LLAttachmentPartition()
: LLBridgePartition()
{
mDrawableType = LLPipeline::RENDER_TYPE_AVATAR;
}
LLHUDBridge::LLHUDBridge(LLDrawable* drawablep) LLHUDBridge::LLHUDBridge(LLDrawable* drawablep)
: LLVolumeBridge(drawablep) : LLVolumeBridge(drawablep)
{ {

View File

@@ -792,6 +792,7 @@ void LLSpatialGroup::shift(const LLVector4a &offset)
if (!mSpatialPartition->mRenderByGroup && if (!mSpatialPartition->mRenderByGroup &&
mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TREE && mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TREE &&
mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TERRAIN && mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TERRAIN &&
mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_ATTACHMENT &&
mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_BRIDGE) mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_BRIDGE)
{ {
setState(GEOM_DIRTY); setState(GEOM_DIRTY);
@@ -2174,6 +2175,10 @@ public:
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i) for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
{ {
LLDrawable* drawable = *i; LLDrawable* drawable = *i;
if (drawable->getVObj().notNull())
{
drawable->getVObj()->resetVertexBuffers();
}
if (drawable->getVObj().notNull() && !group->mSpatialPartition->mRenderByGroup) if (drawable->getVObj().notNull() && !group->mSpatialPartition->mRenderByGroup)
{ {
gPipeline.markRebuild(drawable, LLDrawable::REBUILD_ALL, TRUE); gPipeline.markRebuild(drawable, LLDrawable::REBUILD_ALL, TRUE);

View File

@@ -737,6 +737,12 @@ public:
virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { LLVolumeGeometryManager::addGeometryCount(group, vertex_count, index_count); } virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { LLVolumeGeometryManager::addGeometryCount(group, vertex_count, index_count); }
}; };
class LLAttachmentBridge : public LLVolumeBridge
{
public:
LLAttachmentBridge(LLDrawable* drawable);
};
class LLHUDBridge : public LLVolumeBridge class LLHUDBridge : public LLVolumeBridge
{ {
public: public:
@@ -754,11 +760,18 @@ public:
virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { } virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { }
}; };
//spatial partition that holds nothing but spatial bridges
class LLAttachmentPartition : public LLBridgePartition
{
public:
LLAttachmentPartition();
};
class LLHUDPartition : public LLBridgePartition class LLHUDPartition : public LLBridgePartition
{ {
public: public:
LLHUDPartition(); LLHUDPartition();
virtual void shift(const LLVector4a &offset); virtual void shift(const LLVector4a &offset) { } //HUD objects don't shift with region crossing. That would be silly.
}; };
extern const F32 SG_BOX_SIDE; extern const F32 SG_BOX_SIDE;

View File

@@ -1162,7 +1162,7 @@ void LLViewerJoystick::moveFlycam(bool reset)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool LLViewerJoystick::toggleFlycam() bool LLViewerJoystick::toggleFlycam()
{ {
if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX) || (gRlvHandler.hasBehaviour(RLV_BHVR_CAMUNLOCK) // [RLVa:LF] - @camdistmax and @camunlock mean no going away! if (gRlvHandler.hasBehaviour(RLV_BHVR_CAMDISTMAX) || gRlvHandler.hasBehaviour(RLV_BHVR_CAMUNLOCK) // [RLVa:LF] - @camdistmax and @camunlock mean no going away!
|| !gSavedSettings.getBOOL("JoystickEnabled") || !gSavedSettings.getBOOL("JoystickFlycamEnabled")) || !gSavedSettings.getBOOL("JoystickEnabled") || !gSavedSettings.getBOOL("JoystickFlycamEnabled"))
{ {
mOverrideCamera = false; mOverrideCamera = false;

View File

@@ -133,6 +133,7 @@ public:
LLViewerObject(const LLUUID &id, const LLPCode type, LLViewerRegion *regionp, BOOL is_global = FALSE); LLViewerObject(const LLUUID &id, const LLPCode type, LLViewerRegion *regionp, BOOL is_global = FALSE);
virtual void resetVertexBuffers() {}
virtual void markDead(); // Mark this object as dead, and clean up its references virtual void markDead(); // Mark this object as dead, and clean up its references
BOOL isDead() const {return mDead;} BOOL isDead() const {return mDead;}
BOOL isOrphaned() const { return mOrphaned; } BOOL isOrphaned() const { return mOrphaned; }

View File

@@ -380,6 +380,7 @@ void LLViewerRegion::initPartitions()
mImpl->mObjectPartition.push_back(new LLGrassPartition()); //PARTITION_GRASS mImpl->mObjectPartition.push_back(new LLGrassPartition()); //PARTITION_GRASS
mImpl->mObjectPartition.push_back(new LLVolumePartition()); //PARTITION_VOLUME mImpl->mObjectPartition.push_back(new LLVolumePartition()); //PARTITION_VOLUME
mImpl->mObjectPartition.push_back(new LLBridgePartition()); //PARTITION_BRIDGE mImpl->mObjectPartition.push_back(new LLBridgePartition()); //PARTITION_BRIDGE
mImpl->mObjectPartition.push_back(new LLAttachmentPartition()); //PARTITION_ATTACHMENT
mImpl->mObjectPartition.push_back(new LLHUDParticlePartition());//PARTITION_HUD_PARTICLE mImpl->mObjectPartition.push_back(new LLHUDParticlePartition());//PARTITION_HUD_PARTICLE
mImpl->mObjectPartition.push_back(NULL); //PARTITION_NONE mImpl->mObjectPartition.push_back(NULL); //PARTITION_NONE
} }

View File

@@ -99,6 +99,7 @@ public:
PARTITION_GRASS, PARTITION_GRASS,
PARTITION_VOLUME, PARTITION_VOLUME,
PARTITION_BRIDGE, PARTITION_BRIDGE,
PARTITION_ATTACHMENT,
PARTITION_HUD_PARTICLE, PARTITION_HUD_PARTICLE,
PARTITION_NONE, PARTITION_NONE,
NUM_PARTITIONS NUM_PARTITIONS

View File

@@ -1737,7 +1737,6 @@ LLViewerWindow::LLViewerWindow(
} }
LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable"), gSavedSettings.getBOOL("RenderVBOMappingDisable")); LLVertexBuffer::initClass(gSavedSettings.getBOOL("RenderVBOEnable"), gSavedSettings.getBOOL("RenderVBOMappingDisable"));
LL_INFOS("RenderInit") << "LLVertexBuffer initialization done." << LL_ENDL ; LL_INFOS("RenderInit") << "LLVertexBuffer initialization done." << LL_ENDL ;
gGL.init() ;
LLImageGL::initClass(LLViewerTexture::MAX_GL_IMAGE_CATEGORY) ; LLImageGL::initClass(LLViewerTexture::MAX_GL_IMAGE_CATEGORY) ;
if (LLFeatureManager::getInstance()->isSafe() if (LLFeatureManager::getInstance()->isSafe()
@@ -5308,6 +5307,8 @@ void LLViewerWindow::stopGL(BOOL save_state)
gGLManager.mIsDisabled = TRUE; gGLManager.mIsDisabled = TRUE;
stop_glerror(); stop_glerror();
gGL.resetVertexBuffers();
llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemoryInBytes << " bytes" << llendl; llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemoryInBytes << " bytes" << llendl;
} }
} }
@@ -5323,6 +5324,7 @@ void LLViewerWindow::restoreGL(const std::string& progress_message)
llinfos << "Restoring GL..." << llendl; llinfos << "Restoring GL..." << llendl;
gGLManager.mIsDisabled = FALSE; gGLManager.mIsDisabled = FALSE;
gGL.init();
initGLDefaults(); initGLDefaults();
gGL.refreshState(); //Singu Note: Call immediately. Cached states may have prevented initGLDefaults from actually applying changes. gGL.refreshState(); //Singu Note: Call immediately. Cached states may have prevented initGLDefaults from actually applying changes.
LLGLState::restoreGL(); LLGLState::restoreGL();

View File

@@ -9029,7 +9029,7 @@ void LLVOAvatar::updateSoftwareSkinnedVertices(const LLMeshSkinInfo* skin, const
U32 LLVOAvatar::getPartitionType() const U32 LLVOAvatar::getPartitionType() const
{ {
// Avatars merely exist as drawables in the bridge partition // Avatars merely exist as drawables in the bridge partition
return LLViewerRegion::PARTITION_BRIDGE; return LLViewerRegion::PARTITION_ATTACHMENT;
} }
//static //static

View File

@@ -1516,10 +1516,10 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons
*indicesp++ = index_offset + 2; *indicesp++ = index_offset + 2;
*indicesp++ = index_offset + 3; *indicesp++ = index_offset + 3;
*(colorsp++) = LLColor4::white; *(colorsp++) = LLColor4U::white;
*(colorsp++) = LLColor4::white; *(colorsp++) = LLColor4U::white;
*(colorsp++) = LLColor4::white; *(colorsp++) = LLColor4U::white;
*(colorsp++) = LLColor4::white; *(colorsp++) = LLColor4U::white;
facep->getVertexBuffer()->flush(); facep->getVertexBuffer()->flush();

View File

@@ -550,6 +550,11 @@ const S32 LEAF_VERTICES = 16;
static LLFastTimer::DeclareTimer FTM_UPDATE_TREE("Update Tree"); static LLFastTimer::DeclareTimer FTM_UPDATE_TREE("Update Tree");
void LLVOTree::resetVertexBuffers()
{
mReferenceBuffer = NULL;
}
BOOL LLVOTree::updateGeometry(LLDrawable *drawable) BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
{ {
LLFastTimer ftm(FTM_UPDATE_TREE); LLFastTimer ftm(FTM_UPDATE_TREE);

View File

@@ -77,6 +77,7 @@ public:
/*virtual*/ BOOL updateGeometry(LLDrawable *drawable); /*virtual*/ BOOL updateGeometry(LLDrawable *drawable);
/*virtual*/ void updateSpatialExtents(LLVector4a &min, LLVector4a &max); /*virtual*/ void updateSpatialExtents(LLVector4a &min, LLVector4a &max);
void resetVertexBuffers();
virtual U32 getPartitionType() const; virtual U32 getPartitionType() const;
void updateRadius(); void updateRadius();

View File

@@ -4000,6 +4000,10 @@ U32 LLVOVolume::getPartitionType() const
{ {
return LLViewerRegion::PARTITION_HUD; return LLViewerRegion::PARTITION_HUD;
} }
else if (isAttachment())
{
return LLViewerRegion::PARTITION_ATTACHMENT;
}
return LLViewerRegion::PARTITION_VOLUME; return LLViewerRegion::PARTITION_VOLUME;
} }
@@ -4028,6 +4032,12 @@ LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep)
mSlopRatio = 0.25f; mSlopRatio = 0.25f;
} }
LLAttachmentBridge::LLAttachmentBridge(LLDrawable* drawablep)
: LLVolumeBridge(drawablep)
{
mPartitionType = LLViewerRegion::PARTITION_ATTACHMENT;
}
bool can_batch_texture(const LLFace* facep) bool can_batch_texture(const LLFace* facep)
{ {
static const LLCachedControl<bool> alt_batching("SHAltBatching",true); static const LLCachedControl<bool> alt_batching("SHAltBatching",true);
@@ -5209,29 +5219,22 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
//PROCESS NON-ALPHA FACES //PROCESS NON-ALPHA FACES
U32 simple_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR; U32 simple_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR;
U32 alpha_mask = simple_mask | 0x80000000; //hack to give alpha verts their own VBO U32 alpha_mask = simple_mask | 0x80000000; //hack to give alpha verts their own VBO
U32 bump_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TANGENT; U32 bump_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD1;
U32 fullbright_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR; U32 fullbright_mask = LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR;
U32 norm_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TANGENT; U32 norm_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TANGENT;
U32 normspec_mask = norm_mask | LLVertexBuffer::MAP_TEXCOORD2; U32 normspec_mask = norm_mask | LLVertexBuffer::MAP_TEXCOORD2;
U32 spec_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD2; U32 spec_mask = simple_mask | LLVertexBuffer::MAP_TEXCOORD2;
if (emissive)
{ //emissive faces are present, include emissive byte to preserve batching
simple_mask = simple_mask | LLVertexBuffer::MAP_EMISSIVE;
alpha_mask = alpha_mask | LLVertexBuffer::MAP_EMISSIVE;
bump_mask = bump_mask | LLVertexBuffer::MAP_EMISSIVE;
fullbright_mask = fullbright_mask | LLVertexBuffer::MAP_EMISSIVE;
norm_mask = norm_mask | LLVertexBuffer::MAP_EMISSIVE;
normspec_mask = normspec_mask | LLVertexBuffer::MAP_EMISSIVE;
spec_mask = spec_mask | LLVertexBuffer::MAP_EMISSIVE;
}
BOOL batch_textures = LLGLSLShader::sNoFixedFunction; BOOL batch_textures = LLGLSLShader::sNoFixedFunction;
U32 additional_flags = 0x0; U32 additional_flags = 0x0;
if(batch_textures) if(batch_textures)
additional_flags |= LLVertexBuffer::MAP_TEXTURE_INDEX; additional_flags |= LLVertexBuffer::MAP_TEXTURE_INDEX;
if (LLPipeline::sRenderDeferred)
bump_mask = norm_mask;
//emissive faces are present, include emissive byte to preserve batching
if(emissive) if(emissive)
additional_flags |= LLVertexBuffer::MAP_EMISSIVE; additional_flags |= LLVertexBuffer::MAP_EMISSIVE;
@@ -6390,9 +6393,4 @@ LLHUDPartition::LLHUDPartition()
mLODPeriod = 1; mLODPeriod = 1;
} }
void LLHUDPartition::shift(const LLVector4a &offset)
{
//HUD objects don't shift with region crossing. That would be silly.
}

View File

@@ -491,6 +491,8 @@ void LLPipeline::init()
gSavedSettings.getControl("RenderFSAASamples")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); gSavedSettings.getControl("RenderFSAASamples")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings));
//gSavedSettings.getControl("RenderAvatarVP")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); //Already registered to handleSetShaderChanged //gSavedSettings.getControl("RenderAvatarVP")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); //Already registered to handleSetShaderChanged
//gSavedSettings.getControl("WindLightUseAtmosShaders")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); //Already registered to handleSetShaderChanged //gSavedSettings.getControl("WindLightUseAtmosShaders")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings)); //Already registered to handleSetShaderChanged
gGL.init();
} }
LLPipeline::~LLPipeline() LLPipeline::~LLPipeline()
@@ -1206,10 +1208,7 @@ void LLPipeline::restoreGL()
{ {
assertInitialized(); assertInitialized();
if (LLGLSLShader::sNoFixedFunction) LLViewerShaderMgr::instance()->setShaders();
{
LLViewerShaderMgr::instance()->setShaders();
}
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter) iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
@@ -1291,11 +1290,13 @@ S32 LLPipeline::setLightingDetail(S32 level)
} }
level = llclamp(level, 0, getMaxLightingDetail()); level = llclamp(level, 0, getMaxLightingDetail());
//Bugfix: If setshaders was called with RenderLocalLights off then enabling RenderLocalLights later will not work. Reloading shaders fixes this. //Bugfix: If setshaders was called with RenderLocalLights off then enabling RenderLocalLights later will not work. Reloading shaders fixes this.
if (level != mLightingDetail && LLGLSLShader::sNoFixedFunction) if (level != mLightingDetail)
{ {
LLViewerShaderMgr::instance()->setShaders(); mLightingDetail = level;
if (LLGLSLShader::sNoFixedFunction)
LLViewerShaderMgr::instance()->setShaders();
} }
mLightingDetail = level;
return mLightingDetail; return mLightingDetail;
} }
@@ -6495,6 +6496,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start,
for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++) for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++)
{ {
if ((j == LLViewerRegion::PARTITION_VOLUME) || if ((j == LLViewerRegion::PARTITION_VOLUME) ||
(j == LLViewerRegion::PARTITION_ATTACHMENT) ||
(j == LLViewerRegion::PARTITION_BRIDGE) || (j == LLViewerRegion::PARTITION_BRIDGE) ||
(j == LLViewerRegion::PARTITION_TERRAIN) || (j == LLViewerRegion::PARTITION_TERRAIN) ||
(j == LLViewerRegion::PARTITION_TREE) || (j == LLViewerRegion::PARTITION_TREE) ||
@@ -6557,7 +6559,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start,
{ {
LLViewerRegion* region = *iter; LLViewerRegion* region = *iter;
LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_BRIDGE); LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_ATTACHMENT);
if (part && hasRenderType(part->mDrawableType)) if (part && hasRenderType(part->mDrawableType))
{ {
LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, tangent); LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, face_hit, &position, tex_coord, normal, tangent);
@@ -6743,6 +6745,8 @@ void LLPipeline::doResetVertexBuffers()
//delete all name pool caches //delete all name pool caches
LLGLNamePool::cleanupPools(); LLGLNamePool::cleanupPools();
gGL.resetVertexBuffers();
if (LLVertexBuffer::sGLCount > 0) if (LLVertexBuffer::sGLCount > 0)
{ {
llwarns << "VBO wipe failed -- " << LLVertexBuffer::sGLCount << " buffers remaining." << llendl; llwarns << "VBO wipe failed -- " << LLVertexBuffer::sGLCount << " buffers remaining." << llendl;
@@ -6762,6 +6766,8 @@ void LLPipeline::doResetVertexBuffers()
LLVertexBuffer::initClass(LLVertexBuffer::sEnableVBOs, LLVertexBuffer::sDisableVBOMapping); LLVertexBuffer::initClass(LLVertexBuffer::sEnableVBOs, LLVertexBuffer::sDisableVBOMapping);
LLVOPartGroup::restoreGL(); LLVOPartGroup::restoreGL();
gGL.restoreVertexBuffers();
} }
void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture, BOOL batch_texture) void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture, BOOL batch_texture)