Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add game quirks for unknown BP/CP/XF commands #9576

Merged
merged 4 commits into from Apr 6, 2021

Conversation

Pokechu22
Copy link
Contributor

See e.g. bug 10931. #9497 removed assertions for unknown CP commands, and there were only warnings for BP and XF before. Since there are a few commands marked as maybe unknown, this is something worth tracking.

I have separate quirks for completely unknown CP commands (USES_UNKNOWN_CP_COMMAND) and CP commands where the lower nybble is not in the expected range (USES_MAYBE_INVALID_CP_COMMAND); this is because YAGCD disagrees with Dolphin's current implementation and it would be good to find out which is correct. Based on bug 10931, Toy Story 3 will trigger both of those cases, but other games might only hit one.

@Pokechu22
Copy link
Contributor Author

I've created a separate quirk for 0x00/0x10/0x20, which are unknown commands that appear to be related to performance queries (they're used by e.g. Mario Golf (bug 12461). Note that the SDK (and libogc, but perhaps unsurprisingly not anything by datel) issues 0x20 with argument 0 on startup, which I've ignored here as otherwise it would completely drown everything out. Libogc also has other examples with both 0x20 and 0x00, but nothing with 0x10 (GX_SetVCacheMetric seems suspicious). I haven't attempted to name them. For performance reasons, uses of these commands are DEBUG_LOGged so that there is no impact in release builds; I've left the other ones as warnings.

I've also added logging for inexact matches to MATINDEX_A/MATINDEX_B/VCD_LO/VCD_HI (0x30/0x40/0x50/0x60) rather than just reporting a quirk in that case, as looking at __GXSetMatrixIndex and __GXSetVAT in Super Mario Sunshine shows that those are used without any offset.

@Pokechu22 Pokechu22 marked this pull request as ready for review March 27, 2021 02:39
@@ -192,6 +194,7 @@ static void XFRegWritten(int transferSize, u32 baseAddress, DataReader src)
case 0x1017:

default:
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNKNOWN_XF_COMMAND);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to report 0 here? Any idea why it ignored for the warn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like 636bedb / #3242 hid those logs, specifically because of warnings on FifoCI, but doesn't specify what game did it. Assuming it was a single game, IMO it's still useful to track it.

Copy link
Contributor Author

@Pokechu22 Pokechu22 Mar 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added c702180 temporarily to get a list of these from FifoCI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the source of the problem is that the FIFO player copies all of the registers on startup, which includes the unused ones; this produces log messages for everything (but shouldn't affect normal playback). 1099475 is a hacky workaround where the unused ones just aren't copied, but I don't think it's a great implementation.

0x1007 in particular is odd, because YAGCD says it's Perf1 (0x1006 is Perf0 which Dolphin calls XFMEM_SETGPMETRIC); games don't seem to use it though. It's marked as known in the actual XFMemory struct, but there is no constant for it. And weirder still is this code (which seems very unlikely to be correct):

case XFMEM_ERROR:
case XFMEM_DIAG:
case XFMEM_STATE0: // internal state 0
case XFMEM_STATE1: // internal state 1
case XFMEM_CLOCK:
case XFMEM_SETGPMETRIC:
nextAddress = 0x1007;
break;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having looked at other parts of the code, it turns out nextAddress advances address forward, but also updates the count, so it's more of an optimisation that happens to be rather unnecessary in this case, but makes more sense for e.g. XFMEM_SETPROJECTION where usually all 7 registers are updated at once, but it would be bad to update g_vertex_manager et al 7 times for that.

My earlier hackfix was backwards (I was skipping everything but the unknown registers...); 7ea201c is a correct implementation. Note that that produces rendering differences but it seems that those are only from timing changes (if instead of skipping unknown registers, the last valid register is repeated (2bd038e), there are no differences); since this also only happened on the first frame in the fifo player, I'm not going to worry about it.

With skipping unknown registers, it should be fine to log a warning even when it's set to 0; none of the testcases on fifo.ci have any unknown registers in the fifo itself.

@iwubcode
Copy link
Contributor

I had no idea that Dolphin did tracking on this level, very cool.

@Pokechu22 Pokechu22 force-pushed the invalid-gfx-reg-quirk branch 3 times, most recently from 06f14e8 to 1099475 Compare March 27, 2021 05:39
@Pokechu22 Pokechu22 marked this pull request as draft March 27, 2021 05:39
@Pokechu22 Pokechu22 force-pushed the invalid-gfx-reg-quirk branch 3 times, most recently from 2bd038e to 2755a4e Compare March 28, 2021 03:39
@Pokechu22 Pokechu22 marked this pull request as ready for review March 28, 2021 03:56
@JMC47
Copy link
Contributor

JMC47 commented Apr 6, 2021

Looks reasonable to me. Not a coder ✔️

Source/Core/Core/DolphinAnalytics.cpp Show resolved Hide resolved
Source/Core/VideoCommon/VertexLoaderManager.cpp Outdated Show resolved Hide resolved
Source/Core/VideoCommon/VertexLoaderManager.cpp Outdated Show resolved Hide resolved
Source/Core/VideoCommon/VertexLoaderManager.cpp Outdated Show resolved Hide resolved
Source/Core/VideoCommon/VertexLoaderManager.cpp Outdated Show resolved Hide resolved
…wn 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 avoids some warnings, which were originally fixed by ignoring loads with a value of zero (see 636bedb / dolphin-emu#3242).

Note that FifoCI will report some changes, but only on the first frame; these seem to be timing related as they don't happen if a different write is used to replace skipped ones.
@dolphin-emu-bot
Copy link
Contributor

FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:

  • inverted-depth-range on ogl-lin-mesa: diff
  • inverted-depth-range on ogl-lin-radeon: diff
  • nfsu-reflections on ogl-lin-radeon: diff

automated-fifoci-reporter

@leoetlino leoetlino merged commit f18743a into dolphin-emu:master Apr 6, 2021
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants