Reduce CPU usage and increase FPS

A Forum dedicated to the Suggestion, Creation and Editing of XWA Dynamic Link Library Files

Moderator: JeremyaFr

Reduce CPU usage and increase FPS

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sun Mar 15, 2015 7:06 pm

Hello,

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

xwa_hook_time.zip

User avatar
Darksaber
Vice Admiral
Posts: 10931
Joined: Mon Jan 10, 2000 12:01 am
Contact:

Post by Darksaber » Sun Mar 15, 2015 10:23 pm

So does this remove the need to run XWA on one core, using Runfirst.exe

http://www.xwaupgrade.com/phpBB3008/vie ... 10&t=10594
“You can please some of the people all of the time, you can please all of the people some of the time, but you can’t please all of the people all of the time”.”
- John Lydgate

Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sun Mar 15, 2015 10:35 pm

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.

craig_mac
Cadet 3rd Class
Posts: 31
Joined: Sun Jun 10, 2001 11:01 pm

Post by craig_mac » Sun Mar 13, 2016 9:45 pm

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 !
craig mac

Reimar
Cadet 1st Class
Posts: 239
Joined: Mon Jan 19, 2009 11:45 am

Post by Reimar » Fri Apr 08, 2016 5:08 pm

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.

craig_mac
Cadet 3rd Class
Posts: 31
Joined: Sun Jun 10, 2001 11:01 pm

Post by craig_mac » Mon Apr 11, 2016 10:17 am

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
craig mac

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Fri Dec 14, 2018 5:14 pm

UPDATE

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

Please redownload xwa_hook_time.zip

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Feb 04, 2019 7:20 pm

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

User avatar
Darksaber
Vice Admiral
Posts: 10931
Joined: Mon Jan 10, 2000 12:01 am
Contact:

Post by Darksaber » Mon Feb 04, 2019 9:13 pm

Thanks :)
“You can please some of the people all of the time, you can please all of the people some of the time, but you can’t please all of the people all of the time”.”
- John Lydgate

Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

evilmark
Cadet 2nd Class
Posts: 51
Joined: Tue Feb 05, 2019 12:43 am

Post by evilmark » Tue Feb 05, 2019 2:05 am

the 60fps part isn't working for me, game won't go higher than 11 fps for some reason

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sat Jun 22, 2019 7:54 pm

UPDATE

Hello,
I've updated the time hook.

I've removed the limit of 59 fps.

User avatar
Phoenix Leader
Rebel Alliance
Posts: 437
Joined: Wed Aug 08, 2018 2:20 pm

Post by Phoenix Leader » Wed Jun 26, 2019 11:16 pm

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 ?

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Thu Jun 27, 2019 8:35 pm

The new limit is 236 fps.

User avatar
Phoenix Leader
Rebel Alliance
Posts: 437
Joined: Wed Aug 08, 2018 2:20 pm

Post by Phoenix Leader » Fri Jun 28, 2019 2:27 am

Great. X-Wing Alliance on 120 Hz and 144 Hz monitors will be amazing.

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » 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.

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

Bman
Lieutenant Commander
Posts: 1167
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Sat Mar 12, 2022 6:36 pm

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.
W-I-P: TFTC, MC Viscount Cr., ISD-II Avenger, NL-1 Platform, Ton-Falk Esc. Cr., & Misc.

Bman
Lieutenant Commander
Posts: 1167
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » 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?
W-I-P: TFTC, MC Viscount Cr., ISD-II Avenger, NL-1 Platform, Ton-Falk Esc. Cr., & Misc.

User avatar
Ace Antilles
Admiral (Moderator)
Posts: 7824
Joined: Sat Jan 22, 2000 12:01 am
Contact:

Post by Ace Antilles » Fri May 06, 2022 8:17 pm

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?
Chief XWAU Team annoying nitpicker.
Ace Antilles - The X-Wing Outpost
Image

User avatar
Ace Antilles
Admiral (Moderator)
Posts: 7824
Joined: Sat Jan 22, 2000 12:01 am
Contact:

Post by Ace Antilles » Fri May 06, 2022 8:18 pm

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.
Chief XWAU Team annoying nitpicker.
Ace Antilles - The X-Wing Outpost
Image

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Fri May 06, 2022 8:27 pm

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?

Bman
Lieutenant Commander
Posts: 1167
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Fri May 06, 2022 9:44 pm

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. ???
W-I-P: TFTC, MC Viscount Cr., ISD-II Avenger, NL-1 Platform, Ton-Falk Esc. Cr., & Misc.

aidor
Cadet 4th Class
Posts: 21
Joined: Mon Jun 06, 2011 3:15 pm

Post by aidor » Mon May 23, 2022 2:10 pm

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.

User avatar
Ace Antilles
Admiral (Moderator)
Posts: 7824
Joined: Sat Jan 22, 2000 12:01 am
Contact:

Post by Ace Antilles » Mon May 23, 2022 2:17 pm

Use hooks.ini for custom settings
Chief XWAU Team annoying nitpicker.
Ace Antilles - The X-Wing Outpost
Image

aidor
Cadet 4th Class
Posts: 21
Joined: Mon Jun 06, 2011 3:15 pm

Post by aidor » Mon May 23, 2022 3:06 pm

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.

User avatar
JeremyaFr
XWAU Member
Posts: 3918
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Aug 02, 2022 7:30 pm

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
You do not have the required permissions to view the files attached to this post.

Post Reply