Small cleanup + Fix memory base logged as 0

This commit is contained in:
Exzap 2023-07-27 21:45:00 +02:00
parent 6268a24a4b
commit 0f469eb2b9
5 changed files with 67 additions and 90 deletions

View File

@ -4,17 +4,16 @@
#include "Cafe/GameProfile/GameProfile.h" #include "Cafe/GameProfile/GameProfile.h"
#include "Cafe/HW/Espresso/Interpreter/PPCInterpreterInternal.h" #include "Cafe/HW/Espresso/Interpreter/PPCInterpreterInternal.h"
#include "Cafe/HW/Espresso/Recompiler/PPCRecompiler.h" #include "Cafe/HW/Espresso/Recompiler/PPCRecompiler.h"
#include "Cafe/HW/Espresso/Debugger/Debugger.h"
#include "Cafe/OS/RPL/rpl_symbol_storage.h"
#include "audio/IAudioAPI.h" #include "audio/IAudioAPI.h"
#include "audio/IAudioInputAPI.h" #include "audio/IAudioInputAPI.h"
#include "Cafe/HW/Espresso/Debugger/Debugger.h"
#include "config/ActiveSettings.h" #include "config/ActiveSettings.h"
#include "Cafe/TitleList/GameInfo.h" #include "Cafe/TitleList/GameInfo.h"
#include "util/helpers/SystemException.h"
#include "Cafe/GraphicPack/GraphicPack2.h" #include "Cafe/GraphicPack/GraphicPack2.h"
#include "util/helpers/SystemException.h"
#include "Common/cpu_features.h"
#include "input/InputManager.h" #include "input/InputManager.h"
#include "Cafe/CafeSystem.h" #include "Cafe/CafeSystem.h"
#include "Cafe/TitleList/TitleList.h" #include "Cafe/TitleList/TitleList.h"
#include "Cafe/TitleList/GameInfo.h" #include "Cafe/TitleList/GameInfo.h"
@ -22,14 +21,9 @@
#include "Cafe/OS/libs/snd_core/ax.h" #include "Cafe/OS/libs/snd_core/ax.h"
#include "Cafe/OS/RPL/rpl.h" #include "Cafe/OS/RPL/rpl.h"
#include "Cafe/HW/Latte/Core/Latte.h" #include "Cafe/HW/Latte/Core/Latte.h"
#include "Cafe/Filesystem/FST/FST.h" #include "Cafe/Filesystem/FST/FST.h"
#include "Common/FileStream.h" #include "Common/FileStream.h"
#include "GamePatch.h" #include "GamePatch.h"
#include <time.h>
#include "HW/Espresso/Debugger/GDBStub.h" #include "HW/Espresso/Debugger/GDBStub.h"
#include "Cafe/IOSU/legacy/iosu_ioctl.h" #include "Cafe/IOSU/legacy/iosu_ioctl.h"
@ -70,6 +64,15 @@
// dependency to be removed // dependency to be removed
#include "gui/guiWrapper.h" #include "gui/guiWrapper.h"
#include <time.h>
#if BOOST_OS_LINUX
#include <sys/sysinfo.h>
#elif BOOST_OS_MACOS
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
std::string _pathToExecutable; std::string _pathToExecutable;
std::string _pathToBaseExecutable; std::string _pathToBaseExecutable;
@ -441,6 +444,46 @@ namespace CafeSystem
GameInfo2 sGameInfo_ForegroundTitle; GameInfo2 sGameInfo_ForegroundTitle;
static void _CheckForWine()
{
#if BOOST_OS_WINDOWS
const HMODULE hmodule = GetModuleHandleA("ntdll.dll");
if (!hmodule)
return;
const auto pwine_get_version = (const char*(__cdecl*)())GetProcAddress(hmodule, "wine_get_version");
if (pwine_get_version)
{
cemuLog_log(LogType::Force, "Wine version: {}", pwine_get_version());
}
#endif
}
void logCPUAndMemoryInfo()
{
std::string cpuName = g_CPUFeatures.GetCPUName();
if (!cpuName.empty())
cemuLog_log(LogType::Force, "CPU: {}", cpuName);
#if BOOST_OS_WINDOWS
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
uint32 memoryInMB = (uint32)(statex.ullTotalPhys / 1024LL / 1024LL);
cemuLog_log(LogType::Force, "RAM: {}MB", memoryInMB);
#elif BOOST_OS_LINUX
struct sysinfo info {};
sysinfo(&info);
cemuLog_log(LogType::Force, "RAM: {}MB", ((static_cast<uint64_t>(info.totalram) * info.mem_unit) / 1024LL / 1024LL));
#elif BOOST_OS_MACOS
int64_t totalRam;
size_t size = sizeof(totalRam);
int result = sysctlbyname("hw.memsize", &totalRam, &size, NULL, 0);
if (result == 0)
cemuLog_log(LogType::Force, "RAM: {}MB", (totalRam / 1024LL / 1024LL));
#endif
}
// initialize all subsystems which are persistent and don't depend on a game running // initialize all subsystems which are persistent and don't depend on a game running
void Initialize() void Initialize()
{ {
@ -448,10 +491,19 @@ namespace CafeSystem
return; return;
s_initialized = true; s_initialized = true;
// init core systems // init core systems
cemuLog_log(LogType::Force, "------- Init {} -------", BUILD_VERSION_WITH_NAME_STRING);
fsc_init(); fsc_init();
memory_init(); memory_init();
cemuLog_log(LogType::Force, "Init Wii U memory space (base: 0x{:016x})", (size_t)memory_base);
PPCCore_init(); PPCCore_init();
RPLLoader_InitState(); RPLLoader_InitState();
cemuLog_log(LogType::Force, "mlc01 path: {}", _pathToUtf8(ActiveSettings::GetMlcPath()));
_CheckForWine();
// CPU and RAM info
logCPUAndMemoryInfo();
cemuLog_log(LogType::Force, "Used CPU extensions: {}", g_CPUFeatures.GetCommaSeparatedExtensionList());
// misc systems
rplSymbolStorage_init();
// allocate memory for all SysAllocators // allocate memory for all SysAllocators
// must happen before COS module init, but also before iosu::kernel::Initialize() // must happen before COS module init, but also before iosu::kernel::Initialize()
SysAllocatorContainer::GetInstance().Initialize(); SysAllocatorContainer::GetInstance().Initialize();

View File

@ -363,9 +363,6 @@ void OpenGLRenderer::NotifyLatteCommandProcessorIdle()
glFlush(); glFlush();
} }
bool IsRunningInWine();
void OpenGLRenderer::GetVendorInformation() void OpenGLRenderer::GetVendorInformation()
{ {
// example vendor strings: // example vendor strings:

View File

@ -179,7 +179,6 @@ std::vector<VulkanRenderer::DeviceInfo> VulkanRenderer::GetDevices()
} }
bool IsRunningInWine();
void VulkanRenderer::DetermineVendor() void VulkanRenderer::DetermineVendor()
{ {
VkPhysicalDeviceProperties2 properties{}; VkPhysicalDeviceProperties2 properties{};

View File

@ -34,8 +34,6 @@ std::string _GetTitleIdTypeStr(TitleId titleId)
return "Unknown"; return "Unknown";
} }
bool IsRunningInWine();
bool GameUpdateWindow::ParseUpdate(const fs::path& metaPath) bool GameUpdateWindow::ParseUpdate(const fs::path& metaPath)
{ {
m_title_info = TitleInfo(metaPath); m_title_info = TitleInfo(metaPath);
@ -130,16 +128,12 @@ bool GameUpdateWindow::ParseUpdate(const fs::path& metaPath)
} }
} }
// checking size is buggy on Wine (on Steam Deck this would return values too small to install bigger updates) - we therefore skip this step
if(!IsRunningInWine())
{
const fs::space_info targetSpace = fs::space(ActiveSettings::GetMlcPath()); const fs::space_info targetSpace = fs::space(ActiveSettings::GetMlcPath());
if (targetSpace.free <= m_required_size) if (targetSpace.free <= m_required_size)
{ {
auto string = wxStringFormat(_("Not enough space available.\nRequired: {0} MB\nAvailable: {1} MB"), L"%lld %lld", (m_required_size / 1024 / 1024), (targetSpace.free / 1024 / 1024)); auto string = wxStringFormat(_("Not enough space available.\nRequired: {0} MB\nAvailable: {1} MB"), L"%lld %lld", (m_required_size / 1024 / 1024), (targetSpace.free / 1024 / 1024));
throw std::runtime_error(string); throw std::runtime_error(string);
} }
}
return true; return true;
} }

