OSD: Add option to show display resolution

This commit is contained in:
Connor McLaughlin 2020-08-16 00:17:10 +10:00
parent 26aa627deb
commit 10a46a7fd8
10 changed files with 73 additions and 35 deletions

View File

@ -59,6 +59,11 @@ void GPU::UpdateSettings()
void GPU::UpdateResolutionScale() {} void GPU::UpdateResolutionScale() {}
std::tuple<u32, u32> GPU::GetEffectiveDisplayResolution()
{
return std::tie(m_crtc_state.display_vram_width, m_crtc_state.display_vram_height);
}
void GPU::Reset() void GPU::Reset()
{ {
SoftReset(); SoftReset();

View File

@ -144,6 +144,24 @@ public:
} }
void EndDMAWrite(); void EndDMAWrite();
/// Returns false if the DAC is loading any data from VRAM.
ALWAYS_INLINE bool IsDisplayDisabled() const
{
return m_GPUSTAT.display_disable || m_crtc_state.display_vram_width == 0 || m_crtc_state.display_vram_height == 0;
}
/// Returns true if scanout should be interlaced.
ALWAYS_INLINE bool IsInterlacedDisplayEnabled() const
{
return (!m_force_progressive_scan) & m_GPUSTAT.vertical_interlace;
}
/// Returns true if interlaced rendering is enabled and force progressive scan is disabled.
ALWAYS_INLINE bool IsInterlacedRenderingEnabled() const
{
return (!m_force_progressive_scan) & m_GPUSTAT.SkipDrawingToActiveField();
}
/// Returns the number of pending GPU ticks. /// Returns the number of pending GPU ticks.
TickCount GetPendingCRTCTicks() const; TickCount GetPendingCRTCTicks() const;
TickCount GetPendingCommandTicks() const; TickCount GetPendingCommandTicks() const;
@ -163,6 +181,9 @@ public:
/// Updates the resolution scale when it's set to automatic. /// Updates the resolution scale when it's set to automatic.
virtual void UpdateResolutionScale(); virtual void UpdateResolutionScale();
/// Returns the effective display resolution of the GPU.
virtual std::tuple<u32, u32> GetEffectiveDisplayResolution();
// gpu_hw_d3d11.cpp // gpu_hw_d3d11.cpp
static std::unique_ptr<GPU> CreateHardwareD3D11Renderer(); static std::unique_ptr<GPU> CreateHardwareD3D11Renderer();
@ -367,24 +388,6 @@ protected:
void CRTCTickEvent(TickCount ticks); void CRTCTickEvent(TickCount ticks);
void CommandTickEvent(TickCount ticks); void CommandTickEvent(TickCount ticks);
/// Returns false if the DAC is loading any data from VRAM.
ALWAYS_INLINE bool IsDisplayDisabled() const
{
return m_GPUSTAT.display_disable || m_crtc_state.display_vram_width == 0 || m_crtc_state.display_vram_height == 0;
}
/// Returns true if scanout should be interlaced.
ALWAYS_INLINE bool IsInterlacedDisplayEnabled() const
{
return (!m_force_progressive_scan) & m_GPUSTAT.vertical_interlace;
}
/// Returns true if interlaced rendering is enabled and force progressive scan is disabled.
ALWAYS_INLINE bool IsInterlacedRenderingEnabled() const
{
return (!m_force_progressive_scan) & m_GPUSTAT.SkipDrawingToActiveField();
}
/// Returns 0 if the currently-displayed field is on odd lines (1,3,5,...) or 1 if even (2,4,6,...). /// Returns 0 if the currently-displayed field is on odd lines (1,3,5,...) or 1 if even (2,4,6,...).
ALWAYS_INLINE u32 GetInterlacedDisplayField() const { return ZeroExtend32(m_crtc_state.interlaced_field); } ALWAYS_INLINE u32 GetInterlacedDisplayField() const { return ZeroExtend32(m_crtc_state.interlaced_field); }

View File

