Merge pull request #3457 from booto/si-sampling
[RFC] SI: Base SI sampling on VSync & horiz lines
This commit is contained in:
commit
adffa5fbec
|
@ -565,25 +565,9 @@ void RunSIBuffer(u64 userdata, int cyclesLate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetTicksToNextSIPoll()
|
u32 GetPollXLines()
|
||||||
{
|
{
|
||||||
// Poll for input at regular intervals (once per frame) when playing or recording a movie
|
return g_Poll.X;
|
||||||
if (Movie::IsMovieActive())
|
|
||||||
{
|
|
||||||
if (Movie::IsNetPlayRecording())
|
|
||||||
return SystemTimers::GetTicksPerSecond() / VideoInterface::TargetRefreshRate / 2;
|
|
||||||
else
|
|
||||||
return SystemTimers::GetTicksPerSecond() / VideoInterface::TargetRefreshRate;
|
|
||||||
}
|
|
||||||
if (NetPlay::IsNetPlayRunning())
|
|
||||||
return SystemTimers::GetTicksPerSecond() / VideoInterface::TargetRefreshRate / 2;
|
|
||||||
|
|
||||||
if (!g_Poll.Y && g_Poll.X)
|
|
||||||
return 2 * VideoInterface::GetTicksPerHalfLine() * g_Poll.X;
|
|
||||||
else if (!g_Poll.Y)
|
|
||||||
return SystemTimers::GetTicksPerSecond() / 60;
|
|
||||||
|
|
||||||
return std::min(VideoInterface::GetTicksPerField() / g_Poll.Y, 2 * VideoInterface::GetTicksPerHalfLine() * g_Poll.X);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace SerialInterface
|
} // end of namespace SerialInterface
|
||||||
|
|
|
@ -38,6 +38,6 @@ void ChangeDevice(SIDevices device, int channel);
|
||||||
|
|
||||||
SIDevices GetDeviceType(int channel);
|
SIDevices GetDeviceType(int channel);
|
||||||
|
|
||||||
int GetTicksToNextSIPoll();
|
u32 GetPollXLines();
|
||||||
|
|
||||||
} // end of namespace SerialInterface
|
} // end of namespace SerialInterface
|
||||||
|
|
|
@ -55,7 +55,6 @@ IPC_HLE_PERIOD: For the Wiimote this is the call schedule:
|
||||||
#include "Core/HW/AudioInterface.h"
|
#include "Core/HW/AudioInterface.h"
|
||||||
#include "Core/HW/DSP.h"
|
#include "Core/HW/DSP.h"
|
||||||
#include "Core/HW/EXI_DeviceIPL.h"
|
#include "Core/HW/EXI_DeviceIPL.h"
|
||||||
#include "Core/HW/SI.h"
|
|
||||||
#include "Core/HW/SystemTimers.h"
|
#include "Core/HW/SystemTimers.h"
|
||||||
#include "Core/HW/VideoInterface.h"
|
#include "Core/HW/VideoInterface.h"
|
||||||
#include "Core/IPC_HLE/WII_IPC_HLE.h"
|
#include "Core/IPC_HLE/WII_IPC_HLE.h"
|
||||||
|
@ -69,7 +68,6 @@ namespace SystemTimers
|
||||||
|
|
||||||
static int et_Dec;
|
static int et_Dec;
|
||||||
static int et_VI;
|
static int et_VI;
|
||||||
static int et_SI;
|
|
||||||
static int et_CP;
|
static int et_CP;
|
||||||
static int et_AudioDMA;
|
static int et_AudioDMA;
|
||||||
static int et_DSP;
|
static int et_DSP;
|
||||||
|
@ -127,12 +125,6 @@ static void VICallback(u64 userdata, int cyclesLate)
|
||||||
CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerHalfLine() - cyclesLate, et_VI);
|
CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerHalfLine() - cyclesLate, et_VI);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SICallback(u64 userdata, int cyclesLate)
|
|
||||||
{
|
|
||||||
SerialInterface::UpdateDevices();
|
|
||||||
CoreTiming::ScheduleEvent(SerialInterface::GetTicksToNextSIPoll() - cyclesLate, et_SI);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CPCallback(u64 userdata, int cyclesLate)
|
static void CPCallback(u64 userdata, int cyclesLate)
|
||||||
{
|
{
|
||||||
u64 now = CoreTiming::GetTicks();
|
u64 now = CoreTiming::GetTicks();
|
||||||
|
@ -248,7 +240,6 @@ void Init()
|
||||||
|
|
||||||
et_Dec = CoreTiming::RegisterEvent("DecCallback", DecrementerCallback);
|
et_Dec = CoreTiming::RegisterEvent("DecCallback", DecrementerCallback);
|
||||||
et_VI = CoreTiming::RegisterEvent("VICallback", VICallback);
|
et_VI = CoreTiming::RegisterEvent("VICallback", VICallback);
|
||||||
et_SI = CoreTiming::RegisterEvent("SICallback", SICallback);
|
|
||||||
if (SConfig::GetInstance().bCPUThread && SConfig::GetInstance().bSyncGPU)
|
if (SConfig::GetInstance().bCPUThread && SConfig::GetInstance().bSyncGPU)
|
||||||
et_CP = CoreTiming::RegisterEvent("CPCallback", CPCallback);
|
et_CP = CoreTiming::RegisterEvent("CPCallback", CPCallback);
|
||||||
et_DSP = CoreTiming::RegisterEvent("DSPCallback", DSPCallback);
|
et_DSP = CoreTiming::RegisterEvent("DSPCallback", DSPCallback);
|
||||||
|
@ -259,7 +250,6 @@ void Init()
|
||||||
|
|
||||||
CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerHalfLine(), et_VI);
|
CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerHalfLine(), et_VI);
|
||||||
CoreTiming::ScheduleEvent(0, et_DSP);
|
CoreTiming::ScheduleEvent(0, et_DSP);
|
||||||
CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerField(), et_SI);
|
|
||||||
CoreTiming::ScheduleEvent(s_audio_dma_period, et_AudioDMA);
|
CoreTiming::ScheduleEvent(s_audio_dma_period, et_AudioDMA);
|
||||||
CoreTiming::ScheduleEvent(0, et_Throttle, Common::Timer::GetTimeMs());
|
CoreTiming::ScheduleEvent(0, et_Throttle, Common::Timer::GetTimeMs());
|
||||||
if (SConfig::GetInstance().bCPUThread && SConfig::GetInstance().bSyncGPU)
|
if (SConfig::GetInstance().bCPUThread && SConfig::GetInstance().bSyncGPU)
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
#include "Core/HW/MMIO.h"
|
#include "Core/HW/MMIO.h"
|
||||||
#include "Core/HW/ProcessorInterface.h"
|
#include "Core/HW/ProcessorInterface.h"
|
||||||
|
#include "Core/HW/SI.h"
|
||||||
#include "Core/HW/SystemTimers.h"
|
#include "Core/HW/SystemTimers.h"
|
||||||
#include "Core/HW/VideoInterface.h"
|
#include "Core/HW/VideoInterface.h"
|
||||||
#include "Core/PowerPC/PowerPC.h"
|
#include "Core/PowerPC/PowerPC.h"
|
||||||
|
@ -63,7 +64,8 @@ static u32 s_clock_freqs[2] =
|
||||||
|
|
||||||
static u64 s_ticks_last_line_start; // number of ticks when the current full scanline started
|
static u64 s_ticks_last_line_start; // number of ticks when the current full scanline started
|
||||||
static u32 s_half_line_count; // number of halflines that have occurred for this full frame
|
static u32 s_half_line_count; // number of halflines that have occurred for this full frame
|
||||||
|
static u32 s_half_line_of_next_si_poll; // halfline when next SI poll results should be available
|
||||||
|
static constexpr u32 num_half_lines_for_si_poll = (7 * 2) + 1; // this is how long an SI poll takes
|
||||||
|
|
||||||
static FieldType s_current_field;
|
static FieldType s_current_field;
|
||||||
|
|
||||||
|
@ -100,6 +102,7 @@ void DoState(PointerWrap &p)
|
||||||
p.Do(TargetRefreshRate);
|
p.Do(TargetRefreshRate);
|
||||||
p.Do(s_ticks_last_line_start);
|
p.Do(s_ticks_last_line_start);
|
||||||
p.Do(s_half_line_count);
|
p.Do(s_half_line_count);
|
||||||
|
p.Do(s_half_line_of_next_si_poll);
|
||||||
p.Do(s_current_field);
|
p.Do(s_current_field);
|
||||||
p.Do(s_even_field_first_hl);
|
p.Do(s_even_field_first_hl);
|
||||||
p.Do(s_odd_field_first_hl);
|
p.Do(s_odd_field_first_hl);
|
||||||
|
@ -158,6 +161,7 @@ void Preset(bool _bNTSC)
|
||||||
|
|
||||||
s_ticks_last_line_start = 0;
|
s_ticks_last_line_start = 0;
|
||||||
s_half_line_count = 1;
|
s_half_line_count = 1;
|
||||||
|
s_half_line_of_next_si_poll = num_half_lines_for_si_poll; // first sampling starts at vsync
|
||||||
s_current_field = FIELD_ODD;
|
s_current_field = FIELD_ODD;
|
||||||
|
|
||||||
UpdateParameters();
|
UpdateParameters();
|
||||||
|
@ -661,6 +665,11 @@ static void EndField()
|
||||||
// Run when: When a frame is scanned (progressive/interlace)
|
// Run when: When a frame is scanned (progressive/interlace)
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
if (s_half_line_of_next_si_poll == s_half_line_count)
|
||||||
|
{
|
||||||
|
SerialInterface::UpdateDevices();
|
||||||
|
s_half_line_of_next_si_poll += SerialInterface::GetPollXLines();
|
||||||
|
}
|
||||||
if (s_half_line_count == s_even_field_first_hl)
|
if (s_half_line_count == s_even_field_first_hl)
|
||||||
{
|
{
|
||||||
BeginField(FIELD_EVEN);
|
BeginField(FIELD_EVEN);
|
||||||
|
@ -688,11 +697,19 @@ void Update()
|
||||||
|
|
||||||
s_half_line_count++;
|
s_half_line_count++;
|
||||||
|
|
||||||
if (s_half_line_count > GetHalfLinesPerEvenField() + GetHalfLinesPerOddField()) {
|
if (s_half_line_count > GetHalfLinesPerEvenField() + GetHalfLinesPerOddField())
|
||||||
|
{
|
||||||
s_half_line_count = 1;
|
s_half_line_count = 1;
|
||||||
|
s_half_line_of_next_si_poll = num_half_lines_for_si_poll; // first results start at vsync
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_half_line_count & 1) {
|
if (s_half_line_count == GetHalfLinesPerEvenField())
|
||||||
|
{
|
||||||
|
s_half_line_of_next_si_poll = GetHalfLinesPerEvenField() + num_half_lines_for_si_poll;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_half_line_count & 1)
|
||||||
|
{
|
||||||
s_ticks_last_line_start = CoreTiming::GetTicks();
|
s_ticks_last_line_start = CoreTiming::GetTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
|
||||||
static std::thread g_save_thread;
|
static std::thread g_save_thread;
|
||||||
|
|
||||||
// Don't forget to increase this after doing changes on the savestate system
|
// Don't forget to increase this after doing changes on the savestate system
|
||||||
static const u32 STATE_VERSION = 49; // Last changed in PR 2149
|
static const u32 STATE_VERSION = 50; // Last changed in PR 3457
|
||||||
|
|
||||||
// Maps savestate versions to Dolphin versions.
|
// Maps savestate versions to Dolphin versions.
|
||||||
// Versions after 42 don't need to be added to this list,
|
// Versions after 42 don't need to be added to this list,
|
||||||
|
|
Loading…
Reference in New Issue