
Inori/GPCS4: A Playstation 4 emulator just begin - axiomdata316
https://github.com/Inori/GPCS4
======
0xcde4c3db
It's worth noting that there's another credible PS4 emulator project that's
been around for a while: Orbital [1].

I don't bring this up to suggest that GPCS4 isn't important or innovative, but
to look at the big picture. Orbital is emulating PS4 at a low level and trying
to actually run the PS4 operating system; its first "hype" screenshot was of
the recovery mode prompting to push the PS button on the not-yet-emulated
controller. Following Orbital, I've felt for a while that there would
basically be a two-pronged approach where Orbital enables reverse-engineering
and another emulator leverages those insights to enable a higher-performance
approach for actually playing games. GPCS4 looks a lot like it could become
that other emulator.

[1]
[https://github.com/AlexAltea/orbital](https://github.com/AlexAltea/orbital)

~~~
grawprog
Just out of curiosity, is it really still an emulator when the processor
architecture is the same as the host machine and all you're really doing is
breaking through layers of encryption and lockouts? The ps4 runs on an AMD x86
cpu, would the instruction set not be the same as most PCs?

Not that these aren't still cool projects I'm happy to see being worked on,
but I always think of emulators as emulating one type of architecture on top
of another.

Maybe I'm wrong about all this, but your comment just made me think of this.

~~~
djsumdog
The PS4 isn't a PC at all though. It's missing a bunch of core components, it
has different memory maps and instead of a traditional motherboard chipset, it
has a separate ARM controller that does crazy stuff.

Checkout the Fail0ver video on porting Linux to the PS4. It's really
interesting.

~~~
Vel0cityX
Here's a link to the talk & blog post:
[https://fail0verflow.com/blog/2016/console-
hacking-2016-post...](https://fail0verflow.com/blog/2016/console-
hacking-2016-postscript)

~~~
codetrotter
I remember watching that talk and thinking it was interesting but also that
the guy was a little harsh on Sony. Sure the engineers at Sony may have done
some weird choices in some places, but I think they likely had their reasons
for doing things the way that they did. And at the end of the day, Sony
delivered a console that works well for its intended purpose.

------
kick
This is really neat! It's not very frequent that you see this new of a project
running commercial games out of the gate.

Chinese universities are helping some of the _most_ gifted students I've seen
in years get sunlight here in the West. I can't tell you how many amazing
repos I've found that were by students of Chinese universities that come out
swinging with impressive projects. I wish this was more a trend in the States,
and I have to wonder why it isn't. Possibly because people who speak English
fluently are flooded with blog posts and internet forum comments browbeating
them into avoiding difficult things?

~~~
Vel0cityX
I know the dev and he isn't actually a student, his GitHub profile was just
not updated.

Not to say that there aren't many university students interested in
challenging topics like emulator development - I am one myself and know
several other students in the emudev scene.

Anyway, university doesn't play a big role for most people, you don't learn
many relevant things regarding that there anyway (other than bare essentials).
You learn by doing. Just need to be curious enough to motivate you. That's
true for most programming topics, not just emudev.

------
monocasa
It's not easy to tell, how are they addressing the lack of decryption keys, if
at all? I know you can treat a hacked PS4 as a decryption oracle but that's
sort of a fundamental limitation to emulation, not having the decryption keys
for executables.

~~~
numpad0
Are the game encrypted or signed?

~~~
Vel0cityX
Both games and the firmware are encrypted with several layers of encryption.

------
tluyben2
Not so much fun as ps1,2,3 emulation as this all is too familiar pc tech. Nice
work nonetheless though!

~~~
Vel0cityX
Still gotta emulate a very modern AMD GPU :) Just the shader translation (from
GCN -> SPIR-V so it can be passed to the host gfx driver) is quite a
challenging task actually.

Not to mention the fact that the PS4 has an APU and utilizes Uniform memory
access (UMA). A simplified explanation is that both the GPU and CPU can
read/write the same memory (with _very_ high bandwidth compared to
conventional PCs), which will likely make optimizing high-end games that take
advantage of this difficult.

~~~
miohtama
Can PCs theoretically achieve the same with integrated graphics?

~~~
kevingadd
On paper it would be possible but at the very least the graphics drivers are
going to get in your way (on purpose, for robustness and other reasons) so
you'd need to be running like... a custom kernel module or custom graphics
driver to do this. It's not safe to let a regular user-mode application do
what a PS4 game can do. (The PS4 does security at a hypervisor level instead,
and generally your game is not about to steal credit card numbers from another
user-mode process on the console like it could on a desktop PC)

------
intellix
Wish I could give up my PS4 and switch to my monster of a gaming PC. Only
really looking forward to The Last Of Us 2 and gotta keep it hanging around.
Would be sweet if they supported an official emulator where your games work if
you already bought the hardware

~~~
aasasd
> _where your games work if you already bought the hardware_

I think that's called ‘remote play’.

Also the principle with consoles in the first place is dodging the headaches
of the PCs' configuration zoo. Emulation, ahem, doesn't fit in with this
course.

------
dmos62
Is it conceivable to be able to play PS4 games on other platforms? I.e. what
are the theoretical minimum performance costs of emulating PS4?

~~~
garaetjjte
CPU is just x86-64, so on PC no emulation of that is necessary. More
problematic is translation of custom graphics API (Gnm/Gnmx) and shading
language (PSSL), but similar feats were done before (DirectX->OpenGL wined3d,
DirectX->Vulkan DXVK, etc.) so it should be doable. Game performance might be
hurt because they could have assumed that CPU<>GPU transfers are very fast, on
PS4 it is UMA with single memory.

Though I wonder how feasible would be trying to pull graphics driver from PS4
firmware and make it to work with Radeon HD7000 series GPU.

~~~
Jasper_
PSSL doesn't need to be emulated, it's compiled offline to machine code
binaries for the GPU. The DirectX -> OpenGL wined3d backend is similar
inspirit, but the bytecode (DXBC) in D3D is a much, much higher level, so
better compilation is possible. Untangling machine code into good shading
language is not easy.

Additionally, GNM is a lot lower level than even something like Vulkan, and
you can pass pointers directly between the CPU and GPU, they share the same
memory space. It's this that makes emulating things tricky.

> Though I wonder how feasible would be trying to pull graphics driver from
> PS4 firmware

There is no "graphics driver", in the traditional sense.

~~~
earenndil
> PSSL doesn't need to be emulated

...which makes the job much harder. Shading languages aren't terribly
complicated; implementing a compiler from one to native spir-v/whatever is a
reasonable task. Translating from one shader bytecode to another is a more
involved operation.

------
fulafel
What implementation techniques are used, and which OS/GOUs does it run on?

