Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile the ARAM DMA exception checks into the JIT block #1012

Merged
merged 6 commits into from Sep 28, 2014

Conversation

@skidau
Copy link
Contributor

@skidau skidau commented Sep 7, 2014

Compile the ARAM DMA exception checks into the JIT block in a similar style to FIFO writes. This ensures that the ARAM DMA is handled soon after the DMA completes. Fixes issue 7122 and issue 7342.

UPDATE: To keep Resident Evil 2 and 3 from cutting in and out, added a exception check. Also, removed the special case for short ARAM DMA transfers as that is no longer required.

@JMC47
Copy link
Contributor

@JMC47 JMC47 commented Sep 7, 2014

I can confirm this as fixing the music in Burnout 2 in JIT and Interpreter. JITIL just crashes as soon as the game starts up, so, whatever.

No known regressions that I can find in any of my other games.

if (jit && PC != 0 && (jit->js.dspARAMAddresses.find(PC)) == (jit->js.dspARAMAddresses.end()) && (g_dspState.DSPControl.ARAM & g_dspState.DSPControl.ARAM_mask))
{
int type = GetOpInfo(Memory::ReadUnchecked_U32(PC))->type;
if (type == OPTYPE_STORE || type == OPTYPE_STOREFP || (type == OPTYPE_PS && GetOpInfo(Memory::ReadUnchecked_U32(PC))->opname == "psq_st"))

This comment has been minimized.

@delroth

delroth Sep 7, 2014
Member

Can you add an OPTYPE_STOREPS?

CoreTiming::ScheduleEvent_Threadsafe(0, et_CompleteARAM);

// Force an early exception check on large transfers. Fixes RE2 audio.
CoreTiming::ForceExceptionCheck(250);

This comment has been minimized.

@delroth

delroth Sep 7, 2014
Member

Why 250?

@skidau
Copy link
Contributor Author

@skidau skidau commented Sep 7, 2014

Have actioned the review comments.


if ((g_dspState.DSPControl.Hex >> 1) & g_dspState.DSPControl.Hex & (INT_DSP | INT_ARAM | INT_AID))
{
if (jit && PC != 0 && (jit->js.dspARAMAddresses.find(PC)) == (jit->js.dspARAMAddresses.end()) && (g_dspState.DSPControl.ARAM & g_dspState.DSPControl.ARAM_mask))

This comment has been minimized.

@Sonicadvance1

Sonicadvance1 Sep 7, 2014
Contributor

Stop the raw jit object usage, pass it through the JitInterface instead.
The interface even has the InvalidateICache function...

@skidau skidau force-pushed the skidau:aram-dma-exceptions branch from 54d1c39 to 8e80161 Sep 7, 2014
@skidau
Copy link
Contributor Author

@skidau skidau commented Sep 7, 2014

@Sonicadvance1 I have replaced the jit usage with JitInterface in the update.

@skidau skidau force-pushed the skidau:aram-dma-exceptions branch from 8e80161 to 92bccb6 Sep 7, 2014
ERROR_LOG(POWERPC, "Unknown exception check type");
}

if (PC != 0 && (exception_addresses->find(PC)) == (exception_addresses->end()))

This comment has been minimized.

@Sonicadvance1

Sonicadvance1 Sep 7, 2014
Contributor

Is PC known to be in a sane state at this point?

This comment has been minimized.

@skidau

skidau Sep 7, 2014
Author Contributor

Yes, PC is definitely in a sane state when this function is called. If you want, I can add a IsCPUThread check here (might cause a little performance drop). Let me know.

@JMC47
Copy link
Contributor

@JMC47 JMC47 commented Sep 15, 2014

Any more comments or blocking issues for this?

@@ -544,7 +544,8 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
}

// Add an external exception check if the instruction writes to the FIFO.
if (jit->js.fifoWriteAddresses.find(ops[i].address) != jit->js.fifoWriteAddresses.end())
if (jit->js.fifoWriteAddresses.find(ops[i].address) != jit->js.fifoWriteAddresses.end() ||
jit->js.dspARAMAddresses.find(ops[i].address) != jit->js.dspARAMAddresses.end())

This comment has been minimized.

@FioraAeterna

FioraAeterna Sep 15, 2014
Contributor

What happens if both exceptions happen at the same time; is that an issue?

This comment has been minimized.

@skidau

skidau Sep 16, 2014
Author Contributor

A MMIO write will either be writing to a CP (FIFO) MMIO or a DSP (ARAM) MMIO, so this will not be an issue.

@skidau
Copy link
Contributor Author

@skidau skidau commented Sep 16, 2014

Still running some tests on this code.

@Parlane
Copy link
Member

@Parlane Parlane commented Sep 16, 2014

What happened to IRC @skidau ?

@skidau
Copy link
Contributor Author

@skidau skidau commented Sep 16, 2014

overlord connects but is silent since Saturday morning @delroth

@Parlane
Copy link
Member

@Parlane Parlane commented Sep 16, 2014

@skidau your bnc is gone. Need to find another. Or connect directly.

skidau added 4 commits Sep 6, 2014
… style to FIFO writes. This ensures that the ARAM DMA is handled soon after the DMA completes. Fixes issue 7122 and issue 7342.
…n and out of Resident Evil 2 and 3. Removed the special case for short transfers as it is no longer required.
…able.

Updated ARAM DMA and FIFO write exception checking to uses these types.

Conflicts:
	Source/Core/Core/PowerPC/Interpreter/Interpreter_Tables.cpp
	Source/Core/Core/PowerPC/PPCTables.h
…ted the existing code to utilise the interface.
@skidau skidau force-pushed the skidau:aram-dma-exceptions branch from 92bccb6 to c83987a Sep 27, 2014
…uired.

Detects a situation where the game is writing to the dcache at the address being DMA'd. As we do not have dcache emulation, invalid data is being DMA'd causing audio glitches. The following code detects this and enables the DMA to complete instantly before the invalid data is written.
Added accurate ARAM DMA transfer timing.
Removed the addition of DSP exception checking.
@skidau skidau force-pushed the skidau:aram-dma-exceptions branch from c83987a to 86b6dfe Sep 27, 2014
Added a small note for instant dma.
skidau added a commit that referenced this pull request Sep 28, 2014
Compile the ARAM DMA exception checks into the JIT block
@skidau skidau merged commit afccf22 into dolphin-emu:master Sep 28, 2014
1 check was pending
1 check was pending
@dolphin-emu-bot
default Auto build in progress
Details
CoreTiming::ScheduleEvent_Threadsafe(ticksToTransfer, et_CompleteARAM);

if (instant_dma)
CoreTiming::ForceExceptionCheck(100);

This comment has been minimized.

@phire

phire Apr 9, 2016
Member

Why 100?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants