diff --git a/src/common/gl/context.cpp b/src/common/gl/context.cpp index 220469d56..97c85059f 100644 --- a/src/common/gl/context.cpp +++ b/src/common/gl/context.cpp @@ -67,6 +67,11 @@ Context::Context(const WindowInfo& wi) : m_wi(wi) {} Context::~Context() = default; +std::vector Context::EnumerateFullscreenModes() +{ + return {}; +} + std::unique_ptr Context::Create(const WindowInfo& wi, const Version* versions_to_try, size_t num_versions_to_try) { diff --git a/src/common/gl/context.h b/src/common/gl/context.h index 695ca5df6..70cf8cf0f 100644 --- a/src/common/gl/context.h +++ b/src/common/gl/context.h @@ -3,6 +3,7 @@ #include "../window_info.h" #include #include +#include namespace GL { class Context @@ -25,6 +26,13 @@ public: int minor_version; }; + struct FullscreenModeInfo + { + u32 width; + u32 height; + float refresh_rate; + }; + ALWAYS_INLINE const WindowInfo& GetWindowInfo() const { return m_wi; } ALWAYS_INLINE bool IsGLES() const { return (m_version.profile == Profile::ES); } ALWAYS_INLINE u32 GetSurfaceWidth() const { return m_wi.surface_width; } @@ -40,6 +48,8 @@ public: virtual bool SetSwapInterval(s32 interval) = 0; virtual std::unique_ptr CreateSharedContext(const WindowInfo& wi) = 0; + virtual std::vector EnumerateFullscreenModes(); + static std::unique_ptr Create(const WindowInfo& wi, const Version* versions_to_try, size_t num_versions_to_try); diff --git a/src/common/gl/context_egl_gbm.cpp b/src/common/gl/context_egl_gbm.cpp index 3cc7d041c..fad615f61 100644 --- a/src/common/gl/context_egl_gbm.cpp +++ b/src/common/gl/context_egl_gbm.cpp @@ -206,6 +206,18 @@ bool ContextEGLGBM::SetSwapInterval(s32 interval) return true; } +std::vector ContextEGLGBM::EnumerateFullscreenModes() +{ + std::vector modes; + modes.reserve(m_drm_display.GetModeCount()); + for (u32 i = 0; i < m_drm_display.GetModeCount(); i++) + { + modes.push_back(FullscreenModeInfo{m_drm_display.GetModeWidth(i), m_drm_display.GetModeHeight(i), + m_drm_display.GetModeRefreshRate(i)}); + } + return modes; +} + #ifdef CONTEXT_EGL_GBM_USE_PRESENT_THREAD void ContextEGLGBM::StartPresentThread() diff --git a/src/common/gl/context_egl_gbm.h b/src/common/gl/context_egl_gbm.h index 68488d8bb..b6affe5f1 100644 --- a/src/common/gl/context_egl_gbm.h +++ b/src/common/gl/context_egl_gbm.h @@ -26,6 +26,8 @@ public: bool SwapBuffers() override; bool SetSwapInterval(s32 interval) override; + std::vector EnumerateFullscreenModes() override; + protected: bool SetDisplay() override; EGLNativeWindowType GetNativeWindow(EGLConfig config) override; diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 3394f1ecb..54b3b252f 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -2870,6 +2870,11 @@ bool CommonHostInterface::ParseFullscreenMode(const std::string_view& mode, u32* return false; } +std::string CommonHostInterface::GetFullscreenModeString(u32 width, u32 height, float refresh_rate) +{ + return StringUtil::StdStringFromFormat("%u x %u @ %f hz", width, height, refresh_rate); +} + bool CommonHostInterface::RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) { return false; diff --git a/src/frontend-common/common_host_interface.h b/src/frontend-common/common_host_interface.h index 6748aa567..e60293c61 100644 --- a/src/frontend-common/common_host_interface.h +++ b/src/frontend-common/common_host_interface.h @@ -241,6 +241,9 @@ public: /// Parses a fullscreen mode into its components (width * height @ refresh hz) static bool ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height, float* refresh_rate); + /// Converts a fullscreen mode to a string. + static std::string GetFullscreenModeString(u32 width, u32 height, float refresh_rate); + /// Returns true if fast forwarding or slow motion is currently active. bool IsRunningAtNonStandardSpeed() const; diff --git a/src/frontend-common/d3d11_host_display.cpp b/src/frontend-common/d3d11_host_display.cpp index f15a8796a..ee057faf3 100644 --- a/src/frontend-common/d3d11_host_display.cpp +++ b/src/frontend-common/d3d11_host_display.cpp @@ -4,14 +4,15 @@ #include "common/d3d11/shader_compiler.h" #include "common/log.h" #include "common/string_util.h" +#include "common_host_interface.h" #include "core/host_interface.h" #include "core/settings.h" #include "core/shader_cache_version.h" #include "display_ps.hlsl.h" #include "display_vs.hlsl.h" -#include "frontend-common/postprocessing_shadergen.h" #include "imgui.h" #include "imgui_impl_dx11.h" +#include "postprocessing_shadergen.h" #include #include Log_SetChannel(D3D11HostDisplay); @@ -843,8 +844,8 @@ HostDisplay::AdapterAndModeList D3D11HostDisplay::GetAdapterAndModeList(IDXGIFac { for (const DXGI_MODE_DESC& mode : modes) { - adapter_info.fullscreen_modes.push_back(StringUtil::StdStringFromFormat( - "%u x %u @ %f hz", mode.Width, mode.Height, + adapter_info.fullscreen_modes.push_back(CommonHostInterface::GetFullscreenModeString( + mode.Width, mode.Height, static_cast(mode.RefreshRate.Numerator) / static_cast(mode.RefreshRate.Denominator))); } } diff --git a/src/frontend-common/opengl_host_display.cpp b/src/frontend-common/opengl_host_display.cpp index e74bd2763..7d1fe9b81 100644 --- a/src/frontend-common/opengl_host_display.cpp +++ b/src/frontend-common/opengl_host_display.cpp @@ -3,6 +3,7 @@ #include "common/assert.h" #include "common/log.h" #include "common/string_util.h" +#include "common_host_interface.h" #include "imgui.h" #include "imgui_impl_opengl3.h" #include "postprocessing_shadergen.h" @@ -512,7 +513,18 @@ bool OpenGLHostDisplay::SetFullscreen(bool fullscreen, u32 width, u32 height, fl HostDisplay::AdapterAndModeList OpenGLHostDisplay::GetAdapterAndModeList() { - return {}; + AdapterAndModeList aml; + + if (m_gl_context) + { + for (const GL::Context::FullscreenModeInfo& fmi : m_gl_context->EnumerateFullscreenModes()) + { + aml.fullscreen_modes.push_back( + CommonHostInterface::GetFullscreenModeString(fmi.width, fmi.height, fmi.refresh_rate)); + } + } + + return aml; } void OpenGLHostDisplay::DestroyRenderSurface()