2021-12-09 17:25:59 -08:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
2020-09-15 03:13:10 -07:00
|
|
|
#include "Core/DolphinAnalytics.h"
|
2017-02-08 22:15:43 -05:00
|
|
|
|
2019-06-03 19:25:01 -04:00
|
|
|
#include <array>
|
2016-06-18 02:43:59 +02:00
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
2018-10-27 04:59:08 +02:00
|
|
|
#include <vector>
|
2016-06-18 02:43:59 +02:00
|
|
|
|
2019-10-20 07:35:11 -04:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
#if defined(_WIN32)
|
2023-01-17 01:23:44 -08:00
|
|
|
#include <Windows.h>
|
|
|
|
#include "Common/WindowsRegistry.h"
|
2016-06-18 02:43:59 +02:00
|
|
|
#elif defined(__APPLE__)
|
2020-06-29 00:37:50 -04:00
|
|
|
#include <objc/message.h>
|
2018-08-19 17:38:29 -04:00
|
|
|
#elif defined(ANDROID)
|
|
|
|
#include <functional>
|
|
|
|
#include "Common/AndroidAnalytics.h"
|
2016-06-18 02:43:59 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Common/Analytics.h"
|
|
|
|
#include "Common/CPUDetect.h"
|
|
|
|
#include "Common/CommonTypes.h"
|
2020-07-20 11:22:53 +02:00
|
|
|
#include "Common/Config/Config.h"
|
2022-07-23 22:45:10 -07:00
|
|
|
#include "Common/Crypto/SHA1.h"
|
2018-05-21 15:48:17 +02:00
|
|
|
#include "Common/Random.h"
|
2018-10-27 04:59:08 +02:00
|
|
|
#include "Common/Timer.h"
|
2017-09-09 15:52:35 -04:00
|
|
|
#include "Common/Version.h"
|
2019-03-02 22:41:50 -06:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2016-06-18 02:43:59 +02:00
|
|
|
#include "Core/ConfigManager.h"
|
2016-06-21 01:21:32 +12:00
|
|
|
#include "Core/HW/GCPad.h"
|
2016-06-18 02:43:59 +02:00
|
|
|
#include "Core/Movie.h"
|
|
|
|
#include "Core/NetPlayProto.h"
|
2024-01-13 13:14:48 +01:00
|
|
|
#include "Core/System.h"
|
2016-06-21 01:21:32 +12:00
|
|
|
#include "InputCommon/GCAdapter.h"
|
|
|
|
#include "InputCommon/InputConfig.h"
|
2016-06-19 16:36:18 +02:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2016-06-18 02:43:59 +02:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2019-06-03 19:45:23 -04:00
|
|
|
constexpr char ANALYTICS_ENDPOINT[] = "https://analytics.dolphin-emu.org/report";
|
2016-06-18 02:43:59 +02:00
|
|
|
} // namespace
|
|
|
|
|
2018-08-19 17:38:29 -04:00
|
|
|
#if defined(ANDROID)
|
|
|
|
static std::function<std::string(std::string)> s_get_val_func;
|
|
|
|
void DolphinAnalytics::AndroidSetGetValFunc(std::function<std::string(std::string)> func)
|
|
|
|
{
|
|
|
|
s_get_val_func = std::move(func);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
DolphinAnalytics::DolphinAnalytics()
|
|
|
|
{
|
|
|
|
ReloadConfig();
|
|
|
|
MakeBaseBuilder();
|
|
|
|
}
|
|
|
|
|
2019-06-23 19:26:07 +02:00
|
|
|
DolphinAnalytics& DolphinAnalytics::Instance()
|
2016-06-18 02:43:59 +02:00
|
|
|
{
|
2019-06-23 19:26:07 +02:00
|
|
|
static DolphinAnalytics instance;
|
|
|
|
return instance;
|
2016-06-18 02:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinAnalytics::ReloadConfig()
|
|
|
|
{
|
2019-06-03 19:41:41 -04:00
|
|
|
std::lock_guard lk{m_reporter_mutex};
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// Install the HTTP backend if analytics support is enabled.
|
|
|
|
std::unique_ptr<Common::AnalyticsReportingBackend> new_backend;
|
2020-07-20 11:22:53 +02:00
|
|
|
if (Config::Get(Config::MAIN_ANALYTICS_ENABLED))
|
2016-06-18 02:43:59 +02:00
|
|
|
{
|
2018-08-19 17:38:29 -04:00
|
|
|
#if defined(ANDROID)
|
|
|
|
new_backend = std::make_unique<Common::AndroidAnalyticsBackend>(ANALYTICS_ENDPOINT);
|
|
|
|
#else
|
2016-06-18 02:43:59 +02:00
|
|
|
new_backend = std::make_unique<Common::HttpAnalyticsBackend>(ANALYTICS_ENDPOINT);
|
2018-08-19 17:38:29 -04:00
|
|
|
#endif
|
2016-06-18 02:43:59 +02:00
|
|
|
}
|
|
|
|
m_reporter.SetBackend(std::move(new_backend));
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// Load the unique ID or generate it if needed.
|
2020-07-20 11:22:53 +02:00
|
|
|
m_unique_id = Config::Get(Config::MAIN_ANALYTICS_ID);
|
2016-06-18 02:43:59 +02:00
|
|
|
if (m_unique_id.empty())
|
|
|
|
{
|
|
|
|
GenerateNewIdentity();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinAnalytics::GenerateNewIdentity()
|
|
|
|
{
|
2018-06-14 10:26:11 -04:00
|
|
|
const u64 id_high = Common::Random::GenerateValue<u64>();
|
|
|
|
const u64 id_low = Common::Random::GenerateValue<u64>();
|
2019-10-20 07:35:11 -04:00
|
|
|
m_unique_id = fmt::format("{:016x}{:016x}", id_high, id_low);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// Save the new id in the configuration.
|
2020-07-20 11:22:53 +02:00
|
|
|
Config::SetBase(Config::MAIN_ANALYTICS_ID, m_unique_id);
|
|
|
|
Config::Save();
|
2016-06-18 02:43:59 +02:00
|
|
|
}
|
|
|
|
|
2019-06-03 19:37:33 -04:00
|
|
|
std::string DolphinAnalytics::MakeUniqueId(std::string_view data) const
|
2016-06-18 02:43:59 +02:00
|
|
|
{
|
2019-06-03 19:35:26 -04:00
|
|
|
const auto input = std::string{m_unique_id}.append(data);
|
2022-07-23 22:45:10 -07:00
|
|
|
const auto digest = Common::SHA1::CalculateDigest(input);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// Convert to hex string and truncate to 64 bits.
|
|
|
|
std::string out;
|
|
|
|
for (int i = 0; i < 8; ++i)
|
|
|
|
{
|
2019-10-20 07:35:11 -04:00
|
|
|
out += fmt::format("{:02x}", digest[i]);
|
2016-06-18 02:43:59 +02:00
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2019-06-03 19:35:26 -04:00
|
|
|
void DolphinAnalytics::ReportDolphinStart(std::string_view ui_type)
|
2016-06-18 02:43:59 +02:00
|
|
|
{
|
|
|
|
Common::AnalyticsReportBuilder builder(m_base_builder);
|
|
|
|
builder.AddData("type", "dolphin-start");
|
|
|
|
builder.AddData("ui-type", ui_type);
|
|
|
|
builder.AddData("id", MakeUniqueId("dolphin-start"));
|
|
|
|
Send(builder);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinAnalytics::ReportGameStart()
|
|
|
|
{
|
|
|
|
MakePerGameBuilder();
|
|
|
|
|
|
|
|
Common::AnalyticsReportBuilder builder(m_per_game_builder);
|
|
|
|
builder.AddData("type", "game-start");
|
|
|
|
Send(builder);
|
2018-10-27 04:59:08 +02:00
|
|
|
|
2018-11-15 03:28:36 +01:00
|
|
|
// Reset per-game state.
|
|
|
|
m_reported_quirks.fill(false);
|
2018-10-27 04:59:08 +02:00
|
|
|
InitializePerformanceSampling();
|
|
|
|
}
|
|
|
|
|
2018-11-15 03:28:36 +01:00
|
|
|
// Keep in sync with enum class GameQuirk definition.
|
2024-08-18 13:54:53 +01:00
|
|
|
constexpr std::array<const char*, 34> GAME_QUIRKS_NAMES{
|
2021-03-07 15:42:10 -08:00
|
|
|
"directly-reads-wiimote-input",
|
|
|
|
"uses-DVDLowStopLaser",
|
|
|
|
"uses-DVDLowOffset",
|
|
|
|
"uses-DVDLowReadDiskBca",
|
|
|
|
"uses-DVDLowRequestDiscStatus",
|
|
|
|
"uses-DVDLowRequestRetryNumber",
|
|
|
|
"uses-DVDLowSerMeasControl",
|
|
|
|
"uses-different-partition-command",
|
|
|
|
"uses-di-interrupt-command",
|
|
|
|
"mismatched-gpu-texgens-between-xf-and-bp",
|
|
|
|
"mismatched-gpu-colors-between-xf-and-bp",
|
|
|
|
"uses-uncommon-wd-mode",
|
|
|
|
"uses-wd-unimplemented-ioctl",
|
|
|
|
"uses-unknown-bp-command",
|
|
|
|
"uses-unknown-cp-command",
|
|
|
|
"uses-unknown-xf-command",
|
|
|
|
"uses-maybe-invalid-cp-command",
|
2021-03-26 19:37:51 -07:00
|
|
|
"uses-cp-perf-command",
|
2021-08-01 03:40:06 +01:00
|
|
|
"uses-unimplemented-ax-command",
|
|
|
|
"uses-ax-initial-time-delay",
|
2024-08-18 13:54:53 +01:00
|
|
|
"uses-ax-wiimote-lowpass",
|
|
|
|
"uses-ax-wiimote-biquad",
|
2021-08-15 04:36:08 +01:00
|
|
|
"sets-xf-clipdisable-bit-0",
|
|
|
|
"sets-xf-clipdisable-bit-1",
|
|
|
|
"sets-xf-clipdisable-bit-2",
|
2022-05-17 13:42:31 -07:00
|
|
|
"mismatched-gpu-colors-between-cp-and-xf",
|
|
|
|
"mismatched-gpu-normals-between-cp-and-xf",
|
|
|
|
"mismatched-gpu-tex-coords-between-cp-and-xf",
|
2022-05-17 13:58:54 -07:00
|
|
|
"mismatched-gpu-matrix-indices-between-cp-and-xf",
|
2023-05-06 17:18:17 -07:00
|
|
|
"reads-bounding-box",
|
2024-04-01 21:37:11 -07:00
|
|
|
"invalid-position-component-format",
|
|
|
|
"invalid-normal-component-format",
|
|
|
|
"invalid-texture-coordinate-component-format",
|
|
|
|
"invalid-color-component-format",
|
2021-03-07 15:42:10 -08:00
|
|
|
};
|
2019-06-03 19:25:01 -04:00
|
|
|
static_assert(GAME_QUIRKS_NAMES.size() == static_cast<u32>(GameQuirk::COUNT),
|
2018-11-15 03:28:36 +01:00
|
|
|
"Game quirks names and enum definition are out of sync.");
|
|
|
|
|
|
|
|
void DolphinAnalytics::ReportGameQuirk(GameQuirk quirk)
|
|
|
|
{
|
|
|
|
u32 quirk_idx = static_cast<u32>(quirk);
|
|
|
|
|
|
|
|
// Only report once per run.
|
|
|
|
if (m_reported_quirks[quirk_idx])
|
|
|
|
return;
|
|
|
|
m_reported_quirks[quirk_idx] = true;
|
|
|
|
|
|
|
|
Common::AnalyticsReportBuilder builder(m_per_game_builder);
|
|
|
|
builder.AddData("type", "quirk");
|
|
|
|
builder.AddData("quirk", GAME_QUIRKS_NAMES[quirk_idx]);
|
|
|
|
Send(builder);
|
|
|
|
}
|
|
|
|
|
2018-10-27 04:59:08 +02:00
|
|
|
void DolphinAnalytics::ReportPerformanceInfo(PerformanceSample&& sample)
|
|
|
|
{
|
|
|
|
if (ShouldStartPerformanceSampling())
|
|
|
|
{
|
|
|
|
m_sampling_performance_info = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_sampling_performance_info)
|
|
|
|
{
|
|
|
|
m_performance_samples.emplace_back(std::move(sample));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_performance_samples.size() >= NUM_PERFORMANCE_SAMPLES_PER_REPORT)
|
|
|
|
{
|
|
|
|
std::vector<u32> speed_times_1000(m_performance_samples.size());
|
|
|
|
std::vector<u32> num_prims(m_performance_samples.size());
|
|
|
|
std::vector<u32> num_draw_calls(m_performance_samples.size());
|
|
|
|
for (size_t i = 0; i < m_performance_samples.size(); ++i)
|
|
|
|
{
|
|
|
|
speed_times_1000[i] = static_cast<u32>(m_performance_samples[i].speed_ratio * 1000);
|
|
|
|
num_prims[i] = m_performance_samples[i].num_prims;
|
|
|
|
num_draw_calls[i] = m_performance_samples[i].num_draw_calls;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The per game builder should already exist -- there is no way we can be reporting performance
|
|
|
|
// info without a game start event having been generated.
|
|
|
|
Common::AnalyticsReportBuilder builder(m_per_game_builder);
|
|
|
|
builder.AddData("type", "performance");
|
|
|
|
builder.AddData("speed", speed_times_1000);
|
|
|
|
builder.AddData("prims", num_prims);
|
|
|
|
builder.AddData("draw-calls", num_draw_calls);
|
|
|
|
|
|
|
|
Send(builder);
|
|
|
|
|
|
|
|
// Clear up and stop sampling until next time ShouldStartPerformanceSampling() says so.
|
|
|
|
m_performance_samples.clear();
|
|
|
|
m_sampling_performance_info = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinAnalytics::InitializePerformanceSampling()
|
|
|
|
{
|
|
|
|
m_performance_samples.clear();
|
|
|
|
m_sampling_performance_info = false;
|
|
|
|
|
|
|
|
u64 wait_us =
|
|
|
|
PERFORMANCE_SAMPLING_INITIAL_WAIT_TIME_SECS * 1000000 +
|
|
|
|
Common::Random::GenerateValue<u64>() % (PERFORMANCE_SAMPLING_WAIT_TIME_JITTER_SECS * 1000000);
|
2022-07-17 20:43:47 -07:00
|
|
|
m_sampling_next_start_us = Common::Timer::NowUs() + wait_us;
|
2018-10-27 04:59:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DolphinAnalytics::ShouldStartPerformanceSampling()
|
|
|
|
{
|
2022-07-17 20:43:47 -07:00
|
|
|
if (Common::Timer::NowUs() < m_sampling_next_start_us)
|
2018-10-27 04:59:08 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
u64 wait_us =
|
|
|
|
PERFORMANCE_SAMPLING_INTERVAL_SECS * 1000000 +
|
|
|
|
Common::Random::GenerateValue<u64>() % (PERFORMANCE_SAMPLING_WAIT_TIME_JITTER_SECS * 1000000);
|
2022-07-17 20:43:47 -07:00
|
|
|
m_sampling_next_start_us = Common::Timer::NowUs() + wait_us;
|
2018-10-27 04:59:08 +02:00
|
|
|
return true;
|
2016-06-18 02:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinAnalytics::MakeBaseBuilder()
|
|
|
|
{
|
|
|
|
Common::AnalyticsReportBuilder builder;
|
|
|
|
|
|
|
|
// Version information.
|
2022-01-14 00:04:22 +01:00
|
|
|
builder.AddData("version-desc", Common::GetScmDescStr());
|
|
|
|
builder.AddData("version-hash", Common::GetScmRevGitStr());
|
|
|
|
builder.AddData("version-branch", Common::GetScmBranchStr());
|
|
|
|
builder.AddData("version-dist", Common::GetScmDistributorStr());
|
2016-06-18 02:43:59 +02:00
|
|
|
|
2018-06-02 05:59:03 +02:00
|
|
|
// Auto-Update information.
|
2021-12-27 19:09:47 +01:00
|
|
|
builder.AddData("update-track", Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK));
|
2018-06-02 05:59:03 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// CPU information.
|
|
|
|
builder.AddData("cpu-summary", cpu_info.Summarize());
|
|
|
|
|
|
|
|
// OS information.
|
|
|
|
#if defined(_WIN32)
|
|
|
|
builder.AddData("os-type", "windows");
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2023-01-17 01:23:44 -08:00
|
|
|
const auto winver = WindowsRegistry::GetOSVersion();
|
|
|
|
builder.AddData("win-ver-major", static_cast<u32>(winver.dwMajorVersion));
|
|
|
|
builder.AddData("win-ver-minor", static_cast<u32>(winver.dwMinorVersion));
|
|
|
|
builder.AddData("win-ver-build", static_cast<u32>(winver.dwBuildNumber));
|
2016-06-18 02:43:59 +02:00
|
|
|
#elif defined(ANDROID)
|
|
|
|
builder.AddData("os-type", "android");
|
2018-08-19 17:38:29 -04:00
|
|
|
builder.AddData("android-manufacturer", s_get_val_func("DEVICE_MANUFACTURER"));
|
|
|
|
builder.AddData("android-model", s_get_val_func("DEVICE_MODEL"));
|
|
|
|
builder.AddData("android-version", s_get_val_func("DEVICE_OS"));
|
2016-06-18 02:43:59 +02:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
builder.AddData("os-type", "osx");
|
2021-01-16 20:31:48 -08:00
|
|
|
|
2020-06-29 00:37:50 -04:00
|
|
|
// id processInfo = [NSProcessInfo processInfo]
|
|
|
|
id processInfo = reinterpret_cast<id (*)(Class, SEL)>(objc_msgSend)(
|
|
|
|
objc_getClass("NSProcessInfo"), sel_getUid("processInfo"));
|
|
|
|
if (processInfo)
|
|
|
|
{
|
|
|
|
struct OSVersion // NSOperatingSystemVersion
|
|
|
|
{
|
|
|
|
s64 major_version; // NSInteger majorVersion
|
|
|
|
s64 minor_version; // NSInteger minorVersion
|
|
|
|
s64 patch_version; // NSInteger patchVersion
|
|
|
|
};
|
2021-01-16 20:31:48 -08:00
|
|
|
// Under arm64, we need to call objc_msgSend to recieve a struct.
|
|
|
|
// On x86_64, we need to explicitly call objc_msgSend_stret for a struct.
|
2024-01-23 16:51:31 -05:00
|
|
|
#ifdef _M_ARM_64
|
2021-01-16 20:31:48 -08:00
|
|
|
#define msgSend objc_msgSend
|
|
|
|
#else
|
|
|
|
#define msgSend objc_msgSend_stret
|
|
|
|
#endif
|
2020-06-29 00:37:50 -04:00
|
|
|
// NSOperatingSystemVersion version = [processInfo operatingSystemVersion]
|
2021-01-16 20:31:48 -08:00
|
|
|
OSVersion version = reinterpret_cast<OSVersion (*)(id, SEL)>(msgSend)(
|
2020-06-29 00:37:50 -04:00
|
|
|
processInfo, sel_getUid("operatingSystemVersion"));
|
2021-01-16 20:31:48 -08:00
|
|
|
#undef msgSend
|
2020-06-29 00:37:50 -04:00
|
|
|
builder.AddData("osx-ver-major", version.major_version);
|
|
|
|
builder.AddData("osx-ver-minor", version.minor_version);
|
|
|
|
builder.AddData("osx-ver-bugfix", version.patch_version);
|
|
|
|
}
|
2016-06-18 02:43:59 +02:00
|
|
|
#elif defined(__linux__)
|
|
|
|
builder.AddData("os-type", "linux");
|
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
builder.AddData("os-type", "freebsd");
|
2020-12-20 22:32:07 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
builder.AddData("os-type", "openbsd");
|
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
builder.AddData("os-type", "netbsd");
|
|
|
|
#elif defined(__HAIKU__)
|
|
|
|
builder.AddData("os-type", "haiku");
|
2016-06-18 02:43:59 +02:00
|
|
|
#else
|
|
|
|
builder.AddData("os-type", "unknown");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_base_builder = builder;
|
|
|
|
}
|
|
|
|
|
2018-03-16 23:10:22 +10:00
|
|
|
static const char* GetShaderCompilationMode(const VideoConfig& video_config)
|
2017-07-30 19:45:28 +08:00
|
|
|
{
|
2018-03-16 23:10:22 +10:00
|
|
|
switch (video_config.iShaderCompilationMode)
|
2018-03-01 18:03:24 +10:00
|
|
|
{
|
2018-03-16 23:10:22 +10:00
|
|
|
case ShaderCompilationMode::AsynchronousUberShaders:
|
|
|
|
return "async-ubershaders";
|
|
|
|
case ShaderCompilationMode::AsynchronousSkipRendering:
|
|
|
|
return "async-skip-rendering";
|
|
|
|
case ShaderCompilationMode::SynchronousUberShaders:
|
|
|
|
return "sync-ubershaders";
|
|
|
|
case ShaderCompilationMode::Synchronous:
|
2018-03-01 18:03:24 +10:00
|
|
|
default:
|
2018-03-16 23:10:22 +10:00
|
|
|
return "sync";
|
2018-03-01 18:03:24 +10:00
|
|
|
}
|
2017-07-30 19:45:28 +08:00
|
|
|
}
|
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
void DolphinAnalytics::MakePerGameBuilder()
|
|
|
|
{
|
|
|
|
Common::AnalyticsReportBuilder builder(m_base_builder);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// Gameid.
|
2016-10-29 14:42:43 +02:00
|
|
|
builder.AddData("gameid", SConfig::GetInstance().GetGameID());
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// Unique id bound to the gameid.
|
2016-10-29 14:42:43 +02:00
|
|
|
builder.AddData("id", MakeUniqueId(SConfig::GetInstance().GetGameID()));
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// Configuration.
|
2021-10-13 20:29:04 -04:00
|
|
|
builder.AddData("cfg-dsp-hle", Config::Get(Config::MAIN_DSP_HLE));
|
|
|
|
builder.AddData("cfg-dsp-jit", Config::Get(Config::MAIN_DSP_JIT));
|
|
|
|
builder.AddData("cfg-dsp-thread", Config::Get(Config::MAIN_DSP_THREAD));
|
2022-01-07 03:50:18 +01:00
|
|
|
builder.AddData("cfg-cpu-thread", Config::Get(Config::MAIN_CPU_THREAD));
|
2022-01-06 01:51:29 +01:00
|
|
|
builder.AddData("cfg-fastmem", Config::Get(Config::MAIN_FASTMEM));
|
2022-01-07 06:41:41 +01:00
|
|
|
builder.AddData("cfg-syncgpu", Config::Get(Config::MAIN_SYNC_GPU));
|
2021-10-13 20:29:04 -04:00
|
|
|
builder.AddData("cfg-audio-backend", Config::Get(Config::MAIN_AUDIO_BACKEND));
|
2021-12-25 21:52:50 +01:00
|
|
|
builder.AddData("cfg-oc-enable", Config::Get(Config::MAIN_OVERCLOCK_ENABLE));
|
|
|
|
builder.AddData("cfg-oc-factor", Config::Get(Config::MAIN_OVERCLOCK));
|
2019-03-02 22:41:50 -06:00
|
|
|
builder.AddData("cfg-render-to-main", Config::Get(Config::MAIN_RENDER_TO_MAIN));
|
2016-06-19 16:36:18 +02:00
|
|
|
if (g_video_backend)
|
|
|
|
{
|
|
|
|
builder.AddData("cfg-video-backend", g_video_backend->GetName());
|
|
|
|
}
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// Video configuration.
|
|
|
|
builder.AddData("cfg-gfx-multisamples", g_Config.iMultisamples);
|
|
|
|
builder.AddData("cfg-gfx-ssaa", g_Config.bSSAA);
|
|
|
|
builder.AddData("cfg-gfx-anisotropy", g_Config.iMaxAnisotropy);
|
|
|
|
builder.AddData("cfg-gfx-vsync", g_Config.bVSync);
|
2017-11-10 22:55:00 -05:00
|
|
|
builder.AddData("cfg-gfx-aspect-ratio", static_cast<int>(g_Config.aspect_mode));
|
2016-06-18 02:43:59 +02:00
|
|
|
builder.AddData("cfg-gfx-efb-access", g_Config.bEFBAccessEnable);
|
|
|
|
builder.AddData("cfg-gfx-efb-copy-format-changes", g_Config.bEFBEmulateFormatChanges);
|
|
|
|
builder.AddData("cfg-gfx-efb-copy-ram", !g_Config.bSkipEFBCopyToRam);
|
2017-06-25 22:23:47 -05:00
|
|
|
builder.AddData("cfg-gfx-xfb-copy-ram", !g_Config.bSkipXFBCopyToRam);
|
2018-11-07 11:30:51 +10:00
|
|
|
builder.AddData("cfg-gfx-defer-efb-copies", g_Config.bDeferEFBCopies);
|
2017-08-12 23:10:21 -05:00
|
|
|
builder.AddData("cfg-gfx-immediate-xfb", !g_Config.bImmediateXFB);
|
2016-06-18 02:43:59 +02:00
|
|
|
builder.AddData("cfg-gfx-efb-copy-scaled", g_Config.bCopyEFBScaled);
|
2017-11-02 21:35:09 +01:00
|
|
|
builder.AddData("cfg-gfx-internal-resolution", g_Config.iEFBScale);
|
2016-06-18 02:43:59 +02:00
|
|
|
builder.AddData("cfg-gfx-tc-samples", g_Config.iSafeTextureCache_ColorSamples);
|
2017-11-10 22:55:00 -05:00
|
|
|
builder.AddData("cfg-gfx-stereo-mode", static_cast<int>(g_Config.stereo_mode));
|
2024-08-15 17:20:00 +10:00
|
|
|
builder.AddData("cfg-gfx-stereo-per-eye-resolution-full",
|
|
|
|
g_Config.stereo_per_eye_resolution_full);
|
Video: implement color correction to match the NTSC and PAL color spaces (and gamma) that GC and Wii targeted.
To further increase the accuracy of the post process phase, I've added (scRGB) HDR support, which is necessary
to fully display the PAL and NTSC-J color spaces, and also to improve the quality of post process texture samplings and
do them in linear space instead of gamma space (which is very important when playing at low resolutions).
For SDR, the quality is also slightly increased, at least if any post process runs, as the buffer is now
R10G10B10A2 (on Vulkan, DX11 and DX12) if supported; previously it was R8G8B8A8 but the alpha bits were wasted.
Gamma correction is arguably the most important thing as Dolphin on Windows outputted in "sRGB" (implicitly)
as that's what Windows expects by default, though sRGB gamma is very different from the gamma commonly used
by video standards dating to the pre HDR era (roughly gamma 2.35).
Additionally, the addition of HDR support (which is pretty straight forward and minimal), added support for
our own custom AutoHDR shaders, which would allow us to achieve decent looking HDR in Dolphin games without
having to use SpecialK or Windows 11 AutoHDR. Both of which don't necessarily play nice with older games
with strongly different and simpler lighting. HDR should also be supported in Linux.
Development of my own AutoHDR shader is almost complete and will come next.
This has been carefully tested and there should be no regression in any of the different features that Dolphin
offers, like multisampling, stereo rendering, other post processes, etc etc.
Fixes: https://bugs.dolphin-emu.org/issues/8941
Co-authored-by: EndlesslyFlowering <EndlesslyFlowering@protonmail.com>
Co-authored-by: Dogway <lin_ares@hotmail.com>
2023-06-10 11:48:05 +03:00
|
|
|
builder.AddData("cfg-gfx-hdr", static_cast<int>(g_Config.bHDR));
|
2017-07-30 19:45:28 +08:00
|
|
|
builder.AddData("cfg-gfx-per-pixel-lighting", g_Config.bEnablePixelLighting);
|
2018-03-16 23:10:22 +10:00
|
|
|
builder.AddData("cfg-gfx-shader-compilation-mode", GetShaderCompilationMode(g_Config));
|
|
|
|
builder.AddData("cfg-gfx-wait-for-shaders", g_Config.bWaitForShadersBeforeStarting);
|
2017-07-30 19:45:28 +08:00
|
|
|
builder.AddData("cfg-gfx-fast-depth", g_Config.bFastDepthCalc);
|
|
|
|
builder.AddData("cfg-gfx-vertex-rounding", g_Config.UseVertexRounding());
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// GPU features.
|
|
|
|
if (g_Config.iAdapter < static_cast<int>(g_Config.backend_info.Adapters.size()))
|
|
|
|
{
|
|
|
|
builder.AddData("gpu-adapter", g_Config.backend_info.Adapters[g_Config.iAdapter]);
|
|
|
|
}
|
2016-06-20 23:54:44 +12:00
|
|
|
else if (!g_Config.backend_info.AdapterName.empty())
|
|
|
|
{
|
|
|
|
builder.AddData("gpu-adapter", g_Config.backend_info.AdapterName);
|
|
|
|
}
|
2016-06-18 02:43:59 +02:00
|
|
|
builder.AddData("gpu-has-exclusive-fullscreen",
|
|
|
|
g_Config.backend_info.bSupportsExclusiveFullscreen);
|
|
|
|
builder.AddData("gpu-has-dual-source-blend", g_Config.backend_info.bSupportsDualSourceBlend);
|
|
|
|
builder.AddData("gpu-has-primitive-restart", g_Config.backend_info.bSupportsPrimitiveRestart);
|
|
|
|
builder.AddData("gpu-has-geometry-shaders", g_Config.backend_info.bSupportsGeometryShaders);
|
|
|
|
builder.AddData("gpu-has-3d-vision", g_Config.backend_info.bSupports3DVision);
|
|
|
|
builder.AddData("gpu-has-early-z", g_Config.backend_info.bSupportsEarlyZ);
|
|
|
|
builder.AddData("gpu-has-binding-layout", g_Config.backend_info.bSupportsBindingLayout);
|
|
|
|
builder.AddData("gpu-has-bbox", g_Config.backend_info.bSupportsBBox);
|
2017-03-05 15:17:54 -08:00
|
|
|
builder.AddData("gpu-has-fragment-stores-and-atomics",
|
|
|
|
g_Config.backend_info.bSupportsFragmentStoresAndAtomics);
|
2016-06-18 02:43:59 +02:00
|
|
|
builder.AddData("gpu-has-gs-instancing", g_Config.backend_info.bSupportsGSInstancing);
|
|
|
|
builder.AddData("gpu-has-post-processing", g_Config.backend_info.bSupportsPostProcessing);
|
|
|
|
builder.AddData("gpu-has-palette-conversion", g_Config.backend_info.bSupportsPaletteConversion);
|
|
|
|
builder.AddData("gpu-has-clip-control", g_Config.backend_info.bSupportsClipControl);
|
|
|
|
builder.AddData("gpu-has-ssaa", g_Config.backend_info.bSupportsSSAA);
|
2023-01-02 23:17:02 -08:00
|
|
|
builder.AddData("gpu-has-logic-ops", g_Config.backend_info.bSupportsLogicOp);
|
2022-12-31 20:01:45 -08:00
|
|
|
builder.AddData("gpu-has-framebuffer-fetch", g_Config.backend_info.bSupportsFramebufferFetch);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
// NetPlay / recording.
|
|
|
|
builder.AddData("netplay", NetPlay::IsNetPlayRunning());
|
2024-01-13 13:14:48 +01:00
|
|
|
builder.AddData("movie", Core::System::GetInstance().GetMovie().IsMovieActive());
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-21 01:21:32 +12:00
|
|
|
// Controller information
|
2016-06-22 01:33:53 +12:00
|
|
|
// We grab enough to tell what percentage of our users are playing with keyboard/mouse, some kind
|
2022-12-31 19:45:42 -08:00
|
|
|
// of gamepad, or the official GameCube adapter.
|
2018-07-17 22:31:18 +02:00
|
|
|
builder.AddData("gcadapter-detected", GCAdapter::IsDetected(nullptr));
|
2016-06-22 01:33:53 +12:00
|
|
|
builder.AddData("has-controller", Pad::GetConfig()->IsControllerControlledByGamepadDevice(0) ||
|
2018-07-17 22:31:18 +02:00
|
|
|
GCAdapter::IsDetected(nullptr));
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2016-06-18 02:43:59 +02:00
|
|
|
m_per_game_builder = builder;
|
|
|
|
}
|