mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-05 06:21:19 +12:00
rework gpu selection
This commit is contained in:
parent
ba9a9370fe
commit
d64e0c9b6f
7 changed files with 105 additions and 41 deletions
|
@ -1,3 +1,5 @@
|
|||
#include "Foundation/NSString.hpp"
|
||||
#include "Metal/MTLDevice.hpp"
|
||||
#include "gui/wxgui.h"
|
||||
#include "gui/GeneralSettings2.h"
|
||||
#include "gui/CemuApp.h"
|
||||
|
@ -27,6 +29,9 @@
|
|||
|
||||
#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h"
|
||||
#if ENABLE_METAL
|
||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h"
|
||||
#endif
|
||||
#include "Cafe/Account/Account.h"
|
||||
|
||||
#include <boost/tokenizer.hpp>
|
||||
|
@ -82,15 +87,15 @@ private:
|
|||
IAudioInputAPI::DeviceDescriptionPtr m_description;
|
||||
};
|
||||
|
||||
class wxVulkanUUID : public wxClientData
|
||||
class wxGraphicsDevice : public wxClientData
|
||||
{
|
||||
public:
|
||||
wxVulkanUUID(const VulkanRenderer::DeviceInfo& info)
|
||||
: m_device_info(info) {}
|
||||
const VulkanRenderer::DeviceInfo& GetDeviceInfo() const { return m_device_info; }
|
||||
wxGraphicsDevice(const std::string& name)
|
||||
: m_name(name) {}
|
||||
const std::string& GetName() const { return m_name; }
|
||||
|
||||
private:
|
||||
VulkanRenderer::DeviceInfo m_device_info;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
class wxAccountData : public wxClientData
|
||||
|
@ -1025,14 +1030,14 @@ void GeneralSettings2::StoreConfig()
|
|||
selection = m_graphic_device->GetSelection();
|
||||
if(selection != wxNOT_FOUND)
|
||||
{
|
||||
const auto* info = (wxVulkanUUID*)m_graphic_device->GetClientObject(selection);
|
||||
const auto* info = (wxGraphicsDevice*)m_graphic_device->GetClientObject(selection);
|
||||
if(info)
|
||||
config.graphic_device_uuid = info->GetDeviceInfo().uuid;
|
||||
config.graphic_device_name = info->GetName();
|
||||
else
|
||||
config.graphic_device_uuid = {};
|
||||
config.graphic_device_name = "";
|
||||
}
|
||||
else
|
||||
config.graphic_device_uuid = {};
|
||||
config.graphic_device_name = "";
|
||||
|
||||
|
||||
config.vsync = m_vsync->GetSelection();
|
||||
|
@ -1538,14 +1543,14 @@ void GeneralSettings2::HandleGraphicsApiSelection()
|
|||
{
|
||||
for(const auto& device : devices)
|
||||
{
|
||||
m_graphic_device->Append(device.name, new wxVulkanUUID(device));
|
||||
m_graphic_device->Append(device, new wxGraphicsDevice(device));
|
||||
}
|
||||
m_graphic_device->SetSelection(0);
|
||||
|
||||
const auto& config = GetConfig();
|
||||
for(size_t i = 0; i < devices.size(); ++i)
|
||||
{
|
||||
if(config.graphic_device_uuid == devices[i].uuid)
|
||||
if(config.graphic_device_name == devices[i])
|
||||
{
|
||||
m_graphic_device->SetSelection(i);
|
||||
break;
|
||||
|
@ -1566,9 +1571,30 @@ void GeneralSettings2::HandleGraphicsApiSelection()
|
|||
|
||||
m_vsync->Select(selection);
|
||||
|
||||
// TODO: add an option to select the graphic device
|
||||
m_graphic_device->Clear();
|
||||
m_graphic_device->Disable();
|
||||
m_graphic_device->Enable();
|
||||
m_graphic_device->Clear();
|
||||
|
||||
#if ENABLE_METAL
|
||||
auto devices = MetalRenderer::GetDevices();
|
||||
if (!devices.empty())
|
||||
{
|
||||
for (const auto& device : devices)
|
||||
{
|
||||
m_graphic_device->Append(device, new wxGraphicsDevice(device));
|
||||
}
|
||||
m_graphic_device->SetSelection(0);
|
||||
|
||||
const auto& config = GetConfig();
|
||||
for (size_t i = 0; i < devices.size(); ++i)
|
||||
{
|
||||
if (config.graphic_device_name == devices[i])
|
||||
{
|
||||
m_graphic_device->SetSelection(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue