From 67dc3eef4b97be26a55d4afb4f3fa63697791f2e Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Sat, 30 Jul 2016 15:20:18 +0300 Subject: [PATCH] gui: eeCycleRate: more accurate description based on measurements The ee cyclerate percentage values at the slider text were inaccurate, and sometimes wildely so. Add some code to measure the actual speed at runtime (disabled by default) and update the (static) slider text values according to the measurements. Also change the description from increase/reduce "by AA %" to "to BB %". This makes it slightly easier to grasp. E.g. "reduce speed to 10%" is easier to grasp than "reduce speed by 90%", and similarly, "increase speed to 300%" is easier to grasp than "increase speed by 200%". --- pcsx2/gui/Panels/SpeedhacksPanel.cpp | 10 +++++----- pcsx2/x86/ix86-32/iR5900-32.cpp | 30 ++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/pcsx2/gui/Panels/SpeedhacksPanel.cpp b/pcsx2/gui/Panels/SpeedhacksPanel.cpp index fb868bc130..4b6d7df2cb 100644 --- a/pcsx2/gui/Panels/SpeedhacksPanel.cpp +++ b/pcsx2/gui/Panels/SpeedhacksPanel.cpp @@ -26,27 +26,27 @@ const wxChar* Panels::SpeedHacksPanel::GetEEcycleSliderMsg( int val ) case -2: { m_msg_eecycle->SetForegroundColour(wxColour(L"Red")); - return pxEt(L"-2 - Reduces the EE's cyclerate by about 50%. Moderate speedup, but *will* cause stuttering audio on many FMVs."); + return pxEt(L"-2 - Reduces the EE's cyclerate to about 50%. Moderate speedup, but *will* cause stuttering audio on many FMVs."); } case -1: { m_msg_eecycle->SetForegroundColour(wxColour(L"Red")); - return pxEt(L"-1 - Reduces the EE's cyclerate by about 33%. Mild speedup for most games with high compatibility."); + return pxEt(L"-1 - Reduces the EE's cyclerate to about 60%. Mild speedup for most games with high compatibility."); } case 0: { m_msg_eecycle->SetForegroundColour(wxColour(14,158,19)); // Dark Green - return pxEt(L"0 - Default cyclerate. This closely matches the actual speed of a real PS2 EmotionEngine."); + return pxEt(L"0 - Default cyclerate (100%). This closely matches the actual speed of a real PS2 EmotionEngine."); } case 1: { m_msg_eecycle->SetForegroundColour(wxColour(L"Red")); - return pxEt(L"1 - Increases the EE's cyclerate by about 33%. Increases hardware requirements, may increase in-game FPS."); + return pxEt(L"1 - Increases the EE's cyclerate to about 180%. Increases hardware requirements, may increase in-game FPS."); } case 2: { m_msg_eecycle->SetForegroundColour(wxColour(L"Red")); - return pxEt(L"2 - Increases the EE's cyclerate by about 50%. Greatly increases hardware requirements, may noticeably increase in-game FPS.\nThis setting can cause games to FAIL TO BOOT."); + return pxEt(L"2 - Increases the EE's cyclerate to about 300%. Greatly increases hardware requirements, may noticeably increase in-game FPS.\nThis setting can cause games to FAIL TO BOOT."); } default: break; diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index c9673360b4..b3e6da8bc7 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -569,6 +569,7 @@ static __aligned16 u8 manual_counter[Ps2MemSize::MainRam >> 12]; static std::atomic eeRecIsReset(false); static std::atomic eeRecNeedsReset(false); static bool eeCpuExecuting = false; +static int g_resetEeScalingStats = 0; //////////////////////////////////////////////////// static void recResetRaw() @@ -604,6 +605,7 @@ static void recResetRaw() recConstBufPtr = recConstBuf; g_branch = 0; + g_resetEeScalingStats = 1; } static void recShutdown() @@ -952,14 +954,16 @@ void iFlushCall(int flushtype) // s_nBlockCycles is 3 bit fixed point. Divide by 8 when done! // Scaling blocks under 40 cycles seems to produce countless problem, so let's try to avoid them. -static u32 scaleblockcycles() +#define DEFAULT_SCALING_UNSANITIZED() (s_nBlockCycles >> 3) /* unsanitized sinec we don't check if 0 */ + +static u32 scaleblockcycles_calc() { bool lowcycles = (s_nBlockCycles <= 40); s8 cyclerate = EmuConfig.Speedhacks.EECycleRate; u32 scale_cycles = 0; if (cyclerate == 0 || lowcycles || cyclerate < -99 || cyclerate > 2) - scale_cycles = s_nBlockCycles >> 3; // Default cycle rate + scale_cycles = DEFAULT_SCALING_UNSANITIZED(); // Default cycle rate, could be 0 else if (cyclerate > 0) scale_cycles = s_nBlockCycles >> (3 + cyclerate); @@ -971,6 +975,28 @@ static u32 scaleblockcycles() return (scale_cycles < 1) ? 1 : scale_cycles; } +static u32 scaleblockcycles() { + u32 scaled = scaleblockcycles_calc(); + +#if 0 /* Enable this to get some runtime statistics about the scaling result in practuce */ + static u32 scaled_overal = 0, unscaled_overal = 0; + if (g_resetEeScalingStats) { + scaled_overal = unscaled_overal = 0; + g_resetEeScalingStats = 0; + } + u32 unscaled = DEFAULT_SCALING_UNSANITIZED(); + if (!unscaled) unscaled = 1; + + scaled_overal += scaled; + unscaled_overal += unscaled; + float ratio = (float)unscaled_overal / scaled_overal; + + DevCon.WriteLn(L"Unscaled overal: %d, scaled overal: %d, relative EE clock speed: %d %%", + unscaled_overal, scaled_overal, (int)(100 * ratio)); +#endif + + return scaled; +} // Generates dynarec code for Event tests followed by a block dispatch (branch). // Parameters: