llrender and lldir merge. Removed duplicate assets from skins. cleaned up skin textures.xml files to only include changes from default.

This commit is contained in:
Shyotl
2016-04-11 02:51:08 -05:00
parent d40256fb31
commit be5d2f20bc
1280 changed files with 2354 additions and 10692 deletions

View File

@@ -38,6 +38,11 @@
#include "OpenGL/OpenGL.h"
#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
using std::vector;
using std::pair;
@@ -48,6 +53,12 @@ GLhandleARB LLGLSLShader::sCurBoundShader = 0;
LLGLSLShader* LLGLSLShader::sCurBoundShaderPtr = NULL;
S32 LLGLSLShader::sIndexedTextureChannels = 0;
bool LLGLSLShader::sNoFixedFunction = false;
bool LLGLSLShader::sProfileEnabled = false;
std::set<LLGLSLShader*> LLGLSLShader::sInstances;
U64 LLGLSLShader::sTotalTimeElapsed = 0;
U32 LLGLSLShader::sTotalTrianglesDrawn = 0;
U64 LLGLSLShader::sTotalSamplesDrawn = 0;
U32 LLGLSLShader::sTotalDrawCalls = 0;
//UI shader -- declared here so llui_libtest will link properly
//Singu note: Not using llui_libtest... and LLViewerShaderMgr is a part of newview. So,
@@ -77,13 +88,221 @@ LLShaderFeatures::LLShaderFeatures()
, hasGamma(false)
, mIndexedTextureChannels(0)
, disableTextureIndex(false)
, hasAlphaMask(false)
, hasAlphaMask(false)
, attachNothing(false)
{
}
//===============================
// LLGLSL Shader implementation
//===============================
//static
void LLGLSLShader::initProfile()
{
sProfileEnabled = true;
sTotalTimeElapsed = 0;
sTotalTrianglesDrawn = 0;
sTotalSamplesDrawn = 0;
sTotalDrawCalls = 0;
for (std::set<LLGLSLShader*>::iterator iter = sInstances.begin(); iter != sInstances.end(); ++iter)
{
(*iter)->clearStats();
}
}
struct LLGLSLShaderCompareTimeElapsed
{
bool operator()(const LLGLSLShader* const& lhs, const LLGLSLShader* const& rhs)
{
return lhs->mTimeElapsed < rhs->mTimeElapsed;
}
};
//static
void LLGLSLShader::finishProfile(bool emit_report)
{
sProfileEnabled = false;
if (emit_report)
{
std::vector<LLGLSLShader*> sorted;
for (std::set<LLGLSLShader*>::iterator iter = sInstances.begin(); iter != sInstances.end(); ++iter)
{
sorted.push_back(*iter);
}
std::sort(sorted.begin(), sorted.end(), LLGLSLShaderCompareTimeElapsed());
for (std::vector<LLGLSLShader*>::iterator iter = sorted.begin(); iter != sorted.end(); ++iter)
{
(*iter)->dumpStats();
}
LL_INFOS() << "-----------------------------------" << LL_ENDL;
LL_INFOS() << "Total rendering time: " << llformat("%.4f ms", sTotalTimeElapsed/1000000.f) << LL_ENDL;
LL_INFOS() << "Total samples drawn: " << llformat("%.4f million", sTotalSamplesDrawn/1000000.f) << LL_ENDL;
LL_INFOS() << "Total triangles drawn: " << llformat("%.3f million", sTotalTrianglesDrawn/1000000.f) << LL_ENDL;
}
}
void LLGLSLShader::clearStats()
{
mTrianglesDrawn = 0;
mTimeElapsed = 0;
mSamplesDrawn = 0;
mDrawCalls = 0;
mTextureStateFetched = false;
mTextureMagFilter.clear();
mTextureMinFilter.clear();
}
void LLGLSLShader::dumpStats()
{
if (mDrawCalls > 0)
{
LL_INFOS() << "=============================================" << LL_ENDL;
LL_INFOS() << mName << LL_ENDL;
for (U32 i = 0; i < mShaderFiles.size(); ++i)
{
LL_INFOS() << mShaderFiles[i].first << LL_ENDL;
}
for (U32 i = 0; i < mTexture.size(); ++i)
{
GLint idx = mTexture[i];
if (idx >= 0)
{
GLint uniform_idx = getUniformLocation(i);
LL_INFOS() << mUniformNameMap[uniform_idx] << " - " << std::hex << mTextureMagFilter[i] << "/" << mTextureMinFilter[i] << std::dec << LL_ENDL;
}
}
LL_INFOS() << "=============================================" << LL_ENDL;
F32 ms = mTimeElapsed/1000000.f;
F32 seconds = ms/1000.f;
F32 pct_tris = (F32) mTrianglesDrawn/(F32)sTotalTrianglesDrawn*100.f;
F32 tris_sec = (F32) (mTrianglesDrawn/1000000.0);
tris_sec /= seconds;
F32 pct_samples = (F32) ((F64)mSamplesDrawn/(F64)sTotalSamplesDrawn)*100.f;
F32 samples_sec = (F32) mSamplesDrawn/1000000000.0;
samples_sec /= seconds;
F32 pct_calls = (F32) mDrawCalls/(F32)sTotalDrawCalls*100.f;
U32 avg_batch = mTrianglesDrawn/mDrawCalls;
LL_INFOS() << "Triangles Drawn: " << mTrianglesDrawn << " " << llformat("(%.2f pct of total, %.3f million/sec)", pct_tris, tris_sec ) << LL_ENDL;
LL_INFOS() << "Draw Calls: " << mDrawCalls << " " << llformat("(%.2f pct of total, avg %d tris/call)", pct_calls, avg_batch) << LL_ENDL;
LL_INFOS() << "SamplesDrawn: " << mSamplesDrawn << " " << llformat("(%.2f pct of total, %.3f billion/sec)", pct_samples, samples_sec) << LL_ENDL;
LL_INFOS() << "Time Elapsed: " << mTimeElapsed << " " << llformat("(%.2f pct of total, %.5f ms)\n", (F32) ((F64)mTimeElapsed/(F64)sTotalTimeElapsed)*100.f, ms) << LL_ENDL;
}
}
//static
void LLGLSLShader::startProfile()
{
if (sProfileEnabled && sCurBoundShaderPtr)
{
sCurBoundShaderPtr->placeProfileQuery();
}
}
//static
void LLGLSLShader::stopProfile(U32 count, U32 mode)
{
if (sProfileEnabled && sCurBoundShaderPtr)
{
sCurBoundShaderPtr->readProfileQuery(count, mode);
}
}
void LLGLSLShader::placeProfileQuery()
{
#if !LL_DARWIN
if (mTimerQuery == 0)
{
glGenQueriesARB(1, &mSamplesQuery);
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, mSamplesQuery);
glBeginQueryARB(GL_TIME_ELAPSED, mTimerQuery);
#endif
}
void LLGLSLShader::readProfileQuery(U32 count, U32 mode)
{
#if !LL_DARWIN
glEndQueryARB(GL_TIME_ELAPSED);
glEndQueryARB(GL_SAMPLES_PASSED);
GLuint64 time_elapsed = 0;
glGetQueryObjectui64vEXT(mTimerQuery, GL_QUERY_RESULT, &time_elapsed);
GLuint64 samples_passed = 0;
glGetQueryObjectui64vEXT(mSamplesQuery, GL_QUERY_RESULT, &samples_passed);
sTotalTimeElapsed += time_elapsed;
mTimeElapsed += time_elapsed;
sTotalSamplesDrawn += samples_passed;
mSamplesDrawn += samples_passed;
U32 tri_count = 0;
switch (mode)
{
case LLRender::TRIANGLES: tri_count = count/3; break;
case LLRender::TRIANGLE_FAN: tri_count = count-2; break;
case LLRender::TRIANGLE_STRIP: tri_count = count-2; break;
default: tri_count = count; break; //points lines etc just use primitive count
}
mTrianglesDrawn += tri_count;
sTotalTrianglesDrawn += tri_count;
sTotalDrawCalls++;
mDrawCalls++;
#endif
}
LLGLSLShader::LLGLSLShader(S32 shader_class)
: mProgramObject(0),
mShaderClass(shader_class),
@@ -91,20 +310,25 @@ LLGLSLShader::LLGLSLShader(S32 shader_class)
mTotalUniformSize(0),
mActiveTextureChannels(0),
mShaderLevel(0),
mShaderGroup(SG_DEFAULT),
mUniformsDirty(FALSE)
mShaderGroup(SG_DEFAULT),
mUniformsDirty(FALSE),
mTimerQuery(0),
mSamplesQuery(0)
{
LLShaderMgr::getGlobalShaderList().push_back(this);
}
LLGLSLShader::~LLGLSLShader()
{
{
}
void LLGLSLShader::unload()
{
stop_glerror();
mAttribute.clear();
sInstances.erase(this);
stop_glerror();
mAttribute.clear();
mTexture.clear();
mUniform.clear();
mShaderFiles.clear();
@@ -126,10 +350,22 @@ void LLGLSLShader::unload()
glDeleteObjectARB(mProgramObject);
mProgramObject = 0;
}
//hack to make apple not complain
glGetError();
if (mTimerQuery)
{
glDeleteQueriesARB(1, &mTimerQuery);
mTimerQuery = 0;
}
if (mSamplesQuery)
{
glDeleteQueriesARB(1, &mSamplesQuery);
mSamplesQuery = 0;
}
//hack to make apple not complain
glGetError();
stop_glerror();
}
@@ -138,9 +374,11 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
U32 varying_count,
const char** varyings)
{
//reloading, reset matrix hash values
for (U32 i = 0; i < LLRender::NUM_MATRIX_MODES; ++i)
{
sInstances.insert(this);
//reloading, reset matrix hash values
for (U32 i = 0; i < LLRender::NUM_MATRIX_MODES; ++i)
{
mMatHash[i] = 0xFFFFFFFF;
}
mLightHash = 0xFFFFFFFF;
@@ -243,9 +481,18 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
}
}
unbind();
}
}
return success;
if (LLShaderMgr::instance()->mProgramObjects.find(mName) == LLShaderMgr::instance()->mProgramObjects.end())
{
LLShaderMgr::instance()->mProgramObjects.emplace(mName, mProgramObject);
}
else
{
LL_WARNS("ShaderLoading") << "Attempting to create shader program with duplicate name: " << mName << LL_ENDL;
}
return success;
}
BOOL LLGLSLShader::attachObject(std::string object)
@@ -425,6 +672,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *
}
LLStaticHashedString hashedName(name);
mUniformNameMap[location] = name;
mUniformMap[hashedName] = location;
LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL;
@@ -489,6 +737,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
mActiveTextureChannels = 0;
mUniform.clear();
mUniformMap.clear();
mUniformNameMap.clear();
mTexture.clear();
mValueVec4.clear();
mValueMat3.clear();