Changeset - r28494:36520b934394
[Not reviewed]
master
0 1 0
Jonathan G Rennison - 11 months ago 2024-01-16 22:23:31
j.g.rennison@gmail.com
Fix: Excessive switching of horizontal scale for FPS graph 60 Hz categories
1 file changed with 12 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/framerate_gui.cpp
Show inline comments
 
@@ -798,21 +798,27 @@ struct FrametimeGraphWindow : Window {
 
			size->height += size_s_label.height + 2;
 
		}
 
	}
 

	
 
	void SelectHorizontalScale(TimingMeasurement range)
 
	{
 
		/* 60 Hz graphical drawing results in a value of approximately TIMESTAMP_PRECISION,
 
		 * this lands exactly on the scale = 2 vs scale = 4 boundary.
 
		 * To avoid excessive switching of the horizontal scale, bias these performance
 
		 * categories away from this scale boundary. */
 
		if (this->element == PFE_DRAWING || this->element == PFE_DRAWWORLD) range += (range / 2);
 

	
 
		/* Determine horizontal scale based on period covered by 60 points
 
		 * (slightly less than 2 seconds at full game speed) */
 
		struct ScaleDef { TimingMeasurement range; int scale; };
 
		static const ScaleDef hscales[] = {
 
			{ 120, 60 },
 
			{  10, 20 },
 
			{   5, 10 },
 
			{   3,  4 },
 
			{   1,  2 },
 
			{ TIMESTAMP_PRECISION * 120, 60 },
 
			{ TIMESTAMP_PRECISION *  10, 20 },
 
			{ TIMESTAMP_PRECISION *   5, 10 },
 
			{ TIMESTAMP_PRECISION *   3,  4 },
 
			{ TIMESTAMP_PRECISION *   1,  2 },
 
		};
 
		for (const ScaleDef *sc = hscales; sc < hscales + lengthof(hscales); sc++) {
 
			if (range < sc->range) this->horizontal_scale = sc->scale;
 
		}
 
	}
 

	
 
@@ -866,13 +872,13 @@ struct FrametimeGraphWindow : Window {
 

	
 
			/* Accumulate period of time covered by data */
 
			time_sum += lastts - timestamps[point];
 
			lastts = timestamps[point];
 

	
 
			/* Enough data to select a range and get decent data density */
 
			if (count == 60) this->SelectHorizontalScale(time_sum / TIMESTAMP_PRECISION);
 
			if (count == 60) this->SelectHorizontalScale(time_sum);
 

	
 
			/* End when enough points have been collected and the horizontal scale has been exceeded */
 
			if (count >= 60 && time_sum >= (this->horizontal_scale + 2) * TIMESTAMP_PRECISION / 2) break;
 
		}
 

	
 
		this->SelectVerticalScale(peak_value);
0 comments (0 inline, 0 general)