From 52112006d40dca7b82121b11175d04f7a581e268 Mon Sep 17 00:00:00 2001 From: raven02 Date: Tue, 8 Jul 2014 23:18:29 +0800 Subject: [PATCH] RSX: simplify recale native resolution --- rpcs3/Emu/GS/RSXThread.cpp | 139 +++++++++-------------------------- rpcs3/Emu/GS/RSXThread.h | 3 +- rpcs3/Emu/GS/sysutil_video.h | 7 +- 3 files changed, 40 insertions(+), 109 deletions(-) diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 0143dcfe9d..6fcc246e36 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -9,6 +9,37 @@ u32 methodRegisters[0xffff]; +void RSXThread::nativeRescale(float width, float height) +{ + switch (Ini.GSResolution.GetValue()) + { + case 1: // 1920x1080 window size + m_width_scale = 1920 / width * 2.0f; + m_height_scale = 1080 / height * 2.0f; + m_width = 1920; + m_height = 1080; + break; + case 2: // 1280x720 window size + m_width_scale = 1280 / width * 2.0f; + m_height_scale = 720 / height * 2.0f; + m_width = 1280; + m_height = 720; + break; + case 4: // 720x480 window size + m_width_scale = 720 / width * 2.0f; + m_height_scale = 480 / height * 2.0f; + m_width = 720; + m_height = 480; + break; + case 5: // 720x576 window size + m_width_scale = 720 / width * 2.0f; + m_height_scale = 576 / height * 2.0f; + m_width = 720; + m_height = 576; + break; + } +} + u32 GetAddress(u32 offset, u8 location) { switch(location) @@ -1337,112 +1368,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 m_width = m_buffer_width = re(buffers[m_gcm_current_buffer].width); m_height = m_buffer_height = re(buffers[m_gcm_current_buffer].height); - // Rescale native 1080p to fit 720p/480p window size - if (m_buffer_width == 1920 && m_buffer_height == 1080) - { - switch (Ini.GSResolution.GetValue()) - { - case 2: // 1280x720 window size - m_width_scale = m_height_scale = 1.33f; - m_width = 1280; - m_height = 720; - break; - case 4: // 720x480 window size - m_width_scale = 0.75f; - m_height_scale = 0.88f; - m_width = 720; - m_height = 480; - break; - } - } - - // Rescale native 720p to fit 480p window size - if (m_buffer_width == 1280 && m_buffer_height == 720) - { - if (Ini.GSResolution.GetValue() == 4) // 720x480 window size - { - m_width_scale = 1.125f; - m_height_scale = 1.33f; - m_width = 720; - m_height = 480; - } - } - - // Rescale native 960x540 to fit 1080p/720p/480p window size - if (m_buffer_width == 960 && m_buffer_height == 540) - { - switch (Ini.GSResolution.GetValue()) - { - case 1: // 1920x1080 window size - m_width_scale = m_height_scale = 4.0f; - m_width = 1980; - m_height = 1080; - break; - case 2: // 1280x720 window size - m_width_scale = m_height_scale = 2.66f; - m_width = 1280; - m_height = 720; - break; - case 4: // 720x480 window size - m_width_scale = 1.5f; - m_height_scale = 1.77f; - m_width = 720; - m_height = 480; - break; - } - } - - // Rescale native 960x1080 to fit 1080p/720p/480p window size - if (m_buffer_width == 960 && m_buffer_height == 1080) - { - switch (Ini.GSResolution.GetValue()) - { - case 1: // 1920x1080 window size - m_width_scale = 4.0f; - m_height_scale = 2.0f; - m_width = 1980; - m_height = 1080; - break; - case 2: // 1280x720 window size - m_width_scale = 2.66f; - m_height_scale = 1.33f; - m_width = 1280; - m_height = 720; - break; - case 4: // 720x480 window size - m_width_scale = 1.5f; - m_height_scale = 0.88f; - m_width = 720; - m_height = 480; - break; - } - } - - // Rescale native 1024x768 to fit 1080p/720p/480p window size - if (m_buffer_width == 1024 && m_buffer_height == 768) - { - switch (Ini.GSResolution.GetValue()) - { - case 1: // 1920x1080 window size - m_width_scale = 3.75f; - m_height_scale = 2.81f; - m_width = 1980; - m_height = 1080; - break; - case 2: // 1280x720 window size - m_width_scale = 2.5f; - m_height_scale = 1.87f; - m_width = 1280; - m_height = 720; - break; - case 4: // 720x480 window size - m_width_scale = 1.4f; - m_height_scale = 1.25f; - m_width = 720; - m_height = 480; - break; - } - } + // Rescale native resolution to fit 1080p/720p/480p/576p window size + nativeRescale((float)m_buffer_width, (float)m_buffer_height); } break; diff --git a/rpcs3/Emu/GS/RSXThread.h b/rpcs3/Emu/GS/RSXThread.h index 10c8ef83bb..3dd6abbf58 100644 --- a/rpcs3/Emu/GS/RSXThread.h +++ b/rpcs3/Emu/GS/RSXThread.h @@ -595,7 +595,8 @@ protected: u32 OutOfArgsCount(const uint x, const u32 cmd, const u32 count); void DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u32 count); - + void nativeRescale(float width, float height); + virtual void OnInit() = 0; virtual void OnInitThread() = 0; virtual void OnExitThread() = 0; diff --git a/rpcs3/Emu/GS/sysutil_video.h b/rpcs3/Emu/GS/sysutil_video.h index 5be7d76c36..b0d03c6323 100644 --- a/rpcs3/Emu/GS/sysutil_video.h +++ b/rpcs3/Emu/GS/sysutil_video.h @@ -231,6 +231,7 @@ static const CellVideoOutResolution ResolutionTable[] = {1600, 1080}, //10 - 5 {1440, 1080}, //11 - 6 {1280, 1080}, //12 - 7 + {960, 1080}, //13 - 8 }; inline static u32 ResolutionIdToNum(u32 id) @@ -250,9 +251,10 @@ inline static u32 ResolutionIdToNum(u32 id) 5, //10 6, //11 7, //12 + 8, //13 }; - return id <= 12 ? res[id] : 0; + return id <= 13 ? res[id] : 0; } inline static u32 ResolutionNumToId(u32 num) @@ -267,7 +269,8 @@ inline static u32 ResolutionNumToId(u32 num) 10, //5 11, //6 12, //7 + 13, //8 }; - return num <= 7 ? res[num] : 0; + return num <= 8 ? res[num] : 0; }