ID3DXFont performance

Started by
6 comments, last by IndirectX 22 years, 1 month ago
Hi, I''m using ID3DXFont to draw some 2D text (like SDK examples do -- fps, vp, etc.) on top of my screen after rendering the scene. Now when I draw help text when F1 is pressed, also like SDK examples do, my framerate drops drastically. I have about 1250 bytes of text in help string, spead over two dozen lines. I''m running this in pure hardware vp on GF3. In 1400x1000x32 window, when the help text is not shown, I get ~60 fps, and when the help text is shown, I get about 38 fps. In 1600x1200x32 fullscreen fps drops from 45 to 30. What gives? I still am drawing the fps statistics, and I call DrawText only once (I concatenate all strings before drawing). If I concatenate that 1K help text without drawing, I get no difference in framerate. I''d appreciate any ideas you might have concerning this issue. Should I just throw ID3DXFont away and use modified CD3DFont? Thanks
---visit #directxdev on afternet <- not just for directx, despite the name
Advertisement
CD3DFont above all others
Learn about game programming!Games Programming in C++: Start to Finish
First of all, creating a font is slow. This has to be moved outside the rendering loop.

If this is already done, displaying text involves a lot of render state changes, and these are also quite slow.


Laurent - http://www.lafaqmfc.com/
My little game: http://www.lafaqmfc.com/starshooter.htm
Also be careful with D3DFont, very buggy!

I have posted some quick fixes here:

http://www.lafaqmfc.com/directx.htm

Hope this helps



Laurent - http://www.lafaqmfc.com/
My little game: http://www.lafaqmfc.com/starshooter.htm
I''m creating my font during init. I would use your D3DFont (in fact I got it some time ago) but I''m not using SDK samples framework, largely due to the fact that I have my interfaces wrapped around DX. It''s also a bit hard for me to understand that class, because it throws a lot of new stuff at me at once. However, I''m considering modifying your class to work with my wrappers (can I do that?)

Any particular reason why D3DFont is faster than ID3DXFont, as I saw people say?
---visit #directxdev on afternet <- not just for directx, despite the name
I think D3DFont is faster because it is simpler.

For example, it works with a partial character set, so the texture is much smaller. It does not try to handle all possible cases.

It should be easy to make D3DFont have the same class interface of ID3DXFont.

Also, ID3DXFont does a lot of stuff at construction time, you have to take great care of not inadvertantly creating temporary objects.


Laurent - http://www.lafaqmfc.com/
My little game: http://www.lafaqmfc.com/starshooter.htm
G''day!

D3DXFont is slower because each string you output is rendered to a texture by GDI, then a quad is used to render it to the display.

D3DFont pre-builds a texture map of all characters, then just renders the ones you need.

D3DXFont is prettier (marginally) and if you need to do fancy text formatting it will do it better. But how many games REALLY need fancy text formatting? Not many, and fewer still at any point where speed is critical.

Another alternative that should be easy to plug into whatever structure you have is here:
http://www.drunkenhyena.com/docs/dhFastFont.phtml

It uses a pre-created bitmap, which has pros and cons, most of which relate to personal preference.

Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
Thank you for replies. I''ll look into your implementations.
---visit #directxdev on afternet <- not just for directx, despite the name

This topic is closed to new replies.

Advertisement