summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r--indra/newview/llappviewer.cpp94
1 files changed, 73 insertions, 21 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 08b7b439e8..804462504b 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -131,13 +131,17 @@
#include "stringize.h"
#include "llcoros.h"
#include "llexception.h"
-#if !LL_LINUX
+#if LL_DARWIN || LL_LINUX || __FreeBSD__
#include "cef/dullahan_version.h"
+#endif
#include "vlc/libvlc_version.h"
-#endif // LL_LINUX
#if LL_DARWIN
+#if LL_SDL
+#include "llwindowsdl.h"
+#else
#include "llwindowmacosx.h"
+#endif // LL_SDL
#endif
// Third party library includes
@@ -250,6 +254,8 @@ using namespace LL;
#include "llcoproceduremanager.h"
#include "llviewereventrecorder.h"
+#include <chrono>
+
// *FIX: These extern globals should be cleaned up.
// The globals either represent state/config/resource-storage of either
// this app, or another 'component' of the viewer. App globals should be
@@ -264,9 +270,10 @@ using namespace LL;
// define a self-registering event API object
#include "llappviewerlistener.h"
-#if LL_LINUX && LL_GTK
-#include "glib.h"
-#endif // (LL_LINUX) && LL_GTK
+#if LL_MSVC
+// disable boost::lexical_cast warning
+#pragma warning (disable:4702)
+#endif
static LLAppViewerListener sAppViewerListener(LLAppViewer::instance);
@@ -305,6 +312,8 @@ S32 gLastExecDuration = -1; // (<0 indicates unknown)
# define LL_PLATFORM_KEY "mac"
#elif LL_LINUX
# define LL_PLATFORM_KEY "lnx"
+#elif __FreeBSD__
+# define LL_PLATFORM_KEY "bsd"
#else
# error "Unknown Platform"
#endif
@@ -380,6 +389,7 @@ static std::string gLaunchFileOnQuit;
// Used on Win32 for other apps to identify our window (eg, win_setup)
const char* const VIEWER_WINDOW_CLASSNAME = "Second Life";
+
//----------------------------------------------------------------------------
// List of entries from strings.xml to always replace
@@ -523,11 +533,13 @@ static void settings_to_globals()
{
LLSurface::setTextureSize(gSavedSettings.getU32("RegionTextureSize"));
-#if LL_DARWIN
+//#if LL_DARWIN
LLRender::sGLCoreProfile = true;
+/*
#else
LLRender::sGLCoreProfile = gSavedSettings.getBOOL("RenderGLContextCoreProfile");
#endif
+*/
LLRender::sNsightDebugSupport = gSavedSettings.getBOOL("RenderNsightDebugSupport");
LLImageGL::sGlobalUseAnisotropic = gSavedSettings.getBOOL("RenderAnisotropic");
LLImageGL::sCompressTextures = gSavedSettings.getBOOL("RenderCompressTextures");
@@ -554,7 +566,11 @@ static void settings_to_globals()
LLWorldMapView::setScaleSetting(gSavedSettings.getF32("MapScale"));
#if LL_DARWIN
+#if LL_SDL
+ LLWindowSDL::sUseMultGL = gSavedSettings.getBOOL("RenderAppleUseMultGL");
+#else
LLWindowMacOSX::sUseMultGL = gSavedSettings.getBOOL("RenderAppleUseMultGL");
+#endif // LL_SDL
gHiDPISupport = gSavedSettings.getBOOL("RenderHiDPI");
#endif
}
@@ -659,7 +675,7 @@ LLAppViewer::LLAppViewer()
// Need to do this initialization before we do anything else, since anything
// that touches files should really go through the lldir API
- gDirUtilp->initAppDirs("SecondLife");
+ gDirUtilp->initAppDirs("Megapahit");
//
// IMPORTANT! Do NOT put anything that will write
// into the log files during normal startup until AFTER
@@ -891,7 +907,7 @@ bool LLAppViewer::init()
std::string mime_types_name;
#if LL_DARWIN
mime_types_name = "mime_types_mac.xml";
-#elif LL_LINUX
+#elif LL_LINUX || __FreeBSD__
mime_types_name = "mime_types_linux.xml";
#else
mime_types_name = "mime_types.xml";
@@ -972,6 +988,7 @@ bool LLAppViewer::init()
return false;
}
+#if defined(__i386__) || defined(__x86_64__) || defined(__amd64__)
// Without SSE2 support we will crash almost immediately, warn here.
if (!gSysCPU.hasSSE2())
{
@@ -983,6 +1000,7 @@ bool LLAppViewer::init()
// quit immediately
return false;
}
+#endif
// alert the user if they are using unsupported hardware
if (!gSavedSettings.getBOOL("AlertedUnsupportedHardware"))
@@ -1137,7 +1155,7 @@ bool LLAppViewer::init()
gGLActive = false;
-#if LL_RELEASE_FOR_DOWNLOAD
+#if 0 // LL_RELEASE_FOR_DOWNLOAD && !LL_LINUX
// Skip updater if this is a non-interactive instance
if (!gSavedSettings.getBOOL("CmdLineSkipUpdater") && !gNonInteractive)
{
@@ -1370,6 +1388,14 @@ bool LLAppViewer::frame()
bool LLAppViewer::doFrame()
{
+ U32 fpsLimitMaxFps = (U32)gSavedSettings.getU32("MaxFPS");
+ if(fpsLimitMaxFps>120) fpsLimitMaxFps=0;
+
+ using TimePoint = std::chrono::steady_clock::time_point;
+
+ U64 fpsLimitSleepFor = 0;
+ TimePoint fpsLimitFrameStartTime = std::chrono::steady_clock::now();
+
LL_RECORD_BLOCK_TIME(FTM_FRAME);
{
// and now adjust the visuals from previous frame.
@@ -1540,6 +1566,18 @@ bool LLAppViewer::doFrame()
}
}
+ if(fpsLimitMaxFps > 0)
+ {
+ auto elapsed = std::chrono::steady_clock::now() - fpsLimitFrameStartTime;
+
+ long long fpsLimitFrameTime = std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count();
+ U64 desired_time_us = (U32)(1000000.f / fpsLimitMaxFps);
+ if((fpsLimitFrameTime+1000) < desired_time_us)
+ {
+ fpsLimitSleepFor = (desired_time_us - fpsLimitFrameTime - 1000) * 1.0;
+ }
+ }
+
{
LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df pauseMainloopTimeout");
pingMainloopTimeout("Main:Sleep");
@@ -1552,6 +1590,11 @@ bool LLAppViewer::doFrame()
//LL_RECORD_BLOCK_TIME(SLEEP2);
LL_PROFILE_ZONE_WARN("Sleep2");
+ if(fpsLimitSleepFor)
+ {
+ usleep(fpsLimitSleepFor);
+ }
+
// yield some time to the os based on command line option
static LLCachedControl<S32> yield_time(gSavedSettings, "YieldTime", -1);
if(yield_time >= 0)
@@ -1741,7 +1784,7 @@ bool LLAppViewer::cleanup()
// one because it happens just after mFastTimerLogThread is deleted. This
// comment is in case we guessed wrong, so we can move it here instead.
-#if LL_LINUX
+#if LL_LINUX || __FreeBSD__
// remove any old breakpad minidump files from the log directory
if (! isError())
{
@@ -2372,6 +2415,14 @@ void LLAppViewer::initLoggingAndGetLastDuration()
{
LL_WARNS("MarkerFile") << duration_log_msg << LL_ENDL;
}
+
+ std::string user_data_path_cef_log = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "cef.log");
+ if (gDirUtilp->fileExists(user_data_path_cef_log))
+ {
+ std::string user_data_path_cef_old = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "cef.old");
+ LLFile::remove(user_data_path_cef_old, ENOENT);
+ LLFile::rename(user_data_path_cef_log, user_data_path_cef_old);
+ }
}
}
@@ -2998,9 +3049,10 @@ void LLAppViewer::initStrings()
std::string strings_path_full = gDirUtilp->findSkinnedFilenameBaseLang(LLDir::XUI, strings_file);
if (strings_path_full.empty() || !LLFile::isfile(strings_path_full))
{
+ std::string crash_reason;
if (strings_path_full.empty())
{
- LL_WARNS() << "The file '" << strings_file << "' is not found" << LL_ENDL;
+ crash_reason = "The file '" + strings_file + "' is not found";
}
else
{
@@ -3008,24 +3060,23 @@ void LLAppViewer::initStrings()
int rc = LLFile::stat(strings_path_full, &st);
if (rc != 0)
{
- LL_WARNS() << "The file '" << strings_path_full << "' failed to get status. Error code: " << rc << LL_ENDL;
+ crash_reason = "The file '" + strings_path_full + "' failed to get status. Error code: " + std::to_string(rc);
}
else if (S_ISDIR(st.st_mode))
{
- LL_WARNS() << "The filename '" << strings_path_full << "' is a directory name" << LL_ENDL;
+ crash_reason = "The filename '" + strings_path_full + "' is a directory name";
}
else
{
- LL_WARNS() << "The filename '" << strings_path_full << "' doesn't seem to be a regular file name" << LL_ENDL;
+ crash_reason = "The filename '" + strings_path_full + "' doesn't seem to be a regular file name";
}
}
// initial check to make sure files are there failed
gDirUtilp->dumpCurrentDirectories(LLError::LEVEL_WARN);
LLError::LLUserWarningMsg::showMissingFiles();
- LL_ERRS() << "Viewer failed to find localization and UI files."
- << " Please reinstall viewer from https://secondlife.com/support/downloads"
- << " and contact https://support.secondlife.com if issue persists after reinstall." << LL_ENDL;
+ LL_ERRS() << "Viewer failed to open some of localization and UI files."
+ << " " << crash_reason << "." << LL_ENDL;
}
LLTransUtil::parseStrings(strings_file, default_trans_args);
LLTransUtil::parseLanguageStrings("language_settings.xml");
@@ -3386,7 +3437,7 @@ LLSD LLAppViewer::getViewerInfo() const
info["VOICE_VERSION"] = LLTrans::getString("NotConnected");
}
-#if !LL_LINUX
+#if LL_DARWIN || LL_LINUX || __FreeBSD__
std::ostringstream cef_ver_codec;
cef_ver_codec << "Dullahan: ";
cef_ver_codec << DULLAHAN_VERSION_MAJOR;
@@ -3416,7 +3467,7 @@ LLSD LLAppViewer::getViewerInfo() const
info["LIBCEF_VERSION"] = "Undefined";
#endif
-#if !LL_LINUX
+//#if !LL_LINUX
std::ostringstream vlc_ver_codec;
vlc_ver_codec << LIBVLC_VERSION_MAJOR;
vlc_ver_codec << ".";
@@ -3424,9 +3475,11 @@ LLSD LLAppViewer::getViewerInfo() const
vlc_ver_codec << ".";
vlc_ver_codec << LIBVLC_VERSION_REVISION;
info["LIBVLC_VERSION"] = vlc_ver_codec.str();
+/*
#else
info["LIBVLC_VERSION"] = "Undefined";
#endif
+*/
S32 packets_in = (S32)LLViewerStats::instance().getRecording().getSum(LLStatViewer::PACKETS_IN);
if (packets_in > 0)
@@ -5459,7 +5512,7 @@ void LLAppViewer::forceErrorBreakpoint()
LL_WARNS() << "Forcing a deliberate breakpoint" << LL_ENDL;
#ifdef LL_WINDOWS
DebugBreak();
-#else
+#elif __i386__ || __x86_64__
asm ("int $3");
#endif
return;
@@ -5712,4 +5765,3 @@ void LLAppViewer::metricsSend(bool enable_reporting)
// resolution in time.
gViewerAssetStats->restart();
}
-