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

fixes for "On Display Messages" #8923

Merged
merged 1 commit into from May 18, 2021
Merged

Conversation

Filoppi
Copy link
Contributor

@Filoppi Filoppi commented Jul 1, 2020

Mainly fixed 2 things on "On Display Messages":
-They might have never drawn if DrawMessages wasn't called before they actually expired.
-Their fade was wrong if the duration of the message was less than the fade time.

This makes them much more useful for debugging, I know there might be other means of debugging like logs and imgui, but this was the simplest so that's what I used.
If you want to print the same message every frame, but with a slightly different value to see the changes, it now work.

To compensate for the fact that they are now always rendered once, so on start up a lot of old messages (printed while the emulation was off) could show up, I've added a "drop" time, which means if a msg isn't rendered for the first time within that time, it will be dropped and never rendered.

A previous solution was to clean all the messages before the emulation thread started, but that might have had side effects.

@Filoppi Filoppi changed the title fixes for "On Display Messages": fixes for "On Display Messages" Jul 1, 2020
Source/Core/Core/Core.cpp Outdated Show resolved Hide resolved
@JMC47
Copy link
Contributor

JMC47 commented Jul 12, 2020

@dolphin-emu-bot rebuild

@AdmiralCurtiss
Copy link
Contributor

We should check if our various start-of-emulation-warning messages still work with this. Things like, GPU doesn't support important feature or GCI failed to load come to mind.

@Filoppi
Copy link
Contributor Author

Filoppi commented Jul 12, 2020

We should check if our various start-of-emulation-warning messages still work with this. Things like, GPU doesn't support important feature or GCI failed to load come to mind.

If you don't want to test, I can either get rid of the clean before the window open. At worse, you are going to see a few messages on screen for 1 frame, which is not a big deals, but from my tests, I don't remember any appearing.
Alternatively, we can put in a "force expire" timer, meaning that if more than, let's say, a second has elapsed from the moment that message was queued, then we discard (just like it would have been before) and not even render it once.

@Filoppi
Copy link
Contributor Author

Filoppi commented Dec 30, 2020

I've implemented it in the alternative way that I had already described. The explanation is above.
This change should now have no possible negative consequences.

if (time_left <= 0)
// Make sure we draw them at least once if they were printed with 0ms,
// unless enough time has expired, in that case, we drop them
if (time_left <= 0 && (msg.ever_drawn || -time_left >= MESSAGE_DROP_TIME))

This comment was marked as outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would mean that all the expired messages draw one time more than necessary (which also mean they wouldn't follow the length of time you had specified). I think it's better to have a variable non const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hypothetical case but that would break when going over ~1000fps though (time accuracy is 1ms):
Add a message: timestamp 53 (53ms current time + 0 duration).
Draw messages at time 53ms.
Add another message which is exactly the same: timestamp 53 (if we are still within the same ms).
Draw messages at time 53ms again: the previous message nor the new message will draw now.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true. Sorry, my initial comment was not well thought out. However, still not a fan of that variable so I have a different suggestion.

If I'm understanding things correctly, I think what you're trying to account for are messages that get missed because they expire sometime before DrawMesages() gets called (or in the case of a start/stop of the software expire sometime in between DrawMessages() calls).

I think a solution to that problem is to add another timestamp.

u32 s_last_drawn_timestamp = 0;

void DrawMessages()
{
  if (time_left <= 0 && (s_last_drawn_timestamp > msg.timestamp || -time_left >= MESSAGE_DROP_TIME))
  ...
  s_last_drawn_timestamp = now;
}

Copy link
Contributor Author

@Filoppi Filoppi Dec 30, 2020

Choose a reason for hiding this comment

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

Yeah I was thinking about changing >= to >. Let me finish reasoning :).
If edits are requested for such small things none of my other changes will ever go it, not within 3+ years 👍.

Copy link
Contributor Author

@Filoppi Filoppi Dec 30, 2020

Choose a reason for hiding this comment

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

changing >= to > has the opposite effect of the problem I mentioned above. If going to extremely high fps, they could now draw more than once. Which is not really a problem, but is theoretically wrong, and given that with the ever_drawn flag it works perfectly, I don't think it would be worth changing.

