diff options
-rw-r--r-- | indra/llrender/llglslshader.cpp | 26 | ||||
-rw-r--r-- | indra/llrender/llglslshader.h | 2 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 49 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 174 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.h | 125 | ||||
-rw-r--r-- | indra/newview/llviewercontrol.cpp | 1 | ||||
-rw-r--r-- | indra/newview/llviewerdisplay.cpp | 1 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 77 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.h | 45 | ||||
-rw-r--r-- | indra/newview/llwlparamset.cpp | 4 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 538 | ||||
-rw-r--r-- | indra/newview/pipeline.h | 74 |
12 files changed, 772 insertions, 344 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index ddadf07d73..bbb62ea3c1 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -320,7 +320,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms) for (S32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedUniforms.size(); i++) { if ( (mUniform[i] == -1) - && (LLShaderMgr::instance()->mReservedUniforms[i].compare(0, length, name, LLShaderMgr::instance()->mReservedUniforms[i].length()) == 0)) + && (LLShaderMgr::instance()->mReservedUniforms[i] == name)) { //found it mUniform[i] = location; @@ -334,7 +334,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms) for (U32 i = 0; i < uniforms->size(); i++) { if ( (mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] == -1) - && ((*uniforms)[i].compare(0, length, name, (*uniforms)[i].length()) == 0)) + && ((*uniforms)[i] == name)) { //found it mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location; @@ -762,8 +762,12 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c } } +static LLFastTimer::DeclareTimer FTM_UNIFORM_LOCATION("Get Uniform Location"); + GLint LLGLSLShader::getUniformLocation(const string& uniform) { + LLFastTimer t(FTM_UNIFORM_LOCATION); + GLint ret = -1; if (mProgramObject > 0) { @@ -783,13 +787,19 @@ GLint LLGLSLShader::getUniformLocation(const string& uniform) } } - /*if (gDebugGL) + return ret; +} + +GLint LLGLSLShader::getUniformLocation(U32 index) +{ + LLFastTimer t(FTM_UNIFORM_LOCATION); + + GLint ret = -1; + if (mProgramObject > 0) { - if (ret == -1 && ret != glGetUniformLocationARB(mProgramObject, uniform.c_str())) - { - llerrs << "Uniform map invalid." << llendl; - } - }*/ + llassert(index < mUniform.size()); + return mUniform[index]; + } return ret; } diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index beef57796d..eb19599eca 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -114,6 +114,8 @@ public: void vertexAttrib4fv(U32 index, GLfloat* v); GLint getUniformLocation(const std::string& uniform); + GLint getUniformLocation(U32 index); + GLint getAttribLocation(U32 attrib); GLint mapUniformTextureChannel(GLint location, GLenum type); diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index c73701bbcc..afb19fce55 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -34,6 +34,7 @@ #include "llimagegl.h" #include "llrendertarget.h" #include "lltexture.h" +#include "llshadermgr.h" LLRender gGL; @@ -1127,13 +1128,13 @@ void LLRender::syncLightState() diffuse[i].set(light->mDiffuse.mV); } - shader->uniform4fv("light_position", 8, position[0].mV); - shader->uniform3fv("light_direction", 8, direction[0].mV); - shader->uniform3fv("light_attenuation", 8, attenuation[0].mV); - shader->uniform3fv("light_diffuse", 8, diffuse[0].mV); - shader->uniform4fv("light_ambient", 1, mAmbientLightColor.mV); + shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, 8, position[0].mV); + shader->uniform3fv(LLShaderMgr::LIGHT_DIRECTION, 8, direction[0].mV); + shader->uniform3fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV); + shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV); + shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); //HACK -- duplicate sunlight color for compatibility with drivers that can't deal with multiple shader objects referencing the same uniform - shader->uniform4fv("sunlight_color", 1, diffuse[0].mV); + shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); } } @@ -1151,14 +1152,14 @@ void LLRender::syncMatrices() GL_TEXTURE, }; - std::string name[] = + U32 name[] = { - "modelview_matrix", - "projection_matrix", - "texture_matrix0", - "texture_matrix1", - "texture_matrix2", - "texture_matrix3", + LLShaderMgr::MODELVIEW_MATRIX, + LLShaderMgr::PROJECTION_MATRIX, + LLShaderMgr::TEXTURE_MATRIX0, + LLShaderMgr::TEXTURE_MATRIX1, + LLShaderMgr::TEXTURE_MATRIX2, + LLShaderMgr::TEXTURE_MATRIX3, }; LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; @@ -1185,7 +1186,7 @@ void LLRender::syncMatrices() shader->mMatHash[i] = mMatHash[i]; //update normal matrix - S32 loc = shader->getUniformLocation("normal_matrix"); + S32 loc = shader->getUniformLocation(LLShaderMgr::NORMAL_MATRIX); if (loc > -1) { if (cached_normal_hash != mMatHash[i]) @@ -1203,12 +1204,12 @@ void LLRender::syncMatrices() norm.m[8], norm.m[9], norm.m[10] }; - shader->uniformMatrix3fv("normal_matrix", 1, GL_FALSE, norm_mat); + shader->uniformMatrix3fv(LLShaderMgr::NORMAL_MATRIX, 1, GL_FALSE, norm_mat); } //update MVP matrix mvp_done = true; - loc = shader->getUniformLocation("modelview_projection_matrix"); + loc = shader->getUniformLocation(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX); if (loc > -1) { U32 proj = MM_PROJECTION; @@ -1221,7 +1222,7 @@ void LLRender::syncMatrices() cached_mvp_proj_hash = mMatHash[MM_PROJECTION]; } - shader->uniformMatrix4fv("modelview_projection_matrix", 1, GL_FALSE, cached_mvp.m); + shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.m); } } @@ -1237,7 +1238,7 @@ void LLRender::syncMatrices() if (!mvp_done) { //update MVP matrix - S32 loc = shader->getUniformLocation("modelview_projection_matrix"); + S32 loc = shader->getUniformLocation(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX); if (loc > -1) { if (cached_mvp_mdv_hash != mMatHash[i] || cached_mvp_proj_hash != mMatHash[MM_PROJECTION]) @@ -1249,7 +1250,7 @@ void LLRender::syncMatrices() cached_mvp_proj_hash = mMatHash[MM_PROJECTION]; } - shader->uniformMatrix4fv("modelview_projection_matrix", 1, GL_FALSE, cached_mvp.m); + shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.m); } } } @@ -2176,7 +2177,7 @@ void LLRender::diffuseColor3f(F32 r, F32 g, F32 b) if (shader) { - shader->uniform4f("color", r,g,b,1.f); + shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, r,g,b,1.f); } else { @@ -2191,7 +2192,7 @@ void LLRender::diffuseColor3fv(const F32* c) if (shader) { - shader->uniform4f("color", c[0], c[1], c[2], 1.f); + shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, c[0], c[1], c[2], 1.f); } else { @@ -2206,7 +2207,7 @@ void LLRender::diffuseColor4f(F32 r, F32 g, F32 b, F32 a) if (shader) { - shader->uniform4f("color", r,g,b,a); + shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, r,g,b,a); } else { @@ -2221,7 +2222,7 @@ void LLRender::diffuseColor4fv(const F32* c) if (shader) { - shader->uniform4fv("color", 1, c); + shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, c); } else { @@ -2236,7 +2237,7 @@ void LLRender::diffuseColor4ubv(const U8* c) if (shader) { - shader->uniform4f("color", c[0]/255.f, c[1]/255.f, c[2]/255.f, c[3]/255.f); + shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, c[0]/255.f, c[1]/255.f, c[2]/255.f, c[3]/255.f); } else { diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 16180c6831..0a99c66d09 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -897,3 +897,177 @@ BOOL LLShaderMgr::validateProgramObject(GLhandleARB obj) return success; } +//virtual +void LLShaderMgr::initAttribsAndUniforms() +{ + //MUST match order of enum in LLVertexBuffer.h + mReservedAttribs.push_back("position"); + mReservedAttribs.push_back("normal"); + mReservedAttribs.push_back("texcoord0"); + mReservedAttribs.push_back("texcoord1"); + mReservedAttribs.push_back("texcoord2"); + mReservedAttribs.push_back("texcoord3"); + mReservedAttribs.push_back("diffuse_color"); + mReservedAttribs.push_back("emissive"); + mReservedAttribs.push_back("binormal"); + mReservedAttribs.push_back("weight"); + mReservedAttribs.push_back("weight4"); + mReservedAttribs.push_back("clothing"); + mReservedAttribs.push_back("texture_index"); + + //matrix state + mReservedUniforms.push_back("modelview_matrix"); + mReservedUniforms.push_back("projection_matrix"); + mReservedUniforms.push_back("inv_proj"); + mReservedUniforms.push_back("modelview_projection_matrix"); + mReservedUniforms.push_back("normal_matrix"); + mReservedUniforms.push_back("texture_matrix0"); + mReservedUniforms.push_back("texture_matrix1"); + mReservedUniforms.push_back("texture_matrix2"); + mReservedUniforms.push_back("texture_matrix3"); + llassert(mReservedUniforms.size() == LLShaderMgr::TEXTURE_MATRIX3+1); + + mReservedUniforms.push_back("viewport"); + + mReservedUniforms.push_back("light_position"); + mReservedUniforms.push_back("light_direction"); + mReservedUniforms.push_back("light_attenuation"); + mReservedUniforms.push_back("light_diffuse"); + mReservedUniforms.push_back("light_ambient"); + mReservedUniforms.push_back("light_count"); + mReservedUniforms.push_back("light"); + mReservedUniforms.push_back("light_col"); + mReservedUniforms.push_back("far_z"); + + llassert(mReservedUniforms.size() == LLShaderMgr::MULTI_LIGHT_FAR_Z+1); + + + mReservedUniforms.push_back("proj_mat"); + mReservedUniforms.push_back("proj_near"); + mReservedUniforms.push_back("proj_p"); + mReservedUniforms.push_back("proj_n"); + mReservedUniforms.push_back("proj_origin"); + mReservedUniforms.push_back("proj_range"); + mReservedUniforms.push_back("proj_ambiance"); + mReservedUniforms.push_back("proj_shadow_idx"); + mReservedUniforms.push_back("shadow_fade"); + mReservedUniforms.push_back("proj_focus"); + mReservedUniforms.push_back("proj_lod"); + mReservedUniforms.push_back("proj_ambient_lod"); + + llassert(mReservedUniforms.size() == LLShaderMgr::PROJECTOR_AMBIENT_LOD+1); + + mReservedUniforms.push_back("color"); + mReservedUniforms.push_back("highlight_color"); + + mReservedUniforms.push_back("diffuseMap"); + mReservedUniforms.push_back("specularMap"); + mReservedUniforms.push_back("bumpMap"); + mReservedUniforms.push_back("environmentMap"); + mReservedUniforms.push_back("cloude_noise_texture"); + mReservedUniforms.push_back("fullbright"); + mReservedUniforms.push_back("lightnorm"); + mReservedUniforms.push_back("sunlight_color"); + mReservedUniforms.push_back("ambient"); + mReservedUniforms.push_back("blue_horizon"); + mReservedUniforms.push_back("blue_density"); + mReservedUniforms.push_back("haze_horizon"); + mReservedUniforms.push_back("haze_density"); + mReservedUniforms.push_back("cloud_shadow"); + mReservedUniforms.push_back("density_multiplier"); + mReservedUniforms.push_back("distance_multiplier"); + mReservedUniforms.push_back("max_y"); + mReservedUniforms.push_back("glow"); + mReservedUniforms.push_back("cloud_color"); + mReservedUniforms.push_back("cloud_pos_density1"); + mReservedUniforms.push_back("cloud_pos_density2"); + mReservedUniforms.push_back("cloud_scale"); + mReservedUniforms.push_back("gamma"); + mReservedUniforms.push_back("scene_light_strength"); + + llassert(mReservedUniforms.size() == LLShaderMgr::SCENE_LIGHT_STRENGTH+1); + + mReservedUniforms.push_back("center"); + mReservedUniforms.push_back("size"); + mReservedUniforms.push_back("falloff"); + + + mReservedUniforms.push_back("minLuminance"); + mReservedUniforms.push_back("maxExtractAlpha"); + mReservedUniforms.push_back("lumWeights"); + mReservedUniforms.push_back("warmthWeights"); + mReservedUniforms.push_back("warmthAmount"); + mReservedUniforms.push_back("glowStrength"); + mReservedUniforms.push_back("glowDelta"); + + llassert(mReservedUniforms.size() == LLShaderMgr::GLOW_DELTA+1); + + mReservedUniforms.push_back("shadow_matrix"); + mReservedUniforms.push_back("env_mat"); + mReservedUniforms.push_back("shadow_clip"); + mReservedUniforms.push_back("sun_wash"); + mReservedUniforms.push_back("shadow_noise"); + mReservedUniforms.push_back("blur_size"); + mReservedUniforms.push_back("ssao_radius"); + mReservedUniforms.push_back("ssao_max_radius"); + mReservedUniforms.push_back("ssao_factor"); + mReservedUniforms.push_back("ssao_factor_inv"); + mReservedUniforms.push_back("ssao_effect_mat"); + mReservedUniforms.push_back("screen_res"); + mReservedUniforms.push_back("near_clip"); + mReservedUniforms.push_back("shadow_offset"); + mReservedUniforms.push_back("shadow_bias"); + mReservedUniforms.push_back("spot_shadow_bias"); + mReservedUniforms.push_back("spot_shadow_offset"); + mReservedUniforms.push_back("sun_dir"); + mReservedUniforms.push_back("shadow_res"); + mReservedUniforms.push_back("proj_shadow_res"); + mReservedUniforms.push_back("depth_cutoff"); + mReservedUniforms.push_back("norm_cutoff"); + + llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_NORM_CUTOFF+1); + + mReservedUniforms.push_back("tc_scale"); + mReservedUniforms.push_back("rcp_screen_res"); + mReservedUniforms.push_back("rcp_frame_opt"); + mReservedUniforms.push_back("rcp_frame_opt2"); + + mReservedUniforms.push_back("focal_distance"); + mReservedUniforms.push_back("blur_constant"); + mReservedUniforms.push_back("tan_pixel_angle"); + mReservedUniforms.push_back("magnification"); + + mReservedUniforms.push_back("depthMap"); + mReservedUniforms.push_back("shadowMap0"); + mReservedUniforms.push_back("shadowMap1"); + mReservedUniforms.push_back("shadowMap2"); + mReservedUniforms.push_back("shadowMap3"); + mReservedUniforms.push_back("shadowMap4"); + mReservedUniforms.push_back("shadowMap5"); + + llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_SHADOW5+1); + + mReservedUniforms.push_back("normalMap"); + mReservedUniforms.push_back("positionMap"); + mReservedUniforms.push_back("diffuseRect"); + mReservedUniforms.push_back("specularRect"); + mReservedUniforms.push_back("noiseMap"); + mReservedUniforms.push_back("lightFunc"); + mReservedUniforms.push_back("lightMap"); + mReservedUniforms.push_back("bloomMap"); + mReservedUniforms.push_back("projectionMap"); + + llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); + + std::set<std::string> dupe_check; + + for (U32 i = 0; i < mReservedUniforms.size(); ++i) + { + if (dupe_check.find(mReservedUniforms[i]) != dupe_check.end()) + { + llerrs << "Duplicate reserved uniform name found: " << mReservedUniforms[i] << llendl; + } + dupe_check.insert(mReservedUniforms[i]); + } +} + diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 2f30103811..9cc2f1bd7f 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -36,9 +36,134 @@ public: LLShaderMgr(); virtual ~LLShaderMgr(); + typedef enum + { + MODELVIEW_MATRIX = 0, + PROJECTION_MATRIX, + INVERSE_PROJECTION_MATRIX, + MODELVIEW_PROJECTION_MATRIX, + NORMAL_MATRIX, + TEXTURE_MATRIX0, + TEXTURE_MATRIX1, + TEXTURE_MATRIX2, + TEXTURE_MATRIX3, + VIEWPORT, + LIGHT_POSITION, + LIGHT_DIRECTION, + LIGHT_ATTENUATION, + LIGHT_DIFFUSE, + LIGHT_AMBIENT, + MULTI_LIGHT_COUNT, + MULTI_LIGHT, + MULTI_LIGHT_COL, + MULTI_LIGHT_FAR_Z, + PROJECTOR_MATRIX, + PROJECTOR_NEAR, + PROJECTOR_P, + PROJECTOR_N, + PROJECTOR_ORIGIN, + PROJECTOR_RANGE, + PROJECTOR_AMBIANCE, + PROJECTOR_SHADOW_INDEX, + PROJECTOR_SHADOW_FADE, + PROJECTOR_FOCUS, + PROJECTOR_LOD, + PROJECTOR_AMBIENT_LOD, + DIFFUSE_COLOR, + HIGHLIGHT_COLOR, + DIFFUSE_MAP, + SPECULAR_MAP, + BUMP_MAP, + ENVIRONMENT_MAP, + CLOUD_NOISE_MAP, + FULLBRIGHT, + LIGHTNORM, + SUNLIGHT_COLOR, + AMBIENT, + BLUE_HORIZON, + BLUE_DENSITY, + HAZE_HORIZON, + HAZE_DENSITY, + CLOUD_SHADOW, + DENSITY_MULTIPLIER, + DISTANCE_MULTIPLIER, + MAX_Y, + GLOW, + CLOUD_COLOR, + CLOUD_POS_DENSITY1, + CLOUD_POS_DENSITY2, + CLOUD_SCALE, + GAMMA, + SCENE_LIGHT_STRENGTH, + LIGHT_CENTER, + LIGHT_SIZE, + LIGHT_FALLOFF, + + GLOW_MIN_LUMINANCE, + GLOW_MAX_EXTRACT_ALPHA, + GLOW_LUM_WEIGHTS, + GLOW_WARMTH_WEIGHTS, + GLOW_WARMTH_AMOUNT, + GLOW_STRENGTH, + GLOW_DELTA, + + DEFERRED_SHADOW_MATRIX, + DEFERRED_ENV_MAT, + DEFERRED_SHADOW_CLIP, + DEFERRED_SUN_WASH, + DEFERRED_SHADOW_NOISE, + DEFERRED_BLUR_SIZE, + DEFERRED_SSAO_RADIUS, + DEFERRED_SSAO_MAX_RADIUS, + DEFERRED_SSAO_FACTOR, + DEFERRED_SSAO_FACTOR_INV, + DEFERRED_SSAO_EFFECT_MAT, + DEFERRED_SCREEN_RES, + DEFERRED_NEAR_CLIP, + DEFERRED_SHADOW_OFFSET, + DEFERRED_SHADOW_BIAS, + DEFERRED_SPOT_SHADOW_BIAS, + DEFERRED_SPOT_SHADOW_OFFSET, + DEFERRED_SUN_DIR, + DEFERRED_SHADOW_RES, + DEFERRED_PROJ_SHADOW_RES, + DEFERRED_DEPTH_CUTOFF, + DEFERRED_NORM_CUTOFF, + + FXAA_TC_SCALE, + FXAA_RCP_SCREEN_RES, + FXAA_RCP_FRAME_OPT, + FXAA_RCP_FRAME_OPT2, + + DOF_FOCAL_DISTANCE, + DOF_BLUR_CONSTANT, + DOF_TAN_PIXEL_ANGLE, + DOF_MAGNIFICATION, + + DEFERRED_DEPTH, + DEFERRED_SHADOW0, + DEFERRED_SHADOW1, + DEFERRED_SHADOW2, + DEFERRED_SHADOW3, + DEFERRED_SHADOW4, + DEFERRED_SHADOW5, + DEFERRED_NORMAL, + DEFERRED_POSITION, + DEFERRED_DIFFUSE, + DEFERRED_SPECULAR, + DEFERRED_NOISE, + DEFERRED_LIGHTFUNC, + DEFERRED_LIGHT, + DEFERRED_BLOOM, + DEFERRED_PROJECTION, + END_RESERVED_UNIFORMS + } eGLSLReservedUniforms; + // singleton pattern implementation static LLShaderMgr * instance(); + virtual void initAttribsAndUniforms(void); + BOOL attachShaderFeatures(LLGLSLShader * shader); void dumpObjectLog(GLhandleARB ret, BOOL warns = TRUE); BOOL linkProgramObject(GLhandleARB obj, BOOL suppress_errors = FALSE); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 5b178f82d8..3692da64fc 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -388,6 +388,7 @@ static bool handleRenderDeferredChanged(const LLSD& newvalue) LLRenderTarget::sUseFBO = newvalue.asBoolean(); if (gPipeline.isInit()) { + LLPipeline::refreshCachedSettings(); gPipeline.updateRenderDeferred(); gPipeline.releaseGLBuffers(); gPipeline.createGLBuffers(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 7220f2a20f..1832416a4b 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -862,6 +862,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // gGL.popMatrix(); //} + LLPipeline::refreshCachedSettings(); LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; LLPipeline::refreshRenderDeferred(); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ac489e0caf..8bc573135c 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -195,6 +195,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mMaxAvatarShaderLevel(0) { /// Make sure WL Sky is the first program + //ONLY shaders that need WL Param management should be added here mShaderList.push_back(&gWLSkyProgram); mShaderList.push_back(&gWLCloudProgram); mShaderList.push_back(&gAvatarProgram); @@ -209,16 +210,6 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gObjectFullbrightNoColorWaterProgram); mShaderList.push_back(&gObjectSimpleAlphaMaskProgram); mShaderList.push_back(&gObjectBumpProgram); - mShaderList.push_back(&gUIProgram); - mShaderList.push_back(&gCustomAlphaProgram); - mShaderList.push_back(&gGlowCombineProgram); - mShaderList.push_back(&gGlowCombineFXAAProgram); - mShaderList.push_back(&gTwoTextureAddProgram); - mShaderList.push_back(&gOneTextureNoColorProgram); - mShaderList.push_back(&gSolidColorProgram); - mShaderList.push_back(&gOcclusionProgram); - mShaderList.push_back(&gDebugProgram); - mShaderList.push_back(&gAlphaMaskProgram); mShaderList.push_back(&gObjectEmissiveProgram); mShaderList.push_back(&gObjectEmissiveWaterProgram); mShaderList.push_back(&gObjectFullbrightProgram); @@ -260,23 +251,16 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gObjectShinyNonIndexedWaterProgram); mShaderList.push_back(&gUnderWaterProgram); mShaderList.push_back(&gDeferredSunProgram); - mShaderList.push_back(&gDeferredBlurLightProgram); mShaderList.push_back(&gDeferredSoftenProgram); - mShaderList.push_back(&gDeferredLightProgram); - mShaderList.push_back(&gDeferredMultiLightProgram); mShaderList.push_back(&gDeferredAlphaProgram); mShaderList.push_back(&gDeferredSkinnedAlphaProgram); mShaderList.push_back(&gDeferredFullbrightProgram); mShaderList.push_back(&gDeferredEmissiveProgram); mShaderList.push_back(&gDeferredAvatarEyesProgram); - mShaderList.push_back(&gDeferredPostProgram); - mShaderList.push_back(&gFXAAProgram); mShaderList.push_back(&gDeferredWaterProgram); mShaderList.push_back(&gDeferredAvatarAlphaProgram); mShaderList.push_back(&gDeferredWLSkyProgram); mShaderList.push_back(&gDeferredWLCloudProgram); - mShaderList.push_back(&gDeferredStarProgram); - mShaderList.push_back(&gNormalMapGenProgram); } LLViewerShaderMgr::~LLViewerShaderMgr() @@ -300,70 +284,13 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void) { if (mReservedAttribs.empty()) { - //MUST match order of enum in LLVertexBuffer.h - mReservedAttribs.push_back("position"); - mReservedAttribs.push_back("normal"); - mReservedAttribs.push_back("texcoord0"); - mReservedAttribs.push_back("texcoord1"); - mReservedAttribs.push_back("texcoord2"); - mReservedAttribs.push_back("texcoord3"); - mReservedAttribs.push_back("diffuse_color"); - mReservedAttribs.push_back("emissive"); - mReservedAttribs.push_back("binormal"); - mReservedAttribs.push_back("weight"); - mReservedAttribs.push_back("weight4"); - mReservedAttribs.push_back("clothing"); - mReservedAttribs.push_back("texture_index"); + LLShaderMgr::initAttribsAndUniforms(); mAvatarUniforms.push_back("matrixPalette"); mAvatarUniforms.push_back("gWindDir"); mAvatarUniforms.push_back("gSinWaveParams"); mAvatarUniforms.push_back("gGravity"); - mReservedUniforms.reserve(24); - mReservedUniforms.push_back("diffuseMap"); - mReservedUniforms.push_back("specularMap"); - mReservedUniforms.push_back("bumpMap"); - mReservedUniforms.push_back("environmentMap"); - mReservedUniforms.push_back("cloude_noise_texture"); - mReservedUniforms.push_back("fullbright"); - mReservedUniforms.push_back("lightnorm"); - mReservedUniforms.push_back("sunlight_color"); - mReservedUniforms.push_back("ambient"); - mReservedUniforms.push_back("blue_horizon"); - mReservedUniforms.push_back("blue_density"); - mReservedUniforms.push_back("haze_horizon"); - mReservedUniforms.push_back("haze_density"); - mReservedUniforms.push_back("cloud_shadow"); - mReservedUniforms.push_back("density_multiplier"); - mReservedUniforms.push_back("distance_multiplier"); - mReservedUniforms.push_back("max_y"); - mReservedUniforms.push_back("glow"); - mReservedUniforms.push_back("cloud_color"); - mReservedUniforms.push_back("cloud_pos_density1"); - mReservedUniforms.push_back("cloud_pos_density2"); - mReservedUniforms.push_back("cloud_scale"); - mReservedUniforms.push_back("gamma"); - mReservedUniforms.push_back("scene_light_strength"); - - mReservedUniforms.push_back("depthMap"); - mReservedUniforms.push_back("shadowMap0"); - mReservedUniforms.push_back("shadowMap1"); - mReservedUniforms.push_back("shadowMap2"); - mReservedUniforms.push_back("shadowMap3"); - mReservedUniforms.push_back("shadowMap4"); - mReservedUniforms.push_back("shadowMap5"); - - mReservedUniforms.push_back("normalMap"); - mReservedUniforms.push_back("positionMap"); - mReservedUniforms.push_back("diffuseRect"); - mReservedUniforms.push_back("specularRect"); - mReservedUniforms.push_back("noiseMap"); - mReservedUniforms.push_back("lightFunc"); - mReservedUniforms.push_back("lightMap"); - mReservedUniforms.push_back("bloomMap"); - mReservedUniforms.push_back("projectionMap"); - mWLUniforms.push_back("camPosLocal"); mTerrainUniforms.reserve(5); diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 5bcdf11be5..01f8c3987c 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -73,51 +73,6 @@ public: typedef enum { - DIFFUSE_MAP = 0, - SPECULAR_MAP, - BUMP_MAP, - ENVIRONMENT_MAP, - CLOUD_NOISE_MAP, - FULLBRIGHT, - LIGHTNORM, - SUNLIGHT_COLOR, - AMBIENT, - BLUE_HORIZON, - BLUE_DENSITY, - HAZE_HORIZON, - HAZE_DENSITY, - CLOUD_SHADOW, - DENSITY_MULTIPLIER, - DISTANCE_MULTIPLIER, - MAX_Y, - GLOW, - CLOUD_COLOR, - CLOUD_POS_DENSITY1, - CLOUD_POS_DENSITY2, - CLOUD_SCALE, - GAMMA, - SCENE_LIGHT_STRENGTH, - DEFERRED_DEPTH, - DEFERRED_SHADOW0, - DEFERRED_SHADOW1, - DEFERRED_SHADOW2, - DEFERRED_SHADOW3, - DEFERRED_SHADOW4, - DEFERRED_SHADOW5, - DEFERRED_NORMAL, - DEFERRED_POSITION, - DEFERRED_DIFFUSE, - DEFERRED_SPECULAR, - DEFERRED_NOISE, - DEFERRED_LIGHTFUNC, - DEFERRED_LIGHT, - DEFERRED_BLOOM, - DEFERRED_PROJECTION, - END_RESERVED_UNIFORMS - } eGLSLReservedUniforms; - - typedef enum - { SHINY_ORIGIN = END_RESERVED_UNIFORMS } eShinyUniforms; diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp index 22fba90f65..4a1db3d26c 100644 --- a/indra/newview/llwlparamset.cpp +++ b/indra/newview/llwlparamset.cpp @@ -69,12 +69,16 @@ LLWLParamSet::LLWLParamSet(void) : */ } +static LLFastTimer::DeclareTimer FTM_WL_PARAM_UPDATE("WL Param Update"); + void LLWLParamSet::update(LLGLSLShader * shader) const { for(LLSD::map_const_iterator i = mParamValues.beginMap(); i != mParamValues.endMap(); ++i) { + LLFastTimer t(FTM_WL_PARAM_UPDATE); + const std::string& param = i->first; if( param == "star_brightness" || param == "preset_num" || param == "sun_angle" || diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 42873dbca8..e4125c8dc8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -113,6 +113,79 @@ //#define DEBUG_INDICES #endif +//cached settings +BOOL LLPipeline::RenderAvatarVP; +BOOL LLPipeline::VertexShaderEnable; +BOOL LLPipeline::WindLightUseAtmosShaders; +BOOL LLPipeline::RenderDeferred; +F32 LLPipeline::RenderDeferredSunWash; +U32 LLPipeline::RenderFSAASamples; +U32 LLPipeline::RenderResolutionDivisor; +BOOL LLPipeline::RenderUIBuffer; +S32 LLPipeline::RenderShadowDetail; +BOOL LLPipeline::RenderDeferredSSAO; +F32 LLPipeline::RenderShadowResolutionScale; +BOOL LLPipeline::RenderLocalLights; +BOOL LLPipeline::RenderDelayCreation; +BOOL LLPipeline::RenderAnimateRes; +BOOL LLPipeline::FreezeTime; +S32 LLPipeline::DebugBeaconLineWidth; +F32 LLPipeline::RenderHighlightBrightness; +LLColor4 LLPipeline::RenderHighlightColor; +F32 LLPipeline::RenderHighlightThickness; +BOOL LLPipeline::RenderSpotLightsInNondeferred; +LLColor4 LLPipeline::PreviewAmbientColor; +LLColor4 LLPipeline::PreviewDiffuse0; +LLColor4 LLPipeline::PreviewSpecular0; +LLColor4 LLPipeline::PreviewDiffuse1; +LLColor4 LLPipeline::PreviewSpecular1; +LLColor4 LLPipeline::PreviewDiffuse2; +LLColor4 LLPipeline::PreviewSpecular2; +LLVector3 LLPipeline::PreviewDirection0; +LLVector3 LLPipeline::PreviewDirection1; +LLVector3 LLPipeline::PreviewDirection2; +F32 LLPipeline::RenderGlowMinLuminance; +F32 LLPipeline::RenderGlowMaxExtractAlpha; +F32 LLPipeline::RenderGlowWarmthAmount; +LLVector3 LLPipeline::RenderGlowLumWeights; +LLVector3 LLPipeline::RenderGlowWarmthWeights; +S32 LLPipeline::RenderGlowResolutionPow; +S32 LLPipeline::RenderGlowIterations; +F32 LLPipeline::RenderGlowWidth; +F32 LLPipeline::RenderGlowStrength; +BOOL LLPipeline::RenderDepthOfField; +F32 LLPipeline::CameraFocusTransitionTime; +F32 LLPipeline::CameraFNumber; +F32 LLPipeline::CameraFocalLength; +F32 LLPipeline::CameraFieldOfView; +F32 LLPipeline::RenderShadowNoise; +F32 LLPipeline::RenderShadowBlurSize; +F32 LLPipeline::RenderSSAOScale; +U32 LLPipeline::RenderSSAOMaxScale; +F32 LLPipeline::RenderSSAOFactor; +LLVector3 LLPipeline::RenderSSAOEffect; +F32 LLPipeline::RenderShadowOffsetError; +F32 LLPipeline::RenderShadowBiasError; +F32 LLPipeline::RenderShadowOffset; +F32 LLPipeline::RenderShadowBias; +F32 LLPipeline::RenderSpotShadowOffset; +F32 LLPipeline::RenderSpotShadowBias; +F32 LLPipeline::RenderEdgeDepthCutoff; +F32 LLPipeline::RenderEdgeNormCutoff; +LLVector3 LLPipeline::RenderShadowGaussian; +F32 LLPipeline::RenderShadowBlurDistFactor; +BOOL LLPipeline::RenderDeferredAtmospheric; +S32 LLPipeline::RenderReflectionDetail; +F32 LLPipeline::RenderHighlightFadeTime; +LLVector3 LLPipeline::RenderShadowClipPlanes; +LLVector3 LLPipeline::RenderShadowOrthoClipPlanes; +LLVector3 LLPipeline::RenderShadowNearDist; +F32 LLPipeline::RenderFarClip; +LLVector3 LLPipeline::RenderShadowSplitExponent; +F32 LLPipeline::RenderShadowErrorCutoff; +F32 LLPipeline::RenderShadowFOVCutoff; +BOOL LLPipeline::CameraOffset; + const F32 BACKLIGHT_DAY_MAGNITUDE_AVATAR = 0.2f; const F32 BACKLIGHT_NIGHT_MAGNITUDE_AVATAR = 0.1f; const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f; @@ -371,6 +444,8 @@ void LLPipeline::init() { LLMemType mt(LLMemType::MTYPE_PIPELINE_INIT); + refreshCachedSettings(); + gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); @@ -588,7 +663,7 @@ void LLPipeline::allocatePhysicsBuffer() void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { - U32 samples = gGLManager.getNumFBOFSAASamples(gSavedSettings.getU32("RenderFSAASamples")); + U32 samples = gGLManager.getNumFBOFSAASamples(RenderFSAASamples); //try to allocate screen buffers at requested resolution and samples // - on failure, shrink number of samples and try again @@ -638,7 +713,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mScreenWidth = resX; mScreenHeight = resY; - U32 res_mod = gSavedSettings.getU32("RenderResolutionDivisor"); + U32 res_mod = RenderResolutionDivisor; if (res_mod > 1 && res_mod < resX && res_mod < resY) { @@ -646,7 +721,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) resY /= res_mod; } - if (gSavedSettings.getBOOL("RenderUIBuffer")) + if (RenderUIBuffer) { if (!mUIScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) { @@ -656,8 +731,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (LLPipeline::sRenderDeferred) { - S32 shadow_detail = gSavedSettings.getS32("RenderShadowDetail"); - BOOL ssao = gSavedSettings.getBOOL("RenderDeferredSSAO"); + S32 shadow_detail = RenderShadowDetail; + BOOL ssao = RenderDeferredSSAO; //allocate deferred rendering color buffers if (!mDeferredScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; @@ -683,7 +758,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mDeferredLight.release(); } - F32 scale = gSavedSettings.getF32("RenderShadowResolutionScale"); + F32 scale = RenderShadowResolutionScale; if (shadow_detail > 0) { //allocate 4 sun shadow maps @@ -749,12 +824,12 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) //static void LLPipeline::updateRenderDeferred() { - BOOL deferred = ((gSavedSettings.getBOOL("RenderDeferred") && + BOOL deferred = ((RenderDeferred && LLRenderTarget::sUseFBO && - LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && - gSavedSettings.getBOOL("VertexShaderEnable") && - gSavedSettings.getBOOL("RenderAvatarVP") && - gSavedSettings.getBOOL("WindLightUseAtmosShaders")) ? TRUE : FALSE) && + LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") && + VertexShaderEnable && + RenderAvatarVP && + WindLightUseAtmosShaders) ? TRUE : FALSE) && !gUseWireframe; sRenderDeferred = deferred; @@ -770,6 +845,82 @@ void LLPipeline::refreshRenderDeferred() updateRenderDeferred(); } +//static +void LLPipeline::refreshCachedSettings() +{ + VertexShaderEnable = gSavedSettings.getBOOL("VertexShaderEnable"); + RenderAvatarVP = gSavedSettings.getBOOL("RenderAvatarVP"); + WindLightUseAtmosShaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders"); + RenderDeferred = gSavedSettings.getBOOL("RenderDeferred"); + RenderDeferredSunWash = gSavedSettings.getF32("RenderDeferredSunWash"); + RenderFSAASamples = gSavedSettings.getU32("RenderFSAASamples"); + RenderResolutionDivisor = gSavedSettings.getU32("RenderResolutionDivisor"); + RenderUIBuffer = gSavedSettings.getBOOL("RenderUIBuffer"); + RenderShadowDetail = gSavedSettings.getS32("RenderShadowDetail"); + RenderDeferredSSAO = gSavedSettings.getBOOL("RenderDeferredSSAO"); + RenderShadowResolutionScale = gSavedSettings.getF32("RenderShadowResolutionScale"); + RenderLocalLights = gSavedSettings.getBOOL("RenderLocalLights"); + RenderDelayCreation = gSavedSettings.getBOOL("RenderDelayCreation"); + RenderAnimateRes = gSavedSettings.getBOOL("RenderAnimateRes"); + FreezeTime = gSavedSettings.getBOOL("FreezeTime"); + DebugBeaconLineWidth = gSavedSettings.getS32("DebugBeaconLineWidth"); + RenderHighlightBrightness = gSavedSettings.getF32("RenderHighlightBrightness"); + RenderHighlightColor = gSavedSettings.getColor4("RenderHighlightColor"); + RenderHighlightThickness = gSavedSettings.getF32("RenderHighlightThickness"); + RenderSpotLightsInNondeferred = gSavedSettings.getBOOL("RenderSpotLightsInNondeferred"); + PreviewAmbientColor = gSavedSettings.getColor4("PreviewAmbientColor"); + PreviewDiffuse0 = gSavedSettings.getColor4("PreviewDiffuse0"); + PreviewSpecular0 = gSavedSettings.getColor4("PreviewSpecular0"); + PreviewDiffuse1 = gSavedSettings.getColor4("PreviewDiffuse1"); + PreviewSpecular1 = gSavedSettings.getColor4("PreviewSpecular1"); + PreviewDiffuse2 = gSavedSettings.getColor4("PreviewDiffuse2"); + PreviewSpecular2 = gSavedSettings.getColor4("PreviewSpecular2"); + PreviewDirection0 = gSavedSettings.getVector3("PreviewDirection0"); + PreviewDirection1 = gSavedSettings.getVector3("PreviewDirection1"); + PreviewDirection2 = gSavedSettings.getVector3("PreviewDirection2"); + RenderGlowMinLuminance = gSavedSettings.getF32("RenderGlowMinLuminance"); + RenderGlowMaxExtractAlpha = gSavedSettings.getF32("RenderGlowMaxExtractAlpha"); + RenderGlowWarmthAmount = gSavedSettings.getF32("RenderGlowWarmthAmount"); + RenderGlowLumWeights = gSavedSettings.getVector3("RenderGlowLumWeights"); + RenderGlowWarmthWeights = gSavedSettings.getVector3("RenderGlowWarmthWeights"); + RenderGlowResolutionPow = gSavedSettings.getS32("RenderGlowResolutionPow"); + RenderGlowIterations = gSavedSettings.getS32("RenderGlowIterations"); + RenderGlowWidth = gSavedSettings.getF32("RenderGlowWidth"); + RenderGlowStrength = gSavedSettings.getF32("RenderGlowStrength"); + RenderDepthOfField = gSavedSettings.getBOOL("RenderDepthOfField"); + CameraFocusTransitionTime = gSavedSettings.getF32("CameraFocusTransitionTime"); + CameraFNumber = gSavedSettings.getF32("CameraFNumber"); + CameraFocalLength = gSavedSettings.getF32("CameraFocalLength"); + CameraFieldOfView = gSavedSettings.getF32("CameraFieldOfView"); + RenderShadowNoise = gSavedSettings.getF32("RenderShadowNoise"); + RenderShadowBlurSize = gSavedSettings.getF32("RenderShadowBlurSize"); + RenderSSAOScale = gSavedSettings.getF32("RenderSSAOScale"); + RenderSSAOMaxScale = gSavedSettings.getU32("RenderSSAOMaxScale"); + RenderSSAOFactor = gSavedSettings.getF32("RenderSSAOFactor"); + RenderSSAOEffect = gSavedSettings.getVector3("RenderSSAOEffect"); + RenderShadowOffsetError = gSavedSettings.getF32("RenderShadowOffsetError"); + RenderShadowBiasError = gSavedSettings.getF32("RenderShadowBiasError"); + RenderShadowOffset = gSavedSettings.getF32("RenderShadowOffset"); + RenderShadowBias = gSavedSettings.getF32("RenderShadowBias"); + RenderSpotShadowOffset = gSavedSettings.getF32("RenderSpotShadowOffset"); + RenderSpotShadowBias = gSavedSettings.getF32("RenderSpotShadowBias"); + RenderEdgeDepthCutoff = gSavedSettings.getF32("RenderEdgeDepthCutoff"); + RenderEdgeNormCutoff = gSavedSettings.getF32("RenderEdgeNormCutoff"); + RenderShadowGaussian = gSavedSettings.getVector3("RenderShadowGaussian"); + RenderShadowBlurDistFactor = gSavedSettings.getF32("RenderShadowBlurDistFactor"); + RenderDeferredAtmospheric = gSavedSettings.getBOOL("RenderDeferredAtmospheric"); + RenderReflectionDetail = gSavedSettings.getS32("RenderReflectionDetail"); + RenderHighlightFadeTime = gSavedSettings.getF32("RenderHighlightFadeTime"); + RenderShadowClipPlanes = gSavedSettings.getVector3("RenderShadowClipPlanes"); + RenderShadowOrthoClipPlanes = gSavedSettings.getVector3("RenderShadowOrthoClipPlanes"); + RenderShadowNearDist = gSavedSettings.getVector3("RenderShadowNearDist"); + RenderFarClip = gSavedSettings.getF32("RenderFarClip"); + RenderShadowSplitExponent = gSavedSettings.getVector3("RenderShadowSplitExponent"); + RenderShadowErrorCutoff = gSavedSettings.getF32("RenderShadowErrorCutoff"); + RenderShadowFOVCutoff = gSavedSettings.getF32("RenderShadowFOVCutoff"); + CameraOffset = gSavedSettings.getBOOL("CameraOffset"); +} + void LLPipeline::releaseGLBuffers() { assertInitialized(); @@ -1041,7 +1192,7 @@ S32 LLPipeline::setLightingDetail(S32 level) if (level < 0) { - if (gSavedSettings.getBOOL("RenderLocalLights")) + if (RenderLocalLights) { level = 1; } @@ -1362,7 +1513,7 @@ U32 LLPipeline::addObject(LLViewerObject *vobj) { LLMemType mt_ao(LLMemType::MTYPE_PIPELINE_ADD_OBJECT); - if (gSavedSettings.getBOOL("RenderDelayCreation")) + if (RenderDelayCreation) { mCreateQ.push_back(vobj); } @@ -1425,7 +1576,7 @@ void LLPipeline::createObject(LLViewerObject* vobj) markRebuild(drawablep, LLDrawable::REBUILD_ALL, TRUE); - if (drawablep->getVOVolume() && gSavedSettings.getBOOL("RenderAnimateRes")) + if (drawablep->getVOVolume() && RenderAnimateRes) { // fun animated res drawablep->updateXform(TRUE); @@ -1464,7 +1615,7 @@ void LLPipeline::resetFrameStats() //external functions for asynchronous updating void LLPipeline::updateMoveDampedAsync(LLDrawable* drawablep) { - if (gSavedSettings.getBOOL("FreezeTime")) + if (FreezeTime) { return; } @@ -1494,7 +1645,7 @@ void LLPipeline::updateMoveDampedAsync(LLDrawable* drawablep) void LLPipeline::updateMoveNormalAsync(LLDrawable* drawablep) { - if (gSavedSettings.getBOOL("FreezeTime")) + if (FreezeTime) { return; } @@ -1551,7 +1702,7 @@ void LLPipeline::updateMove() LLFastTimer t(FTM_UPDATE_MOVE); LLMemType mt_um(LLMemType::MTYPE_PIPELINE_UPDATE_MOVE); - if (gSavedSettings.getBOOL("FreezeTime")) + if (FreezeTime) { return; } @@ -2911,7 +3062,7 @@ void renderScriptedBeacons(LLDrawable* drawablep) { if (gPipeline.sRenderBeacons) { - gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 0.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), gSavedSettings.getS32("DebugBeaconLineWidth")); + gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 0.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), LLPipeline::DebugBeaconLineWidth); } if (gPipeline.sRenderHighlight) @@ -2937,7 +3088,7 @@ void renderScriptedTouchBeacons(LLDrawable* drawablep) { if (gPipeline.sRenderBeacons) { - gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 0.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), gSavedSettings.getS32("DebugBeaconLineWidth")); + gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 0.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), LLPipeline::DebugBeaconLineWidth); } if (gPipeline.sRenderHighlight) @@ -2962,7 +3113,7 @@ void renderPhysicalBeacons(LLDrawable* drawablep) { if (gPipeline.sRenderBeacons) { - gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(0.f, 1.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), gSavedSettings.getS32("DebugBeaconLineWidth")); + gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(0.f, 1.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), LLPipeline::DebugBeaconLineWidth); } if (gPipeline.sRenderHighlight) @@ -2998,7 +3149,7 @@ void renderMOAPBeacons(LLDrawable* drawablep) { if (gPipeline.sRenderBeacons) { - gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 1.f, 1.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), gSavedSettings.getS32("DebugBeaconLineWidth")); + gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", LLColor4(1.f, 1.f, 1.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), LLPipeline::DebugBeaconLineWidth); } if (gPipeline.sRenderHighlight) @@ -3023,7 +3174,7 @@ void renderParticleBeacons(LLDrawable* drawablep) if (gPipeline.sRenderBeacons) { LLColor4 light_blue(0.5f, 0.5f, 1.f, 0.5f); - gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", light_blue, LLColor4(1.f, 1.f, 1.f, 0.5f), gSavedSettings.getS32("DebugBeaconLineWidth")); + gObjectList.addDebugBeacon(vobj->getPositionAgent(), "", light_blue, LLColor4(1.f, 1.f, 1.f, 0.5f), LLPipeline::DebugBeaconLineWidth); } if (gPipeline.sRenderHighlight) @@ -3216,7 +3367,7 @@ void LLPipeline::postSort(LLCamera& camera) if (gPipeline.sRenderBeacons) { //pos += LLVector3(0.f, 0.f, 0.2f); - gObjectList.addDebugBeacon(pos, "", LLColor4(1.f, 1.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), gSavedSettings.getS32("DebugBeaconLineWidth")); + gObjectList.addDebugBeacon(pos, "", LLColor4(1.f, 1.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), DebugBeaconLineWidth); } } // now deal with highlights for all those seeable sound sources @@ -3281,7 +3432,7 @@ void render_hud_elements() if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { - LLGLEnable multisample(gSavedSettings.getU32("RenderFSAASamples") > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(LLPipeline::RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d() // Draw the tracking overlays @@ -3368,9 +3519,9 @@ void LLPipeline::renderHighlights() gGL.begin(LLRender::TRIANGLES); - F32 scale = gSavedSettings.getF32("RenderHighlightBrightness"); - LLColor4 color = gSavedSettings.getColor4("RenderHighlightColor"); - F32 thickness = gSavedSettings.getF32("RenderHighlightThickness"); + F32 scale = RenderHighlightBrightness; + LLColor4 color = RenderHighlightColor; + F32 thickness = RenderHighlightThickness; for (S32 pass = 0; pass < 2; ++pass) { @@ -3425,7 +3576,7 @@ void LLPipeline::renderHighlights() if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { gHighlightProgram.bind(); - gHighlightProgram.uniform4f("highlight_color",1,1,1,0.5f); + gHighlightProgram.uniform4f(LLShaderMgr::HIGHLIGHT_COLOR,1,1,1,0.5f); } if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) @@ -3457,7 +3608,7 @@ void LLPipeline::renderHighlights() color.setVec(1.f, 0.f, 0.f, 0.5f); if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { - gHighlightProgram.uniform4f("highlight_color",1,0,0,0.5f); + gHighlightProgram.uniform4f(LLShaderMgr::HIGHLIGHT_COLOR,1,0,0,0.5f); } int count = mHighlightFaces.size(); for (S32 i = 0; i < count; i++) @@ -3530,7 +3681,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) gGL.matrixMode(LLRender::MM_MODELVIEW); LLGLSPipeline gls_pipeline; - LLGLEnable multisample(gSavedSettings.getU32("RenderFSAASamples") > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); LLGLState gls_color_material(GL_COLOR_MATERIAL, mLightingDetail < 2); @@ -3755,7 +3906,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) } } - LLGLEnable multisample(gSavedSettings.getU32("RenderFSAASamples") > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); LLVertexBuffer::unbind(); @@ -3836,7 +3987,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) LLGLEnable cull(GL_CULL_FACE); - LLGLEnable multisample(gSavedSettings.getU32("RenderFSAASamples") > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); calcNearbyLights(camera); setupHWLights(NULL); @@ -5051,8 +5202,9 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) light_state->setQuadraticAttenuation(0.f); } + if (light->isLightSpotlight() // directional (spot-)light - && (LLPipeline::sRenderDeferred || gSavedSettings.getBOOL("RenderSpotLightsInNondeferred"))) // these are only rendered as GL spotlights if we're in deferred rendering mode *or* the setting forces them on + && (LLPipeline::sRenderDeferred || RenderSpotLightsInNondeferred)) // these are only rendered as GL spotlights if we're in deferred rendering mode *or* the setting forces them on { LLVector3 spotparams = light->getSpotLightParams(); LLQuaternion quat = light->getRenderRotation(); @@ -5233,19 +5385,19 @@ void LLPipeline::enableLightsPreview() glEnable(GL_LIGHTING); } - LLColor4 ambient = gSavedSettings.getColor4("PreviewAmbientColor"); + LLColor4 ambient = PreviewAmbientColor; gGL.setAmbientLightColor(ambient); - LLColor4 diffuse0 = gSavedSettings.getColor4("PreviewDiffuse0"); - LLColor4 specular0 = gSavedSettings.getColor4("PreviewSpecular0"); - LLColor4 diffuse1 = gSavedSettings.getColor4("PreviewDiffuse1"); - LLColor4 specular1 = gSavedSettings.getColor4("PreviewSpecular1"); - LLColor4 diffuse2 = gSavedSettings.getColor4("PreviewDiffuse2"); - LLColor4 specular2 = gSavedSettings.getColor4("PreviewSpecular2"); + LLColor4 diffuse0 = PreviewDiffuse0; + LLColor4 specular0 = PreviewSpecular0; + LLColor4 diffuse1 = PreviewDiffuse1; + LLColor4 specular1 = PreviewSpecular1; + LLColor4 diffuse2 = PreviewDiffuse2; + LLColor4 specular2 = PreviewSpecular2; - LLVector3 dir0 = gSavedSettings.getVector3("PreviewDirection0"); - LLVector3 dir1 = gSavedSettings.getVector3("PreviewDirection1"); - LLVector3 dir2 = gSavedSettings.getVector3("PreviewDirection2"); + LLVector3 dir0 = PreviewDirection0; + LLVector3 dir1 = PreviewDirection1; + LLVector3 dir2 = PreviewDirection2; dir0.normVec(); dir1.normVec(); @@ -6085,7 +6237,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } - U32 res_mod = gSavedSettings.getU32("RenderResolutionDivisor"); + U32 res_mod = RenderResolutionDivisor; LLVector2 tc1(0,0); LLVector2 tc2((F32) gViewerWindow->getWorldViewWidthRaw()*2, @@ -6124,16 +6276,18 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) } gGlowExtractProgram.bind(); - F32 minLum = llmax(gSavedSettings.getF32("RenderGlowMinLuminance"), 0.0f); - F32 maxAlpha = gSavedSettings.getF32("RenderGlowMaxExtractAlpha"); - F32 warmthAmount = gSavedSettings.getF32("RenderGlowWarmthAmount"); - LLVector3 lumWeights = gSavedSettings.getVector3("RenderGlowLumWeights"); - LLVector3 warmthWeights = gSavedSettings.getVector3("RenderGlowWarmthWeights"); - gGlowExtractProgram.uniform1f("minLuminance", minLum); - gGlowExtractProgram.uniform1f("maxExtractAlpha", maxAlpha); - gGlowExtractProgram.uniform3f("lumWeights", lumWeights.mV[0], lumWeights.mV[1], lumWeights.mV[2]); - gGlowExtractProgram.uniform3f("warmthWeights", warmthWeights.mV[0], warmthWeights.mV[1], warmthWeights.mV[2]); - gGlowExtractProgram.uniform1f("warmthAmount", warmthAmount); + F32 minLum = llmax((F32) RenderGlowMinLuminance, 0.0f); + F32 maxAlpha = RenderGlowMaxExtractAlpha; + F32 warmthAmount = RenderGlowWarmthAmount; + LLVector3 lumWeights = RenderGlowLumWeights; + LLVector3 warmthWeights = RenderGlowWarmthWeights; + + + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MIN_LUMINANCE, minLum); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_MAX_EXTRACT_ALPHA, maxAlpha); + gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_LUM_WEIGHTS, lumWeights.mV[0], lumWeights.mV[1], lumWeights.mV[2]); + gGlowExtractProgram.uniform3f(LLShaderMgr::GLOW_WARMTH_WEIGHTS, warmthWeights.mV[0], warmthWeights.mV[1], warmthWeights.mV[2]); + gGlowExtractProgram.uniform1f(LLShaderMgr::GLOW_WARMTH_AMOUNT, warmthAmount); LLGLEnable blend_on(GL_BLEND); LLGLEnable test(GL_ALPHA_TEST); @@ -6164,22 +6318,22 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) tc2.setVec(2,2); // power of two between 1 and 1024 - U32 glowResPow = gSavedSettings.getS32("RenderGlowResolutionPow"); + U32 glowResPow = RenderGlowResolutionPow; const U32 glow_res = llmax(1, llmin(1024, 1 << glowResPow)); - S32 kernel = gSavedSettings.getS32("RenderGlowIterations")*2; - F32 delta = gSavedSettings.getF32("RenderGlowWidth") / glow_res; + S32 kernel = RenderGlowIterations*2; + F32 delta = RenderGlowWidth / glow_res; // Use half the glow width if we have the res set to less than 9 so that it looks // almost the same in either case. if (glowResPow < 9) { delta *= 0.5f; } - F32 strength = gSavedSettings.getF32("RenderGlowStrength"); + F32 strength = RenderGlowStrength; gGlowProgram.bind(); - gGlowProgram.uniform1f("glowStrength", strength); + gGlowProgram.uniform1f(LLShaderMgr::GLOW_STRENGTH, strength); for (S32 i = 0; i < kernel; i++) { @@ -6200,11 +6354,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) if (i%2 == 0) { - gGlowProgram.uniform2f("glowDelta", delta, 0); + gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, delta, 0); } else { - gGlowProgram.uniform2f("glowDelta", 0, delta); + gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, 0, delta); } gGL.begin(LLRender::TRIANGLE_STRIP); @@ -6245,11 +6399,13 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) if (LLPipeline::sRenderDeferred) { + bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && !LLToolMgr::getInstance()->inBuildMode() && - gSavedSettings.getBOOL("RenderDepthOfField"); + RenderDepthOfField; + - bool multisample = gSavedSettings.getU32("RenderFSAASamples") > 1; + bool multisample = RenderFSAASamples > 1; if (multisample) { @@ -6261,7 +6417,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) glViewport(0, 0, width, height); gGlowCombineFXAAProgram.bind(); - gGlowCombineFXAAProgram.uniform2f("screen_res", width, height); + gGlowCombineFXAAProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); gGL.getTexUnit(0)->bind(&mGlow[1]); gGL.getTexUnit(1)->bind(&mScreen); @@ -6284,7 +6440,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) LLGLSLShader* shader = &gFXAAProgram; shader->bind(); - S32 channel = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP, mFXAABuffer.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mFXAABuffer.getUsage()); if (channel > -1) { mFXAABuffer.bindTexture(0, channel); @@ -6294,10 +6450,10 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) F32 scale_x = (F32) width/mFXAABuffer.getWidth(); F32 scale_y = (F32) height/mFXAABuffer.getHeight(); - shader->uniform2f("tc_scale", scale_x, scale_y); - shader->uniform2f("rcp_screen_res", 1.f/width*scale_x, 1.f/height*scale_y); - shader->uniform4f("rcp_frame_opt", -0.5f/width*scale_x, -0.5f/height*scale_y, 0.5f/width*scale_x, 0.5f/height*scale_y); - shader->uniform4f("rcp_frame_opt2", -2.f/width*scale_x, -2.f/height*scale_y, 2.f/width*scale_x, 2.f/height*scale_y); + shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y); + shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f/width*scale_x, 1.f/height*scale_y); + shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f/width*scale_x, -0.5f/height*scale_y, 0.5f/width*scale_x, 0.5f/height*scale_y); + shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f/width*scale_x, -2.f/height*scale_y, 2.f/width*scale_x, 2.f/height*scale_y); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.vertex2f(-1,-1); @@ -6391,7 +6547,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) } else if (transition_time < 1.f) { //currently in a transition, continue interpolating - transition_time += 1.f/gSavedSettings.getF32("CameraFocusTransitionTime")*gFrameIntervalSeconds; + transition_time += 1.f/CameraFocusTransitionTime*gFrameIntervalSeconds; transition_time = llmin(transition_time, 1.f); F32 t = cosf(transition_time*F_PI+F_PI)*0.5f+0.5f; @@ -6404,12 +6560,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) //convert to mm F32 subject_distance = current_distance*1000.f; - F32 fnumber = gSavedSettings.getF32("CameraFNumber"); - F32 default_focal_length = gSavedSettings.getF32("CameraFocalLength"); + F32 fnumber = CameraFNumber; + F32 default_focal_length = CameraFocalLength; F32 fov = LLViewerCamera::getInstance()->getView(); - const F32 default_fov = gSavedSettings.getF32("CameraFieldOfView") * F_PI/180.f; + const F32 default_fov = CameraFieldOfView * F_PI/180.f; //const F32 default_aspect_ratio = gSavedSettings.getF32("CameraAspectRatio"); //F32 aspect_ratio = (F32) mScreen.getWidth()/(F32)mScreen.getHeight(); @@ -6432,13 +6588,13 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) blur_constant /= 1000.f; //convert to meters for shader F32 magnification = focal_length/(subject_distance-focal_length); - shader->uniform1f("focal_distance", -subject_distance/1000.f); - shader->uniform1f("blur_constant", blur_constant); - shader->uniform1f("tan_pixel_angle", tanf(1.f/LLDrawable::sCurPixelAngle)); - shader->uniform1f("magnification", magnification); + shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance/1000.f); + shader->uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); + shader->uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f/LLDrawable::sCurPixelAngle)); + shader->uniform1f(LLShaderMgr::DOF_MAGNIFICATION, magnification); } - S32 channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); if (channel > -1) { mScreen.bindTexture(0, channel); @@ -6446,7 +6602,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) if (multisample) { //bloom has already been added, bind black - channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_BLOOM); + channel = shader->enableTexture(LLShaderMgr::DEFERRED_BLOOM); if (channel > -1) { gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sBlackImagep); @@ -6519,7 +6675,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) gGL.getTexUnit(0)->bind(&mGlow[1]); gGL.getTexUnit(1)->bind(&mScreen); - LLGLEnable multisample(gSavedSettings.getU32("RenderFSAASamples") > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); buff->setBuffer(mask); buff->drawArrays(LLRender::TRIANGLE_STRIP, 0, 3); @@ -6611,28 +6767,28 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n shader.bind(); S32 channel = 0; - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage()); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage()); if (channel > -1) { mDeferredScreen.bindTexture(0,channel); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage()); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage()); if (channel > -1) { mDeferredScreen.bindTexture(1, channel); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage()); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage()); if (channel > -1) { mDeferredScreen.bindTexture(2, channel); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, mDeferredDepth.getUsage()); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, mDeferredDepth.getUsage()); if (channel > -1) { gGL.getTexUnit(channel)->bind(&mDeferredDepth, TRUE); @@ -6646,21 +6802,21 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n glh::matrix4f projection = glh_get_current_projection(); glh::matrix4f inv_proj = projection.inverse(); - shader.uniformMatrix4fv("inv_proj", 1, FALSE, inv_proj.m); - shader.uniform4f("viewport", (F32) gGLViewport[0], + shader.uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); + shader.uniform4f(LLShaderMgr::VIEWPORT, (F32) gGLViewport[0], (F32) gGLViewport[1], (F32) gGLViewport[2], (F32) gGLViewport[3]); } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NOISE); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_NOISE); if (channel > -1) { gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, noise_map); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_LIGHTFUNC); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); if (channel > -1) { gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); @@ -6668,7 +6824,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n stop_glerror(); - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, mDeferredLight.getUsage()); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHT, mDeferredLight.getUsage()); if (channel > -1) { if (light_index > 0) @@ -6682,7 +6838,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_BLOOM); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_BLOOM); if (channel > -1) { mGlow[1].bindTexture(0, channel); @@ -6692,7 +6848,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n for (U32 i = 0; i < 4; i++) { - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_RECT_TEXTURE); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_RECT_TEXTURE); stop_glerror(); if (channel > -1) { @@ -6710,7 +6866,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n for (U32 i = 4; i < 6; i++) { - channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i); + channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i); stop_glerror(); if (channel > -1) { @@ -6739,12 +6895,11 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n mat[i+80] = mSunShadowMatrix[5].m[i]; } - shader.uniformMatrix4fv("shadow_matrix[0]", 6, FALSE, mat); - shader.uniformMatrix4fv("shadow_matrix", 6, FALSE, mat); + shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_SHADOW_MATRIX, 6, FALSE, mat); stop_glerror(); - channel = shader.enableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); + channel = shader.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; @@ -6759,24 +6914,23 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n m[4], m[5], m[6], m[8], m[9], m[10] }; - shader.uniform3fv("env_mat[0]", 3, mat); - shader.uniform3fv("env_mat", 3, mat); + shader.uniform3fv(LLShaderMgr::DEFERRED_ENV_MAT, 3, mat); } } - shader.uniform4fv("shadow_clip", 1, mSunClipPlanes.mV); - shader.uniform1f("sun_wash", gSavedSettings.getF32("RenderDeferredSunWash")); - shader.uniform1f("shadow_noise", gSavedSettings.getF32("RenderShadowNoise")); - shader.uniform1f("blur_size", gSavedSettings.getF32("RenderShadowBlurSize")); + shader.uniform4fv(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1, mSunClipPlanes.mV); + shader.uniform1f(LLShaderMgr::DEFERRED_SUN_WASH, RenderDeferredSunWash); + shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_NOISE, RenderShadowNoise); + shader.uniform1f(LLShaderMgr::DEFERRED_BLUR_SIZE, RenderShadowBlurSize); - shader.uniform1f("ssao_radius", gSavedSettings.getF32("RenderSSAOScale")); - shader.uniform1f("ssao_max_radius", gSavedSettings.getU32("RenderSSAOMaxScale")); + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_RADIUS, RenderSSAOScale); + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_MAX_RADIUS, RenderSSAOMaxScale); - F32 ssao_factor = gSavedSettings.getF32("RenderSSAOFactor"); - shader.uniform1f("ssao_factor", ssao_factor); - shader.uniform1f("ssao_factor_inv", 1.0/ssao_factor); + F32 ssao_factor = RenderSSAOFactor; + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR, ssao_factor); + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR_INV, 1.0/ssao_factor); - LLVector3 ssao_effect = gSavedSettings.getVector3("RenderSSAOEffect"); + LLVector3 ssao_effect = RenderSSAOEffect; F32 matrix_diag = (ssao_effect[0] + 2.0*ssao_effect[1])/3.0; F32 matrix_nondiag = (ssao_effect[0] - ssao_effect[1])/3.0; // This matrix scales (proj of color onto <1/rt(3),1/rt(3),1/rt(3)>) by @@ -6784,23 +6938,23 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n F32 ssao_effect_mat[] = { matrix_diag, matrix_nondiag, matrix_nondiag, matrix_nondiag, matrix_diag, matrix_nondiag, matrix_nondiag, matrix_nondiag, matrix_diag}; - shader.uniformMatrix3fv("ssao_effect_mat", 1, GL_FALSE, ssao_effect_mat); - - F32 shadow_offset_error = 1.f + gSavedSettings.getF32("RenderShadowOffsetError") * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]); - F32 shadow_bias_error = 1.f + gSavedSettings.getF32("RenderShadowBiasError") * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]); - - shader.uniform2f("screen_res", mDeferredScreen.getWidth(), mDeferredScreen.getHeight()); - shader.uniform1f("near_clip", LLViewerCamera::getInstance()->getNear()*2.f); - shader.uniform1f ("shadow_offset", gSavedSettings.getF32("RenderShadowOffset")*shadow_offset_error); - shader.uniform1f("shadow_bias", gSavedSettings.getF32("RenderShadowBias")*shadow_bias_error); - shader.uniform1f ("spot_shadow_offset", gSavedSettings.getF32("RenderSpotShadowOffset")); - shader.uniform1f("spot_shadow_bias", gSavedSettings.getF32("RenderSpotShadowBias")); - - shader.uniform3fv("sun_dir", 1, mTransformedSunDir.mV); - shader.uniform2f("shadow_res", mShadow[0].getWidth(), mShadow[0].getHeight()); - shader.uniform2f("proj_shadow_res", mShadow[4].getWidth(), mShadow[4].getHeight()); - shader.uniform1f("depth_cutoff", gSavedSettings.getF32("RenderEdgeDepthCutoff")); - shader.uniform1f("norm_cutoff", gSavedSettings.getF32("RenderEdgeNormCutoff")); + shader.uniformMatrix3fv(LLShaderMgr::DEFERRED_SSAO_EFFECT_MAT, 1, GL_FALSE, ssao_effect_mat); + + F32 shadow_offset_error = 1.f + RenderShadowOffsetError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]); + F32 shadow_bias_error = 1.f + RenderShadowBiasError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]); + + shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredScreen.getWidth(), mDeferredScreen.getHeight()); + shader.uniform1f(LLShaderMgr::DEFERRED_NEAR_CLIP, LLViewerCamera::getInstance()->getNear()*2.f); + shader.uniform1f (LLShaderMgr::DEFERRED_SHADOW_OFFSET, RenderShadowOffset*shadow_offset_error); + shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_BIAS, RenderShadowBias*shadow_bias_error); + shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_OFFSET, RenderSpotShadowOffset); + shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_BIAS, RenderSpotShadowBias); + + shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); + shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mShadow[0].getWidth(), mShadow[0].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mShadow[4].getWidth(), mShadow[4].getHeight()); + shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); + shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); if (shader.getUniformLocation("norm_mat") >= 0) @@ -6839,7 +6993,7 @@ void LLPipeline::renderDeferredLighting() 0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); } - LLGLEnable multisample(gSavedSettings.getU32("RenderFSAASamples") > 0 ? GL_MULTISAMPLE_ARB : 0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { @@ -6886,7 +7040,7 @@ void LLPipeline::renderDeferredLighting() gGL.pushMatrix(); gGL.loadIdentity(); - if (gSavedSettings.getBOOL("RenderDeferredSSAO") || gSavedSettings.getS32("RenderShadowDetail") > 0) + if (RenderDeferredSSAO || RenderShadowDetail > 0) { mDeferredLight.bindTarget(); { //paint shadow/SSAO light map (direct lighting lightmap) @@ -6932,7 +7086,7 @@ void LLPipeline::renderDeferredLighting() mDeferredLight.flush(); } - if (gSavedSettings.getBOOL("RenderDeferredSSAO")) + if (RenderDeferredSSAO) { //soften direct lighting lightmap LLFastTimer ftm(FTM_SOFTEN_SHADOW); //blur lightmap @@ -6943,10 +7097,10 @@ void LLPipeline::renderDeferredLighting() bindDeferredShader(gDeferredBlurLightProgram); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - LLVector3 go = gSavedSettings.getVector3("RenderShadowGaussian"); + LLVector3 go = RenderShadowGaussian; const U32 kern_length = 4; - F32 blur_size = gSavedSettings.getF32("RenderShadowBlurSize"); - F32 dist_factor = gSavedSettings.getF32("RenderShadowBlurDistFactor"); + F32 blur_size = RenderShadowBlurSize; + F32 dist_factor = RenderShadowBlurDistFactor; // sample symmetrically with the middle sample falling exactly on 0.0 F32 x = 0.f; @@ -7011,7 +7165,7 @@ void LLPipeline::renderDeferredLighting() glClearColor(0,0,0,0); mScreen.clear(GL_COLOR_BUFFER_BIT); - if (gSavedSettings.getBOOL("RenderDeferredAtmospheric")) + if (RenderDeferredAtmospheric) { //apply sunlight contribution LLFastTimer ftm(FTM_ATMOSPHERICS); bindDeferredShader(gDeferredSoftenProgram); @@ -7056,7 +7210,7 @@ void LLPipeline::renderDeferredLighting() gPipeline.popRenderTypeMask(); } - BOOL render_local = gSavedSettings.getBOOL("RenderLocalLights"); + BOOL render_local = RenderLocalLights; if (render_local) { @@ -7162,10 +7316,10 @@ void LLPipeline::renderDeferredLighting() LLFastTimer ftm(FTM_LOCAL_LIGHTS); //glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s); - gDeferredLightProgram.uniform3fv("center", 1, tc.v); - gDeferredLightProgram.uniform1f("size", s*s); - gDeferredLightProgram.uniform3fv("color", 1, col.mV); - gDeferredLightProgram.uniform1f("falloff", volume->getLightFalloff()*0.5f); + gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s); + gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); //gGL.diffuseColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f); gGL.syncMatrices(); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -7197,7 +7351,7 @@ void LLPipeline::renderDeferredLighting() mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - gDeferredSpotLightProgram.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); + gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) { @@ -7236,16 +7390,16 @@ void LLPipeline::renderDeferredLighting() v[6].set(c[0]+s,c[1]+s,c[2]-s); // 6 - 0110 v[7].set(c[0]+s,c[1]+s,c[2]+s); // 7 - 0111 - gDeferredSpotLightProgram.uniform3fv("center", 1, tc.v); - gDeferredSpotLightProgram.uniform1f("size", s*s); - gDeferredSpotLightProgram.uniform3fv("color", 1, col.mV); - gDeferredSpotLightProgram.uniform1f("falloff", volume->getLightFalloff()*0.5f); + gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); + gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s); + gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); gGL.syncMatrices(); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8, GL_UNSIGNED_SHORT, get_box_fan_indices_ptr(camera, center)); } - gDeferredSpotLightProgram.disableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); + gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); unbindDeferredShader(gDeferredSpotLightProgram); } @@ -7292,12 +7446,12 @@ void LLPipeline::renderDeferredLighting() count++; if (count == max_count || fullscreen_lights.empty()) { - gDeferredMultiLightProgram.uniform1i("light_count", count); - gDeferredMultiLightProgram.uniform4fv("light", count, (GLfloat*) light); - gDeferredMultiLightProgram.uniform4fv("light_col", count, (GLfloat*) col); - gDeferredMultiLightProgram.uniform1f("far_z", far_z); + gDeferredMultiLightProgram.uniform1i(LLShaderMgr::MULTI_LIGHT_COUNT, count); + gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*) light); + gDeferredMultiLightProgram.uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*) col); + gDeferredMultiLightProgram.uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); far_z = 0.f; - count = 0; + count = 0; mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); } } @@ -7306,7 +7460,7 @@ void LLPipeline::renderDeferredLighting() bindDeferredShader(gDeferredMultiSpotLightProgram); - gDeferredMultiSpotLightProgram.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); + gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -7331,14 +7485,14 @@ void LLPipeline::renderDeferredLighting() LLColor3 col = volume->getLightColor(); col *= volume->getLightIntensity(); - gDeferredMultiSpotLightProgram.uniform3fv("center", 1, tc.v); - gDeferredMultiSpotLightProgram.uniform1f("size", s*s); - gDeferredMultiSpotLightProgram.uniform3fv("color", 1, col.mV); - gDeferredMultiSpotLightProgram.uniform1f("falloff", volume->getLightFalloff()*0.5f); + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); + gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s); + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); + gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); } - gDeferredMultiSpotLightProgram.disableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); + gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); unbindDeferredShader(gDeferredMultiSpotLightProgram); gGL.popMatrix(); @@ -7463,13 +7617,13 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) F32 proj_range = far_clip - near_clip; glh::matrix4f light_proj = gl_perspective(fovy, aspect, near_clip, far_clip); screen_to_light = trans * light_proj * screen_to_light; - shader.uniformMatrix4fv("proj_mat", 1, FALSE, screen_to_light.m); - shader.uniform1f("proj_near", near_clip); - shader.uniform3fv("proj_p", 1, p1.v); - shader.uniform3fv("proj_n", 1, n.v); - shader.uniform3fv("proj_origin", 1, screen_origin.v); - shader.uniform1f("proj_range", proj_range); - shader.uniform1f("proj_ambiance", params.mV[2]); + shader.uniformMatrix4fv(LLShaderMgr::PROJECTOR_MATRIX, 1, FALSE, screen_to_light.m); + shader.uniform1f(LLShaderMgr::PROJECTOR_NEAR, near_clip); + shader.uniform3fv(LLShaderMgr::PROJECTOR_P, 1, p1.v); + shader.uniform3fv(LLShaderMgr::PROJECTOR_N, 1, n.v); + shader.uniform3fv(LLShaderMgr::PROJECTOR_ORIGIN, 1, screen_origin.v); + shader.uniform1f(LLShaderMgr::PROJECTOR_RANGE, proj_range); + shader.uniform1f(LLShaderMgr::PROJECTOR_AMBIANCE, params.mV[2]); S32 s_idx = -1; for (U32 i = 0; i < 2; i++) @@ -7480,15 +7634,15 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) } } - shader.uniform1i("proj_shadow_idx", s_idx); + shader.uniform1i(LLShaderMgr::PROJECTOR_SHADOW_INDEX, s_idx); if (s_idx >= 0) { - shader.uniform1f("shadow_fade", 1.f-mSpotLightFade[s_idx]); + shader.uniform1f(LLShaderMgr::PROJECTOR_SHADOW_FADE, 1.f-mSpotLightFade[s_idx]); } else { - shader.uniform1f("shadow_fade", 1.f); + shader.uniform1f(LLShaderMgr::PROJECTOR_SHADOW_FADE, 1.f); } { @@ -7522,7 +7676,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) img = LLViewerFetchedTexture::sWhiteImagep; } - S32 channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION); + S32 channel = shader.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); if (channel > -1) { @@ -7532,9 +7686,9 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) F32 lod_range = logf(img->getWidth())/logf(2.f); - shader.uniform1f("proj_focus", focus); - shader.uniform1f("proj_lod", lod_range); - shader.uniform1f("proj_ambient_lod", llclamp((proj_range-focus)/proj_range*lod_range, 0.f, 1.f)); + shader.uniform1f(LLShaderMgr::PROJECTOR_FOCUS, focus); + shader.uniform1f(LLShaderMgr::PROJECTOR_LOD, lod_range); + shader.uniform1f(LLShaderMgr::PROJECTOR_AMBIENT_LOD, llclamp((proj_range-focus)/proj_range*lod_range, 0.f, 1.f)); } } @@ -7543,17 +7697,17 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { stop_glerror(); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage()); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage()); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage()); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, mDeferredScreen.getUsage()); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, mDeferredLight.getUsage()); - shader.disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_BLOOM); + shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, mDeferredScreen.getUsage()); + shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, mDeferredLight.getUsage()); + shader.disableTexture(LLShaderMgr::DIFFUSE_MAP); + shader.disableTexture(LLShaderMgr::DEFERRED_BLOOM); for (U32 i = 0; i < 4; i++) { - if (shader.disableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_RECT_TEXTURE) > -1) + if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_RECT_TEXTURE) > -1) { glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); } @@ -7561,16 +7715,16 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) for (U32 i = 4; i < 6; i++) { - if (shader.disableTexture(LLViewerShaderMgr::DEFERRED_SHADOW0+i) > -1) + if (shader.disableTexture(LLShaderMgr::DEFERRED_SHADOW0+i) > -1) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); } } - shader.disableTexture(LLViewerShaderMgr::DEFERRED_NOISE); - shader.disableTexture(LLViewerShaderMgr::DEFERRED_LIGHTFUNC); + shader.disableTexture(LLShaderMgr::DEFERRED_NOISE); + shader.disableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); - S32 channel = shader.disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); + S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; @@ -7718,7 +7872,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES); - S32 detail = gSavedSettings.getS32("RenderReflectionDetail"); + S32 detail = RenderReflectionDetail; if (detail > 0) { //mask out selected geometry based on reflection detail if (detail < 4) @@ -7742,7 +7896,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) if (LLDrawPoolWater::sNeedsDistortionUpdate) { - if (gSavedSettings.getS32("RenderReflectionDetail") > 0) + if (RenderReflectionDetail > 0) { gPipeline.grabReferences(ref_result); LLGLUserClipPlane clip_plane(plane, mat, projection); @@ -8233,7 +8387,7 @@ void LLPipeline::generateHighlight(LLCamera& camera) if (!mHighlightSet.empty()) { - F32 transition = gFrameIntervalSeconds/gSavedSettings.getF32("RenderHighlightFadeTime"); + F32 transition = gFrameIntervalSeconds/RenderHighlightFadeTime; LLGLDisable test(GL_ALPHA_TEST); LLGLDepthTest depth(GL_FALSE); @@ -8279,7 +8433,7 @@ void LLPipeline::generateHighlight(LLCamera& camera) void LLPipeline::generateSunShadow(LLCamera& camera) { - if (!sRenderDeferred || gSavedSettings.getS32("RenderShadowDetail") <= 0) + if (!sRenderDeferred || RenderShadowDetail <= 0) { return; } @@ -8337,25 +8491,25 @@ void LLPipeline::generateSunShadow(LLCamera& camera) glh::matrix4f proj[6]; //clip contains parallel split distances for 3 splits - LLVector3 clip = gSavedSettings.getVector3("RenderShadowClipPlanes"); + LLVector3 clip = RenderShadowClipPlanes; //F32 slope_threshold = gSavedSettings.getF32("RenderShadowSlopeThreshold"); //far clip on last split is minimum of camera view distance and 128 mSunClipPlanes = LLVector4(clip, clip.mV[2] * clip.mV[2]/clip.mV[1]); - clip = gSavedSettings.getVector3("RenderShadowOrthoClipPlanes"); + clip = RenderShadowOrthoClipPlanes; mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); //currently used for amount to extrude frusta corners for constructing shadow frusta - LLVector3 n = gSavedSettings.getVector3("RenderShadowNearDist"); + LLVector3 n = RenderShadowNearDist; //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; //put together a universal "near clip" plane for shadow frusta LLPlane shadow_near_clip; { LLVector3 p = gAgent.getPositionAgent(); - p += mSunDir * gSavedSettings.getF32("RenderFarClip")*2.f; + p += mSunDir * RenderFarClip*2.f; shadow_near_clip.setVec(p, mSunDir); } @@ -8442,7 +8596,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) F32 range = far_clip-near_clip; - LLVector3 split_exp = gSavedSettings.getVector3("RenderShadowSplitExponent"); + LLVector3 split_exp = RenderShadowSplitExponent; F32 da = 1.f-llmax( fabsf(lightDir*up), fabsf(lightDir*camera.getLeftAxis()) ); @@ -8653,7 +8807,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mShadowError.mV[j] /= wpf.size(); mShadowError.mV[j] /= size.mV[0]; - if (mShadowError.mV[j] > gSavedSettings.getF32("RenderShadowErrorCutoff")) + if (mShadowError.mV[j] > RenderShadowErrorCutoff) { //just use ortho projection mShadowFOV.mV[j] = -1.f; origin.clearVec(); @@ -8696,7 +8850,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) fovx = acos(fovx); fovz = acos(fovz); - F32 cutoff = llmin(gSavedSettings.getF32("RenderShadowFOVCutoff"), 1.4f); + F32 cutoff = llmin((F32) RenderShadowFOVCutoff, 1.4f); mShadowFOV.mV[j] = fovx; @@ -8840,7 +8994,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //hack to disable projector shadows - bool gen_shadow = gSavedSettings.getS32("RenderShadowDetail") > 1; + bool gen_shadow = RenderShadowDetail > 1; if (gen_shadow) { @@ -8979,7 +9133,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } - if (!gSavedSettings.getBOOL("CameraOffset")) + if (!CameraOffset) { glh_set_current_modelview(saved_view); glh_set_current_projection(saved_proj); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 86579261ca..584e6e4c23 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -360,6 +360,7 @@ public: static void updateRenderDeferred(); static void refreshRenderDeferred(); + static void refreshCachedSettings(); static void throttleNewMemoryAllocation(BOOL disable); @@ -771,6 +772,79 @@ public: //debug use static U32 sCurRenderPoolType ; + + //cached settings + static BOOL WindLightUseAtmosShaders; + static BOOL VertexShaderEnable; + static BOOL RenderAvatarVP; + static BOOL RenderDeferred; + static F32 RenderDeferredSunWash; + static U32 RenderFSAASamples; + static U32 RenderResolutionDivisor; + static BOOL RenderUIBuffer; + static S32 RenderShadowDetail; + static BOOL RenderDeferredSSAO; + static F32 RenderShadowResolutionScale; + static BOOL RenderLocalLights; + static BOOL RenderDelayCreation; + static BOOL RenderAnimateRes; + static BOOL FreezeTime; + static S32 DebugBeaconLineWidth; + static F32 RenderHighlightBrightness; + static LLColor4 RenderHighlightColor; + static F32 RenderHighlightThickness; + static BOOL RenderSpotLightsInNondeferred; + static LLColor4 PreviewAmbientColor; + static LLColor4 PreviewDiffuse0; + static LLColor4 PreviewSpecular0; + static LLColor4 PreviewDiffuse1; + static LLColor4 PreviewSpecular1; + static LLColor4 PreviewDiffuse2; + static LLColor4 PreviewSpecular2; + static LLVector3 PreviewDirection0; + static LLVector3 PreviewDirection1; + static LLVector3 PreviewDirection2; + static F32 RenderGlowMinLuminance; + static F32 RenderGlowMaxExtractAlpha; + static F32 RenderGlowWarmthAmount; + static LLVector3 RenderGlowLumWeights; + static LLVector3 RenderGlowWarmthWeights; + static S32 RenderGlowResolutionPow; + static S32 RenderGlowIterations; + static F32 RenderGlowWidth; + static F32 RenderGlowStrength; + static BOOL RenderDepthOfField; + static F32 CameraFocusTransitionTime; + static F32 CameraFNumber; + static F32 CameraFocalLength; + static F32 CameraFieldOfView; + static F32 RenderShadowNoise; + static F32 RenderShadowBlurSize; + static F32 RenderSSAOScale; + static U32 RenderSSAOMaxScale; + static F32 RenderSSAOFactor; + static LLVector3 RenderSSAOEffect; + static F32 RenderShadowOffsetError; + static F32 RenderShadowBiasError; + static F32 RenderShadowOffset; + static F32 RenderShadowBias; + static F32 RenderSpotShadowOffset; + static F32 RenderSpotShadowBias; + static F32 RenderEdgeDepthCutoff; + static F32 RenderEdgeNormCutoff; + static LLVector3 RenderShadowGaussian; + static F32 RenderShadowBlurDistFactor; + static BOOL RenderDeferredAtmospheric; + static S32 RenderReflectionDetail; + static F32 RenderHighlightFadeTime; + static LLVector3 RenderShadowClipPlanes; + static LLVector3 RenderShadowOrthoClipPlanes; + static LLVector3 RenderShadowNearDist; + static F32 RenderFarClip; + static LLVector3 RenderShadowSplitExponent; + static F32 RenderShadowErrorCutoff; + static F32 RenderShadowFOVCutoff; + static BOOL CameraOffset; }; void render_bbox(const LLVector3 &min, const LLVector3 &max); |