Friday, May 15, 2009

Per Pixel Lighting Isn't Free

I've had a little bit of time to look at X-Plane 930 performance. The data isn't 100% conclusive yet, but one performance issue sticks out like a sore thumb: per-pixel lighting hurts fps.

Now, part of this is that the per-pixel lighting shaders are not yet optimized (and perhaps are not terribly well written). I need to take some time to see if I can get some more performance out of them.

But...per-pixel lighting isn't free - when per-pixel lighting is on, the video card is simply doing a lot more work than it used to. Consider: a typical X-Plane scene might have 250,000 vertices on screen at once.  At a minimum, you have at least 750,000 pixels on screen*.  Make your window bigger and that number goes up - fast!  Turn on 16x FSAA and watch the pixel count get even larger.  So the number of lighting calculations done by your graphics card are at least 3x higher with per-pixel lighting and potentially 50x higher.  Even if your graphics card has a lot of power, that's going to cost a bit.

So one option I am considering is making per-pixel lighting a rendering option. This would allow users who want 922-level fps to simply turn it off. In my tests so far, turning off per-pixel lighting gets fps to within a few percent of 922.

(The only reason to have shaders on but per-pixel lighting off would be to have a cheap version of the reflective water. In the long term I want to limit the number of a la carte rendering settings, but for now it seems reasonable to support v9.00 base configurations through the entire version run.)

* In practice, not every pixel on screen requires full shading, e.g. the sky does not require complex shading.  But some parts of the screen may be shaded multiple times.  This is called "overdraw".  For example, with a runway we pay for our shaders twice - first with the ground underneath the runway, then with the runway itself.

Thursday, May 14, 2009

Who Are You?

Today Lori and I head to France - we will do a bit of site-seeing before the conference, and then Austin and I will go to Italy to work with Sergio.

So first, my email connectivity will be dubious at best for almost an entire month - if you send me a bug report and hear nothing for several weeks, you're just going to have to wait...our internet connection in Italy doesn't really deserve the name "internet connection", and often doesn't work at all. (If you need tech support, contact info at x-plane dot com - you should not be trying to reach me for tech support in the first place!)

I fixed a number of beta bugs this week; Austin will probably cut beta 11 before the conference, and then there will be a pause while we're off the net.  Once we get back, hopefully we can kill 930 off.  (Most of the crash reports I've received turn out to be a single bug in the OBJ-handling code, fixed in beta 11, so hopefully the next beta will be stable.)

Now here is my request to everyone at the conference: please ... go easy on me if I cannot remember who you are.

The tricky thing about a conference like this is that I mostly know people in the X-Plane community by an email address; if I see a face it is only once every few years.  So if I jumble who you are, what you look like, and what you do with X-Plane, I apologize in advance.  It is not a reflection on the merits of what you do, but rather an indication of the disorganized state of my (soon-to-be-jet-lagged) brain.

Monday, May 11, 2009

X-Plane 930 Performance and Crashes

I have received a number of emails bringing up crashes and performance problems in the X-Plane 930 betas - some of the writers are concerned that 930 might be a lame patch, going final with crashes and lousy performance.

To assuage this concern, let me make a few comments on where we are in the beta process, the likely future schedule, and the problems themselves.

The Schedule

X-Plane 930 has been an absurdly long beta. Going into the beta I had the mindset that we should take the beta slowly to have time to discover driver bugs on a wide variety of hardware - why rush and miss something?

I think we took this too far. To run a "slow" beta we have run other development simultaneous to the beta, but that in turn has stretched the beta to epic lengths.

We are starting to try to clamp down and close out the beta now, but it is going to get interrupted again. Austin and I will be traveling to attend the X-Plane conference in France, and from there we will spend two weeks working with Sergio in Italy. Given how rarely we go to Europe, we cannot pass up the opportunity to work with Sergio in person - we have a few problems in the sim where getting the three of us in one room is the best course of action.

Unfortunately our internet connectivity during the trip will be limited, and we can only bring some of our equipment, so closing out the beta while on the road is really not an option. Thus there will be yet another beta delay. Hopefully when we return, we can close the beta out for good.

Performance Problems

I have seen a number of emails regarding framerate with 930. A few notes on framerate and betas:

I try to save framerate for last in a beta. Most performance problems have two possible causes.
  1. We communicate with the video card driver in a way that is fast on our systems but astoundingly slow on other systems. We discover this from slow performance in a particular piece of the code on other hardware.
  2. The new beta does something new that is more expensive than what the old build did, and users have not figured out how to (or do not have a way to) turn this more expensive option off.
The solution to case 1 is to use another driver call; the solution to case 2 is to make sure the rendering options provide a way to turn the feature off. (We simply cannot guarantee that a new, nicer looking feature run without a fps penalty - we can only give you a choice between better visuals and faster fps.)

Either way, framerate work tends to be the last thing on my beta list for this reason: other bug fixes may cause framerate problems, typically in category 1 - that is, a bug fixes makes use of a new driver call that we find out has hurt performance. Thus I try to do all performance fixes at the end of beta when we won't be adding new code.

This means that in practice, I have spent nearly zero time looking at performance. I am just starting that process this week, so it will be a little bit before I find problems.

Unfortunately often performance problems manifest only in the hardware I do not own - despite having a pile of computers in my office (a pile that seems to grow deeper and less manageable every year) there are just a ton of systems out there. So a lot of the performance bugs will get fixed by users trying experiments and reporting back to me - a slow process despite some of the really great efforts by our users.

