mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 06:25:37 +00:00
System: Invalidate instead of flushing code cache on memory state
This commit is contained in:
parent
c440593788
commit
4513c7a23d
|
@ -75,7 +75,7 @@ static bool ReadExecutableFromImage(ISOReader& iso, std::string* out_executable_
|
||||||
static bool ShouldCheckForImagePatches();
|
static bool ShouldCheckForImagePatches();
|
||||||
|
|
||||||
static bool DoLoadState(ByteStream* stream, bool force_software_renderer, bool update_display);
|
static bool DoLoadState(ByteStream* stream, bool force_software_renderer, bool update_display);
|
||||||
static bool DoState(StateWrapper& sw, HostDisplayTexture** host_texture, bool update_display);
|
static bool DoState(StateWrapper& sw, HostDisplayTexture** host_texture, bool update_display, bool is_memory_state);
|
||||||
static void DoRunFrame();
|
static void DoRunFrame();
|
||||||
static bool CreateGPU(GPURenderer renderer);
|
static bool CreateGPU(GPURenderer renderer);
|
||||||
|
|
||||||
|
@ -1056,10 +1056,8 @@ bool CreateGPU(GPURenderer renderer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DoState(StateWrapper& sw, HostDisplayTexture** host_texture, bool update_display)
|
bool DoState(StateWrapper& sw, HostDisplayTexture** host_texture, bool update_display, bool is_memory_state)
|
||||||
{
|
{
|
||||||
const bool is_memory_state = (host_texture != nullptr);
|
|
||||||
|
|
||||||
if (!sw.DoMarker("System"))
|
if (!sw.DoMarker("System"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1071,7 +1069,12 @@ bool DoState(StateWrapper& sw, HostDisplayTexture** host_texture, bool update_di
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (sw.IsReading())
|
if (sw.IsReading())
|
||||||
CPU::CodeCache::Flush();
|
{
|
||||||
|
if (is_memory_state)
|
||||||
|
CPU::CodeCache::InvalidateAll();
|
||||||
|
else
|
||||||
|
CPU::CodeCache::Flush();
|
||||||
|
}
|
||||||
|
|
||||||
// only reset pgxp if we're not runahead-rollbacking. the value checks will save us from broken rendering, and it
|
// only reset pgxp if we're not runahead-rollbacking. the value checks will save us from broken rendering, and it
|
||||||
// saves using imprecise values for a frame in 30fps games.
|
// saves using imprecise values for a frame in 30fps games.
|
||||||
|
@ -1309,7 +1312,7 @@ bool DoLoadState(ByteStream* state, bool force_software_renderer, bool update_di
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
StateWrapper sw(state, StateWrapper::Mode::Read, header.version);
|
StateWrapper sw(state, StateWrapper::Mode::Read, header.version);
|
||||||
if (!DoState(sw, nullptr, update_display))
|
if (!DoState(sw, nullptr, update_display, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (s_state == State::Starting)
|
if (s_state == State::Starting)
|
||||||
|
@ -1398,7 +1401,7 @@ bool SaveState(ByteStream* state, u32 screenshot_size /* = 256 */)
|
||||||
g_gpu->RestoreGraphicsAPIState();
|
g_gpu->RestoreGraphicsAPIState();
|
||||||
|
|
||||||
StateWrapper sw(state, StateWrapper::Mode::Write, SAVE_STATE_VERSION);
|
StateWrapper sw(state, StateWrapper::Mode::Write, SAVE_STATE_VERSION);
|
||||||
const bool result = DoState(sw, nullptr, false);
|
const bool result = DoState(sw, nullptr, false, false);
|
||||||
|
|
||||||
g_gpu->ResetGraphicsAPIState();
|
g_gpu->ResetGraphicsAPIState();
|
||||||
|
|
||||||
|
@ -2307,7 +2310,7 @@ bool LoadMemoryState(const MemorySaveState& mss)
|
||||||
|
|
||||||
StateWrapper sw(mss.state_stream.get(), StateWrapper::Mode::Read, SAVE_STATE_VERSION);
|
StateWrapper sw(mss.state_stream.get(), StateWrapper::Mode::Read, SAVE_STATE_VERSION);
|
||||||
HostDisplayTexture* host_texture = mss.vram_texture.get();
|
HostDisplayTexture* host_texture = mss.vram_texture.get();
|
||||||
if (!DoState(sw, &host_texture, true))
|
if (!DoState(sw, &host_texture, true, true))
|
||||||
{
|
{
|
||||||
g_host_interface->ReportError("Failed to load memory save state, resetting.");
|
g_host_interface->ReportError("Failed to load memory save state, resetting.");
|
||||||
Reset();
|
Reset();
|
||||||
|
@ -2326,7 +2329,7 @@ bool SaveMemoryState(MemorySaveState* mss)
|
||||||
|
|
||||||
HostDisplayTexture* host_texture = mss->vram_texture.release();
|
HostDisplayTexture* host_texture = mss->vram_texture.release();
|
||||||
StateWrapper sw(mss->state_stream.get(), StateWrapper::Mode::Write, SAVE_STATE_VERSION);
|
StateWrapper sw(mss->state_stream.get(), StateWrapper::Mode::Write, SAVE_STATE_VERSION);
|
||||||
if (!DoState(sw, &host_texture, false))
|
if (!DoState(sw, &host_texture, false, true))
|
||||||
{
|
{
|
||||||
Log_ErrorPrint("Failed to create rewind state.");
|
Log_ErrorPrint("Failed to create rewind state.");
|
||||||
delete host_texture;
|
delete host_texture;
|
||||||
|
|
Loading…
Reference in a new issue