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:
Shyotl
2011-08-10 03:53:49 -05:00
parent 896b7146e7
commit ca328aec72
41 changed files with 1037 additions and 273 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -0,0 +1,11 @@
/**
* @file occlusionF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
void main()
{
gl_FragColor = vec4(1,1,1,1);
}

View File

@@ -0,0 +1,12 @@
/**
* @file uiV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

View File

@@ -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_Color.a;
gl_FragColor = vec4(gl_Color.rgb, alpha);
}

View File

@@ -0,0 +1,16 @@
/**
* @file solidcolorV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_MultiTexCoord0;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -87,7 +87,7 @@ LLDynamicArrayPtr<LLPointer<LLDrawable> > LLDrawable::sDeadList;
void LLDrawable::incrementVisible()
{
sCurVisible++;
sCurPixelAngle = (F32) gViewerWindow->getWindowDisplayHeight()/LLViewerCamera::getInstance()->getView();
sCurPixelAngle = (F32) gViewerWindow->getWindowHeightRaw()/LLViewerCamera::getInstance()->getView();
}
void LLDrawable::init()
{
@@ -202,16 +202,22 @@ void LLDrawable::cleanupReferences()
{
LLFastTimer t(LLFastTimer::FTM_PIPELINE);
std::for_each(mFaces.begin(), mFaces.end(), DeletePointer());
mFaces.clear();
{
//LLFastTimer t(FTM_DELETE_FACES);
std::for_each(mFaces.begin(), mFaces.end(), DeletePointer());
mFaces.clear();
}
gObjectList.removeDrawable(this);
gPipeline.unlinkDrawable(this);
// Cleanup references to other objects
mVObjp = NULL;
mParent = NULL;
{
//LLFastTimer t(FTM_DEREF_DRAWABLE);
// Cleanup references to other objects
mVObjp = NULL;
mParent = NULL;
}
}
void LLDrawable::cleanupDeadDrawables()

View File

@@ -197,14 +197,14 @@ void LLDrawPool::renderPostDeferred(S32 pass)
//virtual
void LLDrawPool::endRenderPass( S32 pass )
{
for (U32 i = 0; i < (U32)gGLManager.mNumTextureImageUnits; i++)
/*for (U32 i = 0; i < (U32)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();
}
}
}*/
gGL.getTexUnit(0)->activate();
}

View File

@@ -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);

View File

@@ -88,6 +88,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!

View File

@@ -50,6 +50,8 @@ LLPointer<LLViewerTexture> LLDrawPoolWLSky::sCloudNoiseTexture = NULL;
LLPointer<LLImageRaw> LLDrawPoolWLSky::sCloudNoiseRawImage = NULL;
static LLGLSLShader* cloud_shader = NULL;
static LLGLSLShader* sky_shader = NULL;
LLDrawPoolWLSky::LLDrawPoolWLSky(void) :
@@ -64,13 +66,24 @@ LLDrawPoolWLSky::LLDrawPoolWLSky(void) :
llerrs << "Error: Failed to load cloud noise image " << cloudNoiseFilename << llendl;
}
cloudNoiseFile->load(cloudNoiseFilename);
if(cloudNoiseFile->load(cloudNoiseFilename))
{
sCloudNoiseRawImage = new LLImageRaw();
sCloudNoiseRawImage = new LLImageRaw();
if(cloudNoiseFile->decode(sCloudNoiseRawImage, 0.0f))
{
//debug use
lldebugs << "cloud noise raw image width: " << sCloudNoiseRawImage->getWidth() << " : height: " << sCloudNoiseRawImage->getHeight() << " : components: " <<
(S32)sCloudNoiseRawImage->getComponents() << " : data size: " << sCloudNoiseRawImage->getDataSize() << llendl ;
llassert_always(sCloudNoiseRawImage->getData()) ;
cloudNoiseFile->decode(sCloudNoiseRawImage, 0.0f);
sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE);
sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE);
}
else
{
sCloudNoiseRawImage = NULL ;
}
}
LLWLParamManager::instance()->propagateParameters();
}
@@ -89,6 +102,15 @@ LLViewerTexture *LLDrawPoolWLSky::getDebugTexture()
void LLDrawPoolWLSky::beginRenderPass( S32 pass )
{
sky_shader =
LLPipeline::sUnderWaterRender ?
&gObjectSimpleWaterProgram :
&gWLSkyProgram;
cloud_shader =
LLPipeline::sUnderWaterRender ?
&gObjectSimpleWaterProgram :
&gWLCloudProgram;
}
void LLDrawPoolWLSky::endRenderPass( S32 pass )
@@ -134,19 +156,14 @@ void LLDrawPoolWLSky::renderSkyHaze(F32 camHeightLocal) const
{
if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))
{
LLGLSLShader* shader =
LLPipeline::sUnderWaterRender ?
&gObjectSimpleWaterProgram :
&gWLSkyProgram;
LLGLDisable blend(GL_BLEND);
shader->bind();
sky_shader->bind();
/// Render the skydome
renderDome(camHeightLocal, shader);
renderDome(camHeightLocal, sky_shader);
shader->unbind();
sky_shader->unbind();
}
}
@@ -182,43 +199,51 @@ void LLDrawPoolWLSky::renderStars(void) const
gGL.pushMatrix();
glRotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f);
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);
/*//Old
gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_COLOR);
gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT_X2, LLTexUnit::TBS_PREV_ALPHA, LLTexUnit::TBS_CONST_ALPHA); */
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, star_alpha.mV);
// gl_FragColor.rgb = gl_Color.rgb;
// gl_FragColor.a = gl_Color.a * star_alpha.a;
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(); //New
//glPointSize(1.f);
// and disable the combiner states
gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
gGL.popMatrix();
if (LLGLSLShader::sNoFixedFunction)
{
gCustomAlphaProgram.unbind();
}
else
{
// and disable the combiner states
gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
}
}
void LLDrawPoolWLSky::renderSkyClouds(F32 camHeightLocal) const
{
if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WL_CLOUDS))
if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WL_CLOUDS) && sCloudNoiseTexture.notNull())
{
LLGLSLShader* shader =
LLPipeline::sUnderWaterRender ?
&gObjectSimpleWaterProgram :
&gWLCloudProgram;
LLGLEnable blend(GL_BLEND);
gGL.setSceneBlendType(LLRender::BT_ALPHA);
gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
gGL.getTexUnit(0)->bind(sCloudNoiseTexture);
shader->bind();
cloud_shader->bind();
/// Render the skydome
renderDome(camHeightLocal, shader);
renderDome(camHeightLocal, cloud_shader);
shader->unbind();
cloud_shader->unbind();
}
}
@@ -244,6 +269,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.
@@ -259,6 +288,11 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
LLFacePool::LLOverrideFaceColor color_override(this, color);
face->renderIndexed();
if (gPipeline.canUseVertexShaders())
{
gUIProgram.unbind();
}
}
}
@@ -330,5 +364,8 @@ void LLDrawPoolWLSky::cleanupGL()
//static
void LLDrawPoolWLSky::restoreGL()
{
sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE);
if(sCloudNoiseRawImage.notNull())
{
sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE);
}
}

