Skip to content

Commit

Permalink
revert SafeCPReadPointer
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuoya committed Jan 11, 2019
1 parent eaa9aa0 commit a4a4f06
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
66 changes: 43 additions & 23 deletions Source/Core/VideoCommon/CommandProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ void SCPFifoStruct::DoState(PointerWrap& p)
p.Do(CPWritePointer);
p.Do(CPReadPointer);
p.Do(CPBreakpoint);

// keep compatible
u32 SafeCPReadPointer = 0;
p.Do(SafeCPReadPointer);

p.Do(bFF_GPLinkEnable);
Expand Down Expand Up @@ -255,33 +252,56 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)

// Some MMIOs have different handlers for single core vs. dual core mode.
mmio->Register(base | FIFO_RW_DISTANCE_LO,
IsOnThread() ?
MMIO::ComplexRead<u16>([](u32) {
if (fifo.CPWritePointer >= fifo.SafeCPReadPointer)
return ReadLow(fifo.CPWritePointer - fifo.SafeCPReadPointer);
else
return ReadLow(fifo.CPEnd - fifo.SafeCPReadPointer + fifo.CPWritePointer -
fifo.CPBase + 32);
}) :
MMIO::DirectRead<u16>(MMIO::Utils::LowPart(&fifo.CPReadWriteDistance)),
MMIO::DirectWrite<u16>(MMIO::Utils::LowPart(&fifo.CPReadWriteDistance),
WMASK_LO_ALIGN_32BIT));
mmio->Register(base | FIFO_RW_DISTANCE_HI,
IsOnThread() ?
MMIO::ComplexRead<u16>([](u32) {
if (fifo.CPWritePointer >= fifo.SafeCPReadPointer)
return ReadHigh(fifo.CPWritePointer - fifo.SafeCPReadPointer);
else
return ReadHigh(fifo.CPEnd - fifo.SafeCPReadPointer + fifo.CPWritePointer -
fifo.CPBase + 32);
}) :
MMIO::DirectRead<u16>(MMIO::Utils::HighPart(&fifo.CPReadWriteDistance)),
MMIO::ComplexWrite<u16>([WMASK_HI_RESTRICT](u32, u16 val) {
WriteHigh(fifo.CPReadWriteDistance, val & WMASK_HI_RESTRICT);
Fifo::SyncGPU(Fifo::SyncGPUReason::Other);
if (fifo.CPReadWriteDistance == 0)
{
GPFifo::ResetGatherPipe();
Fifo::ResetVideoBuffer();
}
else
{
Fifo::ResetVideoBuffer();
}
Fifo::RunGpu();
WriteHigh(fifo.CPReadWriteDistance, val & WMASK_HI_RESTRICT);
Fifo::SyncGPU(Fifo::SyncGPUReason::Other);
if (fifo.CPReadWriteDistance == 0)
{
GPFifo::ResetGatherPipe();
Fifo::ResetVideoBuffer();
}
else
{
Fifo::ResetVideoBuffer();
}
Fifo::RunGpu();
}));
mmio->Register(base | FIFO_READ_POINTER_LO,
MMIO::DirectRead<u16>(MMIO::Utils::LowPart(&fifo.CPReadPointer)),
MMIO::DirectWrite<u16>(MMIO::Utils::LowPart(&fifo.CPReadPointer),
WMASK_LO_ALIGN_32BIT));
mmio->Register(base | FIFO_READ_POINTER_HI,
MMIO::DirectRead<u16>(MMIO::Utils::HighPart(&fifo.CPReadPointer)),
MMIO::DirectWrite<u16>(MMIO::Utils::HighPart(&fifo.CPReadPointer),
WMASK_HI_RESTRICT));
mmio->Register(
base | FIFO_READ_POINTER_LO,
IsOnThread() ? MMIO::DirectRead<u16>(MMIO::Utils::LowPart(&fifo.SafeCPReadPointer)) :
MMIO::DirectRead<u16>(MMIO::Utils::LowPart(&fifo.CPReadPointer)),
MMIO::DirectWrite<u16>(MMIO::Utils::LowPart(&fifo.CPReadPointer), WMASK_LO_ALIGN_32BIT));
mmio->Register(
base | FIFO_READ_POINTER_HI,
IsOnThread() ? MMIO::DirectRead<u16>(MMIO::Utils::HighPart(&fifo.SafeCPReadPointer)) :
MMIO::DirectRead<u16>(MMIO::Utils::HighPart(&fifo.CPReadPointer)),
IsOnThread() ?
MMIO::ComplexWrite<u16>([WMASK_HI_RESTRICT](u32, u16 val) {
WriteHigh(fifo.CPReadPointer, val & WMASK_HI_RESTRICT);
fifo.SafeCPReadPointer = fifo.CPReadPointer;
}) :
MMIO::DirectWrite<u16>(MMIO::Utils::HighPart(&fifo.CPReadPointer), WMASK_HI_RESTRICT));
}

void GatherPipeBursted()
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/CommandProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct SCPFifoStruct
volatile u32 CPWritePointer;
volatile u32 CPReadPointer;
volatile u32 CPBreakpoint;
volatile u32 SafeCPReadPointer;

volatile u32 bFF_GPLinkEnable;
volatile u32 bFF_GPReadEnable;
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/VideoCommon/Fifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ void RunGpuLoop()
s_video_buffer_read_ptr = OpcodeDecoder::Run(
DataReader(s_video_buffer_read_ptr, write_ptr), &cyclesExecuted, false, &needSize);

if ((write_ptr - s_video_buffer_read_ptr) == 0)
Common::AtomicStore(fifo.SafeCPReadPointer, fifo.CPReadPointer);

if (param.bSyncGPU)
{
cyclesExecuted = (u32)(cyclesExecuted / param.fSyncGpuOverclock);
Expand Down

2 comments on commit a4a4f06

@dhanial
Copy link

@dhanial dhanial commented on a4a4f06 Jan 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to latest vrsion of dolphin mmj, the language has not in english

@weihuoya
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to latest vrsion of dolphin mmj, the language has not in english

Thx, upload a new build.

Please sign in to comment.