• Announcements

    • SNIPER62

      64-bit is LIVE   03/27/2020

      CHIMM: 64-bit client is now LIVE and Campaign 172 continues!  
Sign in to follow this  
Followers 0
AHWULF

An FPS Primer

28 posts in this topic

In response to everyone's complaints about FPS (frames per second), here is the rundown on what affects FPS, why its crappy, and what is being done about it. This is based on my knowledge of the actual source code, timings done with the Shark tool, and conversations with Rick and Jaeger (who together with Martini and Oliver are the ONLY 4 coders the Rats have).

Here is a diagram of the pieces involved, and which are affected by what hardware limitations. Software limitations I will discuss below.

game.png

The main game loop is a single thread, which means everything happens one-thing-at-a-time. Packets come (and go actually) asynchronously from the network (ie not tied to the game at all). Mouse, keyboard and controller input is similar. For each frame of the game, the user and network input are used to update the game "world", ie movement of vehicles, bullets, your avatar, etc. Sounds are turned on or off but are played in a separate thread (if you have more than 1 CPU this helps a tiny bit). Then the game decides what the contents of the frame should be, gathers up all graphics information (triangles, textures, shader parameters, etc) and begins to pass ALL of them through to the videocard via numerous calls to the OpenGL graphics framework. Note that some video card information is actually cached on the card itself, mostly textures, so its isn't always sent unless the video card RAM is low (as in a 64MB Video card). The video information (mostly triangle or more accurately vertex data) runs through the OpenGL code (maintained by Apple) moves to the videocard driver (maintained by Apple but originally written by the card manufacturer) moves along the video bus (hardware of your Mac) to the video card, where the onboard software (written by the manufacturer and written on NVRAM on the card) processes all the geometric data (vertexes, normals, whatever), rasterizes the geometry along with the texture information and shaders (a kind of video card program) and generates a video frame, which is pushed output to the display.

Note that the last paragraph happens every single "frame", ie at 4 fps this runs 4 times a second, at 100 fps it runs 100 times a second. The game "time" is the same (a second) but its chopped up into whatever number of frames your hardware and software can handle.

OK, so what can go wrong? First, all the green areas are code running on your Mac, so if your Mac is slow this is all going to take a lot longer. Then each box might not be optimal on your hardware, such as the code is optimized for G4s and you have a G5 (for the game code it makes little difference, but its unknown for Apple's code in the OS). You might insufficient RAM for the code to run without paging to disk (the game can hit 800MB at peak) which then brings the slowness of your hard drive into play. The OpenGL framework is maintained by Apple, and optimized for Quartz and Aqua, not gaming. In PC's the opengl is optimized by the card manufacturers, which generally means for 3D games. Apple's implementation is faster for some kinds of 3D but not the areas used in this game. The video drivers are different for each family of video cards, but then again Apple's (the ones supplied by OS updates) are more generic and not necessarily the best for each distinct type of card. Sometimes you can get new drivers from ATI or NVIDIA but even they don't always optimize the Mac drivers as much as they do on the PC. Some video cards are the same for PC and Mac and some have different card software. Sometimes you can burn new code into a video card if the manufacturer supplies a ROM update. Often you have no clue whats running on your video card.

The important thing to note here is that there are many pieces that ALL have to work perfectly to get the ideal FPS. It only takes one thing to drag your performance down the tube. Then no matter what you try to twiddle with nothing can make it faster.

Some specific issues I know of are: the ATI X-800 card driver or ROM code sucks massively. It's apparent that everyone who has one (me included) is getting pathetic performance, no matter how they tweak the configurations or boost their Mac. Another current bog is that the game currently uses NVIDIA's CG framework to program the shaders (as that was all that was available a few years ago), and apparently they choose to update the framework for their video cards way before worrying about ATI's.

OK, so what the heck can we do to make the game go faster? Well, WE can do nothing. The Rats however know all of this quite well and are not just sitting around.

Despite all the bottlenecks with opengl and the drivers, there are features of opengl that can drammatically make things faster, but they require a lot of effort to rewrite the code to use them. The biggest two savings are called Vertex Buffer Objects and the Opengl Shading language. Jaeger has beeing working on these for months. What they mean are instead of sending all of the vertexes to the video card each frame, you "compile" each object (like a tank, soldier, house) once, package it up, and store it on the video card itself with a number. Then when you need to draw, lets say a Tiger, you tell the card "draw a tiger at this point and angle" and then the card draws it, all without having to send the 2500 vertexes each frame. That's a little simplistic but gets the point. The drawback is it takes a lot more video card memory. Forget the 64MB cards then. But now you can draw a hundred Tigers on the screen and bypass all the crappy opengl and driver code to do it (since you've eliminated 95% of the data). Whohoo HooDoo! FPS shoots way up. Plus you can now do much more highly detailed models and still get better FPS. Using the Opengl Shader Language you get away from being dependent on NVIDIA since each manufacturer does their own optimizations.

Of course the game code can also be speed up a bit but its never been the main bottleneck. Even this is being improved as Rick's new "terrain" engine is more detailed and way more optimized.

The bad news is that software development takes time. Rewriting the whole game (well a good chunk anyway) is not easy. I've been writing code for 25 years and I know ugly code when I see it so that makes it much harder to fix and still have it work correctly. No I can't tell you when it will be done; I don't know. Soon!

Patience, grasshopper. Questions welcome, though I don't know everything. After all, this is a volunteer effort on my part, my day job is writing web applications in Java.

Also if you think I don't care, or the Rats don't care, you are entitled to your opinion; but don't expect it will make anything go faster. If we didn't care it wouldn't happen at all.

Here is document on opengl optimization that (rather densely) describes some of what is coming in 1.25 hopefully.

http://developer.apple.com/graphicsimaging/opengl/optimizingdata.html

Share this post


Link to post
Share on other sites

...once again ahwulf.....you rock.

Thank you for this - I wouldn't under stand code if it shot me in the arse, but somehow I understand your explaination. Appreciate the time/effort to explain it...not to mention all the work you're putting in to port to game over to Intel Macs (which I've been hacking through the game with at 5-12 FPS in emulation....but there is a light at the end of the tunnel!!).

S!

VS

Share this post


Link to post
Share on other sites

You see one thing that, we must send feedback to ATI/Nvidia (Apple GPU makers), Apple itself (OpenGL and OS X is theirs) whatever game we play too.

CRS is not Blizzard, they can't phone Apple and say "I want to contact lead coder of OpenGL subsystem" and tell the bugs they get. That phone call won't result in a system wide (OS X point release) update such as 10.3.7 (or 6?) which was something like, whole OS X'es on earth were optimized for World Of Warcraft. :)

That update I sure remember made WW2 online faster as side effect.

I must be thinking very radically but CRS should consider PS/3 port of game. I explained it lots of times but once more: I don't see Apple optimizing their horrible gaming performance soon.

PC people are happy to be robbed by GPU makers every 3 months? I don't think so.

What is the FPS comparison between WoW latest version on Windows and OS X on Mactel? Let me find? It will be a bit hard but it is doable. You know, zealots of both sides.

I can blindly say WoW will perform BETTER on Windows on exact same hardware.

Sad but true...

Share this post


Link to post
Share on other sites

So your Game Loop diagram would imply that the game's physics engine updates differently based on your FPS. Is this true?

Share this post


Link to post
Share on other sites

No, actually it determines your FPS. As far as I know, nothing happens differently based on hardware or software times. If all the little boxes take 100 ms you get 10 fps. If they happen to take 10ms you will get 100 FPS. FPS is the end result of however long each frame took.

Share this post


Link to post
Share on other sites

Perhaps I am not making myself clear. In what you are calling the "Game Loop" does that include the Physics Engine (which calculates all the motion/acceleration of objects in the game)? Wouldn't a physics engine update of 100 times per second versus 1 per second result in wildly different physical outcomes? An example:

A bullet fired from a gun at time 0...

100 updates per second system - the bullet's velocity is recalculated at 10msec intervals so drag is applied correctly, steadily increasing deceleration.

1 update per second system - the bullet's speed is re-calculated after 1 full second during which the bullet moves at full muzzle velocity for the entire second. The system would then apply a huge amount of deceleration for the next second.

The first bullet might have travelled 500m while the second one might have travelled 750m.

Share this post


Link to post
Share on other sites

No the bullets trajectory is independent of how often the frame was generated. Game time is not frame time - its a constant independent of what the engine is doing. In the case of ballistic objects all you need is the initial vector and velocity, and some constants like gravity and wind resistance to know where it will be at any X game time (until they hit something anyway). Objects that have driver for example will be recalculated each time through but they are not moving fast enough for it to be affected by the variable frame duration. In any case bullets fired by people other than you are only approximate in your client, but its very accurate in the shooters where it determines what it hit, which is then passed to your client (you die, for example). That's why you can't spot for people, since you aren't seeing the same trajectory. You might wonder why both of you aren't seeing the same trajectory - its because the number of bits sent to you for each shot aren't enough to represent an accurate initial vector (saves on net bandwidth) but in the shooters client its fully accurate. If they used more bandwidth you might eventually get close to seeing what the shooter sees, but then again all the modem users would be sad.

Share this post


Link to post
Share on other sites

Are you saying, in a round-a-bout way, that for the time being NVIDIA macs have a FPS advantage? And without having to re-read that post (which after a 12-pack becomes slightly confusing, albeit your good job of explaining it, i've already forgotten) that coding is underway to better support ATI cards?

Regardless, S! and continue your works of greatness for us all!

Share this post


Link to post
Share on other sites

NVIDIA cards "may' have a temporary advantage. In the long run everyone's decent card (128, modern) will get faster with the new coding stuff.

Share this post


Link to post
Share on other sites

I've been playing Call of Duty 2 fully maxed out on a MacBook Pro 2 giga maxed out as well. I can't get over how fast and sharp it is. That being said your explanation was most excellent. Sometime knowing why things happen tends to make people a bit more patient. Thanks again.

Share this post


Link to post
Share on other sites

Thanks ahwulf - just knowing that it is of concern for the rats and that they are working toward a solution makes me feel better.

Share this post


Link to post
Share on other sites

Yeah, the original design was fine for the state of opengl and video cards -- in 2001. Now you have way more options but the coding (and recasting of the models) is a bit of work. Apparently it will be in 1.25 or even 1.24.x but not the upcoming version of 1.24 for sure.

Share this post


Link to post
Share on other sites

nice write up. you've confirmed what i thought they were doing all along but never knew how to really explain it :).

you know, once this is all done unity will be an extremely advanced engine. the cry engine just recently started using similar techniques.

will the new loop (once rick is done) be fully threaded? from the reading i've done in the past it has always seemed incredibly difficult to thread the core loop in any game. carmack has spoken on the subject a few times. at the time though he was commenting on traditional SMP systems where latency between the physical CPUs was incredibly difficult to manage.

has dual core made this easier?

Share this post


Link to post
Share on other sites

I'm not sure exactly how far Rick is going with this, but even if the central loop is still a single thread, you can thread most of the bulk stuff like uploading textures, loading data, etc, freeing up more crap for the game itself. We do a little of that with the sound and map code now, but its just 8% or so on my dual G5. The new Core processors are made for MP unlike the older Intel CPU types. G5's do it well too, that was never the issue.

It's possible he might be able to do more threading that I not of, I haven't talked with him about the new stuff lately.

Share this post


Link to post
Share on other sites

OK, I just have to get this off my chest - bare with me, and, please, help me if you can...

I hope this is the right thread for this issue...

I'm a big fan of the game and I have played it for almost 4 years now (save for some mandatory sleeping every now and then). This is my first post to this forum. I haven't had the need to post any Q's before, because either you guys have already posted a solution for my problem (Thank You All!), or the Rats have identified the flaw and corrected it in due time.

I haven't whined during times when the gameplay on the Mac clearly lagged way behind the wintels because as a Mac user since 1986 I very much value the fact that the game at all has been made available for the miniscule platform that the Mac in reality is (marketshare-wise, that is). Also, I have believed that I'm quite a patient man...

But this is simply too much...

During the last few months I haven't been able to get more than 5-8 fps in ANY situation within the game - including offline! My peak fps has been an occasional 2 seconds of 11fps and then the rate has dropped to 6 or something similar again. In effect, the game is unplayable for me. This has been going on for so long and through so many patches that I'm starting to suspect that there's something fundamentally wrong here.

I have tried practically all options I could think of in the setup app as well as all the tips you guys have posted here. I have also tried to copy the posted settings that seem to have worked for some of you. Furthermore, I have read the primer carefully, even though I don't know much about software and hardware architecture (I'm not completely computer illiterate though so I did get the general picture).

But it really seems as if it doesn't matter at all what my settings are... 6fp on average it is...

Now, 15 fps would be quite allright by me - that's what I'm used to having. I have always wished I could get the 25+ some are getting, but 15 would be quite enough right now.

I even factored in this fps issue when buying a new Mac 6 months ago and I specced it up a bit just to help with the gameplay. Well, it didn't seem to help...

My setup is as follows:

PowerMac Quad G5

4 Gb RAM

NVIDIA GeForce 7800GT

I run the latest Tiger and have all the updates.

Now, until the release of the MacPro a couple of weeks ago, this was the fastest Mac available. The amount of RAM I have should be waaay over the game requirements and I have the 2nd fastest vid card available from Apple when the comp was bought. Surely my machine should be able to handle 15fps? Any ideas why it doesn't? Would someone know why the ---- I can't get more than 6 fps on average? And would someone have an idea why it doesn't seem to matter what settings I use? I actually get the same frame rates with all the goodies turned on - water shadings and everything... Anyone out there with a similar hardware setup as mine? What are you getting?

Sorry for the tone, but I'm really frustrated.

My current settings are as follows:

shademode gouraud

bdithering true

bspecular false

texturereduction true

sound primary sound driver

bsoundenable true

b3dsoundenable true

video 1

resolution 1024x768x32x0

bnoframerunahead false

bnolocktorefresh true

gammared 1.000000

gammagreen 1.000000

gammablue 1.000000

bshowinfo true

shadowsizeselect 0

volumemultiplier 1.000000

musicmultiplier 0.642442

hudvisible 2

fogscaleselector 0

maxnumbersounds 64

suppressmuzzlesmoke true

suppressmuzzlelight false

suppresstracersmoke true

lodfieldofview true

lodlimitperframe true

bcursorenabled false

friendlycolor 65280

enemycolor -16777216

squadcolor -256

missioncolor 8388608

missionleadercolor 7925760

language 0

ambientlevel 0

radialclutter false

radialdensity 0.500000

radialradius 0.500000

visplayerlimit 2

fsaasamples 0

fsaahighquality false

soundhighquality true

soundforcestereo false

soundconvertonload true

capturealldisplays true

enableh2oshaders false

postrenderfilter false

grassshader true

normalmaps false

waterreflections false

reflectionupdate 0

wantmessagealert true

usenetworkroute 0

Share this post


Link to post
Share on other sites

I have a dual 2.0 and have the same issues. I don't know what the deal is but these more powerful G5's seem to suck FPS wise. However, the stuff Jaeger and Rick are working on (I HOPE for 1.25 now) will make the bigger badder video cards really fly. I hate too seeing 9-10 fps in towns, but you seeing 5-6 with a quad is bizarre. Ilgaz has the same setup you do and he gets better FPS (I think). Let me this evening post my current config (once I get 1.24) and see if you get anything better. Note again that multi CPUs only get you about 8% above a single CPU. It could be having multiple CPUS with the current codebase actually punishes you FPS wise. Anyone out there have better stats with lesser Macs?

Share this post


Link to post
Share on other sites

1.24 dropped fps to 14-20 fps levels Ahwulf. First time an update causes performance decrease.

There is something wrong and I am sure it is related to people playing the game, the numbers. Closed or Open Beta never had such numbers playing so it was undetected.

I alt tabbed map screen , I see OS assigned a core to it fine (100% cpu usage) but I saw a horrible number there: 980 MB "real" memory usage. I sure remember it was around 650 mb for sure.

Update: If I understand it right, PC guys speak about getting lower FPS and some horrible low "spikes" dropping game to 4-6 fps. I have even seen some guy named it "slideshow".

It doesn't feel like it happens on mac. We get constant lower fps, not some spikes.

Share this post


Link to post
Share on other sites
OK, I just have to get this off my chest - bare with me, and, please, help me if you can...

Here is my file, if its helps any...

shademode gouraud

bdithering false

bspecular true

texturereduction false

sound primary sound driver

bsoundenable true

b3dsoundenable false

video 1

resolution 1680x1050x32x59

bnoframerunahead false

bnolocktorefresh true

gammared 1.000000

gammagreen 1.000000

gammablue 1.000000

bshowinfo true

shadowsizeselect 0

volumemultiplier 0.921512

musicmultiplier 0.000000

hudvisible 2

fogscaleselector 0

maxnumbersounds 128

suppressmuzzlesmoke false

suppressmuzzlelight false

suppresstracersmoke false

lodfieldofview false

lodlimitperframe false

bcursorenabled false

friendlycolor 65280

enemycolor -16777216

squadcolor -256

missioncolor 13352960

missionleadercolor 264965376

language 0

ambientlevel 0

radialclutter false

radialdensity 0.500000

radialradius 0.500000

visplayerlimit 3

fsaasamples 4

fsaahighquality true

soundhighquality true

soundforcestereo false

soundconvertonload true

capturealldisplays false

enableh2oshaders true

postrenderfilter false

grassshader true

normalmaps true

waterreflections true

reflectionupdate 2

wantmessagealert true

usenetworkroute 0

Share this post


Link to post
Share on other sites

Update: If I understand it right, PC guys speak about getting lower FPS and some horrible low "spikes" dropping game to 4-6 fps. I have even seen some guy named it "slideshow".

It doesn't feel like it happens on mac. We get constant lower fps, not some spikes.

I am DEFINITELY experiencing the slideshow spikes of 2-3 fps that I never saw before.

Usually got about 30-50 fps flying. Now spikes down to 2 or 3 -- slideshow indeed. Impossible for flying.

G5 2.5x2, 3GB Ram, Radeon 9600XT 10.4.6

current settings:

shademode gouraud

bdithering true

bspecular true

texturereduction false

sound primary sound driver

bsoundenable true

b3dsoundenable true

video 1

resolution 1680x1050x32x0

bnoframerunahead false

bnolocktorefresh true

gammared 1.000000

gammagreen 1.000000

gammablue 1.000000

bshowinfo false

shadowsizeselect 0

volumemultiplier 0.258721

musicmultiplier 0.000000

hudvisible 2

fogscaleselector 0

maxnumbersounds 16

suppressmuzzlesmoke false

suppressmuzzlelight false

suppresstracersmoke false

lodfieldofview false

lodlimitperframe false

bcursorenabled false

friendlycolor 65280

enemycolor -16777216

squadcolor -256

missioncolor 8388608

missionleadercolor 7925760

language 0

ambientlevel 0

radialclutter false

radialdensity 0.500000

radialradius 0.500000

visplayerlimit 1

fsaasamples 0

fsaahighquality false

soundhighquality true

soundforcestereo false

soundconvertonload true

capturealldisplays true

enableh2oshaders false

postrenderfilter false

grassshader true

normalmaps true

waterreflections false

reflectionupdate 0

wantmessagealert true

usenetworkroute 0

--Unc

Share this post


Link to post
Share on other sites

The amazing thing is, nothing such happened in beta (closed and open) tests so this must have something with "population" playing. Large population triggers something bad hitting FPS.

Weather? Hulks?

Share this post


Link to post
Share on other sites
Here is my file, if its helps any...

Thanks, I tried it but still got max 9 fps and 6-7fps most of the time. As I said before, I believe there's something fundamentally wrong with this, so I guess I'll just have to stay away until there's a new patch.

Share this post


Link to post
Share on other sites

Oops...

I'm coming to this thread a little late but I have noticed a strange symptom.

1) Go to the offline 500m rifle range.

