Newer
Older
/**
* @file pipeline.cpp
* @brief Rendering pipeline.
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Copyright (C) 2010, 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
*/
#include "llviewerprecompiledheaders.h"
#include "pipeline.h"
// library includes
#include "llaudioengine.h" // For debugging.
#include "llerror.h"
#include "llviewercontrol.h"
#include "llfasttimer.h"
#include "llfontgl.h"
#include "llnamevalue.h"
#include "llpointer.h"
#include "llprimitive.h"
#include "llvolume.h"
#include "material_codes.h"
#include "v3color.h"
Josh Bell
committed
#include "llui.h"
#include "llglheaders.h"
#include "llrender.h"
#include "llwindow.h" // swapBuffers()
#include "llagentcamera.h"
David Parks
committed
#include "llappviewer.h"
#include "lltexturecache.h"
#include "lltexturefetch.h"
#include "llimageworker.h"
#include "lldrawable.h"
#include "lldrawpoolalpha.h"
#include "lldrawpoolavatar.h"
#include "lldrawpoolground.h"
#include "lldrawpoolbump.h"
#include "lldrawpooltree.h"
#include "lldrawpoolwater.h"
#include "llface.h"
#include "llfeaturemanager.h"
#include "llfloatertelehub.h"
#include "llhudtext.h"
#include "llpipelinelistener.h"
#include "llresmgr.h"
#include "llselectmgr.h"
#include "llsky.h"
#include "lltracker.h"
#include "lltool.h"
#include "lltoolmgr.h"
#include "llviewercamera.h"
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
#include "llviewerparcelmgr.h"
#include "llviewerregion.h" // for audio debugging.
#include "llviewerwindow.h" // For getSpinAxis
#include "llvoavatarself.h"
#include "llvocache.h"
#include "llvoground.h"
#include "llvosky.h"
#include "llvotree.h"
#include "llvovolume.h"
#include "llvosurfacepatch.h"
#include "llvowater.h"
#include "llvotree.h"
#include "llvopartgroup.h"
#include "llcubemap.h"
#include "llviewerstats.h"
Josh Bell
committed
#include "llviewerjoystick.h"
Steven Bennetts
committed
#include "llviewerdisplay.h"
#include "llwlparammanager.h"
#include "llwaterparammanager.h"
#include "llspatialpartition.h"
#include "llmutelist.h"
#include "llpathinglib.h"
#include "llfloatertools.h"
#include "llpanelface.h"
#include "llscenemonitor.h"
Xiaohong Bao
committed
#include "llprogressview.h"
// [RLVa:KB] - Checked: RLVa-2.0.0
#include "rlvactions.h"
#include "rlvlocks.h"
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>
#include <glm/gtc/matrix_inverse.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#ifdef _DEBUG
// Debug indices is disabled for now for debug performance - djs 4/24/02
//#define DEBUG_INDICES
#else
//#define DEBUG_INDICES
#endif
bool gShiftFrame = false;
//cached settings
bool LLPipeline::RenderAvatarVP;
bool LLPipeline::VertexShaderEnable;
bool LLPipeline::WindLightUseAtmosShaders;
bool LLPipeline::RenderDeferred;
F32 LLPipeline::RenderDeferredSunWash;
U32 LLPipeline::RenderFSAASamples;
U32 LLPipeline::RenderResolutionDivisor;
Kitty Barnett
committed
// [SL:KB] - Patch: Settings-RenderResolutionMultiplier | Checked: Catznip-5.4
F32 LLPipeline::RenderResolutionMultiplier;
// [/SL:KB]
bool LLPipeline::RenderUIBuffer;
S32 LLPipeline::RenderShadowDetail;
bool LLPipeline::RenderDeferredSSAO;
F32 LLPipeline::RenderDeferredSSAOResolutionScale;
F32 LLPipeline::RenderShadowResolutionScale;
bool LLPipeline::RenderLocalLights;
bool LLPipeline::RenderDelayCreation;
bool LLPipeline::RenderAnimateRes;
bool LLPipeline::FreezeTime;
S32 LLPipeline::DebugBeaconLineWidth;
F32 LLPipeline::RenderHighlightBrightness;
LLColor4 LLPipeline::RenderHighlightColor;
F32 LLPipeline::RenderHighlightThickness;
bool LLPipeline::RenderSpotLightsInNondeferred;
LLColor4 LLPipeline::PreviewAmbientColor;
LLColor4 LLPipeline::PreviewDiffuse0;
LLColor4 LLPipeline::PreviewSpecular0;
LLColor4 LLPipeline::PreviewDiffuse1;
LLColor4 LLPipeline::PreviewSpecular1;
LLColor4 LLPipeline::PreviewDiffuse2;
LLColor4 LLPipeline::PreviewSpecular2;
LLVector3 LLPipeline::PreviewDirection0;
LLVector3 LLPipeline::PreviewDirection1;
LLVector3 LLPipeline::PreviewDirection2;
F32 LLPipeline::RenderGlowMinLuminance;
F32 LLPipeline::RenderGlowMaxExtractAlpha;
F32 LLPipeline::RenderGlowWarmthAmount;
LLVector3 LLPipeline::RenderGlowLumWeights;
LLVector3 LLPipeline::RenderGlowWarmthWeights;
S32 LLPipeline::RenderGlowResolutionPow;
S32 LLPipeline::RenderGlowIterations;
F32 LLPipeline::RenderGlowWidth;
F32 LLPipeline::RenderGlowStrength;
bool LLPipeline::RenderDepthOfField;
bool LLPipeline::RenderDepthOfFieldInEditMode;
F32 LLPipeline::CameraFocusTransitionTime;
F32 LLPipeline::CameraFNumber;
F32 LLPipeline::CameraFocalLength;
F32 LLPipeline::CameraFieldOfView;
F32 LLPipeline::RenderShadowNoise;
F32 LLPipeline::RenderShadowBlurSize;
F32 LLPipeline::RenderSSAOScale;
U32 LLPipeline::RenderSSAOMaxScale;
F32 LLPipeline::RenderSSAOFactor;
LLVector3 LLPipeline::RenderSSAOEffect;
F32 LLPipeline::RenderShadowOffsetError;
F32 LLPipeline::RenderShadowBiasError;
F32 LLPipeline::RenderShadowOffset;
F32 LLPipeline::RenderShadowBias;
F32 LLPipeline::RenderSpotShadowOffset;
F32 LLPipeline::RenderSpotShadowBias;
F32 LLPipeline::RenderEdgeDepthCutoff;
F32 LLPipeline::RenderEdgeNormCutoff;
LLVector3 LLPipeline::RenderShadowGaussian;
F32 LLPipeline::RenderShadowBlurDistFactor;
bool LLPipeline::RenderDeferredAtmospheric;
S32 LLPipeline::RenderReflectionDetail;
F32 LLPipeline::RenderHighlightFadeTime;
LLVector3 LLPipeline::RenderShadowClipPlanes;
LLVector3 LLPipeline::RenderShadowOrthoClipPlanes;
LLVector3 LLPipeline::RenderShadowNearDist;
F32 LLPipeline::RenderFarClip;
LLVector3 LLPipeline::RenderShadowSplitExponent;
F32 LLPipeline::RenderShadowErrorCutoff;
F32 LLPipeline::RenderShadowFOVCutoff;
F32 LLPipeline::CameraDoFResScale;
F32 LLPipeline::RenderAutoHideSurfaceAreaLimit;
BOOL LLPipeline::RenderAggressiveBatching;
BOOL LLPipeline::RenderDeferredFullbright;
LLTrace::EventStatHandle<S64> LLPipeline::sStatBatchSize("renderbatchsize");
const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
const F32 BACKLIGHT_NIGHT_MAGNITUDE_OBJECT = 0.08f;
Drake Arconis
committed
const U32 NOISE_MAP_RES = 256;
const U32 AUX_VB_MASK = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1;
Steven Bennetts
committed
LLPipeline gPipeline;
Steven Bennetts
committed
LLTrace::BlockTimerStatHandle FTM_RENDER_GEOMETRY("Render Geometry");
LLTrace::BlockTimerStatHandle FTM_RENDER_GRASS("Grass");
LLTrace::BlockTimerStatHandle FTM_RENDER_INVISIBLE("Invisible");
LLTrace::BlockTimerStatHandle FTM_RENDER_OCCLUSION("Occlusion");
LLTrace::BlockTimerStatHandle FTM_RENDER_SHINY("Shiny");
LLTrace::BlockTimerStatHandle FTM_RENDER_SIMPLE("Simple");
LLTrace::BlockTimerStatHandle FTM_RENDER_TERRAIN("Terrain");
LLTrace::BlockTimerStatHandle FTM_RENDER_TREES("Trees");
LLTrace::BlockTimerStatHandle FTM_RENDER_UI("UI");
LLTrace::BlockTimerStatHandle FTM_RENDER_WATER("Water");
LLTrace::BlockTimerStatHandle FTM_RENDER_WL_SKY("Windlight Sky");
LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA("Alpha Objects");
LLTrace::BlockTimerStatHandle FTM_RENDER_CHARACTERS("Avatars");
LLTrace::BlockTimerStatHandle FTM_RENDER_BUMP("Bump");
LLTrace::BlockTimerStatHandle FTM_RENDER_MATERIALS("Render Materials");
LLTrace::BlockTimerStatHandle FTM_RENDER_FULLBRIGHT("Fullbright");
LLTrace::BlockTimerStatHandle FTM_RENDER_GLOW("Glow");
LLTrace::BlockTimerStatHandle FTM_GEO_UPDATE("Geo Update");
LLTrace::BlockTimerStatHandle FTM_PIPELINE_CREATE("Pipeline Create");
LLTrace::BlockTimerStatHandle FTM_POOLRENDER("RenderPool");
LLTrace::BlockTimerStatHandle FTM_POOLS("Pools");
LLTrace::BlockTimerStatHandle FTM_DEFERRED_POOLRENDER("RenderPool (Deferred)");
LLTrace::BlockTimerStatHandle FTM_DEFERRED_POOLS("Pools (Deferred)");
LLTrace::BlockTimerStatHandle FTM_POST_DEFERRED_POOLRENDER("RenderPool (Post)");
LLTrace::BlockTimerStatHandle FTM_POST_DEFERRED_POOLS("Pools (Post)");
LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM_FBO("First FBO");
LLTrace::BlockTimerStatHandle FTM_STATESORT("Sort Draw State");
LLTrace::BlockTimerStatHandle FTM_PIPELINE("Pipeline");
LLTrace::BlockTimerStatHandle FTM_CLIENT_COPY("Client Copy");
LLTrace::BlockTimerStatHandle FTM_RENDER_DEFERRED("Deferred Shading");
static LLTrace::BlockTimerStatHandle FTM_STATESORT_DRAWABLE("Sort Drawables");
static LLTrace::BlockTimerStatHandle FTM_STATESORT_POSTSORT("Post Sort");
Drake Arconis
committed
Graham Madarasz (Graham)
committed
static LLStaticHashedString sDelta("delta");
static LLStaticHashedString sDistFactor("dist_factor");
static LLStaticHashedString sScreenRes("framebuffer_res");
std::string gPoolNames[] =
{
// Correspond to LLDrawpool enum render type
"NONE",
"POOL_SIMPLE",
"POOL_BUMP",
"POOL_MATERIALS",
"POOL_SKY",
"POOL_WL_SKY",
David Parks
committed
"POOL_ALPHA_MASK",
"POOL_FULLBRIGHT_ALPHA_MASK",
"POOL_WATER",
"POOL_GLOW",
void drawBox(const LLVector4a& c, const LLVector4a& r);
void drawBoxOutline(const LLVector3& pos, const LLVector3& size);
U32 nhpo2(U32 v);
David Parks
committed
LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage);
{
}
{
}
{
}
{
}
{
}
{
}
void display_update_camera();
//----------------------------------------
S32 LLPipeline::sCompiles = 0;
bool LLPipeline::sPickAvatar = true;
bool LLPipeline::sDynamicLOD = true;
bool LLPipeline::sShowHUDAttachments = true;
bool LLPipeline::sRenderMOAPBeacons = false;
bool LLPipeline::sRenderPhysicalBeacons = true;
bool LLPipeline::sRenderScriptedBeacons = false;
bool LLPipeline::sRenderScriptedTouchBeacons = true;
bool LLPipeline::sRenderParticleBeacons = false;
bool LLPipeline::sRenderSoundBeacons = false;
bool LLPipeline::sRenderBeacons = false;
bool LLPipeline::sRenderHighlight = true;
LLRender::eTexIndex LLPipeline::sRenderHighlightTextureChannel = LLRender::DIFFUSE_MAP;
bool LLPipeline::sForceOldBakedUpload = false;
S32 LLPipeline::sUseOcclusion = 0;
bool LLPipeline::sDelayVBUpdate = true;
bool LLPipeline::sAutoMaskAlphaDeferred = true;
bool LLPipeline::sAutoMaskAlphaNonDeferred = false;
bool LLPipeline::sDisableShaders = false;
bool LLPipeline::sRenderBump = true;
bool LLPipeline::sNoAlpha = false;
bool LLPipeline::sUseTriStrips = true;
bool LLPipeline::sUseFarClip = true;
bool LLPipeline::sShadowRender = false;
bool LLPipeline::sWaterReflections = false;
bool LLPipeline::sRenderGlow = false;
bool LLPipeline::sReflectionRender = false;
bool LLPipeline::sImpostorRender = false;
bool LLPipeline::sImpostorRenderAlphaDepthPass = false;
bool LLPipeline::sUnderWaterRender = false;
bool LLPipeline::sTextureBindTest = false;
bool LLPipeline::sRenderFrameTest = false;
bool LLPipeline::sRenderAttachedLights = true;
bool LLPipeline::sRenderAttachedParticles = true;
bool LLPipeline::sRenderDeferred = false;
bool LLPipeline::sMemAllocationThrottled = false;
S32 LLPipeline::sVisibleLightCount = 0;
F32 LLPipeline::sMinRenderSize = 0.f;
// [SL:KB] - Patch: Render-TextureToggle (Catznip-4.0)
bool LLPipeline::sRenderTextures = true;
// [/SL:KB]
// EventHost API LLPipeline listener.
static LLPipelineListener sPipelineListener;
void validate_framebuffer_object();
bool addDeferredAttachments(LLRenderTarget& target)

