Track and log CP commands 0x00/0x10/0x20 differently from other unknown commands

They appear to relate to perf queries, and combining them with truely unknown commands would probably hide useful information.  Furthermore, 0x20 is issued by every title, so without this every title would be recorded as using an unknown command, which is very unhelpful.
This commit is contained in:
Pokechu22 2021-03-26 19:37:51 -07:00
parent 193f6a67a7
commit cde6cf2ab5
4 changed files with 24 additions and 1 deletions

View File

@ -133,7 +133,7 @@ void DolphinAnalytics::ReportGameStart()
}
// Keep in sync with enum class GameQuirk definition.
constexpr std::array<const char*, 18> GAME_QUIRKS_NAMES{
constexpr std::array<const char*, 19> GAME_QUIRKS_NAMES{
"icache-matters",
"directly-reads-wiimote-input",
"uses-DVDLowStopLaser",
@ -152,6 +152,7 @@ constexpr std::array<const char*, 18> GAME_QUIRKS_NAMES{
"uses-unknown-cp-command",
"uses-unknown-xf-command",
"uses-maybe-invalid-cp-command",
"uses-cp-perf-command",
};
static_assert(GAME_QUIRKS_NAMES.size() == static_cast<u32>(GameQuirk::COUNT),
"Game quirks names and enum definition are out of sync.");

View File

@ -69,6 +69,9 @@ enum class GameQuirk
USES_UNKNOWN_XF_COMMAND,
// YAGCD and Dolphin's implementation disagree about what is valid in some cases
USES_MAYBE_INVALID_CP_COMMAND,
// These commands are used by a few games (e.g. bug 12461), and seem to relate to perf queries.
// Track them separately.
USES_CP_PERF_COMMAND,
COUNT,
};

View File

@ -20,6 +20,13 @@ enum
// TODO: However, Dolphin's implementation (in LoadCPReg) and YAGCD disagree about what values are
// valid for the lower nybble.
// YAGCD mentions 0x20 as "?", and does not mention the others
// Libogc has 0x00 and 0x20, where 0x00 is tied to GX_ClearVCacheMetric and 0x20 related to
// cpPerfMode. 0x10 may be GX_SetVCacheMetric, but that function is empty. In any case, these all
// are probably for perf queries, and no title seems to actually need a full implementation.
UNKNOWN_00 = 0x00,
UNKNOWN_10 = 0x10,
UNKNOWN_20 = 0x20,
// YAGCD says 0x30 only; LoadCPReg allows any
MATINDEX_A = 0x30,
// YAGCD says 0x40 only; LoadCPReg allows any

View File

@ -323,6 +323,18 @@ void LoadCPReg(u32 sub_cmd, u32 value, bool is_preprocess)
CPState* state = is_preprocess ? &g_preprocess_cp_state : &g_main_cp_state;
switch (sub_cmd & CP_COMMAND_MASK)
{
case UNKNOWN_00:
case UNKNOWN_10:
case UNKNOWN_20:
if (!(sub_cmd == UNKNOWN_20 && value == 0))
{
// All titles using libogc or the official SDK issue 0x20 with value=0 on startup
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_CP_PERF_COMMAND);
DEBUG_LOG_FMT(VIDEO, "Unknown CP command possibly relating to perf queries used: {:02x}",
sub_cmd);
}
break;
case MATINDEX_A:
if (sub_cmd != MATINDEX_A)
{