diff --git a/LICENSES/c-ares.txt b/LICENSES/c-ares.txt index ad4be41ac..136107bd6 100644 --- a/LICENSES/c-ares.txt +++ b/LICENSES/c-ares.txt @@ -1,16 +1,11 @@ -http://daniel.haxx.se/projects/c-ares/license.html - - c-ares license - - Copyright 1998 by the Massachusetts Institute of Technology. - - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose and without fee is hereby granted, provided that - the above copyright notice appear in all copies and that both that copyright - notice and this permission notice appear in supporting documentation, and that - the name of M.I.T. not be used in advertising or publicity pertaining to - distribution of the software without specific, written prior permission. - M.I.T. makes no representations about the suitability of this software for any - purpose. It is provided "as is" without express or implied warranty. - +Copyright 1998 by the Massachusetts Institute of Technology. + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that +the above copyright notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting documentation, and that +the name of M.I.T. not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior permission. +M.I.T. makes no representations about the suitability of this software for any +purpose. It is provided "as is" without express or implied warranty. diff --git a/LICENSES/curl.txt b/LICENSES/curl.txt index edfff428c..163b299ae 100644 --- a/LICENSES/curl.txt +++ b/LICENSES/curl.txt @@ -1,6 +1,6 @@ COPYRIGHT AND PERMISSION NOTICE -Copyright (c) 1996 - 2002, Daniel Stenberg, . +Copyright (c) 1996 - 2010, Daniel Stenberg, . All rights reserved. @@ -19,4 +19,3 @@ OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. - diff --git a/indra/llmessage/llares.cpp b/indra/llmessage/llares.cpp index fe37fe814..34dfc9bdb 100644 --- a/indra/llmessage/llares.cpp +++ b/indra/llmessage/llares.cpp @@ -42,6 +42,7 @@ #include "apr_poll.h" #include "llapr.h" +#define CARES_STATICLIB #include "llares.h" #if defined(LL_WINDOWS) @@ -104,7 +105,8 @@ void LLAres::QueryResponder::queryError(int code) LLAres::LLAres() : chan_(NULL), mInitSuccess(false) { - if (ares_init(&chan_) != ARES_SUCCESS) + if (ares_library_init(ARES_LIB_INIT_ALL) != ARES_SUCCESS || + ares_init(&chan_) != ARES_SUCCESS) { llwarns << "Could not succesfully initialize ares!" << llendl; return; @@ -468,7 +470,7 @@ bool LLAres::process(U64 timeout) ll_init_apr(); } - int socks[ARES_GETSOCK_MAXNUM]; + ares_socket_t socks[ARES_GETSOCK_MAXNUM]; apr_pollfd_t aprFds[ARES_GETSOCK_MAXNUM]; apr_int32_t nsds = 0; int nactive = 0; diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 933da8ab7..74d48fa0e 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -69,9 +69,10 @@ hasGamma(false), hasLighting(false), calculatesAtmospherics(false) //=============================== // LLGLSL Shader implementation //=============================== -LLGLSLShader::LLGLSLShader() -: mProgramObject(0), mShaderLevel(0), mShaderGroup(SG_DEFAULT) +LLGLSLShader::LLGLSLShader(S32 shader_class) +: mProgramObject(0), mShaderClass(shader_class), mShaderLevel(0), mShaderGroup(SG_DEFAULT) { + LLShaderMgr::getGlobalShaderList().push_back(this); } void LLGLSLShader::unload() @@ -84,17 +85,18 @@ void LLGLSLShader::unload() if (mProgramObject) { - GLhandleARB obj[1024]; + //Don't do this! Attached objects are already flagged for deletion. + //They will be deleted when no programs have them attached. (deleting a program auto-detaches them!) + /*GLhandleARB obj[1024]; GLsizei count; glGetAttachedObjectsARB(mProgramObject, 1024, &count, obj); - for (GLsizei i = 0; i < count; i++) + for (GLsizei i = 0; i < count; i++) { glDeleteObjectARB(obj[i]); - } - - glDeleteObjectARB(mProgramObject); - + }*/ + if(mProgramObject) + glDeleteObjectARB(mProgramObject); mProgramObject = 0; } @@ -110,12 +112,17 @@ BOOL LLGLSLShader::createShader(vector * attributes, llassert_always(!mShaderFiles.empty()); BOOL success = TRUE; + if(mProgramObject) //purge the old program + glDeleteObjectARB(mProgramObject); // Create program mProgramObject = glCreateProgramObjectARB(); // Attach existing objects if (!LLShaderMgr::instance()->attachShaderFeatures(this)) { + if(mProgramObject) + glDeleteObjectARB(mProgramObject); + mProgramObject = 0; return FALSE; } @@ -145,6 +152,10 @@ BOOL LLGLSLShader::createShader(vector * attributes, } if( !success ) { + if(mProgramObject) + glDeleteObjectARB(mProgramObject); + mProgramObject = 0; + LL_WARNS("ShaderLoading") << "Failed to link shader: " << mName << LL_ENDL; // Try again using a lower shader level; diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 166d4af04..1f46a7b4f 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -67,7 +67,7 @@ public: SG_WATER }; - LLGLSLShader(); + LLGLSLShader(S32 shader_class); void unload(); BOOL createShader(std::vector * attributes, @@ -134,6 +134,7 @@ public: std::map mValue; //lookup map of uniform location to last known value std::vector mTexture; S32 mActiveTextureChannels; + S32 mShaderClass; S32 mShaderLevel; S32 mShaderGroup; BOOL mUniformsDirty; diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index 7f4be6a86..8adbf419f 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -37,6 +37,10 @@ #include "llsdserialize.h" #include "llrender.h" +#include "lldir.h" +extern LLGLSLShader gPostColorFilterProgram; +extern LLGLSLShader gPostNightVisionProgram; +extern LLGLSLShader gPostGaussianBlurProgram; LLPostProcess * gPostProcess = NULL; @@ -60,7 +64,7 @@ LLPostProcess::LLPostProcess(void) : mNoiseTexture = NULL ; mTempBloomTexture = NULL ; - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.*/ std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); LL_DEBUGS2("AppInit", "Shaders") << "Loading PostProcess Effects settings from " << pathName << LL_ENDL; @@ -96,6 +100,7 @@ LLPostProcess::LLPostProcess(void) : defaultEffect["bloom_strength"] = 1.5; /// Color Filter Defaults + defaultEffect["gamma"] = 1.0; defaultEffect["brightness"] = 1.0; defaultEffect["contrast"] = 1.0; defaultEffect["saturation"] = 1.0; @@ -105,10 +110,12 @@ LLPostProcess::LLPostProcess(void) : contrastBase.append(1.0); contrastBase.append(1.0); contrastBase.append(0.5); + + defaultEffect["gauss_blur_passes"] = 2; } setSelectedEffect("default"); - */ + //*/ } LLPostProcess::~LLPostProcess(void) @@ -145,7 +152,7 @@ void LLPostProcess::setSelectedEffect(std::string const & effectName) void LLPostProcess::saveEffect(std::string const & effectName) { - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.*/ mAllEffects[effectName] = tweaks; std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", XML_FILENAME)); @@ -156,7 +163,7 @@ void LLPostProcess::saveEffect(std::string const & effectName) LLPointer formatter = new LLSDXMLFormatter(); formatter->format(mAllEffects, effectsXML); - */ + //*/ } void LLPostProcess::invalidate() { @@ -187,6 +194,7 @@ void LLPostProcess::initialize(unsigned int width, unsigned int height) createNightVisionShader(); createBloomShader(); createColorFilterShader(); + createGaussBlurShader(); checkError(); } @@ -194,50 +202,64 @@ inline bool LLPostProcess::shadersEnabled(void) { return (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean() || - tweaks.useBloomShader().asBoolean() ); + tweaks.useBloomShader().asBoolean() || + tweaks.useGaussBlurFilter().asBoolean() ); } void LLPostProcess::applyShaders(void) { - if (tweaks.useColorFilter()){ + bool copy_buffer = false; + if (tweaks.useColorFilter()) + { applyColorFilterShader(); checkError(); - } - if (tweaks.useNightVisionShader()){ + copy_buffer = true; + } + if (tweaks.useGaussBlurFilter()) + { /// If any of the above shaders have been called update the frame buffer; - if (tweaks.useColorFilter()) - { - U32 tex = mSceneRenderTexture->getTexName() ; - copyFrameBuffer(tex, screenW, screenH); - } + if (copy_buffer) + copyFrameBuffer(mSceneRenderTexture->getTexName(), screenW, screenH); + applyGaussBlurShader(); + checkError(); + copy_buffer = true; + } + if (tweaks.useNightVisionShader()) + { + /// If any of the above shaders have been called update the frame buffer; + if (copy_buffer) + copyFrameBuffer(mSceneRenderTexture->getTexName(), screenW, screenH); applyNightVisionShader(); checkError(); + copy_buffer = true; } - if (tweaks.useBloomShader()){ + if (tweaks.useBloomShader()) + { /// If any of the above shaders have been called update the frame buffer; - if (tweaks.useColorFilter().asBoolean() || tweaks.useNightVisionShader().asBoolean()) - { - U32 tex = mSceneRenderTexture->getTexName() ; - copyFrameBuffer(tex, screenW, screenH); - } + if (copy_buffer) + copyFrameBuffer(mSceneRenderTexture->getTexName(), screenW, screenH); applyBloomShader(); checkError(); + copy_buffer = true; } } void LLPostProcess::applyColorFilterShader(void) { - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + if(gPostColorFilterProgram.mProgramObject == 0) + return; + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.*/ gPostColorFilterProgram.bind(); gGL.getTexUnit(0)->activate(); gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mSceneRenderTexture.get()->getTexName()); getShaderUniforms(colorFilterUniforms, gPostColorFilterProgram.mProgramObject); glUniform1iARB(colorFilterUniforms["RenderTexture"], 0); + glUniform1fARB(colorFilterUniforms["gamma"], tweaks.getGamma()); glUniform1fARB(colorFilterUniforms["brightness"], tweaks.getBrightness()); glUniform1fARB(colorFilterUniforms["contrast"], tweaks.getContrast()); float baseI = (tweaks.getContrastBaseR() + tweaks.getContrastBaseG() + tweaks.getContrastBaseB()) / 3.0f; @@ -256,13 +278,14 @@ void LLPostProcess::applyColorFilterShader(void) /// Draw a screen space quad drawOrthoQuad(screenW, screenH, QUAD_NORMAL); gPostColorFilterProgram.unbind(); - */ + //*/ } void LLPostProcess::createColorFilterShader(void) { /// Define uniform names colorFilterUniforms["RenderTexture"] = 0; + colorFilterUniforms["gamma"] = 0; colorFilterUniforms["brightness"] = 0; colorFilterUniforms["contrast"] = 0; colorFilterUniforms["contrastBase"] = 0; @@ -272,20 +295,22 @@ void LLPostProcess::createColorFilterShader(void) void LLPostProcess::applyNightVisionShader(void) { - /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender. + if(gPostNightVisionProgram.mProgramObject == 0) + return; + /* Do nothing. Needs to be updated to use our current shader system, and to work with the move into llrender.*/ gPostNightVisionProgram.bind(); gGL.getTexUnit(0)->activate(); gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); getShaderUniforms(nightVisionUniforms, gPostNightVisionProgram.mProgramObject); - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, sceneRenderTexture); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mSceneRenderTexture.get()->getTexName()); glUniform1iARB(nightVisionUniforms["RenderTexture"], 0); gGL.getTexUnit(1)->activate(); gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, noiseTexture); + gGL.getTexUnit(1)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseTexture.get()->getTexName()); glUniform1iARB(nightVisionUniforms["NoiseTexture"], 1); @@ -305,7 +330,7 @@ void LLPostProcess::applyNightVisionShader(void) drawOrthoQuad(screenW, screenH, QUAD_NOISE); gPostNightVisionProgram.unbind(); gGL.getTexUnit(0)->activate(); - */ + //*/ } void LLPostProcess::createNightVisionShader(void) @@ -327,7 +352,7 @@ void LLPostProcess::applyBloomShader(void) void LLPostProcess::createBloomShader(void) { - createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); + //createTexture(mTempBloomTexture, unsigned(screenW * 0.5), unsigned(screenH * 0.5)); /// Create Bloom Extract Shader bloomExtractUniforms["RenderTexture"] = 0; @@ -343,6 +368,43 @@ void LLPostProcess::createBloomShader(void) bloomBlurUniforms["blurWidth"] = 0; } +void LLPostProcess::applyGaussBlurShader(void) +{ + int pass_count = tweaks.getGaussBlurPasses(); + if(!pass_count || gPostGaussianBlurProgram.mProgramObject == 0) + return; + + getShaderUniforms(gaussBlurUniforms, gPostGaussianBlurProgram.mProgramObject); + gPostGaussianBlurProgram.bind(); + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mSceneRenderTexture.get()->getTexName()); + LLGLEnable blend(GL_BLEND); + LLGLDepthTest depth(GL_FALSE); + gGL.setSceneBlendType(LLRender::BT_REPLACE); + glUniform1iARB(gaussBlurUniforms["RenderTexture"], 0); + GLint horiz_pass = gaussBlurUniforms["horizontalPass"]; + for(int i = 0;igetTexName(), screenW, screenH); + glUniform1iARB(horiz_pass, j); + drawOrthoQuad(screenW, screenH, QUAD_NORMAL); + + } + } + gPostGaussianBlurProgram.unbind(); + +} + +void LLPostProcess::createGaussBlurShader(void) +{ + gaussBlurUniforms["RenderTexture"] = 0; + gaussBlurUniforms["horizontalPass"] = 0; +} + void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog) { /// Find uniform locations and insert into map @@ -360,8 +422,7 @@ void LLPostProcess::doEffects(void) /// Copy the screen buffer to the render texture { - U32 tex = mSceneRenderTexture->getTexName() ; - copyFrameBuffer(tex, screenW, screenH); + copyFrameBuffer(mSceneRenderTexture->getTexName(), screenW, screenH); } /// Clear the frame buffer. @@ -386,85 +447,85 @@ void LLPostProcess::doEffects(void) checkError(); } -void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height) +void LLPostProcess::copyFrameBuffer(LLGLuint texture, unsigned int width, unsigned int height) { gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture); glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, width, height, 0); } +inline void InitQuadArray(F32 *arr, const F32 x, const F32 y, const F32 width, const F32 height) +{ + //Lower left + *(arr++)=x; + *(arr++)=y; + //Upper left + *(arr++)=x; + *(arr++)=y+height; + //Upper right + *(arr++)=x+width; + *(arr++)=y+height; + //Lower right + *(arr++)=x+width; + *(arr++)=y; +} void LLPostProcess::drawOrthoQuad(unsigned int width, unsigned int height, QuadType type) { -#if 0 - float noiseX = 0.f; - float noiseY = 0.f; - float screenRatio = 1.0f; +#if 1 + //Redid the logic here. Less cases. No longer using immediate mode. + bool second_tex = true; + //Vertex array used for all post-processing effects + static F32 verts[8]; + //Texture coord array used for all post-processing effects + static F32 tex0[8]; + //Texture coord array used for relevant post processing effects + static F32 tex1[8]; - if (type == QUAD_NOISE){ - noiseX = ((float) rand() / (float) RAND_MAX); - noiseY = ((float) rand() / (float) RAND_MAX); - screenRatio = (float) width / (float) height; + //Set up vertex array + InitQuadArray(verts, 0.f, 0.f, width, height); + + //Set up first texture coords + if(type == QUAD_BLOOM_EXTRACT) + { + InitQuadArray(tex0, 0.f, 0.f, width*2.f, height*2.f); + second_tex = false; + } + else + { + InitQuadArray(tex0, 0.f, 0.f, width, height); + //Set up second texture coords + if( type == QUAD_BLOOM_COMBINE) + InitQuadArray(tex1, 0.f, 0.f, width*.5, height*.5); + else if( type == QUAD_NOISE ) + InitQuadArray(tex1, ((float) rand() / (float) RAND_MAX), ((float) rand() / (float) RAND_MAX), + width * noiseTextureScale / height, noiseTextureScale); + else + second_tex = false; } + //Prepare to render + glEnableClientState( GL_VERTEX_ARRAY ); + glVertexPointer(2, GL_FLOAT, sizeof(F32)*2, verts); + if(second_tex) //tex1 setup + { + glClientActiveTextureARB(GL_TEXTURE1); + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + glTexCoordPointer(2, GL_FLOAT, sizeof(F32)*2, tex1); + } + glClientActiveTextureARB(GL_TEXTURE0); + glEnableClientState( GL_TEXTURE_COORD_ARRAY ); + glTexCoordPointer(2, GL_FLOAT, sizeof(F32)*2, tex0); - glBegin(GL_QUADS); - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, (GLfloat) height * 2.0f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - noiseX, - noiseTextureScale + noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, (GLfloat) height * 0.5f); - } - glVertex2f(0.f, (GLfloat) screenH - height); + //Render + glDrawArrays(GL_QUADS, 0, sizeof(verts)/sizeof(verts[0])); - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.f, 0.f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - noiseX, - noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.f, 0.f); - } - glVertex2f(0.f, (GLfloat) height + (screenH - height)); - - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, 0.f); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, 0.f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - screenRatio * noiseTextureScale + noiseX, - noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, 0.f); - } - glVertex2f((GLfloat) width, (GLfloat) height + (screenH - height)); - - - if (type != QUAD_BLOOM_EXTRACT){ - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width, (GLfloat) height); - } else { - glMultiTexCoord2fARB(GL_TEXTURE0_ARB, (GLfloat) width * 2.0f, (GLfloat) height * 2.0f); - } - if (type == QUAD_NOISE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, - screenRatio * noiseTextureScale + noiseX, - noiseTextureScale + noiseY); - } else if (type == QUAD_BLOOM_COMBINE){ - glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (GLfloat) width * 0.5f, (GLfloat) height * 0.5f); - } - glVertex2f((GLfloat) width, (GLfloat) screenH - height); - glEnd(); + //Cleanup + glDisableClientState( GL_VERTEX_ARRAY ); + glDisableClientState( GL_TEXTURE_COORD_ARRAY ); //for tex0 + if(second_tex) + { + glClientActiveTextureARB(GL_TEXTURE1); + glDisableClientState( GL_TEXTURE_COORD_ARRAY ); //for tex1 + } #endif } @@ -473,7 +534,7 @@ void LLPostProcess::viewOrthogonal(unsigned int width, unsigned int height) glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glOrtho( 0.f, (GLdouble) width , (GLdouble) height , 0.f, -1.f, 1.f ); + glOrtho( 0.f, (GLdouble) width, 0.f, (GLdouble) height, -1.f, 1.f ); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); diff --git a/indra/llrender/llpostprocess.h b/indra/llrender/llpostprocess.h index 009e4bd41..8e914a7c7 100644 --- a/indra/llrender/llpostprocess.h +++ b/indra/llrender/llpostprocess.h @@ -124,7 +124,10 @@ public: inline LLSD & useColorFilter() { return (*this)["enable_color_filter"]; } - + + inline LLSD & useGaussBlurFilter() { + return (*this)["enable_gauss_blur"]; + } inline F32 getBrightMult() const { return F32((*this)["brightness_multiplier"].asReal()); @@ -154,6 +157,10 @@ public: return F32((*this)["bloom_strength"].asReal()); } + inline F32 getGamma() const { + return F32((*this)["gamma"].asReal()); + } + inline F32 getBrightness() const { return F32((*this)["brightness"].asReal()); } @@ -182,6 +189,9 @@ public: return F32((*this)["saturation"].asReal()); } + inline LLSD & getGaussBlurPasses() { + return (*this)["gauss_blur_passes"]; + } }; bool initialized; @@ -230,6 +240,7 @@ private: glslUniforms bloomExtractUniforms; glslUniforms bloomBlurUniforms; glslUniforms colorFilterUniforms; + glslUniforms gaussBlurUniforms; // the name of currently selected effect in mAllEffects // invariant: tweaks == mAllEffects[mSelectedEffectName] @@ -253,10 +264,14 @@ private: void createColorFilterShader(void); void applyColorFilterShader(void); + /// Gaussian blur Filter Functions + void createGaussBlurShader(void); + void applyGaussBlurShader(void); + /// OpenGL Helper Functions void getShaderUniforms(glslUniforms & uniforms, GLhandleARB & prog); void createTexture(LLPointer& texture, unsigned int width, unsigned int height); - void copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height); + void copyFrameBuffer(LLGLuint texture, unsigned int width, unsigned int height); void createNoiseTexture(LLPointer& texture); bool checkError(void); void checkShaderError(GLhandleARB shader); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 1286e91e4..810d9fa2c 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -385,6 +385,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (error != GL_NO_ERROR) { LL_WARNS("ShaderLoading") << "GL ERROR in glShaderSourceARB: " << error << LL_ENDL; + glDeleteObjectARB(ret); //no longer need handle } else { @@ -394,6 +395,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (error != GL_NO_ERROR) { LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShaderARB: " << error << LL_ENDL; + glDeleteObjectARB(ret); //no longer need handle } } } @@ -413,6 +415,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade //an error occured, print log LL_WARNS("ShaderLoading") << "GLSL Compilation Error: (" << error << ") in " << filename << LL_ENDL; dumpObjectLog(ret); + glDeleteObjectARB(ret); //no longer need handle ret = 0; } } diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 2488c7ab0..02f5842a1 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -71,6 +71,9 @@ protected: // our parameter manager singleton instance static LLShaderMgr * sInstance; +public: + static void unloadShaderClass(int shader_class); + static std::vector &getGlobalShaderList(); //Holds a list of ALL LLGLSLShader objects. }; //LLShaderMgr #endif diff --git a/indra/lscript/lscript_library/lscript_library.cpp b/indra/lscript/lscript_library/lscript_library.cpp index 9935d99c8..fcfbbffa8 100644 --- a/indra/lscript/lscript_library/lscript_library.cpp +++ b/indra/lscript/lscript_library/lscript_library.cpp @@ -457,6 +457,15 @@ void LLScriptLibrary::init() addFunction(10.f, 0.f, dummy_func, "llGetLinkPrimitiveParams", NULL, "il"); addFunction(10.f, 0.f, dummy_func, "llLinkParticleSystem", NULL, "il"); addFunction(10.f, 0.f, dummy_func, "llSetLinkTextureAnim", NULL, "iiiiifff"); + + addFunction(10.f, 0.f, dummy_func, "llGetLinkNumberOfSides", "i", "i"); + + // IDEVO Name lookup calls, see lscript_avatar_names.h + addFunction(10.f, 0.f, dummy_func, "llGetUsername", "s", "k"); + addFunction(10.f, 0.f, dummy_func, "llRequestUsername", "k", "k"); + addFunction(10.f, 0.f, dummy_func, "llGetDisplayName", "s", "k"); + addFunction(10.f, 0.f, dummy_func, "llRequestDisplayName", "k", "k"); + // energy, sleep, dummy_func, name, return type, parameters, gods-only // IF YOU ADD NEW SCRIPT CALLS, YOU MUST PUT THEM AT THE END OF THIS LIST. diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl index 27c09db92..3f60d4a71 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl @@ -10,6 +10,7 @@ uniform sampler2D diffuseMap; void main() { - gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy)); + //gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy)); //This should not compile! + gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a); } diff --git a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl index 21c7ad765..f81867be6 100644 --- a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl @@ -8,24 +8,20 @@ uniform sampler2D diffuseMap; uniform float glowStrength; +float kern[4] = float[4](.25,.5,.8,1.0); //Initialize the correct (non nVidia cg) way void main() { vec4 col = vec4(0.0, 0.0, 0.0, 0.0); - // ATI compiler falls down on array initialization. - float kern[8]; - kern[0] = 0.25; kern[1] = 0.5; kern[2] = 0.8; kern[3] = 1.0; - kern[4] = 1.0; kern[5] = 0.8; kern[6] = 0.5; kern[7] = 0.25; - col += kern[0] * texture2D(diffuseMap, gl_TexCoord[0].xy); col += kern[1] * texture2D(diffuseMap, gl_TexCoord[1].xy); col += kern[2] * texture2D(diffuseMap, gl_TexCoord[2].xy); col += kern[3] * texture2D(diffuseMap, gl_TexCoord[3].xy); - col += kern[4] * texture2D(diffuseMap, gl_TexCoord[0].zw); - col += kern[5] * texture2D(diffuseMap, gl_TexCoord[1].zw); - col += kern[6] * texture2D(diffuseMap, gl_TexCoord[2].zw); - col += kern[7] * texture2D(diffuseMap, gl_TexCoord[3].zw); + col += kern[3] * texture2D(diffuseMap, gl_TexCoord[0].zw); + col += kern[2] * texture2D(diffuseMap, gl_TexCoord[1].zw); + col += kern[1] * texture2D(diffuseMap, gl_TexCoord[2].zw); + col += kern[0] * texture2D(diffuseMap, gl_TexCoord[3].zw); gl_FragColor = vec4(col.rgb * glowStrength, col.a); } diff --git a/indra/newview/app_settings/shaders/class2/effects/blurF.glsl b/indra/newview/app_settings/shaders/class2/effects/blurF.glsl index 94433202a..7db969ef0 100644 --- a/indra/newview/app_settings/shaders/class2/effects/blurF.glsl +++ b/indra/newview/app_settings/shaders/class2/effects/blurF.glsl @@ -9,21 +9,18 @@ uniform sampler2DRect RenderTexture; uniform float bloomStrength; varying vec4 gl_TexCoord[gl_MaxTextureCoords]; + +float blurWeights[4] = float[4](.05,.1,.2,.3); + void main(void) { - float blurWeights[7]; - blurWeights[0] = 0.05; - blurWeights[1] = 0.1; - blurWeights[2] = 0.2; - blurWeights[3] = 0.3; - blurWeights[4] = 0.2; - blurWeights[5] = 0.1; - blurWeights[6] = 0.05; - - vec3 color = vec3(0,0,0); - for (int i = 0; i < 7; i++){ - color += vec3(texture2DRect(RenderTexture, gl_TexCoord[i].st)) * blurWeights[i]; - } + vec3 color = blurWeights[0] * texture2DRect(RenderTexture, gl_TexCoord[0].st).rgb; + color+= blurWeights[1] * texture2DRect(RenderTexture, gl_TexCoord[1].st).rgb; + color+= blurWeights[2] * texture2DRect(RenderTexture, gl_TexCoord[2].st).rgb; + color+= blurWeights[3] * texture2DRect(RenderTexture, gl_TexCoord[3].st).rgb; + color+= blurWeights[2] * texture2DRect(RenderTexture, gl_TexCoord[4].st).rgb; + color+= blurWeights[1] * texture2DRect(RenderTexture, gl_TexCoord[5].st).rgb; + color+= blurWeights[0] * texture2DRect(RenderTexture, gl_TexCoord[6].st).rgb; color *= bloomStrength; diff --git a/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl b/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl index 623ef7a81..4d5bf2538 100644 --- a/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl +++ b/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl @@ -12,12 +12,15 @@ uniform vec3 contrastBase; uniform float saturation; uniform vec3 lumWeights; -const float gamma = 2.0; +uniform float gamma; void main(void) { vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); + /// Apply gamma + color = pow(color, vec3(1.0/gamma)); + /// Modulate brightness color *= brightness; diff --git a/indra/newview/app_settings/shaders/class2/effects/gaussBlurF.glsl b/indra/newview/app_settings/shaders/class2/effects/gaussBlurF.glsl new file mode 100644 index 000000000..47c9f875b --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/effects/gaussBlurF.glsl @@ -0,0 +1,28 @@ +uniform sampler2DRect RenderTexture; +uniform int horizontalPass; + +uniform float offset[2] = float[2]( 1.3846153846, 3.2307692308 ); +uniform float weight[3] = float[3]( 0.2270270270, 0.3162162162, 0.0702702703 ); + +void main(void) +{ + vec4 color = texture2DRect(RenderTexture, gl_TexCoord[0].st)*weight[0]; + + + if(horizontalPass == 1) + { + color += weight[1] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x+offset[0],gl_TexCoord[0].y)); + color += weight[1] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x-offset[0],gl_TexCoord[0].y)); + color += weight[2] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x+offset[1],gl_TexCoord[0].y)); + color += weight[2] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x-offset[1],gl_TexCoord[0].y)); + + } + else + { + color += weight[1] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x,gl_TexCoord[0].y+offset[0])); + color += weight[1] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x,gl_TexCoord[0].y-offset[0])); + color += weight[2] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x,gl_TexCoord[0].y+offset[1])); + color += weight[2] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x,gl_TexCoord[0].y-offset[1])); + } + gl_FragColor = color; +} \ No newline at end of file diff --git a/indra/newview/app_settings/windlight/postprocesseffects.xml b/indra/newview/app_settings/windlight/postprocesseffects.xml index aeafc5641..2ce7d7c44 100644 --- a/indra/newview/app_settings/windlight/postprocesseffects.xml +++ b/indra/newview/app_settings/windlight/postprocesseffects.xml @@ -151,6 +151,8 @@ 1.5 bloom_width 2.25 + gamma + 1.0 brightness 1 brightness_multiplier @@ -170,6 +172,10 @@ 0 enable_night_vision 0 + enable_gauss_blur + 0 + gauss_blur_passes + 2 extract_high 1 extract_low diff --git a/indra/newview/llfloaterpostprocess.cpp b/indra/newview/llfloaterpostprocess.cpp index de9b598b1..6c3f77d3c 100644 --- a/indra/newview/llfloaterpostprocess.cpp +++ b/indra/newview/llfloaterpostprocess.cpp @@ -53,7 +53,7 @@ LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater(std::string("Post-Proce /// Color Filter Callbacks childSetCommitCallback("ColorFilterToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_color_filter"); - //childSetCommitCallback("ColorFilterGamma", &LLFloaterPostProcess::onFloatControlMoved, &(gPostProcess->tweaks.gamma())); + childSetCommitCallback("ColorFilterGamma", &LLFloaterPostProcess::onFloatControlMoved, (char*)"gamma"); childSetCommitCallback("ColorFilterBrightness", &LLFloaterPostProcess::onFloatControlMoved, (char*)"brightness"); childSetCommitCallback("ColorFilterSaturation", &LLFloaterPostProcess::onFloatControlMoved, (char*)"saturation"); childSetCommitCallback("ColorFilterContrast", &LLFloaterPostProcess::onFloatControlMoved, (char*)"contrast"); @@ -75,6 +75,10 @@ LLFloaterPostProcess::LLFloaterPostProcess() : LLFloater(std::string("Post-Proce childSetCommitCallback("BloomSize", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_width"); childSetCommitCallback("BloomStrength", &LLFloaterPostProcess::onFloatControlMoved, (char*)"bloom_strength"); + // Gauss Blur Callbacks + childSetCommitCallback("GaussBlurToggle", &LLFloaterPostProcess::onBoolToggle, (char*)"enable_gauss_blur"); + childSetCommitCallback("GaussBlurPasses", &LLFloaterPostProcess::onFloatControlMoved, (char*)"gauss_blur_passes"); + // Effect loading and saving. LLComboBox* comboBox = getChild("PPEffectsCombo"); childSetAction("PPLoadEffect", &LLFloaterPostProcess::onLoadEffect, comboBox); @@ -248,7 +252,7 @@ void LLFloaterPostProcess::syncMenu() /// Sync Color Filter Menu childSetValue("ColorFilterToggle", gPostProcess->tweaks.useColorFilter()); - //childSetValue("ColorFilterGamma", gPostProcess->tweaks.gamma()); + childSetValue("ColorFilterGamma", gPostProcess->tweaks.getGamma()); childSetValue("ColorFilterBrightness", gPostProcess->tweaks.brightness()); childSetValue("ColorFilterSaturation", gPostProcess->tweaks.saturation()); childSetValue("ColorFilterContrast", gPostProcess->tweaks.contrast()); @@ -268,4 +272,7 @@ void LLFloaterPostProcess::syncMenu() childSetValue("BloomExtract", gPostProcess->tweaks.extractLow()); childSetValue("BloomSize", gPostProcess->tweaks.bloomWidth()); childSetValue("BloomStrength", gPostProcess->tweaks.bloomStrength()); + + childSetValue("GaussBlurToggle", gPostProcess->tweaks.useGaussBlurFilter()); + childSetValue("GaussBlurPasses", gPostProcess->tweaks.getGaussBlurPasses()); } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index d293f32c5..0ac158db4 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1004,7 +1004,18 @@ bool idle_startup() { gDirUtilp->setChatLogsDir(gSavedPerAccountSettings.getString("InstantMessageLogPath")); } - + + //Get these logs out of my newview root directory, PLEASE. + if (gHippoGridManager->getCurrentGrid()->isSecondLife()) + { + gDirUtilp->setPerAccountChatLogsDir(LLStringUtil::null, + gSavedSettings.getString("FirstName"), gSavedSettings.getString("LastName") ); + } + else + { + gDirUtilp->setPerAccountChatLogsDir(gHippoGridManager->getCurrentGridNick(), + gSavedSettings.getString("FirstName"), gSavedSettings.getString("LastName") ); + } LLFile::mkdir(gDirUtilp->getChatLogsDir()); LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir()); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 09aef8a22..82fe8afd3 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -914,12 +914,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gPipeline.mScreen.flush(); } } - - /// We copy the frame buffer straight into a texture here, - /// and then display it again with compositor effects. - /// Using render to texture would be faster/better, but I don't have a - /// grasp of their full display stack just yet. - // gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) { @@ -933,7 +927,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { gFrameStats.start(LLFrameStats::RENDER_UI); render_ui(); - } + } LLSpatialGroup::sNoDelete = FALSE; } @@ -1131,8 +1125,14 @@ void render_ui(F32 zoom_factor, int subfield) if (to_texture) { gPipeline.renderBloom(gSnapshot, zoom_factor, subfield); + gPipeline.mScreen.flush(); //blit, etc. } - + /// We copy the frame buffer straight into a texture here, + /// and then display it again with compositor effects. + /// Using render to texture would be faster/better, but I don't have a + /// grasp of their full display stack just yet. + gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); + render_hud_elements(); render_hud_attachments(); } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index b5bd2f93a..69a98970d 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -67,98 +67,72 @@ BOOL LLViewerShaderMgr::sInitialized = FALSE; LLVector4 gShinyOrigin; -//object shaders -LLGLSLShader gObjectSimpleProgram; -LLGLSLShader gObjectSimpleWaterProgram; -LLGLSLShader gObjectFullbrightProgram; -LLGLSLShader gObjectFullbrightWaterProgram; + // WindLight shader handles + // Make sure WL Sky is the first program +LLGLSLShader gWLSkyProgram(LLViewerShaderMgr::SHADER_WINDLIGHT); +LLGLSLShader gWLCloudProgram(LLViewerShaderMgr::SHADER_WINDLIGHT); -LLGLSLShader gObjectFullbrightShinyProgram; -LLGLSLShader gObjectShinyProgram; -LLGLSLShader gObjectShinyWaterProgram; - -//environment shaders -LLGLSLShader gTerrainProgram; -LLGLSLShader gTerrainWaterProgram; -LLGLSLShader gWaterProgram; -LLGLSLShader gUnderWaterProgram; - -//interface shaders -LLGLSLShader gHighlightProgram; - -//avatar shader handles -LLGLSLShader gAvatarProgram; -LLGLSLShader gAvatarWaterProgram; -LLGLSLShader gAvatarEyeballProgram; -LLGLSLShader gAvatarPickProgram; - -// WindLight shader handles -LLGLSLShader gWLSkyProgram; -LLGLSLShader gWLCloudProgram; - -// Effects Shaders -LLGLSLShader gGlowProgram; -LLGLSLShader gGlowExtractProgram; -LLGLSLShader gPostColorFilterProgram; -LLGLSLShader gPostNightVisionProgram; - -// Deferred rendering shaders -LLGLSLShader gDeferredImpostorProgram; -LLGLSLShader gDeferredWaterProgram; -LLGLSLShader gDeferredDiffuseProgram; -LLGLSLShader gDeferredBumpProgram; -LLGLSLShader gDeferredTerrainProgram; -LLGLSLShader gDeferredTreeProgram; -LLGLSLShader gDeferredAvatarProgram; -LLGLSLShader gDeferredAvatarAlphaProgram; -LLGLSLShader gDeferredLightProgram; -LLGLSLShader gDeferredMultiLightProgram; -LLGLSLShader gDeferredSunProgram; -LLGLSLShader gDeferredBlurLightProgram; -LLGLSLShader gDeferredSoftenProgram; -LLGLSLShader gDeferredShadowProgram; -LLGLSLShader gDeferredAvatarShadowProgram; -LLGLSLShader gDeferredAlphaProgram; -LLGLSLShader gDeferredFullbrightProgram; + //object shaders +LLGLSLShader gObjectSimpleProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectSimpleWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectFullbrightProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectFullbrightWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); + +LLGLSLShader gObjectFullbrightShinyProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectShinyProgram(LLViewerShaderMgr::SHADER_OBJECT); +LLGLSLShader gObjectShinyWaterProgram(LLViewerShaderMgr::SHADER_OBJECT); + + //environment shaders +LLGLSLShader gTerrainProgram(LLViewerShaderMgr::SHADER_ENVIRONMENT); +LLGLSLShader gTerrainWaterProgram(LLViewerShaderMgr::SHADER_WATER); //note, water. +LLGLSLShader gWaterProgram(LLViewerShaderMgr::SHADER_WATER); +LLGLSLShader gUnderWaterProgram(LLViewerShaderMgr::SHADER_WATER); + + //interface shaders +LLGLSLShader gHighlightProgram(LLViewerShaderMgr::SHADER_INTERFACE); //Not in mShaderList + + //avatar shader handles +LLGLSLShader gAvatarProgram(LLViewerShaderMgr::SHADER_AVATAR); +LLGLSLShader gAvatarWaterProgram(LLViewerShaderMgr::SHADER_AVATAR); +LLGLSLShader gAvatarEyeballProgram(LLViewerShaderMgr::SHADER_AVATAR); +LLGLSLShader gAvatarPickProgram(LLViewerShaderMgr::SHADER_AVATAR); //Not in mShaderList + + // Effects Shaders +LLGLSLShader gGlowProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList +LLGLSLShader gGlowExtractProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList +LLGLSLShader gPostColorFilterProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList +LLGLSLShader gPostNightVisionProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList +LLGLSLShader gPostGaussianBlurProgram(LLViewerShaderMgr::SHADER_EFFECT); //Not in mShaderList + + // Deferred rendering shaders +LLGLSLShader gDeferredImpostorProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredWaterProgram(LLViewerShaderMgr::SHADER_DEFERRED); //calculatesAtmospherics +LLGLSLShader gDeferredDiffuseProgram(LLViewerShaderMgr::SHADER_DEFERRED);//Not in mShaderList +LLGLSLShader gDeferredBumpProgram(LLViewerShaderMgr::SHADER_DEFERRED); //Not in mShaderList +LLGLSLShader gDeferredTerrainProgram(LLViewerShaderMgr::SHADER_DEFERRED);//Not in mShaderList +LLGLSLShader gDeferredTreeProgram(LLViewerShaderMgr::SHADER_DEFERRED); //Not in mShaderList +LLGLSLShader gDeferredAvatarProgram(LLViewerShaderMgr::SHADER_DEFERRED); //Not in mShaderList +LLGLSLShader gDeferredAvatarAlphaProgram(LLViewerShaderMgr::SHADER_DEFERRED); //calculatesAtmospherics +LLGLSLShader gDeferredLightProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredMultiLightProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredSunProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredBlurLightProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredSoftenProgram(LLViewerShaderMgr::SHADER_DEFERRED); +LLGLSLShader gDeferredShadowProgram(LLViewerShaderMgr::SHADER_DEFERRED); //Not in mShaderList +LLGLSLShader gDeferredAvatarShadowProgram(LLViewerShaderMgr::SHADER_DEFERRED);//Not in mShaderList +LLGLSLShader gDeferredAlphaProgram(LLViewerShaderMgr::SHADER_DEFERRED); //calculatesAtmospherics +LLGLSLShader gDeferredFullbrightProgram(LLViewerShaderMgr::SHADER_DEFERRED); //calculatesAtmospherics //current avatar shader parameter pointer GLint gAvatarMatrixParam; LLViewerShaderMgr::LLViewerShaderMgr() : mVertexShaderLevel(SHADER_COUNT, 0) -{ - /// Make sure WL Sky is the first program - mShaderList.push_back(&gWLSkyProgram); - mShaderList.push_back(&gWLCloudProgram); - mShaderList.push_back(&gAvatarProgram); - mShaderList.push_back(&gObjectShinyProgram); - mShaderList.push_back(&gWaterProgram); - mShaderList.push_back(&gAvatarEyeballProgram); - mShaderList.push_back(&gObjectSimpleProgram); - mShaderList.push_back(&gObjectFullbrightProgram); - mShaderList.push_back(&gObjectFullbrightShinyProgram); - mShaderList.push_back(&gTerrainProgram); - mShaderList.push_back(&gTerrainWaterProgram); - mShaderList.push_back(&gObjectSimpleWaterProgram); - mShaderList.push_back(&gObjectFullbrightWaterProgram); - mShaderList.push_back(&gAvatarWaterProgram); - mShaderList.push_back(&gObjectShinyWaterProgram); - 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(&gDeferredFullbrightProgram); - mShaderList.push_back(&gDeferredWaterProgram); - mShaderList.push_back(&gDeferredAvatarAlphaProgram); -} +{} LLViewerShaderMgr::~LLViewerShaderMgr() { mVertexShaderLevel.clear(); - mShaderList.clear(); } // static @@ -283,8 +257,6 @@ void LLViewerShaderMgr::setShaders() { return; } - // Make sure the compiled shader map is cleared before we recompile shaders. - mShaderObjects.clear(); initAttribsAndUniforms(); gPipeline.releaseGLBuffers(); @@ -378,12 +350,7 @@ void LLViewerShaderMgr::setShaders() loadShadersWindLight(); loadShadersEffects(); loadShadersInterface(); - - // Load max avatar shaders to set the max level - mVertexShaderLevel[SHADER_AVATAR] = 3; - mMaxAvatarShaderLevel = 3; - loadShadersAvatar(); - + #if 0 && LL_DARWIN // force avatar shaders off for mac mVertexShaderLevel[SHADER_AVATAR] = 0; sMaxAvatarShaderLevel = 0; @@ -436,28 +403,24 @@ void LLViewerShaderMgr::setShaders() { gPipeline.mVertexShadersEnabled = FALSE; gPipeline.mVertexShadersLoaded = 0; - mVertexShaderLevel[SHADER_LIGHTING] = 0; - mVertexShaderLevel[SHADER_INTERFACE] = 0; - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - mVertexShaderLevel[SHADER_WATER] = 0; - mVertexShaderLevel[SHADER_OBJECT] = 0; - mVertexShaderLevel[SHADER_EFFECT] = 0; - mVertexShaderLevel[SHADER_WINDLIGHT] = 0; - mVertexShaderLevel[SHADER_AVATAR] = 0; + for (S32 i = 0; i < SHADER_COUNT; i++) + mVertexShaderLevel[i] = 0; } + + //Flag base shader objects for deletion + //Don't worry-- they won't be deleted until no programs refrence them. + std::map::iterator it = mShaderObjects.begin(); + for(it;it!=mShaderObjects.end();++it) + if(it->second) + glDeleteObjectARB(it->second); + mShaderObjects.clear(); } else { gPipeline.mVertexShadersEnabled = FALSE; gPipeline.mVertexShadersLoaded = 0; - mVertexShaderLevel[SHADER_LIGHTING] = 0; - mVertexShaderLevel[SHADER_INTERFACE] = 0; - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - mVertexShaderLevel[SHADER_WATER] = 0; - mVertexShaderLevel[SHADER_OBJECT] = 0; - mVertexShaderLevel[SHADER_EFFECT] = 0; - mVertexShaderLevel[SHADER_WINDLIGHT] = 0; - mVertexShaderLevel[SHADER_AVATAR] = 0; + for (S32 i = 0; i < SHADER_COUNT; i++) + mVertexShaderLevel[i] = 0; } if (gViewerWindow) @@ -469,42 +432,14 @@ void LLViewerShaderMgr::setShaders() void LLViewerShaderMgr::unloadShaders() { - gObjectSimpleProgram.unload(); - gObjectSimpleWaterProgram.unload(); - gObjectFullbrightProgram.unload(); - gObjectFullbrightWaterProgram.unload(); + //Instead of manually unloading, shaders are now automatically accumulated in a list. + //Simply iterate and unload. + std::vector &shader_list = LLShaderMgr::getGlobalShaderList(); + for(std::vector::iterator it=shader_list.begin();it!=shader_list.end();++it) + (*it)->unload(); - gObjectShinyProgram.unload(); - gObjectFullbrightShinyProgram.unload(); - gObjectShinyWaterProgram.unload(); - gWaterProgram.unload(); - gUnderWaterProgram.unload(); - gTerrainProgram.unload(); - gTerrainWaterProgram.unload(); - gGlowProgram.unload(); - gGlowExtractProgram.unload(); - gAvatarProgram.unload(); - gAvatarWaterProgram.unload(); - gAvatarEyeballProgram.unload(); - gAvatarPickProgram.unload(); - gHighlightProgram.unload(); - - gWLSkyProgram.unload(); - gWLCloudProgram.unload(); - - gPostColorFilterProgram.unload(); - gPostNightVisionProgram.unload(); - - gDeferredDiffuseProgram.unload(); - - mVertexShaderLevel[SHADER_LIGHTING] = 0; - mVertexShaderLevel[SHADER_OBJECT] = 0; - mVertexShaderLevel[SHADER_AVATAR] = 0; - mVertexShaderLevel[SHADER_ENVIRONMENT] = 0; - mVertexShaderLevel[SHADER_WATER] = 0; - mVertexShaderLevel[SHADER_INTERFACE] = 0; - mVertexShaderLevel[SHADER_EFFECT] = 0; - mVertexShaderLevel[SHADER_WINDLIGHT] = 0; + for (S32 i = 0; i < SHADER_COUNT; i++) + mVertexShaderLevel[i] = 0; gPipeline.mVertexShadersLoaded = 0; } @@ -601,7 +536,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() if (mVertexShaderLevel[SHADER_ENVIRONMENT] == 0) { - gTerrainProgram.unload(); + unloadShaderClass(SHADER_ENVIRONMENT); return FALSE; } @@ -637,9 +572,7 @@ BOOL LLViewerShaderMgr::loadShadersWater() if (mVertexShaderLevel[SHADER_WATER] == 0) { - gWaterProgram.unload(); - gUnderWaterProgram.unload(); - gTerrainWaterProgram.unload(); + unloadShaderClass(SHADER_WATER); return FALSE; } @@ -719,47 +652,41 @@ BOOL LLViewerShaderMgr::loadShadersEffects() if (mVertexShaderLevel[SHADER_EFFECT] == 0) { - gGlowProgram.unload(); - gGlowExtractProgram.unload(); - gPostColorFilterProgram.unload(); - gPostNightVisionProgram.unload(); + unloadShaderClass(SHADER_EFFECT); return FALSE; } - if (success) + if(LLPipeline::sRenderGlow) { - gGlowProgram.mName = "Glow Shader (Post)"; - gGlowProgram.mShaderFiles.clear(); - gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowV.glsl", GL_VERTEX_SHADER_ARB)); - gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowF.glsl", GL_FRAGMENT_SHADER_ARB)); - gGlowProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; - success = gGlowProgram.createShader(NULL, &mGlowUniforms); - if (!success) + if (success) { - LLPipeline::sRenderGlow = FALSE; + gGlowProgram.mName = "Glow Shader (Post)"; + gGlowProgram.mShaderFiles.clear(); + gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowV.glsl", GL_VERTEX_SHADER_ARB)); + gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowF.glsl", GL_FRAGMENT_SHADER_ARB)); + gGlowProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; + success = gGlowProgram.createShader(NULL, &mGlowUniforms); + LLPipeline::sRenderGlow = success; + } + + if (success) + { + gGlowExtractProgram.mName = "Glow Extract Shader (Post)"; + gGlowExtractProgram.mShaderFiles.clear(); + gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractV.glsl", GL_VERTEX_SHADER_ARB)); + gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractF.glsl", GL_FRAGMENT_SHADER_ARB)); + gGlowExtractProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; + success = gGlowExtractProgram.createShader(NULL, &mGlowExtractUniforms); + LLPipeline::sRenderGlow = success; } } - if (success) - { - gGlowExtractProgram.mName = "Glow Extract Shader (Post)"; - gGlowExtractProgram.mShaderFiles.clear(); - gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractV.glsl", GL_VERTEX_SHADER_ARB)); - gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractF.glsl", GL_FRAGMENT_SHADER_ARB)); - gGlowExtractProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; - success = gGlowExtractProgram.createShader(NULL, &mGlowExtractUniforms); - if (!success) - { - LLPipeline::sRenderGlow = FALSE; - } - } - -#if 0 +#if 1 // disabling loading of postprocess shaders until we fix // ATI sampler2DRect compatibility. //load Color Filter Shader - if (success) + //if (success) { vector shaderUniforms; shaderUniforms.reserve(7); @@ -776,11 +703,11 @@ BOOL LLViewerShaderMgr::loadShadersEffects() gPostColorFilterProgram.mShaderFiles.push_back(make_pair("effects/colorFilterF.glsl", GL_FRAGMENT_SHADER_ARB)); gPostColorFilterProgram.mShaderFiles.push_back(make_pair("effects/drawQuadV.glsl", GL_VERTEX_SHADER_ARB)); gPostColorFilterProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; - success = gPostColorFilterProgram.createShader(NULL, &shaderUniforms); + /*success = */gPostColorFilterProgram.createShader(NULL, &shaderUniforms); } //load Night Vision Shader - if (success) + //if (success) { vector shaderUniforms; shaderUniforms.reserve(5); @@ -795,8 +722,25 @@ BOOL LLViewerShaderMgr::loadShadersEffects() gPostNightVisionProgram.mShaderFiles.push_back(make_pair("effects/nightVisionF.glsl", GL_FRAGMENT_SHADER_ARB)); gPostNightVisionProgram.mShaderFiles.push_back(make_pair("effects/drawQuadV.glsl", GL_VERTEX_SHADER_ARB)); gPostNightVisionProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; - success = gPostNightVisionProgram.createShader(NULL, &shaderUniforms); + /*success = */gPostNightVisionProgram.createShader(NULL, &shaderUniforms); } + + //if (success) + { + vector shaderUniforms; + shaderUniforms.reserve(2); + shaderUniforms.push_back("RenderTexture"); + shaderUniforms.push_back("horizontalPass"); + + gPostGaussianBlurProgram.mName = "Gaussian Blur Shader (Post)"; + gPostGaussianBlurProgram.mShaderFiles.clear(); + gPostGaussianBlurProgram.mShaderFiles.push_back(make_pair("effects/gaussBlurF.glsl", GL_FRAGMENT_SHADER_ARB)); + gPostGaussianBlurProgram.mShaderFiles.push_back(make_pair("effects/drawQuadV.glsl", GL_VERTEX_SHADER_ARB)); + gPostGaussianBlurProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT]; + /*success = */gPostGaussianBlurProgram.createShader(NULL, &shaderUniforms); + } + + #endif return success; @@ -807,23 +751,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { if (mVertexShaderLevel[SHADER_DEFERRED] == 0) { - gDeferredTreeProgram.unload(); - gDeferredDiffuseProgram.unload(); - gDeferredBumpProgram.unload(); - gDeferredImpostorProgram.unload(); - gDeferredTerrainProgram.unload(); - gDeferredLightProgram.unload(); - gDeferredMultiLightProgram.unload(); - gDeferredSunProgram.unload(); - gDeferredBlurLightProgram.unload(); - gDeferredSoftenProgram.unload(); - gDeferredShadowProgram.unload(); - gDeferredAvatarShadowProgram.unload(); - gDeferredAvatarProgram.unload(); - gDeferredAvatarAlphaProgram.unload(); - gDeferredAlphaProgram.unload(); - gDeferredFullbrightProgram.unload(); - gDeferredWaterProgram.unload(); + unloadShaderClass(SHADER_DEFERRED); return FALSE; } @@ -1031,13 +959,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() if (mVertexShaderLevel[SHADER_OBJECT] == 0) { - gObjectShinyProgram.unload(); - gObjectFullbrightShinyProgram.unload(); - gObjectShinyWaterProgram.unload(); - gObjectSimpleProgram.unload(); - gObjectSimpleWaterProgram.unload(); - gObjectFullbrightProgram.unload(); - gObjectFullbrightWaterProgram.unload(); + unloadShaderClass(SHADER_OBJECT); return FALSE; } @@ -1163,10 +1085,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar() if (mVertexShaderLevel[SHADER_AVATAR] == 0) { - gAvatarProgram.unload(); - gAvatarWaterProgram.unload(); - gAvatarEyeballProgram.unload(); - gAvatarPickProgram.unload(); + unloadShaderClass(SHADER_AVATAR); return FALSE; } @@ -1253,7 +1172,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface() if (mVertexShaderLevel[SHADER_INTERFACE] == 0) { - gHighlightProgram.unload(); + unloadShaderClass(SHADER_INTERFACE); return FALSE; } @@ -1282,8 +1201,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() if (mVertexShaderLevel[SHADER_WINDLIGHT] < 2) { - gWLSkyProgram.unload(); - gWLCloudProgram.unload(); + unloadShaderClass(SHADER_WINDLIGHT); return FALSE; } @@ -1324,3 +1242,18 @@ void LLViewerShaderMgr::updateShaderUniforms(LLGLSLShader * shader) LLWLParamManager::instance()->updateShaderUniforms(shader); LLWaterParamManager::instance()->updateShaderUniforms(shader); } + +/*static*/ void LLShaderMgr::unloadShaderClass(int shader_class) +{ + std::vector &shader_list = getGlobalShaderList(); + for(std::vector::iterator it=shader_list.begin();it!=shader_list.end();++it) + { + if((*it)->mShaderClass == shader_class) + (*it)->unload(); + } +} +/*static*/ std::vector &LLShaderMgr::getGlobalShaderList() +{ + static std::vector sGlbShaderLst; + return sGlbShaderLst; +} diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index a743966d9..2b0e15051 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -227,12 +227,14 @@ public: shader_iter beginShaders() const { - return mShaderList.begin(); + return getGlobalShaderList().begin(); + //return mShaderList.begin(); } shader_iter endShaders() const { - return mShaderList.end(); + return getGlobalShaderList().end(); + //return mShaderList.end(); } @@ -263,8 +265,10 @@ private: std::vector mAvatarUniforms; // the list of shaders we need to propagate parameters to. - std::vector mShaderList; - + // Currently this is replaced with a global list of all shaders + // which isn't quite as efficient. However, if other changes prove + // stable then I will mimic mShaderList on a per-ParamManager basis. + //std::vector mShaderList; }; //LLViewerShaderMgr inline bool operator == (LLViewerShaderMgr::shader_iter const & a, LLViewerShaderMgr::shader_iter const & b) @@ -316,6 +320,7 @@ extern LLGLSLShader gWLCloudProgram; // Post Process Shaders extern LLGLSLShader gPostColorFilterProgram; extern LLGLSLShader gPostNightVisionProgram; +extern LLGLSLShader gPostGaussianBlurProgram; // Deferred rendering shaders extern LLGLSLShader gDeferredImpostorProgram; diff --git a/indra/newview/skins/default/xui/en-us/floater_post_process.xml b/indra/newview/skins/default/xui/en-us/floater_post_process.xml index 31691a85d..d110c1d62 100644 --- a/indra/newview/skins/default/xui/en-us/floater_post_process.xml +++ b/indra/newview/skins/default/xui/en-us/floater_post_process.xml @@ -8,157 +8,188 @@ width="400"> - + - + - Brightness - - + + Brightness + + + Saturation - + name="ColorFilterSaturation" show_text="true" value="1.0" width="200" /> Contrast - Contrast Base Color - - - - - + + left="14" mouse_opaque="true" name="GaussBlurToggle" width="200" /> + Passes to apply + + + + + + Light Amplification Multiple - + name="NightVisionBrightMult" show_text="true" value="0.7" width="200" /> Noise Size - Noise Strength - + name="NightVisionNoiseStrength" show_text="true" value="1.0" width="200" /> - + + left="14" mouse_opaque="true" name="BloomToggle" width="200" /> Luminosity Extraction - + left="10" mouse_opaque="true" name="BloomSizeText" v_pad="0" width="355"> Bloom Size - Bloom Strength - + + + + + integer llGetLinkNumberOfSides(integer link) + Returns the number of sides of the specified linked prim. + + + string llGetUsername(key id) + Returns the single-word username of an avatar, iff the avatar is in the current region, otherwise the empty string. + + + key llRequestUsername(key id) + Requests single-word username of an avatar. When data is available the dataserver event will be raised. + + + string llGetDisplayName(key id) + Returns the name of an avatar, iff the avatar is in the current simulator, and the name has been cached, otherwise the same as llGetUsername. Use llRequestDisplayName if you absolutely must have the display name. + + + key llRequestDisplayName(key id) + Requests name of an avatar. When data is available the dataserver event will be raised. + + diff --git a/install.xml b/install.xml index f829bdc26..c32f718f2 100644 --- a/install.xml +++ b/install.xml @@ -936,9 +936,12 @@ anguage Infrstructure (CLI) international standard windows md5sum - fa5041874761895a06a20782b8ba34a2 + b678c4d18ea8e4fab42b20f8d0b2629a + url - http://liny-odell.users.sourceforge.net/llqtwebkit-windows-qt4.6-20101122.tar.bz2 + http://viewer-source-downloads.s3.amazonaws.com/install_pkgs/llqtwebkit-windows-qt4.7.1-20101221.tar.bz2 + +