diff options
29 files changed, 200 insertions, 95 deletions
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 09a2138b5e..08c05a0771 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -2555,41 +2555,32 @@ bool LLImageGL::scaleDown(S32 desired_discard)      if (gGLManager.mDownScaleMethod == 0)      { // use an FBO to downscale the texture -        // allocate new texture -        U32 temp_texname = 0; -        generateTextures(1, &temp_texname); -        gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, temp_texname, true); -        { -            LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glTexImage2D"); -            glTexImage2D(mTarget, 0, mFormatInternal, desired_width, desired_height, 0, mFormatPrimary, mFormatType, NULL); -        } - -        // account for new texture getting created -        alloc_tex_image(desired_width, desired_height, mFormatInternal, 1); - -        // Use render-to-texture to scale down the texture -        { -            LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glFramebufferTexture2D"); -            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, mTarget, temp_texname, 0); -        } -          glViewport(0, 0, desired_width, desired_height);          // draw a full screen triangle -        gGL.getTexUnit(0)->bind(this); -        glDrawArrays(GL_TRIANGLES, 0, 3); -        gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); +        if (gGL.getTexUnit(0)->bind(this, true, true)) +        { +            glDrawArrays(GL_TRIANGLES, 0, 3); -        // delete old texture and assign new texture name -        deleteTextures(1, &mTexName); -        mTexName = temp_texname; +            free_tex_image(mTexName); +            glTexImage2D(mTarget, 0, mFormatInternal, desired_width, desired_height, 0, mFormatPrimary, mFormatType, nullptr); +            glCopyTexSubImage2D(mTarget, 0, 0, 0, 0, 0, desired_width, desired_height); +            alloc_tex_image(desired_width, desired_height, mFormatInternal, 1); -        if (mHasMipMaps) -        { // generate mipmaps if needed -            LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glGenerateMipmap"); -            gGL.getTexUnit(0)->bind(this); -            glGenerateMipmap(mTarget); -            gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); +            mTexOptionsDirty = true; + +            if (mHasMipMaps) +            { // generate mipmaps if needed +                LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glGenerateMipmap"); +                gGL.getTexUnit(0)->bind(this); +                glGenerateMipmap(mTarget); +                gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); +            } +        } +        else +        { +            LL_WARNS_ONCE("LLImageGL") << "Failed to bind texture for downscaling." << LL_ENDL; +            return false;          }      }      else diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 091c43c19c..cc0329c6f8 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -272,11 +272,13 @@ static GLuint gen_buffer()      {          LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("gen buffer");          sIndex = pool_size; +#if !LL_DARWIN          if (!gGLManager.mIsAMD)          {              glGenBuffers(pool_size, sNamePool);          }          else +#endif          { // work around for AMD driver bug              for (U32 i = 0; i < pool_size; ++i)              { @@ -942,6 +944,10 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const  void LLVertexBuffer::initClass(LLWindow* window)  {      llassert(sVBOPool == nullptr); + +    LL_INFOS() << "VBO Pooling Disabled" << LL_ENDL; +    sVBOPool = new LLAppleVBOPool(); +      //if (gGLManager.mIsApple)      if(0)      { diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d8dc908e65..f4c8e50e46 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -7902,7 +7902,7 @@          <key>Type</key>          <string>U32</string>          <key>Value</key> -        <integer>1</integer> +        <integer>0</integer>      </map>      <key>RenderDebugTextureBind</key>      <map> @@ -16443,5 +16443,16 @@      <key>Value</key>      <integer>0</integer>    </map> +  <key>RenderHDREnabled</key> +  <map> +    <key>Comment</key> +    <string>Enable HDR rendering.</string> +    <key>Persist</key> +    <integer>1</integer> +    <key>Type</key> +    <string>Boolean</string> +    <key>Value</key> +    <integer>1</integer> +  </map>  </map>  </llsd> diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl index b904df3a1b..32b768cc63 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl @@ -36,6 +36,7 @@ in vec2 vary_texcoord0;  in vec3 vary_position;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag);  void main()  { @@ -51,7 +52,7 @@ void main()      frag_data[0] = vec4(diff.rgb, 0.0);      frag_data[1] = vec4(0,0,0,0);      vec3 nvn = normalize(vary_normal); -    frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS); +    frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);      frag_data[3] = vec4(0);  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl index 2cc3085cd0..79c1b392e9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl @@ -40,6 +40,8 @@ in vec2 vary_texcoord0;  in vec3 vary_position;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag); +  void main()  {      mirrorClip(vary_position); @@ -62,6 +64,6 @@ void main()          frag_data[1] = vertex_color.aaaa; // spec          //frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested          vec3 nvn = normalize(tnorm); -        frag_data[2] = vec4(nvn, GBUFFER_FLAG_HAS_ATMOS); +        frag_data[2] = encodeNormal(nvn, GBUFFER_FLAG_HAS_ATMOS);          frag_data[3] = vec4(vertex_color.a, 0, 0, 0);  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 8588a93648..0e8d8d010b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -75,6 +75,9 @@ const float ONE_OVER_PI = 0.3183098861;  vec3 srgb_to_linear(vec3 cs);  vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten); +vec4 decodeNormal(vec4 norm); + +  float calcLegacyDistanceAttenuation(float distance, float falloff)  {      float dist_atten = 1.0 - clamp((distance + falloff)/(1.0 + falloff), 0.0, 1.0); @@ -145,8 +148,7 @@ vec2 getScreenCoordinate(vec2 screenpos)  vec4 getNorm(vec2 screenpos)  { -    vec4 norm = texture(normalMap, screenpos.xy); -    norm.xyz = normalize(norm.xyz); +    vec4 norm = decodeNormal(texture(normalMap, screenpos.xy));      return norm;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl index 1751e17814..fadf06d592 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl @@ -39,6 +39,8 @@ in vec2 vary_texcoord0;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag); +  void main()  {      mirrorClip(vary_position); @@ -53,7 +55,7 @@ void main()      frag_data[0] = vec4(col.rgb, 0.0);      frag_data[1] = vec4(0,0,0,0); // spec      vec3 nvn = normalize(vary_normal); -    frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS); +    frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);      frag_data[3] = vec4(0);  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl index f5b517a8ea..10d06da416 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl @@ -36,6 +36,7 @@ in vec4 vertex_color;  in vec2 vary_texcoord0;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag);  void main()  { @@ -51,6 +52,6 @@ void main()      frag_data[0] = vec4(col.rgb, 0.0);      frag_data[1] = vec4(0,0,0,0);      vec3 nvn = normalize(vary_normal); -    frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS); +    frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);      frag_data[3] = vec4(0);  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl index 89ea0c1710..f7c8fc9596 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl @@ -33,6 +33,7 @@ uniform sampler2D diffuseMap;  in vec3 vary_normal;  in vec2 vary_texcoord0; +vec4 encodeNormal(vec3 norm, float gbuffer_flag);  void main()  { @@ -46,7 +47,7 @@ void main()      frag_data[0] = vec4(col.rgb, 0.0);      frag_data[1] = vec4(0,0,0,0); // spec      vec3 nvn = normalize(vary_normal); -    frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS); +    frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);      frag_data[3] = vec4(0);  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl index 7f056a51e8..d83f5a3145 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl @@ -35,6 +35,7 @@ in vec2 vary_texcoord0;  in vec3 vary_position;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag);  void main()  { @@ -42,9 +43,8 @@ void main()      vec3 col = vertex_color.rgb * texture(diffuseMap, vary_texcoord0.xy).rgb;      frag_data[0] = vec4(col, 0.0);      frag_data[1] = vertex_color.aaaa; // spec -    //frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested      vec3 nvn = normalize(vary_normal); -    frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS); +    frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);      frag_data[3] = vec4(vertex_color.a, 0, 0, 0);  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl index 5c73878ba9..6d8943e7ae 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -33,6 +33,8 @@ in vec2 vary_texcoord0;  in vec3 vary_position;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag); +  vec3 linear_to_srgb(vec3 c);  void main() @@ -46,6 +48,6 @@ void main()      frag_data[0] = vec4(col, 0.0);      frag_data[1] = vec4(spec, vertex_color.a); // spec      vec3 nvn = normalize(vary_normal); -    frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS); +    frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);      frag_data[3] = vec4(vertex_color.a, 0, 0, 0);  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl index d493976eba..16120508d5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl @@ -43,3 +43,15 @@ void mirrorClip(vec3 pos)      }  } +vec4 encodeNormal(vec3 norm, float gbuffer_flag) +{ +    return vec4(norm * 0.5 + 0.5, gbuffer_flag); +} + +vec4 decodeNormal(vec4 norm) +{ +    norm.xyz = norm.xyz * 2.0 - 1.0; +    return norm; +} + + diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl index 99cb23839a..a6bca68cb0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl @@ -38,6 +38,8 @@ in vec2 vary_texcoord0;  vec3 linear_to_srgb(vec3 c); +vec4 encodeNormal(vec3 norm, float gbuffer_flag); +  void main()  {      vec4 col = texture(diffuseMap, vary_texcoord0.xy); diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index b521081af9..c0d4c387af 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -61,6 +61,7 @@ uniform vec4 clipPlane;  uniform float clipSign;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag);  uniform mat3 normal_matrix; @@ -113,7 +114,7 @@ void main()      // See: C++: addDeferredAttachments(), GLSL: softenLightF      frag_data[0] = max(vec4(col, 0.0), vec4(0));                                                   // Diffuse      frag_data[1] = max(vec4(spec.rgb,0.0), vec4(0));                                    // PBR linear packed Occlusion, Roughness, Metal. -    frag_data[2] = vec4(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags +    frag_data[2] = encodeNormal(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags      frag_data[3] = max(vec4(emissive,0), vec4(0));                                                // PBR sRGB Emissive  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl index 410c447c64..b434479511 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl @@ -162,6 +162,7 @@ in vec4[2] vary_coords;  #endif  void mirrorClip(vec3 position); +vec4 encodeNormal(vec3 norm, float gbuffer_flag);  float terrain_mix(TerrainMix tm, vec4 tms4); @@ -429,7 +430,7 @@ void main()  #endif      frag_data[0] = max(vec4(pbr_mix.col.xyz, 0.0), vec4(0));                                                   // Diffuse      frag_data[1] = max(vec4(mix_orm.rgb, base_color_factor_alpha), vec4(0));                                    // PBR linear packed Occlusion, Roughness, Metal. -    frag_data[2] = vec4(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, flags +    frag_data[2] = encodeNormal(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, flags      frag_data[3] = max(vec4(mix_emissive,0), vec4(0));                                                // PBR sRGB Emissive  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl index 1fd31e0546..5ff84b5937 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl @@ -39,6 +39,7 @@ in vec4 vary_texcoord0;  in vec4 vary_texcoord1;  void mirrorClip(vec3 position); +vec4 encodeNormal(vec3 norm, float gbuffer_flag);  void main()  { @@ -60,7 +61,7 @@ void main()      frag_data[0] = max(outColor, vec4(0));      frag_data[1] = vec4(0.0,0.0,0.0,-1.0);      vec3 nvn = normalize(vary_normal); -    frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS); +    frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);      frag_data[3] = vec4(0);  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl index 05922ecb1a..0894eff660 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl @@ -37,6 +37,8 @@ in vec3 vary_position;  uniform float minimum_alpha;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag); +  void main()  {      mirrorClip(vary_position); @@ -49,6 +51,6 @@ void main()      frag_data[0] = vec4(vertex_color.rgb*col.rgb, 0.0);      frag_data[1] = vec4(0,0,0,0);      vec3 nvn = normalize(vary_normal); -    frag_data[2] = vec4(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS); +    frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);      frag_data[3] = vec4(0);  } diff --git a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl index ac4ff50552..1d8a92bac7 100644 --- a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl +++ b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl @@ -64,6 +64,8 @@ in vec2 base_color_uv;  in vec2 emissive_uv;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag); +  vec3 linear_to_srgb(vec3 c);  vec3 srgb_to_linear(vec3 c);  // ================================== @@ -241,7 +243,7 @@ void main()  #else      frag_data[0] = max(vec4(basecolor.rgb, 0.0), vec4(0));      frag_data[1] = max(vec4(orm.rgb,0.0), vec4(0)); -    frag_data[2] = vec4(norm, GBUFFER_FLAG_HAS_PBR); +    frag_data[2] = encodeNormal(norm, GBUFFER_FLAG_HAS_PBR);      frag_data[3] = max(vec4(emissive,0), vec4(0));  #endif  #endif diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 5ee9aea09d..fb541ab51d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -51,6 +51,7 @@ uniform mat3 normal_matrix;  in vec3 vary_position;  void mirrorClip(vec3 pos); +vec4 encodeNormal(vec3 norm, float gbuffer_flag);  #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) @@ -414,7 +415,7 @@ void main()      frag_data[0] = max(vec4(diffcol.rgb, emissive), vec4(0));        // gbuffer is sRGB for legacy materials      frag_data[1] = max(vec4(spec.rgb, glossiness), vec4(0));           // XYZ = Specular color. W = Specular exponent. -    frag_data[2] = vec4(norm, flag);   // XY = Normal.  Z = Env. intensity. W = 1 skip atmos (mask off fog) +    frag_data[2] = encodeNormal(norm, flag);   // XY = Normal.  Z = Env. intensity. W = 1 skip atmos (mask off fog)      frag_data[3] = vec4(env, 0, 0, 0);  #endif diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 4231d8580e..802d049e74 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -27,6 +27,8 @@  out vec4 frag_color; +vec4 decodeNormal(vec4 norm); +  uniform sampler2D diffuseRect;  uniform sampler2D specularRect;  uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 6390e43b7a..de04db9a64 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -79,7 +79,7 @@ RenderHeroProbeResolution	1	2048  RenderHeroProbeDistance		1	16  RenderHeroProbeUpdateRate	1	6  RenderHeroProbeConservativeUpdateMultiplier 1 16 -RenderDownScaleMethod       1   1 +RenderDownScaleMethod       1   0  RenderCASSharpness          1   1  RenderExposure				1   4  RenderTonemapType			1   1 diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 1b2cc7cc64..82bcfdc0af 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -463,6 +463,11 @@ void LLReflectionMapManager::update()  LLReflectionMap* LLReflectionMapManager::addProbe(LLSpatialGroup* group)  { +    if (gGLManager.mGLVersion < 4.05f) +    { +        return nullptr; +    } +      LLReflectionMap* probe = new LLReflectionMap();      probe->mGroup = group; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 03d5563c65..697433148b 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1303,12 +1303,15 @@ void LLViewerRegion::updateReflectionProbes(bool full_update)                  mReflectionMaps[idx] = gPipeline.mReflectionMapManager.addProbe();              } -            LLVector3 probe_origin = LLVector3(x, y, llmax(water_height, mImpl->mLandp->resolveHeightRegion(x, y))); -            probe_origin.mV[2] += hover_height; -            probe_origin += origin; +            if (mReflectionMaps[idx]) +            { +                LLVector3 probe_origin = LLVector3(x, y, llmax(water_height, mImpl->mLandp->resolveHeightRegion(x, y))); +                probe_origin.mV[2] += hover_height; +                probe_origin += origin; -            mReflectionMaps[idx]->mOrigin.load3(probe_origin.mV); -            mReflectionMaps[idx]->mRadius = probe_radius; +                mReflectionMaps[idx]->mOrigin.load3(probe_origin.mV); +                mReflectionMaps[idx]->mRadius = probe_radius; +            }          }      }  } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index d1201df157..f5af9cc397 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -2493,7 +2493,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()          }      } -    if (success) +    if (success && gGLManager.mGLVersion > 4.05f)      {          gCASProgram.mName = "Contrast Adaptive Sharpening Shader";          gCASProgram.mFeatures.hasSrgb = true; diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 82fefde0a7..c10e28d688 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -546,7 +546,9 @@ void LLViewerTexture::updateClass()          if (sEvaluationTimer.getElapsedTimeF32() > MEMORY_CHECK_WAIT_TIME)          {              static LLCachedControl<F32> low_mem_min_discard_increment(gSavedSettings, "RenderLowMemMinDiscardIncrement", .1f); -            sDesiredDiscardBias += (F32) low_mem_min_discard_increment * (F32) gFrameIntervalSeconds; + +            F32 increment = low_mem_min_discard_increment + llmax(over_pct, 0.f); +            sDesiredDiscardBias += increment * gFrameIntervalSeconds;          }      }      else @@ -605,7 +607,7 @@ void LLViewerTexture::updateClass()                  last_desired_discard_bias = sDesiredDiscardBias;                  was_backgrounded = true;              } -            sDesiredDiscardBias = 4.f; +            sDesiredDiscardBias = 5.f;          }      }      else @@ -619,7 +621,7 @@ void LLViewerTexture::updateClass()          }      } -    sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 4.f); +    sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 5.f);      LLViewerTexture::sFreezeImageUpdates = false;  } diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 65fa633f81..1da8548573 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -410,6 +410,8 @@ public:      /*virtual*/bool  isActiveFetching() override; //is actively in fetching by the fetching pipeline. +    virtual bool scaleDown() { return false; }; +      bool mCreatePending = false;    // if true, this is in gTextureList.mCreateTextureList      mutable bool mDownScalePending = false; // if true, this is in gTextureList.mDownScaleQueue @@ -527,12 +529,12 @@ public:      LLViewerLODTexture(const LLUUID& id, FTType f_type, const LLHost& host = LLHost(), bool usemipmaps = true);      LLViewerLODTexture(const std::string& url, FTType f_type, const LLUUID& id, bool usemipmaps = true); -    /*virtual*/ S8 getType() const; +    S8 getType() const override;      // Process image stats to determine priority/quality requirements. -    /*virtual*/ void processTextureStats(); +    void processTextureStats() override;      bool isUpdateFrozen() ; -    bool scaleDown(); +    bool scaleDown() override;  private:      void init(bool firstinit) ; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index fc92b72513..538e6a6763 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1062,8 +1062,32 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time)      LLTimer create_timer; +    while (!mCreateTextureList.empty()) +    { +        LLViewerFetchedTexture* imagep = mCreateTextureList.front(); +        llassert(imagep->mCreatePending); +        imagep->createTexture(); +        imagep->postCreateTexture(); +        imagep->mCreatePending = false; +        mCreateTextureList.pop(); + +        if (imagep->getDiscardLevel() < imagep->getDesiredDiscardLevel()) +        { +            LL_WARNS_ONCE("Texture") << "Texture will be downscaled immediately after loading." << LL_ENDL; +            imagep->scaleDown(); +        } + +        if (create_timer.getElapsedTimeF32() > max_time) +        { +            break; +        } +    } +      if (!mDownScaleQueue.empty() && gPipeline.mDownResMap.isComplete())      { +        LLGLDisable blend(GL_BLEND); +        gGL.setColorMask(true, true); +          // just in case we downres textures, bind downresmap and copy program          gPipeline.mDownResMap.bindTarget();          gCopyProgram.bind(); @@ -1077,6 +1101,7 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time)          // freeze.          S32 min_count = (S32)mCreateTextureList.size() / 20 + 5; +        create_timer.reset();          while (!mDownScaleQueue.empty())          {              LLViewerFetchedTexture* image = mDownScaleQueue.front(); @@ -1101,25 +1126,6 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time)          gPipeline.mDownResMap.flush();      } -    // do at least 5 and make sure we don't get too far behind even if it violates -    // the time limit.  Textures pending creation have a copy of their texture data -    // in system memory, so we don't want to let them pile up. -    S32 min_count = (S32) mCreateTextureList.size() / 20 + 5; - -    while (!mCreateTextureList.empty()) -    { -        LLViewerFetchedTexture *imagep =  mCreateTextureList.front(); -        llassert(imagep->mCreatePending); -        imagep->createTexture(); -        imagep->postCreateTexture(); -        imagep->mCreatePending = false; -        mCreateTextureList.pop(); - -        if (create_timer.getElapsedTimeF32() > max_time && --min_count <= 0) -        { -            break; -        } -    }      return create_timer.getElapsedTimeF32();  } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index c0df34d3ac..5d5c7f9aae 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5861,7 +5861,23 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)                              {                                  if (gltf_mat != nullptr)                                  { -                                    add_face(sPbrFaces, pbr_count, facep); +                                    // In theory, we should never actually get here with alpha blending. +                                    // How this is supposed to work is we check if the surface is alpha blended, and we assign it to the +                                    // alpha draw pool. For rigged meshes, this apparently may not happen consistently. For now, just +                                    // discard it here if the alpha is 0 (fully transparent) to achieve parity with blinn-phong materials in +                                    // function. +                                    bool should_render = true; +                                    if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND) +                                    { +                                        if (gltf_mat->mBaseColor.mV[3] == 0.0f) +                                        { +                                            should_render = false; +                                        } +                                    } +                                    if (should_render) +                                    { +                                        add_face(sPbrFaces, pbr_count, facep); +                                    }                                  }                                  else                                  { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f95090d134..76b8cebf94 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -345,10 +345,22 @@ void validate_framebuffer_object();  // target -- RenderTarget to add attachments to  bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false)  { +    U32 orm = GL_RGBA; +    U32 norm = GL_RGBA16F; +    U32 emissive = GL_RGB16F; + +    bool hdr = gSavedSettings.getBOOL("RenderHDREnabled") && gGLManager.mGLVersion > 4.05f; + +    if (!hdr) +    { +        norm = GL_RGBA; +        emissive = GL_RGB; +    } +      bool valid = true -        && target.addColorAttachment(GL_RGBA) // frag-data[1] specular OR PBR ORM -        && target.addColorAttachment(GL_RGBA16F)                              // frag_data[2] normal+fogmask, See: class1\deferred\materialF.glsl & softenlight -        && target.addColorAttachment(GL_RGB16F);                  // frag_data[3] PBR emissive OR material env intensity +        && target.addColorAttachment(orm)       // frag-data[1] specular OR PBR ORM +        && target.addColorAttachment(norm)      // frag_data[2] normal+fogmask, See: class1\deferred\materialF.glsl & softenlight +        && target.addColorAttachment(emissive); // frag_data[3] PBR emissive OR material env intensity      return valid;  } @@ -785,6 +797,9 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY)  bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + +    bool hdr = gGLManager.mGLVersion > 4.05f && gSavedSettings.getBOOL("RenderHDREnabled"); +      if (mRT == &mMainRT)      { // hacky -- allocate auxillary buffer @@ -830,7 +845,7 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)      if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, true)) return false;      if (!addDeferredAttachments(mRT->deferredScreen)) return false; -    GLuint screenFormat = GL_RGBA16F; +    GLuint screenFormat = hdr ? GL_RGBA16F : GL_RGBA;      if (!mRT->screen.allocate(resX, resY, screenFormat)) return false; @@ -838,7 +853,7 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)      if (shadow_detail > 0 || ssao || RenderDepthOfField)      { //only need mRT->deferredLight for shadows OR ssao OR dof -        if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16F)) return false; +        if (!mRT->deferredLight.allocate(resX, resY, screenFormat)) return false;      }      else      { @@ -872,22 +887,22 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY)          }          //water reflection texture (always needed as scratch space whether or not transparent water is enabled) -        mWaterDis.allocate(resX, resY, GL_RGBA16F, true); +        mWaterDis.allocate(resX, resY, screenFormat, true);          if(RenderScreenSpaceReflections)          { -            mSceneMap.allocate(resX, resY, GL_RGBA16F, true); +            mSceneMap.allocate(resX, resY, screenFormat, true);          }          else          {              mSceneMap.release();          } -        mPostMap.allocate(resX, resY, GL_RGBA16F); +        mPostMap.allocate(resX, resY, screenFormat);          // used to scale down textures          // See LLViwerTextureList::updateImagesCreateTextures and LLImageGL::scaleDown -        mDownResMap.allocate(4, 4, GL_RGBA); +        mDownResMap.allocate(1024, 1024, GL_RGBA);          mBakeMap.allocate(LLAvatarAppearanceDefines::SCRATCH_TEX_WIDTH, LLAvatarAppearanceDefines::SCRATCH_TEX_HEIGHT, GL_RGBA);      } @@ -4079,6 +4094,13 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)          LLGLState::checkStates(GL_FALSE);      } +    // turn off atmospherics and water haze for low detail reflection probe +    static LLCachedControl<S32> probe_level(gSavedSettings, "RenderReflectionProbeLevel", 0); +    bool low_detail_probe = probe_level == 0 && gCubeSnapshot; +    done_atmospherics = done_atmospherics || low_detail_probe; +    done_water_haze   = done_water_haze || low_detail_probe; + +      while ( iter1 != mPools.end() )      {          LLDrawPool *poolp = *iter1; @@ -7895,15 +7917,20 @@ void LLPipeline::renderFinalize()      gGL.setColorMask(true, true);      glClearColor(0, 0, 0, 0); -    copyScreenSpaceReflections(&mRT->screen, &mSceneMap); +    bool hdr = gGLManager.mGLVersion > 4.05f && gSavedSettings.getBOOL("RenderHDREnabled"); -    generateLuminance(&mRT->screen, &mLuminanceMap); +    if (hdr) +    { +        copyScreenSpaceReflections(&mRT->screen, &mSceneMap); + +        generateLuminance(&mRT->screen, &mLuminanceMap); -    generateExposure(&mLuminanceMap, &mExposureMap); +        generateExposure(&mLuminanceMap, &mExposureMap); -    tonemap(&mRT->screen, &mPostMap); +        tonemap(&mRT->screen, &mPostMap); -    applyCAS(&mPostMap, &mRT->screen); +        applyCAS(&mPostMap, &mRT->screen); +    }      generateSMAABuffers(&mRT->screen); @@ -8505,8 +8532,9 @@ void LLPipeline::renderDeferredLighting()          }          static LLCachedControl<S32> local_light_count(gSavedSettings, "RenderLocalLightCount", 256); +        static LLCachedControl<S32> probe_level(gSavedSettings, "RenderReflectionProbeLevel", 0); -        if (local_light_count > 0) +        if (local_light_count > 0 && (!gCubeSnapshot || probe_level > 0))          {              gGL.setSceneBlendType(LLRender::BT_ADD);              std::list<LLVector4>        fullscreen_lights;  | 
