hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
10.98k stars 2.14k forks source link

PPSSPP and Windows 10 (Phone) #7854

Closed gamelaster closed 7 years ago

gamelaster commented 9 years ago

Hey,

I know, its has been more times before me asked.. But, now, Windows 10 coming.. Is still not possible to port PPSSPP for Windows 10 or Windows Runtime (cross..)??? I though by come of Runtime or W10 is must be allowed to use JIT.. :-)

Is possible to port that?

Thanks :-)

unknownbrackets commented 9 years ago

AFAIK, this is still "desktop apps only": https://msdn.microsoft.com/en-us/library/windows/desktop/aa366898%28v=vs.85%29.aspx

I read about them porting Node.js to use Chakra to take advantage of jit on Windows 10, which implies that v8 still won't work due to the lack of the necessary functions.

Is there any documentation indicating exactly how native ARM code can be written to, and executed from, memory on a device at runtime?

-[Unknown]

gamelaster commented 9 years ago

https://wpdev.uservoice.com/forums/253374-missing-platform-apis/suggestions/5963532-virtualalloc-virtualfree-virtualprotect-etc

"VirtualAlloc and related APIs are available in Windows 10 Universal apps. Creating executable memory requires a capability, but there are no restrictions on who can get that capability."

When it is available in Windows 10 UNIVERSAL apps, then its must go at Windows 10 mobile (windows phone). Actually, i can look that, cause i running under Windows 10 and my WP too, i just need install a Visual Studio 2015, but maybe i wait to final version, i dont want RC :-D

And some other sources about its in Windows 10: http://forums.windowscentral.com/microsoft-news-rumors/223858-gaining-access-full-windows-apis-virtualprotect-metro-apps.html#post_3078907

gamelaster commented 9 years ago

img_08072015_141048 A screen from Visual Studio 2015 Universal App. Yes, i know its in a C#, but anyway, the DllImport works, so its maybe it will be functionaly. (Friend taked a screenshot and he dont want to try it at C++ :D )

Bigpet commented 9 years ago

@GAMELASTER try it on the Windows 10 Mobile simulator or on an actual phone.

hrydgard commented 9 years ago

What Peter Torr says there seems a little hopeful, at least. Should be looked into at some point..

gamelaster commented 9 years ago

Bigpet: i must install our Visual Studio 2015 for debbuging, so its take some time. I will test it on phone ^^.

gamelaster commented 9 years ago

Well, i got funny results... Universal C# App (Windows 10 desktop): Couse of wrong installed Visual Studio 2015 i cannot run a app :D Buut! I see the application has been installed! And its workz... (app dont crash) Soo its working :D Universal C# App (Windows 10 Mobile): Well, this is good, deployed to my phone, but actually the system32.dll is not in ARM version haha :D well i go test a systemarm.dll :D (i maybe can found a good library for hook, i will see) 2015-07-08_17-02-15 Universal C++ App (Windows 10 Mobile): 2015-07-08_17-04-33 Well, here is unsuccessful build, but definitions exists, so its will be already just broken.. Need take time maybe :-) Universal C++ App (Windows 10 Desktop): 2015-07-08_17-06-36 Here is same trouble..

gamelaster commented 9 years ago

Well, after linking a system32.lib (its interesting its not linked by default) i successfuly runned a Windows 10 Universal C++ App with VirtualAlloc function with any crash so its working.

About a phone, application successfully builds, deploys into a device, but application crash. Maybe system32.lib (or .dll) dont exists on Windows Phone, but i didnt already found any replacement, so next waiting..

weltkante commented 8 years ago

Happened to come across this issue while searching google for the status of JITs on Windows 10 ... so I'll leave my findings in case it's useful to you.

VirtualAllocFromApp and VirtualProtectFromApp say there is a "codeGeneration" capability which must be set for the app. In this video they say (around minute 17:50) that creating executable code pages is now allowed for store apps but its not clear if that also applies for windows phone.

So maybe it would "just work" if that capability is set for the process; the question is if this capability is allowed on phones.

hrydgard commented 8 years ago

@weltkante It sounds like it should work, but it's really very poorly documented. Last I looked I couldn't even find how to request the required capability.

But yes, this is probably our best hope of getting the JIT running on WinPhone.

weltkante commented 8 years ago

I assume they mean the capabilities listed in the appxmanifest file.

gamelaster commented 8 years ago

Well, some time ago i writed question to MSDN: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/bac37a70-c3b5-453e-a27c-a47a4e18df15/uwpwindows-10-mobile-system32lib-replacement?forum=wpdevelop#bac37a70-c3b5-453e-a27c-a47a4e18df15 But at that time, VirtualAllocFromApp for Windows 10 Mobile dont work! But now, when i tested it in real device, its works! Windows 10 Mobile 10536 Build + maked Jailbreak (i dont know if its needed, but maybe not).

