Skip to content

Conversation

emoose
Copy link
Collaborator

@emoose emoose commented Jul 9, 2022

As discussed at #44 (comment), this implements the FPS_ACCURATE framelimiter from https://github.com/ThirteenAG/d3d9-wrapper/blob/c1480b0c1b40e0ba7b55b8660bd67f911a967421/source/dllmain.cpp#L46

For me this gave a pretty nice CPU usage reduction:

CPU usage on main menu went from 7% to 1%, ingame from 10% to 4%

qingsheng8848 also mentioned:

it works very well, my CPU usage is reduced from 40% to about 20%.

The code is pretty close to the old framelimiter really, but I think the Sleep(1) call helps reduce CPU usage of the busy loop, there's also no longer a 0.01666666... minimum frametime with this so variableframerate above 60 should work better (though still probably has many issues like the ones mentioned in #50)

This also adds two settings to INI [DEBUG] section, DisableFramelimiting which should be useful for performance comparisons, and UseDynamicFrametime, which makes it pass the actual elapsed frametime to the game, instead of fixed 60/30FPS frametimes - this should help with the slowdown issue when framerate drops, but not sure how well things will work with non-fixed frametime, likely will have a lot of issues, so it's disabled by default for now.

Using both DisableFramelimiting & UseDynamicFrametime might come in useful for finding some non-framerate-adjusted things in the game too, eg. I noticed aiming with laser-sight seems slower using mouse to aim when FPS is very high, so I guess that might mean the aim speed is slightly different between 30/60 too. (#258 should fix that)

Haven't added any GUI options for the ReplaceFramelimiter setting yet, not really sure how to add stuff without breaking everything... would appreciate if you could show how to add a UI option for it with the new layout 😅


If anyone is willing to help test it out, a release build can be found at https://github.com/nipkownix/re4_tweaks/suites/7489502732/artifacts/307459942 - just be sure to set ReplaceFramelimiter = true in the dinput8.ini first!
(should work fine across all the usual EXEs)

We mainly just want to make sure the game still plays fine with this framelimiter in place, no idea if anything might be depending on the previous framelimiter behavior or not. If anyone finds anything broken please let us know!

@nipkownix
Copy link
Owner

Wow, nice work!

Haven't added any GUI options for the ReplaceFramelimiter setting yet, not really sure how to add stuff without breaking everything... would appreciate if you could show how to add a UI option for it with the new layout 😅

Ah.. sorry about that. I tried to make the new code easy to adjust, but I couldn't.

Basically, you have to change the table index (ImGui::TableSetColumnIndex(1/0)) every time you create a new option. You also have to save the Y position of the last item in the current column before moving to the next, and restore it when you get back to that column.
I've just pushed a commit to this PR that shows what I'm talking about.
I'm sure thee must be a better way to do this, though. If you can think of a better solution, let me know :p

(I haven't implemented the other options myself because it's 2:30 AM here and I'm very sleepy lol)

@emoose
Copy link
Collaborator Author

emoose commented Jul 9, 2022

Oh nice, not as difficult as I thought then heh, thanks for the explanation (and adding it to the UI :)

Had a little look at it and might have found a way to let us add things without needing to track 0/1 across items etc, I'll add it to this PR in a sec.

Maybe possible to add the ImGui::Dummy into it as well, but not really sure since it looks like Dummy gets used after all the items are setup too
(E: seems to be working, added it to the commit, not really sure if removing the final Dummy before ImGui::EndTable() might be breaking anything though, looks fine to me at least)

E: took a little while but figured a way to handle the bgHeight stuff in the new functions too, getting that to work properly needed a ColumnFinish func, so was able to add the final Dummy back inside there too 😸

@emoose emoose force-pushed the new-framelimiter branch 2 times, most recently from 5264d76 to 8862259 Compare July 9, 2022 07:56
@nipkownix
Copy link
Owner

nipkownix commented Jul 9, 2022

Amazing work with the helper functions! Thank you!

Edit: Just finished Assignment Ada with the new framelimiter and noticed no issues. Performance has also improved here!
Might be a good idea to have this enabled by default, once some more testing is done, but it looks very promising.

@emoose emoose force-pushed the new-framelimiter branch 3 times, most recently from 5c106c8 to e43f01a Compare July 9, 2022 15:32
@emoose
Copy link
Collaborator Author

emoose commented Jul 12, 2022

Seem to be getting a freeze early in the game, not sure if it's caused by this or something else though, was able to reproduce it once but not again after that.

Freeze happens when starting the cutscene where Leon looks down at the fallen police car, just freezes with the LOOK DOWN prompt stuck, was playing in fullscreen without debug build at the time so not sure where it was frozen at.
I might have heard of other people getting a freeze at this spot in the past too, so hopefully not a issue with this PR, but still an issue with something.

To reproduce I had to go through all the beginning cutscenes (besides the first one), making sure not to skip them or the radio calls, then jump out of the upstairs window, kill enemies, and run over to where police car fell and press the LOOK DOWN prompt button - this got it to freeze twice, but third time onwards seemed to play it fine.

Gonna test some more with this PR, will update if anything else seems broken.

E: played up to 1-2 (I'm pretty slow at this game :p), no other issues so far.

@nipkownix
Copy link
Owner

Tested it a bit more here and everything went smooth. Couldn't reproduce the freeze you mentioned.

@emoose
Copy link
Collaborator Author

emoose commented Jul 14, 2022

I'm sure I heard about that freeze somewhere else before, can't find much about it now though.

Tried testing out UseDynamicFrametime with 51FPS nvidia framecap, seems to cause the freeze at start of first level issue that we had way back with one of the 90/120FPS fixes, don't think we ever found the actual cause for that though unfortunately, maybe will try looking into it more soon.

@nipkownix
Copy link
Owner

Ah, odd.
I'll see if I can dig something up tomorrow. Sorry for not helping much, I was a bit tied up reworking our ultrawide patches :p

@nipkownix
Copy link
Owner

FYI, I just cherry-picked 798bb47 into master so I can make a new release.

@nipkownix
Copy link
Owner

nipkownix commented Jul 23, 2022

Rebased this onto current master.

Updated build here:

https://github.com/nipkownix/re4_tweaks/suites/7489502732/artifacts/307459942

@emoose emoose mentioned this pull request Aug 23, 2022
2 tasks
@nipkownix
Copy link
Owner

Been playing a bit more using this, and no issue so far. Still can't reproduce the freeze from before.
I think we should merge this PR, and leave the new frame limiter enabled by default.

@emoose
Copy link
Collaborator Author

emoose commented Aug 26, 2022

Sounds good to me, I never had any freezing after that point I mentioned with it neither, hopefully was just some kind of fluke, or maybe just a vanilla bug.

Will have to try looking into the UseDynamicFrametime issue I mentioned above some more soon, would be really nice to get game actually playable at non-30/60 framerates with that turned on (rather than freezing on first cutscene...)

@nipkownix
Copy link
Owner

Will have to try looking into the UseDynamicFrametime issue I mentioned above some more soon, would be really nice to get game actually playable at non-30/60 framerates with that turned on (rather than freezing on first cutscene...)

Cool. Just rebased this again and turned the new frame limiter on by default. Hopefully we can get UseDynamicFrametime working at some point, but this should already be a big improvement to the game. Many thanks!

@nipkownix nipkownix merged commit c73bb79 into nipkownix:master Aug 27, 2022
@emoose
Copy link
Collaborator Author

emoose commented Sep 24, 2022

btw @nipkownix about the freeze I had with the police car, seems that's been happening for a while, someone mentioned it on re4hd recently: https://www.re4hd.com/?page_id=9319#comment-203270
and seems we did get a report about it here too: #62, but that was when we had issues with fonts which reporter also had.
Wonder what could be causing that, maybe it's framerate related, since we did get similar freezes with cutscenes when changing framerate at #328 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants