diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index a84b48ddb8..cb9f4584b7 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -485,6 +485,10 @@ EXPORT_C_(int) GSopen2(void** dsp, uint32 flags) if (renderer == GSRendererType::Undefined) { renderer = static_cast(theApp.GetConfigI("Renderer")); +#ifdef _WIN32 + if (renderer == GSRendererType::Default) + renderer = GSUtil::GetBestRenderer(); +#endif } else if (stored_toggle_state != toggle_state) { diff --git a/plugins/GSdx/GS.h b/plugins/GSdx/GS.h index 7d1e4ea83b..3ae8e73136 100644 --- a/plugins/GSdx/GS.h +++ b/plugins/GSdx/GS.h @@ -231,7 +231,7 @@ enum class GSRendererType : int8_t OGL_OpenCL = 17, #ifdef _WIN32 - Default = DX1011_HW + Default = Undefined #else // Use ogl renderer as default otherwise it crash at startup // GSRenderOGL only GSDeviceOGL (not GSDeviceNULL) diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index dcf7792f5a..ccd8d65c50 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -316,8 +316,8 @@ void GSSettingsDlg::UpdateRenderers() } else { - //GSRendererType best_renderer = (level >= D3D_FEATURE_LEVEL_10_0) ? GSRendererType::DX1011_HW : GSRendererType::DX9_HW; - renderer_setting = static_cast(theApp.GetConfigI("Renderer")); + GSRendererType ini_renderer = GSRendererType(theApp.GetConfigI("Renderer")); + renderer_setting = (ini_renderer == GSRendererType::Undefined) ? GSUtil::GetBestRenderer() : ini_renderer; } GSRendererType renderer_sel = GSRendererType::Default; diff --git a/plugins/GSdx/GSUtil.cpp b/plugins/GSdx/GSUtil.cpp index 2afded494d..318f5d3de9 100644 --- a/plugins/GSdx/GSUtil.cpp +++ b/plugins/GSdx/GSUtil.cpp @@ -396,6 +396,29 @@ D3D_FEATURE_LEVEL GSUtil::CheckDirect3D11Level(IDXGIAdapter *adapter, D3D_DRIVER return SUCCEEDED(hr) ? level : (D3D_FEATURE_LEVEL)0; } +GSRendererType GSUtil::GetBestRenderer() +{ + CComPtr dxgi_factory; + if (SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&dxgi_factory)))) + { + CComPtr adapter; + if (SUCCEEDED(dxgi_factory->EnumAdapters1(0, &adapter))) + { + DXGI_ADAPTER_DESC1 desc; + if (SUCCEEDED(adapter->GetDesc1(&desc))) + { + D3D_FEATURE_LEVEL level = GSUtil::CheckDirect3D11Level(); + // Check for Nvidia VendorID. Latest OpenGL features need at least DX11 level GPU + if (desc.VendorId == 0x10DE && level >= D3D_FEATURE_LEVEL_11_0) + return GSRendererType::OGL_HW; + if (level >= D3D_FEATURE_LEVEL_10_0) + return GSRendererType::DX1011_HW; + } + } + } + return GSRendererType::DX9_HW; +} + #else void GSmkdir(const char* dir) diff --git a/plugins/GSdx/GSUtil.h b/plugins/GSdx/GSUtil.h index 6342509448..88d9383afc 100644 --- a/plugins/GSdx/GSUtil.h +++ b/plugins/GSdx/GSUtil.h @@ -60,6 +60,7 @@ public: static bool CheckDirectX(); static bool CheckDXGI(); static bool CheckD3D11(); + static GSRendererType GetBestRenderer(); static D3D_FEATURE_LEVEL CheckDirect3D11Level(IDXGIAdapter *adapter = NULL, D3D_DRIVER_TYPE type = D3D_DRIVER_TYPE_HARDWARE); #endif diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp index 8311724c3f..b96df56dbf 100644 --- a/plugins/GSdx/GSdx.cpp +++ b/plugins/GSdx/GSdx.cpp @@ -295,7 +295,7 @@ GSdxApp::GSdxApp() m_default_configuration["paltex"] = "0"; m_default_configuration["png_compression_level"] = to_string(Z_BEST_SPEED); m_default_configuration["preload_frame_with_gs_data"] = "0"; - m_default_configuration["Renderer"] = to_string(static_cast(GSRendererType::Default)); // FIXME + m_default_configuration["Renderer"] = to_string(static_cast(GSRendererType::Default)); m_default_configuration["resx"] = "1024"; m_default_configuration["resy"] = "1024"; m_default_configuration["save"] = "0";