Anyway, i tryied to run a PPSSPP Android version on Project Astoria (Windows 10 Mobile Built in Android Emulator), but its only change screen orientation and shut down.

Anyway, just copy a Visual Studio Project, change it to Windows Universal Projects, made some tweaks, force using of DX11 its will be usageable on Windows Universal Platform.

MobWiMetro commented 8 years ago

@GAMELASTER I am going to port it to UWP on Windows 10(including Mobile). It's not simply wrapping up the project into Windows Universal Projects then it'll work.

  1. Windows 10 doesn't support PAGE_EXECUTE_READWRITE, which makes it inconvenient to do the virtual allocation of memory since the code has to switch between PAGE_EXECUTE and PAGE_READWRITE for the dynarec's work.
  2. Microsoft's ANGLE lib instead of DX11 can be used for the video component. https://github.com/MSOpenTech/angle
  3. The touch screen UI is different from the win32 version, which needs some time to implement.
unknownbrackets commented 8 years ago

@MobWiMetro for item 1, can you swap the memory without damaging it? Basically, in ArmJit::Compile() and possibly Arm64Jit::Compile, etc., you'd mark the region as writable (but not executable), and then swap it back before completing.

You'd also need it initially writable, and then swap it after generating the fixed code. Note that we sometimes "patch" old code and invalidate cache (for example, block linking.) This will all be done inside Compile() - we don't currently ever modify jit anywhere else, afaik.

For item 2, some effort has already been made (I think for Intel cards) in integrating ANGLE. I recommend looking at the forum and asking @Bigpet. It's probably ultimately better long-term to make a DirectX 12 or similar backend, but ANGLE is probably the quickest approach.

For item 3, it should not really be very different, except the input processing. All you need to do is tell PPSSPP about the touches and it will handle the rest already. It's not really different from any platform - here's SDL, and here's iOS.

There are also a few other platform pieces - opening the keyboard, launching the browser, haptic feedback, etc. Here's Blackberry. An important one can be audio - not sure if WASAPI will work as-is from the Windows code.

-[Unknown]

MobWiMetro commented 8 years ago

@unknownbrackets I will try before I can confirm that. Is the machine code generated from the JIT any ARM or Thumb-2 instructions? Windows on ARM only supports Thumb-2. https://msdn.microsoft.com/en-ca/library/dn736986.aspx#Anchor_3

unknownbrackets commented 8 years ago

We don't generate any Thumb instructions in our jits, only ARM. If that documentation still applies to Windows 10, which it probably does, expect problems. We expect the non-compact ARM instruction set to be fully usable on ARM processors right now.

We also of course use the improved ARM instruction set on armv8 (64-bit) CPUs too. This is the first time I've read anything claiming that ARM was "legacy" and Thumb was "the new order."

The vertex jit and texture hashing also use arm code. Some of the fast matrix math also. There may be other places, including some of ffmpeg.

-[Unknown]

MobWiMetro commented 8 years ago

@unknownbrackets FFmpeg has already been ported to Windows 10. https://blogs.windows.com/buildingapps/2015/06/05/using-ffmpeg-in-windows-applications/

Microsoft sets many obstacles for developers. The emitted opcode has to be changed from ARM to Thumb-2.

hrydgard commented 8 years ago

Ugh, that doesn't sound like a fun project. What a ridiculous decision by MS. ARM is just as fast as THUMB2 on pretty much all modern ARM cpus.

Well, this pushes the prospects of PPSSPP on Windows back even further. I'd almost rather wait for Windows ARM to move over to ARM64.

kika123 commented 8 years ago

ARM mode is supported since Windows 10 Mobile, because of the modifications made to make Astoria possible

MobWiMetro commented 8 years ago

@kika123 Where can you find the evidence? Did MS mentioned this anywhere?

gamelaster commented 8 years ago

@MobWiMetro did you still porting this on WP?

kika123 commented 8 years ago

@MobWiMetro the save/restore context routines were modified specifically for this case ;) Astoria is completly based on that capability

MobWiMetro commented 8 years ago

@kika123 Hasn't Astoria been abandoned?

kika123 commented 8 years ago

@MobWiMetro the changes has been kept because of the Linux subsystem in Windows Server 2016, which also runs on ARM

MobWiMetro commented 8 years ago

@kika123 Do you mean the x86-to-ARM just-in-time (JIT) emulator? https://www.petri.com/windows-10-desktop-for-arm-is-in-development

kika123 commented 8 years ago

@MobWiMetro no, that "Bash on Windows" stuff, which is Astoria rebranded AFAIK. x86-on-ARM was there in early Windows 8 on ARM builds

kika123 commented 8 years ago

So it isn't astonishing that it will make a comeback