@ -134,6 +134,12 @@ void GPU_HW::UpdateResolutionScale()
UpdateSettings(); UpdateSettings();
} }
std::tuple<u32, u32> GPU_HW::GetEffectiveDisplayResolution()
{
return std::make_tuple(m_crtc_state.display_vram_width * m_resolution_scale,
m_resolution_scale * m_crtc_state.display_vram_height);
}
void GPU_HW::PrintSettingsToLog() void GPU_HW::PrintSettingsToLog()
{ {
Log_InfoPrintf("Resolution Scale: %u (%ux%u), maximum %u", m_resolution_scale, VRAM_WIDTH * m_resolution_scale, Log_InfoPrintf("Resolution Scale: %u (%ux%u), maximum %u", m_resolution_scale, VRAM_WIDTH * m_resolution_scale,

View File

@ -34,7 +34,9 @@ public:
virtual bool Initialize(HostDisplay* host_display) override; virtual bool Initialize(HostDisplay* host_display) override;
virtual void Reset() override; virtual void Reset() override;
virtual bool DoState(StateWrapper& sw) override; virtual bool DoState(StateWrapper& sw) override;
virtual void UpdateResolutionScale() override;
void UpdateResolutionScale() override final;
std::tuple<u32, u32> GetEffectiveDisplayResolution() override final;
protected: protected:
enum : u32 enum : u32

View File

@ -385,6 +385,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetBoolValue("Display", "ShowFPS", false); si.SetBoolValue("Display", "ShowFPS", false);
si.SetBoolValue("Display", "ShowVPS", false); si.SetBoolValue("Display", "ShowVPS", false);
si.SetBoolValue("Display", "ShowSpeed", false); si.SetBoolValue("Display", "ShowSpeed", false);
si.SetBoolValue("Display", "ShowResolution", false);
si.SetBoolValue("Display", "Fullscreen", false); si.SetBoolValue("Display", "Fullscreen", false);
si.SetBoolValue("Display", "VSync", true); si.SetBoolValue("Display", "VSync", true);

View File

@ -121,6 +121,7 @@ void Settings::Load(SettingsInterface& si)
display_show_fps = si.GetBoolValue("Display", "ShowFPS", false); display_show_fps = si.GetBoolValue("Display", "ShowFPS", false);
display_show_vps = si.GetBoolValue("Display", "ShowVPS", false); display_show_vps = si.GetBoolValue("Display", "ShowVPS", false);
display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false); display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false);
display_show_resolution = si.GetBoolValue("Display", "ShowResolution", false);
video_sync_enabled = si.GetBoolValue("Display", "VSync", true); video_sync_enabled = si.GetBoolValue("Display", "VSync", true);
cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true); cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true);
@ -223,6 +224,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("Display", "ShowFPS", display_show_fps); si.SetBoolValue("Display", "ShowFPS", display_show_fps);
si.SetBoolValue("Display", "ShowVPS", display_show_vps); si.SetBoolValue("Display", "ShowVPS", display_show_vps);
si.SetBoolValue("Display", "ShowSpeed", display_show_speed); si.SetBoolValue("Display", "ShowSpeed", display_show_speed);
si.SetBoolValue("Display", "ShowResolution", display_show_speed);
si.SetBoolValue("Display", "VSync", video_sync_enabled); si.SetBoolValue("Display", "VSync", video_sync_enabled);
si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread); si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread);

View File

@ -101,6 +101,7 @@ struct Settings
bool display_show_fps = false; bool display_show_fps = false;
bool display_show_vps = false; bool display_show_vps = false;
bool display_show_speed = false; bool display_show_speed = false;
bool display_show_resolution = false;
bool video_sync_enabled = true; bool video_sync_enabled = true;
bool cdrom_read_thread = true; bool cdrom_read_thread = true;

View File

@ -21,6 +21,7 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showFPS, "Display", "ShowFPS", false); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showFPS, "Display", "ShowFPS", false);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showVPS, "Display", "ShowVPS", false); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showVPS, "Display", "ShowVPS", false);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showSpeed, "Display", "ShowSpeed", false); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showSpeed, "Display", "ShowSpeed", false);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.showResolution, "Display", "ShowResolution", false);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter, "Main", "SpeedLimiterEnabled", SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter, "Main", "SpeedLimiterEnabled",
true); true);

View File

@ -173,6 +173,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<widget class="QCheckBox" name="showResolution">
<property name="text">
<string>Show Resolution</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -723,11 +723,14 @@ void CommonHostInterface::DrawImGuiWindows()
void CommonHostInterface::DrawFPSWindow() void CommonHostInterface::DrawFPSWindow()
{ {
if (!(g_settings.display_show_fps | g_settings.display_show_vps | g_settings.display_show_speed)) if (!(g_settings.display_show_fps | g_settings.display_show_vps | g_settings.display_show_speed |
g_settings.display_show_resolution))
{
return; return;
}
const ImVec2 window_size = const ImVec2 window_size =
ImVec2(175.0f * ImGui::GetIO().DisplayFramebufferScale.x, 16.0f * ImGui::GetIO().DisplayFramebufferScale.y); ImVec2(175.0f * ImGui::GetIO().DisplayFramebufferScale.x, 48.0f * ImGui::GetIO().DisplayFramebufferScale.y);
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - window_size.x, 0.0f), ImGuiCond_Always); ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - window_size.x, 0.0f), ImGuiCond_Always);
ImGui::SetNextWindowSize(window_size); ImGui::SetNextWindowSize(window_size);
@ -784,6 +787,13 @@ void CommonHostInterface::DrawFPSWindow()
ImGui::TextColored(ImVec4(0.4f, 1.0f, 0.4f, 1.0f), "%u%%", rounded_speed); ImGui::TextColored(ImVec4(0.4f, 1.0f, 0.4f, 1.0f), "%u%%", rounded_speed);
} }
if (g_settings.display_show_resolution)
{
const auto [effective_width, effective_height] = g_gpu->GetEffectiveDisplayResolution();
const bool interlaced = g_gpu->IsInterlacedDisplayEnabled();
ImGui::Text("%ux%u (%s)", effective_width, effective_height, interlaced ? "interlaced" : "progressive");
}
ImGui::End(); ImGui::End();
} }
@ -1297,8 +1307,8 @@ void CommonHostInterface::RegisterGraphicsHotkeys()
ToggleSoftwareRendering(); ToggleSoftwareRendering();
}); });
RegisterHotkey(StaticString("Graphics"), StaticString("TogglePGXP"), StaticString("Toggle PGXP"), RegisterHotkey(
[this](bool pressed) { StaticString("Graphics"), StaticString("TogglePGXP"), StaticString("Toggle PGXP"), [this](bool pressed) {
if (!pressed) if (!pressed)
{ {
g_settings.gpu_pgxp_enable = !g_settings.gpu_pgxp_enable; g_settings.gpu_pgxp_enable = !g_settings.gpu_pgxp_enable;