Page MenuHomeWildfire Games

AMD Ryzen fix
Needs ReviewPublic

Authored by Stan on Thu, May 7, 6:41 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

Currently we use a wide variety of timers on windows. HPET nearly often fails to initialize because it requires admin rights. The fallback is usually TSC which is an usually reliable timer, that unfortunately seems to have some issues on the latest Ryzen CPUS. This patch force QPC usage. This way all platforms can run the game the same way. It should not have a big performance impact as computers are way faster than they used to 10 years ago. Ideally we'd find a better way to handle those cases but this is patch is in case we don't find a better solution for A24

All the other big engines also use QPC

According to this post on Reddit

Windows will use HPET if required, generally games use QueryPerformanceCounter (QPC) and Windows 10 will use the fastest timer available e.g Invariant TSC (ITSC) or Time Stamp Counter (TSC). Default settings for Windows 10 is HPET available ( not disabled ) and other timers available ( not disabled )

I will post the discussion with @janwas after cleaning it a bit.

See also the discussion here
I also made a post here no answers yet.

The mail exchange with AMD currently lead nowhere.

About clock monotonic https://stackoverflow.com/questions/3523442/difference-between-clock-realtime-and-clock-monotonic

Test Plan

Compile and run the game on windows, try to play in both single player and multiplayer, and report if there are any issues

Event Timeline

Stan created this revision.Thu, May 7, 6:41 PM
Vulcan added a comment.Thu, May 7, 6:41 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2081/display/redirect

Vulcan added a comment.Thu, May 7, 6:43 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/666/display/redirect

Stan added a comment.EditedSat, May 9, 12:54 PM

All the other big engines also use QPC

According to this post on Reddit

Windows will use HPET if required, generally games use QueryPerformanceCounter (QPC) and Windows 10 will use the fastest timer available e.g Invariant TSC (ITSC) or Time Stamp Counter (TSC). Default settings for Windows 10 is HPET available ( not disabled ) and other timers available ( not disabled )

I will post the discussion with @janwas after cleaning it a bit.

See also the discussion here
I also made a post here no answers yet.

The mail exchange with AMD currently lead nowhere.

Stan updated this revision to Diff 11859.EditedThu, May 14, 12:15 PM

Apply some of @janwas' recommendations. Delete Aken.sys and Mahaf as they don't work anyway. They require elevated permission and debug versions of windows with unsigned drivers installation. It is very unlikely to happen.

Still missing a fix for Linux according to@OptimusShepard. Trying to replace CLOCK_REALTIME by CLOCK_MONOTONIC to see if that fixes it.

Also nuke MSR checks since they rely on MAHAF and would have failed anyway.

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2115/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/700/display/redirect

Stan updated this revision to Diff 11860.Thu, May 14, 12:18 PM

Readd pmt check in QPC

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2116/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/701/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1589/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1590/display/redirect

Stan updated this revision to Diff 11861.Thu, May 14, 12:27 PM

Cleanup all references of mahaf

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2117/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/702/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1591/display/redirect

Stan updated this revision to Diff 11862.Thu, May 14, 12:30 PM

Try arc export unified.

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1592/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/lib/config2.h
|   1| /*·Copyright·(C)·2015·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2015"

source/lib/sysdep/arch/x86_x64/apic.h
|   1| /*·Copyright·(C)·2011·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2011"

source/lib/sysdep/os/win/whrt/qpc.cpp
|   1| /*·Copyright·(C)·2010·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2010"

source/lib/sysdep/os/win/whrt/tsc.cpp
|   1| /*·Copyright·(C)·2010·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2010"
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2118/display/redirect

Stan updated this revision to Diff 11884.Sat, May 16, 8:23 PM

Add the linux fix. Diff will fail to build because arc is stupid, but this is only for backup

Stan edited the summary of this revision. (Show Details)Sat, May 16, 8:23 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2134/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/719/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1608/display/redirect

Stan edited the summary of this revision. (Show Details)Sat, May 16, 10:54 PM

I have tested with different setups.

Windows 10 64Bit, Ryzen 3700X, Radeon RX 570, 16GB DDR4
6x 4Ai vs 4Ai, random Isthmus, map size large, speed 20-times
4x 4 vs 4 multiplayer, random maps, different map sizes

Manjaro (Arch) 64Bit, Ryzen 3700X, Radeon RX 570, 16GB DDR4
7x 4Ai vs 4Ai, random Isthmus, map size large, speed 20-times
40x 4Ai vs 4Ai, random Isthmus, map size large (only until map was loaded)

Manjaro (Arch) 64Bit, Ryzen 3700X, Radeon RX 5700, 16GB DDR4
11x 4Ai vs 4Ai, random Isthmus, map size large, speed 20-times
1x 4 vs 4 multiplayer, random Isthmus, map size large

One of the Windows multiplayer matches crashed, one of the Ai matches of the first Linux setup didn't continue to loading the map. Both doesn't show the bug, we are searching for. I don't know, if the problems occurring because of the patch.