@@ -2162,6 +2162,13 @@ SK_Framerate_SanitizeTimerResolution (void) noexcept
21622162 if (! config.render .framerate .max_timer_resolution )
21632163 return ;
21642164
2165+ // Only do this occasionally, it defeats the purpose to
2166+ // call it frequently.
2167+ static int
2168+ tick_tock = 0 ;
2169+ if (++tick_tock % 64 != 0 )
2170+ return ;
2171+
21652172 auto _SetTimerResolution =
21662173 ( ZwSetTimerResolution_Original != nullptr ) ?
21672174 ZwSetTimerResolution_Original :
@@ -2211,7 +2218,7 @@ extern bool reset_frame_history;
22112218
22122219void
22132220SK ::Framerate::Limiter::wait (void ) noexcept
2214- {
2221+ {
22152222 // This is actually counter-productive in testing... when the thread priority
22162223 // is lowered after this goes out of scope it may reschedule the thread.
22172224 // SK_Thread_ScopedPriority prio_scope (THREAD_PRIORITY_TIME_CRITICAL);
@@ -2506,6 +2513,7 @@ SK::Framerate::Limiter::wait (void) noexcept
25062513 }
25072514 }
25082515
2516+ // Trigger a timer phase shift.
25092517 SK_Framerate_SanitizeTimerResolution ();
25102518
25112519 // Create an unnamed waitable timer.
@@ -4502,7 +4510,7 @@ SK::Framerate::TickEx ( bool /*wait*/,
45024510
45034511
45044512 // Prevent inserting infinity into the dataset
4505- if ( std::isnormal (dt) )
4513+ // if ( std::isnormal (dt) )
45064514 {
45074515 if (snapshots->frame_history .addSample (1000.0 * dt, now))
45084516 {
@@ -4597,7 +4605,7 @@ SK::Framerate::TickEx ( bool /*wait*/,
45974605 } break ;
45984606 }
45994607
4600- if (std::isnormal (sample) && now.QuadPart > 0 )
4608+ if (/* std::isnormal(sample) &&*/ now.QuadPart > 0 )
46014609 {
46024610 container->addSample (
46034611 sample, now
@@ -4610,25 +4618,31 @@ SK::Framerate::TickEx ( bool /*wait*/,
46104618
46114619int sk_config_t::fps_osd_s::getTimingMethod (void )
46124620{
4613- if (__SK_IsDLSSGActive )
4614- {
4615- if (config. render . framerate . streamline . enable_native_limit )
4621+ switch (timing_method )
4622+ {
4623+ case SK_FrametimeMeasures_LimiterPacing:
46164624 {
4617- if (__target_fps_now <= 0 .0f && timing_method == SK_FrametimeMeasures_LimiterPacing)
4625+ if (__SK_IsDLSSGActive)
4626+ {
4627+ if (config.render .framerate .streamline .enable_native_limit )
4628+ {
4629+ if (__target_fps_now <= 0 .0f )
4630+ {
4631+ return SK_FrametimeMeasures_NewFrameBegin;
4632+ }
4633+ }
4634+
4635+ else if (__target_fps_now > 0 .0f )
4636+ {
4637+ return SK_FrametimeMeasures_PresentSubmit;
4638+ }
4639+ }
4640+
4641+ else if (__target_fps_now <= 0 .0f )
46184642 {
46194643 return SK_FrametimeMeasures_NewFrameBegin;
46204644 }
4621- }
4622-
4623- else if (__target_fps_now > 0 .0f && timing_method == SK_FrametimeMeasures_LimiterPacing)
4624- {
4625- return SK_FrametimeMeasures_PresentSubmit;
4626- }
4627- }
4628-
4629- else if (__target_fps_now <= 0 .0f && timing_method == SK_FrametimeMeasures_LimiterPacing)
4630- {
4631- return SK_FrametimeMeasures_NewFrameBegin;
4645+ } break ;
46324646 }
46334647
46344648 return timing_method;
@@ -4860,7 +4874,7 @@ SK::Framerate::Stats::sortAndCacheFrametimeHistory (void) //noexcept
48604874 {
48614875 if (datum.when .QuadPart >= 0 )
48624876 {
4863- if (isnormal (datum.val ))
4877+ // if (isnormal (datum.val))
48644878 {
48654879 kWriteBuffer .second .emplace_back (datum.val );
48664880 }
@@ -4891,6 +4905,7 @@ SK_Framerate_WaitUntilQPC (LONGLONG llQPC, HANDLE& hTimer) noexcept
48914905 if (llQPC < SK_QueryPerf ().QuadPart )
48924906 return ;
48934907
4908+ // Trigger a timer phase shift.
48944909 SK_Framerate_SanitizeTimerResolution ();
48954910
48964911 if ((LONG_PTR )hTimer < 0 )
@@ -5066,10 +5081,10 @@ SK_Framerate_EnergyControlPanel (void)
50665081}
50675082
50685083bool
5069- game_pacer_s::wantPacing (void ) noexcept
5084+ game_pacer_s::wantPacing (ULONG64 frames_drawn ) noexcept
50705085{
50715086 return
5072- config.render .framerate .pace_game_thread && isSupported () && event != 0 && last_frame_id > SK_GetFramesDrawn () - 2 ;
5087+ config.render .framerate .pace_game_thread && isSupported (frames_drawn ) && event != 0 && last_frame_id > frames_drawn - 2 ;
50735088}
50745089
50755090void
@@ -5080,10 +5095,10 @@ game_pacer_s::signalEvent (void) noexcept
50805095}
50815096
50825097bool
5083- game_pacer_s::isSupported (void ) noexcept
5098+ game_pacer_s::isSupported (ULONG64 frames_drawn ) noexcept
50845099{
50855100 static constexpr auto SK_Reflex_MinimumFramesBeforeNative = 150 ;
50865101
50875102 return
5088- last_frame_id != 0 && !config.nvidia .reflex .native && SK_GetFramesDrawn () > SK_Reflex_MinimumFramesBeforeNative;
5103+ last_frame_id != 0 && !config.nvidia .reflex .native && frames_drawn > SK_Reflex_MinimumFramesBeforeNative;
50895104}
0 commit comments