View File

@ -3,7 +3,6 @@
#include "util/crypto/aes128.h" #include "util/crypto/aes128.h"
#include "gui/MainWindow.h" #include "gui/MainWindow.h"
#include "Cafe/OS/RPL/rpl.h" #include "Cafe/OS/RPL/rpl.h"
#include "Cafe/OS/RPL/rpl_symbol_storage.h"
#include "Cafe/OS/libs/gx2/GX2.h" #include "Cafe/OS/libs/gx2/GX2.h"
#include "Cafe/OS/libs/coreinit/coreinit_Thread.h" #include "Cafe/OS/libs/coreinit/coreinit_Thread.h"
#include "Cafe/HW/Latte/Core/LatteOverlay.h" #include "Cafe/HW/Latte/Core/LatteOverlay.h"
@ -60,66 +59,6 @@ std::atomic_bool g_isGPUInitFinished = false;
std::wstring executablePath; std::wstring executablePath;
void logCPUAndMemoryInfo()
{
std::string cpuName = g_CPUFeatures.GetCPUName();
if (!cpuName.empty())
cemuLog_log(LogType::Force, "CPU: {}", cpuName);
#if BOOST_OS_WINDOWS
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
uint32 memoryInMB = (uint32)(statex.ullTotalPhys / 1024LL / 1024LL);
cemuLog_log(LogType::Force, "RAM: {}MB", memoryInMB);
#elif BOOST_OS_LINUX
struct sysinfo info {};
sysinfo(&info);
cemuLog_log(LogType::Force, "RAM: {}MB", ((static_cast<uint64_t>(info.totalram) * info.mem_unit) / 1024LL / 1024LL));
#elif BOOST_OS_MACOS
int64_t totalRam;
size_t size = sizeof(totalRam);
int result = sysctlbyname("hw.memsize", &totalRam, &size, NULL, 0);
if (result == 0)
cemuLog_log(LogType::Force, "RAM: {}MB", (totalRam / 1024LL / 1024LL));
#endif
}
bool g_running_in_wine = false;
bool IsRunningInWine()
{
return g_running_in_wine;
}
void checkForWine()
{
#if BOOST_OS_WINDOWS
const HMODULE hmodule = GetModuleHandleA("ntdll.dll");
if (!hmodule)
return;
const auto pwine_get_version = (const char*(__cdecl*)())GetProcAddress(hmodule, "wine_get_version");
if (pwine_get_version)
{
g_running_in_wine = true;
cemuLog_log(LogType::Force, "Wine version: {}", pwine_get_version());
}
#else
g_running_in_wine = false;
#endif
}
void infoLog_cemuStartup()
{
cemuLog_log(LogType::Force, "------- Init {} -------", BUILD_VERSION_WITH_NAME_STRING);
cemuLog_log(LogType::Force, "Init Wii U memory space (base: 0x{:016x})", (size_t)memory_base);
cemuLog_log(LogType::Force, "mlc01 path: {}", _pathToUtf8(ActiveSettings::GetMlcPath()));
checkForWine();
// CPU and RAM info
logCPUAndMemoryInfo();
cemuLog_log(LogType::Force, "Used CPU extensions: {}", g_CPUFeatures.GetCommaSeparatedExtensionList());
}
// some implementations of _putenv dont copy the string and instead only store a pointer // some implementations of _putenv dont copy the string and instead only store a pointer
// thus we use a helper to keep a permanent copy // thus we use a helper to keep a permanent copy
std::vector<std::string*> sPutEnvMap; std::vector<std::string*> sPutEnvMap;
@ -189,16 +128,12 @@ void CemuCommonInit()
g_config.Load(); g_config.Load();
if (NetworkConfig::XMLExists()) if (NetworkConfig::XMLExists())
n_config.Load(); n_config.Load();
// symbol storage
rplSymbolStorage_init();
// parallelize expensive init code // parallelize expensive init code
std::future<int> futureInitAudioAPI = std::async(std::launch::async, []{ IAudioAPI::InitializeStatic(); IAudioInputAPI::InitializeStatic(); return 0; }); std::future<int> futureInitAudioAPI = std::async(std::launch::async, []{ IAudioAPI::InitializeStatic(); IAudioInputAPI::InitializeStatic(); return 0; });
std::future<int> futureInitGraphicPacks = std::async(std::launch::async, []{ GraphicPack2::LoadAll(); return 0; }); std::future<int> futureInitGraphicPacks = std::async(std::launch::async, []{ GraphicPack2::LoadAll(); return 0; });
InputManager::instance().load(); InputManager::instance().load();
futureInitAudioAPI.wait(); futureInitAudioAPI.wait();
futureInitGraphicPacks.wait(); futureInitGraphicPacks.wait();
// log Cemu startup info
infoLog_cemuStartup();
// init Cafe system // init Cafe system
CafeSystem::Initialize(); CafeSystem::Initialize();
// init title list // init title list