diff options
| -rwxr-xr-x | doc/contributions.txt | 1 | ||||
| -rw-r--r-- | indra/llinventory/llsettingssky.cpp | 4 | ||||
| -rw-r--r-- | indra/llinventory/llsettingssky.h | 2 | ||||
| -rw-r--r-- | indra/newview/lllegacyatmospherics.cpp | 27 | ||||
| -rw-r--r-- | indra/newview/lllegacyatmospherics.h | 6 | ||||
| -rw-r--r-- | indra/newview/llvosky.cpp | 63 | ||||
| -rw-r--r-- | indra/newview/llvosky.h | 17 | ||||
| -rw-r--r-- | indra/newview/llvowlsky.cpp | 81 | ||||
| -rw-r--r-- | indra/newview/llvowlsky.h | 13 | 
9 files changed, 103 insertions, 111 deletions
| diff --git a/doc/contributions.txt b/doc/contributions.txt index 537df59c8c..33b169169c 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -1367,6 +1367,7 @@ Sovereign Engineer  	SL-14731  	SL-14732  	SL-15096 +	SL-16127  SpacedOut Frye  	VWR-34  	VWR-45 diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 82c67a1066..bdcf35faae 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1219,9 +1219,9 @@ LLColor3 LLSettingsSky::getLightTransmittanceFast( const LLColor3& total_density  // performs soft scale clip and gamma correction ala the shader implementation  // scales colors down to 0 - 1 range preserving relative ratios -LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const +LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in,const F32 &gamma) const  { -    F32 gamma = getGamma(); +    //F32 gamma = getGamma(); // SL-16127: Use cached gamma from atmospheric vars      LLColor3 v(in);      // scale down to 0 to 1 range preserving relative ratio (aka homegenize) diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 77d9d8e87c..fa9326f006 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -254,7 +254,7 @@ public:      LLColor3 getLightTransmittance(F32 distance) const;      LLColor3 getLightTransmittanceFast(const LLColor3& total_density, const F32 density_multiplier, const F32 distance) const;      LLColor3 getTotalDensity() const; -    LLColor3 gammaCorrect(const LLColor3& in) const; +    LLColor3 gammaCorrect(const LLColor3& in,const F32 &gamma) const;      LLColor3 getBlueDensity() const;      LLColor3 getBlueHorizon() const; diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 9eda254b25..238e9fe0e1 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -202,14 +202,8 @@ void LLAtmospherics::init()  	mInitialized = true;  } -LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) -{ -    LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); -    return calcSkyColorInDir(psky, vars, dir, isShiny); -} -  // This cubemap is used as "environmentMap" in indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl -LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny) +LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3 &dir, bool isShiny, bool low_end)  {  	const F32 sky_saturation = 0.25f;  	const F32 land_saturation = 0.1f; @@ -227,7 +221,7 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm  		}  		F32 greyscale_sat = brightness * (1.0f - land_saturation);  		desat_fog = desat_fog * land_saturation + smear(greyscale_sat); -		if (!gPipeline.canUseWindLightShaders()) +		if (low_end)  		{  			col = LLColor4(desat_fog, 0.f);  		} @@ -258,8 +252,7 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, Atm  		return LLColor4(sky_color, 0.0f);  	} -	bool low_end = !gPipeline.canUseWindLightShaders(); -	LLColor3 sky_color = low_end ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); +	LLColor3 sky_color = low_end ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f, vars.gamma);  	return LLColor4(sky_color, 0.0f);  } @@ -437,12 +430,16 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in)      LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); +    // NOTE: This is very similar to LLVOSky::cacheEnvironment() +    // Differences: +    //     vars.sun_norm +    //     vars.sunlight      // invariants across whole sky tex process... -    vars.blue_density = psky->getBlueDensity();     +    vars.blue_density = psky->getBlueDensity();      vars.blue_horizon = psky->getBlueHorizon();      vars.haze_density = psky->getHazeDensity();      vars.haze_horizon = psky->getHazeHorizon(); -    vars.density_multiplier = psky->getDensityMultiplier();     +    vars.density_multiplier = psky->getDensityMultiplier();      vars.distance_multiplier = psky->getDistanceMultiplier();      vars.max_y = psky->getMaxY();      vars.sun_norm = LLEnvironment::instance().getSunDirectionCFR(); @@ -457,9 +454,9 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in)      vars.total_density = psky->getTotalDensity();      vars.gamma = psky->getGamma(); -	res_color[0] = calcSkyColorInDir(vars, tosun); -	res_color[1] = calcSkyColorInDir(vars, perp_tosun); -	res_color[2] = calcSkyColorInDir(vars, tosun_45); +    res_color[0] = calcSkyColorInDir(psky, vars, tosun); +    res_color[1] = calcSkyColorInDir(psky, vars, perp_tosun); +    res_color[2] = calcSkyColorInDir(psky, vars, tosun_45);  	sky_fog_color = color_norm(res_color[0] + res_color[1] + res_color[2]); diff --git a/indra/newview/lllegacyatmospherics.h b/indra/newview/lllegacyatmospherics.h index 03c8efb91a..d48f3040c3 100644 --- a/indra/newview/lllegacyatmospherics.h +++ b/indra/newview/lllegacyatmospherics.h @@ -257,13 +257,11 @@ public:      void setCloudDensity(F32 cloud_density)          { mCloudDensity = cloud_density; }      void setWind ( const LLVector3& wind )           { mWind = wind.length(); } -    LLColor4 calcSkyColorInDir(AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false); -    LLColor4 calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false); +    LLColor4 calcSkyColorInDir(const LLSettingsSky::ptr_t &psky, AtmosphericsVars& vars, const LLVector3& dir, bool isShiny = false, const bool low_end = false); -protected:     +protected:      void     calcSkyColorWLVert(const LLSettingsSky::ptr_t &psky, LLVector3 & Pn, AtmosphericsVars& vars); -    LLColor3 getHazeColor(LLSettingsSky::ptr_t psky, AtmosphericsVars& vars, F32 costheta, F32 cloud_shadow);      LLHaze              mHaze;      F32                 mHazeConcentration; diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index edf8c40bd3..322e4f110a 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -64,7 +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 NUM_CUBEMAP_FACES = 6; // See sResolution for face dimensions +    const S32 NUM_CUBEMAP_FACES = 6; // See SKYTEX_RESOLUTION for face dimensions      const S32 TOTAL_TILES = NUM_CUBEMAP_FACES * NUM_TILES;      const S32 MAX_TILES = TOTAL_TILES + 1; @@ -92,8 +92,6 @@ namespace  		SkyTex  ***************************************/ -S32 LLSkyTex::sComponents = 4; -S32 LLSkyTex::sResolution = 64;  S32 LLSkyTex::sCurrent = 0; @@ -107,14 +105,14 @@ LLSkyTex::LLSkyTex() :  void LLSkyTex::init(bool isShiny)  {      mIsShiny = isShiny; -	mSkyData = new LLColor4[sResolution * sResolution]; -	mSkyDirs = new LLVector3[sResolution * sResolution]; +	mSkyData = new LLColor4[SKYTEX_RESOLUTION * SKYTEX_RESOLUTION]; +	mSkyDirs = new LLVector3[SKYTEX_RESOLUTION * SKYTEX_RESOLUTION];  	for (S32 i = 0; i < 2; ++i)  	{  		mTexture[i] = LLViewerTextureManager::getLocalTexture(FALSE);  		mTexture[i]->setAddressMode(LLTexUnit::TAM_CLAMP); -		mImageRaw[i] = new LLImageRaw(sResolution, sResolution, sComponents); +		mImageRaw[i] = new LLImageRaw(SKYTEX_RESOLUTION, SKYTEX_RESOLUTION, SKYTEX_COMPONENTS);  		initEmpty(i);  	} @@ -146,7 +144,7 @@ LLSkyTex::~LLSkyTex()  S32 LLSkyTex::getResolution()  { -    return sResolution; +    return SKYTEX_RESOLUTION;  }  S32 LLSkyTex::getCurrent() @@ -174,12 +172,12 @@ S32 LLSkyTex::getWhich(const BOOL curr)  void LLSkyTex::initEmpty(const S32 tex)  {  	U8* data = mImageRaw[tex]->getData(); -	for (S32 i = 0; i < sResolution; ++i) +	for (S32 i = 0; i < SKYTEX_RESOLUTION; ++i)  	{ -		for (S32 j = 0; j < sResolution; ++j) +		for (S32 j = 0; j < SKYTEX_RESOLUTION; ++j)  		{ -			const S32 basic_offset = (i * sResolution + j); -			S32 offset = basic_offset * sComponents; +			const S32 basic_offset = (i * SKYTEX_RESOLUTION + j); +			S32 offset = basic_offset * SKYTEX_COMPONENTS;  			data[offset] = 0;  			data[offset+1] = 0;  			data[offset+2] = 0; @@ -195,12 +193,12 @@ void LLSkyTex::initEmpty(const S32 tex)  void LLSkyTex::create()  {  	U8* data = mImageRaw[sCurrent]->getData(); -	for (S32 i = 0; i < sResolution; ++i) +	for (S32 i = 0; i < SKYTEX_RESOLUTION; ++i)  	{ -		for (S32 j = 0; j < sResolution; ++j) +		for (S32 j = 0; j < SKYTEX_RESOLUTION; ++j)  		{ -			const S32 basic_offset = (i * sResolution + j); -			S32 offset = basic_offset * sComponents; +			const S32 basic_offset = (i * SKYTEX_RESOLUTION + j); +			S32 offset = basic_offset * SKYTEX_COMPONENTS;  			U32* pix = (U32*)(data + offset);  			LLColor4U temp = LLColor4U(mSkyData[basic_offset]);  			*pix = temp.asRGBA(); @@ -397,10 +395,8 @@ const LLVector3* LLHeavenBody::corners() const  		Sky  ***************************************/ - -S32 LLVOSky::sResolution = LLSkyTex::getResolution(); -S32 LLVOSky::sTileResX = sResolution/NUM_TILES_X; -S32 LLVOSky::sTileResY = sResolution/NUM_TILES_Y; +const S32 SKYTEX_TILE_RES_X = SKYTEX_RESOLUTION / NUM_TILES_X; +const S32 SKYTEX_TILE_RES_Y = SKYTEX_RESOLUTION / NUM_TILES_Y;  LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)  :	LLStaticViewerObject(id, pcode, regionp, TRUE), @@ -495,6 +491,7 @@ void LLVOSky::init()  void LLVOSky::cacheEnvironment(LLSettingsSky::ptr_t psky,AtmosphericsVars& atmosphericsVars)  { +    // NOTE: Also see: LLAtmospherics::updateFog()      // invariants across whole sky tex process...      atmosphericsVars.blue_density = psky->getBlueDensity();      atmosphericsVars.blue_horizon = psky->getBlueHorizon(); @@ -602,8 +599,8 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile)  	S32 tile_x = tile % NUM_TILES_X;  	S32 tile_y = tile / NUM_TILES_X; -	S32 tile_x_pos = tile_x * sTileResX; -	S32 tile_y_pos = tile_y * sTileResY; +	S32 tile_x_pos = tile_x * SKYTEX_TILE_RES_X; +	S32 tile_y_pos = tile_y * SKYTEX_TILE_RES_Y;  	F32 coeff[3] = {0, 0, 0};  	const S32 curr_coef = side >> 1; // 0/1 = Z axis, 2/3 = Y, 4/5 = X @@ -613,11 +610,11 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile)  	coeff[curr_coef] = (F32)side_dir; -	F32 inv_res = 1.f/sResolution; +	F32 inv_res = 1.f/SKYTEX_RESOLUTION;  	S32 x, y; -	for (y = tile_y_pos; y < (tile_y_pos + sTileResY); ++y) +	for (y = tile_y_pos; y < (tile_y_pos + SKYTEX_TILE_RES_Y); ++y)  	{ -		for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x) +		for (x = tile_x_pos; x < (tile_x_pos + SKYTEX_TILE_RES_X); ++x)  		{  			coeff[x_coef] = F32((x<<1) + 1) * inv_res - 1.f;  			coeff[y_coef] = F32((y<<1) + 1) * inv_res - 1.f; @@ -629,21 +626,23 @@ void LLVOSky::initSkyTextureDirs(const S32 side, const S32 tile)  	}  } -void LLVOSky::createSkyTexture(LLSettingsSky::ptr_t psky, 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 bool low_end = !gPipeline.canUseWindLightShaders(); +  	S32 tile_x = tile % NUM_TILES_X;  	S32 tile_y = tile / NUM_TILES_X; -	S32 tile_x_pos = tile_x * sTileResX; -	S32 tile_y_pos = tile_y * sTileResY; +	S32 tile_x_pos = tile_x * SKYTEX_TILE_RES_X; +	S32 tile_y_pos = tile_y * SKYTEX_TILE_RES_Y;  	S32 x, y; -	for (y = tile_y_pos; y < (tile_y_pos + sTileResY); ++y) +	for (y = tile_y_pos; y < (tile_y_pos + SKYTEX_TILE_RES_Y); ++y)  	{ -		for (x = tile_x_pos; x < (tile_x_pos + sTileResX); ++x) +		for (x = tile_x_pos; x < (tile_x_pos + SKYTEX_TILE_RES_X); ++x)  		{ -			mSkyTex  [side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mSkyTex  [side].getDir(x, y), false), x, y); -			mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mShinyTex[side].getDir(x, y), true ), x, y); +			mSkyTex  [side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mSkyTex  [side].getDir(x, y), false, low_end), x, y); +			mShinyTex[side].setPixel(m_legacyAtmospherics.calcSkyColorInDir(psky, vars, mShinyTex[side].getDir(x, y), true , low_end), x, y);  		}  	}  } @@ -783,7 +782,7 @@ bool LLVOSky::updateSky()      }      // run 0 to 5 faces, each face in own frame      else if (mCubeMapUpdateStage >= 0 && mCubeMapUpdateStage < NUM_CUBEMAP_FACES) -		{ +	{          LL_RECORD_BLOCK_TIME(FTM_VOSKY_CREATETEXTURES);          S32 side = mCubeMapUpdateStage;          // CPU hungry part, createSkyTexture() is math heavy diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index 793dcf4cbf..5941ab6e3b 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -43,6 +43,9 @@ const F32 HEAVENLY_BODY_DIST	= HORIZON_DIST - 20.f;  const F32 HEAVENLY_BODY_FACTOR	= 0.1f;  const F32 HEAVENLY_BODY_SCALE	= HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR; +const F32 SKYTEX_COMPONENTS = 4; +const F32 SKYTEX_RESOLUTION = 64; +  class LLFace;  class LLHaze; @@ -50,8 +53,6 @@ class LLSkyTex  {  	friend class LLVOSky;  private: -	static S32		sResolution; -	static S32		sComponents;  	LLPointer<LLViewerTexture> mTexture[2];  	LLPointer<LLImageRaw> mImageRaw[2];  	LLColor4		*mSkyData; @@ -82,25 +83,25 @@ protected:  	void setDir(const LLVector3 &dir, const S32 i, const S32 j)  	{ -		S32 offset = i * sResolution + j; +		S32 offset = i * SKYTEX_RESOLUTION + j;  		mSkyDirs[offset] = dir;  	}  	const LLVector3 &getDir(const S32 i, const S32 j) const  	{ -		S32 offset = i * sResolution + j; +		S32 offset = i * SKYTEX_RESOLUTION + j;  		return mSkyDirs[offset];  	}  	void setPixel(const LLColor4 &col, const S32 i, const S32 j)  	{ -		S32 offset = i * sResolution + j; +		S32 offset = i * SKYTEX_RESOLUTION + j;  		mSkyData[offset] = col;  	}  	void setPixel(const LLColor4U &col, const S32 i, const S32 j)  	{ -		S32 offset = (i * sResolution + j) * sComponents; +		S32 offset = (i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS;  		U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);  		*pix = col.asRGBA();  	} @@ -108,7 +109,7 @@ protected:  	LLColor4U getPixel(const S32 i, const S32 j)  	{  		LLColor4U col; -		S32 offset = (i * sResolution + j) * sComponents; +		S32 offset = (i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS;  		U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);  		col.fromRGBA( *pix );  		return col; @@ -300,7 +301,7 @@ protected:  	void updateDirections(LLSettingsSky::ptr_t psky);  	void initSkyTextureDirs(const S32 side, const S32 tile); -	void createSkyTexture(LLSettingsSky::ptr_t psky, 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]; diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index d428cb1568..e292c4b8d8 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -36,8 +36,8 @@  #include "llenvironment.h"  #include "llsettingssky.h" -static const U32 MIN_SKY_DETAIL = 8; -static const U32 MAX_SKY_DETAIL = 180; +constexpr U32 MIN_SKY_DETAIL = 8; +constexpr U32 MAX_SKY_DETAIL = 180;  inline U32 LLVOWLSky::getNumStacks(void)  { @@ -97,13 +97,14 @@ LLDrawable * LLVOWLSky::createDrawable(LLPipeline * pipeline)  	return mDrawable;  } -inline F32 LLVOWLSky::calcPhi(U32 i) +// a tiny helper function for controlling the sky dome tesselation. +inline F32 calcPhi(const U32 &i, const F32 &reciprocal_num_stacks)  {      // Calc: PI/8 * 1-((1-t^4)*(1-t^4))  { 0<t<1 }      // Demos: \pi/8*\left(1-((1-x^{4})*(1-x^{4}))\right)\ \left\{0<x\le1\right\}  	// i should range from [0..SKY_STACKS] so t will range from [0.f .. 1.f] -	F32 t = float(i) / float(getNumStacks()); +	F32 t = float(i) * reciprocal_num_stacks; //SL-16127: remove: / float(getNumStacks());  	// ^4 the parameter of the tesselation to bias things toward 0 (the dome's apex)  	t *= t; @@ -189,6 +190,8 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)      }  	{ +        const F32 dome_radius = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); +  		const U32 max_buffer_bytes = gSavedSettings.getS32("RenderMaxVBOSize")*1024;  		const U32 data_mask = LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK;  		const U32 max_verts = max_buffer_bytes / LLVertexBuffer::calcVertexSize(data_mask); @@ -204,12 +207,14 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)  		// round up to a whole number of segments  		const U32 strips_segments = (total_stacks+stacks_per_seg-1) / stacks_per_seg; -		LL_INFOS() << "WL Skydome strips in " << strips_segments << " batches." << LL_ENDL; -  		mStripsVerts.resize(strips_segments, NULL); +#if RELEASE_SHOW_DEBUG +		LL_INFOS() << "WL Skydome strips in " << strips_segments << " batches." << LL_ENDL; +  		LLTimer timer;  		timer.start(); +#endif  		for (U32 i = 0; i < strips_segments ;++i)  		{ @@ -234,34 +239,42 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)  			const U32 num_indices_this_seg = 1+num_stacks_this_seg*(2+2*verts_per_stack);  			llassert(num_indices_this_seg * sizeof(U16) <= max_buffer_bytes); -			if (!segment->allocateBuffer(num_verts_this_seg, num_indices_this_seg, TRUE)) +			bool allocated = segment->allocateBuffer(num_verts_this_seg, num_indices_this_seg, TRUE); +#if RELEASE_SHOW_WARNS +			if( !allocated )  			{  				LL_WARNS() << "Failed to allocate Vertex Buffer on update to "  					<< num_verts_this_seg << " vertices and "  					<< num_indices_this_seg << " indices" << LL_ENDL;  			} +#else +			(void) allocated; +#endif  			// lock the buffer  			BOOL success = segment->getVertexStrider(vertices)  				&& segment->getTexCoord0Strider(texCoords)  				&& segment->getIndexStrider(indices); -			if(!success)  +#if RELEASE_SHOW_DEBUG +			if(!success)  			{  				LL_ERRS() << "Failed updating WindLight sky geometry." << LL_ENDL;  			} - -            U32 vertex_count = 0; -            U32 index_count  = 0; +#else +			(void) success; +#endif  			// fill it -			buildStripsBuffer(begin_stack, end_stack, vertex_count, index_count, vertices, texCoords, indices); +			buildStripsBuffer(begin_stack, end_stack, vertices, texCoords, indices, dome_radius, verts_per_stack, total_stacks);  			// and unlock the buffer  			segment->flush();  		} +#if RELEASE_SHOW_DEBUG  		LL_INFOS() << "completed in " << llformat("%.2f", timer.getElapsedTimeF32().value()) << "seconds" << LL_ENDL; +#endif  	}  	updateStarColors(); @@ -366,23 +379,16 @@ void LLVOWLSky::initStars()  void LLVOWLSky::buildStripsBuffer(U32 begin_stack,                                    U32 end_stack, -                                  U32& vertex_count, -                                  U32& index_count, -								  LLStrider<LLVector3> & vertices, -								  LLStrider<LLVector2> & texCoords, -								  LLStrider<U16> & indices) +                                  LLStrider<LLVector3> & vertices, +                                  LLStrider<LLVector2> & texCoords, +                                  LLStrider<U16> & indices, +                                  const F32 dome_radius, +                                  const U32& num_slices, +                                  const U32& num_stacks)  { -    const F32 RADIUS = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); - -	U32 i, j, num_slices, num_stacks; +	U32 i, j;  	F32 phi0, theta, x0, y0, z0; - -	// paranoia checking for SL-55986/SL-55833 -	U32 count_verts = 0; -	U32 count_indices = 0; - -	num_slices = getNumSlices(); -	num_stacks = getNumStacks(); +	const F32 reciprocal_num_stacks = 1.f / num_stacks;  	llassert(end_stack <= num_stacks); @@ -393,7 +399,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack,      for(i = begin_stack + 1; i <= end_stack+1; ++i)   #endif  	{ -		phi0 = calcPhi(i); +		phi0 = calcPhi(i, reciprocal_num_stacks);  		for(j = 0; j < num_slices; ++j)  		{ @@ -406,24 +412,22 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack,  			z0 = sin(phi0) * sin(theta);  #if NEW_TESS -            *vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); +            *vertices++ = LLVector3(x0 * dome_radius, y0 * dome_radius, z0 * dome_radius);  #else              if (i == num_stacks-2)  			{ -				*vertices++ = LLVector3(x0*RADIUS, y0*RADIUS-1024.f*2.f, z0*RADIUS); +				*vertices++ = LLVector3(x0*dome_radius, y0*dome_radius-1024.f*2.f, z0*dome_radius);  			}  			else if (i == num_stacks-1)  			{ -				*vertices++ = LLVector3(0, y0*RADIUS-1024.f*2.f, 0); +				*vertices++ = LLVector3(0, y0*dome_radius-1024.f*2.f, 0);  			}  			else  			{ -				*vertices++		= LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); +				*vertices++		= LLVector3(x0 * dome_radius, y0 * dome_radius, z0 * dome_radius);  			}  #endif -			++count_verts; -  			// generate planar uv coordinates  			// note: x and z are transposed in order for things to animate  			// correctly in the global coordinate system where +x is east and @@ -434,12 +438,11 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack,  	//build triangle strip...  	*indices++ = 0 ; -	count_indices++ ; +  	S32 k = 0 ;  	for(i = 1; i <= end_stack - begin_stack; ++i)   	{  		*indices++ = i * num_slices + k ; -		count_indices++ ;  		k = (k+1) % num_slices ;  		for(j = 0; j < num_slices ; ++j)  @@ -447,8 +450,6 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack,  			*indices++ = (i-1) * num_slices + k ;  			*indices++ = i * num_slices + k ; -			count_indices += 2 ; -  			k = (k+1) % num_slices ;  		} @@ -458,11 +459,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack,  		}  		*indices++ = i * num_slices + k ; -		count_indices++ ;  	} - -    vertex_count = count_verts; -    index_count = count_indices;  }  void LLVOWLSky::updateStarColors() diff --git a/indra/newview/llvowlsky.h b/indra/newview/llvowlsky.h index 2b7ebe75dd..3853dd2c70 100644 --- a/indra/newview/llvowlsky.h +++ b/indra/newview/llvowlsky.h @@ -55,8 +55,6 @@ public:  	void restoreGL();  private: -	// a tiny helper function for controlling the sky dome tesselation. -	static F32 calcPhi(U32 i);  	// helper function for initializing the stars.  	void initStars(); @@ -66,11 +64,12 @@ private:  	// begin_stack is the first stack to be included, end_stack is the first  	// stack not to be included.  	static void buildStripsBuffer(U32 begin_stack, U32 end_stack, -                                  U32& vertex_count, -                                  U32& index_count, -								  LLStrider<LLVector3> & vertices, -								  LLStrider<LLVector2> & texCoords, -								  LLStrider<U16> & indices); +                                  LLStrider<LLVector3> & vertices, +                                  LLStrider<LLVector2> & texCoords, +                                  LLStrider<U16> & indices, +                                  const F32 RADIUS, +                                  const U32& num_slices, +                                  const U32& num_stacks);  	// helper function for updating the stars colors.  	void updateStarColors(); | 
