summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-08-22 11:19:04 -0700
committerGraham Linden <graham@lindenlab.com>2019-08-22 11:19:04 -0700
commit8960a56f531745bc2d434bdddb6c65731621f596 (patch)
treecab06c1e1e12745db2abaab96ec525adc8209ad9 /indra/newview
parent440a40c8f9fd35577470aee193a4b7dd128d80bb (diff)
SL-11776
Fix false alarming sky updates and doing expensive CPU work for same sky pixels.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/lllegacyatmospherics.cpp117
-rw-r--r--indra/newview/lllegacyatmospherics.h111
-rw-r--r--indra/newview/llviewershadermgr.cpp2
-rw-r--r--indra/newview/llvosky.cpp140
-rw-r--r--indra/newview/llvosky.h3
5 files changed, 190 insertions, 183 deletions
diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp
index 720c7e2388..a1093df7e1 100644
--- a/indra/newview/lllegacyatmospherics.cpp
+++ b/indra/newview/lllegacyatmospherics.cpp
@@ -242,8 +242,10 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto
calcSkyColorWLVert(Pn, vars);
+ bool low_end = !gPipeline.canUseWindLightShaders();
+
LLColor3 sky_color = isShiny ? vars.hazeColor :
- !gPipeline.canUseWindLightShaders() ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f);
+ low_end ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f);
if (isShiny)
{
@@ -443,8 +445,8 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in)
vars.distance_multiplier = psky->getDistanceMultiplier();
vars.max_y = psky->getMaxY();
vars.sun_norm = LLEnvironment::instance().getSunDirectionCFR();
- vars.sunlight = psky->getSunlightColor();
- vars.ambient = psky->getAmbientColor();
+ vars.sunlight = psky->getSunlightColorClamped();
+ vars.ambient = psky->getAmbientColorClamped();
vars.glow = psky->getGlow();
vars.cloud_shadow = psky->getCloudShadow();
vars.dome_radius = psky->getDomeRadius();
@@ -605,3 +607,112 @@ F32 azimuth(const LLVector3 &v)
}
return azimuth;
}
+
+bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b)
+{
+ if (a.hazeColor != b.hazeColor)
+ {
+ return false;
+ }
+
+ if (a.hazeColorBelowCloud != b.hazeColorBelowCloud)
+ {
+ return false;
+ }
+
+ if (a.cloudColorSun != b.cloudColorSun)
+ {
+ return false;
+ }
+
+ if (a.cloudColorAmbient != b.cloudColorAmbient)
+ {
+ return false;
+ }
+
+ if (a.cloudDensity != b.cloudDensity)
+ {
+ return false;
+ }
+
+ if (a.density_multiplier != b.density_multiplier)
+ {
+ return false;
+ }
+
+ if (a.haze_horizon != b.haze_horizon)
+ {
+ return false;
+ }
+
+ if (a.haze_density != b.haze_density)
+ {
+ return false;
+ }
+
+ if (a.blue_horizon != b.blue_horizon)
+ {
+ return false;
+ }
+
+ if (a.blue_density != b.blue_density)
+ {
+ return false;
+ }
+
+ if (a.dome_offset != b.dome_offset)
+ {
+ return false;
+ }
+
+ if (a.dome_radius != b.dome_radius)
+ {
+ return false;
+ }
+
+ if (a.cloud_shadow != b.cloud_shadow)
+ {
+ return false;
+ }
+
+ if (a.glow != b.glow)
+ {
+ return false;
+ }
+
+ if (a.ambient != b.ambient)
+ {
+ return false;
+ }
+
+ if (a.sunlight != b.sunlight)
+ {
+ return false;
+ }
+
+ if (a.sun_norm != b.sun_norm)
+ {
+ return false;
+ }
+
+ if (a.gamma != b.gamma)
+ {
+ return false;
+ }
+
+ if (a.max_y != b.max_y)
+ {
+ return false;
+ }
+
+ if (a.distance_multiplier != b.distance_multiplier)
+ {
+ return false;
+ }
+
+ // light_atten, light_transmittance, total_density
+ // are ignored as they always change when the values above do
+ // they're just shared calc across the sky map generation to save cycles
+
+ return true;
+}
diff --git a/indra/newview/lllegacyatmospherics.h b/indra/newview/lllegacyatmospherics.h
index 95700227f9..cdfcead7a4 100644
--- a/indra/newview/lllegacyatmospherics.h
+++ b/indra/newview/lllegacyatmospherics.h
@@ -206,7 +206,7 @@ public:
{
}
- LL_FORCE_INLINE friend bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b);
+ friend bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b);
LLColor3 hazeColor;
LLColor3 hazeColorBelowCloud;
@@ -233,115 +233,6 @@ public:
LLColor3 total_density;
};
-bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b)
-{
- if (a.hazeColor != b.hazeColor)
- {
- return false;
- }
-
- if (a.hazeColorBelowCloud != b.hazeColorBelowCloud)
- {
- return false;
- }
-
- if (a.cloudColorSun != b.cloudColorSun)
- {
- return false;
- }
-
- if (a.cloudColorAmbient != b.cloudColorAmbient)
- {
- return false;
- }
-
- if (a.cloudDensity != b.cloudDensity)
- {
- return false;
- }
-
- if (a.density_multiplier != b.density_multiplier)
- {
- return false;
- }
-
- if (a.haze_horizon != b.haze_horizon)
- {
- return false;
- }
-
- if (a.haze_density != b.haze_density)
- {
- return false;
- }
-
- if (a.blue_horizon != b.blue_horizon)
- {
- return false;
- }
-
- if (a.blue_density != b.blue_density)
- {
- return false;
- }
-
- if (a.dome_offset != b.dome_offset)
- {
- return false;
- }
-
- if (a.dome_radius != b.dome_radius)
- {
- return false;
- }
-
- if (a.cloud_shadow != b.cloud_shadow)
- {
- return false;
- }
-
- if (a.glow != b.glow)
- {
- return false;
- }
-
- if (a.ambient != b.ambient)
- {
- return false;
- }
-
- if (a.sunlight != b.sunlight)
- {
- return false;
- }
-
- if (a.sun_norm != b.sun_norm)
- {
- return false;
- }
-
- if (a.gamma != b.gamma)
- {
- return false;
- }
-
- if (a.max_y != b.max_y)
- {
- return false;
- }
-
- if (a.distance_multiplier != b.distance_multiplier)
- {
- return false;
- }
-
- // light_atten, light_transmittance, total_density
- // are ignored as they always change when the values above do
- // they're just shared calc across the sky map generation to save cycles
-
- return true;
-}
-
class LLAtmospherics
{
public:
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index c874b3cf59..aca236cdfd 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -528,7 +528,7 @@ void LLViewerShaderMgr::setShaders()
}
// Trigger a full rebuild of the fallback skybox / cubemap if we've toggled windlight shaders
- if (mShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull())
+ if (!wl_class || (mShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull()))
{
gSky.mVOSkyp->forceSkyUpdate();
}
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 78c782eb5f..ae63a9921c 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -416,6 +416,7 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
mCloudDensity(0.2f),
mWind(0.f),
mForceUpdate(FALSE),
+ mNeedUpdate(TRUE),
mWorldScale(1.f),
mBumpSunDir(0.f, 0.f, 1.f)
{
@@ -608,7 +609,7 @@ void LLVOSky::restoreGL()
initCubeMap();
}
- mForceUpdate = TRUE;
+ forceSkyUpdate();
if (mDrawable)
{
@@ -690,6 +691,13 @@ void LLVOSky::idleUpdate(LLAgent &agent, const F64 &time)
{
}
+void LLVOSky::forceSkyUpdate()
+{
+ mForceUpdate = TRUE;
+
+ memset(&m_lastAtmosphericsVars, 0x00, sizeof(AtmosphericsVars));
+}
+
bool LLVOSky::updateSky()
{
LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
@@ -718,7 +726,7 @@ bool LLVOSky::updateSky()
const S32 frame = next_frame;
- mForceUpdate = mForceUpdate || (total_no_tiles == frame);
+ mNeedUpdate = mForceUpdate || (total_no_tiles == frame);
++next_frame;
next_frame = next_frame % cycle_frame_no;
@@ -727,10 +735,13 @@ bool LLVOSky::updateSky()
LLHeavenBody::setInterpVal( mInterpVal );
updateDirections();
- LLVector3 direction = mSun.getDirection();
- direction.normalize();
- const F32 dot_sun = direction * mLastSunLightingDirection;
- const F32 dot_moon = direction * mLastMoonLightingDirection;
+ LLVector3 sun_dir = mSun.getDirection();
+ sun_dir.normalize();
+ LLVector3 moon_dir = mMoon.getDirection();
+ moon_dir.normalize();
+
+ const F32 dot_sun = sun_dir * mLastSunLightingDirection;
+ const F32 dot_moon = moon_dir * mLastMoonLightingDirection;
LLColor3 delta_color;
delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0],
@@ -741,10 +752,10 @@ bool LLVOSky::updateSky()
bool moon_direction_changed = (dot_moon < LIGHT_DIRECTION_THRESHOLD);
bool color_changed = (delta_color.length() >= COLOR_CHANGE_THRESHOLD);
- mForceUpdate = mForceUpdate || sun_direction_changed;
- mForceUpdate = mForceUpdate || moon_direction_changed;
- mForceUpdate = mForceUpdate || color_changed;
- mForceUpdate = mForceUpdate || !mInitialized;
+ mNeedUpdate = mNeedUpdate || sun_direction_changed;
+ mNeedUpdate = mNeedUpdate || moon_direction_changed;
+ mNeedUpdate = mNeedUpdate || color_changed;
+ mNeedUpdate = mNeedUpdate || !mInitialized;
bool is_alm_wl_sky = gPipeline.canUseWindLightShaders();
@@ -752,7 +763,7 @@ bool LLVOSky::updateSky()
bool same_atmospherics = m_lastAtmosphericsVars == m_atmosphericsVars;
- if (mForceUpdate && mForceUpdateThrottle.hasExpired() && !same_atmospherics)
+ if (mNeedUpdate && mForceUpdateThrottle.hasExpired() && (mForceUpdate || !same_atmospherics))
{
LL_RECORD_BLOCK_TIME(FTM_VOSKY_UPDATEFORCED);
@@ -762,77 +773,76 @@ bool LLVOSky::updateSky()
m_lastAtmosphericsVars = m_atmosphericsVars;
- if (!direction.isExactlyZero())
+ mLastTotalAmbient = total_ambient;
+ mInitialized = TRUE;
+
+ if (mCubeMap)
{
- mLastTotalAmbient = total_ambient;
- mInitialized = TRUE;
+ updateFog(LLViewerCamera::getInstance()->getFar());
- if (mCubeMap)
+ for (int side = 0; side < 6; side++)
{
- updateFog(LLViewerCamera::getInstance()->getFar());
-
- for (int side = 0; side < 6; side++)
+ for (int tile = 0; tile < NUM_TILES; tile++)
{
- for (int tile = 0; tile < NUM_TILES; tile++)
- {
- createSkyTexture(m_atmosphericsVars, side, tile, mSkyTex);
- createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex, true);
- }
+ createSkyTexture(m_atmosphericsVars, side, tile, mSkyTex);
+ createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex, true);
}
}
+ }
- int tex = mSkyTex[0].getWhich(TRUE);
-
- for (int side = 0; side < 6; side++)
- {
- LLImageRaw* raw1 = nullptr;
- LLImageRaw* raw2 = nullptr;
-
- if (!is_alm_wl_sky)
- {
- raw1 = mSkyTex[side].getImageRaw(TRUE);
- raw2 = mSkyTex[side].getImageRaw(FALSE);
- raw2->copy(raw1);
- mSkyTex[side].createGLImage(tex);
- }
+ int tex = mSkyTex[0].getWhich(TRUE);
- raw1 = mShinyTex[side].getImageRaw(TRUE);
- raw2 = mShinyTex[side].getImageRaw(FALSE);
- raw2->copy(raw1);
- mShinyTex[side].createGLImage(tex);
- }
- next_frame = 0;
+ for (int side = 0; side < 6; side++)
+ {
+ LLImageRaw* raw1 = nullptr;
+ LLImageRaw* raw2 = nullptr;
- // update the sky texture
if (!is_alm_wl_sky)
{
- for (S32 i = 0; i < 6; ++i)
- {
- mSkyTex[i].create(1.0f);
- }
+ raw1 = mSkyTex[side].getImageRaw(TRUE);
+ raw2 = mSkyTex[side].getImageRaw(FALSE);
+ raw2->copy(raw1);
+ mSkyTex[side].createGLImage(tex);
}
- for (S32 i = 0; i < 6; ++i)
+ raw1 = mShinyTex[side].getImageRaw(TRUE);
+ raw2 = mShinyTex[side].getImageRaw(FALSE);
+ raw2->copy(raw1);
+ mShinyTex[side].createGLImage(tex);
+ }
+ next_frame = 0;
+
+ // update the sky texture
+ if (!is_alm_wl_sky)
+ {
+ for (S32 i = 0; i < 6; ++i)
{
- mShinyTex[i].create(1.0f);
+ mSkyTex[i].create(1.0f);
}
+ }
+
+ for (S32 i = 0; i < 6; ++i)
+ {
+ mShinyTex[i].create(1.0f);
+ }
- // update the environment map
- if (mCubeMap)
+ // update the environment map
+ if (mCubeMap)
+ {
+ std::vector<LLPointer<LLImageRaw> > images;
+ images.reserve(6);
+ for (S32 side = 0; side < 6; side++)
{
- std::vector<LLPointer<LLImageRaw> > images;
- images.reserve(6);
- for (S32 side = 0; side < 6; side++)
- {
- images.push_back(mShinyTex[side].getImageRaw(TRUE));
- }
- mCubeMap->init(images);
- gGL.getTexUnit(0)->disable();
- }
+ images.push_back(mShinyTex[side].getImageRaw(TRUE));
+ }
+ mCubeMap->init(images);
+ gGL.getTexUnit(0)->disable();
}
gPipeline.markRebuild(gSky.mVOGroundp->mDrawable, LLDrawable::REBUILD_ALL, TRUE);
- mForceUpdate = FALSE;
+
+ mNeedUpdate = FALSE;
+ mForceUpdate = FALSE;
}
if (mDrawable.notNull() && mDrawable->getFace(0) && !mDrawable->getFace(0)->getVertexBuffer())
@@ -1605,8 +1615,6 @@ void LLVOSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_dir_cfr, const LLV
}
updateDirections();
-
- mForceUpdate = true;
}
void LLVOSky::setSunDirectionCFR(const LLVector3 &sun_dir_cfr)
@@ -1630,8 +1638,6 @@ void LLVOSky::setSunDirectionCFR(const LLVector3 &sun_dir_cfr)
}
updateDirections();
-
- mForceUpdate = true;
}
void LLVOSky::setMoonDirectionCFR(const LLVector3 &moon_dir_cfr)
@@ -1639,6 +1645,4 @@ void LLVOSky::setMoonDirectionCFR(const LLVector3 &moon_dir_cfr)
mMoon.setDirection(moon_dir_cfr);
updateDirections();
-
- mForceUpdate = true;
}
diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h
index 5f27085599..6c9d6dc8be 100644
--- a/indra/newview/llvosky.h
+++ b/indra/newview/llvosky.h
@@ -288,7 +288,7 @@ public:
void setSunScale(F32 sun_scale);
void setMoonScale(F32 sun_scale);
- void forceSkyUpdate(void) { mForceUpdate = TRUE; }
+ void forceSkyUpdate(void);
public:
LLFace *mFace[FACE_COUNT];
@@ -337,6 +337,7 @@ protected:
F32 mWind;
bool mInitialized;
+ bool mNeedUpdate; //flag to mark update being necessary (input has changed)
bool mForceUpdate; //flag to force instantaneous update of cubemap
LLVector3 mLastSunLightingDirection;
LLVector3 mLastMoonLightingDirection;