HostDisplay: Add virtual method for getting resolutions
This commit is contained in:
parent
e7fc904cf4
commit
5a66639d78
|
@ -3,6 +3,7 @@
|
||||||
#include "common/window_info.h"
|
#include "common/window_info.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -52,6 +53,12 @@ public:
|
||||||
RightOrBottom
|
RightOrBottom
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct AdapterAndModeList
|
||||||
|
{
|
||||||
|
std::vector<std::string> adapter_names;
|
||||||
|
std::vector<std::string> fullscreen_modes;
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~HostDisplay();
|
virtual ~HostDisplay();
|
||||||
|
|
||||||
ALWAYS_INLINE s32 GetWindowWidth() const { return static_cast<s32>(m_window_info.surface_width); }
|
ALWAYS_INLINE s32 GetWindowWidth() const { return static_cast<s32>(m_window_info.surface_width); }
|
||||||
|
@ -85,6 +92,7 @@ public:
|
||||||
virtual bool SupportsFullscreen() const = 0;
|
virtual bool SupportsFullscreen() const = 0;
|
||||||
virtual bool IsFullscreen() = 0;
|
virtual bool IsFullscreen() = 0;
|
||||||
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) = 0;
|
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) = 0;
|
||||||
|
virtual AdapterAndModeList GetAdapterAndModeList() = 0;
|
||||||
virtual bool CreateResources() = 0;
|
virtual bool CreateResources() = 0;
|
||||||
virtual void DestroyResources() = 0;
|
virtual void DestroyResources() = 0;
|
||||||
|
|
||||||
|
|
|
@ -171,24 +171,19 @@ void DisplaySettingsWidget::setupAdditionalUi()
|
||||||
|
|
||||||
void DisplaySettingsWidget::populateGPUAdaptersAndResolutions()
|
void DisplaySettingsWidget::populateGPUAdaptersAndResolutions()
|
||||||
{
|
{
|
||||||
std::vector<std::string> adapter_names;
|
HostDisplay::AdapterAndModeList aml;
|
||||||
std::vector<std::string> fullscreen_modes;
|
|
||||||
bool thread_supported = false;
|
bool thread_supported = false;
|
||||||
bool threaded_presentation_supported = false;
|
bool threaded_presentation_supported = false;
|
||||||
switch (static_cast<GPURenderer>(m_ui.renderer->currentIndex()))
|
switch (static_cast<GPURenderer>(m_ui.renderer->currentIndex()))
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
case GPURenderer::HardwareD3D11:
|
case GPURenderer::HardwareD3D11:
|
||||||
{
|
aml = FrontendCommon::D3D11HostDisplay::StaticGetAdapterAndModeList();
|
||||||
FrontendCommon::D3D11HostDisplay::AdapterInfo adapter_info = FrontendCommon::D3D11HostDisplay::GetAdapterInfo();
|
|
||||||
adapter_names = std::move(adapter_info.adapter_names);
|
|
||||||
fullscreen_modes = std::move(adapter_info.fullscreen_modes);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case GPURenderer::HardwareVulkan:
|
case GPURenderer::HardwareVulkan:
|
||||||
adapter_names = FrontendCommon::VulkanHostDisplay::EnumerateAdapterNames();
|
aml = FrontendCommon::VulkanHostDisplay::StaticGetAdapterAndModeList();
|
||||||
threaded_presentation_supported = true;
|
threaded_presentation_supported = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -209,7 +204,7 @@ void DisplaySettingsWidget::populateGPUAdaptersAndResolutions()
|
||||||
m_ui.adapter->addItem(tr("(Default)"));
|
m_ui.adapter->addItem(tr("(Default)"));
|
||||||
|
|
||||||
// add the other adapters
|
// add the other adapters
|
||||||
for (const std::string& adapter_name : adapter_names)
|
for (const std::string& adapter_name : aml.adapter_names)
|
||||||
{
|
{
|
||||||
m_ui.adapter->addItem(QString::fromStdString(adapter_name));
|
m_ui.adapter->addItem(QString::fromStdString(adapter_name));
|
||||||
|
|
||||||
|
@ -218,7 +213,7 @@ void DisplaySettingsWidget::populateGPUAdaptersAndResolutions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable it if we don't have a choice
|
// disable it if we don't have a choice
|
||||||
m_ui.adapter->setEnabled(!adapter_names.empty());
|
m_ui.adapter->setEnabled(!aml.adapter_names.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -229,7 +224,7 @@ void DisplaySettingsWidget::populateGPUAdaptersAndResolutions()
|
||||||
m_ui.fullscreenMode->addItem(tr("Borderless Fullscreen"));
|
m_ui.fullscreenMode->addItem(tr("Borderless Fullscreen"));
|
||||||
m_ui.fullscreenMode->setCurrentIndex(0);
|
m_ui.fullscreenMode->setCurrentIndex(0);
|
||||||
|
|
||||||
for (const std::string& mode_name : fullscreen_modes)
|
for (const std::string& mode_name : aml.fullscreen_modes)
|
||||||
{
|
{
|
||||||
m_ui.fullscreenMode->addItem(QString::fromStdString(mode_name));
|
m_ui.fullscreenMode->addItem(QString::fromStdString(mode_name));
|
||||||
|
|
||||||
|
@ -238,7 +233,7 @@ void DisplaySettingsWidget::populateGPUAdaptersAndResolutions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable it if we don't have a choice
|
// disable it if we don't have a choice
|
||||||
m_ui.fullscreenMode->setEnabled(!fullscreen_modes.empty());
|
m_ui.fullscreenMode->setEnabled(!aml.fullscreen_modes.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui.gpuThread->setEnabled(thread_supported);
|
m_ui.gpuThread->setEnabled(thread_supported);
|
||||||
|
|
|
@ -256,7 +256,7 @@ bool D3D11HostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_view
|
||||||
u32 adapter_index;
|
u32 adapter_index;
|
||||||
if (!adapter_name.empty())
|
if (!adapter_name.empty())
|
||||||
{
|
{
|
||||||
AdapterInfo adapter_info = GetAdapterInfo(temp_dxgi_factory.Get());
|
AdapterAndModeList adapter_info(GetAdapterAndModeList(temp_dxgi_factory.Get()));
|
||||||
for (adapter_index = 0; adapter_index < static_cast<u32>(adapter_info.adapter_names.size()); adapter_index++)
|
for (adapter_index = 0; adapter_index < static_cast<u32>(adapter_info.adapter_names.size()); adapter_index++)
|
||||||
{
|
{
|
||||||
if (adapter_name == adapter_info.adapter_names[adapter_index])
|
if (adapter_name == adapter_info.adapter_names[adapter_index])
|
||||||
|
@ -795,19 +795,19 @@ void D3D11HostDisplay::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 he
|
||||||
m_context->Draw(3, 0);
|
m_context->Draw(3, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D11HostDisplay::AdapterInfo D3D11HostDisplay::GetAdapterInfo()
|
HostDisplay::AdapterAndModeList D3D11HostDisplay::StaticGetAdapterAndModeList()
|
||||||
{
|
{
|
||||||
ComPtr<IDXGIFactory> dxgi_factory;
|
ComPtr<IDXGIFactory> dxgi_factory;
|
||||||
HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf()));
|
HRESULT hr = CreateDXGIFactory(IID_PPV_ARGS(dxgi_factory.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return GetAdapterInfo(dxgi_factory.Get());
|
return GetAdapterAndModeList(dxgi_factory.Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D11HostDisplay::AdapterInfo D3D11HostDisplay::GetAdapterInfo(IDXGIFactory* dxgi_factory)
|
HostDisplay::AdapterAndModeList D3D11HostDisplay::GetAdapterAndModeList(IDXGIFactory* dxgi_factory)
|
||||||
{
|
{
|
||||||
AdapterInfo adapter_info;
|
AdapterAndModeList adapter_info;
|
||||||
ComPtr<IDXGIAdapter> current_adapter;
|
ComPtr<IDXGIAdapter> current_adapter;
|
||||||
while (SUCCEEDED(dxgi_factory->EnumAdapters(static_cast<UINT>(adapter_info.adapter_names.size()),
|
while (SUCCEEDED(dxgi_factory->EnumAdapters(static_cast<UINT>(adapter_info.adapter_names.size()),
|
||||||
current_adapter.ReleaseAndGetAddressOf())))
|
current_adapter.ReleaseAndGetAddressOf())))
|
||||||
|
@ -873,6 +873,11 @@ D3D11HostDisplay::AdapterInfo D3D11HostDisplay::GetAdapterInfo(IDXGIFactory* dxg
|
||||||
return adapter_info;
|
return adapter_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HostDisplay::AdapterAndModeList D3D11HostDisplay::GetAdapterAndModeList()
|
||||||
|
{
|
||||||
|
return GetAdapterAndModeList(m_dxgi_factory.Get());
|
||||||
|
}
|
||||||
|
|
||||||
bool D3D11HostDisplay::SetPostProcessingChain(const std::string_view& config)
|
bool D3D11HostDisplay::SetPostProcessingChain(const std::string_view& config)
|
||||||
{
|
{
|
||||||
if (config.empty())
|
if (config.empty())
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
virtual bool SupportsFullscreen() const override;
|
virtual bool SupportsFullscreen() const override;
|
||||||
virtual bool IsFullscreen() override;
|
virtual bool IsFullscreen() override;
|
||||||
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
|
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
|
||||||
|
virtual AdapterAndModeList GetAdapterAndModeList() override;
|
||||||
virtual void DestroyRenderSurface() override;
|
virtual void DestroyRenderSurface() override;
|
||||||
|
|
||||||
virtual bool SetPostProcessingChain(const std::string_view& config) override;
|
virtual bool SetPostProcessingChain(const std::string_view& config) override;
|
||||||
|
@ -68,17 +69,12 @@ public:
|
||||||
|
|
||||||
virtual bool Render() override;
|
virtual bool Render() override;
|
||||||
|
|
||||||
struct AdapterInfo
|
static AdapterAndModeList StaticGetAdapterAndModeList();
|
||||||
{
|
|
||||||
std::vector<std::string> adapter_names;
|
|
||||||
std::vector<std::string> fullscreen_modes;
|
|
||||||
};
|
|
||||||
static AdapterInfo GetAdapterInfo();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static constexpr u32 DISPLAY_UNIFORM_BUFFER_SIZE = 16;
|
static constexpr u32 DISPLAY_UNIFORM_BUFFER_SIZE = 16;
|
||||||
|
|
||||||
static AdapterInfo GetAdapterInfo(IDXGIFactory* dxgi_factory);
|
static AdapterAndModeList GetAdapterAndModeList(IDXGIFactory* dxgi_factory);
|
||||||
|
|
||||||
virtual bool CreateResources() override;
|
virtual bool CreateResources() override;
|
||||||
virtual void DestroyResources() override;
|
virtual void DestroyResources() override;
|
||||||
|
|
|
@ -510,6 +510,11 @@ bool OpenGLHostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, fl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HostDisplay::AdapterAndModeList OpenGLHostDisplay::GetAdapterAndModeList()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLHostDisplay::DestroyRenderSurface()
|
void OpenGLHostDisplay::DestroyRenderSurface()
|
||||||
{
|
{
|
||||||
if (!m_gl_context)
|
if (!m_gl_context)
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
virtual bool SupportsFullscreen() const override;
|
virtual bool SupportsFullscreen() const override;
|
||||||
virtual bool IsFullscreen() override;
|
virtual bool IsFullscreen() override;
|
||||||
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
|
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
|
||||||
|
virtual AdapterAndModeList GetAdapterAndModeList() override;
|
||||||
virtual void DestroyRenderSurface() override;
|
virtual void DestroyRenderSurface() override;
|
||||||
|
|
||||||
virtual bool SetPostProcessingChain(const std::string_view& config) override;
|
virtual bool SetPostProcessingChain(const std::string_view& config) override;
|
||||||
|
|
|
@ -139,6 +139,11 @@ bool VulkanHostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, fl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HostDisplay::AdapterAndModeList VulkanHostDisplay::GetAdapterAndModeList()
|
||||||
|
{
|
||||||
|
return StaticGetAdapterAndModeList();
|
||||||
|
}
|
||||||
|
|
||||||
void VulkanHostDisplay::DestroyRenderSurface()
|
void VulkanHostDisplay::DestroyRenderSurface()
|
||||||
{
|
{
|
||||||
m_window_info = {};
|
m_window_info = {};
|
||||||
|
@ -747,12 +752,15 @@ void VulkanHostDisplay::RenderSoftwareCursor(s32 left, s32 top, s32 width, s32 h
|
||||||
vkCmdDraw(cmdbuffer, 3, 1, 0, 0);
|
vkCmdDraw(cmdbuffer, 3, 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> VulkanHostDisplay::EnumerateAdapterNames()
|
HostDisplay::AdapterAndModeList VulkanHostDisplay::StaticGetAdapterAndModeList()
|
||||||
{
|
{
|
||||||
if (g_vulkan_context)
|
AdapterAndModeList ret;
|
||||||
return Vulkan::Context::EnumerateGPUNames(g_vulkan_context->GetVulkanInstance());
|
|
||||||
|
|
||||||
if (Vulkan::LoadVulkanLibrary())
|
if (g_vulkan_context)
|
||||||
|
{
|
||||||
|
ret.adapter_names = Vulkan::Context::EnumerateGPUNames(g_vulkan_context->GetVulkanInstance());
|
||||||
|
}
|
||||||
|
else if (Vulkan::LoadVulkanLibrary())
|
||||||
{
|
{
|
||||||
Common::ScopeGuard lib_guard([]() { Vulkan::UnloadVulkanLibrary(); });
|
Common::ScopeGuard lib_guard([]() { Vulkan::UnloadVulkanLibrary(); });
|
||||||
|
|
||||||
|
@ -762,7 +770,7 @@ std::vector<std::string> VulkanHostDisplay::EnumerateAdapterNames()
|
||||||
Common::ScopeGuard instance_guard([&instance]() { vkDestroyInstance(instance, nullptr); });
|
Common::ScopeGuard instance_guard([&instance]() { vkDestroyInstance(instance, nullptr); });
|
||||||
|
|
||||||
if (Vulkan::LoadVulkanInstanceFunctions(instance))
|
if (Vulkan::LoadVulkanInstanceFunctions(instance))
|
||||||
return Vulkan::Context::EnumerateGPUNames(instance);
|
ret.adapter_names = Vulkan::Context::EnumerateGPUNames(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
virtual bool SupportsFullscreen() const override;
|
virtual bool SupportsFullscreen() const override;
|
||||||
virtual bool IsFullscreen() override;
|
virtual bool IsFullscreen() override;
|
||||||
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
|
virtual bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
|
||||||
|
virtual AdapterAndModeList GetAdapterAndModeList() override;
|
||||||
virtual void DestroyRenderSurface() override;
|
virtual void DestroyRenderSurface() override;
|
||||||
|
|
||||||
virtual bool SetPostProcessingChain(const std::string_view& config) override;
|
virtual bool SetPostProcessingChain(const std::string_view& config) override;
|
||||||
|
@ -64,7 +65,7 @@ public:
|
||||||
|
|
||||||
virtual bool Render() override;
|
virtual bool Render() override;
|
||||||
|
|
||||||
static std::vector<std::string> EnumerateAdapterNames();
|
static AdapterAndModeList StaticGetAdapterAndModeList();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct PushConstants
|
struct PushConstants
|
||||||
|
|
Loading…
Reference in New Issue