welford
Posts: 20
Joined: Fri Jun 29, 2012 12:05 am

Quake 1 Port, Optimization Questions

Mon May 20, 2013 11:52 pm

I have written a port of Quake 1 for the Raspberry Pi, I'm using my own wrapper for the graphics calls and currently average 30fps when running the demos but there are some dips to as low as 14 fps when certain things happen on screen (for example the explosions from the grenade launcher). I would be very grateful for any hints on how to make things a bit more consistent.

In my graphics wrapper I malloc a fairly large pool to store vertex data (position, colour, uv coordinates) which is filled between glBegin/glEnd with calls to glVertex3f etc. That data is only sent to the GPU when either the game tries to make a state change that would require the previously held data to be drawn (such as a change in bound textures, or blending mode) or when the buffer gets full.

This lets me batch a lot of drawing calls like when drawing the console, which originally was a call per character to draw a quads but is now only a couple of draw calls.

I have also changed the drawing of Entities (monsters and non static objects in the scene) to use triangles instead of constantly switching between triangles fans and triangle strips. This adds extra data to send to the GPU but greatly reduced the number of draw calls (it went from typically 300~500 per frame to less than 80) and improved performance.

When sending the data I use glBufferSubData followed by glBufferData with null to orphan the vbo and apparently avoid synching ( see http://www.opengl.org/wiki/Buffer_Object_Streaming), this improved the performance too.

I thought glMapBufferOES would allow me to avoid having to malloc and send the data myself, but a very quick attempt at using it completely killed the framerate (to about 1fps) are there any pitfalls i might be running into with this version?

There are still a few things I need to iron out before I put the code up, Quake doesn't seem to be freeing any of the textures it creates, and my kb/mouse input code which worked when I first bought the pi seems to have stopped working.

Thanks for any help.

welford
Posts: 20
Joined: Fri Jun 29, 2012 12:05 am

Re: Quake 1 Port, Optimization Questions

Tue May 21, 2013 4:09 am

Just a few notes:
If I render at the original default resolution 640,480 the frame rate is improved (averaging about 50, with lows spikes at 20-ish)

Having a look at the draw logs, I am doing between 20 and 80 draw calls per frame. the total amount of vertex data transferred over each frame ranges from 53kb to 412kb. So perhaps reducing the amount sent could save me some time.

User avatar
johannesl
Posts: 17
Joined: Thu May 23, 2013 8:38 pm

Re: Quake 1 Port, Optimization Questions

Thu May 23, 2013 8:46 pm

Hi welford.
It would be great to get Quake World running properly on the Raspberry Pi.
I do some hobby game development and might be able to help you.
Do you have the code for your port available somewhere?

User avatar
johannesl
Posts: 17
Joined: Thu May 23, 2013 8:38 pm

Re: Quake 1 Port, Optimization Questions

Thu May 23, 2013 9:05 pm

Some of my earlier OpenGL ES tests have indicated that the GPU might be very fill rate limited. Using a single glDrawArrays call with a single texture, increasing triangle sizes really slows the frame down. Even to the point of 5-10 FPS with less than 100 triangles. This was on 1920x1200 though.

Let me do some more proper tests and get back to you.

welford
Posts: 20
Joined: Fri Jun 29, 2012 12:05 am

Re: Quake 1 Port, Optimization Questions

Fri May 24, 2013 12:44 am

Hey,

I will put the source up on github or somewhere this weekend. It runs very smoothly at the default resolutions (320x240 or 640x480) and it's kind of still playable at 720p but rather than wait to iron out all the framerate issues i'll put it up as it is and maybe others can help improve it.

I'm certain that with a big overhaul, like changing the maps and entities to using VBOs and only sending index data every frame, running at 1080p with a smooth framerate is perfectly possible, but I don't have time to do all that just now. Anyway I'll fix the input code and put the source up somewhere and post the link here.

welford
Posts: 20
Joined: Fri Jun 29, 2012 12:05 am

Re: Quake 1 Port, Optimization Questions

Sun Jun 02, 2013 9:06 pm

Ok, i have put up the current version to github
https://github.com/welford/qurp

I haven't used github before so if someone could try to download and build it i would be very grateful.

Also if anyone is interested in helping to make this please do, i will merge any changes where possible. There is still a lot of work to do, i have highlighted some of the problems with the current version in the readme and on the issues page of the github project.

User avatar
johannesl
Posts: 17
Joined: Thu May 23, 2013 8:38 pm

Re: Quake 1 Port, Optimization Questions

Mon Jun 03, 2013 9:35 pm

Great work getting this far welford!
Thanks for putting it up.

I did some small changes in a forked repo and tested making a pull request to see if we can get this git flow going.

Regarding performance, current version in 320x200 here runs at 34 FPS and 1920x1200 at 11 FPS.. That's "timedemo demo1".. It would be awesome if it was somehow possible to get 30+ FPS even in that huge resolution, but I imagine it will require some really heavy tweaking (and probably texture atlasing).. Btw, 27 draw calls at lowest.. Do you have a good picture of where these occur, and the state changes related?

welford
Posts: 20
Joined: Fri Jun 29, 2012 12:05 am

Re: Quake 1 Port, Optimization Questions

Mon Jun 03, 2013 10:52 pm

I think that the majority of draw calls are due to texture changes.

you can comment out various render paths in R_RenderScene or R_RenderView (both found in gl_rmain.c) to see the performance gains you get from not rendering certain stuff.

Commenting out R_DrawEntitiesOnList will stop all enemies and explosions from drawing. R_DrawWorld for the map and so on.

Maybe I should add a way of logging the draw calls based on what they are drawing, and what state change forced them to draw.

by the way, I think the current build runs with a RGB565 Depth 16 frame buffer, this also provides a small boost to the performance. You can use the command line arguments -rgba32d24 or -rgb24d16 for an improved image quality (see gl_vidrpi.c).

User avatar
johannesl
Posts: 17
Joined: Thu May 23, 2013 8:38 pm

Re: Quake 1 Port, Optimization Questions

Tue Jun 04, 2013 7:02 pm

Anyone who want to see Quake 1 in action on a Raspberry Pi can check out:
http://www.youtube.com/watch?v=em-BNECY_8w

LeSanglier
Posts: 226
Joined: Fri Jan 11, 2013 8:11 pm
Location: In Hell with God
Contact: Website

Re: Quake 1 Port, Optimization Questions

Wed Jun 05, 2013 4:42 pm

Hi,

I have compiled Qurp without problem but when I launch the game the keyboard do not run...
Can you help me ?

Thx.
Mon blog sur le Raspberry Pi : http://framboisepi.fr/
Pour avoir plus de chance d'avoir une réponse à votre question,
allez sur le forum français Rasberry Pi : http://forum.raspfr.org

welford
Posts: 20
Joined: Fri Jun 29, 2012 12:05 am

Re: Quake 1 Port, Optimization Questions

Wed Jun 05, 2013 9:52 pm

The release version crashes as soon as you select new game from the menu. The debug version should let you get into the game.

The port still has various issues that we are working on ( you can help out too :) ) the readme on the github lists most of them.