Copy link
Contributor

@iwubcode iwubcode Dec 30, 2020

Choose a reason for hiding this comment

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

If edits are requested for such small things none of my other changes will ever go it, not within 3+ years

It's just an unfortunate consequence of this being an open-source repo with very few developers doing constant reviews (and even fewer with merge powers). Because of that, code changes can take a while. Only thing that gets merged fast are code-cleanup changes and even that can sometimes take a while depending on the size.

If going to extremely high fps, they could now draw more than once.

I personally think that this is a fine trade-off for removing that variable (that is included on every message) and returning const correctness. When you get to that high framerate, timing accuracy isn't going to matter that much. If we really want to fix this, we need a more granular clock. I'm going to guess we aren't using std::chrono in Timer because it didn't exist back then.

EDIT: actually we could use GetTimeUs() for more granularity. But really we should enhance Timer to return chrono times, that way comparisons will be a lot cleaner.

Copy link
Contributor Author

@Filoppi Filoppi Dec 30, 2020

Choose a reason for hiding this comment

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

Well on screen messages are not logs, there are barely any, what's the problem with adding a bool? And it's not like it's not const correct, ever_drawn is changed by the Draw() function. That makes sense.

Changing the timer won't exactly fix the problem, depending on the granularity. But that's kind of beyond the scope of this PR, wanted to avoid changing even more.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm definitely nitpicking. Sorry to take up so much of your time. It just felt counterintuitive for DrawMessage to be changing Message even though I see your reason for doing so. My hope was to come up with a solution that would allow for the Message to be const again.

Anyway, I don't have merge powers, so someone else will need to review this regardless. My apologies again. These are good changes overall.

-They might have never drawn if DrawMessages wasn't called before they actually expired
-Their fade was wrong if the duration of the message was less than the fade time

This makes them much more useful for debugging, I know there might be other means
of debugging like logs and imgui, but this was the simplest so that's what I used.
If you want to print the same message every frame, but with a slightly different value
to see the changes, it now work.

