| 1 | // Copyright 2008 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "VideoCommon/VideoState.h" |
| 5 | |
| 6 | #include "Common/ChunkFile.h" |
| 7 | #include "Core/System.h" |
| 8 | #include "VideoCommon/BPMemory.h" |
| 9 | #include "VideoCommon/BPStructs.h" |
| 10 | #include "VideoCommon/BoundingBox.h" |
| 11 | #include "VideoCommon/CPMemory.h" |
| 12 | #include "VideoCommon/CommandProcessor.h" |
| 13 | #include "VideoCommon/Fifo.h" |
| 14 | #include "VideoCommon/FrameDumper.h" |
| 15 | #include "VideoCommon/FramebufferManager.h" |
| 16 | #include "VideoCommon/GeometryShaderManager.h" |
| 17 | #include "VideoCommon/PixelEngine.h" |
| 18 | #include "VideoCommon/PixelShaderManager.h" |
| 19 | #include "VideoCommon/Present.h" |
| 20 | #include "VideoCommon/TMEM.h" |
| 21 | #include "VideoCommon/TextureCacheBase.h" |
| 22 | #include "VideoCommon/TextureDecoder.h" |
| 23 | #include "VideoCommon/VertexLoaderManager.h" |
| 24 | #include "VideoCommon/VertexManagerBase.h" |
| 25 | #include "VideoCommon/VertexShaderManager.h" |
| 26 | #include "VideoCommon/Widescreen.h" |
| 27 | #include "VideoCommon/XFMemory.h" |
| 28 | #include "VideoCommon/XFStateManager.h" |
| 29 | |
| 30 | void VideoCommon_DoState(PointerWrap& p) |
| 31 | { |
| 32 | bool software = false; |
| 33 | p.Do(software); |
| 34 | |
| 35 | if (p.IsReadMode() && software == true) |
| 36 | { |
| 37 | // change mode to abort load of incompatible save state. |
| 38 | p.SetVerifyMode(); |
| 39 | } |
| 40 | |
| 41 | // BP Memory |
| 42 | p.Do(bpmem); |
| 43 | p.DoMarker("BP Memory"); |
| 44 | |
| 45 | // CP Memory |
| 46 | // We don't save g_preprocess_cp_state separately because the GPU should be |
| 47 | // synced around state save/load. |
| 48 | p.Do(g_main_cp_state); |
| 49 | p.DoMarker("CP Memory"); |
| 50 | if (p.IsReadMode()) |
| 51 | CopyPreprocessCPStateFromMain(); |
| 52 | |
| 53 | // XF Memory |
| 54 | p.Do(xfmem); |
| 55 | p.DoMarker("XF Memory"); |
| 56 | |
| 57 | // Texture decoder |
| 58 | p.DoArray(s_tex_mem); |
| 59 | p.DoMarker("texMem"); |
| 60 | |
| 61 | // TMEM |
| 62 | TMEM::DoState(p); |
| 63 | p.DoMarker("TMEM"); |
| 64 | |
| 65 | // FIFO |
| 66 | auto& system = Core::System::GetInstance(); |
| 67 | system.GetFifo().DoState(p); |
| 68 | p.DoMarker("Fifo"); |
| 69 | |
| 70 | auto& command_processor = system.GetCommandProcessor(); |
| 71 | command_processor.DoState(p); |
| 72 | p.DoMarker("CommandProcessor"); |
| 73 | |
| 74 | system.GetPixelEngine().DoState(p); |
| 75 | p.DoMarker("PixelEngine"); |
| 76 | |
| 77 | // the old way of replaying current bpmem as writes to push side effects to pixel shader manager |
| 78 | // doesn't really work. |
| 79 | system.GetPixelShaderManager().DoState(p); |
| 80 | p.DoMarker("PixelShaderManager"); |
| 81 | |
| 82 | system.GetVertexShaderManager().DoState(p); |
| 83 | p.DoMarker("VertexShaderManager"); |
| 84 | |
| 85 | system.GetGeometryShaderManager().DoState(p); |
| 86 | p.DoMarker("GeometryShaderManager"); |
| 87 | |
| 88 | g_vertex_manager->DoState(p); |
| 89 | p.DoMarker("VertexManager"); |
| 90 | |
| 91 | g_framebuffer_manager->DoState(p); |
| 92 | p.DoMarker("FramebufferManager"); |
| 93 | |
| 94 | g_texture_cache->DoState(p); |
| 95 | p.DoMarker("TextureCache"); |
| 96 | |
| 97 | g_presenter->DoState(p); |
| 98 | g_frame_dumper->DoState(p); |
| 99 | p.DoMarker("Presenter"); |
| 100 | |
| 101 | g_bounding_box->DoState(p); |
| 102 | p.DoMarker("Bounding Box"); |
| 103 | |
| 104 | g_widescreen->DoState(p); |
| 105 | p.DoMarker("Widescreen"); |
| 106 | |
| 107 | system.GetXFStateManager().DoState(p); |
| 108 | p.DoMarker("XFStateManager"); |
| 109 | |
| 110 | // Refresh state. |
| 111 | if (p.IsReadMode()) |
| 112 | { |
| 113 | // Inform backend of new state from registers. |
| 114 | BPReload(); |
| 115 | VertexLoaderManager::MarkAllDirty(); |
| 116 | } |
| 117 | } |