diff options
author | Graham Linden <graham@lindenlab.com> | 2018-10-02 15:43:03 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-10-02 15:43:03 +0100 |
commit | 17ce10ccd98d4795784466bb217e877ca2d8bad2 (patch) | |
tree | 0081d23ae155c2f872bad595181cfc5af84effb0 | |
parent | b4d6611ea7e5f3dfe01e7c7f7dae9c5b2c2347b8 (diff) |
SL-9687
Make WL sky updates only update the env map (the only map used when WL shaders are in effect)
to reduce the cost of generating sky textures.
Update of env map only is 6ms where sky + env map is 14+ms.
-rw-r--r-- | indra/newview/llvosky.cpp | 45 | ||||
-rw-r--r-- | indra/newview/llvosky.h | 2 |
2 files changed, 34 insertions, 13 deletions
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index a42239ec87..705e382a99 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -477,7 +477,7 @@ void LLVOSky::init() for (S32 tile = 0; tile < NUM_TILES; ++tile) { initSkyTextureDirs(side, tile); - createSkyTexture(vars, side, tile); + createSkyTexture(vars, side, tile, false); } } @@ -603,7 +603,7 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile) } } -void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile) +void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile, bool skip_sky_tex) { S32 tile_x = tile % NUM_TILES_X; S32 tile_y = tile / NUM_TILES_X; @@ -612,11 +612,21 @@ void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 S32 tile_y_pos = tile_y * sTileResY; S32 x, y; + if (!skip_sky_tex) + { + for (y = tile_y_pos; y < (tile_y_pos + sTileResY); ++y) + { + for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x) + { + mSkyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, mSkyTex[side].getDir(x, y)), x, y); + } + } + } + for (y = tile_y_pos; y < (tile_y_pos + sTileResY); ++y) { for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x) { - mSkyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, mSkyTex[side].getDir(x, y)), x, y); mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(vars, mSkyTex[side].getDir(x, y), true), x, y); } } @@ -684,8 +694,6 @@ bool LLVOSky::updateSky() direction.normalize(); const F32 dot_lighting = direction * mLastLightingDirection; - //_WARNS("LAPRAS") << " <" << direction.getValue() << "> dot <" << mLastLightingDirection << "> = " << dot_lighting << " (threshold is " << LIGHT_DIRECTION_THRESHOLD << ")" << LL_ENDL; - LLColor3 delta_color; delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0], mLastTotalAmbient.mV[1] - total_ambient.mV[1], @@ -698,6 +706,8 @@ bool LLVOSky::updateSky() mForceUpdate = mForceUpdate || color_changed; mForceUpdate = mForceUpdate || !mInitialized; + bool is_alm_wl_sky = gPipeline.canUseWindLightShaders(); + if (mForceUpdate && mForceUpdateThrottle.hasExpired()) { LL_RECORD_BLOCK_TIME(FTM_VOSKY_UPDATEFORCED); @@ -741,7 +751,7 @@ bool LLVOSky::updateSky() { for (int tile = 0; tile < NUM_TILES; tile++) { - createSkyTexture(vars, side, tile); + createSkyTexture(vars, side, tile, is_alm_wl_sky); } } @@ -751,10 +761,14 @@ bool LLVOSky::updateSky() { LLImageRaw* raw1 = nullptr; LLImageRaw* raw2 = nullptr; - raw1 = mSkyTex[side].getImageRaw(TRUE); - raw2 = mSkyTex[side].getImageRaw(FALSE); - raw2->copy(raw1); - mSkyTex[side].createGLImage(tex); + + if (!is_alm_wl_sky) + { + raw1 = mSkyTex[side].getImageRaw(TRUE); + raw2 = mSkyTex[side].getImageRaw(FALSE); + raw2->copy(raw1); + mSkyTex[side].createGLImage(tex); + } raw1 = mShinyTex[side].getImageRaw(TRUE); raw2 = mShinyTex[side].getImageRaw(FALSE); @@ -764,9 +778,16 @@ bool LLVOSky::updateSky() next_frame = 0; // update the sky texture - for (S32 i = 0; i < 6; ++i) + if (!is_alm_wl_sky) + { + for (S32 i = 0; i < 6; ++i) + { + mSkyTex[i].create(1.0f); + } + } + + for (S32 i = 0; i < 6; ++i) { - mSkyTex[i].create(1.0f); mShinyTex[i].create(1.0f); } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index ed190892fe..e465dcbe27 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -293,7 +293,7 @@ protected: void updateDirections(void); void initSkyTextureDirs(const S32 side, const S32 tile); - void createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile); + void createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile, bool skip_sky_tex); LLPointer<LLViewerFetchedTexture> mSunTexturep[2]; LLPointer<LLViewerFetchedTexture> mMoonTexturep[2]; |