Page 1 of 2

Reduce CPU usage and increase FPS

Posted: Sun Mar 15, 2015 7:06 pm
by JeremyaFr
Hello,

Here is a hook to reduce the CPU usage. The side effect is that the framerate is reduced.

xwa_hook_time.zip

Re: Reduce CPU usage

Posted: Sun Mar 15, 2015 10:23 pm
by Darksaber
So does this remove the need to run XWA on one core, using Runfirst.exe

http://www.xwaupgrade.com/phpBB3008/vie ... 10&t=10594

Re: Reduce CPU usage

Posted: Sun Mar 15, 2015 10:35 pm
by JeremyaFr
It does not remove the need to run XWA on one core.
The game uses 100% of one cpu core. It's because at several places the game engine calls timeGetTime in a loop in order to wait a few ms.
The hook adds a call to Sleep before the call to timeGetTime.

Re: Reduce CPU usage

Posted: Sun Mar 13, 2016 9:45 pm
by craig_mac
I assume this is the same reason I get 100% cpu usage with XvT/Bop ?
If so how would I go about applying the same fix for it ?
Thanks for the great work on this btw !

Re: Reduce CPU usage

Posted: Fri Apr 08, 2016 5:08 pm
by Reimar
You can't easily use this for XvT/BoP, it is specific to the game binary.
I think I don't see the issue when running XvT with this wrapper (the one from JeremyaFr with small changes to make it work with XvT):
https://github.com/rdoeffinger/xwa_ddra ... ses/latest
But even if you do, you can set the PresentSleepTime = 10 option, then it will just stop the game from using your CPU for a fixed amount of time every frame.
It's not as good as this change as it doesn't adjust to how much resources the game really needs, so too low means you waste CPU, too high means the game will run slower than it should, but it's something.

Re: Reduce CPU usage

Posted: Mon Apr 11, 2016 10:17 am
by craig_mac
thanks very much!
this seems to run a lot better.. certain areas were making my framerate fluctuate .. the interdiction of tie advanced fighters especially, but its far more playable now
never thought i'd see the day where i can play the game 1080p with AA but here it is :)
thanks again for the fantastic work

Re: Reduce CPU usage

Posted: Fri Dec 14, 2018 5:14 pm
by JeremyaFr
UPDATE

Hello,
I've included the 60 fps patch to the time hook.

Please redownload xwa_hook_time.zip

Re: Reduce CPU usage

Posted: Mon Feb 04, 2019 7:20 pm
by JeremyaFr
UPDATE

Hello,
I've updated the time hook.
I've reduced CPU usage in game menus and in video playing.

Please redownload xwa_hook_time.zip

Re: Reduce CPU usage

Posted: Mon Feb 04, 2019 9:13 pm
by Darksaber
Thanks :)

Re: Reduce CPU usage

Posted: Tue Feb 05, 2019 2:05 am
by evilmark
the 60fps part isn't working for me, game won't go higher than 11 fps for some reason

Re: Reduce CPU usage

Posted: Sat Jun 22, 2019 7:54 pm
by JeremyaFr
UPDATE

Hello,
I've updated the time hook.

I've removed the limit of 59 fps.

Re: Reduce CPU usage and increase FPS

Posted: Wed Jun 26, 2019 11:16 pm
by Phoenix Leader
Is there a new fps limit now? Is it that 118 fps you mentioned in this topic: https://xwaupgrade.com/phpBB3/viewtopic ... 6&start=70 ?

Re: Reduce CPU usage and increase FPS

Posted: Thu Jun 27, 2019 8:35 pm
by JeremyaFr
The new limit is 236 fps.

Re: Reduce CPU usage and increase FPS

Posted: Fri Jun 28, 2019 2:27 am
by Phoenix Leader
Great. X-Wing Alliance on 120 Hz and 144 Hz monitors will be amazing.

Re: Reduce CPU usage and increase FPS

Posted: Sat Feb 26, 2022 10:10 am
by JeremyaFr
WIP

Hello,
Here a WIP version of the time hook.

I think I've found how to modify the explosions animations speed.
I've added a config file to control the animation speed.

