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

ogc: Fix timer precision #89

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

Mefiresu
Copy link

SDL_GetPerformanceCounter is supposed to return the value of a high precision counter, but SDL_GetTicks64 returns a truncated value in milliseconds.
Correctly return gettime() as a high precision counter instead, and update SDL_GetPerformanceFrequency accordingly.

SDL_GetPerformanceCounter is supposed to return the value of a high
precision counter, but SDL_GetTicks64 returns a truncated value in
milliseconds.
Correctly return gettime() as a high precision counter instead, and
update SDL_GetPerformanceFrequency accordingly.
@Mefiresu
Copy link
Author

Mefiresu commented Jan 17, 2025

For context: I am currently porting Sonic Robo Blast 2 on the Wii, and this game uses a mix of SDL_GetPerformanceFrequency and SDL_GetPerformanceCounter to display performance stats.
The same code worked fine on Wii U (native, not vWii), but didn't on the Wii.

Before timer fix:

After timer fix:

These two functions are often used for deltatime computations in general, so having millisecond precision timers make the frametimes all messy.

@Mefiresu
Copy link
Author

Mefiresu commented Feb 6, 2025

@mardy Since the original timer code is yours, could you take a quick look at it?

Copy link
Collaborator

@mardy mardy left a comment

Choose a reason for hiding this comment

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

Thanks for pinging me, I hadn't seen the issue before!

It looks absolutely correct :-)

@WinterMute WinterMute merged commit e6a34d4 into devkitPro:ogc-sdl-2.28 Feb 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants