nipkownix / re4_tweaks

Fixes and tweaks for the "UHD" port of Resident Evil 4
zlib License
342 stars 32 forks source link

Increase GPU usage #250

Open kTeo-0 opened 2 years ago

kTeo-0 commented 2 years ago

Describe the feature you'd like to see added

If i'm not mistaken, this game is almost entirely restricted to use CPU for rendering everything and that may be the biggest problem with slowmotion. Not sure but IF i'm right about that, Is there a way to increase GPU usage?

emoose commented 2 years ago

It does make use of DX9 for rendering (which uses GPU), but it doesn't really make use of it "natively", the game code is still calling into GX APIs which were used on Gamecube/Wii, except the X360 port team added a layer which translates the GX calls over to DirectX9 - probably adding a bit of CPU overhead in the process.

Maybe possible to optimize those calls a little, but doubt it'd help that much really... I did notice they used a flag when initing DX9 which slowed down FPS a lot though, but removing that flag makes things pretty unstable (the flag is meant for increased multi-thread stability): https://github.com/nipkownix/re4_tweaks/issues/44

Haven't been able to improve stability with it much yet, but maybe worth looking into some more...

FutonGama commented 2 years ago

Its not possible change to Vulkan? AMD users have reported to me have problems with this game. I think Vulkan can be great for both platforms.

qingsheng8848 commented 2 years ago

Ah, if it can reduce the power consumption of the CPU is also great. My CPU is i5-10200h. I play HD project game. The CPU actually reached 90 degrees Celsius. GPU is only 60 degrees Celsius

emoose commented 2 years ago

You could try dxvk to make it run on Vulkan instead, IIRC nipkow did mention it improving performance a little, maybe could help increase GPU usage/framerate for others too, but doubt it'd help with CPU usage much (game is already going from GX->DX9->GPU, dxvk would add yet another layer to it...), could always be wrong though.

https://www.reddit.com/r/pcgaming/comments/mlfcsc/a_guide_to_dxvk_on_windows/ seems like a decent guide for how to set it up, haven't tried myself yet though (middle of reinstalling Windows atm)

There's not much chance of us being able to change the native gfx API the game uses though, besides not having that much experience with 3D APIs, there's also thousands of different gfx calls used in the game, without having source code trying to patch/hook all that would be a huge task...

(though one thing I'd like to look into is updating it from DX9 to DX9Ex, might be able to help with the Direct3DDevice9::Present freezes with #44 with that since PresentEx adds some extra flags... tried doing some tests but didn't have much luck with it yet though, seems Ex changed some D3DPOOL related stuff which the game makes use of...)

emoose commented 2 years ago

Could you guys try the build at https://github.com/nipkownix/re4_tweaks/pull/255 and see if that reduces framedrops/slow-motion for you?

E: also found a way to cut CPU usage quite a bit at https://github.com/nipkownix/re4_tweaks/issues/44#issuecomment-1178293241, will try getting that added in properly soon.

kTeo-0 commented 2 years ago

tried #255 and my game didn't open :\

EDIT: forgot to mention, i'm currently using no other DLLs and i'm on a fresh 1.0.6 EXE. I don't have any spare 1.1.0 EXEs atm to test it out

emoose commented 2 years ago

Huh darn, seems to work fine for me with 1.0.6, does setting MultithreadFix to false allow game to start for you?

Maybe worth trying to start the EXE with MultithreadFix = true a few times, might be a random launch issue, remember having those a few times with this stuff before...

E: if it still won't launch for you, could you try making a CrashDumps folder next to bio4.exe and see if anything gets written there?

kTeo-0 commented 2 years ago

nope, still can't get anything running. No crashlog either. Weird...

emoose commented 2 years ago

Added a new framelimiter which seems to reduce CPU usage quite a bit, you can find it here, would appreciate any testers for it! https://github.com/nipkownix/re4_tweaks/pull/257

nope, still can't get anything running. No crashlog either. Weird...

Even with MultithreadFix = false it fails to start too? If so that is strange, maybe something else that we changed recently is breaking it, could you try the build from https://github.com/nipkownix/re4_tweaks/actions/runs/2629839609 too?

kTeo-0 commented 2 years ago

Added a new framelimiter which seems to reduce CPU usage quite a bit, you can find it here, would appreciate any testers for it! #257

257 is giving me the same results: game doesn't even start, and there's no crashlog.

Even with MultithreadFix = false it fails to start too? If so that is strange, maybe something else that we changed recently is breaking it, could you try the build from https://github.com/nipkownix/re4_tweaks/actions/runs/2629839609 too? alright i have no idea what is going on here, but none of the builds i'm trying is giving me any different results.

by the way, i've found a dll that makes the game run on Vulkan, and so far all the lag is entirely gone. Areas that previously were lagging all the way down to 30fps are now on a smooth 60fps!

This dll has been working flawlessly for everyone that i asked to test it EXCEPT @FutonGama, but i think it could have something to do with him having previously been using reshade (it's the same d3d9.dll, maybe it writes something else in the exe or something).

Link to the tool i used for this: https://github.com/doitsujin/dxvk/releases/tag/v1.10.1

emoose commented 2 years ago

Hmm, did you try it without dxvk installed? Could be something incompatible with it, besides that maybe worth checking if the last published 1.7.6 release works? https://github.com/nipkownix/re4_tweaks/releases/tag/1.7.6

and so far all the lag is entirely gone. Areas that previously were lagging all the way down to 30fps are now on a smooth 60fps!

Wow nice, didn't expect dxvk to work that well, interesting... will have to try testing to make sure all our re4_tweaks stuff works fine with it.

E: whoa yeah, gives a nice performance boost, testing with uncapped framerate went from ~236 up to ~366FPS, not bad! (using GTX 1080, not sure if AMD cards will get the same boost...)

Seems to be working fine for me with latest re4_tweaks too, not really sure why you can't run it :/ maybe worth trying a fresh RE4 install?

Will have to test dxvk out some more, would be nice if we could eventually find a way to bundle it with re4_tweaks in some way, so we could allow checking for Vulkan support & toggling it etc.

E: the latest dxvk seems to add another +10FPS, I did get one crash when trying to load savegame though, so not sure if it's as stable as 1.10.1... artifact can be found at https://github.com/doitsujin/dxvk/actions/runs/2641291447


BTW the UseDynamicFrametime setting added in https://github.com/nipkownix/re4_tweaks/pull/257 should hopefully get rid of any slowdown when FPS drops while in-game (menus still seem a little weird though)

I'm not sure if the way that works might break anything at all though, game was never designed to work with dynamic frametimes after all, don't know if that was deliberate or maybe they just never thought of it.

Would be great to hear from anyone that tests it out!

lAlexl7l commented 2 years ago

So i try this https://github.com/nipkownix/re4_tweaks/pull/257 but the game doesnt even start it crashes at the begining does this one requires something special to amke it run?

emoose commented 2 years ago

@lAlexl7l nah it should be running without needing anything else, could you try seeing if changing the ReplaceFramelimiter setting helps at all?

If that doesn't help, maybe try the https://github.com/nipkownix/re4_tweaks/releases/tag/1.7.6 release and see if that works with your setup.

lAlexl7l commented 2 years ago

1.7.6 version works but it lags on me and crashes on some areas this one it just crashes on start game window doenst even show up i did put ReplaceFramelimiter to true and still happends

Edit: nvm it works now i guess i grab the debug version and not the release version by accident gonna test it now

Edit 2: so far i being experience increase in performance compare to vanilla 1.7.6 it runs better now have a random crash on chapter 4-2 at the beging but when back to that room and it didnt crash

nipkownix commented 2 years ago

Just updated the test builds in #257 and #255. If anyone can test a bit more, that'd be nice. Thanks!

nipkownix commented 2 years ago

Also, btw:

tried https://github.com/nipkownix/re4_tweaks/pull/255 and my game didn't open :\

I'm pretty sure that was indeed happening because you were trying to use a debug version, not a release one :p Not sure why, though.

I've been linking the release version now to avoid confusion.

nipkownix commented 1 year ago

@FutonGama @kTeo-0 This builds adds Vulkan support + MultithreadFix: https://github.com/nipkownix/re4_tweaks/suites/9403429268/artifacts/443786662

Could you guys check if your performance usage improves with it?