Remove Frameskip

This commit is contained in:
anthony 2016-10-07 19:55:47 -07:00 committed by Helios747
parent 4ba1100f31
commit b427ead0cc
20 changed files with 83 additions and 204 deletions

View File

@ -56,7 +56,6 @@ public:
// alone on restore (false)
bool bSetEmulationSpeed;
bool bSetVolume;
bool bSetFrameSkip;
std::array<bool, MAX_BBMOTES> bSetWiimoteSource;
std::array<bool, MAX_SI_CHANNELS> bSetPads;
std::array<bool, MAX_EXI_CHANNELS> bSetEXIDevice;
@ -80,7 +79,6 @@ private:
int iSelectedLanguage;
int iCPUCore;
int Volume;
unsigned int frameSkip;
float m_EmulationSpeed;
std::string strBackend;
std::string sBackend;
@ -112,7 +110,6 @@ void ConfigCache::SaveConfig(const SConfig& config)
iCPUCore = config.iCPUCore;
Volume = config.m_Volume;
m_EmulationSpeed = config.m_EmulationSpeed;
frameSkip = config.m_FrameSkip;
strBackend = config.m_strVideoBackend;
sBackend = config.sBackend;
m_strGPUDeterminismMode = config.m_strGPUDeterminismMode;
@ -123,7 +120,6 @@ void ConfigCache::SaveConfig(const SConfig& config)
bSetEmulationSpeed = false;
bSetVolume = false;
bSetFrameSkip = false;
bSetWiimoteSource.fill(false);
bSetPads.fill(false);
bSetEXIDevice.fill(false);
@ -182,12 +178,6 @@ void ConfigCache::RestoreConfig(SConfig* config)
if (bSetEmulationSpeed)
config->m_EmulationSpeed = m_EmulationSpeed;
if (bSetFrameSkip)
{
config->m_FrameSkip = frameSkip;
Movie::SetFrameSkipping(frameSkip);
}
for (unsigned int i = 0; i < MAX_EXI_CHANNELS; ++i)
{
if (bSetEXIDevice[i])
@ -264,11 +254,6 @@ bool BootCore(const std::string& _rFilename)
if (core_section->Get("EmulationSpeed", &SConfig::GetInstance().m_EmulationSpeed,
SConfig::GetInstance().m_EmulationSpeed))
config_cache.bSetEmulationSpeed = true;
if (core_section->Get("FrameSkip", &SConfig::GetInstance().m_FrameSkip))
{
config_cache.bSetFrameSkip = true;
Movie::SetFrameSkipping(SConfig::GetInstance().m_FrameSkip);
}
if (dsp_section->Get("Volume", &SConfig::GetInstance().m_Volume,
SConfig::GetInstance().m_Volume))

View File

@ -44,8 +44,6 @@
// The chunk to allocate movie data in multiples of.
#define DTM_BASE_LENGTH (1024)
static std::mutex cs_frameSkip;
namespace Movie
{
static bool s_bFrameStep = false;
@ -53,8 +51,6 @@ static bool s_bReadOnly = true;
static u32 s_rerecords = 0;
static PlayMode s_playMode = MODE_NONE;
static u32 s_framesToSkip = 0, s_frameSkipCounter = 0;
static u8 s_numPads = 0;
static ControllerState s_padState;
static DTMHeader tmpHeader;
@ -211,9 +207,6 @@ void FrameUpdate()
CPU::Break();
}
if (s_framesToSkip)
FrameSkipping();
s_bPolled = false;
}
@ -247,7 +240,6 @@ void Init()
s_tickCountAtLastInput = 0;
}
s_frameSkipCounter = s_framesToSkip;
memset(&s_padState, 0, sizeof(s_padState));
if (!tmpHeader.bFromSaveState || !IsPlayingInput())
Core::SetStateFileName("");
@ -278,20 +270,6 @@ void InputUpdate()
}
}
// NOTE: Host Thread
void SetFrameSkipping(unsigned int framesToSkip)
{
std::lock_guard<std::mutex> lk(cs_frameSkip);
s_framesToSkip = framesToSkip;
s_frameSkipCounter = 0;
// Don't forget to re-enable rendering in case it wasn't...
// as this won't be changed anymore when frameskip is turned off
if (framesToSkip == 0)
Fifo::SetRendering(true);
}
// NOTE: CPU Thread
void SetPolledDevice()
{
@ -324,22 +302,6 @@ void SetReadOnly(bool bEnabled)
s_bReadOnly = bEnabled;
}
// NOTE: GPU Thread
void FrameSkipping()
{
// Frameskipping will desync movie playback
if (!Core::g_want_determinism)
{
std::lock_guard<std::mutex> lk(cs_frameSkip);
s_frameSkipCounter++;
if (s_frameSkipCounter > s_framesToSkip || Core::ShouldSkipFrame(s_frameSkipCounter) == false)
s_frameSkipCounter = 0;
Fifo::SetRendering(!s_frameSkipCounter);
}
}
bool IsRecordingInput()
{
return (s_playMode == MODE_RECORDING);

View File

@ -158,9 +158,6 @@ void ChangeWiiPads(bool instantly = false);
void DoFrameStep();
void SetReadOnly(bool bEnabled);
void SetFrameSkipping(unsigned int framesToSkip);
void FrameSkipping();
bool BeginRecordingInput(int controllers);
void RecordInput(GCPadStatus* PadStatus, int controllerID);
void RecordWiimote(int wiimote, u8* data, u8 size);

View File

@ -71,7 +71,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
static std::thread g_save_thread;
// Don't forget to increase this after doing changes on the savestate system
static const u32 STATE_VERSION = 62; // Last changed in PR 4195
static const u32 STATE_VERSION = 63; // Last changed in PR 4322
// Maps savestate versions to Dolphin versions.
// Versions after 42 don't need to be added to this list,

View File

@ -307,7 +307,6 @@ EVT_MENU_RANGE(IDM_LOAD_SLOT_1, IDM_LOAD_SLOT_10, CFrame::OnLoadState)
EVT_MENU_RANGE(IDM_LOAD_LAST_1, IDM_LOAD_LAST_10, CFrame::OnLoadLastState)
EVT_MENU_RANGE(IDM_SAVE_SLOT_1, IDM_SAVE_SLOT_10, CFrame::OnSaveState)
EVT_MENU_RANGE(IDM_SELECT_SLOT_1, IDM_SELECT_SLOT_10, CFrame::OnSelectSlot)
EVT_MENU_RANGE(IDM_FRAME_SKIP_0, IDM_FRAME_SKIP_9, CFrame::OnFrameSkip)
EVT_MENU_RANGE(IDM_DRIVE1, IDM_DRIVE24, CFrame::OnBootDrive)
EVT_MENU_RANGE(IDM_CONNECT_WIIMOTE1, IDM_CONNECT_BALANCEBOARD, CFrame::OnConnectWiimote)
EVT_MENU_RANGE(IDM_LIST_WAD, IDM_LIST_DRIVES, CFrame::GameListChanged)

View File

@ -283,7 +283,6 @@ private:
void OnUndoLoadState(wxCommandEvent& event);
void OnUndoSaveState(wxCommandEvent& event);
void OnFrameSkip(wxCommandEvent& event);
void OnFrameStep(wxCommandEvent& event);
void OnConfigMain(wxCommandEvent& event); // Options

View File

@ -135,13 +135,6 @@ wxMenuBar* CFrame::CreateMenu()
emulationMenu->Append(IDM_TOGGLE_FULLSCREEN, GetMenuLabel(HK_FULLSCREEN));
emulationMenu->Append(IDM_FRAMESTEP, GetMenuLabel(HK_FRAME_ADVANCE), wxEmptyString);
wxMenu* skippingMenu = new wxMenu;
emulationMenu->AppendSubMenu(skippingMenu, _("Frame S&kipping"));
for (int i = 0; i < 10; i++)
skippingMenu->AppendRadioItem(IDM_FRAME_SKIP_0 + i, wxString::Format("%i", i));
skippingMenu->Check(IDM_FRAME_SKIP_0 + SConfig::GetInstance().m_FrameSkip, true);
Movie::SetFrameSkipping(SConfig::GetInstance().m_FrameSkip);
emulationMenu->AppendSeparator();
emulationMenu->Append(IDM_SCREENSHOT, GetMenuLabel(HK_SCREENSHOT));
@ -1643,14 +1636,6 @@ void CFrame::OnSaveState(wxCommandEvent& event)
}
}
void CFrame::OnFrameSkip(wxCommandEvent& event)
{
int amount = event.GetId() - IDM_FRAME_SKIP_0;
Movie::SetFrameSkipping((unsigned int)amount);
SConfig::GetInstance().m_FrameSkip = amount;
}
void CFrame::OnSelectSlot(wxCommandEvent& event)
{
m_saveSlot = event.GetId() - IDM_SELECT_SLOT_1 + 1;

View File

@ -73,16 +73,6 @@ enum
IDM_SELECT_SLOT_10,
IDM_SAVE_SELECTED_SLOT,
IDM_LOAD_SELECTED_SLOT,
IDM_FRAME_SKIP_0,
IDM_FRAME_SKIP_1,
IDM_FRAME_SKIP_2,
IDM_FRAME_SKIP_3,
IDM_FRAME_SKIP_4,
IDM_FRAME_SKIP_5,
IDM_FRAME_SKIP_6,
IDM_FRAME_SKIP_7,
IDM_FRAME_SKIP_8,
IDM_FRAME_SKIP_9,
IDM_PLAY,
IDM_STOP,
IDM_RESET,

View File

@ -765,8 +765,7 @@ void formatBufferDump(const u8* in, u8* out, int w, int h, int p)
void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
const EFBRectangle& rc, float Gamma)
{
if (Fifo::WillSkipCurrentFrame() || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) ||
!fbWidth || !fbHeight)
if ((!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight)
{
RepeatFrameDumpFrame();
Core::Callback_VideoCopiedToXFB(false);

View File

@ -708,8 +708,7 @@ void formatBufferDump(const u8* in, u8* out, int w, int h, int p)
void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height,
const EFBRectangle& rc, float gamma)
{
if (Fifo::WillSkipCurrentFrame() || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) ||
!fb_width || !fb_height)
if ((!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fb_width || !fb_height)
{
RepeatFrameDumpFrame();
Core::Callback_VideoCopiedToXFB(false);

View File

@ -1350,8 +1350,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
glDisable(GL_DEBUG_OUTPUT);
}
if (Fifo::WillSkipCurrentFrame() || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) ||
!fbWidth || !fbHeight)
if ((!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight)
{
RepeatFrameDumpFrame();
Core::Callback_VideoCopiedToXFB(false);

View File

@ -192,40 +192,32 @@ void CopyTempBuffer(s16 x, s16 y, int bufferBase, int subBuffer, const char* nam
void OnObjectBegin()
{
if (!Fifo::WillSkipCurrentFrame())
{
if (g_ActiveConfig.bDumpTextures &&
stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart &&
stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
DumpActiveTextures();
}
if (g_ActiveConfig.bDumpTextures && stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart &&
stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
DumpActiveTextures();
}
void OnObjectEnd()
{
if (!Fifo::WillSkipCurrentFrame())
if (g_ActiveConfig.bDumpObjects && stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart &&
stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
DumpEfb(StringFromFormat("%sobject%i.png", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
stats.thisFrame.numDrawnObjects));
for (int i = 0; i < NUM_OBJECT_BUFFERS; i++)
{
if (g_ActiveConfig.bDumpObjects &&
stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart &&
stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
DumpEfb(StringFromFormat("%sobject%i.png", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
stats.thisFrame.numDrawnObjects));
for (int i = 0; i < NUM_OBJECT_BUFFERS; i++)
if (DrawnToBuffer[i])
{
if (DrawnToBuffer[i])
{
DrawnToBuffer[i] = false;
std::string filename = StringFromFormat(
"%sobject%i_%s(%i).png", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
stats.thisFrame.numDrawnObjects, ObjectBufferName[i], i - BufferBase[i]);
DrawnToBuffer[i] = false;
std::string filename =
StringFromFormat("%sobject%i_%s(%i).png", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(),
stats.thisFrame.numDrawnObjects, ObjectBufferName[i], i - BufferBase[i]);
TextureToPng((u8*)ObjectBuffer[i], EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true);
memset(ObjectBuffer[i], 0, EFB_WIDTH * EFB_HEIGHT * sizeof(u32));
}
TextureToPng((u8*)ObjectBuffer[i], EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true);
memset(ObjectBuffer[i], 0, EFB_WIDTH * EFB_HEIGHT * sizeof(u32));
}
stats.thisFrame.numDrawnObjects++;
}
stats.thisFrame.numDrawnObjects++;
}
}

View File

@ -67,34 +67,31 @@ void CopyEfb()
rc.right = rc.left + (int)bpmem.copyTexSrcWH.x + 1;
rc.bottom = rc.top + (int)bpmem.copyTexSrcWH.y + 1;
if (!Fifo::WillSkipCurrentFrame())
if (bpmem.triggerEFBCopy.copy_to_xfb)
{
if (bpmem.triggerEFBCopy.copy_to_xfb)
{
float yScale;
if (bpmem.triggerEFBCopy.scale_invert)
yScale = 256.0f / (float)bpmem.dispcopyyscale;
else
yScale = (float)bpmem.dispcopyyscale / 256.0f;
float xfbLines = ((bpmem.copyTexSrcWH.y + 1.0f) * yScale);
if (yScale != 1.0)
WARN_LOG(VIDEO, "yScale of %f is currently unsupported", yScale);
if ((u32)xfbLines > MAX_XFB_HEIGHT)
{
INFO_LOG(VIDEO, "Tried to scale EFB to too many XFB lines (%f)", xfbLines);
xfbLines = MAX_XFB_HEIGHT;
}
CopyToXfb(bpmem.copyTexDest << 5, bpmem.copyMipMapStrideChannels << 4, (u32)xfbLines, rc,
s_gammaLUT[bpmem.triggerEFBCopy.gamma]);
}
float yScale;
if (bpmem.triggerEFBCopy.scale_invert)
yScale = 256.0f / (float)bpmem.dispcopyyscale;
else
yScale = (float)bpmem.dispcopyyscale / 256.0f;
float xfbLines = ((bpmem.copyTexSrcWH.y + 1.0f) * yScale);
if (yScale != 1.0)
WARN_LOG(VIDEO, "yScale of %f is currently unsupported", yScale);
if ((u32)xfbLines > MAX_XFB_HEIGHT)
{
CopyToRam(); // FIXME: should use the rectangle we have already created above
INFO_LOG(VIDEO, "Tried to scale EFB to too many XFB lines (%f)", xfbLines);
xfbLines = MAX_XFB_HEIGHT;
}
CopyToXfb(bpmem.copyTexDest << 5, bpmem.copyMipMapStrideChannels << 4, (u32)xfbLines, rc,
s_gammaLUT[bpmem.triggerEFBCopy.gamma]);
}
else
{
CopyToRam(); // FIXME: should use the rectangle we have already created above
}
}
}

View File

@ -112,42 +112,39 @@ void SWRenderer::UpdateColorTexture(EfbInterface::yuv422_packed* xfb, u32 fbWidt
void SWRenderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
const EFBRectangle& rc, float Gamma)
{
if (!Fifo::WillSkipCurrentFrame())
if (g_ActiveConfig.bUseXFB)
{
if (g_ActiveConfig.bUseXFB)
{
EfbInterface::yuv422_packed* xfb = (EfbInterface::yuv422_packed*)Memory::GetPointer(xfbAddr);
UpdateColorTexture(xfb, fbWidth, fbHeight);
}
else
{
EfbInterface::BypassXFB(GetCurrentColorTexture(), fbWidth, fbHeight, rc, Gamma);
}
EfbInterface::yuv422_packed* xfb = (EfbInterface::yuv422_packed*)Memory::GetPointer(xfbAddr);
UpdateColorTexture(xfb, fbWidth, fbHeight);
}
else
{
EfbInterface::BypassXFB(GetCurrentColorTexture(), fbWidth, fbHeight, rc, Gamma);
}
// Save screenshot
if (s_bScreenshot)
{
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
// Save screenshot
if (s_bScreenshot)
{
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
if (TextureToPng(GetCurrentColorTexture(), fbWidth * 4, s_sScreenshotName, fbWidth, fbHeight,
false))
OSD::AddMessage("Screenshot saved to " + s_sScreenshotName);
if (TextureToPng(GetCurrentColorTexture(), fbWidth * 4, s_sScreenshotName, fbWidth, fbHeight,
false))
OSD::AddMessage("Screenshot saved to " + s_sScreenshotName);
// Reset settings
s_sScreenshotName.clear();
s_bScreenshot = false;
s_screenshotCompleted.Set();
}
// Reset settings
s_sScreenshotName.clear();
s_bScreenshot = false;
s_screenshotCompleted.Set();
}
if (SConfig::GetInstance().m_DumpFrames)
{
static int frame_index = 0;
TextureToPng(GetCurrentColorTexture(), fbWidth * 4,
StringFromFormat("%sframe%i_color.png",
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), frame_index),
fbWidth, fbHeight, true);
frame_index++;
}
if (SConfig::GetInstance().m_DumpFrames)
{
static int frame_index = 0;
TextureToPng(GetCurrentColorTexture(), fbWidth * 4,
StringFromFormat("%sframe%i_color.png",
File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), frame_index),
fbWidth, fbHeight, true);
frame_index++;
}
OSD::DoCallbacks(OSD::CallbackType::OnFrame);

View File

@ -380,19 +380,16 @@ static void BPWritten(const BPCmd& bp)
// -------------------------
case BPMEM_CLEARBBOX1:
case BPMEM_CLEARBBOX2:
// Don't compute bounding box if this frame is being skipped!
// Wrong but valid values are better than bogus values...
if (!Fifo::WillSkipCurrentFrame())
{
u8 offset = bp.address & 2;
BoundingBox::active = true;
{
u8 offset = bp.address & 2;
BoundingBox::active = true;
if (g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable)
{
g_renderer->BBoxWrite(offset, bp.newvalue & 0x3ff);
g_renderer->BBoxWrite(offset + 1, bp.newvalue >> 10);
}
if (g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable)
{
g_renderer->BBoxWrite(offset, bp.newvalue & 0x3ff);
g_renderer->BBoxWrite(offset + 1, bp.newvalue >> 10);
}
}
return;
case BPMEM_TEXINVALIDATE:
// TODO: Needs some restructuring in TextureCacheBase.

View File

@ -34,8 +34,6 @@ namespace Fifo
static constexpr u32 FIFO_SIZE = 2 * 1024 * 1024;
static constexpr int GPU_TIME_SLOT_SIZE = 1000;
static bool s_skip_current_frame = false;
static Common::BlockingLoop s_gpu_mainloop;
static Common::Flag s_emu_running_state;
@ -86,7 +84,6 @@ void DoState(PointerWrap& p)
s_video_buffer_seen_ptr = s_video_buffer_pp_read_ptr = s_video_buffer_read_ptr;
}
p.Do(s_skip_current_frame);
p.Do(s_sync_ticks);
}
@ -130,16 +127,6 @@ void Shutdown()
s_fifo_aux_read_ptr = nullptr;
}
void SetRendering(bool enabled)
{
s_skip_current_frame = !enabled;
}
bool WillSkipCurrentFrame()
{
return s_skip_current_frame;
}
// May be executed from any thread, even the graphics thread.
// Created to allow for self shutdown.
void ExitGpuLoop()

View File

@ -44,7 +44,5 @@ void ExitGpuLoop();
void EmulatorState(bool running);
bool AtBreakpoint();
void ResetVideoBuffer();
void SetRendering(bool bEnabled);
bool WillSkipCurrentFrame();
} // namespace Fifo

View File

@ -264,8 +264,7 @@ u8* Run(DataReader src, u32* cycles, bool in_display_list)
u16 num_vertices = src.Read<u16>();
int bytes = VertexLoaderManager::RunVertices(
cmd_byte & GX_VAT_MASK, // Vertex loader index (0 - 7)
(cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT, num_vertices, src,
Fifo::WillSkipCurrentFrame(), is_preprocess);
(cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT, num_vertices, src, is_preprocess);
if (bytes < 0)
goto end;

View File

@ -180,8 +180,7 @@ static VertexLoaderBase* RefreshLoader(int vtx_attr_group, bool preprocess = fal
return loader;
}
int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bool skip_drawing,
bool is_preprocess)
int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bool is_preprocess)
{
if (!count)
return 0;
@ -192,7 +191,7 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
if ((int)src.size() < size)
return -1;
if (skip_drawing || is_preprocess)
if (is_preprocess)
return size;
// If the native vertex format changed, force a flush.

View File

@ -27,8 +27,7 @@ void MarkAllDirty();
NativeVertexFormatMap* GetNativeVertexFormatMap();
// Returns -1 if buf_size is insufficient, else the amount of bytes consumed
int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bool skip_drawing,
bool is_preprocess);
int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bool is_preprocess);
// For debugging
void AppendListToString(std::string* dest);