The settings are in the "hook_time.cfg" file or in the "[hook_time]" section of the "Hooks.ini" file.
To define the duration of an animation frame for explosions, set the ExplosionAnimationTimeFrame setting. The setting is an integer value. The default value is 60.
To define the duration of an animation frame for small debris, set the SmallDebrisAnimationTimeFrame setting. The setting is an integer value. The default value is 60.

Download:
EDIT: link removed

Re: Reduce CPU usage and increase FPS

Posted: Sat Mar 12, 2022 6:36 pm
by Bman
Also on a related note, the explosion time (or rather the duration of explosions) can be lengthen too for say Starships and Stations by using AlliED editor's Departure tab for any FG, and it's bottom left corner tool called "Explosion time." I set larger craft from between 3 to around 7 seconds delay.

Re: Reduce CPU usage and increase FPS

Posted: Sat Mar 26, 2022 7:03 am
by Bman
Hi Jeremy, FYI -- when using the new WIP time hook you posted above, the game kept crashing to desktop for me. Think it's bugged because when I go back to previous version all is well. Would you like me to post a crash report?

Re: Reduce CPU usage and increase FPS

Posted: Fri May 06, 2022 8:17 pm
by Ace Antilles
JeremyaFr wrote:
Sat Feb 26, 2022 10:10 am
WIP
Hello,
Here a WIP version of the time hook.

I think I've found how to modify the explosions animations speed.
I've added a config file to control the animation speed.
Hi @JeremyaFr. Is this still a WIP bug or has it been released as a final version now?

Re: Reduce CPU usage and increase FPS

Posted: Fri May 06, 2022 8:18 pm
by Ace Antilles
Bman wrote:
Sat Mar 26, 2022 7:03 am
Hi Jeremy, FYI -- when using the new WIP time hook you posted above, the game kept crashing to desktop for me. Think it's bugged because when I go back to previous version all is well. Would you like me to post a crash report?
Does this still crash for you? I know you've had other crashes of late.

Re: Reduce CPU usage and increase FPS

Posted: Fri May 06, 2022 8:27 pm
by JeremyaFr
Hello,
The WIP time hook was merged before fixing the random crashes. Then Bman reported that his game is now stable.
Question for @Bman: Can you confirm?

Re: Reduce CPU usage and increase FPS

Posted: Fri May 06, 2022 9:44 pm
by Bman
Hi J. & A., yes, all latest hooks are working fine for me. Thanks 👍. Just having some transparency issues with new GPU ddraw. Posted video of what I see in TFTC discord server in VR-Help channel. Could be my .cfg files or AMD card issue. ???

Re: Reduce CPU usage and increase FPS

Posted: Mon May 23, 2022 2:10 pm
by aidor
Hi @JeremyaFr

I've just installed the XWA megapatch, and there is any
hook_time.cfg file to set explotions framerate. I guees I can get the DLL and the cfg from your GitHub and use that.

Another issue I see, with the unlocked framerate (I'm using a 120hz monitor), is that framerate is much better than vanilla 30fps, obviously, and actually It runs at 120fps, but is not completly smooth and it's 'jittering'. I've tried various settings in Nvidia control panel and in the .ini files (vsync on/off, fixed framerate/gsync, setting my monitor to 60hz...), but nohing chance, it is still 'jittering'. It's most noticiable with backgrounds. Is there ant way to fix It? Maybe this issue is some engine limitation.

Thanks in advance.

Re: Reduce CPU usage and increase FPS

Posted: Mon May 23, 2022 2:17 pm
by Ace Antilles
Use hooks.ini for custom settings

Re: Reduce CPU usage and increase FPS

Posted: Mon May 23, 2022 3:06 pm
by aidor
Yeah, I checked that hooks.ini file, and the only setting I saw about framerate is vsync, but It doesn't fix the 'jittering'.

Also, I don't see inside hooks.ini the ExplosionAnimationTimeFrame setting. I will check It again when I get home.

Re: Reduce CPU usage and increase FPS

Posted: Tue Aug 02, 2022 7:30 pm
by JeremyaFr
WIP

Hello,
Here is a WIP version of the time hook.

When pressing Ctrl+Q, you can toggle increasing time speed.

Download:
xwa_hook_time_WIP_2208022125.zip