diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index e1d70e6bfdcb7a61ce66e2444cd4ccd90c0d4b81..7a8db8c33ebf6fac7591b35a518698ca01a42339 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -64,6 +64,7 @@ namespace const S32 NUM_TILES_X = 8; const S32 NUM_TILES_Y = 4; const S32 NUM_TILES = NUM_TILES_X * NUM_TILES_Y; + const S32 UPDATE_TILES = NUM_TILES / 8; // SL-16127: Amortize updating face; see sTileResX const S32 NUM_CUBEMAP_FACES = 6; // Heavenly body constants @@ -412,6 +413,7 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mForceUpdate(FALSE), mNeedUpdate(TRUE), mCubeMapUpdateStage(-1), + mCubeMapUpdateTile(0), mWorldScale(1.f), mBumpSunDir(0.f, 0.f, 1.f) { @@ -492,7 +494,7 @@ void LLVOSky::init() for (S32 tile = 0; tile < NUM_TILES; ++tile) { initSkyTextureDirs(side, tile); - createSkyTexture(m_atmosphericsVars, side, tile); + createSkyTexture(psky, m_atmosphericsVars, side, tile); } mSkyTex[side].create(); mShinyTex[side].create(); @@ -640,10 +642,8 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile) } } -void LLVOSky::createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile) +void LLVOSky::createSkyTexture(const LLSettingsSky::ptr_t psky, AtmosphericsVars& vars, const S32 side, const S32 tile) { - const LLSettingsSky::ptr_t& psky = LLEnvironment::instance().getCurrentSky(); - S32 tile_x = tile % NUM_TILES_X; S32 tile_y = tile / NUM_TILES_X; @@ -684,6 +684,7 @@ void LLVOSky::forceSkyUpdate() m_lastAtmosphericsVars = AtmosphericsVars(); mCubeMapUpdateStage = -1; + mCubeMapUpdateTile = 0; } bool LLVOSky::updateSky() @@ -693,12 +694,6 @@ bool LLVOSky::updateSky() return TRUE; } - if (mDead) - { - // It's dead. Don't update it. - return TRUE; - } - if (gGLManager.mIsDisabled) { return TRUE; @@ -738,6 +733,7 @@ bool LLVOSky::updateSky() // start updating cube map sides updateFog(LLViewerCamera::getInstance()->getFar()); mCubeMapUpdateStage = 0; + mCubeMapUpdateTile = 0; mForceUpdate = FALSE; } } @@ -802,21 +798,26 @@ bool LLVOSky::updateSky() mCubeMapUpdateStage = -1; } // run 0 to 5 faces, each face in own frame - else if (mCubeMapUpdateStage >= 0 && mCubeMapUpdateStage < NUM_CUBEMAP_FACES) + else if (mCubeMapUpdateStage >= 0 && mCubeMapUpdateStage < NUM_CUBEMAP_FACES) + { + LL_RECORD_BLOCK_TIME(FTM_VOSKY_CREATETEXTURES); + const LLSettingsSky::ptr_t& psky = LLEnvironment::instance().getCurrentSky(); + + const S32 side = mCubeMapUpdateStage; + const S32 start_tile = mCubeMapUpdateTile; + // CPU hungry part, createSkyTexture() is math heavy + // Prior to EEP it was mostly per tile, but since EPP it is per face. + // This still can be optimized further + // (i.e. potentially can be made per tile again, can be moved to thread + // instead of executing per face, or may be can be moved to shaders) + for (S32 tile = 0; tile < UPDATE_TILES; tile++) { - LL_RECORD_BLOCK_TIME(FTM_VOSKY_CREATETEXTURES); - S32 side = mCubeMapUpdateStage; - // CPU hungry part, createSkyTexture() is math heavy - // Prior to EEP it was mostly per tile, but since EPP it is per face. - // This still can be optimized further - // (i.e. potentially can be made per tile again, can be moved to thread - // instead of executing per face, or may be can be moved to shaders) - for (S32 tile = 0; tile < NUM_TILES; tile++) - { - createSkyTexture(m_atmosphericsVars, side, tile); - } - mCubeMapUpdateStage++; - } + createSkyTexture(psky, m_atmosphericsVars, side, start_tile + tile); + } + mCubeMapUpdateTile += UPDATE_TILES; + if (mCubeMapUpdateTile >= NUM_TILES) + mCubeMapUpdateStage++; + } return TRUE; } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index 93212075930c4f4b72360a8d9a827829e932efac..6107b4ecdecd9871fc40c49cb0516d9a266af707 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -302,7 +302,7 @@ class LLVOSky final : public LLStaticViewerObject void updateDirections(void); void initSkyTextureDirs(const S32 side, const S32 tile); - void createSkyTexture(AtmosphericsVars& vars, const S32 side, const S32 tile); + void createSkyTexture(const LLSettingsSky::ptr_t psky, AtmosphericsVars& vars, const S32 side, const S32 tile); LLPointer<LLViewerFetchedTexture> mSunTexturep[2]; LLPointer<LLViewerFetchedTexture> mMoonTexturep[2]; @@ -340,6 +340,7 @@ class LLVOSky final : public LLStaticViewerObject bool mForceUpdate; bool mNeedUpdate; // flag to force update of cubemap S32 mCubeMapUpdateStage; // state of cubemap uodate: -1 idle; 0-5 per-face updates; 6 finalizing + S32 mCubeMapUpdateTile; // Do partial work to amortize cost of updating; SL-16127 F32 mAmbientScale; LLColor3 mNightColorShift;