2) Look at the target without using binos and record FPS.

3) Turn 90 degrees right so you are facing the south-side booth partition and record FPS.

I had an FPS of 37 looking at the target. When facing south I was looking at the booth partition so that the partition wall filled my entire view and my FPS increased to only 43.

What's up with such a small increase? I was expecting a much greater increase in FPS. When looking at the partition wall, everything behind the wall should have been culled resulting in a tremendous increase in FPS. IMO, something is very, very wrong with the graphics engine.

Thought this observation might help. s!

Share this post


Link to post
Share on other sites

Very little culling going on, basically its only culling based on the field of view, not much beside. That's why the engine needs to be rewritten (which is being done).

'

BTW I turned OFF normal maps and my fps went back to reasonable levels.

Share this post


Link to post
Share on other sites
BTW I turned OFF normal maps and my fps went back to reasonable levels.

What graphical consequence does this have?

I'm about to fire it up on my Macbook Pro and try it running Winblows. One benefit I see to this is that I can install software for my Saitek x52 :)

And now for something totally different: I've emailed Saitek many times, the coder I've talked with was very honest and polite. Through our exchange of emails he said they are currently writing Vista drivers and it's up to their marketing committee to decide if Mac drivers are ever written, of which, plans are not in the works. He would not disclose the email addys of any marketing personnel.

Ahwulf, you may want to edit and sticky this... I say we get a petition going to either boycott Saitek or request OS X drivers. Obviously they don't care about us, so as it is, why should we buy their products? It'd be nice to see them respond to a niche of existing and potential users who they seem to disregard for the time being....

(btw, I've tried the 3 USB controller programs available said to be a substitute for the Saitek software, and honestly, they are in some way seriously lacking good control for the x52)

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.