Add ability to select SDL driver.
On a Pi3 opengles2 performs better. Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
e7e848917b
commit
70969a2d03
5 changed files with 26 additions and 26 deletions
|
@ -15,7 +15,8 @@ bool getEmulatorOptions(int argc, const char * argv [], const std::string & vers
|
|||
("conf", "Save configuration on exit")
|
||||
("multi-threaded,m", "Multi threaded")
|
||||
("loose-mutex,l", "Loose mutex")
|
||||
("timer-interval,i", po::value<int>()->default_value(16), "Timer interval in ms")
|
||||
("sdl-driver", po::value<int>()->default_value(options.sdlDriver), "SDL driver")
|
||||
("timer-interval,i", po::value<int>()->default_value(options.timerInterval), "Timer interval in ms")
|
||||
("qt-ini,q", "Use Qt ini file (read only)");
|
||||
|
||||
po::options_description diskDesc("Disk");
|
||||
|
@ -32,7 +33,7 @@ bool getEmulatorOptions(int argc, const char * argv [], const std::string & vers
|
|||
|
||||
po::options_description memoryDesc("Memory");
|
||||
memoryDesc.add_options()
|
||||
("memclear", po::value<int>(), "Memory initialization pattern [0..7]");
|
||||
("memclear", po::value<int>()->default_value(options.memclear), "Memory initialization pattern [0..7]");
|
||||
desc.add(memoryDesc);
|
||||
|
||||
po::options_description emulatorDesc("Emulator");
|
||||
|
@ -60,6 +61,7 @@ bool getEmulatorOptions(int argc, const char * argv [], const std::string & vers
|
|||
options.multiThreaded = vm.count("multi-threaded");
|
||||
options.looseMutex = vm.count("loose-mutex");
|
||||
options.timerInterval = vm["timer-interval"].as<int>();
|
||||
options.sdlDriver = vm["sdl-driver"].as<int>();
|
||||
|
||||
if (vm.count("d1"))
|
||||
{
|
||||
|
@ -78,12 +80,9 @@ bool getEmulatorOptions(int argc, const char * argv [], const std::string & vers
|
|||
options.snapshot = vm["load-state"].as<std::string>();
|
||||
}
|
||||
|
||||
if (vm.count("memclear"))
|
||||
{
|
||||
const int memclear = vm["memclear"].as<int>();
|
||||
if (memclear >=0 && memclear < NUM_MIP)
|
||||
options.memclear = memclear;
|
||||
}
|
||||
|
||||
options.benchmark = vm.count("benchmark") > 0;
|
||||
options.headless = vm.count("headless") > 0;
|
||||
|
|
|
@ -7,29 +7,30 @@ struct EmulatorOptions
|
|||
{
|
||||
std::string disk1;
|
||||
std::string disk2;
|
||||
bool createMissingDisks;
|
||||
bool createMissingDisks = false;
|
||||
|
||||
std::string snapshot;
|
||||
|
||||
int memclear;
|
||||
int memclear = 0;
|
||||
|
||||
bool log;
|
||||
bool log = false;
|
||||
|
||||
bool benchmark;
|
||||
bool headless;
|
||||
bool ntsc;
|
||||
bool benchmark = false;
|
||||
bool headless = false;
|
||||
bool ntsc = false; // only for applen
|
||||
|
||||
bool squaring; // turn the x/y range to a square
|
||||
bool squaring = true; // turn the x/y range to a square
|
||||
|
||||
bool saveConfigurationOnExit;
|
||||
bool useQtIni; // use Qt .ini file (read only)
|
||||
bool saveConfigurationOnExit = false;
|
||||
bool useQtIni = false; // use Qt .ini file (read only)
|
||||
|
||||
bool run; // false if options include "-h"
|
||||
bool run = true; // false if options include "-h"
|
||||
|
||||
bool multiThreaded;
|
||||
bool looseMutex; // whether SDL_UpdateTexture is mutex protected (from CPU)
|
||||
int timerInterval; // only when multithreaded
|
||||
bool multiThreaded = false;
|
||||
bool looseMutex = false; // whether SDL_UpdateTexture is mutex protected (from CPU)
|
||||
int timerInterval = 16; // only when multithreaded
|
||||
|
||||
int sdlDriver = -1; // default = -1 to let SDL choose
|
||||
};
|
||||
|
||||
bool getEmulatorOptions(int argc, const char * argv [], const std::string & version, EmulatorOptions & options);
|
||||
|
|
|
@ -226,7 +226,7 @@ void run_sdl(int argc, const char * argv [])
|
|||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<SDL_Renderer> ren(SDL_CreateRenderer(win.get(), -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), SDL_DestroyRenderer);
|
||||
std::shared_ptr<SDL_Renderer> ren(SDL_CreateRenderer(win.get(), options.sdlDriver, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), SDL_DestroyRenderer);
|
||||
if (!ren)
|
||||
{
|
||||
std::cout << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl;
|
||||
|
@ -234,7 +234,7 @@ void run_sdl(int argc, const char * argv [])
|
|||
}
|
||||
|
||||
const Uint32 format = SDL_PIXELFORMAT_ARGB8888;
|
||||
printRendererInfo(std::cerr, ren, format);
|
||||
printRendererInfo(std::cerr, ren, format, options.sdlDriver);
|
||||
|
||||
std::shared_ptr<SDL_Texture> tex(SDL_CreateTexture(ren.get(), format, SDL_TEXTUREACCESS_STATIC, width, height), SDL_DestroyTexture);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "frontends/sa2/utils.h"
|
||||
#include <ostream>
|
||||
|
||||
void printRendererInfo(std::ostream & os, std::shared_ptr<SDL_Renderer> & ren, const Uint32 pixelFormat)
|
||||
void printRendererInfo(std::ostream & os, std::shared_ptr<SDL_Renderer> & ren, const Uint32 pixelFormat, const int selectedDriver)
|
||||
{
|
||||
SDL_RendererInfo info;
|
||||
SDL_GetRendererInfo(ren.get(), &info);
|
||||
|
@ -17,7 +17,7 @@ void printRendererInfo(std::ostream & os, std::shared_ptr<SDL_Renderer> & ren, c
|
|||
|
||||
if (SDL_GetRendererInfo(ren.get(), &info) == 0)
|
||||
{
|
||||
os << "Active driver: " << info.name << std::endl;
|
||||
os << "Active driver (" << selectedDriver << "): " << info.name << std::endl;
|
||||
os << " SDL_RENDERER_SOFTWARE: " << ((info.flags & SDL_RENDERER_SOFTWARE) > 0) << std::endl;
|
||||
os << " SDL_RENDERER_ACCELERATED: " << ((info.flags & SDL_RENDERER_ACCELERATED) > 0) << std::endl;
|
||||
os << " SDL_RENDERER_PRESENTVSYNC: " << ((info.flags & SDL_RENDERER_PRESENTVSYNC) > 0) << std::endl;
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
#include <memory>
|
||||
#include <iosfwd>
|
||||
|
||||
void printRendererInfo(std::ostream & os, std::shared_ptr<SDL_Renderer> & ren, const Uint32 pixelFormat);
|
||||
void printRendererInfo(std::ostream & os, std::shared_ptr<SDL_Renderer> & ren, const Uint32 pixelFormat, const int selectedDriver);
|
||||
|
|
Loading…
Add table
Reference in a new issue