Crashes

Crashes sometimes are manifestations of gross code defects, but often they fall into the category of driver problems too. I will be working to piece together the puzzle of strange behavior over the next few weeks; usually the solution is to not do some action that we thought was legal but fails in some hardware cases.

Don't Panic

As always, my final message regarding the beta is: don't panic. When it gets quiet over the next few weeks, it is because of travel, and even once Austin and I are back in the office, it will be slightly slow going to piece together problems on hardware other than our own.

Saturday, May 02, 2009

Viva La France!

This year Austin, Sergio and I will be attending the X-Plane 09 Conference this year, near Paris. I am excited by the turn-out - a number of people in the X-Plane community who all do great work will be there, in some cases meeting each other in person for the first time. And there will be cheese!

The conference is officially French, and I must admit, I don't speak a word of the stuff. Fortunately, my beautiful and very patient wife will be there, and she speaks French quite well. So I have asked her to translate the rest of this blog post - a greeting to my French readers.
Bonjour. Ecoutez: Ben croit que je traduis le reste de son article sur ce blog, mais il ne parle pas du tout le français. Lorsqu'on était à Cannes, il a essayé d'apprendre à dire "Le chat est sur la chaise" - ce qui lui a fallu deux semaines! Donc il n'a aucune idée de ce que je suis en train d'écrire, et il ne saura pas non plus si traduis sa présentation correctement ou non.

Lorsqu'il commence sa présentation, je vous expliquerai toutes ses mauvaises habitudes. Est-ce que vous l'avez vu travailler? C'est tellement bizarre! D'habitude il ne porte pas de pantalon. Il s'asseoit devant l'ordinateur en buvant du café et en maudissant les "DSFs" - qu'est-ce que c'est? Je lui ai dit qu'il faut porter un pantalon à la conférence.
I am a very lucky man! I will see you all there.

Friday, May 01, 2009

I Lost My Objects

It seemed like opposite-day at Laminar Research...Austin saying that an error shouldn't quit the sim and me saying the error was never okay, ever. Well, I relented: with X-Plane 930 beta 8, if your scenery pack is missing objects, you can still fly.  Instead you get a single error message like this:

That is the "non-fatal" error dialog box - you will see it only once for each scenery pack with a problem for each time you run the sim.  It means that at least one thing is wrong with your scenery pack, but you need to look at Log.txt to see what's wrong. For example, you might see this in the Log.txt file:
Failed to find resource 'KSBD_example.obj' at 'Custom
Scenery/KSBD Demo Area/KSBD_example.obj'
Failed to find resource 'KSBD_example.obj' at 'Custom
Scenery/KSBD Demo Area/custom objects/KSBD_example.obj'
Failed to find resource 'KSBD_example.obj' at
'Resources/objects/KSBD_example.obj'
Failed to find resource 'KSBD_example.obj'
at 'Resources/KSBD_example.obj'
***Error with scenery file "Custom Scenery/KSBD
Demo Area/Earth nav data/+30-120/+34-118.dsf"
(/Volumes/RAID/code/design/HLutils/Files/io_dsf.cpp: 503.)
Unable to locate object: KSBD_example.obj
In this case, X-Plane couldn't find the object KSBD_example.obj - the sim is also listing all of the places it looked.  Note that only the first location is a good location - the other 3 are legacy search paths that date all the way back to version 6.  It is likely that in the next major version we will trim down our search paths significantly.

A few comments on this whole situation:
  • Authors, do not ignore error messages like the dialog box above - every one of them indicates a condition serious enough that we think you should fix it. Non-fatal errors like these may crash future versions of the sim, or your content may simply stop working.

    If you file a bug against a future version of the sim saying your scenery pack used to work and is now broken, and we find that the old scenery pack had errors, we're not going to fix the bug - we're going to laugh maniacally and dance around you in a circle while singing "told you so".

    Okay - we're very unlikely to do that - but if you have errors in your scenery pack, you're doing something wrong and you need to fix it - treatment of illegal data is not stable between versions of the sim!!

  • I was never very sympathetic to this whole bug report because X-Plane has never accepted a DSF with missing objects - this has been a fatal* error since X-Plane 8.0 when DSF was introduced. So I simply don't understand why there are any scenery packs floating around with objects missing.  Why would you place an object if you don't want to see it? The whole issue strikes me as a total failure to check quality by authors, since even running your pack once would reveal this kind of problem every time!

  • The motivation to make missing objects illegal comes from version 7 and ENVs.  When looking at ENV scenery, I found that a large number of ENV scenery packs were missing at least some of their objects (an error that was silently ignored in ENV). It seemed like we were hiding an error and the result was authors not noticing simple mistakes that might "lose" an object (e.g. renaming an OBJ file).

    Hence the "harsh" policy for DSFs - it was in response to a real problem with existing scenery!

  • You don't need to have missing objects just because you use library objects from another scenery pack (that might not be around).  Use the EXPORT_BACKUP command in your library and a single blank OBJ as a place-holder for the objects you want from a library that might be missing.  OpenSceneryX provides a stub library that authors can include so that their scenery will load without errors even if the OpenSceneryX library is not installed.

Anyway, Austin was right to make the error non-fatal.  Besides being a little bit nicer for users who don't know (or care) why their pack is gone) it lets authors get a list of all missing objects with only one run of the program.

* Fatal?  In computer terms, a fatal error is one that makes the program quit, e.g. the error is fatal because it kills the program.