Add cmd line option to switch off vsync.
Useful to profile. Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
3051fbe3fe
commit
a75833847e
3 changed files with 14 additions and 6 deletions
|
@ -85,6 +85,7 @@ bool getEmulatorOptions(int argc, const char * argv [], const std::string & edit
|
||||||
("timer-interval,i", po::value<int>()->default_value(options.timerInterval), "Timer interval in ms")
|
("timer-interval,i", po::value<int>()->default_value(options.timerInterval), "Timer interval in ms")
|
||||||
("loose-mutex,l", "Loose mutex")
|
("loose-mutex,l", "Loose mutex")
|
||||||
("sdl-driver", po::value<int>()->default_value(options.sdlDriver), "SDL driver")
|
("sdl-driver", po::value<int>()->default_value(options.sdlDriver), "SDL driver")
|
||||||
|
("gl-swap", po::value<int>()->default_value(options.glSwapInterval), "SDL_GL_SwapInterval")
|
||||||
("imgui", "Render with Dear ImGui")
|
("imgui", "Render with Dear ImGui")
|
||||||
("size", po::value<std::string>(), "WxH")
|
("size", po::value<std::string>(), "WxH")
|
||||||
;
|
;
|
||||||
|
@ -114,6 +115,7 @@ bool getEmulatorOptions(int argc, const char * argv [], const std::string & edit
|
||||||
options.looseMutex = vm.count("loose-mutex");
|
options.looseMutex = vm.count("loose-mutex");
|
||||||
options.timerInterval = vm["timer-interval"].as<int>();
|
options.timerInterval = vm["timer-interval"].as<int>();
|
||||||
options.sdlDriver = vm["sdl-driver"].as<int>();
|
options.sdlDriver = vm["sdl-driver"].as<int>();
|
||||||
|
options.glSwapInterval = vm["gl-swap"].as<int>();
|
||||||
options.imgui = vm.count("imgui");
|
options.imgui = vm.count("imgui");
|
||||||
|
|
||||||
if (vm.count("config"))
|
if (vm.count("config"))
|
||||||
|
|
|
@ -38,6 +38,7 @@ struct EmulatorOptions
|
||||||
int sdlDriver = -1; // default = -1 to let SDL choose
|
int sdlDriver = -1; // default = -1 to let SDL choose
|
||||||
bool imgui = false; // use imgui renderer
|
bool imgui = false; // use imgui renderer
|
||||||
std::pair<int, int> size; // width x height
|
std::pair<int, int> size; // width x height
|
||||||
|
int glSwapInterval = 1; // SDL_GL_SetSwapInterval
|
||||||
|
|
||||||
std::vector<std::string> registryOptions;
|
std::vector<std::string> registryOptions;
|
||||||
};
|
};
|
||||||
|
|
|
@ -105,6 +105,11 @@ void run_sdl(int argc, const char * argv [])
|
||||||
frame.reset(new SDLRendererFrame(options));
|
frame.reset(new SDLRendererFrame(options));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (SDL_GL_SetSwapInterval(options.glSwapInterval))
|
||||||
|
{
|
||||||
|
throw std::runtime_error(SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
SetFrame(frame);
|
SetFrame(frame);
|
||||||
|
|
||||||
if (options.log)
|
if (options.log)
|
||||||
|
@ -131,14 +136,14 @@ void run_sdl(int argc, const char * argv [])
|
||||||
{
|
{
|
||||||
// we need to switch off vsync, otherwise FPS is limited to 60
|
// we need to switch off vsync, otherwise FPS is limited to 60
|
||||||
// and it will take longer to run
|
// and it will take longer to run
|
||||||
const int res = SDL_GL_SetSwapInterval(0);
|
if (SDL_GL_SetSwapInterval(0))
|
||||||
// if this fails, should we throw, print something or just ignore?
|
{
|
||||||
|
throw std::runtime_error(SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
const auto redraw = [&frame, res]{
|
const auto redraw = [&frame]{
|
||||||
frame->UpdateTexture();
|
frame->UpdateTexture();
|
||||||
if (res == 0) {
|
frame->RenderPresent();
|
||||||
frame->RenderPresent();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto refresh = [redraw, &video]{
|
const auto refresh = [redraw, &video]{
|
||||||
|
|
Loading…
Add table
Reference in a new issue