The-Wineskin-Project / WineskinServer

Wineskin
GNU Lesser General Public License v2.1
2.47k stars 170 forks source link

Horizon Zero Dawn | D3DMetal – slow motion movement (CPU Frequency readout issue) | wine issue #424

Closed Rastafabisch closed 12 months ago

Rastafabisch commented 1 year ago

Movement (walking/jumping/running) takes place in slow motion even though you have a high framerate. This bug has been fixed in Proton. (Safari has problems opening the specific comment. Append #issuecomment-854036347 to the link if so.)

It's related to the value of the following Registry DWORD: Computer\HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\~MHz This is 960 (2400) on the M1 Pro I tried manually overwriting the value to 9c4 (2500), which is the recognised frequency in the ProcessorNameString, as well as c6c (3180) which is the CPUs supposed boost frequency, but that did not fix the issue. Deleting the DWORD altogether prohibits HZD from starting. I suspect the bug wouldn't happen on Intel Macs though I cannot test this.

To replicate just install Horizon Zero Dawn to a D3DMetal-enabled wrapper. (may need vcrun2019)

I recon that the Proton patch is linux specific. @Gcenx, do you have any idea how a macOS tailored patch could look like? I think it would be a great addition to your engines as they have already come so far enabling Mac gaming.

As far as I know this is the "only" thing preventing HZD from working great on macOS.

This is the code in question. Especially line 3783 to line 3809. If I understood the above proton patch correctly a quick fix could be changing line 3790 from if (!sysctlbyname("hw.cpufrequency", &currentMhz, &valSize, NULL, 0)) to if (!sysctlbyname("hw.cpufrequency", &maxMhz, &valSize, NULL, 0)). I've not been able to verify this, though. Any thoughts on that?

Gcenx commented 1 year ago

According to the linked issue a lot of the problem was driver related.

I’ll take a closer look over the “wine” changes when I get chance.

SadiinsoSnowfall commented 1 year ago

If you decrease the value instead of increasing it, the game actually speeds up. I tried with 1000 (you can choose to enter a value in decimal in regedit) and it was way to fast. 1400 seems to be the sweet spot but it's hard to say (the game still runs as 20fps on my machine which prevents me from really knowing if the animations are running at the right speed).

Edit: after further testing, it seems that the "correct" value should be around 1100-1150.

Andytizer commented 1 year ago

If you decrease the value instead of increasing it, the game actually speeds up. I tried with 1000 (you can choose to enter a value in decimal in regedit) and it was way to fast. 1400 seems to be the sweet spot but it's hard to say (the game still runs as 20fps on my machine which prevents me from really knowing if the animations are running at the right speed).

Edit: after further testing, it seems that the "correct" value should be around 1100-1150.

I am attempting to regedit within the Wineprefix but for I'm not able to 'save' any new values for ~MHz to test the new value, how did you manage to do this? Video: https://cdn.discordapp.com/attachments/1124827425226895491/1124827426137055253/Screen_Recording_2023-07-01_at_23.21.19.mov

SadiinsoSnowfall commented 1 year ago

I just copied the shell function I had to launch steam:

MTL_HUD_ENABLED=1 WINEESYNC=1 WINEPREFIX=/Users/sadiinso/Library/Containers/com.isaacmarovitz.Whisky/Bottles/steam /usr/local/Cellar/game-porting-toolkit/1.0.2/bin/wine64 'C:\windows\regedit.exe'
Gcenx commented 1 year ago

@Andytizer is that bottle that your launching via GPTK from terminal is also a CrossOver bottle it lightly wine save when CrossOver is open.

Make sure your close all other “wine” process before trying to change registry settings/files.

Rastafabisch commented 1 year ago

THEORETICAL SOLUTION - broken in wine or wineskin

I wrote a batch script, that should fix the game on the fly, without having to wait for a wine fix. Setting up the wrapper to start that script however does not work as it just halts on execution, while it does work fine when being called from cmd. That seems to be either a wrapper or wine issue. It's triggered whenever I try to call reg from the bat file.

@echo off
reg add HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0 /V ~MHz /T REG_DWORD /D 1100 /F
start "" "C:\GOG Games\Horizon Zero Dawn\HorizonZeroDawn.exe"

WORKING SOLUTION

I circumvented the issue by resorting to regedit instead of reg, which however requires you to place a reg file into the wrapper. You'd need to copy this code to a plain text file and save it as WHATEVER.bat. Place this file into your Horizon Zero Dawn wrapper and make it start from that file.

@echo off
start "C:\windows" regedit.exe /S C:/HZD_fix.reg
start "" "C:\GOG Games\Horizon Zero Dawn\HorizonZeroDawn.exe"

You may need to adjust paths according to your environment.

Here's my HZD_fix.reg, inspired by @SadiinsoSnowfall, which needs to be saved as HZD_fix.reg into the wrappers C: directory:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0]
"~MHz"=dword:0000044c

EDIT: I attached the premade files for you to unzip. HZD_fix.zip

EDIT 2: Tested with game. Custom game icon added to ZIP archive.

Rastafabisch commented 1 year ago

I did some more research and found that the base frequency of the M1 series e-cores clocks in at (around) 1000Mhz, this correlates to @SadiinsoSnowfall findings that the sweet spot to run the game is around 1100MHz. While I cannot confirm at all that this is the root cause I have a hunch that it is related. That could mean that a wine fix for apple silicon machines could be to set HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0\~MHz to the e-cores base frequency.

EDIT: Another clue is what CPU-Z installed into a wrapper reads…

CPU-Z on Apple M1 under Wine
YuryRegis commented 1 year ago

THEORETICAL SOLUTION - broken in wine or wineskin

I wrote a batch script, that should fix the game on the fly, without having to wait for a wine fix. Setting up the wrapper to start that script however does not work as it just halts on execution, while it does work fine when being called from cmd. That seems to be either a wrapper or wine issue. It's triggered whenever I try to call reg from the bat file.

@echo off
reg add HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0 /V ~MHz /T REG_DWORD /D 1100 /F
start "" "C:\GOG Games\Horizon Zero Dawn\HorizonZeroDawn.exe"

WORKING SOLUTION

I circumvented the issue by resorting to regedit instead of reg, which however requires you to place a reg file into the wrapper. You'd need to copy this code to a plain text file and save it as WHATEVER.bat. Place this file into your Horizon Zero Dawn wrapper and make it start from that file.

@echo off
start "C:\windows" regedit.exe /S C:/HZD_fix.reg
start "" "C:\GOG Games\Horizon Zero Dawn\HorizonZeroDawn.exe"

You may need to adjust paths according to your environment.

Here's my HZD_fix.reg, inspired by @SadiinsoSnowfall, which needs to be saved as HZD_fix.reg into the wrappers C: directory:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0]
"~MHz"=dword:0000044c

EDIT: I attached the premade files for you to unzip. HZD_fix.zip

EDIT 2: Tested with game. Custom game icon added to ZIP archive.

Thanks! This solution also fixed the issue running the HZD + Crossover.

Gcenx commented 1 year ago

Locking due to constant spam, I’ll comment again once I have an actual fix

Gcenx commented 1 year ago

@Rastafabisch could you or really anyone who owns the game please try again with CX23.6.0 as that contains a patch that should resolve the issue, if it doesn’t I’ll pass that info along.

vesper8 commented 1 year ago

@Gcenx I just tried it on CX 23.6 (CXPatched too) and can confirm that the slow-mo is still happening.

Gcenx commented 1 year ago

@vesper8 as in you tired WineCX23.6.0 engine?

The patch wasn’t applied to CXPatcher

marzent commented 1 year ago

@vesper8 what value does Computer\HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\~MHz have for you?

vesper8 commented 1 year ago

@Gcenx Ah sorry I may have misunderstood, I tried the game on CrossOver 23.6, not via WineskinServer no.

@marzent The value is 960

Gcenx commented 1 year ago

@vesper8 only Wineskin using WineCX23.6.0 currently has the fix applied from @marzent

Rastafabisch commented 11 months ago

A bit late to the game. Thank you for the fix! 23.06 (to my testing any CX23 engine) introduced a new (breaking) issue, but I gonna fill a new bug report for that one.