2015-05-24 07:55:12 +03:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 04:22:19 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-08 07:30:24 +02:00
|
|
|
|
2021-12-10 04:22:16 +02:00
|
|
|
#include "VideoCommon/VideoState.h"
|
|
|
|
|
2016-01-17 23:54:31 +02:00
|
|
|
#include <cstring>
|
|
|
|
|
2014-07-30 03:55:07 +03:00
|
|
|
#include "Common/ChunkFile.h"
|
2022-11-27 14:50:50 +02:00
|
|
|
#include "Core/System.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "VideoCommon/BPMemory.h"
|
2023-01-28 04:13:49 +02:00
|
|
|
#include "VideoCommon/BPStructs.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "VideoCommon/CPMemory.h"
|
2014-12-14 22:23:13 +02:00
|
|
|
#include "VideoCommon/CommandProcessor.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "VideoCommon/Fifo.h"
|
2019-06-29 14:05:30 +03:00
|
|
|
#include "VideoCommon/FramebufferManager.h"
|
2014-12-14 22:23:13 +02:00
|
|
|
#include "VideoCommon/GeometryShaderManager.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "VideoCommon/PixelEngine.h"
|
|
|
|
#include "VideoCommon/PixelShaderManager.h"
|
2019-06-29 12:27:53 +03:00
|
|
|
#include "VideoCommon/RenderBase.h"
|
2021-10-10 05:49:59 +03:00
|
|
|
#include "VideoCommon/TMEM.h"
|
2019-06-29 12:27:53 +03:00
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "VideoCommon/TextureDecoder.h"
|
2022-10-07 22:25:04 +03:00
|
|
|
#include "VideoCommon/VertexLoaderManager.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "VideoCommon/VertexManagerBase.h"
|
|
|
|
#include "VideoCommon/VertexShaderManager.h"
|
2014-02-19 03:27:20 +02:00
|
|
|
#include "VideoCommon/XFMemory.h"
|
2008-12-08 07:30:24 +02:00
|
|
|
|
2016-01-12 23:46:44 +02:00
|
|
|
void VideoCommon_DoState(PointerWrap& p)
|
2008-10-25 18:53:43 +03:00
|
|
|
{
|
2019-06-29 12:27:53 +03:00
|
|
|
bool software = false;
|
|
|
|
p.Do(software);
|
|
|
|
|
2022-05-18 08:29:05 +03:00
|
|
|
if (p.IsReadMode() && software == true)
|
2019-06-29 12:27:53 +03:00
|
|
|
{
|
|
|
|
// change mode to abort load of incompatible save state.
|
2022-05-18 08:29:05 +03:00
|
|
|
p.SetVerifyMode();
|
2019-06-29 12:27:53 +03:00
|
|
|
}
|
|
|
|
|
2008-08-30 19:05:32 +03:00
|
|
|
// BP Memory
|
2009-06-22 12:31:30 +03:00
|
|
|
p.Do(bpmem);
|
2012-01-01 23:52:31 +02:00
|
|
|
p.DoMarker("BP Memory");
|
2008-12-08 07:30:24 +02:00
|
|
|
|
2008-08-30 19:05:32 +03:00
|
|
|
// CP Memory
|
2022-10-07 22:25:04 +03: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 23:52:31 +02:00
|
|
|
|
|
|
|
// XF Memory
|
2015-09-29 19:35:30 +03:00
|
|
|
p.Do(xfmem);
|
2012-01-01 23:52:31 +02:00
|
|
|
p.DoMarker("XF Memory");
|
2013-10-29 07:23:17 +02:00
|
|
|
|
2008-08-30 19:05:32 +03:00
|
|
|
// Texture decoder
|
2016-01-12 23:44:58 +02:00
|
|
|
p.DoArray(texMem);
|
2012-01-01 23:52:31 +02:00
|
|
|
p.DoMarker("texMem");
|
2009-10-11 00:19:39 +03:00
|
|
|
|
2021-10-10 05:49:59 +03:00
|
|
|
// TMEM
|
|
|
|
TMEM::DoState(p);
|
|
|
|
p.DoMarker("TMEM");
|
|
|
|
|
2016-06-24 11:43:46 +03:00
|
|
|
// FIFO
|
2022-12-09 21:01:25 +02:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
system.GetFifo().DoState(p);
|
2012-01-01 23:52:31 +02:00
|
|
|
p.DoMarker("Fifo");
|
|
|
|
|
2022-11-27 14:50:50 +02:00
|
|
|
auto& command_processor = system.GetCommandProcessor();
|
|
|
|
command_processor.DoState(p);
|
2012-01-01 23:52:31 +02:00
|
|
|
p.DoMarker("CommandProcessor");
|
2012-01-01 22:46:02 +02:00
|
|
|
|
2022-12-10 17:35:07 +02:00
|
|
|
system.GetPixelEngine().DoState(p);
|
2012-01-01 23:52:31 +02:00
|
|
|
p.DoMarker("PixelEngine");
|
|
|
|
|
2012-01-01 22:46:02 +02: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 18:42:02 +02:00
|
|
|
system.GetPixelShaderManager().DoState(p);
|
2012-01-01 23:52:31 +02:00
|
|
|
p.DoMarker("PixelShaderManager");
|
2012-01-01 22:46:02 +02:00
|
|
|
|
2022-12-28 16:38:46 +02:00
|
|
|
system.GetVertexShaderManager().DoState(p);
|
2014-12-14 22:23:13 +02:00
|
|
|
p.DoMarker("VertexShaderManager");
|
|
|
|
|
2022-12-29 16:27:48 +02:00
|
|
|
system.GetGeometryShaderManager().DoState(p);
|
2012-01-04 10:42:22 +02:00
|
|
|
p.DoMarker("GeometryShaderManager");
|
|
|
|
|
2016-08-22 06:02:37 +03:00
|
|
|
g_vertex_manager->DoState(p);
|
2014-09-14 19:52:51 +03:00
|
|
|
p.DoMarker("VertexManager");
|
|
|
|
|
2019-06-29 14:05:30 +03:00
|
|
|
g_framebuffer_manager->DoState(p);
|
|
|
|
p.DoMarker("FramebufferManager");
|
|
|
|
|
2019-06-29 12:27:53 +03:00
|
|
|
g_texture_cache->DoState(p);
|
|
|
|
p.DoMarker("TextureCache");
|
|
|
|
|
|
|
|
g_renderer->DoState(p);
|
|
|
|
p.DoMarker("Renderer");
|
|
|
|
|
|
|
|
// Refresh state.
|
2022-05-18 08:29:05 +03:00
|
|
|
if (p.IsReadMode())
|
2019-06-29 12:27:53 +03:00
|
|
|
{
|
|
|
|
// Inform backend of new state from registers.
|
|
|
|
BPReload();
|
2022-10-07 22:25:04 +03:00
|
|
|
VertexLoaderManager::MarkAllDirty();
|
2019-06-29 12:27:53 +03:00
|
|
|
}
|
2008-08-30 19:05:32 +03:00
|
|
|
}
|