summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-04-07 01:46:21 +0200
committerGitHub <noreply@github.com>2021-04-07 01:46:21 +0200
commitf18743ab8976d8361da82ddef3c406426d8d2a66 (patch)
tree03369063cd7e5c5ed7dec15432f46b2628e509a4 /Source/Core/VideoCommon
parentc1617460a182f5ea8579e5604a999dcf0734c2ce (diff)
parentf32b771f7ad81b2e128a4265f797eddba2e99427 (diff)
Merge pull request #9576 from Pokechu22/invalid-gfx-reg-quirk
Add game quirks for unknown BP/CP/XF commands
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/BPStructs.cpp3
-rw-r--r--Source/Core/VideoCommon/CPMemory.h7
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.cpp60
-rw-r--r--Source/Core/VideoCommon/XFMemory.h22
-rw-r--r--Source/Core/VideoCommon/XFStructs.cpp7
5 files changed, 89 insertions, 10 deletions
diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp
index 2ad90a350a..699b92ce17 100644
--- a/Source/Core/VideoCommon/BPStructs.cpp
+++ b/Source/Core/VideoCommon/BPStructs.cpp
@@ -12,8 +12,10 @@
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
+
#include "Core/ConfigManager.h"
#include "Core/CoreTiming.h"
+#include "Core/DolphinAnalytics.h"
#include "Core/FifoPlayer/FifoPlayer.h"
#include "Core/FifoPlayer/FifoRecorder.h"
#include "Core/HW/Memmap.h"
@@ -704,6 +706,7 @@ static void BPWritten(const BPCmd& bp)
break;
}
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_BP_COMMAND);
WARN_LOG_FMT(VIDEO, "Unknown BP opcode: address = {:#010x} value = {:#010x}", bp.address,
bp.newvalue);
}
diff --git a/Source/Core/VideoCommon/CPMemory.h b/Source/Core/VideoCommon/CPMemory.h
index 2ede79578b..f54445940f 100644
--- a/Source/Core/VideoCommon/CPMemory.h
+++ b/Source/Core/VideoCommon/CPMemory.h
@@ -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
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp
index 8a2eba09b4..94a331a0d2 100644
--- a/Source/Core/VideoCommon/VertexLoaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp
@@ -16,6 +16,8 @@
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
+
+#include "Core/DolphinAnalytics.h"
#include "Core/HW/Memmap.h"
#include "VideoCommon/BPMemory.h"
@@ -321,23 +323,71 @@ 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)
+ {
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_MAYBE_INVALID_CP_COMMAND);
+ WARN_LOG_FMT(VIDEO,
+ "CP MATINDEX_A: an exact value of {:02x} was expected "
+ "but instead a value of {:02x} was seen",
+ MATINDEX_A, sub_cmd);
+ }
+
if (update_global_state)
VertexShaderManager::SetTexMatrixChangedA(value);
break;
case MATINDEX_B:
+ if (sub_cmd != MATINDEX_B)
+ {
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_MAYBE_INVALID_CP_COMMAND);
+ WARN_LOG_FMT(VIDEO,
+ "CP MATINDEX_B: an exact value of {:02x} was expected "
+ "but instead a value of {:02x} was seen",
+ MATINDEX_B, sub_cmd);
+ }
+
if (update_global_state)
VertexShaderManager::SetTexMatrixChangedB(value);
break;
case VCD_LO:
+ if (sub_cmd != VCD_LO) // Stricter than YAGCD
+ {
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_MAYBE_INVALID_CP_COMMAND);
+ WARN_LOG_FMT(VIDEO,
+ "CP VCD_LO: an exact value of {:02x} was expected "
+ "but instead a value of {:02x} was seen",
+ VCD_LO, sub_cmd);
+ }
+
state->vtx_desc.low.Hex = value;
state->attr_dirty = BitSet32::AllTrue(CP_NUM_VAT_REG);
state->bases_dirty = true;
break;
case VCD_HI:
+ if (sub_cmd != VCD_HI) // Stricter than YAGCD
+ {
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_MAYBE_INVALID_CP_COMMAND);
+ WARN_LOG_FMT(VIDEO,
+ "CP VCD_HI: an exact value of {:02x} was expected "
+ "but instead a value of {:02x} was seen",
+ VCD_HI, sub_cmd);
+ }
+
state->vtx_desc.high.Hex = value;
state->attr_dirty = BitSet32::AllTrue(CP_NUM_VAT_REG);
state->bases_dirty = true;
@@ -345,21 +395,30 @@ void LoadCPReg(u32 sub_cmd, u32 value, bool is_preprocess)
case CP_VAT_REG_A:
if ((sub_cmd - CP_VAT_REG_A) >= CP_NUM_VAT_REG)
+ {
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_MAYBE_INVALID_CP_COMMAND);
WARN_LOG_FMT(VIDEO, "CP_VAT_REG_A: Invalid VAT {}", sub_cmd - CP_VAT_REG_A);
+ }
state->vtx_attr[sub_cmd & CP_VAT_MASK].g0.Hex = value;
state->attr_dirty[sub_cmd & CP_VAT_MASK] = true;
break;
case CP_VAT_REG_B:
if ((sub_cmd - CP_VAT_REG_B) >= CP_NUM_VAT_REG)
+ {
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_MAYBE_INVALID_CP_COMMAND);
WARN_LOG_FMT(VIDEO, "CP_VAT_REG_B: Invalid VAT {}", sub_cmd - CP_VAT_REG_B);
+ }
state->vtx_attr[sub_cmd & CP_VAT_MASK].g1.Hex = value;
state->attr_dirty[sub_cmd & CP_VAT_MASK] = true;
break;
case CP_VAT_REG_C:
if ((sub_cmd - CP_VAT_REG_C) >= CP_NUM_VAT_REG)
+ {
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_MAYBE_INVALID_CP_COMMAND);
WARN_LOG_FMT(VIDEO, "CP_VAT_REG_C: Invalid VAT {}", sub_cmd - CP_VAT_REG_C);
+ }
state->vtx_attr[sub_cmd & CP_VAT_MASK].g2.Hex = value;
state->attr_dirty[sub_cmd & CP_VAT_MASK] = true;
break;
@@ -376,6 +435,7 @@ void LoadCPReg(u32 sub_cmd, u32 value, bool is_preprocess)
break;
default:
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_CP_COMMAND);
WARN_LOG_FMT(VIDEO, "Unknown CP register {:02x} set to {:08x}", sub_cmd, value);
}
}
diff --git a/Source/Core/VideoCommon/XFMemory.h b/Source/Core/VideoCommon/XFMemory.h
index 7efd3d2209..0d16c4f700 100644
--- a/Source/Core/VideoCommon/XFMemory.h
+++ b/Source/Core/VideoCommon/XFMemory.h
@@ -199,7 +199,8 @@ enum
XFMEM_STATE1 = 0x1003,
XFMEM_CLOCK = 0x1004,
XFMEM_CLIPDISABLE = 0x1005,
- XFMEM_SETGPMETRIC = 0x1006,
+ XFMEM_SETGPMETRIC = 0x1006, // Perf0 according to YAGCD
+ XFMEM_UNKNOWN_1007 = 0x1007, // Perf1 according to YAGCD
XFMEM_VTXSPECS = 0x1008,
XFMEM_SETNUMCHAN = 0x1009,
XFMEM_SETCHAN0_AMBCOLOR = 0x100a,
@@ -211,21 +212,26 @@ enum
XFMEM_SETCHAN0_ALPHA = 0x1010,
XFMEM_SETCHAN1_ALPHA = 0x1011,
XFMEM_DUALTEX = 0x1012,
+ XFMEM_UNKNOWN_GROUP_1_START = 0x1013,
+ XFMEM_UNKNOWN_GROUP_1_END = 0x1017,
XFMEM_SETMATRIXINDA = 0x1018,
XFMEM_SETMATRIXINDB = 0x1019,
XFMEM_SETVIEWPORT = 0x101a,
XFMEM_SETZSCALE = 0x101c,
XFMEM_SETZOFFSET = 0x101f,
XFMEM_SETPROJECTION = 0x1020,
- // XFMEM_SETPROJECTIONB = 0x1021,
- // XFMEM_SETPROJECTIONC = 0x1022,
- // XFMEM_SETPROJECTIOND = 0x1023,
- // XFMEM_SETPROJECTIONE = 0x1024,
- // XFMEM_SETPROJECTIONF = 0x1025,
- // XFMEM_SETPROJECTIONORTHO1 = 0x1026,
- // XFMEM_SETPROJECTIONORTHO2 = 0x1027,
+ // XFMEM_SETPROJECTIONB = 0x1021,
+ // XFMEM_SETPROJECTIONC = 0x1022,
+ // XFMEM_SETPROJECTIOND = 0x1023,
+ // XFMEM_SETPROJECTIONE = 0x1024,
+ // XFMEM_SETPROJECTIONF = 0x1025,
+ // XFMEM_SETPROJECTIONORTHO = 0x1026,
+ XFMEM_UNKNOWN_GROUP_2_START = 0x1027,
+ XFMEM_UNKNOWN_GROUP_2_END = 0x103e,
XFMEM_SETNUMTEXGENS = 0x103f,
XFMEM_SETTEXMTXINFO = 0x1040,
+ XFMEM_UNKNOWN_GROUP_3_START = 0x1048,
+ XFMEM_UNKNOWN_GROUP_3_END = 0x104f,
XFMEM_SETPOSTMTXINFO = 0x1050,
XFMEM_REGISTERS_END = 0x1058,
};
diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp
index 741680b826..9ceaf2edc1 100644
--- a/Source/Core/VideoCommon/XFStructs.cpp
+++ b/Source/Core/VideoCommon/XFStructs.cpp
@@ -9,6 +9,7 @@
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
+#include "Core/DolphinAnalytics.h"
#include "Core/HW/Memmap.h"
#include "VideoCommon/CPMemory.h"
@@ -182,6 +183,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case 0x104d:
case 0x104e:
case 0x104f:
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_XF_COMMAND);
DEBUG_LOG_FMT(VIDEO, "Possible Normal Mtx XF reg?: {:x}={:x}", address, newValue);
break;
@@ -192,8 +194,8 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case 0x1017:
default:
- if (newValue != 0) // Ignore writes of zero.
- WARN_LOG_FMT(VIDEO, "Unknown XF Reg: {:x}={:x}", address, newValue);
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_XF_COMMAND);
+ WARN_LOG_FMT(VIDEO, "Unknown XF Reg: {:x}={:x}", address, newValue);
break;
}
@@ -211,6 +213,7 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, DataReader src)
if (baseAddress + transferSize > XFMEM_REGISTERS_END)
{
WARN_LOG_FMT(VIDEO, "XF load exceeds address space: {:x} {} bytes", baseAddress, transferSize);
+ DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_XF_COMMAND);
if (baseAddress >= XFMEM_REGISTERS_END)
transferSize = 0;