Rye Mutt
committed
return target.addColorAttachment(GL_SRGB8_ALPHA8
, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV) && //specular
target.addColorAttachment(GL_RGBA12, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV); //normal+z
}
mMatrixOpCount(0),
mTextureMatrixOps(0),
mNumVisibleNodes(0),
mNumVisibleFaces(0),
mInitialized(false),
mVertexShadersEnabled(false),
mRenderDebugFeatureMask(0),
mRenderDebugMask(0),
mOldRenderDebugMask(0),
David Parks
committed
mMeshDirtyQueryObject(0),
David Parks
committed
mResetVertexBuffers(false),
mLastRebuildPool(nullptr),
mAlphaPool(nullptr),
mSkyPool(nullptr),
mTerrainPool(nullptr),
mWaterPool(nullptr),
mGroundPool(nullptr),
mSimplePool(nullptr),
mGrassPool(nullptr),
mAlphaMaskPool(nullptr),
mFullbrightAlphaMaskPool(nullptr),
mFullbrightPool(nullptr),
mGlowPool(nullptr),
mBumpPool(nullptr),
mMaterialsPool(nullptr),
mWLSkyPool(nullptr),
mLightMovingMask(0),
mNoiseMap = 0;
void LLPipeline::connectRefreshCachedSettingsSafe(const std::string& name)
{
LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(name);
if ( cntrl_ptr.isNull() )
{
LL_WARNS() << "Global setting name not found:" << name << LL_ENDL;
}
else
{
cntrl_ptr->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings));
}
}
refreshCachedSettings();
David Parks
committed
gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity");
gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize");
sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");
sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips");
LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO");
LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO");
LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw");
sRenderAttachedLights = gSavedSettings.getBOOL("RenderAttachedLights");
sRenderAttachedParticles = gSavedSettings.getBOOL("RenderAttachedParticles");
//create render pass pools
getPool(LLDrawPool::POOL_ALPHA);
getPool(LLDrawPool::POOL_SIMPLE);
David Parks
committed
getPool(LLDrawPool::POOL_ALPHA_MASK);
getPool(LLDrawPool::POOL_FULLBRIGHT_ALPHA_MASK);
getPool(LLDrawPool::POOL_GRASS);
getPool(LLDrawPool::POOL_FULLBRIGHT);
getPool(LLDrawPool::POOL_BUMP);
getPool(LLDrawPool::POOL_MATERIALS);
Josh Bell
committed
getPool(LLDrawPool::POOL_GLOW);
if (gSavedSettings.getBOOL("DisableAllRenderFeatures"))
clearAllRenderDebugFeatures();
else
{
setAllRenderDebugFeatures(); // By default, all debugging features on
clearAllRenderDebugDisplays(); // All debug displays off
if (gSavedSettings.getBOOL("DisableAllRenderTypes"))
clearAllRenderTypes();
}
else
setAllRenderTypes(); // By default, all rendering types start enabled
// Don't turn on ground when this is set
// Mac Books with intel 950s need this
if(!gSavedSettings.getBOOL("RenderGround"))
{
toggleRenderType(RENDER_TYPE_GROUND);
}
// make sure RenderPerformanceTest persists (hackity hack hack)
// disables non-object rendering (UI, sky, water, etc)
if (gSavedSettings.getBOOL("RenderPerformanceTest"))
{
gSavedSettings.setBOOL("RenderPerformanceTest", FALSE);
gSavedSettings.setBOOL("RenderPerformanceTest", TRUE);
}
mOldRenderDebugMask = mRenderDebugMask;
LLViewerShaderMgr::instance()->setShaders();
stop_glerror();
for (float& i : mSpotLightFade)
{
i = 1.f;
David Parks
committed
if (mCubeVB.isNull())
{
mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX, GL_STATIC_DRAW_ARB);
}
Leslie Linden
committed
//
// Update all settings to trigger a cached settings refresh
//
connectRefreshCachedSettingsSafe("RenderAutoMaskAlphaDeferred");
connectRefreshCachedSettingsSafe("RenderAutoMaskAlphaNonDeferred");
connectRefreshCachedSettingsSafe("RenderUseFarClip");
connectRefreshCachedSettingsSafe("RenderAvatarMaxNonImpostors");
connectRefreshCachedSettingsSafe("RenderDelayVBUpdate");
connectRefreshCachedSettingsSafe("UseOcclusion");
connectRefreshCachedSettingsSafe("VertexShaderEnable");
connectRefreshCachedSettingsSafe("RenderAvatarVP");
connectRefreshCachedSettingsSafe("WindLightUseAtmosShaders");
connectRefreshCachedSettingsSafe("RenderDeferred");
connectRefreshCachedSettingsSafe("RenderDeferredSunWash");
connectRefreshCachedSettingsSafe("RenderFSAASamples");
connectRefreshCachedSettingsSafe("RenderResolutionDivisor");
Kitty Barnett
committed
// [SL:KB] - Patch: Settings-RenderResolutionMultiplier | Checked: Catznip-5.4
connectRefreshCachedSettingsSafe("RenderResolutionMultiplier");
// [/SL:KB]
connectRefreshCachedSettingsSafe("RenderUIBuffer");
connectRefreshCachedSettingsSafe("RenderShadowDetail");
connectRefreshCachedSettingsSafe("RenderDeferredSSAO");
connectRefreshCachedSettingsSafe("RenderDeferredSSAOResolutionScale");
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
connectRefreshCachedSettingsSafe("RenderShadowResolutionScale");
connectRefreshCachedSettingsSafe("RenderLocalLights");
connectRefreshCachedSettingsSafe("RenderDelayCreation");
connectRefreshCachedSettingsSafe("RenderAnimateRes");
connectRefreshCachedSettingsSafe("FreezeTime");
connectRefreshCachedSettingsSafe("DebugBeaconLineWidth");
connectRefreshCachedSettingsSafe("RenderHighlightBrightness");
connectRefreshCachedSettingsSafe("RenderHighlightColor");
connectRefreshCachedSettingsSafe("RenderHighlightThickness");
connectRefreshCachedSettingsSafe("RenderSpotLightsInNondeferred");
connectRefreshCachedSettingsSafe("PreviewAmbientColor");
connectRefreshCachedSettingsSafe("PreviewDiffuse0");
connectRefreshCachedSettingsSafe("PreviewSpecular0");
connectRefreshCachedSettingsSafe("PreviewDiffuse1");
connectRefreshCachedSettingsSafe("PreviewSpecular1");
connectRefreshCachedSettingsSafe("PreviewDiffuse2");
connectRefreshCachedSettingsSafe("PreviewSpecular2");
connectRefreshCachedSettingsSafe("PreviewDirection0");
connectRefreshCachedSettingsSafe("PreviewDirection1");
connectRefreshCachedSettingsSafe("PreviewDirection2");
connectRefreshCachedSettingsSafe("RenderGlowMinLuminance");
connectRefreshCachedSettingsSafe("RenderGlowMaxExtractAlpha");
connectRefreshCachedSettingsSafe("RenderGlowWarmthAmount");
connectRefreshCachedSettingsSafe("RenderGlowLumWeights");
connectRefreshCachedSettingsSafe("RenderGlowWarmthWeights");
connectRefreshCachedSettingsSafe("RenderGlowResolutionPow");
connectRefreshCachedSettingsSafe("RenderGlowIterations");
connectRefreshCachedSettingsSafe("RenderGlowWidth");
connectRefreshCachedSettingsSafe("RenderGlowStrength");
connectRefreshCachedSettingsSafe("RenderDepthOfField");
connectRefreshCachedSettingsSafe("RenderDepthOfFieldInEditMode");
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
connectRefreshCachedSettingsSafe("CameraFocusTransitionTime");
connectRefreshCachedSettingsSafe("CameraFNumber");
connectRefreshCachedSettingsSafe("CameraFocalLength");
connectRefreshCachedSettingsSafe("CameraFieldOfView");
connectRefreshCachedSettingsSafe("RenderShadowNoise");
connectRefreshCachedSettingsSafe("RenderShadowBlurSize");
connectRefreshCachedSettingsSafe("RenderSSAOScale");
connectRefreshCachedSettingsSafe("RenderSSAOMaxScale");
connectRefreshCachedSettingsSafe("RenderSSAOFactor");
connectRefreshCachedSettingsSafe("RenderSSAOEffect");
connectRefreshCachedSettingsSafe("RenderShadowOffsetError");
connectRefreshCachedSettingsSafe("RenderShadowBiasError");
connectRefreshCachedSettingsSafe("RenderShadowOffset");
connectRefreshCachedSettingsSafe("RenderShadowBias");
connectRefreshCachedSettingsSafe("RenderSpotShadowOffset");
connectRefreshCachedSettingsSafe("RenderSpotShadowBias");
connectRefreshCachedSettingsSafe("RenderEdgeDepthCutoff");
connectRefreshCachedSettingsSafe("RenderEdgeNormCutoff");
connectRefreshCachedSettingsSafe("RenderShadowGaussian");
connectRefreshCachedSettingsSafe("RenderShadowBlurDistFactor");
connectRefreshCachedSettingsSafe("RenderDeferredAtmospheric");
connectRefreshCachedSettingsSafe("RenderReflectionDetail");
connectRefreshCachedSettingsSafe("RenderHighlightFadeTime");
connectRefreshCachedSettingsSafe("RenderShadowClipPlanes");
connectRefreshCachedSettingsSafe("RenderShadowOrthoClipPlanes");
connectRefreshCachedSettingsSafe("RenderShadowNearDist");
connectRefreshCachedSettingsSafe("RenderFarClip");
connectRefreshCachedSettingsSafe("RenderShadowSplitExponent");
connectRefreshCachedSettingsSafe("RenderShadowErrorCutoff");
connectRefreshCachedSettingsSafe("RenderShadowFOVCutoff");
connectRefreshCachedSettingsSafe("CameraOffset");
connectRefreshCachedSettingsSafe("CameraMaxCoF");
connectRefreshCachedSettingsSafe("CameraDoFResScale");
connectRefreshCachedSettingsSafe("RenderAutoHideSurfaceAreaLimit");
connectRefreshCachedSettingsSafe("RenderDeferredAlwaysSoftenShadows");
connectRefreshCachedSettingsSafe("RenderAggressiveBatching");
connectRefreshCachedSettingsSafe("RenderDeferredFullbright");
}
LLPipeline::~LLPipeline()
{
}
void LLPipeline::cleanup()
{
assertInitialized();
mGroupQ1.clear() ;
mGroupQ2.clear() ;
for(pool_set_t::iterator iter = mPools.begin();
iter != mPools.end(); )
{
pool_set_t::iterator curiter = iter++;
LLDrawPool* poolp = *curiter;
if (poolp->isFacePool())
{
LLFacePool* face_pool = (LLFacePool*) poolp;
if (face_pool->mReferences.empty())
{
mPools.erase(curiter);
removeFromQuickLookup( poolp );
delete poolp;
}
}
else
{
mPools.erase(curiter);
removeFromQuickLookup( poolp );
delete poolp;
}
}
if (!mTerrainPools.empty())
{
LL_WARNS() << "Terrain Pools not cleaned up" << LL_ENDL;
LL_WARNS() << "Tree Pools not cleaned up" << LL_ENDL;
delete mFullbrightPool;
Josh Bell
committed
delete mGlowPool;
// don't delete wl sky pool it was handled above in the for loop
//delete mWLSkyPool;
Josh Bell
committed
releaseGLBuffers();
mMovedBridge.clear();
//============================================================================
void LLPipeline::destroyGL()
stop_glerror();
unloadShaders();
mHighlightFaces.clear();
resetDrawOrders();
resetVertexBuffers();
Josh Bell
committed
releaseGLBuffers();
if (LLVertexBuffer::sEnableVBOs)
Josh Bell
committed
{
LLVertexBuffer::sEnableVBOs = FALSE;
Josh Bell
committed
}
David Parks
committed
if (mMeshDirtyQueryObject)
{
glDeleteQueriesARB(1, &mMeshDirtyQueryObject);
mMeshDirtyQueryObject = 0;
}
}
Josh Bell
committed
static LLTrace::BlockTimerStatHandle FTM_RESIZE_SCREEN_TEXTURE("Resize Screen Texture");
void LLPipeline::throttleNewMemoryAllocation(bool disable)
{
if(sMemAllocationThrottled != disable)
{
sMemAllocationThrottled = disable ;
if(sMemAllocationThrottled)
{
//send out notification
LLNotification::Params params("LowMemory");
LLNotifications::instance().add(params);
//release some memory.
}
}
}
void LLPipeline::resizeScreenTexture()
{
LL_RECORD_BLOCK_TIME(FTM_RESIZE_SCREEN_TEXTURE);
if (gPipeline.canUseVertexShaders() && assertInitialized())
Josh Bell
committed
{
GLuint resX = gViewerWindow->getWorldViewWidthRaw();
GLuint resY = gViewerWindow->getWorldViewHeightRaw();
Kitty Barnett
committed
// [SL:KB] - Patch: Settings-RenderResolutionMultiplier | Checked: Catznip-5.4
if ( (RenderResolutionDivisor > 1) && (RenderResolutionDivisor < resX) && (RenderResolutionDivisor < resY) )
Kitty Barnett
committed
resX /= RenderResolutionDivisor;
resY /= RenderResolutionDivisor;
Kitty Barnett
committed
else if (RenderResolutionMultiplier != 1.f)
{
resX *= RenderResolutionMultiplier;
resY *= RenderResolutionMultiplier;
}
// [/SL:KB]
if ((resX != mScreen.getWidth()) || (resY != mScreen.getHeight()))
{
releaseScreenBuffers();
if (!allocateScreenBuffer(resX,resY))
David Parks
committed
{
#if PROBABLE_FALSE_DISABLES_OF_ALM_HERE
//FAILSAFE: screen buffer allocation failed, disable deferred rendering if it's enabled
//NOTE: if the session closes successfully after this call, deferred rendering will be
// disabled on future sessions
if (LLPipeline::sRenderDeferred)
{
gSavedSettings.setBOOL("RenderDeferred", FALSE);
LLPipeline::refreshCachedSettings();
}
#endif
David Parks
committed
}
}
}
void LLPipeline::allocatePhysicsBuffer()
{
GLuint resX = gViewerWindow->getWorldViewWidthRaw();
GLuint resY = gViewerWindow->getWorldViewHeightRaw();
if (mPhysicsDisplay.getWidth() != resX || mPhysicsDisplay.getHeight() != resY)
{

Rye Mutt
committed
mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV);
David Parks
committed
bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY)
{
refreshCachedSettings();
David Parks
committed
Drake Arconis
committed
//bool save_settings = sRenderDeferred;
//if (save_settings)
//{
// // Set this flag in case we crash while resizing window or allocating space for deferred rendering targets
// gSavedSettings.setBOOL("RenderInitError", TRUE);
// gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
//}
David Parks
committed
eFBOStatus ret = doAllocateScreenBuffer(resX, resY);
Drake Arconis
committed
//if (save_settings)
//{
// // don't disable shaders on next session
// gSavedSettings.setBOOL("RenderInitError", FALSE);
// gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
//}
David Parks
committed
if (ret == FBO_FAILURE)
{ //FAILSAFE: screen buffer allocation failed, disable deferred rendering if it's enabled
//NOTE: if the session closes successfully after this call, deferred rendering will be
// disabled on future sessions
if (LLPipeline::sRenderDeferred)
{
gSavedSettings.setBOOL("RenderDeferred", FALSE);
LLPipeline::refreshCachedSettings();
}
}
return ret == FBO_SUCCESS_FULLRES;
David Parks
committed
}
LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY)
David Parks
committed
{
// try to allocate screen buffers at requested resolution and samples
// - on failure, shrink number of samples and try again
// - if not multisampled, shrink resolution and try again (favor X resolution over Y)
// Make sure to call "releaseScreenBuffers" after each failure to cleanup the partially loaded state
David Parks
committed
U32 samples = RenderFSAASamples;
David Parks
committed
eFBOStatus ret = FBO_SUCCESS_FULLRES;
if (!allocateScreenBuffer(resX, resY, samples))
{
David Parks
committed
//failed to allocate at requested specification, return false
ret = FBO_FAILURE;
David Parks
committed
releaseScreenBuffers();
//reduce number of samples
while (samples > 0)
{
samples /= 2;
if (allocateScreenBuffer(resX, resY, samples))
{ //success
return FBO_SUCCESS_LOWRES;
}
releaseScreenBuffers();
}
samples = 0;
//reduce resolution
while (resY > 0 && resX > 0)
{
resY /= 2;
if (allocateScreenBuffer(resX, resY, samples))
{
return FBO_SUCCESS_LOWRES;
}
releaseScreenBuffers();
resX /= 2;
if (allocateScreenBuffer(resX, resY, samples))
{
return FBO_SUCCESS_LOWRES;
}
releaseScreenBuffers();
}
LL_WARNS() << "Unable to allocate screen buffer at any resolution!" << LL_ENDL;
}
David Parks
committed
return ret;
}
bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
{
refreshCachedSettings();
// remember these dimensions
mScreenWidth = resX;
mScreenHeight = resY;
U32 res_mod = RenderResolutionDivisor;
if (res_mod > 1 && res_mod < resX && res_mod < resY)
{
resX /= res_mod;
resY /= res_mod;
}
Kitty Barnett
committed
// [SL:KB] - Patch: Settings-RenderResolutionMultiplier | Checked: Catznip-5.4
else if (RenderResolutionMultiplier != 1.f)
{
resX *= RenderResolutionMultiplier;
resY *= RenderResolutionMultiplier;
}
// [/SL:KB]
if (RenderUIBuffer)

Rye Mutt
committed
if (!mUIScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV))
{
return false;
}
if (LLPipeline::sRenderDeferred)
S32 shadow_detail = RenderShadowDetail;
//allocate deferred rendering color buffers

Rye Mutt
committed
if (!mDeferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_TEXTURE, FALSE, samples, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV)) return false;
Drake Arconis
committed
if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
if (!addDeferredAttachments(mDeferredScreen)) return false;
David Parks
committed
GLuint screenFormat = GL_RGBA16;

