2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2021-12-09 19:22:16 -07:00
|
|
|
#include "VideoCommon/VideoState.h"
|
|
|
|
|
2016-01-17 14:54:31 -07:00
|
|
|
#include <cstring>
|
|
|
|
|
2014-07-29 18:55:07 -06:00
|
|
|
#include "Common/ChunkFile.h"
|
2022-11-27 05:50:50 -07:00
|
|
|
#include "Core/System.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/BPMemory.h"
|
2023-01-27 19:13:49 -07:00
|
|
|
#include "VideoCommon/BPStructs.h"
|
2023-01-30 21:29:16 -07:00
|
|
|
#include "VideoCommon/BoundingBox.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/CPMemory.h"
|
2014-12-14 13:23:13 -07:00
|
|
|
#include "VideoCommon/CommandProcessor.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/Fifo.h"
|
2023-01-30 21:26:46 -07:00
|
|
|
#include "VideoCommon/FrameDumper.h"
|
2023-01-30 21:29:16 -07:00
|
|
|
#include "VideoCommon/FramebufferManager.h"
|
2014-12-14 13:23:13 -07:00
|
|
|
#include "VideoCommon/GeometryShaderManager.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/PixelEngine.h"
|
|
|
|
#include "VideoCommon/PixelShaderManager.h"
|
2023-01-30 21:26:46 -07:00
|
|
|
#include "VideoCommon/Present.h"
|
2021-10-09 20:49:59 -06:00
|
|
|
#include "VideoCommon/TMEM.h"
|
2019-06-29 03:27:53 -06:00
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/TextureDecoder.h"
|
2022-10-07 13:25:04 -06:00
|
|
|
#include "VideoCommon/VertexLoaderManager.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/VertexManagerBase.h"
|
|
|
|
#include "VideoCommon/VertexShaderManager.h"
|
2023-01-30 21:58:54 -07:00
|
|
|
#include "VideoCommon/Widescreen.h"
|
2014-02-18 18:27:20 -07:00
|
|
|
#include "VideoCommon/XFMemory.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2016-01-12 14:46:44 -07:00
|
|
|
void VideoCommon_DoState(PointerWrap& p)
|
2008-10-25 09:53:43 -06:00
|
|
|
{
|
2019-06-29 03:27:53 -06:00
|
|
|
bool software = false;
|
|
|
|
p.Do(software);
|
|
|
|
|
2022-05-17 23:29:05 -06:00
|
|
|
if (p.IsReadMode() && software == true)
|
2019-06-29 03:27:53 -06:00
|
|
|
{
|
|
|
|
// change mode to abort load of incompatible save state.
|
2022-05-17 23:29:05 -06:00
|
|
|
p.SetVerifyMode();
|
2019-06-29 03:27:53 -06:00
|
|
|
}
|
|
|
|
|
2008-08-30 10:05:32 -06:00
|
|
|
// BP Memory
|
2009-06-22 03:31:30 -06:00
|
|
|
p.Do(bpmem);
|
2012-01-01 14:52:31 -07:00
|
|
|
p.DoMarker("BP Memory");
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2008-08-30 10:05:32 -06:00
|
|
|
// CP Memory
|
2022-10-07 13:25:04 -06:00
|
|
|
// We don't save g_preprocess_cp_state separately because the GPU should be
|
|
|
|
// synced around state save/load.
|
|
|
|
p.Do(g_main_cp_state);
|
|
|
|
p.DoMarker("CP Memory");
|
|
|
|
if (p.IsReadMode())
|
|
|
|
CopyPreprocessCPStateFromMain();
|
2012-01-01 14:52:31 -07:00
|
|
|
|
|
|
|
// XF Memory
|
2015-09-29 10:35:30 -06:00
|
|
|
p.Do(xfmem);
|
2012-01-01 14:52:31 -07:00
|
|
|
p.DoMarker("XF Memory");
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2008-08-30 10:05:32 -06:00
|
|
|
// Texture decoder
|
2016-01-12 14:44:58 -07:00
|
|
|
p.DoArray(texMem);
|
2012-01-01 14:52:31 -07:00
|
|
|
p.DoMarker("texMem");
|
2009-10-10 15:19:39 -06:00
|
|
|
|
2021-10-09 20:49:59 -06:00
|
|
|
// TMEM
|
|
|
|
TMEM::DoState(p);
|
|
|
|
p.DoMarker("TMEM");
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// FIFO
|
2022-12-09 12:01:25 -07:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
system.GetFifo().DoState(p);
|
2012-01-01 14:52:31 -07:00
|
|
|
p.DoMarker("Fifo");
|
|
|
|
|
2022-11-27 05:50:50 -07:00
|
|
|
auto& command_processor = system.GetCommandProcessor();
|
|
|
|
command_processor.DoState(p);
|
2012-01-01 14:52:31 -07:00
|
|
|
p.DoMarker("CommandProcessor");
|
2012-01-01 13:46:02 -07:00
|
|
|
|
2022-12-10 08:35:07 -07:00
|
|
|
system.GetPixelEngine().DoState(p);
|
2012-01-01 14:52:31 -07:00
|
|
|
p.DoMarker("PixelEngine");
|
|
|
|
|
2012-01-01 13:46:02 -07:00
|
|
|
// the old way of replaying current bpmem as writes to push side effects to pixel shader manager
|
|
|
|
// doesn't really work.
|
2022-12-27 09:42:02 -07:00
|
|
|
system.GetPixelShaderManager().DoState(p);
|
2012-01-01 14:52:31 -07:00
|
|
|
p.DoMarker("PixelShaderManager");
|
2012-01-01 13:46:02 -07:00
|
|
|
|
2022-12-28 07:38:46 -07:00
|
|
|
system.GetVertexShaderManager().DoState(p);
|
2014-12-14 13:23:13 -07:00
|
|
|
p.DoMarker("VertexShaderManager");
|
|
|
|
|
2022-12-29 07:27:48 -07:00
|
|
|
system.GetGeometryShaderManager().DoState(p);
|
2012-01-04 01:42:22 -07:00
|
|
|
p.DoMarker("GeometryShaderManager");
|
|
|
|
|
2016-08-21 21:02:37 -06:00
|
|
|
g_vertex_manager->DoState(p);
|
2014-09-14 10:52:51 -06:00
|
|
|
p.DoMarker("VertexManager");
|
|
|
|
|
2019-06-29 05:05:30 -06:00
|
|
|
g_framebuffer_manager->DoState(p);
|
|
|
|
p.DoMarker("FramebufferManager");
|
|
|
|
|
2019-06-29 03:27:53 -06:00
|
|
|
g_texture_cache->DoState(p);
|
|
|
|
p.DoMarker("TextureCache");
|
|
|
|
|
2023-01-30 21:26:46 -07:00
|
|
|
g_presenter->DoState(p);
|
|
|
|
g_frame_dumper->DoState(p);
|
|
|
|
p.DoMarker("Presenter");
|
|
|
|
|
|
|
|
g_bounding_box->DoState(p);
|
|
|
|
p.DoMarker("Bounding Box");
|
|
|
|
|
2023-01-30 21:58:54 -07:00
|
|
|
g_widescreen->DoState(p);
|
|
|
|
p.DoMarker("Widescreen");
|
|
|
|
|
2019-06-29 03:27:53 -06:00
|
|
|
// Refresh state.
|
2022-05-17 23:29:05 -06:00
|
|
|
if (p.IsReadMode())
|
2019-06-29 03:27:53 -06:00
|
|
|
{
|
|
|
|
// Inform backend of new state from registers.
|
|
|
|
BPReload();
|
2022-10-07 13:25:04 -06:00
|
|
|
VertexLoaderManager::MarkAllDirty();
|
2019-06-29 03:27:53 -06:00
|
|
|
}
|
2008-08-30 10:05:32 -06:00
|
|
|
}
|