diff options
Diffstat (limited to 'indra')
32 files changed, 458 insertions, 244 deletions
| diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 6988e55034..17fa8f14a9 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1266,6 +1266,7 @@ bool LLGLManager::initGL()      glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords);  #endif      glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); +    glGetIntegerv(GL_MAX_VARYING_VECTORS, &mMaxVaryingVectors);      glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &mMaxUniformBlockSize);      // sanity clamp max uniform block size to 64k just in case diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index f5b1e8d786..24ba4d6deb 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -88,6 +88,7 @@ public:      S32 mGLMaxTextureSize;      F32 mMaxAnisotropy = 0.f;      S32 mMaxUniformBlockSize = 0; +    S32 mMaxVaryingVectors = 0;      // GL 4.x capabilities      bool mHasCubeMapArray = false; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index d333a3fd54..37e15b96c3 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -70,6 +70,7 @@ U32 LLTexUnit::sWhiteTexture = 0;  bool LLRender::sGLCoreProfile = false;  bool LLRender::sNsightDebugSupport = false;  LLVector2 LLRender::sUIGLScaleFactor = LLVector2(1.f, 1.f); +bool LLRender::sClassicMode = false;  struct LLVBCache  { @@ -988,9 +989,13 @@ void LLRender::syncLightState()          shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, LL_NUM_LIGHT_UNITS, diffuse[0].mV);          shader->uniform3fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV);          shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0); -        //shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); -        //shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); -        //shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); + +        if (sClassicMode) +        { +            shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); +            shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); +            shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); +        }      }  } diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 7162ce51a4..97c47bcae9 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -496,6 +496,7 @@ public:      static bool sGLCoreProfile;      static bool sNsightDebugSupport;      static LLVector2 sUIGLScaleFactor; +    static bool sClassicMode; // classic sky mode active  private:      friend class LLLightState; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 42ed222643..a69c09d696 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -7874,7 +7874,18 @@    <key>RenderLowMemMinDiscardIncrement</key>    <map>      <key>Comment</key> -    <string>Minimum increment of discard level if system memory gets low</string> +    <string>Minimum increment of discard bias if available texture memory gets low</string> +    <key>Persist</key> +    <integer>1</integer> +    <key>Type</key> +    <string>F32</string> +    <key>Value</key> +    <real>0.1</real> +  </map> +  <key>RenderHighMemMinDiscardDecrement</key> +  <map> +    <key>Comment</key> +    <string>Minimum decrement of discard bias if excess texture memory is available</string>      <key>Persist</key>      <integer>1</integer>      <key>Type</key> @@ -11499,30 +11510,17 @@        <key>Value</key>        <real>20.0</real>      </map> -    <key>TextureBiasDistanceScale</key> +    <key>TextureCameraBoost</key>      <map>        <key>Comment</key> -      <string>When biasing textures to lower resolution due to lack of vram, weight to put on distance factor.</string> +      <string>Amount to boost resolution of textures that are important to the camera.</string>        <key>Persist</key> -      <integer>1</integer> +      <integer>0</integer>        <key>Type</key>        <string>F32</string>        <key>Value</key>        <real>8.0</real>      </map> -    <key>TextureBiasUnimportantFactor</key> -    <map> -      <key>Comment</key> -      <string>When biasing textures to lower resolution due to lack of vram, the importance threshold below which is considered unimportant and getting an extra bias.</string> -      <key>Persist</key> -      <integer>1</integer> -      <key>Type</key> -      <string>F32</string> -      <key>Value</key> -      <real>0.25</real> -      <key>Backup</key> -      <integer>0</integer> -    </map>      <key>TextureDecodeDisabled</key>      <map>        <key>Comment</key> @@ -16476,16 +16474,16 @@      <key>Value</key>      <integer>1</integer>    </map> -    <key>RenderVintageMode</key> +    <key>RenderDisableVintageMode</key>      <map>          <key>Comment</key> -        <string>Disable different rendering pipeline features to improve performance on older machines that makes the world look closer to how it used to prior to V7.</string> +        <string>Enables additional rendering pipeline features on newer machines such as HDR and emissive textures on PBR content.</string>          <key>Persist</key>          <integer>1</integer>          <key>Type</key>          <string>Boolean</string>          <key>Value</key> -        <integer>0</integer> +        <integer>1</integer>      </map>  </map>  </llsd> diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 86a78f3687..d32455d70c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -544,8 +544,10 @@ vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,          pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, nl, diffPunc, specPunc);          color = intensity * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));      } - -    return color; +    float final_scale = 1.0; +    if (classic_mode > 0) +        final_scale = 0.9; +    return color * final_scale;  }  void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor) @@ -576,22 +578,25 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v,      // Depending on the sky, we combine these differently.      if (classic_mode > 0)      { +        irradiance.rgb = srgb_to_linear(irradiance * 0.9); // BINGO +          // Reconstruct the diffuse lighting that we do for blinn-phong materials here.          // A special note about why we do some really janky stuff for classic mode.          // Since adding classic mode, we've moved the lambertian diffuse multiply out from pbrPunctual and instead handle it in the different light type calcs. -        // For classic mode, this baiscally introduces a double multiplication that we need to somehow avoid -        // Using one of the old mobile gamma correction tricks (val * val to "linearize", sqrt(val) to bring back into sRGB), we can _mostly_ avert this          // This will never be 100% correct, but at the very least we can make it look mostly correct with legacy skies and classic mode. -        float da = pow(sqrt(nl), 1.2); +        float da = pow(nl, 1.2);          vec3 sun_contrib = vec3(min(da, scol));          // Multiply by PI to account for lambertian diffuse colors.  Otherwise things will be too dark when lit by the sun on legacy skies. -        sun_contrib = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit * 0.7) * M_PI; +        sun_contrib = srgb_to_linear(linear_to_srgb(sun_contrib) * sunlit * 0.7) * M_PI;          // Manually recombine everything here.  We have to separate the shading to ensure that lighting is able to more closely match blinn-phong. -        color.rgb = srgb_to_linear(iblDiff) + clamp(sun_contrib * (da * (diffPunc.rgb + specPunc.rgb) * scol), vec3(0), vec3(10)); +        vec3 finalAmbient = irradiance.rgb * diffuseColor.rgb; // BINGO +        vec3 finalSun = clamp(sun_contrib * ((diffPunc.rgb + specPunc.rgb) * scol), vec3(0), vec3(10)); // QUESTIONABLE BINGO? +        color.rgb = srgb_to_linear(linear_to_srgb(finalAmbient) + (linear_to_srgb(finalSun) * 1.1)); +        //color.rgb = sun_contrib * diffuseColor.rgb;      }      else      { diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index bc13e7d1ec..e3290e5e3c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -163,7 +163,10 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec          // no spec for alpha shader...      } -    col = max(col, vec3(0)); +    float final_scale = 1.0; +    if (classic_mode > 0) +        final_scale = 0.9; +    col = max(col * final_scale, vec3(0));      return col;  } @@ -241,7 +244,8 @@ void main()      vec3 atten;      calcAtmosphericVarsLinear(pos.xyz, norm, light_dir, sunlit, amblit, additive, atten); - +    if (classic_mode > 0) +        sunlit *= 1.35;      vec3 sunlit_linear = sunlit;      vec3 amblit_linear = amblit; @@ -296,11 +300,14 @@ void main()      color.rgb = applySkyAndWaterFog(pos.xyz, additive, atten, color).rgb;  #endif // #else // FOR_IMPOSTOR - +    float final_scale = 1; +    if (classic_mode > 0) +        final_scale = 1.1;  #ifdef IS_HUD      color.rgb = linear_to_srgb(color.rgb); +    final_scale = 1;  #endif -    frag_color = max(color, vec4(0)); +    frag_color = max(color * final_scale, vec4(0));  } diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index cec844559f..0418f99459 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -43,6 +43,7 @@ uniform sampler2D lightMap;  uniform int sun_up_factor;  uniform vec3 sun_dir;  uniform vec3 moon_dir; +uniform int classic_mode;  out vec4 frag_color; @@ -160,7 +161,8 @@ void main()      vec3 additive;      vec3 atten;      calcAtmosphericVarsLinear(pos.xyz, norm, light_dir, sunlit, amblit, additive, atten); - +    if (classic_mode > 0) +        sunlit *= 1.35;      vec3 sunlit_linear = sunlit;      vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; @@ -212,8 +214,10 @@ void main()      color.rgb = applySkyAndWaterFog(pos.xyz, additive, atten, vec4(color, 1.0)).rgb;      float a = basecolor.a*vertex_color.a; - -    frag_color = max(vec4(color.rgb,a), vec4(0)); +    float final_scale = 1; +    if (classic_mode > 0) +        final_scale = 1.1; +    frag_color = max(vec4(color.rgb * final_scale,a), vec4(0));  }  #else diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 0166cd6e0c..a4d3962d12 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -178,8 +178,10 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe              }          }      } - -    return max(col, vec3(0.0, 0.0, 0.0)); +    float final_scale = 1.0; +    if (classic_mode > 0) +        final_scale = 0.9; +    return max(col * final_scale, vec3(0.0, 0.0, 0.0));  }  #else @@ -329,7 +331,8 @@ void main()      vec3 additive;      vec3 atten;      calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten); - +    if (classic_mode > 0) +        sunlit *= 1.35;      vec3 sunlit_linear = sunlit;      vec3 amblit_linear = amblit; @@ -418,8 +421,10 @@ void main()      glare *= 1.0-emissive;      glare = min(glare, 1.0);      float al = max(diffcol.a, glare) * vertex_color.a; - -    frag_color = max(vec4(color, al), vec4(0)); +    float final_scale = 1; +    if (classic_mode > 0) +        final_scale = 1.1; +    frag_color = max(vec4(color * final_scale, al), vec4(0));  #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer      // deferred path               // See: C++: addDeferredAttachment(), shader: softenLightF.glsl diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index d4359e7aa3..b11c2644aa 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -38,6 +38,7 @@ uniform vec4  light_col[LIGHT_COUNT]; // .a = falloff  uniform vec2  screen_res;  uniform float far_z;  uniform mat4  inv_proj; +uniform int classic_mode;  in vec4 vary_fragcoord; @@ -169,8 +170,10 @@ void main()              }          }      } - -    frag_color.rgb = max(final_color, vec3(0)); +    float final_scale = 1.0; +    if (classic_mode > 0) +        final_scale = 0.9; +    frag_color.rgb = max(final_color * final_scale, vec3(0));      frag_color.a   = 0.0;  #ifdef IS_AMD_CARD diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl index 1ca4024c69..6a248f25bc 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl @@ -44,6 +44,7 @@ uniform vec2 screen_res;  uniform mat4 inv_proj;  uniform vec4 viewport; +uniform int classic_mode;  void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist);  float calcLegacyDistanceAttenuation(float distance, float falloff); @@ -149,7 +150,9 @@ void main()              discard;          }      } - -    frag_color.rgb = max(final_color, vec3(0)); +    float final_scale = 1.0; +    if (classic_mode > 0) +        final_scale = 0.9; +    frag_color.rgb = max(final_color * final_scale, vec3(0));      frag_color.a = 0.0;  } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index ae6c23be05..2e288184bf 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -155,6 +155,9 @@ void main()      calcAtmosphericVarsLinear(pos.xyz, gb.normal, light_dir, sunlit, amblit, additive, atten); +    if (classic_mode > 0) +        sunlit *= 1.35; +      vec3 sunlit_linear = sunlit;      vec3 amblit_linear = amblit; @@ -224,7 +227,7 @@ void main()              da = pow(da,1.2);              vec3 sun_contrib = vec3(min(da, scol)); -            color.rgb = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit_linear * 0.7); +            color.rgb = srgb_to_linear(color.rgb * 0.9 + (linear_to_srgb(sun_contrib) * sunlit_linear * 0.7));              sunlit_linear = srgb_to_linear(sunlit_linear);          }          else @@ -272,6 +275,9 @@ void main()     }      //color.r = classic_mode > 0 ? 1.0 : 0.0; -    frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results +    float final_scale = 1; +    if (classic_mode > 0) +        final_scale = 1.1; +    frag_color.rgb = max(color.rgb * final_scale, vec3(0)); //output linear since local lights will be added to this shader's results      frag_color.a = 0.0;  } diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index d13e71445f..017f8bc844 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -47,6 +47,7 @@ uniform vec3 proj_origin; //origin of projection to be used for angular attenuat  uniform float sun_wash;  uniform int proj_shadow_idx;  uniform float shadow_fade; +uniform int classic_mode;  // Light params  #if defined(MULTI_SPOTLIGHT) @@ -267,8 +268,10 @@ void main()      //not sure why, but this line prevents MATBUG-194      final_color = max(final_color, vec3(0.0)); - +    float final_scale = 1.0; +    if (classic_mode > 0) +        final_scale = 0.9;      //output linear -    frag_color.rgb = final_color; +    frag_color.rgb = final_color * final_scale;      frag_color.a = 0.0;  } diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index fceb81f061..d894e1b24e 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 72 +version 73  // 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 @@ -84,9 +84,7 @@ RenderCASSharpness          1   1  RenderExposure				1   4  RenderTonemapType			1   1  RenderTonemapMix			1   1 -RenderEnableEmissiveBuffer  1   1 -RenderHDREnabled            1   1 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   1  //  // Low Graphics Settings @@ -127,7 +125,7 @@ RenderCASSharpness          1   0  RenderExposure				1   1  RenderTonemapType			1   1  RenderTonemapMix			1   0.7 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0  //  // Medium Low Graphics Settings @@ -168,7 +166,7 @@ RenderCASSharpness          1   0  RenderExposure				1   1  RenderTonemapType			1   1  RenderTonemapMix			1   0.7 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0  //  // Medium Graphics Settings (standard) @@ -377,8 +375,7 @@ list Unknown  RenderShadowDetail			1	0  RenderDeferredSSAO			1	0  RenderMirrors				1	0 -RenderEnableEmissiveBuffer  1   0 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0  //  // VRAM > 512MB @@ -401,7 +398,7 @@ RenderDeferredSSAO			0	0  RenderShadowDetail			0	0  RenderReflectionProbeDetail	0	-1  RenderMirrors				0	0 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0  list Intel  RenderAnisotropic			1	0 @@ -420,11 +417,13 @@ RenderFSAASamples           0   0  RenderReflectionsEnabled    0   0  RenderReflectionProbeDetail	0	0  RenderMirrors				0	0 -RenderEnableEmissiveBuffer  1   0  RenderGLMultiThreadedTextures 0 0  RenderGLMultiThreadedMedia 0 0 -RenderHDREnabled            1   0 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0  list TexUnit16orLess  RenderTerrainPBRDetail      1   -1 + +list VaryingVectors16orLess +RenderTerrainPBRPlanarSampleCount 1   1 + diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index b411e69ab9..9a3bdf5c5f 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 66 +version 68  // 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 @@ -83,7 +83,7 @@ RenderCASSharpness          1   1  RenderExposure				1   1  RenderTonemapType			1   1  RenderTonemapMix			1   1 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   1  //  // Low Graphics Settings @@ -124,7 +124,7 @@ RenderCASSharpness          1   0  RenderExposure				1   1  RenderTonemapType			1   1  RenderTonemapMix			1   0.7 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0  // @@ -166,7 +166,7 @@ RenderCASSharpness          1   0  RenderExposure				1   1  RenderTonemapType			1   1  RenderTonemapMix			1   0.7 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0  //  // Medium Graphics Settings (standard) @@ -375,7 +375,7 @@ list Unknown  RenderShadowDetail			1	0  RenderDeferredSSAO			1	0  RenderMirrors				1	0 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0  // @@ -397,7 +397,7 @@ RenderTerrainDetail 		1	0  RenderDeferredSSAO			0	0  RenderShadowDetail			0	0  RenderMirrors				0	0 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0  list TexUnit8orLess  RenderDeferredSSAO			0	0 @@ -426,4 +426,7 @@ RenderFSAASamples           0   0  RenderReflectionProbeDetail	0	0  RenderReflectionsEnabled    0   0  RenderMirrors				0	0 -RenderVintageMode           1   1 +RenderDisableVintageMode           1   0 + +list VaryingVectors16orLess +RenderTerrainPBRPlanarSampleCount 1   1 diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 28f26b1eac..2bbe5e90c6 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -719,7 +719,11 @@ void LLFeatureManager::applyBaseMasks()          LLImageGLThread::sEnabledTextures = false;          // Make extra sure that vintage mode also gets enabled. -        gSavedSettings.setBOOL("RenderVintageMode", true); +        gSavedSettings.setBOOL("RenderDisableVintageMode", false); +    } +    if (gGLManager.mMaxVaryingVectors <= 16) +    { +        maskFeatures("VaryingVectors16orLess");      }      // now mask by gpu string diff --git a/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp b/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp index 247c0d249a..51bb255f6e 100644 --- a/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp +++ b/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp @@ -321,17 +321,17 @@ void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings()      }      // Vintage mode -    LLCachedControl<bool> is_vintage(gSavedSettings, "RenderVintageMode"); +    static LLCachedControl<bool> is_not_vintage(gSavedSettings, "RenderDisableVintageMode");      LLSliderCtrl*         tonemapMix    = getChild<LLSliderCtrl>("TonemapMix");      LLComboBox*           tonemapSelect = getChild<LLComboBox>("TonemapType");      LLTextBox*            tonemapLabel  = getChild<LLTextBox>("TonemapTypeText");      LLSliderCtrl*         exposureSlider = getChild<LLSliderCtrl>("RenderExposure"); -    tonemapSelect->setEnabled(!is_vintage); -    tonemapLabel->setEnabled(!is_vintage); -    tonemapMix->setEnabled(!is_vintage); -    exposureSlider->setEnabled(!is_vintage); -    cas_slider->setEnabled(!is_vintage); +    tonemapSelect->setEnabled(is_not_vintage); +    tonemapLabel->setEnabled(is_not_vintage); +    tonemapMix->setEnabled(is_not_vintage); +    exposureSlider->setEnabled(is_not_vintage); +    cas_slider->setEnabled(is_not_vintage);  }  void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 8a3c8b9b17..796cc8bb5e 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2251,13 +2251,14 @@ void LLSelectMgr::selectionRevertGLTFMaterials()                  // Update material locally                  objectp->setRenderMaterialID(te, asset_id, false /*wait for LLGLTFMaterialList update*/); -                objectp->setTEGLTFMaterialOverride(te, nodep->mSavedGLTFOverrideMaterials[te]); +                LLGLTFMaterial* material = new LLGLTFMaterial(*nodep->mSavedGLTFOverrideMaterials[te]); +                objectp->setTEGLTFMaterialOverride(te, material);                  // Enqueue update to server                  if (asset_id.notNull())                  {                      // Restore overrides and base material -                    LLGLTFMaterialList::queueApply(objectp, te, asset_id, nodep->mSavedGLTFOverrideMaterials[te]); +                    LLGLTFMaterialList::queueApply(objectp, te, asset_id, material);                  }                  else                  { @@ -3151,15 +3152,20 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch)                          material->mTextureTransform[i].mScale.set(scale_x, scale_y);                      } -                    LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)tep->getGLTFRenderMaterial(); -                    if (render_mat) +                    const LLGLTFMaterial* base_material = tep->getGLTFMaterial(); +                    if (base_material)                      { -                        render_mat->applyOverride(*material); +                        LLGLTFMaterial* render_material = new LLFetchedGLTFMaterial(); +                        *render_material = *base_material; +                        render_material->applyOverride(*material); +                        tep->setGLTFRenderMaterial(render_material);                      }                      if (send_to_sim)                      { -                        LLGLTFMaterialList::queueModify(object, te_num, material); +                        LLGLTFMaterial new_override; +                        new_override = *material; +                        LLGLTFMaterialList::queueModify(object, te_num, &new_override);                      }                  }                  send = send_to_sim; @@ -5957,12 +5963,12 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data                          LLGLTFMaterial* old_override = node->getObject()->getTE(i)->getGLTFMaterialOverride();                          if (old_override)                          { -                            LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(*old_override); -                            override_materials.push_back(mat); +                            // saveGLTFMaterials will make a copy +                            override_materials.emplace_back(old_override);                          }                          else                          { -                            override_materials.push_back(nullptr); +                            override_materials.emplace_back(nullptr);                          }                      }                      // processObjectProperties does not include overrides so this @@ -6874,16 +6880,22 @@ void LLSelectNode::saveGLTFMaterials(const uuid_vec_t& materials, const gltf_mat          mSavedGLTFMaterialIds.clear();          mSavedGLTFOverrideMaterials.clear(); -        for (uuid_vec_t::const_iterator materials_it = materials.begin(); -            materials_it != materials.end(); ++materials_it) +        for (const LLUUID& id : materials)          { -            mSavedGLTFMaterialIds.push_back(*materials_it); +            mSavedGLTFMaterialIds.push_back(id);          } -        for (gltf_materials_vec_t::const_iterator mat_it = override_materials.begin(); -            mat_it != override_materials.end(); ++mat_it) +        for (const LLPointer<LLGLTFMaterial> &mat : override_materials)          { -            mSavedGLTFOverrideMaterials.push_back(*mat_it); +            if (mat.notNull()) +            { +                LLGLTFMaterial* copy = new LLGLTFMaterial(*mat); +                mSavedGLTFOverrideMaterials.emplace_back(copy); +            } +            else +            { +                mSavedGLTFOverrideMaterials.emplace_back(nullptr); +            }          }      }  } diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index f8242675dc..b70ec3dbea 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -198,6 +198,8 @@ public:      // final gltf material that users see.      // Ids get applied and restored by tools floater,      // overrides get applied in live material editor +    // @param override_materials' content will be copied to not +    // affect originals      void saveGLTFMaterials(const uuid_vec_t& materials, const gltf_materials_vec_t& override_materials);      bool allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 836b181623..85e2f4db90 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -671,7 +671,7 @@ void LLSettingsVOSky::updateSettings()      // After some A/B comparison of relesae vs EEP, tweak to allow strength to fall below 2      // at night, for better match. (mSceneLightStrength is a divisor, so lower value means brighter      // local lights) -    LLCachedControl<F32> sdr(gSavedSettings, "RenderSunDynamicRange", 1.f); +    static LLCachedControl<F32> sdr(gSavedSettings, "RenderSunDynamicRange", 1.f);      F32 sun_dynamic_range = llmax(sdr(), 0.0001f);      mSceneLightStrength = 2.0f * (0.75f + sun_dynamic_range * dp); @@ -818,6 +818,8 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)      shader->uniform1f(LLShaderMgr::SKY_AMBIENT_SCALE, ambient_scale);      shader->uniform1i(LLShaderMgr::CLASSIC_MODE, classic_mode); +    LLRender::sClassicMode = classic_mode; +      F32 probe_ambiance = getReflectionProbeAmbiance();      if (irradiance_pass) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 5172fad29d..bac0c736b1 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1761,7 +1761,10 @@ bool LLTextureFetchWorker::doWork(S32 param)          mRawImage = NULL;          mAuxImage = NULL;          llassert_always(mFormattedImage.notNull()); -        S32 discard = mHaveAllData ? 0 : mLoadedDiscard; + +        // if we have the entire image data (and the image is not J2C), decode the full res image +        // DO NOT decode a higher res j2c than was requested.  This is a waste of time and memory. +        S32 discard = mHaveAllData && mFormattedImage->getCodec() != IMG_CODEC_J2C ? 0 : mLoadedDiscard;          mDecoded  = false;          setState(DECODE_IMAGE_UPDATE);          LL_DEBUGS(LOG_TXT) << mID << ": Decoding. Bytes: " << mFormattedImage->getDataSize() << " Discard: " << discard @@ -2318,6 +2321,10 @@ void LLTextureFetchWorker::callbackDecoded(bool success, const std::string &erro          mRawImage = raw;          mAuxImage = aux;          mDecodedDiscard = mFormattedImage->getDiscardLevel(); +        if (mDecodedDiscard < mDesiredDiscard) +        { +            LL_WARNS_ONCE(LOG_TXT) << "Decoded higher resolution than requested" << LL_ENDL; +        }          LL_DEBUGS(LOG_TXT) << mID << ": Decode Finished. Discard: " << mDecodedDiscard                             << " Raw Image: " << llformat("%dx%d",mRawImage->getWidth(),mRawImage->getHeight()) << LL_ENDL;      } @@ -2481,7 +2488,7 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L      LL_PROFILE_ZONE_SCOPED;      if (mDebugPause)      { -        return -1; +        return CREATE_REQUEST_ERROR_DEFAULT;      }      if (f_type == FTT_SERVER_BAKE) @@ -2497,7 +2504,7 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L                                << host << " != " << worker->mHost << LL_ENDL;              removeRequest(worker, true);              worker = NULL; -            return -1; +            return CREATE_REQUEST_ERROR_MHOSTS;          }      } @@ -2550,13 +2557,13 @@ S32 LLTextureFetch::createRequest(FTType f_type, const std::string& url, const L      {          if (worker->wasAborted())          { -            return -1; // need to wait for previous aborted request to complete +            return CREATE_REQUEST_ERROR_ABORTED; // need to wait for previous aborted request to complete          }          worker->lockWorkMutex();                                        // +Mw          if (worker->mState == LLTextureFetchWorker::DONE && worker->mDesiredSize == llmax(desired_size, TEXTURE_CACHE_ENTRY_SIZE) && worker->mDesiredDiscard == desired_discard) {              worker->unlockWorkMutex();                                  // -Mw -            return -1; // similar request has failed or is in a transitional state +            return CREATE_REQUEST_ERROR_TRANSITION; // similar request has finished, failed or is in a transitional state          }          worker->mActiveCount++;          worker->mNeedsAux = needs_aux; @@ -3149,6 +3156,43 @@ S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& r      return state;  } +// Threads:  T* +S32 LLTextureFetch::getLastFetchState(const LLUUID& id, S32& requested_discard, S32& decoded_discard, bool& decoded) +{ +    LL_PROFILE_ZONE_SCOPED; +    S32 state = LLTextureFetchWorker::INVALID; + +    LLTextureFetchWorker* worker = getWorker(id); +    if (worker) // Don't check haveWork, intent is to get whatever is in the worker +    { +        worker->lockWorkMutex();                                        // +Mw +        state = worker->mState; +        requested_discard = worker->mDesiredDiscard; +        decoded_discard = worker->mDecodedDiscard; +        decoded = worker->mDecoded; +        worker->unlockWorkMutex();                                      // -Mw +    } +    return state; +} + +// Threads:  T* +S32 LLTextureFetch::getLastRawImage(const LLUUID& id, +    LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux) +{ +    LL_PROFILE_ZONE_SCOPED; +    S32 decoded_discard = -1; +    LLTextureFetchWorker* worker = getWorker(id); +    if (worker && !worker->haveWork() && worker->mDecodedDiscard >= 0) +    { +            worker->lockWorkMutex();                                    // +Mw +            raw = worker->mRawImage; +            aux = worker->mAuxImage; +            decoded_discard = worker->mDecodedDiscard; +            worker->unlockWorkMutex();                                  // -Mw +    } +    return decoded_discard; +} +  void LLTextureFetch::dump()  {      LL_INFOS(LOG_TXT) << "LLTextureFetch ACTIVE_HTTP:" << LL_ENDL; diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index c2c5ec5acc..8ab90896dc 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -76,6 +76,14 @@ public:      // Threads:  Tmain      void shutDownImageDecodeThread(); +    enum e_crete_request_errors +    { +        CREATE_REQUEST_ERROR_DEFAULT = -1, +        CREATE_REQUEST_ERROR_MHOSTS = -2, +        CREATE_REQUEST_ERROR_ABORTED = -3, +        CREATE_REQUEST_ERROR_TRANSITION = -4, +    }; +      // Threads:  T* (but Tmain mostly)      S32 createRequest(FTType f_type, const std::string& url, const LLUUID& id, const LLHost& host, F32 priority,                         S32 w, S32 h, S32 c, S32 discard, bool needs_aux, bool can_use_http); @@ -114,12 +122,20 @@ public:      // get the current fetch state, if any, from the given UUID      S32 getFetchState(const LLUUID& id); -    // @return  Fetch state of given image and associates statistics +    // @return  Fetch state of an active given image and associates statistics      //          See also getStateString      // Threads:  T*      S32 getFetchState(const LLUUID& id, F32& decode_progress_p, F32& requested_priority_p,                        U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p, bool& can_use_http); +    // @return  Fetch last state of given image +    // Threads:  T* +    S32 getLastFetchState(const LLUUID& id, S32& requested_discard, S32 &decoded_discard, bool &decoded); + +    // @return  Fetch last raw image +    // Threads:  T* +    S32 getLastRawImage(const LLUUID& id, LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux); +      // Debug utility - generally not safe      void dump(); diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 6d0704a469..6be7ec2262 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1410,6 +1410,7 @@ void LLToolDragAndDrop::dropTexture(LLViewerObject* hit_obj,                  LLTextureEntry* te = hit_obj->getTE(hit_face);                  if (te && !remove_pbr)                  { +                    // saveGLTFMaterials will make a copy                      override_materials.push_back(te->getGLTFMaterialOverride());                  }                  else @@ -1448,7 +1449,8 @@ void LLToolDragAndDrop::dropTexture(LLViewerObject* hit_obj,              LLTextureEntry* te = hit_obj->getTE(hit_face);              if (te && !remove_pbr)              { -                nodep->mSavedGLTFOverrideMaterials[hit_face] = te->getGLTFMaterialOverride(); +                LLGLTFMaterial* copy = new LLGLTFMaterial(*te->getGLTFMaterialOverride()); +                nodep->mSavedGLTFOverrideMaterials[hit_face] = copy;              }              else              { diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index c4afaac476..172ffcb0d4 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -248,10 +248,10 @@ static bool handleEnableEmissiveChanged(const LLSD& newvalue)      return handleReleaseGLBufferChanged(newvalue) && handleSetShaderChanged(newvalue);  } -static bool handleEnableClassicMode(const LLSD& newvalue) +static bool handleDisableVintageMode(const LLSD& newvalue)  { -    gSavedSettings.setBOOL("RenderEnableEmissiveBuffer", !newvalue.asBoolean()); -    gSavedSettings.setBOOL("RenderHDREnabled", !newvalue.asBoolean()); +    gSavedSettings.setBOOL("RenderEnableEmissiveBuffer", newvalue.asBoolean()); +    gSavedSettings.setBOOL("RenderHDREnabled", newvalue.asBoolean());      return true;  } @@ -798,7 +798,7 @@ void settings_setup_listeners()      setting_setup_signal_listener(gSavedSettings, "RenderGlowResolutionPow", handleReleaseGLBufferChanged);      setting_setup_signal_listener(gSavedSettings, "RenderGlowHDR", handleReleaseGLBufferChanged);      setting_setup_signal_listener(gSavedSettings, "RenderEnableEmissiveBuffer", handleEnableEmissiveChanged); -    setting_setup_signal_listener(gSavedSettings, "RenderVintageMode", handleEnableClassicMode); +    setting_setup_signal_listener(gSavedSettings, "RenderDisableVintageMode", handleDisableVintageMode);      setting_setup_signal_listener(gSavedSettings, "RenderHDREnabled", handleEnableHDR);      setting_setup_signal_listener(gSavedSettings, "RenderGlowNoise", handleSetShaderChanged);      setting_setup_signal_listener(gSavedSettings, "RenderGammaFull", handleSetShaderChanged); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 83386eb1ec..9f04c98770 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -258,7 +258,7 @@ static bool make_rigged_variant(LLGLSLShader& shader, LLGLSLShader& riggedShader  static void add_common_permutations(LLGLSLShader* shader)  { -    LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false); +    static LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);      if (emissive)      { @@ -782,7 +782,7 @@ std::string LLViewerShaderMgr::loadBasicShaders()      attribs["MAX_JOINTS_PER_MESH_OBJECT"] =          std::to_string(LLSkinningUtil::getMaxJointCount()); -    LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false); +    static LLCachedControl<bool> emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false);      if (emissive)      { diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 00e1ea4cd3..14647d6f84 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -559,7 +559,10 @@ void LLViewerTexture::updateClass()          // lower discard bias over time when free memory is available          if (sDesiredDiscardBias > 1.f && over_pct < 0.f)          { -            sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01f; +            static LLCachedControl<F32> high_mem_discard_decrement(gSavedSettings, "RenderHighMemMinDiscardDecrement", .1f); + +            F32 decrement = high_mem_discard_decrement - llmin(over_pct, 0.f); +            sDesiredDiscardBias -= decrement * gFrameIntervalSeconds;          }      } @@ -621,7 +624,7 @@ void LLViewerTexture::updateClass()          }      } -    sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 5.f); +    sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 4.f);      LLViewerTexture::sFreezeImageUpdates = false;  } @@ -1808,6 +1811,141 @@ void LLViewerFetchedTexture::setBoostLevel(S32 level)      }  } +bool LLViewerFetchedTexture::processFetchResults(S32& desired_discard, S32 current_discard, S32 fetch_discard, F32 decode_priority) +{ +    // We may have data ready regardless of whether or not we are finished (e.g. waiting on write) +    if (mRawImage.notNull()) +    { +        LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - has raw image"); +        LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); +        if (tester) +        { +            mIsFetched = true; +            tester->updateTextureLoadingStats(this, mRawImage, LLAppViewer::getTextureFetch()->isFromLocalCache(mID)); +        } +        mRawDiscardLevel = fetch_discard; +        if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && +            (current_discard < 0 || mRawDiscardLevel < current_discard)) +        { +            LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data good"); + +            // This is going to conflict with Develop, just pick from develop +            // where it uses setDimensions instead of setTexelsPerImage +            mFullWidth = mRawImage->getWidth() << mRawDiscardLevel; +            mFullHeight = mRawImage->getHeight() << mRawDiscardLevel; +            setTexelsPerImage(); + +            if (mFullWidth > MAX_IMAGE_SIZE || mFullHeight > MAX_IMAGE_SIZE) +            { +                //discard all oversized textures. +                destroyRawImage(); +                LL_WARNS() << "oversize, setting as missing" << LL_ENDL; +                setIsMissingAsset(); +                mRawDiscardLevel = INVALID_DISCARD_LEVEL; +                mIsFetching = false; +                mLastPacketTimer.reset(); +            } +            else +            { +                mIsRawImageValid = true; +                addToCreateTexture(); +            } + +            if (mBoostLevel == LLGLTexture::BOOST_ICON) +            { +                S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS; +                S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS; +                if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)) +                { +                    // scale oversized icon, no need to give more work to gl +                    // since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy +                    // +                    // BOOST_ICON gets scaling because profile icons can have a bunch of different formats, not just j2c +                    // Might need another pass to use discard for j2c and scaling for everything else. +                    mRawImage = mRawImage->scaled(expected_width, expected_height); +                } +            } + +            if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL) +            { +                S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS; +                S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS; +                if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)) +                { +                    // scale oversized icon, no need to give more work to gl +                    // since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy +                    // +                    // Todo: probably needs to be remade to use discard, all thumbnails are supposed to be j2c, +                    // so no need to scale, should be posible to use discard to scale image down. +                    mRawImage = mRawImage->scaled(expected_width, expected_height); +                } +            } + +            return true; +        } +        else +        { +            LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data not needed"); +            // Data is ready but we don't need it +            // (received it already while fetcher was writing to disk) +            destroyRawImage(); +            return false; // done +        } +    } + +    if (!mIsFetching) +    { +        if ((decode_priority > 0) +            && (mRawDiscardLevel < 0 || mRawDiscardLevel == INVALID_DISCARD_LEVEL) +            && mFetchState > 1) // 1 - initial, make sure fetcher did at least something +        { +            // We finished but received no data +            if (getDiscardLevel() < 0) +            { +                if (getFTType() != FTT_MAP_TILE) +                { +                    LL_WARNS() << mID +                        << " Fetch failure, setting as missing, decode_priority " << decode_priority +                        << " mRawDiscardLevel " << mRawDiscardLevel +                        << " current_discard " << current_discard +                        << " stats " << mLastHttpGetStatus.toHex() +                        << " worker state " << mFetchState +                        << LL_ENDL; +                } +                setIsMissingAsset(); +                desired_discard = -1; +            } +            else +            { +                //LL_WARNS() << mID << ": Setting min discard to " << current_discard << LL_ENDL; +                if (current_discard >= 0) +                { +                    mMinDiscardLevel = current_discard; +                    //desired_discard = current_discard; +                } +                else +                { +                    S32 dis_level = getDiscardLevel(); +                    mMinDiscardLevel = dis_level; +                    //desired_discard = dis_level; +                } +            } +            destroyRawImage(); +        } +        else if (mRawImage.notNull()) +        { +            // We have data, but our fetch failed to return raw data +            // *TODO: FIgure out why this is happening and fix it +            // Potentially can happen when TEX_LIST_SCALE and TEX_LIST_STANDARD +            // get requested for the same texture id at the same time +            // (two textures, one fetcher) +            destroyRawImage(); +        } +    } + +    return true; +} +  bool LLViewerFetchedTexture::updateFetch()  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -1892,127 +2030,12 @@ bool LLViewerFetchedTexture::updateFetch()                                                                          mFetchPriority, mFetchDeltaTime, mRequestDeltaTime, mCanUseHTTP);          } -        // We may have data ready regardless of whether or not we are finished (e.g. waiting on write) -        if (mRawImage.notNull()) +        if (!processFetchResults(desired_discard, current_discard, fetch_discard, decode_priority))          { -            LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - has raw image"); -            LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); -            if (tester) -            { -                mIsFetched = true; -                tester->updateTextureLoadingStats(this, mRawImage, LLAppViewer::getTextureFetch()->isFromLocalCache(mID)); -            } -            mRawDiscardLevel = fetch_discard; -            if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && -                (current_discard < 0 || mRawDiscardLevel < current_discard)) -            { -                LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data good"); -                mFullWidth = mRawImage->getWidth() << mRawDiscardLevel; -                mFullHeight = mRawImage->getHeight() << mRawDiscardLevel; -                setTexelsPerImage(); - -                if(mFullWidth > MAX_IMAGE_SIZE || mFullHeight > MAX_IMAGE_SIZE) -                { -                    //discard all oversized textures. -                    destroyRawImage(); -                    LL_WARNS() << "oversize, setting as missing" << LL_ENDL; -                    setIsMissingAsset(); -                    mRawDiscardLevel = INVALID_DISCARD_LEVEL; -                    mIsFetching = false; -                    mLastPacketTimer.reset(); -                } -                else -                { -                    mIsRawImageValid = true; -                    addToCreateTexture(); -                } - -                if (mBoostLevel == LLGLTexture::BOOST_ICON) -                { -                    S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS; -                    S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS; -                    if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)) -                    { -                        // scale oversized icon, no need to give more work to gl -                        // since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy -                        mRawImage = mRawImage->scaled(expected_width, expected_height); -                    } -                } - -                if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL) -                { -                    S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS; -                    S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS; -                    if (mRawImage && (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height)) -                    { -                        // scale oversized icon, no need to give more work to gl -                        // since we got mRawImage from thread worker and image may be in use (ex: writing cache), make a copy -                        mRawImage = mRawImage->scaled(expected_width, expected_height); -                    } -                } - -                return true; -            } -            else -            { -                LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - data not needed"); -                // Data is ready but we don't need it -                // (received it already while fetcher was writing to disk) -                destroyRawImage(); -                return false; // done -            } +            return false;          } -        if (!mIsFetching) -        { -            if ((decode_priority > 0) -                && (mRawDiscardLevel < 0 || mRawDiscardLevel == INVALID_DISCARD_LEVEL) -                && mFetchState > 1) // 1 - initial, make sure fetcher did at least something -            { -                // We finished but received no data -                if (getDiscardLevel() < 0) -                { -                    if (getFTType() != FTT_MAP_TILE) -                    { -                        LL_WARNS() << mID -                                << " Fetch failure, setting as missing, decode_priority " << decode_priority -                                << " mRawDiscardLevel " << mRawDiscardLevel -                                << " current_discard " << current_discard -                                << " stats " << mLastHttpGetStatus.toHex() -                                << " worker state " << mFetchState -                                << LL_ENDL; -                    } -                    setIsMissingAsset(); -                    desired_discard = -1; -                } -                else -                { -                    //LL_WARNS() << mID << ": Setting min discard to " << current_discard << LL_ENDL; -                    if(current_discard >= 0) -                    { -                        mMinDiscardLevel = current_discard; -                        //desired_discard = current_discard; -                    } -                    else -                    { -                        S32 dis_level = getDiscardLevel(); -                        mMinDiscardLevel = dis_level; -                        //desired_discard = dis_level; -                    } -                } -                destroyRawImage(); -            } -            else if (mRawImage.notNull()) -            { -                // We have data, but our fetch failed to return raw data -                // *TODO: FIgure out why this is happening and fix it -                // Potentially can happen when TEX_LIST_SCALE and TEX_LIST_STANDARD -                // get requested for the same texture id at the same time -                // (two textures, one fetcher) -                destroyRawImage(); -            } -        } -        else +        if (mIsFetching)          {              static const F32 MAX_HOLD_TIME = 5.0f; //seconds to wait before canceling fecthing if decode_priority is 0.f.              if(decode_priority > 0.0f || mStopFetchingTimer.getElapsedTimeF32() > MAX_HOLD_TIME) @@ -2087,21 +2110,49 @@ bool LLViewerFetchedTexture::updateFetch()          }          // bypass texturefetch directly by pulling from LLTextureCache -        S32 fetch_request_discard = -1; -        fetch_request_discard = LLAppViewer::getTextureFetch()->createRequest(mFTType, mUrl, getID(), getTargetHost(), decode_priority, +        S32 fetch_request_response = -1; +        S32 worker_discard = -1; +        fetch_request_response = LLAppViewer::getTextureFetch()->createRequest(mFTType, mUrl, getID(), getTargetHost(), decode_priority,                                                                                w, h, c, desired_discard, needsAux(), mCanUseHTTP); -        if (fetch_request_discard >= 0) +        if (fetch_request_response >= 0) // positive values and 0 are discard values          {              LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - request created");              mHasFetcher = true;              mIsFetching = true;              // in some cases createRequest can modify discard, as an example              // bake textures are always at discard 0 -            mRequestedDiscardLevel = llmin(desired_discard, fetch_request_discard); +            mRequestedDiscardLevel = llmin(desired_discard, fetch_request_response);              mFetchState = LLAppViewer::getTextureFetch()->getFetchState(mID, mDownloadProgress, mRequestedDownloadPriority,                                                         mFetchPriority, mFetchDeltaTime, mRequestDeltaTime, mCanUseHTTP);          } +        else if (fetch_request_response == LLTextureFetch::CREATE_REQUEST_ERROR_TRANSITION) +        { +            LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - processing transition error"); +            // Request wasn't created because similar one finished or is in a transitional state, check worker state +            // As an example can happen if an image (like a server bake always fetches at dis 0), was scaled down to +            // needed discard after fetching then sudenly needed higher dis and worker wasn't yet deleted. Worker +            // discard will be identical to requested one and worker will have nothing new to do despite GL image +            // not being up to data. +            S32 desired_discard; +            S32 decoded_discard; +            bool decoded; +            S32 fetch_state = LLAppViewer::getTextureFetch()->getLastFetchState(mID, desired_discard, decoded_discard, decoded); +            if (fetch_state > 1 && decoded && decoded_discard >=0 && decoded_discard <= desired_discard) +            { +                // worker actually has the image +                if (mRawImage.notNull()) sRawCount--; +                if (mAuxRawImage.notNull()) sAuxCount--; +                decoded_discard = LLAppViewer::getTextureFetch()->getLastRawImage(getID(), mRawImage, mAuxRawImage); +                if (mRawImage.notNull()) sRawCount++; +                if (mAuxRawImage.notNull()) +                { +                    mHasAux = true; +                    sAuxCount++; +                } +                processFetchResults(desired_discard, current_discard, decoded_discard, decode_priority); +            } +        }          // If createRequest() failed, that means one of two things:          // 1. We're finishing up a request for this UUID, so we @@ -2923,7 +2974,7 @@ void LLViewerLODTexture::processTextureStats()          mDesiredDiscardLevel = 0;      }      // Generate the request priority and render priority -    else if (mDontDiscard || !mUseMipMaps || (getFTType() == FTT_MAP_TILE)) +    else if (mDontDiscard || !mUseMipMaps)      {          mDesiredDiscardLevel = 0;          if (mFullWidth > MAX_IMAGE_SIZE_DEFAULT || mFullHeight > MAX_IMAGE_SIZE_DEFAULT) diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 1da8548573..4241ef958f 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -423,6 +423,8 @@ private:      void init(bool firstinit) ;      void cleanup() ; +    bool processFetchResults(S32& desired_discard, S32 current_discard, S32 fetch_discard, F32 decode_priority); +      void saveRawImage() ;  private: diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 411190eb67..c2eb8ddd25 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -901,7 +901,6 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag      if (imagep->getBoostLevel() < LLViewerFetchedTexture::BOOST_HIGH)  // don't bother checking face list for boosted textures      { -        static LLCachedControl<F32> bias_distance_scale(gSavedSettings, "TextureBiasDistanceScale", 1.f);          static LLCachedControl<F32> texture_scale_min(gSavedSettings, "TextureScaleMinAreaFactor", 0.04f);          static LLCachedControl<F32> texture_scale_max(gSavedSettings, "TextureScaleMaxAreaFactor", 25.f); @@ -910,7 +909,12 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag          U32 face_count = 0; -        F32 bias = (F32) llroundf(powf(4, LLViewerTexture::sDesiredDiscardBias - 1.f)); +        // get adjusted bias based on image resolution +        F32 max_discard = F32(imagep->getMaxDiscardLevel()); +        F32 bias = llclamp(max_discard - 2.f, 1.f, LLViewerTexture::sDesiredDiscardBias); + +        // convert bias into a vsize scaler +        bias = (F32) llroundf(powf(4, bias - 1.f));          LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;          for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) @@ -924,7 +928,6 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag                      ++face_count;                      F32 radius;                      F32 cos_angle_to_view_dir; -                    static LLCachedControl<F32> bias_unimportant_threshold(gSavedSettings, "TextureBiasUnimportantFactor", 0.25f);                      if ((gFrameCount - face->mLastTextureUpdate) > 10)                      { // only call calcPixelArea at most once every 10 frames for a given face @@ -958,6 +961,13 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag                          vsize /= bias;                      } +                    // boost resolution of textures that are important to the camera +                    if (face->mInFrustum) +                    { +                        static LLCachedControl<F32> texture_camera_boost(gSavedSettings, "TextureCameraBoost", 8.f); +                        vsize *= llmax(face->mImportanceToCamera*texture_camera_boost, 1.f); +                    } +                      max_vsize = llmax(max_vsize, vsize);                  }              } @@ -1066,13 +1076,26 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time)      {          LLViewerFetchedTexture* imagep = mCreateTextureList.front();          llassert(imagep->mCreatePending); -        imagep->createTexture(); + +        // desired discard may change while an image is being decoded. If the texture in VRAM is sufficient +        // for the current desired discard level, skip the texture creation.  This happens more often than it probably +        // should +        bool redundant_load = imagep->hasGLTexture() && imagep->getDiscardLevel() <= imagep->getDesiredDiscardLevel(); + +        if (!redundant_load) +        { +           imagep->createTexture(); +        } +          imagep->postCreateTexture();          imagep->mCreatePending = false;          mCreateTextureList.pop();          if (imagep->hasGLTexture() && imagep->getDiscardLevel() < imagep->getDesiredDiscardLevel())          { +            // NOTE: this may happen if the desired discard reduces while a decode is in progress and does not +            // necessarily indicate a problem, but if log occurrences excede that of dsiplay_stats: FPS, +            // something has probably gone wrong.              LL_WARNS_ONCE("Texture") << "Texture will be downscaled immediately after loading." << LL_ENDL;              imagep->scaleDown();          } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index ba506da720..7740376d5c 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -791,8 +791,10 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)      for (S32 i = 0; i < num_faces; i++)      {          LLFace* face = mDrawable->getFace(i); -        if (!face) continue; +        if (!face || face->mExtents[0].equals3(face->mExtents[1])) continue;          const LLTextureEntry *te = face->getTextureEntry(); +        if (!te) continue; +          LLViewerTexture *imagep = nullptr;          U32 ch_min;          U32 ch_max; @@ -811,8 +813,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)              // Get _a_ non-null texture if possible (usually diffuse/basecolor, but could be something else)              imagep = face->getTexture(ch);          } -        if (!imagep || !te || -            face->mExtents[0].equals3(face->mExtents[1])) +        if (!imagep)          {              continue;          } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2b941bce5a..47c2f2ffa9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -349,8 +349,9 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false)      U32 norm = GL_RGBA16F;      U32 emissive = GL_RGB16F; -    bool hdr = gSavedSettings.getBOOL("RenderHDREnabled") && gGLManager.mGLVersion > 4.05f; -    LLCachedControl<bool> has_emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false); +    static LLCachedControl<bool> has_emissive(gSavedSettings, "RenderEnableEmissiveBuffer", false); +    static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true); +    bool hdr = has_hdr() && gGLManager.mGLVersion > 4.05f;      if (!hdr)      { @@ -803,7 +804,8 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; -    bool hdr = gGLManager.mGLVersion > 4.05f && gSavedSettings.getBOOL("RenderHDREnabled"); +    static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true); +    bool hdr = gGLManager.mGLVersion > 4.05f && has_hdr();      if (mRT == &mMainRT)      { // hacky -- allocate auxillary buffer @@ -7936,7 +7938,8 @@ void LLPipeline::renderFinalize()      gGL.setColorMask(true, true);      glClearColor(0, 0, 0, 0); -    bool hdr = gGLManager.mGLVersion > 4.05f && gSavedSettings.getBOOL("RenderHDREnabled"); +    static LLCachedControl<bool> has_hdr(gSavedSettings, "RenderHDREnabled", true); +    bool hdr = gGLManager.mGLVersion > 4.05f && has_hdr();      if (hdr)      { @@ -8560,6 +8563,7 @@ void LLPipeline::renderDeferredLighting()              std::list<LLVector4>        fullscreen_lights;              LLDrawable::drawable_list_t spot_lights;              LLDrawable::drawable_list_t fullscreen_spot_lights; +            LLSettingsSky::ptr_t        psky        = LLEnvironment::instance().getCurrentSky();              if (!gCubeSnapshot)              { @@ -8655,6 +8659,8 @@ void LLPipeline::renderDeferredLighting()                          gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);                          gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);                          gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF)); +                        gDeferredLightProgram.uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0); +                          gGL.syncMatrices();                          mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); @@ -8715,6 +8721,8 @@ void LLPipeline::renderDeferredLighting()                      gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);                      gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);                      gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff(DEFERRED_LIGHT_FALLOFF)); +                    gDeferredSpotLightProgram.uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0); +                      gGL.syncMatrices();                      mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); @@ -8753,6 +8761,7 @@ void LLPipeline::renderDeferredLighting()                          gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT, count, (GLfloat*)light);                          gDeferredMultiLightProgram[idx].uniform4fv(LLShaderMgr::MULTI_LIGHT_COL, count, (GLfloat*)col);                          gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z); +                        gDeferredMultiLightProgram[idx].uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0);                          far_z = 0.f;                          count = 0;                          mScreenTriangleVB->setBuffer(); @@ -8790,6 +8799,8 @@ void LLPipeline::renderDeferredLighting()                      gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final);                      gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);                      gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, light_falloff_final); +                    gDeferredMultiSpotLightProgram.uniform1i(LLShaderMgr::CLASSIC_MODE, (psky->canAutoAdjust()) ? 1 : 0); +                      mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);                  } diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index aeaa8370ac..d58107690d 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -685,10 +685,10 @@    </check_box>      <check_box -      control_name="RenderVintageMode" +      control_name="RenderDisableVintageMode"        height="16"        initial_value="false" -      label="Vintage Mode" +      label="HDR and Emissive"        layout="topleft"        left="420"        name="VintageMode" diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml index b4b4bb6fd3..7481e10ed2 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml @@ -361,7 +361,7 @@    <slider      control_name="RenderExposure" -    disabled_control="RenderVintageMode" +    enabled_control="RenderDisableVintageMode"      decimal_digits="1"      follows="left|top"      height="16" | 
