Point sprites in XNA Game Studio 4.0

Originally posted to Shawn Hargreaves Blog on MSDN, Monday, March 22, 2010

As of version 4.0, XNA Game Studio no longer supports point sprites.

 

Why?

One big reason, plus two small ones.

The big reason is that DirectX 10 and 11 do not support point sprites, so if we kept them in our API, we would be unable to someday move that API to future DirectX versions. This would violate our "break it good" goal of taking all the pain now to avoid future compatibility breaks.

It is theoretically possible to emulate point sprites using geometry shaders, but after some investigation we concluded this would be:

A smaller reason is that point sprites behave differently on Windows and Xbox, and are not even consistent from one Windows GPU to another (the max size varies, as does the result of TEXCOORD interpolators).

The final reason is that point sprites are slower than triangles on some common graphics chipsets. Hardware manufacturers are sure to keep point sprites around for DirectX 9 compatibility, but they are unlikely to spend much time optimizing what is now a legacy feature, so this performance delta will only grow over time.

 

What can I do instead?

If you are worried about the idea of life without point sprites, the first thing you should know is that this worried me at first, too. But I'm not worried any more. By the end of this article, hopefully you won't be either.

When we looked at why people use point sprites, we found two main purposes:

If you've been reading my blog for long, you probably already heard me mention how the first step in performance work is to measure. Using GS 3.1, I changed the particle sample to draw triangles instead of point sprites. In fact I made three versions:

All three versions used insignificantly tiny amounts of CPU time. The difference was in GPU performance:

A 30% gain from not using point sprites is pretty sweet, but an 80% penalty is painful indeed. I see more people using rotating particles than otherwise, but still... ouch!

One of the best things about my job is the chance to work with amazingly smart people. When I mailed around these performance figures, I was lucky enough that one of the graphics gurus who created the Xbox GPU driver happened to see them, and was sufficiently intrigued to spend some time looking at PIX captures of my test app. Jason discovered that my indexed triangle implementation was bottlenecked by rasterizer performance, specifically by an obscure hardware penalty which occurs if you use both center and centroid mode interpolators with a shader that is fast enough not to be bottlenecked by anything else (an extremely rare situation).

Once identified, it was trivial to remove this bottleneck, which left my indexed triangles bottlenecked by texture fetches, just like the point sprite original. Revised timing data:

Armed with these figures, removing point sprites didn't seem so painful any more.

I can't promise exactly when, but we are working on an updated version of the Particle 3D sample which shows how to use indexed triangle lists, and includes Jason's magic optimization. We will be sure to get this out by the time 4.0 ships, if not before.

Blog index   -   Back to my homepage