From bb1c225e668b4373d3949d4599f0b1aad0d14611 Mon Sep 17 00:00:00 2001 From: Akash Date: Wed, 27 Jun 2018 19:55:33 +0530 Subject: [PATCH] Counters: Fix vsync hsync cycles calculation for rounding error In games like ICO where the render and blanks both need to be rounded, one was prioritized over the other one leading to a truncated value in the total vsync cycles. This patch fixes it, it's more or less for a trivial cycle accuracy rather than a signfifcant change which might influence games. (Not sure, maybe it would?) Potentially it might be nice to revamp the whole vertical blank calculation system to make it more readable (discussed about this with ref), but it's not of much priority right now. --- pcsx2/Counters.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index 87ac43c650..37c6aa82ca 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -220,6 +220,8 @@ static void vSyncInfoCalc(vSyncTimingInfo* info, Fixed100 framesPerSecond, u32 s hRender /= 2; } + //TODO: Carry fixed-point math all the way through the entire vsync and hsync counting processes, and continually apply rounding + //as needed for each scheduled v/hsync related event. Much better to handle than this messed state. info->Framerate = framesPerSecond; info->Render = (u32)(Render / 10000); info->Blank = (u32)(Blank / 10000); @@ -228,13 +230,11 @@ static void vSyncInfoCalc(vSyncTimingInfo* info, Fixed100 framesPerSecond, u32 s info->hBlank = (u32)(hBlank / 10000); info->hScanlinesPerFrame = scansPerFrame; - // Apply rounding: - // To investigate: Why is render rounding prioritized over blank? why skip the latter? if ((Render % 10000) >= 5000) info->Render++; - else if ((Blank % 10000) >= 5000) info->Blank++; + if ((Blank % 10000) >= 5000) info->Blank++; if ((hRender % 10000) >= 5000) info->hRender++; - else if ((hBlank % 10000) >= 5000) info->hBlank++; + if ((hBlank % 10000) >= 5000) info->hBlank++; // Calculate accumulative hSync rounding error per half-frame: if (IsAnalogVideoMode()) // gets off the chart in that mode