147 lines
4.4 KiB
C++
147 lines
4.4 KiB
C++
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include "core/game_settings.h"
|
|
#include "core/game_overrides.h"
|
|
|
|
#include <algorithm>
|
|
#include <cctype>
|
|
|
|
#include "common/logging/log.h"
|
|
#include "common/settings.h"
|
|
#include "video_core/renderer_base.h"
|
|
|
|
#if defined(__APPLE__)
|
|
#include <TargetConditionals.h>
|
|
#endif
|
|
|
|
namespace Core::GameSettings {
|
|
|
|
static GPUVendor GetGPU(const std::string& gpu_vendor_string) {
|
|
struct Entry { const char* name; GPUVendor vendor; };
|
|
static constexpr Entry GpuVendor[] = {
|
|
// NVIDIA
|
|
{"NVIDIA", GPUVendor::Nvidia},
|
|
{"Nouveau", GPUVendor::Nvidia},
|
|
{"NVK", GPUVendor::Nvidia},
|
|
{"Tegra", GPUVendor::Nvidia},
|
|
// AMD
|
|
{"AMD", GPUVendor::AMD},
|
|
{"RadeonSI", GPUVendor::AMD},
|
|
{"RADV", GPUVendor::AMD},
|
|
{"AMDVLK", GPUVendor::AMD},
|
|
{"R600", GPUVendor::AMD},
|
|
// Intel
|
|
{"Intel", GPUVendor::Intel},
|
|
{"ANV", GPUVendor::Intel},
|
|
{"i965", GPUVendor::Intel},
|
|
{"i915", GPUVendor::Intel},
|
|
{"OpenSWR", GPUVendor::Intel},
|
|
// Apple
|
|
{"Apple", GPUVendor::Apple},
|
|
{"MoltenVK", GPUVendor::Apple},
|
|
// Qualcomm / Adreno
|
|
{"Qualcomm", GPUVendor::Qualcomm},
|
|
{"Turnip", GPUVendor::Qualcomm},
|
|
// ARM / Mali
|
|
{"Mali", GPUVendor::ARM},
|
|
{"PanVK", GPUVendor::ARM},
|
|
// Imagination / PowerVR
|
|
{"PowerVR", GPUVendor::Imagination},
|
|
{"PVR", GPUVendor::Imagination},
|
|
// Microsoft / WARP / D3D12 GL
|
|
{"D3D12", GPUVendor::Microsoft},
|
|
{"Microsoft", GPUVendor::Microsoft},
|
|
{"WARP", GPUVendor::Microsoft},
|
|
};
|
|
|
|
for (const auto& entry : GpuVendor) {
|
|
if (gpu_vendor_string == entry.name) {
|
|
return entry.vendor;
|
|
}
|
|
}
|
|
|
|
std::string gpu = gpu_vendor_string;
|
|
std::transform(gpu.begin(), gpu.end(), gpu.begin(), [](unsigned char c){ return (char)std::tolower(c); });
|
|
if (gpu.find("geforce") != std::string::npos) {
|
|
return GPUVendor::Nvidia;
|
|
}
|
|
if (gpu.find("amd") != std::string::npos || gpu.find("radeon") != std::string::npos || gpu.find("ati") != std::string::npos) {
|
|
return GPUVendor::AMD;
|
|
}
|
|
if (gpu.find("intel") != std::string::npos) {
|
|
return GPUVendor::Intel;
|
|
}
|
|
if (gpu.find("apple") != std::string::npos) {
|
|
return GPUVendor::Apple;
|
|
}
|
|
if (gpu.find("qualcomm") != std::string::npos || gpu.find("adreno") != std::string::npos) {
|
|
return GPUVendor::Qualcomm;
|
|
}
|
|
if (gpu.find("mali") != std::string::npos) {
|
|
return GPUVendor::ARM;
|
|
}
|
|
|
|
return GPUVendor::Unknown;
|
|
}
|
|
|
|
static OS DetectOS() {
|
|
#if defined(_WIN32)
|
|
return OS::Windows;
|
|
#elif defined(__FIREOS__)
|
|
return OS::FireOS;
|
|
#elif defined(__ANDROID__)
|
|
return OS::Android;
|
|
#elif defined(__OHOS__)
|
|
return OS::HarmonyOS;
|
|
#elif defined(__HAIKU__)
|
|
return OS::HaikuOS;
|
|
#elif defined(__DragonFly__)
|
|
return OS::DragonFlyBSD;
|
|
#elif defined(__NetBSD__)
|
|
return OS::NetBSD;
|
|
#elif defined(__OpenBSD__)
|
|
return OS::OpenBSD;
|
|
#elif defined(_AIX)
|
|
return OS::AIX;
|
|
#elif defined(__managarm__)
|
|
return OS::Managarm;
|
|
#elif defined(__redox__)
|
|
return OS::RedoxOS;
|
|
#elif defined(__APPLE__) && defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
|
return OS::IOS;
|
|
#elif defined(__APPLE__)
|
|
return OS::MacOS;
|
|
#elif defined(__FreeBSD__)
|
|
return OS::FreeBSD;
|
|
#elif defined(__sun) && defined(__SVR4)
|
|
return OS::Solaris;
|
|
#elif defined(__linux__)
|
|
return OS::Linux;
|
|
#else
|
|
return OS::Unknown;
|
|
#endif
|
|
}
|
|
|
|
EnvironmentInfo DetectEnvironment(const VideoCore::RendererBase& renderer) {
|
|
EnvironmentInfo env{};
|
|
env.os = DetectOS();
|
|
env.vendor_string = renderer.GetDeviceVendor();
|
|
env.vendor = GetGPU(env.vendor_string);
|
|
return env;
|
|
}
|
|
|
|
void LoadEarlyOverrides(std::uint64_t program_id, const std::string& gpu_vendor, bool enabled) {
|
|
if (enabled && GameOverrides::OverridesFileExists()) {
|
|
GameOverrides::ApplyEarlyOverrides(program_id, gpu_vendor);
|
|
}
|
|
}
|
|
|
|
void LoadOverrides(std::uint64_t program_id, const VideoCore::RendererBase& renderer, bool enabled) {
|
|
if (enabled && GameOverrides::OverridesFileExists()) {
|
|
GameOverrides::ApplyLateOverrides(program_id, renderer);
|
|
}
|
|
}
|
|
|
|
} // namespace Core::GameSettings
|