diff options
Diffstat (limited to 'indra')
36 files changed, 429 insertions, 506 deletions
| diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index d2c4e66160..6e988260a9 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -37,12 +37,13 @@ thread_local bool gProfilerEnabled = false;  #if (TRACY_ENABLE)  // Override new/delete for tracy memory profiling -void *operator new(size_t size) + +void* ll_tracy_new(size_t size)  {      void* ptr;      if (gProfilerEnabled)      { -        LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; +        //LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;          ptr = (malloc)(size);      }      else @@ -57,12 +58,22 @@ void *operator new(size_t size)      return ptr;  } -void operator delete(void *ptr) noexcept +void* operator new(size_t size) +{ +    return ll_tracy_new(size); +} + +void* operator new[](std::size_t count) +{ +    return ll_tracy_new(count); +} + +void ll_tracy_delete(void* ptr)  {      TracyFree(ptr);      if (gProfilerEnabled)      { -        LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; +        //LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;          (free)(ptr);      }      else @@ -71,6 +82,16 @@ void operator delete(void *ptr) noexcept      }  } +void operator delete(void *ptr) noexcept +{ +    ll_tracy_delete(ptr); +} + +void operator delete[](void* ptr) noexcept +{ +    ll_tracy_delete(ptr); +} +  // C-style malloc/free can't be so easily overridden, so we define tracy versions and use  // a pre-processor #define in linden_common.h to redirect to them. The parens around the native  // functions below prevents recursive substitution by the preprocessor. diff --git a/indra/llcommon/llprofiler.h b/indra/llcommon/llprofiler.h index 394fbd05f6..736a069f49 100644 --- a/indra/llcommon/llprofiler.h +++ b/indra/llcommon/llprofiler.h @@ -138,10 +138,6 @@ extern thread_local bool gProfilerEnabled;          #define LL_PROFILE_ZONE_ERR(name)               LL_PROFILE_ZONE_NAMED_COLOR( name, 0XFF0000  )  // RGB yellow          #define LL_PROFILE_ZONE_INFO(name)              LL_PROFILE_ZONE_NAMED_COLOR( name, 0X00FFFF  )  // RGB cyan          #define LL_PROFILE_ZONE_WARN(name)              LL_PROFILE_ZONE_NAMED_COLOR( name, 0x0FFFF00 )  // RGB red -        //#define LL_PROFILE_ALLOC(ptr, size)             TracyAlloc(ptr, size) // memory allocation tracking currently not working -        //#define LL_PROFILE_FREE(ptr)                    TracyFree(ptr) -        #define LL_PROFILE_ALLOC(ptr, size)             (void)(ptr); (void)(size); -        #define LL_PROFILE_FREE(ptr)                    (void)(ptr);      #endif  #else      #define LL_PROFILER_FRAME_END @@ -165,7 +161,7 @@ extern thread_local bool gProfilerEnabled;  #define LL_LABEL_OBJECT_GL(type, name, length, label) -#if LL_PROFILER_CONFIG > 1 +#if LL_PROFILER_CONFIGURATION > 1  #define LL_PROFILE_ALLOC(ptr, size)             TracyAlloc(ptr, size)  #define LL_PROFILE_FREE(ptr)                    TracyFree(ptr)  #else diff --git a/indra/llcommon/llprofilercategories.h b/indra/llcommon/llprofilercategories.h index 8db29468cc..617431f629 100644 --- a/indra/llcommon/llprofilercategories.h +++ b/indra/llcommon/llprofilercategories.h @@ -52,7 +52,7 @@  #define LL_PROFILER_CATEGORY_ENABLE_LOGGING     1  #define LL_PROFILER_CATEGORY_ENABLE_MATERIAL    1  #define LL_PROFILER_CATEGORY_ENABLE_MEDIA       1 -#define LL_PROFILER_CATEGORY_ENABLE_MEMORY      1 +#define LL_PROFILER_CATEGORY_ENABLE_MEMORY      0  #define LL_PROFILER_CATEGORY_ENABLE_NETWORK     1  #define LL_PROFILER_CATEGORY_ENABLE_OCTREE      1  #define LL_PROFILER_CATEGORY_ENABLE_PIPELINE    1 diff --git a/indra/llrender/llgltexture.h b/indra/llrender/llgltexture.h index 8cfe7b62de..3732333f8f 100644 --- a/indra/llrender/llgltexture.h +++ b/indra/llrender/llgltexture.h @@ -49,10 +49,8 @@ public:  	enum EBoostLevel  	{  		BOOST_NONE 			= 0, -		BOOST_ALM			, //acts like NONE when ALM is on, max discard when ALM is off  		BOOST_AVATAR_BAKED	,  		BOOST_AVATAR		, -		BOOST_CLOUDS		,  		BOOST_SCULPTED      ,  		BOOST_HIGH 			= 10, diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 5b814f03cb..8430d13093 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -70,9 +70,6 @@ bool LLRender::sGLCoreProfile = false;  bool LLRender::sNsightDebugSupport = false;  LLVector2 LLRender::sUIGLScaleFactor = LLVector2(1.f, 1.f); -static const U32 LL_NUM_TEXTURE_LAYERS = 32;  -static const U32 LL_NUM_LIGHT_UNITS = 8; -  struct LLVBCache  {      LLPointer<LLVertexBuffer> vb; @@ -823,16 +820,14 @@ LLRender::LLRender()      mMode(LLRender::TRIANGLES),      mCurrTextureUnitIndex(0)  {	 -	mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS);  	for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++)  	{ -		mTexUnits.push_back(new LLTexUnit(i)); +        mTexUnits[i].mIndex = i;  	} -	mDummyTexUnit = new LLTexUnit(-1);  	for (U32 i = 0; i < LL_NUM_LIGHT_UNITS; ++i)  	{ -		mLightState.push_back(new LLLightState(i)); +        mLightState[i].mIndex = i;  	}  	for (U32 i = 0; i < 4; i++) @@ -915,19 +910,6 @@ void LLRender::resetVertexBuffer()  void LLRender::shutdown()  { -	for (U32 i = 0; i < mTexUnits.size(); i++) -	{ -		delete mTexUnits[i]; -	} -	mTexUnits.clear(); -	delete mDummyTexUnit; -	mDummyTexUnit = NULL; - -	for (U32 i = 0; i < mLightState.size(); ++i) -	{ -		delete mLightState[i]; -	} -	mLightState.clear();      resetVertexBuffer();  } @@ -939,10 +921,10 @@ void LLRender::refreshState(void)  	for (U32 i = 0; i < mTexUnits.size(); i++)  	{ -		mTexUnits[i]->refreshState(); +		mTexUnits[i].refreshState();  	} -	mTexUnits[active_unit]->activate(); +	mTexUnits[active_unit].activate();  	setColorMask(mCurrColorMask[0], mCurrColorMask[1], mCurrColorMask[2], mCurrColorMask[3]); @@ -974,7 +956,7 @@ void LLRender::syncLightState()          for (U32 i = 0; i < LL_NUM_LIGHT_UNITS; i++)          { -            LLLightState *light = mLightState[i]; +            LLLightState *light = &mLightState[i];              position[i]  = light->mPosition;              direction[i] = light->mSpotDirection; @@ -1501,12 +1483,12 @@ LLTexUnit* LLRender::getTexUnit(U32 index)  {  	if (index < mTexUnits.size())  	{ -		return mTexUnits[index]; +		return &mTexUnits[index];  	}  	else   	{  		LL_DEBUGS() << "Non-existing texture unit layer requested: " << index << LL_ENDL; -		return mDummyTexUnit; +		return &mDummyTexUnit;  	}  } @@ -1514,7 +1496,7 @@ LLLightState* LLRender::getLight(U32 index)  {  	if (index < mLightState.size())  	{ -		return mLightState[index]; +		return &mLightState[index];  	}  	return NULL; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index e8baf6bb7e..6f61627235 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -52,6 +52,9 @@ class LLTexture ;  #define LL_MATRIX_STACK_DEPTH 32 +constexpr U32 LL_NUM_TEXTURE_LAYERS = 32; +constexpr U32 LL_NUM_LIGHT_UNITS = 8; +  class LLTexUnit   {  	friend class LLRender; @@ -135,7 +138,7 @@ public:          TCS_SRGB      } eTextureColorSpace; -	LLTexUnit(S32 index); +	LLTexUnit(S32 index = -1);  	// Refreshes renderer state of the texture unit to the cached values  	// Needed when the render context has changed and invalidated the current state @@ -212,7 +215,9 @@ public:      eTextureColorSpace getCurrColorSpace() { return mTexColorSpace; }  protected: -	const S32			mIndex; +    friend class LLRender; + +	S32		        	mIndex;  	U32					mCurrTexture;  	eTextureType		mCurrTexType;      eTextureColorSpace  mTexColorSpace; @@ -230,7 +235,7 @@ protected:  class LLLightState  {  public: -	LLLightState(S32 index); +	LLLightState(S32 index = -1);  	void enable();  	void disable(); @@ -488,9 +493,9 @@ private:  	LLStrider<LLVector3>		mVerticesp;  	LLStrider<LLVector2>		mTexcoordsp;  	LLStrider<LLColor4U>		mColorsp; -	std::vector<LLTexUnit*>		mTexUnits; -	LLTexUnit*			mDummyTexUnit; -	std::vector<LLLightState*> mLightState; +	std::array<LLTexUnit, LL_NUM_TEXTURE_LAYERS> mTexUnits; +	LLTexUnit			mDummyTexUnit; +	std::array<LLLightState, LL_NUM_LIGHT_UNITS> mLightState;  	eBlendFactor mCurrBlendColorSFactor;  	eBlendFactor mCurrBlendColorDFactor; diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index e5e6882ba1..dd0ea0096c 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -314,13 +314,16 @@ public:      U32 mTouchCount = 0; -#if ANALYZE_VBO_POOL      U64 mDistributed = 0;      U64 mAllocated = 0;      U64 mReserved = 0;      U32 mMisses = 0;      U32 mHits = 0; -#endif + +    U64 getVramBytesUsed() +    { +        return mAllocated + mReserved; +    }      // increase the size to some common value (e.g. a power of two) to increase hit rate      void adjustSize(U32& size) @@ -341,13 +344,9 @@ public:          llassert(data == nullptr);  // non null data indicates a buffer that wasn't freed          llassert(size >= 2);  // any buffer size smaller than a single index is nonsensical -#if ANALYZE_VBO_POOL          mDistributed += size;          adjustSize(size);          mAllocated += size; -#else -        adjustSize(size); -#endif          auto& pool = type == GL_ELEMENT_ARRAY_BUFFER ? mIBOPool : mVBOPool; @@ -357,9 +356,7 @@ public:              LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vbo pool miss");              LL_PROFILE_GPU_ZONE("vbo alloc"); -#if ANALYZE_VBO_POOL              mMisses++; -#endif              name = gen_buffer();              glBindBuffer(type, name);              glBufferData(type, size, nullptr, GL_DYNAMIC_DRAW); @@ -376,11 +373,9 @@ public:          }          else          { -#if ANALYZE_VBO_POOL              mHits++;              llassert(mReserved >= size); // assert if accounting gets messed up              mReserved -= size; -#endif              std::list<Entry>& entries = iter->second;              Entry& entry = entries.back(); @@ -407,16 +402,12 @@ public:          clean(); -#if ANALYZE_VBO_POOL          llassert(mDistributed >= size);          mDistributed -= size;          adjustSize(size);          llassert(mAllocated >= size);          mAllocated -= size;          mReserved += size; -#else -        adjustSize(size); -#endif          auto& pool = type == GL_ELEMENT_ARRAY_BUFFER ? mIBOPool : mVBOPool; @@ -465,10 +456,8 @@ public:                      auto& entry = entries.back();                      ll_aligned_free_16(entry.mData);                      glDeleteBuffers(1, &entry.mGLName); -#if ANALYZE_VBO_POOL                      llassert(mReserved >= iter->first);                      mReserved -= iter->first; -#endif                      entries.pop_back();                  } @@ -484,7 +473,7 @@ public:              }          } -#if ANALYZE_VBO_POOL +#if 0          LL_INFOS() << llformat("(%d/%d)/%d MB (distributed/allocated)/total in VBO Pool. Overhead: %d percent. Hit rate: %d percent",               mDistributed / 1000000,               mAllocated / 1000000,  @@ -515,9 +504,7 @@ public:              }          } -#if ANALYZE_VBO_POOL          mReserved = 0; -#endif          mIBOPool.clear();          mVBOPool.clear(); @@ -528,6 +515,12 @@ public:  static LLVBOPool* sVBOPool = nullptr; +//static +U64 LLVertexBuffer::getBytesAllocated() +{ +    return sVBOPool ? sVBOPool->getVramBytesUsed() : 0; +} +  //============================================================================  //   //static @@ -1364,7 +1357,8 @@ void LLVertexBuffer::setBuffer()      // this Vertex Buffer must provide all necessary attributes for currently bound shader      llassert_msg((data_mask & mTypeMask) == data_mask, -        "Attribute mask mismatch! mTypeMask should be a superset of data_mask.  data_mask: 0x" << std::hex << data_mask << " mTypeMask: 0x" << mTypeMask << std::dec); +        "Attribute mask mismatch! mTypeMask should be a superset of data_mask.  data_mask: 0x"  +                << std::hex << data_mask << " mTypeMask: 0x" << mTypeMask << " Missing: 0x" << (data_mask & ~mTypeMask) <<  std::dec);      if (sGLRenderBuffer != mGLBuffer)      { diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 571856f013..f2d146d4bb 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -256,6 +256,8 @@ private:      bool	allocateBuffer(S32 nverts, S32 nindices, BOOL create) { return allocateBuffer(nverts, nindices); }  public: + +    static U64 getBytesAllocated();  	static const U32 sTypeSize[TYPE_MAX];  	static const U32 sGLMode[LLRender::NUM_MODES];  	static U32 sGLRenderBuffer; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 10cf7513b5..666adcf672 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -4857,13 +4857,14 @@ void LLWindowWin32::LLWindowWin32Thread::updateVRAMUsage()          DXGI_QUERY_VIDEO_MEMORY_INFO info;          mDXGIAdapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info); -  #if 0 // debug 0 budget and 0 CU          info.Budget = 0;          info.CurrentUsage = 0;  #endif          U32 budget_mb = info.Budget / 1024 / 1024; +        gGLManager.mVRAM = llmax(gGLManager.mVRAM, (S32) budget_mb); +          U32 afr_mb = info.AvailableForReservation / 1024 / 1024;          // correct for systems that misreport budget          if (budget_mb == 0) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ffe2202a6d..a369b22ef1 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -12627,27 +12627,16 @@        <key>Value</key>        <real>20.0</real>      </map> -    <key>TextureCameraMotionThreshold</key> +    <key>TextureBiasDistanceScale</key>      <map>        <key>Comment</key> -      <string>If the overall motion is lower than this value, textures will be loaded faster</string> +      <string>When biasing textures to lower resolution due to lack of vram, weight to put on distance factor.</string>        <key>Persist</key>        <integer>1</integer>        <key>Type</key>        <string>F32</string>        <key>Value</key> -      <real>0.2</real> -    </map> -    <key>TextureCameraMotionBoost</key> -    <map> -      <key>Comment</key> -      <string>Progressive discard level decrement when the camera is still</string> -      <key>Persist</key> -      <integer>1</integer> -      <key>Type</key> -      <string>S32</string> -      <key>Value</key> -      <integer>3</integer> +      <real>8.0</real>      </map>      <key>TextureDecodeDisabled</key>      <map> diff --git a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl index 1e640d95ae..929b4e17b1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl @@ -35,7 +35,6 @@ out vec4 frag_color;  uniform sampler2D diffuseRect;  uniform sampler2D depthMap; -uniform sampler2D bloomMap;  uniform float depth_cutoff;  uniform float norm_cutoff; @@ -81,7 +80,6 @@ void main()  	sc = min(sc, max_cof);  	sc = max(sc, -max_cof); -	vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy); -	frag_color.rgb = diff.rgb + bloom.rgb; +	frag_color.rgb = diff.rgb;  	frag_color.a = sc/max_cof*0.5+0.5;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index a1cab87092..d41e0b202b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -59,9 +59,9 @@ ATTRIBUTE vec2 texcoord0;  ATTRIBUTE vec4 tangent;  ATTRIBUTE vec2 texcoord1; -VARYING vec3 vary_mat0; -VARYING vec3 vary_mat1; -VARYING vec3 vary_mat2; +out vec3 vary_tangent; +flat out float vary_sign; +out vec3 vary_normal;  VARYING vec2 vary_texcoord1;  #else @@ -111,24 +111,21 @@ void main()  	vec3 n = normalize((mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz);  #ifdef HAS_NORMAL_MAP  	vec3 t = normalize((mat*vec4(tangent.xyz+position.xyz,1.0)).xyz-pos.xyz); -	vec3 b = cross(n, t)*tangent.w; -	 -	vary_mat0 = vec3(t.x, b.x, n.x); -	vary_mat1 = vec3(t.y, b.y, n.y); -	vary_mat2 = vec3(t.z, b.z, n.z); + +    vary_tangent = t; +    vary_sign = tangent.w; +    vary_normal = n;  #else //HAS_NORMAL_MAP -vary_normal  = n; +	vary_normal  = n;  #endif //HAS_NORMAL_MAP  #else //HAS_SKIN  	vec3 n = normalize(normal_matrix * normal);  #ifdef HAS_NORMAL_MAP  	vec3 t = normalize(normal_matrix * tangent.xyz); -	vec3 b = cross(n,t)*tangent.w; -	//vec3 t = cross(b,n) * binormal.w; -	 -	vary_mat0 = vec3(t.x, b.x, n.x); -	vary_mat1 = vec3(t.y, b.y, n.y); -	vary_mat2 = vec3(t.z, b.z, n.z); + +    vary_tangent = t; +    vary_sign = tangent.w; +    vary_normal = n;  #else //HAS_NORMAL_MAP  	vary_normal = n;  #endif //HAS_NORMAL_MAP diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 383fcaa9a7..87324bca7f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -34,6 +34,7 @@ out vec4 frag_color;  #endif  uniform sampler2D diffuseRect; +uniform sampler2D emissiveRect;  uniform vec2 screen_res;  VARYING vec2 vary_fragcoord; @@ -180,7 +181,7 @@ vec3 legacyGamma(vec3 color)  void main()   {      //this is the one of the rare spots where diffuseRect contains linear color values (not sRGB) -    vec4 diff = texture2D(diffuseRect, vary_fragcoord); +    vec4 diff = texture2D(diffuseRect, vary_fragcoord) + texture2D(emissiveRect, vary_fragcoord);      diff.rgb = toneMap(diff.rgb);      diff.rgb = legacyGamma(diff.rgb); diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl index a79f644aef..1b868aee8d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl @@ -34,7 +34,6 @@ out vec4 frag_color;  #endif  uniform sampler2D diffuseRect; -uniform sampler2D bloomMap;  uniform vec2 screen_res;  VARYING vec2 vary_fragcoord; @@ -43,7 +42,6 @@ void main()  {  	vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy); -	vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy); -	frag_color = diff + bloom; +	frag_color = diff;  } diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl index 3ead2149f5..770c436ede 100644 --- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl @@ -29,7 +29,6 @@  out vec4 frag_color; -uniform sampler2D emissiveRect;  uniform sampler2D diffuseRect;  uniform sampler2D depthMap; @@ -37,8 +36,7 @@ in vec2 tc;  void main()   { -	frag_color = texture2D(emissiveRect, tc) + -					texture2D(diffuseRect, tc); +	frag_color = texture2D(diffuseRect, tc);      gl_FragDepth = texture(depthMap, tc).r;  } diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index add1cb2a37..6e41df34a4 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -210,9 +210,9 @@ uniform float minimum_alpha;  #endif  #ifdef HAS_NORMAL_MAP -VARYING vec3 vary_mat0; -VARYING vec3 vary_mat1; -VARYING vec3 vary_mat2; +in vec3 vary_normal; +in vec3 vary_tangent; +flat in float vary_sign;  VARYING vec2 vary_texcoord1;  #else  VARYING vec3 vary_normal; @@ -227,14 +227,17 @@ vec2 encode_normal(vec3 n);  vec3 getNormal(inout float glossiness)  {  #ifdef HAS_NORMAL_MAP -	vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); -    glossiness *= norm.a; - -	norm.xyz = norm.xyz * 2 - 1; +	vec4 vNt = texture2D(bumpMap, vary_texcoord1.xy); +    glossiness *= vNt.a; +	vNt.xyz = vNt.xyz * 2 - 1; +    float sign = vary_sign; +    vec3 vN = vary_normal; +    vec3 vT = vary_tangent.xyz; +     +    vec3 vB = sign * cross(vN, vT); +    vec3 tnorm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN ); -	return normalize(vec3(dot(norm.xyz,vary_mat0), -			  dot(norm.xyz,vary_mat1), -			  dot(norm.xyz,vary_mat2))); +	return tnorm;  #else  	return normalize(vary_normal);  #endif @@ -316,6 +319,7 @@ void main()      //forward rendering, output lit linear color      diffcol.rgb = srgb_to_linear(diffcol.rgb);      spec.rgb = srgb_to_linear(spec.rgb); +    spec.a = glossiness; // pack glossiness into spec alpha for lighting functions      vec3 pos = vary_position; diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index b24244c188..020c7bbc74 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 50 +version 51  // The version number above should be incremented IF AND ONLY IF some  // change has been made that is sufficiently important to justify  // resetting the graphics preferences of all users to the recommended @@ -99,7 +99,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	0  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	0  RenderScreenSpaceReflections 1  0 @@ -126,7 +126,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	0  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	0  RenderScreenSpaceReflections 1  0 @@ -151,7 +151,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	0  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	2  RenderReflectionsEnabled    1   1  RenderReflectionProbeDetail	1	0 @@ -178,7 +178,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	0  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	2  RenderReflectionsEnabled    1   1  RenderReflectionProbeDetail	1	1 @@ -205,7 +205,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	1  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	2  RenderReflectionsEnabled    1   1  RenderReflectionProbeDetail	1	1 @@ -232,7 +232,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	1  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	2 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	2  RenderReflectionsEnabled    1   1  RenderReflectionProbeDetail	1	1 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index df12f56dd2..dbb33b3997 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 45 +version 46  // The version number above should be incremented IF AND ONLY IF some  // change has been made that is sufficiently important to justify  // resetting the graphics preferences of all users to the recommended @@ -95,7 +95,7 @@ RenderVolumeLODFactor		1	0.5  RenderDeferredSSAO			1	0  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	0  RenderReflectionsEnabled    1   0  RenderReflectionProbeDetail	1	0 @@ -122,7 +122,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	0  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	0  RenderReflectionsEnabled    1   1  RenderReflectionProbeDetail	1	0 @@ -149,7 +149,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	0  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	2  RenderReflectionsEnabled    1   1  RenderReflectionProbeDetail	1	0 @@ -176,7 +176,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	0  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	2  RenderReflectionsEnabled    1   1  RenderReflectionProbeDetail	1	0 @@ -203,7 +203,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	1  RenderUseAdvancedAtmospherics 1 0  RenderShadowDetail			1	0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	2  RenderReflectionsEnabled    1   1  RenderReflectionProbeDetail	1	1 @@ -230,7 +230,7 @@ RenderVolumeLODFactor		1	1.125  RenderDeferredSSAO			1	1  RenderShadowDetail			1	2  RenderUseAdvancedAtmospherics 1 0 -WLSkyDetail					1	48 +WLSkyDetail					1	96  RenderFSAASamples			1	2  RenderReflectionsEnabled    1   1  RenderReflectionProbeDetail	1	1 diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 6113c30a84..a68dba98bb 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -3959,8 +3959,6 @@ bool LLAgent::teleportCore(bool is_local)  		gTeleportDisplay = TRUE;  		LL_INFOS("Teleport") << "Non-local, setting teleport state to TELEPORT_START" << LL_ENDL;  		gAgent.setTeleportState( LLAgent::TELEPORT_START ); - -		LLSpatialPartition::sTeleportRequested = TRUE;  	}  	make_ui_sound("UISndTeleportOut"); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 061feba0a4..7731f37c94 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -572,8 +572,7 @@ static void settings_to_globals()  static void settings_modify()  {      LLPipeline::sRenderTransparentWater = gSavedSettings.getBOOL("RenderTransparentWater"); -    LLPipeline::sRenderBump = TRUE; // FALSE is deprecated --  gSavedSettings.getBOOL("RenderObjectBump"); -    LLPipeline::sRenderDeferred = TRUE; // FALSE is deprecated --  LLPipeline::sRenderBump&& gSavedSettings.getBOOL("RenderDeferred"); +    LLPipeline::sRenderDeferred = TRUE; // FALSE is deprecated      LLRenderTarget::sUseFBO             = LLPipeline::sRenderDeferred;      LLVOSurfacePatch::sLODFactor        = gSavedSettings.getF32("RenderTerrainLODFactor");      LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4] diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 45df4d0eee..04b6ebd14c 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -1094,11 +1094,11 @@ void LLDrawable::updateUVMinMax()  bool LLDrawable::isVisible() const  {  	if (LLViewerOctreeEntryData::isVisible()) -{  -		return true; -} +    {  +		    return true; +    } -{ +    {  		LLViewerOctreeGroup* group = mEntry->getGroup();  		if (group && group->isVisible())  		{ diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 87abb06285..d7e4632ab0 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -357,8 +357,6 @@ void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture)  	llassert(mTexture[ch].notNull()); -	new_texture->addTextureStats(mTexture[ch]->getMaxVirtualSize()) ; -  	if (ch == LLRender::DIFFUSE_MAP)  	{  	    getViewerObject()->changeTEImage(mTEOffset, new_texture) ; @@ -1109,20 +1107,13 @@ bool LLFace::canRenderAsMask()  		(te->getGlow() == 0.f) && // glowing masks are hard to implement - don't mask  		getTexture()->getIsAlphaMask()) // texture actually qualifies for masking (lazily recalculated but expensive)  	{ -		if (LLPipeline::sRenderDeferred) -		{ -			if (getViewerObject()->isHUDAttachment() || te->getFullbright()) -			{ //hud attachments and fullbright objects are NOT subject to the deferred rendering pipe -				return LLPipeline::sAutoMaskAlphaNonDeferred; -			} -			else -			{ -				return LLPipeline::sAutoMaskAlphaDeferred; -			} +		if (getViewerObject()->isHUDAttachment() || te->getFullbright()) +		{ //hud attachments and fullbright objects are NOT subject to the deferred rendering pipe +			return LLPipeline::sAutoMaskAlphaNonDeferred;  		}  		else  		{ -			return LLPipeline::sAutoMaskAlphaNonDeferred; +			return LLPipeline::sAutoMaskAlphaDeferred;  		}  	} @@ -1262,19 +1253,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,  			bool shiny_in_alpha = false; -			if (LLPipeline::sRenderDeferred) -			{ //store shiny in alpha if we don't have a specular map -				if  (!mat || mat->getSpecularID().isNull()) -				{ -					shiny_in_alpha = true; -				} -			} -			else +			//store shiny in alpha if we don't have a specular map +			if  (!mat || mat->getSpecularID().isNull())  			{ -				if (!mat || mat->getDiffuseAlphaMode() != LLMaterial::DIFFUSE_ALPHA_MODE_MASK) -				{ -					shiny_in_alpha = true; -				} +				shiny_in_alpha = true;  			}  			if (shiny_in_alpha) diff --git a/indra/newview/llface.h b/indra/newview/llface.h index ee8316018b..0a66dc6ba6 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -235,6 +235,7 @@ public: //aligned members  	LLVector4a		mExtents[2];  private: +    friend class LLViewerTextureList;  	F32         adjustPartialOverlapPixelArea(F32 cos_angle_to_view_dir, F32 radius );  	BOOL        calcPixelArea(F32& cos_angle_to_view_dir, F32& radius) ;  public: diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 90c4436a04..c664dbbe9e 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -94,7 +94,7 @@ void LLReflectionMapManager::update()      if (!mRenderTarget.isComplete())      { -        U32 color_fmt = GL_RGB16; +        U32 color_fmt = GL_RGB16F;          U32 targetRes = mProbeResolution * 4; // super sample          mRenderTarget.allocate(targetRes, targetRes, color_fmt, true);      } @@ -107,7 +107,7 @@ void LLReflectionMapManager::update()          mMipChain.resize(count);          for (int i = 0; i < count; ++i)          { -            mMipChain[i].allocate(res, res, GL_RGB16); +            mMipChain[i].allocate(res, res, GL_RGB16F);              res /= 2;          }      } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 35e11b8991..fc9b3093e8 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -64,8 +64,6 @@ bool LLSpatialGroup::sNoDelete = false;  static F32 sLastMaxTexPriority = 1.f;  static F32 sCurMaxTexPriority = 1.f; -bool LLSpatialPartition::sTeleportRequested = false; -  //static counter for frame to switch LOD on  void sg_assert(BOOL expr) @@ -1295,8 +1293,6 @@ void drawBoxOutline(const LLVector4a& pos, const LLVector4a& size)  class LLOctreeDirty : public OctreeTraveler  {  public: -	LLOctreeDirty(bool no_rebuild) : mNoRebuild(no_rebuild){} -  	virtual void visit(const OctreeNode* state)  	{  		LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0); @@ -1309,7 +1305,7 @@ public:  			{  				continue;  			} -			if (!mNoRebuild && drawable->getVObj().notNull() && !group->getSpatialPartition()->mRenderByGroup) +			if (drawable->getVObj().notNull() && !group->getSpatialPartition()->mRenderByGroup)  			{  				gPipeline.markRebuild(drawable, LLDrawable::REBUILD_ALL, TRUE);  			} @@ -1321,9 +1317,6 @@ public:  			traverse(bridge->mOctree);  		}  	} - -private: -	BOOL mNoRebuild;  };  void LLSpatialPartition::restoreGL() @@ -1332,7 +1325,7 @@ void LLSpatialPartition::restoreGL()  void LLSpatialPartition::resetVertexBuffers()  { -	LLOctreeDirty dirty(sTeleportRequested); +	LLOctreeDirty dirty;  	dirty.traverse(mOctree);  } @@ -3095,6 +3088,60 @@ void renderAgentTarget(LLVOAvatar* avatar)  	}  } +static void setTextureAreaDebugText(LLDrawable* drawablep) +{ +    LLVOVolume* vobjp = drawablep->getVOVolume(); + +    if (vobjp) +    { +        if (drawablep->mDistanceWRTCamera < 32.f) +        { +            std::ostringstream str; + +            //for (S32 i = 0; i < vobjp->getNumTEs(); ++i) +            S32 i = 0; +            { +                if (i < drawablep->getNumFaces()) +                { +                    LLFace* facep = drawablep->getFace(i); + +                    if (facep) +                    { +                        LLViewerTexture* imagep = facep->getTexture(); + +                        if (imagep) +                        { +                            str << llformat("D - %.2f", sqrtf(imagep->getMaxVirtualSize())); +                        } + +                        imagep = vobjp->getTENormalMap(i); + +                        if (imagep && imagep != LLViewerFetchedTexture::sDefaultImagep) +                        { +                            str << llformat("\nN - %.2f", sqrtf(imagep->getMaxVirtualSize())); +                        } + +                        imagep = vobjp->getTESpecularMap(i); + +                        if (imagep && imagep != LLViewerFetchedTexture::sDefaultImagep) +                        { +                            str << llformat("\nS - %.2f", sqrtf(imagep->getMaxVirtualSize())); +                        } + +                        str << "\n\n"; +                    } + +                    vobjp->setDebugText(str.str()); +                } +            } +        } +        else +        { +            vobjp->setDebugText("."); +        } +    } +} +  class LLOctreeRenderNonOccluded : public OctreeTraveler  {  public: @@ -3183,7 +3230,12 @@ public:  					size.mul(0.5f);  					drawBoxOutline(center, size);  				} -			}	 +			} + +            if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) +            { +                setTextureAreaDebugText(drawable); +            }  			/*if (drawable->getVOVolume() && gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY))  			{ @@ -3514,6 +3566,7 @@ void LLSpatialPartition::renderDebug()  									  LLPipeline::RENDER_DEBUG_NORMALS |  									  LLPipeline::RENDER_DEBUG_POINTS |  									  //LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY | +                                      LLPipeline::RENDER_DEBUG_TEXTURE_AREA |  									  LLPipeline::RENDER_DEBUG_TEXTURE_ANIM |  									  LLPipeline::RENDER_DEBUG_RAYCAST |  									  LLPipeline::RENDER_DEBUG_AVATAR_VOLUME | diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 9b2cb0d44c..053ce9e60b 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -433,8 +433,6 @@ public:  	U32 mVertexDataMask;  	F32 mSlopRatio; //percentage distance must change before drawables receive LOD update (default is 0.25);      bool mDepthMask; //if TRUE, objects in this partition will be written to depth during alpha rendering - -	static bool sTeleportRequested; //started to issue a teleport request  };  // class for creating bridges between spatial partitions diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index 1f4f086352..ca93eb648b 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -175,10 +175,6 @@ void LLTextureBar::draw()  	{  		color = LLColor4::green4;  	} -	else if (mImagep->getBoostLevel() > LLGLTexture::BOOST_ALM) -	{ -		color = LLColor4::magenta; // except none and alm -	}  	else if (mImagep->getMaxVirtualSize() <= 0.0f)  	{  		color = LLColor4::grey; color[VALPHA] = .7f; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index e217ede067..fd3c8de3e9 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4950,10 +4950,10 @@ void LLViewerObject::updateTEMaterialTextures(U8 te)  	if (getTE(te)->getMaterialParams().notNull())  	{  		const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID(); -		mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); +		mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);  		const LLUUID& spec_id = getTE(te)->getMaterialParams()->getSpecularID(); -		mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); +		mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(spec_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);  	}      LLFetchedGLTFMaterial* mat = (LLFetchedGLTFMaterial*) getTE(te)->getGLTFRenderMaterial(); @@ -4982,7 +4982,7 @@ void LLViewerObject::updateTEMaterialTextures(U8 te)              }              else              { -                img = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE); +                img = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);                  img->addTextureStats(64.f * 64.f, TRUE);              }          } @@ -5140,14 +5140,14 @@ S32 LLViewerObject::setTETexture(const U8 te, const LLUUID& uuid)  S32 LLViewerObject::setTENormalMap(const U8 te, const LLUUID& uuid)  {  	LLViewerFetchedTexture *image = (uuid == LLUUID::null) ? NULL : LLViewerTextureManager::getFetchedTexture( -		uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost()); +		uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost());  	return setTENormalMapCore(te, image);  }  S32 LLViewerObject::setTESpecularMap(const U8 te, const LLUUID& uuid)  {  	LLViewerFetchedTexture *image = (uuid == LLUUID::null) ? NULL : LLViewerTextureManager::getFetchedTexture( -		uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost()); +		uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost());  	return setTESpecularMapCore(te, image);  } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 816fa6607e..bb22d90cd9 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -815,19 +815,19 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)  		mCurBin = (mCurBin + 1) % NUM_BINS;  	} -#if 1 +#if 0  	// Slam priorities for textures that we care about (hovered, selected, and focused)  	// Hovered  	// Assumes only one level deep of parenting  	LLSelectNode* nodep = LLSelectMgr::instance().getHoverNode(); -	if (nodep) -	{ -		objectp = nodep->getObject(); -		if (objectp) -		{ -			objectp->boostTexturePriority(); -		} -	} +    if (nodep) +    { +        objectp = nodep->getObject(); +        if (objectp) +        { +            objectp->boostTexturePriority(); +        } +    }  	// Focused  	objectp = gAgentCamera.getFocusObject(); @@ -835,6 +835,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)  	{  		objectp->boostTexturePriority();  	} +#endif  	// Selected  	struct f : public LLSelectedObjectFunctor @@ -846,7 +847,6 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)  		}  	} func;  	LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func); -#endif  	LLVOAvatar::cullAvatarsByPixelArea();  } diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index ee39b7d02f..b1abd0a656 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -570,14 +570,11 @@ void send_viewer_stats(bool include_preferences)  			shader_level = 3;  		}  	} -	else if (gPipeline.canUseWindLightShadersOnObjects()) +	else  	{  		shader_level = 2;  	} -	else if (gPipeline.shadersLoaded()) -	{ -		shader_level = 1; -	} +	  	system["shader_level"] = shader_level; diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 578deb8b3f..ec03556ff4 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -89,8 +89,6 @@ S32 LLViewerTexture::sAuxCount = 0;  LLFrameTimer LLViewerTexture::sEvaluationTimer;  F32 LLViewerTexture::sDesiredDiscardBias = 0.f;  F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; -S8  LLViewerTexture::sCameraMovingDiscardBias = 0; -F32 LLViewerTexture::sCameraMovingBias = 0.0f;  S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size  const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64;  const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez; @@ -103,8 +101,6 @@ F32 LLViewerTexture::sCurrentTime = 0.0f;  LLViewerTexture::EDebugTexels LLViewerTexture::sDebugTexelsMode = LLViewerTexture::DEBUG_TEXELS_OFF; -const F32 desired_discard_bias_min = -2.0f; // -max number of levels to improve image quality by -const F32 desired_discard_bias_max = (F32)MAX_DISCARD_LEVEL; // max number of levels to reduce image quality by  const F64 log_2 = log(2.0);  #if ADDRESS_SIZE == 32 @@ -471,8 +467,6 @@ void LLViewerTexture::initClass()  }  // tuning params -const F32 discard_bias_delta = .25f; -const F32 discard_delta_time = 0.5f;  const F32 GPU_MEMORY_CHECK_WAIT_TIME = 1.0f;  // non-const (used externally  F32 texmem_lower_bound_scale = 0.85f; @@ -552,29 +546,26 @@ void LLViewerTexture::updateClass()  	LLViewerMediaTexture::updateClass(); -	if(isMemoryForTextureLow()) -	{ -		// Note: isMemoryForTextureLow() uses 1s delay, make sure we waited enough for it to recheck -		if (sEvaluationTimer.getElapsedTimeF32() > GPU_MEMORY_CHECK_WAIT_TIME) -		{ -			sDesiredDiscardBias += discard_bias_delta; -			sEvaluationTimer.reset(); -		} -	} -	else if (sDesiredDiscardBias > 0.0f -			 && isMemoryForTextureSuficientlyFree()) -	{ -		// If we are using less texture memory than we should, -		// scale down the desired discard level -		if (sEvaluationTimer.getElapsedTimeF32() > discard_delta_time) -		{ -			sDesiredDiscardBias -= discard_bias_delta; -			sEvaluationTimer.reset(); -		} -	} -	sDesiredDiscardBias = llclamp(sDesiredDiscardBias, desired_discard_bias_min, desired_discard_bias_max); +    static LLCachedControl<U32> max_vram_budget(gSavedSettings, "RenderMaxVRAMBudget", 0); + +    // get an estimate of how much video memory we're using  +    // NOTE: our metrics miss about half the vram we use, so this biases high but turns out to typically be within 5% of the real number +    F32 used = (LLImageGL::getTextureBytesAllocated() + LLVertexBuffer::getBytesAllocated()) / 1024 / 512; +     +    F32 budget = max_vram_budget == 0 ? gGLManager.mVRAM : max_vram_budget; + +    // try to leave half a GB for everyone else, but keep at least 768MB for ourselves +    F32 target = llmax(budget - 512.f, 768.f); + +    F32 over_pct = llmax((used-target) / target, 0.f); +    sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct); -	LLViewerTexture::sFreezeImageUpdates = sDesiredDiscardBias > (desired_discard_bias_max - 1.0f); +    if (sDesiredDiscardBias > 1.f) +    { +        sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01; +    } + +    LLViewerTexture::sFreezeImageUpdates = false; // sDesiredDiscardBias > (desired_discard_bias_max - 1.0f);  }  //end of static functions @@ -627,7 +618,6 @@ LLViewerTexture::~LLViewerTexture()  // virtual  void LLViewerTexture::init(bool firstinit)  { -	mSelectedTime = 0.f;  	mMaxVirtualSize = 0.f;  	mMaxVirtualSizeResetInterval = 1;  	mMaxVirtualSizeResetCounter = mMaxVirtualSizeResetInterval; @@ -685,7 +675,6 @@ void LLViewerTexture::setBoostLevel(S32 level)  	{  		mBoostLevel = level;  		if(mBoostLevel != LLViewerTexture::BOOST_NONE &&  -			mBoostLevel != LLViewerTexture::BOOST_ALM &&   			mBoostLevel != LLViewerTexture::BOOST_SELECTED &&   			mBoostLevel != LLViewerTexture::BOOST_ICON)  		{ @@ -698,12 +687,6 @@ void LLViewerTexture::setBoostLevel(S32 level)      {          mMaxVirtualSize = 2048.f * 2048.f;      } - -	if (mBoostLevel == LLViewerTexture::BOOST_SELECTED) -	{ -		mSelectedTime = gFrameTimeSeconds; -	} -  }  bool LLViewerTexture::isActiveFetching() @@ -1710,10 +1693,6 @@ void LLViewerFetchedTexture::processTextureStats()  		{  			mDesiredDiscardLevel = 0;  		} -		else if (!LLPipeline::sRenderDeferred && mBoostLevel == LLGLTexture::BOOST_ALM) -		{ // ??? don't load spec and normal maps when alm is disabled ??? -			mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; -		}          else if (mDontDiscard && mBoostLevel == LLGLTexture::BOOST_ICON)          {              if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) @@ -1831,8 +1810,7 @@ bool LLViewerFetchedTexture::updateFetch()  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;  	static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled", false); -	static LLCachedControl<F32>  sCameraMotionThreshold(gSavedSettings,"TextureCameraMotionThreshold", 0.2); -	static LLCachedControl<S32>  sCameraMotionBoost(gSavedSettings,"TextureCameraMotionBoost", 3); +	  	if(textures_decode_disabled) // don't fetch the surface textures in wireframe mode  	{  		return false; @@ -2055,32 +2033,9 @@ bool LLViewerFetchedTexture::updateFetch()  		make_request = false;  		switchToCachedImage(); //use the cached raw data first  	} -	//else if (!isJustBound() && mCachedRawImageReady) -	//{ -	//	make_request = false; -	//}  	if (make_request)  	{ -#if 0 -		// Load the texture progressively: we try not to rush to the desired discard too fast. -		// If the camera is not moving, we do not tweak the discard level notch by notch but go to the desired discard with larger boosted steps -		// This mitigates the "textures stay blurry" problem when loading while not killing the texture memory while moving around -		S32 delta_level = (mBoostLevel > LLGLTexture::BOOST_ALM) ? 2 : 1;  -		if (current_discard < 0) -		{ -			desired_discard = llmax(desired_discard, getMaxDiscardLevel() - delta_level); -		} -		else if (LLViewerTexture::sCameraMovingBias < sCameraMotionThreshold) -		{ -			desired_discard = llmax(desired_discard, current_discard - sCameraMotionBoost); -		} -        else -        { -			desired_discard = llmax(desired_discard, current_discard - delta_level); -        } -#endif -  		if (mIsFetching)  		{              // already requested a higher resolution mip @@ -3095,10 +3050,6 @@ void LLViewerLODTexture::processTextureStats()  		if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT)  			mDesiredDiscardLevel = 1; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048  	} -	else if (!LLPipeline::sRenderDeferred && mBoostLevel == LLGLTexture::BOOST_ALM) -	{ -		mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; -	}  	else if (mBoostLevel < LLGLTexture::BOOST_HIGH && mMaxVirtualSize <= 10.f)  	{  		// If the image has not been significantly visible in a while, we don't want it @@ -3108,72 +3059,69 @@ void LLViewerLODTexture::processTextureStats()  	{  		mDesiredDiscardLevel = 	getMaxDiscardLevel();  	} -	else -	{ -		//static const F64 log_2 = log(2.0); -		static const F64 log_4 = log(4.0); +    else +    { +        //static const F64 log_2 = log(2.0); +        static const F64 log_4 = log(4.0); -		F32 discard_level = 0.f; +        F32 discard_level = 0.f; -		// If we know the output width and height, we can force the discard -		// level to the correct value, and thus not decode more texture -		// data than we need to. -		if (mKnownDrawWidth && mKnownDrawHeight) -		{ -			S32 draw_texels = mKnownDrawWidth * mKnownDrawHeight; -			draw_texels = llclamp(draw_texels, MIN_IMAGE_AREA, MAX_IMAGE_AREA); +        // If we know the output width and height, we can force the discard +        // level to the correct value, and thus not decode more texture +        // data than we need to. +        if (mKnownDrawWidth && mKnownDrawHeight) +        { +            S32 draw_texels = mKnownDrawWidth * mKnownDrawHeight; +            draw_texels = llclamp(draw_texels, MIN_IMAGE_AREA, MAX_IMAGE_AREA); -			// Use log_4 because we're in square-pixel space, so an image -			// with twice the width and twice the height will have mTexelsPerImage -			// 4 * draw_size -			discard_level = (F32)(log(mTexelsPerImage/draw_texels) / log_4); -		} -		else -		{ -			// Calculate the required scale factor of the image using pixels per texel -			discard_level = (F32)(log(mTexelsPerImage/mMaxVirtualSize) / log_4); -			mDiscardVirtualSize = mMaxVirtualSize; -			mCalculatedDiscardLevel = discard_level; -		} -		if (mBoostLevel < LLGLTexture::BOOST_SCULPTED) -		{ -			discard_level += sDesiredDiscardBias; -			discard_level *= sDesiredDiscardScale; // scale -			discard_level += sCameraMovingDiscardBias; -		} -		discard_level = floorf(discard_level); +            // Use log_4 because we're in square-pixel space, so an image +            // with twice the width and twice the height will have mTexelsPerImage +            // 4 * draw_size +            discard_level = (F32)(log(mTexelsPerImage / draw_texels) / log_4); +        } +        else +        { +            // Calculate the required scale factor of the image using pixels per texel +            discard_level = (F32)(log(mTexelsPerImage / mMaxVirtualSize) / log_4); +            mDiscardVirtualSize = mMaxVirtualSize; +            mCalculatedDiscardLevel = discard_level; +        } +        if (mBoostLevel < LLGLTexture::BOOST_SCULPTED) +        { +            discard_level *= sDesiredDiscardScale; // scale (default 1.1f) +        } +        discard_level = floorf(discard_level); -		F32 min_discard = 0.f; -		U32 desired_size = MAX_IMAGE_SIZE_DEFAULT; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 -		if (mBoostLevel <= LLGLTexture::BOOST_SCULPTED) -		{ -			desired_size = DESIRED_NORMAL_TEXTURE_SIZE; -		} -		if (mFullWidth > desired_size || mFullHeight > desired_size) -			min_discard = 1.f; +        F32 min_discard = 0.f; +        U32 desired_size = MAX_IMAGE_SIZE_DEFAULT; // MAX_IMAGE_SIZE_DEFAULT = 1024 and max size ever is 2048 +        if (mBoostLevel <= LLGLTexture::BOOST_SCULPTED) +        { +            desired_size = DESIRED_NORMAL_TEXTURE_SIZE; +        } +        if (mFullWidth > desired_size || mFullHeight > desired_size) +            min_discard = 1.f; -		discard_level = llclamp(discard_level, min_discard, (F32)MAX_DISCARD_LEVEL); -		 -		// Can't go higher than the max discard level -		mDesiredDiscardLevel = llmin(getMaxDiscardLevel() + 1, (S32)discard_level); -		// Clamp to min desired discard -		mDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel, mDesiredDiscardLevel); +        discard_level = llclamp(discard_level, min_discard, (F32)MAX_DISCARD_LEVEL); -		// -		// At this point we've calculated the quality level that we want, -		// if possible.  Now we check to see if we have it, and take the -		// proper action if we don't. -		// +        // Can't go higher than the max discard level +        mDesiredDiscardLevel = llmin(getMaxDiscardLevel() + 1, (S32)discard_level); +        // Clamp to min desired discard +        mDesiredDiscardLevel = llmin(mMinDesiredDiscardLevel, mDesiredDiscardLevel); -		S32 current_discard = getDiscardLevel(); -		if (sDesiredDiscardBias > 0.0f && mBoostLevel < LLGLTexture::BOOST_SCULPTED && current_discard >= 0) -		{ -			if(desired_discard_bias_max <= sDesiredDiscardBias && !mForceToSaveRawImage) -			{ -				//needs to release texture memory urgently -				scaleDown(); -			} -		} +        // +        // At this point we've calculated the quality level that we want, +        // if possible.  Now we check to see if we have it, and take the +        // proper action if we don't. +        // + +        S32 current_discard = getDiscardLevel(); +        if (mBoostLevel < LLGLTexture::BOOST_SCULPTED && current_discard >= 0) +        { +            if (current_discard < (mDesiredDiscardLevel-1) && !mForceToSaveRawImage) +            { // should scale down +                scaleDown(); +            } +        }  		if (isUpdateFrozen() // we are out of memory and nearing max allowed bias  			&& mBoostLevel < LLGLTexture::BOOST_SCULPTED @@ -3188,6 +3136,16 @@ void LLViewerLODTexture::processTextureStats()  	{  		mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel);  	} + +    // decay max virtual size over time +    mMaxVirtualSize *= 0.8f; + +    // selection manager will immediately reset BOOST_SELECTED but never unsets it +    // unset it immediately after we consume it +    if (getBoostLevel() == BOOST_SELECTED) +    { +        setBoostLevel(BOOST_NONE); +    }  }  bool LLViewerLODTexture::scaleDown() diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index facf05e52f..1370f4debe 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -195,7 +195,6 @@ protected:  	LLUUID mID;  	S32 mTextureListType; // along with mID identifies where to search for this texture in TextureList -	F32 mSelectedTime;				// time texture was last selected  	mutable F32 mMaxVirtualSize = 0.f;	// The largest virtual size of the image, in pixels - how much data to we need?	  	mutable S32  mMaxVirtualSizeResetCounter;  	mutable S32  mMaxVirtualSizeResetInterval; @@ -223,8 +222,6 @@ public:  	static LLFrameTimer sEvaluationTimer;  	static F32 sDesiredDiscardBias;  	static F32 sDesiredDiscardScale; -	static S8  sCameraMovingDiscardBias; -	static F32 sCameraMovingBias;  	static S32 sMaxSculptRez ;  	static U32 sMinLargeImageSize ;  	static U32 sMaxSmallImageSize ; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 611aace4b4..0f89401bf1 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -61,6 +61,7 @@  #include "llviewerdisplay.h"  #include "llviewerwindow.h"  #include "llprogressview.h" +  ////////////////////////////////////////////////////////////////////////////  void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL; @@ -533,12 +534,6 @@ LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id,  	LLPointer<LLViewerFetchedTexture> imagep = findImage(image_id, get_element_type(boost_priority));  	if (!imagep.isNull())  	{ -		if (boost_priority != LLViewerTexture::BOOST_ALM && imagep->getBoostLevel() == LLViewerTexture::BOOST_ALM) -		{ -			// Workaround: we need BOOST_ALM texture for something, 'rise' to NONE -			imagep->setBoostLevel(LLViewerTexture::BOOST_NONE); -		} -  		LLViewerFetchedTexture *texture = imagep.get();  		if (request_from_host.isOk() &&  			!texture->getTargetHost().isOk()) @@ -874,6 +869,8 @@ static void touch_texture(LLViewerFetchedTexture* tex, F32 vsize)      }  } +extern BOOL gCubeSnapshot; +  void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep)  {      if (imagep->isInDebug() || imagep->isUnremovable()) @@ -882,18 +879,36 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag          return; //is in debug, ignore.      } +    llassert(!gCubeSnapshot); + +    static LLCachedControl<F32> bias_distance_scale(gSavedSettings, "TextureBiasDistanceScale", 1.f); +      LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE      {          for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)          {              for (U32 fi = 0; fi < imagep->getNumFaces(i); ++fi)              { -                const LLFace* face = (*(imagep->getFaceList(i)))[fi]; +                LLFace* face = (*(imagep->getFaceList(i)))[fi];                  if (face && face->getViewerObject() && face->getTextureEntry())                  { -                    F32 vsize = face->getVirtualSize(); - +                    F32 vsize = face->getPixelArea(); + +#if LL_DARWIN +                    vsize /= 1.f + LLViewerTexture::sDesiredDiscardBias*(1.f+face->getDrawable()->mDistanceWRTCamera*bias_distance_scale); +#else +                    vsize /= LLViewerTexture::sDesiredDiscardBias; +                    vsize /= llmax(1.f, (LLViewerTexture::sDesiredDiscardBias-1.f) * (1.f + face->getDrawable()->mDistanceWRTCamera * bias_distance_scale)); + +                    F32 radius; +                    F32 cos_angle_to_view_dir; +                    BOOL in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); +                    if (!in_frustum || !face->getDrawable()->isVisible()) +                    { // further reduce by discard bias when off screen or occluded +                        vsize /= LLViewerTexture::sDesiredDiscardBias; +                    } +#endif                      // if a GLTF material is present, ignore that face                      // as far as this texture stats go, but update the GLTF material                       // stats @@ -914,7 +929,9 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag              }          }      } -     + +    //imagep->setDebugText(llformat("%.3f - %d", sqrtf(imagep->getMaxVirtualSize()), imagep->getBoostLevel())); +      F32 lazy_flush_timeout = 30.f; // stop decoding      F32 max_inactive_time = 20.f; // actually delete      S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index e69dea3444..d1f4fa1c7a 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -858,12 +858,6 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)  			continue;  		} -        // clear out boost selected periodically -        if (imagep->getBoostLevel() == LLGLTexture::BOOST_SELECTED) -        { -            imagep->setBoostLevel(LLGLTexture::BOOST_NONE); -        } -  		F32 vsize;  		F32 old_size = face->getVirtualSize(); @@ -878,7 +872,6 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)  		else  		{  			vsize = face->getTextureVirtualSize(); -            imagep->addTextureStats(vsize);  		}  		mPixelArea = llmax(mPixelArea, face->getPixelArea()); @@ -895,12 +888,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)  			}  		} -		if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) -		{ -			if (vsize < min_vsize) min_vsize = vsize; -			if (vsize > max_vsize) max_vsize = vsize; -		} -		else if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY)) +		if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY))  		{  			LLViewerFetchedTexture* img = LLViewerTextureManager::staticCastToFetchedTexture(imagep) ;  			if(img) @@ -965,7 +953,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)  	{  		LLLightImageParams* params = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);  		LLUUID id = params->getLightTexture(); -		mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM); +		mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE);  		if (mLightTexture.notNull())  		{  			F32 rad = getLightRadius(); @@ -3307,7 +3295,6 @@ void LLVOVolume::updateSpotLightPriority()  	if (mLightTexture.notNull())  	{  		mLightTexture->addTextureStats(mSpotLightPriority); -		mLightTexture->setBoostLevel(LLGLTexture::BOOST_CLOUDS);  	}  } @@ -3331,7 +3318,7 @@ LLViewerTexture* LLVOVolume::getLightTexture()  	{  		if (mLightTexture.isNull() || id != mLightTexture->getID())  		{ -			mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_ALM); +			mLightTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE);  		}  	}  	else @@ -5482,7 +5469,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,      llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_RIGGED || info->mGLTFMaterial != nullptr);      llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK || info->mGLTFMaterial != nullptr);      llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK_RIGGED || info->mGLTFMaterial != nullptr); - +     +    llassert(type != LLRenderPass::PASS_BUMP || (info->mVertexBuffer->getTypeMask() & LLVertexBuffer::MAP_TANGENT) != 0);      llassert(type != LLRenderPass::PASS_NORMSPEC || info->mNormalMap.notNull());  } @@ -5755,7 +5743,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)  			rigged = rigged || (vobj->isAnimatedObject() && vobj->isRiggedMesh() &&                  vobj->getControlAvatar() && vobj->getControlAvatar()->mPlaying); -			bool bake_sunlight = LLPipeline::sBakeSunlight && drawablep->isStatic();  			bool any_rigged_face = false;  			//for each face @@ -5913,13 +5900,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)  							facep->mLastUpdateTime = gFrameTimeSeconds;  						} -						if (gPipeline.canUseWindLightShadersOnObjects() -							&& LLPipeline::sRenderBump)  						{                              LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); -							if (LLPipeline::sRenderDeferred &&  -                                (gltf_mat != nullptr || (te->getMaterialParams().notNull()  && !te->getMaterialID().isNull()))) +							if (gltf_mat != nullptr || (te->getMaterialParams().notNull()  && !te->getMaterialID().isNull()))  							{                                  if (gltf_mat != nullptr)                                  { @@ -5928,7 +5912,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)                                  else                                  {                                      LLMaterial* mat = te->getMaterialParams().get(); -                                    if (mat->getNormalID().notNull()) +                                    if (mat->getNormalID().notNull() || // <-- has a normal map, needs tangents +                                        (te->getBumpmap() && (te->getBumpmap() < 18))) // <-- has an emboss bump map, needs tangents                                      {                                          if (mat->getSpecularID().notNull())                                          { //has normal and specular maps (needs texcoord1, texcoord2, and tangent) @@ -5963,23 +5948,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)                                  add_face(sFullbrightFaces, fullbright_count, facep);  							}  						} -						else -						{ -							if (te->getBumpmap() && LLPipeline::sRenderBump) -							{ //needs normal + tangent -                                add_face(sBumpFaces, bump_count, facep); -							} -							else if ((te->getShiny() && LLPipeline::sRenderBump) || -								!(te->getFullbright() || bake_sunlight)) -							{ //needs normal -                                add_face(sSimpleFaces, simple_count, facep); -							} -							else  -							{ //doesn't need normal -								facep->setState(LLFace::FULLBRIGHT); -                                add_face(sFullbrightFaces, fullbright_count, facep); -							} -						}  					}  				}  				else @@ -6207,7 +6175,7 @@ struct CompareBatchBreaker  		{  			return lte->getFullbright() < rte->getFullbright();  		} -        else if (LLPipeline::sRenderDeferred && lte->getMaterialID() != rte->getMaterialID()) +        else if (lte->getMaterialID() != rte->getMaterialID())          {              return lte->getMaterialID() < rte->getMaterialID();          } @@ -6298,13 +6266,9 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace  		texture_index_channels = LLGLSLShader::sIndexedTextureChannels-1; //always reserve one for shiny for now just for simplicity;  	} -	if (LLPipeline::sRenderDeferred && distance_sort) +	if (distance_sort)  	{  		texture_index_channels = gDeferredAlphaProgram.mFeatures.mIndexedTextureChannels; -	} -     -    if (distance_sort) -    {          buffer_index = -1;      } @@ -6660,6 +6624,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace  				}  				else if (use_legacy_bump)  				{ +                    llassert(mask & LLVertexBuffer::MAP_TANGENT);  					// we have a material AND legacy bump settings, but no normal map  					registerFace(group, facep, LLRenderPass::PASS_BUMP);  				} @@ -6719,7 +6684,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace  					registerFace(group, facep, LLRenderPass::PASS_ALPHA);  				}  				else if (gPipeline.shadersLoaded() -					&& LLPipeline::sRenderBump   					&& te->getShiny()   					&& can_be_shiny)  				{ @@ -6754,7 +6718,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace  				}  			}  			else if (gPipeline.shadersLoaded() -				&& LLPipeline::sRenderBump   				&& te->getShiny()   				&& can_be_shiny)  			{ //shiny @@ -6775,6 +6738,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace  					}  					else if (use_legacy_bump)  					{ //register in deferred bump pass +                        llassert(mask& LLVertexBuffer::MAP_TANGENT);  						registerFace(group, facep, LLRenderPass::PASS_BUMP);  					}  					else @@ -6808,15 +6772,16 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace  					{  						registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT);  					} -					if (!hud_group && LLPipeline::sRenderBump && use_legacy_bump) +					if (!hud_group && use_legacy_bump)  					{ //if this is the deferred render and a bump map is present, register in post deferred bump  						registerFace(group, facep, LLRenderPass::PASS_POST_BUMP);  					}  				}  				else  				{ -					if (LLPipeline::sRenderDeferred && LLPipeline::sRenderBump && use_legacy_bump) +					if (use_legacy_bump)  					{ //non-shiny or fullbright deferred bump +                        llassert(mask& LLVertexBuffer::MAP_TANGENT);  						registerFace(group, facep, LLRenderPass::PASS_BUMP);  					}  					else @@ -6836,8 +6801,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace  				if (!gPipeline.shadersLoaded() &&   					!is_alpha &&  -					te->getShiny() &&  -					LLPipeline::sRenderBump) +					te->getShiny())  				{ //shiny as an extra pass when shaders are disabled  					registerFace(group, facep, LLRenderPass::PASS_SHINY);  				} @@ -6849,8 +6813,9 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace  				llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright);  				facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); -				if (!force_simple && LLPipeline::sRenderBump && use_legacy_bump) +				if (!force_simple && use_legacy_bump)  				{ +                    llassert(mask & LLVertexBuffer::MAP_TANGENT);  					registerFace(group, facep, LLRenderPass::PASS_BUMP);  				}  			} diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index deafa6900e..18b0192346 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -308,7 +308,6 @@ bool	LLPipeline::sDelayVBUpdate = true;  bool	LLPipeline::sAutoMaskAlphaDeferred = true;  bool	LLPipeline::sAutoMaskAlphaNonDeferred = false;  bool	LLPipeline::sRenderTransparentWater = true; -bool	LLPipeline::sRenderBump = true;  bool	LLPipeline::sBakeSunlight = false;  bool	LLPipeline::sNoAlpha = false;  bool	LLPipeline::sUseFarClip = true; @@ -400,7 +399,6 @@ void LLPipeline::init()  	gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity");  	gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize");  	sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); -    sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump");  	sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights");  	sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles"); @@ -968,12 +966,6 @@ void LLPipeline::updateRenderTransparentWater()      sRenderTransparentWater = gSavedSettings.getBOOL("RenderTransparentWater");  } -//static -void LLPipeline::updateRenderBump() -{ -    sRenderBump = TRUE; // DEPRECATED -- gSavedSettings.getBOOL("RenderObjectBump"); -} -  // static  void LLPipeline::refreshCachedSettings()  { @@ -1183,46 +1175,44 @@ void LLPipeline::createGLBuffers()      mRT->width = 0;      mRT->height = 0; -    if (sRenderDeferred) -    { -		if (!mNoiseMap) -		{ -			const U32 noiseRes = 128; -			LLVector3 noise[noiseRes*noiseRes]; +     +	if (!mNoiseMap) +	{ +		const U32 noiseRes = 128; +		LLVector3 noise[noiseRes*noiseRes]; -			F32 scaler = gSavedSettings.getF32("RenderDeferredNoise")/100.f; -			for (U32 i = 0; i < noiseRes*noiseRes; ++i) -			{ -				noise[i] = LLVector3(ll_frand()-0.5f, ll_frand()-0.5f, 0.f); -				noise[i].normVec(); -				noise[i].mV[2] = ll_frand()*scaler+1.f-scaler/2.f; -			} +		F32 scaler = gSavedSettings.getF32("RenderDeferredNoise")/100.f; +		for (U32 i = 0; i < noiseRes*noiseRes; ++i) +		{ +			noise[i] = LLVector3(ll_frand()-0.5f, ll_frand()-0.5f, 0.f); +			noise[i].normVec(); +			noise[i].mV[2] = ll_frand()*scaler+1.f-scaler/2.f; +		} -			LLImageGL::generateTextures(1, &mNoiseMap); +		LLImageGL::generateTextures(1, &mNoiseMap); -			gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); -			LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false); -			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); -		} +		gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap); +		LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false); +		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); +	} -		if (!mTrueNoiseMap) +	if (!mTrueNoiseMap) +	{ +		const U32 noiseRes = 128; +		F32 noise[noiseRes*noiseRes*3]; +		for (U32 i = 0; i < noiseRes*noiseRes*3; i++)  		{ -			const U32 noiseRes = 128; -			F32 noise[noiseRes*noiseRes*3]; -			for (U32 i = 0; i < noiseRes*noiseRes*3; i++) -			{ -				noise[i] = ll_frand()*2.0-1.0; -			} - -			LLImageGL::generateTextures(1, &mTrueNoiseMap); -			gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap); -			LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false); -			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); +			noise[i] = ll_frand()*2.0-1.0;  		} -		createLUTBuffers(); +		LLImageGL::generateTextures(1, &mTrueNoiseMap); +		gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap); +		LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false); +		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);  	} +	createLUTBuffers(); +  	gBumpImageList.restoreGL();  } @@ -1233,70 +1223,67 @@ F32 lerpf(F32 a, F32 b, F32 w)  void LLPipeline::createLUTBuffers()  { -	if (sRenderDeferred) +	if (!mLightFunc)  	{ -		if (!mLightFunc) +		U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); +		U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); +		F32* ls = new F32[lightResX*lightResY]; +		F32 specExp = gSavedSettings.getF32("RenderSpecularExponent"); +        // Calculate the (normalized) blinn-phong specular lookup texture. (with a few tweaks) +		for (U32 y = 0; y < lightResY; ++y)  		{ -			U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); -			U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); -			F32* ls = new F32[lightResX*lightResY]; -			F32 specExp = gSavedSettings.getF32("RenderSpecularExponent"); -            // Calculate the (normalized) blinn-phong specular lookup texture. (with a few tweaks) -			for (U32 y = 0; y < lightResY; ++y) +			for (U32 x = 0; x < lightResX; ++x)  			{ -				for (U32 x = 0; x < lightResX; ++x) -				{ -					ls[y*lightResX+x] = 0; -					F32 sa = (F32) x/(lightResX-1); -					F32 spec = (F32) y/(lightResY-1); -					F32 n = spec * spec * specExp; +				ls[y*lightResX+x] = 0; +				F32 sa = (F32) x/(lightResX-1); +				F32 spec = (F32) y/(lightResY-1); +				F32 n = spec * spec * specExp; -					// Nothing special here.  Just your typical blinn-phong term. -					spec = powf(sa, n); +				// Nothing special here.  Just your typical blinn-phong term. +				spec = powf(sa, n); -					// Apply our normalization function. -					// Note: This is the full equation that applies the full normalization curve, not an approximation. -					// This is fine, given we only need to create our LUT once per buffer initialization. -					spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n))); - -					// Since we use R16F, we no longer have a dynamic range issue we need to work around here. -					// Though some older drivers may not like this, newer drivers shouldn't have this problem. -					ls[y*lightResX+x] = spec; -				} +				// Apply our normalization function. +				// Note: This is the full equation that applies the full normalization curve, not an approximation. +				// This is fine, given we only need to create our LUT once per buffer initialization. +				spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n))); + +				// Since we use R16F, we no longer have a dynamic range issue we need to work around here. +				// Though some older drivers may not like this, newer drivers shouldn't have this problem. +				ls[y*lightResX+x] = spec;  			} +		} -			U32 pix_format = GL_R16F; +		U32 pix_format = GL_R16F;  #if LL_DARWIN -			// Need to work around limited precision with 10.6.8 and older drivers -			// -			pix_format = GL_R32F; +		// Need to work around limited precision with 10.6.8 and older drivers +		// +		pix_format = GL_R32F;  #endif -			LLImageGL::generateTextures(1, &mLightFunc); -			gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); -			LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); -			gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); -			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); -			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); +		LLImageGL::generateTextures(1, &mLightFunc); +		gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); +		LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, pix_format, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); +		gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); +		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); +		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); -			delete [] ls; -		} +		delete [] ls; +	} -        mPbrBrdfLut.allocate(512, 512, GL_RG16F); -        mPbrBrdfLut.bindTarget(); -        gDeferredGenBrdfLutProgram.bind(); +    mPbrBrdfLut.allocate(512, 512, GL_RG16F); +    mPbrBrdfLut.bindTarget(); +    gDeferredGenBrdfLutProgram.bind(); -        gGL.begin(LLRender::TRIANGLE_STRIP); -        gGL.vertex2f(-1, -1); -        gGL.vertex2f(-1, 1); -        gGL.vertex2f(1, -1); -        gGL.vertex2f(1, 1); -        gGL.end(); -        gGL.flush(); +    gGL.begin(LLRender::TRIANGLE_STRIP); +    gGL.vertex2f(-1, -1); +    gGL.vertex2f(-1, 1); +    gGL.vertex2f(1, -1); +    gGL.vertex2f(1, 1); +    gGL.end(); +    gGL.flush(); -        gDeferredGenBrdfLutProgram.unbind(); -        mPbrBrdfLut.flush(); -	} +    gDeferredGenBrdfLutProgram.unbind(); +    mPbrBrdfLut.flush();  } @@ -1331,11 +1318,6 @@ bool LLPipeline::canUseWindLightShaders() const      return true;  } -bool LLPipeline::canUseWindLightShadersOnObjects() const -{ -    return true; -} -  bool LLPipeline::canUseAntiAliasing() const  {  	return true; @@ -2442,7 +2424,7 @@ void LLPipeline::doOcclusion(LLCamera& camera)          gGL.setColorMask(true, true);      } -    if (LLPipeline::sUseOcclusion > 1 && !LLSpatialPartition::sTeleportRequested && +    if (LLPipeline::sUseOcclusion > 1 &&  		(sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck))  	{  		LLVertexBuffer::unbind(); @@ -4319,6 +4301,8 @@ extern std::set<LLSpatialGroup*> visible_selected_groups;  void LLPipeline::renderDebug()  { +    LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; +  	assertInitialized();  	bool hud_only = hasRenderType(LLPipeline::RENDER_TYPE_HUD); @@ -7439,6 +7423,12 @@ void LLPipeline::renderFinalize()  				screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT);              } +			channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, screenTarget()->getUsage()); +			if (channel > -1) +			{ +				mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); +			} +              gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight());              static LLCachedControl<F32> exposure(gSavedSettings, "RenderExposure", 1.f); @@ -7466,8 +7456,8 @@ void LLPipeline::renderFinalize()  		bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete();  		LLGLSLShader* shader = &gGlowCombineProgram; -		S32 width = mRT->screen.getWidth(); -		S32 height = mRT->screen.getHeight(); +		S32 width = screenTarget()->getWidth(); +		S32 height = screenTarget()->getHeight();  		S32 channel = -1; @@ -7485,10 +7475,10 @@ void LLPipeline::renderFinalize()  			shader->bind();  			shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); -			channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); +			channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage());  			if (channel > -1)  			{ -				mRT->deferredLight.bindTexture(0, channel); +				screenTarget()->bindTexture(0, channel);  			}              { @@ -7499,7 +7489,7 @@ void LLPipeline::renderFinalize()  			gGL.flush(); -			shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); +			shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage());  			shader->unbind();  			mRT->fxaaBuffer.flush(); @@ -7551,11 +7541,9 @@ void LLPipeline::renderFinalize()  			shader->bind(); -            S32 glow_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_EMISSIVE);              S32 screen_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DIFFUSE);              S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); -			gGL.getTexUnit(glow_channel)->bind(&mGlow[1]);  			gGL.getTexUnit(screen_channel)->bind(screenTarget());              gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); @@ -7572,7 +7560,6 @@ void LLPipeline::renderFinalize()  			shader->unbind();  		}  	} -          gGL.setSceneBlendType(LLRender::BT_ALPHA); @@ -7729,12 +7716,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_          }  	} -	channel = shader.enableTexture(LLShaderMgr::DEFERRED_BLOOM); -	if (channel > -1) -	{ -		mGlow[1].bindTexture(0, channel); -	} -  	stop_glerror();      bindShadowMaps(shader); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 483fe08559..0faa0c3f20 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -224,7 +224,6 @@ public:  	bool		shadersLoaded();  	bool		canUseWindLightShaders() const; -	bool		canUseWindLightShadersOnObjects() const;  	bool		canUseAntiAliasing() const;  	// phases @@ -421,7 +420,6 @@ public:  	static void setRenderHighlightTextureChannel(LLRender::eTexIndex channel); // sets which UV setup to display in highlight overlay  	static void updateRenderTransparentWater(); -	static void updateRenderBump();  	static void refreshCachedSettings();  	void addDebugBlip(const LLVector3& position, const LLColor4& color); @@ -623,7 +621,6 @@ public:  	static bool				sAutoMaskAlphaDeferred;  	static bool				sAutoMaskAlphaNonDeferred;  	static bool				sRenderTransparentWater; -	static bool				sRenderBump;  	static bool				sBakeSunlight;  	static bool				sNoAlpha;  	static bool				sUseFarClip; | 
