diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index ac48a633c721ec19866edcbc06625934b11fd9e9..7d3a92237b4a0fd69e9746f625835a674b1cb06d 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -122,7 +122,7 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL us bind(0); - U32 format = components == 4 ? GL_RGBA12 : GL_RGB16F; + U32 format = components == 4 ? GL_RGBA16F : GL_RGB16F; U32 mip = 0; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 10da8da05f3bdffccd6985459eb1543055988829..f581ed2dc917339040a624e5f26b5bb4426a77a2 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -42,6 +42,8 @@ #include "llwindow.h" #include "llframetimer.h" +extern LL_COMMON_API bool on_main_thread(); + #if !LL_IMAGEGL_THREAD_CHECK #define checkActiveThread() #endif @@ -131,7 +133,8 @@ bool LLImageGL::sCompressTextures = false; std::set<LLImageGL*> LLImageGL::sImageList; -bool LLImageGLThread::sEnabled = false; +bool LLImageGLThread::sEnabledTextures = false; +bool LLImageGLThread::sEnabledMedia = false; //**************************************************************************************************** //The below for texture auditing use only @@ -241,14 +244,16 @@ BOOL is_little_endian() } //static -void LLImageGL::initClass(LLWindow* window, S32 num_catagories, BOOL skip_analyze_alpha /* = false */, bool multi_threaded /* = false */) +void LLImageGL::initClass(LLWindow* window, S32 num_catagories, BOOL skip_analyze_alpha /* = false */, bool thread_texture_loads /* = false */, bool thread_media_updates /* = false */) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; sSkipAnalyzeAlpha = skip_analyze_alpha; - if (multi_threaded) + if (thread_texture_loads || thread_media_updates) { LLImageGLThread::createInstance(window); + LLImageGLThread::sEnabledTextures = thread_texture_loads; + LLImageGLThread::sEnabledMedia = thread_media_updates; } } @@ -259,6 +264,7 @@ void LLImageGL::cleanupClass() LLImageGLThread::deleteSingleton(); } + //static S32 LLImageGL::dataFormatBits(S32 dataformat) { @@ -1124,9 +1130,20 @@ U32 type_width_from_pixtype(U32 pixtype) return type_width; } +bool should_stagger_image_set(bool compressed) +{ +#if LL_DARWIN + return false; +#else + // glTexSubImage2D doesn't work with compressed textures on select tested Nvidia GPUs on Windows 10 -Cosmic,2023-03-08 + // Setting media textures off-thread seems faster when not using sub_image_lines (Nvidia/Windows 10) -Cosmic,2023-03-31 + return !compressed && on_main_thread(); +#endif +} + // Equivalent to calling glSetSubImage2D(target, miplevel, x_offset, y_offset, width, height, pixformat, pixtype, src), assuming the total width of the image is data_width // However, instead there are multiple calls to glSetSubImage2D on smaller slices of the image -void subImageLines(U32 target, S32 miplevel, S32 x_offset, S32 y_offset, S32 width, S32 height, U32 pixformat, U32 pixtype, const U8* src, S32 data_width) +void sub_image_lines(U32 target, S32 miplevel, S32 x_offset, S32 y_offset, S32 width, S32 height, U32 pixformat, U32 pixtype, const U8* src, S32 data_width) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -1222,11 +1239,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 if (!res) LL_ERRS() << "LLImageGL::setSubImage(): bindTexture failed" << LL_ENDL; stop_glerror(); -#if LL_DARWIN || LL_LINUX - const bool use_sub_image = false; -#else - const bool use_sub_image = !isCompressed(); -#endif + const bool use_sub_image = should_stagger_image_set(isCompressed()); if (!use_sub_image) { // *TODO: Why does this work here, in setSubImage, but not in @@ -1237,7 +1250,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 } else { - subImageLines(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, sub_datap, data_width); + sub_image_lines(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, sub_datap, data_width); } gGL.getTexUnit(0)->disable(); stop_glerror(); @@ -1491,13 +1504,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt LL_PROFILE_ZONE_NUM(height); free_cur_tex_image(); -#if LL_DARWIN || LL_LINUX - const bool use_sub_image = false; -#else - // glTexSubImage2D doesn't work with compressed textures on select tested Nvidia GPUs on Windows 10 -Cosmic,2023-03-08 - // *TODO: Small chance that glCompressedTexImage2D/glCompressedTexSubImage2D may work better here - const bool use_sub_image = !compress; -#endif + const bool use_sub_image = should_stagger_image_set(compress); if (!use_sub_image) { LL_PROFILE_ZONE_NAMED("glTexImage2D alloc + copy"); @@ -1515,7 +1522,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt if (src) { LL_PROFILE_ZONE_NAMED("glTexImage2D copy"); - subImageLines(target, miplevel, 0, 0, width, height, pixformat, pixtype, src, width); + sub_image_lines(target, miplevel, 0, 0, width, height, pixformat, pixtype, src, width); } } alloc_tex_image(width, height, pixformat); @@ -2585,7 +2592,6 @@ LLImageGLThread::LLImageGLThread(LLWindow* window) , mWindow(window) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - sEnabled = true; mFinished = false; mContext = mWindow->createSharedContext(); diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 89560084c4b03990f66391f1b6d1570afafc52a4..65922ad033369e8dc46bbd7bc4c0a5397ed71ba2 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -291,7 +291,7 @@ class LLImageGL : public LLRefCount #endif public: - static void initClass(LLWindow* window, S32 num_catagories, BOOL skip_analyze_alpha = false, bool multi_threaded = false); + static void initClass(LLWindow* window, S32 num_catagories, BOOL skip_analyze_alpha = false, bool thread_texture_loads = false, bool thread_media_updates = false); static void cleanupClass() ; private: @@ -333,8 +333,10 @@ class LLImageGL : public LLRefCount class LLImageGLThread : public LLSimpleton<LLImageGLThread>, LL::ThreadPool { public: - // follows gSavedSettings "RenderGLMultiThreaded" - static bool sEnabled; + // follows gSavedSettings "RenderGLMultiThreadedTextures" + static bool sEnabledTextures; + // follows gSavedSettings "RenderGLMultiThreadedMedia" + static bool sEnabledMedia; LLImageGLThread(LLWindow* window); @@ -353,5 +355,4 @@ class LLImageGLThread : public LLSimpleton<LLImageGLThread>, LL::ThreadPool LLAtomicBool mFinished; }; - #endif // LL_LLIMAGEGL_H diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 6aef1a3bb9734429713dfe58e03b369c064c5fb8..6f36808595b8ef4b1c1eb42cb04a3b3a1939b619 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -485,7 +485,7 @@ U32 LLRenderTarget::getNumTextures() const void LLRenderTarget::bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilterOptions filter_options) { - gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index)); + gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index), filter_options == LLTexUnit::TFO_TRILINEAR || filter_options == LLTexUnit::TFO_ANISOTROPIC); bool isSRGB = false; llassert(mInternalFormat.size() > index); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 8fe14d119406b410da352c1c54e864b8bc5db1ec..da6bec110d631eee743ec00cac53822f3e5b6768 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10386,10 +10386,21 @@ <key>Value</key> <integer>0</integer> </map> - <key>RenderGLMultiThreaded</key> + <key>RenderGLMultiThreadedTextures</key> <map> <key>Comment</key> - <string>Allow OpenGL to use multiple render contexts (reduces frame stutters from loading textures, doesn't play nice with Intel drivers).</string> + <string>Allow OpenGL to use multiple render contexts for loading textures (may reduce frame stutters, doesn't play nice with Intel drivers).</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>RenderGLMultiThreadedMedia</key> + <map> + <key>Comment</key> + <string>Allow OpenGL to use multiple render contexts for playing media (may reduce frame stutters, doesn't play nice with Intel drivers)</string> <key>Persist</key> <integer>1</integer> <key>Type</key> @@ -10924,6 +10935,61 @@ <key>Value</key> <integer>3</integer> </map> + <key>RenderSkyHDRScale</key> + <map> + <key>Comment</key> + <string>Amount to over-brighten sun for HDR effect during the day</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>3.0</real> + </map> + <key>RenderReflectionProbeMaxLocalLightAmbiance</key> + <map> + <key>Comment</key> + <string>Maximum effective probe ambiance for local lights</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>4.0</real> + </map> + <key>RenderDynamicExposureMin</key> + <map> + <key>Comment</key> + <string>Minimum dynamic exposure amount</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.125</real> + </map> + <key>RenderDynamicExposureMax</key> + <map> + <key>Comment</key> + <string>Maximum dynamic exposure amount</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>1.3</real> + </map> + <key>RenderDynamicExposureCoefficient</key> + <map> + <key>Comment</key> + <string>Luminance coefficient for dynamic exposure</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.175</real> + </map> <key>RenderShaderLODThreshold</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl index 861b78c961733bdfb86790d99256c97c7515dd66..3eda2b90502a399a208baeaeb79bc54d8680c0d1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl @@ -29,13 +29,13 @@ out vec4 frag_color; -uniform sampler2D diffuseRect; uniform sampler2D emissiveRect; uniform sampler2D exposureMap; uniform float dt; uniform vec2 noiseVec; +uniform vec3 dynamic_exposure_params; float lum(vec3 col) { @@ -45,44 +45,11 @@ float lum(vec3 col) void main() { - float step = 1.0/16.0; + vec2 tc = vec2(0.5,0.5); - float start = step; - float end = 1.0-step; - - float w = 0.0; - - vec3 col; - - //vec2 nz = noiseVec * step * 0.5; - - for (float x = start; x <= end; x += step) - { - for (float y = start; y <= end; y += step) - { - vec2 tc = vec2(x,y); // + nz; - vec3 c = texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb; - float L = max(lum(c), 0.25); - - float d = length(vec2(0.5)-tc); - d = 1.0-d; - d *= d; - d *= d; - d *= d; - L *= d; - - w += L; - - col += c * L; - } - } - - col /= w; - - float L = lum(col); - - float s = clamp(0.175/L, 0.125, 1.3); + float L = textureLod(emissiveRect, tc, 8).r; + float s = clamp(dynamic_exposure_params.x/L, dynamic_exposure_params.y, dynamic_exposure_params.z); float prev = texture(exposureMap, vec2(0.5,0.5)).r; diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl new file mode 100644 index 0000000000000000000000000000000000000000..e63e666778a49031f658a9d46759050b56c8ce53 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl @@ -0,0 +1,52 @@ +/** + * @file luminanceF.glsl + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + + +/*[EXTRA_CODE_HERE]*/ + +// take a luminance sample of diffuseRect and emissiveRect + +out vec4 frag_color; + +in vec2 vary_fragcoord; + +uniform sampler2D diffuseRect; +uniform sampler2D emissiveRect; + +float lum(vec3 col) +{ + vec3 l = vec3(0.2126, 0.7152, 0.0722); + return dot(l, col); +} + +void main() +{ + vec2 tc = vary_fragcoord*0.6+0.2; + vec3 c = texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb; + float L = lum(c); + + frag_color = vec4(L); +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 22e93496d2f801576445c52d24f508dd2a04f3c8..49ff49fdd8bc16b93329542442a58d00c9d841b7 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -36,7 +36,9 @@ vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) { light *= atten.r; additive = srgb_to_linear(additive*2.0); - additive *= sun_up_factor + 1.0; + // magic 3.0 here is to match the default RenderSkyHDRScale -- this parameter needs to be plumbed into sky settings or something + // so it's available to all shaders that call atmosFragLighting instead of just softenLightF.glsl + additive *= sun_up_factor*3.0 + 1.0; light += additive; return light; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl index 257a76c663989516e56edba4417e415895e00935..6ecbfaecb10e8ab3596304579cf8a5a0a3467815 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl @@ -54,8 +54,4 @@ vec3 scaleDownLight(vec3 light) return (light / scene_light_strength ); } -vec3 scaleUpLight(vec3 light) -{ - return (light * scene_light_strength); -} diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index beaea4ce3360e2e7e775a7b8f9224c352548f564..25603b00aabedb29d6c54b11fd6651b2ae0b3904 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -174,10 +174,7 @@ void main() } } - //not sure why, but this line prevents MATBUG-194 - final_color = max(final_color, vec3(0.0)); - - frag_color.rgb = final_color; + frag_color.rgb = max(final_color, vec3(0)); frag_color.a = 0.0; #endif // LOCAL_LIGHT_KILL diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl index 215eb696668849cdc0aeb6c600e6e36b8ad8af96..d7c3445d7778401bda2c5211a9081bea9ee649b2 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl @@ -149,6 +149,6 @@ void main() } } - frag_color.rgb = max(final_color, vec3(0.0)); + frag_color.rgb = max(final_color, 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 e19d780e7fc89ae2d5fb9f04a198850fb1693529..51ab543e6e89c5047a3f8e16d50907aff32060ee 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -89,6 +89,8 @@ uniform vec4 waterPlane; vec4 applyWaterFogViewLinear(vec3 pos, vec4 color); #endif +uniform float sky_hdr_scale; + void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor); vec3 pbrBaseLight(vec3 diffuseColor, @@ -195,22 +197,17 @@ void main() vec3 v = -normalize(pos.xyz); color = vec3(1,0,1); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); - if (do_atmospherics) { - color = linear_to_srgb(color); color = atmosFragLightingLinear(color, additive, atten); - color = srgb_to_linear(color); } - - } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { //should only be true of WL sky, just port over base color value color = srgb_to_linear(texture2D(emissiveRect, tc).rgb); - color *= sun_up_factor + 1.0; + color *= sun_up_factor * sky_hdr_scale + 1.0; } else { diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index da548dd0d46148b89f868a5ab5b0163adcdedb9e..58509b37f3a68248f62c8d79b9fbc11b179afe2d 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 53 +version 54 // 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 @@ -69,7 +69,8 @@ RenderUseStreamVBO 1 1 RenderFSAASamples 1 16 RenderMaxTextureIndex 1 16 RenderGLContextCoreProfile 1 1 -RenderGLMultiThreaded 1 0 +RenderGLMultiThreadedTextures 1 0 +RenderGLMultiThreadedMedia 1 1 RenderReflectionProbeResolution 1 128 RenderScreenSpaceReflections 1 1 @@ -308,9 +309,10 @@ list Intel RenderAnisotropicLevel 1 0 RenderFSAASamples 1 0 RenderGLContextCoreProfile 1 0 +RenderGLMultiThreadedMedia 1 0 list AMD -RenderGLMultiThreaded 1 1 +RenderGLMultiThreadedTextures 1 1 list GL3 RenderFSAASamples 0 0 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 8732ff230deb0b816227b858b3208025772a9517..c5610b5e41dda7cd685ad28118866dfa824c3f33 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 47 +version 49 // 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 @@ -44,11 +44,9 @@ RenderGlowResolutionPow 1 9 RenderMaxPartCount 1 8192 RenderObjectBump 1 1 RenderLocalLights 1 1 -RenderTransparentWater 1 1 -RenderReflectionsEnabled 1 1 -RenderReflectionProbeDetail 1 2 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 +RenderTransparentWater 1 1 RenderTreeLODFactor 1 1.0 RenderVBOEnable 1 1 RenderVBOMappingDisable 1 1 @@ -68,10 +66,13 @@ RenderUseStreamVBO 1 1 RenderFSAASamples 1 16 RenderMaxTextureIndex 1 16 RenderGLContextCoreProfile 1 1 -RenderGLMultiThreaded 1 1 -RenderReflectionProbeResolution 1 128 +RenderGLMultiThreadedTextures 1 0 +RenderGLMultiThreadedMedia 1 0 +RenderReflectionsEnabled 1 1 +RenderReflectionProbeDetail 1 2 RenderScreenSpaceReflections 1 1 RenderReflectionProbeCount 1 256 +RenderReflectionProbeResolution 1 128 // // Low Graphics Settings diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index f81b8fd5467d8c1cb553d510f0f6f65a2ff61471..4a11b0f9c90d1c40758a019ec209d27ee9b7cae2 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -1027,7 +1027,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI bump->setExplicitFormat(GL_ALPHA8, GL_ALPHA); #if LL_BUMPLIST_MULTITHREADED - auto tex_queue = LLImageGLThread::sEnabled ? sTexUpdateQueue.lock() : nullptr; + auto tex_queue = LLImageGLThread::sEnabledTextures ? sTexUpdateQueue.lock() : nullptr; if (tex_queue) { //dispatch creation to background thread @@ -1139,7 +1139,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI }; #if LL_BUMPLIST_MULTITHREADED - auto main_queue = LLImageGLThread::sEnabled ? sMainQueue.lock() : nullptr; + auto main_queue = LLImageGLThread::sEnabledTextures ? sMainQueue.lock() : nullptr; if (main_queue) { //dispatch texture upload to background thread, issue GPU commands to generate normal map on main thread diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index fa140ec0e598777243129133309f4fffbed23e1e..35e5aff474cec328cc244591eff35a81ce86dc66 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -815,7 +815,7 @@ const F64Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F64Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("01e41537-ff51-2f1f-8ef7-17e4df760bfb"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("e4391f43-74d6-d889-19fb-99a4a3ad6c5c"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("d9950f9a-f693-be73-0384-13ee97b8ca10"); const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("084e26cd-a900-28e8-08d0-64a9de5c15e2"); const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("8a01b97a-cb20-c1ea-ac63-f7ea84ad0090"); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 850b293e7c2de94d608d54506170f23a1d16bbfd..9e947774b19a41dc8cd777d9a42101385dd53950 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -464,6 +464,13 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) // hacky hot-swap of camera specific render targets gPipeline.mRT = &gPipeline.mAuxillaryRT; + mLightScale = 1.f; + static LLCachedControl<F32> max_local_light_ambiance(gSavedSettings, "RenderReflectionProbeMaxLocalLightAmbiance", 8.f); + if (!isRadiancePass() && probe->getAmbiance() > max_local_light_ambiance) + { + mLightScale = max_local_light_ambiance / probe->getAmbiance(); + } + if (probe == mDefaultProbe) { touch_default_probe(probe); diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index fef308541dff33edeeb202ef303365c78050882d..9a46af58b35fe4b87d2b15b2158883ee92dc979b 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -187,5 +187,8 @@ class alignas(16) LLReflectionMapManager // maximum LoD of reflection probes (mip levels - 1) F32 mMaxProbeLOD = 6.f; + + // amount to scale local lights during an irradiance map update (set during updateProbeFace and used by LLPipeline) + F32 mLightScale = 1.f; }; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 705b5eefa3fed38801d66817648f8a126e45a5ec..caf8bcce00e58e647bc29537a0bc6e6f20779255 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -325,7 +325,7 @@ void update_texture_fetch() LLAppViewer::getTextureFetch()->update(1); // unpauses the texture fetch thread gTextureList.updateImages(0.10f); - if (LLImageGLThread::sEnabled) + if (LLImageGLThread::sEnabledTextures) { std::shared_ptr<LL::WorkQueue> main_queue = LL::WorkQueue::getInstance("mainloop"); main_queue->runFor(std::chrono::milliseconds(1)); diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 3ba4d33859af057aca90ebdfa323ba57a745d6a9..2224c909f7ae29e0443773c72d1d630fe6802885 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -2880,7 +2880,7 @@ void LLViewerMediaImpl::update() if (preMediaTexUpdate(media_tex, data, data_width, data_height, x_pos, y_pos, width, height)) { // Push update to worker thread - auto main_queue = LLImageGLThread::sEnabled ? mMainQueue.lock() : nullptr; + auto main_queue = LLImageGLThread::sEnabledMedia ? mMainQueue.lock() : nullptr; if (main_queue) { mTextureUpdatePending = true; @@ -2969,11 +2969,12 @@ void LLViewerMediaImpl::doMediaTexUpdate(LLViewerMediaTexture* media_tex, U8* da // wrap "data" in an LLImageRaw but do NOT make a copy LLPointer<LLImageRaw> raw = new LLImageRaw(data, media_tex->getWidth(), media_tex->getHeight(), media_tex->getComponents(), true); - + // *NOTE: Recreating the GL texture each media update may seem wasteful // (note the texture creation in preMediaTexUpdate), however, it apparently // prevents GL calls from blocking, due to poor bookkeeping of state of - // updated textures by the OpenGL implementation. + // updated textures by the OpenGL implementation. (Windows 10/Nvidia) + // -Cosmic,2023-04-04 // Allocate GL texture based on LLImageRaw but do NOT copy to GL LLGLuint tex_name = 0; media_tex->createGLTexture(0, raw, 0, TRUE, LLGLTexture::OTHER, true, &tex_name); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 132bd24dad7b15c6e121a6383d17bbeabc938858..3000fe061b4c1c8373620b38ac9954318a5ef2c3 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -190,6 +190,7 @@ LLGLSLShader gDeferredCoFProgram; LLGLSLShader gDeferredDoFCombineProgram; LLGLSLShader gDeferredPostGammaCorrectProgram; LLGLSLShader gExposureProgram; +LLGLSLShader gLuminanceProgram; LLGLSLShader gFXAAProgram[4]; LLGLSLShader gDeferredPostNoDoFProgram; LLGLSLShader gDeferredWLSkyProgram; @@ -1016,6 +1017,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredCoFProgram.unload(); gDeferredDoFCombineProgram.unload(); gExposureProgram.unload(); + gLuminanceProgram.unload(); gDeferredPostGammaCorrectProgram.unload(); for (auto i = 0; i < 4; ++i) { @@ -2564,6 +2566,18 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() llassert(success); } + if (success) + { + gLuminanceProgram.mName = "Luminance"; + gLuminanceProgram.mShaderFiles.clear(); + gLuminanceProgram.clearPermutations(); + gLuminanceProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); + gLuminanceProgram.mShaderFiles.push_back(make_pair("deferred/luminanceF.glsl", GL_FRAGMENT_SHADER)); + gLuminanceProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gLuminanceProgram.createShader(NULL, NULL); + llassert(success); + } + if (success) { gDeferredPostGammaCorrectProgram.mName = "Deferred Gamma Correction Post Process"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 7e6595f8e0ad5bcd1805ee131dfe408714fe5edf..69c1e3060eb20a2254944dfa6f161bd7cf566e43 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -241,6 +241,7 @@ extern LLGLSLShader gFXAAProgram[4]; extern LLGLSLShader gDeferredPostNoDoFProgram; extern LLGLSLShader gDeferredPostGammaCorrectProgram; extern LLGLSLShader gExposureProgram; +extern LLGLSLShader gLuminanceProgram; extern LLGLSLShader gDeferredAvatarShadowProgram; extern LLGLSLShader gDeferredAvatarAlphaShadowProgram; extern LLGLSLShader gDeferredAvatarAlphaMaskShadowProgram; diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 08678999b4a3ce95e6b53b24b5b2de319d38a5a2..03e994f120079e15dd070fe823ffcf802cf717aa 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1628,7 +1628,7 @@ void LLViewerFetchedTexture::scheduleCreateTexture() } #endif mNeedsCreateTexture = true; - auto mainq = LLImageGLThread::sEnabled ? mMainQueue.lock() : nullptr; + auto mainq = LLImageGLThread::sEnabledTextures ? mMainQueue.lock() : nullptr; if (mainq) { ref(); diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 336ce2bd5882e4445239dd9c0f9451c0ca748eb2..23c98096610765b0b2304e1ea9320d71e3780321 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1242,7 +1242,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) LLViewerFetchedTexture* imagep = *iter++; imagep->updateFetch(); } - std::shared_ptr<LL::WorkQueue> main_queue = LLImageGLThread::sEnabled ? LL::WorkQueue::getInstance("mainloop") : NULL; + std::shared_ptr<LL::WorkQueue> main_queue = LLImageGLThread::sEnabledTextures ? LL::WorkQueue::getInstance("mainloop") : NULL; // Run threads S32 fetch_pending = 0; while (1) @@ -1251,7 +1251,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) LLAppViewer::instance()->getImageDecodeThread()->update(1); // unpauses the image thread fetch_pending = LLAppViewer::instance()->getTextureFetch()->update(1); // unpauses the texture fetch thread - if (LLImageGLThread::sEnabled) + if (LLImageGLThread::sEnabledTextures) { main_queue->runFor(std::chrono::milliseconds(1)); fetch_pending += main_queue->size(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 0c8866e0e30950f11e5d5cbd5df42c1c537fc106..24f5c6de443333686220417e9db29a291dd2151e 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2016,8 +2016,8 @@ LLViewerWindow::LLViewerWindow(const Params& p) } // Init the image list. Must happen after GL is initialized and before the images that - // LLViewerWindow needs are requested. - LLImageGL::initClass(mWindow, LLViewerTexture::MAX_GL_IMAGE_CATEGORY, false, gSavedSettings.getBOOL("RenderGLMultiThreaded")); + // LLViewerWindow needs are requested, as well as before LLViewerMedia starts updating images. + LLImageGL::initClass(mWindow, LLViewerTexture::MAX_GL_IMAGE_CATEGORY, false, gSavedSettings.getBOOL("RenderGLMultiThreadedTextures"), gSavedSettings.getBOOL("RenderGLMultiThreadedMedia")); gTextureList.init(); LLViewerTextureManager::init() ; gBumpImageList.init(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1e4f81f237d77982941765b6d5953039a1859450..304ac3ce66ff0e883ef29e6f0da58a79f51ed6ab 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -849,7 +849,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0 || RlvActions::hasPostProcess()) // [/RLVa:KB] { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa - if (!mRT->deferredLight.allocate(resX, resY, screenFormat)) return false; + if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16F)) return false; } else { @@ -1148,6 +1148,7 @@ void LLPipeline::releaseLUTBuffers() mPbrBrdfLut.release(); mExposureMap.release(); + mLuminanceMap.release(); mLastExposure.release(); } @@ -1399,6 +1400,8 @@ void LLPipeline::createLUTBuffers() mExposureMap.clear(); mExposureMap.flush(); + mLuminanceMap.allocate(256, 256, GL_R16F); + mLastExposure.allocate(1, 1, GL_R16F); } @@ -5734,6 +5737,14 @@ void LLPipeline::setupHWLights() return; } + F32 light_scale = 1.f; + + if (gCubeSnapshot) + { //darken local lights when probe ambiance is above 1 + light_scale = mReflectionMapManager.mLightScale; + } + + LLEnvironment& environment = LLEnvironment::instance(); const LLSettingsSky::ptr_t& psky = environment.getCurrentSky(); @@ -5833,7 +5844,7 @@ void LLPipeline::setupHWLights() } //send linear light color to shader - LLColor4 light_color = light->getLightLinearColor(); + LLColor4 light_color = light->getLightLinearColor() * light_scale; light_color.mV[3] = 0.0f; F32 fade = iter->fade; @@ -7324,6 +7335,43 @@ void LLPipeline::renderFinalize() dst.flush(); } + // luminance sample and mipmap generation + { + LL_PROFILE_GPU_ZONE("luminance sample"); + + mLuminanceMap.bindTarget(); + + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + + gLuminanceProgram.bind(); + + + S32 channel = 0; + channel = gLuminanceProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); + if (channel > -1) + { + screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); + } + + channel = gLuminanceProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); + if (channel > -1) + { + mGlow[1].bindTexture(0, channel); + } + + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + mLuminanceMap.flush(); + + mLuminanceMap.bindTexture(0, 0, LLTexUnit::TFO_TRILINEAR); + glGenerateMipmap(GL_TEXTURE_2D); + + // note -- unbind AFTER the glGenerateMipMap so time in generatemipmap can be profiled under "Luminance" + // also note -- keep an eye on the performance of glGenerateMipmap, might need to replace it with a mip generation shader + gLuminanceProgram.unbind(); + } + // exposure sample { LL_PROFILE_GPU_ZONE("exposure sample"); @@ -7340,24 +7388,16 @@ void LLPipeline::renderFinalize() mLastExposure.flush(); } - mExposureMap.bindTarget(); LLGLDepthTest depth(GL_FALSE, GL_FALSE); gExposureProgram.bind(); - S32 channel = 0; - channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); + S32 channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); if (channel > -1) { - screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); - } - - channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); - if (channel > -1) - { - mGlow[1].bindTexture(0, channel); + mLuminanceMap.bindTexture(0, channel, LLTexUnit::TFO_TRILINEAR); } channel = gExposureProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP); @@ -7366,11 +7406,17 @@ void LLPipeline::renderFinalize() mLastExposure.bindTexture(0, channel); } + static LLCachedControl<F32> dynamic_exposure_coefficient(gSavedSettings, "RenderDynamicExposureCoefficient", 0.175f); + static LLCachedControl<F32> dynamic_exposure_min(gSavedSettings, "RenderDynamicExposureMin", 0.125f); + static LLCachedControl<F32> dynamic_exposure_max(gSavedSettings, "RenderDynamicExposureMax", 1.3f); + static LLStaticHashedString dt("dt"); static LLStaticHashedString noiseVec("noiseVec"); + static LLStaticHashedString dynamic_exposure_params("dynamic_exposure_params"); gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); - + gExposureProgram.uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, dynamic_exposure_min, dynamic_exposure_max); + mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); @@ -7938,6 +7984,13 @@ void LLPipeline::renderDeferredLighting() llassert(!sRenderingHUDs); + F32 light_scale = 1.f; + + if (gCubeSnapshot) + { //darken local lights when probe ambiance is above 1 + light_scale = mReflectionMapManager.mLightScale; + } + LLRenderTarget *screen_target = &mRT->screen; LLRenderTarget* deferred_light_target = &mRT->deferredLight; @@ -8072,9 +8125,13 @@ void LLPipeline::renderDeferredLighting() LL_PROFILE_GPU_ZONE("atmospherics"); bindDeferredShader(soften_shader); + static LLCachedControl<F32> sky_scale(gSavedSettings, "RenderSkyHDRScale", 1.f); + static LLStaticHashedString sky_hdr_scale("sky_hdr_scale"); + LLEnvironment &environment = LLEnvironment::instance(); soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); soften_shader.uniform3fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + soften_shader.uniform1f(sky_hdr_scale, sky_scale); soften_shader.uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, LLDrawPoolAlpha::sWaterPlane.mV); @@ -8151,7 +8208,7 @@ void LLPipeline::renderDeferredLighting() F32 s = volume->getLightRadius() * 1.5f; // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor(); + LLColor3 col = volume->getLightLinearColor() * light_scale; if (col.magVecSquared() < 0.001f) { @@ -8246,7 +8303,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor(); + LLColor3 col = volume->getLightLinearColor() * light_scale; gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); @@ -8321,7 +8378,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor(); + LLColor3 col = volume->getLightLinearColor() * light_scale; gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, center.getF32ptr()); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index a57926337b96ca103b1828a785601ab0c5151aef..b4d5d352efa2066e4e9fb35b6511ef438eadd2f3 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -662,6 +662,7 @@ class LLPipeline LLRenderTarget mSceneMap; // exposure map for getting average color in scene + LLRenderTarget mLuminanceMap; LLRenderTarget mExposureMap; LLRenderTarget mLastExposure;