diff options
author | William Weaver <paperwork.resident@gmail.com> | 2025-03-12 19:52:56 +0300 |
---|---|---|
committer | William Weaver <paperwork.resident@gmail.com> | 2025-03-12 19:52:56 +0300 |
commit | 76db64e0c8c7dd40ce2a85ef19183c3c245f1dc8 (patch) | |
tree | c73ce383b783be191407df33eca8bc59996cc577 /indra | |
parent | 942527ddf39925e3e77d5c4e30a0fdc245156ada (diff) |
Fixes: Add guard to prevent shadow texture resize with invalid mRT dimensions after shader changes; **Replaces forced shader refresh with lightweight guard**
This commit introduces a guard in `LLPipeline::resizeShadowTexture()` to prevent shadow texture resizing when the shadow render target (mRT) has invalid (zero) dimensions. **This replaces a previous, less efficient approach of forcing a full shader recompile whenever `RenderShadowResolutionScale` was changed in-session.**
**Background and Problem:**
Previously, the code forced a full shader recompile whenever `RenderShadowResolutionScale` changed in-session (after toggling advanced graphics settings like SSAO or HDR). While this “sledgehammer” approach did fix broken shadow rendering, it unnecessarily thrashed the shader cache and reset many pipeline states.
**Solution:**
This commit removes the forced shader recompile in favor of a guard check in `LLPipeline::resizeShadowTexture()`. The guard ensures mRT (the shadow render target) has non-zero dimensions before resizing. If mRT is zero for that frame, the resize operation is skipped, and a warning is logged. Once mRT becomes valid (usually in the next frame), the shadow texture is resized successfully without requiring a full shader refresh.
**Detailed changes:**
- Reverted the binding of `RenderShadowResolutionScale` to `handleSetShaderChanged`.
- Restored the original `handleShadowsResized` listener for `RenderShadowResolutionScale` in `llviewercontrol.cpp`.
- Added guard checks in `LLPipeline::resizeShadowTexture()` to skip resizing when `mRT->width` or `mRT->height` is zero.
- Added logging statements to track how many frames are skipped.
**Benefits:**
- Prevents shader thrashing while still avoiding shadow corruption.
- Shadows now update correctly as soon as mRT dimensions are valid.
- Maintains a detailed record of frames skipped.
- **Lightweight and targeted interim solution, much less disruptive than a full shader recompile.**
Testing:
1. Reproduce the bug as described in the bug report (toggle SSAO, then change RenderShadowResolutionScale).
2. Verify that shadows are no longer broken after these steps.
3. Check the logs for the warning message indicating skipped frames when the bug is triggered.
4. Confirm that under normal operation (without shader changes causing mRT issues), shadow resizing works as expected without excessive warnings.
Documentation:
No user-facing documentation changes are needed for this interim fix. However, internal developer documentation should note this guard and the ongoing investigation into the root cause.
Further Development:
This guard is a temporary fix. The root cause of why mRT becomes invalid after shader changes needs to be investigated and resolved. See the bug report for detailed next steps for investigation.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llviewercontrol.cpp | 4 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 25 |
2 files changed, 25 insertions, 4 deletions
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 1f5ac61040..598ad89907 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -809,9 +809,7 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "RenderSpecularResY", handleLUTBufferChanged); setting_setup_signal_listener(gSavedSettings, "RenderSpecularExponent", handleLUTBufferChanged); setting_setup_signal_listener(gSavedSettings, "RenderAnisotropic", handleAnisotropicChanged); - // Ensure shader update on shadow resolution scale change for correct shadow rendering. - // setting_setup_signal_listener(gSavedSettings, "RenderShadowResolutionScale", handleShadowsResized); // Original line commented out - setting_setup_signal_listener(gSavedSettings, "RenderShadowResolutionScale", handleSetShaderChanged); + setting_setup_signal_listener(gSavedSettings, "RenderShadowResolutionScale", handleShadowsResized); setting_setup_signal_listener(gSavedSettings, "RenderGlow", handleReleaseGLBufferChanged); setting_setup_signal_listener(gSavedSettings, "RenderGlow", handleSetShaderChanged); setting_setup_signal_listener(gSavedSettings, "RenderGlowResolutionPow", handleReleaseGLBufferChanged); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 18dd694246..691d155a3c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -121,7 +121,7 @@ #include "SMAAAreaTex.h" #include "SMAASearchTex.h" - +#include "llerror.h" #ifndef LL_WINDOWS #define A_GCC 1 #pragma GCC diagnostic ignored "-Wunused-function" @@ -727,6 +727,29 @@ void LLPipeline::requestResizeShadowTexture() void LLPipeline::resizeShadowTexture() { + // A static counter to keep track of skipped frames + static int sSkippedFrameCount = 0; + + if (!mRT || mRT->width == 0 || mRT->height == 0) + { + sSkippedFrameCount++; + LL_WARNS("Render") << "Shadow texture resizing aborted: render target dimensions invalid. Skipped " + << sSkippedFrameCount << " frame(s) so far." << LL_ENDL; + return; + } + + // If there were skipped frames before mRT became valid, log that information. + if (sSkippedFrameCount > 0) + { + LL_INFOS("Render") << "Render target now valid after " + << sSkippedFrameCount << " skipped frame(s)." << LL_ENDL; + sSkippedFrameCount = 0; + } + + LL_WARNS() << "LLPipeline::resizeShadowTexture() called." << LL_ENDL; + LL_INFOS() << "Resizing shadow texture. mRT->width = " + << mRT->width << " mRT->height = " << mRT->height << LL_ENDL; + releaseSunShadowTargets(); releaseSpotShadowTargets(); allocateShadowBuffer(mRT->width, mRT->height); |