summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorCosmic Linden <cosmic@lindenlab.com>2024-09-26 17:23:06 -0700
committerCosmic Linden <cosmic@lindenlab.com>2024-09-26 17:23:06 -0700
commit6ebd6494a75d9b3d34e45655d79d0027fbba3898 (patch)
tree7a033a78230c8023c72f083814088acb1dbc69e2 /indra
parent3090e018eac74d87c01c672b602cbcf63ccf450a (diff)
secondlife/viewer#2638: Don't clear big render target if all pixels will be replaced
Diffstat (limited to 'indra')
-rw-r--r--indra/llrender/llrendertarget.cpp9
-rw-r--r--indra/llrender/llrendertarget.h9
-rw-r--r--indra/newview/app_settings/settings.xml11
-rw-r--r--indra/newview/pipeline.cpp25
4 files changed, 37 insertions, 17 deletions
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 38bc5ff331..c72f8fa2ba 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -51,6 +51,7 @@ void check_framebuffer_status()
}
bool LLRenderTarget::sUseFBO = false;
+bool LLRenderTarget::sClearOnInvalidate = false;
U32 LLRenderTarget::sCurFBO = 0;
@@ -473,6 +474,13 @@ void LLRenderTarget::clear(U32 mask_in)
}
}
+void LLRenderTarget::invalidate(U32 mask_in)
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
+ if (!sClearOnInvalidate) { return; }
+ clear(mask_in);
+}
+
U32 LLRenderTarget::getTexture(U32 attachment) const
{
if (attachment >= mTex.size())
@@ -584,7 +592,6 @@ void LLRenderTarget::swapFBORefs(LLRenderTarget& other)
llassert(!other.isBoundInStack());
// Must be same type
- llassert(sUseFBO == other.sUseFBO);
llassert(mResX == other.mResX);
llassert(mResY == other.mResY);
llassert(mInternalFormat == other.mInternalFormat);
diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h
index cd3290cf66..f066534cf4 100644
--- a/indra/llrender/llrendertarget.h
+++ b/indra/llrender/llrendertarget.h
@@ -63,6 +63,7 @@ class LLRenderTarget
public:
// Whether or not to use FBO implementation
static bool sUseFBO;
+ static bool sClearOnInvalidate;
static U32 sBytesAllocated;
static U32 sCurFBO;
static U32 sCurResX;
@@ -128,11 +129,17 @@ public:
// Asserts that this target is not currently bound in the stack
void bindTarget();
- //clear render targer, clears depth buffer if present,
+ //clear render target, clears depth buffer if present,
//uses scissor rect if in copy-to-texture mode
// asserts that this target is currently bound
void clear(U32 mask = 0xFFFFFFFF);
+ //same as clear, except may be a no-op depending on configuration
+ //useful to indicate the buffer is about to be overwritten and we
+ //don't care about its previous contents
+ //depending on the GPU, one may be more expensive than the other
+ void invalidate(U32 mask = 0xFFFFFFFF);
+
//get applied viewport
void getViewport(S32* viewport);
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 82eb98b06b..2cbb493b91 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7330,6 +7330,17 @@
<key>Value</key>
<integer>-1</integer>
</map>
+ <key>RenderBufferClearOnInvalidate</key>
+ <map>
+ <key>Comment</key>
+ <string>Whether to call glClear on render buffers that will be fully overwritten with new contents</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>0</integer>
+ </map>
<key>RenderCompressTextures</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index fe02742aac..19868d2eef 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -576,6 +576,7 @@ void LLPipeline::init()
connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionAdaptiveStepMultiplier");
connectRefreshCachedSettingsSafe("RenderScreenSpaceReflectionGlossySamples");
connectRefreshCachedSettingsSafe("RenderBufferVisualization");
+ connectRefreshCachedSettingsSafe("RenderBufferClearOnInvalidate");
connectRefreshCachedSettingsSafe("RenderMirrors");
connectRefreshCachedSettingsSafe("RenderHeroProbeUpdateRate");
connectRefreshCachedSettingsSafe("RenderHeroProbeConservativeUpdateMultiplier");
@@ -1084,6 +1085,7 @@ void LLPipeline::refreshCachedSettings()
RenderScreenSpaceReflectionAdaptiveStepMultiplier = gSavedSettings.getF32("RenderScreenSpaceReflectionAdaptiveStepMultiplier");
RenderScreenSpaceReflectionGlossySamples = gSavedSettings.getS32("RenderScreenSpaceReflectionGlossySamples");
RenderBufferVisualization = gSavedSettings.getS32("RenderBufferVisualization");
+ LLRenderTarget::sClearOnInvalidate = gSavedSettings.getBOOL("RenderBufferClearOnInvalidate");
RenderMirrors = gSavedSettings.getBOOL("RenderMirrors");
RenderHeroProbeUpdateRate = gSavedSettings.getS32("RenderHeroProbeUpdateRate");
RenderHeroProbeConservativeUpdateMultiplier = gSavedSettings.getS32("RenderHeroProbeConservativeUpdateMultiplier");
@@ -7147,7 +7149,7 @@ void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget*
LLRenderTarget& depth_src = mRT->deferredScreen;
dst->bindTarget();
- dst->clear();
+ dst->invalidate();
gCopyDepthProgram.bind();
S32 diff_map = gCopyDepthProgram.getTextureChannel(LLShaderMgr::DIFFUSE_MAP);
@@ -7334,7 +7336,7 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst)
// bake out texture2D with RGBL for FXAA shader
mFXAAMap.bindTarget();
- mFXAAMap.clear(GL_COLOR_BUFFER_BIT);
+ mFXAAMap.invalidate(GL_COLOR_BUFFER_BIT);
shader = &gGlowCombineFXAAProgram;
shader->bind();
@@ -7433,7 +7435,7 @@ void LLPipeline::generateSMAABuffers(LLRenderTarget* src)
LLGLSLShader& edge_shader = gSMAAEdgeDetectProgram[fsaa_quality];
dest.bindTarget();
- dest.clear(GL_COLOR_BUFFER_BIT);
+ dest.invalidate(GL_COLOR_BUFFER_BIT);
edge_shader.bind();
edge_shader.uniform4fv(sSmaaRTMetrics, 1, rt_metrics);
@@ -7476,7 +7478,7 @@ void LLPipeline::generateSMAABuffers(LLRenderTarget* src)
LLGLSLShader& blend_weights_shader = gSMAABlendWeightsProgram[fsaa_quality];
dest.bindTarget();
- dest.clear(GL_COLOR_BUFFER_BIT);
+ dest.invalidate(GL_COLOR_BUFFER_BIT);
blend_weights_shader.bind();
blend_weights_shader.uniform4fv(sSmaaRTMetrics, 1, rt_metrics);
@@ -7552,7 +7554,7 @@ void LLPipeline::applySMAA(LLRenderTarget* src, LLRenderTarget* dst)
LLGLSLShader& blend_shader = gSMAANeighborhoodBlendProgram[fsaa_quality];
bound_target->bindTarget();
- bound_target->clear(GL_COLOR_BUFFER_BIT);
+ bound_target->invalidate(GL_COLOR_BUFFER_BIT);
blend_shader.bind();
blend_shader.uniform4fv(sSmaaRTMetrics, 1, rt_metrics);
@@ -8330,9 +8332,7 @@ void LLPipeline::renderDeferredLighting()
LLGLSLShader& sun_shader = gCubeSnapshot ? gDeferredSunProbeProgram : gDeferredSunProgram;
bindDeferredShader(sun_shader, deferred_light_target);
mScreenTriangleVB->setBuffer();
- glClearColor(1, 1, 1, 1);
- deferred_light_target->clear(GL_COLOR_BUFFER_BIT);
- glClearColor(0, 0, 0, 0);
+ deferred_light_target->invalidate(GL_COLOR_BUFFER_BIT);
sun_shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES,
(GLfloat)deferred_light_target->getWidth(),
@@ -8356,9 +8356,7 @@ void LLPipeline::renderDeferredLighting()
LL_PROFILE_GPU_ZONE("soften shadow");
// blur lightmap
screen_target->bindTarget();
- glClearColor(1, 1, 1, 1);
- screen_target->clear(GL_COLOR_BUFFER_BIT);
- glClearColor(0, 0, 0, 0);
+ screen_target->invalidate(GL_COLOR_BUFFER_BIT);
bindDeferredShader(gDeferredBlurLightProgram);
@@ -8410,11 +8408,8 @@ void LLPipeline::renderDeferredLighting()
deferred_light_target->flush();
unbindDeferredShader(gDeferredBlurLightProgram);
}
-
screen_target->bindTarget();
- // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky
- glClearColor(0, 0, 0, 0);
- screen_target->clear(GL_COLOR_BUFFER_BIT);
+ screen_target->invalidate(GL_COLOR_BUFFER_BIT);
if (RenderDeferredAtmospheric)
{ // apply sunlight contribution