Rye Mutt
committed
GLuint pixFormat = GL_BGRA;
GLuint pixType = GL_UNSIGNED_INT_8_8_8_8_REV;
if (gGLManager.mIsATI)
{
screenFormat = GL_RGBA12;
}
if (gGLManager.mGLVersion < 4.f && gGLManager.mIsNVIDIA)
{
screenFormat = GL_RGBA16F_ARB;

Rye Mutt
committed
pixFormat = GL_RGBA;
pixType = GL_FLOAT;

Rye Mutt
committed
if (!mScreen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples, pixFormat, pixType)) return false;
if (!mFinalScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV)) return false;
David Parks
committed
if (samples > 0)

Rye Mutt
committed
if (!mFXAABuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV)) return false;
David Parks
committed
mFXAABuffer.release();
David Parks
committed
if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0)
{ //only need mDeferredLight for shadows OR ssao OR dof OR fxaa

Rye Mutt
committed
if (!mDeferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV)) return false;
if(ssao)
{
F32 scale = llclamp(RenderDeferredSSAOResolutionScale, 0.01f, 1.f);
Drake Arconis
committed
if( scale < 1.f && !mDeferredDownsampledDepth.allocate(llceil(F32(resX)*scale), llceil(F32(resY)*scale), 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE) ) return false;
mDeferredLight.release();
andreykproductengine
committed
F32 scale = llmax(0.f, RenderShadowResolutionScale);
U32 sun_shadow_map_width = ((U32(resX*scale)+1)&~1); // must be even to avoid a stripe in the horizontal shadow blur