View File

@@ -1675,7 +1675,7 @@ BOOL LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius)
//the projection of the face partially overlaps with the screen
F32 LLFace::adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius )
{
F32 screen_radius = (F32)llmax(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()) ;
F32 screen_radius = (F32)llmax(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()) ;
F32 center_angle = acosf(cos_angle_to_view_dir) ;
F32 d = center_angle * LLDrawable::sCurPixelAngle ;

View File

@@ -339,17 +339,28 @@ void LLSurface::setOriginGlobal(const LLVector3d &origin_global)
}
}
void LLSurface::getNeighboringRegions( std::vector<LLViewerRegion*>& uniqueRegions )
{
S32 i;
for (i = 0; i < 8; i++)
{
if ( mNeighbors[i] != NULL )
{
uniqueRegions.push_back( mNeighbors[i]->getRegion() );
}
}
}
void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
{
S32 i;
LLSurfacePatch *patchp, *neighbor_patchp;
if (gNoRender)
{
return;
}
S32 i;
LLSurfacePatch *patchp, *neighbor_patchp;
mNeighbors[direction] = neighborp;
neighborp->mNeighbors[gDirOpposite[direction]] = this;

View File

@@ -146,6 +146,9 @@ public:
friend class LLSurfacePatch;
friend std::ostream& operator<<(std::ostream &s, const LLSurface &S);
void getNeighboringRegions( std::vector<LLViewerRegion*>& uniqueRegions );
public:
// Number of grid points on one side of a region, including +1 buffer for
// north and east edge.

View File

@@ -266,11 +266,17 @@ BOOL LLTexLayerSetBuffer::render()
BOOL upload_now = needsUploadNow();
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)

View File

