mirror of https://github.com/PCSX2/pcsx2.git
GS: Move adapter list stuff to module in GSUtil
Will be helpful for when renderers other than DX that let you choose adapters are added
This commit is contained in:
parent
f471c30036
commit
4e762c75b0
|
@ -146,15 +146,8 @@ int _GSopen(const WindowInfo& wi, const char* title, GSRendererType renderer, in
|
||||||
if (renderer == GSRendererType::Undefined)
|
if (renderer == GSRendererType::Undefined)
|
||||||
{
|
{
|
||||||
renderer = static_cast<GSRendererType>(theApp.GetConfigI("Renderer"));
|
renderer = static_cast<GSRendererType>(theApp.GetConfigI("Renderer"));
|
||||||
#ifdef _WIN32
|
|
||||||
if (renderer == GSRendererType::Default)
|
if (renderer == GSRendererType::Default)
|
||||||
{
|
renderer = GSUtil::GetPreferredRenderer();
|
||||||
if (D3D::ShouldPreferD3D())
|
|
||||||
renderer = GSRendererType::DX1011_HW;
|
|
||||||
else
|
|
||||||
renderer = GSRendererType::OGL_HW;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threads == -1)
|
if (threads == -1)
|
||||||
|
@ -286,23 +279,14 @@ int GSopen2(const WindowInfo& wi, u32 flags)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case GSRendererType::OGL_SW:
|
case GSRendererType::OGL_SW:
|
||||||
#ifdef _WIN32
|
|
||||||
{
|
{
|
||||||
const auto config_renderer = static_cast<GSRendererType>(theApp.GetConfigI("Renderer"));
|
const auto config_renderer = static_cast<GSRendererType>(theApp.GetConfigI("Renderer"));
|
||||||
|
|
||||||
if (current_renderer == config_renderer)
|
if (current_renderer == config_renderer)
|
||||||
{
|
current_renderer = GSUtil::GetPreferredRenderer();
|
||||||
if (D3D::ShouldPreferD3D())
|
|
||||||
current_renderer = GSRendererType::DX1011_HW;
|
|
||||||
else
|
|
||||||
current_renderer = GSRendererType::OGL_HW;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
current_renderer = config_renderer;
|
current_renderer = config_renderer;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
current_renderer = GSRendererType::OGL_HW;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case GSRendererType::OGL_HW:
|
case GSRendererType::OGL_HW:
|
||||||
current_renderer = GSRendererType::OGL_SW;
|
current_renderer = GSRendererType::OGL_SW;
|
||||||
|
|
|
@ -36,13 +36,7 @@ enum class GSRendererType : int8_t
|
||||||
OGL_HW = 12,
|
OGL_HW = 12,
|
||||||
OGL_SW = 13,
|
OGL_SW = 13,
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
Default = Undefined
|
Default = Undefined
|
||||||
#else
|
|
||||||
// Use ogl renderer as default otherwise it crash at startup
|
|
||||||
// GSRenderOGL only GSDeviceOGL (not GSDeviceNULL)
|
|
||||||
Default = OGL_HW
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ST_WRITE is defined in libc, avoid this
|
// ST_WRITE is defined in libc, avoid this
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <VersionHelpers.h>
|
#include <VersionHelpers.h>
|
||||||
#include "svnrev.h"
|
#include "svnrev.h"
|
||||||
|
#include "Renderers/DX11/D3D.h"
|
||||||
#include <wil/com.h>
|
#include <wil/com.h>
|
||||||
#else
|
#else
|
||||||
#define SVN_REV 0
|
#define SVN_REV 0
|
||||||
|
@ -187,6 +188,28 @@ CRCHackLevel GSUtil::GetRecommendedCRCHackLevel(GSRendererType type)
|
||||||
return type == GSRendererType::OGL_HW ? CRCHackLevel::Partial : CRCHackLevel::Full;
|
return type == GSRendererType::OGL_HW ? CRCHackLevel::Partial : CRCHackLevel::Full;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GSRendererType GSUtil::GetPreferredRenderer()
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (D3D::ShouldPreferD3D())
|
||||||
|
return GSRendererType::DX1011_HW;
|
||||||
|
#endif
|
||||||
|
return GSRendererType::OGL_HW;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> GSUtil::GetAdapterList(GSRendererType renderer, size_t& default_adapter)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (renderer == GSRendererType::DX1011_HW)
|
||||||
|
{
|
||||||
|
default_adapter = 0;
|
||||||
|
auto factory = D3D::CreateFactory(false);
|
||||||
|
return D3D::GetAdapterList(factory.get());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void GSmkdir(const wchar_t* dir)
|
void GSmkdir(const wchar_t* dir)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,8 @@ public:
|
||||||
|
|
||||||
static bool CheckSSE();
|
static bool CheckSSE();
|
||||||
static CRCHackLevel GetRecommendedCRCHackLevel(GSRendererType type);
|
static CRCHackLevel GetRecommendedCRCHackLevel(GSRendererType type);
|
||||||
|
static GSRendererType GetPreferredRenderer();
|
||||||
|
static std::vector<std::string> GetAdapterList(GSRendererType renderer, size_t& default_adapter);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -16,11 +16,7 @@
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "GSwxDialog.h"
|
#include "GSwxDialog.h"
|
||||||
#include "gui/AppConfig.h"
|
#include "gui/AppConfig.h"
|
||||||
|
#include "GS/GSUtil.h"
|
||||||
#ifdef _WIN32
|
|
||||||
#include "GS/GSExtra.h"
|
|
||||||
#include "GS/Renderers/DX11/D3D.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace GSSettingsDialog;
|
using namespace GSSettingsDialog;
|
||||||
|
|
||||||
|
@ -616,11 +612,9 @@ Dialog::Dialog()
|
||||||
m_renderer_select = m_ui.addComboBoxAndLabel(top_grid, "Renderer:", "Renderer", &theApp.m_gs_renderers).first;
|
m_renderer_select = m_ui.addComboBoxAndLabel(top_grid, "Renderer:", "Renderer", &theApp.m_gs_renderers).first;
|
||||||
m_renderer_select->Bind(wxEVT_CHOICE, &Dialog::OnRendererChange, this);
|
m_renderer_select->Bind(wxEVT_CHOICE, &Dialog::OnRendererChange, this);
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
add_label(this, top_grid, "Adapter:");
|
add_label(this, top_grid, "Adapter:");
|
||||||
m_adapter_select = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, {});
|
m_adapter_select = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, {});
|
||||||
top_grid->Add(m_adapter_select, wxSizerFlags().Expand());
|
top_grid->Add(m_adapter_select, wxSizerFlags().Expand());
|
||||||
#endif
|
|
||||||
|
|
||||||
m_ui.addComboBoxAndLabel(top_grid, "Interlacing (F5):", "interlace", &theApp.m_gs_interlace);
|
m_ui.addComboBoxAndLabel(top_grid, "Interlacing (F5):", "interlace", &theApp.m_gs_interlace);
|
||||||
|
|
||||||
|
@ -687,33 +681,37 @@ GSRendererType Dialog::GetSelectedRendererType()
|
||||||
|
|
||||||
void Dialog::RendererChange()
|
void Dialog::RendererChange()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
GSRendererType renderer = GetSelectedRendererType();
|
GSRendererType renderer = GetSelectedRendererType();
|
||||||
|
std::string current;
|
||||||
|
int current_sel = m_adapter_select->GetSelection();
|
||||||
|
if (current_sel >= 0 && current_sel < static_cast<int>(m_adapter_arr_string.Count()))
|
||||||
|
current = m_adapter_arr_string[current_sel].ToUTF8();
|
||||||
|
|
||||||
|
size_t default_adapter = 0;
|
||||||
|
std::vector<std::string> adapters = GSUtil::GetAdapterList(renderer, default_adapter);
|
||||||
|
|
||||||
m_adapter_select->Clear();
|
m_adapter_select->Clear();
|
||||||
|
if (adapters.empty())
|
||||||
if (renderer == GSRendererType::DX1011_HW)
|
|
||||||
{
|
|
||||||
auto factory = D3D::CreateFactory(false);
|
|
||||||
auto adapter_list = D3D::GetAdapterList(factory.get());
|
|
||||||
|
|
||||||
wxArrayString adapter_arr_string;
|
|
||||||
for (const auto name : adapter_list)
|
|
||||||
{
|
|
||||||
adapter_arr_string.push_back(
|
|
||||||
convert_utf8_to_utf16(name)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_adapter_select->Insert(adapter_arr_string, 0);
|
|
||||||
m_adapter_select->Enable();
|
|
||||||
m_adapter_select->SetSelection(
|
|
||||||
theApp.GetConfigI("adapter_index")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
m_adapter_select->Disable();
|
m_adapter_select->Disable();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_adapter_arr_string.Clear();
|
||||||
|
int new_sel = theApp.GetConfigI("adapter_index");
|
||||||
|
if (new_sel < 0 || new_sel >= static_cast<int>(adapters.size()))
|
||||||
|
new_sel = default_adapter;
|
||||||
|
for (std::string& adapter : adapters)
|
||||||
|
{
|
||||||
|
if (adapter == current)
|
||||||
|
new_sel = m_adapter_arr_string.Count();
|
||||||
|
m_adapter_arr_string.Add(fromUTF8(adapter));
|
||||||
|
}
|
||||||
|
m_adapter_select->Set(m_adapter_arr_string);
|
||||||
|
m_adapter_select->SetSelection(new_sel);
|
||||||
|
m_adapter_select->Enable();
|
||||||
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
m_renderer_panel->UpdateBlendMode(renderer);
|
m_renderer_panel->UpdateBlendMode(renderer);
|
||||||
|
|
||||||
m_renderer_panel->Layout(); // The version of wx we use on Windows is dumb and something prevents relayout from happening to notebook pages
|
m_renderer_panel->Layout(); // The version of wx we use on Windows is dumb and something prevents relayout from happening to notebook pages
|
||||||
|
@ -723,12 +721,10 @@ void Dialog::RendererChange()
|
||||||
void Dialog::Load()
|
void Dialog::Load()
|
||||||
{
|
{
|
||||||
m_ui.Load();
|
m_ui.Load();
|
||||||
#ifdef _WIN32
|
|
||||||
GSRendererType renderer = GSRendererType(theApp.GetConfigI("Renderer"));
|
GSRendererType renderer = GSRendererType(theApp.GetConfigI("Renderer"));
|
||||||
if (renderer == GSRendererType::Undefined)
|
if (renderer == GSRendererType::Undefined)
|
||||||
renderer = D3D::ShouldPreferD3D() ? GSRendererType::DX1011_HW : GSRendererType::OGL_HW;
|
renderer = GSUtil::GetPreferredRenderer();
|
||||||
m_renderer_select->SetSelection(get_config_index(theApp.m_gs_renderers, static_cast<int>(renderer)));
|
m_renderer_select->SetSelection(get_config_index(theApp.m_gs_renderers, static_cast<int>(renderer)));
|
||||||
#endif
|
|
||||||
|
|
||||||
RendererChange();
|
RendererChange();
|
||||||
|
|
||||||
|
@ -743,17 +739,10 @@ void Dialog::Load()
|
||||||
void Dialog::Save()
|
void Dialog::Save()
|
||||||
{
|
{
|
||||||
m_ui.Save();
|
m_ui.Save();
|
||||||
#ifdef _WIN32
|
|
||||||
// only save the adapter when it makes sense to
|
// only save the adapter when it makes sense to
|
||||||
// prevents changing the adapter, switching to another renderer and saving
|
// prevents changing the adapter, switching to another renderer and saving
|
||||||
if (GetSelectedRendererType() == GSRendererType::DX1011_HW)
|
if (m_adapter_select->GetCount())
|
||||||
{
|
theApp.SetConfig("adapter_index", m_adapter_select->GetSelection());
|
||||||
const int current_adapter =
|
|
||||||
m_adapter_select->GetSelection();
|
|
||||||
|
|
||||||
theApp.SetConfig("adapter_index", current_adapter);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_hacks_panel->Save();
|
m_hacks_panel->Save();
|
||||||
m_renderer_panel->Save();
|
m_renderer_panel->Save();
|
||||||
|
|
|
@ -185,9 +185,7 @@ namespace GSSettingsDialog
|
||||||
|
|
||||||
wxBoxSizer* m_top_box;
|
wxBoxSizer* m_top_box;
|
||||||
wxChoice* m_renderer_select;
|
wxChoice* m_renderer_select;
|
||||||
#ifdef _WIN32
|
|
||||||
wxChoice* m_adapter_select;
|
wxChoice* m_adapter_select;
|
||||||
#endif
|
|
||||||
wxChoice* m_bifilter_select;
|
wxChoice* m_bifilter_select;
|
||||||
wxArrayString m_adapter_arr_string;
|
wxArrayString m_adapter_arr_string;
|
||||||
RendererTab* m_renderer_panel;
|
RendererTab* m_renderer_panel;
|
||||||
|
|
Loading…
Reference in New Issue