123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428 |
- /**
- * @file llprefsgraphics.cpp
- * @brief Graphics preferences for the preferences floater
- *
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2009, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #include "llviewerprecompiledheaders.h"
- #include <regex>
- #include "llprefsgraphics.h"
- #include "llcheckboxctrl.h"
- #include "llcombobox.h"
- #include "lllineeditor.h"
- #include "lllocale.h"
- #include "llnotifications.h"
- #include "llpanel.h"
- #include "llradiogroup.h"
- #include "llsliderctrl.h"
- #include "llspinctrl.h"
- #include "llstartup.h"
- #include "lltabcontainer.h"
- #include "lltextbox.h"
- #include "lluictrlfactory.h"
- #include "llwindow.h"
- #include "llfeaturemanager.h"
- #include "llfloaterpreference.h"
- #include "llpipeline.h"
- #include "llsky.h"
- #include "llstartup.h"
- #include "llviewercamera.h"
- #include "llviewercontrol.h"
- #include "llviewermessage.h" // For send_agent_update()
- #include "llviewerobjectlist.h"
- #include "llviewershadermgr.h"
- #include "llviewertexturelist.h"
- #include "llviewerwindow.h"
- #include "llvoavatar.h"
- #include "llvosky.h"
- #include "llvotree.h"
- #include "llvovolume.h"
- #include "llworld.h"
- static bool sNeedsRefresh = false;
- class LLPrefsGraphicsImpl final : public LLPanel
- {
- friend class LLPreferenceCore;
- public:
- LLPrefsGraphicsImpl();
- ~LLPrefsGraphicsImpl() override;
- bool postBuild() override;
- void draw() override;
- void refresh() override; // Refresh enable/disable
- void apply(); // Apply the changed values.
- void applyResolution();
- void applyWindowSize();
- void cancel();
- private:
- void setCloudsMaxAlt();
- void initWindowSizeControls();
- bool extractSizeFromString(const std::string& instr, U32& width,
- U32& height);
- void refreshEnabledState();
- static void onTabChanged(void* data, bool);
- // When the quality radio buttons are changed
- static void onChangeQuality(LLUICtrl* ctrl, void* data);
- // When the custom settings box is clicked
- static void onChangeCustom(LLUICtrl* ctrl, void* data);
- static void onOpenHelp(void* data);
- static void onCommitAutoDetectAspect(LLUICtrl* ctrl, void* data);
- static void onKeystrokeAspectRatio(LLLineEditor* caller, void* data);
- static void onSelectAspectRatio(LLUICtrl*, void*);
- static void onCommitWindowedMode(LLUICtrl* ctrl, void* data);
- static void updateSliderText(LLUICtrl* ctrl, void* data);
- static void updateMeterText(LLUICtrl* ctrl, void* data);
- static void onClassicClouds(LLUICtrl* ctrl, void* data);
- static void onCommitNeedsRefresh(LLUICtrl*, void* data);
- static void onCommitAvatarPhysics(LLUICtrl* ctrl, void* data);
- static void onCommitMaxNonImpostors(LLUICtrl* ctrl, void* data);
- // Callback for defaults
- static void setHardwareDefaults(void* data);
- // Helper method
- static void fractionFromDecimal(F32 decimal_val, S32& numerator,
- S32& denominator);
- private:
- typedef boost::signals2::connection connection_t;
- connection_t mCommitSignal;
- LLTabContainer* mTabContainer;
- // Aspect ratio sliders and boxes
- LLComboBox* mCtrlFullScreen; // Fullscreen resolution
- LLCheckBoxCtrl* mCtrlAutoDetectAspect; // Auto-detect aspect ratio
- LLComboBox* mCtrlAspectRatio; // User provided aspect ratio
- LLCheckBoxCtrl* mCtrlWindowed; // Windowed mode
- LLComboBox* mCtrlWindowSize; // Window size for windowed mode
- LLCheckBoxCtrl* mCtrlBenchmark; // Benchmark GPU
- /// Performance radio group
- LLSliderCtrl* mCtrlSliderQuality;
- // Performance sliders and boxes
- LLSliderCtrl* mCtrlDrawDistance; // Draw distance slider
- LLSliderCtrl* mCtrlLocalLightCount; // Mas local lights count
- LLSliderCtrl* mCtrlGlowResolution; // Glow map resolution
- LLSliderCtrl* mCtrlLODFactor; // LOD for volume objects
- LLSliderCtrl* mCtrlFlexFactor; // Timeslice for flexible objects
- LLSliderCtrl* mCtrlTreeFactor; // Control tree cutoff distance
- LLSliderCtrl* mCtrlAvatarFactor; // LOD for avatars
- LLSliderCtrl* mCtrlTerrainFactor; // LOD for terrain
- LLSliderCtrl* mCtrlTerrainMaterials; // Details for terrain materials
- LLSliderCtrl* mCtrlSkyFactor; // LOD for terrain
- LLSliderCtrl* mCtrlMaxParticle; // Max Particle
- LLCheckBoxCtrl* mCtrlGlow;
- LLCheckBoxCtrl* mCtrlDeferredEnable;
- LLCheckBoxCtrl* mCtrlAvatarCloth;
- LLCheckBoxCtrl* mCtrlClassicClouds;
- LLCheckBoxCtrl* mCtrlPBREnable;
- LLSliderCtrl* mCtrlExposure;
- LLCheckBoxCtrl* mCtrlTransparentWater;
- LLCheckBoxCtrl* mCtrlTerrainPBRTriplanar;
- LLSpinCtrl* mRenderGlowStrength;
- LLSpinCtrl* mSpinCloudsAltitude;
- LLComboBox* mComboRenderShadowDetail;
- LLComboBox* mComboWaterReflectionType;
- LLComboBox* mComboReflections;
- LLComboBox* mComboReflectionLevel;
- LLComboBox* mComboMirrors;
- LLCheckBoxCtrl* mCtrlSMAA;
- LLCheckBoxCtrl* mCtrlSharpen;
- LLTextBox* mAspectRatioLabel1;
- LLTextBox* mDisplayResLabel;
- LLTextBox* mFullScreenInfo;
- LLTextBox* mWindowSizeLabel;
- LLTextBox* mDrawDistanceMeterText1;
- LLTextBox* mDrawDistanceMeterText2;
- LLTextBox* mLODFactorText;
- LLTextBox* mFlexFactorText;
- LLTextBox* mTreeFactorText;
- LLTextBox* mAvatarFactorText;
- LLTextBox* mTerrainFactorText;
- LLTextBox* mTerrainMaterialsText;
- LLTextBox* mSkyFactorText;
- LLTextBox* mGlowResolutionText;
- LLTextBox* mClassicCloudsText;
- // GPU/GL features sub-tab
- LLCheckBoxCtrl* mCtrlOcclusion;
- // Avatar rendering sub-tab
- LLSliderCtrl* mCtrlMaxNonImpostors;
- LLSliderCtrl* mCtrlMaximumComplexity;
- LLSliderCtrl* mCtrlSurfaceAreaLimit;
- LLSliderCtrl* mCtrlGeometryBytesLimit;
- F32 mAspectRatio;
- // Performance value holders for cancel
- S32 mQualityPerformance;
- // Renderer settings sub-tab
- U32 mWaterReflectionType;
- U32 mWaterMaxAltitude;
- S32 mAvatarMode;
- S32 mClassicCloudsAvgAlt;
- U32 mLocalLightCount;
- U32 mRenderShadowDetail;
- U32 mReflectionProbes;
- U32 mReflectionProbeLevel;
- U32 mRenderTerrainPBRDetail;
- F32 mRenderFarClip;
- F32 mPrimLOD;
- F32 mMeshLODBoost;
- F32 mFlexLOD;
- F32 mTreeLOD;
- F32 mAvatarLOD;
- F32 mTerrainLOD;
- S32 mSkyLOD;
- S32 mParticleCount;
- S32 mPostProcess;
- F32 mGlowStrength;
- F32 mExposure;
- U32 mMirrors;
- U32 mFSAASamples;
- bool mFullScreen;
- bool mGlow;
- bool mRenderTransparentWater;
- bool mScreenSpaceReflections;
- bool mUseSMAAShader;
- bool mUseSharpenShader;
- bool mTerrainPBRTriplanar;
- bool mFSAutoDetectAspect;
- #if !LL_LINUX // Irrelevant setting for Linux
- bool mRenderHiDPI;
- #endif
- bool mRenderPBR;
- bool mRenderDeferred;
- bool mAvatarCloth;
- bool mUseClassicClouds;
- bool mCanDoCloth;
- bool mCanDoDeferred;
- // GPU/GL features sub-tab
- bool mRenderGLCoreProfile;
- bool mUseAniso;
- bool mDisableVRAMCheck;
- bool mCompressTextures;
- bool mRenderUseRGBA16ATI;
- S32 mGLWorkerThreads;
- F32 mGamma;
- U32 mVRAMOverride;
- S32 mTextureMem;
- U32 mMaxBoundTexMem;
- U32 mRenderCompressThreshold;
- // Avatars rendering sub-tab
- U32 mNonImpostors;
- U32 mNonImpostorsPuppets;
- U32 mRenderAvatarMaxComplexity;
- F32 mRenderAutoMuteSurfaceAreaLimit;
- U32 mRenderAutoMuteMemoryLimit;
- F32 mRenderAvatarPhysicsLODFactor;
- bool mAvatarPhysics;
- bool mAlwaysRenderFriends;
- bool mColoredJellyDolls;
- bool mFirstRun;
- };
- constexpr S32 ASPECT_RATIO_STR_LEN = 100;
- LLPrefsGraphicsImpl::LLPrefsGraphicsImpl()
- : mFirstRun(true)
- {
- LLUICtrlFactory::getInstance()->buildPanel(this,
- "panel_preferences_graphics.xml");
- }
- bool LLPrefsGraphicsImpl::postBuild()
- {
- mTabContainer = getChild<LLTabContainer>("graphics_tabs");
- LLPanel* tab = mTabContainer->getChild<LLPanel>("Renderer settings");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- tab = mTabContainer->getChild<LLPanel>("GPU/GL features");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- tab = mTabContainer->getChild<LLPanel>("Avatars rendering");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- // Setup graphic card driver capabilities
- mCanDoCloth = gFeatureManager.isFeatureAvailable("RenderAvatarCloth");
- mCanDoDeferred = gFeatureManager.isFeatureAvailable("RenderDeferred");
- // Return to default values
- childSetAction("Defaults", setHardwareDefaults, this);
- // Help button
- childSetAction("GraphicsPreferencesHelpButton", onOpenHelp, this);
- // Resolution
- // Radio set for fullscreen size
- mCtrlWindowed = getChild<LLCheckBoxCtrl>("windowed mode");
- mCtrlWindowed->setCommitCallback(onCommitWindowedMode);
- mCtrlWindowed->setCallbackUserData(this);
- mAspectRatioLabel1 = getChild<LLTextBox>("AspectRatioLabel1");
- mFullScreenInfo = getChild<LLTextBox>("FullScreenInfo");
- mDisplayResLabel = getChild<LLTextBox>("DisplayResLabel");
- S32 num_resolutions = 0;
- LLWindow::LLWindowResolution* resolutions =
- gWindowp->getSupportedResolutions(num_resolutions);
- S32 fullscreen_mode = num_resolutions - 1;
- mCtrlFullScreen = getChild<LLComboBox>("fullscreen combo");
- LLUIString resolution_label = getString("resolution_format");
- for (S32 i = 0; i < num_resolutions; ++i)
- {
- resolution_label.setArg("[RES_X]",
- llformat("%d", resolutions[i].mWidth));
- resolution_label.setArg("[RES_Y]",
- llformat("%d", resolutions[i].mHeight));
- mCtrlFullScreen->add(resolution_label, ADD_BOTTOM);
- }
- bool want_full_screen = gSavedSettings.getBool("FullScreen");
- U32 width, height;
- gViewerWindowp->getTargetWindow(want_full_screen, width, height);
- if (want_full_screen)
- {
- fullscreen_mode = 0;
- for (S32 i = 0; i < num_resolutions; ++i)
- {
- if (width == (U32)resolutions[i].mWidth &&
- height == (U32)resolutions[i].mHeight)
- {
- fullscreen_mode = i;
- }
- }
- mCtrlFullScreen->setCurrentByIndex(fullscreen_mode);
- mCtrlWindowed->set(false);
- mCtrlFullScreen->setVisible(true);
- }
- else
- {
- // Set to windowed mode
- mCtrlWindowed->set(true);
- mCtrlFullScreen->setCurrentByIndex(0);
- mCtrlFullScreen->setVisible(false);
- }
- initWindowSizeControls();
- if (gSavedSettings.getBool("FullScreenAutoDetectAspectRatio"))
- {
- mAspectRatio = gViewerWindowp->getDisplayAspectRatio();
- }
- else
- {
- mAspectRatio = gSavedSettings.getF32("FullScreenAspectRatio");
- }
- S32 numerator = 0;
- S32 denominator = 0;
- fractionFromDecimal(mAspectRatio, numerator, denominator);
- LLUIString aspect_ratio_text = getString("aspect_ratio_text");
- if (numerator != 0)
- {
- aspect_ratio_text.setArg("[NUM]", llformat("%d", numerator));
- aspect_ratio_text.setArg("[DEN]", llformat("%d", denominator));
- }
- else
- {
- aspect_ratio_text = llformat("%.3f", mAspectRatio);
- }
- mCtrlAspectRatio = getChild<LLComboBox>("aspect_ratio");
- mCtrlAspectRatio->setTextEntryCallback(onKeystrokeAspectRatio);
- mCtrlAspectRatio->setCommitCallback(onSelectAspectRatio);
- mCtrlAspectRatio->setCallbackUserData(this);
- // Add default aspect ratios
- mCtrlAspectRatio->add(aspect_ratio_text, &mAspectRatio, ADD_TOP);
- mCtrlAspectRatio->setCurrentByIndex(0);
- mCtrlAutoDetectAspect = getChild<LLCheckBoxCtrl>("aspect_auto_detect");
- mCtrlAutoDetectAspect->setCommitCallback(onCommitAutoDetectAspect);
- mCtrlAutoDetectAspect->setCallbackUserData(this);
- #if LL_LINUX
- // HiDPI (Retina) mode for macOS or UI scaling under Windows 10. Irrelevant
- // to Linux.
- childHide("hi_dpi_check");
- #endif
- // Radio performance box
- mCtrlSliderQuality = getChild<LLSliderCtrl>("QualityPerformanceSelection");
- mCtrlSliderQuality->setSliderMouseUpCallback(onChangeQuality);
- mCtrlSliderQuality->setCallbackUserData(this);
- mCtrlBenchmark = getChild<LLCheckBoxCtrl>("benchmark_gpu_check");
- // Glow
- mCtrlGlow = getChild<LLCheckBoxCtrl>("RenderGlowCheck");
- mCtrlGlow->setCommitCallback(onCommitNeedsRefresh);
- mCtrlGlow->setCallbackUserData(this);
- mRenderGlowStrength = getChild<LLSpinCtrl>("glow_strength");
- mCtrlGlowResolution = getChild<LLSliderCtrl>("GlowResolutionPow");
- mGlowResolutionText = getChild<LLTextBox>("GlowResolutionText");
- mCtrlGlowResolution->setCommitCallback(updateSliderText);
- mCtrlGlowResolution->setCallbackUserData(mGlowResolutionText);
- // Water opacity or reflections
- mComboWaterReflectionType = getChild<LLComboBox>("WaterReflectionTypeCombo");
- mComboWaterReflectionType->setCurrentByIndex(gSavedSettings.getU32("RenderWaterReflectionType"));
- mCtrlTransparentWater = getChild<LLCheckBoxCtrl>("TransparentWaterCheck");
- // PBR reflections
- mComboReflections = getChild<LLComboBox>("ReflectionsCombo");
- mComboReflections->setCurrentByIndex(gSavedSettings.getU32("RenderReflectionProbes"));
- mComboReflectionLevel = getChild<LLComboBox>("ReflectionLevelCombo");
- mComboReflectionLevel->setCurrentByIndex(gSavedSettings.getU32("RenderReflectionProbeLevel"));
- mComboMirrors = getChild<LLComboBox>("RenderHeroProbeResLevel");
- mComboMirrors->setCurrentByIndex(gSavedSettings.getU32("RenderHeroProbeResLevel"));
-
- // Avatar shader
- mCtrlAvatarCloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
- // Deferred rendering
- mCtrlDeferredEnable = getChild<LLCheckBoxCtrl>("RenderDeferred");
- mCtrlDeferredEnable->setCommitCallback(onCommitNeedsRefresh);
- mCtrlDeferredEnable->setCallbackUserData(this);
- mComboRenderShadowDetail =
- getChild<LLComboBox>("RenderShadowDetailCombo");
- mComboRenderShadowDetail->setCurrentByIndex(gSavedSettings.getU32("RenderShadowDetail"));
- mCtrlSMAA = getChild<LLCheckBoxCtrl>("smaa");
- mCtrlSharpen = getChild<LLCheckBoxCtrl>("sharpen");
- mCtrlPBREnable = getChild<LLCheckBoxCtrl>("UsePBRCheck");
- mCtrlExposure = getChild<LLSliderCtrl>("RenderExposureCtrl");
- // Object detail slider
- mCtrlDrawDistance = getChild<LLSliderCtrl>("DrawDistance");
- mDrawDistanceMeterText1 = getChild<LLTextBox>("DrawDistanceMeterText1");
- mDrawDistanceMeterText2 = getChild<LLTextBox>("DrawDistanceMeterText2");
- mCtrlDrawDistance->setCommitCallback(updateMeterText);
- mCtrlDrawDistance->setCallbackUserData(this);
- updateMeterText(mCtrlDrawDistance, (void*)this);
- // Object detail slider
- mCtrlLODFactor = getChild<LLSliderCtrl>("ObjectMeshDetail");
- mLODFactorText = getChild<LLTextBox>("ObjectMeshDetailText");
- mCtrlLODFactor->setCommitCallback(updateSliderText);
- mCtrlLODFactor->setCallbackUserData(mLODFactorText);
- // Flex object detail slider
- mCtrlFlexFactor = getChild<LLSliderCtrl>("FlexibleMeshDetail");
- mFlexFactorText = getChild<LLTextBox>("FlexibleMeshDetailText");
- mCtrlFlexFactor->setCommitCallback(updateSliderText);
- mCtrlFlexFactor->setCallbackUserData(mFlexFactorText);
- // Tree detail slider
- mCtrlTreeFactor = getChild<LLSliderCtrl>("TreeMeshDetail");
- mTreeFactorText = getChild<LLTextBox>("TreeMeshDetailText");
- mCtrlTreeFactor->setCommitCallback(updateSliderText);
- mCtrlTreeFactor->setCallbackUserData(mTreeFactorText);
- // Avatar detail slider
- mCtrlAvatarFactor = getChild<LLSliderCtrl>("AvatarMeshDetail");
- mAvatarFactorText = getChild<LLTextBox>("AvatarMeshDetailText");
- mCtrlAvatarFactor->setCommitCallback(updateSliderText);
- mCtrlAvatarFactor->setCallbackUserData(mAvatarFactorText);
- // Terrain detail
- mCtrlTerrainFactor = getChild<LLSliderCtrl>("TerrainMeshDetail");
- mTerrainFactorText = getChild<LLTextBox>("TerrainMeshDetailText");
- mCtrlTerrainFactor->setCommitCallback(updateSliderText);
- mCtrlTerrainFactor->setCallbackUserData(mTerrainFactorText);
- mCtrlTerrainMaterials = getChild<LLSliderCtrl>("TerrainMaterials");
- mTerrainMaterialsText = getChild<LLTextBox>("TerrainMaterialsText");
- mCtrlTerrainMaterials->setCommitCallback(updateSliderText);
- mCtrlTerrainMaterials->setCallbackUserData(mTerrainMaterialsText);
- mCtrlTerrainPBRTriplanar = getChild<LLCheckBoxCtrl>("triplanar");
- // Sky detail slider
- mCtrlSkyFactor = getChild<LLSliderCtrl>("SkyMeshDetail");
- mSkyFactorText = getChild<LLTextBox>("SkyMeshDetailText");
- mCtrlSkyFactor->setCommitCallback(updateSliderText);
- mCtrlSkyFactor->setCallbackUserData(mSkyFactorText);
- // Classic clouds
- mCtrlClassicClouds = getChild<LLCheckBoxCtrl>("ClassicClouds");
- mCtrlClassicClouds->setCommitCallback(onClassicClouds);
- mCtrlClassicClouds->setCallbackUserData(this);
- mClassicCloudsText = getChild<LLTextBox>("ClassicCloudsText");
- mSpinCloudsAltitude = getChild<LLSpinCtrl>("CloudsAltitude");
- LLControlVariable* controlp =
- gSavedSettings.getControl("ClassicCloudsMaxAlt");
- if (!controlp)
- {
- llerrs << "ClassicCloudsMaxAlt debug setting is missing !" << llendl;
- }
- mCommitSignal =
- controlp->getSignal()->connect(boost::bind(&LLPrefsGraphicsImpl::setCloudsMaxAlt,
- this));
- setCloudsMaxAlt();
- // Particle detail slider
- mCtrlMaxParticle = getChild<LLSliderCtrl>("MaxParticleCount");
- // Local lights count slider
- mCtrlLocalLightCount = getChild<LLSliderCtrl>("LocalLightCount");
- // GPU/GL features sub-tab:
- mCtrlOcclusion = getChild<LLCheckBoxCtrl>("occlusion");
- childSetCommitCallback("texture_compression", onCommitNeedsRefresh, this);
- childSetVisible("after_restart", LLStartUp::isLoggedIn());
- #if LL_DARWIN
- // Under macOS, this setting allows to choose between the legacy GL v2.1
- // compatibility profile, and the GL v3.2 (or v4.1, depending on the macOS
- // version) core profile, so this control must always be available, even
- // when running under the v2.1 compatibility profile. HB
- childSetEnabled("core_gl", true);
- childSetToolTip("core_gl", getString("core_gl_macos_tip"));
- #else
- childSetEnabled("core_gl", gGLManager.mGLVersion >= 3.f);
- #endif
- // Intel iGPUs do not have the necessary GL call for VRAM checks, since
- // they do not have VRAM at all ! This might change with the future ARC
- // discrete GPUs... HB
- if (!gGLManager.mHasATIMemInfo && !gGLManager.mHasNVXMemInfo)
- {
- childSetVisible("no_vram_check", false);
- }
- // Avatars rendering sub-tab:
- std::string off_text = getString("off_text");
- mCtrlMaxNonImpostors = getChild<LLSliderCtrl>("MaxNonImpostors");
- mCtrlMaxNonImpostors->setOffLimit(off_text, 0.f);
- mCtrlMaxNonImpostors->setCommitCallback(onCommitMaxNonImpostors);
- mCtrlMaxNonImpostors->setCallbackUserData(this);
- mCtrlMaximumComplexity = getChild<LLSliderCtrl>("MaximumComplexity");
- mCtrlMaximumComplexity->setOffLimit(off_text, 0.f);
- mCtrlSurfaceAreaLimit = getChild<LLSliderCtrl>("SurfaceAreaLimit");
- mCtrlSurfaceAreaLimit->setOffLimit(off_text, 0.f);
- mCtrlGeometryBytesLimit = getChild<LLSliderCtrl>("GeometryBytesLimit");
- mCtrlGeometryBytesLimit->setOffLimit(off_text, 0.f);
- LLSliderCtrl* slider = getChild<LLSliderCtrl>("MaxPuppetAvatars");
- slider->setOffLimit(off_text, 0.f);
- childSetCommitCallback("AvatarPhysics", onCommitAvatarPhysics, this);
- bool show_rgba16 = gGLManager.mIsAMD && gGLManager.mGLVersion >= 4.f;
- childSetVisible("rgba16_text", show_rgba16);
- childSetVisible("rgba16_check", show_rgba16);
- refresh();
- return true;
- }
- void LLPrefsGraphicsImpl::initWindowSizeControls()
- {
- // Window size
- mWindowSizeLabel = getChild<LLTextBox>("WindowSizeLabel");
- mCtrlWindowSize = getChild<LLComboBox>("windowsize combo");
- // Look to see if current window size matches existing window sizes, if so
- // then just set the selection value...
- const U32 height = gViewerWindowp->getWindowDisplayHeight();
- const U32 width = gViewerWindowp->getWindowDisplayWidth();
- for (S32 i = 0; i < mCtrlWindowSize->getItemCount(); ++i)
- {
- U32 height_test = 0;
- U32 width_test = 0;
- mCtrlWindowSize->setCurrentByIndex(i);
- if (extractSizeFromString(mCtrlWindowSize->getValue().asString(),
- width_test, height_test))
- {
- if (height_test == height && width_test == width)
- {
- return;
- }
- }
- }
- // ...otherwise, add a new entry with the current window height/width.
- LLUIString resolution_label = getString("resolution_format");
- resolution_label.setArg("[RES_X]", llformat("%d", width));
- resolution_label.setArg("[RES_Y]", llformat("%d", height));
- mCtrlWindowSize->add(resolution_label, ADD_TOP);
- mCtrlWindowSize->setCurrentByIndex(0);
- }
- LLPrefsGraphicsImpl::~LLPrefsGraphicsImpl()
- {
- mCommitSignal.disconnect();
- #if 0
- // Clean up user data
- for (S32 i = 0; i < mCtrlAspectRatio->getItemCount(); ++i)
- {
- mCtrlAspectRatio->setCurrentByIndex(i);
- }
- for (S32 i = 0; i < mCtrlWindowSize->getItemCount(); ++i)
- {
- mCtrlWindowSize->setCurrentByIndex(i);
- }
- #endif
- }
- void LLPrefsGraphicsImpl::setCloudsMaxAlt()
- {
- F32 max_alt = gSavedSettings.getU32("ClassicCloudsMaxAlt");
- mSpinCloudsAltitude->setMinValue(-max_alt);
- mSpinCloudsAltitude->setMaxValue(max_alt);
- }
- void LLPrefsGraphicsImpl::draw()
- {
- if (mFirstRun)
- {
- mFirstRun = false;
- mTabContainer->selectTab(gSavedSettings.getS32("LastGraphicsPrefTab"));
- }
- if (sNeedsRefresh)
- {
- sNeedsRefresh = false;
- refresh();
- }
- LLPanel::draw();
- }
- void LLPrefsGraphicsImpl::refresh()
- {
- mFullScreen = gSavedSettings.getBool("FullScreen");
- mFSAutoDetectAspect =
- gSavedSettings.getBool("FullScreenAutoDetectAspectRatio");
- #if !LL_LINUX // Irrelevant setting for Linux
- mRenderHiDPI = gSavedSettings.getBool("RenderHiDPI");
- #endif
- mQualityPerformance = gSavedSettings.getU32("RenderQualityPerformance");
- F32 bw = gFeatureManager.getGPUMemoryBandwidth();
- if (bw > 0.f)
- {
- mCtrlBenchmark->setToolTip(getString("tool_tip_bench"));
- mCtrlBenchmark->setToolTipArg("[BW]", llformat("%d", (S32)bw));
- }
- // Shaders settings
- mWaterReflectionType = gSavedSettings.getU32("RenderWaterReflectionType");
- mWaterMaxAltitude = gSavedSettings.getU32("RenderWaterMaxAltitude");
- mRenderTransparentWater = gSavedSettings.getBool("RenderTransparentWater");
- mScreenSpaceReflections =
- gSavedSettings.getBool("RenderScreenSpaceReflections");
- mAvatarCloth = mCanDoCloth && gSavedSettings.getBool("RenderAvatarCloth");
- mUseSMAAShader = gSavedSettings.getBool("RenderDeferredUseSMAA");
- mUseSharpenShader = gSavedSettings.getBool("RenderDeferredAASharpen");
- // Draw distance
- mRenderFarClip = gSavedSettings.getF32("RenderFarClip");
- // Sliders and their text boxes
- mPrimLOD = gSavedSettings.getF32("RenderVolumeLODFactor");
- mMeshLODBoost = gSavedSettings.getF32("MeshLODBoostFactor");
- mFlexLOD = gSavedSettings.getF32("RenderFlexTimeFactor");
- mTreeLOD = gSavedSettings.getF32("RenderTreeLODFactor");
- mAvatarLOD = gSavedSettings.getF32("RenderAvatarLODFactor");
- mTerrainLOD = gSavedSettings.getF32("RenderTerrainLODFactor");
- mSkyLOD = gSavedSettings.getU32("WLSkyDetail");
- mParticleCount = gSavedSettings.getS32("RenderMaxPartCount");
- mPostProcess = gSavedSettings.getU32("RenderGlowResolutionPow");
- // Classic clouds
- mUseClassicClouds = gSavedSettings.getBool("SkyUseClassicClouds");
- mClassicCloudsAvgAlt = gSavedSettings.getS32("ClassicCloudsAvgAlt");
- // Lighting and terrain radios
- mGlow = gSavedSettings.getBool("RenderGlow");
- mGlowStrength = gSavedSettings.getF32("RenderGlowStrength");
- mLocalLightCount = gSavedSettings.getU32("RenderLocalLightCount");
- mExposure = gSavedSettings.getF32("RenderExposure");
- mRenderPBR = gSavedSettings.getBool("RenderUsePBR");
- mRenderDeferred = gSavedSettings.getBool("RenderDeferred");
- mRenderShadowDetail = gSavedSettings.getU32("RenderShadowDetail");
- mReflectionProbes = gSavedSettings.getU32("RenderReflectionProbes");
- mReflectionProbeLevel =
- gSavedSettings.getU32("RenderReflectionProbeLevel");
- mMirrors = gSavedSettings.getU32("RenderHeroProbeResLevel");
- mRenderTerrainPBRDetail = gSavedSettings.getU32("RenderTerrainPBRDetail");
- mTerrainPBRTriplanar = gSavedSettings.getBool("RenderTerrainPBRTriplanar");
- // Slider text boxes
- updateSliderText(mCtrlLODFactor, mLODFactorText);
- updateSliderText(mCtrlFlexFactor, mFlexFactorText);
- updateSliderText(mCtrlTreeFactor, mTreeFactorText);
- updateSliderText(mCtrlAvatarFactor, mAvatarFactorText);
- updateSliderText(mCtrlTerrainFactor, mTerrainFactorText);
- updateSliderText(mCtrlTerrainMaterials, mTerrainMaterialsText);
- updateSliderText(mCtrlGlowResolution, mGlowResolutionText);
- updateSliderText(mCtrlSkyFactor, mSkyFactorText);
- // GPU/GL features sub-tab
- mRenderGLCoreProfile = gSavedSettings.getBool("RenderGLCoreProfile");
- mUseAniso = gSavedSettings.getBool("RenderAnisotropic");
- mFSAASamples = gSavedSettings.getU32("RenderFSAASamples");
- mGamma = gSavedSettings.getF32("DisplayGamma");
- mVRAMOverride = gSavedSettings.getU32("VRAMOverride");
- mTextureMem = gSavedSettings.getS32("TextureMemory");
- mMaxBoundTexMem = gSavedSettings.getU32("MaxBoundTexMem");
- mCompressTextures = gGLManager.mGLVersion >= 2.1f &&
- gSavedSettings.getBool("RenderCompressTextures");
- mRenderCompressThreshold =
- gSavedSettings.getU32("RenderCompressThreshold");
- mDisableVRAMCheck = gSavedSettings.getBool("DisableVRAMCheck");
- childSetValue("fsaa", (LLSD::Integer)mFSAASamples);
- mRenderUseRGBA16ATI = gSavedSettings.getBool("RenderUseRGBA16ATI");
- mGLWorkerThreads = gSavedSettings.getS32("GLWorkerThreads");
- // Avatars rendering sub-tab
- mNonImpostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors");
- mNonImpostorsPuppets = gSavedSettings.getU32("RenderAvatarMaxPuppets");
- mAvatarPhysics = gSavedSettings.getBool("AvatarPhysics");
- mAlwaysRenderFriends = gSavedSettings.getBool("AlwaysRenderFriends");
- mColoredJellyDolls = gSavedSettings.getBool("ColoredJellyDolls");
- mRenderAvatarPhysicsLODFactor =
- gSavedSettings.getF32("RenderAvatarPhysicsLODFactor");
- mRenderAvatarMaxComplexity =
- gSavedSettings.getU32("RenderAvatarMaxComplexity");
- mRenderAutoMuteSurfaceAreaLimit =
- gSavedSettings.getF32("RenderAutoMuteSurfaceAreaLimit");
- mRenderAutoMuteMemoryLimit =
- gSavedSettings.getU32("RenderAutoMuteMemoryLimit");
- refreshEnabledState();
- }
- void LLPrefsGraphicsImpl::refreshEnabledState()
- {
- // Windowed/full-screen modes UI elements visibility
- mDisplayResLabel->setVisible(mFullScreen);
- mCtrlFullScreen->setVisible(mFullScreen);
- mCtrlAspectRatio->setVisible(mFullScreen);
- mAspectRatioLabel1->setVisible(mFullScreen);
- mCtrlAutoDetectAspect->setVisible(mFullScreen);
- mCtrlWindowSize->setVisible(!mFullScreen);
- mFullScreenInfo->setVisible(!mFullScreen);
- mWindowSizeLabel->setVisible(!mFullScreen);
- // Glow
- if (LLPipeline::sCanRenderGlow)
- {
- mCtrlGlow->setEnabled(true);
- bool glow_enabled = mCtrlGlow->get();
- mRenderGlowStrength->setEnabled(glow_enabled);
- mCtrlGlowResolution->setEnabled(glow_enabled);
- mGlowResolutionText->setEnabled(glow_enabled);
- }
- else
- {
- mCtrlGlow->setEnabled(false);
- mRenderGlowStrength->setEnabled(false);
- mCtrlGlowResolution->setEnabled(false);
- mGlowResolutionText->setEnabled(false);
- }
- // Classic clouds
- bool clouds = mCtrlClassicClouds->get();
- mSpinCloudsAltitude->setEnabled(clouds);
- // Avatar Mode
- bool skinning = !LLStartUp::isLoggedIn() ||
- gViewerShaderMgrp->mMaxAvatarShaderLevel > 0;
- bool cloth = mCanDoCloth && skinning;
- // Avatar cloth
- mCtrlAvatarCloth->setEnabled(cloth);
- if (!cloth)
- {
- mCtrlAvatarCloth->setValue(false);
- }
- // Deferred rendering
- bool deferred = mCanDoDeferred && skinning;
- mCtrlPBREnable->setVisible(deferred);
- if (gUsePBRShaders)
- {
- mCtrlDeferredEnable->setVisible(false);
- childSetVisible("water_text", false);
- mComboWaterReflectionType->setVisible(false);
- mCtrlAvatarCloth->setVisible(false);
- mCtrlExposure->setVisible(true);
- mCtrlTransparentWater->setVisible(true);
- childSetVisible("reflections_text", true);
- childSetVisible("no_reflections_text", !LLViewerShaderMgr::sCanDoRP);
- mComboReflections->setVisible(LLViewerShaderMgr::sCanDoRP);
- childSetVisible("coverage_text", LLViewerShaderMgr::sHasRP);
- mComboReflectionLevel->setVisible(LLViewerShaderMgr::sHasRP);
- childSetVisible("mirrors_text", LLViewerShaderMgr::sHasRP);
- mComboMirrors->setVisible(LLViewerShaderMgr::sHasRP);
- static LLCachedControl<bool> pbr_terrain(gSavedSettings,
- "RenderTerrainPBREnabled");
- bool has_pbr_terrain = pbr_terrain &&
- gGLManager.mNumTextureImageUnits >= 16;
- mCtrlTerrainMaterials->setVisible(has_pbr_terrain);
- mTerrainMaterialsText->setVisible(has_pbr_terrain);
- mCtrlTerrainPBRTriplanar->setVisible(has_pbr_terrain);
- }
- else
- {
- mCtrlDeferredEnable->setVisible(true);
- mCtrlPBREnable->setEnabled(gGLManager.mGLVersion >= 3.1f);
- mCtrlDeferredEnable->setEnabled(deferred);
- if (!deferred)
- {
- mCtrlDeferredEnable->setValue(false);
- }
- mCtrlExposure->setVisible(false);
- mCtrlTransparentWater->setVisible(false);
- childSetVisible("water_text", true);
- mComboWaterReflectionType->setVisible(true);
- childSetVisible("reflections_text", false);
- childSetVisible("no_reflections_text", false);
- mComboReflections->setVisible(false);
- childSetVisible("coverage_text", false);
- mComboReflectionLevel->setVisible(false);
- childSetVisible("mirrors_text", false);
- mComboMirrors->setVisible(false);
- mCtrlTerrainMaterials->setVisible(false);
- mTerrainMaterialsText->setVisible(false);
- mCtrlTerrainPBRTriplanar->setVisible(false);
- mCtrlAvatarCloth->setVisible(true);
- }
- bool alm_on = gUsePBRShaders || mCtrlDeferredEnable->get();
- mComboRenderShadowDetail->setEnabled(alm_on);
- // Visibility of settings depending on ALM shaders
- mCtrlSMAA->setVisible(alm_on && LLViewerShaderMgr::sHasSMAA);
- mCtrlSharpen->setVisible(alm_on && LLViewerShaderMgr::sHasCAS);
- deferred &= gUsePBRShaders || mCtrlDeferredEnable->get();
- mComboRenderShadowDetail->setVisible(deferred);
- childSetVisible("no_alm_text", !deferred);
- childSetToolTip("no_alm_text", getString("tool_tip_no_deferred"));
- // GPU/GL features sub-tab
- S32 min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
- S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(true);
- childSetMinValue("GrapicsCardTextureMemory", min_tex_mem);
- childSetMaxValue("GrapicsCardTextureMemory", max_tex_mem);
- if (!gFeatureManager.isFeatureAvailable("RenderCompressTextures") ||
- gGLManager.mGLVersion < 2.1f)
- {
- childSetEnabled("texture_compression", false);
- }
- if (!gFeatureManager.isFeatureAvailable("UseOcclusion"))
- {
- mCtrlOcclusion->setEnabled(false);
- }
- // Texture compression settings.
- bool compress = gSavedSettings.getBool("RenderCompressTextures");
- childSetEnabled("compress_throttle", compress);
- childSetEnabled("pixels_text", compress);
- // Avatars rendering sub-tab
- bool impostors = mCtrlMaxNonImpostors->getValue().asInteger() > 0;
- mCtrlMaximumComplexity->setEnabled(impostors);
- mCtrlSurfaceAreaLimit->setEnabled(impostors);
- mCtrlGeometryBytesLimit->setEnabled(impostors);
- childSetEnabled("AvatarPhysicsLOD",
- gSavedSettings.getBool("AvatarPhysics"));
- }
- void LLPrefsGraphicsImpl::cancel()
- {
- gSavedSettings.setBool("FullScreen", mFullScreen);
- gSavedSettings.setBool("FullScreenAutoDetectAspectRatio",
- mFSAutoDetectAspect);
- #if !LL_LINUX // Irrelevant setting for Linux
- gSavedSettings.setBool("RenderHiDPI", mRenderHiDPI);
- #endif
- gSavedSettings.setF32("FullScreenAspectRatio", mAspectRatio);
- gSavedSettings.setU32("RenderQualityPerformance", mQualityPerformance);
- gSavedSettings.setU32("RenderWaterReflectionType", mWaterReflectionType);
- gSavedSettings.setU32("RenderWaterMaxAltitude", mWaterMaxAltitude);
- gSavedSettings.setBool("RenderTransparentWater", mRenderTransparentWater);
- gSavedSettings.setBool("RenderScreenSpaceReflections",
- mScreenSpaceReflections);
- gSavedSettings.setBool("RenderAvatarCloth", mAvatarCloth);
- gSavedSettings.setBool("SkyUseClassicClouds", mUseClassicClouds);
- gSavedSettings.setS32("ClassicCloudsAvgAlt", mClassicCloudsAvgAlt);
- gSavedSettings.setBool("RenderUsePBR", mRenderPBR);
- gSavedSettings.setBool("RenderDeferred", mRenderDeferred);
- gSavedSettings.setU32("RenderShadowDetail", mRenderShadowDetail);
- gSavedSettings.setBool("RenderGlow", mGlow);
- gSavedSettings.setF32("RenderGlowStrength", mGlowStrength);
- gSavedSettings.setU32("RenderLocalLightCount", mLocalLightCount);
- gSavedSettings.setF32("RenderExposure", mExposure);
- gSavedSettings.setU32("RenderReflectionProbes", mReflectionProbes);
- gSavedSettings.setU32("RenderReflectionProbeLevel", mReflectionProbeLevel);
- gSavedSettings.setU32("RenderHeroProbeResLevel", mMirrors);
- gSavedSettings.setBool("RenderDeferredUseSMAA", mUseSMAAShader);
- gSavedSettings.setBool("RenderDeferredAASharpen", mUseSharpenShader);
- gSavedSettings.setU32("RenderTerrainPBRDetail", mRenderTerrainPBRDetail);
- gSavedSettings.setBool("RenderTerrainPBRTriplanar", mTerrainPBRTriplanar);
- gSavedSettings.setF32("RenderFarClip", mRenderFarClip);
- gSavedSettings.setF32("RenderVolumeLODFactor", mPrimLOD);
- gSavedSettings.setF32("MeshLODBoostFactor", mMeshLODBoost);
- gSavedSettings.setF32("RenderFlexTimeFactor", mFlexLOD);
- gSavedSettings.setF32("RenderTreeLODFactor", mTreeLOD);
- gSavedSettings.setF32("RenderAvatarLODFactor", mAvatarLOD);
- gSavedSettings.setF32("RenderTerrainLODFactor", mTerrainLOD);
- gSavedSettings.setU32("WLSkyDetail", mSkyLOD);
- gSavedSettings.setS32("RenderMaxPartCount", mParticleCount);
- gSavedSettings.setU32("RenderGlowResolutionPow", mPostProcess);
- // GPU/GL features sub-tab
- gSavedSettings.setBool("RenderGLCoreProfile", mRenderGLCoreProfile);
- gSavedSettings.setBool("RenderAnisotropic", mUseAniso);
- gSavedSettings.setU32("RenderFSAASamples", mFSAASamples);
- gSavedSettings.setF32("DisplayGamma", mGamma);
- gSavedSettings.setU32("VRAMOverride", mVRAMOverride);
- gSavedSettings.setS32("TextureMemory", mTextureMem);
- gSavedSettings.setU32("MaxBoundTexMem", mMaxBoundTexMem);
- gSavedSettings.setBool("RenderCompressTextures", mCompressTextures);
- gSavedSettings.setU32("RenderCompressThreshold", mRenderCompressThreshold);
- gSavedSettings.setBool("DisableVRAMCheck", mDisableVRAMCheck);
- gSavedSettings.setBool("RenderUseRGBA16ATI", mRenderUseRGBA16ATI);
- gSavedSettings.setS32("GLWorkerThreads", mGLWorkerThreads);
- // Avatars rendering sub-tab
- gSavedSettings.setU32("RenderAvatarMaxNonImpostors", mNonImpostors);
- gSavedSettings.setU32("RenderAvatarMaxPuppets", mNonImpostorsPuppets);
- gSavedSettings.setBool("AvatarPhysics", mAvatarPhysics);
- gSavedSettings.setBool("AlwaysRenderFriends", mAlwaysRenderFriends);
- gSavedSettings.setBool("ColoredJellyDolls", mColoredJellyDolls);
- gSavedSettings.setF32("RenderAvatarPhysicsLODFactor",
- mRenderAvatarPhysicsLODFactor);
- gSavedSettings.setU32("RenderAvatarMaxComplexity",
- mRenderAvatarMaxComplexity);
- gSavedSettings.setF32("RenderAutoMuteSurfaceAreaLimit",
- mRenderAutoMuteSurfaceAreaLimit);
- gSavedSettings.setU32("RenderAutoMuteMemoryLimit",
- mRenderAutoMuteMemoryLimit);
- }
- void LLPrefsGraphicsImpl::apply()
- {
- applyResolution();
- applyWindowSize();
- }
- void LLPrefsGraphicsImpl::applyResolution()
- {
- gGL.flush();
- glFinish();
- bool restart_display = false;
- bool after_restart = false;
- bool full_screen = gWindowp->getFullscreen();
- bool want_full_screen = !mCtrlWindowed->get();
- char aspect_ratio_text[ASPECT_RATIO_STR_LEN];
- if (mCtrlAspectRatio->getCurrentIndex() == -1)
- {
- // Cannot pass const char* from c_str() into strtok
- strncpy(aspect_ratio_text, mCtrlAspectRatio->getSimple().c_str(),
- sizeof(aspect_ratio_text) -1);
- aspect_ratio_text[sizeof(aspect_ratio_text) -1] = '\0';
- char* element = strtok(aspect_ratio_text, ":/\\");
- if (!element)
- {
- mAspectRatio = 0.f; // Will be clamped later
- }
- else
- {
- LLLocale locale(LLLocale::USER_LOCALE);
- mAspectRatio = (F32)atof(element);
- }
- // Look for denominator
- element = strtok(NULL, ":/\\");
- if (element)
- {
- LLLocale locale(LLLocale::USER_LOCALE);
- F32 denominator = (F32)atof(element);
- if (denominator > 0.f)
- {
- mAspectRatio /= denominator;
- }
- }
- }
- else
- {
- mAspectRatio = (F32)mCtrlAspectRatio->getValue().asReal();
- }
- // Presumably, user entered a non-numeric value if mAspectRatio == 0.f
- if (mAspectRatio != 0.f)
- {
- mAspectRatio = llclamp(mAspectRatio, 0.2f, 5.f);
- gSavedSettings.setF32("FullScreenAspectRatio", mAspectRatio);
- }
- // Screen resolution
- S32 num_resolutions;
- LLWindow::LLWindowResolution* resolutions =
- gWindowp->getSupportedResolutions(num_resolutions);
- S32 res_idx = mCtrlFullScreen->getCurrentIndex();
- if (res_idx >= 0 && res_idx < num_resolutions)
- {
- S32 width = resolutions[res_idx].mWidth;
- S32 height = resolutions[res_idx].mHeight;
- S32 old_width = gSavedSettings.getS32("FullScreenWidth");
- S32 old_height = gSavedSettings.getS32("FullScreenHeight");
- if (old_width != width)
- {
- gSavedSettings.setS32("FullScreenWidth", width);
- if (want_full_screen && full_screen)
- {
- after_restart = true;
- }
- }
- if (old_height != height)
- {
- gSavedSettings.setS32("FullScreenHeight", height);
- if (want_full_screen && full_screen)
- {
- after_restart = true;
- }
- }
- }
- gViewerWindowp->requestResolutionUpdate();
- send_agent_update(true);
- // GPU/GL features sub-tab
- if (gSavedSettings.getBool("RenderGLCoreProfile") != mRenderGLCoreProfile)
- {
- after_restart = true;
- }
- if (gSavedSettings.getU32("RenderFSAASamples") != mFSAASamples)
- {
- after_restart = true;
- }
- if (gSavedSettings.getBool("RenderAnisotropic") != mUseAniso)
- {
- restart_display = true;
- }
- if (gSavedSettings.getS32("GLWorkerThreads") != mGLWorkerThreads)
- {
- restart_display = true;
- }
- #if !LL_LINUX // Irrelevant setting for Linux
- if (gSavedSettings.getBool("RenderHiDPI") != mRenderHiDPI)
- {
- after_restart = true;
- }
- #endif
- // We do not support any more full screen <--> windowed mode changes during
- // sessions (and when in full screen mode, we do start it before displaying
- // the login screen), since those have always been prone to failures, black
- // screens and crashes. HB
- if (want_full_screen != full_screen)
- {
- after_restart = true;
- }
- // There are currently issues with core GL profile and display settings
- // changes, so require a restart instead for those. HB
- if (restart_display && LLRender::sGLCoreProfile)
- {
- restart_display = false;
- after_restart = true;
- }
- if (restart_display)
- {
- gViewerWindowp->restartDisplay();
- }
- if (after_restart)
- {
- gNotifications.add("InEffectAfterRestart");
- }
- // Update enable/disable
- refresh();
- }
- // Extract from strings of the form "<width> x <height>", e.g. "640 x 480".
- bool LLPrefsGraphicsImpl::extractSizeFromString(const std::string& instr,
- U32& width, U32& height)
- {
- try
- {
- std::cmatch what;
- const std::regex expression("([0-9]+) x ([0-9]+)");
- if (std::regex_match(instr.c_str(), what, expression))
- {
- width = atoi(what[1].first);
- height = atoi(what[2].first);
- return true;
- }
- }
- catch (std::regex_error& e)
- {
- llwarns << "Regex error: " << e.what() << llendl;
- }
- width = height = 0;
- return false;
- }
- void LLPrefsGraphicsImpl::applyWindowSize()
- {
- // Only apply the new window size in real time (i.e. without a restart)
- // when in windowed mode and when the user wants to change the size for
- // that mode. Changing the size (i.e. the resolution or scaling) while in
- // full screen mode most often fails with a black screen or worst, and if
- // the user did not ask for a size change for the windowed mode while we
- // are running in this mode, then we do not care. HB
- if (!(bool)mCtrlWindowed->get() || gWindowp->getFullscreen() ||
- // Check for bogus index (missing combo ?)
- mCtrlWindowSize->getCurrentIndex() == -1)
- {
- return;
- }
- U32 width = 0;
- U32 height = 0;
- std::string res_str = mCtrlWindowSize->getValue().asString();
- if (extractSizeFromString(res_str, width, height))
- {
- gViewerWindowp->resizeWindow(width, height);
- }
- }
- void LLPrefsGraphicsImpl::onChangeQuality(LLUICtrl* ctrl, void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- LLSliderCtrl* sldr = (LLSliderCtrl*)ctrl;
- if (self && sldr)
- {
- U32 set = (U32)sldr->getValueF32();
- gFeatureManager.setGraphicsLevel(set, true);
- self->refreshEnabledState();
- self->refresh();
- self->applyResolution();
- }
- }
- //static
- void LLPrefsGraphicsImpl::onTabChanged(void* data, bool)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- if (self && self->mTabContainer)
- {
- gSavedSettings.setS32("LastGraphicsPrefTab",
- self->mTabContainer->getCurrentPanelIndex());
- }
- }
- //static
- void LLPrefsGraphicsImpl::onOpenHelp(void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- if (!self) return;
- LLFloater* parentp = gFloaterViewp->getParentFloater(self);
- if (!parentp) return;
- gNotifications.add(parentp->contextualNotification("GraphicsPreferencesHelp"));
- }
- //static
- void LLPrefsGraphicsImpl::onCommitWindowedMode(LLUICtrl*, void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- if (self)
- {
- // Store the mode the user wants.
- gSavedSettings.setBool("FullScreen", !self->mCtrlWindowed->get());
- self->refresh();
- }
- }
- //static
- void LLPrefsGraphicsImpl::onCommitAutoDetectAspect(LLUICtrl* ctrl, void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- if (!self || !ctrl) return;
- bool auto_detect = ((LLCheckBoxCtrl*)ctrl)->get();
- if (auto_detect)
- {
- S32 numerator = 0;
- S32 denominator = 0;
- // Clear any aspect ratio override
- gWindowp->setNativeAspectRatio(0.f);
- fractionFromDecimal(gWindowp->getNativeAspectRatio(), numerator,
- denominator);
- std::string aspect;
- if (numerator != 0)
- {
- aspect = llformat("%d:%d", numerator, denominator);
- }
- else
- {
- aspect = llformat("%.3f", gWindowp->getNativeAspectRatio());
- }
- self->mCtrlAspectRatio->setLabel(aspect);
- F32 ratio = gWindowp->getNativeAspectRatio();
- gSavedSettings.setF32("FullScreenAspectRatio", ratio);
- }
- }
- //static
- void LLPrefsGraphicsImpl::onKeystrokeAspectRatio(LLLineEditor*, void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- if (self)
- {
- self->mCtrlAutoDetectAspect->set(false);
- }
- }
- //static
- void LLPrefsGraphicsImpl::onSelectAspectRatio(LLUICtrl*, void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- if (self)
- {
- self->mCtrlAutoDetectAspect->set(false);
- }
- }
- //static
- void LLPrefsGraphicsImpl::fractionFromDecimal(F32 decimal_val, S32& numerator,
- S32& denominator)
- {
- numerator = 0;
- denominator = 0;
- for (F32 test_denominator = 1.f; test_denominator < 30.f;
- test_denominator += 1.f)
- {
- if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
- {
- numerator = ll_round(decimal_val * test_denominator);
- denominator = ll_round(test_denominator);
- break;
- }
- }
- }
- //static
- void LLPrefsGraphicsImpl::onCommitNeedsRefresh(LLUICtrl*, void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- if (self)
- {
- self->refreshEnabledState();
- }
- }
- //static
- void LLPrefsGraphicsImpl::onCommitAvatarPhysics(LLUICtrl* ctrl, void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (!self || !check) return;
- bool enabled = check->get();
- self->childSetEnabled("AvatarPhysicsLOD", enabled);
- }
- //static
- void LLPrefsGraphicsImpl::onCommitMaxNonImpostors(LLUICtrl* ctrl, void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- LLSliderCtrl* slider = (LLSliderCtrl*)ctrl;
- if (!self || !slider) return;
- bool enabled = slider->getValue().asInteger() > 0;
- self->mCtrlMaximumComplexity->setEnabled(enabled);
- self->mCtrlSurfaceAreaLimit->setEnabled(enabled);
- self->mCtrlGeometryBytesLimit->setEnabled(enabled);
- }
- void LLPrefsGraphicsImpl::setHardwareDefaults(void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- if (self)
- {
- gFeatureManager.applyRecommendedSettings();
- self->refreshEnabledState();
- self->refresh();
- }
- }
- void LLPrefsGraphicsImpl::updateSliderText(LLUICtrl* ctrl, void* data)
- {
- // Get our UI widgets
- LLTextBox* text_box = (LLTextBox*)data;
- LLSliderCtrl* slider = (LLSliderCtrl*)ctrl;
- if (!text_box || !slider)
- {
- return;
- }
- // Get range and points when text should change
- F32 range = slider->getMaxValue() - slider->getMinValue();
- llassert(range > 0);
- F32 midPoint = slider->getMinValue() + range / 3.f;
- F32 highPoint = slider->getMinValue() + (2.f / 3.f) * range;
- // Choose the right text
- if (slider->getValueF32() < midPoint)
- {
- text_box->setText("Low");
- }
- else if (slider->getValueF32() < highPoint)
- {
- text_box->setText("Mid");
- }
- else
- {
- text_box->setText("High");
- }
- }
- void LLPrefsGraphicsImpl::updateMeterText(LLUICtrl* ctrl, void* data)
- {
- // Get our UI widgets
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- LLSliderCtrl* slider = (LLSliderCtrl*)ctrl;
- if (self && ctrl)
- {
- // Toggle the two text boxes based on whether we have 1 or two digits
- F32 val = slider->getValueF32();
- bool two_digits = val < 100;
- self->mDrawDistanceMeterText1->setVisible(two_digits);
- self->mDrawDistanceMeterText2->setVisible(!two_digits);
- }
- }
- void LLPrefsGraphicsImpl::onClassicClouds(LLUICtrl* ctrl, void* data)
- {
- LLPrefsGraphicsImpl* self = (LLPrefsGraphicsImpl*)data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (self && check)
- {
- self->mSpinCloudsAltitude->setEnabled(check->get());
- }
- }
- //-----------------------------------------------------------------------------
- LLPrefsGraphics::LLPrefsGraphics()
- : impl(*new LLPrefsGraphicsImpl())
- {
- }
- LLPrefsGraphics::~LLPrefsGraphics()
- {
- delete &impl;
- }
- void LLPrefsGraphics::apply()
- {
- impl.apply();
- }
- void LLPrefsGraphics::cancel()
- {
- impl.cancel();
- }
- LLPanel* LLPrefsGraphics::getPanel()
- {
- return &impl;
- }
- //static
- void LLPrefsGraphics::refresh()
- {
- sNeedsRefresh = true;
- }
|