@@ -649,6 +649,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
&& 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
@@ -680,7 +681,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
LLGLState::checkTextureChannels();
LLGLState::checkClientArrays();
BOOL to_texture = gPipeline.canUseVertexShaders() && LLPipeline::sRenderGlow;
BOOL to_texture = gPipeline.canUseVertexShaders() &&
LLPipeline::sRenderGlow;
LLAppViewer::instance()->pingMainloopTimeout("Display:Swap");
@@ -739,12 +741,18 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
LLGLState::checkStates();
LLGLState::checkClientArrays();
if (!for_snapshot || tiling)
{
LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery");
gPipeline.generateWaterReflection(*LLViewerCamera::getInstance());
}
LLGLState::checkStates();
LLGLState::checkClientArrays();
//////////////////////////////////////
//
// Update images, using the image stats generated during object update/culling
@@ -774,6 +782,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
stop_glerror();
}
llpushcallstacks ;
LLGLState::checkStates();
LLGLState::checkClientArrays();
///////////////////////////////////
//
// StateSort
@@ -802,6 +812,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
}
}
LLGLState::checkStates();
LLGLState::checkClientArrays();
LLPipeline::sUseOcclusion = occlusion;
{
@@ -862,6 +875,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE;
LLPipeline::updateRenderDeferred();
LLGLState::checkStates();
LLGLState::checkClientArrays();
stop_glerror();
if (to_texture)
@@ -910,6 +926,14 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
stop_glerror();
}
for (U32 i = 0; i < (U32)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)
@@ -1031,7 +1055,6 @@ void render_hud_attachments()
S32 use_occlusion = LLPipeline::sUseOcclusion;
LLPipeline::sUseOcclusion = 0;
LLPipeline::sDisableShaders = TRUE;
//cull, sort, and render hud objects
static LLCullResult result;
@@ -1060,6 +1083,7 @@ void render_hud_attachments()
gPipeline.renderGeom(hud_cam);
LLSpatialGroup::sNoDelete = FALSE;
//gPipeline.clearReferences();
render_hud_elements();
@@ -1071,7 +1095,6 @@ void render_hud_attachments()
gPipeline.toggleRenderDebugFeature((void*) LLPipeline::RENDER_DEBUG_FEATURE_UI);
}
LLPipeline::sUseOcclusion = use_occlusion;
LLPipeline::sDisableShaders = FALSE;
}
glMatrixMode(GL_PROJECTION);
glPopMatrix();
@@ -1084,20 +1107,20 @@ void render_hud_attachments()
LLRect get_whole_screen_region()
{
LLRect whole_screen = gViewerWindow->getVirtualWindowRect();
LLRect whole_screen = gViewerWindow->getWorldViewRectScaled();
// apply camera zoom transform (for high res screenshots)
F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor();
S16 sub_region = LLViewerCamera::getInstance()->getZoomSubRegion();
if (zoom_factor > 1.f)
{
S32 num_horizontal_tiles = llceil(zoom_factor);
S32 tile_width = llround((F32)gViewerWindow->getWindowWidth() / zoom_factor);
S32 tile_height = llround((F32)gViewerWindow->getWindowHeight() / zoom_factor);
S32 tile_width = llround((F32)gViewerWindow->getWorldViewWidthScaled() / zoom_factor);
S32 tile_height = llround((F32)gViewerWindow->getWorldViewHeightScaled() / zoom_factor);
int tile_y = sub_region / num_horizontal_tiles;
int tile_x = sub_region - (tile_y * num_horizontal_tiles);
whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWindowHeight() - (tile_y * tile_height), tile_width, tile_height);
whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWorldViewHeightScaled() - (tile_y * tile_height), tile_width, tile_height);
}
return whole_screen;
}
@@ -1116,14 +1139,14 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat
proj.element(2,2) = -0.01f;
F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect();
glh::matrix4f mat;
F32 scale_x = (F32)gViewerWindow->getWindowWidth() / (F32)screen_region.getWidth();
F32 scale_y = (F32)gViewerWindow->getWindowHeight() / (F32)screen_region.getHeight();
F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth();
F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight();
mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f));
mat.set_translate(
glh::vec3f(clamp_rescale((F32)screen_region.getCenterX(), 0.f, (F32)gViewerWindow->getWindowWidth(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
clamp_rescale((F32)screen_region.getCenterY(), 0.f, (F32)gViewerWindow->getWindowHeight(), 0.5f * scale_y, -0.5f * scale_y),
glh::vec3f(clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
0.f));
proj *= mat;
@@ -1375,19 +1398,19 @@ void render_ui_2d()
int pos_y = sub_region / llceil(zoom_factor);
int pos_x = sub_region - (pos_y*llceil(zoom_factor));
// offset for this tile
LLFontGL::sCurOrigin.mX -= llround((F32)gViewerWindow->getWindowWidth() * (F32)pos_x / zoom_factor);
LLFontGL::sCurOrigin.mY -= llround((F32)gViewerWindow->getWindowHeight() * (F32)pos_y / zoom_factor);
LLFontGL::sCurOrigin.mX -= llround((F32)gViewerWindow->getWindowWidthScaled() * (F32)pos_x / zoom_factor);
LLFontGL::sCurOrigin.mY -= llround((F32)gViewerWindow->getWindowHeightScaled() * (F32)pos_y / zoom_factor);
}
stop_glerror();
gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
//gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
// render outline for HUD
if (gAgent.getAvatarObject() && gAgentCamera.mHUDCurZoom < 0.98f)
if (isAgentAvatarValid() && gAgentCamera.mHUDCurZoom < 0.98f)
{
gGL.pushMatrix();
S32 half_width = (gViewerWindow->getWindowWidth() / 2);
S32 half_height = (gViewerWindow->getWindowHeight() / 2);
S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2);
S32 half_height = (gViewerWindow->getWorldViewHeightScaled() / 2);
glScalef(LLUI::sGLScaleFactor.mV[0], LLUI::sGLScaleFactor.mV[1], 1.f);
glTranslatef((F32)half_width, (F32)half_height, 0.f);
F32 zoom = gAgentCamera.mHUDCurZoom;
@@ -1455,8 +1478,8 @@ void render_disconnected_background()
}
// Make sure the progress view always fills the entire window.
S32 width = gViewerWindow->getWindowWidth();
S32 height = gViewerWindow->getWindowHeight();
S32 width = gViewerWindow->getWindowWidthScaled();
S32 height = gViewerWindow->getWindowHeightScaled();
if (gDisconnectedImagep)
{

View File

@@ -72,6 +72,14 @@ LLVector4 gShinyOrigin;
LLGLSLShader gWLSkyProgram(LLViewerShaderMgr::SHADER_WINDLIGHT);
LLGLSLShader gWLCloudProgram(LLViewerShaderMgr::SHADER_WINDLIGHT);
//utility shaders
LLGLSLShader gOcclusionProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gCustomAlphaProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gGlowCombineProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gTwoTextureAddProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gUIProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gSolidColorProgram(LLViewerShaderMgr::SHADER_INTERFACE);
//object shaders
LLGLSLShader gObjectSimpleProgram(LLViewerShaderMgr::SHADER_OBJECT);
LLGLSLShader gObjectSimpleWaterProgram(LLViewerShaderMgr::SHADER_OBJECT);
@@ -82,6 +90,7 @@ LLGLSLShader gObjectFullbrightShinyProgram(LLViewerShaderMgr::SHADER_OBJECT);
LLGLSLShader gObjectFullbrightShinyWaterProgram(LLViewerShaderMgr::SHADER_OBJECT);
LLGLSLShader gObjectShinyProgram(LLViewerShaderMgr::SHADER_OBJECT);
LLGLSLShader gObjectShinyWaterProgram(LLViewerShaderMgr::SHADER_OBJECT);
LLGLSLShader gObjectBumpProgram(LLViewerShaderMgr::SHADER_OBJECT);
LLGLSLShader gObjectSimpleNonIndexedProgram(LLViewerShaderMgr::SHADER_OBJECT);
LLGLSLShader gObjectSimpleNonIndexedWaterProgram(LLViewerShaderMgr::SHADER_OBJECT);
@@ -164,8 +173,12 @@ LLGLSLShader gDeferredGIFinalProgram(LLViewerShaderMgr::SHADER_DEFERRED);
LLGLSLShader gDeferredPostGIProgram(LLViewerShaderMgr::SHADER_DEFERRED);
LLGLSLShader gDeferredPostProgram(LLViewerShaderMgr::SHADER_DEFERRED);
LLGLSLShader gDeferredPostNoDoFProgram(LLViewerShaderMgr::SHADER_DEFERRED);
LLGLSLShader gDeferredWLSkyProgram(LLViewerShaderMgr::SHADER_DEFERRED);
LLGLSLShader gDeferredWLCloudProgram(LLViewerShaderMgr::SHADER_DEFERRED);
LLGLSLShader gDeferredStarProgram(LLViewerShaderMgr::SHADER_DEFERRED);
LLGLSLShader gLuminanceGatherProgram(LLViewerShaderMgr::SHADER_DEFERRED);
//current avatar shader parameter pointer
GLint gAvatarMatrixParam;
@@ -367,9 +380,13 @@ void LLViewerShaderMgr::setShaders()
}
mMaxAvatarShaderLevel = 0;
LLGLSLShader::sNoFixedFunction = false;
if (LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable")
&& gSavedSettings.getBOOL("VertexShaderEnable"))
{
//using shaders, disable fixed function
static const LLCachedControl<bool> renderforcefixedfuncs("ShyotlUseLegacyRenderPath",false);
LLGLSLShader::sNoFixedFunction = !renderforcefixedfuncs;
S32 light_class = 2;
S32 env_class = 2;
S32 obj_class = 2;
@@ -511,6 +528,7 @@ void LLViewerShaderMgr::setShaders()
}
else
{
LLGLSLShader::sNoFixedFunction = false;
gPipeline.mVertexShadersEnabled = FALSE;
gPipeline.mVertexShadersLoaded = 0;
for (S32 i = 0; i < SHADER_COUNT; i++)
@@ -527,6 +545,7 @@ void LLViewerShaderMgr::setShaders()
}
else
{
LLGLSLShader::sNoFixedFunction = false;
gPipeline.mVertexShadersEnabled = FALSE;
gPipeline.mVertexShadersLoaded = 0;
for (S32 i = 0; i < SHADER_COUNT; i++)
@@ -1224,6 +1243,40 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
success = gDeferredPostNoDoFProgram.createShader(NULL, NULL);
}
if (success)
{
gDeferredWLSkyProgram.mName = "Deferred Windlight Sky Shader";
//gWLSkyProgram.mFeatures.hasGamma = true;
gDeferredWLSkyProgram.mShaderFiles.clear();
gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gDeferredWLSkyProgram.createShader(NULL, &mWLUniforms);
}
if (success)
{
gDeferredWLCloudProgram.mName = "Deferred Windlight Cloud Program";
gDeferredWLCloudProgram.mShaderFiles.clear();
gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gDeferredWLCloudProgram.createShader(NULL, &mWLUniforms);
}
if (success)
{
gDeferredStarProgram.mName = "Deferred Star Program";
gDeferredStarProgram.mShaderFiles.clear();
gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredStarProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gDeferredStarProgram.createShader(NULL, &mWLUniforms);
}
if (mVertexShaderLevel[SHADER_DEFERRED] > 1)
{
if (success)
@@ -1450,6 +1503,22 @@ BOOL LLViewerShaderMgr::loadShadersObject()
success = gObjectSimpleProgram.createShader(NULL, NULL);
}
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";
@@ -1833,6 +1902,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;

View File

@@ -305,6 +305,14 @@ inline bool operator != (LLViewerShaderMgr::shader_iter const & a, LLViewerShade
extern LLVector4 gShinyOrigin;
//utility shaders
extern LLGLSLShader gOcclusionProgram;
extern LLGLSLShader gCustomAlphaProgram;
extern LLGLSLShader gGlowCombineProgram;
//output tex0[tc0] + tex1[tc1]
extern LLGLSLShader gTwoTextureAddProgram;
//object shaders
extern LLGLSLShader gObjectSimpleProgram;
extern LLGLSLShader gObjectSimpleWaterProgram;
@@ -314,6 +322,7 @@ extern LLGLSLShader gObjectFullbrightProgram;
extern LLGLSLShader gObjectFullbrightWaterProgram;
extern LLGLSLShader gObjectFullbrightNonIndexedProgram;
extern LLGLSLShader gObjectFullbrightNonIndexedWaterProgram;
extern LLGLSLShader gObjectBumpProgram;
extern LLGLSLShader gObjectSimpleLODProgram;
extern LLGLSLShader gObjectFullbrightLODProgram;
@@ -401,7 +410,9 @@ extern LLGLSLShader gDeferredAttachmentShadowProgram;
extern LLGLSLShader gDeferredAlphaProgram;
extern LLGLSLShader gDeferredFullbrightProgram;
extern LLGLSLShader gDeferredAvatarAlphaProgram;
extern LLGLSLShader gDeferredWLSkyProgram;
extern LLGLSLShader gDeferredWLCloudProgram;
extern LLGLSLShader gDeferredStarProgram;
extern LLGLSLShader gLuminanceGatherProgram;
//current avatar shader parameter pointer

View File

@@ -125,7 +125,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();
@@ -677,10 +677,7 @@ void LLViewerTextureList::updateImagesDecodePriorities()
const F32 LAZY_FLUSH_TIMEOUT = 30.f; // stop decoding
const F32 MAX_INACTIVE_TIME = 50.f; // actually delete
S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference
if (imagep->hasCallbacks())
{
min_refs++; // Add an extra reference if we're on the loaded callback list
}
S32 num_refs = imagep->getNumRefs();
if (num_refs == min_refs)
{

View File

@@ -2401,6 +2401,10 @@ 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();
{
// scale view by UI global scale factor and aspect ratio correction factor
@@ -2492,6 +2496,10 @@ void LLViewerWindow::draw()
}
gGL.popMatrix();
if (LLGLSLShader::sNoFixedFunction)
{
gUIProgram.unbind();
}
#if LL_DEBUG
LLView::sIsDrawing = FALSE;
#endif

View File

@@ -193,12 +193,27 @@ public:
const LLRect& getWindowRect() const { return mWindowRect; };
S32 getWindowDisplayHeight() const;
S32 getWindowDisplayWidth() const;
//Temporary wrappers.
const LLRect& getWindowRectRaw() const { return getWindowRect(); }
S32 getWindowHeightRaw() const { return getWindowDisplayHeight(); }
S32 getWindowWidthRaw() const { return getWindowDisplayWidth(); }
const LLRect& getWorldviewRectRaw() const { return getWindowRect(); }
S32 getWorldViewHeightRaw() const { return getWindowDisplayHeight(); }
S32 getWorldViewWidthRaw() const { return getWindowDisplayWidth(); }
// Window in scaled pixels (via UI scale), use this for
// UI elements checking size.
const LLRect& getVirtualWindowRect() const { return mVirtualWindowRect; };
S32 getWindowHeight() const;
S32 getWindowWidth() const;
//Temporary wrappers.
const LLRect& getWindowRectScaled() const { return getVirtualWindowRect(); }
S32 getWindowHeightScaled() const { return getWindowHeight(); };
S32 getWindowWidthScaled() const { return getWindowWidth(); };
const LLRect& getWorldViewRectScaled() const { return getVirtualWindowRect(); }
S32 getWorldViewHeightScaled() const { return getWindowHeight(); };
S32 getWorldViewWidthScaled() const { return getWindowWidth(); };
LLWindow* getWindow() const { return mWindow; }
void* getPlatformWindow() const { return mWindow->getPlatformWindow(); }

View File

@@ -3515,10 +3515,10 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
{
LLDrawable* drawablep = *drawable_iter;
if (drawablep->isState(LLDrawable::FORCE_INVISIBLE) )
/*if (drawablep->isState(LLDrawable::FORCE_INVISIBLE) )
{
continue;
}
}*/
if (!drawablep->isDead() && drawablep->isState(LLDrawable::REBUILD_ALL) )
{

View File

@@ -312,10 +312,12 @@ static const U32 gl_cube_face[] =
void validate_framebuffer_object();
void addDeferredAttachments(LLRenderTarget& target)
bool addDeferredAttachments(LLRenderTarget& target)
{
target.addColorAttachment(GL_RGBA); //specular
target.addColorAttachment(GL_RGBA); //normal+z
bool ret1 = target.addColorAttachment(GL_RGBA);
bool ret2 = target.addColorAttachment(GL_RGBA);
return ret1 && //specular
ret2; //normal+z
}
LLPipeline::LLPipeline() :
@@ -529,8 +531,8 @@ void LLPipeline::resizeScreenTexture()
{
if (gPipeline.canUseVertexShaders() && assertInitialized())
{
GLuint resX = gViewerWindow->getWindowDisplayWidth();
GLuint resY = gViewerWindow->getWindowDisplayHeight();
GLuint resX = gViewerWindow->getWorldViewWidthRaw();
GLuint resY = gViewerWindow->getWorldViewHeightRaw();
allocateScreenBuffer(resX,resY);
}
@@ -539,6 +541,49 @@ void LLPipeline::resizeScreenTexture()
void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
{
U32 samples = gSavedSettings.getU32("RenderFSAASamples");
//try to allocate screen buffers at requested resolution and samples
// - on failure, shrink number of samples and try again
// - if not multisampled, shrink resolution and try again (favor X resolution over Y)
// Make sure to call "releaseScreenBuffers" after each failure to cleanup the partially loaded state
if (!allocateScreenBuffer(resX, resY, samples))
{
releaseScreenBuffers();
//reduce number of samples
while (samples > 0)
{
samples /= 2;
if (allocateScreenBuffer(resX, resY, samples))
{ //success
return;
}
releaseScreenBuffers();
}
//reduce resolution
while (resY > 0 && resX > 0)
{
resY /= 2;
if (allocateScreenBuffer(resX, resY, samples))
{
return;
}
releaseScreenBuffers();
resX /= 2;
if (allocateScreenBuffer(resX, resY, samples))
{
return;
}
releaseScreenBuffers();
}
llwarns << "Unable to allocate screen buffer at any resolution!" << llendl;
}
}
bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
{
U32 res_mod = gSavedSettings.getU32("RenderResolutionDivisor");
if (res_mod > 1 && res_mod < resX && res_mod < resY)
{
@@ -556,22 +601,22 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
//allocate deferred rendering color buffers
static const LLCachedControl<bool> shadow_precision("DeferredHighPrecision",true);
const GLuint format = shadow_precision ? GL_RGBA : GL_RGBA16F_ARB; //TO-DO: Profile 16bit format later
mDeferredScreen.allocate(resX, resY, format, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
addDeferredAttachments(mDeferredScreen);
if (!mDeferredScreen.allocate(resX, resY, format, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!addDeferredAttachments(mDeferredScreen)) return false;
mScreen.allocate(resX, resY, format, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
if (!mScreen.allocate(resX, resY, format, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
#if LL_DARWIN
// As of OS X 10.6.7, Apple doesn't support multiple color formats in a single FBO
mEdgeMap.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
if (!mEdgeMap.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
#else
mEdgeMap.allocate(resX, resY, GL_ALPHA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
if (!mEdgeMap.allocate(resX, resY, GL_ALPHA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
#endif
if (shadow_detail > 0 || ssao)
{ //only need mDeferredLight[0] for shadows OR ssao
mDeferredLight[0].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
if (!mDeferredLight[0].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
}
else
{
@@ -580,7 +625,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
if (ssao || gi)
{ //only need mDeferredLight[1] for ssao... and GI
mDeferredLight[1].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
if (!mDeferredLight[1].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
}
else
{
@@ -589,14 +634,14 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
if (gi)
{ //only need mDeferredLight[2] and mGIMapPost for gi
mDeferredLight[2].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
if (!mDeferredLight[2].allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
for (U32 i = 0; i < 2; i++)
{
#if LL_DARWIN
// As of OS X 10.6.7, Apple doesn't support multiple color formats in a single FBO
mGIMapPost[i].allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
if (!mGIMapPost[i].allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
#else
mGIMapPost[i].allocate(resX,resY, GL_RGB, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
if (!mGIMapPost[i].allocate(resX,resY, GL_RGB, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
#endif
}
}
@@ -624,7 +669,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
{ //allocate 4 sun shadow maps
for (U32 i = 0; i < 4; i++)
{
mShadow[i].allocate(U32(resX*scale),U32(resY*scale), shadow_fmt, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE);
if (!mShadow[i].allocate(U32(resX*scale),U32(resY*scale), shadow_fmt, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
}
}
else
@@ -642,7 +687,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
{ //allocate two spot shadow maps
for (U32 i = 4; i < 6; i++)
{
mShadow[i].allocate(width, height, shadow_fmt, TRUE, FALSE);
if (!mShadow[i].allocate(width, height, shadow_fmt, TRUE, FALSE)) return false;
}
}
else
@@ -655,7 +700,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
width = nhpo2(resX)/2;
height = nhpo2(resY)/2;
mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE);
if (!mLuminanceMap.allocate(width,height, GL_RGBA, FALSE, FALSE)) return false;
}
else
{
@@ -677,7 +722,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
mEdgeMap.release();
mLuminanceMap.release();
mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
if (!mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
}
@@ -687,14 +732,14 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
{
static const LLCachedControl<bool> shadow_precision("DeferredHighPrecision",true);
const GLuint format = shadow_precision ? GL_RGBA : GL_RGBA16F_ARB; //TO-DO: Profile 16bit format later
mSampleBuffer.allocate(resX,resY,format,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples);
addDeferredAttachments(mSampleBuffer);
if (!mSampleBuffer.allocate(resX,resY,format,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples)) return false;
if (!addDeferredAttachments(mSampleBuffer))return false;
mDeferredScreen.setSampleBuffer(&mSampleBuffer);
mEdgeMap.setSampleBuffer(&mSampleBuffer);
}
else
{
mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples);
if(!mSampleBuffer.allocate(resX,resY,GL_RGBA,TRUE,TRUE,LLTexUnit::TT_RECT_TEXTURE,FALSE,samples)) return false;;
}
mScreen.setSampleBuffer(&mSampleBuffer);
@@ -722,6 +767,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
stop_glerror();
return true;
}
//static
@@ -764,6 +810,19 @@ void LLPipeline::releaseGLBuffers()
mWaterRef.release();
mWaterDis.release();
for (U32 i = 0; i < 3; i++)
{
mGlow[i].release();
}
releaseScreenBuffers();
LLVOAvatar::resetImpostors();
}
void LLPipeline::releaseScreenBuffers()
{
mScreen.release();
mSampleBuffer.release();
mDeferredScreen.release();
@@ -783,13 +842,6 @@ void LLPipeline::releaseGLBuffers()
{
mShadow[i].release();
}
for (U32 i = 0; i < 3; i++)
{
mGlow[i].release();
}
LLVOAvatar::resetImpostors();
}
void LLPipeline::createGLBuffers()
@@ -809,9 +861,9 @@ void LLPipeline::createGLBuffers()
stop_glerror();
GLuint resX = gViewerWindow->getWindowDisplayWidth();
GLuint resY = gViewerWindow->getWindowDisplayHeight();
GLuint resX = gViewerWindow->getWorldViewWidthRaw();
GLuint resY = gViewerWindow->getWorldViewHeightRaw();
if (LLPipeline::sRenderGlow)
{ //screen space glow buffers
const U32 glow_res = llmax(1,
@@ -1914,6 +1966,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)
{
@@ -1941,12 +2001,16 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
}
}
if (bound_shader)
{
gOcclusionProgram.unbind();
}
camera.disableUserClipPlane();
// Render non-windlight sky.
if (hasRenderType(LLPipeline::RENDER_TYPE_SKY) &&
gSky.mVOSkyp.notNull() &&
gSky.mVOSkyp->mDrawable.notNull())
if (hasRenderType(LLPipeline::RENDER_TYPE_SKY) &&
gSky.mVOSkyp.notNull() &&
gSky.mVOSkyp->mDrawable.notNull())
{
gSky.mVOSkyp->mDrawable->setVisible(camera);
sCull->pushDrawable(gSky.mVOSkyp->mDrawable);
@@ -2069,7 +2133,21 @@ void LLPipeline::doOcclusion(LLCamera& camera)
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
LLGLDisable cull(GL_CULL_FACE);
bool bind_shader = LLGLSLShader::sNoFixedFunction && LLGLSLShader::sCurBoundShader == 0;
if (bind_shader)
{
if (LLPipeline::sShadowRender)
{
gDeferredShadowProgram.bind();
}
else
{
gOcclusionProgram.bind();
}
}
for (LLCullResult::sg_list_t::iterator iter = sCull->beginOcclusionGroups(); iter != sCull->endOcclusionGroups(); ++iter)
{
LLSpatialGroup* group = *iter;
@@ -2077,6 +2155,18 @@ void LLPipeline::doOcclusion(LLCamera& camera)
group->clearOcclusionState(LLSpatialGroup::ACTIVE_OCCLUSION);
}
if (bind_shader)
{
if (LLPipeline::sShadowRender)
{
gDeferredShadowProgram.unbind();
}
else
{
gOcclusionProgram.unbind();
}
}
gGL.setColorMask(true, false);
}
}
@@ -3205,6 +3295,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();
}
static const LLCachedControl<U32> fsaa_samples("RenderFSAASamples",0);
LLGLEnable multisample(fsaa_samples > 0 ? GL_MULTISAMPLE_ARB : 0);
gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d()
@@ -3219,6 +3314,10 @@ void render_hud_elements()
// Render name tags.
LLHUDObject::renderAll();
if (LLGLSLShader::sNoFixedFunction)
{
gUIProgram.unbind();
}
}
else if (gForceRenderLandFence)
{
@@ -3354,14 +3453,6 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
LLAppViewer::instance()->pingMainloopTimeout("Pipeline:ForceVBO");
//by bao
//fake vertex buffer updating
//to guaranttee at least updating one VBO buffer every frame
//to walk around the bug caused by ATI card --> DEV-3855
//
//if(forceVBOUpdate)
// gSky.mVOSkyp->updateDummyVertexBuffer() ;
gFrameStats.start(LLFrameStats::RENDER_GEOM);
// Initialize lots of GL state to "safe" values
@@ -3574,8 +3665,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)
@@ -3881,6 +3972,8 @@ void LLPipeline::renderDebug()
glLoadMatrixd(gGLModelView);
gGL.setColorMask(true, false);
bool hud_only = hasRenderType(LLPipeline::RENDER_TYPE_HUD);
// Debug stuff.
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
@@ -3891,7 +3984,8 @@ void LLPipeline::renderDebug()
LLSpatialPartition* part = region->getSpatialPartition(i);
if (part)
{
if (hasRenderType(part->mDrawableType))
if ( hud_only && (part->mDrawableType == RENDER_TYPE_HUD || part->mDrawableType == RENDER_TYPE_HUD_PARTICLES) ||
!hud_only && hasRenderType(part->mDrawableType) )
{
part->renderDebug();
}
@@ -4907,12 +5001,14 @@ void LLPipeline::enableLights(U32 mask)
}
if (mLightMask != mask)
{
stop_glerror();
if (!mLightMask)
{
glEnable(GL_LIGHTING);
}
if (mask)
{
stop_glerror();
for (S32 i=0; i<8; i++)
{
LLLightState* light = gGL.getLight(i);
@@ -4927,14 +5023,17 @@ void LLPipeline::enableLights(U32 mask)
light->setDiffuse(LLColor4::black);
}
}
stop_glerror();
}
else
{
glDisable(GL_LIGHTING);
}
stop_glerror();
mLightMask = mask;
LLColor4 ambient = gSky.getTotalAmbientColor();
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambient.mV);
stop_glerror();
}
}
@@ -5003,7 +5102,7 @@ void LLPipeline::enableLightsFullbright(const LLColor4& color)
void LLPipeline::disableLights()
{
enableLights(0); // no lighting (full bright)
glColor4f(1.f, 1.f, 1.f, 1.f);
// glColor4f(1.f, 1.f, 1.f, 1.f);
}
//============================================================================
@@ -5817,8 +5916,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
static const LLCachedControl<U32> res_mod("RenderResolutionDivisor",1);
LLVector2 tc1(0,0);
LLVector2 tc2((F32) gViewerWindow->getWindowDisplayWidth()*2,
(F32) gViewerWindow->getWindowDisplayHeight()*2);
LLVector2 tc2((F32) gViewerWindow->getWorldViewWidthRaw()*2,
(F32) gViewerWindow->getWorldViewHeightRaw()*2);
if (res_mod > 1)
{
@@ -6021,8 +6120,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
gViewerWindow->setupViewport();
tc2.setVec((F32) gViewerWindow->getWindowDisplayWidth(),
(F32) gViewerWindow->getWindowDisplayHeight());
tc2.setVec((F32) gViewerWindow->getWorldViewWidthRaw(),
(F32) gViewerWindow->getWorldViewHeightRaw());
gGL.flush();
@@ -6225,19 +6324,20 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
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();
static const LLCachedControl<U32> fsaa_samples("RenderFSAASamples",0);
LLGLEnable multisample(fsaa_samples > 0 ? GL_MULTISAMPLE_ARB : 0);
@@ -6245,11 +6345,19 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
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)
@@ -7158,8 +7266,9 @@ void LLPipeline::renderDeferredLighting()
LLFastTimer ftm(LLFastTimer::FTM_LOCAL_LIGHTS);
glTexCoord4f(tc.v[0], tc.v[1], tc.v[2], s*s);
glColor4f(col.mV[0], col.mV[1], col.mV[2], volume->getLightFalloff()*0.5f);
glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8,
GL_UNSIGNED_BYTE, get_box_fan_indices_ptr(camera, center));
glDrawRangeElements(GL_TRIANGLE_FAN, 0, 7, 8,
GL_UNSIGNED_BYTE, get_box_fan_indices_ptr(camera, center));
stop_glerror();
}
}
else
@@ -7527,18 +7636,27 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
LLViewerTexture* img = volume->getLightTexture();
if (img == NULL)
{
img = LLViewerFetchedTexture::sWhiteImagep;
}
S32 channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_PROJECTION);
if (channel > -1 && img)
if (channel > -1)
{
gGL.getTexUnit(channel)->bind(img);
if (img)
{
gGL.getTexUnit(channel)->bind(img);
F32 lod_range = logf(img->getWidth())/logf(2.f);
F32 lod_range = logf(img->getWidth())/logf(2.f);
shader.uniform1f("proj_focus", focus);
shader.uniform1f("proj_lod", lod_range);
shader.uniform1f("proj_ambient_lod", llclamp((proj_range-focus)/proj_range*lod_range, 0.f, 1.f));
shader.uniform1f("proj_focus", focus);
shader.uniform1f("proj_lod", lod_range);
shader.uniform1f("proj_ambient_lod", llclamp((proj_range-focus)/proj_range*lod_range, 0.f, 1.f));
}
}
}
void LLPipeline::unbindDeferredShader(LLGLSLShader &shader)
@@ -7601,7 +7719,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader)
gGL.getTexUnit(0)->activate();
shader.unbind();
LLGLState::checkTextureChannels();
//LLGLState::checkTextureChannels();
}
inline float sgn(float a)
@@ -7710,7 +7828,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
static LLCullResult ref_result;
if (LLDrawPoolWater::sNeedsDistortionUpdate)
if (LLDrawPoolWater::sNeedsReflectionUpdate)
{
//initial sky pass (no user clip plane)
{ //mask out everything but the sky
@@ -7974,6 +8092,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(LLFastTimer::FTM_SHADOW_SIMPLE);
LLGLDisable test(GL_ALPHA_TEST);
gGL.getTexUnit(0)->disable();
@@ -7982,6 +8104,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)
@@ -9247,7 +9373,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
glClearStencil(0);
// get the number of pixels per angle
F32 pa = gViewerWindow->getWindowDisplayHeight() / (RAD_TO_DEG * LLViewerCamera::getInstance()->getView());
F32 pa = gViewerWindow->getWindowHeightRaw() / (RAD_TO_DEG * viewer_camera->getView());
//get resolution based on angle width and height of impostor (double desired resolution to prevent aliasing)
U32 resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512);

View File

@@ -91,8 +91,11 @@ public:
void resetVertexBuffers();
void resizeScreenTexture();
void releaseGLBuffers();
void releaseScreenBuffers();
void createGLBuffers();
void allocateScreenBuffer(U32 resX, U32 resY);
bool allocateScreenBuffer(U32 resX, U32 resY, U32 samples);
void resetVertexBuffers(LLDrawable* drawable);
void setUseVBO(BOOL use_vbo);