From fa3dddad4f1cadfeb4f0e09fe7d1bca14d54eea7 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 10 Jun 2003 23:50:31 +0000 Subject: [PATCH] On systems with less than 192 megs of memory, disable texture caching by default. --- stepmania/src/PrefsManager.cpp | 16 +++++++++++--- stepmania/src/PrefsManager.h | 3 +++ stepmania/src/StepMania.cpp | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index 756499bb89..706554b26c 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -112,8 +112,12 @@ PrefsManager::PrefsManager() m_bHiddenSongs = false; m_bVsync = true; - m_sVideoRenderers = ""; // StepMania.cpp sets this on first run - m_sSoundDrivers = DEFAULT_SOUND_DRIVER_LIST; + // StepMania.cpp sets these on first run: + m_sVideoRenderers = ""; +#if defined(WIN32) + m_iLastSeenMemory = 0; +#endif + m_fSoundVolume = DEFAULT_SOUND_VOLUME; /* This is experimental: let's see if preloading helps people's skipping. * If it doesn't do anything useful, it'll be removed. */ @@ -207,8 +211,11 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame ) ini.GetValueB( "Options", "UseUnlockSystem", m_bUseUnlockSystem ); ini.GetValueB( "Options", "FirstRun", m_bFirstRun ); ini.GetValueB( "Options", "AutoMapJoysticks", m_bAutoMapJoysticks ); - ini.GetValue ( "Options", "LastSeenVideoDriver", m_sLastSeenVideoDriver ); ini.GetValue ( "Options", "VideoRenderers", m_sVideoRenderers ); + ini.GetValue ( "Options", "LastSeenVideoDriver", m_sLastSeenVideoDriver ); +#if defined(WIN32) + ini.GetValue ( "Options", "LastSeenMemory", m_iLastSeenMemory ); +#endif ini.GetValueB( "Options", "AntiAliasing", m_bAntiAliasing ); m_asAdditionalSongFolders.clear(); @@ -299,6 +306,9 @@ void PrefsManager::SaveGlobalPrefsToDisk() ini.SetValueB( "Options", "AutoMapJoysticks", m_bAutoMapJoysticks ); ini.SetValue ( "Options", "VideoRenderers", m_sVideoRenderers ); ini.SetValue ( "Options", "LastSeenVideoDriver", m_sLastSeenVideoDriver ); +#if defined(WIN32) + ini.SetValue ( "Options", "LastSeenMemory", m_iLastSeenMemory ); +#endif ini.SetValueB( "Options", "AntiAliasing", m_bAntiAliasing ); /* Only write these if they aren't the default. This ensures that we can change diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index 17c631abd1..be8d537480 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -89,6 +89,9 @@ public: CString m_DWIPath; CString m_sLastSeenVideoDriver; +#if defined(WIN32) + int m_iLastSeenMemory; +#endif CString m_sVideoRenderers; bool m_bAntiAliasing; CString m_sSoundDrivers; diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index b22c445f23..3216e55604 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -215,6 +215,43 @@ static void BoostAppPri() #endif } +static void CheckSettings() +{ +#if defined(WIN32) + /* Has the amount of memory changed? */ + MEMORYSTATUS mem; + GlobalMemoryStatus(&mem); + + const int Memory = mem.dwTotalPhys / 1048576; + + if( PREFSMAN->m_iLastSeenMemory == Memory ) + return; + + LOG->Trace( "Memory changed from %i to %i; settings changed", PREFSMAN->m_iLastSeenMemory, Memory ); + PREFSMAN->m_iLastSeenMemory = Memory; + + /* Let's consider 128-meg systems low-memory, and 256-meg systems high-memory. + * Cut off at 192. This is somewhat conservative; many 128-meg systems can + * deal with higher memory profile settings, but some can't. + * + * Actually, Windows lops off a meg or two; cut off a little lower to treat + * 192-meg systems as high-memory. */ + const bool HighMemory = (Memory >= 190); + + /* Two memory-consuming features that we can disable are texture caching and + * preloaded banners. Texture caching can use a lot of memory; disable it for + * low-memory systems. */ + PREFSMAN->m_bDelayedTextureDelete = HighMemory; + + /* Preloaded banners takes about 9k per song. That adds up with a lot of songs, + * though it's smaller than the actual song data that we preload anyway. Maybe + * we should disable it for 64-meg systems? */ + // PREFSMAN->m_bPreloadBanners = !LowMemory; + + PREFSMAN->SaveGlobalPrefsToDisk(); +#endif +} + #if defined(WIN32) #include "RageDisplay_D3D.h" #endif @@ -438,9 +475,12 @@ int main(int argc, char* argv[]) SONGMAN = new SongManager( loading_window ); // this takes a long time to load delete loading_window; // destroy this before init'ing Display + /* XXX: Why do we reload global prefs? PREFSMAN loads them in the ctor. -glenn */ PREFSMAN->ReadGlobalPrefsFromDisk( true ); PREFSMAN->ReadGamePrefsFromDisk(); + CheckSettings(); + DISPLAY = CreateDisplay(); TEXTUREMAN = new RageTextureManager(); TEXTUREMAN->SetPrefs(