View Issue Details

IDProjectCategoryView StatusLast Update
0004865The Dark ModGraphicspublic09.03.2020 11:05
Reporterstgatilov Assigned Tocabalistic  
PrioritylowSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product VersionTDM 2.06 
Target VersionTDM 2.08Fixed in VersionTDM 2.08 
Summary0004865: Improve the way how FPS cap works (uncapped FPS)
DescriptionThis issue is only about uncapped FPS mode.
Right now we limit frames on about 125 FPS. It seems that the way it works now means that 6 ms pause is added to each frame, even if FPS is lower than the cap.

It is worth looking for improvement.
Additional InformationDiscission:
  http://forums.thedarkmod.com/topic/19540-sometimes-tdm-is-slow-and-laggy/page-2#entry424731
TagsNo tags attached.

Relationships

related to 0004696 resolvedstgatilov At high FPS player footsteps don't always play 
related to 0004493 resolvedduzenko Some physics events have changed in 2.05 due to faster fps 
related to 0003684 new Investigate GPL Renderer Improvements 
related to 0004514 resolvedstgatilov Game runs sluggish randomly 

Activities

stgatilov

stgatilov

15.07.2018 03:58

administrator   ~0010680

Note: the original reason to limit FPS was the related issue 0004696.
So when working this issue, make sure to test that issue thoroughly.
duzenko

duzenko

15.07.2018 05:38

developer   ~0010681

Last edited: 15.07.2018 09:52

I was wrong in that it's adding 6 ms to each frame.
It's just that it's sleeping one additional ms due to Windows Sleep() precision, so max FPS is right now 1000 / 7 = ~ 140.
I suggest changing the hard-coded delay from 6000 to 4000 microseconds in idSessionLocal::Frame.
I imagine it will result in 200 max fps.
If you still want the 166 fps, then the delay should be 5000.

duzenko

duzenko

15.07.2018 05:44

developer   ~0010682

Things to test include:
http://bugs.thedarkmod.com/view.php?id=4493#c9210
http://bugs.thedarkmod.com/view.php?id=4493#c9211
stgatilov

stgatilov

15.07.2018 07:48

administrator   ~0010683

The delay was initially 4000 us.
But it turned out to be not enough.
duzenko

duzenko

15.07.2018 09:52

developer   ~0010684

Can we put this under a cvar?
stgatilov

stgatilov

15.07.2018 11:21

administrator   ~0010685

Yes, of course we can. There were even some suggestions.
But cvar needs a reliable default, and this should be chosen conservatively =)

By the way, if we are talking about the code after Cabalistic's patch, then the following spin lock gives be precisely 200 FPS:
  static int64_t prevUsec = INT64_MIN;
  while (Sys_GetTimeMicroseconds() - prevUsec < 5000)
    _mm_pause();
  prevUsec = Sys_GetTimeMicroseconds();
duzenko

duzenko

16.07.2018 05:35

developer   ~0010688

The current code might produce the same 200 FPS with 4000microseconds wait.
nbohr1more

nbohr1more

11.12.2018 06:18

developer   ~0010879

To my knowledge, the last part of this discussion was concluded "Too risky for 2.07". As such I am moving this to 2.08
stgatilov

stgatilov

06.03.2019 15:21

administrator   ~0011673

Last edited: 08.03.2019 06:47

While fixing related issue 0004514, the FPS limit was removed in rev 8035 by Cabalistic's patch.
I have reapplied the limit in rev 8036 using the busywait approach described above.

UPDATE: The max FPS limit was buggy, leading to infinite loop.
Commits 8039 and 8040 fix this.

stgatilov

stgatilov

06.03.2019 15:24

administrator   ~0011674

Experimentally, the FPS limit is still quantized to 142 / 166 / 200 / 250 / 333 / 500 FPS. While Sleep(1) is removed, the frame still takes integer number of milliseconds on average.

The current default of 166 means that most likely real FPS limit will be 142, which seems good enough even for 144 Hz monitors.
stgatilov

stgatilov

06.03.2019 15:25

administrator   ~0011675

Cabalistic, do you have anything to do in this issue?

Issue History

Date Modified Username Field Change
15.07.2018 03:57 stgatilov New Issue
15.07.2018 03:57 stgatilov Relationship added related to 0004696
15.07.2018 03:58 stgatilov Note Added: 0010680
15.07.2018 05:38 duzenko Note Added: 0010681
15.07.2018 05:38 duzenko Note Edited: 0010681
15.07.2018 05:39 duzenko Note Edited: 0010681
15.07.2018 05:40 duzenko Note Edited: 0010681
15.07.2018 05:44 duzenko Note Added: 0010682
15.07.2018 05:44 duzenko Relationship added related to 0004493
15.07.2018 07:48 stgatilov Note Added: 0010683
15.07.2018 09:52 duzenko Note Added: 0010684
15.07.2018 09:52 duzenko Note Edited: 0010681
15.07.2018 11:21 stgatilov Note Added: 0010685
16.07.2018 02:35 stgatilov Summary Improve the way how FPS cap works (unfixed tic) => Improve the way how FPS cap works (uncapped FPS)
16.07.2018 05:35 duzenko Note Added: 0010688
11.12.2018 06:18 nbohr1more Note Added: 0010879
11.12.2018 06:18 nbohr1more Target Version TDM 2.07 => TDM 2.08
11.12.2018 06:18 nbohr1more Assigned To => cabalistic
11.12.2018 06:18 nbohr1more Status new => acknowledged
20.12.2018 16:31 nbohr1more Relationship added related to 0003684
04.03.2019 16:33 stgatilov Relationship added related to 0004514
06.03.2019 15:21 stgatilov Note Added: 0011673
06.03.2019 15:24 stgatilov Note Added: 0011674
06.03.2019 15:25 stgatilov Note Added: 0011675
06.03.2019 15:25 stgatilov Status acknowledged => feedback
08.03.2019 06:47 stgatilov Note Edited: 0011673
09.03.2020 11:05 stgatilov Status feedback => resolved
09.03.2020 11:05 stgatilov Resolution open => fixed
09.03.2020 11:05 stgatilov Fixed in Version => TDM 2.08