diff options
author | Dave Parks <davep@lindenlab.com> | 2011-07-17 00:24:08 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-07-17 00:24:08 -0500 |
commit | 6469f1c2f21ecd3b15a18957d882ef6a16b17ecf (patch) | |
tree | 3159983e7a9c6c008d8334bceb672dfc16e2ca35 /indra/newview | |
parent | ddbd5cee7480e565e447486a21e67c301a716b1f (diff) |
SH-2031 High risk changeset, but potentially high reward. Addresses frame stalls in renderer by never using the fixed function pipeline if shaders are available.
Diffstat (limited to 'indra/newview')
34 files changed, 610 insertions, 86 deletions
diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index 9f4e89691f..ae72dee900 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -44,7 +44,6 @@ <array> <!-- sample entry for debugging a specific item --> <!-- <string>Voice</string> --> - <string>Capabilities</string> </array> </map> </array> diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl new file mode 100644 index 0000000000..3827c72f4c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/customalphaF.glsl @@ -0,0 +1,17 @@ +/** + * @file customalphaF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D diffuseMap; + +uniform float custom_alpha; + +void main() +{ + vec4 color = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy); + color.a *= custom_alpha; + gl_FragColor = color; +} diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl new file mode 100644 index 0000000000..04bfff22c1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl @@ -0,0 +1,16 @@ +/** + * @file customalphaV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_FrontColor = gl_Color; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl new file mode 100644 index 0000000000..a60fb1eaa7 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -0,0 +1,17 @@ +/** + * @file glowcombineF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +#extension GL_ARB_texture_rectangle : enable + +uniform sampler2D glowMap; +uniform sampler2DRect screenMap; + +void main() +{ + gl_FragColor = texture2D(glowMap, gl_TexCoord[0].xy) + + texture2DRect(screenMap, gl_TexCoord[1].xy); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl new file mode 100644 index 0000000000..ce183ec154 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl @@ -0,0 +1,15 @@ +/** + * @file glowcombineV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[1] = gl_MultiTexCoord1; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl new file mode 100644 index 0000000000..b140712f18 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl @@ -0,0 +1,11 @@ +/** + * @file occlusionF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +void main() +{ + gl_FragColor = vec4(1,1,1,1); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl new file mode 100644 index 0000000000..5a5d0ec506 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl @@ -0,0 +1,12 @@ +/** + * @file uiV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl new file mode 100644 index 0000000000..ae943cc438 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorF.glsl @@ -0,0 +1,15 @@ +/** + * @file twotextureaddF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D tex0; + +void main() +{ + float alpha = texture2D(tex0, gl_TexCoord[0].xy).a; + + gl_FragColor = vec4(gl_Color.rgb, alpha); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl new file mode 100644 index 0000000000..5a854b4e02 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl @@ -0,0 +1,15 @@ +/** + * @file solidcolorV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl new file mode 100644 index 0000000000..d81b56fdb9 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/twotextureaddF.glsl @@ -0,0 +1,14 @@ +/** + * @file twotextureaddF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D tex0; +uniform sampler2D tex1; + +void main() +{ + gl_FragColor = texture2D(tex0, gl_TexCoord[0].xy)+texture2D(tex1, gl_TexCoord[1].xy); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl b/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl new file mode 100644 index 0000000000..f685b112b4 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl @@ -0,0 +1,16 @@ +/** + * @file twotextureaddV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[1] = gl_MultiTexCoord1; +} + diff --git a/indra/newview/app_settings/shaders/class1/interface/uiF.glsl b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl new file mode 100644 index 0000000000..9dec7a56ba --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/uiF.glsl @@ -0,0 +1,13 @@ +/** + * @file uiF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D diffuseMap; + +void main() +{ + gl_FragColor = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/uiV.glsl b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl new file mode 100644 index 0000000000..9ca6cae5c5 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl @@ -0,0 +1,16 @@ +/** + * @file uiV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_FrontColor = gl_Color; +} + diff --git a/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl new file mode 100644 index 0000000000..587ab93a80 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl @@ -0,0 +1,17 @@ +/** + * @file bumpF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + +uniform sampler2D texture0; +uniform sampler2D texture1; + +void main() +{ + float tex0 = texture2D(texture0, gl_TexCoord[0].xy).a; + float tex1 = texture2D(texture1, gl_TexCoord[1].xy).a; + + gl_FragColor = vec4(tex0+(1.0-tex1)-0.5); +} diff --git a/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl b/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl new file mode 100644 index 0000000000..056d1a9582 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl @@ -0,0 +1,16 @@ +/** + * @file bumpV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $/LicenseInfo$ + */ + + +void main() +{ + //transform vertex + gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex; + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1; + gl_FrontColor = gl_Color; +} diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index fa7d6e2a40..286284f828 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -190,15 +190,16 @@ void LLDrawPool::renderPostDeferred(S32 pass) //virtual void LLDrawPool::endRenderPass( S32 pass ) { - for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++) + /*for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++) { //dummy cleanup of any currently bound textures if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE) { gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType()); gGL.getTexUnit(i)->disable(); } - } + }*/ + //make sure channel 0 is active channel gGL.getTexUnit(0)->activate(); } diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index ad7e3ad593..ddcf42e523 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -138,6 +138,7 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) gPipeline.mDeferredDepth.bindTarget(); simple_shader = NULL; fullbright_shader = NULL; + gObjectFullbrightProgram.bind(); } deferred_render = TRUE; @@ -156,6 +157,7 @@ void LLDrawPoolAlpha::endPostDeferredPass(S32 pass) { gPipeline.mDeferredDepth.flush(); gPipeline.mScreen.bindTarget(); + gObjectFullbrightProgram.unbind(); } deferred_render = FALSE; @@ -238,7 +240,7 @@ void LLDrawPoolAlpha::render(S32 pass) fullbright_shader->bind(); } pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); - LLGLSLShader::bindNoShader(); + //LLGLSLShader::bindNoShader(); } else { diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 813b3820ee..d801f6df18 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -464,11 +464,15 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& } } } - gGL.getTexUnit(diffuse_channel)->disable(); - gGL.getTexUnit(cube_channel)->disable(); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + if (!LLGLSLShader::sNoFixedFunction) + { + gGL.getTexUnit(diffuse_channel)->disable(); + gGL.getTexUnit(cube_channel)->disable(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } } void LLDrawPoolBump::endShiny(bool invisible) @@ -583,19 +587,19 @@ void LLDrawPoolBump::endFullbrightShiny() cube_map->disable(); cube_map->restoreMatrix(); - if (diffuse_channel != 0) + /*if (diffuse_channel != 0) { shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); } gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);*/ shader->unbind(); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + //gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); } - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + //gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + //gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); diffuse_channel = -1; cube_channel = 0; @@ -706,36 +710,44 @@ void LLDrawPoolBump::beginBump(U32 pass) // Optional second pass: emboss bump map stop_glerror(); - // TEXTURE UNIT 0 - // Output.rgb = texture at texture coord 0 - gGL.getTexUnit(0)->activate(); + if (LLGLSLShader::sNoFixedFunction) + { + gObjectBumpProgram.bind(); + } + else + { + // TEXTURE UNIT 0 + // Output.rgb = texture at texture coord 0 + gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); + gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); + gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); - // TEXTURE UNIT 1 - gGL.getTexUnit(1)->activate(); + // TEXTURE UNIT 1 + gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); + + gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD_SIGNED, LLTexUnit::TBS_PREV_COLOR, LLTexUnit::TBS_ONE_MINUS_TEX_ALPHA); + gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); - gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD_SIGNED, LLTexUnit::TBS_PREV_COLOR, LLTexUnit::TBS_ONE_MINUS_TEX_ALPHA); - gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_ALPHA); + // src = tex0 + (1 - tex1) - 0.5 + // = (bump0/2 + 0.5) + (1 - (bump1/2 + 0.5)) - 0.5 + // = (1 + bump0 - bump1) / 2 - // src = tex0 + (1 - tex1) - 0.5 - // = (bump0/2 + 0.5) + (1 - (bump1/2 + 0.5)) - 0.5 - // = (1 + bump0 - bump1) / 2 + // Blend: src * dst + dst * src + // = 2 * src * dst + // = 2 * ((1 + bump0 - bump1) / 2) * dst [0 - 2 * dst] + // = (1 + bump0 - bump1) * dst.rgb + // = dst.rgb + dst.rgb * (bump0 - bump1) + + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + } - // Blend: src * dst + dst * src - // = 2 * src * dst - // = 2 * ((1 + bump0 - bump1) / 2) * dst [0 - 2 * dst] - // = (1 + bump0 - bump1) * dst.rgb - // = dst.rgb + dst.rgb * (bump0 - bump1) gGL.setSceneBlendType(LLRender::BT_MULT_X2); - gGL.getTexUnit(0)->activate(); stop_glerror(); - - gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); } //static @@ -765,14 +777,21 @@ void LLDrawPoolBump::endBump(U32 pass) return; } - // Disable texture unit 1 - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->disable(); - gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); + if (LLGLSLShader::sNoFixedFunction) + { + gObjectBumpProgram.unbind(); + } + else + { + // Disable texture blending on unit 1 + gGL.getTexUnit(1)->activate(); + //gGL.getTexUnit(1)->disable(); + gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); - // Disable texture unit 0 - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + // Disable texture blending on unit 0 + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } gGL.setSceneBlendType(LLRender::BT_ALPHA); } @@ -1407,6 +1426,11 @@ void LLDrawPoolInvisible::render(S32 pass) { //render invisiprims LLFastTimer t(FTM_RENDER_INVISIBLE); + if (gPipeline.canUseVertexShaders()) + { + gOcclusionProgram.bind(); + } + U32 invisi_mask = LLVertexBuffer::MAP_VERTEX; glStencilMask(0); gGL.setColorMask(false, false); @@ -1414,6 +1438,11 @@ void LLDrawPoolInvisible::render(S32 pass) gGL.setColorMask(true, false); glStencilMask(0xFFFFFFFF); + if (gPipeline.canUseVertexShaders()) + { + gOcclusionProgram.unbind(); + } + if (gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)) { beginShiny(true); diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp index 5dbb27cabb..224f149c6b 100644 --- a/indra/newview/lldrawpoolsimple.cpp +++ b/indra/newview/lldrawpoolsimple.cpp @@ -49,6 +49,8 @@ void LLDrawPoolGlow::beginPostDeferredPass(S32 pass) gDeferredFullbrightProgram.bind(); } +static LLFastTimer::DeclareTimer FTM_RENDER_GLOW_PUSH("Glow Push"); + void LLDrawPoolGlow::renderPostDeferred(S32 pass) { LLFastTimer t(FTM_RENDER_GLOW); @@ -62,7 +64,11 @@ void LLDrawPoolGlow::renderPostDeferred(S32 pass) LLGLDepthTest depth(GL_TRUE, GL_FALSE); gGL.setColorMask(false, true); - pushBatches(LLRenderPass::PASS_GLOW, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + + { + LLFastTimer t(FTM_RENDER_GLOW_PUSH); + pushBatches(LLRenderPass::PASS_GLOW, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + } gGL.setColorMask(true, false); gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -374,10 +380,14 @@ void LLDrawPoolFullbright::endRenderPass(S32 pass) LLFastTimer t(FTM_RENDER_FULLBRIGHT); LLRenderPass::endRenderPass(pass); + stop_glerror(); + if (mVertexShaderLevel > 0) { fullbright_shader->unbind(); } + + stop_glerror(); } void LLDrawPoolFullbright::render(S32 pass) @@ -385,6 +395,8 @@ void LLDrawPoolFullbright::render(S32 pass) LLFastTimer t(FTM_RENDER_FULLBRIGHT); gGL.setSceneBlendType(LLRender::BT_ALPHA); + stop_glerror(); + if (mVertexShaderLevel > 0) { fullbright_shader->bind(); @@ -398,6 +410,8 @@ void LLDrawPoolFullbright::render(S32 pass) U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR; renderTexture(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask); } + + stop_glerror(); } S32 LLDrawPoolFullbright::getNumPasses() diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 030d6e1110..efffb2df9e 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -82,6 +82,10 @@ void LLDrawPoolSky::render(S32 pass) mShader = &gObjectFullbrightWaterProgram; mShader->bind(); } + else if (LLGLSLShader::sNoFixedFunction) + { //just use the UI shader (generic single texture no lighting) + gUIProgram.bind(); + } else { // don't use shaders! @@ -139,6 +143,7 @@ void LLDrawPoolSky::renderSkyCubeFace(U8 side) if (LLSkyTex::doInterpolate()) { + LLGLEnable blend(GL_BLEND); mSkyTex[side].bindTexture(FALSE); glColor4f(1, 1, 1, LLSkyTex::getInterpVal()); // lighting is disabled diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index 81c796b146..429e06b227 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -73,7 +73,7 @@ void LLDrawPoolTree::beginRenderPass(S32 pass) shader = &gObjectSimpleNonIndexedProgram; } - if (gPipeline.canUseWindLightShadersOnObjects()) + if (gPipeline.canUseVertexShaders()) { shader->bind(); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index bf79c2100c..f9fd501072 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -189,16 +189,31 @@ void LLDrawPoolWLSky::renderStars(void) const glRotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f); // gl_FragColor.rgb = gl_Color.rgb; // gl_FragColor.a = gl_Color.a * star_alpha.a; - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_VERT_COLOR); - gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT_X2, LLTexUnit::TBS_CONST_ALPHA, LLTexUnit::TBS_TEX_ALPHA); - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, star_alpha.mV); + if (LLGLSLShader::sNoFixedFunction) + { + gCustomAlphaProgram.bind(); + gCustomAlphaProgram.uniform1f("custom_alpha", star_alpha.mV[3]); + } + else + { + gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_VERT_COLOR); + gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT_X2, LLTexUnit::TBS_CONST_ALPHA, LLTexUnit::TBS_TEX_ALPHA); + glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, star_alpha.mV); + } gSky.mVOWLSkyp->drawStars(); gGL.popMatrix(); - - // and disable the combiner states - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + + if (LLGLSLShader::sNoFixedFunction) + { + gCustomAlphaProgram.unbind(); + } + else + { + // and disable the combiner states + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } } void LLDrawPoolWLSky::renderSkyClouds(F32 camHeightLocal) const @@ -242,6 +257,10 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() if (gSky.mVOSkyp->getMoon().getDraw() && face->getGeomCount()) { + if (gPipeline.canUseVertexShaders()) + { + gUIProgram.bind(); + } // *NOTE: even though we already bound this texture above for the // stars register combiners, we bind again here for defensive reasons, // since LLImageGL::bind detects that it's a noop, and optimizes it out. @@ -257,6 +276,11 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() LLFacePool::LLOverrideFaceColor color_override(this, color); face->renderIndexed(); + + if (gPipeline.canUseVertexShaders()) + { + gUIProgram.unbind(); + } } } diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index 82e1f2dfb5..482294c8a6 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -477,7 +477,7 @@ void LLHUDNameTag::renderText(BOOL for_select) // Render label { - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + //gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); for(std::vector<LLHUDTextSegment>::iterator segment_iter = mLabelSegments.begin(); segment_iter != mLabelSegments.end(); ++segment_iter ) diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index f99afa923b..e23b431457 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -47,6 +47,7 @@ #include "llvoavatar.h" #include "llvolumemgr.h" #include "lltextureatlas.h" +#include "llglslshader.h" static LLFastTimer::DeclareTimer FTM_FRUSTUM_CULL("Frustum Culling"); static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); @@ -3176,6 +3177,8 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) glColor4fv(line_color.mV); LLVertexBuffer::unbind(); + llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShader != 0); + glVertexPointer(3, GL_FLOAT, 16, phys_volume->mHullPoints); glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices); @@ -3257,7 +3260,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) if (phys_volume->mHullPoints && phys_volume->mHullIndices) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - + llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShader != 0); LLVertexBuffer::unbind(); glVertexPointer(3, GL_FLOAT, 16, phys_volume->mHullPoints); glColor4fv(line_color.mV); diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index bd41aa64f0..e8abee2fb7 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -45,6 +45,7 @@ #include "llagentwearables.h" #include "llwearable.h" #include "llviewercontrol.h" +#include "llviewershadermgr.h" #include "llviewervisualparam.h" //#include "../tools/imdebug/imdebug.h" @@ -294,11 +295,17 @@ BOOL LLTexLayerSetBuffer::render() BOOL success = TRUE; + //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 ); gGL.flush(); + LLGLSLShader::sNoFixedFunction = no_ff; + if(upload_now) { if (!success) diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 911fc8e1ed..39053fe9e4 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -616,6 +616,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") && gSavedSettings.getBOOL("UseOcclusion") && gGLManager.mHasOcclusionQuery) ? 2 : 0; + LLTexUnit::sWhiteTexture = LLViewerFetchedTexture::sWhiteImagep->getTexName(); /*if (LLPipeline::sUseOcclusion && LLPipeline::sRenderDeferred) { //force occlusion on for all render types if doing deferred render (tighter shadow frustum) @@ -709,6 +710,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } + LLGLState::checkStates(); + LLGLState::checkClientArrays(); + //if (!for_snapshot) { LLMemType mt_gw(LLMemType::MTYPE_DISPLAY_GEN_REFLECTION); @@ -717,6 +721,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gPipeline.generateHighlight(*LLViewerCamera::getInstance()); } + LLGLState::checkStates(); + LLGLState::checkClientArrays(); + ////////////////////////////////////// // // Update images, using the image stats generated during object update/culling @@ -743,6 +750,10 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLImageGL::deleteDeadTextures(); stop_glerror(); } + + LLGLState::checkStates(); + LLGLState::checkClientArrays(); + /////////////////////////////////// // // StateSort @@ -770,6 +781,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) } } + LLGLState::checkStates(); + LLGLState::checkClientArrays(); + LLPipeline::sUseOcclusion = occlusion; { @@ -828,6 +842,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; LLPipeline::refreshRenderDeferred(); + LLGLState::checkStates(); + LLGLState::checkClientArrays(); + stop_glerror(); if (to_texture) @@ -878,6 +895,14 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) stop_glerror(); } + for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++) + { //dummy cleanup of any currently bound textures + if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE) + { + gGL.getTexUnit(i)->unbind(gGL.getTexUnit(i)->getCurrType()); + gGL.getTexUnit(i)->disable(); + } + } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderFlush"); if (to_texture) @@ -1339,7 +1364,7 @@ void render_ui_2d() } stop_glerror(); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + //gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); // render outline for HUD if (isAgentAvatarValid() && gAgentCamera.mHUDCurZoom < 0.98f) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index e473901609..812b03a2e6 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -61,6 +61,14 @@ BOOL LLViewerShaderMgr::sInitialized = FALSE; LLVector4 gShinyOrigin; +//utility shaders +LLGLSLShader gOcclusionProgram; +LLGLSLShader gUIProgram; +LLGLSLShader gCustomAlphaProgram; +LLGLSLShader gGlowCombineProgram; +LLGLSLShader gTwoTextureAddProgram; +LLGLSLShader gSolidColorProgram; + //object shaders LLGLSLShader gObjectSimpleProgram; LLGLSLShader gObjectSimpleWaterProgram; @@ -70,6 +78,7 @@ LLGLSLShader gObjectFullbrightShinyProgram; LLGLSLShader gObjectFullbrightShinyWaterProgram; LLGLSLShader gObjectShinyProgram; LLGLSLShader gObjectShinyWaterProgram; +LLGLSLShader gObjectBumpProgram; LLGLSLShader gObjectSimpleNonIndexedProgram; LLGLSLShader gObjectSimpleNonIndexedWaterProgram; @@ -169,6 +178,13 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gWaterProgram); mShaderList.push_back(&gAvatarEyeballProgram); mShaderList.push_back(&gObjectSimpleProgram); + mShaderList.push_back(&gObjectBumpProgram); + mShaderList.push_back(&gUIProgram); + mShaderList.push_back(&gCustomAlphaProgram); + mShaderList.push_back(&gGlowCombineProgram); + mShaderList.push_back(&gTwoTextureAddProgram); + mShaderList.push_back(&gSolidColorProgram); + mShaderList.push_back(&gOcclusionProgram); mShaderList.push_back(&gObjectFullbrightProgram); mShaderList.push_back(&gObjectFullbrightShinyProgram); mShaderList.push_back(&gObjectFullbrightShinyWaterProgram); @@ -410,9 +426,13 @@ void LLViewerShaderMgr::setShaders() } mMaxAvatarShaderLevel = 0; + LLGLSLShader::sNoFixedFunction = false; if (LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") && gSavedSettings.getBOOL("VertexShaderEnable")) { + //using shaders, disable fixed function + LLGLSLShader::sNoFixedFunction = true; + S32 light_class = 2; S32 env_class = 2; S32 obj_class = 2; @@ -554,6 +574,7 @@ void LLViewerShaderMgr::setShaders() } else { + LLGLSLShader::sNoFixedFunction = false; gPipeline.mVertexShadersEnabled = FALSE; gPipeline.mVertexShadersLoaded = 0; mVertexShaderLevel[SHADER_LIGHTING] = 0; @@ -568,6 +589,7 @@ void LLViewerShaderMgr::setShaders() } else { + LLGLSLShader::sNoFixedFunction = false; gPipeline.mVertexShadersEnabled = FALSE; gPipeline.mVertexShadersLoaded = 0; mVertexShaderLevel[SHADER_LIGHTING] = 0; @@ -591,7 +613,15 @@ void LLViewerShaderMgr::setShaders() void LLViewerShaderMgr::unloadShaders() { + gOcclusionProgram.unload(); + gUIProgram.unload(); + gCustomAlphaProgram.unload(); + gGlowCombineProgram.unload(); + gTwoTextureAddProgram.unload(); + gSolidColorProgram.unload(); + gObjectSimpleProgram.unload(); + gObjectBumpProgram.unload(); gObjectSimpleWaterProgram.unload(); gObjectFullbrightProgram.unload(); gObjectFullbrightWaterProgram.unload(); @@ -1581,6 +1611,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectFullbrightShinyWaterProgram.unload(); gObjectShinyWaterProgram.unload(); gObjectSimpleProgram.unload(); + gObjectBumpProgram.unload(); gObjectSimpleWaterProgram.unload(); gObjectFullbrightProgram.unload(); gObjectFullbrightWaterProgram.unload(); @@ -1753,6 +1784,22 @@ BOOL LLViewerShaderMgr::loadShadersObject() if (success) { + gObjectBumpProgram.mName = "Bump Shader"; + /*gObjectBumpProgram.mFeatures.calculatesLighting = true; + gObjectBumpProgram.mFeatures.calculatesAtmospherics = true; + gObjectBumpProgram.mFeatures.hasGamma = true; + gObjectBumpProgram.mFeatures.hasAtmospherics = true; + gObjectBumpProgram.mFeatures.hasLighting = true; + gObjectBumpProgram.mFeatures.mIndexedTextureChannels = 0;*/ + gObjectBumpProgram.mShaderFiles.clear(); + gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpV.glsl", GL_VERTEX_SHADER_ARB)); + gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpF.glsl", GL_FRAGMENT_SHADER_ARB)); + gObjectBumpProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT]; + success = gObjectBumpProgram.createShader(NULL, NULL); + } + + if (success) + { gObjectSimpleWaterProgram.mName = "Simple Water Shader"; gObjectSimpleWaterProgram.mFeatures.calculatesLighting = true; gObjectSimpleWaterProgram.mFeatures.calculatesAtmospherics = true; @@ -2135,6 +2182,85 @@ BOOL LLViewerShaderMgr::loadShadersInterface() success = gHighlightProgram.createShader(NULL, NULL); } + if (success) + { + gUIProgram.mName = "UI Shader"; + gUIProgram.mShaderFiles.clear(); + gUIProgram.mShaderFiles.push_back(make_pair("interface/uiV.glsl", GL_VERTEX_SHADER_ARB)); + gUIProgram.mShaderFiles.push_back(make_pair("interface/uiF.glsl", GL_FRAGMENT_SHADER_ARB)); + gUIProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gUIProgram.createShader(NULL, NULL); + } + + if (success) + { + gCustomAlphaProgram.mName = "Custom Alpha Shader"; + gCustomAlphaProgram.mShaderFiles.clear(); + gCustomAlphaProgram.mShaderFiles.push_back(make_pair("interface/customalphaV.glsl", GL_VERTEX_SHADER_ARB)); + gCustomAlphaProgram.mShaderFiles.push_back(make_pair("interface/customalphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + gCustomAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gCustomAlphaProgram.createShader(NULL, NULL); + } + + if (success) + { + gGlowCombineProgram.mName = "Glow Combine Shader"; + gGlowCombineProgram.mShaderFiles.clear(); + gGlowCombineProgram.mShaderFiles.push_back(make_pair("interface/glowcombineV.glsl", GL_VERTEX_SHADER_ARB)); + gGlowCombineProgram.mShaderFiles.push_back(make_pair("interface/glowcombineF.glsl", GL_FRAGMENT_SHADER_ARB)); + gGlowCombineProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gGlowCombineProgram.createShader(NULL, NULL); + if (success) + { + gGlowCombineProgram.bind(); + gGlowCombineProgram.uniform1i("glowMap", 0); + gGlowCombineProgram.uniform1i("screenMap", 1); + gGlowCombineProgram.unbind(); + } + } + + if (success) + { + gTwoTextureAddProgram.mName = "Two Texture Add Shader"; + gTwoTextureAddProgram.mShaderFiles.clear(); + gTwoTextureAddProgram.mShaderFiles.push_back(make_pair("interface/twotextureaddV.glsl", GL_VERTEX_SHADER_ARB)); + gTwoTextureAddProgram.mShaderFiles.push_back(make_pair("interface/twotextureaddF.glsl", GL_FRAGMENT_SHADER_ARB)); + gTwoTextureAddProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gTwoTextureAddProgram.createShader(NULL, NULL); + if (success) + { + gTwoTextureAddProgram.bind(); + gTwoTextureAddProgram.uniform1i("tex0", 0); + gTwoTextureAddProgram.uniform1i("tex1", 1); + } + } + + if (success) + { + gSolidColorProgram.mName = "Solid Color Shader"; + gSolidColorProgram.mShaderFiles.clear(); + gSolidColorProgram.mShaderFiles.push_back(make_pair("interface/solidcolorV.glsl", GL_VERTEX_SHADER_ARB)); + gSolidColorProgram.mShaderFiles.push_back(make_pair("interface/solidcolorF.glsl", GL_FRAGMENT_SHADER_ARB)); + gSolidColorProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gSolidColorProgram.createShader(NULL, NULL); + if (success) + { + gSolidColorProgram.bind(); + gSolidColorProgram.uniform1i("tex0", 0); + gSolidColorProgram.unbind(); + } + } + + if (success) + { + gOcclusionProgram.mName = "Occlusion Shader"; + gOcclusionProgram.mShaderFiles.clear(); + gOcclusionProgram.mShaderFiles.push_back(make_pair("interface/occlusionV.glsl", GL_VERTEX_SHADER_ARB)); + gOcclusionProgram.mShaderFiles.push_back(make_pair("interface/occlusionF.glsl", GL_FRAGMENT_SHADER_ARB)); + gOcclusionProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE]; + success = gOcclusionProgram.createShader(NULL, NULL); + } + if( !success ) { mVertexShaderLevel[SHADER_INTERFACE] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index efef9ec5b2..6b22e83a9f 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -287,6 +287,18 @@ inline bool operator != (LLViewerShaderMgr::shader_iter const & a, LLViewerShade extern LLVector4 gShinyOrigin; +//utility shaders +extern LLGLSLShader gOcclusionProgram; +extern LLGLSLShader gUIProgram; +extern LLGLSLShader gCustomAlphaProgram; +extern LLGLSLShader gGlowCombineProgram; + +//output tex0[tc0] + tex1[tc1] +extern LLGLSLShader gTwoTextureAddProgram; + +//output vec4(color.rgb,color.a*tex0[tc0].a) +extern LLGLSLShader gSolidColorProgram; + //object shaders extern LLGLSLShader gObjectSimpleProgram; extern LLGLSLShader gObjectSimpleWaterProgram; @@ -296,6 +308,7 @@ extern LLGLSLShader gObjectFullbrightProgram; extern LLGLSLShader gObjectFullbrightWaterProgram; extern LLGLSLShader gObjectFullbrightNonIndexedProgram; extern LLGLSLShader gObjectFullbrightNonIndexedWaterProgram; +extern LLGLSLShader gObjectBumpProgram; extern LLGLSLShader gObjectSimpleLODProgram; extern LLGLSLShader gObjectFullbrightLODProgram; diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 4da0f80a00..5fcc57bc91 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -599,7 +599,7 @@ bool LLViewerTexture::bindDefaultImage(S32 stage) } if (!res && LLViewerTexture::sNullImagep.notNull() && (this != LLViewerTexture::sNullImagep)) { - res = gGL.getTexUnit(stage)->bind(LLViewerTexture::sNullImagep) ; + res = gGL.getTexUnit(stage)->bind(LLViewerTexture::sNullImagep); } if (!res) { diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index d24174adea..30ef8b8a29 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -115,7 +115,7 @@ void LLViewerTextureList::doPreloadImages() // Set the "white" image LLViewerFetchedTexture::sWhiteImagep = LLViewerTextureManager::getFetchedTextureFromFile("white.tga", MIPMAP_NO, LLViewerFetchedTexture::BOOST_UI); - + LLTexUnit::sWhiteTexture = LLViewerFetchedTexture::sWhiteImagep->getTexName(); LLUIImageList* image_list = LLUIImageList::getInstance(); image_list->initFromFile(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index cff166b825..1e056898d5 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2296,6 +2296,11 @@ void LLViewerWindow::draw() // Draw all nested UI views. // No translation needed, this view is glued to 0,0 + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + gGL.pushMatrix(); LLUI::pushMatrix(); { @@ -2370,6 +2375,11 @@ void LLViewerWindow::draw() LLUI::popMatrix(); gGL.popMatrix(); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } + //#if LL_DEBUG LLView::sIsDrawing = FALSE; //#endif diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index cd2bbad620..9dc6b5194e 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -7049,6 +7049,8 @@ LLVivoxProtocolParser::~LLVivoxProtocolParser() XML_ParserFree(parser); } +//static LLFastTimer::DeclareTimer FTM_VIVOX_PROCESS("Vivox Process"); + // virtual LLIOPipe::EStatus LLVivoxProtocolParser::process_impl( const LLChannelDescriptors& channels, @@ -7057,6 +7059,7 @@ LLIOPipe::EStatus LLVivoxProtocolParser::process_impl( LLSD& context, LLPumpIO* pump) { + //LLFastTimer t(FTM_VIVOX_PROCESS); LLBufferStream istr(channels, buffer.get()); std::ostringstream ostr; while (istr.good()) diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 3c7fe708e6..890861df71 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -51,6 +51,7 @@ #include "llspatialpartition.h" #include "llnotificationsutil.h" #include "raytrace.h" +#include "llglslshader.h" extern LLPipeline gPipeline; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e74bf2a620..8372c2430b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1983,6 +1983,14 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl LLGLDepthTest depth(GL_TRUE, GL_FALSE); + bool bound_shader = false; + if (gPipeline.canUseVertexShaders() && LLGLSLShader::sCurBoundShader == 0) + { //if no shader is currently bound, use the occlusion shader instead of fixed function if we can + // (shadow render uses a special shader that clamps to clip planes) + bound_shader = true; + gOcclusionProgram.bind(); + } + for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { @@ -2010,6 +2018,11 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl } } + if (bound_shader) + { + gOcclusionProgram.unbind(); + } + camera.disableUserClipPlane(); if (hasRenderType(LLPipeline::RENDER_TYPE_SKY) && @@ -2133,7 +2146,12 @@ void LLPipeline::doOcclusion(LLCamera& camera) LLGLDepthTest depth(GL_TRUE, GL_FALSE); LLGLDisable cull(GL_CULL_FACE); - + + if (canUseVertexShaders()) + { + gOcclusionProgram.bind(); + } + for (LLCullResult::sg_list_t::iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter) { LLSpatialGroup* group = *iter; @@ -2141,6 +2159,11 @@ void LLPipeline::doOcclusion(LLCamera& camera) group->clearOcclusionState(LLSpatialGroup::ACTIVE_OCCLUSION); } + if (canUseVertexShaders()) + { + gOcclusionProgram.unbind(); + } + gGL.setColorMask(true, false); } } @@ -3249,6 +3272,11 @@ void render_hud_elements() gGL.color4f(1,1,1,1); if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + LLGLEnable multisample(gSavedSettings.getU32("RenderFSAASamples") > 0 ? GL_MULTISAMPLE_ARB : 0); gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d() @@ -3262,6 +3290,10 @@ void render_hud_elements() // Render name tags. LLHUDObject::renderAll(); + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } } else if (gForceRenderLandFence) { @@ -3599,8 +3631,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) check_stack_depth(stack_depth); std::string msg = llformat("pass %d", i); LLGLState::checkStates(msg); - LLGLState::checkTextureChannels(msg); - LLGLState::checkClientArrays(msg); + //LLGLState::checkTextureChannels(msg); + //LLGLState::checkClientArrays(msg); } } } @@ -3638,16 +3670,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); - - - - stop_glerror(); - - LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); + //LLGLState::checkTextureChannels(); + //LLGLState::checkClientArrays(); LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderHighlights"); @@ -3701,8 +3725,8 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) LLVertexBuffer::unbind(); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); +// LLGLState::checkTextureChannels(); +// LLGLState::checkClientArrays(); } void LLPipeline::renderGeomDeferred(LLCamera& camera) @@ -6449,30 +6473,39 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) LLGLDisable blend(GL_BLEND); - //tex unit 0 - gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR); - - gGL.getTexUnit(0)->bind(&mGlow[1]); - gGL.getTexUnit(1)->activate(); - gGL.getTexUnit(1)->enable(LLTexUnit::TT_RECT_TEXTURE); - - - //tex unit 1 - gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); + if (LLGLSLShader::sNoFixedFunction) + { + gGlowCombineProgram.bind(); + } + else + { + //tex unit 0 + gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_TEX_COLOR); + //tex unit 1 + gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_ADD, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR); + } + gGL.getTexUnit(0)->bind(&mGlow[1]); gGL.getTexUnit(1)->bind(&mScreen); - gGL.getTexUnit(1)->activate(); LLGLEnable multisample(gSavedSettings.getU32("RenderFSAASamples") > 0 ? GL_MULTISAMPLE_ARB : 0); buff->setBuffer(mask); buff->drawArrays(LLRender::TRIANGLE_STRIP, 0, 3); - gGL.getTexUnit(1)->disable(); - gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); + if (LLGLSLShader::sNoFixedFunction) + { + gGlowCombineProgram.unbind(); + } + else + { + gGL.getTexUnit(1)->disable(); + gGL.getTexUnit(1)->setTextureBlendType(LLTexUnit::TB_MULT); - gGL.getTexUnit(0)->activate(); - gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + } + } if (LLRenderTarget::sUseFBO) @@ -6485,6 +6518,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PHYSICS_SHAPES)) { + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.bind(); + } + gGL.setColorMask(true, false); LLVector2 tc1(0,0); @@ -6508,6 +6546,12 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) gGL.end(); gGL.flush(); + + if (LLGLSLShader::sNoFixedFunction) + { + gUIProgram.unbind(); + } + } glMatrixMode(GL_PROJECTION); @@ -8063,8 +8107,8 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLViewerCamera::getInstance()->setUserClipPlane(npnorm); LLGLState::checkStates(); - LLGLState::checkTextureChannels(); - LLGLState::checkClientArrays(); + //LLGLState::checkTextureChannels(); + //LLGLState::checkClientArrays(); if (!skip_avatar_update) { @@ -8197,6 +8241,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLVertexBuffer::unbind(); { + if (!use_shader) + { //occlusion program is general purpose depth-only no-textures + gOcclusionProgram.bind(); + } LLFastTimer ftm(FTM_SHADOW_SIMPLE); LLGLDisable test(GL_ALPHA_TEST); gGL.getTexUnit(0)->disable(); @@ -8205,6 +8253,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE); } gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + if (!use_shader) + { + gOcclusionProgram.unbind(); + } } if (use_shader) |