GSdx: Use correct renderer after config change

Rework the renderer selection logic to reload the saved renderer after
it's been changed in the config panel and to properly detect whether a
renderer toggle has been requested.
This commit is contained in:
Jonathan Li 2015-06-21 15:03:17 +01:00
parent bfa46b7f54
commit acc6ad59ba
1 changed files with 21 additions and 11 deletions

View File

@ -445,17 +445,24 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
EXPORT_C_(int) GSopen2(void** dsp, uint32 flags) EXPORT_C_(int) GSopen2(void** dsp, uint32 flags)
{ {
#ifdef __linux__ static bool stored_toggle_state = false;
// Use ogl renderer as default otherwise it crash at startup bool toggle_state = !!(flags & 4);
// GSRenderOGL only GSDeviceOGL (not GSDeviceNULL)
int renderer = theApp.GetConfig("Renderer", 12);
#else
int renderer = theApp.GetConfig("Renderer", 0);
#endif
if(flags & 4) int renderer = s_renderer;
// Fresh start up or config file changed
if (renderer == -1)
{ {
#ifdef _WINDOWS #ifdef __linux__
// Use ogl renderer as default otherwise it crash at startup
// GSRenderOGL only GSDeviceOGL (not GSDeviceNULL)
renderer = theApp.GetConfig("Renderer", 12);
#else
renderer = theApp.GetConfig("Renderer", 0);
#endif
}
else if (stored_toggle_state != toggle_state)
{
#ifdef _WIN32
int best_sw_renderer = GSUtil::CheckDirect3D11Level() >= D3D_FEATURE_LEVEL_10_0 ? 4 : 1; // dx11 / dx9 sw int best_sw_renderer = GSUtil::CheckDirect3D11Level() >= D3D_FEATURE_LEVEL_10_0 ? 4 : 1; // dx11 / dx9 sw
switch(renderer){ switch(renderer){
@ -477,6 +484,7 @@ EXPORT_C_(int) GSopen2(void** dsp, uint32 flags)
} }
#endif #endif
} }
stored_toggle_state = toggle_state;
int retval = _GSopen(dsp, NULL, renderer); int retval = _GSopen(dsp, NULL, renderer);
@ -761,17 +769,19 @@ EXPORT_C GSconfigure()
GSshutdown(); GSshutdown();
} }
// Force a reload of the gs state
s_renderer = -1;
} }
#else #else
if (RunLinuxDialog()) { if (RunLinuxDialog()) {
theApp.ReloadConfig(); theApp.ReloadConfig();
// Force a reload of the gs state
s_renderer = -1;
} }
#endif #endif
// Force a reload of the gs state
s_renderer = -1;
} catch (GSDXRecoverableError) } catch (GSDXRecoverableError)
{ {