WIP games, GPU scaling and BennuGD 2

First of all, let me show you something I'm working on with the guys at Pixelatom.
My TV looks small to you?
Buy me a new one!
Yep, Monkey vs Robots is coming to the Ouya and iOS soon.
The game is basically ready but we need to set up the in-app purchase process in Ouya. You can check the game's site (and purchase the Windows version) here.
Here's the game trailer:
While preparing the port something beautiful happened: SDL2 was released, along with some beautiful docs on porting your SDL 1.2 code to the new version.
The docs include specific info on how to put fully rendered frames (like those BennuGD creates) to screen through a texture AND includes info on how to use SDL's new SDL_WINDOW_FULLSCREEN_DESKTOP mode. What this new fullscreen mode does is that instead of changing your monitor's resolution (that flickering you see when launching some games), it creates a window with your screen's native resolution and then scales your game's contect up to that resolution.
Now, that's pretty much what some BennuGD games -including MvR- do using scale_resolution. The problem with BennuGD's current implementation of scale_resolution is that it works completely by software and that is SLOW.
SDL's implementation, however, works completely by hardware if supported by your platform. I did a quick switch to this new method, and here are some preliminary results:
Performance of MvR in an iPod touch  4G while using BennuGD's current software implementation
Performance of MvR (the same DCB file)  in the same iPod Touch 4G when using hardware scaling
XCode shows you how much time your code spends doing different thigs. The graphs above show a metric of how long it takes your program to render each frame, where is that time spent (CPU vs GPU) and how many FPS it's running at.
When rendering the frame completely by software, we can only render ~10fps and it takes 113ms to render each frame, most of which (101 ms) are CPU time. The game is unplayable.
When switching to GPU scaling, the FPS meter goes up to 21fps*. The total CPU time is now 58ms, 46 of which are CPU time.

That this means is that with the current software scaling in BennuGD, the iPod was spent more than half the time just scaling frames, Not drawing stuff or performing game logic: just making the fully rendered frame look bigger. And when we offload that job to the GPU, well... the GPU time doesn't even increase.

The new code is not yet publicly available, but I'll upload it to my SVN server soon, but you should not have to do anything in your BennuGD code to be able to use the new functionality.

This is, obviously, huge for BennuGD and when presented to the rest of the community sparked a very interesting discussion: we might switch the whole rendering pipeline to SDL2's new SDL_Render API.
This should -finally- give us full hardware rendering on targets that support it (Direct3D in Windows, OpenGL in Linux/Mac, OpenGL ES in iOS/Android) while having a software rendering fallback stack on the rest of targets. Most interestingly, to do this we'll have to actually remove a lot of code from BennuGD, and change some other tiny bits.
We might call this BennuGD 2. I'll keep you posted ;)

* Remember that this is an iPod Touch 4G, which won't be supported by iOS 7, so we can consider this the lowest performance we'll get in any iOS device.

0 komentar:

Post a Comment

Blog Archive