Cleanup of Windlight lock-in (= force enabling + prevent disabling)

master
Kitty Barnett 2021-03-13 20:41:01 +01:00
parent d846c3642d
commit e9772fc7e2
5 changed files with 58 additions and 40 deletions

View File

@ -76,6 +76,7 @@
#include "llslurl.h"
#include "llstartup.h"
// [RLVa:KB] - Checked: 2015-12-27 (RLVa-1.5.0)
#include "llvisualeffect.h"
#include "rlvactions.h"
#include "rlvcommon.h"
// [/RLVa:KB]
@ -143,15 +144,15 @@ static bool handleAvatarHoverOffsetChanged(const LLSD& newvalue)
static bool handleSetShaderChanged(const LLSD& newvalue)
{
// [RLVa:KB] - @setenv
if ( (!RlvActions::canChangeEnvironment()) && (LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")) && (!gSavedSettings.getBOOL("WindLightUseAtmosShaders")) )
// [RLVa:KB] - @setenv and @setsphere
if ( (RlvActions::isRlvEnabled()) && (!RlvActions::canChangeEnvironment() || (LLVfxManager::instance().hasEffect(EVisualEffect::RlvSphere))) &&
(LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))&& (!gSavedSettings.getBOOL("WindLightUseAtmosShaders")) )
{
gSavedSettings.setBOOL("WindLightUseAtmosShaders", TRUE);
return true;
}
// [/RLVa:KB]
// changing shader level may invalidate existing cached bump maps, as the shader type determines the format of the bump map it expects - clear and repopulate the bump cache
gBumpImageList.destroyGL();
gBumpImageList.restoreGL();
@ -429,21 +430,9 @@ static bool handleRenderLocalLightsChanged(const LLSD& newvalue)
return true;
}
// [RLVa:KB] - @setsphere
static bool handleWindLightAtmosShadersChanged(const LLSD& newvalue)
{
LLRenderTarget::sUseFBO = newvalue.asBoolean() && LLPipeline::sUseDepthTexture;
handleSetShaderChanged(LLSD());
return true;
}
// [/RLVa:KB]
static bool handleRenderDeferredChanged(const LLSD& newvalue)
{
// LLRenderTarget::sUseFBO = newvalue.asBoolean();
// [RLVa:KB] - @setsphere
LLRenderTarget::sUseFBO = newvalue.asBoolean() || (gSavedSettings.getBOOL("WindLightUseAtmosShaders") && LLPipeline::sUseDepthTexture);
// [/RLVa:KB]
LLRenderTarget::sUseFBO = newvalue.asBoolean();
if (gPipeline.isInit())
{
LLPipeline::refreshCachedSettings();
@ -465,10 +454,7 @@ static bool handleRenderDeferredChanged(const LLSD& newvalue)
//
static bool handleRenderBumpChanged(const LLSD& newval)
{
// LLRenderTarget::sUseFBO = newval.asBoolean();
// [RLVa:KB] - @setsphere
LLRenderTarget::sUseFBO = newval.asBoolean() || (gSavedSettings.getBOOL("WindLightUseAtmosShaders") && LLPipeline::sUseDepthTexture);
// [/RLVa:KB]
LLRenderTarget::sUseFBO = newval.asBoolean();
if (gPipeline.isInit())
{
gPipeline.updateRenderBump();
@ -672,10 +658,7 @@ void settings_setup_listeners()
gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
gSavedSettings.getControl("RenderGlowResolutionPow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
gSavedSettings.getControl("RenderAvatarCloth")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
// gSavedSettings.getControl("WindLightUseAtmosShaders")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
// [RLVa:KB] - @setsphere
gSavedSettings.getControl("WindLightUseAtmosShaders")->getSignal()->connect(boost::bind(&handleWindLightAtmosShadersChanged, _2));
// [/RLVa:KB]
gSavedSettings.getControl("WindLightUseAtmosShaders")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
gSavedSettings.getControl("RenderGammaFull")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
gSavedSettings.getControl("RenderVolumeLODFactor")->getSignal()->connect(boost::bind(&handleVolumeLODChanged, _2));
gSavedSettings.getControl("RenderAvatarLODFactor")->getSignal()->connect(boost::bind(&handleAvatarLODChanged, _2));

View File

@ -1118,6 +1118,13 @@ void LLPipeline::updateRenderDeferred()
RenderAvatarVP &&
WindLightUseAtmosShaders &&
(bool) LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred");
// [RLVa:KB] - @setsphere
if (!sRenderDeferred && RlvActions::hasBehaviour(RLV_BHVR_SETSPHERE) && WindLightUseAtmosShaders)
{
LLRenderTarget::sUseFBO = true;
LLPipeline::sUseDepthTexture = true;
}
// [/RLVa:KB]
}
// static
@ -4497,7 +4504,7 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate)
gGL.loadMatrix(gGLModelView);
LLGLSLShader::bindNoShader();
// [RLVa:KB] - @setsphere
if (LLPipeline::RenderDeferred || !LLRenderTarget::sUseFBO || !LLPipeline::sUseDepthTexture)
if (LLPipeline::sRenderDeferred || !LLRenderTarget::sUseFBO || !LLPipeline::sUseDepthTexture)
{
doOcclusion(camera);
}

View File

@ -2071,22 +2071,28 @@ ERlvCmdRet RlvBehaviourHandler<RLV_BHVR_SETSPHERE>::onCommand(const RlvCommand&
ERlvCmdRet eRet = RlvBehaviourGenericHandler<RLV_OPTION_NONE_OR_MODIFIER>::onCommand(rlvCmd, fRefCount);
if ( (RLV_RET_SUCCESS == eRet) && (!rlvCmd.isModifier()) )
{
// If we're not using deferred but are using Windlight shaders we need to force use of FBO and depthmap texture
if ( (!LLPipeline::RenderDeferred) && (LLPipeline::WindLightUseAtmosShaders) && (!LLPipeline::sUseDepthTexture) )
{
LLRenderTarget::sUseFBO = true;
LLPipeline::sUseDepthTexture = true;
gPipeline.releaseGLBuffers();
gPipeline.createGLBuffers();
gPipeline.resetVertexBuffers();
LLViewerShaderMgr::instance()->setShaders();
}
if (gRlvHandler.hasBehaviour(rlvCmd.getObjectID(), rlvCmd.getBehaviourType()))
{
Rlv::forceAtmosphericShadersIfAvailable();
// If we're not using deferred but are using Windlight shaders we need to force use of FBO and depthmap texture
if ( (!LLPipeline::sRenderDeferred) && (LLPipeline::WindLightUseAtmosShaders) && (!LLPipeline::sUseDepthTexture) )
{
LLRenderTarget::sUseFBO = true;
LLPipeline::sUseDepthTexture = true;
gPipeline.releaseGLBuffers();
gPipeline.createGLBuffers();
gPipeline.resetVertexBuffers();
LLViewerShaderMgr::instance()->setShaders();
}
LLVfxManager::instance().addEffect(new RlvSphereEffect(rlvCmd.getObjectID()));
}
else
{
LLVfxManager::instance().removeEffect(gRlvHandler.getCurrentObject());
}
}
return eRet;
}
@ -2402,11 +2408,10 @@ void RlvBehaviourToggleHandler<RLV_BHVR_SETENV>::onCommandToggle(ERlvBehaviour e
}
}
// Don't allow toggling "Atmopsheric Shaders" through the debug settings under @setenv=n
gSavedSettings.getControl("WindLightUseAtmosShaders")->setHiddenFromSettingsEditor(fHasBhvr);
if (fHasBhvr)
{
Rlv::forceAtmosphericShadersIfAvailable();
// Usurp the 'edit' environment for RLVa locking so TPV tools like quick prefs and phototools are automatically locked out as well
// (these needed per-feature awareness of RLV in the previous implementation which often wasn't implemented)
LLEnvironment* pEnv = LLEnvironment::getInstance();

View File

@ -17,9 +17,11 @@
#include "llviewerprecompiledheaders.h"
#include "llappearancemgr.h"
#include "llattachmentsmgr.h"
#include "llfeaturemanager.h"
#include "llgesturemgr.h"
#include "llnotificationsutil.h"
#include "llviewerobjectlist.h"
#include "pipeline.h"
#include "rlvcommon.h"
#include "rlveffects.h"
@ -2038,3 +2040,19 @@ std::string rlvGetLastParenthesisedText(const std::string& strText, std::string:
}
// =========================================================================
// Various helper functions
//
namespace Rlv
{
void forceAtmosphericShadersIfAvailable()
{
if ( (LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders")) && (!LLPipeline::WindLightUseAtmosShaders) )
{
// Triggers handleSetShaderChanged() which will do the actual work for us
gSavedSettings.setBOOL("WindLightUseAtmosShaders", TRUE);
}
}
}
// =========================================================================

View File

@ -692,6 +692,11 @@ ERlvAttachGroupType rlvAttachGroupFromString(const std::string& strGroup);
std::string rlvGetFirstParenthesisedText(const std::string& strText, std::string::size_type* pidxMatch = NULL);
std::string rlvGetLastParenthesisedText(const std::string& strText, std::string::size_type* pidxStart = NULL);
namespace Rlv
{
void forceAtmosphericShadersIfAvailable();
}
// ============================================================================
// Inlined class member functions
//