make frame skip a preference
good values are 1 - render only even frames 3 - render only frames divisble by 4 (i.e., only 25%) anything higher is probably just choppy
This commit is contained in:
parent
a2ddef78de
commit
d5c916b724
4 changed files with 6 additions and 22 deletions
|
@ -469,6 +469,8 @@ public:
|
||||||
bool HardwareCursor; /// If true, uses the hardware to draw the cursor. Shaders do no longer apply to the cursor, but this way it's decoupled from the game refresh rate
|
bool HardwareCursor; /// If true, uses the hardware to draw the cursor. Shaders do no longer apply to the cursor, but this way it's decoupled from the game refresh rate
|
||||||
bool SelectionRectangleIndicatesDamage; /// If true, the selection rectangle interpolates color to indicate damage
|
bool SelectionRectangleIndicatesDamage; /// If true, the selection rectangle interpolates color to indicate damage
|
||||||
|
|
||||||
|
int FrameSkip; /// Mask used to skip rendering frames (useful for slow renderers that keep up with the game logic, but not the rendering to screen like e.g. original Raspberry Pi)
|
||||||
|
|
||||||
int ShowOrders; /// How many second show orders of unit on map.
|
int ShowOrders; /// How many second show orders of unit on map.
|
||||||
int ShowNameDelay; /// How many cycles need to wait until unit's name popup will appear.
|
int ShowNameDelay; /// How many cycles need to wait until unit's name popup will appear.
|
||||||
int ShowNameTime; /// How many cycles need to show unit's name popup.
|
int ShowNameTime; /// How many cycles need to show unit's name popup.
|
||||||
|
|
|
@ -405,7 +405,7 @@ void Exit(int err)
|
||||||
FreeButtonStyles();
|
FreeButtonStyles();
|
||||||
FreeAllContainers();
|
FreeAllContainers();
|
||||||
freeGuichan();
|
freeGuichan();
|
||||||
fprintf(stdout, "Frames %lu, Slow frames %d = %ld%%\n",
|
fprintf(stdout, "Frames %lu, Slow frames %ld = %ld%%\n",
|
||||||
FrameCounter, SlowFrameCounter,
|
FrameCounter, SlowFrameCounter,
|
||||||
(SlowFrameCounter * 100) / (FrameCounter ? FrameCounter : 1));
|
(SlowFrameCounter * 100) / (FrameCounter ? FrameCounter : 1));
|
||||||
lua_settop(Lua, 0);
|
lua_settop(Lua, 0);
|
||||||
|
|
|
@ -37,6 +37,8 @@ class CPreference
|
||||||
bool HardwareCursor;
|
bool HardwareCursor;
|
||||||
bool SelectionRectangleIndicatesDamage;
|
bool SelectionRectangleIndicatesDamage;
|
||||||
|
|
||||||
|
unsigned int FrameSkip;
|
||||||
|
|
||||||
unsigned int ShowOrders;
|
unsigned int ShowOrders;
|
||||||
unsigned int ShowNameDelay;
|
unsigned int ShowNameDelay;
|
||||||
unsigned int ShowNameTime;
|
unsigned int ShowNameTime;
|
||||||
|
|
|
@ -719,9 +719,6 @@ const EventCallback *GetCallbacks()
|
||||||
return Callbacks;
|
return Callbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SkipFrameMask = 0;
|
|
||||||
static unsigned long NextSlowFrameReaction = FRAMES_PER_SECOND * 10;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** Wait for interactive input event for one frame.
|
** Wait for interactive input event for one frame.
|
||||||
**
|
**
|
||||||
|
@ -741,23 +738,6 @@ void WaitEventsOneFrame()
|
||||||
Uint32 ticks = SDL_GetTicks();
|
Uint32 ticks = SDL_GetTicks();
|
||||||
if (ticks > NextFrameTicks) { // We are too slow :(
|
if (ticks > NextFrameTicks) { // We are too slow :(
|
||||||
++SlowFrameCounter;
|
++SlowFrameCounter;
|
||||||
if (SlowFrameCounter > NextSlowFrameReaction) {
|
|
||||||
unsigned long pct = (SlowFrameCounter * 100) / (FrameCounter ? FrameCounter : 1);
|
|
||||||
if (pct >= 60) {
|
|
||||||
SkipFrameMask = 0b111;
|
|
||||||
} else if (pct >= 40) {
|
|
||||||
SkipFrameMask = 0b101;
|
|
||||||
} else if (pct >= 20) {
|
|
||||||
SkipFrameMask = 0b11;
|
|
||||||
} else if (pct >= 10) {
|
|
||||||
SkipFrameMask = 0b1;
|
|
||||||
}
|
|
||||||
NextSlowFrameReaction += FRAMES_PER_SECOND * 10;
|
|
||||||
fprintf(stdout, "WARNING WARNING WARNING\n"
|
|
||||||
"Frames %lu, Slow frames %d = %lu%%, starting to render only every %d%s frame.\n",
|
|
||||||
FrameCounter, SlowFrameCounter, pct, SkipFrameMask + 1, SkipFrameMask == 1 ? "nd" : "th");
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputMouseTimeout(*GetCallbacks(), ticks);
|
InputMouseTimeout(*GetCallbacks(), ticks);
|
||||||
|
@ -855,7 +835,7 @@ void RealizeVideoMemory()
|
||||||
if (dummyRenderer) {
|
if (dummyRenderer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (FrameCounter & SkipFrameMask) {
|
if (Preference.FrameSkip && (FrameCounter & Preference.FrameSkip)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (NumRects) {
|
if (NumRects) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue