Me and a few others have been considering porting PCSX2, the PS2 emulator for x86-64, to ARM so it can run on Android/iOS (eventually, hopefully, at some rate). Before doing that I asked PCSX2 devs, but none of them had much to offer on ARM or porting a recompiler, and this is not something I have experience with.
So, I decided to ask those who have successfully done this ... the Dolphin team. What steps or what kind of general outlook was considered for this pretty difficult task?
I mean, was the recompiler code just passed along and switched up to ARM equivalency?
How much optimization was needed to get it going right?
How much rewriting was needed, if any, of the code, like the GUI, GPU stuff, OpenGL for ES, etc.?
Hope this question isn't taken the wrong way ... just open to a friendly discussion here about the process of porting to ARM/Android, etc.
What's with the obsession with Android, it's a bloated single-tasking ad-filled mobile phone platform and X86 Processors are getting smaller every year, I rather PCSX2 focus solely on x86
If you wanna play PCSX2 on Android then develop a streaming client.
It doesn´t matter how the platform is, if he wants to port it, let he do it. And you are really expecting him to wait for X86 CPUs to get smaller so they can fit in tablets, seriously?
x86 CPUs already fit in tablets.
Gir, the idea isn't specifically to have it on Android OS, but to have it on the Android platform. That includes modified versions without any of the google issues, such as Cyanogenmod.
talkingmime: There is only one guy to ask here: Sonicadvance. You'll find him on #dolphin-dev on freenode as "HdkR"
Holy butts. Porting PCSX2 will be quite an undertaking. PCSX2 is one of the most x86 dependent abominations I've ever looked at.
So the first step would be abstracting away as much x86 mess as possible so you can build the core project without an sort of x86 dependency.
Dolphin has a "Generic" build path which strips away anything host specific, so it'll build/run on any platform as long as it's little endian and at least 32bit.
After the year or two of doing that work and getting the code upstreamed, now is when you'll have "real" work to do.
The dynamic recompiler isn't "ported" to ARM, I had to generate a new one with some basic ideas taken from the existing JIT64. You'll have to do the same thing with PCSX2's. Of course the first step would be just getting their interpreter running on a ARM host.
CPU emulation is of course only one step of the problem, GPU emulation is another large bit that will have to be worked out. I haven't really looked in to what the minimum requirements of PCSX2's OpenGL renderer is, but I'm expecting it to use fairly new features, so it'll probably also require a OpenGL ES 3.0 GPU to use it correctly.
Seeing as how their OpenGL renderer was also initially written by ZeroFrog, I would be inclined to think that they are using Nvidia CG still, which would need to be stripped out of their code base and replaced with GLSL.
It'll be a long and painful project, just like Dolphin Mobile is.
To make your life easier in the porting process to ARM, I'd recommend getting a ARM development board that supports OpenGL ES 3.0 and runs Linux. HardKernel should be releasing one in a month or two that does and is a 8 core machine so compiling won't take decades.
Nice answer, Sonicadvance1, but if I am reading you right you are basically saying that it's so heavily x86 directed that a complete rewrite would be the easiest way. I know that trying to insert ARM in place of x86 would be hard, but rewriting too much would make it seem that I'm "redesigning" as opposed to "porting". My goal is to get PCSX2 to work on ARM and then work on intricate stuff more on mobile platforms and such, but if this calls for entire rewrites instead of simply exchanges I don't think I could manage this and feel like I'd be making a PS2 emulator from scratch in that case. In such a case, it's more rewriting than actually porting ... and I can't write a PS2 emulator myself, for the most part, so I'll have to say no to this undertaking.
I wouldn't call it a rewrite. You can split up this work in lots of smaller parts which could get merged and tested separately. This is _much_ easier than writing a complete blob of code without testing anything.
eg first steps:
- search for assembler and replace them with generic code - tons of small parts
- convert cg shaders to glsl (this a bit bigger deal at once, but not that hard)
- move from deprecated gl to core profile (hint: don't mess with VAO, else you'll break osx), so you'll be gles compatible - also lots of small parts
- gui-less mode - maybe needs some more hacks
And so, you've a binary that runs everywhere.
But it isn't that hard to start. It will just take LOTS of time until you're able to run on arm for the first time.
(05-15-2014, 05:42 AM)Gir Wrote: [ -> ]PCSX2 needs to be ported to x64 not Arm.
https://github.com/PCSX2/pcsx2/issues/34
Why would that be a concern? As shown in the thread there's no immediate reason to bother with that, anymore so than there would be to get it on a different platform altogether. 32-bit support will not just disappear, and even if newer OS versions don't support it, what stops you from continuing the use of the old ones, or ones that remain 32-bit? Backwards compatibility likely won't vanish either on microprocessors. Plus, mobile ARM chips are soon to be heading in the 64-bit direction as well, so it's not going to be just a 32-bit problem for Intel. And the devs of PCSX2 tried x64 a while back but discontinued ... most likely it will be x64 some day, but it's not anymore a priority now than forking it and getting it to work on ARM.