Replaced some opengl fixed functions with shaders. Temporary ShyotlUseLegacyRenderPath setting to debug if this change actually improves framerate at all (setting not tied to callbacks. Have to toggle shaders to have stuff pick up the setting change)
This commit is contained in:
@@ -443,10 +443,10 @@ void LLDrawPoolBump::renderShiny(bool invisible)
|
||||
{
|
||||
renderGroups(LLRenderPass::PASS_SHINY, sVertexMask);
|
||||
}
|
||||
else // invisible
|
||||
{
|
||||
renderGroups(LLRenderPass::PASS_INVISI_SHINY, sVertexMask);
|
||||
}
|
||||
//else // invisible (deprecated)
|
||||
//{
|
||||
//renderGroups(LLRenderPass::PASS_INVISI_SHINY, sVertexMask);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,11 +472,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)
|
||||
@@ -591,19 +595,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;
|
||||
@@ -714,36 +718,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)
|
||||
// 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);
|
||||
}
|
||||
|
||||
gGL.setSceneBlendType(LLRender::BT_MULT_X2);
|
||||
gGL.getTexUnit(0)->activate();
|
||||
stop_glerror();
|
||||
|
||||
gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
|
||||
}
|
||||
|
||||
//static
|
||||
@@ -773,14 +785,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);
|
||||
}
|
||||
@@ -955,7 +974,6 @@ void LLBumpImageList::addTextureStats(U8 bump, const LLUUID& base_image_id, F32
|
||||
|
||||
void LLBumpImageList::updateImages()
|
||||
{
|
||||
llpushcallstacks ;
|
||||
for (bump_image_map_t::iterator iter = mBrightnessEntries.begin(); iter != mBrightnessEntries.end(); )
|
||||
{
|
||||
bump_image_map_t::iterator curiter = iter++;
|
||||
@@ -982,7 +1000,7 @@ void LLBumpImageList::updateImages()
|
||||
}
|
||||
}
|
||||
}
|
||||
llpushcallstacks ;
|
||||
|
||||
for (bump_image_map_t::iterator iter = mDarknessEntries.begin(); iter != mDarknessEntries.end(); )
|
||||
{
|
||||
bump_image_map_t::iterator curiter = iter++;
|
||||
@@ -1009,7 +1027,6 @@ void LLBumpImageList::updateImages()
|
||||
}
|
||||
}
|
||||
}
|
||||
llpushcallstacks ;
|
||||
}
|
||||
|
||||
|
||||
@@ -1410,6 +1427,11 @@ void LLDrawPoolInvisible::render(S32 pass)
|
||||
{ //render invisiprims
|
||||
LLFastTimer t(LLFastTimer::FTM_RENDER_INVISIBLE);
|
||||
|
||||
if (gPipeline.canUseVertexShaders())
|
||||
{
|
||||
gOcclusionProgram.bind();
|
||||
}
|
||||
|
||||
U32 invisi_mask = LLVertexBuffer::MAP_VERTEX;
|
||||
glStencilMask(0);
|
||||
gGL.setColorMask(false, false);
|
||||
@@ -1417,6 +1439,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);
|
||||
|
||||
Reference in New Issue
Block a user