Skip to content

Commit

Permalink
Merge pull request dolphin-emu#10989 from CasualPokePlayer/fifo_reset…
Browse files Browse the repository at this point in the history
…_dual_core

Fix crashes in dual core mode on a PI_FIFO_RESET
  • Loading branch information
JMC47 authored Aug 18, 2022
2 parents fea552a + ab8a8e6 commit 498c06b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Source/Core/Core/HW/ProcessorInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Core/IOS/IOS.h"
#include "Core/IOS/STM/STM.h"
#include "Core/PowerPC/PowerPC.h"
#include "VideoCommon/AsyncRequests.h"
#include "VideoCommon/Fifo.h"

namespace ProcessorInterface
Expand Down Expand Up @@ -108,7 +109,19 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
if ((val & 1) != 0)
{
GPFifo::ResetGatherPipe();
Fifo::ResetVideoBuffer();

// Call Fifo::ResetVideoBuffer() from the video thread. Since that function
// resets various pointers used by the video thread, we can't call it directly
// from the CPU thread, so queue a task to do it instead. In single-core mode,
// AsyncRequests is in passthrough mode, so this will be safely and immediately
// called on the CPU thread.

// NOTE: GPFifo::ResetGatherPipe() only affects
// CPU state, so we can call it directly

AsyncRequests::Event ev = {};
ev.type = AsyncRequests::Event::FIFO_RESET;
AsyncRequests::GetInstance()->PushEvent(ev);
}
}));

Expand Down
4 changes: 4 additions & 0 deletions Source/Core/VideoCommon/AsyncRequests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ void AsyncRequests::HandleEvent(const AsyncRequests::Event& e)
*e.bbox.data = g_renderer->BBoxRead(e.bbox.index);
break;

case Event::FIFO_RESET:
Fifo::ResetVideoBuffer();
break;

case Event::PERF_QUERY:
g_perf_query->FlushResults();
break;
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/VideoCommon/AsyncRequests.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AsyncRequests
EFB_PEEK_Z,
SWAP_EVENT,
BBOX_READ,
FIFO_RESET,
PERF_QUERY,
DO_SAVE_STATE,
} type;
Expand Down Expand Up @@ -62,6 +63,10 @@ class AsyncRequests
u16* data;
} bbox;

struct
{
} fifo_reset;

struct
{
} perf_query;
Expand Down

0 comments on commit 498c06b

Please sign in to comment.