diff options
author | Dave Parks <davep@lindenlab.com> | 2011-09-20 00:54:37 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-09-20 00:54:37 -0500 |
commit | 9ea41c8094695365bc7ea10165ffd54cda204e88 (patch) | |
tree | e5a02d1c64b70181516d936da07a75fc9caefc7d /indra/newview | |
parent | 2ead1691317e9bf32e996fa1f6a70f6a2a9ced02 (diff) |
SH-2243 No deprecated calls for the whole session.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl | 47 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/interface/alphamaskV.glsl | 42 | ||||
-rw-r--r-- | indra/newview/lldynamictexture.cpp | 5 | ||||
-rwxr-xr-x | indra/newview/llfloatermodelpreview.cpp | 21 | ||||
-rw-r--r-- | indra/newview/llstartup.cpp | 5 | ||||
-rw-r--r-- | indra/newview/lltexlayer.cpp | 103 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.h | 3 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 33 |
9 files changed, 239 insertions, 33 deletions
diff --git a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl new file mode 100644 index 0000000000..433ecc9d2a --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl @@ -0,0 +1,47 @@ +/** + * @file alphamaskF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef gl_FragColor +out vec4 gl_FragColor; +#endif + +uniform sampler2D diffuseMap; + +uniform float minimum_alpha; +uniform float maximum_alpha; + +VARYING vec2 vary_texcoord0; +VARYING vec4 vertex_color; + +void main() +{ + vec4 col = vertex_color*texture2D(diffuseMap, vary_texcoord0.xy); + if (col.a < minimum_alpha || col.a > maximum_alpha) + { + discard; + } + + gl_FragColor = col; +} diff --git a/indra/newview/app_settings/shaders/class1/interface/alphamaskV.glsl b/indra/newview/app_settings/shaders/class1/interface/alphamaskV.glsl new file mode 100644 index 0000000000..3580d1f27b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/alphamaskV.glsl @@ -0,0 +1,42 @@ +/** + * @file alphamaskV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 texture_matrix0; +uniform mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position, 1); + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + vertex_color = diffuse_color; +} + diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp index 6f9ff6c210..5d6081a35c 100644 --- a/indra/newview/lldynamictexture.cpp +++ b/indra/newview/lldynamictexture.cpp @@ -211,9 +211,6 @@ BOOL LLViewerDynamicTexture::updateAllInstances() LLGLSLShader::bindNoShader(); LLVertexBuffer::unbind(); - bool no_ff = LLGLSLShader::sNoFixedFunction; - LLGLSLShader::sNoFixedFunction = false; - BOOL result = FALSE; BOOL ret = FALSE ; for( S32 order = 0; order < ORDER_COUNT; order++ ) @@ -244,8 +241,6 @@ BOOL LLViewerDynamicTexture::updateAllInstances() } } - LLGLSLShader::sNoFixedFunction = no_ff; - return ret; } diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 6412a573f5..4e06fb434a 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -102,6 +102,7 @@ #include "llviewerobjectlist.h" #include "llanimationstates.h" #include "llviewernetwork.h" +#include "llviewershadermgr.h" #include "glod/glod.h" #include <boost/algorithm/string.hpp> @@ -4729,6 +4730,8 @@ BOOL LLModelPreview::render() LLMutexLock lock(this); mNeedsUpdate = FALSE; + bool use_shaders = LLGLSLShader::sNoFixedFunction; + bool edges = mViewOption["show_edges"]; bool joint_positions = mViewOption["show_joint_positions"]; bool skin_weight = mViewOption["show_skin_weight"]; @@ -4745,6 +4748,10 @@ BOOL LLModelPreview::render() LLGLDisable fog(GL_FOG); { + if (use_shaders) + { + gUIProgram.bind(); + } //clear background to blue gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); @@ -4764,6 +4771,10 @@ BOOL LLModelPreview::render() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); + if (use_shaders) + { + gUIProgram.unbind(); + } } LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance; @@ -4895,6 +4906,11 @@ BOOL LLModelPreview::render() const U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0; + if (use_shaders) + { + gObjectPreviewProgram.bind(); + } + LLGLEnable normalize(GL_NORMALIZE); if (!mBaseModel.empty() && mVertexBuffer[5].empty()) @@ -5297,6 +5313,11 @@ BOOL LLModelPreview::render() } } + if (use_shaders) + { + gObjectPreviewProgram.unbind(); + } + gGL.popMatrix(); return TRUE; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 749acea6c1..11a4c96f14 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1919,11 +1919,6 @@ bool idle_startup() LLTrans::getString("LoginPrecaching"), gAgent.mMOTD); display_startup(); - if (!LLViewerShaderMgr::sInitialized) - { - LLViewerShaderMgr::sInitialized = TRUE; - LLViewerShaderMgr::instance()->setShaders(); - } } return TRUE; diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index e2c2b2ae21..9f5cbf6ec8 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -294,13 +294,17 @@ BOOL LLTexLayerSetBuffer::render() const BOOL update_now = mNeedsUpdate && isReadyToUpdate(); BOOL success = TRUE; + + bool use_shaders = LLGLSLShader::sNoFixedFunction; + + if (use_shaders) + { + gAlphaMaskProgram.bind(); + gAlphaMaskProgram.setAlphaRange(0.004f, 1.f); + } LLVertexBuffer::unbind(); - //hack to use fixed function when updating tex layer sets - bool no_ff = LLGLSLShader::sNoFixedFunction; - LLGLSLShader::sNoFixedFunction = false; - // Composite the color data LLGLSUIDefault gls_ui; success &= mTexLayerSet->render( mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight ); @@ -335,8 +339,12 @@ BOOL LLTexLayerSetBuffer::render() doUpdate(); } + if (use_shaders) + { + gAlphaMaskProgram.unbind(); + } + LLVertexBuffer::unbind(); - LLGLSLShader::sNoFixedFunction = no_ff; // reset GL state gGL.setColorMask(true, true); @@ -927,6 +935,8 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) } } + bool use_shaders = LLGLSLShader::sNoFixedFunction; + LLGLSUIDefault gls_ui; LLGLDepthTest gls_depth(GL_FALSE, GL_FALSE); gGL.setColorMask(true, true); @@ -935,12 +945,20 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) { gGL.flush(); LLGLDisable no_alpha(GL_ALPHA_TEST); + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.0f, 1.f); + } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.f, 0.f, 0.f, 1.f ); gl_rect_2d_simple( width, height ); gGL.flush(); + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.004f, 1.f); + } } if (mIsVisible) @@ -967,6 +985,11 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) gGL.setSceneBlendType(LLRender::BT_REPLACE); LLGLDisable no_alpha(GL_ALPHA_TEST); + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.f, 1.f); + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.f, 0.f, 0.f, 0.f ); @@ -974,7 +997,10 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) gGL.setSceneBlendType(LLRender::BT_ALPHA); gGL.flush(); - + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.004f, 1.f); + } } return success; @@ -1081,13 +1107,14 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, { const LLTexLayerSetInfo *info = getInfo(); + bool use_shaders = LLGLSLShader::sNoFixedFunction; + gGL.setColorMask(false, true); gGL.setSceneBlendType(LLRender::BT_REPLACE); // (Optionally) replace alpha with a single component image from a tga file. if (!info->mStaticAlphaFileName.empty()) { - LLGLSNoAlphaTest gls_no_alpha_test; gGL.flush(); { LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(info->mStaticAlphaFileName, TRUE); @@ -1106,12 +1133,20 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, // Set the alpha channel to one (clean up after previous blending) gGL.flush(); LLGLDisable no_alpha(GL_ALPHA_TEST); + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.f, 1.f); + } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.f, 0.f, 0.f, 1.f ); gl_rect_2d_simple( width, height ); gGL.flush(); + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.004f, 1.f); + } } // (Optional) Mask out part of the baked texture with alpha masks @@ -1596,6 +1631,8 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) LLGLEnable color_mat(GL_COLOR_MATERIAL); gPipeline.disableLights(); + bool use_shaders = LLGLSLShader::sNoFixedFunction; + LLColor4 net_color; BOOL color_specified = findNetColor(&net_color); @@ -1676,8 +1713,13 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) { if( tex ) { - LLGLDisable alpha_test(getInfo()->mWriteAllChannels ? GL_ALPHA_TEST : 0); - + bool no_alpha_test = getInfo()->mWriteAllChannels; + LLGLDisable alpha_test(no_alpha_test ? GL_ALPHA_TEST : 0); + if (use_shaders && no_alpha_test) + { + gAlphaMaskProgram.setAlphaRange(0.f, 1.f); + } + LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode(); gGL.getTexUnit(0)->bind(tex, TRUE); @@ -1687,6 +1729,11 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) gGL.getTexUnit(0)->setTextureAddressMode(old_mode); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + if (use_shaders && no_alpha_test) + { + gAlphaMaskProgram.setAlphaRange(0.004f, 1.f); + } + } } // else @@ -1719,9 +1766,17 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) color_specified ) { LLGLDisable no_alpha(GL_ALPHA_TEST); + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.f, 1.f); + } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( net_color.mV ); gl_rect_2d_simple( width, height ); + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.004f, 1.f); + } } if( alpha_mask_specified || getInfo()->mWriteAllChannels ) @@ -1809,15 +1864,25 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) gGL.flush(); + bool use_shaders = LLGLSLShader::sNoFixedFunction; + if( !getInfo()->mStaticImageFileName.empty() ) { LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture( getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask ); if( tex ) { LLGLSNoAlphaTest gls_no_alpha_test; + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.f, 1.f); + } gGL.getTexUnit(0)->bind(tex, TRUE); gl_rect_2d_simple_tex( width, height ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.004f, 1.f); + } } else { @@ -1832,10 +1897,18 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) if (tex) { LLGLSNoAlphaTest gls_no_alpha_test; + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.f, 1.f); + } gGL.getTexUnit(0)->bind(tex); gl_rect_2d_simple_tex( width, height ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); success = TRUE; + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.004f, 1.f); + } } } } @@ -1854,6 +1927,13 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC llassert( !mParamAlphaList.empty() ); + bool use_shaders = LLGLSLShader::sNoFixedFunction; + + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.f, 1.f); + } + gGL.setColorMask(false, true); LLTexLayerParamAlpha* first_param = *mParamAlphaList.begin(); @@ -1891,7 +1971,6 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC if( tex && (tex->getComponents() == 4) ) { LLGLSNoAlphaTest gls_no_alpha_test; - LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode(); gGL.getTexUnit(0)->bind(tex, TRUE); @@ -1930,6 +2009,10 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC gl_rect_2d_simple( width, height ); } + if (use_shaders) + { + gAlphaMaskProgram.setAlphaRange(0.004f, 1.f); + } LLGLSUIDefault gls_ui; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 7155311f8e..23351fc994 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -70,6 +70,7 @@ LLGLSLShader gGlowCombineFXAAProgram; LLGLSLShader gTwoTextureAddProgram; LLGLSLShader gOneTextureNoColorProgram; LLGLSLShader gDebugProgram; +LLGLSLShader gAlphaMaskProgram; //object shaders LLGLSLShader gObjectSimpleProgram; @@ -219,6 +220,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : 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); @@ -674,6 +676,7 @@ void LLViewerShaderMgr::unloadShaders() { gOcclusionProgram.unload(); gDebugProgram.unload(); + gAlphaMaskProgram.unload(); gUIProgram.unload(); gCustomAlphaProgram.unload(); gGlowCombineProgram.unload(); @@ -2747,6 +2750,16 @@ BOOL LLViewerShaderMgr::loadShadersInterface() success = gDebugProgram.createShader(NULL, NULL); } + if (success) + { + gAlphaMaskProgram.mName = "Alpha Mask Shader"; + gAlphaMaskProgram.mShaderFiles.clear(); + gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskV.glsl", GL_VERTEX_SHADER_ARB)); + gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskF.glsl", GL_FRAGMENT_SHADER_ARB)); + gAlphaMaskProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gAlphaMaskProgram.createShader(NULL, NULL); + } + if( !success ) { mVertexShaderLevel[SHADER_INTERFACE] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 1c9d7f8453..9988d1d4f7 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -275,7 +275,8 @@ extern LLGLSLShader gCustomAlphaProgram; extern LLGLSLShader gGlowCombineProgram; extern LLGLSLShader gSplatTextureRectProgram; extern LLGLSLShader gGlowCombineFXAAProgram; -extern LLGLSLShader gDebugProgram; +extern LLGLSLShader gDebugProgram; +extern LLGLSLShader gAlphaMaskProgram; //output tex0[tc0] + tex1[tc1] extern LLGLSLShader gTwoTextureAddProgram; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index cfdbfd3f03..2e2614e429 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1574,6 +1574,12 @@ LLViewerWindow::LLViewerWindow( ignore_pixel_depth, gSavedSettings.getBOOL("RenderDeferred") ? 0 : gSavedSettings.getU32("RenderFSAASamples")); //don't use window level anti-aliasing if FBOs are enabled + if (!LLViewerShaderMgr::sInitialized) + { //immediately initialize shaders + LLViewerShaderMgr::sInitialized = TRUE; + LLViewerShaderMgr::instance()->setShaders(); + } + if (NULL == mWindow) { LLSplashScreen::update(LLTrans::getString("StartupRequireDriverUpdate")); @@ -1710,23 +1716,26 @@ LLViewerWindow::LLViewerWindow( void LLViewerWindow::initGLDefaults() { gGL.setSceneBlendType(LLRender::BT_ALPHA); - glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); - glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,LLColor4::black.mV); - glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,LLColor4::white.mV); - - glPixelStorei(GL_PACK_ALIGNMENT,1); - glPixelStorei(GL_UNPACK_ALIGNMENT,1); + if (!LLGLSLShader::sNoFixedFunction) + { //initialize fixed function state + glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,LLColor4::black.mV); + glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,LLColor4::white.mV); - // lights for objects - glShadeModel( GL_SMOOTH ); + // lights for objects + glShadeModel( GL_SMOOTH ); - gGL.setAmbientLightColor(LLColor4::black); - - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } + glPixelStorei(GL_PACK_ALIGNMENT,1); + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + + gGL.setAmbientLightColor(LLColor4::black); + glCullFace(GL_BACK); // RN: Need this for translation and stretch manip. |