hykul
Posts: 1
Joined: Tue Apr 01, 2014 1:15 am

Re: Quake 1 Port, Optimization Questions

Tue Apr 01, 2014 1:22 am

Hi, Welford! First, big thanks for doing this, Quake on the Pi is completely rad!!

Now, my question:

I am an artist using your Quake port as part of a project: In a nutshell, I'm having 4 Pis play a custom deathmatch map independently & indefinitely. The look of the map is pretty important, which brings me to my question: Is there a way to hide the top console? (NOT the standard player/weapon/ammo console.) I'd be willing to go in and change some code, if you provide a bit of guidance on the how-to end.

Thanks in advance, and again, great job with this!

mushis
Posts: 5
Joined: Fri Nov 01, 2013 5:57 pm

Re: Quake 1 Port, Optimization Questions

Wed Apr 23, 2014 9:53 am

i don't mean to mess with this, but there's a FTE port for QuakeWorld http://wiki.quakeworld.nu/How_to_server
while we're at it, there's an android client for QuakeWorld as well http://wiki.quakeworld.nu/FTEDroid
carry on :)

welford
Posts: 20
Joined: Fri Jun 29, 2012 12:05 am

Re: Quake 1 Port, Optimization Questions

Sun Jul 20, 2014 3:02 pm

Ok, i have been very busy with life over the last year or so but i should be able to put a bit of time into this port again.

hykul wrote:Is there a way to hide the top console? (NOT the standard player/weapon/ammo console.) I'd be willing to go in and change some code, if you provide a bit of guidance on the how-to end.
The console not hiding has been fixed in the newest source.

The release version bug has also been fixed, which should help it run a bit faster.

Quaker
Posts: 1
Joined: Thu Jul 24, 2014 6:36 pm

Re: Quake 1 Port, Optimization Questions

Thu Jul 24, 2014 6:43 pm

This is *just* what I was looking for.

I'm looking to build a Arcade style machine a'la http://www.arcade-museum.com/game_detai ... me_id=9188 Your port looks like it'll get me most of the way there. In the bugs, you mention that the Keyboard support isn't great, would using the GPIO help me circumvent this issue?

welford
Posts: 20
Joined: Fri Jun 29, 2012 12:05 am

Re: Quake 1 Port, Optimization Questions

Sat Jul 26, 2014 7:41 pm

I think I will just add sdl to handle the input, it will probably be the best solution.

josedavid
Posts: 3
Joined: Tue Dec 04, 2012 8:18 am

Re: Quake 1 Port, Optimization Questions

Tue Sep 02, 2014 11:48 am

Hi, your port seems awesome! I have just tried to build the release version. Compilation is OK, but linking fails:

/usr/bin/ld: /opt/vc/lib/libkhrn_static.a(khrn_client_platform_linux.c.o): undefined reference to symbol '[email protected]@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: ld returned 1 exit status
make.rpi:153: recipe for target 'releasearm/bin/glquake' failed
make[1]: *** [releasearm/bin/glquake] Error 1
make[1]: Leaving directory '/home/pi/quake/qurp-master/WinQuake'
make.rpi:64: recipe for target 'build_release' failed
make: *** [build_release] Error 2


I have just dist-upgraded my system. Maybe some dependency issue, do I have to install any dependencies?

User avatar
johannesl
Posts: 17
Joined: Thu May 23, 2013 8:38 pm

Re: Quake 1 Port, Optimization Questions

Wed Oct 15, 2014 9:39 pm

josedavid wrote:/usr/bin/ld: /opt/vc/lib/libkhrn_static.a(khrn_client_platform_linux.c.o): undefined reference to symbol '[email protected]@GLIBC_2.4'
There's a build fix up for this now at https://github.com/welford/qurp if you look at the open pull requests.

User avatar
stuartheath
Posts: 23
Joined: Mon Jun 18, 2012 9:42 pm

Re: Quake 1 Port, Optimization Questions

Sun Feb 08, 2015 3:56 am

Hi,

I was wondering now the Rpi 2 is out, will any work continue on getting Quake 1 to run nicely on the pi?

Cheers

Stu

User avatar
johannesl
Posts: 17
Joined: Thu May 23, 2013 8:38 pm

Re: Quake 1 Port, Optimization Questions

Mon Feb 09, 2015 5:46 am

For sure there is a lot of people who would like to run Quake on their Raspberry Pi. Let's hope more people like you turn up now here in the forum, and that some have the skills to help.

My Raspberry Pi 2 just arrived so I will give an update later this week on performance.

( I also earlier tried to compile the framebuffer version of quakeforge but directfb seems tricky on the pi )

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: Quake 1 Port, Optimization Questions

Mon Feb 09, 2015 6:55 am

Glad to hear the project is ongoing. I'm a big fan of Quake 1 :)
note: I may or may not know what I'm talking about...

User avatar
yerzmyey
Posts: 49
Joined: Tue Feb 24, 2015 4:48 pm
Contact: Website

Re: Quake 1 Port, Optimization Questions

Thu Mar 12, 2015 9:42 pm

If You guys have anything new for the Pi2 in the subject-matter, I'd be interested too.

That is, however, if You can provide also some idiot-guide for "installation". ;)
http://yerzmyey.i-demo.pl/ ZX/AMIGA/ATARI music
http://ay-riders.speccy.cz/ ZX Spectrum music-band
https://soundcloud.com/yerzmyey ZX/AMIGA/ATARI music
http://ym-digital.i-demo.pl/ ATARI 520ST music-band
http://z80.i-demo.pl/ MP3 archive of Z80 chip music

User avatar
Aaronaurus
Posts: 9
Joined: Tue Jul 14, 2015 5:32 am
Location: England, UK

Re: Quake 1 Port, Optimization Questions

Tue Jul 14, 2015 5:41 am

Hello all. Hello Welford. =)

I just gave this build a go on the Raspberry Pi 2 and it really shows some potential. I only played e1m1 but: In 640x480 and 1920x1080 the performance is pretty good (all things considered). Some major fps drops around particles/sprites/skyboxes, but in areas where it is smooth both resolutions perform well.

Ideally for a quakeworld/multiplayer client, the client would need to be able to run a stable 72fps(?). Whether this is achieveable or not, I do not know.

Personally I'm used to a very minimal quake client. Get rid of sprites, particles, textures. Just give me simple walls/floors/noskies.

Aaron

Nobuo
Posts: 2
Joined: Tue Aug 25, 2015 4:01 am

Re: Quake 1 Port, Optimization Questions

Tue Aug 25, 2015 4:03 am

Hey johannesl! how is going the Quake1 port on the new Raspberry pi 2?

Nobuo
Posts: 2
Joined: Tue Aug 25, 2015 4:01 am

Re: Quake 1 Port, Optimization Questions

Sun Aug 30, 2015 12:01 am

I tried to install step by step on a RPi2. but I'm completely blocked building the game.

So I think this is where the problem is:

When I execute: ./build.sh build_debug

make.rpi:291: recipe for target 'debugarm/glquake/platform.pi.o' failed
make[1]: *** [debugarm/glquake/platform.pi.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/pi/quake/qurp/WinQuake'
make.rpi:50: recipe for target 'build_debug' failed
make: *** [build_debug] Error 2


When I execute: ./build.sh build_release

make.rpi:291: recipe for target 'releasearm/glquake/platform.pi.o' failed
make[1]: *** [releasearm/glquake/platform.pi.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/pi/quake/qurp/WinQuake'
make.rpi:62: recipe for target 'build_release' failed
make: *** [build_release] Error 2


I appreciate any help!

Return to “Graphics programming”