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

SPU LLVM: LS Memory Mirrors (Optimize loads/stores) #8592

Merged
merged 1 commit into from Jul 17, 2020

Conversation

elad335
Copy link
Contributor

@elad335 elad335 commented Jul 15, 2020

By allowing the SPU Local Storage to wrap around on addressing overflows around 256k+- offsets stores/loads are allowed to not mask the immediate value after the calculating the sum of addresses.
This makes it use a native, single x86 memory address calculation instruction (e.g. as a LEA instruction) instead of separating it into different instructions and masking it everytime.

An example for a start of a function which stores a few registers one after one for registers savings to stack from GOW3:
Before:
https://user-images.githubusercontent.com/18193363/87683427-be936880-c789-11ea-9f88-a94ffd2c7138.png
After:
https://cdn.discordapp.com/attachments/485204327800242177/733052633950191626/unknown.png

Notice how ($SP) is masked with 0x3fff0 only once and there are no additional LEA instructions using the new code.

Misc: Also fixes MFC transfers which went of bounds of Local Storage, making them wrap around.

@elad335 elad335 force-pushed the spu-mask branch 4 times, most recently from baeb7c3 to 4a64d18 Compare July 15, 2020 20:02
@elad335 elad335 force-pushed the spu-mask branch 9 times, most recently from 8f5c443 to 8571e09 Compare July 16, 2020 06:09
@elad335
Copy link
Contributor Author

elad335 commented Jul 16, 2020

Someone wants to perf test?

@alexloxldlol
Copy link

Master
image

Build

image

same performance

@Satan86
Copy link

Satan86 commented Jul 16, 2020

no performance difference on TLOU either

@elad335 elad335 force-pushed the spu-mask branch 2 times, most recently from a0a37da to a7e102c Compare July 16, 2020 20:00
@nitroos-ai
Copy link

Breaks compatibility with Uncharted Drake's Fortune, make the emulator crash with error ·F 0:00:29.917134 {PPU[0x1000000] Thread (main_thread) [0x014a7d80]} SIG: Thread terminated due to fatal error: Verification failed (e=17): (in file ../rpcs3/Emu/Cell/SPUThread.cpp:1190)
RPCS3.log.gz

@Basmurd
Copy link

Basmurd commented Jul 18, 2020

Breaks compatibility with Uncharted Drake's Fortune, make the emulator crash with error ·F 0:00:29.917134 {PPU[0x1000000] Thread (main_thread) [0x014a7d80]} SIG: Thread terminated due to fatal error: Verification failed (e=17): (in file ../rpcs3/Emu/Cell/SPUThread.cpp:1190)
RPCS3.log.gz

Still ingame with no error
image

@nitroos-ai
Copy link

I tried it in windows 10 and it worked fine but tried the emulator with two games in Ubuntu 20.04 and the emulator crashed in both. I will try later with Ubuntu 20.04 live usb.

@paoros1
Copy link

paoros1 commented Jul 18, 2020

I tried under windows 10 and it’s became unstable a lot of crash while loading game or playing with it.

@elad335
Copy link
Contributor Author

elad335 commented Jul 18, 2020

Fixed Linux issue in #8598

@elad335
Copy link
Contributor Author

elad335 commented Jul 18, 2020

I've succedded to repro Windows issue consistently using these added changes in spu_thread constructor:

-		const auto addr = static_cast<u8*>(utils::memory_reserve(SPU_LS_SIZE * 3));
+		auto addr0 = static_cast<u8*>(utils::memory_reserve(SPU_LS_SIZE * 3));
+		auto addr = static_cast<u8*>(utils::memory_reserve(SPU_LS_SIZE * 3));
+
+		while (addr0 + SPU_LS_SIZE * 3 != addr)
+		{
+			utils::memory_release(addr0, SPU_LS_SIZE * 3),utils::memory_release(addr, SPU_LS_SIZE * 3);
+			addr0 = static_cast<u8*>(utils::memory_reserve(SPU_LS_SIZE * 3));
+			addr = static_cast<u8*>(utils::memory_reserve(SPU_LS_SIZE * 3));
+		}

utils::shm::unmap_critical seems to be the cause for the bug, as it can release(amend) memory not within the target memory reservation, causing the assertation in utils::memory_release to trigger as it cant release memory not of the start of the base.

@VVSRevolution
Copy link

error
When you choose a game in KH 2.5 there is a crash and that is the error message. v0.0.11-10664 works

@elad335
Copy link
Contributor Author

elad335 commented Jul 19, 2020

For all crashes use #8598

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

Successfully merging this pull request may close these issues.

None yet

9 participants