Merge remote-tracking branch 'upstream/master'
Conflicts: indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedNoColorF.glsl indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl indra/newview/app_settings/shaders/class1/deferred/giF.glsl indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
This commit is contained in:
@@ -450,7 +450,9 @@ LLGLManager::LLGLManager() :
|
||||
mIsGFFX(FALSE),
|
||||
mATIOffsetVerticalLines(FALSE),
|
||||
mATIOldDriver(FALSE),
|
||||
|
||||
#if LL_DARWIN
|
||||
mIsMobileGF(FALSE),
|
||||
#endif
|
||||
mHasRequirements(TRUE),
|
||||
|
||||
mHasSeparateSpecularColor(FALSE),
|
||||
@@ -648,6 +650,14 @@ bool LLGLManager::initGL()
|
||||
{
|
||||
mIsGF3 = TRUE;
|
||||
}
|
||||
#if LL_DARWIN
|
||||
else if ((mGLRenderer.find("9400M") != std::string::npos)
|
||||
|| (mGLRenderer.find("9600M") != std::string::npos)
|
||||
|| (mGLRenderer.find("9800M") != std::string::npos))
|
||||
{
|
||||
mIsMobileGF = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else if (mGLVendor.find("INTEL") != std::string::npos
|
||||
|
||||
@@ -123,6 +123,11 @@ public:
|
||||
BOOL mATIOffsetVerticalLines;
|
||||
BOOL mATIOldDriver;
|
||||
|
||||
#if LL_DARWIN
|
||||
// Needed to distinguish problem cards on older Macs that break with Materials
|
||||
BOOL mIsMobileGF;
|
||||
#endif
|
||||
|
||||
// Whether this version of GL is good enough for SL to use
|
||||
BOOL mHasRequirements;
|
||||
|
||||
|
||||
@@ -159,6 +159,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++ )
|
||||
|
||||
@@ -1075,6 +1075,15 @@ LLRender::~LLRender()
|
||||
|
||||
void LLRender::init()
|
||||
{
|
||||
if (sGLCoreProfile && !LLVertexBuffer::sUseVAO)
|
||||
{ //bind a dummy vertex array object so we're core profile compliant
|
||||
#ifdef GL_ARB_vertex_array_object
|
||||
U32 ret;
|
||||
glGenVertexArrays(1, &ret);
|
||||
glBindVertexArray(ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
llassert_always(mBuffer.isNull()) ;
|
||||
stop_glerror();
|
||||
mBuffer = new LLVertexBuffer(immediate_mask, 0);
|
||||
@@ -2295,6 +2304,22 @@ void LLRender::diffuseColor4ubv(const U8* c)
|
||||
}
|
||||
}
|
||||
|
||||
void LLRender::diffuseColor4ub(U8 r, U8 g, U8 b, U8 a)
|
||||
{
|
||||
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
|
||||
llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL);
|
||||
|
||||
if (shader)
|
||||
{
|
||||
shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, r/255.f, g/255.f, b/255.f, a/255.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor4ub(r,g,b,a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLRender::debugTexUnits(void)
|
||||
{
|
||||
LL_INFOS("TextureUnit") << "Active TexUnit: " << mCurrTextureUnitIndex << LL_ENDL;
|
||||
|
||||
@@ -262,6 +262,14 @@ class LLRender
|
||||
friend class LLTexUnit;
|
||||
public:
|
||||
|
||||
enum eTexIndex
|
||||
{
|
||||
DIFFUSE_MAP = 0,
|
||||
NORMAL_MAP,
|
||||
SPECULAR_MAP,
|
||||
NUM_TEXTURE_CHANNELS,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TRIANGLES = 0,
|
||||
TRIANGLE_STRIP,
|
||||
@@ -390,6 +398,7 @@ public:
|
||||
void diffuseColor4f(F32 r, F32 g, F32 b, F32 a);
|
||||
void diffuseColor4fv(const F32* c);
|
||||
void diffuseColor4ubv(const U8* c);
|
||||
void diffuseColor4ub(U8 r, U8 g, U8 b, U8 a);
|
||||
|
||||
void vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count);
|
||||
void vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 vert_count);
|
||||
|
||||
@@ -534,8 +534,11 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
range = mShaderObjects.equal_range(filename);
|
||||
for (std::multimap<std::string, CachedObjectInfo>::iterator it = range.first; it != range.second;++it)
|
||||
{
|
||||
if((*it).second.mLevel == shader_level && (*it).second.mType == type)
|
||||
if((*it).second.mLevel == shader_level && (*it).second.mType == type && (*it).second.mDefinitions == (defines ? *defines : std::map<std::string, std::string>()))
|
||||
{
|
||||
llinfos << "Loading cached shader for " << filename << llendl;
|
||||
return (*it).second.mHandle;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum error = GL_NO_ERROR;
|
||||
@@ -727,6 +730,8 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
}
|
||||
*/
|
||||
|
||||
text[count++] = strdup("#define HAS_DIFFUSE_LOOKUP 1\n");
|
||||
|
||||
//uniform declartion
|
||||
for (S32 i = 0; i < texture_index_channels; ++i)
|
||||
{
|
||||
@@ -784,6 +789,10 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
llerrs << "Indexed texture rendering requires GLSL 1.30 or later." << llendl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text[count++] = strdup("#define HAS_DIFFUSE_LOOKUP 0\n");
|
||||
}
|
||||
|
||||
//copy file into memory
|
||||
while( fgets((char *)buff, 1024, file) != NULL && count < LL_ARRAY_SIZE(text) )
|
||||
@@ -932,7 +941,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
if (ret)
|
||||
{
|
||||
// Add shader file to map
|
||||
mShaderObjects.insert(make_pair(filename,CachedObjectInfo(ret,try_gpu_class,type)));
|
||||
mShaderObjects.insert(make_pair(filename,CachedObjectInfo(ret,try_gpu_class,type,defines)));
|
||||
shader_level = try_gpu_class;
|
||||
}
|
||||
else
|
||||
@@ -1143,6 +1152,7 @@ void LLShaderMgr::initAttribsAndUniforms()
|
||||
|
||||
|
||||
mReservedUniforms.push_back("minimum_alpha");
|
||||
mReservedUniforms.push_back("emissive_brightness");
|
||||
|
||||
mReservedUniforms.push_back("shadow_matrix");
|
||||
mReservedUniforms.push_back("env_mat");
|
||||
@@ -1205,6 +1215,12 @@ void LLShaderMgr::initAttribsAndUniforms()
|
||||
mReservedUniforms.push_back("projectionMap");
|
||||
mReservedUniforms.push_back("norm_mat");
|
||||
|
||||
mReservedUniforms.push_back("global_gamma");
|
||||
mReservedUniforms.push_back("texture_gamma");
|
||||
|
||||
mReservedUniforms.push_back("specular_color");
|
||||
mReservedUniforms.push_back("env_intensity");
|
||||
|
||||
mReservedUniforms.push_back("matrixPalette");
|
||||
|
||||
mReservedUniforms.push_back("screenTex");
|
||||
@@ -1244,6 +1260,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;
|
||||
|
||||
@@ -111,6 +111,7 @@ public:
|
||||
GLOW_DELTA,
|
||||
|
||||
MINIMUM_ALPHA,
|
||||
EMISSIVE_BRIGHTNESS,
|
||||
|
||||
DEFERRED_SHADOW_MATRIX,
|
||||
DEFERRED_ENV_MAT,
|
||||
@@ -168,7 +169,14 @@ public:
|
||||
DEFERRED_PROJECTION,
|
||||
DEFERRED_NORM_MATRIX,
|
||||
|
||||
GLOBAL_GAMMA,
|
||||
TEXTURE_GAMMA,
|
||||
|
||||
SPECULAR_COLOR,
|
||||
ENVIRONMENT_INTENSITY,
|
||||
|
||||
AVATAR_MATRIX,
|
||||
|
||||
WATER_SCREENTEX,
|
||||
WATER_SCREENDEPTH,
|
||||
WATER_REFTEX,
|
||||
@@ -204,7 +212,9 @@ public:
|
||||
TERRAIN_DETAIL2,
|
||||
TERRAIN_DETAIL3,
|
||||
TERRAIN_ALPHARAMP,
|
||||
|
||||
SHINY_ORIGIN,
|
||||
DISPLAY_GAMMA,
|
||||
END_RESERVED_UNIFORMS
|
||||
} eGLSLReservedUniforms;
|
||||
|
||||
@@ -228,11 +238,12 @@ public:
|
||||
public:
|
||||
struct CachedObjectInfo
|
||||
{
|
||||
CachedObjectInfo(GLhandleARB handle, U32 level, GLenum type) :
|
||||
mHandle(handle), mLevel(level), mType(type) {}
|
||||
CachedObjectInfo(GLhandleARB handle, U32 level, GLenum type, std::map<std::string,std::string> *definitions) :
|
||||
mHandle(handle), mLevel(level), mType(type), mDefinitions(definitions ? *definitions : std::map<std::string,std::string>()){}
|
||||
GLhandleARB mHandle; //Actual handle of the opengl shader object.
|
||||
U32 mLevel; //Level /might/ not be needed, but it's stored to ensure there's no change in behavior.
|
||||
GLenum mType; //GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB. Tracked because some utility shaders can be loaded as both types (carefully).
|
||||
std::map<std::string,std::string> mDefinitions;
|
||||
};
|
||||
// Map of shader names to compiled
|
||||
std::multimap<std::string, CachedObjectInfo > mShaderObjects; //Singu Note: Packing more info here. Doing such provides capability to skip unneeded duplicate loading..
|
||||
|
||||
@@ -2035,7 +2035,10 @@ bool LLVertexBuffer::getTexCoord1Strider(LLStrider<LLVector2>& strider, S32 inde
|
||||
{
|
||||
return VertexBufferStrider<LLVector2,TYPE_TEXCOORD1>::get(*this, strider, index, count, map_range);
|
||||
}
|
||||
|
||||
bool LLVertexBuffer::getTexCoord2Strider(LLStrider<LLVector2>& strider, S32 index, S32 count, bool map_range)
|
||||
{
|
||||
return VertexBufferStrider<LLVector2,TYPE_TEXCOORD2>::get(*this, strider, index, count, map_range);
|
||||
}
|
||||
bool LLVertexBuffer::getNormalStrider(LLStrider<LLVector3>& strider, S32 index, S32 count, bool map_range)
|
||||
{
|
||||
return VertexBufferStrider<LLVector3,TYPE_NORMAL>::get(*this, strider, index, count, map_range);
|
||||
@@ -2371,7 +2374,8 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
|
||||
if (data_mask & MAP_COLOR)
|
||||
{
|
||||
S32 loc = TYPE_COLOR;
|
||||
void* ptr = (void*)(base + mOffsets[TYPE_COLOR]);
|
||||
//bind emissive instead of color pointer if emissive is present
|
||||
void* ptr = (data_mask & MAP_EMISSIVE) ? (void*)(base + mOffsets[TYPE_EMISSIVE]) : (void*)(base + mOffsets[TYPE_COLOR]);
|
||||
glVertexAttribPointerARB(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_COLOR], ptr);
|
||||
}
|
||||
if (data_mask & MAP_EMISSIVE)
|
||||
@@ -2379,6 +2383,12 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
|
||||
S32 loc = TYPE_EMISSIVE;
|
||||
void* ptr = (void*)(base + mOffsets[TYPE_EMISSIVE]);
|
||||
glVertexAttribPointerARB(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE], ptr);
|
||||
|
||||
if (!(data_mask & MAP_COLOR))
|
||||
{ //map emissive to color channel when color is not also being bound to avoid unnecessary shader swaps
|
||||
loc = TYPE_COLOR;
|
||||
glVertexAttribPointerARB(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE], ptr);
|
||||
}
|
||||
}
|
||||
if (data_mask & MAP_WEIGHT)
|
||||
{
|
||||
|
||||
@@ -246,6 +246,7 @@ public:
|
||||
bool getIndexStrider(LLStrider<U16>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getTexCoord0Strider(LLStrider<LLVector2>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getTexCoord1Strider(LLStrider<LLVector2>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getTexCoord2Strider(LLStrider<LLVector2>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getNormalStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getTangentStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
bool getTangentStrider(LLStrider<LLVector4a>& strider, S32 index=0, S32 count = -1, bool map_range = false);
|
||||
|
||||
Reference in New Issue
Block a user