To compensate for the fact that they are now always rendered once,
so on start up a lot of old messages (printed while the emulation was off) could show up,
I've added a "drop" time, which means if a msg isn't rendered for the first
time within that time, it will be dropped and never rendered.
@dolphin-emu-bot
Copy link
Contributor

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

  • aeon-charge-attack on ogl-lin-radeon: diff
  • bk-tev on ogl-lin-radeon: diff
  • burnout2-vehicletextures on ogl-lin-radeon: diff
  • chibi-robo-fastdepth on ogl-lin-radeon: diff
  • chibi-robo-zfighting on ogl-lin-radeon: diff
  • custom-brawl-char on ogl-lin-radeon: diff
  • dbz-depth on ogl-lin-radeon: diff
  • djhero2-blend on ogl-lin-radeon: diff
  • DKCR-Char on ogl-lin-radeon: diff
  • DKCR-fast-depth on ogl-lin-radeon: diff
  • ed-updated on ogl-lin-radeon: diff
  • fifa-street on ogl-lin-radeon: diff
  • fishing-resort-map on ogl-lin-radeon: diff
  • fortune-street on ogl-lin-radeon: diff
  • fortune-street-fog on ogl-lin-radeon: diff
  • fortune-street-white-box on ogl-lin-radeon: diff
  • f-zero-rain on ogl-lin-radeon: diff
  • inverted-depth-range on ogl-lin-radeon: diff
  • jj-awae-mirrored on ogl-lin-radeon: diff
  • kirby-shadows on ogl-lin-radeon: diff
  • last-story-shadows on ogl-lin-radeon: diff
  • lego-star-wars-crane-shadow on ogl-lin-radeon: diff
  • lesson08 on ogl-lin-radeon: diff
  • luigi-shadows on ogl-lin-radeon: diff
  • mario-baseball-shadows on ogl-lin-radeon: diff
  • mario-sluggers-bar on ogl-lin-radeon: diff
  • mario-tennis-menu on ogl-lin-radeon: diff
  • MaS-LOG-wiimote on ogl-lin-radeon: diff
  • medabots-crash on ogl-lin-radeon: diff
  • megaman-heat on ogl-lin-radeon: diff
  • melee-depth on ogl-lin-radeon: diff
  • melee-lighting on ogl-lin-radeon: diff
  • metroid-visor on ogl-lin-radeon: diff
  • mii-channel on ogl-lin-radeon: diff
  • milotic-texture on ogl-lin-radeon: diff
  • mini-ninjas on ogl-lin-radeon: diff
  • mkdd-babypark on ogl-lin-radeon: diff
  • mkdd-efb on ogl-lin-radeon: diff
  • mkwii-bluebox on ogl-lin-radeon: diff
  • monkeyball-fuse on ogl-lin-radeon: diff
  • mp2-scanner on ogl-lin-radeon: diff
  • mp3-bloom on ogl-lin-radeon: diff
  • mp7-text on ogl-lin-radeon: diff
  • mtennis-zfreeze on ogl-lin-radeon: diff
  • my-word-coach on ogl-lin-radeon: diff
  • nddemo-bumpmapping on ogl-lin-radeon: diff
  • nddemo-lighting on ogl-lin-radeon: diff
  • nfsu-purplerect on ogl-lin-radeon: diff
  • nfsu-reflections on ogl-lin-radeon: diff
  • nhl-slap on ogl-lin-radeon: diff
  • nsmbw-coins on ogl-lin-radeon: diff
  • nsmbw-intro on ogl-lin-radeon: diff
  • pm-hc-jp on ogl-lin-radeon: diff
  • rs2-bumpmapping on ogl-lin-radeon: diff
  • rs2-glass on ogl-lin-radeon: diff
  • rs2-skybox on ogl-lin-radeon: diff
  • rs2-zfreeze on ogl-lin-radeon: diff
  • rs3-bumpmapping on ogl-lin-radeon: diff
  • rs3-skybox2 on ogl-lin-radeon: diff
  • sadx-ui on ogl-lin-radeon: diff
  • sfa-shadows on ogl-lin-radeon: diff
  • sf-assault-flashing on ogl-lin-radeon: diff
  • simpsons-game on ogl-lin-radeon: diff
  • smg2-fog on ogl-lin-radeon: diff
  • smg-marioeyes on ogl-lin-radeon: diff
  • sms-bubbles on ogl-lin-radeon: diff
  • sms-gc on ogl-lin-radeon: diff
  • sms-water on ogl-lin-radeon: diff
  • soniccolors-mm on ogl-lin-radeon: diff
  • sonic-riders-blur on ogl-lin-radeon: diff
  • sonicriderszg-gb on ogl-lin-radeon: diff
  • spyro-bloom on ogl-lin-radeon: diff
  • spyro-depth on ogl-lin-radeon: diff
  • ssbb-mod-lloyd on ogl-lin-radeon: diff
  • ssbm-pointsize on ogl-lin-radeon: diff
  • ss-timestone on ogl-lin-radeon: diff
  • super-sluggers-white-out on ogl-lin-radeon: diff
  • sw3-dt on ogl-lin-radeon: diff
  • thps3-earlyz on ogl-lin-radeon: diff
  • thps4-shadow on ogl-lin-radeon: diff
  • tla-menu on ogl-lin-radeon: diff
  • tos-invis-char on ogl-lin-radeon: diff
  • tsp3-pinkgrass on ogl-lin-radeon: diff
  • vegas-party-depth on ogl-lin-radeon: diff
  • xenoblade-menu on ogl-lin-radeon: diff
  • ztp-grass on ogl-lin-radeon: diff
  • zww-armos on ogl-lin-radeon: diff
  • zww-water on ogl-lin-radeon: diff
  • zww-waves on ogl-lin-radeon: diff

automated-fifoci-reporter

@JMC47
Copy link
Contributor

JMC47 commented May 18, 2021

This has been sitting for a while and it seems like everyone here is in agreement that this is an improvement. I've gone through and tested it and on-screen display messages at startup are fine. I tested purposefully duplicate GCI files for something that would cause issues on boot.

@JMC47 JMC47 merged commit 93e9d8b into dolphin-emu:master May 18, 2021
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants