support --3d-render in common commandline parsing and use in windows port as a demo

This commit is contained in:
zeromus 2016-08-16 22:00:27 +00:00
parent 8c60f5fdf3
commit 9c1f523a72
3 changed files with 36 additions and 1 deletions

View File

@ -66,6 +66,7 @@ CommandLine::CommandLine()
, arm7_gdb_port(0) , arm7_gdb_port(0)
, start_paused(FALSE) , start_paused(FALSE)
, autodetect_method(-1) , autodetect_method(-1)
, render3d(COMMANDLINE_RENDER3D_DEFAULT)
{ {
#ifndef HOST_WINDOWS #ifndef HOST_WINDOWS
disable_sound = 0; disable_sound = 0;
@ -92,6 +93,8 @@ static const char* help_string = \
" --num-cores N Override numcores detection and use this many" ENDL " --num-cores N Override numcores detection and use this many" ENDL
" --spu-synch Use SPU synch (crackles; helps streams; default ON)" ENDL " --spu-synch Use SPU synch (crackles; helps streams; default ON)" ENDL
" --spu-method N Select SPU synch method: 0:N, 1:Z, 2:P; default 0" ENDL " --spu-method N Select SPU synch method: 0:N, 1:Z, 2:P; default 0" ENDL
" --3d-render [SW|AUTOGL|GL|OLDGL]" ENDL
" Select 3d renderer; default SW" ENDL
#ifndef HOST_WINDOWS #ifndef HOST_WINDOWS
" --disable-sound Disables the sound output" ENDL " --disable-sound Disables the sound output" ENDL
" --disable-limiter Disables the 60fps limiter" ENDL " --disable-limiter Disables the 60fps limiter" ENDL
@ -154,6 +157,7 @@ ENDL
#define OPT_NUMCORES 1 #define OPT_NUMCORES 1
#define OPT_SPU_METHOD 2 #define OPT_SPU_METHOD 2
#define OPT_3D_RENDER 3
#define OPT_JIT_SIZE 100 #define OPT_JIT_SIZE 100
#define OPT_CONSOLE_TYPE 200 #define OPT_CONSOLE_TYPE 200
@ -183,6 +187,8 @@ ENDL
bool CommandLine::parse(int argc,char **argv) bool CommandLine::parse(int argc,char **argv)
{ {
std::string _render3d;
int opt_help = 0; int opt_help = 0;
int option_index = 0; int option_index = 0;
for(;;) for(;;)
@ -197,6 +203,7 @@ bool CommandLine::parse(int argc,char **argv)
{ "num-cores", required_argument, NULL, OPT_NUMCORES }, { "num-cores", required_argument, NULL, OPT_NUMCORES },
{ "spu-synch", no_argument, &_spu_sync_mode, 1 }, { "spu-synch", no_argument, &_spu_sync_mode, 1 },
{ "spu-method", required_argument, NULL, OPT_SPU_METHOD }, { "spu-method", required_argument, NULL, OPT_SPU_METHOD },
{ "3d-render", required_argument, NULL, OPT_3D_RENDER },
#ifndef HOST_WINDOWS #ifndef HOST_WINDOWS
{ "disable-sound", no_argument, &disable_sound, 1}, { "disable-sound", no_argument, &disable_sound, 1},
{ "disable-limiter", no_argument, &disable_limiter, 1}, { "disable-limiter", no_argument, &disable_limiter, 1},
@ -265,6 +272,7 @@ bool CommandLine::parse(int argc,char **argv)
//user settings //user settings
case OPT_NUMCORES: _num_cores = atoi(optarg); break; case OPT_NUMCORES: _num_cores = atoi(optarg); break;
case OPT_SPU_METHOD: _spu_sync_method = atoi(optarg); break; case OPT_SPU_METHOD: _spu_sync_method = atoi(optarg); break;
case OPT_3D_RENDER: _render3d = optarg; break;
//sync settings //sync settings
case OPT_JIT_SIZE: _jit_size = atoi(optarg); break; case OPT_JIT_SIZE: _jit_size = atoi(optarg); break;
@ -343,6 +351,14 @@ bool CommandLine::parse(int argc,char **argv)
CommonSettings.DebugConsole = true; CommonSettings.DebugConsole = true;
} }
//process 3d renderer
_render3d = strtoupper(_render3d);
if(_render3d == "NONE") render3d = COMMANDLINE_RENDER3D_NONE;
if(_render3d == "SW") render3d = COMMANDLINE_RENDER3D_SW;
if(_render3d == "OLDGL") render3d = COMMANDLINE_RENDER3D_OLDGL;
if(_render3d == "AUTOGL") render3d = COMMANDLINE_RENDER3D_AUTOGL;
if(_render3d == "GL") render3d = COMMANDLINE_RENDER3D_GL;
if (autodetect_method != -1) if (autodetect_method != -1)
CommonSettings.autodetectBackupMethod = autodetect_method; CommonSettings.autodetectBackupMethod = autodetect_method;

View File

@ -24,17 +24,29 @@
//hacky commandline options that i didnt want to route through commonoptions //hacky commandline options that i didnt want to route through commonoptions
extern int _commandline_linux_nojoy; extern int _commandline_linux_nojoy;
#define COMMANDLINE_RENDER3D_DEFAULT 0
#define COMMANDLINE_RENDER3D_NONE 1
#define COMMANDLINE_RENDER3D_SW 2
#define COMMANDLINE_RENDER3D_OLDGL 3
#define COMMANDLINE_RENDER3D_GL 4
#define COMMANDLINE_RENDER3D_AUTOGL 5
//this class will also eventually try to take over the responsibility of using the args that it handles //this class will also eventually try to take over the responsibility of using the args that it handles
//for example: preparing the emulator run by loading the rom, savestate, and/or movie in the correct pattern. //for example: preparing the emulator run by loading the rom, savestate, and/or movie in the correct pattern.
//it should also populate CommonSettings with its initial values //it should also populate CommonSettings with its initial values
//EDIT: not really. combining this with what a frontend wants to do is complicated.
//you might design the API so that the frontend sets all those up, but I'm not sure I like that
//Really, this should be a passive structure that just collects the results provided by the shared command line processing, to be used later as appropriate
//(and the CommonSettings setup REMOVED or at least refactored into a separate method)
class CommandLine class CommandLine
{ {
public: public:
//actual options: these may move to another sturct //actual options: these may move to another struct
int load_slot; int load_slot;
int depth_threshold; int depth_threshold;
int autodetect_method; int autodetect_method;
int render3d;
std::string nds_file; std::string nds_file;
std::string play_movie_file; std::string play_movie_file;
std::string record_movie_file; std::string record_movie_file;

View File

@ -3283,6 +3283,13 @@ int _main()
cur3DCore = GPU3D_NULL; cur3DCore = GPU3D_NULL;
else if(cur3DCore == GPU3D_NULL) // this value shouldn't be saved anymore else if(cur3DCore == GPU3D_NULL) // this value shouldn't be saved anymore
cur3DCore = GPU3D_DEFAULT; cur3DCore = GPU3D_DEFAULT;
if(cmdline.render3d == COMMANDLINE_RENDER3D_NONE) cur3DCore = GPU3D_NULL;
if(cmdline.render3d == COMMANDLINE_RENDER3D_SW) cur3DCore = GPU3D_SWRAST;
if(cmdline.render3d == COMMANDLINE_RENDER3D_OLDGL) cur3DCore = GPU3D_OPENGL_OLD;
if(cmdline.render3d == COMMANDLINE_RENDER3D_GL) cur3DCore = GPU3D_OPENGL_3_2; //no way of forcing it, at least not right now. I dont care.
if(cmdline.render3d == COMMANDLINE_RENDER3D_AUTOGL) cur3DCore = GPU3D_OPENGL_3_2; //this will fallback i guess
CommonSettings.GFX3D_HighResolutionInterpolateColor = GetPrivateProfileBool("3D", "HighResolutionInterpolateColor", 1, IniName); CommonSettings.GFX3D_HighResolutionInterpolateColor = GetPrivateProfileBool("3D", "HighResolutionInterpolateColor", 1, IniName);
CommonSettings.GFX3D_EdgeMark = GetPrivateProfileBool("3D", "EnableEdgeMark", 1, IniName); CommonSettings.GFX3D_EdgeMark = GetPrivateProfileBool("3D", "EnableEdgeMark", 1, IniName);
CommonSettings.GFX3D_Fog = GetPrivateProfileBool("3D", "EnableFog", 1, IniName); CommonSettings.GFX3D_Fog = GetPrivateProfileBool("3D", "EnableFog", 1, IniName);